[asterisk-commits] russell: trunk r61691 - in /trunk: ./ apps/ include/asterisk/ main/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Apr 20 11:23:25 MST 2007


Author: russell
Date: Fri Apr 20 13:23:24 2007
New Revision: 61691

URL: http://svn.digium.com/view/asterisk?view=rev&rev=61691
Log:
Merged revisions 61690 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r61690 | russell | 2007-04-20 13:19:18 -0500 (Fri, 20 Apr 2007) | 4 lines

Fix the UpdateConfig manager action to properly treat "variables" and "objects"
differently (a=b versus a=>b).
(issue #9568, reported by pari, patch by me)

........

Modified:
    trunk/   (props changed)
    trunk/apps/app_voicemail.c
    trunk/include/asterisk/config.h
    trunk/main/config.c
    trunk/main/manager.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_voicemail.c?view=diff&rev=61691&r1=61690&r2=61691
==============================================================================
--- trunk/apps/app_voicemail.c (original)
+++ trunk/apps/app_voicemail.c Fri Apr 20 13:23:24 2007
@@ -839,7 +839,7 @@
 					ast_log(LOG_WARNING, "Failed to get category structure.\n");
 					break;
 				}
-				ast_variable_update(cat, vmu->mailbox, new, NULL);
+				ast_variable_update(cat, vmu->mailbox, new, NULL, 0);
 			}
 		}
 		/* save the results */
@@ -871,7 +871,7 @@
 					break;
 				}
 				if (!var)		
-					ast_variable_update(cat, "vmsecret", new, NULL);
+					ast_variable_update(cat, "vmsecret", new, NULL, 0);
 				else
 					ast_variable_append(cat, var);
 			}
@@ -3967,7 +3967,7 @@
 				*duration += prepend_duration;
 				msg_cat = ast_category_get(msg_cfg, "message");
 				snprintf(duration_str, 11, "%ld", *duration);
-				if (!ast_variable_update(msg_cat, "duration", duration_str, NULL)) {
+				if (!ast_variable_update(msg_cat, "duration", duration_str, NULL, 0)) {
 					config_text_file_save(textfile, msg_cfg, "app_voicemail");
 					STORE(curdir, vmu->mailbox, context, curmsg, chan, vmu, vmfmts, *duration, vms);
 				}

Modified: trunk/include/asterisk/config.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/config.h?view=diff&rev=61691&r1=61690&r2=61691
==============================================================================
--- trunk/include/asterisk/config.h (original)
+++ trunk/include/asterisk/config.h Fri Apr 20 13:23:24 2007
@@ -212,7 +212,8 @@
 struct ast_variable *ast_variable_new(const char *name, const char *value);
 void ast_variable_append(struct ast_category *category, struct ast_variable *variable);
 int ast_variable_delete(struct ast_category *category, const char *variable, const char *match);
-int ast_variable_update(struct ast_category *category, const char *variable, const char *value, const char *match);
+int ast_variable_update(struct ast_category *category, const char *variable, 
+	const char *value, const char *match, unsigned int object);
 
 int config_text_file_save(const char *filename, const struct ast_config *cfg, const char *generator);
 

Modified: trunk/main/config.c
URL: http://svn.digium.com/view/asterisk/trunk/main/config.c?view=diff&rev=61691&r1=61690&r2=61691
==============================================================================
--- trunk/main/config.c (original)
+++ trunk/main/config.c Fri Apr 20 13:23:24 2007
@@ -468,54 +468,41 @@
 	return res;
 }
 
-int ast_variable_update(struct ast_category *category, const char *variable, const char *value, const char *match)
+int ast_variable_update(struct ast_category *category, const char *variable, 
+	const char *value, const char *match, unsigned int object)
 {
 	struct ast_variable *cur, *prev=NULL, *newer;
-	newer = ast_variable_new(variable, value);
-	if (!newer)
+
+	if (!(newer = ast_variable_new(variable, value)))
 		return -1;
-	cur = category->root;
-	while (cur) {
-		if (cur->name == variable) {
-			newer->next = cur->next;
-			newer->object = cur->object;
-			if (prev)
-				prev->next = newer;
-			else
-				category->root = newer;
-			if (category->last == cur)
-				category->last = newer;
-			cur->next = NULL;
-			ast_variables_destroy(cur);
-			return 0;
-		}
-		prev = cur;
-		cur = cur->next;
-	}
-
-	prev = NULL;
-	cur = category->root;
-	while (cur) {
-		if (!strcasecmp(cur->name, variable) && (ast_strlen_zero(match) || !strcasecmp(cur->value, match))) {
-			newer->next = cur->next;
-			newer->object = cur->object;
-			if (prev)
-				prev->next = newer;
-			else
-				category->root = newer;
-			if (category->last == cur)
-				category->last = newer;
-			cur->next = NULL;
-			ast_variables_destroy(cur);
-			return 0;
-		}
-		prev = cur;
-		cur = cur->next;
-	}
+	
+	newer->object = object;
+
+	for (cur = category->root; cur; prev = cur, cur = cur->next) {
+		if (strcasecmp(cur->name, variable) ||
+			(!ast_strlen_zero(match) && strcasecmp(cur->value, match)))
+			continue;
+
+		newer->next = cur->next;
+		newer->object = cur->object || object;
+		if (prev)
+			prev->next = newer;
+		else
+			category->root = newer;
+		if (category->last == cur)
+			category->last = newer;
+
+		cur->next = NULL;
+		ast_variables_destroy(cur);
+
+		return 0;
+	}
+
 	if (prev)
 		prev->next = newer;
 	else
 		category->root = newer;
+
 	return 0;
 }
 

Modified: trunk/main/manager.c
URL: http://svn.digium.com/view/asterisk/trunk/main/manager.c?view=diff&rev=61691&r1=61690&r2=61691
==============================================================================
--- trunk/main/manager.c (original)
+++ trunk/main/manager.c Fri Apr 20 13:23:24 2007
@@ -1121,6 +1121,8 @@
 	struct ast_variable *v;
 
 	for (x=0;x<100000;x++) {
+		unsigned int object = 0;
+
 		snprintf(hdr, sizeof(hdr), "Action-%06d", x);
 		action = astman_get_header(m, hdr);
 		if (ast_strlen_zero(action))
@@ -1131,6 +1133,10 @@
 		var = astman_get_header(m, hdr);
 		snprintf(hdr, sizeof(hdr), "Value-%06d", x);
 		value = astman_get_header(m, hdr);
+		if (!ast_strlen_zero(value) && *value == '>') {
+			object = 1;
+			value++;
+		}
 		snprintf(hdr, sizeof(hdr), "Match-%06d", x);
 		match = astman_get_header(m, hdr);
 		if (!strcasecmp(action, "newcat")) {
@@ -1151,7 +1157,7 @@
 				ast_category_delete(cfg, cat);
 		} else if (!strcasecmp(action, "update")) {
 			if (!ast_strlen_zero(cat) && !ast_strlen_zero(var) && (category = ast_category_get(cfg, cat)))
-				ast_variable_update(category, var, value, match);
+				ast_variable_update(category, var, value, match, object);
 		} else if (!strcasecmp(action, "delete")) {
 			if (!ast_strlen_zero(cat) && !ast_strlen_zero(var) && (category = ast_category_get(cfg, cat)))
 				ast_variable_delete(category, var, match);
@@ -1159,7 +1165,7 @@
 			if (!ast_strlen_zero(cat) && !ast_strlen_zero(var) &&
 				(category = ast_category_get(cfg, cat)) &&
 				(v = ast_variable_new(var, value))){
-				if (match && !strcasecmp(match, "object"))
+				if (object || (match && !strcasecmp(match, "object")))
 					v->object = 1;
 				ast_variable_append(category, v);
 			}



More information about the asterisk-commits mailing list