X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Frfc822%2Frfc822.h;h=a4ac156522ebdfbffb3401b39ee8567f63ecaa51;hb=b089d462e533d2b304cc28b9ad277cbfa53f12ce;hp=2beae410cda27e80f4905aca63aa37cb776cd70d;hpb=de28abde1337e9255812ba720ffeef2c83a25dde;p=ccan diff --git a/ccan/rfc822/rfc822.h b/ccan/rfc822/rfc822.h index 2beae410..a4ac1565 100644 --- a/ccan/rfc822/rfc822.h +++ b/ccan/rfc822/rfc822.h @@ -22,6 +22,9 @@ struct rfc822_msg; * callback is called with a string describing where the failure * occurred, which can be used to log a more useful error message. * + * Note that tal also has a default function which calls abort() on allocation + * failure: see tal_set_backend(). + * * Example: * static void my_handler(const char *str) * { @@ -53,15 +56,15 @@ static inline bool rfc822_iswsp(char c) * inconsistent, and the function will abort. If the state of the * structure is valid it returns it unchanged. * - * Returns the list head if the list is consistent, NULL if not (it - * can never return NULL if @abortstr is set). + * Returns the @msg if the message is consistent, NULL if not (it can + * never return NULL if @abortstr is set). */ struct rfc822_msg *rfc822_check(const struct rfc822_msg *msg, const char *abortstr); /** * rfc822_start - start parsing a new rfc822 message - * @ctx: talloc context to make allocations in + * @ctx: tal context to make allocations in (or talloc #ifdef TAL_USE_TALLOC) * @p: pointer to a buffer containing the message text * @len: length of the message text * @@ -75,7 +78,7 @@ struct rfc822_msg *rfc822_start(const void *ctx, const char *p, size_t len); * rfc822_free - free an rfc822 message * @msg: message to free * - * Frees an rfc822_msg context, including all subsiduary data + * Frees an rfc822_msg context, including all subsidiary data * structures. */ void rfc822_free(struct rfc822_msg *msg); @@ -117,7 +120,7 @@ struct bytestring rfc822_body(struct rfc822_msg *msg); enum rfc822_header_errors { RFC822_HDR_NO_COLON = 1, - RFC822_HDR_BAD_NAME = 2, + RFC822_HDR_BAD_NAME_CHARS = 2, }; enum rfc822_header_errors rfc822_header_errors(struct rfc822_msg *msg, @@ -168,4 +171,22 @@ struct bytestring rfc822_header_raw_value(struct rfc822_msg *msg, struct bytestring rfc822_header_unfolded_value(struct rfc822_msg *msg, struct rfc822_header *hdr); +/** + * rfc822_header_is - determine if a header is of a given name + * @msg: message + * @hdr: a header handle + * @name: header name + * + * This returns true if the header field @hdr has name @name (case + * insensitive), otherwise false. + */ +bool rfc822_header_is(struct rfc822_msg *msg, struct rfc822_header *hdr, + const char *name); + +struct rfc822_header *rfc822_first_header_of_name(struct rfc822_msg *msg, + const char *name); +struct rfc822_header *rfc822_next_header_of_name(struct rfc822_msg *msg, + struct rfc822_header *hdr, + const char *name); + #endif /* CCAN_RFC822_H_ */