本文整理汇总了C++中INIT_ZVAL函数的典型用法代码示例。如果您正苦于以下问题:C++ INIT_ZVAL函数的具体用法?C++ INIT_ZVAL怎么用?C++ INIT_ZVAL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了INIT_ZVAL函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: PHP_METHOD
/**
* Escapes a string with htmlentities
*
* @param string $value
* @return string
*/
PHP_METHOD(Phalcon_Debug, _escapeString){
zval *value, *charset, *replaced_value;
phalcon_fetch_params(0, 1, 0, &value);
if (Z_TYPE_P(value) == IS_STRING) {
zval line_break;
zval escaped_line_break;
charset = phalcon_fetch_static_property_ce(phalcon_debug_ce, SL("_charset") TSRMLS_CC);
INIT_ZVAL(line_break);
ZVAL_STRING(&line_break, "\n", 0);
INIT_ZVAL(escaped_line_break);
ZVAL_STRING(&escaped_line_break, "\\n", 0);
ALLOC_INIT_ZVAL(replaced_value);
phalcon_fast_str_replace(replaced_value, &line_break, &escaped_line_break, value);
phalcon_htmlentities(return_value, replaced_value, NULL, charset TSRMLS_CC);
phalcon_ptr_dtor(&replaced_value);
return;
}
RETURN_ZVAL(value, 1, 0);
}
开发者ID:Myleft,项目名称:cphalcon,代码行数:33,代码来源:debug.c
示例2: mlfi_body
/* {{{ mlfi_body()
*/
static sfsistat mlfi_body(SMFICTX *ctx, u_char *bodyp, size_t len)
{
zval function_name, retval, *param[1];
int status;
TSRMLS_FETCH();
/* call userland */
INIT_ZVAL(function_name);
ALLOC_ZVAL(param[0]);
INIT_PZVAL(param[0]);
ZVAL_STRING(&function_name, "milter_body", 0);
ZVAL_STRINGL(param[0], (char*)bodyp, len, 1); /*alex*/
/* set the milter context for possible use in API functions */
MG(ctx) = ctx;
MG(state) = MLFI_BODY;
status = call_user_function(CG(function_table), NULL, &function_name, &retval, 1, param TSRMLS_CC);
MG(state) = MLFI_NONE;
zval_ptr_dtor(param);
if (status == SUCCESS && Z_TYPE(retval) == IS_LONG) {
return Z_LVAL(retval);
}
return SMFIS_CONTINUE;
}
开发者ID:do-aki,项目名称:petipeti,代码行数:33,代码来源:php_milter.c
示例3: mlfi_header
/* {{{ mlfi_header()
*/
static sfsistat mlfi_header(SMFICTX *ctx, char *headerf, char *headerv)
{
zval function_name, retval, *param[2];
int status;
TSRMLS_FETCH();
/* call userland */
INIT_ZVAL(function_name);
ALLOC_ZVAL(param[0]);
ALLOC_ZVAL(param[1]);
INIT_PZVAL(param[0]);
INIT_PZVAL(param[1]);
ZVAL_STRING(&function_name, "milter_header", 0);
ZVAL_STRING(param[0], headerf, 1);
ZVAL_STRING(param[1], headerv, 1);
/* set the milter context for possible use in API functions */
MG(ctx) = ctx;
MG(state) = MLFI_HEADER;
status = call_user_function(CG(function_table), NULL, &function_name, &retval, 2, param TSRMLS_CC);
MG(state) = MLFI_NONE;
zval_ptr_dtor(¶m[0]);
zval_ptr_dtor(¶m[1]);
if (status == SUCCESS && Z_TYPE(retval) == IS_LONG) {
return Z_LVAL(retval);
}
return SMFIS_CONTINUE;
}
开发者ID:do-aki,项目名称:petipeti,代码行数:37,代码来源:php_milter.c
示例4: mlfi_connect
/* {{{ mlfi_connect()
*/
static sfsistat mlfi_connect(SMFICTX *ctx, char *hostname, _SOCK_ADDR *hostaddr)
{
zend_file_handle file_handle;
zval function_name, retval, *param[1];
int status;
TSRMLS_FETCH();
/* request startup */
if (php_request_startup(TSRMLS_C)==FAILURE) {
SG(headers_sent) = 1;
SG(request_info).no_headers = 1;
php_request_shutdown((void *) 0);
return SMFIS_TEMPFAIL;
}
/* disable headers */
SG(headers_sent) = 1;
SG(request_info).no_headers = 1;
if (filename == NULL) {
php_printf("No input file specified");
return SMFIS_TEMPFAIL;
}
if (!(file_handle.handle.fp = VCWD_FOPEN(filename, "rb"))) {
php_printf("Could not open input file: %s\n", filename);
return SMFIS_TEMPFAIL;
}
file_handle.type = ZEND_HANDLE_FP;
file_handle.filename = filename;
file_handle.free_filename = 0;
file_handle.opened_path = NULL;
php_execute_script(&file_handle TSRMLS_CC);
/* call userland */
INIT_ZVAL(function_name);
ALLOC_ZVAL(param[0]);
INIT_PZVAL(param[0]);
ZVAL_STRING(&function_name, "milter_connect", 0);
ZVAL_STRING(param[0], hostname, 1);
/* set the milter context for possible use in API functions */
MG(ctx) = ctx;
MG(state) = MLFI_CONNECT;
status = call_user_function(CG(function_table), NULL, &function_name, &retval, 1, param TSRMLS_CC);
MG(state) = MLFI_NONE;
zval_ptr_dtor(param);
if (status == SUCCESS && Z_TYPE(retval) == IS_LONG) {
return Z_LVAL(retval);
}
return SMFIS_CONTINUE;
}
开发者ID:do-aki,项目名称:petipeti,代码行数:62,代码来源:php_milter.c
示例5: mlfi_envfrom
/* {{{ mlfi_envform()
*/
static sfsistat mlfi_envfrom(SMFICTX *ctx, char **argv)
{
zval function_name, retval, *param[1];
int status;
TSRMLS_FETCH();
/* call userland */
INIT_ZVAL(function_name);
ALLOC_ZVAL(param[0]);
INIT_PZVAL(param[0]);
ZVAL_STRING(&function_name, "milter_envfrom", 0);
array_init(param[0]);
while (*argv) {
add_next_index_string(param[0], *argv, 1);
argv++;
}
/* set the milter context for possible use in API functions */
MG(ctx) = ctx;
MG(state) = MLFI_ENVFROM;
status = call_user_function(CG(function_table), NULL, &function_name, &retval, 1, param TSRMLS_CC);
MG(state) = MLFI_NONE;
zval_ptr_dtor(param);
if (status == SUCCESS && Z_TYPE(retval) == IS_LONG) {
return Z_LVAL(retval);
}
return SMFIS_CONTINUE;
}
开发者ID:do-aki,项目名称:petipeti,代码行数:37,代码来源:php_milter.c
示例6: ZEND_MODULE_POST_ZEND_DEACTIVATE_D
static ZEND_MODULE_POST_ZEND_DEACTIVATE_D(phalcon)
{
TSRMLS_FETCH();
#ifndef PHALCON_RELEASE
if (!CG(unclean_shutdown)) {
//phalcon_verify_permanent_zvals(1 TSRMLS_CC);
}
#endif
if (CG(unclean_shutdown)) {
zend_phalcon_globals *pg = PHALCON_VGLOBAL;
INIT_ZVAL(*pg->z_null);
Z_ADDREF_P(pg->z_null);
INIT_PZVAL(pg->z_false);
Z_ADDREF_P(pg->z_false);
ZVAL_FALSE(pg->z_false);
INIT_PZVAL(pg->z_true);
Z_ADDREF_P(pg->z_true);
ZVAL_TRUE(pg->z_true);
INIT_PZVAL(pg->z_zero);
Z_ADDREF_P(pg->z_zero);
ZVAL_LONG(pg->z_zero, 0);
INIT_PZVAL(pg->z_one);
Z_ADDREF_P(pg->z_one);
ZVAL_LONG(pg->z_one, 1);
}
return SUCCESS;
}
开发者ID:naheedakhtar,项目名称:docker-phalcon,代码行数:35,代码来源:phalcon.c
示例7: mlfi_close
/* {{{ mlfi_close()
*/
static sfsistat mlfi_close(SMFICTX *ctx)
{
int ret = SMFIS_CONTINUE;
zval function_name, retval;
int status;
TSRMLS_FETCH();
/* call userland */
INIT_ZVAL(function_name);
ZVAL_STRING(&function_name, "milter_close", 0);
/* set the milter context for possible use in API functions */
MG(ctx) = ctx;
MG(state) = MLFI_CLOSE;
status = call_user_function(CG(function_table), NULL, &function_name, &retval, 0, NULL TSRMLS_CC);
MG(state) = MLFI_NONE;
if (status == SUCCESS && Z_TYPE(retval) == IS_LONG) {
ret = Z_LVAL(retval);
}
php_request_shutdown((void *) 0);
return ret;
}
开发者ID:do-aki,项目名称:petipeti,代码行数:29,代码来源:php_milter.c
示例8: mlfi_init
/* {{{ Init Milter
*/
static int mlfi_init()
{
int ret = 0;
zend_file_handle file_handle;
zval function_name, retval;
int status;
TSRMLS_FETCH();
/* request startup */
if (php_request_startup(TSRMLS_C)==FAILURE) {
SG(headers_sent) = 1;
SG(request_info).no_headers = 1;
php_request_shutdown((void *) 0);
return -1;
}
/* disable headers */
SG(headers_sent) = 1;
SG(request_info).no_headers = 1;
if (filename == NULL) {
php_printf("No input file specified");
return SMFIS_TEMPFAIL;
}
if (!(file_handle.handle.fp = VCWD_FOPEN(filename, "rb"))) {
php_printf("Could not open input file: %s\n", filename);
return SMFIS_TEMPFAIL;
}
file_handle.type = ZEND_HANDLE_FP;
file_handle.filename = filename;
file_handle.free_filename = 0;
file_handle.opened_path = NULL;
php_execute_script(&file_handle TSRMLS_CC);
/* call userland */
INIT_ZVAL(function_name);
ZVAL_STRING(&function_name, "milter_init", 0);
/* set the milter context for possible use in API functions */
MG(state) = MLFI_INIT;
status = call_user_function(CG(function_table), NULL, &function_name, &retval, 0, NULL TSRMLS_CC);
MG(state) = MLFI_NONE;
MG(initialized) = 1;
if (status == SUCCESS && Z_TYPE(retval) == IS_LONG) {
ret = Z_LVAL(retval);
}
php_request_shutdown((void *) 0);
return ret;
}
开发者ID:do-aki,项目名称:petipeti,代码行数:61,代码来源:php_milter.c
示例9: ZEND_METHOD
/* {{{ proto Closure Closure::bind(Closure $old, object $to [, mixed $scope = "static" ] )
Create a closure from another one and bind to another object and scope */
ZEND_METHOD(Closure, bind) /* {{{ */
{
zval *newthis, *zclosure, *scope_arg = NULL;
zend_closure *closure;
zend_class_entry *ce, **ce_p;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oo!|z", &zclosure, zend_ce_closure, &newthis, &scope_arg) == FAILURE) {
RETURN_NULL();
}
closure = (zend_closure *)zend_object_store_get_object(zclosure TSRMLS_CC);
if ((newthis != NULL) && (closure->func.common.fn_flags & ZEND_ACC_STATIC)) {
zend_error(E_WARNING, "Cannot bind an instance to a static closure");
}
if (scope_arg != NULL) { /* scope argument was given */
if (IS_ZEND_STD_OBJECT(*scope_arg)) {
ce = Z_OBJCE_P(scope_arg);
} else if (Z_TYPE_P(scope_arg) == IS_NULL) {
ce = NULL;
} else {
char *class_name;
int class_name_len;
zval tmp_zval;
INIT_ZVAL(tmp_zval);
if (Z_TYPE_P(scope_arg) == IS_STRING) {
class_name = Z_STRVAL_P(scope_arg);
class_name_len = Z_STRLEN_P(scope_arg);
} else {
tmp_zval = *scope_arg;
zval_copy_ctor(&tmp_zval);
convert_to_string(&tmp_zval);
class_name = Z_STRVAL(tmp_zval);
class_name_len = Z_STRLEN(tmp_zval);
}
if ((class_name_len == sizeof("static") - 1) &&
(memcmp("static", class_name, sizeof("static") - 1) == 0)) {
ce = closure->func.common.scope;
}
else if (zend_lookup_class_ex(class_name, class_name_len, NULL, 1, &ce_p TSRMLS_CC) == FAILURE) {
zend_error(E_WARNING, "Class '%s' not found", class_name);
zval_dtor(&tmp_zval);
RETURN_NULL();
} else {
ce = *ce_p;
}
zval_dtor(&tmp_zval);
}
} else { /* scope argument not given; do not change the scope by default */
ce = closure->func.common.scope;
}
zend_create_closure(return_value, &closure->func, ce, newthis TSRMLS_CC);
}
开发者ID:0,项目名称:php-src,代码行数:59,代码来源:zend_closures.c
示例10: PHP_METHOD
/**
* Escapes a HTML attribute string
*
* @param string $attribute
* @return string
*/
PHP_METHOD(Phalcon_Escaper, escapeHtmlAttr){
zval *attribute, *encoding;
phalcon_fetch_params(0, 1, 0, &attribute);
if (Z_TYPE_P(attribute) == IS_STRING && zend_is_true(attribute)) {
zval quoting;
INIT_ZVAL(quoting);
ZVAL_LONG("ing, ENT_QUOTES);
encoding = phalcon_fetch_nproperty_this(this_ptr, SL("_encoding"), PH_NOISY TSRMLS_CC);
phalcon_htmlspecialchars(return_value, attribute, "ing, encoding TSRMLS_CC);
return;
}
RETURN_ZVAL(attribute, 1, 0);
}
开发者ID:100851766,项目名称:cphalcon,代码行数:26,代码来源:escaper.c
示例11: phalcon_http_request_getmethod_helper
static const char* phalcon_http_request_getmethod_helper(TSRMLS_D)
{
zval **value;
const char *method = SG(request_info).request_method;
if (unlikely(!method)) {
zval *_SERVER, key;
INIT_ZVAL(key);
ZVAL_STRING(&key, "REQUEST_METHOD", 0);
phalcon_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC);
value = phalcon_hash_get(Z_ARRVAL_P(_SERVER), &key, BP_VAR_NA);
if (value && Z_TYPE_PP(value) == IS_STRING) {
return Z_STRVAL_PP(value);
}
return "";
}
return method;
}
开发者ID:CreativeOutbreak,项目名称:cphalcon,代码行数:21,代码来源:request.c
示例12: mlfi_abort
/* {{{ mlfi_abort()
*/
static sfsistat mlfi_abort(SMFICTX *ctx)
{
zval function_name, retval;
int status;
/* call userland */
INIT_ZVAL(function_name);
ZVAL_STRING(&function_name, "milter_abort", 0);
/* set the milter context for possible use in API functions */
MG(ctx) = ctx;
MG(state) = MLFI_ABORT;
status = call_user_function(CG(function_table), NULL, &function_name, &retval, 0, NULL);
MG(state) = MLFI_NONE;
if (status == SUCCESS && Z_TYPE(retval) == IS_LONG) {
return Z_LVAL(retval);
}
return SMFIS_CONTINUE;
}
开发者ID:AmesianX,项目名称:php-src,代码行数:25,代码来源:php_milter.c
示例13: main
int main(int argc, char ** argv)
{
zval t1, * pt2, ** ppt3;
INIT_ZVAL(t1);
Z_TYPE(t1) = IS_LONG;
Z_LVAL(t1) = 54321;
zval_print(&t1);
ALLOC_INIT_ZVAL(pt2);
ZVAL_STRING(pt2, "this is string val.", 1);
zval_print(pt2);
*ppt3 = pt2;
ZVAL_ADDREF(*ppt3);
zval_print(*ppt3);
//zval_copy_ctor(*ppt3);
SEPARATE_ZVAL(ppt3);
zval_print(*ppt3);
zval_print(pt2);
Z_TYPE(t1) = IS_BOOL;
Z_LVAL(t1) = 1;
zval_print(&t1);
Z_TYPE(t1) = IS_DOUBLE;
Z_DVAL(t1) = 20.12;
zval_print(&t1);
/*
zval_dtor(pt2);
FREE_ZVAL(pt2);
zval_dtor(*ppt3);
FREE_ZVAL(*ppt3);
*/
}
开发者ID:langr-org,项目名称:langr,代码行数:36,代码来源:test_val.c
示例14: ZEND_METHOD
/* {{{ proto Closure Closure::bind(Closure $old, object $to [, mixed $scope = "static" ] )
Create a closure from another one and bind to another object and scope */
ZEND_METHOD(Closure, bind)
{
zval *newthis, *zclosure, *scope_arg = NULL;
zend_closure *closure;
zend_class_entry *ce, **ce_p;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oo!|z", &zclosure, zend_ce_closure, &newthis, &scope_arg) == FAILURE) {
RETURN_NULL();
}
closure = (zend_closure *)zend_object_store_get_object(zclosure TSRMLS_CC);
if ((newthis != NULL) && (closure->func.common.fn_flags & ZEND_ACC_STATIC)) {
zend_error(E_WARNING, "Cannot bind an instance to a static closure");
}
if (newthis == NULL && !(closure->func.common.fn_flags & ZEND_ACC_STATIC)
&& closure->func.common.scope && closure->func.type == ZEND_INTERNAL_FUNCTION) {
zend_error(E_WARNING, "Cannot unbind $this of internal method");
return;
}
if (scope_arg != NULL) { /* scope argument was given */
if (IS_ZEND_STD_OBJECT(*scope_arg)) {
ce = Z_OBJCE_P(scope_arg);
} else if (Z_TYPE_P(scope_arg) == IS_NULL) {
ce = NULL;
} else {
char *class_name;
int class_name_len;
zval tmp_zval;
INIT_ZVAL(tmp_zval);
if (Z_TYPE_P(scope_arg) == IS_STRING) {
class_name = Z_STRVAL_P(scope_arg);
class_name_len = Z_STRLEN_P(scope_arg);
} else {
tmp_zval = *scope_arg;
zval_copy_ctor(&tmp_zval);
convert_to_string(&tmp_zval);
class_name = Z_STRVAL(tmp_zval);
class_name_len = Z_STRLEN(tmp_zval);
}
if ((class_name_len == sizeof("static") - 1) &&
(memcmp("static", class_name, sizeof("static") - 1) == 0)) {
ce = closure->func.common.scope;
}
else if (zend_lookup_class_ex(class_name, class_name_len, NULL, 1, &ce_p TSRMLS_CC) == FAILURE) {
zend_error(E_WARNING, "Class '%s' not found", class_name);
zval_dtor(&tmp_zval);
RETURN_NULL();
} else {
ce = *ce_p;
}
zval_dtor(&tmp_zval);
}
} else { /* scope argument not given; do not change the scope by default */
ce = closure->func.common.scope;
}
/* verify that we aren't binding internal function to a wrong scope */
if (closure->func.type == ZEND_INTERNAL_FUNCTION && closure->func.common.scope != NULL) {
if (ce && !instanceof_function(ce, closure->func.common.scope TSRMLS_CC)) {
zend_error(E_WARNING, "Cannot bind function %s::%s to scope class %s", closure->func.common.scope->name, closure->func.common.function_name, ce->name);
return;
}
if (ce && newthis && (closure->func.common.fn_flags & ZEND_ACC_STATIC) == 0 &&
!instanceof_function(Z_OBJCE_P(newthis), closure->func.common.scope TSRMLS_CC)) {
zend_error(E_WARNING, "Cannot bind internal method %s::%s() to object of class %s", closure->func.common.scope->name, closure->func.common.function_name, Z_OBJCE_P(newthis)->name);
return;
}
}
zend_create_closure(return_value, &closure->func, ce, newthis TSRMLS_CC);
}
开发者ID:nishisan,项目名称:scripts,代码行数:78,代码来源:zend_closures.c
示例15: money_handler_do_operation
static int money_handler_do_operation(zend_uchar opcode, zval *result, zval *op1, zval *op2)
{
zval *currency1 = NULL, *currency2 = NULL, *currency_result = NULL;
long amount1, amount2, amount_result;
switch (TYPE_PAIR(Z_TYPE_P(op1), Z_TYPE_P(op2))) {
case TYPE_PAIR(IS_OBJECT, IS_OBJECT):
if (!instanceof_function(Z_OBJCE_P(op1), money_ce) || !instanceof_function(Z_OBJCE_P(op2), money_ce)) {
return FAILURE;
}
currency1 = zend_read_property(Z_OBJCE_P(op1), op1, MONEY_PROP_CURRENCY_WS, 0);
currency2 = zend_read_property(Z_OBJCE_P(op2), op2, MONEY_PROP_CURRENCY_WS, 0);
if (Z_OBJ_HANDLER_P(currency1, compare_objects)(currency1, currency2) != 0) {
zend_throw_exception(CurrencyMismatchException_ce, "Currencies don't match", 0);
ZVAL_NULL(result);
return SUCCESS;
}
amount1 = Z_LVAL_P(zend_read_property(Z_OBJCE_P(op1), op1, MONEY_PROP_AMOUNT_WS, 0));
amount2 = Z_LVAL_P(zend_read_property(Z_OBJCE_P(op2), op2, MONEY_PROP_AMOUNT_WS, 0));
currency_result = currency1;
break;
case TYPE_PAIR(IS_LONG, IS_OBJECT): /* negate */
if (!instanceof_function(Z_OBJCE_P(op2), money_ce)) {
return FAILURE;
}
if (Z_LVAL_P(op1) != 0) {
return FAILURE; /* I said negate */
}
amount1 = 0;
amount2 = Z_LVAL_P(zend_read_property(Z_OBJCE_P(op2), op2, MONEY_PROP_AMOUNT_WS, 0));
currency_result = zend_read_property(Z_OBJCE_P(op2), op2, MONEY_PROP_CURRENCY_WS, 0);
break;
default :
return FAILURE;
}
INIT_ZVAL(*result);
switch (opcode) {
case ZEND_ADD:
if (UNEXPECTED((amount1 & LONG_SIGN_MASK) == (amount2 & LONG_SIGN_MASK)
&& (amount1 & LONG_SIGN_MASK) != ((amount1 + amount2) & LONG_SIGN_MASK))) {
zend_throw_exception(spl_ce_OverflowException, "Integer overflow", 0);
return FAILURE;
}
amount_result = amount1 + amount2;
goto success;
break;
case ZEND_SUB:
{
amount_result = amount1 - amount2;
if (amount_result == LONG_MIN) {
zend_throw_exception(spl_ce_OverflowException, "Integer negative overflow", 0);
return FAILURE;
}
goto success;
}
break;
default:
return FAILURE;
break;
}
success:
CREATE_NEW_MONEY_OBJ(result, amount_result, currency_result);
return SUCCESS;
}
开发者ID:Peekmo,项目名称:money,代码行数:70,代码来源:money.c
示例16: PHP_METHOD
/**
* Set the background color of an image. This is only useful for images
* with alpha transparency.
*
* @param string $color hexadecimal color value
* @param int $opacity background opacity: 0-100
* @return Phalcon\Image\Adapter
*/
PHP_METHOD(Phalcon_Image_Adapter, background) {
zval *color, *opacity = NULL;
zval *tmp_color = NULL, *r = NULL, *g = NULL, *b = NULL;
long i;
char *c;
zval tmp;
PHALCON_MM_GROW();
phalcon_fetch_params(1, 1, 1, &color, &opacity);
if (Z_TYPE_P(color) != IS_STRING) {
PHALCON_SEPARATE_PARAM(color);
convert_to_string(color);
}
c = Z_STRVAL_P(color);
if (Z_STRLEN_P(color) > 0 && c[0] == '#') {
PHALCON_INIT_NVAR(tmp_color);
phalcon_substr(tmp_color, color, 1, 0);
} else {
PHALCON_CPY_WRT_CTOR(tmp_color, color);
}
if (Z_STRLEN_P(tmp_color) == 3) {
/* Convert RGB to RRGGBB */
c = Z_STRVAL_P(tmp_color);
if (!IS_INTERNED(c)) {
STR_REALLOC(c, 7);
}
else {
char* tmp = ecalloc(7, 1);
memcpy(tmp, c, Z_STRLEN_P(tmp_color));
c = tmp;
}
c[6] = '\0';
c[5] = c[2];
c[4] = c[2];
c[3] = c[1];
c[2] = c[1];
c[1] = c[0];
ZVAL_STRING(tmp_color, c, 0);
}
if (Z_STRLEN_P(tmp_color) < 6) {
PHALCON_THROW_EXCEPTION_STR(phalcon_image_exception_ce, "Color is not valid");
return;
}
INIT_ZVAL(tmp);
Z_TYPE(tmp) = IS_STRING;
ZVAL_STRINGL(&tmp, Z_STRVAL_P(tmp_color), 2, 0);
PHALCON_INIT_NVAR(r);
_php_math_basetozval(&tmp, 16, r);
Z_STRVAL(tmp) += 2;
PHALCON_INIT_NVAR(g);
_php_math_basetozval(&tmp, 16, g);
Z_STRVAL(tmp) += 2;
PHALCON_INIT_NVAR(b);
_php_math_basetozval(&tmp, 16, b);
if (!opacity) {
PHALCON_INIT_NVAR(opacity);
ZVAL_LONG(opacity, 100);
} else {
PHALCON_SEPARATE_PARAM(opacity);
i = phalcon_get_intval(opacity);
if (i < 1) {
PHALCON_INIT_NVAR(opacity);
ZVAL_LONG(opacity, 1);
} else if (i > 100) {
PHALCON_INIT_NVAR(opacity);
ZVAL_LONG(opacity, 100);
}
}
PHALCON_CALL_METHOD(NULL, this_ptr, "_background", r, g, b, opacity);
RETURN_THIS();
}
开发者ID:9466,项目名称:cphalcon,代码行数:97,代码来源:adapter.c
示例17: PHP_METHOD
/**
* Replaces placeholders from pattern returning a valid PCRE regular expression
*
* @param string $pattern
* @return string
*/
PHP_METHOD(Phalcon_Mvc_Router_Route, compilePattern){
zval *pattern, *compiled_pattern = NULL, *id_pattern;
zval wildcard, *pattern_copy = NULL, *params_pattern;
zval *int_pattern;
PHALCON_MM_GROW();
phalcon_fetch_params(1, 1, 0, &pattern);
PHALCON_CPY_WRT(compiled_pattern, pattern);
/**
* If a pattern contains ':', maybe there are placeholders to replace
*/
if (phalcon_memnstr_str(pattern, SL(":"))) {
/**
* This is a pattern for valid identifiers
*/
PHALCON_INIT_VAR(id_pattern);
ZVAL_STRING(id_pattern, "/([a-zA-Z0-9\\_\\-]+)", 1);
/**
* Replace the module part
*/
if (phalcon_memnstr_str(pattern, SL("/:module"))) {
INIT_ZVAL(wildcard);
ZVAL_STRING(&wildcard, "/:module", 0);
PHALCON_CPY_WRT(pattern_copy, compiled_pattern);
PHALCON_INIT_NVAR(compiled_pattern);
phalcon_fast_str_replace(compiled_pattern, &wildcard, id_pattern, pattern_copy);
}
/**
* Replace the controller placeholder
*/
if (phalcon_memnstr_str(pattern, SL("/:controller"))) {
INIT_ZVAL(wildcard);
ZVAL_STRING(&wildcard, "/:controller", 0);
PHALCON_CPY_WRT(pattern_copy, compiled_pattern);
PHALCON_INIT_NVAR(compiled_pattern);
phalcon_fast_str_replace(compiled_pattern, &wildcard, id_pattern, pattern_copy);
}
/**
* Replace the namespace placeholder
*/
if (phalcon_memnstr_str(pattern, SL("/:namespace"))) {
INIT_ZVAL(wildcard)
ZVAL_STRING(&wildcard, "/:namespace", 0);
PHALCON_CPY_WRT(pattern_copy, compiled_pattern);
PHALCON_INIT_NVAR(compiled_pattern);
phalcon_fast_str_replace(compiled_pattern, &wildcard, id_pattern, pattern_copy);
}
/**
* Replace the action placeholder
*/
if (phalcon_memnstr_str(pattern, SL("/:action"))) {
INIT_ZVAL(wildcard);
ZVAL_STRING(&wildcard, "/:action", 0);
PHALCON_CPY_WRT(pattern_copy, compiled_pattern);
PHALCON_INIT_NVAR(compiled_pattern);
phalcon_fast_str_replace(compiled_pattern, &wildcard, id_pattern, pattern_copy);
}
/**
* Replace the params placeholder
*/
if (phalcon_memnstr_str(pattern, SL("/:params"))) {
INIT_ZVAL(wildcard);
ZVAL_STRING(&wildcard, "/:params", 0);
PHALCON_INIT_VAR(params_pattern);
ZVAL_STRING(params_pattern, "(/.*)*", 1);
PHALCON_CPY_WRT(pattern_copy, compiled_pattern);
PHALCON_INIT_NVAR(compiled_pattern);
phalcon_fast_str_replace(compiled_pattern, &wildcard, params_pattern, pattern_copy);
}
/**
* Replace the int placeholder
*/
if (phalcon_memnstr_str(pattern, SL("/:int"))) {
INIT_ZVAL(wildcard);
ZVAL_STRING(&wildcard, "/:int", 0);
PHALCON_INIT_VAR(int_pattern);
//.........这里部分代码省略.........
开发者ID:11mariom,项目名称:cphalcon,代码行数:101,代码来源:route.c
示例18: call_php
static void call_php(char *name, PARAMDSC *r, int argc, PARAMDSC **argv)
{
do {
zval callback, args[4], *argp[4], return_value;
PARAMVARY *res = (PARAMVARY*)r->dsc_address;
int i;
INIT_ZVAL(callback);
ZVAL_STRING(&callback,name,0);
LOCK();
/* check if the requested function exists */
if (!zend_is_callable(&callback, 0, NULL TSRMLS_CC)) {
break;
}
UNLOCK();
/* create the argument array */
for (i = 0; i < argc; ++i) {
INIT_ZVAL(args[i]);
argp[i] = &args[i];
/* test arg for null */
if (argv[i]->dsc_flags & DSC_null) {
ZVAL_NULL(argp[i]);
continue;
}
switch (argv[i]->dsc_dtype) {
ISC_INT64 l;
struct tm t;
char const *fmt;
char d[64];
case dtype_cstring:
ZVAL_STRING(argp[i], (char*)argv[i]->dsc_address,0);
break;
case dtype_text:
ZVAL_STRINGL(argp[i], (char*)argv[i]->dsc_address, argv[i]->dsc_length,0);
break;
case dtype_varying:
ZVAL_STRINGL(argp[i], ((PARAMVARY*)argv[i]->dsc_address)->vary_string,
((PARAMVARY*)argv[i]->dsc_address)->vary_length,0);
break;
case dtype_short:
if (argv[i]->dsc_scale == 0) {
ZVAL_LONG(argp[i], *(short*)argv[i]->dsc_address);
} else {
ZVAL_DOUBLE(argp[i],
((double)*(short*)argv[i]->dsc_address)/scales[-argv[i]->dsc_scale]);
}
break;
case dtype_long:
if (argv[i]->dsc_scale == 0) {
ZVAL_LONG(argp[i], *(ISC_LONG*)argv[i]->dsc_address);
} else {
ZVAL_DOUBLE(argp[i],
((double)*(ISC_LONG*)argv[i]->dsc_address)/scales[-argv[i]->dsc_scale]);
}
break;
case dtype_int64:
l = *(ISC_INT64*)argv[i]->dsc_address;
if (argv[i]->dsc_scale == 0 && l <= LONG_MAX && l >= LONG_MIN) {
ZVAL_LONG(argp[i], (long)l);
} else {
ZVAL_DOUBLE(argp[i], ((double)l)/scales[-argv[i]->dsc_scale]);
}
break;
case dtype_real:
ZVAL_DOUBLE(argp[i], *(float*)argv[i]->dsc_address);
break;
case dtype_double:
ZVAL_DOUBLE(argp[i], *(double*)argv[i]->dsc_address);
break;
case dtype_sql_date:
isc_decode_sql_date((ISC_DATE*)argv[i]->dsc_address, &t);
ZVAL_STRINGL(argp[i], d, strftime(d, sizeof(d), INI_STR("ibase.dateformat"), &t),1);
break;
case dtype_sql_time:
isc_decode_sql_time((ISC_TIME*)argv[i]->dsc_address, &t);
ZVAL_STRINGL(argp[i], d, strftime(d, sizeof(d), INI_STR("ibase.timeformat"), &t),1);
break;
case dtype_timestamp:
isc_decode_timestamp((ISC_TIMESTAMP*)argv[i]->dsc_address, &t);
ZVAL_STRINGL(argp[i], d, strftime(d, sizeof(d), INI_STR("ibase.timestampformat"), &t),1);
break;
//.........这里部分代码省略.........
开发者ID:1HLtd,项目名称:php-src,代码行数:101,代码来源:php_ibase_udf.c
注:本文中的INIT_ZVAL函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论