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


C++ smart_str_appendl函数代码示例

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


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

示例1: print_hash

static void print_hash(smart_str *buf, HashTable *ht, int indent, zend_bool is_object) /* {{{ */
{
	zval *tmp;
	zend_string *string_key;
	zend_ulong num_key;
	int i;

	for (i = 0; i < indent; i++) {
		smart_str_appendc(buf, ' ');
	}
	smart_str_appends(buf, "(\n");
	indent += PRINT_ZVAL_INDENT;
	ZEND_HASH_FOREACH_KEY_VAL_IND(ht, num_key, string_key, tmp) {
		for (i = 0; i < indent; i++) {
			smart_str_appendc(buf, ' ');
		}
		smart_str_appendc(buf, '[');
		if (string_key) {
			if (is_object) {
				const char *prop_name, *class_name;
				size_t prop_len;
				int mangled = zend_unmangle_property_name_ex(string_key, &class_name, &prop_name, &prop_len);

				smart_str_appendl(buf, prop_name, prop_len);
				if (class_name && mangled == SUCCESS) {
					if (class_name[0] == '*') {
						smart_str_appends(buf, ":protected");
					} else {
						smart_str_appends(buf, ":");
						smart_str_appends(buf, class_name);
						smart_str_appends(buf, ":private");
					}
				}
			} else {
				smart_str_append(buf, string_key);
			}
		} else {
			smart_str_append_long(buf, num_key);
		}
		smart_str_appends(buf, "] => ");
		zend_print_zval_r_to_buf(buf, tmp, indent+PRINT_ZVAL_INDENT);
		smart_str_appends(buf, "\n");
	} ZEND_HASH_FOREACH_END();
	indent -= PRINT_ZVAL_INDENT;
	for (i = 0; i < indent; i++) {
		smart_str_appendc(buf, ' ');
	}
	smart_str_appends(buf, ")\n");
}
开发者ID:woyager,项目名称:vgtrk_br,代码行数:49,代码来源:zend.c

示例2: php_mail_build_headers_elem

static void php_mail_build_headers_elem(smart_str *s, zend_string *key, zval *val)
{
	switch(Z_TYPE_P(val)) {
		case IS_STRING:
			if (php_mail_build_headers_check_field_name(key) != SUCCESS) {
				php_error_docref(NULL, E_WARNING, "Header field name (%s) contains invalid chars", ZSTR_VAL(key));
				return;
			}
			if (php_mail_build_headers_check_field_value(val) != SUCCESS) {
				php_error_docref(NULL, E_WARNING, "Header field value (%s => %s) contains invalid chars or format", ZSTR_VAL(key), Z_STRVAL_P(val));
				return;
			}
			smart_str_append(s, key);
			smart_str_appendl(s, ": ", 2);
			smart_str_appends(s, Z_STRVAL_P(val));
			smart_str_appendl(s, "\r\n", 2);
			break;
		case IS_ARRAY:
			php_mail_build_headers_elems(s, key, val);
			break;
		default:
			php_error_docref(NULL, E_WARNING, "headers array elements must be string or array (%s)", ZSTR_VAL(key));
	}
}
开发者ID:LTD-Beget,项目名称:php-src,代码行数:24,代码来源:mail.c

示例3: handle_tag

static inline void handle_tag(STD_PARA) 
{
	int ok = 0;
	unsigned int i;

	if (ctx->tag.s) {
		ctx->tag.s->len = 0;
	}
	smart_str_appendl(&ctx->tag, start, YYCURSOR - start);
	for (i = 0; i < ctx->tag.s->len; i++)
		ctx->tag.s->val[i] = tolower((int)(unsigned char)ctx->tag.s->val[i]);
    /* intentionally using str_find here, in case the hash value is set, but the string val is changed later */
	if ((ctx->lookup_data = zend_hash_str_find_ptr(ctx->tags, ctx->tag.s->val, ctx->tag.s->len)) != NULL)
		ok = 1;
	STATE = ok ? STATE_NEXT_ARG : STATE_PLAIN;
}
开发者ID:0x1111,项目名称:php-src,代码行数:16,代码来源:url_scanner_ex.c

示例4: readline_shell_write

static size_t readline_shell_write(const char *str, size_t str_length TSRMLS_DC) /* {{{ */
{
	if (CLIR_G(prompt_str)) {
		smart_str_appendl(CLIR_G(prompt_str), str, str_length);
		return str_length;
	}

	if (CLIR_G(pager) && *CLIR_G(pager) && !pager_pipe) {
		pager_pipe = VCWD_POPEN(CLIR_G(pager), "w");
	}
	if (pager_pipe) {
		return fwrite(str, 1, MIN(str_length, 16384), pager_pipe);
	}

	return -1;
}
开发者ID:KomaBeyond,项目名称:php-src,代码行数:16,代码来源:readline_cli.c

示例5: php_discuz_auth_encode

PHPAPI static void php_discuz_auth_encode(smart_str *buf, const char *str, int str_len, const char *key, int keylen, long expiry)
{
	char keya[33], keyb[33], keyc[DISCUZ_AUTH_CKEYLEN+1], cryptkey[65]={0};
        char ret[100], retmd5[33];
        char *pc;
	struct timeval tp = {0};
        smart_str strbuf = {0};
        if (gettimeofday(&tp, NULL)) {
                return;
        }
        snprintf(ret, 100, "%.8F %ld", tp.tv_usec / MICRO_IN_SEC, tp.tv_sec);

        php_md5(retmd5, ret, strlen(ret));
        bzero(keyc, sizeof(keyc));
        memcpy(keyc, retmd5 + 32 - DISCUZ_AUTH_CKEYLEN, DISCUZ_AUTH_CKEYLEN);

	php_discuz_auth_initkey(keya, keyb, cryptkey, keyc, key, keylen);
	//$string = sprintf('%010d', $expiry ? $expiry + time() : 0).substr(md5($string.$keyb), 0, 16).$string;
	smart_str_appendl(&strbuf, str, str_len);
	smart_str_appendl(&strbuf, keyb, 32);
	php_md5(retmd5, strbuf.c, strbuf.len);
	smart_str_free(&strbuf);

	snprintf(ret, sizeof(ret), "%010d", expiry ? expiry + time(NULL) : 0);
	smart_str_appendl(&strbuf, ret, 10);
	smart_str_appendl(&strbuf, retmd5, 16);
	smart_str_appendl(&strbuf, str, str_len);

	pc = (unsigned char *)safe_emalloc(strbuf.len, sizeof(char), 1);
	php_discuz_authcode(pc, strbuf.c, strbuf.len, cryptkey);

	//return $keyc.str_replace('=', '', base64_encode($result));
	char *result;
	int retlen;
	result = php_base64_encode((unsigned char*)pc, strbuf.len, &retlen);
	efree(pc);	

	int index, to;
	for(index = 0, to = 0; index <= retlen; index++) {
		if(*(result+index) != '=') {
			*(result+to) = *(result+index);
			to++;
		}
	}
	smart_str_appendl(buf, keyc, DISCUZ_AUTH_CKEYLEN);
	smart_str_appendl(buf, result, retlen - (index - to));
	smart_str_free(&strbuf);
}
开发者ID:potterhe,项目名称:php_discuz,代码行数:48,代码来源:discuz.c

示例6: php_ds_default_cast_object

int php_ds_default_cast_object(zval *obj, zval *return_value, int type)
{
    switch (type) {
        case IS_STRING: {
            smart_str buffer = {0};

            smart_str_appendl(&buffer, "object(", 7);
            smart_str_append (&buffer, Z_OBJCE_P(obj)->name);
            smart_str_appendc(&buffer, ')');

            smart_str_0(&buffer);
            ZVAL_STR(return_value, buffer.s);
            return SUCCESS;
        }
    }

    return FAILURE;
}
开发者ID:php-ds,项目名称:extension,代码行数:18,代码来源:php_common_handlers.c

示例7: ZSTR_EMPTY_ALLOC

zend_string *ds_join_zval_buffer(
    zval        *buffer,
    zend_long    size,
    char        *glue,
    size_t       len
) {
    smart_str str = {0};

    if (size <= 0) {
        return ZSTR_EMPTY_ALLOC();
    }

    if (size == 1) {
        return zval_get_string(buffer);
    }

    // Glue is optional, will use empty string by default if NULL
    if (glue && len) {
        zval *pos = buffer;
        zval *end = buffer + size - 1; // Exclude last value

        // Append each part and the glue right up to the last value.
        do {
            smart_str_appendz(&str, pos);
            smart_str_appendl(&str, glue, len);
        } while (++pos != end);

        // Append last value
        smart_str_appendz(&str, pos);

    } else {
        zval *pos = buffer;
        zval *end = buffer + size;

        // Append each part including the last, without glue.
        do {
            smart_str_appendz(&str, pos);
        } while (++pos != end);
    }

    smart_str_0(&str);
    return str.s;
}
开发者ID:php-ds,项目名称:extension,代码行数:43,代码来源:common.c

示例8: handle_tag

static inline void handle_tag(STD_PARA)
{
	int ok = 0;
	unsigned int i;

	if (ctx->tag.s) {
		ZSTR_LEN(ctx->tag.s) = 0;
	}
	smart_str_appendl(&ctx->tag, start, YYCURSOR - start);
	for (i = 0; i < ZSTR_LEN(ctx->tag.s); i++)
		ZSTR_VAL(ctx->tag.s)[i] = tolower((int)(unsigned char)ZSTR_VAL(ctx->tag.s)[i]);
    /* intentionally using str_find here, in case the hash value is set, but the string val is changed later */
	if ((ctx->lookup_data = zend_hash_str_find_ptr(ctx->tags, ZSTR_VAL(ctx->tag.s), ZSTR_LEN(ctx->tag.s))) != NULL) {
		ok = 1;
		if (ZSTR_LEN(ctx->tag.s) == sizeof("form")-1
			&& !strncasecmp(ZSTR_VAL(ctx->tag.s), "form", ZSTR_LEN(ctx->tag.s))) {
			ctx->tag_type = TAG_FORM;
		} else {
			ctx->tag_type = TAG_NORMAL;
		}
	}
	STATE = ok ? STATE_NEXT_ARG : STATE_PLAIN;
}
开发者ID:LTD-Beget,项目名称:php-src,代码行数:23,代码来源:url_scanner_ex.c

示例9: zephir_prepare_virtual_path

/**
 * Replaces directory separators by the virtual separator
 */
void zephir_prepare_virtual_path(zval *return_value, zval *path, zval *virtual_separator)
{

	unsigned int i;
	unsigned char ch;
	smart_str virtual_str = {0};

	if (Z_TYPE_P(path) != IS_STRING || Z_TYPE_P(virtual_separator) != IS_STRING) {
		if (Z_TYPE_P(path) == IS_STRING) {
			RETURN_STR(zval_get_string(path));
		} else {
			RETURN_EMPTY_STRING();
		}
		return;
	}

	for (i = 0; i < Z_STRLEN_P(path); i++) {
		ch = Z_STRVAL_P(path)[i];
		if (ch == '\0') {
			break;
		}
		if (ch == '/' || ch == '\\' || ch == ':') {
			smart_str_appendl(&virtual_str, Z_STRVAL_P(virtual_separator), Z_STRLEN_P(virtual_separator));
		}
		else {
			smart_str_appendc(&virtual_str, tolower(ch));
		}
	}

	smart_str_0(&virtual_str);

	if (virtual_str.s) {
		RETURN_STR(virtual_str.s);
	} else {
		RETURN_EMPTY_STRING();
	}
}
开发者ID:oscarmolinadev,项目名称:zephir,代码行数:40,代码来源:file.c

示例10: php_url_scanner_session_handler_impl

static inline void php_url_scanner_session_handler_impl(char *output, size_t output_len, char **handled_output, size_t *handled_output_len, int mode, int type)
{
	size_t len;
	url_adapt_state_ex_t *url_state;

	if (type) {
		url_state = &BG(url_adapt_session_ex);
	} else {
		url_state = &BG(url_adapt_output_ex);
	}

	if (ZSTR_LEN(url_state->url_app.s) != 0) {
		*handled_output = url_adapt_ext(output, output_len, &len, (zend_bool) (mode & (PHP_OUTPUT_HANDLER_END | PHP_OUTPUT_HANDLER_CONT | PHP_OUTPUT_HANDLER_FLUSH | PHP_OUTPUT_HANDLER_FINAL) ? 1 : 0), url_state);
		if (sizeof(uint32_t) < sizeof(size_t)) {
			if (len > UINT_MAX)
				len = UINT_MAX;
		}
		*handled_output_len = len;
	} else if (ZSTR_LEN(url_state->url_app.s) == 0) {
		url_adapt_state_ex_t *ctx = url_state;
		if (ctx->buf.s && ZSTR_LEN(ctx->buf.s)) {
			smart_str_append(&ctx->result, ctx->buf.s);
			smart_str_appendl(&ctx->result, output, output_len);

			*handled_output = estrndup(ZSTR_VAL(ctx->result.s), ZSTR_LEN(ctx->result.s));
			*handled_output_len = ZSTR_LEN(ctx->buf.s) + output_len;

			smart_str_free(&ctx->buf);
			smart_str_free(&ctx->result);
		} else {
			*handled_output = estrndup(output, *handled_output_len = output_len);
		}
	} else {
		*handled_output = NULL;
	}
}
开发者ID:LTD-Beget,项目名称:php-src,代码行数:36,代码来源:url_scanner_ex.c

示例11: xx_mainloop

static char *url_adapt_ext(const char *src, size_t srclen, size_t *newlen, zend_bool do_flush, url_adapt_state_ex_t *ctx)
{
	char *retval;

	xx_mainloop(ctx, src, srclen);

	if (!ctx->result.s) {
		smart_str_appendl(&ctx->result, "", 0);
		*newlen = 0;
	} else {
		*newlen = ZSTR_LEN(ctx->result.s);
	}
	smart_str_0(&ctx->result);
	if (do_flush) {
		smart_str_append(&ctx->result, ctx->buf.s);
		*newlen += ZSTR_LEN(ctx->buf.s);
		smart_str_free(&ctx->buf);
		smart_str_free(&ctx->val);
		smart_str_free(&ctx->attr_val);
	}
	retval = estrndup(ZSTR_VAL(ctx->result.s), ZSTR_LEN(ctx->result.s));
	smart_str_free(&ctx->result);
	return retval;
}
开发者ID:LTD-Beget,项目名称:php-src,代码行数:24,代码来源:url_scanner_ex.c

示例12: PHP_METHOD

/**
 * Gets HTTP raw request body
 *
 * @return string
 */
PHP_METHOD(Phalcon_Http_Request, getRawBody){

	zval *raw;
	if (SG(request_info).raw_post_data) {
		RETURN_STRINGL(SG(request_info).raw_post_data, SG(request_info).raw_post_data_length, 1);
	}

	phalcon_read_property_this(&raw, getThis(), SL("_rawBody"), PH_NOISY TSRMLS_CC);
	if (Z_TYPE_P(raw) == IS_STRING) {
		RETURN_ZVAL(raw, 1, 1);
	}
	else if (sapi_module.read_post) {
		int read_bytes;
		char *buf          = emalloc(8192);
		smart_str raw_data = { NULL, 0, 0 };

		while ((read_bytes = sapi_module.read_post(buf, 8192 TSRMLS_CC)) > 0) {
			smart_str_appendl(&raw_data, buf, read_bytes);
			SG(read_post_bytes) += read_bytes;
		}

		efree(buf);
		if (raw_data.c) {
			smart_str_0(&raw_data);
			RETVAL_STRINGL(raw_data.c, raw_data.len, 0);
		}
		else {
			RETVAL_EMPTY_STRING();
		}

		phalcon_update_property_this(getThis(), SL("_rawBody"), return_value TSRMLS_CC);
	}
	else {
		RETURN_EMPTY_STRING();
	}
}
开发者ID:CreativeOutbreak,项目名称:cphalcon,代码行数:41,代码来源:request.c

示例13: php_yar_packager_get

zend_string *php_yar_packager_pack(char *packager_name, zval *pzval, char **msg) /* {{{ */ {
	char header[8];
	smart_str buf = {0};
	const yar_packager_t *packager = packager_name ?
		php_yar_packager_get(packager_name, strlen(packager_name)) : YAR_G(packager);

	if (!packager) {
		php_error_docref(NULL, E_ERROR, "unsupported packager %s", packager_name);
		return 0;
	}
	memcpy(header, packager->name, 8);
	smart_str_alloc(&buf, YAR_PACKAGER_BUFFER_SIZE /* 1M */, 0);
	smart_str_appendl(&buf, header, 8);
    packager->pack(packager, pzval, &buf, msg); 

	if (buf.s) {
		smart_str_0(&buf);
		return buf.s;
	}

	smart_str_free(&buf);

	return NULL;
} /* }}} */
开发者ID:laruence,项目名称:yar,代码行数:24,代码来源:yar_packager.c

示例14: PHP_METHOD

/**
 * Gets HTTP raw request body
 *
 * @return string
 */
PHP_METHOD(Phalcon_Http_Request, getRawBody){

	if (SG(request_info).raw_post_data) {
		RETURN_STRINGL(SG(request_info).raw_post_data, SG(request_info).raw_post_data_length, 1);
	}

	if (sapi_module.read_post) {
		int read_bytes;
		char *buf          = emalloc(8192);
		smart_str raw_data = { NULL, 0, 0 };

		while ((read_bytes = sapi_module.read_post(buf, 8192 TSRMLS_CC)) > 0) {
			smart_str_appendl(&raw_data, buf, read_bytes);
			SG(read_post_bytes) += read_bytes;
		}

		efree(buf);
		if (raw_data.c) {
			RETURN_STRINGL(raw_data.c, raw_data.len, 0);
		}
	}

	RETURN_EMPTY_STRING();
}
开发者ID:Diego-Brocanelli,项目名称:cphalcon,代码行数:29,代码来源:request.c

示例15: intl_parse_error_to_string

smart_str intl_parse_error_to_string( UParseError* pe )
{
	smart_str  ret = {0};
	char       *buf;
	size_t     u8len;
	UErrorCode status;
	int        any = 0;

	assert( pe != NULL );

	smart_str_appends( &ret, "parse error " );
	if( pe->line > 0 )
	{
		smart_str_appends( &ret, "on line " );
		smart_str_append_long( &ret, (zend_long ) pe->line );
		any = 1;
	}
	if( pe->offset >= 0 ) {
		if( any )
			smart_str_appends( &ret, ", " );
		else
			smart_str_appends( &ret, "at " );

		smart_str_appends( &ret, "offset " );
		smart_str_append_long( &ret, (zend_long ) pe->offset ); 
		any = 1;
	}

	if (pe->preContext[0] != 0 ) {
		if( any )
			smart_str_appends( &ret, ", " );

		smart_str_appends( &ret, "after \"" );
		intl_convert_utf16_to_utf8( &buf, &u8len, pe->preContext, -1, &status );
		if( U_FAILURE( status ) )
		{
			smart_str_appends( &ret, "(could not convert parser error pre-context to UTF-8)" );
		}
		else {
			smart_str_appendl( &ret, buf, u8len );
			efree( buf );
		}
		smart_str_appends( &ret, "\"" );
		any = 1;
	}

	if( pe->postContext[0] != 0 )
	{
		if( any )
			smart_str_appends( &ret, ", " );

		smart_str_appends( &ret, "before or at \"" );
		intl_convert_utf16_to_utf8( &buf, &u8len, pe->postContext, -1, &status );
		if( U_FAILURE( status ) )
		{
			smart_str_appends( &ret, "(could not convert parser error post-context to UTF-8)" );
		}
		else
		{
			smart_str_appendl( &ret, buf, u8len );
			efree( buf );
		}
		smart_str_appends( &ret, "\"" );
		any = 1;
	}

	if( !any )
	{
		smart_str_free( &ret );
		smart_str_appends( &ret, "no parse error" );
	}
	
	smart_str_0( &ret );
	return ret;
}
开发者ID:Tyrael,项目名称:php-src,代码行数:75,代码来源:intl_error.c


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