… | |
… | |
25 | |
25 | |
26 | #include "rxvt.h" |
26 | #include "rxvt.h" |
27 | |
27 | |
28 | #include <cstdio> |
28 | #include <cstdio> |
29 | #include <cstdlib> |
29 | #include <cstdlib> |
|
|
30 | #include <cstring> |
|
|
31 | #include <csignal> |
30 | |
32 | |
31 | #include <unistd.h> |
33 | #include <unistd.h> |
32 | #include <signal.h> |
|
|
33 | #include <sys/socket.h> |
34 | #include <sys/socket.h> |
34 | #include <sys/un.h> |
35 | #include <sys/un.h> |
35 | |
36 | |
36 | struct client : rxvt_connection { |
37 | struct client : rxvt_connection { |
37 | client (); |
38 | client (); |
… | |
… | |
51 | strcpy (sa.sun_path, sockname); |
52 | strcpy (sa.sun_path, sockname); |
52 | free (sockname); |
53 | free (sockname); |
53 | |
54 | |
54 | if (connect (fd, (sockaddr *)&sa, sizeof (sa))) |
55 | if (connect (fd, (sockaddr *)&sa, sizeof (sa))) |
55 | { |
56 | { |
56 | perror ("unable to connect to rxvtd"); |
57 | perror ("unable to connect to the rxvt-unicode daemon"); |
57 | exit (EXIT_FAILURE); |
58 | exit (EXIT_FAILURE); |
58 | } |
59 | } |
59 | } |
60 | } |
60 | |
61 | |
61 | extern char **environ; |
62 | extern char **environ; |
… | |
… | |
79 | c.send ("CWD"), c.send (getcwd (buf, sizeof (buf))); |
80 | c.send ("CWD"), c.send (getcwd (buf, sizeof (buf))); |
80 | |
81 | |
81 | for (char **var = environ; *environ; environ++) |
82 | for (char **var = environ; *environ; environ++) |
82 | c.send ("ENV"), c.send (*environ); |
83 | c.send ("ENV"), c.send (*environ); |
83 | |
84 | |
|
|
85 | const char *base = strrchr (argv[0], '/'); |
|
|
86 | base = base ? base + 1 : argv[0]; |
|
|
87 | c.send ("ARG"), c.send (strcmp (base, RXVTNAME "c") ? base : RXVTNAME); |
|
|
88 | |
84 | for (int i = 0; i < argc; i++) |
89 | for (int i = 1; i < argc; i++) |
85 | c.send ("ARG"), c.send (argv[i]); |
90 | c.send ("ARG"), c.send (argv[i]); |
86 | |
91 | |
87 | c.send ("END"); |
92 | c.send ("END"); |
88 | |
93 | |
89 | auto_str tok; |
94 | auto_str tok; |