Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!seismo!mimsy!chris From: chris@mimsy.UUCP Newsgroups: comp.unix.questions Subject: Re: login gripes Message-ID: <6008@mimsy.UUCP> Date: Sun, 29-Mar-87 20:31:22 EST Article-I.D.: mimsy.6008 Posted: Sun Mar 29 20:31:22 1987 Date-Received: Tue, 31-Mar-87 01:07:11 EST References: <8703231450.AA18626@ephemeral.ai.toronto.edu> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 170 In article <8703231450.AA18626@ephemeral.ai.toronto.edu> lamy@ai.toronto.edu writes: >a) What on earth does [login] do between the time I hit return on > the username line and the time it gives me back the Password prompt? That is not login, but rather getty, that you are running. It is exec'ing login. >b) Any fundamental reason why true baud rate detection is not provided? It *is* provided---you just have to know who to ask. :-) RCS file: RCS/subr.c,v retrieving revision 1.1 diff -c2 -r1.1 subr.c *** /tmp/,RCSt1003237 Sun Mar 29 20:30:25 1987 --- subr.c Sat Oct 5 06:40:21 1985 *************** *** 417,420 **** --- 417,422 ---- } + #ifdef notdef + /* * This auto-baud speed select mechanism is written for the Micom 600 *************** *** 469,470 **** --- 471,608 ---- return (type); } + + #else + + /* + * Try to figure out what speed the terminal is set to based on what + * a carriage-return or newline looks like at 2400 baud. 5/18/82 FLB + * + * N.B.: some of the table entries for \n collide with those for \r. + * Only the first one in the table will be matched. + */ + + #include + #include + #include + #include + + struct autobaud { + char *s_speed; + char *s_string; /* first byte is length */ + } a_tab[] = { + /* carriage-return */ + "110-baud", "\3\000\000\000", /* also \n */ + "300-baud", "\3\200\200\000", /* collides with 600 \n */ + "300-baud", "\3\200\000\000", + "300-baud", "\3\000\200\000", /* also \n */ + "600-baud", "\3\000\376\000", + "1200-baud", "\2\346\200", + "1200-baud", "\2\346\340", + "1200-baud", "\2\367\300", + "1800-baud", "\2\000\376", /* also \n */ + "1800-baud", "\2\000\377", + "2400-baud", "\1\015", + "2400-baud", "\1\215", + "4800-baud", "\1\361", /* needed for Gandalf */ + "4800-baud", "\1\362", + "4800-baud", "\1\363", /* needed for Gandalf */ + "4800-baud", "\1\371", /* needed for Gandalf */ + "4800-baud", "\1\375", /* needed for Gandalf */ + "4800-baud", "\1\376", /* needed for Gandalf; + collides with 9600 \n */ + "9600-baud", "\1\377", /* needed for Gandalf */ + + /* newline */ + "600-baud", "\3\200\000\000", /* collides with 300 \r */ + "1200-baud", "\2\230\200", + "2400-baud", "\1\012", + "4800-baud", "\1\370", + "9600-baud", "\1\376", /* collides with 4800 \r */ + + /* The next entry must be the last entry in the table. */ + 0, "\1\0", /* BREAK: handled specially */ + + 0, 0 + }; + + char * + autobaud() + { + register struct autobaud *tp; + register int i; + struct sgttyb ttyb; + static char buf[10]; + + extern jmp_buf timeout; /* from main.c */ + extern int dingdong(); /* from main.c */ + + if (TO) { + if (setjmp(timeout)) { + /* + * Drop DTR for a while. This is important + * for Gandalf lines which must be told to + * disconnect. + */ + ttyb.sg_ispeed = ttyb.sg_ospeed = 0; + (void) ioctl(0, TIOCSETP, &ttyb); + sleep(3); + exit(1); + } + signal(SIGALRM, dingdong); + alarm(TO); + } + + /* + * The following hack sets BREAK to sequence to the next + * gettytab entry. + */ + a_tab[(sizeof (a_tab) / sizeof (a_tab[0])) - 2].s_speed = + NX && *NX ? NX : 0; + + ttyb.sg_ispeed = ttyb.sg_ospeed = B2400; + ttyb.sg_flags = ANYP|RAW; + + for (;;) { + (void) ioctl(0, TIOCSETP, &ttyb); + input(buf, sizeof buf); + + for (tp = a_tab; tp->s_speed; tp++) { + for (i = 0;; i++) { + if (buf[i] != tp->s_string[i]) + break; + if (i == buf[0]) { + alarm(0); + return (tp->s_speed); + } + } + } + } + /*NOTREACHED*/ + } + + input(s, n) + char *s; + register int n; + { + register char *cp = s + 1; + fd_set rfds; + struct timeval timeout; + + FD_ZERO(&rfds); + FD_SET(0, &rfds); + timeout.tv_sec = 0; /* .15 seconds */ + timeout.tv_usec = 150000; + n--; /* first byte is for length */ + (void) read(0, cp, 1); /* wait for something */ + n--, cp++; + while (--n >= 0) { + if (select(1, &rfds, (fd_set *)0, (fd_set *)0, &timeout) <= 0) + break; + if (read(0, cp, 1) != 1) + break; + cp++; + } + *s = (cp - s) - 1; + } + + #endif -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690) UUCP: seismo!mimsy!chris ARPA/CSNet: chris@mimsy.umd.edu