Mercurial > emacs
comparison lib-src/emacsclient.c @ 25261:89be69860eeb
(main): Move the dynamic allocation of
system_name outside of the SERVER_HOME_DIR conditional.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Sat, 14 Aug 1999 04:08:25 +0000 |
parents | f14a11549a64 |
children | 307d2eb37259 |
comparison
equal
deleted
inserted
replaced
25260:0c8c07d1d12f | 25261:89be69860eeb |
---|---|
217 fprintf (stderr, "%s: ", argv[0]); | 217 fprintf (stderr, "%s: ", argv[0]); |
218 perror ("socket"); | 218 perror ("socket"); |
219 exit (1); | 219 exit (1); |
220 } | 220 } |
221 server.sun_family = AF_UNIX; | 221 server.sun_family = AF_UNIX; |
222 | |
223 { | |
224 system_name_length = 32; | |
225 | |
226 while (1) | |
227 { | |
228 system_name = (char *) xmalloc (system_name_length + 1); | |
229 | |
230 /* system_name must be null-terminated string. */ | |
231 system_name[system_name_length] = '\0'; | |
232 | |
233 if (gethostname (system_name, system_name_length) == 0) | |
234 break; | |
235 | |
236 free (system_name); | |
237 system_name_length *= 2; | |
238 } | |
239 } | |
240 | |
222 #ifndef SERVER_HOME_DIR | 241 #ifndef SERVER_HOME_DIR |
223 { | 242 { |
224 struct stat statbfr; | 243 struct stat statbfr; |
225 system_name_length = 32; | |
226 | |
227 while (1) | |
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 | 244 |
241 sprintf (server.sun_path, "/tmp/esrv%d-%s", geteuid (), system_name); | 245 sprintf (server.sun_path, "/tmp/esrv%d-%s", geteuid (), system_name); |
242 | 246 |
243 if (stat (server.sun_path, &statbfr) == -1) | 247 if (stat (server.sun_path, &statbfr) == -1) |
244 { | 248 { |
263 fprintf (stderr, "%s: No home directory\n", argv[0]); | 267 fprintf (stderr, "%s: No home directory\n", argv[0]); |
264 exit (1); | 268 exit (1); |
265 } | 269 } |
266 strcpy (server.sun_path, homedir); | 270 strcpy (server.sun_path, homedir); |
267 strcat (server.sun_path, "/.emacs-server-"); | 271 strcat (server.sun_path, "/.emacs-server-"); |
268 gethostname (system_name, sizeof (system_name)); | |
269 strcat (server.sun_path, system_name); | 272 strcat (server.sun_path, system_name); |
270 #endif | 273 #endif |
271 | 274 |
272 if (connect (s, (struct sockaddr *) &server, strlen (server.sun_path) + 2) | 275 if (connect (s, (struct sockaddr *) &server, strlen (server.sun_path) + 2) |
273 < 0) | 276 < 0) |