[svn-commits] branch russell/autoconf_and_menuselect - r8091 in
/team/russell/autoconf_and_...
svn-commits at lists.digium.com
svn-commits at lists.digium.com
Sun Jan 15 20:02:07 MST 2006
Author: russell
Date: Sun Jan 15 21:02:05 2006
New Revision: 8091
URL: http://svn.digium.com/view/asterisk?rev=8091&view=rev
Log:
- store info about what modules depend on (which will soon be checked
against information generated by autoconf)
- add the ability to include the asterisk linked list macros, but exclude the
locking parts
Modified:
team/russell/autoconf_and_menuselect/build_tools/Makefile
team/russell/autoconf_and_menuselect/build_tools/menuselect.c
team/russell/autoconf_and_menuselect/include/asterisk/linkedlists.h
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=8091&r1=8090&r2=8091&view=diff
==============================================================================
--- team/russell/autoconf_and_menuselect/build_tools/Makefile (original)
+++ team/russell/autoconf_and_menuselect/build_tools/Makefile Sun Jan 15 21:02:05 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/asterisk/ menuselect.c
+ $(CC) -o menuselect.o -c -I../ -I../include/ 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=8091&r1=8090&r2=8091&view=diff
==============================================================================
--- team/russell/autoconf_and_menuselect/build_tools/menuselect.c (original)
+++ team/russell/autoconf_and_menuselect/build_tools/menuselect.c Sun Jan 15 21:02:05 2006
@@ -30,10 +30,11 @@
#include <curses.h>
#include "mxml/mxml.h"
-
-#include "linkedlists.h"
-
#include "menuselect.h"
+
+#define AST_LIST_NOLOCK
+#include "asterisk/linkedlists.h"
+#undef AST_LIST_NOLOCK
#define HELP_MESSAGE "scroll = up/down arrows, select = Enter, back = left arrow"
#define HELP_MESSAGE2 "quit = q, save and quit = x"
@@ -43,7 +44,7 @@
#define MIN_X 80
#define MIN_Y 25
-/* #define MENUSELECT_DEBUG */
+#define MENUSELECT_DEBUG
#define my_calloc(num, len) \
({ \
@@ -64,11 +65,18 @@
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 {
+ const char *name;
+ AST_LIST_ENTRY(depend) list;
+};
+
struct member {
const char *name;
const char *displayname;
const char *desc;
int enabled;
+ int depsmet;
+ AST_LIST_HEAD_NOLOCK(, depend) depends;
AST_LIST_ENTRY(member) list;
};
@@ -120,53 +128,39 @@
return str;
}
-struct category *add_category(const char *category, const char *displayname, const char *desc)
-{
- struct category *cat;
-
- 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->name = category;
- cat->displayname = displayname;
- cat->desc = desc;
+int add_category(struct category *cat)
+{
+ struct category *tmp;
+
+ AST_LIST_TRAVERSE(&categories, tmp, list) {
+ if (!strcmp(tmp->name, cat->name)) {
+ fprintf(stderr, "Category '%s' specified more than once!\n", cat->name);
+ return -1;
+ }
+ }
AST_LIST_INSERT_TAIL(&categories, cat, list);
- return cat;
-}
-
-struct member *add_member(const char *name, const char *displayname, const char *desc, struct category *cat)
-{
- struct member *mem;
-
- if (!cat)
- return NULL;
-
- AST_LIST_TRAVERSE(&cat->members, mem, list) {
- if (!strcmp(name, mem->name)) {
- fprintf(stderr, "Member '%s' already exists in category '%s', ignoring.\n", name, cat->name);
- return NULL;
- }
- }
-
- if (!(mem = my_calloc(1, sizeof(*mem))))
- return NULL;
-
- mem->name = name;
- mem->displayname = displayname;
- mem->desc = desc;
+ return 0;
+}
+
+int add_member(struct member *mem, struct category *cat)
+{
+ struct member *tmp;
+
+ if (!cat || !mem)
+ return -1;
+
+ AST_LIST_TRAVERSE(&cat->members, tmp, list) {
+ if (!strcmp(tmp->name, mem->name)) {
+ fprintf(stderr, "Member '%s' already exists in category '%s', ignoring.\n", mem->name, cat->name);
+ return -1;
+ }
+ }
AST_LIST_INSERT_TAIL(&cat->members, mem, list);
- return mem;
+ return 0;
}
int parse_makeopts_xml(const char *makeopts_xml)
@@ -174,12 +168,8 @@
FILE *f;
struct category *cat;
struct tree *tree;
- const char *mem_name;
- const char *mem_displayname;
- const char *mem_desc;
- const char *cat_name;
- const char *cat_displayname;
- const char *cat_desc;
+ struct member *mem;
+ struct depend *dep;
mxml_node_t *cur;
mxml_node_t *cur2;
mxml_node_t *cur3;
@@ -224,20 +214,21 @@
fprintf(stderr, "category with empty name!\n");
continue;
}
- cat_name = cur2->child->value.opaque;
+ if (!(cat = my_calloc(1, sizeof(*cat))))
+ 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;
- else
- cat_displayname = NULL;
+ cat->displayname = cur2->child->value.opaque;
if ((cur2 = mxmlFindElement(cur, cur, "description", NULL, NULL, MXML_DESCEND)) && cur2->child)
- cat_desc = cur2->child->value.opaque;
- else
- cat_desc = NULL;
-
- if (!(cat = add_category(cat_name, cat_displayname, cat_desc)))
- continue;
+ cat->desc = cur2->child->value.opaque;
+
+ if (add_category(cat)) {
+ free(cat);
+ continue;
+ }
for (cur2 = mxmlFindElement(cur, cur, "member", NULL, NULL, MXML_DESCEND);
cur2;
@@ -247,23 +238,31 @@
fprintf(stderr, "Member listed in category '%s' with no name! Moving on ...\n", cat->name);
continue;
}
- if (!cur3->child) {
- fprintf(stderr, "Member with empty name in category '%s'!\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;
+ if ((cur3 = mxmlFindElement(cur2, cur2, "displayname", NULL, NULL, MXML_DESCEND)) && cur3->child)
+ mem->displayname = cur3->child->value.opaque;
+
+ for (cur3 = mxmlFindElement(cur2, cur2, "depend", NULL, NULL, MXML_DESCEND);
+ cur3 && cur3->child;
+ cur3 = mxmlFindElement(cur3, cur2, "depend", NULL, NULL, MXML_DESCEND))
+ {
+ if (!(dep = my_calloc(1, sizeof(*dep))))
+ return -1;
+ if (!strlen_zero(cur3->child->value.opaque)) {
+ dep->name = cur3->child->value.opaque;
+ AST_LIST_INSERT_HEAD(&mem->depends, dep, list);
+ } else
+ free(dep);
}
- mem_name = cur3->child->value.opaque;
-
- if ((cur3 = mxmlFindElement(cur2, cur2, "description", NULL, NULL, MXML_DESCEND)) && cur3->child)
- mem_desc = cur3->child->value.opaque;
- else
- mem_desc = NULL;
-
- if ((cur3 = mxmlFindElement(cur2, cur2, "displayname", NULL, NULL, MXML_DESCEND)) && cur3->child)
- mem_displayname = cur3->child->value.opaque;
- else
- mem_displayname = NULL;
-
- add_member(mem_name, mem_displayname, mem_desc, cat);
+
+ if (add_member(mem, cat))
+ free(mem);
}
}
@@ -402,6 +401,7 @@
{
struct category *cat;
struct member *mem;
+ struct depend *dep;
AST_LIST_TRAVERSE(&categories, cat, list) {
fprintf(stderr, "Category: '%s'\n", cat->name);
@@ -411,6 +411,8 @@
fprintf(stderr, " ==>> Member: '%s' (%s)\n", mem->name, mem->enabled ? "Enabled" : "Disabled");
if (!strlen_zero(mem->desc))
fprintf(stderr, " --> Description: '%s'\n", mem->desc);
+ AST_LIST_TRAVERSE(&mem->depends, dep, list)
+ fprintf(stderr, " --> Depends on: '%s'\n", dep->name);
}
}
}
Modified: team/russell/autoconf_and_menuselect/include/asterisk/linkedlists.h
URL: http://svn.digium.com/view/asterisk/team/russell/autoconf_and_menuselect/include/asterisk/linkedlists.h?rev=8091&r1=8090&r2=8091&view=diff
==============================================================================
--- team/russell/autoconf_and_menuselect/include/asterisk/linkedlists.h (original)
+++ team/russell/autoconf_and_menuselect/include/asterisk/linkedlists.h Sun Jan 15 21:02:05 2006
@@ -17,15 +17,16 @@
* at the top of the source tree.
*/
+/*!
+ \file linkedlists.h
+ \brief A set of macros to manage forward-linked lists.
+*/
+
#ifndef ASTERISK_LINKEDLISTS_H
#define ASTERISK_LINKEDLISTS_H
+#ifndef AST_LIST_NOLOCK
#include "asterisk/lock.h"
-
-/*!
- \file linkedlists.h
- \brief A set of macros to manage forward-linked lists.
-*/
/*!
\brief Attempts to lock a list.
@@ -73,31 +74,6 @@
struct type *first; \
struct type *last; \
ast_mutex_t lock; \
-}
-
-/*!
- \brief Defines a structure to be used to hold a list of specified type (with no lock).
- \param name This will be the name of the defined structure.
- \param type This is the type of each list entry.
-
- This macro creates a structure definition that can be used
- to hold a list of the entries of type \a type. It does not actually
- declare (allocate) a structure; to do that, either follow this
- macro with the desired name of the instance you wish to declare,
- or use the specified \a name to declare instances elsewhere.
-
- Example usage:
- \code
- static AST_LIST_HEAD_NOLOCK(entry_list, entry) entries;
- \endcode
-
- This would define \c struct \c entry_list, and declare an instance of it named
- \a entries, all intended to hold a list of type \c struct \c entry.
-*/
-#define AST_LIST_HEAD_NOLOCK(name, type) \
-struct name { \
- struct type *first; \
- struct type *last; \
}
/*!
@@ -129,6 +105,75 @@
};
/*!
+ \brief Initializes a list head structure with a specified first entry.
+ \param head This is a pointer to the list head structure
+ \param entry pointer to the list entry that will become the head of the list
+
+ This macro initializes a list head structure by setting the head
+ entry to the supplied value and recreating the embedded lock.
+*/
+#define AST_LIST_HEAD_SET(head, entry) do { \
+ (head)->first = (entry); \
+ (head)->last = (entry); \
+ ast_mutex_init(&(head)->lock); \
+} while (0)
+
+/*!
+ \brief Initializes a list head structure.
+ \param head This is a pointer to the list head structure
+
+ This macro initializes a list head structure by setting the head
+ entry to \a NULL (empty list) and recreating the embedded lock.
+*/
+#define AST_LIST_HEAD_INIT(head) { \
+ (head)->first = NULL; \
+ (head)->last = NULL; \
+ ast_mutex_init(&(head)->lock); \
+}
+
+/*!
+ \brief Destroys a list head structure.
+ \param head This is a pointer to the list head structure
+
+ This macro destroys a list head structure by setting the head
+ entry to \a NULL (empty list) and destroying the embedded lock.
+ It does not free the structure from memory.
+*/
+#define AST_LIST_HEAD_DESTROY(head) { \
+ (head)->first = NULL; \
+ (head)->last = NULL; \
+ ast_mutex_destroy(&(head)->lock); \
+}
+
+
+#endif /* AST_LIST_NOLOCK */
+
+/*!
+ \brief Defines a structure to be used to hold a list of specified type (with no lock).
+ \param name This will be the name of the defined structure.
+ \param type This is the type of each list entry.
+
+ This macro creates a structure definition that can be used
+ to hold a list of the entries of type \a type. It does not actually
+ declare (allocate) a structure; to do that, either follow this
+ macro with the desired name of the instance you wish to declare,
+ or use the specified \a name to declare instances elsewhere.
+
+ Example usage:
+ \code
+ static AST_LIST_HEAD_NOLOCK(entry_list, entry) entries;
+ \endcode
+
+ This would define \c struct \c entry_list, and declare an instance of it named
+ \a entries, all intended to hold a list of type \c struct \c entry.
+*/
+#define AST_LIST_HEAD_NOLOCK(name, type) \
+struct name { \
+ struct type *first; \
+ struct type *last; \
+}
+
+/*!
\brief Defines a structure to be used to hold a list of specified type, statically initialized.
This is the same as AST_LIST_HEAD_STATIC, except without the lock included.
@@ -141,20 +186,6 @@
.first = NULL, \
.last = NULL, \
};
-
-/*!
- \brief Initializes a list head structure with a specified first entry.
- \param head This is a pointer to the list head structure
- \param entry pointer to the list entry that will become the head of the list
-
- This macro initializes a list head structure by setting the head
- entry to the supplied value and recreating the embedded lock.
-*/
-#define AST_LIST_HEAD_SET(head, entry) do { \
- (head)->first = (entry); \
- (head)->last = (entry); \
- ast_mutex_init(&(head)->lock); \
-} while (0)
/*!
\brief Initializes a list head structure with a specified first entry.
@@ -317,33 +348,6 @@
\brief Closes a safe loop traversal block.
*/
#define AST_LIST_TRAVERSE_SAFE_END }
-
-/*!
- \brief Initializes a list head structure.
- \param head This is a pointer to the list head structure
-
- This macro initializes a list head structure by setting the head
- entry to \a NULL (empty list) and recreating the embedded lock.
-*/
-#define AST_LIST_HEAD_INIT(head) { \
- (head)->first = NULL; \
- (head)->last = NULL; \
- ast_mutex_init(&(head)->lock); \
-}
-
-/*!
- \brief Destroys a list head structure.
- \param head This is a pointer to the list head structure
-
- This macro destroys a list head structure by setting the head
- entry to \a NULL (empty list) and destroying the embedded lock.
- It does not free the structure from memory.
-*/
-#define AST_LIST_HEAD_DESTROY(head) { \
- (head)->first = NULL; \
- (head)->last = NULL; \
- ast_mutex_destroy(&(head)->lock); \
-}
/*!
\brief Initializes a list head structure.
More information about the svn-commits
mailing list