Browse Source

Project import

master
Rafal Kupiec 10 months ago
parent
commit
443ae08c05
Signed by: belliash <belliash@codingworkshop.eu.org> GPG Key ID: 4E829243E0CFE6B4
63 changed files with 23293 additions and 0 deletions
  1. 8
    0
      BSDmakefile
  2. 14
    0
      CHANGELOG
  3. 339
    0
      COPYING
  4. 38
    0
      Makefile
  5. 34
    0
      config/boards.in
  6. 290
    0
      config/config.in
  7. 29
    0
      config/kconfig/Makefile
  8. 2
    0
      config/kconfig/README
  9. 701
    0
      config/kconfig/conf.c
  10. 1164
    0
      config/kconfig/confdata.c
  11. 1168
    0
      config/kconfig/expr.c
  12. 235
    0
      config/kconfig/expr.h
  13. 91
    0
      config/kconfig/list.h
  14. 190
    0
      config/kconfig/lkc.h
  15. 56
    0
      config/kconfig/lkc_proto.h
  16. 332
    0
      config/kconfig/lxdialog/checklist.c
  17. 234
    0
      config/kconfig/lxdialog/dialog.h
  18. 238
    0
      config/kconfig/lxdialog/inputbox.c
  19. 434
    0
      config/kconfig/lxdialog/menubox.c
  20. 408
    0
      config/kconfig/lxdialog/textbox.c
  21. 664
    0
      config/kconfig/lxdialog/util.c
  22. 114
    0
      config/kconfig/lxdialog/yesno.c
  23. 951
    0
      config/kconfig/mconf.c
  24. 644
    0
      config/kconfig/menu.c
  25. 1550
    0
      config/kconfig/nconf.c
  26. 654
    0
      config/kconfig/nconf.gui.c
  27. 96
    0
      config/kconfig/nconf.h
  28. 1310
    0
      config/kconfig/symbol.c
  29. 140
    0
      config/kconfig/util.c
  30. 47
    0
      config/kconfig/zconf.gperf
  31. 286
    0
      config/kconfig/zconf.hash.c_shipped
  32. 364
    0
      config/kconfig/zconf.l
  33. 2420
    0
      config/kconfig/zconf.lex.c_shipped
  34. 2504
    0
      config/kconfig/zconf.tab.c_shipped
  35. 740
    0
      config/kconfig/zconf.y
  36. 9
    0
      packages/base-files/files/etc/banner
  37. 6
    0
      packages/base-files/files/etc/version
  38. 40
    0
      packages/kagera/cbsi/Makefile
  39. 41
    0
      packages/kagera/kuhttpd/Makefile
  40. 43
    0
      packages/kagera/sessmgr/Makefile
  41. 60
    0
      packages/kagera/webget/Makefile
  42. 90
    0
      packages/kagera/webui/Makefile
  43. 23
    0
      patches/101-make_the_usage_from_kagera_tools.patch
  44. 11
    0
      patches/102-set_kernel_default_vermagic.patch
  45. 10
    0
      patches/301-replace_the_regulatory_domain_rules.patch
  46. 8
    0
      patches/501-set_default_root_password.patch
  47. 10
    0
      patches/502-dont_create_www_directory.patch
  48. 8
    0
      patches/503-add_kagera_repo_url_in_opkg_conf.patch
  49. 9
    0
      patches/504-set_kagera_hostname_and_dns.patch
  50. 11
    0
      patches/505-run_kagera_services_during_sysupgrade.patch
  51. 11
    0
      patches/PATCHES
  52. 37
    0
      rules/config.mk
  53. 18
    0
      rules/help.mk
  54. 49
    0
      rules/kagera.mk
  55. 149
    0
      rules/openwrt.mk
  56. 26
    0
      rules/rules.mk
  57. 17
    0
      rules/version.mk
  58. 3636
    0
      targets/ar71xx/profiles/routerstation/config
  59. 2
    0
      targets/ar71xx/profiles/routerstation/images
  60. 30
    0
      tools/node/Makefile
  61. 22
    0
      tools/reghack/Makefile
  62. 397
    0
      tools/reghack/src/reghack.c
  63. 31
    0
      tools/uglifyjs/Makefile

+ 8
- 0
BSDmakefile View File

@@ -0,0 +1,8 @@
1
+# 
2
+# Copyright (C) 2013, Asio Software Technologies
3
+#
4
+# This is free software, licensed under the GNU General Public License v2.
5
+# See /COPYING for more information.
6
+#
7
+world ${.TARGETS}:
8
+	@gmake $@

+ 14
- 0
CHANGELOG View File

@@ -0,0 +1,14 @@
1
+2013.2 (Pre-Alpha):
2
+ * 
3
+
4
+2013.1 (Pre-Alpha):
5
+ * Added 'Reboot' button
6
+ * Added 'Run Custom Commands' module
7
+ * Added extended 'System Logs' module
8
+ * Ajaxified Web Interface
9
+ * Fixed compatibility with some web browsers
10
+ * Fixed multilanguage support
11
+ * Improvements in authentication system
12
+
13
+2013.0 (Pre-Alpha):
14
+ * Initial, test release

+ 339
- 0
COPYING View File

@@ -0,0 +1,339 @@
1
+                    GNU GENERAL PUBLIC LICENSE
2
+                       Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+                            Preamble
10
+
11
+  The licenses for most software are designed to take away your
12
+freedom to share and change it.  By contrast, the GNU General Public
13
+License is intended to guarantee your freedom to share and change free
14
+software--to make sure the software is free for all its users.  This
15
+General Public License applies to most of the Free Software
16
+Foundation's software and to any other program whose authors commit to
17
+using it.  (Some other Free Software Foundation software is covered by
18
+the GNU Lesser General Public License instead.)  You can apply it to
19
+your programs, too.
20
+
21
+  When we speak of free software, we are referring to freedom, not
22
+price.  Our General Public Licenses are designed to make sure that you
23
+have the freedom to distribute copies of free software (and charge for
24
+this service if you wish), that you receive source code or can get it
25
+if you want it, that you can change the software or use pieces of it
26
+in new free programs; and that you know you can do these things.
27
+
28
+  To protect your rights, we need to make restrictions that forbid
29
+anyone to deny you these rights or to ask you to surrender the rights.
30
+These restrictions translate to certain responsibilities for you if you
31
+distribute copies of the software, or if you modify it.
32
+
33
+  For example, if you distribute copies of such a program, whether
34
+gratis or for a fee, you must give the recipients all the rights that
35
+you have.  You must make sure that they, too, receive or can get the
36
+source code.  And you must show them these terms so they know their
37
+rights.
38
+
39
+  We protect your rights with two steps: (1) copyright the software, and
40
+(2) offer you this license which gives you legal permission to copy,
41
+distribute and/or modify the software.
42
+
43
+  Also, for each author's protection and ours, we want to make certain
44
+that everyone understands that there is no warranty for this free
45
+software.  If the software is modified by someone else and passed on, we
46
+want its recipients to know that what they have is not the original, so
47
+that any problems introduced by others will not reflect on the original
48
+authors' reputations.
49
+
50
+  Finally, any free program is threatened constantly by software
51
+patents.  We wish to avoid the danger that redistributors of a free
52
+program will individually obtain patent licenses, in effect making the
53
+program proprietary.  To prevent this, we have made it clear that any
54
+patent must be licensed for everyone's free use or not licensed at all.
55
+
56
+  The precise terms and conditions for copying, distribution and
57
+modification follow.
58
+
59
+                    GNU GENERAL PUBLIC LICENSE
60
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
+
62
+  0. This License applies to any program or other work which contains
63
+a notice placed by the copyright holder saying it may be distributed
64
+under the terms of this General Public License.  The "Program", below,
65
+refers to any such program or work, and a "work based on the Program"
66
+means either the Program or any derivative work under copyright law:
67
+that is to say, a work containing the Program or a portion of it,
68
+either verbatim or with modifications and/or translated into another
69
+language.  (Hereinafter, translation is included without limitation in
70
+the term "modification".)  Each licensee is addressed as "you".
71
+
72
+Activities other than copying, distribution and modification are not
73
+covered by this License; they are outside its scope.  The act of
74
+running the Program is not restricted, and the output from the Program
75
+is covered only if its contents constitute a work based on the
76
+Program (independent of having been made by running the Program).
77
+Whether that is true depends on what the Program does.
78
+
79
+  1. You may copy and distribute verbatim copies of the Program's
80
+source code as you receive it, in any medium, provided that you
81
+conspicuously and appropriately publish on each copy an appropriate
82
+copyright notice and disclaimer of warranty; keep intact all the
83
+notices that refer to this License and to the absence of any warranty;
84
+and give any other recipients of the Program a copy of this License
85
+along with the Program.
86
+
87
+You may charge a fee for the physical act of transferring a copy, and
88
+you may at your option offer warranty protection in exchange for a fee.
89
+
90
+  2. You may modify your copy or copies of the Program or any portion
91
+of it, thus forming a work based on the Program, and copy and
92
+distribute such modifications or work under the terms of Section 1
93
+above, provided that you also meet all of these conditions:
94
+
95
+    a) You must cause the modified files to carry prominent notices
96
+    stating that you changed the files and the date of any change.
97
+
98
+    b) You must cause any work that you distribute or publish, that in
99
+    whole or in part contains or is derived from the Program or any
100
+    part thereof, to be licensed as a whole at no charge to all third
101
+    parties under the terms of this License.
102
+
103
+    c) If the modified program normally reads commands interactively
104
+    when run, you must cause it, when started running for such
105
+    interactive use in the most ordinary way, to print or display an
106
+    announcement including an appropriate copyright notice and a
107
+    notice that there is no warranty (or else, saying that you provide
108
+    a warranty) and that users may redistribute the program under
109
+    these conditions, and telling the user how to view a copy of this
110
+    License.  (Exception: if the Program itself is interactive but
111
+    does not normally print such an announcement, your work based on
112
+    the Program is not required to print an announcement.)
113
+
114
+These requirements apply to the modified work as a whole.  If
115
+identifiable sections of that work are not derived from the Program,
116
+and can be reasonably considered independent and separate works in
117
+themselves, then this License, and its terms, do not apply to those
118
+sections when you distribute them as separate works.  But when you
119
+distribute the same sections as part of a whole which is a work based
120
+on the Program, the distribution of the whole must be on the terms of
121
+this License, whose permissions for other licensees extend to the
122
+entire whole, and thus to each and every part regardless of who wrote it.
123
+
124
+Thus, it is not the intent of this section to claim rights or contest
125
+your rights to work written entirely by you; rather, the intent is to
126
+exercise the right to control the distribution of derivative or
127
+collective works based on the Program.
128
+
129
+In addition, mere aggregation of another work not based on the Program
130
+with the Program (or with a work based on the Program) on a volume of
131
+a storage or distribution medium does not bring the other work under
132
+the scope of this License.
133
+
134
+  3. You may copy and distribute the Program (or a work based on it,
135
+under Section 2) in object code or executable form under the terms of
136
+Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+    a) Accompany it with the complete corresponding machine-readable
139
+    source code, which must be distributed under the terms of Sections
140
+    1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+    b) Accompany it with a written offer, valid for at least three
143
+    years, to give any third party, for a charge no more than your
144
+    cost of physically performing source distribution, a complete
145
+    machine-readable copy of the corresponding source code, to be
146
+    distributed under the terms of Sections 1 and 2 above on a medium
147
+    customarily used for software interchange; or,
148
+
149
+    c) Accompany it with the information you received as to the offer
150
+    to distribute corresponding source code.  (This alternative is
151
+    allowed only for noncommercial distribution and only if you
152
+    received the program in object code or executable form with such
153
+    an offer, in accord with Subsection b above.)
154
+
155
+The source code for a work means the preferred form of the work for
156
+making modifications to it.  For an executable work, complete source
157
+code means all the source code for all modules it contains, plus any
158
+associated interface definition files, plus the scripts used to
159
+control compilation and installation of the executable.  However, as a
160
+special exception, the source code distributed need not include
161
+anything that is normally distributed (in either source or binary
162
+form) with the major components (compiler, kernel, and so on) of the
163
+operating system on which the executable runs, unless that component
164
+itself accompanies the executable.
165
+
166
+If distribution of executable or object code is made by offering
167
+access to copy from a designated place, then offering equivalent
168
+access to copy the source code from the same place counts as
169
+distribution of the source code, even though third parties are not
170
+compelled to copy the source along with the object code.
171
+
172
+  4. You may not copy, modify, sublicense, or distribute the Program
173
+except as expressly provided under this License.  Any attempt
174
+otherwise to copy, modify, sublicense or distribute the Program is
175
+void, and will automatically terminate your rights under this License.
176
+However, parties who have received copies, or rights, from you under
177
+this License will not have their licenses terminated so long as such
178
+parties remain in full compliance.
179
+
180
+  5. You are not required to accept this License, since you have not
181
+signed it.  However, nothing else grants you permission to modify or
182
+distribute the Program or its derivative works.  These actions are
183
+prohibited by law if you do not accept this License.  Therefore, by
184
+modifying or distributing the Program (or any work based on the
185
+Program), you indicate your acceptance of this License to do so, and
186
+all its terms and conditions for copying, distributing or modifying
187
+the Program or works based on it.
188
+
189
+  6. Each time you redistribute the Program (or any work based on the
190
+Program), the recipient automatically receives a license from the
191
+original licensor to copy, distribute or modify the Program subject to
192
+these terms and conditions.  You may not impose any further
193
+restrictions on the recipients' exercise of the rights granted herein.
194
+You are not responsible for enforcing compliance by third parties to
195
+this License.
196
+
197
+  7. If, as a consequence of a court judgment or allegation of patent
198
+infringement or for any other reason (not limited to patent issues),
199
+conditions are imposed on you (whether by court order, agreement or
200
+otherwise) that contradict the conditions of this License, they do not
201
+excuse you from the conditions of this License.  If you cannot
202
+distribute so as to satisfy simultaneously your obligations under this
203
+License and any other pertinent obligations, then as a consequence you
204
+may not distribute the Program at all.  For example, if a patent
205
+license would not permit royalty-free redistribution of the Program by
206
+all those who receive copies directly or indirectly through you, then
207
+the only way you could satisfy both it and this License would be to
208
+refrain entirely from distribution of the Program.
209
+
210
+If any portion of this section is held invalid or unenforceable under
211
+any particular circumstance, the balance of the section is intended to
212
+apply and the section as a whole is intended to apply in other
213
+circumstances.
214
+
215
+It is not the purpose of this section to induce you to infringe any
216
+patents or other property right claims or to contest validity of any
217
+such claims; this section has the sole purpose of protecting the
218
+integrity of the free software distribution system, which is
219
+implemented by public license practices.  Many people have made
220
+generous contributions to the wide range of software distributed
221
+through that system in reliance on consistent application of that
222
+system; it is up to the author/donor to decide if he or she is willing
223
+to distribute software through any other system and a licensee cannot
224
+impose that choice.
225
+
226
+This section is intended to make thoroughly clear what is believed to
227
+be a consequence of the rest of this License.
228
+
229
+  8. If the distribution and/or use of the Program is restricted in
230
+certain countries either by patents or by copyrighted interfaces, the
231
+original copyright holder who places the Program under this License
232
+may add an explicit geographical distribution limitation excluding
233
+those countries, so that distribution is permitted only in or among
234
+countries not thus excluded.  In such case, this License incorporates
235
+the limitation as if written in the body of this License.
236
+
237
+  9. The Free Software Foundation may publish revised and/or new versions
238
+of the General Public License from time to time.  Such new versions will
239
+be similar in spirit to the present version, but may differ in detail to
240
+address new problems or concerns.
241
+
242
+Each version is given a distinguishing version number.  If the Program
243
+specifies a version number of this License which applies to it and "any
244
+later version", you have the option of following the terms and conditions
245
+either of that version or of any later version published by the Free
246
+Software Foundation.  If the Program does not specify a version number of
247
+this License, you may choose any version ever published by the Free Software
248
+Foundation.
249
+
250
+  10. If you wish to incorporate parts of the Program into other free
251
+programs whose distribution conditions are different, write to the author
252
+to ask for permission.  For software which is copyrighted by the Free
253
+Software Foundation, write to the Free Software Foundation; we sometimes
254
+make exceptions for this.  Our decision will be guided by the two goals
255
+of preserving the free status of all derivatives of our free software and
256
+of promoting the sharing and reuse of software generally.
257
+
258
+                            NO WARRANTY
259
+
260
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
262
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
266
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
267
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+REPAIR OR CORRECTION.
269
+
270
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+POSSIBILITY OF SUCH DAMAGES.
279
+
280
+                     END OF TERMS AND CONDITIONS
281
+
282
+            How to Apply These Terms to Your New Programs
283
+
284
+  If you develop a new program, and you want it to be of the greatest
285
+possible use to the public, the best way to achieve this is to make it
286
+free software which everyone can redistribute and change under these terms.
287
+
288
+  To do so, attach the following notices to the program.  It is safest
289
+to attach them to the start of each source file to most effectively
290
+convey the exclusion of warranty; and each file should have at least
291
+the "copyright" line and a pointer to where the full notice is found.
292
+
293
+    <one line to give the program's name and a brief idea of what it does.>
294
+    Copyright (C) <year>  <name of author>
295
+
296
+    This program is free software; you can redistribute it and/or modify
297
+    it under the terms of the GNU General Public License as published by
298
+    the Free Software Foundation; either version 2 of the License, or
299
+    (at your option) any later version.
300
+
301
+    This program is distributed in the hope that it will be useful,
302
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
303
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
304
+    GNU General Public License for more details.
305
+
306
+    You should have received a copy of the GNU General Public License along
307
+    with this program; if not, write to the Free Software Foundation, Inc.,
308
+    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309
+
310
+Also add information on how to contact you by electronic and paper mail.
311
+
312
+If the program is interactive, make it output a short notice like this
313
+when it starts in an interactive mode:
314
+
315
+    Gnomovision version 69, Copyright (C) year name of author
316
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317
+    This is free software, and you are welcome to redistribute it
318
+    under certain conditions; type `show c' for details.
319
+
320
+The hypothetical commands `show w' and `show c' should show the appropriate
321
+parts of the General Public License.  Of course, the commands you use may
322
+be called something other than `show w' and `show c'; they could even be
323
+mouse-clicks or menu items--whatever suits your program.
324
+
325
+You should also get your employer (if you work as a programmer) or your
326
+school, if any, to sign a "copyright disclaimer" for the program, if
327
+necessary.  Here is a sample; alter the names:
328
+
329
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
331
+
332
+  <signature of Ty Coon>, 1 April 1989
333
+  Ty Coon, President of Vice
334
+
335
+This General Public License does not permit incorporating your program into
336
+proprietary programs.  If your program is a subroutine library, you may
337
+consider it more useful to permit linking proprietary applications with the
338
+library.  If this is what you want to do, use the GNU Lesser General
339
+Public License instead of this License.

+ 38
- 0
Makefile View File

@@ -0,0 +1,38 @@
1
+#
2
+# Copyright(C) 2010-2013, Asio Software Technologies
3
+#
4
+# This is free software, licensed under the GNU General Public License v2.
5
+# See COPYING in the top level directory for more information.
6
+#
7
+
8
+VERSION:=2013
9
+RELEASE:=1
10
+PATCHLEVEL:=
11
+CODENAME:=Evans Peek
12
+
13
+FORCE:=clean distclean mrproper world
14
+LANG:=C
15
+LC_ALL:=C
16
+TOPDIR:=${CURDIR}
17
+
18
+
19
+all: world
20
+
21
+include rules/config.mk
22
+include rules/help.mk
23
+include rules/kagera.mk
24
+include rules/openwrt.mk
25
+include rules/rules.mk
26
+include rules/version.mk
27
+
28
+clean: config/clean
29
+
30
+distclean: clean
31
+	@rm -rf $(TOPDIR)/binaries $(TOPDIR)/temp
32
+	@rm -f $(TOPDIR)/.config $(TOPDIR)/.config.old
33
+
34
+mrproper: distclean
35
+
36
+world: .config kagera/build
37
+
38
+.PHONY: $(FORCE)

+ 34
- 0
config/boards.in View File

@@ -0,0 +1,34 @@
1
+choice
2
+	prompt "Target architecture"
3
+	default TARGET_ARCH_AR71XX
4
+	help
5
+		This is an extensive list of supported platforms, with the numerous target
6
+		profiles – ranging from specific devices to generic profiles, all depending
7
+		on the particular device at hand.
8
+	config TARGET_ARCH_AR71XX
9
+		bool "AR7xxx/AR9xxx"
10
+		help
11
+			Builds firmware images for Atheros AR7xxx/AR9xxx based boards.
12
+endchoice
13
+
14
+choice
15
+	prompt "Target board type"
16
+	default TARGET_BOARD_AR71XX_UBNTRSPRO if TARGET_ARCH_AR71XX
17
+	help
18
+		This is an extensive list of supported boards and routers, with the numerous
19
+		target profiles - ranging from specific devices to generic profiles, all
20
+		depending on the particular device at hand.
21
+	config TARGET_BOARD_AR71XX_UBNTRSPRO
22
+		bool "Ubiquiti RouterStation (Pro)"
23
+		depends on TARGET_ARCH_AR71XX && EXPERIMENTAL
24
+		help
25
+			Package set optimized for the Ubiquiti RouterStation and RouterStation Pro.
26
+endchoice
27
+
28
+config TARGET_ARCH
29
+	string
30
+	default "ar71xx" if TARGET_ARCH_AR71XX
31
+
32
+config TARGET_BOARD
33
+	string
34
+	default "routerstation" if TARGET_BOARD_AR71XX_UBNTRSPRO

+ 290
- 0
config/config.in View File

@@ -0,0 +1,290 @@
1
+mainmenu "Kagera Firmware $KAGERA_VERSION Configuration"
2
+
3
+config HAVE_DOT_CONFIG
4
+	bool
5
+	default y
6
+
7
+config KAGERA_VERSION
8
+	string
9
+	option env="KVER"
10
+
11
+source config/boards.in
12
+
13
+menu "General setup"
14
+	config EXPERIMENTAL
15
+		bool "Prompt for development and/or testing options"
16
+		default n
17
+		help
18
+			Some of the various things that Kagera supports (such as special build options,
19
+			architectures, boards, etc.) can be in a state of development or testing, where
20
+			the functionality, stability, or level of support is not yet high enough for
21
+			general use. This is usually known as "alpha-test" phase among developers. If
22
+			a feature is currently in alpha-test, then the developers usually discourage
23
+			uninformed widespread use of this feature by the general public to avoid "Why
24
+			doesn't this work?" type messages. However, active testing and use of these
25
+			systems is welcomed. Just be aware that it may not meet the normal level of
26
+			reliability or it may fail to work in some special cases, even bricking device.
27
+			Detailed bug reports from people familiar with the routers internals are
28
+			usually welcomed by the developers.
29
+
30
+	config KAGERA_APPLY_PATCHES
31
+		bool "Apply Kagera patches on top of OpenWrt"
32
+		default y
33
+		help
34
+			A patch is a piece of software designed to fix problems with, or update
35
+			a computer program or its supporting data. This includes fixing security
36
+			vulnerabilities and other bugs, and improving the usability or performance.
37
+			Enable this option to apply patches on top of OpenWrt. Wihout this, Kagera
38
+			might not work properly.
39
+
40
+	config KAGERA_DISABLE_ARCH_PATCHES
41
+		bool "Do NOT apply ARCH-specific patches"
42
+		depends on KAGERA_APPLY_PATCHES && EXPERIMENTAL
43
+		default n
44
+		help
45
+			This option disables architecture-specific patches for Kagera.
46
+	
47
+	config KAGERA_OPEN_OPENWRT_CONFIG
48
+		bool "Launch OpenWrt configuration before compilation"
49
+		default n
50
+		help
51
+			This option invokes a convenient menu-driven user-interface, that allows the user
52
+			to choose the features of the OpenWrt (and other options) that will be compiled.
53
+			It is normally launched using the 'make openwrt_menuconfig' command.
54
+
55
+	config KAGERA_OPEN_KERNEL_CONFIG
56
+		bool "Launch Kernel configuration before compilation"
57
+		default n
58
+		help
59
+			This option invokes a convenient menu-driven user-interface, that allows the user
60
+			to choose the features of the Linux Kernel (and other options) that will be
61
+			compiled. It is normally launched using the 'make kernel_menuconfig' command.
62
+
63
+	config KAGERA_BUILD_JOBS
64
+		string "Number of package submake jobs (1-512)"
65
+		depends on EXPERIMENTAL
66
+		default 1
67
+		help
68
+			Kagera adds a -jX option to certain packages that are known to behave well for
69
+			parallel build. This option specifies the number of jobs (-jX) to pass to packages
70
+			submake. By default, the packages are NOT built parallelized.
71
+
72
+	config KAGERA_VERBOSE_BUILD
73
+		bool "Kagera verbose build (debug mode)"
74
+		default n
75
+		help
76
+			This option specifies whether there should be produced a debugging output visible
77
+			on the screen and logged to the file or not.
78
+endmenu
79
+
80
+menu "OpenWrt setup"
81
+	choice
82
+		prompt "OpenWrt source repository type"
83
+		default OPENWRT_REPO_GIT
84
+		help
85
+			Specify a source control repository type. A source code repository is a place
86
+			where large amounts of source code are kept. They are often used by multi-developer
87
+			projects to handle various versions and handle conflicts arising from developers
88
+			submitting conflicting modifications in an organized fashion. GIT and Subversion
89
+			are popular tools used to handle this workflow, and are common in open source
90
+			projects.
91
+
92
+		config OPENWRT_REPO_GIT
93
+			bool "GIT"
94
+			help
95
+				GIT is a distributed revision control and source code management (SCM) system with an
96
+				emphasis on speed. Every Git working directory is a full-fledged repository with
97
+				complete history and full revision tracking capabilities, not dependent on network
98
+				access or a central server.
99
+
100
+		config OPENWRT_REPO_SVN
101
+			bool "SVN"
102
+			help
103
+				Subversion (often abbreviated SVN, after the command name svn) is a software versioning
104
+				and revision control system distributed under an open source license. Developers use
105
+				Subversion to maintain current and historical versions of files such as source code, web
106
+				pages, and documentation. Its goal is to be a mostly compatible successor to the widely
107
+				used CVS.
108
+	endchoice
109
+
110
+	config OPENWRT_REPO_GIT_URL
111
+		string "OpenWrt GIT repository URL"
112
+		depends on OPENWRT_REPO_GIT
113
+		default "git://git.openwrt.org/openwrt.git"
114
+		help
115
+			Repository is a place for storing data that are under control. Mind that they are
116
+			not the data you work with on your disk. GIT URL is a string of a special format
117
+			specifying the address of the remote repository which you connect to for source
118
+			code synchronization.
119
+
120
+	config OPENWRT_REPO_GIT_BRANCH
121
+		string "OpenWrt GIT branch"
122
+		depends on OPENWRT_REPO_GIT
123
+		default "master"
124
+		help
125
+			A set of files under version control may be branched or forked at a point in time
126
+			so that, from that time forward, two copies of those files may develop at different
127
+			speeds or in different ways independently of each other.
128
+
129
+	config OPENWRT_REPO_SVN_URL
130
+		string "OpenWrt SVN repository URL"
131
+		depends on OPENWRT_REPO_SVN
132
+		default "svn://svn.openwrt.org/openwrt/trunk"
133
+		help
134
+			Repository is a place for storing data that are under control. Mind that they are
135
+			not the data you work with on your disk. SVN URL is a string of a special format
136
+			specifying the address of the remote repository which you connect to for source
137
+			code synchronization.
138
+
139
+	config OPENWRT_REPO_SVN_REV
140
+		string "OpenWrt SVN revision"
141
+		depends on OPENWRT_REPO_SVN
142
+		default "0"
143
+		help
144
+			A revision is a set of changes which should be treated as an indivisible group
145
+			(i.e., an atomic package); the list of differences between two successive versions
146
+			in the repository. Specify 0 (zero) here to fetch latest version.
147
+
148
+	choice
149
+		prompt "Essential packages repository type"
150
+		default PACKAGES_ESSENTIAL_REPO_GIT
151
+		help
152
+			Specify a source control repository type. A source code repository is a place
153
+			where large amounts of source code are kept. They are often used by multi-developer
154
+			projects to handle various versions and handle conflicts arising from developers
155
+			submitting conflicting modifications in an organized fashion. GIT and Subversion
156
+			are popular tools used to handle this workflow, and are common in open source
157
+			projects.
158
+
159
+		config PACKAGES_ESSENTIAL_REPO_GIT
160
+			bool "GIT"
161
+			help
162
+				GIT is a distributed revision control and source code management (SCM) system with an
163
+				emphasis on speed. Every Git working directory is a full-fledged repository with
164
+				complete history and full revision tracking capabilities, not dependent on network
165
+				access or a central server.
166
+
167
+		config PACKAGES_ESSENTIAL_REPO_SVN
168
+			bool "SVN"
169
+			help
170
+				Subversion (often abbreviated SVN, after the command name svn) is a software versioning
171
+				and revision control system distributed under an open source license. Developers use
172
+				Subversion to maintain current and historical versions of files such as source code, web
173
+				pages, and documentation. Its goal is to be a mostly compatible successor to the widely
174
+				used CVS.
175
+	endchoice
176
+
177
+	config PACKAGES_ESSENTIAL_REPO_GIT_URL
178
+		string "Essential packages GIT repository URL"
179
+		depends on PACKAGES_ESSENTIAL_REPO_GIT
180
+		default "git://git.openwrt.org/packages.git"
181
+		help
182
+			Repository is a place for storing data that are under control. Mind that they are
183
+			not the data you work with on your disk. GIT URL is a string of a special format
184
+			specifying the address of the remote repository which you connect to for source
185
+			code synchronization.
186
+
187
+	config PACKAGES_ESSENTIAL_REPO_GIT_BRANCH
188
+		string "Essential packages GIT branch"
189
+		depends on PACKAGES_ESSENTIAL_REPO_GIT
190
+		default "master"
191
+		help
192
+			A set of files under version control may be branched or forked at a point in time
193
+			so that, from that time forward, two copies of those files may develop at different
194
+			speeds or in different ways independently of each other.
195
+
196
+	config PACKAGES_ESSENTIAL_REPO_SVN_URL
197
+		string "Essential packages SVN repository URL"
198
+		depends on PACKAGES_ESSENTIAL_REPO_SVN
199
+		default "svn://svn.openwrt.org/openwrt/packages"
200
+		help
201
+			Repository is a place for storing data that are under control. Mind that they are
202
+			not the data you work with on your disk. SVN URL is a string of a special format
203
+			specifying the address of the remote repository which you connect to for source
204
+			code synchronization.
205
+
206
+	config PACKAGES_ESSENTIAL_REPO_SVN_REV
207
+		string "Essential packages SVN revision"
208
+		depends on PACKAGES_ESSENTIAL_REPO_SVN
209
+		default "0"
210
+		help
211
+			A revision is a set of changes which should be treated as an indivisible group
212
+			(i.e., an atomic package); the list of differences between two successive versions
213
+			in the repository. Specify 0 (zero) here to fetch latest version.
214
+
215
+	config PACKAGES_EXTRA_REPO
216
+		bool "Enable extra feeds repository"
217
+		default n
218
+		help
219
+			A feed in OpenWrt and Kagera is a collection of packages which share a common location
220
+			Feeds reside on a remote server, in a version control system, addressable by a single
221
+			name (URL) over a protocol with a supported feed method.
222
+
223
+	choice
224
+		prompt "Extra packages repository type"
225
+		default PACKAGES_EXTRA_REPO_SVN
226
+		depends on PACKAGES_EXTRA_REPO
227
+		help
228
+			Specify a source control repository type. A source code repository is a place
229
+			where large amounts of source code are kept. They are often used by multi-developer
230
+			projects to handle various versions and handle conflicts arising from developers
231
+			submitting conflicting modifications in an organized fashion. GIT and Subversion
232
+			are popular tools used to handle this workflow, and are common in open source
233
+			projects.
234
+
235
+		config PACKAGES_EXTRA_REPO_GIT
236
+			bool "GIT"
237
+			help
238
+				GIT is a distributed revision control and source code management (SCM) system with an
239
+				emphasis on speed. Every Git working directory is a full-fledged repository with
240
+				complete history and full revision tracking capabilities, not dependent on network
241
+				access or a central server.
242
+
243
+		config PACKAGES_EXTRA_REPO_SVN
244
+			bool "SVN"
245
+			help
246
+				Subversion (often abbreviated SVN, after the command name svn) is a software versioning
247
+				and revision control system distributed under an open source license. Developers use
248
+				Subversion to maintain current and historical versions of files such as source code, web
249
+				pages, and documentation. Its goal is to be a mostly compatible successor to the widely
250
+				used CVS.
251
+	endchoice
252
+
253
+	config PACKAGES_EXTRA_REPO_GIT_URL
254
+		string "Essential packages GIT repository URL"
255
+		depends on PACKAGES_EXTRA_REPO && PACKAGES_EXTRA_REPO_GIT
256
+		default ""
257
+		help
258
+			Repository is a place for storing data that are under control. Mind that they are
259
+			not the data you work with on your disk. GIT URL is a string of a special format
260
+			specifying the address of the remote repository which you connect to for source
261
+			code synchronization.
262
+
263
+	config PACKAGES_EXTRA_REPO_GIT_BRANCH
264
+		string "Essential packages GIT branch"
265
+		depends on PACKAGES_EXTRA_REPO && PACKAGES_EXTRA_REPO_GIT
266
+		default "master"
267
+		help
268
+			A set of files under version control may be branched or forked at a point in time
269
+			so that, from that time forward, two copies of those files may develop at different
270
+			speeds or in different ways independently of each other.
271
+
272
+	config PACKAGES_EXTRA_REPO_SVN_URL
273
+		string "Essential packages SVN repository URL"
274
+		depends on PACKAGES_EXTRA_REPO && PACKAGES_EXTRA_REPO_SVN
275
+		default ""
276
+		help
277
+			Repository is a place for storing data that are under control. Mind that they are
278
+			not the data you work with on your disk. SVN URL is a string of a special format
279
+			specifying the address of the remote repository which you connect to for source
280
+			code synchronization.
281
+
282
+	config PACKAGES_EXTRA_REPO_SVN_REV
283
+		string "Essential packages SVN revision"
284
+		depends on PACKAGES_EXTRA_REPO && PACKAGES_EXTRA_REPO_SVN
285
+		default "0"
286
+		help
287
+			A revision is a set of changes which should be treated as an indivisible group
288
+			(i.e., an atomic package); the list of differences between two successive versions
289
+			in the repository. Specify 0 (zero) here to fetch latest version.
290
+endmenu

+ 29
- 0
config/kconfig/Makefile View File

@@ -0,0 +1,29 @@
1
+CC =		gcc
2
+LDLIBS =	-lmenu -lpanel -lncurses
3
+LXDIALOG =	lxdialog/checklist.o lxdialog/inputbox.o lxdialog/menubox.o lxdialog/textbox.o lxdialog/util.o lxdialog/yesno.o
4
+
5
+all: conf mconf nconf
6
+
7
+conf: zconf.tab.o conf.o
8
+	$(CC) zconf.tab.o conf.o -o $@
9
+
10
+mconf: zconf.tab.o mconf.o $(LXDIALOG)
11
+	$(CC) $(LDLIBS) zconf.tab.o mconf.o $(LXDIALOG) -o $@
12
+
13
+nconf: zconf.tab.o nconf.o nconf.gui.o
14
+	$(CC) $(LDLIBS) zconf.tab.o nconf.o nconf.gui.o -o $@
15
+
16
+zconf.tab.o: zconf.lex.c zconf.hash.c confdata.c
17
+zconf.lex.c: zconf.l
18
+
19
+%.lex.c: %.l
20
+	cp $@_shipped $@ || flex -L -P$(notdir $*) -o$@ $<
21
+
22
+%.hash.c: %.gperf
23
+	cp $@_shipped $@ || gperf < $< > $@
24
+
25
+%.tab.c: %.y
26
+	cp $@_shipped $@ || bison -l  -b $* -p$(notdir $*) $<
27
+
28
+clean:
29
+	rm -f *.o *.backup lxdialog/*.o conf mconf nconf zconf.lex.c zconf.hash.c

+ 2
- 0
config/kconfig/README View File

@@ -0,0 +1,2 @@
1
+These files were taken from the Linux Kernel 3.8.6 Configuration System
2
+and slightly modified for the Kagera Router Management Utility.

+ 701
- 0
config/kconfig/conf.c View File

@@ -0,0 +1,701 @@
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 <locale.h>
7
+#include <ctype.h>
8
+#include <stdio.h>
9
+#include <stdlib.h>
10
+#include <string.h>
11
+#include <time.h>
12
+#include <unistd.h>
13
+#include <getopt.h>
14
+#include <sys/stat.h>
15
+#include <sys/time.h>
16
+
17
+#include "lkc.h"
18
+
19
+static void conf(struct menu *menu);
20
+static void check_conf(struct menu *menu);
21
+static void xfgets(char *str, int size, FILE *in);
22
+
23
+enum input_mode {
24
+	oldaskconfig,
25
+	silentoldconfig,
26
+	oldconfig,
27
+	allnoconfig,
28
+	allyesconfig,
29
+	allmodconfig,
30
+	alldefconfig,
31
+	randconfig,
32
+	defconfig,
33
+	savedefconfig,
34
+	listnewconfig,
35
+	olddefconfig,
36
+} input_mode = oldaskconfig;
37
+
38
+static int indent = 1;
39
+static int valid_stdin = 1;
40
+static int sync_kconfig;
41
+static int conf_cnt;
42
+static char line[128];
43
+static struct menu *rootEntry;
44
+
45
+static void print_help(struct menu *menu)
46
+{
47
+	struct gstr help = str_new();
48
+
49
+	menu_get_ext_help(menu, &help);
50
+
51
+	printf("\n%s\n", str_get(&help));
52
+	str_free(&help);
53
+}
54
+
55
+static void strip(char *str)
56
+{
57
+	char *p = str;
58
+	int l;
59
+
60
+	while ((isspace(*p)))
61
+		p++;
62
+	l = strlen(p);
63
+	if (p != str)
64
+		memmove(str, p, l + 1);
65
+	if (!l)
66
+		return;
67
+	p = str + l - 1;
68
+	while ((isspace(*p)))
69
+		*p-- = 0;
70
+}
71
+
72
+static void check_stdin(void)
73
+{
74
+	if (!valid_stdin) {
75
+		printf(_("aborted!\n\n"));
76
+		printf(_("Console input/output is redirected. "));
77
+		printf(_("Run 'make oldconfig' to update configuration.\n\n"));
78
+		exit(1);
79
+	}
80
+}
81
+
82
+static int conf_askvalue(struct symbol *sym, const char *def)
83
+{
84
+	enum symbol_type type = sym_get_type(sym);
85
+
86
+	if (!sym_has_value(sym))
87
+		printf(_("(NEW) "));
88
+
89
+	line[0] = '\n';
90
+	line[1] = 0;
91
+
92
+	if (!sym_is_changable(sym)) {
93
+		printf("%s\n", def);
94
+		line[0] = '\n';
95
+		line[1] = 0;
96
+		return 0;
97
+	}
98
+
99
+	switch (input_mode) {
100
+	case oldconfig:
101
+	case silentoldconfig:
102
+		if (sym_has_value(sym)) {
103
+			printf("%s\n", def);
104
+			return 0;
105
+		}
106
+		check_stdin();
107
+		/* fall through */
108
+	case oldaskconfig:
109
+		fflush(stdout);
110
+		xfgets(line, 128, stdin);
111
+		return 1;
112
+	default:
113
+		break;
114
+	}
115
+
116
+	switch (type) {
117
+	case S_INT:
118
+	case S_HEX:
119
+	case S_STRING:
120
+		printf("%s\n", def);
121
+		return 1;
122
+	default:
123
+		;
124
+	}
125
+	printf("%s", line);
126
+	return 1;
127
+}
128
+
129
+static int conf_string(struct menu *menu)
130
+{
131
+	struct symbol *sym = menu->sym;
132
+	const char *def;
133
+
134
+	while (1) {
135
+		printf("%*s%s ", indent - 1, "", _(menu->prompt->text));
136
+		printf("(%s) ", sym->name);
137
+		def = sym_get_string_value(sym);
138
+		if (sym_get_string_value(sym))
139
+			printf("[%s] ", def);
140
+		if (!conf_askvalue(sym, def))
141
+			return 0;
142
+		switch (line[0]) {
143
+		case '\n':
144
+			break;
145
+		case '?':
146
+			/* print help */
147
+			if (line[1] == '\n') {
148
+				print_help(menu);
149
+				def = NULL;
150
+				break;
151
+			}
152
+			/* fall through */
153
+		default:
154
+			line[strlen(line)-1] = 0;
155
+			def = line;
156
+		}
157
+		if (def && sym_set_string_value(sym, def))
158
+			return 0;
159
+	}
160
+}
161
+
162
+static int conf_sym(struct menu *menu)
163
+{
164
+	struct symbol *sym = menu->sym;
165
+	tristate oldval, newval;
166
+
167
+	while (1) {
168
+		printf("%*s%s ", indent - 1, "", _(menu->prompt->text));
169
+		if (sym->name)
170
+			printf("(%s) ", sym->name);
171
+		putchar('[');
172
+		oldval = sym_get_tristate_value(sym);
173
+		switch (oldval) {
174
+		case no:
175
+			putchar('N');
176
+			break;
177
+		case mod:
178
+			putchar('M');
179
+			break;
180
+		case yes:
181
+			putchar('Y');
182
+			break;
183
+		}
184
+		if (oldval != no && sym_tristate_within_range(sym, no))
185
+			printf("/n");
186
+		if (oldval != mod && sym_tristate_within_range(sym, mod))
187
+			printf("/m");
188
+		if (oldval != yes && sym_tristate_within_range(sym, yes))
189
+			printf("/y");
190
+		if (menu_has_help(menu))
191
+			printf("/?");
192
+		printf("] ");
193
+		if (!conf_askvalue(sym, sym_get_string_value(sym)))
194
+			return 0;
195
+		strip(line);
196
+
197
+		switch (line[0]) {
198
+		case 'n':
199
+		case 'N':
200
+			newval = no;
201
+			if (!line[1] || !strcmp(&line[1], "o"))
202
+				break;
203
+			continue;
204
+		case 'm':
205
+		case 'M':
206
+			newval = mod;
207
+			if (!line[1])
208
+				break;
209
+			continue;
210
+		case 'y':
211
+		case 'Y':
212
+			newval = yes;
213
+			if (!line[1] || !strcmp(&line[1], "es"))
214
+				break;
215
+			continue;
216
+		case 0:
217
+			newval = oldval;
218
+			break;
219
+		case '?':
220
+			goto help;
221
+		default:
222
+			continue;
223
+		}
224
+		if (sym_set_tristate_value(sym, newval))
225
+			return 0;
226
+help:
227
+		print_help(menu);
228
+	}
229
+}
230
+
231
+static int conf_choice(struct menu *menu)
232
+{
233
+	struct symbol *sym, *def_sym;
234
+	struct menu *child;
235
+	bool is_new;
236
+
237
+	sym = menu->sym;
238
+	is_new = !sym_has_value(sym);
239
+	if (sym_is_changable(sym)) {
240
+		conf_sym(menu);
241
+		sym_calc_value(sym);
242
+		switch (sym_get_tristate_value(sym)) {
243
+		case no:
244
+			return 1;
245
+		case mod:
246
+			return 0;
247
+		case yes:
248
+			break;
249
+		}
250
+	} else {
251
+		switch (sym_get_tristate_value(sym)) {
252
+		case no:
253
+			return 1;
254
+		case mod:
255
+			printf("%*s%s\n", indent - 1, "", _(menu_get_prompt(menu)));
256
+			return 0;
257
+		case yes:
258
+			break;
259
+		}
260
+	}
261
+
262
+	while (1) {
263
+		int cnt, def;
264
+
265
+		printf("%*s%s\n", indent - 1, "", _(menu_get_prompt(menu)));
266
+		def_sym = sym_get_choice_value(sym);
267
+		cnt = def = 0;
268
+		line[0] = 0;
269
+		for (child = menu->list; child; child = child->next) {
270
+			if (!menu_is_visible(child))
271
+				continue;
272
+			if (!child->sym) {
273
+				printf("%*c %s\n", indent, '*', _(menu_get_prompt(child)));
274
+				continue;
275
+			}
276
+			cnt++;
277
+			if (child->sym == def_sym) {
278
+				def = cnt;
279
+				printf("%*c", indent, '>');
280
+			} else
281
+				printf("%*c", indent, ' ');
282
+			printf(" %d. %s", cnt, _(menu_get_prompt(child)));
283
+			if (child->sym->name)
284
+				printf(" (%s)", child->sym->name);
285
+			if (!sym_has_value(child->sym))
286
+				printf(_(" (NEW)"));
287
+			printf("\n");
288
+		}
289
+		printf(_("%*schoice"), indent - 1, "");
290
+		if (cnt == 1) {
291
+			printf("[1]: 1\n");
292
+			goto conf_childs;
293
+		}
294
+		printf("[1-%d", cnt);
295
+		if (menu_has_help(menu))
296
+			printf("?");
297
+		printf("]: ");
298
+		switch (input_mode) {
299
+		case oldconfig:
300
+		case silentoldconfig:
301
+			if (!is_new) {
302
+				cnt = def;
303
+				printf("%d\n", cnt);
304
+				break;
305
+			}
306
+			check_stdin();
307
+			/* fall through */
308
+		case oldaskconfig:
309
+			fflush(stdout);
310
+			xfgets(line, 128, stdin);
311
+			strip(line);
312
+			if (line[0] == '?') {
313
+				print_help(menu);
314
+				continue;
315
+			}
316
+			if (!line[0])
317
+				cnt = def;
318
+			else if (isdigit(line[0]))
319
+				cnt = atoi(line);
320
+			else
321
+				continue;
322
+			break;
323
+		default:
324
+			break;
325
+		}
326
+
327
+	conf_childs:
328
+		for (child = menu->list; child; child = child->next) {
329
+			if (!child->sym || !menu_is_visible(child))
330
+				continue;
331
+			if (!--cnt)
332
+				break;
333
+		}
334
+		if (!child)
335
+			continue;
336
+		if (line[0] && line[strlen(line) - 1] == '?') {
337
+			print_help(child);
338
+			continue;
339
+		}
340
+		sym_set_choice_value(sym, child->sym);
341
+		for (child = child->list; child; child = child->next) {
342
+			indent += 2;
343
+			conf(child);
344
+			indent -= 2;
345
+		}
346
+		return 1;
347
+	}
348
+}
349
+
350
+static void conf(struct menu *menu)
351
+{
352
+	struct symbol *sym;
353
+	struct property *prop;
354
+	struct menu *child;
355
+
356
+	if (!menu_is_visible(menu))
357
+		return;
358
+
359
+	sym = menu->sym;
360
+	prop = menu->prompt;
361
+	if (prop) {
362
+		const char *prompt;
363
+
364
+		switch (prop->type) {
365
+		case P_MENU:
366
+			if ((input_mode == silentoldconfig ||
367
+			     input_mode == listnewconfig ||
368
+			     input_mode == olddefconfig) &&
369
+			    rootEntry != menu) {
370
+				check_conf(menu);
371
+				return;
372
+			}
373
+			/* fall through */
374
+		case P_COMMENT:
375
+			prompt = menu_get_prompt(menu);
376
+			if (prompt)
377
+				printf("%*c\n%*c %s\n%*c\n",
378
+					indent, '*',
379
+					indent, '*', _(prompt),
380
+					indent, '*');
381
+		default:
382
+			;
383
+		}
384
+	}
385
+
386
+	if (!sym)
387
+		goto conf_childs;
388
+
389
+	if (sym_is_choice(sym)) {
390
+		conf_choice(menu);
391
+		if (sym->curr.tri != mod)
392
+			return;
393
+		goto conf_childs;
394
+	}
395
+
396
+	switch (sym->type) {
397
+	case S_INT:
398
+	case S_HEX:
399
+	case S_STRING:
400
+		conf_string(menu);
401
+		break;
402
+	default:
403
+		conf_sym(menu);
404
+		break;
405
+	}
406
+
407
+conf_childs:
408
+	if (sym)
409
+		indent += 2;
410
+	for (child = menu->list; child; child = child->next)
411
+		conf(child);
412
+	if (sym)
413
+		indent -= 2;
414
+}
415
+
416
+static void check_conf(struct menu *menu)
417
+{
418
+	struct symbol *sym;
419
+	struct menu *child;
420
+
421
+	if (!menu_is_visible(menu))
422
+		return;
423
+
424
+	sym = menu->sym;
425
+	if (sym && !sym_has_value(sym)) {
426
+		if (sym_is_changable(sym) ||
427
+		    (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) {
428
+			if (input_mode == listnewconfig) {
429
+				if (sym->name && !sym_is_choice_value(sym)) {
430
+					printf("%s%s\n", CONFIG_, sym->name);
431
+				}
432
+			} else if (input_mode != olddefconfig) {
433
+				if (!conf_cnt++)
434
+					printf(_("*\n* Restart config...\n*\n"));
435
+				rootEntry = menu_get_parent_menu(menu);
436
+				conf(rootEntry);
437
+			}
438
+		}
439
+	}
440
+
441
+	for (child = menu->list; child; child = child->next)
442
+		check_conf(child);
443
+}
444
+
445
+static struct option long_opts[] = {
446
+	{"oldaskconfig",    no_argument,       NULL, oldaskconfig},
447
+	{"oldconfig",       no_argument,       NULL, oldconfig},
448
+	{"silentoldconfig", no_argument,       NULL, silentoldconfig},
449
+	{"defconfig",       optional_argument, NULL, defconfig},
450
+	{"savedefconfig",   required_argument, NULL, savedefconfig},
451
+	{"allnoconfig",     no_argument,       NULL, allnoconfig},
452
+	{"allyesconfig",    no_argument,       NULL, allyesconfig},
453
+	{"allmodconfig",    no_argument,       NULL, allmodconfig},
454
+	{"alldefconfig",    no_argument,       NULL, alldefconfig},
455
+	{"randconfig",      no_argument,       NULL, randconfig},
456
+	{"listnewconfig",   no_argument,       NULL, listnewconfig},
457
+	{"olddefconfig",    no_argument,       NULL, olddefconfig},
458
+	/*
459
+	 * oldnoconfig is an alias of olddefconfig, because people already
460
+	 * are dependent on its behavior(sets new symbols to their default
461
+	 * value but not 'n') with the counter-intuitive name.
462
+	 */
463
+	{"oldnoconfig",     no_argument,       NULL, olddefconfig},
464
+	{NULL, 0, NULL, 0}
465
+};
466
+
467
+static void conf_usage(const char *progname)
468
+{
469
+
470
+	printf("Usage: %s [option] <kconfig-file>\n", progname);
471
+	printf("[option] is _one_ of the following:\n");
472
+	printf("  --listnewconfig         List new options\n");
473
+	printf("  --oldaskconfig          Start a new configuration using a line-oriented program\n");
474
+	printf("  --oldconfig             Update a configuration using a provided .config as base\n");
475
+	printf("  --silentoldconfig       Same as oldconfig, but quietly, additionally update deps\n");
476
+	printf("  --olddefconfig          Same as silentoldconfig but sets new symbols to their default value\n");
477
+	printf("  --oldnoconfig           An alias of olddefconfig\n");
478
+	printf("  --defconfig <file>      New config with default defined in <file>\n");
479
+	printf("  --savedefconfig <file>  Save the minimal current configuration to <file>\n");
480
+	printf("  --allnoconfig           New config where all options are answered with no\n");
481
+	printf("  --allyesconfig          New config where all options are answered with yes\n");
482
+	printf("  --allmodconfig          New config where all options are answered with mod\n");
483
+	printf("  --alldefconfig          New config with all symbols set to default\n");
484
+	printf("  --randconfig            New config with random answer to all options\n");
485
+}
486
+
487
+int main(int ac, char **av)
488
+{
489
+	const char *progname = av[0];
490
+	int opt;
491
+	const char *name, *defconfig_file = NULL /* gcc uninit */;
492
+	struct stat tmpstat;
493
+
494
+	setlocale(LC_ALL, "");
495
+	bindtextdomain(PACKAGE, LOCALEDIR);
496
+	textdomain(PACKAGE);
497
+
498
+	while ((opt = getopt_long(ac, av, "", long_opts, NULL)) != -1) {
499
+		input_mode = (enum input_mode)opt;
500
+		switch (opt) {
501
+		case silentoldconfig:
502
+			sync_kconfig = 1;
503
+			break;
504
+		case defconfig:
505
+		case savedefconfig:
506
+			defconfig_file = optarg;
507
+			break;
508
+		case randconfig:
509
+		{
510
+			struct timeval now;
511
+			unsigned int seed;
512
+
513
+			/*
514
+			 * Use microseconds derived seed,
515
+			 * compensate for systems where it may be zero
516
+			 */
517
+			gettimeofday(&now, NULL);
518
+
519
+			seed = (unsigned int)((now.tv_sec + 1) * (now.tv_usec + 1));
520
+			srand(seed);
521
+			break;
522
+		}
523
+		case oldaskconfig:
524
+		case oldconfig:
525
+		case allnoconfig:
526
+		case allyesconfig:
527
+		case allmodconfig:
528
+		case alldefconfig:
529
+		case listnewconfig:
530
+		case olddefconfig:
531
+			break;
532
+		case '?':
533
+			conf_usage(progname);
534
+			exit(1);
535
+			break;
536
+		}
537
+	}
538
+	if (ac == optind) {
539
+		printf(_("%s: Kconfig file missing\n"), av[0]);
540
+		conf_usage(progname);
541
+		exit(1);
542
+	}
543
+	name = av[optind];
544
+	conf_parse(name);
545
+	//zconfdump(stdout);
546
+	if (sync_kconfig) {
547
+		name = conf_get_configname();
548
+		if (stat(name, &tmpstat)) {
549
+			fprintf(stderr, _("***\n"
550
+				"*** Configuration file \"%s\" not found!\n"
551
+				"***\n"
552
+				"*** Please run some configurator (e.g. \"make oldconfig\" or\n"
553
+				"*** \"make menuconfig\" or \"make xconfig\").\n"
554
+				"***\n"), name);
555
+			exit(1);
556
+		}
557
+	}
558
+
559
+	switch (input_mode) {
560
+	case defconfig:
561
+		if (!defconfig_file)
562
+			defconfig_file = conf_get_default_confname();
563
+		if (conf_read(defconfig_file)) {
564
+			printf(_("***\n"
565
+				"*** Can't find default configuration \"%s\"!\n"
566
+				"***\n"), defconfig_file);
567
+			exit(1);
568
+		}
569
+		break;
570
+	case savedefconfig:
571
+	case silentoldconfig:
572
+	case oldaskconfig:
573
+	case oldconfig:
574
+	case listnewconfig:
575
+	case olddefconfig:
576
+		conf_read(NULL);
577
+		break;
578
+	case allnoconfig:
579
+	case allyesconfig:
580
+	case allmodconfig:
581
+	case alldefconfig:
582
+	case randconfig:
583
+		name = getenv("KCONFIG_ALLCONFIG");
584
+		if (!name)
585
+			break;
586
+		if ((strcmp(name, "") != 0) && (strcmp(name, "1") != 0)) {
587
+			if (conf_read_simple(name, S_DEF_USER)) {
588
+				fprintf(stderr,
589
+					_("*** Can't read seed configuration \"%s\"!\n"),
590
+					name);
591
+				exit(1);
592
+			}
593
+			break;
594
+		}
595
+		switch (input_mode) {
596
+		case allnoconfig:	name = "allno.config"; break;
597
+		case allyesconfig:	name = "allyes.config"; break;
598
+		case allmodconfig:	name = "allmod.config"; break;
599
+		case alldefconfig:	name = "alldef.config"; break;
600
+		case randconfig:	name = "allrandom.config"; break;
601
+		default: break;
602
+		}
603
+		if (conf_read_simple(name, S_DEF_USER) &&
604
+		    conf_read_simple("all.config", S_DEF_USER)) {
605
+			fprintf(stderr,
606
+				_("*** KCONFIG_ALLCONFIG set, but no \"%s\" or \"all.config\" file found\n"),
607
+				name);
608
+			exit(1);
609
+		}
610
+		break;
611
+	default:
612
+		break;
613
+	}
614
+
615
+	if (sync_kconfig) {
616
+		if (conf_get_changed()) {
617
+			name = getenv("KCONFIG_NOSILENTUPDATE");
618
+			if (name && *name) {
619
+				fprintf(stderr,
620
+					_("\n*** The configuration requires explicit update.\n\n"));
621
+				return 1;
622
+			}
623
+		}
624
+		valid_stdin = isatty(0) && isatty(1) && isatty(2);
625
+	}
626
+
627
+	switch (input_mode) {
628
+	case allnoconfig:
629
+		conf_set_all_new_symbols(def_no);
630
+		break;
631
+	case allyesconfig:
632
+		conf_set_all_new_symbols(def_yes);
633
+		break;
634
+	case allmodconfig:
635
+		conf_set_all_new_symbols(def_mod);
636
+		break;
637
+	case alldefconfig:
638
+		conf_set_all_new_symbols(def_default);
639
+		break;
640
+	case randconfig:
641
+		conf_set_all_new_symbols(def_random);
642
+		break;
643
+	case defconfig:
644
+		conf_set_all_new_symbols(def_default);
645
+		break;
646
+	case savedefconfig:
647
+		break;
648
+	case oldaskconfig:
649
+		rootEntry = &rootmenu;
650
+		conf(&rootmenu);
651
+		input_mode = silentoldconfig;
652
+		/* fall through */
653
+	case oldconfig:
654
+	case listnewconfig:
655
+	case olddefconfig:
656
+	case silentoldconfig:
657
+		/* Update until a loop caused no more changes */
658
+		do {
659
+			conf_cnt = 0;
660
+			check_conf(&rootmenu);
661
+		} while (conf_cnt &&
662
+			 (input_mode != listnewconfig &&
663
+			  input_mode != olddefconfig));
664
+		break;
665
+	}
666
+
667
+	if (sync_kconfig) {
668
+		/* silentoldconfig is used during the build so we shall update autoconf.
669
+		 * All other commands are only used to generate a config.
670
+		 */
671
+		if (conf_get_changed() && conf_write(NULL)) {
672
+			fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n"));
673
+			exit(1);
674
+		}
675
+		if (conf_write_autoconf()) {
676
+			fprintf(stderr, _("\n*** Error during update of the configuration.\n\n"));
677
+			return 1;
678
+		}
679
+	} else if (input_mode == savedefconfig) {
680
+		if (conf_write_defconfig(defconfig_file)) {
681
+			fprintf(stderr, _("n*** Error while saving defconfig to: %s\n\n"),
682
+			        defconfig_file);
683
+			return 1;
684
+		}
685
+	} else if (input_mode != listnewconfig) {
686
+		if (conf_write(NULL)) {
687
+			fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n"));
688
+			exit(1);
689
+		}
690
+	}
691
+	return 0;
692
+}
693
+
694
+/*
695
+ * Helper function to facilitate fgets() by Jean Sacren.
696
+ */
697
+void xfgets(char *str, int size, FILE *in)
698
+{
699
+	if (fgets(str, size, in) == NULL)
700
+		fprintf(stderr, "\nError in reading or end of file.\n");
701
+}

+ 1164
- 0
config/kconfig/confdata.c
File diff suppressed because it is too large
View File


+ 1168
- 0
config/kconfig/expr.c
File diff suppressed because it is too large
View File


+ 235
- 0
config/kconfig/expr.h View File

@@ -0,0 +1,235 @@
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 <assert.h>
14
+#include <stdio.h>
15
+#include "list.h"
16
+#ifndef __cplusplus
17
+#include <stdbool.h>
18
+#endif
19
+
20
+struct file {
21
+	struct file *next;
22
+	struct file *parent;
23
+	const char *name;
24
+	int lineno;
25
+};
26
+
27
+typedef enum tristate {
28
+	no, mod, yes
29
+} tristate;
30
+
31
+enum expr_type {
32
+	E_NONE, E_OR, E_AND, E_NOT, E_EQUAL, E_UNEQUAL, E_LIST, E_SYMBOL, E_RANGE
33
+};
34
+
35
+union expr_data {
36
+	struct expr *expr;
37
+	struct symbol *sym;
38
+};
39
+
40
+struct expr {
41
+	enum expr_type type;
42
+	union expr_data left, right;
43
+};
44
+
45
+#define EXPR_OR(dep1, dep2)	(((dep1)>(dep2))?(dep1):(dep2))
46
+#define EXPR_AND(dep1, dep2)	(((dep1)<(dep2))?(dep1):(dep2))
47
+#define EXPR_NOT(dep)		(2-(dep))
48
+
49
+#define expr_list_for_each_sym(l, e, s) \
50
+	for (e = (l); e && (s = e->right.sym); e = e->left.expr)
51
+
52
+struct expr_value {
53
+	struct expr *expr;
54
+	tristate tri;
55
+};
56
+
57
+struct symbol_value {
58
+	void *val;
59
+	tristate tri;
60
+};
61
+
62
+enum symbol_type {
63
+	S_UNKNOWN, S_BOOLEAN, S_TRISTATE, S_INT, S_HEX, S_STRING, S_OTHER
64
+};
65
+
66
+/* enum values are used as index to symbol.def[] */
67
+enum {
68
+	S_DEF_USER,		/* main user value */
69
+	S_DEF_AUTO,		/* values read from auto.conf */
70
+	S_DEF_DEF3,		/* Reserved for UI usage */
71
+	S_DEF_DEF4,		/* Reserved for UI usage */
72
+	S_DEF_COUNT
73
+};
74
+
75
+struct symbol {
76
+	struct symbol *next;
77
+	char *name;
78
+	enum symbol_type type;
79
+	struct symbol_value curr;
80
+	struct symbol_value def[S_DEF_COUNT];
81
+	tristate visible;
82
+	int flags;
83
+	struct property *prop;
84
+	struct expr_value dir_dep;
85
+	struct expr_value rev_dep;
86
+};
87
+
88
+#define for_all_symbols(i, sym) for (i = 0; i < SYMBOL_HASHSIZE; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) if (sym->type != S_OTHER)
89
+
90
+#define SYMBOL_CONST      0x0001  /* symbol is const */
91
+#define SYMBOL_CHECK      0x0008  /* used during dependency checking */
92
+#define SYMBOL_CHOICE     0x0010  /* start of a choice block (null name) */
93
+#define SYMBOL_CHOICEVAL  0x0020  /* used as a value in a choice block */
94
+#define SYMBOL_VALID      0x0080  /* set when symbol.curr is calculated */
95
+#define SYMBOL_OPTIONAL   0x0100  /* choice is optional - values can be 'n' */
96
+#define SYMBOL_WRITE      0x0200  /* ? */
97
+#define SYMBOL_CHANGED    0x0400  /* ? */
98
+#define SYMBOL_AUTO       0x1000  /* value from environment variable */
99
+#define SYMBOL_CHECKED    0x2000  /* used during dependency checking */
100
+#define SYMBOL_WARNED     0x8000  /* warning has been issued */
101
+
102
+/* Set when symbol.def[] is used */
103
+#define SYMBOL_DEF        0x10000  /* First bit of SYMBOL_DEF */
104
+#define SYMBOL_DEF_USER   0x10000  /* symbol.def[S_DEF_USER] is valid */
105
+#define SYMBOL_DEF_AUTO   0x20000  /* symbol.def[S_DEF_AUTO] is valid */
106
+#define SYMBOL_DEF3       0x40000  /* symbol.def[S_DEF_3] is valid */
107
+#define SYMBOL_DEF4       0x80000  /* symbol.def[S_DEF_4] is valid */
108
+
109
+#define SYMBOL_MAXLENGTH	256
110
+#define SYMBOL_HASHSIZE		9973
111
+
112
+/* A property represent the config options that can be associated
113
+ * with a config "symbol".
114
+ * Sample:
115
+ * config FOO
116
+ *         default y
117
+ *         prompt "foo prompt"
118
+ *         select BAR
119
+ * config BAZ
120
+ *         int "BAZ Value"
121
+ *         range 1..255
122
+ */
123
+enum prop_type {
124
+	P_UNKNOWN,
125
+	P_PROMPT,   /* prompt "foo prompt" or "BAZ Value" */
126
+	P_COMMENT,  /* text associated with a comment */
127
+	P_MENU,     /* prompt associated with a menuconfig option */
128
+	P_DEFAULT,  /* default y */
129
+	P_CHOICE,   /* choice value */
130
+	P_SELECT,   /* select BAR */
131
+	P_RANGE,    /* range 7..100 (for a symbol) */
132
+	P_ENV,      /* value from environment variable */
133
+	P_SYMBOL,   /* where a symbol is defined */
134
+};
135
+
136
+struct property {
137
+	struct property *next;     /* next property - null if last */
138
+	struct symbol *sym;        /* the symbol for which the property is associated */
139
+	enum prop_type type;       /* type of property */
140
+	const char *text;          /* the prompt value - P_PROMPT, P_MENU, P_COMMENT */
141
+	struct expr_value visible;
142
+	struct expr *expr;         /* the optional conditional part of the property */
143
+	struct menu *menu;         /* the menu the property are associated with
144
+	                            * valid for: P_SELECT, P_RANGE, P_CHOICE,
145
+	                            * P_PROMPT, P_DEFAULT, P_MENU, P_COMMENT */
146
+	struct file *file;         /* what file was this property defined */
147
+	int lineno;                /* what lineno was this property defined */
148
+};
149
+
150
+#define for_all_properties(sym, st, tok) \
151
+	for (st = sym->prop; st; st = st->next) \
152
+		if (st->type == (tok))
153
+#define for_all_defaults(sym, st) for_all_properties(sym, st, P_DEFAULT)
154
+#define for_all_choices(sym, st) for_all_properties(sym, st, P_CHOICE)
155
+#define for_all_prompts(sym, st) \
156
+	for (st = sym->prop; st; st = st->next) \
157
+		if (st->text)
158
+
159
+struct menu {
160
+	struct menu *next;
161
+	struct menu *parent;
162
+	struct menu *list;
163
+	struct symbol *sym;
164
+	struct property *prompt;
165
+	struct expr *visibility;
166
+	struct expr *dep;
167
+	unsigned int flags;
168
+	char *help;
169
+	struct file *file;
170
+	int lineno;
171
+	void *data;
172
+};
173
+
174
+#define MENU_CHANGED		0x0001
175
+#define MENU_ROOT		0x0002
176
+
177
+struct jump_key {
178
+	struct list_head entries;
179
+	size_t offset;
180
+	struct menu *target;
181
+	int index;
182
+};
183
+
184
+#define JUMP_NB			9
185
+
186
+extern struct file *file_list;
187
+extern struct file *current_file;
188
+struct file *lookup_file(const char *name);
189
+
190
+extern struct symbol symbol_yes, symbol_no, symbol_mod;
191
+extern struct symbol *modules_sym;
192
+extern struct symbol *sym_defconfig_list;
193
+extern int cdebug;
194
+struct expr *expr_alloc_symbol(struct symbol *sym);
195
+struct expr *expr_alloc_one(enum expr_type type, struct expr *ce);
196
+struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2);
197
+struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2);
198
+struct expr *expr_alloc_and(struct expr *e1, struct expr *e2);
199
+struct expr *expr_alloc_or(struct expr *e1, struct expr *e2);
200
+struct expr *expr_copy(const struct expr *org);
201
+void expr_free(struct expr *e);
202
+int expr_eq(struct expr *e1, struct expr *e2);
203
+void expr_eliminate_eq(struct expr **ep1, struct expr **ep2);
204
+tristate expr_calc_value(struct expr *e);
205
+struct expr *expr_eliminate_yn(struct expr *e);
206
+struct expr *expr_trans_bool(struct expr *e);
207
+struct expr *expr_eliminate_dups(struct expr *e);
208
+struct expr *expr_transform(struct expr *e);
209
+int expr_contains_symbol(struct expr *dep, struct symbol *sym);
210
+bool expr_depends_symbol(struct expr *dep, struct symbol *sym);
211
+struct expr *expr_extract_eq_and(struct expr **ep1, struct expr **ep2);
212
+struct expr *expr_extract_eq_or(struct expr **ep1, struct expr **ep2);
213
+void expr_extract_eq(enum expr_type type, struct expr **ep, struct expr **ep1, struct expr **ep2);
214
+struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym);
215
+struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2);
216
+
217
+void expr_fprint(struct expr *e, FILE *out);
218
+struct gstr; /* forward */
219
+void expr_gstr_print(struct expr *e, struct gstr *gs);
220
+
221
+static inline int expr_is_yes(struct expr *e)
222
+{
223
+	return !e || (e->type == E_SYMBOL && e->left.sym == &symbol_yes);
224
+}
225
+
226
+static inline int expr_is_no(struct expr *e)
227
+{
228
+	return e && (e->type == E_SYMBOL && e->left.sym == &symbol_no);
229
+}
230
+
231
+#ifdef __cplusplus
232
+}
233
+#endif
234
+
235
+#endif /* EXPR_H */

+ 91
- 0
config/kconfig/list.h View File

@@ -0,0 +1,91 @@
1
+#ifndef LIST_H
2
+#define LIST_H
3
+
4
+/*
5
+ * Copied from include/linux/...
6
+ */
7
+
8
+#undef offsetof
9
+#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
10
+
11
+/**
12
+ * container_of - cast a member of a structure out to the containing structure
13
+ * @ptr:        the pointer to the member.
14
+ * @type:       the type of the container struct this is embedded in.
15
+ * @member:     the name of the member within the struct.
16
+ *
17
+ */
18
+#define container_of(ptr, type, member) ({                      \
19
+	const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
20
+	(type *)( (char *)__mptr - offsetof(type,member) );})
21
+
22
+
23
+struct list_head {
24
+	struct list_head *next, *prev;
25
+};
26
+
27
+
28
+#define LIST_HEAD_INIT(name) { &(name), &(name) }
29
+
30
+#define LIST_HEAD(name) \
31
+	struct list_head name = LIST_HEAD_INIT(name)
32
+
33
+/**
34
+ * list_entry - get the struct for this entry
35
+ * @ptr:	the &struct list_head pointer.
36
+ * @type:	the type of the struct this is embedded in.
37
+ * @member:	the name of the list_struct within the struct.
38
+ */
39
+#define list_entry(ptr, type, member) \
40
+	container_of(ptr, type, member)
41
+
42
+/**
43
+ * list_for_each_entry	-	iterate over list of given type
44
+ * @pos:	the type * to use as a loop cursor.
45
+ * @head:	the head for your list.
46
+ * @member:	the name of the list_struct within the struct.
47
+ */
48
+#define list_for_each_entry(pos, head, member)				\
49
+	for (pos = list_entry((head)->next, typeof(*pos), member);	\
50
+	     &pos->member != (head); 	\
51
+	     pos = list_entry(pos->member.next, typeof(*pos), member))
52
+
53
+/**
54
+ * list_empty - tests whether a list is empty
55
+ * @head: the list to test.
56
+ */
57
+static inline int list_empty(const struct list_head *head)
58
+{
59
+	return head->next == head;
60
+}
61
+
62
+/*
63
+ * Insert a new entry between two known consecutive entries.
64
+ *
65
+ * This is only for internal list manipulation where we know
66
+ * the prev/next entries already!
67
+ */
68
+static inline void __list_add(struct list_head *_new,
69
+			      struct list_head *prev,
70
+			      struct list_head *next)
71
+{
72
+	next->prev = _new;
73
+	_new->next = next;
74
+	_new->prev = prev;
75
+	prev->next = _new;
76
+}
77
+
78
+/**
79
+ * list_add_tail - add a new entry
80
+ * @new: new entry to be added
81
+ * @head: list head to add it before
82
+ *
83
+ * Insert a new entry before the specified head.
84
+ * This is useful for implementing queues.
85
+ */
86
+static inline void list_add_tail(struct list_head *_new, struct list_head *head)
87
+{
88
+	__list_add(_new, head->prev, head);
89
+}
90
+
91
+#endif

+ 190
- 0
config/kconfig/lkc.h View File

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

+ 56
- 0
config/kconfig/lkc_proto.h View File

@@ -0,0 +1,56 @@
1
+#include <stdarg.h>
2
+
3
+/* confdata.c */
4
+P(conf_parse,void,(const char *name));
5
+P(conf_read,int,(const char *name));
6
+P(conf_read_simple,int,(const char *name, int));
7
+P(conf_write_defconfig,int,(const char *name));
8
+P(conf_write,int,(const char *name));
9
+P(conf_write_autoconf,int,(void));
10
+P(conf_get_changed,bool,(void));
11
+P(conf_set_changed_callback, void,(void (*fn)(void)));
12
+P(conf_set_message_callback, void,(void (*fn)(const char *fmt, va_list ap)));
13
+
14
+/* menu.c */
15
+P(rootmenu,struct menu,);
16
+
17
+P(menu_is_visible, bool, (struct menu *menu));
18
+P(menu_has_prompt, bool, (struct menu *menu));
19
+P(menu_get_prompt,const char *,(struct menu *menu));
20
+P(menu_get_root_menu,struct menu *,(struct menu *menu));
21
+P(menu_get_parent_menu,struct menu *,(struct menu *menu));
22
+P(menu_has_help,bool,(struct menu *menu));
23
+P(menu_get_help,const char *,(struct menu *menu));
24
+P(get_symbol_str, void, (struct gstr *r, struct symbol *sym, struct list_head
25
+			 *head));
26
+P(get_relations_str, struct gstr, (struct symbol **sym_arr, struct list_head
27
+				   *head));
28
+P(menu_get_ext_help,void,(struct menu *menu, struct gstr *help));
29
+
30
+/* symbol.c */
31
+P(symbol_hash,struct symbol *,[SYMBOL_HASHSIZE]);
32
+
33
+P(sym_lookup,struct symbol *,(const char *name, int flags));
34
+P(sym_find,struct symbol *,(const char *name));
35
+P(sym_expand_string_value,const char *,(const char *in));
36
+P(sym_escape_string_value, const char *,(const char *in));
37
+P(sym_re_search,struct symbol **,(const char *pattern));
38
+P(sym_type_name,const char *,(enum symbol_type type));
39
+P(sym_calc_value,void,(struct symbol *sym));
40
+P(sym_get_type,enum symbol_type,(struct symbol *sym));
41
+P(sym_tristate_within_range,bool,(struct symbol *sym,tristate tri));
42
+P(sym_set_tristate_value,bool,(struct symbol *sym,tristate tri));
43
+P(sym_toggle_tristate_value,tristate,(struct symbol *sym));
44
+P(sym_string_valid,bool,(struct symbol *sym, const char *newval));
45
+P(sym_string_within_range,bool,(struct symbol *sym, const char *str));
46
+P(sym_set_string_value,bool,(struct symbol *sym, const char *newval));
47
+P(sym_is_changable,bool,(struct symbol *sym));
48
+P(sym_get_choice_prop,struct property *,(struct symbol *sym));
49
+P(sym_get_default_prop,struct property *,(struct symbol *sym));
50
+P(sym_get_string_value,const char *,(struct symbol *sym));
51
+
52
+P(prop_get_type_name,const char *,(enum prop_type type));
53
+
54
+/* expr.c */
55
+P(expr_compare_type,int,(enum expr_type t1, enum expr_type t2));
56
+P(expr_print,void,(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken));

+ 332
- 0
config/kconfig/lxdialog/checklist.c View File

@@ -0,0 +1,332 @@
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;
27
+
28
+/*
29
+ * Print list item
30
+ */
31
+static void print_item(WINDOW * win, int choice, int selected)
32
+{
33
+	int i;
34
+	char *list_item = malloc(list_width + 1);
35
+
36
+	strncpy(list_item, item_str(), list_width - item_x);
37
+	list_item[list_width - item_x] = '\0';
38
+
39
+	/* Clear 'residue' of last item */
40
+	wattrset(win, dlg.menubox.atr);
41
+	wmove(win, choice, 0);
42
+	for (i = 0; i < list_width; i++)
43
+		waddch(win, ' ');
44
+
45
+	wmove(win, choice, check_x);
46
+	wattrset(win, selected ? dlg.check_selected.atr
47
+		 : dlg.check.atr);
48
+	if (!item_is_tag(':'))
49
+		wprintw(win, "(%c)", item_is_tag('X') ? 'X' : ' ');
50
+
51
+	wattrset(win, selected ? dlg.tag_selected.atr : dlg.tag.atr);
52
+	mvwaddch(win, choice, item_x, list_item[0]);
53
+	wattrset(win, selected ? dlg.item_selected.atr : dlg.item.atr);
54
+	waddstr(win, list_item + 1);
55
+	if (selected) {
56
+		wmove(win, choice, check_x + 1);
57
+		wrefresh(win);
58
+	}
59
+	free(list_item);
60
+}
61
+
62
+/*
63
+ * Print the scroll indicators.
64
+ */
65
+static void print_arrows(WINDOW * win, int choice, int item_no, int scroll,
66
+	     int y, int x, int height)
67
+{
68
+	wmove(win, y, x);
69
+
70
+	if (scroll > 0) {
71
+		wattrset(win, dlg.uarrow.atr);
72
+		waddch(win, ACS_UARROW);
73
+		waddstr(win, "(-)");
74
+	} else {
75
+		wattrset(win, dlg.menubox.atr);
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, dlg.darrow.atr);
87
+		waddch(win, ACS_DARROW);
88
+		waddstr(win, "(+)");
89
+	} else {
90
+		wattrset(win, dlg.menubox_border.atr);
91
+		waddch(win, ACS_HLINE);
92
+		waddch(win, ACS_HLINE);
93
+		waddch(win, ACS_HLINE);
94
+		waddch(win, ACS_HLINE);
95
+	}
96
+}
97
+
98
+/*
99
+ *  Display the termination buttons
100
+ */
101
+static void print_buttons(WINDOW * dialog, int height, int width, int selected)
102
+{
103
+	int x = width / 2 - 11;
104
+	int y = height - 2;
105
+
106
+	print_button(dialog, gettext("Select"), y, x, selected == 0);
107
+	print_button(dialog, gettext(" Help "), y, x + 14, selected == 1);
108
+
109
+	wmove(dialog, y, x + 1 + 14 * selected);
110
+	wrefresh(dialog);
111
+}
112
+
113
+/*
114
+ * Display a dialog box with a list of options that can be turned on or off
115
+ * in the style of radiolist (only one option turned on at a time).
116
+ */
117
+int dialog_checklist(const char *title, const char *prompt, int height,
118
+		     int width, int list_height)
119
+{
120
+	int i, x, y, box_x, box_y;
121
+	int key = 0, button = 0, choice = 0, scroll = 0, max_choice;
122
+	WINDOW *dialog, *list;
123
+
124
+	/* which item to highlight */
125
+	item_foreach() {
126
+		if (item_is_tag('X'))
127
+			choice = item_n();
128
+		if (item_is_selected()) {
129
+			choice = item_n();
130
+			break;
131
+		}
132
+	}
133
+
134
+do_resize:
135
+	if (getmaxy(stdscr) < (height + 6))
136
+		return -ERRDISPLAYTOOSMALL;
137
+	if (getmaxx(stdscr) < (width + 6))
138
+		return -ERRDISPLAYTOOSMALL;
139
+
140
+	max_choice = MIN(list_height, item_count());
141
+
142
+	/* center dialog box on screen */
143
+	x = (COLS - width) / 2;
144
+	y = (LINES - height) / 2;
145
+
146
+	draw_shadow(stdscr, y, x, height, width);
147
+
148
+	dialog = newwin(height, width, y, x);
149
+	keypad(dialog, TRUE);
150
+
151
+	draw_box(dialog, 0, 0, height, width,
152
+		 dlg.dialog.atr, dlg.border.atr);
153
+	wattrset(dialog, dlg.border.atr);
154
+	mvwaddch(dialog, height - 3, 0, ACS_LTEE);
155
+	for (i = 0; i < width - 2; i++)
156
+		waddch(dialog, ACS_HLINE);
157
+	wattrset(dialog, dlg.dialog.atr);
158
+	waddch(dialog, ACS_RTEE);
159
+
160
+	print_title(dialog, title, width);
161
+
162
+	wattrset(dialog, dlg.dialog.atr);
163
+	print_autowrap(dialog, prompt, width - 2, 1, 3);
164
+
165
+	list_width = width - 6;
166
+	box_y = height - list_height - 5;
167
+	box_x = (width - list_width) / 2 - 1;
168
+
169
+	/* create new window for the list */
170
+	list = subwin(dialog, list_height, list_width, y + box_y + 1,
171
+	              x + box_x + 1);
172
+
173
+	keypad(list, TRUE);
174
+
175
+	/* draw a box around the list items */
176
+	draw_box(dialog, box_y, box_x, list_height + 2, list_width + 2,
177
+	         dlg.menubox_border.atr, dlg.menubox.atr);
178
+
179
+	/* Find length of longest item in order to center checklist */
180
+	check_x = 0;
181
+	item_foreach()
182
+		check_x = MAX(check_x, strlen(item_str()) + 4);
183
+	check_x = MIN(check_x, list_width);
184
+
185
+	check_x = (list_width - check_x) / 2;
186
+	item_x = check_x + 4;
187
+
188
+	if (choice >= list_height) {
189
+		scroll = choice - list_height + 1;
190
+		choice -= scroll;
191
+	}
192
+
193
+	/* Print the list */
194
+	for (i = 0; i < max_choice; i++) {
195
+		item_set(scroll + i);
196
+		print_item(list, i, i == choice);
197
+	}
198
+
199
+	print_arrows(dialog, choice, item_count(), scroll,
200
+		     box_y, box_x + check_x + 5, list_height);
201
+
202
+	print_buttons(dialog, height, width, 0);
203
+
204
+	wnoutrefresh(dialog);
205
+	wnoutrefresh(list);
206
+	doupdate();
207
+
208
+	while (key != KEY_ESC) {
209
+		key = wgetch(dialog);
210
+
211
+		for (i = 0; i < max_choice; i++) {
212
+			item_set(i + scroll);
213
+			if (toupper(key) == toupper(item_str()[0]))
214
+				break;
215
+		}
216
+
217
+		if (i < max_choice || key == KEY_UP || key == KEY_DOWN ||
218
+		    key == '+' || key == '-') {
219
+			if (key == KEY_UP || key == '-') {
220
+				if (!choice) {
221
+					if (!scroll)
222
+						continue;
223
+					/* Scroll list down */
224
+					if (list_height > 1) {
225
+						/* De-highlight current first item */
226
+						item_set(scroll);
227
+						print_item(list, 0, FALSE);
228
+						scrollok(list, TRUE);
229
+						wscrl(list, -1);
230
+						scrollok(list, FALSE);
231
+					}
232
+					scroll--;
233
+					item_set(scroll);
234
+					print_item(list, 0, TRUE);
235
+					print_arrows(dialog, choice, item_count(),
236
+						     scroll, box_y, box_x + check_x + 5, list_height);
237
+
238
+					wnoutrefresh(dialog);
239
+					wrefresh(list);
240
+
241
+					continue;	/* wait for another key press */
242
+				} else
243
+					i = choice - 1;
244
+			} else if (key == KEY_DOWN || key == '+') {
245
+				if (choice == max_choice - 1) {
246
+					if (scroll + choice >= item_count() - 1)
247
+						continue;
248
+					/* Scroll list up */
249
+					if (list_height > 1) {
250
+						/* De-highlight current last item before scrolling up */
251
+						item_set(scroll + max_choice - 1);
252
+						print_item(list,
253
+							    max_choice - 1,
254
+							    FALSE);
255
+						scrollok(list, TRUE);
256
+						wscrl(list, 1);
257
+						scrollok(list, FALSE);
258
+					}
259
+					scroll++;
260
+					item_set(scroll + max_choice - 1);
261
+					print_item(list, max_choice - 1, TRUE);
262
+
263
+					print_arrows(dialog, choice, item_count(),
264
+						     scroll, box_y, box_x + check_x + 5, list_height);
265
+
266
+					wnoutrefresh(dialog);
267
+					wrefresh(list);
268
+
269
+					continue;	/* wait for another key press */
270
+				} else
271
+					i = choice + 1;
272
+			}
273
+			if (i != choice) {
274
+				/* De-highlight current item */
275
+				item_set(scroll + choice);
276
+				print_item(list, choice, FALSE);
277
+				/* Highlight new item */
278
+				choice = i;
279
+				item_set(scroll + choice);
280
+				print_item(list, choice, TRUE);
281
+				wnoutrefresh(dialog);
282
+				wrefresh(list);
283
+			}
284
+			continue;	/* wait for another key press */
285
+		}
286
+		switch (key) {
287
+		case 'H':
288
+		case 'h':
289
+		case '?':
290
+			button = 1;
291
+			/* fall-through */
292
+		case 'S':
293
+		case 's':
294
+		case ' ':
295
+		case '\n':
296
+			item_foreach()
297
+				item_set_selected(0);
298
+			item_set(scroll + choice);
299
+			item_set_selected(1);
300
+			delwin(list);
301
+			delwin(dialog);
302
+			return button;
303
+		case TAB:
304
+		case KEY_LEFT:
305
+		case KEY_RIGHT:
306
+			button = ((key == KEY_LEFT ? --button : ++button) < 0)
307
+			    ? 1 : (button > 1 ? 0 : button);
308
+
309
+			print_buttons(dialog, height, width, button);
310
+			wrefresh(dialog);
311
+			break;
312
+		case 'X':
313
+		case 'x':
314
+			key = KEY_ESC;
315
+			break;
316
+		case KEY_ESC:
317
+			key = on_key_esc(dialog);
318
+			break;
319
+		case KEY_RESIZE:
320
+			delwin(list);
321
+			delwin(dialog);
322
+			on_key_resize();
323
+			goto do_resize;
324
+		}
325
+
326
+		/* Now, update everything... */
327
+		doupdate();
328
+	}
329
+	delwin(list);
330
+	delwin(dialog);
331
+	return key;		/* ESC pressed */
332
+}

+ 234
- 0
config/kconfig/lxdialog/dialog.h View File

@@ -0,0 +1,234 @@
1
+/*
2
+ *  dialog.h -- common declarations for all dialog modules
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
+#include <sys/types.h>
22
+#include <fcntl.h>
23
+#include <unistd.h>
24
+#include <ctype.h>
25
+#include <stdlib.h>
26
+#include <string.h>
27
+#include <stdbool.h>
28
+
29
+#ifndef KBUILD_NO_NLS
30
+# include <libintl.h>
31
+#else
32
+# define gettext(Msgid) ((const char *) (Msgid))
33
+#endif
34
+
35
+#include "ncurses.h"
36
+
37
+/*
38
+ * Colors in ncurses 1.9.9e do not work properly since foreground and
39
+ * background colors are OR'd rather than separately masked.  This version
40
+ * of dialog was hacked to work with ncurses 1.9.9e, making it incompatible
41
+ * with standard curses.  The simplest fix (to make this work with standard
42
+ * curses) uses the wbkgdset() function, not used in the original hack.
43
+ * Turn it off if we're building with 1.9.9e, since it just confuses things.
44
+ */
45
+#if defined(NCURSES_VERSION) && defined(_NEED_WRAP) && !defined(GCC_PRINTFLIKE)
46
+#define OLD_NCURSES 1
47
+#undef  wbkgdset
48
+#define wbkgdset(w,p)		/*nothing */
49
+#else
50
+#define OLD_NCURSES 0
51
+#endif
52
+
53
+#define TR(params) _tracef params
54
+
55
+#define KEY_ESC 27
56
+#define TAB 9
57
+#define MAX_LEN 2048
58
+#define BUF_SIZE (10*1024)
59
+#define MIN(x,y) (x < y ? x : y)
60
+#define MAX(x,y) (x > y ? x : y)
61
+
62
+#ifndef ACS_ULCORNER
63
+#define ACS_ULCORNER '+'
64
+#endif
65
+#ifndef ACS_LLCORNER
66
+#define ACS_LLCORNER '+'
67
+#endif
68
+#ifndef ACS_URCORNER
69
+#define ACS_URCORNER '+'
70
+#endif
71
+#ifndef ACS_LRCORNER
72
+#define ACS_LRCORNER '+'
73
+#endif
74
+#ifndef ACS_HLINE
75
+#define ACS_HLINE '-'
76
+#endif
77
+#ifndef ACS_VLINE
78
+#define ACS_VLINE '|'
79
+#endif
80
+#ifndef ACS_LTEE
81
+#define ACS_LTEE '+'
82
+#endif
83
+#ifndef ACS_RTEE
84
+#define ACS_RTEE '+'
85
+#endif
86
+#ifndef ACS_UARROW
87
+#define ACS_UARROW '^'
88
+#endif
89
+#ifndef ACS_DARROW
90
+#define ACS_DARROW 'v'
91
+#endif
92
+
93
+/* error return codes */
94
+#define ERRDISPLAYTOOSMALL (KEY_MAX + 1)
95
+
96
+/*
97
+ *   Color definitions
98
+ */
99
+struct dialog_color {
100
+	chtype atr;	/* Color attribute */
101
+	int fg;		/* foreground */
102
+	int bg;		/* background */
103
+	int hl;		/* highlight this item */
104
+};
105
+
106
+struct dialog_info {
107
+	const char *backtitle;
108
+	struct dialog_color screen;
109
+	struct dialog_color shadow;
110
+	struct dialog_color dialog;
111
+	struct dialog_color title;
112
+	struct dialog_color border;
113
+	struct dialog_color button_active;
114
+	struct dialog_color button_inactive;
115
+	struct dialog_color button_key_active;
116
+	struct dialog_color button_key_inactive;
117
+	struct dialog_color button_label_active;
118
+	struct dialog_color button_label_inactive;
119
+	struct dialog_color inputbox;
120
+	struct dialog_color inputbox_border;
121
+	struct dialog_color searchbox;
122
+	struct dialog_color searchbox_title;
123
+	struct dialog_color searchbox_border;
124
+	struct dialog_color position_indicator;
125
+	struct dialog_color menubox;
126
+	struct dialog_color menubox_border;
127
+	struct dialog_color item;
128
+	struct dialog_color item_selected;
129
+	struct dialog_color tag;
130
+	struct dialog_color tag_selected;
131
+	struct dialog_color tag_key;
132
+	struct dialog_color tag_key_selected;
133
+	struct dialog_color check;
134
+	struct dialog_color check_selected;
135
+	struct dialog_color uarrow;
136
+	struct dialog_color darrow;
137
+};
138
+
139
+/*
140
+ * Global variables
141
+ */
142
+extern struct dialog_info dlg;
143
+extern char dialog_input_result[];
144
+extern int saved_x, saved_y;		/* Needed in signal handler in mconf.c */
145
+
146
+/*
147
+ * Function prototypes
148
+ */
149
+
150
+/* item list as used by checklist and menubox */
151
+void item_reset(void);
152
+void item_make(const char *fmt, ...);
153
+void item_add_str(const char *fmt, ...);
154
+void item_set_tag(char tag);
155
+void item_set_data(void *p);
156
+void item_set_selected(int val);
157
+int item_activate_selected(void);
158
+void *item_data(void);
159
+char item_tag(void);
160
+
161
+/* item list manipulation for lxdialog use */
162
+#define MAXITEMSTR 200
163
+struct dialog_item {
164
+	char str[MAXITEMSTR];	/* promtp displayed */
165
+	char tag;
166
+	void *data;	/* pointer to menu item - used by menubox+checklist */
167
+	int selected;	/* Set to 1 by dialog_*() function if selected. */
168
+};
169
+
170
+/* list of lialog_items */
171
+struct dialog_list {
172
+	struct dialog_item node;
173
+	struct dialog_list *next;
174
+};
175
+
176
+extern struct dialog_list *item_cur;
177
+extern struct dialog_list item_nil;
178
+extern struct dialog_list *item_head;
179
+
180
+int item_count(void);
181
+void item_set(int n);
182
+int item_n(void);
183
+const char *item_str(void);
184
+int item_is_selected(void);
185
+int item_is_tag(char tag);
186
+#define item_foreach() \
187
+	for (item_cur = item_head ? item_head: item_cur; \
188
+	     item_cur && (item_cur != &item_nil); item_cur = item_cur->next)
189
+
190
+/* generic key handlers */