lkc.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /*
  2. * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
  3. * Released under the terms of the GNU GPL v2.0.
  4. */
  5. #ifndef LKC_H
  6. #define LKC_H
  7. #include "expr.h"
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. #include "lkc_proto.h"
  12. #define SRCTREE "srctree"
  13. #ifndef PACKAGE
  14. #define PACKAGE "linux"
  15. #endif
  16. #ifndef CONFIG_
  17. #define CONFIG_ "CONFIG_"
  18. #endif
  19. static inline const char *CONFIG_prefix(void)
  20. {
  21. return getenv( "CONFIG_" ) ?: CONFIG_;
  22. }
  23. #undef CONFIG_
  24. #define CONFIG_ CONFIG_prefix()
  25. #define TF_COMMAND 0x0001
  26. #define TF_PARAM 0x0002
  27. #define TF_OPTION 0x0004
  28. enum conf_def_mode {
  29. def_default,
  30. def_yes,
  31. def_mod,
  32. def_no,
  33. def_random
  34. };
  35. #define T_OPT_MODULES 1
  36. #define T_OPT_DEFCONFIG_LIST 2
  37. #define T_OPT_ALLNOCONFIG_Y 4
  38. struct kconf_id {
  39. const char *name;
  40. int token;
  41. unsigned int flags;
  42. enum symbol_type stype;
  43. };
  44. extern int yylineno;
  45. void zconfdump(FILE *out);
  46. void zconf_starthelp(void);
  47. FILE *zconf_fopen(const char *name);
  48. void zconf_initscan(const char *name);
  49. void zconf_nextfile(const char *name);
  50. int zconf_lineno(void);
  51. const char *zconf_curname(void);
  52. /* confdata.c */
  53. const char *conf_get_configname(void);
  54. const char *conf_get_autoconfig_name(void);
  55. char *conf_get_default_confname(void);
  56. void sym_set_change_count(int count);
  57. void sym_add_change_count(int count);
  58. bool conf_set_all_new_symbols(enum conf_def_mode mode);
  59. void set_all_choice_values(struct symbol *csym);
  60. /* confdata.c and expr.c */
  61. static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out)
  62. {
  63. assert(len != 0);
  64. if (fwrite(str, len, count, out) != count)
  65. fprintf(stderr, "Error in writing or end of file.\n");
  66. }
  67. /* menu.c */
  68. void _menu_init(void);
  69. void menu_warn(struct menu *menu, const char *fmt, ...);
  70. struct menu *menu_add_menu(void);
  71. void menu_end_menu(void);
  72. void menu_add_entry(struct symbol *sym);
  73. void menu_add_dep(struct expr *dep);
  74. void menu_add_visibility(struct expr *dep);
  75. struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep);
  76. void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep);
  77. void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep);
  78. void menu_add_option(int token, char *arg);
  79. void menu_finalize(struct menu *parent);
  80. void menu_set_type(int type);
  81. /* util.c */
  82. struct file *file_lookup(const char *name);
  83. void *xmalloc(size_t size);
  84. void *xcalloc(size_t nmemb, size_t size);
  85. void *xrealloc(void *p, size_t size);
  86. char *xstrdup(const char *s);
  87. char *xstrndup(const char *s, size_t n);
  88. struct gstr {
  89. size_t len;
  90. char *s;
  91. /*
  92. * when max_width is not zero long lines in string s (if any) get
  93. * wrapped not to exceed the max_width value
  94. */
  95. int max_width;
  96. };
  97. struct gstr str_new(void);
  98. void str_free(struct gstr *gs);
  99. void str_append(struct gstr *gs, const char *s);
  100. void str_printf(struct gstr *gs, const char *fmt, ...);
  101. const char *str_get(struct gstr *gs);
  102. /* symbol.c */
  103. void sym_clear_all_valid(void);
  104. struct symbol *sym_choice_default(struct symbol *sym);
  105. const char *sym_get_string_default(struct symbol *sym);
  106. struct symbol *sym_check_deps(struct symbol *sym);
  107. struct property *prop_alloc(enum prop_type type, struct symbol *sym);
  108. struct symbol *prop_get_symbol(struct property *prop);
  109. static inline tristate sym_get_tristate_value(struct symbol *sym)
  110. {
  111. return sym->curr.tri;
  112. }
  113. static inline struct symbol *sym_get_choice_value(struct symbol *sym)
  114. {
  115. return (struct symbol *)sym->curr.val;
  116. }
  117. static inline bool sym_set_choice_value(struct symbol *ch, struct symbol *chval)
  118. {
  119. return sym_set_tristate_value(chval, yes);
  120. }
  121. static inline bool sym_is_choice(struct symbol *sym)
  122. {
  123. return sym->flags & SYMBOL_CHOICE ? true : false;
  124. }
  125. static inline bool sym_is_choice_value(struct symbol *sym)
  126. {
  127. return sym->flags & SYMBOL_CHOICEVAL ? true : false;
  128. }
  129. static inline bool sym_is_optional(struct symbol *sym)
  130. {
  131. return sym->flags & SYMBOL_OPTIONAL ? true : false;
  132. }
  133. static inline bool sym_has_value(struct symbol *sym)
  134. {
  135. return sym->flags & SYMBOL_DEF_USER ? true : false;
  136. }
  137. #ifdef __cplusplus
  138. }
  139. #endif
  140. #endif /* LKC_H */