annotate data-provider.c @ 168:4de7f2c9f328

Minor cleanup
author Daniele Nicolodi <daniele.nicolodi@obspm.fr>
date Fri, 14 Feb 2014 16:58:08 +0100
parents be87c8e78266
children 97112b45b838
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
144
be87c8e78266 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1 #include <ansi_c.h>
be87c8e78266 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2 #include <userint.h>
be87c8e78266 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
3
be87c8e78266 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
4 /* message buffer */
be87c8e78266 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
5 #define DATA_PROVIDER_MSGLEN 256
be87c8e78266 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
6 #define DATA_PROVIDER_MSGNUM 16
be87c8e78266 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
7 static char messages[DATA_PROVIDER_MSGLEN][DATA_PROVIDER_MSGNUM];
be87c8e78266 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
8 static unsigned int messageid = 0;
be87c8e78266 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
9
be87c8e78266 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
10 /* logging function defined in main program */
be87c8e78266 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
11 extern void logmsg(const char *frmt, ...);
be87c8e78266 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
12
be87c8e78266 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
13 /* message callback */
be87c8e78266 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
14 void CVICALLBACK MessageCB (void *msg)
be87c8e78266 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
15 {
be87c8e78266 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
16 if (msg != NULL)
be87c8e78266 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
17 logmsg(msg);
be87c8e78266 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
18 }
be87c8e78266 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
19
be87c8e78266 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
20 void SendMessage(int threadId, const char *frmt, ...)
be87c8e78266 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
21 {
be87c8e78266 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
22 /* message buffer */
be87c8e78266 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
23 char *message = messages[messageid++ % DATA_PROVIDER_MSGNUM];
be87c8e78266 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
24
be87c8e78266 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
25 /* format message */
be87c8e78266 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
26 va_list args;
be87c8e78266 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
27 va_start(args, frmt);
be87c8e78266 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
28 vsnprintf(message, DATA_PROVIDER_MSGLEN - 1, frmt, args);
be87c8e78266 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
29 va_end(args);
be87c8e78266 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
30
be87c8e78266 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
31 /* signal main thread */
be87c8e78266 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
32 PostDeferredCallToThread(MessageCB, message, threadId);
be87c8e78266 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
33 }
be87c8e78266 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
34