aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2006-12-18 15:38:50 +0000
committerrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2006-12-18 15:38:50 +0000
commitd78959e7456c504b505700d985d7b4d4abb8010a (patch)
tree78b512e0d17d9e20a9d7d06c5df6ed451fe520af /main
parent0c344600b1ce8b1eefd339707fc53502392a4774 (diff)
convert the final clients of ast_build_string to use ast_str_*()
Now the only module left using it is chan_sip.c git-svn-id: http://svn.digium.com/svn/asterisk/trunk@48559 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r--main/cdr.c11
-rw-r--r--main/cli.c10
-rw-r--r--main/pbx.c7
3 files changed, 15 insertions, 13 deletions
diff --git a/main/cdr.c b/main/cdr.c
index 309d73c0d..3f6215c88 100644
--- a/main/cdr.c
+++ b/main/cdr.c
@@ -344,7 +344,7 @@ int ast_cdr_copy_vars(struct ast_cdr *to_cdr, struct ast_cdr *from_cdr)
return x;
}
-int ast_cdr_serialize_variables(struct ast_cdr *cdr, char *buf, size_t size, char delim, char sep, int recur)
+int ast_cdr_serialize_variables(struct ast_cdr *cdr, struct ast_str **buf, char delim, char sep, int recur)
{
struct ast_var_t *variables;
const char *var, *val;
@@ -352,17 +352,18 @@ int ast_cdr_serialize_variables(struct ast_cdr *cdr, char *buf, size_t size, cha
char workspace[256];
int total = 0, x = 0, i;
- memset(buf, 0, size);
+ (*buf)->used = 0;
+ (*buf)->str[0] = '\0';
for (; cdr; cdr = recur ? cdr->next : NULL) {
if (++x > 1)
- ast_build_string(&buf, &size, "\n");
+ ast_str_append(buf, 0, "\n");
AST_LIST_TRAVERSE(&cdr->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, "level %d: %s%c%s%c", x, var, delim, val, sep)) {
+ if (ast_str_append(buf, 0, "level %d: %s%c%s%c", x, var, delim, val, sep) < 0) {
ast_log(LOG_ERROR, "Data Buffer Size Exceeded!\n");
break;
} else
@@ -376,7 +377,7 @@ int ast_cdr_serialize_variables(struct ast_cdr *cdr, char *buf, size_t size, cha
if (!tmp)
continue;
- if (ast_build_string(&buf, &size, "level %d: %s%c%s%c", x, cdr_readonly_vars[i], delim, tmp, sep)) {
+ if (ast_str_append(buf, 0, "level %d: %s%c%s%c", x, cdr_readonly_vars[i], delim, tmp, sep) < 0) {
ast_log(LOG_ERROR, "Data Buffer Size Exceeded!\n");
break;
} else
diff --git a/main/cli.c b/main/cli.c
index e2a3a6db8..d099ae409 100644
--- a/main/cli.c
+++ b/main/cli.c
@@ -766,7 +766,7 @@ static int handle_showchan(int fd, int argc, char *argv[])
{
struct ast_channel *c=NULL;
struct timeval now;
- char buf[2048];
+ struct ast_str *out = ast_str_alloca(2048);
char cdrtime[256];
char nf[256], wf[256], rf[256];
long elapsed_seconds=0;
@@ -837,10 +837,10 @@ static int handle_showchan(int fd, int argc, char *argv[])
( c-> data ? S_OR(c->data, "(Empty)") : "(None)"),
(ast_test_flag(c, AST_FLAG_BLOCKING) ? c->blockproc : "(Not Blocking)"));
- if(pbx_builtin_serialize_variables(c,buf,sizeof(buf)))
- ast_cli(fd," Variables:\n%s\n",buf);
- if(c->cdr && ast_cdr_serialize_variables(c->cdr,buf, sizeof(buf), '=', '\n', 1))
- ast_cli(fd," CDR Variables:\n%s\n",buf);
+ if(pbx_builtin_serialize_variables(c, &out))
+ ast_cli(fd," Variables:\n%s\n", out->str);
+ if(c->cdr && ast_cdr_serialize_variables(c->cdr, &out, '=', '\n', 1))
+ ast_cli(fd," CDR Variables:\n%s\n", out->str);
ast_channel_unlock(c);
return RESULT_SUCCESS;
diff --git a/main/pbx.c b/main/pbx.c
index 8a7d7200e..1e331c755 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -5644,7 +5644,7 @@ 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)
+int pbx_builtin_serialize_variables(struct ast_channel *chan, struct ast_str **buf)
{
struct ast_var_t *variables;
const char *var, *val;
@@ -5653,13 +5653,14 @@ int pbx_builtin_serialize_variables(struct ast_channel *chan, char *buf, size_t
if (!chan)
return 0;
- memset(buf, 0, size);
+ (*buf)->used = 0;
+ (*buf)->str[0] = '\0';
AST_LIST_TRAVERSE(&chan->varshead, variables, entries) {
if ((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)) {
+ if (ast_str_append(buf, 0, "%s=%s\n", var, val) < 0) {
ast_log(LOG_ERROR, "Data Buffer Size Exceeded!\n");
break;
} else