/* process function for help_state=0 */ static void help_send_escape(int fd, char c) { struct termios pts; /* termios settings on port */ in_escape = 0; help_state = 0; switch (c) { case 'x': /* restore termios settings and exit */ write(STDOUT_FILENO, "\n", 1); cleanup_termios(0); break; case 'q': /* quit help */ break; case 'l': /* log on/off */ if (flog == 0) { /* open log file */ open_logFile(log_file); } else { /* close log file */ close_logFile(); } break; case 's': /* script active/inactive */ script_init(scr_name); script = (script)? 0: 1; break; case 'b': /* send break */ /* send a break */ tcsendbreak(fd, 0); break; case 't': /* set terminal */ help_state = 1; help_terminal(); in_escape = 1; break; case '~': /* display it again */ help_escape(); break; default: /* pass the character through */ /* "C-\ C-\" sends "C-\" */ write(fd, &c, 1); break; } if (in_escape == 0) help_done(); return; }
/* process function for help_state=0 */ static void help_send_escape(struct ios_ops *ios, char c) { struct winsize win; char buf[100]; int sz; in_escape = 0; help_state = 0; switch (c) { case 'q': /* quit help */ case 'x': /* restore termios settings and exit */ write(STDOUT_FILENO, "\n", 1); microcom_exit(0); break; case 'l': /* log on/off */ dolog = (dolog == 0) ? 1 : 0; if (dolog) { /* open log file */ if ((flog = fopen("microcom.log", "a")) == (FILE *) 0) { write(STDOUT_FILENO, "Cannot open microcom.log \n", 26); dolog = 0; } } else { /* cloase log file */ fflush(flog); fclose(flog); } break; case 'b': /* send break */ /* send a break */ tcsendbreak(ios->fd, 0); break; case 't': /* set terminal */ help_state = 1; help_terminal(); in_escape = 1; break; case 'o': /* echo mode */ in_echo = !in_echo; if (in_echo) printf("echo mode ON\n"); else printf("echo mode OFF\n"); break; case 'i': /* input line mode */ in_line = !in_line; if (in_line) printf("line mode ON\n"); else printf("line mode OFF\n"); break; case 'h': /* output hex mode */ out_hex = !out_hex; if (out_hex) printf("hex mode ON\n"); else printf("hex mode OFF\n"); break; case '~': /* display it again */ help_escape(); break; case 'w': if(ioctl(0, TIOCGWINSZ, &win)) break; sz = sprintf(buf, "stty rows %d cols %d\n", win.ws_row, win.ws_col); write(ios->fd, &buf, sz); break; case 'e': break; default: printf("unknown command '%c'\n",c); break; } if (in_escape == 0) help_done(); return; }