本文整理汇总了C++中HASH_OF函数的典型用法代码示例。如果您正苦于以下问题:C++ HASH_OF函数的具体用法?C++ HASH_OF怎么用?C++ HASH_OF使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了HASH_OF函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: geojson_linestring_to_array
int 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;
}
示例2: zend_is_auto_global_str
static 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;
}
示例3: PHP_METHOD
static 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);
}
}
示例4: real_php_log_buffer
static 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);
}
示例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;
示例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;
}
示例7: geojson_point_to_lon_lat
int 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);
}
示例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;
}
示例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();
示例10: SWIG_ZTS_SetPointerZval
static void
SWIG_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);
}
示例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);
}
示例12: php_grpc_read_args_array
void 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();
}
示例13: dom_nodelist_length_read
/* {{{ length int
readonly=yes
URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-203510337
Since:
*/
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;
}
示例14: switch
php_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;
}
示例15: php_mail_build_headers_elems
static 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();
}