From 1083c2a818cda51f81c908a801bd5f922f99149e Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Fri, 26 Sep 2008 16:02:27 +0000 Subject: [PATCH] Updated the MIME Parser API to include Content-ID in the callback functions. This effects the entire Citadel system, so you will have to update all three components now. --- citadel/citadel.h | 4 +-- citadel/modules/calendar/serv_calendar.c | 10 +++---- citadel/modules/imap/imap_fetch.c | 8 +++--- citadel/modules/notes/serv_notes.c | 2 +- citadel/modules/vcard/serv_vcard.c | 4 +-- citadel/msgbase.c | 24 ++++++++--------- libcitadel/lib/libcitadel.h | 12 ++++++++- libcitadel/lib/mime_parser.c | 34 +++++++++++++++++++----- webcit/groupdav_get.c | 2 +- webcit/webcit.c | 3 ++- webcit/webcit.h | 6 ++--- 11 files changed, 70 insertions(+), 39 deletions(-) diff --git a/citadel/citadel.h b/citadel/citadel.h index 5f205c4cb..5b6bb0a69 100644 --- a/citadel/citadel.h +++ b/citadel/citadel.h @@ -38,10 +38,10 @@ extern "C" { * usually more strict because you're not really supposed to dump/load and * upgrade at the same time. */ -#define REV_LEVEL 738 /* This version */ +#define REV_LEVEL 739 /* This version */ #define REV_MIN 591 /* Oldest compatible database */ #define EXPORT_REV_MIN 737 /* Oldest compatible export files */ -#define LIBCITADEL_MIN 738 /* Minimum required version of libcitadel */ +#define LIBCITADEL_MIN 739 /* Minimum required version of libcitadel */ #define SERVER_TYPE 0 /* zero for stock Citadel; other developers please obtain SERVER_TYPE codes for your implementations */ diff --git a/citadel/modules/calendar/serv_calendar.c b/citadel/modules/calendar/serv_calendar.c index 62b3a4e42..b1cc6e496 100644 --- a/citadel/modules/calendar/serv_calendar.c +++ b/citadel/modules/calendar/serv_calendar.c @@ -19,7 +19,7 @@ #ifdef HAVE_STRINGS_H #include #endif -#include +#include #include #include "citadel.h" #include "server.h" @@ -355,7 +355,7 @@ void ical_send_a_reply(icalcomponent *request, char *action) { */ void ical_locate_part(char *name, char *filename, char *partnum, char *disp, void *content, char *cbtype, char *cbcharset, size_t length, char *encoding, - void *cbuserdata) { + char *cbid, void *cbuserdata) { struct ical_respond_data *ird = NULL; @@ -514,7 +514,7 @@ struct original_event_container { */ void ical_locate_original_event(char *name, char *filename, char *partnum, char *disp, void *content, char *cbtype, char *cbcharset, size_t length, char *encoding, - void *cbuserdata) { + char *cbid, void *cbuserdata) { struct original_event_container *oec = NULL; @@ -2007,7 +2007,7 @@ void ical_saving_vevent(icalcomponent *cal) { */ void ical_obj_beforesave_backend(char *name, char *filename, char *partnum, char *disp, void *content, char *cbtype, char *cbcharset, size_t length, - char *encoding, void *cbuserdata) + char *encoding, char *cbid, void *cbuserdata) { icalcomponent *cal, *nested_event, *nested_todo, *whole_cal; icalproperty *p; @@ -2151,7 +2151,7 @@ int ical_obj_beforesave(struct CtdlMessage *msg) */ void ical_obj_aftersave_backend(char *name, char *filename, char *partnum, char *disp, void *content, char *cbtype, char *cbcharset, size_t length, - char *encoding, void *cbuserdata) + char *encoding, char *cbid, void *cbuserdata) { icalcomponent *cal; diff --git a/citadel/modules/imap/imap_fetch.c b/citadel/modules/imap/imap_fetch.c index a7a4f3fd3..75a05dbb4 100644 --- a/citadel/modules/imap/imap_fetch.c +++ b/citadel/modules/imap/imap_fetch.c @@ -261,7 +261,7 @@ void imap_fetch_rfc822(long msgnum, char *whichfmt) { */ void imap_load_part(char *name, char *filename, char *partnum, char *disp, void *content, char *cbtype, char *cbcharset, size_t length, char *encoding, - void *cbuserdata) + char *cbid, void *cbuserdata) { char mbuf2[SIZ]; char *desired_section; @@ -728,7 +728,7 @@ void imap_fetch_body(long msgnum, char *item, int is_peek) { void imap_fetch_bodystructure_pre( char *name, char *filename, char *partnum, char *disp, void *content, char *cbtype, char *cbcharset, size_t length, char *encoding, - void *cbuserdata + char *cbid, void *cbuserdata ) { cprintf("("); @@ -742,7 +742,7 @@ void imap_fetch_bodystructure_pre( void imap_fetch_bodystructure_post( char *name, char *filename, char *partnum, char *disp, void *content, char *cbtype, char *cbcharset, size_t length, char *encoding, - void *cbuserdata + char *cbid, void *cbuserdata ) { char subtype[128]; @@ -768,7 +768,7 @@ void imap_fetch_bodystructure_post( void imap_fetch_bodystructure_part( char *name, char *filename, char *partnum, char *disp, void *content, char *cbtype, char *cbcharset, size_t length, char *encoding, - void *cbuserdata + char *cbid, void *cbuserdata ) { int have_cbtype = 0; diff --git a/citadel/modules/notes/serv_notes.c b/citadel/modules/notes/serv_notes.c index 56c1e6ee9..8d3f88822 100644 --- a/citadel/modules/notes/serv_notes.c +++ b/citadel/modules/notes/serv_notes.c @@ -49,7 +49,7 @@ */ void notes_extract_vnote(char *name, char *filename, char *partnum, char *disp, void *content, char *cbtype, char *cbcharset, size_t length, - char *encoding, void *cbuserdata) + char *encoding, char *cbid, void *cbuserdata) { struct vnote **v = (struct vnote **) cbuserdata; diff --git a/citadel/modules/vcard/serv_vcard.c b/citadel/modules/vcard/serv_vcard.c index a6f6f9d51..8561d43ce 100644 --- a/citadel/modules/vcard/serv_vcard.c +++ b/citadel/modules/vcard/serv_vcard.c @@ -458,7 +458,7 @@ void extract_friendly_name(char *namebuf, size_t namebuf_len, struct vCard *v) */ void vcard_extract_vcard(char *name, char *filename, char *partnum, char *disp, void *content, char *cbtype, char *cbcharset, size_t length, - char *encoding, void *cbuserdata) + char *encoding, char *cbid, void *cbuserdata) { struct vCard **v = (struct vCard **) cbuserdata; @@ -1176,7 +1176,7 @@ void cmd_gvea(char *argbuf) */ void dvca_mime_callback(char *name, char *filename, char *partnum, char *disp, void *content, char *cbtype, char *cbcharset, size_t length, char *encoding, - void *cbuserdata) { + char *cbid, void *cbuserdata) { struct vCard *v; char displayname[256]; diff --git a/citadel/msgbase.c b/citadel/msgbase.c index e48dca901..9ccc60a9a 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -925,7 +925,7 @@ void memfmout( */ void list_this_part(char *name, char *filename, char *partnum, char *disp, void *content, char *cbtype, char *cbcharset, size_t length, char *encoding, - void *cbuserdata) + char *cbid, void *cbuserdata) { struct ma_info *ma; @@ -941,7 +941,7 @@ void list_this_part(char *name, char *filename, char *partnum, char *disp, */ void list_this_pref(char *name, char *filename, char *partnum, char *disp, void *content, char *cbtype, char *cbcharset, size_t length, char *encoding, - void *cbuserdata) + char *cbid, void *cbuserdata) { struct ma_info *ma; @@ -960,7 +960,7 @@ void list_this_pref(char *name, char *filename, char *partnum, char *disp, */ void list_this_suff(char *name, char *filename, char *partnum, char *disp, void *content, char *cbtype, char *cbcharset, size_t length, char *encoding, - void *cbuserdata) + char *cbid, void *cbuserdata) { struct ma_info *ma; @@ -979,7 +979,7 @@ void list_this_suff(char *name, char *filename, char *partnum, char *disp, */ void mime_download(char *name, char *filename, char *partnum, char *disp, void *content, char *cbtype, char *cbcharset, size_t length, - char *encoding, void *cbuserdata) + char *encoding, char *cbid, void *cbuserdata) { /* Silently go away if there's already a download open... */ @@ -1008,7 +1008,7 @@ void mime_download(char *name, char *filename, char *partnum, char *disp, */ void mime_spew_section(char *name, char *filename, char *partnum, char *disp, void *content, char *cbtype, char *cbcharset, size_t length, - char *encoding, void *cbuserdata) + char *encoding, char *cbid, void *cbuserdata) { int *found_it = (int *)cbuserdata; @@ -1161,7 +1161,7 @@ void CtdlFreeMessage(struct CtdlMessage *msg) */ void fixed_output_pre(char *name, char *filename, char *partnum, char *disp, void *content, char *cbtype, char *cbcharset, size_t length, char *encoding, - void *cbuserdata) + char *cbid, void *cbuserdata) { struct ma_info *ma; @@ -1181,7 +1181,7 @@ void fixed_output_pre(char *name, char *filename, char *partnum, char *disp, */ void fixed_output_post(char *name, char *filename, char *partnum, char *disp, void *content, char *cbtype, char *cbcharset, size_t length, - char *encoding, void *cbuserdata) + char *encoding, char *cbid, void *cbuserdata) { struct ma_info *ma; @@ -1201,7 +1201,7 @@ void fixed_output_post(char *name, char *filename, char *partnum, char *disp, */ void fixed_output(char *name, char *filename, char *partnum, char *disp, void *content, char *cbtype, char *cbcharset, size_t length, - char *encoding, void *cbuserdata) + char *encoding, char *cbid, void *cbuserdata) { char *ptr; char *wptr; @@ -1274,7 +1274,7 @@ void fixed_output(char *name, char *filename, char *partnum, char *disp, */ void choose_preferred(char *name, char *filename, char *partnum, char *disp, void *content, char *cbtype, char *cbcharset, size_t length, - char *encoding, void *cbuserdata) + char *encoding, char *cbid, void *cbuserdata) { char buf[1024]; int i; @@ -1304,7 +1304,7 @@ void choose_preferred(char *name, char *filename, char *partnum, char *disp, */ void output_preferred(char *name, char *filename, char *partnum, char *disp, void *content, char *cbtype, char *cbcharset, size_t length, - char *encoding, void *cbuserdata) + char *encoding, char *cbid, void *cbuserdata) { int i; char buf[128]; @@ -1352,7 +1352,7 @@ void output_preferred(char *name, char *filename, char *partnum, char *disp, /* No translations required or possible: output as text/plain */ cprintf("Content-type: text/plain\n\n"); fixed_output(name, filename, partnum, disp, content, cbtype, cbcharset, - length, encoding, cbuserdata); + length, encoding, cbid, cbuserdata); } @@ -1368,7 +1368,7 @@ struct encapmsg { */ void extract_encapsulated_message(char *name, char *filename, char *partnum, char *disp, void *content, char *cbtype, char *cbcharset, size_t length, - char *encoding, void *cbuserdata) + char *encoding, char *cbid, void *cbuserdata) { struct encapmsg *encap; diff --git a/libcitadel/lib/libcitadel.h b/libcitadel/lib/libcitadel.h index 2c5b48d91..35438cdd7 100644 --- a/libcitadel/lib/libcitadel.h +++ b/libcitadel/lib/libcitadel.h @@ -15,7 +15,7 @@ #include #include #include -#define LIBCITADEL_VERSION_NUMBER 738 +#define LIBCITADEL_VERSION_NUMBER 739 /* * Here's a bunch of stupid magic to make the MIME parser portable. @@ -90,6 +90,7 @@ void mime_parser(char *content_start, char *content_end, char *cbcharset, size_t cblength, char *cbencoding, + char *cbid, void *cbuserdata), void (*PreMultiPartCallBack) (char *cbname, @@ -101,6 +102,7 @@ void mime_parser(char *content_start, char *content_end, char *cbcharset, size_t cblength, char *cbencoding, + char *cbid, void *cbuserdata), void (*PostMultiPartCallBack) (char *cbname, @@ -112,6 +114,7 @@ void mime_parser(char *content_start, char *content_end, char *cbcharset, size_t cblength, char *cbencoding, + char *cbid, void *cbuserdata), void *userdata, int dont_decode @@ -124,6 +127,7 @@ void mime_decode(char *partnum, char *part_start, size_t length, char *content_type, char *charset, char *encoding, char *disposition, + char *id, char *name, char *filename, void (*CallBack) (char *cbname, @@ -135,6 +139,7 @@ void mime_decode(char *partnum, char *cbcharset, size_t cblength, char *cbencoding, + char *cbid, void *cbuserdata), void (*PreMultiPartCallBack) (char *cbname, @@ -146,6 +151,7 @@ void mime_decode(char *partnum, char *cbcharset, size_t cblength, char *cbencoding, + char *cbid, void *cbuserdata), void (*PostMultiPartCallBack) (char *cbname, @@ -157,6 +163,7 @@ void mime_decode(char *partnum, char *cbcharset, size_t cblength, char *cbencoding, + char *cbid, void *cbuserdata), void *userdata, int dont_decode @@ -173,6 +180,7 @@ void the_mime_parser(char *partnum, char *cbcharset, size_t cblength, char *cbencoding, + char *cbid, void *cbuserdata), void (*PreMultiPartCallBack) (char *cbname, @@ -184,6 +192,7 @@ void the_mime_parser(char *partnum, char *cbcharset, size_t cblength, char *cbencoding, + char *cbid, void *cbuserdata), void (*PostMultiPartCallBack) (char *cbname, @@ -195,6 +204,7 @@ void the_mime_parser(char *partnum, char *cbcharset, size_t cblength, char *cbencoding, + char *cbid, void *cbuserdata), void *userdata, int dont_decode diff --git a/libcitadel/lib/mime_parser.c b/libcitadel/lib/mime_parser.c index bbc255463..68f09a277 100644 --- a/libcitadel/lib/mime_parser.c +++ b/libcitadel/lib/mime_parser.c @@ -116,6 +116,7 @@ void mime_decode(char *partnum, char *part_start, size_t length, char *content_type, char *charset, char *encoding, char *disposition, + char *id, char *name, char *filename, void (*CallBack) (char *cbname, @@ -127,6 +128,7 @@ void mime_decode(char *partnum, char *cbcharset, size_t cblength, char *cbencoding, + char *cbid, void *cbuserdata), void (*PreMultiPartCallBack) (char *cbname, @@ -138,6 +140,7 @@ void mime_decode(char *partnum, char *cbcharset, size_t cblength, char *cbencoding, + char *cbid, void *cbuserdata), void (*PostMultiPartCallBack) (char *cbname, @@ -149,6 +152,7 @@ void mime_decode(char *partnum, char *cbcharset, size_t cblength, char *cbencoding, + char *cbid, void *cbuserdata), void *userdata, int dont_decode @@ -171,7 +175,7 @@ void mime_decode(char *partnum, if (CallBack != NULL) { CallBack(name, filename, fixed_partnum(partnum), disposition, part_start, - content_type, charset, length, encoding, userdata); + content_type, charset, length, encoding, id, userdata); } return; } @@ -203,7 +207,7 @@ void mime_decode(char *partnum, if (bytes_decoded > 0) if (CallBack != NULL) { CallBack(name, filename, fixed_partnum(partnum), disposition, decoded, - content_type, charset, bytes_decoded, "binary", userdata); + content_type, charset, bytes_decoded, "binary", id, userdata); } free(decoded); @@ -227,6 +231,7 @@ void the_mime_parser(char *partnum, char *cbcharset, size_t cblength, char *cbencoding, + char *cbid, void *cbuserdata), void (*PreMultiPartCallBack) (char *cbname, @@ -238,6 +243,7 @@ void the_mime_parser(char *partnum, char *cbcharset, size_t cblength, char *cbencoding, + char *cbid, void *cbuserdata), void (*PostMultiPartCallBack) (char *cbname, @@ -249,6 +255,7 @@ void the_mime_parser(char *partnum, char *cbcharset, size_t cblength, char *cbencoding, + char *cbid, void *cbuserdata), void *userdata, int dont_decode @@ -270,6 +277,7 @@ void the_mime_parser(char *partnum, size_t content_length; char *encoding; char *disposition; + char *id; char *name = NULL; char *content_type_name; char *content_disposition_name; @@ -320,6 +328,9 @@ void the_mime_parser(char *partnum, disposition = malloc(SIZ); memset(disposition, 0, SIZ); + id = malloc(SIZ); + memset(id, 0, SIZ); + /* If the caller didn't supply an endpointer, generate one by measure */ if (content_end == NULL) { content_end = &content_start[strlen(content_start)]; @@ -359,6 +370,11 @@ void the_mime_parser(char *partnum, extract_key(content_disposition_name, disposition, "name"); extract_key(filename, disposition, "filename"); } + if (!strncasecmp(header, "Content-ID:", 11)) { + strcpy(id, &header[11]); + striplt(id); + stripallbut(id, '<', '>'); + } if (!strncasecmp(header, "Content-length: ", 15)) { char clbuf[10]; safestrncpy(clbuf, &header[15], sizeof clbuf); @@ -400,7 +416,7 @@ void the_mime_parser(char *partnum, if (PreMultiPartCallBack != NULL) { PreMultiPartCallBack("", "", partnum, "", NULL, content_type, charset, - 0, encoding, userdata); + 0, encoding, id, userdata); } /* Figure out where the boundaries are */ @@ -478,7 +494,7 @@ void the_mime_parser(char *partnum, if (PostMultiPartCallBack != NULL) { PostMultiPartCallBack("", "", partnum, "", NULL, - content_type, charset, 0, encoding, userdata); + content_type, charset, 0, encoding, id, userdata); } goto end_parser; } @@ -518,7 +534,7 @@ void the_mime_parser(char *partnum, */ mime_decode(partnum, part_start, length, - content_type, charset, encoding, disposition, + content_type, charset, encoding, disposition, id, name, filename, CallBack, NULL, NULL, userdata, dont_decode @@ -532,7 +548,7 @@ void the_mime_parser(char *partnum, if (PreMultiPartCallBack != NULL) { PreMultiPartCallBack("", "", partnum, "", NULL, content_type, charset, - 0, encoding, userdata); + 0, encoding, id, userdata); } if (CallBack != NULL) { if (strlen(partnum) > 0) { @@ -557,7 +573,7 @@ void the_mime_parser(char *partnum, } if (PostMultiPartCallBack != NULL) { PostMultiPartCallBack("", "", partnum, "", NULL, - content_type, charset, 0, encoding, userdata); + content_type, charset, 0, encoding, id, userdata); } @@ -577,6 +593,7 @@ end_parser: /* free the buffers! end the oppression!! */ free(content_disposition_name); free(filename); free(disposition); + free(id); } @@ -600,6 +617,7 @@ void mime_parser(char *content_start, char *cbcharset, size_t cblength, char *cbencoding, + char *cbid, void *cbuserdata), void (*PreMultiPartCallBack) @@ -612,6 +630,7 @@ void mime_parser(char *content_start, char *cbcharset, size_t cblength, char *cbencoding, + char *cbid, void *cbuserdata), void (*PostMultiPartCallBack) @@ -624,6 +643,7 @@ void mime_parser(char *content_start, char *cbcharset, size_t cblength, char *cbencoding, + char *cbid, void *cbuserdata), void *userdata, diff --git a/webcit/groupdav_get.c b/webcit/groupdav_get.c index 928a5669b..40b62d72c 100644 --- a/webcit/groupdav_get.c +++ b/webcit/groupdav_get.c @@ -46,7 +46,7 @@ void groupdav_get_big_ics(void) { */ void extract_preferred(char *name, char *filename, char *partnum, char *disp, void *content, char *cbtype, char *cbcharset, - size_t length, char *encoding, void *userdata) + size_t length, char *encoding, char *cbid, void *userdata) { struct epdata *epdata = (struct epdata *)userdata; int hit = 0; diff --git a/webcit/webcit.c b/webcit/webcit.c index e03a81545..51105a76b 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -1147,11 +1147,12 @@ void authorization_required(const char *message) * cbcharset Character set * length Content length * encoding MIME encoding type (not needed) + * cbid Content ID (not needed) * userdata Not used here */ void upload_handler(char *name, char *filename, char *partnum, char *disp, void *content, char *cbtype, char *cbcharset, - size_t length, char *encoding, void *userdata) + size_t length, char *encoding, char *cbid, void *userdata) { urlcontent *u; #ifdef DEBUG_URLSTRINGS diff --git a/webcit/webcit.h b/webcit/webcit.h index ebb565fc8..220c68f7d 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -107,9 +107,9 @@ extern locale_t wc_locales[]; #define PORT_NUM 2000 /* port number to listen on */ #define DEVELOPER_ID 0 #define CLIENT_ID 4 -#define CLIENT_VERSION 737 /* This version of WebCit */ -#define MINIMUM_CIT_VERSION 737 /* min required Citadel ver */ -#define LIBCITADEL_MIN 738 /* min required libcitadel ver */ +#define CLIENT_VERSION 739 /* This version of WebCit */ +#define MINIMUM_CIT_VERSION 739 /* min required Citadel ver */ +#define LIBCITADEL_MIN 739 /* min required libcitadel ver */ #define DEFAULT_HOST "localhost" /* Default Citadel server */ #define DEFAULT_PORT "504" #define TARGET "webcit01" /* Target for inline URL's */ -- 2.30.2