cvs commit: apache-1.3/src/main http_core.c util_script.c

1999-06-28 Thread stoddard
stoddard99/06/28 15:38:27

  Modified:src/include http_core.h
   src/main http_core.c util_script.c
  Log:
  Win32: Fix 16-bit CGI support
  PR: 2494
  
  Revision  ChangesPath
  1.59  +3 -2  apache-1.3/src/include/http_core.h
  
  Index: http_core.h
  ===
  RCS file: /home/cvs/apache-1.3/src/include/http_core.h,v
  retrieving revision 1.58
  retrieving revision 1.59
  diff -u -r1.58 -r1.59
  --- http_core.h   1999/06/22 00:51:28 1.58
  +++ http_core.h   1999/06/28 22:38:25 1.59
  @@ -156,10 +156,11 @@
   /* 
* CGI Script stuff for Win32...
*/
  -typedef enum { FileTypeUNKNOWN, FileTypeBIN, FileTypeEXE, FileTypeSCRIPT } 
file_type_e;
  +typedef enum { eFileTypeUNKNOWN, eFileTypeBIN, eFileTypeEXE16, 
eFileTypeEXE32, 
  +   eFileTypeSCRIPT } file_type_e;
   typedef enum { INTERPRETER_SOURCE_UNSET, INTERPRETER_SOURCE_REGISTRY, 
  INTERPRETER_SOURCE_SHEBANG } interpreter_source_e;
  -API_EXPORT(file_type_e) ap_get_win32_interpreter(const request_rec *, char*, 
char **);
  +API_EXPORT(file_type_e) ap_get_win32_interpreter(const request_rec *, char 
**);
   #endif
   
   #ifdef CORE_PRIVATE
  
  
  
  1.268 +45 -23apache-1.3/src/main/http_core.c
  
  Index: http_core.c
  ===
  RCS file: /home/cvs/apache-1.3/src/main/http_core.c,v
  retrieving revision 1.267
  retrieving revision 1.268
  diff -u -r1.267 -r1.268
  --- http_core.c   1999/06/24 16:38:45 1.267
  +++ http_core.c   1999/06/28 22:38:25 1.268
  @@ -848,7 +848,6 @@
   }
   
   API_EXPORT (file_type_e) ap_get_win32_interpreter(const  request_rec *r, 
  -  char*  ext, 
 char** interpreter )
   {
   HANDLE hFile;
  @@ -856,50 +855,68 @@
   BOOLEAN bResult;
   char buffer[1024];
   core_dir_config *d;
  -file_type_e fileType = FileTypeUNKNOWN;
   int i;
  +file_type_e fileType = eFileTypeUNKNOWN;
  +char *ext = NULL;
  +char *exename = NULL;
   
   d = (core_dir_config *)ap_get_module_config(r-per_dir_config, 
   core_module);
   
  -if (d-script_interpreter_source == INTERPRETER_SOURCE_REGISTRY) {
  -/* 
  - * Check the registry
  - */
  +/* Find the file extension */
  +exename = strrchr(r-filename, '/');
  +if (!exename) {
  +exename = strrchr(r-filename, '\\');
  +}
  +if (!exename) {
  +exename = r-filename;
  +}
  +else {
  +exename++;
  +}
  +ext = strrchr(exename, '.');
  +
  +if (ext  (!strcasecmp(ext,.bat) || !strcasecmp(ext,.cmd))) {
  +return eFileTypeEXE32;
  +}
  +
  +/* If the file has an extension and it is not .com and not .exe and
  + * we've been instructed to search the registry, then do it!
  + */
  +if (ext  strcasecmp(ext,.exe)  strcasecmp(ext,.com) 
  +d-script_interpreter_source == INTERPRETER_SOURCE_REGISTRY) {
  + /* Check the registry */
   *interpreter = get_interpreter_from_win32_registry(r-pool, ext);
   if (*interpreter)
  -return FileTypeSCRIPT;
  +return eFileTypeSCRIPT;
   else {
   ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, r-server,
ScriptInterpreterSource config directive set to 
\registry\.\n\t
Registry was searched but interpreter not found. Trying the 
shebang line.);
   }
  -}
  +}
   
  -/* 
  - * Look for a #! line in the script
  - */
  +/* Need to peek into the file figure out what it really is... */
   hFile = CreateFile(r-filename, GENERIC_READ, FILE_SHARE_READ, NULL,
  OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
  -
   if (hFile == INVALID_HANDLE_VALUE) {
  -return FileTypeUNKNOWN;
  +return eFileTypeUNKNOWN;
   }
  -
   bResult = ReadFile(hFile, (void*) buffer, sizeof(buffer) - 1, 
  nBytesRead, NULL);
   if (!bResult || (nBytesRead == 0)) {
   ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
 ReadFile(%s) failed, r-filename);
   CloseHandle(hFile);
  -return (FileTypeUNKNOWN);
  +return eFileTypeUNKNOWN;
   }
   CloseHandle(hFile);
  -
   buffer[nBytesRead] = '\0';
  -
  +
  +/* Script or executable, that is the question... */
   if ((buffer[0] == '#')  (buffer[1] == '!')) {
  -fileType = FileTypeSCRIPT;
  +/* Assuming file is a script since it starts with a shebang */
  +fileType = eFileTypeSCRIPT;
   for (i = 2; i  sizeof(buffer); i++) {
   if ((buffer[i] == '\r')
   || (buffer[i] == '\n')) {
  @@ 

cvs commit: apache-1.3/src/main http_core.c util_script.c

1998-02-21 Thread dgaudet
dgaudet 98/02/20 17:42:41

  Modified:src/include conf.h http_core.h
   src/main http_core.c util_script.c
  Log:
  RLIMIT_AS is part of Single Unix... and presumably posix as well.  So it
  makes sense to support it everywhere rather than just on Linux.  So treat
  it like RLIMIT_VMEM and RLIMIT_DATA.
  
  Revision  ChangesPath
  1.182 +0 -7  apache-1.3/src/include/conf.h
  
  Index: conf.h
  ===
  RCS file: /export/home/cvs/apache-1.3/src/include/conf.h,v
  retrieving revision 1.181
  retrieving revision 1.182
  diff -u -r1.181 -r1.182
  --- conf.h1998/02/18 20:52:55 1.181
  +++ conf.h1998/02/21 01:42:36 1.182
  @@ -372,13 +372,6 @@
   typedef int rlim_t;
   #endif
   
  -/* Linux 2.0 and above implement the new posix RLIMIT_AS rather than the
  - * older BSD semantics (some would actually call this a bug, like me -djg).
  - */
  -#ifndef RLIMIT_VMEM
  -#define RLIMIT_VMEM RLIMIT_AS
  -#endif
  -
   /* flock is faster ... but hasn't been tested on 1.x systems */
   #define USE_FLOCK_SERIALIZED_ACCEPT
   
  
  
  
  1.36  +1 -1  apache-1.3/src/include/http_core.h
  
  Index: http_core.h
  ===
  RCS file: /export/home/cvs/apache-1.3/src/include/http_core.h,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- http_core.h   1998/02/02 19:46:55 1.35
  +++ http_core.h   1998/02/21 01:42:36 1.36
  @@ -202,7 +202,7 @@
   #ifdef RLIMIT_CPU
   struct rlimit *limit_cpu;
   #endif
  -#if defined (RLIMIT_DATA) || defined (RLIMIT_VMEM)
  +#if defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined(RLIMIT_AS)
   struct rlimit *limit_mem;
   #endif
   #ifdef RLIMIT_NPROC
  
  
  
  1.162 +10 -8 apache-1.3/src/main/http_core.c
  
  Index: http_core.c
  ===
  RCS file: /export/home/cvs/apache-1.3/src/main/http_core.c,v
  retrieving revision 1.161
  retrieving revision 1.162
  diff -u -r1.161 -r1.162
  --- http_core.c   1998/02/20 10:51:34 1.161
  +++ http_core.c   1998/02/21 01:42:39 1.162
  @@ -127,7 +127,7 @@
   #ifdef RLIMIT_CPU
   conf-limit_cpu = NULL;
   #endif
  -#if defined(RLIMIT_DATA) || defined(RLIMIT_VMEM)
  +#if defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS)
   conf-limit_mem = NULL;
   #endif
   #ifdef RLIMIT_NPROC
  @@ -207,7 +207,7 @@
   #ifdef RLIMIT_CPU
   if (new-limit_cpu) conf-limit_cpu = new-limit_cpu;
   #endif
  -#if defined(RLIMIT_DATA) || defined(RLIMIT_VMEM)
  +#if defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS)
   if (new-limit_mem) conf-limit_mem = new-limit_mem;
   #endif
   #ifdef RLIMIT_NPROC
  @@ -1560,7 +1560,7 @@
   }
   
   
  -#if defined(RLIMIT_CPU) || defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || 
defined(RLIMIT_NPROC)
  +#if defined(RLIMIT_CPU) || defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || 
defined(RLIMIT_NPROC) || defined(RLIMIT_AS)
   static void set_rlimit(cmd_parms *cmd, struct rlimit **plimit, const char 
*arg,
  const char * arg2, int type)
   {
  @@ -1612,7 +1612,7 @@
   }
   #endif
   
  -#if !defined (RLIMIT_CPU) || !(defined (RLIMIT_DATA) || defined 
(RLIMIT_VMEM)) || !defined (RLIMIT_NPROC)
  +#if !defined (RLIMIT_CPU) || !(defined (RLIMIT_DATA) || defined 
(RLIMIT_VMEM) || defined(RLIMIT_AS)) || !defined (RLIMIT_NPROC)
   static const char *no_set_limit (cmd_parms *cmd, core_dir_config *conf,
 char *arg, char *arg2)
   {
  @@ -1630,12 +1630,14 @@
   }
   #endif
   
  -#if defined (RLIMIT_DATA) || defined (RLIMIT_VMEM)
  +#if defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined(RLIMIT_AS)
   const char *set_limit_mem (cmd_parms *cmd, core_dir_config *conf, char *arg, 
char * arg2)
   {
  -#ifdef RLIMIT_DATA
  +#if defined(RLIMIT_AS)
  +set_rlimit(cmd,conf-limit_mem,arg,arg2,RLIMIT_AS);
  +#elif defined(RLIMIT_DATA)
   set_rlimit(cmd,conf-limit_mem,arg,arg2,RLIMIT_DATA);
  -#else
  +#else defined(RLIMIT_VMEM)
   set_rlimit(cmd,conf-limit_mem,arg,arg2,RLIMIT_VMEM);
   #endif
   return NULL;
  @@ -1898,7 +1900,7 @@
   #endif
 OR_ALL, TAKE12, soft/hard limits for max CPU usage in seconds },
   { RLimitMEM,
  -#if defined (RLIMIT_DATA) || defined (RLIMIT_VMEM)
  +#if defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined (RLIMIT_AS)
set_limit_mem, (void*)XtOffsetOf(core_dir_config, limit_mem),
   #else
no_set_limit, NULL,
  
  
  
  1.95  +10 -6 apache-1.3/src/main/util_script.c
  
  Index: util_script.c
  ===
  RCS file: /export/home/cvs/apache-1.3/src/main/util_script.c,v
  retrieving revision 1.94
  retrieving revision 1.95
  diff -u -r1.94 -r1.95
  --- util_script.c 1998/02/01 22:05:38 1.94
  +++ util_script.c