[asterisk-commits] tilghman: trunk r49801 - in /trunk: funcs/
include/asterisk/ main/ res/
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Sun Jan 7 09:21:13 MST 2007
Author: tilghman
Date: Sun Jan 7 10:21:12 2007
New Revision: 49801
URL: http://svn.digium.com/view/asterisk?view=rev&rev=49801
Log:
When calling the Realtime app more than once, unset fields which were
previously set are erroneously still set (Bug 6701). After discussion,
it was determined this should only be changed in trunk.
Modified:
trunk/funcs/func_realtime.c
trunk/include/asterisk/config.h
trunk/main/config.c
trunk/res/res_config_odbc.c
trunk/res/res_realtime.c
Modified: trunk/funcs/func_realtime.c
URL: http://svn.digium.com/view/asterisk/trunk/funcs/func_realtime.c?view=diff&rev=49801&r1=49800&r2=49801
==============================================================================
--- trunk/funcs/func_realtime.c (original)
+++ trunk/funcs/func_realtime.c Sun Jan 7 10:21:12 2007
@@ -75,7 +75,7 @@
if (!args.delim2)
args.delim2 = "=";
- head = ast_load_realtime(args.family, args.fieldmatch, args.value, NULL);
+ head = ast_load_realtime_all(args.family, args.fieldmatch, args.value, NULL);
if (!head) {
ast_module_user_remove(u);
Modified: trunk/include/asterisk/config.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/config.h?view=diff&rev=49801&r1=49800&r2=49801
==============================================================================
--- trunk/include/asterisk/config.h (original)
+++ trunk/include/asterisk/config.h Sun Jan 7 10:21:12 2007
@@ -128,6 +128,7 @@
* MUST be freed with ast_variables_destroy() as there is no container.
*/
struct ast_variable *ast_load_realtime(const char *family, ...);
+struct ast_variable *ast_load_realtime_all(const char *family, ...);
/*! \brief Retrieve realtime configuration
* \param family which family/config to lookup
Modified: trunk/main/config.c
URL: http://svn.digium.com/view/asterisk/trunk/main/config.c?view=diff&rev=49801&r1=49800&r2=49801
==============================================================================
--- trunk/main/config.c (original)
+++ trunk/main/config.c Sun Jan 7 10:21:12 2007
@@ -1314,7 +1314,7 @@
return result;
}
-struct ast_variable *ast_load_realtime(const char *family, ...)
+struct ast_variable *ast_load_realtime_all(const char *family, ...)
{
struct ast_config_engine *eng;
char db[256]="";
@@ -1328,6 +1328,35 @@
res = eng->realtime_func(db, table, ap);
va_end(ap);
+ return res;
+}
+
+struct ast_variable *ast_load_realtime(const char *family, ...)
+{
+ struct ast_variable *res, *cur, *prev = NULL, *freeme = NULL;
+ va_list ap;
+
+ va_start(ap, family);
+ res = ast_load_realtime_all(family, ap);
+ va_end(ap);
+
+ /* Eliminate blank entries */
+ for (cur = res; cur; cur = cur->next) {
+ if (freeme) {
+ free(freeme);
+ freeme = NULL;
+ }
+
+ if (ast_strlen_zero(cur->value)) {
+ if (prev)
+ prev->next = cur->next;
+ else
+ res = cur->next;
+ freeme = cur;
+ } else {
+ prev = cur;
+ }
+ }
return res;
}
Modified: trunk/res/res_config_odbc.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_config_odbc.c?view=diff&rev=49801&r1=49800&r2=49801
==============================================================================
--- trunk/res/res_config_odbc.c (original)
+++ trunk/res/res_config_odbc.c Sun Jan 7 10:21:12 2007
@@ -168,7 +168,12 @@
indicator = 0;
res = SQLGetData(stmt, x + 1, SQL_CHAR, rowdata, sizeof(rowdata), &indicator);
if (indicator == SQL_NULL_DATA)
- continue;
+ rowdata[0] = '\0';
+ else if (ast_strlen_zero(rowdata)) {
+ /* Because we encode the empty string for a NULL, we will encode
+ * actual empty strings as a string containing a single whitespace. */
+ ast_copy_string(rowdata, " ", sizeof(rowdata));
+ }
if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
ast_log(LOG_WARNING, "SQL Get Data error!\n[%s]\n\n", sql);
@@ -180,15 +185,12 @@
stringp = rowdata;
while(stringp) {
chunk = strsep(&stringp, ";");
- if (!ast_strlen_zero(ast_strip(chunk))) {
- if (prev) {
- prev->next = ast_variable_new(coltitle, chunk);
- if (prev->next)
- prev = prev->next;
- } else
- prev = var = ast_variable_new(coltitle, chunk);
-
- }
+ if (prev) {
+ prev->next = ast_variable_new(coltitle, chunk);
+ if (prev->next)
+ prev = prev->next;
+ } else
+ prev = var = ast_variable_new(coltitle, chunk);
}
}
Modified: trunk/res/res_realtime.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_realtime.c?view=diff&rev=49801&r1=49800&r2=49801
==============================================================================
--- trunk/res/res_realtime.c (original)
+++ trunk/res/res_realtime.c Sun Jan 7 10:21:12 2007
@@ -57,7 +57,7 @@
return RESULT_FAILURE;
}
- var = ast_load_realtime(argv[2], argv[3], argv[4], NULL);
+ var = ast_load_realtime_all(argv[2], argv[3], argv[4], NULL);
if(var) {
ast_cli(fd, header_format, "Column Name", "Column Value");
More information about the asterisk-commits
mailing list