chiark / gitweb /
Synchronize with trunk
[disorder] / lib / mime.h
CommitLineData
460b9539 1/*
2 * This file is part of DisOrder
5aff007d 3 * Copyright (C) 2005, 2007, 2008 Richard Kettlewell
460b9539 4 *
e7eb3a27 5 * This program is free software: you can redistribute it and/or modify
460b9539 6 * it under the terms of the GNU General Public License as published by
e7eb3a27 7 * the Free Software Foundation, either version 3 of the License, or
460b9539 8 * (at your option) any later version.
e7eb3a27
RK
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 *
460b9539 15 * You should have received a copy of the GNU General Public License
e7eb3a27 16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
460b9539 17 */
39d4aa6b
RK
18/** @file lib/mime.h
19 * @brief Support for MIME and allied protocols
20 */
460b9539 21
22#ifndef MIME_H
23#define MIME_H
24
9bce81d1 25struct kvp;
26
460b9539 27int mime_content_type(const char *s,
28 char **typep,
9bce81d1 29 struct kvp **parametersp);
460b9539 30
31const 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
39int 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
45int 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
51char *mime_qp(const char *s);
460b9539 52
36bde473 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 */
39d4aa6b
RK
57struct 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
36bde473 68/** @brief A parsed cookie
69 *
70 * See <a href="http://tools.ietf.org/html/rfc2109">RFC 2109</a> and @ref
71 * cookiedata.
72 */
39d4aa6b
RK
73struct 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
88int parse_cookie(const char *s,
89 struct cookiedata *cd);
90const struct cookie *find_cookie(const struct cookiedata *cd,
91 const char *name);
36bde473 92char *quote822(const char *s, int force);
bb6ae3fb 93char *mime_to_qp(const char *text);
94const char *mime_encode_text(const char *text,
95 const char **charsetp,
96 const char **encodingp);
a1bedb6d
RK
97const char *mime_parse_word(const char *s, char **valuep,
98 int (*special)(int));
99int mime_http_separator(int c);
100int mime_tspecial(int c);
39d4aa6b 101
460b9539 102#endif /* MIME_H */
103
104/*
105Local Variables:
106c-basic-offset:2
107comment-column:40
108fill-column:79
109End:
110*/