/*
* $Log$
+ * Revision 1.11 2008/02/26 23:23:17 james
+ * *** empty log message ***
+ *
+ * Revision 1.10 2008/02/24 00:42:53 james
+ * *** empty log message ***
+ *
+ * Revision 1.9 2008/02/23 13:05:58 staffcvs
+ * *** empty log message ***
+ *
+ * Revision 1.8 2008/02/23 11:48:37 james
+ * *** empty log message ***
+ *
+ * Revision 1.7 2008/02/22 17:07:00 james
+ * *** empty log message ***
+ *
+ * Revision 1.6 2008/02/22 14:51:54 james
+ * *** empty log message ***
+ *
+ * Revision 1.5 2008/02/15 23:52:12 james
+ * *** empty log message ***
+ *
+ * Revision 1.4 2008/02/14 10:39:14 james
+ * *** empty log message ***
+ *
+ * Revision 1.3 2008/02/13 09:12:21 james
+ * *** empty log message ***
+ *
+ * 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 ***
*
#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);
}
static int
ptty_read (TTY * _t, void *buf, int len)
{
-PTTY *t=(PTTY *)_t;
+ PTTY *t = (PTTY *) _t;
int red, done = 0;
do
ptty_write (TTY * _t, void *buf, int len)
{
int writ, done = 0;
- PTTY *t=(PTTY *) _t;
+ PTTY *t = (PTTY *) _t;
do
{
return done;
}
-TTY * ptty_open(char *path,char *argv[])
+TTY *
+ptty_open (char *path, char *argv[])
{
PTTY *t;
pid_t child;
char name[1024];
struct winsize winsize = { 0 };
- struct termios termios;
+ struct termios ctermios = { 0 };
int fd;
- char *default_argv={"-",(char *) 0};
+ char *default_argv[] = { "-", (char *) 0 };
+
+
+ client_termios (&ctermios);
+ winsize.ws_row = VT102_ROWS;
+ winsize.ws_col = VT102_COLS_80;
- child = forkpty (&fd, name, &termios, &winsize);
+ child = forkpty (&fd, name, &ctermios, &winsize);
switch (child)
{
case -1: /*boo hiss */
- return -1;
+ return NULL;
case 0: /*waaah */
- setenv ("TERM", "vt102", 1);
- setenv ("LANG", "C", 1);
- if (!path)
- path="/bin/sh";
-
- if (!argv)
- argv=default_argv;
-
- execv (path,argv);
+ setenv ("TERM", "xterm", 1);
+ if (!path)
+ path = "/bin/sh";
+
+ if (!argv)
+ argv = default_argv;
+
+ execv (path, argv);
_exit (-1);
}
set_nonblocking (fd);
- t=(PTTY*) malloc(sizeof(PTTY));
-
- 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;
-
- 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;
+#if 0
+ {
+ struct termios termios = { 0 };
+
+ tcgetattr (fd, &termios);
+ default_termios (&termios);
+ tcsetattr (fd, TCSANOW, &termios);
+ }
+#endif
+
+ t = (PTTY *) malloc (sizeof (PTTY));
+
+ strncpy (t->name, name, sizeof (t->name));
+ t->name[sizeof (t->name) - 1] = 0;
+
+ t->recv = ptty_read;
+ t->xmit = ptty_write;
+ t->close = ptty_close;
+ t->fd = fd;
+ t->child = child;
+ t->rfd = t->fd;
+ t->wfd = t->fd;
+ t->size.x = winsize.ws_row;
+ t->size.y = winsize.ws_col;
+ t->blocked = 0;
+ t->hanging_up = 0;
return (TTY *) t;
}