42 #include "asterisk/strings.h"
55 #if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
56 int __ast_debug_str_helper(
struct ast_str **buf, ssize_t max_len,
57 int append,
const char *fmt, va_list ap,
const char *file,
int lineno,
const char *
function)
60 int append,
const char *fmt, va_list ap)
64 int offset = (append && (*buf)->__AST_STR_LEN) ? (*buf)->__AST_STR_USED : 0;
69 max_len = (*buf)->__AST_STR_LEN;
76 res = vsnprintf((*buf)->__AST_STR_STR + offset, (*buf)->__AST_STR_LEN - offset, fmt, aq);
78 need = res + offset + 1;
83 if (need > (*buf)->__AST_STR_LEN && (max_len == 0 || (*buf)->__AST_STR_LEN < max_len) ) {
84 int len = (int)(*buf)->__AST_STR_LEN;
85 if (max_len && max_len < need) {
87 }
else if (max_len == 0) {
88 need += 16 + need / 4;
94 #
if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
95 _ast_str_make_space(buf, need, file, lineno,
function)
100 ast_verbose(
"failed to extend from %d to %d\n", len, need);
104 (*buf)->__AST_STR_STR[offset] =
'\0';
114 (*buf)->__AST_STR_USED = (res + offset > (*buf)->__AST_STR_LEN) ? (*buf)->__AST_STR_LEN - 1: res + offset;
122 char *ptr = append ? &((*buf)->__AST_STR_STR[(*buf)->__AST_STR_USED]) : (*buf)->__AST_STR_STR;
128 maxlen = (*buf)->__AST_STR_LEN;
131 while (*src && maxsrc && maxlen && (!escapecommas || (maxlen - 1))) {
132 if (escapecommas && (*src ==
'\\' || *src ==
',')) {
135 (*buf)->__AST_STR_USED++;
140 (*buf)->__AST_STR_USED++;
142 if ((ptr >= (*buf)->__AST_STR_STR + (*buf)->__AST_STR_LEN - 3) ||
143 (dynamic && (!maxlen || (escapecommas && !(maxlen - 1))))) {
144 char *oldbase = (*buf)->__AST_STR_STR;
145 size_t old = (*buf)->__AST_STR_LEN;
153 ptr += (*buf)->__AST_STR_STR - oldbase;
156 if (__builtin_expect(!maxlen, 0)) {
160 return (*buf)->__AST_STR_STR;
Asterisk main include file. File version handling, generic pbx functions.
void ast_verbose(const char *fmt,...)
int ast_str_make_space(struct ast_str **buf, size_t new_len)
Core PBX routines and definitions.
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
char * __ast_str_helper2(struct ast_str **buf, ssize_t max_len, const char *src, size_t maxsrc, int append, int escapecommas)
if(yyss+yystacksize-1<=yyssp)
int __ast_str_helper(struct ast_str **buf, ssize_t max_len, int append, const char *fmt, va_list ap)
Core functionality of ast_str_(set|append)_va.
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.