这篇教程C++ HASH_OF函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中HASH_OF函数的典型用法代码示例。如果您正苦于以下问题:C++ HASH_OF函数的具体用法?C++ HASH_OF怎么用?C++ HASH_OF使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了HASH_OF函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: geojson_linestring_to_arrayint geojson_linestring_to_array(zval *line, geo_array **array){ geo_array *tmp; zval **type, **coordinates; if (Z_TYPE_P(line) != IS_ARRAY) { return 0; } if (zend_hash_find(HASH_OF(line), "type", sizeof("type"), (void**) &type) != SUCCESS) { return 0; } if (Z_TYPE_PP(type) != IS_STRING || strcmp(Z_STRVAL_PP(type), "Linestring") != 0) { return 0; } if (zend_hash_find(HASH_OF(line), "coordinates", sizeof("coordinates"), (void**) &coordinates) != SUCCESS) { return 0; } if (Z_TYPE_PP(coordinates) != IS_ARRAY) { return 0; } tmp = geo_hashtable_to_array(*coordinates); if (tmp && array) { *array = tmp; return 1; } return 0;}
开发者ID:rickogden,项目名称:geospatial,代码行数:30,
示例2: zend_is_auto_global_strstatic char *oauth_provider_get_http_verb() /* {{{ */{ zval *tmp; zend_is_auto_global_str("_SERVER", sizeof("_SERVER")-1); if(Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) != IS_UNDEF) { if((tmp = zend_hash_str_find(HASH_OF(&PG(http_globals)[TRACK_VARS_SERVER]), "REQUEST_METHOD", sizeof("REQUEST_METHOD") - 1)) != NULL || (tmp = zend_hash_str_find(HASH_OF(&PG(http_globals)[TRACK_VARS_SERVER]), "HTTP_METHOD", sizeof("HTTP_METHOD") - 1)) != NULL ) { return Z_STRVAL_P(tmp); } } return NULL;}
开发者ID:keyurdg,项目名称:pecl-web_services-oauth,代码行数:15,
示例3: PHP_METHODstatic PHP_METHOD(midgard_workspace_storage, list_children){ if (zend_parse_parameters_none() == FAILURE) return; guint n_objects; MidgardWorkspaceStorage *self = MIDGARD_WORKSPACE_STORAGE(__php_gobject_ptr(getThis())); MidgardWorkspaceStorage **children = midgard_workspace_storage_list_children(self, &n_objects); array_init(return_value); if (!children) return; const char *g_class_name = G_OBJECT_TYPE_NAME(children[0]); zend_class_entry *ce = zend_fetch_class((char *) g_class_name, strlen(g_class_name), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); int i; for (i = 0; i < n_objects; i++) { zval *zobject; MAKE_STD_ZVAL(zobject); php_midgard_gobject_new_with_gobject(zobject, ce, G_OBJECT(children[i]), TRUE TSRMLS_CC); zend_hash_next_index_insert(HASH_OF(return_value), &zobject, sizeof(zval *), NULL); }}
开发者ID:William-Wai,项目名称:midgard-php5,代码行数:26,
示例4: real_php_log_bufferstatic int real_php_log_buffer(zval *msg_buffer, char *opt, int opt_len TSRMLS_DC){ php_stream *stream = NULL; HashTable *ht;#if PHP_VERSION_ID >= 70000 zend_ulong num_key; zend_string *str_key; zval *entry;#else zval **log;#endif stream = process_stream(opt,opt_len TSRMLS_CC); if (stream == NULL) { return FAILURE; }#if PHP_VERSION_ID >= 70000 ht = HASH_OF(msg_buffer); ZEND_HASH_FOREACH_KEY_VAL(ht, num_key, str_key, entry) { zend_string *s = zval_get_string(entry); php_stream_write(stream, ZSTR_VAL(s), ZSTR_LEN(s)); zend_string_release(s); }
开发者ID:SeasX,项目名称:SeasLog,代码行数:29,
示例5: append_multiple_key_values/* {{{ append_multiple_key_values* Internal function which is called from locale_compose* gets the multiple values for the key_name and appends to the loc_name* used for 'variant','extlang','private'* returns 1 if successful , -1 if not found ,* 0 if array element is not a string , -2 if buffer-overflow*/static int append_multiple_key_values(smart_str* loc_name, HashTable* hash_arr, char* key_name){ zval *ele_value; int i = 0; int isFirstSubtag = 0; int max_value = 0; /* Variant/ Extlang/Private etc. */ if ((ele_value = zend_hash_str_find( hash_arr , key_name , strlen(key_name))) != NULL) { if( Z_TYPE_P(ele_value) == IS_STRING ){ add_prefix( loc_name , key_name); smart_str_appendl(loc_name, SEPARATOR , sizeof(SEPARATOR)-1); smart_str_appendl(loc_name, Z_STRVAL_P(ele_value) , Z_STRLEN_P(ele_value)); return SUCCESS; } else if(Z_TYPE_P(ele_value) == IS_ARRAY ) { HashTable *arr = HASH_OF(ele_value); zval *data; ZEND_HASH_FOREACH_VAL(arr, data) { if(Z_TYPE_P(data) != IS_STRING) { return FAILURE; } if (isFirstSubtag++ == 0){ add_prefix(loc_name , key_name); } smart_str_appendl(loc_name, SEPARATOR , sizeof(SEPARATOR)-1); smart_str_appendl(loc_name, Z_STRVAL_P(data) , Z_STRLEN_P(data)); } ZEND_HASH_FOREACH_END(); return SUCCESS; } else { return FAILURE;
开发者ID:0xhacking,项目名称:php-src,代码行数:39,
示例6: pip_sequence_to_hash/* {{{ pip_sequence_to_hash(PyObject *seq) * Convert a Python sequence to a PHP hash */zval *pip_sequence_to_hash(PyObject *seq){ zval *hash, *val; PyObject *item; int i = 0; /* Make sure this object implements the sequence protocol */ if (!PySequence_Check(seq)) { return NULL; } /* Initialize our PHP array */ MAKE_STD_ZVAL(hash); if (array_init(hash) != SUCCESS) { return NULL; } /* Iterate over the items in the sequence */ while (item = PySequence_GetItem(seq, i++)) { val = pip_pyobject_to_zval(item); if (zend_hash_next_index_insert(HASH_OF(hash), (void *)&val, sizeof(zval *), NULL) == FAILURE) { php_error(E_ERROR, "Python: Array conversion error"); } Py_DECREF(item); } return hash;}
开发者ID:demos,项目名称:Motif,代码行数:33,
示例7: geojson_point_to_lon_latint geojson_point_to_lon_lat(zval *point, double *lon, double *lat){ zval **type, **coordinates; if (zend_hash_find(HASH_OF(point), "type", sizeof("type"), (void**) &type) != SUCCESS) { return 0; } if (Z_TYPE_PP(type) != IS_STRING || strcmp(Z_STRVAL_PP(type), "Point") != 0) { return 0; } if (zend_hash_find(HASH_OF(point), "coordinates", sizeof("coordinates"), (void**) &coordinates) != SUCCESS) { return 0; } if (Z_TYPE_PP(coordinates) != IS_ARRAY) { return 0; } return parse_point_pair(*coordinates, lon, lat);}
开发者ID:rickogden,项目名称:geospatial,代码行数:19,
示例8: pip_mapping_to_hash/* {{{ pip_mapping_to_hash(PyObject *map) Convert a Python mapping to a PHP hash */zval *pip_mapping_to_hash(PyObject *map){ zval *hash, *val; PyObject *keys, *key, *item; char *key_name; int i, key_len; if (!PyMapping_Check(map)) { return NULL; } /* Initialize our PHP array */ MAKE_STD_ZVAL(hash); if (array_init(hash) != SUCCESS) { return NULL; } /* Retrieve the list of keys for this mapping */ keys = PyMapping_Keys(map); if (keys == NULL) { return hash; } /* Iterate over the list of keys */ for (i = 0; i < PySequence_Size(keys); i++) { key = PySequence_GetItem(keys, i); if (key) { /* Get the string representation of the key */ if (pip_str(key, &key_name, &key_len) != -1) { /* Extract the item for this key */ item = PyMapping_GetItemString(map, key_name); if (item) { val = pip_pyobject_to_zval(item); /* Add the new item to the associative array */ if (zend_hash_update(HASH_OF(hash), key_name, key_len, (void *)&val, sizeof(zval *), NULL) == FAILURE) { php_error(E_ERROR, "Python: Array conversion error"); } Py_DECREF(item); } else { php_error(E_ERROR, "Python: Could not get item for key"); } } else { php_error(E_ERROR, "Python: Mapping key conversion error"); } Py_DECREF(key); } } Py_DECREF(keys); return hash;}
开发者ID:demos,项目名称:Motif,代码行数:57,
示例9: _php_array_to_envp/* {{{ _php_array_to_envp */static php_process_env_t _php_array_to_envp(zval *environment, int is_persistent TSRMLS_DC){ zval *element; php_process_env_t env; zend_string *string_key;#ifndef PHP_WIN32 char **ep;#endif char *p; uint cnt, l, sizeenv=0; HashTable *target_hash; memset(&env, 0, sizeof(env)); if (!environment) { return env; } cnt = zend_hash_num_elements(Z_ARRVAL_P(environment)); if (cnt < 1) {#ifndef PHP_WIN32 env.envarray = (char **) pecalloc(1, sizeof(char *), is_persistent);#endif env.envp = (char *) pecalloc(4, 1, is_persistent); return env; } target_hash = HASH_OF(environment); if (!target_hash) { return env; } /* first, we have to get the size of all the elements in the hash */ ZEND_HASH_FOREACH_STR_KEY_VAL(target_hash, string_key, element) { zend_string *str = zval_get_string(element); uint el_len = str->len; STR_RELEASE(str); if (el_len == 0) { continue; } sizeenv += el_len + 1; if (string_key) { if (string_key->len == 0) { continue; } sizeenv += string_key->len + 1; } } ZEND_HASH_FOREACH_END();
开发者ID:SiebelsTim,项目名称:php-src,代码行数:53,
示例10: SWIG_ZTS_SetPointerZvalstatic voidSWIG_ZTS_SetPointerZval(zval *z, void *ptr, swig_type_info *type, int newobject TSRMLS_DC) { swig_object_wrapper *value=NULL; /* * First test for Null pointers. Return those as PHP native NULL */ if (!ptr ) { ZVAL_NULL(z); return; } if (type->clientdata) { if (! (*(int *)(type->clientdata))) zend_error(E_ERROR, "Type: %s failed to register with zend",type->name); value=(swig_object_wrapper *)emalloc(sizeof(swig_object_wrapper)); value->ptr=ptr; value->newobject=newobject; if (newobject <= 1) { /* Just register the pointer as a resource. */ ZEND_REGISTER_RESOURCE(z, value, *(int *)(type->clientdata)); } else { /* * Wrap the resource in an object, the resource will be accessible * via the "_cPtr" member. This is currently only used by * directorin typemaps. */ value->newobject = 0; zval *resource; MAKE_STD_ZVAL(resource); ZEND_REGISTER_RESOURCE(resource, value, *(int *)(type->clientdata)); zend_class_entry **ce = NULL; zval *classname; MAKE_STD_ZVAL(classname); /* _p_Foo -> Foo */ ZVAL_STRING(classname, (char*)type->name+3, 1); /* class names are stored in lowercase */ php_strtolower(Z_STRVAL_PP(&classname), Z_STRLEN_PP(&classname)); if (zend_lookup_class(Z_STRVAL_P(classname), Z_STRLEN_P(classname), &ce TSRMLS_CC) != SUCCESS) { /* class does not exist */ object_init(z); } else { object_init_ex(z, *ce); } Z_SET_REFCOUNT_P(z, 1); Z_SET_ISREF_P(z); zend_hash_update(HASH_OF(z), (char*)"_cPtr", sizeof("_cPtr"), (void*)&resource, sizeof(zval), NULL); FREE_ZVAL(classname); } return; } zend_error(E_ERROR, "Type: %s not registered with zend",type->name);}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:51,
示例11: PHP_METHOD/** * Construct an instance of the Channel class. If the $args array contains a * "credentials" key mapping to a ChannelCredentials object, a secure channel * will be created with those credentials. * @param string $target The hostname to associate with this channel * @param array $args The arguments to pass to the Channel (optional) */PHP_METHOD(Channel, __construct) { wrapped_grpc_channel *channel = Z_WRAPPED_GRPC_CHANNEL_P(getThis()); zend_string *target; zval *args_array = NULL; grpc_channel_args args; HashTable *array_hash; zval *creds_obj = NULL; wrapped_grpc_channel_credentials *creds = NULL; /* "Sa" == 1 string, 1 array */#ifndef FAST_ZPP if (zend_parse_parameters(ZEND_NUM_ARGS(), "Sa", &target, &args_array) == FAILURE) { zend_throw_exception(spl_ce_InvalidArgumentException, "Channel expects a string and an array", 1); return; }#else ZEND_PARSE_PARAMETERS_START(2, 2) Z_PARAM_STR(target) Z_PARAM_ARRAY(args_array) ZEND_PARSE_PARAMETERS_END();#endif array_hash = HASH_OF(args_array); if ((creds_obj = zend_hash_str_find(array_hash, "credentials", sizeof("credentials") - 1)) != NULL) { if (Z_TYPE_P(creds_obj) == IS_NULL) { creds = NULL; zend_hash_str_del(array_hash, "credentials", sizeof("credentials") - 1); } else if (Z_OBJ_P(creds_obj)->ce != grpc_ce_channel_credentials) { zend_throw_exception(spl_ce_InvalidArgumentException, "credentials must be a ChannelCredentials object", 1); return; } else { creds = Z_WRAPPED_GRPC_CHANNEL_CREDS_P(creds_obj); zend_hash_str_del(array_hash, "credentials", sizeof("credentials") - 1); } } php_grpc_read_args_array(args_array, &args); if (creds == NULL) { channel->wrapped = grpc_insecure_channel_create(ZSTR_VAL(target), &args, NULL); } else { channel->wrapped = grpc_secure_channel_create(creds->wrapped, ZSTR_VAL(target), &args, NULL); } efree(args.args);}
开发者ID:stanley-cheung,项目名称:grpc-php7,代码行数:58,
示例12: php_grpc_read_args_arrayvoid php_grpc_read_args_array(zval *args_array, grpc_channel_args *args) { HashTable *array_hash; //HashPosition array_pointer; int args_index; zval *data; zend_string *key; //zend_ulong index; array_hash = HASH_OF(args_array); if (!array_hash) { zend_throw_exception(spl_ce_InvalidArgumentException, "array_hash is NULL", 1); return; } args->num_args = zend_hash_num_elements(array_hash); args->args = ecalloc(args->num_args, sizeof(grpc_arg)); args_index = 0; ZEND_HASH_FOREACH_STR_KEY_VAL(array_hash, key, data) { /*for (zend_hash_internal_pointer_reset_ex(array_hash, &array_pointer); (data = zend_hash_get_current_data_ex(array_hash, &array_pointer)) != NULL; zend_hash_move_forward_ex(array_hash, &array_pointer)) { if (zend_hash_get_current_key_ex(array_hash, &key, &index, &array_pointer) != HASH_KEY_IS_STRING) { zend_throw_exception(spl_ce_InvalidArgumentException, "args keys must be strings", 1); return; }*/ if (key == NULL) { zend_throw_exception(spl_ce_InvalidArgumentException, "args keys must be strings", 1); } args->args[args_index].key = ZSTR_VAL(key); switch (Z_TYPE_P(data)) { case IS_LONG: args->args[args_index].value.integer = (int)Z_LVAL_P(data); args->args[args_index].type = GRPC_ARG_INTEGER; break; case IS_STRING: args->args[args_index].value.string = Z_STRVAL_P(data); args->args[args_index].type = GRPC_ARG_STRING; break; default: zend_throw_exception(spl_ce_InvalidArgumentException, "args values must be int or string", 1); return; } args_index++; } ZEND_HASH_FOREACH_END();}
开发者ID:stanley-cheung,项目名称:grpc-php7,代码行数:49,
示例13: dom_nodelist_length_read/* {{{ length intreadonly=yesURL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-203510337Since:*/int dom_nodelist_length_read(dom_object *obj, zval *retval){ dom_nnodemap_object *objmap; xmlNodePtr nodep, curnode; int count = 0; HashTable *nodeht; objmap = (dom_nnodemap_object *)obj->ptr; if (objmap != NULL) { if (objmap->ht) { count = xmlHashSize(objmap->ht); } else { if (objmap->nodetype == DOM_NODESET) { nodeht = HASH_OF(&objmap->baseobj_zv); count = zend_hash_num_elements(nodeht); } else { nodep = dom_object_get_node(objmap->baseobj); if (nodep) { if (objmap->nodetype == XML_ATTRIBUTE_NODE || objmap->nodetype == XML_ELEMENT_NODE) { curnode = nodep->children; if (curnode) { count++; while (curnode->next != NULL) { count++; curnode = curnode->next; } } } else { if (nodep->type == XML_DOCUMENT_NODE || nodep->type == XML_HTML_DOCUMENT_NODE) { nodep = xmlDocGetRootElement((xmlDoc *) nodep); } else { nodep = nodep->children; } curnode = dom_get_elements_by_tag_name_ns_raw( nodep, (char *) objmap->ns, (char *) objmap->local, &count, -1); } } } } } ZVAL_LONG(retval, count); return SUCCESS;}
开发者ID:0xhacking,项目名称:php-src,代码行数:49,
示例14: switchphp_http_url_t *php_http_url_from_zval(zval *value, unsigned flags TSRMLS_DC){ zval *zcpy; php_http_url_t *purl; switch (Z_TYPE_P(value)) { case IS_ARRAY: case IS_OBJECT: purl = php_http_url_from_struct(HASH_OF(value)); break; default: zcpy = php_http_ztyp(IS_STRING, value); purl = php_http_url_parse(Z_STRVAL_P(zcpy), Z_STRLEN_P(zcpy), flags TSRMLS_CC); zval_ptr_dtor(&zcpy); } return purl;}
开发者ID:datasift,项目名称:ext-http,代码行数:19,
示例15: php_mail_build_headers_elemsstatic void php_mail_build_headers_elems(smart_str *s, zend_string *key, zval *val){ zend_ulong idx; zend_string *tmp_key; zval *tmp_val; (void)(idx); ZEND_HASH_FOREACH_KEY_VAL(HASH_OF(val), idx, tmp_key, tmp_val) { if (tmp_key) { php_error_docref(NULL, E_WARNING, "Multiple header key must be numeric index (%s)", ZSTR_VAL(tmp_key)); continue; } if (Z_TYPE_P(tmp_val) != IS_STRING) { php_error_docref(NULL, E_WARNING, "Multiple header values must be string (%s)", ZSTR_VAL(key)); continue; } php_mail_build_headers_elem(s, key, tmp_val); } ZEND_HASH_FOREACH_END();}
开发者ID:LTD-Beget,项目名称:php-src,代码行数:19,
示例16: ZEND_METHODZEND_METHOD( alinq_class , getArrayItem ){ zval *data_array; zval *copy_array; char *name; int name_len; zval **fooval; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "as",&data_array, &name, &name_len) == FAILURE) { RETURN_NULL(); } if(zend_hash_find(HASH_OF(data_array),name,name_len,(void**)&fooval) == SUCCESS ){ RETVAL_ZVAL(*fooval, 1, 0); }else{ RETVAL_STRING("index_not_found", 1); } return;}
开发者ID:wosiwo,项目名称:clinq,代码行数:19,
示例17: PHP_METHODstatic PHP_METHOD(midgard_query_builder, execute){ RETVAL_FALSE; MidgardConnection *mgd = mgd_handle(TSRMLS_C); CHECK_MGD(mgd); if (zend_parse_parameters_none() == FAILURE) return; _GET_BUILDER_OBJECT; zend_class_entry *ce = php_gobject->user_ce; if (ce == NULL) { php_error(E_WARNING, "Query Builder instance not associated with any class"); return; } guint i, n_objects; GObject **objects = midgard_query_builder_execute(builder, &n_objects); array_init(return_value); if (!objects) return; /* TODO: Should use iterator, instead, and create objects lazily */ /* Initialize zend objects for the same class which was used to initialize Query Builder */ for (i = 0; i < n_objects; i++) { GObject *gobject = objects[i]; zval *zobject; /* TODO: Simplify code below. If possible. */ MAKE_STD_ZVAL(zobject); object_init_ex(zobject, ce); /* Initialize new object for which QB has been created for */ MGD_PHP_SET_GOBJECT(zobject, gobject); // inject our gobject zend_call_method_with_0_params(&zobject, ce, &ce->constructor, "__construct", NULL); /* Call class constructor on given instance */ zend_hash_next_index_insert(HASH_OF(return_value), &zobject, sizeof(zval *), NULL); } if (objects) g_free(objects);}
开发者ID:indeyets,项目名称:midgard-php5,代码行数:43,
示例18: PHP_METHOD/** * Returns a list of all the events associated with the EventLoop. * * NOTE: In the case of the default event loop, only events which have * been added using php-libev will be returned as the others are * managed by others. * * @return array */PHP_METHOD(EventLoop, getEvents){ event_loop_object *obj = (event_loop_object *)zend_object_store_get_object(getThis() TSRMLS_CC); array_init(return_value); event_object *ev = obj->events; while(ev) { assert(ev->this); zval_add_ref(&ev->this); zend_hash_next_index_insert(HASH_OF(return_value), (void *)&ev->this, sizeof(zval *), NULL); ev = ev->next; } return;}
开发者ID:WordpressDev,项目名称:php-libev,代码行数:29,
示例19: parse_point_pairstatic int parse_point_pair(zval *coordinates, double *lon, double *lat){ HashTable *coords; zval **z_lon, **z_lat; coords = HASH_OF(coordinates); if (coords->nNumOfElements != 2) { return 0; } if (zend_hash_index_find(coords, 0, (void**) &z_lon) != SUCCESS) { return 0; } if (zend_hash_index_find(coords, 1, (void**) &z_lat) != SUCCESS) { return 0; } convert_to_double_ex(z_lon); convert_to_double_ex(z_lat); *lon = Z_DVAL_PP(z_lon); *lat = Z_DVAL_PP(z_lat); return 1;}
开发者ID:rickogden,项目名称:geospatial,代码行数:21,
示例20: PHP_METHODstatic PHP_METHOD(midgard_query_builder, execute){ RETVAL_FALSE; MidgardConnection *mgd = mgd_handle(TSRMLS_C); CHECK_MGD(mgd); if (zend_parse_parameters_none() == FAILURE) return; _GET_BUILDER_OBJECT; zend_class_entry *ce = php_gobject->user_ce; if (ce == NULL) { php_error(E_WARNING, "Query Builder instance not associated with any class"); return; } guint i, n_objects; GObject **objects = midgard_query_builder_execute(builder, &n_objects); array_init(return_value); if (!objects) return; /* TODO: Should use iterator, instead, and create objects lazily */ for (i = 0; i < n_objects; i++) { GObject *gobject = objects[i]; zval *zobject; MAKE_STD_ZVAL(zobject); php_midgard_gobject_new_with_gobject(zobject, ce, gobject, TRUE TSRMLS_CC); zend_hash_next_index_insert(HASH_OF(return_value), &zobject, sizeof(zval *), NULL); } if (objects) g_free(objects);}
开发者ID:William-Wai,项目名称:midgard-php5,代码行数:40,
示例21: json_determine_array_typestatic int json_determine_array_type(zval *val) /* {{{ */{ int i; HashTable *myht = HASH_OF(val); i = myht ? zend_hash_num_elements(myht) : 0; if (i > 0) { zend_string *key; zend_ulong index, idx; idx = 0; ZEND_HASH_FOREACH_KEY(myht, index, key) { if (key) { return PHP_JSON_OUTPUT_OBJECT; } else { if (index != idx) { return PHP_JSON_OUTPUT_OBJECT; } } idx++; } ZEND_HASH_FOREACH_END(); }
开发者ID:ahamid,项目名称:php-src,代码行数:22,
示例22: grpc_parse_metadata_array/* Creates and returns a PHP array object with the data in a * grpc_metadata_array. Returns NULL on failure */void grpc_parse_metadata_array(grpc_metadata_array *metadata_array, zval *array) { int count = metadata_array->count; grpc_metadata *elements = metadata_array->metadata; int i; zval *data; HashTable *array_hash; zval inner_array; char *str_key; char *str_val; size_t key_len; array_init(array); array_hash = HASH_OF(array); grpc_metadata *elem; for (i = 0; i < count; i++) { elem = &elements[i]; key_len = strlen(elem->key); str_key = ecalloc(key_len + 1, sizeof(char)); memcpy(str_key, elem->key, key_len); str_val = ecalloc(elem->value_length + 1, sizeof(char)); memcpy(str_val, elem->value, elem->value_length); if ((data = zend_hash_str_find(array_hash, str_key, key_len)) != NULL) { if (Z_TYPE_P(data) != IS_ARRAY) { zend_throw_exception(zend_exception_get_default(), "Metadata hash somehow contains wrong types.", 1); efree(str_key); efree(str_val); return; } add_next_index_stringl(data, str_val, elem->value_length); } else { array_init(&inner_array); add_next_index_stringl(&inner_array, str_val, elem->value_length); add_assoc_zval(array, str_key, &inner_array); } } return;}
开发者ID:sunzhijie,项目名称:grpc-php7,代码行数:41,
示例23: array/* {{{ xslt_make_array() Make an XSLT array (char **) from a zval array (HashTable *) */extern void xslt_make_array(zval **zarr, char ***carr){ zval **current; HashTable *arr; int idx = 0; arr = HASH_OF(*zarr); if (! arr) { php_error(E_WARNING, "Invalid argument or parameter array to %s", get_active_function_name()); return; } *carr = emalloc((zend_hash_num_elements(arr) * 2) + 1); for (zend_hash_internal_pointer_reset(arr); zend_hash_get_current_data(arr, (void **) ¤t) == SUCCESS; zend_hash_move_forward(arr)) { char *string_key = NULL; ulong num_key; int type; SEPARATE_ZVAL(current); convert_to_string_ex(current); type = zend_hash_get_current_key(arr, &string_key, &num_key, 0); if (type == HASH_KEY_IS_LONG) { php_error(E_WARNING, "Invalid argument or parameter array to %s", get_active_function_name()); return; } (*carr)[idx++] = estrdup(string_key); (*carr)[idx++] = estrndup(Z_STRVAL_PP(current), Z_STRLEN_PP(current)); } (*carr)[idx] = NULL;}
开发者ID:jehurodrig,项目名称:PHP-4.0.6-16-07-2009,代码行数:40,
示例24: PHP_METHODstatic PHP_METHOD(php_midgard_reflection_class, listSignals){ if (zend_parse_parameters_none() == FAILURE) { return; } _GET_RC_CE; if (ce == NULL) return; array_init(return_value); GType classtype = g_type_from_name(php_class_name_to_g_class_name(ce->name)); if (!classtype) { return; } guint n_ids = 0; guint *ids = g_signal_list_ids(classtype, &n_ids); if (ids == NULL) { return; } size_t i; for (i = 0; i < n_ids; i++) { zval *signalname; MAKE_STD_ZVAL(signalname); ZVAL_STRING(signalname, (char *) g_signal_name(ids[i]), 1); zend_hash_next_index_insert(HASH_OF(return_value), &signalname, sizeof(zval *), NULL); } g_free(ids);}
开发者ID:William-Wai,项目名称:midgard-php5,代码行数:38,
示例25: msgpack_convert_string_to_propertiesinline int msgpack_convert_string_to_properties( zval *object, char *key, uint key_len, zval *val, HashTable *var){ zval **data = NULL; HashTable *ht; zend_class_entry *ce; char *prot_name, *priv_name; int prop_name_len; TSRMLS_FETCH(); ht = HASH_OF(object); ce = zend_get_class_entry(object TSRMLS_CC); /* private */ zend_mangle_property_name( &priv_name, &prop_name_len, ce->name, ce->name_length, key, key_len, 1); if (zend_hash_find( ht, priv_name, prop_name_len, (void **)&data) == SUCCESS) { MSGPACK_CONVERT_UPDATE_PROPERTY(ht, priv_name, prop_name_len, val, var); } /* protected */ zend_mangle_property_name( &prot_name, &prop_name_len, "*", 1, key, key_len, 1); if (zend_hash_find( ht, prot_name, prop_name_len, (void **)&data) == SUCCESS) { MSGPACK_CONVERT_UPDATE_PROPERTY(ht, prot_name, prop_name_len, val, var); } /* public */ MSGPACK_CONVERT_UPDATE_PROPERTY(ht, key, key_len, val, var); return FAILURE;}
开发者ID:LoosKonstantin,项目名称:msgpack,代码行数:36,
示例26: _php_array_to_envp/* {{{ _php_array_to_envp */static php_process_env_t _php_array_to_envp(zval *environment, int is_persistent TSRMLS_DC){ zval **element; php_process_env_t env; char *string_key, *data;#ifndef PHP_WIN32 char **ep;#endif char *p; uint string_length, cnt, l, sizeenv=0, el_len; ulong num_key; HashTable *target_hash; HashPosition pos; memset(&env, 0, sizeof(env)); if (!environment) { return env; } cnt = zend_hash_num_elements(Z_ARRVAL_P(environment)); if (cnt < 1) {#ifndef PHP_WIN32 env.envarray = (char **) pecalloc(1, sizeof(char *), is_persistent);#endif env.envp = (char *) pecalloc(4, 1, is_persistent); return env; } target_hash = HASH_OF(environment); if (!target_hash) { return env; } /* first, we have to get the size of all the elements in the hash */ for (zend_hash_internal_pointer_reset_ex(target_hash, &pos); zend_hash_get_current_data_ex(target_hash, (void **) &element, &pos) == SUCCESS; zend_hash_move_forward_ex(target_hash, &pos)) { if (Z_TYPE_PP(element) != IS_STRING) { zval tmp; MAKE_COPY_ZVAL(element, &tmp); convert_to_string(&tmp); el_len = Z_STRLEN(tmp); zval_dtor(&tmp); } else { el_len = Z_STRLEN_PP(element); } if (el_len == 0) { continue; } sizeenv += el_len+1; switch (zend_hash_get_current_key_ex(target_hash, &string_key, &string_length, &num_key, 0, &pos)) { case HASH_KEY_IS_STRING: if (string_length == 0) { continue; } sizeenv += string_length; break; } }#ifndef PHP_WIN32 ep = env.envarray = (char **) pecalloc(cnt + 1, sizeof(char *), is_persistent);#endif p = env.envp = (char *) pecalloc(sizeenv + 4, 1, is_persistent); for (zend_hash_internal_pointer_reset_ex(target_hash, &pos); zend_hash_get_current_data_ex(target_hash, (void **) &element, &pos) == SUCCESS; zend_hash_move_forward_ex(target_hash, &pos)) { zval tmp; if (Z_TYPE_PP(element) != IS_STRING) { MAKE_COPY_ZVAL(element, &tmp); convert_to_string(&tmp); } else { tmp = **element; } el_len = Z_STRLEN(tmp); if (el_len == 0) { goto next_element; } data = Z_STRVAL(tmp); switch (zend_hash_get_current_key_ex(target_hash, &string_key, &string_length, &num_key, 0, &pos)) { case HASH_KEY_IS_STRING: if (string_length == 0) { goto next_element; } l = string_length + el_len + 1; memcpy(p, string_key, string_length);//.........这里部分代码省略.........
开发者ID:90youth,项目名称:php-src,代码行数:101,
示例27: PHP_MINFO_FUNCTIONstatic PHP_MINFO_FUNCTION(json){ php_info_print_table_start(); php_info_print_table_row(2, "json support", "enabled"); php_info_print_table_row(2, "json version", PHP_JSON_VERSION); php_info_print_table_row(2, "json remark", "support for non utf8 charset, like 5.3, modify by [email C++ HAS_BIT函数代码示例 C++ HASH_ID函数代码示例
|