From 64122c31fa4a4d652fa61d639d250c99f534e17f Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Mon, 17 Dec 2012 00:05:10 +0200 Subject: sprinter: add text0 formatter for null character separated text Same as the text formatter, but with each field separated by a null character rather than a newline character. --- sprinter-text.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'sprinter-text.c') diff --git a/sprinter-text.c b/sprinter-text.c index 10343be4..7779488f 100644 --- a/sprinter-text.c +++ b/sprinter-text.c @@ -67,6 +67,14 @@ text_separator (struct sprinter *sp) fputc ('\n', sptxt->stream); } +static void +text0_separator (struct sprinter *sp) +{ + struct sprinter_text *sptxt = (struct sprinter_text *) sp; + + fputc ('\0', sptxt->stream); +} + static void text_set_prefix (struct sprinter *sp, const char *prefix) { @@ -133,3 +141,17 @@ sprinter_text_create (const void *ctx, FILE *stream) res->stream = stream; return &res->vtable; } + +struct sprinter * +sprinter_text0_create (const void *ctx, FILE *stream) +{ + struct sprinter *sp; + + sp = sprinter_text_create (ctx, stream); + if (! sp) + return NULL; + + sp->separator = text0_separator; + + return sp; +} -- cgit v1.2.3