<feed xmlns='http://www.w3.org/2005/Atom'>
<title>notmuch/sprinter.h, branch 0.23.6</title>
<subtitle>thread-based email index, search, and tagging</subtitle>
<id>https://git.notmuchmail.org/git/notmuch/atom?h=0.23.6</id>
<link rel='self' href='https://git.notmuchmail.org/git/notmuch/atom?h=0.23.6'/>
<link rel='alternate' type='text/html' href='https://git.notmuchmail.org/git/notmuch/'/>
<updated>2012-12-18T21:03:34Z</updated>
<entry>
<title>sprinter: add text0 formatter for null character separated text</title>
<updated>2012-12-18T21:03:34Z</updated>
<author>
<name>Jani Nikula</name>
<email>jani@nikula.org</email>
</author>
<published>2012-12-16T22:05:10Z</published>
<link rel='alternate' type='text/html' href='https://git.notmuchmail.org/git/notmuch/commit/?id=64122c31fa4a4d652fa61d639d250c99f534e17f'/>
<id>urn:sha1:64122c31fa4a4d652fa61d639d250c99f534e17f</id>
<content type='text'>
Same as the text formatter, but with each field separated by a null
character rather than a newline character.
</content>
</entry>
<entry>
<title>sprinter: clarify separator documentation</title>
<updated>2012-12-18T21:03:24Z</updated>
<author>
<name>Jani Nikula</name>
<email>jani@nikula.org</email>
</author>
<published>2012-12-16T22:05:09Z</published>
<link rel='alternate' type='text/html' href='https://git.notmuchmail.org/git/notmuch/commit/?id=1358f93a9f9c827f43ad174dc7bbf27b90d2ef8a'/>
<id>urn:sha1:1358f93a9f9c827f43ad174dc7bbf27b90d2ef8a</id>
<content type='text'>
For text printers, the separator is a syntactic element.
</content>
</entry>
<entry>
<title>Adding an S-expression structured output printer.</title>
<updated>2012-12-08T13:26:29Z</updated>
<author>
<name>Peter Feigl</name>
<email>craven@gmx.net</email>
</author>
<published>2012-12-06T21:12:11Z</published>
<link rel='alternate' type='text/html' href='https://git.notmuchmail.org/git/notmuch/commit/?id=fd3ffe35a2bf15676426235b809df915cd3473e4'/>
<id>urn:sha1:fd3ffe35a2bf15676426235b809df915cd3473e4</id>
<content type='text'>
This commit adds a structured output printer for Lisp
S-Expressions. Later commits will use this printer in notmuch search,
show and reply.

The structure is the same as json, but:
- arrays are written as lists: ("foo" "bar" "baaz" 1 2 3)
- maps are written as p-lists: (:key "value" :other-key "other-value")
- true is written as t
- false is written as nil
- null is written as nil

[ whitespace changes by db ]
</content>
</entry>
<entry>
<title>sprinters: bugfix when NULL passed for a string.</title>
<updated>2012-08-12T19:25:01Z</updated>
<author>
<name>Mark Walters</name>
<email>markwalters1009@gmail.com</email>
</author>
<published>2012-08-08T21:23:33Z</published>
<link rel='alternate' type='text/html' href='https://git.notmuchmail.org/git/notmuch/commit/?id=94c3b40d41f1ad98719d411ef28b69075fda0579'/>
<id>urn:sha1:94c3b40d41f1ad98719d411ef28b69075fda0579</id>
<content type='text'>
The string function in a sprinter may be called with a NULL string
pointer (eg if a header is absent). This causes a segfault. We fix
this by checking for a null pointer in the string functions and update
the sprinter documentation.

At the moment some output when format=text is done directly rather than
via an sprinter: in that case a null pointer is passed to printf or
similar and a "(null)" appears in the output. That behaviour is not
changed in this patch.
</content>
</entry>
<entry>
<title>sprinter: Add a string_len method</title>
<updated>2012-08-03T23:21:29Z</updated>
<author>
<name>Austin Clements</name>
<email>amdragon@MIT.EDU</email>
</author>
<published>2012-08-03T01:14:49Z</published>
<link rel='alternate' type='text/html' href='https://git.notmuchmail.org/git/notmuch/commit/?id=14883b07003b9ed4223cd8f2c03b301fddae07bd'/>
<id>urn:sha1:14883b07003b9ed4223cd8f2c03b301fddae07bd</id>
<content type='text'>
This method allows callers to output strings with specific lengths.
It's useful both for strings with embedded NULs (which JSON can
represent, though parser support is apparently spotty), and
non-terminated strings.
</content>
</entry>
<entry>
<title>Add structured output formatter for JSON and plain text (but don't use them yet).</title>
<updated>2012-07-24T12:26:59Z</updated>
<author>
<name>craven@gmx.net</name>
<email>craven@gmx.net</email>
</author>
<published>2012-07-23T10:39:45Z</published>
<link rel='alternate' type='text/html' href='https://git.notmuchmail.org/git/notmuch/commit/?id=36522fca1cac6ca23c2c4c0280e3e20e96f7bfbb'/>
<id>urn:sha1:36522fca1cac6ca23c2c4c0280e3e20e96f7bfbb</id>
<content type='text'>
Using the new structured printer support in sprinter.h, implement
sprinter_json_create, which returns a new JSON structured output
formatter. The formatter prints output similar to the existing JSON, but
with differences in whitespace (mostly newlines, --output=summary prints
the entire message summary on one line, not split across multiple lines).

Also implement a "structured" formatter for plain text that prints
prefixed strings, to be used with notmuch-search.c plain text output.
</content>
</entry>
<entry>
<title>Add support for structured output formatters.</title>
<updated>2012-07-24T12:26:49Z</updated>
<author>
<name>craven@gmx.net</name>
<email>craven@gmx.net</email>
</author>
<published>2012-07-23T10:39:44Z</published>
<link rel='alternate' type='text/html' href='https://git.notmuchmail.org/git/notmuch/commit/?id=41becc0c9dfabbd59a1c96bdedc99a785539a93b'/>
<id>urn:sha1:41becc0c9dfabbd59a1c96bdedc99a785539a93b</id>
<content type='text'>
This patch adds a new struct type sprinter_t, which is used for
structured formatting, e.g. JSON or S-Expressions. The structure printer
is heavily based on code from Austin Clements
(id:87d34hsdx8.fsf@awakening.csail.mit.edu).

It includes the following functions:

    /* Start a new map/dictionary structure. This should be followed by
     * a sequence of alternating calls to map_key and one of the
     * value-printing functions until the map is ended by end.
     */
    void (*begin_map) (struct sprinter *);

    /* Start a new list/array structure.
     */
    void (*begin_list) (struct sprinter *);

    /* End the last opened list or map structure.
     */
    void (*end) (struct sprinter *);

    /* Print one string/integer/boolean/null element (possibly inside a
     * list or map, followed or preceded by separators).
     * For string, the char * must be UTF-8 encoded.
     */
    void (*string) (struct sprinter *, const char *);
    void (*integer) (struct sprinter *, int);
    void (*boolean) (struct sprinter *, notmuch_bool_t);
    void (*null) (struct sprinter *);

    /* Print the key of a map's key/value pair. The char * must be UTF-8
     * encoded.
     */
    void (*map_key) (struct sprinter *, const char *);

    /* Insert a separator (usually extra whitespace) for improved
     * readability without affecting the abstract syntax of the
     * structure being printed.
     * For JSON, this could simply be a line break.
     */
    void (*separator) (struct sprinter *);

    /* Set the current string prefix. This only affects the text
     * printer, which will print this string, followed by a colon,
     * before any string. For other printers, this does nothing.
     */
    void (*set_prefix) (struct sprinter *, const char *);

To support the plain text format properly, the following additional
function must also be implemented:

    /* Set the current string prefix. This only affects the text
     * printer, which will print this string, followed by a colon,
     * before any string. For other printers, this does nothing.
     */
    void (*set_prefix) (struct sprinter *, const char *);

The structure also contains a flag that should be set to FALSE in all
custom printers and to TRUE in the plain text formatter.

    /* True if this is the special-cased plain text printer.
     */
    notmuch_bool_t is_text_printer;

The printer can (and should) use internal state to insert delimiters
and syntax at the correct places.

Example:

format-&gt;begin_map(format);
format-&gt;map_key(format, "foo");
format-&gt;begin_list(format);
format-&gt;integer(format, 1);
format-&gt;integer(format, 2);
format-&gt;integer(format, 3);
format-&gt;end(format);
format-&gt;map_key(format, "bar");
format-&gt;begin_map(format);
format-&gt;map_key(format, "baaz");
format-&gt;string(format, "hello world");
format-&gt;end(format);
format-&gt;end(format);

would output JSON as follows:

{"foo": [1, 2, 3], "bar": { "baaz": "hello world"}}
</content>
</entry>
</feed>
