Commit version string files.
[disorder] / lib / mime.h
1 /*
2 * This file is part of DisOrder
3 * Copyright (C) 2005, 2007, 2008 Richard Kettlewell
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (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 General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 /** @file lib/mime.h
19 * @brief Support for MIME and allied protocols
20 */
21
22 #ifndef MIME_H
23 #define MIME_H
24
25 struct kvp;
26
27 int mime_content_type(const char *s,
28 char **typep,
29 struct kvp **parametersp);
30
31 const char *mime_parse(const char *s,
32 int (*callback)(const char *name, const char *value,
33 void *u),
34 void *u);
35 /* Parse a MIME message. Calls CALLBACK for each header field, then returns a
36 * pointer to the decoded body (might or might not point back into the original
37 * string). */
38
39 int mime_multipart(const char *s,
40 int (*callback)(const char *s, void *u),
41 const char *boundary,
42 void *u);
43 /* call CALLBACK with each part of multipart document [s,s+n) */
44
45 int mime_rfc2388_content_disposition(const char *s,
46 char **dispositionp,
47 char **parameternamep,
48 char **parametervaluep);
49 /* Parse an RFC2388-style content-disposition field */
50
51 char *mime_qp(const char *s);
52
53 /** @brief Parsed form of an HTTP Cookie: header field
54 *
55 * See <a href="http://tools.ietf.org/html/rfc2109">RFC 2109</a>.
56 */
57 struct cookiedata {
58 /** @brief @c $Version or NULL if not set */
59 char *version;
60
61 /** @brief List of cookies */
62 struct cookie *cookies;
63
64 /** @brief Number of cookies */
65 int ncookies;
66 };
67
68 /** @brief A parsed cookie
69 *
70 * See <a href="http://tools.ietf.org/html/rfc2109">RFC 2109</a> and @ref
71 * cookiedata.
72 */
73 struct cookie {
74 /** @brief Cookie name */
75 char *name;
76
77 /** @brief Cookie value */
78 char *value;
79
80 /** @brief Cookie path */
81 char *path;
82
83 /** @brief Cookie domain */
84 char *domain;
85
86 };
87
88 int parse_cookie(const char *s,
89 struct cookiedata *cd);
90 const struct cookie *find_cookie(const struct cookiedata *cd,
91 const char *name);
92 char *quote822(const char *s, int force);
93 char *mime_to_qp(const char *text);
94 const char *mime_encode_text(const char *text,
95 const char **charsetp,
96 const char **encodingp);
97 const char *mime_parse_word(const char *s, char **valuep,
98 int (*special)(int));
99 int mime_http_separator(int c);
100 int mime_tspecial(int c);
101
102 #endif /* MIME_H */
103
104 /*
105 Local Variables:
106 c-basic-offset:2
107 comment-column:40
108 fill-column:79
109 End:
110 */