aboutsummaryrefslogtreecommitdiffhomepage
path: root/sprinter-text.c
diff options
context:
space:
mode:
authorGravatar Jani Nikula <jani@nikula.org>2012-12-17 00:05:10 +0200
committerGravatar David Bremner <bremner@debian.org>2012-12-18 17:03:34 -0400
commit64122c31fa4a4d652fa61d639d250c99f534e17f (patch)
tree979eb32254639b47cad21daee5e89822d0cb766f /sprinter-text.c
parent1358f93a9f9c827f43ad174dc7bbf27b90d2ef8a (diff)
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.
Diffstat (limited to 'sprinter-text.c')
-rw-r--r--sprinter-text.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/sprinter-text.c b/sprinter-text.c
index 10343be4..7779488f 100644
--- a/sprinter-text.c
+++ b/sprinter-text.c
@@ -68,6 +68,14 @@ text_separator (struct sprinter *sp)
}
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)
{
struct sprinter_text *sptxt = (struct sprinter_text *) sp;
@@ -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;
+}