diff options
author | Ladislav Michl <ladis@linux-mips.org> | 2007-12-17 13:07:41 -0500 |
---|---|---|
committer | Sam Ravnborg <sam@ravnborg.org> | 2008-01-28 17:14:37 -0500 |
commit | 09af091f50409a60a72086c737b9a6224dde5ab8 (patch) | |
tree | 5a022543e70fffee0807d38076555f824d0549e6 /scripts/kconfig/mconf.c | |
parent | 0486bc9098f4556a0aa90d57f717d08164b7647e (diff) |
kconfig: make kconfig MinGW friendly
Kconfig is powerfull tool. So powerfull that more and more software
projects are using it for configuration. So instead of fixing some of
them one by one, lets fix it in kernel and wait for sync.
This work was originaly done for PTXdist - GPL licensed build system for
userlands and cross-compilers, but it will not hurt kernel kconfig
either. PTXdist menuconfig now works on Windows linked with PDCurses and
compiled using MinGW - there is no termios and signals.
* Do not include <sys/wait.h> and <signal.h> (comes from times when
lxdialog was separate process)
* Do not mess with termios directly and let curses tell screen size.
Comment to commit c8dc68ad0fbd934e78e913b8a8d7b45945db4930 says
check for screen size could be removed later, but because it didn't
happen for more than year I left it here as well.
* Save cursor position added by Sam
Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Roman Zippel <zippel@linux-m68k.org>
Diffstat (limited to 'scripts/kconfig/mconf.c')
-rw-r--r-- | scripts/kconfig/mconf.c | 61 |
1 files changed, 9 insertions, 52 deletions
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index 47e226fdedd7..ee9ed3059472 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c | |||
@@ -8,17 +8,13 @@ | |||
8 | * i18n, 2005, Arnaldo Carvalho de Melo <acme@conectiva.com.br> | 8 | * i18n, 2005, Arnaldo Carvalho de Melo <acme@conectiva.com.br> |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <sys/ioctl.h> | ||
12 | #include <sys/wait.h> | ||
13 | #include <ctype.h> | 11 | #include <ctype.h> |
14 | #include <errno.h> | 12 | #include <errno.h> |
15 | #include <fcntl.h> | 13 | #include <fcntl.h> |
16 | #include <limits.h> | 14 | #include <limits.h> |
17 | #include <signal.h> | ||
18 | #include <stdarg.h> | 15 | #include <stdarg.h> |
19 | #include <stdlib.h> | 16 | #include <stdlib.h> |
20 | #include <string.h> | 17 | #include <string.h> |
21 | #include <termios.h> | ||
22 | #include <unistd.h> | 18 | #include <unistd.h> |
23 | #include <locale.h> | 19 | #include <locale.h> |
24 | 20 | ||
@@ -275,8 +271,6 @@ search_help[] = N_( | |||
275 | "\n"); | 271 | "\n"); |
276 | 272 | ||
277 | static int indent; | 273 | static int indent; |
278 | static struct termios ios_org; | ||
279 | static int rows = 0, cols = 0; | ||
280 | static struct menu *current_menu; | 274 | static struct menu *current_menu; |
281 | static int child_count; | 275 | static int child_count; |
282 | static int single_menu_mode; | 276 | static int single_menu_mode; |
@@ -290,41 +284,6 @@ static void show_textbox(const char *title, const char *text, int r, int c); | |||
290 | static void show_helptext(const char *title, const char *text); | 284 | static void show_helptext(const char *title, const char *text); |
291 | static void show_help(struct menu *menu); | 285 | static void show_help(struct menu *menu); |
292 | 286 | ||
293 | static void init_wsize(void) | ||
294 | { | ||
295 | struct winsize ws; | ||
296 | char *env; | ||
297 | |||
298 | if (!ioctl(STDIN_FILENO, TIOCGWINSZ, &ws)) { | ||
299 | rows = ws.ws_row; | ||
300 | cols = ws.ws_col; | ||
301 | } | ||
302 | |||
303 | if (!rows) { | ||
304 | env = getenv("LINES"); | ||
305 | if (env) | ||
306 | rows = atoi(env); | ||
307 | if (!rows) | ||
308 | rows = 24; | ||
309 | } | ||
310 | if (!cols) { | ||
311 | env = getenv("COLUMNS"); | ||
312 | if (env) | ||
313 | cols = atoi(env); | ||
314 | if (!cols) | ||
315 | cols = 80; | ||
316 | } | ||
317 | |||
318 | if (rows < 19 || cols < 80) { | ||
319 | fprintf(stderr, N_("Your display is too small to run Menuconfig!\n")); | ||
320 | fprintf(stderr, N_("It must be at least 19 lines by 80 columns.\n")); | ||
321 | exit(1); | ||
322 | } | ||
323 | |||
324 | rows -= 4; | ||
325 | cols -= 5; | ||
326 | } | ||
327 | |||
328 | static void get_prompt_str(struct gstr *r, struct property *prop) | 287 | static void get_prompt_str(struct gstr *r, struct property *prop) |
329 | { | 288 | { |
330 | int i, j; | 289 | int i, j; |
@@ -900,13 +859,9 @@ static void conf_save(void) | |||
900 | } | 859 | } |
901 | } | 860 | } |
902 | 861 | ||
903 | static void conf_cleanup(void) | ||
904 | { | ||
905 | tcsetattr(1, TCSAFLUSH, &ios_org); | ||
906 | } | ||
907 | |||
908 | int main(int ac, char **av) | 862 | int main(int ac, char **av) |
909 | { | 863 | { |
864 | int saved_x, saved_y; | ||
910 | char *mode; | 865 | char *mode; |
911 | int res; | 866 | int res; |
912 | 867 | ||
@@ -923,11 +878,13 @@ int main(int ac, char **av) | |||
923 | single_menu_mode = 1; | 878 | single_menu_mode = 1; |
924 | } | 879 | } |
925 | 880 | ||
926 | tcgetattr(1, &ios_org); | 881 | getyx(stdscr, saved_y, saved_x); |
927 | atexit(conf_cleanup); | 882 | if (init_dialog(NULL)) { |
928 | init_wsize(); | 883 | fprintf(stderr, N_("Your display is too small to run Menuconfig!\n")); |
929 | reset_dialog(); | 884 | fprintf(stderr, N_("It must be at least 19 lines by 80 columns.\n")); |
930 | init_dialog(NULL); | 885 | return 1; |
886 | } | ||
887 | |||
931 | set_config_filename(conf_get_configname()); | 888 | set_config_filename(conf_get_configname()); |
932 | do { | 889 | do { |
933 | conf(&rootmenu); | 890 | conf(&rootmenu); |
@@ -941,7 +898,7 @@ int main(int ac, char **av) | |||
941 | else | 898 | else |
942 | res = -1; | 899 | res = -1; |
943 | } while (res == KEY_ESC); | 900 | } while (res == KEY_ESC); |
944 | end_dialog(); | 901 | end_dialog(saved_x, saved_y); |
945 | 902 | ||
946 | switch (res) { | 903 | switch (res) { |
947 | case 0: | 904 | case 0: |