[svn-commits] branch russell/autoconf_and_menuselect - r8018 /team/russell/autoconf_and_men...

svn-commits at lists.digium.com svn-commits at lists.digium.com
Thu Jan 12 12:12:48 CST 2006


Author: russell
Date: Thu Jan 12 12:12:45 2006
New Revision: 8018

URL: http://svn.digium.com/view/asterisk?rev=8018&view=rev
Log: (empty)

Modified:
    team/russell/autoconf_and_menuselect/build_tools/Makefile
    team/russell/autoconf_and_menuselect/build_tools/menuselect.c

Modified: team/russell/autoconf_and_menuselect/build_tools/Makefile
URL: http://svn.digium.com/view/asterisk/team/russell/autoconf_and_menuselect/build_tools/Makefile?rev=8018&r1=8017&r2=8018&view=diff
==============================================================================
--- team/russell/autoconf_and_menuselect/build_tools/Makefile (original)
+++ team/russell/autoconf_and_menuselect/build_tools/Makefile Thu Jan 12 12:12:45 2006
@@ -2,7 +2,7 @@
 	$(CC) -o menuselect menuselect.o ../mxml/libmxml.a -lcurses
 
 menuselect.o: menuselect.c menuselect.h
-	$(CC) -o menuselect.o -c -I../ -I../include/ menuselect.c
+	$(CC) -o menuselect.o -c -I../ -I../include/asterisk/ menuselect.c
 
 clean:
 	rm -f menuselect menuselect.o

Modified: team/russell/autoconf_and_menuselect/build_tools/menuselect.c
URL: http://svn.digium.com/view/asterisk/team/russell/autoconf_and_menuselect/build_tools/menuselect.c?rev=8018&r1=8017&r2=8018&view=diff
==============================================================================
--- team/russell/autoconf_and_menuselect/build_tools/menuselect.c (original)
+++ team/russell/autoconf_and_menuselect/build_tools/menuselect.c Thu Jan 12 12:12:45 2006
@@ -31,6 +31,8 @@
 
 #include "mxml/mxml.h"
 
+#include "linkedlists.h"
+
 #include "menuselect.h"
 
 #define HELP_MESSAGE	"scroll = up/down arrows, select = Enter, back = left arrow"
@@ -75,8 +77,10 @@
 	const char *displayname;
 	const char *desc;
 	struct member *members;
-	struct category *next;
-} *categories = NULL;
+	AST_LIST_ENTRY(category) list;
+};
+
+AST_LIST_HEAD_NOLOCK_STATIC(categories, category);
 
 /*!
    We have to maintain a pointer to the root of the trees generated from reading
@@ -117,29 +121,22 @@
 struct category *add_category(const char *category, const char *displayname, const char *desc)
 {
 	struct category *cat;
-	struct category *cat_prev = NULL;
-
-	for (cat = categories; cat; cat = cat->next) {
-		if (!strcmp(category, cat->name))
-			break;
-		cat_prev = cat;
-	}
-	if (cat) {
-		fprintf(stderr, "Category '%s' specified more than once!\n", category);
+
+	AST_LIST_TRAVERSE(&categories, cat, list) {
+		if (!strcmp(category, cat->name)) {
+			fprintf(stderr, "Category '%s' specified more than once!\n", category);
+			return NULL;
+		}
+	}
+
+	if (!(cat = my_calloc(1, sizeof(*cat))))
 		return NULL;
-	}
-
-	cat = my_calloc(1, sizeof(struct category));
-	if (!cat)
-		return NULL;	
-
-	if (!categories)
-		categories = cat;
-	if (cat_prev)
-		cat_prev->next = cat;
+
 	cat->name = category;
 	cat->displayname = displayname;
 	cat->desc = desc;
+
+	AST_LIST_INSERT_TAIL(&categories, cat, list);
 
 	return cat;
 }
@@ -299,7 +296,7 @@
 	struct category *cat;
 	struct member *mem;
 
-	for (cat = categories; cat; cat = cat->next) {
+	AST_LIST_TRAVERSE(&categories, cat, list) {
 		if (strcmp(category, cat->name))
 			continue;
 
@@ -391,7 +388,7 @@
 		return -1;
 	}
 
-	for (cat = categories; cat; cat = cat->next) {
+	AST_LIST_TRAVERSE(&categories, cat, list) {
 		if (!cat->members)
 			continue;
 
@@ -422,7 +419,7 @@
 	struct category *cat;
 	struct member *mem;
 
-	for (cat = categories; cat; cat = cat->next) {
+	AST_LIST_TRAVERSE(&categories, cat, list) {
 		fprintf(stderr, "Category: '%s'\n", cat->name);
 		if (!strlen_zero(cat->desc))
 			fprintf(stderr, " --> Description: '%s'\n", cat->desc);
@@ -438,18 +435,17 @@
 void free_member_list(void)
 {
 	struct category *cat;
-	struct category *cat_next;
 	struct member *mem;
 	struct member *mem_next;
 
-	for (cat = categories; cat; cat = cat_next) {
-		cat_next = cat->next;
+	AST_LIST_TRAVERSE_SAFE_BEGIN(&categories, cat, list) {
 		for (mem = cat->members; mem; mem = mem_next) { 
 			mem_next = mem->next;
 			free(mem);
 		}
 		free(cat);
 	}
+	AST_LIST_TRAVERSE_SAFE_END
 }
 
 void free_trees(void)
@@ -483,7 +479,7 @@
 
 	wclear(menu);
 	
-	for (cat = categories; cat; cat = cat->next) {
+	AST_LIST_TRAVERSE(&categories, cat, list) {
 		wmove(menu, i, max_x / 2 - 10);
 		if (!strlen_zero(cat->displayname))
 			snprintf(buf, sizeof(buf), "%d. %s", ++i, cat->displayname);
@@ -504,7 +500,7 @@
 	struct category *cat;
 	int count = 0;
 
-	for (cat = categories; cat; cat = cat->next)
+	AST_LIST_TRAVERSE(&categories, cat, list);
 		count++;
 
 	return count;		
@@ -514,9 +510,6 @@
 {
 	struct member *mem;
 	int count = 0;
-
-	if (!cat)
-		return 0;
 
 	for (mem = cat->members; mem; mem = mem->next)
 		count++;
@@ -559,7 +552,7 @@
 	int curopt = 0;
 	int maxopt;
 
-	for (cat = categories; cat; cat = cat->next) {
+	AST_LIST_TRAVERSE(&categories, cat, list) {
 		if (i++ == cat_num)
 			break;
 	}



More information about the svn-commits mailing list