本文整理汇总了C++中zend_hash_str_find函数的典型用法代码示例。如果您正苦于以下问题:C++ zend_hash_str_find函数的具体用法?C++ zend_hash_str_find怎么用?C++ zend_hash_str_find使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了zend_hash_str_find函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: binary_serialize_spec
static
void binary_serialize_spec(zval* zthis, PHPOutputTransport& transport, HashTable* spec) {
HashPosition key_ptr;
zval* val_ptr;
for (zend_hash_internal_pointer_reset_ex(spec, &key_ptr);
(val_ptr = zend_hash_get_current_data_ex(spec, &key_ptr)) != nullptr;
zend_hash_move_forward_ex(spec, &key_ptr)) {
zend_ulong fieldno;
if (zend_hash_get_current_key_ex(spec, nullptr, &fieldno, &key_ptr) != HASH_KEY_IS_LONG) {
throw_tprotocolexception("Bad keytype in TSPEC (expected 'long')", INVALID_DATA);
return;
}
HashTable* fieldspec = Z_ARRVAL_P(val_ptr);
// field name
val_ptr = zend_hash_str_find(fieldspec, "var", sizeof("var")-1);
char* varname = Z_STRVAL_P(val_ptr);
// thrift type
val_ptr = zend_hash_str_find(fieldspec, "type", sizeof("type")-1);
if (Z_TYPE_P(val_ptr) != IS_LONG) convert_to_long(val_ptr);
int8_t ttype = Z_LVAL_P(val_ptr);
zval rv;
zval* prop = zend_read_property(Z_OBJCE_P(zthis), zthis, varname, strlen(varname), false, &rv);
if (Z_TYPE_P(prop) != IS_NULL) {
transport.writeI8(ttype);
transport.writeI16(fieldno);
binary_serialize(ttype, transport, prop, fieldspec);
}
}
transport.writeI8(T_STOP); // struct end
}
示例2: php_auto_globals_create_server
static zend_bool php_auto_globals_create_server(zend_string *name)
{
if (PG(variables_order) && (strchr(PG(variables_order),'S') || strchr(PG(variables_order),'s'))) {
php_register_server_variables();
if (PG(register_argc_argv)) {
if (SG(request_info).argc) {
zval *argc, *argv;
if ((argc = zend_hash_str_find(&EG(symbol_table), "argc", sizeof("argc")-1)) != NULL &&
(argv = zend_hash_str_find(&EG(symbol_table), "argv", sizeof("argv")-1)) != NULL) {
Z_ADDREF_P(argv);
zend_hash_str_update(Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]), "argv", sizeof("argv")-1, argv);
zend_hash_str_update(Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]), "argc", sizeof("argc")-1, argc);
}
} else {
php_build_argv(SG(request_info).query_string, &PG(http_globals)[TRACK_VARS_SERVER]);
}
}
} else {
zval_ptr_dtor(&PG(http_globals)[TRACK_VARS_SERVER]);
array_init(&PG(http_globals)[TRACK_VARS_SERVER]);
}
zend_hash_update(&EG(symbol_table), name, &PG(http_globals)[TRACK_VARS_SERVER]);
Z_ADDREF(PG(http_globals)[TRACK_VARS_SERVER]);
return 0; /* don't rearm */
}
示例3: yaf_route_simple_assemble
/** {{{ zend_string * yaf_route_simple_assemble(zval *info, zval *query)
*/
zend_string * yaf_route_simple_assemble(yaf_route_t *this_ptr, zval *info, zval *query) {
smart_str tvalue = {0};
zval *nmodule, *ncontroller, *naction;
smart_str_appendc(&tvalue, '?');
nmodule = zend_read_property(yaf_route_simple_ce,
this_ptr, ZEND_STRL(YAF_ROUTE_SIMPLE_VAR_NAME_MODULE), 1, NULL);
ncontroller = zend_read_property(yaf_route_simple_ce,
this_ptr, ZEND_STRL(YAF_ROUTE_SIMPLE_VAR_NAME_CONTROLLER), 1, NULL);
naction = zend_read_property(yaf_route_simple_ce,
this_ptr, ZEND_STRL(YAF_ROUTE_SIMPLE_VAR_NAME_ACTION), 1, NULL);
do {
zval *tmp;
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(info), ZEND_STRL(YAF_ROUTE_ASSEMBLE_MOUDLE_FORMAT))) != NULL) {
smart_str_appendl(&tvalue, Z_STRVAL_P(nmodule), Z_STRLEN_P(nmodule));
smart_str_appendc(&tvalue, '=');
smart_str_appendl(&tvalue, Z_STRVAL_P(tmp), Z_STRLEN_P(tmp));
smart_str_appendc(&tvalue, '&');
}
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(info), ZEND_STRL(YAF_ROUTE_ASSEMBLE_CONTROLLER_FORMAT))) == NULL) {
yaf_trigger_error(YAF_ERR_TYPE_ERROR, "%s", "You need to specify the controller by ':c'");
break;
}
smart_str_appendl(&tvalue, Z_STRVAL_P(ncontroller), Z_STRLEN_P(ncontroller));
smart_str_appendc(&tvalue, '=');
smart_str_appendl(&tvalue, Z_STRVAL_P(tmp), Z_STRLEN_P(tmp));
smart_str_appendc(&tvalue, '&');
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(info), ZEND_STRL(YAF_ROUTE_ASSEMBLE_ACTION_FORMAT))) == NULL) {
yaf_trigger_error(YAF_ERR_TYPE_ERROR, "%s", "You need to specify the action by ':a'");
break;
}
smart_str_appendl(&tvalue, Z_STRVAL_P(naction), Z_STRLEN_P(naction));
smart_str_appendc(&tvalue, '=');
smart_str_appendl(&tvalue, Z_STRVAL_P(tmp), Z_STRLEN_P(tmp));
if (query && IS_ARRAY == Z_TYPE_P(query)) {
zend_string *key;
ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(query), key, tmp) {
if (IS_STRING == Z_TYPE_P(tmp) && key) {
smart_str_appendc(&tvalue, '&');
smart_str_appendl(&tvalue, ZSTR_VAL(key), ZSTR_LEN(key));
smart_str_appendc(&tvalue, '=');
smart_str_appendl(&tvalue, Z_STRVAL_P(tmp), Z_STRLEN_P(tmp));
}
} ZEND_HASH_FOREACH_END();
}
smart_str_0(&tvalue);
return tvalue.s;
} while (0);
示例4: _build_trace_string
static void _build_trace_string(smart_str *str, HashTable *ht, uint32_t num) /* {{{ */
{
zval *file, *tmp;
smart_str_appendc(str, '#');
smart_str_append_long(str, num);
smart_str_appendc(str, ' ');
file = zend_hash_str_find(ht, "file", sizeof("file")-1);
if (file) {
if (Z_TYPE_P(file) != IS_STRING) {
zend_error(E_WARNING, "Function name is no string");
smart_str_appends(str, "[unknown function]");
} else{
zend_long line;
tmp = zend_hash_str_find(ht, "line", sizeof("line")-1);
if (tmp) {
if (Z_TYPE_P(tmp) == IS_LONG) {
line = Z_LVAL_P(tmp);
} else {
zend_error(E_WARNING, "Line is no long");
line = 0;
}
} else {
line = 0;
}
smart_str_append(str, Z_STR_P(file));
smart_str_appendc(str, '(');
smart_str_append_long(str, line);
smart_str_appends(str, "): ");
}
} else {
smart_str_appends(str, "[internal function]: ");
}
TRACE_APPEND_KEY("class");
TRACE_APPEND_KEY("type");
TRACE_APPEND_KEY("function");
smart_str_appendc(str, '(');
tmp = zend_hash_str_find(ht, "args", sizeof("args")-1);
if (tmp) {
if (Z_TYPE_P(tmp) == IS_ARRAY) {
size_t last_len = ZSTR_LEN(str->s);
zval *arg;
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(tmp), arg) {
_build_trace_args(arg, str);
} ZEND_HASH_FOREACH_END();
if (last_len != ZSTR_LEN(str->s)) {
ZSTR_LEN(str->s) -= 2; /* remove last ', ' */
}
} else {
示例5: php_stream_bucket_attach
/* {{{ php_stream_bucket_attach */
static void php_stream_bucket_attach(int append, INTERNAL_FUNCTION_PARAMETERS)
{
zval *zbrigade, *zobject;
zval *pzbucket, *pzdata;
php_stream_bucket_brigade *brigade;
php_stream_bucket *bucket;
ZEND_PARSE_PARAMETERS_START(2, 2)
Z_PARAM_RESOURCE(zbrigade)
Z_PARAM_OBJECT(zobject)
ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
if (NULL == (pzbucket = zend_hash_str_find(Z_OBJPROP_P(zobject), "bucket", sizeof("bucket")-1))) {
php_error_docref(NULL, E_WARNING, "Object has no bucket property");
RETURN_FALSE;
}
if ((brigade = (php_stream_bucket_brigade*)zend_fetch_resource(
Z_RES_P(zbrigade), PHP_STREAM_BRIGADE_RES_NAME, le_bucket_brigade)) == NULL) {
RETURN_FALSE;
}
if ((bucket = (php_stream_bucket *)zend_fetch_resource_ex(pzbucket, PHP_STREAM_BUCKET_RES_NAME, le_bucket)) == NULL) {
RETURN_FALSE;
}
if (NULL != (pzdata = zend_hash_str_find(Z_OBJPROP_P(zobject), "data", sizeof("data")-1)) && Z_TYPE_P(pzdata) == IS_STRING) {
if (!bucket->own_buf) {
bucket = php_stream_bucket_make_writeable(bucket);
}
if (bucket->buflen != Z_STRLEN_P(pzdata)) {
bucket->buf = perealloc(bucket->buf, Z_STRLEN_P(pzdata), bucket->is_persistent);
bucket->buflen = Z_STRLEN_P(pzdata);
}
memcpy(bucket->buf, Z_STRVAL_P(pzdata), bucket->buflen);
}
if (append) {
php_stream_bucket_append(brigade, bucket);
} else {
php_stream_bucket_prepend(brigade, bucket);
}
/* This is a hack necessary to accommodate situations where bucket is appended to the stream
* multiple times. See bug35916.phpt for reference.
*/
if (bucket->refcount == 1) {
bucket->refcount++;
}
}
示例6: 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;
}
示例7: 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;
示例8: ALLOCA_FLAG
ZEND_API zval *zend_get_constant(zend_string *name)
{
zval *zv;
zend_constant *c;
ALLOCA_FLAG(use_heap)
zv = zend_hash_find(EG(zend_constants), name);
if (zv == NULL) {
char *lcname = do_alloca(ZSTR_LEN(name) + 1, use_heap);
zend_str_tolower_copy(lcname, ZSTR_VAL(name), ZSTR_LEN(name));
zv = zend_hash_str_find(EG(zend_constants), lcname, ZSTR_LEN(name));
if (zv != NULL) {
c = Z_PTR_P(zv);
if (c->flags & CONST_CS) {
c = NULL;
}
} else {
c = zend_get_special_constant(ZSTR_VAL(name), ZSTR_LEN(name));
}
free_alloca(lcname, use_heap);
return c ? &c->value : NULL;
} else {
return &((zend_constant*)Z_PTR_P(zv))->value;
}
}
示例9: ALLOCA_FLAG
static inline zend_constant *zend_get_constant_impl(zend_string *name)
{
zval *zv;
zend_constant *c;
ALLOCA_FLAG(use_heap)
zv = zend_hash_find(EG(zend_constants), name);
if (zv == NULL) {
char *lcname = do_alloca(ZSTR_LEN(name) + 1, use_heap);
zend_str_tolower_copy(lcname, ZSTR_VAL(name), ZSTR_LEN(name));
zv = zend_hash_str_find(EG(zend_constants), lcname, ZSTR_LEN(name));
if (zv != NULL) {
c = Z_PTR_P(zv);
if (ZEND_CONSTANT_FLAGS(c) & CONST_CS) {
c = NULL;
}
} else {
c = zend_get_special_constant(ZSTR_VAL(name), ZSTR_LEN(name));
}
free_alloca(lcname, use_heap);
return c;
} else {
return (zend_constant *) Z_PTR_P(zv);
}
}
示例10: internal_get_arr_ele
/* {{{
* Internal function which fetches an element from the passed array for the key_name passed
*/
static int32_t internal_get_arr_ele(IntlDateFormatter_object *dfo,
HashTable* hash_arr, char* key_name, intl_error *err)
{
zval *ele_value = NULL;
int32_t result = 0;
char *message;
if (U_FAILURE(err->code)) {
return result;
}
if ((ele_value = zend_hash_str_find(hash_arr, key_name, strlen(key_name))) != NULL) {
if(Z_TYPE_P(ele_value) != IS_LONG) {
spprintf(&message, 0, "datefmt_format: parameter array contains "
"a non-integer element for key '%s'", key_name);
intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, message, 1);
efree(message);
} else {
if (Z_LVAL_P(ele_value) > INT32_MAX ||
Z_LVAL_P(ele_value) < INT32_MIN) {
spprintf(&message, 0, "datefmt_format: value " ZEND_LONG_FMT " is out of "
"bounds for a 32-bit integer in key '%s'",
Z_LVAL_P(ele_value), key_name);
intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, message, 1);
efree(message);
} else {
result = Z_LVAL_P(ele_value);
}
}
}
return result;
}
示例11: from_zval_write_aggregation
/* Generic Aggregated conversions */
static void from_zval_write_aggregation(const zval *container,
char *structure,
const field_descriptor *descriptors,
ser_context *ctx)
{
const field_descriptor *descr;
zval *elem;
if (Z_TYPE_P(container) != IS_ARRAY) {
do_from_zval_err(ctx, "%s", "expected an array here");
}
for (descr = descriptors; descr->name != NULL && !ctx->err.has_error; descr++) {
if ((elem = zend_hash_str_find(Z_ARRVAL_P(container),
descr->name, descr->name_size - 1)) != NULL) {
if (descr->from_zval == NULL) {
do_from_zval_err(ctx, "No information on how to convert value "
"of key '%s'", descr->name);
break;
}
zend_llist_add_element(&ctx->keys, (void*)&descr->name);
descr->from_zval(elem, ((char*)structure) + descr->field_offset, ctx);
zend_llist_remove_tail(&ctx->keys);
} else if (descr->required) {
do_from_zval_err(ctx, "The key '%s' is required", descr->name);
break;
}
}
}
示例12: PHP_RUNKIT_SANDBOX_PARENT_FETCHBOX
/* {{{ php_runkit_sandbox_parent_read_property
read_property handler */
static zval *php_runkit_sandbox_parent_read_property(zval *object, zval *member, int type
, const zend_literal *key)
{
php_runkit_sandbox_parent_object *objval = PHP_RUNKIT_SANDBOX_PARENT_FETCHBOX(object);
zval tmp_member;
zval retval;
int prop_found = 0;
if (!objval) {
return EG(uninitialized_zval_ptr);
}
if (!objval->self->parent_access || !objval->self->parent_read) {
php_error_docref(NULL, E_WARNING, "Access to read parent's symbol table is disallowed");
return EG(uninitialized_zval_ptr);
}
PHP_RUNKIT_ZVAL_CONVERT_TO_STRING_IF_NEEDED(member, tmp_member);
PHP_RUNKIT_SANDBOX_PARENT_BEGIN(objval)
zval **value;
if ((value = zend_hash_str_find(php_runkit_sandbox_parent_resolve_symbol_table(objval), Z_STRVAL_P(member), Z_STRLEN_P(member) + 1)) != NULL) {
retval = **value;
prop_found = 1;
}
PHP_RUNKIT_SANDBOX_PARENT_END(objval)
if (member == &tmp_member) {
zval_dtor(member);
}
return php_runkit_sandbox_return_property_value(prop_found, &retval);
}
示例13: node_in_hosts_list
/* Check if a node* pointer is in a php array of host pairs
* The hosts array will have been validated at this point, so we don't check bounds
* on any of the individual elements */
static inline bool node_in_hosts_list(const as_node* node, HashTable* hosts_ary) {
zval* z_host_pair = NULL;
char host_buffer[AS_HOSTNAME_SIZE] = {0};
zval* hostname = NULL;
zval* port = NULL;
HashTable* host_pair = NULL;
ZEND_HASH_FOREACH_VAL(hosts_ary, z_host_pair) {
host_pair = Z_ARRVAL_P(z_host_pair);
hostname = zend_hash_str_find(host_pair, "addr", strlen("addr"));
port = zend_hash_str_find(host_pair, "port", strlen("port"));
snprintf(host_buffer, AS_HOSTNAME_SIZE, "%s:%ld", Z_STRVAL_P(hostname), Z_LVAL_P(port));
if (!strcmp(host_buffer, as_node_get_address_string((as_node*)node))) {
return true;
}
}ZEND_HASH_FOREACH_END();
示例14: is_valid_hosts_list
/*
* True if the argument is an array of host entries, else false
* should look like ["hosts"=>[[addr, port]]]
*/
static bool is_valid_hosts_list(HashTable* outer_hosts_ary) {
HashTable* host_pair = NULL;
zval* hostname = NULL;
zval* port = NULL;
zval* z_host_pair = NULL;
HashTable* hosts_ary = NULL;
zval* z_hosts_ary = NULL;
z_hosts_ary = zend_hash_str_find(outer_hosts_ary, "hosts", strlen("hosts"));
if (!z_hosts_ary || Z_TYPE_P(z_hosts_ary) != IS_ARRAY) {
return false;
}
hosts_ary = Z_ARRVAL_P(z_hosts_ary);
/* Each entry should be of the form: ["addr"=> "192.168.1.1", "port"=>4500] *
* return false if one does not match the expected format
*/
ZEND_HASH_FOREACH_VAL(hosts_ary, z_host_pair) {
if (!z_host_pair || Z_TYPE_P(z_host_pair) != IS_ARRAY) {
return false;
}
host_pair = Z_ARRVAL_P(z_host_pair);
if (zend_hash_num_elements(host_pair) != 2) {
return false;
}
hostname = zend_hash_str_find(host_pair, "addr", strlen("addr"));
port = zend_hash_str_find(host_pair, "port", strlen("port"));
if (!hostname || !port) {
return false;
}
if (Z_TYPE_P(hostname) != IS_STRING) {
return false;
}
if (Z_TYPE_P(port) != IS_LONG) {
return false;
}
}ZEND_HASH_FOREACH_END();
return true;
}
示例15: begin_read
ZEND_API zval *zend_ts_hash_str_find(TsHashTable *ht, const char *key, size_t len)
{
zval *retval;
begin_read(ht);
retval = zend_hash_str_find(TS_HASH(ht), key, len);
end_read(ht);
return retval;
}