Fix building thttpd SAPI module.

This works now with thttpd 2.19.

Thanks to Andrzej Borsuk <andrzej.borsuk@alfaelektro.com.pl> for
pointing me into the right direction.
This commit is contained in:
Sascha Schumann 2000-08-07 13:54:35 +00:00
parent 55801d5330
commit 4b8823d427
5 changed files with 60 additions and 31 deletions

View File

@ -1,5 +1,5 @@
LTLIBRARY_NAME = libsapi.la
LTLIBRARY_SOURCES = thttpd.c
LTLIBRARY_SOURCES = stub.c
include $(top_srcdir)/build/ltlib.mk

View File

@ -4,7 +4,7 @@ README FOR THTTPD MODULE (by Sascha Schumann)
This is a SAPI module for PHP 4.0 supporting thttpd, the tiny,
turbo, throttling HTTP server by Jef Poskanzer.
The module contains a patch against version 2.10 of thttpd. The patch
The module contains a patch against version 2.19 of thttpd. The patch
adds hooks to thttpd to call PHP, if a filename matches *.php. This
patch will be applied when you install PHP.
@ -20,11 +20,11 @@ REQUIRED DOWNLOADS
2. PHP 4.0.x
Beta Versions:
http://www.php.net/version4/
Download:
http://www.php.net/
Snapshots:
http://va.php.net/~sas/snapshots/
Snapshots from CVS:
http://snaps.php.net/
BUILD INSTRUCTIONS

View File

@ -5,6 +5,8 @@ AC_ARG_WITH(thttpd,
INSTALL_IT="\
echo 'PHP_LIBS = -L. -lphp4 \$(PHP_LIBS) \$(EXTRA_LIBS)' > $THTTPD/php_makefile; \
echo 'PHP_LDFLAGS = \$(NATIVE_RPATHS) \$(PHP_LDFLAGS)' >> $THTTPD/php_makefile; \
echo 'PHP_CFLAGS = \$(COMMON_FLAGS) \$(CFLAGS) \$(EXTRA_CFLAGS)' >> $THTTPD/php_makefile; \
\$(LN_S) $abs_srcdir/sapi/thttpd/thttpd.c $THTTPD/php_thttpd.c; \
cp $abs_srcdir/sapi/thttpd/php_thttpd.h $SAPI_STATIC $THTTPD;\
test -f $THTTPD/php_patched || \
(cd $THTTPD && patch < $abs_srcdir/sapi/thttpd/thttpd_patch && touch php_patched)"

0
sapi/thttpd/stub.c Normal file
View File

View File

@ -1,6 +1,6 @@
diff -ur thttpd-2.10/Makefile.in thttpd-2.10-php/Makefile.in
--- thttpd-2.10/Makefile.in Mon Oct 11 20:45:38 1999
+++ thttpd-2.10-php/Makefile.in Mon Dec 20 01:37:49 1999
diff -ur thttpd-2.19/Makefile.in thttpd-2.19-t/Makefile.in
--- thttpd-2.19/Makefile.in Tue Jul 4 18:21:32 2000
+++ thttpd-2.19-t/Makefile.in Mon Aug 7 15:34:41 2000
@@ -46,13 +46,15 @@
# You shouldn't need to edit anything below here.
@ -19,9 +19,31 @@ diff -ur thttpd-2.10/Makefile.in thttpd-2.10-php/Makefile.in
NETLIBS = @V_NETLIBS@
INSTALL = @INSTALL@
diff -ur thttpd-2.10/libhttpd.c thttpd-2.10-php/libhttpd.c
--- thttpd-2.10/libhttpd.c Wed Dec 15 23:22:50 1999
+++ thttpd-2.10-php/libhttpd.c Mon Dec 20 01:05:47 1999
@@ -62,7 +64,7 @@
@rm -f $@
$(CC) $(CFLAGS) -c $*.c
-SRC = thttpd.c libhttpd.c fdwatch.c mmc.c timers.c match.c tdate_parse.c syslog.c
+SRC = thttpd.c libhttpd.c fdwatch.c mmc.c timers.c match.c tdate_parse.c syslog.c php_thttpd.c
OBJ = $(SRC:.c=.o) @LIBOBJS@
@@ -151,6 +153,9 @@
tags:
ctags -wtd *.c *.h
+
+php_thttpd.o: php_thttpd.c
+ $(CC) $(PHP_CFLAGS) $(CFLAGS) -c php_thttpd.c
tar:
@name=`sed -n -e '/SERVER_SOFTWARE/!d' -e 's,.*thttpd/,thttpd-,' -e 's, .*,,p' version.h` ; \
Only in thttpd-2.19-t/cgi-src: Makefile
Only in thttpd-2.19-t/: config.log
Only in thttpd-2.19-t/extras: Makefile
diff -ur thttpd-2.19/libhttpd.c thttpd-2.19-t/libhttpd.c
--- thttpd-2.19/libhttpd.c Fri Jun 23 05:43:40 2000
+++ thttpd-2.19-t/libhttpd.c Mon Aug 7 15:27:25 2000
@@ -75,6 +75,8 @@
#include "match.h"
#include "tdate_parse.h"
@ -31,36 +53,41 @@ diff -ur thttpd-2.10/libhttpd.c thttpd-2.10-php/libhttpd.c
#ifndef STDIN_FILENO
#define STDIN_FILENO 0
#endif
@@ -211,7 +213,11 @@
@@ -224,6 +226,8 @@
free( (void*) hs->cwd );
if ( hs->cgi_pattern != (char*) 0 )
free( (void*) hs->cgi_pattern );
+ if ( hs->php_pattern != (char*) 0 )
+ free( (void *) hs->php_pattern );
+ free( (void*) hs->php_pattern );
if ( hs->charset != (char*) 0 )
free( (void*) hs->charset );
if ( hs->url_pattern != (char*) 0 )
@@ -231,6 +235,7 @@
if ( hs->local_pattern != (char*) 0 )
free( (void*) hs->local_pattern );
free( (void*) hs );
+
+ thttpd_php_shutdown();
}
@@ -244,6 +250,7 @@
else
hs->hostname = strdup( hostname );
@@ -291,6 +296,7 @@
}
hs->port = port;
+ hs->php_pattern = strdup("*.php");
if ( cgi_pattern == (char*) 0 )
hs->cgi_pattern = (char*) 0;
else
@@ -272,6 +279,8 @@
hs->no_symlinks = no_symlinks;
hs->vhost = vhost;
@@ -379,6 +385,8 @@
int listen_fd;
int on, flags;
+ thttpd_php_init();
+
/* Create socket. */
hs->listen_fd = socket( AF_INET, SOCK_STREAM, 0 );
if ( hs->listen_fd < 0 )
@@ -3129,6 +3138,11 @@
listen_fd = socket( saP->sa.sa_family, SOCK_STREAM, 0 );
if ( listen_fd < 0 )
@@ -3302,6 +3310,11 @@
( hc->sb.st_mode & S_IXOTH ) &&
match( hc->hs->cgi_pattern, hc->expnfilename ) )
return cgi( hc );
@ -72,14 +99,14 @@ diff -ur thttpd-2.10/libhttpd.c thttpd-2.10-php/libhttpd.c
/* It's not CGI. If it's executable or there's pathinfo, someone's
** trying to either serve or run a non-CGI file as CGI. Either case
diff -ur thttpd-2.10/libhttpd.h thttpd-2.10-php/libhttpd.h
--- thttpd-2.10/libhttpd.h Wed Dec 8 19:53:34 1999
+++ thttpd-2.10-php/libhttpd.h Mon Dec 20 01:06:09 1999
@@ -57,6 +57,7 @@
struct in_addr host_addr;
diff -ur thttpd-2.19/libhttpd.h thttpd-2.19-t/libhttpd.h
--- thttpd-2.19/libhttpd.h Tue Jun 13 20:48:56 2000
+++ thttpd-2.19-t/libhttpd.h Mon Aug 7 15:33:08 2000
@@ -69,6 +69,7 @@
char* server_hostname;
int port;
char* cgi_pattern;
+ char* php_pattern;
char* charset;
char* cwd;
int listen_fd;
FILE* logfp;
int listen4_fd, listen6_fd;