Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
0004  */
0005 
0006 #ifndef LKC_H
0007 #define LKC_H
0008 
0009 #include <assert.h>
0010 #include <stdio.h>
0011 #include <stdlib.h>
0012 
0013 #include "expr.h"
0014 
0015 #ifdef __cplusplus
0016 extern "C" {
0017 #endif
0018 
0019 #include "lkc_proto.h"
0020 
0021 #define SRCTREE "srctree"
0022 
0023 #ifndef CONFIG_
0024 #define CONFIG_ "CONFIG_"
0025 #endif
0026 static inline const char *CONFIG_prefix(void)
0027 {
0028     return getenv( "CONFIG_" ) ?: CONFIG_;
0029 }
0030 #undef CONFIG_
0031 #define CONFIG_ CONFIG_prefix()
0032 
0033 extern int yylineno;
0034 void zconfdump(FILE *out);
0035 void zconf_starthelp(void);
0036 FILE *zconf_fopen(const char *name);
0037 void zconf_initscan(const char *name);
0038 void zconf_nextfile(const char *name);
0039 int zconf_lineno(void);
0040 const char *zconf_curname(void);
0041 
0042 /* confdata.c */
0043 const char *conf_get_configname(void);
0044 void set_all_choice_values(struct symbol *csym);
0045 
0046 /* confdata.c and expr.c */
0047 static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out)
0048 {
0049     assert(len != 0);
0050 
0051     if (fwrite(str, len, count, out) != count)
0052         fprintf(stderr, "Error in writing or end of file.\n");
0053 }
0054 
0055 /* util.c */
0056 struct file *file_lookup(const char *name);
0057 void *xmalloc(size_t size);
0058 void *xcalloc(size_t nmemb, size_t size);
0059 void *xrealloc(void *p, size_t size);
0060 char *xstrdup(const char *s);
0061 char *xstrndup(const char *s, size_t n);
0062 
0063 /* lexer.l */
0064 int yylex(void);
0065 
0066 struct gstr {
0067     size_t len;
0068     char  *s;
0069     /*
0070     * when max_width is not zero long lines in string s (if any) get
0071     * wrapped not to exceed the max_width value
0072     */
0073     int max_width;
0074 };
0075 struct gstr str_new(void);
0076 void str_free(struct gstr *gs);
0077 void str_append(struct gstr *gs, const char *s);
0078 void str_printf(struct gstr *gs, const char *fmt, ...);
0079 const char *str_get(struct gstr *gs);
0080 
0081 /* menu.c */
0082 void _menu_init(void);
0083 void menu_warn(struct menu *menu, const char *fmt, ...);
0084 struct menu *menu_add_menu(void);
0085 void menu_end_menu(void);
0086 void menu_add_entry(struct symbol *sym);
0087 void menu_add_dep(struct expr *dep);
0088 void menu_add_visibility(struct expr *dep);
0089 struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep);
0090 void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep);
0091 void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep);
0092 void menu_finalize(struct menu *parent);
0093 void menu_set_type(int type);
0094 
0095 extern struct menu rootmenu;
0096 
0097 bool menu_is_empty(struct menu *menu);
0098 bool menu_is_visible(struct menu *menu);
0099 bool menu_has_prompt(struct menu *menu);
0100 const char *menu_get_prompt(struct menu *menu);
0101 struct menu *menu_get_parent_menu(struct menu *menu);
0102 bool menu_has_help(struct menu *menu);
0103 const char *menu_get_help(struct menu *menu);
0104 struct gstr get_relations_str(struct symbol **sym_arr, struct list_head *head);
0105 void menu_get_ext_help(struct menu *menu, struct gstr *help);
0106 
0107 /* symbol.c */
0108 void sym_clear_all_valid(void);
0109 struct symbol *sym_choice_default(struct symbol *sym);
0110 struct property *sym_get_range_prop(struct symbol *sym);
0111 const char *sym_get_string_default(struct symbol *sym);
0112 struct symbol *sym_check_deps(struct symbol *sym);
0113 struct symbol *prop_get_symbol(struct property *prop);
0114 
0115 static inline tristate sym_get_tristate_value(struct symbol *sym)
0116 {
0117     return sym->curr.tri;
0118 }
0119 
0120 
0121 static inline struct symbol *sym_get_choice_value(struct symbol *sym)
0122 {
0123     return (struct symbol *)sym->curr.val;
0124 }
0125 
0126 static inline bool sym_set_choice_value(struct symbol *ch, struct symbol *chval)
0127 {
0128     return sym_set_tristate_value(chval, yes);
0129 }
0130 
0131 static inline bool sym_is_choice(struct symbol *sym)
0132 {
0133     return sym->flags & SYMBOL_CHOICE ? true : false;
0134 }
0135 
0136 static inline bool sym_is_choice_value(struct symbol *sym)
0137 {
0138     return sym->flags & SYMBOL_CHOICEVAL ? true : false;
0139 }
0140 
0141 static inline bool sym_is_optional(struct symbol *sym)
0142 {
0143     return sym->flags & SYMBOL_OPTIONAL ? true : false;
0144 }
0145 
0146 static inline bool sym_has_value(struct symbol *sym)
0147 {
0148     return sym->flags & SYMBOL_DEF_USER ? true : false;
0149 }
0150 
0151 #ifdef __cplusplus
0152 }
0153 #endif
0154 
0155 #endif /* LKC_H */