cvs: php4 /main SAPI.h main.c

From: Date: Sun, 06 Jan 2002 13:58:06 +0000
Subject: cvs: php4 /main SAPI.h main.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-8962@lists.php.net to get a copy of this message
edink Sun Jan 6 08:58:06 2002 EDT Modified files: /php4/main SAPI.h main.c Log: Added argc and argv in request_info needed for the new cli sapi. Modified registering $argc and $argv to support cli sapi. Index: php4/main/SAPI.h diff -u php4/main/SAPI.h:1.78 php4/main/SAPI.h:1.79 --- php4/main/SAPI.h:1.78 Tue Dec 11 10:31:01 2001 +++ php4/main/SAPI.h Sun Jan 6 08:58:05 2002 @@ -97,6 +97,10 @@ /* this is necessary for Safe Mode */ char *current_user; int current_user_length; + + /* this is necessary for CLI module */ + int argc; + char **argv; } sapi_request_info; Index: php4/main/main.c diff -u php4/main/main.c:1.416 php4/main/main.c:1.417 --- php4/main/main.c:1.416 Sun Dec 16 17:45:57 2001 +++ php4/main/main.c Sun Jan 6 08:58:05 2002 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: main.c,v 1.416 2001/12/16 22:45:57 zeev Exp $ */ +/* $Id: main.c,v 1.417 2002/01/06 13:58:05 edink Exp $ */ /* {{{ includes */ @@ -861,6 +861,8 @@ PG(header_is_being_sent) = 0; SG(request_info).headers_only = 0; SG(request_info).argv0 = NULL; + SG(request_info).argc=0; + SG(request_info).argv=(char **)NULL; PG(connection_status) = PHP_CONNECTION_NORMAL; PG(during_request_startup) = 0; @@ -1195,7 +1197,21 @@ INIT_PZVAL(arr); /* Prepare argv */ - if (s && *s) { + if (SG(request_info).argc) { /* are we in cli sapi? */ + int i; + for (i=0; i<SG(request_info).argc; i++) { + ALLOC_ZVAL(tmp); + Z_TYPE_P(tmp) = IS_STRING; + Z_STRLEN_P(tmp) = strlen(SG(request_info).argv[i]); + Z_STRVAL_P(tmp) = estrndup(SG(request_info).argv[i], Z_STRLEN_P(tmp)); + INIT_PZVAL(tmp); + if (zend_hash_next_index_insert(Z_ARRVAL_P(arr), &tmp, sizeof(pval *), NULL)==FAILURE) { + if (Z_TYPE_P(tmp) == IS_STRING) { + efree(Z_STRVAL_P(tmp)); + } + } + } + } else if (s && *s) { ss = s; while (ss) { space = strchr(ss, '+'); @@ -1225,7 +1241,11 @@ /* prepare argc */ ALLOC_ZVAL(argc); - Z_LVAL_P(argc) = count; + if (SG(request_info).argc) { + Z_LVAL_P(argc) = SG(request_info).argc; + } else { + Z_LVAL_P(argc) = count; + } Z_TYPE_P(argc) = IS_LONG; INIT_PZVAL(argc);

« previous php.cvs (#8962) next »