From 0b77132507dad64295a1521f9d4abfc5fbb747c9 Mon Sep 17 00:00:00 2001 From: Zeev Suraski Date: Tue, 11 May 1999 00:01:47 +0000 Subject: [PATCH] * Get Apache to work. POST doesn't work yet. * There are now -I directives for the absolute path of php4, php4/libzend and the builddir for the Apache module, so we can #include any php/Zend header. * Rename config.h to php_config.h --- Makefile.in | 8 ++--- configure.in.in | 10 +++++-- ext/ereg/ereg.c | 1 + ext/ereg/php_regex.h | 14 +++++++++ ext/gd/gdcache.c | 2 +- ext/gd/gdttf.c | 2 +- ext/hyperwave/dlist.c | 5 +++- ext/hyperwave/hg_comm.c | 2 +- ext/hyperwave/hw.c | 2 +- ext/interbase/interbase.c | 2 +- ext/odbc/odbc.c | 2 +- ext/pgsql/pgsql.c | 2 +- ext/standard/browscap.c | 1 + ext/standard/post.c | 2 +- ext/standard/reg.c | 1 + ext/standard/url.c | 2 +- ext/sybase/sybase-ct.c | 2 +- ext/sybase/sybase.c | 2 +- ext/sysvsem/sysvsem.c | 2 +- ext/sysvshm/sysvshm.c | 2 +- genif.sh | 4 +-- libphp3.module.in | 4 +-- main/alloca.c | 2 +- main/main.c | 5 ++-- main/php.h | 12 +------- main/php_regex.h | 14 +++++++++ main/snprintf.c | 2 +- mod_php3.c | 61 +++++++++++++++++++++------------------ php3_sprintf.c | 2 +- request_info.c | 10 ------- 30 files changed, 102 insertions(+), 80 deletions(-) create mode 100644 ext/ereg/php_regex.h create mode 100644 main/php_regex.h diff --git a/Makefile.in b/Makefile.in index 10af29153b..4a7e9e3296 100644 --- a/Makefile.in +++ b/Makefile.in @@ -124,7 +124,7 @@ clean: clean-recursive distclean: clean distclean-recursive -rm -f *-parser.[ch] *-scanner.c *.output -rm -f config.status config.cache config.log - -rm -f Makefile Makefile.depend config.h build-defs.h + -rm -f Makefile Makefile.depend php_config.h build-defs.h -rm -f libphp3.module stamp-h -rm -f regex/*.o regex/*.a regex/*.ih -rm -f doc/checkdoc doc/funcparse doc/version.ent @@ -144,8 +144,8 @@ regression check: $(BINNAME) config.status: configure ./config.status --recheck -build-defs.h config.h: stamp-h -stamp-h: config.h.in config.status +build-defs.h php_config.h: stamp-h +stamp-h: php_config.h.in config.status CONFIG_FILES='build-defs.h stamp-h' ./config.status Makefile: Makefile.in config.status @@ -158,7 +158,7 @@ Makefile: Makefile.in config.status configure: @MAINT@ configure.in aclocal.m4 cd $(srcdir) && autoconf -config.h.in: @MAINT@ stamp-h.in +php_config.h.in: @MAINT@ stamp-h.in stamp-h.in: configure.in aclocal.m4 acconfig.h cd ${srcdir} && autoheader && touch ${srcdir}/stamp-h.in diff --git a/configure.in.in b/configure.in.in index 9ea289df70..193ffd19e7 100644 --- a/configure.in.in +++ b/configure.in.in @@ -57,7 +57,7 @@ else fi AC_SUBST(PHP_VERSION) -AM_CONFIG_HEADER(config.h) +AM_CONFIG_HEADER(php_config.h) AM_MAINTAINER_MODE dnl We want this one before the checks, so the checks can modify CFLAGS. @@ -348,8 +348,12 @@ AC_ARG_WITH(apxs, ]) -APACHE_INSTALL_FILES="$srcdir/mod_php3.* $srcdir/php_version.h libphp3.module $srcdir/SAPI.h" +APACHE_INSTALL_FILES="$srcdir/mod_php3.* libphp3.module" +abs_srcdir=`(cd $srcdir; pwd)` +abs_builddir=`pwd` +AC_SUBST(abs_srcdir) +AC_SUBST(abs_builddir) AC_MSG_CHECKING(for Apache module support via DSO through APACI) AC_ARG_WITH(shared-apache, @@ -876,7 +880,7 @@ chmod +x scripts/mkextlib echo "creating internal_functions.c" extensions=\`grep '^s.@EXT_SUBDIRS@' \$0|sed -e 's/^.*@% *//' -e 's/%.*$//'\` mv -f internal_functions.c internal_functions.c.old 2>/dev/null -sh $srcdir/genif.sh $srcdir/internal_functions.c.in \$srcdir \$extensions > internal_functions.c +sh $srcdir/genif.sh $srcdir/internal_functions.c.in $srcdir \$extensions > internal_functions.c if cmp internal_functions.c.old internal_functions.c > /dev/null 2>&1; then echo "internal_functions.c is unchanged" mv internal_functions.c.old internal_functions.c diff --git a/ext/ereg/ereg.c b/ext/ereg/ereg.c index 9b7bbd1899..4c8b1e240e 100644 --- a/ext/ereg/ereg.c +++ b/ext/ereg/ereg.c @@ -33,6 +33,7 @@ #include #include "php.h" #include "php3_string.h" +#include "php_regex.h" #include "reg.h" unsigned char third_argument_force_ref[] = { 3, BYREF_NONE, BYREF_NONE, BYREF_FORCE }; diff --git a/ext/ereg/php_regex.h b/ext/ereg/php_regex.h new file mode 100644 index 0000000000..2d18db721d --- /dev/null +++ b/ext/ereg/php_regex.h @@ -0,0 +1,14 @@ +#ifndef _PHP_REGEX_H +#define _PHP_REGEX_H + +#if REGEX +#include "regex/regex.h" +#define _REGEX_H 1 /* this should stop Apache from loading the system version of regex.h */ +#define _RX_H 1 /* Try defining these for Linux to */ +#define __REGEXP_LIBRARY_H__ 1 /* avoid Apache including regex.h */ +#define _H_REGEX 1 /* This one is for AIX */ +#else +#include +#endif + +#endif /* _PHP_REGEX_H */ \ No newline at end of file diff --git a/ext/gd/gdcache.c b/ext/gd/gdcache.c index 3fd82dea70..1662ebb184 100644 --- a/ext/gd/gdcache.c +++ b/ext/gd/gdcache.c @@ -40,7 +40,7 @@ #if (WIN32|WINNT) #define HAVE_LIBTTF 1 #else -#include "config.h" +#include "php_config.h" #endif #if HAVE_LIBTTF diff --git a/ext/gd/gdttf.c b/ext/gd/gdttf.c index 39e93ed339..93bb3528d1 100644 --- a/ext/gd/gdttf.c +++ b/ext/gd/gdttf.c @@ -7,7 +7,7 @@ #if WIN32|WINNT #include "config.w32.h" #else -#include "config.h" +#include "php_config.h" #endif #if HAVE_LIBTTF #include diff --git a/ext/hyperwave/dlist.c b/ext/hyperwave/dlist.c index 27c1305664..94dd6edf7b 100644 --- a/ext/hyperwave/dlist.c +++ b/ext/hyperwave/dlist.c @@ -18,6 +18,9 @@ * ----------------- * * $Log$ +* Revision 1.1 1999/04/21 23:11:20 ssb +* moved apache, com and hyperwave into ext/ +* * Revision 1.1.1.1 1999/04/07 21:03:31 zeev * PHP 4.0 * @@ -48,7 +51,7 @@ ****************************************************************************/ #ifndef MSVC5 -#include "config.h" +#include "php_config.h" #endif #if HYPERWAVE diff --git a/ext/hyperwave/hg_comm.c b/ext/hyperwave/hg_comm.c index eb10f00f19..9250e20970 100644 --- a/ext/hyperwave/hg_comm.c +++ b/ext/hyperwave/hg_comm.c @@ -32,7 +32,7 @@ #if WIN32|WINNT #include "win95nt.h" #else -#include "config.h" +#include "php_config.h" #endif #if HYPERWAVE diff --git a/ext/hyperwave/hw.c b/ext/hyperwave/hw.c index dcee8874d5..570e415597 100644 --- a/ext/hyperwave/hw.c +++ b/ext/hyperwave/hw.c @@ -31,7 +31,7 @@ #include #if !(WIN32|WINNT) -#include "config.h" +#include "php_config.h" #endif #include "php.h" #include "ext/standard/head.h" diff --git a/ext/interbase/interbase.c b/ext/interbase/interbase.c index 1cc8aa530b..9ad4507c79 100644 --- a/ext/interbase/interbase.c +++ b/ext/interbase/interbase.c @@ -32,7 +32,7 @@ /* TODO: A lot... */ -#include "config.h" +#include "php_config.h" #include "php.h" #include "php3_interbase.h" diff --git a/ext/odbc/odbc.c b/ext/odbc/odbc.c index 3af8798c55..e78a6d4b91 100644 --- a/ext/odbc/odbc.c +++ b/ext/odbc/odbc.c @@ -41,7 +41,7 @@ #if HAVE_UODBC # if !(WIN32|WINNT) -# include "config.h" +# include "php_config.h" # include "build-defs.h" # endif diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index fa38715d25..1d34c2349f 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -33,7 +33,7 @@ #include #ifndef MSVC5 -#include "config.h" +#include "php_config.h" #endif #include "php.h" #include "php3_pgsql.h" diff --git a/ext/standard/browscap.c b/ext/standard/browscap.c index f6bc5e80a3..95136da331 100644 --- a/ext/standard/browscap.c +++ b/ext/standard/browscap.c @@ -30,6 +30,7 @@ #include "php.h" #include "php3_browscap.h" #include "php_ini.h" +#include "php_regex.h" #include "zend_globals.h" diff --git a/ext/standard/post.c b/ext/standard/post.c index 52260585d9..8258493213 100644 --- a/ext/standard/post.c +++ b/ext/standard/post.c @@ -320,7 +320,7 @@ void php3_treat_data(int arg, char *str) { char *res = NULL, *var, *val; pval *array_ptr; - int free_buffer; + int free_buffer=0; ELS_FETCH(); PLS_FETCH(); SLS_FETCH(); diff --git a/ext/standard/reg.c b/ext/standard/reg.c index 9b7bbd1899..4c8b1e240e 100644 --- a/ext/standard/reg.c +++ b/ext/standard/reg.c @@ -33,6 +33,7 @@ #include #include "php.h" #include "php3_string.h" +#include "php_regex.h" #include "reg.h" unsigned char third_argument_force_ref[] = { 3, BYREF_NONE, BYREF_NONE, BYREF_FORCE }; diff --git a/ext/standard/url.c b/ext/standard/url.c index a44f01a4dc..e5acd6c578 100644 --- a/ext/standard/url.c +++ b/ext/standard/url.c @@ -33,8 +33,8 @@ #include #include -/* php.h includes the correct regex.h */ #include "php.h" +#include "php_regex.h" #include "url.h" #ifdef _OSD_POSIX diff --git a/ext/sybase/sybase-ct.c b/ext/sybase/sybase-ct.c index 58ba286bad..a07c1994ec 100644 --- a/ext/sybase/sybase-ct.c +++ b/ext/sybase/sybase-ct.c @@ -32,7 +32,7 @@ #ifndef MSVC5 -#include "config.h" +#include "php_config.h" #endif #include "php.h" #include "php3_sybase-ct.h" diff --git a/ext/sybase/sybase.c b/ext/sybase/sybase.c index 94a8c9ccd1..f52790227f 100644 --- a/ext/sybase/sybase.c +++ b/ext/sybase/sybase.c @@ -35,7 +35,7 @@ #ifndef MSVC5 -#include "config.h" +#include "php_config.h" #endif #include "php.h" #include "php3_sybase.h" diff --git a/ext/sysvsem/sysvsem.c b/ext/sysvsem/sysvsem.c index 2c2a9ccbc0..4107f1477c 100644 --- a/ext/sysvsem/sysvsem.c +++ b/ext/sysvsem/sysvsem.c @@ -36,7 +36,7 @@ */ #ifndef MSVC5 -#include "config.h" +#include "php_config.h" #endif #if HAVE_SYSVSEM diff --git a/ext/sysvshm/sysvshm.c b/ext/sysvshm/sysvshm.c index 68547281c5..88678478c7 100644 --- a/ext/sysvshm/sysvshm.c +++ b/ext/sysvshm/sysvshm.c @@ -34,7 +34,7 @@ */ #ifndef MSVC5 -#include "config.h" +#include "php_config.h" #endif diff --git a/genif.sh b/genif.sh index b074f84ed8..b04486bf83 100644 --- a/genif.sh +++ b/genif.sh @@ -1,6 +1,6 @@ #! /bin/sh -# $Id: genif.sh,v 1.4 1999-05-08 22:00:02 sas Exp $ +# $Id: genif.sh,v 1.5 1999-05-11 00:01:41 zeev Exp $ # replacement for genif.pl infile="$1" @@ -20,7 +20,7 @@ for ext in ${1+"$@"} ; do module_ptrs=" phpext_${ext}_ptr,\\\n$module_ptrs" for pre in php3 php php4 zend; do hdrfile="ext/$ext/${pre}_${ext}.h" - if test -f $hdrfile ; then + if test -f "$srcdir/$hdrfile" ; then includes="#include \"$hdrfile\"\\\n$includes" fi done diff --git a/libphp3.module.in b/libphp3.module.in index b762834981..5b234bf875 100644 --- a/libphp3.module.in +++ b/libphp3.module.in @@ -3,5 +3,5 @@ ConfigStart RULE_WANTHSREGEX=@HSREGEX@ LIBS="@PHP_LIBS@ @EXTRA_LIBS@ @LIBS@ @RDYNAMIC_LFLAGS@ $LIBS" RULE_HIDE=yes -ConfigEnd - + CFLAGS="$CFLAGS -I@abs_srcdir@ -I@abs_srcdir@/libzend -I@abs_builddir@" +ConfigEnd \ No newline at end of file diff --git a/main/alloca.c b/main/alloca.c index aa512d9a1c..a520f2c834 100644 --- a/main/alloca.c +++ b/main/alloca.c @@ -21,7 +21,7 @@ allocating any. It is a good idea to use alloca(0) in your main control loop, etc. to force garbage collection. */ -#include +#include "php_config.h" #if !HAVE_ALLOCA diff --git a/main/main.c b/main/main.c index 1f3303304d..006032f498 100644 --- a/main/main.c +++ b/main/main.c @@ -921,6 +921,7 @@ int _php3_hash_environment(PLS_D ELS_DC) case 'g': case 'G': if (!_gpc_flags[2]) { + printf("Parsing GET data: '%s'\n", SG(request_info).query_string); php3_treat_data(PARSE_GET, NULL); /* GET Data */ _gpc_flags[2]=1; } @@ -1188,7 +1189,7 @@ PHPAPI void php_execute_script(zend_file_handle *primary_file CLS_DC ELS_DC PLS_ /* some systems are missing these from their header files */ #if APACHE -PHPAPI int apache_php3_module_main(request_rec *r, int fd, int display_source_mode) +PHPAPI int apache_php3_module_main(request_rec *r, int fd, int display_source_mode SLS_DC) { zend_file_handle file_handle; #ifdef ZTS @@ -1201,8 +1202,6 @@ PHPAPI int apache_php3_module_main(request_rec *r, int fd, int display_source_mo #endif SLS_FETCH(); - SG(server_context) = r; - if (php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC) == FAILURE) { return FAILURE; } diff --git a/main/php.h b/main/php.h index f40528ea00..e7df9ae5ad 100644 --- a/main/php.h +++ b/main/php.h @@ -75,7 +75,7 @@ extern unsigned char second_arg_allow_ref[]; # define PHPAPI __declspec(dllimport) # endif #else -#include "config.h" +#include "php_config.h" #define PHPAPI #define THREAD_LS #endif @@ -151,16 +151,6 @@ typedef zval pval; #define pval_copy_constructor zval_copy_ctor #define pval_destructor zval_dtor -#if REGEX -#include "regex/regex.h" -#define _REGEX_H 1 /* this should stop Apache from loading the system version of regex.h */ -#define _RX_H 1 /* Try defining these for Linux to */ -#define __REGEXP_LIBRARY_H__ 1 /* avoid Apache including regex.h */ -#define _H_REGEX 1 /* This one is for AIX */ -#else -#include -#endif - #if STDC_HEADERS # include #else diff --git a/main/php_regex.h b/main/php_regex.h new file mode 100644 index 0000000000..2d18db721d --- /dev/null +++ b/main/php_regex.h @@ -0,0 +1,14 @@ +#ifndef _PHP_REGEX_H +#define _PHP_REGEX_H + +#if REGEX +#include "regex/regex.h" +#define _REGEX_H 1 /* this should stop Apache from loading the system version of regex.h */ +#define _RX_H 1 /* Try defining these for Linux to */ +#define __REGEXP_LIBRARY_H__ 1 /* avoid Apache including regex.h */ +#define _H_REGEX 1 /* This one is for AIX */ +#else +#include +#endif + +#endif /* _PHP_REGEX_H */ \ No newline at end of file diff --git a/main/snprintf.c b/main/snprintf.c index 32bff374e2..9c6a552f61 100644 --- a/main/snprintf.c +++ b/main/snprintf.c @@ -53,7 +53,7 @@ * for xinetd. */ -#include "config.h" +#include "php_config.h" #if !defined(APACHE) || (!APACHE) #if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF) diff --git a/mod_php3.c b/mod_php3.c index 01bdd8d73d..85451001b4 100644 --- a/mod_php3.c +++ b/mod_php3.c @@ -25,7 +25,7 @@ +----------------------------------------------------------------------+ | Authors: Rasmus Lerdorf | | (with helpful hints from Dean Gaudet | - | PHP4 patches by Zeev Suraski | + | PHP 4.0 patches by Zeev Suraski | +----------------------------------------------------------------------+ */ /* $Id$ */ @@ -44,27 +44,11 @@ #include "http_protocol.h" #include "http_request.h" #include "http_log.h" -#include "SAPI.h" - - -/* These are taken out of php_ini.h - * they must be updated if php_ini.h changes! - */ -#define PHP_INI_USER (1<<0) -#define PHP_INI_PERDIR (1<<1) -#define PHP_INI_SYSTEM (1<<2) -/* These are taken out of main.h - * they must be updated if main.h changes! - */ - -int apache_php3_module_main(request_rec * r, int fd, int display_source_mode); -int php_module_startup(sapi_module_struct *sf); -void php_module_shutdown(); -void php_module_shutdown_for_exec(); -int php_module_shutdown_wrapper(sapi_module_struct *sapi_globals); - -int php3_error(int type, const char *format, ...); +#include "php.h" +#include "php_ini.h" +#include "SAPI.h" +#include "main.h" #include "util_script.h" @@ -74,6 +58,8 @@ int php3_error(int type, const char *format, ...); # include "mod_dav.h" #endif +PHPAPI int apache_php3_module_main(request_rec *r, int fd, int display_source_mode SLS_DC); + /* ### these should be defined in mod_php3.h or somewhere else */ #define USE_PATH 1 #define IGNORE_URL 2 @@ -120,15 +106,15 @@ static int zend_apache_ub_write(const char *str, uint str_length) } -char *sapi_apache_read_post(SLS_D) +int sapi_apache_read_post(char *buffer, uint count_bytes SLS_DC) { - return NULL; + return 0; } char *sapi_apache_read_cookies(SLS_D) { - return table_get(r->subprocess_env, "HTTP_COOKIE"); + return (char *) table_get(((request_rec *) SG(server_context))->subprocess_env, "HTTP_COOKIE"); } @@ -146,11 +132,11 @@ int sapi_apache_header_handler(sapi_header_struct *sapi_header, sapi_headers_str *p = 0; do { - header_content++ + header_content++; } while (*header_content==' '); if (!strcasecmp(header_name, "Content-Type")) { - r->content_type = pstrdup(header_content); + r->content_type = pstrdup(r->pool, header_content); } else if (!strcasecmp(header_name, "Location")) { r->status = REDIRECT; } else { @@ -163,7 +149,7 @@ int sapi_apache_header_handler(sapi_header_struct *sapi_header, sapi_headers_str } -void sapi_apache_send_headers(sapi_headers_struct *sapi_headers SLS_DC) +int sapi_apache_send_headers(sapi_headers_struct *sapi_headers SLS_DC) { send_http_header((request_rec *) SG(server_context)); return SAPI_HEADER_SENT_SUCCESSFULLY; @@ -195,9 +181,24 @@ void php3_restore_umask() } +static void init_request_info(SLS_D) +{ + request_rec *r = ((request_rec *) SG(server_context)); + char *content_length = (char *) table_get(r->subprocess_env, "CONTENT_LENGTH"); + + SG(request_info).query_string = r->args; + SG(request_info).path_translated = r->filename; + SG(request_info).request_uri = r->uri; + SG(request_info).request_method = r->method; + SG(request_info).content_type = (char *) table_get(r->subprocess_env, "CONTENT_TYPE"); + SG(request_info).content_length = (content_length ? atoi(content_length) : 0); +} + + int send_php3(request_rec *r, int display_source_mode, char *filename) { int fd, retval; + SLS_FETCH(); /* We don't accept OPTIONS requests, but take everything else */ if (r->method_number == M_OPTIONS) { @@ -251,11 +252,15 @@ int send_php3(request_rec *r, int display_source_mode, char *filename) /* Init timeout */ hard_timeout("send", r); + SG(server_context) = r; + init_request_info(SLS_C); + php3_save_umask(); chdir_file(filename); add_common_vars(r); add_cgi_vars(r); - apache_php3_module_main(r, fd, display_source_mode); + init_request_info(); + apache_php3_module_main(r, fd, display_source_mode SLS_CC); /* Done, restore umask, turn off timeout, close file and return */ php3_restore_umask(); diff --git a/php3_sprintf.c b/php3_sprintf.c index f90a46b356..8f34b29cab 100644 --- a/php3_sprintf.c +++ b/php3_sprintf.c @@ -30,7 +30,7 @@ /* $Id$ */ -#include "config.h" +#include "php_config.h" #include #include diff --git a/request_info.c b/request_info.c index 884b184c31..5ed42393b5 100644 --- a/request_info.c +++ b/request_info.c @@ -92,23 +92,13 @@ int php3_destroy_request_info(void *conf) #if APACHE int php3_init_request_info(void *conf) { - const char *buf; request_rec *r; SLS_FETCH(); r = ((request_rec *) SG(server_context)); - SG(request_info).query_string = r->args; - SG(request_info).path_translated = r->filename; - SG(request_info).request_uri = r->uri; request_info.current_user = NULL; request_info.current_user_length = 0; - request_info.filename = r->filename; - SG(request_info).request_method = r->method; - SG(request_info).content_type = table_get(r->subprocess_env, "CONTENT_TYPE"); - - buf = table_get(r->subprocess_env, "CONTENT_LENGTH"); - SG(request_info).content_length = (buf ? atoi(buf) : 0); return SUCCESS; } -- 2.40.0