]> git.ozlabs.org Git - ccan/commitdiff
rfc822: beef up _info example.
authorRusty Russell <rusty@rustcorp.com.au>
Fri, 7 Dec 2012 05:56:37 +0000 (16:26 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Fri, 7 Dec 2012 05:56:37 +0000 (16:26 +1030)
Now it's a useful little command line utility, with tests.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ccan/rfc822/_info

index 17ad934f45dbec577ef766898d3de140d5f054ab..7b8eda62ac3e976679ce6c4aa5dc8d8689723d65 100644 (file)
  *   data as possible.
  *
  * Example:
  *   data as possible.
  *
  * Example:
+ *     // Given '' outputs 'body'
+ *     // Given 'From' outputs ' <from@example.com>'
+ *     // Given 'To' outputs ' <to@example.com>'
  *     char buf[] = "From: <from@example.com>\n"
  *                  "To: <to@example.com>\n\n"
  *                   "body\n";
  *     struct rfc822_msg *msg;
  *     char buf[] = "From: <from@example.com>\n"
  *                  "To: <to@example.com>\n\n"
  *                   "body\n";
  *     struct rfc822_msg *msg;
- *     struct bytestring body;
+ *     struct bytestring out;
  *
  *     msg = rfc822_start(NULL, buf, sizeof(buf));
  *
  *     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)
  *
  *
  * License: LGPL (v2.1 or any later version)
  *