aboutsummaryrefslogtreecommitdiffstats
path: root/src/ptty.c
diff options
context:
space:
mode:
authorjames <>2008-02-12 22:36:46 +0000
committerjames <>2008-02-12 22:36:46 +0000
commit8688a9519c349b6ee8664be6ce2897a59c0f52be (patch)
treeacfb9332cedbc05b114aa5c5d70fc08741ae8ce7 /src/ptty.c
parent5ee4b614cdc64a13aeeb00bf0e0ecbc234e8852d (diff)
downloadsympathy-8688a9519c349b6ee8664be6ce2897a59c0f52be.tar.gz
sympathy-8688a9519c349b6ee8664be6ce2897a59c0f52be.tar.bz2
sympathy-8688a9519c349b6ee8664be6ce2897a59c0f52be.zip
*** empty log message ***
Diffstat (limited to 'src/ptty.c')
-rw-r--r--src/ptty.c67
1 files changed, 37 insertions, 30 deletions
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;
}