Remove useless comparison
[pidgin-git.git] / libpurple / mime.h
blobb568a49288de6b38c00c9172b92c78a6969d4b2a
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
27 #include <glib.h>
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
33 /**
34 * @file mime.h
35 * @ingroup core
37 * Rudimentary parsing of multi-part MIME messages into more
38 * accessible structures.
41 /**
42 * A MIME document.
44 typedef struct _PurpleMimeDocument PurpleMimeDocument;
46 /**
47 * A part of a multipart MIME document.
49 typedef struct _PurpleMimePart PurpleMimePart;
51 /**
52 * Allocate an empty MIME document.
54 PurpleMimeDocument *purple_mime_document_new(void);
56 /**
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);
63 /**
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);
72 /**
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);
82 /**
83 * Write (append) a MIME document onto a GString.
85 void purple_mime_document_write(PurpleMimeDocument *doc, GString *str);
87 /**
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);
97 /**
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,
107 const char *field);
110 * Set or replace the value of a specific field in the header of a
111 * document.
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,
119 const char *field,
120 const char *value);
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,
160 const char *field);
163 * Get the decoded value of a specific field in the header of a
164 * document part.
166 char *purple_mime_part_get_field_decoded(PurpleMimePart *part,
167 const char *field);
170 * Set or replace the value of a specific field in the header of a
171 * document.
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,
179 const char *field,
180 const char *value);
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
195 * return NULL.
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);
214 #ifdef __cplusplus
216 #endif
218 #endif