X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=sympathy.git;a=blobdiff_plain;f=apps%2Fclients.c;h=d5bd256cb7b4846bf9d31d7bee348aad1072bbec;hp=b5bafcdabd42e146565beb74f61074b2245edc73;hb=3e72a1f6fc28777c26e4fb109867bd2a3c7b89b0;hpb=d20265fbf33e22b30b5c2879cff7ae5c22d3fc29 diff --git a/apps/clients.c b/apps/clients.c index b5bafcd..d5bd256 100644 --- a/apps/clients.c +++ b/apps/clients.c @@ -10,6 +10,39 @@ static char rcsid[] = "$Id$"; /* * $Log$ + * Revision 1.14 2008/02/28 16:57:51 james + * *** empty log message *** + * + * Revision 1.13 2008/02/28 16:37:16 james + * *** empty log message *** + * + * Revision 1.12 2008/02/28 12:12:24 james + * *** empty log message *** + * + * Revision 1.11 2008/02/23 11:48:51 james + * *** empty log message *** + * + * Revision 1.10 2008/02/22 17:06:59 james + * *** empty log message *** + * + * Revision 1.9 2008/02/20 18:49:11 staffcvs + * *** empty log message *** + * + * Revision 1.8 2008/02/20 18:31:44 james + * *** empty log message *** + * + * Revision 1.7 2008/02/15 23:52:12 james + * *** empty log message *** + * + * 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 *** * @@ -22,9 +55,14 @@ static char rcsid[] = "$Id$"; */ #include +#include +#include +#include +#include +#include #include "clients.h" -static void +void client_msg (IPC_Msg * m, Context * c) { switch (m->hdr.type) @@ -38,6 +76,30 @@ 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); + tty_parse_reset (c); + + log_f (c->l, "", 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; + case IPC_MSG_TYPE_SETANSI: + vt102_set_ansi (c->v, m->setansi.ansi); + break; + case IPC_MSG_TYPE_HANGUP: + tty_hangup (c->t); + break; + case IPC_MSG_TYPE_SETSIZE: + vt102_resize (c, m->setsize.winsize); + break; + case IPC_MSG_TYPE_RESET: + vt102_reset (c); + break; default: fprintf (stderr, "Unhandeled message type %d\n", m->hdr.type); } @@ -50,7 +112,9 @@ client_free (Client * c) socket_free (c->s); free (c); +#if 0 fprintf (stderr, "Client at %p freed\n", c); +#endif } Client * @@ -67,7 +131,9 @@ clients_new_client (Clients * cs, Socket * s, Context * ctx) cs->head = c; cs->n++; +#if 0 fprintf (stderr, "Client at %p created\n", c); +#endif if (ipc_msg_send_debug (s, "new_client")) @@ -148,8 +214,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 +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 -clients_output (Clients * cs, void *buf, int len) +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 +298,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); }