-/*
+/*
* serial.c:
*
* Copyright (c) 2008 James McKenzie <james@fishsoup.dhs.org>,
*
*/
-static char rcsid[] = "$Id$";
+static char rcsid[] = "$Id: serial.c,v 1.18 2011/02/06 16:51:22 james Exp $";
-/*
- * $Log$
+/*
+ * $Log: serial.c,v $
+ * Revision 1.18 2011/02/06 16:51:22 james
+ * *** empty log message ***
+ *
+ * Revision 1.17 2008/03/10 11:49:33 james
+ * *** empty log message ***
+ *
+ * Revision 1.16 2008/03/07 13:16:02 james
+ * *** empty log message ***
+ *
+ * Revision 1.15 2008/03/07 12:37:04 james
+ * *** empty log message ***
+ *
+ * Revision 1.14 2008/03/03 06:04:42 james
+ * *** empty log message ***
+ *
+ * Revision 1.13 2008/03/02 10:37:56 james
+ * *** empty log message ***
+ *
+ * Revision 1.12 2008/02/28 16:57:52 james
+ * *** empty log message ***
+ *
+ * Revision 1.11 2008/02/26 23:23:17 james
+ * *** empty log message ***
+ *
* Revision 1.10 2008/02/24 00:47:14 james
* *** empty log message ***
*
#include <sys/stat.h>
-typedef struct
-{
+typedef struct {
TTY_SIGNATURE;
Serial_lock *lock;
int fd;
if (t->blocked)
return 0;
- do
- {
+ do {
- red = wrap_read (t->fd, buf, len);
- if (red < 0)
- return -1;
- if (!red)
- return done;
+ red = wrap_read (t->fd, buf, len);
+ if (red < 0)
+ return done ? done:-1;
+ if (!red)
+ return done;
- buf += red;
- len -= red;
- done += red;
- }
+ buf += red;
+ len -= red;
+ done += red;
+ }
while (len);
if (t->blocked)
return 0;
- do
- {
+ do {
- writ = wrap_write (t->fd, buf, len);
- if (writ < 0)
- return -1;
- if (!writ)
- sleep (1);
+ writ = wrap_write (t->fd, buf, len);
+ if (writ < 0)
+ return -1;
+ if (!writ)
+ sleep (1);
- buf += writ;
- len -= writ;
- done += writ;
- }
+ buf += writ;
+ len -= writ;
+ done += writ;
+ }
while (len);
set_nonblocking (fd);
- if (tcgetattr (fd, &termios))
- {
- close (fd);
- return NULL;
- }
+ if (tcgetattr (fd, &termios)) {
+ close (fd);
+ return NULL;
+ }
default_termios (&termios);
- if (tcsetattr (fd, TCSANOW, &termios))
- {
- close (fd);
- return NULL;
- }
+ if (tcsetattr (fd, TCSANOW, &termios)) {
+ close (fd);
+ return NULL;
+ }
- t = (Serial *) malloc (sizeof (Serial));
+ t = (Serial *) xmalloc (sizeof (Serial));
t->lock = l;
t->fd = fd;
t->rfd = t->fd;
t->wfd = t->fd;
- t->size.x = VT102_COLS;
- t->size.y = VT102_ROWS;
+ t->size.x = VT102_COLS_80;
+ t->size.y = VT102_ROWS_24;
t->blocked = serial_lock_check (t->lock);
t->hanging_up = 0;