summaryrefslogtreecommitdiff
path: root/sapi/thttpd/thttpd_patch
blob: ff6b60d991981c67ebda13e9e2a75e44007d5327 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
diff -Nur thttpd-2.20b/Makefile.in thttpd-2.20b-php/Makefile.in
--- thttpd-2.20b/Makefile.in	Tue Jul  4 18:21:32 2000
+++ thttpd-2.20b-php/Makefile.in	Mon Nov 13 14:25:48 2000
@@ -46,13 +46,15 @@
 
 # You shouldn't need to edit anything below here.
 
+include php_makefile
+
 CC =		@CC@
 CCOPT =		@V_CCOPT@
 DEFS =		@DEFS@
 INCLS =		-I.
 CFLAGS =	$(CCOPT) $(DEFS) $(INCLS)
-LDFLAGS =	@LDFLAGS@
-LIBS =		@LIBS@
+LDFLAGS =	@LDFLAGS@ $(PHP_LDFLAGS)
+LIBS =		@LIBS@ $(PHP_LIBS)
 NETLIBS =	@V_NETLIBS@
 INSTALL =	@INSTALL@
 
@@ -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` ; \
diff -Nur thttpd-2.20b/libhttpd.c thttpd-2.20b-php/libhttpd.c
--- thttpd-2.20b/libhttpd.c	Wed Sep 27 20:13:24 2000
+++ thttpd-2.20b-php/libhttpd.c	Mon Nov 13 14:25:57 2000
@@ -75,6 +75,8 @@
 #include "match.h"
 #include "tdate_parse.h"
 
+#include "php_thttpd.h"
+
 #ifndef STDIN_FILENO
 #define STDIN_FILENO 0
 #endif
@@ -225,6 +227,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 );
     if ( hs->charset != (char*) 0 )
 	free( (void*) hs->charset );
     if ( hs->url_pattern != (char*) 0 )
@@ -232,6 +236,7 @@
     if ( hs->local_pattern != (char*) 0 )
 	free( (void*) hs->local_pattern );
     free( (void*) hs );
+    thttpd_php_shutdown();
     }
 
 
@@ -292,6 +297,7 @@
 	}
 
     hs->port = port;
+    hs->php_pattern = strdup("**.php");
     if ( cgi_pattern == (char*) 0 )
 	hs->cgi_pattern = (char*) 0;
     else
@@ -363,6 +369,8 @@
 	return (httpd_server*) 0;
 	}
 
+    thttpd_php_init();
+
     /* Done initializing. */
     if ( hs->binding_hostname == (char*) 0 )
 	syslog( LOG_INFO, "%s starting on port %d", SERVER_SOFTWARE, hs->port );
@@ -2167,7 +2175,9 @@
 void
 httpd_close_conn( httpd_conn* hc, struct timeval* nowP )
     {
-    if ( hc->file_address != (char*) 0 )
+	if (hc->file_address == (char *) 1) {
+		thttpd_closed_conn(hc->conn_fd);
+	} else if ( hc->file_address != (char*) 0 )
 	{
 	mmc_unmap( hc->file_address, nowP, &(hc->sb) );
 	hc->file_address = (char*) 0;
@@ -3336,6 +3346,11 @@
 	 ( hc->sb.st_mode & S_IXOTH ) &&
 	 match( hc->hs->cgi_pattern, hc->expnfilename ) )
 	return cgi( hc );
+
+	if ( hc->hs->php_pattern != (char*) 0 &&
+			match( hc->hs->php_pattern, hc->expnfilename)) {
+		return thttpd_php_request( hc );
+	}
 
     /* 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 -Nur thttpd-2.20b/libhttpd.h thttpd-2.20b-php/libhttpd.h
--- thttpd-2.20b/libhttpd.h	Tue Jun 13 20:48:56 2000
+++ thttpd-2.20b-php/libhttpd.h	Mon Nov 13 14:25:48 2000
@@ -69,6 +69,7 @@
     char* server_hostname;
     int port;
     char* cgi_pattern;
+    char* php_pattern;
     char* charset;
     char* cwd;
     int listen4_fd, listen6_fd;
diff -Nur thttpd-2.20b/thttpd.c thttpd-2.20b-php/thttpd.c
--- thttpd-2.20b/thttpd.c	Wed Sep 27 21:31:48 2000
+++ thttpd-2.20b-php/thttpd.c	Mon Nov 13 14:25:57 2000
@@ -1332,6 +1333,12 @@
 	c->bytes_sent = hc->bytes;
 	clear_connection( c, tvP );
 	return;
+	}
+	if (hc->file_address == (char *) 1) {
+		tmr_cancel( c->idle_read_timer );
+		c->idle_read_timer = (Timer*) 0;
+		c->wouldblock_delay = 0;
+		return;
 	}
     if ( c->bytes_sent >= c->bytes_to_send )
 	{