text
stringlengths
0
357
exit(33);
}
mimepart->type = 0;
mimepart->param = dc_param_new();
return mimepart;
}
static void dc_mimepart_unref(dc_mimepart_t* mimepart)
{
if (mimepart==NULL) {
return;
}
free(mimepart->msg);
mimepart->msg = NULL;
free(mimepart->msg_raw);
mimepart->msg_raw = NULL;
dc_param_unref(mimepart->param);
free(mimepart);
}
/*******************************************************************************
* Main interface
******************************************************************************/
/**
* Create a new mime parser object.
*
* @private @memberof dc_mimeparser_t
* @param blobdir Directrory to write attachments to.
* @param context Mailbox object, used for logging only.
* @return The MIME-parser object.
*/
dc_mimeparser_t* dc_mimeparser_new(const char* blobdir, dc_context_t* context)
{
dc_mimeparser_t* mimeparser = NULL;
if ((mimeparser=calloc(1, sizeof(dc_mimeparser_t)))==NULL) {
exit(30);
}
mimeparser->context = context;
mimeparser->parts = carray_new(16);
mimeparser->blobdir = blobdir; /* no need to copy the string at the moment */
mimeparser->reports = carray_new(16);
mimeparser->e2ee_helper = calloc(1, sizeof(dc_e2ee_helper_t));
dc_hash_init(&mimeparser->header, DC_HASH_STRING, 0/* do not copy key */);
return mimeparser;
}
/**
* Free a MIME-parser object.
*
* Esp. all data allocated by dc_mimeparser_parse() will be free()'d.
*
* @private @memberof dc_mimeparser_t
* @param mimeparser The MIME-parser object.
* @return None.
*/
void dc_mimeparser_unref(dc_mimeparser_t* mimeparser)
{
if (mimeparser==NULL) {
return;
}
dc_mimeparser_empty(mimeparser);
if (mimeparser->parts) {
carray_free(mimeparser->parts);
}
if (mimeparser->reports) {
carray_free(mimeparser->reports);
}
free(mimeparser->e2ee_helper);
free(mimeparser);
}
/**
* Empty all data in a MIME-parser object.
*
* This function is called implicitly by dc_mimeparser_parse() to free
* previously allocated data.
*
* @private @memberof dc_mimeparser_t
* @param mimeparser The MIME-parser object.
* @return None.
*/