📄 ttyprocs.c
字号:
tty_logfile_proc(){ FILE *tmp; char temp[162], *editor, *file; if (arg_no == 1) /* command without arguments */ switch (get_com(logfile_tbl1, arg[0])) { case 'd': /* done */ switch_to_control(); return; case 'l': /* display logs */ editor = getenv("EDITOR"); if (editor == NULL) editor = "view"; /* use "view" as the default editor */ switch (tty_logfile) { case 'e': /* error logs */ (void)sprintf(temp, "%s %s", editor, error_file); break; case 'i': /* info. logs */ (void)sprintf(temp, "%s %s", editor, info_file); break; case 'u': /* UNIX logs */ (void)sprintf(temp, "%s %s", editor, "/usr/adm/messages"); break; default: /* for safty sake */ return; } nl(); (void)system(temp); (void)wrefresh(curscr); nonl(); break; case 'r': /* remove logs */ switch (tty_logfile) { case 'e': /* error logs */ (void)fclose(error_fp); if (unlink(error_file) != 0) tty_message("Error logs not removed!"); error_fp = fopen(error_file, "a"); break; case 'i': /* info. logs */ (void)fclose(info_fp); if (unlink(info_file) != 0) tty_message("Info. logs not removed!"); error_fp = fopen(error_file, "a"); break; case 'u': /* UNIX logs */ if ((tmp=fopen("/usr/adm/messages", "w")) != NULL) (void)fclose(tmp);/* reopen for writing(truncated) */ else tty_message("UNIX logs not removed!"); break; default: /* for safty sake */ break; } break; case 'p': /* print logs */ file = NULL; switch (tty_logfile) { case 'e': /* error logs */ file = error_file; break; case 'i': /* info. logs */ file = info_file; break; case 'u': /* UNIX logs */ file = "/usr/adm/messages"; break; default: /* for safty sake */ break; } if (file != NULL) { (void)sprintf(temp, "fold %s | lpr -p -P%s -T %s", file, printer_name, file); (void)system(temp); } break; case 'h': /* help */ tty_help(); break; default: tty_message(com_err); return; } else if (arg_no == 2) /* command with one argument */ switch (get_com(logfile_tbl2, arg[0])) { case 'm': /* name command */ switch (get_com(logfile_tbl3, arg[1])) { case 'e': /* error logs */ tty_logfile = 'e'; break; case 'i': /* info. logs */ tty_logfile = 'i'; break; case 'u': /* UNIX logs */ tty_logfile = 'u'; break; default: tty_message(com_err); return; } (void)sprintf(temp, "[NAME(m)]: %s", tty_logfile=='e'? "ERROR [INFO(i)/UNIX(u)]": (tty_logfile=='i'? "INFO [UNIX(u)/ERROR(e)]":"UNIX [ERROR(e)/INFO(i)]")); mvwaddstr(tty_other, 5, LOGFILE_COL-6, temp); (void)wrefresh(tty_other); (void)refresh(); /* restore the cursor */ break; default: tty_message(com_err); break; } else tty_message(format_err);}/****************************************************************************** * tty_test_opt_proc, the tty version of the test option procedure. * * input: arg[0](device name), and arg[1]("o", or "option"). * ******************************************************************************/tty_test_opt_proc(devname, option)char *devname, *option;{ int test_id; if (strcmp(option, "option") != 0 && strcmp(option, "o") != 0) { tty_message(com_err); return; } for (test_id=0; test_id != exist_tests; ++test_id) /* gone through all existing devices to find the specified device */ if (strcmp(devname, tests[test_id]->devname) == 0) break; if (test_id == exist_tests) /* unknown test */ { tty_message(com_err); return; } if (!tests[test_id]->popup) /* no option popup for this test */ { tty_message("No option menu for this device!"); return; } option_id = test_id; window_type = OPTION_TTY; (void)wclear(tty_option); panel_printf((Panel_item)0, "[DEFAULT(f)] [DONE(d)] [HELP(h)]", 1, -2); (void)init_opt_panel(test_id); /* initialize and display the rest */}/****************************************************************************** * tty_help, the tty version of the on-line help. * ******************************************************************************/tty_help(){ tty_message("The HELP command is not implemented yet!");}/****************************************************************************** * init_tty_windows, initializes the control/status window arrays to NULL. * ******************************************************************************/init_tty_windows(){ int i; for (i=0; i != TTY_WINNO; ++i) { tty_control[i] = NULL; tty_status[i] = NULL; }}/****************************************************************************** * tty_eeprom(), display the eeprom tool. * ******************************************************************************/#define EEPROM_COL1 10#define EEPROM_COL2 44tty_eeprom(){#ifndef sun386 char *true, *false; char *tmp; int row;#ifdef sun4 /* Check for Sun4c */ if ( cpu_is_sun4c() ) return;#endif sun4 mvwaddstr(tty_other, 0, 24, "<< EEPROM Option Menu >>"); mvwaddstr(tty_other, 2, 24, "[DEFAULT(f)] [DONE(d)] [CANCEL(c)] [HELP(h)]"); mvwprintw(tty_other, 4, 24, "LASTUPDATE: %-32s",hwupdate_file); true = "True"; false = "False"; row = 6; (void)mvwprintw(tty_other, row++, EEPROM_COL1, "[ASSERTSCSIA(a)]: %-7s", ttya_rtsdtr_file?true:false); (void)mvwprintw(tty_other, row++, EEPROM_COL1, "[ASSERTSCSIB(b)]: %-7s", ttyb_rtsdtr_file?true:false); switch(console_file) { case 1: tmp = "ttya "; break; case 2: tmp = "ttyb "; break; case 3: tmp = "VME fb "; break; case 4: tmp = "P4 fb "; break; default: tmp = "on-board fb"; } (void)mvwprintw(tty_other, row++, EEPROM_COL1, "[CONSOLETYPE(x)]: %-5s", tmp); switch(scrsize_file) { case 1: tmp = "1152x900"; break; case 2: tmp = "1600x1280"; break; case 3: tmp = "1440x1440"; break; default: tmp = "1024x1024"; } (void)mvwprintw(tty_other, row++, EEPROM_COL1, "[SCREENSIZE(z)]: %-9s", tmp); (void)mvwprintw(tty_other, row++, EEPROM_COL1, "[KEYCLICK(k)]: %-7s", keyclick_file?true:false); (void)mvwprintw(tty_other, row++, EEPROM_COL1, "[WATCHDOGREBOOT(w)]: %-7s", watchdog_reboot_file?true:false); switch(default_boot_file) { case 1: tmp = "eeprom"; break; default: tmp = "poll"; } (void)mvwprintw(tty_other, row++, EEPROM_COL1, "[UNIXBOOTPATH(u)]: %-7s", tmp); (void)mvwprintw(tty_other, row++, EEPROM_COL1, "[UNIXBOOTDEVICE(o)]: %-9s", bootdev_file); (void)mvwprintw(tty_other, row++, EEPROM_COL1, "[CUSTOMLOGO(l)]: %-7s", custom_banner_file?true:false); (void)mvwprintw(tty_other, row++, EEPROM_COL1, "[BANNERSTRING(s)]: %-40s", banner_file); (void)mvwprintw(tty_other, row++, EEPROM_COL1, "[DIAGBOOTPATH(p)]: %-40s", diagpath_file); row = 6; (void)mvwprintw(tty_other, row++, EEPROM_COL2, "[DIAGBOOTDEVICE(g)]: %-9s", diagdev_file); (void)mvwprintw(tty_other, row++, EEPROM_COL2, "[KEYBOARDTYPE(t)]: %-1u", kbdtype_file); (void)mvwprintw(tty_other, row++, EEPROM_COL2, "[MEMORYSIZE(m)]: %-3u", memsize_file); (void)mvwprintw(tty_other, row++, EEPROM_COL2, "[MEMORYTESTSIZE(i)]: %-3u", memtest_file); (void)mvwprintw(tty_other, row++, EEPROM_COL2, "[COLUMNS(n)]: %-3u", columns_file); (void)mvwprintw(tty_other, row++, EEPROM_COL2, "[ROWS(r)]: %-3u", rows_file); touchwin(tty_other); (void)wrefresh(tty_other); (void)refresh(); /* restore the cursor */#endif sun386}/****************************************************************************** * tty_eeprom_proc(), process the eeprom option menu commands. * ******************************************************************************/tty_eeprom_proc(){#ifndef sun386#ifdef sun4 /* Check for Sun4c */ if ( cpu_is_sun4c() ) return;#endif sun4 if (arg_no == 1) /* command without arguments */ switch (get_com(eeprom_tbl1, arg[0])) { case 'f': /* default */ eeprom_get_proc(); break; case 'd': /* done */ write_eeprom(); fix_chksum(); switch_to_control(); return; case 'c': /* cancel */ switch_to_control(); return; case 'a': /* Assert SCSI A DTR/RTS */ ttya_rtsdtr_file = !ttya_rtsdtr_file; break; case 'b': /* Assert SCSI B DTR/RTS */ ttyb_rtsdtr_file = !ttyb_rtsdtr_file; break; case 'x': /* console file */ if (++console_file > 4) console_file = 0; break; case 'z': /* screen size file */ if (++scrsize_file > 3) scrsize_file = 0; break; case 'k': /* keyclick file */ keyclick_file = !keyclick_file; break; case 'w': /* watchdog reboot file */ watchdog_reboot_file = !watchdog_reboot_file; break; case 'u': /* Unix boot path */ default_boot_file = !default_boot_file; break; case 'l': /* custom logo file */ custom_banner_file = !custom_banner_file; break; case 'h': /* help */ tty_help(); break; default: tty_message(com_err); return; } else if (arg_no == 2) /* command with one argument */ switch (get_com(eeprom_tbl2, arg[0])) { case 'o': /* Unix boot device */ (void)strcpy(bootdev_file, arg[1]); break; case 's': /* banner string */ (void)strcpy(banner_file, arg[1]); break; case 'p': /* Diagnostics boot path name */ (void)strcpy(diagpath_file, arg[1]); break; case 'g': /* Diagniostics boot path */ (void)strcpy(diagdev_file, arg[1]); break; case 't': /* Keyboard type */ kbdtype_file = atoi(arg[1]); break; case 'm': /* Memory size */ memsize_file = atoi(arg[1]); break; case 'i': /* Memory test size */ memtest_file = atoi(arg[1]); break; case 'n': /* # of Columns */ columns_file = atoi(arg[1]); break; case 'r': /* # of Rows */ rows_file = atoi(arg[1]); break; default: tty_message(com_err); return; } else { tty_message(com_err); return; } tty_eeprom(); /* update the eeprom window */#endif sun386}/****************************************************************************** * tty_processors_proc(), process the processors option menu commands. * ******************************************************************************/tty_processors_proc(){ int i, index, num, bit; char cmd; cmd = get_com(processors_tbl1, arg[0]); if (arg_no == 1) if ((cmd < (number_system_processors +'0')) && (cmd >= '0')) { index = cmd - '0'; system_processor_selected[index] = !system_processor_selected[index]; } else switch (cmd) { case 'f': for (bit = 1, num = 0, i = 0; num < number_system_processors; bit <<= 1, i++) { if (system_processors_mask & bit) { system_processor_selected[i] = 0; num++; } } break; case 'd': switch_to_control(); return; case 'h': /* help */ tty_help(); break; default: tty_message(com_err); break; } else { tty_message(com_err); return; } tty_processors(); /* update the schedule window */}/****************************************************************************** * tty_schedule_proc(), process the schedule option menu commands. * ******************************************************************************/tty_schedule_proc(){ if (arg_no == 1) /* command without arguments */ switch (get_com(schedule_tbl1, arg[0])) { case 'd': /* done */ ttime_process_proc(); switch_to_control(); return; case 'c': /* cancel */ switch_to_control(); return; case 's': /* Enable or Disable Scheduler */ schedule_file = !schedule_file; break; case 'h': /* help */ tty_help(); break; default: tty_message(com_err); break; } else if (arg_no == 2) /* command with one argument */ switch (get_com(schedule_tbl2, arg[0])) { case 'r': /* Start date */ (void)strcpy(start_date_file, arg[1]); break; case 'x': /* Start time */ (void)strcpy(run_time_file, arg[1]); break; case 't': /* Start time */ (void)strcpy(start_time_file, arg[1]); break; case 'o': /* Stop date */ (void)strcpy(stop_date_file, arg[1]); break; case 'm': /* Stop time */ (void)strcpy(stop_time_file, arg[1]); break; default: tty_message(com_err); break; } else { tty_message(com_err); return; } tty_schedule(); /* update the schedule window */}/****************************************************************************** * tty_schedule(), display the schedule tool. * ******************************************************************************/#define SCHEDULE_COL 24tty_schedule(){ char *enable, *disable; int row; mvwaddstr(tty_other, 0, SCHEDULE_COL, "<< SCHEDULE Option Menu >>"); mvwaddstr(tty_other, 2, SCHEDULE_COL, "[DONE(d)] [CANCEL(c)] [HELP(h)]"); enable = "Enable"; disable = "Disable"; row = 6; (void)mvwprintw(tty_other, 4, SCHEDULE_COL, "[SCHEDULER(s)]: %-7s", schedule_file?enable:disable); (void)mvwprintw(tty_other, row++, SCHEDULE_COL, "[RUNTIME (x)]: %-9s", run_time_file); (void)mvwprintw(tty_other, row++, SCHEDULE_COL, "[STARTDATE(r)]: %-9s", start_date_file); (void)mvwprintw(tty_other, row++, SCHEDULE_COL, "[STARTTIME(t)]: %-9s", start_time_file); (void)mvwprintw(tty_other, row++, SCHEDULE_COL, "[STOPDATE (o)]: %-9s", stop_date_file); (void)mvwprintw(tty_other, row++, SCHEDULE_COL, "[STOPTIME (m)]: %-9s", stop_time_file); touchwin(tty_other); (void)wrefresh(tty_other); (void)refresh(); /* restore the cursor */} /****************************************************************************** * tty_processors(), display the processors enable. * ******************************************************************************/#define PROCESSORS_COL 24tty_processors(){ char *enable, *disable; int row, i, processor_mask, num; unsigned int b; mvwaddstr(tty_other, 0, PROCESSORS_COL, "<< PROCESSORS Option Menu >>"); mvwaddstr(tty_other, 2, PROCESSORS_COL, "[DEFAULT(f)] [DONE(d)] [HELP(h)]"); enable = "Enable"; disable = "Disable"; row = 5; for (b = 1, num = 0, i = 0; num < number_system_processors; b <<= 1, i++) { processor_mask = system_processors_mask & b; if (processor_mask) { (void)mvwprintw(tty_other, row++, OPTION_COL, "[PROCESSOR %d(%c)]: %-7s", i, i+ '0', system_processor_selected[i]?disable:enable); num++; } } touchwin(tty_other); (void)wrefresh(tty_other); (void)refresh(); /* restore the cursor */}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -