您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ zend_hash_find函数代码示例

51自学网 2021-06-03 11:56:36
  C++
这篇教程C++ zend_hash_find函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中zend_hash_find函数的典型用法代码示例。如果您正苦于以下问题:C++ zend_hash_find函数的具体用法?C++ zend_hash_find怎么用?C++ zend_hash_find使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了zend_hash_find函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: spl_find_ce_by_name

static zend_class_entry * spl_find_ce_by_name(char *name, int len, zend_bool autoload TSRMLS_DC){	zend_class_entry **ce;	int found;	if (!autoload) {		char *lc_name;		ALLOCA_FLAG(use_heap)		lc_name = do_alloca(len + 1, use_heap);		zend_str_tolower_copy(lc_name, name, len);		found = zend_hash_find(EG(class_table), lc_name, len +1, (void **) &ce);		free_alloca(lc_name, use_heap);	} else { 		found = zend_lookup_class(name, len, &ce TSRMLS_CC); 	} 	if (found != SUCCESS) {		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Class %s does not exist%s", name, autoload ? " and could not be loaded" : "");		return NULL;	}		return *ce;}
开发者ID:haizhilin2013,项目名称:php-src,代码行数:24,


示例2: apply_to_cursor

static int apply_to_cursor(zval *cursor, apply_copy_func_t apply_copy_func, void *to, int max TSRMLS_DC){	int total = 0;	zval *next;	MAKE_STD_ZVAL(next);	MONGO_METHOD(MongoCursor, getNext, next, cursor);	if (EG(exception)) {		return FAILURE;	}    	if (Z_TYPE_P(next) != IS_ARRAY) {		zval_ptr_dtor(&next);		return FAILURE;	}	while (Z_TYPE_P(next) == IS_ARRAY) {		zval **zdata;		/* Check if data field exists. If it doesn't, we've probably got an		 * error message from the db, so return that */		if (zend_hash_find(HASH_P(next), "data", 5, (void**)&zdata) == FAILURE) {			if (zend_hash_exists(HASH_P(next), "$err", 5)) {				zval_ptr_dtor(&next);				return FAILURE;			}			continue;		}		/* This copies the next chunk -> *to		 * Due to a talent I have for not reading directions, older versions of		 * the driver store files as raw bytes, not MongoBinData. So, we'll		 * check for and handle both cases. */		if (Z_TYPE_PP(zdata) == IS_STRING) {			/* raw bytes */			if (total + Z_STRLEN_PP(zdata) > max) {				zend_throw_exception_ex(mongo_ce_GridFSException, 1 TSRMLS_CC, "There is more data associated with this file than the metadata specifies");				return FAILURE;			}			total += apply_copy_func(to, Z_STRVAL_PP(zdata), Z_STRLEN_PP(zdata));		} else if (Z_TYPE_PP(zdata) == IS_OBJECT && Z_OBJCE_PP(zdata) == mongo_ce_BinData) {			/* MongoBinData */			zval *bin = zend_read_property(mongo_ce_BinData, *zdata, "bin", strlen("bin"), NOISY TSRMLS_CC);			if (total + Z_STRLEN_P(bin) > max) {				zval **n;				if (zend_hash_find(HASH_P(next), "n", strlen("n") + 1, (void**)&n) == SUCCESS) {					convert_to_long_ex(n);					zend_throw_exception_ex(mongo_ce_GridFSException, 1 TSRMLS_CC, "There is more data associated with this file than the metadata specifies (reading chunk %d)", Z_LVAL_PP(n));				} else {					zend_throw_exception_ex(mongo_ce_GridFSException, 1 TSRMLS_CC, "There is more data associated with this file than the metadata specifies");				}				zval_ptr_dtor(&next);				return FAILURE;			}			total += apply_copy_func(to, Z_STRVAL_P(bin), Z_STRLEN_P(bin));		} else {			/* If it's not a string or a MongoBinData, give up */			zval_ptr_dtor(&next);			return FAILURE;		}		/* get ready for the next iteration */		zval_ptr_dtor(&next);		MAKE_STD_ZVAL(next);		MONGO_METHOD(MongoCursor, getNext, next, cursor);	}	zval_ptr_dtor(&next);	/* return the number of bytes copied */	return total;}
开发者ID:CheowTong,项目名称:mongo-php-driver,代码行数:77,


示例3: php_error_docref

//.........这里部分代码省略.........            ua = (char *)emalloc(ua_len + 1);            if ((ua_len = snprintf(ua, ua_len, _UA_HEADER, ua_str)) > 0) {                ua[ua_len] = 0;                php_stream_write(stream, ua, ua_len);            } else {                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot construct User-agent header");            }            if (ua) {                efree(ua);            }        }    }    php_stream_write(stream, "/r/n", sizeof("/r/n")-1);    /* Request content, such as for POST requests */    if (context && php_stream_context_get_option(context, "http", "content", &tmpzval) == SUCCESS && Z_STRLEN_PP(tmpzval) > 0) {        php_stream_write(stream, Z_STRVAL_PP(tmpzval), Z_STRLEN_PP(tmpzval));        php_stream_write(stream, "/r/n/r/n", sizeof("/r/n/r/n")-1);    }    location[0] = '/0';    /*     * We need to read the HTTP response header one-by-one, because     * the original author did not know about MSG_PEEK.     * The chunk_size will be reset later, once we have read the     * header completely.     */    if (options & STREAM_WILL_CAST)        chunk_size = php_stream_set_chunk_size(stream, 1);    if (!header_init && FAILURE == zend_hash_find(EG(active_symbol_table),            "http_response_header", sizeof("http_response_header"), (void **) &response_header)) {        header_init = 1;    }    if (header_init) {        zval *tmp;        MAKE_STD_ZVAL(tmp);        array_init(tmp);        ZEND_SET_SYMBOL(EG(active_symbol_table), "http_response_header", tmp);        zend_hash_find(EG(active_symbol_table),                       "http_response_header", sizeof("http_response_header"), (void **) &response_header);    }    if (!php_stream_eof(stream)) {        size_t tmp_line_len;        /* get response header */        if (_php_stream_get_line(stream, tmp_line, sizeof(tmp_line) - 1, &tmp_line_len TSRMLS_CC) != NULL) {            zval *http_response;            int response_code;            MAKE_STD_ZVAL(http_response);            ZVAL_NULL(http_response);            if (tmp_line_len > 9) {                response_code = atoi(tmp_line + 9);            } else {                response_code = 0;            }            switch(response_code) {
开发者ID:Ashod,项目名称:Phalanger,代码行数:67,


示例4: PHP_METHOD

PHP_METHOD(MongoDB, command) {  zval limit, *temp, *cmd, *cursor, *ns, *options = 0;  mongo_db *db;  mongo_link *link;  char *cmd_ns;  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|a", &cmd, &options) == FAILURE) {    return;  }  if (IS_SCALAR_P(cmd)) {    zend_error(E_WARNING, "MongoDB::command() expects parameter 1 to be an array or object");    return;  }  PHP_MONGO_GET_DB(getThis());  // create db.$cmd  MAKE_STD_ZVAL(ns);  cmd_ns = get_cmd_ns(Z_STRVAL_P(db->name), Z_STRLEN_P(db->name));  ZVAL_STRING(ns, cmd_ns, 0);  // create cursor  MAKE_STD_ZVAL(cursor);  object_init_ex(cursor, mongo_ce_Cursor);  MAKE_STD_ZVAL(temp);  ZVAL_NULL(temp);  MONGO_METHOD3(MongoCursor, __construct, temp, cursor, db->link, ns, cmd);  zval_ptr_dtor(&ns);  zval_ptr_dtor(&temp);  MAKE_STD_ZVAL(temp);  ZVAL_NULL(temp);  // limit  Z_TYPE(limit) = IS_LONG;  Z_LVAL(limit) = -1;  MONGO_METHOD1(MongoCursor, limit, temp, cursor, &limit);  zval_ptr_dtor(&temp);  if (options) {    zval **timeout;    if (zend_hash_find(HASH_P(options), "timeout", strlen("timeout")+1, (void**)&timeout) == SUCCESS) {      MAKE_STD_ZVAL(temp);      ZVAL_NULL(temp);      MONGO_METHOD1(MongoCursor, timeout, temp, cursor, *timeout);      zval_ptr_dtor(&temp);    }  }  // make sure commands aren't be sent to slaves  PHP_MONGO_GET_LINK(db->link);  if (link->rs) {    zval slave_okay;    Z_TYPE(slave_okay) = IS_BOOL;    Z_LVAL(slave_okay) = 0;    MAKE_STD_ZVAL(temp);    ZVAL_NULL(temp);    MONGO_METHOD1(MongoCursor, slaveOkay, temp, cursor, &slave_okay);    zval_ptr_dtor(&temp);  }  // query  MONGO_METHOD(MongoCursor, getNext, return_value, cursor);  clear_exception(return_value TSRMLS_CC);  zend_objects_store_del_ref(cursor TSRMLS_CC);  zval_ptr_dtor(&cursor);}
开发者ID:cockatoo-org,项目名称:mongo-php-driver,代码行数:71,


示例5: PHP_METHOD

PHP_METHOD(air_view, render){	AIR_INIT_THIS;	char *tpl_str;	int tpl_len = 0;	zend_bool ret_res = 0;	if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sb", &tpl_str, &tpl_len, &ret_res) == FAILURE)	{		RETURN_FALSE;	}	smart_str ss_path = {0};	if(tpl_str[0] != '/'){		zval *root_path = NULL;		MAKE_STD_ZVAL(root_path);		if(zend_get_constant(ZEND_STRL("ROOT_PATH"), root_path) == FAILURE){			php_error_docref(NULL TSRMLS_CC, E_ERROR,  "ROOT_PATH not defined");		}		smart_str_appendl(&ss_path, Z_STRVAL_P(root_path), Z_STRLEN_P(root_path));		smart_str_appendc(&ss_path, '/');		if(root_path != NULL){			zval_ptr_dtor(&root_path);		}		zval *tmp = NULL;		zval **tmp_pp;		zval *config = zend_read_property(air_view_ce, getThis(), ZEND_STRL("_config"), 0 TSRMLS_CC);		if(config != NULL && Z_TYPE_P(config) == IS_ARRAY				&& zend_hash_find(Z_ARRVAL_P(config), ZEND_STRL("path"), (void **)&tmp_pp) == SUCCESS){			smart_str_appendl(&ss_path, Z_STRVAL_PP(tmp_pp), Z_STRLEN_PP(tmp_pp));		}else{			zval *app_conf;			zval *view_conf;			if(air_config_get(NULL, ZEND_STRS("app"), &app_conf TSRMLS_CC) == FAILURE){				AIR_NEW_EXCEPTION(1, "@error config: app");			}			zval *app_path = NULL;			if(air_config_get(app_conf, ZEND_STRS("path"), &app_path) == FAILURE){				AIR_NEW_EXCEPTION(1, "@error config: app.path");			}			zval *view_path = NULL;			if(air_config_get_path(app_conf, ZEND_STRS("view.path"), &view_path) == FAILURE){				AIR_NEW_EXCEPTION(1, "@view config not found");			}			smart_str_appendl(&ss_path, Z_STRVAL_P(app_path), Z_STRLEN_P(app_path));			smart_str_appendc(&ss_path, '/');			smart_str_appendl(&ss_path, Z_STRVAL_P(view_path), Z_STRLEN_P(view_path));		}		smart_str_appendc(&ss_path, '/');	}	smart_str_appendl(&ss_path, tpl_str, tpl_len);	smart_str_0(&ss_path);	//php_printf("full view path: %s/n", ss_path.c);	//构造运行时所需基本变量	HashTable *origin_symbol_table = NULL;	zval *output_handler = NULL;	long chunk_size = 0;	long flags = PHP_OUTPUT_HANDLER_STDFLAGS;	zval *view_ret = NULL;	//尝试缓存当前符号表	if(EG(active_symbol_table)){		origin_symbol_table = EG(active_symbol_table);	}	if (ret_res) {		MAKE_STD_ZVAL(view_ret);		if(php_output_start_user(output_handler, chunk_size, flags TSRMLS_CC) == FAILURE)		{			php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to create buffer");			RETURN_FALSE;		}	}	ALLOC_HASHTABLE(EG(active_symbol_table));	zval *data = zend_read_property(air_view_ce, getThis(), ZEND_STRL("_data"), 0 TSRMLS_CC);	zend_hash_init(EG(active_symbol_table), 0, NULL, ZVAL_PTR_DTOR, 0);	//将当前的模板变量放到符号表去	ZEND_SET_SYMBOL_WITH_LENGTH(EG(active_symbol_table), "var", 4, data, Z_REFCOUNT_P(data) + 1, PZVAL_IS_REF(data));	if(air_loader_include_file(ss_path.c TSRMLS_CC) == FAILURE){		air_throw_exception_ex(1, "tpl %s render failed!/n", ss_path.c);		return ;	}	if(ret_res){		php_output_get_contents(view_ret TSRMLS_CC);		php_output_discard(TSRMLS_C);		RETVAL_ZVAL(view_ret, 1, 0);		zval_ptr_dtor(&view_ret);	}	zend_hash_destroy(EG(active_symbol_table));	FREE_HASHTABLE(EG(active_symbol_table));	EG(active_symbol_table) = origin_symbol_table;	smart_str_free(&ss_path);}
开发者ID:panbooks,项目名称:air,代码行数:98,


示例6: msgpack_convert_long_to_properties

inline int msgpack_convert_long_to_properties(    HashTable *ht, HashTable **properties, HashPosition *prop_pos,    uint key_index, zval *val, HashTable *var){    TSRMLS_FETCH();    if (*properties != NULL)    {        char *prop_key;        uint prop_key_len;        ulong prop_key_index;        zval **data = NULL;        zval *tplval = NULL;        zval **dataval = NULL;        for (;; zend_hash_move_forward_ex(*properties, prop_pos))        {            if (zend_hash_get_current_key_ex(                    *properties, &prop_key, &prop_key_len,                    &prop_key_index, 0, prop_pos) == HASH_KEY_IS_STRING)            {                if (var == NULL ||                    !zend_hash_exists(var, prop_key, prop_key_len))                {                    if (zend_hash_find(                            ht, prop_key, prop_key_len,                            (void **)&data) == SUCCESS)                    {                        switch (Z_TYPE_PP(data))                        {                            case IS_ARRAY:                            {                                HashTable *dataht;                                dataht = HASH_OF(val);                                if (zend_hash_index_find(                                        dataht, prop_key_index,                                        (void **)dataval) != SUCCESS)                                {                                    MSGPACK_WARNING(                                        "[msgpack] (%s) "                                        "can't get data value by index",                                        __FUNCTION__);                                    return FAILURE;                                }                                ALLOC_INIT_ZVAL(tplval);                                if (msgpack_convert_array(                                        tplval, *data, dataval) == SUCCESS)                                {                                    zend_hash_move_forward_ex(                                        *properties, prop_pos);                                    return zend_symtable_update(                                        ht, prop_key, prop_key_len,                                        &tplval, sizeof(tplval), NULL);                                }                                // TODO: de we need to call dtor?                                return FAILURE;                                break;                            }                            case IS_OBJECT:                            {                                ALLOC_INIT_ZVAL(tplval);                                if (msgpack_convert_object(                                        tplval, *data, &val) == SUCCESS)                                {                                    zend_hash_move_forward_ex(                                        *properties, prop_pos);                                    return zend_symtable_update(                                        ht, prop_key, prop_key_len,                                        &tplval, sizeof(tplval), NULL);                                }                                // TODO: de we need to call dtor?                                return FAILURE;                                break;                            }                            default:                                zend_hash_move_forward_ex(*properties, prop_pos);                                return zend_symtable_update(                                    ht, prop_key, prop_key_len,                                    &val, sizeof(val), NULL);                                break;                        }                    }                }            }            else            {                break;            }        }        *properties = NULL;    }    return zend_hash_index_update(ht, key_index, &val, sizeof(val), NULL);}
开发者ID:LoosKonstantin,项目名称:msgpack,代码行数:98,


示例7: PHP_METHOD

PHP_METHOD(jsonrpc_server, rpcformat){  zval *payload;  zval *object;  zval **method = NULL;  zval **jsonrpc = NULL;  zval **params = NULL;  object = getThis();  payload = zend_read_property(      php_jsonrpc_server_entry, object, "payload", sizeof("payload")-1, 0 TSRMLS_CC    );  if (Z_TYPE_P(payload) != IS_ARRAY)  {    RETVAL_LONG(-32600);    return ;  }  if (!zend_symtable_exists(Z_ARRVAL_P(payload), "jsonrpc", strlen("jsonrpc")+1))  {    RETVAL_LONG(-32600);    return ;  }  if (!zend_symtable_exists(Z_ARRVAL_P(payload), "method", strlen("method")+1))  {    RETVAL_LONG(-32601);    return ;  }  //MAKE_STD_ZVAL(&method);  if (zend_hash_find(Z_ARRVAL_P(payload), "method", strlen("method")+1, (void **)&method) == FAILURE)  {    RETVAL_LONG(-32601);    return ;  }  if (Z_TYPE_PP(method) != IS_STRING)  {    RETVAL_LONG(-32601);    return ;  }  //MAKE_STD_ZVAL(&jsonrpc);  if (zend_hash_find(Z_ARRVAL_P(payload), "jsonrpc", strlen("jsonrpc")+1, (void **)&jsonrpc) == FAILURE)  {    RETVAL_LONG(-32600);    return ;  }  if (strcmp(Z_STRVAL_PP(jsonrpc),"2.0") != 0)  {    RETVAL_LONG(-32600);    return ;  }    //MAKE_STD_ZVAL(&params);  if (zend_hash_find(Z_ARRVAL_P(payload), "params", strlen("params")+1, (void **)&params) == FAILURE)  {    RETVAL_LONG(-32602);    return ;  }  if (Z_TYPE_PP(params) != IS_ARRAY)  {    RETVAL_LONG(-32602);    return ;  }  RETVAL_LONG(0);  return ;}
开发者ID:guoyu07,项目名称:JsonRPC,代码行数:75,


示例8: phar_parse_url

/** * Open a phar file for streams API */php_url* phar_parse_url(php_stream_wrapper *wrapper, char *filename, char *mode, int options TSRMLS_DC) /* {{{ */{	php_url *resource;	char *arch = NULL, *entry = NULL, *error;	int arch_len, entry_len;	if (strlen(filename) < 7 || strncasecmp(filename, "phar://", 7)) {		return NULL;	}	if (mode[0] == 'a') {		if (!(options & PHP_STREAM_URL_STAT_QUIET)) {			php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: open mode append not supported");		}		return NULL;	}	if (phar_split_fname(filename, strlen(filename), &arch, &arch_len, &entry, &entry_len, 2, (mode[0] == 'w' ? 2 : 0) TSRMLS_CC) == FAILURE) {		if (!(options & PHP_STREAM_URL_STAT_QUIET)) {			if (arch && !entry) {				php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: no directory in /"%s/", must have at least phar://%s/ for root directory (always use full path to a new phar)", filename, arch);				arch = NULL;			} else {				php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: invalid url or non-existent phar /"%s/"", filename);			}		}		return NULL;	}	resource = ecalloc(1, sizeof(php_url));	resource->scheme = estrndup("phar", 4);	resource->host = arch;	resource->path = entry;#if MBO_0		if (resource) {			fprintf(stderr, "Alias:     %s/n", alias);			fprintf(stderr, "Scheme:    %s/n", resource->scheme);/*			fprintf(stderr, "User:      %s/n", resource->user);*//*			fprintf(stderr, "Pass:      %s/n", resource->pass ? "***" : NULL);*/			fprintf(stderr, "Host:      %s/n", resource->host);/*			fprintf(stderr, "Port:      %d/n", resource->port);*/			fprintf(stderr, "Path:      %s/n", resource->path);/*			fprintf(stderr, "Query:     %s/n", resource->query);*//*			fprintf(stderr, "Fragment:  %s/n", resource->fragment);*/		}#endif	if (mode[0] == 'w' || (mode[0] == 'r' && mode[1] == '+')) {		phar_archive_data **pphar = NULL, *phar;		if (PHAR_GLOBALS->request_init && PHAR_GLOBALS->phar_fname_map.arBuckets && FAILURE == zend_hash_find(&(PHAR_GLOBALS->phar_fname_map), arch, arch_len, (void **)&pphar)) {			pphar = NULL;		}		if (PHAR_G(readonly) && (!pphar || !(*pphar)->is_data)) {			if (!(options & PHP_STREAM_URL_STAT_QUIET)) {				php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: write operations disabled by the php.ini setting phar.readonly");			}			php_url_free(resource);			return NULL;		}		if (phar_open_or_create_filename(resource->host, arch_len, NULL, 0, 0, options, &phar, &error TSRMLS_CC) == FAILURE)		{			if (error) {				if (!(options & PHP_STREAM_URL_STAT_QUIET)) {					php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "%s", error);				}				efree(error);			}			php_url_free(resource);			return NULL;		}		if (phar->is_persistent && FAILURE == phar_copy_on_write(&phar TSRMLS_CC)) {			if (error) {				spprintf(&error, 0, "Cannot open cached phar '%s' as writeable, copy on write failed", resource->host);				if (!(options & PHP_STREAM_URL_STAT_QUIET)) {					php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "%s", error);				}				efree(error);			}			php_url_free(resource);			return NULL;		}	} else {		if (phar_open_from_filename(resource->host, arch_len, NULL, 0, options, NULL, &error TSRMLS_CC) == FAILURE)		{			if (error) {				if (!(options & PHP_STREAM_URL_STAT_QUIET)) {					php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "%s", error);				}				efree(error);			}			php_url_free(resource);			return NULL;		}	}	return resource;}
开发者ID:rogerhu,项目名称:dd-wrt,代码行数:97,


示例9: zend_optimizer_compact_literals

//.........这里部分代码省略.........					}					map[i] = l_false;					break;				case IS_TRUE:					if (l_true < 0) {						l_true = j;						if (i != j) {							op_array->literals[j] = op_array->literals[i];							info[j] = info[i];						}						j++;					}					map[i] = l_true;					break;				case IS_LONG:					if (LITERAL_NUM_RELATED(info[i].flags) == 1) {						if ((pos = zend_hash_index_find(&hash, Z_LVAL(op_array->literals[i]))) != NULL) {							map[i] = Z_LVAL_P(pos);						} else {							map[i] = j;							ZVAL_LONG(&zv, j);							zend_hash_index_add_new(&hash, Z_LVAL(op_array->literals[i]), &zv);							if (i != j) {								op_array->literals[j] = op_array->literals[i];								info[j] = info[i];							}							j++;						}					} else {						ZEND_ASSERT(LITERAL_NUM_RELATED(info[i].flags) == 2);						key = zend_string_init(Z_STRVAL(op_array->literals[i+1]), Z_STRLEN(op_array->literals[i+1]), 0);						ZSTR_H(key) = ZSTR_HASH(Z_STR(op_array->literals[i+1])) + 100 +							LITERAL_NUM_RELATED(info[i].flags) - 1;						if ((pos = zend_hash_find(&hash, key)) != NULL						 && LITERAL_NUM_RELATED(info[Z_LVAL_P(pos)].flags) == 2) {							map[i] = Z_LVAL_P(pos);							zval_ptr_dtor_nogc(&op_array->literals[i+1]);						} else {							map[i] = j;							ZVAL_LONG(&zv, j);							zend_hash_add_new(&hash, key, &zv);							if (i != j) {								op_array->literals[j] = op_array->literals[i];								info[j] = info[i];								op_array->literals[j+1] = op_array->literals[i+1];								info[j+1] = info[i+1];							}							j += 2;						}						zend_string_release_ex(key, 0);						i++;					}					break;				case IS_DOUBLE:					if ((pos = zend_hash_str_find(&hash, (char*)&Z_DVAL(op_array->literals[i]), sizeof(double))) != NULL) {						map[i] = Z_LVAL_P(pos);					} else {						map[i] = j;						ZVAL_LONG(&zv, j);						zend_hash_str_add(&hash, (char*)&Z_DVAL(op_array->literals[i]), sizeof(double), &zv);						if (i != j) {							op_array->literals[j] = op_array->literals[i];							info[j] = info[i];						}						j++;					}
开发者ID:crrodriguez,项目名称:php-src,代码行数:67,


示例10: solr_document_set_field

/* {{{ static int solr_document_set_field(zval *objptr, solr_char_t *field_name, int field_name_length, solr_char_t *field_value, int field_value_length TSRMLS_DC) */static int solr_document_set_field(zval *objptr, solr_char_t *field_name, int field_name_length, solr_char_t *field_value, int field_value_length TSRMLS_DC){	double field_boost = 0.0f;	solr_document_t *doc_entry = NULL;	if (!field_name_length) {		return FAILURE;	}	if (!field_value_length)	{		return FAILURE;	}	/* Retrieve the document entry for the SolrDocument instance */	if (solr_fetch_document_entry(objptr, &doc_entry TSRMLS_CC) == SUCCESS)	{		solr_field_list_t **field_values_ptr = NULL;		solr_field_list_t *field_values      = NULL;		/* If the field already exists in the SolrDocument instance append the value to the field list queue */		if (zend_hash_find(doc_entry->fields, field_name, field_name_length, (void **) &field_values_ptr) == SUCCESS) {			if (solr_document_insert_field_value(*field_values_ptr, field_value, field_boost) == FAILURE) {				return FAILURE;			}		} else {			/* Otherwise, create a new one and add it to the hash table */			field_values = (solr_field_list_t *)  pemalloc(sizeof(solr_field_list_t), SOLR_DOCUMENT_FIELD_PERSISTENT);			memset(field_values, 0, sizeof(solr_field_list_t));			field_values_ptr = &field_values;			field_values->count       = 0L;			field_values->field_boost = 0.0;			field_values->field_name  = (solr_char_t *) pestrdup(field_name,SOLR_DOCUMENT_FIELD_PERSISTENT);			field_values->head        = NULL;			field_values->last        = NULL;			if (solr_document_insert_field_value(field_values, field_value, field_boost) == FAILURE) {				solr_destroy_field_list(&field_values);				return FAILURE;			}			if (zend_hash_add(doc_entry->fields, field_name, field_name_length, (void *) field_values_ptr, sizeof(solr_field_list_t *), (void **) NULL) == FAILURE) {				solr_destroy_field_list(&field_values);				return FAILURE;			}			/* Increment field count only when HEAD is added */			doc_entry->field_count++;		}		return SUCCESS;	}	return FAILURE;}
开发者ID:gunt2raro,项目名称:SDIDD,代码行数:69,


示例11: PHP_METHOD

PHP_METHOD(Edge_Controller, model){    char *model_name = NULL;    char *model_dir = NULL;    int mnlen=0;    int mdlen=0;    if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &model_name, &mnlen, &model_dir, &mdlen) == FAILURE)    {        RETURN_FALSE;    }        char *model_class_name;    int class_name_len;    class_name_len = spprintf(&model_class_name, 0, "%s%s", model_name, "Model");    zval **z_obj;    if(zend_hash_find(Z_ARRVAL_P(EDGE_G(regs)), model_class_name, class_name_len+1, (void **)&z_obj) == SUCCESS)    {        efree(model_class_name);        RETURN_ZVAL(*z_obj, 1, 0);    }        zval *config;    zval *config_data;    config = zend_read_static_property(edge_core_ce, ZEND_STRL("config"), 1 TSRMLS_DC);    config_data = zend_read_property(edge_config_ce, config, ZEND_STRL("_data"), 1 TSRMLS_DC);    zval **models_home_pp;    if(zend_hash_find(Z_ARRVAL_P(config_data), "_models_home", strlen("_models_home")+1, (void **)&models_home_pp) == FAILURE)    {        RETURN_FALSE;    }        zval *z_model_name;    MAKE_STD_ZVAL(z_model_name);    ZVAL_STRING(z_model_name, model_class_name, 1);    zval *loader;    zval *ret;    loader = zend_read_static_property(edge_core_ce, ZEND_STRL("loader"), 1 TSRMLS_DC);    zend_call_method_with_2_params(&loader, Z_OBJCE_P(loader), NULL, "autoload", &ret, z_model_name, *models_home_pp);    zval_ptr_dtor(&z_model_name);    if(!Z_BVAL_P(ret))    {        php_error_docref(NULL TSRMLS_CC, E_WARNING, "model %s%s load fail", Z_STRVAL_PP(models_home_pp), model_class_name);        zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 0 TSRMLS_CC, "model %s%s load fail", Z_STRVAL_PP(models_home_pp), model_class_name);        zval_ptr_dtor(&ret);        efree(model_class_name);        RETURN_FALSE;    }    zval_ptr_dtor(&ret);    zend_class_entry **model_ce;    if(zend_lookup_class(model_class_name, class_name_len, &model_ce TSRMLS_CC) == FAILURE)    {        php_error_docref(NULL TSRMLS_CC, E_WARNING, "model class %s not exist", model_class_name);        zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 0 TSRMLS_CC, "model class %s%s  not exist", model_class_name);        efree(model_class_name);        RETURN_FALSE;    }    zval *model_obj;    MAKE_STD_ZVAL(model_obj);    object_init_ex(model_obj, *model_ce);    zval **cfptr;    if(zend_hash_find(&((*model_ce)->function_table), "__construct", strlen("__construct")+1, (void **)&cfptr) == SUCCESS)    {        zval *cretval;        zend_call_method(&model_obj, *model_ce, NULL, "__construct", strlen("__construct"), &cretval, 0, NULL, NULL TSRMLS_CC);        zval_ptr_dtor(&cretval);    }    zend_hash_update(Z_ARRVAL_P(EDGE_G(regs)), model_class_name, class_name_len+1, (void **)&model_obj, sizeof(zval *), NULL);    efree(model_class_name);    RETURN_ZVAL(model_obj, 1, 0);}
开发者ID:linkaisheng,项目名称:edge,代码行数:78,


示例12: ZEND_METHOD

ZEND_METHOD( alinq_class , GroupBy ){    zend_fcall_info fci;    zend_fcall_info_cache fci_cache;    zend_class_entry *ce;    ce = Z_OBJCE_P(getThis());    zval * reVal;    zval * resultArray;    MAKE_STD_ZVAL(resultArray);    array_init(resultArray);    zval *retval_ptr = NULL;    zval *returnObj;      zval *dataSource, **tmpns;    char aReturnType;    int aReturnTypeLen;     // aReturnType = 'bool';     //取得数组    dataSource = zend_read_property(ce, getThis(), "dataSource", sizeof("dataSource")-1, 0 TSRMLS_DC);    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "f", &fci, &fci_cache) == FAILURE) {        return;    }         while (zend_hash_get_current_data(Z_ARRVAL_P(dataSource), (void **)&tmpns) == SUCCESS) {        char *key;        uint keylen;        ulong idx;        int type;        zval **ppzval, tmpcopy;        zval **item,*item1;        MAKE_STD_ZVAL(item1);        array_init(item1);        item = &item1;        // php_printf("step-/n");        // if(count>0 && i>=count){        //只循环count次        //     break;        // }        type = zend_hash_get_current_key_ex(Z_ARRVAL_P(dataSource), &key, &keylen,&idx, 0, NULL);        //重新copy一个zval,防止破坏原数据        tmpcopy = **tmpns;        zval_copy_ctor(&tmpcopy);        INIT_PZVAL(&tmpcopy);         // convert_to_string(&tmpcopy);                walu_call_anony_function(&retval_ptr, NULL, fci, "sz", key, keylen,&tmpcopy);         if(zend_hash_find(Z_ARRVAL_P(resultArray), Z_STRVAL_P(retval_ptr),sizeof(Z_STRVAL_P(retval_ptr)), (void **)&item) == FAILURE && IS_STRING==Z_TYPE_P(retval_ptr)) {            // php_printf("step0/n");            // zend_error(E_ERROR, "element not found");            // MAKE_STD_ZVAL(item);            // array_init(item);            add_assoc_zval(resultArray, Z_STRVAL_P(retval_ptr), *item);         }        // PHPWRITE(Z_STRVAL_P(retval_ptr),strlen(Z_STRVAL_P(retval_ptr)));          // php_printf("step1/n");        if( IS_ARRAY!=Z_TYPE_PP(item)){            php_printf("not array/n");            continue;        }        // add_assoc_zval(resultArray, retval_ptr, *tmpns);          add_next_index_zval(*item,*tmpns);        // /* Toss out old copy */        zval_dtor(&tmpcopy);        zend_hash_move_forward(Z_ARRVAL_P(dataSource));    }        walu_call_user_function(&returnObj, getThis(), "Instance", "z", resultArray);    RETURN_ZVAL(returnObj,1,1);        return; }
开发者ID:wosiwo,项目名称:clinq,代码行数:82,


示例13: php_jam_capture_error_ex

/* event must be initialized with MAKE_STD_ZVAL or similar and array_init before sending here */void php_jam_capture_error_ex(zval *event, int type, const char *error_filename, const uint error_lineno, zend_bool free_event, const char *format, va_list args TSRMLS_DC){	zval **ppzval;	va_list args_cp;	int len;	char *buffer;	char uuid_str[PHP_JAM_UUID_LEN + 1];		TSRMLS_FETCH();		/* Generate unique identifier */	if (!php_jam_generate_uuid(uuid_str)) {		php_jam_original_error_cb(E_WARNING TSRMLS_CC, "Failed to generate uuid");		return;	}	/* Capture superglobals */	if (JAM_G(log_get)) {		_add_assoc_zval_helper(event, "_GET", sizeof("_GET") TSRMLS_CC);	}		if (JAM_G(log_post)) {		_add_assoc_zval_helper(event, "_POST", sizeof("_POST") TSRMLS_CC);	}		if (JAM_G(log_cookie)) {		_add_assoc_zval_helper(event, "_COOKIE", sizeof("_COOKIE") TSRMLS_CC);	}		if (JAM_G(log_session)) {		_add_assoc_zval_helper(event, "_SESSION", sizeof("_SESSION") TSRMLS_CC);	}		if (JAM_G(log_server)) {		_add_assoc_zval_helper(event, "_SERVER", sizeof("_SERVER") TSRMLS_CC);	}		if (JAM_G(log_env)) {		_add_assoc_zval_helper(event, "_ENV", sizeof("_ENV") TSRMLS_CC);	}		if (JAM_G(log_files)) {		_add_assoc_zval_helper(event, "_FILES", sizeof("_FILES") TSRMLS_CC);	}		/* Capture backtrace */	if (JAM_G(log_backtrace)) {		zval *btrace;		ALLOC_INIT_ZVAL(btrace);#if PHP_API_VERSION <= PHP_5_3_X_API_NO		zend_fetch_debug_backtrace(btrace, 0, 0 TSRMLS_CC);#else// TODO: introduce a directive for the amount of stack frames returned instead of hard coded 1000?		zend_fetch_debug_backtrace(btrace, 0, 0 TSRMLS_CC,1000);#endif		add_assoc_zval(event, "backtrace", btrace);	}		va_copy(args_cp, args);	len = vspprintf(&buffer, PG(log_errors_max_len), format, args_cp);	va_end(args_cp);	add_assoc_string(event,	"error_message", buffer, 0);	add_assoc_string(event,	"filename",	(char *)error_filename, 1);		add_assoc_long(event, "line_number", error_lineno);	add_assoc_long(event, "error_type", type);		/*		Set the last logged uuid into _SERVER	*/	add_assoc_string(event, "jam_event_uuid", uuid_str, 1);	add_assoc_long(event, "jam_event_time", time(NULL));	/*		Set the last logged uuid into _SERVER	*/	if (zend_hash_find(&EG(symbol_table), "_SERVER", sizeof("_SERVER"), (void **) &ppzval) == SUCCESS) {		add_assoc_string(*ppzval, "jam_last_uuid", uuid_str, 1);	}	/* Send to backend */	php_jam_storage_store_all(uuid_str, event, type, error_filename, error_lineno TSRMLS_CC);		if (free_event) {		zval_dtor(event);		FREE_ZVAL(event);	}}
开发者ID:brzuchal,项目名称:jam,代码行数:90,


示例14: PHP_METHOD

/* {{{ proto int MongoGridFSFile::write([string filename = null])   Writes this file to the filesystem */PHP_METHOD(MongoGridFSFile, write){	char *filename = 0;	int filename_len, total = 0;	zval *gridfs, *file, *chunks, *query, *cursor, *sort, tmp;	zval **id, **size;	int len;	FILE *fp;	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &filename, &filename_len) == FAILURE) {		return;	}	gridfs = zend_read_property(mongo_ce_GridFSFile, getThis(), "gridfs", strlen("gridfs"), NOISY TSRMLS_CC);	file = zend_read_property(mongo_ce_GridFSFile, getThis(), "file", strlen("file"), NOISY TSRMLS_CC);	if (zend_hash_find(HASH_P(file), "length", strlen("length") + 1, (void**)&size) == FAILURE) {		zend_throw_exception(mongo_ce_GridFSException, "couldn't find file size", 14 TSRMLS_CC);		return;	}	if (Z_TYPE_PP(size) == IS_DOUBLE) {		len = (int)Z_DVAL_PP(size);	} else if (Z_TYPE_PP(size) == IS_LONG) {		len = Z_LVAL_PP(size);	} else if (Z_TYPE_PP(size) == IS_OBJECT && (Z_OBJCE_PP(size) == mongo_ce_Int32 || Z_OBJCE_PP(size) == mongo_ce_Int64)) {		zval *sizet = zend_read_property(mongo_ce_Int64, *size, "value", strlen("value"), NOISY TSRMLS_CC);		if (Z_TYPE_P(sizet) != IS_STRING) {			zval_ptr_dtor(&cursor);			zend_throw_exception(mongo_ce_GridFSException, "couldn't find file size, value object broken", 0 TSRMLS_CC);			return;		}		len = atoi(Z_STRVAL_P(sizet));	} else {		zval_ptr_dtor(&cursor);		zend_throw_exception(mongo_ce_GridFSException, "couldn't find file size, property invalid", 0 TSRMLS_CC);		return;	}	/* Make sure that there's an index on chunks so we can sort by chunk num */	chunks = zend_read_property(mongo_ce_GridFS, gridfs, "chunks", strlen("chunks"), NOISY TSRMLS_CC);	php_mongo_ensure_gridfs_index(&tmp, chunks TSRMLS_CC);	zval_dtor(&tmp);	if (!filename) {		zval **temp;		if (zend_hash_find(HASH_P(file), "filename", strlen("filename") + 1, (void**) &temp) == SUCCESS) {			convert_to_string_ex(temp);			filename = Z_STRVAL_PP(temp);		} else {			zend_throw_exception(mongo_ce_GridFSException, "Cannot find filename", 15 TSRMLS_CC);			return;		}	}	fp = fopen(filename, "wb");	if (!fp) {		zend_throw_exception_ex(mongo_ce_GridFSException, 16 TSRMLS_CC, "could not open destination file %s", filename);		return;	}	zend_hash_find(HASH_P(file), "_id", strlen("_id") + 1, (void**)&id);	MAKE_STD_ZVAL(query);	array_init(query);	zval_add_ref(id);	add_assoc_zval(query, "files_id", *id);	MAKE_STD_ZVAL(cursor);	MONGO_METHOD1(MongoCollection, find, cursor, chunks, query);	MAKE_STD_ZVAL(sort);	array_init(sort);	add_assoc_long(sort, "n", 1);	MONGO_METHOD1(MongoCursor, sort, cursor, cursor, sort);	if ((total = apply_to_cursor(cursor, copy_file, fp, len TSRMLS_CC)) == FAILURE) {		zend_throw_exception(mongo_ce_GridFSException, "error reading chunk of file", 17 TSRMLS_CC);	}	fclose(fp);	zval_ptr_dtor(&cursor);	zval_ptr_dtor(&sort);	zval_ptr_dtor(&query);	RETURN_LONG(total);}
开发者ID:CheowTong,项目名称:mongo-php-driver,代码行数:92,


示例15: php_swoole_aio_onComplete

static void php_swoole_aio_onComplete(swAio_event *event){	int isEOF = SW_FALSE;	int64_t ret;	zval *retval = NULL, *zcallback = NULL, *zwriten = NULL;	zval *zcontent = NULL;	zval **args[2];	file_request *file_req = NULL;	dns_request *dns_req = NULL;	TSRMLS_FETCH_FROM_CTX(sw_thread_ctx ? sw_thread_ctx : NULL);	if (event->type == SW_AIO_DNS_LOOKUP)	{		dns_req = (dns_request *) event->req;		if (dns_req->callback == NULL)		{			php_error_docref(NULL TSRMLS_CC, E_WARNING, "swoole_async: onAsyncComplete callback not found[2]");			return;		}		zcallback = dns_req->callback;	}	else	{		if (zend_hash_find(&php_sw_aio_callback, (char *)&(event->fd), sizeof(event->fd), (void**) &file_req) != SUCCESS)		{			php_error_docref(NULL TSRMLS_CC, E_WARNING, "swoole_async: onAsyncComplete callback not found[1]");			return;		}		if (file_req->callback == NULL && file_req->type == SW_AIO_READ)		{			php_error_docref(NULL TSRMLS_CC, E_WARNING, "swoole_async: onAsyncComplete callback not found[2]");			return;		}		zcallback = file_req->callback;	}	ret = event->ret;	if (ret < 0)	{		php_error_docref(NULL TSRMLS_CC, E_WARNING, "swoole_async: Aio Error: %s[%d]", strerror(event->error), event->error);	}    else if (file_req != NULL)    {        if (ret == 0)        {            bzero(event->buf, event->nbytes);            isEOF = SW_TRUE;        }        else if (file_req->once == 1 && ret < file_req->content_length)        {            php_error_docref(NULL TSRMLS_CC, E_WARNING, "swoole_async: ret_length[%d] < req->length[%d].", (int) ret, file_req->content_length);        }        else if (event->type == SW_AIO_READ)        {            file_req->offset += event->ret;        }    }    if (event->type == SW_AIO_READ)    {        MAKE_STD_ZVAL(zcontent);        args[0] = &file_req->filename;        args[1] = &zcontent;        ZVAL_STRINGL(zcontent, event->buf, ret, 0);    }    else if (event->type == SW_AIO_WRITE)    {        MAKE_STD_ZVAL(zwriten);        args[0] = &file_req->filename;        args[1] = &zwriten;        ZVAL_LONG(zwriten, ret);        if (file_req->once != 1)        {            if (SwooleAIO.mode == SW_AIO_LINUX)            {                free(event->buf);            }            else            {                efree(event->buf);            }        }    }	else if(event->type == SW_AIO_DNS_LOOKUP)	{		MAKE_STD_ZVAL(zcontent);		args[0] = &dns_req->domain;		if (ret < 0)		{			ZVAL_STRING(zcontent, "", 0);		}		else		{			ZVAL_STRING(zcontent, event->buf, 0);		}		args[1] = &zcontent;	}//.........这里部分代码省略.........
开发者ID:190235047,项目名称:swoole-src,代码行数:101,


示例16: zend_string_init

ZEND_API zval *zend_get_constant_ex(zend_string *cname, zend_class_entry *scope, zend_ulong flags){	zend_constant *c;	const char *colon;	zend_class_entry *ce = NULL;	zend_string *class_name;	const char *name = cname->val;	size_t name_len = cname->len;	/* Skip leading // */	if (name[0] == '//') {		name += 1;		name_len -= 1;		cname = NULL;	}	if ((colon = zend_memrchr(name, ':', name_len)) &&	    colon > name && (*(colon - 1) == ':')) {		int class_name_len = colon - name - 1;		size_t const_name_len = name_len - class_name_len - 2;		zend_string *constant_name = zend_string_init(colon + 1, const_name_len, 0);		char *lcname;		zval *ret_constant = NULL;		ALLOCA_FLAG(use_heap)		class_name = zend_string_init(name, class_name_len, 0);		lcname = do_alloca(class_name_len + 1, use_heap);		zend_str_tolower_copy(lcname, name, class_name_len);		if (!scope) {			if (EG(current_execute_data)) {				scope = EG(scope);			} else {				scope = CG(active_class_entry);			}		}		if (class_name_len == sizeof("self")-1 &&		    !memcmp(lcname, "self", sizeof("self")-1)) {			if (UNEXPECTED(!scope)) {				zend_error(E_EXCEPTION | E_ERROR, "Cannot access self:: when no class scope is active");				return NULL;			}			ce = scope;		} else if (class_name_len == sizeof("parent")-1 &&		           !memcmp(lcname, "parent", sizeof("parent")-1)) {			if (UNEXPECTED(!scope)) {				zend_error(E_EXCEPTION | E_ERROR, "Cannot access parent:: when no class scope is active");				return NULL;			} else if (UNEXPECTED(!scope->parent)) {				zend_error(E_EXCEPTION | E_ERROR, "Cannot access parent:: when current class scope has no parent");				return NULL;			} else {				ce = scope->parent;			}		} else if (class_name_len == sizeof("static")-1 &&		           !memcmp(lcname, "static", sizeof("static")-1)) {			ce = zend_get_called_scope(EG(current_execute_data));			if (UNEXPECTED(!ce)) {				zend_error(E_EXCEPTION | E_ERROR, "Cannot access static:: when no class scope is active");				return NULL;			}		} else {			ce = zend_fetch_class(class_name, flags);		}		free_alloca(lcname, use_heap);		if (ce) {			ret_constant = zend_hash_find(&ce->constants_table, constant_name);			if (ret_constant == NULL) {				if ((flags & ZEND_FETCH_CLASS_SILENT) == 0) {					zend_error(E_EXCEPTION | E_ERROR, "Undefined class constant '%s::%s'", class_name->val, constant_name->val);					zend_string_release(class_name);					zend_string_free(constant_name);					return NULL;				}			} else if (Z_ISREF_P(ret_constant)) {				ret_constant = Z_REFVAL_P(ret_constant);			}		}		zend_string_release(class_name);		zend_string_free(constant_name);		if (ret_constant && Z_CONSTANT_P(ret_constant)) {			if (UNEXPECTED(zval_update_constant_ex(ret_constant, 1, ce) != SUCCESS)) {				return NULL;			}		}		return ret_constant;	}	/* non-class constant */	if ((colon = zend_memrchr(name, '//', name_len)) != NULL) {		/* compound constant name */		int prefix_len = colon - name;		size_t const_name_len = name_len - prefix_len - 1;		const char *constant_name = colon + 1;		char *lcname;		size_t lcname_len;		ALLOCA_FLAG(use_heap)		lcname_len = prefix_len + 1 + const_name_len;		lcname = do_alloca(lcname_len + 1, use_heap);//.........这里部分代码省略.........
开发者ID:0xhacking,项目名称:php-src,代码行数:101,


示例17: php_swoole_aio_onComplete

static void php_swoole_aio_onComplete(struct io_event *events, int n){	int i, argc;	int64_t ret;	struct iocb *iocb;	zval *retval;	zval *zcontent;	zval **args[2];	swoole_async_request *req;	MAKE_STD_ZVAL(zcontent);	TSRMLS_FETCH_FROM_CTX(sw_thread_ctx ? sw_thread_ctx : NULL);	for (i = 0; i < n; i++)	{		iocb = (struct iocb *) events[i].obj;		if(zend_hash_find(&php_sw_aio_callback, (char *)&(iocb->aio_fildes), sizeof(iocb->aio_fildes), (void**)&req) != SUCCESS)		{			zend_error(E_WARNING, "swoole_async: onAsyncComplete callback not found[1]");			return;		}		if (req->callback == NULL && req->type == IOCB_CMD_PREAD)		{			zend_error(E_WARNING, "swoole_async: onAsyncComplete callback not found[2]");			return;		}		ret = (int64_t) events[i].res;		if (ret < 0)		{			zend_error(E_WARNING, "swoole_async: Aio Error: %s[%d]", strerror((-ret)), (int) ret);			return;		}		if (ret < req->content_length)		{			zend_error(E_WARNING, "swoole_async: return length < req->length.");		}		args[0] = &req->filename;		if (req->type == IOCB_CMD_PREAD)		{			ZVAL_STRINGL(zcontent, req->file_content, ret, 0);			args[1] = &zcontent;			argc = 2;		}		else		{			argc = 1;		}		if (call_user_function_ex(EG(function_table), NULL, req->callback, &retval, argc, args, 0, NULL TSRMLS_CC) == FAILURE)		{			zend_error(E_WARNING, "swoole_async: onAsyncComplete handler error");			return;		}		//readfile/writefile 只操作一次,完成后释放缓存区并关闭文件		if (req->once == 1)		{			free(req->file_content);			close(iocb->aio_fildes);		}		//free(iocb);	}	zval_ptr_dtor(&zcontent);}
开发者ID:ZheYuan,项目名称:swoole,代码行数:67,


示例18: php_stream_wrapper_log_error

//.........这里部分代码省略.........	if (header_init && context &&		php_stream_context_get_option(context, "http", "content", &tmpzval) == SUCCESS &&		Z_TYPE_PP(tmpzval) == IS_STRING && Z_STRLEN_PP(tmpzval) > 0) {		if (!(have_header & HTTP_HEADER_CONTENT_LENGTH)) {			scratch_len = slprintf(scratch, scratch_len, "Content-Length: %d/r/n", Z_STRLEN_PP(tmpzval));			php_stream_write(stream, scratch, scratch_len);		}		if (!(have_header & HTTP_HEADER_TYPE)) {			php_stream_write(stream, "Content-Type: application/x-www-form-urlencoded/r/n",				sizeof("Content-Type: application/x-www-form-urlencoded/r/n") - 1);			php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Content-type not specified assuming application/x-www-form-urlencoded");		}		php_stream_write(stream, "/r/n", sizeof("/r/n")-1);		php_stream_write(stream, Z_STRVAL_PP(tmpzval), Z_STRLEN_PP(tmpzval));	} else {		php_stream_write(stream, "/r/n", sizeof("/r/n")-1);	}	location[0] = '/0';	if (!EG(active_symbol_table)) {		zend_rebuild_symbol_table(TSRMLS_C);	}	if (header_init) {		zval *ztmp;		MAKE_STD_ZVAL(ztmp);		array_init(ztmp);		ZEND_SET_SYMBOL(EG(active_symbol_table), "http_response_header", ztmp);	}	{		zval **rh;		zend_hash_find(EG(active_symbol_table), "http_response_header", sizeof("http_response_header"), (void **) &rh);		response_header = *rh;	}	if (!php_stream_eof(stream)) {		size_t tmp_line_len;		/* get response header */		if (php_stream_get_line(stream, tmp_line, sizeof(tmp_line) - 1, &tmp_line_len) != NULL) {			zval *http_response;			if (tmp_line_len > 9) {				response_code = atoi(tmp_line + 9);			} else {				response_code = 0;			}			if (context && SUCCESS==php_stream_context_get_option(context, "http", "ignore_errors", &tmpzval)) {				ignore_errors = zend_is_true(*tmpzval TSRMLS_CC);			}			/* when we request only the header, don't fail even on error codes */			if ((options & STREAM_ONLY_GET_HEADERS) || ignore_errors) {				reqok = 1;			}			/* all status codes in the 2xx range are defined by the specification as successful;			 * all status codes in the 3xx range are for redirection, and so also should never			 * fail */			if (response_code >= 200 && response_code < 400) {				reqok = 1;			} else {				switch(response_code) {					case 403:						php_stream_notify_error(context, PHP_STREAM_NOTIFY_AUTH_RESULT,								tmp_line, response_code);
开发者ID:90youth,项目名称:php-src,代码行数:67,


示例19: PHP_METHOD

/* {{{ MongoDBRef::get() */PHP_METHOD(MongoDBRef, get){	zval *db, *ref, *collection, *query;	zval **ns, **id, **dbname;	zend_bool alloced_db = 0;	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Oz", &db, mongo_ce_DB, &ref) == FAILURE) {		return;	}	if (		IS_SCALAR_P(ref) ||		zend_hash_find(HASH_P(ref), "$ref", strlen("$ref") + 1, (void**)&ns) == FAILURE ||		zend_hash_find(HASH_P(ref), "$id", strlen("$id") + 1, (void**)&id) == FAILURE	) {		RETURN_NULL();	}	if (Z_TYPE_PP(ns) != IS_STRING) {		zend_throw_exception(mongo_ce_Exception, "MongoDBRef::get: $ref field must be a string", 10 TSRMLS_CC);		return;	}	/* if this reference contains a db name, we have to switch dbs */	if (zend_hash_find(HASH_P(ref), "$db", strlen("$db") + 1, (void**)&dbname) == SUCCESS) {		mongo_db *temp_db = (mongo_db*)zend_object_store_get_object(db TSRMLS_CC);		/* just to be paranoid, make sure dbname is a string */		if (Z_TYPE_PP(dbname) != IS_STRING) {			zend_throw_exception(mongo_ce_Exception, "MongoDBRef::get: $db field must be a string", 11 TSRMLS_CC);			return;		}		/* if the name in the $db field doesn't match the current db, make up		 * a new db */		if (strcmp(Z_STRVAL_PP(dbname), Z_STRVAL_P(temp_db->name)) != 0) {			zval *new_db_z;			MAKE_STD_ZVAL(new_db_z);			ZVAL_NULL(new_db_z);			MONGO_METHOD1(MongoClient, selectDB, new_db_z, temp_db->link, *dbname);			/* make the new db the current one */			db = new_db_z;			/* so we can dtor this later */			alloced_db = 1;		}	}	/* get the collection */	MAKE_STD_ZVAL(collection);	MONGO_METHOD1(MongoDB, selectCollection, collection, db, *ns);	/* query for the $id */	MAKE_STD_ZVAL(query);	array_init(query);	add_assoc_zval(query, "_id", *id);	zval_add_ref(id);	/* return whatever's there */	MONGO_METHOD1(MongoCollection, findOne, return_value, collection, query);	/* cleanup */	zval_ptr_dtor(&collection);	zval_ptr_dtor(&query);	if (alloced_db) {		zval_ptr_dtor(&db);	}}
开发者ID:BumBliss,项目名称:mongo-php-driver,代码行数:73,


示例20: process_nested_data

static zend_always_inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, zend_long elements, int objprops){	while (elements-- > 0) {		zval key, *data, d, *old_data;		zend_ulong idx;		ZVAL_UNDEF(&key);		if (!php_var_unserialize_ex(&key, p, max, NULL, classes)) {			zval_dtor(&key);			return 0;		}		data = NULL;		ZVAL_UNDEF(&d);		if (!objprops) {			if (Z_TYPE(key) == IS_LONG) {				idx = Z_LVAL(key);numeric_key:				if (UNEXPECTED((old_data = zend_hash_index_find(ht, idx)) != NULL)) {					//??? update hash					var_push_dtor(var_hash, old_data);					data = zend_hash_index_update(ht, idx, &d);				} else {					data = zend_hash_index_add_new(ht, idx, &d);				}			} else if (Z_TYPE(key) == IS_STRING) {				if (UNEXPECTED(ZEND_HANDLE_NUMERIC(Z_STR(key), idx))) {					goto numeric_key;				}				if (UNEXPECTED((old_data = zend_hash_find(ht, Z_STR(key))) != NULL)) {					//??? update hash					var_push_dtor(var_hash, old_data);					data = zend_hash_update(ht, Z_STR(key), &d);				} else {					data = zend_hash_add_new(ht, Z_STR(key), &d);				}			} else {				zval_dtor(&key);				return 0;			}		} else {			if (EXPECTED(Z_TYPE(key) == IS_STRING)) {string_key:				if ((old_data = zend_hash_find(ht, Z_STR(key))) != NULL) {					if (Z_TYPE_P(old_data) == IS_INDIRECT) {						old_data = Z_INDIRECT_P(old_data);					}					var_push_dtor(var_hash, old_data);					data = zend_hash_update_ind(ht, Z_STR(key), &d);				} else {					data = zend_hash_add_new(ht, Z_STR(key), &d);				}			} else if (Z_TYPE(key) == IS_LONG) {				/* object properties should include no integers */				convert_to_string(&key);				goto string_key;			} else {				zval_dtor(&key);				return 0;			}		}		if (!php_var_unserialize_ex(data, p, max, var_hash, classes)) {			zval_dtor(&key);			return 0;		}		if (UNEXPECTED(Z_ISUNDEF_P(data))) {			if (Z_TYPE(key) == IS_LONG) {				zend_hash_index_del(ht, Z_LVAL(key));			} else {				zend_hash_del_ind(ht, Z_STR(key));			}		} else {			var_push_dtor(var_hash, data);		}		zval_dtor(&key);		if (elements && *(*p-1) != ';' && *(*p-1) != '}') {			(*p)--;			return 0;		}	}	return 1;}
开发者ID:Freeaqingme,项目名称:php-src,代码行数:89,


示例21: PHP_METHOD

/** {{{ proto bool Win/Gdi/Window::endPaint( paint_data );		Marks the end of painting in the specified window.*/PHP_METHOD( WinGdiWindow, endPaint ){	wingdi_devicecontext_object * dc_object;	wingdi_window_object        * window_object = zend_object_store_get_object( getThis() TSRMLS_CC );	HashTable                   * paint_data;	PAINTSTRUCT                   paint_struct;	WINGDI_ERROR_HANDLING();	if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "h", &paint_data ) == FAILURE )		return;	WINGDI_RESTORE_ERRORS();	// Error checking	// Not sure about the error messages	if ( ! zend_hash_exists( paint_data, "hdc", strlen( "hdc" ) + 1 ) )	{		php_error( E_ERROR, "no 'hdc' element found in array" );		return;	}	else if ( ! zend_hash_exists( paint_data, "erase", strlen( "erase" ) + 1 ) )	{		php_error( E_ERROR, "no 'erase' element found in array" );		return;	}	else if ( ! zend_hash_exists( paint_data, "paint", strlen( "paint" ) + 1 ) )	{		php_error( E_ERROR, "no 'paint' element found in array" );		return;	}	else	{		zval ** hdc_element,			 ** erase_element,			 ** paint_element,			 ** left = NULL, ** top = NULL, ** right = NULL, ** bottom = NULL;		HashTable * paint_rect;		zend_hash_find( paint_data, "hdc", strlen( "hdc" ) + 1, ( void ** ) &hdc_element );		dc_object = ( wingdi_devicecontext_object * ) zend_objects_get_address( * hdc_element TSRMLS_CC );		paint_struct.hdc = dc_object->hdc;		zend_hash_find( paint_data, "erase", strlen( "erase" ) + 1, ( void ** ) &erase_element );		paint_struct.fErase = Z_BVAL_PP( erase_element );		zend_hash_find( paint_data, "paint", strlen( "paint" ) + 1, ( void ** ) &paint_element );		if ( Z_TYPE_PP( paint_element ) != IS_ARRAY || zend_hash_num_elements( Z_ARRVAL_PP( paint_element ) ) < 4 )		{			php_error( E_ERROR, "expected an array of for elements for 'paint' element of array" );			return;		}		paint_rect = Z_ARRVAL_PP( paint_element );		// TODO: error checking		zend_hash_index_find( paint_rect, 0, ( void ** ) &left );		zend_hash_index_find( paint_rect, 1, ( void ** ) &top );		zend_hash_index_find( paint_rect, 2, ( void ** ) &right );		zend_hash_index_find( paint_rect, 3, ( void ** ) &bottom );		paint_struct.rcPaint.left = Z_LVAL_PP( left );		paint_struct.rcPaint.top = Z_LVAL_PP( top );		paint_struct.rcPaint.right = Z_LVAL_PP( right );		paint_struct.rcPaint.bottom = Z_LVAL_PP( bottom );		RETURN_BOOL( EndPaint( window_object->window_handle, &paint_struct ) );	}}
开发者ID:winapiforphp,项目名称:gdi,代码行数:67,


示例22: php_mongo_enumerate_collections

static void php_mongo_enumerate_collections(INTERNAL_FUNCTION_PARAMETERS, int full_collection){	zend_bool system_col = 0;	zval *nss, *collection, *cursor, *list, *next;	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &system_col) == FAILURE) {		return;	}  // select db.system.namespaces collection  MAKE_STD_ZVAL(nss);  ZVAL_STRING(nss, "system.namespaces", 1);  MAKE_STD_ZVAL(collection);  MONGO_METHOD1(MongoDB, selectCollection, collection, getThis(), nss);  // list to return  MAKE_STD_ZVAL(list);  array_init(list);  // do find  MAKE_STD_ZVAL(cursor);  MONGO_METHOD(MongoCollection, find, cursor, collection);  // populate list  MAKE_STD_ZVAL(next);  MONGO_METHOD(MongoCursor, getNext, next, cursor);  while (!IS_SCALAR_P(next)) {    zval *c, *zname;    zval **collection;    char *name, *first_dot, *system;    // check that the ns is valid and not an index (contains $)    if (zend_hash_find(HASH_P(next), "name", 5, (void**)&collection) == FAILURE ||        strchr(Z_STRVAL_PP(collection), '$')) {      zval_ptr_dtor(&next);      MAKE_STD_ZVAL(next);      ZVAL_NULL(next);      MONGO_METHOD(MongoCursor, getNext, next, cursor);      continue;    }    first_dot = strchr(Z_STRVAL_PP(collection), '.');    system = strstr(Z_STRVAL_PP(collection), ".system.");    // check that this isn't a system ns    if (!system_col && (system && first_dot == system) ||      (name = strchr(Z_STRVAL_PP(collection), '.')) == 0) {      zval_ptr_dtor(&next);      MAKE_STD_ZVAL(next);      ZVAL_NULL(next);      MONGO_METHOD(MongoCursor, getNext, next, cursor);      continue;    }    // take a substring after the first "."    name++;    // "foo." was allowed in earlier versions    if (name == '/0') {      zval_ptr_dtor(&next);      MAKE_STD_ZVAL(next);      ZVAL_NULL(next);      MONGO_METHOD(MongoCursor, getNext, next, cursor);      continue;    }	if (full_collection) {		MAKE_STD_ZVAL(c);		ZVAL_NULL(c);		MAKE_STD_ZVAL(zname);		ZVAL_NULL(zname);		// name must be copied because it is a substring of		// a string that will be garbage collected in a sec		ZVAL_STRING(zname, name, 1);		MONGO_METHOD1(MongoDB, selectCollection, c, getThis(), zname);		add_next_index_zval(list, c);		zval_ptr_dtor(&zname);	} else {		add_next_index_string(list, name, 1);	}    zval_ptr_dtor(&next);    MAKE_STD_ZVAL(next);    MONGO_METHOD(MongoCursor, getNext, next, cursor);  }  zval_ptr_dtor(&next);  zval_ptr_dtor(&nss);  zval_ptr_dtor(&cursor);  zval_ptr_dtor(&collection);//.........这里部分代码省略.........
开发者ID:cockatoo-org,项目名称:mongo-php-driver,代码行数:101,


示例23: PHP_METHOD

/** {{{ public ZeStatus::getBrief() */PHP_METHOD(ze_status, getBrief) {	zval *  self      = NULL;	zval *  brief     = NULL;	zval *  name_z    = NULL;	char *  name      = NULL;	int     name_len  = 0;	zval ** msg_pp    = NULL;	zval *  msg_p     = NULL;	zval *  msg       = NULL;	zval *  is_debug  = NULL;	char *  debug_msg = NULL;	int     len       = 0;	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s"							, &name, &name_len							) == FAILURE) {		WRONG_PARAM_COUNT;	}	self = getThis();	brief = zend_read_property(ze_status_ce, self, ZEND_STRL(ZE_BRIEF), 1 TSRMLS_CC);		if (!brief) {		RETURN_NULL();	}	do {		if (Z_TYPE_P(brief) == IS_ARRAY && name_len) {			if (zend_hash_find(Z_ARRVAL_P(brief), name, name_len + 1, (void **) &msg_pp) == SUCCESS) {				ALLOC_INIT_ZVAL(msg);				*msg = **msg_pp;				break;			}		} else if (Z_TYPE_P(brief) == IS_OBJECT && name_len) {			msg_p = zend_read_property(Z_OBJCE_P(brief), brief, name, name_len , 1 TSRMLS_CC);			ALLOC_INIT_ZVAL(msg);			*msg = *msg_p;			break;		} else if (Z_TYPE_P(brief) == IS_STRING) {			ALLOC_INIT_ZVAL(msg);			*msg = *brief;			break;		}	} while(0);	if (!msg) {		RETURN_NULL();	}		zval_copy_ctor(msg);		ALLOC_INIT_ZVAL(is_debug);	if (zend_get_constant(ZEND_STRL(ZE_DEBUG), is_debug TSRMLS_CC)) {		convert_to_boolean(is_debug);		name_z = zend_read_property(ze_status_ce, self, ZEND_STRL(ZE_NAME), 0 TSRMLS_CC);		if (Z_BVAL_P(is_debug) && Z_TYPE_P(name_z) == IS_STRING) {			len = spprintf(&debug_msg, len, "[%s]%s", Z_STRVAL_P(name_z), Z_STRVAL_P(msg));			zval_dtor(msg);			FREE_ZVAL(msg);			ALLOC_INIT_ZVAL(msg);			ZVAL_STRINGL(msg, debug_msg, len, 1);			efree(debug_msg);		}	}	FREE_ZVAL(is_debug);		RETURN_ZVAL(msg, 1, 1);}
开发者ID:eixom,项目名称:zoeeyphp,代码行数:73,


示例24: fcgi_read_request

//.........这里部分代码省略.........				zend_hash_update(req->env, "FCGI_ROLE", sizeof("FCGI_ROLE"), &val, sizeof(char*), NULL);				break;			default:				return 0;		}		if (safe_read(req, &hdr, sizeof(fcgi_header)) != sizeof(fcgi_header) ||		    hdr.version < FCGI_VERSION_1) {			return 0;		}		len = (hdr.contentLengthB1 << 8) | hdr.contentLengthB0;		padding = hdr.paddingLength;		while (hdr.type == FCGI_PARAMS && len > 0) {			if (len + padding > FCGI_MAX_LENGTH) {				return 0;			}			if (safe_read(req, buf, len+padding) != len+padding) {				req->keep = 0;				return 0;			}			if (!fcgi_get_params(req, buf, buf+len)) {				req->keep = 0;				return 0;			}			if (safe_read(req, &hdr, sizeof(fcgi_header)) != sizeof(fcgi_header) ||			    hdr.version < FCGI_VERSION_1) {				req->keep = 0;				return 0;			}			len = (hdr.contentLengthB1 << 8) | hdr.contentLengthB0;			padding = hdr.paddingLength;		}	} else if (hdr.type == FCGI_GET_VALUES) {		unsigned char *p = buf + sizeof(fcgi_header);		HashPosition pos;		char * str_index;		uint str_length;		ulong num_index;		int key_type;		zval ** value;		if (safe_read(req, buf, len+padding) != len+padding) {			req->keep = 0;			return 0;		}		if (!fcgi_get_params(req, buf, buf+len)) {			req->keep = 0;			return 0;		}		zend_hash_internal_pointer_reset_ex(req->env, &pos);		while ((key_type = zend_hash_get_current_key_ex(req->env, &str_index, &str_length, &num_index, 0, &pos)) != HASH_KEY_NON_EXISTENT) {			int zlen;			zend_hash_move_forward_ex(req->env, &pos);			if (key_type != HASH_KEY_IS_STRING) {				continue;			}			if (zend_hash_find(&fcgi_mgmt_vars, str_index, str_length, (void**) &value) != SUCCESS) {				continue;			}			--str_length;			zlen = Z_STRLEN_PP(value);			if ((p + 4 + 4 + str_length + zlen) >= (buf + sizeof(buf))) {				break;			}			if (str_length < 0x80) {				*p++ = str_length;			} else {				*p++ = ((str_length >> 24) & 0xff) | 0x80;				*p++ = (str_length >> 16) & 0xff;				*p++ = (str_length >> 8) & 0xff;				*p++ = str_length & 0xff;			}			if (zlen < 0x80) {				*p++ = zlen;			} else {				*p++ = ((zlen >> 24) & 0xff) | 0x80;				*p++ = (zlen >> 16) & 0xff;				*p++ = (zlen >> 8) & 0xff;				*p++ = zlen & 0xff;			}			memcpy(p, str_index, str_length);			p += str_length;			memcpy(p, Z_STRVAL_PP(value), zlen);			p += zlen;		}		len = p - buf - sizeof(fcgi_header);		len += fcgi_make_header((fcgi_header*)buf, FCGI_GET_VALUES_RESULT, 0, len);		if (safe_write(req, buf, sizeof(fcgi_header)+len) != (int)sizeof(fcgi_header)+len) {			req->keep = 0;			return 0;		}		return 0;	} else {
开发者ID:jormin,项目名称:php-src,代码行数:101,


示例25: php_can_strtr_array

zval * php_can_strtr_array(char *str, int slen, HashTable *hash){    zval **entry;    char  *string_key;    uint   string_key_len;    zval **trans;    zval   ctmp;    ulong num_key;    int minlen = 128*1024;    int maxlen = 0, pos, len, found;    char *key;    HashPosition hpos;    smart_str result = {0};    HashTable tmp_hash;    zend_hash_init(&tmp_hash, zend_hash_num_elements(hash), NULL, NULL, 0);    zend_hash_internal_pointer_reset_ex(hash, &hpos);    while (zend_hash_get_current_data_ex(hash, (void **)&entry, &hpos) == SUCCESS) {        switch (zend_hash_get_current_key_ex(hash, &string_key, &string_key_len, &num_key, 0, &hpos)) {            case HASH_KEY_IS_STRING:                len = string_key_len-1;                if (len < 1) {                    zend_hash_destroy(&tmp_hash);                    return NULL;                }                zend_hash_add(&tmp_hash, string_key, string_key_len, entry, sizeof(zval*), NULL);                if (len > maxlen) {                    maxlen = len;                }                if (len < minlen) {                    minlen = len;                }                break;            case HASH_KEY_IS_LONG:                Z_TYPE(ctmp) = IS_LONG;                Z_LVAL(ctmp) = num_key;                convert_to_string(&ctmp);                len = Z_STRLEN(ctmp);                zend_hash_add(&tmp_hash, Z_STRVAL(ctmp), len+1, entry, sizeof(zval*), NULL);                zval_dtor(&ctmp);                if (len > maxlen) {                    maxlen = len;                }                if (len < minlen) {                    minlen = len;                }                break;        }        zend_hash_move_forward_ex(hash, &hpos);    }    key = emalloc(maxlen+1);    pos = 0;    while (pos < slen) {        if ((pos + maxlen) > slen) {            maxlen = slen - pos;        }        found = 0;        memcpy(key, str+pos, maxlen);        for (len = maxlen; len >= minlen; len--) {            key[len] = 0;            if (zend_hash_find(&tmp_hash, key, len+1, (void**)&trans) == SUCCESS) {                char *tval;                int tlen;                zval tmp;                if (Z_TYPE_PP(trans) != IS_STRING) {                    tmp = **trans;                    zval_copy_ctor(&tmp);                    convert_to_string(&tmp);                    tval = Z_STRVAL(tmp);                    tlen = Z_STRLEN(tmp);                } else {                    tval = Z_STRVAL_PP(trans);                    tlen = Z_STRLEN_PP(trans);                }                smart_str_appendl(&result, tval, tlen);                pos += len;                found = 1;                if (Z_TYPE_PP(trans) != IS_STRING) {                    zval_dtor(&tmp);                }                break;            }        }        if (! found) {            smart_str_appendc(&result, str[pos++]);        }    }//.........这里部分代码省略.........
开发者ID:MaxMillion,项目名称:phpcan,代码行数:101,


示例26: cpManagerReload

static void cpManagerReload(int sig){    zval *group_conf = NULL, **v;    group_conf = cpGetConfig(CPGC.ini_file);    int gid = 0;    zval **gid_ptr = NULL;    cpGroup *G = NULL;    if (!Z_BVAL_P(group_conf))    {        cpLog("parse ini file[%s]  reload error!", CPGC.ini_file);    }    else    {        for (zend_hash_internal_pointer_reset(Z_ARRVAL_P(group_conf)); zend_hash_has_more_elements(Z_ARRVAL_P(group_conf)) == SUCCESS; zend_hash_move_forward(Z_ARRVAL_P(group_conf)))        {            zval **config;            zend_hash_get_current_data(Z_ARRVAL_P(group_conf), (void**) &config);            char *name;            uint keylen;            zend_hash_get_current_key_ex(Z_ARRVAL_P(group_conf), &name, &keylen, NULL, 0, NULL);            if (strcmp(name, "common") != 0)            {                if (zend_hash_find(Z_ARRVAL_P(CPGS->group), name, strlen(name) + 1, (void **) &gid_ptr) == SUCCESS)                {                    gid = Z_LVAL_PP(gid_ptr);                    G = &CPGS->G[gid];                }                else                {                    cpLog("can not add datasource when the server runing,if you want add it please restart");                    return;                }                if (pthread_mutex_lock(G->mutex_lock) == 0)                {                    if (zend_hash_find(Z_ARRVAL_PP(config), ZEND_STRS("pool_max"), (void **) &v) == SUCCESS)                    {                        convert_to_long(*v);                        G->worker_max = (int) Z_LVAL_PP(v);                    }                    if (zend_hash_find(Z_ARRVAL_PP(config), ZEND_STRS("pool_min"), (void **) &v) == SUCCESS)                    {                        convert_to_long(*v);                        int new_min = (int) Z_LVAL_PP(v);                        if (new_min > G->worker_min)                        {//增加最小                            while (G->worker_num < new_min)                            {                                cpCreate_worker_mem(G->worker_num, gid);                                G->workers_status[G->worker_num] = CP_WORKER_IDLE;                                G->worker_num++; //先加 线程安全                                int new_pid = cpFork_one_worker(G->worker_num - 1, gid);                                if (new_pid < 0)                                {                                    cpLog("Fork worker process failed. Error: %s [%d]", strerror(errno), errno);                                }                                else                                {                                    G->workers[G->worker_num - 1].pid = new_pid;                                }                            }                        }                        G->worker_min = new_min;                    }                    if (pthread_mutex_unlock(G->mutex_lock) != 0)                    {                        cpLog("pthread_mutex_unlock. Error: %s [%d]", strerror(errno), errno);                    }                }            }            else            {                if (zend_hash_find(Z_ARRVAL_PP(config), ZEND_STRS("recycle_num"), (void **) &v) == SUCCESS)                {                    convert_to_long(*v);                    CPGC.recycle_num = (int) Z_LVAL_PP(v);                }                if (zend_hash_find(Z_ARRVAL_PP(config), ZEND_STRS("idel_time"), (void **) &v) == SUCCESS)                {                    convert_to_long(*v);                    CPGC.idel_time = (int) Z_LVAL_PP(v);                }            }        }        zval_ptr_dtor(&group_conf);    }}
开发者ID:caoge,项目名称:php-cp,代码行数:88,


示例27: FG

/* {{{ php_ssh2_session_connect * Connect to an SSH server with requested methods */LIBSSH2_SESSION *php_ssh2_session_connect(char *host, int port, zval *methods, zval *callbacks){	LIBSSH2_SESSION *session;	int socket;	php_ssh2_session_data *data;	struct timeval tv;	zend_string *hash_lookup_zstring;	tv.tv_sec = FG(default_socket_timeout);	tv.tv_usec = 0;	socket = php_network_connect_socket_to_host(host, port, SOCK_STREAM, 0, &tv, NULL, NULL, NULL, 0, STREAM_SOCKOP_NONE);	if (socket <= 0) {		php_error_docref(NULL, E_WARNING, "Unable to connect to %s on port %d", host, port);		return NULL;	}	data = ecalloc(1, sizeof(php_ssh2_session_data));	data->socket = socket;	session = libssh2_session_init_ex(php_ssh2_alloc_cb, php_ssh2_free_cb, php_ssh2_realloc_cb, data);	if (!session) {		php_error_docref(NULL, E_WARNING, "Unable to initialize SSH2 session");		efree(data);		closesocket(socket);		return NULL;	}	libssh2_banner_set(session, LIBSSH2_SSH_DEFAULT_BANNER " PHP");	/* Override method preferences */	if (methods) {		zval *container;		if (php_ssh2_set_method(session, HASH_OF(methods), "kex", sizeof("kex") - 1, LIBSSH2_METHOD_KEX)) {			php_error_docref(NULL, E_WARNING, "Failed overriding KEX method");		}		if (php_ssh2_set_method(session, HASH_OF(methods), "hostkey", sizeof("hostkey") - 1, LIBSSH2_METHOD_HOSTKEY)) {			php_error_docref(NULL, E_WARNING, "Failed overriding HOSTKEY method");		}		hash_lookup_zstring = zend_string_init("client_to_server", sizeof("client_to_server") - 1, 0);		if ((container = zend_hash_find(HASH_OF(methods), hash_lookup_zstring)) != NULL && Z_TYPE_P(container) == IS_ARRAY) {			if (php_ssh2_set_method(session, HASH_OF(container), "crypt", sizeof("crypt") - 1, LIBSSH2_METHOD_CRYPT_CS)) {				php_error_docref(NULL, E_WARNING, "Failed overriding client to server CRYPT method");			}			if (php_ssh2_set_method(session, HASH_OF(container), "mac", sizeof("mac") - 1, LIBSSH2_METHOD_MAC_CS)) {				php_error_docref(NULL, E_WARNING, "Failed overriding client to server MAC method");			}			if (php_ssh2_set_method(session, HASH_OF(container), "comp", sizeof("comp") - 1, LIBSSH2_METHOD_COMP_CS)) {				php_error_docref(NULL, E_WARNING, "Failed overriding client to server COMP method");			}			if (php_ssh2_set_method(session, HASH_OF(container), "lang", sizeof("lang") - 1, LIBSSH2_METHOD_LANG_CS)) {				php_error_docref(NULL, E_WARNING, "Failed overriding client to server LANG method");			}		}		zend_string_release(hash_lookup_zstring);		hash_lookup_zstring = zend_string_init("server_to_client", sizeof("server_to_client") - 1, 0);		if ((container = zend_hash_find(HASH_OF(methods), hash_lookup_zstring)) != NULL && Z_TYPE_P(container) == IS_ARRAY) {			if (php_ssh2_set_method(session, HASH_OF(container), "crypt", sizeof("crypt") - 1, LIBSSH2_METHOD_CRYPT_SC)) {				php_error_docref(NULL, E_WARNING, "Failed overriding server to client CRYPT method");			}			if (php_ssh2_set_method(session, HASH_OF(container), "mac", sizeof("mac") - 1, LIBSSH2_METHOD_MAC_SC)) {				php_error_docref(NULL, E_WARNING, "Failed overriding server to client MAC method");			}			if (php_ssh2_set_method(session, HASH_OF(container), "comp", sizeof("comp") - 1, LIBSSH2_METHOD_COMP_SC)) {				php_error_docref(NULL, E_WARNING, "Failed overriding server to client COMP method");			}			if (php_ssh2_set_method(session, HASH_OF(container), "lang", sizeof("lang") - 1, LIBSSH2_METHOD_LANG_SC)) {				php_error_docref(NULL, E_WARNING, "Failed overriding server to client LANG method");			}		}		zend_string_release(hash_lookup_zstring);	}	/* Register Callbacks */	if (callbacks) {		/* ignore debug disconnect macerror */		if (php_ssh2_set_callback(session, HASH_OF(callbacks), "ignore", sizeof("ignore") - 1, LIBSSH2_CALLBACK_IGNORE, data)) {			php_error_docref(NULL, E_WARNING, "Failed setting IGNORE callback");		}		if (php_ssh2_set_callback(session, HASH_OF(callbacks), "debug", sizeof("debug") - 1, LIBSSH2_CALLBACK_DEBUG, data)) {			php_error_docref(NULL, E_WARNING, "Failed setting DEBUG callback");		}		if (php_ssh2_set_callback(session, HASH_OF(callbacks), "macerror", sizeof("macerror") - 1, LIBSSH2_CALLBACK_MACERROR, data)) {			php_error_docref(NULL, E_WARNING, "Failed setting MACERROR callback");		}		if (php_ssh2_set_callback(session, HASH_OF(callbacks), "disconnect", sizeof("disconnect") - 1, LIBSSH2_CALLBACK_DISCONNECT, data)) {			php_error_docref(NULL, E_WARNING, "Failed setting DISCONNECT callback");		}	}//.........这里部分代码省略.........
开发者ID:Sean-Der,项目名称:pecl-networking-ssh2,代码行数:101,



注:本文中的zend_hash_find函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ zend_hash_find_ptr函数代码示例
C++ zend_hash_exists函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。