diff options
author | Thies C. Arntzen <thies@php.net> | 1999-12-28 13:58:52 +0000 |
---|---|---|
committer | Thies C. Arntzen <thies@php.net> | 1999-12-28 13:58:52 +0000 |
commit | f3240be01650ab1ce43b4ce2a8a14a1bfa51bbb2 (patch) | |
tree | 6fc5fbc9ac3e86128d2e7f0457a73759b7b1ab82 /sapi/phttpd | |
parent | eb1927d94ea570f3663ef8cdaef3128fe81167f8 (diff) | |
download | php-git-f3240be01650ab1ce43b4ce2a8a14a1bfa51bbb2.tar.gz |
SAPI module for phttpd - found at ftp://ftp.netuse.de/pub/phttpd/, ftp://ftp.signum.se/pub/phttpd/
(DOES NOT WORK YET!!)
Diffstat (limited to 'sapi/phttpd')
-rw-r--r-- | sapi/phttpd/Makefile.am | 2 | ||||
-rw-r--r-- | sapi/phttpd/config.h.stub | 1 | ||||
-rw-r--r-- | sapi/phttpd/config.m4 | 24 | ||||
-rw-r--r-- | sapi/phttpd/php.sym | 4 | ||||
-rw-r--r-- | sapi/phttpd/php_phttpd.h | 24 | ||||
-rw-r--r-- | sapi/phttpd/phttpd.c | 251 |
6 files changed, 306 insertions, 0 deletions
diff --git a/sapi/phttpd/Makefile.am b/sapi/phttpd/Makefile.am new file mode 100644 index 0000000000..6430c64bc5 --- /dev/null +++ b/sapi/phttpd/Makefile.am @@ -0,0 +1,2 @@ +noinst_LTLIBRARIES=libphpsapi_phttpd.la +libphpsapi_phttpd_la_SOURCES=phttpd.c diff --git a/sapi/phttpd/config.h.stub b/sapi/phttpd/config.h.stub new file mode 100644 index 0000000000..56c1d73baa --- /dev/null +++ b/sapi/phttpd/config.h.stub @@ -0,0 +1 @@ +#undef HAVE_PHTTPD diff --git a/sapi/phttpd/config.m4 b/sapi/phttpd/config.m4 new file mode 100644 index 0000000000..299e69225c --- /dev/null +++ b/sapi/phttpd/config.m4 @@ -0,0 +1,24 @@ +dnl ## $Id$ -*- sh -*- + +RESULT=no +AC_MSG_CHECKING(for PHTTPD support) +AC_ARG_WITH(phttpd, +[ --with-phttpd=DIR], +[ + if test ! -d $withval ; then + AC_MSG_ERROR(You did not specify a directory) + fi + PHP_BUILD_THREAD_SAFE + PHTTPD_DIR=$withval + AC_ADD_INCLUDE($PHTTPD_DIR/include) + AC_DEFINE(HAVE_PHTTPD) + PHP_SAPI=phttpd + PHP_BUILD_SHARED + INSTALL_IT="\$(SHELL) \$(srcdir)/install-sh -m 0755 $SAPI_SHARED $PHTTPD_DIR/modules/" + RESULT=yes +]) +AC_MSG_RESULT($RESULT) + +dnl ## Local Variables: +dnl ## tab-width: 4 +dnl ## End: diff --git a/sapi/phttpd/php.sym b/sapi/phttpd/php.sym new file mode 100644 index 0000000000..f10b883a99 --- /dev/null +++ b/sapi/phttpd/php.sym @@ -0,0 +1,4 @@ +pm_init +pm_exit +pm_request + diff --git a/sapi/phttpd/php_phttpd.h b/sapi/phttpd/php_phttpd.h new file mode 100644 index 0000000000..83e2d935d8 --- /dev/null +++ b/sapi/phttpd/php_phttpd.h @@ -0,0 +1,24 @@ +/* + +----------------------------------------------------------------------+ + | PHP version 4.0 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997, 1998, 1999 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 2.0 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | http://www.php.net/license/2_0.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Thies C. Arntzen <thies@digicol.de> | + +----------------------------------------------------------------------+ +*/ + +#ifndef PHP_PHTTPD_H +#define PHP_PHTTPD_H + +#include <phttpd.h> + +#endif diff --git a/sapi/phttpd/phttpd.c b/sapi/phttpd/phttpd.c new file mode 100644 index 0000000000..b8e5c651dc --- /dev/null +++ b/sapi/phttpd/phttpd.c @@ -0,0 +1,251 @@ +/* + +----------------------------------------------------------------------+ + | PHP version 4.0 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997, 1998, 1999 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 2.0 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | http://www.php.net/license/2_0.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Thies C. Arntzen <thies@digicol.de> | + +----------------------------------------------------------------------+ +*/ + + +#include "php.h" +#include "SAPI.h" +#include "main.h" +#include "php_phttpd.h" + +static int +php_phttpd_startup(sapi_module_struct *sapi_module) +{ +/* + if(php_module_startup(sapi_module) == FAILURE + || zend_register_module(&php_aolserver_module) == FAILURE) { +*/ + fprintf(stderr,"***php_phttpd_startup\n"); + + if (php_module_startup(sapi_module)) { + return FAILURE; + } else { + return SUCCESS; + } +} + +static int +php_phttpd_sapi_ub_write(const char *str, uint str_length) +{ + int sent_bytes; + fprintf(stderr,"***php_phttpd_sapi_ub_write\n"); + fwrite(str,1,str_length,stderr); + return 0; +/* + NSLS_FETCH(); + + sent_bytes = Ns_ConnWrite(NSG(conn), (void *) str, str_length); + + return sent_bytes; +*/ +} + +static int +php_phttpd_sapi_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers SLS_DC) +{ +#if 0 + char *header_name, *header_content; + char *p; + NSLS_FETCH(); + + header_name = sapi_header->header; + header_content = p = strchr(header_name, ':'); + + if (p) { + *p = '\0'; + do { + header_content++; + } while (*header_content == ' '); + + if (!strcasecmp(header_name, "Content-type")) { + Ns_ConnSetTypeHeader(NSG(conn), header_content); + } else { + Ns_ConnSetHeaders(NSG(conn), header_name, header_content); + } + + *p = ':'; + } + + sapi_free_header(sapi_header); +#endif + fprintf(stderr,"***php_phttpd_sapi_header_handler\n"); + + return 0; +} + +static int +php_phttpd_sapi_send_headers(sapi_headers_struct *sapi_headers SLS_DC) +{ +/* + NSLS_FETCH(); + + if(SG(sapi_headers).send_default_content_type) { + Ns_ConnSetRequiredHeaders(NSG(conn), "text/html", 0); + } + + Ns_ConnFlushHeaders(NSG(conn), SG(sapi_headers).http_response_code); +*/ + + fprintf(stderr,"***php_phttpd_sapi_send_headers\n"); + + return SAPI_HEADER_SENT_SUCCESSFULLY; +} + +static char * +php_phttpd_sapi_read_cookies(SLS_D) +{ + +/* + int i; + char *http_cookie = NULL; + NSLS_FETCH(); + + i = Ns_SetIFind(NSG(conn->headers), "cookie"); + if(i != -1) { + http_cookie = Ns_SetValue(NSG(conn->headers), i); + } + + return http_cookie; +*/ + fprintf(stderr,"***php_phttpd_sapi_read_cookies\n"); + + return 0; +} + +static int +php_phttpd_sapi_read_post(char *buf, uint count_bytes SLS_DC) +{ +/* + uint max_read; + uint total_read = 0; + NSLS_FETCH(); + + max_read = MIN(NSG(data_avail), count_bytes); + + total_read = Ns_ConnRead(NSG(conn), buf, max_read); + + if(total_read == NS_ERROR) { + total_read = -1; + } else { + NSG(data_avail) -= total_read; + } + + return total_read; +*/ + fprintf(stderr,"***php_phttpd_sapi_read_post\n"); + return 0; +} + +static sapi_module_struct sapi_module = { + "PHTTPD", + + php_phttpd_startup, /* startup */ + php_module_shutdown_wrapper, /* shutdown */ + + php_phttpd_sapi_ub_write, /* unbuffered write */ + + php_error, /* error handler */ + + php_phttpd_sapi_header_handler, /* header handler */ + php_phttpd_sapi_send_headers, /* send headers handler */ + NULL, /* send header handler */ + + php_phttpd_sapi_read_post, /* read POST data */ + php_phttpd_sapi_read_cookies, /* read Cookies */ + + STANDARD_SAPI_MODULE_PROPERTIES +}; + + +int pm_init(const char **argv) +{ + fprintf(stderr,"***pm_init\n"); + tsrm_startup(1, 1, 0); + fprintf(stderr,"***tsrm_startup\n"); + reentrancy_startup(); + fprintf(stderr,"***reentrancy_startup\n"); + sapi_startup(&sapi_module); + fprintf(stderr,"***sapi_startup\n"); + sapi_module.startup(&sapi_module); + fprintf(stderr,"***sapi_module.startup\n"); + + return 0; +} + +void pm_exit(void) +{ + fprintf(stderr,"***pm_exit\n"); +} + +int php_doit(struct connectioninfo *cip) +{ + char path[MAXPATHLEN]; + struct stat sb; + zend_file_handle file_handle; + struct httpinfo *hip = cip->hip; + + CLS_FETCH(); + ELS_FETCH(); + PLS_FETCH(); + SLS_FETCH(); + + if (debug > 1) { + fprintf(stderr, "*** php/php_doit() called ***\n"); + } + + if (url_expand(hip->url, path, sizeof(path), &sb, NULL, NULL) == NULL) { + return -1; + } + + if (debug > 1) { + fprintf(stderr, "*** php/php_request_startup for %s ***\n",path); + } + + memset(&SG(request_info),0,sizeof(sapi_globals_struct)); + + if (php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC) == FAILURE) { + return -1; + } + + if (debug > 1) { + fprintf(stderr, "*** php/php_doit/script %s ***\n",path); + } + + file_handle.type = ZEND_HANDLE_FILENAME; + file_handle.filename = path; + file_handle.free_filename = 0; + + php_execute_script(&file_handle CLS_CC ELS_CC PLS_CC); + + php_request_shutdown(NULL); + + return -1; +} + +int pm_request(struct connectioninfo *cip) +{ + struct httpinfo *hip = cip->hip; + + if (strcasecmp(hip->method, "GET") == 0 || + strcasecmp(hip->method, "HEAD") == 0 || + strcasecmp(hip->method, "POST") == 0) { + return php_doit(cip); + } else { + return -2; + } +} + |