#include #include #include #ifndef B0 #define B0 0 #endif #ifndef B134 #define B134 B135 #endif struct { char *name; short bits; } modes[] = { { "crmod", CRMOD }, { "cbreak", CBREAK }, { "echo", ECHO }, { "even", EVENP }, { "odd", ODDP }, { "raw", RAW }, { "tandem", TANDEM }, { "tostop", TOSTOP }, { "xkey", XKEY } }; #define NMODES (sizeof(modes) / sizeof(modes[0])) struct { int num; int baud; } bauds[] = { { B0, 0 }, { B50, 50 }, { B75, 75 }, { B110, 110 }, { B134, 134 }, { B150, 150 }, { B200, 200 }, { B300, 300 }, { B600, 600 }, { B1200, 1200 }, { B1800, 1800 }, { B2400, 2400 }, { B4800, 4800 }, { B9600, 9600 }, { B19200, 19200 } }; #define NBAUDS (sizeof(bauds) / sizeof(bauds[0])) void prchar(s,c) char *s; char c; { printf("%s ",s); if (c < ' ') printf("^%c ",c + '@'); else if (c == 127) printf("^? "); else printf("%c ",c); } void prmode(s,f) char *s; int f; { printf("%s%s ",(f ? "" : "-"),s); } int speed(sp) int sp; { int i; for (i = 0; i= '@' && c <= '_') return (c - '@'); else if (c >= 'a' && c <= 'z') return (c - '`'); else return -1; } else if (*s) return -1; else return c; } main(argc,argv) int argc; char *argv[]; { int fd; int i; char *kp; long err; struct sgttyb sg; struct tchars tc; struct ltchars ltc; int b; fd = 0; if (!(isatty(fd))) { if ((fd = open("U:\\dev\\tty",0)) < 0) { perror("can't open tty"); exit(1); } } if (ioctl(fd,TIOCGETP,&sg) || ioctl(fd,TIOCGETC,&tc) || ioctl(fd,TIOCGLTC,<c)) { perror("can't do ioctl"); exit(1); } --argc, ++argv; if (!argc) { /* print current state */ prchar("intr",tc.t_intrc); prchar("quit",tc.t_quitc); prchar("start",tc.t_startc); prchar("stop",tc.t_stopc); prchar("eof",tc.t_eofc); prchar("brk",tc.t_brkc); putchar('\n'); prchar("susp",ltc.t_suspc); prchar("dsusp",ltc.t_dsuspc); prchar("rprnt",ltc.t_rprntc); prchar("flush",ltc.t_flushc); prchar("werase",ltc.t_werasc); prchar("lnext",ltc.t_lnextc); putchar('\n'); printf("ispeed %d ospeed %d ", speed(sg.sg_ispeed), speed(sg.sg_ospeed)); prchar("erase",sg.sg_erase); prchar("kill",sg.sg_kill); putchar('\n'); for (i=0; i