[asterisk-commits] markster: branch markster/usersconf r38500 - in /team/markster/usersconf: ./ ...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sat Jul 29 16:14:32 MST 2006


Author: markster
Date: Sat Jul 29 18:14:32 2006
New Revision: 38500

URL: http://svn.digium.com/view/asterisk?rev=38500&view=rev
Log:
Merged revisions 38489 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

........
r38489 | markster | 2006-07-29 17:02:37 -0500 (Sat, 29 Jul 2006) | 3 lines

Allow updates to match specific lines, allow specification of object or 
no when appending.

........

Modified:
    team/markster/usersconf/   (props changed)
    team/markster/usersconf/config.c
    team/markster/usersconf/include/asterisk/config.h
    team/markster/usersconf/manager.c

Propchange: team/markster/usersconf/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/markster/usersconf/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Sat Jul 29 18:14:32 2006
@@ -1,1 +1,1 @@
-/trunk:1-38482
+/trunk:1-38499

Modified: team/markster/usersconf/config.c
URL: http://svn.digium.com/view/asterisk/team/markster/usersconf/config.c?rev=38500&r1=38499&r2=38500&view=diff
==============================================================================
--- team/markster/usersconf/config.c (original)
+++ team/markster/usersconf/config.c Sat Jul 29 18:14:32 2006
@@ -333,9 +333,10 @@
 	return config;
 }
 
-int ast_variable_delete(struct ast_category *category, char *variable)
-{
-	struct ast_variable *cur, *prev=NULL;
+int ast_variable_delete(struct ast_category *category, char *variable, char *match)
+{
+	struct ast_variable *cur, *prev=NULL, *curn;
+	int res = -1;
 	cur = category->root;
 	while (cur) {
 		if (cur->name == variable) {
@@ -359,7 +360,8 @@
 	prev = NULL;
 	cur = category->root;
 	while (cur) {
-		if (!strcasecmp(cur->name, variable)) {
+		curn = cur->next;
+		if (!strcasecmp(cur->name, variable) && (ast_strlen_zero(match) || !strcasecmp(cur->value, match))) {
 			if (prev) {
 				prev->next = cur->next;
 				if (cur == category->last)
@@ -371,15 +373,16 @@
 			}
 			cur->next = NULL;
 			ast_variables_destroy(cur);
-			return 0;
-		}
-		prev = cur;
-		cur = cur->next;
-	}
-	return -1;
-}
-
-int ast_variable_update(struct ast_category *category, char *variable, char *value)
+			res = 0;
+		} else
+			prev = cur;
+
+		cur = curn;
+	}
+	return res;
+}
+
+int ast_variable_update(struct ast_category *category, char *variable, char *value, char *match)
 {
 	struct ast_variable *cur, *prev=NULL, *newer;
 	newer = ast_variable_new(variable, value);
@@ -389,6 +392,7 @@
 	while (cur) {
 		if (cur->name == variable) {
 			newer->next = cur->next;
+			newer->object = cur->object;
 			if (prev)
 				prev->next = newer;
 			else
@@ -406,8 +410,9 @@
 	prev = NULL;
 	cur = category->root;
 	while (cur) {
-		if (!strcasecmp(cur->name, variable)) {
+		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

Modified: team/markster/usersconf/include/asterisk/config.h
URL: http://svn.digium.com/view/asterisk/team/markster/usersconf/include/asterisk/config.h?rev=38500&r1=38499&r2=38500&view=diff
==============================================================================
--- team/markster/usersconf/include/asterisk/config.h (original)
+++ team/markster/usersconf/include/asterisk/config.h Sat Jul 29 18:14:32 2006
@@ -183,8 +183,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, char *variable);
-int ast_variable_update(struct ast_category *category, char *variable, char *value);
+int ast_variable_delete(struct ast_category *category, char *variable, char *match);
+int ast_variable_update(struct ast_category *category, char *variable, char *value, char *match);
 
 int config_text_file_save(const char *filename, const struct ast_config *cfg, const char *generator);
 

Modified: team/markster/usersconf/manager.c
URL: http://svn.digium.com/view/asterisk/team/markster/usersconf/manager.c?rev=38500&r1=38499&r2=38500&view=diff
==============================================================================
--- team/markster/usersconf/manager.c (original)
+++ team/markster/usersconf/manager.c Sat Jul 29 18:14:32 2006
@@ -925,7 +925,7 @@
 {
 	int x;
 	char hdr[40];
-	char *action, *cat, *var, *value;
+	char *action, *cat, *var, *value, *match;
 	struct ast_category *category;
 	struct ast_variable *v;
 	
@@ -940,6 +940,8 @@
 		var = astman_get_header(m, hdr);
 		snprintf(hdr, sizeof(hdr), "Value-%06d", x);
 		value = astman_get_header(m, hdr);
+		snprintf(hdr, sizeof(hdr), "Match-%06d", x);
+		match = astman_get_header(m, hdr);
 		if (!strcasecmp(action, "newcat")) {
 			if (!ast_strlen_zero(cat)) {
 				category = ast_category_new(cat);
@@ -958,14 +960,16 @@
 				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);
+				ast_variable_update(category, var, value, match);
 		} 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);
+				ast_variable_delete(category, var, match);
 		} else if (!strcasecmp(action, "append")) {
 			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"))
+					v->object = 1;
 				ast_variable_append(category, v);
 			}
 		}
@@ -982,6 +986,7 @@
 "   Cat-XXXXXX:    Category to operate on\n"
 "   Var-XXXXXX:    Variable to work on\n"
 "   Value-XXXXXX:  Value to work on\n"
+"   Match-XXXXXX:  Extra match required to match line\n"
 "   Reload:        Whether or not to reload ('yes', 'no' or a filename)\n";
 
 static int action_updateconfig(struct mansession *s, struct message *m)



More information about the asterisk-commits mailing list