chiark / gitweb /
*** empty log message ***
authorjames <james>
Fri, 8 Feb 2008 15:06:42 +0000 (15:06 +0000)
committerjames <james>
Fri, 8 Feb 2008 15:06:42 +0000 (15:06 +0000)
apps/ipc.h
apps/sympathyd.c
src/Makefile.am
src/history.c [new file with mode: 0644]
src/history.h [new file with mode: 0644]
src/libsympathy.c
src/ring.c [new file with mode: 0644]
src/ring.h [new file with mode: 0644]
src/vt102.h

index 9ac3642d93761f1c8d92aee10621c6fedbae0606..33852fe7b1908f6dc2c1e160051ce50e972d734b 100644 (file)
@@ -3,3 +3,10 @@
 #include <sys/un.h>
 
 #define SOCKPATH "/tmp/sympathy"
+
+typedef struct {
+int type;
+int len;
+uint8_t data[0];
+} Sympathy_msg;
+
index a535ac6a34c7a7bb38e63ca8c73ea0f87c5b3e26..4845c95c27866344aeda50bab0abbcc8ae725a29 100644 (file)
@@ -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));
 
 }
index 6cfd2216f2a4745eef115cb1a8d195772a638f20..59bd862bcc69554cca3fe2537ce256ec5962a52f 100644 (file)
@@ -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 (file)
index 0000000..026714c
--- /dev/null
@@ -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 (file)
index 0000000..6c1bdba
--- /dev/null
@@ -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__ */
index ffe8d1679cb7654d2d77694f3f030739557ceff6..9c3608b166069d3c7a0408d41ee454c0c19897d6 100644 (file)
@@ -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 (file)
index 0000000..310ea64
--- /dev/null
@@ -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 (file)
index 0000000..d0dd3a0
--- /dev/null
@@ -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__ */
index e8caf5ed291ca57f3296ad4f2dd12d9b67aa1e0d..4f5ff059789e77f4984e9606bab65a71ebe135ac 100644 (file)
@@ -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;