aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorjames <>2008-02-14 02:46:45 +0000
committerjames <>2008-02-14 02:46:45 +0000
commitbc6a29d06c22bdcada4cb18d8401e5d37f46fd36 (patch)
treecbe671b5cad8d7af21450915e2e312119ef0406d /src
parente65130e63d050d37b9605339c0abfdcef73c4472 (diff)
downloadsympathy-bc6a29d06c22bdcada4cb18d8401e5d37f46fd36.tar.gz
sympathy-bc6a29d06c22bdcada4cb18d8401e5d37f46fd36.tar.bz2
sympathy-bc6a29d06c22bdcada4cb18d8401e5d37f46fd36.zip
*** empty log message ***
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am7
-rw-r--r--src/ansi.c22
-rw-r--r--src/context.h5
-rw-r--r--src/keydis.c81
-rw-r--r--src/keydis.h37
-rw-r--r--src/prototypes.h6
-rw-r--r--src/slide.c7
-rw-r--r--src/symsocket.c23
-rw-r--r--src/term.c17
-rw-r--r--src/term.h23
-rw-r--r--src/vt102.c6
11 files changed, 169 insertions, 65 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index f648e7a..92a0e88 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -8,6 +8,9 @@
# $Id$
#
# $Log$
+# Revision 1.12 2008/02/14 02:46:44 james
+# *** empty log message ***
+#
# Revision 1.11 2008/02/14 01:55:57 james
# *** empty log message ***
#
@@ -47,11 +50,11 @@
INCLUDES=
-PROJECTHDRS= crt.h tty.h ansi.h vt102.h keys.h history.h ring.h slide.h log.h ipc.h symsocket.h term.h context.h prototypes.h
+PROJECTHDRS= crt.h tty.h ansi.h vt102.h keys.h history.h ring.h slide.h log.h ipc.h symsocket.h keydis.h context.h prototypes.h
HDRS=project.h
-SRCS=ansi.c crt.c html.c libsympathy.c render.c version.c vt102.c tty.c term.c \
+SRCS=ansi.c crt.c html.c libsympathy.c render.c version.c vt102.c tty.c keydis.c \
history.c ring.c ptty.c terminal.c util.c log.c ipc.c slide.c symsocket.c
CPROTO=cproto
diff --git a/src/ansi.c b/src/ansi.c
index 7ec9abd..6253f95 100644
--- a/src/ansi.c
+++ b/src/ansi.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.21 2008/02/14 02:46:44 james
+ * *** empty log message ***
+ *
* Revision 1.20 2008/02/14 01:55:57 james
* *** empty log message ***
*
@@ -624,7 +627,7 @@ ansi_flush_escape (ANSI * a, Context * c)
for (i = 0; i < p->escape_ptr; ++i)
{
- term_send (c, p->escape_buf[i]);
+ c->k->key (c->k, p->escape_buf[i]);
}
p->escape_ptr = 0;
@@ -643,11 +646,11 @@ ansi_parse_deckey (ANSI * a, Context * c)
if ((p->escape_buf[2] >= 'A') || (p->escape_buf[2] <= 'Z'))
{
- term_send (c, KEY_UP + (p->escape_buf[2] - 'A'));
+ c->k->key (c->k, KEY_UP + (p->escape_buf[2] - 'A'));
}
else if ((p->escape_buf[2] >= 'a') || (p->escape_buf[2] <= 'z'))
{
- term_send (c, KEY_154 + (p->escape_buf[2] - 'a'));
+ c->k->key (c->k, KEY_154 + (p->escape_buf[2] - 'a'));
}
else
{
@@ -670,7 +673,7 @@ ansi_parse_ansikey (ANSI * a, Context * c)
}
if ((p->escape_buf[2] >= '0') || (p->escape_buf[2] <= '9'))
{
- term_send (c, KEY_180 + (p->escape_buf[2] - '0'));
+ c->k->key (c->k, KEY_180 + (p->escape_buf[2] - '0'));
}
else
{
@@ -783,7 +786,7 @@ ansi_parse_char (ANSI * a, Context * c, int ch)
}
else
{
- term_send (c, ch);
+ c->k->key (c->k, ch);
}
}
@@ -817,16 +820,13 @@ ansi_dispatch (ANSI * a, Context * c)
#endif
#if 1
- if (*buf == 1)
- {
- ansi_reset (a, NULL);
- return 0;
- }
if (*buf == 2)
{
+#if 0
a->history_ptr = c->h->wptr;
HISTORY_INC (c->h, a->history_ptr);
- return 0;
+#endif
+ return -1;
}
#endif
diff --git a/src/context.h b/src/context.h
index a0edf33..e746ad1 100644
--- a/src/context.h
+++ b/src/context.h
@@ -12,6 +12,9 @@
/*
* $Log$
+ * Revision 1.5 2008/02/14 02:46:44 james
+ * *** empty log message ***
+ *
* Revision 1.4 2008/02/14 01:55:57 james
* *** empty log message ***
*
@@ -35,7 +38,7 @@ typedef struct
TTY *t;
History *h;
Log *l;
- Term *r;
+ KeyDis *k;
} Context;
#endif /* __CONTEXT_H__ */
diff --git a/src/keydis.c b/src/keydis.c
new file mode 100644
index 0000000..e921f79
--- /dev/null
+++ b/src/keydis.c
@@ -0,0 +1,81 @@
+/*
+ * keydis.c:
+ *
+ * Copyright (c) 2008 James McKenzie <james@fishsoup.dhs.org>,
+ * All rights reserved.
+ *
+ */
+
+static char rcsid[] = "$Id$";
+
+/*
+ * $Log$
+ * Revision 1.1 2008/02/14 02:46:44 james
+ * *** empty log message ***
+ *
+ * Revision 1.1 2008/02/14 01:55:57 james
+ * *** empty log message ***
+ *
+ */
+
+
+#include "project.h"
+
+typedef struct
+{
+ KEYDIS_SIGNATURE;
+ Context *c;
+} KeyDis_VT102;
+
+typedef struct
+{
+ KEYDIS_SIGNATURE;
+ Socket *s;
+} KeyDis_IPC;
+
+
+static void
+keydis_close (KeyDis * t)
+{
+ free (t);
+}
+
+
+static int
+keydis_ipc_key (KeyDis * _t, int key)
+{
+ KeyDis_IPC *t = (KeyDis_IPC *) _t;
+
+ return ipc_msg_send_key (t->s, key);
+}
+
+static int
+keydis_vt102_key (KeyDis * _t, int key)
+{
+ KeyDis_VT102 *t = (KeyDis_VT102 *) _t;
+
+ vt102_send (t->c, key);
+ return 0;
+}
+
+
+KeyDis *
+keydis_vt102_new (Context * c)
+{
+ KeyDis_VT102 *t = malloc (sizeof (KeyDis_VT102));
+ t->key = keydis_vt102_key;
+ t->close = keydis_close;
+ t->c = c;
+ return (KeyDis *) t;
+}
+
+
+KeyDis *
+keydis_ipc_new (Socket * s)
+{
+ KeyDis_IPC *t = malloc (sizeof (KeyDis_IPC));
+ t->key = keydis_ipc_key;
+ t->close = keydis_close;
+ t->s = s;
+ return (KeyDis *) t;
+}
diff --git a/src/keydis.h b/src/keydis.h
new file mode 100644
index 0000000..d0ca69a
--- /dev/null
+++ b/src/keydis.h
@@ -0,0 +1,37 @@
+/*
+ * keydis.h:
+ *
+ * Copyright (c) 2008 James McKenzie <james@fishsoup.dhs.org>,
+ * All rights reserved.
+ *
+ */
+
+/*
+ * $Id$
+ */
+
+/*
+ * $Log$
+ * Revision 1.1 2008/02/14 02:46:44 james
+ * *** empty log message ***
+ *
+ * Revision 1.1 2008/02/14 01:55:57 james
+ * *** empty log message ***
+ *
+ */
+
+#ifndef __KEYDIS_H__
+#define __KEYDIS_H__
+
+
+#define KEYDIS_SIGNATURE \
+ void (*close)(struct KeyDis_struct *); \
+ int (*key)(struct KeyDis_struct *,int key)
+
+typedef struct KeyDis_struct
+{
+ KEYDIS_SIGNATURE;
+} KeyDis;
+
+
+#endif /* __KEYDIS_H__ */
diff --git a/src/prototypes.h b/src/prototypes.h
index dc88c14..28cffac 100644
--- a/src/prototypes.h
+++ b/src/prototypes.h
@@ -73,6 +73,9 @@ extern VT102 *vt102_new(void);
extern void vt102_free(VT102 *v);
/* tty.c */
extern void tty_pre_select(TTY *t, fd_set *rfds, fd_set *wfds);
+/* keydis.c */
+extern KeyDis *keydis_vt102_new(Context *c);
+extern KeyDis *keydis_ipc_new(Socket *s);
/* history.c */
extern History *history_new(int n);
extern void history_free(History *h);
@@ -107,6 +110,9 @@ extern void ipc_consume_message_in_slide(Slide *s);
extern int ipc_msg_send(Socket *s, IPC_Msg *m);
extern int ipc_msg_send_debug(Socket *s, char *msg);
extern int ipc_msg_send_history(Socket *s, History_ent *l);
+extern int ipc_msg_send_vt102(Socket *s, VT102 *v);
+extern int ipc_msg_send_key(Socket *s, int key);
+extern int ipc_msg_send_term(Socket *s, void *buf, int len);
/* slide.c */
extern void slide_free(Slide *s);
extern void slide_consume(Slide *s, int n);
diff --git a/src/slide.c b/src/slide.c
index d032421..06c7768 100644
--- a/src/slide.c
+++ b/src/slide.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.3 2008/02/14 02:46:44 james
+ * *** empty log message ***
+ *
* Revision 1.2 2008/02/14 00:57:58 james
* *** empty log message ***
*
@@ -41,8 +44,8 @@ slide_consume (Slide * s, int n)
{
s->nbytes -= n;
- if (s->nbytes<0)
- abort();
+ if (s->nbytes < 0)
+ abort ();
memmove (s->slide, s->slide + n, s->nbytes);
diff --git a/src/symsocket.c b/src/symsocket.c
index 25657db..061ff6d 100644
--- a/src/symsocket.c
+++ b/src/symsocket.c
@@ -11,6 +11,9 @@ static char rcsid[] =
/*
* $Log$
+ * Revision 1.3 2008/02/14 02:46:44 james
+ * *** empty log message ***
+ *
* Revision 1.2 2008/02/14 00:57:58 james
* *** empty log message ***
*
@@ -164,6 +167,7 @@ socket_connect (char *path)
return ret;
}
+
void
socket_consume_msg (Socket * s)
{
@@ -172,7 +176,7 @@ socket_consume_msg (Socket * s)
if (!s->msg)
return;
- ipc_consume_message_in_slide(s->read_buf);
+ ipc_consume_message_in_slide (s->read_buf);
s->msg = ipc_check_for_message_in_slide (s->read_buf);
}
@@ -203,7 +207,7 @@ socket_post_select (Socket * s, fd_set * rfds, fd_set * wfds)
{
char buf[1024];
int n;
- int error=0;
+ int error = 0;
if ((!SLIDE_EMPTY (s->write_buf)) && FD_ISSET (s->fd, wfds))
@@ -214,7 +218,8 @@ socket_post_select (Socket * s, fd_set * rfds, fd_set * wfds)
n = wrap_write (s->fd, SLIDE_RPTR (s->write_buf), n);
if (n > 0)
slide_consume (s->write_buf, n);
- if (n<0) error=-1;
+ if (n < 0)
+ error = -1;
}
if (!SLIDE_FULL (s->read_buf) && FD_ISSET (s->fd, rfds))
@@ -225,7 +230,8 @@ socket_post_select (Socket * s, fd_set * rfds, fd_set * wfds)
n = wrap_read (s->fd, SLIDE_WPTR (s->read_buf), n);
if (n > 0)
slide_added (s->read_buf, n);
- if (n<0) error=-1;
+ if (n < 0)
+ error = -1;
}
s->msg = ipc_check_for_message_in_slide (s->read_buf);
@@ -248,14 +254,15 @@ socket_write (Socket * s, void *buf, int len)
(SLIDE_BYTES (s->write_buf) >
MAX_TXN) ? MAX_TXN : SLIDE_BYTES (s->write_buf);
n = wrap_write (s->fd, SLIDE_RPTR (s->write_buf), n);
- {
- uint8_t *c=SLIDE_RPTR(s->write_buf);
+ {
+ uint8_t *c = SLIDE_RPTR (s->write_buf);
}
if (n > 0)
slide_consume (s->write_buf, n);
-
- if (n<0) return -1;
+
+ if (n < 0)
+ return -1;
return len;
}
diff --git a/src/term.c b/src/term.c
deleted file mode 100644
index 8c4f427..0000000
--- a/src/term.c
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * term.c:
- *
- * Copyright (c) 2008 James McKenzie <james@fishsoup.dhs.org>,
- * All rights reserved.
- *
- */
-
-static char rcsid[] = "$Id$";
-
-/*
- * $Log$
- * Revision 1.1 2008/02/14 01:55:57 james
- * *** empty log message ***
- *
- */
-
diff --git a/src/term.h b/src/term.h
deleted file mode 100644
index 3190ef3..0000000
--- a/src/term.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * term.h:
- *
- * Copyright (c) 2008 James McKenzie <james@fishsoup.dhs.org>,
- * All rights reserved.
- *
- */
-
-/*
- * $Id$
- */
-
-/*
- * $Log$
- * Revision 1.1 2008/02/14 01:55:57 james
- * *** empty log message ***
- *
- */
-
-#ifndef __TERM_H__
-#define __TERM_H__
-
-#endif /* __TERM_H__ */
diff --git a/src/vt102.c b/src/vt102.c
index 33d2d67..d33d309 100644
--- a/src/vt102.c
+++ b/src/vt102.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.27 2008/02/14 02:46:45 james
+ * *** empty log message ***
+ *
* Revision 1.26 2008/02/14 01:55:57 james
* *** empty log message ***
*
@@ -1209,7 +1212,8 @@ vt102_send (Context * c, uint8_t key)
{
uint8_t ch;
- if (!c->t) return;
+ if (!c->t)
+ return;
#if 0
fprintf (stderr, "vts: %d(%c)\n", key, (key > 31) ? key : ' ');