The file gswin32c.exe is from Ghostscript 5.10 with two changes: 1. Put standard input in binary mode. 2. Correctly handle spaces in the module name. This patch is needed if you are using Win32 Ghostscript with RedMon. *** dwmainc.cpp Sun Nov 09 04:21:54 1997 --- ../dwmainc.cpp Fri Jan 16 04:20:18 1998 *************** *** 1,4 **** ! /* Copyright (C) 1996, 1997, Russell Lang. All rights reserved. This file is part of Aladdin Ghostscript. --- 1,4 ---- ! /* Copyright (C) 1996-1998, Russell Lang. All rights reserved. This file is part of Aladdin Ghostscript. *************** *** 28,33 **** --- 28,35 ---- #include #include #include + #include + #include extern "C" { #include "gscdefs.h" #define GSREVISION gs_revision *************** *** 60,65 **** --- 62,69 ---- typedef char FAR * FARARGV_PTR; int rc; + setmode(fileno(stdin), O_BINARY); + // load DLL if (gsdll.load(ghInstance, szDllName, GSREVISION)) { char buf[256]; *************** *** 108,162 **** int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int cmdShow) { - #if defined(_MSC_VER) /* MSC doesn't give us _argc and _argv[] so ... */ #define MAXCMDTOKENS 128 ! int _argc=0; ! LPSTR _argv[MAXCMDTOKENS]; ! LPSTR p, q; ! #ifdef __WIN32__ ! _argv[_argc] = "gswin32.exe"; ! #else ! _argv[_argc] = "gswin.exe"; ! #endif ! // Parse command line handling quotes. ! p = lpszCmdLine; ! while (*p) { ! // for each argument ! while ((*p) && (*p == ' ')) ! p++; // skip over leading spaces if (*p == '\042') { ! p++; // skip " ! q = p; ! // scan to end of argument ! // doesn't handle embedded quotes ! while ((*p) && (*p != '\042')) ! p++; ! _argv[++_argc] = q; ! if (*p) ! *p++ = '\0'; ! } ! else if (*p) { ! // delimited by spaces ! q = p; ! while ((*p) && (*p != ' ')) ! p++; ! _argv[++_argc] = q; ! if (*p) ! *p++ = '\0'; } ! } ! _argv[++_argc] = (LPSTR)NULL; ! #endif ! if (hPrevInstance) { ! fputs("Can't run twice", stdout); ! return FALSE; ! } ! /* copy the hInstance into a variable so it can be used */ ! ghInstance = hInstance; ! return new_main(_argc, _argv); } #endif --- 112,191 ---- int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int cmdShow) { #define MAXCMDTOKENS 128 ! // BC++ 4.5 will give us _argc and _argv[], but they will be ! // incorrect if there is a space in the program name. ! // Provide our own parsing code to create argc and argv[]. ! int argc; ! LPSTR argv[MAXCMDTOKENS]; ! LPSTR p; ! char command[256]; ! char *args; ! char *d, *e; ! ! if (hPrevInstance) { ! fputs("Can't run twice", stdout); ! return FALSE; ! } ! ! /* copy the hInstance into a variable so it can be used */ ! ghInstance = hInstance; ! ! argc = 0; ! args = (char *)malloc(lstrlen(lpszCmdLine)+1); ! if (args == (char *)NULL) { ! fprintf(stdout, "Insufficient memory in WinMain()\n"); ! return 1; ! } ! ! // If called with "gswin32c.exe arg1 arg2" ! // lpszCmdLine returns: ! // "arg1 arg2" if called with CreateProcess(NULL, command, ...) ! // "arg2" if called with CreateProcess(command, args, ...) ! // GetCommandLine() returns ! // ""gswin32c.exe" arg1 arg2" ! // if called with CreateProcess(NULL, command, ...) ! // " arg1 arg2" ! // if called with CreateProcess(command, args, ...) ! // Consequently we must use GetCommandLine() ! p = GetCommandLine(); ! ! // Parse command line handling quotes. ! d = args; ! while (*p) { ! // for each argument ! ! if (argc >= MAXCMDTOKENS - 1) ! break; ! ! e = d; ! while ((*p) && (*p != ' ')) { if (*p == '\042') { ! // Remove quotes, skipping over embedded spaces. ! // Doesn't handle embedded quotes. ! p++; ! while ((*p) && (*p != '\042')) ! *d++ =*p++; } ! else ! *d++ = *p; ! if (*p) ! p++; ! } ! *d++ = '\0'; ! argv[argc++] = e; ! while ((*p) && (*p == ' ')) ! p++; // Skip over trailing spaces ! } ! argv[argc] = NULL; ! if (strlen(argv[0]) == 0) { ! GetModuleFileName(hInstance, command, sizeof(command)-1); ! argv[0] = command; ! } ! return new_main(argc, argv); } #endif