#include #include #define TOSTOP 0x0100 #define XKEY 0x0200 struct { char *name; short bits; } modes[] = { { "crmod", CRMOD }, { "cbreak", CBREAK }, { "echo", ECHO }, { "raw", RAW }, { "tostop", TOSTOP }, { "xkey", XKEY } }; #define NMODES (sizeof(modes) / sizeof(modes[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; { return sp; } /* * atok: turns a string into an ASCII value. ^x yields control-x * for X in @A-Za-z[\]^_ as long as there are only two chars. * ^? yields DEL (127) and other single chars yield themselves. */ int atok(s) char *s; { char c; if (!s || !*s) return -1; c = *s++; if (c == '^') { c = *s++; if (*s) return -1; if (c == '?') return 127; else if (c >= '@' && 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; 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