aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--scripts/kconfig/confdata.c35
-rw-r--r--scripts/kconfig/lkc_proto.h2
-rw-r--r--scripts/kconfig/nconf.c51
3 files changed, 40 insertions, 48 deletions
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 96110ea41cf3..9df80114b47b 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -19,6 +19,9 @@
19static void conf_warning(const char *fmt, ...) 19static void conf_warning(const char *fmt, ...)
20 __attribute__ ((format (printf, 1, 2))); 20 __attribute__ ((format (printf, 1, 2)));
21 21
22static void conf_message(const char *fmt, ...)
23 __attribute__ ((format (printf, 1, 2)));
24
22static const char *conf_filename; 25static const char *conf_filename;
23static int conf_lineno, conf_warnings, conf_unsaved; 26static int conf_lineno, conf_warnings, conf_unsaved;
24 27
@@ -35,6 +38,29 @@ static void conf_warning(const char *fmt, ...)
35 conf_warnings++; 38 conf_warnings++;
36} 39}
37 40
41static void conf_default_message_callback(const char *fmt, va_list ap)
42{
43 printf("#\n# ");
44 vprintf(fmt, ap);
45 printf("\n#\n");
46}
47
48static void (*conf_message_callback) (const char *fmt, va_list ap) =
49 conf_default_message_callback;
50void conf_set_message_callback(void (*fn) (const char *fmt, va_list ap))
51{
52 conf_message_callback = fn;
53}
54
55static void conf_message(const char *fmt, ...)
56{
57 va_list ap;
58
59 va_start(ap, fmt);
60 if (conf_message_callback)
61 conf_message_callback(fmt, ap);
62}
63
38const char *conf_get_configname(void) 64const char *conf_get_configname(void)
39{ 65{
40 char *name = getenv("KCONFIG_CONFIG"); 66 char *name = getenv("KCONFIG_CONFIG");
@@ -184,9 +210,8 @@ int conf_read_simple(const char *name, int def)
184 name = conf_expand_value(prop->expr->left.sym->name); 210 name = conf_expand_value(prop->expr->left.sym->name);
185 in = zconf_fopen(name); 211 in = zconf_fopen(name);
186 if (in) { 212 if (in) {
187 printf(_("#\n" 213 conf_message(_("using defaults found in %s"),
188 "# using defaults found in %s\n" 214 name);
189 "#\n"), name);
190 goto load; 215 goto load;
191 } 216 }
192 } 217 }
@@ -642,9 +667,7 @@ next:
642 return 1; 667 return 1;
643 } 668 }
644 669
645 printf(_("#\n" 670 conf_message(_("configuration written to %s"), newname);
646 "# configuration written to %s\n"
647 "#\n"), newname);
648 671
649 sym_set_change_count(0); 672 sym_set_change_count(0);
650 673
diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h
index 4531badb3fe1..17342fef38b9 100644
--- a/scripts/kconfig/lkc_proto.h
+++ b/scripts/kconfig/lkc_proto.h
@@ -1,3 +1,4 @@
1#include <stdarg.h>
1 2
2/* confdata.c */ 3/* confdata.c */
3P(conf_parse,void,(const char *name)); 4P(conf_parse,void,(const char *name));
@@ -8,6 +9,7 @@ P(conf_write,int,(const char *name));
8P(conf_write_autoconf,int,(void)); 9P(conf_write_autoconf,int,(void));
9P(conf_get_changed,bool,(void)); 10P(conf_get_changed,bool,(void));
10P(conf_set_changed_callback, void,(void (*fn)(void))); 11P(conf_set_changed_callback, void,(void (*fn)(void)));
12P(conf_set_message_callback, void,(void (*fn)(const char *fmt, va_list ap)));
11 13
12/* menu.c */ 14/* menu.c */
13P(rootmenu,struct menu,); 15P(rootmenu,struct menu,);
diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c
index a2969fdc66b4..272a987f23e0 100644
--- a/scripts/kconfig/nconf.c
+++ b/scripts/kconfig/nconf.c
@@ -645,25 +645,6 @@ static const char *set_config_filename(const char *config_filename)
645 return menu_backtitle; 645 return menu_backtitle;
646} 646}
647 647
648/* command = 0 is supress, 1 is restore */
649static void supress_stdout(int command)
650{
651 static FILE *org_stdout;
652 static FILE *org_stderr;
653
654 if (command == 0) {
655 org_stdout = stdout;
656 org_stderr = stderr;
657 stdout = fopen("/dev/null", "a");
658 stderr = fopen("/dev/null", "a");
659 } else {
660 fclose(stdout);
661 fclose(stderr);
662 stdout = org_stdout;
663 stderr = org_stderr;
664 }
665}
666
667/* return = 0 means we are successful. 648/* return = 0 means we are successful.
668 * -1 means go on doing what you were doing 649 * -1 means go on doing what you were doing
669 */ 650 */
@@ -688,9 +669,7 @@ static int do_exit(void)
688 /* if we got here, the user really wants to exit */ 669 /* if we got here, the user really wants to exit */
689 switch (res) { 670 switch (res) {
690 case 0: 671 case 0:
691 supress_stdout(0);
692 res = conf_write(filename); 672 res = conf_write(filename);
693 supress_stdout(1);
694 if (res) 673 if (res)
695 btn_dialog( 674 btn_dialog(
696 main_window, 675 main_window,
@@ -698,19 +677,6 @@ static int do_exit(void)
698 "Your configuration changes were NOT saved."), 677 "Your configuration changes were NOT saved."),
699 1, 678 1,
700 "<OK>"); 679 "<OK>");
701 else {
702 char buf[1024];
703 snprintf(buf, 1024,
704 _("Configuration written to %s\n"
705 "End of the configuration.\n"
706 "Execute 'make' to start the build or try"
707 " 'make help'."), filename);
708 btn_dialog(
709 main_window,
710 buf,
711 1,
712 "<OK>");
713 }
714 break; 680 break;
715 default: 681 default:
716 btn_dialog( 682 btn_dialog(
@@ -1246,6 +1212,14 @@ static void conf(struct menu *menu)
1246 } 1212 }
1247} 1213}
1248 1214
1215static void conf_message_callback(const char *fmt, va_list ap)
1216{
1217 char buf[1024];
1218
1219 vsnprintf(buf, sizeof(buf), fmt, ap);
1220 btn_dialog(main_window, buf, 1, "<OK>");
1221}
1222
1249static void show_help(struct menu *menu) 1223static void show_help(struct menu *menu)
1250{ 1224{
1251 struct gstr help = str_new(); 1225 struct gstr help = str_new();
@@ -1470,16 +1444,8 @@ static void conf_save(void)
1470 case 0: 1444 case 0:
1471 if (!dialog_input_result[0]) 1445 if (!dialog_input_result[0])
1472 return; 1446 return;
1473 supress_stdout(0);
1474 res = conf_write(dialog_input_result); 1447 res = conf_write(dialog_input_result);
1475 supress_stdout(1);
1476 if (!res) { 1448 if (!res) {
1477 char buf[1024];
1478 sprintf(buf, "%s %s",
1479 _("configuration file saved to: "),
1480 dialog_input_result);
1481 btn_dialog(main_window,
1482 buf, 1, "<OK>");
1483 set_config_filename(dialog_input_result); 1449 set_config_filename(dialog_input_result);
1484 return; 1450 return;
1485 } 1451 }
@@ -1572,6 +1538,7 @@ int main(int ac, char **av)
1572 _(menu_no_f_instructions)); 1538 _(menu_no_f_instructions));
1573 } 1539 }
1574 1540
1541 conf_set_message_callback(conf_message_callback);
1575 /* do the work */ 1542 /* do the work */
1576 while (!global_exit) { 1543 while (!global_exit) {
1577 conf(&rootmenu); 1544 conf(&rootmenu);