summaryrefslogtreecommitdiff
path: root/main/ast_expr2f.c
diff options
context:
space:
mode:
authorTilghman Lesher <tilghman@meg.abyt.es>2009-04-29 18:53:01 +0000
committerTilghman Lesher <tilghman@meg.abyt.es>2009-04-29 18:53:01 +0000
commita866a7590085a1f635ca92459c3917e5cded257a (patch)
tree972bdf8f96c18f1b9667469307af69385f4a75f3 /main/ast_expr2f.c
parent0ea83eab4811c8519e4e04bf4c59b1744cf1efc9 (diff)
Merge str_substitution branch.
This branch adds additional methods to dialplan functions, whereby the result buffers are now dynamic buffers, which can be expanded to the size of any result. No longer are variable substitutions limited to 4095 bytes of data. In addition, the common case of needing buffers much smaller than that will enable substitution to only take up the amount of memory actually needed. The existing variable substitution routines are still available, but users of those API calls should transition to using the dynamic-buffer APIs. Reviewboard: http://reviewboard.digium.com/r/174/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@191140 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/ast_expr2f.c')
-rw-r--r--main/ast_expr2f.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/main/ast_expr2f.c b/main/ast_expr2f.c
index 7c8d2f824..15dbb5c2e 100644
--- a/main/ast_expr2f.c
+++ b/main/ast_expr2f.c
@@ -2424,6 +2424,32 @@ int ast_expr(char *expr, char *buf, int length, struct ast_channel *chan)
return return_value;
}
+#if !defined(STANDALONE)
+int ast_str_expr(struct ast_str **str, ssize_t maxlen, struct ast_channel *chan, char *expr)
+{
+ struct parse_io io = { .string = expr, .chan = chan };
+
+ ast_yylex_init(&io.scanner);
+ ast_yy_scan_string(expr, io.scanner);
+ ast_yyparse ((void *) &io);
+ ast_yylex_destroy(io.scanner);
+
+ if (!io.val) {
+ ast_str_set(str, maxlen, "0");
+ } else {
+ if (io.val->type == AST_EXPR_number) {
+ int res_length;
+ ast_str_set(str, maxlen, FP___PRINTF, io.val->u.i);
+ } else if (io.val->u.s) {
+ ast_str_set(str, maxlen, "%s", io.val->u.s);
+ free(io.val->u.s);
+ }
+ free(io.val);
+ }
+ return ast_str_strlen(*str);
+}
+#endif
+
char extra_error_message[4095];
int extra_error_message_supplied = 0;