diff options
Diffstat (limited to 'sapi')
51 files changed, 1674 insertions, 670 deletions
diff --git a/sapi/aolserver/aolserver.c b/sapi/aolserver/aolserver.c index a89b98e57a..13091b908a 100644 --- a/sapi/aolserver/aolserver.c +++ b/sapi/aolserver/aolserver.c @@ -273,7 +273,7 @@ PHP_FUNCTION(getallheaders) char *key = Ns_SetKey(NSG(conn->headers), i); char *value = Ns_SetValue(NSG(conn->headers), i); - add_assoc_string(return_value, key, value, 1); + add_assoc_string(return_value, key, value); } } diff --git a/sapi/apache/mod_php5.c b/sapi/apache/mod_php5.c index a1e5a70e89..a78b8dc913 100644 --- a/sapi/apache/mod_php5.c +++ b/sapi/apache/mod_php5.c @@ -108,7 +108,7 @@ static int sapi_apache_ub_write(const char *str, uint str_length TSRMLS_DC) /* {{{ sapi_apache_flush */ -static void sapi_apache_flush(void *server_context) +static void sapi_apache_flush(void *server_context TSRMLS_DC) { if (server_context) { #if MODULE_MAGIC_NUMBER > 19970110 @@ -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 43a4c90efe..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; @@ -404,7 +404,7 @@ PHP_FUNCTION(apache_request_headers) if (!tenv[i].key) { continue; } - if (add_assoc_string(return_value, tenv[i].key, (tenv[i].val==NULL) ? "" : tenv[i].val, 1)==FAILURE) { + if (add_assoc_string(return_value, tenv[i].key, (tenv[i].val==NULL) ? "" : tenv[i].val)==FAILURE) { RETURN_FALSE; } } @@ -424,7 +424,7 @@ PHP_FUNCTION(apache_response_headers) tenv = (table_entry *)env_arr->elts; for (i = 0; i < env_arr->nelts; ++i) { if (!tenv[i].key) continue; - if (add_assoc_string(return_value, tenv[i].key, (tenv[i].val==NULL) ? "" : tenv[i].val, 1)==FAILURE) { + if (add_assoc_string(return_value, tenv[i].key, (tenv[i].val==NULL) ? "" : tenv[i].val)==FAILURE) { RETURN_FALSE; } } @@ -475,34 +475,34 @@ PHP_FUNCTION(apache_lookup_uri) add_property_long(return_value,"status", rr->status); if (rr->the_request) { - add_property_string(return_value,"the_request", rr->the_request, 1); + add_property_string(return_value,"the_request", rr->the_request); } if (rr->status_line) { - add_property_string(return_value,"status_line", (char *)rr->status_line, 1); + add_property_string(return_value,"status_line", (char *)rr->status_line); } if (rr->method) { - add_property_string(return_value,"method", (char *)rr->method, 1); + add_property_string(return_value,"method", (char *)rr->method); } if (rr->content_type) { - add_property_string(return_value,"content_type", (char *)rr->content_type, 1); + add_property_string(return_value,"content_type", (char *)rr->content_type); } if (rr->handler) { - add_property_string(return_value,"handler", (char *)rr->handler, 1); + add_property_string(return_value,"handler", (char *)rr->handler); } if (rr->uri) { - add_property_string(return_value,"uri", rr->uri, 1); + add_property_string(return_value,"uri", rr->uri); } if (rr->filename) { - add_property_string(return_value,"filename", rr->filename, 1); + add_property_string(return_value,"filename", rr->filename); } if (rr->path_info) { - add_property_string(return_value,"path_info", rr->path_info, 1); + add_property_string(return_value,"path_info", rr->path_info); } if (rr->args) { - add_property_string(return_value,"args", rr->args, 1); + add_property_string(return_value,"args", rr->args); } if (rr->boundary) { - add_property_string(return_value,"boundary", rr->boundary, 1); + add_property_string(return_value,"boundary", rr->boundary); } add_property_long(return_value,"no_cache", rr->no_cache); @@ -515,7 +515,7 @@ PHP_FUNCTION(apache_lookup_uri) #if MODULE_MAGIC_NUMBER >= 19980324 if (rr->unparsed_uri) { - add_property_string(return_value,"unparsed_uri", rr->unparsed_uri, 1); + add_property_string(return_value,"unparsed_uri", rr->unparsed_uri); } if(rr->mtime) { add_property_long(return_value,"mtime", rr->mtime); @@ -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; @@ -580,9 +580,9 @@ PHP_FUNCTION(apache_get_modules) for (n = 0; ap_loaded_modules[n]; ++n) { char *s = (char *) ap_loaded_modules[n]->name; if ((p = strchr(s, '.'))) { - add_next_index_stringl(return_value, s, (p - s), 1); + add_next_index_stringl(return_value, s, (p - s)); } else { - add_next_index_string(return_value, s, 1); + add_next_index_string(return_value, s); } } } diff --git a/sapi/apache2filter/apache_config.c b/sapi/apache2filter/apache_config.c index 7c50b9e6a8..6de4b3ab36 100644 --- a/sapi/apache2filter/apache_config.c +++ b/sapi/apache2filter/apache_config.c @@ -137,7 +137,7 @@ void *merge_php_config(apr_pool_t *p, void *base_conf, void *new_conf) zend_hash_move_forward(&d->config)) { pe = NULL; zend_hash_get_current_data(&d->config, (void **) &data); - if (zend_hash_find(&n->config, str, str_len, (void **) &pe) == SUCCESS) { + if ((pe = zend_hash_find(&n->config, str, str_len) != NULL) != NULL) { if (pe->status >= data->status) continue; } zend_hash_update(&n->config, str, str_len, data, sizeof(*data), NULL); @@ -152,7 +152,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_find(&d->config, name, name_len)) != NULL) { return pe->value; } diff --git a/sapi/apache2filter/php_functions.c b/sapi/apache2filter/php_functions.c index f1ae9c974b..3a0b3ee0b9 100644 --- a/sapi/apache2filter/php_functions.c +++ b/sapi/apache2filter/php_functions.c @@ -93,7 +93,7 @@ PHP_FUNCTION(virtual) #define ADD_TIME(name) \ add_property_long(return_value, #name, apr_time_sec(rr->name)); #define ADD_STRING(name) \ - if (rr->name) add_property_string(return_value, #name, (char *) rr->name, 1) + if (rr->name) add_property_string(return_value, #name, (char *) rr->name) PHP_FUNCTION(apache_lookup_uri) { @@ -163,7 +163,7 @@ PHP_FUNCTION(apache_request_headers) APR_ARRAY_FOREACH_OPEN(arr, key, val) if (!val) val = ""; - add_assoc_string(return_value, key, val, 1); + add_assoc_string(return_value, key, val); APR_ARRAY_FOREACH_CLOSE() } /* }}} */ @@ -183,7 +183,7 @@ PHP_FUNCTION(apache_response_headers) APR_ARRAY_FOREACH_OPEN(arr, key, val) if (!val) val = ""; - add_assoc_string(return_value, key, val, 1); + add_assoc_string(return_value, key, val); APR_ARRAY_FOREACH_CLOSE() } /* }}} */ @@ -313,9 +313,9 @@ PHP_FUNCTION(apache_get_modules) for (n = 0; ap_loaded_modules[n]; ++n) { char *s = (char *) ap_loaded_modules[n]->name; if ((p = strchr(s, '.'))) { - add_next_index_stringl(return_value, s, (p - s), 1); + add_next_index_stringl(return_value, s, (p - s)); } else { - add_next_index_string(return_value, s, 1); + add_next_index_string(return_value, s); } } } diff --git a/sapi/apache2filter/sapi_apache2.c b/sapi/apache2filter/sapi_apache2.c index d5bf0d8646..4fd45041ba 100644 --- a/sapi/apache2filter/sapi_apache2.c +++ b/sapi/apache2filter/sapi_apache2.c @@ -248,14 +248,13 @@ php_apache_sapi_register_variables(zval *track_vars_array TSRMLS_DC) } static void -php_apache_sapi_flush(void *server_context) +php_apache_sapi_flush(void *server_context TSRMLS_DC) { php_struct *ctx; apr_bucket_brigade *bb; apr_bucket_alloc_t *ba; apr_bucket *b; ap_filter_t *f; /* output filters */ - TSRMLS_FETCH(); ctx = server_context; 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_apache.h b/sapi/apache2handler/php_apache.h index 34846048b0..10b4186306 100644 --- a/sapi/apache2handler/php_apache.h +++ b/sapi/apache2handler/php_apache.h @@ -25,6 +25,9 @@ #include "http_config.h" #include "http_core.h" +#include "php.h" +#include "main/php_streams.h" + /* Declare this so we can get to it from outside the sapi_apache2.c file */ extern module AP_MODULE_DECLARE_DATA php5_module; @@ -40,7 +43,7 @@ typedef struct php_struct { #if defined(NETWARE) && defined(CLIB_STAT_PATCH) struct stat_libc finfo; #else - struct stat finfo; + php_stat_t finfo; #endif /* Whether or not we've processed PHP in the output filters yet. */ int request_processed; diff --git a/sapi/apache2handler/php_functions.c b/sapi/apache2handler/php_functions.c index 2c57300926..675bb78371 100644 --- a/sapi/apache2handler/php_functions.c +++ b/sapi/apache2handler/php_functions.c @@ -109,11 +109,11 @@ PHP_FUNCTION(virtual) /* }}} */ #define ADD_LONG(name) \ - add_property_long(return_value, #name, rr->name) + add_property_int(return_value, #name, rr->name) #define ADD_TIME(name) \ - add_property_long(return_value, #name, apr_time_sec(rr->name)); + add_property_int(return_value, #name, apr_time_sec(rr->name)); #define ADD_STRING(name) \ - if (rr->name) add_property_string(return_value, #name, (char *) rr->name, 1) + if (rr->name) add_property_string(return_value, #name, (char *) rr->name) PHP_FUNCTION(apache_lookup_uri) { @@ -187,7 +187,7 @@ PHP_FUNCTION(apache_request_headers) APR_ARRAY_FOREACH_OPEN(arr, key, val) if (!val) val = ""; - add_assoc_string(return_value, key, val, 1); + add_assoc_string(return_value, key, val); APR_ARRAY_FOREACH_CLOSE() } /* }}} */ @@ -211,7 +211,7 @@ PHP_FUNCTION(apache_response_headers) APR_ARRAY_FOREACH_OPEN(arr, key, val) if (!val) val = ""; - add_assoc_string(return_value, key, val, 1); + add_assoc_string(return_value, key, val); APR_ARRAY_FOREACH_CLOSE() } /* }}} */ @@ -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; } @@ -355,9 +355,9 @@ PHP_FUNCTION(apache_get_modules) for (n = 0; ap_loaded_modules[n]; ++n) { char *s = (char *) ap_loaded_modules[n]->name; if ((p = strchr(s, '.'))) { - add_next_index_stringl(return_value, s, (p - s), 1); + add_next_index_stringl(return_value, s, (p - s)); } else { - add_next_index_string(return_value, s, 1); + add_next_index_string(return_value, s); } } } @@ -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 a0c24bd0e3..669f25f786 100644 --- a/sapi/apache2handler/sapi_apache2.c +++ b/sapi/apache2handler/sapi_apache2.c @@ -72,8 +72,8 @@ /* A way to specify the location of the php.ini dir in an apache directive */ char *apache2_php_ini_path_override = NULL; -static int -php_apache_sapi_ub_write(const char *str, uint str_length TSRMLS_DC) +static php_size_t +php_apache_sapi_ub_write(const char *str, php_size_t str_length TSRMLS_DC) { request_rec *r; php_struct *ctx; @@ -180,8 +180,8 @@ php_apache_sapi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) return SAPI_HEADER_SENT_SUCCESSFULLY; } -static int -php_apache_sapi_read_post(char *buf, uint count_bytes TSRMLS_DC) +static apr_size_t +php_apache_sapi_read_post(char *buf, php_size_t count_bytes TSRMLS_DC) { apr_size_t len, tlen=0; php_struct *ctx = SG(server_context); @@ -212,7 +212,7 @@ php_apache_sapi_read_post(char *buf, uint count_bytes TSRMLS_DC) return tlen; } -static struct stat* +static php_stat_t* php_apache_sapi_get_stat(TSRMLS_D) { php_struct *ctx = SG(server_context); @@ -270,28 +270,27 @@ php_apache_sapi_register_variables(zval *track_vars_array TSRMLS_DC) php_struct *ctx = SG(server_context); const apr_array_header_t *arr = apr_table_elts(ctx->r->subprocess_env); char *key, *val; - int new_val_len; + php_size_t new_val_len; APR_ARRAY_FOREACH_OPEN(arr, key, val) if (!val) { val = ""; } - if (sapi_module.input_filter(PARSE_SERVER, key, &val, strlen(val), (unsigned int *)&new_val_len TSRMLS_CC)) { + if (sapi_module.input_filter(PARSE_SERVER, key, &val, strlen(val), (php_size_t *)&new_val_len TSRMLS_CC)) { php_register_variable_safe(key, val, new_val_len, track_vars_array TSRMLS_CC); } APR_ARRAY_FOREACH_CLOSE() - if (sapi_module.input_filter(PARSE_SERVER, "PHP_SELF", &ctx->r->uri, strlen(ctx->r->uri), (unsigned int *)&new_val_len TSRMLS_CC)) { + if (sapi_module.input_filter(PARSE_SERVER, "PHP_SELF", &ctx->r->uri, strlen(ctx->r->uri), (php_size_t *)&new_val_len TSRMLS_CC)) { php_register_variable_safe("PHP_SELF", ctx->r->uri, new_val_len, track_vars_array TSRMLS_CC); } } static void -php_apache_sapi_flush(void *server_context) +php_apache_sapi_flush(void *server_context TSRMLS_DC) { php_struct *ctx; request_rec *r; - TSRMLS_FETCH(); ctx = server_context; @@ -515,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; diff --git a/sapi/apache_hooks/mod_php5.c b/sapi/apache_hooks/mod_php5.c index a069e324c1..901d3b57a3 100644 --- a/sapi/apache_hooks/mod_php5.c +++ b/sapi/apache_hooks/mod_php5.c @@ -253,7 +253,7 @@ static int sapi_apache_ub_write(const char *str, uint str_length TSRMLS_DC) /* {{{ sapi_apache_flush */ -static void sapi_apache_flush(void *server_context) +static void sapi_apache_flush(void *server_context TSRMLS_DC) { if (server_context) { #if MODULE_MAGIC_NUMBER > 19970110 diff --git a/sapi/apache_hooks/php_apache.c b/sapi/apache_hooks/php_apache.c index 6531ca20ee..8045bbce32 100644 --- a/sapi/apache_hooks/php_apache.c +++ b/sapi/apache_hooks/php_apache.c @@ -155,15 +155,13 @@ static request_rec *get_apache_request(zval *z TSRMLS_DC) return r; } -/* {{{ php_apache_request_new(request_rec *r) +/* {{{ php_apache_request_new(request_rec *r TSRMLS_DC) * create a new zval-instance for ApacheRequest that wraps request_rec */ -zval *php_apache_request_new(request_rec *r) +zval *php_apache_request_new(request_rec *r TSRMLS_DC) { zval *req; zval *addr; - - TSRMLS_FETCH(); MAKE_STD_ZVAL(addr); Z_TYPE_P(addr) = IS_LONG; @@ -1170,7 +1168,7 @@ PHP_FUNCTION(apache_request_sub_req_lookup_uri) if (!sub_r) { RETURN_FALSE; } - return_value = php_apache_request_new(sub_r); + return_value = php_apache_request_new(sub_r TSRMLS_CC); } /* }}} */ @@ -1196,7 +1194,7 @@ PHP_FUNCTION(apache_request_sub_req_lookup_file) if (!sub_r) { RETURN_FALSE; } - return_value = php_apache_request_new(sub_r); + return_value = php_apache_request_new(sub_r TSRMLS_CC); } /* }}} */ @@ -1222,7 +1220,7 @@ PHP_FUNCTION(apache_request_sub_req_method_uri) if (!sub_r) { RETURN_FALSE; } - return_value = php_apache_request_new(sub_r); + return_value = php_apache_request_new(sub_r TSRMLS_CC); } /* }}} */ @@ -1403,7 +1401,7 @@ static PHP_MINIT_FUNCTION(apache) le_apachereq = zend_register_list_destructors_ex(php_apache_request_free, NULL, "ApacheRequest", module_number); INIT_OVERLOADED_CLASS_ENTRY(ce, "ApacheRequest", php_apache_request_class_functions, NULL, NULL, NULL); - apacherequest_class_entry = zend_register_internal_class_ex(&ce, NULL, NULL TSRMLS_CC); + apacherequest_class_entry = zend_register_internal_class_ex(&ce, NULL TSRMLS_CC); REGISTER_LONG_CONSTANT("OK", OK, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("DECLINED", DECLINED, CONST_CS | CONST_PERSISTENT); @@ -1766,7 +1764,7 @@ static void apache_table_to_zval(table *t, zval *return_value) if (!tenv[i].key) { continue; } - if (add_assoc_string(return_value, tenv[i].key, (tenv[i].val==NULL) ? "" : tenv[i].val, 1)==FAILURE) { + if (add_assoc_string(return_value, tenv[i].key, (tenv[i].val==NULL) ? "" : tenv[i].val)==FAILURE) { RETURN_FALSE; } } @@ -1850,34 +1848,34 @@ PHP_FUNCTION(apache_lookup_uri) add_property_long(return_value,"status", rr->status); if (rr->the_request) { - add_property_string(return_value,"the_request", rr->the_request, 1); + add_property_string(return_value,"the_request", rr->the_request); } if (rr->status_line) { - add_property_string(return_value,"status_line", (char *)rr->status_line, 1); + add_property_string(return_value,"status_line", (char *)rr->status_line); } if (rr->method) { - add_property_string(return_value,"method", (char *)rr->method, 1); + add_property_string(return_value,"method", (char *)rr->method); } if (rr->content_type) { - add_property_string(return_value,"content_type", (char *)rr->content_type, 1); + add_property_string(return_value,"content_type", (char *)rr->content_type); } if (rr->handler) { - add_property_string(return_value,"handler", (char *)rr->handler, 1); + add_property_string(return_value,"handler", (char *)rr->handler); } if (rr->uri) { - add_property_string(return_value,"uri", rr->uri, 1); + add_property_string(return_value,"uri", rr->uri); } if (rr->filename) { - add_property_string(return_value,"filename", rr->filename, 1); + add_property_string(return_value,"filename", rr->filename); } if (rr->path_info) { - add_property_string(return_value,"path_info", rr->path_info, 1); + add_property_string(return_value,"path_info", rr->path_info); } if (rr->args) { - add_property_string(return_value,"args", rr->args, 1); + add_property_string(return_value,"args", rr->args); } if (rr->boundary) { - add_property_string(return_value,"boundary", rr->boundary, 1); + add_property_string(return_value,"boundary", rr->boundary); } add_property_long(return_value,"no_cache", rr->no_cache); add_property_long(return_value,"no_local_copy", rr->no_local_copy); @@ -1889,7 +1887,7 @@ PHP_FUNCTION(apache_lookup_uri) #if MODULE_MAGIC_NUMBER >= 19980324 if (rr->unparsed_uri) { - add_property_string(return_value,"unparsed_uri", rr->unparsed_uri, 1); + add_property_string(return_value,"unparsed_uri", rr->unparsed_uri); } if(rr->mtime) { add_property_long(return_value,"mtime", rr->mtime); @@ -1954,9 +1952,9 @@ PHP_FUNCTION(apache_get_modules) for (n = 0; ap_loaded_modules[n]; ++n) { char *s = (char *) ap_loaded_modules[n]->name; if ((p = strchr(s, '.'))) { - add_next_index_stringl(return_value, s, (p - s), 1); + add_next_index_stringl(return_value, s, (p - s)); } else { - add_next_index_string(return_value, s, 1); + add_next_index_string(return_value, s); } } } diff --git a/sapi/caudium/caudium.c b/sapi/caudium/caudium.c index e707f3576e..946f7a039e 100644 --- a/sapi/caudium/caudium.c +++ b/sapi/caudium/caudium.c @@ -395,11 +395,10 @@ php_caudium_sapi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) * the client. Used for POST/PUT requests. */ -INLINE static int php_caudium_low_read_post(char *buf, uint count_bytes) +INLINE static int php_caudium_low_read_post(char *buf, uint count_bytes TSRMLS_DC) { uint total_read = 0; GET_THIS(); - TSRMLS_FETCH(); if(!MY_FD_OBJ->prog) { @@ -423,7 +422,7 @@ static int php_caudium_sapi_read_post(char *buf, uint count_bytes TSRMLS_DC) { uint total_read = 0; - THREAD_SAFE_RUN(total_read = php_caudium_low_read_post(buf, count_bytes), "read post"); + THREAD_SAFE_RUN(total_read = php_caudium_low_read_post(buf, count_bytes TSRMLS_CC), "read post"); return total_read; } diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index 437d09cf32..9d30b53cfc 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -187,10 +187,12 @@ typedef struct _user_config_cache_entry { HashTable *user_config; } user_config_cache_entry; -static void user_config_cache_entry_dtor(user_config_cache_entry *entry) +static void user_config_cache_entry_dtor(zval *el) { + user_config_cache_entry *entry = (user_config_cache_entry *)Z_PTR_P(el); zend_hash_destroy(entry->user_config); free(entry->user_config); + free(entry); } /* }}} */ @@ -215,30 +217,30 @@ static php_cgi_globals_struct php_cgi_globals; #define TRANSLATE_SLASHES(path) #endif -static int print_module_info(zend_module_entry *module, void *arg TSRMLS_DC) +static int print_module_info(zval *element TSRMLS_DC) { + zend_module_entry *module = Z_PTR_P(element); php_printf("%s\n", module->name); - return 0; + return ZEND_HASH_APPLY_KEEP; } static int module_name_cmp(const void *a, const void *b TSRMLS_DC) { - Bucket *f = *((Bucket **) a); - Bucket *s = *((Bucket **) b); + Bucket *f = (Bucket *) a; + Bucket *s = (Bucket *) b; - return strcasecmp( ((zend_module_entry *)f->pData)->name, - ((zend_module_entry *)s->pData)->name); + return strcasecmp( ((zend_module_entry *)Z_PTR(f->val))->name, + ((zend_module_entry *)Z_PTR(s->val))->name); } static void print_modules(TSRMLS_D) { HashTable sorted_registry; - zend_module_entry tmp; - zend_hash_init(&sorted_registry, 50, NULL, NULL, 1); - zend_hash_copy(&sorted_registry, &module_registry, NULL, &tmp, sizeof(zend_module_entry)); + zend_hash_init(&sorted_registry, 64, NULL, NULL, 1); + zend_hash_copy(&sorted_registry, &module_registry, NULL); zend_hash_sort(&sorted_registry, zend_qsort, module_name_cmp, 0 TSRMLS_CC); - zend_hash_apply_with_argument(&sorted_registry, (apply_func_arg_t) print_module_info, NULL TSRMLS_CC); + zend_hash_apply(&sorted_registry, print_module_info TSRMLS_CC); zend_hash_destroy(&sorted_registry); } @@ -272,7 +274,7 @@ static void print_extensions(TSRMLS_D) static inline size_t sapi_cgi_single_write(const char *str, uint str_length TSRMLS_DC) { #ifdef PHP_WRITE_STDOUT - long ret; + int ret; ret = write(STDOUT_FILENO, str, str_length); if (ret <= 0) return 0; @@ -285,10 +287,10 @@ static inline size_t sapi_cgi_single_write(const char *str, uint str_length TSRM #endif } -static int sapi_cgi_ub_write(const char *str, uint str_length TSRMLS_DC) +static php_size_t sapi_cgi_ub_write(const char *str, php_size_t str_length TSRMLS_DC) { const char *ptr = str; - uint remaining = str_length; + php_size_t remaining = str_length; size_t ret; while (remaining > 0) { @@ -304,14 +306,14 @@ static int sapi_cgi_ub_write(const char *str, uint str_length TSRMLS_DC) return str_length; } -static int sapi_fcgi_ub_write(const char *str, uint str_length TSRMLS_DC) +static php_size_t sapi_fcgi_ub_write(const char *str, php_size_t str_length TSRMLS_DC) { const char *ptr = str; - uint remaining = str_length; + php_size_t remaining = str_length; fcgi_request *request = (fcgi_request*) SG(server_context); while (remaining > 0) { - long ret = fcgi_write(request, FCGI_STDOUT, ptr, remaining); + php_int_t ret = fcgi_write(request, FCGI_STDOUT, ptr, remaining); if (ret <= 0) { php_handle_aborted_connection(); @@ -324,14 +326,14 @@ static int sapi_fcgi_ub_write(const char *str, uint str_length TSRMLS_DC) return str_length; } -static void sapi_cgi_flush(void *server_context) +static void sapi_cgi_flush(void *server_context TSRMLS_DC) { if (fflush(stdout) == EOF) { php_handle_aborted_connection(); } } -static void sapi_fcgi_flush(void *server_context) +static void sapi_fcgi_flush(void *server_context TSRMLS_DC) { fcgi_request *request = (fcgi_request*) server_context; @@ -503,9 +505,9 @@ static int sapi_cgi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) # define STDIN_FILENO 0 #endif -static int sapi_cgi_read_post(char *buffer, uint count_bytes TSRMLS_DC) +static php_size_t sapi_cgi_read_post(char *buffer, php_size_t count_bytes TSRMLS_DC) { - uint read_bytes = 0; + php_size_t read_bytes = 0; int tmp_read_bytes; count_bytes = MIN(count_bytes, SG(request_info).content_length - SG(read_post_bytes)); @@ -519,9 +521,9 @@ static int sapi_cgi_read_post(char *buffer, uint count_bytes TSRMLS_DC) return read_bytes; } -static int sapi_fcgi_read_post(char *buffer, uint count_bytes TSRMLS_DC) +static php_size_t sapi_fcgi_read_post(char *buffer, php_size_t count_bytes TSRMLS_DC) { - uint read_bytes = 0; + php_size_t read_bytes = 0; int tmp_read_bytes; fcgi_request *request = (fcgi_request*) SG(server_context); size_t remaining = SG(request_info).content_length - SG(read_post_bytes); @@ -619,8 +621,8 @@ static char *sapi_fcgi_read_cookies(TSRMLS_D) static void cgi_php_load_env_var(char *var, unsigned int var_len, char *val, unsigned int val_len, void *arg TSRMLS_DC) { zval *array_ptr = (zval*)arg; - int filter_arg = (array_ptr == PG(http_globals)[TRACK_VARS_ENV])?PARSE_ENV:PARSE_SERVER; - unsigned int new_val_len; + int filter_arg = (Z_ARR_P(array_ptr) == Z_ARR(PG(http_globals)[TRACK_VARS_ENV]))?PARSE_ENV:PARSE_SERVER; + php_size_t new_val_len; if (sapi_module.input_filter(filter_arg, var, &val, strlen(val), &new_val_len TSRMLS_CC)) { php_register_variable_safe(var, val, new_val_len, array_ptr TSRMLS_CC); @@ -629,25 +631,19 @@ static void cgi_php_load_env_var(char *var, unsigned int var_len, char *val, uns static void cgi_php_import_environment_variables(zval *array_ptr TSRMLS_DC) { - if (PG(http_globals)[TRACK_VARS_ENV] && - array_ptr != PG(http_globals)[TRACK_VARS_ENV] && - Z_TYPE_P(PG(http_globals)[TRACK_VARS_ENV]) == IS_ARRAY && - zend_hash_num_elements(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_ENV])) > 0 + if (Z_TYPE(PG(http_globals)[TRACK_VARS_ENV]) == IS_ARRAY && + Z_ARR_P(array_ptr) != Z_ARR(PG(http_globals)[TRACK_VARS_ENV]) && + zend_hash_num_elements(Z_ARRVAL(PG(http_globals)[TRACK_VARS_ENV])) > 0 ) { zval_dtor(array_ptr); - *array_ptr = *PG(http_globals)[TRACK_VARS_ENV]; - INIT_PZVAL(array_ptr); - zval_copy_ctor(array_ptr); + ZVAL_DUP(array_ptr, &PG(http_globals)[TRACK_VARS_ENV]); return; - } else if (PG(http_globals)[TRACK_VARS_SERVER] && - array_ptr != PG(http_globals)[TRACK_VARS_SERVER] && - Z_TYPE_P(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY && - zend_hash_num_elements(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER])) > 0 + } else if (Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY && + Z_ARR_P(array_ptr) != Z_ARR(PG(http_globals)[TRACK_VARS_SERVER]) && + zend_hash_num_elements(Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER])) > 0 ) { zval_dtor(array_ptr); - *array_ptr = *PG(http_globals)[TRACK_VARS_SERVER]; - INIT_PZVAL(array_ptr); - zval_copy_ctor(array_ptr); + ZVAL_DUP(array_ptr, &PG(http_globals)[TRACK_VARS_SERVER]); return; } @@ -662,7 +658,7 @@ static void cgi_php_import_environment_variables(zval *array_ptr TSRMLS_DC) static void sapi_cgi_register_variables(zval *track_vars_array TSRMLS_DC) { - unsigned int php_self_len; + php_size_t php_self_len; char *php_self; /* In CGI mode, we consider the environment to be a part of the server @@ -758,13 +754,12 @@ static void php_cgi_ini_activate_user_config(char *path, int path_len, const cha time_t request_time = sapi_get_request_time(TSRMLS_C); /* Find cached config entry: If not found, create one */ - if (zend_hash_find(&CGIG(user_config_cache), path, path_len + 1, (void **) &entry) == FAILURE) { + if ((entry = zend_hash_str_find_ptr(&CGIG(user_config_cache), path, path_len)) == NULL) { new_entry = pemalloc(sizeof(user_config_cache_entry), 1); new_entry->expires = 0; new_entry->user_config = (HashTable *) pemalloc(sizeof(HashTable), 1); - zend_hash_init(new_entry->user_config, 0, NULL, (dtor_func_t) config_zval_dtor, 1); - zend_hash_update(&CGIG(user_config_cache), path, path_len + 1, new_entry, sizeof(user_config_cache_entry), (void **) &entry); - free(new_entry); + zend_hash_init(new_entry->user_config, 8, NULL, (dtor_func_t) config_zval_dtor, 1); + entry = zend_hash_str_update_ptr(&CGIG(user_config_cache), path, path_len, new_entry); } /* Check whether cache entry has expired and rescan if it is */ @@ -852,7 +847,7 @@ static int sapi_cgi_activate(TSRMLS_D) server_name_len = strlen(server_name); server_name = estrndup(server_name, server_name_len); zend_str_tolower(server_name, server_name_len); - php_ini_activate_per_host_config(server_name, server_name_len + 1 TSRMLS_CC); + php_ini_activate_per_host_config(server_name, server_name_len TSRMLS_CC); efree(server_name); } } @@ -928,7 +923,7 @@ static int sapi_cgi_deactivate(TSRMLS_D) php_handle_aborted_connection(); } } else { - sapi_cgi_flush(SG(server_context)); + sapi_cgi_flush(SG(server_context) TSRMLS_CC); } } return SUCCESS; @@ -1189,7 +1184,7 @@ static void init_request_info(fcgi_request *request TSRMLS_DC) #endif if (CGIG(fix_pathinfo)) { - struct stat st; + php_stat_t st; char *real_path = NULL; char *env_redirect_url = CGI_GETENV("REDIRECT_URL"); char *env_document_root = CGI_GETENV("DOCUMENT_ROOT"); @@ -1243,7 +1238,7 @@ static void init_request_info(fcgi_request *request TSRMLS_DC) while ((ptr = strrchr(pt, '/')) || (ptr = strrchr(pt, '\\'))) { *ptr = 0; - if (stat(pt, &st) == 0 && S_ISREG(st.st_mode)) { + if (zend_stat(pt, &st) == 0 && S_ISREG(st.st_mode)) { /* * okay, we found the base script! * work out how many chars we had to strip off; @@ -1482,7 +1477,7 @@ static void php_cgi_globals_ctor(php_cgi_globals_struct *php_cgi_globals TSRMLS_ #ifdef PHP_WIN32 php_cgi_globals->impersonate = 0; #endif - zend_hash_init(&php_cgi_globals->user_config_cache, 0, NULL, (dtor_func_t) user_config_cache_entry_dtor, 1); + zend_hash_init(&php_cgi_globals->user_config_cache, 8, NULL, user_config_cache_entry_dtor, 1); } /* }}} */ @@ -1571,7 +1566,7 @@ static void add_request_header(char *var, unsigned int var_len, char *val, unsig } else { return; } - add_assoc_stringl_ex(return_value, var, var_len+1, val, val_len, 1); + add_assoc_stringl_ex(return_value, var, var_len+1, val, val_len); if (str) { free_alloca(var, use_heap); } @@ -1592,7 +1587,7 @@ PHP_FUNCTION(apache_request_headers) /* {{{ */ char buf[128]; char **env, *p, *q, *var, *val, *t = buf; size_t alloc_size = sizeof(buf); - unsigned long var_len; + php_uint_t var_len; for (env = environ; env != NULL && *env != NULL; env++) { val = strchr(*env, '='); @@ -1652,7 +1647,7 @@ PHP_FUNCTION(apache_request_headers) /* {{{ */ continue; } val++; - add_assoc_string_ex(return_value, var, var_len+1, val, 1); + add_assoc_string_ex(return_value, var, var_len, val); } if (t != buf && t != NULL) { efree(t); @@ -1681,7 +1676,7 @@ static void add_response_header(sapi_header_struct *h, zval *return_value TSRMLS do { p++; } while (*p == ' ' || *p == '\t'); - add_assoc_stringl_ex(return_value, s, len+1, p, h->header_len - (p - h->header), 1); + add_assoc_stringl_ex(return_value, s, len, p, h->header_len - (p - h->header)); free_alloca(s, use_heap); } } @@ -2240,7 +2235,7 @@ consult the installation file that came with this distribution, or visit \n\ break; case 'z': /* load extension file */ - zend_load_extension(php_optarg); + zend_load_extension(php_optarg TSRMLS_CC); break; default: @@ -2250,7 +2245,7 @@ consult the installation file that came with this distribution, or visit \n\ if (script_file) { /* override path_translated if -f on command line */ - STR_FREE(SG(request_info).path_translated); + if (SG(request_info).path_translated) efree(SG(request_info).path_translated); SG(request_info).path_translated = script_file; /* before registering argv to module exchange the *new* argv[0] */ /* we can achieve this without allocating more memory */ @@ -2259,7 +2254,7 @@ consult the installation file that came with this distribution, or visit \n\ SG(request_info).argv[0] = script_file; } else if (argc > php_optind) { /* file is on command line, but not in -f opt */ - STR_FREE(SG(request_info).path_translated); + if (SG(request_info).path_translated) efree(SG(request_info).path_translated); SG(request_info).path_translated = estrdup(argv[php_optind]); /* arguments after the file are considered script args */ SG(request_info).argc = argc - php_optind; @@ -2362,7 +2357,7 @@ consult the installation file that came with this distribution, or visit \n\ goto fastcgi_request_done; } - STR_FREE(SG(request_info).path_translated); + if (SG(request_info).path_translated) efree(SG(request_info).path_translated); if (free_query_string && SG(request_info).query_string) { free(SG(request_info).query_string); @@ -2421,7 +2416,7 @@ consult the installation file that came with this distribution, or visit \n\ /* handle situations where line is terminated by \r\n */ if (c == '\r') { if (php_stream_getc((php_stream*)file_handle.handle.stream.handle) != '\n') { - long pos = php_stream_tell((php_stream*)file_handle.handle.stream.handle); + php_off_t pos = php_stream_tell((php_stream*)file_handle.handle.stream.handle); php_stream_seek((php_stream*)file_handle.handle.stream.handle, pos - 1, SEEK_SET); } } @@ -2493,7 +2488,7 @@ consult the installation file that came with this distribution, or visit \n\ /* Zeev might want to do something with this one day */ case PHP_MODE_INDENT: open_file_for_scanning(&file_handle TSRMLS_CC); - zend_indent(); + zend_indent(TSRMLS_C); zend_file_handle_dtor(&file_handle TSRMLS_CC); php_output_teardown(); return SUCCESS; @@ -2503,7 +2498,7 @@ consult the installation file that came with this distribution, or visit \n\ fastcgi_request_done: { - STR_FREE(SG(request_info).path_translated); + if (SG(request_info).path_translated) efree(SG(request_info).path_translated); php_request_shutdown((void *) 0); diff --git a/sapi/cgi/config.w32 b/sapi/cgi/config.w32 index 8d1d431da4..55a2fba48f 100644 --- a/sapi/cgi/config.w32 +++ b/sapi/cgi/config.w32 @@ -4,7 +4,7 @@ ARG_ENABLE('cgi', 'Build CGI version of PHP', 'yes'); if (PHP_CGI == "yes") { - ADD_FLAG("LDFLAGS_CGI", "/stack:8388608"); + ADD_FLAG("LDFLAGS_CGI", "/stack:67108864"); SAPI('cgi', 'cgi_main.c fastcgi.c', 'php-cgi.exe'); ADD_FLAG('LIBS_CGI', 'ws2_32.lib kernel32.lib advapi32.lib'); } diff --git a/sapi/cgi/fastcgi.c b/sapi/cgi/fastcgi.c index 8ddc2e4577..45f809f5b3 100644 --- a/sapi/cgi/fastcgi.c +++ b/sapi/cgi/fastcgi.c @@ -19,6 +19,7 @@ /* $Id$ */ #include "php.h" +#include "php_network.h" #include "fastcgi.h" #include <string.h> @@ -411,7 +412,7 @@ int fcgi_init(void) sa_t sa; socklen_t len = sizeof(sa); #endif - zend_hash_init(&fcgi_mgmt_vars, 0, NULL, fcgi_free_mgmt_var_cb, 1); + zend_hash_init(&fcgi_mgmt_vars, 8, NULL, fcgi_free_mgmt_var_cb, 1); fcgi_set_mgmt_var("FCGI_MPXS_CONNS", sizeof("FCGI_MPXS_CONNS")-1, "0", sizeof("0")-1); is_initialized = 1; @@ -973,7 +974,7 @@ static int fcgi_read_request(fcgi_request *req) } } else if (hdr.type == FCGI_GET_VALUES) { unsigned char *p = buf + sizeof(fcgi_header); - zval ** value; + zval *value; unsigned int zlen; fcgi_hash_bucket *q; @@ -989,10 +990,10 @@ static int fcgi_read_request(fcgi_request *req) q = req->env.list; while (q != NULL) { - if (zend_hash_find(&fcgi_mgmt_vars, q->var, q->var_len, (void**) &value) != SUCCESS) { + if ((value = zend_hash_str_find(&fcgi_mgmt_vars, q->var, q->var_len)) == NULL) { continue; } - zlen = Z_STRLEN_PP(value); + zlen = Z_STRSIZE_P(value); if ((p + 4 + 4 + q->var_len + zlen) >= (buf + sizeof(buf))) { break; } @@ -1014,7 +1015,7 @@ static int fcgi_read_request(fcgi_request *req) } memcpy(p, q->var, q->var_len); p += q->var_len; - memcpy(p, Z_STRVAL_PP(value), zlen); + memcpy(p, Z_STRVAL_P(value), zlen); p += zlen; } len = p - buf - sizeof(fcgi_header); @@ -1112,7 +1113,7 @@ static inline void fcgi_close(fcgi_request *req, int force, int destroy) shutdown(req->fd, 1); /* read the last FCGI_STDIN header (it may be omitted) */ - recv(req->fd, &buf, sizeof(buf), 0); + recv(req->fd, (char *)&buf, sizeof(buf), 0); } closesocket(req->fd); } @@ -1510,19 +1511,14 @@ void fcgi_impersonate(void) void fcgi_set_mgmt_var(const char * name, size_t name_len, const char * value, size_t value_len) { - zval * zvalue; - zvalue = pemalloc(sizeof(*zvalue), 1); - Z_TYPE_P(zvalue) = IS_STRING; - Z_STRVAL_P(zvalue) = pestrndup(value, value_len, 1); - Z_STRLEN_P(zvalue) = value_len; - zend_hash_add(&fcgi_mgmt_vars, name, name_len, &zvalue, sizeof(zvalue), NULL); + zval zvalue; + ZVAL_NEW_STR(&zvalue, STR_INIT(value, value_len, 1)); + zend_hash_str_add(&fcgi_mgmt_vars, name, name_len, &zvalue); } -void fcgi_free_mgmt_var_cb(void * ptr) +void fcgi_free_mgmt_var_cb(zval *zv) { - zval ** var = (zval **)ptr; - pefree(Z_STRVAL_PP(var), 1); - pefree(*var, 1); + pefree(Z_STR_P(zv), 1); } /* diff --git a/sapi/cgi/fastcgi.h b/sapi/cgi/fastcgi.h index 702f51df6b..d5f141cd1b 100644 --- a/sapi/cgi/fastcgi.h +++ b/sapi/cgi/fastcgi.h @@ -139,7 +139,7 @@ void fcgi_impersonate(void); #endif void fcgi_set_mgmt_var(const char * name, size_t name_len, const char * value, size_t value_len); -void fcgi_free_mgmt_var_cb(void * ptr); +void fcgi_free_mgmt_var_cb(zval *zv); /* * Local variables: diff --git a/sapi/cli/cli.h b/sapi/cli/cli.h index dc85893a0b..8840ac01cc 100644 --- a/sapi/cli/cli.h +++ b/sapi/cli/cli.h @@ -30,11 +30,11 @@ #endif -extern PHP_CLI_API size_t sapi_cli_single_write(const char *str, uint str_length TSRMLS_DC); +extern PHP_CLI_API size_t sapi_cli_single_write(const char *str, php_size_t str_length TSRMLS_DC); typedef struct { - size_t (*cli_shell_write)(const char *str, uint str_length TSRMLS_DC); - int (*cli_shell_ub_write)(const char *str, uint str_length TSRMLS_DC); + php_size_t (*cli_shell_write)(const char *str, php_size_t str_length TSRMLS_DC); + php_size_t (*cli_shell_ub_write)(const char *str, php_size_t str_length TSRMLS_DC); int (*cli_shell_run)(TSRMLS_D); } cli_shell_callbacks_t; diff --git a/sapi/cli/config.w32 b/sapi/cli/config.w32 index adcbb2b496..438c9e6d62 100644 --- a/sapi/cli/config.w32 +++ b/sapi/cli/config.w32 @@ -11,11 +11,11 @@ if (PHP_CLI == "yes") { if (PHP_CRT_DEBUG == "yes") { ADD_FLAG("CFLAGS_CLI", "/D PHP_WIN32_DEBUG_HEAP"); } - ADD_FLAG("LDFLAGS_CLI", "/stack:8388608"); + ADD_FLAG("LDFLAGS_CLI", "/stack:67108864"); } if (PHP_CLI_WIN32 == "yes") { SAPI('cli_win32', 'cli_win32.c php_cli_process_title.c ps_title.c', 'php-win.exe'); - ADD_FLAG("LDFLAGS_CLI_WIN32", "/stack:8388608"); + ADD_FLAG("LDFLAGS_CLI_WIN32", "/stack:67108864"); } diff --git a/sapi/cli/generate_mime_type_map.php b/sapi/cli/generate_mime_type_map.php new file mode 100644 index 0000000000..4475004985 --- /dev/null +++ b/sapi/cli/generate_mime_type_map.php @@ -0,0 +1,76 @@ +#!/usr/bin/env php +<?php + +// Check if we are being given a mime.types file or if we should use the +// default URL. +$source = count($_SERVER['argv']) > 1 ? $_SERVER['argv'][1] : 'https://raw.githubusercontent.com/apache/httpd/trunk/docs/conf/mime.types'; + +// See if we can actually load it. +$types = @file($source); +if ($types === false) { + fprintf(STDERR, "Error: unable to read $source\n"); + exit(1); +} + +// Remove comments and flip into an extensions array. +$extensions = []; +array_walk($types, function ($line) use (&$extensions) { + $line = trim($line); + if ($line && $line[0] != '#') { + $fields = preg_split('/\s+/', $line); + if (count($fields) > 1) { + $mime = array_shift($fields); + foreach ($fields as $extension) { + $extensions[$extension] = $mime; + } + } + } +}); + +?> +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2014 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Moriyoshi Koizumi <moriyoshi@php.net> | + +----------------------------------------------------------------------+ +*/ + +/* This is a generated file. Rather than modifying it, please run + * "php generate_mime_type_map.php > mime_type_map.h" to regenerate the file. */ + +#ifndef PHP_CLI_SERVER_MIME_TYPE_MAP_H +#define PHP_CLI_SERVER_MIME_TYPE_MAP_H + +typedef struct php_cli_server_ext_mime_type_pair { + const char *ext; + const char *mime_type; +} php_cli_server_ext_mime_type_pair; + +static php_cli_server_ext_mime_type_pair mime_type_map[] = { +<?php foreach ($extensions as $extension => $mime): ?> + { "<?= addcslashes($extension, "\0..\37!@\@\177..\377") ?>", "<?= addcslashes($mime, "\0..\37!@\@\177..\377") ?>" }, +<?php endforeach ?> + { NULL, NULL } +}; + +#endif /* PHP_CLI_SERVER_MIME_TYPE_MAP_H */ + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: noet sw=4 ts=4 fdm=marker + * vim<600: noet sw=4 ts=4 + */ diff --git a/sapi/cli/mime_type_map.h b/sapi/cli/mime_type_map.h new file mode 100644 index 0000000000..72c05d4149 --- /dev/null +++ b/sapi/cli/mime_type_map.h @@ -0,0 +1,1024 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2014 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Moriyoshi Koizumi <moriyoshi@php.net> | + +----------------------------------------------------------------------+ +*/ + +/* This is a generated file. Rather than modifying it, please run + * "php generate_mime_type_map.php > mime_type_map.h" to regenerate the file. */ + +#ifndef PHP_CLI_SERVER_MIME_TYPE_MAP_H +#define PHP_CLI_SERVER_MIME_TYPE_MAP_H + +typedef struct php_cli_server_ext_mime_type_pair { + const char *ext; + const char *mime_type; +} php_cli_server_ext_mime_type_pair; + +static php_cli_server_ext_mime_type_pair mime_type_map[] = { + { "ez", "application/andrew-inset" }, + { "aw", "application/applixware" }, + { "atom", "application/atom+xml" }, + { "atomcat", "application/atomcat+xml" }, + { "atomsvc", "application/atomsvc+xml" }, + { "ccxml", "application/ccxml+xml" }, + { "cdmia", "application/cdmi-capability" }, + { "cdmic", "application/cdmi-container" }, + { "cdmid", "application/cdmi-domain" }, + { "cdmio", "application/cdmi-object" }, + { "cdmiq", "application/cdmi-queue" }, + { "cu", "application/cu-seeme" }, + { "davmount", "application/davmount+xml" }, + { "dbk", "application/docbook+xml" }, + { "dssc", "application/dssc+der" }, + { "xdssc", "application/dssc+xml" }, + { "ecma", "application/ecmascript" }, + { "emma", "application/emma+xml" }, + { "epub", "application/epub+zip" }, + { "exi", "application/exi" }, + { "pfr", "application/font-tdpfr" }, + { "gml", "application/gml+xml" }, + { "gpx", "application/gpx+xml" }, + { "gxf", "application/gxf" }, + { "stk", "application/hyperstudio" }, + { "ink", "application/inkml+xml" }, + { "inkml", "application/inkml+xml" }, + { "ipfix", "application/ipfix" }, + { "jar", "application/java-archive" }, + { "ser", "application/java-serialized-object" }, + { "class", "application/java-vm" }, + { "js", "application/javascript" }, + { "json", "application/json" }, + { "jsonml", "application/jsonml+json" }, + { "lostxml", "application/lost+xml" }, + { "hqx", "application/mac-binhex40" }, + { "cpt", "application/mac-compactpro" }, + { "mads", "application/mads+xml" }, + { "mrc", "application/marc" }, + { "mrcx", "application/marcxml+xml" }, + { "ma", "application/mathematica" }, + { "nb", "application/mathematica" }, + { "mb", "application/mathematica" }, + { "mathml", "application/mathml+xml" }, + { "mbox", "application/mbox" }, + { "mscml", "application/mediaservercontrol+xml" }, + { "metalink", "application/metalink+xml" }, + { "meta4", "application/metalink4+xml" }, + { "mets", "application/mets+xml" }, + { "mods", "application/mods+xml" }, + { "m21", "application/mp21" }, + { "mp21", "application/mp21" }, + { "mp4s", "application/mp4" }, + { "doc", "application/msword" }, + { "dot", "application/msword" }, + { "mxf", "application/mxf" }, + { "bin", "application/octet-stream" }, + { "dms", "application/octet-stream" }, + { "lrf", "application/octet-stream" }, + { "mar", "application/octet-stream" }, + { "so", "application/octet-stream" }, + { "dist", "application/octet-stream" }, + { "distz", "application/octet-stream" }, + { "pkg", "application/octet-stream" }, + { "bpk", "application/octet-stream" }, + { "dump", "application/octet-stream" }, + { "elc", "application/octet-stream" }, + { "deploy", "application/octet-stream" }, + { "oda", "application/oda" }, + { "opf", "application/oebps-package+xml" }, + { "ogx", "application/ogg" }, + { "omdoc", "application/omdoc+xml" }, + { "onetoc", "application/onenote" }, + { "onetoc2", "application/onenote" }, + { "onetmp", "application/onenote" }, + { "onepkg", "application/onenote" }, + { "oxps", "application/oxps" }, + { "xer", "application/patch-ops-error+xml" }, + { "pdf", "application/pdf" }, + { "pgp", "application/pgp-encrypted" }, + { "asc", "application/pgp-signature" }, + { "sig", "application/pgp-signature" }, + { "prf", "application/pics-rules" }, + { "p10", "application/pkcs10" }, + { "p7m", "application/pkcs7-mime" }, + { "p7c", "application/pkcs7-mime" }, + { "p7s", "application/pkcs7-signature" }, + { "p8", "application/pkcs8" }, + { "ac", "application/pkix-attr-cert" }, + { "cer", "application/pkix-cert" }, + { "crl", "application/pkix-crl" }, + { "pkipath", "application/pkix-pkipath" }, + { "pki", "application/pkixcmp" }, + { "pls", "application/pls+xml" }, + { "ai", "application/postscript" }, + { "eps", "application/postscript" }, + { "ps", "application/postscript" }, + { "cww", "application/prs.cww" }, + { "pskcxml", "application/pskc+xml" }, + { "rdf", "application/rdf+xml" }, + { "rif", "application/reginfo+xml" }, + { "rnc", "application/relax-ng-compact-syntax" }, + { "rl", "application/resource-lists+xml" }, + { "rld", "application/resource-lists-diff+xml" }, + { "rs", "application/rls-services+xml" }, + { "gbr", "application/rpki-ghostbusters" }, + { "mft", "application/rpki-manifest" }, + { "roa", "application/rpki-roa" }, + { "rsd", "application/rsd+xml" }, + { "rss", "application/rss+xml" }, + { "rtf", "application/rtf" }, + { "sbml", "application/sbml+xml" }, + { "scq", "application/scvp-cv-request" }, + { "scs", "application/scvp-cv-response" }, + { "spq", "application/scvp-vp-request" }, + { "spp", "application/scvp-vp-response" }, + { "sdp", "application/sdp" }, + { "setpay", "application/set-payment-initiation" }, + { "setreg", "application/set-registration-initiation" }, + { "shf", "application/shf+xml" }, + { "smi", "application/smil+xml" }, + { "smil", "application/smil+xml" }, + { "rq", "application/sparql-query" }, + { "srx", "application/sparql-results+xml" }, + { "gram", "application/srgs" }, + { "grxml", "application/srgs+xml" }, + { "sru", "application/sru+xml" }, + { "ssdl", "application/ssdl+xml" }, + { "ssml", "application/ssml+xml" }, + { "tei", "application/tei+xml" }, + { "teicorpus", "application/tei+xml" }, + { "tfi", "application/thraud+xml" }, + { "tsd", "application/timestamped-data" }, + { "plb", "application/vnd.3gpp.pic-bw-large" }, + { "psb", "application/vnd.3gpp.pic-bw-small" }, + { "pvb", "application/vnd.3gpp.pic-bw-var" }, + { "tcap", "application/vnd.3gpp2.tcap" }, + { "pwn", "application/vnd.3m.post-it-notes" }, + { "aso", "application/vnd.accpac.simply.aso" }, + { "imp", "application/vnd.accpac.simply.imp" }, + { "acu", "application/vnd.acucobol" }, + { "atc", "application/vnd.acucorp" }, + { "acutc", "application/vnd.acucorp" }, + { "air", "application/vnd.adobe.air-application-installer-package+zip" }, + { "fcdt", "application/vnd.adobe.formscentral.fcdt" }, + { "fxp", "application/vnd.adobe.fxp" }, + { "fxpl", "application/vnd.adobe.fxp" }, + { "xdp", "application/vnd.adobe.xdp+xml" }, + { "xfdf", "application/vnd.adobe.xfdf" }, + { "ahead", "application/vnd.ahead.space" }, + { "azf", "application/vnd.airzip.filesecure.azf" }, + { "azs", "application/vnd.airzip.filesecure.azs" }, + { "azw", "application/vnd.amazon.ebook" }, + { "acc", "application/vnd.americandynamics.acc" }, + { "ami", "application/vnd.amiga.ami" }, + { "apk", "application/vnd.android.package-archive" }, + { "cii", "application/vnd.anser-web-certificate-issue-initiation" }, + { "fti", "application/vnd.anser-web-funds-transfer-initiation" }, + { "atx", "application/vnd.antix.game-component" }, + { "mpkg", "application/vnd.apple.installer+xml" }, + { "m3u8", "application/vnd.apple.mpegurl" }, + { "swi", "application/vnd.aristanetworks.swi" }, + { "iota", "application/vnd.astraea-software.iota" }, + { "aep", "application/vnd.audiograph" }, + { "mpm", "application/vnd.blueice.multipass" }, + { "bmi", "application/vnd.bmi" }, + { "rep", "application/vnd.businessobjects" }, + { "cdxml", "application/vnd.chemdraw+xml" }, + { "mmd", "application/vnd.chipnuts.karaoke-mmd" }, + { "cdy", "application/vnd.cinderella" }, + { "cla", "application/vnd.claymore" }, + { "rp9", "application/vnd.cloanto.rp9" }, + { "c4g", "application/vnd.clonk.c4group" }, + { "c4d", "application/vnd.clonk.c4group" }, + { "c4f", "application/vnd.clonk.c4group" }, + { "c4p", "application/vnd.clonk.c4group" }, + { "c4u", "application/vnd.clonk.c4group" }, + { "c11amc", "application/vnd.cluetrust.cartomobile-config" }, + { "c11amz", "application/vnd.cluetrust.cartomobile-config-pkg" }, + { "csp", "application/vnd.commonspace" }, + { "cdbcmsg", "application/vnd.contact.cmsg" }, + { "cmc", "application/vnd.cosmocaller" }, + { "clkx", "application/vnd.crick.clicker" }, + { "clkk", "application/vnd.crick.clicker.keyboard" }, + { "clkp", "application/vnd.crick.clicker.palette" }, + { "clkt", "application/vnd.crick.clicker.template" }, + { "clkw", "application/vnd.crick.clicker.wordbank" }, + { "wbs", "application/vnd.criticaltools.wbs+xml" }, + { "pml", "application/vnd.ctc-posml" }, + { "ppd", "application/vnd.cups-ppd" }, + { "car", "application/vnd.curl.car" }, + { "pcurl", "application/vnd.curl.pcurl" }, + { "dart", "application/vnd.dart" }, + { "rdz", "application/vnd.data-vision.rdz" }, + { "uvf", "application/vnd.dece.data" }, + { "uvvf", "application/vnd.dece.data" }, + { "uvd", "application/vnd.dece.data" }, + { "uvvd", "application/vnd.dece.data" }, + { "uvt", "application/vnd.dece.ttml+xml" }, + { "uvvt", "application/vnd.dece.ttml+xml" }, + { "uvx", "application/vnd.dece.unspecified" }, + { "uvvx", "application/vnd.dece.unspecified" }, + { "uvz", "application/vnd.dece.zip" }, + { "uvvz", "application/vnd.dece.zip" }, + { "fe_launch", "application/vnd.denovo.fcselayout-link" }, + { "dna", "application/vnd.dna" }, + { "mlp", "application/vnd.dolby.mlp" }, + { "dpg", "application/vnd.dpgraph" }, + { "dfac", "application/vnd.dreamfactory" }, + { "kpxx", "application/vnd.ds-keypoint" }, + { "ait", "application/vnd.dvb.ait" }, + { "svc", "application/vnd.dvb.service" }, + { "geo", "application/vnd.dynageo" }, + { "mag", "application/vnd.ecowin.chart" }, + { "nml", "application/vnd.enliven" }, + { "esf", "application/vnd.epson.esf" }, + { "msf", "application/vnd.epson.msf" }, + { "qam", "application/vnd.epson.quickanime" }, + { "slt", "application/vnd.epson.salt" }, + { "ssf", "application/vnd.epson.ssf" }, + { "es3", "application/vnd.eszigno3+xml" }, + { "et3", "application/vnd.eszigno3+xml" }, + { "ez2", "application/vnd.ezpix-album" }, + { "ez3", "application/vnd.ezpix-package" }, + { "fdf", "application/vnd.fdf" }, + { "mseed", "application/vnd.fdsn.mseed" }, + { "seed", "application/vnd.fdsn.seed" }, + { "dataless", "application/vnd.fdsn.seed" }, + { "gph", "application/vnd.flographit" }, + { "ftc", "application/vnd.fluxtime.clip" }, + { "fm", "application/vnd.framemaker" }, + { "frame", "application/vnd.framemaker" }, + { "maker", "application/vnd.framemaker" }, + { "book", "application/vnd.framemaker" }, + { "fnc", "application/vnd.frogans.fnc" }, + { "ltf", "application/vnd.frogans.ltf" }, + { "fsc", "application/vnd.fsc.weblaunch" }, + { "oas", "application/vnd.fujitsu.oasys" }, + { "oa2", "application/vnd.fujitsu.oasys2" }, + { "oa3", "application/vnd.fujitsu.oasys3" }, + { "fg5", "application/vnd.fujitsu.oasysgp" }, + { "bh2", "application/vnd.fujitsu.oasysprs" }, + { "ddd", "application/vnd.fujixerox.ddd" }, + { "xdw", "application/vnd.fujixerox.docuworks" }, + { "xbd", "application/vnd.fujixerox.docuworks.binder" }, + { "fzs", "application/vnd.fuzzysheet" }, + { "txd", "application/vnd.genomatix.tuxedo" }, + { "ggb", "application/vnd.geogebra.file" }, + { "ggt", "application/vnd.geogebra.tool" }, + { "gex", "application/vnd.geometry-explorer" }, + { "gre", "application/vnd.geometry-explorer" }, + { "gxt", "application/vnd.geonext" }, + { "g2w", "application/vnd.geoplan" }, + { "g3w", "application/vnd.geospace" }, + { "gmx", "application/vnd.gmx" }, + { "kml", "application/vnd.google-earth.kml+xml" }, + { "kmz", "application/vnd.google-earth.kmz" }, + { "gqf", "application/vnd.grafeq" }, + { "gqs", "application/vnd.grafeq" }, + { "gac", "application/vnd.groove-account" }, + { "ghf", "application/vnd.groove-help" }, + { "gim", "application/vnd.groove-identity-message" }, + { "grv", "application/vnd.groove-injector" }, + { "gtm", "application/vnd.groove-tool-message" }, + { "tpl", "application/vnd.groove-tool-template" }, + { "vcg", "application/vnd.groove-vcard" }, + { "hal", "application/vnd.hal+xml" }, + { "zmm", "application/vnd.handheld-entertainment+xml" }, + { "hbci", "application/vnd.hbci" }, + { "les", "application/vnd.hhe.lesson-player" }, + { "hpgl", "application/vnd.hp-hpgl" }, + { "hpid", "application/vnd.hp-hpid" }, + { "hps", "application/vnd.hp-hps" }, + { "jlt", "application/vnd.hp-jlyt" }, + { "pcl", "application/vnd.hp-pcl" }, + { "pclxl", "application/vnd.hp-pclxl" }, + { "sfd-hdstx", "application/vnd.hydrostatix.sof-data" }, + { "mpy", "application/vnd.ibm.minipay" }, + { "afp", "application/vnd.ibm.modcap" }, + { "listafp", "application/vnd.ibm.modcap" }, + { "list3820", "application/vnd.ibm.modcap" }, + { "irm", "application/vnd.ibm.rights-management" }, + { "sc", "application/vnd.ibm.secure-container" }, + { "icc", "application/vnd.iccprofile" }, + { "icm", "application/vnd.iccprofile" }, + { "igl", "application/vnd.igloader" }, + { "ivp", "application/vnd.immervision-ivp" }, + { "ivu", "application/vnd.immervision-ivu" }, + { "igm", "application/vnd.insors.igm" }, + { "xpw", "application/vnd.intercon.formnet" }, + { "xpx", "application/vnd.intercon.formnet" }, + { "i2g", "application/vnd.intergeo" }, + { "qbo", "application/vnd.intu.qbo" }, + { "qfx", "application/vnd.intu.qfx" }, + { "rcprofile", "application/vnd.ipunplugged.rcprofile" }, + { "irp", "application/vnd.irepository.package+xml" }, + { "xpr", "application/vnd.is-xpr" }, + { "fcs", "application/vnd.isac.fcs" }, + { "jam", "application/vnd.jam" }, + { "rms", "application/vnd.jcp.javame.midlet-rms" }, + { "jisp", "application/vnd.jisp" }, + { "joda", "application/vnd.joost.joda-archive" }, + { "ktz", "application/vnd.kahootz" }, + { "ktr", "application/vnd.kahootz" }, + { "karbon", "application/vnd.kde.karbon" }, + { "chrt", "application/vnd.kde.kchart" }, + { "kfo", "application/vnd.kde.kformula" }, + { "flw", "application/vnd.kde.kivio" }, + { "kon", "application/vnd.kde.kontour" }, + { "kpr", "application/vnd.kde.kpresenter" }, + { "kpt", "application/vnd.kde.kpresenter" }, + { "ksp", "application/vnd.kde.kspread" }, + { "kwd", "application/vnd.kde.kword" }, + { "kwt", "application/vnd.kde.kword" }, + { "htke", "application/vnd.kenameaapp" }, + { "kia", "application/vnd.kidspiration" }, + { "kne", "application/vnd.kinar" }, + { "knp", "application/vnd.kinar" }, + { "skp", "application/vnd.koan" }, + { "skd", "application/vnd.koan" }, + { "skt", "application/vnd.koan" }, + { "skm", "application/vnd.koan" }, + { "sse", "application/vnd.kodak-descriptor" }, + { "lasxml", "application/vnd.las.las+xml" }, + { "lbd", "application/vnd.llamagraphics.life-balance.desktop" }, + { "lbe", "application/vnd.llamagraphics.life-balance.exchange+xml" }, + { "123", "application/vnd.lotus-1-2-3" }, + { "apr", "application/vnd.lotus-approach" }, + { "pre", "application/vnd.lotus-freelance" }, + { "nsf", "application/vnd.lotus-notes" }, + { "org", "application/vnd.lotus-organizer" }, + { "scm", "application/vnd.lotus-screencam" }, + { "lwp", "application/vnd.lotus-wordpro" }, + { "portpkg", "application/vnd.macports.portpkg" }, + { "mcd", "application/vnd.mcd" }, + { "mc1", "application/vnd.medcalcdata" }, + { "cdkey", "application/vnd.mediastation.cdkey" }, + { "mwf", "application/vnd.mfer" }, + { "mfm", "application/vnd.mfmp" }, + { "flo", "application/vnd.micrografx.flo" }, + { "igx", "application/vnd.micrografx.igx" }, + { "mif", "application/vnd.mif" }, + { "daf", "application/vnd.mobius.daf" }, + { "dis", "application/vnd.mobius.dis" }, + { "mbk", "application/vnd.mobius.mbk" }, + { "mqy", "application/vnd.mobius.mqy" }, + { "msl", "application/vnd.mobius.msl" }, + { "plc", "application/vnd.mobius.plc" }, + { "txf", "application/vnd.mobius.txf" }, + { "mpn", "application/vnd.mophun.application" }, + { "mpc", "application/vnd.mophun.certificate" }, + { "xul", "application/vnd.mozilla.xul+xml" }, + { "cil", "application/vnd.ms-artgalry" }, + { "cab", "application/vnd.ms-cab-compressed" }, + { "xls", "application/vnd.ms-excel" }, + { "xlm", "application/vnd.ms-excel" }, + { "xla", "application/vnd.ms-excel" }, + { "xlc", "application/vnd.ms-excel" }, + { "xlt", "application/vnd.ms-excel" }, + { "xlw", "application/vnd.ms-excel" }, + { "xlam", "application/vnd.ms-excel.addin.macroenabled.12" }, + { "xlsb", "application/vnd.ms-excel.sheet.binary.macroenabled.12" }, + { "xlsm", "application/vnd.ms-excel.sheet.macroenabled.12" }, + { "xltm", "application/vnd.ms-excel.template.macroenabled.12" }, + { "eot", "application/vnd.ms-fontobject" }, + { "chm", "application/vnd.ms-htmlhelp" }, + { "ims", "application/vnd.ms-ims" }, + { "lrm", "application/vnd.ms-lrm" }, + { "thmx", "application/vnd.ms-officetheme" }, + { "cat", "application/vnd.ms-pki.seccat" }, + { "stl", "application/vnd.ms-pki.stl" }, + { "ppt", "application/vnd.ms-powerpoint" }, + { "pps", "application/vnd.ms-powerpoint" }, + { "pot", "application/vnd.ms-powerpoint" }, + { "ppam", "application/vnd.ms-powerpoint.addin.macroenabled.12" }, + { "pptm", "application/vnd.ms-powerpoint.presentation.macroenabled.12" }, + { "sldm", "application/vnd.ms-powerpoint.slide.macroenabled.12" }, + { "ppsm", "application/vnd.ms-powerpoint.slideshow.macroenabled.12" }, + { "potm", "application/vnd.ms-powerpoint.template.macroenabled.12" }, + { "mpp", "application/vnd.ms-project" }, + { "mpt", "application/vnd.ms-project" }, + { "docm", "application/vnd.ms-word.document.macroenabled.12" }, + { "dotm", "application/vnd.ms-word.template.macroenabled.12" }, + { "wps", "application/vnd.ms-works" }, + { "wks", "application/vnd.ms-works" }, + { "wcm", "application/vnd.ms-works" }, + { "wdb", "application/vnd.ms-works" }, + { "wpl", "application/vnd.ms-wpl" }, + { "xps", "application/vnd.ms-xpsdocument" }, + { "mseq", "application/vnd.mseq" }, + { "mus", "application/vnd.musician" }, + { "msty", "application/vnd.muvee.style" }, + { "taglet", "application/vnd.mynfc" }, + { "nlu", "application/vnd.neurolanguage.nlu" }, + { "ntf", "application/vnd.nitf" }, + { "nitf", "application/vnd.nitf" }, + { "nnd", "application/vnd.noblenet-directory" }, + { "nns", "application/vnd.noblenet-sealer" }, + { "nnw", "application/vnd.noblenet-web" }, + { "ngdat", "application/vnd.nokia.n-gage.data" }, + { "n-gage", "application/vnd.nokia.n-gage.symbian.install" }, + { "rpst", "application/vnd.nokia.radio-preset" }, + { "rpss", "application/vnd.nokia.radio-presets" }, + { "edm", "application/vnd.novadigm.edm" }, + { "edx", "application/vnd.novadigm.edx" }, + { "ext", "application/vnd.novadigm.ext" }, + { "odc", "application/vnd.oasis.opendocument.chart" }, + { "otc", "application/vnd.oasis.opendocument.chart-template" }, + { "odb", "application/vnd.oasis.opendocument.database" }, + { "odf", "application/vnd.oasis.opendocument.formula" }, + { "odft", "application/vnd.oasis.opendocument.formula-template" }, + { "odg", "application/vnd.oasis.opendocument.graphics" }, + { "otg", "application/vnd.oasis.opendocument.graphics-template" }, + { "odi", "application/vnd.oasis.opendocument.image" }, + { "oti", "application/vnd.oasis.opendocument.image-template" }, + { "odp", "application/vnd.oasis.opendocument.presentation" }, + { "otp", "application/vnd.oasis.opendocument.presentation-template" }, + { "ods", "application/vnd.oasis.opendocument.spreadsheet" }, + { "ots", "application/vnd.oasis.opendocument.spreadsheet-template" }, + { "odt", "application/vnd.oasis.opendocument.text" }, + { "odm", "application/vnd.oasis.opendocument.text-master" }, + { "ott", "application/vnd.oasis.opendocument.text-template" }, + { "oth", "application/vnd.oasis.opendocument.text-web" }, + { "xo", "application/vnd.olpc-sugar" }, + { "dd2", "application/vnd.oma.dd2+xml" }, + { "oxt", "application/vnd.openofficeorg.extension" }, + { "pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation" }, + { "sldx", "application/vnd.openxmlformats-officedocument.presentationml.slide" }, + { "ppsx", "application/vnd.openxmlformats-officedocument.presentationml.slideshow" }, + { "potx", "application/vnd.openxmlformats-officedocument.presentationml.template" }, + { "xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" }, + { "xltx", "application/vnd.openxmlformats-officedocument.spreadsheetml.template" }, + { "docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document" }, + { "dotx", "application/vnd.openxmlformats-officedocument.wordprocessingml.template" }, + { "mgp", "application/vnd.osgeo.mapguide.package" }, + { "dp", "application/vnd.osgi.dp" }, + { "esa", "application/vnd.osgi.subsystem" }, + { "pdb", "application/vnd.palm" }, + { "pqa", "application/vnd.palm" }, + { "oprc", "application/vnd.palm" }, + { "paw", "application/vnd.pawaafile" }, + { "str", "application/vnd.pg.format" }, + { "ei6", "application/vnd.pg.osasli" }, + { "efif", "application/vnd.picsel" }, + { "wg", "application/vnd.pmi.widget" }, + { "plf", "application/vnd.pocketlearn" }, + { "pbd", "application/vnd.powerbuilder6" }, + { "box", "application/vnd.previewsystems.box" }, + { "mgz", "application/vnd.proteus.magazine" }, + { "qps", "application/vnd.publishare-delta-tree" }, + { "ptid", "application/vnd.pvi.ptid1" }, + { "qxd", "application/vnd.quark.quarkxpress" }, + { "qxt", "application/vnd.quark.quarkxpress" }, + { "qwd", "application/vnd.quark.quarkxpress" }, + { "qwt", "application/vnd.quark.quarkxpress" }, + { "qxl", "application/vnd.quark.quarkxpress" }, + { "qxb", "application/vnd.quark.quarkxpress" }, + { "bed", "application/vnd.realvnc.bed" }, + { "mxl", "application/vnd.recordare.musicxml" }, + { "musicxml", "application/vnd.recordare.musicxml+xml" }, + { "cryptonote", "application/vnd.rig.cryptonote" }, + { "cod", "application/vnd.rim.cod" }, + { "rm", "application/vnd.rn-realmedia" }, + { "rmvb", "application/vnd.rn-realmedia-vbr" }, + { "link66", "application/vnd.route66.link66+xml" }, + { "st", "application/vnd.sailingtracker.track" }, + { "see", "application/vnd.seemail" }, + { "sema", "application/vnd.sema" }, + { "semd", "application/vnd.semd" }, + { "semf", "application/vnd.semf" }, + { "ifm", "application/vnd.shana.informed.formdata" }, + { "itp", "application/vnd.shana.informed.formtemplate" }, + { "iif", "application/vnd.shana.informed.interchange" }, + { "ipk", "application/vnd.shana.informed.package" }, + { "twd", "application/vnd.simtech-mindmapper" }, + { "twds", "application/vnd.simtech-mindmapper" }, + { "mmf", "application/vnd.smaf" }, + { "teacher", "application/vnd.smart.teacher" }, + { "sdkm", "application/vnd.solent.sdkm+xml" }, + { "sdkd", "application/vnd.solent.sdkm+xml" }, + { "dxp", "application/vnd.spotfire.dxp" }, + { "sfs", "application/vnd.spotfire.sfs" }, + { "sdc", "application/vnd.stardivision.calc" }, + { "sda", "application/vnd.stardivision.draw" }, + { "sdd", "application/vnd.stardivision.impress" }, + { "smf", "application/vnd.stardivision.math" }, + { "sdw", "application/vnd.stardivision.writer" }, + { "vor", "application/vnd.stardivision.writer" }, + { "sgl", "application/vnd.stardivision.writer-global" }, + { "smzip", "application/vnd.stepmania.package" }, + { "sm", "application/vnd.stepmania.stepchart" }, + { "sxc", "application/vnd.sun.xml.calc" }, + { "stc", "application/vnd.sun.xml.calc.template" }, + { "sxd", "application/vnd.sun.xml.draw" }, + { "std", "application/vnd.sun.xml.draw.template" }, + { "sxi", "application/vnd.sun.xml.impress" }, + { "sti", "application/vnd.sun.xml.impress.template" }, + { "sxm", "application/vnd.sun.xml.math" }, + { "sxw", "application/vnd.sun.xml.writer" }, + { "sxg", "application/vnd.sun.xml.writer.global" }, + { "stw", "application/vnd.sun.xml.writer.template" }, + { "sus", "application/vnd.sus-calendar" }, + { "susp", "application/vnd.sus-calendar" }, + { "svd", "application/vnd.svd" }, + { "sis", "application/vnd.symbian.install" }, + { "sisx", "application/vnd.symbian.install" }, + { "xsm", "application/vnd.syncml+xml" }, + { "bdm", "application/vnd.syncml.dm+wbxml" }, + { "xdm", "application/vnd.syncml.dm+xml" }, + { "tao", "application/vnd.tao.intent-module-archive" }, + { "pcap", "application/vnd.tcpdump.pcap" }, + { "cap", "application/vnd.tcpdump.pcap" }, + { "dmp", "application/vnd.tcpdump.pcap" }, + { "tmo", "application/vnd.tmobile-livetv" }, + { "tpt", "application/vnd.trid.tpt" }, + { "mxs", "application/vnd.triscape.mxs" }, + { "tra", "application/vnd.trueapp" }, + { "ufd", "application/vnd.ufdl" }, + { "ufdl", "application/vnd.ufdl" }, + { "utz", "application/vnd.uiq.theme" }, + { "umj", "application/vnd.umajin" }, + { "unityweb", "application/vnd.unity" }, + { "uoml", "application/vnd.uoml+xml" }, + { "vcx", "application/vnd.vcx" }, + { "vsd", "application/vnd.visio" }, + { "vst", "application/vnd.visio" }, + { "vss", "application/vnd.visio" }, + { "vsw", "application/vnd.visio" }, + { "vis", "application/vnd.visionary" }, + { "vsf", "application/vnd.vsf" }, + { "wbxml", "application/vnd.wap.wbxml" }, + { "wmlc", "application/vnd.wap.wmlc" }, + { "wmlsc", "application/vnd.wap.wmlscriptc" }, + { "wtb", "application/vnd.webturbo" }, + { "nbp", "application/vnd.wolfram.player" }, + { "wpd", "application/vnd.wordperfect" }, + { "wqd", "application/vnd.wqd" }, + { "stf", "application/vnd.wt.stf" }, + { "xar", "application/vnd.xara" }, + { "xfdl", "application/vnd.xfdl" }, + { "hvd", "application/vnd.yamaha.hv-dic" }, + { "hvs", "application/vnd.yamaha.hv-script" }, + { "hvp", "application/vnd.yamaha.hv-voice" }, + { "osf", "application/vnd.yamaha.openscoreformat" }, + { "osfpvg", "application/vnd.yamaha.openscoreformat.osfpvg+xml" }, + { "saf", "application/vnd.yamaha.smaf-audio" }, + { "spf", "application/vnd.yamaha.smaf-phrase" }, + { "cmp", "application/vnd.yellowriver-custom-menu" }, + { "zir", "application/vnd.zul" }, + { "zirz", "application/vnd.zul" }, + { "zaz", "application/vnd.zzazz.deck+xml" }, + { "vxml", "application/voicexml+xml" }, + { "wgt", "application/widget" }, + { "hlp", "application/winhlp" }, + { "wsdl", "application/wsdl+xml" }, + { "wspolicy", "application/wspolicy+xml" }, + { "7z", "application/x-7z-compressed" }, + { "abw", "application/x-abiword" }, + { "ace", "application/x-ace-compressed" }, + { "dmg", "application/x-apple-diskimage" }, + { "aab", "application/x-authorware-bin" }, + { "x32", "application/x-authorware-bin" }, + { "u32", "application/x-authorware-bin" }, + { "vox", "application/x-authorware-bin" }, + { "aam", "application/x-authorware-map" }, + { "aas", "application/x-authorware-seg" }, + { "bcpio", "application/x-bcpio" }, + { "torrent", "application/x-bittorrent" }, + { "blb", "application/x-blorb" }, + { "blorb", "application/x-blorb" }, + { "bz", "application/x-bzip" }, + { "bz2", "application/x-bzip2" }, + { "boz", "application/x-bzip2" }, + { "cbr", "application/x-cbr" }, + { "cba", "application/x-cbr" }, + { "cbt", "application/x-cbr" }, + { "cbz", "application/x-cbr" }, + { "cb7", "application/x-cbr" }, + { "vcd", "application/x-cdlink" }, + { "cfs", "application/x-cfs-compressed" }, + { "chat", "application/x-chat" }, + { "pgn", "application/x-chess-pgn" }, + { "nsc", "application/x-conference" }, + { "cpio", "application/x-cpio" }, + { "csh", "application/x-csh" }, + { "deb", "application/x-debian-package" }, + { "udeb", "application/x-debian-package" }, + { "dgc", "application/x-dgc-compressed" }, + { "dir", "application/x-director" }, + { "dcr", "application/x-director" }, + { "dxr", "application/x-director" }, + { "cst", "application/x-director" }, + { "cct", "application/x-director" }, + { "cxt", "application/x-director" }, + { "w3d", "application/x-director" }, + { "fgd", "application/x-director" }, + { "swa", "application/x-director" }, + { "wad", "application/x-doom" }, + { "ncx", "application/x-dtbncx+xml" }, + { "dtb", "application/x-dtbook+xml" }, + { "res", "application/x-dtbresource+xml" }, + { "dvi", "application/x-dvi" }, + { "evy", "application/x-envoy" }, + { "eva", "application/x-eva" }, + { "bdf", "application/x-font-bdf" }, + { "gsf", "application/x-font-ghostscript" }, + { "psf", "application/x-font-linux-psf" }, + { "otf", "application/x-font-otf" }, + { "pcf", "application/x-font-pcf" }, + { "snf", "application/x-font-snf" }, + { "ttf", "application/x-font-ttf" }, + { "ttc", "application/x-font-ttf" }, + { "pfa", "application/x-font-type1" }, + { "pfb", "application/x-font-type1" }, + { "pfm", "application/x-font-type1" }, + { "afm", "application/x-font-type1" }, + { "woff", "application/font-woff" }, + { "arc", "application/x-freearc" }, + { "spl", "application/x-futuresplash" }, + { "gca", "application/x-gca-compressed" }, + { "ulx", "application/x-glulx" }, + { "gnumeric", "application/x-gnumeric" }, + { "gramps", "application/x-gramps-xml" }, + { "gtar", "application/x-gtar" }, + { "hdf", "application/x-hdf" }, + { "install", "application/x-install-instructions" }, + { "iso", "application/x-iso9660-image" }, + { "jnlp", "application/x-java-jnlp-file" }, + { "latex", "application/x-latex" }, + { "lzh", "application/x-lzh-compressed" }, + { "lha", "application/x-lzh-compressed" }, + { "mie", "application/x-mie" }, + { "prc", "application/x-mobipocket-ebook" }, + { "mobi", "application/x-mobipocket-ebook" }, + { "application", "application/x-ms-application" }, + { "lnk", "application/x-ms-shortcut" }, + { "wmd", "application/x-ms-wmd" }, + { "wmz", "application/x-msmetafile" }, + { "xbap", "application/x-ms-xbap" }, + { "mdb", "application/x-msaccess" }, + { "obd", "application/x-msbinder" }, + { "crd", "application/x-mscardfile" }, + { "clp", "application/x-msclip" }, + { "exe", "application/x-msdownload" }, + { "dll", "application/x-msdownload" }, + { "com", "application/x-msdownload" }, + { "bat", "application/x-msdownload" }, + { "msi", "application/x-msdownload" }, + { "mvb", "application/x-msmediaview" }, + { "m13", "application/x-msmediaview" }, + { "m14", "application/x-msmediaview" }, + { "wmf", "application/x-msmetafile" }, + { "emf", "application/x-msmetafile" }, + { "emz", "application/x-msmetafile" }, + { "mny", "application/x-msmoney" }, + { "pub", "application/x-mspublisher" }, + { "scd", "application/x-msschedule" }, + { "trm", "application/x-msterminal" }, + { "wri", "application/x-mswrite" }, + { "nc", "application/x-netcdf" }, + { "cdf", "application/x-netcdf" }, + { "nzb", "application/x-nzb" }, + { "p12", "application/x-pkcs12" }, + { "pfx", "application/x-pkcs12" }, + { "p7b", "application/x-pkcs7-certificates" }, + { "spc", "application/x-pkcs7-certificates" }, + { "p7r", "application/x-pkcs7-certreqresp" }, + { "rar", "application/x-rar-compressed" }, + { "ris", "application/x-research-info-systems" }, + { "sh", "application/x-sh" }, + { "shar", "application/x-shar" }, + { "swf", "application/x-shockwave-flash" }, + { "xap", "application/x-silverlight-app" }, + { "sql", "application/x-sql" }, + { "sit", "application/x-stuffit" }, + { "sitx", "application/x-stuffitx" }, + { "srt", "application/x-subrip" }, + { "sv4cpio", "application/x-sv4cpio" }, + { "sv4crc", "application/x-sv4crc" }, + { "t3", "application/x-t3vm-image" }, + { "gam", "application/x-tads" }, + { "tar", "application/x-tar" }, + { "tcl", "application/x-tcl" }, + { "tex", "application/x-tex" }, + { "tfm", "application/x-tex-tfm" }, + { "texinfo", "application/x-texinfo" }, + { "texi", "application/x-texinfo" }, + { "obj", "application/x-tgif" }, + { "ustar", "application/x-ustar" }, + { "src", "application/x-wais-source" }, + { "der", "application/x-x509-ca-cert" }, + { "crt", "application/x-x509-ca-cert" }, + { "fig", "application/x-xfig" }, + { "xlf", "application/x-xliff+xml" }, + { "xpi", "application/x-xpinstall" }, + { "xz", "application/x-xz" }, + { "z1", "application/x-zmachine" }, + { "z2", "application/x-zmachine" }, + { "z3", "application/x-zmachine" }, + { "z4", "application/x-zmachine" }, + { "z5", "application/x-zmachine" }, + { "z6", "application/x-zmachine" }, + { "z7", "application/x-zmachine" }, + { "z8", "application/x-zmachine" }, + { "xaml", "application/xaml+xml" }, + { "xdf", "application/xcap-diff+xml" }, + { "xenc", "application/xenc+xml" }, + { "xhtml", "application/xhtml+xml" }, + { "xht", "application/xhtml+xml" }, + { "xml", "application/xml" }, + { "xsl", "application/xml" }, + { "dtd", "application/xml-dtd" }, + { "xop", "application/xop+xml" }, + { "xpl", "application/xproc+xml" }, + { "xslt", "application/xslt+xml" }, + { "xspf", "application/xspf+xml" }, + { "mxml", "application/xv+xml" }, + { "xhvml", "application/xv+xml" }, + { "xvml", "application/xv+xml" }, + { "xvm", "application/xv+xml" }, + { "yang", "application/yang" }, + { "yin", "application/yin+xml" }, + { "zip", "application/zip" }, + { "adp", "audio/adpcm" }, + { "au", "audio/basic" }, + { "snd", "audio/basic" }, + { "mid", "audio/midi" }, + { "midi", "audio/midi" }, + { "kar", "audio/midi" }, + { "rmi", "audio/midi" }, + { "mp4a", "audio/mp4" }, + { "mpga", "audio/mpeg" }, + { "mp2", "audio/mpeg" }, + { "mp2a", "audio/mpeg" }, + { "mp3", "audio/mpeg" }, + { "m2a", "audio/mpeg" }, + { "m3a", "audio/mpeg" }, + { "oga", "audio/ogg" }, + { "ogg", "audio/ogg" }, + { "spx", "audio/ogg" }, + { "s3m", "audio/s3m" }, + { "sil", "audio/silk" }, + { "uva", "audio/vnd.dece.audio" }, + { "uvva", "audio/vnd.dece.audio" }, + { "eol", "audio/vnd.digital-winds" }, + { "dra", "audio/vnd.dra" }, + { "dts", "audio/vnd.dts" }, + { "dtshd", "audio/vnd.dts.hd" }, + { "lvp", "audio/vnd.lucent.voice" }, + { "pya", "audio/vnd.ms-playready.media.pya" }, + { "ecelp4800", "audio/vnd.nuera.ecelp4800" }, + { "ecelp7470", "audio/vnd.nuera.ecelp7470" }, + { "ecelp9600", "audio/vnd.nuera.ecelp9600" }, + { "rip", "audio/vnd.rip" }, + { "weba", "audio/webm" }, + { "aac", "audio/x-aac" }, + { "aif", "audio/x-aiff" }, + { "aiff", "audio/x-aiff" }, + { "aifc", "audio/x-aiff" }, + { "caf", "audio/x-caf" }, + { "flac", "audio/x-flac" }, + { "mka", "audio/x-matroska" }, + { "m3u", "audio/x-mpegurl" }, + { "wax", "audio/x-ms-wax" }, + { "wma", "audio/x-ms-wma" }, + { "ram", "audio/x-pn-realaudio" }, + { "ra", "audio/x-pn-realaudio" }, + { "rmp", "audio/x-pn-realaudio-plugin" }, + { "wav", "audio/x-wav" }, + { "xm", "audio/xm" }, + { "cdx", "chemical/x-cdx" }, + { "cif", "chemical/x-cif" }, + { "cmdf", "chemical/x-cmdf" }, + { "cml", "chemical/x-cml" }, + { "csml", "chemical/x-csml" }, + { "xyz", "chemical/x-xyz" }, + { "bmp", "image/bmp" }, + { "cgm", "image/cgm" }, + { "g3", "image/g3fax" }, + { "gif", "image/gif" }, + { "ief", "image/ief" }, + { "jpeg", "image/jpeg" }, + { "jpg", "image/jpeg" }, + { "jpe", "image/jpeg" }, + { "ktx", "image/ktx" }, + { "png", "image/png" }, + { "btif", "image/prs.btif" }, + { "sgi", "image/sgi" }, + { "svg", "image/svg+xml" }, + { "svgz", "image/svg+xml" }, + { "tiff", "image/tiff" }, + { "tif", "image/tiff" }, + { "psd", "image/vnd.adobe.photoshop" }, + { "uvi", "image/vnd.dece.graphic" }, + { "uvvi", "image/vnd.dece.graphic" }, + { "uvg", "image/vnd.dece.graphic" }, + { "uvvg", "image/vnd.dece.graphic" }, + { "sub", "text/vnd.dvb.subtitle" }, + { "djvu", "image/vnd.djvu" }, + { "djv", "image/vnd.djvu" }, + { "dwg", "image/vnd.dwg" }, + { "dxf", "image/vnd.dxf" }, + { "fbs", "image/vnd.fastbidsheet" }, + { "fpx", "image/vnd.fpx" }, + { "fst", "image/vnd.fst" }, + { "mmr", "image/vnd.fujixerox.edmics-mmr" }, + { "rlc", "image/vnd.fujixerox.edmics-rlc" }, + { "mdi", "image/vnd.ms-modi" }, + { "wdp", "image/vnd.ms-photo" }, + { "npx", "image/vnd.net-fpx" }, + { "wbmp", "image/vnd.wap.wbmp" }, + { "xif", "image/vnd.xiff" }, + { "webp", "image/webp" }, + { "3ds", "image/x-3ds" }, + { "ras", "image/x-cmu-raster" }, + { "cmx", "image/x-cmx" }, + { "fh", "image/x-freehand" }, + { "fhc", "image/x-freehand" }, + { "fh4", "image/x-freehand" }, + { "fh5", "image/x-freehand" }, + { "fh7", "image/x-freehand" }, + { "ico", "image/x-icon" }, + { "sid", "image/x-mrsid-image" }, + { "pcx", "image/x-pcx" }, + { "pic", "image/x-pict" }, + { "pct", "image/x-pict" }, + { "pnm", "image/x-portable-anymap" }, + { "pbm", "image/x-portable-bitmap" }, + { "pgm", "image/x-portable-graymap" }, + { "ppm", "image/x-portable-pixmap" }, + { "rgb", "image/x-rgb" }, + { "tga", "image/x-tga" }, + { "xbm", "image/x-xbitmap" }, + { "xpm", "image/x-xpixmap" }, + { "xwd", "image/x-xwindowdump" }, + { "eml", "message/rfc822" }, + { "mime", "message/rfc822" }, + { "igs", "model/iges" }, + { "iges", "model/iges" }, + { "msh", "model/mesh" }, + { "mesh", "model/mesh" }, + { "silo", "model/mesh" }, + { "dae", "model/vnd.collada+xml" }, + { "dwf", "model/vnd.dwf" }, + { "gdl", "model/vnd.gdl" }, + { "gtw", "model/vnd.gtw" }, + { "mts", "model/vnd.mts" }, + { "vtu", "model/vnd.vtu" }, + { "wrl", "model/vrml" }, + { "vrml", "model/vrml" }, + { "x3db", "model/x3d+binary" }, + { "x3dbz", "model/x3d+binary" }, + { "x3dv", "model/x3d+vrml" }, + { "x3dvz", "model/x3d+vrml" }, + { "x3d", "model/x3d+xml" }, + { "x3dz", "model/x3d+xml" }, + { "appcache", "text/cache-manifest" }, + { "ics", "text/calendar" }, + { "ifb", "text/calendar" }, + { "css", "text/css" }, + { "csv", "text/csv" }, + { "html", "text/html" }, + { "htm", "text/html" }, + { "n3", "text/n3" }, + { "txt", "text/plain" }, + { "text", "text/plain" }, + { "conf", "text/plain" }, + { "def", "text/plain" }, + { "list", "text/plain" }, + { "log", "text/plain" }, + { "in", "text/plain" }, + { "dsc", "text/prs.lines.tag" }, + { "rtx", "text/richtext" }, + { "sgml", "text/sgml" }, + { "sgm", "text/sgml" }, + { "tsv", "text/tab-separated-values" }, + { "t", "text/troff" }, + { "tr", "text/troff" }, + { "roff", "text/troff" }, + { "man", "text/troff" }, + { "me", "text/troff" }, + { "ms", "text/troff" }, + { "ttl", "text/turtle" }, + { "uri", "text/uri-list" }, + { "uris", "text/uri-list" }, + { "urls", "text/uri-list" }, + { "vcard", "text/vcard" }, + { "curl", "text/vnd.curl" }, + { "dcurl", "text/vnd.curl.dcurl" }, + { "scurl", "text/vnd.curl.scurl" }, + { "mcurl", "text/vnd.curl.mcurl" }, + { "fly", "text/vnd.fly" }, + { "flx", "text/vnd.fmi.flexstor" }, + { "gv", "text/vnd.graphviz" }, + { "3dml", "text/vnd.in3d.3dml" }, + { "spot", "text/vnd.in3d.spot" }, + { "jad", "text/vnd.sun.j2me.app-descriptor" }, + { "wml", "text/vnd.wap.wml" }, + { "wmls", "text/vnd.wap.wmlscript" }, + { "s", "text/x-asm" }, + { "asm", "text/x-asm" }, + { "c", "text/x-c" }, + { "cc", "text/x-c" }, + { "cxx", "text/x-c" }, + { "cpp", "text/x-c" }, + { "h", "text/x-c" }, + { "hh", "text/x-c" }, + { "dic", "text/x-c" }, + { "f", "text/x-fortran" }, + { "for", "text/x-fortran" }, + { "f77", "text/x-fortran" }, + { "f90", "text/x-fortran" }, + { "java", "text/x-java-source" }, + { "opml", "text/x-opml" }, + { "p", "text/x-pascal" }, + { "pas", "text/x-pascal" }, + { "nfo", "text/x-nfo" }, + { "etx", "text/x-setext" }, + { "sfv", "text/x-sfv" }, + { "uu", "text/x-uuencode" }, + { "vcs", "text/x-vcalendar" }, + { "vcf", "text/x-vcard" }, + { "3gp", "video/3gpp" }, + { "3g2", "video/3gpp2" }, + { "h261", "video/h261" }, + { "h263", "video/h263" }, + { "h264", "video/h264" }, + { "jpgv", "video/jpeg" }, + { "jpm", "video/jpm" }, + { "jpgm", "video/jpm" }, + { "mj2", "video/mj2" }, + { "mjp2", "video/mj2" }, + { "mp4", "video/mp4" }, + { "mp4v", "video/mp4" }, + { "mpg4", "video/mp4" }, + { "mpeg", "video/mpeg" }, + { "mpg", "video/mpeg" }, + { "mpe", "video/mpeg" }, + { "m1v", "video/mpeg" }, + { "m2v", "video/mpeg" }, + { "ogv", "video/ogg" }, + { "qt", "video/quicktime" }, + { "mov", "video/quicktime" }, + { "uvh", "video/vnd.dece.hd" }, + { "uvvh", "video/vnd.dece.hd" }, + { "uvm", "video/vnd.dece.mobile" }, + { "uvvm", "video/vnd.dece.mobile" }, + { "uvp", "video/vnd.dece.pd" }, + { "uvvp", "video/vnd.dece.pd" }, + { "uvs", "video/vnd.dece.sd" }, + { "uvvs", "video/vnd.dece.sd" }, + { "uvv", "video/vnd.dece.video" }, + { "uvvv", "video/vnd.dece.video" }, + { "dvb", "video/vnd.dvb.file" }, + { "fvt", "video/vnd.fvt" }, + { "mxu", "video/vnd.mpegurl" }, + { "m4u", "video/vnd.mpegurl" }, + { "pyv", "video/vnd.ms-playready.media.pyv" }, + { "uvu", "video/vnd.uvvu.mp4" }, + { "uvvu", "video/vnd.uvvu.mp4" }, + { "viv", "video/vnd.vivo" }, + { "webm", "video/webm" }, + { "f4v", "video/x-f4v" }, + { "fli", "video/x-fli" }, + { "flv", "video/x-flv" }, + { "m4v", "video/x-m4v" }, + { "mkv", "video/x-matroska" }, + { "mk3d", "video/x-matroska" }, + { "mks", "video/x-matroska" }, + { "mng", "video/x-mng" }, + { "asf", "video/x-ms-asf" }, + { "asx", "video/x-ms-asf" }, + { "vob", "video/x-ms-vob" }, + { "wm", "video/x-ms-wm" }, + { "wmv", "video/x-ms-wmv" }, + { "wmx", "video/x-ms-wmx" }, + { "wvx", "video/x-ms-wvx" }, + { "avi", "video/x-msvideo" }, + { "movie", "video/x-sgi-movie" }, + { "smv", "video/x-smv" }, + { "ice", "x-conference/x-cooltalk" }, + { NULL, NULL } +}; + +#endif /* PHP_CLI_SERVER_MIME_TYPE_MAP_H */ + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: noet sw=4 ts=4 fdm=marker + * vim<600: noet sw=4 ts=4 + */ diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index 9daa382eec..bdc4629c08 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -173,8 +173,9 @@ const opt_struct OPTIONS[] = { {'-', 0, NULL} /* end of args */ }; -static int print_module_info(zend_module_entry *module TSRMLS_DC) /* {{{ */ +static int print_module_info(zval *element TSRMLS_DC) /* {{{ */ { + zend_module_entry *module = (zend_module_entry*)Z_PTR_P(element); php_printf("%s\n", module->name); return ZEND_HASH_APPLY_KEEP; } @@ -182,23 +183,22 @@ static int print_module_info(zend_module_entry *module TSRMLS_DC) /* {{{ */ static int module_name_cmp(const void *a, const void *b TSRMLS_DC) /* {{{ */ { - Bucket *f = *((Bucket **) a); - Bucket *s = *((Bucket **) b); + Bucket *f = (Bucket *) a; + Bucket *s = (Bucket *) b; - return strcasecmp(((zend_module_entry *)f->pData)->name, - ((zend_module_entry *)s->pData)->name); + return strcasecmp(((zend_module_entry *)Z_PTR(f->val))->name, + ((zend_module_entry *)Z_PTR(s->val))->name); } /* }}} */ static void print_modules(TSRMLS_D) /* {{{ */ { HashTable sorted_registry; - zend_module_entry tmp; - zend_hash_init(&sorted_registry, 50, NULL, NULL, 1); - zend_hash_copy(&sorted_registry, &module_registry, NULL, &tmp, sizeof(zend_module_entry)); + zend_hash_init(&sorted_registry, 50, NULL, NULL, 0); + zend_hash_copy(&sorted_registry, &module_registry, NULL); zend_hash_sort(&sorted_registry, zend_qsort, module_name_cmp, 0 TSRMLS_CC); - zend_hash_apply(&sorted_registry, (apply_func_t) print_module_info TSRMLS_CC); + zend_hash_apply(&sorted_registry, print_module_info TSRMLS_CC); zend_hash_destroy(&sorted_registry); } /* }}} */ @@ -252,16 +252,16 @@ static inline int sapi_cli_select(int fd TSRMLS_DC) return ret != -1; } -PHP_CLI_API size_t sapi_cli_single_write(const char *str, uint str_length TSRMLS_DC) /* {{{ */ +PHP_CLI_API size_t sapi_cli_single_write(const char *str, php_size_t str_length TSRMLS_DC) /* {{{ */ { #ifdef PHP_WRITE_STDOUT - long ret; + php_int_t ret; #else - size_t ret; + php_size_t ret; #endif if (cli_shell_callbacks.cli_shell_write) { - size_t shell_wrote; + php_size_t shell_wrote; shell_wrote = cli_shell_callbacks.cli_shell_write(str, str_length TSRMLS_CC); if (shell_wrote > -1) { return shell_wrote; @@ -285,10 +285,10 @@ PHP_CLI_API size_t sapi_cli_single_write(const char *str, uint str_length TSRMLS } /* }}} */ -static int sapi_cli_ub_write(const char *str, uint str_length TSRMLS_DC) /* {{{ */ +static php_size_t sapi_cli_ub_write(const char *str, php_size_t str_length TSRMLS_DC) /* {{{ */ { const char *ptr = str; - uint remaining = str_length; + php_size_t remaining = str_length; size_t ret; if (!str_length) { @@ -296,7 +296,7 @@ static int sapi_cli_ub_write(const char *str, uint str_length TSRMLS_DC) /* {{{ } if (cli_shell_callbacks.cli_shell_ub_write) { - int ub_wrote; + php_size_t ub_wrote; ub_wrote = cli_shell_callbacks.cli_shell_ub_write(str, str_length TSRMLS_CC); if (ub_wrote > -1) { return ub_wrote; @@ -320,7 +320,7 @@ static int sapi_cli_ub_write(const char *str, uint str_length TSRMLS_DC) /* {{{ } /* }}} */ -static void sapi_cli_flush(void *server_context) /* {{{ */ +static void sapi_cli_flush(void *server_context TSRMLS_DC) /* {{{ */ { /* Ignore EBADF here, it's caused by the fact that STDIN/STDOUT/STDERR streams * are/could be closed before fflush() is called. @@ -338,7 +338,7 @@ static char *script_filename = ""; static void sapi_cli_register_variables(zval *track_vars_array TSRMLS_DC) /* {{{ */ { - unsigned int len; + php_size_t len; char *docroot = ""; /* In CGI mode, we consider the environment to be a part of the server @@ -425,10 +425,8 @@ static int php_cli_startup(sapi_module_struct *sapi_module) /* {{{ */ /* overwriteable ini defaults must be set in sapi_cli_ini_defaults() */ #define INI_DEFAULT(name,value)\ - Z_SET_REFCOUNT(tmp, 0);\ - Z_UNSET_ISREF(tmp); \ - ZVAL_STRINGL(&tmp, zend_strndup(value, sizeof(value)-1), sizeof(value)-1, 0);\ - zend_hash_update(configuration_hash, name, sizeof(name), &tmp, sizeof(zval), NULL);\ + ZVAL_NEW_STR(&tmp, STR_INIT(value, sizeof(value)-1, 1));\ + zend_hash_str_update(configuration_hash, name, sizeof(name)-1, &tmp);\ static void sapi_cli_ini_defaults(HashTable *configuration_hash) { @@ -553,23 +551,16 @@ static php_stream *s_in_process = NULL; static void cli_register_file_handles(TSRMLS_D) /* {{{ */ { - zval *zin, *zout, *zerr; + zval zin, zout, zerr; php_stream *s_in, *s_out, *s_err; php_stream_context *sc_in=NULL, *sc_out=NULL, *sc_err=NULL; zend_constant ic, oc, ec; - MAKE_STD_ZVAL(zin); - MAKE_STD_ZVAL(zout); - MAKE_STD_ZVAL(zerr); - s_in = php_stream_open_wrapper_ex("php://stdin", "rb", 0, NULL, sc_in); s_out = php_stream_open_wrapper_ex("php://stdout", "wb", 0, NULL, sc_out); s_err = php_stream_open_wrapper_ex("php://stderr", "wb", 0, NULL, sc_err); if (s_in==NULL || s_out==NULL || s_err==NULL) { - FREE_ZVAL(zin); - FREE_ZVAL(zout); - FREE_ZVAL(zerr); if (s_in) php_stream_close(s_in); if (s_out) php_stream_close(s_out); if (s_err) php_stream_close(s_err); @@ -584,34 +575,27 @@ static void cli_register_file_handles(TSRMLS_D) /* {{{ */ s_in_process = s_in; - php_stream_to_zval(s_in, zin); - php_stream_to_zval(s_out, zout); - php_stream_to_zval(s_err, zerr); + php_stream_to_zval(s_in, &zin); + php_stream_to_zval(s_out, &zout); + php_stream_to_zval(s_err, &zerr); - ic.value = *zin; + ZVAL_COPY_VALUE(&ic.value, &zin); ic.flags = CONST_CS; - ic.name = zend_strndup(ZEND_STRL("STDIN")); - ic.name_len = sizeof("STDIN"); + ic.name = STR_INIT("STDIN", sizeof("STDIN")-1, 1); ic.module_number = 0; zend_register_constant(&ic TSRMLS_CC); - oc.value = *zout; + ZVAL_COPY_VALUE(&oc.value, &zout); oc.flags = CONST_CS; - oc.name = zend_strndup(ZEND_STRL("STDOUT")); - oc.name_len = sizeof("STDOUT"); + oc.name = STR_INIT("STDOUT", sizeof("STDOUT")-1, 1); oc.module_number = 0; zend_register_constant(&oc TSRMLS_CC); - ec.value = *zerr; + ZVAL_COPY_VALUE(&ec.value, &zerr); ec.flags = CONST_CS; - ec.name = zend_strndup(ZEND_STRL("STDERR")); - ec.name_len = sizeof("STDERR"); + ec.name = STR_INIT("STDERR", sizeof("STDERR")-1, 1); ec.module_number = 0; zend_register_constant(&ec TSRMLS_CC); - - FREE_ZVAL(zin); - FREE_ZVAL(zout); - FREE_ZVAL(zerr); } /* }}} */ @@ -673,11 +657,11 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */ int lineno = 0; const char *param_error=NULL; int hide_argv = 0; + zend_string *key; zend_try { CG(in_compilation) = 0; /* not initialized but needed for several options */ - EG(uninitialized_zval_ptr) = NULL; while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0, 2)) != -1) { switch (c) { @@ -870,7 +854,7 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */ break; case 'z': /* load extension file */ - zend_load_extension(php_optarg); + zend_load_extension(php_optarg TSRMLS_CC); break; case 'H': hide_argv = 1; @@ -979,7 +963,9 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */ } } - zend_is_auto_global("_SERVER", sizeof("_SERVER")-1 TSRMLS_CC); + key = STR_INIT("_SERVER", sizeof("_SERVER")-1, 0); + zend_is_auto_global(key TSRMLS_CC); + STR_RELEASE(key); PG(during_request_startup) = 0; switch (behavior) { @@ -1024,7 +1010,7 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */ /* Zeev might want to do something with this one day */ case PHP_MODE_INDENT: open_file_for_scanning(&file_handle TSRMLS_CC); - zend_indent(); + zend_indent(TSRMLS_C); zend_file_handle_dtor(file_handle.handle TSRMLS_CC); goto out; break; @@ -1040,30 +1026,23 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */ { char *input; size_t len, index = 0; - zval *argn, *argi; + zval argn, argi; cli_register_file_handles(TSRMLS_C); if (exec_begin && zend_eval_string_ex(exec_begin, NULL, "Command line begin code", 1 TSRMLS_CC) == FAILURE) { exit_status=254; } - ALLOC_ZVAL(argi); - Z_TYPE_P(argi) = IS_LONG; - Z_LVAL_P(argi) = index; - INIT_PZVAL(argi); - zend_hash_update(&EG(symbol_table), "argi", sizeof("argi"), &argi, sizeof(zval *), NULL); + ZVAL_INT(&argi, index); + zend_hash_str_update(&EG(symbol_table).ht, "argi", sizeof("argi")-1, &argi); while (exit_status == SUCCESS && (input=php_stream_gets(s_in_process, NULL, 0)) != NULL) { len = strlen(input); - while (len-- && (input[len]=='\n' || input[len]=='\r')) { + while (len > 0 && len-- && (input[len]=='\n' || input[len]=='\r')) { input[len] = '\0'; } - ALLOC_ZVAL(argn); - Z_TYPE_P(argn) = IS_STRING; - Z_STRLEN_P(argn) = ++len; - Z_STRVAL_P(argn) = estrndup(input, len); - INIT_PZVAL(argn); - zend_hash_update(&EG(symbol_table), "argn", sizeof("argn"), &argn, sizeof(zval *), NULL); - Z_LVAL_P(argi) = ++index; + ZVAL_STRINGL(&argn, input, len); + zend_hash_str_update(&EG(symbol_table).ht, "argn", sizeof("argn")-1, &argn); + Z_IVAL(argi) = ++index; if (exec_run) { if (zend_eval_string_ex(exec_run, NULL, "Command line run code", 1 TSRMLS_CC) == FAILURE) { exit_status=254; @@ -1087,13 +1066,14 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */ break; } + case PHP_MODE_REFLECTION_FUNCTION: case PHP_MODE_REFLECTION_CLASS: case PHP_MODE_REFLECTION_EXTENSION: case PHP_MODE_REFLECTION_ZEND_EXTENSION: { zend_class_entry *pce = NULL; - zval *arg, *ref; + zval arg, ref; zend_execute_data execute_data; switch (behavior) { @@ -1117,24 +1097,23 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */ break; } - MAKE_STD_ZVAL(arg); - ZVAL_STRING(arg, reflection_what, 1); - ALLOC_ZVAL(ref); - object_init_ex(ref, pce); - INIT_PZVAL(ref); + ZVAL_STRING(&arg, reflection_what); + object_init_ex(&ref, pce); memset(&execute_data, 0, sizeof(zend_execute_data)); EG(current_execute_data) = &execute_data; - EX(function_state).function = pce->constructor; - zend_call_method_with_1_params(&ref, pce, &pce->constructor, "__construct", NULL, arg); + zend_call_method_with_1_params(&ref, pce, &pce->constructor, "__construct", NULL, &arg); if (EG(exception)) { - zval *msg = zend_read_property(zend_exception_get_default(TSRMLS_C), EG(exception), "message", sizeof("message")-1, 0 TSRMLS_CC); + zval tmp, *msg; + + ZVAL_OBJ(&tmp, EG(exception)); + msg = zend_read_property(zend_exception_get_default(TSRMLS_C), &tmp, "message", sizeof("message")-1, 0 TSRMLS_CC); zend_printf("Exception: %s\n", Z_STRVAL_P(msg)); - zval_ptr_dtor(&EG(exception)); + zval_ptr_dtor(&tmp); EG(exception) = NULL; } else { - zend_call_method_with_1_params(NULL, reflection_ptr, NULL, "export", NULL, ref); + zend_call_method_with_1_params(NULL, reflection_ptr, NULL, "export", NULL, &ref); } zval_ptr_dtor(&ref); zval_ptr_dtor(&arg); @@ -1147,7 +1126,7 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */ char *lcname = zend_str_tolower_dup(reflection_what, len); zend_module_entry *module; - if (zend_hash_find(&module_registry, lcname, len+1, (void**)&module) == FAILURE) { + if ((module = zend_hash_str_find_ptr(&module_registry, lcname, len)) == NULL) { if (!strcmp(reflection_what, "main")) { display_ini_entries(NULL); } else { @@ -1161,6 +1140,7 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */ efree(lcname); break; } + case PHP_MODE_SHOW_INI_CONFIG: { zend_printf("Configuration File (php.ini) Path: %s\n", PHP_CONFIG_FILE_PATH); diff --git a/sapi/cli/php_cli_process_title.c b/sapi/cli/php_cli_process_title.c index dec5613670..298300f065 100644 --- a/sapi/cli/php_cli_process_title.c +++ b/sapi/cli/php_cli_process_title.c @@ -66,7 +66,7 @@ PHP_FUNCTION(cli_get_process_title) RETURN_NULL(); } - RETURN_STRINGL(title, length, 1); + RETURN_STRINGL(title, length); } /* }}} */ diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c index f333addafd..f381e4ba2b 100644 --- a/sapi/cli/php_cli_server.c +++ b/sapi/cli/php_cli_server.c @@ -104,6 +104,7 @@ #include "php_http_parser.h" #include "php_cli_server.h" +#include "mime_type_map.h" #include "php_cli_process_title.h" @@ -138,7 +139,7 @@ typedef struct php_cli_server_request { size_t content_len; const char *ext; size_t ext_len; - struct stat sb; + php_stat_t sb; } php_cli_server_request; typedef struct php_cli_server_chunk { @@ -194,6 +195,7 @@ typedef struct php_cli_server { size_t router_len; socklen_t socklen; HashTable clients; + HashTable extension_mime_types; } php_cli_server; typedef struct php_cli_server_http_response_status_code_pair { @@ -201,11 +203,6 @@ typedef struct php_cli_server_http_response_status_code_pair { const char *str; } php_cli_server_http_response_status_code_pair; -typedef struct php_cli_server_ext_mime_type_pair { - const char *ext; - const char *mime_type; -} php_cli_server_ext_mime_type_pair; - static php_cli_server_http_response_status_code_pair status_map[] = { { 100, "Continue" }, { 101, "Switching Protocols" }, @@ -262,64 +259,6 @@ static php_cli_server_http_response_status_code_pair template_map[] = { { 501, "<h1>%s</h1><p>Request method not supported.</p>" } }; -static php_cli_server_ext_mime_type_pair mime_type_map[] = { - { "html", "text/html" }, - { "htm", "text/html" }, - { "js", "text/javascript" }, - { "css", "text/css" }, - { "gif", "image/gif" }, - { "jpg", "image/jpeg" }, - { "jpeg", "image/jpeg" }, - { "jpe", "image/jpeg" }, - { "pdf", "application/pdf" }, - { "png", "image/png" }, - { "svg", "image/svg+xml" }, - { "txt", "text/plain" }, - { "webm", "video/webm" }, - { "ogv", "video/ogg" }, - { "ogg", "audio/ogg" }, - { "3gp", "video/3gpp" }, /* This is standard video format used for MMS in phones */ - { "apk", "application/vnd.android.package-archive" }, - { "avi", "video/x-msvideo" }, - { "bmp", "image/x-ms-bmp" }, - { "csv", "text/comma-separated-values" }, - { "doc", "application/msword" }, - { "docx", "application/msword" }, - { "flac", "audio/flac" }, - { "gz", "application/x-gzip" }, - { "gzip", "application/x-gzip" }, - { "ics", "text/calendar" }, - { "kml", "application/vnd.google-earth.kml+xml" }, - { "kmz", "application/vnd.google-earth.kmz" }, - { "m4a", "audio/mp4" }, - { "mp3", "audio/mpeg" }, - { "mp4", "video/mp4" }, - { "mpg", "video/mpeg" }, - { "mpeg", "video/mpeg" }, - { "mov", "video/quicktime" }, - { "odp", "application/vnd.oasis.opendocument.presentation" }, - { "ods", "application/vnd.oasis.opendocument.spreadsheet" }, - { "odt", "application/vnd.oasis.opendocument.text" }, - { "oga", "audio/ogg" }, - { "pdf", "application/pdf" }, - { "pptx", "application/vnd.ms-powerpoint" }, - { "pps", "application/vnd.ms-powerpoint" }, - { "qt", "video/quicktime" }, - { "swf", "application/x-shockwave-flash" }, - { "tar", "application/x-tar" }, - { "text", "text/plain" }, - { "tif", "image/tiff" }, - { "wav", "audio/wav" }, - { "wmv", "video/x-ms-wmv" }, - { "xls", "application/vnd.ms-excel" }, - { "xlsx", "application/vnd.ms-excel" }, - { "zip", "application/x-zip-compressed" }, - { "xml", "application/xml" }, - { "xsl", "application/xml" }, - { "xsd", "application/xml" }, - { NULL, NULL } -}; - static int php_cli_output_is_tty = OUTPUT_NOT_CHECKED; static size_t php_cli_server_client_send_through(php_cli_server_client *client, const char *str, size_t str_len); @@ -371,9 +310,9 @@ int php_cli_server_get_system_time(char *buf) { } #endif -static void char_ptr_dtor_p(char **p) /* {{{ */ -{ - pefree(*p, 1); +static void char_ptr_dtor_p(zval *zv) /* {{{ */ +{ + pefree(Z_PTR_P(zv), 1); } /* }}} */ static char *get_last_error() /* {{{ */ @@ -454,37 +393,29 @@ static void append_http_status_line(smart_str *buffer, int protocol_version, int static void append_essential_headers(smart_str* buffer, php_cli_server_client *client, int persistent) /* {{{ */ { { - char **val; - if (SUCCESS == zend_hash_find(&client->request.headers, "host", sizeof("host"), (void**)&val)) { + char *val; + if (NULL != (val = zend_hash_str_find_ptr(&client->request.headers, "host", sizeof("host")-1))) { smart_str_appendl_ex(buffer, "Host", sizeof("Host") - 1, persistent); smart_str_appendl_ex(buffer, ": ", sizeof(": ") - 1, persistent); - smart_str_appends_ex(buffer, *val, persistent); + smart_str_appends_ex(buffer, val, persistent); smart_str_appendl_ex(buffer, "\r\n", 2, persistent); } } smart_str_appendl_ex(buffer, "Connection: close\r\n", sizeof("Connection: close\r\n") - 1, persistent); } /* }}} */ -static const char *get_mime_type(const char *ext, size_t ext_len) /* {{{ */ +static const char *get_mime_type(const php_cli_server *server, const char *ext, size_t ext_len) /* {{{ */ { - php_cli_server_ext_mime_type_pair *pair; - for (pair = mime_type_map; pair->ext; pair++) { - size_t len = strlen(pair->ext); - if (len == ext_len && memcmp(pair->ext, ext, len) == 0) { - return pair->mime_type; - } - } - return NULL; + return (const char*)zend_hash_str_find_ptr(&server->extension_mime_types, ext, ext_len); } /* }}} */ PHP_FUNCTION(apache_request_headers) /* {{{ */ { php_cli_server_client *client; HashTable *headers; - char *key; - uint key_len; - char **value_pointer; - HashPosition pos; + zend_string *key; + char *value; + zval tmp; if (zend_parse_parameters_none() == FAILURE) { return; @@ -495,19 +426,17 @@ PHP_FUNCTION(apache_request_headers) /* {{{ */ array_init_size(return_value, zend_hash_num_elements(headers)); - zend_hash_internal_pointer_reset_ex(headers, &pos); - while (zend_hash_get_current_data_ex(headers, (void **)&value_pointer, &pos) == SUCCESS) { - zend_hash_get_current_key_ex(headers, &key, &key_len, NULL, 0, &pos); - add_assoc_string_ex(return_value, key, key_len, *value_pointer, 1); - zend_hash_move_forward_ex(headers, &pos); - } + ZEND_HASH_FOREACH_STR_KEY_PTR(headers, key, value) { + ZVAL_STRING(&tmp, value); + zend_symtable_update(Z_ARRVAL_P(return_value), key, &tmp); + } ZEND_HASH_FOREACH_END(); } /* }}} */ static void add_response_header(sapi_header_struct *h, zval *return_value TSRMLS_DC) /* {{{ */ { char *s, *p; - int len; + ptrdiff_t len; ALLOCA_FLAG(use_heap) if (h->header_len > 0) { @@ -524,7 +453,7 @@ static void add_response_header(sapi_header_struct *h, zval *return_value TSRMLS do { p++; } while (*p == ' ' || *p == '\t'); - add_assoc_stringl_ex(return_value, s, len+1, p, h->header_len - (p - h->header), 1); + add_assoc_stringl_ex(return_value, s, len, p, h->header_len - (p - h->header)); free_alloca(s, use_heap); } } @@ -610,7 +539,7 @@ static int sapi_cli_server_startup(sapi_module_struct *sapi_module) /* {{{ */ return SUCCESS; } /* }}} */ -static int sapi_cli_server_ub_write(const char *str, uint str_length TSRMLS_DC) /* {{{ */ +static php_size_t sapi_cli_server_ub_write(const char *str, php_size_t str_length TSRMLS_DC) /* {{{ */ { php_cli_server_client *client = SG(server_context); if (!client) { @@ -619,10 +548,9 @@ static int sapi_cli_server_ub_write(const char *str, uint str_length TSRMLS_DC) return php_cli_server_client_send_through(client, str, str_length); } /* }}} */ -static void sapi_cli_server_flush(void *server_context) /* {{{ */ +static void sapi_cli_server_flush(void *server_context TSRMLS_DC) /* {{{ */ { php_cli_server_client *client = server_context; - TSRMLS_FETCH(); if (!client) { return; @@ -674,7 +602,7 @@ static int sapi_cli_server_send_headers(sapi_headers_struct *sapi_headers TSRMLS } smart_str_appendl(&buffer, "\r\n", 2); - php_cli_server_client_send_through(client, buffer.c, buffer.len); + php_cli_server_client_send_through(client, buffer.s->val, buffer.s->len); smart_str_free(&buffer); return SAPI_HEADER_SENT_SUCCESSFULLY; @@ -684,14 +612,14 @@ static int sapi_cli_server_send_headers(sapi_headers_struct *sapi_headers TSRMLS static char *sapi_cli_server_read_cookies(TSRMLS_D) /* {{{ */ { php_cli_server_client *client = SG(server_context); - char **val; - if (FAILURE == zend_hash_find(&client->request.headers, "cookie", sizeof("cookie"), (void**)&val)) { + char *val; + if (NULL == (val = zend_hash_str_find_ptr(&client->request.headers, "cookie", sizeof("cookie")-1))) { return NULL; } - return *val; + return val; } /* }}} */ -static int sapi_cli_server_read_post(char *buf, uint count_bytes TSRMLS_DC) /* {{{ */ +static php_size_t sapi_cli_server_read_post(char *buf, php_size_t count_bytes TSRMLS_DC) /* {{{ */ { php_cli_server_client *client = SG(server_context); if (client->request.content) { @@ -707,7 +635,7 @@ static int sapi_cli_server_read_post(char *buf, uint count_bytes TSRMLS_DC) /* { static void sapi_cli_server_register_variable(zval *track_vars_array, const char *key, const char *val TSRMLS_DC) /* {{{ */ { char *new_val = (char *)val; - uint new_val_len; + php_size_t new_val_len; if (sapi_module.input_filter(PARSE_SERVER, (char*)key, &new_val, strlen(val), &new_val_len TSRMLS_CC)) { php_register_variable_safe((char *)key, new_val, new_val_len, track_vars_array TSRMLS_CC); } @@ -715,11 +643,11 @@ static void sapi_cli_server_register_variable(zval *track_vars_array, const char static int sapi_cli_server_register_entry_cb(char **entry TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ { zval *track_vars_array = va_arg(args, zval *); - if (hash_key->nKeyLength) { + if (hash_key->key) { char *real_key, *key; uint i; - key = estrndup(hash_key->arKey, hash_key->nKeyLength); - for(i=0; i<hash_key->nKeyLength; i++) { + key = estrndup(hash_key->key->val, hash_key->key->len); + for(i=0; i<hash_key->key->len; i++) { if (key[i] == '-') { key[i] = '_'; } else { @@ -861,7 +789,7 @@ static int php_cli_server_poller_ctor(php_cli_server_poller *poller) /* {{{ */ return SUCCESS; } /* }}} */ -static void php_cli_server_poller_add(php_cli_server_poller *poller, int mode, int fd) /* {{{ */ +static void php_cli_server_poller_add(php_cli_server_poller *poller, int mode, php_socket_t fd) /* {{{ */ { if (mode & POLLIN) { PHP_SAFE_FD_SET(fd, &poller->rfds); @@ -874,7 +802,7 @@ static void php_cli_server_poller_add(php_cli_server_poller *poller, int mode, i } } /* }}} */ -static void php_cli_server_poller_remove(php_cli_server_poller *poller, int mode, int fd) /* {{{ */ +static void php_cli_server_poller_remove(php_cli_server_poller *poller, int mode, php_socket_t fd) /* {{{ */ { if (mode & POLLIN) { PHP_SAFE_FD_CLR(fd, &poller->rfds); @@ -902,7 +830,7 @@ static int php_cli_server_poller_poll(php_cli_server_poller *poller, struct time return php_select(poller->max_fd + 1, &poller->active.rfds, &poller->active.wfds, NULL, tv); } /* }}} */ -static int php_cli_server_poller_iter_on_active(php_cli_server_poller *poller, void *opaque, int(*callback)(void *, int fd, int events)) /* {{{ */ +static int php_cli_server_poller_iter_on_active(php_cli_server_poller *poller, void *opaque, int(*callback)(void *, php_socket_t fd, int events)) /* {{{ */ { int retval = SUCCESS; #ifdef PHP_WIN32 @@ -1053,7 +981,7 @@ static php_cli_server_chunk *php_cli_server_chunk_immortal_new(const char *buf, return chunk; } /* }}} */ -static php_cli_server_chunk *php_cli_server_chunk_heap_new(char *block, char *buf, size_t len) /* {{{ */ +static php_cli_server_chunk *php_cli_server_chunk_heap_new(void *block, char *buf, size_t len) /* {{{ */ { php_cli_server_chunk *chunk = pemalloc(sizeof(php_cli_server_chunk), 1); if (!chunk) { @@ -1146,7 +1074,7 @@ static int php_cli_server_content_sender_send(php_cli_server_content_sender *sen return 0; } /* }}} */ -static int php_cli_server_content_sender_pull(php_cli_server_content_sender *sender, int fd, size_t *nbytes_read) /* {{{ */ +static int php_cli_server_content_sender_pull(php_cli_server_content_sender *sender, int fd, size_t *nbytes_read TSRMLS_DC) /* {{{ */ { ssize_t _nbytes_read; php_cli_server_chunk *chunk = php_cli_server_chunk_heap_new_self_contained(131072); @@ -1154,7 +1082,6 @@ static int php_cli_server_content_sender_pull(php_cli_server_content_sender *sen _nbytes_read = read(fd, chunk->data.heap.p, chunk->data.heap.len); if (_nbytes_read < 0) { char *errstr = get_last_error(); - TSRMLS_FETCH(); php_cli_server_logf("%s" TSRMLS_CC, errstr); pefree(errstr, 1); php_cli_server_chunk_dtor(chunk); @@ -1280,9 +1207,9 @@ static void php_cli_server_logf(const char *format TSRMLS_DC, ...) /* {{{ */ efree(buf); } /* }}} */ -static int php_network_listen_socket(const char *host, int *port, int socktype, int *af, socklen_t *socklen, char **errstr TSRMLS_DC) /* {{{ */ +static int php_network_listen_socket(const char *host, int *port, int socktype, int *af, socklen_t *socklen, zend_string **errstr TSRMLS_DC) /* {{{ */ { - int retval = SOCK_ERR; + php_socket_t retval = SOCK_ERR; int err = 0; struct sockaddr *sa = NULL, **p, **sal; @@ -1395,7 +1322,7 @@ out: closesocket(retval); } if (errstr) { - *errstr = php_socket_strerror(err, NULL, 0); + *errstr = php_socket_error_str(err); } return SOCK_ERR; } @@ -1415,7 +1342,7 @@ static int php_cli_server_request_ctor(php_cli_server_request *req) /* {{{ */ req->path_info_len = 0; req->query_string = NULL; req->query_string_len = 0; - zend_hash_init(&req->headers, 0, NULL, (void(*)(void*))char_ptr_dtor_p, 1); + zend_hash_init(&req->headers, 0, NULL, char_ptr_dtor_p, 1); zend_hash_init(&req->headers_original_case, 0, NULL, NULL, 1); req->content = NULL; req->content_len = 0; @@ -1450,7 +1377,7 @@ static void php_cli_server_request_dtor(php_cli_server_request *req) /* {{{ */ static void php_cli_server_request_translate_vpath(php_cli_server_request *request, const char *document_root, size_t document_root_len) /* {{{ */ { - struct stat sb; + php_stat_t sb; static const char *index_files[] = { "index.php", "index.html", NULL }; char *buf = safe_pemalloc(1, request->vpath_len, 1 + document_root_len + 1 + sizeof("index.html"), 1); char *p = buf, *prev_path = NULL, *q, *vpath; @@ -1487,7 +1414,7 @@ static void php_cli_server_request_translate_vpath(php_cli_server_request *reque *p = '\0'; q = p; while (q > buf) { - if (!stat(buf, &sb)) { + if (!php_stat_fn(buf, &sb)) { if (sb.st_mode & S_IFDIR) { const char **file = index_files; if (q[-1] != DEFAULT_SLASH) { @@ -1496,7 +1423,7 @@ static void php_cli_server_request_translate_vpath(php_cli_server_request *reque while (*file) { size_t l = strlen(*file); memmove(q, *file, l + 1); - if (!stat(buf, &sb) && (sb.st_mode & S_IFREG)) { + if (!php_stat_fn(buf, &sb) && (sb.st_mode & S_IFREG)) { q += l; break; } @@ -1686,13 +1613,12 @@ static int php_cli_server_client_read_request_on_header_value(php_http_parser *p } { /* strip off the colon */ - char *orig_header_name = estrndup(client->current_header_name, client->current_header_name_len); + zend_string *orig_header_name = STR_INIT(client->current_header_name, client->current_header_name_len, 1); char *lc_header_name = zend_str_tolower_dup(client->current_header_name, client->current_header_name_len); - - zend_hash_add(&client->request.headers, lc_header_name, client->current_header_name_len + 1, &value, sizeof(char *), NULL); - zend_hash_add(&client->request.headers_original_case, orig_header_name, client->current_header_name_len + 1, &value, sizeof(char *), NULL); + zend_hash_str_add_ptr(&client->request.headers, lc_header_name, client->current_header_name_len, value); + zend_hash_add_ptr(&client->request.headers_original_case, orig_header_name, value); efree(lc_header_name); - efree(orig_header_name); + STR_RELEASE(orig_header_name); } if (client->current_header_name_allocated) { @@ -1841,7 +1767,7 @@ static size_t php_cli_server_client_send_through(php_cli_server_client *client, static void php_cli_server_client_populate_request_info(const php_cli_server_client *client, sapi_request_info *request_info) /* {{{ */ { - char **val; + char *val; request_info->request_method = php_http_method_str(client->request.request_method); request_info->proto_num = client->request.protocol_version; @@ -1850,8 +1776,8 @@ static void php_cli_server_client_populate_request_info(const php_cli_server_cli request_info->query_string = client->request.query_string; request_info->content_length = client->request.content_len; request_info->auth_user = request_info->auth_password = request_info->auth_digest = NULL; - if (SUCCESS == zend_hash_find(&client->request.headers, "content-type", sizeof("content-type"), (void**)&val)) { - request_info->content_type = *val; + if (NULL != (val = zend_hash_str_find_ptr(&client->request.headers, "content-type", sizeof("content-type")-1))) { + request_info->content_type = val; } } /* }}} */ @@ -1859,19 +1785,19 @@ static void destroy_request_info(sapi_request_info *request_info) /* {{{ */ { } /* }}} */ -static int php_cli_server_client_ctor(php_cli_server_client *client, php_cli_server *server, int client_sock, struct sockaddr *addr, socklen_t addr_len TSRMLS_DC) /* {{{ */ +static int php_cli_server_client_ctor(php_cli_server_client *client, php_cli_server *server, php_socket_t client_sock, struct sockaddr *addr, socklen_t addr_len TSRMLS_DC) /* {{{ */ { client->server = server; client->sock = client_sock; client->addr = addr; client->addr_len = addr_len; { - char *addr_str = 0; - long addr_str_len = 0; - php_network_populate_name_from_sockaddr(addr, addr_len, &addr_str, &addr_str_len, NULL, 0 TSRMLS_CC); - client->addr_str = pestrndup(addr_str, addr_str_len, 1); - client->addr_str_len = addr_str_len; - efree(addr_str); + zend_string *addr_str = 0; + + php_network_populate_name_from_sockaddr(addr, addr_len, &addr_str, NULL, 0 TSRMLS_CC); + client->addr_str = pestrndup(addr_str->val, addr_str->len, 1); + client->addr_str_len = addr_str->len; + STR_RELEASE(addr_str); } php_http_parser_init(&client->parser, PHP_HTTP_REQUEST); client->request_read = 0; @@ -1911,8 +1837,7 @@ static void php_cli_server_close_connection(php_cli_server *server, php_cli_serv static int php_cli_server_send_error_page(php_cli_server *server, php_cli_server_client *client, int status TSRMLS_DC) /* {{{ */ { - char *escaped_request_uri = NULL; - size_t escaped_request_uri_len; + zend_string *escaped_request_uri = NULL; const char *status_string = get_status_string(status); const char *content_template = get_template_string(status); char *errstr = get_last_error(); @@ -1921,7 +1846,7 @@ static int php_cli_server_send_error_page(php_cli_server *server, php_cli_server php_cli_server_content_sender_ctor(&client->content_sender); client->content_sender_initialized = 1; - escaped_request_uri = php_escape_html_entities_ex((unsigned char *)client->request.request_uri, client->request.request_uri_len, &escaped_request_uri_len, 0, ENT_QUOTES, NULL, 0 TSRMLS_CC); + escaped_request_uri = php_escape_html_entities_ex((unsigned char *)client->request.request_uri, client->request.request_uri_len, 0, ENT_QUOTES, NULL, 0 TSRMLS_CC); { static const char prologue_template[] = "<!doctype html><html><head><title>%d %s</title>"; @@ -1929,7 +1854,7 @@ static int php_cli_server_send_error_page(php_cli_server *server, php_cli_server if (!chunk) { goto fail; } - snprintf(chunk->data.heap.p, chunk->data.heap.len, prologue_template, status, status_string, escaped_request_uri); + snprintf(chunk->data.heap.p, chunk->data.heap.len, prologue_template, status, status_string, escaped_request_uri->val); chunk->data.heap.len = strlen(chunk->data.heap.p); php_cli_server_buffer_append(&client->content_sender.buffer, chunk); } @@ -1949,11 +1874,11 @@ static int php_cli_server_send_error_page(php_cli_server *server, php_cli_server php_cli_server_buffer_append(&client->content_sender.buffer, chunk); } { - php_cli_server_chunk *chunk = php_cli_server_chunk_heap_new_self_contained(strlen(content_template) + escaped_request_uri_len + 3 + strlen(status_string) + 1); + php_cli_server_chunk *chunk = php_cli_server_chunk_heap_new_self_contained(strlen(content_template) + escaped_request_uri->len + 3 + strlen(status_string) + 1); if (!chunk) { goto fail; } - snprintf(chunk->data.heap.p, chunk->data.heap.len, content_template, status_string, escaped_request_uri); + snprintf(chunk->data.heap.p, chunk->data.heap.len, content_template, status_string, escaped_request_uri->val); chunk->data.heap.len = strlen(chunk->data.heap.p); php_cli_server_buffer_append(&client->content_sender.buffer, chunk); } @@ -1970,7 +1895,7 @@ static int php_cli_server_send_error_page(php_cli_server *server, php_cli_server php_cli_server_chunk *chunk; smart_str buffer = { 0 }; append_http_status_line(&buffer, client->request.protocol_version, status, 1); - if (!buffer.c) { + if (!buffer.s) { /* out of memory */ goto fail; } @@ -1981,7 +1906,7 @@ static int php_cli_server_send_error_page(php_cli_server *server, php_cli_server smart_str_appendl_ex(&buffer, "\r\n", 2, 1); smart_str_appendl_ex(&buffer, "\r\n", 2, 1); - chunk = php_cli_server_chunk_heap_new(buffer.c, buffer.c, buffer.len); + chunk = php_cli_server_chunk_heap_new(buffer.s, buffer.s->val, buffer.s->len); if (!chunk) { smart_str_free_ex(&buffer, 1); goto fail; @@ -1994,14 +1919,14 @@ static int php_cli_server_send_error_page(php_cli_server *server, php_cli_server if (errstr) { pefree(errstr, 1); } - efree(escaped_request_uri); + STR_FREE(escaped_request_uri); return SUCCESS; fail: if (errstr) { pefree(errstr, 1); } - efree(escaped_request_uri); + STR_FREE(escaped_request_uri); return FAILURE; } /* }}} */ @@ -2049,13 +1974,13 @@ static int php_cli_server_begin_send_static(php_cli_server *server, php_cli_serv { php_cli_server_chunk *chunk; smart_str buffer = { 0 }; - const char *mime_type = get_mime_type(client->request.ext, client->request.ext_len); + const char *mime_type = get_mime_type(server, client->request.ext, client->request.ext_len); if (!mime_type) { mime_type = "application/octet-stream"; } append_http_status_line(&buffer, client->request.protocol_version, status, 1); - if (!buffer.c) { + if (!buffer.s) { /* out of memory */ php_cli_server_log_response(client, 500, NULL TSRMLS_CC); return FAILURE; @@ -2071,7 +1996,7 @@ static int php_cli_server_begin_send_static(php_cli_server *server, php_cli_serv smart_str_append_generic_ex(&buffer, client->request.sb.st_size, 1, size_t, _unsigned); smart_str_appendl_ex(&buffer, "\r\n", 2, 1); smart_str_appendl_ex(&buffer, "\r\n", 2, 1); - chunk = php_cli_server_chunk_heap_new(buffer.c, buffer.c, buffer.len); + chunk = php_cli_server_chunk_heap_new(buffer.s, buffer.s->val, buffer.s->len); if (!chunk) { smart_str_free_ex(&buffer, 1); php_cli_server_log_response(client, 500, NULL TSRMLS_CC); @@ -2086,10 +2011,10 @@ static int php_cli_server_begin_send_static(php_cli_server *server, php_cli_serv /* }}} */ static int php_cli_server_request_startup(php_cli_server *server, php_cli_server_client *client TSRMLS_DC) { /* {{{ */ - char **auth; + char *auth; php_cli_server_client_populate_request_info(client, &SG(request_info)); - if (SUCCESS == zend_hash_find(&client->request.headers, "authorization", sizeof("authorization"), (void**)&auth)) { - php_handle_auth_data(*auth TSRMLS_CC); + if (NULL != (auth = zend_hash_str_find_ptr(&client->request.headers, "authorization", sizeof("authorization")-1))) { + php_handle_auth_data(auth TSRMLS_CC); } SG(sapi_headers).http_response_code = 200; if (FAILURE == php_request_startup(TSRMLS_C)) { @@ -2131,10 +2056,10 @@ static int php_cli_server_dispatch_router(php_cli_server *server, php_cli_server zfd.opened_path = NULL; zend_try { - zval *retval = NULL; + zval retval; if (SUCCESS == zend_execute_scripts(ZEND_REQUIRE TSRMLS_CC, &retval, 1, &zfd)) { - if (retval) { - decline = Z_TYPE_P(retval) == IS_BOOL && !Z_LVAL_P(retval); + if (Z_TYPE(retval) != IS_UNDEF) { + decline = Z_TYPE(retval) == IS_FALSE; zval_ptr_dtor(&retval); } } else { @@ -2209,9 +2134,28 @@ static int php_cli_server_dispatch(php_cli_server *server, php_cli_server_client } /* }}} */ +static int php_cli_server_mime_type_ctor(php_cli_server *server, const php_cli_server_ext_mime_type_pair *mime_type_map) /* {{{ */ +{ + const php_cli_server_ext_mime_type_pair *pair; + + zend_hash_init(&server->extension_mime_types, 0, NULL, NULL, 1); + + for (pair = mime_type_map; pair->ext; pair++) { + size_t ext_len = 0, mime_type_len = 0; + + ext_len = strlen(pair->ext); + mime_type_len = strlen(pair->mime_type); + + zend_hash_str_add_mem(&server->extension_mime_types, pair->ext, ext_len, (void*)pair->mime_type, mime_type_len + 1); + } + + return SUCCESS; +} /* }}} */ + static void php_cli_server_dtor(php_cli_server *server TSRMLS_DC) /* {{{ */ { zend_hash_destroy(&server->clients); + zend_hash_destroy(&server->extension_mime_types); if (server->server_sock >= 0) { closesocket(server->server_sock); } @@ -2226,19 +2170,21 @@ static void php_cli_server_dtor(php_cli_server *server TSRMLS_DC) /* {{{ */ } } /* }}} */ -static void php_cli_server_client_dtor_wrapper(php_cli_server_client **p) /* {{{ */ +static void php_cli_server_client_dtor_wrapper(zval *zv) /* {{{ */ { - closesocket((*p)->sock); - php_cli_server_poller_remove(&(*p)->server->poller, POLLIN | POLLOUT, (*p)->sock); - php_cli_server_client_dtor(*p); - pefree(*p, 1); + php_cli_server_client *p = Z_PTR_P(zv); + + closesocket(p->sock); + php_cli_server_poller_remove(&p->server->poller, POLLIN | POLLOUT, p->sock); + php_cli_server_client_dtor(p); + pefree(p, 1); } /* }}} */ static int php_cli_server_ctor(php_cli_server *server, const char *addr, const char *document_root, const char *router TSRMLS_DC) /* {{{ */ { int retval = SUCCESS; char *host = NULL; - char *errstr = NULL; + zend_string *errstr = NULL; char *_document_root = NULL; char *_router = NULL; int err = 0; @@ -2285,8 +2231,10 @@ static int php_cli_server_ctor(php_cli_server *server, const char *addr, const c server_sock = php_network_listen_socket(host, &port, SOCK_STREAM, &server->address_family, &server->socklen, &errstr TSRMLS_CC); if (server_sock == SOCK_ERR) { - php_cli_server_logf("Failed to listen on %s:%d (reason: %s)" TSRMLS_CC, host, port, errstr ? errstr: "?"); - efree(errstr); + php_cli_server_logf("Failed to listen on %s:%d (reason: %s)" TSRMLS_CC, host, port, errstr ? errstr->val : "?"); + if (errstr) { + STR_RELEASE(errstr); + } retval = FAILURE; goto out; } @@ -2302,7 +2250,7 @@ static int php_cli_server_ctor(php_cli_server *server, const char *addr, const c server->host = host; server->port = port; - zend_hash_init(&server->clients, 0, NULL, (void(*)(void*))php_cli_server_client_dtor_wrapper, 1); + zend_hash_init(&server->clients, 0, NULL, php_cli_server_client_dtor_wrapper, 1); { size_t document_root_len = strlen(document_root); @@ -2329,6 +2277,11 @@ static int php_cli_server_ctor(php_cli_server *server, const char *addr, const c server->router_len = 0; } + if (php_cli_server_mime_type_ctor(server, mime_type_map) == FAILURE) { + retval = FAILURE; + goto out; + } + server->is_running = 1; out: if (retval != SUCCESS) { @@ -2374,7 +2327,7 @@ static int php_cli_server_send_event(php_cli_server *server, php_cli_server_clie if (client->content_sender_initialized) { if (client->file_fd >= 0 && !client->content_sender.buffer.first) { size_t nbytes_read; - if (php_cli_server_content_sender_pull(&client->content_sender, client->file_fd, &nbytes_read)) { + if (php_cli_server_content_sender_pull(&client->content_sender, client->file_fd, &nbytes_read TSRMLS_CC)) { php_cli_server_close_connection(server, client TSRMLS_CC); return FAILURE; } @@ -2408,7 +2361,7 @@ typedef struct php_cli_server_do_event_for_each_fd_callback_params { int(*whandler)(php_cli_server*, php_cli_server_client* TSRMLS_DC); } php_cli_server_do_event_for_each_fd_callback_params; -static int php_cli_server_do_event_for_each_fd_callback(void *_params, int fd, int event) /* {{{ */ +static int php_cli_server_do_event_for_each_fd_callback(void *_params, php_socket_t fd, int event) /* {{{ */ { php_cli_server_do_event_for_each_fd_callback_params *params = _params; #ifdef ZTS @@ -2446,16 +2399,16 @@ static int php_cli_server_do_event_for_each_fd_callback(void *_params, int fd, i #ifdef DEBUG php_cli_server_logf("%s Accepted" TSRMLS_CC, client->addr_str); #endif - zend_hash_index_update(&server->clients, client_sock, &client, sizeof(client), NULL); + zend_hash_index_update_ptr(&server->clients, client_sock, client); php_cli_server_recv_event_read_request(server, client TSRMLS_CC); } else { - php_cli_server_client **client; - if (SUCCESS == zend_hash_index_find(&server->clients, fd, (void **)&client)) { + php_cli_server_client *client; + if (NULL != (client = zend_hash_index_find_ptr(&server->clients, fd))) { if (event & POLLIN) { - params->rhandler(server, *client TSRMLS_CC); + params->rhandler(server, client TSRMLS_CC); } if (event & POLLOUT) { - params->whandler(server, *client TSRMLS_CC); + params->whandler(server, client TSRMLS_CC); } } } @@ -2534,9 +2487,9 @@ int do_cli_server(int argc, char **argv TSRMLS_DC) /* {{{ */ } if (document_root) { - struct stat sb; + php_stat_t sb; - if (stat(document_root, &sb)) { + if (php_stat_fn(document_root, &sb)) { fprintf(stderr, "Directory %s does not exist.\n", document_root); return 1; } diff --git a/sapi/cli/tests/006.phpt b/sapi/cli/tests/006.phpt index 3d5c916e9c..e9e8b7e219 100644 --- a/sapi/cli/tests/006.phpt +++ b/sapi/cli/tests/006.phpt @@ -34,6 +34,9 @@ string(%d) "Extension [ <persistent> extension #%d pcre version <no_version> ] { Entry [ pcre.recursion_limit <ALL> ] Current = '%d' } + Entry [ pcre.jit <ALL> ] + Current = '%d' + } } - Constants [14] { diff --git a/sapi/cli/tests/bug61977.phpt b/sapi/cli/tests/bug61977.phpt index 09a6ba6d23..6250c9aec0 100644 --- a/sapi/cli/tests/bug61977.phpt +++ b/sapi/cli/tests/bug61977.phpt @@ -48,7 +48,7 @@ foo.html => Content-Type: text/html; charset=UTF-8 foo.htm => Content-Type: text/html; charset=UTF-8 foo.svg => Content-Type: image/svg+xml foo.css => Content-Type: text/css; charset=UTF-8 -foo.js => Content-Type: text/javascript; charset=UTF-8 +foo.js => Content-Type: application/javascript foo.png => Content-Type: image/png foo.webm => Content-Type: video/webm foo.ogv => Content-Type: video/ogg diff --git a/sapi/continuity/capi.c b/sapi/continuity/capi.c index 953991474d..30d10ed0a0 100644 --- a/sapi/continuity/capi.c +++ b/sapi/continuity/capi.c @@ -462,7 +462,7 @@ int phpFinit(lstTset * opt) core_globals = ts_resource(core_globals_id); logFmsg(0, "mod/php: PHP Interface v3 (module)"); - logFmsg(0, "mod/php: Copyright (c) 1999-2005 The PHP Group. All rights reserved."); + logFmsg(0, "mod/php: Copyright (c) 1999-2014 The PHP Group. All rights reserved."); sapi_startup(&capi_sapi_module); capi_sapi_module.startup(&capi_sapi_module); diff --git a/sapi/embed/php_embed.c b/sapi/embed/php_embed.c index dad54de1ae..2f2f31fb85 100644 --- a/sapi/embed/php_embed.c +++ b/sapi/embed/php_embed.c @@ -44,10 +44,10 @@ static int php_embed_deactivate(TSRMLS_D) return SUCCESS; } -static inline size_t php_embed_single_write(const char *str, uint str_length) +static inline size_t php_embed_single_write(const char *str, php_size_t str_length) { #ifdef PHP_WRITE_STDOUT - long ret; + php_int_t ret; ret = write(STDOUT_FILENO, str, str_length); if (ret <= 0) return 0; @@ -61,10 +61,10 @@ static inline size_t php_embed_single_write(const char *str, uint str_length) } -static int php_embed_ub_write(const char *str, uint str_length TSRMLS_DC) +static php_size_t php_embed_ub_write(const char *str, php_size_t str_length TSRMLS_DC) { const char *ptr = str; - uint remaining = str_length; + php_size_t remaining = str_length; size_t ret; while (remaining > 0) { @@ -79,7 +79,7 @@ static int php_embed_ub_write(const char *str, uint str_length TSRMLS_DC) return str_length; } -static void php_embed_flush(void *server_context) +static void php_embed_flush(void *server_context TSRMLS_DC) { if (fflush(stdout)==EOF) { php_handle_aborted_connection(); diff --git a/sapi/fpm/fpm/fastcgi.c b/sapi/fpm/fpm/fastcgi.c index d77b6f8ca7..e5018591ee 100644 --- a/sapi/fpm/fpm/fastcgi.c +++ b/sapi/fpm/fpm/fastcgi.c @@ -479,11 +479,7 @@ static int fcgi_get_params(fcgi_request *req, unsigned char *p, unsigned char *e memcpy(tmp, p, eff_name_len); tmp[eff_name_len] = 0; s = estrndup((char*)p + name_len, val_len); - if (s == NULL) { - ret = 0; - break; - } - zend_hash_update(req->env, tmp, eff_name_len+1, &s, sizeof(char*), NULL); + zend_hash_str_update_ptr(req->env, tmp, eff_name_len, s); p += name_len + val_len; } if (tmp != buf && tmp != NULL) { @@ -492,9 +488,9 @@ static int fcgi_get_params(fcgi_request *req, unsigned char *p, unsigned char *e return ret; } -static void fcgi_free_var(char **s) +static void fcgi_free_var(zval *zv) { - efree(*s); + efree(Z_PTR_P(zv)); } static int fcgi_read_request(fcgi_request *req) @@ -509,7 +505,7 @@ static int fcgi_read_request(fcgi_request *req) req->out_hdr = NULL; req->out_pos = req->out_buf; ALLOC_HASHTABLE(req->env); - zend_hash_init(req->env, 0, NULL, (void (*)(void *)) fcgi_free_var, 0); + zend_hash_init(req->env, 0, NULL, fcgi_free_var, 0); if (safe_read(req, &hdr, sizeof(fcgi_header)) != sizeof(fcgi_header) || hdr.version < FCGI_VERSION_1) { @@ -546,15 +542,15 @@ static int fcgi_read_request(fcgi_request *req) switch ((((fcgi_begin_request*)buf)->roleB1 << 8) + ((fcgi_begin_request*)buf)->roleB0) { case FCGI_RESPONDER: val = estrdup("RESPONDER"); - zend_hash_update(req->env, "FCGI_ROLE", sizeof("FCGI_ROLE"), &val, sizeof(char*), NULL); + zend_hash_str_update_ptr(req->env, "FCGI_ROLE", sizeof("FCGI_ROLE"), val); break; case FCGI_AUTHORIZER: val = estrdup("AUTHORIZER"); - zend_hash_update(req->env, "FCGI_ROLE", sizeof("FCGI_ROLE"), &val, sizeof(char*), NULL); + zend_hash_str_update_ptr(req->env, "FCGI_ROLE", sizeof("FCGI_ROLE"), val); break; case FCGI_FILTER: val = estrdup("FILTER"); - zend_hash_update(req->env, "FCGI_ROLE", sizeof("FCGI_ROLE"), &val, sizeof(char*), NULL); + zend_hash_str_update_ptr(req->env, "FCGI_ROLE", sizeof("FCGI_ROLE"), val); break; default: return 0; @@ -593,12 +589,8 @@ static int fcgi_read_request(fcgi_request *req) } } else if (hdr.type == FCGI_GET_VALUES) { unsigned char *p = buf + sizeof(fcgi_header); - HashPosition pos; - char * str_index; - uint str_length; - ulong num_index; - int key_type; - zval ** value; + zend_string *key; + zval *value; if (safe_read(req, buf, len+padding) != len+padding) { req->keep = 0; @@ -610,28 +602,26 @@ static int fcgi_read_request(fcgi_request *req) return 0; } - zend_hash_internal_pointer_reset_ex(req->env, &pos); - while ((key_type = zend_hash_get_current_key_ex(req->env, &str_index, &str_length, &num_index, 0, &pos)) != HASH_KEY_NON_EXISTENT) { + ZEND_HASH_FOREACH_STR_KEY(req->env, key) { int zlen; - zend_hash_move_forward_ex(req->env, &pos); - if (key_type != HASH_KEY_IS_STRING) { + if (!key) { continue; } - if (zend_hash_find(&fcgi_mgmt_vars, str_index, str_length, (void**) &value) != SUCCESS) { + value = zend_hash_find(&fcgi_mgmt_vars, key); + if (!value) { continue; } - --str_length; - zlen = Z_STRLEN_PP(value); - if ((p + 4 + 4 + str_length + zlen) >= (buf + sizeof(buf))) { + zlen = Z_STRSIZE_P(value); + if ((p + 4 + 4 + key->len + zlen) >= (buf + sizeof(buf))) { break; } - if (str_length < 0x80) { - *p++ = str_length; + if (key->len < 0x80) { + *p++ = key->len; } else { - *p++ = ((str_length >> 24) & 0xff) | 0x80; - *p++ = (str_length >> 16) & 0xff; - *p++ = (str_length >> 8) & 0xff; - *p++ = str_length & 0xff; + *p++ = ((key->len >> 24) & 0xff) | 0x80; + *p++ = (key->len >> 16) & 0xff; + *p++ = (key->len >> 8) & 0xff; + *p++ = key->len & 0xff; } if (zlen < 0x80) { *p++ = zlen; @@ -641,11 +631,11 @@ static int fcgi_read_request(fcgi_request *req) *p++ = (zlen >> 8) & 0xff; *p++ = zlen & 0xff; } - memcpy(p, str_index, str_length); - p += str_length; - memcpy(p, Z_STRVAL_PP(value), zlen); + memcpy(p, key->val, key->len); + p += key->len; + memcpy(p, Z_STRVAL_P(value), zlen); p += zlen; - } + } ZEND_HASH_FOREACH_END(); len = p - buf - sizeof(fcgi_header); len += fcgi_make_header((fcgi_header*)buf, FCGI_GET_VALUES_RESULT, 0, len); if (safe_write(req, buf, sizeof(fcgi_header)+len) != (int)sizeof(fcgi_header)+len) { @@ -1050,28 +1040,22 @@ int fcgi_finish_request(fcgi_request *req, int force_close) char* fcgi_getenv(fcgi_request *req, const char* var, int var_len) { - char **val; - - if (!req) return NULL; - - if (zend_hash_find(req->env, (char*)var, var_len+1, (void**)&val) == SUCCESS) { - return *val; + if (!req) { + return NULL; } - return NULL; + + return zend_hash_str_find_ptr(req->env, var, var_len); } char* fcgi_putenv(fcgi_request *req, char* var, int var_len, char* val) { if (var && req) { if (val == NULL) { - zend_hash_del(req->env, var, var_len+1); + zend_hash_str_del(req->env, var, var_len); } else { - char **ret; - val = estrdup(val); - if (zend_hash_update(req->env, var, var_len+1, &val, sizeof(char*), (void**)&ret) == SUCCESS) { - return *ret; - } + zend_hash_str_update_ptr(req->env, var, var_len, val); + return val; } } return NULL; @@ -1079,19 +1063,14 @@ char* fcgi_putenv(fcgi_request *req, char* var, int var_len, char* val) void fcgi_set_mgmt_var(const char * name, size_t name_len, const char * value, size_t value_len) { - zval * zvalue; - zvalue = pemalloc(sizeof(*zvalue), 1); - Z_TYPE_P(zvalue) = IS_STRING; - Z_STRVAL_P(zvalue) = pestrndup(value, value_len, 1); - Z_STRLEN_P(zvalue) = value_len; - zend_hash_add(&fcgi_mgmt_vars, name, name_len + 1, &zvalue, sizeof(zvalue), NULL); + zval zvalue; + ZVAL_STR(&zvalue, STR_INIT(value, value_len, 1)); + zend_hash_str_add(&fcgi_mgmt_vars, name, name_len, &zvalue); } -void fcgi_free_mgmt_var_cb(void * ptr) +void fcgi_free_mgmt_var_cb(zval *zv) { - zval ** var = (zval **)ptr; - pefree(Z_STRVAL_PP(var), 1); - pefree(*var, 1); + STR_FREE(Z_STR_P(zv)); } char *fcgi_get_last_client_ip() /* {{{ */ diff --git a/sapi/fpm/fpm/fastcgi.h b/sapi/fpm/fpm/fastcgi.h index 34f9eef9da..5a8aa0e70e 100644 --- a/sapi/fpm/fpm/fastcgi.h +++ b/sapi/fpm/fpm/fastcgi.h @@ -131,7 +131,7 @@ ssize_t fcgi_write(fcgi_request *req, fcgi_request_type type, const char *str, i int fcgi_flush(fcgi_request *req, int close); void fcgi_set_mgmt_var(const char * name, size_t name_len, const char * value, size_t value_len); -void fcgi_free_mgmt_var_cb(void * ptr); +void fcgi_free_mgmt_var_cb(zval *ptr); char *fcgi_get_last_client_ip(); diff --git a/sapi/fpm/fpm/fpm_conf.c b/sapi/fpm/fpm/fpm_conf.c index 34e0480101..18ddccb300 100644 --- a/sapi/fpm/fpm/fpm_conf.c +++ b/sapi/fpm/fpm/fpm_conf.c @@ -1476,7 +1476,8 @@ static void fpm_conf_ini_parser(zval *arg1, zval *arg2, zval *arg3, int callback int fpm_conf_load_ini_file(char *filename TSRMLS_DC) /* {{{ */ { int error = 0; - char buf[1024+1]; + char *buf = NULL, *newbuf = NULL; + int bufsize = 0; int fd, n; int nb_read = 1; char c = '*'; @@ -1503,19 +1504,36 @@ int fpm_conf_load_ini_file(char *filename TSRMLS_DC) /* {{{ */ ini_lineno = 0; while (nb_read > 0) { int tmp; - memset(buf, 0, sizeof(char) * (1024 + 1)); - for (n = 0; n < 1024 && (nb_read = read(fd, &c, sizeof(char))) == sizeof(char) && c != '\n'; n++) { + ini_lineno++; + ini_filename = filename; + for (n = 0; (nb_read = read(fd, &c, sizeof(char))) == sizeof(char) && c != '\n'; n++) { + if (n == bufsize) { + bufsize += 1024; + newbuf = (char*) realloc(buf, sizeof(char) * (bufsize + 2)); + if (newbuf == NULL) { + ini_recursion--; + close(fd); + free(buf); + return -1; + } + buf = newbuf; + } + buf[n] = c; } + if (n == 0) { + continue; + } + /* always append newline and null terminate */ buf[n++] = '\n'; - ini_lineno++; - ini_filename = filename; + buf[n] = '\0'; tmp = zend_parse_ini_string(buf, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t)fpm_conf_ini_parser, &error TSRMLS_CC); ini_filename = filename; if (error || tmp == FAILURE) { if (ini_include) free(ini_include); ini_recursion--; close(fd); + free(buf); return -1; } if (ini_include) { @@ -1527,16 +1545,17 @@ int fpm_conf_load_ini_file(char *filename TSRMLS_DC) /* {{{ */ free(tmp); ini_recursion--; close(fd); + free(buf); return -1; } free(tmp); } } + free(buf); ini_recursion--; close(fd); return ret; - } /* }}} */ diff --git a/sapi/fpm/fpm/fpm_main.c b/sapi/fpm/fpm/fpm_main.c index cd5492d73d..5e9fa89cc8 100644 --- a/sapi/fpm/fpm/fpm_main.c +++ b/sapi/fpm/fpm/fpm_main.c @@ -188,10 +188,12 @@ typedef struct _user_config_cache_entry { HashTable *user_config; } user_config_cache_entry; -static void user_config_cache_entry_dtor(user_config_cache_entry *entry) +static void user_config_cache_entry_dtor(zval *el) { + user_config_cache_entry *entry = (user_config_cache_entry *)Z_PTR_P(el); zend_hash_destroy(entry->user_config); free(entry->user_config); + free(entry); } /* }}} */ @@ -216,30 +218,30 @@ static php_cgi_globals_struct php_cgi_globals; #define TRANSLATE_SLASHES(path) #endif -static int print_module_info(zend_module_entry *module, void *arg TSRMLS_DC) +static int print_module_info(zval *zv TSRMLS_DC) { + zend_module_entry *module = Z_PTR_P(zv); php_printf("%s\n", module->name); return 0; } static int module_name_cmp(const void *a, const void *b TSRMLS_DC) { - Bucket *f = *((Bucket **) a); - Bucket *s = *((Bucket **) b); + Bucket *f = (Bucket *) a; + Bucket *s = (Bucket *) b; - return strcasecmp( ((zend_module_entry *)f->pData)->name, - ((zend_module_entry *)s->pData)->name); + return strcasecmp( ((zend_module_entry *) Z_PTR(f->val))->name, + ((zend_module_entry *) Z_PTR(s->val))->name); } static void print_modules(TSRMLS_D) { HashTable sorted_registry; - zend_module_entry tmp; zend_hash_init(&sorted_registry, 50, NULL, NULL, 1); - zend_hash_copy(&sorted_registry, &module_registry, NULL, &tmp, sizeof(zend_module_entry)); + zend_hash_copy(&sorted_registry, &module_registry, NULL); zend_hash_sort(&sorted_registry, zend_qsort, module_name_cmp, 0 TSRMLS_CC); - zend_hash_apply_with_argument(&sorted_registry, (apply_func_arg_t) print_module_info, NULL TSRMLS_CC); + zend_hash_apply(&sorted_registry, print_module_info TSRMLS_CC); zend_hash_destroy(&sorted_registry); } @@ -316,7 +318,7 @@ static int sapi_cgibin_ub_write(const char *str, uint str_length TSRMLS_DC) } -static void sapi_cgibin_flush(void *server_context) +static void sapi_cgibin_flush(void *server_context TSRMLS_DC) { /* fpm has started, let use fcgi instead of stdout */ if (fpm_is_running) { @@ -568,32 +570,23 @@ static char *sapi_cgi_read_cookies(TSRMLS_D) void cgi_php_import_environment_variables(zval *array_ptr TSRMLS_DC) { fcgi_request *request; - HashPosition pos; - char *var, **val; - uint var_len; - ulong idx; + zend_string *var; + char *val; int filter_arg; - - if (PG(http_globals)[TRACK_VARS_ENV] && - array_ptr != PG(http_globals)[TRACK_VARS_ENV] && - Z_TYPE_P(PG(http_globals)[TRACK_VARS_ENV]) == IS_ARRAY && - zend_hash_num_elements(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_ENV])) > 0 + if (Z_TYPE(PG(http_globals)[TRACK_VARS_ENV]) == IS_ARRAY && + Z_ARR_P(array_ptr) != Z_ARR(PG(http_globals)[TRACK_VARS_ENV]) && + zend_hash_num_elements(Z_ARRVAL(PG(http_globals)[TRACK_VARS_ENV])) > 0 ) { zval_dtor(array_ptr); - *array_ptr = *PG(http_globals)[TRACK_VARS_ENV]; - INIT_PZVAL(array_ptr); - zval_copy_ctor(array_ptr); + ZVAL_DUP(array_ptr, &PG(http_globals)[TRACK_VARS_ENV]); return; - } else if (PG(http_globals)[TRACK_VARS_SERVER] && - array_ptr != PG(http_globals)[TRACK_VARS_SERVER] && - Z_TYPE_P(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY && - zend_hash_num_elements(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER])) > 0 + } else if (Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY && + Z_ARR_P(array_ptr) != Z_ARR(PG(http_globals)[TRACK_VARS_SERVER]) && + zend_hash_num_elements(Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER])) > 0 ) { zval_dtor(array_ptr); - *array_ptr = *PG(http_globals)[TRACK_VARS_SERVER]; - INIT_PZVAL(array_ptr); - zval_copy_ctor(array_ptr); + ZVAL_DUP(array_ptr, &PG(http_globals)[TRACK_VARS_SERVER]); return; } @@ -601,19 +594,16 @@ void cgi_php_import_environment_variables(zval *array_ptr TSRMLS_DC) php_php_import_environment_variables(array_ptr TSRMLS_CC); request = (fcgi_request*) SG(server_context); - filter_arg = (array_ptr == PG(http_globals)[TRACK_VARS_ENV])?PARSE_ENV:PARSE_SERVER; + filter_arg = Z_ARR_P(array_ptr) == Z_ARR(PG(http_globals)[TRACK_VARS_ENV]) + ? PARSE_ENV : PARSE_SERVER; - for (zend_hash_internal_pointer_reset_ex(request->env, &pos); - zend_hash_get_current_key_ex(request->env, &var, &var_len, &idx, 0, &pos) == HASH_KEY_IS_STRING && - zend_hash_get_current_data_ex(request->env, (void **) &val, &pos) == SUCCESS; - zend_hash_move_forward_ex(request->env, &pos) - ) { + ZEND_HASH_FOREACH_STR_KEY_PTR(request->env, var, val) { unsigned int new_val_len; - if (sapi_module.input_filter(filter_arg, var, val, strlen(*val), &new_val_len TSRMLS_CC)) { - php_register_variable_safe(var, *val, new_val_len, array_ptr TSRMLS_CC); + if (var && sapi_module.input_filter(filter_arg, var->val, &val, strlen(val), &new_val_len TSRMLS_CC)) { + php_register_variable_safe(var->val, val, new_val_len, array_ptr TSRMLS_CC); } - } + } ZEND_HASH_FOREACH_END(); } static void sapi_cgi_register_variables(zval *track_vars_array TSRMLS_DC) @@ -695,17 +685,16 @@ static void sapi_cgi_log_message(char *message) static void php_cgi_ini_activate_user_config(char *path, int path_len, const char *doc_root, int doc_root_len, int start TSRMLS_DC) { char *ptr; - user_config_cache_entry *new_entry, *entry; time_t request_time = sapi_get_request_time(TSRMLS_C); + user_config_cache_entry *entry = zend_hash_str_find_ptr(&CGIG(user_config_cache), path, path_len); /* Find cached config entry: If not found, create one */ - if (zend_hash_find(&CGIG(user_config_cache), path, path_len + 1, (void **) &entry) == FAILURE) { - new_entry = pemalloc(sizeof(user_config_cache_entry), 1); - new_entry->expires = 0; - new_entry->user_config = (HashTable *) pemalloc(sizeof(HashTable), 1); - zend_hash_init(new_entry->user_config, 0, NULL, (dtor_func_t) config_zval_dtor, 1); - zend_hash_update(&CGIG(user_config_cache), path, path_len + 1, new_entry, sizeof(user_config_cache_entry), (void **) &entry); - free(new_entry); + if (!entry) { + entry = pemalloc(sizeof(user_config_cache_entry), 1); + entry->expires = 0; + entry->user_config = (HashTable *) pemalloc(sizeof(HashTable), 1); + zend_hash_init(entry->user_config, 0, NULL, config_zval_dtor, 1); + zend_hash_str_update_ptr(&CGIG(user_config_cache), path, path_len, entry); } /* Check whether cache entry has expired and rescan if it is */ @@ -784,7 +773,7 @@ static int sapi_cgi_activate(TSRMLS_D) server_name_len = strlen(server_name); server_name = estrndup(server_name, server_name_len); zend_str_tolower(server_name, server_name_len); - php_ini_activate_per_host_config(server_name, server_name_len + 1 TSRMLS_CC); + php_ini_activate_per_host_config(server_name, server_name_len TSRMLS_CC); efree(server_name); } } @@ -1473,7 +1462,7 @@ static void php_cgi_globals_ctor(php_cgi_globals_struct *php_cgi_globals TSRMLS_ php_cgi_globals->fix_pathinfo = 1; php_cgi_globals->discard_path = 0; php_cgi_globals->fcgi_logging = 1; - zend_hash_init(&php_cgi_globals->user_config_cache, 0, NULL, (dtor_func_t) user_config_cache_entry_dtor, 1); + zend_hash_init(&php_cgi_globals->user_config_cache, 0, NULL, user_config_cache_entry_dtor, 1); php_cgi_globals->error_header = NULL; php_cgi_globals->fpm_config = NULL; } @@ -1971,7 +1960,7 @@ fastcgi_request_done: fpm_request_end(TSRMLS_C); fpm_log_write(NULL TSRMLS_CC); - STR_FREE(SG(request_info).path_translated); + efree(SG(request_info).path_translated); SG(request_info).path_translated = NULL; php_request_shutdown((void *) 0); diff --git a/sapi/fpm/fpm/fpm_php.c b/sapi/fpm/fpm/fpm_php.c index cd4d3aef3a..7112cb923b 100644 --- a/sapi/fpm/fpm/fpm_php.c +++ b/sapi/fpm/fpm/fpm_php.c @@ -28,7 +28,7 @@ static int fpm_php_zend_ini_alter_master(char *name, int name_length, char *new_ zend_ini_entry *ini_entry; char *duplicate; - if (zend_hash_find(EG(ini_directives), name, name_length, (void **) &ini_entry) == FAILURE) { + if ((ini_entry = zend_hash_str_find_ptr(EG(ini_directives), name, name_length))) { return FAILURE; } @@ -89,7 +89,7 @@ int fpm_php_apply_defines_ex(struct key_value_s *kv, int mode) /* {{{ */ if (!strcmp(name, "extension") && *value) { zval zv; php_dl(value, MODULE_PERSISTENT, &zv, 1 TSRMLS_CC); - return Z_BVAL(zv) ? 1 : -1; + return Z_TYPE(zv) == IS_TRUE; } if (fpm_php_zend_ini_alter_master(name, name_len+1, value, value_len, mode, PHP_INI_STAGE_ACTIVATE TSRMLS_CC) == FAILURE) { @@ -258,39 +258,30 @@ int fpm_php_limit_extensions(char *path) /* {{{ */ } /* }}} */ -char* fpm_php_get_string_from_table(char *table, char *key TSRMLS_DC) /* {{{ */ +char* fpm_php_get_string_from_table(zend_string *table, char *key TSRMLS_DC) /* {{{ */ { - zval **data, **tmp; - char *string_key; - uint string_len; - ulong num_key; + zval *data, *tmp; + zend_string *str; if (!table || !key) { return NULL; } /* inspired from ext/standard/info.c */ - zend_is_auto_global(table, strlen(table) TSRMLS_CC); + zend_is_auto_global(table TSRMLS_CC); /* find the table and ensure it's an array */ - if (zend_hash_find(&EG(symbol_table), table, strlen(table) + 1, (void **) &data) == SUCCESS && Z_TYPE_PP(data) == IS_ARRAY) { - - /* reset the internal pointer */ - zend_hash_internal_pointer_reset(Z_ARRVAL_PP(data)); - - /* parse the array to look for our key */ - while (zend_hash_get_current_data(Z_ARRVAL_PP(data), (void **) &tmp) == SUCCESS) { - /* ensure the key is a string */ - if (zend_hash_get_current_key_ex(Z_ARRVAL_PP(data), &string_key, &string_len, &num_key, 0, NULL) == HASH_KEY_IS_STRING) { - /* compare to our key */ - if (!strncmp(string_key, key, string_len)) { - return Z_STRVAL_PP(tmp); - } - } - zend_hash_move_forward(Z_ARRVAL_PP(data)); - } + data = zend_hash_find(&EG(symbol_table).ht, table); + if (!data || Z_TYPE_P(data) != IS_ARRAY) { + return NULL; } + ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(data), str, tmp) { + if (str && !strncmp(str->val, key, str->len)) { + return Z_STRVAL_P(tmp); + } + } ZEND_HASH_FOREACH_END(); + return NULL; } /* }}} */ diff --git a/sapi/fpm/fpm/fpm_php.h b/sapi/fpm/fpm/fpm_php.h index d6054737d6..20f5a9454b 100644 --- a/sapi/fpm/fpm/fpm_php.h +++ b/sapi/fpm/fpm/fpm_php.h @@ -44,7 +44,7 @@ void fpm_php_soft_quit(); int fpm_php_init_main(); int fpm_php_apply_defines_ex(struct key_value_s *kv, int mode); int fpm_php_limit_extensions(char *path); -char* fpm_php_get_string_from_table(char *table, char *key TSRMLS_DC); +char* fpm_php_get_string_from_table(zend_string *table, char *key TSRMLS_DC); #endif diff --git a/sapi/fpm/fpm/fpm_php_trace.c b/sapi/fpm/fpm/fpm_php_trace.c index 925f2de64e..d5b4242fc3 100644 --- a/sapi/fpm/fpm/fpm_php_trace.c +++ b/sapi/fpm/fpm/fpm_php_trace.c @@ -42,6 +42,8 @@ static int fpm_php_trace_dump(struct fpm_child_s *child, FILE *slowlog TSRMLS_DC) /* {{{ */ { +// TODO: fpm_php_trace_dump() has to be reimplemented ??? +#if 0 int callers_limit = 20; pid_t pid = child->pid; struct timeval tv; @@ -131,6 +133,7 @@ static int fpm_php_trace_dump(struct fpm_child_s *child, FILE *slowlog TSRMLS_DC break; } } +#endif return 0; } /* }}} */ diff --git a/sapi/fpm/fpm/fpm_status.c b/sapi/fpm/fpm/fpm_status.c index 2363b57f80..e447648462 100644 --- a/sapi/fpm/fpm/fpm_status.c +++ b/sapi/fpm/fpm/fpm_status.c @@ -55,6 +55,7 @@ int fpm_status_handle_request(TSRMLS_D) /* {{{ */ int full, encode; char *short_syntax, *short_post; char *full_pre, *full_syntax, *full_post, *full_separator; + zend_string *_GET_str; if (!SG(request_info).request_uri) { return 0; @@ -126,13 +127,14 @@ int fpm_status_handle_request(TSRMLS_D) /* {{{ */ } /* full status ? */ - full = (fpm_php_get_string_from_table("_GET", "full" TSRMLS_CC) != NULL); + _GET_str = STR_INIT("_GET", sizeof("_GET")-1, 0); + full = (fpm_php_get_string_from_table(_GET_str, "full" TSRMLS_CC) != NULL); short_syntax = short_post = NULL; full_separator = full_pre = full_syntax = full_post = NULL; encode = 0; /* HTML */ - if (fpm_php_get_string_from_table("_GET", "html" TSRMLS_CC)) { + if (fpm_php_get_string_from_table(_GET_str, "html" TSRMLS_CC)) { sapi_add_header_ex(ZEND_STRL("Content-Type: text/html"), 1, 1 TSRMLS_CC); time_format = "%d/%b/%Y:%H:%M:%S %z"; encode = 1; @@ -207,7 +209,7 @@ int fpm_status_handle_request(TSRMLS_D) /* {{{ */ } /* XML */ - } else if (fpm_php_get_string_from_table("_GET", "xml" TSRMLS_CC)) { + } else if (fpm_php_get_string_from_table(_GET_str, "xml" TSRMLS_CC)) { sapi_add_header_ex(ZEND_STRL("Content-Type: text/xml"), 1, 1 TSRMLS_CC); time_format = "%s"; encode = 1; @@ -259,7 +261,7 @@ int fpm_status_handle_request(TSRMLS_D) /* {{{ */ } /* JSON */ - } else if (fpm_php_get_string_from_table("_GET", "json" TSRMLS_CC)) { + } else if (fpm_php_get_string_from_table(_GET_str, "json" TSRMLS_CC)) { sapi_add_header_ex(ZEND_STRL("Content-Type: application/json"), 1, 1 TSRMLS_CC); time_format = "%s"; @@ -376,6 +378,7 @@ int fpm_status_handle_request(TSRMLS_D) /* {{{ */ PUTS(buffer); efree(buffer); + STR_RELEASE(_GET_str); if (short_post) { PUTS(short_post); @@ -384,7 +387,7 @@ int fpm_status_handle_request(TSRMLS_D) /* {{{ */ /* no need to test the var 'full' */ if (full_syntax) { int i, first; - size_t len; + zend_string *tmp_query_string; char *query_string; struct timeval duration, now; #ifdef HAVE_FPM_LQ @@ -413,12 +416,13 @@ int fpm_status_handle_request(TSRMLS_D) /* {{{ */ } query_string = NULL; - len = 0; + tmp_query_string = NULL; if (proc.query_string[0] != '\0') { if (!encode) { query_string = proc.query_string; } else { - query_string = php_escape_html_entities_ex((unsigned char *)proc.query_string, strlen(proc.query_string), &len, 1, ENT_HTML_IGNORE_ERRORS & ENT_COMPAT, NULL, 1 TSRMLS_CC); + tmp_query_string = php_escape_html_entities_ex((unsigned char *)proc.query_string, strlen(proc.query_string), 1, ENT_HTML_IGNORE_ERRORS & ENT_COMPAT, NULL, 1 TSRMLS_CC); + query_string = tmp_query_string->val; } } @@ -458,8 +462,8 @@ int fpm_status_handle_request(TSRMLS_D) /* {{{ */ PUTS(buffer); efree(buffer); - if (len > 0 && query_string) { - efree(query_string); + if (tmp_query_string) { + STR_FREE(tmp_query_string); } } diff --git a/sapi/litespeed/lsapi_main.c b/sapi/litespeed/lsapi_main.c index 3413a423ac..cf26ba8ad5 100644 --- a/sapi/litespeed/lsapi_main.c +++ b/sapi/litespeed/lsapi_main.c @@ -104,7 +104,7 @@ static int php_lsapi_startup(sapi_module_struct *sapi_module) #define INI_DEFAULT(name,value)\ ZVAL_STRING(tmp, value, 0);\ zend_hash_update(configuration_hash, name, sizeof(name), tmp, sizeof(zval), (void**)&entry);\ - Z_STRVAL_P(entry) = zend_strndup(Z_STRVAL_P(entry), Z_STRLEN_P(entry)) + Z_STRVAL_P(entry) = zend_strndup(Z_STRVAL_P(entry), Z_STRSIZE_P(entry)) static void sapi_lsapi_ini_defaults(HashTable *configuration_hash) { @@ -155,7 +155,7 @@ static int sapi_lsapi_ub_write(const char *str, uint str_length TSRMLS_DC) /* {{{ sapi_lsapi_flush */ -static void sapi_lsapi_flush( void * server_context ) +static void sapi_lsapi_flush( void * server_context TSRMLS_DC ) { if ( lsapi_mode ) { if ( LSAPI_Flush() == -1) { @@ -212,7 +212,7 @@ static int add_variable( const char * pKey, int keyLen, const char * pValue, int register char * pKey1 = (char *)pKey; MAKE_STD_ZVAL(gpc_element); - Z_STRLEN_P( gpc_element ) = valLen; + Z_STRSIZE_P( gpc_element ) = valLen; Z_STRVAL_P( gpc_element ) = estrndup(pValue, valLen); Z_TYPE_P( gpc_element ) = IS_STRING; #if PHP_MAJOR_VERSION > 4 @@ -233,8 +233,8 @@ static int add_variable_magic_quote( const char * pKey, int keyLen, const char * register char * pKey1 = (char *)pKey; MAKE_STD_ZVAL(gpc_element); - Z_STRLEN_P( gpc_element ) = valLen; - Z_STRVAL_P( gpc_element ) = php_addslashes((char *)pValue, valLen, &Z_STRLEN_P( gpc_element ), 0 ); + Z_STRSIZE_P( gpc_element ) = valLen; + Z_STRVAL_P( gpc_element ) = php_addslashes((char *)pValue, valLen, &Z_STRSIZE_P( gpc_element ), 0 ); Z_TYPE_P( gpc_element ) = IS_STRING; #if PHP_MAJOR_VERSION > 4 zend_symtable_update( symtable1, pKey1, keyLen + 1, &gpc_element, sizeof( zval *), (void **) &gpc_element_p ); @@ -1090,7 +1090,7 @@ zend_module_entry litespeed_module_entry = { static int add_associate_array( const char * pKey, int keyLen, const char * pValue, int valLen, void * arg ) { - add_assoc_string_ex( (zval *)arg, (char *)pKey, keyLen+1, (char *)pValue, 1 ); + add_assoc_string_ex( (zval *)arg, (char *)pKey, keyLen+1, (char *)pValue); return 1; } @@ -1144,7 +1144,7 @@ PHP_FUNCTION(litespeed_response_headers) headerBuf[len] = 0; if ( len ) { while( isspace(*++p)); - add_assoc_string_ex(return_value, headerBuf, len+1, p, 1 ); + add_assoc_string_ex(return_value, headerBuf, len+1, p); } } } @@ -1164,10 +1164,10 @@ PHP_FUNCTION(apache_get_modules) WRONG_PARAM_COUNT; } array_init(return_value); - add_next_index_string(return_value, "mod_rewrite", 1); - add_next_index_string(return_value, "mod_mime", 1); - add_next_index_string(return_value, "mod_headers", 1); - add_next_index_string(return_value, "mod_expires", 1); + add_next_index_string(return_value, "mod_rewrite"); + add_next_index_string(return_value, "mod_mime"); + add_next_index_string(return_value, "mod_headers"); + add_next_index_string(return_value, "mod_expires"); } /* }}} */ diff --git a/sapi/milter/php_milter.c b/sapi/milter/php_milter.c index 4a11707239..443fee9dfd 100644 --- a/sapi/milter/php_milter.c +++ b/sapi/milter/php_milter.c @@ -290,7 +290,7 @@ static sfsistat mlfi_envfrom(SMFICTX *ctx, char **argv) array_init(param[0]); while (*argv) { - add_next_index_string(param[0], *argv, 1); + add_next_index_string(param[0], *argv); argv++; } @@ -330,7 +330,7 @@ static sfsistat mlfi_envrcpt(SMFICTX *ctx, char **argv) array_init(param[0]); while (*argv) { - add_next_index_string(param[0], *argv, 1); + add_next_index_string(param[0], *argv); argv++; } @@ -864,10 +864,6 @@ static int sapi_milter_ub_write(const char *str, uint str_length TSRMLS_DC) return str_length; } -static void sapi_milter_flush(void *server_context) -{ -} - static void sapi_milter_register_variables(zval *track_vars_array TSRMLS_DC) { php_register_variable ("SERVER_SOFTWARE", "Sendmail Milter", track_vars_array TSRMLS_CC); @@ -910,7 +906,7 @@ static sapi_module_struct milter_sapi_module = { NULL, /* deactivate */ sapi_milter_ub_write, /* unbuffered write */ - sapi_milter_flush, /* flush */ + NULL, /* flush */ NULL, /* get uid */ NULL, /* getenv */ @@ -1123,7 +1119,7 @@ int main(int argc, char *argv[]) break; case 'z': /* load extension file */ - zend_load_extension(ap_php_optarg); + zend_load_extension(ap_php_optarg TSRMLS_CC); break; default: diff --git a/sapi/nsapi/nsapi.c b/sapi/nsapi/nsapi.c index ec3137ca51..496596d773 100644 --- a/sapi/nsapi/nsapi.c +++ b/sapi/nsapi/nsapi.c @@ -414,7 +414,7 @@ PHP_FUNCTION(nsapi_request_headers) for (i=0; i < rc->rq->headers->hsize; i++) { entry=rc->rq->headers->ht[i]; while (entry) { - add_assoc_string(return_value, entry->param->name, entry->param->value, 1); + add_assoc_string(return_value, entry->param->name, entry->param->value); entry=entry->next; } } @@ -438,7 +438,7 @@ PHP_FUNCTION(nsapi_response_headers) for (i=0; i < rc->rq->srvhdrs->hsize; i++) { entry=rc->rq->srvhdrs->ht[i]; while (entry) { - add_assoc_string(return_value, entry->param->name, entry->param->value, 1); + add_assoc_string(return_value, entry->param->name, entry->param->value); entry=entry->next; } } @@ -467,10 +467,9 @@ static int sapi_nsapi_ub_write(const char *str, unsigned int str_length TSRMLS_D } /* modified version of apache2 */ -static void sapi_nsapi_flush(void *server_context) +static void sapi_nsapi_flush(void *server_context TSRMLS_DC) { nsapi_request_context *rc = (nsapi_request_context *)server_context; - TSRMLS_FETCH(); if (!rc) { /* we have no context, so no flushing needed. This fixes a SIGSEGV on shutdown */ diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index 1fbd18a423..aaed7a3a88 100644 --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@ -87,14 +87,14 @@ static PHP_MINIT_FUNCTION(phpdbg) /* {{{ */ REGISTER_STRINGL_CONSTANT("PHPDBG_VERSION", PHPDBG_VERSION, sizeof(PHPDBG_VERSION)-1, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PHPDBG_FILE", FILE_PARAM, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PHPDBG_METHOD", METHOD_PARAM, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PHPDBG_LINENO", NUMERIC_PARAM, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PHPDBG_FUNC", STR_PARAM, CONST_CS|CONST_PERSISTENT); - - REGISTER_LONG_CONSTANT("PHPDBG_COLOR_PROMPT", PHPDBG_COLOR_PROMPT, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PHPDBG_COLOR_NOTICE", PHPDBG_COLOR_NOTICE, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PHPDBG_COLOR_ERROR", PHPDBG_COLOR_ERROR, CONST_CS|CONST_PERSISTENT); + REGISTER_INT_CONSTANT("PHPDBG_FILE", FILE_PARAM, CONST_CS|CONST_PERSISTENT); + REGISTER_INT_CONSTANT("PHPDBG_METHOD", METHOD_PARAM, CONST_CS|CONST_PERSISTENT); + REGISTER_INT_CONSTANT("PHPDBG_LINENO", NUMERIC_PARAM, CONST_CS|CONST_PERSISTENT); + REGISTER_INT_CONSTANT("PHPDBG_FUNC", STR_PARAM, CONST_CS|CONST_PERSISTENT); + + REGISTER_INT_CONSTANT("PHPDBG_COLOR_PROMPT", PHPDBG_COLOR_PROMPT, CONST_CS|CONST_PERSISTENT); + REGISTER_INT_CONSTANT("PHPDBG_COLOR_NOTICE", PHPDBG_COLOR_NOTICE, CONST_CS|CONST_PERSISTENT); + REGISTER_INT_CONSTANT("PHPDBG_COLOR_ERROR", PHPDBG_COLOR_ERROR, CONST_CS|CONST_PERSISTENT); return SUCCESS; } /* }}} */ diff --git a/sapi/phpdbg/phpdbg_bp.c b/sapi/phpdbg/phpdbg_bp.c index a18316a228..35273554f8 100644 --- a/sapi/phpdbg/phpdbg_bp.c +++ b/sapi/phpdbg/phpdbg_bp.c @@ -721,12 +721,12 @@ static inline void phpdbg_create_conditional_break(phpdbg_breakcond_t *brake, co new_break.code = estrndup(expr, expr_len); new_break.code_len = expr_len; - Z_STRLEN(pv) = expr_len + sizeof("return ;") - 1; - Z_STRVAL(pv) = emalloc(Z_STRLEN(pv) + 1); + Z_STRSIZE(pv) = expr_len + sizeof("return ;") - 1; + Z_STRVAL(pv) = emalloc(Z_STRSIZE(pv) + 1); memcpy(Z_STRVAL(pv), "return ", sizeof("return ") - 1); memcpy(Z_STRVAL(pv) + sizeof("return ") - 1, expr, expr_len); - Z_STRVAL(pv)[Z_STRLEN(pv) - 1] = ';'; - Z_STRVAL(pv)[Z_STRLEN(pv)] = '\0'; + Z_STRVAL(pv)[Z_STRSIZE(pv) - 1] = ';'; + Z_STRVAL(pv)[Z_STRSIZE(pv)] = '\0'; Z_TYPE(pv) = IS_STRING; new_break.ops = zend_compile_string( diff --git a/sapi/phpdbg/phpdbg_frame.c b/sapi/phpdbg/phpdbg_frame.c index a235fe8cb0..67fa6a267f 100644 --- a/sapi/phpdbg/phpdbg_frame.c +++ b/sapi/phpdbg/phpdbg_frame.c @@ -114,7 +114,7 @@ static void phpdbg_dump_prototype(zval **tmp TSRMLS_DC) /* {{{ */ (void **)&class); } else { zend_get_object_classname(*class, (const char **)&Z_STRVAL_PP(class), - (zend_uint *)&Z_STRLEN_PP(class) TSRMLS_CC); + (zend_uint *)&Z_STRSIZE_PP(class) TSRMLS_CC); } if (is_class == SUCCESS) { @@ -186,14 +186,14 @@ void phpdbg_dump_backtrace(size_t num TSRMLS_DC) /* {{{ */ if (zend_hash_get_current_data_ex(Z_ARRVAL(zbacktrace), (void**)&tmp, &position) == FAILURE) { - phpdbg_write("frame #%d: {main} at %s:%ld", i, Z_STRVAL_PP(file), Z_LVAL_PP(line)); + phpdbg_write("frame #%d: {main} at %s:%ld", i, Z_STRVAL_PP(file), Z_IVAL_PP(line)); break; } if (user_defined == SUCCESS) { phpdbg_write("frame #%d: ", i++); phpdbg_dump_prototype(tmp TSRMLS_CC); - phpdbg_writeln(" at %s:%ld", Z_STRVAL_PP(file), Z_LVAL_PP(line)); + phpdbg_writeln(" at %s:%ld", Z_STRVAL_PP(file), Z_IVAL_PP(line)); } else { phpdbg_write(" => "); phpdbg_dump_prototype(tmp TSRMLS_CC); diff --git a/sapi/phpdbg/phpdbg_help.c b/sapi/phpdbg/phpdbg_help.c index 1e58dc69ca..c552529930 100644 --- a/sapi/phpdbg/phpdbg_help.c +++ b/sapi/phpdbg/phpdbg_help.c @@ -362,7 +362,7 @@ phpdbg_help_text_t phpdbg_help_text[] = { " **-c** **-c**/my/php.ini Set php.ini file to load" CR " **-d** **-d**memory_limit=4G Set a php.ini directive" CR " **-n** Disable default php.ini" CR -" **-q** Supress welcome banner" CR +" **-q** Suppress welcome banner" CR " **-v** Enable oplog output" CR " **-s** Enable stepping" CR " **-b** Disable colour" CR @@ -545,7 +545,7 @@ phpdbg_help_text_t phpdbg_help_text[] = { " $P break ZEND_ADD" CR " $P b ZEND_ADD" CR -" Break on any occurence of the opcode ZEND_ADD" CR CR +" Break on any occurrence of the opcode ZEND_ADD" CR CR " $P break del 2" CR " $P b ~ 2" CR diff --git a/sapi/phpdbg/phpdbg_info.c b/sapi/phpdbg/phpdbg_info.c index 97f88bfa1e..851e93b3c7 100644 --- a/sapi/phpdbg/phpdbg_info.c +++ b/sapi/phpdbg/phpdbg_info.c @@ -159,7 +159,7 @@ PHPDBG_INFO(vars) /* {{{ */ switch (Z_TYPE_PP(data)) { case IS_STRING: phpdbg_write("(string)\t"); break; - case IS_LONG: phpdbg_write("(integer)\t"); break; + case IS_INT: phpdbg_write("(integer)\t"); break; case IS_DOUBLE: phpdbg_write("(float)\t"); break; case IS_RESOURCE: phpdbg_write("(resource)\t"); break; case IS_ARRAY: phpdbg_write("(array)\t"); break; diff --git a/sapi/phpdbg/phpdbg_prompt.c b/sapi/phpdbg/phpdbg_prompt.c index d91ef3f3f5..69ad49ecc6 100644 --- a/sapi/phpdbg/phpdbg_prompt.c +++ b/sapi/phpdbg/phpdbg_prompt.c @@ -118,7 +118,7 @@ static inline int phpdbg_call_register(phpdbg_param_t *stack TSRMLS_DC) /* {{{ * break; case NUMERIC_PARAM: - add_next_index_long(¶ms, next->num); + add_next_index_int(¶ms, next->num); break; case METHOD_PARAM: diff --git a/sapi/phpdbg/phpdbg_utils.h b/sapi/phpdbg/phpdbg_utils.h index 56bacfc459..83474cd7ad 100644 --- a/sapi/phpdbg/phpdbg_utils.h +++ b/sapi/phpdbg/phpdbg_utils.h @@ -136,10 +136,10 @@ static void zend_hash_get_current_key_zval_ex(const HashTable *ht, zval *key, Ha } else if (p->nKeyLength) { Z_TYPE_P(key) = IS_STRING; Z_STRVAL_P(key) = IS_INTERNED(p->arKey) ? (char*)p->arKey : estrndup(p->arKey, p->nKeyLength - 1); - Z_STRLEN_P(key) = p->nKeyLength - 1; + Z_STRSIZE_P(key) = p->nKeyLength - 1; } else { - Z_TYPE_P(key) = IS_LONG; - Z_LVAL_P(key) = p->h; + Z_TYPE_P(key) = IS_INT; + Z_IVAL_P(key) = p->h; } } #endif diff --git a/sapi/phpdbg/phpdbg_watch.c b/sapi/phpdbg/phpdbg_watch.c index e88622444b..10834fa9a6 100644 --- a/sapi/phpdbg/phpdbg_watch.c +++ b/sapi/phpdbg/phpdbg_watch.c @@ -182,11 +182,11 @@ static int phpdbg_create_recursive_watchpoint(phpdbg_watchpoint_t *watch TSRMLS_ zend_hash_get_current_key_zval_ex(ht, &key, &position); if (Z_TYPE(key) == IS_STRING) { - new_watch->name_in_parent = zend_strndup(Z_STRVAL(key), Z_STRLEN(key)); - new_watch->name_in_parent_len = Z_STRLEN(key); + new_watch->name_in_parent = zend_strndup(Z_STRVAL(key), Z_STRSIZE(key)); + new_watch->name_in_parent_len = Z_STRSIZE(key); } else { new_watch->name_in_parent = NULL; - new_watch->name_in_parent_len = asprintf(&new_watch->name_in_parent, "%ld", Z_LVAL(key)); + new_watch->name_in_parent_len = asprintf(&new_watch->name_in_parent, "%ld", Z_IVAL(key)); } new_watch->str = NULL; @@ -238,7 +238,7 @@ static int phpdbg_delete_watchpoint_recursive(phpdbg_watchpoint_t *watch, zend_b if (Z_TYPE(key) == IS_STRING) { str_len = asprintf(&str, "%.*s%s%s%s", (int)watch->parent->str_len, watch->parent->str, Z_TYPE_P(watch->parent->addr.zv) == IS_ARRAY?"[":"->", phpdbg_get_property_key(Z_STRVAL(key)), Z_TYPE_P(watch->parent->addr.zv) == IS_ARRAY?"]":""); } else { - str_len = asprintf(&str, "%.*s%s%li%s", (int)watch->parent->str_len, watch->parent->str, Z_TYPE_P(watch->parent->addr.zv) == IS_ARRAY?"[":"->", Z_LVAL(key), Z_TYPE_P(watch->parent->addr.zv) == IS_ARRAY?"]":""); + str_len = asprintf(&str, "%.*s%s%li%s", (int)watch->parent->str_len, watch->parent->str, Z_TYPE_P(watch->parent->addr.zv) == IS_ARRAY?"[":"->", Z_IVAL(key), Z_TYPE_P(watch->parent->addr.zv) == IS_ARRAY?"]":""); } if (zend_hash_find(&PHPDBG_G(watchpoints), str, str_len, (void **) &watchpoint) == SUCCESS) { @@ -338,7 +338,7 @@ static int phpdbg_watchpoint_parse_input(char *input, size_t len, HashTable *par watch->flags = 0; zend_hash_get_current_key_zval_ex(parent, key, &position); convert_to_string(key); - watch->str = malloc(i + Z_STRLEN_P(key) + 2); + watch->str = malloc(i + Z_STRSIZE_P(key) + 2); watch->str_len = sprintf(watch->str, "%.*s%s%s", (int)i, input, phpdbg_get_property_key(Z_STRVAL_P(key)), input[len - 1] == ']'?"]":""); efree(key); watch->name_in_parent = zend_strndup(last_index, index_len); diff --git a/sapi/pi3web/pi3web_sapi.c b/sapi/pi3web/pi3web_sapi.c index 4bc08e5382..0e17c0e029 100644 --- a/sapi/pi3web/pi3web_sapi.c +++ b/sapi/pi3web/pi3web_sapi.c @@ -385,7 +385,7 @@ MODULE_API DWORD PHP5_wrapper(LPCONTROL_BLOCK lpCB) } if ( open_file_for_scanning( &file_handle TSRMLS_CC ) == SUCCESS ) { - zend_indent(); + zend_indent(TSRMLS_C); } else { diff --git a/sapi/roxen/roxen.c b/sapi/roxen/roxen.c index b3a64345ea..14456477b0 100644 --- a/sapi/roxen/roxen.c +++ b/sapi/roxen/roxen.c @@ -387,13 +387,12 @@ php_roxen_sapi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) * the client. Used for POST/PUT requests. */ -INLINE static int php_roxen_low_read_post(char *buf, uint count_bytes) +INLINE static int php_roxen_low_read_post(char *buf, uint count_bytes TSRMLS_DC) { uint total_read = 0; #ifdef ROXEN_USE_ZTS GET_THIS(); #endif - TSRMLS_FETCH(); if(!MY_FD_OBJ->prog) { @@ -417,7 +416,7 @@ static int php_roxen_sapi_read_post(char *buf, uint count_bytes TSRMLS_DC) { uint total_read = 0; - THREAD_SAFE_RUN(total_read = php_roxen_low_read_post(buf, count_bytes), "read post"); + THREAD_SAFE_RUN(total_read = php_roxen_low_read_post(buf, count_bytes TSRMLS_CC), "read post"); return total_read; } diff --git a/sapi/thttpd/thttpd.c b/sapi/thttpd/thttpd.c index 843e4a62fb..f6ba8585b9 100644 --- a/sapi/thttpd/thttpd.c +++ b/sapi/thttpd/thttpd.c @@ -349,11 +349,12 @@ static zend_module_entry php_thttpd_module = { STANDARD_MODULE_PROPERTIES }; -static int php_thttpd_startup(sapi_module_struct *sapi_module) +static int php_thttpd_startup(sapi_module_struct *sapi_module TSRMLS_DC) { #if PHP_API_VERSION >= 20020918 if (php_module_startup(sapi_module, &php_thttpd_module, 1) == FAILURE) { #else + /* No TSRMLS_CC here to zend_startup_module() as 5.6 and older does not have that parameter */ if (php_module_startup(sapi_module) == FAILURE || zend_startup_module(&php_thttpd_module) == FAILURE) { #endif diff --git a/sapi/tux/php_tux.c b/sapi/tux/php_tux.c index 55d911f8ab..9dba8efbfe 100644 --- a/sapi/tux/php_tux.c +++ b/sapi/tux/php_tux.c @@ -96,7 +96,7 @@ static int sapi_tux_ub_write(const char *str, uint str_length TSRMLS_DC) return n; } -static int sapi_tux_send_headers(sapi_headers_struct *sapi_headers) +static int sapi_tux_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) { char buf[1024]; struct iovec *vec; @@ -107,7 +107,6 @@ static int sapi_tux_send_headers(sapi_headers_struct *sapi_headers) size_t len; char *status_line; int locate_cl; - TSRMLS_FETCH(); max_headers = 30; n = 1; @@ -158,11 +157,10 @@ static int sapi_tux_send_headers(sapi_headers_struct *sapi_headers) return SAPI_HEADER_SENT_SUCCESSFULLY; } -static int sapi_tux_read_post(char *buffer, uint count_bytes) +static int sapi_tux_read_post(char *buffer, uint count_bytes TSRMLS_DC) { #if 0 int amount = 0; - TSRMLS_FETCH(); TG(req)->objectlen = count_bytes; TG(req)->object_addr = buffer; @@ -177,10 +175,8 @@ static int sapi_tux_read_post(char *buffer, uint count_bytes) #endif } -static char *sapi_tux_read_cookies(void) +static char *sapi_tux_read_cookies(TSRMLS_D) { - TSRMLS_FETCH(); - return TG(req)->cookies; } |
