From: vischne@ibm.net (Victor Schneider)
Subject: Using helper apps to dossify ported Unix programs
24 Oct 1997 09:30:30 -0700
Message-ID: <1.5.4.16.19971024120120.0e5fa6e2.cygnus.gnu-win32@pop1.ibm.net>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
To: gnu-win32@cygnus.com
Cc: lynx-dev@sig.net

One logical thing to do with Unix programs like lynx.exe is to forget about all
the DOSPATH macro code in its source distribution, and compile it as a pure
Unix program working under W95/WNT.  The way to do this is to edit the lynx.cfg
file so that all the file viewers are called using a dossifying launch program
that converts '/' to '\\' on the command line.

Such a program is attached to this letter.  You can observe that this is one of
the few times that it makes much sense to use `WinMain', since the lpCmdLine
parameter allows you to handle variable-length command lines, and the launcher
itself is only about 12KB of executable when compiled from __CYGWIN32__.

Unfortunately, the launcher crashes the cygwin32 dll when used.

One alternative is to keep Cygwin lynx.exe, and compile the launcher under the
Borland compiler.  What you do is delete the c++ winmain from the c++ module
that the latest Borland builder foists on you, and replace it with the code
below.  That way, the executable is only about 107KB.  However, it _doesn't_
crash the b18 cygwin stack when called from cygwin lynx.exe.

Here is the launch program:

#include <windows.h>

#ifdef __CYGWIN32__
#undef  WINAPI
#define WINAPI	STDCALL
#endif

int
WINAPI WinMain (HINSTANCE hInst, HINSTANCE hprev,
			LPSTR lpCmd, int nCmd)
{
  char *last_slash;
  for ( ; ; )
   if ((last_slash = strstr(lpCmd, "/")) != (char *)NULL)
      last_slash[0] = '\\';
   else break;
  /* CreateProcess is more modern to use, but what a nuisance. */
  return WinExec(lpCmd, nCmd);
}

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
