|
NAMEmsgno - manage error codes and associated messages across separate librariesSYNOPSIS#include <mba/msgno.h> MMSG(fmt, ...) MMNO(msgno) MMNF(msgno, fmt, ...) /* Primary */ PMSG(fmt, ...) PMNO(msgno) PMNF(msgno, fmt, ...) /* Additional */ AMSG(fmt, ...) AMNO(msgno) AMNF(msgno, fmt, ...) extern int (*msgno_hdlr)(const char *fmt, ...); struct msgno_entry { unsigned int msgno; const char *msg; }; int msgno_add_codes(struct msgno_entry *list); DESCRIPTIONThe msgno(3m) module provides a set of macros that when used consistently will generate stacktrace-like output like the following example:src/expatls.c:97:utf8tods: Character encoding error src/expatls.c:449:start_fn: src/dom.c:405:DOM_Element_normalize: dump.c:30:main: Failed to process sample.xml Note: As of version 0.9, this implementation no longer uses variadic macros -- it is strict standard C. Additionally this module provides functions for managing error codes (or more generically message numbers) and associated messages across separate C libraries. This functionality is very similar to the com_err library but with runtime message registration. Each participating library registers a table of messages at runtime with the msgno_add_codes function. The msgno(3m) macros are provided to dispatch messages (e.g. print to stderr). Note: The msgno(3m) macros operate on a shared buffer and therefore they are not reentrant. Meaning they cannot not be used concurrently by multiple threads.
#define DOM_INDEX_SIZE_ERR dom_codes[0].msgno #define DOM_DOMSTRING_SIZE_ERR dom_codes[1].msgno struct msgno_entry dom_codes[] = { { 1, "The index specified was out of range" }, { 0, "The text size is out of range" }, ... { 0, NULL } };
static int MessageBoxHdlr(const char *fmt, ...) { char mbs[4096]; wchar_t wcs[4096]; va_list ap; va_start(ap, fmt); _vsnprintf(mbs, 4096, fmt, ap); if (mbstowcs(wcs, mbs, 4096) != (size_t)-1) { AfxMessageBox(wcs); } va_end(ap); return 0; } BOOL CWutApp::InitInstance() { ... msgno_hdlr = MessageBoxHdlr; RETURNS
Visit the GSP FreeBSD Man Page Interface. |