X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilcutil%2Fsilcmime.h;h=8bc221cd07ec2d968228c3e60b42d296ec94a410;hb=e9374395ec9747bddd3ea0bfd3e5a17717e97b31;hp=62ebdefcef82efb8631863f21c06dd58b019c102;hpb=c27a4ecc3e616e8a5ee09b8ca888ed6ff3e501f7;p=silc.git diff --git a/lib/silcutil/silcmime.h b/lib/silcutil/silcmime.h index 62ebdefc..8bc221cd 100644 --- a/lib/silcutil/silcmime.h +++ b/lib/silcutil/silcmime.h @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 2005 Pekka Riikonen + Copyright (C) 2005 - 2006 Pekka Riikonen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,6 +25,9 @@ * MIME messages, multipart MIME messages, including nested multiparts, and * MIME fragmentation and defragmentation. * + * SILC Mime API is not thread-safe. If the same MIME context must be + * used in multithreaded environment concurrency control must be employed. + * ***/ #ifndef SILCMIME_H @@ -116,28 +119,32 @@ void silc_mime_assembler_free(SilcMimeAssembler assembler); * * SYNOPSIS * - * SilcMime silc_mime_decode(const unsigned char *data, + * SilcMime silc_mime_decode(SilcMime mime, const unsigned char *data, * SilcUInt32 data_len); * * DESCRIPTION * * Decodes a MIME message and returns the parsed message into newly - * allocated SilcMime context. + * allocated SilcMime context and returns it. If `mime' is non-NULL + * then the MIME message will be encoded into the pre-allocated `mime' + * context and same context is returned. If it is NULL then newly + * allocated SilcMime context is returned. On error NULL is returned. * * EXAMPLE * * // Parse MIME message and get its content type - * mime = silc_mime_decode(data, data_len); + * mime = silc_mime_decode(NULL, data, data_len); * type = silc_mime_get_field(mime, "Content-Type"); * ... * * // Assemble received MIME fragment - * mime = silc_mime_decode(data, data_len); + * mime = silc_mime_decode(NULL, data, data_len); * if (silc_mime_is_partial(mime) == TRUE) * silc_mime_assmeble(assembler, mime); * ***/ -SilcMime silc_mime_decode(const unsigned char *data, SilcUInt32 data_len); +SilcMime silc_mime_decode(SilcMime mime, const unsigned char *data, + SilcUInt32 data_len); /****f* silcutil/SILCMIMEAPI/silc_mime_encode * @@ -286,6 +293,22 @@ void silc_mime_add_data(SilcMime mime, const unsigned char *data, ***/ const unsigned char *silc_mime_get_data(SilcMime mime, SilcUInt32 *data_len); +/****f* silcutil/SILCMIMEAPI/silc_mime_steal_data + * + * SYNOPSIS + * + * unsigned char * + * silc_mime_steal_data(SilcMime mime, SilcUInt32 *data_len); + * + * DESCRIPTION + * + * Returns the MIME data from the `mime' message. The data will be + * removed from the `mime' and the caller is responsible of freeing the + * returned pointer. + * + ***/ +unsigned char *silc_mime_steal_data(SilcMime mime, SilcUInt32 *data_len); + /****f* silcutil/SILCMIMEAPI/silc_mime_is_partial * * SYNOPSIS @@ -377,4 +400,6 @@ SilcBool silc_mime_is_multipart(SilcMime mime); ***/ SilcDList silc_mime_get_multiparts(SilcMime mime, const char **type); +#include "silcmime_i.h" + #endif /* SILCMIME_H */