… | |
… | |
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" |
24 | #include "rxvtdaemon.h" |
|
|
25 | #include "fdpass.h" |
25 | |
26 | |
26 | #include "rxvt.h" |
27 | #include "rxvt.h" |
27 | |
28 | |
28 | #include <cstdio> |
29 | #include <cstdio> |
29 | #include <cstdlib> |
30 | #include <cstdlib> |
… | |
… | |
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 (rxvt_send_fd (c.fd, cint) < 0) |
|
|
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; |
114 | if (c.recv (success)) |
124 | if (c.recv (success)) |
115 | exit (success ? EXIT_SUCCESS : EXIT_FAILURE); |
125 | exit (success ? EXIT_SUCCESS : EXIT_FAILURE); |
116 | } |
126 | } |
117 | else |
127 | else |
118 | { |
128 | { |
119 | fprintf (stderr, "protocol error: received illegal token '%s'.\n", (const char *)tok); |
129 | fprintf (stderr, "protocol error: received unsupported token '%s'.\n", (const char *)tok); |
120 | break; |
130 | break; |
121 | } |
131 | } |
122 | |
132 | |
123 | return EXIT_FAILURE; |
133 | return EXIT_FAILURE; |
124 | } |
134 | } |