mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-28 13:44:12 +01:00
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.
This commit is contained in:
parent
1358f93a9f
commit
64122c31fa
2 changed files with 28 additions and 0 deletions
|
@ -67,6 +67,14 @@ text_separator (struct sprinter *sp)
|
||||||
fputc ('\n', sptxt->stream);
|
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
|
static void
|
||||||
text_set_prefix (struct sprinter *sp, const char *prefix)
|
text_set_prefix (struct sprinter *sp, const char *prefix)
|
||||||
{
|
{
|
||||||
|
@ -133,3 +141,17 @@ sprinter_text_create (const void *ctx, FILE *stream)
|
||||||
res->stream = stream;
|
res->stream = stream;
|
||||||
return &res->vtable;
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -67,6 +67,12 @@ typedef struct sprinter {
|
||||||
struct sprinter *
|
struct sprinter *
|
||||||
sprinter_text_create (const void *ctx, FILE *stream);
|
sprinter_text_create (const void *ctx, FILE *stream);
|
||||||
|
|
||||||
|
/* Create a new unstructured printer that emits the text format for
|
||||||
|
* "notmuch search", with each field separated by a null character
|
||||||
|
* instead of the newline character. */
|
||||||
|
struct sprinter *
|
||||||
|
sprinter_text0_create (const void *ctx, FILE *stream);
|
||||||
|
|
||||||
/* Create a new structure printer that emits JSON. */
|
/* Create a new structure printer that emits JSON. */
|
||||||
struct sprinter *
|
struct sprinter *
|
||||||
sprinter_json_create (const void *ctx, FILE *stream);
|
sprinter_json_create (const void *ctx, FILE *stream);
|
||||||
|
|
Loading…
Reference in a new issue