1 | #include <unistd.h> |
|
|
2 | #include <stdint.h> |
1 | #include <stdint.h> |
3 | #include <cstdlib> |
2 | #include <cstdlib> |
4 | #include <cstring> |
3 | #include <cstring> |
|
|
4 | #include <cstdio> |
|
|
5 | |
|
|
6 | #include <unistd.h> |
|
|
7 | #include <sys/utsname.h> |
|
|
8 | #include <limits.h> |
5 | |
9 | |
6 | #include "rxvtdaemon.h" |
10 | #include "rxvtdaemon.h" |
7 | |
11 | |
8 | const char *rxvt_connection::unix_sockname () |
12 | char *rxvt_connection::unix_sockname () |
9 | { |
13 | { |
10 | return "/tmp/rxvtd~"; |
14 | char name[PATH_MAX]; |
|
|
15 | char *path = getenv ("RXVT_SOCKET"); |
|
|
16 | |
|
|
17 | if (!path) |
|
|
18 | { |
|
|
19 | struct utsname u; |
|
|
20 | uname (&u); |
|
|
21 | |
|
|
22 | path = getenv ("HOME"); |
|
|
23 | snprintf (name, PATH_MAX, "%s/.rxvt-%s", |
|
|
24 | path ? path : "/tmp", |
|
|
25 | u.nodename); |
|
|
26 | |
|
|
27 | path = name; |
|
|
28 | } |
|
|
29 | |
|
|
30 | return strdup (path); |
11 | } |
31 | } |
12 | |
32 | |
13 | void rxvt_connection::send (const char *data, int len) |
33 | void rxvt_connection::send (const char *data, int len) |
14 | { |
34 | { |
15 | uint8_t s[2]; |
35 | uint8_t s[2]; |
… | |
… | |
55 | |
75 | |
56 | void rxvt_connection::send (int data) |
76 | void rxvt_connection::send (int data) |
57 | { |
77 | { |
58 | uint8_t s[4]; |
78 | uint8_t s[4]; |
59 | |
79 | |
60 | s[0] = data >> 24; s[1] = data >> 16; s[0] = data >> 8; s[1] = data; |
80 | s[0] = data >> 24; s[1] = data >> 16; s[2] = data >> 8; s[3] = data; |
61 | |
81 | |
62 | write (fd, s, 4); |
82 | write (fd, s, 4); |
63 | } |
83 | } |
64 | |
84 | |
65 | bool rxvt_connection::recv (int &data) |
85 | bool rxvt_connection::recv (int &data) |