diff options
Diffstat (limited to 'scripts/config')
26 files changed, 13284 insertions, 0 deletions
diff --git a/scripts/config/.cvsignore b/scripts/config/.cvsignore new file mode 100644 index 000000000..e8bf7a75b --- /dev/null +++ b/scripts/config/.cvsignore | |||
@@ -0,0 +1,8 @@ | |||
1 | conf | ||
2 | mconf | ||
3 | lkc_defs.h | ||
4 | lex.zconf.c | ||
5 | zconf.tab.h | ||
6 | zconf.tab.c | ||
7 | lex.backup | ||
8 | zconf.output | ||
diff --git a/scripts/config/Kconfig-language.txt b/scripts/config/Kconfig-language.txt new file mode 100644 index 000000000..a3037ffcf --- /dev/null +++ b/scripts/config/Kconfig-language.txt | |||
@@ -0,0 +1,255 @@ | |||
1 | Introduction | ||
2 | ------------ | ||
3 | |||
4 | The configuration database is collection of configuration options | ||
5 | organized in a tree structure: | ||
6 | |||
7 | +- Code maturity level options | ||
8 | | +- Prompt for development and/or incomplete code/drivers | ||
9 | +- General setup | ||
10 | | +- Networking support | ||
11 | | +- System V IPC | ||
12 | | +- BSD Process Accounting | ||
13 | | +- Sysctl support | ||
14 | +- Loadable module support | ||
15 | | +- Enable loadable module support | ||
16 | | +- Set version information on all module symbols | ||
17 | | +- Kernel module loader | ||
18 | +- ... | ||
19 | |||
20 | Every entry has its own dependencies. These dependencies are used | ||
21 | to determine the visible of an entry. Any child entry is only | ||
22 | visible if its parent entry is also visible. | ||
23 | |||
24 | Menu entries | ||
25 | ------------ | ||
26 | |||
27 | Most entries define a config option, all other entries help to organize | ||
28 | them. A single configuration option is defined like this: | ||
29 | |||
30 | config MODVERSIONS | ||
31 | bool "Set version information on all module symbols" | ||
32 | depends MODULES | ||
33 | help | ||
34 | Usually, modules have to be recompiled whenever you switch to a new | ||
35 | kernel. ... | ||
36 | |||
37 | Every line starts with a key word and can be followed by multiple | ||
38 | arguments. "config" starts a new config entry. The following lines | ||
39 | define attributes for this config option. Attributes can be the type of | ||
40 | the config option, input prompt, dependencies, help text and default | ||
41 | values. A config option can be defined multiple times with the same | ||
42 | name, but every definition can have only a single input prompt and the | ||
43 | type must not conflict. | ||
44 | |||
45 | Menu attributes | ||
46 | --------------- | ||
47 | |||
48 | A menu entry can have a number of attributes. Not all of them are | ||
49 | applicable everywhere (see syntax). | ||
50 | |||
51 | - type definition: "bool"/"tristate"/"string"/"hex"/"integer" | ||
52 | Every config option must have a type. There are only two basic types: | ||
53 | tristate and string, the other types base on these two. The type | ||
54 | definition optionally accepts an input prompt, so these two examples | ||
55 | are equivalent: | ||
56 | |||
57 | bool "Networking support" | ||
58 | and | ||
59 | bool | ||
60 | prompt "Networking support" | ||
61 | |||
62 | - input prompt: "prompt" <prompt> ["if" <expr>] | ||
63 | Every menu entry can have at most one prompt, which is used to display | ||
64 | to the user. Optionally dependencies only for this prompt can be added | ||
65 | with "if". | ||
66 | |||
67 | - default value: "default" <symbol> ["if" <expr>] | ||
68 | A config option can have any number of default values. If multiple | ||
69 | default values are visible, only the first defined one is active. | ||
70 | Default values are not limited to the menu entry, where they are | ||
71 | defined, this means the default can be defined somewhere else or be | ||
72 | overriden by an earlier definition. | ||
73 | The default value is only assigned to the config symbol if no other | ||
74 | value was set by the user (via the input prompt above). If an input | ||
75 | prompt is visible the default value is presented to the user and can | ||
76 | be overridden by him. | ||
77 | Optionally dependencies only for this default value can be added with | ||
78 | "if". | ||
79 | |||
80 | - dependencies: "depends on"/"requires" <expr> | ||
81 | This defines a dependency for this menu entry. If multiple | ||
82 | dependencies are defined they are connected with '&&'. Dependencies | ||
83 | are applied to all other options within this menu entry (which also | ||
84 | accept "if" expression), so these two examples are equivalent: | ||
85 | |||
86 | bool "foo" if BAR | ||
87 | default y if BAR | ||
88 | and | ||
89 | depends on BAR | ||
90 | bool "foo" | ||
91 | default y | ||
92 | |||
93 | - help text: "help" | ||
94 | This defines a help text. The end of the help text is determined by | ||
95 | the level indentation, this means it ends at the first line which has | ||
96 | a smaller indentation than the first line of the help text. | ||
97 | |||
98 | |||
99 | Menu dependencies | ||
100 | ----------------- | ||
101 | |||
102 | Dependencies define the visibility of a menu entry and can also reduce | ||
103 | the input range of tristate symbols. The tristate logic used in the | ||
104 | expressions uses one more state than normal boolean logic to express the | ||
105 | module state. Dependency expressions have the following syntax: | ||
106 | |||
107 | <expr> ::= <symbol> (1) | ||
108 | <symbol> '=' <symbol> (2) | ||
109 | <symbol> '!=' <symbol> (3) | ||
110 | '(' <expr> ')' (4) | ||
111 | '!' <expr> (5) | ||
112 | <expr> '||' <expr> (6) | ||
113 | <expr> '&&' <expr> (7) | ||
114 | |||
115 | Expressions are listed in decreasing order of precedence. | ||
116 | |||
117 | (1) Convert the symbol into an expression. Boolean and tristate symbols | ||
118 | are simply converted into the respective expression values. All | ||
119 | other symbol types result in 'n'. | ||
120 | (2) If the values of both symbols are equal, it returns 'y', | ||
121 | otherwise 'n'. | ||
122 | (3) If the values of both symbols are equal, it returns 'n', | ||
123 | otherwise 'y'. | ||
124 | (4) Returns the value of the expression. Used to override precedence. | ||
125 | (5) Returns the result of (2-/expr/). | ||
126 | (6) Returns the result of min(/expr/, /expr/). | ||
127 | (7) Returns the result of max(/expr/, /expr/). | ||
128 | |||
129 | An expression can have a value of 'n', 'm' or 'y' (or 0, 1, 2 | ||
130 | respectively for calculations). A menu entry becomes visible when it's | ||
131 | expression evaluates to 'm' or 'y'. | ||
132 | |||
133 | There are two type of symbols: constant and nonconstant symbols. | ||
134 | Nonconstant symbols are the most common ones and are defined with the | ||
135 | 'config' statement. Nonconstant symbols consist entirely of alphanumeric | ||
136 | characters or underscores. | ||
137 | Constant symbols are only part of expressions. Constant symbols are | ||
138 | always surrounded by single or double quotes. Within the quote any | ||
139 | other character is allowed and the quotes can be escaped using '\'. | ||
140 | |||
141 | Menu structure | ||
142 | -------------- | ||
143 | |||
144 | The position of a menu entry in the tree is determined in two ways. First | ||
145 | it can be specified explicitely: | ||
146 | |||
147 | menu "Network device support" | ||
148 | depends NET | ||
149 | |||
150 | config NETDEVICES | ||
151 | ... | ||
152 | |||
153 | endmenu | ||
154 | |||
155 | All entries within the "menu" ... "endmenu" block become a submenu of | ||
156 | "Network device support". All subentries inherit the dependencies from | ||
157 | the menu entry, e.g. this means the dependency "NET" is added to the | ||
158 | dependency list of the config option NETDEVICES. | ||
159 | |||
160 | The other way to generate the menu structure is done by analyzing the | ||
161 | dependencies. If a menu entry somehow depends on the previous entry, it | ||
162 | can be made a submenu of it. First the the previous (parent) symbol must | ||
163 | be part of the dependency list and then one of these two condititions | ||
164 | must be true: | ||
165 | - the child entry must become invisible, if the parent is set to 'n' | ||
166 | - the child entry must only be visible, if the parent is visible | ||
167 | |||
168 | config MODULES | ||
169 | bool "Enable loadable module support" | ||
170 | |||
171 | config MODVERSIONS | ||
172 | bool "Set version information on all module symbols" | ||
173 | depends MODULES | ||
174 | |||
175 | comment "module support disabled" | ||
176 | depends !MODULES | ||
177 | |||
178 | MODVERSIONS directly depends on MODULES, this means it's only visible if | ||
179 | MODULES is different from 'n'. The comment on the other hand is always | ||
180 | visible when MODULES it's visible (the (empty) dependency of MODULES is | ||
181 | also part of the comment dependencies). | ||
182 | |||
183 | |||
184 | Kconfig syntax | ||
185 | -------------- | ||
186 | |||
187 | The configuration file describes a series of menu entries, where every | ||
188 | line starts with a keyword (except help texts). The following keywords | ||
189 | end a menu entry: | ||
190 | - config | ||
191 | - choice/endchoice | ||
192 | - comment | ||
193 | - menu/endmenu | ||
194 | - if/endif | ||
195 | - source | ||
196 | The first four also start the definition of a menu entry. | ||
197 | |||
198 | config: | ||
199 | |||
200 | "config" <symbol> | ||
201 | <config options> | ||
202 | |||
203 | This defines a config symbol <symbol> and accepts any of above | ||
204 | attributes as options. | ||
205 | |||
206 | choices: | ||
207 | |||
208 | "choice" | ||
209 | <choice options> | ||
210 | <choice block> | ||
211 | "endchoice" | ||
212 | |||
213 | This defines a choice group and accepts any of above attributes as | ||
214 | options. A choice can only be of type bool or tristate, while a boolean | ||
215 | choice only allows a single config entry to be selected, a tristate | ||
216 | choice also allows any number of config entries to be set to 'm'. This | ||
217 | can be used if multiple drivers for a single hardware exists and only a | ||
218 | single driver can be compiled/loaded into the kernel, but all drivers | ||
219 | can be compiled as modules. | ||
220 | A choice accepts another option "optional", which allows to set the | ||
221 | choice to 'n' and no entry needs to be selected. | ||
222 | |||
223 | comment: | ||
224 | |||
225 | "comment" <prompt> | ||
226 | <comment options> | ||
227 | |||
228 | This defines a comment which is displayed to the user during the | ||
229 | configuration process and is also echoed to the output files. The only | ||
230 | possible options are dependencies. | ||
231 | |||
232 | menu: | ||
233 | |||
234 | "menu" <prompt> | ||
235 | <menu options> | ||
236 | <menu block> | ||
237 | "endmenu" | ||
238 | |||
239 | This defines a menu block, see "Menu structure" above for more | ||
240 | information. The only possible options are dependencies. | ||
241 | |||
242 | if: | ||
243 | |||
244 | "if" <expr> | ||
245 | <if block> | ||
246 | "endif" | ||
247 | |||
248 | This defines an if block. The dependency expression <expr> is appended | ||
249 | to all enclosed menu entries. | ||
250 | |||
251 | source: | ||
252 | |||
253 | "source" <prompt> | ||
254 | |||
255 | This reads the specified configuration file. This file is always parsed. | ||
diff --git a/scripts/config/Makefile b/scripts/config/Makefile new file mode 100644 index 000000000..d43c8b14f --- /dev/null +++ b/scripts/config/Makefile | |||
@@ -0,0 +1,102 @@ | |||
1 | # Makefile for BusyBox | ||
2 | # | ||
3 | # Copyright (C) 2002 Erik Andersen <andersen@codepoet.org> | ||
4 | |||
5 | TOPDIR=../../ | ||
6 | include $(TOPDIR)Rules.mak | ||
7 | |||
8 | |||
9 | all: ncurses conf mconf | ||
10 | |||
11 | #HOSTCFLAGS=-Wall -g -O0 | ||
12 | LIBS = -lncurses | ||
13 | ifeq (/usr/include/ncurses/ncurses.h, $(wildcard /usr/include/ncurses/ncurses.h)) | ||
14 | HOSTCFLAGS += -I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>" | ||
15 | else | ||
16 | ifeq (/usr/include/ncurses/curses.h, $(wildcard /usr/include/ncurses/curses.h)) | ||
17 | HOSTCFLAGS += -I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>" | ||
18 | else | ||
19 | ifeq (/usr/include/ncurses.h, $(wildcard /usr/include/ncurses.h)) | ||
20 | HOSTCFLAGS += -DCURSES_LOC="<ncurses.h>" | ||
21 | else | ||
22 | HOSTCFLAGS += -DCURSES_LOC="<curses.h>" | ||
23 | endif | ||
24 | endif | ||
25 | endif | ||
26 | |||
27 | |||
28 | CONF_SRC =conf.c zconf.tab.c | ||
29 | MCONF_SRC =mconf.c zconf.tab.c | ||
30 | LXDLG_SRC =checklist.c menubox.c textbox.c yesno.c inputbox.c util.c msgbox.c | ||
31 | CONF_OBJS =$(patsubst %.c,%.o, $(CONF_SRC)) | ||
32 | MCONF_OBJS=$(patsubst %.c,%.o, $(MCONF_SRC)) | ||
33 | LXDLG_OBJS=$(patsubst %.c,%.o, $(LXDLG_SRC)) | ||
34 | |||
35 | conf: $(CONF_OBJS) | ||
36 | $(HOSTCC) $(HOSTCFLAGS) $(NATIVE_LDFLAGS) $^ -o $@ | ||
37 | |||
38 | mconf: $(MCONF_OBJS) $(LXDLG_OBJS) | ||
39 | $(HOSTCC) $(HOSTCFLAGS) $(NATIVE_LDFLAGS) $^ -o $@ $(LIBS) | ||
40 | |||
41 | lkc_deps:=lkc.h lkc_proto.h lkc_defs.h expr.h zconf.tab.h | ||
42 | |||
43 | conf.o: conf.c $(lkc_deps) | ||
44 | |||
45 | mconf.o: mconf.c $(lkc_deps) | ||
46 | |||
47 | zconf.tab.o: zconf.tab.c lex.zconf.c confdata.c expr.c symbol.c menu.c $(lkc_deps) | ||
48 | |||
49 | lex.zconf.o: lex.zconf.c $(lkc_deps) | ||
50 | |||
51 | %.o : %.c | ||
52 | $(HOSTCC) $(HOSTCFLAGS) -I. -c $< -o $@ | ||
53 | |||
54 | lkc_defs.h: lkc_proto.h | ||
55 | @sed < $< > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/' | ||
56 | |||
57 | ### | ||
58 | # The following requires flex/bison | ||
59 | # By default we use the _shipped versions, uncomment the | ||
60 | # following line if you are modifying the flex/bison src. | ||
61 | #LKC_GENPARSER := 1 | ||
62 | |||
63 | ifdef LKC_GENPARSER | ||
64 | |||
65 | %.tab.c %.tab.h: %.y | ||
66 | bison -t -d -v -b $* -p $(notdir $*) $< | ||
67 | |||
68 | lex.%.c: %.l | ||
69 | flex -P$(notdir $*) -o$@ $< | ||
70 | else | ||
71 | |||
72 | lex.zconf.c: lex.zconf.c_shipped | ||
73 | cp lex.zconf.c_shipped lex.zconf.c | ||
74 | |||
75 | zconf.tab.c: zconf.tab.c_shipped | ||
76 | cp zconf.tab.c_shipped zconf.tab.c | ||
77 | |||
78 | zconf.tab.h: zconf.tab.h_shipped | ||
79 | cp zconf.tab.h_shipped zconf.tab.h | ||
80 | endif | ||
81 | |||
82 | .PHONY: ncurses | ||
83 | |||
84 | ncurses: | ||
85 | @echo "main() {}" > lxtemp.c | ||
86 | @if $(HOSTCC) lxtemp.c $(LIBS) ; then \ | ||
87 | rm -f lxtemp.c a.out; \ | ||
88 | else \ | ||
89 | rm -f lxtemp.c; \ | ||
90 | echo -e "\007" ;\ | ||
91 | echo ">> Unable to find the Ncurses libraries." ;\ | ||
92 | echo ">>" ;\ | ||
93 | echo ">> You must have Ncurses installed in order" ;\ | ||
94 | echo ">> to use 'make menuconfig'" ;\ | ||
95 | echo ;\ | ||
96 | exit 1 ;\ | ||
97 | fi | ||
98 | |||
99 | clean: | ||
100 | rm -f *.o *~ core $(TARGETS) $(MCONF_OBJS) $(CONF_OBJS) \ | ||
101 | conf mconf zconf.tab.c zconf.tab.h lex.zconf.c lkc_defs.h | ||
102 | |||
diff --git a/scripts/config/checklist.c b/scripts/config/checklist.c new file mode 100644 index 000000000..c4a9289b9 --- /dev/null +++ b/scripts/config/checklist.c | |||
@@ -0,0 +1,363 @@ | |||
1 | /* | ||
2 | * checklist.c -- implements the checklist box | ||
3 | * | ||
4 | * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) | ||
5 | * Stuart Herbert - S.Herbert@sheffield.ac.uk: radiolist extension | ||
6 | * Alessandro Rubini - rubini@ipvvis.unipv.it: merged the two | ||
7 | * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or | ||
10 | * modify it under the terms of the GNU General Public License | ||
11 | * as published by the Free Software Foundation; either version 2 | ||
12 | * of the License, or (at your option) any later version. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | * GNU General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
22 | */ | ||
23 | |||
24 | #include "dialog.h" | ||
25 | |||
26 | static int list_width, check_x, item_x, checkflag; | ||
27 | |||
28 | /* | ||
29 | * Print list item | ||
30 | */ | ||
31 | static void | ||
32 | print_item (WINDOW * win, const char *item, int status, | ||
33 | int choice, int selected) | ||
34 | { | ||
35 | int i; | ||
36 | |||
37 | /* Clear 'residue' of last item */ | ||
38 | wattrset (win, menubox_attr); | ||
39 | wmove (win, choice, 0); | ||
40 | for (i = 0; i < list_width; i++) | ||
41 | waddch (win, ' '); | ||
42 | |||
43 | wmove (win, choice, check_x); | ||
44 | wattrset (win, selected ? check_selected_attr : check_attr); | ||
45 | if (checkflag == FLAG_CHECK) | ||
46 | wprintw (win, "[%c]", status ? 'X' : ' '); | ||
47 | else | ||
48 | wprintw (win, "(%c)", status ? 'X' : ' '); | ||
49 | |||
50 | wattrset (win, selected ? tag_selected_attr : tag_attr); | ||
51 | mvwaddch(win, choice, item_x, item[0]); | ||
52 | wattrset (win, selected ? item_selected_attr : item_attr); | ||
53 | waddstr (win, (char *)item+1); | ||
54 | if (selected) { | ||
55 | wmove (win, choice, check_x+1); | ||
56 | wrefresh (win); | ||
57 | } | ||
58 | } | ||
59 | |||
60 | /* | ||
61 | * Print the scroll indicators. | ||
62 | */ | ||
63 | static void | ||
64 | print_arrows (WINDOW * win, int choice, int item_no, int scroll, | ||
65 | int y, int x, int height) | ||
66 | { | ||
67 | wmove(win, y, x); | ||
68 | |||
69 | if (scroll > 0) { | ||
70 | wattrset (win, uarrow_attr); | ||
71 | waddch (win, ACS_UARROW); | ||
72 | waddstr (win, "(-)"); | ||
73 | } | ||
74 | else { | ||
75 | wattrset (win, menubox_attr); | ||
76 | waddch (win, ACS_HLINE); | ||
77 | waddch (win, ACS_HLINE); | ||
78 | waddch (win, ACS_HLINE); | ||
79 | waddch (win, ACS_HLINE); | ||
80 | } | ||
81 | |||
82 | y = y + height + 1; | ||
83 | wmove(win, y, x); | ||
84 | |||
85 | if ((height < item_no) && (scroll + choice < item_no - 1)) { | ||
86 | wattrset (win, darrow_attr); | ||
87 | waddch (win, ACS_DARROW); | ||
88 | waddstr (win, "(+)"); | ||
89 | } | ||
90 | else { | ||
91 | wattrset (win, menubox_border_attr); | ||
92 | waddch (win, ACS_HLINE); | ||
93 | waddch (win, ACS_HLINE); | ||
94 | waddch (win, ACS_HLINE); | ||
95 | waddch (win, ACS_HLINE); | ||
96 | } | ||
97 | } | ||
98 | |||
99 | /* | ||
100 | * Display the termination buttons | ||
101 | */ | ||
102 | static void | ||
103 | print_buttons( WINDOW *dialog, int height, int width, int selected) | ||
104 | { | ||
105 | int x = width / 2 - 11; | ||
106 | int y = height - 2; | ||
107 | |||
108 | print_button (dialog, "Select", y, x, selected == 0); | ||
109 | print_button (dialog, " Help ", y, x + 14, selected == 1); | ||
110 | |||
111 | wmove(dialog, y, x+1 + 14*selected); | ||
112 | wrefresh (dialog); | ||
113 | } | ||
114 | |||
115 | /* | ||
116 | * Display a dialog box with a list of options that can be turned on or off | ||
117 | * The `flag' parameter is used to select between radiolist and checklist. | ||
118 | */ | ||
119 | int | ||
120 | dialog_checklist (const char *title, const char *prompt, int height, int width, | ||
121 | int list_height, int item_no, struct dialog_list_item ** items, | ||
122 | int flag) | ||
123 | |||
124 | { | ||
125 | int i, x, y, box_x, box_y; | ||
126 | int key = 0, button = 0, choice = 0, scroll = 0, max_choice, *status; | ||
127 | WINDOW *dialog, *list; | ||
128 | |||
129 | checkflag = flag; | ||
130 | |||
131 | /* Allocate space for storing item on/off status */ | ||
132 | if ((status = malloc (sizeof (int) * item_no)) == NULL) { | ||
133 | endwin (); | ||
134 | fprintf (stderr, | ||
135 | "\nCan't allocate memory in dialog_checklist().\n"); | ||
136 | exit (-1); | ||
137 | } | ||
138 | |||
139 | /* Initializes status */ | ||
140 | for (i = 0; i < item_no; i++) { | ||
141 | status[i] = items[i]->selected; | ||
142 | if (!choice && status[i]) | ||
143 | choice = i; | ||
144 | } | ||
145 | |||
146 | max_choice = MIN (list_height, item_no); | ||
147 | |||
148 | /* center dialog box on screen */ | ||
149 | x = (COLS - width) / 2; | ||
150 | y = (LINES - height) / 2; | ||
151 | |||
152 | draw_shadow (stdscr, y, x, height, width); | ||
153 | |||
154 | dialog = newwin (height, width, y, x); | ||
155 | keypad (dialog, TRUE); | ||
156 | |||
157 | draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr); | ||
158 | wattrset (dialog, border_attr); | ||
159 | mvwaddch (dialog, height-3, 0, ACS_LTEE); | ||
160 | for (i = 0; i < width - 2; i++) | ||
161 | waddch (dialog, ACS_HLINE); | ||
162 | wattrset (dialog, dialog_attr); | ||
163 | waddch (dialog, ACS_RTEE); | ||
164 | |||
165 | if (title != NULL && strlen(title) >= width-2 ) { | ||
166 | /* truncate long title -- mec */ | ||
167 | char * title2 = malloc(width-2+1); | ||
168 | memcpy( title2, title, width-2 ); | ||
169 | title2[width-2] = '\0'; | ||
170 | title = title2; | ||
171 | } | ||
172 | |||
173 | if (title != NULL) { | ||
174 | wattrset (dialog, title_attr); | ||
175 | mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' '); | ||
176 | waddstr (dialog, (char *)title); | ||
177 | waddch (dialog, ' '); | ||
178 | } | ||
179 | |||
180 | wattrset (dialog, dialog_attr); | ||
181 | print_autowrap (dialog, prompt, width - 2, 1, 3); | ||
182 | |||
183 | list_width = width - 6; | ||
184 | box_y = height - list_height - 5; | ||
185 | box_x = (width - list_width) / 2 - 1; | ||
186 | |||
187 | /* create new window for the list */ | ||
188 | list = subwin (dialog, list_height, list_width, y+box_y+1, x+box_x+1); | ||
189 | |||
190 | keypad (list, TRUE); | ||
191 | |||
192 | /* draw a box around the list items */ | ||
193 | draw_box (dialog, box_y, box_x, list_height + 2, list_width + 2, | ||
194 | menubox_border_attr, menubox_attr); | ||
195 | |||
196 | /* Find length of longest item in order to center checklist */ | ||
197 | check_x = 0; | ||
198 | for (i = 0; i < item_no; i++) | ||
199 | check_x = MAX (check_x, + strlen (items[i]->name) + 4); | ||
200 | |||
201 | check_x = (list_width - check_x) / 2; | ||
202 | item_x = check_x + 4; | ||
203 | |||
204 | if (choice >= list_height) { | ||
205 | scroll = choice - list_height + 1; | ||
206 | choice -= scroll; | ||
207 | } | ||
208 | |||
209 | /* Print the list */ | ||
210 | for (i = 0; i < max_choice; i++) { | ||
211 | print_item (list, items[scroll + i]->name, | ||
212 | status[i+scroll], i, i == choice); | ||
213 | } | ||
214 | |||
215 | print_arrows(dialog, choice, item_no, scroll, | ||
216 | box_y, box_x + check_x + 5, list_height); | ||
217 | |||
218 | print_buttons(dialog, height, width, 0); | ||
219 | |||
220 | wnoutrefresh (list); | ||
221 | wnoutrefresh (dialog); | ||
222 | doupdate (); | ||
223 | |||
224 | while (key != ESC) { | ||
225 | key = wgetch (dialog); | ||
226 | |||
227 | for (i = 0; i < max_choice; i++) | ||
228 | if (toupper(key) == toupper(items[scroll + i]->name[0])) | ||
229 | break; | ||
230 | |||
231 | |||
232 | if ( i < max_choice || key == KEY_UP || key == KEY_DOWN || | ||
233 | key == '+' || key == '-' ) { | ||
234 | if (key == KEY_UP || key == '-') { | ||
235 | if (!choice) { | ||
236 | if (!scroll) | ||
237 | continue; | ||
238 | /* Scroll list down */ | ||
239 | if (list_height > 1) { | ||
240 | /* De-highlight current first item */ | ||
241 | print_item (list, items[scroll]->name, | ||
242 | status[scroll], 0, FALSE); | ||
243 | scrollok (list, TRUE); | ||
244 | wscrl (list, -1); | ||
245 | scrollok (list, FALSE); | ||
246 | } | ||
247 | scroll--; | ||
248 | print_item (list, items[scroll]->name, | ||
249 | status[scroll], 0, TRUE); | ||
250 | wnoutrefresh (list); | ||
251 | |||
252 | print_arrows(dialog, choice, item_no, scroll, | ||
253 | box_y, box_x + check_x + 5, list_height); | ||
254 | |||
255 | wrefresh (dialog); | ||
256 | |||
257 | continue; /* wait for another key press */ | ||
258 | } else | ||
259 | i = choice - 1; | ||
260 | } else if (key == KEY_DOWN || key == '+') { | ||
261 | if (choice == max_choice - 1) { | ||
262 | if (scroll + choice >= item_no - 1) | ||
263 | continue; | ||
264 | /* Scroll list up */ | ||
265 | if (list_height > 1) { | ||
266 | /* De-highlight current last item before scrolling up */ | ||
267 | print_item (list, items[scroll + max_choice - 1]->name, | ||
268 | status[scroll + max_choice - 1], | ||
269 | max_choice - 1, FALSE); | ||
270 | scrollok (list, TRUE); | ||
271 | scroll (list); | ||
272 | scrollok (list, FALSE); | ||
273 | } | ||
274 | scroll++; | ||
275 | print_item (list, items[scroll + max_choice - 1]->name, | ||
276 | status[scroll + max_choice - 1], | ||
277 | max_choice - 1, TRUE); | ||
278 | wnoutrefresh (list); | ||
279 | |||
280 | print_arrows(dialog, choice, item_no, scroll, | ||
281 | box_y, box_x + check_x + 5, list_height); | ||
282 | |||
283 | wrefresh (dialog); | ||
284 | |||
285 | continue; /* wait for another key press */ | ||
286 | } else | ||
287 | i = choice + 1; | ||
288 | } | ||
289 | if (i != choice) { | ||
290 | /* De-highlight current item */ | ||
291 | print_item (list, items[scroll + choice]->name, | ||
292 | status[scroll + choice], choice, FALSE); | ||
293 | /* Highlight new item */ | ||
294 | choice = i; | ||
295 | print_item (list, items[scroll + choice]->name, | ||
296 | status[scroll + choice], choice, TRUE); | ||
297 | wnoutrefresh (list); | ||
298 | wrefresh (dialog); | ||
299 | } | ||
300 | continue; /* wait for another key press */ | ||
301 | } | ||
302 | switch (key) { | ||
303 | case 'H': | ||
304 | case 'h': | ||
305 | case '?': | ||
306 | delwin (dialog); | ||
307 | free (status); | ||
308 | return 1; | ||
309 | case TAB: | ||
310 | case KEY_LEFT: | ||
311 | case KEY_RIGHT: | ||
312 | button = ((key == KEY_LEFT ? --button : ++button) < 0) | ||
313 | ? 1 : (button > 1 ? 0 : button); | ||
314 | |||
315 | print_buttons(dialog, height, width, button); | ||
316 | wrefresh (dialog); | ||
317 | break; | ||
318 | case 'S': | ||
319 | case 's': | ||
320 | case ' ': | ||
321 | case '\n': | ||
322 | if (!button) { | ||
323 | if (flag == FLAG_CHECK) { | ||
324 | status[scroll + choice] = !status[scroll + choice]; | ||
325 | wmove (list, choice, check_x); | ||
326 | wattrset (list, check_selected_attr); | ||
327 | wprintw (list, "[%c]", status[scroll + choice] ? 'X' : ' '); | ||
328 | } else { | ||
329 | if (!status[scroll + choice]) { | ||
330 | for (i = 0; i < item_no; i++) | ||
331 | status[i] = 0; | ||
332 | status[scroll + choice] = 1; | ||
333 | for (i = 0; i < max_choice; i++) | ||
334 | print_item (list, items[scroll + i]->name, | ||
335 | status[scroll + i], i, i == choice); | ||
336 | } | ||
337 | } | ||
338 | wnoutrefresh (list); | ||
339 | wrefresh (dialog); | ||
340 | |||
341 | for (i = 0; i < item_no; i++) { | ||
342 | items[i]->selected = status[i]; | ||
343 | } | ||
344 | } | ||
345 | delwin (dialog); | ||
346 | free (status); | ||
347 | return button; | ||
348 | case 'X': | ||
349 | case 'x': | ||
350 | key = ESC; | ||
351 | case ESC: | ||
352 | break; | ||
353 | } | ||
354 | |||
355 | /* Now, update everything... */ | ||
356 | doupdate (); | ||
357 | } | ||
358 | |||
359 | |||
360 | delwin (dialog); | ||
361 | free (status); | ||
362 | return -1; /* ESC pressed */ | ||
363 | } | ||
diff --git a/scripts/config/colors.h b/scripts/config/colors.h new file mode 100644 index 000000000..d34dd37c6 --- /dev/null +++ b/scripts/config/colors.h | |||
@@ -0,0 +1,161 @@ | |||
1 | /* | ||
2 | * colors.h -- color attribute definitions | ||
3 | * | ||
4 | * AUTHOR: Savio Lam (lam836@cs.cuhk.hk) | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * as published by the Free Software Foundation; either version 2 | ||
9 | * of the License, or (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
19 | */ | ||
20 | |||
21 | |||
22 | /* | ||
23 | * Default color definitions | ||
24 | * | ||
25 | * *_FG = foreground | ||
26 | * *_BG = background | ||
27 | * *_HL = highlight? | ||
28 | */ | ||
29 | #define SCREEN_FG COLOR_CYAN | ||
30 | #define SCREEN_BG COLOR_BLUE | ||
31 | #define SCREEN_HL TRUE | ||
32 | |||
33 | #define SHADOW_FG COLOR_BLACK | ||
34 | #define SHADOW_BG COLOR_BLACK | ||
35 | #define SHADOW_HL TRUE | ||
36 | |||
37 | #define DIALOG_FG COLOR_BLACK | ||
38 | #define DIALOG_BG COLOR_WHITE | ||
39 | #define DIALOG_HL FALSE | ||
40 | |||
41 | #define TITLE_FG COLOR_YELLOW | ||
42 | #define TITLE_BG COLOR_WHITE | ||
43 | #define TITLE_HL TRUE | ||
44 | |||
45 | #define BORDER_FG COLOR_WHITE | ||
46 | #define BORDER_BG COLOR_WHITE | ||
47 | #define BORDER_HL TRUE | ||
48 | |||
49 | #define BUTTON_ACTIVE_FG COLOR_WHITE | ||
50 | #define BUTTON_ACTIVE_BG COLOR_BLUE | ||
51 | #define BUTTON_ACTIVE_HL TRUE | ||
52 | |||
53 | #define BUTTON_INACTIVE_FG COLOR_BLACK | ||
54 | #define BUTTON_INACTIVE_BG COLOR_WHITE | ||
55 | #define BUTTON_INACTIVE_HL FALSE | ||
56 | |||
57 | #define BUTTON_KEY_ACTIVE_FG COLOR_WHITE | ||
58 | #define BUTTON_KEY_ACTIVE_BG COLOR_BLUE | ||
59 | #define BUTTON_KEY_ACTIVE_HL TRUE | ||
60 | |||
61 | #define BUTTON_KEY_INACTIVE_FG COLOR_RED | ||
62 | #define BUTTON_KEY_INACTIVE_BG COLOR_WHITE | ||
63 | #define BUTTON_KEY_INACTIVE_HL FALSE | ||
64 | |||
65 | #define BUTTON_LABEL_ACTIVE_FG COLOR_YELLOW | ||
66 | #define BUTTON_LABEL_ACTIVE_BG COLOR_BLUE | ||
67 | #define BUTTON_LABEL_ACTIVE_HL TRUE | ||
68 | |||
69 | #define BUTTON_LABEL_INACTIVE_FG COLOR_BLACK | ||
70 | #define BUTTON_LABEL_INACTIVE_BG COLOR_WHITE | ||
71 | #define BUTTON_LABEL_INACTIVE_HL TRUE | ||
72 | |||
73 | #define INPUTBOX_FG COLOR_BLACK | ||
74 | #define INPUTBOX_BG COLOR_WHITE | ||
75 | #define INPUTBOX_HL FALSE | ||
76 | |||
77 | #define INPUTBOX_BORDER_FG COLOR_BLACK | ||
78 | #define INPUTBOX_BORDER_BG COLOR_WHITE | ||
79 | #define INPUTBOX_BORDER_HL FALSE | ||
80 | |||
81 | #define SEARCHBOX_FG COLOR_BLACK | ||
82 | #define SEARCHBOX_BG COLOR_WHITE | ||
83 | #define SEARCHBOX_HL FALSE | ||
84 | |||
85 | #define SEARCHBOX_TITLE_FG COLOR_YELLOW | ||
86 | #define SEARCHBOX_TITLE_BG COLOR_WHITE | ||
87 | #define SEARCHBOX_TITLE_HL TRUE | ||
88 | |||
89 | #define SEARCHBOX_BORDER_FG COLOR_WHITE | ||
90 | #define SEARCHBOX_BORDER_BG COLOR_WHITE | ||
91 | #define SEARCHBOX_BORDER_HL TRUE | ||
92 | |||
93 | #define POSITION_INDICATOR_FG COLOR_YELLOW | ||
94 | #define POSITION_INDICATOR_BG COLOR_WHITE | ||
95 | #define POSITION_INDICATOR_HL TRUE | ||
96 | |||
97 | #define MENUBOX_FG COLOR_BLACK | ||
98 | #define MENUBOX_BG COLOR_WHITE | ||
99 | #define MENUBOX_HL FALSE | ||
100 | |||
101 | #define MENUBOX_BORDER_FG COLOR_WHITE | ||
102 | #define MENUBOX_BORDER_BG COLOR_WHITE | ||
103 | #define MENUBOX_BORDER_HL TRUE | ||
104 | |||
105 | #define ITEM_FG COLOR_BLACK | ||
106 | #define ITEM_BG COLOR_WHITE | ||
107 | #define ITEM_HL FALSE | ||
108 | |||
109 | #define ITEM_SELECTED_FG COLOR_WHITE | ||
110 | #define ITEM_SELECTED_BG COLOR_BLUE | ||
111 | #define ITEM_SELECTED_HL TRUE | ||
112 | |||
113 | #define TAG_FG COLOR_YELLOW | ||
114 | #define TAG_BG COLOR_WHITE | ||
115 | #define TAG_HL TRUE | ||
116 | |||
117 | #define TAG_SELECTED_FG COLOR_YELLOW | ||
118 | #define TAG_SELECTED_BG COLOR_BLUE | ||
119 | #define TAG_SELECTED_HL TRUE | ||
120 | |||
121 | #define TAG_KEY_FG COLOR_YELLOW | ||
122 | #define TAG_KEY_BG COLOR_WHITE | ||
123 | #define TAG_KEY_HL TRUE | ||
124 | |||
125 | #define TAG_KEY_SELECTED_FG COLOR_YELLOW | ||
126 | #define TAG_KEY_SELECTED_BG COLOR_BLUE | ||
127 | #define TAG_KEY_SELECTED_HL TRUE | ||
128 | |||
129 | #define CHECK_FG COLOR_BLACK | ||
130 | #define CHECK_BG COLOR_WHITE | ||
131 | #define CHECK_HL FALSE | ||
132 | |||
133 | #define CHECK_SELECTED_FG COLOR_WHITE | ||
134 | #define CHECK_SELECTED_BG COLOR_BLUE | ||
135 | #define CHECK_SELECTED_HL TRUE | ||
136 | |||
137 | #define UARROW_FG COLOR_GREEN | ||
138 | #define UARROW_BG COLOR_WHITE | ||
139 | #define UARROW_HL TRUE | ||
140 | |||
141 | #define DARROW_FG COLOR_GREEN | ||
142 | #define DARROW_BG COLOR_WHITE | ||
143 | #define DARROW_HL TRUE | ||
144 | |||
145 | /* End of default color definitions */ | ||
146 | |||
147 | #define C_ATTR(x,y) ((x ? A_BOLD : 0) | COLOR_PAIR((y))) | ||
148 | #define COLOR_NAME_LEN 10 | ||
149 | #define COLOR_COUNT 8 | ||
150 | |||
151 | /* | ||
152 | * Global variables | ||
153 | */ | ||
154 | |||
155 | typedef struct { | ||
156 | char name[COLOR_NAME_LEN]; | ||
157 | int value; | ||
158 | } color_names_st; | ||
159 | |||
160 | extern color_names_st color_names[]; | ||
161 | extern int color_table[][3]; | ||
diff --git a/scripts/config/conf.c b/scripts/config/conf.c new file mode 100644 index 000000000..884175e54 --- /dev/null +++ b/scripts/config/conf.c | |||
@@ -0,0 +1,566 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> | ||
3 | * Released under the terms of the GNU GPL v2.0. | ||
4 | */ | ||
5 | |||
6 | #include <ctype.h> | ||
7 | #include <stdlib.h> | ||
8 | #include <string.h> | ||
9 | #include <unistd.h> | ||
10 | #include <time.h> | ||
11 | #include <sys/stat.h> | ||
12 | |||
13 | #define LKC_DIRECT_LINK | ||
14 | #include "lkc.h" | ||
15 | |||
16 | static void conf(struct menu *menu); | ||
17 | static void check_conf(struct menu *menu); | ||
18 | |||
19 | enum { | ||
20 | ask_all, | ||
21 | ask_new, | ||
22 | ask_silent, | ||
23 | set_default, | ||
24 | set_yes, | ||
25 | set_mod, | ||
26 | set_no, | ||
27 | set_random | ||
28 | } input_mode = ask_all; | ||
29 | |||
30 | static int indent = 1; | ||
31 | static int valid_stdin = 1; | ||
32 | static int conf_cnt; | ||
33 | static char line[128]; | ||
34 | static struct menu *rootEntry; | ||
35 | |||
36 | static char nohelp_text[] = "Sorry, no help available for this option yet.\n"; | ||
37 | |||
38 | #if 0 | ||
39 | static void printc(int ch) | ||
40 | { | ||
41 | static int sep = 0; | ||
42 | |||
43 | if (!sep) { | ||
44 | putchar('['); | ||
45 | sep = 1; | ||
46 | } else if (ch) | ||
47 | putchar('/'); | ||
48 | if (!ch) { | ||
49 | putchar(']'); | ||
50 | putchar(' '); | ||
51 | sep = 0; | ||
52 | } else | ||
53 | putchar(ch); | ||
54 | } | ||
55 | #endif | ||
56 | |||
57 | static void printo(const char *o) | ||
58 | { | ||
59 | static int sep = 0; | ||
60 | |||
61 | if (!sep) { | ||
62 | putchar('('); | ||
63 | sep = 1; | ||
64 | } else if (o) { | ||
65 | putchar(','); | ||
66 | putchar(' '); | ||
67 | } | ||
68 | if (!o) { | ||
69 | putchar(')'); | ||
70 | putchar(' '); | ||
71 | sep = 0; | ||
72 | } else | ||
73 | printf("%s", o); | ||
74 | } | ||
75 | |||
76 | static void strip(char *str) | ||
77 | { | ||
78 | char *p = str; | ||
79 | int l; | ||
80 | |||
81 | while ((isspace((int)*p))) | ||
82 | p++; | ||
83 | l = strlen(p); | ||
84 | if (p != str) | ||
85 | memmove(str, p, l + 1); | ||
86 | if (!l) | ||
87 | return; | ||
88 | p = str + l - 1; | ||
89 | while ((isspace((int)*p))) | ||
90 | *p-- = 0; | ||
91 | } | ||
92 | |||
93 | static void conf_askvalue(struct symbol *sym, const char *def) | ||
94 | { | ||
95 | enum symbol_type type = sym_get_type(sym); | ||
96 | tristate val; | ||
97 | |||
98 | if (!sym_has_value(sym)) | ||
99 | printf("(NEW) "); | ||
100 | |||
101 | line[0] = '\n'; | ||
102 | line[1] = 0; | ||
103 | |||
104 | switch (input_mode) { | ||
105 | case ask_new: | ||
106 | case ask_silent: | ||
107 | if (sym_has_value(sym)) { | ||
108 | printf("%s\n", def); | ||
109 | return; | ||
110 | } | ||
111 | if (!valid_stdin && input_mode == ask_silent) { | ||
112 | printf("aborted!\n\n"); | ||
113 | printf("Console input/output is redirected. "); | ||
114 | printf("Run 'make oldconfig' to update configuration.\n\n"); | ||
115 | exit(1); | ||
116 | } | ||
117 | case ask_all: | ||
118 | fflush(stdout); | ||
119 | fgets(line, 128, stdin); | ||
120 | return; | ||
121 | case set_default: | ||
122 | printf("%s\n", def); | ||
123 | return; | ||
124 | default: | ||
125 | break; | ||
126 | } | ||
127 | |||
128 | switch (type) { | ||
129 | case S_INT: | ||
130 | case S_HEX: | ||
131 | case S_STRING: | ||
132 | printf("%s\n", def); | ||
133 | return; | ||
134 | default: | ||
135 | ; | ||
136 | } | ||
137 | switch (input_mode) { | ||
138 | case set_yes: | ||
139 | if (sym_tristate_within_range(sym, yes)) { | ||
140 | line[0] = 'y'; | ||
141 | line[1] = '\n'; | ||
142 | line[2] = 0; | ||
143 | break; | ||
144 | } | ||
145 | case set_mod: | ||
146 | if (type == S_TRISTATE) { | ||
147 | if (sym_tristate_within_range(sym, mod)) { | ||
148 | line[0] = 'm'; | ||
149 | line[1] = '\n'; | ||
150 | line[2] = 0; | ||
151 | break; | ||
152 | } | ||
153 | } else { | ||
154 | if (sym_tristate_within_range(sym, yes)) { | ||
155 | line[0] = 'y'; | ||
156 | line[1] = '\n'; | ||
157 | line[2] = 0; | ||
158 | break; | ||
159 | } | ||
160 | } | ||
161 | case set_no: | ||
162 | if (sym_tristate_within_range(sym, no)) { | ||
163 | line[0] = 'n'; | ||
164 | line[1] = '\n'; | ||
165 | line[2] = 0; | ||
166 | break; | ||
167 | } | ||
168 | case set_random: | ||
169 | do { | ||
170 | val = (tristate)(random() % 3); | ||
171 | } while (!sym_tristate_within_range(sym, val)); | ||
172 | switch (val) { | ||
173 | case no: line[0] = 'n'; break; | ||
174 | case mod: line[0] = 'm'; break; | ||
175 | case yes: line[0] = 'y'; break; | ||
176 | } | ||
177 | line[1] = '\n'; | ||
178 | line[2] = 0; | ||
179 | break; | ||
180 | default: | ||
181 | break; | ||
182 | } | ||
183 | printf("%s", line); | ||
184 | } | ||
185 | |||
186 | int conf_string(struct menu *menu) | ||
187 | { | ||
188 | struct symbol *sym = menu->sym; | ||
189 | const char *def, *help; | ||
190 | |||
191 | while (1) { | ||
192 | printf("%*s%s ", indent - 1, "", menu->prompt->text); | ||
193 | printf("(%s) ", sym->name); | ||
194 | def = sym_get_string_value(sym); | ||
195 | if (sym_get_string_value(sym)) | ||
196 | printf("[%s] ", def); | ||
197 | conf_askvalue(sym, def); | ||
198 | switch (line[0]) { | ||
199 | case '\n': | ||
200 | break; | ||
201 | case '?': | ||
202 | /* print help */ | ||
203 | if (line[1] == 0) { | ||
204 | help = nohelp_text; | ||
205 | if (menu->sym->help) | ||
206 | help = menu->sym->help; | ||
207 | printf("\n%s\n", menu->sym->help); | ||
208 | def = NULL; | ||
209 | break; | ||
210 | } | ||
211 | default: | ||
212 | line[strlen(line)-1] = 0; | ||
213 | def = line; | ||
214 | } | ||
215 | if (def && sym_set_string_value(sym, def)) | ||
216 | return 0; | ||
217 | } | ||
218 | } | ||
219 | |||
220 | static int conf_sym(struct menu *menu) | ||
221 | { | ||
222 | struct symbol *sym = menu->sym; | ||
223 | int type; | ||
224 | tristate oldval, newval; | ||
225 | const char *help; | ||
226 | |||
227 | while (1) { | ||
228 | printf("%*s%s ", indent - 1, "", menu->prompt->text); | ||
229 | if (sym->name) | ||
230 | printf("(%s) ", sym->name); | ||
231 | type = sym_get_type(sym); | ||
232 | putchar('['); | ||
233 | oldval = sym_get_tristate_value(sym); | ||
234 | switch (oldval) { | ||
235 | case no: | ||
236 | putchar('N'); | ||
237 | break; | ||
238 | case mod: | ||
239 | putchar('M'); | ||
240 | break; | ||
241 | case yes: | ||
242 | putchar('Y'); | ||
243 | break; | ||
244 | } | ||
245 | if (oldval != no && sym_tristate_within_range(sym, no)) | ||
246 | printf("/n"); | ||
247 | if (oldval != mod && sym_tristate_within_range(sym, mod)) | ||
248 | printf("/m"); | ||
249 | if (oldval != yes && sym_tristate_within_range(sym, yes)) | ||
250 | printf("/y"); | ||
251 | if (sym->help) | ||
252 | printf("/?"); | ||
253 | printf("] "); | ||
254 | conf_askvalue(sym, sym_get_string_value(sym)); | ||
255 | strip(line); | ||
256 | |||
257 | switch (line[0]) { | ||
258 | case 'n': | ||
259 | case 'N': | ||
260 | newval = no; | ||
261 | if (!line[1] || !strcmp(&line[1], "o")) | ||
262 | break; | ||
263 | continue; | ||
264 | case 'm': | ||
265 | case 'M': | ||
266 | newval = mod; | ||
267 | if (!line[1]) | ||
268 | break; | ||
269 | continue; | ||
270 | case 'y': | ||
271 | case 'Y': | ||
272 | newval = yes; | ||
273 | if (!line[1] || !strcmp(&line[1], "es")) | ||
274 | break; | ||
275 | continue; | ||
276 | case 0: | ||
277 | newval = oldval; | ||
278 | break; | ||
279 | case '?': | ||
280 | goto help; | ||
281 | default: | ||
282 | continue; | ||
283 | } | ||
284 | if (sym_set_tristate_value(sym, newval)) | ||
285 | return 0; | ||
286 | help: | ||
287 | help = nohelp_text; | ||
288 | if (sym->help) | ||
289 | help = sym->help; | ||
290 | printf("\n%s\n", help); | ||
291 | } | ||
292 | } | ||
293 | |||
294 | static int conf_choice(struct menu *menu) | ||
295 | { | ||
296 | struct symbol *sym, *def_sym; | ||
297 | struct menu *cmenu, *def_menu; | ||
298 | const char *help; | ||
299 | int type, len; | ||
300 | bool is_new; | ||
301 | |||
302 | sym = menu->sym; | ||
303 | type = sym_get_type(sym); | ||
304 | is_new = !sym_has_value(sym); | ||
305 | if (sym_is_changable(sym)) { | ||
306 | conf_sym(menu); | ||
307 | sym_calc_value(sym); | ||
308 | switch (sym_get_tristate_value(sym)) { | ||
309 | case no: | ||
310 | return 1; | ||
311 | case mod: | ||
312 | return 0; | ||
313 | case yes: | ||
314 | break; | ||
315 | } | ||
316 | } else { | ||
317 | sym->def = sym->curr; | ||
318 | if (S_TRI(sym->curr) == mod) { | ||
319 | printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu)); | ||
320 | return 0; | ||
321 | } | ||
322 | } | ||
323 | |||
324 | while (1) { | ||
325 | printf("%*s%s ", indent - 1, "", menu_get_prompt(menu)); | ||
326 | def_sym = sym_get_choice_value(sym); | ||
327 | def_menu = NULL; | ||
328 | for (cmenu = menu->list; cmenu; cmenu = cmenu->next) { | ||
329 | if (!menu_is_visible(cmenu)) | ||
330 | continue; | ||
331 | printo(menu_get_prompt(cmenu)); | ||
332 | if (cmenu->sym == def_sym) | ||
333 | def_menu = cmenu; | ||
334 | } | ||
335 | printo(NULL); | ||
336 | if (def_menu) | ||
337 | printf("[%s] ", menu_get_prompt(def_menu)); | ||
338 | else { | ||
339 | printf("\n"); | ||
340 | return 1; | ||
341 | } | ||
342 | switch (input_mode) { | ||
343 | case ask_new: | ||
344 | case ask_silent: | ||
345 | case ask_all: | ||
346 | conf_askvalue(sym, menu_get_prompt(def_menu)); | ||
347 | strip(line); | ||
348 | break; | ||
349 | default: | ||
350 | line[0] = 0; | ||
351 | printf("\n"); | ||
352 | } | ||
353 | if (line[0] == '?' && !line[1]) { | ||
354 | help = nohelp_text; | ||
355 | if (menu->sym->help) | ||
356 | help = menu->sym->help; | ||
357 | printf("\n%s\n", help); | ||
358 | continue; | ||
359 | } | ||
360 | if (line[0]) { | ||
361 | len = strlen(line); | ||
362 | line[len] = 0; | ||
363 | |||
364 | def_menu = NULL; | ||
365 | for (cmenu = menu->list; cmenu; cmenu = cmenu->next) { | ||
366 | if (!cmenu->sym || !menu_is_visible(cmenu)) | ||
367 | continue; | ||
368 | if (!strncasecmp(line, menu_get_prompt(cmenu), len)) { | ||
369 | def_menu = cmenu; | ||
370 | break; | ||
371 | } | ||
372 | } | ||
373 | } | ||
374 | if (def_menu) { | ||
375 | sym_set_choice_value(sym, def_menu->sym); | ||
376 | if (def_menu->list) { | ||
377 | indent += 2; | ||
378 | conf(def_menu->list); | ||
379 | indent -= 2; | ||
380 | } | ||
381 | return 1; | ||
382 | } | ||
383 | } | ||
384 | } | ||
385 | |||
386 | static void conf(struct menu *menu) | ||
387 | { | ||
388 | struct symbol *sym; | ||
389 | struct property *prop; | ||
390 | struct menu *child; | ||
391 | |||
392 | if (!menu_is_visible(menu)) | ||
393 | return; | ||
394 | |||
395 | sym = menu->sym; | ||
396 | prop = menu->prompt; | ||
397 | if (prop) { | ||
398 | const char *prompt; | ||
399 | |||
400 | switch (prop->type) { | ||
401 | case P_MENU: | ||
402 | if (input_mode == ask_silent && rootEntry != menu) { | ||
403 | check_conf(menu); | ||
404 | return; | ||
405 | } | ||
406 | case P_COMMENT: | ||
407 | prompt = menu_get_prompt(menu); | ||
408 | if (prompt) | ||
409 | printf("%*c\n%*c %s\n%*c\n", | ||
410 | indent, '*', | ||
411 | indent, '*', prompt, | ||
412 | indent, '*'); | ||
413 | default: | ||
414 | ; | ||
415 | } | ||
416 | } | ||
417 | |||
418 | if (!sym) | ||
419 | goto conf_childs; | ||
420 | |||
421 | if (sym_is_choice(sym)) { | ||
422 | conf_choice(menu); | ||
423 | if (S_TRI(sym->curr) != mod) | ||
424 | return; | ||
425 | goto conf_childs; | ||
426 | } | ||
427 | |||
428 | switch (sym->type) { | ||
429 | case S_INT: | ||
430 | case S_HEX: | ||
431 | case S_STRING: | ||
432 | conf_string(menu); | ||
433 | break; | ||
434 | default: | ||
435 | conf_sym(menu); | ||
436 | break; | ||
437 | } | ||
438 | |||
439 | conf_childs: | ||
440 | if (sym) | ||
441 | indent += 2; | ||
442 | for (child = menu->list; child; child = child->next) | ||
443 | conf(child); | ||
444 | if (sym) | ||
445 | indent -= 2; | ||
446 | } | ||
447 | |||
448 | static void check_conf(struct menu *menu) | ||
449 | { | ||
450 | struct symbol *sym; | ||
451 | struct menu *child; | ||
452 | |||
453 | if (!menu_is_visible(menu)) | ||
454 | return; | ||
455 | |||
456 | sym = menu->sym; | ||
457 | if (!sym) | ||
458 | goto conf_childs; | ||
459 | |||
460 | if (sym_is_choice(sym)) { | ||
461 | if (!sym_has_value(sym)) { | ||
462 | if (!conf_cnt++) | ||
463 | printf("*\n* Restart config...\n*\n"); | ||
464 | rootEntry = menu_get_parent_menu(menu); | ||
465 | conf(rootEntry); | ||
466 | } | ||
467 | if (sym_get_tristate_value(sym) != mod) | ||
468 | return; | ||
469 | goto conf_childs; | ||
470 | } | ||
471 | |||
472 | if (!sym_has_value(sym)) { | ||
473 | if (!conf_cnt++) | ||
474 | printf("*\n* Restart config...\n*\n"); | ||
475 | rootEntry = menu_get_parent_menu(menu); | ||
476 | conf(rootEntry); | ||
477 | } | ||
478 | |||
479 | conf_childs: | ||
480 | for (child = menu->list; child; child = child->next) | ||
481 | check_conf(child); | ||
482 | } | ||
483 | |||
484 | int main(int ac, char **av) | ||
485 | { | ||
486 | const char *name; | ||
487 | struct stat tmpstat; | ||
488 | |||
489 | if (ac > 1 && av[1][0] == '-') { | ||
490 | switch (av[1][1]) { | ||
491 | case 'o': | ||
492 | input_mode = ask_new; | ||
493 | break; | ||
494 | case 's': | ||
495 | input_mode = ask_silent; | ||
496 | valid_stdin = isatty(0) && isatty(1) && isatty(2); | ||
497 | break; | ||
498 | case 'd': | ||
499 | input_mode = set_default; | ||
500 | break; | ||
501 | case 'n': | ||
502 | input_mode = set_no; | ||
503 | break; | ||
504 | case 'm': | ||
505 | input_mode = set_mod; | ||
506 | break; | ||
507 | case 'y': | ||
508 | input_mode = set_yes; | ||
509 | break; | ||
510 | case 'r': | ||
511 | input_mode = set_random; | ||
512 | srandom(time(NULL)); | ||
513 | break; | ||
514 | case 'h': | ||
515 | case '?': | ||
516 | printf("%s [-o|-s] config\n", av[0]); | ||
517 | exit(0); | ||
518 | } | ||
519 | name = av[2]; | ||
520 | } else | ||
521 | name = av[1]; | ||
522 | conf_parse(name); | ||
523 | //zconfdump(stdout); | ||
524 | switch (input_mode) { | ||
525 | case set_default: | ||
526 | name = conf_get_default_confname(); | ||
527 | if (conf_read(name)) { | ||
528 | printf("***\n" | ||
529 | "*** Can't find default configuration \"%s\"!\n" | ||
530 | "***\n", name); | ||
531 | exit(1); | ||
532 | } | ||
533 | break; | ||
534 | case ask_silent: | ||
535 | if (stat(".config", &tmpstat)) { | ||
536 | printf("***\n" | ||
537 | "*** You have not yet configured BusyBox!\n" | ||
538 | "***\n" | ||
539 | "*** Please run some configurator (e.g. \"make oldconfig\"\n" | ||
540 | "*** or \"make menuconfig\").\n" | ||
541 | "***\n"); | ||
542 | exit(1); | ||
543 | } | ||
544 | case ask_all: | ||
545 | case ask_new: | ||
546 | conf_read(NULL); | ||
547 | break; | ||
548 | default: | ||
549 | break; | ||
550 | } | ||
551 | |||
552 | if (input_mode != ask_silent) { | ||
553 | rootEntry = &rootmenu; | ||
554 | conf(&rootmenu); | ||
555 | if (input_mode == ask_all) { | ||
556 | input_mode = ask_silent; | ||
557 | valid_stdin = 1; | ||
558 | } | ||
559 | } | ||
560 | do { | ||
561 | conf_cnt = 0; | ||
562 | check_conf(&rootmenu); | ||
563 | } while (conf_cnt); | ||
564 | conf_write(NULL); | ||
565 | return 0; | ||
566 | } | ||
diff --git a/scripts/config/confdata.c b/scripts/config/confdata.c new file mode 100644 index 000000000..44835bbfe --- /dev/null +++ b/scripts/config/confdata.c | |||
@@ -0,0 +1,371 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> | ||
3 | * Released under the terms of the GNU GPL v2.0. | ||
4 | * | ||
5 | * Allow 'n' as a symbol value. | ||
6 | * 2002-11-05 Petr Baudis <pasky@ucw.cz> | ||
7 | */ | ||
8 | |||
9 | #include <ctype.h> | ||
10 | #include <stdio.h> | ||
11 | #include <stdlib.h> | ||
12 | #include <string.h> | ||
13 | #include <unistd.h> | ||
14 | |||
15 | #define LKC_DIRECT_LINK | ||
16 | #include "lkc.h" | ||
17 | |||
18 | const char conf_def_filename[] = ".config"; | ||
19 | |||
20 | const char conf_defname[] = "extra/Configs/Config.$TARGET_ARCH.default"; | ||
21 | |||
22 | const char *conf_confnames[] = { | ||
23 | ".config", | ||
24 | conf_defname, | ||
25 | NULL, | ||
26 | }; | ||
27 | |||
28 | static char *conf_expand_value(const char *in) | ||
29 | { | ||
30 | struct symbol *sym; | ||
31 | const char *src; | ||
32 | static char res_value[SYMBOL_MAXLENGTH]; | ||
33 | char *dst, name[SYMBOL_MAXLENGTH]; | ||
34 | |||
35 | res_value[0] = 0; | ||
36 | dst = name; | ||
37 | while ((src = strchr(in, '$'))) { | ||
38 | strncat(res_value, in, src - in); | ||
39 | src++; | ||
40 | dst = name; | ||
41 | while (isalnum((int)*src) || *src == '_') | ||
42 | *dst++ = *src++; | ||
43 | *dst = 0; | ||
44 | sym = sym_lookup(name, 0); | ||
45 | sym_calc_value(sym); | ||
46 | strcat(res_value, sym_get_string_value(sym)); | ||
47 | in = src; | ||
48 | } | ||
49 | strcat(res_value, in); | ||
50 | |||
51 | return res_value; | ||
52 | } | ||
53 | |||
54 | char *conf_get_default_confname(void) | ||
55 | { | ||
56 | return conf_expand_value(conf_defname); | ||
57 | } | ||
58 | |||
59 | int conf_read(const char *name) | ||
60 | { | ||
61 | FILE *in = NULL; | ||
62 | char line[1024]; | ||
63 | char *p, *p2; | ||
64 | int lineno = 0; | ||
65 | struct symbol *sym; | ||
66 | struct property *prop; | ||
67 | struct expr *e; | ||
68 | int i; | ||
69 | |||
70 | if (name) { | ||
71 | in = fopen(name, "r"); | ||
72 | } else { | ||
73 | const char **names = conf_confnames; | ||
74 | while ((name = *names++)) { | ||
75 | name = conf_expand_value(name); | ||
76 | in = fopen(name, "r"); | ||
77 | if (in) { | ||
78 | printf("#\n" | ||
79 | "# using defaults found in %s\n" | ||
80 | "#\n", name); | ||
81 | break; | ||
82 | } | ||
83 | } | ||
84 | } | ||
85 | |||
86 | if (!in) | ||
87 | return 1; | ||
88 | |||
89 | for_all_symbols(i, sym) { | ||
90 | sym->flags |= SYMBOL_NEW | SYMBOL_CHANGED; | ||
91 | sym->flags &= ~SYMBOL_VALID; | ||
92 | switch (sym->type) { | ||
93 | case S_INT: | ||
94 | case S_HEX: | ||
95 | case S_STRING: | ||
96 | if (S_VAL(sym->def)) | ||
97 | free(S_VAL(sym->def)); | ||
98 | default: | ||
99 | S_VAL(sym->def) = NULL; | ||
100 | S_TRI(sym->def) = no; | ||
101 | ; | ||
102 | } | ||
103 | } | ||
104 | |||
105 | while (fgets(line, sizeof(line), in)) { | ||
106 | lineno++; | ||
107 | switch (line[0]) { | ||
108 | case '\n': | ||
109 | break; | ||
110 | case ' ': | ||
111 | break; | ||
112 | case '#': | ||
113 | p = strchr(line, ' '); | ||
114 | if (!p) | ||
115 | continue; | ||
116 | *p++ = 0; | ||
117 | p = strchr(p, ' '); | ||
118 | if (!p) | ||
119 | continue; | ||
120 | *p++ = 0; | ||
121 | if (strncmp(p, "is not set", 10)) | ||
122 | continue; | ||
123 | sym = sym_lookup(line+2, 0); | ||
124 | switch (sym->type) { | ||
125 | case S_BOOLEAN: | ||
126 | case S_TRISTATE: | ||
127 | sym->def = symbol_no.curr; | ||
128 | sym->flags &= ~SYMBOL_NEW; | ||
129 | break; | ||
130 | default: | ||
131 | ; | ||
132 | } | ||
133 | break; | ||
134 | case 'A' ... 'Z': | ||
135 | p = strchr(line, '='); | ||
136 | if (!p) | ||
137 | continue; | ||
138 | *p++ = 0; | ||
139 | p2 = strchr(p, '\n'); | ||
140 | if (p2) | ||
141 | *p2 = 0; | ||
142 | sym = sym_find(line); | ||
143 | if (!sym) { | ||
144 | fprintf(stderr, "%s:%d: trying to assign nonexistent symbol %s\n", name, lineno, line); | ||
145 | break; | ||
146 | } | ||
147 | switch (sym->type) { | ||
148 | case S_TRISTATE: | ||
149 | if (p[0] == 'm') { | ||
150 | S_TRI(sym->def) = mod; | ||
151 | sym->flags &= ~SYMBOL_NEW; | ||
152 | break; | ||
153 | } | ||
154 | case S_BOOLEAN: | ||
155 | if (p[0] == 'y') { | ||
156 | S_TRI(sym->def) = yes; | ||
157 | sym->flags &= ~SYMBOL_NEW; | ||
158 | break; | ||
159 | } | ||
160 | if (p[0] == 'n') { | ||
161 | S_TRI(sym->def) = no; | ||
162 | sym->flags &= ~SYMBOL_NEW; | ||
163 | break; | ||
164 | } | ||
165 | break; | ||
166 | case S_STRING: | ||
167 | if (*p++ != '"') | ||
168 | break; | ||
169 | for (p2 = p; (p2 = strpbrk(p2, "\"\\")); p2++) { | ||
170 | if (*p2 == '"') { | ||
171 | *p2 = 0; | ||
172 | break; | ||
173 | } | ||
174 | memmove(p2, p2 + 1, strlen(p2)); | ||
175 | } | ||
176 | case S_INT: | ||
177 | case S_HEX: | ||
178 | if (sym_string_valid(sym, p)) { | ||
179 | S_VAL(sym->def) = strdup(p); | ||
180 | sym->flags &= ~SYMBOL_NEW; | ||
181 | } else | ||
182 | fprintf(stderr, "%s:%d:symbol value '%s' invalid for %s\n", name, lineno, p, sym->name); | ||
183 | break; | ||
184 | default: | ||
185 | ; | ||
186 | } | ||
187 | if (sym_is_choice_value(sym)) { | ||
188 | prop = sym_get_choice_prop(sym); | ||
189 | switch (S_TRI(sym->def)) { | ||
190 | case mod: | ||
191 | if (S_TRI(prop->def->def) == yes) | ||
192 | /* warn? */; | ||
193 | break; | ||
194 | case yes: | ||
195 | if (S_TRI(prop->def->def) != no) | ||
196 | /* warn? */; | ||
197 | S_VAL(prop->def->def) = sym; | ||
198 | break; | ||
199 | case no: | ||
200 | break; | ||
201 | } | ||
202 | S_TRI(prop->def->def) = S_TRI(sym->def); | ||
203 | } | ||
204 | break; | ||
205 | default: | ||
206 | continue; | ||
207 | } | ||
208 | } | ||
209 | fclose(in); | ||
210 | |||
211 | for_all_symbols(i, sym) { | ||
212 | if (!sym_is_choice(sym)) | ||
213 | continue; | ||
214 | prop = sym_get_choice_prop(sym); | ||
215 | for (e = prop->dep; e; e = e->left.expr) | ||
216 | sym->flags |= e->right.sym->flags & SYMBOL_NEW; | ||
217 | sym->flags &= ~SYMBOL_NEW; | ||
218 | } | ||
219 | |||
220 | sym_change_count = 1; | ||
221 | |||
222 | return 0; | ||
223 | } | ||
224 | |||
225 | int conf_write(const char *name) | ||
226 | { | ||
227 | FILE *out, *out_h; | ||
228 | struct symbol *sym; | ||
229 | struct menu *menu; | ||
230 | char oldname[128]; | ||
231 | int type, l; | ||
232 | const char *str; | ||
233 | |||
234 | out = fopen(".tmpconfig", "w"); | ||
235 | if (!out) | ||
236 | return 1; | ||
237 | out_h = fopen(".tmpconfig.h", "w"); | ||
238 | if (!out_h) | ||
239 | return 1; | ||
240 | fprintf(out, "#\n" | ||
241 | "# Automatically generated make config: don't edit\n" | ||
242 | "#\n"); | ||
243 | fprintf(out_h, "/*\n" | ||
244 | " * Automatically generated header file: don't edit\n" | ||
245 | " */\n\n" | ||
246 | "#define AUTOCONF_INCLUDED\n\n" | ||
247 | "/* Version Number */\n" | ||
248 | "#define BB_VER \"%s\"\n" | ||
249 | "#define BB_BT \"%s\"\n\n", | ||
250 | getenv("VERSION"), | ||
251 | getenv("BUILDTIME") | ||
252 | ); | ||
253 | |||
254 | if (!sym_change_count) | ||
255 | sym_clear_all_valid(); | ||
256 | |||
257 | menu = rootmenu.list; | ||
258 | while (menu) { | ||
259 | sym = menu->sym; | ||
260 | if (!sym) { | ||
261 | if (!menu_is_visible(menu)) | ||
262 | goto next; | ||
263 | str = menu_get_prompt(menu); | ||
264 | fprintf(out, "\n" | ||
265 | "#\n" | ||
266 | "# %s\n" | ||
267 | "#\n", str); | ||
268 | fprintf(out_h, "\n" | ||
269 | "/*\n" | ||
270 | " * %s\n" | ||
271 | " */\n", str); | ||
272 | } else if (!(sym->flags & SYMBOL_CHOICE)) { | ||
273 | sym_calc_value(sym); | ||
274 | if (!(sym->flags & SYMBOL_WRITE)) | ||
275 | goto next; | ||
276 | sym->flags &= ~SYMBOL_WRITE; | ||
277 | type = sym->type; | ||
278 | if (type == S_TRISTATE) { | ||
279 | sym_calc_value(modules_sym); | ||
280 | if (S_TRI(modules_sym->curr) == no) | ||
281 | type = S_BOOLEAN; | ||
282 | } | ||
283 | switch (type) { | ||
284 | case S_BOOLEAN: | ||
285 | case S_TRISTATE: | ||
286 | switch (sym_get_tristate_value(sym)) { | ||
287 | case no: | ||
288 | fprintf(out, "# %s is not set\n", sym->name); | ||
289 | fprintf(out_h, "#undef %s\n", sym->name); | ||
290 | break; | ||
291 | case mod: | ||
292 | #if 0 | ||
293 | fprintf(out, "%s=m\n", sym->name); | ||
294 | fprintf(out_h, "#define __%s__MODULE 1\n", sym->name); | ||
295 | #endif | ||
296 | break; | ||
297 | case yes: | ||
298 | fprintf(out, "%s=y\n", sym->name); | ||
299 | fprintf(out_h, "#define %s 1\n", sym->name); | ||
300 | break; | ||
301 | } | ||
302 | break; | ||
303 | case S_STRING: | ||
304 | // fix me | ||
305 | str = sym_get_string_value(sym); | ||
306 | fprintf(out, "%s=\"", sym->name); | ||
307 | fprintf(out_h, "#define %s \"", sym->name); | ||
308 | do { | ||
309 | l = strcspn(str, "\"\\"); | ||
310 | if (l) { | ||
311 | fwrite(str, l, 1, out); | ||
312 | fwrite(str, l, 1, out_h); | ||
313 | } | ||
314 | str += l; | ||
315 | while (*str == '\\' || *str == '"') { | ||
316 | fprintf(out, "\\%c", *str); | ||
317 | fprintf(out_h, "\\%c", *str); | ||
318 | str++; | ||
319 | } | ||
320 | } while (*str); | ||
321 | fputs("\"\n", out); | ||
322 | fputs("\"\n", out_h); | ||
323 | break; | ||
324 | case S_HEX: | ||
325 | str = sym_get_string_value(sym); | ||
326 | if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) { | ||
327 | fprintf(out, "%s=%s\n", sym->name, str); | ||
328 | fprintf(out_h, "#define %s 0x%s\n", sym->name, str); | ||
329 | break; | ||
330 | } | ||
331 | case S_INT: | ||
332 | str = sym_get_string_value(sym); | ||
333 | fprintf(out, "%s=%s\n", sym->name, str); | ||
334 | fprintf(out_h, "#define %s %s\n", sym->name, str); | ||
335 | break; | ||
336 | } | ||
337 | } | ||
338 | |||
339 | next: | ||
340 | if (menu->list) { | ||
341 | menu = menu->list; | ||
342 | continue; | ||
343 | } | ||
344 | if (menu->next) | ||
345 | menu = menu->next; | ||
346 | else while ((menu = menu->parent)) { | ||
347 | if (menu->next) { | ||
348 | menu = menu->next; | ||
349 | break; | ||
350 | } | ||
351 | } | ||
352 | } | ||
353 | fclose(out); | ||
354 | fclose(out_h); | ||
355 | |||
356 | if (!name) { | ||
357 | rename(".tmpconfig.h", "include/config.h"); | ||
358 | name = conf_def_filename; | ||
359 | file_write_dep(NULL); | ||
360 | } else | ||
361 | unlink(".tmpconfig.h"); | ||
362 | |||
363 | sprintf(oldname, "%s.old", name); | ||
364 | rename(name, oldname); | ||
365 | if (rename(".tmpconfig", name)) | ||
366 | return 1; | ||
367 | |||
368 | sym_change_count = 0; | ||
369 | |||
370 | return 0; | ||
371 | } | ||
diff --git a/scripts/config/dialog.h b/scripts/config/dialog.h new file mode 100644 index 000000000..8116cee36 --- /dev/null +++ b/scripts/config/dialog.h | |||
@@ -0,0 +1,196 @@ | |||
1 | |||
2 | /* | ||
3 | * dialog.h -- common declarations for all dialog modules | ||
4 | * | ||
5 | * AUTHOR: Savio Lam (lam836@cs.cuhk.hk) | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; either version 2 | ||
10 | * of the License, or (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | */ | ||
21 | |||
22 | #include <sys/types.h> | ||
23 | #include <fcntl.h> | ||
24 | #include <unistd.h> | ||
25 | #include <ctype.h> | ||
26 | #include <stdlib.h> | ||
27 | #include <string.h> | ||
28 | |||
29 | #ifdef CURSES_LOC | ||
30 | #include CURSES_LOC | ||
31 | |||
32 | /* | ||
33 | * Colors in ncurses 1.9.9e do not work properly since foreground and | ||
34 | * background colors are OR'd rather than separately masked. This version | ||
35 | * of dialog was hacked to work with ncurses 1.9.9e, making it incompatible | ||
36 | * with standard curses. The simplest fix (to make this work with standard | ||
37 | * curses) uses the wbkgdset() function, not used in the original hack. | ||
38 | * Turn it off if we're building with 1.9.9e, since it just confuses things. | ||
39 | */ | ||
40 | #if defined(NCURSES_VERSION) && defined(_NEED_WRAP) && !defined(GCC_PRINTFLIKE) | ||
41 | #define OLD_NCURSES 1 | ||
42 | #undef wbkgdset | ||
43 | #define wbkgdset(w,p) /*nothing*/ | ||
44 | #else | ||
45 | #define OLD_NCURSES 0 | ||
46 | #endif | ||
47 | |||
48 | #define TR(params) _tracef params | ||
49 | |||
50 | #define ESC 27 | ||
51 | #define TAB 9 | ||
52 | #define MAX_LEN 2048 | ||
53 | #define BUF_SIZE (10*1024) | ||
54 | #define MIN(x,y) (x < y ? x : y) | ||
55 | #define MAX(x,y) (x > y ? x : y) | ||
56 | |||
57 | |||
58 | #ifndef ACS_ULCORNER | ||
59 | #define ACS_ULCORNER '+' | ||
60 | #endif | ||
61 | #ifndef ACS_LLCORNER | ||
62 | #define ACS_LLCORNER '+' | ||
63 | #endif | ||
64 | #ifndef ACS_URCORNER | ||
65 | #define ACS_URCORNER '+' | ||
66 | #endif | ||
67 | #ifndef ACS_LRCORNER | ||
68 | #define ACS_LRCORNER '+' | ||
69 | #endif | ||
70 | #ifndef ACS_HLINE | ||
71 | #define ACS_HLINE '-' | ||
72 | #endif | ||
73 | #ifndef ACS_VLINE | ||
74 | #define ACS_VLINE '|' | ||
75 | #endif | ||
76 | #ifndef ACS_LTEE | ||
77 | #define ACS_LTEE '+' | ||
78 | #endif | ||
79 | #ifndef ACS_RTEE | ||
80 | #define ACS_RTEE '+' | ||
81 | #endif | ||
82 | #ifndef ACS_UARROW | ||
83 | #define ACS_UARROW '^' | ||
84 | #endif | ||
85 | #ifndef ACS_DARROW | ||
86 | #define ACS_DARROW 'v' | ||
87 | #endif | ||
88 | |||
89 | /* | ||
90 | * Attribute names | ||
91 | */ | ||
92 | #define screen_attr attributes[0] | ||
93 | #define shadow_attr attributes[1] | ||
94 | #define dialog_attr attributes[2] | ||
95 | #define title_attr attributes[3] | ||
96 | #define border_attr attributes[4] | ||
97 | #define button_active_attr attributes[5] | ||
98 | #define button_inactive_attr attributes[6] | ||
99 | #define button_key_active_attr attributes[7] | ||
100 | #define button_key_inactive_attr attributes[8] | ||
101 | #define button_label_active_attr attributes[9] | ||
102 | #define button_label_inactive_attr attributes[10] | ||
103 | #define inputbox_attr attributes[11] | ||
104 | #define inputbox_border_attr attributes[12] | ||
105 | #define searchbox_attr attributes[13] | ||
106 | #define searchbox_title_attr attributes[14] | ||
107 | #define searchbox_border_attr attributes[15] | ||
108 | #define position_indicator_attr attributes[16] | ||
109 | #define menubox_attr attributes[17] | ||
110 | #define menubox_border_attr attributes[18] | ||
111 | #define item_attr attributes[19] | ||
112 | #define item_selected_attr attributes[20] | ||
113 | #define tag_attr attributes[21] | ||
114 | #define tag_selected_attr attributes[22] | ||
115 | #define tag_key_attr attributes[23] | ||
116 | #define tag_key_selected_attr attributes[24] | ||
117 | #define check_attr attributes[25] | ||
118 | #define check_selected_attr attributes[26] | ||
119 | #define uarrow_attr attributes[27] | ||
120 | #define darrow_attr attributes[28] | ||
121 | |||
122 | /* number of attributes */ | ||
123 | #define ATTRIBUTE_COUNT 29 | ||
124 | |||
125 | /* | ||
126 | * Global variables | ||
127 | */ | ||
128 | extern bool use_colors; | ||
129 | |||
130 | extern chtype attributes[]; | ||
131 | #endif | ||
132 | |||
133 | extern char *backtitle; | ||
134 | |||
135 | struct dialog_list_item { | ||
136 | char *name; | ||
137 | int namelen; | ||
138 | char *tag; | ||
139 | int selected; /* Set to 1 by dialog_*() function. */ | ||
140 | }; | ||
141 | |||
142 | /* | ||
143 | * Function prototypes | ||
144 | */ | ||
145 | |||
146 | void init_dialog (void); | ||
147 | void end_dialog (void); | ||
148 | void dialog_clear (void); | ||
149 | #ifdef CURSES_LOC | ||
150 | void attr_clear (WINDOW * win, int height, int width, chtype attr); | ||
151 | void color_setup (void); | ||
152 | void print_autowrap (WINDOW * win, const char *prompt, int width, int y, int x); | ||
153 | void print_button (WINDOW * win, const char *label, int y, int x, int selected); | ||
154 | void draw_box (WINDOW * win, int y, int x, int height, int width, chtype box, | ||
155 | chtype border); | ||
156 | void draw_shadow (WINDOW * win, int y, int x, int height, int width); | ||
157 | #endif | ||
158 | |||
159 | int first_alpha (const char *string, const char *exempt); | ||
160 | int dialog_yesno (const char *title, const char *prompt, int height, int width); | ||
161 | int dialog_msgbox (const char *title, const char *prompt, int height, | ||
162 | int width, int pause); | ||
163 | int dialog_textbox (const char *title, const char *file, int height, int width); | ||
164 | int dialog_menu (const char *title, const char *prompt, int height, int width, | ||
165 | int menu_height, const char *choice, int item_no, | ||
166 | struct dialog_list_item ** items); | ||
167 | int dialog_checklist (const char *title, const char *prompt, int height, | ||
168 | int width, int list_height, int item_no, | ||
169 | struct dialog_list_item ** items, int flag); | ||
170 | extern unsigned char dialog_input_result[]; | ||
171 | int dialog_inputbox (const char *title, const char *prompt, int height, | ||
172 | int width, const char *init); | ||
173 | |||
174 | struct dialog_list_item *first_sel_item(int item_no, | ||
175 | struct dialog_list_item ** items); | ||
176 | |||
177 | /* | ||
178 | * This is the base for fictitious keys, which activate | ||
179 | * the buttons. | ||
180 | * | ||
181 | * Mouse-generated keys are the following: | ||
182 | * -- the first 32 are used as numbers, in addition to '0'-'9' | ||
183 | * -- the lowercase are used to signal mouse-enter events (M_EVENT + 'o') | ||
184 | * -- uppercase chars are used to invoke the button (M_EVENT + 'O') | ||
185 | */ | ||
186 | #ifdef CURSES_LOC | ||
187 | #define M_EVENT (KEY_MAX+1) | ||
188 | #endif | ||
189 | |||
190 | |||
191 | /* | ||
192 | * The `flag' parameter in checklist is used to select between | ||
193 | * radiolist and checklist | ||
194 | */ | ||
195 | #define FLAG_CHECK 1 | ||
196 | #define FLAG_RADIO 0 | ||
diff --git a/scripts/config/expr.c b/scripts/config/expr.c new file mode 100644 index 000000000..d1af2a581 --- /dev/null +++ b/scripts/config/expr.c | |||
@@ -0,0 +1,1054 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> | ||
3 | * Released under the terms of the GNU GPL v2.0. | ||
4 | */ | ||
5 | |||
6 | #include <stdio.h> | ||
7 | #include <stdlib.h> | ||
8 | #include <string.h> | ||
9 | |||
10 | #define LKC_DIRECT_LINK | ||
11 | #include "lkc.h" | ||
12 | |||
13 | struct expr *expr_alloc_symbol(struct symbol *sym) | ||
14 | { | ||
15 | struct expr *e = malloc(sizeof(*e)); | ||
16 | memset(e, 0, sizeof(*e)); | ||
17 | e->type = E_SYMBOL; | ||
18 | e->left.sym = sym; | ||
19 | return e; | ||
20 | } | ||
21 | |||
22 | struct expr *expr_alloc_one(enum expr_type type, struct expr *ce) | ||
23 | { | ||
24 | struct expr *e = malloc(sizeof(*e)); | ||
25 | memset(e, 0, sizeof(*e)); | ||
26 | e->type = type; | ||
27 | e->left.expr = ce; | ||
28 | return e; | ||
29 | } | ||
30 | |||
31 | struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2) | ||
32 | { | ||
33 | struct expr *e = malloc(sizeof(*e)); | ||
34 | memset(e, 0, sizeof(*e)); | ||
35 | e->type = type; | ||
36 | e->left.expr = e1; | ||
37 | e->right.expr = e2; | ||
38 | return e; | ||
39 | } | ||
40 | |||
41 | struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2) | ||
42 | { | ||
43 | struct expr *e = malloc(sizeof(*e)); | ||
44 | memset(e, 0, sizeof(*e)); | ||
45 | e->type = type; | ||
46 | e->left.sym = s1; | ||
47 | e->right.sym = s2; | ||
48 | return e; | ||
49 | } | ||
50 | |||
51 | struct expr *expr_alloc_and(struct expr *e1, struct expr *e2) | ||
52 | { | ||
53 | if (!e1) | ||
54 | return e2; | ||
55 | return e2 ? expr_alloc_two(E_AND, e1, e2) : e1; | ||
56 | } | ||
57 | |||
58 | struct expr *expr_copy(struct expr *org) | ||
59 | { | ||
60 | struct expr *e; | ||
61 | |||
62 | if (!org) | ||
63 | return NULL; | ||
64 | |||
65 | e = malloc(sizeof(*org)); | ||
66 | memcpy(e, org, sizeof(*org)); | ||
67 | switch (org->type) { | ||
68 | case E_SYMBOL: | ||
69 | e->left = org->left; | ||
70 | break; | ||
71 | case E_NOT: | ||
72 | e->left.expr = expr_copy(org->left.expr); | ||
73 | break; | ||
74 | case E_EQUAL: | ||
75 | case E_UNEQUAL: | ||
76 | e->left.sym = org->left.sym; | ||
77 | e->right.sym = org->right.sym; | ||
78 | break; | ||
79 | case E_AND: | ||
80 | case E_OR: | ||
81 | case E_CHOICE: | ||
82 | e->left.expr = expr_copy(org->left.expr); | ||
83 | e->right.expr = expr_copy(org->right.expr); | ||
84 | break; | ||
85 | default: | ||
86 | printf("can't copy type %d\n", e->type); | ||
87 | free(e); | ||
88 | e = NULL; | ||
89 | break; | ||
90 | } | ||
91 | |||
92 | return e; | ||
93 | } | ||
94 | |||
95 | void expr_free(struct expr *e) | ||
96 | { | ||
97 | if (!e) | ||
98 | return; | ||
99 | |||
100 | switch (e->type) { | ||
101 | case E_SYMBOL: | ||
102 | break; | ||
103 | case E_NOT: | ||
104 | expr_free(e->left.expr); | ||
105 | return; | ||
106 | case E_EQUAL: | ||
107 | case E_UNEQUAL: | ||
108 | break; | ||
109 | case E_OR: | ||
110 | case E_AND: | ||
111 | expr_free(e->left.expr); | ||
112 | expr_free(e->right.expr); | ||
113 | break; | ||
114 | default: | ||
115 | printf("how to free type %d?\n", e->type); | ||
116 | break; | ||
117 | } | ||
118 | free(e); | ||
119 | } | ||
120 | |||
121 | static int trans_count; | ||
122 | |||
123 | #define e1 (*ep1) | ||
124 | #define e2 (*ep2) | ||
125 | |||
126 | static void __expr_eliminate_eq(enum expr_type type, struct expr **ep1, struct expr **ep2) | ||
127 | { | ||
128 | if (e1->type == type) { | ||
129 | __expr_eliminate_eq(type, &e1->left.expr, &e2); | ||
130 | __expr_eliminate_eq(type, &e1->right.expr, &e2); | ||
131 | return; | ||
132 | } | ||
133 | if (e2->type == type) { | ||
134 | __expr_eliminate_eq(type, &e1, &e2->left.expr); | ||
135 | __expr_eliminate_eq(type, &e1, &e2->right.expr); | ||
136 | return; | ||
137 | } | ||
138 | if (e1->type == E_SYMBOL && e2->type == E_SYMBOL && | ||
139 | e1->left.sym == e2->left.sym && (e1->left.sym->flags & (SYMBOL_YES|SYMBOL_NO))) | ||
140 | return; | ||
141 | if (!expr_eq(e1, e2)) | ||
142 | return; | ||
143 | trans_count++; | ||
144 | expr_free(e1); expr_free(e2); | ||
145 | switch (type) { | ||
146 | case E_OR: | ||
147 | e1 = expr_alloc_symbol(&symbol_no); | ||
148 | e2 = expr_alloc_symbol(&symbol_no); | ||
149 | break; | ||
150 | case E_AND: | ||
151 | e1 = expr_alloc_symbol(&symbol_yes); | ||
152 | e2 = expr_alloc_symbol(&symbol_yes); | ||
153 | break; | ||
154 | default: | ||
155 | ; | ||
156 | } | ||
157 | } | ||
158 | |||
159 | void expr_eliminate_eq(struct expr **ep1, struct expr **ep2) | ||
160 | { | ||
161 | if (!e1 || !e2 || e1->type != e2->type) | ||
162 | return; | ||
163 | __expr_eliminate_eq(e1->type, ep1, ep2); | ||
164 | e1 = expr_eliminate_yn(e1); | ||
165 | e2 = expr_eliminate_yn(e2); | ||
166 | } | ||
167 | |||
168 | #undef e1 | ||
169 | #undef e2 | ||
170 | |||
171 | int expr_eq(struct expr *e1, struct expr *e2) | ||
172 | { | ||
173 | int res, old_count; | ||
174 | |||
175 | if (e1->type != e2->type) | ||
176 | return 0; | ||
177 | switch (e1->type) { | ||
178 | case E_EQUAL: | ||
179 | case E_UNEQUAL: | ||
180 | return e1->left.sym == e2->left.sym && e1->right.sym == e2->right.sym; | ||
181 | case E_SYMBOL: | ||
182 | return e1->left.sym == e2->left.sym; | ||
183 | case E_NOT: | ||
184 | return expr_eq(e1->left.expr, e2->left.expr); | ||
185 | case E_AND: | ||
186 | case E_OR: | ||
187 | e1 = expr_copy(e1); | ||
188 | e2 = expr_copy(e2); | ||
189 | old_count = trans_count; | ||
190 | expr_eliminate_eq(&e1, &e2); | ||
191 | res = (e1->type == E_SYMBOL && e2->type == E_SYMBOL && | ||
192 | e1->left.sym == e2->left.sym); | ||
193 | expr_free(e1); | ||
194 | expr_free(e2); | ||
195 | trans_count = old_count; | ||
196 | return res; | ||
197 | case E_CHOICE: | ||
198 | case E_NONE: | ||
199 | /* panic */; | ||
200 | } | ||
201 | |||
202 | print_expr(0, e1, 0); | ||
203 | printf(" = "); | ||
204 | print_expr(0, e2, 0); | ||
205 | printf(" ?\n"); | ||
206 | |||
207 | return 0; | ||
208 | } | ||
209 | |||
210 | struct expr *expr_eliminate_yn(struct expr *e) | ||
211 | { | ||
212 | struct expr *tmp; | ||
213 | |||
214 | if (e) switch (e->type) { | ||
215 | case E_AND: | ||
216 | e->left.expr = expr_eliminate_yn(e->left.expr); | ||
217 | e->right.expr = expr_eliminate_yn(e->right.expr); | ||
218 | if (e->left.expr->type == E_SYMBOL) { | ||
219 | if (e->left.expr->left.sym == &symbol_no) { | ||
220 | expr_free(e->left.expr); | ||
221 | expr_free(e->right.expr); | ||
222 | e->type = E_SYMBOL; | ||
223 | e->left.sym = &symbol_no; | ||
224 | e->right.expr = NULL; | ||
225 | return e; | ||
226 | } else if (e->left.expr->left.sym == &symbol_yes) { | ||
227 | free(e->left.expr); | ||
228 | tmp = e->right.expr; | ||
229 | *e = *(e->right.expr); | ||
230 | free(tmp); | ||
231 | return e; | ||
232 | } | ||
233 | } | ||
234 | if (e->right.expr->type == E_SYMBOL) { | ||
235 | if (e->right.expr->left.sym == &symbol_no) { | ||
236 | expr_free(e->left.expr); | ||
237 | expr_free(e->right.expr); | ||
238 | e->type = E_SYMBOL; | ||
239 | e->left.sym = &symbol_no; | ||
240 | e->right.expr = NULL; | ||
241 | return e; | ||
242 | } else if (e->right.expr->left.sym == &symbol_yes) { | ||
243 | free(e->right.expr); | ||
244 | tmp = e->left.expr; | ||
245 | *e = *(e->left.expr); | ||
246 | free(tmp); | ||
247 | return e; | ||
248 | } | ||
249 | } | ||
250 | break; | ||
251 | case E_OR: | ||
252 | e->left.expr = expr_eliminate_yn(e->left.expr); | ||
253 | e->right.expr = expr_eliminate_yn(e->right.expr); | ||
254 | if (e->left.expr->type == E_SYMBOL) { | ||
255 | if (e->left.expr->left.sym == &symbol_no) { | ||
256 | free(e->left.expr); | ||
257 | tmp = e->right.expr; | ||
258 | *e = *(e->right.expr); | ||
259 | free(tmp); | ||
260 | return e; | ||
261 | } else if (e->left.expr->left.sym == &symbol_yes) { | ||
262 | expr_free(e->left.expr); | ||
263 | expr_free(e->right.expr); | ||
264 | e->type = E_SYMBOL; | ||
265 | e->left.sym = &symbol_yes; | ||
266 | e->right.expr = NULL; | ||
267 | return e; | ||
268 | } | ||
269 | } | ||
270 | if (e->right.expr->type == E_SYMBOL) { | ||
271 | if (e->right.expr->left.sym == &symbol_no) { | ||
272 | free(e->right.expr); | ||
273 | tmp = e->left.expr; | ||
274 | *e = *(e->left.expr); | ||
275 | free(tmp); | ||
276 | return e; | ||
277 | } else if (e->right.expr->left.sym == &symbol_yes) { | ||
278 | expr_free(e->left.expr); | ||
279 | expr_free(e->right.expr); | ||
280 | e->type = E_SYMBOL; | ||
281 | e->left.sym = &symbol_yes; | ||
282 | e->right.expr = NULL; | ||
283 | return e; | ||
284 | } | ||
285 | } | ||
286 | break; | ||
287 | default: | ||
288 | ; | ||
289 | } | ||
290 | return e; | ||
291 | } | ||
292 | |||
293 | /* | ||
294 | * bool FOO!=n => FOO | ||
295 | */ | ||
296 | struct expr *expr_trans_bool(struct expr *e) | ||
297 | { | ||
298 | if (!e) | ||
299 | return NULL; | ||
300 | switch (e->type) { | ||
301 | case E_AND: | ||
302 | case E_OR: | ||
303 | case E_NOT: | ||
304 | e->left.expr = expr_trans_bool(e->left.expr); | ||
305 | e->right.expr = expr_trans_bool(e->right.expr); | ||
306 | break; | ||
307 | case E_UNEQUAL: | ||
308 | // FOO!=n -> FOO | ||
309 | if (e->left.sym->type == S_TRISTATE) { | ||
310 | if (e->right.sym == &symbol_no) { | ||
311 | e->type = E_SYMBOL; | ||
312 | e->right.sym = NULL; | ||
313 | } | ||
314 | } | ||
315 | break; | ||
316 | default: | ||
317 | ; | ||
318 | } | ||
319 | return e; | ||
320 | } | ||
321 | |||
322 | /* | ||
323 | * e1 || e2 -> ? | ||
324 | */ | ||
325 | struct expr *expr_join_or(struct expr *e1, struct expr *e2) | ||
326 | { | ||
327 | struct expr *tmp; | ||
328 | struct symbol *sym1, *sym2; | ||
329 | |||
330 | if (expr_eq(e1, e2)) | ||
331 | return expr_copy(e1); | ||
332 | if (e1->type != E_EQUAL && e1->type != E_UNEQUAL && e1->type != E_SYMBOL && e1->type != E_NOT) | ||
333 | return NULL; | ||
334 | if (e2->type != E_EQUAL && e2->type != E_UNEQUAL && e2->type != E_SYMBOL && e2->type != E_NOT) | ||
335 | return NULL; | ||
336 | if (e1->type == E_NOT) { | ||
337 | tmp = e1->left.expr; | ||
338 | if (tmp->type != E_EQUAL && tmp->type != E_UNEQUAL && tmp->type != E_SYMBOL) | ||
339 | return NULL; | ||
340 | sym1 = tmp->left.sym; | ||
341 | } else | ||
342 | sym1 = e1->left.sym; | ||
343 | if (e2->type == E_NOT) { | ||
344 | if (e2->left.expr->type != E_SYMBOL) | ||
345 | return NULL; | ||
346 | sym2 = e2->left.expr->left.sym; | ||
347 | } else | ||
348 | sym2 = e2->left.sym; | ||
349 | if (sym1 != sym2) | ||
350 | return NULL; | ||
351 | if (sym1->type != S_BOOLEAN && sym1->type != S_TRISTATE) | ||
352 | return NULL; | ||
353 | if (sym1->type == S_TRISTATE) { | ||
354 | if (e1->type == E_EQUAL && e2->type == E_EQUAL && | ||
355 | ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_mod) || | ||
356 | (e1->right.sym == &symbol_mod && e2->right.sym == &symbol_yes))) { | ||
357 | // (a='y') || (a='m') -> (a!='n') | ||
358 | return expr_alloc_comp(E_UNEQUAL, sym1, &symbol_no); | ||
359 | } | ||
360 | if (e1->type == E_EQUAL && e2->type == E_EQUAL && | ||
361 | ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_no) || | ||
362 | (e1->right.sym == &symbol_no && e2->right.sym == &symbol_yes))) { | ||
363 | // (a='y') || (a='n') -> (a!='m') | ||
364 | return expr_alloc_comp(E_UNEQUAL, sym1, &symbol_mod); | ||
365 | } | ||
366 | if (e1->type == E_EQUAL && e2->type == E_EQUAL && | ||
367 | ((e1->right.sym == &symbol_mod && e2->right.sym == &symbol_no) || | ||
368 | (e1->right.sym == &symbol_no && e2->right.sym == &symbol_mod))) { | ||
369 | // (a='m') || (a='n') -> (a!='y') | ||
370 | return expr_alloc_comp(E_UNEQUAL, sym1, &symbol_yes); | ||
371 | } | ||
372 | } | ||
373 | if (sym1->type == S_BOOLEAN && sym1 == sym2) { | ||
374 | if ((e1->type == E_NOT && e1->left.expr->type == E_SYMBOL && e2->type == E_SYMBOL) || | ||
375 | (e2->type == E_NOT && e2->left.expr->type == E_SYMBOL && e1->type == E_SYMBOL)) | ||
376 | return expr_alloc_symbol(&symbol_yes); | ||
377 | } | ||
378 | |||
379 | printf("optimize "); | ||
380 | print_expr(0, e1, 0); | ||
381 | printf(" || "); | ||
382 | print_expr(0, e2, 0); | ||
383 | printf(" ?\n"); | ||
384 | return NULL; | ||
385 | } | ||
386 | |||
387 | struct expr *expr_join_and(struct expr *e1, struct expr *e2) | ||
388 | { | ||
389 | struct expr *tmp; | ||
390 | struct symbol *sym1, *sym2; | ||
391 | |||
392 | if (expr_eq(e1, e2)) | ||
393 | return expr_copy(e1); | ||
394 | if (e1->type != E_EQUAL && e1->type != E_UNEQUAL && e1->type != E_SYMBOL && e1->type != E_NOT) | ||
395 | return NULL; | ||
396 | if (e2->type != E_EQUAL && e2->type != E_UNEQUAL && e2->type != E_SYMBOL && e2->type != E_NOT) | ||
397 | return NULL; | ||
398 | if (e1->type == E_NOT) { | ||
399 | tmp = e1->left.expr; | ||
400 | if (tmp->type != E_EQUAL && tmp->type != E_UNEQUAL && tmp->type != E_SYMBOL) | ||
401 | return NULL; | ||
402 | sym1 = tmp->left.sym; | ||
403 | } else | ||
404 | sym1 = e1->left.sym; | ||
405 | if (e2->type == E_NOT) { | ||
406 | if (e2->left.expr->type != E_SYMBOL) | ||
407 | return NULL; | ||
408 | sym2 = e2->left.expr->left.sym; | ||
409 | } else | ||
410 | sym2 = e2->left.sym; | ||
411 | if (sym1 != sym2) | ||
412 | return NULL; | ||
413 | if (sym1->type != S_BOOLEAN && sym1->type != S_TRISTATE) | ||
414 | return NULL; | ||
415 | |||
416 | if ((e1->type == E_SYMBOL && e2->type == E_EQUAL && e2->right.sym == &symbol_yes) || | ||
417 | (e2->type == E_SYMBOL && e1->type == E_EQUAL && e1->right.sym == &symbol_yes)) | ||
418 | // (a) && (a='y') -> (a='y') | ||
419 | return expr_alloc_comp(E_EQUAL, sym1, &symbol_yes); | ||
420 | |||
421 | if ((e1->type == E_SYMBOL && e2->type == E_UNEQUAL && e2->right.sym == &symbol_no) || | ||
422 | (e2->type == E_SYMBOL && e1->type == E_UNEQUAL && e1->right.sym == &symbol_no)) | ||
423 | // (a) && (a!='n') -> (a) | ||
424 | return expr_alloc_symbol(sym1); | ||
425 | |||
426 | if (sym1->type == S_TRISTATE) { | ||
427 | if (e1->type == E_EQUAL && e2->type == E_UNEQUAL) { | ||
428 | // (a='b') && (a!='c') -> 'b'='c' ? 'n' : a='b' | ||
429 | sym2 = e1->right.sym; | ||
430 | if ((e2->right.sym->flags & SYMBOL_CONST) && (sym2->flags & SYMBOL_CONST)) | ||
431 | return sym2 != e2->right.sym ? expr_alloc_comp(E_EQUAL, sym1, sym2) | ||
432 | : expr_alloc_symbol(&symbol_no); | ||
433 | } | ||
434 | if (e1->type == E_UNEQUAL && e2->type == E_EQUAL) { | ||
435 | // (a='b') && (a!='c') -> 'b'='c' ? 'n' : a='b' | ||
436 | sym2 = e2->right.sym; | ||
437 | if ((e1->right.sym->flags & SYMBOL_CONST) && (sym2->flags & SYMBOL_CONST)) | ||
438 | return sym2 != e1->right.sym ? expr_alloc_comp(E_EQUAL, sym1, sym2) | ||
439 | : expr_alloc_symbol(&symbol_no); | ||
440 | } | ||
441 | if (e1->type == E_UNEQUAL && e2->type == E_UNEQUAL && | ||
442 | ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_no) || | ||
443 | (e1->right.sym == &symbol_no && e2->right.sym == &symbol_yes))) | ||
444 | // (a!='y') && (a!='n') -> (a='m') | ||
445 | return expr_alloc_comp(E_EQUAL, sym1, &symbol_mod); | ||
446 | |||
447 | if (e1->type == E_UNEQUAL && e2->type == E_UNEQUAL && | ||
448 | ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_mod) || | ||
449 | (e1->right.sym == &symbol_mod && e2->right.sym == &symbol_yes))) | ||
450 | // (a!='y') && (a!='m') -> (a='n') | ||
451 | return expr_alloc_comp(E_EQUAL, sym1, &symbol_no); | ||
452 | |||
453 | if (e1->type == E_UNEQUAL && e2->type == E_UNEQUAL && | ||
454 | ((e1->right.sym == &symbol_mod && e2->right.sym == &symbol_no) || | ||
455 | (e1->right.sym == &symbol_no && e2->right.sym == &symbol_mod))) | ||
456 | // (a!='m') && (a!='n') -> (a='m') | ||
457 | return expr_alloc_comp(E_EQUAL, sym1, &symbol_yes); | ||
458 | |||
459 | if ((e1->type == E_SYMBOL && e2->type == E_EQUAL && e2->right.sym == &symbol_mod) || | ||
460 | (e2->type == E_SYMBOL && e1->type == E_EQUAL && e1->right.sym == &symbol_mod) || | ||
461 | (e1->type == E_SYMBOL && e2->type == E_UNEQUAL && e2->right.sym == &symbol_yes) || | ||
462 | (e2->type == E_SYMBOL && e1->type == E_UNEQUAL && e1->right.sym == &symbol_yes)) | ||
463 | return NULL; | ||
464 | } | ||
465 | printf("optimize "); | ||
466 | print_expr(0, e1, 0); | ||
467 | printf(" && "); | ||
468 | print_expr(0, e2, 0); | ||
469 | printf(" ?\n"); | ||
470 | return NULL; | ||
471 | } | ||
472 | |||
473 | static void expr_eliminate_dups1(enum expr_type type, struct expr **ep1, struct expr **ep2) | ||
474 | { | ||
475 | #define e1 (*ep1) | ||
476 | #define e2 (*ep2) | ||
477 | struct expr *tmp; | ||
478 | |||
479 | if (e1->type == type) { | ||
480 | expr_eliminate_dups1(type, &e1->left.expr, &e2); | ||
481 | expr_eliminate_dups1(type, &e1->right.expr, &e2); | ||
482 | return; | ||
483 | } | ||
484 | if (e2->type == type) { | ||
485 | expr_eliminate_dups1(type, &e1, &e2->left.expr); | ||
486 | expr_eliminate_dups1(type, &e1, &e2->right.expr); | ||
487 | return; | ||
488 | } | ||
489 | if (e1 == e2) | ||
490 | return; | ||
491 | |||
492 | switch (e1->type) { | ||
493 | case E_OR: case E_AND: | ||
494 | expr_eliminate_dups1(e1->type, &e1, &e1); | ||
495 | default: | ||
496 | ; | ||
497 | } | ||
498 | |||
499 | switch (type) { | ||
500 | case E_OR: | ||
501 | tmp = expr_join_or(e1, e2); | ||
502 | if (tmp) { | ||
503 | expr_free(e1); expr_free(e2); | ||
504 | e1 = expr_alloc_symbol(&symbol_no); | ||
505 | e2 = tmp; | ||
506 | trans_count++; | ||
507 | } | ||
508 | break; | ||
509 | case E_AND: | ||
510 | tmp = expr_join_and(e1, e2); | ||
511 | if (tmp) { | ||
512 | expr_free(e1); expr_free(e2); | ||
513 | e1 = expr_alloc_symbol(&symbol_yes); | ||
514 | e2 = tmp; | ||
515 | trans_count++; | ||
516 | } | ||
517 | break; | ||
518 | default: | ||
519 | ; | ||
520 | } | ||
521 | #undef e1 | ||
522 | #undef e2 | ||
523 | } | ||
524 | |||
525 | static void expr_eliminate_dups2(enum expr_type type, struct expr **ep1, struct expr **ep2) | ||
526 | { | ||
527 | #define e1 (*ep1) | ||
528 | #define e2 (*ep2) | ||
529 | struct expr *tmp, *tmp1, *tmp2; | ||
530 | |||
531 | if (e1->type == type) { | ||
532 | expr_eliminate_dups2(type, &e1->left.expr, &e2); | ||
533 | expr_eliminate_dups2(type, &e1->right.expr, &e2); | ||
534 | return; | ||
535 | } | ||
536 | if (e2->type == type) { | ||
537 | expr_eliminate_dups2(type, &e1, &e2->left.expr); | ||
538 | expr_eliminate_dups2(type, &e1, &e2->right.expr); | ||
539 | } | ||
540 | if (e1 == e2) | ||
541 | return; | ||
542 | |||
543 | switch (e1->type) { | ||
544 | case E_OR: | ||
545 | expr_eliminate_dups2(e1->type, &e1, &e1); | ||
546 | // (FOO || BAR) && (!FOO && !BAR) -> n | ||
547 | tmp1 = expr_transform(expr_alloc_one(E_NOT, expr_copy(e1))); | ||
548 | tmp2 = expr_copy(e2); | ||
549 | tmp = expr_extract_eq_and(&tmp1, &tmp2); | ||
550 | if (expr_is_yes(tmp1)) { | ||
551 | expr_free(e1); | ||
552 | e1 = expr_alloc_symbol(&symbol_no); | ||
553 | trans_count++; | ||
554 | } | ||
555 | expr_free(tmp2); | ||
556 | expr_free(tmp1); | ||
557 | expr_free(tmp); | ||
558 | break; | ||
559 | case E_AND: | ||
560 | expr_eliminate_dups2(e1->type, &e1, &e1); | ||
561 | // (FOO && BAR) || (!FOO || !BAR) -> y | ||
562 | tmp1 = expr_transform(expr_alloc_one(E_NOT, expr_copy(e1))); | ||
563 | tmp2 = expr_copy(e2); | ||
564 | tmp = expr_extract_eq_or(&tmp1, &tmp2); | ||
565 | if (expr_is_no(tmp1)) { | ||
566 | expr_free(e1); | ||
567 | e1 = expr_alloc_symbol(&symbol_yes); | ||
568 | trans_count++; | ||
569 | } | ||
570 | expr_free(tmp2); | ||
571 | expr_free(tmp1); | ||
572 | expr_free(tmp); | ||
573 | break; | ||
574 | default: | ||
575 | ; | ||
576 | } | ||
577 | #undef e1 | ||
578 | #undef e2 | ||
579 | } | ||
580 | |||
581 | struct expr *expr_eliminate_dups(struct expr *e) | ||
582 | { | ||
583 | int oldcount; | ||
584 | if (!e) | ||
585 | return e; | ||
586 | |||
587 | oldcount = trans_count; | ||
588 | while (1) { | ||
589 | trans_count = 0; | ||
590 | switch (e->type) { | ||
591 | case E_OR: case E_AND: | ||
592 | expr_eliminate_dups1(e->type, &e, &e); | ||
593 | expr_eliminate_dups2(e->type, &e, &e); | ||
594 | default: | ||
595 | ; | ||
596 | } | ||
597 | if (!trans_count) | ||
598 | break; | ||
599 | e = expr_eliminate_yn(e); | ||
600 | } | ||
601 | trans_count = oldcount; | ||
602 | return e; | ||
603 | } | ||
604 | |||
605 | struct expr *expr_transform(struct expr *e) | ||
606 | { | ||
607 | struct expr *tmp; | ||
608 | |||
609 | if (!e) | ||
610 | return NULL; | ||
611 | switch (e->type) { | ||
612 | case E_EQUAL: | ||
613 | case E_UNEQUAL: | ||
614 | case E_SYMBOL: | ||
615 | case E_CHOICE: | ||
616 | break; | ||
617 | default: | ||
618 | e->left.expr = expr_transform(e->left.expr); | ||
619 | e->right.expr = expr_transform(e->right.expr); | ||
620 | } | ||
621 | |||
622 | switch (e->type) { | ||
623 | case E_EQUAL: | ||
624 | if (e->left.sym->type != S_BOOLEAN) | ||
625 | break; | ||
626 | if (e->right.sym == &symbol_no) { | ||
627 | e->type = E_NOT; | ||
628 | e->left.expr = expr_alloc_symbol(e->left.sym); | ||
629 | e->right.sym = NULL; | ||
630 | break; | ||
631 | } | ||
632 | if (e->right.sym == &symbol_mod) { | ||
633 | printf("boolean symbol %s tested for 'm'? test forced to 'n'\n", e->left.sym->name); | ||
634 | e->type = E_SYMBOL; | ||
635 | e->left.sym = &symbol_no; | ||
636 | e->right.sym = NULL; | ||
637 | break; | ||
638 | } | ||
639 | if (e->right.sym == &symbol_yes) { | ||
640 | e->type = E_SYMBOL; | ||
641 | e->right.sym = NULL; | ||
642 | break; | ||
643 | } | ||
644 | break; | ||
645 | case E_UNEQUAL: | ||
646 | if (e->left.sym->type != S_BOOLEAN) | ||
647 | break; | ||
648 | if (e->right.sym == &symbol_no) { | ||
649 | e->type = E_SYMBOL; | ||
650 | e->right.sym = NULL; | ||
651 | break; | ||
652 | } | ||
653 | if (e->right.sym == &symbol_mod) { | ||
654 | printf("boolean symbol %s tested for 'm'? test forced to 'y'\n", e->left.sym->name); | ||
655 | e->type = E_SYMBOL; | ||
656 | e->left.sym = &symbol_yes; | ||
657 | e->right.sym = NULL; | ||
658 | break; | ||
659 | } | ||
660 | if (e->right.sym == &symbol_yes) { | ||
661 | e->type = E_NOT; | ||
662 | e->left.expr = expr_alloc_symbol(e->left.sym); | ||
663 | e->right.sym = NULL; | ||
664 | break; | ||
665 | } | ||
666 | break; | ||
667 | case E_NOT: | ||
668 | switch (e->left.expr->type) { | ||
669 | case E_NOT: | ||
670 | // !!a -> a | ||
671 | tmp = e->left.expr->left.expr; | ||
672 | free(e->left.expr); | ||
673 | free(e); | ||
674 | e = tmp; | ||
675 | e = expr_transform(e); | ||
676 | break; | ||
677 | case E_EQUAL: | ||
678 | case E_UNEQUAL: | ||
679 | // !a='x' -> a!='x' | ||
680 | tmp = e->left.expr; | ||
681 | free(e); | ||
682 | e = tmp; | ||
683 | e->type = e->type == E_EQUAL ? E_UNEQUAL : E_EQUAL; | ||
684 | break; | ||
685 | case E_OR: | ||
686 | // !(a || b) -> !a && !b | ||
687 | tmp = e->left.expr; | ||
688 | e->type = E_AND; | ||
689 | e->right.expr = expr_alloc_one(E_NOT, tmp->right.expr); | ||
690 | tmp->type = E_NOT; | ||
691 | tmp->right.expr = NULL; | ||
692 | e = expr_transform(e); | ||
693 | break; | ||
694 | case E_AND: | ||
695 | // !(a && b) -> !a || !b | ||
696 | tmp = e->left.expr; | ||
697 | e->type = E_OR; | ||
698 | e->right.expr = expr_alloc_one(E_NOT, tmp->right.expr); | ||
699 | tmp->type = E_NOT; | ||
700 | tmp->right.expr = NULL; | ||
701 | e = expr_transform(e); | ||
702 | break; | ||
703 | case E_SYMBOL: | ||
704 | if (e->left.expr->left.sym == &symbol_yes) { | ||
705 | // !'y' -> 'n' | ||
706 | tmp = e->left.expr; | ||
707 | free(e); | ||
708 | e = tmp; | ||
709 | e->type = E_SYMBOL; | ||
710 | e->left.sym = &symbol_no; | ||
711 | break; | ||
712 | } | ||
713 | if (e->left.expr->left.sym == &symbol_mod) { | ||
714 | // !'m' -> 'm' | ||
715 | tmp = e->left.expr; | ||
716 | free(e); | ||
717 | e = tmp; | ||
718 | e->type = E_SYMBOL; | ||
719 | e->left.sym = &symbol_mod; | ||
720 | break; | ||
721 | } | ||
722 | if (e->left.expr->left.sym == &symbol_no) { | ||
723 | // !'n' -> 'y' | ||
724 | tmp = e->left.expr; | ||
725 | free(e); | ||
726 | e = tmp; | ||
727 | e->type = E_SYMBOL; | ||
728 | e->left.sym = &symbol_yes; | ||
729 | break; | ||
730 | } | ||
731 | break; | ||
732 | default: | ||
733 | ; | ||
734 | } | ||
735 | break; | ||
736 | default: | ||
737 | ; | ||
738 | } | ||
739 | return e; | ||
740 | } | ||
741 | |||
742 | int expr_contains_symbol(struct expr *dep, struct symbol *sym) | ||
743 | { | ||
744 | if (!dep) | ||
745 | return 0; | ||
746 | |||
747 | switch (dep->type) { | ||
748 | case E_AND: | ||
749 | case E_OR: | ||
750 | return expr_contains_symbol(dep->left.expr, sym) || | ||
751 | expr_contains_symbol(dep->right.expr, sym); | ||
752 | case E_SYMBOL: | ||
753 | return dep->left.sym == sym; | ||
754 | case E_EQUAL: | ||
755 | case E_UNEQUAL: | ||
756 | return dep->left.sym == sym || | ||
757 | dep->right.sym == sym; | ||
758 | case E_NOT: | ||
759 | return expr_contains_symbol(dep->left.expr, sym); | ||
760 | default: | ||
761 | ; | ||
762 | } | ||
763 | return 0; | ||
764 | } | ||
765 | |||
766 | bool expr_depends_symbol(struct expr *dep, struct symbol *sym) | ||
767 | { | ||
768 | if (!dep) | ||
769 | return false; | ||
770 | |||
771 | switch (dep->type) { | ||
772 | case E_AND: | ||
773 | return expr_depends_symbol(dep->left.expr, sym) || | ||
774 | expr_depends_symbol(dep->right.expr, sym); | ||
775 | case E_SYMBOL: | ||
776 | return dep->left.sym == sym; | ||
777 | case E_EQUAL: | ||
778 | if (dep->left.sym == sym) { | ||
779 | if (dep->right.sym == &symbol_yes || dep->right.sym == &symbol_mod) | ||
780 | return true; | ||
781 | } | ||
782 | break; | ||
783 | case E_UNEQUAL: | ||
784 | if (dep->left.sym == sym) { | ||
785 | if (dep->right.sym == &symbol_no) | ||
786 | return true; | ||
787 | } | ||
788 | break; | ||
789 | default: | ||
790 | ; | ||
791 | } | ||
792 | return false; | ||
793 | } | ||
794 | |||
795 | struct expr *expr_extract_eq_and(struct expr **ep1, struct expr **ep2) | ||
796 | { | ||
797 | struct expr *tmp = NULL; | ||
798 | expr_extract_eq(E_AND, &tmp, ep1, ep2); | ||
799 | if (tmp) { | ||
800 | *ep1 = expr_eliminate_yn(*ep1); | ||
801 | *ep2 = expr_eliminate_yn(*ep2); | ||
802 | } | ||
803 | return tmp; | ||
804 | } | ||
805 | |||
806 | struct expr *expr_extract_eq_or(struct expr **ep1, struct expr **ep2) | ||
807 | { | ||
808 | struct expr *tmp = NULL; | ||
809 | expr_extract_eq(E_OR, &tmp, ep1, ep2); | ||
810 | if (tmp) { | ||
811 | *ep1 = expr_eliminate_yn(*ep1); | ||
812 | *ep2 = expr_eliminate_yn(*ep2); | ||
813 | } | ||
814 | return tmp; | ||
815 | } | ||
816 | |||
817 | void expr_extract_eq(enum expr_type type, struct expr **ep, struct expr **ep1, struct expr **ep2) | ||
818 | { | ||
819 | #define e1 (*ep1) | ||
820 | #define e2 (*ep2) | ||
821 | if (e1->type == type) { | ||
822 | expr_extract_eq(type, ep, &e1->left.expr, &e2); | ||
823 | expr_extract_eq(type, ep, &e1->right.expr, &e2); | ||
824 | return; | ||
825 | } | ||
826 | if (e2->type == type) { | ||
827 | expr_extract_eq(type, ep, ep1, &e2->left.expr); | ||
828 | expr_extract_eq(type, ep, ep1, &e2->right.expr); | ||
829 | return; | ||
830 | } | ||
831 | if (expr_eq(e1, e2)) { | ||
832 | *ep = *ep ? expr_alloc_two(type, *ep, e1) : e1; | ||
833 | expr_free(e2); | ||
834 | if (type == E_AND) { | ||
835 | e1 = expr_alloc_symbol(&symbol_yes); | ||
836 | e2 = expr_alloc_symbol(&symbol_yes); | ||
837 | } else if (type == E_OR) { | ||
838 | e1 = expr_alloc_symbol(&symbol_no); | ||
839 | e2 = expr_alloc_symbol(&symbol_no); | ||
840 | } | ||
841 | } | ||
842 | #undef e1 | ||
843 | #undef e2 | ||
844 | } | ||
845 | |||
846 | struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym) | ||
847 | { | ||
848 | struct expr *e1, *e2; | ||
849 | |||
850 | if (!e) { | ||
851 | e = expr_alloc_symbol(sym); | ||
852 | if (type == E_UNEQUAL) | ||
853 | e = expr_alloc_one(E_NOT, e); | ||
854 | return e; | ||
855 | } | ||
856 | switch (e->type) { | ||
857 | case E_AND: | ||
858 | e1 = expr_trans_compare(e->left.expr, E_EQUAL, sym); | ||
859 | e2 = expr_trans_compare(e->right.expr, E_EQUAL, sym); | ||
860 | if (sym == &symbol_yes) | ||
861 | e = expr_alloc_two(E_AND, e1, e2); | ||
862 | if (sym == &symbol_no) | ||
863 | e = expr_alloc_two(E_OR, e1, e2); | ||
864 | if (type == E_UNEQUAL) | ||
865 | e = expr_alloc_one(E_NOT, e); | ||
866 | return e; | ||
867 | case E_OR: | ||
868 | e1 = expr_trans_compare(e->left.expr, E_EQUAL, sym); | ||
869 | e2 = expr_trans_compare(e->right.expr, E_EQUAL, sym); | ||
870 | if (sym == &symbol_yes) | ||
871 | e = expr_alloc_two(E_OR, e1, e2); | ||
872 | if (sym == &symbol_no) | ||
873 | e = expr_alloc_two(E_AND, e1, e2); | ||
874 | if (type == E_UNEQUAL) | ||
875 | e = expr_alloc_one(E_NOT, e); | ||
876 | return e; | ||
877 | case E_NOT: | ||
878 | return expr_trans_compare(e->left.expr, type == E_EQUAL ? E_UNEQUAL : E_EQUAL, sym); | ||
879 | case E_UNEQUAL: | ||
880 | case E_EQUAL: | ||
881 | if (type == E_EQUAL) { | ||
882 | if (sym == &symbol_yes) | ||
883 | return expr_copy(e); | ||
884 | if (sym == &symbol_mod) | ||
885 | return expr_alloc_symbol(&symbol_no); | ||
886 | if (sym == &symbol_no) | ||
887 | return expr_alloc_one(E_NOT, expr_copy(e)); | ||
888 | } else { | ||
889 | if (sym == &symbol_yes) | ||
890 | return expr_alloc_one(E_NOT, expr_copy(e)); | ||
891 | if (sym == &symbol_mod) | ||
892 | return expr_alloc_symbol(&symbol_yes); | ||
893 | if (sym == &symbol_no) | ||
894 | return expr_copy(e); | ||
895 | } | ||
896 | break; | ||
897 | case E_SYMBOL: | ||
898 | return expr_alloc_comp(type, e->left.sym, sym); | ||
899 | case E_CHOICE: | ||
900 | case E_NONE: | ||
901 | /* panic */; | ||
902 | } | ||
903 | return NULL; | ||
904 | } | ||
905 | |||
906 | tristate expr_calc_value(struct expr *e) | ||
907 | { | ||
908 | tristate val1, val2; | ||
909 | const char *str1, *str2; | ||
910 | |||
911 | if (!e) | ||
912 | return yes; | ||
913 | |||
914 | switch (e->type) { | ||
915 | case E_SYMBOL: | ||
916 | sym_calc_value(e->left.sym); | ||
917 | return S_TRI(e->left.sym->curr); | ||
918 | case E_AND: | ||
919 | val1 = expr_calc_value(e->left.expr); | ||
920 | val2 = expr_calc_value(e->right.expr); | ||
921 | return E_AND(val1, val2); | ||
922 | case E_OR: | ||
923 | val1 = expr_calc_value(e->left.expr); | ||
924 | val2 = expr_calc_value(e->right.expr); | ||
925 | return E_OR(val1, val2); | ||
926 | case E_NOT: | ||
927 | val1 = expr_calc_value(e->left.expr); | ||
928 | return E_NOT(val1); | ||
929 | case E_EQUAL: | ||
930 | sym_calc_value(e->left.sym); | ||
931 | sym_calc_value(e->right.sym); | ||
932 | str1 = sym_get_string_value(e->left.sym); | ||
933 | str2 = sym_get_string_value(e->right.sym); | ||
934 | return !strcmp(str1, str2) ? yes : no; | ||
935 | case E_UNEQUAL: | ||
936 | sym_calc_value(e->left.sym); | ||
937 | sym_calc_value(e->right.sym); | ||
938 | str1 = sym_get_string_value(e->left.sym); | ||
939 | str2 = sym_get_string_value(e->right.sym); | ||
940 | return !strcmp(str1, str2) ? no : yes; | ||
941 | default: | ||
942 | printf("expr_calc_value: %d?\n", e->type); | ||
943 | return no; | ||
944 | } | ||
945 | } | ||
946 | |||
947 | int expr_compare_type(enum expr_type t1, enum expr_type t2) | ||
948 | { | ||
949 | #if 0 | ||
950 | return 1; | ||
951 | #else | ||
952 | if (t1 == t2) | ||
953 | return 0; | ||
954 | switch (t1) { | ||
955 | case E_EQUAL: | ||
956 | case E_UNEQUAL: | ||
957 | if (t2 == E_NOT) | ||
958 | return 1; | ||
959 | case E_NOT: | ||
960 | if (t2 == E_AND) | ||
961 | return 1; | ||
962 | case E_AND: | ||
963 | if (t2 == E_OR) | ||
964 | return 1; | ||
965 | case E_OR: | ||
966 | if (t2 == E_CHOICE) | ||
967 | return 1; | ||
968 | case E_CHOICE: | ||
969 | if (t2 == 0) | ||
970 | return 1; | ||
971 | default: | ||
972 | return -1; | ||
973 | } | ||
974 | printf("[%dgt%d?]", t1, t2); | ||
975 | return 0; | ||
976 | #endif | ||
977 | } | ||
978 | |||
979 | void expr_print(struct expr *e, void (*fn)(void *, const char *), void *data, int prevtoken) | ||
980 | { | ||
981 | if (!e) { | ||
982 | fn(data, "y"); | ||
983 | return; | ||
984 | } | ||
985 | |||
986 | if (expr_compare_type(prevtoken, e->type) > 0) | ||
987 | fn(data, "("); | ||
988 | switch (e->type) { | ||
989 | case E_SYMBOL: | ||
990 | if (e->left.sym->name) | ||
991 | fn(data, e->left.sym->name); | ||
992 | else | ||
993 | fn(data, "<choice>"); | ||
994 | break; | ||
995 | case E_NOT: | ||
996 | fn(data, "!"); | ||
997 | expr_print(e->left.expr, fn, data, E_NOT); | ||
998 | break; | ||
999 | case E_EQUAL: | ||
1000 | fn(data, e->left.sym->name); | ||
1001 | fn(data, "="); | ||
1002 | fn(data, e->right.sym->name); | ||
1003 | break; | ||
1004 | case E_UNEQUAL: | ||
1005 | fn(data, e->left.sym->name); | ||
1006 | fn(data, "!="); | ||
1007 | fn(data, e->right.sym->name); | ||
1008 | break; | ||
1009 | case E_OR: | ||
1010 | expr_print(e->left.expr, fn, data, E_OR); | ||
1011 | fn(data, " || "); | ||
1012 | expr_print(e->right.expr, fn, data, E_OR); | ||
1013 | break; | ||
1014 | case E_AND: | ||
1015 | expr_print(e->left.expr, fn, data, E_AND); | ||
1016 | fn(data, " && "); | ||
1017 | expr_print(e->right.expr, fn, data, E_AND); | ||
1018 | break; | ||
1019 | case E_CHOICE: | ||
1020 | if (e->left.expr) { | ||
1021 | expr_print(e->left.expr, fn, data, E_CHOICE); | ||
1022 | fn(data, " ^ "); | ||
1023 | } | ||
1024 | fn(data, e->right.sym->name); | ||
1025 | break; | ||
1026 | default: | ||
1027 | { | ||
1028 | char buf[32]; | ||
1029 | sprintf(buf, "<unknown type %d>", e->type); | ||
1030 | fn(data, buf); | ||
1031 | break; | ||
1032 | } | ||
1033 | } | ||
1034 | if (expr_compare_type(prevtoken, e->type) > 0) | ||
1035 | fn(data, ")"); | ||
1036 | } | ||
1037 | |||
1038 | static void expr_print_file_helper(void *data, const char *str) | ||
1039 | { | ||
1040 | fwrite(str, strlen(str), 1, data); | ||
1041 | } | ||
1042 | |||
1043 | void expr_fprint(struct expr *e, FILE *out) | ||
1044 | { | ||
1045 | expr_print(e, expr_print_file_helper, out, E_NONE); | ||
1046 | } | ||
1047 | |||
1048 | void print_expr(int mask, struct expr *e, int prevtoken) | ||
1049 | { | ||
1050 | if (!(cdebug & mask)) | ||
1051 | return; | ||
1052 | expr_fprint(e, stdout); | ||
1053 | } | ||
1054 | |||
diff --git a/scripts/config/expr.h b/scripts/config/expr.h new file mode 100644 index 000000000..e96d03b5a --- /dev/null +++ b/scripts/config/expr.h | |||
@@ -0,0 +1,242 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> | ||
3 | * Released under the terms of the GNU GPL v2.0. | ||
4 | */ | ||
5 | |||
6 | #ifndef EXPR_H | ||
7 | #define EXPR_H | ||
8 | |||
9 | #ifdef __cplusplus | ||
10 | extern "C" { | ||
11 | #endif | ||
12 | |||
13 | #include <stdio.h> | ||
14 | #ifndef __cplusplus | ||
15 | #include <stdbool.h> | ||
16 | #endif | ||
17 | |||
18 | struct file { | ||
19 | struct file *next; | ||
20 | struct file *parent; | ||
21 | #ifdef CML1 | ||
22 | struct statement *stmt; | ||
23 | struct statement *last_stmt; | ||
24 | #endif | ||
25 | char *name; | ||
26 | int lineno; | ||
27 | int flags; | ||
28 | }; | ||
29 | |||
30 | #define FILE_BUSY 0x0001 | ||
31 | #define FILE_SCANNED 0x0002 | ||
32 | #define FILE_PRINTED 0x0004 | ||
33 | |||
34 | typedef enum tristate { | ||
35 | no, mod, yes | ||
36 | } tristate; | ||
37 | |||
38 | enum expr_type { | ||
39 | E_NONE, E_OR, E_AND, E_NOT, E_EQUAL, E_UNEQUAL, E_CHOICE, E_SYMBOL | ||
40 | }; | ||
41 | |||
42 | union expr_data { | ||
43 | struct expr *expr; | ||
44 | struct symbol *sym; | ||
45 | }; | ||
46 | |||
47 | struct expr { | ||
48 | #ifdef CML1 | ||
49 | int token; | ||
50 | #else | ||
51 | enum expr_type type; | ||
52 | #endif | ||
53 | union expr_data left, right; | ||
54 | }; | ||
55 | |||
56 | #define E_TRI(ev) ((ev).tri) | ||
57 | #define E_EXPR(ev) ((ev).expr) | ||
58 | #define E_CALC(ev) (E_TRI(ev) = expr_calc_value(E_EXPR(ev))) | ||
59 | |||
60 | #define E_OR(dep1, dep2) (((dep1)>(dep2))?(dep1):(dep2)) | ||
61 | #define E_AND(dep1, dep2) (((dep1)<(dep2))?(dep1):(dep2)) | ||
62 | #define E_NOT(dep) (2-(dep)) | ||
63 | |||
64 | struct expr_value { | ||
65 | struct expr *expr; | ||
66 | tristate tri; | ||
67 | }; | ||
68 | |||
69 | #define S_VAL(sv) ((sv).value) | ||
70 | #define S_TRI(sv) ((sv).tri) | ||
71 | #define S_EQ(sv1, sv2) (S_VAL(sv1) == S_VAL(sv2) || !strcmp(S_VAL(sv1), S_VAL(sv2))) | ||
72 | |||
73 | struct symbol_value { | ||
74 | void *value; | ||
75 | tristate tri; | ||
76 | }; | ||
77 | |||
78 | enum symbol_type { | ||
79 | S_UNKNOWN, S_BOOLEAN, S_TRISTATE, S_INT, S_HEX, S_STRING, S_OTHER | ||
80 | }; | ||
81 | |||
82 | struct symbol { | ||
83 | struct symbol *next; | ||
84 | char *name; | ||
85 | char *help; | ||
86 | #ifdef CML1 | ||
87 | int type; | ||
88 | #else | ||
89 | enum symbol_type type; | ||
90 | #endif | ||
91 | struct symbol_value curr, def; | ||
92 | tristate visible; | ||
93 | int flags; | ||
94 | struct property *prop; | ||
95 | struct expr *dep, *dep2; | ||
96 | struct menu *menu; | ||
97 | }; | ||
98 | |||
99 | #define for_all_symbols(i, sym) for (i = 0; i < 257; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) if (sym->type != S_OTHER) | ||
100 | |||
101 | #ifdef CML1 | ||
102 | #define SYMBOL_UNKNOWN S_UNKNOWN | ||
103 | #define SYMBOL_BOOLEAN S_BOOLEAN | ||
104 | #define SYMBOL_TRISTATE S_TRISTATE | ||
105 | #define SYMBOL_INT S_INT | ||
106 | #define SYMBOL_HEX S_HEX | ||
107 | #define SYMBOL_STRING S_STRING | ||
108 | #define SYMBOL_OTHER S_OTHER | ||
109 | #endif | ||
110 | |||
111 | #define SYMBOL_YES 0x0001 | ||
112 | #define SYMBOL_MOD 0x0002 | ||
113 | #define SYMBOL_NO 0x0004 | ||
114 | #define SYMBOL_CONST 0x0007 | ||
115 | #define SYMBOL_CHECK 0x0008 | ||
116 | #define SYMBOL_CHOICE 0x0010 | ||
117 | #define SYMBOL_CHOICEVAL 0x0020 | ||
118 | #define SYMBOL_PRINTED 0x0040 | ||
119 | #define SYMBOL_VALID 0x0080 | ||
120 | #define SYMBOL_OPTIONAL 0x0100 | ||
121 | #define SYMBOL_WRITE 0x0200 | ||
122 | #define SYMBOL_CHANGED 0x0400 | ||
123 | #define SYMBOL_NEW 0x0800 | ||
124 | #define SYMBOL_AUTO 0x1000 | ||
125 | |||
126 | #define SYMBOL_MAXLENGTH 256 | ||
127 | #define SYMBOL_HASHSIZE 257 | ||
128 | #define SYMBOL_HASHMASK 0xff | ||
129 | |||
130 | enum prop_type { | ||
131 | P_UNKNOWN, P_PROMPT, P_COMMENT, P_MENU, P_ROOTMENU, P_DEFAULT, P_CHOICE | ||
132 | }; | ||
133 | |||
134 | struct property { | ||
135 | struct property *next; | ||
136 | struct symbol *sym; | ||
137 | #ifdef CML1 | ||
138 | int token; | ||
139 | #else | ||
140 | enum prop_type type; | ||
141 | #endif | ||
142 | const char *text; | ||
143 | struct symbol *def; | ||
144 | struct expr_value visible; | ||
145 | struct expr *dep; | ||
146 | struct expr *dep2; | ||
147 | struct menu *menu; | ||
148 | struct file *file; | ||
149 | int lineno; | ||
150 | #ifdef CML1 | ||
151 | struct property *next_pos; | ||
152 | #endif | ||
153 | }; | ||
154 | |||
155 | #define for_all_properties(sym, st, tok) \ | ||
156 | for (st = sym->prop; st; st = st->next) \ | ||
157 | if (st->type == (tok)) | ||
158 | #define for_all_prompts(sym, st) for_all_properties(sym, st, P_PROMPT) | ||
159 | #define for_all_defaults(sym, st) for_all_properties(sym, st, P_DEFAULT) | ||
160 | #define for_all_choices(sym, st) for_all_properties(sym, st, P_CHOICE) | ||
161 | |||
162 | struct menu { | ||
163 | struct menu *next; | ||
164 | struct menu *parent; | ||
165 | struct menu *list; | ||
166 | struct symbol *sym; | ||
167 | struct property *prompt; | ||
168 | struct expr *dep; | ||
169 | //char *help; | ||
170 | struct file *file; | ||
171 | int lineno; | ||
172 | void *data; | ||
173 | }; | ||
174 | |||
175 | #ifndef SWIG | ||
176 | |||
177 | extern struct file *file_list; | ||
178 | extern struct file *current_file; | ||
179 | struct file *lookup_file(const char *name); | ||
180 | |||
181 | extern struct symbol symbol_yes, symbol_no, symbol_mod; | ||
182 | extern struct symbol *modules_sym; | ||
183 | extern int cdebug; | ||
184 | extern int print_type; | ||
185 | struct expr *expr_alloc_symbol(struct symbol *sym); | ||
186 | #ifdef CML1 | ||
187 | struct expr *expr_alloc_one(int token, struct expr *ce); | ||
188 | struct expr *expr_alloc_two(int token, struct expr *e1, struct expr *e2); | ||
189 | struct expr *expr_alloc_comp(int token, struct symbol *s1, struct symbol *s2); | ||
190 | #else | ||
191 | struct expr *expr_alloc_one(enum expr_type type, struct expr *ce); | ||
192 | struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2); | ||
193 | struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2); | ||
194 | #endif | ||
195 | struct expr *expr_alloc_and(struct expr *e1, struct expr *e2); | ||
196 | struct expr *expr_copy(struct expr *org); | ||
197 | void expr_free(struct expr *e); | ||
198 | int expr_eq(struct expr *e1, struct expr *e2); | ||
199 | void expr_eliminate_eq(struct expr **ep1, struct expr **ep2); | ||
200 | tristate expr_calc_value(struct expr *e); | ||
201 | struct expr *expr_eliminate_yn(struct expr *e); | ||
202 | struct expr *expr_trans_bool(struct expr *e); | ||
203 | struct expr *expr_eliminate_dups(struct expr *e); | ||
204 | struct expr *expr_transform(struct expr *e); | ||
205 | int expr_contains_symbol(struct expr *dep, struct symbol *sym); | ||
206 | bool expr_depends_symbol(struct expr *dep, struct symbol *sym); | ||
207 | struct expr *expr_extract_eq_and(struct expr **ep1, struct expr **ep2); | ||
208 | struct expr *expr_extract_eq_or(struct expr **ep1, struct expr **ep2); | ||
209 | void expr_extract_eq(enum expr_type type, struct expr **ep, struct expr **ep1, struct expr **ep2); | ||
210 | struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym); | ||
211 | |||
212 | void expr_fprint(struct expr *e, FILE *out); | ||
213 | void print_expr(int mask, struct expr *e, int prevtoken); | ||
214 | |||
215 | #ifdef CML1 | ||
216 | static inline int expr_is_yes(struct expr *e) | ||
217 | { | ||
218 | return !e || (e->token == WORD && e->left.sym == &symbol_yes); | ||
219 | } | ||
220 | |||
221 | static inline int expr_is_no(struct expr *e) | ||
222 | { | ||
223 | return e && (e->token == WORD && e->left.sym == &symbol_no); | ||
224 | } | ||
225 | #else | ||
226 | static inline int expr_is_yes(struct expr *e) | ||
227 | { | ||
228 | return !e || (e->type == E_SYMBOL && e->left.sym == &symbol_yes); | ||
229 | } | ||
230 | |||
231 | static inline int expr_is_no(struct expr *e) | ||
232 | { | ||
233 | return e && (e->type == E_SYMBOL && e->left.sym == &symbol_no); | ||
234 | } | ||
235 | #endif | ||
236 | #endif | ||
237 | |||
238 | #ifdef __cplusplus | ||
239 | } | ||
240 | #endif | ||
241 | |||
242 | #endif /* EXPR_H */ | ||
diff --git a/scripts/config/inputbox.c b/scripts/config/inputbox.c new file mode 100644 index 000000000..fa7bebc69 --- /dev/null +++ b/scripts/config/inputbox.c | |||
@@ -0,0 +1,240 @@ | |||
1 | /* | ||
2 | * inputbox.c -- implements the input box | ||
3 | * | ||
4 | * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) | ||
5 | * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; either version 2 | ||
10 | * of the License, or (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | */ | ||
21 | |||
22 | #include "dialog.h" | ||
23 | |||
24 | unsigned char dialog_input_result[MAX_LEN + 1]; | ||
25 | |||
26 | /* | ||
27 | * Print the termination buttons | ||
28 | */ | ||
29 | static void | ||
30 | print_buttons(WINDOW *dialog, int height, int width, int selected) | ||
31 | { | ||
32 | int x = width / 2 - 11; | ||
33 | int y = height - 2; | ||
34 | |||
35 | print_button (dialog, " Ok ", y, x, selected==0); | ||
36 | print_button (dialog, " Help ", y, x + 14, selected==1); | ||
37 | |||
38 | wmove(dialog, y, x+1+14*selected); | ||
39 | wrefresh(dialog); | ||
40 | } | ||
41 | |||
42 | /* | ||
43 | * Display a dialog box for inputing a string | ||
44 | */ | ||
45 | int | ||
46 | dialog_inputbox (const char *title, const char *prompt, int height, int width, | ||
47 | const char *init) | ||
48 | { | ||
49 | int i, x, y, box_y, box_x, box_width; | ||
50 | int input_x = 0, scroll = 0, key = 0, button = -1; | ||
51 | unsigned char *instr = dialog_input_result; | ||
52 | WINDOW *dialog; | ||
53 | |||
54 | /* center dialog box on screen */ | ||
55 | x = (COLS - width) / 2; | ||
56 | y = (LINES - height) / 2; | ||
57 | |||
58 | |||
59 | draw_shadow (stdscr, y, x, height, width); | ||
60 | |||
61 | dialog = newwin (height, width, y, x); | ||
62 | keypad (dialog, TRUE); | ||
63 | |||
64 | draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr); | ||
65 | wattrset (dialog, border_attr); | ||
66 | mvwaddch (dialog, height-3, 0, ACS_LTEE); | ||
67 | for (i = 0; i < width - 2; i++) | ||
68 | waddch (dialog, ACS_HLINE); | ||
69 | wattrset (dialog, dialog_attr); | ||
70 | waddch (dialog, ACS_RTEE); | ||
71 | |||
72 | if (title != NULL && strlen(title) >= width-2 ) { | ||
73 | /* truncate long title -- mec */ | ||
74 | char * title2 = malloc(width-2+1); | ||
75 | memcpy( title2, title, width-2 ); | ||
76 | title2[width-2] = '\0'; | ||
77 | title = title2; | ||
78 | } | ||
79 | |||
80 | if (title != NULL) { | ||
81 | wattrset (dialog, title_attr); | ||
82 | mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' '); | ||
83 | waddstr (dialog, (char *)title); | ||
84 | waddch (dialog, ' '); | ||
85 | } | ||
86 | |||
87 | wattrset (dialog, dialog_attr); | ||
88 | print_autowrap (dialog, prompt, width - 2, 1, 3); | ||
89 | |||
90 | /* Draw the input field box */ | ||
91 | box_width = width - 6; | ||
92 | getyx (dialog, y, x); | ||
93 | box_y = y + 2; | ||
94 | box_x = (width - box_width) / 2; | ||
95 | draw_box (dialog, y + 1, box_x - 1, 3, box_width + 2, | ||
96 | border_attr, dialog_attr); | ||
97 | |||
98 | print_buttons(dialog, height, width, 0); | ||
99 | |||
100 | /* Set up the initial value */ | ||
101 | wmove (dialog, box_y, box_x); | ||
102 | wattrset (dialog, inputbox_attr); | ||
103 | |||
104 | if (!init) | ||
105 | instr[0] = '\0'; | ||
106 | else | ||
107 | strcpy (instr, init); | ||
108 | |||
109 | input_x = strlen (instr); | ||
110 | |||
111 | if (input_x >= box_width) { | ||
112 | scroll = input_x - box_width + 1; | ||
113 | input_x = box_width - 1; | ||
114 | for (i = 0; i < box_width - 1; i++) | ||
115 | waddch (dialog, instr[scroll + i]); | ||
116 | } else | ||
117 | waddstr (dialog, instr); | ||
118 | |||
119 | wmove (dialog, box_y, box_x + input_x); | ||
120 | |||
121 | wrefresh (dialog); | ||
122 | |||
123 | while (key != ESC) { | ||
124 | key = wgetch (dialog); | ||
125 | |||
126 | if (button == -1) { /* Input box selected */ | ||
127 | switch (key) { | ||
128 | case TAB: | ||
129 | case KEY_UP: | ||
130 | case KEY_DOWN: | ||
131 | break; | ||
132 | case KEY_LEFT: | ||
133 | continue; | ||
134 | case KEY_RIGHT: | ||
135 | continue; | ||
136 | case KEY_BACKSPACE: | ||
137 | case 127: | ||
138 | if (input_x || scroll) { | ||
139 | wattrset (dialog, inputbox_attr); | ||
140 | if (!input_x) { | ||
141 | scroll = scroll < box_width - 1 ? | ||
142 | 0 : scroll - (box_width - 1); | ||
143 | wmove (dialog, box_y, box_x); | ||
144 | for (i = 0; i < box_width; i++) | ||
145 | waddch (dialog, instr[scroll + input_x + i] ? | ||
146 | instr[scroll + input_x + i] : ' '); | ||
147 | input_x = strlen (instr) - scroll; | ||
148 | } else | ||
149 | input_x--; | ||
150 | instr[scroll + input_x] = '\0'; | ||
151 | mvwaddch (dialog, box_y, input_x + box_x, ' '); | ||
152 | wmove (dialog, box_y, input_x + box_x); | ||
153 | wrefresh (dialog); | ||
154 | } | ||
155 | continue; | ||
156 | default: | ||
157 | if (key < 0x100 && isprint (key)) { | ||
158 | if (scroll + input_x < MAX_LEN) { | ||
159 | wattrset (dialog, inputbox_attr); | ||
160 | instr[scroll + input_x] = key; | ||
161 | instr[scroll + input_x + 1] = '\0'; | ||
162 | if (input_x == box_width - 1) { | ||
163 | scroll++; | ||
164 | wmove (dialog, box_y, box_x); | ||
165 | for (i = 0; i < box_width - 1; i++) | ||
166 | waddch (dialog, instr[scroll + i]); | ||
167 | } else { | ||
168 | wmove (dialog, box_y, input_x++ + box_x); | ||
169 | waddch (dialog, key); | ||
170 | } | ||
171 | wrefresh (dialog); | ||
172 | } else | ||
173 | flash (); /* Alarm user about overflow */ | ||
174 | continue; | ||
175 | } | ||
176 | } | ||
177 | } | ||
178 | switch (key) { | ||
179 | case 'O': | ||
180 | case 'o': | ||
181 | delwin (dialog); | ||
182 | return 0; | ||
183 | case 'H': | ||
184 | case 'h': | ||
185 | delwin (dialog); | ||
186 | return 1; | ||
187 | case KEY_UP: | ||
188 | case KEY_LEFT: | ||
189 | switch (button) { | ||
190 | case -1: | ||
191 | button = 1; /* Indicates "Cancel" button is selected */ | ||
192 | print_buttons(dialog, height, width, 1); | ||
193 | break; | ||
194 | case 0: | ||
195 | button = -1; /* Indicates input box is selected */ | ||
196 | print_buttons(dialog, height, width, 0); | ||
197 | wmove (dialog, box_y, box_x + input_x); | ||
198 | wrefresh (dialog); | ||
199 | break; | ||
200 | case 1: | ||
201 | button = 0; /* Indicates "OK" button is selected */ | ||
202 | print_buttons(dialog, height, width, 0); | ||
203 | break; | ||
204 | } | ||
205 | break; | ||
206 | case TAB: | ||
207 | case KEY_DOWN: | ||
208 | case KEY_RIGHT: | ||
209 | switch (button) { | ||
210 | case -1: | ||
211 | button = 0; /* Indicates "OK" button is selected */ | ||
212 | print_buttons(dialog, height, width, 0); | ||
213 | break; | ||
214 | case 0: | ||
215 | button = 1; /* Indicates "Cancel" button is selected */ | ||
216 | print_buttons(dialog, height, width, 1); | ||
217 | break; | ||
218 | case 1: | ||
219 | button = -1; /* Indicates input box is selected */ | ||
220 | print_buttons(dialog, height, width, 0); | ||
221 | wmove (dialog, box_y, box_x + input_x); | ||
222 | wrefresh (dialog); | ||
223 | break; | ||
224 | } | ||
225 | break; | ||
226 | case ' ': | ||
227 | case '\n': | ||
228 | delwin (dialog); | ||
229 | return (button == -1 ? 0 : button); | ||
230 | case 'X': | ||
231 | case 'x': | ||
232 | key = ESC; | ||
233 | case ESC: | ||
234 | break; | ||
235 | } | ||
236 | } | ||
237 | |||
238 | delwin (dialog); | ||
239 | return -1; /* ESC pressed */ | ||
240 | } | ||
diff --git a/scripts/config/lex.zconf.c_shipped b/scripts/config/lex.zconf.c_shipped new file mode 100644 index 000000000..df102812f --- /dev/null +++ b/scripts/config/lex.zconf.c_shipped | |||
@@ -0,0 +1,3280 @@ | |||
1 | #define yy_create_buffer zconf_create_buffer | ||
2 | #define yy_delete_buffer zconf_delete_buffer | ||
3 | #define yy_scan_buffer zconf_scan_buffer | ||
4 | #define yy_scan_string zconf_scan_string | ||
5 | #define yy_scan_bytes zconf_scan_bytes | ||
6 | #define yy_flex_debug zconf_flex_debug | ||
7 | #define yy_init_buffer zconf_init_buffer | ||
8 | #define yy_flush_buffer zconf_flush_buffer | ||
9 | #define yy_load_buffer_state zconf_load_buffer_state | ||
10 | #define yy_switch_to_buffer zconf_switch_to_buffer | ||
11 | #define yyin zconfin | ||
12 | #define yyleng zconfleng | ||
13 | #define yylex zconflex | ||
14 | #define yyout zconfout | ||
15 | #define yyrestart zconfrestart | ||
16 | #define yytext zconftext | ||
17 | |||
18 | /* A lexical scanner generated by flex */ | ||
19 | |||
20 | /* Scanner skeleton version: | ||
21 | * $Header: /var/cvs/busybox/scripts/config/lex.zconf.c_shipped,v 1.1 2002/12/05 08:41:07 andersen Exp $ | ||
22 | */ | ||
23 | |||
24 | #define FLEX_SCANNER | ||
25 | #define YY_FLEX_MAJOR_VERSION 2 | ||
26 | #define YY_FLEX_MINOR_VERSION 5 | ||
27 | |||
28 | #include <stdio.h> | ||
29 | #include <errno.h> | ||
30 | |||
31 | /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ | ||
32 | #ifdef c_plusplus | ||
33 | #ifndef __cplusplus | ||
34 | #define __cplusplus | ||
35 | #endif | ||
36 | #endif | ||
37 | |||
38 | |||
39 | #ifdef __cplusplus | ||
40 | |||
41 | #include <stdlib.h> | ||
42 | #ifndef _WIN32 | ||
43 | #include <unistd.h> | ||
44 | #endif | ||
45 | |||
46 | /* Use prototypes in function declarations. */ | ||
47 | #define YY_USE_PROTOS | ||
48 | |||
49 | /* The "const" storage-class-modifier is valid. */ | ||
50 | #define YY_USE_CONST | ||
51 | |||
52 | #else /* ! __cplusplus */ | ||
53 | |||
54 | #if __STDC__ | ||
55 | |||
56 | #define YY_USE_PROTOS | ||
57 | #define YY_USE_CONST | ||
58 | |||
59 | #endif /* __STDC__ */ | ||
60 | #endif /* ! __cplusplus */ | ||
61 | |||
62 | #ifdef __TURBOC__ | ||
63 | #pragma warn -rch | ||
64 | #pragma warn -use | ||
65 | #include <io.h> | ||
66 | #include <stdlib.h> | ||
67 | #define YY_USE_CONST | ||
68 | #define YY_USE_PROTOS | ||
69 | #endif | ||
70 | |||
71 | #ifdef YY_USE_CONST | ||
72 | #define yyconst const | ||
73 | #else | ||
74 | #define yyconst | ||
75 | #endif | ||
76 | |||
77 | |||
78 | #ifdef YY_USE_PROTOS | ||
79 | #define YY_PROTO(proto) proto | ||
80 | #else | ||
81 | #define YY_PROTO(proto) () | ||
82 | #endif | ||
83 | |||
84 | /* Returned upon end-of-file. */ | ||
85 | #define YY_NULL 0 | ||
86 | |||
87 | /* Promotes a possibly negative, possibly signed char to an unsigned | ||
88 | * integer for use as an array index. If the signed char is negative, | ||
89 | * we want to instead treat it as an 8-bit unsigned char, hence the | ||
90 | * double cast. | ||
91 | */ | ||
92 | #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) | ||
93 | |||
94 | /* Enter a start condition. This macro really ought to take a parameter, | ||
95 | * but we do it the disgusting crufty way forced on us by the ()-less | ||
96 | * definition of BEGIN. | ||
97 | */ | ||
98 | #define BEGIN yy_start = 1 + 2 * | ||
99 | |||
100 | /* Translate the current start state into a value that can be later handed | ||
101 | * to BEGIN to return to the state. The YYSTATE alias is for lex | ||
102 | * compatibility. | ||
103 | */ | ||
104 | #define YY_START ((yy_start - 1) / 2) | ||
105 | #define YYSTATE YY_START | ||
106 | |||
107 | /* Action number for EOF rule of a given start state. */ | ||
108 | #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) | ||
109 | |||
110 | /* Special action meaning "start processing a new file". */ | ||
111 | #define YY_NEW_FILE yyrestart( yyin ) | ||
112 | |||
113 | #define YY_END_OF_BUFFER_CHAR 0 | ||
114 | |||
115 | /* Size of default input buffer. */ | ||
116 | #define YY_BUF_SIZE 16384 | ||
117 | |||
118 | typedef struct yy_buffer_state *YY_BUFFER_STATE; | ||
119 | |||
120 | extern int yyleng; | ||
121 | extern FILE *yyin, *yyout; | ||
122 | |||
123 | #define EOB_ACT_CONTINUE_SCAN 0 | ||
124 | #define EOB_ACT_END_OF_FILE 1 | ||
125 | #define EOB_ACT_LAST_MATCH 2 | ||
126 | |||
127 | /* The funky do-while in the following #define is used to turn the definition | ||
128 | * int a single C statement (which needs a semi-colon terminator). This | ||
129 | * avoids problems with code like: | ||
130 | * | ||
131 | * if ( condition_holds ) | ||
132 | * yyless( 5 ); | ||
133 | * else | ||
134 | * do_something_else(); | ||
135 | * | ||
136 | * Prior to using the do-while the compiler would get upset at the | ||
137 | * "else" because it interpreted the "if" statement as being all | ||
138 | * done when it reached the ';' after the yyless() call. | ||
139 | */ | ||
140 | |||
141 | /* Return all but the first 'n' matched characters back to the input stream. */ | ||
142 | |||
143 | #define yyless(n) \ | ||
144 | do \ | ||
145 | { \ | ||
146 | /* Undo effects of setting up yytext. */ \ | ||
147 | *yy_cp = yy_hold_char; \ | ||
148 | YY_RESTORE_YY_MORE_OFFSET \ | ||
149 | yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ | ||
150 | YY_DO_BEFORE_ACTION; /* set up yytext again */ \ | ||
151 | } \ | ||
152 | while ( 0 ) | ||
153 | |||
154 | #define unput(c) yyunput( c, yytext_ptr ) | ||
155 | |||
156 | /* The following is because we cannot portably get our hands on size_t | ||
157 | * (without autoconf's help, which isn't available because we want | ||
158 | * flex-generated scanners to compile on their own). | ||
159 | */ | ||
160 | typedef unsigned int yy_size_t; | ||
161 | |||
162 | |||
163 | struct yy_buffer_state | ||
164 | { | ||
165 | FILE *yy_input_file; | ||
166 | |||
167 | char *yy_ch_buf; /* input buffer */ | ||
168 | char *yy_buf_pos; /* current position in input buffer */ | ||
169 | |||
170 | /* Size of input buffer in bytes, not including room for EOB | ||
171 | * characters. | ||
172 | */ | ||
173 | yy_size_t yy_buf_size; | ||
174 | |||
175 | /* Number of characters read into yy_ch_buf, not including EOB | ||
176 | * characters. | ||
177 | */ | ||
178 | int yy_n_chars; | ||
179 | |||
180 | /* Whether we "own" the buffer - i.e., we know we created it, | ||
181 | * and can realloc() it to grow it, and should free() it to | ||
182 | * delete it. | ||
183 | */ | ||
184 | int yy_is_our_buffer; | ||
185 | |||
186 | /* Whether this is an "interactive" input source; if so, and | ||
187 | * if we're using stdio for input, then we want to use getc() | ||
188 | * instead of fread(), to make sure we stop fetching input after | ||
189 | * each newline. | ||
190 | */ | ||
191 | int yy_is_interactive; | ||
192 | |||
193 | /* Whether we're considered to be at the beginning of a line. | ||
194 | * If so, '^' rules will be active on the next match, otherwise | ||
195 | * not. | ||
196 | */ | ||
197 | int yy_at_bol; | ||
198 | |||
199 | /* Whether to try to fill the input buffer when we reach the | ||
200 | * end of it. | ||
201 | */ | ||
202 | int yy_fill_buffer; | ||
203 | |||
204 | int yy_buffer_status; | ||
205 | #define YY_BUFFER_NEW 0 | ||
206 | #define YY_BUFFER_NORMAL 1 | ||
207 | /* When an EOF's been seen but there's still some text to process | ||
208 | * then we mark the buffer as YY_EOF_PENDING, to indicate that we | ||
209 | * shouldn't try reading from the input source any more. We might | ||
210 | * still have a bunch of tokens to match, though, because of | ||
211 | * possible backing-up. | ||
212 | * | ||
213 | * When we actually see the EOF, we change the status to "new" | ||
214 | * (via yyrestart()), so that the user can continue scanning by | ||
215 | * just pointing yyin at a new input file. | ||
216 | */ | ||
217 | #define YY_BUFFER_EOF_PENDING 2 | ||
218 | }; | ||
219 | |||
220 | static YY_BUFFER_STATE yy_current_buffer = 0; | ||
221 | |||
222 | /* We provide macros for accessing buffer states in case in the | ||
223 | * future we want to put the buffer states in a more general | ||
224 | * "scanner state". | ||
225 | */ | ||
226 | #define YY_CURRENT_BUFFER yy_current_buffer | ||
227 | |||
228 | |||
229 | /* yy_hold_char holds the character lost when yytext is formed. */ | ||
230 | static char yy_hold_char; | ||
231 | |||
232 | static int yy_n_chars; /* number of characters read into yy_ch_buf */ | ||
233 | |||
234 | |||
235 | int yyleng; | ||
236 | |||
237 | /* Points to current character in buffer. */ | ||
238 | static char *yy_c_buf_p = (char *) 0; | ||
239 | static int yy_init = 1; /* whether we need to initialize */ | ||
240 | static int yy_start = 0; /* start state number */ | ||
241 | |||
242 | /* Flag which is used to allow yywrap()'s to do buffer switches | ||
243 | * instead of setting up a fresh yyin. A bit of a hack ... | ||
244 | */ | ||
245 | static int yy_did_buffer_switch_on_eof; | ||
246 | |||
247 | void yyrestart YY_PROTO(( FILE *input_file )); | ||
248 | |||
249 | void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); | ||
250 | void yy_load_buffer_state YY_PROTO(( void )); | ||
251 | YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); | ||
252 | void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); | ||
253 | void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); | ||
254 | void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); | ||
255 | #define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) | ||
256 | |||
257 | YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); | ||
258 | YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); | ||
259 | YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); | ||
260 | |||
261 | static void *yy_flex_alloc YY_PROTO(( yy_size_t )); | ||
262 | static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); | ||
263 | static void yy_flex_free YY_PROTO(( void * )); | ||
264 | |||
265 | #define yy_new_buffer yy_create_buffer | ||
266 | |||
267 | #define yy_set_interactive(is_interactive) \ | ||
268 | { \ | ||
269 | if ( ! yy_current_buffer ) \ | ||
270 | yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ | ||
271 | yy_current_buffer->yy_is_interactive = is_interactive; \ | ||
272 | } | ||
273 | |||
274 | #define yy_set_bol(at_bol) \ | ||
275 | { \ | ||
276 | if ( ! yy_current_buffer ) \ | ||
277 | yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ | ||
278 | yy_current_buffer->yy_at_bol = at_bol; \ | ||
279 | } | ||
280 | |||
281 | #define YY_AT_BOL() (yy_current_buffer->yy_at_bol) | ||
282 | |||
283 | |||
284 | #define yywrap() 1 | ||
285 | #define YY_SKIP_YYWRAP | ||
286 | typedef unsigned char YY_CHAR; | ||
287 | FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; | ||
288 | typedef int yy_state_type; | ||
289 | extern char *yytext; | ||
290 | #define yytext_ptr yytext | ||
291 | static yyconst short yy_nxt[][37] = | ||
292 | { | ||
293 | { | ||
294 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
295 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
296 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
297 | 0, 0, 0, 0, 0, 0, 0 | ||
298 | }, | ||
299 | |||
300 | { | ||
301 | 11, 12, 13, 14, 12, 12, 15, 12, 12, 12, | ||
302 | 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, | ||
303 | 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, | ||
304 | 12, 12, 12, 12, 12, 12, 12 | ||
305 | }, | ||
306 | |||
307 | { | ||
308 | 11, 12, 13, 14, 12, 12, 15, 12, 12, 12, | ||
309 | 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, | ||
310 | |||
311 | 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, | ||
312 | 12, 12, 12, 12, 12, 12, 12 | ||
313 | }, | ||
314 | |||
315 | { | ||
316 | 11, 16, 16, 17, 16, 16, 16, 16, 16, 16, | ||
317 | 16, 16, 16, 18, 16, 16, 18, 19, 20, 21, | ||
318 | 22, 18, 18, 23, 24, 18, 25, 18, 26, 27, | ||
319 | 18, 28, 29, 30, 18, 18, 16 | ||
320 | }, | ||
321 | |||
322 | { | ||
323 | 11, 16, 16, 17, 16, 16, 16, 16, 16, 16, | ||
324 | 16, 16, 16, 18, 16, 16, 18, 19, 20, 21, | ||
325 | 22, 18, 18, 23, 24, 18, 25, 18, 26, 27, | ||
326 | 18, 28, 29, 30, 18, 18, 16 | ||
327 | |||
328 | }, | ||
329 | |||
330 | { | ||
331 | 11, 31, 32, 33, 31, 31, 31, 31, 31, 31, | ||
332 | 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, | ||
333 | 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, | ||
334 | 31, 31, 31, 31, 31, 31, 31 | ||
335 | }, | ||
336 | |||
337 | { | ||
338 | 11, 31, 32, 33, 31, 31, 31, 31, 31, 31, | ||
339 | 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, | ||
340 | 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, | ||
341 | 31, 31, 31, 31, 31, 31, 31 | ||
342 | }, | ||
343 | |||
344 | { | ||
345 | 11, 34, 34, 35, 34, 36, 34, 34, 36, 34, | ||
346 | 34, 34, 34, 34, 34, 37, 34, 34, 34, 34, | ||
347 | |||
348 | 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, | ||
349 | 34, 34, 34, 34, 34, 34, 34 | ||
350 | }, | ||
351 | |||
352 | { | ||
353 | 11, 34, 34, 35, 34, 36, 34, 34, 36, 34, | ||
354 | 34, 34, 34, 34, 34, 37, 34, 34, 34, 34, | ||
355 | 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, | ||
356 | 34, 34, 34, 34, 34, 34, 34 | ||
357 | }, | ||
358 | |||
359 | { | ||
360 | 11, 38, 38, 39, 40, 41, 38, 42, 41, 43, | ||
361 | 44, 45, 46, 46, 47, 38, 46, 46, 46, 46, | ||
362 | 46, 46, 46, 46, 48, 46, 46, 46, 49, 46, | ||
363 | 46, 46, 46, 46, 46, 46, 50 | ||
364 | |||
365 | }, | ||
366 | |||
367 | { | ||
368 | 11, 38, 38, 39, 40, 41, 38, 42, 41, 43, | ||
369 | 44, 45, 46, 46, 47, 38, 46, 46, 46, 46, | ||
370 | 46, 46, 46, 46, 48, 46, 46, 46, 49, 46, | ||
371 | 46, 46, 46, 46, 46, 46, 50 | ||
372 | }, | ||
373 | |||
374 | { | ||
375 | -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, | ||
376 | -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, | ||
377 | -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, | ||
378 | -11, -11, -11, -11, -11, -11, -11 | ||
379 | }, | ||
380 | |||
381 | { | ||
382 | 11, -12, -12, -12, -12, -12, -12, -12, -12, -12, | ||
383 | -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, | ||
384 | |||
385 | -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, | ||
386 | -12, -12, -12, -12, -12, -12, -12 | ||
387 | }, | ||
388 | |||
389 | { | ||
390 | 11, -13, 51, 52, -13, -13, 53, -13, -13, -13, | ||
391 | -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, | ||
392 | -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, | ||
393 | -13, -13, -13, -13, -13, -13, -13 | ||
394 | }, | ||
395 | |||
396 | { | ||
397 | 11, -14, -14, -14, -14, -14, -14, -14, -14, -14, | ||
398 | -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, | ||
399 | -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, | ||
400 | -14, -14, -14, -14, -14, -14, -14 | ||
401 | |||
402 | }, | ||
403 | |||
404 | { | ||
405 | 11, 54, 54, 55, 54, 54, 54, 54, 54, 54, | ||
406 | 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, | ||
407 | 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, | ||
408 | 54, 54, 54, 54, 54, 54, 54 | ||
409 | }, | ||
410 | |||
411 | { | ||
412 | 11, -16, -16, -16, -16, -16, -16, -16, -16, -16, | ||
413 | -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, | ||
414 | -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, | ||
415 | -16, -16, -16, -16, -16, -16, -16 | ||
416 | }, | ||
417 | |||
418 | { | ||
419 | 11, -17, -17, -17, -17, -17, -17, -17, -17, -17, | ||
420 | -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, | ||
421 | |||
422 | -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, | ||
423 | -17, -17, -17, -17, -17, -17, -17 | ||
424 | }, | ||
425 | |||
426 | { | ||
427 | 11, -18, -18, -18, -18, -18, -18, -18, -18, -18, | ||
428 | -18, -18, -18, 56, -18, -18, 56, 56, 56, 56, | ||
429 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
430 | 56, 56, 56, 56, 56, 56, -18 | ||
431 | }, | ||
432 | |||
433 | { | ||
434 | 11, -19, -19, -19, -19, -19, -19, -19, -19, -19, | ||
435 | -19, -19, -19, 56, -19, -19, 56, 56, 56, 56, | ||
436 | 56, 56, 56, 56, 56, 56, 56, 56, 57, 56, | ||
437 | 56, 56, 56, 56, 56, 56, -19 | ||
438 | |||
439 | }, | ||
440 | |||
441 | { | ||
442 | 11, -20, -20, -20, -20, -20, -20, -20, -20, -20, | ||
443 | -20, -20, -20, 56, -20, -20, 56, 56, 56, 56, | ||
444 | 56, 56, 56, 58, 56, 56, 56, 56, 59, 56, | ||
445 | 56, 56, 56, 56, 56, 56, -20 | ||
446 | }, | ||
447 | |||
448 | { | ||
449 | 11, -21, -21, -21, -21, -21, -21, -21, -21, -21, | ||
450 | -21, -21, -21, 56, -21, -21, 56, 56, 56, 56, | ||
451 | 60, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
452 | 56, 56, 56, 56, 56, 56, -21 | ||
453 | }, | ||
454 | |||
455 | { | ||
456 | 11, -22, -22, -22, -22, -22, -22, -22, -22, -22, | ||
457 | -22, -22, -22, 56, -22, -22, 56, 56, 56, 56, | ||
458 | |||
459 | 56, 56, 56, 56, 56, 56, 56, 61, 56, 56, | ||
460 | 56, 56, 56, 56, 56, 56, -22 | ||
461 | }, | ||
462 | |||
463 | { | ||
464 | 11, -23, -23, -23, -23, -23, -23, -23, -23, -23, | ||
465 | -23, -23, -23, 56, -23, -23, 56, 56, 56, 56, | ||
466 | 62, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
467 | 56, 56, 56, 56, 56, 56, -23 | ||
468 | }, | ||
469 | |||
470 | { | ||
471 | 11, -24, -24, -24, -24, -24, -24, -24, -24, -24, | ||
472 | -24, -24, -24, 56, -24, -24, 56, 56, 56, 56, | ||
473 | 56, 63, 56, 56, 56, 56, 56, 64, 56, 56, | ||
474 | 56, 56, 56, 56, 56, 56, -24 | ||
475 | |||
476 | }, | ||
477 | |||
478 | { | ||
479 | 11, -25, -25, -25, -25, -25, -25, -25, -25, -25, | ||
480 | -25, -25, -25, 56, -25, -25, 65, 56, 56, 56, | ||
481 | 66, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
482 | 56, 56, 56, 56, 56, 56, -25 | ||
483 | }, | ||
484 | |||
485 | { | ||
486 | 11, -26, -26, -26, -26, -26, -26, -26, -26, -26, | ||
487 | -26, -26, -26, 56, -26, -26, 56, 56, 56, 56, | ||
488 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 67, | ||
489 | 56, 56, 56, 56, 56, 56, -26 | ||
490 | }, | ||
491 | |||
492 | { | ||
493 | 11, -27, -27, -27, -27, -27, -27, -27, -27, -27, | ||
494 | -27, -27, -27, 56, -27, -27, 56, 56, 56, 56, | ||
495 | |||
496 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
497 | 56, 68, 56, 56, 56, 56, -27 | ||
498 | }, | ||
499 | |||
500 | { | ||
501 | 11, -28, -28, -28, -28, -28, -28, -28, -28, -28, | ||
502 | -28, -28, -28, 56, -28, -28, 56, 56, 56, 56, | ||
503 | 69, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
504 | 56, 56, 56, 56, 56, 56, -28 | ||
505 | }, | ||
506 | |||
507 | { | ||
508 | 11, -29, -29, -29, -29, -29, -29, -29, -29, -29, | ||
509 | -29, -29, -29, 56, -29, -29, 56, 56, 56, 56, | ||
510 | 56, 56, 56, 56, 56, 56, 56, 56, 70, 56, | ||
511 | 56, 56, 56, 71, 56, 56, -29 | ||
512 | |||
513 | }, | ||
514 | |||
515 | { | ||
516 | 11, -30, -30, -30, -30, -30, -30, -30, -30, -30, | ||
517 | -30, -30, -30, 56, -30, -30, 56, 56, 56, 56, | ||
518 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
519 | 56, 72, 56, 56, 56, 56, -30 | ||
520 | }, | ||
521 | |||
522 | { | ||
523 | 11, 73, 73, -31, 73, 73, 73, 73, 73, 73, | ||
524 | 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, | ||
525 | 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, | ||
526 | 73, 73, 73, 73, 73, 73, 73 | ||
527 | }, | ||
528 | |||
529 | { | ||
530 | 11, -32, 74, 75, -32, -32, -32, -32, -32, -32, | ||
531 | -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, | ||
532 | |||
533 | -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, | ||
534 | -32, -32, -32, -32, -32, -32, -32 | ||
535 | }, | ||
536 | |||
537 | { | ||
538 | 11, 76, -33, -33, 76, 76, 76, 76, 76, 76, | ||
539 | 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, | ||
540 | 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, | ||
541 | 76, 76, 76, 76, 76, 76, 76 | ||
542 | }, | ||
543 | |||
544 | { | ||
545 | 11, 77, 77, 78, 77, -34, 77, 77, -34, 77, | ||
546 | 77, 77, 77, 77, 77, -34, 77, 77, 77, 77, | ||
547 | 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, | ||
548 | 77, 77, 77, 77, 77, 77, 77 | ||
549 | |||
550 | }, | ||
551 | |||
552 | { | ||
553 | 11, -35, -35, -35, -35, -35, -35, -35, -35, -35, | ||
554 | -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, | ||
555 | -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, | ||
556 | -35, -35, -35, -35, -35, -35, -35 | ||
557 | }, | ||
558 | |||
559 | { | ||
560 | 11, -36, -36, -36, -36, -36, -36, -36, -36, -36, | ||
561 | -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, | ||
562 | -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, | ||
563 | -36, -36, -36, -36, -36, -36, -36 | ||
564 | }, | ||
565 | |||
566 | { | ||
567 | 11, 79, 79, 80, 79, 79, 79, 79, 79, 79, | ||
568 | 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, | ||
569 | |||
570 | 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, | ||
571 | 79, 79, 79, 79, 79, 79, 79 | ||
572 | }, | ||
573 | |||
574 | { | ||
575 | 11, -38, -38, -38, -38, -38, -38, -38, -38, -38, | ||
576 | -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, | ||
577 | -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, | ||
578 | -38, -38, -38, -38, -38, -38, -38 | ||
579 | }, | ||
580 | |||
581 | { | ||
582 | 11, -39, -39, -39, -39, -39, -39, -39, -39, -39, | ||
583 | -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, | ||
584 | -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, | ||
585 | -39, -39, -39, -39, -39, -39, -39 | ||
586 | |||
587 | }, | ||
588 | |||
589 | { | ||
590 | 11, -40, -40, -40, -40, -40, -40, -40, -40, -40, | ||
591 | -40, -40, -40, -40, 81, -40, -40, -40, -40, -40, | ||
592 | -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, | ||
593 | -40, -40, -40, -40, -40, -40, -40 | ||
594 | }, | ||
595 | |||
596 | { | ||
597 | 11, -41, -41, -41, -41, -41, -41, -41, -41, -41, | ||
598 | -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, | ||
599 | -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, | ||
600 | -41, -41, -41, -41, -41, -41, -41 | ||
601 | }, | ||
602 | |||
603 | { | ||
604 | 11, -42, -42, -42, -42, -42, -42, 82, -42, -42, | ||
605 | -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, | ||
606 | |||
607 | -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, | ||
608 | -42, -42, -42, -42, -42, -42, -42 | ||
609 | }, | ||
610 | |||
611 | { | ||
612 | 11, -43, -43, -43, -43, -43, -43, -43, -43, -43, | ||
613 | -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, | ||
614 | -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, | ||
615 | -43, -43, -43, -43, -43, -43, -43 | ||
616 | }, | ||
617 | |||
618 | { | ||
619 | 11, -44, -44, -44, -44, -44, -44, -44, -44, -44, | ||
620 | -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, | ||
621 | -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, | ||
622 | -44, -44, -44, -44, -44, -44, -44 | ||
623 | |||
624 | }, | ||
625 | |||
626 | { | ||
627 | 11, -45, -45, -45, -45, -45, -45, -45, -45, -45, | ||
628 | -45, 83, 84, 84, -45, -45, 84, 84, 84, 84, | ||
629 | 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, | ||
630 | 84, 84, 84, 84, 84, 84, -45 | ||
631 | }, | ||
632 | |||
633 | { | ||
634 | 11, -46, -46, -46, -46, -46, -46, -46, -46, -46, | ||
635 | -46, 84, 84, 84, -46, -46, 84, 84, 84, 84, | ||
636 | 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, | ||
637 | 84, 84, 84, 84, 84, 84, -46 | ||
638 | }, | ||
639 | |||
640 | { | ||
641 | 11, -47, -47, -47, -47, -47, -47, -47, -47, -47, | ||
642 | -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, | ||
643 | |||
644 | -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, | ||
645 | -47, -47, -47, -47, -47, -47, -47 | ||
646 | }, | ||
647 | |||
648 | { | ||
649 | 11, -48, -48, -48, -48, -48, -48, -48, -48, -48, | ||
650 | -48, 84, 84, 84, -48, -48, 84, 84, 84, 84, | ||
651 | 84, 85, 84, 84, 84, 84, 84, 84, 84, 84, | ||
652 | 84, 84, 84, 84, 84, 84, -48 | ||
653 | }, | ||
654 | |||
655 | { | ||
656 | 11, -49, -49, -49, -49, -49, -49, -49, -49, -49, | ||
657 | -49, 84, 84, 84, -49, -49, 84, 84, 84, 84, | ||
658 | 84, 84, 84, 84, 84, 84, 84, 86, 84, 84, | ||
659 | 84, 84, 84, 84, 84, 84, -49 | ||
660 | |||
661 | }, | ||
662 | |||
663 | { | ||
664 | 11, -50, -50, -50, -50, -50, -50, -50, -50, -50, | ||
665 | -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, | ||
666 | -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, | ||
667 | -50, -50, -50, -50, -50, -50, 87 | ||
668 | }, | ||
669 | |||
670 | { | ||
671 | 11, -51, 51, 52, -51, -51, 53, -51, -51, -51, | ||
672 | -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, | ||
673 | -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, | ||
674 | -51, -51, -51, -51, -51, -51, -51 | ||
675 | }, | ||
676 | |||
677 | { | ||
678 | 11, -52, -52, -52, -52, -52, -52, -52, -52, -52, | ||
679 | -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, | ||
680 | |||
681 | -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, | ||
682 | -52, -52, -52, -52, -52, -52, -52 | ||
683 | }, | ||
684 | |||
685 | { | ||
686 | 11, 54, 54, 55, 54, 54, 54, 54, 54, 54, | ||
687 | 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, | ||
688 | 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, | ||
689 | 54, 54, 54, 54, 54, 54, 54 | ||
690 | }, | ||
691 | |||
692 | { | ||
693 | 11, 54, 54, 55, 54, 54, 54, 54, 54, 54, | ||
694 | 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, | ||
695 | 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, | ||
696 | 54, 54, 54, 54, 54, 54, 54 | ||
697 | |||
698 | }, | ||
699 | |||
700 | { | ||
701 | 11, -55, -55, -55, -55, -55, -55, -55, -55, -55, | ||
702 | -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, | ||
703 | -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, | ||
704 | -55, -55, -55, -55, -55, -55, -55 | ||
705 | }, | ||
706 | |||
707 | { | ||
708 | 11, -56, -56, -56, -56, -56, -56, -56, -56, -56, | ||
709 | -56, -56, -56, 56, -56, -56, 56, 56, 56, 56, | ||
710 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
711 | 56, 56, 56, 56, 56, 56, -56 | ||
712 | }, | ||
713 | |||
714 | { | ||
715 | 11, -57, -57, -57, -57, -57, -57, -57, -57, -57, | ||
716 | -57, -57, -57, 56, -57, -57, 56, 56, 56, 56, | ||
717 | |||
718 | 56, 56, 56, 56, 56, 56, 56, 56, 88, 56, | ||
719 | 56, 56, 56, 56, 56, 56, -57 | ||
720 | }, | ||
721 | |||
722 | { | ||
723 | 11, -58, -58, -58, -58, -58, -58, -58, -58, -58, | ||
724 | -58, -58, -58, 56, -58, -58, 56, 56, 56, 56, | ||
725 | 56, 56, 56, 56, 56, 56, 56, 56, 89, 56, | ||
726 | 56, 56, 56, 56, 56, 56, -58 | ||
727 | }, | ||
728 | |||
729 | { | ||
730 | 11, -59, -59, -59, -59, -59, -59, -59, -59, -59, | ||
731 | -59, -59, -59, 56, -59, -59, 56, 56, 56, 56, | ||
732 | 56, 56, 56, 56, 56, 56, 90, 91, 56, 56, | ||
733 | 56, 56, 56, 56, 56, 56, -59 | ||
734 | |||
735 | }, | ||
736 | |||
737 | { | ||
738 | 11, -60, -60, -60, -60, -60, -60, -60, -60, -60, | ||
739 | -60, -60, -60, 56, -60, -60, 56, 56, 56, 56, | ||
740 | 56, 92, 56, 56, 56, 56, 56, 56, 56, 93, | ||
741 | 56, 56, 56, 56, 56, 56, -60 | ||
742 | }, | ||
743 | |||
744 | { | ||
745 | 11, -61, -61, -61, -61, -61, -61, -61, -61, -61, | ||
746 | -61, -61, -61, 56, -61, -61, 56, 56, 56, 94, | ||
747 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
748 | 56, 56, 56, 56, 56, 56, -61 | ||
749 | }, | ||
750 | |||
751 | { | ||
752 | 11, -62, -62, -62, -62, -62, -62, -62, -62, -62, | ||
753 | -62, -62, -62, 56, -62, -62, 56, 56, 56, 56, | ||
754 | |||
755 | 56, 56, 56, 56, 56, 95, 56, 56, 56, 56, | ||
756 | 56, 56, 56, 56, 56, 96, -62 | ||
757 | }, | ||
758 | |||
759 | { | ||
760 | 11, -63, -63, -63, -63, -63, -63, -63, -63, -63, | ||
761 | -63, -63, -63, 56, -63, -63, 56, 56, 56, 56, | ||
762 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
763 | 56, 56, 56, 56, 56, 56, -63 | ||
764 | }, | ||
765 | |||
766 | { | ||
767 | 11, -64, -64, -64, -64, -64, -64, -64, -64, -64, | ||
768 | -64, -64, -64, 56, -64, -64, 56, 56, 56, 56, | ||
769 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
770 | 56, 56, 56, 97, 56, 56, -64 | ||
771 | |||
772 | }, | ||
773 | |||
774 | { | ||
775 | 11, -65, -65, -65, -65, -65, -65, -65, -65, -65, | ||
776 | -65, -65, -65, 56, -65, -65, 56, 56, 56, 56, | ||
777 | 56, 56, 56, 56, 98, 56, 56, 56, 56, 56, | ||
778 | 56, 56, 56, 56, 56, 56, -65 | ||
779 | }, | ||
780 | |||
781 | { | ||
782 | 11, -66, -66, -66, -66, -66, -66, -66, -66, -66, | ||
783 | -66, -66, -66, 56, -66, -66, 56, 56, 56, 56, | ||
784 | 56, 56, 56, 56, 56, 56, 56, 99, 56, 56, | ||
785 | 56, 56, 56, 56, 56, 56, -66 | ||
786 | }, | ||
787 | |||
788 | { | ||
789 | 11, -67, -67, -67, -67, -67, -67, -67, -67, -67, | ||
790 | -67, -67, -67, 56, -67, -67, 56, 56, 56, 56, | ||
791 | |||
792 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
793 | 56, 56, 56, 100, 56, 56, -67 | ||
794 | }, | ||
795 | |||
796 | { | ||
797 | 11, -68, -68, -68, -68, -68, -68, -68, -68, -68, | ||
798 | -68, -68, -68, 56, -68, -68, 56, 56, 56, 56, | ||
799 | 56, 56, 56, 56, 56, 56, 56, 56, 101, 56, | ||
800 | 56, 56, 56, 56, 56, 56, -68 | ||
801 | }, | ||
802 | |||
803 | { | ||
804 | 11, -69, -69, -69, -69, -69, -69, -69, -69, -69, | ||
805 | -69, -69, -69, 56, -69, -69, 56, 56, 56, 56, | ||
806 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
807 | 102, 56, 56, 56, 56, 56, -69 | ||
808 | |||
809 | }, | ||
810 | |||
811 | { | ||
812 | 11, -70, -70, -70, -70, -70, -70, -70, -70, -70, | ||
813 | -70, -70, -70, 56, -70, -70, 56, 56, 56, 56, | ||
814 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
815 | 56, 56, 56, 56, 103, 56, -70 | ||
816 | }, | ||
817 | |||
818 | { | ||
819 | 11, -71, -71, -71, -71, -71, -71, -71, -71, -71, | ||
820 | -71, -71, -71, 56, -71, -71, 56, 56, 56, 56, | ||
821 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
822 | 56, 104, 56, 56, 56, 56, -71 | ||
823 | }, | ||
824 | |||
825 | { | ||
826 | 11, -72, -72, -72, -72, -72, -72, -72, -72, -72, | ||
827 | -72, -72, -72, 56, -72, -72, 56, 56, 56, 56, | ||
828 | |||
829 | 56, 56, 56, 56, 105, 56, 56, 56, 56, 56, | ||
830 | 56, 56, 56, 56, 56, 56, -72 | ||
831 | }, | ||
832 | |||
833 | { | ||
834 | 11, 73, 73, -73, 73, 73, 73, 73, 73, 73, | ||
835 | 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, | ||
836 | 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, | ||
837 | 73, 73, 73, 73, 73, 73, 73 | ||
838 | }, | ||
839 | |||
840 | { | ||
841 | 11, -74, 74, 75, -74, -74, -74, -74, -74, -74, | ||
842 | -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, | ||
843 | -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, | ||
844 | -74, -74, -74, -74, -74, -74, -74 | ||
845 | |||
846 | }, | ||
847 | |||
848 | { | ||
849 | 11, -75, -75, -75, -75, -75, -75, -75, -75, -75, | ||
850 | -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, | ||
851 | -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, | ||
852 | -75, -75, -75, -75, -75, -75, -75 | ||
853 | }, | ||
854 | |||
855 | { | ||
856 | 11, -76, -76, -76, -76, -76, -76, -76, -76, -76, | ||
857 | -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, | ||
858 | -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, | ||
859 | -76, -76, -76, -76, -76, -76, -76 | ||
860 | }, | ||
861 | |||
862 | { | ||
863 | 11, 77, 77, 78, 77, -77, 77, 77, -77, 77, | ||
864 | 77, 77, 77, 77, 77, -77, 77, 77, 77, 77, | ||
865 | |||
866 | 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, | ||
867 | 77, 77, 77, 77, 77, 77, 77 | ||
868 | }, | ||
869 | |||
870 | { | ||
871 | 11, -78, -78, -78, -78, -78, -78, -78, -78, -78, | ||
872 | -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, | ||
873 | -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, | ||
874 | -78, -78, -78, -78, -78, -78, -78 | ||
875 | }, | ||
876 | |||
877 | { | ||
878 | 11, -79, -79, 80, -79, -79, -79, -79, -79, -79, | ||
879 | -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, | ||
880 | -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, | ||
881 | -79, -79, -79, -79, -79, -79, -79 | ||
882 | |||
883 | }, | ||
884 | |||
885 | { | ||
886 | 11, -80, -80, -80, -80, -80, -80, -80, -80, -80, | ||
887 | -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, | ||
888 | -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, | ||
889 | -80, -80, -80, -80, -80, -80, -80 | ||
890 | }, | ||
891 | |||
892 | { | ||
893 | 11, -81, -81, -81, -81, -81, -81, -81, -81, -81, | ||
894 | -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, | ||
895 | -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, | ||
896 | -81, -81, -81, -81, -81, -81, -81 | ||
897 | }, | ||
898 | |||
899 | { | ||
900 | 11, -82, -82, -82, -82, -82, -82, -82, -82, -82, | ||
901 | -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, | ||
902 | |||
903 | -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, | ||
904 | -82, -82, -82, -82, -82, -82, -82 | ||
905 | }, | ||
906 | |||
907 | { | ||
908 | 11, -83, -83, -83, -83, -83, -83, -83, -83, -83, | ||
909 | -83, 106, 84, 84, -83, -83, 84, 84, 84, 84, | ||
910 | 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, | ||
911 | 84, 84, 84, 84, 84, 84, -83 | ||
912 | }, | ||
913 | |||
914 | { | ||
915 | 11, -84, -84, -84, -84, -84, -84, -84, -84, -84, | ||
916 | -84, 84, 84, 84, -84, -84, 84, 84, 84, 84, | ||
917 | 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, | ||
918 | 84, 84, 84, 84, 84, 84, -84 | ||
919 | |||
920 | }, | ||
921 | |||
922 | { | ||
923 | 11, -85, -85, -85, -85, -85, -85, -85, -85, -85, | ||
924 | -85, 84, 84, 84, -85, -85, 84, 84, 84, 84, | ||
925 | 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, | ||
926 | 84, 84, 84, 84, 84, 84, -85 | ||
927 | }, | ||
928 | |||
929 | { | ||
930 | 11, -86, -86, -86, -86, -86, -86, -86, -86, -86, | ||
931 | -86, 84, 84, 84, -86, -86, 84, 84, 84, 84, | ||
932 | 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, | ||
933 | 84, 84, 84, 84, 84, 84, -86 | ||
934 | }, | ||
935 | |||
936 | { | ||
937 | 11, -87, -87, -87, -87, -87, -87, -87, -87, -87, | ||
938 | -87, -87, -87, -87, -87, -87, -87, -87, -87, -87, | ||
939 | |||
940 | -87, -87, -87, -87, -87, -87, -87, -87, -87, -87, | ||
941 | -87, -87, -87, -87, -87, -87, -87 | ||
942 | }, | ||
943 | |||
944 | { | ||
945 | 11, -88, -88, -88, -88, -88, -88, -88, -88, -88, | ||
946 | -88, -88, -88, 56, -88, -88, 56, 56, 56, 56, | ||
947 | 56, 56, 56, 56, 56, 107, 56, 56, 56, 56, | ||
948 | 56, 56, 56, 56, 56, 56, -88 | ||
949 | }, | ||
950 | |||
951 | { | ||
952 | 11, -89, -89, -89, -89, -89, -89, -89, -89, -89, | ||
953 | -89, -89, -89, 56, -89, -89, 56, 56, 56, 56, | ||
954 | 56, 56, 56, 56, 108, 56, 56, 56, 56, 56, | ||
955 | 56, 56, 56, 56, 56, 56, -89 | ||
956 | |||
957 | }, | ||
958 | |||
959 | { | ||
960 | 11, -90, -90, -90, -90, -90, -90, -90, -90, -90, | ||
961 | -90, -90, -90, 56, -90, -90, 56, 56, 56, 56, | ||
962 | 56, 56, 56, 56, 56, 56, 109, 56, 56, 56, | ||
963 | 56, 56, 56, 56, 56, 56, -90 | ||
964 | }, | ||
965 | |||
966 | { | ||
967 | 11, -91, -91, -91, -91, -91, -91, -91, -91, -91, | ||
968 | -91, -91, -91, 56, -91, -91, 56, 56, 56, 56, | ||
969 | 56, 110, 56, 56, 56, 56, 56, 56, 56, 56, | ||
970 | 56, 56, 56, 56, 56, 56, -91 | ||
971 | }, | ||
972 | |||
973 | { | ||
974 | 11, -92, -92, -92, -92, -92, -92, -92, -92, -92, | ||
975 | -92, -92, -92, 56, -92, -92, 111, 56, 56, 56, | ||
976 | |||
977 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
978 | 56, 56, 56, 56, 56, 56, -92 | ||
979 | }, | ||
980 | |||
981 | { | ||
982 | 11, -93, -93, -93, -93, -93, -93, -93, -93, -93, | ||
983 | -93, -93, -93, 56, -93, -93, 56, 56, 56, 56, | ||
984 | 112, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
985 | 56, 56, 56, 56, 56, 56, -93 | ||
986 | }, | ||
987 | |||
988 | { | ||
989 | 11, -94, -94, -94, -94, -94, -94, -94, -94, -94, | ||
990 | -94, -94, -94, 56, -94, -94, 56, 56, 113, 56, | ||
991 | 56, 56, 56, 56, 114, 56, 115, 56, 56, 56, | ||
992 | 56, 56, 56, 56, 56, 56, -94 | ||
993 | |||
994 | }, | ||
995 | |||
996 | { | ||
997 | 11, -95, -95, -95, -95, -95, -95, -95, -95, -95, | ||
998 | -95, -95, -95, 56, -95, -95, 56, 56, 56, 56, | ||
999 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 116, | ||
1000 | 56, 56, 56, 56, 56, 56, -95 | ||
1001 | }, | ||
1002 | |||
1003 | { | ||
1004 | 11, -96, -96, -96, -96, -96, -96, -96, -96, -96, | ||
1005 | -96, -96, -96, 56, -96, -96, 56, 56, 56, 56, | ||
1006 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1007 | 56, 56, 56, 56, 56, 56, -96 | ||
1008 | }, | ||
1009 | |||
1010 | { | ||
1011 | 11, -97, -97, -97, -97, -97, -97, -97, -97, -97, | ||
1012 | -97, -97, -97, 56, -97, -97, 56, 56, 56, 56, | ||
1013 | |||
1014 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1015 | 56, 56, 56, 56, 56, 56, -97 | ||
1016 | }, | ||
1017 | |||
1018 | { | ||
1019 | 11, -98, -98, -98, -98, -98, -98, -98, -98, -98, | ||
1020 | -98, -98, -98, 56, -98, -98, 56, 56, 56, 56, | ||
1021 | 56, 56, 56, 56, 56, 56, 56, 117, 56, 56, | ||
1022 | 56, 56, 56, 56, 56, 56, -98 | ||
1023 | }, | ||
1024 | |||
1025 | { | ||
1026 | 11, -99, -99, -99, -99, -99, -99, -99, -99, -99, | ||
1027 | -99, -99, -99, 56, -99, -99, 56, 56, 56, 56, | ||
1028 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1029 | 56, 56, 56, 56, 118, 56, -99 | ||
1030 | |||
1031 | }, | ||
1032 | |||
1033 | { | ||
1034 | 11, -100, -100, -100, -100, -100, -100, -100, -100, -100, | ||
1035 | -100, -100, -100, 56, -100, -100, 56, 56, 56, 56, | ||
1036 | 56, 56, 56, 56, 119, 56, 56, 56, 56, 56, | ||
1037 | 56, 56, 56, 56, 56, 56, -100 | ||
1038 | }, | ||
1039 | |||
1040 | { | ||
1041 | 11, -101, -101, -101, -101, -101, -101, -101, -101, -101, | ||
1042 | -101, -101, -101, 56, -101, -101, 56, 56, 56, 56, | ||
1043 | 56, 56, 56, 56, 56, 56, 120, 56, 56, 56, | ||
1044 | 56, 56, 56, 56, 56, 56, -101 | ||
1045 | }, | ||
1046 | |||
1047 | { | ||
1048 | 11, -102, -102, -102, -102, -102, -102, -102, -102, -102, | ||
1049 | -102, -102, -102, 56, -102, -102, 56, 56, 56, 56, | ||
1050 | |||
1051 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1052 | 56, 56, 56, 56, 121, 56, -102 | ||
1053 | }, | ||
1054 | |||
1055 | { | ||
1056 | 11, -103, -103, -103, -103, -103, -103, -103, -103, -103, | ||
1057 | -103, -103, -103, 56, -103, -103, 56, 56, 56, 56, | ||
1058 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1059 | 56, 122, 56, 56, 56, 56, -103 | ||
1060 | }, | ||
1061 | |||
1062 | { | ||
1063 | 11, -104, -104, -104, -104, -104, -104, -104, -104, -104, | ||
1064 | -104, -104, -104, 56, -104, -104, 56, 56, 56, 56, | ||
1065 | 56, 56, 56, 56, 123, 56, 56, 56, 56, 56, | ||
1066 | 56, 56, 56, 56, 56, 56, -104 | ||
1067 | |||
1068 | }, | ||
1069 | |||
1070 | { | ||
1071 | 11, -105, -105, -105, -105, -105, -105, -105, -105, -105, | ||
1072 | -105, -105, -105, 56, -105, -105, 56, 56, 56, 56, | ||
1073 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1074 | 56, 56, 124, 56, 56, 56, -105 | ||
1075 | }, | ||
1076 | |||
1077 | { | ||
1078 | 11, -106, -106, -106, -106, -106, -106, -106, -106, -106, | ||
1079 | -106, 84, 84, 84, -106, -106, 84, 84, 84, 84, | ||
1080 | 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, | ||
1081 | 84, 84, 84, 84, 84, 84, -106 | ||
1082 | }, | ||
1083 | |||
1084 | { | ||
1085 | 11, -107, -107, -107, -107, -107, -107, -107, -107, -107, | ||
1086 | -107, -107, -107, 56, -107, -107, 56, 56, 56, 56, | ||
1087 | |||
1088 | 125, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1089 | 56, 56, 56, 56, 56, 56, -107 | ||
1090 | }, | ||
1091 | |||
1092 | { | ||
1093 | 11, -108, -108, -108, -108, -108, -108, -108, -108, -108, | ||
1094 | -108, -108, -108, 56, -108, -108, 56, 56, 126, 56, | ||
1095 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1096 | 56, 56, 56, 56, 56, 56, -108 | ||
1097 | }, | ||
1098 | |||
1099 | { | ||
1100 | 11, -109, -109, -109, -109, -109, -109, -109, -109, -109, | ||
1101 | -109, -109, -109, 56, -109, -109, 56, 56, 56, 56, | ||
1102 | 127, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1103 | 56, 56, 56, 56, 56, 56, -109 | ||
1104 | |||
1105 | }, | ||
1106 | |||
1107 | { | ||
1108 | 11, -110, -110, -110, -110, -110, -110, -110, -110, -110, | ||
1109 | -110, -110, -110, 56, -110, -110, 56, 56, 56, 56, | ||
1110 | 56, 56, 56, 56, 128, 56, 56, 56, 56, 56, | ||
1111 | 56, 56, 56, 56, 56, 56, -110 | ||
1112 | }, | ||
1113 | |||
1114 | { | ||
1115 | 11, -111, -111, -111, -111, -111, -111, -111, -111, -111, | ||
1116 | -111, -111, -111, 56, -111, -111, 56, 56, 56, 56, | ||
1117 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1118 | 56, 56, 56, 56, 129, 56, -111 | ||
1119 | }, | ||
1120 | |||
1121 | { | ||
1122 | 11, -112, -112, -112, -112, -112, -112, -112, -112, -112, | ||
1123 | -112, -112, -112, 56, -112, -112, 56, 56, 56, 56, | ||
1124 | |||
1125 | 56, 56, 56, 56, 56, 56, 56, 130, 56, 56, | ||
1126 | 56, 56, 56, 56, 56, 56, -112 | ||
1127 | }, | ||
1128 | |||
1129 | { | ||
1130 | 11, -113, -113, -113, -113, -113, -113, -113, -113, -113, | ||
1131 | -113, -113, -113, 56, -113, -113, 56, 56, 56, 56, | ||
1132 | 56, 56, 56, 131, 56, 56, 56, 56, 56, 56, | ||
1133 | 56, 56, 56, 56, 56, 56, -113 | ||
1134 | }, | ||
1135 | |||
1136 | { | ||
1137 | 11, -114, -114, -114, -114, -114, -114, -114, -114, -114, | ||
1138 | -114, -114, -114, 56, -114, -114, 56, 56, 56, 56, | ||
1139 | 56, 132, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1140 | 56, 56, 56, 56, 56, 56, -114 | ||
1141 | |||
1142 | }, | ||
1143 | |||
1144 | { | ||
1145 | 11, -115, -115, -115, -115, -115, -115, -115, -115, -115, | ||
1146 | -115, -115, -115, 56, -115, -115, 56, 56, 56, 56, | ||
1147 | 133, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1148 | 56, 56, 56, 56, 56, 56, -115 | ||
1149 | }, | ||
1150 | |||
1151 | { | ||
1152 | 11, -116, -116, -116, -116, -116, -116, -116, -116, -116, | ||
1153 | -116, -116, -116, 56, -116, -116, 56, 56, 56, 56, | ||
1154 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1155 | 56, 56, 56, 56, 56, 56, -116 | ||
1156 | }, | ||
1157 | |||
1158 | { | ||
1159 | 11, -117, -117, -117, -117, -117, -117, -117, -117, -117, | ||
1160 | -117, -117, -117, 56, -117, -117, 56, 56, 56, 56, | ||
1161 | |||
1162 | 56, 56, 56, 56, 56, 56, 134, 56, 56, 56, | ||
1163 | 56, 56, 56, 56, 56, 56, -117 | ||
1164 | }, | ||
1165 | |||
1166 | { | ||
1167 | 11, -118, -118, -118, -118, -118, -118, -118, -118, -118, | ||
1168 | -118, -118, -118, 56, -118, -118, 56, 56, 56, 56, | ||
1169 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1170 | 56, 56, 56, 56, 56, 56, -118 | ||
1171 | }, | ||
1172 | |||
1173 | { | ||
1174 | 11, -119, -119, -119, -119, -119, -119, -119, -119, -119, | ||
1175 | -119, -119, -119, 56, -119, -119, 56, 56, 56, 56, | ||
1176 | 56, 56, 56, 56, 56, 56, 56, 56, 135, 56, | ||
1177 | 56, 56, 56, 56, 56, 56, -119 | ||
1178 | |||
1179 | }, | ||
1180 | |||
1181 | { | ||
1182 | 11, -120, -120, -120, -120, -120, -120, -120, -120, -120, | ||
1183 | -120, -120, -120, 56, -120, -120, 56, 56, 56, 56, | ||
1184 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 136, | ||
1185 | 56, 56, 56, 56, 56, 56, -120 | ||
1186 | }, | ||
1187 | |||
1188 | { | ||
1189 | 11, -121, -121, -121, -121, -121, -121, -121, -121, -121, | ||
1190 | -121, -121, -121, 56, -121, -121, 56, 56, 56, 56, | ||
1191 | 56, 56, 56, 56, 137, 56, 56, 56, 56, 56, | ||
1192 | 56, 56, 56, 56, 56, 56, -121 | ||
1193 | }, | ||
1194 | |||
1195 | { | ||
1196 | 11, -122, -122, -122, -122, -122, -122, -122, -122, -122, | ||
1197 | -122, -122, -122, 56, -122, -122, 56, 56, 138, 56, | ||
1198 | |||
1199 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1200 | 56, 56, 56, 56, 56, 56, -122 | ||
1201 | }, | ||
1202 | |||
1203 | { | ||
1204 | 11, -123, -123, -123, -123, -123, -123, -123, -123, -123, | ||
1205 | -123, -123, -123, 56, -123, -123, 56, 56, 56, 56, | ||
1206 | 56, 56, 56, 56, 56, 56, 56, 139, 56, 56, | ||
1207 | 56, 56, 56, 56, 56, 56, -123 | ||
1208 | }, | ||
1209 | |||
1210 | { | ||
1211 | 11, -124, -124, -124, -124, -124, -124, -124, -124, -124, | ||
1212 | -124, -124, -124, 56, -124, -124, 56, 56, 56, 56, | ||
1213 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1214 | 56, 56, 56, 140, 56, 56, -124 | ||
1215 | |||
1216 | }, | ||
1217 | |||
1218 | { | ||
1219 | 11, -125, -125, -125, -125, -125, -125, -125, -125, -125, | ||
1220 | -125, -125, -125, 56, -125, -125, 141, 56, 56, 56, | ||
1221 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1222 | 56, 56, 56, 56, 56, 56, -125 | ||
1223 | }, | ||
1224 | |||
1225 | { | ||
1226 | 11, -126, -126, -126, -126, -126, -126, -126, -126, -126, | ||
1227 | -126, -126, -126, 56, -126, -126, 56, 56, 56, 56, | ||
1228 | 142, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1229 | 56, 56, 56, 56, 56, 56, -126 | ||
1230 | }, | ||
1231 | |||
1232 | { | ||
1233 | 11, -127, -127, -127, -127, -127, -127, -127, -127, -127, | ||
1234 | -127, -127, -127, 56, -127, -127, 56, 56, 56, 56, | ||
1235 | |||
1236 | 56, 56, 56, 56, 56, 56, 56, 143, 56, 56, | ||
1237 | 56, 56, 56, 56, 56, 56, -127 | ||
1238 | }, | ||
1239 | |||
1240 | { | ||
1241 | 11, -128, -128, -128, -128, -128, -128, -128, -128, -128, | ||
1242 | -128, -128, -128, 56, -128, -128, 56, 56, 56, 56, | ||
1243 | 56, 56, 144, 56, 56, 56, 56, 56, 56, 56, | ||
1244 | 56, 56, 56, 56, 56, 56, -128 | ||
1245 | }, | ||
1246 | |||
1247 | { | ||
1248 | 11, -129, -129, -129, -129, -129, -129, -129, -129, -129, | ||
1249 | -129, -129, -129, 56, -129, -129, 56, 56, 56, 56, | ||
1250 | 56, 56, 56, 56, 56, 145, 56, 56, 56, 56, | ||
1251 | 56, 56, 56, 56, 56, 56, -129 | ||
1252 | |||
1253 | }, | ||
1254 | |||
1255 | { | ||
1256 | 11, -130, -130, -130, -130, -130, -130, -130, -130, -130, | ||
1257 | -130, -130, -130, 56, -130, -130, 56, 56, 56, 146, | ||
1258 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1259 | 56, 56, 56, 56, 56, 56, -130 | ||
1260 | }, | ||
1261 | |||
1262 | { | ||
1263 | 11, -131, -131, -131, -131, -131, -131, -131, -131, -131, | ||
1264 | -131, -131, -131, 56, -131, -131, 56, 56, 56, 56, | ||
1265 | 56, 56, 56, 56, 56, 56, 56, 56, 147, 56, | ||
1266 | 56, 56, 56, 56, 56, 56, -131 | ||
1267 | }, | ||
1268 | |||
1269 | { | ||
1270 | 11, -132, -132, -132, -132, -132, -132, -132, -132, -132, | ||
1271 | -132, -132, -132, 56, -132, -132, 56, 56, 56, 56, | ||
1272 | |||
1273 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1274 | 56, 56, 56, 56, 56, 56, -132 | ||
1275 | }, | ||
1276 | |||
1277 | { | ||
1278 | 11, -133, -133, -133, -133, -133, -133, -133, -133, -133, | ||
1279 | -133, -133, -133, 56, -133, -133, 56, 56, 56, 56, | ||
1280 | 56, 56, 56, 56, 56, 56, 56, 148, 56, 56, | ||
1281 | 56, 56, 56, 56, 56, 56, -133 | ||
1282 | }, | ||
1283 | |||
1284 | { | ||
1285 | 11, -134, -134, -134, -134, -134, -134, -134, -134, -134, | ||
1286 | -134, -134, -134, 56, -134, -134, 56, 56, 56, 56, | ||
1287 | 149, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1288 | 56, 56, 56, 56, 56, 56, -134 | ||
1289 | |||
1290 | }, | ||
1291 | |||
1292 | { | ||
1293 | 11, -135, -135, -135, -135, -135, -135, -135, -135, -135, | ||
1294 | -135, -135, -135, 56, -135, -135, 56, 56, 56, 56, | ||
1295 | 56, 56, 56, 56, 56, 56, 56, 150, 56, 56, | ||
1296 | 56, 56, 56, 56, 56, 56, -135 | ||
1297 | }, | ||
1298 | |||
1299 | { | ||
1300 | 11, -136, -136, -136, -136, -136, -136, -136, -136, -136, | ||
1301 | -136, -136, -136, 56, -136, -136, 56, 56, 56, 56, | ||
1302 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1303 | 56, 56, 56, 151, 56, 56, -136 | ||
1304 | }, | ||
1305 | |||
1306 | { | ||
1307 | 11, -137, -137, -137, -137, -137, -137, -137, -137, -137, | ||
1308 | -137, -137, -137, 56, -137, -137, 56, 56, 56, 56, | ||
1309 | |||
1310 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1311 | 56, 152, 56, 56, 56, 56, -137 | ||
1312 | }, | ||
1313 | |||
1314 | { | ||
1315 | 11, -138, -138, -138, -138, -138, -138, -138, -138, -138, | ||
1316 | -138, -138, -138, 56, -138, -138, 56, 56, 56, 56, | ||
1317 | 153, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1318 | 56, 56, 56, 56, 56, 56, -138 | ||
1319 | }, | ||
1320 | |||
1321 | { | ||
1322 | 11, -139, -139, -139, -139, -139, -139, -139, -139, -139, | ||
1323 | -139, -139, -139, 56, -139, -139, 56, 56, 56, 56, | ||
1324 | 56, 56, 154, 56, 56, 56, 56, 56, 56, 56, | ||
1325 | 56, 56, 56, 56, 56, 56, -139 | ||
1326 | |||
1327 | }, | ||
1328 | |||
1329 | { | ||
1330 | 11, -140, -140, -140, -140, -140, -140, -140, -140, -140, | ||
1331 | -140, -140, -140, 56, -140, -140, 155, 56, 56, 56, | ||
1332 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1333 | 56, 56, 56, 56, 56, 56, -140 | ||
1334 | }, | ||
1335 | |||
1336 | { | ||
1337 | 11, -141, -141, -141, -141, -141, -141, -141, -141, -141, | ||
1338 | -141, -141, -141, 56, -141, -141, 56, 56, 56, 56, | ||
1339 | 56, 56, 56, 56, 56, 56, 56, 156, 56, 56, | ||
1340 | 56, 56, 56, 56, 56, 56, -141 | ||
1341 | }, | ||
1342 | |||
1343 | { | ||
1344 | 11, -142, -142, -142, -142, -142, -142, -142, -142, -142, | ||
1345 | -142, -142, -142, 56, -142, -142, 56, 56, 56, 56, | ||
1346 | |||
1347 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1348 | 56, 56, 56, 56, 56, 56, -142 | ||
1349 | }, | ||
1350 | |||
1351 | { | ||
1352 | 11, -143, -143, -143, -143, -143, -143, -143, -143, -143, | ||
1353 | -143, -143, -143, 56, -143, -143, 56, 56, 56, 56, | ||
1354 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1355 | 56, 56, 56, 157, 56, 56, -143 | ||
1356 | }, | ||
1357 | |||
1358 | { | ||
1359 | 11, -144, -144, -144, -144, -144, -144, -144, -144, -144, | ||
1360 | -144, -144, -144, 56, -144, -144, 56, 56, 56, 56, | ||
1361 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1362 | 56, 56, 56, 56, 56, 56, -144 | ||
1363 | |||
1364 | }, | ||
1365 | |||
1366 | { | ||
1367 | 11, -145, -145, -145, -145, -145, -145, -145, -145, -145, | ||
1368 | -145, -145, -145, 56, -145, -145, 56, 56, 56, 56, | ||
1369 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1370 | 56, 56, 56, 158, 56, 56, -145 | ||
1371 | }, | ||
1372 | |||
1373 | { | ||
1374 | 11, -146, -146, -146, -146, -146, -146, -146, -146, -146, | ||
1375 | -146, -146, -146, 56, -146, -146, 56, 56, 56, 56, | ||
1376 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1377 | 56, 56, 159, 56, 56, 56, -146 | ||
1378 | }, | ||
1379 | |||
1380 | { | ||
1381 | 11, -147, -147, -147, -147, -147, -147, -147, -147, -147, | ||
1382 | -147, -147, -147, 56, -147, -147, 56, 56, 56, 56, | ||
1383 | |||
1384 | 56, 56, 56, 56, 160, 56, 56, 56, 56, 56, | ||
1385 | 56, 56, 56, 56, 56, 56, -147 | ||
1386 | }, | ||
1387 | |||
1388 | { | ||
1389 | 11, -148, -148, -148, -148, -148, -148, -148, -148, -148, | ||
1390 | -148, -148, -148, 56, -148, -148, 56, 56, 56, 56, | ||
1391 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1392 | 56, 56, 56, 56, 161, 56, -148 | ||
1393 | }, | ||
1394 | |||
1395 | { | ||
1396 | 11, -149, -149, -149, -149, -149, -149, -149, -149, -149, | ||
1397 | -149, -149, -149, 56, -149, -149, 56, 56, 56, 56, | ||
1398 | 56, 56, 56, 56, 56, 56, 56, 162, 56, 56, | ||
1399 | 56, 56, 56, 56, 56, 56, -149 | ||
1400 | |||
1401 | }, | ||
1402 | |||
1403 | { | ||
1404 | 11, -150, -150, -150, -150, -150, -150, -150, -150, -150, | ||
1405 | -150, -150, -150, 56, -150, -150, 163, 56, 56, 56, | ||
1406 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1407 | 56, 56, 56, 56, 56, 56, -150 | ||
1408 | }, | ||
1409 | |||
1410 | { | ||
1411 | 11, -151, -151, -151, -151, -151, -151, -151, -151, -151, | ||
1412 | -151, -151, -151, 56, -151, -151, 56, 56, 56, 56, | ||
1413 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1414 | 56, 56, 56, 56, 56, 56, -151 | ||
1415 | }, | ||
1416 | |||
1417 | { | ||
1418 | 11, -152, -152, -152, -152, -152, -152, -152, -152, -152, | ||
1419 | -152, -152, -152, 56, -152, -152, 56, 56, 56, 56, | ||
1420 | |||
1421 | 164, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1422 | 56, 56, 56, 56, 56, 56, -152 | ||
1423 | }, | ||
1424 | |||
1425 | { | ||
1426 | 11, -153, -153, -153, -153, -153, -153, -153, -153, -153, | ||
1427 | -153, -153, -153, 56, -153, -153, 56, 56, 56, 56, | ||
1428 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1429 | 56, 56, 56, 56, 56, 56, -153 | ||
1430 | }, | ||
1431 | |||
1432 | { | ||
1433 | 11, -154, -154, -154, -154, -154, -154, -154, -154, -154, | ||
1434 | -154, -154, -154, 56, -154, -154, 56, 56, 56, 56, | ||
1435 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1436 | 56, 56, 56, 56, 56, 56, -154 | ||
1437 | |||
1438 | }, | ||
1439 | |||
1440 | { | ||
1441 | 11, -155, -155, -155, -155, -155, -155, -155, -155, -155, | ||
1442 | -155, -155, -155, 56, -155, -155, 56, 56, 56, 56, | ||
1443 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1444 | 56, 56, 56, 165, 56, 56, -155 | ||
1445 | }, | ||
1446 | |||
1447 | { | ||
1448 | 11, -156, -156, -156, -156, -156, -156, -156, -156, -156, | ||
1449 | -156, -156, -156, 56, -156, -156, 56, 56, 56, 56, | ||
1450 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1451 | 56, 56, 56, 56, 56, 56, -156 | ||
1452 | }, | ||
1453 | |||
1454 | { | ||
1455 | 11, -157, -157, -157, -157, -157, -157, -157, -157, -157, | ||
1456 | -157, -157, -157, 56, -157, -157, 56, 56, 56, 56, | ||
1457 | |||
1458 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1459 | 56, 56, 56, 56, 56, 56, -157 | ||
1460 | }, | ||
1461 | |||
1462 | { | ||
1463 | 11, -158, -158, -158, -158, -158, -158, -158, -158, -158, | ||
1464 | -158, -158, -158, 56, -158, -158, 56, 56, 56, 56, | ||
1465 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1466 | 56, 56, 56, 56, 56, 56, -158 | ||
1467 | }, | ||
1468 | |||
1469 | { | ||
1470 | 11, -159, -159, -159, -159, -159, -159, -159, -159, -159, | ||
1471 | -159, -159, -159, 56, -159, -159, 56, 56, 56, 56, | ||
1472 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1473 | 56, 56, 56, 56, 56, 56, -159 | ||
1474 | |||
1475 | }, | ||
1476 | |||
1477 | { | ||
1478 | 11, -160, -160, -160, -160, -160, -160, -160, -160, -160, | ||
1479 | -160, -160, -160, 56, -160, -160, 56, 56, 166, 56, | ||
1480 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1481 | 56, 56, 56, 56, 56, 56, -160 | ||
1482 | }, | ||
1483 | |||
1484 | { | ||
1485 | 11, -161, -161, -161, -161, -161, -161, -161, -161, -161, | ||
1486 | -161, -161, -161, 56, -161, -161, 56, 56, 56, 56, | ||
1487 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1488 | 56, 56, 56, 56, 56, 56, -161 | ||
1489 | }, | ||
1490 | |||
1491 | { | ||
1492 | 11, -162, -162, -162, -162, -162, -162, -162, -162, -162, | ||
1493 | -162, -162, -162, 56, -162, -162, 56, 56, 56, 56, | ||
1494 | |||
1495 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1496 | 56, 56, 56, 56, 167, 56, -162 | ||
1497 | }, | ||
1498 | |||
1499 | { | ||
1500 | 11, -163, -163, -163, -163, -163, -163, -163, -163, -163, | ||
1501 | -163, -163, -163, 56, -163, -163, 56, 56, 56, 56, | ||
1502 | 56, 56, 56, 56, 56, 168, 56, 56, 56, 56, | ||
1503 | 56, 56, 56, 56, 56, 56, -163 | ||
1504 | }, | ||
1505 | |||
1506 | { | ||
1507 | 11, -164, -164, -164, -164, -164, -164, -164, -164, -164, | ||
1508 | -164, -164, -164, 56, -164, -164, 56, 56, 56, 56, | ||
1509 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1510 | 56, 56, 169, 56, 56, 56, -164 | ||
1511 | |||
1512 | }, | ||
1513 | |||
1514 | { | ||
1515 | 11, -165, -165, -165, -165, -165, -165, -165, -165, -165, | ||
1516 | -165, -165, -165, 56, -165, -165, 56, 56, 56, 56, | ||
1517 | 170, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1518 | 56, 56, 56, 56, 56, 56, -165 | ||
1519 | }, | ||
1520 | |||
1521 | { | ||
1522 | 11, -166, -166, -166, -166, -166, -166, -166, -166, -166, | ||
1523 | -166, -166, -166, 56, -166, -166, 56, 56, 56, 56, | ||
1524 | 171, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1525 | 56, 56, 56, 56, 56, 56, -166 | ||
1526 | }, | ||
1527 | |||
1528 | { | ||
1529 | 11, -167, -167, -167, -167, -167, -167, -167, -167, -167, | ||
1530 | -167, -167, -167, 56, -167, -167, 56, 56, 56, 56, | ||
1531 | |||
1532 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1533 | 56, 56, 56, 56, 56, 56, -167 | ||
1534 | }, | ||
1535 | |||
1536 | { | ||
1537 | 11, -168, -168, -168, -168, -168, -168, -168, -168, -168, | ||
1538 | -168, -168, -168, 56, -168, -168, 56, 56, 56, 56, | ||
1539 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1540 | 56, 56, 56, 56, 56, 56, -168 | ||
1541 | }, | ||
1542 | |||
1543 | { | ||
1544 | 11, -169, -169, -169, -169, -169, -169, -169, -169, -169, | ||
1545 | -169, -169, -169, 56, -169, -169, 56, 56, 56, 56, | ||
1546 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1547 | 56, 56, 56, 56, 56, 56, -169 | ||
1548 | |||
1549 | }, | ||
1550 | |||
1551 | { | ||
1552 | 11, -170, -170, -170, -170, -170, -170, -170, -170, -170, | ||
1553 | -170, -170, -170, 56, -170, -170, 56, 56, 56, 56, | ||
1554 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1555 | 56, 56, 56, 56, 56, 56, -170 | ||
1556 | }, | ||
1557 | |||
1558 | { | ||
1559 | 11, -171, -171, -171, -171, -171, -171, -171, -171, -171, | ||
1560 | -171, -171, -171, 56, -171, -171, 56, 56, 56, 56, | ||
1561 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | ||
1562 | 56, 56, 56, 56, 56, 56, -171 | ||
1563 | }, | ||
1564 | |||
1565 | } ; | ||
1566 | |||
1567 | |||
1568 | static yy_state_type yy_get_previous_state YY_PROTO(( void )); | ||
1569 | static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); | ||
1570 | static int yy_get_next_buffer YY_PROTO(( void )); | ||
1571 | static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); | ||
1572 | |||
1573 | /* Done after the current pattern has been matched and before the | ||
1574 | * corresponding action - sets up yytext. | ||
1575 | */ | ||
1576 | #define YY_DO_BEFORE_ACTION \ | ||
1577 | yytext_ptr = yy_bp; \ | ||
1578 | yyleng = (int) (yy_cp - yy_bp); \ | ||
1579 | yy_hold_char = *yy_cp; \ | ||
1580 | *yy_cp = '\0'; \ | ||
1581 | yy_c_buf_p = yy_cp; | ||
1582 | |||
1583 | #define YY_NUM_RULES 55 | ||
1584 | #define YY_END_OF_BUFFER 56 | ||
1585 | static yyconst short int yy_accept[172] = | ||
1586 | { 0, | ||
1587 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
1588 | 56, 5, 4, 3, 2, 29, 30, 28, 28, 28, | ||
1589 | 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, | ||
1590 | 54, 51, 53, 46, 50, 49, 48, 44, 41, 35, | ||
1591 | 40, 44, 33, 34, 43, 43, 36, 43, 43, 44, | ||
1592 | 4, 3, 2, 2, 1, 28, 28, 28, 28, 28, | ||
1593 | 28, 28, 15, 28, 28, 28, 28, 28, 28, 28, | ||
1594 | 28, 28, 54, 51, 53, 52, 46, 45, 48, 47, | ||
1595 | 37, 31, 43, 43, 38, 39, 32, 28, 28, 28, | ||
1596 | 28, 28, 28, 28, 28, 26, 25, 28, 28, 28, | ||
1597 | |||
1598 | 28, 28, 28, 28, 28, 42, 23, 28, 28, 28, | ||
1599 | 28, 28, 28, 28, 28, 14, 28, 7, 28, 28, | ||
1600 | 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, | ||
1601 | 28, 16, 28, 28, 28, 28, 28, 28, 28, 28, | ||
1602 | 28, 10, 28, 13, 28, 28, 28, 28, 28, 28, | ||
1603 | 21, 28, 9, 27, 28, 24, 12, 20, 17, 28, | ||
1604 | 8, 28, 28, 28, 28, 28, 6, 19, 18, 22, | ||
1605 | 11 | ||
1606 | } ; | ||
1607 | |||
1608 | static yyconst int yy_ec[256] = | ||
1609 | { 0, | ||
1610 | 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, | ||
1611 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
1612 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
1613 | 1, 2, 4, 5, 6, 1, 1, 7, 8, 9, | ||
1614 | 10, 1, 1, 1, 11, 12, 12, 13, 13, 13, | ||
1615 | 13, 13, 13, 13, 13, 13, 13, 1, 1, 1, | ||
1616 | 14, 1, 1, 1, 13, 13, 13, 13, 13, 13, | ||
1617 | 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, | ||
1618 | 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, | ||
1619 | 1, 15, 1, 1, 13, 1, 16, 17, 18, 19, | ||
1620 | |||
1621 | 20, 21, 22, 23, 24, 13, 13, 25, 26, 27, | ||
1622 | 28, 29, 30, 31, 32, 33, 34, 13, 13, 35, | ||
1623 | 13, 13, 1, 36, 1, 1, 1, 1, 1, 1, | ||
1624 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
1625 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
1626 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
1627 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
1628 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
1629 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
1630 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
1631 | |||
1632 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
1633 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
1634 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
1635 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
1636 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
1637 | 1, 1, 1, 1, 1 | ||
1638 | } ; | ||
1639 | |||
1640 | /* The intent behind this definition is that it'll catch | ||
1641 | * any uses of REJECT which flex missed. | ||
1642 | */ | ||
1643 | #define REJECT reject_used_but_not_detected | ||
1644 | #define yymore() yymore_used_but_not_detected | ||
1645 | #define YY_MORE_ADJ 0 | ||
1646 | #define YY_RESTORE_YY_MORE_OFFSET | ||
1647 | char *yytext; | ||
1648 | #line 1 "zconf.l" | ||
1649 | #define INITIAL 0 | ||
1650 | #define YY_NEVER_INTERACTIVE 1 | ||
1651 | #define COMMAND 1 | ||
1652 | #define HELP 2 | ||
1653 | #define STRING 3 | ||
1654 | #define PARAM 4 | ||
1655 | |||
1656 | #line 5 "zconf.l" | ||
1657 | /* | ||
1658 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> | ||
1659 | * Released under the terms of the GNU GPL v2.0. | ||
1660 | */ | ||
1661 | |||
1662 | #include <stdio.h> | ||
1663 | #include <stdlib.h> | ||
1664 | #include <string.h> | ||
1665 | #include <unistd.h> | ||
1666 | |||
1667 | #define LKC_DIRECT_LINK | ||
1668 | #include "lkc.h" | ||
1669 | #include "zconf.tab.h" | ||
1670 | |||
1671 | #define START_STRSIZE 16 | ||
1672 | |||
1673 | char *text; | ||
1674 | static char *text_ptr; | ||
1675 | static int text_size, text_asize; | ||
1676 | |||
1677 | struct buffer { | ||
1678 | struct buffer *parent; | ||
1679 | YY_BUFFER_STATE state; | ||
1680 | }; | ||
1681 | |||
1682 | struct buffer *current_buf; | ||
1683 | |||
1684 | static int last_ts, first_ts; | ||
1685 | |||
1686 | static void zconf_endhelp(void); | ||
1687 | static struct buffer *zconf_endfile(void); | ||
1688 | |||
1689 | void new_string(void) | ||
1690 | { | ||
1691 | text = malloc(START_STRSIZE); | ||
1692 | text_asize = START_STRSIZE; | ||
1693 | text_ptr = text; | ||
1694 | text_size = 0; | ||
1695 | *text_ptr = 0; | ||
1696 | } | ||
1697 | |||
1698 | void append_string(const char *str, int size) | ||
1699 | { | ||
1700 | int new_size = text_size + size + 1; | ||
1701 | if (new_size > text_asize) { | ||
1702 | text = realloc(text, new_size); | ||
1703 | text_asize = new_size; | ||
1704 | text_ptr = text + text_size; | ||
1705 | } | ||
1706 | memcpy(text_ptr, str, size); | ||
1707 | text_ptr += size; | ||
1708 | text_size += size; | ||
1709 | *text_ptr = 0; | ||
1710 | } | ||
1711 | |||
1712 | void alloc_string(const char *str, int size) | ||
1713 | { | ||
1714 | text = malloc(size + 1); | ||
1715 | memcpy(text, str, size); | ||
1716 | text[size] = 0; | ||
1717 | } | ||
1718 | #line 1719 "lex.zconf.c" | ||
1719 | |||
1720 | /* Macros after this point can all be overridden by user definitions in | ||
1721 | * section 1. | ||
1722 | */ | ||
1723 | |||
1724 | #ifndef YY_SKIP_YYWRAP | ||
1725 | #ifdef __cplusplus | ||
1726 | extern "C" int yywrap YY_PROTO(( void )); | ||
1727 | #else | ||
1728 | extern int yywrap YY_PROTO(( void )); | ||
1729 | #endif | ||
1730 | #endif | ||
1731 | |||
1732 | #ifndef YY_NO_UNPUT | ||
1733 | static void yyunput YY_PROTO(( int c, char *buf_ptr )); | ||
1734 | #endif | ||
1735 | |||
1736 | #ifndef yytext_ptr | ||
1737 | static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); | ||
1738 | #endif | ||
1739 | |||
1740 | #ifdef YY_NEED_STRLEN | ||
1741 | static int yy_flex_strlen YY_PROTO(( yyconst char * )); | ||
1742 | #endif | ||
1743 | |||
1744 | #ifndef YY_NO_INPUT | ||
1745 | #ifdef __cplusplus | ||
1746 | static int yyinput YY_PROTO(( void )); | ||
1747 | #else | ||
1748 | static int input YY_PROTO(( void )); | ||
1749 | #endif | ||
1750 | #endif | ||
1751 | |||
1752 | #if YY_STACK_USED | ||
1753 | static int yy_start_stack_ptr = 0; | ||
1754 | static int yy_start_stack_depth = 0; | ||
1755 | static int *yy_start_stack = 0; | ||
1756 | #ifndef YY_NO_PUSH_STATE | ||
1757 | static void yy_push_state YY_PROTO(( int new_state )); | ||
1758 | #endif | ||
1759 | #ifndef YY_NO_POP_STATE | ||
1760 | static void yy_pop_state YY_PROTO(( void )); | ||
1761 | #endif | ||
1762 | #ifndef YY_NO_TOP_STATE | ||
1763 | static int yy_top_state YY_PROTO(( void )); | ||
1764 | #endif | ||
1765 | |||
1766 | #else | ||
1767 | #define YY_NO_PUSH_STATE 1 | ||
1768 | #define YY_NO_POP_STATE 1 | ||
1769 | #define YY_NO_TOP_STATE 1 | ||
1770 | #endif | ||
1771 | |||
1772 | #ifdef YY_MALLOC_DECL | ||
1773 | YY_MALLOC_DECL | ||
1774 | #else | ||
1775 | #if __STDC__ | ||
1776 | #ifndef __cplusplus | ||
1777 | #include <stdlib.h> | ||
1778 | #endif | ||
1779 | #else | ||
1780 | /* Just try to get by without declaring the routines. This will fail | ||
1781 | * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) | ||
1782 | * or sizeof(void*) != sizeof(int). | ||
1783 | */ | ||
1784 | #endif | ||
1785 | #endif | ||
1786 | |||
1787 | /* Amount of stuff to slurp up with each read. */ | ||
1788 | #ifndef YY_READ_BUF_SIZE | ||
1789 | #define YY_READ_BUF_SIZE 8192 | ||
1790 | #endif | ||
1791 | |||
1792 | /* Copy whatever the last rule matched to the standard output. */ | ||
1793 | |||
1794 | #ifndef ECHO | ||
1795 | /* This used to be an fputs(), but since the string might contain NUL's, | ||
1796 | * we now use fwrite(). | ||
1797 | */ | ||
1798 | #define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) | ||
1799 | #endif | ||
1800 | |||
1801 | /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, | ||
1802 | * is returned in "result". | ||
1803 | */ | ||
1804 | #ifndef YY_INPUT | ||
1805 | #define YY_INPUT(buf,result,max_size) \ | ||
1806 | errno=0; \ | ||
1807 | while ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \ | ||
1808 | { \ | ||
1809 | if( errno != EINTR) \ | ||
1810 | { \ | ||
1811 | YY_FATAL_ERROR( "input in flex scanner failed" ); \ | ||
1812 | break; \ | ||
1813 | } \ | ||
1814 | errno=0; \ | ||
1815 | clearerr(yyin); \ | ||
1816 | } | ||
1817 | #endif | ||
1818 | |||
1819 | /* No semi-colon after return; correct usage is to write "yyterminate();" - | ||
1820 | * we don't want an extra ';' after the "return" because that will cause | ||
1821 | * some compilers to complain about unreachable statements. | ||
1822 | */ | ||
1823 | #ifndef yyterminate | ||
1824 | #define yyterminate() return YY_NULL | ||
1825 | #endif | ||
1826 | |||
1827 | /* Number of entries by which start-condition stack grows. */ | ||
1828 | #ifndef YY_START_STACK_INCR | ||
1829 | #define YY_START_STACK_INCR 25 | ||
1830 | #endif | ||
1831 | |||
1832 | /* Report a fatal error. */ | ||
1833 | #ifndef YY_FATAL_ERROR | ||
1834 | #define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) | ||
1835 | #endif | ||
1836 | |||
1837 | /* Default declaration of generated scanner - a define so the user can | ||
1838 | * easily add parameters. | ||
1839 | */ | ||
1840 | #ifndef YY_DECL | ||
1841 | #define YY_DECL int yylex YY_PROTO(( void )) | ||
1842 | #endif | ||
1843 | |||
1844 | /* Code executed at the beginning of each rule, after yytext and yyleng | ||
1845 | * have been set up. | ||
1846 | */ | ||
1847 | #ifndef YY_USER_ACTION | ||
1848 | #define YY_USER_ACTION | ||
1849 | #endif | ||
1850 | |||
1851 | /* Code executed at the end of each rule. */ | ||
1852 | #ifndef YY_BREAK | ||
1853 | #define YY_BREAK break; | ||
1854 | #endif | ||
1855 | |||
1856 | #define YY_RULE_SETUP \ | ||
1857 | YY_USER_ACTION | ||
1858 | |||
1859 | YY_DECL | ||
1860 | { | ||
1861 | register yy_state_type yy_current_state; | ||
1862 | register char *yy_cp, *yy_bp; | ||
1863 | register int yy_act; | ||
1864 | |||
1865 | #line 71 "zconf.l" | ||
1866 | |||
1867 | int str = 0; | ||
1868 | int ts, i; | ||
1869 | |||
1870 | #line 1871 "lex.zconf.c" | ||
1871 | |||
1872 | if ( yy_init ) | ||
1873 | { | ||
1874 | yy_init = 0; | ||
1875 | |||
1876 | #ifdef YY_USER_INIT | ||
1877 | YY_USER_INIT; | ||
1878 | #endif | ||
1879 | |||
1880 | if ( ! yy_start ) | ||
1881 | yy_start = 1; /* first start state */ | ||
1882 | |||
1883 | if ( ! yyin ) | ||
1884 | yyin = stdin; | ||
1885 | |||
1886 | if ( ! yyout ) | ||
1887 | yyout = stdout; | ||
1888 | |||
1889 | if ( ! yy_current_buffer ) | ||
1890 | yy_current_buffer = | ||
1891 | yy_create_buffer( yyin, YY_BUF_SIZE ); | ||
1892 | |||
1893 | yy_load_buffer_state(); | ||
1894 | } | ||
1895 | |||
1896 | while ( 1 ) /* loops until end-of-file is reached */ | ||
1897 | { | ||
1898 | yy_cp = yy_c_buf_p; | ||
1899 | |||
1900 | /* Support of yytext. */ | ||
1901 | *yy_cp = yy_hold_char; | ||
1902 | |||
1903 | /* yy_bp points to the position in yy_ch_buf of the start of | ||
1904 | * the current run. | ||
1905 | */ | ||
1906 | yy_bp = yy_cp; | ||
1907 | |||
1908 | yy_current_state = yy_start; | ||
1909 | yy_match: | ||
1910 | while ( (yy_current_state = yy_nxt[yy_current_state][yy_ec[YY_SC_TO_UI(*yy_cp)]]) > 0 ) | ||
1911 | ++yy_cp; | ||
1912 | |||
1913 | yy_current_state = -yy_current_state; | ||
1914 | |||
1915 | yy_find_action: | ||
1916 | yy_act = yy_accept[yy_current_state]; | ||
1917 | |||
1918 | YY_DO_BEFORE_ACTION; | ||
1919 | |||
1920 | |||
1921 | do_action: /* This label is used only to access EOF actions. */ | ||
1922 | |||
1923 | |||
1924 | switch ( yy_act ) | ||
1925 | { /* beginning of action switch */ | ||
1926 | case 1: | ||
1927 | YY_RULE_SETUP | ||
1928 | #line 75 "zconf.l" | ||
1929 | current_file->lineno++; | ||
1930 | YY_BREAK | ||
1931 | case 2: | ||
1932 | YY_RULE_SETUP | ||
1933 | #line 76 "zconf.l" | ||
1934 | |||
1935 | YY_BREAK | ||
1936 | case 3: | ||
1937 | YY_RULE_SETUP | ||
1938 | #line 78 "zconf.l" | ||
1939 | current_file->lineno++; return T_EOL; | ||
1940 | YY_BREAK | ||
1941 | case 4: | ||
1942 | YY_RULE_SETUP | ||
1943 | #line 80 "zconf.l" | ||
1944 | { | ||
1945 | BEGIN(COMMAND); | ||
1946 | } | ||
1947 | YY_BREAK | ||
1948 | case 5: | ||
1949 | YY_RULE_SETUP | ||
1950 | #line 84 "zconf.l" | ||
1951 | { | ||
1952 | unput(yytext[0]); | ||
1953 | BEGIN(COMMAND); | ||
1954 | } | ||
1955 | YY_BREAK | ||
1956 | |||
1957 | case 6: | ||
1958 | YY_RULE_SETUP | ||
1959 | #line 91 "zconf.l" | ||
1960 | BEGIN(PARAM); return T_MAINMENU; | ||
1961 | YY_BREAK | ||
1962 | case 7: | ||
1963 | YY_RULE_SETUP | ||
1964 | #line 92 "zconf.l" | ||
1965 | BEGIN(PARAM); return T_MENU; | ||
1966 | YY_BREAK | ||
1967 | case 8: | ||
1968 | YY_RULE_SETUP | ||
1969 | #line 93 "zconf.l" | ||
1970 | BEGIN(PARAM); return T_ENDMENU; | ||
1971 | YY_BREAK | ||
1972 | case 9: | ||
1973 | YY_RULE_SETUP | ||
1974 | #line 94 "zconf.l" | ||
1975 | BEGIN(PARAM); return T_SOURCE; | ||
1976 | YY_BREAK | ||
1977 | case 10: | ||
1978 | YY_RULE_SETUP | ||
1979 | #line 95 "zconf.l" | ||
1980 | BEGIN(PARAM); return T_CHOICE; | ||
1981 | YY_BREAK | ||
1982 | case 11: | ||
1983 | YY_RULE_SETUP | ||
1984 | #line 96 "zconf.l" | ||
1985 | BEGIN(PARAM); return T_ENDCHOICE; | ||
1986 | YY_BREAK | ||
1987 | case 12: | ||
1988 | YY_RULE_SETUP | ||
1989 | #line 97 "zconf.l" | ||
1990 | BEGIN(PARAM); return T_COMMENT; | ||
1991 | YY_BREAK | ||
1992 | case 13: | ||
1993 | YY_RULE_SETUP | ||
1994 | #line 98 "zconf.l" | ||
1995 | BEGIN(PARAM); return T_CONFIG; | ||
1996 | YY_BREAK | ||
1997 | case 14: | ||
1998 | YY_RULE_SETUP | ||
1999 | #line 99 "zconf.l" | ||
2000 | BEGIN(PARAM); return T_HELP; | ||
2001 | YY_BREAK | ||
2002 | case 15: | ||
2003 | YY_RULE_SETUP | ||
2004 | #line 100 "zconf.l" | ||
2005 | BEGIN(PARAM); return T_IF; | ||
2006 | YY_BREAK | ||
2007 | case 16: | ||
2008 | YY_RULE_SETUP | ||
2009 | #line 101 "zconf.l" | ||
2010 | BEGIN(PARAM); return T_ENDIF; | ||
2011 | YY_BREAK | ||
2012 | case 17: | ||
2013 | YY_RULE_SETUP | ||
2014 | #line 102 "zconf.l" | ||
2015 | BEGIN(PARAM); return T_DEPENDS; | ||
2016 | YY_BREAK | ||
2017 | case 18: | ||
2018 | YY_RULE_SETUP | ||
2019 | #line 103 "zconf.l" | ||
2020 | BEGIN(PARAM); return T_REQUIRES; | ||
2021 | YY_BREAK | ||
2022 | case 19: | ||
2023 | YY_RULE_SETUP | ||
2024 | #line 104 "zconf.l" | ||
2025 | BEGIN(PARAM); return T_OPTIONAL; | ||
2026 | YY_BREAK | ||
2027 | case 20: | ||
2028 | YY_RULE_SETUP | ||
2029 | #line 105 "zconf.l" | ||
2030 | BEGIN(PARAM); return T_DEFAULT; | ||
2031 | YY_BREAK | ||
2032 | case 21: | ||
2033 | YY_RULE_SETUP | ||
2034 | #line 106 "zconf.l" | ||
2035 | BEGIN(PARAM); return T_PROMPT; | ||
2036 | YY_BREAK | ||
2037 | case 22: | ||
2038 | YY_RULE_SETUP | ||
2039 | #line 107 "zconf.l" | ||
2040 | BEGIN(PARAM); return T_TRISTATE; | ||
2041 | YY_BREAK | ||
2042 | case 23: | ||
2043 | YY_RULE_SETUP | ||
2044 | #line 108 "zconf.l" | ||
2045 | BEGIN(PARAM); return T_BOOLEAN; | ||
2046 | YY_BREAK | ||
2047 | case 24: | ||
2048 | YY_RULE_SETUP | ||
2049 | #line 109 "zconf.l" | ||
2050 | BEGIN(PARAM); return T_BOOLEAN; | ||
2051 | YY_BREAK | ||
2052 | case 25: | ||
2053 | YY_RULE_SETUP | ||
2054 | #line 110 "zconf.l" | ||
2055 | BEGIN(PARAM); return T_INT; | ||
2056 | YY_BREAK | ||
2057 | case 26: | ||
2058 | YY_RULE_SETUP | ||
2059 | #line 111 "zconf.l" | ||
2060 | BEGIN(PARAM); return T_HEX; | ||
2061 | YY_BREAK | ||
2062 | case 27: | ||
2063 | YY_RULE_SETUP | ||
2064 | #line 112 "zconf.l" | ||
2065 | BEGIN(PARAM); return T_STRING; | ||
2066 | YY_BREAK | ||
2067 | case 28: | ||
2068 | YY_RULE_SETUP | ||
2069 | #line 113 "zconf.l" | ||
2070 | { | ||
2071 | alloc_string(yytext, yyleng); | ||
2072 | zconflval.string = text; | ||
2073 | return T_WORD; | ||
2074 | } | ||
2075 | YY_BREAK | ||
2076 | case 29: | ||
2077 | YY_RULE_SETUP | ||
2078 | #line 118 "zconf.l" | ||
2079 | |||
2080 | YY_BREAK | ||
2081 | case 30: | ||
2082 | YY_RULE_SETUP | ||
2083 | #line 119 "zconf.l" | ||
2084 | current_file->lineno++; BEGIN(INITIAL); | ||
2085 | YY_BREAK | ||
2086 | |||
2087 | |||
2088 | case 31: | ||
2089 | YY_RULE_SETUP | ||
2090 | #line 123 "zconf.l" | ||
2091 | return T_AND; | ||
2092 | YY_BREAK | ||
2093 | case 32: | ||
2094 | YY_RULE_SETUP | ||
2095 | #line 124 "zconf.l" | ||
2096 | return T_OR; | ||
2097 | YY_BREAK | ||
2098 | case 33: | ||
2099 | YY_RULE_SETUP | ||
2100 | #line 125 "zconf.l" | ||
2101 | return T_OPEN_PAREN; | ||
2102 | YY_BREAK | ||
2103 | case 34: | ||
2104 | YY_RULE_SETUP | ||
2105 | #line 126 "zconf.l" | ||
2106 | return T_CLOSE_PAREN; | ||
2107 | YY_BREAK | ||
2108 | case 35: | ||
2109 | YY_RULE_SETUP | ||
2110 | #line 127 "zconf.l" | ||
2111 | return T_NOT; | ||
2112 | YY_BREAK | ||
2113 | case 36: | ||
2114 | YY_RULE_SETUP | ||
2115 | #line 128 "zconf.l" | ||
2116 | return T_EQUAL; | ||
2117 | YY_BREAK | ||
2118 | case 37: | ||
2119 | YY_RULE_SETUP | ||
2120 | #line 129 "zconf.l" | ||
2121 | return T_UNEQUAL; | ||
2122 | YY_BREAK | ||
2123 | case 38: | ||
2124 | YY_RULE_SETUP | ||
2125 | #line 130 "zconf.l" | ||
2126 | return T_IF; | ||
2127 | YY_BREAK | ||
2128 | case 39: | ||
2129 | YY_RULE_SETUP | ||
2130 | #line 131 "zconf.l" | ||
2131 | return T_ON; | ||
2132 | YY_BREAK | ||
2133 | case 40: | ||
2134 | YY_RULE_SETUP | ||
2135 | #line 132 "zconf.l" | ||
2136 | { | ||
2137 | str = yytext[0]; | ||
2138 | new_string(); | ||
2139 | BEGIN(STRING); | ||
2140 | } | ||
2141 | YY_BREAK | ||
2142 | case 41: | ||
2143 | YY_RULE_SETUP | ||
2144 | #line 137 "zconf.l" | ||
2145 | BEGIN(INITIAL); current_file->lineno++; return T_EOL; | ||
2146 | YY_BREAK | ||
2147 | case 42: | ||
2148 | YY_RULE_SETUP | ||
2149 | #line 138 "zconf.l" | ||
2150 | /* ignore */ | ||
2151 | YY_BREAK | ||
2152 | case 43: | ||
2153 | YY_RULE_SETUP | ||
2154 | #line 139 "zconf.l" | ||
2155 | { | ||
2156 | alloc_string(yytext, yyleng); | ||
2157 | zconflval.string = text; | ||
2158 | return T_WORD; | ||
2159 | } | ||
2160 | YY_BREAK | ||
2161 | case 44: | ||
2162 | YY_RULE_SETUP | ||
2163 | #line 144 "zconf.l" | ||
2164 | |||
2165 | YY_BREAK | ||
2166 | case YY_STATE_EOF(PARAM): | ||
2167 | #line 145 "zconf.l" | ||
2168 | { | ||
2169 | BEGIN(INITIAL); | ||
2170 | } | ||
2171 | YY_BREAK | ||
2172 | |||
2173 | |||
2174 | case 45: | ||
2175 | *yy_cp = yy_hold_char; /* undo effects of setting up yytext */ | ||
2176 | yy_c_buf_p = yy_cp -= 1; | ||
2177 | YY_DO_BEFORE_ACTION; /* set up yytext again */ | ||
2178 | YY_RULE_SETUP | ||
2179 | #line 151 "zconf.l" | ||
2180 | { | ||
2181 | append_string(yytext, yyleng); | ||
2182 | zconflval.string = text; | ||
2183 | return T_STRING; | ||
2184 | } | ||
2185 | YY_BREAK | ||
2186 | case 46: | ||
2187 | YY_RULE_SETUP | ||
2188 | #line 156 "zconf.l" | ||
2189 | { | ||
2190 | append_string(yytext, yyleng); | ||
2191 | } | ||
2192 | YY_BREAK | ||
2193 | case 47: | ||
2194 | *yy_cp = yy_hold_char; /* undo effects of setting up yytext */ | ||
2195 | yy_c_buf_p = yy_cp -= 1; | ||
2196 | YY_DO_BEFORE_ACTION; /* set up yytext again */ | ||
2197 | YY_RULE_SETUP | ||
2198 | #line 159 "zconf.l" | ||
2199 | { | ||
2200 | append_string(yytext+1, yyleng); | ||
2201 | zconflval.string = text; | ||
2202 | return T_STRING; | ||
2203 | } | ||
2204 | YY_BREAK | ||
2205 | case 48: | ||
2206 | YY_RULE_SETUP | ||
2207 | #line 164 "zconf.l" | ||
2208 | { | ||
2209 | append_string(yytext+1, yyleng - 1); | ||
2210 | } | ||
2211 | YY_BREAK | ||
2212 | case 49: | ||
2213 | YY_RULE_SETUP | ||
2214 | #line 167 "zconf.l" | ||
2215 | { | ||
2216 | if (str == yytext[0]) { | ||
2217 | BEGIN(PARAM); | ||
2218 | zconflval.string = text; | ||
2219 | return T_STRING; | ||
2220 | } else | ||
2221 | append_string(yytext, 1); | ||
2222 | } | ||
2223 | YY_BREAK | ||
2224 | case 50: | ||
2225 | YY_RULE_SETUP | ||
2226 | #line 175 "zconf.l" | ||
2227 | { | ||
2228 | printf("%s:%d:warning: multi-line strings not supported\n", zconf_curname(), zconf_lineno()); | ||
2229 | BEGIN(INITIAL); | ||
2230 | return T_EOL; | ||
2231 | } | ||
2232 | YY_BREAK | ||
2233 | case YY_STATE_EOF(STRING): | ||
2234 | #line 180 "zconf.l" | ||
2235 | { | ||
2236 | BEGIN(INITIAL); | ||
2237 | } | ||
2238 | YY_BREAK | ||
2239 | |||
2240 | |||
2241 | case 51: | ||
2242 | YY_RULE_SETUP | ||
2243 | #line 186 "zconf.l" | ||
2244 | { | ||
2245 | ts = 0; | ||
2246 | for (i = 0; i < yyleng; i++) { | ||
2247 | if (yytext[i] == '\t') | ||
2248 | ts = (ts & ~7) + 8; | ||
2249 | else | ||
2250 | ts++; | ||
2251 | } | ||
2252 | last_ts = ts; | ||
2253 | if (first_ts) { | ||
2254 | if (ts < first_ts) { | ||
2255 | zconf_endhelp(); | ||
2256 | return T_HELPTEXT; | ||
2257 | } | ||
2258 | ts -= first_ts; | ||
2259 | while (ts > 8) { | ||
2260 | append_string(" ", 8); | ||
2261 | ts -= 8; | ||
2262 | } | ||
2263 | append_string(" ", ts); | ||
2264 | } | ||
2265 | |||
2266 | } | ||
2267 | YY_BREAK | ||
2268 | case 52: | ||
2269 | *yy_cp = yy_hold_char; /* undo effects of setting up yytext */ | ||
2270 | yy_c_buf_p = yy_cp = yy_bp + 1; | ||
2271 | YY_DO_BEFORE_ACTION; /* set up yytext again */ | ||
2272 | YY_RULE_SETUP | ||
2273 | #line 209 "zconf.l" | ||
2274 | { | ||
2275 | current_file->lineno++; | ||
2276 | zconf_endhelp(); | ||
2277 | return T_HELPTEXT; | ||
2278 | } | ||
2279 | YY_BREAK | ||
2280 | case 53: | ||
2281 | YY_RULE_SETUP | ||
2282 | #line 214 "zconf.l" | ||
2283 | { | ||
2284 | current_file->lineno++; | ||
2285 | append_string("\n", 1); | ||
2286 | } | ||
2287 | YY_BREAK | ||
2288 | case 54: | ||
2289 | YY_RULE_SETUP | ||
2290 | #line 218 "zconf.l" | ||
2291 | { | ||
2292 | append_string(yytext, yyleng); | ||
2293 | if (!first_ts) | ||
2294 | first_ts = last_ts; | ||
2295 | } | ||
2296 | YY_BREAK | ||
2297 | case YY_STATE_EOF(HELP): | ||
2298 | #line 223 "zconf.l" | ||
2299 | { | ||
2300 | zconf_endhelp(); | ||
2301 | return T_HELPTEXT; | ||
2302 | } | ||
2303 | YY_BREAK | ||
2304 | |||
2305 | case YY_STATE_EOF(INITIAL): | ||
2306 | case YY_STATE_EOF(COMMAND): | ||
2307 | #line 229 "zconf.l" | ||
2308 | { | ||
2309 | if (current_buf) { | ||
2310 | zconf_endfile(); | ||
2311 | return T_EOF; | ||
2312 | } | ||
2313 | fclose(yyin); | ||
2314 | yyterminate(); | ||
2315 | } | ||
2316 | YY_BREAK | ||
2317 | case 55: | ||
2318 | YY_RULE_SETUP | ||
2319 | #line 238 "zconf.l" | ||
2320 | YY_FATAL_ERROR( "flex scanner jammed" ); | ||
2321 | YY_BREAK | ||
2322 | #line 2323 "lex.zconf.c" | ||
2323 | |||
2324 | case YY_END_OF_BUFFER: | ||
2325 | { | ||
2326 | /* Amount of text matched not including the EOB char. */ | ||
2327 | int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; | ||
2328 | |||
2329 | /* Undo the effects of YY_DO_BEFORE_ACTION. */ | ||
2330 | *yy_cp = yy_hold_char; | ||
2331 | YY_RESTORE_YY_MORE_OFFSET | ||
2332 | |||
2333 | if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW ) | ||
2334 | { | ||
2335 | /* We're scanning a new file or input source. It's | ||
2336 | * possible that this happened because the user | ||
2337 | * just pointed yyin at a new source and called | ||
2338 | * yylex(). If so, then we have to assure | ||
2339 | * consistency between yy_current_buffer and our | ||
2340 | * globals. Here is the right place to do so, because | ||
2341 | * this is the first action (other than possibly a | ||
2342 | * back-up) that will match for the new input source. | ||
2343 | */ | ||
2344 | yy_n_chars = yy_current_buffer->yy_n_chars; | ||
2345 | yy_current_buffer->yy_input_file = yyin; | ||
2346 | yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL; | ||
2347 | } | ||
2348 | |||
2349 | /* Note that here we test for yy_c_buf_p "<=" to the position | ||
2350 | * of the first EOB in the buffer, since yy_c_buf_p will | ||
2351 | * already have been incremented past the NUL character | ||
2352 | * (since all states make transitions on EOB to the | ||
2353 | * end-of-buffer state). Contrast this with the test | ||
2354 | * in input(). | ||
2355 | */ | ||
2356 | if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) | ||
2357 | { /* This was really a NUL. */ | ||
2358 | yy_state_type yy_next_state; | ||
2359 | |||
2360 | yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; | ||
2361 | |||
2362 | yy_current_state = yy_get_previous_state(); | ||
2363 | |||
2364 | /* Okay, we're now positioned to make the NUL | ||
2365 | * transition. We couldn't have | ||
2366 | * yy_get_previous_state() go ahead and do it | ||
2367 | * for us because it doesn't know how to deal | ||
2368 | * with the possibility of jamming (and we don't | ||
2369 | * want to build jamming into it because then it | ||
2370 | * will run more slowly). | ||
2371 | */ | ||
2372 | |||
2373 | yy_next_state = yy_try_NUL_trans( yy_current_state ); | ||
2374 | |||
2375 | yy_bp = yytext_ptr + YY_MORE_ADJ; | ||
2376 | |||
2377 | if ( yy_next_state ) | ||
2378 | { | ||
2379 | /* Consume the NUL. */ | ||
2380 | yy_cp = ++yy_c_buf_p; | ||
2381 | yy_current_state = yy_next_state; | ||
2382 | goto yy_match; | ||
2383 | } | ||
2384 | |||
2385 | else | ||
2386 | { | ||
2387 | yy_cp = yy_c_buf_p; | ||
2388 | goto yy_find_action; | ||
2389 | } | ||
2390 | } | ||
2391 | |||
2392 | else switch ( yy_get_next_buffer() ) | ||
2393 | { | ||
2394 | case EOB_ACT_END_OF_FILE: | ||
2395 | { | ||
2396 | yy_did_buffer_switch_on_eof = 0; | ||
2397 | |||
2398 | if ( yywrap() ) | ||
2399 | { | ||
2400 | /* Note: because we've taken care in | ||
2401 | * yy_get_next_buffer() to have set up | ||
2402 | * yytext, we can now set up | ||
2403 | * yy_c_buf_p so that if some total | ||
2404 | * hoser (like flex itself) wants to | ||
2405 | * call the scanner after we return the | ||
2406 | * YY_NULL, it'll still work - another | ||
2407 | * YY_NULL will get returned. | ||
2408 | */ | ||
2409 | yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; | ||
2410 | |||
2411 | yy_act = YY_STATE_EOF(YY_START); | ||
2412 | goto do_action; | ||
2413 | } | ||
2414 | |||
2415 | else | ||
2416 | { | ||
2417 | if ( ! yy_did_buffer_switch_on_eof ) | ||
2418 | YY_NEW_FILE; | ||
2419 | } | ||
2420 | break; | ||
2421 | } | ||
2422 | |||
2423 | case EOB_ACT_CONTINUE_SCAN: | ||
2424 | yy_c_buf_p = | ||
2425 | yytext_ptr + yy_amount_of_matched_text; | ||
2426 | |||
2427 | yy_current_state = yy_get_previous_state(); | ||
2428 | |||
2429 | yy_cp = yy_c_buf_p; | ||
2430 | yy_bp = yytext_ptr + YY_MORE_ADJ; | ||
2431 | goto yy_match; | ||
2432 | |||
2433 | case EOB_ACT_LAST_MATCH: | ||
2434 | yy_c_buf_p = | ||
2435 | &yy_current_buffer->yy_ch_buf[yy_n_chars]; | ||
2436 | |||
2437 | yy_current_state = yy_get_previous_state(); | ||
2438 | |||
2439 | yy_cp = yy_c_buf_p; | ||
2440 | yy_bp = yytext_ptr + YY_MORE_ADJ; | ||
2441 | goto yy_find_action; | ||
2442 | } | ||
2443 | break; | ||
2444 | } | ||
2445 | |||
2446 | default: | ||
2447 | YY_FATAL_ERROR( | ||
2448 | "fatal flex scanner internal error--no action found" ); | ||
2449 | } /* end of action switch */ | ||
2450 | } /* end of scanning one token */ | ||
2451 | } /* end of yylex */ | ||
2452 | |||
2453 | |||
2454 | /* yy_get_next_buffer - try to read in a new buffer | ||
2455 | * | ||
2456 | * Returns a code representing an action: | ||
2457 | * EOB_ACT_LAST_MATCH - | ||
2458 | * EOB_ACT_CONTINUE_SCAN - continue scanning from current position | ||
2459 | * EOB_ACT_END_OF_FILE - end of file | ||
2460 | */ | ||
2461 | |||
2462 | static int yy_get_next_buffer() | ||
2463 | { | ||
2464 | register char *dest = yy_current_buffer->yy_ch_buf; | ||
2465 | register char *source = yytext_ptr; | ||
2466 | register int number_to_move, i; | ||
2467 | int ret_val; | ||
2468 | |||
2469 | if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) | ||
2470 | YY_FATAL_ERROR( | ||
2471 | "fatal flex scanner internal error--end of buffer missed" ); | ||
2472 | |||
2473 | if ( yy_current_buffer->yy_fill_buffer == 0 ) | ||
2474 | { /* Don't try to fill the buffer, so this is an EOF. */ | ||
2475 | if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 ) | ||
2476 | { | ||
2477 | /* We matched a single character, the EOB, so | ||
2478 | * treat this as a final EOF. | ||
2479 | */ | ||
2480 | return EOB_ACT_END_OF_FILE; | ||
2481 | } | ||
2482 | |||
2483 | else | ||
2484 | { | ||
2485 | /* We matched some text prior to the EOB, first | ||
2486 | * process it. | ||
2487 | */ | ||
2488 | return EOB_ACT_LAST_MATCH; | ||
2489 | } | ||
2490 | } | ||
2491 | |||
2492 | /* Try to read more data. */ | ||
2493 | |||
2494 | /* First move last chars to start of buffer. */ | ||
2495 | number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1; | ||
2496 | |||
2497 | for ( i = 0; i < number_to_move; ++i ) | ||
2498 | *(dest++) = *(source++); | ||
2499 | |||
2500 | if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING ) | ||
2501 | /* don't do the read, it's not guaranteed to return an EOF, | ||
2502 | * just force an EOF | ||
2503 | */ | ||
2504 | yy_current_buffer->yy_n_chars = yy_n_chars = 0; | ||
2505 | |||
2506 | else | ||
2507 | { | ||
2508 | int num_to_read = | ||
2509 | yy_current_buffer->yy_buf_size - number_to_move - 1; | ||
2510 | |||
2511 | while ( num_to_read <= 0 ) | ||
2512 | { /* Not enough room in the buffer - grow it. */ | ||
2513 | #ifdef YY_USES_REJECT | ||
2514 | YY_FATAL_ERROR( | ||
2515 | "input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); | ||
2516 | #else | ||
2517 | |||
2518 | /* just a shorter name for the current buffer */ | ||
2519 | YY_BUFFER_STATE b = yy_current_buffer; | ||
2520 | |||
2521 | int yy_c_buf_p_offset = | ||
2522 | (int) (yy_c_buf_p - b->yy_ch_buf); | ||
2523 | |||
2524 | if ( b->yy_is_our_buffer ) | ||
2525 | { | ||
2526 | int new_size = b->yy_buf_size * 2; | ||
2527 | |||
2528 | if ( new_size <= 0 ) | ||
2529 | b->yy_buf_size += b->yy_buf_size / 8; | ||
2530 | else | ||
2531 | b->yy_buf_size *= 2; | ||
2532 | |||
2533 | b->yy_ch_buf = (char *) | ||
2534 | /* Include room in for 2 EOB chars. */ | ||
2535 | yy_flex_realloc( (void *) b->yy_ch_buf, | ||
2536 | b->yy_buf_size + 2 ); | ||
2537 | } | ||
2538 | else | ||
2539 | /* Can't grow it, we don't own it. */ | ||
2540 | b->yy_ch_buf = 0; | ||
2541 | |||
2542 | if ( ! b->yy_ch_buf ) | ||
2543 | YY_FATAL_ERROR( | ||
2544 | "fatal error - scanner input buffer overflow" ); | ||
2545 | |||
2546 | yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; | ||
2547 | |||
2548 | num_to_read = yy_current_buffer->yy_buf_size - | ||
2549 | number_to_move - 1; | ||
2550 | #endif | ||
2551 | } | ||
2552 | |||
2553 | if ( num_to_read > YY_READ_BUF_SIZE ) | ||
2554 | num_to_read = YY_READ_BUF_SIZE; | ||
2555 | |||
2556 | /* Read in more data. */ | ||
2557 | YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), | ||
2558 | yy_n_chars, num_to_read ); | ||
2559 | |||
2560 | yy_current_buffer->yy_n_chars = yy_n_chars; | ||
2561 | } | ||
2562 | |||
2563 | if ( yy_n_chars == 0 ) | ||
2564 | { | ||
2565 | if ( number_to_move == YY_MORE_ADJ ) | ||
2566 | { | ||
2567 | ret_val = EOB_ACT_END_OF_FILE; | ||
2568 | yyrestart( yyin ); | ||
2569 | } | ||
2570 | |||
2571 | else | ||
2572 | { | ||
2573 | ret_val = EOB_ACT_LAST_MATCH; | ||
2574 | yy_current_buffer->yy_buffer_status = | ||
2575 | YY_BUFFER_EOF_PENDING; | ||
2576 | } | ||
2577 | } | ||
2578 | |||
2579 | else | ||
2580 | ret_val = EOB_ACT_CONTINUE_SCAN; | ||
2581 | |||
2582 | yy_n_chars += number_to_move; | ||
2583 | yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; | ||
2584 | yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; | ||
2585 | |||
2586 | yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; | ||
2587 | |||
2588 | return ret_val; | ||
2589 | } | ||
2590 | |||
2591 | |||
2592 | /* yy_get_previous_state - get the state just before the EOB char was reached */ | ||
2593 | |||
2594 | static yy_state_type yy_get_previous_state() | ||
2595 | { | ||
2596 | register yy_state_type yy_current_state; | ||
2597 | register char *yy_cp; | ||
2598 | |||
2599 | yy_current_state = yy_start; | ||
2600 | |||
2601 | for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) | ||
2602 | { | ||
2603 | yy_current_state = yy_nxt[yy_current_state][(*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1)]; | ||
2604 | } | ||
2605 | |||
2606 | return yy_current_state; | ||
2607 | } | ||
2608 | |||
2609 | |||
2610 | /* yy_try_NUL_trans - try to make a transition on the NUL character | ||
2611 | * | ||
2612 | * synopsis | ||
2613 | * next_state = yy_try_NUL_trans( current_state ); | ||
2614 | */ | ||
2615 | |||
2616 | #ifdef YY_USE_PROTOS | ||
2617 | static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) | ||
2618 | #else | ||
2619 | static yy_state_type yy_try_NUL_trans( yy_current_state ) | ||
2620 | yy_state_type yy_current_state; | ||
2621 | #endif | ||
2622 | { | ||
2623 | register int yy_is_jam; | ||
2624 | |||
2625 | yy_current_state = yy_nxt[yy_current_state][1]; | ||
2626 | yy_is_jam = (yy_current_state <= 0); | ||
2627 | |||
2628 | return yy_is_jam ? 0 : yy_current_state; | ||
2629 | } | ||
2630 | |||
2631 | |||
2632 | #ifndef YY_NO_UNPUT | ||
2633 | #ifdef YY_USE_PROTOS | ||
2634 | static void yyunput( int c, register char *yy_bp ) | ||
2635 | #else | ||
2636 | static void yyunput( c, yy_bp ) | ||
2637 | int c; | ||
2638 | register char *yy_bp; | ||
2639 | #endif | ||
2640 | { | ||
2641 | register char *yy_cp = yy_c_buf_p; | ||
2642 | |||
2643 | /* undo effects of setting up yytext */ | ||
2644 | *yy_cp = yy_hold_char; | ||
2645 | |||
2646 | if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) | ||
2647 | { /* need to shift things up to make room */ | ||
2648 | /* +2 for EOB chars. */ | ||
2649 | register int number_to_move = yy_n_chars + 2; | ||
2650 | register char *dest = &yy_current_buffer->yy_ch_buf[ | ||
2651 | yy_current_buffer->yy_buf_size + 2]; | ||
2652 | register char *source = | ||
2653 | &yy_current_buffer->yy_ch_buf[number_to_move]; | ||
2654 | |||
2655 | while ( source > yy_current_buffer->yy_ch_buf ) | ||
2656 | *--dest = *--source; | ||
2657 | |||
2658 | yy_cp += (int) (dest - source); | ||
2659 | yy_bp += (int) (dest - source); | ||
2660 | yy_current_buffer->yy_n_chars = | ||
2661 | yy_n_chars = yy_current_buffer->yy_buf_size; | ||
2662 | |||
2663 | if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) | ||
2664 | YY_FATAL_ERROR( "flex scanner push-back overflow" ); | ||
2665 | } | ||
2666 | |||
2667 | *--yy_cp = (char) c; | ||
2668 | |||
2669 | |||
2670 | yytext_ptr = yy_bp; | ||
2671 | yy_hold_char = *yy_cp; | ||
2672 | yy_c_buf_p = yy_cp; | ||
2673 | } | ||
2674 | #endif /* ifndef YY_NO_UNPUT */ | ||
2675 | |||
2676 | |||
2677 | #ifdef __cplusplus | ||
2678 | static int yyinput() | ||
2679 | #else | ||
2680 | static int input() | ||
2681 | #endif | ||
2682 | { | ||
2683 | int c; | ||
2684 | |||
2685 | *yy_c_buf_p = yy_hold_char; | ||
2686 | |||
2687 | if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) | ||
2688 | { | ||
2689 | /* yy_c_buf_p now points to the character we want to return. | ||
2690 | * If this occurs *before* the EOB characters, then it's a | ||
2691 | * valid NUL; if not, then we've hit the end of the buffer. | ||
2692 | */ | ||
2693 | if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) | ||
2694 | /* This was really a NUL. */ | ||
2695 | *yy_c_buf_p = '\0'; | ||
2696 | |||
2697 | else | ||
2698 | { /* need more input */ | ||
2699 | int offset = yy_c_buf_p - yytext_ptr; | ||
2700 | ++yy_c_buf_p; | ||
2701 | |||
2702 | switch ( yy_get_next_buffer() ) | ||
2703 | { | ||
2704 | case EOB_ACT_LAST_MATCH: | ||
2705 | /* This happens because yy_g_n_b() | ||
2706 | * sees that we've accumulated a | ||
2707 | * token and flags that we need to | ||
2708 | * try matching the token before | ||
2709 | * proceeding. But for input(), | ||
2710 | * there's no matching to consider. | ||
2711 | * So convert the EOB_ACT_LAST_MATCH | ||
2712 | * to EOB_ACT_END_OF_FILE. | ||
2713 | */ | ||
2714 | |||
2715 | /* Reset buffer status. */ | ||
2716 | yyrestart( yyin ); | ||
2717 | |||
2718 | /* fall through */ | ||
2719 | |||
2720 | case EOB_ACT_END_OF_FILE: | ||
2721 | { | ||
2722 | if ( yywrap() ) | ||
2723 | return EOF; | ||
2724 | |||
2725 | if ( ! yy_did_buffer_switch_on_eof ) | ||
2726 | YY_NEW_FILE; | ||
2727 | #ifdef __cplusplus | ||
2728 | return yyinput(); | ||
2729 | #else | ||
2730 | return input(); | ||
2731 | #endif | ||
2732 | } | ||
2733 | |||
2734 | case EOB_ACT_CONTINUE_SCAN: | ||
2735 | yy_c_buf_p = yytext_ptr + offset; | ||
2736 | break; | ||
2737 | } | ||
2738 | } | ||
2739 | } | ||
2740 | |||
2741 | c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */ | ||
2742 | *yy_c_buf_p = '\0'; /* preserve yytext */ | ||
2743 | yy_hold_char = *++yy_c_buf_p; | ||
2744 | |||
2745 | |||
2746 | return c; | ||
2747 | } | ||
2748 | |||
2749 | |||
2750 | #ifdef YY_USE_PROTOS | ||
2751 | void yyrestart( FILE *input_file ) | ||
2752 | #else | ||
2753 | void yyrestart( input_file ) | ||
2754 | FILE *input_file; | ||
2755 | #endif | ||
2756 | { | ||
2757 | if ( ! yy_current_buffer ) | ||
2758 | yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); | ||
2759 | |||
2760 | yy_init_buffer( yy_current_buffer, input_file ); | ||
2761 | yy_load_buffer_state(); | ||
2762 | } | ||
2763 | |||
2764 | |||
2765 | #ifdef YY_USE_PROTOS | ||
2766 | void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) | ||
2767 | #else | ||
2768 | void yy_switch_to_buffer( new_buffer ) | ||
2769 | YY_BUFFER_STATE new_buffer; | ||
2770 | #endif | ||
2771 | { | ||
2772 | if ( yy_current_buffer == new_buffer ) | ||
2773 | return; | ||
2774 | |||
2775 | if ( yy_current_buffer ) | ||
2776 | { | ||
2777 | /* Flush out information for old buffer. */ | ||
2778 | *yy_c_buf_p = yy_hold_char; | ||
2779 | yy_current_buffer->yy_buf_pos = yy_c_buf_p; | ||
2780 | yy_current_buffer->yy_n_chars = yy_n_chars; | ||
2781 | } | ||
2782 | |||
2783 | yy_current_buffer = new_buffer; | ||
2784 | yy_load_buffer_state(); | ||
2785 | |||
2786 | /* We don't actually know whether we did this switch during | ||
2787 | * EOF (yywrap()) processing, but the only time this flag | ||
2788 | * is looked at is after yywrap() is called, so it's safe | ||
2789 | * to go ahead and always set it. | ||
2790 | */ | ||
2791 | yy_did_buffer_switch_on_eof = 1; | ||
2792 | } | ||
2793 | |||
2794 | |||
2795 | #ifdef YY_USE_PROTOS | ||
2796 | void yy_load_buffer_state( void ) | ||
2797 | #else | ||
2798 | void yy_load_buffer_state() | ||
2799 | #endif | ||
2800 | { | ||
2801 | yy_n_chars = yy_current_buffer->yy_n_chars; | ||
2802 | yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; | ||
2803 | yyin = yy_current_buffer->yy_input_file; | ||
2804 | yy_hold_char = *yy_c_buf_p; | ||
2805 | } | ||
2806 | |||
2807 | |||
2808 | #ifdef YY_USE_PROTOS | ||
2809 | YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) | ||
2810 | #else | ||
2811 | YY_BUFFER_STATE yy_create_buffer( file, size ) | ||
2812 | FILE *file; | ||
2813 | int size; | ||
2814 | #endif | ||
2815 | { | ||
2816 | YY_BUFFER_STATE b; | ||
2817 | |||
2818 | b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); | ||
2819 | if ( ! b ) | ||
2820 | YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); | ||
2821 | |||
2822 | b->yy_buf_size = size; | ||
2823 | |||
2824 | /* yy_ch_buf has to be 2 characters longer than the size given because | ||
2825 | * we need to put in 2 end-of-buffer characters. | ||
2826 | */ | ||
2827 | b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 ); | ||
2828 | if ( ! b->yy_ch_buf ) | ||
2829 | YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); | ||
2830 | |||
2831 | b->yy_is_our_buffer = 1; | ||
2832 | |||
2833 | yy_init_buffer( b, file ); | ||
2834 | |||
2835 | return b; | ||
2836 | } | ||
2837 | |||
2838 | |||
2839 | #ifdef YY_USE_PROTOS | ||
2840 | void yy_delete_buffer( YY_BUFFER_STATE b ) | ||
2841 | #else | ||
2842 | void yy_delete_buffer( b ) | ||
2843 | YY_BUFFER_STATE b; | ||
2844 | #endif | ||
2845 | { | ||
2846 | if ( ! b ) | ||
2847 | return; | ||
2848 | |||
2849 | if ( b == yy_current_buffer ) | ||
2850 | yy_current_buffer = (YY_BUFFER_STATE) 0; | ||
2851 | |||
2852 | if ( b->yy_is_our_buffer ) | ||
2853 | yy_flex_free( (void *) b->yy_ch_buf ); | ||
2854 | |||
2855 | yy_flex_free( (void *) b ); | ||
2856 | } | ||
2857 | |||
2858 | |||
2859 | #ifndef _WIN32 | ||
2860 | #include <unistd.h> | ||
2861 | #else | ||
2862 | #ifndef YY_ALWAYS_INTERACTIVE | ||
2863 | #ifndef YY_NEVER_INTERACTIVE | ||
2864 | extern int isatty YY_PROTO(( int )); | ||
2865 | #endif | ||
2866 | #endif | ||
2867 | #endif | ||
2868 | |||
2869 | #ifdef YY_USE_PROTOS | ||
2870 | void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) | ||
2871 | #else | ||
2872 | void yy_init_buffer( b, file ) | ||
2873 | YY_BUFFER_STATE b; | ||
2874 | FILE *file; | ||
2875 | #endif | ||
2876 | |||
2877 | |||
2878 | { | ||
2879 | yy_flush_buffer( b ); | ||
2880 | |||
2881 | b->yy_input_file = file; | ||
2882 | b->yy_fill_buffer = 1; | ||
2883 | |||
2884 | #if YY_ALWAYS_INTERACTIVE | ||
2885 | b->yy_is_interactive = 1; | ||
2886 | #else | ||
2887 | #if YY_NEVER_INTERACTIVE | ||
2888 | b->yy_is_interactive = 0; | ||
2889 | #else | ||
2890 | b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; | ||
2891 | #endif | ||
2892 | #endif | ||
2893 | } | ||
2894 | |||
2895 | |||
2896 | #ifdef YY_USE_PROTOS | ||
2897 | void yy_flush_buffer( YY_BUFFER_STATE b ) | ||
2898 | #else | ||
2899 | void yy_flush_buffer( b ) | ||
2900 | YY_BUFFER_STATE b; | ||
2901 | #endif | ||
2902 | |||
2903 | { | ||
2904 | if ( ! b ) | ||
2905 | return; | ||
2906 | |||
2907 | b->yy_n_chars = 0; | ||
2908 | |||
2909 | /* We always need two end-of-buffer characters. The first causes | ||
2910 | * a transition to the end-of-buffer state. The second causes | ||
2911 | * a jam in that state. | ||
2912 | */ | ||
2913 | b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; | ||
2914 | b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; | ||
2915 | |||
2916 | b->yy_buf_pos = &b->yy_ch_buf[0]; | ||
2917 | |||
2918 | b->yy_at_bol = 1; | ||
2919 | b->yy_buffer_status = YY_BUFFER_NEW; | ||
2920 | |||
2921 | if ( b == yy_current_buffer ) | ||
2922 | yy_load_buffer_state(); | ||
2923 | } | ||
2924 | |||
2925 | |||
2926 | #ifndef YY_NO_SCAN_BUFFER | ||
2927 | #ifdef YY_USE_PROTOS | ||
2928 | YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) | ||
2929 | #else | ||
2930 | YY_BUFFER_STATE yy_scan_buffer( base, size ) | ||
2931 | char *base; | ||
2932 | yy_size_t size; | ||
2933 | #endif | ||
2934 | { | ||
2935 | YY_BUFFER_STATE b; | ||
2936 | |||
2937 | if ( size < 2 || | ||
2938 | base[size-2] != YY_END_OF_BUFFER_CHAR || | ||
2939 | base[size-1] != YY_END_OF_BUFFER_CHAR ) | ||
2940 | /* They forgot to leave room for the EOB's. */ | ||
2941 | return 0; | ||
2942 | |||
2943 | b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); | ||
2944 | if ( ! b ) | ||
2945 | YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); | ||
2946 | |||
2947 | b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ | ||
2948 | b->yy_buf_pos = b->yy_ch_buf = base; | ||
2949 | b->yy_is_our_buffer = 0; | ||
2950 | b->yy_input_file = 0; | ||
2951 | b->yy_n_chars = b->yy_buf_size; | ||
2952 | b->yy_is_interactive = 0; | ||
2953 | b->yy_at_bol = 1; | ||
2954 | b->yy_fill_buffer = 0; | ||
2955 | b->yy_buffer_status = YY_BUFFER_NEW; | ||
2956 | |||
2957 | yy_switch_to_buffer( b ); | ||
2958 | |||
2959 | return b; | ||
2960 | } | ||
2961 | #endif | ||
2962 | |||
2963 | |||
2964 | #ifndef YY_NO_SCAN_STRING | ||
2965 | #ifdef YY_USE_PROTOS | ||
2966 | YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) | ||
2967 | #else | ||
2968 | YY_BUFFER_STATE yy_scan_string( yy_str ) | ||
2969 | yyconst char *yy_str; | ||
2970 | #endif | ||
2971 | { | ||
2972 | int len; | ||
2973 | for ( len = 0; yy_str[len]; ++len ) | ||
2974 | ; | ||
2975 | |||
2976 | return yy_scan_bytes( yy_str, len ); | ||
2977 | } | ||
2978 | #endif | ||
2979 | |||
2980 | |||
2981 | #ifndef YY_NO_SCAN_BYTES | ||
2982 | #ifdef YY_USE_PROTOS | ||
2983 | YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) | ||
2984 | #else | ||
2985 | YY_BUFFER_STATE yy_scan_bytes( bytes, len ) | ||
2986 | yyconst char *bytes; | ||
2987 | int len; | ||
2988 | #endif | ||
2989 | { | ||
2990 | YY_BUFFER_STATE b; | ||
2991 | char *buf; | ||
2992 | yy_size_t n; | ||
2993 | int i; | ||
2994 | |||
2995 | /* Get memory for full buffer, including space for trailing EOB's. */ | ||
2996 | n = len + 2; | ||
2997 | buf = (char *) yy_flex_alloc( n ); | ||
2998 | if ( ! buf ) | ||
2999 | YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); | ||
3000 | |||
3001 | for ( i = 0; i < len; ++i ) | ||
3002 | buf[i] = bytes[i]; | ||
3003 | |||
3004 | buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; | ||
3005 | |||
3006 | b = yy_scan_buffer( buf, n ); | ||
3007 | if ( ! b ) | ||
3008 | YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); | ||
3009 | |||
3010 | /* It's okay to grow etc. this buffer, and we should throw it | ||
3011 | * away when we're done. | ||
3012 | */ | ||
3013 | b->yy_is_our_buffer = 1; | ||
3014 | |||
3015 | return b; | ||
3016 | } | ||
3017 | #endif | ||
3018 | |||
3019 | |||
3020 | #ifndef YY_NO_PUSH_STATE | ||
3021 | #ifdef YY_USE_PROTOS | ||
3022 | static void yy_push_state( int new_state ) | ||
3023 | #else | ||
3024 | static void yy_push_state( new_state ) | ||
3025 | int new_state; | ||
3026 | #endif | ||
3027 | { | ||
3028 | if ( yy_start_stack_ptr >= yy_start_stack_depth ) | ||
3029 | { | ||
3030 | yy_size_t new_size; | ||
3031 | |||
3032 | yy_start_stack_depth += YY_START_STACK_INCR; | ||
3033 | new_size = yy_start_stack_depth * sizeof( int ); | ||
3034 | |||
3035 | if ( ! yy_start_stack ) | ||
3036 | yy_start_stack = (int *) yy_flex_alloc( new_size ); | ||
3037 | |||
3038 | else | ||
3039 | yy_start_stack = (int *) yy_flex_realloc( | ||
3040 | (void *) yy_start_stack, new_size ); | ||
3041 | |||
3042 | if ( ! yy_start_stack ) | ||
3043 | YY_FATAL_ERROR( | ||
3044 | "out of memory expanding start-condition stack" ); | ||
3045 | } | ||
3046 | |||
3047 | yy_start_stack[yy_start_stack_ptr++] = YY_START; | ||
3048 | |||
3049 | BEGIN(new_state); | ||
3050 | } | ||
3051 | #endif | ||
3052 | |||
3053 | |||
3054 | #ifndef YY_NO_POP_STATE | ||
3055 | static void yy_pop_state() | ||
3056 | { | ||
3057 | if ( --yy_start_stack_ptr < 0 ) | ||
3058 | YY_FATAL_ERROR( "start-condition stack underflow" ); | ||
3059 | |||
3060 | BEGIN(yy_start_stack[yy_start_stack_ptr]); | ||
3061 | } | ||
3062 | #endif | ||
3063 | |||
3064 | |||
3065 | #ifndef YY_NO_TOP_STATE | ||
3066 | static int yy_top_state() | ||
3067 | { | ||
3068 | return yy_start_stack[yy_start_stack_ptr - 1]; | ||
3069 | } | ||
3070 | #endif | ||
3071 | |||
3072 | #ifndef YY_EXIT_FAILURE | ||
3073 | #define YY_EXIT_FAILURE 2 | ||
3074 | #endif | ||
3075 | |||
3076 | #ifdef YY_USE_PROTOS | ||
3077 | static void yy_fatal_error( yyconst char msg[] ) | ||
3078 | #else | ||
3079 | static void yy_fatal_error( msg ) | ||
3080 | char msg[]; | ||
3081 | #endif | ||
3082 | { | ||
3083 | (void) fprintf( stderr, "%s\n", msg ); | ||
3084 | exit( YY_EXIT_FAILURE ); | ||
3085 | } | ||
3086 | |||
3087 | |||
3088 | |||
3089 | /* Redefine yyless() so it works in section 3 code. */ | ||
3090 | |||
3091 | #undef yyless | ||
3092 | #define yyless(n) \ | ||
3093 | do \ | ||
3094 | { \ | ||
3095 | /* Undo effects of setting up yytext. */ \ | ||
3096 | yytext[yyleng] = yy_hold_char; \ | ||
3097 | yy_c_buf_p = yytext + n; \ | ||
3098 | yy_hold_char = *yy_c_buf_p; \ | ||
3099 | *yy_c_buf_p = '\0'; \ | ||
3100 | yyleng = n; \ | ||
3101 | } \ | ||
3102 | while ( 0 ) | ||
3103 | |||
3104 | |||
3105 | /* Internal utility routines. */ | ||
3106 | |||
3107 | #ifndef yytext_ptr | ||
3108 | #ifdef YY_USE_PROTOS | ||
3109 | static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) | ||
3110 | #else | ||
3111 | static void yy_flex_strncpy( s1, s2, n ) | ||
3112 | char *s1; | ||
3113 | yyconst char *s2; | ||
3114 | int n; | ||
3115 | #endif | ||
3116 | { | ||
3117 | register int i; | ||
3118 | for ( i = 0; i < n; ++i ) | ||
3119 | s1[i] = s2[i]; | ||
3120 | } | ||
3121 | #endif | ||
3122 | |||
3123 | #ifdef YY_NEED_STRLEN | ||
3124 | #ifdef YY_USE_PROTOS | ||
3125 | static int yy_flex_strlen( yyconst char *s ) | ||
3126 | #else | ||
3127 | static int yy_flex_strlen( s ) | ||
3128 | yyconst char *s; | ||
3129 | #endif | ||
3130 | { | ||
3131 | register int n; | ||
3132 | for ( n = 0; s[n]; ++n ) | ||
3133 | ; | ||
3134 | |||
3135 | return n; | ||
3136 | } | ||
3137 | #endif | ||
3138 | |||
3139 | |||
3140 | #ifdef YY_USE_PROTOS | ||
3141 | static void *yy_flex_alloc( yy_size_t size ) | ||
3142 | #else | ||
3143 | static void *yy_flex_alloc( size ) | ||
3144 | yy_size_t size; | ||
3145 | #endif | ||
3146 | { | ||
3147 | return (void *) malloc( size ); | ||
3148 | } | ||
3149 | |||
3150 | #ifdef YY_USE_PROTOS | ||
3151 | static void *yy_flex_realloc( void *ptr, yy_size_t size ) | ||
3152 | #else | ||
3153 | static void *yy_flex_realloc( ptr, size ) | ||
3154 | void *ptr; | ||
3155 | yy_size_t size; | ||
3156 | #endif | ||
3157 | { | ||
3158 | /* The cast to (char *) in the following accommodates both | ||
3159 | * implementations that use char* generic pointers, and those | ||
3160 | * that use void* generic pointers. It works with the latter | ||
3161 | * because both ANSI C and C++ allow castless assignment from | ||
3162 | * any pointer type to void*, and deal with argument conversions | ||
3163 | * as though doing an assignment. | ||
3164 | */ | ||
3165 | return (void *) realloc( (char *) ptr, size ); | ||
3166 | } | ||
3167 | |||
3168 | #ifdef YY_USE_PROTOS | ||
3169 | static void yy_flex_free( void *ptr ) | ||
3170 | #else | ||
3171 | static void yy_flex_free( ptr ) | ||
3172 | void *ptr; | ||
3173 | #endif | ||
3174 | { | ||
3175 | free( ptr ); | ||
3176 | } | ||
3177 | |||
3178 | #if YY_MAIN | ||
3179 | int main() | ||
3180 | { | ||
3181 | yylex(); | ||
3182 | return 0; | ||
3183 | } | ||
3184 | #endif | ||
3185 | #line 238 "zconf.l" | ||
3186 | |||
3187 | void zconf_starthelp(void) | ||
3188 | { | ||
3189 | new_string(); | ||
3190 | last_ts = first_ts = 0; | ||
3191 | BEGIN(HELP); | ||
3192 | } | ||
3193 | |||
3194 | static void zconf_endhelp(void) | ||
3195 | { | ||
3196 | zconflval.string = text; | ||
3197 | BEGIN(INITIAL); | ||
3198 | } | ||
3199 | |||
3200 | void zconf_initscan(const char *name) | ||
3201 | { | ||
3202 | yyin = fopen(name, "r"); | ||
3203 | if (!yyin) { | ||
3204 | printf("can't find file %s\n", name); | ||
3205 | exit(1); | ||
3206 | } | ||
3207 | |||
3208 | current_buf = malloc(sizeof(*current_buf)); | ||
3209 | memset(current_buf, 0, sizeof(*current_buf)); | ||
3210 | |||
3211 | current_file = file_lookup(name); | ||
3212 | current_file->lineno = 1; | ||
3213 | current_file->flags = FILE_BUSY; | ||
3214 | } | ||
3215 | |||
3216 | void zconf_nextfile(const char *name) | ||
3217 | { | ||
3218 | struct file *file = file_lookup(name); | ||
3219 | struct buffer *buf = malloc(sizeof(*buf)); | ||
3220 | memset(buf, 0, sizeof(*buf)); | ||
3221 | |||
3222 | current_buf->state = YY_CURRENT_BUFFER; | ||
3223 | yyin = fopen(name, "r"); | ||
3224 | if (!yyin) { | ||
3225 | printf("%s:%d: can't open file \"%s\"\n", zconf_curname(), zconf_lineno(), name); | ||
3226 | exit(1); | ||
3227 | } | ||
3228 | yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE)); | ||
3229 | buf->parent = current_buf; | ||
3230 | current_buf = buf; | ||
3231 | |||
3232 | if (file->flags & FILE_BUSY) { | ||
3233 | printf("recursive scan (%s)?\n", name); | ||
3234 | exit(1); | ||
3235 | } | ||
3236 | if (file->flags & FILE_SCANNED) { | ||
3237 | printf("file %s already scanned?\n", name); | ||
3238 | exit(1); | ||
3239 | } | ||
3240 | file->flags |= FILE_BUSY; | ||
3241 | file->lineno = 1; | ||
3242 | file->parent = current_file; | ||
3243 | current_file = file; | ||
3244 | } | ||
3245 | |||
3246 | static struct buffer *zconf_endfile(void) | ||
3247 | { | ||
3248 | struct buffer *parent; | ||
3249 | |||
3250 | current_file->flags |= FILE_SCANNED; | ||
3251 | current_file->flags &= ~FILE_BUSY; | ||
3252 | current_file = current_file->parent; | ||
3253 | |||
3254 | parent = current_buf->parent; | ||
3255 | if (parent) { | ||
3256 | fclose(yyin); | ||
3257 | yy_delete_buffer(YY_CURRENT_BUFFER); | ||
3258 | yy_switch_to_buffer(parent->state); | ||
3259 | } | ||
3260 | free(current_buf); | ||
3261 | current_buf = parent; | ||
3262 | |||
3263 | return parent; | ||
3264 | } | ||
3265 | |||
3266 | int zconf_lineno(void) | ||
3267 | { | ||
3268 | if (current_buf) | ||
3269 | return current_file->lineno; | ||
3270 | else | ||
3271 | return 0; | ||
3272 | } | ||
3273 | |||
3274 | char *zconf_curname(void) | ||
3275 | { | ||
3276 | if (current_buf) | ||
3277 | return current_file->name; | ||
3278 | else | ||
3279 | return "<none>"; | ||
3280 | } | ||
diff --git a/scripts/config/lkc.h b/scripts/config/lkc.h new file mode 100644 index 000000000..688945b87 --- /dev/null +++ b/scripts/config/lkc.h | |||
@@ -0,0 +1,106 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> | ||
3 | * Released under the terms of the GNU GPL v2.0. | ||
4 | */ | ||
5 | |||
6 | #ifndef LKC_H | ||
7 | #define LKC_H | ||
8 | |||
9 | #include "expr.h" | ||
10 | |||
11 | #ifdef __cplusplus | ||
12 | extern "C" { | ||
13 | #endif | ||
14 | |||
15 | #ifdef LKC_DIRECT_LINK | ||
16 | #define P(name,type,arg) extern type name arg | ||
17 | #else | ||
18 | #include "lkc_defs.h" | ||
19 | #define P(name,type,arg) extern type (*name ## _p) arg | ||
20 | #endif | ||
21 | #include "lkc_proto.h" | ||
22 | #undef P | ||
23 | |||
24 | void symbol_end(char *help); | ||
25 | int zconfparse(void); | ||
26 | void zconfdump(FILE *out); | ||
27 | |||
28 | extern int zconfdebug; | ||
29 | void zconf_starthelp(void); | ||
30 | void zconf_initscan(const char *name); | ||
31 | void zconf_nextfile(const char *name); | ||
32 | int zconf_lineno(void); | ||
33 | char *zconf_curname(void); | ||
34 | |||
35 | /* confdata.c */ | ||
36 | extern const char conf_def_filename[]; | ||
37 | extern char conf_filename[]; | ||
38 | |||
39 | char *conf_get_default_confname(void); | ||
40 | |||
41 | /* kconfig_load.c */ | ||
42 | void kconfig_load(void); | ||
43 | |||
44 | /* menu.c */ | ||
45 | void menu_init(void); | ||
46 | void menu_add_menu(void); | ||
47 | void menu_end_menu(void); | ||
48 | void menu_add_entry(struct symbol *sym); | ||
49 | void menu_end_entry(void); | ||
50 | struct property *create_prop(enum prop_type type); | ||
51 | void menu_add_dep(struct expr *dep); | ||
52 | struct property *menu_add_prop(int token, char *prompt, struct symbol *def, struct expr *dep); | ||
53 | void menu_finalize(struct menu *parent); | ||
54 | void menu_set_type(int type); | ||
55 | struct file *file_lookup(const char *name); | ||
56 | int file_write_dep(const char *name); | ||
57 | |||
58 | extern struct menu *current_entry; | ||
59 | extern struct menu *current_menu; | ||
60 | |||
61 | /* symbol.c */ | ||
62 | void sym_init(void); | ||
63 | void sym_clear_all_valid(void); | ||
64 | |||
65 | static inline tristate sym_get_tristate_value(struct symbol *sym) | ||
66 | { | ||
67 | return S_TRI(sym->curr); | ||
68 | } | ||
69 | |||
70 | |||
71 | static inline struct symbol *sym_get_choice_value(struct symbol *sym) | ||
72 | { | ||
73 | return (struct symbol *)S_VAL(sym->curr); | ||
74 | } | ||
75 | |||
76 | static inline bool sym_set_choice_value(struct symbol *ch, struct symbol *chval) | ||
77 | { | ||
78 | return sym_set_tristate_value(chval, yes); | ||
79 | } | ||
80 | |||
81 | static inline bool sym_is_choice(struct symbol *sym) | ||
82 | { | ||
83 | return sym->flags & SYMBOL_CHOICE ? true : false; | ||
84 | } | ||
85 | |||
86 | static inline bool sym_is_choice_value(struct symbol *sym) | ||
87 | { | ||
88 | return sym->flags & SYMBOL_CHOICEVAL ? true : false; | ||
89 | } | ||
90 | |||
91 | static inline bool sym_is_optional(struct symbol *sym) | ||
92 | { | ||
93 | return sym->flags & SYMBOL_OPTIONAL ? true : false; | ||
94 | } | ||
95 | |||
96 | static inline bool sym_has_value(struct symbol *sym) | ||
97 | { | ||
98 | //return S_VAL(sym->def) != NULL; | ||
99 | return sym->flags & SYMBOL_NEW ? false : true; | ||
100 | } | ||
101 | |||
102 | #ifdef __cplusplus | ||
103 | } | ||
104 | #endif | ||
105 | |||
106 | #endif /* LKC_H */ | ||
diff --git a/scripts/config/lkc_proto.h b/scripts/config/lkc_proto.h new file mode 100644 index 000000000..116d7593b --- /dev/null +++ b/scripts/config/lkc_proto.h | |||
@@ -0,0 +1,38 @@ | |||
1 | |||
2 | /* confdata.c */ | ||
3 | P(conf_parse,void,(const char *name)); | ||
4 | P(conf_read,int,(const char *name)); | ||
5 | P(conf_write,int,(const char *name)); | ||
6 | |||
7 | /* menu.c */ | ||
8 | P(rootmenu,struct menu,); | ||
9 | |||
10 | P(menu_is_visible,bool,(struct menu *menu)); | ||
11 | P(menu_get_prompt,const char *,(struct menu *menu)); | ||
12 | P(menu_get_root_menu,struct menu *,(struct menu *menu)); | ||
13 | P(menu_get_parent_menu,struct menu *,(struct menu *menu)); | ||
14 | |||
15 | /* symbol.c */ | ||
16 | P(symbol_hash,struct symbol *,[SYMBOL_HASHSIZE]); | ||
17 | P(sym_change_count,int,); | ||
18 | |||
19 | P(sym_lookup,struct symbol *,(const char *name, int isconst)); | ||
20 | P(sym_find,struct symbol *,(const char *name)); | ||
21 | P(sym_type_name,const char *,(int type)); | ||
22 | P(sym_calc_value,void,(struct symbol *sym)); | ||
23 | P(sym_get_type,int,(struct symbol *sym)); | ||
24 | P(sym_tristate_within_range,bool,(struct symbol *sym,tristate tri)); | ||
25 | P(sym_set_tristate_value,bool,(struct symbol *sym,tristate tri)); | ||
26 | P(sym_toggle_tristate_value,tristate,(struct symbol *sym)); | ||
27 | P(sym_string_valid,bool,(struct symbol *sym, const char *newval)); | ||
28 | P(sym_set_string_value,bool,(struct symbol *sym, const char *newval)); | ||
29 | P(sym_is_changable,bool,(struct symbol *sym)); | ||
30 | P(sym_get_choice_prop,struct property *,(struct symbol *sym)); | ||
31 | P(sym_get_default_prop,struct property *,(struct symbol *sym)); | ||
32 | P(sym_get_string_value,const char *,(struct symbol *sym)); | ||
33 | |||
34 | P(prop_get_type_name,const char *,(enum prop_type type)); | ||
35 | |||
36 | /* expr.c */ | ||
37 | P(expr_compare_type,int,(enum expr_type t1, enum expr_type t2)); | ||
38 | P(expr_print,void,(struct expr *e, void (*fn)(void *, const char *), void *data, int prevtoken)); | ||
diff --git a/scripts/config/mconf.c b/scripts/config/mconf.c new file mode 100644 index 000000000..476e78adc --- /dev/null +++ b/scripts/config/mconf.c | |||
@@ -0,0 +1,669 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> | ||
3 | * Released under the terms of the GNU GPL v2.0. | ||
4 | * | ||
5 | * Introduced single menu mode (show all sub-menus in one large tree). | ||
6 | * 2002-11-06 Petr Baudis <pasky@ucw.cz> | ||
7 | * | ||
8 | * Directly use liblxdialog library routines. | ||
9 | * 2002-11-14 Petr Baudis <pasky@ucw.cz> | ||
10 | */ | ||
11 | |||
12 | #include <sys/ioctl.h> | ||
13 | #include <sys/wait.h> | ||
14 | #include <sys/termios.h> | ||
15 | #include <ctype.h> | ||
16 | #include <errno.h> | ||
17 | #include <fcntl.h> | ||
18 | #include <limits.h> | ||
19 | #include <signal.h> | ||
20 | #include <stdarg.h> | ||
21 | #include <stdlib.h> | ||
22 | #include <string.h> | ||
23 | #include <termios.h> | ||
24 | #include <unistd.h> | ||
25 | |||
26 | #include "dialog.h" | ||
27 | |||
28 | #define LKC_DIRECT_LINK | ||
29 | #include "lkc.h" | ||
30 | |||
31 | static const char menu_instructions[] = | ||
32 | "Arrow keys navigate the menu. " | ||
33 | "<Enter> selects submenus --->. " | ||
34 | "Highlighted letters are hotkeys. " | ||
35 | "Pressing <Y> selectes a feature, while <N> will exclude a feature. " | ||
36 | "Press <Esc><Esc> to exit, <?> for Help. " | ||
37 | "Legend: [*] feature is selected [ ] feature is excluded", | ||
38 | radiolist_instructions[] = | ||
39 | "Use the arrow keys to navigate this window or " | ||
40 | "press the hotkey of the item you wish to select " | ||
41 | "followed by the <SPACE BAR>. " | ||
42 | "Press <?> for additional information about this option.", | ||
43 | inputbox_instructions_int[] = | ||
44 | "Please enter a decimal value. " | ||
45 | "Fractions will not be accepted. " | ||
46 | "Use the <TAB> key to move from the input field to the buttons below it.", | ||
47 | inputbox_instructions_hex[] = | ||
48 | "Please enter a hexadecimal value. " | ||
49 | "Use the <TAB> key to move from the input field to the buttons below it.", | ||
50 | inputbox_instructions_string[] = | ||
51 | "Please enter a string value. " | ||
52 | "Use the <TAB> key to move from the input field to the buttons below it.", | ||
53 | setmod_text[] = | ||
54 | "This feature depends on another which has been configured as a module.\n" | ||
55 | "As a result, this feature will be built as a module.", | ||
56 | nohelp_text[] = | ||
57 | "There is no help available for this option.\n", | ||
58 | load_config_text[] = | ||
59 | "Enter the name of the configuration file you wish to load. " | ||
60 | "Accept the name shown to restore the configuration you " | ||
61 | "last retrieved. Leave blank to abort.", | ||
62 | load_config_help[] = | ||
63 | "\n" | ||
64 | "For various reasons, one may wish to keep several different BusyBox\n" | ||
65 | "configurations available on a single machine.\n" | ||
66 | "\n" | ||
67 | "If you have saved a previous configuration in a file other than the\n" | ||
68 | "BusyBox default, entering the name of the file here will allow you\n" | ||
69 | "to modify that configuration.\n" | ||
70 | "\n" | ||
71 | "If you are uncertain, then you have probably never used alternate\n" | ||
72 | "configuration files. You should therefor leave this blank to abort.\n", | ||
73 | save_config_text[] = | ||
74 | "Enter a filename to which this configuration should be saved " | ||
75 | "as an alternate. Leave blank to abort.", | ||
76 | save_config_help[] = | ||
77 | "\n" | ||
78 | "For various reasons, one may wish to keep different BusyBox\n" | ||
79 | "configurations available on a single machine.\n" | ||
80 | "\n" | ||
81 | "Entering a file name here will allow you to later retrieve, modify\n" | ||
82 | "and use the current configuration as an alternate to whatever\n" | ||
83 | "configuration options you have selected at that time.\n" | ||
84 | "\n" | ||
85 | "If you are uncertain what all this means then you should probably\n" | ||
86 | "leave this blank.\n" | ||
87 | ; | ||
88 | |||
89 | static char filename[PATH_MAX+1] = ".config"; | ||
90 | static int indent = 0; | ||
91 | static struct termios ios_org; | ||
92 | static int rows, cols; | ||
93 | static struct menu *current_menu; | ||
94 | static int child_count; | ||
95 | static int single_menu_mode; | ||
96 | |||
97 | static struct dialog_list_item *items[16384]; /* FIXME: This ought to be dynamic. */ | ||
98 | static int item_no; | ||
99 | |||
100 | static void conf(struct menu *menu); | ||
101 | static void conf_choice(struct menu *menu); | ||
102 | static void conf_string(struct menu *menu); | ||
103 | static void conf_load(void); | ||
104 | static void conf_save(void); | ||
105 | static void show_textbox(const char *title, const char *text, int r, int c); | ||
106 | static void show_helptext(const char *title, const char *text); | ||
107 | static void show_help(struct menu *menu); | ||
108 | static void show_readme(void); | ||
109 | |||
110 | static void init_wsize(void) | ||
111 | { | ||
112 | struct winsize ws; | ||
113 | |||
114 | if (ioctl(1, TIOCGWINSZ, &ws) == -1) { | ||
115 | rows = 24; | ||
116 | cols = 80; | ||
117 | } else { | ||
118 | rows = ws.ws_row; | ||
119 | cols = ws.ws_col; | ||
120 | } | ||
121 | |||
122 | if (rows < 19 || cols < 80) { | ||
123 | fprintf(stderr, "Your display is too small to run Menuconfig!\n"); | ||
124 | fprintf(stderr, "It must be at least 19 lines by 80 columns.\n"); | ||
125 | exit(1); | ||
126 | } | ||
127 | |||
128 | rows -= 4; | ||
129 | cols -= 5; | ||
130 | } | ||
131 | |||
132 | static void cinit(void) | ||
133 | { | ||
134 | item_no = 0; | ||
135 | } | ||
136 | |||
137 | static void cmake(void) | ||
138 | { | ||
139 | items[item_no] = malloc(sizeof(struct dialog_list_item)); | ||
140 | memset(items[item_no], 0, sizeof(struct dialog_list_item)); | ||
141 | items[item_no]->tag = malloc(32); items[item_no]->tag[0] = 0; | ||
142 | items[item_no]->name = malloc(512); items[item_no]->name[0] = 0; | ||
143 | items[item_no]->namelen = 0; | ||
144 | item_no++; | ||
145 | } | ||
146 | |||
147 | static int cprint_name(const char *fmt, ...) | ||
148 | { | ||
149 | va_list ap; | ||
150 | int res; | ||
151 | |||
152 | if (!item_no) | ||
153 | cmake(); | ||
154 | va_start(ap, fmt); | ||
155 | res = vsnprintf(items[item_no - 1]->name + items[item_no - 1]->namelen, | ||
156 | 512 - items[item_no - 1]->namelen, fmt, ap); | ||
157 | if (res > 0) | ||
158 | items[item_no - 1]->namelen += res; | ||
159 | va_end(ap); | ||
160 | |||
161 | return res; | ||
162 | } | ||
163 | |||
164 | static int cprint_tag(const char *fmt, ...) | ||
165 | { | ||
166 | va_list ap; | ||
167 | int res; | ||
168 | |||
169 | if (!item_no) | ||
170 | cmake(); | ||
171 | va_start(ap, fmt); | ||
172 | res = vsnprintf(items[item_no - 1]->tag, 32, fmt, ap); | ||
173 | va_end(ap); | ||
174 | |||
175 | return res; | ||
176 | } | ||
177 | |||
178 | static void cdone(void) | ||
179 | { | ||
180 | int i; | ||
181 | |||
182 | for (i = 0; i < item_no; i++) { | ||
183 | free(items[i]->tag); | ||
184 | free(items[i]->name); | ||
185 | free(items[i]); | ||
186 | } | ||
187 | |||
188 | item_no = 0; | ||
189 | } | ||
190 | |||
191 | static void build_conf(struct menu *menu) | ||
192 | { | ||
193 | struct symbol *sym; | ||
194 | struct property *prop; | ||
195 | struct menu *child; | ||
196 | int type, tmp, doint = 2; | ||
197 | tristate val; | ||
198 | char ch; | ||
199 | |||
200 | if (!menu_is_visible(menu)) | ||
201 | return; | ||
202 | |||
203 | sym = menu->sym; | ||
204 | prop = menu->prompt; | ||
205 | if (!sym) { | ||
206 | if (prop && menu != current_menu) { | ||
207 | const char *prompt = menu_get_prompt(menu); | ||
208 | switch (prop->type) { | ||
209 | case P_MENU: | ||
210 | child_count++; | ||
211 | cmake(); | ||
212 | cprint_tag("m%p", menu); | ||
213 | |||
214 | if (single_menu_mode) { | ||
215 | cprint_name("%s%*c%s", | ||
216 | menu->data ? "-->" : "++>", | ||
217 | indent + 1, ' ', prompt); | ||
218 | } else { | ||
219 | if (menu->parent != &rootmenu) | ||
220 | cprint_name(" %*c", indent + 1, ' '); | ||
221 | cprint_name("%s --->", prompt); | ||
222 | } | ||
223 | |||
224 | if (single_menu_mode && menu->data) | ||
225 | goto conf_childs; | ||
226 | return; | ||
227 | default: | ||
228 | if (prompt) { | ||
229 | child_count++; | ||
230 | cmake(); | ||
231 | cprint_tag(":%p", menu); | ||
232 | cprint_name("---%*c%s", indent + 1, ' ', prompt); | ||
233 | } | ||
234 | } | ||
235 | } else | ||
236 | doint = 0; | ||
237 | goto conf_childs; | ||
238 | } | ||
239 | |||
240 | cmake(); | ||
241 | type = sym_get_type(sym); | ||
242 | if (sym_is_choice(sym)) { | ||
243 | struct symbol *def_sym = sym_get_choice_value(sym); | ||
244 | struct menu *def_menu = NULL; | ||
245 | |||
246 | child_count++; | ||
247 | for (child = menu->list; child; child = child->next) { | ||
248 | if (menu_is_visible(child) && child->sym == def_sym) | ||
249 | def_menu = child; | ||
250 | } | ||
251 | |||
252 | val = sym_get_tristate_value(sym); | ||
253 | if (sym_is_changable(sym)) { | ||
254 | cprint_tag("t%p", menu); | ||
255 | switch (type) { | ||
256 | case S_BOOLEAN: | ||
257 | cprint_name("[%c]", val == no ? ' ' : '*'); | ||
258 | break; | ||
259 | case S_TRISTATE: | ||
260 | switch (val) { | ||
261 | case yes: ch = '*'; break; | ||
262 | case mod: ch = 'M'; break; | ||
263 | default: ch = ' '; break; | ||
264 | } | ||
265 | cprint_name("<%c>", ch); | ||
266 | break; | ||
267 | } | ||
268 | } else { | ||
269 | cprint_tag("%c%p", def_menu ? 't' : ':', menu); | ||
270 | cprint_name(" "); | ||
271 | } | ||
272 | |||
273 | cprint_name("%*c%s", indent + 1, ' ', menu_get_prompt(menu)); | ||
274 | if (val == yes) { | ||
275 | if (def_menu) { | ||
276 | cprint_name(" (%s)", menu_get_prompt(def_menu)); | ||
277 | cprint_name(" --->"); | ||
278 | if (def_menu->list) { | ||
279 | indent += 2; | ||
280 | build_conf(def_menu); | ||
281 | indent -= 2; | ||
282 | } | ||
283 | } | ||
284 | return; | ||
285 | } | ||
286 | } else { | ||
287 | child_count++; | ||
288 | val = sym_get_tristate_value(sym); | ||
289 | if (sym_is_choice_value(sym) && val == yes) { | ||
290 | cprint_tag(":%p", menu); | ||
291 | cprint_name(" "); | ||
292 | } else { | ||
293 | switch (type) { | ||
294 | case S_BOOLEAN: | ||
295 | cprint_tag("t%p", menu); | ||
296 | cprint_name("[%c]", val == no ? ' ' : '*'); | ||
297 | break; | ||
298 | case S_TRISTATE: | ||
299 | cprint_tag("t%p", menu); | ||
300 | switch (val) { | ||
301 | case yes: ch = '*'; break; | ||
302 | case mod: ch = 'M'; break; | ||
303 | default: ch = ' '; break; | ||
304 | } | ||
305 | cprint_name("<%c>", ch); | ||
306 | break; | ||
307 | default: | ||
308 | cprint_tag("s%p", menu); | ||
309 | tmp = cprint_name("(%s)", sym_get_string_value(sym)); | ||
310 | tmp = indent - tmp + 4; | ||
311 | if (tmp < 0) | ||
312 | tmp = 0; | ||
313 | cprint_name("%*c%s%s", tmp, ' ', menu_get_prompt(menu), | ||
314 | sym_has_value(sym) ? "" : " (NEW)"); | ||
315 | goto conf_childs; | ||
316 | } | ||
317 | } | ||
318 | cprint_name("%*c%s%s", indent + 1, ' ', menu_get_prompt(menu), | ||
319 | sym_has_value(sym) ? "" : " (NEW)"); | ||
320 | } | ||
321 | |||
322 | conf_childs: | ||
323 | indent += doint; | ||
324 | for (child = menu->list; child; child = child->next) | ||
325 | build_conf(child); | ||
326 | indent -= doint; | ||
327 | } | ||
328 | |||
329 | static void conf(struct menu *menu) | ||
330 | { | ||
331 | struct dialog_list_item *active_item = NULL; | ||
332 | struct menu *submenu; | ||
333 | const char *prompt = menu_get_prompt(menu); | ||
334 | struct symbol *sym; | ||
335 | char active_entry[40]; | ||
336 | int stat, type; | ||
337 | |||
338 | unlink("lxdialog.scrltmp"); | ||
339 | active_entry[0] = 0; | ||
340 | while (1) { | ||
341 | indent = 0; | ||
342 | child_count = 0; | ||
343 | current_menu = menu; | ||
344 | cdone(); cinit(); | ||
345 | build_conf(menu); | ||
346 | if (!child_count) | ||
347 | break; | ||
348 | if (menu == &rootmenu) { | ||
349 | cmake(); cprint_tag(":"); cprint_name("--- "); | ||
350 | cmake(); cprint_tag("L"); cprint_name("Load an Alternate Configuration File"); | ||
351 | cmake(); cprint_tag("S"); cprint_name("Save Configuration to an Alternate File"); | ||
352 | } | ||
353 | dialog_clear(); | ||
354 | stat = dialog_menu(prompt ? prompt : "Main Menu", | ||
355 | menu_instructions, rows, cols, rows - 10, | ||
356 | active_entry, item_no, items); | ||
357 | if (stat < 0) | ||
358 | return; | ||
359 | |||
360 | if (stat == 1 || stat == 255) | ||
361 | break; | ||
362 | |||
363 | active_item = first_sel_item(item_no, items); | ||
364 | if (!active_item) | ||
365 | continue; | ||
366 | active_item->selected = 0; | ||
367 | strncpy(active_entry, active_item->tag, sizeof(active_entry)); | ||
368 | active_entry[sizeof(active_entry)-1] = 0; | ||
369 | type = active_entry[0]; | ||
370 | if (!type) | ||
371 | continue; | ||
372 | |||
373 | sym = NULL; | ||
374 | submenu = NULL; | ||
375 | if (sscanf(active_entry + 1, "%p", &submenu) == 1) | ||
376 | sym = submenu->sym; | ||
377 | |||
378 | switch (stat) { | ||
379 | case 0: | ||
380 | switch (type) { | ||
381 | case 'm': | ||
382 | if (single_menu_mode) | ||
383 | submenu->data = (submenu->data)? NULL : (void *)1; | ||
384 | else | ||
385 | conf(submenu); | ||
386 | break; | ||
387 | case 't': | ||
388 | if (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes) | ||
389 | conf_choice(submenu); | ||
390 | break; | ||
391 | case 's': | ||
392 | conf_string(submenu); | ||
393 | break; | ||
394 | case 'L': | ||
395 | conf_load(); | ||
396 | break; | ||
397 | case 'S': | ||
398 | conf_save(); | ||
399 | break; | ||
400 | } | ||
401 | break; | ||
402 | case 2: | ||
403 | if (sym) | ||
404 | show_help(submenu); | ||
405 | else | ||
406 | show_readme(); | ||
407 | break; | ||
408 | case 3: | ||
409 | if (type == 't') { | ||
410 | if (sym_set_tristate_value(sym, yes)) | ||
411 | break; | ||
412 | if (sym_set_tristate_value(sym, mod)) | ||
413 | show_textbox(NULL, setmod_text, 6, 74); | ||
414 | } | ||
415 | break; | ||
416 | case 4: | ||
417 | if (type == 't') | ||
418 | sym_set_tristate_value(sym, no); | ||
419 | break; | ||
420 | case 5: | ||
421 | if (type == 't') | ||
422 | sym_set_tristate_value(sym, mod); | ||
423 | break; | ||
424 | case 6: | ||
425 | if (type == 't') | ||
426 | sym_toggle_tristate_value(sym); | ||
427 | else if (type == 'm') | ||
428 | conf(submenu); | ||
429 | break; | ||
430 | } | ||
431 | } | ||
432 | } | ||
433 | |||
434 | static void show_textbox(const char *title, const char *text, int r, int c) | ||
435 | { | ||
436 | int fd; | ||
437 | |||
438 | fd = creat(".help.tmp", 0777); | ||
439 | write(fd, text, strlen(text)); | ||
440 | close(fd); | ||
441 | while (dialog_textbox(title, ".help.tmp", r, c) < 0) | ||
442 | ; | ||
443 | unlink(".help.tmp"); | ||
444 | } | ||
445 | |||
446 | static void show_helptext(const char *title, const char *text) | ||
447 | { | ||
448 | show_textbox(title, text, rows, cols); | ||
449 | } | ||
450 | |||
451 | static void show_help(struct menu *menu) | ||
452 | { | ||
453 | const char *help; | ||
454 | char *helptext; | ||
455 | struct symbol *sym = menu->sym; | ||
456 | |||
457 | help = sym->help; | ||
458 | if (!help) | ||
459 | help = nohelp_text; | ||
460 | if (sym->name) { | ||
461 | helptext = malloc(strlen(sym->name) + strlen(help) + 16); | ||
462 | sprintf(helptext, "%s:\n\n%s", sym->name, help); | ||
463 | show_helptext(menu_get_prompt(menu), helptext); | ||
464 | free(helptext); | ||
465 | } else | ||
466 | show_helptext(menu_get_prompt(menu), help); | ||
467 | } | ||
468 | |||
469 | static void show_readme(void) | ||
470 | { | ||
471 | while (dialog_textbox(NULL, "scripts/README.Menuconfig", rows, cols) < 0) | ||
472 | ; | ||
473 | } | ||
474 | |||
475 | static void conf_choice(struct menu *menu) | ||
476 | { | ||
477 | const char *prompt = menu_get_prompt(menu); | ||
478 | struct menu *child; | ||
479 | struct symbol *active; | ||
480 | |||
481 | while (1) { | ||
482 | current_menu = menu; | ||
483 | active = sym_get_choice_value(menu->sym); | ||
484 | cdone(); cinit(); | ||
485 | for (child = menu->list; child; child = child->next) { | ||
486 | if (!menu_is_visible(child)) | ||
487 | continue; | ||
488 | cmake(); | ||
489 | cprint_tag("%p", child); | ||
490 | cprint_name("%s", menu_get_prompt(child)); | ||
491 | items[item_no - 1]->selected = (child->sym == active); | ||
492 | } | ||
493 | |||
494 | switch (dialog_checklist(prompt ? prompt : "Main Menu", | ||
495 | radiolist_instructions, 15, 70, 6, | ||
496 | item_no, items, FLAG_RADIO)) { | ||
497 | case 0: | ||
498 | if (sscanf(first_sel_item(item_no, items)->tag, "%p", &menu) != 1) | ||
499 | break; | ||
500 | sym_set_tristate_value(menu->sym, yes); | ||
501 | return; | ||
502 | case 1: | ||
503 | show_help(menu); | ||
504 | break; | ||
505 | case 255: | ||
506 | return; | ||
507 | } | ||
508 | } | ||
509 | } | ||
510 | |||
511 | static void conf_string(struct menu *menu) | ||
512 | { | ||
513 | const char *prompt = menu_get_prompt(menu); | ||
514 | |||
515 | while (1) { | ||
516 | char *heading; | ||
517 | |||
518 | switch (sym_get_type(menu->sym)) { | ||
519 | case S_INT: | ||
520 | heading = (char *) inputbox_instructions_int; | ||
521 | break; | ||
522 | case S_HEX: | ||
523 | heading = (char *) inputbox_instructions_hex; | ||
524 | break; | ||
525 | case S_STRING: | ||
526 | heading = (char *) inputbox_instructions_string; | ||
527 | break; | ||
528 | default: | ||
529 | heading = "Internal mconf error!"; | ||
530 | /* panic? */; | ||
531 | } | ||
532 | |||
533 | switch (dialog_inputbox(prompt ? prompt : "Main Menu", | ||
534 | heading, 10, 75, | ||
535 | sym_get_string_value(menu->sym))) { | ||
536 | case 0: | ||
537 | if (sym_set_string_value(menu->sym, dialog_input_result)) | ||
538 | return; | ||
539 | show_textbox(NULL, "You have made an invalid entry.", 5, 43); | ||
540 | break; | ||
541 | case 1: | ||
542 | show_help(menu); | ||
543 | break; | ||
544 | case 255: | ||
545 | return; | ||
546 | } | ||
547 | } | ||
548 | } | ||
549 | |||
550 | static void conf_load(void) | ||
551 | { | ||
552 | while (1) { | ||
553 | switch (dialog_inputbox(NULL, load_config_text, 11, 55, | ||
554 | filename)) { | ||
555 | case 0: | ||
556 | if (!dialog_input_result[0]) | ||
557 | return; | ||
558 | if (!conf_read(dialog_input_result)) | ||
559 | return; | ||
560 | show_textbox(NULL, "File does not exist!", 5, 38); | ||
561 | break; | ||
562 | case 1: | ||
563 | show_helptext("Load Alternate Configuration", load_config_help); | ||
564 | break; | ||
565 | case 255: | ||
566 | return; | ||
567 | } | ||
568 | } | ||
569 | } | ||
570 | |||
571 | static void conf_save(void) | ||
572 | { | ||
573 | while (1) { | ||
574 | switch (dialog_inputbox(NULL, save_config_text, 11, 55, | ||
575 | filename)) { | ||
576 | case 0: | ||
577 | if (!dialog_input_result[0]) | ||
578 | return; | ||
579 | if (!conf_write(dialog_input_result)) | ||
580 | return; | ||
581 | show_textbox(NULL, "Can't create file! Probably a nonexistent directory.", 5, 60); | ||
582 | break; | ||
583 | case 1: | ||
584 | show_helptext("Save Alternate Configuration", save_config_help); | ||
585 | break; | ||
586 | case 255: | ||
587 | return; | ||
588 | } | ||
589 | } | ||
590 | } | ||
591 | |||
592 | static void conf_cleanup(void) | ||
593 | { | ||
594 | tcsetattr(1, TCSAFLUSH, &ios_org); | ||
595 | unlink(".help.tmp"); | ||
596 | unlink("lxdialog.scrltmp"); | ||
597 | } | ||
598 | |||
599 | static void winch_handler(int sig) | ||
600 | { | ||
601 | struct winsize ws; | ||
602 | |||
603 | if (ioctl(1, TIOCGWINSZ, &ws) == -1) { | ||
604 | rows = 24; | ||
605 | cols = 80; | ||
606 | } else { | ||
607 | rows = ws.ws_row; | ||
608 | cols = ws.ws_col; | ||
609 | } | ||
610 | |||
611 | if (rows < 19 || cols < 80) { | ||
612 | end_dialog(); | ||
613 | fprintf(stderr, "Your display is too small to run Menuconfig!\n"); | ||
614 | fprintf(stderr, "It must be at least 19 lines by 80 columns.\n"); | ||
615 | exit(1); | ||
616 | } | ||
617 | |||
618 | rows -= 4; | ||
619 | cols -= 5; | ||
620 | |||
621 | } | ||
622 | |||
623 | int main(int ac, char **av) | ||
624 | { | ||
625 | int stat; | ||
626 | char *mode; | ||
627 | struct symbol *sym; | ||
628 | |||
629 | conf_parse(av[1]); | ||
630 | conf_read(NULL); | ||
631 | |||
632 | backtitle = malloc(128); | ||
633 | sym = sym_lookup("VERSION", 0); | ||
634 | sym_calc_value(sym); | ||
635 | snprintf(backtitle, 128, "BusyBox v%s Configuration", | ||
636 | sym_get_string_value(sym)); | ||
637 | |||
638 | mode = getenv("MENUCONFIG_MODE"); | ||
639 | if (mode) { | ||
640 | if (!strcasecmp(mode, "single_menu")) | ||
641 | single_menu_mode = 1; | ||
642 | } | ||
643 | |||
644 | tcgetattr(1, &ios_org); | ||
645 | atexit(conf_cleanup); | ||
646 | init_wsize(); | ||
647 | init_dialog(); | ||
648 | signal(SIGWINCH, winch_handler); | ||
649 | conf(&rootmenu); | ||
650 | end_dialog(); | ||
651 | |||
652 | /* Restart dialog to act more like when lxdialog was still separate */ | ||
653 | init_dialog(); | ||
654 | do { | ||
655 | stat = dialog_yesno(NULL, | ||
656 | "Do you wish to save your new BusyBox configuration?", 5, 60); | ||
657 | } while (stat < 0); | ||
658 | end_dialog(); | ||
659 | |||
660 | if (stat == 0) { | ||
661 | conf_write(NULL); | ||
662 | printf("\n\n" | ||
663 | "*** End of BusyBox configuration.\n" | ||
664 | "*** Check the top-level Makefile for additional configuration options.\n\n"); | ||
665 | } else | ||
666 | printf("\n\nYour BusyBox configuration changes were NOT saved.\n\n"); | ||
667 | |||
668 | return 0; | ||
669 | } | ||
diff --git a/scripts/config/menu.c b/scripts/config/menu.c new file mode 100644 index 000000000..3d3b4d19c --- /dev/null +++ b/scripts/config/menu.c | |||
@@ -0,0 +1,309 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> | ||
3 | * Released under the terms of the GNU GPL v2.0. | ||
4 | */ | ||
5 | |||
6 | #include <stdlib.h> | ||
7 | #include <string.h> | ||
8 | |||
9 | #define LKC_DIRECT_LINK | ||
10 | #include "lkc.h" | ||
11 | |||
12 | struct menu rootmenu; | ||
13 | struct menu *current_menu, *current_entry; | ||
14 | static struct menu **last_entry_ptr; | ||
15 | |||
16 | struct file *file_list; | ||
17 | struct file *current_file; | ||
18 | |||
19 | void menu_init(void) | ||
20 | { | ||
21 | current_entry = current_menu = &rootmenu; | ||
22 | last_entry_ptr = &rootmenu.list; | ||
23 | } | ||
24 | |||
25 | void menu_add_entry(struct symbol *sym) | ||
26 | { | ||
27 | struct menu *menu; | ||
28 | |||
29 | menu = malloc(sizeof(*menu)); | ||
30 | memset(menu, 0, sizeof(*menu)); | ||
31 | menu->sym = sym; | ||
32 | menu->parent = current_menu; | ||
33 | menu->file = current_file; | ||
34 | menu->lineno = zconf_lineno(); | ||
35 | |||
36 | *last_entry_ptr = menu; | ||
37 | last_entry_ptr = &menu->next; | ||
38 | current_entry = menu; | ||
39 | } | ||
40 | |||
41 | void menu_end_entry(void) | ||
42 | { | ||
43 | } | ||
44 | |||
45 | void menu_add_menu(void) | ||
46 | { | ||
47 | current_menu = current_entry; | ||
48 | last_entry_ptr = ¤t_entry->list; | ||
49 | } | ||
50 | |||
51 | void menu_end_menu(void) | ||
52 | { | ||
53 | last_entry_ptr = ¤t_menu->next; | ||
54 | current_menu = current_menu->parent; | ||
55 | } | ||
56 | |||
57 | void menu_add_dep(struct expr *dep) | ||
58 | { | ||
59 | current_entry->dep = expr_alloc_and(current_entry->dep, dep); | ||
60 | } | ||
61 | |||
62 | void menu_set_type(int type) | ||
63 | { | ||
64 | struct symbol *sym = current_entry->sym; | ||
65 | |||
66 | if (sym->type == type) | ||
67 | return; | ||
68 | if (sym->type == S_UNKNOWN) { | ||
69 | sym->type = type; | ||
70 | return; | ||
71 | } | ||
72 | fprintf(stderr, "%s:%d: type of '%s' redefined from '%s' to '%s'\n", | ||
73 | current_entry->file->name, current_entry->lineno, | ||
74 | sym->name ? sym->name : "<choice>", sym_type_name(sym->type), sym_type_name(type)); | ||
75 | } | ||
76 | |||
77 | struct property *create_prop(enum prop_type type) | ||
78 | { | ||
79 | struct property *prop; | ||
80 | |||
81 | prop = malloc(sizeof(*prop)); | ||
82 | memset(prop, 0, sizeof(*prop)); | ||
83 | prop->type = type; | ||
84 | prop->file = current_file; | ||
85 | prop->lineno = zconf_lineno(); | ||
86 | |||
87 | return prop; | ||
88 | } | ||
89 | |||
90 | struct property *menu_add_prop(int token, char *prompt, struct symbol *def, struct expr *dep) | ||
91 | { | ||
92 | struct property *prop = create_prop(token); | ||
93 | struct property **propp; | ||
94 | |||
95 | prop->sym = current_entry->sym; | ||
96 | prop->menu = current_entry; | ||
97 | prop->text = prompt; | ||
98 | prop->def = def; | ||
99 | E_EXPR(prop->visible) = dep; | ||
100 | |||
101 | if (prompt) | ||
102 | current_entry->prompt = prop; | ||
103 | |||
104 | /* append property to the prop list of symbol */ | ||
105 | if (prop->sym) { | ||
106 | for (propp = &prop->sym->prop; *propp; propp = &(*propp)->next) | ||
107 | ; | ||
108 | *propp = prop; | ||
109 | } | ||
110 | |||
111 | return prop; | ||
112 | } | ||
113 | |||
114 | void menu_add_prompt(int token, char *prompt, struct expr *dep) | ||
115 | { | ||
116 | current_entry->prompt = menu_add_prop(token, prompt, NULL, dep); | ||
117 | } | ||
118 | |||
119 | void menu_add_default(int token, struct symbol *def, struct expr *dep) | ||
120 | { | ||
121 | current_entry->prompt = menu_add_prop(token, NULL, def, dep); | ||
122 | } | ||
123 | |||
124 | void menu_finalize(struct menu *parent) | ||
125 | { | ||
126 | struct menu *menu, *last_menu; | ||
127 | struct symbol *sym; | ||
128 | struct property *prop; | ||
129 | struct expr *parentdep, *basedep, *dep, *dep2; | ||
130 | |||
131 | sym = parent->sym; | ||
132 | if (parent->list) { | ||
133 | if (sym && sym_is_choice(sym)) { | ||
134 | /* find the first choice value and find out choice type */ | ||
135 | for (menu = parent->list; menu; menu = menu->next) { | ||
136 | if (menu->sym) { | ||
137 | current_entry = parent; | ||
138 | menu_set_type(menu->sym->type); | ||
139 | current_entry = menu; | ||
140 | menu_set_type(sym->type); | ||
141 | break; | ||
142 | } | ||
143 | } | ||
144 | parentdep = expr_alloc_symbol(sym); | ||
145 | } else if (parent->prompt) | ||
146 | parentdep = E_EXPR(parent->prompt->visible); | ||
147 | else | ||
148 | parentdep = parent->dep; | ||
149 | |||
150 | for (menu = parent->list; menu; menu = menu->next) { | ||
151 | basedep = expr_transform(menu->dep); | ||
152 | basedep = expr_alloc_and(expr_copy(parentdep), basedep); | ||
153 | basedep = expr_eliminate_dups(basedep); | ||
154 | menu->dep = basedep; | ||
155 | if (menu->sym) | ||
156 | prop = menu->sym->prop; | ||
157 | else | ||
158 | prop = menu->prompt; | ||
159 | for (; prop; prop = prop->next) { | ||
160 | if (prop->menu != menu) | ||
161 | continue; | ||
162 | dep = expr_transform(E_EXPR(prop->visible)); | ||
163 | dep = expr_alloc_and(expr_copy(basedep), dep); | ||
164 | dep = expr_eliminate_dups(dep); | ||
165 | if (menu->sym && menu->sym->type != S_TRISTATE) | ||
166 | dep = expr_trans_bool(dep); | ||
167 | E_EXPR(prop->visible) = dep; | ||
168 | } | ||
169 | } | ||
170 | for (menu = parent->list; menu; menu = menu->next) | ||
171 | menu_finalize(menu); | ||
172 | } else if (sym && parent->prompt) { | ||
173 | basedep = E_EXPR(parent->prompt->visible); | ||
174 | basedep = expr_trans_compare(basedep, E_UNEQUAL, &symbol_no); | ||
175 | basedep = expr_eliminate_dups(expr_transform(basedep)); | ||
176 | last_menu = NULL; | ||
177 | for (menu = parent->next; menu; menu = menu->next) { | ||
178 | dep = menu->prompt ? E_EXPR(menu->prompt->visible) : menu->dep; | ||
179 | if (!expr_contains_symbol(dep, sym)) | ||
180 | break; | ||
181 | if (expr_depends_symbol(dep, sym)) | ||
182 | goto next; | ||
183 | dep = expr_trans_compare(dep, E_UNEQUAL, &symbol_no); | ||
184 | dep = expr_eliminate_dups(expr_transform(dep)); | ||
185 | dep2 = expr_copy(basedep); | ||
186 | expr_eliminate_eq(&dep, &dep2); | ||
187 | expr_free(dep); | ||
188 | if (!expr_is_yes(dep2)) { | ||
189 | expr_free(dep2); | ||
190 | break; | ||
191 | } | ||
192 | expr_free(dep2); | ||
193 | next: | ||
194 | menu_finalize(menu); | ||
195 | menu->parent = parent; | ||
196 | last_menu = menu; | ||
197 | } | ||
198 | if (last_menu) { | ||
199 | parent->list = parent->next; | ||
200 | parent->next = last_menu->next; | ||
201 | last_menu->next = NULL; | ||
202 | } | ||
203 | } | ||
204 | for (menu = parent->list; menu; menu = menu->next) { | ||
205 | if (sym && sym_is_choice(sym) && menu->sym) { | ||
206 | menu->sym->flags |= SYMBOL_CHOICEVAL; | ||
207 | current_entry = menu; | ||
208 | menu_set_type(sym->type); | ||
209 | menu_add_prop(P_CHOICE, NULL, parent->sym, NULL); | ||
210 | prop = sym_get_choice_prop(parent->sym); | ||
211 | //dep = expr_alloc_one(E_CHOICE, dep); | ||
212 | //dep->right.sym = menu->sym; | ||
213 | prop->dep = expr_alloc_one(E_CHOICE, prop->dep); | ||
214 | prop->dep->right.sym = menu->sym; | ||
215 | } | ||
216 | if (menu->list && (!menu->prompt || !menu->prompt->text)) { | ||
217 | for (last_menu = menu->list; ; last_menu = last_menu->next) { | ||
218 | last_menu->parent = parent; | ||
219 | if (!last_menu->next) | ||
220 | break; | ||
221 | } | ||
222 | last_menu->next = menu->next; | ||
223 | menu->next = menu->list; | ||
224 | menu->list = NULL; | ||
225 | } | ||
226 | } | ||
227 | } | ||
228 | |||
229 | bool menu_is_visible(struct menu *menu) | ||
230 | { | ||
231 | tristate visible; | ||
232 | |||
233 | if (!menu->prompt) | ||
234 | return false; | ||
235 | if (menu->sym) { | ||
236 | sym_calc_value(menu->sym); | ||
237 | visible = E_TRI(menu->prompt->visible); | ||
238 | } else | ||
239 | visible = E_CALC(menu->prompt->visible); | ||
240 | return visible != no; | ||
241 | } | ||
242 | |||
243 | const char *menu_get_prompt(struct menu *menu) | ||
244 | { | ||
245 | if (menu->prompt) | ||
246 | return menu->prompt->text; | ||
247 | else if (menu->sym) | ||
248 | return menu->sym->name; | ||
249 | return NULL; | ||
250 | } | ||
251 | |||
252 | struct menu *menu_get_root_menu(struct menu *menu) | ||
253 | { | ||
254 | return &rootmenu; | ||
255 | } | ||
256 | |||
257 | struct menu *menu_get_parent_menu(struct menu *menu) | ||
258 | { | ||
259 | enum prop_type type; | ||
260 | |||
261 | while (menu != &rootmenu) { | ||
262 | menu = menu->parent; | ||
263 | type = menu->prompt ? menu->prompt->type : 0; | ||
264 | if (type == P_MENU || type == P_ROOTMENU) | ||
265 | break; | ||
266 | } | ||
267 | return menu; | ||
268 | } | ||
269 | |||
270 | struct file *file_lookup(const char *name) | ||
271 | { | ||
272 | struct file *file; | ||
273 | |||
274 | for (file = file_list; file; file = file->next) { | ||
275 | if (!strcmp(name, file->name)) | ||
276 | return file; | ||
277 | } | ||
278 | |||
279 | file = malloc(sizeof(*file)); | ||
280 | memset(file, 0, sizeof(*file)); | ||
281 | file->name = strdup(name); | ||
282 | file->next = file_list; | ||
283 | file_list = file; | ||
284 | return file; | ||
285 | } | ||
286 | |||
287 | int file_write_dep(const char *name) | ||
288 | { | ||
289 | struct file *file; | ||
290 | FILE *out; | ||
291 | |||
292 | if (!name) | ||
293 | name = ".config.cmd"; | ||
294 | out = fopen(".config.tmp", "w"); | ||
295 | if (!out) | ||
296 | return 1; | ||
297 | fprintf(out, "deps_config := \\\n"); | ||
298 | for (file = file_list; file; file = file->next) { | ||
299 | if (file->next) | ||
300 | fprintf(out, "\t%s \\\n", file->name); | ||
301 | else | ||
302 | fprintf(out, "\t%s\n", file->name); | ||
303 | } | ||
304 | fprintf(out, "\n.config include/config.h: $(deps_config)\n\n$(deps_config):\n"); | ||
305 | fclose(out); | ||
306 | rename(".config.tmp", name); | ||
307 | return 0; | ||
308 | } | ||
309 | |||
diff --git a/scripts/config/menubox.c b/scripts/config/menubox.c new file mode 100644 index 000000000..b9cf4b6a3 --- /dev/null +++ b/scripts/config/menubox.c | |||
@@ -0,0 +1,436 @@ | |||
1 | /* | ||
2 | * menubox.c -- implements the menu box | ||
3 | * | ||
4 | * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) | ||
5 | * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcapw@cfw.com) | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; either version 2 | ||
10 | * of the License, or (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | */ | ||
21 | |||
22 | /* | ||
23 | * Changes by Clifford Wolf (god@clifford.at) | ||
24 | * | ||
25 | * [ 1998-06-13 ] | ||
26 | * | ||
27 | * *) A bugfix for the Page-Down problem | ||
28 | * | ||
29 | * *) Formerly when I used Page Down and Page Up, the cursor would be set | ||
30 | * to the first position in the menu box. Now lxdialog is a bit | ||
31 | * smarter and works more like other menu systems (just have a look at | ||
32 | * it). | ||
33 | * | ||
34 | * *) Formerly if I selected something my scrolling would be broken because | ||
35 | * lxdialog is re-invoked by the Menuconfig shell script, can't | ||
36 | * remember the last scrolling position, and just sets it so that the | ||
37 | * cursor is at the bottom of the box. Now it writes the temporary file | ||
38 | * lxdialog.scrltmp which contains this information. The file is | ||
39 | * deleted by lxdialog if the user leaves a submenu or enters a new | ||
40 | * one, but it would be nice if Menuconfig could make another "rm -f" | ||
41 | * just to be sure. Just try it out - you will recognise a difference! | ||
42 | * | ||
43 | * [ 1998-06-14 ] | ||
44 | * | ||
45 | * *) Now lxdialog is crash-safe against broken "lxdialog.scrltmp" files | ||
46 | * and menus change their size on the fly. | ||
47 | * | ||
48 | * *) If for some reason the last scrolling position is not saved by | ||
49 | * lxdialog, it sets the scrolling so that the selected item is in the | ||
50 | * middle of the menu box, not at the bottom. | ||
51 | * | ||
52 | * 02 January 1999, Michael Elizabeth Chastain (mec@shout.net) | ||
53 | * Reset 'scroll' to 0 if the value from lxdialog.scrltmp is bogus. | ||
54 | * This fixes a bug in Menuconfig where using ' ' to descend into menus | ||
55 | * would leave mis-synchronized lxdialog.scrltmp files lying around, | ||
56 | * fscanf would read in 'scroll', and eventually that value would get used. | ||
57 | */ | ||
58 | |||
59 | #include "dialog.h" | ||
60 | |||
61 | static int menu_width, item_x; | ||
62 | |||
63 | /* | ||
64 | * Print menu item | ||
65 | */ | ||
66 | static void | ||
67 | print_item (WINDOW * win, const char *item, int choice, int selected, int hotkey) | ||
68 | { | ||
69 | int j; | ||
70 | char menu_item[menu_width+1]; | ||
71 | |||
72 | strncpy(menu_item, item, menu_width); | ||
73 | menu_item[menu_width] = 0; | ||
74 | j = first_alpha(menu_item, "YyNnMm"); | ||
75 | |||
76 | /* Clear 'residue' of last item */ | ||
77 | wattrset (win, menubox_attr); | ||
78 | wmove (win, choice, 0); | ||
79 | #if OLD_NCURSES | ||
80 | { | ||
81 | int i; | ||
82 | for (i = 0; i < menu_width; i++) | ||
83 | waddch (win, ' '); | ||
84 | } | ||
85 | #else | ||
86 | wclrtoeol(win); | ||
87 | #endif | ||
88 | wattrset (win, selected ? item_selected_attr : item_attr); | ||
89 | mvwaddstr (win, choice, item_x, menu_item); | ||
90 | if (hotkey) { | ||
91 | wattrset (win, selected ? tag_key_selected_attr : tag_key_attr); | ||
92 | mvwaddch(win, choice, item_x+j, menu_item[j]); | ||
93 | } | ||
94 | if (selected) { | ||
95 | wmove (win, choice, item_x+1); | ||
96 | wnoutrefresh (win); | ||
97 | } | ||
98 | } | ||
99 | |||
100 | /* | ||
101 | * Print the scroll indicators. | ||
102 | */ | ||
103 | static void | ||
104 | print_arrows (WINDOW * win, int item_no, int scroll, | ||
105 | int y, int x, int height) | ||
106 | { | ||
107 | int cur_y, cur_x; | ||
108 | |||
109 | getyx(win, cur_y, cur_x); | ||
110 | |||
111 | wmove(win, y, x); | ||
112 | |||
113 | if (scroll > 0) { | ||
114 | wattrset (win, uarrow_attr); | ||
115 | waddch (win, ACS_UARROW); | ||
116 | waddstr (win, "(-)"); | ||
117 | } | ||
118 | else { | ||
119 | wattrset (win, menubox_attr); | ||
120 | waddch (win, ACS_HLINE); | ||
121 | waddch (win, ACS_HLINE); | ||
122 | waddch (win, ACS_HLINE); | ||
123 | waddch (win, ACS_HLINE); | ||
124 | } | ||
125 | |||
126 | y = y + height + 1; | ||
127 | wmove(win, y, x); | ||
128 | |||
129 | if ((height < item_no) && (scroll + height < item_no)) { | ||
130 | wattrset (win, darrow_attr); | ||
131 | waddch (win, ACS_DARROW); | ||
132 | waddstr (win, "(+)"); | ||
133 | } | ||
134 | else { | ||
135 | wattrset (win, menubox_border_attr); | ||
136 | waddch (win, ACS_HLINE); | ||
137 | waddch (win, ACS_HLINE); | ||
138 | waddch (win, ACS_HLINE); | ||
139 | waddch (win, ACS_HLINE); | ||
140 | } | ||
141 | |||
142 | wmove(win, cur_y, cur_x); | ||
143 | } | ||
144 | |||
145 | /* | ||
146 | * Display the termination buttons. | ||
147 | */ | ||
148 | static void | ||
149 | print_buttons (WINDOW *win, int height, int width, int selected) | ||
150 | { | ||
151 | int x = width / 2 - 16; | ||
152 | int y = height - 2; | ||
153 | |||
154 | print_button (win, "Select", y, x, selected == 0); | ||
155 | print_button (win, " Exit ", y, x + 12, selected == 1); | ||
156 | print_button (win, " Help ", y, x + 24, selected == 2); | ||
157 | |||
158 | wmove(win, y, x+1+12*selected); | ||
159 | wrefresh (win); | ||
160 | } | ||
161 | |||
162 | /* | ||
163 | * Display a menu for choosing among a number of options | ||
164 | */ | ||
165 | int | ||
166 | dialog_menu (const char *title, const char *prompt, int height, int width, | ||
167 | int menu_height, const char *current, int item_no, | ||
168 | struct dialog_list_item ** items) | ||
169 | { | ||
170 | int i, j, x, y, box_x, box_y; | ||
171 | int key = 0, button = 0, scroll = 0, choice = 0, first_item = 0, max_choice; | ||
172 | WINDOW *dialog, *menu; | ||
173 | FILE *f; | ||
174 | |||
175 | max_choice = MIN (menu_height, item_no); | ||
176 | |||
177 | /* center dialog box on screen */ | ||
178 | x = (COLS - width) / 2; | ||
179 | y = (LINES - height) / 2; | ||
180 | |||
181 | draw_shadow (stdscr, y, x, height, width); | ||
182 | |||
183 | dialog = newwin (height, width, y, x); | ||
184 | keypad (dialog, TRUE); | ||
185 | |||
186 | draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr); | ||
187 | wattrset (dialog, border_attr); | ||
188 | mvwaddch (dialog, height - 3, 0, ACS_LTEE); | ||
189 | for (i = 0; i < width - 2; i++) | ||
190 | waddch (dialog, ACS_HLINE); | ||
191 | wattrset (dialog, dialog_attr); | ||
192 | wbkgdset (dialog, dialog_attr & A_COLOR); | ||
193 | waddch (dialog, ACS_RTEE); | ||
194 | |||
195 | if (title != NULL && strlen(title) >= width-2 ) { | ||
196 | /* truncate long title -- mec */ | ||
197 | char * title2 = malloc(width-2+1); | ||
198 | memcpy( title2, title, width-2 ); | ||
199 | title2[width-2] = '\0'; | ||
200 | title = title2; | ||
201 | } | ||
202 | |||
203 | if (title != NULL) { | ||
204 | wattrset (dialog, title_attr); | ||
205 | mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' '); | ||
206 | waddstr (dialog, (char *)title); | ||
207 | waddch (dialog, ' '); | ||
208 | } | ||
209 | |||
210 | wattrset (dialog, dialog_attr); | ||
211 | print_autowrap (dialog, prompt, width - 2, 1, 3); | ||
212 | |||
213 | menu_width = width - 6; | ||
214 | box_y = height - menu_height - 5; | ||
215 | box_x = (width - menu_width) / 2 - 1; | ||
216 | |||
217 | /* create new window for the menu */ | ||
218 | menu = subwin (dialog, menu_height, menu_width, | ||
219 | y + box_y + 1, x + box_x + 1); | ||
220 | keypad (menu, TRUE); | ||
221 | |||
222 | /* draw a box around the menu items */ | ||
223 | draw_box (dialog, box_y, box_x, menu_height + 2, menu_width + 2, | ||
224 | menubox_border_attr, menubox_attr); | ||
225 | |||
226 | /* | ||
227 | * Find length of longest item in order to center menu. | ||
228 | * Set 'choice' to default item. | ||
229 | */ | ||
230 | item_x = 0; | ||
231 | for (i = 0; i < item_no; i++) { | ||
232 | item_x = MAX (item_x, MIN(menu_width, strlen (items[i]->name) + 2)); | ||
233 | if (strcmp(current, items[i]->tag) == 0) choice = i; | ||
234 | } | ||
235 | |||
236 | item_x = (menu_width - item_x) / 2; | ||
237 | |||
238 | /* get the scroll info from the temp file */ | ||
239 | if ( (f=fopen("lxdialog.scrltmp","r")) != NULL ) { | ||
240 | if ( (fscanf(f,"%d\n",&scroll) == 1) && (scroll <= choice) && | ||
241 | (scroll+max_choice > choice) && (scroll >= 0) && | ||
242 | (scroll+max_choice <= item_no) ) { | ||
243 | first_item = scroll; | ||
244 | choice = choice - scroll; | ||
245 | fclose(f); | ||
246 | } else { | ||
247 | scroll=0; | ||
248 | remove("lxdialog.scrltmp"); | ||
249 | fclose(f); | ||
250 | f=NULL; | ||
251 | } | ||
252 | } | ||
253 | if ( (choice >= max_choice) || (f==NULL && choice >= max_choice/2) ) { | ||
254 | if (choice >= item_no-max_choice/2) | ||
255 | scroll = first_item = item_no-max_choice; | ||
256 | else | ||
257 | scroll = first_item = choice - max_choice/2; | ||
258 | choice = choice - scroll; | ||
259 | } | ||
260 | |||
261 | /* Print the menu */ | ||
262 | for (i=0; i < max_choice; i++) { | ||
263 | print_item (menu, items[first_item + i]->name, i, i == choice, | ||
264 | (items[first_item + i]->tag[0] != ':')); | ||
265 | } | ||
266 | |||
267 | wnoutrefresh (menu); | ||
268 | |||
269 | print_arrows(dialog, item_no, scroll, | ||
270 | box_y, box_x+item_x+1, menu_height); | ||
271 | |||
272 | print_buttons (dialog, height, width, 0); | ||
273 | wmove (menu, choice, item_x+1); | ||
274 | wrefresh (menu); | ||
275 | |||
276 | while (key != ESC) { | ||
277 | key = wgetch(menu); | ||
278 | |||
279 | if (key < 256 && isalpha(key)) key = tolower(key); | ||
280 | |||
281 | if (strchr("ynm", key)) | ||
282 | i = max_choice; | ||
283 | else { | ||
284 | for (i = choice+1; i < max_choice; i++) { | ||
285 | j = first_alpha(items[scroll + i]->name, "YyNnMm>"); | ||
286 | if (key == tolower(items[scroll + i]->name[j])) | ||
287 | break; | ||
288 | } | ||
289 | if (i == max_choice) | ||
290 | for (i = 0; i < max_choice; i++) { | ||
291 | j = first_alpha(items[scroll + i]->name, "YyNnMm>"); | ||
292 | if (key == tolower(items[scroll + i]->name[j])) | ||
293 | break; | ||
294 | } | ||
295 | } | ||
296 | |||
297 | if (i < max_choice || | ||
298 | key == KEY_UP || key == KEY_DOWN || | ||
299 | key == '-' || key == '+' || | ||
300 | key == KEY_PPAGE || key == KEY_NPAGE) { | ||
301 | |||
302 | print_item (menu, items[scroll + choice]->name, choice, FALSE, | ||
303 | (items[scroll + choice]->tag[0] != ':')); | ||
304 | |||
305 | if (key == KEY_UP || key == '-') { | ||
306 | if (choice < 2 && scroll) { | ||
307 | /* Scroll menu down */ | ||
308 | scrollok (menu, TRUE); | ||
309 | wscrl (menu, -1); | ||
310 | scrollok (menu, FALSE); | ||
311 | |||
312 | scroll--; | ||
313 | |||
314 | print_item (menu, items[scroll * 2]->name, 0, FALSE, | ||
315 | (items[scroll * 2]->tag[0] != ':')); | ||
316 | } else | ||
317 | choice = MAX(choice - 1, 0); | ||
318 | |||
319 | } else if (key == KEY_DOWN || key == '+') { | ||
320 | |||
321 | print_item (menu, items[scroll + choice]->name, choice, FALSE, | ||
322 | (items[scroll + choice]->tag[0] != ':')); | ||
323 | |||
324 | if ((choice > max_choice-3) && | ||
325 | (scroll + max_choice < item_no) | ||
326 | ) { | ||
327 | /* Scroll menu up */ | ||
328 | scrollok (menu, TRUE); | ||
329 | scroll (menu); | ||
330 | scrollok (menu, FALSE); | ||
331 | |||
332 | scroll++; | ||
333 | |||
334 | print_item (menu, items[scroll + max_choice - 1]->name, | ||
335 | max_choice-1, FALSE, | ||
336 | (items[scroll + max_choice - 1]->tag[0] != ':')); | ||
337 | } else | ||
338 | choice = MIN(choice+1, max_choice-1); | ||
339 | |||
340 | } else if (key == KEY_PPAGE) { | ||
341 | scrollok (menu, TRUE); | ||
342 | for (i=0; (i < max_choice); i++) { | ||
343 | if (scroll > 0) { | ||
344 | wscrl (menu, -1); | ||
345 | scroll--; | ||
346 | print_item (menu, items[scroll * 2]->name, 0, FALSE, | ||
347 | (items[scroll * 2]->tag[0] != ':')); | ||
348 | } else { | ||
349 | if (choice > 0) | ||
350 | choice--; | ||
351 | } | ||
352 | } | ||
353 | scrollok (menu, FALSE); | ||
354 | |||
355 | } else if (key == KEY_NPAGE) { | ||
356 | for (i=0; (i < max_choice); i++) { | ||
357 | if (scroll+max_choice < item_no) { | ||
358 | scrollok (menu, TRUE); | ||
359 | scroll(menu); | ||
360 | scrollok (menu, FALSE); | ||
361 | scroll++; | ||
362 | print_item (menu, items[scroll + max_choice - 1]->name, | ||
363 | max_choice-1, FALSE, | ||
364 | (items[scroll + max_choice - 1]->tag[0] != ':')); | ||
365 | } else { | ||
366 | if (choice+1 < max_choice) | ||
367 | choice++; | ||
368 | } | ||
369 | } | ||
370 | |||
371 | } else | ||
372 | choice = i; | ||
373 | |||
374 | print_item (menu, items[scroll + choice]->name, choice, TRUE, | ||
375 | (items[scroll + choice]->tag[0] != ':')); | ||
376 | |||
377 | print_arrows(dialog, item_no, scroll, | ||
378 | box_y, box_x+item_x+1, menu_height); | ||
379 | |||
380 | wnoutrefresh (dialog); | ||
381 | wrefresh (menu); | ||
382 | |||
383 | continue; /* wait for another key press */ | ||
384 | } | ||
385 | |||
386 | switch (key) { | ||
387 | case KEY_LEFT: | ||
388 | case TAB: | ||
389 | case KEY_RIGHT: | ||
390 | button = ((key == KEY_LEFT ? --button : ++button) < 0) | ||
391 | ? 2 : (button > 2 ? 0 : button); | ||
392 | |||
393 | print_buttons(dialog, height, width, button); | ||
394 | wrefresh (menu); | ||
395 | break; | ||
396 | case ' ': | ||
397 | case 's': | ||
398 | case 'y': | ||
399 | case 'n': | ||
400 | case 'm': | ||
401 | /* save scroll info */ | ||
402 | if ( (f=fopen("lxdialog.scrltmp","w")) != NULL ) { | ||
403 | fprintf(f,"%d\n",scroll); | ||
404 | fclose(f); | ||
405 | } | ||
406 | delwin (dialog); | ||
407 | items[scroll + choice]->selected = 1; | ||
408 | switch (key) { | ||
409 | case 's': return 3; | ||
410 | case 'y': return 3; | ||
411 | case 'n': return 4; | ||
412 | case 'm': return 5; | ||
413 | case ' ': return 6; | ||
414 | } | ||
415 | return 0; | ||
416 | case 'h': | ||
417 | case '?': | ||
418 | button = 2; | ||
419 | case '\n': | ||
420 | delwin (dialog); | ||
421 | items[scroll + choice]->selected = 1; | ||
422 | |||
423 | remove("lxdialog.scrltmp"); | ||
424 | return button; | ||
425 | case 'e': | ||
426 | case 'x': | ||
427 | key = ESC; | ||
428 | case ESC: | ||
429 | break; | ||
430 | } | ||
431 | } | ||
432 | |||
433 | delwin (dialog); | ||
434 | remove("lxdialog.scrltmp"); | ||
435 | return -1; /* ESC pressed */ | ||
436 | } | ||
diff --git a/scripts/config/msgbox.c b/scripts/config/msgbox.c new file mode 100644 index 000000000..93692e1fb --- /dev/null +++ b/scripts/config/msgbox.c | |||
@@ -0,0 +1,85 @@ | |||
1 | /* | ||
2 | * msgbox.c -- implements the message box and info box | ||
3 | * | ||
4 | * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) | ||
5 | * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcapw@cfw.com) | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; either version 2 | ||
10 | * of the License, or (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | */ | ||
21 | |||
22 | #include "dialog.h" | ||
23 | |||
24 | /* | ||
25 | * Display a message box. Program will pause and display an "OK" button | ||
26 | * if the parameter 'pause' is non-zero. | ||
27 | */ | ||
28 | int | ||
29 | dialog_msgbox (const char *title, const char *prompt, int height, int width, | ||
30 | int pause) | ||
31 | { | ||
32 | int i, x, y, key = 0; | ||
33 | WINDOW *dialog; | ||
34 | |||
35 | /* center dialog box on screen */ | ||
36 | x = (COLS - width) / 2; | ||
37 | y = (LINES - height) / 2; | ||
38 | |||
39 | draw_shadow (stdscr, y, x, height, width); | ||
40 | |||
41 | dialog = newwin (height, width, y, x); | ||
42 | keypad (dialog, TRUE); | ||
43 | |||
44 | draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr); | ||
45 | |||
46 | if (title != NULL && strlen(title) >= width-2 ) { | ||
47 | /* truncate long title -- mec */ | ||
48 | char * title2 = malloc(width-2+1); | ||
49 | memcpy( title2, title, width-2 ); | ||
50 | title2[width-2] = '\0'; | ||
51 | title = title2; | ||
52 | } | ||
53 | |||
54 | if (title != NULL) { | ||
55 | wattrset (dialog, title_attr); | ||
56 | mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' '); | ||
57 | waddstr (dialog, (char *)title); | ||
58 | waddch (dialog, ' '); | ||
59 | } | ||
60 | wattrset (dialog, dialog_attr); | ||
61 | print_autowrap (dialog, prompt, width - 2, 1, 2); | ||
62 | |||
63 | if (pause) { | ||
64 | wattrset (dialog, border_attr); | ||
65 | mvwaddch (dialog, height - 3, 0, ACS_LTEE); | ||
66 | for (i = 0; i < width - 2; i++) | ||
67 | waddch (dialog, ACS_HLINE); | ||
68 | wattrset (dialog, dialog_attr); | ||
69 | waddch (dialog, ACS_RTEE); | ||
70 | |||
71 | print_button (dialog, " Ok ", | ||
72 | height - 2, width / 2 - 4, TRUE); | ||
73 | |||
74 | wrefresh (dialog); | ||
75 | while (key != ESC && key != '\n' && key != ' ' && | ||
76 | key != 'O' && key != 'o' && key != 'X' && key != 'x') | ||
77 | key = wgetch (dialog); | ||
78 | } else { | ||
79 | key = '\n'; | ||
80 | wrefresh (dialog); | ||
81 | } | ||
82 | |||
83 | delwin (dialog); | ||
84 | return key == ESC ? -1 : 0; | ||
85 | } | ||
diff --git a/scripts/config/symbol.c b/scripts/config/symbol.c new file mode 100644 index 000000000..f2d0015de --- /dev/null +++ b/scripts/config/symbol.c | |||
@@ -0,0 +1,629 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> | ||
3 | * Released under the terms of the GNU GPL v2.0. | ||
4 | */ | ||
5 | |||
6 | #include <ctype.h> | ||
7 | #include <stdlib.h> | ||
8 | #include <string.h> | ||
9 | #include <sys/utsname.h> | ||
10 | |||
11 | #define LKC_DIRECT_LINK | ||
12 | #include "lkc.h" | ||
13 | |||
14 | struct symbol symbol_yes = { | ||
15 | name: "y", | ||
16 | curr: { "y", yes }, | ||
17 | flags: SYMBOL_YES|SYMBOL_VALID, | ||
18 | }, symbol_mod = { | ||
19 | name: "m", | ||
20 | curr: { "m", mod }, | ||
21 | flags: SYMBOL_MOD|SYMBOL_VALID, | ||
22 | }, symbol_no = { | ||
23 | name: "n", | ||
24 | curr: { "n", no }, | ||
25 | flags: SYMBOL_NO|SYMBOL_VALID, | ||
26 | }, symbol_empty = { | ||
27 | name: "", | ||
28 | curr: { "", no }, | ||
29 | flags: SYMBOL_VALID, | ||
30 | }; | ||
31 | |||
32 | int sym_change_count; | ||
33 | struct symbol *modules_sym; | ||
34 | |||
35 | void sym_add_default(struct symbol *sym, const char *def) | ||
36 | { | ||
37 | struct property *prop = create_prop(P_DEFAULT); | ||
38 | struct property **propp; | ||
39 | |||
40 | prop->sym = sym; | ||
41 | prop->def = sym_lookup(def, 1); | ||
42 | |||
43 | /* append property to the prop list of symbol */ | ||
44 | if (prop->sym) { | ||
45 | for (propp = &prop->sym->prop; *propp; propp = &(*propp)->next) | ||
46 | ; | ||
47 | *propp = prop; | ||
48 | } | ||
49 | } | ||
50 | |||
51 | void sym_init(void) | ||
52 | { | ||
53 | struct symbol *sym; | ||
54 | struct utsname uts; | ||
55 | char *p; | ||
56 | static bool inited = false; | ||
57 | |||
58 | if (inited) | ||
59 | return; | ||
60 | inited = true; | ||
61 | |||
62 | uname(&uts); | ||
63 | |||
64 | #if 0 | ||
65 | sym = sym_lookup("ARCH", 0); | ||
66 | sym->type = S_STRING; | ||
67 | sym->flags |= SYMBOL_AUTO; | ||
68 | p = getenv("ARCH"); | ||
69 | if (p) | ||
70 | sym_add_default(sym, p); | ||
71 | #endif | ||
72 | |||
73 | sym = sym_lookup("VERSION", 0); | ||
74 | sym->type = S_STRING; | ||
75 | sym->flags |= SYMBOL_AUTO; | ||
76 | p = getenv("VERSION"); | ||
77 | if (p) | ||
78 | sym_add_default(sym, p); | ||
79 | |||
80 | #if 0 | ||
81 | sym = sym_lookup("UNAME_RELEASE", 0); | ||
82 | sym->type = S_STRING; | ||
83 | sym->flags |= SYMBOL_AUTO; | ||
84 | sym_add_default(sym, uts.release); | ||
85 | #endif | ||
86 | |||
87 | sym = sym_lookup("TARGET_ARCH", 0); | ||
88 | sym->type = S_STRING; | ||
89 | sym->flags |= SYMBOL_AUTO; | ||
90 | p = getenv("TARGET_ARCH"); | ||
91 | if (p) | ||
92 | sym_add_default(sym, p); | ||
93 | } | ||
94 | |||
95 | int sym_get_type(struct symbol *sym) | ||
96 | { | ||
97 | int type = sym->type; | ||
98 | if (type == S_TRISTATE) { | ||
99 | if (sym_is_choice_value(sym) && sym->visible == yes) | ||
100 | type = S_BOOLEAN; | ||
101 | else { | ||
102 | sym_calc_value(modules_sym); | ||
103 | if (S_TRI(modules_sym->curr) == no) | ||
104 | type = S_BOOLEAN; | ||
105 | } | ||
106 | } | ||
107 | return type; | ||
108 | } | ||
109 | |||
110 | const char *sym_type_name(int type) | ||
111 | { | ||
112 | switch (type) { | ||
113 | case S_BOOLEAN: | ||
114 | return "boolean"; | ||
115 | case S_TRISTATE: | ||
116 | return "tristate"; | ||
117 | case S_INT: | ||
118 | return "integer"; | ||
119 | case S_HEX: | ||
120 | return "hex"; | ||
121 | case S_STRING: | ||
122 | return "string"; | ||
123 | case S_UNKNOWN: | ||
124 | return "unknown"; | ||
125 | } | ||
126 | return "???"; | ||
127 | } | ||
128 | |||
129 | struct property *sym_get_choice_prop(struct symbol *sym) | ||
130 | { | ||
131 | struct property *prop; | ||
132 | |||
133 | for_all_choices(sym, prop) | ||
134 | return prop; | ||
135 | return NULL; | ||
136 | } | ||
137 | |||
138 | struct property *sym_get_default_prop(struct symbol *sym) | ||
139 | { | ||
140 | struct property *prop; | ||
141 | tristate visible; | ||
142 | |||
143 | for_all_defaults(sym, prop) { | ||
144 | visible = E_CALC(prop->visible); | ||
145 | if (visible != no) | ||
146 | return prop; | ||
147 | } | ||
148 | return NULL; | ||
149 | } | ||
150 | |||
151 | void sym_calc_visibility(struct symbol *sym) | ||
152 | { | ||
153 | struct property *prop; | ||
154 | tristate visible, oldvisible; | ||
155 | |||
156 | /* any prompt visible? */ | ||
157 | oldvisible = sym->visible; | ||
158 | visible = no; | ||
159 | for_all_prompts(sym, prop) | ||
160 | visible = E_OR(visible, E_CALC(prop->visible)); | ||
161 | if (oldvisible != visible) { | ||
162 | sym->visible = visible; | ||
163 | sym->flags |= SYMBOL_CHANGED; | ||
164 | } | ||
165 | } | ||
166 | |||
167 | void sym_calc_value(struct symbol *sym) | ||
168 | { | ||
169 | struct symbol_value newval, oldval; | ||
170 | struct property *prop, *def_prop; | ||
171 | struct symbol *def_sym; | ||
172 | struct expr *e; | ||
173 | |||
174 | if (sym->flags & SYMBOL_VALID) | ||
175 | return; | ||
176 | |||
177 | oldval = sym->curr; | ||
178 | |||
179 | switch (sym->type) { | ||
180 | case S_INT: | ||
181 | case S_HEX: | ||
182 | case S_STRING: | ||
183 | newval = symbol_empty.curr; | ||
184 | break; | ||
185 | case S_BOOLEAN: | ||
186 | case S_TRISTATE: | ||
187 | newval = symbol_no.curr; | ||
188 | break; | ||
189 | default: | ||
190 | S_VAL(newval) = sym->name; | ||
191 | S_TRI(newval) = no; | ||
192 | if (sym->flags & SYMBOL_CONST) { | ||
193 | goto out; | ||
194 | } | ||
195 | //newval = symbol_empty.curr; | ||
196 | // generate warning somewhere here later | ||
197 | //S_TRI(newval) = yes; | ||
198 | goto out; | ||
199 | } | ||
200 | sym->flags |= SYMBOL_VALID; | ||
201 | if (!sym_is_choice_value(sym)) | ||
202 | sym->flags &= ~SYMBOL_WRITE; | ||
203 | |||
204 | sym_calc_visibility(sym); | ||
205 | |||
206 | /* set default if recursively called */ | ||
207 | sym->curr = newval; | ||
208 | |||
209 | if (sym->visible != no) { | ||
210 | sym->flags |= SYMBOL_WRITE; | ||
211 | if (!sym_has_value(sym)) { | ||
212 | if (!sym_is_choice(sym)) { | ||
213 | prop = sym_get_default_prop(sym); | ||
214 | if (prop) { | ||
215 | sym_calc_value(prop->def); | ||
216 | newval = prop->def->curr; | ||
217 | } | ||
218 | } | ||
219 | } else | ||
220 | newval = sym->def; | ||
221 | |||
222 | S_TRI(newval) = E_AND(S_TRI(newval), sym->visible); | ||
223 | /* if the symbol is visible and not optionial, | ||
224 | * possibly ignore old user choice. */ | ||
225 | if (!sym_is_optional(sym) && S_TRI(newval) == no) | ||
226 | S_TRI(newval) = sym->visible; | ||
227 | if (sym_is_choice_value(sym) && sym->visible == yes) { | ||
228 | prop = sym_get_choice_prop(sym); | ||
229 | S_TRI(newval) = (S_VAL(prop->def->curr) == sym) ? yes : no; | ||
230 | } | ||
231 | } else { | ||
232 | prop = sym_get_default_prop(sym); | ||
233 | if (prop) { | ||
234 | sym->flags |= SYMBOL_WRITE; | ||
235 | sym_calc_value(prop->def); | ||
236 | newval = prop->def->curr; | ||
237 | } | ||
238 | } | ||
239 | |||
240 | switch (sym_get_type(sym)) { | ||
241 | case S_TRISTATE: | ||
242 | if (S_TRI(newval) != mod) | ||
243 | break; | ||
244 | sym_calc_value(modules_sym); | ||
245 | if (S_TRI(modules_sym->curr) == no) | ||
246 | S_TRI(newval) = yes; | ||
247 | break; | ||
248 | case S_BOOLEAN: | ||
249 | if (S_TRI(newval) == mod) | ||
250 | S_TRI(newval) = yes; | ||
251 | } | ||
252 | |||
253 | out: | ||
254 | sym->curr = newval; | ||
255 | |||
256 | if (sym_is_choice(sym) && S_TRI(newval) == yes) { | ||
257 | def_sym = S_VAL(sym->def); | ||
258 | if (def_sym) { | ||
259 | sym_calc_visibility(def_sym); | ||
260 | if (def_sym->visible == no) | ||
261 | def_sym = NULL; | ||
262 | } | ||
263 | if (!def_sym) { | ||
264 | for_all_defaults(sym, def_prop) { | ||
265 | if (E_CALC(def_prop->visible) == no) | ||
266 | continue; | ||
267 | sym_calc_visibility(def_prop->def); | ||
268 | if (def_prop->def->visible != no) { | ||
269 | def_sym = def_prop->def; | ||
270 | break; | ||
271 | } | ||
272 | } | ||
273 | } | ||
274 | |||
275 | if (!def_sym) { | ||
276 | prop = sym_get_choice_prop(sym); | ||
277 | for (e = prop->dep; e; e = e->left.expr) { | ||
278 | sym_calc_visibility(e->right.sym); | ||
279 | if (e->right.sym->visible != no) { | ||
280 | def_sym = e->right.sym; | ||
281 | break; | ||
282 | } | ||
283 | } | ||
284 | } | ||
285 | |||
286 | S_VAL(newval) = def_sym; | ||
287 | } | ||
288 | |||
289 | if (memcmp(&oldval, &newval, sizeof(newval))) | ||
290 | sym->flags |= SYMBOL_CHANGED; | ||
291 | sym->curr = newval; | ||
292 | |||
293 | if (sym_is_choice(sym)) { | ||
294 | int flags = sym->flags & (SYMBOL_CHANGED | SYMBOL_WRITE); | ||
295 | prop = sym_get_choice_prop(sym); | ||
296 | for (e = prop->dep; e; e = e->left.expr) | ||
297 | e->right.sym->flags |= flags; | ||
298 | } | ||
299 | } | ||
300 | |||
301 | void sym_clear_all_valid(void) | ||
302 | { | ||
303 | struct symbol *sym; | ||
304 | int i; | ||
305 | |||
306 | for_all_symbols(i, sym) | ||
307 | sym->flags &= ~SYMBOL_VALID; | ||
308 | sym_change_count++; | ||
309 | } | ||
310 | |||
311 | void sym_set_all_changed(void) | ||
312 | { | ||
313 | struct symbol *sym; | ||
314 | int i; | ||
315 | |||
316 | for_all_symbols(i, sym) | ||
317 | sym->flags |= SYMBOL_CHANGED; | ||
318 | } | ||
319 | |||
320 | bool sym_tristate_within_range(struct symbol *sym, tristate val) | ||
321 | { | ||
322 | int type = sym_get_type(sym); | ||
323 | |||
324 | if (sym->visible == no) | ||
325 | return false; | ||
326 | |||
327 | if (type != S_BOOLEAN && type != S_TRISTATE) | ||
328 | return false; | ||
329 | |||
330 | switch (val) { | ||
331 | case no: | ||
332 | if (sym_is_choice_value(sym) && sym->visible == yes) | ||
333 | return false; | ||
334 | return sym_is_optional(sym); | ||
335 | case mod: | ||
336 | if (sym_is_choice_value(sym) && sym->visible == yes) | ||
337 | return false; | ||
338 | return type == S_TRISTATE; | ||
339 | case yes: | ||
340 | return type == S_BOOLEAN || sym->visible == yes; | ||
341 | } | ||
342 | return false; | ||
343 | } | ||
344 | |||
345 | bool sym_set_tristate_value(struct symbol *sym, tristate val) | ||
346 | { | ||
347 | tristate oldval = sym_get_tristate_value(sym); | ||
348 | |||
349 | if (oldval != val && !sym_tristate_within_range(sym, val)) | ||
350 | return false; | ||
351 | |||
352 | if (sym->flags & SYMBOL_NEW) { | ||
353 | sym->flags &= ~SYMBOL_NEW; | ||
354 | sym->flags |= SYMBOL_CHANGED; | ||
355 | } | ||
356 | if (sym_is_choice_value(sym) && val == yes) { | ||
357 | struct property *prop = sym_get_choice_prop(sym); | ||
358 | |||
359 | S_VAL(prop->def->def) = sym; | ||
360 | prop->def->flags &= ~SYMBOL_NEW; | ||
361 | } | ||
362 | |||
363 | S_TRI(sym->def) = val; | ||
364 | if (oldval != val) { | ||
365 | sym_clear_all_valid(); | ||
366 | if (sym == modules_sym) | ||
367 | sym_set_all_changed(); | ||
368 | } | ||
369 | |||
370 | return true; | ||
371 | } | ||
372 | |||
373 | tristate sym_toggle_tristate_value(struct symbol *sym) | ||
374 | { | ||
375 | tristate oldval, newval; | ||
376 | |||
377 | oldval = newval = sym_get_tristate_value(sym); | ||
378 | do { | ||
379 | switch (newval) { | ||
380 | case no: | ||
381 | newval = mod; | ||
382 | break; | ||
383 | case mod: | ||
384 | newval = yes; | ||
385 | break; | ||
386 | case yes: | ||
387 | newval = no; | ||
388 | break; | ||
389 | } | ||
390 | if (sym_set_tristate_value(sym, newval)) | ||
391 | break; | ||
392 | } while (oldval != newval); | ||
393 | return newval; | ||
394 | } | ||
395 | |||
396 | bool sym_string_valid(struct symbol *sym, const char *str) | ||
397 | { | ||
398 | char ch; | ||
399 | |||
400 | switch (sym->type) { | ||
401 | case S_STRING: | ||
402 | return true; | ||
403 | case S_INT: | ||
404 | ch = *str++; | ||
405 | if (ch == '-') | ||
406 | ch = *str++; | ||
407 | if (!isdigit((int)ch)) | ||
408 | return false; | ||
409 | if (ch == '0' && *str != 0) | ||
410 | return false; | ||
411 | while ((ch = *str++)) { | ||
412 | if (!isdigit((int)ch)) | ||
413 | return false; | ||
414 | } | ||
415 | return true; | ||
416 | case S_HEX: | ||
417 | if (str[0] == '0' && (str[1] == 'x' || str[1] == 'X')) | ||
418 | str += 2; | ||
419 | ch = *str++; | ||
420 | do { | ||
421 | if (!isxdigit((int)ch)) | ||
422 | return false; | ||
423 | } while ((ch = *str++)); | ||
424 | return true; | ||
425 | case S_BOOLEAN: | ||
426 | case S_TRISTATE: | ||
427 | switch (str[0]) { | ||
428 | case 'y': | ||
429 | case 'Y': | ||
430 | return sym_tristate_within_range(sym, yes); | ||
431 | case 'm': | ||
432 | case 'M': | ||
433 | return sym_tristate_within_range(sym, mod); | ||
434 | case 'n': | ||
435 | case 'N': | ||
436 | return sym_tristate_within_range(sym, no); | ||
437 | } | ||
438 | return false; | ||
439 | default: | ||
440 | return false; | ||
441 | } | ||
442 | } | ||
443 | |||
444 | bool sym_set_string_value(struct symbol *sym, const char *newval) | ||
445 | { | ||
446 | const char *oldval; | ||
447 | char *val; | ||
448 | int size; | ||
449 | |||
450 | switch (sym->type) { | ||
451 | case S_BOOLEAN: | ||
452 | case S_TRISTATE: | ||
453 | switch (newval[0]) { | ||
454 | case 'y': | ||
455 | case 'Y': | ||
456 | return sym_set_tristate_value(sym, yes); | ||
457 | case 'm': | ||
458 | case 'M': | ||
459 | return sym_set_tristate_value(sym, mod); | ||
460 | case 'n': | ||
461 | case 'N': | ||
462 | return sym_set_tristate_value(sym, no); | ||
463 | } | ||
464 | return false; | ||
465 | default: | ||
466 | ; | ||
467 | } | ||
468 | |||
469 | if (!sym_string_valid(sym, newval)) | ||
470 | return false; | ||
471 | |||
472 | if (sym->flags & SYMBOL_NEW) { | ||
473 | sym->flags &= ~SYMBOL_NEW; | ||
474 | sym->flags |= SYMBOL_CHANGED; | ||
475 | } | ||
476 | |||
477 | oldval = S_VAL(sym->def); | ||
478 | size = strlen(newval) + 1; | ||
479 | if (sym->type == S_HEX && (newval[0] != '0' || (newval[1] != 'x' && newval[1] != 'X'))) { | ||
480 | size += 2; | ||
481 | S_VAL(sym->def) = val = malloc(size); | ||
482 | *val++ = '0'; | ||
483 | *val++ = 'x'; | ||
484 | } else if (!oldval || strcmp(oldval, newval)) | ||
485 | S_VAL(sym->def) = val = malloc(size); | ||
486 | else | ||
487 | return true; | ||
488 | |||
489 | strcpy(val, newval); | ||
490 | free((void *)oldval); | ||
491 | sym_clear_all_valid(); | ||
492 | |||
493 | return true; | ||
494 | } | ||
495 | |||
496 | const char *sym_get_string_value(struct symbol *sym) | ||
497 | { | ||
498 | tristate val; | ||
499 | |||
500 | switch (sym->type) { | ||
501 | case S_BOOLEAN: | ||
502 | case S_TRISTATE: | ||
503 | val = sym_get_tristate_value(sym); | ||
504 | switch (val) { | ||
505 | case no: | ||
506 | return "n"; | ||
507 | case mod: | ||
508 | return "m"; | ||
509 | case yes: | ||
510 | return "y"; | ||
511 | } | ||
512 | break; | ||
513 | default: | ||
514 | ; | ||
515 | } | ||
516 | return (const char *)S_VAL(sym->curr); | ||
517 | } | ||
518 | |||
519 | bool sym_is_changable(struct symbol *sym) | ||
520 | { | ||
521 | if (sym->visible == no) | ||
522 | return false; | ||
523 | /* at least 'n' and 'y'/'m' is selectable */ | ||
524 | if (sym_is_optional(sym)) | ||
525 | return true; | ||
526 | /* no 'n', so 'y' and 'm' must be selectable */ | ||
527 | if (sym_get_type(sym) == S_TRISTATE && sym->visible == yes) | ||
528 | return true; | ||
529 | return false; | ||
530 | } | ||
531 | |||
532 | struct symbol *sym_lookup(const char *name, int isconst) | ||
533 | { | ||
534 | struct symbol *symbol; | ||
535 | const char *ptr; | ||
536 | char *new_name; | ||
537 | int hash = 0; | ||
538 | |||
539 | //printf("lookup: %s -> ", name); | ||
540 | if (name) { | ||
541 | if (name[0] && !name[1]) { | ||
542 | switch (name[0]) { | ||
543 | case 'y': return &symbol_yes; | ||
544 | case 'm': return &symbol_mod; | ||
545 | case 'n': return &symbol_no; | ||
546 | } | ||
547 | } | ||
548 | for (ptr = name; *ptr; ptr++) | ||
549 | hash += *ptr; | ||
550 | hash &= 0xff; | ||
551 | |||
552 | for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) { | ||
553 | if (!strcmp(symbol->name, name)) { | ||
554 | if ((isconst && symbol->flags & SYMBOL_CONST) || | ||
555 | (!isconst && !(symbol->flags & SYMBOL_CONST))) { | ||
556 | //printf("h:%p\n", symbol); | ||
557 | return symbol; | ||
558 | } | ||
559 | } | ||
560 | } | ||
561 | new_name = strdup(name); | ||
562 | } else { | ||
563 | new_name = NULL; | ||
564 | hash = 256; | ||
565 | } | ||
566 | |||
567 | symbol = malloc(sizeof(*symbol)); | ||
568 | memset(symbol, 0, sizeof(*symbol)); | ||
569 | symbol->name = new_name; | ||
570 | symbol->type = S_UNKNOWN; | ||
571 | symbol->flags = SYMBOL_NEW; | ||
572 | if (isconst) | ||
573 | symbol->flags |= SYMBOL_CONST; | ||
574 | |||
575 | symbol->next = symbol_hash[hash]; | ||
576 | symbol_hash[hash] = symbol; | ||
577 | |||
578 | //printf("n:%p\n", symbol); | ||
579 | return symbol; | ||
580 | } | ||
581 | |||
582 | struct symbol *sym_find(const char *name) | ||
583 | { | ||
584 | struct symbol *symbol = NULL; | ||
585 | const char *ptr; | ||
586 | int hash = 0; | ||
587 | |||
588 | if (!name) | ||
589 | return NULL; | ||
590 | |||
591 | if (name[0] && !name[1]) { | ||
592 | switch (name[0]) { | ||
593 | case 'y': return &symbol_yes; | ||
594 | case 'm': return &symbol_mod; | ||
595 | case 'n': return &symbol_no; | ||
596 | } | ||
597 | } | ||
598 | for (ptr = name; *ptr; ptr++) | ||
599 | hash += *ptr; | ||
600 | hash &= 0xff; | ||
601 | |||
602 | for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) { | ||
603 | if (!strcmp(symbol->name, name) && | ||
604 | !(symbol->flags & SYMBOL_CONST)) | ||
605 | break; | ||
606 | } | ||
607 | |||
608 | return symbol; | ||
609 | } | ||
610 | |||
611 | const char *prop_get_type_name(enum prop_type type) | ||
612 | { | ||
613 | switch (type) { | ||
614 | case P_PROMPT: | ||
615 | return "prompt"; | ||
616 | case P_COMMENT: | ||
617 | return "comment"; | ||
618 | case P_MENU: | ||
619 | return "menu"; | ||
620 | case P_ROOTMENU: | ||
621 | return "rootmenu"; | ||
622 | case P_DEFAULT: | ||
623 | return "default"; | ||
624 | case P_CHOICE: | ||
625 | return "choice"; | ||
626 | default: | ||
627 | return "unknown"; | ||
628 | } | ||
629 | } | ||
diff --git a/scripts/config/textbox.c b/scripts/config/textbox.c new file mode 100644 index 000000000..8fe907718 --- /dev/null +++ b/scripts/config/textbox.c | |||
@@ -0,0 +1,556 @@ | |||
1 | /* | ||
2 | * textbox.c -- implements the text box | ||
3 | * | ||
4 | * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) | ||
5 | * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; either version 2 | ||
10 | * of the License, or (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | */ | ||
21 | |||
22 | #include "dialog.h" | ||
23 | |||
24 | static void back_lines (int n); | ||
25 | static void print_page (WINDOW * win, int height, int width); | ||
26 | static void print_line (WINDOW * win, int row, int width); | ||
27 | static char *get_line (void); | ||
28 | static void print_position (WINDOW * win, int height, int width); | ||
29 | |||
30 | static int hscroll = 0, fd, file_size, bytes_read; | ||
31 | static int begin_reached = 1, end_reached = 0, page_length; | ||
32 | static char *buf, *page; | ||
33 | |||
34 | /* | ||
35 | * Display text from a file in a dialog box. | ||
36 | */ | ||
37 | int | ||
38 | dialog_textbox (const char *title, const char *file, int height, int width) | ||
39 | { | ||
40 | int i, x, y, cur_x, cur_y, fpos, key = 0; | ||
41 | int passed_end; | ||
42 | char search_term[MAX_LEN + 1]; | ||
43 | WINDOW *dialog, *text; | ||
44 | |||
45 | search_term[0] = '\0'; /* no search term entered yet */ | ||
46 | |||
47 | /* Open input file for reading */ | ||
48 | if ((fd = open (file, O_RDONLY)) == -1) { | ||
49 | endwin (); | ||
50 | fprintf (stderr, | ||
51 | "\nCan't open input file in dialog_textbox().\n"); | ||
52 | exit (-1); | ||
53 | } | ||
54 | /* Get file size. Actually, 'file_size' is the real file size - 1, | ||
55 | since it's only the last byte offset from the beginning */ | ||
56 | if ((file_size = lseek (fd, 0, SEEK_END)) == -1) { | ||
57 | endwin (); | ||
58 | fprintf (stderr, "\nError getting file size in dialog_textbox().\n"); | ||
59 | exit (-1); | ||
60 | } | ||
61 | /* Restore file pointer to beginning of file after getting file size */ | ||
62 | if (lseek (fd, 0, SEEK_SET) == -1) { | ||
63 | endwin (); | ||
64 | fprintf (stderr, "\nError moving file pointer in dialog_textbox().\n"); | ||
65 | exit (-1); | ||
66 | } | ||
67 | /* Allocate space for read buffer */ | ||
68 | if ((buf = malloc (BUF_SIZE + 1)) == NULL) { | ||
69 | endwin (); | ||
70 | fprintf (stderr, "\nCan't allocate memory in dialog_textbox().\n"); | ||
71 | exit (-1); | ||
72 | } | ||
73 | if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) { | ||
74 | endwin (); | ||
75 | fprintf (stderr, "\nError reading file in dialog_textbox().\n"); | ||
76 | exit (-1); | ||
77 | } | ||
78 | buf[bytes_read] = '\0'; /* mark end of valid data */ | ||
79 | page = buf; /* page is pointer to start of page to be displayed */ | ||
80 | |||
81 | /* center dialog box on screen */ | ||
82 | x = (COLS - width) / 2; | ||
83 | y = (LINES - height) / 2; | ||
84 | |||
85 | |||
86 | draw_shadow (stdscr, y, x, height, width); | ||
87 | |||
88 | dialog = newwin (height, width, y, x); | ||
89 | keypad (dialog, TRUE); | ||
90 | |||
91 | /* Create window for text region, used for scrolling text */ | ||
92 | text = subwin (dialog, height - 4, width - 2, y + 1, x + 1); | ||
93 | wattrset (text, dialog_attr); | ||
94 | wbkgdset (text, dialog_attr & A_COLOR); | ||
95 | |||
96 | keypad (text, TRUE); | ||
97 | |||
98 | /* register the new window, along with its borders */ | ||
99 | draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr); | ||
100 | |||
101 | wattrset (dialog, border_attr); | ||
102 | mvwaddch (dialog, height-3, 0, ACS_LTEE); | ||
103 | for (i = 0; i < width - 2; i++) | ||
104 | waddch (dialog, ACS_HLINE); | ||
105 | wattrset (dialog, dialog_attr); | ||
106 | wbkgdset (dialog, dialog_attr & A_COLOR); | ||
107 | waddch (dialog, ACS_RTEE); | ||
108 | |||
109 | if (title != NULL && strlen(title) >= width-2 ) { | ||
110 | /* truncate long title -- mec */ | ||
111 | char * title2 = malloc(width-2+1); | ||
112 | memcpy( title2, title, width-2 ); | ||
113 | title2[width-2] = '\0'; | ||
114 | title = title2; | ||
115 | } | ||
116 | |||
117 | if (title != NULL) { | ||
118 | wattrset (dialog, title_attr); | ||
119 | mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' '); | ||
120 | waddstr (dialog, (char *)title); | ||
121 | waddch (dialog, ' '); | ||
122 | } | ||
123 | print_button (dialog, " Exit ", height - 2, width / 2 - 4, TRUE); | ||
124 | wnoutrefresh (dialog); | ||
125 | getyx (dialog, cur_y, cur_x); /* Save cursor position */ | ||
126 | |||
127 | /* Print first page of text */ | ||
128 | attr_clear (text, height - 4, width - 2, dialog_attr); | ||
129 | print_page (text, height - 4, width - 2); | ||
130 | print_position (dialog, height, width); | ||
131 | wmove (dialog, cur_y, cur_x); /* Restore cursor position */ | ||
132 | wrefresh (dialog); | ||
133 | |||
134 | while ((key != ESC) && (key != '\n')) { | ||
135 | key = wgetch (dialog); | ||
136 | switch (key) { | ||
137 | case 'E': /* Exit */ | ||
138 | case 'e': | ||
139 | case 'X': | ||
140 | case 'x': | ||
141 | delwin (dialog); | ||
142 | free (buf); | ||
143 | close (fd); | ||
144 | return 0; | ||
145 | case 'g': /* First page */ | ||
146 | case KEY_HOME: | ||
147 | if (!begin_reached) { | ||
148 | begin_reached = 1; | ||
149 | /* First page not in buffer? */ | ||
150 | if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) { | ||
151 | endwin (); | ||
152 | fprintf (stderr, | ||
153 | "\nError moving file pointer in dialog_textbox().\n"); | ||
154 | exit (-1); | ||
155 | } | ||
156 | if (fpos > bytes_read) { /* Yes, we have to read it in */ | ||
157 | if (lseek (fd, 0, SEEK_SET) == -1) { | ||
158 | endwin (); | ||
159 | fprintf (stderr, "\nError moving file pointer in " | ||
160 | "dialog_textbox().\n"); | ||
161 | exit (-1); | ||
162 | } | ||
163 | if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) { | ||
164 | endwin (); | ||
165 | fprintf (stderr, | ||
166 | "\nError reading file in dialog_textbox().\n"); | ||
167 | exit (-1); | ||
168 | } | ||
169 | buf[bytes_read] = '\0'; | ||
170 | } | ||
171 | page = buf; | ||
172 | print_page (text, height - 4, width - 2); | ||
173 | print_position (dialog, height, width); | ||
174 | wmove (dialog, cur_y, cur_x); /* Restore cursor position */ | ||
175 | wrefresh (dialog); | ||
176 | } | ||
177 | break; | ||
178 | case 'G': /* Last page */ | ||
179 | case KEY_END: | ||
180 | |||
181 | end_reached = 1; | ||
182 | /* Last page not in buffer? */ | ||
183 | if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) { | ||
184 | endwin (); | ||
185 | fprintf (stderr, | ||
186 | "\nError moving file pointer in dialog_textbox().\n"); | ||
187 | exit (-1); | ||
188 | } | ||
189 | if (fpos < file_size) { /* Yes, we have to read it in */ | ||
190 | if (lseek (fd, -BUF_SIZE, SEEK_END) == -1) { | ||
191 | endwin (); | ||
192 | fprintf (stderr, | ||
193 | "\nError moving file pointer in dialog_textbox().\n"); | ||
194 | exit (-1); | ||
195 | } | ||
196 | if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) { | ||
197 | endwin (); | ||
198 | fprintf (stderr, | ||
199 | "\nError reading file in dialog_textbox().\n"); | ||
200 | exit (-1); | ||
201 | } | ||
202 | buf[bytes_read] = '\0'; | ||
203 | } | ||
204 | page = buf + bytes_read; | ||
205 | back_lines (height - 4); | ||
206 | print_page (text, height - 4, width - 2); | ||
207 | print_position (dialog, height, width); | ||
208 | wmove (dialog, cur_y, cur_x); /* Restore cursor position */ | ||
209 | wrefresh (dialog); | ||
210 | break; | ||
211 | case 'K': /* Previous line */ | ||
212 | case 'k': | ||
213 | case KEY_UP: | ||
214 | if (!begin_reached) { | ||
215 | back_lines (page_length + 1); | ||
216 | |||
217 | /* We don't call print_page() here but use scrolling to ensure | ||
218 | faster screen update. However, 'end_reached' and | ||
219 | 'page_length' should still be updated, and 'page' should | ||
220 | point to start of next page. This is done by calling | ||
221 | get_line() in the following 'for' loop. */ | ||
222 | scrollok (text, TRUE); | ||
223 | wscrl (text, -1); /* Scroll text region down one line */ | ||
224 | scrollok (text, FALSE); | ||
225 | page_length = 0; | ||
226 | passed_end = 0; | ||
227 | for (i = 0; i < height - 4; i++) { | ||
228 | if (!i) { | ||
229 | /* print first line of page */ | ||
230 | print_line (text, 0, width - 2); | ||
231 | wnoutrefresh (text); | ||
232 | } else | ||
233 | /* Called to update 'end_reached' and 'page' */ | ||
234 | get_line (); | ||
235 | if (!passed_end) | ||
236 | page_length++; | ||
237 | if (end_reached && !passed_end) | ||
238 | passed_end = 1; | ||
239 | } | ||
240 | |||
241 | print_position (dialog, height, width); | ||
242 | wmove (dialog, cur_y, cur_x); /* Restore cursor position */ | ||
243 | wrefresh (dialog); | ||
244 | } | ||
245 | break; | ||
246 | case 'B': /* Previous page */ | ||
247 | case 'b': | ||
248 | case KEY_PPAGE: | ||
249 | if (begin_reached) | ||
250 | break; | ||
251 | back_lines (page_length + height - 4); | ||
252 | print_page (text, height - 4, width - 2); | ||
253 | print_position (dialog, height, width); | ||
254 | wmove (dialog, cur_y, cur_x); | ||
255 | wrefresh (dialog); | ||
256 | break; | ||
257 | case 'J': /* Next line */ | ||
258 | case 'j': | ||
259 | case KEY_DOWN: | ||
260 | if (!end_reached) { | ||
261 | begin_reached = 0; | ||
262 | scrollok (text, TRUE); | ||
263 | scroll (text); /* Scroll text region up one line */ | ||
264 | scrollok (text, FALSE); | ||
265 | print_line (text, height - 5, width - 2); | ||
266 | wnoutrefresh (text); | ||
267 | print_position (dialog, height, width); | ||
268 | wmove (dialog, cur_y, cur_x); /* Restore cursor position */ | ||
269 | wrefresh (dialog); | ||
270 | } | ||
271 | break; | ||
272 | case KEY_NPAGE: /* Next page */ | ||
273 | case ' ': | ||
274 | if (end_reached) | ||
275 | break; | ||
276 | |||
277 | begin_reached = 0; | ||
278 | print_page (text, height - 4, width - 2); | ||
279 | print_position (dialog, height, width); | ||
280 | wmove (dialog, cur_y, cur_x); | ||
281 | wrefresh (dialog); | ||
282 | break; | ||
283 | case '0': /* Beginning of line */ | ||
284 | case 'H': /* Scroll left */ | ||
285 | case 'h': | ||
286 | case KEY_LEFT: | ||
287 | if (hscroll <= 0) | ||
288 | break; | ||
289 | |||
290 | if (key == '0') | ||
291 | hscroll = 0; | ||
292 | else | ||
293 | hscroll--; | ||
294 | /* Reprint current page to scroll horizontally */ | ||
295 | back_lines (page_length); | ||
296 | print_page (text, height - 4, width - 2); | ||
297 | wmove (dialog, cur_y, cur_x); | ||
298 | wrefresh (dialog); | ||
299 | break; | ||
300 | case 'L': /* Scroll right */ | ||
301 | case 'l': | ||
302 | case KEY_RIGHT: | ||
303 | if (hscroll >= MAX_LEN) | ||
304 | break; | ||
305 | hscroll++; | ||
306 | /* Reprint current page to scroll horizontally */ | ||
307 | back_lines (page_length); | ||
308 | print_page (text, height - 4, width - 2); | ||
309 | wmove (dialog, cur_y, cur_x); | ||
310 | wrefresh (dialog); | ||
311 | break; | ||
312 | case ESC: | ||
313 | break; | ||
314 | } | ||
315 | } | ||
316 | |||
317 | delwin (dialog); | ||
318 | free (buf); | ||
319 | close (fd); | ||
320 | return 1; /* ESC pressed */ | ||
321 | } | ||
322 | |||
323 | /* | ||
324 | * Go back 'n' lines in text file. Called by dialog_textbox(). | ||
325 | * 'page' will be updated to point to the desired line in 'buf'. | ||
326 | */ | ||
327 | static void | ||
328 | back_lines (int n) | ||
329 | { | ||
330 | int i, fpos; | ||
331 | |||
332 | begin_reached = 0; | ||
333 | /* We have to distinguish between end_reached and !end_reached | ||
334 | since at end of file, the line is not ended by a '\n'. | ||
335 | The code inside 'if' basically does a '--page' to move one | ||
336 | character backward so as to skip '\n' of the previous line */ | ||
337 | if (!end_reached) { | ||
338 | /* Either beginning of buffer or beginning of file reached? */ | ||
339 | if (page == buf) { | ||
340 | if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) { | ||
341 | endwin (); | ||
342 | fprintf (stderr, "\nError moving file pointer in " | ||
343 | "back_lines().\n"); | ||
344 | exit (-1); | ||
345 | } | ||
346 | if (fpos > bytes_read) { /* Not beginning of file yet */ | ||
347 | /* We've reached beginning of buffer, but not beginning of | ||
348 | file yet, so read previous part of file into buffer. | ||
349 | Note that we only move backward for BUF_SIZE/2 bytes, | ||
350 | but not BUF_SIZE bytes to avoid re-reading again in | ||
351 | print_page() later */ | ||
352 | /* Really possible to move backward BUF_SIZE/2 bytes? */ | ||
353 | if (fpos < BUF_SIZE / 2 + bytes_read) { | ||
354 | /* No, move less then */ | ||
355 | if (lseek (fd, 0, SEEK_SET) == -1) { | ||
356 | endwin (); | ||
357 | fprintf (stderr, "\nError moving file pointer in " | ||
358 | "back_lines().\n"); | ||
359 | exit (-1); | ||
360 | } | ||
361 | page = buf + fpos - bytes_read; | ||
362 | } else { /* Move backward BUF_SIZE/2 bytes */ | ||
363 | if (lseek (fd, -(BUF_SIZE / 2 + bytes_read), SEEK_CUR) | ||
364 | == -1) { | ||
365 | endwin (); | ||
366 | fprintf (stderr, "\nError moving file pointer " | ||
367 | "in back_lines().\n"); | ||
368 | exit (-1); | ||
369 | } | ||
370 | page = buf + BUF_SIZE / 2; | ||
371 | } | ||
372 | if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) { | ||
373 | endwin (); | ||
374 | fprintf (stderr, "\nError reading file in back_lines().\n"); | ||
375 | exit (-1); | ||
376 | } | ||
377 | buf[bytes_read] = '\0'; | ||
378 | } else { /* Beginning of file reached */ | ||
379 | begin_reached = 1; | ||
380 | return; | ||
381 | } | ||
382 | } | ||
383 | if (*(--page) != '\n') { /* '--page' here */ | ||
384 | /* Something's wrong... */ | ||
385 | endwin (); | ||
386 | fprintf (stderr, "\nInternal error in back_lines().\n"); | ||
387 | exit (-1); | ||
388 | } | ||
389 | } | ||
390 | /* Go back 'n' lines */ | ||
391 | for (i = 0; i < n; i++) | ||
392 | do { | ||
393 | if (page == buf) { | ||
394 | if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) { | ||
395 | endwin (); | ||
396 | fprintf (stderr, | ||
397 | "\nError moving file pointer in back_lines().\n"); | ||
398 | exit (-1); | ||
399 | } | ||
400 | if (fpos > bytes_read) { | ||
401 | /* Really possible to move backward BUF_SIZE/2 bytes? */ | ||
402 | if (fpos < BUF_SIZE / 2 + bytes_read) { | ||
403 | /* No, move less then */ | ||
404 | if (lseek (fd, 0, SEEK_SET) == -1) { | ||
405 | endwin (); | ||
406 | fprintf (stderr, "\nError moving file pointer " | ||
407 | "in back_lines().\n"); | ||
408 | exit (-1); | ||
409 | } | ||
410 | page = buf + fpos - bytes_read; | ||
411 | } else { /* Move backward BUF_SIZE/2 bytes */ | ||
412 | if (lseek (fd, -(BUF_SIZE / 2 + bytes_read), | ||
413 | SEEK_CUR) == -1) { | ||
414 | endwin (); | ||
415 | fprintf (stderr, "\nError moving file pointer" | ||
416 | " in back_lines().\n"); | ||
417 | exit (-1); | ||
418 | } | ||
419 | page = buf + BUF_SIZE / 2; | ||
420 | } | ||
421 | if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) { | ||
422 | endwin (); | ||
423 | fprintf (stderr, "\nError reading file in " | ||
424 | "back_lines().\n"); | ||
425 | exit (-1); | ||
426 | } | ||
427 | buf[bytes_read] = '\0'; | ||
428 | } else { /* Beginning of file reached */ | ||
429 | begin_reached = 1; | ||
430 | return; | ||
431 | } | ||
432 | } | ||
433 | } while (*(--page) != '\n'); | ||
434 | page++; | ||
435 | } | ||
436 | |||
437 | /* | ||
438 | * Print a new page of text. Called by dialog_textbox(). | ||
439 | */ | ||
440 | static void | ||
441 | print_page (WINDOW * win, int height, int width) | ||
442 | { | ||
443 | int i, passed_end = 0; | ||
444 | |||
445 | page_length = 0; | ||
446 | for (i = 0; i < height; i++) { | ||
447 | print_line (win, i, width); | ||
448 | if (!passed_end) | ||
449 | page_length++; | ||
450 | if (end_reached && !passed_end) | ||
451 | passed_end = 1; | ||
452 | } | ||
453 | wnoutrefresh (win); | ||
454 | } | ||
455 | |||
456 | /* | ||
457 | * Print a new line of text. Called by dialog_textbox() and print_page(). | ||
458 | */ | ||
459 | static void | ||
460 | print_line (WINDOW * win, int row, int width) | ||
461 | { | ||
462 | int y, x; | ||
463 | char *line; | ||
464 | |||
465 | line = get_line (); | ||
466 | line += MIN (strlen (line), hscroll); /* Scroll horizontally */ | ||
467 | wmove (win, row, 0); /* move cursor to correct line */ | ||
468 | waddch (win, ' '); | ||
469 | waddnstr (win, line, MIN (strlen (line), width - 2)); | ||
470 | |||
471 | getyx (win, y, x); | ||
472 | /* Clear 'residue' of previous line */ | ||
473 | #if OLD_NCURSES | ||
474 | { | ||
475 | int i; | ||
476 | for (i = 0; i < width - x; i++) | ||
477 | waddch (win, ' '); | ||
478 | } | ||
479 | #else | ||
480 | wclrtoeol(win); | ||
481 | #endif | ||
482 | } | ||
483 | |||
484 | /* | ||
485 | * Return current line of text. Called by dialog_textbox() and print_line(). | ||
486 | * 'page' should point to start of current line before calling, and will be | ||
487 | * updated to point to start of next line. | ||
488 | */ | ||
489 | static char * | ||
490 | get_line (void) | ||
491 | { | ||
492 | int i = 0, fpos; | ||
493 | static char line[MAX_LEN + 1]; | ||
494 | |||
495 | end_reached = 0; | ||
496 | while (*page != '\n') { | ||
497 | if (*page == '\0') { | ||
498 | /* Either end of file or end of buffer reached */ | ||
499 | if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) { | ||
500 | endwin (); | ||
501 | fprintf (stderr, "\nError moving file pointer in " | ||
502 | "get_line().\n"); | ||
503 | exit (-1); | ||
504 | } | ||
505 | if (fpos < file_size) { /* Not end of file yet */ | ||
506 | /* We've reached end of buffer, but not end of file yet, | ||
507 | so read next part of file into buffer */ | ||
508 | if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) { | ||
509 | endwin (); | ||
510 | fprintf (stderr, "\nError reading file in get_line().\n"); | ||
511 | exit (-1); | ||
512 | } | ||
513 | buf[bytes_read] = '\0'; | ||
514 | page = buf; | ||
515 | } else { | ||
516 | if (!end_reached) | ||
517 | end_reached = 1; | ||
518 | break; | ||
519 | } | ||
520 | } else if (i < MAX_LEN) | ||
521 | line[i++] = *(page++); | ||
522 | else { | ||
523 | /* Truncate lines longer than MAX_LEN characters */ | ||
524 | if (i == MAX_LEN) | ||
525 | line[i++] = '\0'; | ||
526 | page++; | ||
527 | } | ||
528 | } | ||
529 | if (i <= MAX_LEN) | ||
530 | line[i] = '\0'; | ||
531 | if (!end_reached) | ||
532 | page++; /* move pass '\n' */ | ||
533 | |||
534 | return line; | ||
535 | } | ||
536 | |||
537 | /* | ||
538 | * Print current position | ||
539 | */ | ||
540 | static void | ||
541 | print_position (WINDOW * win, int height, int width) | ||
542 | { | ||
543 | int fpos, percent; | ||
544 | |||
545 | if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) { | ||
546 | endwin (); | ||
547 | fprintf (stderr, "\nError moving file pointer in print_position().\n"); | ||
548 | exit (-1); | ||
549 | } | ||
550 | wattrset (win, position_indicator_attr); | ||
551 | wbkgdset (win, position_indicator_attr & A_COLOR); | ||
552 | percent = !file_size ? | ||
553 | 100 : ((fpos - bytes_read + page - buf) * 100) / file_size; | ||
554 | wmove (win, height - 3, width - 9); | ||
555 | wprintw (win, "(%3d%%)", percent); | ||
556 | } | ||
diff --git a/scripts/config/util.c b/scripts/config/util.c new file mode 100644 index 000000000..d20730b88 --- /dev/null +++ b/scripts/config/util.c | |||
@@ -0,0 +1,375 @@ | |||
1 | /* | ||
2 | * util.c | ||
3 | * | ||
4 | * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) | ||
5 | * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; either version 2 | ||
10 | * of the License, or (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | */ | ||
21 | |||
22 | #include "dialog.h" | ||
23 | |||
24 | |||
25 | /* use colors by default? */ | ||
26 | bool use_colors = 1; | ||
27 | |||
28 | char *backtitle = NULL; | ||
29 | |||
30 | const char *dialog_result; | ||
31 | |||
32 | /* | ||
33 | * Attribute values, default is for mono display | ||
34 | */ | ||
35 | chtype attributes[] = | ||
36 | { | ||
37 | A_NORMAL, /* screen_attr */ | ||
38 | A_NORMAL, /* shadow_attr */ | ||
39 | A_NORMAL, /* dialog_attr */ | ||
40 | A_BOLD, /* title_attr */ | ||
41 | A_NORMAL, /* border_attr */ | ||
42 | A_REVERSE, /* button_active_attr */ | ||
43 | A_DIM, /* button_inactive_attr */ | ||
44 | A_REVERSE, /* button_key_active_attr */ | ||
45 | A_BOLD, /* button_key_inactive_attr */ | ||
46 | A_REVERSE, /* button_label_active_attr */ | ||
47 | A_NORMAL, /* button_label_inactive_attr */ | ||
48 | A_NORMAL, /* inputbox_attr */ | ||
49 | A_NORMAL, /* inputbox_border_attr */ | ||
50 | A_NORMAL, /* searchbox_attr */ | ||
51 | A_BOLD, /* searchbox_title_attr */ | ||
52 | A_NORMAL, /* searchbox_border_attr */ | ||
53 | A_BOLD, /* position_indicator_attr */ | ||
54 | A_NORMAL, /* menubox_attr */ | ||
55 | A_NORMAL, /* menubox_border_attr */ | ||
56 | A_NORMAL, /* item_attr */ | ||
57 | A_REVERSE, /* item_selected_attr */ | ||
58 | A_BOLD, /* tag_attr */ | ||
59 | A_REVERSE, /* tag_selected_attr */ | ||
60 | A_BOLD, /* tag_key_attr */ | ||
61 | A_REVERSE, /* tag_key_selected_attr */ | ||
62 | A_BOLD, /* check_attr */ | ||
63 | A_REVERSE, /* check_selected_attr */ | ||
64 | A_BOLD, /* uarrow_attr */ | ||
65 | A_BOLD /* darrow_attr */ | ||
66 | }; | ||
67 | |||
68 | |||
69 | #include "colors.h" | ||
70 | |||
71 | /* | ||
72 | * Table of color values | ||
73 | */ | ||
74 | int color_table[][3] = | ||
75 | { | ||
76 | {SCREEN_FG, SCREEN_BG, SCREEN_HL}, | ||
77 | {SHADOW_FG, SHADOW_BG, SHADOW_HL}, | ||
78 | {DIALOG_FG, DIALOG_BG, DIALOG_HL}, | ||
79 | {TITLE_FG, TITLE_BG, TITLE_HL}, | ||
80 | {BORDER_FG, BORDER_BG, BORDER_HL}, | ||
81 | {BUTTON_ACTIVE_FG, BUTTON_ACTIVE_BG, BUTTON_ACTIVE_HL}, | ||
82 | {BUTTON_INACTIVE_FG, BUTTON_INACTIVE_BG, BUTTON_INACTIVE_HL}, | ||
83 | {BUTTON_KEY_ACTIVE_FG, BUTTON_KEY_ACTIVE_BG, BUTTON_KEY_ACTIVE_HL}, | ||
84 | {BUTTON_KEY_INACTIVE_FG, BUTTON_KEY_INACTIVE_BG, BUTTON_KEY_INACTIVE_HL}, | ||
85 | {BUTTON_LABEL_ACTIVE_FG, BUTTON_LABEL_ACTIVE_BG, BUTTON_LABEL_ACTIVE_HL}, | ||
86 | {BUTTON_LABEL_INACTIVE_FG, BUTTON_LABEL_INACTIVE_BG, | ||
87 | BUTTON_LABEL_INACTIVE_HL}, | ||
88 | {INPUTBOX_FG, INPUTBOX_BG, INPUTBOX_HL}, | ||
89 | {INPUTBOX_BORDER_FG, INPUTBOX_BORDER_BG, INPUTBOX_BORDER_HL}, | ||
90 | {SEARCHBOX_FG, SEARCHBOX_BG, SEARCHBOX_HL}, | ||
91 | {SEARCHBOX_TITLE_FG, SEARCHBOX_TITLE_BG, SEARCHBOX_TITLE_HL}, | ||
92 | {SEARCHBOX_BORDER_FG, SEARCHBOX_BORDER_BG, SEARCHBOX_BORDER_HL}, | ||
93 | {POSITION_INDICATOR_FG, POSITION_INDICATOR_BG, POSITION_INDICATOR_HL}, | ||
94 | {MENUBOX_FG, MENUBOX_BG, MENUBOX_HL}, | ||
95 | {MENUBOX_BORDER_FG, MENUBOX_BORDER_BG, MENUBOX_BORDER_HL}, | ||
96 | {ITEM_FG, ITEM_BG, ITEM_HL}, | ||
97 | {ITEM_SELECTED_FG, ITEM_SELECTED_BG, ITEM_SELECTED_HL}, | ||
98 | {TAG_FG, TAG_BG, TAG_HL}, | ||
99 | {TAG_SELECTED_FG, TAG_SELECTED_BG, TAG_SELECTED_HL}, | ||
100 | {TAG_KEY_FG, TAG_KEY_BG, TAG_KEY_HL}, | ||
101 | {TAG_KEY_SELECTED_FG, TAG_KEY_SELECTED_BG, TAG_KEY_SELECTED_HL}, | ||
102 | {CHECK_FG, CHECK_BG, CHECK_HL}, | ||
103 | {CHECK_SELECTED_FG, CHECK_SELECTED_BG, CHECK_SELECTED_HL}, | ||
104 | {UARROW_FG, UARROW_BG, UARROW_HL}, | ||
105 | {DARROW_FG, DARROW_BG, DARROW_HL}, | ||
106 | }; /* color_table */ | ||
107 | |||
108 | /* | ||
109 | * Set window to attribute 'attr' | ||
110 | */ | ||
111 | void | ||
112 | attr_clear (WINDOW * win, int height, int width, chtype attr) | ||
113 | { | ||
114 | int i, j; | ||
115 | |||
116 | wattrset (win, attr); | ||
117 | for (i = 0; i < height; i++) { | ||
118 | wmove (win, i, 0); | ||
119 | for (j = 0; j < width; j++) | ||
120 | waddch (win, ' '); | ||
121 | } | ||
122 | touchwin (win); | ||
123 | } | ||
124 | |||
125 | void dialog_clear (void) | ||
126 | { | ||
127 | attr_clear (stdscr, LINES, COLS, screen_attr); | ||
128 | /* Display background title if it exists ... - SLH */ | ||
129 | if (backtitle != NULL) { | ||
130 | int i; | ||
131 | |||
132 | wattrset (stdscr, screen_attr); | ||
133 | mvwaddstr (stdscr, 0, 1, (char *)backtitle); | ||
134 | wmove (stdscr, 1, 1); | ||
135 | for (i = 1; i < COLS - 1; i++) | ||
136 | waddch (stdscr, ACS_HLINE); | ||
137 | } | ||
138 | wnoutrefresh (stdscr); | ||
139 | } | ||
140 | |||
141 | /* | ||
142 | * Do some initialization for dialog | ||
143 | */ | ||
144 | void | ||
145 | init_dialog (void) | ||
146 | { | ||
147 | initscr (); /* Init curses */ | ||
148 | keypad (stdscr, TRUE); | ||
149 | cbreak (); | ||
150 | noecho (); | ||
151 | |||
152 | |||
153 | if (use_colors) /* Set up colors */ | ||
154 | color_setup (); | ||
155 | |||
156 | |||
157 | dialog_clear (); | ||
158 | } | ||
159 | |||
160 | /* | ||
161 | * Setup for color display | ||
162 | */ | ||
163 | void | ||
164 | color_setup (void) | ||
165 | { | ||
166 | int i; | ||
167 | |||
168 | if (has_colors ()) { /* Terminal supports color? */ | ||
169 | start_color (); | ||
170 | |||
171 | /* Initialize color pairs */ | ||
172 | for (i = 0; i < ATTRIBUTE_COUNT; i++) | ||
173 | init_pair (i + 1, color_table[i][0], color_table[i][1]); | ||
174 | |||
175 | /* Setup color attributes */ | ||
176 | for (i = 0; i < ATTRIBUTE_COUNT; i++) | ||
177 | attributes[i] = C_ATTR (color_table[i][2], i + 1); | ||
178 | } | ||
179 | } | ||
180 | |||
181 | /* | ||
182 | * End using dialog functions. | ||
183 | */ | ||
184 | void | ||
185 | end_dialog (void) | ||
186 | { | ||
187 | endwin (); | ||
188 | } | ||
189 | |||
190 | |||
191 | /* | ||
192 | * Print a string of text in a window, automatically wrap around to the | ||
193 | * next line if the string is too long to fit on one line. Newline | ||
194 | * characters '\n' are replaced by spaces. We start on a new line | ||
195 | * if there is no room for at least 4 nonblanks following a double-space. | ||
196 | */ | ||
197 | void | ||
198 | print_autowrap (WINDOW * win, const char *prompt, int width, int y, int x) | ||
199 | { | ||
200 | int newl, cur_x, cur_y; | ||
201 | int i, prompt_len, room, wlen; | ||
202 | char tempstr[MAX_LEN + 1], *word, *sp, *sp2; | ||
203 | |||
204 | strcpy (tempstr, prompt); | ||
205 | |||
206 | prompt_len = strlen(tempstr); | ||
207 | |||
208 | /* | ||
209 | * Remove newlines | ||
210 | */ | ||
211 | for(i=0; i<prompt_len; i++) { | ||
212 | if(tempstr[i] == '\n') tempstr[i] = ' '; | ||
213 | } | ||
214 | |||
215 | if (prompt_len <= width - x * 2) { /* If prompt is short */ | ||
216 | wmove (win, y, (width - prompt_len) / 2); | ||
217 | waddstr (win, tempstr); | ||
218 | } else { | ||
219 | cur_x = x; | ||
220 | cur_y = y; | ||
221 | newl = 1; | ||
222 | word = tempstr; | ||
223 | while (word && *word) { | ||
224 | sp = index(word, ' '); | ||
225 | if (sp) | ||
226 | *sp++ = 0; | ||
227 | |||
228 | /* Wrap to next line if either the word does not fit, | ||
229 | or it is the first word of a new sentence, and it is | ||
230 | short, and the next word does not fit. */ | ||
231 | room = width - cur_x; | ||
232 | wlen = strlen(word); | ||
233 | if (wlen > room || | ||
234 | (newl && wlen < 4 && sp && wlen+1+strlen(sp) > room | ||
235 | && (!(sp2 = index(sp, ' ')) || wlen+1+(sp2-sp) > room))) { | ||
236 | cur_y++; | ||
237 | cur_x = x; | ||
238 | } | ||
239 | wmove (win, cur_y, cur_x); | ||
240 | waddstr (win, word); | ||
241 | getyx (win, cur_y, cur_x); | ||
242 | cur_x++; | ||
243 | if (sp && *sp == ' ') { | ||
244 | cur_x++; /* double space */ | ||
245 | while (*++sp == ' '); | ||
246 | newl = 1; | ||
247 | } else | ||
248 | newl = 0; | ||
249 | word = sp; | ||
250 | } | ||
251 | } | ||
252 | } | ||
253 | |||
254 | /* | ||
255 | * Print a button | ||
256 | */ | ||
257 | void | ||
258 | print_button (WINDOW * win, const char *label, int y, int x, int selected) | ||
259 | { | ||
260 | int i, temp; | ||
261 | |||
262 | wmove (win, y, x); | ||
263 | wattrset (win, selected ? button_active_attr : button_inactive_attr); | ||
264 | waddstr (win, "<"); | ||
265 | temp = strspn (label, " "); | ||
266 | label += temp; | ||
267 | wattrset (win, selected ? button_label_active_attr | ||
268 | : button_label_inactive_attr); | ||
269 | for (i = 0; i < temp; i++) | ||
270 | waddch (win, ' '); | ||
271 | wattrset (win, selected ? button_key_active_attr | ||
272 | : button_key_inactive_attr); | ||
273 | waddch (win, label[0]); | ||
274 | wattrset (win, selected ? button_label_active_attr | ||
275 | : button_label_inactive_attr); | ||
276 | waddstr (win, (char *)label + 1); | ||
277 | wattrset (win, selected ? button_active_attr : button_inactive_attr); | ||
278 | waddstr (win, ">"); | ||
279 | wmove (win, y, x + temp + 1); | ||
280 | } | ||
281 | |||
282 | /* | ||
283 | * Draw a rectangular box with line drawing characters | ||
284 | */ | ||
285 | void | ||
286 | draw_box (WINDOW * win, int y, int x, int height, int width, | ||
287 | chtype box, chtype border) | ||
288 | { | ||
289 | int i, j; | ||
290 | |||
291 | wattrset (win, 0); | ||
292 | for (i = 0; i < height; i++) { | ||
293 | wmove (win, y + i, x); | ||
294 | for (j = 0; j < width; j++) | ||
295 | if (!i && !j) | ||
296 | waddch (win, border | ACS_ULCORNER); | ||
297 | else if (i == height - 1 && !j) | ||
298 | waddch (win, border | ACS_LLCORNER); | ||
299 | else if (!i && j == width - 1) | ||
300 | waddch (win, box | ACS_URCORNER); | ||
301 | else if (i == height - 1 && j == width - 1) | ||
302 | waddch (win, box | ACS_LRCORNER); | ||
303 | else if (!i) | ||
304 | waddch (win, border | ACS_HLINE); | ||
305 | else if (i == height - 1) | ||
306 | waddch (win, box | ACS_HLINE); | ||
307 | else if (!j) | ||
308 | waddch (win, border | ACS_VLINE); | ||
309 | else if (j == width - 1) | ||
310 | waddch (win, box | ACS_VLINE); | ||
311 | else | ||
312 | waddch (win, box | ' '); | ||
313 | } | ||
314 | } | ||
315 | |||
316 | /* | ||
317 | * Draw shadows along the right and bottom edge to give a more 3D look | ||
318 | * to the boxes | ||
319 | */ | ||
320 | void | ||
321 | draw_shadow (WINDOW * win, int y, int x, int height, int width) | ||
322 | { | ||
323 | int i; | ||
324 | |||
325 | if (has_colors ()) { /* Whether terminal supports color? */ | ||
326 | wattrset (win, shadow_attr); | ||
327 | wmove (win, y + height, x + 2); | ||
328 | for (i = 0; i < width; i++) | ||
329 | waddch (win, winch (win) & A_CHARTEXT); | ||
330 | for (i = y + 1; i < y + height + 1; i++) { | ||
331 | wmove (win, i, x + width); | ||
332 | waddch (win, winch (win) & A_CHARTEXT); | ||
333 | waddch (win, winch (win) & A_CHARTEXT); | ||
334 | } | ||
335 | wnoutrefresh (win); | ||
336 | } | ||
337 | } | ||
338 | |||
339 | /* | ||
340 | * Return the position of the first alphabetic character in a string. | ||
341 | */ | ||
342 | int | ||
343 | first_alpha(const char *string, const char *exempt) | ||
344 | { | ||
345 | int i, in_paren=0, c; | ||
346 | |||
347 | for (i = 0; i < strlen(string); i++) { | ||
348 | c = tolower(string[i]); | ||
349 | |||
350 | if (strchr("<[(", c)) ++in_paren; | ||
351 | if (strchr(">])", c)) --in_paren; | ||
352 | |||
353 | if ((! in_paren) && isalpha(c) && | ||
354 | strchr(exempt, c) == 0) | ||
355 | return i; | ||
356 | } | ||
357 | |||
358 | return 0; | ||
359 | } | ||
360 | |||
361 | /* | ||
362 | * Get the first selected item in the dialog_list_item list. | ||
363 | */ | ||
364 | struct dialog_list_item * | ||
365 | first_sel_item(int item_no, struct dialog_list_item ** items) | ||
366 | { | ||
367 | int i; | ||
368 | |||
369 | for (i = 0; i < item_no; i++) { | ||
370 | if (items[i]->selected) | ||
371 | return items[i]; | ||
372 | } | ||
373 | |||
374 | return NULL; | ||
375 | } | ||
diff --git a/scripts/config/yesno.c b/scripts/config/yesno.c new file mode 100644 index 000000000..11fcc25f5 --- /dev/null +++ b/scripts/config/yesno.c | |||
@@ -0,0 +1,118 @@ | |||
1 | /* | ||
2 | * yesno.c -- implements the yes/no box | ||
3 | * | ||
4 | * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) | ||
5 | * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; either version 2 | ||
10 | * of the License, or (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | */ | ||
21 | |||
22 | #include "dialog.h" | ||
23 | |||
24 | /* | ||
25 | * Display termination buttons | ||
26 | */ | ||
27 | static void | ||
28 | print_buttons(WINDOW *dialog, int height, int width, int selected) | ||
29 | { | ||
30 | int x = width / 2 - 10; | ||
31 | int y = height - 2; | ||
32 | |||
33 | print_button (dialog, " Yes ", y, x, selected == 0); | ||
34 | print_button (dialog, " No ", y, x + 13, selected == 1); | ||
35 | |||
36 | wmove(dialog, y, x+1 + 13*selected ); | ||
37 | wrefresh (dialog); | ||
38 | } | ||
39 | |||
40 | /* | ||
41 | * Display a dialog box with two buttons - Yes and No | ||
42 | */ | ||
43 | int | ||
44 | dialog_yesno (const char *title, const char *prompt, int height, int width) | ||
45 | { | ||
46 | int i, x, y, key = 0, button = 0; | ||
47 | WINDOW *dialog; | ||
48 | |||
49 | /* center dialog box on screen */ | ||
50 | x = (COLS - width) / 2; | ||
51 | y = (LINES - height) / 2; | ||
52 | |||
53 | draw_shadow (stdscr, y, x, height, width); | ||
54 | |||
55 | dialog = newwin (height, width, y, x); | ||
56 | keypad (dialog, TRUE); | ||
57 | |||
58 | draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr); | ||
59 | wattrset (dialog, border_attr); | ||
60 | mvwaddch (dialog, height-3, 0, ACS_LTEE); | ||
61 | for (i = 0; i < width - 2; i++) | ||
62 | waddch (dialog, ACS_HLINE); | ||
63 | wattrset (dialog, dialog_attr); | ||
64 | waddch (dialog, ACS_RTEE); | ||
65 | |||
66 | if (title != NULL && strlen(title) >= width-2 ) { | ||
67 | /* truncate long title -- mec */ | ||
68 | char * title2 = malloc(width-2+1); | ||
69 | memcpy( title2, title, width-2 ); | ||
70 | title2[width-2] = '\0'; | ||
71 | title = title2; | ||
72 | } | ||
73 | |||
74 | if (title != NULL) { | ||
75 | wattrset (dialog, title_attr); | ||
76 | mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' '); | ||
77 | waddstr (dialog, (char *)title); | ||
78 | waddch (dialog, ' '); | ||
79 | } | ||
80 | |||
81 | wattrset (dialog, dialog_attr); | ||
82 | print_autowrap (dialog, prompt, width - 2, 1, 3); | ||
83 | |||
84 | print_buttons(dialog, height, width, 0); | ||
85 | |||
86 | while (key != ESC) { | ||
87 | key = wgetch (dialog); | ||
88 | switch (key) { | ||
89 | case 'Y': | ||
90 | case 'y': | ||
91 | delwin (dialog); | ||
92 | return 0; | ||
93 | case 'N': | ||
94 | case 'n': | ||
95 | delwin (dialog); | ||
96 | return 1; | ||
97 | |||
98 | case TAB: | ||
99 | case KEY_LEFT: | ||
100 | case KEY_RIGHT: | ||
101 | button = ((key == KEY_LEFT ? --button : ++button) < 0) | ||
102 | ? 1 : (button > 1 ? 0 : button); | ||
103 | |||
104 | print_buttons(dialog, height, width, button); | ||
105 | wrefresh (dialog); | ||
106 | break; | ||
107 | case ' ': | ||
108 | case '\n': | ||
109 | delwin (dialog); | ||
110 | return button; | ||
111 | case ESC: | ||
112 | break; | ||
113 | } | ||
114 | } | ||
115 | |||
116 | delwin (dialog); | ||
117 | return -1; /* ESC pressed */ | ||
118 | } | ||
diff --git a/scripts/config/zconf.l b/scripts/config/zconf.l new file mode 100644 index 000000000..a412bf411 --- /dev/null +++ b/scripts/config/zconf.l | |||
@@ -0,0 +1,332 @@ | |||
1 | %option backup nostdinit noyywrap never-interactive full ecs | ||
2 | %option 8bit backup nodefault perf-report perf-report | ||
3 | %x COMMAND HELP STRING PARAM | ||
4 | %{ | ||
5 | /* | ||
6 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> | ||
7 | * Released under the terms of the GNU GPL v2.0. | ||
8 | */ | ||
9 | |||
10 | #include <stdio.h> | ||
11 | #include <stdlib.h> | ||
12 | #include <string.h> | ||
13 | #include <unistd.h> | ||
14 | |||
15 | #define LKC_DIRECT_LINK | ||
16 | #include "lkc.h" | ||
17 | #include "zconf.tab.h" | ||
18 | |||
19 | #define START_STRSIZE 16 | ||
20 | |||
21 | char *text; | ||
22 | static char *text_ptr; | ||
23 | static int text_size, text_asize; | ||
24 | |||
25 | struct buffer { | ||
26 | struct buffer *parent; | ||
27 | YY_BUFFER_STATE state; | ||
28 | }; | ||
29 | |||
30 | struct buffer *current_buf; | ||
31 | |||
32 | static int last_ts, first_ts; | ||
33 | |||
34 | static void zconf_endhelp(void); | ||
35 | static struct buffer *zconf_endfile(void); | ||
36 | |||
37 | void new_string(void) | ||
38 | { | ||
39 | text = malloc(START_STRSIZE); | ||
40 | text_asize = START_STRSIZE; | ||
41 | text_ptr = text; | ||
42 | text_size = 0; | ||
43 | *text_ptr = 0; | ||
44 | } | ||
45 | |||
46 | void append_string(const char *str, int size) | ||
47 | { | ||
48 | int new_size = text_size + size + 1; | ||
49 | if (new_size > text_asize) { | ||
50 | text = realloc(text, new_size); | ||
51 | text_asize = new_size; | ||
52 | text_ptr = text + text_size; | ||
53 | } | ||
54 | memcpy(text_ptr, str, size); | ||
55 | text_ptr += size; | ||
56 | text_size += size; | ||
57 | *text_ptr = 0; | ||
58 | } | ||
59 | |||
60 | void alloc_string(const char *str, int size) | ||
61 | { | ||
62 | text = malloc(size + 1); | ||
63 | memcpy(text, str, size); | ||
64 | text[size] = 0; | ||
65 | } | ||
66 | %} | ||
67 | |||
68 | ws [ \n\t] | ||
69 | n [A-Za-z0-9_] | ||
70 | |||
71 | %% | ||
72 | int str = 0; | ||
73 | int ts, i; | ||
74 | |||
75 | [ \t]*#.*\n current_file->lineno++; | ||
76 | [ \t]*#.* | ||
77 | |||
78 | [ \t]*\n current_file->lineno++; return T_EOL; | ||
79 | |||
80 | [ \t]+ { | ||
81 | BEGIN(COMMAND); | ||
82 | } | ||
83 | |||
84 | . { | ||
85 | unput(yytext[0]); | ||
86 | BEGIN(COMMAND); | ||
87 | } | ||
88 | |||
89 | |||
90 | <COMMAND>{ | ||
91 | "mainmenu" BEGIN(PARAM); return T_MAINMENU; | ||
92 | "menu" BEGIN(PARAM); return T_MENU; | ||
93 | "endmenu" BEGIN(PARAM); return T_ENDMENU; | ||
94 | "source" BEGIN(PARAM); return T_SOURCE; | ||
95 | "choice" BEGIN(PARAM); return T_CHOICE; | ||
96 | "endchoice" BEGIN(PARAM); return T_ENDCHOICE; | ||
97 | "comment" BEGIN(PARAM); return T_COMMENT; | ||
98 | "config" BEGIN(PARAM); return T_CONFIG; | ||
99 | "help" BEGIN(PARAM); return T_HELP; | ||
100 | "if" BEGIN(PARAM); return T_IF; | ||
101 | "endif" BEGIN(PARAM); return T_ENDIF; | ||
102 | "depends" BEGIN(PARAM); return T_DEPENDS; | ||
103 | "requires" BEGIN(PARAM); return T_REQUIRES; | ||
104 | "optional" BEGIN(PARAM); return T_OPTIONAL; | ||
105 | "default" BEGIN(PARAM); return T_DEFAULT; | ||
106 | "prompt" BEGIN(PARAM); return T_PROMPT; | ||
107 | "tristate" BEGIN(PARAM); return T_TRISTATE; | ||
108 | "bool" BEGIN(PARAM); return T_BOOLEAN; | ||
109 | "boolean" BEGIN(PARAM); return T_BOOLEAN; | ||
110 | "int" BEGIN(PARAM); return T_INT; | ||
111 | "hex" BEGIN(PARAM); return T_HEX; | ||
112 | "string" BEGIN(PARAM); return T_STRING; | ||
113 | {n}+ { | ||
114 | alloc_string(yytext, yyleng); | ||
115 | zconflval.string = text; | ||
116 | return T_WORD; | ||
117 | } | ||
118 | . | ||
119 | \n current_file->lineno++; BEGIN(INITIAL); | ||
120 | } | ||
121 | |||
122 | <PARAM>{ | ||
123 | "&&" return T_AND; | ||
124 | "||" return T_OR; | ||
125 | "(" return T_OPEN_PAREN; | ||
126 | ")" return T_CLOSE_PAREN; | ||
127 | "!" return T_NOT; | ||
128 | "=" return T_EQUAL; | ||
129 | "!=" return T_UNEQUAL; | ||
130 | "if" return T_IF; | ||
131 | "on" return T_ON; | ||
132 | \"|\' { | ||
133 | str = yytext[0]; | ||
134 | new_string(); | ||
135 | BEGIN(STRING); | ||
136 | } | ||
137 | \n BEGIN(INITIAL); current_file->lineno++; return T_EOL; | ||
138 | --- /* ignore */ | ||
139 | ({n}|[-/.])+ { | ||
140 | alloc_string(yytext, yyleng); | ||
141 | zconflval.string = text; | ||
142 | return T_WORD; | ||
143 | } | ||
144 | . | ||
145 | <<EOF>> { | ||
146 | BEGIN(INITIAL); | ||
147 | } | ||
148 | } | ||
149 | |||
150 | <STRING>{ | ||
151 | [^'"\\\n]+/\n { | ||
152 | append_string(yytext, yyleng); | ||
153 | zconflval.string = text; | ||
154 | return T_STRING; | ||
155 | } | ||
156 | [^'"\\\n]+ { | ||
157 | append_string(yytext, yyleng); | ||
158 | } | ||
159 | \\.?/\n { | ||
160 | append_string(yytext+1, yyleng); | ||
161 | zconflval.string = text; | ||
162 | return T_STRING; | ||
163 | } | ||
164 | \\.? { | ||
165 | append_string(yytext+1, yyleng); | ||
166 | } | ||
167 | \'|\" { | ||
168 | if (str == yytext[0]) { | ||
169 | BEGIN(PARAM); | ||
170 | zconflval.string = text; | ||
171 | return T_STRING; | ||
172 | } else | ||
173 | append_string(yytext, 1); | ||
174 | } | ||
175 | \n { | ||
176 | printf("%s:%d:warning: multi-line strings not supported\n", zconf_curname(), zconf_lineno()); | ||
177 | BEGIN(INITIAL); | ||
178 | return T_EOL; | ||
179 | } | ||
180 | <<EOF>> { | ||
181 | BEGIN(INITIAL); | ||
182 | } | ||
183 | } | ||
184 | |||
185 | <HELP>{ | ||
186 | [ \t]+ { | ||
187 | ts = 0; | ||
188 | for (i = 0; i < yyleng; i++) { | ||
189 | if (yytext[i] == '\t') | ||
190 | ts = (ts & ~7) + 8; | ||
191 | else | ||
192 | ts++; | ||
193 | } | ||
194 | last_ts = ts; | ||
195 | if (first_ts) { | ||
196 | if (ts < first_ts) { | ||
197 | zconf_endhelp(); | ||
198 | return T_HELPTEXT; | ||
199 | } | ||
200 | ts -= first_ts; | ||
201 | while (ts > 8) { | ||
202 | append_string(" ", 8); | ||
203 | ts -= 8; | ||
204 | } | ||
205 | append_string(" ", ts); | ||
206 | } | ||
207 | |||
208 | } | ||
209 | \n/[^ \t\n] { | ||
210 | current_file->lineno++; | ||
211 | zconf_endhelp(); | ||
212 | return T_HELPTEXT; | ||
213 | } | ||
214 | [ \t]*\n { | ||
215 | current_file->lineno++; | ||
216 | append_string("\n", 1); | ||
217 | } | ||
218 | [^ \t\n].* { | ||
219 | append_string(yytext, yyleng); | ||
220 | if (!first_ts) | ||
221 | first_ts = last_ts; | ||
222 | } | ||
223 | <<EOF>> { | ||
224 | zconf_endhelp(); | ||
225 | return T_HELPTEXT; | ||
226 | } | ||
227 | } | ||
228 | |||
229 | <<EOF>> { | ||
230 | if (current_buf) { | ||
231 | zconf_endfile(); | ||
232 | return T_EOF; | ||
233 | } | ||
234 | fclose(yyin); | ||
235 | yyterminate(); | ||
236 | } | ||
237 | |||
238 | %% | ||
239 | void zconf_starthelp(void) | ||
240 | { | ||
241 | new_string(); | ||
242 | last_ts = first_ts = 0; | ||
243 | BEGIN(HELP); | ||
244 | } | ||
245 | |||
246 | static void zconf_endhelp(void) | ||
247 | { | ||
248 | zconflval.string = text; | ||
249 | BEGIN(INITIAL); | ||
250 | } | ||
251 | |||
252 | void zconf_initscan(const char *name) | ||
253 | { | ||
254 | yyin = fopen(name, "r"); | ||
255 | if (!yyin) { | ||
256 | printf("can't find file %s\n", name); | ||
257 | exit(1); | ||
258 | } | ||
259 | |||
260 | current_buf = malloc(sizeof(*current_buf)); | ||
261 | memset(current_buf, 0, sizeof(*current_buf)); | ||
262 | |||
263 | current_file = file_lookup(name); | ||
264 | current_file->lineno = 1; | ||
265 | current_file->flags = FILE_BUSY; | ||
266 | } | ||
267 | |||
268 | void zconf_nextfile(const char *name) | ||
269 | { | ||
270 | struct file *file = file_lookup(name); | ||
271 | struct buffer *buf = malloc(sizeof(*buf)); | ||
272 | memset(buf, 0, sizeof(*buf)); | ||
273 | |||
274 | current_buf->state = YY_CURRENT_BUFFER; | ||
275 | yyin = fopen(name, "r"); | ||
276 | if (!yyin) { | ||
277 | printf("%s:%d: can't open file \"%s\"\n", zconf_curname(), zconf_lineno(), name); | ||
278 | exit(1); | ||
279 | } | ||
280 | yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE)); | ||
281 | buf->parent = current_buf; | ||
282 | current_buf = buf; | ||
283 | |||
284 | if (file->flags & FILE_BUSY) { | ||
285 | printf("recursive scan (%s)?\n", name); | ||
286 | exit(1); | ||
287 | } | ||
288 | if (file->flags & FILE_SCANNED) { | ||
289 | printf("file %s already scanned?\n", name); | ||
290 | exit(1); | ||
291 | } | ||
292 | file->flags |= FILE_BUSY; | ||
293 | file->lineno = 1; | ||
294 | file->parent = current_file; | ||
295 | current_file = file; | ||
296 | } | ||
297 | |||
298 | static struct buffer *zconf_endfile(void) | ||
299 | { | ||
300 | struct buffer *parent; | ||
301 | |||
302 | current_file->flags |= FILE_SCANNED; | ||
303 | current_file->flags &= ~FILE_BUSY; | ||
304 | current_file = current_file->parent; | ||
305 | |||
306 | parent = current_buf->parent; | ||
307 | if (parent) { | ||
308 | fclose(yyin); | ||
309 | yy_delete_buffer(YY_CURRENT_BUFFER); | ||
310 | yy_switch_to_buffer(parent->state); | ||
311 | } | ||
312 | free(current_buf); | ||
313 | current_buf = parent; | ||
314 | |||
315 | return parent; | ||
316 | } | ||
317 | |||
318 | int zconf_lineno(void) | ||
319 | { | ||
320 | if (current_buf) | ||
321 | return current_file->lineno; | ||
322 | else | ||
323 | return 0; | ||
324 | } | ||
325 | |||
326 | char *zconf_curname(void) | ||
327 | { | ||
328 | if (current_buf) | ||
329 | return current_file->name; | ||
330 | else | ||
331 | return "<none>"; | ||
332 | } | ||
diff --git a/scripts/config/zconf.tab.c_shipped b/scripts/config/zconf.tab.c_shipped new file mode 100644 index 000000000..33b2b6f84 --- /dev/null +++ b/scripts/config/zconf.tab.c_shipped | |||
@@ -0,0 +1,2017 @@ | |||
1 | /* A Bison parser, made from zconf.y, by GNU bison 1.75. */ | ||
2 | |||
3 | /* Skeleton parser for Yacc-like parsing with Bison, | ||
4 | Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc. | ||
5 | |||
6 | This program is free software; you can redistribute it and/or modify | ||
7 | it under the terms of the GNU General Public License as published by | ||
8 | the Free Software Foundation; either version 2, or (at your option) | ||
9 | any later version. | ||
10 | |||
11 | This program is distributed in the hope that it will be useful, | ||
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | GNU General Public License for more details. | ||
15 | |||
16 | You should have received a copy of the GNU General Public License | ||
17 | along with this program; if not, write to the Free Software | ||
18 | Foundation, Inc., 59 Temple Place - Suite 330, | ||
19 | Boston, MA 02111-1307, USA. */ | ||
20 | |||
21 | /* As a special exception, when this file is copied by Bison into a | ||
22 | Bison output file, you may use that output file without restriction. | ||
23 | This special exception was added by the Free Software Foundation | ||
24 | in version 1.24 of Bison. */ | ||
25 | |||
26 | /* Written by Richard Stallman by simplifying the original so called | ||
27 | ``semantic'' parser. */ | ||
28 | |||
29 | /* All symbols defined below should begin with yy or YY, to avoid | ||
30 | infringing on user name space. This should be done even for local | ||
31 | variables, as they might otherwise be expanded by user macros. | ||
32 | There are some unavoidable exceptions within include files to | ||
33 | define necessary library symbols; they are noted "INFRINGES ON | ||
34 | USER NAME SPACE" below. */ | ||
35 | |||
36 | /* Identify Bison output. */ | ||
37 | #define YYBISON 1 | ||
38 | |||
39 | /* Pure parsers. */ | ||
40 | #define YYPURE 0 | ||
41 | |||
42 | /* Using locations. */ | ||
43 | #define YYLSP_NEEDED 0 | ||
44 | |||
45 | /* If NAME_PREFIX is specified substitute the variables and functions | ||
46 | names. */ | ||
47 | #define yyparse zconfparse | ||
48 | #define yylex zconflex | ||
49 | #define yyerror zconferror | ||
50 | #define yylval zconflval | ||
51 | #define yychar zconfchar | ||
52 | #define yydebug zconfdebug | ||
53 | #define yynerrs zconfnerrs | ||
54 | |||
55 | |||
56 | /* Tokens. */ | ||
57 | #ifndef YYTOKENTYPE | ||
58 | # define YYTOKENTYPE | ||
59 | /* Put the tokens into the symbol table, so that GDB and other debuggers | ||
60 | know about them. */ | ||
61 | enum yytokentype { | ||
62 | T_MAINMENU = 258, | ||
63 | T_MENU = 259, | ||
64 | T_ENDMENU = 260, | ||
65 | T_SOURCE = 261, | ||
66 | T_CHOICE = 262, | ||
67 | T_ENDCHOICE = 263, | ||
68 | T_COMMENT = 264, | ||
69 | T_CONFIG = 265, | ||
70 | T_HELP = 266, | ||
71 | T_HELPTEXT = 267, | ||
72 | T_IF = 268, | ||
73 | T_ENDIF = 269, | ||
74 | T_DEPENDS = 270, | ||
75 | T_REQUIRES = 271, | ||
76 | T_OPTIONAL = 272, | ||
77 | T_PROMPT = 273, | ||
78 | T_DEFAULT = 274, | ||
79 | T_TRISTATE = 275, | ||
80 | T_BOOLEAN = 276, | ||
81 | T_INT = 277, | ||
82 | T_HEX = 278, | ||
83 | T_WORD = 279, | ||
84 | T_STRING = 280, | ||
85 | T_UNEQUAL = 281, | ||
86 | T_EOF = 282, | ||
87 | T_EOL = 283, | ||
88 | T_CLOSE_PAREN = 284, | ||
89 | T_OPEN_PAREN = 285, | ||
90 | T_ON = 286, | ||
91 | T_OR = 287, | ||
92 | T_AND = 288, | ||
93 | T_EQUAL = 289, | ||
94 | T_NOT = 290 | ||
95 | }; | ||
96 | #endif | ||
97 | #define T_MAINMENU 258 | ||
98 | #define T_MENU 259 | ||
99 | #define T_ENDMENU 260 | ||
100 | #define T_SOURCE 261 | ||
101 | #define T_CHOICE 262 | ||
102 | #define T_ENDCHOICE 263 | ||
103 | #define T_COMMENT 264 | ||
104 | #define T_CONFIG 265 | ||
105 | #define T_HELP 266 | ||
106 | #define T_HELPTEXT 267 | ||
107 | #define T_IF 268 | ||
108 | #define T_ENDIF 269 | ||
109 | #define T_DEPENDS 270 | ||
110 | #define T_REQUIRES 271 | ||
111 | #define T_OPTIONAL 272 | ||
112 | #define T_PROMPT 273 | ||
113 | #define T_DEFAULT 274 | ||
114 | #define T_TRISTATE 275 | ||
115 | #define T_BOOLEAN 276 | ||
116 | #define T_INT 277 | ||
117 | #define T_HEX 278 | ||
118 | #define T_WORD 279 | ||
119 | #define T_STRING 280 | ||
120 | #define T_UNEQUAL 281 | ||
121 | #define T_EOF 282 | ||
122 | #define T_EOL 283 | ||
123 | #define T_CLOSE_PAREN 284 | ||
124 | #define T_OPEN_PAREN 285 | ||
125 | #define T_ON 286 | ||
126 | #define T_OR 287 | ||
127 | #define T_AND 288 | ||
128 | #define T_EQUAL 289 | ||
129 | #define T_NOT 290 | ||
130 | |||
131 | |||
132 | |||
133 | |||
134 | /* Copy the first part of user declarations. */ | ||
135 | #line 1 "zconf.y" | ||
136 | |||
137 | /* | ||
138 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> | ||
139 | * Released under the terms of the GNU GPL v2.0. | ||
140 | */ | ||
141 | |||
142 | #include <ctype.h> | ||
143 | #include <stdarg.h> | ||
144 | #include <stdio.h> | ||
145 | #include <stdlib.h> | ||
146 | #include <string.h> | ||
147 | #include <stdbool.h> | ||
148 | |||
149 | #define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt) | ||
150 | |||
151 | #define PRINTD 0x0001 | ||
152 | #define DEBUG_PARSE 0x0002 | ||
153 | |||
154 | int cdebug = PRINTD; | ||
155 | |||
156 | extern int zconflex(void); | ||
157 | static void zconfprint(const char *err, ...); | ||
158 | static void zconferror(const char *err); | ||
159 | static bool zconf_endtoken(int token, int starttoken, int endtoken); | ||
160 | |||
161 | struct symbol *symbol_hash[257]; | ||
162 | |||
163 | #define YYERROR_VERBOSE | ||
164 | |||
165 | |||
166 | /* Enabling traces. */ | ||
167 | #ifndef YYDEBUG | ||
168 | # define YYDEBUG 1 | ||
169 | #endif | ||
170 | |||
171 | /* Enabling verbose error messages. */ | ||
172 | #ifdef YYERROR_VERBOSE | ||
173 | # undef YYERROR_VERBOSE | ||
174 | # define YYERROR_VERBOSE 1 | ||
175 | #else | ||
176 | # define YYERROR_VERBOSE 0 | ||
177 | #endif | ||
178 | |||
179 | #ifndef YYSTYPE | ||
180 | #line 33 "zconf.y" | ||
181 | typedef union { | ||
182 | int token; | ||
183 | char *string; | ||
184 | struct symbol *symbol; | ||
185 | struct expr *expr; | ||
186 | struct menu *menu; | ||
187 | } yystype; | ||
188 | /* Line 193 of /usr/share/bison/yacc.c. */ | ||
189 | #line 190 "zconf.tab.c" | ||
190 | # define YYSTYPE yystype | ||
191 | # define YYSTYPE_IS_TRIVIAL 1 | ||
192 | #endif | ||
193 | |||
194 | #ifndef YYLTYPE | ||
195 | typedef struct yyltype | ||
196 | { | ||
197 | int first_line; | ||
198 | int first_column; | ||
199 | int last_line; | ||
200 | int last_column; | ||
201 | } yyltype; | ||
202 | # define YYLTYPE yyltype | ||
203 | # define YYLTYPE_IS_TRIVIAL 1 | ||
204 | #endif | ||
205 | |||
206 | /* Copy the second part of user declarations. */ | ||
207 | #line 83 "zconf.y" | ||
208 | |||
209 | #define LKC_DIRECT_LINK | ||
210 | #include "lkc.h" | ||
211 | |||
212 | |||
213 | /* Line 213 of /usr/share/bison/yacc.c. */ | ||
214 | #line 215 "zconf.tab.c" | ||
215 | |||
216 | #if ! defined (yyoverflow) || YYERROR_VERBOSE | ||
217 | |||
218 | /* The parser invokes alloca or malloc; define the necessary symbols. */ | ||
219 | |||
220 | # if YYSTACK_USE_ALLOCA | ||
221 | # define YYSTACK_ALLOC alloca | ||
222 | # else | ||
223 | # ifndef YYSTACK_USE_ALLOCA | ||
224 | # if defined (alloca) || defined (_ALLOCA_H) | ||
225 | # define YYSTACK_ALLOC alloca | ||
226 | # else | ||
227 | # ifdef __GNUC__ | ||
228 | # define YYSTACK_ALLOC __builtin_alloca | ||
229 | # endif | ||
230 | # endif | ||
231 | # endif | ||
232 | # endif | ||
233 | |||
234 | # ifdef YYSTACK_ALLOC | ||
235 | /* Pacify GCC's `empty if-body' warning. */ | ||
236 | # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) | ||
237 | # else | ||
238 | # if defined (__STDC__) || defined (__cplusplus) | ||
239 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ | ||
240 | # define YYSIZE_T size_t | ||
241 | # endif | ||
242 | # define YYSTACK_ALLOC malloc | ||
243 | # define YYSTACK_FREE free | ||
244 | # endif | ||
245 | #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ | ||
246 | |||
247 | |||
248 | #if (! defined (yyoverflow) \ | ||
249 | && (! defined (__cplusplus) \ | ||
250 | || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) | ||
251 | |||
252 | /* A type that is properly aligned for any stack member. */ | ||
253 | union yyalloc | ||
254 | { | ||
255 | short yyss; | ||
256 | YYSTYPE yyvs; | ||
257 | }; | ||
258 | |||
259 | /* The size of the maximum gap between one aligned stack and the next. */ | ||
260 | # define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1) | ||
261 | |||
262 | /* The size of an array large to enough to hold all stacks, each with | ||
263 | N elements. */ | ||
264 | # define YYSTACK_BYTES(N) \ | ||
265 | ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ | ||
266 | + YYSTACK_GAP_MAX) | ||
267 | |||
268 | /* Copy COUNT objects from FROM to TO. The source and destination do | ||
269 | not overlap. */ | ||
270 | # ifndef YYCOPY | ||
271 | # if 1 < __GNUC__ | ||
272 | # define YYCOPY(To, From, Count) \ | ||
273 | __builtin_memcpy (To, From, (Count) * sizeof (*(From))) | ||
274 | # else | ||
275 | # define YYCOPY(To, From, Count) \ | ||
276 | do \ | ||
277 | { \ | ||
278 | register YYSIZE_T yyi; \ | ||
279 | for (yyi = 0; yyi < (Count); yyi++) \ | ||
280 | (To)[yyi] = (From)[yyi]; \ | ||
281 | } \ | ||
282 | while (0) | ||
283 | # endif | ||
284 | # endif | ||
285 | |||
286 | /* Relocate STACK from its old location to the new one. The | ||
287 | local variables YYSIZE and YYSTACKSIZE give the old and new number of | ||
288 | elements in the stack, and YYPTR gives the new location of the | ||
289 | stack. Advance YYPTR to a properly aligned location for the next | ||
290 | stack. */ | ||
291 | # define YYSTACK_RELOCATE(Stack) \ | ||
292 | do \ | ||
293 | { \ | ||
294 | YYSIZE_T yynewbytes; \ | ||
295 | YYCOPY (&yyptr->Stack, Stack, yysize); \ | ||
296 | Stack = &yyptr->Stack; \ | ||
297 | yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX; \ | ||
298 | yyptr += yynewbytes / sizeof (*yyptr); \ | ||
299 | } \ | ||
300 | while (0) | ||
301 | |||
302 | #endif | ||
303 | |||
304 | #if defined (__STDC__) || defined (__cplusplus) | ||
305 | typedef signed char yysigned_char; | ||
306 | #else | ||
307 | typedef short yysigned_char; | ||
308 | #endif | ||
309 | |||
310 | /* YYFINAL -- State number of the termination state. */ | ||
311 | #define YYFINAL 2 | ||
312 | #define YYLAST 151 | ||
313 | |||
314 | /* YYNTOKENS -- Number of terminals. */ | ||
315 | #define YYNTOKENS 36 | ||
316 | /* YYNNTS -- Number of nonterminals. */ | ||
317 | #define YYNNTS 39 | ||
318 | /* YYNRULES -- Number of rules. */ | ||
319 | #define YYNRULES 96 | ||
320 | /* YYNRULES -- Number of states. */ | ||
321 | #define YYNSTATES 145 | ||
322 | |||
323 | /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ | ||
324 | #define YYUNDEFTOK 2 | ||
325 | #define YYMAXUTOK 290 | ||
326 | |||
327 | #define YYTRANSLATE(X) \ | ||
328 | ((unsigned)(X) <= YYMAXUTOK ? yytranslate[X] : YYUNDEFTOK) | ||
329 | |||
330 | /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ | ||
331 | static const unsigned char yytranslate[] = | ||
332 | { | ||
333 | 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
334 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
335 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
336 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
337 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
338 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
339 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
340 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
341 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
342 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
343 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
344 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
345 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
346 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
347 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
348 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
349 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
350 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
351 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
352 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
353 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
354 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
355 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
356 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
357 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
358 | 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, | ||
359 | 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, | ||
360 | 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, | ||
361 | 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, | ||
362 | 35 | ||
363 | }; | ||
364 | |||
365 | #if YYDEBUG | ||
366 | /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in | ||
367 | YYRHS. */ | ||
368 | static const unsigned short yyprhs[] = | ||
369 | { | ||
370 | 0, 0, 3, 4, 7, 9, 11, 13, 17, 19, | ||
371 | 21, 23, 26, 28, 30, 32, 34, 36, 39, 43, | ||
372 | 44, 48, 52, 55, 58, 61, 64, 67, 70, 73, | ||
373 | 77, 81, 83, 87, 89, 94, 97, 98, 102, 106, | ||
374 | 109, 112, 116, 118, 121, 122, 125, 128, 130, 136, | ||
375 | 140, 141, 144, 147, 150, 153, 157, 159, 164, 167, | ||
376 | 168, 171, 174, 177, 181, 184, 187, 190, 194, 197, | ||
377 | 200, 201, 205, 208, 212, 215, 218, 219, 221, 225, | ||
378 | 227, 229, 231, 233, 235, 237, 239, 240, 243, 245, | ||
379 | 249, 253, 257, 260, 264, 268, 270 | ||
380 | }; | ||
381 | |||
382 | /* YYRHS -- A `-1'-separated list of the rules' RHS. */ | ||
383 | static const yysigned_char yyrhs[] = | ||
384 | { | ||
385 | 37, 0, -1, -1, 37, 38, -1, 39, -1, 47, | ||
386 | -1, 58, -1, 3, 69, 71, -1, 5, -1, 14, | ||
387 | -1, 8, -1, 1, 71, -1, 53, -1, 63, -1, | ||
388 | 41, -1, 61, -1, 71, -1, 10, 24, -1, 40, | ||
389 | 28, 42, -1, -1, 42, 43, 28, -1, 42, 67, | ||
390 | 28, -1, 42, 65, -1, 42, 28, -1, 20, 68, | ||
391 | -1, 21, 68, -1, 22, 68, -1, 23, 68, -1, | ||
392 | 25, 68, -1, 18, 69, 72, -1, 19, 74, 72, | ||
393 | -1, 7, -1, 44, 28, 48, -1, 70, -1, 45, | ||
394 | 50, 46, 28, -1, 45, 50, -1, -1, 48, 49, | ||
395 | 28, -1, 48, 67, 28, -1, 48, 65, -1, 48, | ||
396 | 28, -1, 18, 69, 72, -1, 17, -1, 19, 74, | ||
397 | -1, -1, 50, 39, -1, 13, 73, -1, 70, -1, | ||
398 | 51, 28, 54, 52, 28, -1, 51, 28, 54, -1, | ||
399 | -1, 54, 39, -1, 54, 58, -1, 54, 47, -1, | ||
400 | 4, 69, -1, 55, 28, 66, -1, 70, -1, 56, | ||
401 | 59, 57, 28, -1, 56, 59, -1, -1, 59, 39, | ||
402 | -1, 59, 58, -1, 59, 47, -1, 59, 1, 28, | ||
403 | -1, 6, 69, -1, 60, 28, -1, 9, 69, -1, | ||
404 | 62, 28, 66, -1, 11, 28, -1, 64, 12, -1, | ||
405 | -1, 66, 67, 28, -1, 66, 28, -1, 15, 31, | ||
406 | 73, -1, 15, 73, -1, 16, 73, -1, -1, 69, | ||
407 | -1, 69, 13, 73, -1, 24, -1, 25, -1, 5, | ||
408 | -1, 8, -1, 14, -1, 28, -1, 27, -1, -1, | ||
409 | 13, 73, -1, 74, -1, 74, 34, 74, -1, 74, | ||
410 | 26, 74, -1, 30, 73, 29, -1, 35, 73, -1, | ||
411 | 73, 32, 73, -1, 73, 33, 73, -1, 24, -1, | ||
412 | 25, -1 | ||
413 | }; | ||
414 | |||
415 | /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ | ||
416 | static const unsigned short yyrline[] = | ||
417 | { | ||
418 | 0, 88, 88, 89, 92, 93, 94, 95, 96, 97, | ||
419 | 98, 99, 102, 104, 105, 106, 107, 113, 121, 127, | ||
420 | 129, 130, 131, 132, 135, 141, 147, 153, 159, 165, | ||
421 | 171, 179, 188, 194, 202, 204, 210, 212, 213, 214, | ||
422 | 215, 218, 224, 230, 237, 239, 244, 254, 262, 264, | ||
423 | 270, 272, 273, 274, 279, 286, 292, 300, 302, 308, | ||
424 | 310, 311, 312, 313, 316, 322, 329, 336, 343, 349, | ||
425 | 356, 357, 358, 361, 366, 371, 379, 381, 385, 390, | ||
426 | 391, 394, 395, 396, 399, 400, 402, 403, 406, 407, | ||
427 | 408, 409, 410, 411, 412, 415, 416 | ||
428 | }; | ||
429 | #endif | ||
430 | |||
431 | #if YYDEBUG || YYERROR_VERBOSE | ||
432 | /* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. | ||
433 | First, the terminals, then, starting at YYNTOKENS, nonterminals. */ | ||
434 | static const char *const yytname[] = | ||
435 | { | ||
436 | "$end", "error", "$undefined", "T_MAINMENU", "T_MENU", "T_ENDMENU", | ||
437 | "T_SOURCE", "T_CHOICE", "T_ENDCHOICE", "T_COMMENT", "T_CONFIG", | ||
438 | "T_HELP", "T_HELPTEXT", "T_IF", "T_ENDIF", "T_DEPENDS", "T_REQUIRES", | ||
439 | "T_OPTIONAL", "T_PROMPT", "T_DEFAULT", "T_TRISTATE", "T_BOOLEAN", | ||
440 | "T_INT", "T_HEX", "T_WORD", "T_STRING", "T_UNEQUAL", "T_EOF", "T_EOL", | ||
441 | "T_CLOSE_PAREN", "T_OPEN_PAREN", "T_ON", "T_OR", "T_AND", "T_EQUAL", | ||
442 | "T_NOT", "$accept", "input", "block", "common_block", | ||
443 | "config_entry_start", "config_stmt", "config_option_list", | ||
444 | "config_option", "choice", "choice_entry", "choice_end", "choice_stmt", | ||
445 | "choice_option_list", "choice_option", "choice_block", "if", "if_end", | ||
446 | "if_stmt", "if_block", "menu", "menu_entry", "menu_end", "menu_stmt", | ||
447 | "menu_block", "source", "source_stmt", "comment", "comment_stmt", | ||
448 | "help_start", "help", "depends_list", "depends", "prompt_stmt_opt", | ||
449 | "prompt", "end", "nl_or_eof", "if_expr", "expr", "symbol", 0 | ||
450 | }; | ||
451 | #endif | ||
452 | |||
453 | # ifdef YYPRINT | ||
454 | /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to | ||
455 | token YYLEX-NUM. */ | ||
456 | static const unsigned short yytoknum[] = | ||
457 | { | ||
458 | 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, | ||
459 | 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, | ||
460 | 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, | ||
461 | 285, 286, 287, 288, 289, 290 | ||
462 | }; | ||
463 | # endif | ||
464 | |||
465 | /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ | ||
466 | static const unsigned char yyr1[] = | ||
467 | { | ||
468 | 0, 36, 37, 37, 38, 38, 38, 38, 38, 38, | ||
469 | 38, 38, 39, 39, 39, 39, 39, 40, 41, 42, | ||
470 | 42, 42, 42, 42, 43, 43, 43, 43, 43, 43, | ||
471 | 43, 44, 45, 46, 47, 47, 48, 48, 48, 48, | ||
472 | 48, 49, 49, 49, 50, 50, 51, 52, 53, 53, | ||
473 | 54, 54, 54, 54, 55, 56, 57, 58, 58, 59, | ||
474 | 59, 59, 59, 59, 60, 61, 62, 63, 64, 65, | ||
475 | 66, 66, 66, 67, 67, 67, 68, 68, 68, 69, | ||
476 | 69, 70, 70, 70, 71, 71, 72, 72, 73, 73, | ||
477 | 73, 73, 73, 73, 73, 74, 74 | ||
478 | }; | ||
479 | |||
480 | /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ | ||
481 | static const unsigned char yyr2[] = | ||
482 | { | ||
483 | 0, 2, 0, 2, 1, 1, 1, 3, 1, 1, | ||
484 | 1, 2, 1, 1, 1, 1, 1, 2, 3, 0, | ||
485 | 3, 3, 2, 2, 2, 2, 2, 2, 2, 3, | ||
486 | 3, 1, 3, 1, 4, 2, 0, 3, 3, 2, | ||
487 | 2, 3, 1, 2, 0, 2, 2, 1, 5, 3, | ||
488 | 0, 2, 2, 2, 2, 3, 1, 4, 2, 0, | ||
489 | 2, 2, 2, 3, 2, 2, 2, 3, 2, 2, | ||
490 | 0, 3, 2, 3, 2, 2, 0, 1, 3, 1, | ||
491 | 1, 1, 1, 1, 1, 1, 0, 2, 1, 3, | ||
492 | 3, 3, 2, 3, 3, 1, 1 | ||
493 | }; | ||
494 | |||
495 | /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state | ||
496 | STATE-NUM when YYTABLE doesn't specify something else to do. Zero | ||
497 | means the default is an error. */ | ||
498 | static const unsigned char yydefact[] = | ||
499 | { | ||
500 | 2, 0, 1, 0, 0, 0, 8, 0, 31, 10, | ||
501 | 0, 0, 0, 9, 85, 84, 3, 4, 0, 14, | ||
502 | 0, 44, 5, 0, 12, 0, 59, 6, 0, 15, | ||
503 | 0, 13, 16, 11, 79, 80, 0, 54, 64, 66, | ||
504 | 17, 95, 96, 0, 0, 46, 88, 19, 36, 35, | ||
505 | 50, 70, 0, 65, 70, 7, 0, 92, 0, 0, | ||
506 | 0, 0, 18, 32, 81, 82, 83, 45, 0, 33, | ||
507 | 49, 55, 0, 60, 62, 0, 61, 56, 67, 91, | ||
508 | 93, 94, 90, 89, 0, 0, 0, 0, 0, 76, | ||
509 | 76, 76, 76, 76, 23, 0, 0, 22, 0, 42, | ||
510 | 0, 0, 40, 0, 39, 0, 34, 51, 53, 0, | ||
511 | 52, 47, 72, 0, 63, 57, 68, 0, 74, 75, | ||
512 | 86, 86, 24, 77, 25, 26, 27, 28, 20, 69, | ||
513 | 21, 86, 43, 37, 38, 48, 71, 73, 0, 29, | ||
514 | 30, 0, 41, 87, 78 | ||
515 | }; | ||
516 | |||
517 | /* YYDEFGOTO[NTERM-NUM]. */ | ||
518 | static const short yydefgoto[] = | ||
519 | { | ||
520 | -1, 1, 16, 17, 18, 19, 62, 95, 20, 21, | ||
521 | 68, 22, 63, 103, 49, 23, 109, 24, 70, 25, | ||
522 | 26, 75, 27, 52, 28, 29, 30, 31, 96, 97, | ||
523 | 71, 113, 122, 123, 69, 32, 139, 45, 46 | ||
524 | }; | ||
525 | |||
526 | /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing | ||
527 | STATE-NUM. */ | ||
528 | #define YYPACT_NINF -120 | ||
529 | static const short yypact[] = | ||
530 | { | ||
531 | -120, 17, -120, 41, 48, 48, -120, 48, -120, -120, | ||
532 | 48, -11, 40, -120, -120, -120, -120, -120, 13, -120, | ||
533 | 23, -120, -120, 66, -120, 72, -120, -120, 77, -120, | ||
534 | 81, -120, -120, -120, -120, -120, 41, -120, -120, -120, | ||
535 | -120, -120, -120, 40, 40, 57, 59, -120, -120, 98, | ||
536 | -120, -120, 49, -120, -120, -120, 7, -120, 40, 40, | ||
537 | 67, 67, 99, 117, -120, -120, -120, -120, 85, -120, | ||
538 | 74, 18, 88, -120, -120, 95, -120, -120, 18, -120, | ||
539 | 96, -120, -120, -120, 102, 36, 40, 48, 67, 48, | ||
540 | 48, 48, 48, 48, -120, 103, 129, -120, 114, -120, | ||
541 | 48, 67, -120, 115, -120, 116, -120, -120, -120, 118, | ||
542 | -120, -120, -120, 119, -120, -120, -120, 40, 57, 57, | ||
543 | 135, 135, -120, 136, -120, -120, -120, -120, -120, -120, | ||
544 | -120, 135, -120, -120, -120, -120, -120, 57, 40, -120, | ||
545 | -120, 40, -120, 57, 57 | ||
546 | }; | ||
547 | |||
548 | /* YYPGOTO[NTERM-NUM]. */ | ||
549 | static const yysigned_char yypgoto[] = | ||
550 | { | ||
551 | -120, -120, -120, -38, -120, -120, -120, -120, -120, -120, | ||
552 | -120, -42, -120, -120, -120, -120, -120, -120, -120, -120, | ||
553 | -120, -120, -33, -120, -120, -120, -120, -120, -120, 87, | ||
554 | 97, 34, 47, -1, -23, 2, -119, -43, -53 | ||
555 | }; | ||
556 | |||
557 | /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If | ||
558 | positive, shift that token. If negative, reduce the rule which | ||
559 | number is the opposite. If zero, do what YYDEFACT says. | ||
560 | If YYTABLE_NINF, parse error. */ | ||
561 | #define YYTABLE_NINF -59 | ||
562 | static const short yytable[] = | ||
563 | { | ||
564 | 56, 57, 140, 36, 37, 33, 38, 82, 83, 39, | ||
565 | 74, 67, 142, 40, 73, 80, 81, 2, 3, 76, | ||
566 | 4, 5, 6, 7, 8, 9, 10, 11, 108, 77, | ||
567 | 12, 13, 107, 85, 86, 121, 79, 110, 55, 58, | ||
568 | 59, 47, 118, 119, 14, 15, 112, 111, 132, -58, | ||
569 | 72, 48, -58, 5, 64, 7, 8, 65, 10, 11, | ||
570 | 41, 42, 12, 66, 41, 42, 43, 117, 14, 15, | ||
571 | 43, 44, 34, 35, 137, 44, 14, 15, 5, 64, | ||
572 | 7, 8, 65, 10, 11, 60, 120, 12, 66, 58, | ||
573 | 59, 41, 42, 61, 50, 143, 98, 105, 144, 131, | ||
574 | 51, 14, 15, 64, 7, 53, 65, 10, 11, 54, | ||
575 | 84, 12, 66, 106, 85, 86, 114, 87, 88, 89, | ||
576 | 90, 91, 92, 115, 93, 14, 15, 94, 84, 59, | ||
577 | 116, 128, 85, 86, 99, 100, 101, 124, 125, 126, | ||
578 | 127, 129, 130, 133, 134, 102, 135, 136, 138, 141, | ||
579 | 104, 78 | ||
580 | }; | ||
581 | |||
582 | static const unsigned char yycheck[] = | ||
583 | { | ||
584 | 43, 44, 121, 4, 5, 3, 7, 60, 61, 10, | ||
585 | 52, 49, 131, 24, 52, 58, 59, 0, 1, 52, | ||
586 | 3, 4, 5, 6, 7, 8, 9, 10, 70, 52, | ||
587 | 13, 14, 70, 15, 16, 88, 29, 70, 36, 32, | ||
588 | 33, 28, 85, 86, 27, 28, 28, 70, 101, 0, | ||
589 | 1, 28, 3, 4, 5, 6, 7, 8, 9, 10, | ||
590 | 24, 25, 13, 14, 24, 25, 30, 31, 27, 28, | ||
591 | 30, 35, 24, 25, 117, 35, 27, 28, 4, 5, | ||
592 | 6, 7, 8, 9, 10, 26, 87, 13, 14, 32, | ||
593 | 33, 24, 25, 34, 28, 138, 62, 63, 141, 100, | ||
594 | 28, 27, 28, 5, 6, 28, 8, 9, 10, 28, | ||
595 | 11, 13, 14, 28, 15, 16, 28, 18, 19, 20, | ||
596 | 21, 22, 23, 28, 25, 27, 28, 28, 11, 33, | ||
597 | 28, 28, 15, 16, 17, 18, 19, 90, 91, 92, | ||
598 | 93, 12, 28, 28, 28, 28, 28, 28, 13, 13, | ||
599 | 63, 54 | ||
600 | }; | ||
601 | |||
602 | /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing | ||
603 | symbol of state STATE-NUM. */ | ||
604 | static const unsigned char yystos[] = | ||
605 | { | ||
606 | 0, 37, 0, 1, 3, 4, 5, 6, 7, 8, | ||
607 | 9, 10, 13, 14, 27, 28, 38, 39, 40, 41, | ||
608 | 44, 45, 47, 51, 53, 55, 56, 58, 60, 61, | ||
609 | 62, 63, 71, 71, 24, 25, 69, 69, 69, 69, | ||
610 | 24, 24, 25, 30, 35, 73, 74, 28, 28, 50, | ||
611 | 28, 28, 59, 28, 28, 71, 73, 73, 32, 33, | ||
612 | 26, 34, 42, 48, 5, 8, 14, 39, 46, 70, | ||
613 | 54, 66, 1, 39, 47, 57, 58, 70, 66, 29, | ||
614 | 73, 73, 74, 74, 11, 15, 16, 18, 19, 20, | ||
615 | 21, 22, 23, 25, 28, 43, 64, 65, 67, 17, | ||
616 | 18, 19, 28, 49, 65, 67, 28, 39, 47, 52, | ||
617 | 58, 70, 28, 67, 28, 28, 28, 31, 73, 73, | ||
618 | 69, 74, 68, 69, 68, 68, 68, 68, 28, 12, | ||
619 | 28, 69, 74, 28, 28, 28, 28, 73, 13, 72, | ||
620 | 72, 13, 72, 73, 73 | ||
621 | }; | ||
622 | |||
623 | #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) | ||
624 | # define YYSIZE_T __SIZE_TYPE__ | ||
625 | #endif | ||
626 | #if ! defined (YYSIZE_T) && defined (size_t) | ||
627 | # define YYSIZE_T size_t | ||
628 | #endif | ||
629 | #if ! defined (YYSIZE_T) | ||
630 | # if defined (__STDC__) || defined (__cplusplus) | ||
631 | # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ | ||
632 | # define YYSIZE_T size_t | ||
633 | # endif | ||
634 | #endif | ||
635 | #if ! defined (YYSIZE_T) | ||
636 | # define YYSIZE_T unsigned int | ||
637 | #endif | ||
638 | |||
639 | #define yyerrok (yyerrstatus = 0) | ||
640 | #define yyclearin (yychar = YYEMPTY) | ||
641 | #define YYEMPTY -2 | ||
642 | #define YYEOF 0 | ||
643 | |||
644 | #define YYACCEPT goto yyacceptlab | ||
645 | #define YYABORT goto yyabortlab | ||
646 | #define YYERROR goto yyerrlab1 | ||
647 | |||
648 | /* Like YYERROR except do call yyerror. This remains here temporarily | ||
649 | to ease the transition to the new meaning of YYERROR, for GCC. | ||
650 | Once GCC version 2 has supplanted version 1, this can go. */ | ||
651 | |||
652 | #define YYFAIL goto yyerrlab | ||
653 | |||
654 | #define YYRECOVERING() (!!yyerrstatus) | ||
655 | |||
656 | #define YYBACKUP(Token, Value) \ | ||
657 | do \ | ||
658 | if (yychar == YYEMPTY && yylen == 1) \ | ||
659 | { \ | ||
660 | yychar = (Token); \ | ||
661 | yylval = (Value); \ | ||
662 | yychar1 = YYTRANSLATE (yychar); \ | ||
663 | YYPOPSTACK; \ | ||
664 | goto yybackup; \ | ||
665 | } \ | ||
666 | else \ | ||
667 | { \ | ||
668 | yyerror ("syntax error: cannot back up"); \ | ||
669 | YYERROR; \ | ||
670 | } \ | ||
671 | while (0) | ||
672 | |||
673 | #define YYTERROR 1 | ||
674 | #define YYERRCODE 256 | ||
675 | |||
676 | /* YYLLOC_DEFAULT -- Compute the default location (before the actions | ||
677 | are run). */ | ||
678 | |||
679 | #ifndef YYLLOC_DEFAULT | ||
680 | # define YYLLOC_DEFAULT(Current, Rhs, N) \ | ||
681 | Current.first_line = Rhs[1].first_line; \ | ||
682 | Current.first_column = Rhs[1].first_column; \ | ||
683 | Current.last_line = Rhs[N].last_line; \ | ||
684 | Current.last_column = Rhs[N].last_column; | ||
685 | #endif | ||
686 | |||
687 | /* YYLEX -- calling `yylex' with the right arguments. */ | ||
688 | |||
689 | #define YYLEX yylex () | ||
690 | |||
691 | /* Enable debugging if requested. */ | ||
692 | #if YYDEBUG | ||
693 | |||
694 | # ifndef YYFPRINTF | ||
695 | # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ | ||
696 | # define YYFPRINTF fprintf | ||
697 | # endif | ||
698 | |||
699 | # define YYDPRINTF(Args) \ | ||
700 | do { \ | ||
701 | if (yydebug) \ | ||
702 | YYFPRINTF Args; \ | ||
703 | } while (0) | ||
704 | # define YYDSYMPRINT(Args) \ | ||
705 | do { \ | ||
706 | if (yydebug) \ | ||
707 | yysymprint Args; \ | ||
708 | } while (0) | ||
709 | /* Nonzero means print parse trace. It is left uninitialized so that | ||
710 | multiple parsers can coexist. */ | ||
711 | int yydebug; | ||
712 | #else /* !YYDEBUG */ | ||
713 | # define YYDPRINTF(Args) | ||
714 | # define YYDSYMPRINT(Args) | ||
715 | #endif /* !YYDEBUG */ | ||
716 | |||
717 | /* YYINITDEPTH -- initial size of the parser's stacks. */ | ||
718 | #ifndef YYINITDEPTH | ||
719 | # define YYINITDEPTH 200 | ||
720 | #endif | ||
721 | |||
722 | /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only | ||
723 | if the built-in stack extension method is used). | ||
724 | |||
725 | Do not make this value too large; the results are undefined if | ||
726 | SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) | ||
727 | evaluated with infinite-precision integer arithmetic. */ | ||
728 | |||
729 | #if YYMAXDEPTH == 0 | ||
730 | # undef YYMAXDEPTH | ||
731 | #endif | ||
732 | |||
733 | #ifndef YYMAXDEPTH | ||
734 | # define YYMAXDEPTH 10000 | ||
735 | #endif | ||
736 | |||
737 | |||
738 | |||
739 | #if YYERROR_VERBOSE | ||
740 | |||
741 | # ifndef yystrlen | ||
742 | # if defined (__GLIBC__) && defined (_STRING_H) | ||
743 | # define yystrlen strlen | ||
744 | # else | ||
745 | /* Return the length of YYSTR. */ | ||
746 | static YYSIZE_T | ||
747 | # if defined (__STDC__) || defined (__cplusplus) | ||
748 | yystrlen (const char *yystr) | ||
749 | # else | ||
750 | yystrlen (yystr) | ||
751 | const char *yystr; | ||
752 | # endif | ||
753 | { | ||
754 | register const char *yys = yystr; | ||
755 | |||
756 | while (*yys++ != '\0') | ||
757 | continue; | ||
758 | |||
759 | return yys - yystr - 1; | ||
760 | } | ||
761 | # endif | ||
762 | # endif | ||
763 | |||
764 | # ifndef yystpcpy | ||
765 | # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) | ||
766 | # define yystpcpy stpcpy | ||
767 | # else | ||
768 | /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in | ||
769 | YYDEST. */ | ||
770 | static char * | ||
771 | # if defined (__STDC__) || defined (__cplusplus) | ||
772 | yystpcpy (char *yydest, const char *yysrc) | ||
773 | # else | ||
774 | yystpcpy (yydest, yysrc) | ||
775 | char *yydest; | ||
776 | const char *yysrc; | ||
777 | # endif | ||
778 | { | ||
779 | register char *yyd = yydest; | ||
780 | register const char *yys = yysrc; | ||
781 | |||
782 | while ((*yyd++ = *yys++) != '\0') | ||
783 | continue; | ||
784 | |||
785 | return yyd - 1; | ||
786 | } | ||
787 | # endif | ||
788 | # endif | ||
789 | |||
790 | #endif /* !YYERROR_VERBOSE */ | ||
791 | |||
792 | |||
793 | |||
794 | #if YYDEBUG | ||
795 | /*-----------------------------. | ||
796 | | Print this symbol on YYOUT. | | ||
797 | `-----------------------------*/ | ||
798 | |||
799 | static void | ||
800 | #if defined (__STDC__) || defined (__cplusplus) | ||
801 | yysymprint (FILE* yyout, int yytype, YYSTYPE yyvalue) | ||
802 | #else | ||
803 | yysymprint (yyout, yytype, yyvalue) | ||
804 | FILE* yyout; | ||
805 | int yytype; | ||
806 | YYSTYPE yyvalue; | ||
807 | #endif | ||
808 | { | ||
809 | /* Pacify ``unused variable'' warnings. */ | ||
810 | (void) yyvalue; | ||
811 | |||
812 | if (yytype < YYNTOKENS) | ||
813 | { | ||
814 | YYFPRINTF (yyout, "token %s (", yytname[yytype]); | ||
815 | # ifdef YYPRINT | ||
816 | YYPRINT (yyout, yytoknum[yytype], yyvalue); | ||
817 | # endif | ||
818 | } | ||
819 | else | ||
820 | YYFPRINTF (yyout, "nterm %s (", yytname[yytype]); | ||
821 | |||
822 | switch (yytype) | ||
823 | { | ||
824 | default: | ||
825 | break; | ||
826 | } | ||
827 | YYFPRINTF (yyout, ")"); | ||
828 | } | ||
829 | #endif /* YYDEBUG. */ | ||
830 | |||
831 | |||
832 | /*-----------------------------------------------. | ||
833 | | Release the memory associated to this symbol. | | ||
834 | `-----------------------------------------------*/ | ||
835 | |||
836 | static void | ||
837 | #if defined (__STDC__) || defined (__cplusplus) | ||
838 | yydestruct (int yytype, YYSTYPE yyvalue) | ||
839 | #else | ||
840 | yydestruct (yytype, yyvalue) | ||
841 | int yytype; | ||
842 | YYSTYPE yyvalue; | ||
843 | #endif | ||
844 | { | ||
845 | /* Pacify ``unused variable'' warnings. */ | ||
846 | (void) yyvalue; | ||
847 | |||
848 | switch (yytype) | ||
849 | { | ||
850 | default: | ||
851 | break; | ||
852 | } | ||
853 | } | ||
854 | |||
855 | |||
856 | |||
857 | /* The user can define YYPARSE_PARAM as the name of an argument to be passed | ||
858 | into yyparse. The argument should have type void *. | ||
859 | It should actually point to an object. | ||
860 | Grammar actions can access the variable by casting it | ||
861 | to the proper pointer type. */ | ||
862 | |||
863 | #ifdef YYPARSE_PARAM | ||
864 | # if defined (__STDC__) || defined (__cplusplus) | ||
865 | # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM | ||
866 | # define YYPARSE_PARAM_DECL | ||
867 | # else | ||
868 | # define YYPARSE_PARAM_ARG YYPARSE_PARAM | ||
869 | # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; | ||
870 | # endif | ||
871 | #else /* !YYPARSE_PARAM */ | ||
872 | # define YYPARSE_PARAM_ARG | ||
873 | # define YYPARSE_PARAM_DECL | ||
874 | #endif /* !YYPARSE_PARAM */ | ||
875 | |||
876 | /* Prevent warning if -Wstrict-prototypes. */ | ||
877 | #ifdef __GNUC__ | ||
878 | # ifdef YYPARSE_PARAM | ||
879 | int yyparse (void *); | ||
880 | # else | ||
881 | int yyparse (void); | ||
882 | # endif | ||
883 | #endif | ||
884 | |||
885 | |||
886 | /* The lookahead symbol. */ | ||
887 | int yychar; | ||
888 | |||
889 | /* The semantic value of the lookahead symbol. */ | ||
890 | YYSTYPE yylval; | ||
891 | |||
892 | /* Number of parse errors so far. */ | ||
893 | int yynerrs; | ||
894 | |||
895 | |||
896 | int | ||
897 | yyparse (YYPARSE_PARAM_ARG) | ||
898 | YYPARSE_PARAM_DECL | ||
899 | { | ||
900 | |||
901 | register int yystate; | ||
902 | register int yyn; | ||
903 | int yyresult; | ||
904 | /* Number of tokens to shift before error messages enabled. */ | ||
905 | int yyerrstatus; | ||
906 | /* Lookahead token as an internal (translated) token number. */ | ||
907 | int yychar1 = 0; | ||
908 | |||
909 | /* Three stacks and their tools: | ||
910 | `yyss': related to states, | ||
911 | `yyvs': related to semantic values, | ||
912 | `yyls': related to locations. | ||
913 | |||
914 | Refer to the stacks thru separate pointers, to allow yyoverflow | ||
915 | to reallocate them elsewhere. */ | ||
916 | |||
917 | /* The state stack. */ | ||
918 | short yyssa[YYINITDEPTH]; | ||
919 | short *yyss = yyssa; | ||
920 | register short *yyssp; | ||
921 | |||
922 | /* The semantic value stack. */ | ||
923 | YYSTYPE yyvsa[YYINITDEPTH]; | ||
924 | YYSTYPE *yyvs = yyvsa; | ||
925 | register YYSTYPE *yyvsp; | ||
926 | |||
927 | |||
928 | |||
929 | #define YYPOPSTACK (yyvsp--, yyssp--) | ||
930 | |||
931 | YYSIZE_T yystacksize = YYINITDEPTH; | ||
932 | |||
933 | /* The variables used to return semantic value and location from the | ||
934 | action routines. */ | ||
935 | YYSTYPE yyval; | ||
936 | |||
937 | |||
938 | /* When reducing, the number of symbols on the RHS of the reduced | ||
939 | rule. */ | ||
940 | int yylen; | ||
941 | |||
942 | YYDPRINTF ((stderr, "Starting parse\n")); | ||
943 | |||
944 | yystate = 0; | ||
945 | yyerrstatus = 0; | ||
946 | yynerrs = 0; | ||
947 | yychar = YYEMPTY; /* Cause a token to be read. */ | ||
948 | |||
949 | /* Initialize stack pointers. | ||
950 | Waste one element of value and location stack | ||
951 | so that they stay on the same level as the state stack. | ||
952 | The wasted elements are never initialized. */ | ||
953 | |||
954 | yyssp = yyss; | ||
955 | yyvsp = yyvs; | ||
956 | |||
957 | goto yysetstate; | ||
958 | |||
959 | /*------------------------------------------------------------. | ||
960 | | yynewstate -- Push a new state, which is found in yystate. | | ||
961 | `------------------------------------------------------------*/ | ||
962 | yynewstate: | ||
963 | /* In all cases, when you get here, the value and location stacks | ||
964 | have just been pushed. so pushing a state here evens the stacks. | ||
965 | */ | ||
966 | yyssp++; | ||
967 | |||
968 | yysetstate: | ||
969 | *yyssp = yystate; | ||
970 | |||
971 | if (yyssp >= yyss + yystacksize - 1) | ||
972 | { | ||
973 | /* Get the current used size of the three stacks, in elements. */ | ||
974 | YYSIZE_T yysize = yyssp - yyss + 1; | ||
975 | |||
976 | #ifdef yyoverflow | ||
977 | { | ||
978 | /* Give user a chance to reallocate the stack. Use copies of | ||
979 | these so that the &'s don't force the real ones into | ||
980 | memory. */ | ||
981 | YYSTYPE *yyvs1 = yyvs; | ||
982 | short *yyss1 = yyss; | ||
983 | |||
984 | |||
985 | /* Each stack pointer address is followed by the size of the | ||
986 | data in use in that stack, in bytes. This used to be a | ||
987 | conditional around just the two extra args, but that might | ||
988 | be undefined if yyoverflow is a macro. */ | ||
989 | yyoverflow ("parser stack overflow", | ||
990 | &yyss1, yysize * sizeof (*yyssp), | ||
991 | &yyvs1, yysize * sizeof (*yyvsp), | ||
992 | |||
993 | &yystacksize); | ||
994 | |||
995 | yyss = yyss1; | ||
996 | yyvs = yyvs1; | ||
997 | } | ||
998 | #else /* no yyoverflow */ | ||
999 | # ifndef YYSTACK_RELOCATE | ||
1000 | goto yyoverflowlab; | ||
1001 | # else | ||
1002 | /* Extend the stack our own way. */ | ||
1003 | if (yystacksize >= YYMAXDEPTH) | ||
1004 | goto yyoverflowlab; | ||
1005 | yystacksize *= 2; | ||
1006 | if (yystacksize > YYMAXDEPTH) | ||
1007 | yystacksize = YYMAXDEPTH; | ||
1008 | |||
1009 | { | ||
1010 | short *yyss1 = yyss; | ||
1011 | union yyalloc *yyptr = | ||
1012 | (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); | ||
1013 | if (! yyptr) | ||
1014 | goto yyoverflowlab; | ||
1015 | YYSTACK_RELOCATE (yyss); | ||
1016 | YYSTACK_RELOCATE (yyvs); | ||
1017 | |||
1018 | # undef YYSTACK_RELOCATE | ||
1019 | if (yyss1 != yyssa) | ||
1020 | YYSTACK_FREE (yyss1); | ||
1021 | } | ||
1022 | # endif | ||
1023 | #endif /* no yyoverflow */ | ||
1024 | |||
1025 | yyssp = yyss + yysize - 1; | ||
1026 | yyvsp = yyvs + yysize - 1; | ||
1027 | |||
1028 | |||
1029 | YYDPRINTF ((stderr, "Stack size increased to %lu\n", | ||
1030 | (unsigned long int) yystacksize)); | ||
1031 | |||
1032 | if (yyssp >= yyss + yystacksize - 1) | ||
1033 | YYABORT; | ||
1034 | } | ||
1035 | |||
1036 | YYDPRINTF ((stderr, "Entering state %d\n", yystate)); | ||
1037 | |||
1038 | goto yybackup; | ||
1039 | |||
1040 | /*-----------. | ||
1041 | | yybackup. | | ||
1042 | `-----------*/ | ||
1043 | yybackup: | ||
1044 | |||
1045 | /* Do appropriate processing given the current state. */ | ||
1046 | /* Read a lookahead token if we need one and don't already have one. */ | ||
1047 | /* yyresume: */ | ||
1048 | |||
1049 | /* First try to decide what to do without reference to lookahead token. */ | ||
1050 | |||
1051 | yyn = yypact[yystate]; | ||
1052 | if (yyn == YYPACT_NINF) | ||
1053 | goto yydefault; | ||
1054 | |||
1055 | /* Not known => get a lookahead token if don't already have one. */ | ||
1056 | |||
1057 | /* yychar is either YYEMPTY or YYEOF | ||
1058 | or a valid token in external form. */ | ||
1059 | |||
1060 | if (yychar == YYEMPTY) | ||
1061 | { | ||
1062 | YYDPRINTF ((stderr, "Reading a token: ")); | ||
1063 | yychar = YYLEX; | ||
1064 | } | ||
1065 | |||
1066 | /* Convert token to internal form (in yychar1) for indexing tables with. */ | ||
1067 | |||
1068 | if (yychar <= 0) /* This means end of input. */ | ||
1069 | { | ||
1070 | yychar1 = 0; | ||
1071 | yychar = YYEOF; /* Don't call YYLEX any more. */ | ||
1072 | |||
1073 | YYDPRINTF ((stderr, "Now at end of input.\n")); | ||
1074 | } | ||
1075 | else | ||
1076 | { | ||
1077 | yychar1 = YYTRANSLATE (yychar); | ||
1078 | |||
1079 | /* We have to keep this `#if YYDEBUG', since we use variables | ||
1080 | which are defined only if `YYDEBUG' is set. */ | ||
1081 | YYDPRINTF ((stderr, "Next token is ")); | ||
1082 | YYDSYMPRINT ((stderr, yychar1, yylval)); | ||
1083 | YYDPRINTF ((stderr, "\n")); | ||
1084 | } | ||
1085 | |||
1086 | /* If the proper action on seeing token YYCHAR1 is to reduce or to | ||
1087 | detect an error, take that action. */ | ||
1088 | yyn += yychar1; | ||
1089 | if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yychar1) | ||
1090 | goto yydefault; | ||
1091 | yyn = yytable[yyn]; | ||
1092 | if (yyn <= 0) | ||
1093 | { | ||
1094 | if (yyn == 0 || yyn == YYTABLE_NINF) | ||
1095 | goto yyerrlab; | ||
1096 | yyn = -yyn; | ||
1097 | goto yyreduce; | ||
1098 | } | ||
1099 | |||
1100 | if (yyn == YYFINAL) | ||
1101 | YYACCEPT; | ||
1102 | |||
1103 | /* Shift the lookahead token. */ | ||
1104 | YYDPRINTF ((stderr, "Shifting token %d (%s), ", | ||
1105 | yychar, yytname[yychar1])); | ||
1106 | |||
1107 | /* Discard the token being shifted unless it is eof. */ | ||
1108 | if (yychar != YYEOF) | ||
1109 | yychar = YYEMPTY; | ||
1110 | |||
1111 | *++yyvsp = yylval; | ||
1112 | |||
1113 | |||
1114 | /* Count tokens shifted since error; after three, turn off error | ||
1115 | status. */ | ||
1116 | if (yyerrstatus) | ||
1117 | yyerrstatus--; | ||
1118 | |||
1119 | yystate = yyn; | ||
1120 | goto yynewstate; | ||
1121 | |||
1122 | |||
1123 | /*-----------------------------------------------------------. | ||
1124 | | yydefault -- do the default action for the current state. | | ||
1125 | `-----------------------------------------------------------*/ | ||
1126 | yydefault: | ||
1127 | yyn = yydefact[yystate]; | ||
1128 | if (yyn == 0) | ||
1129 | goto yyerrlab; | ||
1130 | goto yyreduce; | ||
1131 | |||
1132 | |||
1133 | /*-----------------------------. | ||
1134 | | yyreduce -- Do a reduction. | | ||
1135 | `-----------------------------*/ | ||
1136 | yyreduce: | ||
1137 | /* yyn is the number of a rule to reduce with. */ | ||
1138 | yylen = yyr2[yyn]; | ||
1139 | |||
1140 | /* If YYLEN is nonzero, implement the default value of the action: | ||
1141 | `$$ = $1'. | ||
1142 | |||
1143 | Otherwise, the following line sets YYVAL to garbage. | ||
1144 | This behavior is undocumented and Bison | ||
1145 | users should not rely upon it. Assigning to YYVAL | ||
1146 | unconditionally makes the parser a bit smaller, and it avoids a | ||
1147 | GCC warning that YYVAL may be used uninitialized. */ | ||
1148 | yyval = yyvsp[1-yylen]; | ||
1149 | |||
1150 | |||
1151 | |||
1152 | #if YYDEBUG | ||
1153 | /* We have to keep this `#if YYDEBUG', since we use variables which | ||
1154 | are defined only if `YYDEBUG' is set. */ | ||
1155 | if (yydebug) | ||
1156 | { | ||
1157 | int yyi; | ||
1158 | |||
1159 | YYFPRINTF (stderr, "Reducing via rule %d (line %d), ", | ||
1160 | yyn - 1, yyrline[yyn]); | ||
1161 | |||
1162 | /* Print the symbols being reduced, and their result. */ | ||
1163 | for (yyi = yyprhs[yyn]; yyrhs[yyi] >= 0; yyi++) | ||
1164 | YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); | ||
1165 | YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]); | ||
1166 | } | ||
1167 | #endif | ||
1168 | switch (yyn) | ||
1169 | { | ||
1170 | case 8: | ||
1171 | #line 96 "zconf.y" | ||
1172 | { zconfprint("unexpected 'endmenu' statement"); } | ||
1173 | break; | ||
1174 | |||
1175 | case 9: | ||
1176 | #line 97 "zconf.y" | ||
1177 | { zconfprint("unexpected 'endif' statement"); } | ||
1178 | break; | ||
1179 | |||
1180 | case 10: | ||
1181 | #line 98 "zconf.y" | ||
1182 | { zconfprint("unexpected 'endchoice' statement"); } | ||
1183 | break; | ||
1184 | |||
1185 | case 11: | ||
1186 | #line 99 "zconf.y" | ||
1187 | { zconfprint("syntax error"); yyerrok; } | ||
1188 | break; | ||
1189 | |||
1190 | case 17: | ||
1191 | #line 114 "zconf.y" | ||
1192 | { | ||
1193 | struct symbol *sym = sym_lookup(yyvsp[0].string, 0); | ||
1194 | sym->flags |= SYMBOL_OPTIONAL; | ||
1195 | menu_add_entry(sym); | ||
1196 | printd(DEBUG_PARSE, "%s:%d:config %s\n", zconf_curname(), zconf_lineno(), yyvsp[0].string); | ||
1197 | } | ||
1198 | break; | ||
1199 | |||
1200 | case 18: | ||
1201 | #line 122 "zconf.y" | ||
1202 | { | ||
1203 | menu_end_entry(); | ||
1204 | printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); | ||
1205 | } | ||
1206 | break; | ||
1207 | |||
1208 | case 23: | ||
1209 | #line 133 "zconf.y" | ||
1210 | { } | ||
1211 | break; | ||
1212 | |||
1213 | case 24: | ||
1214 | #line 136 "zconf.y" | ||
1215 | { | ||
1216 | menu_set_type(S_TRISTATE); | ||
1217 | printd(DEBUG_PARSE, "%s:%d:tristate\n", zconf_curname(), zconf_lineno()); | ||
1218 | } | ||
1219 | break; | ||
1220 | |||
1221 | case 25: | ||
1222 | #line 142 "zconf.y" | ||
1223 | { | ||
1224 | menu_set_type(S_BOOLEAN); | ||
1225 | printd(DEBUG_PARSE, "%s:%d:boolean\n", zconf_curname(), zconf_lineno()); | ||
1226 | } | ||
1227 | break; | ||
1228 | |||
1229 | case 26: | ||
1230 | #line 148 "zconf.y" | ||
1231 | { | ||
1232 | menu_set_type(S_INT); | ||
1233 | printd(DEBUG_PARSE, "%s:%d:int\n", zconf_curname(), zconf_lineno()); | ||
1234 | } | ||
1235 | break; | ||
1236 | |||
1237 | case 27: | ||
1238 | #line 154 "zconf.y" | ||
1239 | { | ||
1240 | menu_set_type(S_HEX); | ||
1241 | printd(DEBUG_PARSE, "%s:%d:hex\n", zconf_curname(), zconf_lineno()); | ||
1242 | } | ||
1243 | break; | ||
1244 | |||
1245 | case 28: | ||
1246 | #line 160 "zconf.y" | ||
1247 | { | ||
1248 | menu_set_type(S_STRING); | ||
1249 | printd(DEBUG_PARSE, "%s:%d:string\n", zconf_curname(), zconf_lineno()); | ||
1250 | } | ||
1251 | break; | ||
1252 | |||
1253 | case 29: | ||
1254 | #line 166 "zconf.y" | ||
1255 | { | ||
1256 | menu_add_prop(P_PROMPT, yyvsp[-1].string, NULL, yyvsp[0].expr); | ||
1257 | printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); | ||
1258 | } | ||
1259 | break; | ||
1260 | |||
1261 | case 30: | ||
1262 | #line 172 "zconf.y" | ||
1263 | { | ||
1264 | menu_add_prop(P_DEFAULT, NULL, yyvsp[-1].symbol, yyvsp[0].expr); | ||
1265 | printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno()); | ||
1266 | } | ||
1267 | break; | ||
1268 | |||
1269 | case 31: | ||
1270 | #line 180 "zconf.y" | ||
1271 | { | ||
1272 | struct symbol *sym = sym_lookup(NULL, 0); | ||
1273 | sym->flags |= SYMBOL_CHOICE; | ||
1274 | menu_add_entry(sym); | ||
1275 | menu_add_prop(P_CHOICE, NULL, NULL, NULL); | ||
1276 | printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno()); | ||
1277 | } | ||
1278 | break; | ||
1279 | |||
1280 | case 32: | ||
1281 | #line 189 "zconf.y" | ||
1282 | { | ||
1283 | menu_end_entry(); | ||
1284 | menu_add_menu(); | ||
1285 | } | ||
1286 | break; | ||
1287 | |||
1288 | case 33: | ||
1289 | #line 195 "zconf.y" | ||
1290 | { | ||
1291 | if (zconf_endtoken(yyvsp[0].token, T_CHOICE, T_ENDCHOICE)) { | ||
1292 | menu_end_menu(); | ||
1293 | printd(DEBUG_PARSE, "%s:%d:endchoice\n", zconf_curname(), zconf_lineno()); | ||
1294 | } | ||
1295 | } | ||
1296 | break; | ||
1297 | |||
1298 | case 35: | ||
1299 | #line 205 "zconf.y" | ||
1300 | { | ||
1301 | printf("%s:%d: missing 'endchoice' for this 'choice' statement\n", current_menu->file->name, current_menu->lineno); | ||
1302 | zconfnerrs++; | ||
1303 | } | ||
1304 | break; | ||
1305 | |||
1306 | case 41: | ||
1307 | #line 219 "zconf.y" | ||
1308 | { | ||
1309 | menu_add_prop(P_PROMPT, yyvsp[-1].string, NULL, yyvsp[0].expr); | ||
1310 | printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); | ||
1311 | } | ||
1312 | break; | ||
1313 | |||
1314 | case 42: | ||
1315 | #line 225 "zconf.y" | ||
1316 | { | ||
1317 | current_entry->sym->flags |= SYMBOL_OPTIONAL; | ||
1318 | printd(DEBUG_PARSE, "%s:%d:optional\n", zconf_curname(), zconf_lineno()); | ||
1319 | } | ||
1320 | break; | ||
1321 | |||
1322 | case 43: | ||
1323 | #line 231 "zconf.y" | ||
1324 | { | ||
1325 | menu_add_prop(P_DEFAULT, NULL, yyvsp[0].symbol, NULL); | ||
1326 | //current_choice->prop->def = ; | ||
1327 | printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno()); | ||
1328 | } | ||
1329 | break; | ||
1330 | |||
1331 | case 46: | ||
1332 | #line 245 "zconf.y" | ||
1333 | { | ||
1334 | printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno()); | ||
1335 | menu_add_entry(NULL); | ||
1336 | //current_entry->prompt = menu_add_prop(T_IF, NULL, NULL, ); | ||
1337 | menu_add_dep(yyvsp[0].expr); | ||
1338 | menu_end_entry(); | ||
1339 | menu_add_menu(); | ||
1340 | } | ||
1341 | break; | ||
1342 | |||
1343 | case 47: | ||
1344 | #line 255 "zconf.y" | ||
1345 | { | ||
1346 | if (zconf_endtoken(yyvsp[0].token, T_IF, T_ENDIF)) { | ||
1347 | menu_end_menu(); | ||
1348 | printd(DEBUG_PARSE, "%s:%d:endif\n", zconf_curname(), zconf_lineno()); | ||
1349 | } | ||
1350 | } | ||
1351 | break; | ||
1352 | |||
1353 | case 49: | ||
1354 | #line 265 "zconf.y" | ||
1355 | { | ||
1356 | printf("%s:%d: missing 'endif' for this 'if' statement\n", current_menu->file->name, current_menu->lineno); | ||
1357 | zconfnerrs++; | ||
1358 | } | ||
1359 | break; | ||
1360 | |||
1361 | case 54: | ||
1362 | #line 280 "zconf.y" | ||
1363 | { | ||
1364 | menu_add_entry(NULL); | ||
1365 | menu_add_prop(P_MENU, yyvsp[0].string, NULL, NULL); | ||
1366 | printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno()); | ||
1367 | } | ||
1368 | break; | ||
1369 | |||
1370 | case 55: | ||
1371 | #line 287 "zconf.y" | ||
1372 | { | ||
1373 | menu_end_entry(); | ||
1374 | menu_add_menu(); | ||
1375 | } | ||
1376 | break; | ||
1377 | |||
1378 | case 56: | ||
1379 | #line 293 "zconf.y" | ||
1380 | { | ||
1381 | if (zconf_endtoken(yyvsp[0].token, T_MENU, T_ENDMENU)) { | ||
1382 | menu_end_menu(); | ||
1383 | printd(DEBUG_PARSE, "%s:%d:endmenu\n", zconf_curname(), zconf_lineno()); | ||
1384 | } | ||
1385 | } | ||
1386 | break; | ||
1387 | |||
1388 | case 58: | ||
1389 | #line 303 "zconf.y" | ||
1390 | { | ||
1391 | printf("%s:%d: missing 'endmenu' for this 'menu' statement\n", current_menu->file->name, current_menu->lineno); | ||
1392 | zconfnerrs++; | ||
1393 | } | ||
1394 | break; | ||
1395 | |||
1396 | case 63: | ||
1397 | #line 313 "zconf.y" | ||
1398 | { zconfprint("invalid menu option"); yyerrok; } | ||
1399 | break; | ||
1400 | |||
1401 | case 64: | ||
1402 | #line 317 "zconf.y" | ||
1403 | { | ||
1404 | yyval.string = yyvsp[0].string; | ||
1405 | printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), yyvsp[0].string); | ||
1406 | } | ||
1407 | break; | ||
1408 | |||
1409 | case 65: | ||
1410 | #line 323 "zconf.y" | ||
1411 | { | ||
1412 | zconf_nextfile(yyvsp[-1].string); | ||
1413 | } | ||
1414 | break; | ||
1415 | |||
1416 | case 66: | ||
1417 | #line 330 "zconf.y" | ||
1418 | { | ||
1419 | menu_add_entry(NULL); | ||
1420 | menu_add_prop(P_COMMENT, yyvsp[0].string, NULL, NULL); | ||
1421 | printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno()); | ||
1422 | } | ||
1423 | break; | ||
1424 | |||
1425 | case 67: | ||
1426 | #line 337 "zconf.y" | ||
1427 | { | ||
1428 | menu_end_entry(); | ||
1429 | } | ||
1430 | break; | ||
1431 | |||
1432 | case 68: | ||
1433 | #line 344 "zconf.y" | ||
1434 | { | ||
1435 | printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno()); | ||
1436 | zconf_starthelp(); | ||
1437 | } | ||
1438 | break; | ||
1439 | |||
1440 | case 69: | ||
1441 | #line 350 "zconf.y" | ||
1442 | { | ||
1443 | current_entry->sym->help = yyvsp[0].string; | ||
1444 | } | ||
1445 | break; | ||
1446 | |||
1447 | case 72: | ||
1448 | #line 359 "zconf.y" | ||
1449 | { } | ||
1450 | break; | ||
1451 | |||
1452 | case 73: | ||
1453 | #line 362 "zconf.y" | ||
1454 | { | ||
1455 | menu_add_dep(yyvsp[0].expr); | ||
1456 | printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno()); | ||
1457 | } | ||
1458 | break; | ||
1459 | |||
1460 | case 74: | ||
1461 | #line 367 "zconf.y" | ||
1462 | { | ||
1463 | menu_add_dep(yyvsp[0].expr); | ||
1464 | printd(DEBUG_PARSE, "%s:%d:depends\n", zconf_curname(), zconf_lineno()); | ||
1465 | } | ||
1466 | break; | ||
1467 | |||
1468 | case 75: | ||
1469 | #line 372 "zconf.y" | ||
1470 | { | ||
1471 | menu_add_dep(yyvsp[0].expr); | ||
1472 | printd(DEBUG_PARSE, "%s:%d:requires\n", zconf_curname(), zconf_lineno()); | ||
1473 | } | ||
1474 | break; | ||
1475 | |||
1476 | case 77: | ||
1477 | #line 382 "zconf.y" | ||
1478 | { | ||
1479 | menu_add_prop(P_PROMPT, yyvsp[0].string, NULL, NULL); | ||
1480 | } | ||
1481 | break; | ||
1482 | |||
1483 | case 78: | ||
1484 | #line 386 "zconf.y" | ||
1485 | { | ||
1486 | menu_add_prop(P_PROMPT, yyvsp[-2].string, NULL, yyvsp[0].expr); | ||
1487 | } | ||
1488 | break; | ||
1489 | |||
1490 | case 81: | ||
1491 | #line 394 "zconf.y" | ||
1492 | { yyval.token = T_ENDMENU; } | ||
1493 | break; | ||
1494 | |||
1495 | case 82: | ||
1496 | #line 395 "zconf.y" | ||
1497 | { yyval.token = T_ENDCHOICE; } | ||
1498 | break; | ||
1499 | |||
1500 | case 83: | ||
1501 | #line 396 "zconf.y" | ||
1502 | { yyval.token = T_ENDIF; } | ||
1503 | break; | ||
1504 | |||
1505 | case 86: | ||
1506 | #line 402 "zconf.y" | ||
1507 | { yyval.expr = NULL; } | ||
1508 | break; | ||
1509 | |||
1510 | case 87: | ||
1511 | #line 403 "zconf.y" | ||
1512 | { yyval.expr = yyvsp[0].expr; } | ||
1513 | break; | ||
1514 | |||
1515 | case 88: | ||
1516 | #line 406 "zconf.y" | ||
1517 | { yyval.expr = expr_alloc_symbol(yyvsp[0].symbol); } | ||
1518 | break; | ||
1519 | |||
1520 | case 89: | ||
1521 | #line 407 "zconf.y" | ||
1522 | { yyval.expr = expr_alloc_comp(E_EQUAL, yyvsp[-2].symbol, yyvsp[0].symbol); } | ||
1523 | break; | ||
1524 | |||
1525 | case 90: | ||
1526 | #line 408 "zconf.y" | ||
1527 | { yyval.expr = expr_alloc_comp(E_UNEQUAL, yyvsp[-2].symbol, yyvsp[0].symbol); } | ||
1528 | break; | ||
1529 | |||
1530 | case 91: | ||
1531 | #line 409 "zconf.y" | ||
1532 | { yyval.expr = yyvsp[-1].expr; } | ||
1533 | break; | ||
1534 | |||
1535 | case 92: | ||
1536 | #line 410 "zconf.y" | ||
1537 | { yyval.expr = expr_alloc_one(E_NOT, yyvsp[0].expr); } | ||
1538 | break; | ||
1539 | |||
1540 | case 93: | ||
1541 | #line 411 "zconf.y" | ||
1542 | { yyval.expr = expr_alloc_two(E_OR, yyvsp[-2].expr, yyvsp[0].expr); } | ||
1543 | break; | ||
1544 | |||
1545 | case 94: | ||
1546 | #line 412 "zconf.y" | ||
1547 | { yyval.expr = expr_alloc_two(E_AND, yyvsp[-2].expr, yyvsp[0].expr); } | ||
1548 | break; | ||
1549 | |||
1550 | case 95: | ||
1551 | #line 415 "zconf.y" | ||
1552 | { yyval.symbol = sym_lookup(yyvsp[0].string, 0); free(yyvsp[0].string); } | ||
1553 | break; | ||
1554 | |||
1555 | case 96: | ||
1556 | #line 416 "zconf.y" | ||
1557 | { yyval.symbol = sym_lookup(yyvsp[0].string, 1); free(yyvsp[0].string); } | ||
1558 | break; | ||
1559 | |||
1560 | |||
1561 | } | ||
1562 | |||
1563 | /* Line 1016 of /usr/share/bison/yacc.c. */ | ||
1564 | #line 1565 "zconf.tab.c" | ||
1565 | |||
1566 | yyvsp -= yylen; | ||
1567 | yyssp -= yylen; | ||
1568 | |||
1569 | |||
1570 | #if YYDEBUG | ||
1571 | if (yydebug) | ||
1572 | { | ||
1573 | short *yyssp1 = yyss - 1; | ||
1574 | YYFPRINTF (stderr, "state stack now"); | ||
1575 | while (yyssp1 != yyssp) | ||
1576 | YYFPRINTF (stderr, " %d", *++yyssp1); | ||
1577 | YYFPRINTF (stderr, "\n"); | ||
1578 | } | ||
1579 | #endif | ||
1580 | |||
1581 | *++yyvsp = yyval; | ||
1582 | |||
1583 | |||
1584 | /* Now `shift' the result of the reduction. Determine what state | ||
1585 | that goes to, based on the state we popped back to and the rule | ||
1586 | number reduced by. */ | ||
1587 | |||
1588 | yyn = yyr1[yyn]; | ||
1589 | |||
1590 | yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; | ||
1591 | if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) | ||
1592 | yystate = yytable[yystate]; | ||
1593 | else | ||
1594 | yystate = yydefgoto[yyn - YYNTOKENS]; | ||
1595 | |||
1596 | goto yynewstate; | ||
1597 | |||
1598 | |||
1599 | /*------------------------------------. | ||
1600 | | yyerrlab -- here on detecting error | | ||
1601 | `------------------------------------*/ | ||
1602 | yyerrlab: | ||
1603 | /* If not already recovering from an error, report this error. */ | ||
1604 | if (!yyerrstatus) | ||
1605 | { | ||
1606 | ++yynerrs; | ||
1607 | #if YYERROR_VERBOSE | ||
1608 | yyn = yypact[yystate]; | ||
1609 | |||
1610 | if (YYPACT_NINF < yyn && yyn < YYLAST) | ||
1611 | { | ||
1612 | YYSIZE_T yysize = 0; | ||
1613 | int yytype = YYTRANSLATE (yychar); | ||
1614 | char *yymsg; | ||
1615 | int yyx, yycount; | ||
1616 | |||
1617 | yycount = 0; | ||
1618 | /* Start YYX at -YYN if negative to avoid negative indexes in | ||
1619 | YYCHECK. */ | ||
1620 | for (yyx = yyn < 0 ? -yyn : 0; | ||
1621 | yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) | ||
1622 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) | ||
1623 | yysize += yystrlen (yytname[yyx]) + 15, yycount++; | ||
1624 | yysize += yystrlen ("parse error, unexpected ") + 1; | ||
1625 | yysize += yystrlen (yytname[yytype]); | ||
1626 | yymsg = (char *) YYSTACK_ALLOC (yysize); | ||
1627 | if (yymsg != 0) | ||
1628 | { | ||
1629 | char *yyp = yystpcpy (yymsg, "parse error, unexpected "); | ||
1630 | yyp = yystpcpy (yyp, yytname[yytype]); | ||
1631 | |||
1632 | if (yycount < 5) | ||
1633 | { | ||
1634 | yycount = 0; | ||
1635 | for (yyx = yyn < 0 ? -yyn : 0; | ||
1636 | yyx < (int) (sizeof (yytname) / sizeof (char *)); | ||
1637 | yyx++) | ||
1638 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) | ||
1639 | { | ||
1640 | const char *yyq = ! yycount ? ", expecting " : " or "; | ||
1641 | yyp = yystpcpy (yyp, yyq); | ||
1642 | yyp = yystpcpy (yyp, yytname[yyx]); | ||
1643 | yycount++; | ||
1644 | } | ||
1645 | } | ||
1646 | yyerror (yymsg); | ||
1647 | YYSTACK_FREE (yymsg); | ||
1648 | } | ||
1649 | else | ||
1650 | yyerror ("parse error; also virtual memory exhausted"); | ||
1651 | } | ||
1652 | else | ||
1653 | #endif /* YYERROR_VERBOSE */ | ||
1654 | yyerror ("parse error"); | ||
1655 | } | ||
1656 | goto yyerrlab1; | ||
1657 | |||
1658 | |||
1659 | /*----------------------------------------------------. | ||
1660 | | yyerrlab1 -- error raised explicitly by an action. | | ||
1661 | `----------------------------------------------------*/ | ||
1662 | yyerrlab1: | ||
1663 | if (yyerrstatus == 3) | ||
1664 | { | ||
1665 | /* If just tried and failed to reuse lookahead token after an | ||
1666 | error, discard it. */ | ||
1667 | |||
1668 | /* Return failure if at end of input. */ | ||
1669 | if (yychar == YYEOF) | ||
1670 | { | ||
1671 | /* Pop the error token. */ | ||
1672 | YYPOPSTACK; | ||
1673 | /* Pop the rest of the stack. */ | ||
1674 | while (yyssp > yyss) | ||
1675 | { | ||
1676 | YYDPRINTF ((stderr, "Error: popping ")); | ||
1677 | YYDSYMPRINT ((stderr, | ||
1678 | yystos[*yyssp], | ||
1679 | *yyvsp)); | ||
1680 | YYDPRINTF ((stderr, "\n")); | ||
1681 | yydestruct (yystos[*yyssp], *yyvsp); | ||
1682 | YYPOPSTACK; | ||
1683 | } | ||
1684 | YYABORT; | ||
1685 | } | ||
1686 | |||
1687 | YYDPRINTF ((stderr, "Discarding token %d (%s).\n", | ||
1688 | yychar, yytname[yychar1])); | ||
1689 | yydestruct (yychar1, yylval); | ||
1690 | yychar = YYEMPTY; | ||
1691 | } | ||
1692 | |||
1693 | /* Else will try to reuse lookahead token after shifting the error | ||
1694 | token. */ | ||
1695 | |||
1696 | yyerrstatus = 3; /* Each real token shifted decrements this. */ | ||
1697 | |||
1698 | for (;;) | ||
1699 | { | ||
1700 | yyn = yypact[yystate]; | ||
1701 | if (yyn != YYPACT_NINF) | ||
1702 | { | ||
1703 | yyn += YYTERROR; | ||
1704 | if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) | ||
1705 | { | ||
1706 | yyn = yytable[yyn]; | ||
1707 | if (0 < yyn) | ||
1708 | break; | ||
1709 | } | ||
1710 | } | ||
1711 | |||
1712 | /* Pop the current state because it cannot handle the error token. */ | ||
1713 | if (yyssp == yyss) | ||
1714 | YYABORT; | ||
1715 | |||
1716 | YYDPRINTF ((stderr, "Error: popping ")); | ||
1717 | YYDSYMPRINT ((stderr, | ||
1718 | yystos[*yyssp], *yyvsp)); | ||
1719 | YYDPRINTF ((stderr, "\n")); | ||
1720 | |||
1721 | yydestruct (yystos[yystate], *yyvsp); | ||
1722 | yyvsp--; | ||
1723 | yystate = *--yyssp; | ||
1724 | |||
1725 | |||
1726 | #if YYDEBUG | ||
1727 | if (yydebug) | ||
1728 | { | ||
1729 | short *yyssp1 = yyss - 1; | ||
1730 | YYFPRINTF (stderr, "Error: state stack now"); | ||
1731 | while (yyssp1 != yyssp) | ||
1732 | YYFPRINTF (stderr, " %d", *++yyssp1); | ||
1733 | YYFPRINTF (stderr, "\n"); | ||
1734 | } | ||
1735 | #endif | ||
1736 | } | ||
1737 | |||
1738 | if (yyn == YYFINAL) | ||
1739 | YYACCEPT; | ||
1740 | |||
1741 | YYDPRINTF ((stderr, "Shifting error token, ")); | ||
1742 | |||
1743 | *++yyvsp = yylval; | ||
1744 | |||
1745 | |||
1746 | yystate = yyn; | ||
1747 | goto yynewstate; | ||
1748 | |||
1749 | |||
1750 | /*-------------------------------------. | ||
1751 | | yyacceptlab -- YYACCEPT comes here. | | ||
1752 | `-------------------------------------*/ | ||
1753 | yyacceptlab: | ||
1754 | yyresult = 0; | ||
1755 | goto yyreturn; | ||
1756 | |||
1757 | /*-----------------------------------. | ||
1758 | | yyabortlab -- YYABORT comes here. | | ||
1759 | `-----------------------------------*/ | ||
1760 | yyabortlab: | ||
1761 | yyresult = 1; | ||
1762 | goto yyreturn; | ||
1763 | |||
1764 | #ifndef yyoverflow | ||
1765 | /*----------------------------------------------. | ||
1766 | | yyoverflowlab -- parser overflow comes here. | | ||
1767 | `----------------------------------------------*/ | ||
1768 | yyoverflowlab: | ||
1769 | yyerror ("parser stack overflow"); | ||
1770 | yyresult = 2; | ||
1771 | /* Fall through. */ | ||
1772 | #endif | ||
1773 | |||
1774 | yyreturn: | ||
1775 | #ifndef yyoverflow | ||
1776 | if (yyss != yyssa) | ||
1777 | YYSTACK_FREE (yyss); | ||
1778 | #endif | ||
1779 | return yyresult; | ||
1780 | } | ||
1781 | |||
1782 | |||
1783 | #line 419 "zconf.y" | ||
1784 | |||
1785 | |||
1786 | void conf_parse(const char *name) | ||
1787 | { | ||
1788 | zconf_initscan(name); | ||
1789 | |||
1790 | sym_init(); | ||
1791 | menu_init(); | ||
1792 | rootmenu.prompt = menu_add_prop(P_MENU, "BusyBox Configuration", NULL, NULL); | ||
1793 | |||
1794 | //zconfdebug = 1; | ||
1795 | zconfparse(); | ||
1796 | if (zconfnerrs) | ||
1797 | exit(1); | ||
1798 | menu_finalize(&rootmenu); | ||
1799 | |||
1800 | modules_sym = sym_lookup("MODULES", 0); | ||
1801 | |||
1802 | sym_change_count = 1; | ||
1803 | } | ||
1804 | |||
1805 | const char *zconf_tokenname(int token) | ||
1806 | { | ||
1807 | switch (token) { | ||
1808 | case T_MENU: return "menu"; | ||
1809 | case T_ENDMENU: return "endmenu"; | ||
1810 | case T_CHOICE: return "choice"; | ||
1811 | case T_ENDCHOICE: return "endchoice"; | ||
1812 | case T_IF: return "if"; | ||
1813 | case T_ENDIF: return "endif"; | ||
1814 | } | ||
1815 | return "<token>"; | ||
1816 | } | ||
1817 | |||
1818 | static bool zconf_endtoken(int token, int starttoken, int endtoken) | ||
1819 | { | ||
1820 | if (token != endtoken) { | ||
1821 | zconfprint("unexpected '%s' within %s block", zconf_tokenname(token), zconf_tokenname(starttoken)); | ||
1822 | zconfnerrs++; | ||
1823 | return false; | ||
1824 | } | ||
1825 | if (current_menu->file != current_file) { | ||
1826 | zconfprint("'%s' in different file than '%s'", zconf_tokenname(token), zconf_tokenname(starttoken)); | ||
1827 | zconfprint("location of the '%s'", zconf_tokenname(starttoken)); | ||
1828 | zconfnerrs++; | ||
1829 | return false; | ||
1830 | } | ||
1831 | return true; | ||
1832 | } | ||
1833 | |||
1834 | static void zconfprint(const char *err, ...) | ||
1835 | { | ||
1836 | va_list ap; | ||
1837 | |||
1838 | fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno()); | ||
1839 | va_start(ap, err); | ||
1840 | vfprintf(stderr, err, ap); | ||
1841 | va_end(ap); | ||
1842 | fprintf(stderr, "\n"); | ||
1843 | } | ||
1844 | |||
1845 | static void zconferror(const char *err) | ||
1846 | { | ||
1847 | fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno(), err); | ||
1848 | } | ||
1849 | |||
1850 | void print_quoted_string(FILE *out, const char *str) | ||
1851 | { | ||
1852 | const char *p; | ||
1853 | int len; | ||
1854 | |||
1855 | putc('"', out); | ||
1856 | while ((p = strchr(str, '"'))) { | ||
1857 | len = p - str; | ||
1858 | if (len) | ||
1859 | fprintf(out, "%.*s", len, str); | ||
1860 | fputs("\\\"", out); | ||
1861 | str = p + 1; | ||
1862 | } | ||
1863 | fputs(str, out); | ||
1864 | putc('"', out); | ||
1865 | } | ||
1866 | |||
1867 | void print_symbol(FILE *out, struct menu *menu) | ||
1868 | { | ||
1869 | struct symbol *sym = menu->sym; | ||
1870 | struct property *prop; | ||
1871 | |||
1872 | //sym->flags |= SYMBOL_PRINTED; | ||
1873 | |||
1874 | if (sym_is_choice(sym)) | ||
1875 | fprintf(out, "choice\n"); | ||
1876 | else | ||
1877 | fprintf(out, "config %s\n", sym->name); | ||
1878 | switch (sym->type) { | ||
1879 | case S_BOOLEAN: | ||
1880 | fputs(" boolean\n", out); | ||
1881 | break; | ||
1882 | case S_TRISTATE: | ||
1883 | fputs(" tristate\n", out); | ||
1884 | break; | ||
1885 | case S_STRING: | ||
1886 | fputs(" string\n", out); | ||
1887 | break; | ||
1888 | case S_INT: | ||
1889 | fputs(" integer\n", out); | ||
1890 | break; | ||
1891 | case S_HEX: | ||
1892 | fputs(" hex\n", out); | ||
1893 | break; | ||
1894 | default: | ||
1895 | fputs(" ???\n", out); | ||
1896 | break; | ||
1897 | } | ||
1898 | #if 0 | ||
1899 | if (!expr_is_yes(sym->dep)) { | ||
1900 | fputs(" depends ", out); | ||
1901 | expr_fprint(sym->dep, out); | ||
1902 | fputc('\n', out); | ||
1903 | } | ||
1904 | #endif | ||
1905 | for (prop = sym->prop; prop; prop = prop->next) { | ||
1906 | if (prop->menu != menu) | ||
1907 | continue; | ||
1908 | switch (prop->type) { | ||
1909 | case P_PROMPT: | ||
1910 | fputs(" prompt ", out); | ||
1911 | print_quoted_string(out, prop->text); | ||
1912 | if (prop->def) { | ||
1913 | fputc(' ', out); | ||
1914 | if (prop->def->flags & SYMBOL_CONST) | ||
1915 | print_quoted_string(out, prop->def->name); | ||
1916 | else | ||
1917 | fputs(prop->def->name, out); | ||
1918 | } | ||
1919 | if (!expr_is_yes(E_EXPR(prop->visible))) { | ||
1920 | fputs(" if ", out); | ||
1921 | expr_fprint(E_EXPR(prop->visible), out); | ||
1922 | } | ||
1923 | fputc('\n', out); | ||
1924 | break; | ||
1925 | case P_DEFAULT: | ||
1926 | fputs( " default ", out); | ||
1927 | print_quoted_string(out, prop->def->name); | ||
1928 | if (!expr_is_yes(E_EXPR(prop->visible))) { | ||
1929 | fputs(" if ", out); | ||
1930 | expr_fprint(E_EXPR(prop->visible), out); | ||
1931 | } | ||
1932 | fputc('\n', out); | ||
1933 | break; | ||
1934 | case P_CHOICE: | ||
1935 | fputs(" #choice value\n", out); | ||
1936 | break; | ||
1937 | default: | ||
1938 | fprintf(out, " unknown prop %d!\n", prop->type); | ||
1939 | break; | ||
1940 | } | ||
1941 | } | ||
1942 | if (sym->help) { | ||
1943 | int len = strlen(sym->help); | ||
1944 | while (sym->help[--len] == '\n') | ||
1945 | sym->help[len] = 0; | ||
1946 | fprintf(out, " help\n%s\n", sym->help); | ||
1947 | } | ||
1948 | fputc('\n', out); | ||
1949 | } | ||
1950 | |||
1951 | void zconfdump(FILE *out) | ||
1952 | { | ||
1953 | //struct file *file; | ||
1954 | struct property *prop; | ||
1955 | struct symbol *sym; | ||
1956 | struct menu *menu; | ||
1957 | |||
1958 | menu = rootmenu.list; | ||
1959 | while (menu) { | ||
1960 | if ((sym = menu->sym)) | ||
1961 | print_symbol(out, menu); | ||
1962 | else if ((prop = menu->prompt)) { | ||
1963 | switch (prop->type) { | ||
1964 | //case T_MAINMENU: | ||
1965 | // fputs("\nmainmenu ", out); | ||
1966 | // print_quoted_string(out, prop->text); | ||
1967 | // fputs("\n", out); | ||
1968 | // break; | ||
1969 | case P_COMMENT: | ||
1970 | fputs("\ncomment ", out); | ||
1971 | print_quoted_string(out, prop->text); | ||
1972 | fputs("\n", out); | ||
1973 | break; | ||
1974 | case P_MENU: | ||
1975 | fputs("\nmenu ", out); | ||
1976 | print_quoted_string(out, prop->text); | ||
1977 | fputs("\n", out); | ||
1978 | break; | ||
1979 | //case T_SOURCE: | ||
1980 | // fputs("\nsource ", out); | ||
1981 | // print_quoted_string(out, prop->text); | ||
1982 | // fputs("\n", out); | ||
1983 | // break; | ||
1984 | //case T_IF: | ||
1985 | // fputs("\nif\n", out); | ||
1986 | default: | ||
1987 | ; | ||
1988 | } | ||
1989 | if (!expr_is_yes(E_EXPR(prop->visible))) { | ||
1990 | fputs(" depends ", out); | ||
1991 | expr_fprint(E_EXPR(prop->visible), out); | ||
1992 | fputc('\n', out); | ||
1993 | } | ||
1994 | fputs("\n", out); | ||
1995 | } | ||
1996 | |||
1997 | if (menu->list) | ||
1998 | menu = menu->list; | ||
1999 | else if (menu->next) | ||
2000 | menu = menu->next; | ||
2001 | else while ((menu = menu->parent)) { | ||
2002 | if (menu->prompt && menu->prompt->type == P_MENU) | ||
2003 | fputs("\nendmenu\n", out); | ||
2004 | if (menu->next) { | ||
2005 | menu = menu->next; | ||
2006 | break; | ||
2007 | } | ||
2008 | } | ||
2009 | } | ||
2010 | } | ||
2011 | |||
2012 | #include "lex.zconf.c" | ||
2013 | #include "confdata.c" | ||
2014 | #include "expr.c" | ||
2015 | #include "symbol.c" | ||
2016 | #include "menu.c" | ||
2017 | |||
diff --git a/scripts/config/zconf.tab.h_shipped b/scripts/config/zconf.tab.h_shipped new file mode 100644 index 000000000..3b191ef59 --- /dev/null +++ b/scripts/config/zconf.tab.h_shipped | |||
@@ -0,0 +1,125 @@ | |||
1 | /* A Bison parser, made from zconf.y, by GNU bison 1.75. */ | ||
2 | |||
3 | /* Skeleton parser for Yacc-like parsing with Bison, | ||
4 | Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc. | ||
5 | |||
6 | This program is free software; you can redistribute it and/or modify | ||
7 | it under the terms of the GNU General Public License as published by | ||
8 | the Free Software Foundation; either version 2, or (at your option) | ||
9 | any later version. | ||
10 | |||
11 | This program is distributed in the hope that it will be useful, | ||
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | GNU General Public License for more details. | ||
15 | |||
16 | You should have received a copy of the GNU General Public License | ||
17 | along with this program; if not, write to the Free Software | ||
18 | Foundation, Inc., 59 Temple Place - Suite 330, | ||
19 | Boston, MA 02111-1307, USA. */ | ||
20 | |||
21 | /* As a special exception, when this file is copied by Bison into a | ||
22 | Bison output file, you may use that output file without restriction. | ||
23 | This special exception was added by the Free Software Foundation | ||
24 | in version 1.24 of Bison. */ | ||
25 | |||
26 | #ifndef BISON_ZCONF_TAB_H | ||
27 | # define BISON_ZCONF_TAB_H | ||
28 | |||
29 | /* Tokens. */ | ||
30 | #ifndef YYTOKENTYPE | ||
31 | # define YYTOKENTYPE | ||
32 | /* Put the tokens into the symbol table, so that GDB and other debuggers | ||
33 | know about them. */ | ||
34 | enum yytokentype { | ||
35 | T_MAINMENU = 258, | ||
36 | T_MENU = 259, | ||
37 | T_ENDMENU = 260, | ||
38 | T_SOURCE = 261, | ||
39 | T_CHOICE = 262, | ||
40 | T_ENDCHOICE = 263, | ||
41 | T_COMMENT = 264, | ||
42 | T_CONFIG = 265, | ||
43 | T_HELP = 266, | ||
44 | T_HELPTEXT = 267, | ||
45 | T_IF = 268, | ||
46 | T_ENDIF = 269, | ||
47 | T_DEPENDS = 270, | ||
48 | T_REQUIRES = 271, | ||
49 | T_OPTIONAL = 272, | ||
50 | T_PROMPT = 273, | ||
51 | T_DEFAULT = 274, | ||
52 | T_TRISTATE = 275, | ||
53 | T_BOOLEAN = 276, | ||
54 | T_INT = 277, | ||
55 | T_HEX = 278, | ||
56 | T_WORD = 279, | ||
57 | T_STRING = 280, | ||
58 | T_UNEQUAL = 281, | ||
59 | T_EOF = 282, | ||
60 | T_EOL = 283, | ||
61 | T_CLOSE_PAREN = 284, | ||
62 | T_OPEN_PAREN = 285, | ||
63 | T_ON = 286, | ||
64 | T_OR = 287, | ||
65 | T_AND = 288, | ||
66 | T_EQUAL = 289, | ||
67 | T_NOT = 290 | ||
68 | }; | ||
69 | #endif | ||
70 | #define T_MAINMENU 258 | ||
71 | #define T_MENU 259 | ||
72 | #define T_ENDMENU 260 | ||
73 | #define T_SOURCE 261 | ||
74 | #define T_CHOICE 262 | ||
75 | #define T_ENDCHOICE 263 | ||
76 | #define T_COMMENT 264 | ||
77 | #define T_CONFIG 265 | ||
78 | #define T_HELP 266 | ||
79 | #define T_HELPTEXT 267 | ||
80 | #define T_IF 268 | ||
81 | #define T_ENDIF 269 | ||
82 | #define T_DEPENDS 270 | ||
83 | #define T_REQUIRES 271 | ||
84 | #define T_OPTIONAL 272 | ||
85 | #define T_PROMPT 273 | ||
86 | #define T_DEFAULT 274 | ||
87 | #define T_TRISTATE 275 | ||
88 | #define T_BOOLEAN 276 | ||
89 | #define T_INT 277 | ||
90 | #define T_HEX 278 | ||
91 | #define T_WORD 279 | ||
92 | #define T_STRING 280 | ||
93 | #define T_UNEQUAL 281 | ||
94 | #define T_EOF 282 | ||
95 | #define T_EOL 283 | ||
96 | #define T_CLOSE_PAREN 284 | ||
97 | #define T_OPEN_PAREN 285 | ||
98 | #define T_ON 286 | ||
99 | #define T_OR 287 | ||
100 | #define T_AND 288 | ||
101 | #define T_EQUAL 289 | ||
102 | #define T_NOT 290 | ||
103 | |||
104 | |||
105 | |||
106 | |||
107 | #ifndef YYSTYPE | ||
108 | #line 33 "zconf.y" | ||
109 | typedef union { | ||
110 | int token; | ||
111 | char *string; | ||
112 | struct symbol *symbol; | ||
113 | struct expr *expr; | ||
114 | struct menu *menu; | ||
115 | } yystype; | ||
116 | /* Line 1281 of /usr/share/bison/yacc.c. */ | ||
117 | #line 118 "zconf.tab.h" | ||
118 | # define YYSTYPE yystype | ||
119 | #endif | ||
120 | |||
121 | extern YYSTYPE zconflval; | ||
122 | |||
123 | |||
124 | #endif /* not BISON_ZCONF_TAB_H */ | ||
125 | |||
diff --git a/scripts/config/zconf.y b/scripts/config/zconf.y new file mode 100644 index 000000000..301d7a896 --- /dev/null +++ b/scripts/config/zconf.y | |||
@@ -0,0 +1,651 @@ | |||
1 | %{ | ||
2 | /* | ||
3 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> | ||
4 | * Released under the terms of the GNU GPL v2.0. | ||
5 | */ | ||
6 | |||
7 | #include <ctype.h> | ||
8 | #include <stdarg.h> | ||
9 | #include <stdio.h> | ||
10 | #include <stdlib.h> | ||
11 | #include <string.h> | ||
12 | #include <stdbool.h> | ||
13 | |||
14 | #define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt) | ||
15 | |||
16 | #define PRINTD 0x0001 | ||
17 | #define DEBUG_PARSE 0x0002 | ||
18 | |||
19 | int cdebug = PRINTD; | ||
20 | |||
21 | extern int zconflex(void); | ||
22 | static void zconfprint(const char *err, ...); | ||
23 | static void zconferror(const char *err); | ||
24 | static bool zconf_endtoken(int token, int starttoken, int endtoken); | ||
25 | |||
26 | struct symbol *symbol_hash[257]; | ||
27 | |||
28 | #define YYERROR_VERBOSE | ||
29 | %} | ||
30 | %expect 36 | ||
31 | |||
32 | %union | ||
33 | { | ||
34 | int token; | ||
35 | char *string; | ||
36 | struct symbol *symbol; | ||
37 | struct expr *expr; | ||
38 | struct menu *menu; | ||
39 | } | ||
40 | |||
41 | %token T_MAINMENU | ||
42 | %token T_MENU | ||
43 | %token T_ENDMENU | ||
44 | %token T_SOURCE | ||
45 | %token T_CHOICE | ||
46 | %token T_ENDCHOICE | ||
47 | %token T_COMMENT | ||
48 | %token T_CONFIG | ||
49 | %token T_HELP | ||
50 | %token <string> T_HELPTEXT | ||
51 | %token T_IF | ||
52 | %token T_ENDIF | ||
53 | %token T_DEPENDS | ||
54 | %token T_REQUIRES | ||
55 | %token T_OPTIONAL | ||
56 | %token T_PROMPT | ||
57 | %token T_DEFAULT | ||
58 | %token T_TRISTATE | ||
59 | %token T_BOOLEAN | ||
60 | %token T_INT | ||
61 | %token T_HEX | ||
62 | %token <string> T_WORD | ||
63 | %token <string> T_STRING | ||
64 | %token T_UNEQUAL | ||
65 | %token T_EOF | ||
66 | %token T_EOL | ||
67 | %token T_CLOSE_PAREN | ||
68 | %token T_OPEN_PAREN | ||
69 | %token T_ON | ||
70 | |||
71 | %left T_OR | ||
72 | %left T_AND | ||
73 | %left T_EQUAL T_UNEQUAL | ||
74 | %nonassoc T_NOT | ||
75 | |||
76 | %type <string> prompt | ||
77 | %type <string> source | ||
78 | %type <symbol> symbol | ||
79 | %type <expr> expr | ||
80 | %type <expr> if_expr | ||
81 | %type <token> end | ||
82 | |||
83 | %{ | ||
84 | #define LKC_DIRECT_LINK | ||
85 | #include "lkc.h" | ||
86 | %} | ||
87 | %% | ||
88 | input: /* empty */ | ||
89 | | input block | ||
90 | ; | ||
91 | |||
92 | block: common_block | ||
93 | | choice_stmt | ||
94 | | menu_stmt | ||
95 | | T_MAINMENU prompt nl_or_eof | ||
96 | | T_ENDMENU { zconfprint("unexpected 'endmenu' statement"); } | ||
97 | | T_ENDIF { zconfprint("unexpected 'endif' statement"); } | ||
98 | | T_ENDCHOICE { zconfprint("unexpected 'endchoice' statement"); } | ||
99 | | error nl_or_eof { zconfprint("syntax error"); yyerrok; } | ||
100 | ; | ||
101 | |||
102 | common_block: | ||
103 | if_stmt | ||
104 | | comment_stmt | ||
105 | | config_stmt | ||
106 | | source_stmt | ||
107 | | nl_or_eof | ||
108 | ; | ||
109 | |||
110 | |||
111 | /* config entry */ | ||
112 | |||
113 | config_entry_start: T_CONFIG T_WORD | ||
114 | { | ||
115 | struct symbol *sym = sym_lookup($2, 0); | ||
116 | sym->flags |= SYMBOL_OPTIONAL; | ||
117 | menu_add_entry(sym); | ||
118 | printd(DEBUG_PARSE, "%s:%d:config %s\n", zconf_curname(), zconf_lineno(), $2); | ||
119 | }; | ||
120 | |||
121 | config_stmt: config_entry_start T_EOL config_option_list | ||
122 | { | ||
123 | menu_end_entry(); | ||
124 | printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); | ||
125 | }; | ||
126 | |||
127 | config_option_list: | ||
128 | /* empty */ | ||
129 | | config_option_list config_option T_EOL | ||
130 | | config_option_list depends T_EOL | ||
131 | | config_option_list help | ||
132 | | config_option_list T_EOL | ||
133 | { }; | ||
134 | |||
135 | config_option: T_TRISTATE prompt_stmt_opt | ||
136 | { | ||
137 | menu_set_type(S_TRISTATE); | ||
138 | printd(DEBUG_PARSE, "%s:%d:tristate\n", zconf_curname(), zconf_lineno()); | ||
139 | }; | ||
140 | |||
141 | config_option: T_BOOLEAN prompt_stmt_opt | ||
142 | { | ||
143 | menu_set_type(S_BOOLEAN); | ||
144 | printd(DEBUG_PARSE, "%s:%d:boolean\n", zconf_curname(), zconf_lineno()); | ||
145 | }; | ||
146 | |||
147 | config_option: T_INT prompt_stmt_opt | ||
148 | { | ||
149 | menu_set_type(S_INT); | ||
150 | printd(DEBUG_PARSE, "%s:%d:int\n", zconf_curname(), zconf_lineno()); | ||
151 | }; | ||
152 | |||
153 | config_option: T_HEX prompt_stmt_opt | ||
154 | { | ||
155 | menu_set_type(S_HEX); | ||
156 | printd(DEBUG_PARSE, "%s:%d:hex\n", zconf_curname(), zconf_lineno()); | ||
157 | }; | ||
158 | |||
159 | config_option: T_STRING prompt_stmt_opt | ||
160 | { | ||
161 | menu_set_type(S_STRING); | ||
162 | printd(DEBUG_PARSE, "%s:%d:string\n", zconf_curname(), zconf_lineno()); | ||
163 | }; | ||
164 | |||
165 | config_option: T_PROMPT prompt if_expr | ||
166 | { | ||
167 | menu_add_prop(P_PROMPT, $2, NULL, $3); | ||
168 | printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); | ||
169 | }; | ||
170 | |||
171 | config_option: T_DEFAULT symbol if_expr | ||
172 | { | ||
173 | menu_add_prop(P_DEFAULT, NULL, $2, $3); | ||
174 | printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno()); | ||
175 | }; | ||
176 | |||
177 | /* choice entry */ | ||
178 | |||
179 | choice: T_CHOICE | ||
180 | { | ||
181 | struct symbol *sym = sym_lookup(NULL, 0); | ||
182 | sym->flags |= SYMBOL_CHOICE; | ||
183 | menu_add_entry(sym); | ||
184 | menu_add_prop(P_CHOICE, NULL, NULL, NULL); | ||
185 | printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno()); | ||
186 | }; | ||
187 | |||
188 | choice_entry: choice T_EOL choice_option_list | ||
189 | { | ||
190 | menu_end_entry(); | ||
191 | menu_add_menu(); | ||
192 | }; | ||
193 | |||
194 | choice_end: end | ||
195 | { | ||
196 | if (zconf_endtoken($1, T_CHOICE, T_ENDCHOICE)) { | ||
197 | menu_end_menu(); | ||
198 | printd(DEBUG_PARSE, "%s:%d:endchoice\n", zconf_curname(), zconf_lineno()); | ||
199 | } | ||
200 | }; | ||
201 | |||
202 | choice_stmt: | ||
203 | choice_entry choice_block choice_end T_EOL | ||
204 | | choice_entry choice_block | ||
205 | { | ||
206 | printf("%s:%d: missing 'endchoice' for this 'choice' statement\n", current_menu->file->name, current_menu->lineno); | ||
207 | zconfnerrs++; | ||
208 | }; | ||
209 | |||
210 | choice_option_list: | ||
211 | /* empty */ | ||
212 | | choice_option_list choice_option T_EOL | ||
213 | | choice_option_list depends T_EOL | ||
214 | | choice_option_list help | ||
215 | | choice_option_list T_EOL | ||
216 | ; | ||
217 | |||
218 | choice_option: T_PROMPT prompt if_expr | ||
219 | { | ||
220 | menu_add_prop(P_PROMPT, $2, NULL, $3); | ||
221 | printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); | ||
222 | }; | ||
223 | |||
224 | choice_option: T_OPTIONAL | ||
225 | { | ||
226 | current_entry->sym->flags |= SYMBOL_OPTIONAL; | ||
227 | printd(DEBUG_PARSE, "%s:%d:optional\n", zconf_curname(), zconf_lineno()); | ||
228 | }; | ||
229 | |||
230 | choice_option: T_DEFAULT symbol | ||
231 | { | ||
232 | menu_add_prop(P_DEFAULT, NULL, $2, NULL); | ||
233 | //current_choice->prop->def = $2; | ||
234 | printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno()); | ||
235 | }; | ||
236 | |||
237 | choice_block: | ||
238 | /* empty */ | ||
239 | | choice_block common_block | ||
240 | ; | ||
241 | |||
242 | /* if entry */ | ||
243 | |||
244 | if: T_IF expr | ||
245 | { | ||
246 | printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno()); | ||
247 | menu_add_entry(NULL); | ||
248 | //current_entry->prompt = menu_add_prop(T_IF, NULL, NULL, $2); | ||
249 | menu_add_dep($2); | ||
250 | menu_end_entry(); | ||
251 | menu_add_menu(); | ||
252 | }; | ||
253 | |||
254 | if_end: end | ||
255 | { | ||
256 | if (zconf_endtoken($1, T_IF, T_ENDIF)) { | ||
257 | menu_end_menu(); | ||
258 | printd(DEBUG_PARSE, "%s:%d:endif\n", zconf_curname(), zconf_lineno()); | ||
259 | } | ||
260 | }; | ||
261 | |||
262 | if_stmt: | ||
263 | if T_EOL if_block if_end T_EOL | ||
264 | | if T_EOL if_block | ||
265 | { | ||
266 | printf("%s:%d: missing 'endif' for this 'if' statement\n", current_menu->file->name, current_menu->lineno); | ||
267 | zconfnerrs++; | ||
268 | }; | ||
269 | |||
270 | if_block: | ||
271 | /* empty */ | ||
272 | | if_block common_block | ||
273 | | if_block menu_stmt | ||
274 | | if_block choice_stmt | ||
275 | ; | ||
276 | |||
277 | /* menu entry */ | ||
278 | |||
279 | menu: T_MENU prompt | ||
280 | { | ||
281 | menu_add_entry(NULL); | ||
282 | menu_add_prop(P_MENU, $2, NULL, NULL); | ||
283 | printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno()); | ||
284 | }; | ||
285 | |||
286 | menu_entry: menu T_EOL depends_list | ||
287 | { | ||
288 | menu_end_entry(); | ||
289 | menu_add_menu(); | ||
290 | }; | ||
291 | |||
292 | menu_end: end | ||
293 | { | ||
294 | if (zconf_endtoken($1, T_MENU, T_ENDMENU)) { | ||
295 | menu_end_menu(); | ||
296 | printd(DEBUG_PARSE, "%s:%d:endmenu\n", zconf_curname(), zconf_lineno()); | ||
297 | } | ||
298 | }; | ||
299 | |||
300 | menu_stmt: | ||
301 | menu_entry menu_block menu_end T_EOL | ||
302 | | menu_entry menu_block | ||
303 | { | ||
304 | printf("%s:%d: missing 'endmenu' for this 'menu' statement\n", current_menu->file->name, current_menu->lineno); | ||
305 | zconfnerrs++; | ||
306 | }; | ||
307 | |||
308 | menu_block: | ||
309 | /* empty */ | ||
310 | | menu_block common_block | ||
311 | | menu_block menu_stmt | ||
312 | | menu_block choice_stmt | ||
313 | | menu_block error T_EOL { zconfprint("invalid menu option"); yyerrok; } | ||
314 | ; | ||
315 | |||
316 | source: T_SOURCE prompt | ||
317 | { | ||
318 | $$ = $2; | ||
319 | printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), $2); | ||
320 | }; | ||
321 | |||
322 | source_stmt: source T_EOL | ||
323 | { | ||
324 | zconf_nextfile($1); | ||
325 | }; | ||
326 | |||
327 | /* comment entry */ | ||
328 | |||
329 | comment: T_COMMENT prompt | ||
330 | { | ||
331 | menu_add_entry(NULL); | ||
332 | menu_add_prop(P_COMMENT, $2, NULL, NULL); | ||
333 | printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno()); | ||
334 | }; | ||
335 | |||
336 | comment_stmt: comment T_EOL depends_list | ||
337 | { | ||
338 | menu_end_entry(); | ||
339 | }; | ||
340 | |||
341 | /* help option */ | ||
342 | |||
343 | help_start: T_HELP T_EOL | ||
344 | { | ||
345 | printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno()); | ||
346 | zconf_starthelp(); | ||
347 | }; | ||
348 | |||
349 | help: help_start T_HELPTEXT | ||
350 | { | ||
351 | current_entry->sym->help = $2; | ||
352 | }; | ||
353 | |||
354 | /* depends option */ | ||
355 | |||
356 | depends_list: /* empty */ | ||
357 | | depends_list depends T_EOL | ||
358 | | depends_list T_EOL | ||
359 | { }; | ||
360 | |||
361 | depends: T_DEPENDS T_ON expr | ||
362 | { | ||
363 | menu_add_dep($3); | ||
364 | printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno()); | ||
365 | } | ||
366 | | T_DEPENDS expr | ||
367 | { | ||
368 | menu_add_dep($2); | ||
369 | printd(DEBUG_PARSE, "%s:%d:depends\n", zconf_curname(), zconf_lineno()); | ||
370 | } | ||
371 | | T_REQUIRES expr | ||
372 | { | ||
373 | menu_add_dep($2); | ||
374 | printd(DEBUG_PARSE, "%s:%d:requires\n", zconf_curname(), zconf_lineno()); | ||
375 | }; | ||
376 | |||
377 | /* prompt statement */ | ||
378 | |||
379 | prompt_stmt_opt: | ||
380 | /* empty */ | ||
381 | | prompt | ||
382 | { | ||
383 | menu_add_prop(P_PROMPT, $1, NULL, NULL); | ||
384 | } | ||
385 | | prompt T_IF expr | ||
386 | { | ||
387 | menu_add_prop(P_PROMPT, $1, NULL, $3); | ||
388 | }; | ||
389 | |||
390 | prompt: T_WORD | ||
391 | | T_STRING | ||
392 | ; | ||
393 | |||
394 | end: T_ENDMENU { $$ = T_ENDMENU; } | ||
395 | | T_ENDCHOICE { $$ = T_ENDCHOICE; } | ||
396 | | T_ENDIF { $$ = T_ENDIF; } | ||
397 | ; | ||
398 | |||
399 | nl_or_eof: | ||
400 | T_EOL | T_EOF; | ||
401 | |||
402 | if_expr: /* empty */ { $$ = NULL; } | ||
403 | | T_IF expr { $$ = $2; } | ||
404 | ; | ||
405 | |||
406 | expr: symbol { $$ = expr_alloc_symbol($1); } | ||
407 | | symbol T_EQUAL symbol { $$ = expr_alloc_comp(E_EQUAL, $1, $3); } | ||
408 | | symbol T_UNEQUAL symbol { $$ = expr_alloc_comp(E_UNEQUAL, $1, $3); } | ||
409 | | T_OPEN_PAREN expr T_CLOSE_PAREN { $$ = $2; } | ||
410 | | T_NOT expr { $$ = expr_alloc_one(E_NOT, $2); } | ||
411 | | expr T_OR expr { $$ = expr_alloc_two(E_OR, $1, $3); } | ||
412 | | expr T_AND expr { $$ = expr_alloc_two(E_AND, $1, $3); } | ||
413 | ; | ||
414 | |||
415 | symbol: T_WORD { $$ = sym_lookup($1, 0); free($1); } | ||
416 | | T_STRING { $$ = sym_lookup($1, 1); free($1); } | ||
417 | ; | ||
418 | |||
419 | %% | ||
420 | |||
421 | void conf_parse(const char *name) | ||
422 | { | ||
423 | zconf_initscan(name); | ||
424 | |||
425 | sym_init(); | ||
426 | menu_init(); | ||
427 | rootmenu.prompt = menu_add_prop(P_MENU, "BusyBox Configuration", NULL, NULL); | ||
428 | |||
429 | //zconfdebug = 1; | ||
430 | zconfparse(); | ||
431 | if (zconfnerrs) | ||
432 | exit(1); | ||
433 | menu_finalize(&rootmenu); | ||
434 | |||
435 | modules_sym = sym_lookup("MODULES", 0); | ||
436 | |||
437 | sym_change_count = 1; | ||
438 | } | ||
439 | |||
440 | const char *zconf_tokenname(int token) | ||
441 | { | ||
442 | switch (token) { | ||
443 | case T_MENU: return "menu"; | ||
444 | case T_ENDMENU: return "endmenu"; | ||
445 | case T_CHOICE: return "choice"; | ||
446 | case T_ENDCHOICE: return "endchoice"; | ||
447 | case T_IF: return "if"; | ||
448 | case T_ENDIF: return "endif"; | ||
449 | } | ||
450 | return "<token>"; | ||
451 | } | ||
452 | |||
453 | static bool zconf_endtoken(int token, int starttoken, int endtoken) | ||
454 | { | ||
455 | if (token != endtoken) { | ||
456 | zconfprint("unexpected '%s' within %s block", zconf_tokenname(token), zconf_tokenname(starttoken)); | ||
457 | zconfnerrs++; | ||
458 | return false; | ||
459 | } | ||
460 | if (current_menu->file != current_file) { | ||
461 | zconfprint("'%s' in different file than '%s'", zconf_tokenname(token), zconf_tokenname(starttoken)); | ||
462 | zconfprint("location of the '%s'", zconf_tokenname(starttoken)); | ||
463 | zconfnerrs++; | ||
464 | return false; | ||
465 | } | ||
466 | return true; | ||
467 | } | ||
468 | |||
469 | static void zconfprint(const char *err, ...) | ||
470 | { | ||
471 | va_list ap; | ||
472 | |||
473 | fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno()); | ||
474 | va_start(ap, err); | ||
475 | vfprintf(stderr, err, ap); | ||
476 | va_end(ap); | ||
477 | fprintf(stderr, "\n"); | ||
478 | } | ||
479 | |||
480 | static void zconferror(const char *err) | ||
481 | { | ||
482 | fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno(), err); | ||
483 | } | ||
484 | |||
485 | void print_quoted_string(FILE *out, const char *str) | ||
486 | { | ||
487 | const char *p; | ||
488 | int len; | ||
489 | |||
490 | putc('"', out); | ||
491 | while ((p = strchr(str, '"'))) { | ||
492 | len = p - str; | ||
493 | if (len) | ||
494 | fprintf(out, "%.*s", len, str); | ||
495 | fputs("\\\"", out); | ||
496 | str = p + 1; | ||
497 | } | ||
498 | fputs(str, out); | ||
499 | putc('"', out); | ||
500 | } | ||
501 | |||
502 | void print_symbol(FILE *out, struct menu *menu) | ||
503 | { | ||
504 | struct symbol *sym = menu->sym; | ||
505 | struct property *prop; | ||
506 | |||
507 | //sym->flags |= SYMBOL_PRINTED; | ||
508 | |||
509 | if (sym_is_choice(sym)) | ||
510 | fprintf(out, "choice\n"); | ||
511 | else | ||
512 | fprintf(out, "config %s\n", sym->name); | ||
513 | switch (sym->type) { | ||
514 | case S_BOOLEAN: | ||
515 | fputs(" boolean\n", out); | ||
516 | break; | ||
517 | case S_TRISTATE: | ||
518 | fputs(" tristate\n", out); | ||
519 | break; | ||
520 | case S_STRING: | ||
521 | fputs(" string\n", out); | ||
522 | break; | ||
523 | case S_INT: | ||
524 | fputs(" integer\n", out); | ||
525 | break; | ||
526 | case S_HEX: | ||
527 | fputs(" hex\n", out); | ||
528 | break; | ||
529 | default: | ||
530 | fputs(" ???\n", out); | ||
531 | break; | ||
532 | } | ||
533 | #if 0 | ||
534 | if (!expr_is_yes(sym->dep)) { | ||
535 | fputs(" depends ", out); | ||
536 | expr_fprint(sym->dep, out); | ||
537 | fputc('\n', out); | ||
538 | } | ||
539 | #endif | ||
540 | for (prop = sym->prop; prop; prop = prop->next) { | ||
541 | if (prop->menu != menu) | ||
542 | continue; | ||
543 | switch (prop->type) { | ||
544 | case P_PROMPT: | ||
545 | fputs(" prompt ", out); | ||
546 | print_quoted_string(out, prop->text); | ||
547 | if (prop->def) { | ||
548 | fputc(' ', out); | ||
549 | if (prop->def->flags & SYMBOL_CONST) | ||
550 | print_quoted_string(out, prop->def->name); | ||
551 | else | ||
552 | fputs(prop->def->name, out); | ||
553 | } | ||
554 | if (!expr_is_yes(E_EXPR(prop->visible))) { | ||
555 | fputs(" if ", out); | ||
556 | expr_fprint(E_EXPR(prop->visible), out); | ||
557 | } | ||
558 | fputc('\n', out); | ||
559 | break; | ||
560 | case P_DEFAULT: | ||
561 | fputs( " default ", out); | ||
562 | print_quoted_string(out, prop->def->name); | ||
563 | if (!expr_is_yes(E_EXPR(prop->visible))) { | ||
564 | fputs(" if ", out); | ||
565 | expr_fprint(E_EXPR(prop->visible), out); | ||
566 | } | ||
567 | fputc('\n', out); | ||
568 | break; | ||
569 | case P_CHOICE: | ||
570 | fputs(" #choice value\n", out); | ||
571 | break; | ||
572 | default: | ||
573 | fprintf(out, " unknown prop %d!\n", prop->type); | ||
574 | break; | ||
575 | } | ||
576 | } | ||
577 | if (sym->help) { | ||
578 | int len = strlen(sym->help); | ||
579 | while (sym->help[--len] == '\n') | ||
580 | sym->help[len] = 0; | ||
581 | fprintf(out, " help\n%s\n", sym->help); | ||
582 | } | ||
583 | fputc('\n', out); | ||
584 | } | ||
585 | |||
586 | void zconfdump(FILE *out) | ||
587 | { | ||
588 | //struct file *file; | ||
589 | struct property *prop; | ||
590 | struct symbol *sym; | ||
591 | struct menu *menu; | ||
592 | |||
593 | menu = rootmenu.list; | ||
594 | while (menu) { | ||
595 | if ((sym = menu->sym)) | ||
596 | print_symbol(out, menu); | ||
597 | else if ((prop = menu->prompt)) { | ||
598 | switch (prop->type) { | ||
599 | //case T_MAINMENU: | ||
600 | // fputs("\nmainmenu ", out); | ||
601 | // print_quoted_string(out, prop->text); | ||
602 | // fputs("\n", out); | ||
603 | // break; | ||
604 | case P_COMMENT: | ||
605 | fputs("\ncomment ", out); | ||
606 | print_quoted_string(out, prop->text); | ||
607 | fputs("\n", out); | ||
608 | break; | ||
609 | case P_MENU: | ||
610 | fputs("\nmenu ", out); | ||
611 | print_quoted_string(out, prop->text); | ||
612 | fputs("\n", out); | ||
613 | break; | ||
614 | //case T_SOURCE: | ||
615 | // fputs("\nsource ", out); | ||
616 | // print_quoted_string(out, prop->text); | ||
617 | // fputs("\n", out); | ||
618 | // break; | ||
619 | //case T_IF: | ||
620 | // fputs("\nif\n", out); | ||
621 | default: | ||
622 | ; | ||
623 | } | ||
624 | if (!expr_is_yes(E_EXPR(prop->visible))) { | ||
625 | fputs(" depends ", out); | ||
626 | expr_fprint(E_EXPR(prop->visible), out); | ||
627 | fputc('\n', out); | ||
628 | } | ||
629 | fputs("\n", out); | ||
630 | } | ||
631 | |||
632 | if (menu->list) | ||
633 | menu = menu->list; | ||
634 | else if (menu->next) | ||
635 | menu = menu->next; | ||
636 | else while ((menu = menu->parent)) { | ||
637 | if (menu->prompt && menu->prompt->type == P_MENU) | ||
638 | fputs("\nendmenu\n", out); | ||
639 | if (menu->next) { | ||
640 | menu = menu->next; | ||
641 | break; | ||
642 | } | ||
643 | } | ||
644 | } | ||
645 | } | ||
646 | |||
647 | #include "lex.zconf.c" | ||
648 | #include "confdata.c" | ||
649 | #include "expr.c" | ||
650 | #include "symbol.c" | ||
651 | #include "menu.c" | ||