[PHP-DEV] CVS update: php31/sapi From: shane (php-dev <email protected>)
Date: 05/31/98

Date: Sunday May 31, 1998 @ 15:44
Author: shane

Update of /repository/php31/sapi
In directory asf:/tmp/cvs-serv27884/sapi

Modified Files:
        apache_sapi.c cgi_sapi.c fhttpd_sapi.c isapi_sapi.c sapi.h
Added Files:
        old_cgimain.c
Log Message:
Moving much server specific code out to sapi interface files.

Index: php31/sapi/apache_sapi.c
diff -c php31/sapi/apache_sapi.c:1.1 php31/sapi/apache_sapi.c:1.2
*** php31/sapi/apache_sapi.c:1.1 Thu May 28 15:14:20 1998
--- php31/sapi/apache_sapi.c Sun May 31 15:44:05 1998
***************
*** 1,5 ****
--- 1,33 ----
  /* I know non of this is working right now. */
  
+ #include "php.h"
+ #if APACHE /* apache httpd */
+ # if HAVE_AP_CONFIG_H
+ #include "ap_config.h"
+ # endif
+ # if HAVE_AP_COMPAT_H
+ #include "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()
+ # ifndef THREAD_SAFE
+ request_rec *php3_rqst = NULL; /* request record pointer for apache module version */
+ # endif
+ #endif
+
+ #define SAPI_FUNC_VARS \
+ php3_globals_struct *php3_globals=(php3_globals_struct *)php3_globals_var;\
+ struct sapi_request_info *sapi_info=(struct sapi_request_info *)php3_globals->sapi_rqst;\
+ request_rec *php3_rqst=(request_rec *)sapi_info->scid
+
+
  /*
     We are still using a PHP2-style Push/Pop list here as opposed
     to the PHP3 built-in list functionality because of the nature
***************
*** 22,56 ****
  void php3_PushCookieList(char *cookie)
  {
          CookieList *new;
- TLS_VARS;
  
          new = emalloc(sizeof(CookieList));
! new->next = GLOBAL(top);
          new->name = cookie;
! GLOBAL(top) = new;
  }
  
  CookieList *php3_PopCookieList(void)
  {
          CookieList *ret;
- TLS_VARS;
  
! ret = GLOBAL(top);
! if (GLOBAL(top))
! GLOBAL(top) = GLOBAL(top)->next;
          return (ret);
  }
  
  
! void sapi_insert_header(void *scid, char *header){
          char *rr = NULL;
          char *temp = NULL;
          long myuid = 0L;
          char temp2[32];
          char *r;
!
! /*apache should store its request id in scid*/
! php3_rqst=scid;
  
          /*
           * Not entirely sure this is the right way to support the header
--- 50,80 ----
  void php3_PushCookieList(char *cookie)
  {
          CookieList *new;
  
          new = emalloc(sizeof(CookieList));
! new->next = top;
          new->name = cookie;
! top = new;
  }
  
  CookieList *php3_PopCookieList(void)
  {
          CookieList *ret;
  
! ret = top;
! if (top)
! top = top->next;
          return (ret);
  }
  
  
! void sapi_insert_header(void *php3_globals_var, char *header){
          char *rr = NULL;
          char *temp = NULL;
          long myuid = 0L;
          char temp2[32];
          char *r;
! SAPI_FUNC_VARS;
  
          /*
           * Not entirely sure this is the right way to support the header
***************
*** 108,118 ****
          }
  }
  
! void sapi_send_header(void *scid){
          CookieList *cookie;
          int len = 0;
          time_t t;
          char *r, *dt;
  
          if (!GLOBAL(php3_rqst)) { /* we're not in a request, allow output */
                  return 1;
--- 132,144 ----
          }
  }
  
! void sapi_send_header(void *php3_globals_var){
          CookieList *cookie;
          int len = 0;
          time_t t;
          char *r, *dt;
+ SAPI_FUNC_VARS;
+
  
          if (!GLOBAL(php3_rqst)) { /* we're not in a request, allow output */
                  return 1;
***************
*** 140,142 ****
--- 166,466 ----
                  }
          }
  }
+
+ /* this was php3_apache_puts*/
+ int sapi_puts(void *php3_globals_var, char *string){
+ {
+ SAPI_FUNC_VARS;
+
+ if (php3_rqst) {
+ return rputs(s, php3_rqst);
+ } else {
+ return fputs(s, stdout);
+ }
+ return FAILURE;
+ }
+
+ /* this was php3_apache_putc */
+ int sapi_putc(void *php3_globals_var, char *string){
+ {
+ SAPI_FUNC_VARS;
+
+ if (php3_rqst) {
+ return rputc(c, php3_rqst);
+ } else {
+ return fputc(c, stdout);
+ }
+ return FAILURE;
+ }
+
+ int sapi_writeclient(void *php3_globals_var, char *string, int len){
+ SAPI_FUNC_VARS;
+
+ if (php3_rqst) {
+ return rputs(s, php3_rqst);
+ } else {
+ return fputs(s, stdout);
+ }
+ return FAILURE;
+ }
+
+ void sapi_block(void *php3_globals_var){block_alarms();}
+ void sapi_unblock(void *php3_globals_var){unblock_alarms();}
+
+ /* code from main.c in php3_log_err() */
+ void sapi_log(void *php3_globals_var, char *message){
+ SAPI_FUNC_VARS;
+
+ if (GLOBAL(php3_rqst)) {
+ #if MODULE_MAGIC_NUMBER >= 19970831
+ aplog_error(NULL, 0, APLOG_ERR | APLOG_NOERRNO, php3_rqst->server, log_message);
+ #else
+ log_error(log_message, php3_rqst->server);
+ #endif
+ } else {
+ fprintf(stderr, log_message);
+ fprintf(stderr, "\n");
+ }
+ }
+
+ void sapi_register_cleanup(void *php3_globals_var, void *arg1, void *arg2, void *arg3){
+ SAPI_FUNC_VARS;
+ register_cleanup(php3_rqst->pool, arg1, arg2, arg3);
+ }
+
+ #if defined(CRASH_DETECTION)
+ /******************************************************************************
+ /* apache crash detection
+ /*****************************************************************************/
+ void sapi_debug_log(void *php3_globals_var, char *message){
+ SAPI_FUNC_VARS;
+ {
+ char log_message[256];
+
+ #if MSVC5
+ snprintf(log_message,256,"pid=%d:%s script='%s'",message,sapi_info->filename,GetCurrentThreadId());
+ OutputDebugString(log_message);
+ #else
+ snprintf(log_message,256,"%s script='%s', pid=%d",message,php3_rqst->filename,getpid());
+ log_error(log_message, php3_rqst->server);
+ #endif
+ }
+ }
+ #endif
+
+
+ /******************************************************************************
+ /* apache specific info called from info.c
+ /*****************************************************************************/
+
+ extern module *top_module;/* from info.c */
+
+ void sapi_print_info(void *php3_globals_var){
+ SAPI_FUNC_VARS;
+ {
+ module *modp = NULL;
+ #if !defined(WIN32) && !defined(WINNT)
+ char name[64];
+ char *p;
+ #endif
+ server_rec *serv = GLOBAL(php3_rqst)->server;
+ extern char server_root[MAX_STRING_LEN];
+ extern uid_t user_id;
+ extern char *user_name;
+ extern gid_t group_id;
+ extern int max_requests_per_child;
+
+ PUTS("<tr><th bgcolor=\"" ENTRY_NAME_COLOR "\">Apache</th><td>\n");
+ #if WIN32|WINNT
+ PUTS("Apache for Windows 95/NT<br>");
+ #else
+ php3_printf("<tt>APACHE_INCLUDE=%s<br>\n", PHP_APACHE_INCLUDE);
+ php3_printf("APACHE_TARGET=%s<br></tt>\n", PHP_APACHE_TARGET);
+ #endif
+ php3_printf("Apache Version: <b>%s</b><br>",SERVER_VERSION);
+ #ifdef APACHE_RELEASE
+ php3_printf("Apache Release: <b>%d</b><br>",APACHE_RELEASE);
+ #endif
+ php3_printf("Apache API Version: <b>%d</b><br>",MODULE_MAGIC_NUMBER);
+ php3_printf("Hostname/port: <b>%s:%u</b><br>\n",serv->server_hostname,serv->port);
+ #if !defined(WIN32) && !defined(WINNT)
+ php3_printf("User/Group: <b>%s(%d)/%d</b><br>\n",user_name,(int)user_id,(int)group_id);
+ php3_printf("Max Requests: <b>per child: %d &nbsp;&nbsp; keep alive: %s &nbsp;&nbsp; max per connection: %d</b><br>\n",max_requests_per_child,serv->keep_alive ? "on":"off", serv->keep_alive_max);
+ #endif
+ php3_printf("Timeouts: <b>connection: %d &nbsp;&nbsp; keep-alive: %d</b><br>",serv->timeout,serv->keep_alive_timeout);
+ #if !defined(WIN32) && !defined(WINNT)
+ php3_printf("Server Root: <b>%s</b><br>\n",server_root);
+
+ PUTS("Loaded modules: ");
+ for(modp = top_module; modp; modp = modp->next) {
+ strncpy(name, modp->name, sizeof(name) - 1);
+ if ((p = strrchr(name, '.'))) {
+ *p='\0'; /* Cut off ugly .c extensions on module names */
+ }
+ PUTS(name);
+ if (modp->next) {
+ PUTS(", ");
+ }
+ }
+ #endif
+ PUTS("<br>\n");
+ }
+ PUTS("</td></tr>\n");
+
+ {
+ register int i;
+ array_header *arr = table_elts(GLOBAL(php3_rqst)->subprocess_env);
+ table_entry *elts = (table_entry *)arr->elts;
+
+ SECTION("Apache Environment");
+ PUTS("<table border=5 width=\"600\">\n");
+ PUTS("<tr><th bgcolor=\"" HEADER_COLOR "\">Variable</th><th bgcolor=\"" HEADER_COLOR "\">Value</th></tr>\n");
+ for (i=0; i < arr->nelts; i++) {
+ PUTS("<tr><td bgcolor=\"" ENTRY_NAME_COLOR "\">");
+ PUTS(elts[i].key);
+ PUTS("</td><td bgcolor=\"" CONTENTS_COLOR "\">");
+ PUTS(elts[i].val);
+ PUTS("&nbsp;</td></tr>\n");
+ }
+ PUTS("</table>\n");
+ }
+ {
+ array_header *env_arr;
+ table_entry *env;
+ int i;
+
+ SECTION("HTTP Headers Information");
+ PUTS("<table border=5 width=\"600\">\n");
+ PUTS(" <tr><th colspan=2 bgcolor=\"" HEADER_COLOR "\">HTTP Request Headers</th></tr>\n");
+ PUTS("<tr><td bgcolor=\"" ENTRY_NAME_COLOR "\">HTTP Request</td><td bgcolor=\"" CONTENTS_COLOR "\">");
+ PUTS(GLOBAL(php3_rqst)->the_request);
+ PUTS("&nbsp;</td></tr>\n");
+ env_arr = table_elts(GLOBAL(php3_rqst)->headers_in);
+ env = (table_entry *)env_arr->elts;
+ for (i = 0; i < env_arr->nelts; ++i) {
+ if (env[i].key) {
+ PUTS("<tr><td bgcolor=\"" ENTRY_NAME_COLOR "\">");
+ PUTS(env[i].key);
+ PUTS("</td><td bgcolor=\"" CONTENTS_COLOR "\">");
+ PUTS(env[i].val);
+ PUTS("&nbsp;</td></tr>\n");
+ }
+ }
+ PUTS(" <tr><th colspan=2 bgcolor=\"" HEADER_COLOR "\">HTTP Response Headers</th></tr>\n");
+ env_arr = table_elts(GLOBAL(php3_rqst)->headers_out);
+ env = (table_entry *)env_arr->elts;
+ for(i = 0; i < env_arr->nelts; ++i) {
+ if (env[i].key) {
+ PUTS("<tr><td bgcolor=\"" ENTRY_NAME_COLOR "\">");
+ PUTS(env[i].key);
+ PUTS("</td><td bgcolor=\"" CONTENTS_COLOR "\">");
+ PUTS(env[i].val);
+ PUTS("&nbsp;</td></tr>\n");
+ }
+ }
+ PUTS("</table>\n\n");
+ }
+ }
+
+
+ /******************************************************************************
+ /* code from main.c in hash_environment()
+ /*****************************************************************************/
+ void sapi_hash_server_env(void *php3_globals_var){
+ SAPI_FUNC_VARS;
+ {
+ pval *tmp_ptr, tmp2;
+ register int i;
+ array_header *arr = table_elts(GLOBAL(php3_rqst)->subprocess_env);
+ table_entry *elts = (table_entry *) arr->elts;
+ int len;
+
+ for (i = 0; i < arr->nelts; i++) {
+ len = strlen(elts[i].key);
+ t = estrndup(elts[i].key, len);
+ if (elts[i].val) {
+ tmp.value.str.len = strlen(elts[i].val);
+ tmp.value.str.val = estrndup(elts[i].val, tmp.value.str.len);
+ } else {
+ tmp.value.str.len = 0;
+ tmp.value.str.val = empty_string;
+ }
+ tmp.type = IS_STRING;
+ if (hash_update(&GLOBAL(symbol_table), t, len + 1, &tmp, sizeof(pval), NULL) == FAILURE) {
+ STR_FREE(tmp.value.str.val);
+ }
+ efree(t);
+ }
+ /* insert special variables */
+ if (hash_find(&GLOBAL(symbol_table), "SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME"), (void **) & tmp_ptr) == SUCCESS) {
+ tmp2 = *tmp_ptr;
+ yystype_copy_constructor(&tmp2);
+ hash_update(&GLOBAL(symbol_table), "PATH_TRANSLATED", sizeof("PATH_TRANSLATED"), (void *) & tmp2, sizeof(pval), NULL);
+ }
+ tmp.value.str.len = strlen(GLOBAL(php3_rqst)->uri);
+ tmp.value.str.val = estrndup(GLOBAL(php3_rqst)->uri, tmp.value.str.len);
+ tmp.type = IS_STRING;
+ hash_update(&GLOBAL(symbol_table), "PHP_SELF", sizeof("PHP_SELF"), (void *) & tmp, sizeof(pval), NULL);
+ }
+ }
+
+ /*
+ Here is the old apache main from main.c
+
+ DEPRECATED.
+
+ Must now call php3_sapi_main from this file.
+
+ */
+
+ #if APACHE
+ PHPAPI int apache_php3_module_main(request_rec * r, int fd, int display_source_mode, int preprocessed)
+ {
+ FILE *in = NULL;
+ TLS_VARS;
+
+ GLOBAL(php3_rqst) = r;
+
+ if (php3_request_startup(_INLINE_TLS_VOID) == FAILURE) {
+ return FAILURE;
+ }
+ php3_TreatHeaders();
+ in = fdopen(fd, "r");
+ if (in) {
+ GLOBAL(phpin) = in;
+ phprestart(GLOBAL(phpin));
+ GLOBAL(initialized) |= INIT_SCANNER;
+ hash_index_update(&GLOBAL(include_names), 0, (void *) &GLOBAL(sapi_rqst)->filename, sizeof(char *), NULL);
+ } else {
+ return OK;
+ }
+ if (display_source_mode) {
+ GLOBAL(Execute) = 0;
+ GLOBAL(ExecuteFlag) = DONT_EXECUTE;
+ GLOBAL(php3_display_source) = 1;
+ if (!php3_header())
+ return (OK);
+ PUTS("<html><head><title>Source for ");
+ PUTS(r->uri);
+ PUTS("</title></head><body bgcolor=\"");
+ PUTS(GLOBAL(php3_ini).highlight_bg);
+ PUTS("\" text=\"");
+ PUTS(GLOBAL(php3_ini).highlight_html);
+ PUTS("\">\n"); /* color: seashell */
+ }
+ if (preprocessed) {
+ if (tcm_load(&GLOBAL(token_cache_manager))==FAILURE) {
+ return OK;
+ }
+ }
+ (void) php3_parse(GLOBAL(phpin));
+
+ if (GLOBAL(php3_display_source)) {
+ php3_printf("\n</html>\n");
+ }
+ if (GLOBAL(initialized)) {
+ php3_header(); /* Make sure headers have been sent */
+ }
+ return (OK);
+ }
+ #endif /* APACHE */
Index: php31/sapi/cgi_sapi.c
diff -c php31/sapi/cgi_sapi.c:1.4 php31/sapi/cgi_sapi.c:1.5
*** php31/sapi/cgi_sapi.c:1.4 Thu May 28 15:14:20 1998
--- php31/sapi/cgi_sapi.c Sun May 31 15:44:05 1998
***************
*** 17,62 ****
  struct sapi_request_info sapi_info;
  
  /* sapi functions */
! int sapi_readclient(void *scid, char *buf, int size, int len){
          return fread(buf, size, len, stdin);
  }
  
! char *sapi_getenv(void *scid, char *string){
          return getenv(string);
  }
  
! int sapi_insert_header(void *sapi_rqst, char *header){
          puts(header);
          return puts("\015\012");
  }
  
! int sapi_send_header(void *sapi_rqst){
          return puts("\015\012");
  }
  
! int sapi_flush(void *scid){
          return fflush(stdout);
  }
  
! int sapi_puts(void *scid, char *string){
          return puts(string);
  }
  
! int sapi_putc(void *scid, char c){
          return putc(c,stdout);
  }
  
! int sapi_writeclient(void *scid, char *string, int len){
          return fwrite(string,len,1,stdout);
  }
  
! void sapi_log(void *scid, char *message){
          fprintf(stderr,message);
  }
  
! void sapi_block(void *scid){}
! void sapi_unblock(void *scid){}
! void sapi_print_info(void *sapi_rqst){}
  
  void sapi_init(void)
  {
--- 17,86 ----
  struct sapi_request_info sapi_info;
  
  /* sapi functions */
! int sapi_readclient(void *php3_globals_var, char *buf, int size, int len){
          return fread(buf, size, len, stdin);
  }
  
! char *sapi_getenv(void *php3_globals_var, char *string){
          return getenv(string);
  }
  
! int sapi_insert_header(void *php3_globals_var, char *header){
          puts(header);
          return puts("\015\012");
  }
  
! int sapi_send_header(void *php3_globals_var){
          return puts("\015\012");
  }
  
! int sapi_flush(void *php3_globals_var){
          return fflush(stdout);
  }
  
! int sapi_puts(void *php3_globals_var, char *string){
          return puts(string);
  }
  
! int sapi_putc(void *php3_globals_var, char c){
          return putc(c,stdout);
  }
  
! int sapi_writeclient(void *php3_globals_var, char *string, int len){
          return fwrite(string,len,1,stdout);
  }
  
! void sapi_log(void *php3_globals_var, char *message){
          fprintf(stderr,message);
  }
  
! void sapi_block(void *php3_globals_var){}
! void sapi_unblock(void *php3_globals_var){}
! void sapi_print_info(void *php3_globals_var){}
!
! /******************************************************************************
! /* code from main.c in hash_environment()
! /*****************************************************************************/
! void sapi_hash_server_env(void *php3_globals_var){
! /* Build the special-case PHP_SELF variable for the CGI version */
! char *sn, *pi;
! int l = 0;
!
! sn = sapi_info->script_name;
! pi = sapi_info->path_info;
! if (sn)
! l += strlen(sn);
! if (pi)
! l += strlen(pi);
! if (pi && sn && !strcmp(pi, sn)) {
! l -= strlen(pi);
! pi = NULL;
! }
! tmp.value.str.val = emalloc(l + 1);
! tmp.value.str.len = _php3_sprintf(tmp.value.str.val, "%s%s", (sn ? sn : ""), (pi ? pi : "")); /* SAFE */
! tmp.type = IS_STRING;
! hash_update(&GLOBAL(symbol_table), "PHP_SELF", sizeof("PHP_SELF"), (void *) & tmp, sizeof(pval), NULL);
! }
  
  void sapi_init(void)
  {
Index: php31/sapi/fhttpd_sapi.c
diff -c php31/sapi/fhttpd_sapi.c:1.1 php31/sapi/fhttpd_sapi.c:1.2
*** php31/sapi/fhttpd_sapi.c:1.1 Thu May 28 15:14:21 1998
--- php31/sapi/fhttpd_sapi.c Sun May 31 15:44:06 1998
***************
*** 1,11 ****
  /* this is just a slight beginning, as I strip some code from other
     areas of php. Shane */
  
! void sapi_insert_header(void *scid, char *header){
          php3_fhttpd_puts_header(header);
          php3_fhttpd_puts_header("\r\n");
  }
  
! void sapi_send_header(void *scid){
          php3_fhttpd_puts_header("\015\012");
  }
--- 1,511 ----
  /* this is just a slight beginning, as I strip some code from other
     areas of php. Shane */
  
! #include "php.h"
! #if FHTTPD
!
! #include <servproc.h>
!
! #ifndef IDLE_TIMEOUT
! #define IDLE_TIMEOUT 120
! #endif
! #ifndef SIGACTARGS
! #define SIGACTARGS int n
! #endif
!
! extern struct http_server *server;
! extern struct request *req;
! extern struct httpresponse *response;
! extern int global_alarmflag;
! extern int idle_timeout;
! extern int exit_status;
! extern int headermade;
! extern char **currentheader;
! extern char *headerfirstline;
! extern int headerlines;
!
! void alarmhandler(SIGACTARGS);
! void setalarm(int t);
! int checkinput(int h);
!
! extern PHPAPI void php3_fhttpd_free_header(void);
! extern PHPAPI void php3_fhttpd_puts_header(char *s);
! extern PHPAPI void php3_fhttpd_puts(char *s);
! extern PHPAPI void php3_fhttpd_putc(char c);
! extern PHPAPI int php3_fhttpd_write(char *a,int n);
! # if !defined(COMPILE_DL)
! # define PUTS(s) php3_fhttpd_puts(s)
! # define PUTC(c) php3_fhttpd_putc(c)
! # define PHPWRITE(a,n) php3_fhttpd_write((a),(n))
! # endif
! #endif
!
! void sapi_insert_header(void *php3_global_var, char *header){
          php3_fhttpd_puts_header(header);
          php3_fhttpd_puts_header("\r\n");
  }
  
! void sapi_send_header(void *php3_global_var){
          php3_fhttpd_puts_header("\015\012");
  }
+
+ #if defined(CRASH_DETECTION)
+ /******************************************************************************
+ /* crash detection logging
+ /*****************************************************************************/
+ void sapi_debug_log(void *php3_globals_var, char *log_message){
+ #if MSVC5
+ OutputDebugString(log_message);
+ #endif
+ }
+ #endif
+
+ /******************************************************************************
+ /* code from main.c in hash_environment()
+ /*****************************************************************************/
+ void sapi_hash_server_env(void *php3_globals_var){
+ SAPI_FUNC_VARS;
+ {
+ int i, j;
+ if (req) {
+ for (i = 0; i < req->nlines; i++) {
+ if (req->lines[i].paramc > 1 && req->lines[i].params[0] && req->lines[i].params[1]) {
+ tmp.value.str.len = strlen(req->lines[i].params[1]);
+ tmp.value.str.val = estrndup(req->lines[i].params[1], tmp.value.str.len);
+ tmp.type = IS_STRING;
+ if (hash_update(&GLOBAL(symbol_table), req->lines[i].params[0],
+ strlen(req->lines[i].params[0]) + 1,
+ &tmp, sizeof(pval), NULL) == FAILURE) {
+ efree(tmp.value.str.val);
+ }
+ }
+ }
+ if (req->script_name_resolved) {
+ i = strlen(req->script_name_resolved);
+ tmp.value.str.len = i;
+ tmp.value.str.val = estrndup(req->script_name_resolved, i);
+ tmp.type = IS_STRING;
+ if (hash_update(&GLOBAL(symbol_table), "PATH_TRANSLATED",
+ sizeof("PATH_TRANSLATED"),
+ &tmp, sizeof(pval), NULL) == FAILURE) {
+ efree(tmp.value.str.val);
+ }
+ if (req->script_name) {
+ j = i - strlen(req->script_name);
+ if (j > 0
+ && !strcmp(req->script_name_resolved + j,
+ req->script_name)) {
+ tmp.value.str.len = j;
+ tmp.value.str.val = estrndup(req->script_name_resolved, j);
+ tmp.type = IS_STRING;
+ if (hash_update(&GLOBAL(symbol_table), "DOCUMENT_ROOT",
+ sizeof("DOCUMENT_ROOT"),
+ &tmp, sizeof(pval), NULL) == FAILURE) {
+ efree(tmp.value.str.val);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /*
+ this is the code from php3_request_shutdown. This is now
+ called before the end of request_shutdown.
+ */
+ void sapi_request_end(void *php3_global_var){
+ #if FHTTPD
+ char tmpline[128];
+ int i, serverdefined;
+ #endif
+ #if FHTTPD
+ if (response) {
+ if (!headermade) {
+ makestandardheader(response, 200, "text/html", "fhttpd", req && req->keepalive);
+ } else {
+ if (headerfirstline)
+ putlinetoheader(response, headerfirstline);
+ else
+ putlinetoheader(response, "HTTP/1.0 200 OK\r\n");
+ serverdefined = 0;
+ for (i = 0; i < headerlines; i++) {
+ if (!strncmp(currentheader[i], "Server:", 7))
+ serverdefined = 1;
+ putlinetoheader(response, currentheader[i]);
+ }
+ if (!serverdefined)
+ putlinetoheader(response, "Server: fhttpd\r\n");
+ if (response->datasize) {
+ sprintf(tmpline, "Content-Length: %ld\r\n", response->datasize);
+ putlinetoheader(response, tmpline);
+ if (req && req->keepalive)
+ putlinetoheader(response,
+ "Connection: Keep-Alive\r\nKeep-Alive: max=0, timeout=30\r\n");
+ }
+ php3_fhttpd_free_header();
+ }
+ sendresponse(server, response);
+ if (response->datasize)
+ finishresponse(server, response);
+ else
+ finishdropresponse(server, response);
+ deleteresponse(response);
+ }
+ response = NULL;
+ if (req)
+ deleterequest(req);
+ req = NULL;
+ #endif
+
+ }
+
+ /*
+ Here is the old fhttpd main from main.c
+
+ DEPRECATED.
+
+ Must now call php3_sapi_main from this file.
+
+ */
+
+
+ #if FHTTPD
+
+ char *get_pretokenized_name(void)
+ {
+ char *pretokenized_name = NULL;
+
+ if (GLOBAL(sapi_rqst)->filename) {
+ int length = strlen(GLOBAL(sapi_rqst)->filename);
+
+ if (length > (sizeof(".php3") - 1) && !strcmp(GLOBAL(sapi_rqst)->filename + length - sizeof(".php3") + 1, ".php3")) {
+ pretokenized_name = (char *) emalloc(length + 2);
+ strcpy(pretokenized_name, GLOBAL(sapi_rqst)->filename);
+ strcat(pretokenized_name, "p");
+ } else {
+ length += sizeof(".php3p");
+ pretokenized_name = (char *) emalloc(length + 1);
+ strcpy(pretokenized_name, GLOBAL(sapi_rqst)->filename);
+ strcat(pretokenized_name, ".php3p");
+ }
+ } else {
+ pretokenized_name = estrdup("stdin.php3p");
+ }
+ return pretokenized_name;
+ }
+
+
+ void _php3_usage(char *progname)
+ {
+ fprintf(stderr,
+ "Usage: %s [options] [appname] [username] [hostname] [portname]\n"
+ "Options:\n"
+ " -d Daemon mode -- never attempt terminal I/O\n"
+ " -s Socket mode, fhttpd internal use only\n"
+ " -p Pipe mode, fhttpd internal use only\n"
+ " -u<mask> Set umask\n"
+ " -t<time> Idle timeout in seconds, 0 - disable\n"
+ " -S Display colour syntax highlighted source\n"
+ " -P Make and execute a pretokenized script\n"
+ " (.php3p file) or, if pretokenized script, newer\n"
+ " than original file exists, execute it instead\n"
+ " -E Execute a pretokenized (.php3p) script\n"
+ " -c<path> Look for php3.ini file in this directory\n"
+ " (must appear before any other options)\n"
+ " -v Version number\n"
+ " -h This help\n",
+ progname);
+ }
+
+ int main(int argc, char **argv)
+ {
+ int c, i, processing_error;
+ FILE *in = NULL;
+ FILE *in2;
+ int display_source_mode = 0;
+ int preprocess_mode = PREPROCESS_NONE;
+ int argc1;
+ char **argv1;
+ int human = 1, fd2;
+ int i0 = 0, i1 = 0;
+ char *pn;
+ struct stat statbuf, pstatbuf;
+
+ #ifdef THREAD_SAFE
+ php3_globals_struct *php3_globals;
+ flex_globals *php_flex_gbl;
+ tls_startup();
+ tls_create();
+ php_flex_gbl = yy_init_tls();
+ php3_globals = TlsGetValue(TlsIndex);
+
+ if ((php3_globals == 0) && (GetLastError() != 0)) {
+ if (!php3_header())
+ exit(0);
+ PUTS("TlsGetValue error\n");
+ return FAILURE;
+ }
+ #endif
+
+ #if HAVE_SETLOCALE
+ setlocale(LC_CTYPE, "");
+ #endif
+
+ if (php3_module_startup(_INLINE_TLS_VOID) == FAILURE) {
+ return FAILURE;
+ }
+ signal(SIGPIPE, SIG_IGN);
+ umask(077);
+
+ while ((c = getopt(argc, argv, "spdu:t:c:PESvh")) != -1) {
+ switch (c) {
+ case 'd':
+ human = 0;
+ break;
+ case 's':
+ i0 = 1;
+ break;
+ case 'p':
+ i1 = 1;
+ break;
+ case 'u':
+ if (*optarg == '0')
+ umask(strtoul(optarg, NULL, 8));
+ else
+ umask(strtoul(optarg, NULL, 10));
+ break;
+ case 't':
+ idle_timeout = atoi(optarg);
+ break;
+ case 'c':
+ GLOBAL(php3_ini_path) = strdup(optarg); /* intentional leak */
+ break;
+ case 'P': /* preprocess */
+ preprocess_mode = PREPROCESS_PREPROCESS;
+ break;
+ case 'E': /* execute preprocessed script */
+ preprocess_mode = PREPROCESS_EXECUTE;
+ break;
+ case 'S':
+ display_source_mode = 1;
+ break;
+ case 'v':
+ printf("%s\n", PHP_VERSION);
+ exit(1);
+ break;
+ case 'h':
+ case ':':
+ case '?':
+ _php3_usage(argv[0]);
+ return -1;
+ }
+ }
+
+ argc1 = argc - optind;
+ argv1 = (char **) malloc(sizeof(char *) * (argc1 + 2));
+ if (!argv1)
+ return -1;
+ argv1 += 2;
+ for (i = optind; i < argc; i++)
+ argv1[i - optind] = argv[i];
+
+ if (i0) {
+ argv1--;
+ *argv1 = "-s";
+ argc1++;
+ } else {
+ if (i1) {
+ argv1--;
+ *argv1 = "-p";
+ argc1++;
+ }
+ }
+ argv1--;
+ argc1++;
+ *argv1 = *argv;
+
+ server = createserver();
+ if (!server)
+ return -1;
+
+ switch (servproc_init(server, human, argc1, argv1)) {
+ case 0:
+ break;
+ case APP_ERR_HUMAN:
+ _php3_usage(argv[0]);
+ exit(1);
+ break;
+ case APP_ERR_CONFIG:
+ fprintf(stderr, "%s: configuration error\n", server->app_progname);
+ exit(1);
+ break;
+ case APP_ERR_READ:
+ fprintf(stderr, "%s: read error\n", server->app_progname);
+ exit(1);
+ break;
+ case APP_ERR_HOSTNAME:
+ fprintf(stderr, "%s: can't resolve server hostname\n", server->app_progname);
+ exit(1);
+ break;
+ case APP_ERR_SOCKET:
+ fprintf(stderr, "%s: can't create socket\n", server->app_progname);
+ exit(1);
+ break;
+ case APP_ERR_CONNECT:
+ fprintf(stderr, "%s: can't connect\n", server->app_progname);
+ exit(1);
+ break;
+ case APP_ERR_APPCONNECT:
+ fprintf(stderr, "%s: connect error\n", server->app_progname);
+ exit(1);
+ break;
+ case APP_ERR_USER:
+ fprintf(stderr, "%s: login error\n", server->app_progname);
+ exit(1);
+ break;
+ case APP_ERR_PASSWORD:
+ fprintf(stderr, "%s: login error\n", server->app_progname);
+ exit(1);
+ break;
+ case APP_ERR_APPLICATION:
+ fprintf(stderr, "%s: application rejected by server\n", server->app_progname);
+ exit(1);
+ break;
+ case APP_ERR_INSANE:
+ case APP_ERR_DAEMON:
+ case APP_ERR_AUTH:
+ default:
+ if (server->infd < 0)
+ exit(1);
+ }
+
+ if (server->infd == 0 && server->outfd == 1) {
+ close(2);
+ fd2 = open("/dev/null", O_WRONLY);
+ if (fd2 != 2) {
+ dup2(fd2, 2);
+ close(fd2);
+ }
+ }
+ setcapabilities(server, APP_CAP_KEEPALIVE);
+
+ exit_status = 0;
+ while (!exit_status) {
+ processing_error = 0;
+ if (php3_request_startup(_INLINE_TLS_VOID) == FAILURE) {
+ processing_error = 1;
+ }
+ if (!processing_error) {
+ GLOBAL(phpin) = NULL;
+ GLOBAL(current_lineno) = 0;
+
+ php3_TreatHeaders();
+
+ in = php3_fopen_for_parser();
+
+ GLOBAL(php3_preprocess) = preprocess_mode;
+
+ if (!in) {
+ if (php3_header())
+ PUTS("No input file specified.\n");
+ php3_request_shutdown((void *) 0 _INLINE_TLS);
+ processing_error = 1;
+ } else {
+ if (GLOBAL(php3_preprocess) == PREPROCESS_PREPROCESS) {
+ pn = get_pretokenized_name();
+ if (pn) {
+ if (!stat(pn, &pstatbuf)
+ && !fstat(fileno(in), &statbuf)
+ && S_ISREG(pstatbuf.st_mode)
+ && statbuf.st_mtime < pstatbuf.st_mtime) {
+ in2 = fopen(pn, "r");
+ if (in2) {
+ fclose(in);
+ in = in2;
+ GLOBAL(php3_preprocess) = PREPROCESS_EXECUTE;
+ }
+ }
+ efree(pn);
+ }
+ }
+ if (GLOBAL(php3_preprocess) != PREPROCESS_EXECUTE) {
+ /* #!php support */
+ c = fgetc(in);
+ if (c == '#') {
+ while (c != 10 && c != 13) {
+ c = fgetc(in); /* skip to end of line */
+ }
+ GLOBAL(phplineno)++;
+ } else {
+ rewind(in);
+ }
+ }
+ GLOBAL(phpin) = in;
+ GLOBAL(initialized) |= INIT_SCANNER;
+ phprestart(GLOBAL(phpin));
+
+ if (display_source_mode) {
+ GLOBAL(Execute) = 0;
+ GLOBAL(ExecuteFlag) = DONT_EXECUTE;
+ GLOBAL(php3_display_source) = 1;
+ if (php3_header()) {
+ PUTS("<html><head><title>Source for ");
+ PUTS(GLOBAL(sapi_rqst)->filename);
+ PUTS("</title></head><body bgcolor=\"");
+ PUTS(GLOBAL(php3_ini).highlight_bg);
+ PUTS("\" text=\"");
+ PUTS(GLOBAL(php3_ini).highlight_html);
+ PUTS("\">\n"); /* color: seashell */
+ } else {
+ processing_error = 1;
+ }
+ }
+ if (GLOBAL(php3_display_source) && GLOBAL(php3_preprocess) == PREPROCESS_PREPROCESS) {
+ php3_printf("Can't preprocess while displaying source.<br>\n");
+ processing_error = 1;
+ }
+ if (!processing_error) {
+ if (GLOBAL(php3_preprocess) == PREPROCESS_EXECUTE) {
+ if (tcm_load(&GLOBAL(token_cache_manager), GLOBAL(phpin))==FAILURE) {
+ /* should bail out on an error, don't know how to do it in fhttpd */
+ }
+ GLOBAL(php3_preprocess) = PREPROCESS_NONE;
+ }
+ if (GLOBAL(php3_preprocess)!=PREPROCESS_NONE) {
+ pval yylval;
+
+ #ifdef THREAD_SAFE
+ while (phplex(&yylval, php3_globals, php_flex_gbl)); /* create the token cache */
+ #else
+ while (phplex(&yylval)); /* create the token cache */
+ #endif
+ tcm_save(&GLOBAL(token_cache_manager));
+ seek_token(&GLOBAL(token_cache_manager), 0, NULL);
+ GLOBAL(php3_preprocess) = PREPROCESS_NONE;
+ }
+ php3_parse(GLOBAL(phpin));
+
+ if (GLOBAL(php3_display_source)) {
+ php3_printf("\n</html>\n");
+ }
+ }
+ }
+ }
+ if (GLOBAL(initialized)) {
+ php3_header(); /* Make sure headers have been sent */
+ php3_request_shutdown((void *) 0 _INLINE_TLS);
+ }
+ }
+ php3_module_shutdown(_INLINE_TLS_VOID);
+ #ifdef THREAD_SAFE
+ if (GLOBAL(initialized)) {
+ yy_destroy_tls();
+ tls_shutdown();
+ tls_destroy();
+ }
+ #endif
+ return 0;
+ }
+ #endif /* FHTTPD */
+
Index: php31/sapi/isapi_sapi.c
diff -c php31/sapi/isapi_sapi.c:1.6 php31/sapi/isapi_sapi.c:1.7
*** php31/sapi/isapi_sapi.c:1.6 Sun May 31 12:44:31 1998
--- php31/sapi/isapi_sapi.c Sun May 31 15:44:06 1998
***************
*** 7,12 ****
--- 7,19 ----
  #define SAPI_INTERFACE 1
  #include "sapi.h"
  #include "tls.h"
+ #include "snprintf.h"
+
+ #define SAPI_FUNC_VARS \
+ php3_globals_struct *php3_globals=(php3_globals_struct *)php3_globals_var;\
+ struct sapi_request_info *sapi_info=(struct sapi_request_info *)php3_globals->sapi_rqst;\
+ LPEXTENSION_CONTROL_BLOCK lpEcb=(LPEXTENSION_CONTROL_BLOCK)sapi_info->scid
+
  
  #if DEBUG
  void logmessage(void *scid,char *message, char *funcname){
***************
*** 24,32 ****
  #endif
  
  int sapi_readclient(void *php3_globals_var, char *buf, int size, int len){
! php3_globals_struct *php3_globals=(php3_globals_struct *)php3_globals_var;
! struct sapi_request_info *sapi_info=(struct sapi_request_info *)php3_globals->sapi_rqst;
! LPEXTENSION_CONTROL_BLOCK lpEcb=(LPEXTENSION_CONTROL_BLOCK)sapi_info->scid;
          if (!lpEcb->ReadClient(lpEcb->ConnID,(LPVOID)buf,&len)){
                  OutputDebugString("ReadClient Failed\n");
                  return FAILURE;
--- 31,37 ----
  #endif
  
  int sapi_readclient(void *php3_globals_var, char *buf, int size, int len){
! SAPI_FUNC_VARS;
          if (!lpEcb->ReadClient(lpEcb->ConnID,(LPVOID)buf,&len)){
                  OutputDebugString("ReadClient Failed\n");
                  return FAILURE;
***************
*** 37,45 ****
  char *sapi_getenv(void *php3_globals_var, char *string){
          char var[1024];
          DWORD dwLen;
! php3_globals_struct *php3_globals=(php3_globals_struct *)php3_globals_var;
! struct sapi_request_info *sapi_info=(struct sapi_request_info *)php3_globals->sapi_rqst;
! LPEXTENSION_CONTROL_BLOCK lpEcb=(LPEXTENSION_CONTROL_BLOCK)sapi_info->scid;
  
          if (!string)
                  return NULL;
--- 42,48 ----
  char *sapi_getenv(void *php3_globals_var, char *string){
          char var[1024];
          DWORD dwLen;
! SAPI_FUNC_VARS;
  
          if (!string)
                  return NULL;
***************
*** 70,77 ****
  /*FIXME need to make isapi correctly handle redirects and status strings*/
  int sapi_insert_header(void *php3_globals_var, char *header){
          char *tempstr=NULL;
! php3_globals_struct *php3_globals=(php3_globals_struct *)php3_globals_var;
! struct sapi_request_info *sapi_info=(struct sapi_request_info *)php3_globals->sapi_rqst;
          /*inserts header into a list of headers*/
          if(header){
          if(sapi_info->headers){
--- 73,79 ----
  /*FIXME need to make isapi correctly handle redirects and status strings*/
  int sapi_insert_header(void *php3_globals_var, char *header){
          char *tempstr=NULL;
! SAPI_FUNC_VARS;
          /*inserts header into a list of headers*/
          if(header){
          if(sapi_info->headers){
***************
*** 87,95 ****
  }
  
  int sapi_send_header(void *php3_globals_var){
! php3_globals_struct *php3_globals=(php3_globals_struct *)php3_globals_var;
! struct sapi_request_info *sapi_info=(struct sapi_request_info *)php3_globals->sapi_rqst;
! LPEXTENSION_CONTROL_BLOCK lpEcb=(LPEXTENSION_CONTROL_BLOCK)sapi_info->scid;
          int headlen=0;
          char *tempstr=NULL;
  
--- 89,95 ----
  }
  
  int sapi_send_header(void *php3_globals_var){
! SAPI_FUNC_VARS;
          int headlen=0;
          char *tempstr=NULL;
  
***************
*** 113,129 ****
  
  /* FIXME probably not used in isapi unless we buffer the page */
  int sapi_flush(void *php3_globals_var){
! php3_globals_struct *php3_globals=(php3_globals_struct *)php3_globals_var;
! struct sapi_request_info *sapi_info=(struct sapi_request_info *)php3_globals->sapi_rqst;
! LPEXTENSION_CONTROL_BLOCK lpEcb=(LPEXTENSION_CONTROL_BLOCK)sapi_info->scid;
          /*fflush(stdout);*/
          return SUCCESS;
  }
  
  int sapi_puts(void *php3_globals_var, char *string){
! php3_globals_struct *php3_globals=(php3_globals_struct *)php3_globals_var;
! struct sapi_request_info *sapi_info=(struct sapi_request_info *)php3_globals->sapi_rqst;
! LPEXTENSION_CONTROL_BLOCK lpEcb=(LPEXTENSION_CONTROL_BLOCK)sapi_info->scid;
          int n;
          n = strlen(string);
          if (!lpEcb->WriteClient(lpEcb->ConnID,string,&n,0)){
--- 113,125 ----
  
  /* FIXME probably not used in isapi unless we buffer the page */
  int sapi_flush(void *php3_globals_var){
! SAPI_FUNC_VARS;
          /*fflush(stdout);*/
          return SUCCESS;
  }
  
  int sapi_puts(void *php3_globals_var, char *string){
! SAPI_FUNC_VARS;
          int n;
          n = strlen(string);
          if (!lpEcb->WriteClient(lpEcb->ConnID,string,&n,0)){
***************
*** 135,143 ****
  }
  
  int sapi_putc(void *php3_globals_var, char c){
! php3_globals_struct *php3_globals=(php3_globals_struct *)php3_globals_var;
! struct sapi_request_info *sapi_info=(struct sapi_request_info *)php3_globals->sapi_rqst;
! LPEXTENSION_CONTROL_BLOCK lpEcb=(LPEXTENSION_CONTROL_BLOCK)sapi_info->scid;
          int n = 1;
          if (!lpEcb->WriteClient(lpEcb->ConnID,&c,&n,0)){
                  /*FIXME request_shutdown on failure! */
--- 131,137 ----
  }
  
  int sapi_putc(void *php3_globals_var, char c){
! SAPI_FUNC_VARS;
          int n = 1;
          if (!lpEcb->WriteClient(lpEcb->ConnID,&c,&n,0)){
                  /*FIXME request_shutdown on failure! */
***************
*** 148,156 ****
  }
  
  int sapi_writeclient(void *php3_globals_var, char *string, int len){
! php3_globals_struct *php3_globals=(php3_globals_struct *)php3_globals_var;
! struct sapi_request_info *sapi_info=(struct sapi_request_info *)php3_globals->sapi_rqst;
! LPEXTENSION_CONTROL_BLOCK lpEcb=(LPEXTENSION_CONTROL_BLOCK)sapi_info->scid;
          if (!lpEcb->WriteClient(lpEcb->ConnID,string,&len,0)){
                  /*FIXME request_shutdown on failure! */
                  OutputDebugString("WriteClient Failed\n");
--- 142,148 ----
  }
  
  int sapi_writeclient(void *php3_globals_var, char *string, int len){
! SAPI_FUNC_VARS;
          if (!lpEcb->WriteClient(lpEcb->ConnID,string,&len,0)){
                  /*FIXME request_shutdown on failure! */
                  OutputDebugString("WriteClient Failed\n");
***************
*** 160,180 ****
  }
  
  void sapi_log(void *php3_globals_var, char *message){
! php3_globals_struct *php3_globals=(php3_globals_struct *)php3_globals_var;
! struct sapi_request_info *sapi_info=(struct sapi_request_info *)php3_globals->sapi_rqst;
! LPEXTENSION_CONTROL_BLOCK lpEcb=(LPEXTENSION_CONTROL_BLOCK)sapi_info->scid;
  }
  void sapi_block(void *php3_globals_var){
! php3_globals_struct *php3_globals=(php3_globals_struct *)php3_globals_var;
! struct sapi_request_info *sapi_info=(struct sapi_request_info *)php3_globals->sapi_rqst;
! LPEXTENSION_CONTROL_BLOCK lpEcb=(LPEXTENSION_CONTROL_BLOCK)sapi_info->scid;
  }
  void sapi_unblock(void *php3_globals_var){
! php3_globals_struct *php3_globals=(php3_globals_struct *)php3_globals_var;
! struct sapi_request_info *sapi_info=(struct sapi_request_info *)php3_globals->sapi_rqst;
! LPEXTENSION_CONTROL_BLOCK lpEcb=(LPEXTENSION_CONTROL_BLOCK)sapi_info->scid;
  }
  
  #define ENTRY_NAME_COLOR "#999999"
  #define CONTENTS_COLOR "#DDDDDD"
  #define HEADER_COLOR "#00DDDD"
--- 152,215 ----
  }
  
  void sapi_log(void *php3_globals_var, char *message){
! SAPI_FUNC_VARS;
  }
  void sapi_block(void *php3_globals_var){
! SAPI_FUNC_VARS;
  }
  void sapi_unblock(void *php3_globals_var){
! SAPI_FUNC_VARS;
! }
! void sapi_reqister_cleanup(void *php3_globals_var, void *arg1, void *arg2, void *arg3){
! SAPI_FUNC_VARS;
! }
! void sapi_request_shutdown(void *php3_globals_var){
! SAPI_FUNC_VARS;
! }
!
! #if defined(CRASH_DETECTION)
! /******************************************************************************
! /* crash detection logging
! /*****************************************************************************/
! void sapi_debug_log(void *php3_globals_var, char *message){
! SAPI_FUNC_VARS;
! char log_message[256];
!
! #if MSVC5
! snprintf(log_message,256,"pid=%d:%s script='%s'",message,sapi_info->filename,GetCurrentThreadId());
! OutputDebugString(log_message);
! #endif
! }
! #endif
!
! /******************************************************************************
! /* code from main.c in hash_environment()
! /*****************************************************************************/
! void sapi_hash_server_env(void *php3_globals_var){
! SAPI_FUNC_VARS;
! pval tmp;
!
! /* Build the special-case PHP_SELF variable for the CGI version */
! char *sn, *pi;
! int l = 0;
!
! sn = sapi_info->script_name;
! pi = sapi_info->path_info;
! if (sn)
! l += strlen(sn);
! if (pi)
! l += strlen(pi);
! if (pi && sn && !strcmp(pi, sn)) {
! l -= strlen(pi);
! pi = NULL;
! }
! tmp.value.str.val = emalloc(l + 1);
! tmp.value.str.len = _php3_sprintf(tmp.value.str.val, "%s%s", (sn ? sn : ""), (pi ? pi : "")); /* SAFE */
! tmp.type = IS_STRING;
! hash_update(&php3_globals->symbol_table, "PHP_SELF", sizeof("PHP_SELF"), (void *) & tmp, sizeof(pval), NULL);
  }
  
+
  #define ENTRY_NAME_COLOR "#999999"
  #define CONTENTS_COLOR "#DDDDDD"
  #define HEADER_COLOR "#00DDDD"
***************
*** 210,218 ****
  void sapi_print_info(void *php3_globals_var){
          char *temp;
          int i=0;
! php3_globals_struct *php3_globals=(php3_globals_struct *)php3_globals_var;
! struct sapi_request_info *sapi_info=(struct sapi_request_info *)php3_globals->sapi_rqst;
! LPEXTENSION_CONTROL_BLOCK lpEcb=(LPEXTENSION_CONTROL_BLOCK)sapi_info->scid;
  
          sapi_puts(php3_globals,"<center><h2>ISAPI Request Environment</h2></center>");
          sapi_puts(php3_globals,"<table border=5 width=\"600\">\n");
--- 245,251 ----
  void sapi_print_info(void *php3_globals_var){
          char *temp;
          int i=0;
! SAPI_FUNC_VARS;
  
          sapi_puts(php3_globals,"<center><h2>ISAPI Request Environment</h2></center>");
          sapi_puts(php3_globals,"<table border=5 width=\"600\">\n");
***************
*** 253,266 ****
  
          sapi_info->content_type = lpEcb->lpszContentType;
          sapi_info->cookies = _sapi_getenv(lpEcb,"HTTP_COOKIE");
          sapi_info->puts=sapi_puts;
          sapi_info->putc=sapi_putc;
          sapi_info->getenv=sapi_getenv;
          sapi_info->writeclient=sapi_writeclient;
          sapi_info->flush=sapi_flush;
          sapi_info->readclient=sapi_readclient;
! sapi_info->block=sapi_block;
! sapi_info->unblock=sapi_unblock;
          sapi_info->log=sapi_log;
          sapi_info->info=sapi_print_info;
  
--- 286,302 ----
  
          sapi_info->content_type = lpEcb->lpszContentType;
          sapi_info->cookies = _sapi_getenv(lpEcb,"HTTP_COOKIE");
+
+ sapi_info->aborted=0;
+
          sapi_info->puts=sapi_puts;
          sapi_info->putc=sapi_putc;
          sapi_info->getenv=sapi_getenv;
          sapi_info->writeclient=sapi_writeclient;
          sapi_info->flush=sapi_flush;
          sapi_info->readclient=sapi_readclient;
! sapi_info->block_alarms=sapi_block;
! sapi_info->unblock_alarms=sapi_unblock;
          sapi_info->log=sapi_log;
          sapi_info->info=sapi_print_info;
  
***************
*** 268,273 ****
--- 304,316 ----
          sapi_info->send_header=sapi_send_header;
          sapi_info->headers=NULL;
  
+ sapi_info->hash_server_env=sapi_hash_server_env;
+ sapi_info->register_cleanup=sapi_reqister_cleanup;
+ sapi_info->request_shutdown=sapi_request_shutdown;
+ #if defined(CRASH_DETECTION)
+ sapi_info->debug_log=sapi_debug_log;
+ #endif
+
          /*these are used in cgi, what do we do with them now*/
          sapi_info->cgi=0;
          sapi_info->display_source_mode=0;
***************
*** 283,288 ****
--- 326,332 ----
          if(sapi_info->script_name)free(sapi_info->script_name);
          if(sapi_info->cookies)free(sapi_info->cookies);
          if(sapi_info)free(sapi_info);
+ sapi_info=NULL;
  }
  
  BOOL WINAPI GetExtensionVersion (HSE_VERSION_INFO *version)
Index: php31/sapi/sapi.h
diff -c php31/sapi/sapi.h:1.4 php31/sapi/sapi.h:1.5
*** php31/sapi/sapi.h:1.4 Sun May 31 12:44:31 1998
--- php31/sapi/sapi.h Sun May 31 15:44:06 1998
***************
*** 29,35 ****
          char *cookies;
          int cgi, display_source_mode,preprocess,info_only,quiet_mode;
          char *argv0,*ini_path,*script_filename;
!
          /*handling headers*/
          char *headers; /*pointer to header list*/
          char *http_status; /* such as 401 Access Denied, needed for isapi*/
--- 29,35 ----
          char *cookies;
          int cgi, display_source_mode,preprocess,info_only,quiet_mode;
          char *argv0,*ini_path,*script_filename;
! int *aborted; /* same as apaches php3_rqst->connection->aborted*/
          /*handling headers*/
          char *headers; /*pointer to header list*/
          char *http_status; /* such as 401 Access Denied, needed for isapi*/
***************
*** 47,54 ****
          void (*log)(void *php3_globals, char *); /*use server error log*/
  
          /* signal and thread functions */
! void (*block)(void *php3_globals); /*signal blocking*/
! void (*unblock)(void *php3_globals); /*signal blocking*/
  };
  
  #if !SAPI_INTERFACE
--- 47,67 ----
          void (*log)(void *php3_globals, char *); /*use server error log*/
  
          /* signal and thread functions */
! void (*block_alarms)(void *php3_globals); /*signal blocking*/
! void (*unblock_alarms)(void *php3_globals); /*signal blocking*/
!
! /* FIXME these functions need definet work */
! void (*hash_server_env)(void *php3_globals);
! /* so far, apache specific */
! void (*register_cleanup)(void *php3_globals, void *, void *, void *);
!
! /* so far, fhttpd specific */
! void (*request_shutdown)(void *php3_globals);
!
! /* output debug information somewhere */
! #if defined(CRASH_DETECTION)
! void (*debug_log)(void *php3_globals,char *log_message);
! #endif
  };
  
  #if !SAPI_INTERFACE
***************
*** 56,67 ****
  #define PUTS(a) GLOBAL(sapi_rqst)->puts(php3_globals,(a))
  #define PUTC(a) GLOBAL(sapi_rqst)->putc(php3_globals,(a))
  #define PHPWRITE(a,n) GLOBAL(sapi_rqst)->writeclient(php3_globals,(a),(n))
! #define BLOCK_INTERRUPTIONS
! #define UNBLOCK_INTERRUPTIONS
! /*
! #define BLOCK_INTERRUPTIONS GLOBAL(sapi_rqst)->block(GLOBAL(sapi_rqst)->scid)
! #define UNBLOCK_INTERRUPTIONS GLOBAL(sapi_rqst)->unblock(GLOBAL(sapi_rqst)->scid)
! */
  #endif
  #endif
  
--- 69,76 ----
  #define PUTS(a) GLOBAL(sapi_rqst)->puts(php3_globals,(a))
  #define PUTC(a) GLOBAL(sapi_rqst)->putc(php3_globals,(a))
  #define PHPWRITE(a,n) GLOBAL(sapi_rqst)->writeclient(php3_globals,(a),(n))
! #define BLOCK_INTERRUPTIONS if(GLOBAL(sapi_rqst))GLOBAL(sapi_rqst)->block_alarms(php3_globals)
! #define UNBLOCK_INTERRUPTIONS if(GLOBAL(sapi_rqst))GLOBAL(sapi_rqst)->unblock_alarms(php3_globals)
  #endif
  #endif