aboutsummaryrefslogtreecommitdiffstats
path: root/pbx.c
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-06-20 23:37:01 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-06-20 23:37:01 +0000
commitec0590611f9d5092ee7488a4b3b4d872782c6314 (patch)
tree60b67f937be0e7f1b5ed94de1ec88af1dad653e0 /pbx.c
parent8ba8a2e02e9156e7e04672c194c9e7eeb38eab27 (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-xpbx.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/pbx.c b/pbx.c
index b4df9be52..767023c85 100755
--- a/pbx.c
+++ b/pbx.c
@@ -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;