Lines 36-43
Link Here
|
36 |
#undef open |
36 |
#undef open |
37 |
#undef close |
37 |
#undef close |
38 |
|
38 |
|
|
|
39 |
#include <stdlib.h> |
40 |
#include <string.h> |
39 |
|
41 |
|
40 |
#if !defined(BSD) && !defined(HAVE_SYSVIPC) |
42 |
#if !defined(HAVE_SOCKETS) && !defined(HAVE_SYSVIPC) |
41 |
#include <stdio.h> |
43 |
#include <stdio.h> |
42 |
|
44 |
|
43 |
main () |
45 |
main () |
Lines 47-55
Link Here
|
47 |
exit (1); |
49 |
exit (1); |
48 |
} |
50 |
} |
49 |
|
51 |
|
50 |
#else /* BSD or HAVE_SYSVIPC */ |
52 |
#else /* HAVE_SOCKETS or HAVE_SYSVIPC */ |
51 |
|
53 |
|
52 |
#if defined (BSD) && ! defined (HAVE_SYSVIPC) |
54 |
#if defined (HAVE_SOCKETS) |
53 |
/* BSD code is very different from SYSV IPC code */ |
55 |
/* BSD code is very different from SYSV IPC code */ |
54 |
|
56 |
|
55 |
#include <sys/file.h> |
57 |
#include <sys/file.h> |
Lines 110-116
Link Here
|
110 |
unlink (server.sun_path); |
112 |
unlink (server.sun_path); |
111 |
#endif |
113 |
#endif |
112 |
|
114 |
|
113 |
if (bind (s, &server, strlen (server.sun_path) + 2) < 0) |
115 |
if (bind (s, (struct sockaddr *)&server, strlen (server.sun_path) + 2) < 0) |
114 |
{ |
116 |
{ |
115 |
perror ("bind"); |
117 |
perror ("bind"); |
116 |
exit (1); |
118 |
exit (1); |
Lines 128-141
Link Here
|
128 |
signal (SIGPIPE, SIG_IGN); |
130 |
signal (SIGPIPE, SIG_IGN); |
129 |
for (;;) |
131 |
for (;;) |
130 |
{ |
132 |
{ |
131 |
int rmask = (1 << s) + 1; |
133 |
fd_set rmask; |
|
|
134 |
FD_ZERO (&rmask); |
135 |
FD_SET (0, &rmask); |
136 |
FD_SET (s, &rmask); |
132 |
if (select (s + 1, &rmask, 0, 0, 0) < 0) |
137 |
if (select (s + 1, &rmask, 0, 0, 0) < 0) |
133 |
perror ("select"); |
138 |
perror ("select"); |
134 |
if (rmask & (1 << s)) /* client sends list of filenames */ |
139 |
if (FD_ISSET (s, &rmask)) /* client sends list of filenames */ |
135 |
{ |
140 |
{ |
136 |
fromlen = sizeof (fromunix); |
141 |
fromlen = sizeof (fromunix); |
137 |
fromunix.sun_family = AF_UNIX; |
142 |
fromunix.sun_family = AF_UNIX; |
138 |
infd = accept (s, &fromunix, &fromlen); /* open socket fd */ |
143 |
infd = accept (s, (struct sockaddr *)&fromunix, &fromlen); |
|
|
144 |
/* open socket fd */ |
139 |
if (infd < 0) |
145 |
if (infd < 0) |
140 |
{ |
146 |
{ |
141 |
if (errno == EMFILE || errno == ENFILE) |
147 |
if (errno == EMFILE || errno == ENFILE) |
Lines 184-190
Link Here
|
184 |
fflush (infile); |
190 |
fflush (infile); |
185 |
continue; |
191 |
continue; |
186 |
} |
192 |
} |
187 |
else if (rmask & 1) /* emacs sends codeword, fd, and string message */ |
193 |
else if (FD_ISSET (0, &rmask)) |
|
|
194 |
/* emacs sends codeword, fd, and string message */ |
188 |
{ |
195 |
{ |
189 |
/* Read command codeword and fd */ |
196 |
/* Read command codeword and fd */ |
190 |
clearerr (stdin); |
197 |
clearerr (stdin); |
Lines 325-330
Link Here
|
325 |
|
332 |
|
326 |
#endif /* SYSV IPC */ |
333 |
#endif /* SYSV IPC */ |
327 |
|
334 |
|
328 |
#endif /* BSD && IPC */ |
335 |
#endif /* HAVE_SOCKETS && IPC */ |
329 |
|
|
|
330 |
|