28
28
/* todo, make this dynamic as needed */
29
29
#define MAX_MSG_LEN 8192
31
bool errmsg_stderr_func (Session *,
33
const char *format, va_list ap)
31
class Error_message_stderr : public Error_message_handler
35
char msgbuf[MAX_MSG_LEN];
38
prv= vsnprintf(msgbuf, MAX_MSG_LEN, format, ap);
39
if (prv < 0) return true;
41
/* a single write has a OS level thread lock
42
so there is no need to have mutexes guarding this write,
44
wrv= write(2, msgbuf, prv);
45
if ((wrv < 0) || (wrv != prv)) return true;
34
virtual bool errmsg(Session *, int , const char *format, va_list ap)
36
char msgbuf[MAX_MSG_LEN];
39
prv= vsnprintf(msgbuf, MAX_MSG_LEN, format, ap);
40
if (prv < 0) return true;
42
/* a single write has a OS level thread lock
43
so there is no need to have mutexes guarding this write,
45
wrv= write(2, msgbuf, prv);
46
if ((wrv < 0) || (wrv != prv)) return true;
50
52
static int errmsg_stderr_plugin_init(void *p)
52
errmsg_t *l= (errmsg_t *) p;
54
Error_message_handler **handler= static_cast<Error_message_handler **>(p);
54
l->errmsg_func= errmsg_stderr_func;
56
*handler= new Error_message_stderr();
59
61
static int errmsg_stderr_plugin_deinit(void *p)
61
errmsg_t *l= (errmsg_t *) p;
63
Error_message_stderr **handler= static_cast<Error_message_stderr **>(p);