[asterisk-commits] branch group/autoconf_and_menuselect r8805 - /team/group/autoconf_and_menusel...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Jan 27 19:50:09 MST 2006


Author: russell
Date: Fri Jan 27 20:50:08 2006
New Revision: 8805

URL: http://svn.digium.com/view/asterisk?rev=8805&view=rev
Log:
make sure a module with unmet dependencies can not be selected

Modified:
    team/group/autoconf_and_menuselect/build_tools/menuselect.c

Modified: team/group/autoconf_and_menuselect/build_tools/menuselect.c
URL: http://svn.digium.com/view/asterisk/team/group/autoconf_and_menuselect/build_tools/menuselect.c?rev=8805&r1=8804&r2=8805&view=diff
==============================================================================
--- team/group/autoconf_and_menuselect/build_tools/menuselect.c (original)
+++ team/group/autoconf_and_menuselect/build_tools/menuselect.c Fri Jan 27 20:50:08 2006
@@ -1,7 +1,7 @@
 /*
  * Asterisk -- An open source telephony toolkit.
  *
- * Copyright (C) 2005, Russell Bryant
+ * Copyright (C) 2005 - 2006, Russell Bryant
  *
  * Russell Bryant <russell at digium.com>
  *
@@ -18,9 +18,9 @@
 
 /*
  * \file
- *
+ * \author Russell Bryant <russell at digium.com>
+ * 
  * \brief a generic 'make menuselect' system
- *
  */
 
 #include <stdlib.h>
@@ -52,7 +52,7 @@
 		__tmp = calloc(num, len); \
 		if (!__tmp) \
 			fprintf(stderr, "Memory allocation error!\n"); \
-		(__tmp); \
+		__tmp; \
 	})
 
 /*!
@@ -64,9 +64,13 @@
    options are enabled and disabled. This information is read from any existing
    build configuration, and then changed as the user navigates the system. We
    will then use this information to output a new build configuration file.
+
+  {
 */
 struct depend {
+	/*! the name of the dependency */
 	const char *name;
+	/*! for linking */
 	AST_LIST_ENTRY(depend) list;
 };
 
@@ -88,12 +92,19 @@
 };
 
 struct category {
+	/*! the Makefile variable */
 	const char *name;
+	/*! the name displayed in the menu */
 	const char *displayname;
+	/*! A description of this variable */
 	const char *desc;
+	/*! the list of possible values to be set in this variable */
 	AST_LIST_HEAD_NOLOCK(, member) members;
+	/*! for linking */
 	AST_LIST_ENTRY(category) list;
 };
+
+/*! } */
 
 AST_LIST_HEAD_NOLOCK_STATIC(categories, category);
 
@@ -105,10 +116,13 @@
    additional piece of information - whether the build option is enabled or not.
 */
 struct tree {
+	/*! the root of the tree */
 	mxml_node_t *root;
+	/*! for linking */
 	AST_LIST_ENTRY(tree) list;
 };
 
+/*! The list of trees from maketops.xml files */
 AST_LIST_HEAD_NOLOCK_STATIC(trees, tree);
 
 /*! The output build configuration file - TODO Make this optionally specified as a command line argument */
@@ -166,7 +180,7 @@
 	}
 
 	AST_LIST_INSERT_TAIL(&cat->members, mem, list);
-	
+
 	return 0;
 }
 
@@ -190,12 +204,14 @@
 		close(f);
 		return -1;
 	}
-	AST_LIST_INSERT_HEAD(&trees, tree, list);
 
 	if (!(tree->root = mxmlLoadFile(NULL, f, MXML_OPAQUE_CALLBACK))) {
 		close(f);
+		free(tree);
 		return -1;
 	}
+
+	AST_LIST_INSERT_HEAD(&trees, tree, list);
 
 	/* 
 	 * The following loop is explained here:
@@ -209,6 +225,12 @@
 	 * the member list for the category.
 	 */
 
+	/* TODO There is no need to require the 'category' tag.  The outer tag can simply
+	   be replaced with the name, and the name can be removed from inside. For example:
+	   <APPS>
+		...
+	   </APPS> 
+	*/
 	for (cur = mxmlFindElement(tree->root, tree->root, "category", NULL, NULL, MXML_DESCEND);
 	     cur;
 	     cur = mxmlFindElement(cur, tree->root, "category", NULL, NULL, MXML_DESCEND))
@@ -225,7 +247,7 @@
 			return -1;
 
 		cat->name = cur2->child->value.opaque;
-	
+
 		if ((cur2 = mxmlFindElement(cur, cur, "displayname", NULL, NULL, MXML_DESCEND)) && cur2->child)
 			cat->displayname = cur2->child->value.opaque;
 
@@ -245,10 +267,10 @@
 				fprintf(stderr, "Member listed in category '%s' with no name!  Moving on ...\n", cat->name);
 				continue;	
 			}
-			
+
 			if (!(mem = my_calloc(1, sizeof(*mem))))
 				return -1;
-			
+
 			mem->name = cur3->child->value.opaque;
 			if ((cur3 = mxmlFindElement(cur2, cur2, "description", NULL, NULL, MXML_DESCEND)) && cur3->child)
 				mem->desc = cur3->child->value.opaque;
@@ -274,7 +296,7 @@
 	}
 
 	close(f);
-	
+
 	return 0;
 }
 
@@ -340,7 +362,8 @@
 			continue;
 		AST_LIST_TRAVERSE(&cat->members, mem, list) {
 			if (!strcmp(member, mem->name)) {
-				mem->enabled = 1;
+				if (!mem->depsfailed)
+					mem->enabled = 1;
 				break;
 			}
 		}
@@ -350,7 +373,7 @@
 	}
 
 	if (!cat)
-		fprintf(stderr, "category '%s' not found!\n", category);
+		fprintf(stderr, "category '%s' not found! Can't mark '%s' as enabled.\n", category, member);
 }
 
 void toggle_enabled(struct category *cat, int index)
@@ -362,8 +385,8 @@
 		if (i++ == index)
 			break;
 	}
-	
-	if (mem)
+
+	if (mem && !mem->depsfailed)
 		mem->enabled = !mem->enabled;
 }
 
@@ -376,6 +399,7 @@
 
 	if (!(f = fopen(output_makeopts, "r"))) {
 #ifdef MENUSELECT_DEBUG
+		/* This isn't really an error, so only print the message in debug mode */
 		fprintf(stderr, "Unable to open '%s' for reading exisiting config.\n", output_makeopts);
 #endif	
 		return;
@@ -417,7 +441,6 @@
 	FILE *f;
 	struct category *cat;
 	struct member *mem;
-	int print_cat = 1;
 
 	if (!(f = fopen(output_makeopts, "w"))) {
 		fprintf(stderr, "Unable to open build configuration file (%s) for writing!\n", output_makeopts);
@@ -426,8 +449,6 @@
 
 	/* Traverse all categories (Makefile variables) */
 	AST_LIST_TRAVERSE(&categories, cat, list) {
-		if (AST_LIST_EMPTY(&cat->members))
-			continue;
 		fprintf(f, "%s=", cat->name);
 		/* Write out all enabled members (values) */
 		AST_LIST_TRAVERSE(&cat->members, mem, list) {
@@ -509,7 +530,7 @@
 	int i = 0;
 
 	wclear(menu);
-	
+
 	AST_LIST_TRAVERSE(&categories, cat, list) {
 		wmove(menu, i, max_x / 2 - 10);
 		if (!strlen_zero(cat->displayname))
@@ -556,6 +577,7 @@
 	char buf[64];
 	
 	wclear(menu);
+
 	AST_LIST_TRAVERSE(&cat->members, mem, list) {
 		if (i < start) {
 			i++;
@@ -572,7 +594,7 @@
 	}
 
 	wmove(menu, curopt - start, max_x / 2 - 9);
-	
+
 	wrefresh(menu);
 }
 
@@ -596,7 +618,7 @@
 	maxopt = count_members(cat) - 1;
 
 	draw_category_menu(menu, cat, start, end, curopt);
-	
+
 	while ((c = getch())) {
 		switch (c) {
 		case KEY_UP:



More information about the asterisk-commits mailing list