Mercurial > hg > xemacs-beta
changeset 5030:422b4b4fb2a6
Winclient updates
author | Vin Shelton <acs@xemacs.org> |
---|---|
date | Thu, 11 Feb 2010 19:33:50 -0500 |
parents | acf7d1bc0490 |
children | bd3e7db3bdf6 e70a73f9243d 6f2158fa75ed 06dd936cde16 |
files | lib-src/ChangeLog lib-src/winclient.c nt/ChangeLog nt/xemacs.mak |
diffstat | 4 files changed, 80 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/lib-src/ChangeLog Wed Feb 10 23:15:40 2010 +0900 +++ b/lib-src/ChangeLog Thu Feb 11 19:33:50 2010 -0500 @@ -1,3 +1,14 @@ +2010-02-11 Vin Shelton <acs@xemacs.org> + + * winclient.c: Bump connection retries to 20 because some people + have long startup files. + (openConversation): If CreateProcess cannot find + xemacs.exe, try again with the name of the version-specific + executable. This is useful because the cygwin version of XEmacs + doesn't install an xemacs.exe executable. + (parseCommandLine): Fix tracker issue 675 - add current directory + to filenames under cygwin. + 2010-01-26 Ben Wing <ben@xemacs.org> * make-msgfile.lex: Vague hacking on this file, insert a comment
--- a/lib-src/winclient.c Wed Feb 10 23:15:40 2010 +0900 +++ b/lib-src/winclient.c Thu Feb 11 19:33:50 2010 -0500 @@ -32,6 +32,11 @@ #include <ctype.h> #include <errno.h> +#ifdef __CYGWIN__ +#include <stdlib.h> +#include <unistd.h> +#endif + static void error (const char* s1, const char* s2); static void fatal (const char *s1, const char *s2); static void * xmalloc (size_t size); @@ -40,7 +45,7 @@ /* -- Post-Include Defines -------------------------------------------------- */ /* Timeouts & delays */ -#define CONNECT_RETRIES 10 +#define CONNECT_RETRIES 20 #define CONNECT_DELAY 500 /* ms */ #define TRANSACTION_TIMEOUT 5000 /* ms */ #define MAX_INPUT_IDLE_WAIT INFINITE /* ms */ @@ -51,7 +56,8 @@ #define COMMAND_FORMAT "[open(\"%s%s\")]" /* XEmacs program name */ -#define PROGRAM_TO_RUN "xemacs.exe" +#define GENERIC_PROGRAM EMACS_PROGNAME ".exe" +#define VERSIONED_PROGRAM EMACS_PROGNAME "-" EMACS_VERSION ".exe" /* -- Constants ------------------------------------------------------------- */ @@ -107,7 +113,7 @@ HCONV hConv; int ret = 0; UINT uiRet; - + /* Initialise the DDEML library */ uiRet = DdeInitialize (&idInst, (PFNCALLBACK) ddeCallback, @@ -134,7 +140,7 @@ /* Close the conversation */ closeConversation (hConv); } - + DdeUninitialize (idInst); return ret; @@ -164,7 +170,7 @@ goto error; } - + /* Get the topic name */ hszTopic = DdeCreateStringHandle (idInst, TOPIC_NAME, @@ -186,11 +192,13 @@ STARTUPINFO sti; PROCESS_INFORMATION pi; int n; - + /* Try to start the program */ ZeroMemory (&sti, sizeof (sti)); sti.cb = sizeof (sti); - if (!CreateProcess (NULL, PROGRAM_TO_RUN, NULL, NULL, FALSE, 0, + if (!CreateProcess (NULL, GENERIC_PROGRAM, NULL, NULL, FALSE, 0, + NULL, NULL, &sti, &pi) && + !CreateProcess (NULL, VERSIONED_PROGRAM, NULL, NULL, FALSE, 0, NULL, NULL, &sti, &pi)) { MessageBox (NULL, "Could not start process.", @@ -205,12 +213,12 @@ /* Close the handles */ CloseHandle (pi.hThread); CloseHandle (pi.hProcess); - + /* Try to connect */ for (n = 0; n < CONNECT_RETRIES; n++) { Sleep (CONNECT_DELAY); - + hConv = DdeConnect (idInst, hszService, hszTopic, NULL); if (hConv) @@ -232,7 +240,7 @@ DdeFreeStringHandle (idInst, hszTopic); return hConv; - + error: if (hConv) DdeDisconnect (hConv); @@ -268,11 +276,11 @@ { char *buf = NULL; unsigned len; - + /* Calculate the buffer length */ len = strlen (lpszFileName1) + strlen (lpszFileName2) + strlen (COMMAND_FORMAT); - + /* Allocate a buffer */ buf = (char *) xmalloc (len); @@ -286,15 +294,14 @@ /* Build the command */ len = wsprintf (buf, COMMAND_FORMAT, lpszFileName1, lpszFileName2); + len++; - len++; - /* OK. We're connected. Send the message. */ DdeClientTransaction (buf, len, hConv, NULL, 0, XTYP_EXECUTE, TRANSACTION_TIMEOUT, NULL); free (buf); - + return 0; } @@ -319,14 +326,14 @@ /* If this is the end, return NULL */ if (!*p) return NULL; - + /* Remember where we are */ start = p; - + /* Find the next whitespace character outside quotes */ if (*p == '"') all_in_quotes = 1; - + while (*p && !quit) { switch (*p) @@ -339,7 +346,7 @@ case '\\': if (!in_quotes) all_in_quotes = 0; - + p++; if (!*p) @@ -368,13 +375,13 @@ start++; length -= 2; } - + /* Copy */ buf = (char *) xmalloc (length + 1); if (!buf) return NULL; - + strncpy (buf, start, length); buf[length] = '\0'; @@ -405,6 +412,38 @@ /* Retrieve arguments */ while ((arg = getNextArg ((const char**)&lpszCommandLine, &len)) != NULL) { + fullpath = NULL; +#ifdef __CYGWIN__ + /* If the filename is not an absolute path, + add the current directory to the pathname */ + if (*arg != '/') + { + len = pathconf(".", _PC_PATH_MAX); + fullpath = (char *) xmalloc (len+1); + if (!fullpath) + { + MessageBox (NULL, "Not enough memory.", "winclient", + MB_ICONEXCLAMATION | MB_OK); + ret = 1; + break; + } + if (!getcwd(fullpath, (size_t)len)) + { + MessageBox (NULL, "Could not retrieve current directory.", + "winclient", MB_ICONEXCLAMATION | MB_OK); + ret = 1; + break; + } + /* Append trailing slash */ + strcat(fullpath, "/"); + ret = doFile (hConv, fullpath, arg); + } + else + { + /* The arg has already been expanded, so pass it as it is */ + ret = doFile (hConv, "", arg); + } +#else /* First find the canonical path name */ fullpath = filepart = NULL; pathlen = GetFullPathName (arg, 0, fullpath, &filepart); @@ -415,10 +454,7 @@ { MessageBox (NULL, "Not enough memory.", "winclient", MB_ICONEXCLAMATION | MB_OK); - ret = 1; - free (arg); - break; } @@ -448,9 +484,10 @@ FindClose (hFindFile); } - +#endif /* Release the path name buffers */ - free (fullpath); + if (fullpath) + free (fullpath); free (arg); if (ret)
--- a/nt/ChangeLog Wed Feb 10 23:15:40 2010 +0900 +++ b/nt/ChangeLog Thu Feb 11 19:33:50 2010 -0500 @@ -1,3 +1,8 @@ +2010-02-11 Vin Shelton <acs@xemacs.org> + + * xemacs.mak (LIB_SRC_DEFINES): Added PROGRAM_DEFINES to lib_src + compilation options so winclient.c can see them. + 2010-02-03 Jerry James <james@xemacs.org> * xemacs.rc: Add license and copyright boilerplate text for Jonathan
--- a/nt/xemacs.mak Wed Feb 10 23:15:40 2010 +0900 +++ b/nt/xemacs.mak Thu Feb 11 19:33:50 2010 -0500 @@ -1065,7 +1065,7 @@ ###################### lib-src programs -LIB_SRC_DEFINES = -DHAVE_CONFIG_H -DWIN32_NATIVE +LIB_SRC_DEFINES = -DHAVE_CONFIG_H -DWIN32_NATIVE $(PROGRAM_DEFINES) # # Creating config.values to be used by config.el