From: Wilfried Goesgens Date: Tue, 1 Oct 2013 07:57:33 +0000 (+0200) Subject: Put our known stringlength into the mime parser so it doesn't need to strlen again. X-Git-Tag: v9.01~229 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=72cf2e7f757fd0d4e977be9154222be3af77b59c Put our known stringlength into the mime parser so it doesn't need to strlen again. --- diff --git a/citadel/modules/calendar/serv_calendar.c b/citadel/modules/calendar/serv_calendar.c index 8d3fe42cb..414f9caae 100644 --- a/citadel/modules/calendar/serv_calendar.c +++ b/citadel/modules/calendar/serv_calendar.c @@ -386,12 +386,11 @@ void ical_respond(long msgnum, char *partnum, char *action) { memset(&ird, 0, sizeof ird); strcpy(ird.desired_partnum, partnum); - mime_parser(msg->cm_fields[eMesageText], - NULL, - *ical_locate_part, /* callback function */ - NULL, NULL, - (void *) &ird, /* user data */ - 0 + mime_parser(CM_RANGE(msg, eMesageText), + *ical_locate_part, /* callback function */ + NULL, NULL, + (void *) &ird, /* user data */ + 0 ); /* We're done with the incoming message, because we now have a @@ -642,12 +641,11 @@ int ical_update_my_calendar_with_reply(icalcomponent *cal) { return(2); /* internal error */ } oec.c = NULL; - mime_parser(msg->cm_fields[eMesageText], - NULL, - *ical_locate_original_event, /* callback function */ - NULL, NULL, - &oec, /* user data */ - 0 + mime_parser(CM_RANGE(msg, eMesageText), + *ical_locate_original_event, /* callback function */ + NULL, NULL, + &oec, /* user data */ + 0 ); CM_Free(msg); @@ -729,13 +727,12 @@ void ical_handle_rsvp(long msgnum, char *partnum, char *action) { memset(&ird, 0, sizeof ird); strcpy(ird.desired_partnum, partnum); - mime_parser(msg->cm_fields[eMesageText], - NULL, - *ical_locate_part, /* callback function */ - NULL, NULL, - (void *) &ird, /* user data */ - 0 - ); + mime_parser(CM_RANGE(msg, eMesageText), + *ical_locate_part, /* callback function */ + NULL, NULL, + (void *) &ird, /* user data */ + 0 + ); /* We're done with the incoming message, because we now have a * calendar object in memory. @@ -1161,12 +1158,11 @@ void ical_hunt_for_conflicts_backend(long msgnum, void *data) { if (msg == NULL) return; memset(&ird, 0, sizeof ird); strcpy(ird.desired_partnum, "_HUNT_"); - mime_parser(msg->cm_fields[eMesageText], - NULL, - *ical_locate_part, /* callback function */ - NULL, NULL, - (void *) &ird, /* user data */ - 0 + mime_parser(CM_RANGE(msg, eMesageText), + *ical_locate_part, /* callback function */ + NULL, NULL, + (void *) &ird, /* user data */ + 0 ); CM_Free(msg); @@ -1230,13 +1226,12 @@ void ical_conflicts(long msgnum, char *partnum) { memset(&ird, 0, sizeof ird); strcpy(ird.desired_partnum, partnum); - mime_parser(msg->cm_fields[eMesageText], - NULL, - *ical_locate_part, /* callback function */ - NULL, NULL, - (void *) &ird, /* user data */ - 0 - ); + mime_parser(CM_RANGE(msg, eMesageText), + *ical_locate_part, /* callback function */ + NULL, NULL, + (void *) &ird, /* user data */ + 0 + ); CM_Free(msg); @@ -1411,13 +1406,12 @@ void ical_freebusy_backend(long msgnum, void *data) { if (msg == NULL) return; memset(&ird, 0, sizeof ird); strcpy(ird.desired_partnum, "_HUNT_"); - mime_parser(msg->cm_fields[eMesageText], - NULL, - *ical_locate_part, /* callback function */ - NULL, NULL, - (void *) &ird, /* user data */ - 0 - ); + mime_parser(CM_RANGE(msg, eMesageText), + *ical_locate_part, /* callback function */ + NULL, NULL, + (void *) &ird, /* user data */ + 0 + ); CM_Free(msg); if (ird.cal) { @@ -1612,12 +1606,11 @@ void ical_getics_backend(long msgnum, void *data) { if (msg == NULL) return; memset(&ird, 0, sizeof ird); strcpy(ird.desired_partnum, "_HUNT_"); - mime_parser(msg->cm_fields[eMesageText], - NULL, - *ical_locate_part, /* callback function */ - NULL, NULL, - (void *) &ird, /* user data */ - 0 + mime_parser(CM_RANGE(msg, eMesageText), + *ical_locate_part, /* callback function */ + NULL, NULL, + (void *) &ird, /* user data */ + 0 ); CM_Free(msg); @@ -2413,13 +2406,12 @@ int ical_obj_beforesave(struct CtdlMessage *msg, recptypes *recp) } /* Do all of our lovely back-end parsing */ - mime_parser(msg->cm_fields[eMesageText], - NULL, - *ical_obj_beforesave_backend, - NULL, NULL, - (void *)msg, - 0 - ); + mime_parser(CM_RANGE(msg, eMesageText), + *ical_obj_beforesave_backend, + NULL, NULL, + (void *)msg, + 0 + ); return(0); } @@ -2482,13 +2474,12 @@ int ical_obj_aftersave(struct CtdlMessage *msg, recptypes *recp) if (CM_IsEmpty(msg, eMesageText)) return(1); /* Now recurse through it looking for our icalendar data */ - mime_parser(msg->cm_fields[eMesageText], - NULL, - *ical_obj_aftersave_backend, - NULL, NULL, - NULL, - 0 - ); + mime_parser(CM_RANGE(msg, eMesageText), + *ical_obj_aftersave_backend, + NULL, NULL, + NULL, + 0 + ); return(0); } diff --git a/citadel/modules/imap/imap_fetch.c b/citadel/modules/imap/imap_fetch.c index f99989371..f010b37dc 100644 --- a/citadel/modules/imap/imap_fetch.c +++ b/citadel/modules/imap/imap_fetch.c @@ -752,7 +752,7 @@ void imap_fetch_body(long msgnum, ConstStr item, int is_peek) { * (Note value of 1 passed as 'dont_decode' so client gets it encoded) */ else { - mime_parser(msg->cm_fields[eMesageText], NULL, + mime_parser(CM_RANGE(msg, eMesageText), *imap_load_part, NULL, NULL, section, 1 @@ -1017,13 +1017,12 @@ void imap_fetch_bodystructure (long msgnum, const char *item, /* For messages already stored in RFC822 format, we have to parse. */ IAPuts("BODYSTRUCTURE "); - mime_parser(msg->cm_fields[eMesageText], - NULL, - *imap_fetch_bodystructure_part, /* part */ - *imap_fetch_bodystructure_pre, /* pre-multi */ - *imap_fetch_bodystructure_post, /* post-multi */ - NULL, - 1); /* don't decode -- we want it as-is */ + mime_parser(CM_RANGE(msg, eMesageText), + *imap_fetch_bodystructure_part, /* part */ + *imap_fetch_bodystructure_pre, /* pre-multi */ + *imap_fetch_bodystructure_post, /* post-multi */ + NULL, + 1); /* don't decode -- we want it as-is */ } diff --git a/citadel/modules/notes/serv_notes.c b/citadel/modules/notes/serv_notes.c index a250c8ccd..cb21be03d 100644 --- a/citadel/modules/notes/serv_notes.c +++ b/citadel/modules/notes/serv_notes.c @@ -130,12 +130,11 @@ int serv_notes_beforesave(struct CtdlMessage *msg, recptypes *recp) /* Modern clients are using vNote format. Check for one... */ - mime_parser(msg->cm_fields[eMesageText], - NULL, - *notes_extract_vnote, - NULL, NULL, - &v, /* user data ptr - put the vnote here */ - 0 + mime_parser(CM_RANGE(msg, eMesageText), + *notes_extract_vnote, + NULL, NULL, + &v, /* user data ptr - put the vnote here */ + 0 ); if (v == NULL) return(0); /* no vNotes were found in this message */ diff --git a/citadel/modules/vcard/serv_vcard.c b/citadel/modules/vcard/serv_vcard.c index 3d62c83d0..2722b3bca 100644 --- a/citadel/modules/vcard/serv_vcard.c +++ b/citadel/modules/vcard/serv_vcard.c @@ -375,12 +375,11 @@ int vcard_upload_beforesave(struct CtdlMessage *msg, recptypes *recp) { if (CM_IsEmpty(msg, eMesageText)) return(0); - mime_parser(msg->cm_fields[eMesageText], - NULL, - *vcard_extract_vcard, - NULL, NULL, - &v, /* user data ptr - put the vcard here */ - 0 + mime_parser(CM_RANGE(msg, eMesageText), + *vcard_extract_vcard, + NULL, NULL, + &v, /* user data ptr - put the vcard here */ + 0 ); if (v == NULL) return(0); /* no vCards were found in this message */ @@ -1107,13 +1106,12 @@ void dvca_callback(long msgnum, void *userdata) { msg = CtdlFetchMessage(msgnum, 1); if (msg == NULL) return; - mime_parser(msg->cm_fields[eMesageText], - NULL, - *dvca_mime_callback, /* callback function */ - NULL, NULL, - NULL, /* user data */ - 0 - ); + mime_parser(CM_RANGE(msg, eMesageText), + *dvca_mime_callback, /* callback function */ + NULL, NULL, + NULL, /* user data */ + 0 + ); CM_Free(msg); } diff --git a/citadel/modules/wiki/serv_wiki.c b/citadel/modules/wiki/serv_wiki.c index ccfc77b7e..36e010b37 100644 --- a/citadel/modules/wiki/serv_wiki.c +++ b/citadel/modules/wiki/serv_wiki.c @@ -407,7 +407,7 @@ void wiki_history(char *pagename) { cprintf("%d Revision history for '%s'\n", LISTING_FOLLOWS, pagename); - mime_parser(msg->cm_fields[eMesageText], NULL, *wiki_history_callback, NULL, NULL, NULL, 0); + mime_parser(CM_RANGE(msg, eMesageText), *wiki_history_callback, NULL, NULL, NULL, 0); cprintf("000\n"); CM_Free(msg); @@ -580,7 +580,7 @@ void wiki_rev(char *pagename, char *rev, char *operation) hecbd.stop_when = rev; striplt(hecbd.stop_when); - mime_parser(msg->cm_fields[eMesageText], NULL, *wiki_rev_callback, NULL, NULL, (void *)&hecbd, 0); + mime_parser(CM_RANGE(msg, eMesageText), *wiki_rev_callback, NULL, NULL, (void *)&hecbd, 0); CM_Free(msg); /* Were we successful? */ diff --git a/citadel/msgbase.c b/citadel/msgbase.c index d1270f4d1..57eb0d213 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -1584,11 +1584,10 @@ int CtdlOutputMsg(long msg_num, /* message number (local) to fetch */ if (section) if (!IsEmptyStr(section)) if (strcmp(section, "0")) { memset(&encap, 0, sizeof encap); safestrncpy(encap.desired_section, section, sizeof encap.desired_section); - mime_parser(TheMessage->cm_fields[eMesageText], - NULL, - *extract_encapsulated_message, - NULL, NULL, (void *)&encap, 0 - ); + mime_parser(CM_RANGE(TheMessage, eMesageText), + *extract_encapsulated_message, + NULL, NULL, (void *)&encap, 0 + ); if ((Author != NULL) && (*Author == NULL)) { @@ -2004,7 +2003,6 @@ int CtdlOutputPreLoadedMsg( ) { struct CitContext *CCC = CC; int i; - char *mptr = NULL; const char *nl; /* newline string */ struct ma_info ma; @@ -2051,8 +2049,8 @@ int CtdlOutputPreLoadedMsg( ERROR + RESOURCE_BUSY); } else { /* Parse the message text component */ - mptr = TheMessage->cm_fields[eMesageText]; - mime_parser(mptr, NULL, *mime_download, NULL, NULL, NULL, 0); + mime_parser(CM_RANGE(TheMessage, eMesageText), + *mime_download, NULL, NULL, NULL, 0); /* If there's no file open by this time, the requested * section wasn't found, so print an error */ @@ -2078,8 +2076,8 @@ int CtdlOutputPreLoadedMsg( /* Parse the message text component */ int found_it = 0; - mptr = TheMessage->cm_fields[eMesageText]; - mime_parser(mptr, NULL, *mime_spew_section, NULL, NULL, (void *)&found_it, 0); + mime_parser(CM_RANGE(TheMessage, eMesageText), + *mime_spew_section, NULL, NULL, (void *)&found_it, 0); /* If section wasn't found, print an error */ if (!found_it) { @@ -2176,9 +2174,8 @@ START_TEXT: /* Tell the client about the MIME parts in this message */ if (TheMessage->cm_format_type == FMT_RFC822) { if ( (mode == MT_CITADEL) || (mode == MT_MIME) ) { - mptr = TheMessage->cm_fields[eMesageText]; memset(&ma, 0, sizeof(struct ma_info)); - mime_parser(mptr, NULL, + mime_parser(CM_RANGE(TheMessage, eMesageText), (do_proto ? *list_this_part : NULL), (do_proto ? *list_this_pref : NULL), (do_proto ? *list_this_suff : NULL), @@ -2217,12 +2214,10 @@ START_TEXT: * message to the reader's screen width. */ if (TheMessage->cm_format_type == FMT_CITADEL) { - mptr = TheMessage->cm_fields[eMesageText]; - if (mode == MT_MIME) { cprintf("Content-type: text/x-citadel-variformat\n\n"); } - memfmout(mptr, nl); + memfmout(TheMessage->cm_fields[eMesageText], nl); } /* If the message on disk is format 4 (MIME), we've gotta hand it @@ -2238,17 +2233,17 @@ START_TEXT: strcpy(ma.chosen_part, "1"); ma.chosen_pref = 9999; ma.dont_decode = CCC->msg4_dont_decode; - mime_parser(mptr, NULL, - *choose_preferred, *fixed_output_pre, - *fixed_output_post, (void *)&ma, 1); - mime_parser(mptr, NULL, - *output_preferred, NULL, NULL, (void *)&ma, 1); + mime_parser(CM_RANGE(TheMessage, eMesageText), + *choose_preferred, *fixed_output_pre, + *fixed_output_post, (void *)&ma, 1); + mime_parser(CM_RANGE(TheMessage, eMesageText), + *output_preferred, NULL, NULL, (void *)&ma, 1); } else { ma.use_fo_hooks = 1; - mime_parser(mptr, NULL, - *fixed_output, *fixed_output_pre, - *fixed_output_post, (void *)&ma, 0); + mime_parser(CM_RANGE(TheMessage, eMesageText), + *fixed_output, *fixed_output_pre, + *fixed_output_post, (void *)&ma, 0); } } diff --git a/citadel/msgbase.h b/citadel/msgbase.h index a9a4eaba4..aecdb18f6 100644 --- a/citadel/msgbase.h +++ b/citadel/msgbase.h @@ -146,6 +146,8 @@ void CM_FreeContents (struct CtdlMessage *msg); int CM_IsValidMsg (struct CtdlMessage *msg); #define CM_KEY(Message, Which) Message->cm_fields[Which], Message->cm_lengths[Which] +#define CM_RANGE(Message, Which) Message->cm_fields[Which], \ + Message->cm_fields[Which] + Message->cm_lengths[Which] void CtdlSerializeMessage(struct ser_ret *, struct CtdlMessage *); void ReplicationChecks(struct CtdlMessage *);