[asterisk-commits] jpeeler: branch jpeeler/manager-configactions r102322 - in /team/jpeeler/mana...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Feb 4 13:52:03 CST 2008


Author: jpeeler
Date: Mon Feb  4 13:52:02 2008
New Revision: 102322

URL: http://svn.digium.com/view/asterisk?view=rev&rev=102322
Log:
updateconfig updated to allow deletion with category/line combination

Modified:
    team/jpeeler/manager-configactions/include/asterisk/config.h
    team/jpeeler/manager-configactions/main/config.c
    team/jpeeler/manager-configactions/main/manager.c

Modified: team/jpeeler/manager-configactions/include/asterisk/config.h
URL: http://svn.digium.com/view/asterisk/team/jpeeler/manager-configactions/include/asterisk/config.h?view=diff&rev=102322&r1=102321&r2=102322
==============================================================================
--- team/jpeeler/manager-configactions/include/asterisk/config.h (original)
+++ team/jpeeler/manager-configactions/include/asterisk/config.h Mon Feb  4 13:52:02 2008
@@ -265,7 +265,7 @@
 struct ast_config_include *ast_include_find(struct ast_config *conf, const char *included_file);
 void ast_include_rename(struct ast_config *conf, const char *from_file, const char *to_file);
 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_delete(struct ast_category *category, const char *variable, const char *match, const char *line);
 int ast_variable_update(struct ast_category *category, const char *variable, 
 						const char *value, const char *match, unsigned int object);
 

Modified: team/jpeeler/manager-configactions/main/config.c
URL: http://svn.digium.com/view/asterisk/team/jpeeler/manager-configactions/main/config.c?view=diff&rev=102322&r1=102321&r2=102322
==============================================================================
--- team/jpeeler/manager-configactions/main/config.c (original)
+++ team/jpeeler/manager-configactions/main/config.c Mon Feb  4 13:52:02 2008
@@ -629,10 +629,11 @@
 	return config;
 }
 
-int ast_variable_delete(struct ast_category *category, const char *variable, const char *match)
+int ast_variable_delete(struct ast_category *category, const char *variable, const char *match, const char *line)
 {
 	struct ast_variable *cur, *prev=NULL, *curn;
 	int res = -1;
+	int lineno = 0;
 
 	cur = category->root;
 	while (cur) {
@@ -658,7 +659,7 @@
 	cur = category->root;
 	while (cur) {
 		curn = cur->next;
-		if (!strcasecmp(cur->name, variable) && (ast_strlen_zero(match) || !strcasecmp(cur->value, match))) {
+		if ((!ast_strlen_zero(line) && lineno == atoi(line)) || (ast_strlen_zero(line) && !strcasecmp(cur->name, variable) && (ast_strlen_zero(match) || !strcasecmp(cur->value, match)))) {
 			if (prev) {
 				prev->next = cur->next;
 				if (cur == category->last)
@@ -675,6 +676,7 @@
 			prev = cur;
 
 		cur = curn;
+		lineno++;
 	}
 	return res;
 }

Modified: team/jpeeler/manager-configactions/main/manager.c
URL: http://svn.digium.com/view/asterisk/team/jpeeler/manager-configactions/main/manager.c?view=diff&rev=102322&r1=102321&r2=102322
==============================================================================
--- team/jpeeler/manager-configactions/main/manager.c (original)
+++ team/jpeeler/manager-configactions/main/manager.c Mon Feb  4 13:52:02 2008
@@ -1222,7 +1222,7 @@
 {
 	int x;
 	char hdr[40];
-	const char *action, *cat, *var, *value, *match;
+	const char *action, *cat, *var, *value, *match, *line;
 	struct ast_category *category;
 	struct ast_variable *v;
 
@@ -1245,6 +1245,8 @@
 		}
 		snprintf(hdr, sizeof(hdr), "Match-%06d", x);
 		match = astman_get_header(m, hdr);
+		snprintf(hdr, sizeof(hdr), "Line-%06d", x);
+		line = astman_get_header(m, hdr);
 		if (!strcasecmp(action, "newcat")) {
 			if (!ast_strlen_zero(cat)) {
 				category = ast_category_new(cat, dfn, 99999);
@@ -1276,8 +1278,8 @@
 			else
 				return -3;
 		} 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);
+			if (!ast_strlen_zero(cat) && (!ast_strlen_zero(var) || !ast_strlen_zero(line)) && (category = ast_category_get(cfg, cat)))
+				ast_variable_delete(category, var, match, line);
 			else
 				return -3;
 		} else if (!strcasecmp(action, "append")) {




More information about the asterisk-commits mailing list