menuselect.h 5.7 KB

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