Debian Codegraph @

menuselect/menuselect.h

raw symbols SCIP
1 /*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) 2005-2006, Russell Bryant
5 *
6 * Russell Bryant <[email protected]>
7 *
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
13 *
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
17 */
18
19 /*!
20 * \file
21 *
22 * \brief public data structures and defaults for menuselect
23 *
24 */
25
26 #ifndef MENUSELECT_H
27 #define MENUSELECT_H
28
29 #include "linkedlists.h"
30
31 #define OUTPUT_MAKEOPTS_DEFAULT "menuselect.makeopts"
32 #define OUTPUT_MAKEDEPS_DEFAULT "menuselect.makedeps"
33 #define MENUSELECT_DEPS "build_tools/menuselect-deps"
34
35 struct member;
36
37 struct reference {
38 /*! the name of the dependency */
39 const char *name;
40 /*! the display name of the dependency */
41 const char *displayname;
42 /*! if this dependency is a member, not an external object */
43 struct member *member;
44 /*! if this package was found */
45 unsigned char met:1;
46 /*! if this package should be autoselected */
47 unsigned char autoselect:1;
48 /*! for linking */
49 AST_LIST_ENTRY(reference) list;
50 };
51
52 enum failure_types {
53 NO_FAILURE = 0,
54 SOFT_FAILURE = 1,
55 HARD_FAILURE = 2,
56 };
57
58 AST_LIST_HEAD_NOLOCK(reference_list, reference);
59
60 struct member {
61 /*! What will be sent to the makeopts file */
62 const char *name;
63 /*! Display name if known */
64 const char *displayname;
65 /*! Default setting */
66 const char *defaultenabled;
67 /*! Delete these file(s) if this member changes */
68 const char *remove_on_change;
69 /*! Touch these file(s) if this member changes */
70 const char *touch_on_change;
71 const char *support_level;
72 const char *replacement;
73 const char *deprecated_in;
74 const char *removed_in;
75 /*! member_data is just an opaque, member-specific string */
76 const char *member_data;
77 /*! This module is currently selected */
78 unsigned int enabled:1;
79 /*! This module was enabled when the config was loaded */
80 unsigned int was_enabled:1;
81 /*! This module has failed dependencies */
82 unsigned int depsfailed:2;
83 /*! Previous failed dependencies when calculating */
84 unsigned int depsfailedold:2;
85 /*! This module has failed conflicts */
86 unsigned int conflictsfailed:2;
87 /*! This module's 'enabled' flag was changed by a default only */
88 unsigned int was_defaulted:1;
89 /*! This module is a dependency, and if it is selected then
90 we have included it in the MENUSELECT_BUILD_DEPS line
91 in the output file */
92 unsigned int build_deps_output:1;
93 /*! This module should never be enabled automatically, but only
94 * when explicitly set. */
95 unsigned int explicitly_enabled_only:1;
96 /*! This isn't actually a module! It's a separator, and it should
97 * be passed over for many of the usual purposes associated with members. */
98 unsigned int is_separator:1;
99 /*! dependencies of this module */
100 struct reference_list deps;
101 /*! conflicts of this module */
102 struct reference_list conflicts;
103 /*! optional packages used by this module */
104 struct reference_list uses;
105 /*! for making a list of modules */
106 AST_LIST_ENTRY(member) list;
107 };
108
109 enum support_level_values {
110 SUPPORT_CORE = 0,
111 SUPPORT_EXTENDED = 1,
112 SUPPORT_DEPRECATED = 2,
113 SUPPORT_UNSPECIFIED = 3,
114 SUPPORT_EXTERNAL = 4,
115 SUPPORT_OPTION = 5,
116 SUPPORT_COUNT = 6, /* Keep this item at the end of the list. Tracks total number of support levels. */
117 };
118
119 AST_LIST_HEAD_NOLOCK(support_level_bucket, member);
120
121 struct category {
122 /*! Workspace for building support levels */
123 struct support_level_bucket buckets[SUPPORT_COUNT];
124 /*! the Makefile variable */
125 const char *name;
126 /*! the name displayed in the menu */
127 const char *displayname;
128 /*! Delete these file(s) if anything in this category changes */
129 const char *remove_on_change;
130 /*! Touch these file(s) if anything in this category changes */
131 const char *touch_on_change;
132 /*! Output what is selected, as opposed to not selected */
133 unsigned int positive_output:1;
134 /*! All choices in this category are mutually exclusive */
135 unsigned int exclusive:1;
136 /*! the list of possible values to be set in this variable */
137 AST_LIST_HEAD_NOLOCK(, member) members;
138 /*! for linking */
139 AST_LIST_ENTRY(category) list;
140 };
141
142 extern AST_LIST_HEAD_NOLOCK(categories, category) categories;
143
144 extern const char *menu_name;
145
146 /*! This is implemented by the frontend */
147 int run_menu(void);
148
149 int count_categories(void);
150
151 int count_members(struct category *cat);
152
153 /*! \brief Toggle a member of a category at the specified index to enabled/disabled */
154 void toggle_enabled_index(struct category *cat, int index);
155
156 void toggle_enabled(struct member *mem);
157
158 /*! \brief Set a member of a category at the specified index to enabled */
159 void set_enabled(struct category *cat, int index);
160 /*! \brief Set a member of a category at the specified index to not enabled */
161 void clear_enabled(struct category *cat, int index);
162
163 /*! \brief Enable/Disable all members of a category as long as dependencies have been met and no conflicts are found */
164 void set_all(struct category *cat, int val);
165
166 /*! \brief returns non-zero if the string is not defined, or has zero length */
167 static inline int strlen_zero(const char *s)
168 {
169 return (!s || (*s == '\0'));
170 }
171
172 #if !defined(ast_strdupa) && defined(__GNUC__)
173 #define ast_strdupa(s) \
174 (__extension__ \
175 ({ \
176 const char *__old = (s); \
177 size_t __len = strlen(__old) + 1; \
178 char *__new = __builtin_alloca(__len); \
179 memcpy (__new, __old, __len); \
180 __new; \
181 }))
182 #endif
183
184 #endif /* MENUSELECT_H */