shane           Sun Dec  1 18:11:15 2002 EDT

  Added files:                 (Branch: PHP_4_3)
    /php4/sapi/cgi/libfcgi      acinclude.m4 libfcgi.m4 

  Modified files:              
    /php4/sapi/cgi/libfcgi      fcgiapp.c os_unix.c 
    /php4/sapi/cgi/libfcgi/include      fcgi_config.h fcgiapp.h fcgios.h 
  Log:
  MFH
  
  
Index: php4/sapi/cgi/libfcgi/fcgiapp.c
diff -u php4/sapi/cgi/libfcgi/fcgiapp.c:1.1 php4/sapi/cgi/libfcgi/fcgiapp.c:1.1.4.1
--- php4/sapi/cgi/libfcgi/fcgiapp.c:1.1 Sun Mar 10 16:39:28 2002
+++ php4/sapi/cgi/libfcgi/fcgiapp.c     Sun Dec  1 18:11:14 2002
@@ -11,7 +11,7 @@
  *
  */
 #ifndef lint
-static const char rcsid[] = "$Id: fcgiapp.c,v 1.1 2002/03/10 21:39:28 shane Exp $";
+static const char rcsid[] = "$Id: fcgiapp.c,v 1.1.4.1 2002/12/01 23:11:14 shane Exp 
+$";
 #endif /* not lint */
 
 #include <assert.h>
@@ -70,7 +70,7 @@
 static int isFastCGI = -1;
 static char *webServerAddressList = NULL;
 static FCGX_Request the_request;
-void _FCGX_FreeStream(FCGX_Stream **streamPtr, BOOL freeData);
+void _FCGX_FreeStream(FCGX_Stream **streamPtr, int freeData);
 
 void FCGX_ShutdownPending(void)
 {
@@ -980,24 +980,7 @@
      */
 }
 
-/*
- *======================================================================
- * Parameters
- *======================================================================
- */
 
-/*
- * A vector of pointers representing the parameters received
- * by a FastCGI application server, with the vector's length
- * and last valid element so adding new parameters is efficient.
- */
-
-typedef struct Params {
-    FCGX_ParamArray vec;    /* vector of strings */
-    int length;                    /* number of string vec can hold */
-    char **cur;                    /* current item in vec; *cur == NULL */
-} Params;
-typedef Params *ParamsPtr;
 
 /*
  *----------------------------------------------------------------------
@@ -1071,13 +1054,45 @@
     *paramsPtr->cur++ = nameValue;
     size = paramsPtr->cur - paramsPtr->vec;
     if(size >= paramsPtr->length) {
-       paramsPtr->length *= 2;
-       paramsPtr->vec = (FCGX_ParamArray)realloc(paramsPtr->vec, paramsPtr->length * 
sizeof(char *));
-       paramsPtr->cur = paramsPtr->vec + size;
+        paramsPtr->length *= 2;
+        paramsPtr->vec = (FCGX_ParamArray)realloc(paramsPtr->vec, paramsPtr->length * 
+sizeof(char *));
+        paramsPtr->cur = paramsPtr->vec + size;
     }
     *paramsPtr->cur = NULL;
 }
 
+
+void FCGX_PutEnv(FCGX_Request *request, char *var)
+{
+       char *nameValue;
+       char *e, **p;
+       int len;
+
+       if (!strchr(var,'=')) {
+               return;
+       }
+       nameValue = StringCopy(var);
+       e = strchr(nameValue,'=');
+       *e = 0;
+
+       /* find the name and replace it */
+    len = strlen(nameValue);
+
+    for (p = request->envp; p && *p; ++p) {
+        if((strncmp(nameValue, *p, len) == 0) && ((*p)[len] == '=')) {
+            free(*p);
+                       *e = '=';
+                       *p = nameValue;
+                       return;
+        }
+    }
+    *e = '=';
+       /* this is a new var, add it to the environment */
+       PutParam(request->paramsPtr,nameValue);
+       request->envp = request->paramsPtr->vec;
+}
+
+
 /*
  *----------------------------------------------------------------------
  *
@@ -1100,7 +1115,7 @@
 
     len = strlen(name);
 
-    for (p = envp; *p; ++p) {
+    for (p = envp; p && *p; ++p) {
         if((strncmp(name, *p, len) == 0) && ((*p)[len] == '=')) {
             return *p+len+1;
         }
@@ -1814,7 +1829,7 @@
        _FCGX_FreeStream(streamPtr, TRUE);
 }
 
-void _FCGX_FreeStream(FCGX_Stream **streamPtr, BOOL freeData)
+void _FCGX_FreeStream(FCGX_Stream **streamPtr, int freeData)
 {
     FCGX_Stream *stream = *streamPtr;
     FCGX_Stream_Data *data;
@@ -2027,6 +2042,7 @@
     _FCGX_FreeStream(&request->out, FALSE);
     _FCGX_FreeStream(&request->err, FALSE);
     FreeParams(&request->paramsPtr);
+       request->envp = NULL;
 
     if (close) {
         OS_IpcClose(request->ipcFd);
Index: php4/sapi/cgi/libfcgi/os_unix.c
diff -u php4/sapi/cgi/libfcgi/os_unix.c:1.2 php4/sapi/cgi/libfcgi/os_unix.c:1.2.2.1
--- php4/sapi/cgi/libfcgi/os_unix.c:1.2 Sun Oct 13 04:34:27 2002
+++ php4/sapi/cgi/libfcgi/os_unix.c     Sun Dec  1 18:11:14 2002
@@ -17,7 +17,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: os_unix.c,v 1.2 2002/10/13 08:34:27 shane Exp $";
+static const char rcsid[] = "$Id: os_unix.c,v 1.2.2.1 2002/12/01 23:11:14 shane Exp 
+$";
 #endif /* not lint */
 
 #include "fcgi_config.h"
@@ -498,7 +498,7 @@
  *
  *----------------------------------------------------------------------
  */
-int OS_SpawnChild(char *appPath, int listenFd, PROCESS_INFORMATION *pInfo, char *env)
+int OS_SpawnChild(char *appPath, int listenFd)
 {
     int forkResult;
 
Index: php4/sapi/cgi/libfcgi/include/fcgi_config.h
diff -u php4/sapi/cgi/libfcgi/include/fcgi_config.h:1.1 
php4/sapi/cgi/libfcgi/include/fcgi_config.h:1.1.4.1
--- php4/sapi/cgi/libfcgi/include/fcgi_config.h:1.1     Sun Mar 10 16:39:28 2002
+++ php4/sapi/cgi/libfcgi/include/fcgi_config.h Sun Dec  1 18:11:15 2002
@@ -1,111 +1,7 @@
-/* fcgi_config.h.  Generated automatically by configure.  */
-/* fcgi_config.h.in.  Generated automatically from configure.in by autoheader.  */
+/* hack workaround for libfcgi configure */
+#ifdef _WIN32
+#include "fcgi_config_win32.h"
+#else
+#include "main/php_config.h"
+#endif
 
-/* Define if you have the <arpa/inet.h> header file. */
-#define HAVE_ARPA_INET_H 1
-
-/* Define if you have the <dlfcn.h> header file. */
-#define HAVE_DLFCN_H 1
-
-/* Define if there's a fileno() prototype in stdio.h */
-#define HAVE_FILENO_PROTO 1
-
-/* Define if the fpos_t typedef is in stdio.h */
-#define HAVE_FPOS 1
-
-/* Define if you have the <inttypes.h> header file. */
-#define HAVE_INTTYPES_H 1
-
-/* Define if you have the `dnet_stub' library (-ldnet_stub). */
-/* #undef HAVE_LIBDNET_STUB */
-
-/* Define if you have the `ieee' library (-lieee). */
-/* #undef HAVE_LIBIEEE */
-
-/* Define if you have the `nsl' library (-lnsl). */
-#define HAVE_LIBNSL 1
-
-/* Define if you have the pthread library */
-#define HAVE_LIBPTHREAD 1
-
-/* Define if you have the `resolv' library (-lresolv). */
-#define HAVE_LIBRESOLV 1
-
-/* Define if you have the `socket' library (-lsocket). */
-#define HAVE_LIBSOCKET 1
-
-/* Define if you have the <limits.h> header file. */
-#define HAVE_LIMITS_H 1
-
-/* Define if you have the <memory.h> header file. */
-#define HAVE_MEMORY_H 1
-
-/* Define if you have the <netdb.h> header file. */
-/* #define HAVE_NETDB_H 1 */
-
-/* Define if you have the <netinet/in.h> header file. */
-#define HAVE_NETINET_IN_H 1
-
-/* Define if sockaddr_un in sys/un.h contains a sun_len component */
-/* #undef HAVE_SOCKADDR_UN_SUN_LEN */
-
-/* Define if the socklen_t typedef is in sys/socket.h */
-/* #undef HAVE_SOCKLEN */
-
-/* Define if you have the <stdint.h> header file. */
-/* #undef HAVE_STDINT_H */
-
-/* Define if you have the <stdlib.h> header file. */
-#define HAVE_STDLIB_H 1
-
-/* Define if you have the `strerror' function. */
-#define HAVE_STRERROR 1
-
-/* Define if you have the <strings.h> header file. */
-#define HAVE_STRINGS_H 1
-
-/* Define if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
-
-/* Define if you have the <sys/param.h> header file. */
-/* #define HAVE_SYS_PARAM_H 1 */
-
-/* Define if you have the <sys/socket.h> header file. */
-/*#define HAVE_SYS_SOCKET_H 1*/
-
-/* Define if you have the <sys/stat.h> header file. */
-#define HAVE_SYS_STAT_H 1
-
-/* Define if you have the <sys/time.h> header file. */
-/*#define HAVE_SYS_TIME_H 1*/
-
-/* Define if you have the <sys/types.h> header file. */
-#define HAVE_SYS_TYPES_H 1
-
-/* Define if you have the <unistd.h> header file. */
-/*#define HAVE_UNISTD_H 1*/
-
-/* Define if va_arg(arg, long double) crashes the compiler */
-/* #undef HAVE_VA_ARG_LONG_DOUBLE_BUG */
-
-/* Name of package */
-#define PACKAGE "fcgi"
-
-/* Define if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* Define if cross-process locking is required by accept() */
-#define USE_LOCKING 1
-
-/* Version number of package */
-#define VERSION "2.2.2"
-
-/* Define to empty if `const' does not conform to ANSI C. */
-/* #undef const */
-
-/* Define as `__inline' if that's what the C compiler calls it, or to nothing
-   if it is not supported. */
-/* #undef inline */
-
-/* Define to `int' if <sys/types.h> does not define. */
-#define ssize_t int
\ No newline at end of file
Index: php4/sapi/cgi/libfcgi/include/fcgiapp.h
diff -u php4/sapi/cgi/libfcgi/include/fcgiapp.h:1.1 
php4/sapi/cgi/libfcgi/include/fcgiapp.h:1.1.4.1
--- php4/sapi/cgi/libfcgi/include/fcgiapp.h:1.1 Sun Mar 10 16:39:28 2002
+++ php4/sapi/cgi/libfcgi/include/fcgiapp.h     Sun Dec  1 18:11:15 2002
@@ -9,7 +9,7 @@
  * See the file "LICENSE.TERMS" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  *
- * $Id: fcgiapp.h,v 1.1 2002/03/10 21:39:28 shane Exp $
+ * $Id: fcgiapp.h,v 1.1.4.1 2002/12/01 23:11:15 shane Exp $
  */
 
 #ifndef _FCGIAPP_H
@@ -80,6 +80,19 @@
 typedef char **FCGX_ParamArray;
 
 /*
+ * A vector of pointers representing the parameters received
+ * by a FastCGI application server, with the vector's length
+ * and last valid element so adding new parameters is efficient.
+ */
+
+typedef struct Params {
+    FCGX_ParamArray vec;    /* vector of strings */
+    int length;                    /* number of string vec can hold */
+    char **cur;                    /* current item in vec; *cur == NULL */
+} Params;
+typedef Params *ParamsPtr;
+
+/*
  * FCGX_Request Flags
  *
  * Setting FCGI_FAIL_ACCEPT_ON_INTR prevents FCGX_Accept() from
@@ -98,11 +111,11 @@
     FCGX_Stream *in;
     FCGX_Stream *out;
     FCGX_Stream *err;
-       char **envp;
+       FCGX_ParamArray envp;
 
        /* Don't use anything below here */
 
-    struct Params *paramsPtr;
+    ParamsPtr paramsPtr;
     int ipcFd;               /* < 0 means no connection */
     int isBeginProcessed;     /* FCGI_BEGIN_REQUEST seen */
     int keepConnection;       /* don't close ipcFd at end of request */
@@ -351,7 +364,8 @@
  *----------------------------------------------------------------------
  */
 DLLAPI char *FCGX_GetParam(const char *name, FCGX_ParamArray envp);
-
+DLLAPI void FCGX_PutEnv(FCGX_Request *request, char *nameValue);
+
 /*
  *======================================================================
  * Readers
@@ -533,7 +547,7 @@
  *----------------------------------------------------------------------
  */
 DLLAPI int FCGX_FFlush(FCGX_Stream *stream);
-
+
 /*
  *======================================================================
  * Both Readers and Writers
Index: php4/sapi/cgi/libfcgi/include/fcgios.h
diff -u php4/sapi/cgi/libfcgi/include/fcgios.h:1.2 
php4/sapi/cgi/libfcgi/include/fcgios.h:1.2.4.1
--- php4/sapi/cgi/libfcgi/include/fcgios.h:1.2  Sun Mar 17 23:48:34 2002
+++ php4/sapi/cgi/libfcgi/include/fcgios.h      Sun Dec  1 18:11:15 2002
@@ -108,7 +108,11 @@
 DLLAPI int OS_FcgiConnect(char *bindPath);
 DLLAPI int OS_Read(int fd, char * buf, size_t len);
 DLLAPI int OS_Write(int fd, char * buf, size_t len);
+#ifdef _WIN32
 DLLAPI int OS_SpawnChild(char *execPath, int listenFd, PROCESS_INFORMATION *pInfo, 
char *env);
+#else
+DLLAPI int OS_SpawnChild(char *execPath, int listenfd);
+#endif
 DLLAPI int OS_AsyncReadStdin(void *buf, int len, OS_AsyncProc procPtr,
                       ClientData clientData);
 DLLAPI int OS_AsyncRead(int fd, int offset, void *buf, int len,

Index: php4/sapi/cgi/libfcgi/acinclude.m4
+++ php4/sapi/cgi/libfcgi/acinclude.m4

Index: php4/sapi/cgi/libfcgi/libfcgi.m4
+++ php4/sapi/cgi/libfcgi/libfcgi.m4

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to