_info 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #include "config.h"
  2. #include <stdio.h>
  3. #include <string.h>
  4. /**
  5. * rfc822 - Parsing of RFC822 emails
  6. *
  7. * This code allows easy processing of RFC822/RFC2822/RFC5322
  8. * formatted email messages. For now only read-only operation is
  9. * supported.
  10. *
  11. * The important design goals are these:
  12. * - Be lazy. Don't compute immediately compute fancy indexes for the
  13. * message. Just reading messages into the system and then sending
  14. * them out again should not incur a serious performance hit.
  15. * - But cache. Once the user does request data that needs parsing,
  16. * cache the results in suitable data structures so that if lots
  17. * more lookups are done they're then fast.
  18. * - Cope with ill-formatted messages. Even if the input is not
  19. * RFC822 compliant, don't SEGV and try to return as much useful
  20. * data as possible.
  21. *
  22. * Define TAL_USE_TALLOC to use libtalloc as the allocator, otherwise
  23. * it will use ccan/tal (usually done on the cmdline, as tal/str will need
  24. * it too).
  25. *
  26. * Example:
  27. * // Given '' outputs 'body'
  28. * // Given 'From' outputs ' <from@example.com>'
  29. * // Given 'To' outputs ' <to@example.com>'
  30. * char buf[] = "From: <from@example.com>\n"
  31. * "To: <to@example.com>\n\n"
  32. * "body\n";
  33. * struct rfc822_msg *msg;
  34. * struct bytestring out;
  35. *
  36. * msg = rfc822_start(NULL, buf, sizeof(buf));
  37. * if (!argv[1] || !argv[1][0])
  38. * out = rfc822_body(msg);
  39. * else {
  40. * struct rfc822_header *hdr;
  41. * hdr = rfc822_first_header_of_name(msg, argv[1]);
  42. * if (!hdr)
  43. * exit(1);
  44. * out = rfc822_header_unfolded_value(msg, hdr);
  45. * }
  46. * fwrite(out.ptr, 1, out.len, stdout);
  47. * rfc822_free(msg);
  48. *
  49. * License: LGPL (v2.1 or any later version)
  50. *
  51. */
  52. int main(int argc, char *argv[])
  53. {
  54. /* Expect exactly one argument */
  55. if (argc != 2)
  56. return 1;
  57. if (strcmp(argv[1], "depends") == 0) {
  58. #ifdef TAL_USE_TALLOC
  59. printf("ccan/tal/talloc\n");
  60. #else
  61. printf("ccan/tal\n");
  62. #endif
  63. printf("ccan/list\n");
  64. printf("ccan/str\n");
  65. printf("ccan/bytestring\n");
  66. printf("ccan/mem\n");
  67. return 0;
  68. }
  69. if (strcmp(argv[1], "testdepends") == 0) {
  70. printf("ccan/failtest\n");
  71. printf("ccan/foreach\n");
  72. printf("ccan/array_size\n");
  73. printf("ccan/tal/str\n");
  74. return 0;
  75. }
  76. return 1;
  77. }