conf.c (754451342fc5954061ede74b0a8485ec4a4c6eaa) conf.c (694c49a7c01cc87194be40cb26404b58b68c291c)
1/*
2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
3 * Released under the terms of the GNU GPL v2.0.
4 */
5
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 <limits.h>
9#include <stdio.h>
10#include <stdlib.h>
11#include <string.h>
12#include <time.h>
13#include <unistd.h>
14#include <getopt.h>

--- 66 unchanged lines hidden (view full) ---

81 printf("%s", str);
82}
83
84static int conf_askvalue(struct symbol *sym, const char *def)
85{
86 enum symbol_type type = sym_get_type(sym);
87
88 if (!sym_has_value(sym))
6#include <ctype.h>
7#include <limits.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>

--- 66 unchanged lines hidden (view full) ---

80 printf("%s", str);
81}
82
83static int conf_askvalue(struct symbol *sym, const char *def)
84{
85 enum symbol_type type = sym_get_type(sym);
86
87 if (!sym_has_value(sym))
89 printf(_("(NEW) "));
88 printf("(NEW) ");
90
91 line[0] = '\n';
92 line[1] = 0;
93
94 if (!sym_is_changable(sym)) {
95 printf("%s\n", def);
96 line[0] = '\n';
97 line[1] = 0;

--- 30 unchanged lines hidden (view full) ---

128}
129
130static int conf_string(struct menu *menu)
131{
132 struct symbol *sym = menu->sym;
133 const char *def;
134
135 while (1) {
89
90 line[0] = '\n';
91 line[1] = 0;
92
93 if (!sym_is_changable(sym)) {
94 printf("%s\n", def);
95 line[0] = '\n';
96 line[1] = 0;

--- 30 unchanged lines hidden (view full) ---

127}
128
129static int conf_string(struct menu *menu)
130{
131 struct symbol *sym = menu->sym;
132 const char *def;
133
134 while (1) {
136 printf("%*s%s ", indent - 1, "", _(menu->prompt->text));
135 printf("%*s%s ", indent - 1, "", menu->prompt->text);
137 printf("(%s) ", sym->name);
138 def = sym_get_string_value(sym);
139 if (sym_get_string_value(sym))
140 printf("[%s] ", def);
141 if (!conf_askvalue(sym, def))
142 return 0;
143 switch (line[0]) {
144 case '\n':

--- 16 unchanged lines hidden (view full) ---

161}
162
163static int conf_sym(struct menu *menu)
164{
165 struct symbol *sym = menu->sym;
166 tristate oldval, newval;
167
168 while (1) {
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':

--- 16 unchanged lines hidden (view full) ---

160}
161
162static int conf_sym(struct menu *menu)
163{
164 struct symbol *sym = menu->sym;
165 tristate oldval, newval;
166
167 while (1) {
169 printf("%*s%s ", indent - 1, "", _(menu->prompt->text));
168 printf("%*s%s ", indent - 1, "", menu->prompt->text);
170 if (sym->name)
171 printf("(%s) ", sym->name);
172 putchar('[');
173 oldval = sym_get_tristate_value(sym);
174 switch (oldval) {
175 case no:
176 putchar('N');
177 break;

--- 68 unchanged lines hidden (view full) ---

246 case yes:
247 break;
248 }
249 } else {
250 switch (sym_get_tristate_value(sym)) {
251 case no:
252 return 1;
253 case mod:
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;

--- 68 unchanged lines hidden (view full) ---

245 case yes:
246 break;
247 }
248 } else {
249 switch (sym_get_tristate_value(sym)) {
250 case no:
251 return 1;
252 case mod:
254 printf("%*s%s\n", indent - 1, "", _(menu_get_prompt(menu)));
253 printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu));
255 return 0;
256 case yes:
257 break;
258 }
259 }
260
261 while (1) {
262 int cnt, def;
263
254 return 0;
255 case yes:
256 break;
257 }
258 }
259
260 while (1) {
261 int cnt, def;
262
264 printf("%*s%s\n", indent - 1, "", _(menu_get_prompt(menu)));
263 printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu));
265 def_sym = sym_get_choice_value(sym);
266 cnt = def = 0;
267 line[0] = 0;
268 for (child = menu->list; child; child = child->next) {
269 if (!menu_is_visible(child))
270 continue;
271 if (!child->sym) {
264 def_sym = sym_get_choice_value(sym);
265 cnt = def = 0;
266 line[0] = 0;
267 for (child = menu->list; child; child = child->next) {
268 if (!menu_is_visible(child))
269 continue;
270 if (!child->sym) {
272 printf("%*c %s\n", indent, '*', _(menu_get_prompt(child)));
271 printf("%*c %s\n", indent, '*', menu_get_prompt(child));
273 continue;
274 }
275 cnt++;
276 if (child->sym == def_sym) {
277 def = cnt;
278 printf("%*c", indent, '>');
279 } else
280 printf("%*c", indent, ' ');
272 continue;
273 }
274 cnt++;
275 if (child->sym == def_sym) {
276 def = cnt;
277 printf("%*c", indent, '>');
278 } else
279 printf("%*c", indent, ' ');
281 printf(" %d. %s", cnt, _(menu_get_prompt(child)));
280 printf(" %d. %s", cnt, menu_get_prompt(child));
282 if (child->sym->name)
283 printf(" (%s)", child->sym->name);
284 if (!sym_has_value(child->sym))
281 if (child->sym->name)
282 printf(" (%s)", child->sym->name);
283 if (!sym_has_value(child->sym))
285 printf(_(" (NEW)"));
284 printf(" (NEW)");
286 printf("\n");
287 }
285 printf("\n");
286 }
288 printf(_("%*schoice"), indent - 1, "");
287 printf("%*schoice", indent - 1, "");
289 if (cnt == 1) {
290 printf("[1]: 1\n");
291 goto conf_childs;
292 }
293 printf("[1-%d?]: ", cnt);
294 switch (input_mode) {
295 case oldconfig:
296 case syncconfig:

--- 70 unchanged lines hidden (view full) ---

367 return;
368 }
369 /* fall through */
370 case P_COMMENT:
371 prompt = menu_get_prompt(menu);
372 if (prompt)
373 printf("%*c\n%*c %s\n%*c\n",
374 indent, '*',
288 if (cnt == 1) {
289 printf("[1]: 1\n");
290 goto conf_childs;
291 }
292 printf("[1-%d?]: ", cnt);
293 switch (input_mode) {
294 case oldconfig:
295 case syncconfig:

--- 70 unchanged lines hidden (view full) ---

366 return;
367 }
368 /* fall through */
369 case P_COMMENT:
370 prompt = menu_get_prompt(menu);
371 if (prompt)
372 printf("%*c\n%*c %s\n%*c\n",
373 indent, '*',
375 indent, '*', _(prompt),
374 indent, '*', prompt,
376 indent, '*');
377 default:
378 ;
379 }
380 }
381
382 if (!sym)
383 goto conf_childs;

--- 48 unchanged lines hidden (view full) ---

432 free((void *)str);
433 } else {
434 str = sym_get_string_value(sym);
435 printf("%s%s=%s\n", CONFIG_, sym->name, str);
436 }
437 }
438 } else {
439 if (!conf_cnt++)
375 indent, '*');
376 default:
377 ;
378 }
379 }
380
381 if (!sym)
382 goto conf_childs;

--- 48 unchanged lines hidden (view full) ---

431 free((void *)str);
432 } else {
433 str = sym_get_string_value(sym);
434 printf("%s%s=%s\n", CONFIG_, sym->name, str);
435 }
436 }
437 } else {
438 if (!conf_cnt++)
440 printf(_("*\n* Restart config...\n*\n"));
439 printf("*\n* Restart config...\n*\n");
441 rootEntry = menu_get_parent_menu(menu);
442 conf(rootEntry);
443 }
444 }
445 }
446
447 for (child = menu->list; child; child = child->next)
448 check_conf(child);

--- 44 unchanged lines hidden (view full) ---

493
494int main(int ac, char **av)
495{
496 const char *progname = av[0];
497 int opt;
498 const char *name, *defconfig_file = NULL /* gcc uninit */;
499 struct stat tmpstat;
500
440 rootEntry = menu_get_parent_menu(menu);
441 conf(rootEntry);
442 }
443 }
444 }
445
446 for (child = menu->list; child; child = child->next)
447 check_conf(child);

--- 44 unchanged lines hidden (view full) ---

492
493int main(int ac, char **av)
494{
495 const char *progname = av[0];
496 int opt;
497 const char *name, *defconfig_file = NULL /* gcc uninit */;
498 struct stat tmpstat;
499
501 setlocale(LC_ALL, "");
502 bindtextdomain(PACKAGE, LOCALEDIR);
503 textdomain(PACKAGE);
504
505 tty_stdio = isatty(0) && isatty(1);
506
507 while ((opt = getopt_long(ac, av, "s", long_opts, NULL)) != -1) {
508 if (opt == 's') {
509 conf_set_message_callback(NULL);
510 continue;
511 }
512 input_mode = (enum input_mode)opt;

--- 41 unchanged lines hidden (view full) ---

554 break;
555 case '?':
556 conf_usage(progname);
557 exit(1);
558 break;
559 }
560 }
561 if (ac == optind) {
500 tty_stdio = isatty(0) && isatty(1);
501
502 while ((opt = getopt_long(ac, av, "s", long_opts, NULL)) != -1) {
503 if (opt == 's') {
504 conf_set_message_callback(NULL);
505 continue;
506 }
507 input_mode = (enum input_mode)opt;

--- 41 unchanged lines hidden (view full) ---

549 break;
550 case '?':
551 conf_usage(progname);
552 exit(1);
553 break;
554 }
555 }
556 if (ac == optind) {
562 fprintf(stderr, _("%s: Kconfig file missing\n"), av[0]);
557 fprintf(stderr, "%s: Kconfig file missing\n", av[0]);
563 conf_usage(progname);
564 exit(1);
565 }
566 name = av[optind];
567 conf_parse(name);
568 //zconfdump(stdout);
569 if (sync_kconfig) {
570 name = conf_get_configname();
571 if (stat(name, &tmpstat)) {
558 conf_usage(progname);
559 exit(1);
560 }
561 name = av[optind];
562 conf_parse(name);
563 //zconfdump(stdout);
564 if (sync_kconfig) {
565 name = conf_get_configname();
566 if (stat(name, &tmpstat)) {
572 fprintf(stderr, _("***\n"
567 fprintf(stderr, "***\n"
573 "*** Configuration file \"%s\" not found!\n"
574 "***\n"
575 "*** Please run some configurator (e.g. \"make oldconfig\" or\n"
576 "*** \"make menuconfig\" or \"make xconfig\").\n"
568 "*** Configuration file \"%s\" not found!\n"
569 "***\n"
570 "*** Please run some configurator (e.g. \"make oldconfig\" or\n"
571 "*** \"make menuconfig\" or \"make xconfig\").\n"
577 "***\n"), name);
572 "***\n", name);
578 exit(1);
579 }
580 }
581
582 switch (input_mode) {
583 case defconfig:
584 if (!defconfig_file)
585 defconfig_file = conf_get_default_confname();
586 if (conf_read(defconfig_file)) {
587 fprintf(stderr,
573 exit(1);
574 }
575 }
576
577 switch (input_mode) {
578 case defconfig:
579 if (!defconfig_file)
580 defconfig_file = conf_get_default_confname();
581 if (conf_read(defconfig_file)) {
582 fprintf(stderr,
588 _("***\n"
583 "***\n"
589 "*** Can't find default configuration \"%s\"!\n"
584 "*** Can't find default configuration \"%s\"!\n"
590 "***\n"),
585 "***\n",
591 defconfig_file);
592 exit(1);
593 }
594 break;
595 case savedefconfig:
596 case syncconfig:
597 case oldaskconfig:
598 case oldconfig:

--- 7 unchanged lines hidden (view full) ---

606 case alldefconfig:
607 case randconfig:
608 name = getenv("KCONFIG_ALLCONFIG");
609 if (!name)
610 break;
611 if ((strcmp(name, "") != 0) && (strcmp(name, "1") != 0)) {
612 if (conf_read_simple(name, S_DEF_USER)) {
613 fprintf(stderr,
586 defconfig_file);
587 exit(1);
588 }
589 break;
590 case savedefconfig:
591 case syncconfig:
592 case oldaskconfig:
593 case oldconfig:

--- 7 unchanged lines hidden (view full) ---

601 case alldefconfig:
602 case randconfig:
603 name = getenv("KCONFIG_ALLCONFIG");
604 if (!name)
605 break;
606 if ((strcmp(name, "") != 0) && (strcmp(name, "1") != 0)) {
607 if (conf_read_simple(name, S_DEF_USER)) {
608 fprintf(stderr,
614 _("*** Can't read seed configuration \"%s\"!\n"),
609 "*** Can't read seed configuration \"%s\"!\n",
615 name);
616 exit(1);
617 }
618 break;
619 }
620 switch (input_mode) {
621 case allnoconfig: name = "allno.config"; break;
622 case allyesconfig: name = "allyes.config"; break;
623 case allmodconfig: name = "allmod.config"; break;
624 case alldefconfig: name = "alldef.config"; break;
625 case randconfig: name = "allrandom.config"; break;
626 default: break;
627 }
628 if (conf_read_simple(name, S_DEF_USER) &&
629 conf_read_simple("all.config", S_DEF_USER)) {
630 fprintf(stderr,
610 name);
611 exit(1);
612 }
613 break;
614 }
615 switch (input_mode) {
616 case allnoconfig: name = "allno.config"; break;
617 case allyesconfig: name = "allyes.config"; break;
618 case allmodconfig: name = "allmod.config"; break;
619 case alldefconfig: name = "alldef.config"; break;
620 case randconfig: name = "allrandom.config"; break;
621 default: break;
622 }
623 if (conf_read_simple(name, S_DEF_USER) &&
624 conf_read_simple("all.config", S_DEF_USER)) {
625 fprintf(stderr,
631 _("*** KCONFIG_ALLCONFIG set, but no \"%s\" or \"all.config\" file found\n"),
626 "*** KCONFIG_ALLCONFIG set, but no \"%s\" or \"all.config\" file found\n",
632 name);
633 exit(1);
634 }
635 break;
636 default:
637 break;
638 }
639
640 if (sync_kconfig) {
641 if (conf_get_changed()) {
642 name = getenv("KCONFIG_NOSILENTUPDATE");
643 if (name && *name) {
644 fprintf(stderr,
627 name);
628 exit(1);
629 }
630 break;
631 default:
632 break;
633 }
634
635 if (sync_kconfig) {
636 if (conf_get_changed()) {
637 name = getenv("KCONFIG_NOSILENTUPDATE");
638 if (name && *name) {
639 fprintf(stderr,
645 _("\n*** The configuration requires explicit update.\n\n"));
640 "\n*** The configuration requires explicit update.\n\n");
646 return 1;
647 }
648 }
649 }
650
651 switch (input_mode) {
652 case allnoconfig:
653 conf_set_all_new_symbols(def_no);

--- 35 unchanged lines hidden (view full) ---

689 break;
690 }
691
692 if (sync_kconfig) {
693 /* syncconfig is used during the build so we shall update autoconf.
694 * All other commands are only used to generate a config.
695 */
696 if (conf_get_changed() && conf_write(NULL)) {
641 return 1;
642 }
643 }
644 }
645
646 switch (input_mode) {
647 case allnoconfig:
648 conf_set_all_new_symbols(def_no);

--- 35 unchanged lines hidden (view full) ---

684 break;
685 }
686
687 if (sync_kconfig) {
688 /* syncconfig is used during the build so we shall update autoconf.
689 * All other commands are only used to generate a config.
690 */
691 if (conf_get_changed() && conf_write(NULL)) {
697 fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n"));
692 fprintf(stderr, "\n*** Error during writing of the configuration.\n\n");
698 exit(1);
699 }
700 if (conf_write_autoconf()) {
693 exit(1);
694 }
695 if (conf_write_autoconf()) {
701 fprintf(stderr, _("\n*** Error during update of the configuration.\n\n"));
696 fprintf(stderr, "\n*** Error during update of the configuration.\n\n");
702 return 1;
703 }
704 } else if (input_mode == savedefconfig) {
705 if (conf_write_defconfig(defconfig_file)) {
697 return 1;
698 }
699 } else if (input_mode == savedefconfig) {
700 if (conf_write_defconfig(defconfig_file)) {
706 fprintf(stderr, _("n*** Error while saving defconfig to: %s\n\n"),
701 fprintf(stderr, "n*** Error while saving defconfig to: %s\n\n",
707 defconfig_file);
708 return 1;
709 }
710 } else if (input_mode != listnewconfig) {
711 if (conf_write(NULL)) {
702 defconfig_file);
703 return 1;
704 }
705 } else if (input_mode != listnewconfig) {
706 if (conf_write(NULL)) {
712 fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n"));
707 fprintf(stderr, "\n*** Error during writing of the configuration.\n\n");
713 exit(1);
714 }
715 }
716 return 0;
717}
708 exit(1);
709 }
710 }
711 return 0;
712}