chiark / gitweb /
*** empty log message ***
authorjames <james>
Thu, 14 Feb 2008 10:34:30 +0000 (10:34 +0000)
committerjames <james>
Thu, 14 Feb 2008 10:34:30 +0000 (10:34 +0000)
12 files changed:
apps/Makefile.am
apps/client.c
apps/clients.c
apps/clients.h
apps/sympathyd.c
src/prototypes.h
src/ptty.c
src/terminal.c
src/tty.c
src/tty.h
src/vt102.c
test/test.c

index b14601cd344314e19b58cfbbbfea0cfc657918f1..dd6b433c51a7426d68f865e4a1448cec310fd76f 100644 (file)
@@ -7,6 +7,9 @@
 # $Id$
 #
 # $Log$
 # $Id$
 #
 # $Log$
+# Revision 1.6  2008/02/14 10:34:30  james
+# *** empty log message ***
+#
 # Revision 1.5  2008/02/14 02:46:44  james
 # *** empty log message ***
 #
 # Revision 1.5  2008/02/14 02:46:44  james
 # *** empty log message ***
 #
@@ -35,7 +38,7 @@ sympathy_SOURCES = sympathy.c client.c
 sympathy_LDADD = ../src/libsympathy.a  -lutil
 
 sympathyd_SOURCES = sympathyd.c clients.c client.c
 sympathy_LDADD = ../src/libsympathy.a  -lutil
 
 sympathyd_SOURCES = sympathyd.c clients.c client.c
-sympathyd_LDADD = ../src/libsympathy.la  -lutil
+sympathyd_LDADD = ../src/libsympathy.a  -lutil
 
 AM_CFLAGS=-g -Werror
 
 
 AM_CFLAGS=-g -Werror
 
index 28526f223a7f37dde24e3342f69da982c9335d9f..541603b6d84152fc64e74b958555a5f9ec68865e 100644 (file)
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
 
 /*
  * $Log$
+ * Revision 1.5  2008/02/14 10:34:47  james
+ * *** empty log message ***
+ *
  * Revision 1.4  2008/02/14 10:34:30  james
  * *** empty log message ***
  *
  * Revision 1.4  2008/02/14 10:34:30  james
  * *** empty log message ***
  *
@@ -53,8 +56,8 @@ server_msg (IPC_Msg * m, Context * c)
       vt102_parse (c, m->term.term, m->term.len);
       break;
     case IPC_MSG_TYPE_STATUS:
       vt102_parse (c, m->term.term, m->term.len);
       break;
     case IPC_MSG_TYPE_STATUS:
-       vt102_status_line(c->v,m->status.status);
-       break;
+      vt102_status_line (c->v, m->status.status);
+      break;
     default:
       fprintf (stderr, "Unhandeled message type %d\n", m->hdr.type);
     }
     default:
       fprintf (stderr, "Unhandeled message type %d\n", m->hdr.type);
     }
index cd7bcee8d7593829a1fef8beacfb6c34cc9eea4e..40713a9db057d1f77172e725f4005a619a03c90e 100644 (file)
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
 
 /*
  * $Log$
+ * Revision 1.5  2008/02/14 10:34:47  james
+ * *** empty log message ***
+ *
  * Revision 1.4  2008/02/14 10:34:30  james
  * *** empty log message ***
  *
  * Revision 1.4  2008/02/14 10:34:30  james
  * *** empty log message ***
  *
@@ -180,8 +183,9 @@ send_status (Clients * cs, char *msg)
 
   Client *c;
 
 
   Client *c;
 
-  if (!msg) return;
-  len=strlen(msg)+1;
+  if (!msg)
+    return;
+  len = strlen (msg) + 1;
 
   if (!len)
     return;
 
   if (!len)
     return;
@@ -190,8 +194,8 @@ send_status (Clients * cs, char *msg)
 
   m->size = len + sizeof (IPC_Msg_status);
   m->type = IPC_MSG_TYPE_STATUS;
 
   m->size = len + sizeof (IPC_Msg_status);
   m->type = IPC_MSG_TYPE_STATUS;
-  strncpy(m->status,msg, IPC_MAX_BUF);
-  m->status[IPC_MAX_BUF-1]=0;
+  strncpy (m->status, msg, IPC_MAX_BUF);
+  m->status[IPC_MAX_BUF - 1] = 0;
 
   for (c = cs->head; c; c = c->next)
     {
 
   for (c = cs->head; c; c = c->next)
     {
@@ -262,5 +266,3 @@ send_vt102 (VT102 * v, Client * c)
     c->dead++;
 
 }
     c->dead++;
 
 }
-
-
index 605b3cda8834a9ab7c421767e16d4d4cf677ca91..f8dd9f1067bd5733f61d4915edfbf7a17f643a6e 100644 (file)
@@ -12,6 +12,9 @@
 
 /*
  * $Log$
 
 /*
  * $Log$
+ * Revision 1.5  2008/02/14 10:34:47  james
+ * *** empty log message ***
+ *
  * Revision 1.4  2008/02/14 10:34:30  james
  * *** empty log message ***
  *
  * Revision 1.4  2008/02/14 10:34:30  james
  * *** empty log message ***
  *
@@ -44,17 +47,18 @@ typedef struct
 
 
 /* clients.c */
 
 
 /* clients.c */
-extern void client_free(Client *c);
-extern Client *clients_new_client(Clients *cs, Socket *s, Context *ctx);
-extern void clients_reap(Clients *cs);
-extern Clients *clients_new(void);
-extern void clients_pre_select(Clients *cs, fd_set *rfds, fd_set *wfds);
-extern void clients_post_select(Clients *cs, Context *ctx, fd_set *rfds, fd_set *wfds);
-extern void clients_shutdown(Clients *cs);
-
-extern int send_output(Clients *cs, void *buf, int len);
-extern int send_status(Clients *cs, char *msg);
-extern void send_history(History *h, Client *c);
-extern void send_vt102(VT102 *v, Client *c);
+extern void client_free (Client * c);
+extern Client *clients_new_client (Clients * cs, Socket * s, Context * ctx);
+extern void clients_reap (Clients * cs);
+extern Clients *clients_new (void);
+extern void clients_pre_select (Clients * cs, fd_set * rfds, fd_set * wfds);
+extern void clients_post_select (Clients * cs, Context * ctx, fd_set * rfds,
+                                 fd_set * wfds);
+extern void clients_shutdown (Clients * cs);
+
+extern int send_output (Clients * cs, void *buf, int len);
+extern int send_status (Clients * cs, char *msg);
+extern void send_history (History * h, Client * c);
+extern void send_vt102 (VT102 * v, Client * c);
 
 #endif
 
 #endif
index 352b6a9f01bf34759e16c95e44fcc5a7fb0c1cd2..41a39f270297dcf151f221487bd2656309c3b2e0 100644 (file)
@@ -11,6 +11,9 @@ static char rcsid[] =
 
 /*
  * $Log$
 
 /*
  * $Log$
+ * Revision 1.10  2008/02/14 10:39:14  james
+ * *** empty log message ***
+ *
  * Revision 1.9  2008/02/14 10:34:47  james
  * *** empty log message ***
  *
  * Revision 1.9  2008/02/14 10:34:47  james
  * *** empty log message ***
  *
@@ -53,6 +56,7 @@ typedef struct
   int baud;
   int crtscts;
   int cd_edge_sec;
   int baud;
   int crtscts;
   int cd_edge_sec;
+  int blocked;
   int bootstrap;
 } Status;
 
   int bootstrap;
 } Status;
 
@@ -74,6 +78,7 @@ get_status (TTY * t, Clients * cs)
   status.lines = tty_status.lines;
   status.baud = tty_status.baud;
   status.crtscts = (tty_status.termios.c_cflag & CRTSCTS) ? 1 : 0;
   status.lines = tty_status.lines;
   status.baud = tty_status.baud;
   status.crtscts = (tty_status.termios.c_cflag & CRTSCTS) ? 1 : 0;
+  status.blocked=tty_status.blocked;
 
   cd = (tty_status.lines & TIOCM_CD) ? 1 : 0;
 
 
   cd = (tty_status.lines & TIOCM_CD) ? 1 : 0;
 
@@ -224,6 +229,13 @@ check_status (Context * c, Clients * cs)
   ptr = do_line (ptr, status.lines, TIOCM_DSR);
   ptr = do_line (ptr, status.lines, TIOCM_RI);
 
   ptr = do_line (ptr, status.lines, TIOCM_DSR);
   ptr = do_line (ptr, status.lines, TIOCM_RI);
 
+  if (status.blocked)
+  {
+      t = ", Locked";
+      while (*t)
+        *(ptr++) = *(t++);
+  }
+
   if (status.crtscts)
     {
       t = ", Flow";
   if (status.crtscts)
     {
       t = ", Flow";
index 28cffacb1e6c6394b9b96e0baea680ba8d1f0386..3fca7af629805db34902afc60ce99dc24d6d8143 100644 (file)
@@ -73,6 +73,7 @@ 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);
 extern void vt102_free(VT102 *v);
 /* tty.c */
 extern void tty_pre_select(TTY *t, fd_set *rfds, fd_set *wfds);
+extern int tty_get_status(TTY *t, TTY_Status *s);
 /* keydis.c */
 extern KeyDis *keydis_vt102_new(Context *c);
 extern KeyDis *keydis_ipc_new(Socket *s);
 /* keydis.c */
 extern KeyDis *keydis_vt102_new(Context *c);
 extern KeyDis *keydis_ipc_new(Socket *s);
@@ -113,6 +114,7 @@ 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);
 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);
+extern int ipc_msg_send_status(Socket *s, char *buf);
 /* slide.c */
 extern void slide_free(Slide *s);
 extern void slide_consume(Slide *s, int n);
 /* slide.c */
 extern void slide_free(Slide *s);
 extern void slide_consume(Slide *s, int n);
index c0f85f5689e647e7f1afc8e8a62e1d5c33222dc5..63d1e44738f7ff240a1523d898f42995e686b75c 100644 (file)
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
 
 /*
  * $Log$
+ * Revision 1.4  2008/02/14 10:39:14  james
+ * *** empty log message ***
+ *
  * Revision 1.3  2008/02/13 09:12:21  james
  * *** empty log message ***
  *
  * Revision 1.3  2008/02/13 09:12:21  james
  * *** empty log message ***
  *
@@ -164,6 +167,7 @@ ptty_open (char *path, char *argv[])
   t->wfd = t->fd;
   t->size.x = winsize.ws_row;
   t->size.y = winsize.ws_col;
   t->wfd = t->fd;
   t->size.x = winsize.ws_row;
   t->size.y = winsize.ws_col;
+  t->blocked = 0;
 
   return (TTY *) t;
 }
 
   return (TTY *) t;
 }
index 03b688a30b62288a5e2c1900b5d339b8db625f4b..ab048fdd75d5d87f4b8936fb97375e1d6c513f6d 100644 (file)
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
 
 /*
  * $Log$
+ * Revision 1.8  2008/02/14 10:39:14  james
+ * *** empty log message ***
+ *
  * Revision 1.7  2008/02/14 01:55:57  james
  * *** empty log message ***
  *
  * Revision 1.7  2008/02/14 01:55:57  james
  * *** empty log message ***
  *
@@ -244,11 +247,11 @@ terminal_open (int rfd, int wfd)
 {
   TERMINAL *t;
   pid_t child;
 {
   TERMINAL *t;
   pid_t child;
-  char name[1024];
   struct termios termios;
 
   t = (TERMINAL *) malloc (sizeof (TERMINAL));
 
   struct termios termios;
 
   t = (TERMINAL *) malloc (sizeof (TERMINAL));
 
+  strcpy(t->name,"terminal");
   t->rfd = rfd;
   t->wfd = wfd;
 
   t->rfd = rfd;
   t->wfd = wfd;
 
@@ -271,6 +274,7 @@ terminal_open (int rfd, int wfd)
   t->recv = terminal_read;
   t->xmit = terminal_write;
   t->close = terminal_close;
   t->recv = terminal_read;
   t->xmit = terminal_write;
   t->close = terminal_close;
+  t->blocked = 0;
 
 
   terminal_getsize ((TTY *) t);
 
 
   terminal_getsize ((TTY *) t);
index fb60246c51a488e226500193f88cd57ca49c18b7..cd9081022fc7d405c096a9ed4756a444295fe703 100644 (file)
--- a/src/tty.c
+++ b/src/tty.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
 
 /*
  * $Log$
+ * Revision 1.8  2008/02/14 10:36:18  james
+ * *** empty log message ***
+ *
  * Revision 1.7  2008/02/14 10:34:30  james
  * *** empty log message ***
  *
  * Revision 1.7  2008/02/14 10:34:30  james
  * *** empty log message ***
  *
@@ -211,13 +214,14 @@ int
 tty_get_status (TTY * t, TTY_Status * s)
 {
 
 tty_get_status (TTY * t, TTY_Status * s)
 {
 
-       s->lines=0;
+  s->lines = 0;
   ioctl (t->rfd, TIOCMGET, &s->lines);
 
   if (tcgetattr (t->rfd, &s->termios))
     return -1;
   ioctl (t->rfd, TIOCMGET, &s->lines);
 
   if (tcgetattr (t->rfd, &s->termios))
     return -1;
-  s->baud=speed_t_to_baud(cfgetispeed(&s->termios));
+
+  s->baud = speed_t_to_baud (cfgetispeed (&s->termios));
+  s->blocked = t->blocked;
 
   return 0;
 }
 
   return 0;
 }
index 5286c28134b4a22e4f0c439da82eea88b2d4b197..9b73c9c1497057053390797157c740540306d304 100644 (file)
--- a/src/tty.h
+++ b/src/tty.h
@@ -12,6 +12,9 @@
 
 /*
  * $Log$
 
 /*
  * $Log$
+ * Revision 1.7  2008/02/14 10:36:18  james
+ * *** empty log message ***
+ *
  * Revision 1.6  2008/02/14 10:34:30  james
  * *** empty log message ***
  *
  * Revision 1.6  2008/02/14 10:34:30  james
  * *** empty log message ***
  *
@@ -37,6 +40,7 @@
 
 #define TTY_SIGNATURE \
        char name[1024]; \
 
 #define TTY_SIGNATURE \
        char name[1024]; \
+        int blocked; \
        CRT_Pos size; \
        void (*close)(struct TTY_struct *); \
        int (*recv)(struct TTY_struct *,void *buf,int len); \
        CRT_Pos size; \
        void (*close)(struct TTY_struct *); \
        int (*recv)(struct TTY_struct *,void *buf,int len); \
@@ -51,6 +55,7 @@ typedef struct TTY_struct
 
 typedef struct {
   int lines;
 
 typedef struct {
   int lines;
+  int blocked;
   struct termios termios;
   int baud;
 } TTY_Status;
   struct termios termios;
   int baud;
 } TTY_Status;
index d33d3092d33369156ef424075c9a030b86cf8dc1..f481c1a7dfd3810413fc44ed7249039167079f5f 100644 (file)
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
 
 /*
  * $Log$
+ * Revision 1.28  2008/02/14 10:34:30  james
+ * *** empty log message ***
+ *
  * Revision 1.27  2008/02/14 02:46:45  james
  * *** empty log message ***
  *
  * Revision 1.27  2008/02/14 02:46:45  james
  * *** empty log message ***
  *
@@ -1187,7 +1190,6 @@ vt102_parse_char (Context * c, int ch)
       v->current_line = v->pos;
     }
 
       v->current_line = v->pos;
     }
 
-  vt102_status_line (v, "VT102 foo bar baz I'm the urban spaceman baby");
 }
 
 vt102_parse (Context * c, char *buf, int len)
 }
 
 vt102_parse (Context * c, char *buf, int len)
@@ -1413,7 +1415,7 @@ vt102_reset (VT102 * v)
 
   vt102_save_state (v);
 
 
   vt102_save_state (v);
 
-  vt102_status_line (v, "VT102 foo bar baz I'm the urban spaceman baby");
+  vt102_status_line (v, "");
 
 }
 
 
 }
 
index 92ffdda8f73ab56ee99e927fbeb4a2bae23731db..af12ee9857acb021ab49e91eb914f6ecfe50facc 100644 (file)
@@ -6,29 +6,84 @@
  *
  */
 
  *
  */
 
-static char rcsid[] = "$Id$";
+static char rcsid[] =
+  "$Id$";
 
 /*
  * $Log$
 
 /*
  * $Log$
- * Revision 1.4  2008/02/14 00:57:58  james
+ * Revision 1.5  2008/02/14 10:34:30  james
  * *** empty log message ***
  *
  * *** empty log message ***
  *
- * Revision 1.3  2008/02/13 18:05:06  james
+ * Revision 1.7  2008/02/14 02:46:44  james
  * *** empty log message ***
  *
  * *** empty log message ***
  *
- * Revision 1.2  2008/02/04 11:30:57  james
+ * Revision 1.6  2008/02/14 00:57:58  james
  * *** empty log message ***
  *
  * *** empty log message ***
  *
- * Revision 1.1  2008/02/03 16:20:24  james
+ * Revision 1.5  2008/02/13 18:05:06  james
+ * *** empty log message ***
+ *
+ * Revision 1.4  2008/02/13 17:21:55  james
+ * *** empty log message ***
+ *
+ * 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 ***
+ *
+ * Revision 1.1  2008/02/05 14:25:49  james
  * *** empty log message ***
  *
  */
 
  * *** empty log message ***
  *
  */
 
-#include "sympathy.h"
+#include <sympathy.h>
+
 
 
-int main(int argc,char *argv[])
+int
+main (int argc, char *argv[])
 {
 {
+  fd_set rfds, wfds;
+  ANSI a = { 0 };
+  Context c;
+
+
+  c.t = ptty_open (NULL, NULL);
+  c.v = vt102_new ();
+  c.h = history_new (200);
+  c.l = file_log_new ("log");
+  c.k = keydis_vt102_new (&c);
+
+  terminal_register_handlers ();
+  a.terminal = terminal_open (0, 1);
+
+  ansi_reset (&a, NULL);
+
+  for (;;)
+    {
+      struct timeval tv = { 10, 0 };
+
+      FD_ZERO (&rfds);
+      FD_ZERO (&wfds);
+
+      tty_pre_select (c.t, &rfds, &wfds);
+      tty_pre_select (a.terminal, &rfds, &wfds);
+
+
+      select (FD_SETSIZE, &rfds, &wfds, NULL, &tv);
+
+      if (FD_ISSET (c.t->rfd, &rfds))
+        {
+         if (vt102_dispatch(&c)) break;
+        }
+
+      ansi_dispatch (&a, &c);
+      ansi_update (&a, &c);
+
 
 
+    }
 
 
-return 0;
+  ansi_terminal_reset (&a);
+  terminal_atexit ();
+  printf ("QUAT\n");
 }
 }