mirror of
https://github.com/php/php-src.git
synced 2025-08-16 14:08:47 +02:00
Added argc and argv in request_info needed for the new cli sapi.
Modified registering $argc and $argv to support cli sapi.
This commit is contained in:
parent
6e1878b0fc
commit
1788410a56
2 changed files with 26 additions and 2 deletions
|
@ -97,6 +97,10 @@ typedef struct {
|
||||||
/* this is necessary for Safe Mode */
|
/* this is necessary for Safe Mode */
|
||||||
char *current_user;
|
char *current_user;
|
||||||
int current_user_length;
|
int current_user_length;
|
||||||
|
|
||||||
|
/* this is necessary for CLI module */
|
||||||
|
int argc;
|
||||||
|
char **argv;
|
||||||
} sapi_request_info;
|
} sapi_request_info;
|
||||||
|
|
||||||
|
|
||||||
|
|
24
main/main.c
24
main/main.c
|
@ -861,6 +861,8 @@ int php_module_startup(sapi_module_struct *sf)
|
||||||
PG(header_is_being_sent) = 0;
|
PG(header_is_being_sent) = 0;
|
||||||
SG(request_info).headers_only = 0;
|
SG(request_info).headers_only = 0;
|
||||||
SG(request_info).argv0 = NULL;
|
SG(request_info).argv0 = NULL;
|
||||||
|
SG(request_info).argc=0;
|
||||||
|
SG(request_info).argv=(char **)NULL;
|
||||||
PG(connection_status) = PHP_CONNECTION_NORMAL;
|
PG(connection_status) = PHP_CONNECTION_NORMAL;
|
||||||
PG(during_request_startup) = 0;
|
PG(during_request_startup) = 0;
|
||||||
|
|
||||||
|
@ -1195,7 +1197,21 @@ static void php_build_argv(char *s, zval *track_vars_array TSRMLS_DC)
|
||||||
INIT_PZVAL(arr);
|
INIT_PZVAL(arr);
|
||||||
|
|
||||||
/* Prepare argv */
|
/* 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;
|
ss = s;
|
||||||
while (ss) {
|
while (ss) {
|
||||||
space = strchr(ss, '+');
|
space = strchr(ss, '+');
|
||||||
|
@ -1225,7 +1241,11 @@ static void php_build_argv(char *s, zval *track_vars_array TSRMLS_DC)
|
||||||
|
|
||||||
/* prepare argc */
|
/* prepare argc */
|
||||||
ALLOC_ZVAL(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;
|
Z_TYPE_P(argc) = IS_LONG;
|
||||||
INIT_PZVAL(argc);
|
INIT_PZVAL(argc);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue