[svn-commits] branch russell/make_menuconfig - r7596 /team/russell/make_menuconfig/build_to...

svn-commits at lists.digium.com svn-commits at lists.digium.com
Thu Dec 22 12:42:07 CST 2005


Author: russell
Date: Thu Dec 22 12:42:05 2005
New Revision: 7596

URL: http://svn.digium.com/view/asterisk?rev=7596&view=rev
Log:
store all xml trees in a list, in preperation for splitting up the makeopts.xml
file into one for each sub directory

Modified:
    team/russell/make_menuconfig/build_tools/menuconfig.c

Modified: team/russell/make_menuconfig/build_tools/menuconfig.c
URL: http://svn.digium.com/view/asterisk/team/russell/make_menuconfig/build_tools/menuconfig.c?rev=7596&r1=7595&r2=7596&view=diff
==============================================================================
--- team/russell/make_menuconfig/build_tools/menuconfig.c (original)
+++ team/russell/make_menuconfig/build_tools/menuconfig.c Thu Dec 22 12:42:05 2005
@@ -79,13 +79,16 @@
 } *categories = NULL;
 
 /*!
-   We have to maintain a pointer to the root of the tree generated from reading
-   the build options XML file so that we can free it when we're done.  We don't
-   copy any of the information over from this tree. Our list is just a 
-   convenient mapping to the information contained in this list with one
+   We have to maintain a pointer to the root of the trees generated from reading
+   the build options XML files so that we can free it when we're done.  We don't
+   copy any of the information over from these trees. Our list is just a 
+   convenient mapping to the information contained in these lists with one
    additional piece of information - whether the build option is enabled or not.
 */
-static mxml_node_t *root;
+static struct tree {
+	mxml_node_t *root;
+	struct tree *next;
+} *trees = NULL;
 
 /*! The input build options file - TODO Make this optionally specified as a command line argument */
 static const char *build_options = BUILD_OPTIONS_DEFAULT;
@@ -180,6 +183,7 @@
 {
 	FILE *f;
 	struct category *cat;
+	struct tree *tree;
 	const char *mem_name;
 	const char *mem_displayname;
 	const char *mem_desc;
@@ -196,8 +200,16 @@
 		return -1;
 	}
 
-	root = mxmlLoadFile(NULL, f, MXML_OPAQUE_CALLBACK);
-	if (!root) {
+	tree = my_calloc(1, sizeof(struct tree));
+	if (!tree) {
+		close(f);
+		return -1;
+	}
+	tree->next = trees;
+	trees = tree;
+
+	tree->root = mxmlLoadFile(NULL, f, MXML_OPAQUE_CALLBACK);
+	if (!tree->root) {
 		close(f);
 		return -1;
 	}
@@ -214,9 +226,9 @@
 	 * the member list for the category.
 	 */
 
-	for (cur = mxmlFindElement(root, root, "category", NULL, NULL, MXML_DESCEND);
+	for (cur = mxmlFindElement(tree->root, tree->root, "category", NULL, NULL, MXML_DESCEND);
 	     cur;
-	     cur = mxmlFindElement(cur, root, "category", NULL, NULL, MXML_DESCEND))
+	     cur = mxmlFindElement(cur, tree->root, "category", NULL, NULL, MXML_DESCEND))
 	{
 		cur2 = mxmlFindElement(cur, cur, "name", NULL, NULL, MXML_DESCEND);
 		if (!cur2) {
@@ -441,6 +453,18 @@
 			free(mem);
 		}
 		free(cat);
+	}
+}
+
+void free_trees(void)
+{
+	struct tree *cur;
+	struct tree *next;
+
+	for (cur = trees; cur; cur = next) {
+		next = cur->next;
+		mxmlDelete(cur->root);
+		free(cur);
 	}
 }
 
@@ -681,24 +705,30 @@
 {
 	int res = 1;
 
+	/* Parse the input XML files to build the list of available options */
 	if (build_member_list()) {
 		fprintf(stderr, "Unable to build the list of available build options from '%s'!\n", build_options);
 		exit(res);
 	}
 
+	/* Read in the existing makeopts, if they exist */
 	parse_existing_config();
 
 #ifdef MENUCONFIG_DEBUG
+	/* Dump the list produced by parsing the input XML and show which ones
+	   are already enabled by reading in the existing config */
 	dump_member_list();
 #endif
 
+	/* Run the menu to let the user enable/disable options */
 	res = run_menu();
 
+	/* If all is good, save the new config */
 	if (!res)
 		res = output_build_config();
 
-	mxmlDelete(root);
-
+	/* free everything we allocated */	
+	free_trees();
 	free_member_list();	
 
 	exit(res);



More information about the svn-commits mailing list