+static void
+client_msg (IPC_Msg * m, Context * c)
+{
+ switch (m->hdr.type)
+ {
+
+ case IPC_MSG_TYPE_NOOP:
+ break;
+ case IPC_MSG_TYPE_DEBUG:
+ fprintf (stderr, "%p [%d] %s\n", m, m->hdr.size, m->debug.msg);
+ break;
+ case IPC_MSG_TYPE_KEY:
+ vt102_send (c, m->key.key);
+ break;
+ default:
+ fprintf (stderr, "Unhandeled message type %d\n", m->hdr.type);
+ }
+}
+
+void
+client_free (Client * c)
+{
+ if (c->s)
+ socket_free (c->s);
+
+ free (c);
+ fprintf (stderr, "Client at %p freed\n", c);
+}
+
+Client *
+clients_new_client (Clients * cs, Socket * s, Context * ctx)
+{
+ Client *c;
+
+ c = (Client *) malloc (sizeof (Client));
+
+ c->dead = 0;
+ c->s = s;
+ c->next = cs->head;
+
+ cs->head = c;
+ cs->n++;
+
+ fprintf (stderr, "Client at %p created\n", c);
+
+
+ if (ipc_msg_send_debug (s, "new_client"))
+ c->dead++;
+
+ return c;
+}
+
+void
+clients_reap (Clients * cs)
+{
+ Client **p, *c;
+
+
+ for (p = &cs->head; *p;)
+ {
+ Client *c = *p;