]> granicus.if.org Git - php/commitdiff
SAPIfication, Episode VI: Return of the SAPI
authorZeev Suraski <zeev@php.net>
Thu, 10 Feb 2000 19:41:21 +0000 (19:41 +0000)
committerZeev Suraski <zeev@php.net>
Thu, 10 Feb 2000 19:41:21 +0000 (19:41 +0000)
Remove mostly all references to APACHE and CGI_BINARY from the code.

- Apache include files are no longer included by any PHP code, except for the Apache SAPI module.
- No server specific code is in any of the base PHP code.

Still left to be done:
- Eliminate any references to APACHE from the few remaining modules.
- Move request_info.c's logic to SAPI
- Modify the regex function names, and globals, so that we can always
  include them, without having to fear any interference with Apache;
  Always use the bundled regex library

33 files changed:
acconfig.h.in
acinclude.m4
ext/aspell/aspell.c
ext/db/db.c
ext/ereg/php_regex.h
ext/hyperwave/hg_comm.c
ext/mysql/php_mysql.c
ext/oci8/oci8.c
ext/posix/posix.c
ext/standard/basic_functions.c
ext/standard/browscap.c
ext/standard/dl.c
ext/standard/exec.c
ext/standard/head.c
ext/standard/mail.c
ext/standard/php_string.h
ext/standard/string.c
ext/standard/url.c
main/config.w32.h
main/fopen_wrappers.c
main/internal_functions_registry.h
main/php.h
main/php_regex.h
main/snprintf.c
main/snprintf.h
main/win95nt.h
request_info.c
request_info.h
sapi/apache/config.m4
sapi/apache/mod_php4.c
sapi/apache/php_apache.c
sapi/apache/php_apache_http.h [new file with mode: 0644]
sapi/cgi/cgi_main.c

index c2d60387066c664717671013396f291ae5a71da8..2194c1cd4a11aa20318487ce0fe05c1502bd6be3 100644 (file)
@@ -74,9 +74,6 @@
 /* Define if you have the sendmail program available */
 #define HAVE_SENDMAIL 0
 
-/* Define if you are compiling PHP as an Apache module */
-#define APACHE 0
-
 /* Define if you are compiling PHP as an Apache module with mod_charset patch applied (aka Russian Apache)*/
 #define USE_TRANSFER_TABLES 0
 
index 0aec0c688a12ceeae4c8db61eed633672794a230..ff560ebdfaad402972914c2a769ec556db5642df 100644 (file)
@@ -295,8 +295,6 @@ if test "$REGEX_TYPE" = "php"; then
   PHP_FAST_OUTPUT(regex/Makefile)
 elif test "$REGEX_TYPE" = "system"; then
   AC_DEFINE(REGEX,0)
-elif test "$REGEX_TYPE" = "apache"; then
-  AC_DEFINE(REGEX,2)
 fi
 
 AC_MSG_CHECKING(which regex library to use)
index b942517ba2308e1d33bd6ee7be9a24f85d0b8fcb..5866a66b57f970e5c9ad7c02758b8ee5e2153d40 100644 (file)
 #if HAVE_ASPELL
 
 #include "php_aspell.h"
-#if APACHE
-#  ifndef DEBUG
-#  undef palloc
-#  endif
-#endif
 #include <aspell-c.h>
 
 function_entry aspell_functions[] = {
index 5b0eb112822d1be581a04586904cf3be2fed3e30..e4e5b51d3b54e0d1a3bb3a68b094e38f048dffea 100644 (file)
@@ -317,7 +317,7 @@ dbm_info *php_dbm_open(char *filename, char *mode) {
 #if NFS_HACK 
                while((last_try = stat(lockfn,&sb))==0) {
                        retries++;
-                       sleep(1);
+                       php_sleep(1);
                        if (retries>30) break;
                }       
                if (last_try!=0) {
index be0f445af70372ed83668b675563e351ae846de3..f4dc865163bfbd3fa38297531d3cf4c877325701 100644 (file)
@@ -5,10 +5,9 @@
  * REGEX means:
  * 0.. system regex
  * 1.. bundled regex
- * 2.. Apache's regex
  */
 
-#if REGEX == 1
+#if REGEX
 /* get aliases */
 #include "regex/regex_extra.h"
 #include "regex/regex.h"
index 1138df59b6802d906005eb244ee5084d3417aef8..20ed8d683ef32c2b51a9cda74302dde464fc12af 100644 (file)
@@ -1137,7 +1137,7 @@ static int hg_read(int sockfd, char *buf, int size)
                        if ( (errno == EAGAIN) || (errno == EWOULDBLOCK) )  {
                                if ( ++try > 5 )
                                        return(-1);
-                               sleep(1);
+                               php_sleep(1);
                        } 
                        else return(-1);
                } 
@@ -1159,7 +1159,7 @@ static int hg_write(int sockfd, char *buf, int size)
                        if ( (errno == EAGAIN) || (errno == EWOULDBLOCK) )  {
                                if ( ++try > 5 )
                                        return(-1);
-                               sleep(1);
+                               php_sleep(1);
                        } 
                        else return(-1);
                } 
index f02382d2fe35d4653cbdcb76037207438950a133..57c3add0556e9a8da5fbd30909c2a546245c668c 100644 (file)
@@ -158,9 +158,6 @@ PHP_MYSQL_API php_mysql_globals mysql_globals;
 DLEXPORT zend_module_entry *get_module(void) { return &mysql_module_entry; }
 #endif
 
-#if APACHE
-void timeout(int sig);
-#endif
 
 #define CHECK_LINK(link) { if (link==-1) { php_error(E_WARNING,"MySQL:  A link to the server could not be established"); RETURN_FALSE; } }
 
@@ -187,42 +184,19 @@ static void php_mysql_set_default_link(int id)
 
 static void _close_mysql_link(MYSQL *link)
 {
-#if APACHE
-       void (*handler) (int);
-#endif
        MySLS_FETCH();
 
-#if APACHE
-       handler = signal(SIGPIPE, SIG_IGN);
-#endif
-
        mysql_close(link);
-
-#if APACHE
-       signal(SIGPIPE,handler);
-#endif
-
        efree(link);
        MySG(num_links)--;
 }
 
 static void _close_mysql_plink(MYSQL *link)
 {
-#if APACHE
-       void (*handler) (int);
-#endif
        MySLS_FETCH();
 
-#if APACHE
-       handler = signal(SIGPIPE, SIG_IGN);
-#endif
-
        mysql_close(link);
 
-#if APACHE
-       signal(SIGPIPE,handler);
-#endif
-
        free(link);
        MySG(num_persistent)--;
        MySG(num_links)--;
@@ -338,9 +312,6 @@ PHP_MINFO_FUNCTION(mysql)
 
 static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent)
 {
-#if APACHE
-       void (*handler) (int);
-#endif
        char *user,*passwd,*host,*socket=NULL,*tmp;
        char *hashed_details;
        int hashed_details_length,port = MYSQL_PORT;
@@ -478,18 +449,12 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent)
                                RETURN_FALSE;
                        }
                        /* ensure that the link did not die */
-#if APACHE
-                       handler=signal(SIGPIPE,SIG_IGN);
-#endif
 #if defined(HAVE_MYSQL_ERRNO) && defined(CR_SERVER_GONE_ERROR)
                        mysql_stat(le->ptr);
                        if (mysql_errno((MYSQL *)le->ptr) == CR_SERVER_GONE_ERROR) {
 #else
                        if (!strcasecmp(mysql_stat(le->ptr),"mysql server has gone away")) { /* the link died */
 #endif
-#if APACHE
-                               signal(SIGPIPE,handler);
-#endif
 #if MYSQL_VERSION_ID > 32199 /* this lets us set the port number */
                                if (mysql_real_connect(le->ptr,host,user,passwd,NULL,port,socket,0)==NULL) {
 #else
@@ -501,9 +466,6 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent)
                                        RETURN_FALSE;
                                }
                        }
-#if APACHE
-                       signal(SIGPIPE,handler);
-#endif
                        mysql = (MYSQL *) le->ptr;
                }
                ZEND_REGISTER_RESOURCE(return_value, mysql, le_plink);
index 85b9a391f58808756b3f0da09959642fa67b6fed..8304a0bb838096a87e2371ef92b6f53839100d49 100644 (file)
@@ -1642,7 +1642,7 @@ oci_failover_callback(dvoid *svchp,
                case OCI_FO_ERROR:
                        {
                                printf(" Failover error gotten. Sleeping...\n");
-                               sleep(3);
+                               php_sleep(3);
                                /* cannot find this blody define !!! return OCI_FO_RETRY; */
                                break;
                        }
index 37d6fa39c6ae79f574e3adc329b30ca4748d6c2a..8d32d82a69e27066b32b3c053c0287802236eb47 100644 (file)
@@ -132,10 +132,6 @@ zend_module_entry posix_module_entry = {
 DLEXPORT zend_module_entry *get_module(void) { return &posix__module_entry; }
 #endif
 
-#if APACHE
-void timeout(int sig);
-#endif
-
 static PHP_MINFO_FUNCTION(posix)
 {
     PUTS("$Revision$\n");
index 2309df2db2c7e8aed11a8534f1c197f42622ff4e..953eebe7f2706b84603096640d0e636e30becfb1 100644 (file)
@@ -664,7 +664,7 @@ PHP_FUNCTION(sleep)
                WRONG_PARAM_COUNT;
        }
        convert_to_long_ex(num);
-       sleep((*num)->value.lval);
+       php_sleep((*num)->value.lval);
 }
 
 PHP_FUNCTION(usleep)
index c6ea118081aff7bf145bb4f5614e6e45f9779268..f29429e2d4c991c6d49348700bdc5467c744c683 100644 (file)
@@ -17,6 +17,7 @@
  */
 
 #include "php.h"
+#include "php_regex.h"
 #include "php_browscap.h"
 #include "php_ini.h"
 
index 471ef75e9a5f7fd78892c09c75e908a255d603e5..86decf5d371b0504979a799d5ba86b292e90ba86 100644 (file)
@@ -104,7 +104,7 @@ void php_dl(pval *file,int type,pval *return_value)
        }
 
        /* load dynamic symbol */
-       handle = dlopen(libpath, RTLD_LAZY);
+       handle = DL_LOAD(libpath);
        if (!handle) {
                int error_type;
 
@@ -120,10 +120,10 @@ void php_dl(pval *file,int type,pval *return_value)
 #endif
                RETURN_FALSE;
        }
-       get_module = (zend_module_entry *(*)(void)) dlsym(handle, "get_module");
+       get_module = (zend_module_entry *(*)(void)) DL_FETCH_SYMBOL(handle, "get_module");
        
        if (!get_module) {
-               dlclose(handle);
+               DL_UNLOAD(handle);
                php_error(E_CORE_WARNING,"Invalid library (maybe not a PHP library) '%s' ",file->value.str.val);
                RETURN_FALSE;
        }
@@ -133,7 +133,7 @@ void php_dl(pval *file,int type,pval *return_value)
        if (module_entry->module_startup_func) {
                if (module_entry->module_startup_func(type, module_entry->module_number ELS_CC)==FAILURE) {
                        php_error(E_CORE_WARNING,"%s:  Unable to initialize module",module_entry->name);
-                       dlclose(handle);
+                       DL_UNLOAD(handle);
                        RETURN_FALSE;
                }
        }
@@ -143,7 +143,7 @@ void php_dl(pval *file,int type,pval *return_value)
        if (module_entry->request_startup_func) {
                if (module_entry->request_startup_func(type, module_entry->module_number ELS_CC)) {
                        php_error(E_CORE_WARNING,"%s:  Unable to initialize module",module_entry->name);
-                       dlclose(handle);
+                       DL_UNLOAD(handle);
                        RETURN_FALSE;
                }
        }
index 53394a4b368d5d4dd343c9b3fd2219cae9dd01fc..c450d17ecdcaec4fff2ac3a01e6857d7476560aa 100644 (file)
@@ -145,27 +145,8 @@ static int _Exec(int type, char *cmd, pval *array, pval *return_value)
 
                
                        if (type == 1) {
-#if APACHE
-                               SLS_FETCH();
-#endif
-                               
                                if (output) PUTS(buf);
-#if APACHE
-#  if MODULE_MAGIC_NUMBER > 19970110
-                               if (output) rflush(((request_rec *) SG(server_context)));
-#  else
-                               if (output) bflush(((request_rec *) SG(server_context))->connection->client);
-#  endif
-#endif
-#if CGI_BINARY
-                               fflush(stdout);
-#endif
-#if FHTTPD
-                               /* fhttpd doesn't flush */
-#endif
-#if USE_SAPI
-                               sapi_rqst->flush(sapi_rqst->scid);
-#endif
+                               sapi_flush();
                        }
                        else if (type == 2) {
                                /* strip trailing whitespaces */        
index 493703e7722390d950dfaca4e34d58dd66e3a9ea..23f5f58efb8bede5b5c1e93486420a24b0c01ed7 100644 (file)
@@ -58,133 +58,10 @@ PHP_RINIT_FUNCTION(head)
 }
 
 
-#if 0
-/* Adds header information */
-void php4i_add_header_information(char *header_information, uint header_length)
-{
-       char *r;
-#if APACHE
-       char *rr = NULL;
-       char *temp = NULL;
-       long myuid = 0L;
-       char temp2[32];
-       request_rec *req;
-       SLS_FETCH();
-       
-       req = ((request_rec *) SG(server_context));
-#endif
-
-       if (php_header_printed == 1) {
-#if DEBUG
-               php_error(E_WARNING, "Cannot add more header information - the header was already sent "
-                                                         "(header information may be added only before any output is generated from the script - "
-                                                         "check for text or whitespace outside PHP tags, or calls to functions that output text)");
-#endif
-               return;                                 /* too late, already sent */
-       }
-#if APACHE
-       /*
-        * Not entirely sure this is the right way to support the header
-        * command in the Apache module.  Comments?
-        */
-       r = strchr(header_information, ':');
-       if (r) {
-               *r = '\0';
-               if (!strcasecmp(header_information, "Content-type")) {
-                       if (*(r + 1) == ' ')
-                               req->content_type = pstrdup(req->pool,r + 2);
-                       else
-                               req->content_type = pstrdup(req->pool,r + 1);
-                       cont_type = (char *) req->content_type;
-               } else {
-                       if (*(r + 1) == ' ') {
-                               rr = r + 2;
-                       } else {
-                               rr = r + 1;
-                       }
-                       if (PG(safe_mode) && (!strcasecmp(header_information, "WWW-authenticate"))) {
-                               myuid = php_getuid();
-                               sprintf(temp2, "realm=\"%ld ", myuid);  /* SAFE */
-                               temp = php_reg_replace("realm=\"", temp2, rr, 1, 0);
-                               if (!strcmp(temp, rr)) {
-                                       sprintf(temp2, "realm=%ld", myuid);  /* SAFE */
-                                       temp = php_reg_replace("realm=", temp2, rr, 1, 0);
-                                       if (!strcmp(temp, rr)) {
-                                               sprintf(temp2, " realm=%ld", myuid);  /* SAFE */
-                                               temp = php_reg_replace("$", temp2, rr, 0, 0);
-                                       }
-                               }
-                               table_set(req->headers_out, header_information, temp);
-                       } else
-                               table_set(req->headers_out, header_information, rr);
-               }
-               if (!strcasecmp(header_information, "location")) {
-                       req->status = REDIRECT;
-               }
-               *r = ':';
-               php_header_printed = 2;
-       }
-       if (!strncasecmp(header_information, "http/", 5)) {
-               if (strlen(header_information) > 9) {
-                       req->status = atoi(&((header_information)[9]));
-               }
-               /* Use a pstrdup here to get the memory straight from Apache's per-request pool to
-                * avoid having our own memory manager complain about this memory not being freed
-                * because it really shouldn't be freed until the end of the request and it isn't
-                * easy for us to figure out when we allocated it vs. when something else might have.
-                */
-               req->status_line = pstrdup(req->pool,&((header_information)[9]));
-       }
-#else
-       r = strchr(header_information, ':');
-       if (r) {
-               *r = '\0';
-               if (!strcasecmp(header_information, "Content-type")) {
-                       if (cont_type) efree(cont_type);
-                       cont_type = estrdup(r + 1);
-#if 0 /*WIN32|WINNT / *M$ does us again*/
-                       if (!strcmp(cont_type," text/html")){
-                               *r=':';
-                               PUTS_H(header_information);
-                               PUTS_H("\015\012");
-                       }
-#endif
-               } else {
-                       *r = ':';
-#if USE_SAPI
-                       {
-                               char *tempstr=emalloc(strlen(header_information)+2);
-                               
-                               sprintf(tempstr,"%s\015\012",tempstr);
-                               sapi_rqst->header(sapi_rqst->scid,tempstr);
-                               efree(tempstr);
-                       }
-#else
-                       PUTS_H(header_information);
-                       PUTS_H("\015\012");
-#endif
-               }
-       } else {
-#if USE_SAPI
-               {
-               char *tempstr=emalloc(strlen(header_information)+2);
-               sprintf(tempstr,"%s\015\012",tempstr);
-               sapi_rqst->header(sapi_rqst->scid,tempstr);
-               efree(tempstr);
-               }
-#else
-               PUTS_H(header_information);
-               PUTS_H("\015\012");
-#endif
-       }
-#endif
-}
-#else
 void php4i_add_header_information(char *header_information, uint header_length)
 {
        sapi_add_header(header_information, header_length);
 }
-#endif
 
 
 /* Implementation of the language Header() function */
index 7657ef6ba768af2afbc278bb6604c45a54222011..d87861a6050f454191ed5070a4bcbd4661eff6a7 100644 (file)
 #include "php_mail.h"
 #include "php_ini.h"
 
-#if APACHE
-#  ifndef DEBUG
-#  undef palloc
-#  endif
-#endif
-
 #if HAVE_SENDMAIL
 #if MSVC5
 #include "win32/sendmail.h"
index 74f0b899d8594ed5d038dfa3ac369e7a5ba2d5e9..467e85789e01410422d2b1544e0103e1715e71ff 100644 (file)
@@ -83,26 +83,31 @@ PHP_FUNCTION(strip_tags);
 PHP_FUNCTION(str_repeat);
 PHP_FUNCTION(substr_replace);
 
-extern PHPAPI char *php_strtoupper(char *s, size_t len);
-extern PHPAPI char *php_strtolower(char *s, size_t len);
-extern PHPAPI char *php_strtr(char *str, int len, char *str_from, char *str_to, int trlen);
-extern PHPAPI char *php_addslashes(char *str, int length, int *new_length, int freeit);
-extern PHPAPI char *php_addcslashes(char *str, int length, int *new_length, int freeit, char *what, int wlength);
-extern PHPAPI void php_stripslashes(char *str, int *len);
-extern PHPAPI void php_stripcslashes(char *str, int *len);
-extern PHPAPI void php_dirname(char *str, int len);
-extern PHPAPI char *php_stristr(unsigned char *s, unsigned char *t, size_t s_len, size_t t_len);
-extern PHPAPI char *php_str_to_str(char *haystack, int length, char *needle,
+PHPAPI char *php_strtoupper(char *s, size_t len);
+PHPAPI char *php_strtolower(char *s, size_t len);
+PHPAPI char *php_strtr(char *str, int len, char *str_from, char *str_to, int trlen);
+PHPAPI char *php_addslashes(char *str, int length, int *new_length, int freeit);
+PHPAPI char *php_addcslashes(char *str, int length, int *new_length, int freeit, char *what, int wlength);
+PHPAPI void php_stripslashes(char *str, int *len);
+PHPAPI void php_stripcslashes(char *str, int *len);
+PHPAPI void php_dirname(char *str, int len);
+PHPAPI char *php_stristr(unsigned char *s, unsigned char *t, size_t s_len, size_t t_len);
+PHPAPI char *php_str_to_str(char *haystack, int length, char *needle,
                int needle_len, char *str, int str_len, int *_new_length);
-extern PHPAPI void php_trim(pval *str, pval *return_value, int mode);
-extern PHPAPI void php_strip_tags(char *rbuf, int len, int state, char *allow, int allow_len);
+PHPAPI void php_trim(pval *str, pval *return_value, int mode);
+PHPAPI void php_strip_tags(char *rbuf, int len, int state, char *allow, int allow_len);
 
-extern PHPAPI void php_char_to_str(char *str, uint len, char from, char *to, int to_len, pval *result);
+PHPAPI void php_char_to_str(char *str, uint len, char from, char *to, int to_len, pval *result);
 
-extern PHPAPI void php_implode(pval *delim, pval *arr, pval *return_value);
-extern PHPAPI void php_explode(pval *delim, pval *str, pval *return_value);
-extern PHPAPI inline char *php_memnstr(char *haystack, char *needle, int needle_len, char *end);
-extern PHPAPI size_t php_strspn(char *s1, char *s2, char *s1_end, char *s2_end); 
-extern PHPAPI size_t php_strcspn(char *s1, char *s2, char *s1_end, char *s2_end); 
+PHPAPI void php_implode(pval *delim, pval *arr, pval *return_value);
+PHPAPI void php_explode(pval *delim, pval *str, pval *return_value);
+PHPAPI inline char *php_memnstr(char *haystack, char *needle, int needle_len, char *end);
+PHPAPI size_t php_strspn(char *s1, char *s2, char *s1_end, char *s2_end); 
+PHPAPI size_t php_strcspn(char *s1, char *s2, char *s1_end, char *s2_end); 
+
+#ifndef HAVE_STRERROR
+PHPAPI char *php_strerror(int errnum);
+#define strerror php_strerror
+#endif
 
 #endif /* _PHPSTRING_H */
index a9f767a82c93299be4a5752433667a5e5362ef17..f3cd2bda12d2a227cd035263f8824d242baf36f7 100644 (file)
@@ -1503,8 +1503,7 @@ PHP_FUNCTION(stripslashes)
 /* }}} */
 
 #ifndef HAVE_STRERROR
-#if !APACHE
-char *strerror(int errnum) 
+char *php_strerror(int errnum) 
 {
        extern int sys_nerr;
        extern char *sys_errlist[];
@@ -1515,7 +1514,6 @@ char *strerror(int errnum)
        return(BG(str_ebuf));
 }
 #endif
-#endif
 
 PHPAPI void php_stripcslashes(char *str, int *len)
 {
index f37500f9846f354428bb34d1605aff41c8a2e19b..e8e85b3b4115afe6746cfa097e7750f1c2ceab19 100644 (file)
@@ -27,7 +27,7 @@
 #include "url.h"
 #ifdef _OSD_POSIX
 #ifndef APACHE
-#error On this EBCDIC platform, PHP3 is only supported as an Apache module.
+#error On this EBCDIC platform, PHP is only supported as an Apache module.
 #else /*APACHE*/
 #ifndef CHARSET_EBCDIC
 #define CHARSET_EBCDIC /* this machine uses EBCDIC, not ASCII! */
index e12c7efe33fcfcfd2aabdb516c4ba771cdf8064d..d9f8b1ecf2dbf76d3b949ec48519faff014d58c3 100644 (file)
@@ -97,8 +97,6 @@
    will move to the "don't touch" list below eventualy.
    ---------------------------------------------------------------*/
 
-/*#define APACHE 0 defined in preprocessor section*/
-
 
 /* ----------------------------------------------------------------
    The following should never need to be played with
index 4dd5c7d73470236f89bc33d3bc391f90a968017c..28706af51416c49b330e2efbeae392de008131d5 100644 (file)
@@ -208,7 +208,6 @@ PHPAPI FILE *php_fopen_wrapper(char *path, char *mode, int options, int *issock,
        }
 }
 
-#if CGI_BINARY || FHTTPD || USE_SAPI
 
 PHPAPI FILE *php_fopen_primary_script(void)
 {
@@ -307,7 +306,6 @@ PHPAPI FILE *php_fopen_primary_script(void)
        return fp;
 }
 
-#endif                                                 /* CGI_BINARY || USE_SAPI */
 
 /*
  * Tries to open a file with a PATH-style list of directories.
index 7152eb8b1634e64aef8ef340da78b87a0271861b..a2d71969e55fc27f6311aeda73b0f957659c852b 100644 (file)
 
 extern int php_init_mime(INIT_FUNC_ARGS);
 
-#if 0
-#if APACHE
-extern zend_module_entry apache_module_entry;
-#define phpext_apache_ptr &apache_module_entry
-extern void php_virtual(INTERNAL_FUNCTION_PARAMETERS);
-#else
-#define phpext_apache_ptr NULL
-#endif
-#endif
-
 /* environment functions */
 extern int php_init_environment(void);
 
index cefb35e6b5251e9a196be71024142b3a74456c14..ff8c3c8c4399c1583bdf8944589aba739e07f6c4 100644 (file)
@@ -30,8 +30,6 @@
 
 #define YYDEBUG 0
 
-#define CGI_BINARY (!APACHE && !USE_SAPI && !FHTTPD)
-
 #include "php_version.h"
 #include "zend.h"
 
@@ -89,6 +87,8 @@ extern unsigned char second_arg_allow_ref[];
 #define inline
 #endif
 
+#define APACHE 0
+#define CGI_BINARY 0
 
 #if HAVE_UNIX_H
 #include <unix.h>
@@ -116,19 +116,6 @@ typedef unsigned int socklen_t;
 
 #include "request_info.h"
 
-#if HAVE_LIBDL
-# if MSVC5
-#  include <windows.h>
-#  define dlclose FreeLibrary
-#  define dlopen(a,b) LoadLibrary(a)
-#  define dlsym GetProcAddress
-# else
-#if HAVE_DLFCN_H && !((defined(_AIX) || defined(AIX)) && APACHE)
-#  include <dlfcn.h>
-#endif
-# endif
-#endif
-
 #define CREATE_MUTEX(a,b)
 #define SET_MUTEX(a)
 #define FREE_MUTEX(a)
@@ -180,35 +167,6 @@ extern char *strerror(int);
 
 #include "fopen-wrappers.h"
 
-#if APACHE /* apache httpd */
-# if HAVE_AP_CONFIG_H
-#include "ap_config_auto.h"
-#ifdef RHAPSODY
-#undef HAVE_SNPRINTF
-#endif
-#include "ap_config.h"
-#ifdef RHAPSODY
-#undef HAVE_SNPRINTF
-#define HAVE_SNPRINTF 1
-#endif
-# endif
-# if HAVE_OLD_COMPAT_H
-#include "compat.h"
-# endif
-# if HAVE_AP_COMPAT_H
-#include "ap_compat.h"
-# endif
-#include "httpd.h"
-#include "http_main.h"
-#include "http_core.h"
-#include "http_request.h"
-#include "http_protocol.h"
-#include "http_config.h"
-#include "http_log.h"
-#define BLOCK_INTERRUPTIONS block_alarms
-#define UNBLOCK_INTERRUPTIONS unblock_alarms
-#endif
-
 #if REGEX == 1 || REGEX == 0
 #include "regex/regex_extra.h"
 #endif
@@ -222,10 +180,6 @@ extern char *strerror(int);
 #include <sys/param.h>
 # endif
 #endif
-#if CGI_BINARY /* CGI version */
-#define BLOCK_INTERRUPTIONS            NULL
-#define UNBLOCK_INTERRUPTIONS  NULL
-#endif
 
 #if HAVE_LIMITS_H
 #include <limits.h>
@@ -292,6 +246,7 @@ extern int ap_vsnprintf(char *, size_t, const char *, va_list);
 extern pval *data;
 #if !(PHP_WIN32)
 extern char **environ;
+#define php_sleep sleep
 #endif
 
 extern void phperror(char *error);
index be0f445af70372ed83668b675563e351ae846de3..f4dc865163bfbd3fa38297531d3cf4c877325701 100644 (file)
@@ -5,10 +5,9 @@
  * REGEX means:
  * 0.. system regex
  * 1.. bundled regex
- * 2.. Apache's regex
  */
 
-#if REGEX == 1
+#if REGEX
 /* get aliases */
 #include "regex/regex_extra.h"
 #include "regex/regex.h"
index 4437dee00351ea175b8962233b456c72188c6ce2..b3afec1146509f3f6898e6c2269b85d56b883ebf 100644 (file)
@@ -55,7 +55,6 @@
 
 #include "php.h"
 
-#if !defined(APACHE) || (!APACHE)
 #if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF)
 
 #include <stdio.h>
@@ -69,9 +68,9 @@
 
 #ifdef HAVE_GCVT
 
-#define ap_ecvt ecvt
-#define ap_fcvt fcvt
-#define ap_gcvt gcvt
+#define ap_php_ecvt ecvt
+#define ap_php_fcvt fcvt
+#define ap_php_gcvt gcvt
 
 #else
 
@@ -81,7 +80,7 @@
  */
 
 /*
- *    ap_ecvt converts to decimal
+ *    ap_php_ecvt converts to decimal
  *      the number of digits is specified by ndigit
  *      decpt is set to the position of the decimal point
  *      sign is set to 0 for positive, 1 for negative
@@ -90,7 +89,7 @@
 #define        NDIG    80
 
 static char *
- ap_cvt(double arg, int ndigits, int *decpt, int *sign, int eflag)
+ ap_php_cvt(double arg, int ndigits, int *decpt, int *sign, int eflag)
 {
        register int r2;
        double fi, fj;
@@ -164,30 +163,30 @@ static char *
 }
 
 static char *
- ap_ecvt(double arg, int ndigits, int *decpt, int *sign)
+ ap_php_ecvt(double arg, int ndigits, int *decpt, int *sign)
 {
-       return (ap_cvt(arg, ndigits, decpt, sign, 1));
+       return (ap_php_cvt(arg, ndigits, decpt, sign, 1));
 }
 
 static char *
- ap_fcvt(double arg, int ndigits, int *decpt, int *sign)
+ ap_php_fcvt(double arg, int ndigits, int *decpt, int *sign)
 {
-       return (ap_cvt(arg, ndigits, decpt, sign, 0));
+       return (ap_php_cvt(arg, ndigits, decpt, sign, 0));
 }
 
 /*
- * ap_gcvt  - Floating output conversion to
+ * ap_php_gcvt  - Floating output conversion to
  * minimal length string
  */
 
 static char *
- ap_gcvt(double number, int ndigit, char *buf)
+ ap_php_gcvt(double number, int ndigit, char *buf)
 {
        int sign, decpt;
        register char *p1, *p2;
        register i;
 
-       p1 = ap_ecvt(number, ndigit, &decpt, &sign);
+       p1 = ap_php_ecvt(number, ndigit, &decpt, &sign);
        p2 = buf;
        if (sign)
                *p2++ = '-';
@@ -413,9 +412,9 @@ static char *
        int decimal_point;
 
        if (format == 'f')
-               p = ap_fcvt(num, precision, &decimal_point, is_negative);
+               p = ap_php_fcvt(num, precision, &decimal_point, is_negative);
        else                                            /* either e or E format */
-               p = ap_ecvt(num, precision + 1, &decimal_point, is_negative);
+               p = ap_php_ecvt(num, precision + 1, &decimal_point, is_negative);
 
        /*
         * Check for Infinity and NaN
@@ -765,7 +764,7 @@ static int format_converter(register buffy * odp, const char *fmt,
                                        /*
                                         * * We use &num_buf[ 1 ], so that we have room for the sign
                                         */
-                                       s = ap_gcvt(va_arg(ap, double), precision, &num_buf[1]);
+                                       s = ap_php_gcvt(va_arg(ap, double), precision, &num_buf[1]);
                                        if (*s == '-')
                                                prefix_char = *s++;
                                        else if (print_sign)
@@ -910,7 +909,7 @@ static void strx_printv(int *ccp, char *buf, size_t len, const char *format,
 }
 
 
-int ap_snprintf(char *buf, size_t len, const char *format,...)
+int ap_php_snprintf(char *buf, size_t len, const char *format,...)
 {
        int cc;
        va_list ap;
@@ -922,7 +921,7 @@ int ap_snprintf(char *buf, size_t len, const char *format,...)
 }
 
 
-int ap_vsnprintf(char *buf, size_t len, const char *format, va_list ap)
+int ap_php_vsnprintf(char *buf, size_t len, const char *format, va_list ap)
 {
        int cc;
 
@@ -931,4 +930,3 @@ int ap_vsnprintf(char *buf, size_t len, const char *format, va_list ap)
 }
 
 #endif                                                 /* HAVE_SNPRINTF */
-#endif                                                 /* APACHE */
index 7c9afdbff819aed4b7c507536b82c778c0b1851f..e9a10e4e794b98e965c51f96ffca3a8dbe331c28 100644 (file)
    +----------------------------------------------------------------------+
  */
 
-#ifndef _PHP3_SNPRINTF_H
-#define _PHP3_SNPRINTF_H
+#ifndef _PHP_SNPRINTF_H
+#define _PHP_SNPRINTF_H
 
 #ifndef HAVE_SNPRINTF
-extern int ap_snprintf(char *, size_t, const char *, ...);
-#define snprintf ap_snprintf
+extern int ap_php_snprintf(char *, size_t, const char *, ...);
+#define snprintf ap_php_snprintf
 #endif
 
 #ifndef HAVE_VSNPRINTF
-extern int ap_vsnprintf(char *, size_t, const char *, va_list ap);
-#define vsnprintf ap_vsnprintf
+extern int ap_php_vsnprintf(char *, size_t, const char *, va_list ap);
+#define vsnprintf ap_php_vsnprintf
 #endif
 
 #if BROKEN_SPRINTF
@@ -35,7 +35,7 @@ int php_sprintf (char* s, const char* format, ...);
 #define php_sprintf sprintf
 #endif
 
-#endif /* _PHP3_SNPRINTF_H */
+#endif /* _PHP_SNPRINTF_H */
 
 /*
  * Local variables:
index b481d70f61963b8ee2daccc1952e81516db21a55..1d565aa8f686ef830537d63c6e708a307f43cf1f 100644 (file)
@@ -25,9 +25,7 @@ typedef char * caddr_t;
 #define mkdir(a,b)     _mkdir(a)
 #define rmdir          _rmdir
 #define getpid         _getpid
-#if !(APACHE)
-#define sleep(t)       Sleep(t*1000)
-#endif
+#define php_sleep(t)   Sleep(t*1000)
 #define getcwd         _getcwd
 #define snprintf       _snprintf
 #define off_t          _off_t
index 770a68bbb59e92716c2c6fb5717bec89d7d7af91..03d5c70329581c8f14a08640b5b4ce4e41ebcc64 100644 (file)
@@ -26,8 +26,6 @@ PHPAPI php_request_info request_info;
 #if CGI_BINARY
 int php_init_request_info(void *conf)
 {
-       request_info.current_user = NULL;
-       request_info.current_user_length = 0;
        request_info.script_name = getenv("SCRIPT_NAME");
        request_info.script_filename = getenv("SCRIPT_FILENAME");
        /* Hack for annoying servers that do not set SCRIPT_FILENAME for us */
@@ -79,8 +77,6 @@ int php_init_request_info(void *conf)
        SLS_FETCH();
 
        r = ((request_rec *) SG(server_context));
-       request_info.current_user = NULL;
-       request_info.current_user_length = 0;
 
        return SUCCESS;
 }
@@ -95,8 +91,18 @@ int php_destroy_request_info(void *conf)
        return SUCCESS;
 }
 #endif
-/*
- * Local variables:
+
+
+int php_init_request_info(void *conf)
+{
+    request_info.current_user = NULL;
+    request_info.current_user_length = 0;
+       return SUCCESS;
+}
+
+
+
+/* * Local variables:
  * tab-width: 4
  * c-basic-offset: 4
  * End:
index ccf9c60b89bd474d26d0ca998727aa3acacd9ee0..12933eea4d64fc1deab1c4a3d32988ed755ac6ff 100644 (file)
@@ -20,7 +20,6 @@
 #define _REQUEST_INFO_H_
 
 typedef struct {
-       char *script_name;
        char *current_user;
        int current_user_length;
        const char *script_filename;
index e35b11caf0025386a4a5399c3df90eebb11f15be..05ade912aad7c283f280df28fcdd328e9e985cb4 100644 (file)
@@ -36,7 +36,6 @@ AC_ARG_WITH(apxs,
                PHP_APXS_BROKEN=yes
        fi
        STRONGHOLD=
-       AC_DEFINE(APACHE)
        AC_DEFINE(HAVE_AP_CONFIG_H)
        AC_DEFINE(HAVE_AP_COMPAT_H)
        AC_MSG_RESULT(yes)
@@ -66,7 +65,6 @@ AC_ARG_WITH(apache,
                        PHP_SAPI=apache
                        APACHE_INSTALL="mkdir -p $APACHE_TARGET; cp $SAPI_STATIC $APACHE_INSTALL_FILES $APACHE_TARGET"
                        PHP_LIBS="-L. -lphp3"
-                       AC_DEFINE(APACHE)
                        AC_MSG_RESULT(yes - Apache 1.2.x)
                        STRONGHOLD=
                        if test -f $withval/src/ap_config.h; then
@@ -84,7 +82,6 @@ AC_ARG_WITH(apache,
                        PHP_SAPI=apache
                        APACHE_INSTALL="mkdir -p $APACHE_TARGET; cp $SAPI_STATIC $APACHE_TARGET/libmodphp4.a; cp $APACHE_INSTALL_FILES $APACHE_TARGET; cp $srcdir/sapi/apache/apMakefile.tmpl $APACHE_TARGET/Makefile.tmpl; cp $srcdir/sapi/apache/apMakefile.libdir $APACHE_TARGET/Makefile.libdir"
                        PHP_LIBS="-Lmodules/php4 -L../modules/php4 -L../../modules/php4 -lmodphp4"
-                       AC_DEFINE(APACHE)
                        AC_MSG_RESULT(yes - Apache 2.0.X)
                        STRONGHOLD=
                        if test -f $withval/src/include/ap_config.h; then
@@ -111,7 +108,6 @@ AC_ARG_WITH(apache,
                        PHP_SAPI=apache
                        APACHE_INSTALL="mkdir -p $APACHE_TARGET; cp $SAPI_STATIC $APACHE_TARGET/libmodphp4.a; cp $APACHE_INSTALL_FILES $APACHE_TARGET; cp $srcdir/sapi/apache/apMakefile.tmpl $APACHE_TARGET/Makefile.tmpl; cp $srcdir/sapi/apache/apMakefile.libdir $APACHE_TARGET/Makefile.libdir"
                        PHP_LIBS="-Lmodules/php4 -L../modules/php4 -L../../modules/php4 -lmodphp4"
-                       AC_DEFINE(APACHE)
                        AC_MSG_RESULT(yes - Apache 1.3.x)
                        STRONGHOLD=
                        if test -f $withval/src/include/ap_config.h; then
@@ -141,7 +137,6 @@ AC_ARG_WITH(apache,
                        PHP_SAPI=apache
                        PHP_LIBS="-Lmodules/php4 -L../modules/php4 -L../../modules/php4 -lmodphp4"
                        APACHE_INSTALL="mkdir -p $APACHE_TARGET; cp $SAPI_STATIC $APACHE_TARGET/libmodphp4.a; cp $APACHE_INSTALL_FILES $APACHE_TARGET; cp $srcdir/sapi/apache/apMakefile.tmpl $APACHE_TARGET/Makefile.tmpl; cp $srcdir/sapi/apache/apMakefile.libdir $APACHE_TARGET/Makefile.libdir"
-                       AC_DEFINE(APACHE)
                        AC_MSG_RESULT(yes - Apache 1.3.x)
                        STRONGHOLD=
                        if test -f $withval/src/include/ap_config.h; then
@@ -165,7 +160,6 @@ AC_ARG_WITH(apache,
                        PHP_LIBS="-Lmodules/php4 -L../modules/php4 -L../../modules/php4 -lmodphp4"
                        APACHE_INSTALL="mkdir -p $APACHE_TARGET; cp $SAPI_STATIC $APACHE_TARGET/libmodphp4.a; cp $APACHE_INSTALL_FILES $APACHE_TARGET"
                        STRONGHOLD=-DSTRONGHOLD=1
-                       AC_DEFINE(APACHE)
                        AC_MSG_RESULT(yes - StrongHold)
                        if test -f $withval/apache/ap_config.h; then
                                AC_DEFINE(HAVE_AP_CONFIG_H)
index 86bab41fa20db3f2ef038b4b4f89c5bb50c15897..5d23a64ab627a3949d52f7d8b772df7549d568e3 100644 (file)
@@ -22,6 +22,7 @@
 #include "zend.h"
 #include "php.h"
 #include "php_variables.h"
+#include "SAPI.h"
 
 #include "httpd.h"
 #include "http_config.h"
@@ -299,6 +300,7 @@ static int php_apache_sapi_activate(SLS_D)
        block_alarms();
        register_cleanup(((request_rec *) SG(server_context))->pool, NULL, php_request_shutdown, php_request_shutdown_for_exec);
        unblock_alarms();
+       return SUCCESS;
 }
 
 
@@ -310,9 +312,7 @@ static struct stat *php_apache_get_stat(SLS_D)
 
 static char *php_apache_getenv(char *name, int name_len SLS_DC)
 {
-       char *value;
-
-       return (char *) table_get(((request_rec *) SG(server_context))->subprocess_env, name));
+       return (char *) table_get(((request_rec *) SG(server_context))->subprocess_env, name);
 }
 
 
index e9988594e633ea5640504a72bca4df787b1cf679..0915feb7c8d23f32235f09388e6e894a846bf66b 100644 (file)
@@ -35,7 +35,7 @@
 #include <errno.h>
 #include <ctype.h>
 
-#if APACHE
+#include "remains.h"
 #include "http_request.h"
 #include "build-defs.h"
 
@@ -440,8 +440,6 @@ PHP_FUNCTION(apache_exec_uri)
 }
 #endif
 
-#endif
-
 /*
  * Local variables:
  * tab-width: 4
diff --git a/sapi/apache/php_apache_http.h b/sapi/apache/php_apache_http.h
new file mode 100644 (file)
index 0000000..a878b8f
--- /dev/null
@@ -0,0 +1,24 @@
+# if HAVE_AP_CONFIG_H
+#include "ap_config_auto.h"
+#ifdef RHAPSODY
+#undef HAVE_SNPRINTF
+#endif
+#include "ap_config.h"
+#ifdef RHAPSODY
+#undef HAVE_SNPRINTF   
+#define HAVE_SNPRINTF 1
+#endif 
+# endif
+# if HAVE_OLD_COMPAT_H
+#include "compat.h"
+# endif
+# if HAVE_AP_COMPAT_H 
+#include "ap_compat.h"
+# endif
+#include "httpd.h"
+#include "http_main.h"    
+#include "http_core.h"    
+#include "http_request.h" 
+#include "http_protocol.h"
+#include "http_config.h"
+#include "http_log.h"
index af4bf9da1c289e51b3038e92f190a863eed69246..b764bfaa02a290170e4349e1256298debb2fb931 100644 (file)
@@ -25,8 +25,6 @@
 
 #include "SAPI.h"
 
-#if CGI_BINARY
-
 #include <stdio.h>
 #include "php.h"
 #ifdef MSVC5
@@ -138,7 +136,7 @@ static void sapi_cgi_register_variables(zval *track_vars_array ELS_DC SLS_DC PLS
                char *val;
                int l=0;
 
-               sn = request_info.script_name;
+               sn = getenv("SCRIPT_NAME");
                pi = SG(request_info).request_uri;
                if (sn)
                        l += strlen(sn);
@@ -574,5 +572,3 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
        return SUCCESS;
 }
 
-
-#endif