diff options
Diffstat (limited to 'ext/standard/basic_functions.c')
-rw-r--r-- | ext/standard/basic_functions.c | 136 |
1 files changed, 67 insertions, 69 deletions
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 8015c6288f..ca00d8abed 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -896,7 +896,7 @@ PHP_FUNCTION(ip2long) convert_to_string_ex(str); - RETURN_LONG(ntohl(inet_addr((*str)->value.str.val))); + RETURN_LONG(ntohl(inet_addr(Z_STRVAL_PP(str)))); } /* }}} */ @@ -912,7 +912,7 @@ PHP_FUNCTION(long2ip) } convert_to_long_ex(num); - myaddr.s_addr = htonl((unsigned long)(*num)->value.lval); + myaddr.s_addr = htonl((unsigned long)Z_LVAL_PP(num)); RETURN_STRING (inet_ntoa(myaddr), 1); } @@ -936,14 +936,14 @@ PHP_FUNCTION(getenv) } convert_to_string_ex(str); - if ((*str)->type != IS_STRING) { + if (Z_TYPE_PP(str) != IS_STRING) { RETURN_FALSE; } - ptr = sapi_getenv((*str)->value.str.val, (*str)->value.str.len); + ptr = sapi_getenv(Z_STRVAL_PP(str), Z_STRLEN_PP(str)); if (!ptr) { - ptr = getenv((*str)->value.str.val); + ptr = getenv(Z_STRVAL_PP(str)); } if (ptr) { RETURN_STRING(ptr, 1); @@ -966,14 +966,14 @@ PHP_FUNCTION(putenv) } convert_to_string_ex(str); - if ((*str)->value.str.val && *((*str)->value.str.val)) { + if (Z_STRVAL_PP(str) && *(Z_STRVAL_PP(str))) { int ret; char *p,**env; putenv_entry pe; PLS_FETCH(); - pe.putenv_string = estrndup((*str)->value.str.val,(*str)->value.str.len); - pe.key = estrndup((*str)->value.str.val, (*str)->value.str.len); + pe.putenv_string = estrndup(Z_STRVAL_PP(str),Z_STRLEN_PP(str)); + pe.key = estrndup(Z_STRVAL_PP(str), Z_STRLEN_PP(str)); if ((p=strchr(pe.key,'='))) { /* nullify the '=' if there is one */ *p='\0'; } @@ -1058,7 +1058,7 @@ PHP_FUNCTION(intval) WRONG_PARAM_COUNT; } convert_to_long_ex(arg_base); - base = (*arg_base)->value.lval; + base = Z_LVAL_PP(arg_base); break; default: WRONG_PARAM_COUNT; @@ -1117,7 +1117,7 @@ PHP_FUNCTION(sleep) WRONG_PARAM_COUNT; } convert_to_long_ex(num); - php_sleep((*num)->value.lval); + php_sleep(Z_LVAL_PP(num)); } /* }}} */ @@ -1132,7 +1132,7 @@ PHP_FUNCTION(usleep) WRONG_PARAM_COUNT; } convert_to_long_ex(num); - usleep((*num)->value.lval); + usleep(Z_LVAL_PP(num)); #endif } /* }}} */ @@ -1146,7 +1146,7 @@ PHP_FUNCTION(gettype) if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) { WRONG_PARAM_COUNT; } - switch ((*arg)->type) { + switch (Z_TYPE_PP(arg)) { case IS_NULL: RETVAL_STRING("NULL",1); break; @@ -1200,7 +1200,7 @@ PHP_FUNCTION(settype) WRONG_PARAM_COUNT; } convert_to_string_ex(type); - new_type = (*type)->value.str.val; + new_type = Z_STRVAL_PP(type); if (!strcasecmp(new_type, "integer")) { convert_to_long(*var); @@ -1246,7 +1246,7 @@ PHP_FUNCTION(get_cfg_var) convert_to_string_ex(varname); - if (cfg_get_string((*varname)->value.str.val,&value)==FAILURE) { + if (cfg_get_string(Z_STRVAL_PP(varname),&value)==FAILURE) { RETURN_FALSE; } RETURN_STRING(value,1); @@ -1266,7 +1266,7 @@ PHP_FUNCTION(set_magic_quotes_runtime) } convert_to_boolean_ex(new_setting); - PG(magic_quotes_runtime) = (zend_bool) (*new_setting)->value.lval; + PG(magic_quotes_runtime) = (zend_bool) Z_LVAL_PP(new_setting); RETURN_TRUE; } /* }}} */ @@ -1299,7 +1299,7 @@ void php_is_type(INTERNAL_FUNCTION_PARAMETERS,int type) if (ZEND_NUM_ARGS()!=1 || zend_get_parameters_ex(1, &arg)==FAILURE) { RETURN_FALSE; } - if ((*arg)->type == type) { + if (Z_TYPE_PP(arg) == type) { RETURN_TRUE; } else { RETURN_FALSE; @@ -1373,14 +1373,14 @@ PHP_FUNCTION(is_numeric) WRONG_PARAM_COUNT; } - switch ((*arg)->type) { + switch (Z_TYPE_PP(arg)) { case IS_LONG: case IS_DOUBLE: RETURN_TRUE; break; case IS_STRING: - result = is_numeric_string((*arg)->value.str.val, (*arg)->value.str.len, NULL, NULL); + result = is_numeric_string(Z_STRVAL_PP(arg), Z_STRLEN_PP(arg), NULL, NULL); if (result == IS_LONG || result == IS_DOUBLE) { RETURN_TRUE; } else { @@ -1429,7 +1429,7 @@ PHP_FUNCTION(error_log) RETURN_FALSE; } convert_to_long_ex(erropt); - opt_err=(*erropt)->value.lval; + opt_err=Z_LVAL_PP(erropt); break; case 3: if (zend_get_parameters_ex(3,&string,&erropt,&option) == FAILURE){ @@ -1437,9 +1437,9 @@ PHP_FUNCTION(error_log) RETURN_FALSE; } convert_to_long_ex(erropt); - opt_err=(*erropt)->value.lval; + opt_err=Z_LVAL_PP(erropt); convert_to_string_ex(option); - opt=(*option)->value.str.val; + opt=Z_STRVAL_PP(option); break; case 4: if (zend_get_parameters_ex(4,&string,&erropt,&option,&emailhead) == FAILURE){ @@ -1452,18 +1452,18 @@ PHP_FUNCTION(error_log) } convert_to_string_ex(string); - message=(*string)->value.str.val; + message=Z_STRVAL_PP(string); if (erropt != NULL) { convert_to_long_ex(erropt); - opt_err=(*erropt)->value.lval; + opt_err=Z_LVAL_PP(erropt); } if (option != NULL) { convert_to_string_ex(option); - opt=(*option)->value.str.val; + opt=Z_STRVAL_PP(option); } if (emailhead != NULL) { convert_to_string_ex(emailhead); - headers=(*emailhead)->value.str.val; + headers=Z_STRVAL_PP(emailhead); } if (_php_error_log(opt_err,message,opt,headers)==FAILURE) { @@ -1534,7 +1534,7 @@ PHP_FUNCTION(call_user_func) && retval_ptr) { COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr); } else { - php_error(E_WARNING,"Unable to call %s() - function does not exist", (*params[0])->value.str.val); + php_error(E_WARNING,"Unable to call %s() - function does not exist", Z_STRVAL_PP(params[0])); } efree(params); } @@ -1598,7 +1598,7 @@ PHP_FUNCTION(call_user_method) efree(params); RETURN_FALSE; } - if ((*params[1])->type != IS_OBJECT) { + if (Z_TYPE_PP(params[1]) != IS_OBJECT) { php_error(E_WARNING,"2nd argument is not an object\n"); efree(params); RETURN_FALSE; @@ -1610,7 +1610,7 @@ PHP_FUNCTION(call_user_method) && retval_ptr) { COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr); } else { - php_error(E_WARNING,"Unable to call %s() - function does not exist", (*params[0])->value.str.val); + php_error(E_WARNING,"Unable to call %s() - function does not exist", Z_STRVAL_PP(params[0])); } efree(params); } @@ -1645,7 +1645,7 @@ static int user_shutdown_function_call(php_shutdown_function_entry *shutdown_fun zval_dtor(&retval); } else { php_error(E_WARNING,"Unable to call %s() - function does not exist", - shutdown_function_entry->arguments[0]->value.str.val); + Z_STRVAL_P(shutdown_function_entry->arguments[0])); } return 0; } @@ -1666,8 +1666,8 @@ static void user_tick_function_call(user_tick_function_entry *tick_fe) php_error(E_WARNING, "Unable to call %s() - function does not exist", Z_STRVAL_P(function)); } else if (Z_TYPE_P(function) == IS_ARRAY && - zend_hash_index_find(function->value.ht, 0, (void **) &obj) == SUCCESS && - zend_hash_index_find(function->value.ht, 1, (void **) &method) == SUCCESS && + zend_hash_index_find(Z_ARRVAL_P(function), 0, (void **) &obj) == SUCCESS && + zend_hash_index_find(Z_ARRVAL_P(function), 1, (void **) &method) == SUCCESS && Z_TYPE_PP(obj) == IS_OBJECT && Z_TYPE_PP(method) == IS_STRING) { php_error(E_WARNING, "Unable to call %s::%s() - function does not exist", @@ -1778,7 +1778,7 @@ PHP_FUNCTION(highlight_file) php_get_highlight_struct(&syntax_highlighter_ini); - if (highlight_file((*filename)->value.str.val, &syntax_highlighter_ini)==FAILURE) { + if (highlight_file(Z_STRVAL_PP(filename), &syntax_highlighter_ini)==FAILURE) { RETURN_FALSE; } RETURN_TRUE; @@ -1825,7 +1825,7 @@ pval test_class_get_property(zend_property_reference *property_reference) for (element=property_reference->elements_list->head; element; element=element->next) { overloaded_property = (zend_overloaded_element *) element->data; - switch (overloaded_property->type) { + switch (Z_TYPE_P(overloaded_property)) { case OE_IS_ARRAY: printf("Array offset: "); break; @@ -1833,20 +1833,20 @@ pval test_class_get_property(zend_property_reference *property_reference) printf("Object property: "); break; } - switch (overloaded_property->element.type) { + switch (Z_TYPE(overloaded_property->element)) { case IS_LONG: - printf("%ld (numeric)\n", overloaded_property->element.value.lval); + printf("%ld (numeric)\n", Z_LVAL(overloaded_property->element)); break; case IS_STRING: - printf("'%s'\n", overloaded_property->element.value.str.val); + printf("'%s'\n", Z_STRVAL(overloaded_property->element)); break; } pval_destructor(&overloaded_property->element); } - result.value.str.val = estrndup("testing", 7); - result.value.str.len = 7; - result.type = IS_STRING; + Z_STRVAL(result) = estrndup("testing", 7); + Z_STRLEN(result) = 7; + Z_TYPE(result) = IS_STRING; return result; } @@ -1863,7 +1863,7 @@ int test_class_set_property(zend_property_reference *property_reference, pval *v for (element=property_reference->elements_list->head; element; element=element->next) { overloaded_property = (zend_overloaded_element *) element->data; - switch (overloaded_property->type) { + switch (Z_TYPE_P(overloaded_property)) { case OE_IS_ARRAY: printf("Array offset: "); break; @@ -1871,12 +1871,12 @@ int test_class_set_property(zend_property_reference *property_reference, pval *v printf("Object property: "); break; } - switch (overloaded_property->element.type) { + switch (Z_TYPE(overloaded_property->element)) { case IS_LONG: - printf("%ld (numeric)\n", overloaded_property->element.value.lval); + printf("%ld (numeric)\n", Z_LVAL(overloaded_property->element)); break; case IS_STRING: - printf("'%s'\n", overloaded_property->element.value.str.val); + printf("'%s'\n", Z_STRVAL(overloaded_property->element)); break; } pval_destructor(&overloaded_property->element); @@ -1897,7 +1897,7 @@ void test_class_call_function(INTERNAL_FUNCTION_PARAMETERS, zend_property_refere for (element=property_reference->elements_list->head; element; element=element->next) { overloaded_property = (zend_overloaded_element *) element->data; - switch (overloaded_property->type) { + switch (Z_TYPE_P(overloaded_property)) { case OE_IS_ARRAY: printf("Array offset: "); break; @@ -1907,21 +1907,19 @@ void test_class_call_function(INTERNAL_FUNCTION_PARAMETERS, zend_property_refere case OE_IS_METHOD: printf("Overloaded method: "); } - switch (overloaded_property->element.type) { + switch (Z_TYPE(overloaded_property->element)) { case IS_LONG: - printf("%ld (numeric)\n", overloaded_property->element.value.lval); + printf("%ld (numeric)\n", Z_LVAL(overloaded_property->element)); break; case IS_STRING: - printf("'%s'\n", overloaded_property->element.value.str.val); + printf("'%s'\n", Z_STRVAL(overloaded_property->element)); break; } pval_destructor(&overloaded_property->element); } printf("%d arguments\n", ZEND_NUM_ARGS()); - return_value->value.str.val = estrndup("testing", 7); - return_value->value.str.len = 7; - return_value->type = IS_STRING; + RETVAL_STRING("testing", 1); } @@ -1950,7 +1948,7 @@ PHP_FUNCTION(ini_get) convert_to_string_ex(varname); - str = php_ini_string((*varname)->value.str.val, (*varname)->value.str.len+1, 0); + str = php_ini_string(Z_STRVAL_PP(varname), Z_STRLEN_PP(varname)+1, 0); if (!str) { RETURN_FALSE; @@ -1974,7 +1972,7 @@ PHP_FUNCTION(ini_set) convert_to_string_ex(varname); convert_to_string_ex(new_value); - old_value = php_ini_string((*varname)->value.str.val, (*varname)->value.str.len+1, 0); + old_value = php_ini_string(Z_STRVAL_PP(varname), Z_STRLEN_PP(varname)+1, 0); /* copy to return here, because alter might free it! */ if (old_value) { RETVAL_STRING(old_value, 1); @@ -1982,7 +1980,7 @@ PHP_FUNCTION(ini_set) RETVAL_FALSE; } - if (zend_alter_ini_entry((*varname)->value.str.val, (*varname)->value.str.len+1, (*new_value)->value.str.val, (*new_value)->value.str.len, PHP_INI_USER, PHP_INI_STAGE_RUNTIME)==FAILURE) { + if (zend_alter_ini_entry(Z_STRVAL_PP(varname), Z_STRLEN_PP(varname)+1, Z_STRVAL_PP(new_value), Z_STRLEN_PP(new_value), PHP_INI_USER, PHP_INI_STAGE_RUNTIME)==FAILURE) { zval_dtor(return_value); RETURN_FALSE; } @@ -2001,7 +1999,7 @@ PHP_FUNCTION(ini_restore) convert_to_string_ex(varname); - zend_restore_ini_entry((*varname)->value.str.val, (*varname)->value.str.len+1, PHP_INI_STAGE_RUNTIME); + zend_restore_ini_entry(Z_STRVAL_PP(varname), Z_STRLEN_PP(varname)+1, PHP_INI_STAGE_RUNTIME); } /* }}} */ @@ -2071,7 +2069,7 @@ PHP_FUNCTION(ignore_user_abort) RETURN_FALSE; } convert_to_boolean_ex(arg); - PG(ignore_user_abort) = (zend_bool) (*arg)->value.lval; + PG(ignore_user_abort) = (zend_bool) Z_LVAL_PP(arg); break; default: WRONG_PARAM_COUNT; @@ -2094,7 +2092,7 @@ PHP_FUNCTION(getservbyname) convert_to_string_ex(name); convert_to_string_ex(proto); - serv = getservbyname((*name)->value.str.val,(*proto)->value.str.val); + serv = getservbyname(Z_STRVAL_PP(name),Z_STRVAL_PP(proto)); if(serv == NULL) RETURN_FALSE; @@ -2117,7 +2115,7 @@ PHP_FUNCTION(getservbyport) convert_to_long_ex(port); convert_to_string_ex(proto); - serv = getservbyport(htons((unsigned short) (*port)->value.lval),(*proto)->value.str.val); + serv = getservbyport(htons((unsigned short) Z_LVAL_PP(port)),Z_STRVAL_PP(proto)); if(serv == NULL) RETURN_FALSE; @@ -2140,11 +2138,11 @@ PHP_FUNCTION(getprotobyname) convert_to_string_ex(name); - ent = getprotobyname((*name)->value.str.val); + ent = getprotobyname(Z_STRVAL_PP(name)); if(ent == NULL) { - return_value->value.lval = -1; - return_value->type = IS_LONG; + Z_LVAL_P(return_value) = -1; + Z_TYPE_P(return_value) = IS_LONG; return; } @@ -2166,7 +2164,7 @@ PHP_FUNCTION(getprotobynumber) convert_to_long_ex(proto); - ent = getprotobynumber((*proto)->value.lval); + ent = getprotobynumber(Z_LVAL_PP(proto)); if(ent == NULL) RETURN_FALSE; @@ -2208,7 +2206,7 @@ PHP_FUNCTION(extension_loaded) } convert_to_string_ex(extension_name); - if (zend_hash_exists(&module_registry, (*extension_name)->value.str.val, (*extension_name)->value.str.len+1)) { + if (zend_hash_exists(&module_registry, Z_STRVAL_PP(extension_name), Z_STRLEN_PP(extension_name)+1)) { RETURN_TRUE; } else { RETURN_FALSE; @@ -2230,8 +2228,8 @@ PHP_FUNCTION(get_extension_funcs) } convert_to_string_ex(extension_name); - if (zend_hash_find(&module_registry, (*extension_name)->value.str.val, - (*extension_name)->value.str.len+1, (void**)&module) == FAILURE) { + if (zend_hash_find(&module_registry, Z_STRVAL_PP(extension_name), + Z_STRLEN_PP(extension_name)+1, (void**)&module) == FAILURE) { return; } @@ -2392,7 +2390,7 @@ static void php_simple_ini_parser_cb(zval *arg1, zval *arg2, int callback_type, *element = *arg2; zval_copy_ctor(element); INIT_PZVAL(element); - zend_hash_update(arr->value.ht, Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1, &element, sizeof(zval *), NULL); + zend_hash_update(Z_ARRVAL_P(arr), Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1, &element, sizeof(zval *), NULL); break; case ZEND_INI_PARSER_SECTION: break; @@ -2418,13 +2416,13 @@ static void php_ini_parser_cb_with_sections(zval *arg1, zval *arg2, int callback *element = *arg2; zval_copy_ctor(element); INIT_PZVAL(element); - zend_hash_update(active_arr->value.ht, Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1, &element, sizeof(zval *), NULL); + zend_hash_update(Z_ARRVAL_P(active_arr), Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1, &element, sizeof(zval *), NULL); } break; case ZEND_INI_PARSER_SECTION: MAKE_STD_ZVAL(BG(active_ini_file_section)); array_init(BG(active_ini_file_section)); - zend_hash_update(arr->value.ht, Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1, &BG(active_ini_file_section), sizeof(zval *), NULL); + zend_hash_update(Z_ARRVAL_P(arr), Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1, &BG(active_ini_file_section), sizeof(zval *), NULL); break; } } @@ -2467,10 +2465,10 @@ PHP_FUNCTION(parse_ini_file) convert_to_string_ex(filename); fh.handle.fp = V_FOPEN(Z_STRVAL_PP(filename), "r"); if (!fh.handle.fp) { - php_error(E_WARNING,"Cannot open '%s' for reading", (*filename)->value.str.val); + php_error(E_WARNING,"Cannot open '%s' for reading", Z_STRVAL_PP(filename)); return; } - fh.type = ZEND_HANDLE_FP; + Z_TYPE(fh) = ZEND_HANDLE_FP; fh.filename = Z_STRVAL_PP(filename); array_init(return_value); zend_parse_ini_file(&fh, 0, ini_parser_cb, return_value); |