Mercurial > emacs
comparison lib-src/emacsserver.c @ 470:db84d8d9a1d9
*** empty log message ***
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Sat, 21 Dec 1991 07:03:14 +0000 |
parents | 00dde7fa9e98 |
children | 88a29c720fa7 |
comparison
equal
deleted
inserted
replaced
469:ffa6d5c9b074 | 470:db84d8d9a1d9 |
---|---|
57 | 57 |
58 extern int errno; | 58 extern int errno; |
59 | 59 |
60 main () | 60 main () |
61 { | 61 { |
62 char system_name[32]; | |
62 int s, infd, fromlen; | 63 int s, infd, fromlen; |
63 struct sockaddr_un server, fromunix; | 64 struct sockaddr_un server, fromunix; |
64 char *homedir; | 65 char *homedir; |
65 char *str, string[BUFSIZ], code[BUFSIZ]; | 66 char *str, string[BUFSIZ], code[BUFSIZ]; |
66 FILE *infile; | 67 FILE *infile; |
83 { | 84 { |
84 perror ("socket"); | 85 perror ("socket"); |
85 exit (1); | 86 exit (1); |
86 } | 87 } |
87 server.sun_family = AF_UNIX; | 88 server.sun_family = AF_UNIX; |
88 homedir = getenv ("HOME"); | 89 #ifndef SERVER_HOME_DIR |
89 if (homedir == NULL) | 90 gethostname (system_name, sizeof (system_name)); |
91 sprintf (server.sun_path, "/tmp/esrv%d-%s", geteuid (), system_name); | |
92 | |
93 if (unlink (server.sun_path) == -1 && errno != ENOENT) | |
94 { | |
95 perror ("unlink"); | |
96 exit (1); | |
97 } | |
98 #else | |
99 if ((homedir = getenv ("HOME")) == NULL) | |
90 { | 100 { |
91 fprintf (stderr,"No home directory\n"); | 101 fprintf (stderr,"No home directory\n"); |
92 exit (1); | 102 exit (1); |
93 } | 103 } |
94 sprintf (server.sun_path, "/tmp/esrv%d", geteuid ()); | |
95 | |
96 #if 0 | |
97 strcpy (server.sun_path, homedir); | 104 strcpy (server.sun_path, homedir); |
98 strcat (server.sun_path, "/.emacs_server"); | 105 strcat (server.sun_path, "/.emacs_server"); |
99 #endif | |
100 | |
101 /* Delete anyone else's old server. */ | 106 /* Delete anyone else's old server. */ |
102 unlink (server.sun_path); | 107 unlink (server.sun_path); |
108 #endif | |
109 | |
103 if (bind (s, &server, strlen (server.sun_path) + 2) < 0) | 110 if (bind (s, &server, strlen (server.sun_path) + 2) < 0) |
104 { | 111 { |
105 perror ("bind"); | 112 perror ("bind"); |
106 exit (1); | 113 exit (1); |
107 } | 114 } |
292 while (1) | 299 while (1) |
293 { | 300 { |
294 if ((fromlen = msgrcv (s, msgp, BUFSIZ - 1, 1, 0)) < 0) | 301 if ((fromlen = msgrcv (s, msgp, BUFSIZ - 1, 1, 0)) < 0) |
295 { | 302 { |
296 perror ("msgrcv"); | 303 perror ("msgrcv"); |
304 exit (1); | |
297 } | 305 } |
298 else | 306 else |
299 { | 307 { |
300 msgctl (s, IPC_STAT, &msg_st); | 308 msgctl (s, IPC_STAT, &msg_st); |
301 strncpy (string, msgp->mtext, fromlen); | 309 strncpy (string, msgp->mtext, fromlen); |