void ngx_http_php_zend_uthread_create(ngx_http_request_t *r, char *func_prefix) { zval *func_main; zval *func_valid; zval retval; ngx_http_php_ctx_t *ctx; ngx_http_php_loc_conf_t *plcf; ngx_str_t func_name; ctx = ngx_http_get_module_ctx(r, ngx_http_php_module); if (ctx == NULL) { return ; } ctx->generator_closure = (zval *)emalloc(sizeof(zval)); plcf = ngx_http_get_module_loc_conf(r, ngx_http_php_module); //func_name.data = ngx_pnalloc(r->pool, strlen(func_prefix)+sizeof("_18446744073709551616")-1+NGX_TIME_T_LEN); //func_name.len = ngx_sprintf(func_name.data, "%s_%V", func_prefix, &(plcf->content_inline_code->code_id)) - func_name.data; func_name.data = ngx_pnalloc(r->pool, strlen(func_prefix) + 32); func_name.len = ngx_sprintf(func_name.data, "%s_%V", func_prefix, &(plcf->content_inline_code->code_id)) - func_name.data; ngx_php_debug("%*s", (int)func_name.len, func_name.data); ZVAL_STRINGL(func_main, (char *)func_name.data, func_name.len, 1); call_user_function(EG(function_table), NULL, func_main, ctx->generator_closure, 0, NULL TSRMLS_CC); zval_ptr_dtor(&func_main); if (Z_TYPE_P(ctx->generator_closure) == IS_OBJECT){ MAKE_STD_ZVAL(func_valid); ZVAL_STRING(&func_valid, "valid", 1); if (call_user_function(NULL, &(ctx->generator_closure), func_valid, &retval, 0, NULL TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed calling valid"); return ; } zval_ptr_dtor(&func_valid); ngx_php_debug("r:%p, closure:%p, retval:%d", r, ctx->generator_closure, Z_TYPE(retval)); if (Z_TYPE(retval) == IS_BOOL && Z_BVAL(retval)){ ctx->phase_status = NGX_AGAIN; }else { ctx->phase_status = NGX_OK; } }else { ngx_php_debug("r:%p, closure:%p, retval:%d", r, ctx->generator_closure, Z_TYPE(retval)); efree(ctx->generator_closure); } }
void riak_stream_key_cb(riack_client* c, void* p, riack_string key) {/* {{{ */ zval *zkey, zret, zfuncname; struct riak_stream_key_cb_param *param = (struct riak_stream_key_cb_param*)p; MAKE_STD_ZVAL(zkey); ZVAL_STRINGL(zkey, key.value, key.len, 1); ZVAL_STRING(&zfuncname, "process", 0); #ifdef ZTS call_user_function(NULL, ¶m->zstreamer, &zfuncname, &zret, 1, &zkey, param->tsrm_ls); #else call_user_function(NULL, ¶m->zstreamer, &zfuncname, &zret, 1, &zkey); #endif zval_ptr_dtor(&zkey); }
/** * Call single static function on a zval which requires parameters */ int phalcon_call_static_zval_func_params(zval *return_value, zval *mixed_name, char *method_name, int method_len, zend_uint param_count, zval *params[], int noreturn TSRMLS_DC){ zval *fn; int status = FAILURE; if (!noreturn) { ALLOC_INIT_ZVAL(return_value); } ALLOC_INIT_ZVAL(fn); array_init(fn); add_next_index_zval(fn, mixed_name); add_next_index_stringl(fn, method_name, method_len, 1); status = call_user_function(CG(function_table), NULL, fn, return_value, param_count, params TSRMLS_CC); if (status == FAILURE) { if(Z_TYPE_P(mixed_name) == IS_STRING) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Call to undefined function %s::%s()", Z_STRVAL_P(mixed_name), method_name); } else { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Call to undefined function not-callable::%s()", method_name); } return FAILURE; } zval_ptr_dtor(&fn); if (!noreturn) { zval_ptr_dtor(&return_value); } return status; }
/** * Call single static function which not requires parameters */ int phalcon_call_static_func(zval *return_value, char *class_name, int class_length, char *method_name, int method_len, int noreturn TSRMLS_DC){ zval *fn; int status = FAILURE; if (!noreturn) { ALLOC_INIT_ZVAL(return_value); } ALLOC_INIT_ZVAL(fn); array_init(fn); add_next_index_stringl(fn, class_name, class_length, 1); add_next_index_stringl(fn, method_name, method_len, 1); status = call_user_function(CG(function_table), NULL, fn, return_value, 0, NULL TSRMLS_CC); if (status == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Call to undefined function %s::%s()", class_name, method_name); return FAILURE; } zval_ptr_dtor(&fn); if (!noreturn) { zval_ptr_dtor(&return_value); } return status; }
static size_t _php_curl_write_header(char *data, size_t size, size_t nmemb, void *ctx) { php_curl *ch = (php_curl *) ctx; zval *func = ch->handlers->write_header; zval *argv[2]; zval *retval; int error; int length; ELS_FETCH(); MAKE_STD_ZVAL(argv[0]); MAKE_STD_ZVAL(argv[1]); MAKE_STD_ZVAL(retval); ZVAL_RESOURCE(argv[0], ch->id); zend_list_addref(ch->id); ZVAL_STRINGL(argv[0], data, size * nmemb, 1); error = call_user_function(EG(function_table), NULL, func, retval, 2, argv); if (error == FAILURE) { php_error(E_WARNING, "Couldn't call the CURLOPT_HEADERFUNCTION"); return -1; } length = Z_LVAL_P(retval); zval_ptr_dtor(&argv[0]); zval_ptr_dtor(&argv[1]); zval_ptr_dtor(&retval); return length; }
/** * Call single static function direct on a zend_class_entry which requires parameters */ int phalcon_call_static_ce_func_params(zval *return_value, zend_class_entry *ce, char *method_name, int method_len, zend_uint param_count, zval *params[], int noreturn TSRMLS_DC){ zval *fn; int status = FAILURE; if (!noreturn) { ALLOC_INIT_ZVAL(return_value); } ALLOC_INIT_ZVAL(fn); array_init(fn); add_next_index_stringl(fn, ce->name, ce->name_length, 0); add_next_index_stringl(fn, method_name, method_len, 0); status = call_user_function(CG(function_table), NULL, fn, return_value, param_count, params TSRMLS_CC); if (status == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Call to undefined function %s::%s()", ce->name, method_name); return FAILURE; } if (!noreturn) { zval_ptr_dtor(&return_value); } return status; }
/* {{{ mlfi_close() */ static sfsistat mlfi_close(SMFICTX *ctx) { int ret = SMFIS_CONTINUE; zval function_name, retval; int status; TSRMLS_FETCH(); /* call userland */ INIT_ZVAL(function_name); ZVAL_STRING(&function_name, "milter_close", 0); /* set the milter context for possible use in API functions */ MG(ctx) = ctx; MG(state) = MLFI_CLOSE; status = call_user_function(CG(function_table), NULL, &function_name, &retval, 0, NULL TSRMLS_CC); MG(state) = MLFI_NONE; if (status == SUCCESS && Z_TYPE(retval) == IS_LONG) { ret = Z_LVAL(retval); } php_request_shutdown((void *) 0); return ret; }
/* {{{ call_xslt_function() Call an XSLT handler */ extern void xslt_call_function(char *name, struct xslt_function *fptr, int argc, zval **argv, zval **retval) { int error; /* Error container */ int idx; /* Idx, when looping through and free'ing the arguments */ ELS_FETCH(); /* For TS mode, fetch the executor globals */ /* Allocate and initialize return value from the function */ MAKE_STD_ZVAL(*retval); /* Call the function */ error = call_user_function(EG(function_table), XSLT_OBJ(fptr), XSLT_FUNC(fptr), *retval, argc, argv); if (error == FAILURE) { php_error(E_WARNING, "Cannot call the %s handler: %s", name, Z_STRVAL_P(XSLT_FUNC(fptr))); } /* Cleanup arguments */ for (idx = 0; idx < argc; idx++) { /* Decrease refcount and free if refcount is <= 0 */ zval_ptr_dtor(&argv[idx]); } }
bool resolveDocument(XmlTransaction *txn, XmlManager &mgr, const std::string &uri, XmlValue &result) { DEBUG(); TSRMLS_FETCH(); bool status = false; zval *argv[2], *retval, *func; MAKE_STD_ZVAL(func); MAKE_STD_ZVAL(retval); MAKE_STD_ZVAL(argv[0]); MAKE_STD_ZVAL(argv[1]); ZVAL_STRING(func, "resolveDocument", (int)1); ZVAL_STRINGL(argv[0], (char*)uri.data(), (int)uri.length(), 1); if (SUCCESS == call_user_function(EG(function_table), &m_userspace, func, retval, 2, argv TSRMLS_CC)) { convert_to_long_ex(&retval); if (Z_LVAL_P(retval)) { /* convert argv[1] to an XmlResult */ result = php_dbxml_wrap_zval(argv[1]); status = true; } } zval_ptr_dtor(&func); zval_ptr_dtor(&retval); zval_ptr_dtor(&argv[0]); zval_ptr_dtor(&argv[1]); return status; }
/* {{{ mlfi_body() */ static sfsistat mlfi_body(SMFICTX *ctx, u_char *bodyp, size_t len) { zval function_name, retval, *param[1]; int status; TSRMLS_FETCH(); /* call userland */ INIT_ZVAL(function_name); ALLOC_ZVAL(param[0]); INIT_PZVAL(param[0]); ZVAL_STRING(&function_name, "milter_body", 0); ZVAL_STRINGL(param[0], (char*)bodyp, len, 1); /*alex*/ /* set the milter context for possible use in API functions */ MG(ctx) = ctx; MG(state) = MLFI_BODY; status = call_user_function(CG(function_table), NULL, &function_name, &retval, 1, param TSRMLS_CC); MG(state) = MLFI_NONE; zval_ptr_dtor(param); if (status == SUCCESS && Z_TYPE(retval) == IS_LONG) { return Z_LVAL(retval); } return SMFIS_CONTINUE; }
/* {{{ mlfi_envform() */ static sfsistat mlfi_envfrom(SMFICTX *ctx, char **argv) { zval function_name, retval, *param[1]; int status; TSRMLS_FETCH(); /* call userland */ INIT_ZVAL(function_name); ALLOC_ZVAL(param[0]); INIT_PZVAL(param[0]); ZVAL_STRING(&function_name, "milter_envfrom", 0); array_init(param[0]); while (*argv) { add_next_index_string(param[0], *argv, 1); argv++; } /* set the milter context for possible use in API functions */ MG(ctx) = ctx; MG(state) = MLFI_ENVFROM; status = call_user_function(CG(function_table), NULL, &function_name, &retval, 1, param TSRMLS_CC); MG(state) = MLFI_NONE; zval_ptr_dtor(param); if (status == SUCCESS && Z_TYPE(retval) == IS_LONG) { return Z_LVAL(retval); } return SMFIS_CONTINUE; }
/* call userland key distributor function */ zend_bool ra_call_distributor(RedisArray *ra, const char *key, int key_len, int *pos) { zval z_ret; zval z_argv0; /* check that we can call the extractor function */ if (!zend_is_callable_ex(&ra->z_dist, NULL, 0, NULL, NULL, NULL)) { php_error_docref(NULL, E_ERROR, "Could not call distributor function"); return 0; } //convert_to_string(ra->z_fun); /* call extraction function */ ZVAL_STRINGL(&z_argv0, key, key_len); call_user_function(EG(function_table), NULL, &ra->z_dist, &z_ret, 1, &z_argv0); efree(&z_argv0); if (Z_TYPE(z_ret) != IS_LONG) { zval_dtor(&z_ret); return 0; } *pos = Z_LVAL(z_ret); zval_dtor(&z_ret); return 1; }
// time critical zval* PHPQt::callPHPMethod(const zval* z_this_ptr, const char* methodName, const zend_uint param_count, zval** args) { if(z_this_ptr == NULL){ pError() << "could not call PHP method: no related PHP object found."; } zval *function_name; MAKE_STD_ZVAL(function_name); ZVAL_STRING(function_name,const_cast<char*>(methodName),1); zval* retval; ALLOC_INIT_ZVAL( retval ); if(call_user_function( CG(function_table), const_cast<zval**>(&z_this_ptr), function_name, retval, param_count, args TSRMLS_CC ) == FAILURE){ smokephp_object* o = PHPQt::getSmokePHPObjectFromZval(z_this_ptr); pError() << "could not call method " << o->ce_ptr()->name << "::" << methodName << "(...)"; } // make sure we return the right object if(PHPQt::SmokePHPObjectExists(retval)){ smokephp_object* o = PHPQt::getSmokePHPObjectFromZval(retval); retval = const_cast<zval*>(o->zval_ptr()); } efree( function_name ); return retval; }
static void ra_index_change_keys(const char *cmd, zval *z_keys, zval *z_redis) { int i, argc; zval z_fun, z_ret, *z_args; /* alloc */ argc = 1 + zend_hash_num_elements(Z_ARRVAL_P(z_keys)); z_args = emalloc(argc * sizeof(zval*)); /* prepare first parameters */ ZVAL_STRING(&z_fun, cmd); z_args = safe_emalloc(sizeof(zval), argc, 0); ZVAL_STRING(&z_args[0], PHPREDIS_INDEX_NAME); /* prepare keys */ for (i = 0; i < argc - 1; ++i) { zval *zpp; zpp = zend_hash_index_find(Z_ARRVAL_P(z_keys), i); ZVAL_COPY(&z_args[i+1], zpp); } /* run cmd */ call_user_function(&redis_ce->function_table, z_redis, &z_fun, &z_ret, argc, z_args); /* don't dtor z_ret, since we're returning z_redis */ /* free index name zval */ for (i = 0; i < argc; i++) { zval_ptr_dtor(&z_args[i]); efree(&z_args[i]); /* free index name zval */ } efree(z_args); /* free container */ }
XmlInputStream *resolveEntity(XmlTransaction *txn, XmlManager &mgr, const std::string &systemId, const std::string &publicId) { bool status = false; zval *argv[3], *retval, *func; TSRMLS_FETCH(); DEBUG(); MAKE_STD_ZVAL(func); MAKE_STD_ZVAL(retval); MAKE_STD_ZVAL(argv[0]); MAKE_STD_ZVAL(argv[1]); MAKE_STD_ZVAL(argv[2]); ZVAL_STRING(func, "resolveEntity", (int)1); ZVAL_STRINGL(argv[0], (char*)systemId.data(), (int)systemId.length(), 1); ZVAL_STRINGL(argv[1], (char*)publicId.data(), (int)publicId.length(), 1); if (SUCCESS == call_user_function(EG(function_table), &m_userspace, func, retval, 3, argv TSRMLS_CC)) { convert_to_long_ex(&retval); if (Z_LVAL_P(retval)) { //result = std::string(Z_STRVAL_P(argv[2]), Z_STRLEN_P(argv[2])); status = true; } } zval_ptr_dtor(&func); zval_ptr_dtor(&retval); zval_ptr_dtor(&argv[0]); zval_ptr_dtor(&argv[1]); zval_ptr_dtor(&argv[2]); // return status; return NULL; }
/* call userland key extraction function */ char * ra_call_extractor(RedisArray *ra, const char *key, int key_len, int *out_len) { char *out; zval z_ret; zval z_argv0; /* check that we can call the extractor function */ if (!zend_is_callable_ex(&ra->z_fun, NULL, 0, NULL, NULL, NULL)) { php_error_docref(NULL, E_ERROR, "Could not call extractor function"); return NULL; } //convert_to_string(ra->z_fun); /* call extraction function */ ZVAL_STRINGL(&z_argv0, key, key_len); call_user_function(EG(function_table), NULL, &ra->z_fun, &z_ret, 1, &z_argv0); efree(&z_argv0); if (Z_TYPE(z_ret) != IS_STRING) { zval_dtor(&z_ret); return NULL; } *out_len = Z_STRLEN(z_ret); out = emalloc(*out_len + 1); out[*out_len] = 0; memcpy(out, Z_STRVAL(z_ret), *out_len); zval_dtor(&z_ret); return out; }
/* {{{ mlfi_connect() */ static sfsistat mlfi_connect(SMFICTX *ctx, char *hostname, _SOCK_ADDR *hostaddr) { zend_file_handle file_handle; zval function_name, retval, *param[1]; int status; TSRMLS_FETCH(); /* request startup */ if (php_request_startup(TSRMLS_C)==FAILURE) { SG(headers_sent) = 1; SG(request_info).no_headers = 1; php_request_shutdown((void *) 0); return SMFIS_TEMPFAIL; } /* disable headers */ SG(headers_sent) = 1; SG(request_info).no_headers = 1; if (filename == NULL) { php_printf("No input file specified"); return SMFIS_TEMPFAIL; } if (!(file_handle.handle.fp = VCWD_FOPEN(filename, "rb"))) { php_printf("Could not open input file: %s\n", filename); return SMFIS_TEMPFAIL; } file_handle.type = ZEND_HANDLE_FP; file_handle.filename = filename; file_handle.free_filename = 0; file_handle.opened_path = NULL; php_execute_script(&file_handle TSRMLS_CC); /* call userland */ INIT_ZVAL(function_name); ALLOC_ZVAL(param[0]); INIT_PZVAL(param[0]); ZVAL_STRING(&function_name, "milter_connect", 0); ZVAL_STRING(param[0], hostname, 1); /* set the milter context for possible use in API functions */ MG(ctx) = ctx; MG(state) = MLFI_CONNECT; status = call_user_function(CG(function_table), NULL, &function_name, &retval, 1, param TSRMLS_CC); MG(state) = MLFI_NONE; zval_ptr_dtor(param); if (status == SUCCESS && Z_TYPE(retval) == IS_LONG) { return Z_LVAL(retval); } return SMFIS_CONTINUE; }
/* {{{ mlfi_header() */ static sfsistat mlfi_header(SMFICTX *ctx, char *headerf, char *headerv) { zval function_name, retval, *param[2]; int status; TSRMLS_FETCH(); /* call userland */ INIT_ZVAL(function_name); ALLOC_ZVAL(param[0]); ALLOC_ZVAL(param[1]); INIT_PZVAL(param[0]); INIT_PZVAL(param[1]); ZVAL_STRING(&function_name, "milter_header", 0); ZVAL_STRING(param[0], headerf, 1); ZVAL_STRING(param[1], headerv, 1); /* set the milter context for possible use in API functions */ MG(ctx) = ctx; MG(state) = MLFI_HEADER; status = call_user_function(CG(function_table), NULL, &function_name, &retval, 2, param TSRMLS_CC); MG(state) = MLFI_NONE; zval_ptr_dtor(¶m[0]); zval_ptr_dtor(¶m[1]); if (status == SUCCESS && Z_TYPE(retval) == IS_LONG) { return Z_LVAL(retval); } return SMFIS_CONTINUE; }
zval *samphp::call(char *fn, char *argspec, va_list ap TSRMLS_DC) { zval *rrv = NULL; zend_try { // convert the function name to a zval zval *function_name; MAKE_STD_ZVAL(function_name); ZVAL_STRING(function_name, fn, 0); // parse the parameter list zval **params = NULL; int len = strlen(argspec); if(len > 0) params = new zval* [strlen(argspec)]; zend_uint count; if (parse_args(params, &count, argspec, ap) != SUCCESS) { error_wrap(0, "Error parsing args for function %s", fn); for(unsigned int i = 0; i < count; i++) if(params[i]) zval_ptr_dtor(¶ms[i]); efree(function_name); status = FAIL; } if(status != FAIL) { zval *rv; MAKE_STD_ZVAL(rv); if(call_user_function(EG(function_table), NULL, function_name, rv, count, params TSRMLS_CC) != SUCCESS) { error_wrap(0, "calling function %s\n", fn); for(unsigned int i = 0; i < count; i++) if(params[i]) zval_ptr_dtor(¶ms[i]); efree(function_name); status = FAIL; } if(status != FAIL) { for(unsigned int i = 0; i < count; i++) if(params[i]) zval_ptr_dtor(¶ms[i]); efree(function_name); rrv = rv; } } delete params; } zend_catch { error_wrap(0, "preparing function %s\n", fn); status = FAIL; } zend_end_try() { } return rrv; }
void refill() { assert(buffer_used == 0); zval retval; ZVAL_NULL(&retval); zval *args[1]; MAKE_STD_ZVAL(args[0]); ZVAL_LONG(args[0], buffer_size); TSRMLS_FETCH(); zval funcname; ZVAL_STRING(&funcname, "read", 0); call_user_function(EG(function_table), &t, &funcname, &retval, 1, args TSRMLS_CC); zval_ptr_dtor(args); if (EG(exception)) { zval_dtor(&retval); zval* ex = EG(exception); EG(exception) = NULL; throw PHPExceptionWrapper(ex); } buffer_used = Z_STRLEN(retval); memcpy(buffer, Z_STRVAL(retval), buffer_used); zval_dtor(&retval); buffer_ptr = buffer; }
void refill() { assert(buffer_used == 0); zval retval; zval args[1]; zval funcname; ZVAL_NULL(&retval); ZVAL_LONG(&args[0], buffer_size); ZVAL_STRING(&funcname, "read"); call_user_function(EG(function_table), &(this->t), &funcname, &retval, 1, args); zval_dtor(&args[0]); zval_dtor(&funcname); if (EG(exception)) { zval_dtor(&retval); zend_object *ex = EG(exception); EG(exception) = nullptr; throw PHPExceptionWrapper(ex); } buffer_used = Z_STRLEN(retval); memcpy(buffer, Z_STRVAL(retval), buffer_used); zval_dtor(&retval); buffer_ptr = buffer; }
/* {{{ Init Milter */ static int mlfi_init() { int ret = 0; zend_file_handle file_handle; zval function_name, retval; int status; TSRMLS_FETCH(); /* request startup */ if (php_request_startup(TSRMLS_C)==FAILURE) { SG(headers_sent) = 1; SG(request_info).no_headers = 1; php_request_shutdown((void *) 0); return -1; } /* disable headers */ SG(headers_sent) = 1; SG(request_info).no_headers = 1; if (filename == NULL) { php_printf("No input file specified"); return SMFIS_TEMPFAIL; } if (!(file_handle.handle.fp = VCWD_FOPEN(filename, "rb"))) { php_printf("Could not open input file: %s\n", filename); return SMFIS_TEMPFAIL; } file_handle.type = ZEND_HANDLE_FP; file_handle.filename = filename; file_handle.free_filename = 0; file_handle.opened_path = NULL; php_execute_script(&file_handle TSRMLS_CC); /* call userland */ INIT_ZVAL(function_name); ZVAL_STRING(&function_name, "milter_init", 0); /* set the milter context for possible use in API functions */ MG(state) = MLFI_INIT; status = call_user_function(CG(function_table), NULL, &function_name, &retval, 0, NULL TSRMLS_CC); MG(state) = MLFI_NONE; MG(initialized) = 1; if (status == SUCCESS && Z_TYPE(retval) == IS_LONG) { ret = Z_LVAL(retval); } php_request_shutdown((void *) 0); return ret; }
static isc_callback _php_ibase_callback(ibase_event *event, /* {{{ */ unsigned short buffer_size, char *result_buf) { zval *res; /* this function is called asynchronously by the Interbase client library. */ TSRMLS_FETCH_FROM_CTX(event->thread_ctx); /** * The callback function is called when the event is first registered and when the event * is cancelled. I consider this is a bug. By clearing event->callback first and setting * it to -1 later, we make sure nothing happens if no event was actually posted. */ switch (event->state) { unsigned short i; unsigned long occurred_event[15]; zval return_value, args[2]; default: /* == DEAD */ break; case ACTIVE: /* copy the updated results into the result buffer */ memcpy(event->result_buffer, result_buf, buffer_size); res = zend_hash_index_find(&EG(regular_list), event->link_res_id); ZVAL_RES(&args[1], Z_RES_P(res)); /* find out which event occurred */ isc_event_counts(occurred_event, buffer_size, event->event_buffer, event->result_buffer); for (i = 0; i < event->event_count; ++i) { if (occurred_event[i]) { ZVAL_STRING(&args[0], event->events[i]); efree(event->events[i]); break; } } /* call the callback provided by the user */ if (SUCCESS != call_user_function(EG(function_table), NULL, &event->callback, &return_value, 2, args)) { _php_ibase_module_error("Error calling callback %s", Z_STRVAL(event->callback)); break; } if (Z_TYPE(return_value) == IS_FALSE) { event->state = DEAD; break; } case NEW: /* re-register the event */ if (isc_que_events(IB_STATUS, &event->link->handle, &event->event_id, buffer_size, event->event_buffer,(isc_callback)_php_ibase_callback, (void *)event)) { _php_ibase_error(); } event->state = ACTIVE; } return 0; }
void ngx_http_php_zend_uthread_resume(ngx_http_request_t *r) { ngx_php_request = r; ngx_http_php_ctx_t *ctx = ngx_http_get_module_ctx(r, ngx_http_php_module); ngx_php_debug("ctx: %p", ctx); if (ctx == NULL) { } zend_try { zval *closure; zval *func_next; zval *func_valid; zval retval; closure = ctx->generator_closure; MAKE_STD_ZVAL(func_valid); ZVAL_STRING(func_next, "next", 1); call_user_function(NULL, &(closure), func_next, &retval, 0, NULL TSRMLS_CC); zval_ptr_dtor(&func_next); MAKE_STD_ZVAL(func_valid); ZVAL_STRING(func_valid, "valid", 1); call_user_function(NULL, &(closure), func_valid, &retval, 0, NULL TSRMLS_CC); zval_ptr_dtor(&func_valid); ngx_php_debug("r:%p, closure:%p, retval:%d", r, closure, Z_TYPE(retval)); if (Z_TYPE(retval) == IS_BOOL && Z_BVAL(retval)) { ctx->phase_status = NGX_AGAIN; }else { ctx->phase_status = NGX_OK; ngx_http_core_run_phases(r); efree(ctx->generator_closure); ctx->generator_closure = NULL; } }zend_catch { }zend_end_try(); }
void directFlush() { zval ret, flushfn; ZVAL_NULL(&ret); ZVAL_STRING(&flushfn, "flush"); call_user_function(EG(function_table), &(this->t), &flushfn, &ret, 0, nullptr); zval_dtor(&flushfn); zval_dtor(&ret); }
void directFlush() { zval ret; ZVAL_NULL(&ret); zval flushfn; ZVAL_STRING(&flushfn, "flush", 0); TSRMLS_FETCH(); call_user_function(EG(function_table), &t, &flushfn, &ret, 0, NULL TSRMLS_CC); zval_dtor(&ret); }
RedisArray* ra_load_hosts(RedisArray *ra, HashTable *hosts, long retry_interval, zend_bool b_lazy_connect) { int i = 0, host_len; zval *id; char *host, *p; short port; zval *zpData, z_cons, z_ret; RedisSock *redis_sock = NULL; /* function calls on the Redis object */ ZVAL_STRING(&z_cons, "__construct"); /* init connections */ ZEND_HASH_FOREACH_VAL(hosts, zpData) { if (Z_TYPE_P(zpData) != IS_STRING) { efree(ra); return NULL; } ra->hosts[i] = estrdup(Z_STRVAL_P(zpData)); /* default values */ host = Z_STRVAL_P(zpData); host_len = Z_STRLEN_P(zpData); port = 6379; if ((p = strchr(host, ':'))) { /* found port */ host_len = p - host; port = (short)atoi(p+1); } else if (strchr(host,'/') != NULL) { /* unix socket */ port = -1; } /* create Redis object */ object_init_ex(&ra->redis[i], redis_ce); call_user_function(&redis_ce->function_table, &ra->redis[i], &z_cons, &z_ret, 0, NULL); /* create socket */ redis_sock = redis_sock_create(host, host_len, port, ra->connect_timeout, ra->pconnect, NULL, retry_interval, b_lazy_connect); if (!b_lazy_connect) { /* connect */ redis_sock_server_open(redis_sock, 1); } /* attach */ id = zend_list_insert(redis_sock, le_redis_sock); add_property_resource(&ra->redis[i], "socket", Z_RES_P(id)); i++; } ZEND_HASH_FOREACH_END(); return ra; }
static void timer_handle_callback(uv_timer_ext_t *timer_handle){ zval *timer_cb; zval retval; zval *params[] = {timer_handle->object}; TSRMLS_FETCH(); ZVAL_NULL(&retval); timer_cb = zend_read_property(CLASS_ENTRY(UVTimer), timer_handle->object, ZEND_STRL("callback"), 0 TSRMLS_CC); call_user_function(CG(function_table), NULL, timer_cb, &retval, 1, params TSRMLS_CC); zval_dtor(&retval); }
PHP_METHOD(MIME, load) { zval *array, *arg, retval; /* Fetch allowHEAD */ MAKE_STD_ZVAL(array); array_init_size(array, 2); add_next_index_stringl(array, "Pancake\\Config", sizeof("Pancake\\Config") - 1, 1); add_next_index_stringl(array, "get", 3, 1); MAKE_STD_ZVAL(arg); Z_TYPE_P(arg) = IS_STRING; Z_STRLEN_P(arg) = 4; Z_STRVAL_P(arg) = estrndup("mime", 4); call_user_function(CG(function_table), NULL, array, &retval, 1, &arg TSRMLS_CC); if(Z_TYPE(retval) != IS_ARRAY) { zend_error(E_ERROR, "Bad MIME type array - Please check Pancake MIME type configuration"); } ALLOC_HASHTABLE(PANCAKE_GLOBALS(mimeTable)); zend_hash_init(PANCAKE_GLOBALS(mimeTable), 0, NULL, ZVAL_PTR_DTOR, 0); zval **data, **ext; char *key; for(zend_hash_internal_pointer_reset(Z_ARRVAL(retval)); zend_hash_get_current_data(Z_ARRVAL(retval), (void**) &data) == SUCCESS && zend_hash_get_current_key(Z_ARRVAL(retval), &key, NULL, 0) == HASH_KEY_IS_STRING; zend_hash_move_forward(Z_ARRVAL(retval))) { for(zend_hash_internal_pointer_reset(Z_ARRVAL_PP(data)); zend_hash_get_current_data(Z_ARRVAL_PP(data), (void**) &ext) == SUCCESS; zend_hash_move_forward(Z_ARRVAL_PP(data))) { zval *zkey; MAKE_STD_ZVAL(zkey); Z_TYPE_P(zkey) = IS_STRING; Z_STRLEN_P(zkey) = strlen(key); Z_STRVAL_P(zkey) = estrndup(key, Z_STRLEN_P(zkey)); zend_hash_add(PANCAKE_GLOBALS(mimeTable), Z_STRVAL_PP(ext), Z_STRLEN_PP(ext), (void*) &zkey, sizeof(zval*), NULL); } } MAKE_STD_ZVAL(PANCAKE_GLOBALS(defaultMimeType)); Z_TYPE_P(PANCAKE_GLOBALS(defaultMimeType)) = IS_STRING; Z_STRLEN_P(PANCAKE_GLOBALS(defaultMimeType)) = sizeof("application/octet-stream") - 1; Z_STRVAL_P(PANCAKE_GLOBALS(defaultMimeType)) = estrndup("application/octet-stream", sizeof("application/octet-stream") - 1); free: zval_dtor(&retval); zval_ptr_dtor(&array); zval_ptr_dtor(&arg); }
RedisArray* ra_load_hosts(RedisArray *ra, HashTable *hosts, long retry_interval TSRMLS_DC) { int i, host_len, id; int count = zend_hash_num_elements(hosts); char *host, *p; short port; zval **zpData, z_cons, z_ret; RedisSock *redis_sock = NULL; /* function calls on the Redis object */ ZVAL_STRING(&z_cons, "__construct", 0); /* init connections */ for(i = 0; i < count; ++i) { if(FAILURE == zend_hash_quick_find(hosts, NULL, 0, i, (void**)&zpData)) { efree(ra); return NULL; } ra->hosts[i] = estrdup(Z_STRVAL_PP(zpData)); /* default values */ host = Z_STRVAL_PP(zpData); host_len = Z_STRLEN_PP(zpData); port = 6379; if((p = strchr(host, ':'))) { /* found port */ host_len = p - host; port = (short)atoi(p+1); } /* create Redis object */ MAKE_STD_ZVAL(ra->redis[i]); object_init_ex(ra->redis[i], redis_ce); INIT_PZVAL(ra->redis[i]); call_user_function(&redis_ce->function_table, &ra->redis[i], &z_cons, &z_ret, 0, NULL TSRMLS_CC); /* create socket */ redis_sock = redis_sock_create(host, host_len, port, 0, 0, NULL, retry_interval); /* TODO: persistence? */ /* connect */ redis_sock_server_open(redis_sock, 1 TSRMLS_CC); /* attach */ #if PHP_VERSION_ID >= 50400 id = zend_list_insert(redis_sock, le_redis_sock TSRMLS_CC); #else id = zend_list_insert(redis_sock, le_redis_sock); #endif add_property_resource(ra->redis[i], "socket", id); } return ra; }