diff options
author | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-06-20 23:37:01 +0000 |
---|---|---|
committer | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-06-20 23:37:01 +0000 |
commit | ec0590611f9d5092ee7488a4b3b4d872782c6314 (patch) | |
tree | 60b67f937be0e7f1b5ed94de1ec88af1dad653e0 /pbx.c | |
parent | 8ba8a2e02e9156e7e04672c194c9e7eeb38eab27 (diff) |
use ast_build_string() to build strings into buffers, and general cleanup of variable serializing functions used by 'show channel' (bug #4558)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@5944 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'pbx.c')
-rwxr-xr-x | pbx.c | 31 |
1 files changed, 16 insertions, 15 deletions
@@ -5667,24 +5667,25 @@ static int pbx_builtin_goto(struct ast_channel *chan, void *data) int pbx_builtin_serialize_variables(struct ast_channel *chan, char *buf, size_t size) { struct ast_var_t *variables; - struct varshead *headp; - char *var=NULL ,*val=NULL; + char *var, *val; int total = 0; - memset(buf,0,size); - if (chan) { - headp=&chan->varshead; - AST_LIST_TRAVERSE(headp,variables,entries) { - if(chan && variables && (var=ast_var_name(variables)) && (val=ast_var_value(variables)) && !ast_strlen_zero(var) && !ast_strlen_zero(val)) { - snprintf(buf + strlen(buf), size - strlen(buf), "%s=%s\n", var, val); - if(strlen(buf) >= size) { - ast_log(LOG_ERROR,"Data Buffer Size Exceeded!\n"); - break; - } - total++; - } else + if (!chan) + return 0; + + memset(buf, 0, size); + + AST_LIST_TRAVERSE(&chan->varshead, variables, entries) { + if(variables && + (var=ast_var_name(variables)) && (val=ast_var_value(variables)) && + !ast_strlen_zero(var) && !ast_strlen_zero(val)) { + if (ast_build_string(&buf, &size, "%s=%s\n", var, val)) { + ast_log(LOG_ERROR, "Data Buffer Size Exceeded!\n"); break; - } + } else + total++; + } else + break; } return total; |