Fix some functions descriptions
[pidgin-git.git] / libpurple / mime.h
blob967215eff95bb429d4e0ca22635b67fcc0fb7bdd
1 /*
2 * Purple
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,
21 * USA.
24 #ifndef _PURPLE_MIME_H
25 #define _PURPLE_MIME_H
26 /**
27 * SECTION:mime
28 * @section_id: libpurple-mime
29 * @short_description: <filename>mime.h</filename>
30 * @title: Multi-part MIME Message Parsing
32 * Rudimentary parsing of multi-part MIME messages into more
33 * accessible structures.
36 #include <glib.h>
38 /**
39 * PurpleMimeDocument:
41 * A MIME document.
43 typedef struct _PurpleMimeDocument PurpleMimeDocument;
45 /**
46 * PurpleMimePart:
48 * A part of a multipart MIME document.
50 typedef struct _PurpleMimePart PurpleMimePart;
52 G_BEGIN_DECLS
54 /**
55 * purple_mime_document_new:
57 * Allocate an empty MIME document.
59 PurpleMimeDocument *purple_mime_document_new(void);
61 /**
62 * purple_mime_document_free:
63 * @doc: The MIME document to free.
65 * Frees memory used in a MIME document and all of its parts and fields
67 void purple_mime_document_free(PurpleMimeDocument *doc);
69 /**
70 * purple_mime_document_parse:
71 * @buf: The NULL-terminated string containing the MIME-encoded data.
73 * Parse a MIME document from a NUL-terminated string.
75 * Returns: A MIME document.
77 PurpleMimeDocument *purple_mime_document_parse(const char *buf);
79 /**
80 * purple_mime_document_parsen:
81 * @buf: The string containing the MIME-encoded data.
82 * @len: Length of buf.
84 * Parse a MIME document from a string
86 * Returns: A MIME document.
88 PurpleMimeDocument *purple_mime_document_parsen(const char *buf, gsize len);
90 /**
91 * purple_mime_document_write:
93 * Write (append) a MIME document onto a GString.
95 void purple_mime_document_write(PurpleMimeDocument *doc, GString *str);
97 /**
98 * purple_mime_document_get_fields:
99 * @doc: The MIME document.
101 * The list of fields in the header of a document
103 * Returns: (transfer none): A list of strings indicating the fields (but not
104 * the values of the fields) in the header of doc.
106 GList *purple_mime_document_get_fields(PurpleMimeDocument *doc);
109 * purple_mime_document_get_field:
110 * @doc: The MIME document.
111 * @field: Case-insensitive field name.
113 * Get the value of a specific field in the header of a document.
115 * Returns: Value associated with the indicated header field, or
116 * NULL if the field doesn't exist.
118 const char *purple_mime_document_get_field(PurpleMimeDocument *doc,
119 const char *field);
122 * purple_mime_document_set_field:
123 * @doc: The MIME document.
124 * @field: Case-insensitive field name.
125 * @value: Value to associate with the indicated header field,
126 * of NULL to remove the field.
128 * Set or replace the value of a specific field in the header of a
129 * document.
131 void purple_mime_document_set_field(PurpleMimeDocument *doc,
132 const char *field,
133 const char *value);
136 * purple_mime_document_get_parts:
137 * @doc: The MIME document.
139 * The list of parts in a multipart document.
141 * Returns: (transfer none): List of PurpleMimePart contained within doc.
143 GList *purple_mime_document_get_parts(PurpleMimeDocument *doc);
146 * purple_mime_part_new:
147 * @doc: The new part's parent MIME document.
149 * Create and insert a new part into a MIME document.
151 PurpleMimePart *purple_mime_part_new(PurpleMimeDocument *doc);
155 * purple_mime_part_get_fields:
156 * @part: The MIME document part.
158 * The list of fields in the header of a document part.
160 * Returns: (transfer none): List of strings indicating the fields (but not the
161 * values of the fields) in the header of part.
163 GList *purple_mime_part_get_fields(PurpleMimePart *part);
167 * purple_mime_part_get_field:
168 * @part: The MIME document part.
169 * @field: Case-insensitive name of the header field.
171 * Get the value of a specific field in the header of a document part.
173 * Returns: Value of the specified header field, or NULL if the
174 * field doesn't exist.
176 const char *purple_mime_part_get_field(PurpleMimePart *part,
177 const char *field);
180 * purple_mime_part_get_field_decoded:
182 * Get the decoded value of a specific field in the header of a
183 * document part.
185 char *purple_mime_part_get_field_decoded(PurpleMimePart *part,
186 const char *field);
189 * purple_mime_part_set_field:
190 * @part: The part of the MIME document.
191 * @field: Case-insensitive field name
192 * @value: Value to associate with the indicated header field,
193 * of NULL to remove the field.
195 * Set or replace the value of a specific field in the header of a
196 * document.
198 void purple_mime_part_set_field(PurpleMimePart *part,
199 const char *field,
200 const char *value);
203 * purple_mime_part_get_data:
204 * @part: The MIME document part.
206 * Get the (possibly encoded) data portion of a MIME document part.
208 * Returns: NULL-terminated data found in the document part
210 const char *purple_mime_part_get_data(PurpleMimePart *part);
213 * purple_mime_part_get_data_decoded:
214 * @part: The MIME documemt part.
215 * @data: Buffer for the data.
216 * @len: The length of the buffer.
218 * Get the data portion of a MIME document part, after attempting to
219 * decode it according to the content-transfer-encoding field. If the
220 * specified encoding method is not supported, this function will
221 * return NULL.
223 void purple_mime_part_get_data_decoded(PurpleMimePart *part,
224 guchar **data, gsize *len);
227 * purple_mime_part_get_length:
228 * @part: The MIME document part.
230 * Get the length of the data portion of a MIME document part.
232 * Returns: Length of the data in the document part.
234 gsize purple_mime_part_get_length(PurpleMimePart *part);
236 void purple_mime_part_set_data(PurpleMimePart *part, const char *data);
238 G_END_DECLS
240 #endif