Mercurial > hg > xemacs-beta
comparison nt/runemacs.c @ 321:19dcec799385 r21-0-58
Import from CVS: tag r21-0-58
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:46:44 +0200 |
parents | c9fe270a4101 |
children | a4f53d9b3154 |
comparison
equal
deleted
inserted
replaced
320:73c75c43c1f2 | 321:19dcec799385 |
---|---|
39 SECURITY_DESCRIPTOR sec_desc; | 39 SECURITY_DESCRIPTOR sec_desc; |
40 PROCESS_INFORMATION child; | 40 PROCESS_INFORMATION child; |
41 int wait_for_child = FALSE; | 41 int wait_for_child = FALSE; |
42 DWORD ret_code = 0; | 42 DWORD ret_code = 0; |
43 char *new_cmdline; | 43 char *new_cmdline; |
44 char *basename; | |
44 char *p; | 45 char *p; |
45 char modname[MAX_PATH]; | 46 char modname[MAX_PATH]; |
46 | 47 |
47 if (!GetModuleFileName (NULL, modname, MAX_PATH)) | 48 if (!GetModuleFileName (NULL, modname, MAX_PATH)) |
48 goto error; | 49 goto error; |
49 if ((p = strrchr (modname, '\\')) == NULL) | 50 if ((p = strrchr (modname, '\\')) == NULL) |
50 goto error; | 51 goto error; |
52 | |
53 basename = alloca(strlen(p) + 1); | |
54 strcpy (basename, p + 1); | |
55 | |
51 *p = 0; | 56 *p = 0; |
52 | 57 |
53 new_cmdline = alloca (MAX_PATH + strlen (cmdline) + 1); | 58 new_cmdline = alloca (MAX_PATH + strlen (cmdline) + 1); |
54 strcpy (new_cmdline, modname); | 59 strcpy (new_cmdline, modname); |
55 | 60 |
88 { | 93 { |
89 struct stat stbuf; | 94 struct stat stbuf; |
90 char sym_link_name[MAX_PATH+1], real_name[MAX_PATH+1]; | 95 char sym_link_name[MAX_PATH+1], real_name[MAX_PATH+1]; |
91 | 96 |
92 strcpy(sym_link_name, new_cmdline); | 97 strcpy(sym_link_name, new_cmdline); |
93 strcat(sym_link_name, "\\xemacs"); | 98 if (strcmp(basename, "rungnuclient.exe") == 0) |
94 if (lstat(sym_link_name, &stbuf) == 0) | 99 strcat(new_cmdline, "\\gnuclient.exe "); |
100 else if (strcmp(basename, "runemacs.exe") == 0) | |
95 { | 101 { |
96 if ((stbuf.st_mode & S_IFLNK) == S_IFLNK) | 102 strcat(sym_link_name, "\\xemacs"); |
103 | |
104 if (lstat(sym_link_name, &stbuf) == 0) | |
97 { | 105 { |
98 if (readlink(sym_link_name, real_name, sizeof(real_name)) == -1) | 106 if ((stbuf.st_mode & S_IFLNK) == S_IFLNK) |
99 { | 107 { |
100 MessageBox (NULL, "Error reading symbolic link for xemacs", | 108 if (readlink(sym_link_name, real_name, sizeof(real_name)) == -1) |
101 "Error", MB_ICONSTOP); | 109 { |
102 return 1; | 110 MessageBox (NULL, "Error reading symbolic link for xemacs", |
111 "Error", MB_ICONSTOP); | |
112 return 1; | |
113 } | |
114 else | |
115 { | |
116 strcat(new_cmdline, "\\"); | |
117 strcat(new_cmdline, real_name); | |
118 strcat(new_cmdline, " "); | |
119 } | |
103 } | 120 } |
104 else | 121 else |
105 { | 122 strcat(new_cmdline, "\\xemacs "); |
106 strcat(new_cmdline, "\\"); | |
107 strcat(new_cmdline, real_name); | |
108 strcat(new_cmdline, " "); | |
109 } | |
110 } | 123 } |
111 else | 124 else |
112 strcat(new_cmdline, "\\xemacs "); | 125 { |
113 } | 126 MessageBox (NULL, "can't locate XEmacs executable", |
114 else | 127 "Error", MB_ICONSTOP); |
115 { | 128 return 1; |
116 MessageBox (NULL, "can't locate XEmacs executable", | 129 } |
117 "Error", MB_ICONSTOP); | |
118 return 1; | |
119 } | 130 } |
120 } | 131 } |
121 #else | 132 #else |
122 strcat (new_cmdline, "\\xemacs.exe "); | 133 if (strcmp(basename, "rungnuclient.exe") == 0) |
134 strcat (new_cmdline, "\\gnuclient.exe "); | |
135 else | |
136 strcat (new_cmdline, "\\xemacs.exe "); | |
123 #endif | 137 #endif |
124 #endif | 138 #endif |
125 | 139 |
126 /* Append original arguments if any; first look for -wait as first | 140 /* Append original arguments if any; first look for -wait as first |
127 argument, and apply that ourselves. */ | 141 argument, and apply that ourselves. */ |
164 else | 178 else |
165 goto error; | 179 goto error; |
166 return (int) ret_code; | 180 return (int) ret_code; |
167 | 181 |
168 error: | 182 error: |
169 MessageBox (NULL, "Could not start XEmacs.", "Error", MB_ICONSTOP); | 183 MessageBox (NULL, "Could not start XEmacs or gnuclient.", "Error", MB_ICONSTOP); |
170 return 1; | 184 return 1; |
171 } | 185 } |