コード例 #1
0
ファイル: validator.c プロジェクト: meibk/cphalcon
/**
 * Phalcon\Mvc\Model\Validator constructor
 *
 * @param array $options
 */
PHP_METHOD(Phalcon_Mvc_Model_Validator, __construct){

	zval *options = NULL;
	zval *a0 = NULL, *a1 = NULL;

	PHALCON_MM_GROW();
	PHALCON_ALLOC_ZVAL_MM(a0);
	array_init(a0);
	zend_update_property(phalcon_mvc_model_validator_ce, this_ptr, SL("_options"), a0 TSRMLS_CC);
	
	PHALCON_ALLOC_ZVAL_MM(a1);
	array_init(a1);
	zend_update_property(phalcon_mvc_model_validator_ce, this_ptr, SL("_messages"), a1 TSRMLS_CC);
	
	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &options) == FAILURE) {
		PHALCON_MM_RESTORE();
		RETURN_NULL();
	}

	if (Z_TYPE_P(options) != IS_ARRAY) { 
		PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "$options argument must be an Array");
		return;
	}
	phalcon_update_property_zval(this_ptr, SL("_options"), options TSRMLS_CC);
	
	PHALCON_MM_RESTORE();
}
コード例 #2
0
ファイル: yaf_route_simple.c プロジェクト: 190589751/yaf
/** {{{ int yaf_route_simple_route(yaf_route_t *route, yaf_request_t *request)
 */
int yaf_route_simple_route(yaf_route_t *route, yaf_request_t *request) {
	zval *module, *controller, *action;
	zval *nmodule, *ncontroller, *naction;

	nmodule	= zend_read_property(yaf_route_simple_ce,
			route, ZEND_STRL(YAF_ROUTE_SIMPLE_VAR_NAME_MODULE), 1, NULL);
	ncontroller = zend_read_property(yaf_route_simple_ce,
			route, ZEND_STRL(YAF_ROUTE_SIMPLE_VAR_NAME_CONTROLLER), 1, NULL);
	naction = zend_read_property(yaf_route_simple_ce,
			route, ZEND_STRL(YAF_ROUTE_SIMPLE_VAR_NAME_ACTION), 1, NULL);

	/* if there is no expect parameter in supervars, then null will be return */
	module 	= yaf_request_query(YAF_GLOBAL_VARS_GET, Z_STR_P(nmodule));
	controller = yaf_request_query(YAF_GLOBAL_VARS_GET, Z_STR_P(ncontroller));
	action = yaf_request_query(YAF_GLOBAL_VARS_GET, Z_STR_P(naction));

	if (!module && !controller && !action) {
		return 0;
	}

	if (module && Z_TYPE_P(module) == IS_STRING && yaf_application_is_module_name(Z_STR_P(module))) {
		zend_update_property(yaf_request_ce, request, ZEND_STRL(YAF_REQUEST_PROPERTY_NAME_MODULE), module);
	}

	if (controller) {
		zend_update_property(yaf_request_ce, request, ZEND_STRL(YAF_REQUEST_PROPERTY_NAME_CONTROLLER), controller);
	}

	if (action) {
		zend_update_property(yaf_request_ce, request, ZEND_STRL(YAF_REQUEST_PROPERTY_NAME_ACTION), action);
	}

	return 1;
}
コード例 #3
0
ファイル: view.c プロジェクト: andresgutierrez/cphalcon
PHP_METHOD(Phalcon_View, __construct){

	zval *a0 = NULL, *a1 = NULL, *a2 = NULL, *a3 = NULL, *a4 = NULL;

	PHALCON_MM_GROW();

	
	PHALCON_INIT_VAR(a0);
	array_init(a0);
	zend_update_property(phalcon_view_ce, this_ptr, "_viewParams", strlen("_viewParams"), a0 TSRMLS_CC);
	
	PHALCON_INIT_VAR(a1);
	array_init(a1);
	zend_update_property(phalcon_view_ce, this_ptr, "_templatesBefore", strlen("_templatesBefore"), a1 TSRMLS_CC);
	
	PHALCON_INIT_VAR(a2);
	array_init(a2);
	zend_update_property(phalcon_view_ce, this_ptr, "_templatesAfter", strlen("_templatesAfter"), a2 TSRMLS_CC);
	
	PHALCON_INIT_VAR(a3);
	array_init(a3);
	zend_update_property(phalcon_view_ce, this_ptr, "_registeredEngines", strlen("_registeredEngines"), a3 TSRMLS_CC);
	
	PHALCON_INIT_VAR(a4);
	array_init(a4);
	zend_update_property(phalcon_view_ce, this_ptr, "_params", strlen("_params"), a4 TSRMLS_CC);

	PHALCON_MM_RESTORE();
}
コード例 #4
0
ファイル: manager.c プロジェクト: digitalhydra/cphalcon
PHP_METHOD(Phalcon_Mvc_Model_Manager, __construct){

	zval *a0 = NULL, *a1 = NULL, *a2 = NULL, *a3 = NULL;

	PHALCON_MM_GROW();

	
	PHALCON_ALLOC_ZVAL_MM(a0);
	array_init(a0);
	zend_update_property(phalcon_mvc_model_manager_ce, this_ptr, SL("_hasMany"), a0 TSRMLS_CC);
	
	PHALCON_ALLOC_ZVAL_MM(a1);
	array_init(a1);
	zend_update_property(phalcon_mvc_model_manager_ce, this_ptr, SL("_hasOne"), a1 TSRMLS_CC);
	
	PHALCON_ALLOC_ZVAL_MM(a2);
	array_init(a2);
	zend_update_property(phalcon_mvc_model_manager_ce, this_ptr, SL("_belongsTo"), a2 TSRMLS_CC);
	
	PHALCON_ALLOC_ZVAL_MM(a3);
	array_init(a3);
	zend_update_property(phalcon_mvc_model_manager_ce, this_ptr, SL("_initialized"), a3 TSRMLS_CC);

	PHALCON_MM_RESTORE();
}
コード例 #5
0
ファイル: status.c プロジェクト: eixom/zoeeyphp
/** {{{ public ZeStatus::__construct()
 */
PHP_METHOD(ze_status, __construct) {
	zval * self           = NULL;
	zval * label          = NULL;
	zval * name           = NULL;
	zval * brief          = NULL;

	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|zz"
							 , &label
							 , &name
							 , &brief
							 ) == FAILURE) {
		WRONG_PARAM_COUNT;
	}

	self = getThis();

	zend_update_property(ze_status_ce, self, ZEND_STRL(ZE_LABEL), label TSRMLS_CC);

	if (name) {
		zend_update_property(ze_status_ce, self, ZEND_STRL(ZE_NAME), name TSRMLS_CC);
	}

	if (brief) {
		zend_update_property(ze_status_ce, self, ZEND_STRL(ZE_BRIEF) , brief TSRMLS_CC);
	}

}
コード例 #6
0
ファイル: memory.c プロジェクト: BlueShark/cphalcon
/**
 * Phalcon\Acl\Adapter\Memory constructor
 */
PHP_METHOD(Phalcon_Acl_Adapter_Memory, __construct){

	zval *a0 = NULL, *a1 = NULL, *a2 = NULL;

	PHALCON_MM_GROW();

	phalcon_update_property_empty_array(phalcon_acl_adapter_memory_ce, this_ptr, SL("_rolesNames") TSRMLS_CC);
	
	phalcon_update_property_empty_array(phalcon_acl_adapter_memory_ce, this_ptr, SL("_roles") TSRMLS_CC);
	
	phalcon_update_property_empty_array(phalcon_acl_adapter_memory_ce, this_ptr, SL("_resources") TSRMLS_CC);
	
	phalcon_update_property_empty_array(phalcon_acl_adapter_memory_ce, this_ptr, SL("_access") TSRMLS_CC);
	
	phalcon_update_property_empty_array(phalcon_acl_adapter_memory_ce, this_ptr, SL("_roleInherits") TSRMLS_CC);
	
	PHALCON_INIT_VAR(a0);
	array_init_size(a0, 1);
	add_assoc_bool_ex(a0, SS("*"), 1);
	zend_update_property(phalcon_acl_adapter_memory_ce, this_ptr, SL("_resourcesNames"), a0 TSRMLS_CC);
	
	PHALCON_INIT_VAR(a1);
	array_init_size(a1, 1);
	
	PHALCON_INIT_VAR(a2);
	array_init_size(a2, 1);
	add_assoc_bool_ex(a2, SS("*"), 1);
	phalcon_array_update_string(&a1, SL("*"), &a2, PH_COPY | PH_SEPARATE TSRMLS_CC);
	zend_update_property(phalcon_acl_adapter_memory_ce, this_ptr, SL("_accessList"), a1 TSRMLS_CC);
	

	PHALCON_MM_RESTORE();
}
コード例 #7
0
ファイル: router.c プロジェクト: peterericchen/cphalcon
/**
 * Phalcon\Mvc\Router constructor
 *
 * @param boolean $defaultRoutes
 */
PHP_METHOD(Phalcon_Mvc_Router, __construct) {

    zval *default_routes = NULL, *routes = NULL, *paths = NULL, *route = NULL;
    zval *a0 = NULL, *a1 = NULL;
    zval *c0 = NULL, *c1 = NULL;

    PHALCON_MM_GROW();

    PHALCON_ALLOC_ZVAL_MM(a0);
    array_init(a0);
    zend_update_property(phalcon_mvc_router_ce, this_ptr, SL("_params"), a0 TSRMLS_CC);

    PHALCON_ALLOC_ZVAL_MM(a1);
    array_init(a1);
    zend_update_property(phalcon_mvc_router_ce, this_ptr, SL("_defaultParams"), a1 TSRMLS_CC);

    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z", &default_routes) == FAILURE) {
        PHALCON_MM_RESTORE();
        RETURN_NULL();
    }

    if (!default_routes) {
        PHALCON_ALLOC_ZVAL_MM(default_routes);
        ZVAL_BOOL(default_routes, 1);
    }

    PHALCON_INIT_VAR(routes);
    array_init(routes);
    if (PHALCON_IS_TRUE(default_routes)) {
        PHALCON_INIT_VAR(paths);
        array_init(paths);
        add_assoc_long_ex(paths, SL("controller")+1, 1);

        PHALCON_INIT_VAR(route);
        object_init_ex(route, phalcon_mvc_router_route_ce);

        PHALCON_INIT_VAR(c0);
        ZVAL_STRING(c0, "#^/([a-zA-Z0-9\\_]+)[/]{0,1}$#", 1);
        PHALCON_CALL_METHOD_PARAMS_2_NORETURN(route, "__construct", c0, paths, PH_CHECK);
        phalcon_array_append(&routes, route, PH_SEPARATE TSRMLS_CC);

        PHALCON_INIT_VAR(paths);
        array_init(paths);
        add_assoc_long_ex(paths, SL("controller")+1, 1);
        add_assoc_long_ex(paths, SL("action")+1, 2);
        add_assoc_long_ex(paths, SL("params")+1, 3);

        PHALCON_INIT_VAR(route);
        object_init_ex(route, phalcon_mvc_router_route_ce);

        PHALCON_INIT_VAR(c1);
        ZVAL_STRING(c1, "#^/([a-zA-Z0-9\\_]+)/([a-zA-Z0-9\\_]+)(/.*)*$#", 1);
        PHALCON_CALL_METHOD_PARAMS_2_NORETURN(route, "__construct", c1, paths, PH_CHECK);
        phalcon_array_append(&routes, route, PH_SEPARATE TSRMLS_CC);
    }

    phalcon_update_property_zval(this_ptr, SL("_routes"), routes TSRMLS_CC);

    PHALCON_MM_RESTORE();
}
コード例 #8
0
ファイル: validator.c プロジェクト: xingskycn/cphalcon
/**
 * Phalcon_Model_Validator constructor
 *
 * @param Phalcon_Model_Base $record
 * @param string $field
 * @param string $value
 * @param array $options
 */
PHP_METHOD(Phalcon_Model_Validator, __construct){

	zval *a0 = NULL, *a1 = NULL, *a2 = NULL;
	zval *v0 = NULL, *v1 = NULL, *v2 = NULL, *v3 = NULL;

	PHALCON_MM_GROW();
	PHALCON_INIT_VAR(a0);
	array_init(a0);
	zend_update_property(phalcon_model_validator_class_entry, this_ptr, "_options", strlen("_options"), a0 TSRMLS_CC);
	PHALCON_INIT_VAR(a1);
	array_init(a1);
	zend_update_property(phalcon_model_validator_class_entry, this_ptr, "_messages", strlen("_messages"), a1 TSRMLS_CC);
	
	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzz|z", &v0, &v1, &v2, &v3) == FAILURE) {
		PHALCON_MM_RESTORE();
		RETURN_NULL();
	}

	
	if (!v3) {
		PHALCON_INIT_VAR(a2);
		array_init(a2);
		PHALCON_CPY_WRT(v3, a2);
	}
	
	phalcon_update_property_zval(this_ptr, "_record", strlen("_record"), v0 TSRMLS_CC);
	phalcon_update_property_zval(this_ptr, "_fieldName", strlen("_fieldName"), v1 TSRMLS_CC);
	phalcon_update_property_zval(this_ptr, "_value", strlen("_value"), v2 TSRMLS_CC);
	phalcon_update_property_zval(this_ptr, "_options", strlen("_options"), v3 TSRMLS_CC);
	PHALCON_MM_RESTORE();
	RETURN_NULL();
}
コード例 #9
0
ファイル: loader.c プロジェクト: fatihzkaratana/cphalcon
PHP_METHOD(Phalcon_Loader, __construct){

	zval *a0 = NULL, *a1 = NULL, *a2 = NULL, *a3 = NULL;

	PHALCON_MM_GROW();

	
	PHALCON_ALLOC_ZVAL_MM(a0);
	array_init(a0);
	zend_update_property(phalcon_loader_ce, this_ptr, SL("_classes"), a0 TSRMLS_CC);
	
	PHALCON_ALLOC_ZVAL_MM(a1);
	array_init(a1);
	add_next_index_stringl(a1, SL("php"), 1);
	zend_update_property(phalcon_loader_ce, this_ptr, SL("_extensions"), a1 TSRMLS_CC);
	
	PHALCON_ALLOC_ZVAL_MM(a2);
	array_init(a2);
	zend_update_property(phalcon_loader_ce, this_ptr, SL("_namespaces"), a2 TSRMLS_CC);
	
	PHALCON_ALLOC_ZVAL_MM(a3);
	array_init(a3);
	zend_update_property(phalcon_loader_ce, this_ptr, SL("_directories"), a3 TSRMLS_CC);

	PHALCON_MM_RESTORE();
}
コード例 #10
0
ファイル: view.c プロジェクト: kenjiroy/cphalcon
/**
 * Phalcon\Mvc\View constructor
 *
 * @param array $options
 */
PHP_METHOD(Phalcon_Mvc_View, __construct){

	zval *options = NULL;
	zval *a0 = NULL, *a1 = NULL, *a2 = NULL;

	PHALCON_MM_GROW();

	
	PHALCON_INIT_VAR(a0);
	array_init(a0);
	zend_update_property(phalcon_mvc_view_ce, this_ptr, SL("_viewParams"), a0 TSRMLS_CC);
	
	PHALCON_INIT_VAR(a1);
	array_init(a1);
	zend_update_property(phalcon_mvc_view_ce, this_ptr, SL("_registeredEngines"), a1 TSRMLS_CC);
	
	PHALCON_INIT_VAR(a2);
	array_init(a2);
	zend_update_property(phalcon_mvc_view_ce, this_ptr, SL("_params"), a2 TSRMLS_CC);
	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z", &options) == FAILURE) {
		PHALCON_MM_RESTORE();
		RETURN_NULL();
	}

	if (!options) {
		PHALCON_INIT_NVAR(options);
	}
	
	phalcon_update_property_zval(this_ptr, SL("_options"), options TSRMLS_CC);
	
	PHALCON_MM_RESTORE();
}
コード例 #11
0
ファイル: gridfs.c プロジェクト: sailthru/mongo-php-driver
PHP_METHOD(MongoGridFS, __construct) {
  zval *zdb, *files = 0, *chunks = 0, *zchunks;

  // chunks is deprecated
  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|zz", &zdb, mongo_ce_DB, &files, &chunks) == FAILURE) {
    return;
  }

  if (!files && !chunks) {
    MAKE_STD_ZVAL(files);
    ZVAL_STRING(files, "fs.files", 1);
    MAKE_STD_ZVAL(chunks);
    ZVAL_STRING(chunks, "fs.chunks", 1);
  }
  else {
    zval *temp_file;
    char *temp;

    if (Z_TYPE_P(files) != IS_STRING || Z_STRLEN_P(files) == 0 ) {
#if ZEND_MODULE_API_NO >= 20060613
        zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 0
                                TSRMLS_CC,
                                "MongoGridFS::__construct(): invalid prefix");
#else
        zend_throw_exception_ex(zend_exception_get_default(), 0 TSRMLS_CC,
                                "MongoGridFS::__construct(): invalid prefix");
#endif /* ZEND_MODULE_API_NO >= 20060613 */
        return;
    }

    MAKE_STD_ZVAL(chunks);
    spprintf(&temp, 0, "%s.chunks", Z_STRVAL_P(files));
    ZVAL_STRING(chunks, temp, 0);

    MAKE_STD_ZVAL(temp_file);
    spprintf(&temp, 0, "%s.files", Z_STRVAL_P(files));
    ZVAL_STRING(temp_file, temp, 0);
    files = temp_file;
  }

  // create files collection
  MONGO_METHOD2(MongoCollection, __construct, return_value, getThis(), zdb, files);

  // create chunks collection
  MAKE_STD_ZVAL(zchunks);
  object_init_ex(zchunks, mongo_ce_Collection);
  MONGO_METHOD2(MongoCollection, __construct, return_value, zchunks, zdb, chunks);

  // add chunks collection as a property
  zend_update_property(mongo_ce_GridFS, getThis(), "chunks", strlen("chunks"), zchunks TSRMLS_CC);
  zend_update_property(mongo_ce_GridFS, getThis(), "filesName", strlen("filesName"), files TSRMLS_CC);
  zend_update_property(mongo_ce_GridFS, getThis(), "chunksName", strlen("chunksName"), chunks TSRMLS_CC);

  // cleanup
  zval_ptr_dtor(&zchunks);

  zval_ptr_dtor(&files);
  zval_ptr_dtor(&chunks);
}
コード例 #12
0
/** {{{ 从文件载入js代码 */
PHP_METHOD(HyperMobile, loadjsfromfile) {
	char *filename;
	int filename_len;
	char *contents;//,*err;
	php_stream *stream;
	int len;
	zval *self,*value;
		/* Parse arguments */
	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) {
		return;
	}
	self=getThis();

	if (strlen(filename) != filename_len) {
		RETURN_FALSE;
	}

	stream = php_stream_open_wrapper(filename, "rb",
				ENFORCE_SAFE_MODE | REPORT_ERRORS,
				NULL);
	if (!stream) {
		RETURN_FALSE;
	}


	if ((len = php_stream_copy_to_mem(stream, &contents, PHP_STREAM_COPY_ALL, 0)) > 0) {

		if (PG(magic_quotes_runtime)) {
			contents = php_addslashes(contents, len, &len, 1 TSRMLS_CC); /* 1 = free source string */
		}
		php_stream_close(stream);
		//
		MAKE_STD_ZVAL(value);
		ZVAL_STRING(value,contents,0);
		zend_update_property(Z_OBJCE_P(self),self,ZEND_STRL("js_content"),value TSRMLS_CC);
		RETURN_TRUE;
	} else if (len == 0) {
		php_stream_close(stream);
		MAKE_STD_ZVAL(value);
		// err = ;
		ZVAL_STRING(value,"file content is empty",0);
		zend_update_property(Z_OBJCE_P(self),self,ZEND_STRL("err_msg"),value TSRMLS_CC);
		zend_update_property_bool(Z_OBJCE_P(self),self,ZEND_STRL("error"),1 TSRMLS_CC);
		RETURN_FALSE;
	} else {
		php_stream_close(stream);
		MAKE_STD_ZVAL(value);
		ZVAL_STRING(value,"unknown error",0);
		zend_update_property(Z_OBJCE_P(self),self,ZEND_STRL("err_msg"),value TSRMLS_CC);
		zend_update_property_bool(Z_OBJCE_P(self),self,ZEND_STRL("error"),1 TSRMLS_CC);
		RETURN_FALSE;
	}

	
}
コード例 #13
0
ファイル: yaf_route_simple.c プロジェクト: 190589751/yaf
/** {{{ yaf_route_t * yaf_route_simple_instance(yaf_route_t *this_ptr, zval *module, zval *controller, zval *action)
 */
yaf_route_t * yaf_route_simple_instance(yaf_route_t *this_ptr, zval *module, zval *controller, zval *action) {
	if (Z_ISUNDEF_P(this_ptr)) {
		object_init_ex(this_ptr, yaf_route_simple_ce);
	}

	zend_update_property(yaf_route_simple_ce, this_ptr, ZEND_STRL(YAF_ROUTE_SIMPLE_VAR_NAME_MODULE), module);
	zend_update_property(yaf_route_simple_ce, this_ptr, ZEND_STRL(YAF_ROUTE_SIMPLE_VAR_NAME_CONTROLLER), controller);
	zend_update_property(yaf_route_simple_ce, this_ptr, ZEND_STRL(YAF_ROUTE_SIMPLE_VAR_NAME_ACTION), action);

	return this_ptr;
}
コード例 #14
0
ファイル: dataserv.c プロジェクト: justpaybank/dataserv
PHP_METHOD(dataserv, create) {

	zval * self = getThis();
	zval * z_start, * z_end, * retval;
	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz",  &z_start, &z_end) == FAILURE) {
		WRONG_PARAM_COUNT;
	}
	zend_update_property(Z_OBJCE_P(self), self, ZEND_STRL("start"), z_start TSRMLS_CC);
	zend_update_property(Z_OBJCE_P(self), self, ZEND_STRL("end"), z_end TSRMLS_CC);

	zend_call_method_with_0_params(&self, Z_OBJCE_P(self), NULL, "insdata", &retval);
}
コード例 #15
0
ファイル: air_router.c プロジェクト: jaykizhou/air
/* {{{ PHP METHODS */
PHP_METHOD(air_router, __construct) {
	AIR_INIT_THIS;

	zval *or_arr;
	MAKE_STD_ZVAL(or_arr);
	array_init(or_arr);
	zval *cr_arr;
	MAKE_STD_ZVAL(cr_arr);
	array_init(cr_arr);

	zend_update_property(air_router_ce, self, ZEND_STRL("_original_rules"), or_arr TSRMLS_CC);
	zend_update_property(air_router_ce, self, ZEND_STRL("_compiled_rules"), cr_arr TSRMLS_CC);
	zval_ptr_dtor(&or_arr);
	zval_ptr_dtor(&cr_arr);
}
コード例 #16
0
ファイル: map_phase.c プロジェクト: FabioBatSilva/php_riak
/* {{{ proto void Riak\MapReduce\Phase\MapPhase->__construct(Riak\MapReduce\Function\Function $function [, bool $keep [, array $arguments]])
Create a new MapPhase */
PHP_METHOD(Riak_MapReduce_Phase_MapPhase, __construct)
{
    zval *zfunction, *zargs;
    zend_bool keep;
    keep = 0;
    zargs = NULL;
    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o|ba", &zfunction, &keep, &zargs) == FAILURE) {
        return;
    }
    zend_update_property(riak_mr_mapphase_ce, getThis(), "function", sizeof("function")-1, zfunction TSRMLS_CC);
    zend_update_property_bool(riak_mr_mapphase_ce, getThis(), "keep", sizeof("keep")-1, keep TSRMLS_CC);
    if (zargs) {
        zend_update_property(riak_mr_mapphase_ce, getThis(), "arg", sizeof("arg")-1, zargs TSRMLS_CC);
    }
}
コード例 #17
0
ファイル: mcphessian.c プロジェクト: Raaaay/mcphessian
/* {{{ constructor, create one new instance like this:
 * $client = new McpackHessianClient('http://xxxx', array('xxx' => 'xxx')),
 * method's declaration is McpackHessianClient($strUrl, $arrOptions).
 **/
PHP_METHOD(McpackHessianClient, __construct) {
	zend_class_entry *ce;
	zval *url, *options, *p_this;

	MAKE_STD_ZVAL(options);
	array_init(options);
	p_this = getThis();

    if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, p_this,
				"Oz|z", &ce, mcphessian_ce_ptr, &url, &options) == FAILURE) {
		return;
	}
	// set the properties of instance
	zend_update_property(mcphessian_ce_ptr, p_this, ZEND_STRL("url"), url TSRMLS_CC);
	zend_update_property(mcphessian_ce_ptr, p_this, ZEND_STRL("options"), options TSRMLS_CC);
}
コード例 #18
0
/** {{{ public ZeActiveString::put($condition, $val)
 */
PHP_METHOD(ze_activestring, put) {
    zval * self       = NULL;
    zval * items      = NULL;
    char * cond       = NULL;
    int    cond_len   = 0;
    char * val        = NULL;
    int    val_len    = 0;



    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss"
                            , &cond, &cond_len
                            , &val , &val_len
                            ) == FAILURE) {
        WRONG_PARAM_COUNT;
    }

    self = getThis();

    items = zend_read_property(ze_activestring_ce, self, ZEND_STRL(ZE_ITEMS), 0 TSRMLS_CC);

    add_assoc_stringl(items, cond, val, val_len, 1);


    zend_update_property(ze_activestring_ce, self, ZEND_STRL(ZE_ITEMS), items TSRMLS_CC);

    RETURN_ZVAL(self, 1, 0);
}
コード例 #19
0
ファイル: swoole_mysql.c プロジェクト: JacketZ/swoole-src
static PHP_METHOD(swoole_mysql, on)
{
    char *name;
    zend_size_t len;
    zval *cb;

    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz", &name, &len, &cb) == FAILURE)
    {
        return;
    }

    mysql_client *client = swoole_get_object(getThis());
    if (!client)
    {
        swoole_php_fatal_error(E_WARNING, "object is not instanceof swoole_mysql.");
        RETURN_FALSE;
    }

    if (strncasecmp("close", name, len) == 0)
    {
        zend_update_property(swoole_mysql_class_entry_ptr, getThis(), ZEND_STRL("onClose"), cb TSRMLS_CC);
        client->onClose = sw_zend_read_property(swoole_mysql_class_entry_ptr, getThis(), ZEND_STRL("onClose"), 0 TSRMLS_CC);
        sw_copy_to_stack(client->onClose, client->_onClose);
    }
    else
    {
        swoole_php_error(E_WARNING, "Unknown event type[%s]", name);
        RETURN_FALSE;
    }
    RETURN_TRUE;
}
コード例 #20
0
ファイル: swoole_http.c プロジェクト: solomylove/swoole-src
static int http_request_on_body(php_http_parser *parser, const char *at, size_t length)
{
    TSRMLS_FETCH_FROM_CTX(sw_thread_ctx ? sw_thread_ctx : NULL);

    http_client *client = parser->data;
    char *body = estrndup(at, length);

    if (client->request.post_form_urlencoded)
    {
        zval *post;
        MAKE_STD_ZVAL(post);
        array_init(post);
        zend_update_property(swoole_http_request_class_entry_ptr, client->zrequest, ZEND_STRL("post"), post TSRMLS_CC);
        sapi_module.treat_data(PARSE_STRING, body, post TSRMLS_CC);
        mergeGlobal(post, client->zrequest, HTTP_GLOBAL_POST);

    }
    else
    {
        client->request.post_content = body;
        client->request.post_length = length;
    }

    return 0;
}
コード例 #21
0
/** {{{ 转换代码 */
PHP_METHOD(HyperMobile, convert) {
	/* 此方法不需要传入参数,返回布尔值表名是否转换正确 */
	zval *self,*jscontent,*result;
	self = getThis();
	jscontent= zend_read_property(Z_OBJCE_P(self),self,ZEND_STRL("js_content"),0 TSRMLS_CC);
	// Z_STRVAL_P(jscontent) //此宏能把zval转换成字符






	//
	MAKE_STD_ZVAL(result);
	ZVAL_STRING(result,Z_STRVAL_P(jscontent),0);
	zend_update_property(Z_OBJCE_P(self),self,ZEND_STRL("objc_content"),result TSRMLS_CC);







	RETURN_TRUE;
}
コード例 #22
0
ファイル: albumiterator.c プロジェクト: maxubd/libspotify-php
PHP_METHOD(SpotifyAlbumIterator, __construct)
{
	zval *thisptr = getThis(), *parent;
	spotifyartist_object *artistobj;
	int timeout = 0;
	
	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &parent, spotifyartist_ce) == FAILURE) {
		return;
	}

	zval *spotifyobject = GET_PROPERTY(spotifyartist_ce, parent, "spotify");
	spotify_object *p = (spotify_object*)zend_object_store_get_object(spotifyobject TSRMLS_CC);

	artistobj = (spotifyartist_object*)zend_object_store_get_object(parent TSRMLS_CC);

	spotifyalbumiterator_object *obj = (spotifyalbumiterator_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
	obj->session = p->session;
	obj->artist = artistobj->artist;
	obj->artistbrowse = sp_artistbrowse_create(p->session, artistobj->artist, SP_ARTISTBROWSE_FULL, spotify_artistbrowse_complete, obj);

	while (!sp_artistbrowse_is_loaded(obj->artistbrowse)) {
		sp_session_process_events(p->session, &timeout);
	}

	obj->position = 0;
	obj->length = sp_artistbrowse_num_albums(obj->artistbrowse);

	zend_update_property(spotifyalbumiterator_ce, getThis(), "spotify", strlen("spotify"), spotifyobject TSRMLS_CC);

	sp_artistbrowse_add_ref(obj->artistbrowse);
}
コード例 #23
0
ファイル: money.c プロジェクト: pborreli/money
PHP_METHOD(Money, __construct)
{
	long amount;
	zval *currency, *currency_obj;

	if (zend_parse_parameters(ZEND_NUM_ARGS(), "lz", &amount, &currency) == FAILURE) {
		return;
	}

	switch(Z_TYPE_P(currency)) {
		case IS_OBJECT:
			if (!instanceof_function(currency_ce, Z_OBJCE_P(currency))) {
				zend_throw_exception(spl_ce_InvalidArgumentException, "Invalid currency object", 0);
				return;
			}
		break;
		case IS_STRING:
			ALLOC_INIT_ZVAL(currency_obj);
			object_init_ex(currency_obj, currency_ce);
			zend_update_property_stringl(currency_ce, currency_obj, CURRENCY_PROP_CURRENCYCODE_WS, Z_STRVAL_P(currency), Z_STRLEN_P(currency));
			currency = currency_obj;
			Z_DELREF_P(currency);
		break;
		default:
			zend_throw_exception(spl_ce_InvalidArgumentException, "Invalid currency value", 0);
			return;
	}

	zend_update_property_long(Z_OBJCE_P(getThis()), getThis(), MONEY_PROP_AMOUNT_WS, amount);
	zend_update_property(Z_OBJCE_P(getThis()), getThis(), MONEY_PROP_CURRENCY_WS, currency);
}
コード例 #24
0
ファイル: backend.c プロジェクト: rcpsec/cphalcon
/**
 * Phalcon_Cache_Backend constructor
 *
 * @param mixed $frontendObject
 * @param array $backendOptions
 */
PHP_METHOD(Phalcon_Cache_Backend, __construct){

	zval *frontend_object = NULL, *backend_options = NULL;
	zval *a0 = NULL;
	zval *r0 = NULL;
	int eval_int;

	PHALCON_MM_GROW();
	
	PHALCON_INIT_VAR(a0);
	array_init(a0);
	zend_update_property(phalcon_cache_backend_ce, this_ptr, SL("_backendOptions"), a0 TSRMLS_CC);
	
	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &frontend_object, &backend_options) == FAILURE) {
		PHALCON_MM_RESTORE();
		RETURN_NULL();
	}

	eval_int = phalcon_array_isset_string(backend_options, SL("prefix")+1);
	if (eval_int) {
		PHALCON_ALLOC_ZVAL_MM(r0);
		phalcon_array_fetch_string(&r0, backend_options, SL("prefix"), PHALCON_NOISY TSRMLS_CC);
		phalcon_update_property_zval(this_ptr, SL("_prefix"), r0 TSRMLS_CC);
	}
	phalcon_update_property_zval(this_ptr, SL("_frontendObject"), frontend_object TSRMLS_CC);
	phalcon_update_property_zval(this_ptr, SL("_backendOptions"), backend_options TSRMLS_CC);
	
	PHALCON_MM_RESTORE();
}
コード例 #25
0
ファイル: process_watcher.c プロジェクト: Lucups/Skyray
skyray_process_watcher_t * skyray_process_watcher_new(skyray_reactor_t *reactor, zval *zprocess, zval *handler)
{
    zval object;
    skyray_process_watcher_t *intern;
    skyray_process_t *process = skyray_process_from_obj(Z_OBJ_P(zprocess));

    if (process->watcher) {
        zend_throw_exception_ex(skyray_ce_InvalidParamException, 0, "The process is already under watching, unable to watch again");
        return NULL;
    }

    object_init_ex(&object, skyray_ce_ProcessWatcher);
    zend_update_property(skyray_ce_ProcessWatcherHandler, handler, ZEND_STRL("watcher"), &object);

    intern = skyray_process_watcher_from_obj(Z_OBJ(object));
    intern->process = process;
    intern->handler = Z_OBJ_P(handler);
    zval_add_ref(handler);
    zval_add_ref(zprocess);

    process->watcher = intern;

    if (skyray_sigchld_count < 0) {
        uv_signal_init(&reactor->loop, &skyray_sigchld);
        skyray_sigchld_count = 0;
    }

    if (skyray_sigchld_count == 0) {
        uv_signal_start(&skyray_sigchld, signal_cb, SIGCHLD);
    }
    skyray_sigchld_count ++;

    return intern;
}
コード例 #26
0
ファイル: loader.c プロジェクト: rcpsec/cphalcon
PHP_METHOD(Phalcon_Loader, __construct){

	zval *a0 = NULL, *a1 = NULL;

	PHALCON_MM_GROW();

	PHALCON_INIT_VAR(a0);
	array_init(a0);
	zend_update_property(phalcon_loader_ce, this_ptr, SL("_namespaces"), a0 TSRMLS_CC);
	
	PHALCON_INIT_VAR(a1);
	array_init(a1);
	zend_update_property(phalcon_loader_ce, this_ptr, SL("_directories"), a1 TSRMLS_CC);

	PHALCON_MM_RESTORE();
}
コード例 #27
0
ファイル: php_cbc.cpp プロジェクト: gunesahmet/php-cryptopp
/* {{{ proto SymmetricModeCbc::__construct(Cryptopp\BlockCipherInterface cipher) */
PHP_METHOD(Cryptopp_SymmetricModeCbc, __construct) {
    zval *cipherObject;

    if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &cipherObject, cryptopp_ce_BlockCipherInterface)) {
        return;
    }

    // get needed cipher elements
    CryptoPP::BlockCipher *cipherEncryptor;
    CryptoPP::BlockCipher *cipherDecryptor;
    std::string *modeName;
    bool cipherMustBeDestructed;

    if (!cryptoppSymmetricModeGetCipherElements("cbc", cipherObject, getThis(), &cipherEncryptor, &cipherDecryptor, &modeName, cipherMustBeDestructed TSRMLS_CC)) {
        RETURN_NULL()
    }

    // instanciate mode encryptor/decryptor
    byte dummyIv[cipherEncryptor->BlockSize()];
    Cbc::Encryption *encryptor = new Cbc::Encryption(cipherEncryptor, cipherMustBeDestructed, dummyIv, cipherEncryptor->BlockSize());
    Cbc::Decryption *decryptor = new Cbc::Decryption(cipherDecryptor, cipherMustBeDestructed, dummyIv, cipherEncryptor->BlockSize());
    setCryptoppSymmetricModeEncryptorPtr(getThis(), encryptor TSRMLS_CC);
    setCryptoppSymmetricModeDecryptorPtr(getThis(), decryptor TSRMLS_CC);

    zend_update_property_stringl(cryptopp_ce_SymmetricModeAbstract, getThis(), "name", 4, modeName->c_str(), modeName->size() TSRMLS_CC);
    delete modeName;

    // hold the cipher object. if not, it can be deleted and associated encryptor/decryptor objects will be deleted too
    zend_update_property(cryptopp_ce_SymmetricModeAbstract, getThis(), "cipher", 6, cipherObject TSRMLS_CC);
}
コード例 #28
0
ファイル: berg.c プロジェクト: henryzxj/berg
/* {{{ proto ProtocolBuffers_DescriptorBuilder ProtocolBuffers_DescriptorBuilder::__construct()
*/
PHP_METHOD(berg_buffers, __construct)
{
	zval *instance = getThis();
	zval fields,options,extension_ranges,*tmp;
	array_init(&fields);
	add_next_index_double(&fields,42.00);
	add_next_index_long(&fields,42);
	php_var_dump(&fields,1);
	zend_update_property(Z_OBJCE_P(instance),instance,ZEND_STRL("fields"),&fields);
	zval_ptr_dtor(&fields);

//	array_init(&options);
//	zend_update_property(berg_buffers_class_entry,instance,ZEND_STRL("options"),&options);
//	zval_ptr_dtor(&options);
//
//	array_init(&extension_ranges);
//	zend_update_property(berg_buffers_class_entry,instance,ZEND_STRL("extension_ranges"),&extension_ranges);
//	zval_ptr_dtor(&extension_ranges);

	zend_string *key = zend_string_init(ZEND_STRL("fields"),0);
	if((tmp=zend_hash_find(Z_OBJPROP_P(instance), key))!=NULL){
		php_var_dump(tmp,1);
	}
	zend_string_release(key);
	//>gdb
	//(gdb) p fields1->u2
	//$1 = {var_flags = 4294967295, next = 4294967295, cache_slot = 4294967295, lineno = 4294967295, num_args = 4294967295, fe_pos = 4294967295, fe_iter_idx = 4294967295}
	//(gdb) p fields1->value->arr->nNumUsed
	//$4 = 1
	//(gdb) p fields1->value->arr->nTableSize
	//$5 = 4294956704
	//(gdb) p fields1->value->arr->nNumOfElements
	//$6 = 0
}
コード例 #29
0
/* {{{ proto MongoGridFSFile::__construct(MongoGridFS gridfs, array file)
   Creates a new MongoGridFSFile object */
PHP_METHOD(MongoGridFSFile, __construct)
{
	zval *gridfs = 0, *file = 0;
	long flags = 0;

	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Oa|l", &gridfs, mongo_ce_GridFS, &file, &flags) == FAILURE) {
		zval *object = getThis();

		ZVAL_NULL(object);
		return;
	}

	zend_update_property(mongo_ce_GridFSFile, getThis(), "gridfs", strlen("gridfs"), gridfs TSRMLS_CC);
	zend_update_property(mongo_ce_GridFSFile, getThis(), "file", strlen("file"), file TSRMLS_CC);
	zend_update_property_long(mongo_ce_GridFSFile, getThis(), "flags", strlen("flags"), flags TSRMLS_CC);
}
コード例 #30
0
ファイル: session.c プロジェクト: meibk/cphalcon
PHP_METHOD(Phalcon_Session, __construct){

	zval *options = NULL;
	zval *a0 = NULL;

	PHALCON_MM_GROW();
	
	PHALCON_ALLOC_ZVAL_MM(a0);
	array_init(a0);
	zend_update_property(phalcon_session_ce, this_ptr, SL("_options"), a0 TSRMLS_CC);
	
	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z", &options) == FAILURE) {
		PHALCON_MM_RESTORE();
		RETURN_NULL();
	}

	if (!options) {
		PHALCON_INIT_VAR(options);
		array_init(options);
	}
	
	phalcon_update_property_zval(this_ptr, SL("_options"), options TSRMLS_CC);
	
	PHALCON_MM_RESTORE();
}