chiark / gitweb /
Merge and end branch-hostside-wip-2008-01-25 PROPERLY; cvs up -j branch-hostside...
[trains.git] / hostside / selectout.c
1 /*
2  * mulitplexer daemon
3  * transmissions to clients of their selected messages
4  */
5
6 #include <string.h>
7 #include <stdarg.h>
8
9 #include "multiplex.h"
10 #include "auproto-pic.h"
11
12 #define FOR_CLS(s) do{                          \
13     Client *cl, *next_cl;                       \
14     for (cl= clients.head;                      \
15          cl;                                    \
16          cl= next_cl) {                         \
17       OutBufferChain *ch= &cl->ch;              \
18       next_cl= cl->next;                        \
19       if (!(sel & cl->sel)) continue;           \
20       s;                                        \
21     }                                           \
22   }while(0)
23
24 void sovprintf(Selector sel, const char *fmt, va_list al) {
25   FOR_CLS( ovprintf(ch, fmt, al) );
26 }
27
28 void soprintf(Selector sel, const char *fmt, ...)
29   { va_list al; va_start(al,fmt); sovprintf(sel,fmt,al); va_end(al); }
30
31 void sowrite(Selector sel, const char *data, int l) {
32   FOR_CLS( owrite(ch, data, l) );
33 }