X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=nt%2Frunemacs.c;h=1b5d3e19d9df35ccb0504f61fcb2ec881d180928;hb=f09a16897fcf8508c80f8341ba00ef756b8b7486;hp=a516eec6fb9933f0576f1a7cdb4367b6193f10ef;hpb=2e3e3f9ee27fec50f45c282d71eaddf7c673bc56;p=chise%2Fxemacs-chise.git- diff --git a/nt/runemacs.c b/nt/runemacs.c index a516eec..1b5d3e1 100644 --- a/nt/runemacs.c +++ b/nt/runemacs.c @@ -41,6 +41,7 @@ WinMain (HINSTANCE hSelf, HINSTANCE hPrev, LPSTR cmdline, int nShow) int wait_for_child = FALSE; DWORD ret_code = 0; char *new_cmdline; + char *basename; char *p; char modname[MAX_PATH]; @@ -48,6 +49,10 @@ WinMain (HINSTANCE hSelf, HINSTANCE hPrev, LPSTR cmdline, int nShow) goto error; if ((p = strrchr (modname, '\\')) == NULL) goto error; + + basename = alloca(strlen(p) + 1); + strcpy (basename, p + 1); + *p = 0; new_cmdline = alloca (MAX_PATH + strlen (cmdline) + 1); @@ -90,36 +95,45 @@ WinMain (HINSTANCE hSelf, HINSTANCE hPrev, LPSTR cmdline, int nShow) char sym_link_name[MAX_PATH+1], real_name[MAX_PATH+1]; strcpy(sym_link_name, new_cmdline); - strcat(sym_link_name, "\\xemacs"); - if (lstat(sym_link_name, &stbuf) == 0) + if (strcmp(basename, "rungnuclient.exe") == 0) + strcat(new_cmdline, "\\gnuclient.exe "); + else if (strcmp(basename, "runemacs.exe") == 0) { - if ((stbuf.st_mode & S_IFLNK) == S_IFLNK) + strcat(sym_link_name, "\\xemacs"); + + if (lstat(sym_link_name, &stbuf) == 0) { - if (readlink(sym_link_name, real_name, sizeof(real_name)) == -1) + if ((stbuf.st_mode & S_IFLNK) == S_IFLNK) { - MessageBox (NULL, "Error reading symbolic link for xemacs", - "Error", MB_ICONSTOP); - return 1; + if (readlink(sym_link_name, real_name, sizeof(real_name)) == -1) + { + MessageBox (NULL, "Error reading symbolic link for xemacs", + "Error", MB_ICONSTOP); + return 1; + } + else + { + strcat(new_cmdline, "\\"); + strcat(new_cmdline, real_name); + strcat(new_cmdline, " "); + } } else - { - strcat(new_cmdline, "\\"); - strcat(new_cmdline, real_name); - strcat(new_cmdline, " "); - } + strcat(new_cmdline, "\\xemacs "); } else - strcat(new_cmdline, "\\xemacs "); - } - else - { - MessageBox (NULL, "can't locate XEmacs executable", - "Error", MB_ICONSTOP); - return 1; + { + MessageBox (NULL, "can't locate XEmacs executable", + "Error", MB_ICONSTOP); + return 1; + } } } #else - strcat (new_cmdline, "\\xemacs.exe "); + if (strcmp(basename, "rungnuclient.exe") == 0) + strcat (new_cmdline, "\\gnuclient.exe "); + else + strcat (new_cmdline, "\\xemacs.exe "); #endif #endif @@ -166,6 +180,6 @@ WinMain (HINSTANCE hSelf, HINSTANCE hPrev, LPSTR cmdline, int nShow) return (int) ret_code; error: - MessageBox (NULL, "Could not start XEmacs.", "Error", MB_ICONSTOP); + MessageBox (NULL, "Could not start XEmacs or gnuclient.", "Error", MB_ICONSTOP); return 1; }