ben         97/11/16 07:43:20

  Modified:    src      ApacheCore.mak CHANGES Makefile.nt
               src/main conf.h http_main.c util_script.c
               src/os/win32 os.h util_win32.c
  Log:
  Deal with Win32 spawn of the Devil problems. Also add buildmark support
  (I know, I know, these should be separate, but I'm in a hurry and I forgot).
  
  Revision  Changes    Path
  1.21      +138 -65   apachen/src/ApacheCore.mak
  
  Index: ApacheCore.mak
  ===================================================================
  RCS file: /export/home/cvs/apachen/src/ApacheCore.mak,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- ApacheCore.mak    1997/10/20 20:19:11     1.20
  +++ ApacheCore.mak    1997/11/16 15:43:11     1.21
  @@ -28,10 +28,6 @@
   NULL=nul
   !ENDIF 
   
  -CPP=cl.exe
  -MTL=midl.exe
  -RSC=rc.exe
  -
   !IF  "$(CFG)" == "ApacheCore - Win32 Release"
   
   OUTDIR=.\CoreR
  @@ -53,6 +49,7 @@
   CLEAN :
        [EMAIL PROTECTED] "$(INTDIR)\alloc.obj"
        [EMAIL PROTECTED] "$(INTDIR)\buff.obj"
  +     [EMAIL PROTECTED] "$(INTDIR)\buildmark.obj"
        [EMAIL PROTECTED] "$(INTDIR)\explain.obj"
        [EMAIL PROTECTED] "$(INTDIR)\fnmatch.obj"
        [EMAIL PROTECTED] "$(INTDIR)\getopt.obj"
  @@ -102,12 +99,46 @@
   "$(OUTDIR)" :
       if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
   
  +CPP=cl.exe
   CPP_PROJ=/nologo /MD /W3 /GX /O2 /I ".\regex" /I ".\main" /D "WIN32" /D\
    "NDEBUG" /D "_WINDOWS" /Fp"$(INTDIR)\ApacheCore.pch" /YX /Fo"$(INTDIR)\\"\
    /Fd"$(INTDIR)\\" /FD /c 
   CPP_OBJS=.\CoreR/
   CPP_SBRS=.
  +
  +.c{$(CPP_OBJS)}.obj::
  +   $(CPP) @<<
  +   $(CPP_PROJ) $< 
  +<<
  +
  +.cpp{$(CPP_OBJS)}.obj::
  +   $(CPP) @<<
  +   $(CPP_PROJ) $< 
  +<<
  +
  +.cxx{$(CPP_OBJS)}.obj::
  +   $(CPP) @<<
  +   $(CPP_PROJ) $< 
  +<<
  +
  +.c{$(CPP_SBRS)}.sbr::
  +   $(CPP) @<<
  +   $(CPP_PROJ) $< 
  +<<
  +
  +.cpp{$(CPP_SBRS)}.sbr::
  +   $(CPP) @<<
  +   $(CPP_PROJ) $< 
  +<<
  +
  +.cxx{$(CPP_SBRS)}.sbr::
  +   $(CPP) @<<
  +   $(CPP_PROJ) $< 
  +<<
  +
  +MTL=midl.exe
   MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
  +RSC=rc.exe
   BSC32=bscmake.exe
   BSC32_FLAGS=/nologo /o"$(OUTDIR)\ApacheCore.bsc" 
   BSC32_SBRS= \
  @@ -123,6 +154,7 @@
   LINK32_OBJS= \
        "$(INTDIR)\alloc.obj" \
        "$(INTDIR)\buff.obj" \
  +     "$(INTDIR)\buildmark.obj" \
        "$(INTDIR)\explain.obj" \
        "$(INTDIR)\fnmatch.obj" \
        "$(INTDIR)\getopt.obj" \
  @@ -193,6 +225,8 @@
        [EMAIL PROTECTED] "$(INTDIR)\alloc.sbr"
        [EMAIL PROTECTED] "$(INTDIR)\buff.obj"
        [EMAIL PROTECTED] "$(INTDIR)\buff.sbr"
  +     [EMAIL PROTECTED] "$(INTDIR)\buildmark.obj"
  +     [EMAIL PROTECTED] "$(INTDIR)\buildmark.sbr"
        [EMAIL PROTECTED] "$(INTDIR)\explain.obj"
        [EMAIL PROTECTED] "$(INTDIR)\explain.sbr"
        [EMAIL PROTECTED] "$(INTDIR)\fnmatch.obj"
  @@ -287,17 +321,52 @@
   "$(OUTDIR)" :
       if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
   
  +CPP=cl.exe
   CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /I ".\regex" /I ".\main" /D 
"WIN32"\
    /D "_DEBUG" /D "_WINDOWS" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\ApacheCore.pch" 
/YX\
    /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
   CPP_OBJS=.\CoreD/
   CPP_SBRS=.\CoreD/
  +
  +.c{$(CPP_OBJS)}.obj::
  +   $(CPP) @<<
  +   $(CPP_PROJ) $< 
  +<<
  +
  +.cpp{$(CPP_OBJS)}.obj::
  +   $(CPP) @<<
  +   $(CPP_PROJ) $< 
  +<<
  +
  +.cxx{$(CPP_OBJS)}.obj::
  +   $(CPP) @<<
  +   $(CPP_PROJ) $< 
  +<<
  +
  +.c{$(CPP_SBRS)}.sbr::
  +   $(CPP) @<<
  +   $(CPP_PROJ) $< 
  +<<
  +
  +.cpp{$(CPP_SBRS)}.sbr::
  +   $(CPP) @<<
  +   $(CPP_PROJ) $< 
  +<<
  +
  +.cxx{$(CPP_SBRS)}.sbr::
  +   $(CPP) @<<
  +   $(CPP_PROJ) $< 
  +<<
  +
  +MTL=midl.exe
   MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 
  +RSC=rc.exe
   BSC32=bscmake.exe
   BSC32_FLAGS=/nologo /o"$(OUTDIR)\ApacheCore.bsc" 
   BSC32_SBRS= \
        "$(INTDIR)\alloc.sbr" \
        "$(INTDIR)\buff.sbr" \
  +     "$(INTDIR)\buildmark.sbr" \
        "$(INTDIR)\explain.sbr" \
        "$(INTDIR)\fnmatch.sbr" \
        "$(INTDIR)\getopt.sbr" \
  @@ -356,6 +425,7 @@
   LINK32_OBJS= \
        "$(INTDIR)\alloc.obj" \
        "$(INTDIR)\buff.obj" \
  +     "$(INTDIR)\buildmark.obj" \
        "$(INTDIR)\explain.obj" \
        "$(INTDIR)\fnmatch.obj" \
        "$(INTDIR)\getopt.obj" \
  @@ -405,36 +475,6 @@
   
   !ENDIF 
   
  -.c{$(CPP_OBJS)}.obj::
  -   $(CPP) @<<
  -   $(CPP_PROJ) $< 
  -<<
  -
  -.cpp{$(CPP_OBJS)}.obj::
  -   $(CPP) @<<
  -   $(CPP_PROJ) $< 
  -<<
  -
  -.cxx{$(CPP_OBJS)}.obj::
  -   $(CPP) @<<
  -   $(CPP_PROJ) $< 
  -<<
  -
  -.c{$(CPP_SBRS)}.sbr::
  -   $(CPP) @<<
  -   $(CPP_PROJ) $< 
  -<<
  -
  -.cpp{$(CPP_SBRS)}.sbr::
  -   $(CPP) @<<
  -   $(CPP_PROJ) $< 
  -<<
  -
  -.cxx{$(CPP_SBRS)}.sbr::
  -   $(CPP) @<<
  -   $(CPP_PROJ) $< 
  -<<
  -
   
   !IF "$(CFG)" == "ApacheCore - Win32 Release" || "$(CFG)" ==\
    "ApacheCore - Win32 Debug"
  @@ -446,6 +486,7 @@
        ".\main\alloc.h"\
        ".\main\buff.h"\
        ".\main\conf.h"\
  +     ".\main\http_log.h"\
        ".\main\httpd.h"\
        ".\main\multithread.h"\
        ".\os\win32\os.h"\
  @@ -486,6 +527,7 @@
        ".\main\alloc.h"\
        ".\main\buff.h"\
        ".\main\conf.h"\
  +     ".\main\http_log.h"\
        ".\main\http_main.h"\
        ".\main\httpd.h"\
        ".\os\win32\os.h"\
  @@ -503,6 +545,7 @@
        ".\main\alloc.h"\
        ".\main\buff.h"\
        ".\main\conf.h"\
  +     ".\main\http_log.h"\
        ".\main\http_main.h"\
        ".\main\httpd.h"\
        ".\os\win32\os.h"\
  @@ -517,13 +560,36 @@
   
   !ENDIF 
   
  +SOURCE=.\buildmark.c
  +
  +!IF  "$(CFG)" == "ApacheCore - Win32 Release"
  +
  +
  +"$(INTDIR)\buildmark.obj" : $(SOURCE) "$(INTDIR)"
  +
  +
  +!ELSEIF  "$(CFG)" == "ApacheCore - Win32 Debug"
  +
  +
  +"$(INTDIR)\buildmark.obj"    "$(INTDIR)\buildmark.sbr" : $(SOURCE) 
"$(INTDIR)"
  +
  +
  +!ENDIF 
  +
   SOURCE=.\main\explain.c
  -DEP_CPP_EXPLA=\
  -     ".\main\explain.h"\
  -     
   
   !IF  "$(CFG)" == "ApacheCore - Win32 Release"
   
  +DEP_CPP_EXPLA=\
  +     ".\main\alloc.h"\
  +     ".\main\buff.h"\
  +     ".\main\conf.h"\
  +     ".\main\explain.h"\
  +     ".\main\httpd.h"\
  +     ".\os\win32\os.h"\
  +     ".\os\win32\readdir.h"\
  +     ".\regex\regex.h"\
  +     
   
   "$(INTDIR)\explain.obj" : $(SOURCE) $(DEP_CPP_EXPLA) "$(INTDIR)"
        $(CPP) $(CPP_PROJ) $(SOURCE)
  @@ -531,6 +597,16 @@
   
   !ELSEIF  "$(CFG)" == "ApacheCore - Win32 Debug"
   
  +DEP_CPP_EXPLA=\
  +     ".\main\alloc.h"\
  +     ".\main\buff.h"\
  +     ".\main\conf.h"\
  +     ".\main\explain.h"\
  +     ".\main\httpd.h"\
  +     ".\os\win32\os.h"\
  +     ".\os\win32\readdir.h"\
  +     ".\regex\regex.h"\
  +     
   
   "$(INTDIR)\explain.obj"      "$(INTDIR)\explain.sbr" : $(SOURCE) 
$(DEP_CPP_EXPLA)\
    "$(INTDIR)"
  @@ -1986,9 +2062,6 @@
   !ENDIF 
   
   SOURCE=.\os\win32\service.c
  -
  -!IF  "$(CFG)" == "ApacheCore - Win32 Release"
  -
   DEP_CPP_SERVI=\
        ".\main\conf.h"\
        ".\main\multithread.h"\
  @@ -1997,19 +2070,15 @@
        ".\regex\regex.h"\
        
   
  +!IF  "$(CFG)" == "ApacheCore - Win32 Release"
  +
  +
   "$(INTDIR)\service.obj" : $(SOURCE) $(DEP_CPP_SERVI) "$(INTDIR)"
        $(CPP) $(CPP_PROJ) $(SOURCE)
   
   
   !ELSEIF  "$(CFG)" == "ApacheCore - Win32 Debug"
   
  -DEP_CPP_SERVI=\
  -     ".\main\conf.h"\
  -     ".\main\multithread.h"\
  -     ".\os\win32\os.h"\
  -     ".\os\win32\service.h"\
  -     ".\regex\regex.h"\
  -     
   
   "$(INTDIR)\service.obj"      "$(INTDIR)\service.sbr" : $(SOURCE) 
$(DEP_CPP_SERVI)\
    "$(INTDIR)"
  @@ -2027,6 +2096,7 @@
        ".\main\buff.h"\
        ".\main\conf.h"\
        ".\main\http_conf_globals.h"\
  +     ".\main\http_log.h"\
        ".\main\httpd.h"\
        ".\os\win32\os.h"\
        ".\os\win32\readdir.h"\
  @@ -2044,6 +2114,7 @@
        ".\main\buff.h"\
        ".\main\conf.h"\
        ".\main\http_conf_globals.h"\
  +     ".\main\http_log.h"\
        ".\main\httpd.h"\
        ".\os\win32\os.h"\
        ".\os\win32\readdir.h"\
  @@ -2058,6 +2129,9 @@
   !ENDIF 
   
   SOURCE=.\main\util_date.c
  +
  +!IF  "$(CFG)" == "ApacheCore - Win32 Release"
  +
   DEP_CPP_UTIL_D=\
        ".\main\conf.h"\
        ".\main\util_date.h"\
  @@ -2065,15 +2139,18 @@
        ".\regex\regex.h"\
        
   
  -!IF  "$(CFG)" == "ApacheCore - Win32 Release"
  -
  -
   "$(INTDIR)\util_date.obj" : $(SOURCE) $(DEP_CPP_UTIL_D) "$(INTDIR)"
        $(CPP) $(CPP_PROJ) $(SOURCE)
   
   
   !ELSEIF  "$(CFG)" == "ApacheCore - Win32 Debug"
   
  +DEP_CPP_UTIL_D=\
  +     ".\main\conf.h"\
  +     ".\main\util_date.h"\
  +     ".\os\win32\os.h"\
  +     ".\regex\regex.h"\
  +     
   
   "$(INTDIR)\util_date.obj"    "$(INTDIR)\util_date.sbr" : $(SOURCE)\
    $(DEP_CPP_UTIL_D) "$(INTDIR)"
  @@ -2179,21 +2256,26 @@
   !ENDIF 
   
   SOURCE=.\main\util_snprintf.c
  +
  +!IF  "$(CFG)" == "ApacheCore - Win32 Release"
  +
   DEP_CPP_UTIL_SN=\
        ".\main\conf.h"\
        ".\os\win32\os.h"\
        ".\regex\regex.h"\
        
   
  -!IF  "$(CFG)" == "ApacheCore - Win32 Release"
  -
  -
   "$(INTDIR)\util_snprintf.obj" : $(SOURCE) $(DEP_CPP_UTIL_SN) "$(INTDIR)"
        $(CPP) $(CPP_PROJ) $(SOURCE)
   
   
   !ELSEIF  "$(CFG)" == "ApacheCore - Win32 Debug"
   
  +DEP_CPP_UTIL_SN=\
  +     ".\main\conf.h"\
  +     ".\os\win32\os.h"\
  +     ".\regex\regex.h"\
  +     
   
   "$(INTDIR)\util_snprintf.obj"        "$(INTDIR)\util_snprintf.sbr" : 
$(SOURCE)\
    $(DEP_CPP_UTIL_SN) "$(INTDIR)"
  @@ -2203,9 +2285,6 @@
   !ENDIF 
   
   SOURCE=.\os\win32\util_win32.c
  -
  -!IF  "$(CFG)" == "ApacheCore - Win32 Release"
  -
   DEP_CPP_UTIL_W=\
        ".\main\alloc.h"\
        ".\main\buff.h"\
  @@ -2216,21 +2295,15 @@
        ".\regex\regex.h"\
        
   
  +!IF  "$(CFG)" == "ApacheCore - Win32 Release"
  +
  +
   "$(INTDIR)\util_win32.obj" : $(SOURCE) $(DEP_CPP_UTIL_W) "$(INTDIR)"
        $(CPP) $(CPP_PROJ) $(SOURCE)
   
   
   !ELSEIF  "$(CFG)" == "ApacheCore - Win32 Debug"
   
  -DEP_CPP_UTIL_W=\
  -     ".\main\alloc.h"\
  -     ".\main\buff.h"\
  -     ".\main\conf.h"\
  -     ".\main\httpd.h"\
  -     ".\os\win32\os.h"\
  -     ".\os\win32\readdir.h"\
  -     ".\regex\regex.h"\
  -     
   
   "$(INTDIR)\util_win32.obj"   "$(INTDIR)\util_win32.sbr" : $(SOURCE)\
    $(DEP_CPP_UTIL_W) "$(INTDIR)"
  
  
  
  1.515     +9 -6      apachen/src/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /export/home/cvs/apachen/src/CHANGES,v
  retrieving revision 1.514
  retrieving revision 1.515
  diff -u -r1.514 -r1.515
  --- CHANGES   1997/11/16 02:17:01     1.514
  +++ CHANGES   1997/11/16 15:43:12     1.515
  @@ -1,8 +1,11 @@
   Changes with Apache 1.3b3
   
  +  *) WIN32: Work around brain-damaged spawn calls that can't deal
  +     with spaces and slashes.  [Ben Laurie]
  +
     *) WIN32: Fix the code so CGIs can use socket calls on Windows.  
  -     The problem was that certain environment variables needed for
  -     sockets to work under Win32 were not being passed.
  +     The problem was that certain undocumented environment variables
  +      needed for sockets to work under Win32 were not being passed.
        [Frank Faubert <[EMAIL PROTECTED]>]
   
     *) Add a "-V" command line flag to the httpd binary.  This 
  @@ -158,9 +161,9 @@
   
     *) Make single-exe Windows install. [Ben Laurie and Eric Esselink]
   
  -  *) Make CGI work under Win95. [Ben Laurie and Paul Sutton]
  +  *) WIN32: Make CGI work under Win95. [Ben Laurie and Paul Sutton]
   
  -  *) Make index.html and friends work under Win95. [Ben Laurie]
  +  *) WIN32: Make index.html and friends work under Win95. [Ben Laurie]
   
     *) PORT: Solaris 2.4 needs Spencer regex, the system regex is broken.
        [John Line <[EMAIL PROTECTED]>] PR#1321
  @@ -413,7 +416,7 @@
     *) Further enhance aplog_error() to not log filename, line number, and
        errno information when it isn't applicable. [Ken Coar, Dean Gaudet]
   
  -  *) Canonicalise filenames under Win32. Short filenames are
  +  *) WIN32: Canonicalise filenames under Win32. Short filenames are
        converted to long ones. Backslashes are converted to forward
        slashes. Case is converted to lower. Parts of URLs that do not
        correspond to files are left completely alone. [Ben Laurie]
  @@ -821,7 +824,7 @@
        if there is one.  If there isn't one, the behaviour is unchanged.
        [Ken Coar, Roy Fielding, Andrey A. Chernov]
   
  -  *) On Win32, modules can now be dynamically loaded DLLs using the
  +  *) WIN32: Modules can now be dynamically loaded DLLs using the
        LoadModule/LoadFile directives. Note that module DLLs must be
        compiled with the multithreaded DLL version of the runtime library.
        [Alexei Kosut and Ben Laurie]
  
  
  
  1.18      +6 -4      apachen/src/Makefile.nt
  
  Index: Makefile.nt
  ===================================================================
  RCS file: /export/home/cvs/apachen/src/Makefile.nt,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- Makefile.nt       1997/10/10 08:26:31     1.17
  +++ Makefile.nt       1997/11/16 15:43:13     1.18
  @@ -18,10 +18,11 @@
         set CFG=regex - Win32 Release
         nmake /nologo -f regex.mak
        cd ..
  -     set CFG=ApacheCore - Win32 Release
  -     nmake /nologo -f ApacheCore.mak
  -     set CFG=Apache - Win32 Release
  -     nmake /nologo -f Apache.mak
  +      del CoreR\buildmark.obj
  +      set CFG=ApacheCore - Win32 Release
  +      nmake /nologo -f ApacheCore.mak
  +      set CFG=Apache - Win32 Release
  +      nmake /nologo -f Apache.mak
        cd os\win32
         set CFG=ApacheModuleStatus - Win32 Release
         nmake /nologo -f ApacheModuleStatus.mak
  @@ -56,6 +57,7 @@
         set CFG=regex - Win32 Debug
         nmake /nologo -f regex.mak
        cd ..
  +      del CoreD\buildmark.obj
         set CFG=ApacheCore - Win32 Debug
         nmake /nologo -f ApacheCore.mak
         set CFG=Apache - Win32 Debug
  
  
  
  1.161     +2 -0      apachen/src/main/conf.h
  
  Index: conf.h
  ===================================================================
  RCS file: /export/home/cvs/apachen/src/main/conf.h,v
  retrieving revision 1.160
  retrieving revision 1.161
  diff -u -r1.160 -r1.161
  --- conf.h    1997/11/13 17:05:16     1.160
  +++ conf.h    1997/11/16 15:43:15     1.161
  @@ -63,6 +63,8 @@
   #include <sys/stat.h>
   
   #ifdef WIN32
  +/* include process.h first so we can override spawn[lv]e* properly */
  +#include <process.h>
   #include "../os/win32/os.h"
   #else
   #include "os.h"
  
  
  
  1.252     +0 -4      apachen/src/main/http_main.c
  
  Index: http_main.c
  ===================================================================
  RCS file: /export/home/cvs/apachen/src/main/http_main.c,v
  retrieving revision 1.251
  retrieving revision 1.252
  diff -u -r1.251 -r1.252
  --- http_main.c       1997/11/15 19:04:51     1.251
  +++ http_main.c       1997/11/16 15:43:16     1.252
  @@ -2647,9 +2647,7 @@
   #else
       printf("Server version \"%s\"\n", SERVER_VERSION);
   #endif
  -#ifndef WIN32
       printf("Server built:  %s\n", SERVER_BUILT);
  -#endif
       printf("Server compiled with....\n");
   #ifdef BIG_SECURITY_HOLE
       printf(" -D BIG_SECURITY_HOLE\n");
  @@ -4325,9 +4323,7 @@
            break;
        case 'v':
            printf("Server version %s.\n", SERVER_VERSION);
  -#ifndef WIN32
            printf("Server built:  %s\n", SERVER_BUILT);
  -#endif
            exit(0);
        case 'V':
            show_compile_settings();
  
  
  
  1.84      +0 -7      apachen/src/main/util_script.c
  
  Index: util_script.c
  ===================================================================
  RCS file: /export/home/cvs/apachen/src/main/util_script.c,v
  retrieving revision 1.83
  retrieving revision 1.84
  diff -u -r1.83 -r1.84
  --- util_script.c     1997/11/12 00:50:44     1.83
  +++ util_script.c     1997/11/16 15:43:17     1.84
  @@ -680,7 +680,6 @@
        int i, sz;
        char *dot;
        char *exename;
  -     char *s;
        int is_exe = 0;
   
        interpreter[0] = 0;
  @@ -745,12 +744,6 @@
   
            }
        }
  -     /* FIXME: Probably ought to do this in another buffer - Ben
  -      * This really annoys me - Win95 (and not NT) spawn[vl]e don't 
  -         * like '/'! - Ben */
  -     for (s = r->filename; *s; ++s)
  -         if (*s == '/')
  -             *s = '\\';
   
        if ((!r->args) || (!r->args[0]) || (ind(r->args, '=') >= 0)) {
            if (is_exe || is_binary) {
  
  
  
  1.7       +11 -1     apachen/src/os/win32/os.h
  
  Index: os.h
  ===================================================================
  RCS file: /export/home/cvs/apachen/src/os/win32/os.h,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- os.h      1997/10/21 09:12:13     1.6
  +++ os.h      1997/11/16 15:43:19     1.7
  @@ -21,7 +21,7 @@
   #define NO_USE_SIGACTION
   #define NO_TIMES
   #define NO_GETTIMEOFDAY
  -#define NEED_PROCESS_H
  +//#define NEED_PROCESS_H    although we do, this is specially handled in 
conf.h
   #define USE_LONGJMP
   #define HAVE_MMAP
   #define MULTITHREAD
  @@ -82,3 +82,13 @@
   
   #define stat(f,ps)  os_stat(f,ps)
   API_EXPORT(int) os_stat(const char *szPath,struct stat *pStat);
  +
  +#define _spawnv(mode,cmdname,argv)       os_spawnv(mode,cmdname,argv)
  +#define spawnv(mode,cmdname,argv)        os_spawnv(mode,cmdname,argv)
  +API_EXPORT(int) os_spawnv(int mode,const char *cmdname,const char *const 
*argv);
  +#define _spawnve(mode,cmdname,argv,envp)    
os_spawnve(mode,cmdname,argv,envp)
  +#define spawnve(mode,cmdname,argv,envp)          
os_spawnve(mode,cmdname,argv,envp)
  +API_EXPORT(int) os_spawnve(int mode,const char *cmdname,const char *const 
*argv,const char *const *envp);
  +#define _spawnle                         os_spawnle
  +#define spawnle                                  os_spawnle
  +API_EXPORT(int) os_spawnle(int mode,const char *cmdname,...);
  
  
  
  1.3       +132 -0    apachen/src/os/win32/util_win32.c
  
  Index: util_win32.c
  ===================================================================
  RCS file: /export/home/cvs/apachen/src/os/win32/util_win32.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- util_win32.c      1997/10/21 09:12:14     1.2
  +++ util_win32.c      1997/11/16 15:43:19     1.3
  @@ -1,6 +1,7 @@
   #include <windows.h>
   #include <assert.h>
   #include <sys/stat.h>
  +#include <stdarg.h>
   
   #include "httpd.h"
   
  @@ -86,3 +87,134 @@
        }
       return stat(szPath,pStat);
   }
  +
  +/*
  +Fix two really crap problems with Win32 spawn[lv]e*:
  +
  +  1. Win32 doesn't deal with spaces in argv.
  +  2. Win95 doesn't like / in cmdname.
  +*/
  +
  +#undef _spawnv
  +API_EXPORT(int) os_spawnv(int mode,const char *cmdname,const char *const 
*argv)
  +{
  +    int n;
  +    char **aszArgs;
  +    const char *szArg;
  +    char *szCmd;
  +    char *s;
  +    
  +    szCmd=_alloca(strlen(cmdname)+1);
  +    strcpy(szCmd,cmdname);
  +    for(s=szCmd ; *s ; ++s)
  +     if(*s == '/')
  +         *s='\\';
  +    
  +    for(n=0 ; argv[n] ; ++n)
  +     ;
  +
  +    aszArgs=_alloca((n+1)*sizeof(const char *));
  +
  +    for(n=0 ; szArg=argv[n] ; ++n)
  +     if(strchr(szArg,' '))
  +         {
  +         int l=strlen(szArg);
  +
  +         aszArgs[n]=_alloca(l+2+1);
  +         aszArgs[n][0]='"';
  +         strcpy(&aszArgs[n][1],szArg);
  +         aszArgs[n][l+1]='"';
  +         aszArgs[n][l+2]='\0';
  +         }
  +     else
  +         aszArgs[n]=(char *)szArg;
  +
  +    aszArgs[n]=NULL;
  +
  +    return _spawnv(mode,szCmd,aszArgs);
  +    }
  +
  +#undef _spawnve
  +API_EXPORT(int) os_spawnve(int mode,const char *cmdname,const char *const 
*argv,const char *const *envp)
  +{
  +    int n;
  +    char **aszArgs;
  +    const char *szArg;
  +    char *szCmd;
  +    char *s;
  +    
  +    szCmd=_alloca(strlen(cmdname)+1);
  +    strcpy(szCmd,cmdname);
  +    for(s=szCmd ; *s ; ++s)
  +     if(*s == '/')
  +         *s='\\';
  +    
  +    for(n=0 ; argv[n] ; ++n)
  +     ;
  +
  +    aszArgs=_alloca((n+1)*sizeof(const char *));
  +
  +    for(n=0 ; szArg=argv[n] ; ++n)
  +     if(strchr(szArg,' '))
  +         {
  +         int l=strlen(szArg);
  +
  +         aszArgs[n]=_alloca(l+2+1);
  +         aszArgs[n][0]='"';
  +         strcpy(&aszArgs[n][1],szArg);
  +         aszArgs[n][l+1]='"';
  +         aszArgs[n][l+2]='\0';
  +         }
  +     else
  +         aszArgs[n]=(char *)szArg;
  +
  +    aszArgs[n]=NULL;
  +
  +    return _spawnve(mode,szCmd,aszArgs,envp);
  +    }
  +
  +API_EXPORT(int) os_spawnle(int mode,const char *cmdname,...)
  +{
  +    int n;
  +    va_list vlist;
  +    char **aszArgs;
  +    const char *szArg;
  +    const char *const *aszEnv;
  +    char *szCmd;
  +    char *s;
  +    
  +    szCmd=_alloca(strlen(cmdname)+1);
  +    strcpy(szCmd,cmdname);
  +    for(s=szCmd ; *s ; ++s)
  +     if(*s == '/')
  +         *s='\\';
  +
  +    va_start(vlist,cmdname);
  +    for(n=0 ; va_arg(vlist,const char *) ; ++n)
  +     ;
  +    va_end(vlist);
  +
  +    aszArgs=_alloca((n+1)*sizeof(const char *));
  +
  +    va_start(vlist,cmdname);
  +    for(n=0 ; szArg=va_arg(vlist,const char *) ; ++n)
  +     if(strchr(szArg,' '))
  +         {
  +         int l=strlen(szArg);
  +
  +         aszArgs[n]=_alloca(l+2+1);
  +         aszArgs[n][0]='"';
  +         strcpy(&aszArgs[n][1],szArg);
  +         aszArgs[n][l+1]='"';
  +         aszArgs[n][l+2]='\0';
  +         }
  +     else
  +         aszArgs[n]=(char *)szArg;
  +
  +    aszArgs[n]=NULL;
  +
  +    aszEnv=va_arg(vlist,const char *const *);
  +    va_end(vlist);
  +
  +    return _spawnve(mode,szCmd,aszArgs,aszEnv);
  +    }
  
  
  

Reply via email to