aboutsummaryrefslogtreecommitdiffstats
path: root/apps/clients.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/clients.c')
-rw-r--r--apps/clients.c177
1 files changed, 83 insertions, 94 deletions
diff --git a/apps/clients.c b/apps/clients.c
index d5bd256..4c4ea21 100644
--- a/apps/clients.c
+++ b/apps/clients.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.15 2008/03/02 10:27:24 james
+ * *** empty log message ***
+ *
* Revision 1.14 2008/02/28 16:57:51 james
* *** empty log message ***
*
@@ -65,44 +68,43 @@ static char rcsid[] = "$Id$";
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;
- case IPC_MSG_TYPE_SETBAUD:
- tty_set_baud (c->t, m->setbaud.baud);
- tty_parse_reset (c);
-
- log_f (c->l, "<baud changed to %d>", 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);
- }
+ 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;
+ case IPC_MSG_TYPE_SETBAUD:
+ tty_set_baud (c->t, m->setbaud.baud);
+ tty_parse_reset (c);
+
+ log_f (c->l, "<baud changed to %d>", 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);
+ }
}
void
@@ -148,21 +150,17 @@ clients_reap (Clients * cs)
Client **p, *c;
- for (p = &cs->head; *p;)
- {
- Client *c = *p;
-
- if (c->dead)
- {
- *p = c->next;
- client_free (c);
- cs->n--;
- }
- else
- {
- p = &(c->next);
- }
+ for (p = &cs->head; *p;) {
+ Client *c = *p;
+
+ if (c->dead) {
+ *p = c->next;
+ client_free (c);
+ cs->n--;
+ } else {
+ p = &(c->next);
}
+ }
}
Clients *
@@ -181,10 +179,9 @@ clients_pre_select (Clients * cs, fd_set * rfds, fd_set * wfds)
{
Client *c;
- for (c = cs->head; c; c = c->next)
- {
- socket_pre_select (c->s, rfds, wfds);
- }
+ for (c = cs->head; c; c = c->next) {
+ socket_pre_select (c->s, rfds, wfds);
+ }
}
void
@@ -194,22 +191,19 @@ clients_post_select (Clients * cs, Context * ctx, fd_set * rfds,
Client *c;
int deaded = 0;
- for (c = cs->head; c; c = c->next)
- {
- if (socket_post_select (c->s, rfds, wfds))
- {
- c->dead++;
- deaded++;
- }
-
- if (c->s->msg)
- {
- client_msg (c->s->msg, ctx);
- socket_consume_msg (c->s);
- }
+ for (c = cs->head; c; c = c->next) {
+ if (socket_post_select (c->s, rfds, wfds)) {
+ c->dead++;
+ deaded++;
+ }
+ if (c->s->msg) {
+ client_msg (c->s->msg, ctx);
+ socket_consume_msg (c->s);
}
+ }
+
if (deaded)
clients_reap (cs);
}
@@ -220,10 +214,9 @@ clients_shutdown (Clients * cs)
{
Client *c;
- for (c = cs->head; c; c = c->next)
- {
- c->dead++;
- }
+ for (c = cs->head; c; c = c->next) {
+ c->dead++;
+ }
clients_reap (cs);
@@ -257,12 +250,11 @@ send_status (Clients * cs, char *msg)
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++;
- }
+ for (c = cs->head; c; c = c->next) {
+ if (!c->dead)
+ if (ipc_msg_send (c->s, (IPC_Msg *) m))
+ c->dead++;
+ }
return len;
}
@@ -286,12 +278,11 @@ send_output (Clients * cs, void *buf, int len)
m->len = len;
memcpy (m->term, buf, len);
- for (c = cs->head; c; c = c->next)
- {
- if (!c->dead)
- if (ipc_msg_send (c->s, (IPC_Msg *) m))
- c->dead++;
- }
+ for (c = cs->head; c; c = c->next) {
+ if (!c->dead)
+ if (ipc_msg_send (c->s, (IPC_Msg *) m))
+ c->dead++;
+ }
return len;
@@ -305,18 +296,16 @@ send_history (History * h, Client * c)
HISTORY_INC (h, rptr);
HISTORY_INC (h, rptr);
- while (rptr != h->wptr)
- {
- History_ent *l = &h->lines[rptr];
- if (l->valid)
- {
+ while (rptr != h->wptr) {
+ History_ent *l = &h->lines[rptr];
+ if (l->valid) {
- if (ipc_msg_send_history (c->s, l))
- c->dead++;
+ if (ipc_msg_send_history (c->s, l))
+ c->dead++;
- }
- HISTORY_INC (h, rptr);
}
+ HISTORY_INC (h, rptr);
+ }
}
void