chiark / gitweb /
*** empty log message ***
authorjames <james>
Fri, 15 Feb 2008 03:32:07 +0000 (03:32 +0000)
committerjames <james>
Fri, 15 Feb 2008 03:32:07 +0000 (03:32 +0000)
15 files changed:
apps/client.c
apps/clients.c
apps/sympathyd.c
src/Makefile.am
src/ansi.c
src/context.h
src/ipc.c
src/ipc.h
src/keydis.c
src/keydis.h
src/prototypes.h
src/serial.c
src/terminal.c
src/tty.c
src/vt102.c

index 541603b6d84152fc64e74b958555a5f9ec68865e..93ade70768eca57e9647cb29f906171236dd0783 100644 (file)
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.6  2008/02/15 03:32:07  james
+ * *** empty log message ***
+ *
  * Revision 1.5  2008/02/14 10:34:47  james
  * *** empty log message ***
  *
@@ -56,7 +59,7 @@ server_msg (IPC_Msg * m, Context * c)
       vt102_parse (c, m->term.term, m->term.len);
       break;
     case IPC_MSG_TYPE_STATUS:
-      vt102_status_line (c->v, m->status.status);
+      cmd_new_status (c->d, c, m->status.status);
       break;
     default:
       fprintf (stderr, "Unhandeled message type %d\n", m->hdr.type);
@@ -72,6 +75,7 @@ client (void)
   ANSI a = { 0 };
   Context c;
 
+
   s = socket_connect ("socket");
 
   if (!s)
@@ -85,6 +89,7 @@ client (void)
   c.h = history_new (200);
   c.l = NULL;
   c.k = keydis_ipc_new (s);
+  c.d = cmd_new ();
 
   terminal_register_handlers ();
   a.terminal = terminal_open (0, 1);
@@ -95,6 +100,9 @@ client (void)
     {
       struct timeval tv = { 0, 100000 };
 
+      if (c.d->disconnect)
+        break;
+
       FD_ZERO (&rfds);
       FD_ZERO (&wfds);
 
index 40713a9db057d1f77172e725f4005a619a03c90e..01d5995a94ddf0cab9b79cf6224e177a75dc1541 100644 (file)
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.6  2008/02/15 03:32:07  james
+ * *** empty log message ***
+ *
  * Revision 1.5  2008/02/14 10:34:47  james
  * *** empty log message ***
  *
@@ -44,6 +47,15 @@ client_msg (IPC_Msg * m, Context * c)
     case IPC_MSG_TYPE_KEY:
       vt102_send (c, m->key.key);
       break;
+    case IPC_MSG_TYPE_SETBAUD:
+      tty_set_baud (c->t, m->setbaud.baud);
+      break;
+    case IPC_MSG_TYPE_SENDBREAK:
+      tty_send_break (c->t);
+      break;
+    case IPC_MSG_TYPE_SETFLOW:
+      tty_set_flow (c->t, m->setflow.flow);
+      break;
     default:
       fprintf (stderr, "Unhandeled message type %d\n", m->hdr.type);
     }
index 81ea2f010ccc23ecc30caeee316cda7ac21f3714..bdf81323008ab1e7967169d7d91c814bcc677493 100644 (file)
@@ -11,6 +11,9 @@ static char rcsid[] =
 
 /*
  * $Log$
+ * Revision 1.12  2008/02/15 03:32:07  james
+ * *** empty log message ***
+ *
  * Revision 1.11  2008/02/14 16:21:17  james
  * *** empty log message ***
  *
@@ -81,7 +84,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.blocked=tty_status.blocked;
+  status.blocked = tty_status.blocked;
 
   cd = (tty_status.lines & TIOCM_CD) ? 1 : 0;
 
@@ -218,6 +221,8 @@ check_status (Context * c, Clients * cs)
 
   log_line_changes (c, old_status.lines, status.lines);
 
+  ptr += sprintf (ptr, "CTRL-B ");
+
   t = c->t->name;
   if (!strncmp (t, "/dev/", 5))
     t += 5;
@@ -231,13 +236,14 @@ check_status (Context * c, Clients * cs)
   ptr = do_line (ptr, status.lines, TIOCM_DTR);
   ptr = do_line (ptr, status.lines, TIOCM_DSR);
   ptr = do_line (ptr, status.lines, TIOCM_RI);
+  ptr = do_line (ptr, status.lines, TIOCM_CD);
 
   if (status.blocked)
-  {
+    {
       t = ", Locked";
       while (*t)
         *(ptr++) = *(t++);
-  }
+    }
 
   if (status.crtscts)
     {
@@ -246,6 +252,7 @@ check_status (Context * c, Clients * cs)
         *(ptr++) = *(t++);
     }
 
+#if 0
   if (status.lines & TIOCM_CD)
     {
       ptr +=
@@ -258,6 +265,7 @@ check_status (Context * c, Clients * cs)
         sprintf (ptr, ", Off %d.%d", status.cd_edge_sec / 60,
                  status.cd_edge_sec % 60);
     }
+#endif
 
   ptr +=
     sprintf (ptr, ", %d client%s", status.nclients,
@@ -277,8 +285,10 @@ main (int argc, char *argv[])
   Clients *clients;
 
 
-       construct_possible_lock_files("/dev/modem");
-       return 0;
+#if 0
+  construct_possible_lock_files ("/dev/modem");
+  return 0;
+#endif
 
   s = socket_listen ("socket");
 
@@ -286,7 +296,8 @@ main (int argc, char *argv[])
   c.v = vt102_new ();
   c.h = history_new (200);
   c.l = file_log_new ("log");
-  c.k = keydis_vt102_new (&c);
+  c.k = keydis_vt102_new ();
+  c.d = NULL;
 
 
   clients = clients_new ();
index c783d064faf33a0a1d850107feb4d7434a4b8566..2f99fe0035e2f3e070913e1e2799aec90b6a74d1 100644 (file)
@@ -8,6 +8,9 @@
 # $Id$
 #
 # $Log$
+# Revision 1.14  2008/02/15 03:32:07  james
+# *** empty log message ***
+#
 # Revision 1.13  2008/02/14 16:21:17  james
 # *** empty log message ***
 #
@@ -55,13 +58,14 @@ INCLUDES=
 
 # NB order here matters.
 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
+               log.h ipc.h symsocket.h keydis.h cmd.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 \
        keydis.c history.c ring.c ptty.c terminal.c util.c log.c ipc.c \
-       slide.c symsocket.c  serial.c
+       slide.c symsocket.c  serial.c cmd.c
 
 CPROTO=cproto
 
index 6253f953ab8c5e1ca8cefda5ea0a309928e5e3d7..3504750aa708eced4fad6862283d4dc28a845a7b 100644 (file)
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.22  2008/02/15 03:32:07  james
+ * *** empty log message ***
+ *
  * Revision 1.21  2008/02/14 02:46:44  james
  * *** empty log message ***
  *
@@ -627,7 +630,7 @@ ansi_flush_escape (ANSI * a, Context * c)
 
   for (i = 0; i < p->escape_ptr; ++i)
     {
-      c->k->key (c->k, p->escape_buf[i]);
+      keydis_key (c->k, c, p->escape_buf[i]);
     }
 
   p->escape_ptr = 0;
@@ -646,11 +649,11 @@ ansi_parse_deckey (ANSI * a, Context * c)
 
   if ((p->escape_buf[2] >= 'A') || (p->escape_buf[2] <= 'Z'))
     {
-      c->k->key (c->k, KEY_UP + (p->escape_buf[2] - 'A'));
+      keydis_key (c->k, c, KEY_UP + (p->escape_buf[2] - 'A'));
     }
   else if ((p->escape_buf[2] >= 'a') || (p->escape_buf[2] <= 'z'))
     {
-      c->k->key (c->k, KEY_154 + (p->escape_buf[2] - 'a'));
+      keydis_key (c->k, c, KEY_154 + (p->escape_buf[2] - 'a'));
     }
   else
     {
@@ -673,7 +676,7 @@ ansi_parse_ansikey (ANSI * a, Context * c)
     }
   if ((p->escape_buf[2] >= '0') || (p->escape_buf[2] <= '9'))
     {
-      c->k->key (c->k, KEY_180 + (p->escape_buf[2] - '0'));
+      keydis_key (c->k, c, KEY_180 + (p->escape_buf[2] - '0'));
     }
   else
     {
@@ -786,7 +789,7 @@ ansi_parse_char (ANSI * a, Context * c, int ch)
     }
   else
     {
-      c->k->key (c->k, ch);
+      keydis_key (c->k, c, ch);
     }
 
 }
@@ -819,7 +822,7 @@ ansi_dispatch (ANSI * a, Context * c)
     return -1;
 #endif
 
-#if 1
+#if 0
   if (*buf == 2)
     {
 #if  0
index e746ad1cea8fd63b896c651f3148b0b4397c3402..358a938cc03d2f6760cc808fde3de0c71d0cd31d 100644 (file)
@@ -12,6 +12,9 @@
 
 /*
  * $Log$
+ * Revision 1.6  2008/02/15 03:32:07  james
+ * *** empty log message ***
+ *
  * Revision 1.5  2008/02/14 02:46:44  james
  * *** empty log message ***
  *
 #ifndef __CONTEXT_H__
 #define __CONTEXT_H__
 
-typedef struct
+typedef struct Context_struct
 {
   VT102 *v;
   TTY *t;
   History *h;
   Log *l;
   KeyDis *k;
+  Cmd *d;
 } Context;
 
 #endif /* __CONTEXT_H__ */
index e42f6ff59756613e69732c2fe72fa1da07bc4d62..2a3ad7c62146ee56ea11cd7ecc92022b81696ca1 100644 (file)
--- a/src/ipc.c
+++ b/src/ipc.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.2  2008/02/15 03:32:07  james
+ * *** empty log message ***
+ *
  * Revision 1.1  2008/02/14 12:17:42  james
  * *** empty log message ***
  *
@@ -150,3 +153,38 @@ ipc_msg_send_status (Socket * s, char *buf)
 
   return ipc_msg_send (s, (IPC_Msg *) & m);
 }
+
+
+int
+ipc_msg_send_setbaud (Socket * s, int baud)
+{
+  IPC_Msg_setbaud m;
+
+  m.size = sizeof (m);
+  m.type = IPC_MSG_TYPE_SETBAUD;
+  m.baud = baud;
+  return ipc_msg_send (s, (IPC_Msg *) & m);
+}
+
+
+int
+ipc_msg_send_sendbreak (Socket * s)
+{
+  IPC_Msg_sendbreak m;
+
+  m.size = sizeof (m);
+  m.type = IPC_MSG_TYPE_SENDBREAK;
+  return ipc_msg_send (s, (IPC_Msg *) & m);
+}
+
+
+int
+ipc_msg_send_setflow (Socket * s, int flow)
+{
+  IPC_Msg_setflow m;
+
+  m.size = sizeof (m);
+  m.type = IPC_MSG_TYPE_SETFLOW;
+  m.flow = flow;
+  return ipc_msg_send (s, (IPC_Msg *) & m);
+}
index e8d224c1eb2badd0f8eb454f818b17fd2fceb4f1..b83f7369941d68bb6ea497f3e8ccc0b8e6c79e18 100644 (file)
--- a/src/ipc.h
+++ b/src/ipc.h
@@ -12,6 +12,9 @@
 
 /*
  * $Log$
+ * Revision 1.2  2008/02/15 03:32:07  james
+ * *** empty log message ***
+ *
  * Revision 1.1  2008/02/14 12:17:42  james
  * *** empty log message ***
  *
@@ -29,6 +32,9 @@
 #define IPC_MSG_TYPE_KEY 4
 #define IPC_MSG_TYPE_TERM 5
 #define IPC_MSG_TYPE_STATUS 6
+#define IPC_MSG_TYPE_SETBAUD 7
+#define IPC_MSG_TYPE_SENDBREAK 8
+#define IPC_MSG_TYPE_SETFLOW 9
 
 typedef struct
 {
@@ -91,6 +97,28 @@ typedef struct
   char  status[0];
 } IPC_Msg_status;
 
+typedef struct 
+{
+  int32_t size;
+  int32_t type;
+  int32_t baud;
+} IPC_Msg_setbaud;
+
+
+typedef struct 
+{
+  int32_t size;
+  int32_t type;
+} IPC_Msg_sendbreak;
+
+
+typedef struct 
+{
+  int32_t size;
+  int32_t type;
+  int32_t flow;
+} IPC_Msg_setflow;
+
 
 
 typedef union 
@@ -103,6 +131,9 @@ IPC_Msg_VT102 vt102;
 IPC_Msg_key key;
 IPC_Msg_term term;
 IPC_Msg_status status;
+IPC_Msg_setbaud setbaud;
+IPC_Msg_sendbreak sendbreak;
+IPC_Msg_setflow setflow;
 } IPC_Msg;
 
 
index e921f794ac163eced28d3e1ea1a1052e1395e521..33eef20c7d9278880c118242041f2df5016b1a70 100644 (file)
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.2  2008/02/15 03:32:07  james
+ * *** empty log message ***
+ *
  * Revision 1.1  2008/02/14 02:46:44  james
  * *** empty log message ***
  *
@@ -21,10 +24,11 @@ static char rcsid[] = "$Id$";
 
 #include "project.h"
 
+#define CMD_BUFLEN     128
+
 typedef struct
 {
   KEYDIS_SIGNATURE;
-  Context *c;
 } KeyDis_VT102;
 
 typedef struct
@@ -42,7 +46,7 @@ keydis_close (KeyDis * t)
 
 
 static int
-keydis_ipc_key (KeyDis * _t, int key)
+keydis_ipc_key (KeyDis * _t, Context * c, int key)
 {
   KeyDis_IPC *t = (KeyDis_IPC *) _t;
 
@@ -50,22 +54,85 @@ keydis_ipc_key (KeyDis * _t, int key)
 }
 
 static int
-keydis_vt102_key (KeyDis * _t, int key)
+keydis_ipc_set_baud (KeyDis * _t, Context * c, int baud)
+{
+  KeyDis_IPC *t = (KeyDis_IPC *) _t;
+
+  ipc_msg_send_setbaud (t->s, baud);
+
+  return 0;
+}
+
+static int
+keydis_ipc_send_break (KeyDis * _t, Context * c)
+{
+  KeyDis_IPC *t = (KeyDis_IPC *) _t;
+
+  ipc_msg_send_sendbreak (t->s);
+
+  return 0;
+}
+
+static int
+keydis_ipc_set_flow (KeyDis * _t, Context * c, int flow)
+{
+  KeyDis_IPC *t = (KeyDis_IPC *) _t;
+
+  ipc_msg_send_setflow (t->s, flow);
+
+  return 0;
+}
+
+static int
+keydis_vt102_key (KeyDis * _t, Context * c, int key)
+{
+  KeyDis_VT102 *t = (KeyDis_VT102 *) _t;
+
+  vt102_send (c, key);
+  return 0;
+}
+
+static int
+keydis_vt102_set_baud (KeyDis * _t, Context * c, int baud)
 {
   KeyDis_VT102 *t = (KeyDis_VT102 *) _t;
 
-  vt102_send (t->c, key);
+  tty_set_baud (c->t, baud);
+
   return 0;
 }
 
+static int
+keydis_vt102_send_break (KeyDis * _t, Context * c)
+{
+  KeyDis_VT102 *t = (KeyDis_VT102 *) _t;
+
+  tty_send_break (c->t);
+
+  return 0;
+}
+
+static int
+keydis_vt102_set_flow (KeyDis * _t, Context * c, int flow)
+{
+  KeyDis_VT102 *t = (KeyDis_VT102 *) _t;
+
+  tty_set_flow (c->t, flow);
+
+  return 0;
+}
+
+
 
 KeyDis *
-keydis_vt102_new (Context * c)
+keydis_vt102_new (void)
 {
   KeyDis_VT102 *t = malloc (sizeof (KeyDis_VT102));
   t->key = keydis_vt102_key;
   t->close = keydis_close;
-  t->c = c;
+  t->set_baud = keydis_vt102_set_baud;
+  t->send_break = keydis_vt102_send_break;
+  t->set_flow = keydis_vt102_set_flow;
   return (KeyDis *) t;
 }
 
@@ -76,6 +143,33 @@ keydis_ipc_new (Socket * s)
   KeyDis_IPC *t = malloc (sizeof (KeyDis_IPC));
   t->key = keydis_ipc_key;
   t->close = keydis_close;
+  t->set_baud = keydis_ipc_set_baud;
+  t->send_break = keydis_ipc_send_break;
+  t->set_flow = keydis_ipc_set_flow;
   t->s = s;
   return (KeyDis *) t;
 }
+
+
+
+
+
+
+int
+keydis_key (KeyDis * t, Context * c, int key)
+{
+
+  if (!c->d)
+    return t->key (t, c, key);
+
+  cmd_show_status (c->d, c);
+
+  if (c->d->active)
+    return cmd_key (c->d, c, key);
+
+  if (key == CMD_KEY)
+    return cmd_activate (c->d, c);
+
+
+  return t->key (t, c, key);
+}
index d0ca69a31b864aaf03494e5a152e930c5ee792bc..dafc5da7c8432d5e14e14ee72624f719d5ff34ce 100644 (file)
@@ -12,6 +12,9 @@
 
 /*
  * $Log$
+ * Revision 1.2  2008/02/15 03:32:07  james
+ * *** empty log message ***
+ *
  * Revision 1.1  2008/02/14 02:46:44  james
  * *** empty log message ***
  *
 #define __KEYDIS_H__
 
 
+struct Context_struct;
+
 #define KEYDIS_SIGNATURE \
        void (*close)(struct KeyDis_struct *); \
-       int (*key)(struct KeyDis_struct *,int key)
+       int (*key)(struct KeyDis_struct *,struct Context_struct *,int key); \
+       int (*set_baud)(struct KeyDis_struct *,struct Context_struct *,int rate); \
+       int (*send_break)(struct KeyDis_struct *,struct Context_struct *); \
+       int (*set_flow)(struct KeyDis_struct *,struct Context_struct *,int flow)
+
+       
 
 typedef struct KeyDis_struct
 {
index 3fca7af629805db34902afc60ce99dc24d6d8143..f528ef2f641a61b91732664dfe034cfaf4f0887f 100644 (file)
@@ -74,9 +74,13 @@ 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);
+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);
 /* keydis.c */
-extern KeyDis *keydis_vt102_new(Context *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);
@@ -130,3 +134,16 @@ extern void socket_consume_msg(Socket *s);
 extern void socket_pre_select(Socket *s, fd_set *rfds, fd_set *wfds);
 extern int socket_post_select(Socket *s, fd_set *rfds, fd_set *wfds);
 extern int socket_write(Socket *s, void *buf, int len);
+/* serial.c */
+extern int make_lockfile(char *name);
+extern void construct_lock_file_name_by_name(char *ptr);
+extern void construct_lock_file_name_by_device(dev_t dev);
+extern int construct_possible_lock_files(char *device);
+extern TTY *serial_open(char *path);
+/* cmd.c */
+extern void cmd_parse(Cmd *c, Context *ctx, 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);
index c8e2295190d42fa74955c9873bf50d413e298b08..c2c53b8d07eaa8b9a2e092c4ec45faf4c15a4ae7 100644 (file)
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.3  2008/02/15 03:32:07  james
+ * *** empty log message ***
+ *
  * Revision 1.2  2008/02/14 16:21:17  james
  * *** empty log message ***
  *
@@ -55,10 +58,11 @@ static char rcsid[] = "$Id$";
 
 #define NLOCKFILES     10
 
-typedef struct {
-char *lockfiles[NLOCKFILES];
-char *potential_lockfiles[NLOCKFILES];
-struct timeval last_content_check;
+typedef struct
+{
+  char *lockfiles[NLOCKFILES];
+  char *potential_lockfiles[NLOCKFILES];
+  struct timeval last_content_check;
 } Serial_lock;
 
 typedef struct
@@ -71,118 +75,136 @@ typedef struct
 
 
 static int
-chown_uucp(fd)
-int fd;
+chown_uucp (fd)
+     int fd;
 {
-    static int uuid = -1, ugid;
-    struct passwd *pw;
-
-    if (uuid <0) {
-        if (pw = getpwnam("uucp")) {
-            uuid = pw->pw_uid;
-            ugid = pw->pw_gid;
-        } else {
-               return -1;
-       }
+  static int uuid = -1, ugid;
+  struct passwd *pw;
+
+  if (uuid < 0)
+    {
+      if (pw = getpwnam ("uucp"))
+        {
+          uuid = pw->pw_uid;
+          ugid = pw->pw_gid;
+        }
+      else
+        {
+          return -1;
+        }
     }
-    return fchown(fd, uuid, ugid);
+  return fchown (fd, uuid, ugid);
 }
 
-int make_lockfile(char *name)
+int
+make_lockfile (char *name)
 {
-char buf[1024],tmpfn[1024];
-char *ptr;
-int fd;
-int i;
+  char buf[1024], tmpfn[1024];
+  char *ptr;
+  int fd;
+  int i;
 
-strcpy(tmpfn,name);
+  strcpy (tmpfn, name);
 
-ptr=rindex(tmpfn,'/');
-if (!ptr) return -1;
+  ptr = rindex (tmpfn, '/');
+  if (!ptr)
+    return -1;
 
-ptr++;
+  ptr++;
 
-ptr+=sprintf(ptr,"LTMP.%d",getpid());
-*ptr=0;
+  ptr += sprintf (ptr, "LTMP.%d", getpid ());
+  *ptr = 0;
 
-i=sprintf(buf,"%10d\n",getpid());
+  i = sprintf (buf, "%10d\n", getpid ());
 
-fd=open(tmpfn,O_WRONLY|O_CREAT|O_TRUNC,0444);
-if (fd<0) {
-       unlink(tmpfn);
-       return -1;
-}
+  fd = open (tmpfn, O_WRONLY | O_CREAT | O_TRUNC, 0444);
+  if (fd < 0)
+    {
+      unlink (tmpfn);
+      return -1;
+    }
 
-write(fd,buf,i);
-fchmod(fd,044);
-if( chown_uucp(fd)) {
-       close(fd);
-       unlink(tmpfn);
-       return -1;
-}
+  write (fd, buf, i);
+  fchmod (fd, 044);
+  if (chown_uucp (fd))
+    {
+      close (fd);
+      unlink (tmpfn);
+      return -1;
+    }
 
-close(fd);
+  close (fd);
 
-if (link(tmpfn,name)<0) {
-       unlink(tmpfn);
-       return -1;
-}
+  if (link (tmpfn, name) < 0)
+    {
+      unlink (tmpfn);
+      return -1;
+    }
 
-unlink(tmpfn);
-return 0;
+  unlink (tmpfn);
+  return 0;
 }
 
 
 
-void construct_lock_file_name_by_name(char *ptr)
+void
+construct_lock_file_name_by_name (char *ptr)
 {
 
-printf("lock by file %s\n",ptr);
+  printf ("lock by file %s\n", ptr);
 
 }
-void construct_lock_file_name_by_device(dev_t dev)
+
+void
+construct_lock_file_name_by_device (dev_t dev)
 {
 
-printf("lock by dev %x\n",dev);
+  printf ("lock by dev %x\n", dev);
 }
 
 
 #define DEV "/dev/"
-int construct_possible_lock_files(char *device)
+int
+construct_possible_lock_files (char *device)
 {
-int nl;
-struct dirent *de;
-DIR *d;
-struct stat dev_stat,ent_stat;
-char buf[1024];
+  int nl;
+  struct dirent *de;
+  DIR *d;
+  struct stat dev_stat, ent_stat;
+  char buf[1024];
 
 
-if (stat(device,&dev_stat)) return -1;
-if (!S_ISCHR(dev_stat.st_mode)) return -1;
+  if (stat (device, &dev_stat))
+    return -1;
+  if (!S_ISCHR (dev_stat.st_mode))
+    return -1;
 
-construct_lock_file_name_by_device(dev_stat.st_rdev);
+  construct_lock_file_name_by_device (dev_stat.st_rdev);
 
-construct_lock_file_name_by_name(device);
+  construct_lock_file_name_by_name (device);
 
-for (d=opendir(DEV);(de=readdir(d));)
-{
-strcpy(buf,DEV);
-strcat(buf,de->d_name);
+  for (d = opendir (DEV); (de = readdir (d));)
+    {
+      strcpy (buf, DEV);
+      strcat (buf, de->d_name);
 
-if (stat(buf,&ent_stat)) continue;
-if (!S_ISCHR(ent_stat.st_mode)) continue;
-if (ent_stat.st_rdev!=dev_stat.st_rdev) continue;
+      if (stat (buf, &ent_stat))
+        continue;
+      if (!S_ISCHR (ent_stat.st_mode))
+        continue;
+      if (ent_stat.st_rdev != dev_stat.st_rdev)
+        continue;
 
-construct_lock_file_name_by_name(buf);
+      construct_lock_file_name_by_name (buf);
 
-}
-closedir(d);
+    }
+  closedir (d);
 
 }
 
 
-static void 
-serial_check_lock(Serial *t)
+static void
+serial_check_lock (Serial * t)
 {
 }
 
@@ -207,8 +229,9 @@ serial_read (TTY * _t, void *buf, int len)
   Serial *t = (Serial *) _t;
   int red, done = 0;
 
-  serial_check_lock(t);
-  if (t->blocked) return 0;
+  serial_check_lock (t);
+  if (t->blocked)
+    return 0;
 
   do
     {
@@ -236,8 +259,9 @@ ptty_write (TTY * _t, void *buf, int len)
   int writ, done = 0;
   Serial *t = (Serial *) _t;
 
-  serial_check_lock(t);
-  if (t->blocked) return 0;
+  serial_check_lock (t);
+  if (t->blocked)
+    return 0;
 
   do
     {
@@ -271,7 +295,7 @@ serial_open (char *path)
 
   default_termios (&termios);
 
-  fd=open(path,O_RDWR);
+  fd = open (path, O_RDWR);
 
   set_nonblocking (fd);
 
index ab048fdd75d5d87f4b8936fb97375e1d6c513f6d..9a3290eeee645e81057f6e326ce84ceaa732b8a3 100644 (file)
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.9  2008/02/15 03:32:07  james
+ * *** empty log message ***
+ *
  * Revision 1.8  2008/02/14 10:39:14  james
  * *** empty log message ***
  *
@@ -251,7 +254,7 @@ terminal_open (int rfd, int wfd)
 
   t = (TERMINAL *) malloc (sizeof (TERMINAL));
 
-  strcpy(t->name,"terminal");
+  strcpy (t->name, "terminal");
   t->rfd = rfd;
   t->wfd = wfd;
 
index cd9081022fc7d405c096a9ed4756a444295fe703..82fd9edc3f5df683ce7a38f135455a085041c699 100644 (file)
--- a/src/tty.c
+++ b/src/tty.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.9  2008/02/15 03:32:07  james
+ * *** empty log message ***
+ *
  * Revision 1.8  2008/02/14 10:36:18  james
  * *** empty log message ***
  *
@@ -226,6 +229,49 @@ tty_get_status (TTY * t, TTY_Status * s)
   return 0;
 }
 
+void
+tty_set_baud (TTY * t, int rate)
+{
+  struct termios tios = { 0 };
+
+  speed_t s = baud_to_speed_t (rate);
+
+  if (s == (speed_t) - 1)
+    return;
+
+  if (tcgetattr (t->rfd, &tios))
+    return;
+
+  cfsetispeed (&tios, s);
+  cfsetospeed (&tios, s);
+
+  tcsetattr (t->rfd, TCSANOW, &tios);
+}
+
+void
+tty_send_break (TTY * t)
+{
+  tcsendbreak (t->wfd, 0);
+}
+
+void
+tty_set_flow (TTY * t, int flow)
+{
+  struct termios tios = { 0 };
+
+  if (tcgetattr (t->rfd, &tios))
+    return;
+
+  if (flow)
+    tios.c_cflag |= CRTSCTS;
+  else
+    tios.c_cflag &= ~CRTSCTS;
+
+  tcsetattr (t->rfd, TCSANOW, &tios);
+
+}
+
+
 #if 0
 int
 tty_post_select (Context * c, fd_set * rfds, fd_set * wfds)
index f481c1a7dfd3810413fc44ed7249039167079f5f..586b7d91ccbefbead876589bb4926d56226a8c8c 100644 (file)
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.29  2008/02/15 03:32:07  james
+ * *** empty log message ***
+ *
  * Revision 1.28  2008/02/14 10:34:30  james
  * *** empty log message ***
  *
@@ -1190,6 +1193,8 @@ vt102_parse_char (Context * c, int ch)
       v->current_line = v->pos;
     }
 
+  if (c->d)
+    cmd_show_status (c->d, c);
 }
 
 vt102_parse (Context * c, char *buf, int len)