lkc.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
  4. */
  5. #ifndef LKC_H
  6. #define LKC_H
  7. #include <assert.h>
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include "expr.h"
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14. #include "lkc_proto.h"
  15. #define SRCTREE "srctree"
  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. extern int yylineno;
  26. void zconfdump(FILE *out);
  27. void zconf_starthelp(void);
  28. FILE *zconf_fopen(const char *name);
  29. void zconf_initscan(const char *name);
  30. void zconf_nextfile(const char *name);
  31. /* confdata.c */
  32. extern struct gstr autoconf_cmd;
  33. const char *conf_get_configname(void);
  34. /* confdata.c and expr.c */
  35. static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out)
  36. {
  37. assert(len != 0);
  38. if (fwrite(str, len, count, out) != count)
  39. fprintf(stderr, "Error in writing or end of file.\n");
  40. }
  41. /* util.c */
  42. const char *file_lookup(const char *name);
  43. /* lexer.l */
  44. int yylex(void);
  45. struct gstr {
  46. size_t len;
  47. char *s;
  48. /*
  49. * when max_width is not zero long lines in string s (if any) get
  50. * wrapped not to exceed the max_width value
  51. */
  52. int max_width;
  53. };
  54. struct gstr str_new(void);
  55. void str_free(struct gstr *gs);
  56. void str_append(struct gstr *gs, const char *s);
  57. void str_printf(struct gstr *gs, const char *fmt, ...);
  58. char *str_get(const struct gstr *gs);
  59. /* menu.c */
  60. struct menu *menu_next(struct menu *menu, struct menu *root);
  61. #define menu_for_each_sub_entry(menu, root) \
  62. for (menu = menu_next(root, root); menu; menu = menu_next(menu, root))
  63. #define menu_for_each_entry(menu) \
  64. menu_for_each_sub_entry(menu, &rootmenu)
  65. void _menu_init(void);
  66. void menu_warn(const struct menu *menu, const char *fmt, ...);
  67. struct menu *menu_add_menu(void);
  68. void menu_end_menu(void);
  69. void menu_add_entry(struct symbol *sym);
  70. void menu_add_dep(struct expr *dep);
  71. void menu_add_visibility(struct expr *dep);
  72. struct property *menu_add_prompt(enum prop_type type, const char *prompt,
  73. struct expr *dep);
  74. void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep);
  75. void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep);
  76. void menu_finalize(void);
  77. void menu_set_type(int type);
  78. extern struct menu rootmenu;
  79. bool menu_is_empty(struct menu *menu);
  80. bool menu_is_visible(struct menu *menu);
  81. bool menu_has_prompt(const struct menu *menu);
  82. const char *menu_get_prompt(const struct menu *menu);
  83. struct menu *menu_get_parent_menu(struct menu *menu);
  84. int get_jump_key_char(void);
  85. struct gstr get_relations_str(struct symbol **sym_arr, struct list_head *head);
  86. void menu_get_ext_help(struct menu *menu, struct gstr *help);
  87. /* symbol.c */
  88. void sym_clear_all_valid(void);
  89. struct symbol *sym_choice_default(struct menu *choice);
  90. struct symbol *sym_calc_choice(struct menu *choice);
  91. struct property *sym_get_range_prop(struct symbol *sym);
  92. const char *sym_get_string_default(struct symbol *sym);
  93. struct symbol *sym_check_deps(struct symbol *sym);
  94. struct symbol *prop_get_symbol(const struct property *prop);
  95. static inline tristate sym_get_tristate_value(const struct symbol *sym)
  96. {
  97. return sym->curr.tri;
  98. }
  99. static inline bool sym_is_choice(const struct symbol *sym)
  100. {
  101. /* A choice is a symbol with no name */
  102. return sym->name == NULL;
  103. }
  104. bool sym_is_choice_value(const struct symbol *sym);
  105. static inline bool sym_has_value(const struct symbol *sym)
  106. {
  107. return sym->flags & SYMBOL_DEF_USER ? true : false;
  108. }
  109. #ifdef __cplusplus
  110. }
  111. #endif
  112. #endif /* LKC_H */