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