chiark / gitweb /
*** empty log message ***
[sympathy.git] / apps / clients.c
index b5bafcdabd42e146565beb74f61074b2245edc73..01d5995a94ddf0cab9b79cf6224e177a75dc1541 100644 (file)
@@ -10,6 +10,15 @@ 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 ***
+ *
+ * Revision 1.4  2008/02/14 10:34:30  james
+ * *** empty log message ***
+ *
  * Revision 1.3  2008/02/14 02:46:44  james
  * *** empty log message ***
  *
@@ -38,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);
     }
@@ -148,8 +166,62 @@ clients_post_select (Clients * cs, Context * ctx, fd_set * rfds,
     clients_reap (cs);
 }
 
+
+void
+clients_shutdown (Clients * cs)
+{
+  Client *c;
+
+  for (c = cs->head; c; c = c->next)
+    {
+      c->dead++;
+    }
+
+
+  clients_reap (cs);
+}
+
+
+
+
+
+
 int
-clients_output (Clients * cs, void *buf, int len)
+send_status (Clients * cs, char *msg)
+{
+  char mbuf[IPC_MAX_BUF + sizeof (IPC_Msg_status)];
+  IPC_Msg_status *m = (IPC_Msg_status *) mbuf;
+  int len;
+
+  Client *c;
+
+  if (!msg)
+    return;
+  len = strlen (msg) + 1;
+
+  if (!len)
+    return;
+  if (len > IPC_MAX_BUF)
+    len = IPC_MAX_BUF;
+
+  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;
+
+  for (c = cs->head; c; c = c->next)
+    {
+      if (!c->dead)
+        if (ipc_msg_send (c->s, (IPC_Msg *) m))
+          c->dead++;
+    }
+
+  return len;
+}
+
+
+int
+send_output (Clients * cs, void *buf, int len)
 {
   char mbuf[IPC_MAX_BUF + sizeof (IPC_Msg_term)];
   IPC_Msg_term *m = (IPC_Msg_term *) mbuf;
@@ -178,15 +250,31 @@ clients_output (Clients * cs, void *buf, int len)
 }
 
 void
-clients_shutdown (Clients * cs)
+send_history (History * h, Client * c)
 {
-  Client *c;
+  int rptr = h->wptr;
 
-  for (c = cs->head; c; c = c->next)
+  HISTORY_INC (h, rptr);
+
+  HISTORY_INC (h, rptr);
+  while (rptr != h->wptr)
     {
-      c->dead++;
+      History_ent *l = &h->lines[rptr];
+      if (l->valid)
+        {
+
+          if (ipc_msg_send_history (c->s, l))
+            c->dead++;
+
+        }
+      HISTORY_INC (h, rptr);
     }
+}
 
+void
+send_vt102 (VT102 * v, Client * c)
+{
+  if (ipc_msg_send_vt102 (c->s, v))
+    c->dead++;
 
-  clients_reap (cs);
 }