ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtc.C
(Generate patch)

Comparing rxvt-unicode/src/rxvtc.C (file contents):
Revision 1.15 by root, Mon Feb 14 20:46:47 2005 UTC vs.
Revision 1.22 by root, Sun Jan 22 16:36:40 2006 UTC

19 * along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 *----------------------------------------------------------------------*/ 21 *----------------------------------------------------------------------*/
22 22
23#include "../config.h" 23#include "../config.h"
24#include "rxvtdaemon.h"
25
26#include "rxvt.h"
27
28#include <cstdio> 24#include <cstdio>
29#include <cstdlib> 25#include <cstdlib>
30#include <cstring> 26#include <cstring>
31#include <csignal> 27#include <csignal>
32 28
33#include <unistd.h> 29#include <unistd.h>
34#include <sys/socket.h> 30#include <sys/socket.h>
35#include <sys/un.h> 31#include <sys/un.h>
36 32
33#include "rxvtdaemon.h"
34#include "libptytty.h"
35
36#include "rxvt.h"
37
37struct client : rxvt_connection { 38struct client : rxvt_connection {
38 client (); 39 client ();
39}; 40};
40 41
41client::client () 42client::client ()
42{ 43{
43 if ((fd = socket (PF_UNIX, SOCK_STREAM, 0)) < 0) 44 if ((fd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0)
44 { 45 {
45 perror ("unable to create communications socket"); 46 perror ("unable to create communications socket");
46 exit (EXIT_FAILURE); 47 exit (EXIT_FAILURE);
47 } 48 }
48 49
84 exit (EXIT_FAILURE); 85 exit (EXIT_FAILURE);
85 } 86 }
86 87
87 c.send ("CWD"), c.send (cwd); 88 c.send ("CWD"), c.send (cwd);
88 89
89 for (char **var = environ; *environ; environ++) 90 for (char **var = environ; *var; var++)
90 c.send ("ENV"), c.send (*environ); 91 c.send ("ENV"), c.send (*var);
91 92
92 const char *base = strrchr (argv[0], '/'); 93 const char *base = strrchr (argv[0], '/');
93 base = base ? base + 1 : argv[0]; 94 base = base ? base + 1 : argv[0];
94 c.send ("ARG"), c.send (strcmp (base, RXVTNAME "c") ? base : RXVTNAME); 95 c.send ("ARG"), c.send (strcmp (base, RXVTNAME "c") ? base : RXVTNAME);
95 96
97 c.send ("ARG"), c.send (argv[i]); 98 c.send ("ARG"), c.send (argv[i]);
98 99
99 c.send ("END"); 100 c.send ("END");
100 101
101 auto_str tok; 102 auto_str tok;
103 int cint;
102 104
103 for (;;) 105 for (;;)
104 if (!c.recv (tok)) 106 if (!c.recv (tok))
105 { 107 {
106 fprintf (stderr, "protocol error: unexpected eof from server.\n"); 108 fprintf (stderr, "protocol error: unexpected eof from server.\n");
107 break; 109 break;
108 } 110 }
109 else if (!strcmp (tok, "MSG") && c.recv (tok)) 111 else if (!strcmp (tok, "MSG") && c.recv (tok))
110 fprintf (stderr, "%s", (const char *)tok); 112 fprintf (stderr, "%s", (const char *)tok);
113 else if (!strcmp (tok, "GETFD") && c.recv (cint))
114 {
115 if (!ptytty::send_fd (c.fd, cint))
116 {
117 fprintf (stderr, "unable to send fd %d: ", cint); perror (0);
118 exit (EXIT_FAILURE);
119 }
120 }
111 else if (!strcmp (tok, "END")) 121 else if (!strcmp (tok, "END"))
112 { 122 {
113 int success; 123 int success;
124
114 if (c.recv (success)) 125 if (c.recv (success))
115 exit (success ? EXIT_SUCCESS : EXIT_FAILURE); 126 exit (success ? EXIT_SUCCESS : EXIT_FAILURE);
116 } 127 }
117 else 128 else
118 { 129 {
119 fprintf (stderr, "protocol error: received illegal token '%s'.\n", (const char *)tok); 130 fprintf (stderr, "protocol error: received unsupported token '%s'.\n", (const char *)tok);
120 break; 131 break;
121 } 132 }
122 133
123 return EXIT_FAILURE; 134 return EXIT_FAILURE;
124} 135}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines