|
NAMEmsgno - manage error codes and associated messages across separate libraries SYNOPSIS#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 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[] = {
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
|