GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> MDB / dev > mdb / sun-gcc
#include <stdio.h>
#include <stdarg.h>
#include <MDB/MDB_pubdefs.h>
#include <PBS/WCT.h>
Functions | |
unsigned int | MSG_find (unsigned int code, const MSG_FacList **fdb, const MSG_MsgList **mdb) |
Return facility and message database entries corresponding to code. | |
void | MSG_insertFacility (const MSG_FacList *fac) |
Insert a new facility into the store. | |
void | MSG_removeFacility (const MSG_FacList *fac) |
Remove an existing facility from the store. | |
unsigned int | MSG_report (unsigned int code, WCT_time hack, const char *rtn, unsigned int nprm,...) |
Process a message reporting request. | |
void | MSG_setReportRtn (MSG_cb_ReportRtn *rtn) |
Set a new MSG_report() callback routine. | |
Variables | |
static MSG_cb_ReportRtn * | reportRtn |
Real routine used to report messages. | |
static struct _MSG_FacList * | facTable [1<< MSG_K_FACILITY] |
Table of pointers to facilities. |
CVS $Id: MDB_database.c,v 1.5 2011/04/06 01:23:51 apw Exp $
MDB_database.c also provides the dummy entry point MSG_report(). The name is to maintain backward compatibility with the previous implementation of this routine which used to appear in the MSG package proper. This version simply branches to a callback routine. When first initialized, it branches to a default, no-op routine (which simply returns the message code as is). When the MSG system is initialized, it overwrites the callback routine address so that the MSG_report() here branches to the proper message handling routine provided by MSG.
unsigned int MSG_find | ( | unsigned int | code, | |
const MSG_FacList ** | fdb, | |||
const MSG_MsgList ** | mdb | |||
) |
Return facility and message database entries corresponding to code.
code | (in ) Message code | |
fdb | (out) Facility descriptor | |
mdb | (out) Message descriptor |
0 | Database entry found | |
1 | Database entry not found |
References _MSG_FacList::frst, and _MSG_FacList::nmsg.
void MSG_insertFacility | ( | const MSG_FacList * | fac | ) |
Insert a new facility into the store.
fac | (in) Pointer to the facility. |
__attribute__((constructor))
which results in it being run either before the main routine starts up (typical for single-threaded host applications) or immediately after a module is loaded (typical for the multi-threaded VxWorks environment). This technique is really provided for C++ static constructors, but there's no reason not to take advantage of it.
Thus every message facility source file contains a little stub routine declared constructor
whose sole function is to call this routine with the address of the facility block.
References _MSG_FacList::ID.
void MSG_removeFacility | ( | const MSG_FacList * | fac | ) |
Remove an existing facility from the store.
fac | (in) Pointer to the facility. |
__attribute__((destructor))
which results in it being run either after the main routine completes (typical for single-threaded host applications) or a immediately before a module is unloaded (typical for the multi-threaded VxWorks environment). This technique is really provided for C++ static destructors, but there's no reason not to take advantage of it.
Thus every message facility source file contains a little stub routine declared destructor
whose sole function is to call this routine with the address of the facility block.
References _MSG_FacList::ID.
unsigned int MSG_report | ( | unsigned int | code, | |
WCT_time | hack, | |||
const char * | rtn, | |||
unsigned int | nprm, | |||
... | ||||
) |
Process a message reporting request.
code | (in) Message code to be reported | |
hack | (in) Wall clock time to be recorded with the meessage (note 1) | |
rtn | (in) Name of calling routine (note 2) | |
nprm | (in) Number of parameters that follow |
__func__
macro to fill in the routine name.code | Reflection of the first input argument, probably with "reported" bit set |
The packet is sent to an message task (in the multi-threaded case) where the message is formatted using the formatting string associated with the message code. The message task then calls all output processors in turn to do whatever it is they want to do with the information.
In the single-threaded case, the message processing occurs inline with the MSG_report() call.
void MSG_setReportRtn | ( | MSG_cb_ReportRtn * | rtn | ) |
Set a new MSG_report() callback routine.
rtn | (in) Pointer to the message reporting routine |
static struct _MSG_FacList * facTable[1<< MSG_K_FACILITY] [static] |
Table of pointers to facilities.
Used in the first stage (facility) lookup of an error code. The facility number is used as an index into this table to find the facility description (a MSG_FacList structure), and the associated messages description (MSG_MsgList structures accessed from a root pointer in MSG_FacList).
static MSG_cb_ReportRtn * reportRtn [static] |
Real routine used to report messages.
Pointer to a message reporting routine. When MDB is loaded, this is NULL, but MSG_report() can still be called "naturally" (the message code is simply returned). Once MSG is initialized, this static points to the real message reporting routine.