aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjames <>2008-02-08 15:06:52 +0000
committerjames <>2008-02-08 15:06:52 +0000
commita4101322d71ce2f800d741e98ec8f537c70b663f (patch)
tree9ff178d83a007491efafce60ba2d7b0a363e2858
parent314cd6b742efa6e0c97f4b9e991add65c5bbaad4 (diff)
downloadsympathy-a4101322d71ce2f800d741e98ec8f537c70b663f.tar.gz
sympathy-a4101322d71ce2f800d741e98ec8f537c70b663f.tar.bz2
sympathy-a4101322d71ce2f800d741e98ec8f537c70b663f.zip
*** empty log message ***
-rw-r--r--apps/ipc.h7
-rw-r--r--apps/sympathyd.c9
-rw-r--r--src/Makefile.am6
-rw-r--r--src/history.c52
-rw-r--r--src/history.h35
-rw-r--r--src/libsympathy.c6
-rw-r--r--src/ring.c62
-rw-r--r--src/ring.h65
-rw-r--r--src/vt102.h4
9 files changed, 242 insertions, 4 deletions
diff --git a/apps/ipc.h b/apps/ipc.h
index 9ac3642..33852fe 100644
--- a/apps/ipc.h
+++ b/apps/ipc.h
@@ -3,3 +3,10 @@
#include <sys/un.h>
#define SOCKPATH "/tmp/sympathy"
+
+typedef struct {
+int type;
+int len;
+uint8_t data[0];
+} Sympathy_msg;
+
diff --git a/apps/sympathyd.c b/apps/sympathyd.c
index a535ac6..4845c95 100644
--- a/apps/sympathyd.c
+++ b/apps/sympathyd.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.3 2008/02/08 15:06:52 james
+ * *** empty log message ***
+ *
* Revision 1.2 2008/02/07 15:42:49 james
* *** empty log message ***
*
@@ -21,6 +24,10 @@ static char rcsid[] = "$Id$";
#include "sympathy.h"
#include "ipc.h"
+#include "../src/crt.h"
+#include "../src/vt102.h"
+
+
int main(int argc,char *argv[])
{
int fd;
@@ -48,6 +55,6 @@ if (listen(fd,5)<0) {
}
-
+printf("sizeof(VT102)=%d\n",sizeof(VT102));
}
diff --git a/src/Makefile.am b/src/Makefile.am
index 6cfd221..59bd862 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -8,6 +8,9 @@
# $Id$
#
# $Log$
+# Revision 1.5 2008/02/08 15:06:42 james
+# *** empty log message ***
+#
# Revision 1.4 2008/02/07 01:04:16 james
# *** empty log message ***
#
@@ -26,7 +29,8 @@
INCLUDES =
-SRCS= ansi.c crt.c html.c libsympathy.c render.c version.c vt102.c tty.c
+SRCS= ansi.c crt.c html.c libsympathy.c render.c version.c vt102.c tty.c \
+ history.c buf.c
CPROTO=cproto
SYMPATHYSRCS=${SRCS}
diff --git a/src/history.c b/src/history.c
new file mode 100644
index 0000000..026714c
--- /dev/null
+++ b/src/history.c
@@ -0,0 +1,52 @@
+/*
+ * history.c:
+ *
+ * Copyright (c) 2008 James McKenzie <james@fishsoup.dhs.org>,
+ * All rights reserved.
+ *
+ */
+
+static char rcsid[] = "$Id$";
+
+/*
+ * $Log$
+ * Revision 1.1 2008/02/08 15:06:42 james
+ * *** empty log message ***
+ *
+ */
+
+#include "project.h"
+
+History *history_new(int n)
+{
+History *ret;
+
+ret=(History *) malloc(sizeof(History));
+ret->lines=malloc(n*sizeof(History_ent));
+memset(ret->lines,0,n*sizeof(History_ent));
+
+ret->wptr=0;
+ret->nlines=n;
+
+return ret;
+}
+
+void history_free(History *h)
+{
+if (!h) return;
+if (h->lines) free(h->lines);
+free(h);
+}
+
+
+void history_add(History *h,CRT_CA *c)
+{
+if (!h) return;
+
+memcpy(h->lines[h->wptr].line,c,sizeof(CRT_CA)*CRT_COLS);
+h->wptr++;
+
+if (h->wptr==h->nlines)
+ h->wptr=0;
+
+}
diff --git a/src/history.h b/src/history.h
new file mode 100644
index 0000000..6c1bdba
--- /dev/null
+++ b/src/history.h
@@ -0,0 +1,35 @@
+/*
+ * history.h:
+ *
+ * Copyright (c) 2008 James McKenzie <james@fishsoup.dhs.org>,
+ * All rights reserved.
+ *
+ */
+
+/*
+ * $Id$
+ */
+
+/*
+ * $Log$
+ * Revision 1.1 2008/02/08 15:06:42 james
+ * *** empty log message ***
+ *
+ */
+
+#ifndef __HISTORY_H__
+#define __HISTORY_H__
+
+typedef struct {
+int valid;
+time_t t;
+CRT_CA line[CRT_COLS];
+} History_ent;
+
+typedef struct {
+History_ent *lines;
+int nlines;
+int wptr;
+} History;
+
+#endif /* __HISTORY_H__ */
diff --git a/src/libsympathy.c b/src/libsympathy.c
index ffe8d16..9c3608b 100644
--- a/src/libsympathy.c
+++ b/src/libsympathy.c
@@ -11,6 +11,9 @@ static char rcsid[] =
/*
* $Log$
+ * Revision 1.13 2008/02/08 15:06:42 james
+ * *** empty log message ***
+ *
* Revision 1.12 2008/02/07 13:26:35 james
* *** empty log message ***
*
@@ -79,6 +82,7 @@ testy (void)
char c;
TTY *t;
VT102 *v;
+ History *h;
int i;
@@ -132,7 +136,7 @@ testy (void)
if (FD_ISSET (t->fd, &rfd))
{
- if (vt102_dispatch_one (v, t))
+ if (vt102_dispatch_one (v, t,h))
break;
}
diff --git a/src/ring.c b/src/ring.c
new file mode 100644
index 0000000..310ea64
--- /dev/null
+++ b/src/ring.c
@@ -0,0 +1,62 @@
+/*
+ * ring.c:
+ *
+ * Copyright (c) 2008 James McKenzie <james@fishsoup.dhs.org>,
+ * All rights reserved.
+ *
+ */
+
+static char rcsid[] = "$Id$";
+
+/*
+ * $Log$
+ * Revision 1.1 2008/02/08 15:06:42 james
+ * *** empty log message ***
+ *
+ */
+
+#include "project.h"
+
+int ring_read(Ring *r,void *b,int n)
+{
+int red=0;
+
+while (n--) {
+
+if (!ring_read_one(r,b))
+ break;
+
+b++;
+red++;
+}
+
+return red;
+}
+
+int ring_write(Ring *r,void *b,int n)
+{
+int writ=0;
+
+while (n--) {
+
+if (!ring_write_one(r,b))
+ break;
+
+b++;
+writ++;
+}
+
+return writ;
+}
+
+
+
+Ring *ring_new(int n)
+{
+Ring *ret=(Ring *)malloc(sizeof(Ring));
+ret->buf=(uint8_t *)malloc(n);
+ret->size=n;
+ret->wptr=ret->rptr=0;
+
+return ret;
+}
diff --git a/src/ring.h b/src/ring.h
new file mode 100644
index 0000000..d0dd3a0
--- /dev/null
+++ b/src/ring.h
@@ -0,0 +1,65 @@
+/*
+ * ring.h:
+ *
+ * Copyright (c) 2008 James McKenzie <james@fishsoup.dhs.org>,
+ * All rights reserved.
+ *
+ */
+
+/*
+ * $Id$
+ */
+
+/*
+ * $Log$
+ * Revision 1.1 2008/02/08 15:06:42 james
+ * *** empty log message ***
+ *
+ */
+
+#ifndef __RING_H__
+#define __RING_H__
+
+typedef struct {
+ uint8_t *ring;
+ int wptr;
+ int rptr;
+ int size;
+} Ring;
+
+#define RING_NEXT(r,a) (((a)+1) % ((r)->size))
+#define RING_NEXT_R(r) RING_NEXT(r,r->rptr)
+#define RING_NEXT_W(r) RING_NEXT(r,r->wptr)
+
+#define RING_EMPTY(r) (((r)->wptr) == ((r)->rptr))
+#define RING_FULL(r) (RING_NEXT_W(r) == ((r)->rptr))
+
+static inline int ring_write_one(Ring *r,uint8_t *c)
+{
+if (RING_FULL(r)) return 0;
+
+r->ring[r->wptr++]=*c;
+
+if (r->wptr==r->size)
+ r->wptr=0;
+}
+
+return 1;
+}
+
+static inline int ring_read_one(Ring *r,uint8_t *c)
+{
+if (RING_EMPTY(r)) return 0;
+
+*c=r->ring[r->rptr++];
+
+if (r->rptr==r->size)
+ r->rptr=0;
+}
+
+return 1;
+}
+
+
+
+#endif /* __RING_H__ */
diff --git a/src/vt102.h b/src/vt102.h
index e8caf5e..4f5ff05 100644
--- a/src/vt102.h
+++ b/src/vt102.h
@@ -12,6 +12,9 @@
/*
* $Log$
+ * Revision 1.11 2008/02/08 15:06:42 james
+ * *** empty log message ***
+ *
* Revision 1.10 2008/02/07 12:16:04 james
* *** empty log message ***
*
@@ -94,7 +97,6 @@ typedef struct
int application_keypad_mode;
- TTY *tty;
} VT102;