rfc822-parser.h revision 2de709376eddc50ec5fa470358bb57cf0a87bb1f
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen#ifndef __RFC822_PARSER_H
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen#define __RFC822_PARSER_H
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainenstruct rfc822_parser_context {
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen const unsigned char *data, *end;
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen string_t *last_comment;
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen};
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainenvoid rfc822_parser_init(struct rfc822_parser_context *ctx,
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen const unsigned char *data, size_t size,
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen string_t *last_comment);
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen/* Parse comment. Assumes parser's data points to '(' */
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainenint rfc822_skip_comment(struct rfc822_parser_context *ctx);
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen/* Skip LWSP if there is any */
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainenint rfc822_skip_lwsp(struct rfc822_parser_context *ctx);
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen/* Stop at next non-atext char */
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainenint rfc822_parse_atom(struct rfc822_parser_context *ctx, string_t *str);
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen/* Like parse_atom() but don't stop at '.' */
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainenint rfc822_parse_dot_atom(struct rfc822_parser_context *ctx, string_t *str);
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen/* Like parse_dot_atom() but stops for '/', '?' and '='.
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen Also it doesn't allow LWSP around '.' chars. */
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainenint rfc822_parse_mime_token(struct rfc822_parser_context *ctx, string_t *str);
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen/* "quoted string" */
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainenint rfc822_parse_quoted_string(struct rfc822_parser_context *ctx,
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen string_t *str);
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen/* atom or quoted-string */
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainenint rfc822_parse_phrase(struct rfc822_parser_context *ctx, string_t *str);
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen/* dot-atom / domain-literal */
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainenint rfc822_parse_domain(struct rfc822_parser_context *ctx, string_t *str);
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen#endif
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen