Mercurial > hg > xemacs-beta
comparison nt/runemacs.c @ 371:cc15677e0335 r21-2b1
Import from CVS: tag r21-2b1
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:03:08 +0200 |
parents | a4f53d9b3154 |
children | a300bb07d72d |
comparison
equal
deleted
inserted
replaced
370:bd866891f083 | 371:cc15677e0335 |
---|---|
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; | |
45 char *p; | 44 char *p; |
46 char modname[MAX_PATH]; | 45 char modname[MAX_PATH]; |
47 | 46 |
48 if (!GetModuleFileName (NULL, modname, MAX_PATH)) | 47 if (!GetModuleFileName (NULL, modname, MAX_PATH)) |
49 goto error; | 48 goto error; |
50 if ((p = strrchr (modname, '\\')) == NULL) | 49 if ((p = strrchr (modname, '\\')) == NULL) |
51 goto error; | 50 goto error; |
52 | |
53 basename = alloca(strlen(p) + 1); | |
54 strcpy (basename, p + 1); | |
55 | |
56 *p = 0; | 51 *p = 0; |
57 | 52 |
58 new_cmdline = alloca (MAX_PATH + strlen (cmdline) + 1); | 53 new_cmdline = alloca (MAX_PATH + strlen (cmdline) + 1); |
59 strcpy (new_cmdline, modname); | 54 strcpy (new_cmdline, modname); |
60 | 55 |
93 { | 88 { |
94 struct stat stbuf; | 89 struct stat stbuf; |
95 char sym_link_name[MAX_PATH+1], real_name[MAX_PATH+1]; | 90 char sym_link_name[MAX_PATH+1], real_name[MAX_PATH+1]; |
96 | 91 |
97 strcpy(sym_link_name, new_cmdline); | 92 strcpy(sym_link_name, new_cmdline); |
98 if (strcmp(basename, "rungnuclient.exe") == 0) | 93 strcat(sym_link_name, "\\xemacs"); |
99 strcat(new_cmdline, "\\gnuclient.exe "); | 94 if (lstat(sym_link_name, &stbuf) == 0) |
100 else if (strcmp(basename, "runemacs.exe") == 0) | |
101 { | 95 { |
102 strcat(sym_link_name, "\\xemacs"); | 96 if ((stbuf.st_mode & S_IFLNK) == S_IFLNK) |
103 | |
104 if (lstat(sym_link_name, &stbuf) == 0) | |
105 { | 97 { |
106 if ((stbuf.st_mode & S_IFLNK) == S_IFLNK) | 98 if (readlink(sym_link_name, real_name, sizeof(real_name)) == -1) |
107 { | 99 { |
108 if (readlink(sym_link_name, real_name, sizeof(real_name)) == -1) | 100 MessageBox (NULL, "Error reading symbolic link for xemacs", |
109 { | 101 "Error", MB_ICONSTOP); |
110 MessageBox (NULL, "Error reading symbolic link for xemacs", | 102 return 1; |
111 "Error", MB_ICONSTOP); | |
112 return 1; | |
113 } | |
114 else | |
115 { | |
116 strcat(new_cmdline, "\\"); | |
117 /* #### Horrible kludge to get round 1.1.6 bug in readlink. */ | |
118 p = strrchr (real_name, '.'); | |
119 if (p[1] == 'e' || p[1] == 'E' | |
120 && p[2] == 'x' || p[2] == 'X' | |
121 && p[3] == 'e' || p[3] == 'E') | |
122 p[4] = 0; | |
123 strcat(new_cmdline, real_name); | |
124 strcat(new_cmdline, " "); | |
125 } | |
126 } | 103 } |
127 else | 104 else |
128 strcat(new_cmdline, "\\xemacs "); | 105 { |
106 strcat(new_cmdline, "\\"); | |
107 strcat(new_cmdline, real_name); | |
108 strcat(new_cmdline, " "); | |
109 } | |
129 } | 110 } |
130 else | 111 else |
131 { | 112 strcat(new_cmdline, "\\xemacs "); |
132 MessageBox (NULL, "can't locate XEmacs executable", | 113 } |
133 "Error", MB_ICONSTOP); | 114 else |
134 return 1; | 115 { |
135 } | 116 MessageBox (NULL, "can't locate XEmacs executable", |
117 "Error", MB_ICONSTOP); | |
118 return 1; | |
136 } | 119 } |
137 } | 120 } |
138 #else | 121 #else |
139 if (strcmp(basename, "rungnuclient.exe") == 0) | 122 strcat (new_cmdline, "\\xemacs.exe "); |
140 strcat (new_cmdline, "\\gnuclient.exe "); | |
141 else | |
142 strcat (new_cmdline, "\\xemacs.exe "); | |
143 #endif | 123 #endif |
144 #endif | 124 #endif |
145 | 125 |
146 /* Append original arguments if any; first look for -wait as first | 126 /* Append original arguments if any; first look for -wait as first |
147 argument, and apply that ourselves. */ | 127 argument, and apply that ourselves. */ |
184 else | 164 else |
185 goto error; | 165 goto error; |
186 return (int) ret_code; | 166 return (int) ret_code; |
187 | 167 |
188 error: | 168 error: |
189 MessageBox (NULL, "Could not start XEmacs or gnuclient.", "Error", MB_ICONSTOP); | 169 MessageBox (NULL, "Could not start XEmacs.", "Error", MB_ICONSTOP); |
190 return 1; | 170 return 1; |
191 } | 171 } |