aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjames <>2008-02-28 22:00:45 +0000
committerjames <>2008-02-28 22:00:45 +0000
commit3ea64d3f157cabbf22a9c96d5dd356659047a093 (patch)
tree79c5f3c8f6d4efe32abe9abf7c23b0f338487c03
parent68f1170ace397c32f9c80a6b7cb89388d88743f2 (diff)
downloadsympathy-3ea64d3f157cabbf22a9c96d5dd356659047a093.tar.gz
sympathy-3ea64d3f157cabbf22a9c96d5dd356659047a093.tar.bz2
sympathy-3ea64d3f157cabbf22a9c96d5dd356659047a093.zip
*** empty log message ***
-rw-r--r--apps/sympathy.c101
-rw-r--r--src/ansi.c33
-rw-r--r--src/cmd.c14
-rw-r--r--src/keydis.c5
-rw-r--r--src/prototypes.h6
-rw-r--r--sympathy.15
-rw-r--r--version-md5sums1
-rw-r--r--version-micro2
-rw-r--r--version-stamps1
9 files changed, 127 insertions, 41 deletions
diff --git a/apps/sympathy.c b/apps/sympathy.c
index b5bf326..2339853 100644
--- a/apps/sympathy.c
+++ b/apps/sympathy.c
@@ -11,6 +11,9 @@ static char rcsid[] =
/*
* $Log$
+ * Revision 1.24 2008/02/28 22:00:42 james
+ * *** empty log message ***
+ *
* Revision 1.23 2008/02/28 16:57:51 james
* *** empty log message ***
*
@@ -269,6 +272,9 @@ main (int argc, char *argv[])
extern int optind, opterr, optopt;
CRT_Pos size = { VT102_COLS_80, VT102_ROWS_24 };
+ int csnok_pipe[2] = { 0 };
+ int csnok = 0;
+
int oflags[128];
char *oargs[128];
@@ -278,7 +284,7 @@ main (int argc, char *argv[])
Log *log = NULL;
int history = 200;
-
+ int pid;
get_hostname ();
@@ -386,43 +392,35 @@ main (int argc, char *argv[])
if (oflags['p'] && oflags['d'])
fatal_moan ("-p incompatible with -d");
- /*implement server and client by opening the server socket to prevent */
- /*a race condition, and then forking and munging the cmd line options */
- /*in the parent and child so that the child is the server and the */
- /*parent becomes its client */
if (oflags['c'] && oflags['s'] && oflags['F'])
fatal_moan ("-F is incompatible with -c -s");
- if (oflags['s'] && !oflags['k'])
- {
- char *path;
- path = mome ("/.sympathy");
- mkdir (path, 0700);
- free (path);
-
- oargs['k'] = mome ("/.sympathy/%s%d", hostname, getpid ());
- oflags['k']++;
- }
-
- if (oflags['s'])
- {
- server_socket = socket_listen (oargs['k']);
- if (!server_socket)
- fatal_moan ("failed to create socket %s for listening", oargs['k']);
- }
+ /*implement server and client: this process forks. The parent */
+ /*becomes the client and the child forks again to become the */
+ /*server. If there's no -k argument the client (parent) needs */
+ /*to find out the pid of the server, we use a pipe */
if (oflags['s'] && oflags['c'])
{
- switch (fork ())
+ if (!oflags['k'])
+ {
+ csnok++;
+ pipe (csnok_pipe);
+ }
+
+ switch (pid = fork ())
{
case 0: /*child becomes the server */
oflags['c'] = 0;
oflags['H'] = 0;
+
+ if (csnok)
+ close (csnok_pipe[0]);
break;
case -1:
fatal_moan ("fork failed");
- default:
+ default: /*parent becomes client*/
oflags['s'] = 0;
oflags['K'] = 0;
oflags['d'] = 0;
@@ -432,10 +430,26 @@ main (int argc, char *argv[])
oflags['L'] = 0;
oflags['n'] = 0;
oflags['w'] = 0;
- if (server_socket)
+
+ /*Collect the child*/
+ waitpid (pid, NULL, 0);
+
+ /*if there was no k argument we need to find the*/
+ /*pid of the server process so that we can work out*/
+ /*what the socket is called. The server tells us on*/
+ /*a pipe*/
+
+ if (csnok)
{
- socket_free_parent (server_socket);
- server_socket = NULL;
+ close (csnok_pipe[1]);
+
+ if (read (csnok_pipe[0], &pid, sizeof (pid)) != sizeof (pid))
+ fatal_moan ("Failed to receive pid of server process");
+
+ close (csnok_pipe[0]);
+
+ oargs['k'] = mome ("/.sympathy/%s%d", hostname, pid);
+ oflags['k']++;
}
}
}
@@ -478,10 +492,41 @@ main (int argc, char *argv[])
if (oflags['s'] && !oflags['F'])
{
- daemon (1, 0); /*incase socket is relative path, unlink then will fail */
+ /*nochdir incase socket is relative path, unlink then will fail */
+ daemon (1, 0);
+
+ /*Tell our parent's parent what our pid is */
+ if (csnok)
+ {
+ pid = getpid ();
+
+ write (csnok_pipe[1], &pid, sizeof (pid));
+ close (csnok_pipe[1]);
+ }
}
+ if (oflags['s'] )
+ {
+ char *path;
+ path = mome ("/.sympathy");
+ mkdir (path, 0700);
+ free (path);
+
+
+ if (!oflags['k']) {
+ pid = getpid ();
+
+ oargs['k'] = mome ("/.sympathy/%s%d", hostname, pid);
+ oflags['k']++;
+ }
+
+ server_socket = socket_listen (oargs['k']);
+ if (!server_socket)
+ fatal_moan ("failed to create socket %s for listening", oargs['k']);
+
+ }
+
if (oflags['s'] || oflags['t'])
{
diff --git a/src/ansi.c b/src/ansi.c
index 4113a36..970d353 100644
--- a/src/ansi.c
+++ b/src/ansi.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.36 2008/02/28 22:00:42 james
+ * *** empty log message ***
+ *
* Revision 1.35 2008/02/28 16:57:51 james
* *** empty log message ***
*
@@ -728,6 +731,26 @@ ansi_terminal_reset (ANSI * a)
ansi_move (a, p);
}
+
+int ansi_key(ANSI *a,Context *c,int key)
+{
+
+ if (!c->d)
+ return c->k->key (c->k, c, key);
+
+ cmd_show_status (c->d, c);
+
+ if (c->d->active)
+ return cmd_key (c->d, c,a, key);
+
+ if (key == CMD_KEY)
+ return cmd_activate (c->d, c);
+
+
+ return c->k->key (c->k, c, key);
+}
+
+
static void
ansi_flush_escape (ANSI * a, Context * c)
{
@@ -736,7 +759,7 @@ ansi_flush_escape (ANSI * a, Context * c)
for (i = 0; i < p->escape_ptr; ++i)
{
- keydis_key (c->k, c, p->escape_buf[i]);
+ ansi_key (a, c, p->escape_buf[i]);
}
p->escape_ptr = 0;
@@ -755,11 +778,11 @@ ansi_parse_deckey (ANSI * a, Context * c)
if ((p->escape_buf[2] >= 'A') || (p->escape_buf[2] <= 'Z'))
{
- keydis_key (c->k, c, KEY_UP + (p->escape_buf[2] - 'A'));
+ ansi_key (a, c, KEY_UP + (p->escape_buf[2] - 'A'));
}
else if ((p->escape_buf[2] >= 'a') || (p->escape_buf[2] <= 'z'))
{
- keydis_key (c->k, c, KEY_154 + (p->escape_buf[2] - 'a'));
+ ansi_key (a, c, KEY_154 + (p->escape_buf[2] - 'a'));
}
else
{
@@ -782,7 +805,7 @@ ansi_parse_ansikey (ANSI * a, Context * c)
}
if ((p->escape_buf[2] >= '0') || (p->escape_buf[2] <= '9'))
{
- keydis_key (c->k, c, KEY_180 + (p->escape_buf[2] - '0'));
+ ansi_key (a, c, KEY_180 + (p->escape_buf[2] - '0'));
}
else
{
@@ -895,7 +918,7 @@ ansi_parse_char (ANSI * a, Context * c, int ch)
}
else
{
- keydis_key (c->k, c, ch);
+ ansi_key (a, c, ch);
}
}
diff --git a/src/cmd.c b/src/cmd.c
index 7e86977..34dc2f4 100644
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.7 2008/02/28 22:00:42 james
+ * *** empty log message ***
+ *
* Revision 1.6 2008/02/28 16:57:51 james
* *** empty log message ***
*
@@ -34,7 +37,7 @@ static char rcsid[] = "$Id$";
int
-cmd_parse (Cmd * c, Context * ctx, char *buf)
+cmd_parse (Cmd * c, Context * ctx,ANSI *a, char *buf)
{
if (!strcmp (buf, "quit"))
c->disconnect++;
@@ -54,6 +57,11 @@ cmd_parse (Cmd * c, Context * ctx, char *buf)
ctx->k->hangup (ctx->k, ctx);
else if (!strcmp (buf, "reset"))
ctx->k->reset (ctx->k, ctx);
+ else if (!strcmp (buf, "expand")) {
+ int w=a->terminal->size.x;
+ int h=a->terminal->size.y-1;
+ ctx->k->set_size (ctx->k, ctx, w,h);
+ }
else if (!strncmp (buf, "width", 5))
ctx->k->set_size (ctx->k, ctx, atoi (buf + 5), 0);
else if (!strncmp (buf, "height", 6))
@@ -82,7 +90,7 @@ cmd_show_status (Cmd * c, Context * ctx)
}
int
-cmd_key (Cmd * c, Context * ctx, int key)
+cmd_key (Cmd * c, Context * ctx,ANSI *a, int key)
{
if (c->error)
@@ -95,7 +103,7 @@ cmd_key (Cmd * c, Context * ctx, int key)
if (key == 13)
{
- if (cmd_parse (c, ctx, c->buf + 1))
+ if (cmd_parse (c, ctx, a,c->buf + 1))
{
c->error++;
}
diff --git a/src/keydis.c b/src/keydis.c
index c6e4db2..a288347 100644
--- a/src/keydis.c
+++ b/src/keydis.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.9 2008/02/28 22:00:42 james
+ * *** empty log message ***
+ *
* Revision 1.8 2008/02/28 16:57:52 james
* *** empty log message ***
*
@@ -276,6 +279,7 @@ keydis_ipc_new (Socket * s)
+#if 0
int
keydis_key (KeyDis * t, Context * c, int key)
{
@@ -294,3 +298,4 @@ keydis_key (KeyDis * t, Context * c, int key)
return t->key (t, c, key);
}
+#endif
diff --git a/src/prototypes.h b/src/prototypes.h
index e96cb1b..c378764 100644
--- a/src/prototypes.h
+++ b/src/prototypes.h
@@ -1,4 +1,5 @@
/* ansi.c */
+extern int ansi_key(ANSI *a, Context *c, int key);
extern int ansi_dispatch(ANSI *a, Context *c);
extern ANSI *ansi_new_from_terminal(TTY *t, int utf8);
/* crt.c */
@@ -66,6 +67,7 @@ extern void tty_set_baud(TTY *t, int rate);
extern void tty_send_break(TTY *t);
extern void tty_set_flow(TTY *t, int flow);
extern void tty_hangup(TTY *t);
+extern void tty_length(TTY *t, int l);
extern void tty_winch(TTY *t, CRT_Pos size);
extern void tty_parse_reset(Context *c);
extern void tty_analyse(Context *c);
@@ -74,7 +76,6 @@ extern void tty_parse(Context *c, uint8_t *buf, int len);
/* keydis.c */
extern KeyDis *keydis_vt102_new(void);
extern KeyDis *keydis_ipc_new(Socket *s);
-extern int keydis_key(KeyDis *t, Context *c, int key);
/* history.c */
extern History *history_new(int n);
extern void history_free(History *h);
@@ -143,9 +144,8 @@ extern int socket_write(Socket *s, void *buf, int len);
/* serial.c */
extern TTY *serial_open(char *path, int lock_mode);
/* cmd.c */
-extern int cmd_parse(Cmd *c, Context *ctx, char *buf);
+extern int cmd_parse(Cmd *c, Context *ctx, ANSI *a, char *buf);
extern void cmd_show_status(Cmd *c, Context *ctx);
-extern int cmd_key(Cmd *c, Context *ctx, int key);
extern int cmd_activate(Cmd *c, Context *ctx);
extern void cmd_new_status(Cmd *c, Context *ctx, char *msg);
extern Cmd *cmd_new(void);
diff --git a/sympathy.1 b/sympathy.1
index f7b34b4..7a7e436 100644
--- a/sympathy.1
+++ b/sympathy.1
@@ -181,7 +181,7 @@ log activity to the file \fIlogfile\fP. If \fIlogfile\fP is `-' then log to \fIs
that logging to \fIstdout\fP only makes sense with the \-\fBF\fP \fIserver_option\fP.
.TP 5
.B \-w \fIwidth\fP[x\fIheight\fP]
-set the initialise size of the terminal emulator's frame buffer to be \fIwidth\fP columns
+set the initial size of the terminal emulator's frame buffer to be \fIwidth\fP columns
by \fIheight\fP rows. If \fIheight\fP is omitted it defaults to 24, the default width
is 80. These values may
be overridden later by terminal escape sequences. If \-\fBp\fP is also specified
@@ -345,6 +345,9 @@ set the current height of the screen to \fInn\fP, and reset the terminal emulato
.B reset
reset the terminal emulator
.TP 7
+.B expand
+expand the size of the screen to fit the size of the current outer terminal emulator window
+.TP 7
.B quit
exit this instance of sympathy (disconnect from the server if present)
.SH CHARACTER ENCODINGS
diff --git a/version-md5sums b/version-md5sums
index 08fdf34..a0fd824 100644
--- a/version-md5sums
+++ b/version-md5sums
@@ -10,3 +10,4 @@ f844259e45d571cf913580d8851ee261 1.1.3
0baf4bcc06f0271dba444738df2ef1e3 1.1.6
30b3685c955c05efa7ba0affb9fbca1a 1.1.7
b9ef98229248516850808e590721c0e5 1.1.8
+a5ee6f647e6d98d5f06b75a70b7bf9a5 1.1.9
diff --git a/version-micro b/version-micro
index 45a4fb7..ec63514 100644
--- a/version-micro
+++ b/version-micro
@@ -1 +1 @@
-8
+9
diff --git a/version-stamps b/version-stamps
index 9a07f49..3e0ada7 100644
--- a/version-stamps
+++ b/version-stamps
@@ -3,3 +3,4 @@
0baf4bcc06f0271dba444738df2ef1e3 "February 28, 2008"
30b3685c955c05efa7ba0affb9fbca1a "February 28, 2008"
b9ef98229248516850808e590721c0e5 "February 28, 2008"
+a5ee6f647e6d98d5f06b75a70b7bf9a5 "February 28, 2008"