chiark
/
gitweb
/
~ianmdlvl
/
sympathy.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
*** empty log message ***
[sympathy.git]
/
src
/
ptty.c
diff --git
a/src/ptty.c
b/src/ptty.c
index dee241b8c1497c00c210ca728a6abc764089cedc..c0f85f5689e647e7f1afc8e8a62e1d5c33222dc5 100644
(file)
--- a/
src/ptty.c
+++ b/
src/ptty.c
@@
-10,6
+10,12
@@
static char rcsid[] = "$Id$";
/*
* $Log$
/*
* $Log$
+ * 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 ***
*
* Revision 1.1 2008/02/09 15:47:28 james
* *** empty log message ***
*
@@
-33,21
+39,24
@@
static char rcsid[] = "$Id$";
#include "project.h"
#include "project.h"
-typedef struct {
- TTY_SIGNATURE;
- int fd;
- pid_t child;
+typedef struct
+{
+ TTY_SIGNATURE;
+ int fd;
+ pid_t child;
} PTTY;
} 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
+64,7
@@
free(t);
static int
ptty_read (TTY * _t, void *buf, int len)
{
static int
ptty_read (TTY * _t, void *buf, int len)
{
-
PTTY *t=(PTTY *)
_t;
+
PTTY *t = (PTTY *)
_t;
int red, done = 0;
do
int red, done = 0;
do
@@
-82,7
+91,7
@@
static int
ptty_write (TTY * _t, void *buf, int len)
{
int writ, done = 0;
ptty_write (TTY * _t, void *buf, int len)
{
int writ, done = 0;
- PTTY *t
=
(PTTY *) _t;
+ PTTY *t
=
(PTTY *) _t;
do
{
do
{
@@
-103,7
+112,8
@@
ptty_write (TTY * _t, void *buf, int len)
return done;
}
return done;
}
-TTY * ptty_open(char *path,char *argv[])
+TTY *
+ptty_open (char *path, char *argv[])
{
PTTY *t;
pid_t child;
{
PTTY *t;
pid_t child;
@@
-111,47
+121,49
@@
TTY * ptty_open(char *path,char *argv[])
struct winsize winsize = { 0 };
struct termios termios;
int fd;
struct winsize winsize = { 0 };
struct termios termios;
int fd;
- char *default_argv={"-",(char *) 0};
+ char *default_argv[] = { "-", (char *) 0 };
+
+
+ default_termios (&termios);
+
+ winsize.ws_row = VT102_ROWS;
+ winsize.ws_col = VT102_COLS;
child = forkpty (&fd, name, &termios, &winsize);
switch (child)
{
case -1: /*boo hiss */
child = forkpty (&fd, name, &termios, &winsize);
switch (child)
{
case -1: /*boo hiss */
- return
-1
;
+ return
NULL
;
case 0: /*waaah */
setenv ("TERM", "vt102", 1);
setenv ("LANG", "C", 1);
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);
_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 = (PTTY *) malloc (sizeof (PTTY));
- 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;
+ strncpy (t->name, name, sizeof (t->name));
+ t->name[sizeof (t->name) - 1] = 0;
- t->fd = open_fd_to_pty (path,argv);
- t->pid=child;
- t->rfd=t->fd;
- t->wfd=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;
return (TTY *) t;
}
return (TTY *) t;
}