当前位置: 首页>>代码示例>>C++>>正文


C++ convert_to_long_ex函数代码示例

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


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

示例1: PHP_FUNCTION

U_CFUNC PHP_FUNCTION(intltz_create_enumeration)
{
	zval				*arg = NULL;
	StringEnumeration	*se	  = NULL;
	intl_error_reset(NULL);

	/* double indirection to have the zend engine destroy the new zval that
	 * results from separation */
	if (zend_parse_parameters(ZEND_NUM_ARGS(), "|z", &arg) == FAILURE) {
		intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
			"intltz_create_enumeration: bad arguments", 0);
		RETURN_FALSE;
	}

	if (arg == NULL || Z_TYPE_P(arg) == IS_NULL) {
		se = TimeZone::createEnumeration();
	} else if (Z_TYPE_P(arg) == IS_LONG) {
int_offset:
		if (Z_LVAL_P(arg) < (zend_long)INT32_MIN ||
				Z_LVAL_P(arg) > (zend_long)INT32_MAX) {
			intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
				"intltz_create_enumeration: value is out of range", 0);
			RETURN_FALSE;
		} else {
			se = TimeZone::createEnumeration((int32_t) Z_LVAL_P(arg));
		}
	} else if (Z_TYPE_P(arg) == IS_DOUBLE) {
double_offset:
		convert_to_long_ex(arg);
		goto int_offset;
	} else if (Z_TYPE_P(arg) == IS_OBJECT || Z_TYPE_P(arg) == IS_STRING) {
		zend_long lval;
		double dval;
		convert_to_string_ex(arg);
		switch (is_numeric_string(Z_STRVAL_P(arg), Z_STRLEN_P(arg), &lval, &dval, 0)) {
		case IS_DOUBLE:
			zval_ptr_dtor(arg);
			ZVAL_DOUBLE(arg, dval);
			goto double_offset;
		case IS_LONG:
			zval_ptr_dtor(arg);
			ZVAL_LONG(arg, lval);
			goto int_offset;
		}
		/* else call string version */
		se = TimeZone::createEnumeration(Z_STRVAL_P(arg));
	} else {
		intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
			"intltz_create_enumeration: invalid argument type", 0);
		RETURN_FALSE;
	}

	if (se) {
		IntlIterator_from_StringEnumeration(se, return_value);
	} else {
		intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
			"intltz_create_enumeration: error obtaining enumeration", 0);
		RETVAL_FALSE;
	}
}
开发者ID:GreenLightt,项目名称:php-src,代码行数:60,代码来源:timezone_methods.cpp

示例2: TSRMLS_FETCH

  XmlInputStream *resolveEntity(XmlTransaction *txn, XmlManager &mgr, const std::string &systemId, const std::string &publicId)
  {
    bool status = false;
    zval *argv[3], *retval, *func;
    TSRMLS_FETCH();
DEBUG();

    MAKE_STD_ZVAL(func);
    MAKE_STD_ZVAL(retval);
    MAKE_STD_ZVAL(argv[0]);
    MAKE_STD_ZVAL(argv[1]);
    MAKE_STD_ZVAL(argv[2]);
    
    ZVAL_STRING(func, "resolveEntity", (int)1);
    ZVAL_STRINGL(argv[0], (char*)systemId.data(), (int)systemId.length(), 1);
    ZVAL_STRINGL(argv[1], (char*)publicId.data(), (int)publicId.length(), 1);

    if (SUCCESS == call_user_function(EG(function_table),
        &m_userspace, func, retval, 3, argv TSRMLS_CC)) {
      convert_to_long_ex(&retval);
      if (Z_LVAL_P(retval)) {
        //result = std::string(Z_STRVAL_P(argv[2]), Z_STRLEN_P(argv[2]));
        status = true;
      }
    }

    zval_ptr_dtor(&func);
    zval_ptr_dtor(&retval);
    zval_ptr_dtor(&argv[0]);
    zval_ptr_dtor(&argv[1]);
    zval_ptr_dtor(&argv[2]);
    
  //  return status;
    return NULL;
  }
开发者ID:kanbang,项目名称:Colt,代码行数:35,代码来源:php_dbxml_resolver.cpp

示例3: resolveDocument

  bool resolveDocument(XmlTransaction *txn, XmlManager &mgr, const std::string &uri, XmlValue &result)
  {
DEBUG();
    TSRMLS_FETCH();
    bool status = false;
    zval *argv[2], *retval, *func;

    MAKE_STD_ZVAL(func);
    MAKE_STD_ZVAL(retval);
    MAKE_STD_ZVAL(argv[0]);
    MAKE_STD_ZVAL(argv[1]);
    
    ZVAL_STRING(func, "resolveDocument", (int)1);
    ZVAL_STRINGL(argv[0], (char*)uri.data(), (int)uri.length(), 1);

    if (SUCCESS == call_user_function(EG(function_table),
        &m_userspace, func, retval, 2, argv TSRMLS_CC)) {
      convert_to_long_ex(&retval);

      if (Z_LVAL_P(retval)) {
        /* convert argv[1] to an XmlResult */
        result = php_dbxml_wrap_zval(argv[1]);
        status = true;
      }
    }

    zval_ptr_dtor(&func);
    zval_ptr_dtor(&retval);
    zval_ptr_dtor(&argv[0]);
    zval_ptr_dtor(&argv[1]);
    
    return status;
  }
开发者ID:kanbang,项目名称:Colt,代码行数:33,代码来源:php_dbxml_resolver.cpp

示例4: binary_serialize_spec

void binary_serialize_spec(zval* zthis, PHPOutputTransport& transport, HashTable* spec) {
  HashPosition key_ptr;
  zval** val_ptr;

  TSRMLS_FETCH();
  zend_class_entry* ce = zend_get_class_entry(zthis TSRMLS_CC);

  for (zend_hash_internal_pointer_reset_ex(spec, &key_ptr); zend_hash_get_current_data_ex(spec, (void**)&val_ptr, &key_ptr) == SUCCESS; zend_hash_move_forward_ex(spec, &key_ptr)) {
    ulong fieldno;
    if (zend_hash_get_current_key_ex(spec, NULL, NULL, &fieldno, 0, &key_ptr) != HASH_KEY_IS_LONG) {
      throw_tprotocolexception("Bad keytype in TSPEC (expected 'long')", INVALID_DATA);
      return;
    }
    HashTable* fieldspec = Z_ARRVAL_PP(val_ptr);

    // field name
    zend_hash_find(fieldspec, "var", 4, (void**)&val_ptr);
    char* varname = Z_STRVAL_PP(val_ptr);

    // thrift type
    zend_hash_find(fieldspec, "type", 5, (void**)&val_ptr);
    convert_to_long_ex(val_ptr);
    int8_t ttype = Z_LVAL_PP(val_ptr);

    zval* prop = zend_read_property(ce, zthis, varname, strlen(varname), false TSRMLS_CC);
    if (Z_TYPE_P(prop) != IS_NULL) {
      transport.writeI8(ttype);
      transport.writeI16(fieldno);
      binary_serialize(ttype, transport, &prop, fieldspec);
    }
  }
  transport.writeI8(T_STOP); // struct end
}
开发者ID:KirinDave,项目名称:powerset_thrift,代码行数:33,代码来源:php_thrift_protocol.cpp

示例5: gmp_zval_unary_ui_op

/* {{{ gmp_zval_unary_ui_op
 */
static inline void gmp_zval_unary_ui_op(zval *return_value, zval **a_arg, gmp_unary_ui_op_t gmp_op TSRMLS_DC)
{
	mpz_t *gmpnum_result;

	convert_to_long_ex(a_arg);

	INIT_GMP_NUM(gmpnum_result);
	gmp_op(*gmpnum_result, Z_LVAL_PP(a_arg));

	ZEND_REGISTER_RESOURCE(return_value, gmpnum_result, le_gmp);
}
开发者ID:AllardJ,项目名称:Tomato,代码行数:13,代码来源:gmp.c

示例6: php_get_warnings

/* {{{ MYSQLI_WARNING *php_get_warnings(MYSQL *mysql) */
MYSQLI_WARNING * php_get_warnings(MYSQLND_CONN_DATA * mysql)
{
	MYSQLI_WARNING	*w, *first = NULL, *prev = NULL;
	MYSQL_RES		*result;
	zval			row;

	if (mysql->m->query(mysql, "SHOW WARNINGS", 13)) {
		return NULL;
	}

	result = mysql->m->use_result(mysql, 0);

	for (;;) {
		zval *entry;
		int errno;

		mysqlnd_fetch_into(result, MYSQLND_FETCH_NUM, &row, MYSQLND_MYSQLI);
		if (Z_TYPE(row) != IS_ARRAY) {
			zval_ptr_dtor(&row);
			break;
		}
		zend_hash_internal_pointer_reset(Z_ARRVAL(row));
		/* 0. we don't care about the first */
		zend_hash_move_forward(Z_ARRVAL(row));

		/* 1. Here comes the error no */
		entry = zend_hash_get_current_data(Z_ARRVAL(row));
		convert_to_long_ex(entry);
		errno = Z_LVAL_P(entry);
		zend_hash_move_forward(Z_ARRVAL(row));

		/* 2. Here comes the reason */
		entry = zend_hash_get_current_data(Z_ARRVAL(row));

		w = php_new_warning(entry, errno);
		/*
		  Don't destroy entry, because the row destroy will decrease
		  the refcounter. Decreased twice then mysqlnd_free_result()
		  will crash, because it will try to access already freed memory.
		*/
		if (!first) {
			first = w;
		}
		if (prev) {
			prev->next = (void *)w;
		}
		prev = w;

		zval_ptr_dtor(&row);
	}

	mysql_free_result(result);
	return first;
}
开发者ID:13572293130,项目名称:php-src,代码行数:55,代码来源:mysqli_warning.c

示例7: mysqlnd_stmt_execute_prepare_param_types

/* {{{ mysqlnd_stmt_execute_prepare_param_types */
static enum_func_status
mysqlnd_stmt_execute_prepare_param_types(MYSQLND_STMT_DATA * stmt, zval ** copies_param, int * resend_types_next_time)
{
	unsigned int i;
	DBG_ENTER("mysqlnd_stmt_execute_prepare_param_types");
	for (i = 0; i < stmt->param_count; i++) {
		short current_type = stmt->param_bind[i].type;
		zval *parameter = &stmt->param_bind[i].zv;

		ZVAL_DEREF(parameter);
		if (!Z_ISNULL_P(parameter) && (current_type == MYSQL_TYPE_LONG || current_type == MYSQL_TYPE_LONGLONG)) {
			/* always copy the var, because we do many conversions */
			if (Z_TYPE_P(parameter) != IS_LONG &&
				PASS != mysqlnd_stmt_copy_it(copies_param, parameter, stmt->param_count, i))
			{
				SET_OOM_ERROR(*stmt->error_info);
				goto end;
			}
			/*
			  if it doesn't fit in a long send it as a string.
			  Check bug #52891 : Wrong data inserted with mysqli/mysqlnd when using bind_param, value > LONG_MAX
			*/
			if (Z_TYPE_P(parameter) != IS_LONG) {
				zval *tmp_data = (*copies_param && !Z_ISUNDEF((*copies_param)[i]))? &(*copies_param)[i]: parameter;
				/*
				  Because converting to double and back to long can lead
				  to losing precision we need second variable. Conversion to double is to see if
				  value is too big for a long. As said, precision could be lost.
				*/
				zval tmp_data_copy;
				ZVAL_COPY(&tmp_data_copy, tmp_data);
				convert_to_double_ex(&tmp_data_copy);

				/*
				  if it doesn't fit in a long send it as a string.
				  Check bug #52891 : Wrong data inserted with mysqli/mysqlnd when using bind_param, value > LONG_MAX
				  We do transformation here, which will be used later when sending types. The code later relies on this.
				*/
				if (Z_DVAL(tmp_data_copy) > ZEND_LONG_MAX || Z_DVAL(tmp_data_copy) < ZEND_LONG_MIN) {
					stmt->send_types_to_server = *resend_types_next_time = 1;
					convert_to_string_ex(tmp_data);
				} else {
					convert_to_long_ex(tmp_data);
				}

				zval_ptr_dtor(&tmp_data_copy);
			}
		}
	}
	DBG_RETURN(PASS);
end:
	DBG_RETURN(FAIL);
}
开发者ID:Sobak,项目名称:php-src,代码行数:54,代码来源:mysqlnd_ps_codec.c

示例8: php_pack

/* {{{ php_pack
 */
static void php_pack(zval **val, int size, int *map, char *output)
{
	int i;
	char *v;

	convert_to_long_ex(val);
	v = (char *) &Z_LVAL_PP(val);

	for (i = 0; i < size; i++) {
		*output++ = v[map[i]];
	}
}
开发者ID:89snake89,项目名称:php-src,代码行数:14,代码来源:pack.c

示例9: convert_to_gmp

/* {{{ convert_to_gmp
 * Convert zval to be gmp number */
static int convert_to_gmp(mpz_t * *gmpnumber, zval **val, int base TSRMLS_DC) 
{
	int ret = 0;
	int skip_lead = 0;

	*gmpnumber = emalloc(sizeof(mpz_t));

	switch (Z_TYPE_PP(val)) {
	case IS_LONG:
	case IS_BOOL:
	case IS_CONSTANT:
		{
			convert_to_long_ex(val);
			mpz_init_set_si(**gmpnumber, Z_LVAL_PP(val));
		}
		break;
	case IS_STRING:
		{
			char *numstr = Z_STRVAL_PP(val);

			if (Z_STRLEN_PP(val) > 2) {
				if (numstr[0] == '0') {
					if (numstr[1] == 'x' || numstr[1] == 'X') {
						base = 16;
						skip_lead = 1;
					} else if (base != 16 && (numstr[1] == 'b' || numstr[1] == 'B')) {
						base = 2;
						skip_lead = 1;
					}
				}
			}
			ret = mpz_init_set_str(**gmpnumber, (skip_lead ? &numstr[2] : numstr), base);
		}
		break;
	default:
		php_error_docref(NULL TSRMLS_CC, E_WARNING,"Unable to convert variable to GMP - wrong type");
		efree(*gmpnumber);
		return FAILURE;
	}

	if (ret) {
		FREE_GMP_NUM(*gmpnumber);
		return FAILURE;
	}
	
	return SUCCESS;
}
开发者ID:AllardJ,项目名称:Tomato,代码行数:49,代码来源:gmp.c

示例10: zephir_fast_count

/**
 * Makes fast count on implicit array types
 */
void zephir_fast_count(zval *result, zval *value)
{
	if (Z_TYPE_P(value) == IS_ARRAY) {
		ZVAL_LONG(result, zend_hash_num_elements(Z_ARRVAL_P(value)));
		return;
	}

	if (Z_TYPE_P(value) == IS_OBJECT) {

		#ifdef HAVE_SPL
		zval retval;
		#endif

		if (Z_OBJ_HT_P(value)->count_elements) {
			ZVAL_LONG(result, 1);
			if (SUCCESS == Z_OBJ_HT(*value)->count_elements(value, &Z_LVAL_P(result))) {
				return;
			}
		}

		#ifdef HAVE_SPL
		if (instanceof_function(Z_OBJCE_P(value), spl_ce_Countable)) {
			zend_call_method_with_0_params(value, NULL, NULL, "count", &retval);
			if (Z_TYPE(retval) != IS_UNDEF) {
				convert_to_long_ex(&retval);
				ZVAL_LONG(result, Z_LVAL(retval));
				zval_ptr_dtor(&retval);
			}
			return;
		}
		#endif

		ZVAL_LONG(result, 0);
		return;
	}

	if (Z_TYPE_P(value) == IS_NULL) {
		ZVAL_LONG(result, 0);
		return;
	}

	ZVAL_LONG(result, 1);
}
开发者ID:KorsaR-ZN,项目名称:zephir,代码行数:46,代码来源:main.c

示例11: php_sqlite3_collation_callback

static int php_sqlite3_collation_callback(void *context,
	int string1_len, const void *string1,
	int string2_len, const void *string2)
{
	int ret;
	zval zargs[2];
	zval retval;
	struct pdo_sqlite_collation *collation = (struct pdo_sqlite_collation*) context;

	collation->fc.fci.size = sizeof(collation->fc.fci);
	collation->fc.fci.function_table = EG(function_table);
	ZVAL_COPY_VALUE(&collation->fc.fci.function_name, &collation->callback);
	collation->fc.fci.symbol_table = NULL;
	collation->fc.fci.object = NULL;
	collation->fc.fci.retval = &retval;

	// Prepare the arguments.
	ZVAL_STRINGL(&zargs[0], (char *) string1, string1_len);
	ZVAL_STRINGL(&zargs[1], (char *) string2, string2_len);
	collation->fc.fci.param_count = 2;
	collation->fc.fci.params = zargs;

	if ((ret = zend_call_function(&collation->fc.fci, &collation->fc.fcc)) == FAILURE) {
		php_error_docref(NULL, E_WARNING, "An error occurred while invoking the callback");
	} else if (!Z_ISUNDEF(retval)) {
		if (Z_TYPE(retval) != IS_LONG) {
			convert_to_long_ex(&retval);
		}
		ret = 0;
		if (Z_LVAL(retval) > 0) {
			ret = 1;
		} else if (Z_LVAL(retval) < 0) {
			ret = -1;
		}
		zval_ptr_dtor(&retval);
	}

	zval_ptr_dtor(&zargs[0]);
	zval_ptr_dtor(&zargs[1]);

	return ret;
}
开发者ID:CooCoooo,项目名称:php-src,代码行数:42,代码来源:sqlite_driver.c

示例12: zephir_fast_count_int

/**
 * Makes fast count on implicit array types without creating a return zval value
 */
int zephir_fast_count_int(zval *value)
{
	long count = 0;

	if (Z_TYPE_P(value) == IS_ARRAY) {
		return zend_hash_num_elements(Z_ARRVAL_P(value));
	}

	if (Z_TYPE_P(value) == IS_OBJECT) {

		#ifdef HAVE_SPL
		zval retval;
		#endif

		if (Z_OBJ_HT_P(value)->count_elements) {
			Z_OBJ_HT(*value)->count_elements(value, &count TSRMLS_CC);
			return (int) count;
		}

		#ifdef HAVE_SPL
		if (instanceof_function(Z_OBJCE_P(value), spl_ce_Countable)) {
			zend_call_method_with_0_params(value, NULL, NULL, "count", &retval);
			if (Z_TYPE(retval) != IS_UNDEF) {
				convert_to_long_ex(&retval);
				count = Z_LVAL(retval);
				zval_ptr_dtor(&retval);
				return (int) count;
			}
			return 0;
		}
		#endif

		return 0;
	}

	if (Z_TYPE_P(value) == IS_NULL) {
		return 0;
	}

	return 1;
}
开发者ID:KorsaR-ZN,项目名称:zephir,代码行数:44,代码来源:main.c

示例13: _php_curl_share_setopt

static int _php_curl_share_setopt(php_curlsh *sh, zend_long option, zval *zvalue, zval *return_value) /* {{{ */
{
	CURLSHcode error = CURLSHE_OK;

	switch (option) {
		case CURLSHOPT_SHARE:
		case CURLSHOPT_UNSHARE:
			convert_to_long_ex(zvalue);
			error = curl_share_setopt(sh->share, option, Z_LVAL_P(zvalue));
			break;

		default:
			php_error_docref(NULL, E_WARNING, "Invalid curl share configuration option");
			error = CURLSHE_BAD_OPTION;
			break;
	}

	if (error != CURLSHE_OK) {
		return 1;
	} else {
		return 0;
	}
}
开发者ID:Crell,项目名称:php-src,代码行数:23,代码来源:share.c

示例14: binary_deserialize_spec

void binary_deserialize_spec(zval* zthis, PHPInputTransport& transport, HashTable* spec) {
  // SET and LIST have 'elem' => array('type', [optional] 'class')
  // MAP has 'val' => array('type', [optiona] 'class')
  TSRMLS_FETCH();
  zend_class_entry* ce = zend_get_class_entry(zthis TSRMLS_CC);
  while (true) {
    zval** val_ptr = NULL;

    int8_t ttype = transport.readI8();
    if (ttype == T_STOP) return;
    int16_t fieldno = transport.readI16();
    if (zend_hash_index_find(spec, fieldno, (void**)&val_ptr) == SUCCESS) {
      HashTable* fieldspec = Z_ARRVAL_PP(val_ptr);
      // pull the field name
      // zend hash tables use the null at the end in the length... so strlen(hash key) + 1.
      zend_hash_find(fieldspec, "var", 4, (void**)&val_ptr);
      char* varname = Z_STRVAL_PP(val_ptr);

      // and the type
      zend_hash_find(fieldspec, "type", 5, (void**)&val_ptr);
      convert_to_long_ex(val_ptr);
      int8_t expected_ttype = Z_LVAL_PP(val_ptr);

      if (ttypes_are_compatible(ttype, expected_ttype)) {
        zval* rv = NULL;
        MAKE_STD_ZVAL(rv);
        binary_deserialize(ttype, transport, rv, fieldspec);
        zend_update_property(ce, zthis, varname, strlen(varname), rv TSRMLS_CC);
        zval_ptr_dtor(&rv);
      } else {
        skip_element(ttype, transport);
      }
    } else {
      skip_element(ttype, transport);
    }
  }
}
开发者ID:KirinDave,项目名称:powerset_thrift,代码行数:37,代码来源:php_thrift_protocol.cpp

示例15: verify_callback

static int verify_callback(int preverify_ok, X509_STORE_CTX *ctx) /* {{{ */
{
    void *stream;
    SSL *ssl;
    X509 *err_cert;
    int err, depth, ret;

    ret = preverify_ok;

    /* determine the status for the current cert */
    err_cert = X509_STORE_CTX_get_current_cert(ctx);
    err = X509_STORE_CTX_get_error(ctx);
    depth = X509_STORE_CTX_get_error_depth(ctx);

    /* conjure the stream & context to use */
    ssl = X509_STORE_CTX_get_ex_data(ctx, SSL_get_ex_data_X509_STORE_CTX_idx());
    stream = SSL_get_ex_data(ssl, ssl_stream_data_index);

    /* if allow_self_signed is set, make sure that verification succeeds */
    if (err == X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT && GET_VER_OPT("allow_self_signed") && zval_is_true(*val)) {
        ret = 1;
    }

    /* check the depth */
    if (GET_VER_OPT("verify_depth")) {
        convert_to_long_ex(val);

        if (depth > Z_LVAL_PP(val)) {
            ret = 0;
            X509_STORE_CTX_set_error(ctx, X509_V_ERR_CERT_CHAIN_TOO_LONG);
        }
    }

    return ret;

}
开发者ID:guijun,项目名称:lua-openssl,代码行数:36,代码来源:openssl.c


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