Mercurial > hg > fxanalyse
comparison data-provider.c @ 144:be87c8e78266
Code cleanup
author | Daniele Nicolodi <daniele.nicolodi@obspm.fr> |
---|---|
date | Wed, 22 Jan 2014 14:45:24 +0100 |
parents | |
children | 97112b45b838 |
comparison
equal
deleted
inserted
replaced
143:09a4548e1436 | 144:be87c8e78266 |
---|---|
1 #include <ansi_c.h> | |
2 #include <userint.h> | |
3 | |
4 /* message buffer */ | |
5 #define DATA_PROVIDER_MSGLEN 256 | |
6 #define DATA_PROVIDER_MSGNUM 16 | |
7 static char messages[DATA_PROVIDER_MSGLEN][DATA_PROVIDER_MSGNUM]; | |
8 static unsigned int messageid = 0; | |
9 | |
10 /* logging function defined in main program */ | |
11 extern void logmsg(const char *frmt, ...); | |
12 | |
13 /* message callback */ | |
14 void CVICALLBACK MessageCB (void *msg) | |
15 { | |
16 if (msg != NULL) | |
17 logmsg(msg); | |
18 } | |
19 | |
20 void SendMessage(int threadId, const char *frmt, ...) | |
21 { | |
22 /* message buffer */ | |
23 char *message = messages[messageid++ % DATA_PROVIDER_MSGNUM]; | |
24 | |
25 /* format message */ | |
26 va_list args; | |
27 va_start(args, frmt); | |
28 vsnprintf(message, DATA_PROVIDER_MSGLEN - 1, frmt, args); | |
29 va_end(args); | |
30 | |
31 /* signal main thread */ | |
32 PostDeferredCallToThread(MessageCB, message, threadId); | |
33 } | |
34 |