… | |
… | |
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 | #include "fdpass.h" |
|
|
26 | |
|
|
27 | #include "rxvt.h" |
|
|
28 | |
|
|
29 | #include <cstdio> |
24 | #include <cstdio> |
30 | #include <cstdlib> |
25 | #include <cstdlib> |
31 | #include <cstring> |
26 | #include <cstring> |
32 | #include <csignal> |
27 | #include <csignal> |
33 | |
28 | |
34 | #include <unistd.h> |
29 | #include <unistd.h> |
35 | #include <sys/socket.h> |
30 | #include <sys/socket.h> |
36 | #include <sys/un.h> |
31 | #include <sys/un.h> |
37 | |
32 | |
|
|
33 | #include "rxvtdaemon.h" |
|
|
34 | #include "libptytty.h" |
|
|
35 | |
|
|
36 | #include "rxvt.h" |
|
|
37 | |
38 | struct client : rxvt_connection { |
38 | struct client : rxvt_connection { |
39 | client (); |
39 | client (); |
40 | }; |
40 | }; |
41 | |
41 | |
42 | client::client () |
42 | client::client () |
43 | { |
43 | { |
44 | if ((fd = socket (PF_UNIX, SOCK_STREAM, 0)) < 0) |
44 | if ((fd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0) |
45 | { |
45 | { |
46 | perror ("unable to create communications socket"); |
46 | perror ("unable to create communications socket"); |
47 | exit (EXIT_FAILURE); |
47 | exit (EXIT_FAILURE); |
48 | } |
48 | } |
49 | |
49 | |
… | |
… | |
110 | } |
110 | } |
111 | else if (!strcmp (tok, "MSG") && c.recv (tok)) |
111 | else if (!strcmp (tok, "MSG") && c.recv (tok)) |
112 | fprintf (stderr, "%s", (const char *)tok); |
112 | fprintf (stderr, "%s", (const char *)tok); |
113 | else if (!strcmp (tok, "GETFD") && c.recv (cint)) |
113 | else if (!strcmp (tok, "GETFD") && c.recv (cint)) |
114 | { |
114 | { |
115 | if (rxvt_send_fd (c.fd, cint) < 0) |
115 | if (ptytty::send_fd (c.fd, cint) < 0) |
116 | { |
116 | { |
117 | fprintf (stderr, "unable to send fd %d: ", cint); perror (0); |
117 | fprintf (stderr, "unable to send fd %d: ", cint); perror (0); |
118 | exit (EXIT_FAILURE); |
118 | exit (EXIT_FAILURE); |
119 | } |
119 | } |
120 | } |
120 | } |
121 | else if (!strcmp (tok, "END")) |
121 | else if (!strcmp (tok, "END")) |
122 | { |
122 | { |
123 | int success; |
123 | int success; |
|
|
124 | |
124 | if (c.recv (success)) |
125 | if (c.recv (success)) |
125 | exit (success ? EXIT_SUCCESS : EXIT_FAILURE); |
126 | exit (success ? EXIT_SUCCESS : EXIT_FAILURE); |
126 | } |
127 | } |
127 | else |
128 | else |
128 | { |
129 | { |