From f1f22b2a9635ecb5bd361d45b80db47231218d1b Mon Sep 17 00:00:00 2001 From: Yu Qing Date: Tue, 8 Dec 2015 12:49:42 +0800 Subject: [PATCH] php extension compiled in PHP 7 --- HISTORY | 3 +- php_client/fastdfs_client.c | 932 +++++++++++++++++++++--------------- 2 files changed, 555 insertions(+), 380 deletions(-) diff --git a/HISTORY b/HISTORY index 8370e10..a748a21 100644 --- a/HISTORY +++ b/HISTORY @@ -1,6 +1,7 @@ -Version 5.08 2015-10-10 +Version 5.08 2015-12-08 * install library to $(TARGET_PREFIX)/lib anyway + * php extension compiled in PHP 7 Version 5.07 2015-09-13 * schedule task add the "second" field diff --git a/php_client/fastdfs_client.c b/php_client/fastdfs_client.c index 64bfd5e..3c6b38d 100644 --- a/php_client/fastdfs_client.c +++ b/php_client/fastdfs_client.c @@ -40,9 +40,9 @@ typedef struct typedef struct { - zend_object zo; FDFSConfigInfo *pConfigInfo; FDFSPhpContext context; + zend_object zo; } php_fdfs_t; typedef struct @@ -57,6 +57,115 @@ typedef struct int64_t file_size; } php_fdfs_upload_callback_t; + +#if PHP_MAJOR_VERSION < 7 +typedef int zend_size_t; +#define ZEND_RETURN_STRINGL(s, l, dup) RETURN_STRINGL(s, l, dup) +#define ZEND_TYPE_OF(z) (z)->type +#define ZEND_IS_BOOL(z) (ZEND_TYPE_OF(z) == IS_BOOL) +#define fdfs_get_object(obj) zend_object_store_get_object(obj) + +#define fdfs_zend_hash_update zend_hash_update +#define fdfs_call_user_function call_user_function + +#define zend_add_assoc_long_ex(z, key, key_len, n) \ + add_assoc_long_ex(z, key, key_len, n) + +#define zend_add_assoc_stringl_ex(z, key, key_len, str, length, dup) \ + add_assoc_stringl_ex(z, key, key_len, str, length, dup) + +#define zend_add_assoc_zval_ex(z, key, key_len, value) \ + add_assoc_zval_ex(z, key, key_len, value) + +#define zend_add_assoc_bool_ex(z, key, key_len, b) \ + add_assoc_bool_ex(z, key, key_len, b) + +static inline int fdfs_zend_hash_find(HashTable *ht, char *key, int key_len, zval **value) +{ + zval **pp; + + pp = NULL; + if (zend_hash_find(ht, key, key_len, (void **)&pp) == SUCCESS) + { + *value = *pp; + return SUCCESS; + } + else + { + *value = NULL; + return FAILURE; + } +} + +static inline int fdfs_zend_get_configuration_directive(char *name, int len, zval **value) +{ + return zend_get_configuration_directive(name, len, *value); +} + +#else + +typedef size_t zend_size_t; +#define ZEND_RETURN_STRINGL(s, l, dup) RETURN_STRINGL(s, l) +#define ZEND_TYPE_OF(z) Z_TYPE_P(z) +#define ZEND_IS_BOOL(z) (Z_TYPE_P(z) == IS_TRUE || Z_TYPE_P(z) == IS_FALSE) +#define Z_STRVAL_PP(s) Z_STRVAL_P(*s) +#define Z_STRLEN_PP(s) Z_STRLEN_P(*s) +#define fdfs_get_object(obj) (void *)((char *)(Z_OBJ_P(obj)) - offsetof(php_fdfs_t, zo)) + +#define MAKE_STD_ZVAL(p) zval _stack_zval_##p; p = &(_stack_zval_##p) +#define ALLOC_INIT_ZVAL(p) MAKE_STD_ZVAL(p) +#define INIT_ZVAL(z) + +#define zend_add_assoc_long_ex(z, key, key_len, n) \ + add_assoc_long_ex(z, key, key_len - 1, n) + +#define zend_add_assoc_stringl_ex(z, key, key_len, str, length, dup) \ + add_assoc_stringl_ex(z, key, key_len - 1, str, length) + +#define zend_add_assoc_zval_ex(z, key, key_len, value) \ + add_assoc_zval_ex(z, key, key_len - 1, value) + +#define zend_add_assoc_bool_ex(z, key, key_len, b) \ + add_assoc_bool_ex(z, key, key_len - 1, b) + +static inline int fdfs_zend_hash_find(HashTable *ht, char *key, int key_len, zval **value) +{ + zval zkey; + ZVAL_STRINGL(&zkey, key, key_len - 1); + *value = zend_hash_find(ht, Z_STR(zkey)); + return (*value != NULL ? SUCCESS : FAILURE); +} + +static inline int fdfs_zend_hash_update(HashTable *ht, char *k, int len, void * val, int size, void *ptr) +{ + zval key; + ZVAL_STRINGL(&key, k, len - 1); + return zend_hash_update(ht, Z_STR(key), val) ? SUCCESS : FAILURE; +} + +static inline int fdfs_call_user_function(HashTable *function_table, zval *object, + zval *function_name, zval *retval_ptr, uint32_t param_count, zval **params) +{ + int i; + zval real_params[param_count]; + for(i=0; i= 7 + zval *for_php7; +#endif FDFSMetaData *pMetaData; meta_hash = Z_ARRVAL_P(metadata_obj); @@ -222,12 +334,26 @@ static int fastdfs_convert_metadata_to_array(zval *metadata_obj, \ memset(*meta_list, 0, sizeof(FDFSMetaData) * (*meta_count)); pMetaData = *meta_list; ppp = &data; + +#if PHP_MAJOR_VERSION < 7 for (zend_hash_internal_pointer_reset_ex(meta_hash, &pointer); \ zend_hash_get_current_data_ex(meta_hash, (void **)ppp, &pointer) == SUCCESS; zend_hash_move_forward_ex(meta_hash, &pointer)) +#else + data = &for_php7; + for (zend_hash_internal_pointer_reset_ex(meta_hash, &pointer); \ + (for_php7=zend_hash_get_current_data_ex(meta_hash, &pointer)) + != NULL; zend_hash_move_forward_ex(meta_hash, &pointer)) +#endif { +#if PHP_MAJOR_VERSION < 7 if (zend_hash_get_current_key_ex(meta_hash, &szKey, \ &(key_len), &index, 0, &pointer) != HASH_KEY_IS_STRING) +#else + zend_string *_key_ptr; + if (zend_hash_get_current_key_ex(meta_hash, &_key_ptr, \ + (zend_ulong *)&index, &pointer) != HASH_KEY_IS_STRING) +#endif { logError("file: "__FILE__", line: %d, " \ "invalid array element, " \ @@ -239,13 +365,17 @@ static int fastdfs_convert_metadata_to_array(zval *metadata_obj, \ return EINVAL; } +#if PHP_MAJOR_VERSION >= 7 + szKey = _key_ptr->val; + key_len = _key_ptr->len; +#endif if (key_len > FDFS_MAX_META_NAME_LEN) { key_len = FDFS_MAX_META_NAME_LEN; } memcpy(pMetaData->name, szKey, key_len); - if ((*data)->type == IS_STRING) + if (ZEND_TYPE_OF(*data) == IS_STRING) { szValue = Z_STRVAL_PP(data); value_len = Z_STRLEN_PP(data); @@ -256,11 +386,11 @@ static int fastdfs_convert_metadata_to_array(zval *metadata_obj, \ } memcpy(pMetaData->value, szValue, value_len); } - else if ((*data)->type == IS_LONG || (*data)->type == IS_BOOL) + else if (ZEND_TYPE_OF(*data) == IS_LONG || ZEND_IS_BOOL(*data)) { sprintf(pMetaData->value, "%ld", (*data)->value.lval); } - else if ((*data)->type == IS_DOUBLE) + else if (ZEND_TYPE_OF(*data) == IS_DOUBLE) { sprintf(pMetaData->value, "%.2f", (*data)->value.dval); } @@ -268,7 +398,7 @@ static int fastdfs_convert_metadata_to_array(zval *metadata_obj, \ { logError("file: "__FILE__", line: %d, " \ "invalid array element, key=%s, value type=%d",\ - __LINE__, szKey, (*data)->type); + __LINE__, szKey, ZEND_TYPE_OF(*data)); free(*meta_list); *meta_list = NULL; @@ -308,11 +438,11 @@ static void php_fdfs_tracker_get_connection_impl(INTERNAL_FUNCTION_PARAMETERS, \ pContext->err_no = 0; array_init(return_value); - add_assoc_stringl_ex(return_value, "ip_addr", sizeof("ip_addr"), \ + zend_add_assoc_stringl_ex(return_value, "ip_addr", sizeof("ip_addr"), \ pTrackerServer->ip_addr, strlen(pTrackerServer->ip_addr), 1); - add_assoc_long_ex(return_value, "port", sizeof("port"), \ + zend_add_assoc_long_ex(return_value, "port", sizeof("port"), \ pTrackerServer->port); - add_assoc_long_ex(return_value, "sock", sizeof("sock"), \ + zend_add_assoc_long_ex(return_value, "sock", sizeof("sock"), \ pTrackerServer->sock); } @@ -368,7 +498,7 @@ static void php_fdfs_connect_server_impl(INTERNAL_FUNCTION_PARAMETERS, \ { int argc; char *ip_addr; - int ip_len; + zend_size_t ip_len; long port; ConnectionInfo server_info; @@ -400,11 +530,11 @@ static void php_fdfs_connect_server_impl(INTERNAL_FUNCTION_PARAMETERS, \ g_fdfs_network_timeout)) == 0) { array_init(return_value); - add_assoc_stringl_ex(return_value, "ip_addr", \ + zend_add_assoc_stringl_ex(return_value, "ip_addr", \ sizeof("ip_addr"), ip_addr, ip_len, 1); - add_assoc_long_ex(return_value, "port", sizeof("port"), \ + zend_add_assoc_long_ex(return_value, "port", sizeof("port"), \ port); - add_assoc_long_ex(return_value, "sock", sizeof("sock"), \ + zend_add_assoc_long_ex(return_value, "sock", sizeof("sock"), \ server_info.sock); } else @@ -419,8 +549,7 @@ static void php_fdfs_disconnect_server_impl(INTERNAL_FUNCTION_PARAMETERS, \ int argc; zval *server_info; HashTable *tracker_hash; - zval **data; - zval ***ppp; + zval *data; int sock; argc = ZEND_NUM_ARGS(); @@ -443,18 +572,16 @@ static void php_fdfs_disconnect_server_impl(INTERNAL_FUNCTION_PARAMETERS, \ } tracker_hash = Z_ARRVAL_P(server_info); - data = NULL; - ppp = &data; - if (zend_hash_find(tracker_hash, "sock", sizeof("sock"), \ - (void **)ppp) == FAILURE) + if (fdfs_zend_hash_find(tracker_hash, "sock", sizeof("sock"), \ + &data) == FAILURE) { pContext->err_no = ENOENT; RETURN_BOOL(false); } - if ((*data)->type == IS_LONG) + if (ZEND_TYPE_OF(data) == IS_LONG) { - sock = (*data)->value.lval; + sock = data->value.lval; if (sock >= 0) { close(sock); @@ -469,7 +596,7 @@ static void php_fdfs_disconnect_server_impl(INTERNAL_FUNCTION_PARAMETERS, \ { logError("file: "__FILE__", line: %d, " \ "sock type is invalid, type=%d!", \ - __LINE__, (*data)->type); + __LINE__, ZEND_TYPE_OF(data)); pContext->err_no = EINVAL; RETURN_BOOL(false); } @@ -478,36 +605,32 @@ static void php_fdfs_disconnect_server_impl(INTERNAL_FUNCTION_PARAMETERS, \ static int php_fdfs_get_callback_from_hash(HashTable *callback_hash, \ php_fdfs_callback_t *pCallback) { - zval **data; - zval ***ppp; + zval *data; - data = NULL; - ppp = &data; - if (zend_hash_find(callback_hash, "callback", sizeof("callback"), \ - (void **)ppp) == FAILURE) + if (fdfs_zend_hash_find(callback_hash, "callback", sizeof("callback"), \ + &data) == FAILURE) { logError("file: "__FILE__", line: %d, " \ "key \"callback\" not exist!", __LINE__); return ENOENT; } - if ((*data)->type != IS_STRING) + if (ZEND_TYPE_OF(data) != IS_STRING) { logError("file: "__FILE__", line: %d, " \ "key \"callback\" is not string type, type=%d!", \ - __LINE__, (*data)->type); + __LINE__, ZEND_TYPE_OF(data)); return EINVAL; } - pCallback->func_name = *data; + pCallback->func_name = data; - data = NULL; - if (zend_hash_find(callback_hash, "args", sizeof("args"), \ - (void **)ppp) == FAILURE) + if (fdfs_zend_hash_find(callback_hash, "args", sizeof("args"), \ + &data) == FAILURE) { pCallback->args = NULL; } else { - pCallback->args = ((*data)->type == IS_NULL) ? NULL : *data; + pCallback->args = (ZEND_TYPE_OF(data) == IS_NULL) ? NULL : data; } return 0; @@ -516,8 +639,7 @@ static int php_fdfs_get_callback_from_hash(HashTable *callback_hash, \ static int php_fdfs_get_upload_callback_from_hash(HashTable *callback_hash, \ php_fdfs_upload_callback_t *pUploadCallback) { - zval **data; - zval ***ppp; + zval *data; int result; if ((result=php_fdfs_get_callback_from_hash(callback_hash, \ @@ -526,23 +648,21 @@ static int php_fdfs_get_upload_callback_from_hash(HashTable *callback_hash, \ return result; } - data = NULL; - ppp = &data; - if (zend_hash_find(callback_hash, "file_size", sizeof("file_size"), \ - (void **)ppp) == FAILURE) + if (fdfs_zend_hash_find(callback_hash, "file_size", sizeof("file_size"), \ + &data) == FAILURE) { logError("file: "__FILE__", line: %d, " \ "key \"file_size\" not exist!", __LINE__); return ENOENT; } - if ((*data)->type != IS_LONG) + if (ZEND_TYPE_OF(data) != IS_LONG) { logError("file: "__FILE__", line: %d, " \ "key \"file_size\" is not long type, type=%d!", \ - __LINE__, (*data)->type); + __LINE__, ZEND_TYPE_OF(data)); return EINVAL; } - pUploadCallback->file_size = (*data)->value.lval; + pUploadCallback->file_size = data->value.lval; if (pUploadCallback->file_size < 0) { logError("file: "__FILE__", line: %d, " \ @@ -557,69 +677,67 @@ static int php_fdfs_get_upload_callback_from_hash(HashTable *callback_hash, \ static int php_fdfs_get_server_from_hash(HashTable *tracker_hash, \ ConnectionInfo *pTrackerServer) { - zval **data; - zval ***ppp; + zval *data; char *ip_addr; int ip_len; memset(pTrackerServer, 0, sizeof(ConnectionInfo)); data = NULL; - ppp = &data; - if (zend_hash_find(tracker_hash, "ip_addr", sizeof("ip_addr"), \ - (void **)ppp) == FAILURE) + if (fdfs_zend_hash_find(tracker_hash, "ip_addr", sizeof("ip_addr"), \ + &data) == FAILURE) { logError("file: "__FILE__", line: %d, " \ "key \"ip_addr\" not exist!", __LINE__); return ENOENT; } - if ((*data)->type != IS_STRING) + if (ZEND_TYPE_OF(data) != IS_STRING) { logError("file: "__FILE__", line: %d, " \ "key \"ip_addr\" is not string type, type=%d!", \ - __LINE__, (*data)->type); + __LINE__, ZEND_TYPE_OF(data)); return EINVAL; } - ip_addr = Z_STRVAL_PP(data); - ip_len = Z_STRLEN_PP(data); + ip_addr = Z_STRVAL_P(data); + ip_len = Z_STRLEN_P(data); if (ip_len >= IP_ADDRESS_SIZE) { ip_len = IP_ADDRESS_SIZE - 1; } memcpy(pTrackerServer->ip_addr, ip_addr, ip_len); - if (zend_hash_find(tracker_hash, "port", sizeof("port"), \ - (void **)ppp) == FAILURE) + if (fdfs_zend_hash_find(tracker_hash, "port", sizeof("port"), \ + &data) == FAILURE) { logError("file: "__FILE__", line: %d, " \ "key \"port\" not exist!", __LINE__); return ENOENT; } - if ((*data)->type != IS_LONG) + if (ZEND_TYPE_OF(data) != IS_LONG) { logError("file: "__FILE__", line: %d, " \ "key \"port\" is not long type, type=%d!", \ - __LINE__, (*data)->type); + __LINE__, ZEND_TYPE_OF(data)); return EINVAL; } - pTrackerServer->port = (*data)->value.lval; + pTrackerServer->port = data->value.lval; - if (zend_hash_find(tracker_hash, "sock", sizeof("sock"), \ - (void **)ppp) == FAILURE) + if (fdfs_zend_hash_find(tracker_hash, "sock", sizeof("sock"), \ + &data) == FAILURE) { logError("file: "__FILE__", line: %d, " \ "key \"sock\" not exist!", __LINE__); return ENOENT; } - if ((*data)->type != IS_LONG) + if (ZEND_TYPE_OF(data) != IS_LONG) { logError("file: "__FILE__", line: %d, " \ "key \"sock\" is not long type, type=%d!", \ - __LINE__, (*data)->type); + __LINE__, ZEND_TYPE_OF(data)); return EINVAL; } - pTrackerServer->sock = (*data)->value.lval; + pTrackerServer->sock = data->value.lval; return 0; } @@ -673,7 +791,7 @@ static void php_fdfs_tracker_list_groups_impl(INTERNAL_FUNCTION_PARAMETERS, \ { int argc; char *group_name; - int group_nlen; + zend_size_t group_nlen; zval *tracker_obj; zval *group_info_array; zval *server_info_array; @@ -779,34 +897,34 @@ static void php_fdfs_tracker_list_groups_impl(INTERNAL_FUNCTION_PARAMETERS, \ ALLOC_INIT_ZVAL(group_info_array); array_init(group_info_array); - add_assoc_zval_ex(return_value, pGroupStat->group_name, \ + zend_add_assoc_zval_ex(return_value, pGroupStat->group_name, \ strlen(pGroupStat->group_name) + 1, group_info_array); - add_assoc_long_ex(group_info_array, "total_space", \ + zend_add_assoc_long_ex(group_info_array, "total_space", \ sizeof("total_space"), pGroupStat->total_mb); - add_assoc_long_ex(group_info_array, "free_space", \ + zend_add_assoc_long_ex(group_info_array, "free_space", \ sizeof("free_space"), pGroupStat->free_mb); - add_assoc_long_ex(group_info_array, "trunk_free_space", \ + zend_add_assoc_long_ex(group_info_array, "trunk_free_space", \ sizeof("trunk_free_space"), pGroupStat->trunk_free_mb); - add_assoc_long_ex(group_info_array, "server_count", \ + zend_add_assoc_long_ex(group_info_array, "server_count", \ sizeof("server_count"), pGroupStat->count); - add_assoc_long_ex(group_info_array, "active_count", \ + zend_add_assoc_long_ex(group_info_array, "active_count", \ sizeof("active_count"), pGroupStat->active_count); - add_assoc_long_ex(group_info_array, "storage_port", \ + zend_add_assoc_long_ex(group_info_array, "storage_port", \ sizeof("storage_port"), pGroupStat->storage_port); - add_assoc_long_ex(group_info_array, "storage_http_port", \ + zend_add_assoc_long_ex(group_info_array, "storage_http_port", \ sizeof("storage_http_port"), \ pGroupStat->storage_http_port); - add_assoc_long_ex(group_info_array, "store_path_count", \ + zend_add_assoc_long_ex(group_info_array, "store_path_count", \ sizeof("store_path_count"), \ pGroupStat->store_path_count); - add_assoc_long_ex(group_info_array, "subdir_count_per_path", \ + zend_add_assoc_long_ex(group_info_array, "subdir_count_per_path", \ sizeof("subdir_count_per_path"), \ pGroupStat->subdir_count_per_path); - add_assoc_long_ex(group_info_array, "current_write_server", \ + zend_add_assoc_long_ex(group_info_array, "current_write_server", \ sizeof("current_write_server"), \ pGroupStat->current_write_server); - add_assoc_long_ex(group_info_array, "current_trunk_file_id", \ + zend_add_assoc_long_ex(group_info_array, "current_trunk_file_id", \ sizeof("current_trunk_file_id"), \ pGroupStat->current_trunk_file_id); @@ -832,274 +950,274 @@ static void php_fdfs_tracker_list_groups_impl(INTERNAL_FUNCTION_PARAMETERS, \ ALLOC_INIT_ZVAL(server_info_array); array_init(server_info_array); - add_assoc_zval_ex(group_info_array, pStorage->id, \ + zend_add_assoc_zval_ex(group_info_array, pStorage->id, \ strlen(pStorage->id) + 1, server_info_array); - add_assoc_stringl_ex(server_info_array, \ + zend_add_assoc_stringl_ex(server_info_array, \ "ip_addr", sizeof("ip_addr"), \ pStorage->ip_addr, strlen(pStorage->ip_addr), 1); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "join_time", sizeof("join_time"), \ pStorage->join_time); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "up_time", sizeof("up_time"), \ pStorage->up_time); - add_assoc_stringl_ex(server_info_array, \ + zend_add_assoc_stringl_ex(server_info_array, \ "http_domain", sizeof("http_domain"), \ pStorage->domain_name, \ strlen(pStorage->domain_name), 1); - add_assoc_stringl_ex(server_info_array, \ + zend_add_assoc_stringl_ex(server_info_array, \ "version", sizeof("version"), \ pStorage->version, strlen(pStorage->version), 1); - add_assoc_stringl_ex(server_info_array, \ + zend_add_assoc_stringl_ex(server_info_array, \ "src_storage_id", sizeof("src_storage_id"), \ pStorage->src_id, strlen(pStorage->src_id), 1); - add_assoc_bool_ex(server_info_array, \ + zend_add_assoc_bool_ex(server_info_array, \ "if_trunk_server", sizeof("if_trunk_server"), \ pStorage->if_trunk_server); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "upload_priority", sizeof("upload_priority"), \ pStorage->upload_priority); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "store_path_count", sizeof("store_path_count"),\ pStorage->store_path_count); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "subdir_count_per_path", \ sizeof("subdir_count_per_path"), \ pStorage->subdir_count_per_path); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "storage_port", sizeof("storage_port"), \ pStorage->storage_port); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "storage_http_port", \ sizeof("storage_http_port"), \ pStorage->storage_http_port); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "current_write_path", \ sizeof("current_write_path"), \ pStorage->current_write_path); - add_assoc_long_ex(server_info_array, "status", \ + zend_add_assoc_long_ex(server_info_array, "status", \ sizeof("status"), pStorage->status); - add_assoc_long_ex(server_info_array, "total_space", \ + zend_add_assoc_long_ex(server_info_array, "total_space", \ sizeof("total_space"), pStorage->total_mb); - add_assoc_long_ex(server_info_array, "free_space", \ + zend_add_assoc_long_ex(server_info_array, "free_space", \ sizeof("free_space"), pStorage->free_mb); pStorageStat = &(pStorage->stat); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "connection.alloc_count", \ sizeof("connection.alloc_count"), \ pStorageStat->connection.alloc_count); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "connection.current_count", \ sizeof("connection.current_count"), \ pStorageStat->connection.current_count); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "connection.max_count", \ sizeof("connection.max_count"), \ pStorageStat->connection.max_count); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "total_upload_count", \ sizeof("total_upload_count"), \ pStorageStat->total_upload_count); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "success_upload_count", \ sizeof("success_upload_count"), \ pStorageStat->success_upload_count); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "total_append_count", \ sizeof("total_append_count"), \ pStorageStat->total_append_count); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "success_append_count", \ sizeof("success_append_count"), \ pStorageStat->success_append_count); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "total_modify_count", \ sizeof("total_modify_count"), \ pStorageStat->total_modify_count); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "success_modify_count", \ sizeof("success_modify_count"), \ pStorageStat->success_modify_count); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "total_truncate_count", \ sizeof("total_truncate_count"), \ pStorageStat->total_truncate_count); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "success_truncate_count", \ sizeof("success_truncate_count"), \ pStorageStat->success_truncate_count); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "total_set_meta_count", \ sizeof("total_set_meta_count"), \ pStorageStat->total_set_meta_count); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "success_set_meta_count", \ sizeof("success_set_meta_count"), \ pStorageStat->success_set_meta_count); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "total_delete_count", \ sizeof("total_delete_count"), \ pStorageStat->total_delete_count); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "success_delete_count", \ sizeof("success_delete_count"), \ pStorageStat->success_delete_count); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "total_download_count", \ sizeof("total_download_count"), \ pStorageStat->total_download_count); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "success_download_count", \ sizeof("success_download_count"), \ pStorageStat->success_download_count); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "total_get_meta_count", \ sizeof("total_get_meta_count"), \ pStorageStat->total_get_meta_count); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "success_get_meta_count", \ sizeof("success_get_meta_count"), \ pStorageStat->success_get_meta_count); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "total_create_link_count", \ sizeof("total_create_link_count"), \ pStorageStat->total_create_link_count); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "success_create_link_count", \ sizeof("success_create_link_count"), \ pStorageStat->success_create_link_count); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "total_delete_link_count", \ sizeof("total_delete_link_count"), \ pStorageStat->total_delete_link_count); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "success_delete_link_count", \ sizeof("success_delete_link_count"), \ pStorageStat->success_delete_link_count); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "total_upload_bytes", \ sizeof("total_upload_bytes"), \ pStorageStat->total_upload_bytes); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "success_upload_bytes", \ sizeof("success_upload_bytes"), \ pStorageStat->success_upload_bytes); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "total_append_bytes", \ sizeof("total_append_bytes"), \ pStorageStat->total_append_bytes); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "success_append_bytes", \ sizeof("success_append_bytes"), \ pStorageStat->success_append_bytes); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "total_modify_bytes", \ sizeof("total_modify_bytes"), \ pStorageStat->total_modify_bytes); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "success_modify_bytes", \ sizeof("success_modify_bytes"), \ pStorageStat->success_modify_bytes); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "total_download_bytes", \ sizeof("total_download_bytes"), \ pStorageStat->total_download_bytes); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "success_download_bytes", \ sizeof("success_download_bytes"), \ pStorageStat->success_download_bytes); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "total_sync_in_bytes", \ sizeof("total_sync_in_bytes"), \ pStorageStat->total_sync_in_bytes); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "success_sync_in_bytes", \ sizeof("success_sync_in_bytes"), \ pStorageStat->success_sync_in_bytes); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "total_sync_out_bytes", \ sizeof("total_sync_out_bytes"), \ pStorageStat->total_sync_out_bytes); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "success_sync_out_bytes", \ sizeof("success_sync_out_bytes"), \ pStorageStat->success_sync_out_bytes); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "total_file_open_count", \ sizeof("total_file_open_count"), \ pStorageStat->total_file_open_count); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "success_file_open_count", \ sizeof("success_file_open_count"), \ pStorageStat->success_file_open_count); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "total_file_read_count", \ sizeof("total_file_read_count"), \ pStorageStat->total_file_read_count); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "success_file_read_count", \ sizeof("success_file_read_count"), \ pStorageStat->success_file_read_count); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "total_file_write_count", \ sizeof("total_file_write_count"), \ pStorageStat->total_file_write_count); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "success_file_write_count", \ sizeof("success_file_write_count"), \ pStorageStat->success_file_write_count); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "last_heart_beat_time", \ sizeof("last_heart_beat_time"), \ pStorageStat->last_heart_beat_time); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "last_source_update", \ sizeof("last_source_update"), \ pStorageStat->last_source_update); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "last_sync_update", \ sizeof("last_sync_update"), \ pStorageStat->last_sync_update); - add_assoc_long_ex(server_info_array, \ + zend_add_assoc_long_ex(server_info_array, \ "last_synced_timestamp", \ sizeof("last_synced_timestamp"), \ pStorageStat->last_synced_timestamp); @@ -1114,7 +1232,7 @@ static void php_fdfs_tracker_query_storage_store_impl( \ int argc; char new_group_name[FDFS_GROUP_NAME_MAX_LEN + 1]; char *group_name; - int group_nlen; + zend_size_t group_nlen; zval *tracker_obj; HashTable *tracker_hash; ConnectionInfo tracker_server; @@ -1202,13 +1320,13 @@ static void php_fdfs_tracker_query_storage_store_impl( \ } array_init(return_value); - add_assoc_stringl_ex(return_value, "ip_addr", \ + zend_add_assoc_stringl_ex(return_value, "ip_addr", \ sizeof("ip_addr"), storage_server.ip_addr, \ strlen(storage_server.ip_addr), 1); - add_assoc_long_ex(return_value, "port", sizeof("port"), \ + zend_add_assoc_long_ex(return_value, "port", sizeof("port"), \ storage_server.port); - add_assoc_long_ex(return_value, "sock", sizeof("sock"), -1); - add_assoc_long_ex(return_value, "store_path_index", \ + zend_add_assoc_long_ex(return_value, "sock", sizeof("sock"), -1); + zend_add_assoc_long_ex(return_value, "store_path_index", \ sizeof("store_path_index"), \ store_path_index); } @@ -1220,7 +1338,7 @@ static void php_fdfs_tracker_query_storage_store_list_impl( \ int argc; char *group_name; char new_group_name[FDFS_GROUP_NAME_MAX_LEN + 1]; - int group_nlen; + zend_size_t group_nlen; zval *server_info_array; zval *tracker_obj; HashTable *tracker_hash; @@ -1324,13 +1442,13 @@ static void php_fdfs_tracker_query_storage_store_list_impl( \ add_index_zval(return_value, pServer - storage_servers, \ server_info_array); - add_assoc_stringl_ex(server_info_array, "ip_addr", \ + zend_add_assoc_stringl_ex(server_info_array, "ip_addr", \ sizeof("ip_addr"), pServer->ip_addr, \ strlen(pServer->ip_addr), 1); - add_assoc_long_ex(server_info_array, "port", sizeof("port"), \ + zend_add_assoc_long_ex(server_info_array, "port", sizeof("port"), \ pServer->port); - add_assoc_long_ex(server_info_array, "sock", sizeof("sock"), -1); - add_assoc_long_ex(server_info_array, "store_path_index", \ + zend_add_assoc_long_ex(server_info_array, "sock", sizeof("sock"), -1); + zend_add_assoc_long_ex(server_info_array, "store_path_index", \ sizeof("store_path_index"), \ store_path_index); } @@ -1344,8 +1462,8 @@ static void php_fdfs_tracker_do_query_storage_impl( \ int argc; char *group_name; char *remote_filename; - int group_nlen; - int filename_len; + zend_size_t group_nlen; + zend_size_t filename_len; zval *tracker_obj; HashTable *tracker_hash; ConnectionInfo tracker_server; @@ -1384,7 +1502,7 @@ static void php_fdfs_tracker_do_query_storage_impl( \ { char *pSeperator; char *file_id; - int file_id_len; + zend_size_t file_id_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|a", \ &file_id, &file_id_len, &tracker_obj) == FAILURE) @@ -1465,12 +1583,12 @@ static void php_fdfs_tracker_do_query_storage_impl( \ } array_init(return_value); - add_assoc_stringl_ex(return_value, "ip_addr", \ + zend_add_assoc_stringl_ex(return_value, "ip_addr", \ sizeof("ip_addr"), storage_server.ip_addr, \ strlen(storage_server.ip_addr), 1); - add_assoc_long_ex(return_value, "port", sizeof("port"), \ + zend_add_assoc_long_ex(return_value, "port", sizeof("port"), \ storage_server.port); - add_assoc_long_ex(return_value, "sock", sizeof("sock"), -1); + zend_add_assoc_long_ex(return_value, "sock", sizeof("sock"), -1); } static void php_fdfs_tracker_delete_storage_impl( \ @@ -1478,8 +1596,8 @@ static void php_fdfs_tracker_delete_storage_impl( \ FDFSPhpContext *pContext) { int argc; - int group_name_len; - int storage_ip_len; + zend_size_t group_name_len; + zend_size_t storage_ip_len; char *group_name; char *storage_ip; @@ -1531,8 +1649,8 @@ static void php_fdfs_storage_delete_file_impl( \ int argc; char *group_name; char *remote_filename; - int group_nlen; - int filename_len; + zend_size_t group_nlen; + zend_size_t filename_len; zval *tracker_obj; zval *storage_obj; HashTable *tracker_hash; @@ -1576,7 +1694,7 @@ static void php_fdfs_storage_delete_file_impl( \ { char *pSeperator; char *file_id; - int file_id_len; + zend_size_t file_id_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|aa", \ &file_id, &file_id_len, &tracker_obj, &storage_obj) \ @@ -1690,8 +1808,8 @@ static void php_fdfs_storage_truncate_file_impl( \ int argc; char *group_name; char *remote_filename; - int group_nlen; - int filename_len; + zend_size_t group_nlen; + zend_size_t filename_len; zval *tracker_obj; zval *storage_obj; HashTable *tracker_hash; @@ -1736,7 +1854,7 @@ static void php_fdfs_storage_truncate_file_impl( \ { char *pSeperator; char *file_id; - int file_id_len; + zend_size_t file_id_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \ "s|laa", &file_id, &file_id_len, \ @@ -1853,8 +1971,8 @@ static void php_fdfs_storage_download_file_to_callback_impl( \ char *group_name; char *remote_filename; zval *download_callback; - int group_nlen; - int filename_len; + zend_size_t group_nlen; + zend_size_t filename_len; long file_offset; long download_bytes; int64_t file_size; @@ -1905,7 +2023,7 @@ static void php_fdfs_storage_download_file_to_callback_impl( \ { char *pSeperator; char *file_id; - int file_id_len; + zend_size_t file_id_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \ "sa|llaa", &file_id, &file_id_len, \ @@ -2035,8 +2153,8 @@ static void php_fdfs_storage_download_file_to_buff_impl( \ char *remote_filename; char *file_buff; char *new_file_buff; - int group_nlen; - int filename_len; + zend_size_t group_nlen; + zend_size_t filename_len; long file_offset; long download_bytes; int64_t file_size; @@ -2085,7 +2203,7 @@ static void php_fdfs_storage_download_file_to_buff_impl( \ { char *pSeperator; char *file_id; - int file_id_len; + zend_size_t file_id_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|llaa", \ &file_id, &file_id_len, &file_offset, &download_bytes, \ @@ -2207,7 +2325,7 @@ static void php_fdfs_storage_download_file_to_buff_impl( \ free(file_buff); pContext->err_no = 0; - RETURN_STRINGL(new_file_buff, file_size, 0); + ZEND_RETURN_STRINGL(new_file_buff, file_size, 0); } static void php_fdfs_storage_download_file_to_file_impl( \ @@ -2218,9 +2336,9 @@ static void php_fdfs_storage_download_file_to_file_impl( \ char *group_name; char *remote_filename; char *local_filename; - int group_nlen; - int remote_file_nlen; - int local_file_nlen; + zend_size_t group_nlen; + zend_size_t remote_file_nlen; + zend_size_t local_file_nlen; long file_offset; long download_bytes; int64_t file_size; @@ -2269,7 +2387,7 @@ static void php_fdfs_storage_download_file_to_file_impl( \ { char *pSeperator; char *file_id; - int file_id_len; + zend_size_t file_id_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|llaa",\ &file_id, &file_id_len, &local_filename, \ @@ -2388,8 +2506,8 @@ static void php_fdfs_storage_get_metadata_impl( \ int argc; char *group_name; char *remote_filename; - int group_nlen; - int filename_len; + zend_size_t group_nlen; + zend_size_t filename_len; zval *tracker_obj; zval *storage_obj; HashTable *tracker_hash; @@ -2437,7 +2555,7 @@ static void php_fdfs_storage_get_metadata_impl( \ { char *pSeperator; char *file_id; - int file_id_len; + zend_size_t file_id_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|aa", \ &file_id, &file_id_len, &tracker_obj, &storage_obj) \ @@ -2547,7 +2665,7 @@ static void php_fdfs_storage_get_metadata_impl( \ pMetaEnd = meta_list + meta_count; for (pMetaData=meta_list; pMetaDataname, \ + zend_add_assoc_stringl_ex(return_value, pMetaData->name, \ strlen(pMetaData->name)+1, pMetaData->value,\ strlen(pMetaData->value), 1); } @@ -2563,8 +2681,8 @@ static void php_fdfs_storage_file_exist_impl( \ int argc; char *group_name; char *remote_filename; - int group_nlen; - int filename_len; + zend_size_t group_nlen; + zend_size_t filename_len; zval *tracker_obj; zval *storage_obj; HashTable *tracker_hash; @@ -2608,7 +2726,7 @@ static void php_fdfs_storage_file_exist_impl( \ { char *pSeperator; char *file_id; - int file_id_len; + zend_size_t file_id_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|aa", \ &file_id, &file_id_len, &tracker_obj, &storage_obj) \ @@ -2720,8 +2838,8 @@ static void php_fdfs_tracker_query_storage_list_impl( \ int argc; char *group_name; char *remote_filename; - int group_nlen; - int filename_len; + zend_size_t group_nlen; + zend_size_t filename_len; zval *tracker_obj; zval *server_info_array; HashTable *tracker_hash; @@ -2764,7 +2882,7 @@ static void php_fdfs_tracker_query_storage_list_impl( \ { char *pSeperator; char *file_id; - int file_id_len; + zend_size_t file_id_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|a", \ &file_id, &file_id_len, &tracker_obj) == FAILURE) @@ -2854,12 +2972,12 @@ static void php_fdfs_tracker_query_storage_list_impl( \ add_index_zval(return_value, pServer - storage_servers, \ server_info_array); - add_assoc_stringl_ex(server_info_array, "ip_addr", \ + zend_add_assoc_stringl_ex(server_info_array, "ip_addr", \ sizeof("ip_addr"), pServer->ip_addr, \ strlen(pServer->ip_addr), 1); - add_assoc_long_ex(server_info_array, "port", sizeof("port"), \ + zend_add_assoc_long_ex(server_info_array, "port", sizeof("port"), \ pServer->port); - add_assoc_long_ex(server_info_array,"sock",sizeof("sock"),-1); + zend_add_assoc_long_ex(server_info_array,"sock",sizeof("sock"),-1); } } @@ -2873,23 +2991,23 @@ static int php_fdfs_upload_callback(void *arg, const int64_t file_size, int sock int result; TSRMLS_FETCH(); - INIT_ZVAL(ret); + INIT_ZVAL(ret); ZVAL_NULL(&ret); - INIT_ZVAL(zsock); + INIT_ZVAL(zsock); ZVAL_LONG(&zsock, sock); pUploadCallback = (php_fdfs_upload_callback_t *)arg; if (pUploadCallback->callback.args == NULL) { - INIT_ZVAL(null_args); + INIT_ZVAL(null_args); ZVAL_NULL(&null_args); pUploadCallback->callback.args = &null_args; } args[0] = &zsock; args[1] = pUploadCallback->callback.args; - if (call_user_function(EG(function_table), NULL, \ + if (fdfs_call_user_function(EG(function_table), NULL, \ pUploadCallback->callback.func_name, &ret, 2, args TSRMLS_CC) == FAILURE) { @@ -2899,7 +3017,7 @@ static int php_fdfs_upload_callback(void *arg, const int64_t file_size, int sock return EINVAL; } - if (ret.type == IS_LONG || ret.type == IS_BOOL) + if (ZEND_TYPE_OF(&ret) == IS_LONG || ZEND_IS_BOOL(&ret)) { result = ret.value.lval == 0 ? EFAULT : 0; } @@ -2907,7 +3025,7 @@ static int php_fdfs_upload_callback(void *arg, const int64_t file_size, int sock { logError("file: "__FILE__", line: %d, " \ "callback function return invalid value type: %d", \ - __LINE__, ret.type); + __LINE__, ZEND_TYPE_OF(&ret)); result = EINVAL; } @@ -2926,26 +3044,30 @@ static int php_fdfs_download_callback(void *arg, const int64_t file_size, \ int result; TSRMLS_FETCH(); - INIT_ZVAL(ret); + INIT_ZVAL(ret); ZVAL_NULL(&ret); - INIT_ZVAL(zfilesize); + INIT_ZVAL(zfilesize); ZVAL_LONG(&zfilesize, file_size); - INIT_ZVAL(zdata); + INIT_ZVAL(zdata); +#if PHP_MAJOR_VERSION < 7 ZVAL_STRINGL(&zdata, (char *)data, current_size, 0); +#else + ZVAL_STRINGL(&zdata, (char *)data, current_size); +#endif pCallback = (php_fdfs_callback_t *)arg; if (pCallback->args == NULL) { - INIT_ZVAL(null_args); + INIT_ZVAL(null_args); ZVAL_NULL(&null_args); pCallback->args = &null_args; } args[0] = pCallback->args; args[1] = &zfilesize; args[2] = &zdata; - if (call_user_function(EG(function_table), NULL, \ + if (fdfs_call_user_function(EG(function_table), NULL, \ pCallback->func_name, &ret, 3, args TSRMLS_CC) == FAILURE) { @@ -2955,7 +3077,7 @@ static int php_fdfs_download_callback(void *arg, const int64_t file_size, \ return EINVAL; } - if (ret.type == IS_LONG || ret.type == IS_BOOL) + if (ZEND_TYPE_OF(&ret) == IS_LONG || ZEND_IS_BOOL(&ret)) { result = ret.value.lval == 0 ? EFAULT : 0; } @@ -2963,7 +3085,7 @@ static int php_fdfs_download_callback(void *arg, const int64_t file_size, \ { logError("file: "__FILE__", line: %d, " \ "callback function return invalid value type: %d", \ - __LINE__, ret.type); + __LINE__, ZEND_TYPE_OF(&ret)); result = EINVAL; } @@ -2983,7 +3105,7 @@ static void php_fdfs_storage_upload_file_impl(INTERNAL_FUNCTION_PARAMETERS, \ int result; int argc; char *local_filename; - int filename_len; + zend_size_t filename_len; char *file_ext_name; zval *callback_obj; zval *ext_name_obj; @@ -3052,28 +3174,28 @@ static void php_fdfs_storage_upload_file_impl(INTERNAL_FUNCTION_PARAMETERS, \ } else { - if (ext_name_obj->type == IS_NULL) + if (ZEND_TYPE_OF(ext_name_obj) == IS_NULL) { file_ext_name = NULL; } - else if (ext_name_obj->type == IS_STRING) + else if (ZEND_TYPE_OF(ext_name_obj) == IS_STRING) { - file_ext_name = ext_name_obj->value.str.val; + file_ext_name = Z_STRVAL_P(ext_name_obj); } else { logError("file: "__FILE__", line: %d, " \ "file_ext_name is not a string, type=%d!", \ - __LINE__, ext_name_obj->type); + __LINE__, ZEND_TYPE_OF(ext_name_obj)); pContext->err_no = EINVAL; RETURN_BOOL(false); } } - if (group_name_obj != NULL && group_name_obj->type == IS_STRING) + if (group_name_obj != NULL && ZEND_TYPE_OF(group_name_obj) == IS_STRING) { snprintf(group_name, sizeof(group_name), "%s", \ - group_name_obj->value.str.val); + Z_STRVAL_P(group_name_obj)); } else { @@ -3115,8 +3237,7 @@ static void php_fdfs_storage_upload_file_impl(INTERNAL_FUNCTION_PARAMETERS, \ } else { - zval **data; - zval ***ppp; + zval *data; pStorageServer = &storage_server; storage_hash = Z_ARRVAL_P(storage_obj); @@ -3127,10 +3248,8 @@ static void php_fdfs_storage_upload_file_impl(INTERNAL_FUNCTION_PARAMETERS, \ RETURN_BOOL(false); } - data = NULL; - ppp = &data; - if (zend_hash_find(storage_hash, "store_path_index", \ - sizeof("store_path_index"), (void **)ppp) == FAILURE) + if (fdfs_zend_hash_find(storage_hash, "store_path_index", \ + sizeof("store_path_index"), &data) == FAILURE) { logError("file: "__FILE__", line: %d, " \ "key \"store_path_index\" not exist!", \ @@ -3139,19 +3258,19 @@ static void php_fdfs_storage_upload_file_impl(INTERNAL_FUNCTION_PARAMETERS, \ RETURN_BOOL(false); } - if ((*data)->type == IS_LONG) + if (ZEND_TYPE_OF(data) == IS_LONG) { - store_path_index = (*data)->value.lval; + store_path_index = data->value.lval; } - else if ((*data)->type == IS_STRING) + else if (ZEND_TYPE_OF(data) == IS_STRING) { - store_path_index = atoi(Z_STRVAL_PP(data)); + store_path_index = atoi(Z_STRVAL_P(data)); } else { logError("file: "__FILE__", line: %d, " \ "key \"store_path_index\" is invalid, " \ - "type=%d!", __LINE__, (*data)->type); + "type=%d!", __LINE__, ZEND_TYPE_OF(data)); pContext->err_no = EINVAL; RETURN_BOOL(false); } @@ -3246,16 +3365,16 @@ static void php_fdfs_storage_upload_file_impl(INTERNAL_FUNCTION_PARAMETERS, \ file_id_len = sprintf(file_id, "%s%c%s", group_name, \ FDFS_FILE_ID_SEPERATOR, remote_filename); - RETURN_STRINGL(file_id, file_id_len, 1); + ZEND_RETURN_STRINGL(file_id, file_id_len, 1); } else { array_init(return_value); - add_assoc_stringl_ex(return_value, "group_name", \ + zend_add_assoc_stringl_ex(return_value, "group_name", \ sizeof("group_name"), group_name, \ strlen(group_name), 1); - add_assoc_stringl_ex(return_value, "filename", \ + zend_add_assoc_stringl_ex(return_value, "filename", \ sizeof("filename"), remote_filename, \ strlen(remote_filename), 1); } @@ -3285,10 +3404,10 @@ static void php_fdfs_storage_upload_slave_file_impl( \ ConnectionInfo *pStorageServer; FDFSMetaData *meta_list; int meta_count; - int filename_len; - int group_name_len; - int master_filename_len; - int prefix_name_len; + zend_size_t filename_len; + zend_size_t group_name_len; + zend_size_t master_filename_len; + zend_size_t prefix_name_len; int saved_tracker_sock; int saved_storage_sock; int min_param_count; @@ -3330,7 +3449,7 @@ static void php_fdfs_storage_upload_slave_file_impl( \ { char *pSeperator; char *master_file_id; - int master_file_id_len; + zend_size_t master_file_id_len; if (upload_type == FDFS_UPLOAD_BY_CALLBACK) { @@ -3406,19 +3525,19 @@ static void php_fdfs_storage_upload_slave_file_impl( \ } else { - if (ext_name_obj->type == IS_NULL) + if (ZEND_TYPE_OF(ext_name_obj) == IS_NULL) { file_ext_name = NULL; } - else if (ext_name_obj->type == IS_STRING) + else if (ZEND_TYPE_OF(ext_name_obj) == IS_STRING) { - file_ext_name = ext_name_obj->value.str.val; + file_ext_name = Z_STRVAL_P(ext_name_obj); } else { logError("file: "__FILE__", line: %d, " \ "file_ext_name is not a string, type=%d!", \ - __LINE__, ext_name_obj->type); + __LINE__, ZEND_TYPE_OF(ext_name_obj)); pContext->err_no = EINVAL; RETURN_BOOL(false); } @@ -3554,16 +3673,16 @@ static void php_fdfs_storage_upload_slave_file_impl( \ file_id_len = sprintf(file_id, "%s%c%s", new_group_name, \ FDFS_FILE_ID_SEPERATOR, remote_filename); - RETURN_STRINGL(file_id, file_id_len, 1); + ZEND_RETURN_STRINGL(file_id, file_id_len, 1); } else { array_init(return_value); - add_assoc_stringl_ex(return_value, "group_name", \ + zend_add_assoc_stringl_ex(return_value, "group_name", \ sizeof("group_name"), new_group_name, \ strlen(new_group_name), 1); - add_assoc_stringl_ex(return_value, "filename", \ + zend_add_assoc_stringl_ex(return_value, "filename", \ sizeof("filename"), remote_filename, \ strlen(remote_filename), 1); } @@ -3594,9 +3713,9 @@ static void php_fdfs_storage_append_file_impl( \ ConnectionInfo *pTrackerServer; ConnectionInfo *pStorageServer; char new_file_id[FDFS_GROUP_NAME_MAX_LEN + 128]; - int filename_len; - int group_name_len; - int appender_filename_len; + zend_size_t filename_len; + zend_size_t group_name_len; + zend_size_t appender_filename_len; int saved_tracker_sock; int saved_storage_sock; int min_param_count; @@ -3633,7 +3752,7 @@ static void php_fdfs_storage_append_file_impl( \ { char *pSeperator; char *appender_file_id; - int appender_file_id_len; + zend_size_t appender_file_id_len; if (upload_type == FDFS_UPLOAD_BY_CALLBACK) { @@ -3822,9 +3941,9 @@ static void php_fdfs_storage_modify_file_impl( \ ConnectionInfo *pTrackerServer; ConnectionInfo *pStorageServer; char new_file_id[FDFS_GROUP_NAME_MAX_LEN + 128]; - int filename_len; - int group_name_len; - int appender_filename_len; + zend_size_t filename_len; + zend_size_t group_name_len; + zend_size_t appender_filename_len; int saved_tracker_sock; int saved_storage_sock; int min_param_count; @@ -3862,7 +3981,7 @@ static void php_fdfs_storage_modify_file_impl( \ { char *pSeperator; char *appender_file_id; - int appender_file_id_len; + zend_size_t appender_file_id_len; if (upload_type == FDFS_UPLOAD_BY_CALLBACK) { @@ -4039,9 +4158,9 @@ static void php_fdfs_storage_set_metadata_impl(INTERNAL_FUNCTION_PARAMETERS, \ char *remote_filename; char *op_type_str; char op_type; - int group_nlen; - int filename_len; - int op_type_len; + zend_size_t group_nlen; + zend_size_t filename_len; + zend_size_t op_type_len; zval *metadata_obj; zval *tracker_obj; zval *storage_obj; @@ -4089,7 +4208,7 @@ static void php_fdfs_storage_set_metadata_impl(INTERNAL_FUNCTION_PARAMETERS, \ { char *pSeperator; char *file_id; - int file_id_len; + zend_size_t file_id_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sa|saa", \ &file_id, &file_id_len, &metadata_obj, &op_type_str, \ @@ -4246,7 +4365,7 @@ static void php_fdfs_http_gen_token_impl(INTERNAL_FUNCTION_PARAMETERS, \ int result; int argc; char *file_id; - int file_id_len; + zend_size_t file_id_len; long ts; char token[64]; @@ -4277,7 +4396,7 @@ static void php_fdfs_http_gen_token_impl(INTERNAL_FUNCTION_PARAMETERS, \ RETURN_BOOL(false); } - RETURN_STRINGL(token, strlen(token), 1); + ZEND_RETURN_STRINGL(token, strlen(token), 1); } static void php_fdfs_send_data_impl(INTERNAL_FUNCTION_PARAMETERS, \ @@ -4286,7 +4405,7 @@ static void php_fdfs_send_data_impl(INTERNAL_FUNCTION_PARAMETERS, \ int argc; long sock; char *buff; - int buff_len; + zend_size_t buff_len; argc = ZEND_NUM_ARGS(); if (argc != 2) @@ -4323,8 +4442,8 @@ static void php_fdfs_get_file_info_impl(INTERNAL_FUNCTION_PARAMETERS, \ int argc; char *group_name; char *remote_filename; - int group_nlen; - int filename_len; + zend_size_t group_nlen; + zend_size_t filename_len; int param_count; FDFSFileInfo file_info; char new_file_id[FDFS_GROUP_NAME_MAX_LEN + 128]; @@ -4352,7 +4471,7 @@ static void php_fdfs_get_file_info_impl(INTERNAL_FUNCTION_PARAMETERS, \ { char *pSeperator; char *file_id; - int file_id_len; + zend_size_t file_id_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", \ &file_id, &file_id_len) == FAILURE) @@ -4399,16 +4518,16 @@ static void php_fdfs_get_file_info_impl(INTERNAL_FUNCTION_PARAMETERS, \ } array_init(return_value); - add_assoc_long_ex(return_value, "source_id", \ + zend_add_assoc_long_ex(return_value, "source_id", \ sizeof("source_id"), file_info.source_id); - add_assoc_long_ex(return_value, "create_timestamp", \ + zend_add_assoc_long_ex(return_value, "create_timestamp", \ sizeof("create_timestamp"), file_info.create_timestamp); - add_assoc_long_ex(return_value, "file_size", \ + zend_add_assoc_long_ex(return_value, "file_size", \ sizeof("file_size"), (long)file_info.file_size); - add_assoc_stringl_ex(return_value, "source_ip_addr", \ + zend_add_assoc_stringl_ex(return_value, "source_ip_addr", \ sizeof("source_ip_addr"), file_info.source_ip_addr, \ strlen(file_info.source_ip_addr), 1); - add_assoc_long_ex(return_value, "crc32", \ + zend_add_assoc_long_ex(return_value, "crc32", \ sizeof("crc32"), file_info.crc32); } @@ -4423,9 +4542,9 @@ static void php_fdfs_gen_slave_filename_impl(INTERNAL_FUNCTION_PARAMETERS, \ int result; int argc; char *master_filename; - int master_filename_len; + zend_size_t master_filename_len; char *prefix_name; - int prefix_name_len; + zend_size_t prefix_name_len; int filename_len; zval *ext_name_obj; char *file_ext_name; @@ -4460,21 +4579,21 @@ static void php_fdfs_gen_slave_filename_impl(INTERNAL_FUNCTION_PARAMETERS, \ } else { - if (ext_name_obj->type == IS_NULL) + if (ZEND_TYPE_OF(ext_name_obj) == IS_NULL) { file_ext_name = NULL; file_ext_name_len = 0; } - else if (ext_name_obj->type == IS_STRING) + else if (ZEND_TYPE_OF(ext_name_obj) == IS_STRING) { - file_ext_name = ext_name_obj->value.str.val; - file_ext_name_len = ext_name_obj->value.str.len; + file_ext_name = Z_STRVAL_P(ext_name_obj); + file_ext_name_len = Z_STRLEN_P(ext_name_obj); } else { logError("file: "__FILE__", line: %d, " \ "file_ext_name is not a string, type=%d!", \ - __LINE__, ext_name_obj->type); + __LINE__, ZEND_TYPE_OF(ext_name_obj)); pContext->err_no = EINVAL; RETURN_BOOL(false); } @@ -4497,7 +4616,7 @@ static void php_fdfs_gen_slave_filename_impl(INTERNAL_FUNCTION_PARAMETERS, \ RETURN_BOOL(false); } - RETURN_STRINGL(filename, filename_len, 1); + ZEND_RETURN_STRINGL(filename, filename_len, 1); } /* @@ -4578,7 +4697,7 @@ ZEND_FUNCTION(fastdfs_get_last_error_info) char *error_info; error_info = STRERROR(php_context.err_no); - RETURN_STRINGL(error_info, strlen(error_info), 1); + ZEND_RETURN_STRINGL(error_info, strlen(error_info), 1); } /* @@ -4593,7 +4712,7 @@ ZEND_FUNCTION(fastdfs_client_version) len = sprintf(szVersion, "%d.%02d", \ g_fdfs_version.major, g_fdfs_version.minor); - RETURN_STRINGL(szVersion, len, 1); + ZEND_RETURN_STRINGL(szVersion, len, 1); } /* @@ -5342,7 +5461,6 @@ static void php_fdfs_close(php_fdfs_t *i_obj TSRMLS_DC) } } -/* constructor/destructor */ static void php_fdfs_destroy(php_fdfs_t *i_obj TSRMLS_DC) { php_fdfs_close(i_obj TSRMLS_CC); @@ -5359,12 +5477,22 @@ static void php_fdfs_destroy(php_fdfs_t *i_obj TSRMLS_DC) ZEND_RSRC_DTOR_FUNC(php_fdfs_dtor) { +#if PHP_MAJOR_VERSION < 7 if (rsrc->ptr != NULL) { php_fdfs_t *i_obj = (php_fdfs_t *)rsrc->ptr; php_fdfs_destroy(i_obj TSRMLS_CC); rsrc->ptr = NULL; } +#else + if (res->ptr != NULL) + { + php_fdfs_t *i_obj = (php_fdfs_t *)res->ptr; + php_fdfs_destroy(i_obj TSRMLS_CC); + res->ptr = NULL; + } +#endif + } /* FastDFS::__construct([int config_index = 0, bool bMultiThread = false]) @@ -5396,7 +5524,7 @@ static PHP_METHOD(FastDFS, __construct) return; } - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); i_obj->pConfigInfo = config_list + config_index; i_obj->context.err_no = 0; if (bMultiThread) @@ -5425,6 +5553,11 @@ static PHP_METHOD(FastDFS, __construct) } } +static PHP_METHOD(FastDFS, __destruct) +{ + logInfo("file: "__FILE__",line: %d, __destruct", __LINE__); +} + /* array FastDFS::tracker_get_connection() return array for success, false for error @@ -5434,7 +5567,7 @@ PHP_METHOD(FastDFS, tracker_get_connection) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_tracker_get_connection_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, \ &(i_obj->context)); } @@ -5448,7 +5581,7 @@ PHP_METHOD(FastDFS, tracker_make_all_connections) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_tracker_make_all_connections_impl( \ INTERNAL_FUNCTION_PARAM_PASSTHRU, &(i_obj->context)); } @@ -5462,7 +5595,7 @@ PHP_METHOD(FastDFS, tracker_close_all_connections) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_tracker_close_all_connections_impl( \ INTERNAL_FUNCTION_PARAM_PASSTHRU, &(i_obj->context)); } @@ -5476,7 +5609,7 @@ PHP_METHOD(FastDFS, connect_server) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_connect_server_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, \ &(i_obj->context)); } @@ -5490,7 +5623,7 @@ PHP_METHOD(FastDFS, disconnect_server) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_disconnect_server_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, \ &(i_obj->context)); } @@ -5504,7 +5637,7 @@ PHP_METHOD(FastDFS, active_test) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fastdfs_active_test_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, \ &(i_obj->context)); } @@ -5518,7 +5651,7 @@ PHP_METHOD(FastDFS, tracker_list_groups) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_tracker_list_groups_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, \ &(i_obj->context)); } @@ -5533,7 +5666,7 @@ PHP_METHOD(FastDFS, tracker_query_storage_store) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_tracker_query_storage_store_impl( \ INTERNAL_FUNCTION_PARAM_PASSTHRU, \ &(i_obj->context)); @@ -5549,7 +5682,7 @@ PHP_METHOD(FastDFS, tracker_query_storage_store_list) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_tracker_query_storage_store_list_impl( \ INTERNAL_FUNCTION_PARAM_PASSTHRU, \ &(i_obj->context)); @@ -5565,7 +5698,7 @@ PHP_METHOD(FastDFS, tracker_query_storage_update) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_tracker_do_query_storage_impl( \ INTERNAL_FUNCTION_PARAM_PASSTHRU, &(i_obj->context), \ TRACKER_PROTO_CMD_SERVICE_QUERY_UPDATE, false); @@ -5581,7 +5714,7 @@ PHP_METHOD(FastDFS, tracker_query_storage_fetch) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_tracker_do_query_storage_impl( \ INTERNAL_FUNCTION_PARAM_PASSTHRU, &(i_obj->context), \ TRACKER_PROTO_CMD_SERVICE_QUERY_FETCH_ONE, false); @@ -5597,7 +5730,7 @@ PHP_METHOD(FastDFS, tracker_query_storage_list) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_tracker_query_storage_list_impl( \ INTERNAL_FUNCTION_PARAM_PASSTHRU, &(i_obj->context), false); } @@ -5611,7 +5744,7 @@ PHP_METHOD(FastDFS, tracker_delete_storage) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_tracker_delete_storage_impl( \ INTERNAL_FUNCTION_PARAM_PASSTHRU, &(i_obj->context)); } @@ -5626,7 +5759,7 @@ PHP_METHOD(FastDFS, tracker_query_storage_update1) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_tracker_do_query_storage_impl( \ INTERNAL_FUNCTION_PARAM_PASSTHRU, &(i_obj->context), \ TRACKER_PROTO_CMD_SERVICE_QUERY_UPDATE, true); @@ -5642,7 +5775,7 @@ PHP_METHOD(FastDFS, tracker_query_storage_fetch1) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_tracker_do_query_storage_impl( \ INTERNAL_FUNCTION_PARAM_PASSTHRU, &(i_obj->context), \ TRACKER_PROTO_CMD_SERVICE_QUERY_FETCH_ONE, true); @@ -5658,7 +5791,7 @@ PHP_METHOD(FastDFS, tracker_query_storage_list1) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_tracker_query_storage_list_impl( \ INTERNAL_FUNCTION_PARAM_PASSTHRU, &(i_obj->context), true); } @@ -5674,7 +5807,7 @@ PHP_METHOD(FastDFS, storage_upload_by_filename) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_upload_file_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, \ &(i_obj->context), STORAGE_PROTO_CMD_UPLOAD_FILE, \ FDFS_UPLOAD_BY_FILE, false); @@ -5691,7 +5824,7 @@ PHP_METHOD(FastDFS, storage_upload_by_filename1) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_upload_file_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, \ &(i_obj->context), STORAGE_PROTO_CMD_UPLOAD_FILE, \ FDFS_UPLOAD_BY_FILE, true); @@ -5708,7 +5841,7 @@ PHP_METHOD(FastDFS, storage_upload_by_filebuff) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_upload_file_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, \ &(i_obj->context), STORAGE_PROTO_CMD_UPLOAD_FILE, \ FDFS_UPLOAD_BY_BUFF, false); @@ -5725,7 +5858,7 @@ PHP_METHOD(FastDFS, storage_upload_by_filebuff1) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_upload_file_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, \ &(i_obj->context), STORAGE_PROTO_CMD_UPLOAD_FILE, \ FDFS_UPLOAD_BY_BUFF, true); @@ -5742,7 +5875,7 @@ PHP_METHOD(FastDFS, storage_upload_by_callback) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_upload_file_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, \ &(i_obj->context), STORAGE_PROTO_CMD_UPLOAD_FILE, \ FDFS_UPLOAD_BY_CALLBACK, false); @@ -5759,7 +5892,7 @@ PHP_METHOD(FastDFS, storage_upload_by_callback1) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_upload_file_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, \ &(i_obj->context), STORAGE_PROTO_CMD_UPLOAD_FILE, \ FDFS_UPLOAD_BY_CALLBACK, true); @@ -5776,7 +5909,7 @@ PHP_METHOD(FastDFS, storage_append_by_filename) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_append_file_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, \ &(i_obj->context), FDFS_UPLOAD_BY_FILE, false); } @@ -5792,7 +5925,7 @@ PHP_METHOD(FastDFS, storage_append_by_filename1) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_append_file_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, \ &(i_obj->context), FDFS_UPLOAD_BY_FILE, true); } @@ -5808,7 +5941,7 @@ PHP_METHOD(FastDFS, storage_append_by_filebuff) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_append_file_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, \ &(i_obj->context), FDFS_UPLOAD_BY_BUFF, false); } @@ -5824,7 +5957,7 @@ PHP_METHOD(FastDFS, storage_append_by_filebuff1) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_append_file_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, \ &(i_obj->context), FDFS_UPLOAD_BY_BUFF, true); } @@ -5840,7 +5973,7 @@ PHP_METHOD(FastDFS, storage_append_by_callback) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_append_file_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, \ &(i_obj->context), FDFS_UPLOAD_BY_CALLBACK, false); } @@ -5856,7 +5989,7 @@ PHP_METHOD(FastDFS, storage_append_by_callback1) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_append_file_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, \ &(i_obj->context), FDFS_UPLOAD_BY_CALLBACK, true); } @@ -5873,7 +6006,7 @@ PHP_METHOD(FastDFS, storage_modify_by_filename) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_modify_file_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, \ &(i_obj->context), FDFS_UPLOAD_BY_FILE, false); } @@ -5889,7 +6022,7 @@ PHP_METHOD(FastDFS, storage_modify_by_filename1) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_modify_file_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, \ &(i_obj->context), FDFS_UPLOAD_BY_FILE, true); } @@ -5905,7 +6038,7 @@ PHP_METHOD(FastDFS, storage_modify_by_filebuff) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_modify_file_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, \ &(i_obj->context), FDFS_UPLOAD_BY_BUFF, false); } @@ -5921,7 +6054,7 @@ PHP_METHOD(FastDFS, storage_modify_by_filebuff1) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_modify_file_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, \ &(i_obj->context), FDFS_UPLOAD_BY_BUFF, true); } @@ -5937,7 +6070,7 @@ PHP_METHOD(FastDFS, storage_modify_by_callback) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_modify_file_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, \ &(i_obj->context), FDFS_UPLOAD_BY_CALLBACK, false); } @@ -5953,7 +6086,7 @@ PHP_METHOD(FastDFS, storage_modify_by_callback1) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_modify_file_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, \ &(i_obj->context), FDFS_UPLOAD_BY_CALLBACK, true); } @@ -5969,7 +6102,7 @@ PHP_METHOD(FastDFS, storage_upload_appender_by_filename) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_upload_file_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, \ &(i_obj->context), STORAGE_PROTO_CMD_UPLOAD_APPENDER_FILE, \ FDFS_UPLOAD_BY_FILE, false); @@ -5986,7 +6119,7 @@ PHP_METHOD(FastDFS, storage_upload_appender_by_filename1) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_upload_file_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, \ &(i_obj->context), STORAGE_PROTO_CMD_UPLOAD_APPENDER_FILE, \ FDFS_UPLOAD_BY_FILE, true); @@ -6003,7 +6136,7 @@ PHP_METHOD(FastDFS, storage_upload_appender_by_filebuff) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_upload_file_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, \ &(i_obj->context), STORAGE_PROTO_CMD_UPLOAD_APPENDER_FILE, \ FDFS_UPLOAD_BY_BUFF, false); @@ -6020,7 +6153,7 @@ PHP_METHOD(FastDFS, storage_upload_appender_by_filebuff1) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_upload_file_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, \ &(i_obj->context), STORAGE_PROTO_CMD_UPLOAD_APPENDER_FILE, \ FDFS_UPLOAD_BY_BUFF, true); @@ -6037,7 +6170,7 @@ PHP_METHOD(FastDFS, storage_upload_appender_by_callback) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_upload_file_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, \ &(i_obj->context), STORAGE_PROTO_CMD_UPLOAD_APPENDER_FILE, \ FDFS_UPLOAD_BY_CALLBACK, false); @@ -6054,7 +6187,7 @@ PHP_METHOD(FastDFS, storage_upload_appender_by_callback1) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_upload_file_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, \ &(i_obj->context), STORAGE_PROTO_CMD_UPLOAD_APPENDER_FILE, \ FDFS_UPLOAD_BY_CALLBACK, true); @@ -6073,7 +6206,7 @@ PHP_METHOD(FastDFS, storage_upload_slave_by_filename) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_upload_slave_file_impl( \ INTERNAL_FUNCTION_PARAM_PASSTHRU, &(i_obj->context), \ FDFS_UPLOAD_BY_FILE, false); @@ -6091,7 +6224,7 @@ PHP_METHOD(FastDFS, storage_upload_slave_by_filename1) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_upload_slave_file_impl( \ INTERNAL_FUNCTION_PARAM_PASSTHRU, &(i_obj->context), \ FDFS_UPLOAD_BY_FILE, true); @@ -6109,7 +6242,7 @@ PHP_METHOD(FastDFS, storage_upload_slave_by_filebuff) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_upload_slave_file_impl( \ INTERNAL_FUNCTION_PARAM_PASSTHRU, &(i_obj->context), \ FDFS_UPLOAD_BY_BUFF, false); @@ -6126,7 +6259,7 @@ PHP_METHOD(FastDFS, storage_upload_slave_by_filebuff1) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_upload_slave_file_impl( \ INTERNAL_FUNCTION_PARAM_PASSTHRU, &(i_obj->context), \ FDFS_UPLOAD_BY_BUFF, true); @@ -6144,7 +6277,7 @@ PHP_METHOD(FastDFS, storage_upload_slave_by_callback) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_upload_slave_file_impl( \ INTERNAL_FUNCTION_PARAM_PASSTHRU, &(i_obj->context), \ FDFS_UPLOAD_BY_CALLBACK, false); @@ -6162,7 +6295,7 @@ PHP_METHOD(FastDFS, storage_upload_slave_by_callback1) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_upload_slave_file_impl( \ INTERNAL_FUNCTION_PARAM_PASSTHRU, &(i_obj->context), \ FDFS_UPLOAD_BY_CALLBACK, true); @@ -6178,7 +6311,7 @@ PHP_METHOD(FastDFS, storage_delete_file) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_delete_file_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, \ &(i_obj->context), false); } @@ -6193,7 +6326,7 @@ PHP_METHOD(FastDFS, storage_delete_file1) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_delete_file_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, \ &(i_obj->context), true); } @@ -6209,7 +6342,7 @@ PHP_METHOD(FastDFS, storage_truncate_file) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_truncate_file_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, \ &(i_obj->context), false); } @@ -6225,7 +6358,7 @@ PHP_METHOD(FastDFS, storage_truncate_file1) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_truncate_file_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, \ &(i_obj->context), true); } @@ -6241,7 +6374,7 @@ PHP_METHOD(FastDFS, storage_download_file_to_buff) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_download_file_to_buff_impl( \ INTERNAL_FUNCTION_PARAM_PASSTHRU, &(i_obj->context), false); } @@ -6257,7 +6390,7 @@ PHP_METHOD(FastDFS, storage_download_file_to_buff1) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_download_file_to_buff_impl( \ INTERNAL_FUNCTION_PARAM_PASSTHRU, &(i_obj->context), true); } @@ -6273,7 +6406,7 @@ PHP_METHOD(FastDFS, storage_download_file_to_callback) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_download_file_to_callback_impl( \ INTERNAL_FUNCTION_PARAM_PASSTHRU, &(i_obj->context), false); } @@ -6289,7 +6422,7 @@ PHP_METHOD(FastDFS, storage_download_file_to_callback1) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_download_file_to_callback_impl( \ INTERNAL_FUNCTION_PARAM_PASSTHRU, &(i_obj->context), true); } @@ -6306,7 +6439,7 @@ PHP_METHOD(FastDFS, storage_download_file_to_file) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_download_file_to_file_impl( \ INTERNAL_FUNCTION_PARAM_PASSTHRU, &(i_obj->context), false); } @@ -6322,7 +6455,7 @@ PHP_METHOD(FastDFS, storage_download_file_to_file1) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_download_file_to_file_impl( \ INTERNAL_FUNCTION_PARAM_PASSTHRU, &(i_obj->context), true); } @@ -6338,7 +6471,7 @@ PHP_METHOD(FastDFS, storage_set_metadata) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_set_metadata_impl( \ INTERNAL_FUNCTION_PARAM_PASSTHRU, &(i_obj->context), false); } @@ -6354,7 +6487,7 @@ PHP_METHOD(FastDFS, storage_set_metadata1) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_set_metadata_impl( \ INTERNAL_FUNCTION_PARAM_PASSTHRU, &(i_obj->context), true); } @@ -6369,7 +6502,7 @@ PHP_METHOD(FastDFS, storage_get_metadata) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_get_metadata_impl( \ INTERNAL_FUNCTION_PARAM_PASSTHRU, &(i_obj->context), false); } @@ -6384,7 +6517,7 @@ PHP_METHOD(FastDFS, storage_get_metadata1) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_get_metadata_impl( \ INTERNAL_FUNCTION_PARAM_PASSTHRU, &(i_obj->context), true); } @@ -6399,7 +6532,7 @@ PHP_METHOD(FastDFS, storage_file_exist) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_file_exist_impl( \ INTERNAL_FUNCTION_PARAM_PASSTHRU, &(i_obj->context), false); } @@ -6414,7 +6547,7 @@ PHP_METHOD(FastDFS, storage_file_exist1) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_storage_file_exist_impl( \ INTERNAL_FUNCTION_PARAM_PASSTHRU, &(i_obj->context), true); } @@ -6428,7 +6561,7 @@ PHP_METHOD(FastDFS, get_last_error_no) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); RETURN_LONG(i_obj->context.err_no); } @@ -6442,9 +6575,9 @@ PHP_METHOD(FastDFS, get_last_error_info) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); error_info = STRERROR(i_obj->context.err_no); - RETURN_STRINGL(error_info, strlen(error_info), 1); + ZEND_RETURN_STRINGL(error_info, strlen(error_info), 1); } /* @@ -6456,7 +6589,7 @@ PHP_METHOD(FastDFS, http_gen_token) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_http_gen_token_impl( \ INTERNAL_FUNCTION_PARAM_PASSTHRU, &(i_obj->context)); } @@ -6470,7 +6603,7 @@ PHP_METHOD(FastDFS, get_file_info) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_get_file_info_impl( \ INTERNAL_FUNCTION_PARAM_PASSTHRU, &(i_obj->context), false); } @@ -6484,7 +6617,7 @@ PHP_METHOD(FastDFS, get_file_info1) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_get_file_info_impl( \ INTERNAL_FUNCTION_PARAM_PASSTHRU, &(i_obj->context), true); } @@ -6498,7 +6631,7 @@ PHP_METHOD(FastDFS, send_data) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_send_data_impl( \ INTERNAL_FUNCTION_PARAM_PASSTHRU, &(i_obj->context)); } @@ -6513,7 +6646,7 @@ PHP_METHOD(FastDFS, gen_slave_filename) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_gen_slave_filename_impl( \ INTERNAL_FUNCTION_PARAM_PASSTHRU, &(i_obj->context)); } @@ -6526,13 +6659,16 @@ PHP_METHOD(FastDFS, close) zval *object = getThis(); php_fdfs_t *i_obj; - i_obj = (php_fdfs_t *) zend_object_store_get_object(object TSRMLS_CC); + i_obj = (php_fdfs_t *) fdfs_get_object(object); php_fdfs_close(i_obj TSRMLS_CC); } ZEND_BEGIN_ARG_INFO_EX(arginfo___construct, 0, 0, 0) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo___destruct, 0, 0, 0) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_tracker_get_connection, 0, 0, 0) ZEND_END_ARG_INFO() @@ -7033,6 +7169,7 @@ ZEND_END_ARG_INFO() #define FDFS_ME(name, args) PHP_ME(FastDFS, name, args, ZEND_ACC_PUBLIC) static zend_function_entry fdfs_class_methods[] = { FDFS_ME(__construct, arginfo___construct) + FDFS_ME(__destruct, arginfo___destruct) FDFS_ME(tracker_get_connection, arginfo_tracker_get_connection) FDFS_ME(tracker_make_all_connections, arginfo_tracker_make_all_connections) FDFS_ME(tracker_close_all_connections,arginfo_tracker_close_all_connections) @@ -7114,6 +7251,7 @@ static void php_fdfs_free_storage(php_fdfs_t *i_obj TSRMLS_DC) php_fdfs_destroy(i_obj TSRMLS_CC); } +#if PHP_MAJOR_VERSION < 7 zend_object_value php_fdfs_new(zend_class_entry *ce TSRMLS_DC) { zend_object_value retval; @@ -7131,6 +7269,20 @@ zend_object_value php_fdfs_new(zend_class_entry *ce TSRMLS_DC) return retval; } +#else + +zend_object* php_fdfs_new(zend_class_entry *ce) +{ + php_fdfs_t *i_obj; + + i_obj = (php_fdfs_t *)ecalloc(1, sizeof(php_fdfs_t)); + + zend_object_std_init(&i_obj->zo, ce TSRMLS_CC); + zend_objects_store_put(&i_obj->zo); + return &i_obj->zo; +} +#endif + PHP_FASTDFS_API zend_class_entry *php_fdfs_get_ce(void) { return fdfs_ce; @@ -7148,15 +7300,19 @@ PHP_FASTDFS_API zend_class_entry *php_fdfs_get_exception_base(int root TSRMLS_DC { if (!spl_ce_RuntimeException) { - zend_class_entry **pce; - zend_class_entry ***ppce; + zend_class_entry *pce; + zval *value; - ppce = &pce; - if (zend_hash_find(CG(class_table), "runtimeexception", - sizeof("RuntimeException"), (void **) ppce) == SUCCESS) + if (fdfs_zend_hash_find(CG(class_table), "runtimeexception", + sizeof("RuntimeException"), &value) == SUCCESS) { - spl_ce_RuntimeException = *pce; - return *pce; + pce = Z_CE_P(value); + spl_ce_RuntimeException = pce; + return pce; + } + else + { + return NULL; } } else @@ -7186,16 +7342,18 @@ static int load_config_files() #define ITEM_NAME_USE_CONN_POOL "fastdfs_client.use_connection_pool" #define ITEM_NAME_CONN_POOL_MAX_IDLE_TIME "fastdfs_client.connection_pool_max_idle_time" - zval conf_c; - zval base_path; - zval connect_timeout; - zval network_timeout; - zval log_level; - zval anti_steal_secret_key; - zval log_filename; - zval conf_filename; - zval use_conn_pool; - zval conn_pool_max_idle_time; + zval zarr[16]; + zval *pz; + zval *conf_c; + zval *base_path; + zval *connect_timeout; + zval *network_timeout; + zval *log_level; + zval *anti_steal_secret_key; + zval *log_filename; + zval *conf_filename; + zval *use_conn_pool; + zval *conn_pool_max_idle_time; char *pAntiStealSecretKey; char szItemName[sizeof(ITEM_NAME_CONF_FILE) + 10]; int nItemLen; @@ -7203,10 +7361,21 @@ static int load_config_files() FDFSConfigInfo *pConfigEnd; int result; - if (zend_get_configuration_directive(ITEM_NAME_CONF_COUNT, + pz = zarr; + conf_c = pz++; + base_path = pz++; + connect_timeout = pz++; + network_timeout = pz++; + log_level = pz++; + anti_steal_secret_key = pz++; + log_filename = pz++; + conf_filename = pz++; + use_conn_pool = pz++; + conn_pool_max_idle_time = pz++; + if (fdfs_zend_get_configuration_directive(ITEM_NAME_CONF_COUNT, sizeof(ITEM_NAME_CONF_COUNT), &conf_c) == SUCCESS) { - config_count = atoi(conf_c.value.str.val); + config_count = atoi(Z_STRVAL_P(conf_c)); if (config_count <= 0) { fprintf(stderr, "file: "__FILE__", line: %d, " \ @@ -7220,7 +7389,7 @@ static int load_config_files() config_count = 1; } - if (zend_get_configuration_directive(ITEM_NAME_BASE_PATH, \ + if (fdfs_zend_get_configuration_directive(ITEM_NAME_BASE_PATH, \ sizeof(ITEM_NAME_BASE_PATH), &base_path) != SUCCESS) { strcpy(g_fdfs_base_path, "/tmp"); @@ -7232,7 +7401,7 @@ static int load_config_files() else { snprintf(g_fdfs_base_path, sizeof(g_fdfs_base_path), "%s", \ - base_path.value.str.val); + Z_STRVAL_P(base_path)); chopPath(g_fdfs_base_path); } @@ -7248,11 +7417,11 @@ static int load_config_files() return ENOTDIR; } - if (zend_get_configuration_directive(ITEM_NAME_CONNECT_TIMEOUT, \ + if (fdfs_zend_get_configuration_directive(ITEM_NAME_CONNECT_TIMEOUT, \ sizeof(ITEM_NAME_CONNECT_TIMEOUT), \ &connect_timeout) == SUCCESS) { - g_fdfs_connect_timeout = atoi(connect_timeout.value.str.val); + g_fdfs_connect_timeout = atoi(Z_STRVAL_P(connect_timeout)); if (g_fdfs_connect_timeout <= 0) { g_fdfs_connect_timeout = DEFAULT_CONNECT_TIMEOUT; @@ -7263,11 +7432,11 @@ static int load_config_files() g_fdfs_connect_timeout = DEFAULT_CONNECT_TIMEOUT; } - if (zend_get_configuration_directive(ITEM_NAME_NETWORK_TIMEOUT, \ + if (fdfs_zend_get_configuration_directive(ITEM_NAME_NETWORK_TIMEOUT, \ sizeof(ITEM_NAME_NETWORK_TIMEOUT), \ &network_timeout) == SUCCESS) { - g_fdfs_network_timeout = atoi(network_timeout.value.str.val); + g_fdfs_network_timeout = atoi(Z_STRVAL_P(network_timeout)); if (g_fdfs_network_timeout <= 0) { g_fdfs_network_timeout = DEFAULT_NETWORK_TIMEOUT; @@ -7278,29 +7447,29 @@ static int load_config_files() g_fdfs_network_timeout = DEFAULT_NETWORK_TIMEOUT; } - if (zend_get_configuration_directive(ITEM_NAME_LOG_LEVEL, \ + if (fdfs_zend_get_configuration_directive(ITEM_NAME_LOG_LEVEL, \ sizeof(ITEM_NAME_LOG_LEVEL), \ &log_level) == SUCCESS) { - set_log_level(log_level.value.str.val); + set_log_level(Z_STRVAL_P(log_level)); } - if (zend_get_configuration_directive(ITEM_NAME_LOG_FILENAME, \ + if (fdfs_zend_get_configuration_directive(ITEM_NAME_LOG_FILENAME, \ sizeof(ITEM_NAME_LOG_FILENAME), \ &log_filename) == SUCCESS) { - if (log_filename.value.str.len > 0) + if (Z_STRLEN_P(log_filename) > 0) { - log_set_filename(log_filename.value.str.val); + log_set_filename(Z_STRVAL_P(log_filename)); } } - if (zend_get_configuration_directive(ITEM_NAME_ANTI_STEAL_SECRET_KEY, \ + if (fdfs_zend_get_configuration_directive(ITEM_NAME_ANTI_STEAL_SECRET_KEY, \ sizeof(ITEM_NAME_ANTI_STEAL_SECRET_KEY), \ &anti_steal_secret_key) == SUCCESS) { - pAntiStealSecretKey = anti_steal_secret_key.value.str.val; + pAntiStealSecretKey = Z_STRVAL_P(anti_steal_secret_key); } else { @@ -7323,7 +7492,7 @@ static int load_config_files() { nItemLen = sprintf(szItemName, "%s%d", ITEM_NAME_CONF_FILE, \ (int)(pConfigInfo - config_list)); - if (zend_get_configuration_directive(szItemName, \ + if (fdfs_zend_get_configuration_directive(szItemName, \ nItemLen + 1, &conf_filename) != SUCCESS) { if (pConfigInfo != config_list) @@ -7335,7 +7504,7 @@ static int load_config_files() return ENOENT; } - if (zend_get_configuration_directive( \ + if (fdfs_zend_get_configuration_directive( \ ITEM_NAME_CONF_FILE, \ sizeof(ITEM_NAME_CONF_FILE), \ &conf_filename) != SUCCESS) @@ -7366,31 +7535,31 @@ static int load_config_files() } if ((result=fdfs_load_tracker_group(pConfigInfo->pTrackerGroup, - conf_filename.value.str.val)) != 0) + Z_STRVAL_P(conf_filename))) != 0) { return result; } } - if (zend_get_configuration_directive(ITEM_NAME_USE_CONN_POOL, + if (fdfs_zend_get_configuration_directive(ITEM_NAME_USE_CONN_POOL, sizeof(ITEM_NAME_USE_CONN_POOL), &use_conn_pool) == SUCCESS) { char *use_conn_pool_str; - use_conn_pool_str = use_conn_pool.value.str.val; + use_conn_pool_str = Z_STRVAL_P(use_conn_pool); if (strcasecmp(use_conn_pool_str, "yes") == 0 || strcasecmp(use_conn_pool_str, "on") == 0 || strcasecmp(use_conn_pool_str, "true") == 0 || strcmp(use_conn_pool_str, "1") == 0) { - if (zend_get_configuration_directive( \ + if (fdfs_zend_get_configuration_directive( \ ITEM_NAME_CONN_POOL_MAX_IDLE_TIME, \ sizeof(ITEM_NAME_CONN_POOL_MAX_IDLE_TIME), \ &conn_pool_max_idle_time) == SUCCESS) { g_connection_pool_max_idle_time = \ - atoi(conn_pool_max_idle_time.value.str.val); + atoi(Z_STRVAL_P(conn_pool_max_idle_time)); if (g_connection_pool_max_idle_time <= 0) { logError("file: "__FILE__", line: %d, " \ @@ -7440,7 +7609,7 @@ PHP_MINIT_FUNCTION(fastdfs_client) return FAILURE; } - le_fdht = zend_register_list_destructors_ex(NULL, php_fdfs_dtor, \ + le_fdfs = zend_register_list_destructors_ex(NULL, php_fdfs_dtor, \ "FastDFS", module_number); INIT_CLASS_ENTRY(ce, "FastDFS", fdfs_class_methods); @@ -7448,8 +7617,13 @@ PHP_MINIT_FUNCTION(fastdfs_client) fdfs_ce->create_object = php_fdfs_new; INIT_CLASS_ENTRY(ce, "FastDFSException", NULL); +#if PHP_MAJOR_VERSION < 7 fdfs_exception_ce = zend_register_internal_class_ex(&ce, \ php_fdfs_get_exception_base(0 TSRMLS_CC), NULL TSRMLS_CC); +#else + fdfs_exception_ce = zend_register_internal_class_ex(&ce, \ + php_fdfs_get_exception_base(0 TSRMLS_CC)); +#endif REGISTER_STRING_CONSTANT("FDFS_FILE_ID_SEPERATOR", \ FDFS_FILE_ID_SEPERATE_STR, \