From 49ac066464e0127e4b9924b150bf47473ab733ae Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 7 Dec 2012 16:26:37 +1030 Subject: [PATCH] rfc822: beef up _info example. Now it's a useful little command line utility, with tests. Signed-off-by: Rusty Russell --- ccan/rfc822/_info | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/ccan/rfc822/_info b/ccan/rfc822/_info index 17ad934f..7b8eda62 100644 --- a/ccan/rfc822/_info +++ b/ccan/rfc822/_info @@ -21,15 +21,27 @@ * data as possible. * * Example: + * // Given '' outputs 'body' + * // Given 'From' outputs ' ' + * // Given 'To' outputs ' ' * char buf[] = "From: \n" * "To: \n\n" * "body\n"; * struct rfc822_msg *msg; - * struct bytestring body; + * struct bytestring out; * * msg = rfc822_start(NULL, buf, sizeof(buf)); - * body = rfc822_body(msg); - * fwrite(body.ptr, 1, body.len, stdout); + * if (!argv[1] || !argv[1][0]) + * out = rfc822_body(msg); + * else { + * struct rfc822_header *hdr; + * hdr = rfc822_first_header_of_name(msg, argv[1]); + * if (!hdr) + * exit(1); + * out = rfc822_header_unfolded_value(msg, hdr); + * } + * fwrite(out.ptr, 1, out.len, stdout); + * rfc822_free(msg); * * License: LGPL (v2.1 or any later version) * -- 2.39.2