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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Feb 11 16:07:22 CST 2008


Author: jpeeler
Date: Mon Feb 11 16:07:22 2008
New Revision: 103323

URL: http://svn.digium.com/view/asterisk?view=rev&rev=103323
Log:
added match option for newcat action to insert above existing category

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=103323&r1=103322&r2=103323
==============================================================================
--- team/jpeeler/manager-configactions/include/asterisk/config.h (original)
+++ team/jpeeler/manager-configactions/include/asterisk/config.h Mon Feb 11 16:07:22 2008
@@ -254,6 +254,7 @@
 
 struct ast_category *ast_category_new(const char *name, const char *in_file, int lineno);
 void ast_category_append(struct ast_config *config, struct ast_category *cat);
+void ast_category_insert(struct ast_config *config, struct ast_category *cat, const char *match);
 int ast_category_delete(struct ast_config *cfg, const char *category);
 int ast_category_empty(struct ast_config *cfg, const char *category);
 void ast_category_destroy(struct ast_category *cat);

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=103323&r1=103322&r2=103323
==============================================================================
--- team/jpeeler/manager-configactions/main/config.c (original)
+++ team/jpeeler/manager-configactions/main/config.c Mon Feb 11 16:07:22 2008
@@ -362,7 +362,7 @@
 
 	if (!variable || sscanf(line, "%d", &insertline) != 1)
 		return;
-	if (atoi(line) == 0) {
+	if (insertline == 0) {
 		variable->next = category->root;
 		category->root = variable;
 	} else {
@@ -501,6 +501,26 @@
 	category->include_level = config->include_level;
 	config->last = category;
 	config->current = category;
+}
+
+void ast_category_insert(struct ast_config *config, struct ast_category *cat, const char *match)
+{
+	struct ast_category *cur_category;
+
+	if (!cat || !match)
+		return;
+	if (!strcasecmp(config->root->name, match)) {
+		cat->next = config->root;
+		config->root = cat;
+	} else {
+		for (cur_category = config->root; cur_category; cur_category = cur_category->next) {
+			if (!strcasecmp(cur_category->next->name, match)) {
+				cat->next = cur_category->next;
+				cur_category->next = cat;
+				break;
+			}
+		}
+	}
 }
 
 static void ast_destroy_comments(struct ast_category *cat)

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=103323&r1=103322&r2=103323
==============================================================================
--- team/jpeeler/manager-configactions/main/manager.c (original)
+++ team/jpeeler/manager-configactions/main/manager.c Mon Feb 11 16:07:22 2008
@@ -1262,9 +1262,13 @@
 		if (!strcasecmp(action, "newcat")) {
 			if (ast_strlen_zero(cat))
 				return UNSPECIFIED_CATEGORY;
-			if (!(category = ast_category_new(cat, dfn, 99999)))
+			if (!(category = ast_category_new(cat, dfn, -1))) /* TODO: -1 seems ok like in res_config_ldap.c */
 				return FAILURE_ALLOCATION;
-			ast_category_append(cfg, category);
+			if (ast_strlen_zero(match)) {
+				ast_category_append(cfg, category);
+			}
+			else
+				ast_category_insert(cfg, category, match);
 		} else if (!strcasecmp(action, "renamecat")) {
 			if (ast_strlen_zero(cat) || ast_strlen_zero(value))
 				return UNSPECIFIED_ARGUMENT;




More information about the asterisk-commits mailing list