void do_command(char c) { switch (c) { case '.': case '\004': /* ^D */ event_loopexit(NULL); break; case '\032': /* ^Z */ restore_termios(); kill(getpid(), SIGTSTP); set_termios(); break; case 'C': connect_command(); break; case 'D': ioctl(line_fd, TIOCCDTR, NULL); sleep(1); ioctl(line_fd, TIOCSDTR, NULL); break; case 'R': start_record(); break; case 'S': set_speed(); break; case 'X': send_xmodem(); break; case '$': pipe_command(); break; case '>': send_file(); break; case '#': ioctl(line_fd, TIOCSBRK, NULL); sleep(1); ioctl(line_fd, TIOCCBRK, NULL); break; case '~': bufferevent_write(line_ev, "~", 1); break; case '?': printf("\r\n" "~# send break\r\n" "~$ pipe local command to remote host\r\n" "~> send file to remote host\r\n" "~C connect program to remote host\r\n" "~D de-assert DTR line briefly\r\n" "~R start recording to file\r\n" "~S set speed\r\n" "~X send file with XMODEM\r\n" "~? get this summary\r\n" ); break; } }
/* A line of input (a command) is received. Look at the first character to determine * the type and take it from there. */ static void handle_line(struct file_info *fi, char *line){ switch (line[0]) { case 0: break; case 'C': connect_command(fi, &line[1]); break; case 'G': gossip_received(fi, &line[1]); break; case 'H': hello_received(fi, &line[1]); break; case 'E': case 'e': exit(0); break; case 'S': send_handler(fi, &line[1]); break; default: fprintf(stderr, "unknown command: '%s'\n", line); } }