本文整理汇总了C++中smart_str_0函数的典型用法代码示例。如果您正苦于以下问题:C++ smart_str_0函数的具体用法?C++ smart_str_0怎么用?C++ smart_str_0使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了smart_str_0函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: php_bencode_decode_str
static void php_bencode_decode_str(zval *return_value, char *str, size_t *pos, size_t *str_len) /* {{{ */
{
size_t len = 0;
smart_str buf = {0};
while (*pos < *str_len && str[*pos] != ':') {
smart_str_appendc(&buf, str[*pos]);
(*pos)++;
}
if (str[*pos] != ':') {
zend_error(E_WARNING, "Invaild bencoded-string, expected semicolon, stop at position %u.", *pos);
RETURN_NULL();
}
(*pos)++;
smart_str_0(&buf);
len = atoi(ZSTR_VAL(buf.s));
smart_str_free(&buf);
if (len > 0 && *pos + len - 1 < *str_len) {
size_t i;
for (i = 0; i < len; i++, (*pos)++) {
smart_str_appendc(&buf, str[*pos]);
}
smart_str_0(&buf);
RETVAL_STR(buf.s);
} else {
RETVAL_EMPTY_STRING();
}
}
示例2: PHP_FUNCTION
/* {{{ proto string json_encode(mixed data [, int options[, int depth]])
Returns the JSON representation of a value */
static PHP_FUNCTION(json_encode)
{
zval *parameter;
php_json_encoder encoder;
smart_str buf = {0};
zend_long options = 0;
zend_long depth = PHP_JSON_PARSER_DEFAULT_DEPTH;
ZEND_PARSE_PARAMETERS_START(1, 3)
Z_PARAM_ZVAL_DEREF(parameter)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(options)
Z_PARAM_LONG(depth)
ZEND_PARSE_PARAMETERS_END();
php_json_encode_init(&encoder);
encoder.max_depth = (int)depth;
encoder.error_code = PHP_JSON_ERROR_NONE;
php_json_encode_zval(&buf, parameter, (int)options, &encoder);
JSON_G(error_code) = encoder.error_code;
if (encoder.error_code != PHP_JSON_ERROR_NONE && !(options & PHP_JSON_PARTIAL_OUTPUT_ON_ERROR)) {
smart_str_free(&buf);
RETURN_FALSE;
}
smart_str_0(&buf); /* copy? */
if (buf.s) {
RETURN_NEW_STR(buf.s);
}
RETURN_EMPTY_STRING();
}
示例3: PHP_FUNCTION
/* {{{ proto string json_encode(mixed data [, int options[, int depth]])
Returns the JSON representation of a value */
static PHP_FUNCTION(json_encode)
{
zval *parameter;
php_json_encoder encoder;
smart_str buf = {0};
zend_long options = 0;
zend_long depth = PHP_JSON_PARSER_DEFAULT_DEPTH;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|ll", ¶meter, &options, &depth) == FAILURE) {
return;
}
php_json_encode_init(&encoder);
encoder.max_depth = (int)depth;
encoder.error_code = PHP_JSON_ERROR_NONE;
php_json_encode_zval(&buf, parameter, (int)options, &encoder);
JSON_G(error_code) = encoder.error_code;
if (encoder.error_code != PHP_JSON_ERROR_NONE && !(options & PHP_JSON_PARTIAL_OUTPUT_ON_ERROR)) {
smart_str_free(&buf);
RETURN_FALSE;
}
smart_str_0(&buf); /* copy? */
if (buf.s) {
RETURN_NEW_STR(buf.s);
}
RETURN_EMPTY_STRING();
}
示例4: php_filter_encode_html
/* {{{ HELPER FUNCTIONS */
static void php_filter_encode_html(zval *value, const unsigned char *chars)
{
smart_str str = {0};
size_t len = Z_STRLEN_P(value);
unsigned char *s = (unsigned char *)Z_STRVAL_P(value);
unsigned char *e = s + len;
if (Z_STRLEN_P(value) == 0) {
return;
}
while (s < e) {
if (chars[*s]) {
smart_str_appendl(&str, "&#", 2);
smart_str_append_unsigned(&str, (zend_ulong)*s);
smart_str_appendc(&str, ';');
} else {
/* XXX: this needs to be optimized to work with blocks of 'safe' chars */
smart_str_appendc(&str, *s);
}
s++;
}
smart_str_0(&str);
zval_ptr_dtor(value);
ZVAL_NEW_STR(value, str.s);
}
示例5: hs_response_recv
static inline long
hs_response_recv(php_stream *stream, char *recv, size_t size TSRMLS_DC)
{
long ret;
#ifdef HS_DEBUG
long i;
smart_str debug = {0};
#endif
ret = php_stream_read(stream, recv, size);
if (ret <= 0) {
return -1;
}
recv[size] = '\0';
#ifdef HS_DEBUG
for (i = 0; i < ret; i++) {
if ((unsigned char)recv[i] == HS_CODE_NULL) {
smart_str_appendl_ex(&debug, "\\0", strlen("\\0"), 1);
} else {
smart_str_appendc(&debug, recv[i]);
}
}
smart_str_0(&debug);
php_printf("[handlersocket] (recv) %ld : \"%s\"", ret, debug.c);
smart_str_free(&debug);
#endif
return ret;
}
示例6: PHP_FUNCTION
/* {{{ proto string json_encode(mixed data [, int options[, int depth]])
Returns the JSON representation of a value */
static PHP_FUNCTION(json_encode)
{
zval *parameter;
smart_str buf = {0};
zend_long options = 0;
zend_long depth = PHP_JSON_PARSER_DEFAULT_DEPTH;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|ll", ¶meter, &options, &depth) == FAILURE) {
return;
}
JSON_G(error_code) = PHP_JSON_ERROR_NONE;
JSON_G(encode_max_depth) = (int)depth;
php_json_encode(&buf, parameter, (int)options);
if (JSON_G(error_code) != PHP_JSON_ERROR_NONE && !(options & PHP_JSON_PARTIAL_OUTPUT_ON_ERROR)) {
smart_str_free(&buf);
ZVAL_FALSE(return_value);
} else {
smart_str_0(&buf); /* copy? */
ZVAL_NEW_STR(return_value, buf.s);
}
}
示例7: ONPHP_METHOD
ONPHP_METHOD(ExtractPart, toDialectString)
{
zval *dialect, *what, *from, *whatString, *fromString;
smart_str string = {0};
ONPHP_GET_ARGS("O", &dialect, onphp_ce_Dialect);
what = ONPHP_READ_PROPERTY(getThis(), "what");
from = ONPHP_READ_PROPERTY(getThis(), "from");
ONPHP_CALL_METHOD_0(what, "tostring", &whatString);
ONPHP_CALL_METHOD_1_NORET(from, "todialectstring", &fromString, dialect);
if (EG(exception)) {
ZVAL_FREE(whatString);
return;
}
smart_str_appendl(&string, "EXTRACT(", 8);
onphp_append_zval_to_smart_string(&string, whatString);
smart_str_appendl(&string, " FROM ", 6);
onphp_append_zval_to_smart_string(&string, fromString);
smart_str_appendc(&string, ')');
smart_str_0(&string);
zval_ptr_dtor(&whatString);
zval_ptr_dtor(&fromString);
RETURN_STRINGL(string.c, string.len, 0);
}
示例8: php_bencode_decode_int
static void php_bencode_decode_int(zval *return_value, char *str, size_t *pos, size_t *str_len) /* {{{ */
{
int len = 0;
double d;
smart_str buf = {0};
(*pos)++;
while (*pos < *str_len && str[*pos] != PHP_BENCODE_END_STRUCTURE) {
smart_str_appendc(&buf, str[*pos]);
(*pos)++;
len++;
}
smart_str_0(&buf);
if (str[*pos] != PHP_BENCODE_END_STRUCTURE) {
smart_str_free(&buf);
zend_error(E_WARNING, "Invaild bencoded-integer, expected 'e'.");
RETURN_NULL();
}
(*pos)++;
ZVAL_STRINGL(return_value, ZSTR_VAL(buf.s), len);
d = zend_strtod(ZSTR_VAL(buf.s), NULL);
if (d <= ZEND_LONG_MAX && d >= ZEND_LONG_MIN) {
convert_to_long(return_value);
}
smart_str_free(&buf);
}
示例9: zend_print_zval_r_to_buf
ZEND_API zend_string *zend_print_zval_r_to_str(zval *expr, int indent) /* {{{ */
{
smart_str buf = {0};
zend_print_zval_r_to_buf(&buf, expr, indent);
smart_str_0(&buf);
return buf.s;
}
示例10: phalcon_cssmin_internal
static int phalcon_cssmin_internal(zval *return_value, zval *style, const char **error) {
int i;
unsigned char c;
cssmin_parser parser;
smart_str minified = {0};
parser.tmp_state = 0;
parser.state = 1;
parser.last_state = 1;
parser.in_paren = 0;
parser.style = style;
parser.error = NULL;
parser.minified = &minified;
for (i = 0; i < Z_STRLEN_P(style); i++) {
parser.style_pointer = i + 1;
c = phalcon_cssmin_machine(&parser, Z_STRVAL_P(style)[i]);
if (c != 0) {
smart_str_appendc(parser.minified, c);
}
i = parser.style_pointer - 1;
}
smart_str_0(&minified);
if (minified.s) {
ZVAL_STRINGL(return_value, minified.s->val, minified.s->len);
} else {
ZVAL_EMPTY_STRING(return_value);
}
*error = parser.error;
return SUCCESS;
}
示例11: PHP_METHOD
/**
* Writes the meta-data to files
*
* @param string $key
* @param array $data
*/
PHP_METHOD(Phalcon_Mvc_Model_MetaData_Files, write){
zval **key, **data, *meta_data_dir, *virtual_key;
zval *path, *php_export, *status;
smart_str exp = { NULL, 0, 0 };
phalcon_fetch_params_ex(2, 0, &key, &data);
PHALCON_MM_GROW();
meta_data_dir = phalcon_fetch_nproperty_this(this_ptr, SL("_metaDataDir"), PH_NOISY TSRMLS_CC);
PHALCON_INIT_VAR(virtual_key);
phalcon_prepare_virtual_path_ex(virtual_key, Z_STRVAL_PP(key), Z_STRLEN_PP(key), '_' TSRMLS_CC);
PHALCON_INIT_VAR(path);
PHALCON_CONCAT_VVS(path, meta_data_dir, virtual_key, ".php");
smart_str_appends(&exp, "<?php return ");
php_var_export_ex(data, 0, &exp TSRMLS_CC);
smart_str_appendc(&exp, ';');
smart_str_0(&exp);
PHALCON_INIT_VAR(php_export);
ZVAL_STRINGL(php_export, exp.c, exp.len, 0);
PHALCON_INIT_VAR(status);
phalcon_file_put_contents(status, path, php_export TSRMLS_CC);
if (PHALCON_IS_FALSE(status)) {
PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "Meta-Data directory cannot be written");
return;
}
PHALCON_MM_RESTORE();
}
示例12: PHP_METHOD
/**
* Writes parsed annotations to files
*
* @param string $key
* @param Phalcon\Annotations\Reflection $data
*/
PHP_METHOD(Phalcon_Annotations_Adapter_Files, write){
zval *key, *data, annotations_dir = {}, virtual_key = {}, path = {}, php_export = {}, status = {};
smart_str exp = { 0 };
phalcon_fetch_params(0, 2, 0, &key, &data);
PHALCON_ENSURE_IS_STRING(key);
phalcon_return_property(&annotations_dir, getThis(), SL("_annotationsDir"));
/**
* Paths must be normalized before be used as keys
*/
phalcon_prepare_virtual_path_ex(&virtual_key, Z_STRVAL_P(key), Z_STRLEN_P(key), '_');
PHALCON_CONCAT_VVS(&path, &annotations_dir, &virtual_key, ".php");
smart_str_appends(&exp, "<?php return ");
php_var_export_ex(data, 0, &exp);
smart_str_appendc(&exp, ';');
smart_str_0(&exp);
ZVAL_STR(&php_export, exp.s);
phalcon_file_put_contents(&status, &path, &php_export);
if (PHALCON_IS_FALSE(&status)) {
PHALCON_THROW_EXCEPTION_STRW(phalcon_annotations_exception_ce, "Annotations directory cannot be written");
return;
}
}
示例13: phalcon_var_export_ex
/**
* var_export returns php variables without using the PHP userland
*/
void phalcon_var_export_ex(zval *return_value, zval *var) {
smart_str buf = { 0 };
php_var_export_ex(var, 1, &buf);
smart_str_0(&buf);
ZVAL_STR(return_value, buf.s);
}
示例14: yaf_route_simple_assemble
/** {{{ zend_string * yaf_route_simple_assemble(zval *info, zval *query)
*/
zend_string * yaf_route_simple_assemble(yaf_route_t *this_ptr, zval *info, zval *query) {
smart_str tvalue = {0};
zval *nmodule, *ncontroller, *naction;
smart_str_appendc(&tvalue, '?');
nmodule = zend_read_property(yaf_route_simple_ce,
this_ptr, ZEND_STRL(YAF_ROUTE_SIMPLE_VAR_NAME_MODULE), 1, NULL);
ncontroller = zend_read_property(yaf_route_simple_ce,
this_ptr, ZEND_STRL(YAF_ROUTE_SIMPLE_VAR_NAME_CONTROLLER), 1, NULL);
naction = zend_read_property(yaf_route_simple_ce,
this_ptr, ZEND_STRL(YAF_ROUTE_SIMPLE_VAR_NAME_ACTION), 1, NULL);
do {
zval *tmp;
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(info), ZEND_STRL(YAF_ROUTE_ASSEMBLE_MOUDLE_FORMAT))) != NULL) {
smart_str_appendl(&tvalue, Z_STRVAL_P(nmodule), Z_STRLEN_P(nmodule));
smart_str_appendc(&tvalue, '=');
smart_str_appendl(&tvalue, Z_STRVAL_P(tmp), Z_STRLEN_P(tmp));
smart_str_appendc(&tvalue, '&');
}
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(info), ZEND_STRL(YAF_ROUTE_ASSEMBLE_CONTROLLER_FORMAT))) == NULL) {
yaf_trigger_error(YAF_ERR_TYPE_ERROR, "%s", "You need to specify the controller by ':c'");
break;
}
smart_str_appendl(&tvalue, Z_STRVAL_P(ncontroller), Z_STRLEN_P(ncontroller));
smart_str_appendc(&tvalue, '=');
smart_str_appendl(&tvalue, Z_STRVAL_P(tmp), Z_STRLEN_P(tmp));
smart_str_appendc(&tvalue, '&');
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(info), ZEND_STRL(YAF_ROUTE_ASSEMBLE_ACTION_FORMAT))) == NULL) {
yaf_trigger_error(YAF_ERR_TYPE_ERROR, "%s", "You need to specify the action by ':a'");
break;
}
smart_str_appendl(&tvalue, Z_STRVAL_P(naction), Z_STRLEN_P(naction));
smart_str_appendc(&tvalue, '=');
smart_str_appendl(&tvalue, Z_STRVAL_P(tmp), Z_STRLEN_P(tmp));
if (query && IS_ARRAY == Z_TYPE_P(query)) {
zend_string *key;
ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(query), key, tmp) {
if (IS_STRING == Z_TYPE_P(tmp) && key) {
smart_str_appendc(&tvalue, '&');
smart_str_appendl(&tvalue, ZSTR_VAL(key), ZSTR_LEN(key));
smart_str_appendc(&tvalue, '=');
smart_str_appendl(&tvalue, Z_STRVAL_P(tmp), Z_STRLEN_P(tmp));
}
} ZEND_HASH_FOREACH_END();
}
smart_str_0(&tvalue);
return tvalue.s;
} while (0);
示例15: ONPHP_METHOD
ONPHP_METHOD(Joiner, toDialectString)
{
zval
*dialect,
*from = ONPHP_READ_PROPERTY(getThis(), "from"),
*table;
zend_class_entry **cep;
smart_str string = {0};
unsigned int i = 0, count = zend_hash_num_elements(Z_ARRVAL_P(from));
if (!count) {
RETURN_NULL();
} else {
smart_str_appendl(&string, " FROM ", 6);
}
ONPHP_GET_ARGS("O", &dialect, onphp_ce_Dialect);
ONPHP_FIND_FOREIGN_CLASS("SelectQuery", cep);
for (i = 0; i < count; ++i) {
zval *out;
ONPHP_ARRAY_GET(from, i, table);
if (i == 0) {
/* nop */
} else {
if (ONPHP_INSTANCEOF(from, FromTable)) {
zval *name;
ONPHP_CALL_METHOD_0(table, "gettable", &name);
if (instanceof_function(Z_OBJCE_P(table), *cep TSRMLS_CC)) {
smart_str_appendl(&string, ", ", 2);
} else {
smart_str_appendc(&string, ' ');
}
zval_ptr_dtor(&name);
} else {
smart_str_appendc(&string, ' ');
}
}
ONPHP_CALL_METHOD_1(table, "todialectstring", &out, dialect);
onphp_append_zval_to_smart_string(&string, out);
zval_ptr_dtor(&out);
}
smart_str_0(&string);
RETURN_STRINGL(string.c, string.len, 0);
}