aboutsummaryrefslogtreecommitdiffstats
path: root/src/testtty.c
diff options
context:
space:
mode:
authorjames <>2008-02-04 01:32:39 +0000
committerjames <>2008-02-04 01:32:39 +0000
commite45109d0e28411913f65e5aa16911e19217d2312 (patch)
treefe95a5cc6b8927a907ea9856655e071ad18ddc78 /src/testtty.c
parentba58c87c457aa20cfebcc69374736ee8e7e3c470 (diff)
downloadsympathy-e45109d0e28411913f65e5aa16911e19217d2312.tar.gz
sympathy-e45109d0e28411913f65e5aa16911e19217d2312.tar.bz2
sympathy-e45109d0e28411913f65e5aa16911e19217d2312.zip
*** empty log message ***
Diffstat (limited to 'src/testtty.c')
-rw-r--r--src/testtty.c76
1 files changed, 76 insertions, 0 deletions
diff --git a/src/testtty.c b/src/testtty.c
new file mode 100644
index 0000000..2cef3e0
--- /dev/null
+++ b/src/testtty.c
@@ -0,0 +1,76 @@
+/*
+ * testtty.c:
+ *
+ * Copyright (c) 2008 James McKenzie <james@fishsoup.dhs.org>,
+ * All rights reserved.
+ *
+ */
+
+static char rcsid[] = "$Id$";
+
+/*
+ * $Log$
+ * Revision 1.1 2008/02/04 01:32:39 james
+ * *** empty log message ***
+ *
+ */
+
+#include "project.h"
+
+static void default_termios(struct termios *termios)
+{
+
+memset(termios,0,sizeof(termios));
+
+termios->c_iflag=ICRNL|IXON;
+termios->c_oflag=OPOST | ONLCR | NL0 | CR0 | TAB0 | BS0 | VT0 | FF0;
+termios->c_lflag=ISIG | ICANON | IEXTEN | ECHO | ECHOE | ECHOK | ECHOCTL | ECHOKE;
+
+termios->c_cc[VINTR]=003;
+termios->c_cc[VQUIT]=034;
+termios->c_cc[VERASE]=0177;
+termios->c_cc[VKILL]=025;
+termios->c_cc[VEOF]=004;
+termios->c_cc[VEOL]=0;
+termios->c_cc[VEOL2]=0;
+termios->c_cc[VSTART]=021;
+termios->c_cc[VSTOP]=023;
+termios->c_cc[VSUSP]=032;
+termios->c_cc[VLNEXT]=026;
+termios->c_cc[VWERASE]=027;
+termios->c_cc[VREPRINT]=022;
+termios->c_cc[VDISCARD]=017;
+
+termios->c_cflag=CS8 | CREAD | CLOCAL;
+
+cfsetispeed(termios,B9600);
+cfsetospeed(termios,B9600);
+}
+
+
+int open_fd_to_bash(void) /*thump*/
+{
+pid_t child;
+int fd;
+struct winsize winsize={0};
+struct termios termios;
+
+default_termios(&termios);
+
+winsize.ws_row=CRT_ROWS;
+winsize.ws_col=CRT_COLS;
+
+child=forkpty(&fd,NULL,&termios,&winsize);
+
+switch (child)
+{
+case -1:/*boo hiss*/
+ return -1;
+case 0: /*waaah*/
+ setenv("TERM","vt102",1);
+ execl("/bin/sh","-",(char *) 0);
+ _exit(-1);
+}
+
+return fd;
+}