aboutsummaryrefslogtreecommitdiffstats
path: root/main/app.c
diff options
context:
space:
mode:
Diffstat (limited to 'main/app.c')
-rw-r--r--main/app.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/main/app.c b/main/app.c
index c9721d58b..3604c6352 100644
--- a/main/app.c
+++ b/main/app.c
@@ -43,6 +43,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/lock.h"
#include "asterisk/indications.h"
#include "asterisk/linkedlists.h"
+#include "asterisk/strings.h"
#define MAX_OTHER_FORMATS 10
@@ -1788,3 +1789,30 @@ int ast_get_encoded_str(const char *stream, char *result, size_t result_size)
return 0;
}
+int ast_str_get_encoded_str(struct ast_str **str, int maxlen, const char *stream)
+{
+ char next, *buf;
+ size_t offset = 0;
+ size_t consumed;
+
+ if (strchr(stream, '\\')) {
+ while (!ast_get_encoded_char(stream, &next, &consumed)) {
+ if (offset + 2 > ast_str_size(*str) && maxlen > -1) {
+ ast_str_make_space(str, maxlen > 0 ? maxlen : (ast_str_size(*str) + 48) * 2 - 48);
+ }
+ if (offset + 2 > ast_str_size(*str)) {
+ break;
+ }
+ buf = ast_str_buffer(*str);
+ buf[offset++] = next;
+ stream += consumed;
+ }
+ buf = ast_str_buffer(*str);
+ buf[offset++] = '\0';
+ ast_str_update(*str);
+ } else {
+ ast_str_set(str, maxlen, "%s", stream);
+ }
+ return 0;
+}
+