static HashTable *zend_closure_get_debug_info(zval *object, int *is_temp) /* {{{ */ { zend_closure *closure = (zend_closure *)Z_OBJ_P(object); zval val; struct _zend_arg_info *arg_info = closure->func.common.arg_info; *is_temp = 0; if (closure->debug_info == NULL) { ALLOC_HASHTABLE(closure->debug_info); zend_hash_init(closure->debug_info, 8, NULL, ZVAL_PTR_DTOR, 0); } if (closure->debug_info->u.v.nApplyCount == 0) { if (closure->func.type == ZEND_USER_FUNCTION && closure->func.op_array.static_variables) { HashTable *static_variables = closure->func.op_array.static_variables; ZVAL_NEW_ARR(&val); zend_array_dup(Z_ARRVAL(val), static_variables); zend_hash_str_update(closure->debug_info, "static", sizeof("static")-1, &val); } if (Z_TYPE(closure->this_ptr) != IS_UNDEF) { Z_ADDREF(closure->this_ptr); zend_hash_str_update(closure->debug_info, "this", sizeof("this")-1, &closure->this_ptr); } if (arg_info) { uint32_t i, num_args, required = closure->func.common.required_num_args; array_init(&val); num_args = closure->func.common.num_args; if (closure->func.common.fn_flags & ZEND_ACC_VARIADIC) { num_args++; } for (i = 0; i < num_args; i++) { zend_string *name; zval info; if (arg_info->name) { name = zend_strpprintf(0, "%s$%s", arg_info->pass_by_reference ? "&" : "", arg_info->name->val); } else { name = zend_strpprintf(0, "%s$param%d", arg_info->pass_by_reference ? "&" : "", i + 1); } ZVAL_NEW_STR(&info, zend_strpprintf(0, "%s", i >= required ? "<optional>" : "<required>")); zend_hash_update(Z_ARRVAL(val), name, &info); zend_string_release(name); arg_info++; } zend_hash_str_update(closure->debug_info, "parameter", sizeof("parameter")-1, &val); } } return closure->debug_info; }
void call_user_watch_callback(int watch_index) { Watch *watch_ret; watch_ret = &FSEVENTS_GLOBAL(watches)[watch_index]; zval *retval = NULL; zval params[1]; zval *event_array; ZVAL_NEW_ARR(retval); ZVAL_NEW_ARR(event_array); array_init(event_array); params[0] = *event_array; watch_ret->fci.params = params; watch_ret->fci.param_count = 1; watch_ret->fci.retval = retval; watch_ret->fci.no_separation = 0; zend_call_function(&watch_ret->fci, NULL TSRMLS_CC); }
static void php_browscap_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_type, void *arg) /* {{{ */ { browser_data *bdata = arg; int persistent = bdata->htab->u.flags & HASH_FLAG_PERSISTENT; if (!arg1) { return; } switch (callback_type) { case ZEND_INI_PARSER_ENTRY: if (Z_TYPE(bdata->current_section) != IS_UNDEF && arg2) { zval new_property; zend_string *new_key; /* parent entry can not be same as current section -> causes infinite loop! */ if (!strcasecmp(Z_STRVAL_P(arg1), "parent") && bdata->current_section_name != NULL && !strcasecmp(bdata->current_section_name, Z_STRVAL_P(arg2)) ) { zend_error(E_CORE_ERROR, "Invalid browscap ini file: " "'Parent' value cannot be same as the section name: %s " "(in file %s)", bdata->current_section_name, INI_STR("browscap")); return; } /* Set proper value for true/false settings */ if ((Z_STRLEN_P(arg2) == 2 && !strncasecmp(Z_STRVAL_P(arg2), "on", sizeof("on") - 1)) || (Z_STRLEN_P(arg2) == 3 && !strncasecmp(Z_STRVAL_P(arg2), "yes", sizeof("yes") - 1)) || (Z_STRLEN_P(arg2) == 4 && !strncasecmp(Z_STRVAL_P(arg2), "true", sizeof("true") - 1)) ) { ZVAL_NEW_STR(&new_property, zend_string_init("1", sizeof("1")-1, persistent)); } else if ( (Z_STRLEN_P(arg2) == 2 && !strncasecmp(Z_STRVAL_P(arg2), "no", sizeof("no") - 1)) || (Z_STRLEN_P(arg2) == 3 && !strncasecmp(Z_STRVAL_P(arg2), "off", sizeof("off") - 1)) || (Z_STRLEN_P(arg2) == 4 && !strncasecmp(Z_STRVAL_P(arg2), "none", sizeof("none") - 1)) || (Z_STRLEN_P(arg2) == 5 && !strncasecmp(Z_STRVAL_P(arg2), "false", sizeof("false") - 1)) ) { // TODO: USE STR_EMPTY_ALLOC()? ZVAL_NEW_STR(&new_property, zend_string_init("", sizeof("")-1, persistent)); } else { /* Other than true/false setting */ ZVAL_STR(&new_property, zend_string_dup(Z_STR_P(arg2), persistent)); } new_key = zend_string_dup(Z_STR_P(arg1), persistent); zend_str_tolower(new_key->val, new_key->len); zend_hash_update(Z_ARRVAL(bdata->current_section), new_key, &new_property); zend_string_release(new_key); } break; case ZEND_INI_PARSER_SECTION: { zval processed; zval unprocessed; /*printf("'%s' (%d)\n",$1.value.str.val,$1.value.str.len + 1);*/ if (persistent) { ZVAL_NEW_PERSISTENT_ARR(&bdata->current_section); } else { ZVAL_NEW_ARR(&bdata->current_section); } zend_hash_init(Z_ARRVAL(bdata->current_section), 0, NULL, (dtor_func_t) (persistent?browscap_entry_dtor_persistent :browscap_entry_dtor_request), persistent); if (bdata->current_section_name) { pefree(bdata->current_section_name, persistent); } bdata->current_section_name = pestrndup(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1), persistent); zend_hash_update(bdata->htab, Z_STR_P(arg1), &bdata->current_section); ZVAL_STR(&processed, Z_STR_P(arg1)); ZVAL_STR(&unprocessed, zend_string_dup(Z_STR_P(arg1), persistent)); convert_browscap_pattern(&processed, persistent); zend_hash_str_update(Z_ARRVAL(bdata->current_section), "browser_name_regex", sizeof("browser_name_regex")-1, &processed); zend_hash_str_update(Z_ARRVAL(bdata->current_section), "browser_name_pattern", sizeof("browser_name_pattern")-1, &unprocessed); } break; } }