CVS update: php31/sapi
| From: | zeev | Date: | Thu, 20 Aug 1998 23:06:44 +0000 |
| Subject: | CVS update: php31/sapi | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-372@lists.php.net to get a copy of this message | ||
Date: Thursday August 20, 1998 @ 19:06
Author: zeev
Update of /repository/php31/sapi
In directory asf:/tmp/cvs-serv17574/sapi
Modified Files:
apache.c apache_sapi.c cgi_sapi.c fhttpd_sapi.c getopt.c
getopt.h isapi_sapi.c mod_php3.c nsapi_cookie.h nsapi_sapi.c
old_cgimain.c php3_apache.h sapi.h
Log Message:
Some indent work
Index: php31/sapi/apache.c
diff -c php31/sapi/apache.c:2.1 php31/sapi/apache.c:2.2
*** php31/sapi/apache.c:2.1 Tue Jul 14 10:39:39 1998
--- php31/sapi/apache.c Thu Aug 20 19:06:40 1998
***************
*** 28,40 ****
+----------------------------------------------------------------------+
*/
! /* $Id: apache.c,v 2.1 1998/07/14 14:39:39 ssb Exp $ */
/* Something will have to be done with this particular file as it is
apache specific and should move out of the core compile.
! for now, it will be removed from the php3.1 project.
! */
#include "php3_apache.h"
void php3_virtual(INTERNAL_FUNCTION_PARAMETERS);
--- 28,40 ----
+----------------------------------------------------------------------+
*/
! /* $Id: apache.c,v 2.2 1998/08/20 23:06:40 zeev Exp $ */
/* Something will have to be done with this particular file as it is
apache specific and should move out of the core compile.
! for now, it will be removed from the php3.1 project.
! */
#include "php3_apache.h"
void php3_virtual(INTERNAL_FUNCTION_PARAMETERS);
***************
*** 43,88 ****
void php3_info_apache(void);
void php3_apache_note(INTERNAL_FUNCTION_PARAMETERS);
! function_entry apache_functions[] = {
! {"virtual", php3_virtual, NULL},
! {"getallheaders", php3_getallheaders, NULL},
! {"apache_note", php3_apache_note,NULL},
{NULL, NULL, NULL}
};
! php3_module_entry apache_module_entry = {
"Apache", apache_functions, NULL, NULL, NULL, NULL, php3_info_apache,
STANDARD_MODULE_PROPERTIES
};
void php3_apache_note(INTERNAL_FUNCTION_PARAMETERS)
{
! pval *arg_name,*arg_val;
char *note_val;
int arg_count = ARG_COUNT(ht);
! TLS_VARS;
! if (arg_count<1 || arg_count>2 ||
! getParameters(ht,arg_count,&arg_name,&arg_val) == FAILURE ) {
WRONG_PARAM_COUNT;
}
-
convert_to_string(arg_name);
! note_val = (char *) table_get(GLOBAL(php3_rqst)->notes,arg_name->value.str.val);
!
if (arg_count == 2) {
convert_to_string(arg_val);
! table_set(GLOBAL(php3_rqst)->notes,arg_name->value.str.val,arg_val->value.str.val);
}
-
if (note_val) {
! RETURN_STRING(note_val,0);
} else {
RETURN_FALSE;
}
}
! void php3_info_apache(void) {
module *modp = NULL;
#if !defined(WIN32) && !defined(WINNT)
char name[64];
--- 43,89 ----
void php3_info_apache(void);
void php3_apache_note(INTERNAL_FUNCTION_PARAMETERS);
! function_entry apache_functions[] =
! {
! {"virtual", php3_virtual, NULL},
! {"getallheaders", php3_getallheaders, NULL},
! {"apache_note", php3_apache_note, NULL},
{NULL, NULL, NULL}
};
! php3_module_entry apache_module_entry =
! {
"Apache", apache_functions, NULL, NULL, NULL, NULL, php3_info_apache,
STANDARD_MODULE_PROPERTIES
};
void php3_apache_note(INTERNAL_FUNCTION_PARAMETERS)
{
! pval *arg_name, *arg_val;
char *note_val;
int arg_count = ARG_COUNT(ht);
! TLS_VARS;
! if (arg_count < 1 || arg_count > 2 ||
! getParameters(ht, arg_count, &arg_name, &arg_val) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_string(arg_name);
! note_val = (char *) table_get(GLOBAL(php3_rqst)->notes, arg_name->value.str.val);
!
if (arg_count == 2) {
convert_to_string(arg_val);
! table_set(GLOBAL(php3_rqst)->notes, arg_name->value.str.val, arg_val->value.str.val);
}
if (note_val) {
! RETURN_STRING(note_val, 0);
} else {
RETURN_FALSE;
}
}
! void php3_info_apache(void)
! {
module *modp = NULL;
#if !defined(WIN32) && !defined(WINNT)
char name[64];
***************
*** 101,125 ****
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 keep alive: %s
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 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) {
--- 102,126 ----
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 keep alive: %s
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 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) {
***************
*** 143,183 ****
pval *filename;
request_rec *rr = NULL;
! if (ARG_COUNT(ht) != 1 || getParameters(ht,1,&filename) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_string(filename);
!
! if (!(rr = sub_req_lookup_uri (filename->value.str.val, php3_rqst))) {
php3_error(E_WARNING, "Unable to include '%s' - URI lookup failed",
filename->value.str.val);
! if (rr) destroy_sub_req (rr);
RETURN_FALSE;
}
-
if (rr->status != 200) {
php3_error(E_WARNING, "Unable to include '%s' - error finding URI",
filename->value.str.val);
! if (rr) destroy_sub_req (rr);
RETURN_FALSE;
}
-
/* Cannot include another PHP file because of global conflicts */
if (rr->content_type &&
!strcmp(rr->content_type, PHP3_MIME_TYPE)) {
php3_error(E_WARNING, "Cannot include a PHP file "
! "(use <code><?include \"%s\"></code> instead)",
filename->value.str.val);
! if (rr) destroy_sub_req (rr);
RETURN_FALSE;
}
-
if (!php3_header()) {
RETURN_FALSE;
}
if (run_sub_req(rr)) {
php3_error(E_WARNING, "Unable to include '%s' - request execution failed",
filename->value.str.val);
! if (rr) destroy_sub_req (rr);
RETURN_FALSE;
} else {
! if (rr) destroy_sub_req (rr);
RETURN_TRUE;
}
}
--- 144,186 ----
pval *filename;
request_rec *rr = NULL;
! if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &filename) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_string(filename);
!
! if (!(rr = sub_req_lookup_uri(filename->value.str.val, php3_rqst))) {
php3_error(E_WARNING, "Unable to include '%s' - URI lookup failed",
filename->value.str.val);
! if (rr)
! destroy_sub_req(rr);
RETURN_FALSE;
}
if (rr->status != 200) {
php3_error(E_WARNING, "Unable to include '%s' - error finding URI",
filename->value.str.val);
! if (rr)
! destroy_sub_req(rr);
RETURN_FALSE;
}
/* Cannot include another PHP file because of global conflicts */
if (rr->content_type &&
!strcmp(rr->content_type, PHP3_MIME_TYPE)) {
php3_error(E_WARNING, "Cannot include a PHP file "
! "(use <code><?include \"%s\"></code>
instead)", filename->value.str.val);
! if (rr)
! destroy_sub_req(rr);
RETURN_FALSE;
}
if (!php3_header()) {
RETURN_FALSE;
}
if (run_sub_req(rr)) {
php3_error(E_WARNING, "Unable to include '%s' - request execution failed",
filename->value.str.val);
! if (rr)
! destroy_sub_req(rr);
RETURN_FALSE;
} else {
! if (rr)
! destroy_sub_req(rr);
RETURN_TRUE;
}
}
***************
*** 185,209 ****
void php3_getallheaders(INTERNAL_FUNCTION_PARAMETERS)
{
! array_header *env_arr;
! table_entry *tenv;
! int i;
!
! if (array_init(return_value) == FAILURE) {
! RETURN_FALSE;
! }
! env_arr = table_elts(php3_rqst->headers_in);
! tenv = (table_entry *)env_arr->elts;
! for (i = 0; i < env_arr->nelts; ++i) {
if (!tenv[i].key ||
(php3_ini.safe_mode &&
!strncasecmp(tenv[i].key, "authorization", 13))) {
continue;
}
! if (add_assoc_string(return_value, tenv[i].key,tenv[i].val, 1)==FAILURE) {
RETURN_FALSE;
}
! }
}
--- 188,212 ----
void php3_getallheaders(INTERNAL_FUNCTION_PARAMETERS)
{
! array_header *env_arr;
! table_entry *tenv;
! int i;
!
! if (array_init(return_value) == FAILURE) {
! RETURN_FALSE;
! }
! env_arr = table_elts(php3_rqst->headers_in);
! tenv = (table_entry *) env_arr->elts;
! for (i = 0; i < env_arr->nelts; ++i) {
if (!tenv[i].key ||
(php3_ini.safe_mode &&
!strncasecmp(tenv[i].key, "authorization", 13))) {
continue;
}
! if (add_assoc_string(return_value, tenv[i].key, tenv[i].val, 1) == FAILURE) {
RETURN_FALSE;
}
! }
}
Index: php31/sapi/apache_sapi.c
diff -c php31/sapi/apache_sapi.c:2.3 php31/sapi/apache_sapi.c:2.4
*** php31/sapi/apache_sapi.c:2.3 Tue Aug 11 14:22:38 1998
--- php31/sapi/apache_sapi.c Thu Aug 20 19:06:41 1998
***************
*** 9,18 ****
#include "php3_ini.h"
static CookieList *top = NULL;
! char *empty_string="";
! char *undefined_variable_string="\0";
! /*temporary*/
#define module_info NULL
void php3_PushCookieList(char *);
--- 9,18 ----
#include "php3_ini.h"
static CookieList *top = NULL;
! char *empty_string = "";
! char *undefined_variable_string = "\0";
! /*temporary */
#define module_info NULL
void php3_PushCookieList(char *);
***************
*** 26,45 ****
/* FIXME what to do with p and dummy, not used here now
see php3_ini.c
! Also, what to do with php3_module_startup. At least on windows,
! this will be handled elsewhere.
! */
#if !(WIN32|WINNT)
! php3_module_startup(); /* php3_ini_master is set up here */
#endif
return _php3_copy_ini_master();
}
! void *php3_merge_dir(pool *p, void *basev,void *addv){
return _php3_merge_ini(addv);
}
! void php3_set_ini(php3_ini_structure *conf){
_php3_set_ini(conf);
}
--- 26,47 ----
/* FIXME what to do with p and dummy, not used here now
see php3_ini.c
! Also, what to do with php3_module_startup. At least on windows,
! this will be handled elsewhere.
! */
#if !(WIN32|WINNT)
! php3_module_startup(); /* php3_ini_master is set up here */
#endif
return _php3_copy_ini_master();
}
! void *php3_merge_dir(pool * p, void *basev, void *addv)
! {
return _php3_merge_ini(addv);
}
! void php3_set_ini(php3_ini_structure * conf)
! {
_php3_set_ini(conf);
}
***************
*** 64,78 ****
return (ret);
}
! char *sapi_getenv(SAPI_GLOBAL_INCLUDE char *string){
char *ptr;
SAPI_FUNC_VARS;
! ptr=table_get(php3_rqst->subprocess_env, string);
! if(!ptr)ptr = getenv(string);
return ptr;
}
! int sapi_readclient(SAPI_GLOBAL_INCLUDE unsigned char *buf, int length){
SAPI_FUNC_VARS;
long bytes;
#if MODULE_MAGIC_NUMBER > 19961007
--- 66,83 ----
return (ret);
}
! char *sapi_getenv(SAPI_GLOBAL_INCLUDE char *string)
! {
char *ptr;
SAPI_FUNC_VARS;
! ptr = table_get(php3_rqst->subprocess_env, string);
! if (!ptr)
! ptr = getenv(string);
return ptr;
}
! int sapi_readclient(SAPI_GLOBAL_INCLUDE unsigned char *buf, int length)
! {
SAPI_FUNC_VARS;
long bytes;
#if MODULE_MAGIC_NUMBER > 19961007
***************
*** 105,111 ****
return bytes;
}
! int sapi_insert_header(SAPI_GLOBAL_INCLUDE unsigned char *header){
char *rr = NULL;
char *temp = NULL;
long myuid = 0L;
--- 110,117 ----
return bytes;
}
! int sapi_insert_header(SAPI_GLOBAL_INCLUDE unsigned char *header)
! {
char *rr = NULL;
char *temp = NULL;
long myuid = 0L;
***************
*** 122,137 ****
*r = '\0';
if (!strcasecmp(header, "Content-type")) {
if (*(r + 1) == ' ')
! php3_rqst->content_type = pstrdup(php3_rqst->pool,r + 2);
else
! php3_rqst->content_type = pstrdup(php3_rqst->pool,r + 1);
/* FIXME cont_type is already estrduped. This changed it, thus causing
! the efree to fail after this function exits. What is it here for,
! and what do we need to do to fix it.
! GLOBAL(cont_type) = php3_rqst->content_type; */
! } else if (!strcasecmp(header, "Set-Cookie")){
*r = ':';
! php3_PushCookieList(r+1);
} else {
if (*(r + 1) == ' ')
rr = r + 2;
--- 128,143 ----
*r = '\0';
if (!strcasecmp(header, "Content-type")) {
if (*(r + 1) == ' ')
! php3_rqst->content_type = pstrdup(php3_rqst->pool, r + 2);
else
! php3_rqst->content_type = pstrdup(php3_rqst->pool, r + 1);
/* FIXME cont_type is already estrduped. This changed it, thus causing
! the efree to fail after this function exits. What is it here for,
! and what do we need to do to fix it.
! GLOBAL(cont_type) = php3_rqst->content_type; */
! } else if (!strcasecmp(header, "Set-Cookie")) {
*r = ':';
! php3_PushCookieList(r + 1);
} else {
if (*(r + 1) == ' ')
rr = r + 2;
***************
*** 139,151 ****
rr = r + 1;
if (GLOBAL(php3_ini)->safe_mode && (!strcasecmp(header,
"WWW-authenticate"))) {
myuid = _php3_getuid();
! sprintf(temp2, "realm=\"%ld ", myuid); /* SAFE */
temp = _php3_regreplace("realm=\"", temp2, rr, 1, 0);
if (!strcmp(temp, rr)) {
! sprintf(temp2, "realm=%ld", myuid); /* SAFE */
temp = _php3_regreplace("realm=", temp2, rr, 1, 0);
if (!strcmp(temp, rr)) {
! sprintf(temp2, " realm=%ld", myuid); /* SAFE */
temp = _php3_regreplace("$", temp2, rr, 0, 0);
}
}
--- 145,157 ----
rr = r + 1;
if (GLOBAL(php3_ini)->safe_mode && (!strcasecmp(header,
"WWW-authenticate"))) {
myuid = _php3_getuid();
! sprintf(temp2, "realm=\"%ld ", myuid); /* SAFE */
temp = _php3_regreplace("realm=\"", temp2, rr, 1, 0);
if (!strcmp(temp, rr)) {
! sprintf(temp2, "realm=%ld", myuid); /* SAFE */
temp = _php3_regreplace("realm=", temp2, rr, 1, 0);
if (!strcmp(temp, rr)) {
! sprintf(temp2, " realm=%ld", myuid); /* SAFE */
temp = _php3_regreplace("$", temp2, rr, 0, 0);
}
}
***************
*** 157,163 ****
php3_rqst->status = REDIRECT;
}
*r = ':';
! /*GLOBAL(php3_HeaderPrinted) = 2;*/
}
if (!strncasecmp(header, "http/", 5)) {
if (strlen(header) > 9) {
--- 163,169 ----
php3_rqst->status = REDIRECT;
}
*r = ':';
! /*GLOBAL(php3_HeaderPrinted) = 2; */
}
if (!strncasecmp(header, "http/", 5)) {
if (strlen(header) > 9) {
***************
*** 168,185 ****
* because it really shouldn't be freed until the end of the request and it isn't
* easy for us to figure out when we allocated it vs. when something else might have.
*/
! php3_rqst->status_line = pstrdup(php3_rqst->pool,&((header)[9]));
}
return SUCCESS;
}
! int sapi_send_header(SAPI_GLOBAL_INCLUDE_V){
CookieList *cookie;
int len = 0;
SAPI_FUNC_VARS;
! if (!php3_rqst) { /* we're not in a request, allow output */
return 1;
}
if ((GLOBAL(php3_PrintHeader) && !GLOBAL(php3_HeaderPrinted)) ||
(GLOBAL(php3_PrintHeader) && GLOBAL(php3_HeaderPrinted) == 2)) {
--- 174,192 ----
* because it really shouldn't be freed until the end of the request and it isn't
* easy for us to figure out when we allocated it vs. when something else might have.
*/
! php3_rqst->status_line = pstrdup(php3_rqst->pool, &((header)[9]));
}
return SUCCESS;
}
! int sapi_send_header(SAPI_GLOBAL_INCLUDE_V)
! {
CookieList *cookie;
int len = 0;
SAPI_FUNC_VARS;
! if (!php3_rqst) { /* we're not in a request, allow output */
return 1;
}
if ((GLOBAL(php3_PrintHeader) && !GLOBAL(php3_HeaderPrinted)) ||
(GLOBAL(php3_PrintHeader) && GLOBAL(php3_HeaderPrinted) == 2)) {
***************
*** 187,195 ****
php3_treat_data(PARSE_POST, NULL); /* POST Data */
}
cookie = php3_PopCookieList();
! while(cookie){
table_add(php3_rqst->headers_out, "Set-Cookie", cookie->cookie);
! if (cookie->cookie) efree(cookie->cookie);
efree(cookie);
cookie = php3_PopCookieList();
}
--- 194,203 ----
php3_treat_data(PARSE_POST, NULL); /* POST Data */
}
cookie = php3_PopCookieList();
! while (cookie) {
table_add(php3_rqst->headers_out, "Set-Cookie", cookie->cookie);
! if (cookie->cookie)
! efree(cookie->cookie);
efree(cookie);
cookie = php3_PopCookieList();
}
***************
*** 198,209 ****
send_http_header(php3_rqst);
if (php3_rqst->header_only) {
GLOBAL(shutdown_requested) = NORMAL_SHUTDOWN;
! return(0);
}
}
}
! void sapi_treat_headers(SAPI_GLOBAL_INCLUDE_V){
#if MODULE_MAGIC_NUMBER > 19961007
const char *s = NULL;
#else
--- 206,218 ----
send_http_header(php3_rqst);
if (php3_rqst->header_only) {
GLOBAL(shutdown_requested) = NORMAL_SHUTDOWN;
! return (0);
}
}
}
! void sapi_treat_headers(SAPI_GLOBAL_INCLUDE_V)
! {
#if MODULE_MAGIC_NUMBER > 19961007
const char *s = NULL;
#else
***************
*** 223,229 ****
/* Check to make sure that this URL isn't authenticated
using a traditional auth module mechanism */
if (auth_type(php3_rqst)) {
! /*php3_error(E_WARNING, "Authentication done by server module\n");*/
return;
}
if (strcmp(getword(php3_rqst->pool, &s, ' '), "Basic")) {
--- 232,238 ----
/* Check to make sure that this URL isn't authenticated
using a traditional auth module mechanism */
if (auth_type(php3_rqst)) {
! /*php3_error(E_WARNING, "Authentication done by server module\n"); */
return;
}
if (strcmp(getword(php3_rqst->pool, &s, ' '), "Basic")) {
***************
*** 265,272 ****
}
}
! /* this was php3_apache_puts*/
! int sapi_puts(SAPI_GLOBAL_INCLUDE unsigned char *string){
SAPI_FUNC_VARS;
if (php3_rqst) {
--- 274,282 ----
}
}
! /* this was php3_apache_puts */
! int sapi_puts(SAPI_GLOBAL_INCLUDE unsigned char *string)
! {
SAPI_FUNC_VARS;
if (php3_rqst) {
***************
*** 278,286 ****
}
/* this was php3_apache_putc */
! int sapi_putc(SAPI_GLOBAL_INCLUDE unsigned char c){
SAPI_FUNC_VARS;
!
if (php3_rqst) {
return rputc(c, php3_rqst);
} else {
--- 288,297 ----
}
/* this was php3_apache_putc */
! int sapi_putc(SAPI_GLOBAL_INCLUDE unsigned char c)
! {
SAPI_FUNC_VARS;
!
if (php3_rqst) {
return rputc(c, php3_rqst);
} else {
***************
*** 289,295 ****
return FAILURE;
}
! int sapi_writeclient(SAPI_GLOBAL_INCLUDE unsigned char *string, int len){
SAPI_FUNC_VARS;
--- 300,307 ----
return FAILURE;
}
! int sapi_writeclient(SAPI_GLOBAL_INCLUDE unsigned char *string, int len)
! {
SAPI_FUNC_VARS;
***************
*** 301,323 ****
return FAILURE;
}
! int sapi_flush(SAPI_GLOBAL_INCLUDE_V){
SAPI_FUNC_VARS;
! # if MODULE_MAGIC_NUMBER > 19970110
rflush(php3_rqst);
! # else
bflush(php3_rqst->connection->client);
! # endif
return SUCCESS;
}
! void sapi_block(SAPI_GLOBAL_INCLUDE_V){block_alarms();}
! void sapi_unblock(SAPI_GLOBAL_INCLUDE_V){unblock_alarms();}
! int sapi_request_shutdown(SAPI_GLOBAL_INCLUDE_V){return SUCCESS;}
/* code from main.c in php3_log_err() */
! void sapi_log(SAPI_GLOBAL_INCLUDE char *log_message){
SAPI_FUNC_VARS;
if (php3_rqst) {
--- 313,348 ----
return FAILURE;
}
! int sapi_flush(SAPI_GLOBAL_INCLUDE_V)
! {
SAPI_FUNC_VARS;
! #if MODULE_MAGIC_NUMBER > 19970110
rflush(php3_rqst);
! #else
bflush(php3_rqst->connection->client);
! #endif
return SUCCESS;
}
+
+ void sapi_block(SAPI_GLOBAL_INCLUDE_V)
+ {
+ block_alarms();
+ }
+
+ void sapi_unblock(SAPI_GLOBAL_INCLUDE_V)
+ {
+ unblock_alarms();
+ }
! int sapi_request_shutdown(SAPI_GLOBAL_INCLUDE_V)
! {
! return SUCCESS;
! }
/* code from main.c in php3_log_err() */
! void sapi_log(SAPI_GLOBAL_INCLUDE char *log_message)
! {
SAPI_FUNC_VARS;
if (php3_rqst) {
***************
*** 332,343 ****
}
}
! void sapi_register_cleanup(SAPI_GLOBAL_INCLUDE void *arg1, void *arg2, void *arg3){
SAPI_FUNC_VARS;
! register_cleanup(php3_rqst->pool, arg1, arg2, arg3);
}
! int sapi_aborted(SAPI_GLOBAL_INCLUDE_V){
SAPI_FUNC_VARS;
return php3_rqst->connection->aborted;
}
--- 357,370 ----
}
}
! void sapi_register_cleanup(SAPI_GLOBAL_INCLUDE void *arg1, void *arg2, void *arg3)
! {
SAPI_FUNC_VARS;
! register_cleanup(php3_rqst->pool, arg1, arg2, arg3);
}
! int sapi_aborted(SAPI_GLOBAL_INCLUDE_V)
! {
SAPI_FUNC_VARS;
return php3_rqst->connection->aborted;
}
***************
*** 346,365 ****
/******************************************************************************
/* apache crash detection
/*****************************************************************************/
! void sapi_debug_log(SAPI_GLOBAL_INCLUDE 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
--- 373,394 ----
/******************************************************************************
/* apache crash detection
/*****************************************************************************/
! void sapi_debug_log(SAPI_GLOBAL_INCLUDE 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
***************
*** 367,375 ****
/* apache specific info called from info.c
/*****************************************************************************/
! extern module *top_module;/* from info.c */
! void sapi_print_info(SAPI_GLOBAL_INCLUDE_V){
SAPI_FUNC_VARS;
module *modp = NULL;
#if !defined(WIN32) && !defined(WINNT)
--- 396,405 ----
/* apache specific info called from info.c
/*****************************************************************************/
! extern module *top_module; /* from info.c */
! void sapi_print_info(SAPI_GLOBAL_INCLUDE_V)
! {
SAPI_FUNC_VARS;
module *modp = NULL;
#if !defined(WIN32) && !defined(WINNT)
***************
*** 390,414 ****
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 keep alive: %s
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 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) {
--- 420,444 ----
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 keep alive: %s
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 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) {
***************
*** 422,433 ****
{
register int i;
array_header *arr = table_elts(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 "\">");
--- 452,463 ----
{
register int i;
array_header *arr = table_elts(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 "\">");
***************
*** 448,454 ****
PUTS(php3_rqst->the_request);
PUTS(" </td></tr>\n");
env_arr = table_elts(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 "\">");
--- 478,484 ----
PUTS(php3_rqst->the_request);
PUTS(" </td></tr>\n");
env_arr = table_elts(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 "\">");
***************
*** 460,467 ****
}
PUTS(" <tr><th colspan=2 bgcolor=\"" HEADER_COLOR "\">HTTP
Response Headers</th></tr>\n");
env_arr = table_elts(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);
--- 490,497 ----
}
PUTS(" <tr><th colspan=2 bgcolor=\"" HEADER_COLOR "\">HTTP
Response Headers</th></tr>\n");
env_arr = table_elts(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);
***************
*** 478,484 ****
/******************************************************************************
/* code from main.c in _php3_hash_environment()
/*****************************************************************************/
! void sapi__php3_hash_server_env(SAPI_GLOBAL_INCLUDE_V){
SAPI_FUNC_VARS;
pval *tmp_ptr, tmp2, tmp;
char *t;
--- 508,515 ----
/******************************************************************************
/* code from main.c in _php3_hash_environment()
/*****************************************************************************/
! void sapi__php3_hash_server_env(SAPI_GLOBAL_INCLUDE_V)
! {
SAPI_FUNC_VARS;
pval *tmp_ptr, tmp2, tmp;
char *t;
***************
*** 516,543 ****
}
/*
! Here is the old apache request info init
!
! DEPRECATED.
! Must now init the sapi structure
! */
! struct sapi_request_info *sapi_init(request_rec *php3_rqst)
{
char *buf;
! struct sapi_request_info *sapi_info=malloc(sizeof(struct sapi_request_info));
! if(!sapi_info)return NULL;
! sapi_info->scid=php3_rqst;
sapi_info->current_user = NULL;
sapi_info->current_user_length = 0;
/* see above for why this has to be estrdup()'d */
sapi_info->rqst_filename = strdup(php3_rqst->filename);
! sapi_info->filename = NULL; /* we will estrdup rqst_filename later*/
sapi_info->request_method = php3_rqst->method;
sapi_info->query_string = php3_rqst->args;
sapi_info->content_type = table_get(php3_rqst->subprocess_env, "CONTENT_TYPE");
--- 547,575 ----
}
/*
! Here is the old apache request info init
!
! DEPRECATED.
! Must now init the sapi structure
! */
! struct sapi_request_info *sapi_init(request_rec * php3_rqst)
{
char *buf;
! struct sapi_request_info *sapi_info = malloc(sizeof(struct sapi_request_info));
! if (!sapi_info)
! return NULL;
! sapi_info->scid = php3_rqst;
sapi_info->current_user = NULL;
sapi_info->current_user_length = 0;
/* see above for why this has to be estrdup()'d */
sapi_info->rqst_filename = strdup(php3_rqst->filename);
! sapi_info->filename = NULL; /* we will estrdup rqst_filename later */
sapi_info->request_method = php3_rqst->method;
sapi_info->query_string = php3_rqst->args;
sapi_info->content_type = table_get(php3_rqst->subprocess_env, "CONTENT_TYPE");
***************
*** 547,619 ****
sapi_info->cookies = table_get(php3_rqst->subprocess_env, "HTTP_COOKIE");
! sapi_info->puts=sapi_puts;
! sapi_info->sputc=sapi_putc;
! sapi_info->getenv=sapi_getenv;
! sapi_info->writeclient=sapi_writeclient;
! sapi_info->flush=sapi_flush;
! sapi_info->readclient=sapi_readclient;
! sapi_info->blockalarms=sapi_block;
! sapi_info->unblockalarms=sapi_unblock;
! sapi_info->log=sapi_log;
! sapi_info->info=sapi_print_info;
!
! sapi_info->insert_header=sapi_insert_header;
! sapi_info->send_header=sapi_send_header;
! sapi_info->headers=NULL;
! sapi_info->treat_headers=sapi_treat_headers;
!
! sapi_info->_php3_hash_server_env=sapi__php3_hash_server_env;
! sapi_info->register_clean=sapi_register_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;
! sapi_info->preprocess=0;
! sapi_info->info_only=0;
! sapi_info->quiet_mode=0;
/* Apache has already gone through the trouble of doing
! the stat(), so the only real overhead is copying three
! values. We can afford it, and it means we don't have to
! worry about resetting the static variables after every
! hit. */
! sapi_info->page_uid = php3_rqst->finfo.st_uid;
sapi_info->page_inode = php3_rqst->finfo.st_ino;
sapi_info->page_mtime = php3_rqst->finfo.st_mtime;
sapi_info->aborted = sapi_aborted;
return sapi_info;
}
! void sapi_shutdown(struct sapi_request_info *sapi_info){
! if(sapi_info->filename)free(sapi_info->filename);
! if(sapi_info)free(sapi_info);
! sapi_info=NULL;
}
/*
! Here is the old apache main from main.c
!
! DEPRECATED.
! Must now call php3_sapi_main from this file.
! */
PHPAPI int apache_php3_module_main(request_rec * r, int fd, int display_source_mode, int
preprocessed)
{
! struct sapi_request_info *sapi_info=sapi_init(r);
! if(!sapi_info)return FAILURE;
!
! sapi_info->display_source_mode=display_source_mode;
! sapi_info->preprocess=preprocessed;
! sapi_info->fileopen=fd;
! return(php3_sapi_main(sapi_info,module_info));
}
#if WIN32|WINNT
--- 579,655 ----
sapi_info->cookies = table_get(php3_rqst->subprocess_env, "HTTP_COOKIE");
! sapi_info->puts = sapi_puts;
! sapi_info->sputc = sapi_putc;
! sapi_info->getenv = sapi_getenv;
! sapi_info->writeclient = sapi_writeclient;
! sapi_info->flush = sapi_flush;
! sapi_info->readclient = sapi_readclient;
! sapi_info->blockalarms = sapi_block;
! sapi_info->unblockalarms = sapi_unblock;
! sapi_info->log = sapi_log;
! sapi_info->info = sapi_print_info;
!
! sapi_info->insert_header = sapi_insert_header;
! sapi_info->send_header = sapi_send_header;
! sapi_info->headers = NULL;
! sapi_info->treat_headers = sapi_treat_headers;
!
! sapi_info->_php3_hash_server_env = sapi__php3_hash_server_env;
! sapi_info->register_clean = sapi_register_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;
! sapi_info->preprocess = 0;
! sapi_info->info_only = 0;
! sapi_info->quiet_mode = 0;
/* Apache has already gone through the trouble of doing
! the stat(), so the only real overhead is copying three
! values. We can afford it, and it means we don't have to
! worry about resetting the static variables after every
! hit. */
! sapi_info->page_uid = php3_rqst->finfo.st_uid;
sapi_info->page_inode = php3_rqst->finfo.st_ino;
sapi_info->page_mtime = php3_rqst->finfo.st_mtime;
sapi_info->aborted = sapi_aborted;
return sapi_info;
}
! void sapi_shutdown(struct sapi_request_info *sapi_info)
! {
! if (sapi_info->filename)
! free(sapi_info->filename);
! if (sapi_info)
! free(sapi_info);
! sapi_info = NULL;
}
/*
! Here is the old apache main from main.c
! DEPRECATED.
! Must now call php3_sapi_main from this file.
+ */
+
PHPAPI int apache_php3_module_main(request_rec * r, int fd, int display_source_mode, int
preprocessed)
{
! struct sapi_request_info *sapi_info = sapi_init(r);
!
! if (!sapi_info)
! return FAILURE;
! sapi_info->display_source_mode = display_source_mode;
! sapi_info->preprocess = preprocessed;
! sapi_info->fileopen = fd;
! return (php3_sapi_main(sapi_info, module_info));
}
#if WIN32|WINNT
Index: php31/sapi/cgi_sapi.c
diff -c php31/sapi/cgi_sapi.c:2.8 php31/sapi/cgi_sapi.c:2.9
*** php31/sapi/cgi_sapi.c:2.8 Fri Aug 14 15:41:27 1998
--- php31/sapi/cgi_sapi.c Thu Aug 20 19:06:41 1998
***************
*** 1,9 ****
/*
! Server API Abstraction Layer
! functions for CGI
! */
#include <stdio.h>
#include <stdarg.h>
#include "php.h"
--- 1,9 ----
/*
! Server API Abstraction Layer
! functions for CGI
! */
#include <stdio.h>
#include <stdarg.h>
#include "php.h"
***************
*** 33,145 ****
#define module_info NULL
/* sapi functions */
! int sapi_readclient(SAPI_GLOBAL_INCLUDE unsigned char *buf, int length){
! int bytes=0,cnt = 0;
do {
bytes = fread(buf + cnt, 1, length - cnt, stdin);
cnt += bytes;
} while (bytes && cnt < length);
return bytes;
}
! char *sapi_getenv(SAPI_GLOBAL_INCLUDE char *string){
return getenv(string);
}
! int sapi_insert_header(SAPI_GLOBAL_INCLUDE unsigned char *header){
puts(header);
! if(puts("\015\012")<0){
! sapi_info->abort=1;
#if MSVC5
OutputDebugString("insert header failed\n");
#endif
}
return SUCCESS;
}
! int sapi_send_header(SAPI_GLOBAL_INCLUDE_V){
! if(puts("\015\012")<0){
! sapi_info->abort=1;
#if MSVC5
OutputDebugString("send header failed\n");
#endif
}
return SUCCESS;
}
! int sapi_flush(SAPI_GLOBAL_INCLUDE_V){
return fflush(stdout);
}
! int sapi_puts(SAPI_GLOBAL_INCLUDE unsigned char *string){
! if(puts(string)<0){
! sapi_info->abort=1;
#if MSVC5
OutputDebugString("puts failed\n");
#endif
}
return SUCCESS;
}
! int sapi_putc(SAPI_GLOBAL_INCLUDE unsigned char c){
! if(putc(c,stdout)<0){
! sapi_info->abort=1;
#if MSVC5
OutputDebugString("putc failed\n");
#endif
}
return SUCCESS;
}
! int sapi_writeclient(SAPI_GLOBAL_INCLUDE unsigned char *string, int len){
! if(fwrite(string,len,1,stdout)<(unsigned int)len){
! sapi_info->abort=1;
#if MSVC5
OutputDebugString("write client (fwrite) failed\n");
#endif
}
return SUCCESS;
}
! void sapi_log(SAPI_GLOBAL_INCLUDE char *message){
! fprintf(stderr,message);
}
! void sapi_print_info(SAPI_GLOBAL_INCLUDE_V){
}
! void sapi_block(SAPI_GLOBAL_INCLUDE_V){
}
! void sapi_unblock(SAPI_GLOBAL_INCLUDE_V){
}
! void sapi_reqister_cleanup(SAPI_GLOBAL_INCLUDE void *arg1, void *arg2, void *arg3){
}
! void sapi_request_shutdown(SAPI_GLOBAL_INCLUDE_V){
}
! void sapi_treat_headers(SAPI_GLOBAL_INCLUDE_V){
}
! int sapi_aborted(SAPI_GLOBAL_INCLUDE_V){
return sapi_info->abort;
}
#if defined(CRASH_DETECTION)
! /******************************************************************************
! /* crash detection logging
! /*****************************************************************************/
! void sapi_debug_log(SAPI_GLOBAL_INCLUDE char *message){
char log_message[256];
SAPI_FUNC_VARS;
!
! #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 _php3_hash_environment()
/*****************************************************************************/
! void sapi__php3_hash_server_env(SAPI_GLOBAL_INCLUDE_V){
pval tmp;
/* Build the special-case PHP_SELF variable for the CGI version */
char *sn, *pi;
--- 33,183 ----
#define module_info NULL
/* sapi functions */
! int sapi_readclient(SAPI_GLOBAL_INCLUDE unsigned char *buf, int length)
! {
! int bytes = 0, cnt = 0;
do {
bytes = fread(buf + cnt, 1, length - cnt, stdin);
cnt += bytes;
} while (bytes && cnt < length);
return bytes;
}
+
! char *sapi_getenv(SAPI_GLOBAL_INCLUDE char *string)
! {
return getenv(string);
}
+
! int sapi_insert_header(SAPI_GLOBAL_INCLUDE unsigned char *header)
! {
puts(header);
! if (puts("\015\012") < 0) {
! sapi_info->abort = 1;
#if MSVC5
OutputDebugString("insert header failed\n");
#endif
}
return SUCCESS;
}
+
! int sapi_send_header(SAPI_GLOBAL_INCLUDE_V)
! {
! if (puts("\015\012") < 0) {
! sapi_info->abort = 1;
#if MSVC5
OutputDebugString("send header failed\n");
#endif
}
return SUCCESS;
}
+
! int sapi_flush(SAPI_GLOBAL_INCLUDE_V)
! {
return fflush(stdout);
}
+
! int sapi_puts(SAPI_GLOBAL_INCLUDE unsigned char *string)
! {
! if (puts(string) < 0) {
! sapi_info->abort = 1;
#if MSVC5
OutputDebugString("puts failed\n");
#endif
}
return SUCCESS;
}
+
! int sapi_putc(SAPI_GLOBAL_INCLUDE unsigned char c)
! {
! if (putc(c, stdout) < 0) {
! sapi_info->abort = 1;
#if MSVC5
OutputDebugString("putc failed\n");
#endif
}
return SUCCESS;
}
+
! int sapi_writeclient(SAPI_GLOBAL_INCLUDE unsigned char *string, int len)
! {
! if (fwrite(string, len, 1, stdout) < (unsigned int) len) {
! sapi_info->abort = 1;
#if MSVC5
OutputDebugString("write client (fwrite) failed\n");
#endif
}
return SUCCESS;
}
+
! void sapi_log(SAPI_GLOBAL_INCLUDE char *message)
! {
! fprintf(stderr, message);
}
+
! void sapi_print_info(SAPI_GLOBAL_INCLUDE_V)
! {
}
!
!
! void sapi_block(SAPI_GLOBAL_INCLUDE_V)
! {
}
!
!
! void sapi_unblock(SAPI_GLOBAL_INCLUDE_V)
! {
}
!
!
! void sapi_reqister_cleanup(SAPI_GLOBAL_INCLUDE void *arg1, void *arg2, void *arg3)
! {
}
!
!
! void sapi_request_shutdown(SAPI_GLOBAL_INCLUDE_V)
! {
}
!
!
! void sapi_treat_headers(SAPI_GLOBAL_INCLUDE_V)
! {
}
!
!
! int sapi_aborted(SAPI_GLOBAL_INCLUDE_V)
! {
return sapi_info->abort;
}
#if defined(CRASH_DETECTION)
! /* Crash detection logging */
! void sapi_debug_log(SAPI_GLOBAL_INCLUDE char *message)
! {
char log_message[256];
SAPI_FUNC_VARS;
!
! # 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 _php3_hash_environment()
/*****************************************************************************/
! void sapi__php3_hash_server_env(SAPI_GLOBAL_INCLUDE_V)
! {
pval tmp;
/* Build the special-case PHP_SELF variable for the CGI version */
char *sn, *pi;
***************
*** 148,157 ****
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;
--- 186,197 ----
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;
***************
*** 166,191 ****
#endif
}
void sapi_init(void)
{
char *buf;
/* for cgi we dont use request id's */
! sapi_info->scid=NULL;
! if (!sapi_info->rqst_filename){
! sapi_info->rqst_filename=NULL;
}
! sapi_info->filename=NULL;
! if (!sapi_info->path_info){
sapi_info->path_info = getenv("PATH_INFO");
}
sapi_info->path_translated = getenv("PATH_TRANSLATED");
! if (!sapi_info->query_string){
sapi_info->query_string = getenv("QUERY_STRING");
}
sapi_info->current_user = NULL;
! sapi_info->current_user_length=0;
sapi_info->request_method = getenv("REQUEST_METHOD");
sapi_info->script_name = getenv("SCRIPT_NAME");
buf = getenv("CONTENT_LENGTH");
--- 206,232 ----
#endif
}
+
void sapi_init(void)
{
char *buf;
/* for cgi we dont use request id's */
! sapi_info->scid = NULL;
! if (!sapi_info->rqst_filename) {
! sapi_info->rqst_filename = NULL;
}
! sapi_info->filename = NULL;
! if (!sapi_info->path_info) {
sapi_info->path_info = getenv("PATH_INFO");
}
sapi_info->path_translated = getenv("PATH_TRANSLATED");
! if (!sapi_info->query_string) {
sapi_info->query_string = getenv("QUERY_STRING");
}
sapi_info->current_user = NULL;
! sapi_info->current_user_length = 0;
sapi_info->request_method = getenv("REQUEST_METHOD");
sapi_info->script_name = getenv("SCRIPT_NAME");
buf = getenv("CONTENT_LENGTH");
***************
*** 193,246 ****
sapi_info->content_type = getenv("CONTENT_TYPE");
sapi_info->cookies = getenv("HTTP_COOKIE");
! sapi_info->aborted=0;
! sapi_info->puts=sapi_puts;
! sapi_info->sputc=sapi_putc;
! sapi_info->getenv=sapi_getenv;
! sapi_info->writeclient=sapi_writeclient;
! sapi_info->flush=sapi_flush;
! sapi_info->insert_header=sapi_insert_header;
! sapi_info->send_header=sapi_send_header;
! sapi_info->treat_headers=sapi_treat_headers;
! sapi_info->readclient=sapi_readclient;
! sapi_info->blockalarms=sapi_block;
! sapi_info->unblockalarms=sapi_unblock;
! sapi_info->log=sapi_log;
! sapi_info->info=sapi_print_info;
sapi_info->aborted = sapi_aborted;
sapi_info->abort = 0;
! /*page stat info*/
! sapi_info->page_uid=0;
! sapi_info->page_inode=0;
! sapi_info->page_mtime=0;
!
! sapi_info->_php3_hash_server_env=sapi__php3_hash_server_env;
! sapi_info->register_clean=sapi_reqister_cleanup;
! sapi_info->request_shutdown=sapi_request_shutdown;
#if defined(CRASH_DETECTION)
! sapi_info->debug_log=sapi_debug_log;
#endif
/* Hack for annoying servers that do not set SCRIPT_FILENAME for us
! (like anything other than apache? :)*/
! if(!sapi_info->script_filename){
sapi_info->script_filename = getenv("SCRIPT_FILENAME");
}
! if(!sapi_info->script_filename){
if (sapi_info->argv0) {
sapi_info->script_filename = sapi_info->argv0;
! }else if (sapi_info->path_translated) {
/*for broken servers that don't set argv correctly,
! not the best thing, but works*/
sapi_info->script_filename = strdup(sapi_info->path_translated);
} else {
! /*hmm, no file specified, we could just exit with error now*/
sapi_info->script_filename = NULL;
}
}
-
if (sapi_info->script_filename) {
sapi_info->rqst_filename = strdup(sapi_info->script_filename);
} else {
--- 234,286 ----
sapi_info->content_type = getenv("CONTENT_TYPE");
sapi_info->cookies = getenv("HTTP_COOKIE");
! sapi_info->aborted = 0;
! sapi_info->puts = sapi_puts;
! sapi_info->sputc = sapi_putc;
! sapi_info->getenv = sapi_getenv;
! sapi_info->writeclient = sapi_writeclient;
! sapi_info->flush = sapi_flush;
! sapi_info->insert_header = sapi_insert_header;
! sapi_info->send_header = sapi_send_header;
! sapi_info->treat_headers = sapi_treat_headers;
! sapi_info->readclient = sapi_readclient;
! sapi_info->blockalarms = sapi_block;
! sapi_info->unblockalarms = sapi_unblock;
! sapi_info->log = sapi_log;
! sapi_info->info = sapi_print_info;
sapi_info->aborted = sapi_aborted;
sapi_info->abort = 0;
! /*page stat info */
! sapi_info->page_uid = 0;
! sapi_info->page_inode = 0;
! sapi_info->page_mtime = 0;
!
! sapi_info->_php3_hash_server_env = sapi__php3_hash_server_env;
! sapi_info->register_clean = sapi_reqister_cleanup;
! sapi_info->request_shutdown = sapi_request_shutdown;
#if defined(CRASH_DETECTION)
! sapi_info->debug_log = sapi_debug_log;
#endif
/* Hack for annoying servers that do not set SCRIPT_FILENAME for us
! (like anything other than apache? :) */
! if (!sapi_info->script_filename) {
sapi_info->script_filename = getenv("SCRIPT_FILENAME");
}
! if (!sapi_info->script_filename) {
if (sapi_info->argv0) {
sapi_info->script_filename = sapi_info->argv0;
! } else if (sapi_info->path_translated) {
/*for broken servers that don't set argv correctly,
! not the best thing, but works */
sapi_info->script_filename = strdup(sapi_info->path_translated);
} else {
! /*hmm, no file specified, we could just exit with error now */
sapi_info->script_filename = NULL;
}
}
if (sapi_info->script_filename) {
sapi_info->rqst_filename = strdup(sapi_info->script_filename);
} else {
***************
*** 248,257 ****
}
}
! void sapi_end(void){
! if(sapi_info->argv0)free(sapi_info->argv0);
! if(sapi_info->rqst_filename)free(sapi_info->rqst_filename);
! #ifndef THREAD_SAFE /*it gets freed from dllmain() if thread safe*/
free(sapi_info);
#endif
}
--- 288,303 ----
}
}
!
! void sapi_end(void)
! {
! if (sapi_info->argv0) {
! free(sapi_info->argv0);
! }
! if (sapi_info->rqst_filename) {
! free(sapi_info->rqst_filename);
! }
! #ifndef THREAD_SAFE /*it gets freed from dllmain() if thread safe */
free(sapi_info);
#endif
}
***************
*** 269,316 ****
}
printf("Usage: %s [-q] [-h]"
! " [-s]"
! " [-v] [-i] [-f <file>] | "
! "{<file> [args...]}\n"
! " -q Quiet-mode. Suppress HTTP Header output.\n"
! " -s Display colour syntax highlighted source.\n"
! " -f<file> Parse <file>. Implies `-q'\n"
! " -v Version number\n"
! " -p Pretokenize a script (creates a .php3p file)\n"
! " -e Execute a pretokenized (.php3p) script\n"
! " -c<path> Look for php3.ini file in this directory\n"
! " -i PHP information\n"
! " -h This help\n", prog);
}
/* some systems are missing these from their header files */
extern char *optarg;
extern int optind;
int main(int argc, char *argv[])
{
! int cgi=0, arg = 1, c, i, len, ret=0;
FILE *in = NULL;
char *s;
#if WIN32|WINNT
WORD wVersionRequested;
WSADATA wsaData;
!
! wVersionRequested = MAKEWORD( 2, 0 );
#endif
! sapi_info=malloc(sizeof(struct sapi_request_info));
#ifndef THREAD_SAFE
! sapi_rqst=sapi_info;
#endif
! sapi_info->cgi=0;
! sapi_info->quiet_mode=0;
! sapi_info->preprocess=0;
! sapi_info->info_only=0;
sapi_info->display_source_mode = 0;
! sapi_info->rqst_filename=NULL;
! sapi_info->script_filename=NULL;
! sapi_info->filename=NULL;
! sapi_info->query_string=NULL;
/* Make sure we detect we are a cgi - a bit redundancy here,
but the default case is that we have to check only the first one. */
--- 315,363 ----
}
printf("Usage: %s [-q] [-h]"
! " [-s]"
! " [-v] [-i] [-f <file>] | "
! "{<file> [args...]}\n"
! " -q Quiet-mode. Suppress HTTP Header output.\n"
! " -s Display colour syntax highlighted source.\n"
! " -f<file> Parse <file>. Implies `-q'\n"
! " -v Version number\n"
! " -p Pretokenize a script (creates a .php3p file)\n"
! " -e Execute a pretokenized (.php3p) script\n"
! " -c<path> Look for php3.ini file in this directory\n"
! " -i PHP information\n"
! " -h This help\n", prog);
}
+
/* some systems are missing these from their header files */
extern char *optarg;
extern int optind;
int main(int argc, char *argv[])
{
! int cgi = 0, arg = 1, c, i, len, ret = 0;
FILE *in = NULL;
char *s;
#if WIN32|WINNT
WORD wVersionRequested;
WSADATA wsaData;
!
! wVersionRequested = MAKEWORD(2, 0);
#endif
! sapi_info = malloc(sizeof(struct sapi_request_info));
#ifndef THREAD_SAFE
! sapi_rqst = sapi_info;
#endif
! sapi_info->cgi = 0;
! sapi_info->quiet_mode = 0;
! sapi_info->preprocess = 0;
! sapi_info->info_only = 0;
sapi_info->display_source_mode = 0;
! sapi_info->rqst_filename = NULL;
! sapi_info->script_filename = NULL;
! sapi_info->filename = NULL;
! sapi_info->query_string = NULL;
/* Make sure we detect we are a cgi - a bit redundancy here,
but the default case is that we have to check only the first one. */
***************
*** 346,352 ****
#endif /* FORCE_CGI_REDIRECT */
}
#if WIN32|WINNT
! if ( WSAStartup( wVersionRequested, &wsaData ) != 0 ) {
return 0;
}
#endif
--- 393,399 ----
#endif /* FORCE_CGI_REDIRECT */
}
#if WIN32|WINNT
! if (WSAStartup(wVersionRequested, &wsaData) != 0) {
return 0;
}
#endif
***************
*** 356,378 ****
switch (c) {
case 'f':
sapi_info->script_filename = strdup(optarg);
! /* break missing intentionally */
case 'q':
! sapi_info->quiet_mode=1;
break;
case 'v':
printf("%s\n", PHP_VERSION);
exit(1);
break;
case 'i':
! sapi_info->info_only=1;
break;
! case 'p': /* preprocess */
! sapi_info->preprocess=1;
! sapi_info->quiet_mode=1;
break;
! case 'e': /* execute preprocessed script */
! sapi_info->preprocess=2;
break;
case 's':
sapi_info->display_source_mode = 1;
--- 403,425 ----
switch (c) {
case 'f':
sapi_info->script_filename = strdup(optarg);
! /* break missing intentionally */
case 'q':
! sapi_info->quiet_mode = 1;
break;
case 'v':
printf("%s\n", PHP_VERSION);
exit(1);
break;
case 'i':
! sapi_info->info_only = 1;
break;
! case 'p': /* preprocess */
! sapi_info->preprocess = 1;
! sapi_info->quiet_mode = 1;
break;
! case 'e': /* execute preprocessed script */
! sapi_info->preprocess = 2;
break;
case 's':
sapi_info->display_source_mode = 1;
***************
*** 392,433 ****
arg++;
}
}
!
! if ((sapi_info->path_info=getenv("PATH_INFO"))) {
sapi_info->cgi = 1;
! } else if (!(sapi_info->query_string=getenv("QUERY_STRING"))) {
! for(i=arg,len=0; i<argc; i++) {
! len+=strlen(argv[i])+1;
}
! s = malloc(len*sizeof(char)+1); /* leak - but only for command line version, so ok */
! *s='\0'; /* we are pretending it came from the environment */
! s[len-1]='\0';
! for(i=arg,len=0; i<argc; i++) {
! strcat(s,argv[i]);
! if (i<(argc-1)) strcat(s,"+");
}
sapi_info->query_string = s;
}
-
if (sapi_info->script_filename == NULL && !sapi_info->cgi && argc > arg)
{
sapi_info->argv0 = strdup(argv[arg]);
}
-
sapi_init();
_php3_sapi_process_start(module_info);
! ret=php3_sapi_main(sapi_info,module_info);
_php3_sapi_process_end(module_info);
#if WIN32|WINNT
! /*close down sockets*/
WSACleanup();
#endif
sapi_end();
return ret;
}
-
-
--- 439,476 ----
arg++;
}
}
! if ((sapi_info->path_info = getenv("PATH_INFO"))) {
sapi_info->cgi = 1;
! } else if (!(sapi_info->query_string = getenv("QUERY_STRING"))) {
! for (i = arg, len = 0; i < argc; i++) {
! len += strlen(argv[i]) + 1;
}
! s = malloc(len * sizeof(char) + 1); /* leak - but only for command line version, so ok */
! *s = '\0'; /* we are pretending it came from the environment */
! s[len - 1] = '\0';
! for (i = arg, len = 0; i < argc; i++) {
! strcat(s, argv[i]);
! if (i < (argc - 1))
! strcat(s, "+");
}
sapi_info->query_string = s;
}
if (sapi_info->script_filename == NULL && !sapi_info->cgi && argc > arg)
{
sapi_info->argv0 = strdup(argv[arg]);
}
sapi_init();
_php3_sapi_process_start(module_info);
! ret = php3_sapi_main(sapi_info, module_info);
_php3_sapi_process_end(module_info);
#if WIN32|WINNT
! /*close down sockets */
WSACleanup();
#endif
sapi_end();
return ret;
}
Index: php31/sapi/fhttpd_sapi.c
diff -c php31/sapi/fhttpd_sapi.c:2.0 php31/sapi/fhttpd_sapi.c:2.1
*** php31/sapi/fhttpd_sapi.c:2.0 Fri Jul 3 09:19:22 1998
--- php31/sapi/fhttpd_sapi.c Thu Aug 20 19:06:41 1998
***************
*** 1,3 ****
--- 1,5 ----
+
+
/* this is just a slight beginning, as I strip some code from other
areas of php. Shane */
***************
*** 32,96 ****
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
! char *sapi_getenv(void *php3_globals_var, char *string){
! char *ptr=NULL;
int i;
! if (req){
! for(i=0;i<req->nlines;i++){
! if (req->lines[i].paramc>1){
! if (req->lines[i].params[0]){
if (!strcmp(req->lines[i].params[0],
! str->value.str.val)){
! ptr=req->lines[i].params[1];
! i=req->nlines;
}
}
}
}
}
! if (!ptr) ptr = getenv(str->value.str.val);
return ptr;
}
! int sapi_readclient(void *php3_globals_var, char *buf, int len){
! memcpy(buf,req->databuffer,length);
! buf[length]=0;
return length
}
! int sapi_flush(void *php3_globals_var){
return SUCCESS;
}
! 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");
}
! void sapi_treat_headers(){
#if FHTTPD
! int i,len;
struct rline *l;
char *type;
char *escaped_str;
! if(req && req->remote_user){
! for(i=0; i < req->nlines; i++){
! l=req->lines+i;
! if((l->paramc > 1)&&!strcasecmp(l->params[0], "REMOTE_PW")){
type = "Basic";
if (GLOBAL(php3_ini).magic_quotes_gpc) {
escaped_str = _php3_addslashes(type, 0, &len, 0);
--- 34,105 ----
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
! char *sapi_getenv(void *php3_globals_var, char *string)
! {
! char *ptr = NULL;
int i;
! if (req) {
! for (i = 0; i < req->nlines; i++) {
! if (req->lines[i].paramc > 1) {
! if (req->lines[i].params[0]) {
if (!strcmp(req->lines[i].params[0],
! str->value.str.val)) {
! ptr = req->lines[i].params[1];
! i = req->nlines;
}
}
}
}
}
! if (!ptr)
! ptr = getenv(str->value.str.val);
return ptr;
}
! int sapi_readclient(void *php3_globals_var, char *buf, int len)
! {
! memcpy(buf, req->databuffer, length);
! buf[length] = 0;
return length
}
! int sapi_flush(void *php3_globals_var)
! {
return SUCCESS;
}
! 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");
}
! void sapi_treat_headers()
! {
#if FHTTPD
! int i, len;
struct rline *l;
char *type;
char *escaped_str;
! if (req && req->remote_user) {
! for (i = 0; i < req->nlines; i++) {
! l = req->lines + i;
! if ((l->paramc > 1) && !strcasecmp(l->params[0], "REMOTE_PW")) {
type = "Basic";
if (GLOBAL(php3_ini).magic_quotes_gpc) {
escaped_str = _php3_addslashes(type, 0, &len, 0);
***************
*** 105,111 ****
SET_VAR_STRING("PHP_AUTH_PW", estrdup(l->params[1]));
SET_VAR_STRING("PHP_AUTH_USER", estrdup(req->remote_user));
}
! i=req->nlines;
}
}
}
--- 114,120 ----
SET_VAR_STRING("PHP_AUTH_PW", estrdup(l->params[1]));
SET_VAR_STRING("PHP_AUTH_USER", estrdup(req->remote_user));
}
! i = req->nlines;
}
}
}
***************
*** 116,132 ****
/******************************************************************************
/* 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 _php3_hash_environment()
/*****************************************************************************/
! void sapi__php3_hash_server_env(void *php3_globals_var){
SAPI_FUNC_VARS;
{
int i, j;
--- 125,144 ----
/******************************************************************************
/* 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 _php3_hash_environment()
/*****************************************************************************/
! void sapi__php3_hash_server_env(void *php3_globals_var)
! {
SAPI_FUNC_VARS;
{
int i, j;
***************
*** 137,144 ****
tmp.value.str.val = estrndup(req->lines[i].params[1], tmp.value.str.len);
tmp.type = IS_STRING;
if (_php3_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);
}
}
--- 149,156 ----
tmp.value.str.val = estrndup(req->lines[i].params[1], tmp.value.str.len);
tmp.type = IS_STRING;
if (_php3_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);
}
}
***************
*** 149,156 ****
tmp.value.str.val = estrndup(req->script_name_resolved, i);
tmp.type = IS_STRING;
if (_php3_hash_update(&GLOBAL(symbol_table), "PATH_TRANSLATED",
! sizeof("PATH_TRANSLATED"),
! &tmp, sizeof(pval), NULL) == FAILURE) {
efree(tmp.value.str.val);
}
if (req->script_name) {
--- 161,168 ----
tmp.value.str.val = estrndup(req->script_name_resolved, i);
tmp.type = IS_STRING;
if (_php3_hash_update(&GLOBAL(symbol_table), "PATH_TRANSLATED",
! sizeof("PATH_TRANSLATED"),
! &tmp, sizeof(pval), NULL) == FAILURE) {
efree(tmp.value.str.val);
}
if (req->script_name) {
***************
*** 162,169 ****
tmp.value.str.val = estrndup(req->script_name_resolved, j);
tmp.type = IS_STRING;
if (_php3_hash_update(&GLOBAL(symbol_table), "DOCUMENT_ROOT",
! sizeof("DOCUMENT_ROOT"),
! &tmp, sizeof(pval), NULL) == FAILURE) {
efree(tmp.value.str.val);
}
}
--- 174,181 ----
tmp.value.str.val = estrndup(req->script_name_resolved, j);
tmp.type = IS_STRING;
if (_php3_hash_update(&GLOBAL(symbol_table), "DOCUMENT_ROOT",
! sizeof("DOCUMENT_ROOT"),
! &tmp, sizeof(pval), NULL) == FAILURE) {
efree(tmp.value.str.val);
}
}
***************
*** 176,183 ****
/*
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;
--- 188,196 ----
/*
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;
***************
*** 224,236 ****
}
/*
! Here is the old fhttpd request info init
!
! DEPRECATED.
! Must now init the sapi structure.
! */
#if FHTTPD
char script_name_resolved_buffer[2048];
--- 237,249 ----
}
/*
! Here is the old fhttpd request info init
!
! DEPRECATED.
! Must now init the sapi structure.
! */
#if FHTTPD
char script_name_resolved_buffer[2048];
***************
*** 320,341 ****
exit_requested = 1;
}
} else {
! exit_status = 1;
}
return FAILURE;
}
#endif /* FHTTPD */
/*
! 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)
--- 333,354 ----
exit_requested = 1;
}
} else {
! exit_status = 1;
}
return FAILURE;
}
#endif /* FHTTPD */
/*
! 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)
***************
*** 633,644 ****
}
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
--- 646,657 ----
}
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
***************
*** 674,677 ****
return 0;
}
#endif /* FHTTPD */
-
--- 687,689 ----
Index: php31/sapi/getopt.c
diff -c php31/sapi/getopt.c:2.0 php31/sapi/getopt.c:2.1
*** php31/sapi/getopt.c:2.0 Fri Jul 3 09:19:22 1998
--- php31/sapi/getopt.c Thu Aug 20 19:06:42 1998
***************
*** 1,3 ****
--- 1,4 ----
+
/* Borrowed from Apache NT Port */
#if !APACHE
***************
*** 17,171 ****
int opterr = 1;
int optopt;
! static int
! optiserr(int argc, char * const *argv, int oint, const char *optstr,
! int optchr, int err)
{
! if (opterr)
! {
! fprintf(stderr, "Error in argument %d, char %d: ", oint, optchr+1);
! switch(err)
! {
! case OPTERRCOLON:
! fprintf(stderr, ": in flags\n");
! break;
! case OPTERRNF:
! fprintf(stderr, "option not found %c\n", argv[oint][optchr]);
! break;
! case OPTERRARG:
! fprintf(stderr, "no argument for option %c\n", argv[oint][optchr]);
! break;
! default:
! fprintf(stderr, "unknown\n");
! break;
! }
! }
! optopt = argv[oint][optchr];
! return('?');
}
!
! int
! getopt(int argc, char* const *argv, const char *optstr)
{
! static int optchr = 0;
! static int dash = 0; /* have already seen the - */
! char *cp;
! if (optind >= argc)
! return(EOF);
! if (!dash && (argv[optind][0] != '-'))
! return(EOF);
! if (!dash && (argv[optind][0] == '-') && !argv[optind][1])
! {
! /*
! * use to specify stdin. Need to let pgm process this and
! * the following args
! */
! return(EOF);
! }
! if ((argv[optind][0] == '-') && (argv[optind][1] == '-'))
! {
! /* -- indicates end of args */
! optind++;
! return(EOF);
! }
! if (!dash)
! {
! assert((argv[optind][0] == '-') && argv[optind][1]);
! dash = 1;
! optchr = 1;
! }
!
! /* Check if the guy tries to do a -: kind of flag */
! assert(dash);
! if (argv[optind][optchr] == ':')
! {
! dash = 0;
! optind++;
! return(optiserr(argc, argv, optind-1, optstr, optchr, OPTERRCOLON));
! }
! if (!(cp = strchr(optstr, argv[optind][optchr])))
! {
! int errind = optind;
! int errchr = optchr;
!
! if (!argv[optind][optchr+1])
! {
! dash = 0;
! optind++;
! }
! else
! optchr++;
! return(optiserr(argc, argv, errind, optstr, errchr, OPTERRNF));
! }
! if (cp[1] == ':')
! {
! dash = 0;
! optind++;
! if (optind == argc)
! return(optiserr(argc, argv, optind-1, optstr, optchr, OPTERRARG));
! optarg = argv[optind++];
! return(*cp);
! }
! else
! {
! if (!argv[optind][optchr+1])
! {
! dash = 0;
! optind++;
! }
! else
! optchr++;
! return(*cp);
! }
! assert(0);
! return(0);
}
! #endif /* !APACHE */
#ifdef TESTGETOPT
! int
! main (int argc, char **argv)
! {
! int c;
! extern char *optarg;
! extern int optind;
! int aflg = 0;
! int bflg = 0;
! int errflg = 0;
! char *ofile = NULL;
!
! while ((c = getopt(argc, argv, "abo:")) != EOF)
! switch (c) {
! case 'a':
! if (bflg)
! errflg++;
! else
! aflg++;
! break;
! case 'b':
! if (aflg)
! errflg++;
! else
! bflg++;
! break;
! case 'o':
! ofile = optarg;
! (void)printf("ofile = %s\n", ofile);
! break;
! case '?':
! errflg++;
! }
! if (errflg) {
! (void)fprintf(stderr,
! "usage: cmd [-a|-b] [-o <filename>] files...\n");
! exit (2);
! }
! for ( ; optind < argc; optind++)
! (void)printf("%s\n", argv[optind]);
! return 0;
! }
! #endif /* TESTGETOPT */
--- 18,154 ----
int opterr = 1;
int optopt;
! static int optiserr(int argc, char *const *argv, int oint, const char *optstr,
! int optchr, int err)
{
! if (opterr) {
! fprintf(stderr, "Error in argument %d, char %d: ", oint, optchr + 1);
! switch (err) {
! case OPTERRCOLON:
! fprintf(stderr, ": in flags\n");
! break;
! case OPTERRNF:
! fprintf(stderr, "option not found %c\n", argv[oint][optchr]);
! break;
! case OPTERRARG:
! fprintf(stderr, "no argument for option %c\n", argv[oint][optchr]);
! break;
! default:
! fprintf(stderr, "unknown\n");
! break;
! }
! }
! optopt = argv[oint][optchr];
! return ('?');
}
!
! int getopt(int argc, char *const *argv, const char *optstr)
{
! static int optchr = 0;
! static int dash = 0; /* have already seen the - */
! char *cp;
! if (optind >= argc)
! return (EOF);
! if (!dash && (argv[optind][0] != '-'))
! return (EOF);
! if (!dash && (argv[optind][0] == '-') && !argv[optind][1]) {
! /*
! * use to specify stdin. Need to let pgm process this and
! * the following args
! */
! return (EOF);
! }
! if ((argv[optind][0] == '-') && (argv[optind][1] == '-')) {
! /* -- indicates end of args */
! optind++;
! return (EOF);
! }
! if (!dash) {
! assert((argv[optind][0] == '-') && argv[optind][1]);
! dash = 1;
! optchr = 1;
! }
! /* Check if the guy tries to do a -: kind of flag */
! assert(dash);
! if (argv[optind][optchr] == ':') {
! dash = 0;
! optind++;
! return (optiserr(argc, argv, optind - 1, optstr, optchr, OPTERRCOLON));
! }
! if (!(cp = strchr(optstr, argv[optind][optchr]))) {
! int errind = optind;
! int errchr = optchr;
!
! if (!argv[optind][optchr + 1]) {
! dash = 0;
! optind++;
! } else
! optchr++;
! return (optiserr(argc, argv, errind, optstr, errchr, OPTERRNF));
! }
! if (cp[1] == ':') {
! dash = 0;
! optind++;
! if (optind == argc)
! return (optiserr(argc, argv, optind - 1, optstr, optchr, OPTERRARG));
! optarg = argv[optind++];
! return (*cp);
! } else {
! if (!argv[optind][optchr + 1]) {
! dash = 0;
! optind++;
! } else
! optchr++;
! return (*cp);
! }
! assert(0);
! return (0);
}
! #endif /* !APACHE */
#ifdef TESTGETOPT
! int main(int argc, char **argv)
! {
! int c;
! extern char *optarg;
! extern int optind;
! int aflg = 0;
! int bflg = 0;
! int errflg = 0;
! char *ofile = NULL;
!
! while ((c = getopt(argc, argv, "abo:")) != EOF)
! switch (c) {
! case 'a':
! if (bflg)
! errflg++;
! else
! aflg++;
! break;
! case 'b':
! if (aflg)
! errflg++;
! else
! bflg++;
! break;
! case 'o':
! ofile = optarg;
! (void) printf("ofile = %s\n", ofile);
! break;
! case '?':
! errflg++;
! }
! if (errflg) {
! (void) fprintf(stderr,
! "usage: cmd [-a|-b] [-o <filename>] files...\n");
! exit(2);
! }
! for (; optind < argc; optind++)
! (void) printf("%s\n", argv[optind]);
! return 0;
! }
! #endif /* TESTGETOPT */
Index: php31/sapi/getopt.h
diff -c php31/sapi/getopt.h:2.0 php31/sapi/getopt.h:2.1
*** php31/sapi/getopt.h:2.0 Fri Jul 3 09:19:22 1998
--- php31/sapi/getopt.h Thu Aug 20 19:06:42 1998
***************
*** 6,9 ****
extern int opterr;
extern int optopt;
! extern int getopt(int argc, char* const *argv, const char *optstr);
--- 6,9 ----
extern int opterr;
extern int optopt;
! extern int getopt(int argc, char *const *argv, const char *optstr);
Index: php31/sapi/isapi_sapi.c
diff -c php31/sapi/isapi_sapi.c:2.8 php31/sapi/isapi_sapi.c:2.9
*** php31/sapi/isapi_sapi.c:2.8 Tue Aug 11 14:22:38 1998
--- php31/sapi/isapi_sapi.c Thu Aug 20 19:06:42 1998
***************
*** 11,23 ****
#include "ext/standard/php3_string.h"
#include "ext/standard/base64.h"
! char *empty_string="";
! char *undefined_variable_string="\0";
#define ENTRY_NAME_COLOR "#999999"
#define CONTENTS_COLOR "#DDDDDD"
#define HEADER_COLOR "#00DDDD"
! char *isapi_env[]={
"AUTH_TYPE",
"CONTENT_LENGTH",
"CONTENT_TYPE",
--- 11,24 ----
#include "ext/standard/php3_string.h"
#include "ext/standard/base64.h"
! char *empty_string = "";
! char *undefined_variable_string = "\0";
#define ENTRY_NAME_COLOR "#999999"
#define CONTENTS_COLOR "#DDDDDD"
#define HEADER_COLOR "#00DDDD"
! char *isapi_env[] =
! {
"AUTH_TYPE",
"CONTENT_LENGTH",
"CONTENT_TYPE",
***************
*** 55,256 ****
struct sapi_request_info *sapi_info=(struct sapi_request_info *)php3_globals->sapi_rqst;\
LPEXTENSION_CONTROL_BLOCK lpEcb=(LPEXTENSION_CONTROL_BLOCK)sapi_info->scid
! php3_module_entry *module_info=NULL;
#if DEBUG
! void logmessage(void *scid,char *message, char *funcname){
char logmessage[81];
! LPEXTENSION_CONTROL_BLOCK lpEcb=scid;
! snprintf(logmessage,79,"%d:%s:%s\n",lpEcb->ConnID,funcname,message);
#if 0
! _php3_error_log(4,logmessage,"/phplog.txt",NULL);
#else
/* this will output right to the msvc debugger window,
or to DBMON which comes with msvc */
OutputDebugString(logmessage);
#endif
}
#endif
! int sapi_readclient(SAPI_GLOBAL_INCLUDE unsigned char *buf, int len){
DWORD leftover;
SAPI_FUNC_VARS;
! strncpy(buf,lpEcb->lpbData,lpEcb->cbAvailable);
! if((leftover=lpEcb->cbTotalBytes-lpEcb->cbAvailable)>0)
! lpEcb->ReadClient(lpEcb->ConnID,(LPVOID)(buf+lpEcb->cbAvailable),&leftover);
return leftover;
}
#define MAX_BUFF_SIZE 4096
! char *sapi_getenv(SAPI_GLOBAL_INCLUDE char *string){
char var[MAX_BUFF_SIZE];
! DWORD dwLen=MAX_BUFF_SIZE;
SAPI_FUNC_VARS;
if (!string)
return NULL;
!
! dwLen=lpEcb->GetServerVariable(lpEcb->ConnID,string,var,&dwLen);
! if (dwLen == 0 || dwLen >1024)
return NULL;
else
return estrdup(var);
}
! char *_sapi_getenv(LPEXTENSION_CONTROL_BLOCK lpEcb, char *string){
char var[MAX_BUFF_SIZE];
! DWORD dwLen=MAX_BUFF_SIZE;
if (!string)
return NULL;
!
! dwLen=lpEcb->GetServerVariable(lpEcb->ConnID,string,var,&dwLen);
! if (dwLen == 0 || dwLen >1024)
return NULL;
else
return strdup(var);
}
! /*FIXME need to make isapi correctly handle redirects and status strings*/
! int sapi_insert_header(SAPI_GLOBAL_INCLUDE unsigned char *header){
! char *tempstr=NULL,*r;
! SAPI_FUNC_VARS;
! /*inserts header into a list of headers*/
! if(header){
! /*lets check to see if this is a HTTP/1.x response*/
r = strchr(header, '/');
! if(r){
*r = '\0';
if (!strcasecmp(header, "HTTP")) {
! *r='/';
r = strchr(header, ' ');
! sapi_info->http_status=estrdup(r+1);
return SUCCESS;
}
! *r='/';
}
/*lets check to see if this is a redirect
! NOTE sending a redirect in IIS cancels out all other
! headers (docs say they are ignored) */
r = strchr(header, ':');
! if(r){
*r = '\0';
if (!strcasecmp(header, "Location")) {
! *r=':';
! if(*(r+1) == '/' || *(r+2) == '/'){ /*local redirect*/
! sapi_info->http_redirect=2;
! }else{ /*redirect to remote system*/
! sapi_info->http_redirect=1;
}
! sapi_info->http_status=estrdup(r+1);
return SUCCESS;
}
! *r=':';
}
-
/* iis will not do any other headers if we're redirecting,
! so ignore them */
! if(!sapi_info->http_redirect){
! if(sapi_info->headers){
! tempstr=emalloc(strlen(header)+strlen(sapi_info->headers)+3);
! sprintf(tempstr,"%s\015\012%s",sapi_info->headers,header);
efree(sapi_info->headers);
! sapi_info->headers=tempstr;
! }else{
! sapi_info->headers=estrdup(header);
}
}
! /* we could do this, but no real sence to it.
! else{
! php3_error(E_NOTICE,"Cannot send additional headers on a redirect!");
! return FAILURE;
! }*/
}
return SUCCESS;
}
! int sapi_send_header(SAPI_GLOBAL_INCLUDE_V){
SAPI_FUNC_VARS;
! int headlen=0;
! char *tempstr=NULL;
DWORD req;
if (php3_globals->php3_PrintHeader && !php3_globals->php3_HeaderPrinted) {
/* if we're sending a location header... */
! switch(sapi_info->http_redirect){
! case 1:
! req=HSE_REQ_SEND_URL_REDIRECT_RESP;
! headlen=strlen(sapi_info->http_status);
! break;
! case 2:
! req=HSE_REQ_SEND_URL;
! headlen=strlen(sapi_info->http_status);
! break;
! default:
! req=HSE_REQ_SEND_RESPONSE_HEADER;
! /* iis will not do any other headers if we're redirecting,
! so ignore them */
! if(sapi_info->headers){
! headlen=strlen(sapi_info->headers)+5;
! tempstr=emalloc(headlen);
! sprintf(tempstr,"%s\015\012\015\012",sapi_info->headers);
! }
! break;
}
/* free headers now, as some headers may exist even if we
! are doing a redirect */
! if(sapi_info->headers){
efree(sapi_info->headers);
}
-
if (!lpEcb->ServerSupportFunction(lpEcb->ConnID,
! req,sapi_info->http_status,&headlen,
! (LPDWORD)tempstr)){
/*FIXME request_shutdown on failure! */
! if(tempstr)efree(tempstr);
#if defined(CRASH_DETECTION)
! debug_log("sapi_send_header failure %s,%d\n",cfilename,clineno);
#endif
! sapi_info->abort=1;
return FAILURE;
}
! if(tempstr)efree(tempstr);
}
return SUCCESS;
}
! void sapi_treat_headers(SAPI_GLOBAL_INCLUDE_V){
SAPI_FUNC_VARS;
int len;
! char *escaped_str,*decoded,*r,*password;
! char *auth,*authinfo=sapi_getenv(SAPI_GLOBAL_PASS "HTTP_AUTHORIZATION");
#ifdef DEBUG
char logmessage[80];
#endif
! if(!authinfo)return;
! if(strncmp("Basic ",authinfo,6)){
efree(authinfo);
return;
}
! auth=authinfo+6;
! decoded=_php3_base64_decode(auth,strlen(auth),&len);
r = strchr(decoded, ':');
! if(r){
*r = '\0';
! password=r+1;
#ifdef DEBUG
! snprintf(logmessage,79,"%d:sapi_treat_headers:decoded: %s - %s\n",
! GetCurrentThreadId(),
! decoded,password);
OutputDebugString(logmessage);
#endif
if (decoded) {
if (GLOBAL(php3_ini)->magic_quotes_gpc) {
! len=strlen(decoded);
escaped_str = _php3_addslashes(decoded, 0, &len, 0);
SET_VAR_STRINGL("PHP_AUTH_USER", escaped_str, len);
} else {
--- 56,266 ----
struct sapi_request_info *sapi_info=(struct sapi_request_info *)php3_globals->sapi_rqst;\
LPEXTENSION_CONTROL_BLOCK lpEcb=(LPEXTENSION_CONTROL_BLOCK)sapi_info->scid
! php3_module_entry *module_info = NULL;
#if DEBUG
! void logmessage(void *scid, char *message, char *funcname)
! {
char logmessage[81];
! LPEXTENSION_CONTROL_BLOCK lpEcb = scid;
! snprintf(logmessage, 79, "%d:%s:%s\n", lpEcb->ConnID, funcname, message);
#if 0
! _php3_error_log(4, logmessage, "/phplog.txt", NULL);
#else
/* this will output right to the msvc debugger window,
or to DBMON which comes with msvc */
OutputDebugString(logmessage);
#endif
}
+
#endif
! int sapi_readclient(SAPI_GLOBAL_INCLUDE unsigned char *buf, int len)
! {
DWORD leftover;
SAPI_FUNC_VARS;
! strncpy(buf, lpEcb->lpbData, lpEcb->cbAvailable);
! if ((leftover = lpEcb->cbTotalBytes - lpEcb->cbAvailable) > 0)
! lpEcb->ReadClient(lpEcb->ConnID, (LPVOID) (buf + lpEcb->cbAvailable), &leftover);
return leftover;
}
#define MAX_BUFF_SIZE 4096
! char *sapi_getenv(SAPI_GLOBAL_INCLUDE char *string)
! {
char var[MAX_BUFF_SIZE];
! DWORD dwLen = MAX_BUFF_SIZE;
SAPI_FUNC_VARS;
if (!string)
return NULL;
!
! dwLen = lpEcb->GetServerVariable(lpEcb->ConnID, string, var, &dwLen);
! if (dwLen == 0 || dwLen > 1024)
return NULL;
else
return estrdup(var);
}
! char *_sapi_getenv(LPEXTENSION_CONTROL_BLOCK lpEcb, char *string)
! {
char var[MAX_BUFF_SIZE];
! DWORD dwLen = MAX_BUFF_SIZE;
if (!string)
return NULL;
!
! dwLen = lpEcb->GetServerVariable(lpEcb->ConnID, string, var, &dwLen);
! if (dwLen == 0 || dwLen > 1024)
return NULL;
else
return strdup(var);
}
! /*FIXME need to make isapi correctly handle redirects and status strings */
! int sapi_insert_header(SAPI_GLOBAL_INCLUDE unsigned char *header)
! {
! char *tempstr = NULL, *r;
! SAPI_FUNC_VARS;
! /*inserts header into a list of headers */
! if (header) {
! /*lets check to see if this is a HTTP/1.x response */
r = strchr(header, '/');
! if (r) {
*r = '\0';
if (!strcasecmp(header, "HTTP")) {
! *r = '/';
r = strchr(header, ' ');
! sapi_info->http_status = estrdup(r + 1);
return SUCCESS;
}
! *r = '/';
}
/*lets check to see if this is a redirect
! NOTE sending a redirect in IIS cancels out all other
! headers (docs say they are ignored) */
r = strchr(header, ':');
! if (r) {
*r = '\0';
if (!strcasecmp(header, "Location")) {
! *r = ':';
! if (*(r + 1) == '/' || *(r + 2) == '/') { /*local redirect */
! sapi_info->http_redirect = 2;
! } else { /*redirect to remote system */
! sapi_info->http_redirect = 1;
}
! sapi_info->http_status = estrdup(r + 1);
return SUCCESS;
}
! *r = ':';
}
/* iis will not do any other headers if we're redirecting,
! so ignore them */
! if (!sapi_info->http_redirect) {
! if (sapi_info->headers) {
! tempstr = emalloc(strlen(header) + strlen(sapi_info->headers) + 3);
! sprintf(tempstr, "%s\015\012%s", sapi_info->headers, header);
efree(sapi_info->headers);
! sapi_info->headers = tempstr;
! } else {
! sapi_info->headers = estrdup(header);
}
}
! /* we could do this, but no real sence to it.
! else{
! php3_error(E_NOTICE,"Cannot send additional headers on a redirect!");
! return FAILURE;
! } */
}
return SUCCESS;
}
! int sapi_send_header(SAPI_GLOBAL_INCLUDE_V)
! {
SAPI_FUNC_VARS;
! int headlen = 0;
! char *tempstr = NULL;
DWORD req;
if (php3_globals->php3_PrintHeader && !php3_globals->php3_HeaderPrinted) {
/* if we're sending a location header... */
! switch (sapi_info->http_redirect) {
! case 1:
! req = HSE_REQ_SEND_URL_REDIRECT_RESP;
! headlen = strlen(sapi_info->http_status);
! break;
! case 2:
! req = HSE_REQ_SEND_URL;
! headlen = strlen(sapi_info->http_status);
! break;
! default:
! req = HSE_REQ_SEND_RESPONSE_HEADER;
! /* iis will not do any other headers if we're redirecting,
! so ignore them */
! if (sapi_info->headers) {
! headlen = strlen(sapi_info->headers) + 5;
! tempstr = emalloc(headlen);
! sprintf(tempstr, "%s\015\012\015\012", sapi_info->headers);
! }
! break;
}
/* free headers now, as some headers may exist even if we
! are doing a redirect */
! if (sapi_info->headers) {
efree(sapi_info->headers);
}
if (!lpEcb->ServerSupportFunction(lpEcb->ConnID,
! req, sapi_info->http_status, &headlen,
! (LPDWORD) tempstr)) {
/*FIXME request_shutdown on failure! */
! if (tempstr)
! efree(tempstr);
#if defined(CRASH_DETECTION)
! debug_log("sapi_send_header failure %s,%d\n", cfilename, clineno);
#endif
! sapi_info->abort = 1;
return FAILURE;
}
! if (tempstr)
! efree(tempstr);
}
return SUCCESS;
}
! void sapi_treat_headers(SAPI_GLOBAL_INCLUDE_V)
! {
SAPI_FUNC_VARS;
int len;
! char *escaped_str, *decoded, *r, *password;
! char *auth, *authinfo = sapi_getenv(SAPI_GLOBAL_PASS "HTTP_AUTHORIZATION");
#ifdef DEBUG
char logmessage[80];
#endif
! if (!authinfo)
! return;
! if (strncmp("Basic ", authinfo, 6)) {
efree(authinfo);
return;
}
! auth = authinfo + 6;
! decoded = _php3_base64_decode(auth, strlen(auth), &len);
r = strchr(decoded, ':');
! if (r) {
*r = '\0';
! password = r + 1;
#ifdef DEBUG
! snprintf(logmessage, 79, "%d:sapi_treat_headers:decoded: %s - %s\n",
! GetCurrentThreadId(),
! decoded, password);
OutputDebugString(logmessage);
#endif
if (decoded) {
if (GLOBAL(php3_ini)->magic_quotes_gpc) {
! len = strlen(decoded);
escaped_str = _php3_addslashes(decoded, 0, &len, 0);
SET_VAR_STRINGL("PHP_AUTH_USER", escaped_str, len);
} else {
***************
*** 259,265 ****
}
if (password) {
if (GLOBAL(php3_ini)->magic_quotes_gpc) {
! len=strlen(password);
escaped_str = _php3_addslashes(password, 0, &len, 0);
SET_VAR_STRINGL("PHP_AUTH_PW", escaped_str, len);
} else {
--- 269,275 ----
}
if (password) {
if (GLOBAL(php3_ini)->magic_quotes_gpc) {
! len = strlen(password);
escaped_str = _php3_addslashes(password, 0, &len, 0);
SET_VAR_STRINGL("PHP_AUTH_PW", escaped_str, len);
} else {
***************
*** 274,337 ****
}
/* FIXME probably not used in isapi unless we buffer the page */
! int sapi_flush(SAPI_GLOBAL_INCLUDE_V){
return SUCCESS;
}
! int sapi_puts(SAPI_GLOBAL_INCLUDE unsigned char *string){
SAPI_FUNC_VARS;
int n;
n = strlen(string);
! if (!lpEcb->WriteClient(lpEcb->ConnID,string,&n,0)){
/*FIXME request_shutdown on failure! */
#if defined(CRASH_DETECTION)
! debug_log("sapi_puts Failure called from %s,%d\n",cfilename,clineno);
#endif
! sapi_info->abort=1;
return FAILURE;
}
return SUCCESS;
}
! int sapi_putc(SAPI_GLOBAL_INCLUDE unsigned char c){
SAPI_FUNC_VARS;
int n = 1;
! if (!lpEcb->WriteClient(lpEcb->ConnID,&c,&n,0)){
/*FIXME request_shutdown on failure! */
#if defined(CRASH_DETECTION)
! debug_log("sapi_putc failure called from %s,%d\n",cfilename,clineno);
#endif
! sapi_info->abort=1;
return FAILURE;
}
return SUCCESS;
}
! int sapi_writeclient(SAPI_GLOBAL_INCLUDE unsigned char *string, int len){
SAPI_FUNC_VARS;
! if (!lpEcb->WriteClient(lpEcb->ConnID,string,&len,0)){
/*FIXME request_shutdown on failure! */
#if defined(CRASH_DETECTION)
! debug_log("sapi_writeclient failure called from %s,%d\n",cfilename,clineno);
#endif
! sapi_info->abort=1;
return FAILURE;
}
return SUCCESS;
}
! void sapi_log(SAPI_GLOBAL_INCLUDE char *message){
}
! void sapi_block(SAPI_GLOBAL_INCLUDE_V){
}
! void sapi_unblock(SAPI_GLOBAL_INCLUDE_V){
}
! void sapi_reqister_cleanup(SAPI_GLOBAL_INCLUDE void *arg1, void *arg2, void *arg3){
}
! void sapi_request_shutdown(SAPI_GLOBAL_INCLUDE_V){
}
! int sapi_aborted(SAPI_GLOBAL_INCLUDE_V){
SAPI_FUNC_VARS;
return sapi_info->abort;
}
--- 284,357 ----
}
/* FIXME probably not used in isapi unless we buffer the page */
! int sapi_flush(SAPI_GLOBAL_INCLUDE_V)
! {
return SUCCESS;
}
! int sapi_puts(SAPI_GLOBAL_INCLUDE unsigned char *string)
! {
SAPI_FUNC_VARS;
int n;
n = strlen(string);
! if (!lpEcb->WriteClient(lpEcb->ConnID, string, &n, 0)) {
/*FIXME request_shutdown on failure! */
#if defined(CRASH_DETECTION)
! debug_log("sapi_puts Failure called from %s,%d\n", cfilename, clineno);
#endif
! sapi_info->abort = 1;
return FAILURE;
}
return SUCCESS;
}
! int sapi_putc(SAPI_GLOBAL_INCLUDE unsigned char c)
! {
SAPI_FUNC_VARS;
int n = 1;
! if (!lpEcb->WriteClient(lpEcb->ConnID, &c, &n, 0)) {
/*FIXME request_shutdown on failure! */
#if defined(CRASH_DETECTION)
! debug_log("sapi_putc failure called from %s,%d\n", cfilename, clineno);
#endif
! sapi_info->abort = 1;
return FAILURE;
}
return SUCCESS;
}
! int sapi_writeclient(SAPI_GLOBAL_INCLUDE unsigned char *string, int len)
! {
SAPI_FUNC_VARS;
! if (!lpEcb->WriteClient(lpEcb->ConnID, string, &len, 0)) {
/*FIXME request_shutdown on failure! */
#if defined(CRASH_DETECTION)
! debug_log("sapi_writeclient failure called from %s,%d\n", cfilename, clineno);
#endif
! sapi_info->abort = 1;
return FAILURE;
}
return SUCCESS;
}
! void sapi_log(SAPI_GLOBAL_INCLUDE char *message)
! {
}
! void sapi_block(SAPI_GLOBAL_INCLUDE_V)
! {
}
! void sapi_unblock(SAPI_GLOBAL_INCLUDE_V)
! {
}
! void sapi_reqister_cleanup(SAPI_GLOBAL_INCLUDE void *arg1, void *arg2, void *arg3)
! {
}
! void sapi_request_shutdown(SAPI_GLOBAL_INCLUDE_V)
! {
}
! int sapi_aborted(SAPI_GLOBAL_INCLUDE_V)
! {
SAPI_FUNC_VARS;
return sapi_info->abort;
}
***************
*** 340,363 ****
/******************************************************************************
/* crash detection logging
/*****************************************************************************/
! void sapi_debug_log(SAPI_GLOBAL_INCLUDE 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 _php3_hash_environment()
/*****************************************************************************/
! void sapi__php3_hash_server_env(SAPI_GLOBAL_INCLUDE_V){
SAPI_FUNC_VARS;
pval tmp;
! int i=0;
/* Build the special-case PHP_SELF variable for the CGI version */
char *sn, *pi, *temp;
--- 360,386 ----
/******************************************************************************
/* crash detection logging
/*****************************************************************************/
! void sapi_debug_log(SAPI_GLOBAL_INCLUDE 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 _php3_hash_environment()
/*****************************************************************************/
! void sapi__php3_hash_server_env(SAPI_GLOBAL_INCLUDE_V)
! {
SAPI_FUNC_VARS;
pval tmp;
! int i = 0;
/* Build the special-case PHP_SELF variable for the CGI version */
char *sn, *pi, *temp;
***************
*** 378,387 ****
tmp.type = IS_STRING;
_php3_hash_update(&php3_globals->symbol_table, "PHP_SELF",
sizeof("PHP_SELF"), (void *) & tmp, sizeof(pval), NULL);
! while(isapi_env[i]!=NULL){
! temp=sapi_getenv(SAPI_GLOBAL_PASS isapi_env[i]);
tmp.type = IS_STRING;
! if(temp){
tmp.value.str.len = strlen(temp);
tmp.value.str.val = estrndup(temp, tmp.value.str.len);
if (_php3_hash_update(&GLOBAL(symbol_table), isapi_env[i], sizeof(isapi_env[i]) + 1,
&tmp, sizeof(pval), NULL) == FAILURE) {
--- 401,410 ----
tmp.type = IS_STRING;
_php3_hash_update(&php3_globals->symbol_table, "PHP_SELF",
sizeof("PHP_SELF"), (void *) & tmp, sizeof(pval), NULL);
! while (isapi_env[i] != NULL) {
! temp = sapi_getenv(SAPI_GLOBAL_PASS isapi_env[i]);
tmp.type = IS_STRING;
! if (temp) {
tmp.value.str.len = strlen(temp);
tmp.value.str.val = estrndup(temp, tmp.value.str.len);
if (_php3_hash_update(&GLOBAL(symbol_table), isapi_env[i], sizeof(isapi_env[i]) + 1,
&tmp, sizeof(pval), NULL) == FAILURE) {
***************
*** 395,416 ****
! void sapi_print_info(SAPI_GLOBAL_INCLUDE_V){
char *temp;
! int i=0;
SAPI_FUNC_VARS;
sapi_puts(SAPI_GLOBAL_PASS "<center><h2>ISAPI Request
Environment</h2></center>");
sapi_puts(SAPI_GLOBAL_PASS "<table border=5 width=\"600\">\n");
sapi_puts(SAPI_GLOBAL_PASS "<tr><th bgcolor=\"" HEADER_COLOR
"\">Variable</th><th bgcolor=\"" HEADER_COLOR
"\">Value</th></tr>\n");
! while(isapi_env[i]!=NULL){
! temp=sapi_getenv(SAPI_GLOBAL_PASS isapi_env[i]);
sapi_puts(SAPI_GLOBAL_PASS "<tr><td bgcolor=\"" ENTRY_NAME_COLOR
"\">");
sapi_puts(SAPI_GLOBAL_PASS isapi_env[i]);
sapi_puts(SAPI_GLOBAL_PASS "</td><td bgcolor=\"" CONTENTS_COLOR
"\">");
! if(temp)sapi_puts(SAPI_GLOBAL_PASS temp);
sapi_puts(SAPI_GLOBAL_PASS " </td></tr>\n");
! if(temp)efree(temp);
i++;
}
sapi_puts(SAPI_GLOBAL_PASS "</table>\n");
--- 418,442 ----
! void sapi_print_info(SAPI_GLOBAL_INCLUDE_V)
! {
char *temp;
! int i = 0;
SAPI_FUNC_VARS;
sapi_puts(SAPI_GLOBAL_PASS "<center><h2>ISAPI Request
Environment</h2></center>");
sapi_puts(SAPI_GLOBAL_PASS "<table border=5 width=\"600\">\n");
sapi_puts(SAPI_GLOBAL_PASS "<tr><th bgcolor=\"" HEADER_COLOR
"\">Variable</th><th bgcolor=\"" HEADER_COLOR
"\">Value</th></tr>\n");
! while (isapi_env[i] != NULL) {
! temp = sapi_getenv(SAPI_GLOBAL_PASS isapi_env[i]);
sapi_puts(SAPI_GLOBAL_PASS "<tr><td bgcolor=\"" ENTRY_NAME_COLOR
"\">");
sapi_puts(SAPI_GLOBAL_PASS isapi_env[i]);
sapi_puts(SAPI_GLOBAL_PASS "</td><td bgcolor=\"" CONTENTS_COLOR
"\">");
! if (temp)
! sapi_puts(SAPI_GLOBAL_PASS temp);
sapi_puts(SAPI_GLOBAL_PASS " </td></tr>\n");
! if (temp)
! efree(temp);
i++;
}
sapi_puts(SAPI_GLOBAL_PASS "</table>\n");
***************
*** 419,530 ****
struct sapi_request_info *sapi_init(LPEXTENSION_CONTROL_BLOCK lpEcb)
{
! struct sapi_request_info *sapi_info=malloc(sizeof(struct sapi_request_info));
! sapi_info->scid=lpEcb;
sapi_info->path_info = lpEcb->lpszPathInfo;
sapi_info->path_translated = lpEcb->lpszPathTranslated;
sapi_info->rqst_filename = strdup(sapi_info->path_translated);
! sapi_info->filename = NULL; /* we will estrdup rqst_filename later*/
sapi_info->query_string = lpEcb->lpszQueryString;
sapi_info->current_user = NULL;
! sapi_info->current_user_length=0;
sapi_info->request_method = lpEcb->lpszMethod;
! sapi_info->script_name = _sapi_getenv(lpEcb,"SCRIPT_NAME");
sapi_info->content_length = lpEcb->cbTotalBytes;
sapi_info->content_type = lpEcb->lpszContentType;
! sapi_info->cookies = _sapi_getenv(lpEcb,"HTTP_COOKIE");
! sapi_info->puts=sapi_puts;
! sapi_info->sputc=sapi_putc;
! sapi_info->getenv=sapi_getenv;
! sapi_info->writeclient=sapi_writeclient;
! sapi_info->flush=sapi_flush;
! sapi_info->readclient=sapi_readclient;
! sapi_info->blockalarms=sapi_block;
! sapi_info->unblockalarms=sapi_unblock;
! sapi_info->log=sapi_log;
! sapi_info->info=sapi_print_info;
sapi_info->aborted = sapi_aborted;
sapi_info->abort = 0;
! sapi_info->insert_header=sapi_insert_header;
! sapi_info->treat_headers=sapi_treat_headers;
! sapi_info->send_header=sapi_send_header;
! sapi_info->headers=NULL;
! sapi_info->http_status=NULL;
! sapi_info->http_redirect=0;
!
! sapi_info->_php3_hash_server_env=sapi__php3_hash_server_env;
! sapi_info->register_clean=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;
! sapi_info->preprocess=0;
! sapi_info->info_only=0;
! sapi_info->quiet_mode=0;
!
! /*page stat info*/
! sapi_info->page_uid=0;
! sapi_info->page_inode=0;
! sapi_info->page_mtime=0;
return sapi_info;
}
! void sapi_shutdown(struct sapi_request_info *sapi_info){
! if(sapi_info->rqst_filename)free(sapi_info->rqst_filename);
! 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)
! {
! version->dwExtensionVersion = MAKELONG( HSE_VERSION_MINOR,
! HSE_VERSION_MAJOR );
! strncpy( version->lpszExtensionDesc,
! "PHP v3.1 ISAPI Extension",
HSE_MAX_EXT_DLL_NAME_LEN);
! return TRUE;
}
/* this is php3_isapi_main()!!! */
! DWORD WINAPI HttpExtensionProc (LPEXTENSION_CONTROL_BLOCK lpEcb)
{
! int ret=0;
struct sapi_request_info *sapi_info;
#if DEBUG
char logmessage[80];
! snprintf(logmessage,79,"%d:isapi_main:connID\n",GetCurrentThreadId());
OutputDebugString(logmessage);
#endif
! sapi_info=sapi_init(lpEcb);
#if DEBUG
! snprintf(logmessage,79,"%d:isapi_main:request info set\n",GetCurrentThreadId());
OutputDebugString(logmessage);
#endif
! ret=php3_sapi_main(sapi_info,module_info);
#if DEBUG
! snprintf(logmessage,79,"%d:isapi_main:php parsed\n",GetCurrentThreadId());
OutputDebugString(logmessage);
#endif
! /*make sure we free any loose allocations*/
sapi_shutdown(sapi_info);
#if DEBUG
! snprintf(logmessage,79,"%d:isapi_main:request info reset\n",GetCurrentThreadId());
OutputDebugString(logmessage);
#endif
! if(ret==SUCCESS)
return HSE_STATUS_SUCCESS;
else
return HSE_STATUS_ERROR;
--- 445,561 ----
struct sapi_request_info *sapi_init(LPEXTENSION_CONTROL_BLOCK lpEcb)
{
! struct sapi_request_info *sapi_info = malloc(sizeof(struct sapi_request_info));
! sapi_info->scid = lpEcb;
sapi_info->path_info = lpEcb->lpszPathInfo;
sapi_info->path_translated = lpEcb->lpszPathTranslated;
sapi_info->rqst_filename = strdup(sapi_info->path_translated);
! sapi_info->filename = NULL; /* we will estrdup rqst_filename later */
sapi_info->query_string = lpEcb->lpszQueryString;
sapi_info->current_user = NULL;
! sapi_info->current_user_length = 0;
sapi_info->request_method = lpEcb->lpszMethod;
! sapi_info->script_name = _sapi_getenv(lpEcb, "SCRIPT_NAME");
sapi_info->content_length = lpEcb->cbTotalBytes;
sapi_info->content_type = lpEcb->lpszContentType;
! sapi_info->cookies = _sapi_getenv(lpEcb, "HTTP_COOKIE");
! sapi_info->puts = sapi_puts;
! sapi_info->sputc = sapi_putc;
! sapi_info->getenv = sapi_getenv;
! sapi_info->writeclient = sapi_writeclient;
! sapi_info->flush = sapi_flush;
! sapi_info->readclient = sapi_readclient;
! sapi_info->blockalarms = sapi_block;
! sapi_info->unblockalarms = sapi_unblock;
! sapi_info->log = sapi_log;
! sapi_info->info = sapi_print_info;
sapi_info->aborted = sapi_aborted;
sapi_info->abort = 0;
! sapi_info->insert_header = sapi_insert_header;
! sapi_info->treat_headers = sapi_treat_headers;
! sapi_info->send_header = sapi_send_header;
! sapi_info->headers = NULL;
! sapi_info->http_status = NULL;
! sapi_info->http_redirect = 0;
!
! sapi_info->_php3_hash_server_env = sapi__php3_hash_server_env;
! sapi_info->register_clean = 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;
! sapi_info->preprocess = 0;
! sapi_info->info_only = 0;
! sapi_info->quiet_mode = 0;
!
! /*page stat info */
! sapi_info->page_uid = 0;
! sapi_info->page_inode = 0;
! sapi_info->page_mtime = 0;
return sapi_info;
}
! void sapi_shutdown(struct sapi_request_info *sapi_info)
! {
! if (sapi_info->rqst_filename)
! free(sapi_info->rqst_filename);
! 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)
! {
! version->dwExtensionVersion = MAKELONG(HSE_VERSION_MINOR,
! HSE_VERSION_MAJOR);
! strncpy(version->lpszExtensionDesc,
! "PHP v3.1 ISAPI Extension",
HSE_MAX_EXT_DLL_NAME_LEN);
! return TRUE;
}
/* this is php3_isapi_main()!!! */
! DWORD WINAPI HttpExtensionProc(LPEXTENSION_CONTROL_BLOCK lpEcb)
{
! int ret = 0;
struct sapi_request_info *sapi_info;
#if DEBUG
char logmessage[80];
! snprintf(logmessage, 79, "%d:isapi_main:connID\n", GetCurrentThreadId());
OutputDebugString(logmessage);
#endif
! sapi_info = sapi_init(lpEcb);
#if DEBUG
! snprintf(logmessage, 79, "%d:isapi_main:request info set\n", GetCurrentThreadId());
OutputDebugString(logmessage);
#endif
! ret = php3_sapi_main(sapi_info, module_info);
#if DEBUG
! snprintf(logmessage, 79, "%d:isapi_main:php parsed\n", GetCurrentThreadId());
OutputDebugString(logmessage);
#endif
! /*make sure we free any loose allocations */
sapi_shutdown(sapi_info);
#if DEBUG
! snprintf(logmessage, 79, "%d:isapi_main:request info reset\n", GetCurrentThreadId());
OutputDebugString(logmessage);
#endif
! if (ret == SUCCESS)
return HSE_STATUS_SUCCESS;
else
return HSE_STATUS_ERROR;
***************
*** 554,600 ****
/*****************************************************************************/
#define FILTER_DESCRIPTION "PHP Authentication"
! BOOL WINAPI GetFilterVersion(HTTP_FILTER_VERSION *pVersion){
! pVersion->dwFilterVersion=HTTP_FILTER_REVISION;
! strncpy(pVersion->lpszFilterDesc, FILTER_DESCRIPTION, SF_MAX_FILTER_DESC_LEN);
! pVersion->dwFlags=(SF_NOTIFY_AUTHENTICATION);
! return TRUE;
}
! DWORD WINAPI HttpFilterProc(HTTP_FILTER_CONTEXT *pFC, DWORD dwNotificationType, VOID *pvData){
! DWORD dwRet=SF_STATUS_REQ_NEXT_NOTIFICATION;
! PHTTP_FILTER_AUTHENT user=(PHTTP_FILTER_AUTHENT)pvData;
char logmessage[256];
! char *iis_user,*iis_userpw;
! switch(dwNotificationType){
! case SF_NOTIFY_AUTHENTICATION:
! if(!*user->pszUser)break;
! /* we have to get the iis user/pw we want to authenticate to*/
! cfg_get_string("iis_username",&iis_user);
! cfg_get_string("iis_userpw",&iis_userpw);
#if DEBUG
! snprintf(logmessage,256,"%d:HttpFilterProc:User: %s Pword: %s NTUser: %s NTPw: %s\n",
! GetCurrentThreadId(),
! user->pszUser,
! user->pszPassword,
! iis_user,
! iis_userpw);
! OutputDebugString(logmessage);
! #endif
!
! /*map to the iis user defined in php3.ini*/
! strcpy(user->pszUser,iis_user);
! strcpy(user->pszPassword,iis_userpw);
! /*later, we will do something here to test wether we want to pass on the
! authentication or not. Right now, this filter kills ALL authentication
! on the server except for that which is handled by PHP. */
!
! /*NOTE that with IIS 4, you can set up the filter PER server, so this
! authentication could be set up for just those servers you want to use
! php authentication for.*/
! dwRet=SF_STATUS_REQ_HANDLED_NOTIFICATION;
! break;
}
return dwRet;
}
--- 585,634 ----
/*****************************************************************************/
#define FILTER_DESCRIPTION "PHP Authentication"
! BOOL WINAPI GetFilterVersion(HTTP_FILTER_VERSION * pVersion)
! {
! pVersion->dwFilterVersion = HTTP_FILTER_REVISION;
! strncpy(pVersion->lpszFilterDesc, FILTER_DESCRIPTION, SF_MAX_FILTER_DESC_LEN);
! pVersion->dwFlags = (SF_NOTIFY_AUTHENTICATION);
! return TRUE;
}
! DWORD WINAPI HttpFilterProc(HTTP_FILTER_CONTEXT * pFC, DWORD dwNotificationType, VOID * pvData)
! {
! DWORD dwRet = SF_STATUS_REQ_NEXT_NOTIFICATION;
! PHTTP_FILTER_AUTHENT user = (PHTTP_FILTER_AUTHENT) pvData;
char logmessage[256];
! char *iis_user, *iis_userpw;
! switch (dwNotificationType) {
! case SF_NOTIFY_AUTHENTICATION:
! if (!*user->pszUser)
! break;
! /* we have to get the iis user/pw we want to authenticate to */
! cfg_get_string("iis_username", &iis_user);
! cfg_get_string("iis_userpw", &iis_userpw);
#if DEBUG
! snprintf(logmessage, 256, "%d:HttpFilterProc:User: %s Pword: %s NTUser: %s NTPw:
%s\n",
! GetCurrentThreadId(),
! user->pszUser,
! user->pszPassword,
! iis_user,
! iis_userpw);
! OutputDebugString(logmessage);
! #endif
!
! /*map to the iis user defined in php3.ini */
! strcpy(user->pszUser, iis_user);
! strcpy(user->pszPassword, iis_userpw);
! /*later, we will do something here to test wether we want to pass on the
! authentication or not. Right now, this filter kills ALL authentication
! on the server except for that which is handled by PHP. */
!
! /*NOTE that with IIS 4, you can set up the filter PER server, so this
! authentication could be set up for just those servers you want to use
! php authentication for. */
! dwRet = SF_STATUS_REQ_HANDLED_NOTIFICATION;
! break;
}
return dwRet;
}
Index: php31/sapi/mod_php3.c
diff -c php31/sapi/mod_php3.c:2.0 php31/sapi/mod_php3.c:2.1
*** php31/sapi/mod_php3.c:2.0 Fri Jul 3 09:19:23 1998
--- php31/sapi/mod_php3.c Thu Aug 20 19:06:42 1998
***************
*** 27,33 ****
| (with helpful hints from Dean Gaudet <dgaudet@arctic.org> |
+----------------------------------------------------------------------+
*/
! /* $Id: mod_php3.c,v 2.0 1998/07/03 13:19:23 rasmus Exp $ */
#include "php3_apache.h"
--- 27,33 ----
| (with helpful hints from Dean Gaudet <dgaudet@arctic.org> |
+----------------------------------------------------------------------+
*/
! /* $Id: mod_php3.c,v 2.1 1998/08/20 23:06:42 zeev Exp $ */
#include "php3_apache.h"
***************
*** 52,61 ****
extern void php3_module_shutdown();
extern void php3_module_shutdown_for_exec();
#endif
! /*located in apache_sapi.c*/
extern void *php3_create_dir(pool * p, char *dummy);
! extern void *php3_merge_dir(pool *p, void *basev,void *addv);
! extern void *php3_set_ini(php3_ini_structure *conf);
void php3_save_umask()
{
--- 52,61 ----
extern void php3_module_shutdown();
extern void php3_module_shutdown_for_exec();
#endif
! /*located in apache_sapi.c */
extern void *php3_create_dir(pool * p, char *dummy);
! extern void *php3_merge_dir(pool * p, void *basev, void *addv);
! extern void *php3_set_ini(php3_ini_structure * conf);
void php3_save_umask()
{
***************
*** 74,80 ****
#endif
}
! int send_php3(request_rec *r, int display_source_mode, int preprocessed)
{
int fd, retval;
php3_ini_structure *conf;
--- 74,80 ----
#endif
}
! int send_php3(request_rec * r, int display_source_mode, int preprocessed)
{
int fd, retval;
php3_ini_structure *conf;
***************
*** 84,97 ****
r->allowed |= (1 << METHODS) - 1;
return DECLINED;
}
-
/* Make sure file exists */
if (r->finfo.st_mode == 0)
return NOT_FOUND;
/* grab configuration settings */
conf = (php3_ini_structure *) get_module_config(r->per_dir_config, &php3_module);
! php3_set_ini(conf); /* copy to active configuration */
/*
* If PHP parser engine has been turned off with the phpEngine off directive,
--- 84,96 ----
r->allowed |= (1 << METHODS) - 1;
return DECLINED;
}
/* Make sure file exists */
if (r->finfo.st_mode == 0)
return NOT_FOUND;
/* grab configuration settings */
conf = (php3_ini_structure *) get_module_config(r->per_dir_config, &php3_module);
! php3_set_ini(conf); /* copy to active configuration */
/*
* If PHP parser engine has been turned off with the phpEngine off directive,
***************
*** 103,112 ****
return DECLINED;
}
/* Open the file */
! /* popenf isnt working on windows, so lets just open it*/
#if 0
#if WIN32|WINNT
! fd = open(r->filename, O_RDONLY,0);
#else
if ((fd = popenf(r->pool, r->filename, O_RDONLY, 0)) == -1) {
log_reason("file permissions deny server access", r->filename, r);
--- 102,111 ----
return DECLINED;
}
/* Open the file */
! /* popenf isnt working on windows, so lets just open it */
#if 0
#if WIN32|WINNT
! fd = open(r->filename, O_RDONLY, 0);
#else
if ((fd = popenf(r->pool, r->filename, O_RDONLY, 0)) == -1) {
log_reason("file permissions deny server access", r->filename, r);
***************
*** 126,132 ****
return retval;
}
#else
! update_mtime (r, r->finfo.st_mtime);
set_last_modified(r);
set_etag(r);
#endif
--- 125,131 ----
return retval;
}
#else
! update_mtime(r, r->finfo.st_mtime);
set_last_modified(r);
set_etag(r);
#endif
***************
*** 314,320 ****
return send_parsed_php3(r);
}
! void php3_init_handler(server_rec *s, pool *p)
{
/* FIXME, well have to figure out how this fits in for threaded architecture */
#ifndef THREAD_SAFE
--- 313,319 ----
return send_parsed_php3(r);
}
! void php3_init_handler(server_rec * s, pool * p)
{
/* FIXME, well have to figure out how this fits in for threaded architecture */
#ifndef THREAD_SAFE
***************
*** 322,330 ****
register_cleanup(p, NULL, NULL, NULL);
#endif
#if 0
! Skip this until the Apache guys figure out what the heck they are doing
#if MODULE_MAGIC_NUMBER >= 19980507
! ap_add_version_component(PHP_VERSION);
#endif
#endif
}
--- 321,329 ----
register_cleanup(p, NULL, NULL, NULL);
#endif
#if 0
! Skip this until the Apache guys figure out what the heck they are doing
#if MODULE_MAGIC_NUMBER >= 19980507
! ap_add_version_component(PHP_VERSION);
#endif
#endif
}
***************
*** 332,338 ****
handler_rec php3_handlers[] =
{
{"application/x-httpd-php3", send_parsed_php3},
! {"application/x-httpd-php3-preprocessed", send_parsed_preprocessed_php3},
{"application/x-httpd-php3-source", send_parsed_php3_source},
{"text/html", php3_xbithack_handler},
{NULL}
--- 331,337 ----
handler_rec php3_handlers[] =
{
{"application/x-httpd-php3", send_parsed_php3},
! {"application/x-httpd-php3-preprocessed", send_parsed_preprocessed_php3},
{"application/x-httpd-php3-source", send_parsed_php3_source},
{"text/html", php3_xbithack_handler},
{NULL}
***************
*** 341,376 ****
command_rec php3_commands[] =
{
! {"php3_error_reporting", php3take1handler, (void *)0, OR_OPTIONS, TAKE1, "error
reporting level"},
! {"php3_doc_root", php3take1handler, (void *)1, ACCESS_CONF|RSRC_CONF, TAKE1,
"directory"}, /* not used yet */
! {"php3_user_dir", php3take1handler, (void *)2, ACCESS_CONF|RSRC_CONF, TAKE1, "user
directory"}, /* not used yet */
! {"php3_safe_mode_exec_dir", php3take1handler, (void *)3, ACCESS_CONF|RSRC_CONF, TAKE1,
"safe mode executable dir"},
! {"php3_include_path", php3take1handler, (void *)4, OR_OPTIONS, TAKE1,
"colon-separated path"},
! {"php3_auto_prepend_file", php3take1handler, (void *)5, OR_OPTIONS, TAKE1, "file
name"},
! {"php3_auto_append_file", php3take1handler, (void *)6, OR_OPTIONS, TAKE1, "file
name"},
! {"php3_upload_tmp_dir", php3take1handler, (void *)7, ACCESS_CONF|RSRC_CONF, TAKE1,
"directory"},
! {"php3_extension_dir", php3take1handler, (void *)8, ACCESS_CONF|RSRC_CONF, TAKE1,
"directory"},
! {"php3_error_log", php3take1handler, (void *)9, OR_OPTIONS, TAKE1, "error log
file"},
! {"php3_arg_separator", php3take1handler, (void *)10, OR_OPTIONS, TAKE1, "GET
method arg separator"},
! {"php3_max_execution_time", php3take1handler, (void *)11, OR_OPTIONS, TAKE1, "Max
script run time in seconds"},
! {"php3_memory_limit", php3take1handler, (void *)12, OR_OPTIONS, TAKE1, "Max memory
in bytes a script may use"},
! {"php3_sendmail_path", php3take1handler, (void *)13, OR_OPTIONS, TAKE1, "Full path
to sendmail binary"},
! {"php3_browscap", php3take1handler, (void *)14, OR_OPTIONS, TAKE1, "Full path to
browscap file"},
! {"php3_gpc_order", php3take1handler, (void *)15, OR_OPTIONS, TAKE1, "Set
GET-COOKIE-POST order [default is GPC]"},
!
! {"php3_track_errors", php3flaghandler, (void *)0, OR_OPTIONS, FLAG,
"on|off"},
! {"php3_magic_quotes_gpc", php3flaghandler, (void *)1, OR_OPTIONS, FLAG,
"on|off"},
! {"php3_magic_quotes_runtime", php3flaghandler, (void *)2, OR_OPTIONS, FLAG,
"on|off"},
! {"php3_short_open_tag", php3flaghandler, (void *)3, OR_OPTIONS, FLAG,
"on|off"},
! {"php3_safe_mode", php3flaghandler, (void *)4, ACCESS_CONF|RSRC_CONF, FLAG,
"on|off"},
! {"php3_track_vars", php3flaghandler, (void *)5, OR_OPTIONS, FLAG, "on|off"},
! {"php3_sql_safe_mode", php3flaghandler, (void *)6, ACCESS_CONF|RSRC_CONF, FLAG,
"on|off"},
! {"php3_engine", php3flaghandler, (void *)7, RSRC_CONF|ACCESS_CONF, FLAG,
"on|off"},
! {"php3_xbithack", php3flaghandler, (void *)8, OR_OPTIONS, FLAG, "on|off"},
! {"php3_last_modified", php3flaghandler, (void *)9, OR_OPTIONS, FLAG,
"on|off"},
! {"php3_log_errors", php3flaghandler, (void *)10, OR_OPTIONS, FLAG, "on|off"},
! {"php3_display_errors", php3flaghandler, (void *)11, OR_OPTIONS, FLAG,
"on|off"},
! {"php3_magic_quotes_sybase", php3flaghandler, (void *)12, OR_OPTIONS, FLAG,
"on|off"},
{NULL}
};
--- 340,375 ----
command_rec php3_commands[] =
{
! {"php3_error_reporting", php3take1handler, (void *) 0, OR_OPTIONS, TAKE1, "error
reporting level"},
! {"php3_doc_root", php3take1handler, (void *) 1, ACCESS_CONF | RSRC_CONF, TAKE1,
"directory"}, /* not used yet */
! {"php3_user_dir", php3take1handler, (void *) 2, ACCESS_CONF | RSRC_CONF, TAKE1,
"user directory"}, /* not used yet */
! {"php3_safe_mode_exec_dir", php3take1handler, (void *) 3, ACCESS_CONF | RSRC_CONF,
TAKE1, "safe mode executable dir"},
! {"php3_include_path", php3take1handler, (void *) 4, OR_OPTIONS, TAKE1,
"colon-separated path"},
! {"php3_auto_prepend_file", php3take1handler, (void *) 5, OR_OPTIONS, TAKE1, "file
name"},
! {"php3_auto_append_file", php3take1handler, (void *) 6, OR_OPTIONS, TAKE1, "file
name"},
! {"php3_upload_tmp_dir", php3take1handler, (void *) 7, ACCESS_CONF | RSRC_CONF, TAKE1,
"directory"},
! {"php3_extension_dir", php3take1handler, (void *) 8, ACCESS_CONF | RSRC_CONF, TAKE1,
"directory"},
! {"php3_error_log", php3take1handler, (void *) 9, OR_OPTIONS, TAKE1, "error log
file"},
! {"php3_arg_separator", php3take1handler, (void *) 10, OR_OPTIONS, TAKE1, "GET
method arg separator"},
! {"php3_max_execution_time", php3take1handler, (void *) 11, OR_OPTIONS, TAKE1, "Max
script run time in seconds"},
! {"php3_memory_limit", php3take1handler, (void *) 12, OR_OPTIONS, TAKE1, "Max
memory in bytes a script may use"},
! {"php3_sendmail_path", php3take1handler, (void *) 13, OR_OPTIONS, TAKE1, "Full
path to sendmail binary"},
! {"php3_browscap", php3take1handler, (void *) 14, OR_OPTIONS, TAKE1, "Full path to
browscap file"},
! {"php3_gpc_order", php3take1handler, (void *) 15, OR_OPTIONS, TAKE1, "Set
GET-COOKIE-POST order [default is GPC]"},
!
! {"php3_track_errors", php3flaghandler, (void *) 0, OR_OPTIONS, FLAG,
"on|off"},
! {"php3_magic_quotes_gpc", php3flaghandler, (void *) 1, OR_OPTIONS, FLAG,
"on|off"},
! {"php3_magic_quotes_runtime", php3flaghandler, (void *) 2, OR_OPTIONS, FLAG,
"on|off"},
! {"php3_short_open_tag", php3flaghandler, (void *) 3, OR_OPTIONS, FLAG,
"on|off"},
! {"php3_safe_mode", php3flaghandler, (void *) 4, ACCESS_CONF | RSRC_CONF, FLAG,
"on|off"},
! {"php3_track_vars", php3flaghandler, (void *) 5, OR_OPTIONS, FLAG, "on|off"},
! {"php3_sql_safe_mode", php3flaghandler, (void *) 6, ACCESS_CONF | RSRC_CONF, FLAG,
"on|off"},
! {"php3_engine", php3flaghandler, (void *) 7, RSRC_CONF | ACCESS_CONF, FLAG,
"on|off"},
! {"php3_xbithack", php3flaghandler, (void *) 8, OR_OPTIONS, FLAG, "on|off"},
! {"php3_last_modified", php3flaghandler, (void *) 9, OR_OPTIONS, FLAG,
"on|off"},
! {"php3_log_errors", php3flaghandler, (void *) 10, OR_OPTIONS, FLAG,
"on|off"},
! {"php3_display_errors", php3flaghandler, (void *) 11, OR_OPTIONS, FLAG,
"on|off"},
! {"php3_magic_quotes_sybase", php3flaghandler, (void *) 12, OR_OPTIONS, FLAG,
"on|off"},
{NULL}
};
***************
*** 383,389 ****
php3_create_dir, /* per-directory config creator */
php3_merge_dir, /* dir merger */
NULL, /* per-server config creator */
! NULL, /* merge server config */
php3_commands, /* command table */
php3_handlers, /* handlers */
NULL, /* filename translation */
--- 382,388 ----
php3_create_dir, /* per-directory config creator */
php3_merge_dir, /* dir merger */
NULL, /* per-server config creator */
! NULL, /* merge server config */
php3_commands, /* command table */
php3_handlers, /* handlers */
NULL, /* filename translation */
***************
*** 397,403 ****
,NULL /* header parser */
#endif
#if MODULE_MAGIC_NUMBER >= 19970719
! ,NULL /* child_init */
#endif
#if MODULE_MAGIC_NUMBER >= 19970728
,NULL /* child_exit */
--- 396,402 ----
,NULL /* header parser */
#endif
#if MODULE_MAGIC_NUMBER >= 19970719
! ,NULL /* child_init */
#endif
#if MODULE_MAGIC_NUMBER >= 19970728
,NULL /* child_exit */
Index: php31/sapi/nsapi_cookie.h
diff -c php31/sapi/nsapi_cookie.h:2.0 php31/sapi/nsapi_cookie.h:2.1
*** php31/sapi/nsapi_cookie.h:2.0 Fri Jul 3 09:19:24 1998
--- php31/sapi/nsapi_cookie.h Thu Aug 20 19:06:43 1998
***************
*** 62,68 ****
* Retrieves the "cookie" header sent by the client and converts it into a
* pblock. If the client did not send a cookie header, returns NULL.
*/
! pblock *get_cookie_pblock(Request *rq);
/*
* set_cookie_pblock()
--- 62,68 ----
* Retrieves the "cookie" header sent by the client and converts it into a
* pblock. If the client did not send a cookie header, returns NULL.
*/
! pblock *get_cookie_pblock(Request * rq);
/*
* set_cookie_pblock()
***************
*** 73,78 ****
* pairs found in the pblock. Returns -1 on failure. Failure most likely
* means that the size of the cookie was greater than MAX_COOKIE_STRING_LEN.
*/
! int set_cookie_pblock(pblock *pb, Request *rq);
! #endif /* _NSAPI_COOKIE_H_ */
--- 73,78 ----
* pairs found in the pblock. Returns -1 on failure. Failure most likely
* means that the size of the cookie was greater than MAX_COOKIE_STRING_LEN.
*/
! int set_cookie_pblock(pblock * pb, Request * rq);
! #endif /* _NSAPI_COOKIE_H_ */
Index: php31/sapi/nsapi_sapi.c
diff -c php31/sapi/nsapi_sapi.c:2.0 php31/sapi/nsapi_sapi.c:2.1
*** php31/sapi/nsapi_sapi.c:2.0 Fri Jul 3 09:19:24 1998
--- php31/sapi/nsapi_sapi.c Thu Aug 20 19:06:43 1998
***************
*** 47,62 ****
#include "ext/standard/base64.h"
#include "ext/standard/php3_string.h"
! /*netscape headers*/
#include "base/pblock.h"
#include "base/session.h"
#include "frame/req.h"
! #include "base/util.h" /* is_mozilla, getline */
! #include "frame/protocol.h" /* protocol_start_response */
#include "frame/http.h"
! #include "base/file.h" /* system_fopenRO */
! #include "base/buffer.h" /* filebuf */
! #include "frame/log.h" /* log_error */
#include "base/crit.h"
#include "base/daemon.h"
#define NET_SSL "visible"
--- 47,62 ----
#include "ext/standard/base64.h"
#include "ext/standard/php3_string.h"
! /*netscape headers */
#include "base/pblock.h"
#include "base/session.h"
#include "frame/req.h"
! #include "base/util.h" /* is_mozilla, getline */
! #include "frame/protocol.h" /* protocol_start_response */
#include "frame/http.h"
! #include "base/file.h" /* system_fopenRO */
! #include "base/buffer.h" /* filebuf */
! #include "frame/log.h" /* log_error */
#include "base/crit.h"
#include "base/daemon.h"
#define NET_SSL "visible"
***************
*** 66,86 ****
#ifndef XP_WIN32
! #include <unistd.h> /* sleep */
#define DLLEXPORT
! #else /* XP_WIN32 */
#define WIN32_LEAN_AND_MEAN
#define EXPORT __declspec(dllexport)
#include <windows.h>
#include <stdio.h>
! #endif /* XP_WIN32 */
! struct ns_request_info{
pblock *pb;
Session *sn;
Request *rq;
! pblock *cookie_recv;
};
#define SAPI_FUNC_VARS \
--- 66,86 ----
#ifndef XP_WIN32
! #include <unistd.h> /* sleep */
#define DLLEXPORT
! #else /* XP_WIN32 */
#define WIN32_LEAN_AND_MEAN
#define EXPORT __declspec(dllexport)
#include <windows.h>
#include <stdio.h>
! #endif /* XP_WIN32 */
! struct ns_request_info {
pblock *pb;
Session *sn;
Request *rq;
! pblock *cookie_recv;
};
#define SAPI_FUNC_VARS \
***************
*** 91,218 ****
Session *sn=(Session *)ns_rqst->sn; \
Request *rq=(Request *)ns_rqst->rq
! php3_module_entry *module_info=NULL;
/* these are the environment structures we need to know where to find
any particular environment variable
! 0=no idea where it is
! 1=pblock_findval(var,rq->vars);
! 2=pblock_findval(var,rq->srvhdrs);
! 3=pblock_findval(var,rq->headers);
! 4=pblock_findval(var,rq->reqpb);
! 5=pblock_findval(var,sn->client);
! */
! struct _nsapi_env{
int type;
char *name1;
char *name2;
};
! struct _nsapi_env nsapi_env[]={
! {1,"AUTH_TYPE","auth-type"},
! {1,"AUTH_USER","auth-user"},
! {1,"AUTH_GROUP","auth-group"},
! {3,"CONTENT_LENGTH","content-length"},
! {2,"CONTENT_TYPE","content-type"},
! {1,"PATH_INFO","path-info"},
! {1,"PATH_TRANSLATED","path"},
! {4,"QUERY_STRING","query"},
! {4,"REQUEST_METHOD","method"},
! {5,"REMOTE_ADDR","ip"},
! {9,"REMOTE_HOST",""},
! {1,"REMOTE_USER","auth-user"},
!
! {1,"SCRIPT_NAME","script-name"},// ? does it work
!
! {8,"SERVER_NAME",""},
! {8,"SERVER_HOSTNAME",""},
! {7,"SERVER_PORT",""},
! {10,"SERVER_PORT_SECURE",""}, //well make this match HTTPS
! {4,"SERVER_PROTOCOL","protocol"},
! {6,"SERVER_SOFTWARE",""},
! {3,"HTTP_ACCEPT","accept"},
!
! {3,"HTTP_ACCEPT_ENCODING","accept-encoding"},// ? does it work
! {3,"HTTP_ACCEPT_LANGUAGE","accept-language"},// ? does it work
!
! {3,"HTTP_CONNECTION","connection"},
! {3,"HTTP_HOST","host"},
! {3,"HTTP_USER_AGENT","user-agent"},
!
! {3,"HTTP_REFERER","referer"},// ? does it work
!
! {10,"HTTPS",""},
! {5,"HTTPS_KEYSIZE","keysize"},
! {5,"HTTPS_SECRETKEYSIZE","secret-keysize"},
! {4,"URL","uri"},
! {-1,NULL,NULL}
};
! char *_php3_nsapi_env_get(struct ns_request_info *ns_rqst, char *var){
! pblock *pb=(pblock *)ns_rqst->pb;
! Session *sn=(Session *)ns_rqst->sn;
! Request *rq=(Request *)ns_rqst->rq;
! int i=0;
/* we need to go through the table above, and see if we can get
what is being looked for from netscape, otherwise, try the regular
environment
! */
! while(nsapi_env[i].type!=-1){
! if(!stricmp(var,nsapi_env[i].name1)){
/* ok, we found a match, now lets get it */
! switch(nsapi_env[i].type){
! case 1:
! return pblock_findval(nsapi_env[i].name2,rq->vars);
! break;
! case 2:
! return pblock_findval(nsapi_env[i].name2,rq->srvhdrs);
! break;
! case 3:
! return pblock_findval(nsapi_env[i].name2,rq->headers);
! break;
! case 4:
! return pblock_findval(nsapi_env[i].name2,rq->reqpb);
! break;
! case 5:
! return pblock_findval(nsapi_env[i].name2,sn->client);
! break;
! case 6:
#if defined(MAGNUS_VERSION_STRING)
! return MAGNUS_VERSION_STRING;
#else
! /* FIXME, nsapi 3.0 headers dont define the above */
! return "PHP NSAPI MODULE";
#endif
! break;
! case 7: // handle server_port port is a macro
//FIXME this is BAD BAD BAD
! {
! char *envport=malloc(6);
! #if 1 /* version 3 nsapi, how can we tell? */
! sprintf(envport,"%d",server_portnum);
! #else /* version 2 nsapi */
! sprintf(envport,"%d",port);
#endif
! return envport;
! }
! break;
! case 8: //handle server host name server_hostname is a macro
! return server_hostname;
! break;
! case 9: //handle reverse dns for client host
! return session_dns(sn);
! break;
! case 10:
! if (security_active)
! return "on";
! else
! return "off";
! break;
! default:
! return getenv(var);
! break;
}
}
i++;
--- 91,222 ----
Session *sn=(Session *)ns_rqst->sn; \
Request *rq=(Request *)ns_rqst->rq
! php3_module_entry *module_info = NULL;
/* these are the environment structures we need to know where to find
any particular environment variable
! 0=no idea where it is
! 1=pblock_findval(var,rq->vars);
! 2=pblock_findval(var,rq->srvhdrs);
! 3=pblock_findval(var,rq->headers);
! 4=pblock_findval(var,rq->reqpb);
! 5=pblock_findval(var,sn->client);
! */
! struct _nsapi_env {
int type;
char *name1;
char *name2;
};
! struct _nsapi_env nsapi_env[] =
! {
! {1, "AUTH_TYPE", "auth-type"},
! {1, "AUTH_USER", "auth-user"},
! {1, "AUTH_GROUP", "auth-group"},
! {3, "CONTENT_LENGTH", "content-length"},
! {2, "CONTENT_TYPE", "content-type"},
! {1, "PATH_INFO", "path-info"},
! {1, "PATH_TRANSLATED", "path"},
! {4, "QUERY_STRING", "query"},
! {4, "REQUEST_METHOD", "method"},
! {5, "REMOTE_ADDR", "ip"},
! {9, "REMOTE_HOST", ""},
! {1, "REMOTE_USER", "auth-user"},
!
! {1, "SCRIPT_NAME", "script-name"}, // ? does it work
!
! {8, "SERVER_NAME", ""},
! {8, "SERVER_HOSTNAME", ""},
! {7, "SERVER_PORT", ""},
! {10, "SERVER_PORT_SECURE", ""}, //well make this match HTTPS
! {4, "SERVER_PROTOCOL", "protocol"},
! {6, "SERVER_SOFTWARE", ""},
! {3, "HTTP_ACCEPT", "accept"},
!
! {3, "HTTP_ACCEPT_ENCODING", "accept-encoding"}, // ? does it work
! {3, "HTTP_ACCEPT_LANGUAGE", "accept-language"}, // ? does it work
!
! {3, "HTTP_CONNECTION", "connection"},
! {3, "HTTP_HOST", "host"},
! {3, "HTTP_USER_AGENT", "user-agent"},
!
! {3, "HTTP_REFERER", "referer"}, // ? does it work
!
! {10, "HTTPS", ""},
! {5, "HTTPS_KEYSIZE", "keysize"},
! {5, "HTTPS_SECRETKEYSIZE", "secret-keysize"},
! {4, "URL", "uri"},
! {-1, NULL, NULL}
};
! char *_php3_nsapi_env_get(struct ns_request_info *ns_rqst, char *var)
! {
! pblock *pb = (pblock *) ns_rqst->pb;
! Session *sn = (Session *) ns_rqst->sn;
! Request *rq = (Request *) ns_rqst->rq;
! int i = 0;
/* we need to go through the table above, and see if we can get
what is being looked for from netscape, otherwise, try the regular
environment
! */
! while (nsapi_env[i].type != -1) {
! if (!stricmp(var, nsapi_env[i].name1)) {
/* ok, we found a match, now lets get it */
! switch (nsapi_env[i].type) {
! case 1:
! return pblock_findval(nsapi_env[i].name2, rq->vars);
! break;
! case 2:
! return pblock_findval(nsapi_env[i].name2, rq->srvhdrs);
! break;
! case 3:
! return pblock_findval(nsapi_env[i].name2, rq->headers);
! break;
! case 4:
! return pblock_findval(nsapi_env[i].name2, rq->reqpb);
! break;
! case 5:
! return pblock_findval(nsapi_env[i].name2, sn->client);
! break;
! case 6:
#if defined(MAGNUS_VERSION_STRING)
! return MAGNUS_VERSION_STRING;
#else
! /* FIXME, nsapi 3.0 headers dont define the above */
! return "PHP NSAPI MODULE";
#endif
! break;
! case 7: // handle server_port port is a macro
//FIXME this is BAD BAD BAD
! {
! char *envport = malloc(6);
! #if 1 /* version 3 nsapi, how can we tell? */
! sprintf(envport, "%d", server_portnum);
! #else /* version 2 nsapi */
! sprintf(envport, "%d", port);
#endif
! return envport;
! }
! break;
! case 8: //handle server host name server_hostname is a macro
!
! return server_hostname;
! break;
! case 9: //handle reverse dns for client host
!
! return session_dns(sn);
! break;
! case 10:
! if (security_active)
! return "on";
! else
! return "off";
! break;
! default:
! return getenv(var);
! break;
}
}
i++;
***************
*** 223,231 ****
}
! char *sapi_getenv(SAPI_GLOBAL_INCLUDE char *var){
SAPI_FUNC_VARS;
! return _php3_nsapi_env_get(ns_rqst,var);
}
/*********************************************************
--- 227,236 ----
}
! char *sapi_getenv(SAPI_GLOBAL_INCLUDE char *var)
! {
SAPI_FUNC_VARS;
! return _php3_nsapi_env_get(ns_rqst, var);
}
/*********************************************************
***************
*** 237,304 ****
/* ok, we can get cookies with this, but how do we get them into
php variables? This will most likely have to be transformed into
some other function that php calls to parse the headers.
! */
! pblock *_php3_nsapi_get_cookie_pblock(Request *rq)
{
! char *cookie = pblock_findval("cookie", rq->headers);
! char *name, *value;
! char *ptr;
! pblock *cookie_pblock;
! int fInValue = 0;
! int done = 0;
!
! if (!cookie)
! return NULL;
!
! cookie_pblock = pblock_create(5);
!
! ptr = cookie;
! while(*ptr && isspace(*ptr))
! ptr++;
! name = ptr;
! while(!done) {
! switch(*ptr) {
! case '=':
! if (!fInValue) {
! *ptr = '\0';
! ptr++;
! while(*ptr && isspace(*ptr))
! ptr++;
! value = ptr;
! fInValue = 1;
! }
! break;
! case '\0':
! case ';':
! if (fInValue) {
! if (*ptr) {
! *ptr = '\0';
! ptr++;
! while(*ptr && isspace(*ptr))
! ptr++;
! if (!ptr) /* don't go past edge */
! ptr--;
! } else
! done = 1;
! pblock_nvinsert(name, value, cookie_pblock);
! name = ptr;
! fInValue = 0;
! }
! break;
! }
! ptr++;
! }
! return cookie_pblock;
}
/* adds a cookie to outgoing headers. We can add this to the below
sapi_insert_header later, this is just to illustrate */
! void _php3_nsapi_set_cookie(struct ns_request_info *ns_rqst, char *cookie){
! Request *rq=(Request *)ns_rqst->rq;
! pblock_nvinsert("Set-cookie", cookie, rq->srvhdrs);
}
/*********************************************************
--- 242,310 ----
/* ok, we can get cookies with this, but how do we get them into
php variables? This will most likely have to be transformed into
some other function that php calls to parse the headers.
! */
! pblock *_php3_nsapi_get_cookie_pblock(Request * rq)
{
! char *cookie = pblock_findval("cookie", rq->headers);
! char *name, *value;
! char *ptr;
! pblock *cookie_pblock;
! int fInValue = 0;
! int done = 0;
!
! if (!cookie)
! return NULL;
!
! cookie_pblock = pblock_create(5);
!
! ptr = cookie;
! while (*ptr && isspace(*ptr))
! ptr++;
! name = ptr;
! while (!done) {
! switch (*ptr) {
! case '=':
! if (!fInValue) {
! *ptr = '\0';
! ptr++;
! while (*ptr && isspace(*ptr))
! ptr++;
! value = ptr;
! fInValue = 1;
! }
! break;
! case '\0':
! case ';':
! if (fInValue) {
! if (*ptr) {
! *ptr = '\0';
! ptr++;
! while (*ptr && isspace(*ptr))
! ptr++;
! if (!ptr) /* don't go past edge */
! ptr--;
! } else
! done = 1;
! pblock_nvinsert(name, value, cookie_pblock);
! name = ptr;
! fInValue = 0;
! }
! break;
! }
! ptr++;
! }
! return cookie_pblock;
}
/* adds a cookie to outgoing headers. We can add this to the below
sapi_insert_header later, this is just to illustrate */
! void _php3_nsapi_set_cookie(struct ns_request_info *ns_rqst, char *cookie)
! {
! Request *rq = (Request *) ns_rqst->rq;
! pblock_nvinsert("Set-cookie", cookie, rq->srvhdrs);
}
/*********************************************************
***************
*** 308,335 ****
/ stack, and send all headers at once in send_header.
/*********************************************************/
! /*FIXME need to make nsapi correctly handle redirects and status strings*/
! int sapi_insert_header(SAPI_GLOBAL_INCLUDE char *header){
! char *tempstr=NULL;
SAPI_FUNC_VARS;
! /*inserts header into a list of headers*/
/* header is in form of "headername: info"
need to split into two strings and handle from there
! */
! if(!rq->senthdrs){ /*just verify headers not already sent*/
! pblock_remove("content-type",rq->srvhdrs);
! pblock_nvinsert("content-type","text/html",rq->srvhdrs);
}
return SUCCESS;
}
! int sapi_send_header(SAPI_GLOBAL_INCLUDE_V){
SAPI_FUNC_VARS;
/* this is sending ok on every call. need to figure out how
we can handle other status codes */
! if(!rq->senthdrs){ /*just verify headers not already sent*/
! protocol_status(sn,rq,PROTOCOL_OK,NULL);
! if (protocol_start_response(sn,rq)==REQ_NOACTION)
return REQ_PROCEED;
}
return SUCCESS;
--- 314,343 ----
/ stack, and send all headers at once in send_header.
/*********************************************************/
! /*FIXME need to make nsapi correctly handle redirects and status strings */
! int sapi_insert_header(SAPI_GLOBAL_INCLUDE char *header)
! {
! char *tempstr = NULL;
SAPI_FUNC_VARS;
! /*inserts header into a list of headers */
/* header is in form of "headername: info"
need to split into two strings and handle from there
! */
! if (!rq->senthdrs) { /*just verify headers not already sent */
! pblock_remove("content-type", rq->srvhdrs);
! pblock_nvinsert("content-type", "text/html", rq->srvhdrs);
}
return SUCCESS;
}
! int sapi_send_header(SAPI_GLOBAL_INCLUDE_V)
! {
SAPI_FUNC_VARS;
/* this is sending ok on every call. need to figure out how
we can handle other status codes */
! if (!rq->senthdrs) { /*just verify headers not already sent */
! protocol_status(sn, rq, PROTOCOL_OK, NULL);
! if (protocol_start_response(sn, rq) == REQ_NOACTION)
return REQ_PROCEED;
}
return SUCCESS;
***************
*** 367,421 ****
/ <Object ppath="path/to/be/authenticated/by/php/*">
/ AuthTrans fn="php3_nsapi_auth_trans"
/*********************************************************/
! int php3_nsapi_has_auth(char *string, Request *rq){
! char *authheader=pblock_findval("authorization",rq->headers);
! *string='\0';
! if(authheader)
! strcpy(string,authheader);
return strlen(authheader);
}
! int php3_nsapi_isvalid_auth(char *authstring){
! if(strncmp("Basic ",authstring,6))return 0;
return 1;
}
! int EXPORT php3_nsapi_auth_trans(pblock *pb, Session *sn, Request *rq){
char AuthString[MAX_PATH];
! return (php3_nsapi_has_auth(AuthString,rq)&&
! php3_nsapi_isvalid_auth(AuthString))
? REQ_PROCEED : REQ_ABORTED;
}
! void sapi_treat_headers(SAPI_GLOBAL_INCLUDE_V){
char *s = NULL;
char *t;
! char *user, *type="Basic ";
int len;
char *escaped_str;
SAPI_FUNC_VARS;
if (rq->headers)
! s = pblock_findval("Authorization",rq->headers);
if (!s)
return;
/* Check to make sure that this URL isn't authenticated
using a traditional auth module mechanism
Not yet sure how to do this with NSAPI
! if (auth_type(rq)) {
! return;
! }
! */
! if (strncmp(type,s,6)) {
/* Client tried to authenticate using wrong auth scheme */
php3_error(E_WARNING, "client used wrong authentication scheme");
return;
}
t = _php3_base64_decode(s, strlen(s), &len);
! /* FIXME
! user = getword_nulls_nc(php3_rqst->pool, &t, ':');
! */
if (user) {
if (GLOBAL(php3_ini)->magic_quotes_gpc) {
escaped_str = _php3_addslashes(user, 0, &len, 0);
--- 375,434 ----
/ <Object ppath="path/to/be/authenticated/by/php/*">
/ AuthTrans fn="php3_nsapi_auth_trans"
/*********************************************************/
! int php3_nsapi_has_auth(char *string, Request * rq)
! {
! char *authheader = pblock_findval("authorization", rq->headers);
! *string = '\0';
! if (authheader)
! strcpy(string, authheader);
return strlen(authheader);
}
! int php3_nsapi_isvalid_auth(char *authstring)
! {
! if (strncmp("Basic ", authstring, 6))
! return 0;
return 1;
}
! int EXPORT php3_nsapi_auth_trans(pblock * pb, Session * sn, Request * rq)
! {
char AuthString[MAX_PATH];
! return (php3_nsapi_has_auth(AuthString, rq) &&
! php3_nsapi_isvalid_auth(AuthString))
? REQ_PROCEED : REQ_ABORTED;
}
! void sapi_treat_headers(SAPI_GLOBAL_INCLUDE_V)
! {
char *s = NULL;
char *t;
! char *user, *type = "Basic ";
int len;
char *escaped_str;
SAPI_FUNC_VARS;
if (rq->headers)
! s = pblock_findval("Authorization", rq->headers);
if (!s)
return;
/* Check to make sure that this URL isn't authenticated
using a traditional auth module mechanism
Not yet sure how to do this with NSAPI
! if (auth_type(rq)) {
! return;
! }
! */
! if (strncmp(type, s, 6)) {
/* Client tried to authenticate using wrong auth scheme */
php3_error(E_WARNING, "client used wrong authentication scheme");
return;
}
t = _php3_base64_decode(s, strlen(s), &len);
! /* FIXME
! user = getword_nulls_nc(php3_rqst->pool, &t, ':');
! */
if (user) {
if (GLOBAL(php3_ini)->magic_quotes_gpc) {
escaped_str = _php3_addslashes(user, 0, &len, 0);
***************
*** 445,483 ****
/*********************************************************
/ input / output functions
/*********************************************************/
! int sapi_readclient(SAPI_GLOBAL_INCLUDE char *buf, int len){
SAPI_FUNC_VARS;
! return net_read (sn->csd, buf, len, 10);
}
! int sapi_puts(SAPI_GLOBAL_INCLUDE char *string){
SAPI_FUNC_VARS;
return net_write(sn->csd, string, strlen(string));
}
! int sapi_putc(SAPI_GLOBAL_INCLUDE char c){
SAPI_FUNC_VARS;
return net_write(sn->csd, &c, 1);
}
! int sapi_writeclient(SAPI_GLOBAL_INCLUDE char *string, int len){
SAPI_FUNC_VARS;
return net_write(sn->csd, string, len);
}
! int sapi_flush(SAPI_GLOBAL_INCLUDE_V){ /* as in flush() */
return SUCCESS;
}
! void sapi_log(SAPI_GLOBAL_INCLUDE char *message){
}
#define ENTRY_NAME_COLOR "#999999"
#define CONTENTS_COLOR "#DDDDDD"
#define HEADER_COLOR "#00DDDD"
! void sapi_print_info(SAPI_GLOBAL_INCLUDE_V){
! int i=0;
char *temp;
SAPI_FUNC_VARS;
--- 458,503 ----
/*********************************************************
/ input / output functions
/*********************************************************/
! int sapi_readclient(SAPI_GLOBAL_INCLUDE char *buf, int len)
! {
SAPI_FUNC_VARS;
! return net_read(sn->csd, buf, len, 10);
}
! int sapi_puts(SAPI_GLOBAL_INCLUDE char *string)
! {
SAPI_FUNC_VARS;
return net_write(sn->csd, string, strlen(string));
}
! int sapi_putc(SAPI_GLOBAL_INCLUDE char c)
! {
SAPI_FUNC_VARS;
return net_write(sn->csd, &c, 1);
}
! int sapi_writeclient(SAPI_GLOBAL_INCLUDE char *string, int len)
! {
SAPI_FUNC_VARS;
return net_write(sn->csd, string, len);
}
! int sapi_flush(SAPI_GLOBAL_INCLUDE_V)
! { /* as in flush() */
return SUCCESS;
}
! void sapi_log(SAPI_GLOBAL_INCLUDE char *message)
! {
}
#define ENTRY_NAME_COLOR "#999999"
#define CONTENTS_COLOR "#DDDDDD"
#define HEADER_COLOR "#00DDDD"
! void sapi_print_info(SAPI_GLOBAL_INCLUDE_V)
! {
! int i = 0;
char *temp;
SAPI_FUNC_VARS;
***************
*** 486,493 ****
sapi_puts(SAPI_GLOBAL_PASS "<tr><th bgcolor=\"" HEADER_COLOR
"\">Variable</th><th bgcolor=\"" HEADER_COLOR
"\">Value</th></tr>\n");
/* print out the server environment table here */
! while(nsapi_env[i].type!=-1){
! temp=_php3_nsapi_env_get(ns_rqst,nsapi_env[i].name1);
sapi_puts(SAPI_GLOBAL_PASS "<tr><td bgcolor=\"" ENTRY_NAME_COLOR
"\">");
sapi_puts(SAPI_GLOBAL_PASS nsapi_env[i].name1);
sapi_puts(SAPI_GLOBAL_PASS "</td><td bgcolor=\"" CONTENTS_COLOR
"\">");
--- 506,513 ----
sapi_puts(SAPI_GLOBAL_PASS "<tr><th bgcolor=\"" HEADER_COLOR
"\">Variable</th><th bgcolor=\"" HEADER_COLOR
"\">Value</th></tr>\n");
/* print out the server environment table here */
! while (nsapi_env[i].type != -1) {
! temp = _php3_nsapi_env_get(ns_rqst, nsapi_env[i].name1);
sapi_puts(SAPI_GLOBAL_PASS "<tr><td bgcolor=\"" ENTRY_NAME_COLOR
"\">");
sapi_puts(SAPI_GLOBAL_PASS nsapi_env[i].name1);
sapi_puts(SAPI_GLOBAL_PASS "</td><td bgcolor=\"" CONTENTS_COLOR
"\">");
***************
*** 503,528 ****
/*********************************************************
/ signal blocking
/*********************************************************/
! void sapi_block(SAPI_GLOBAL_INCLUDE_V){ /*signal blocking*/
}
! void sapi_unblock(SAPI_GLOBAL_INCLUDE_V){ /*signal blocking*/
}
/*********************************************************
/ misc leftovers from apache stuff
/*********************************************************/
! void sapi_reqister_cleanup(SAPI_GLOBAL_INCLUDE void *arg1, void *arg2, void *arg3){
}
! void sapi_request_shutdown(SAPI_GLOBAL_INCLUDE_V){
}
! int sapi_aborted(SAPI_GLOBAL_INCLUDE_V){
return 0;
}
/******************************************************************************
/* code from main.c in _php3_hash_environment()
/*****************************************************************************/
! void sapi__php3_hash_server_env(SAPI_GLOBAL_INCLUDE_V){
SAPI_FUNC_VARS;
pval tmp;
--- 523,554 ----
/*********************************************************
/ signal blocking
/*********************************************************/
! void sapi_block(SAPI_GLOBAL_INCLUDE_V)
! { /*signal blocking */
}
! void sapi_unblock(SAPI_GLOBAL_INCLUDE_V)
! { /*signal blocking */
}
/*********************************************************
/ misc leftovers from apache stuff
/*********************************************************/
! void sapi_reqister_cleanup(SAPI_GLOBAL_INCLUDE void *arg1, void *arg2, void *arg3)
! {
}
! void sapi_request_shutdown(SAPI_GLOBAL_INCLUDE_V)
! {
}
! int sapi_aborted(SAPI_GLOBAL_INCLUDE_V)
! {
return 0;
}
/******************************************************************************
/* code from main.c in _php3_hash_environment()
/*****************************************************************************/
! void sapi__php3_hash_server_env(SAPI_GLOBAL_INCLUDE_V)
! {
SAPI_FUNC_VARS;
pval tmp;
***************
*** 541,547 ****
pi = NULL;
}
tmp.value.str.val = emalloc(l + 1);
! tmp.value.str.len = _php3_sprintf(tmp.value.str.val, "%s%s", (phpsn ? phpsn :
""), (pi ? pi : "")); /* SAFE */
tmp.type = IS_STRING;
_php3_hash_update(&php3_globals->symbol_table, "PHP_SELF",
sizeof("PHP_SELF"), (void *) & tmp, sizeof(pval), NULL);
}
--- 567,573 ----
pi = NULL;
}
tmp.value.str.val = emalloc(l + 1);
! tmp.value.str.len = _php3_sprintf(tmp.value.str.val, "%s%s", (phpsn ? phpsn :
""), (pi ? pi : "")); /* SAFE */
tmp.type = IS_STRING;
_php3_hash_update(&php3_globals->symbol_table, "PHP_SELF",
sizeof("PHP_SELF"), (void *) & tmp, sizeof(pval), NULL);
}
***************
*** 550,620 ****
/******************************************************************************
/* crash detection logging
/*****************************************************************************/
! void sapi_debug_log(SAPI_GLOBAL_INCLUDE 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
! void sapi_init(struct ns_request_info *ns_rqst,struct sapi_request_info *sapi_info)
{
! pblock *pb=(pblock *)ns_rqst->pb;
! Session *sn=(Session *)ns_rqst->sn;
! Request *rq=(Request *)ns_rqst->rq;
/* for cgi we dont use request id's */
! sapi_info->scid=ns_rqst;
! sapi_info->path_info = pblock_findval("path-info",rq->vars);
! sapi_info->path_translated = pblock_findval("path",rq->vars);
sapi_info->filename = estrdup(sapi_info->path_translated);
! sapi_info->query_string = pblock_findval("query", rq->vars);
! sapi_info->request_method = pblock_findval("method",rq->reqpb);
! sapi_info->script_name = pblock_findval("path",rq->vars);
! sapi_info->content_length = atoi(pblock_findval("content-length",rq->headers));
! sapi_info->content_type = pblock_findval("content-type",rq->srvhdrs);
!
! sapi_info->puts=sapi_puts;
! sapi_info->sputc=sapi_putc;
! sapi_info->getenv=sapi_getenv;
! sapi_info->writeclient=sapi_writeclient;
! sapi_info->flush=sapi_flush;
! sapi_info->readclient=sapi_readclient;
! sapi_info->blockalarms=sapi_block;
! sapi_info->unblockalarms=sapi_unblock;
! sapi_info->log=sapi_log;
! sapi_info->info=sapi_print_info;
sapi_info->aborted = sapi_aborted;
! sapi_info->insert_header=sapi_insert_header;
! sapi_info->treat_headers=sapi_treat_headers;
! sapi_info->send_header=sapi_send_header;
! sapi_info->headers=NULL;
!
! sapi_info->_php3_hash_server_env=sapi__php3_hash_server_env;
! sapi_info->register_clean=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;
! sapi_info->preprocess=0;
! sapi_info->info_only=0;
! sapi_info->quiet_mode=0;
!
! /*page stat info*/
! sapi_info->page_uid=0;
! sapi_info->page_inode=0;
! sapi_info->page_mtime=0;
}
--- 576,648 ----
/******************************************************************************
/* crash detection logging
/*****************************************************************************/
! void sapi_debug_log(SAPI_GLOBAL_INCLUDE 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
! void sapi_init(struct ns_request_info *ns_rqst, struct sapi_request_info *sapi_info)
{
! pblock *pb = (pblock *) ns_rqst->pb;
! Session *sn = (Session *) ns_rqst->sn;
! Request *rq = (Request *) ns_rqst->rq;
/* for cgi we dont use request id's */
! sapi_info->scid = ns_rqst;
! sapi_info->path_info = pblock_findval("path-info", rq->vars);
! sapi_info->path_translated = pblock_findval("path", rq->vars);
sapi_info->filename = estrdup(sapi_info->path_translated);
! sapi_info->query_string = pblock_findval("query", rq->vars);
! sapi_info->request_method = pblock_findval("method", rq->reqpb);
! sapi_info->script_name = pblock_findval("path", rq->vars);
! sapi_info->content_length = atoi(pblock_findval("content-length", rq->headers));
! sapi_info->content_type = pblock_findval("content-type", rq->srvhdrs);
!
! sapi_info->puts = sapi_puts;
! sapi_info->sputc = sapi_putc;
! sapi_info->getenv = sapi_getenv;
! sapi_info->writeclient = sapi_writeclient;
! sapi_info->flush = sapi_flush;
! sapi_info->readclient = sapi_readclient;
! sapi_info->blockalarms = sapi_block;
! sapi_info->unblockalarms = sapi_unblock;
! sapi_info->log = sapi_log;
! sapi_info->info = sapi_print_info;
sapi_info->aborted = sapi_aborted;
! sapi_info->insert_header = sapi_insert_header;
! sapi_info->treat_headers = sapi_treat_headers;
! sapi_info->send_header = sapi_send_header;
! sapi_info->headers = NULL;
!
! sapi_info->_php3_hash_server_env = sapi__php3_hash_server_env;
! sapi_info->register_clean = 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;
! sapi_info->preprocess = 0;
! sapi_info->info_only = 0;
! sapi_info->quiet_mode = 0;
!
! /*page stat info */
! sapi_info->page_uid = 0;
! sapi_info->page_inode = 0;
! sapi_info->page_mtime = 0;
}
***************
*** 625,631 ****
//_php3_sapi_process_end();
}
! int init_nsapi_mod(pblock *pb, Session *sn, Request *rq)
{
//global initialization for all php threads
//do we use dllmain or this? What about thread start/end?
--- 653,659 ----
//_php3_sapi_process_end();
}
! int init_nsapi_mod(pblock * pb, Session * sn, Request * rq)
{
//global initialization for all php threads
//do we use dllmain or this? What about thread start/end?
***************
*** 634,661 ****
return REQ_PROCEED;
}
! int nsapi_php_main(pblock *pb, Session *sn, Request *rq)
{
! struct ns_request_info *ns_rqst=malloc(sizeof(struct ns_request_info));
! struct sapi_request_info *sapi_info=malloc(sizeof(struct sapi_request_info));
!
! ns_rqst->pb=pb;
! ns_rqst->sn=sn;
! ns_rqst->rq=rq;
! ns_rqst->cookie_recv=_php3_nsapi_get_cookie_pblock(rq);//get cookies up front
// we can now get cookies like this:
// char *cookiename=pblock_findval("cookiename", cookie_recv);
! sapi_init(ns_rqst,sapi_info);
! if (!php3_sapi_main(sapi_info,module_info)){
free(sapi_info);
free(ns_rqst);
! return REQ_ABORTED; /*FAILURE*/
}
free(sapi_info);
free(ns_rqst);
! return REQ_PROCEED; /*SUCCESS*/
}
--- 662,689 ----
return REQ_PROCEED;
}
! int nsapi_php_main(pblock * pb, Session * sn, Request * rq)
{
! struct ns_request_info *ns_rqst = malloc(sizeof(struct ns_request_info));
! struct sapi_request_info *sapi_info = malloc(sizeof(struct sapi_request_info));
!
! ns_rqst->pb = pb;
! ns_rqst->sn = sn;
! ns_rqst->rq = rq;
! ns_rqst->cookie_recv = _php3_nsapi_get_cookie_pblock(rq); //get cookies up front
// we can now get cookies like this:
// char *cookiename=pblock_findval("cookiename", cookie_recv);
! sapi_init(ns_rqst, sapi_info);
! if (!php3_sapi_main(sapi_info, module_info)) {
free(sapi_info);
free(ns_rqst);
! return REQ_ABORTED; /*FAILURE */
}
free(sapi_info);
free(ns_rqst);
! return REQ_PROCEED; /*SUCCESS */
}
Index: php31/sapi/old_cgimain.c
diff -c php31/sapi/old_cgimain.c:2.0 php31/sapi/old_cgimain.c:2.1
*** php31/sapi/old_cgimain.c:2.0 Fri Jul 3 09:19:24 1998
--- php31/sapi/old_cgimain.c Thu Aug 20 19:06:43 1998
***************
*** 42,51 ****
char *s;
int display_source_mode = 0;
/* temporary locals */
! char *_cgi_filename=NULL;
! int _cgi_preprocess=PREPROCESS_NONE;
! int _cgi_display_source_mode=0;
! int _cgi_started=0;
/* end of temporary locals */
#ifdef THREAD_SAFE
php3_globals_struct *php3_globals;
--- 42,51 ----
char *s;
int display_source_mode = 0;
/* temporary locals */
! char *_cgi_filename = NULL;
! int _cgi_preprocess = PREPROCESS_NONE;
! int _cgi_display_source_mode = 0;
! int _cgi_started = 0;
/* end of temporary locals */
#ifdef THREAD_SAFE
php3_globals_struct *php3_globals;
***************
*** 64,70 ****
#endif
#if WIN32|WINNT
_fmode = _O_BINARY; /*sets default for file streams to binary */
! setmode(_fileno(stdin), O_BINARY); /* make the stdio mode be binary */
setmode(_fileno(stdout), O_BINARY); /* make the stdio mode be binary */
setmode(_fileno(stderr), O_BINARY); /* make the stdio mode be binary */
#endif
--- 64,70 ----
#endif
#if WIN32|WINNT
_fmode = _O_BINARY; /*sets default for file streams to binary */
! setmode(_fileno(stdin), O_BINARY); /* make the stdio mode be binary */
setmode(_fileno(stdout), O_BINARY); /* make the stdio mode be binary */
setmode(_fileno(stderr), O_BINARY); /* make the stdio mode be binary */
#endif
***************
*** 78,84 ****
cgi = 1;
if (argc > 1)
GLOBAL(sapi_rqst)->php_argv0 = strdup(argv[1]);
! else GLOBAL(sapi_rqst)->php_argv0 = NULL;
#if FORCE_CGI_REDIRECT
if (!getenv("REDIRECT_STATUS")) {
if (php3_header())
--- 78,85 ----
cgi = 1;
if (argc > 1)
GLOBAL(sapi_rqst)->php_argv0 = strdup(argv[1]);
! else
! GLOBAL(sapi_rqst)->php_argv0 = NULL;
#if FORCE_CGI_REDIRECT
if (!getenv("REDIRECT_STATUS")) {
if (php3_header())
***************
*** 103,122 ****
}
#endif /* FORCE_CGI_REDIRECT */
}
-
-
-
if (!cgi) { /* never execute the arguments if you are a CGI */
GLOBAL(sapi_rqst)->php_argv0 = NULL;
while ((c = getopt(argc, argv, "c:qvishpe?vf:")) != -1) {
switch (c) {
case 'f':
! if (!_cgi_started){
if (php3_module_startup(_INLINE_TLS_VOID) == FAILURE ||
php3_request_startup(_INLINE_TLS_VOID) == FAILURE) {
return FAILURE;
}
}
! _cgi_started=1;
_cgi_filename = estrdup(optarg);
/* break missing intentionally */
case 'q':
--- 104,120 ----
}
#endif /* FORCE_CGI_REDIRECT */
}
if (!cgi) { /* never execute the arguments if you are a CGI */
GLOBAL(sapi_rqst)->php_argv0 = NULL;
while ((c = getopt(argc, argv, "c:qvishpe?vf:")) != -1) {
switch (c) {
case 'f':
! if (!_cgi_started) {
if (php3_module_startup(_INLINE_TLS_VOID) == FAILURE ||
php3_request_startup(_INLINE_TLS_VOID) == FAILURE) {
return FAILURE;
}
}
! _cgi_started = 1;
_cgi_filename = estrdup(optarg);
/* break missing intentionally */
case 'q':
***************
*** 132,138 ****
return FAILURE;
}
}
! _cgi_started=1;
php3_TreatHeaders();
_php3_info();
exit(1);
--- 130,136 ----
return FAILURE;
}
}
! _cgi_started = 1;
php3_TreatHeaders();
_php3_info();
exit(1);
***************
*** 161,167 ****
}
}
} /* not cgi */
-
if (!_cgi_started) {
if (php3_module_startup(_INLINE_TLS_VOID) == FAILURE || php3_request_startup(_INLINE_TLS_VOID)
== FAILURE) {
return FAILURE;
--- 159,164 ----
***************
*** 205,216 ****
if (cgi && !in) {
if (php3_header()) {
PUTS("No input file specified.\n");
! #if 0 /* this is here for debuging under windows */
if (argc) {
i = 0;
! php3_printf("\nargc %d\n",argc);
while (i <= argc) {
! php3_printf("%s\n",argv[i]);
i++;
}
}
--- 202,213 ----
if (cgi && !in) {
if (php3_header()) {
PUTS("No input file specified.\n");
! #if 0 /* this is here for debuging under windows */
if (argc) {
i = 0;
! php3_printf("\nargc %d\n", argc);
while (i <= argc) {
! php3_printf("%s\n", argv[i]);
i++;
}
}
***************
*** 253,264 ****
return 0;
}
if (GLOBAL(php3_preprocess) == PREPROCESS_EXECUTE) {
! if (tcm_load(&GLOBAL(token_cache_manager))==FAILURE) {
return 0;
}
GLOBAL(php3_preprocess) = PREPROCESS_NONE;
}
! if (GLOBAL(php3_preprocess)==PREPROCESS_NONE) {
php3_parse(GLOBAL(phpin));
} else {
pval yylval;
--- 250,261 ----
return 0;
}
if (GLOBAL(php3_preprocess) == PREPROCESS_EXECUTE) {
! if (tcm_load(&GLOBAL(token_cache_manager)) == FAILURE) {
return 0;
}
GLOBAL(php3_preprocess) = PREPROCESS_NONE;
}
! if (GLOBAL(php3_preprocess) == PREPROCESS_NONE) {
php3_parse(GLOBAL(phpin));
} else {
pval yylval;
Index: php31/sapi/php3_apache.h
diff -c php31/sapi/php3_apache.h:2.0 php31/sapi/php3_apache.h:2.1
*** php31/sapi/php3_apache.h:2.0 Fri Jul 3 09:19:24 1998
--- php31/sapi/php3_apache.h Thu Aug 20 19:06:43 1998
***************
*** 1,15 ****
! /* This was pulled from internal_functions_registry.h*/
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include "php.h"
! # 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"
--- 1,15 ----
! /* This was pulled from internal_functions_registry.h */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include "php.h"
! #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"
***************
*** 17,25 ****
#include "http_protocol.h"
#include "http_config.h"
#include "http_log.h"
! # ifndef THREAD_SAFE
request_rec *php3_rqst = NULL; /* request record pointer for apache module version */
! # endif
#include "sapi.h"
#include "internal_functions.h"
--- 17,25 ----
#include "http_protocol.h"
#include "http_config.h"
#include "http_log.h"
! #ifndef THREAD_SAFE
request_rec *php3_rqst = NULL; /* request record pointer for apache module version */
! #endif
#include "sapi.h"
#include "internal_functions.h"
***************
*** 56,62 ****
some changes to allow a search for the first item with a
certain type. This type of search would not be optimal.
Private list management makes more sense here
! */
typedef struct CookieList {
char *cookie;
struct CookieList *next;
--- 56,62 ----
some changes to allow a search for the first item with a
certain type. This type of search would not be optimal.
Private list management makes more sense here
! */
typedef struct CookieList {
char *cookie;
struct CookieList *next;
Index: php31/sapi/sapi.h
diff -c php31/sapi/sapi.h:2.5 php31/sapi/sapi.h:2.6
*** php31/sapi/sapi.h:2.5 Fri Aug 14 13:08:25 1998
--- php31/sapi/sapi.h Thu Aug 20 19:06:43 1998
***************
*** 1,15 ****
/*
! Server API Abstraction Layer
! This set of functions is required to create a new
! api interface for php. These functions map
! functions that would be used in cgi to server
! specific api's
!
! Some functions are specific to php so that the main
! php module may obtain information from the server
! */
#ifndef _PHP3_SAPI_H_
#define _PHP3_SAPI_H_
#include "modules.h"
--- 1,15 ----
/*
! Server API Abstraction Layer
! This set of functions is required to create a new
! api interface for php. These functions map
! functions that would be used in cgi to server
! specific api's
+ Some functions are specific to php so that the main
+ php module may obtain information from the server
+ */
+
#ifndef _PHP3_SAPI_H_
#define _PHP3_SAPI_H_
#include "modules.h"
***************
*** 34,45 ****
#define SAPI_GLOBAL_PASS_V
#endif
! struct sapi_request_info{
/* request variables */
! void *scid; /* request identifier */
! char *rqst_filename; /*we need to estrdup this to filename later*/
char *filename;
! int fileopen; /*set to fd to make php main use fdopen*/
char *path_info;
char *path_translated;
char *query_string;
--- 34,45 ----
#define SAPI_GLOBAL_PASS_V
#endif
! struct sapi_request_info {
/* request variables */
! void *scid; /* request identifier */
! char *rqst_filename; /*we need to estrdup this to filename later */
char *filename;
! int fileopen; /*set to fd to make php main use fdopen */
char *path_info;
char *path_translated;
char *query_string;
***************
*** 50,168 ****
unsigned int content_length;
char *content_type;
unsigned char *cookies;
! int cgi, display_source_mode,preprocess,info_only,quiet_mode;
! char *argv0,*ini_path,*script_filename;
/* page stat vars */
long page_uid;
long page_inode;
long page_mtime;
! /*handling headers*/
! unsigned char *headers; /*pointer to header list*/
! unsigned char *http_status; /* such as 401 Access Denied, needed for isapi*/
! int http_redirect; /*used to signal redirect for isapi*/
int abort;
! int (*insert_header)(SAPI_GLOBAL_INCLUDE unsigned char *); /*insert header into a list*/
! int (*send_header)(SAPI_GLOBAL_INCLUDE_V); /*write headers to client*/
! void (*treat_headers)(SAPI_GLOBAL_INCLUDE_V);
! int (*aborted)(SAPI_GLOBAL_INCLUDE_V); /* returns: same as apaches
php3_rqst->connection->aborted*/
/* io functions */
! int (*readclient)(SAPI_GLOBAL_INCLUDE unsigned char *, int );
! void (*info)(SAPI_GLOBAL_INCLUDE_V);
! int (*puts)(SAPI_GLOBAL_INCLUDE unsigned char *);
! int (*sputc)(SAPI_GLOBAL_INCLUDE unsigned char);
! char *(*getenv)(SAPI_GLOBAL_INCLUDE char *);
! int (*writeclient)(SAPI_GLOBAL_INCLUDE unsigned char *, int);
! int (*flush)(SAPI_GLOBAL_INCLUDE_V); /*flush writes to client*/
! void (*log)(SAPI_GLOBAL_INCLUDE char *); /*use server error log*/
/* signal and thread functions */
! void (*blockalarms)(SAPI_GLOBAL_INCLUDE_V); /*signal blocking*/
! void (*unblockalarms)(SAPI_GLOBAL_INCLUDE_V); /*signal blocking*/
! #if 0 /* XXX FIXME Stig disabled this temporarily
! I get the following error:
! ../sapi/sapi.h:83: parse error before `*'
! ../sapi/sapi.h:83: `sapi_signal' declared as function returning a function
! ../sapi/sapi.h:83: warning: no semicolon at end of struct or union
! ../sapi/sapi.h:83: parse error before `)'
! */
/* dont know if this will actualy be used yet */
! void (*signal)(SAPI_GLOBAL_INCLUDE int sig, void (__cdecl *func) ( int sig , int subcode ));
#endif
/* FIXME these functions need definet work */
! void (*_php3_hash_server_env)(SAPI_GLOBAL_INCLUDE_V);
/* so far, apache specific */
! void (*register_clean)(SAPI_GLOBAL_INCLUDE void *, void *, void *);
/* so far, fhttpd specific */
! void (*request_shutdown)(SAPI_GLOBAL_INCLUDE_V);
/* output debug information somewhere */
#if defined(CRASH_DETECTION)
! void (*debug_log)(SAPI_GLOBAL_INCLUDE char *log_message);
#endif
};
#ifndef THREAD_SAFE
! extern struct sapi_request_info *sapi_rqst;
#endif
#if defined(COMPILE_DL)
! # define PUTS(a) php3_printf("%s",a)
! # define PUTC(a) PUTS(a)
! # define PHPWRITE(a,n) php3_write((a),(n))
#else
! # define PUTS(a) GLOBAL(sapi_rqst)->puts(SAPI_GLOBAL_PASS a)
! # define PUTC(a) GLOBAL(sapi_rqst)->sputc(SAPI_GLOBAL_PASS a)
! # define PHPWRITE(a,n) GLOBAL(sapi_rqst)->writeclient(SAPI_GLOBAL_PASS (a),(n))
! # define BLOCK_INTERRUPTIONS
if(GLOBAL(sapi_rqst))GLOBAL(sapi_rqst)->blockalarms(SAPI_GLOBAL_PASS_V)
! # define UNBLOCK_INTERRUPTIONS
if(GLOBAL(sapi_rqst))GLOBAL(sapi_rqst)->unblockalarms(SAPI_GLOBAL_PASS_V)
#endif
! /*emulates puts*/
extern int sapi_puts(SAPI_GLOBAL_INCLUDE unsigned char *);
! /*emulates putc*/
extern int sapi_putc(SAPI_GLOBAL_INCLUDE unsigned char);
! /*emulates getenv*/
extern char *sapi_getenv(SAPI_GLOBAL_INCLUDE char *);
! /*writes a string to the client*/
extern int sapi_writeclient(SAPI_GLOBAL_INCLUDE unsigned char *, int);
! /*flushes any writes to the client*/
extern int sapi_flush(SAPI_GLOBAL_INCLUDE_V);
! /*sends a header to the client, adds \n\r to the end*/
extern int sapi_insert_header(SAPI_GLOBAL_INCLUDE unsigned char *header);
extern int sapi_send_header(SAPI_GLOBAL_INCLUDE_V);
extern void sapi_treat_headers(SAPI_GLOBAL_INCLUDE_V);
/*reads info from the client, used to get post
! fills the supplied buffer with the post data*/
extern int sapi_readclient(SAPI_GLOBAL_INCLUDE unsigned char *buf, int len);
/*signal blocking so a signal doesnt interrupt us in a bad place (used in apache) */
extern void sapi_block(SAPI_GLOBAL_INCLUDE_V);
extern void sapi_unblock(SAPI_GLOBAL_INCLUDE_V);
! /*logs messages to servers error log*/
extern void sapi_log(SAPI_GLOBAL_INCLUDE char *log_message);
/* this is the main function in main.c Initialization
* may be required before calling this function.
*/
! extern PHPAPI int php3_sapi_main(struct sapi_request_info *sapi_info,php3_module_entry
*module_info);
extern void sapi_print_info(SAPI_GLOBAL_INCLUDE_V);
! extern PHPAPI int _php3_sapi_thread_start(php3_module_entry *module_info);
extern PHPAPI int _php3_sapi_thread_end();
! extern PHPAPI int _php3_sapi_process_start(php3_module_entry *module_info);
extern PHPAPI int _php3_sapi_process_end();
#endif
--- 50,168 ----
unsigned int content_length;
char *content_type;
unsigned char *cookies;
! int cgi, display_source_mode, preprocess, info_only, quiet_mode;
! char *argv0, *ini_path, *script_filename;
/* page stat vars */
long page_uid;
long page_inode;
long page_mtime;
! /*handling headers */
! unsigned char *headers; /*pointer to header list */
! unsigned char *http_status; /* such as 401 Access Denied, needed for isapi */
! int http_redirect; /*used to signal redirect for isapi */
int abort;
! int (*insert_header) (SAPI_GLOBAL_INCLUDE unsigned char *); /*insert header into a list */
! int (*send_header) (SAPI_GLOBAL_INCLUDE_V); /*write headers to client */
! void (*treat_headers) (SAPI_GLOBAL_INCLUDE_V);
! int (*aborted) (SAPI_GLOBAL_INCLUDE_V); /* returns: same as apaches
php3_rqst->connection->aborted */
/* io functions */
! int (*readclient) (SAPI_GLOBAL_INCLUDE unsigned char *, int);
! void (*info) (SAPI_GLOBAL_INCLUDE_V);
! int (*puts) (SAPI_GLOBAL_INCLUDE unsigned char *);
! int (*sputc) (SAPI_GLOBAL_INCLUDE unsigned char);
! char *(*getenv) (SAPI_GLOBAL_INCLUDE char *);
! int (*writeclient) (SAPI_GLOBAL_INCLUDE unsigned char *, int);
! int (*flush) (SAPI_GLOBAL_INCLUDE_V); /*flush writes to client */
! void (*log) (SAPI_GLOBAL_INCLUDE char *); /*use server error log */
/* signal and thread functions */
! void (*blockalarms) (SAPI_GLOBAL_INCLUDE_V); /*signal blocking */
! void (*unblockalarms) (SAPI_GLOBAL_INCLUDE_V); /*signal blocking */
! #if 0 /* XXX FIXME Stig disabled this temporarily
! I get the following error:
! ../sapi/sapi.h:83: parse error before `*'
! ../sapi/sapi.h:83: `sapi_signal' declared as function returning a function
! ../sapi/sapi.h:83: warning: no semicolon at end of struct or union
! ../sapi/sapi.h:83: parse error before `)'
! */
/* dont know if this will actualy be used yet */
! void (*signal) (SAPI_GLOBAL_INCLUDE int sig, void (__cdecl * func) (int sig, int subcode));
#endif
/* FIXME these functions need definet work */
! void (*_php3_hash_server_env) (SAPI_GLOBAL_INCLUDE_V);
/* so far, apache specific */
! void (*register_clean) (SAPI_GLOBAL_INCLUDE void *, void *, void *);
/* so far, fhttpd specific */
! void (*request_shutdown) (SAPI_GLOBAL_INCLUDE_V);
/* output debug information somewhere */
#if defined(CRASH_DETECTION)
! void (*debug_log) (SAPI_GLOBAL_INCLUDE char *log_message);
#endif
};
#ifndef THREAD_SAFE
! extern struct sapi_request_info *sapi_rqst;
#endif
#if defined(COMPILE_DL)
! #define PUTS(a) php3_printf("%s",a)
! #define PUTC(a) PUTS(a)
! #define PHPWRITE(a,n) php3_write((a),(n))
#else
! #define PUTS(a) GLOBAL(sapi_rqst)->puts(SAPI_GLOBAL_PASS a)
! #define PUTC(a) GLOBAL(sapi_rqst)->sputc(SAPI_GLOBAL_PASS a)
! #define PHPWRITE(a,n) GLOBAL(sapi_rqst)->writeclient(SAPI_GLOBAL_PASS (a),(n))
! #define BLOCK_INTERRUPTIONS
if(GLOBAL(sapi_rqst))GLOBAL(sapi_rqst)->blockalarms(SAPI_GLOBAL_PASS_V)
! #define UNBLOCK_INTERRUPTIONS
if(GLOBAL(sapi_rqst))GLOBAL(sapi_rqst)->unblockalarms(SAPI_GLOBAL_PASS_V)
#endif
! /*emulates puts */
extern int sapi_puts(SAPI_GLOBAL_INCLUDE unsigned char *);
! /*emulates putc */
extern int sapi_putc(SAPI_GLOBAL_INCLUDE unsigned char);
! /*emulates getenv */
extern char *sapi_getenv(SAPI_GLOBAL_INCLUDE char *);
! /*writes a string to the client */
extern int sapi_writeclient(SAPI_GLOBAL_INCLUDE unsigned char *, int);
! /*flushes any writes to the client */
extern int sapi_flush(SAPI_GLOBAL_INCLUDE_V);
! /*sends a header to the client, adds \n\r to the end */
extern int sapi_insert_header(SAPI_GLOBAL_INCLUDE unsigned char *header);
extern int sapi_send_header(SAPI_GLOBAL_INCLUDE_V);
extern void sapi_treat_headers(SAPI_GLOBAL_INCLUDE_V);
/*reads info from the client, used to get post
! fills the supplied buffer with the post data */
extern int sapi_readclient(SAPI_GLOBAL_INCLUDE unsigned char *buf, int len);
/*signal blocking so a signal doesnt interrupt us in a bad place (used in apache) */
extern void sapi_block(SAPI_GLOBAL_INCLUDE_V);
extern void sapi_unblock(SAPI_GLOBAL_INCLUDE_V);
! /*logs messages to servers error log */
extern void sapi_log(SAPI_GLOBAL_INCLUDE char *log_message);
/* this is the main function in main.c Initialization
* may be required before calling this function.
*/
! extern PHPAPI int php3_sapi_main(struct sapi_request_info *sapi_info, php3_module_entry *
module_info);
extern void sapi_print_info(SAPI_GLOBAL_INCLUDE_V);
! extern PHPAPI int _php3_sapi_thread_start(php3_module_entry * module_info);
extern PHPAPI int _php3_sapi_thread_end();
! extern PHPAPI int _php3_sapi_process_start(php3_module_entry * module_info);
extern PHPAPI int _php3_sapi_process_end();
#endif
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net