Mercurial > hg > fxanalyse
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data-provider.c Wed Jan 22 14:45:24 2014 +0100 @@ -0,0 +1,34 @@ +#include <ansi_c.h> +#include <userint.h> + +/* message buffer */ +#define DATA_PROVIDER_MSGLEN 256 +#define DATA_PROVIDER_MSGNUM 16 +static char messages[DATA_PROVIDER_MSGLEN][DATA_PROVIDER_MSGNUM]; +static unsigned int messageid = 0; + +/* logging function defined in main program */ +extern void logmsg(const char *frmt, ...); + +/* message callback */ +void CVICALLBACK MessageCB (void *msg) +{ + if (msg != NULL) + logmsg(msg); +} + +void SendMessage(int threadId, const char *frmt, ...) +{ + /* message buffer */ + char *message = messages[messageid++ % DATA_PROVIDER_MSGNUM]; + + /* format message */ + va_list args; + va_start(args, frmt); + vsnprintf(message, DATA_PROVIDER_MSGLEN - 1, frmt, args); + va_end(args); + + /* signal main thread */ + PostDeferredCallToThread(MessageCB, message, threadId); +} +