本文整理汇总了C++中INIT_ZVAL函数的典型用法代码示例。如果您正苦于以下问题:C++ INIT_ZVAL函数的具体用法?C++ INIT_ZVAL怎么用?C++ INIT_ZVAL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了INIT_ZVAL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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);
*/
}
示例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);
}
示例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;
}