mirror of
https://github.com/php/php-src.git
synced 2024-09-25 11:57:26 +00:00
MFB: new parameter-parsing API
This commit is contained in:
parent
18c13084c7
commit
bf9dc86e1a
@ -59,23 +59,22 @@ static request_rec *php_apache_lookup_uri(char *filename TSRMLS_DC)
|
||||
Perform an apache sub-request */
|
||||
PHP_FUNCTION(virtual)
|
||||
{
|
||||
zval **filename;
|
||||
char *filename;
|
||||
int filename_len;
|
||||
request_rec *rr;
|
||||
|
||||
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &filename) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
convert_to_string_ex(filename);
|
||||
|
||||
if (!(rr = php_apache_lookup_uri(Z_STRVAL_PP(filename) TSRMLS_CC))) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include '%s' - URI lookup failed", Z_STRVAL_PP(filename));
|
||||
if (!(rr = php_apache_lookup_uri(filename TSRMLS_CC))) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include '%s' - URI lookup failed", filename);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (rr->status == HTTP_OK) {
|
||||
if (ap_run_sub_req(rr)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include '%s' - request execution failed", Z_STRVAL_PP(filename));
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include '%s' - request execution failed", filename);
|
||||
ap_destroy_sub_req(rr);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
@ -83,7 +82,7 @@ PHP_FUNCTION(virtual)
|
||||
RETURN_TRUE;
|
||||
}
|
||||
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include '%s' - error finding URI", Z_STRVAL_PP(filename));
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include '%s' - error finding URI", filename);
|
||||
ap_destroy_sub_req(rr);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
@ -99,16 +98,15 @@ PHP_FUNCTION(virtual)
|
||||
PHP_FUNCTION(apache_lookup_uri)
|
||||
{
|
||||
request_rec *rr;
|
||||
zval **filename;
|
||||
char *filename;
|
||||
int filename_len;
|
||||
|
||||
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &filename) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
convert_to_string_ex(filename);
|
||||
|
||||
if (!(rr = php_apache_lookup_uri(Z_STRVAL_PP(filename) TSRMLS_CC))) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include '%s' - URI lookup failed", Z_STRVAL_PP(filename));
|
||||
if (!(rr = php_apache_lookup_uri(filename TSRMLS_CC))) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include '%s' - URI lookup failed", filename);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
@ -145,7 +143,7 @@ PHP_FUNCTION(apache_lookup_uri)
|
||||
return;
|
||||
}
|
||||
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include '%s' - error finding URI", Z_STRVAL_PP(filename));
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include '%s' - error finding URI", filename);
|
||||
ap_destroy_sub_req(rr);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
@ -195,31 +193,28 @@ PHP_FUNCTION(apache_response_headers)
|
||||
PHP_FUNCTION(apache_note)
|
||||
{
|
||||
php_struct *ctx;
|
||||
zval **note_name, **note_val;
|
||||
char *note_name, *note_val;
|
||||
int note_name_len, note_val_len;
|
||||
char *old_note_val=NULL;
|
||||
int arg_count = ZEND_NUM_ARGS();
|
||||
|
||||
if (arg_count<1 || arg_count>2 ||
|
||||
zend_get_parameters_ex(arg_count, ¬e_name, ¬e_val) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
if (zend_parse_parameters(arg_count TSRMLS_CC, "s|s", ¬e_name, ¬e_name_len, ¬e_val, ¬e_val_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
ctx = SG(server_context);
|
||||
|
||||
convert_to_string_ex(note_name);
|
||||
|
||||
old_note_val = (char *) apr_table_get(ctx->r->notes, Z_STRVAL_PP(note_name));
|
||||
|
||||
ctx = SG(server_context);
|
||||
|
||||
old_note_val = (char *) apr_table_get(ctx->r->notes, note_name);
|
||||
|
||||
if (arg_count == 2) {
|
||||
convert_to_string_ex(note_val);
|
||||
apr_table_set(ctx->r->notes, Z_STRVAL_PP(note_name), Z_STRVAL_PP(note_val));
|
||||
apr_table_set(ctx->r->notes, note_name, note_val);
|
||||
}
|
||||
|
||||
if (old_note_val) {
|
||||
RETURN_STRING(old_note_val, 1);
|
||||
} else {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
RETURN_FALSE;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -229,26 +224,24 @@ PHP_FUNCTION(apache_note)
|
||||
PHP_FUNCTION(apache_setenv)
|
||||
{
|
||||
php_struct *ctx;
|
||||
zval **variable=NULL, **string_val=NULL, **walk_to_top=NULL;
|
||||
char *variable=NULL, *string_val=NULL;
|
||||
int variable_len, string_val_len;
|
||||
zend_bool walk_to_top = 0;
|
||||
int arg_count = ZEND_NUM_ARGS();
|
||||
|
||||
if (arg_count<1 || arg_count>3 ||
|
||||
zend_get_parameters_ex(arg_count, &variable, &string_val, &walk_to_top) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
if (zend_parse_parameters(arg_count TSRMLS_CC, "ss|b", &variable, &variable_len, &string_val, &string_val_len, &walk_to_top) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
ctx = SG(server_context);
|
||||
|
||||
if (arg_count == 3 && Z_STRVAL_PP(walk_to_top)) {
|
||||
if (arg_count == 3 && walk_to_top) {
|
||||
while(ctx->f->r->prev) {
|
||||
ctx->f->r = ctx->f->r->prev;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
convert_to_string_ex(variable);
|
||||
convert_to_string_ex(string_val);
|
||||
|
||||
apr_table_set(ctx->r->subprocess_env, Z_STRVAL_PP(variable), Z_STRVAL_PP(string_val));
|
||||
apr_table_set(ctx->r->subprocess_env, variable, string_val);
|
||||
|
||||
RETURN_TRUE;
|
||||
}
|
||||
@ -259,31 +252,30 @@ PHP_FUNCTION(apache_setenv)
|
||||
PHP_FUNCTION(apache_getenv)
|
||||
{
|
||||
php_struct *ctx;
|
||||
zval **variable=NULL, **walk_to_top=NULL;
|
||||
char *variable=NULL;
|
||||
int variable_len;
|
||||
zend_bool walk_to_top = 0;
|
||||
int arg_count = ZEND_NUM_ARGS();
|
||||
char *env_val=NULL;
|
||||
|
||||
if (arg_count<1 || arg_count>2 ||
|
||||
zend_get_parameters_ex(arg_count, &variable, &walk_to_top) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
if (zend_parse_parameters(arg_count TSRMLS_CC, "s|b", &variable, &variable_len, &walk_to_top) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
ctx = SG(server_context);
|
||||
|
||||
if (arg_count == 2 && Z_STRVAL_PP(walk_to_top)) {
|
||||
if (arg_count == 2 && walk_to_top) {
|
||||
while(ctx->f->r->prev) {
|
||||
ctx->f->r = ctx->f->r->prev;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
convert_to_string_ex(variable);
|
||||
|
||||
env_val = (char*) apr_table_get(ctx->r->subprocess_env, Z_STRVAL_PP(variable));
|
||||
env_val = (char*) apr_table_get(ctx->r->subprocess_env, variable);
|
||||
if (env_val != NULL) {
|
||||
RETURN_STRING(env_val, 1);
|
||||
} else {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_FALSE;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user