6 * rfc822 - Parsing of RFC822 emails
8 * This code allows easy processing of RFC822/RFC2822/RFC5322
9 * formatted email messages. For now only read-only operation is
12 * The important design goals are these:
13 * - Be lazy. Don't compute immediately compute fancy indexes for the
14 * message. Just reading messages into the system and then sending
15 * them out again should not incur a serious performance hit.
16 * - But cache. Once the user does request data that needs parsing,
17 * cache the results in suitable data structures so that if lots
18 * more lookups are done they're then fast.
19 * - Cope with ill-formatted messages. Even if the input is not
20 * RFC822 compliant, don't SEGV and try to return as much useful
24 * // Given '' outputs 'body'
25 * // Given 'From' outputs ' <from@example.com>'
26 * // Given 'To' outputs ' <to@example.com>'
27 * char buf[] = "From: <from@example.com>\n"
28 * "To: <to@example.com>\n\n"
30 * struct rfc822_msg *msg;
31 * struct bytestring out;
33 * msg = rfc822_start(NULL, buf, sizeof(buf));
34 * if (!argv[1] || !argv[1][0])
35 * out = rfc822_body(msg);
37 * struct rfc822_header *hdr;
38 * hdr = rfc822_first_header_of_name(msg, argv[1]);
41 * out = rfc822_header_unfolded_value(msg, hdr);
43 * fwrite(out.ptr, 1, out.len, stdout);
46 * License: LGPL (v2.1 or any later version)
49 int main(int argc, char *argv[])
51 /* Expect exactly one argument */
55 if (strcmp(argv[1], "depends") == 0) {
56 printf("ccan/talloc\n");
57 printf("ccan/list\n");
59 printf("ccan/bytestring\n");
63 if (strcmp(argv[1], "testdepends") == 0) {
64 printf("ccan/failtest\n");
65 printf("ccan/foreach\n");
66 printf("ccan/array_size\n");