Mercurial > emacs
comparison lib-src/emacsclient.c @ 24084:c0b0893dd5a6
(main): Eliminate arbitrary limit on length of system_name.
(xmalloc): Define unconditionally.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 16 Jan 1999 21:45:10 +0000 |
parents | 2ce0e36402ff |
children | fbd8d10e80bd |
comparison
equal
deleted
inserted
replaced
24083:33b162fe4507 | 24084:c0b0893dd5a6 |
---|---|
144 *q++ = 0; | 144 *q++ = 0; |
145 | 145 |
146 return copy; | 146 return copy; |
147 } | 147 } |
148 | 148 |
149 #ifdef C_ALLOCA | |
150 /* Like malloc but get fatal error if memory is exhausted. */ | 149 /* Like malloc but get fatal error if memory is exhausted. */ |
151 | 150 |
152 char * | 151 char * |
153 xmalloc (size) | 152 xmalloc (size) |
154 unsigned int size; | 153 unsigned int size; |
159 perror ("malloc"); | 158 perror ("malloc"); |
160 exit (1); | 159 exit (1); |
161 } | 160 } |
162 return result; | 161 return result; |
163 } | 162 } |
164 #endif /* C_ALLOCA */ | |
165 | 163 |
166 #if !defined (HAVE_SOCKETS) && !defined (HAVE_SYSVIPC) | 164 #if !defined (HAVE_SOCKETS) && !defined (HAVE_SYSVIPC) |
167 | 165 |
168 main (argc, argv) | 166 main (argc, argv) |
169 int argc; | 167 int argc; |
192 int | 190 int |
193 main (argc, argv) | 191 main (argc, argv) |
194 int argc; | 192 int argc; |
195 char **argv; | 193 char **argv; |
196 { | 194 { |
197 char system_name[32]; | 195 char *system_name; |
196 int system_name_length; | |
198 int s, i; | 197 int s, i; |
199 FILE *out, *in; | 198 FILE *out, *in; |
200 struct sockaddr_un server; | 199 struct sockaddr_un server; |
201 char *homedir, *cwd, *str; | 200 char *homedir, *cwd, *str; |
202 char string[BUFSIZ]; | 201 char string[BUFSIZ]; |
221 } | 220 } |
222 server.sun_family = AF_UNIX; | 221 server.sun_family = AF_UNIX; |
223 #ifndef SERVER_HOME_DIR | 222 #ifndef SERVER_HOME_DIR |
224 { | 223 { |
225 struct stat statbfr; | 224 struct stat statbfr; |
226 | 225 system_name_length = 32; |
227 gethostname (system_name, sizeof (system_name)); | 226 |
228 /* system_name must be null-terminated string */ | 227 while (1) |
229 system_name[sizeof (system_name) - 1] = '\0'; | 228 { |
229 system_name = (char *) xmalloc (system_name_length + 1); | |
230 | |
231 /* system_name must be null-terminated string. */ | |
232 system_name[system_name_length] = '\0'; | |
233 | |
234 if (gethostname (system_name, system_name_length) == 0) | |
235 break; | |
236 | |
237 free (system_name); | |
238 system_name_length *= 2; | |
239 } | |
240 | |
230 sprintf (server.sun_path, "/tmp/esrv%d-%s", geteuid (), system_name); | 241 sprintf (server.sun_path, "/tmp/esrv%d-%s", geteuid (), system_name); |
231 | 242 |
232 if (stat (server.sun_path, &statbfr) == -1) | 243 if (stat (server.sun_path, &statbfr) == -1) |
233 { | 244 { |
234 if (errno == ENOENT) | 245 if (errno == ENOENT) |