From c1924483f5976a09b74e1aaeb3e20e0ce7df12d0 Mon Sep 17 00:00:00 2001 From: tilghman Date: Sat, 17 Jul 2010 17:52:28 +0000 Subject: Merge issues... git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.2@277777 f38db490-d61c-443f-a65b-d21fe96a405b --- res/res_config_pgsql.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'res') diff --git a/res/res_config_pgsql.c b/res/res_config_pgsql.c index 9f996e0b5..14146e330 100644 --- a/res/res_config_pgsql.c +++ b/res/res_config_pgsql.c @@ -291,6 +291,18 @@ static struct columns *find_column(struct tables *t, const char *colname) return NULL; } +static char *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; +} + static struct ast_variable *realtime_pgsql(const char *database, const char *tablename, va_list ap) { PGresult *result = NULL; @@ -402,7 +414,7 @@ static struct ast_variable *realtime_pgsql(const char *database, const char *tab stringp = PQgetvalue(result, rowIndex, i); while (stringp) { chunk = strsep(&stringp, ";"); - if (chunk && !ast_strlen_zero(ast_realtime_decode_chunk(ast_strip(chunk)))) { + if (chunk && !ast_strlen_zero(decode_chunk(ast_strip(chunk)))) { if (prev) { prev->next = ast_variable_new(fieldnames[i], chunk, ""); if (prev->next) { @@ -561,7 +573,7 @@ static struct ast_config *realtime_multi_pgsql(const char *database, const char stringp = PQgetvalue(result, rowIndex, i); while (stringp) { chunk = strsep(&stringp, ";"); - if (chunk && !ast_strlen_zero(ast_realtime_decode_chunk(ast_strip(chunk)))) { + if (chunk && !ast_strlen_zero(decode_chunk(ast_strip(chunk)))) { if (initfield && !strcmp(initfield, fieldnames[i])) { ast_category_rename(cat, chunk); } -- cgit v1.2.3