home *** CD-ROM | disk | FTP | other *** search
- /*
- * Display the setup menu, prompts for a bunch of other menus. A return
- * code of 1 means we have to restart the input routine.
- */
-
- #include <stdio.h>
- #include <curses.h>
- #include "config.h"
- #include "misc.h"
-
- int
- setup_menu()
- {
- extern int fd, xmc;
- WINDOW *s_win, *newwin();
- char *ans, *get_str();
- int param_flag, modem_flag, ret_code;
- void top_line();
-
- s_win = newwin(23, 80, 0, 0);
-
- top_line(s_win);
- mvwaddstr(s_win, 4, 30, "1) TTY Setup");
- mvwaddstr(s_win, 6, 30, "2) Modem Setup");
- mvwaddstr(s_win, 8, 30, "3) Terminal Setup");
- mvwaddstr(s_win, 10, 30, "4) General Setup");
- mvwaddstr(s_win, 12, 30, "5) ASCII Transfer Setup");
- mvwaddstr(s_win, 14, 30, "S) Save setup to disk");
- horizontal(s_win, 19, 0, 80);
- mvwattrstr(s_win, 20, 0, A_BOLD, "OPTION ==> ");
- mvwaddstr(s_win, 20, 58, " Press <ESC> to exit");
- wmove(s_win, 20, 12);
- touchwin(s_win);
- wrefresh(s_win);
-
- param_flag = 0;
- modem_flag = 0;
- ret_code = 0;
- /* get the options */
- while ((ans = get_str(s_win, 1, "12345Ss", "")) != NULL) {
- if (xmc > 0) {
- clear_line(s_win, 0, 0, 0);
- wrefresh(s_win);
- }
- switch (*ans) {
- case '1':
- if (tty_setup())
- modem_flag++;
- break;
- case '2':
- if (modem_setup())
- modem_flag++;
- break;
- case '3':
- if (ret_code = term_setup()) {
- ret_code--;
- param_flag++;
- }
- break;
- case '4':
- if (gen_setup())
- param_flag++;
- break;
- case '5':
- if (axfer_setup())
- param_flag++;
- break;
- case 's':
- case 'S':
- if (xmc > 0)
- top_line(s_win);
- if (param_flag || modem_flag) {
- wmove(s_win, 22, 27);
- /*
- * Writes to disk are not critical,
- * the changes are made in memory.
- */
- if (param_flag) {
- wattrstr(s_win, A_BLINK, "Updating Parameter File");
- wrefresh(s_win);
- wait_key(s_win, 3);
- if (up_param()) {
- touchwin(s_win);
- wrefresh(s_win);
- }
- }
- if (modem_flag) {
- wattrstr(s_win, A_BLINK, "Updating Modem Database");
- wrefresh(s_win);
- wait_key(s_win, 3);
- if (up_modem()) {
- touchwin(s_win);
- wrefresh(s_win);
- }
- }
- clear_line(s_win, 22, 27, 0);
- wrefresh(s_win);
- }
- break;
- default:
- beep();
- }
- touchwin(s_win);
- if (xmc > 0)
- top_line(s_win);
-
- mvwaddch(s_win, 20, 12, (chtype) ' ');
- wmove(s_win, 20, 12);
- wrefresh(s_win);
- }
- if (fd == -1) {
- werase(s_win);
- wrefresh(s_win);
- }
- delwin(s_win);
- return(ret_code);
- }
-
- /*
- * Put the top line on the window.
- */
-
- void
- top_line(win)
- WINDOW *win;
- {
- clear_line(win, 0, 0, 0);
- wrefresh(win);
- horizontal(win, 0, 0, 33);
- mvwattrstr(win, 0, 34, A_BOLD, "Setup Menu");
- horizontal(win, 0, 45, 34);
- wrefresh(win);
- return;
- }
-