4 * Purple is the legal property of its developers, whose names are too
5 * numerous to list here. Please refer to the COPYRIGHT file distributed
6 * with this source distribution
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or (at
11 * your option) any later version.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301,
24 #ifndef _PURPLE_MIME_H
25 #define _PURPLE_MIME_H
37 * Rudimentary parsing of multi-part MIME messages into more
38 * accessible structures.
44 typedef struct _PurpleMimeDocument PurpleMimeDocument
;
47 * A part of a multipart MIME document.
49 typedef struct _PurpleMimePart PurpleMimePart
;
52 * Allocate an empty MIME document.
54 PurpleMimeDocument
*purple_mime_document_new(void);
57 * Frees memory used in a MIME document and all of its parts and fields
59 * @param doc The MIME document to free.
61 void purple_mime_document_free(PurpleMimeDocument
*doc
);
64 * Parse a MIME document from a NUL-terminated string.
66 * @param buf The NULL-terminated string containing the MIME-encoded data.
68 * @returns A MIME document.
70 PurpleMimeDocument
*purple_mime_document_parse(const char *buf
);
73 * Parse a MIME document from a string
75 * @param buf The string containing the MIME-encoded data.
76 * @param len Length of buf.
78 * @returns A MIME document.
80 PurpleMimeDocument
*purple_mime_document_parsen(const char *buf
, gsize len
);
83 * Write (append) a MIME document onto a GString.
85 void purple_mime_document_write(PurpleMimeDocument
*doc
, GString
*str
);
88 * The list of fields in the header of a document
90 * @param doc The MIME document.
92 * @constreturn A list of strings indicating the fields (but not the values
93 * of the fields) in the header of doc.
95 GList
*purple_mime_document_get_fields(PurpleMimeDocument
*doc
);
98 * Get the value of a specific field in the header of a document.
100 * @param doc The MIME document.
101 * @param field Case-insensitive field name.
103 * @returns Value associated with the indicated header field, or
104 * NULL if the field doesn't exist.
106 const char *purple_mime_document_get_field(PurpleMimeDocument
*doc
,
110 * Set or replace the value of a specific field in the header of a
113 * @param doc The MIME document.
114 * @param field Case-insensitive field name.
115 * @param value Value to associate with the indicated header field,
116 * of NULL to remove the field.
118 void purple_mime_document_set_field(PurpleMimeDocument
*doc
,
123 * The list of parts in a multipart document.
125 * @param doc The MIME document.
127 * @constreturn List of PurpleMimePart contained within doc.
129 GList
*purple_mime_document_get_parts(PurpleMimeDocument
*doc
);
132 * Create and insert a new part into a MIME document.
134 * @param doc The new part's parent MIME document.
136 PurpleMimePart
*purple_mime_part_new(PurpleMimeDocument
*doc
);
140 * The list of fields in the header of a document part.
142 * @param part The MIME document part.
144 * @constreturn List of strings indicating the fields (but not the values
145 * of the fields) in the header of part.
147 GList
*purple_mime_part_get_fields(PurpleMimePart
*part
);
151 * Get the value of a specific field in the header of a document part.
153 * @param part The MIME document part.
154 * @param field Case-insensitive name of the header field.
156 * @returns Value of the specified header field, or NULL if the
157 * field doesn't exist.
159 const char *purple_mime_part_get_field(PurpleMimePart
*part
,
163 * Get the decoded value of a specific field in the header of a
166 char *purple_mime_part_get_field_decoded(PurpleMimePart
*part
,
170 * Set or replace the value of a specific field in the header of a
173 * @param part The part of the MIME document.
174 * @param field Case-insensitive field name
175 * @param value Value to associate with the indicated header field,
176 * of NULL to remove the field.
178 void purple_mime_part_set_field(PurpleMimePart
*part
,
183 * Get the (possibly encoded) data portion of a MIME document part.
185 * @param part The MIME document part.
187 * @returns NULL-terminated data found in the document part
189 const char *purple_mime_part_get_data(PurpleMimePart
*part
);
192 * Get the data portion of a MIME document part, after attempting to
193 * decode it according to the content-transfer-encoding field. If the
194 * specified encoding method is not supported, this function will
197 * @param part The MIME documemt part.
198 * @param data Buffer for the data.
199 * @param len The length of the buffer.
201 void purple_mime_part_get_data_decoded(PurpleMimePart
*part
,
202 guchar
**data
, gsize
*len
);
205 * Get the length of the data portion of a MIME document part.
207 * @param part The MIME document part.
208 * @returns Length of the data in the document part.
210 gsize
purple_mime_part_get_length(PurpleMimePart
*part
);
212 void purple_mime_part_set_data(PurpleMimePart
*part
, const char *data
);