From 8688a9519c349b6ee8664be6ce2897a59c0f52be Mon Sep 17 00:00:00 2001 From: james <> Date: Tue, 12 Feb 2008 22:36:46 +0000 Subject: *** empty log message *** --- src/ptty.c | 67 ++++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 37 insertions(+), 30 deletions(-) (limited to 'src/ptty.c') diff --git a/src/ptty.c b/src/ptty.c index dee241b..b59f823 100644 --- a/src/ptty.c +++ b/src/ptty.c @@ -10,6 +10,9 @@ static char rcsid[] = "$Id$"; /* * $Log$ + * Revision 1.2 2008/02/12 22:36:46 james + * *** empty log message *** + * * Revision 1.1 2008/02/09 15:47:28 james * *** empty log message *** * @@ -33,21 +36,24 @@ static char rcsid[] = "$Id$"; #include "project.h" -typedef struct { - TTY_SIGNATURE; - int fd; - pid_t child; +typedef struct +{ + TTY_SIGNATURE; + int fd; + pid_t child; } PTTY; -void ptty_close(TTY *_t) +static void +ptty_close (TTY * _t) { -PTTY *t=(PTTY *) _t; + PTTY *t = (PTTY *) _t; -if (!t) return; + if (!t) + return; -close(t->fd); -free(t); + close (t->fd); + free (t); } @@ -55,7 +61,7 @@ free(t); static int ptty_read (TTY * _t, void *buf, int len) { -PTTY *t=(PTTY *)_t; + PTTY *t = (PTTY *) _t; int red, done = 0; do @@ -82,7 +88,7 @@ static int ptty_write (TTY * _t, void *buf, int len) { int writ, done = 0; - PTTY *t=(PTTY *) _t; + PTTY *t = (PTTY *) _t; do { @@ -103,7 +109,8 @@ ptty_write (TTY * _t, void *buf, int len) return done; } -TTY * ptty_open(char *path,char *argv[]) +TTY * +ptty_open (char *path, char *argv[]) { PTTY *t; pid_t child; @@ -111,7 +118,7 @@ TTY * ptty_open(char *path,char *argv[]) struct winsize winsize = { 0 }; struct termios termios; int fd; - char *default_argv={"-",(char *) 0}; + char *default_argv = { "-", (char *) 0 }; child = forkpty (&fd, name, &termios, &winsize); @@ -122,36 +129,36 @@ TTY * ptty_open(char *path,char *argv[]) case 0: /*waaah */ setenv ("TERM", "vt102", 1); setenv ("LANG", "C", 1); - if (!path) - path="/bin/sh"; - - if (!argv) - argv=default_argv; - - execv (path,argv); + if (!path) + path = "/bin/sh"; + + if (!argv) + argv = default_argv; + + execv (path, argv); _exit (-1); } set_nonblocking (fd); - t=(PTTY*) malloc(sizeof(PTTY)); + t = (PTTY *) malloc (sizeof (PTTY)); - strncpy(t->name,name,sizeof(t->name)); - t->name[sizeof(t->name)-1]=0; + strncpy (t->name, name, sizeof (t->name)); + t->name[sizeof (t->name) - 1] = 0; - t->read=ptty_read; - t->write=ptty_write; - t->close=ptty_close; + t->read = ptty_read; + t->write = ptty_write; + t->close = ptty_close; default_termios (&termios); winsize.ws_row = VT102_ROWS; winsize.ws_col = VT102_COLS; - t->fd = open_fd_to_pty (path,argv); - t->pid=child; - t->rfd=t->fd; - t->wfd=0; + t->fd = open_fd_to_pty (path, argv); + t->pid = child; + t->rfd = t->fd; + t->wfd = 0; return (TTY *) t; } -- cgit v1.2.3