diff options
-rw-r--r-- | sapi/apache/mod_php5.c | 52 | ||||
-rw-r--r-- | sapi/apache/php_apache.c | 4 | ||||
-rw-r--r-- | sapi/apache2handler/apache_config.c | 33 | ||||
-rw-r--r-- | sapi/apache2handler/php_functions.c | 12 | ||||
-rw-r--r-- | sapi/apache2handler/sapi_apache2.c | 12 |
5 files changed, 58 insertions, 55 deletions
diff --git a/sapi/apache/mod_php5.c b/sapi/apache/mod_php5.c index 37252e1126..a78b8dc913 100644 --- a/sapi/apache/mod_php5.c +++ b/sapi/apache/mod_php5.c @@ -256,7 +256,7 @@ static void sapi_apache_register_server_variables(zval *track_vars_array TSRMLS_ register int i; array_header *arr = table_elts(((request_rec *) SG(server_context))->subprocess_env); table_entry *elts = (table_entry *) arr->elts; - zval **path_translated; + zval *path_translated; HashTable *symbol_table; unsigned int new_val_len; @@ -277,14 +277,14 @@ static void sapi_apache_register_server_variables(zval *track_vars_array TSRMLS_ /* If PATH_TRANSLATED doesn't exist, copy it from SCRIPT_FILENAME */ if (track_vars_array) { - symbol_table = track_vars_array->value.ht; + symbol_table = Z_ARRVAL_P(track_vars_array); } else { symbol_table = NULL; } if (symbol_table - && !zend_hash_exists(symbol_table, "PATH_TRANSLATED", sizeof("PATH_TRANSLATED")) - && zend_hash_find(symbol_table, "SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME"), (void **) &path_translated)==SUCCESS) { - php_register_variable("PATH_TRANSLATED", Z_STRVAL_PP(path_translated), track_vars_array TSRMLS_CC); + && !zend_hash_str_exists(symbol_table, "PATH_TRANSLATED", sizeof("PATH_TRANSLATED")-1) + && (path_translated = zend_hash_str_find(symbol_table, "SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME")-1)) != NULL) { + php_register_variable("PATH_TRANSLATED", Z_STRVAL_P(path_translated), track_vars_array TSRMLS_CC); } if (sapi_module.input_filter(PARSE_SERVER, "PHP_SELF", &((request_rec *) SG(server_context))->uri, strlen(((request_rec *) SG(server_context))->uri), &new_val_len TSRMLS_CC)) { @@ -566,7 +566,9 @@ static void init_request_info(TSRMLS_D) */ static int php_apache_alter_ini_entries(php_per_dir_entry *per_dir_entry TSRMLS_DC) { - zend_alter_ini_entry(per_dir_entry->key, per_dir_entry->key_length+1, per_dir_entry->value, per_dir_entry->value_length, per_dir_entry->type, per_dir_entry->htaccess?PHP_INI_STAGE_HTACCESS:PHP_INI_STAGE_ACTIVATE); + zend_string *key = STR_INIT(per_dir_entry->key, per_dir_entry->key_length, 0); + zend_alter_ini_entry(key, per_dir_entry->value, per_dir_entry->value_length, per_dir_entry->type, per_dir_entry->htaccess?PHP_INI_STAGE_HTACCESS:PHP_INI_STAGE_ACTIVATE); + STR_RELEASE(key); return 0; } /* }}} */ @@ -710,36 +712,44 @@ static int send_parsed_php_source(request_rec * r) /* {{{ destroy_per_dir_entry */ -static void destroy_per_dir_entry(php_per_dir_entry *per_dir_entry) +static void destroy_per_dir_entry(zval *zv) { + php_per_dir_entry *per_dir_entry = Z_PTR_P(zv); + free(per_dir_entry->key); free(per_dir_entry->value); + free(per_dir_entry); } /* }}} */ /* {{{ copy_per_dir_entry */ -static void copy_per_dir_entry(php_per_dir_entry *per_dir_entry) +static void copy_per_dir_entry(zval *zv) { - php_per_dir_entry tmp = *per_dir_entry; + php_per_dir_entry *old_per_dir_entry = Z_PTR_P(zv); + php_per_dir_entry *new_per_dir_entry = malloc(sizeof(php_per_dir_entry)); + + memcpy(new_per_dir_entry, old_per_dir_entry, sizeof(php_per_dir_entry)); + Z_PTR_P(zv) = new_per_dir_entry; - per_dir_entry->key = (char *) malloc(tmp.key_length+1); - memcpy(per_dir_entry->key, tmp.key, tmp.key_length); - per_dir_entry->key[per_dir_entry->key_length] = 0; + new_per_dir_entry->key = (char *) malloc(old_per_dir_entry->key_length+1); + memcpy(new_per_dir_entry->key, old_per_dir_entry->key, old_per_dir_entry->key_length); + new_per_dir_entry->key[new_per_dir_entry->key_length] = 0; - per_dir_entry->value = (char *) malloc(tmp.value_length+1); - memcpy(per_dir_entry->value, tmp.value, tmp.value_length); - per_dir_entry->value[per_dir_entry->value_length] = 0; + new_per_dir_entry->value = (char *) malloc(old_per_dir_entry->value_length+1); + memcpy(new_per_dir_entry->value, old_per_dir_entry->value, old_per_dir_entry->value_length); + new_per_dir_entry->value[new_per_dir_entry->value_length] = 0; } /* }}} */ /* {{{ should_overwrite_per_dir_entry */ -static zend_bool should_overwrite_per_dir_entry(HashTable *target_ht, php_per_dir_entry *new_per_dir_entry, zend_hash_key *hash_key, void *pData) +static zend_bool should_overwrite_per_dir_entry(HashTable *target_ht, zval *zv, zend_hash_key *hash_key, void *pData) { + php_per_dir_entry *new_per_dir_entry = Z_PTR_P(zv); php_per_dir_entry *orig_per_dir_entry; - if (zend_hash_find(target_ht, hash_key->arKey, hash_key->nKeyLength, (void **) &orig_per_dir_entry)==FAILURE) { + if ((orig_per_dir_entry = zend_hash_find_ptr(target_ht, hash_key->key)) == NULL) { return 1; /* does not exist in dest, copy from source */ } @@ -768,7 +778,7 @@ static void *php_create_dir(pool *p, char *dummy) HashTable *per_dir_info; per_dir_info = (HashTable *) malloc(sizeof(HashTable)); - zend_hash_init_ex(per_dir_info, 5, NULL, (void (*)(void *)) destroy_per_dir_entry, 1, 0); + zend_hash_init_ex(per_dir_info, 5, NULL, destroy_per_dir_entry, 1, 0); register_cleanup(p, (void *) per_dir_info, (void (*)(void *)) php_destroy_per_dir_info, (void (*)(void *)) zend_hash_destroy); return per_dir_info; @@ -784,9 +794,9 @@ static void *php_merge_dir(pool *p, void *basev, void *addv) /* need a copy of addv to merge */ new = php_create_dir(p, "php_merge_dir"); - zend_hash_copy(new, (HashTable *) basev, (copy_ctor_func_t) copy_per_dir_entry, NULL, sizeof(php_per_dir_entry)); + zend_hash_copy(new, (HashTable *) basev, copy_per_dir_entry); - zend_hash_merge_ex(new, (HashTable *) addv, (copy_ctor_func_t) copy_per_dir_entry, sizeof(php_per_dir_entry), (merge_checker_func_t) should_overwrite_per_dir_entry, NULL); + zend_hash_merge_ex(new, (HashTable *) addv, copy_per_dir_entry, should_overwrite_per_dir_entry, NULL); return new; } /* }}} */ @@ -823,7 +833,7 @@ static CONST_PREFIX char *php_apache_value_handler_ex(cmd_parms *cmd, HashTable memcpy(per_dir_entry.value, arg2, per_dir_entry.value_length); per_dir_entry.value[per_dir_entry.value_length] = 0; - zend_hash_update(conf, per_dir_entry.key, per_dir_entry.key_length, &per_dir_entry, sizeof(php_per_dir_entry), NULL); + zend_hash_str_update_mem(conf, per_dir_entry.key, per_dir_entry.key_length, &per_dir_entry, sizeof(php_per_dir_entry)); return NULL; } /* }}} */ diff --git a/sapi/apache/php_apache.c b/sapi/apache/php_apache.c index 1ad4897a35..3a88a1210e 100644 --- a/sapi/apache/php_apache.c +++ b/sapi/apache/php_apache.c @@ -327,7 +327,7 @@ PHP_FUNCTION(apache_note) } if (old_val) { - RETURN_STRING(old_val, 1); + RETURN_STRING(old_val); } RETURN_FALSE; @@ -561,7 +561,7 @@ PHP_FUNCTION(apache_get_version) char *apv = (char *) ap_get_server_version(); if (apv && *apv) { - RETURN_STRING(apv, 1); + RETURN_STRING(apv); } RETURN_FALSE; diff --git a/sapi/apache2handler/apache_config.c b/sapi/apache2handler/apache_config.c index 76d3ee2264..5302afcf18 100644 --- a/sapi/apache2handler/apache_config.c +++ b/sapi/apache2handler/apache_config.c @@ -70,7 +70,7 @@ static const char *real_value_hnd(cmd_parms *cmd, void *dummy, const char *name, e.status = status; e.htaccess = ((cmd->override & (RSRC_CONF|ACCESS_CONF)) == 0); - zend_hash_update(&d->config, (char *) name, strlen(name) + 1, &e, sizeof(e), NULL); + zend_hash_str_update_mem(&d->config, (char *) name, strlen(name), &e, sizeof(e)); return NULL; } @@ -117,11 +117,12 @@ static const char *php_apache_phpini_set(cmd_parms *cmd, void *mconfig, const ch return NULL; } -static zend_bool should_overwrite_per_dir_entry(HashTable *target_ht, php_dir_entry *new_per_dir_entry, zend_hash_key *hash_key, void *pData) +static zend_bool should_overwrite_per_dir_entry(HashTable *target_ht, zval *zv, zend_hash_key *hash_key, void *pData) { + php_dir_entry *new_per_dir_entry = Z_PTR_P(zv); php_dir_entry *orig_per_dir_entry; - if (zend_hash_find(target_ht, hash_key->arKey, hash_key->nKeyLength, (void **) &orig_per_dir_entry)==FAILURE) { + if ((orig_per_dir_entry = zend_hash_find_ptr(target_ht, hash_key->key)) == NULL) { return 1; /* does not exist in dest, copy from source */ } @@ -148,10 +149,12 @@ void *merge_php_config(apr_pool_t *p, void *base_conf, void *new_conf) n = create_php_config(p, "merge_php_config"); /* copy old config */ - zend_hash_copy(&n->config, &d->config, NULL, NULL, sizeof(php_dir_entry)); + zend_hash_copy(&n->config, &d->config, NULL); +//??? zend_hash_copy(&n->config, &d->config, NULL, NULL, sizeof(php_dir_entry)); /* merge new config */ phpapdebug((stderr, "Merge dir (%p)+(%p)=(%p)\n", base_conf, new_conf, n)); - zend_hash_merge_ex(&n->config, &e->config, NULL, sizeof(php_dir_entry), (merge_checker_func_t) should_overwrite_per_dir_entry, NULL); + zend_hash_merge_ex(&n->config, &e->config, NULL, should_overwrite_per_dir_entry, NULL); +//??? zend_hash_merge_ex(&n->config, &e->config, NULL, sizeof(php_dir_entry), (merge_checker_func_t) should_overwrite_per_dir_entry, NULL); #if STAS_0 for (zend_hash_internal_pointer_reset(&d->config); zend_hash_get_current_key_ex(&d->config, &str, &str_len, @@ -174,7 +177,7 @@ char *get_php_config(void *conf, char *name, size_t name_len) php_conf_rec *d = conf; php_dir_entry *pe; - if (zend_hash_find(&d->config, name, name_len, (void **) &pe) == SUCCESS) { + if ((pe = zend_hash_str_find_ptr(&d->config, name, name_len)) != NULL) { return pe->value; } @@ -184,21 +187,15 @@ char *get_php_config(void *conf, char *name, size_t name_len) void apply_config(void *dummy) { php_conf_rec *d = dummy; - char *str; - uint str_len; + zend_string *str; php_dir_entry *data; - for (zend_hash_internal_pointer_reset(&d->config); - zend_hash_get_current_key_ex(&d->config, &str, &str_len, NULL, 0, - NULL) == HASH_KEY_IS_STRING; - zend_hash_move_forward(&d->config)) { - if (zend_hash_get_current_data(&d->config, (void **) &data) == SUCCESS) { - phpapdebug((stderr, "APPLYING (%s)(%s)\n", str, data->value)); - if (zend_alter_ini_entry(str, str_len, data->value, data->value_len, data->status, data->htaccess?PHP_INI_STAGE_HTACCESS:PHP_INI_STAGE_ACTIVATE) == FAILURE) { - phpapdebug((stderr, "..FAILED\n")); - } + ZEND_HASH_FOREACH_STR_KEY_PTR(&d->config, str, data) { + phpapdebug((stderr, "APPLYING (%s)(%s)\n", str, data->value)); + if (zend_alter_ini_entry(str, data->value, data->value_len, data->status, data->htaccess?PHP_INI_STAGE_HTACCESS:PHP_INI_STAGE_ACTIVATE) == FAILURE) { + phpapdebug((stderr, "..FAILED\n")); } - } + } ZEND_HASH_FOREACH_END(); } const command_rec php_dir_cmds[] = diff --git a/sapi/apache2handler/php_functions.c b/sapi/apache2handler/php_functions.c index c6bed48dac..4bc8fe8872 100644 --- a/sapi/apache2handler/php_functions.c +++ b/sapi/apache2handler/php_functions.c @@ -238,7 +238,7 @@ PHP_FUNCTION(apache_note) } if (old_note_val) { - RETURN_STRING(old_note_val, 1); + RETURN_STRING(old_note_val); } RETURN_FALSE; @@ -313,7 +313,7 @@ PHP_FUNCTION(apache_getenv) env_val = (char*) apr_table_get(r->subprocess_env, variable); if (env_val != NULL) { - RETURN_STRING(env_val, 1); + RETURN_STRING(env_val); } RETURN_FALSE; @@ -336,7 +336,7 @@ PHP_FUNCTION(apache_get_version) char *apv = php_apache_get_version(); if (apv && *apv) { - RETURN_STRING(apv, 1); + RETURN_STRING(apv); } else { RETURN_FALSE; } @@ -388,8 +388,8 @@ PHP_MINFO_FUNCTION(apache) } smart_str_appendc(&tmp1, ' '); } - if ((tmp1.len - 1) >= 0) { - tmp1.c[tmp1.len - 1] = '\0'; + if (tmp1.s && (tmp1.s->len - 1) >= 0) { + tmp1.s->val[tmp1.s->len - 1] = '\0'; } php_info_print_table_start(); @@ -426,7 +426,7 @@ PHP_MINFO_FUNCTION(apache) php_info_print_table_row(2, "Virtual Server", (serv->is_virtual ? "Yes" : "No")); php_info_print_table_row(2, "Server Root", ap_server_root); - php_info_print_table_row(2, "Loaded Modules", tmp1.c); + php_info_print_table_row(2, "Loaded Modules", tmp1.s->val); smart_str_free(&tmp1); php_info_print_table_end(); diff --git a/sapi/apache2handler/sapi_apache2.c b/sapi/apache2handler/sapi_apache2.c index dfb5eac28a..ebcc3e9bc9 100644 --- a/sapi/apache2handler/sapi_apache2.c +++ b/sapi/apache2handler/sapi_apache2.c @@ -514,16 +514,12 @@ static void php_apache_ini_dtor(request_rec *r, request_rec *p TSRMLS_DC) typedef struct { HashTable config; } php_conf_rec; - char *str; - uint str_len; + zend_string *str; php_conf_rec *c = ap_get_module_config(r->per_dir_config, &php5_module); - for (zend_hash_internal_pointer_reset(&c->config); - zend_hash_get_current_key_ex(&c->config, &str, &str_len, NULL, 0, NULL) == HASH_KEY_IS_STRING; - zend_hash_move_forward(&c->config) - ) { - zend_restore_ini_entry(str, str_len, ZEND_INI_STAGE_SHUTDOWN); - } + ZEND_HASH_FOREACH_STR_KEY(&c->config, str) { + zend_restore_ini_entry(str, ZEND_INI_STAGE_SHUTDOWN); + } ZEND_HASH_FOREACH_END(); } if (p) { ((php_struct *)SG(server_context))->r = p; |