1 |
pcg |
1.1 |
#include "rxvtdaemon.h" |
2 |
|
|
|
3 |
|
|
#include <cstdio> |
4 |
|
|
#include <cstdlib> |
5 |
|
|
|
6 |
|
|
#include <unistd.h> |
7 |
|
|
#include <sys/socket.h> |
8 |
|
|
#include <sys/un.h> |
9 |
|
|
|
10 |
|
|
struct client : rxvt_connection { |
11 |
|
|
client (); |
12 |
|
|
}; |
13 |
|
|
|
14 |
|
|
client::client () |
15 |
|
|
{ |
16 |
|
|
if ((fd = socket (PF_LOCAL, SOCK_STREAM, 0)) < 0) |
17 |
|
|
{ |
18 |
|
|
perror ("unable to create listening socket"); |
19 |
|
|
exit (EXIT_FAILURE); |
20 |
|
|
} |
21 |
|
|
|
22 |
|
|
sockaddr_un sa; |
23 |
|
|
|
24 |
|
|
sa.sun_family = AF_UNIX; |
25 |
|
|
strcpy (sa.sun_path, rxvt_connection::unix_sockname ()); |
26 |
|
|
|
27 |
|
|
if (connect (fd, (sockaddr *)&sa, sizeof (sa))) |
28 |
|
|
{ |
29 |
|
|
perror ("unable to bind listening socket"); |
30 |
|
|
exit (EXIT_FAILURE); |
31 |
|
|
} |
32 |
|
|
} |
33 |
|
|
|
34 |
|
|
int |
35 |
|
|
main(int argc, const char *const *argv) |
36 |
|
|
{ |
37 |
|
|
client c; |
38 |
|
|
char buf[PATH_MAX]; |
39 |
|
|
|
40 |
|
|
c.send ("NEW"); |
41 |
|
|
c.send ("DISPLAY"); c.send (getenv ("DISPLAY")); |
42 |
|
|
// instead of getcwd we could opendir(".") and pass the fd for fchdir *g* |
43 |
|
|
c.send ("CWD"); c.send (getcwd (buf, sizeof (buf))); |
44 |
|
|
|
45 |
|
|
c.send ("ARGV"); c.send (argc); |
46 |
|
|
for (int i = 0; i < argc; i++) |
47 |
|
|
c.send (argv[i]); |
48 |
|
|
c.send ("END"); |
49 |
|
|
} |
50 |
|
|
|