4 * Copyright (c) 2008 James McKenzie <james@fishsoup.dhs.org>,
9 static char rcsid[] = "$Id$";
13 * Revision 1.1 2008/02/13 01:08:38 james
14 * *** empty log message ***
21 wrap_read (int fd, void *buf, int len)
25 red = read (fd, buf, len);
29 if ((red < 0) && (errno == EAGAIN))
36 wrap_write (int fd, void *buf, int len)
40 writ = write (fd, buf, len);
44 if ((writ < 0) && (errno == -EAGAIN))
52 set_nonblocking (int fd)
55 arg = fcntl (fd, F_GETFL, arg);
57 fcntl (fd, F_SETFL, arg);
64 arg = fcntl (fd, F_GETFL, arg);
66 fcntl (fd, F_SETFL, arg);
69 void raw_termios(struct termios *termios)
72 termios->c_iflag = ICRNL | IXON;
73 termios->c_oflag = OPOST | ONLCR | NL0 | CR0 | TAB0 | BS0 | VT0 | FF0;
75 ISIG | ICANON | IEXTEN | ECHO | ECHOE | ECHOK | ECHOCTL | ECHOKE;
77 termios->c_cc[VINTR] = 003;
78 termios->c_cc[VQUIT] = 034;
79 termios->c_cc[VERASE] = 0177;
80 termios->c_cc[VKILL] = 025;
81 termios->c_cc[VEOF] = 004;
82 termios->c_cc[VEOL] = 0;
83 termios->c_cc[VEOL2] = 0;
84 termios->c_cc[VSTART] = 021;
85 termios->c_cc[VSTOP] = 023;
86 termios->c_cc[VSUSP] = 032;
87 termios->c_cc[VLNEXT] = 026;
88 termios->c_cc[VWERASE] = 027;
89 termios->c_cc[VREPRINT] = 022;
90 termios->c_cc[VDISCARD] = 017;
95 default_termios (struct termios *termios)
98 memset (termios, 0, sizeof (termios));
100 raw_termios(termios);
102 termios->c_cflag = CS8 | CREAD | CLOCAL;
104 cfsetispeed (termios, B9600);
105 cfsetospeed (termios, B9600);