[svn-commits] jpeeler: branch jpeeler/manager-configactions r102373 - in /team/jpeeler/mana...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Feb 4 17:49:02 CST 2008


Author: jpeeler
Date: Mon Feb  4 17:49:01 2008
New Revision: 102373

URL: http://svn.digium.com/view/asterisk?view=rev&rev=102373
Log:
added insert to updateconfig allowing one to insert a variable above a given line

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=102373&r1=102372&r2=102373
==============================================================================
--- team/jpeeler/manager-configactions/include/asterisk/config.h (original)
+++ team/jpeeler/manager-configactions/include/asterisk/config.h Mon Feb  4 17:49:01 2008
@@ -265,6 +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);
+void ast_variable_insert(struct ast_category *category, struct ast_variable *variable, const char *line);
 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=102373&r1=102372&r2=102373
==============================================================================
--- team/jpeeler/manager-configactions/main/config.c (original)
+++ team/jpeeler/manager-configactions/main/config.c Mon Feb  4 17:49:01 2008
@@ -352,6 +352,27 @@
 	category->last = variable;
 	while (category->last->next)
 		category->last = category->last->next;
+}
+
+void ast_variable_insert(struct ast_category *category, struct ast_variable *variable, const char *line)
+{
+	struct ast_variable *cur = category->root;
+	int lineno;
+
+	if (!variable)
+		return;
+	if (atoi(line) == 0) {
+		variable->next = category->root;
+		category->root = variable;
+	} else {
+		for(lineno = 1; lineno < atoi(line); lineno++) {
+			cur = cur->next;
+			if (cur->next == NULL)
+				break;
+		}
+		variable->next = cur->next;
+		cur->next = variable;
+	}
 }
 
 void ast_variables_destroy(struct ast_variable *v)

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=102373&r1=102372&r2=102373
==============================================================================
--- team/jpeeler/manager-configactions/main/manager.c (original)
+++ team/jpeeler/manager-configactions/main/manager.c Mon Feb  4 17:49:01 2008
@@ -1292,6 +1292,13 @@
 			}
 			else
 				return -3;
+		} else if (!strcasecmp(action, "insert")) {
+			if (!ast_strlen_zero(cat) && !ast_strlen_zero(var) && !ast_strlen_zero(line) &&
+				(category = ast_category_get(cfg, cat)) &&
+				(v = ast_variable_new(var, value, dfn)))
+				ast_variable_insert(category, v, line);
+			else
+				return -3;
 		}
 		else {
 			ast_log(LOG_WARNING, "Action-%06d: %s not handled\n", x, action);
@@ -1308,7 +1315,7 @@
 "   SrcFilename:   Configuration filename to read(e.g. foo.conf)\n"
 "   DstFilename:   Configuration filename to write(e.g. foo.conf)\n"
 "   Reload:        Whether or not a reload should take place (or name of specific module)\n"
-"   Action-XXXXXX: Action to Take (NewCat,RenameCat,DelCat,EmptyCat,Update,Delete,Append)\n"
+"   Action-XXXXXX: Action to Take (NewCat,RenameCat,DelCat,EmptyCat,Update,Delete,Append,Insert)\n"
 "   Cat-XXXXXX:    Category to operate on\n"
 "   Var-XXXXXX:    Variable to work on\n"
 "   Value-XXXXXX:  Value to work on\n"
@@ -1353,7 +1360,7 @@
 			break;
 			case -2: astman_send_error(s, m, "Category not specified");
 			break;
-			case -3: astman_send_error(s, m, "Category or value not specified");
+			case -3: astman_send_error(s, m, "Problem with category, value, or line (if required)");
 			break;
 		}
 	}




More information about the svn-commits mailing list