1*53ee8cc1Swenshuai.xi /*
2*53ee8cc1Swenshuai.xi * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
3*53ee8cc1Swenshuai.xi * Released under the terms of the GNU GPL v2.0.
4*53ee8cc1Swenshuai.xi */
5*53ee8cc1Swenshuai.xi
6*53ee8cc1Swenshuai.xi #ifndef LKC_H
7*53ee8cc1Swenshuai.xi #define LKC_H
8*53ee8cc1Swenshuai.xi
9*53ee8cc1Swenshuai.xi #include "expr.h"
10*53ee8cc1Swenshuai.xi
11*53ee8cc1Swenshuai.xi #ifndef KBUILD_NO_NLS
12*53ee8cc1Swenshuai.xi # include <libintl.h>
13*53ee8cc1Swenshuai.xi #else
gettext(const char * txt)14*53ee8cc1Swenshuai.xi static inline const char *gettext(const char *txt) { return txt; }
textdomain(const char * domainname)15*53ee8cc1Swenshuai.xi static inline void textdomain(const char *domainname) {}
bindtextdomain(const char * name,const char * dir)16*53ee8cc1Swenshuai.xi static inline void bindtextdomain(const char *name, const char *dir) {}
bind_textdomain_codeset(const char * dn,char * c)17*53ee8cc1Swenshuai.xi static inline char *bind_textdomain_codeset(const char *dn, char *c) { return c; }
18*53ee8cc1Swenshuai.xi #endif
19*53ee8cc1Swenshuai.xi
20*53ee8cc1Swenshuai.xi #ifdef __cplusplus
21*53ee8cc1Swenshuai.xi extern "C" {
22*53ee8cc1Swenshuai.xi #endif
23*53ee8cc1Swenshuai.xi
24*53ee8cc1Swenshuai.xi #ifdef LKC_DIRECT_LINK
25*53ee8cc1Swenshuai.xi #define P(name,type,arg) extern type name arg
26*53ee8cc1Swenshuai.xi #else
27*53ee8cc1Swenshuai.xi #include "lkc_defs.h"
28*53ee8cc1Swenshuai.xi #define P(name,type,arg) extern type (*name ## _p) arg
29*53ee8cc1Swenshuai.xi #endif
30*53ee8cc1Swenshuai.xi #include "lkc_proto.h"
31*53ee8cc1Swenshuai.xi #undef P
32*53ee8cc1Swenshuai.xi
33*53ee8cc1Swenshuai.xi #define SRCTREE "srctree"
34*53ee8cc1Swenshuai.xi
35*53ee8cc1Swenshuai.xi #ifndef PACKAGE
36*53ee8cc1Swenshuai.xi #define PACKAGE "linux"
37*53ee8cc1Swenshuai.xi #endif
38*53ee8cc1Swenshuai.xi
39*53ee8cc1Swenshuai.xi #define LOCALEDIR "/usr/share/locale"
40*53ee8cc1Swenshuai.xi
41*53ee8cc1Swenshuai.xi #define _(text) gettext(text)
42*53ee8cc1Swenshuai.xi #define N_(text) (text)
43*53ee8cc1Swenshuai.xi
44*53ee8cc1Swenshuai.xi #ifndef CONFIG_
45*53ee8cc1Swenshuai.xi #define CONFIG_ "CONFIG_"
46*53ee8cc1Swenshuai.xi #endif
47*53ee8cc1Swenshuai.xi
48*53ee8cc1Swenshuai.xi #define TF_COMMAND 0x0001
49*53ee8cc1Swenshuai.xi #define TF_PARAM 0x0002
50*53ee8cc1Swenshuai.xi #define TF_OPTION 0x0004
51*53ee8cc1Swenshuai.xi
52*53ee8cc1Swenshuai.xi enum conf_def_mode {
53*53ee8cc1Swenshuai.xi def_default,
54*53ee8cc1Swenshuai.xi def_yes,
55*53ee8cc1Swenshuai.xi def_mod,
56*53ee8cc1Swenshuai.xi def_no,
57*53ee8cc1Swenshuai.xi def_random
58*53ee8cc1Swenshuai.xi };
59*53ee8cc1Swenshuai.xi
60*53ee8cc1Swenshuai.xi #define T_OPT_MODULES 1
61*53ee8cc1Swenshuai.xi #define T_OPT_DEFCONFIG_LIST 2
62*53ee8cc1Swenshuai.xi #define T_OPT_ENV 3
63*53ee8cc1Swenshuai.xi
64*53ee8cc1Swenshuai.xi struct kconf_id {
65*53ee8cc1Swenshuai.xi int name;
66*53ee8cc1Swenshuai.xi int token;
67*53ee8cc1Swenshuai.xi unsigned int flags;
68*53ee8cc1Swenshuai.xi enum symbol_type stype;
69*53ee8cc1Swenshuai.xi };
70*53ee8cc1Swenshuai.xi
71*53ee8cc1Swenshuai.xi #ifdef YYDEBUG
72*53ee8cc1Swenshuai.xi extern int zconfdebug;
73*53ee8cc1Swenshuai.xi #endif
74*53ee8cc1Swenshuai.xi
75*53ee8cc1Swenshuai.xi int zconfparse(void);
76*53ee8cc1Swenshuai.xi void zconfdump(FILE *out);
77*53ee8cc1Swenshuai.xi void zconf_starthelp(void);
78*53ee8cc1Swenshuai.xi FILE *zconf_fopen(const char *name);
79*53ee8cc1Swenshuai.xi void zconf_initscan(const char *name);
80*53ee8cc1Swenshuai.xi void zconf_nextfile(const char *name);
81*53ee8cc1Swenshuai.xi int zconf_lineno(void);
82*53ee8cc1Swenshuai.xi const char *zconf_curname(void);
83*53ee8cc1Swenshuai.xi
84*53ee8cc1Swenshuai.xi /* conf.c */
85*53ee8cc1Swenshuai.xi void xfgets(char *str, int size, FILE *in);
86*53ee8cc1Swenshuai.xi
87*53ee8cc1Swenshuai.xi /* confdata.c */
88*53ee8cc1Swenshuai.xi const char *conf_get_configname(void);
89*53ee8cc1Swenshuai.xi const char *conf_get_autoconfig_name(void);
90*53ee8cc1Swenshuai.xi char *conf_get_default_confname(void);
91*53ee8cc1Swenshuai.xi void sym_set_change_count(int count);
92*53ee8cc1Swenshuai.xi void sym_add_change_count(int count);
93*53ee8cc1Swenshuai.xi void conf_set_all_new_symbols(enum conf_def_mode mode);
94*53ee8cc1Swenshuai.xi
95*53ee8cc1Swenshuai.xi /* confdata.c and expr.c */
xfwrite(const void * str,size_t len,size_t count,FILE * out)96*53ee8cc1Swenshuai.xi static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out)
97*53ee8cc1Swenshuai.xi {
98*53ee8cc1Swenshuai.xi if (fwrite(str, len, count, out) < count)
99*53ee8cc1Swenshuai.xi fprintf(stderr, "\nError in writing or end of file.\n");
100*53ee8cc1Swenshuai.xi }
101*53ee8cc1Swenshuai.xi
102*53ee8cc1Swenshuai.xi /* kconfig_load.c */
103*53ee8cc1Swenshuai.xi void kconfig_load(void);
104*53ee8cc1Swenshuai.xi
105*53ee8cc1Swenshuai.xi /* menu.c */
106*53ee8cc1Swenshuai.xi void _menu_init(void);
107*53ee8cc1Swenshuai.xi void menu_warn(struct menu *menu, const char *fmt, ...);
108*53ee8cc1Swenshuai.xi struct menu *menu_add_menu(void);
109*53ee8cc1Swenshuai.xi void menu_end_menu(void);
110*53ee8cc1Swenshuai.xi void menu_add_entry(struct symbol *sym);
111*53ee8cc1Swenshuai.xi void menu_end_entry(void);
112*53ee8cc1Swenshuai.xi void menu_add_dep(struct expr *dep);
113*53ee8cc1Swenshuai.xi void menu_add_visibility(struct expr *dep);
114*53ee8cc1Swenshuai.xi struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep);
115*53ee8cc1Swenshuai.xi struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep);
116*53ee8cc1Swenshuai.xi void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep);
117*53ee8cc1Swenshuai.xi void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep);
118*53ee8cc1Swenshuai.xi void menu_add_option(int token, char *arg);
119*53ee8cc1Swenshuai.xi void menu_finalize(struct menu *parent);
120*53ee8cc1Swenshuai.xi void menu_set_type(int type);
121*53ee8cc1Swenshuai.xi
122*53ee8cc1Swenshuai.xi /* util.c */
123*53ee8cc1Swenshuai.xi struct file *file_lookup(const char *name);
124*53ee8cc1Swenshuai.xi int file_write_dep(const char *name);
125*53ee8cc1Swenshuai.xi
126*53ee8cc1Swenshuai.xi struct gstr {
127*53ee8cc1Swenshuai.xi size_t len;
128*53ee8cc1Swenshuai.xi char *s;
129*53ee8cc1Swenshuai.xi /*
130*53ee8cc1Swenshuai.xi * when max_width is not zero long lines in string s (if any) get
131*53ee8cc1Swenshuai.xi * wrapped not to exceed the max_width value
132*53ee8cc1Swenshuai.xi */
133*53ee8cc1Swenshuai.xi int max_width;
134*53ee8cc1Swenshuai.xi };
135*53ee8cc1Swenshuai.xi struct gstr str_new(void);
136*53ee8cc1Swenshuai.xi struct gstr str_assign(const char *s);
137*53ee8cc1Swenshuai.xi void str_free(struct gstr *gs);
138*53ee8cc1Swenshuai.xi void str_append(struct gstr *gs, const char *s);
139*53ee8cc1Swenshuai.xi void str_printf(struct gstr *gs, const char *fmt, ...);
140*53ee8cc1Swenshuai.xi const char *str_get(struct gstr *gs);
141*53ee8cc1Swenshuai.xi
142*53ee8cc1Swenshuai.xi /* symbol.c */
143*53ee8cc1Swenshuai.xi extern struct expr *sym_env_list;
144*53ee8cc1Swenshuai.xi
145*53ee8cc1Swenshuai.xi void sym_init(void);
146*53ee8cc1Swenshuai.xi void sym_clear_all_valid(void);
147*53ee8cc1Swenshuai.xi void sym_set_all_changed(void);
148*53ee8cc1Swenshuai.xi void sym_set_changed(struct symbol *sym);
149*53ee8cc1Swenshuai.xi struct symbol *sym_choice_default(struct symbol *sym);
150*53ee8cc1Swenshuai.xi const char *sym_get_string_default(struct symbol *sym);
151*53ee8cc1Swenshuai.xi struct symbol *sym_check_deps(struct symbol *sym);
152*53ee8cc1Swenshuai.xi struct property *prop_alloc(enum prop_type type, struct symbol *sym);
153*53ee8cc1Swenshuai.xi struct symbol *prop_get_symbol(struct property *prop);
154*53ee8cc1Swenshuai.xi struct property *sym_get_env_prop(struct symbol *sym);
155*53ee8cc1Swenshuai.xi
sym_get_tristate_value(struct symbol * sym)156*53ee8cc1Swenshuai.xi static inline tristate sym_get_tristate_value(struct symbol *sym)
157*53ee8cc1Swenshuai.xi {
158*53ee8cc1Swenshuai.xi return sym->curr.tri;
159*53ee8cc1Swenshuai.xi }
160*53ee8cc1Swenshuai.xi
161*53ee8cc1Swenshuai.xi
sym_get_choice_value(struct symbol * sym)162*53ee8cc1Swenshuai.xi static inline struct symbol *sym_get_choice_value(struct symbol *sym)
163*53ee8cc1Swenshuai.xi {
164*53ee8cc1Swenshuai.xi return (struct symbol *)sym->curr.val;
165*53ee8cc1Swenshuai.xi }
166*53ee8cc1Swenshuai.xi
sym_set_choice_value(struct symbol * ch,struct symbol * chval)167*53ee8cc1Swenshuai.xi static inline bool sym_set_choice_value(struct symbol *ch, struct symbol *chval)
168*53ee8cc1Swenshuai.xi {
169*53ee8cc1Swenshuai.xi return sym_set_tristate_value(chval, yes);
170*53ee8cc1Swenshuai.xi }
171*53ee8cc1Swenshuai.xi
sym_is_choice(struct symbol * sym)172*53ee8cc1Swenshuai.xi static inline bool sym_is_choice(struct symbol *sym)
173*53ee8cc1Swenshuai.xi {
174*53ee8cc1Swenshuai.xi return sym->flags & SYMBOL_CHOICE ? true : false;
175*53ee8cc1Swenshuai.xi }
176*53ee8cc1Swenshuai.xi
sym_is_choice_value(struct symbol * sym)177*53ee8cc1Swenshuai.xi static inline bool sym_is_choice_value(struct symbol *sym)
178*53ee8cc1Swenshuai.xi {
179*53ee8cc1Swenshuai.xi return sym->flags & SYMBOL_CHOICEVAL ? true : false;
180*53ee8cc1Swenshuai.xi }
181*53ee8cc1Swenshuai.xi
sym_is_optional(struct symbol * sym)182*53ee8cc1Swenshuai.xi static inline bool sym_is_optional(struct symbol *sym)
183*53ee8cc1Swenshuai.xi {
184*53ee8cc1Swenshuai.xi return sym->flags & SYMBOL_OPTIONAL ? true : false;
185*53ee8cc1Swenshuai.xi }
186*53ee8cc1Swenshuai.xi
sym_has_value(struct symbol * sym)187*53ee8cc1Swenshuai.xi static inline bool sym_has_value(struct symbol *sym)
188*53ee8cc1Swenshuai.xi {
189*53ee8cc1Swenshuai.xi return sym->flags & SYMBOL_DEF_USER ? true : false;
190*53ee8cc1Swenshuai.xi }
191*53ee8cc1Swenshuai.xi
192*53ee8cc1Swenshuai.xi #ifdef __cplusplus
193*53ee8cc1Swenshuai.xi }
194*53ee8cc1Swenshuai.xi #endif
195*53ee8cc1Swenshuai.xi
196*53ee8cc1Swenshuai.xi #endif /* LKC_H */
197