aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2010-07-17 17:39:28 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2010-07-17 17:39:28 +0000
commitf4e254a73c91f23cc59fa9492ba92f167b821595 (patch)
tree4ca71aba7bd867ac3fdac2a3e9dc71db6ee2578d /main
parenta1269419a0b8f453471104158527bf486871a2bc (diff)
Merged revisions 277568 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r277568 | tilghman | 2010-07-16 16:54:29 -0500 (Fri, 16 Jul 2010) | 8 lines Since we split values at the semicolon, we should store values with a semicolon as an encoded value. (closes issue #17369) Reported by: gkservice Patches: 20100625__issue17369.diff.txt uploaded by tilghman (license 14) Tested by: tilghman ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@277773 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r--main/config.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/main/config.c b/main/config.c
index e1c51dcd6..f65c69e53 100644
--- a/main/config.c
+++ b/main/config.c
@@ -1,7 +1,7 @@
/*
* Asterisk -- An open source telephony toolkit.
*
- * Copyright (C) 1999 - 2005, Digium, Inc.
+ * Copyright (C) 1999 - 2010, Digium, Inc.
*
* Mark Spencer <markster@digium.com>
*
@@ -2297,6 +2297,35 @@ int ast_destroy_realtime(const char *family, const char *keyfield, const char *l
return res;
}
+char *ast_realtime_decode_chunk(char *chunk)
+{
+ char *orig = chunk;
+ for (; *chunk; chunk++) {
+ if (*chunk == '^' && strchr("0123456789ABCDEFabcdef", chunk[1]) && strchr("0123456789ABCDEFabcdef", chunk[2])) {
+ sscanf(chunk + 1, "%02hhd", chunk);
+ memmove(chunk + 1, chunk + 3, strlen(chunk + 3) + 1);
+ }
+ }
+ return orig;
+}
+
+char *ast_realtime_encode_chunk(struct ast_str **dest, ssize_t maxlen, const char *chunk)
+{
+ if (!strchr(chunk, ';') && !strchr(chunk, '^')) {
+ ast_str_set(dest, maxlen, "%s", chunk);
+ } else {
+ ast_str_reset(*dest);
+ for (; *chunk; chunk++) {
+ if (strchr(";^", *chunk)) {
+ ast_str_append(dest, maxlen, "^%02hhX", *chunk);
+ } else {
+ ast_str_append(dest, maxlen, "%c", *chunk);
+ }
+ }
+ }
+ return ast_str_buffer(*dest);
+}
+
/*! \brief Helper function to parse arguments
* See documentation in config.h
*/