X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=blobdiff_plain;f=lib%2Fsilcutil%2Fsilcmime.h;h=664b526a06adbaaa137947327282a30b437c5edc;hp=649c3d369c3e91a450c7de8a2d7f7242b6c6ce86;hb=e7b6c157b80152bf9fb9266e6bdd93f9fb0db776;hpb=40f8443d8d3a6577336ee66d18e04d9ac4d956bb diff --git a/lib/silcutil/silcmime.h b/lib/silcutil/silcmime.h index 649c3d36..664b526a 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 - 2007 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 @@ -68,7 +71,8 @@ typedef struct SilcMimeAssemblerStruct *SilcMimeAssembler; * * DESCRIPTION * - * Allocates SILC Mime message context. + * Allocates SILC Mime message context. Returns NULL if system is out of + * memory. * ***/ SilcMime silc_mime_alloc(void); @@ -94,7 +98,8 @@ void silc_mime_free(SilcMime mime); * * DESCRIPTION * - * Allocates MIME fragment assembler. + * Allocates MIME fragment assembler. Returns NULL if system is out of + * memory. * ***/ SilcMimeAssembler silc_mime_assembler_alloc(void); @@ -112,6 +117,29 @@ SilcMimeAssembler silc_mime_assembler_alloc(void); ***/ void silc_mime_assembler_free(SilcMimeAssembler assembler); +/****f* silcutil/SILCMIMEAPI/silc_mime_assembler_purge + * + * SYNOPSIS + * + * void silc_mime_assembler_purge(SilcMimeAssembler assembler, + * SilcUInt32 purge_minutes); + * + * DESCRIPTION + * + * Purges the MIME fragment assembler from old fragments that have never + * completed into a full MIME message. This function may be called + * periodically to purge MIME fragments. The `purge_minutes' specify + * how old fragments are purged. If it is 0, fragments older than 5 minutes + * are purged, by default. The value is in minutes. + * + * It is usefull to call this periodically to assure that memory is not + * consumed needlessly by keeping old unfinished fragments in a long + * running assembler. + * + ***/ +void silc_mime_assembler_purge(SilcMimeAssembler assembler, + SilcUInt32 purge_minutes); + /****f* silcutil/SILCMIMEAPI/silc_mime_decode * * SYNOPSIS @@ -173,7 +201,7 @@ unsigned char *silc_mime_encode(SilcMime mime, SilcUInt32 *encoded_len); * * Processes and attempts to assemble the received MIME fragment `partial'. * To check if a received MIME message is a fragment use the - * silc_mime_is_partial function. Returns NULL if all fragments has not + * silc_mime_is_partial function. Returns NULL if all fragments have not * yet been received, or the newly allocated completed MIME message if * all fragments were received. The caller must free the returned * SilcMime context. The caller must not free the `partial'. @@ -290,6 +318,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