mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-19 21:27:57 +00:00
Add XPRINT strbuf adapter
This commit is contained in:
parent
74adb2038a
commit
28a77abc18
@ -19,6 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "strbuf.h"
|
||||
#include "xprintf.h"
|
||||
|
||||
void xprintf(XPRINTF xfp, const char *fmt, ...)
|
||||
@ -89,3 +90,8 @@ void _cx_vprintf_mallocbuf(void *context, const char *fmt, va_list ap)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _cx_vprintf_strbuf(void *context, const char *fmt, va_list ap)
|
||||
{
|
||||
strbuf_vsprintf((strbuf)context, fmt, ap);
|
||||
}
|
||||
|
@ -99,4 +99,10 @@ struct mallocbuf {
|
||||
#define XPRINTF_MALLOCBUF(MB) _XPRINTF(_cx_vprintf_mallocbuf, (MB))
|
||||
CONTEXT_VPRINTF _cx_vprintf_mallocbuf;
|
||||
|
||||
/* Strbuf adapter. An XPRINTF constructed with XPRINTF_STRBUF(sb) will write
|
||||
* all its output to the give strbuf using strbuf_sprintf(sb,...).
|
||||
*/
|
||||
#define XPRINTF_STRBUF(SB) _XPRINTF(_cx_vprintf_strbuf,(SB))
|
||||
CONTEXT_VPRINTF _cx_vprintf_strbuf;
|
||||
|
||||
#endif // __SERVALD_XPRINTF_H
|
||||
|
Loading…
Reference in New Issue
Block a user