Addition of a version of printf that can print to a DCB
This commit is contained in:
parent
fad37adfbf
commit
939d2bf46c
24
core/dcb.c
24
core/dcb.c
@ -26,6 +26,7 @@
|
||||
*
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <dcb.h>
|
||||
@ -216,3 +217,26 @@ gw_dcb_state2string (int state) {
|
||||
return "DCB (unknown)";
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* A DCB based wrapper for printf. Allows formattign printing to
|
||||
* a descritor control block.
|
||||
*
|
||||
* @param dcb Descriptor to write to
|
||||
* @param fmt A printf format string
|
||||
* @param ... Variable arguments for the print format
|
||||
*/
|
||||
void
|
||||
dcb_printf(DCB *dcb, const char *fmt, ...)
|
||||
{
|
||||
GWBUF *buf;
|
||||
va_list args;
|
||||
|
||||
if ((buf = gwbuf_alloc(10240)) == NULL)
|
||||
return;
|
||||
va_start(args, fmt);
|
||||
vsnprintf(GWBUF_DATA(buf), 10240, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
dcb->func.write(dcb, buf);
|
||||
}
|
||||
|
@ -106,5 +106,6 @@ extern DCB *connect_dcb(struct server *, struct session *, const char *);
|
||||
extern void printAllDCBs(); /* Debug to print all DCB in the system */
|
||||
extern void printDCB(DCB *); /* Debug print routine */
|
||||
extern const char *gw_dcb_state2string(int); /* DCB state to string */
|
||||
extern void dcb_printf(DCB *, const char *, ...); /* DCB version of printf */
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user