|
|
1 | #include "../config.h" |
1 | #include "rxvtdaemon.h" |
2 | #include "rxvtdaemon.h" |
|
|
3 | |
|
|
4 | #include "rxvt.h" |
2 | |
5 | |
3 | #include <cstdio> |
6 | #include <cstdio> |
4 | #include <cstdlib> |
7 | #include <cstdlib> |
5 | |
8 | |
6 | #include <unistd.h> |
9 | #include <unistd.h> |
… | |
… | |
58 | |
61 | |
59 | for (int i = 0; i < argc; i++) |
62 | for (int i = 0; i < argc; i++) |
60 | c.send ("ARG"), c.send (argv[i]); |
63 | c.send ("ARG"), c.send (argv[i]); |
61 | |
64 | |
62 | c.send ("END"); |
65 | c.send ("END"); |
|
|
66 | |
|
|
67 | auto_str tok; |
|
|
68 | |
|
|
69 | for (;;) |
|
|
70 | if (!c.recv (tok)) |
|
|
71 | { |
|
|
72 | fprintf (stderr, "protocol error: unexpected eof from server.\n"); |
|
|
73 | break; |
|
|
74 | } |
|
|
75 | else if (!strcmp (tok, "MSG") && c.recv (tok)) |
|
|
76 | fprintf (stderr, "%s", (const char *)tok); |
|
|
77 | else if (!strcmp (tok, "END")) |
|
|
78 | { |
|
|
79 | int success; |
|
|
80 | if (c.recv (success)) |
|
|
81 | exit (success ? EXIT_SUCCESS : EXIT_FAILURE); |
|
|
82 | } |
|
|
83 | else |
|
|
84 | { |
|
|
85 | fprintf (stderr, "protocol error: received illegal token '%s'.\n", (const char *)tok); |
|
|
86 | break; |
|
|
87 | } |
|
|
88 | |
|
|
89 | return EXIT_FAILURE; |
63 | } |
90 | } |
64 | |
91 | |