4 * Copyright (c) 2008 James McKenzie <james@fishsoup.dhs.org>,
9 static char rcsid[] = "$Id$";
13 * Revision 1.12 2008/02/22 23:39:27 james
14 * *** empty log message ***
16 * Revision 1.11 2008/02/20 18:31:53 james
17 * *** empty log message ***
19 * Revision 1.10 2008/02/15 23:52:12 james
20 * *** empty log message ***
22 * Revision 1.9 2008/02/15 03:32:07 james
23 * *** empty log message ***
25 * Revision 1.8 2008/02/14 10:36:18 james
26 * *** empty log message ***
28 * Revision 1.7 2008/02/14 10:34:30 james
29 * *** empty log message ***
31 * Revision 1.6 2008/02/13 16:59:34 james
32 * *** empty log message ***
34 * Revision 1.5 2008/02/13 16:57:29 james
35 * *** empty log message ***
37 * Revision 1.4 2008/02/12 22:36:46 james
38 * *** empty log message ***
40 * Revision 1.3 2008/02/09 15:47:28 james
41 * *** empty log message ***
49 speed_t_to_baud (speed_t s)
135 baud_to_speed_t (int baud)
220 tty_pre_select (TTY * t, fd_set * rfds, fd_set * wfds)
223 struct timeval now, dif;
228 gettimeofday (&now, NULL);
229 timersub (&now, &t->hangup_clock, &dif);
233 ioctl (t->rfd, TIOCMBIS, &line);
239 FD_SET (t->rfd, rfds);
243 tty_get_status (TTY * t, TTY_Status * s)
247 ioctl (t->rfd, TIOCMGET, &s->lines);
249 if (tcgetattr (t->rfd, &s->termios))
252 s->baud = speed_t_to_baud (cfgetispeed (&s->termios));
253 s->blocked = t->blocked;
259 tty_set_baud (TTY * t, int rate)
261 struct termios tios = { 0 };
263 speed_t s = baud_to_speed_t (rate);
265 if (s == (speed_t) - 1)
268 if (tcgetattr (t->rfd, &tios))
271 cfsetispeed (&tios, s);
272 cfsetospeed (&tios, s);
274 tcsetattr (t->rfd, TCSANOW, &tios);
278 tty_send_break (TTY * t)
280 tcsendbreak (t->wfd, 0);
284 tty_set_flow (TTY * t, int flow)
286 struct termios tios = { 0 };
288 if (tcgetattr (t->rfd, &tios))
292 tios.c_cflag |= CRTSCTS;
294 tios.c_cflag &= ~CRTSCTS;
296 tcsetattr (t->rfd, TCSANOW, &tios);
306 ioctl (t->rfd, TIOCMBIC, &line);
309 gettimeofday (&t->hangup_clock, NULL);
320 int bit_edge_frequency[8];
327 #define bit(p,b,z,o) \
348 tty_stats (TTY_Parser * p, int err, int ch)
360 bit (p,ch & c,zc,oc);
367 tty_parse (Context * c, uint8_t * buf, int len)
369 TTY_Parser *p = &c->t->parser;
380 tty_bit_analyse (p, 0, *buf);
381 utf8_parse (c, *buf);
387 log_f (c->l, "%s:%d DLE parsing error: \\377 \\%03o", *buf);
390 else if (p->in_errmark)
393 log_f (c->l, "%s:%d tty reports error: \\377 \\000 \\%03o", *buf);
394 utf8_parse (c, *buf);
395 tty_bit_analyse (p, 1, *buf);
396 utf8_parse (c, SYM_CHAR_RESET);
400 tty_bit_analyse (p, 0, *buf);
401 utf8_parse (c, *buf);