ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtc.C
Revision: 1.2
Committed: Mon Nov 24 19:52:16 2003 UTC (20 years, 6 months ago) by pcg
Content type: text/plain
Branch: MAIN
Changes since 1.1: +4 -4 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
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 pcg 1.2 c.send ("DISPLAY"), c.send (getenv ("DISPLAY"));
42 pcg 1.1 // instead of getcwd we could opendir(".") and pass the fd for fchdir *g*
43 pcg 1.2 c.send ("CWD"), c.send (getcwd (buf, sizeof (buf)));
44 pcg 1.1
45     for (int i = 0; i < argc; i++)
46 pcg 1.2 c.send ("ARG"), c.send (argv[i]);
47    
48 pcg 1.1 c.send ("END");
49     }
50