From f5c0446975d0e1109a1c15f272f35fd7e20dbf9b Mon Sep 17 00:00:00 2001 From: james <> Date: Fri, 15 Feb 2008 19:51:30 +0000 Subject: *** empty log message *** --- src/serial.c | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) (limited to 'src/serial.c') diff --git a/src/serial.c b/src/serial.c index dbd8206..2e67d3d 100644 --- a/src/serial.c +++ b/src/serial.c @@ -10,6 +10,9 @@ static char rcsid[] = "$Id$"; /* * $Log$ + * Revision 1.6 2008/02/15 19:51:30 james + * *** empty log message *** + * * Revision 1.5 2008/02/15 19:09:00 james * *** empty log message *** * @@ -60,31 +63,14 @@ static char rcsid[] = "$Id$"; #include - -typedef struct -{ - int mode; - int i; - - struct timeval last_stale_purge; - Filelist locks_to_check; - Filelist locks_held; -} Serial_lock; - typedef struct { TTY_SIGNATURE; - Serial_lock lock; + Serial_lock *lock; int fd; } Serial; -static void -serial_check_lock (Serial * t) -{ -} - - static void serial_close (TTY * _t) { @@ -98,14 +84,14 @@ serial_close (TTY * _t) } - static int serial_read (TTY * _t, void *buf, int len) { Serial *t = (Serial *) _t; int red, done = 0; - serial_check_lock (t); + t->blocked = serial_lock_check (t->lock); + if (t->blocked) return 0; @@ -135,7 +121,7 @@ ptty_write (TTY * _t, void *buf, int len) int writ, done = 0; Serial *t = (Serial *) _t; - serial_check_lock (t); + t->blocked = serial_lock_check (t->lock); if (t->blocked) return 0; @@ -159,7 +145,7 @@ ptty_write (TTY * _t, void *buf, int len) } TTY * -serial_open (char *path) +serial_open (char *path, int lock_mode) { Serial *t; pid_t child; @@ -167,7 +153,11 @@ serial_open (char *path) struct winsize winsize = { 0 }; struct termios termios; int fd; + Serial_lock *l; + l = serial_lock_new (path, lock_mode); + if (!l) + return NULL; default_termios (&termios); @@ -177,6 +167,8 @@ serial_open (char *path) t = (Serial *) malloc (sizeof (Serial)); + t->lock = l; + strncpy (t->name, path, sizeof (t->name)); t->name[sizeof (t->name) - 1] = 0; @@ -188,7 +180,7 @@ serial_open (char *path) t->wfd = t->fd; t->size.x = VT102_COLS; t->size.y = VT102_ROWS; - t->blocked = 0; + t->blocked = serial_lock_check (t->lock); return (TTY *) t; } -- cgit v1.2.3