agent/
[gnupg.git] / tools / rfc822parse.h
blob12699d5e8812f1ced930f9837cd3873f0783fdc0
1 /* rfc822parse.h - Simple mail and MIME parser
2 * Copyright (C) 1999 Werner Koch, Duesseldorf
3 * Copyright (C) 2003, g10 Code GmbH
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public License
7 * as published by the Free Software Foundation; either version 3 of
8 * the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this program; if not, see <http://www.gnu.org/licenses/>.
19 #ifndef RFC822PARSE_H
20 #define RFC822PARSE_H
22 struct rfc822parse_context;
23 typedef struct rfc822parse_context *rfc822parse_t;
25 typedef enum
27 RFC822PARSE_OPEN = 1,
28 RFC822PARSE_CLOSE,
29 RFC822PARSE_CANCEL,
30 RFC822PARSE_T2BODY,
31 RFC822PARSE_FINISH,
32 RFC822PARSE_RCVD_SEEN,
33 RFC822PARSE_LEVEL_DOWN,
34 RFC822PARSE_LEVEL_UP,
35 RFC822PARSE_BOUNDARY,
36 RFC822PARSE_LAST_BOUNDARY,
37 RFC822PARSE_BEGIN_HEADER,
38 RFC822PARSE_PREAMBLE,
39 RFC822PARSE_EPILOGUE
41 rfc822parse_event_t;
43 struct rfc822parse_field_context;
44 typedef struct rfc822parse_field_context *rfc822parse_field_t;
47 typedef int (*rfc822parse_cb_t) (void *opaque,
48 rfc822parse_event_t event,
49 rfc822parse_t msg);
52 rfc822parse_t rfc822parse_open (rfc822parse_cb_t cb, void *opaque_value);
54 void rfc822parse_close (rfc822parse_t msg);
56 void rfc822parse_cancel (rfc822parse_t msg);
57 int rfc822parse_finish (rfc822parse_t msg);
59 int rfc822parse_insert (rfc822parse_t msg,
60 const unsigned char *line, size_t length);
62 char *rfc822parse_get_field (rfc822parse_t msg, const char *name, int which,
63 size_t *valueoff);
65 const char *rfc822parse_enum_header_lines (rfc822parse_t msg, void **context);
67 rfc822parse_field_t rfc822parse_parse_field (rfc822parse_t msg,
68 const char *name,
69 int which);
71 void rfc822parse_release_field (rfc822parse_field_t field);
73 const char *rfc822parse_query_parameter (rfc822parse_field_t ctx,
74 const char *attr, int lower_value);
76 const char *rfc822parse_query_media_type (rfc822parse_field_t ctx,
77 const char **subtype);
79 #endif /*RFC822PARSE_H */