diff --git a/mozilla/mailnews/mime/cthandlers/calendar/mimecal.cpp b/mozilla/mailnews/mime/cthandlers/calendar/mimecal.cpp index 07efd470502..72e759974c9 100644 --- a/mozilla/mailnews/mime/cthandlers/calendar/mimecal.cpp +++ b/mozilla/mailnews/mime/cthandlers/calendar/mimecal.cpp @@ -34,13 +34,13 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + #include "mimecal.h" #include "prmem.h" #include "plstr.h" #include "mimexpcom.h" #include "mimecth.h" #include "mimeobj.h" -#include "nsCRT.h" static int MimeInlineTextCalendar_parse_line (char *, PRInt32, MimeObject *); static int MimeInlineTextCalendar_parse_eof (MimeObject *, PRBool); @@ -84,7 +84,7 @@ MimeInlineTextCalendarClassInitialize(MimeInlineTextCalendarClass *clazz) int mime_TranslateCalendar(char* caldata, char** html) { - *html = nsCRT::strdup("\ + *html = strdup("\ \
\
This libmime Content Type Handler plugin for the Content-Type text/calendar\ diff --git a/mozilla/mailnews/mime/cthandlers/glue/nsMimeContentTypeHandler.cpp b/mozilla/mailnews/mime/cthandlers/glue/nsMimeContentTypeHandler.cpp index 216c40076ac..45812565a8d 100644 --- a/mozilla/mailnews/mime/cthandlers/glue/nsMimeContentTypeHandler.cpp +++ b/mozilla/mailnews/mime/cthandlers/glue/nsMimeContentTypeHandler.cpp @@ -41,11 +41,10 @@ #include "prtypes.h" //#include "mimecth.h" #include "nsMimeContentTypeHandler.h" -#include "nsCRT.h" -/* - * The following macros actually implement addref, release and - * query interface for our component. +/* + * The following macros actually implement addref, release and + * query interface for our component. */ NS_IMPL_ISUPPORTS1(nsMimeContentTypeHandler, nsIMimeContentTypeHandler) @@ -80,8 +79,8 @@ nsMimeContentTypeHandler::GetContentType(char **contentType) // Set the output stream for processed data. nsresult -nsMimeContentTypeHandler::CreateContentTypeHandlerClass(const char *content_type, - contentTypeHandlerInitStruct *initStruct, +nsMimeContentTypeHandler::CreateContentTypeHandlerClass(const char *content_type, + contentTypeHandlerInitStruct *initStruct, MimeObjectClass **objClass) { *objClass = realCreateContentTypeHandlerClass(content_type, initStruct); diff --git a/mozilla/mailnews/mime/cthandlers/smimestub/nsSMIMEStub.cpp b/mozilla/mailnews/mime/cthandlers/smimestub/nsSMIMEStub.cpp index 09c08f8aba8..499164c9e37 100644 --- a/mozilla/mailnews/mime/cthandlers/smimestub/nsSMIMEStub.cpp +++ b/mozilla/mailnews/mime/cthandlers/smimestub/nsSMIMEStub.cpp @@ -41,7 +41,6 @@ #include "mimexpcom.h" #include "mimecth.h" #include "mimeobj.h" -#include "nsCRT.h" #include "nsReadableUtils.h" // String bundles... @@ -57,64 +56,61 @@ static nsCOMPtr stringBundle = nsnull; static char *SMimeGetStringByID(PRInt32 aMsgId) { char *tempString = nsnull; - nsresult res = NS_OK; + nsresult res = NS_OK; #ifdef XP_MAC -nsCOMPtr stringBundle = nsnull; + nsCOMPtr stringBundle = nsnull; #endif - if (!stringBundle) - { - static const char propertyURL[] = SMIME_PROPERTIES_URL; + if (!stringBundle) + { + static const char propertyURL[] = SMIME_PROPERTIES_URL; - nsCOMPtr sBundleService = - do_GetService(NS_STRINGBUNDLE_CONTRACTID, &res); - if (NS_SUCCEEDED(res) && (nsnull != sBundleService)) - { - res = sBundleService->CreateBundle(propertyURL, getter_AddRefs(stringBundle)); - } - } + nsCOMPtr sBundleService = + do_GetService(NS_STRINGBUNDLE_CONTRACTID, &res); + if (NS_SUCCEEDED(res) && (nsnull != sBundleService)) + { + res = sBundleService->CreateBundle(propertyURL, getter_AddRefs(stringBundle)); + } + } - if (stringBundle) - { - PRUnichar *ptrv = nsnull; - res = stringBundle->GetStringFromID(aMsgId, &ptrv); + if (stringBundle) + { + PRUnichar *ptrv = nsnull; + res = stringBundle->GetStringFromID(aMsgId, &ptrv); - if (NS_FAILED(res)) - return nsCRT::strdup("???"); - else + if (NS_FAILED(res)) + return strdup("???"); + else { nsAutoString v; v.Append(ptrv); - PR_FREEIF(ptrv); + PR_FREEIF(ptrv); tempString = ToNewUTF8String(v); } - } + } if (!tempString) - return nsCRT::strdup("???"); + return strdup("???"); else return tempString; } - - - static int MimeInlineTextSMIMEStub_parse_line (const char *, PRInt32, MimeObject *); static int MimeInlineTextSMIMEStub_parse_eof (MimeObject *, PRBool); static int MimeInlineTextSMIMEStub_parse_begin (MimeObject *obj); - /* This is the object definition. Note: we will set the superclass + /* This is the object definition. Note: we will set the superclass to NULL and manually set this on the class creation */ -MimeDefClass(MimeInlineTextSMIMEStub, MimeInlineTextSMIMEStubClass, mimeInlineTextSMIMEStubClass, NULL); +MimeDefClass(MimeInlineTextSMIMEStub, MimeInlineTextSMIMEStubClass, mimeInlineTextSMIMEStubClass, NULL); extern "C" MimeObjectClass * -MIME_SMimeCreateContentTypeHandlerClass(const char *content_type, +MIME_SMimeCreateContentTypeHandlerClass(const char *content_type, contentTypeHandlerInitStruct *initStruct) { MimeObjectClass *clazz = (MimeObjectClass *)&mimeInlineTextSMIMEStubClass; - /* + /* * Must set the superclass by hand. */ if (!COM_GetmimeInlineTextClass()) @@ -138,7 +134,7 @@ MimeInlineTextSMIMEStubClassInitialize(MimeInlineTextSMIMEStubClass *clazz) } int -GenerateMessage(char** html) +GenerateMessage(char** html) { nsCString temp; temp.Append("
"); @@ -158,16 +154,16 @@ MimeInlineTextSMIMEStub_parse_begin(MimeObject *obj) { MimeInlineTextSMIMEStubClass *clazz; int status = ((MimeObjectClass*)COM_GetmimeLeafClass())->parse_begin(obj); - - if (status < 0) + + if (status < 0) return status; - - if (!obj->output_p) + + if (!obj->output_p) return 0; - if (!obj->options || !obj->options->write_html_p) + if (!obj->options || !obj->options->write_html_p) return 0; - - /* This is a fine place to write out any HTML before the real meat begins. */ + + /* This is a fine place to write out any HTML before the real meat begins. */ // Initialize the clazz variable... clazz = ((MimeInlineTextSMIMEStubClass *) obj->clazz); @@ -177,20 +173,20 @@ MimeInlineTextSMIMEStub_parse_begin(MimeObject *obj) static int MimeInlineTextSMIMEStub_parse_line(const char *line, PRInt32 length, MimeObject *obj) { - /* + /* * This routine gets fed each line of data, one at a time. We just buffer - * it all up, to be dealt with all at once at the end. - */ - if (!obj->output_p) + * it all up, to be dealt with all at once at the end. + */ + if (!obj->output_p) return 0; - if (!obj->options || !obj->options->output_fn) + if (!obj->options || !obj->options->output_fn) return 0; - if (!obj->options->write_html_p) + if (!obj->options->write_html_p) { return COM_MimeObject_write(obj, line, length, PR_TRUE); } - + return 0; } @@ -199,28 +195,28 @@ MimeInlineTextSMIMEStub_parse_eof (MimeObject *obj, PRBool abort_p) { int status = 0; char* html = NULL; - + if (obj->closed_p) return 0; /* Run parent method first, to flush out any buffered data. */ status = ((MimeObjectClass*)COM_GetmimeInlineTextClass())->parse_eof(obj, abort_p); - if (status < 0) + if (status < 0) return status; - if ( (obj->options) && + if ( (obj->options) && ((obj->options->format_out == nsMimeOutput::nsMimeMessageQuoting) || (obj->options->format_out == nsMimeOutput::nsMimeMessageBodyQuoting)) ) return 0; status = GenerateMessage(&html); - if (status < 0) + if (status < 0) return status; - + status = COM_MimeObject_write(obj, html, PL_strlen(html), PR_TRUE); PR_FREEIF(html); - if (status < 0) + if (status < 0) return status; - + return 0; } diff --git a/mozilla/mailnews/mime/cthandlers/vcard/mimevcrd.cpp b/mozilla/mailnews/mime/cthandlers/vcard/mimevcrd.cpp index d929cb5ef79..a85ebe0ad1e 100644 --- a/mozilla/mailnews/mime/cthandlers/vcard/mimevcrd.cpp +++ b/mozilla/mailnews/mime/cthandlers/vcard/mimevcrd.cpp @@ -58,7 +58,6 @@ #include "nsIStringBundle.h" #include "nsVCardStringResources.h" -#include "nsCRT.h" #include "prprf.h" // String bundles... @@ -209,12 +208,12 @@ static PRInt32 INTL_ConvertCharset(const char* from_charset, const char* to_char return -1; // from to identical - if (!nsCRT::strcasecmp(from_charset, to_charset)) + if (!PL_strcasecmp(from_charset, to_charset)) return -1; // us-ascii is a subset of utf-8 - if ((!nsCRT::strcasecmp(from_charset, "us-ascii") && !nsCRT::strcasecmp(to_charset, "UTF-8")) || - (!nsCRT::strcasecmp(from_charset, "UTF-8") && !nsCRT::strcasecmp(to_charset, "us-ascii"))) + if ((!PL_strcasecmp(from_charset, "us-ascii") && !PL_strcasecmp(to_charset, "UTF-8")) || + (!PL_strcasecmp(from_charset, "UTF-8") && !PL_strcasecmp(to_charset, "us-ascii"))) return -1; @@ -224,7 +223,7 @@ static PRInt32 INTL_ConvertCharset(const char* from_charset, const char* to_char // known bug in 4.x, it mixes Shift_JIS (or EUC-JP) and ISO-2022-JP in vCard fields if (NS_ERROR_MODULE_UCONV == NS_ERROR_GET_MODULE(res)) { - if (!nsCRT::strcasecmp("ISO-2022-JP", from_charset)) { + if (!PL_strcasecmp("ISO-2022-JP", from_charset)) { res = ConvertToUnicode("Shift_JIS", inBuffer, outString); if (NS_ERROR_MODULE_UCONV == NS_ERROR_GET_MODULE(res)) { res = ConvertToUnicode("EUC-JP", inBuffer, outString); @@ -860,7 +859,7 @@ static int OutputAdvancedVcard(MimeObject *obj, VObject *v) { namestring = vCardService->FakeCString(prop); if (namestring) - if (nsCRT::strcasecmp (namestring, "TRUE") == 0) + if (PL_strcasecmp (namestring, "TRUE") == 0) { PR_FREEIF (namestring); status = OutputFont(obj, PR_FALSE, "-1", NULL); @@ -939,16 +938,16 @@ static int OutputAdvancedVcard(MimeObject *obj, VObject *v) { namestring = vCardService->FakeCString(prop2); char *tString1 = NULL; - if (nsCRT::strcmp (namestring, "0") == 0) + if (strcmp (namestring, "0") == 0) { tString1 = VCardGetStringByID(VCARD_ADDR_DEFAULT_DLS); } else { - if (nsCRT::strcmp (namestring, "1") == 0) + if (strcmp (namestring, "1") == 0) tString1 = VCardGetStringByID(VCARD_ADDR_SPECIFIC_DLS); else - if (nsCRT::strcmp (namestring, "2") == 0) + if (strcmp (namestring, "2") == 0) tString1 = VCardGetStringByID(VCARD_ADDR_HOSTNAMEIP); } @@ -1459,7 +1458,7 @@ static int WriteOutEachVCardPhoneProperty (MimeObject *obj, VObject* o) if (vCardService->VObjectName(o)) { - if (nsCRT::strcasecmp (VCTelephoneProp, vCardService->VObjectName(o)) == 0) + if (PL_strcasecmp (VCTelephoneProp, vCardService->VObjectName(o)) == 0) { if (VALUE_TYPE(o)) { @@ -1546,7 +1545,7 @@ static int WriteOutEachVCardProperty (MimeObject *obj, VObject* o, int* numEmail if (vCardService->VObjectName(o)) { - if (nsCRT::strcasecmp (VCPhotoProp, vCardService->VObjectName(o)) == 0) { + if (PL_strcasecmp (VCPhotoProp, vCardService->VObjectName(o)) == 0) { VObject* urlProp = vCardService->IsAPropertyOf(o, VCURLProp); if (urlProp) { attribName = VCardGetStringByID(VCARD_LDAP_PHOTOGRAPH); @@ -1560,7 +1559,7 @@ static int WriteOutEachVCardProperty (MimeObject *obj, VObject* o, int* numEmail } } - if (nsCRT::strcasecmp (VCBirthDateProp, vCardService->VObjectName(o)) == 0) { + if (PL_strcasecmp (VCBirthDateProp, vCardService->VObjectName(o)) == 0) { if (VALUE_TYPE(o)) { attribName = VCardGetStringByID(VCARD_LDAP_BIRTHDAY); value = vCardService->FakeCString(o); @@ -1568,14 +1567,14 @@ static int WriteOutEachVCardProperty (MimeObject *obj, VObject* o, int* numEmail } } - if (nsCRT::strcasecmp (VCDeliveryLabelProp, vCardService->VObjectName(o)) == 0) { + if (PL_strcasecmp (VCDeliveryLabelProp, vCardService->VObjectName(o)) == 0) { attribName = VCardGetStringByID(VCARD_LDAP_LABEL); GetAddressProperties(o, &attribName); value = vCardService->FakeCString(o); goto DOWRITE; } - if (nsCRT::strcasecmp (VCEmailAddressProp, vCardService->VObjectName(o)) == 0) { + if (PL_strcasecmp (VCEmailAddressProp, vCardService->VObjectName(o)) == 0) { if ((*numEmail) != 1) { if (VALUE_TYPE(o)) { @@ -1588,7 +1587,7 @@ static int WriteOutEachVCardProperty (MimeObject *obj, VObject* o, int* numEmail } } - if (nsCRT::strcasecmp (VCFamilyNameProp, vCardService->VObjectName(o)) == 0) { + if (PL_strcasecmp (VCFamilyNameProp, vCardService->VObjectName(o)) == 0) { if (VALUE_TYPE(o)) { attribName = VCardGetStringByID(VCARD_LDAP_SURNAME); value = vCardService->FakeCString(o); @@ -1596,7 +1595,7 @@ static int WriteOutEachVCardProperty (MimeObject *obj, VObject* o, int* numEmail } } - if (nsCRT::strcasecmp (VCGivenNameProp, vCardService->VObjectName(o)) == 0) { + if (PL_strcasecmp (VCGivenNameProp, vCardService->VObjectName(o)) == 0) { if (VALUE_TYPE(o)) { attribName = VCardGetStringByID(VCARD_LDAP_GIVEN_NAME); value = vCardService->FakeCString(o); @@ -1604,7 +1603,7 @@ static int WriteOutEachVCardProperty (MimeObject *obj, VObject* o, int* numEmail } } - if (nsCRT::strcasecmp (VCNamePrefixesProp, vCardService->VObjectName(o)) == 0) { + if (PL_strcasecmp (VCNamePrefixesProp, vCardService->VObjectName(o)) == 0) { if (VALUE_TYPE(o)) { attribName = VCardGetStringByID(VCARD_LDAP_NAME_PREFIX); value = vCardService->FakeCString(o); @@ -1612,7 +1611,7 @@ static int WriteOutEachVCardProperty (MimeObject *obj, VObject* o, int* numEmail } } - if (nsCRT::strcasecmp (VCNameSuffixesProp, vCardService->VObjectName(o)) == 0) { + if (PL_strcasecmp (VCNameSuffixesProp, vCardService->VObjectName(o)) == 0) { if (VALUE_TYPE(o)) { attribName = VCardGetStringByID(VCARD_LDAP_NAME_SUFFIX); value = vCardService->FakeCString(o); @@ -1620,7 +1619,7 @@ static int WriteOutEachVCardProperty (MimeObject *obj, VObject* o, int* numEmail } } - if (nsCRT::strcasecmp (VCAdditionalNamesProp, vCardService->VObjectName(o)) == 0) { + if (PL_strcasecmp (VCAdditionalNamesProp, vCardService->VObjectName(o)) == 0) { if (VALUE_TYPE(o)) { attribName = VCardGetStringByID(VCARD_LDAP_MIDDLE_NAME); value = vCardService->FakeCString(o); @@ -1628,7 +1627,7 @@ static int WriteOutEachVCardProperty (MimeObject *obj, VObject* o, int* numEmail } } - if (nsCRT::strcasecmp (VCMailerProp, vCardService->VObjectName(o)) == 0) { + if (PL_strcasecmp (VCMailerProp, vCardService->VObjectName(o)) == 0) { if (VALUE_TYPE(o)) { attribName = VCardGetStringByID(VCARD_LDAP_MAILER); value = vCardService->FakeCString(o); @@ -1636,7 +1635,7 @@ static int WriteOutEachVCardProperty (MimeObject *obj, VObject* o, int* numEmail } } - if (nsCRT::strcasecmp (VCTimeZoneProp, vCardService->VObjectName(o)) == 0) { + if (PL_strcasecmp (VCTimeZoneProp, vCardService->VObjectName(o)) == 0) { if (VALUE_TYPE(o)) { attribName = VCardGetStringByID(VCARD_LDAP_TZ); value = vCardService->FakeCString(o); @@ -1644,7 +1643,7 @@ static int WriteOutEachVCardProperty (MimeObject *obj, VObject* o, int* numEmail } } - if (nsCRT::strcasecmp (VCGeoProp, vCardService->VObjectName(o)) == 0) { + if (PL_strcasecmp (VCGeoProp, vCardService->VObjectName(o)) == 0) { if (VALUE_TYPE(o)) { attribName = VCardGetStringByID(VCARD_LDAP_GEO); value = vCardService->FakeCString(o); @@ -1652,7 +1651,7 @@ static int WriteOutEachVCardProperty (MimeObject *obj, VObject* o, int* numEmail } } - if (nsCRT::strcasecmp (VCBusinessRoleProp, vCardService->VObjectName(o)) == 0) { + if (PL_strcasecmp (VCBusinessRoleProp, vCardService->VObjectName(o)) == 0) { if (VALUE_TYPE(o)) { attribName = VCardGetStringByID(VCARD_LDAP_ROLE); value = vCardService->FakeCString(o); @@ -1660,7 +1659,7 @@ static int WriteOutEachVCardProperty (MimeObject *obj, VObject* o, int* numEmail } } - if (nsCRT::strcasecmp (VCLogoProp, vCardService->VObjectName(o)) == 0) { + if (PL_strcasecmp (VCLogoProp, vCardService->VObjectName(o)) == 0) { VObject* urlProp = vCardService->IsAPropertyOf(o, VCURLProp); if (urlProp) { attribName = VCardGetStringByID(VCARD_LDAP_LOGO); @@ -1673,12 +1672,12 @@ static int WriteOutEachVCardProperty (MimeObject *obj, VObject* o, int* numEmail } } - if (nsCRT::strcasecmp (VCAgentProp, vCardService->VObjectName(o)) == 0) { + if (PL_strcasecmp (VCAgentProp, vCardService->VObjectName(o)) == 0) { attribName = VCardGetStringByID(VCARD_LDAP_SECRETARY); goto DOWRITE; } - if (nsCRT::strcasecmp (VCLastRevisedProp, vCardService->VObjectName(o)) == 0) { + if (PL_strcasecmp (VCLastRevisedProp, vCardService->VObjectName(o)) == 0) { if (VALUE_TYPE(o)) { attribName = VCardGetStringByID(VCARD_LDAP_REVISION); value = vCardService->FakeCString(o); @@ -1686,7 +1685,7 @@ static int WriteOutEachVCardProperty (MimeObject *obj, VObject* o, int* numEmail } } - if (nsCRT::strcasecmp (VCPronunciationProp, vCardService->VObjectName(o)) == 0) { + if (PL_strcasecmp (VCPronunciationProp, vCardService->VObjectName(o)) == 0) { if (VALUE_TYPE(o)) { attribName = VCardGetStringByID(VCARD_LDAP_SOUND); value = vCardService->FakeCString(o); @@ -1695,7 +1694,7 @@ static int WriteOutEachVCardProperty (MimeObject *obj, VObject* o, int* numEmail } - if (nsCRT::strcasecmp (VCVersionProp, vCardService->VObjectName(o)) == 0) { + if (PL_strcasecmp (VCVersionProp, vCardService->VObjectName(o)) == 0) { if (VALUE_TYPE(o)) { attribName = VCardGetStringByID(VCARD_LDAP_VERSION); value = vCardService->FakeCString(o); @@ -1840,10 +1839,10 @@ WriteLineToStream (MimeObject *obj, const char *line, PRBool aDoCharConversion) if (!charset) charset = FindCharacterSet(obj); - if ( (!charset) || ( (charset) && (!nsCRT::strcasecmp(charset, "us-ascii"))) ) + if ( (!charset) || ( (charset) && (!PL_strcasecmp(charset, "us-ascii"))) ) { PR_Free(charset); - charset = nsCRT::strdup("ISO-8859-1"); + charset = strdup("ISO-8859-1"); } // convert from the resource charset. res = INTL_ConvertCharset(charset, "UTF-8", line, strlen(line), @@ -1925,7 +1924,7 @@ nsCOMPtr stringBundle = nsnull; res = stringBundle->GetStringFromID(aMsgId, &ptrv); if (NS_FAILED(res)) - return nsCRT::strdup("???"); + return strdup("???"); else { nsAutoString v; @@ -1936,7 +1935,7 @@ nsCOMPtr stringBundle = nsnull; } if (!tempString) - return nsCRT::strdup("???"); + return strdup("???"); else return tempString; } diff --git a/mozilla/mailnews/mime/emitters/src/nsEmitterUtils.cpp b/mozilla/mailnews/mime/emitters/src/nsEmitterUtils.cpp index 157a7f8b545..93bc835e5c6 100644 --- a/mozilla/mailnews/mime/emitters/src/nsEmitterUtils.cpp +++ b/mozilla/mailnews/mime/emitters/src/nsEmitterUtils.cpp @@ -44,12 +44,12 @@ #include "nsIIOService.h" #include "nsIURI.h" #include "prprf.h" -#include "nsCRT.h" + extern "C" PRBool EmitThisHeaderForPrefSetting(PRInt32 dispType, const char *header) { - if (nsMimeHeaderDisplayTypes::AllHeaders == dispType) + if (nsMimeHeaderDisplayTypes::AllHeaders == dispType) return PR_TRUE; if ((!header) || (!*header)) @@ -58,9 +58,9 @@ EmitThisHeaderForPrefSetting(PRInt32 dispType, const char *header) if (nsMimeHeaderDisplayTypes::MicroHeaders == dispType) { if ( - (!nsCRT::strcmp(header, HEADER_SUBJECT)) || - (!nsCRT::strcmp(header, HEADER_FROM)) || - (!nsCRT::strcmp(header, HEADER_DATE)) + (!strcmp(header, HEADER_SUBJECT)) || + (!strcmp(header, HEADER_FROM)) || + (!strcmp(header, HEADER_DATE)) ) return PR_TRUE; else @@ -70,24 +70,24 @@ EmitThisHeaderForPrefSetting(PRInt32 dispType, const char *header) if (nsMimeHeaderDisplayTypes::NormalHeaders == dispType) { if ( - (!nsCRT::strcmp(header, HEADER_DATE)) || - (!nsCRT::strcmp(header, HEADER_TO)) || - (!nsCRT::strcmp(header, HEADER_SUBJECT)) || - (!nsCRT::strcmp(header, HEADER_SENDER)) || - (!nsCRT::strcmp(header, HEADER_RESENT_TO)) || - (!nsCRT::strcmp(header, HEADER_RESENT_SENDER)) || - (!nsCRT::strcmp(header, HEADER_RESENT_FROM)) || - (!nsCRT::strcmp(header, HEADER_RESENT_CC)) || - (!nsCRT::strcmp(header, HEADER_REPLY_TO)) || - (!nsCRT::strcmp(header, HEADER_REFERENCES)) || - (!nsCRT::strcmp(header, HEADER_NEWSGROUPS)) || - (!nsCRT::strcmp(header, HEADER_MESSAGE_ID)) || - (!nsCRT::strcmp(header, HEADER_FROM)) || - (!nsCRT::strcmp(header, HEADER_FOLLOWUP_TO)) || - (!nsCRT::strcmp(header, HEADER_CC)) || - (!nsCRT::strcmp(header, HEADER_ORGANIZATION)) || - (!nsCRT::strcmp(header, HEADER_REPLY_TO)) || - (!nsCRT::strcmp(header, HEADER_BCC)) + (!strcmp(header, HEADER_DATE)) || + (!strcmp(header, HEADER_TO)) || + (!strcmp(header, HEADER_SUBJECT)) || + (!strcmp(header, HEADER_SENDER)) || + (!strcmp(header, HEADER_RESENT_TO)) || + (!strcmp(header, HEADER_RESENT_SENDER)) || + (!strcmp(header, HEADER_RESENT_FROM)) || + (!strcmp(header, HEADER_RESENT_CC)) || + (!strcmp(header, HEADER_REPLY_TO)) || + (!strcmp(header, HEADER_REFERENCES)) || + (!strcmp(header, HEADER_NEWSGROUPS)) || + (!strcmp(header, HEADER_MESSAGE_ID)) || + (!strcmp(header, HEADER_FROM)) || + (!strcmp(header, HEADER_FOLLOWUP_TO)) || + (!strcmp(header, HEADER_CC)) || + (!strcmp(header, HEADER_ORGANIZATION)) || + (!strcmp(header, HEADER_REPLY_TO)) || + (!strcmp(header, HEADER_BCC)) ) return PR_TRUE; else diff --git a/mozilla/mailnews/mime/emitters/src/nsMimeBaseEmitter.cpp b/mozilla/mailnews/mime/emitters/src/nsMimeBaseEmitter.cpp index 9a0d3239030..a1bf30702fe 100644 --- a/mozilla/mailnews/mime/emitters/src/nsMimeBaseEmitter.cpp +++ b/mozilla/mailnews/mime/emitters/src/nsMimeBaseEmitter.cpp @@ -327,7 +327,7 @@ nsMimeBaseEmitter::LocalizeHeaderName(const char *aHeaderName, const char *aDefa if (retVal) return retVal; else - return nsCRT::strdup(aDefaultName); + return strdup(aDefaultName); } /////////////////////////////////////////////////////////////////////////// @@ -396,9 +396,9 @@ nsMimeBaseEmitter::StartAttachment(const char *name, const char *contentType, co { ++mAttachCount; - mCurrentAttachment->displayName = nsCRT::strdup(name); - mCurrentAttachment->urlSpec = nsCRT::strdup(url); - mCurrentAttachment->contentType = nsCRT::strdup(contentType); + mCurrentAttachment->displayName = strdup(name); + mCurrentAttachment->urlSpec = strdup(url); + mCurrentAttachment->contentType = strdup(contentType); mCurrentAttachment->isExternalAttachment = aIsExternalAttachment; } @@ -544,7 +544,7 @@ nsMimeBaseEmitter::GetHeaderValue(const char *aHeaderName) if ( (!headerInfo) || (!headerInfo->name) || (!(*headerInfo->name)) ) continue; - if (!nsCRT::strcasecmp(aHeaderName, headerInfo->name)) + if (!PL_strcasecmp(aHeaderName, headerInfo->name)) { retVal = headerInfo->value; break; @@ -656,8 +656,8 @@ nsMimeBaseEmitter::AddHeaderField(const char *field, const char *value) headerInfoType *ptr = (headerInfoType *) PR_NEWZAP(headerInfoType); if ( (ptr) && tPtr) { - ptr->name = nsCRT::strdup(field); - ptr->value = nsCRT::strdup(value); + ptr->name = strdup(field); + ptr->value = strdup(value); tPtr->AppendElement(ptr); } @@ -716,7 +716,7 @@ nsMimeBaseEmitter::WriteHeaderFieldHTML(const char *field, const char *value) } else { - newValue = nsCRT::strdup(value); + newValue = strdup(value); } if (!newValue) @@ -879,11 +879,11 @@ nsMimeBaseEmitter::DumpRestOfHeaders() (!headerInfo->value) || (!(*headerInfo->value))) continue; - if ( (!nsCRT::strcasecmp(HEADER_SUBJECT, headerInfo->name)) || - (!nsCRT::strcasecmp(HEADER_DATE, headerInfo->name)) || - (!nsCRT::strcasecmp(HEADER_FROM, headerInfo->name)) || - (!nsCRT::strcasecmp(HEADER_TO, headerInfo->name)) || - (!nsCRT::strcasecmp(HEADER_CC, headerInfo->name)) ) + if ( (!PL_strcasecmp(HEADER_SUBJECT, headerInfo->name)) || + (!PL_strcasecmp(HEADER_DATE, headerInfo->name)) || + (!PL_strcasecmp(HEADER_FROM, headerInfo->name)) || + (!PL_strcasecmp(HEADER_TO, headerInfo->name)) || + (!PL_strcasecmp(HEADER_CC, headerInfo->name)) ) continue; WriteHeaderFieldHTML(headerInfo->name, headerInfo->value); diff --git a/mozilla/mailnews/mime/emitters/src/nsMimeHtmlEmitter.cpp b/mozilla/mailnews/mime/emitters/src/nsMimeHtmlEmitter.cpp index 0bfd486e221..b65e0894c09 100644 --- a/mozilla/mailnews/mime/emitters/src/nsMimeHtmlEmitter.cpp +++ b/mozilla/mailnews/mime/emitters/src/nsMimeHtmlEmitter.cpp @@ -86,7 +86,7 @@ nsresult nsMimeHtmlDisplayEmitter::Init() PRBool nsMimeHtmlDisplayEmitter::BroadCastHeadersAndAttachments() { // try to get a header sink if there is one.... - nsCOMPtr headerSink; + nsCOMPtr headerSink; nsresult rv = GetHeaderSink(getter_AddRefs(headerSink)); if (NS_SUCCEEDED(rv) && headerSink && mDocHeader) return PR_TRUE; @@ -94,7 +94,7 @@ PRBool nsMimeHtmlDisplayEmitter::BroadCastHeadersAndAttachments() return PR_FALSE; } -nsresult +nsresult nsMimeHtmlDisplayEmitter::WriteHeaderFieldHTMLPrefix() { if (!BroadCastHeadersAndAttachments() || (mFormat == nsMimeOutput::nsMimeMessagePrintOutput)) @@ -189,34 +189,34 @@ nsresult nsMimeHtmlDisplayEmitter::BroadcastHeaders(nsIMsgHeaderSink * aHeaderSi const char * headerValue = headerInfo->value; // optimization: if we aren't in view all header view mode, we only show a small set of the total # of headers. - // don't waste time sending those out to the UI since the UI is going to ignore them anyway. - if (aHeaderMode != VIEW_ALL_HEADERS && (mFormat != nsMimeOutput::nsMimeMessageFilterSniffer)) + // don't waste time sending those out to the UI since the UI is going to ignore them anyway. + if (aHeaderMode != VIEW_ALL_HEADERS && (mFormat != nsMimeOutput::nsMimeMessageFilterSniffer)) { nsDependentCString headerStr(headerInfo->name); - if (nsCRT::strcasecmp("to", headerInfo->name) && nsCRT::strcasecmp("from", headerInfo->name) && - nsCRT::strcasecmp("cc", headerInfo->name) && nsCRT::strcasecmp("newsgroups", headerInfo->name) && - nsCRT::strcasecmp("bcc", headerInfo->name) && nsCRT::strcasecmp("followup-to", headerInfo->name) && - nsCRT::strcasecmp("reply-to", headerInfo->name) && nsCRT::strcasecmp("subject", headerInfo->name) && - nsCRT::strcasecmp("organization", headerInfo->name) && nsCRT::strcasecmp("user-agent", headerInfo->name) && - nsCRT::strcasecmp("content-base", headerInfo->name) && nsCRT::strcasecmp("sender", headerInfo->name) && - nsCRT::strcasecmp("date", headerInfo->name) && nsCRT::strcasecmp("x-mailer", headerInfo->name) && - nsCRT::strcasecmp("content-type", headerInfo->name) && nsCRT::strcasecmp("message-id", headerInfo->name) && - nsCRT::strcasecmp("x-newsreader", headerInfo->name) && nsCRT::strcasecmp("x-mimeole", headerInfo->name) && + if (PL_strcasecmp("to", headerInfo->name) && PL_strcasecmp("from", headerInfo->name) && + PL_strcasecmp("cc", headerInfo->name) && PL_strcasecmp("newsgroups", headerInfo->name) && + PL_strcasecmp("bcc", headerInfo->name) && PL_strcasecmp("followup-to", headerInfo->name) && + PL_strcasecmp("reply-to", headerInfo->name) && PL_strcasecmp("subject", headerInfo->name) && + PL_strcasecmp("organization", headerInfo->name) && PL_strcasecmp("user-agent", headerInfo->name) && + PL_strcasecmp("content-base", headerInfo->name) && PL_strcasecmp("sender", headerInfo->name) && + PL_strcasecmp("date", headerInfo->name) && PL_strcasecmp("x-mailer", headerInfo->name) && + PL_strcasecmp("content-type", headerInfo->name) && PL_strcasecmp("message-id", headerInfo->name) && + PL_strcasecmp("x-newsreader", headerInfo->name) && PL_strcasecmp("x-mimeole", headerInfo->name) && // make headerStr lower case because IndexOf is case-sensitive (!extraExpandedHeadersArray.Count() || (ToLowerCase(headerStr), extraExpandedHeadersArray.IndexOf(headerStr) == kNotFound))) continue; } - if (!nsCRT::strcasecmp("Date", headerInfo->name) && !displayOriginalDate) + if (!PL_strcasecmp("Date", headerInfo->name) && !displayOriginalDate) { - GenerateDateString(headerValue, convertedDateString); + GenerateDateString(headerValue, convertedDateString); headerValueArray.AppendCString(convertedDateString); } else // append the header value as is headerValueArray.AppendCString(nsCString(headerValue)); - // XXX: TODO If nsCStringArray were converted over to take nsACStrings instead of nsCStrings, we can just + // XXX: TODO If nsCStringArray were converted over to take nsACStrings instead of nsCStrings, we can just // wrap these strings with a nsDependentCString which would avoid making a duplicate copy of the string // like we are doing here.... headerNameArray.AppendCString(nsCString(headerInfo->name)); @@ -249,7 +249,7 @@ NS_IMETHODIMP nsMimeHtmlDisplayEmitter::WriteHTMLHeaders() } else mFirstHeaders = PR_FALSE; - + PRBool bFromNewsgroups = PR_FALSE; for (PRInt32 j=0; j < mHeaderArray->Count(); j++) { @@ -257,7 +257,7 @@ NS_IMETHODIMP nsMimeHtmlDisplayEmitter::WriteHTMLHeaders() if (!(headerInfo && headerInfo->name && *headerInfo->name)) continue; - if (!nsCRT::strcasecmp("Newsgroups", headerInfo->name)) + if (!PL_strcasecmp("Newsgroups", headerInfo->name)) { bFromNewsgroups = PR_TRUE; break; @@ -265,7 +265,7 @@ NS_IMETHODIMP nsMimeHtmlDisplayEmitter::WriteHTMLHeaders() } // try to get a header sink if there is one.... - nsCOMPtr headerSink; + nsCOMPtr headerSink; nsresult rv = GetHeaderSink(getter_AddRefs(headerSink)); if (headerSink) @@ -311,10 +311,10 @@ nsresult nsMimeHtmlDisplayEmitter::GenerateDateString(const char * dateString, n { // same day... dateFormat = kDateFormatNone; - } + } // the following chunk of code causes us to show a day instead of a number if the message was received // within the last 7 days. i.e. Mon 5:10pm. We need to add a preference so folks to can enable this behavior - // if they want it. + // if they want it. /* else if (LL_CMP(currentTime, >, dateOfMsg)) { @@ -325,12 +325,12 @@ nsresult nsMimeHtmlDisplayEmitter::GenerateDateString(const char * dateString, n PRInt64 diff; LL_SUB(diff, currentTime, dateOfMsg); - if (LL_CMP(diff, <=, microSecondsInDays)) // within the same week + if (LL_CMP(diff, <=, microSecondsInDays)) // within the same week dateFormat = kDateFormatWeekday; } */ - if (NS_SUCCEEDED(rv)) + if (NS_SUCCEEDED(rv)) rv = mDateFormater->FormatPRTime(nsnull /* nsILocale* locale */, dateFormat, kTimeFormatNoSeconds, @@ -387,11 +387,11 @@ nsMimeHtmlDisplayEmitter::StartAttachment(const char *name, PRBool aIsExternalAttachment) { nsresult rv = NS_OK; - nsCOMPtr headerSink; + nsCOMPtr headerSink; rv = GetHeaderSink(getter_AddRefs(headerSink)); - + if (NS_SUCCEEDED(rv) && headerSink) - { + { char * escapedUrl = nsEscape(url, url_Path); nsCString uriString; @@ -430,7 +430,7 @@ nsMimeHtmlDisplayEmitter::StartAttachment(const char *name, unicodeHeaderValue.get(), uriString.get(), aIsExternalAttachment); - nsCRT::free(escapedUrl); + NS_Free(escapedUrl); mSkipAttachment = PR_TRUE; } else if (mFormat == nsMimeOutput::nsMimeMessagePrintOutput) @@ -450,7 +450,7 @@ nsMimeHtmlDisplayEmitter::StartAttachment(const char *name, } // Attachment handling routines -// Ok, we are changing the way we handle these now...It used to be that we output +// Ok, we are changing the way we handle these now...It used to be that we output // HTML to make a clickable link, etc... but now, this should just be informational // and only show up during printing // XXX should they also show up during quoting? @@ -553,7 +553,7 @@ nsresult nsMimeHtmlDisplayEmitter::EndAllAttachments() { nsresult rv = NS_OK; - nsCOMPtr headerSink; + nsCOMPtr headerSink; rv = GetHeaderSink(getter_AddRefs(headerSink)); if (headerSink) headerSink->OnEndAllAttachments(); @@ -575,7 +575,7 @@ nsMimeHtmlDisplayEmitter::EndBody() UtilityWriteCRLF(""); UtilityWriteCRLF(""); } - nsCOMPtr headerSink; + nsCOMPtr headerSink; nsresult rv = GetHeaderSink(getter_AddRefs(headerSink)); nsCOMPtr mailnewsUrl (do_QueryInterface(mURL, &rv)); if (headerSink) diff --git a/mozilla/mailnews/mime/emitters/src/nsMimeXmlEmitter.cpp b/mozilla/mailnews/mime/emitters/src/nsMimeXmlEmitter.cpp index 23cd3c28be0..24233f6b9a6 100644 --- a/mozilla/mailnews/mime/emitters/src/nsMimeXmlEmitter.cpp +++ b/mozilla/mailnews/mime/emitters/src/nsMimeXmlEmitter.cpp @@ -47,7 +47,6 @@ #include "nsCOMPtr.h" #include "nsReadableUtils.h" #include "nsUnicharUtils.h" -#include "nsCRT.h" /* * nsMimeXmlEmitter definitions.... @@ -87,11 +86,11 @@ nsMimeXmlEmitter::WriteXMLHeader(const char *msgID) { if ( (!msgID) || (!*msgID) ) msgID = "none"; - + char *newValue = nsEscapeHTML(msgID); if (!newValue) return NS_ERROR_OUT_OF_MEMORY; - + UtilityWrite(""); UtilityWriteCRLF(""); @@ -113,7 +112,7 @@ nsMimeXmlEmitter::WriteXMLTag(const char *tagName, const char *value) char *upCaseTag = NULL; char *newValue = nsEscapeHTML(value); - if (!newValue) + if (!newValue) return NS_OK; nsString newTagName; @@ -149,7 +148,7 @@ nsMimeXmlEmitter::WriteXMLTag(const char *tagName, const char *value) UtilityWrite(newValue); UtilityWrite(""); - nsCRT::free(upCaseTag); + NS_Free(upCaseTag); PR_FREEIF(newValue); return NS_OK; @@ -164,7 +163,7 @@ nsMimeXmlEmitter::StartHeader(PRBool rootMailHeader, PRBool headerOnly, const ch WriteXMLHeader(msgID); UtilityWrite(""); - return NS_OK; + return NS_OK; } nsresult @@ -181,7 +180,7 @@ nsresult nsMimeXmlEmitter::EndHeader() { UtilityWrite(""); - return NS_OK; + return NS_OK; } diff --git a/mozilla/mailnews/mime/src/comi18n.cpp b/mozilla/mailnews/mime/src/comi18n.cpp index 8498f74f015..d2e40778730 100644 --- a/mozilla/mailnews/mime/src/comi18n.cpp +++ b/mozilla/mailnews/mime/src/comi18n.cpp @@ -49,7 +49,6 @@ #include "prlog.h" #include "prprf.h" #include "plstr.h" -#include "nsCRT.h" #include "comi18n.h" #include "nsIServiceManager.h" #include "nsIStringCharsetDetector.h" @@ -214,7 +213,7 @@ PRInt32 generate_encodedwords(char *pUTF8, const char *charset, char method, cha { nsCOMPtr calias = do_GetService(NS_CHARSETALIAS_CONTRACTID, &rv); nsCOMPtr charsetAtom; - charset = !nsCRT::strcasecmp(charset, "us-ascii") ? "ISO-8859-1" : charset; + charset = !PL_strcasecmp(charset, "us-ascii") ? "ISO-8859-1" : charset; rv = calias->GetPreferred(nsDependentCString(charset), _charset); if (NS_FAILED(rv)) { @@ -236,7 +235,7 @@ PRInt32 generate_encodedwords(char *pUTF8, const char *charset, char method, cha encodedword_headlen = strlen(encodedword_head); // Load HANKAKU-KANA prefrence and cache it. - if (!nsCRT::strcasecmp("ISO-2022-JP", charset)) { + if (!PL_strcasecmp("ISO-2022-JP", charset)) { static PRInt32 conv_kana = -1; if (conv_kana < 0) { nsCOMPtr prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv)); @@ -252,7 +251,7 @@ PRInt32 generate_encodedwords(char *pUTF8, const char *charset, char method, cha do_CreateInstance(NS_HANKAKUTOZENKAKU_CONTRACTID, &rv); if (NS_SUCCEEDED(rv)) { nsString text(pUCS2), result; - rv = textTransform->Change(pUCS2, nsCRT::strlen(pUCS2), result); + rv = textTransform->Change(pUCS2, NS_strlen(pUCS2), result); if (NS_SUCCEEDED(rv)) { if (_pUCS2) nsMemory::Free(_pUCS2); @@ -267,8 +266,8 @@ PRInt32 generate_encodedwords(char *pUTF8, const char *charset, char method, cha // Create an instance of charset converter and initialize it conv = do_CreateInstance(NS_SAVEASCHARSET_CONTRACTID, &rv); if(NS_SUCCEEDED(rv)) { - rv = conv->Init(charset, - nsISaveAsCharset::attr_FallbackQuestionMark + nsISaveAsCharset::attr_EntityAfterCharsetConv, + rv = conv->Init(charset, + nsISaveAsCharset::attr_FallbackQuestionMark + nsISaveAsCharset::attr_EntityAfterCharsetConv, nsIEntityConverter::transliterate); } if (NS_FAILED(rv)) { @@ -489,7 +488,7 @@ RFC822AddressList * construct_addresslist(char *s) if (--comment == 0) { *s = '\0'; PR_FREEIF(list->displayname); - list->displayname = nsCRT::strdup(displayname); + list->displayname = strdup(displayname); list->asciionly = intlmime_only_ascii_str(displayname); *s = ')'; } @@ -506,7 +505,7 @@ RFC822AddressList * construct_addresslist(char *s) char tmp = *(s+1); *(s+1) = '\0'; PR_FREEIF(list->displayname); - list->displayname = nsCRT::strdup(displayname); + list->displayname = strdup(displayname); list->asciionly = intlmime_only_ascii_str(displayname); *(s+1) = tmp; } @@ -525,7 +524,7 @@ RFC822AddressList * construct_addresslist(char *s) tmp = *++e; *e = '\0'; PR_FREEIF(list->displayname); - list->displayname = nsCRT::strdup(displayname); + list->displayname = strdup(displayname); list->asciionly = intlmime_only_ascii_str(displayname); *e = tmp; } @@ -536,7 +535,7 @@ RFC822AddressList * construct_addresslist(char *s) tmp = *(s+1); *(s+1) = '\0'; PR_FREEIF(list->addrspec); - list->addrspec = nsCRT::strdup(addrspec); + list->addrspec = strdup(addrspec); *(s+1) = tmp; } continue; @@ -548,7 +547,7 @@ RFC822AddressList * construct_addresslist(char *s) /* deal with addr-spec only address */ if (!addrspec && displayname) { *s = '\0'; - list->addrspec = nsCRT::strdup(displayname); + list->addrspec = strdup(displayname); /* and don't forget to free the display name in the list, in that case it's bogus */ PR_FREEIF(list->displayname); } @@ -574,7 +573,7 @@ RFC822AddressList * construct_addresslist(char *s) /* deal with addr-spec only address comes at last */ if (!addrspec && displayname) { - list->addrspec = nsCRT::strdup(displayname); + list->addrspec = strdup(displayname); /* and don't forget to free the display name in the list, in that case it's bogus */ PR_FREEIF(list->displayname); } @@ -582,7 +581,7 @@ RFC822AddressList * construct_addresslist(char *s) return listhead; } -static +static char * apply_rfc2047_encoding(const char *_src, PRBool structured, const char *charset, PRInt32 cursor, PRInt32 foldlen) { RFC822AddressList *listhead, *list; @@ -596,7 +595,7 @@ char * apply_rfc2047_encoding(const char *_src, PRBool structured, const char *c //=???...?= PRInt32 perLineOverhead = strlen(charset) + 10; - if (perLineOverhead > foldlen || (src = src_head = nsCRT::strdup(_src)) == nsnull) + if (perLineOverhead > foldlen || (src = src_head = strdup(_src)) == nsnull) return nsnull; /* allocate enough buffer for conversion, this way it can avoid @@ -680,7 +679,7 @@ char * apply_rfc2047_encoding(const char *_src, PRBool structured, const char *c } else { char *spacepos = nsnull, *org_output = output; - /* show some mercy to stupid ML systems which don't know + /* show some mercy to stupid ML systems which don't know how to respect MIME encoded subject */ for (char *p = src; *p && !(*p & 0x80); p++) { if (*p == 0x20 || *p == TAB) @@ -725,7 +724,7 @@ extern "C" { #define PUBLIC -extern "C" char *MIME_DecodeMimeHeader(const char *header, +extern "C" char *MIME_DecodeMimeHeader(const char *header, const char *default_charset, PRBool override_charset, PRBool eatContinuations) @@ -735,12 +734,12 @@ extern "C" char *MIME_DecodeMimeHeader(const char *header, if (NS_FAILED(rv)) return nsnull; nsCAutoString result; - rv = mimehdrpar->DecodeRFC2047Header(header, default_charset, override_charset, + rv = mimehdrpar->DecodeRFC2047Header(header, default_charset, override_charset, eatContinuations, result); if (NS_SUCCEEDED(rv)) - return nsCRT::strdup(result.get()); + return ToNewCString(result); return nsnull; -} +} char *MIME_EncodeMimePartIIStr(const char* header, PRBool structured, const char* mailCharset, const PRInt32 fieldNameLen, const PRInt32 encodedWordSize) { @@ -781,40 +780,40 @@ MIME_detect_charset(const char *aBuf, PRInt32 aLength, const char** aCharset) } //Get unicode decoder(from inputcharset to unicode) for aInputCharset -nsresult +nsresult MIME_get_unicode_decoder(const char* aInputCharset, nsIUnicodeDecoder **aDecoder) { nsresult res; // get charset converters. - nsCOMPtr ccm = - do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &res); + nsCOMPtr ccm = + do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &res); if (NS_SUCCEEDED(res)) { // create a decoder (conv to unicode), ok if failed if we do auto detection - if (!*aInputCharset || !nsCRT::strcasecmp("us-ascii", aInputCharset)) + if (!*aInputCharset || !PL_strcasecmp("us-ascii", aInputCharset)) res = ccm->GetUnicodeDecoderRaw("ISO-8859-1", aDecoder); else res = ccm->GetUnicodeDecoder(aInputCharset, aDecoder); } - + return res; } //Get unicode encoder(from unicode to inputcharset) for aOutputCharset -nsresult +nsresult MIME_get_unicode_encoder(const char* aOutputCharset, nsIUnicodeEncoder **aEncoder) { nsresult res; // get charset converters. - nsCOMPtr ccm = - do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &res); + nsCOMPtr ccm = + do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &res); if (NS_SUCCEEDED(res) && *aOutputCharset) { // create a encoder (conv from unicode) res = ccm->GetUnicodeEncoder(aOutputCharset, aEncoder); } - + return res; } diff --git a/mozilla/mailnews/mime/src/mimebuf.cpp b/mozilla/mailnews/mime/src/mimebuf.cpp index f6c4686a2ff..e8ac3eac187 100644 --- a/mozilla/mailnews/mime/src/mimebuf.cpp +++ b/mozilla/mailnews/mime/src/mimebuf.cpp @@ -48,7 +48,6 @@ #include "prmem.h" #include "plstr.h" #include "prlog.h" -#include "nsCRT.h" #include "msgCore.h" #include "nsMimeStringResources.h" diff --git a/mozilla/mailnews/mime/src/mimecms.cpp b/mozilla/mailnews/mime/src/mimecms.cpp index 83b673d0b51..ffc6ed2b8e7 100644 --- a/mozilla/mailnews/mime/src/mimecms.cpp +++ b/mozilla/mailnews/mime/src/mimecms.cpp @@ -42,7 +42,6 @@ #include "nsICMSDecoder.h" #include "mimecms.h" #include "mimemsig.h" -#include "nsCRT.h" #include "nspr.h" #include "nsEscape.h" #include "mimemsg.h" diff --git a/mozilla/mailnews/mime/src/mimecont.cpp b/mozilla/mailnews/mime/src/mimecont.cpp index 107c5c912db..6a46110b6aa 100644 --- a/mozilla/mailnews/mime/src/mimecont.cpp +++ b/mozilla/mailnews/mime/src/mimecont.cpp @@ -37,7 +37,6 @@ #include "prmem.h" #include "plstr.h" #include "prlog.h" -#include "nsCRT.h" #include "prio.h" #include "mimecont.h" #include "nsMimeStringResources.h" diff --git a/mozilla/mailnews/mime/src/mimecryp.cpp b/mozilla/mailnews/mime/src/mimecryp.cpp index 28c04e8844f..5c402739d12 100644 --- a/mozilla/mailnews/mime/src/mimecryp.cpp +++ b/mozilla/mailnews/mime/src/mimecryp.cpp @@ -43,13 +43,12 @@ #include "prmem.h" #include "plstr.h" #include "prlog.h" -#include "nsCRT.h" #include "mimemult.h" #define MIME_SUPERCLASS mimeContainerClass MimeDefClass(MimeEncrypted, MimeEncryptedClass, mimeEncryptedClass, - &MIME_SUPERCLASS); + &MIME_SUPERCLASS); static int MimeEncrypted_initialize (MimeObject *); static void MimeEncrypted_finalize (MimeObject *); @@ -103,51 +102,51 @@ MimeEncrypted_parse_begin (MimeObject *obj) MimeDecoderData *(*fn) (nsresult (*) (const char*, PRInt32, void*), void*) = 0; if (enc->crypto_closure) - return -1; + return -1; enc->crypto_closure = (((MimeEncryptedClass *) obj->clazz)->crypto_init) (obj, MimeHandleDecryptedOutput, obj); if (!enc->crypto_closure) - return -1; + return -1; /* (Mostly duplicated from MimeLeaf, see comments in mimecryp.h.) Initialize a decoder if necessary. */ if (!obj->encoding) - ; - else if (!nsCRT::strcasecmp(obj->encoding, ENCODING_BASE64)) - fn = &MimeB64DecoderInit; - else if (!nsCRT::strcasecmp(obj->encoding, ENCODING_QUOTED_PRINTABLE)) + ; + else if (!PL_strcasecmp(obj->encoding, ENCODING_BASE64)) + fn = &MimeB64DecoderInit; + else if (!PL_strcasecmp(obj->encoding, ENCODING_QUOTED_PRINTABLE)) { enc->decoder_data = - MimeQPDecoderInit (/* The (int (*) ...) cast is to turn the `void' argument - into `MimeObject'. */ - ((nsresult (*) (const char *, PRInt32, void *)) - ((MimeEncryptedClass *)obj->clazz)->parse_decoded_buffer), - obj); + MimeQPDecoderInit (/* The (int (*) ...) cast is to turn the `void' argument + into `MimeObject'. */ + ((nsresult (*) (const char *, PRInt32, void *)) + ((MimeEncryptedClass *)obj->clazz)->parse_decoded_buffer), + obj); if (!enc->decoder_data) - return MIME_OUT_OF_MEMORY; + return MIME_OUT_OF_MEMORY; } - else if (!nsCRT::strcasecmp(obj->encoding, ENCODING_UUENCODE) || - !nsCRT::strcasecmp(obj->encoding, ENCODING_UUENCODE2) || - !nsCRT::strcasecmp(obj->encoding, ENCODING_UUENCODE3) || - !nsCRT::strcasecmp(obj->encoding, ENCODING_UUENCODE4)) - fn = &MimeUUDecoderInit; - else if (!nsCRT::strcasecmp(obj->encoding, ENCODING_YENCODE)) + else if (!PL_strcasecmp(obj->encoding, ENCODING_UUENCODE) || + !PL_strcasecmp(obj->encoding, ENCODING_UUENCODE2) || + !PL_strcasecmp(obj->encoding, ENCODING_UUENCODE3) || + !PL_strcasecmp(obj->encoding, ENCODING_UUENCODE4)) + fn = &MimeUUDecoderInit; + else if (!PL_strcasecmp(obj->encoding, ENCODING_YENCODE)) fn = &MimeYDecoderInit; if (fn) - { - enc->decoder_data = - fn (/* The (int (*) ...) cast is to turn the `void' argument - into `MimeObject'. */ - ((nsresult (*) (const char *, PRInt32, void *)) - ((MimeEncryptedClass *)obj->clazz)->parse_decoded_buffer), - obj); + { + enc->decoder_data = + fn (/* The (int (*) ...) cast is to turn the `void' argument + into `MimeObject'. */ + ((nsresult (*) (const char *, PRInt32, void *)) + ((MimeEncryptedClass *)obj->clazz)->parse_decoded_buffer), + obj); - if (!enc->decoder_data) - return MIME_OUT_OF_MEMORY; - } + if (!enc->decoder_data) + return MIME_OUT_OF_MEMORY; + } return ((MimeObjectClass*)&MIME_SUPERCLASS)->parse_begin(obj); } @@ -164,15 +163,15 @@ MimeEncrypted_parse_buffer (const char *buffer, PRInt32 size, MimeObject *obj) if (obj->closed_p) return -1; /* Don't consult output_p here, since at this point we're behaving as a - simple container object -- the output_p decision should be made by - the child of this object. */ + simple container object -- the output_p decision should be made by + the child of this object. */ if (enc->decoder_data) - return MimeDecoderWrite (enc->decoder_data, buffer, size); + return MimeDecoderWrite (enc->decoder_data, buffer, size); else - return ((MimeEncryptedClass *)obj->clazz)->parse_decoded_buffer (buffer, - size, - obj); + return ((MimeEncryptedClass *)obj->clazz)->parse_decoded_buffer (buffer, + size, + obj); } @@ -189,8 +188,8 @@ MimeEncrypted_parse_decoded_buffer (const char *buffer, PRInt32 size, MimeObject { MimeEncrypted *enc = (MimeEncrypted *) obj; return - ((MimeEncryptedClass *) obj->clazz)->crypto_write (buffer, size, - enc->crypto_closure); + ((MimeEncryptedClass *) obj->clazz)->crypto_write (buffer, size, + enc->crypto_closure); } @@ -205,63 +204,63 @@ MimeEncrypted_parse_eof (MimeObject *obj, PRBool abort_p) /* (Duplicated from MimeLeaf, see comments in mimecryp.h.) Close off the decoder, to cause it to give up any buffered data that - it is still holding. + it is still holding. */ if (enc->decoder_data) - { - int status = MimeDecoderDestroy(enc->decoder_data, PR_FALSE); - enc->decoder_data = 0; - if (status < 0) return status; - } + { + int status = MimeDecoderDestroy(enc->decoder_data, PR_FALSE); + enc->decoder_data = 0; + if (status < 0) return status; + } /* If there is still data in the ibuffer, that means that the last - *decrypted* line of this part didn't end in a newline; so push it out - anyway (this means that the parse_line method will be called with a - string with no trailing newline, which isn't the usual case.) */ + *decrypted* line of this part didn't end in a newline; so push it out + anyway (this means that the parse_line method will be called with a + string with no trailing newline, which isn't the usual case.) */ if (!abort_p && - obj->ibuffer_fp > 0) - { - int status = MimeHandleDecryptedOutputLine (obj->ibuffer, - obj->ibuffer_fp, obj); - obj->ibuffer_fp = 0; - if (status < 0) - { - obj->closed_p = PR_TRUE; - return status; - } - } + obj->ibuffer_fp > 0) + { + int status = MimeHandleDecryptedOutputLine (obj->ibuffer, + obj->ibuffer_fp, obj); + obj->ibuffer_fp = 0; + if (status < 0) + { + obj->closed_p = PR_TRUE; + return status; + } + } /* Now run the superclass's parse_eof, which (because we've already taken - care of ibuffer in a way appropriate for this class, immediately above) - will ony set closed_p to true. + care of ibuffer in a way appropriate for this class, immediately above) + will ony set closed_p to true. */ status = ((MimeObjectClass*)&MIME_SUPERCLASS)->parse_eof (obj, abort_p); if (status < 0) return status; /* Now close off the underlying crypto module. At this point, the crypto - module has all of the input. (DecoderDestroy called parse_decoded_buffer - which called crypto_write, with the last of the data.) + module has all of the input. (DecoderDestroy called parse_decoded_buffer + which called crypto_write, with the last of the data.) */ if (enc->crypto_closure) - { - status = - ((MimeEncryptedClass *) obj->clazz)->crypto_eof (enc->crypto_closure, - abort_p); - if (status < 0 && !abort_p) - return status; - } + { + status = + ((MimeEncryptedClass *) obj->clazz)->crypto_eof (enc->crypto_closure, + abort_p); + if (status < 0 && !abort_p) + return status; + } /* Now we have the entire child part in the part buffer. - We are now able to verify its signature, emit a blurb, and then - emit the part. + We are now able to verify its signature, emit a blurb, and then + emit the part. */ if (abort_p) - return 0; + return 0; else - return MimeEncrypted_emit_buffered_child (obj); + return MimeEncrypted_emit_buffered_child (obj); } @@ -278,33 +277,33 @@ MimeEncrypted_cleanup (MimeObject *obj, PRBool finalizing_p) MimeEncrypted *enc = (MimeEncrypted *) obj; if (enc->part_buffer) - { - MimePartBufferDestroy(enc->part_buffer); - enc->part_buffer = 0; - } + { + MimePartBufferDestroy(enc->part_buffer); + enc->part_buffer = 0; + } if (finalizing_p && enc->crypto_closure) - { - /* Don't free these until this object is really going away -- keep them - around for the lifetime of the MIME object, so that we can get at the - security info of sub-parts of the currently-displayed message. */ - ((MimeEncryptedClass *) obj->clazz)->crypto_free (enc->crypto_closure); - enc->crypto_closure = 0; - } + { + /* Don't free these until this object is really going away -- keep them + around for the lifetime of the MIME object, so that we can get at the + security info of sub-parts of the currently-displayed message. */ + ((MimeEncryptedClass *) obj->clazz)->crypto_free (enc->crypto_closure); + enc->crypto_closure = 0; + } /* (Duplicated from MimeLeaf, see comments in mimecryp.h.) - Free the decoder data, if it's still around. */ + Free the decoder data, if it's still around. */ if (enc->decoder_data) - { - MimeDecoderDestroy(enc->decoder_data, PR_TRUE); - enc->decoder_data = 0; - } + { + MimeDecoderDestroy(enc->decoder_data, PR_TRUE); + enc->decoder_data = 0; + } if (enc->hdrs) - { - MimeHeaders_free(enc->hdrs); - enc->hdrs = 0; - } + { + MimeHeaders_free(enc->hdrs); + enc->hdrs = 0; + } } @@ -318,38 +317,38 @@ MimeEncrypted_finalize (MimeObject *obj) static int MimeHandleDecryptedOutput (const char *buf, PRInt32 buf_size, - void *output_closure) + void *output_closure) { /* This method is invoked by the underlying decryption module. - The module is assumed to return a MIME object, and its associated - headers. For example, if a text/plain document was encrypted, - the encryption module would return the following data: + The module is assumed to return a MIME object, and its associated + headers. For example, if a text/plain document was encrypted, + the encryption module would return the following data: - Content-Type: text/plain + Content-Type: text/plain - Decrypted text goes here. + Decrypted text goes here. - This function will then extract a header block (up to the first - blank line, as usual) and will then handle the included data as - appropriate. + This function will then extract a header block (up to the first + blank line, as usual) and will then handle the included data as + appropriate. */ MimeObject *obj = (MimeObject *) output_closure; /* Is it truly safe to use ibuffer here? I think so... */ return mime_LineBuffer (buf, buf_size, - &obj->ibuffer, &obj->ibuffer_size, &obj->ibuffer_fp, - PR_TRUE, - ((int (*PR_CALLBACK) (char *, PRInt32, void *)) - /* This cast is to turn void into MimeObject */ - MimeHandleDecryptedOutputLine), - obj); + &obj->ibuffer, &obj->ibuffer_size, &obj->ibuffer_fp, + PR_TRUE, + ((int (*PR_CALLBACK) (char *, PRInt32, void *)) + /* This cast is to turn void into MimeObject */ + MimeHandleDecryptedOutputLine), + obj); } static int MimeHandleDecryptedOutputLine (char *line, PRInt32 length, MimeObject *obj) { /* Largely the same as MimeMessage_parse_line (the other MIME container - type which contains exactly one child.) + type which contains exactly one child.) */ MimeEncrypted *enc = (MimeEncrypted *) obj; int status = 0; @@ -357,41 +356,41 @@ MimeHandleDecryptedOutputLine (char *line, PRInt32 length, MimeObject *obj) if (!line || !*line) return -1; /* If we're supposed to write this object, but aren't supposed to convert - it to HTML, simply pass it through unaltered. */ + it to HTML, simply pass it through unaltered. */ if (obj->output_p && - obj->options && - !obj->options->write_html_p && - obj->options->output_fn) - return MimeObject_write(obj, line, length, PR_TRUE); + obj->options && + !obj->options->write_html_p && + obj->options->output_fn) + return MimeObject_write(obj, line, length, PR_TRUE); /* If we already have a child object in the buffer, then we're done parsing - headers, and all subsequent lines get passed to the inferior object - without further processing by us. (Our parent will stop feeding us - lines when this MimeMessage part is out of data.) + headers, and all subsequent lines get passed to the inferior object + without further processing by us. (Our parent will stop feeding us + lines when this MimeMessage part is out of data.) */ if (enc->part_buffer) - return MimePartBufferWrite (enc->part_buffer, line, length); + return MimePartBufferWrite (enc->part_buffer, line, length); /* Otherwise we don't yet have a child object in the buffer, which means - we're not done parsing our headers yet. + we're not done parsing our headers yet. */ if (!enc->hdrs) - { - enc->hdrs = MimeHeaders_new(); - if (!enc->hdrs) return MIME_OUT_OF_MEMORY; - } + { + enc->hdrs = MimeHeaders_new(); + if (!enc->hdrs) return MIME_OUT_OF_MEMORY; + } status = MimeHeaders_parse_line(line, length, enc->hdrs); if (status < 0) return status; /* If this line is blank, we're now done parsing headers, and should - examine our content-type to create our "body" part. + examine our content-type to create our "body" part. */ if (*line == '\r' || *line == '\n') - { - status = MimeEncrypted_close_headers(obj); - if (status < 0) return status; - } + { + status = MimeEncrypted_close_headers(obj); + if (status < 0) return status; + } return 0; } @@ -404,7 +403,7 @@ MimeEncrypted_close_headers (MimeObject *obj) if (enc->part_buffer) return -1; enc->part_buffer = MimePartBufferCreate(); if (!enc->part_buffer) - return MIME_OUT_OF_MEMORY; + return MIME_OUT_OF_MEMORY; return 0; } @@ -434,83 +433,83 @@ MimeEncrypted_emit_buffered_child(MimeObject *obj) NS_ASSERTION(enc->crypto_closure, "1.2 01 Nov 2001 17:59"); /* Emit some HTML saying whether the signature was cool. - But don't emit anything if in FO_QUOTE_MESSAGE mode. + But don't emit anything if in FO_QUOTE_MESSAGE mode. - Also, don't emit anything if the enclosed object is itself a signed - object -- in the case of an encrypted object which contains a signed - object, we only emit the HTML once (since the normal way of encrypting - and signing is to nest the signature inside the crypto envelope.) + Also, don't emit anything if the enclosed object is itself a signed + object -- in the case of an encrypted object which contains a signed + object, we only emit the HTML once (since the normal way of encrypting + and signing is to nest the signature inside the crypto envelope.) */ if (enc->crypto_closure && - obj->options && - obj->options->headers != MimeHeadersCitation && - obj->options->write_html_p && - obj->options->output_fn) - // && !mime_crypto_object_p(enc->hdrs, PR_TRUE)) // XXX fix later XXX // - { + obj->options && + obj->options->headers != MimeHeadersCitation && + obj->options->write_html_p && + obj->options->output_fn) + // && !mime_crypto_object_p(enc->hdrs, PR_TRUE)) // XXX fix later XXX // + { char *html; #if 0 // XXX Fix this later XXX // - char *html = (((MimeEncryptedClass *) obj->clazz)->crypto_generate_html - (enc->crypto_closure)); - if (!html) return -1; /* MK_OUT_OF_MEMORY? */ - - status = MimeObject_write(obj, html, nsCRT::strlen(html), PR_FALSE); - PR_FREEIF(html); - if (status < 0) return status; + char *html = (((MimeEncryptedClass *) obj->clazz)->crypto_generate_html + (enc->crypto_closure)); + if (!html) return -1; /* MK_OUT_OF_MEMORY? */ + + status = MimeObject_write(obj, html, strlen(html), PR_FALSE); + PR_FREEIF(html); + if (status < 0) return status; #endif - /* Now that we have written out the crypto stamp, the outermost header - block is well and truly closed. If this is in fact the outermost - message, then run the post_header_html_fn now. - */ - if (obj->options && - obj->options->state && - obj->options->generate_post_header_html_fn && - !obj->options->state->post_header_html_run_p) - { - MimeHeaders *outer_headers = nsnull; - MimeObject *p; - for (p = obj; p->parent; p = p->parent) - outer_headers = p->headers; - NS_ASSERTION(obj->options->state->first_data_written_p, "1.2 01 Nov 2001 17:59"); - html = obj->options->generate_post_header_html_fn(NULL, - obj->options->html_closure, - outer_headers); - obj->options->state->post_header_html_run_p = PR_TRUE; - if (html) - { + /* Now that we have written out the crypto stamp, the outermost header + block is well and truly closed. If this is in fact the outermost + message, then run the post_header_html_fn now. + */ + if (obj->options && + obj->options->state && + obj->options->generate_post_header_html_fn && + !obj->options->state->post_header_html_run_p) + { + MimeHeaders *outer_headers = nsnull; + MimeObject *p; + for (p = obj; p->parent; p = p->parent) + outer_headers = p->headers; + NS_ASSERTION(obj->options->state->first_data_written_p, "1.2 01 Nov 2001 17:59"); + html = obj->options->generate_post_header_html_fn(NULL, + obj->options->html_closure, + outer_headers); + obj->options->state->post_header_html_run_p = PR_TRUE; + if (html) + { status = MimeObject_write(obj, html, strlen(html), PR_FALSE); - PR_FREEIF(html); - if (status < 0) return status; - } - } - } + PR_FREEIF(html); + if (status < 0) return status; + } + } + } else if (enc->crypto_closure && - obj->options && - obj->options->decrypt_p) - { - /* Do this just to cause `mime_set_crypto_stamp' to be called, and to - cause the various `decode_error' and `verify_error' slots to be set: - we don't actually use the returned HTML, because we're not emitting - HTML. It's maybe not such a good thing that the determination of - whether it was encrypted or not is tied up with generating HTML, - but oh well. */ - char *html = (((MimeEncryptedClass *) obj->clazz)->crypto_generate_html - (enc->crypto_closure)); - PR_FREEIF(html); - } + obj->options && + obj->options->decrypt_p) + { + /* Do this just to cause `mime_set_crypto_stamp' to be called, and to + cause the various `decode_error' and `verify_error' slots to be set: + we don't actually use the returned HTML, because we're not emitting + HTML. It's maybe not such a good thing that the determination of + whether it was encrypted or not is tied up with generating HTML, + but oh well. */ + char *html = (((MimeEncryptedClass *) obj->clazz)->crypto_generate_html + (enc->crypto_closure)); + PR_FREEIF(html); + } if (enc->hdrs) - ct = MimeHeaders_get (enc->hdrs, HEADER_CONTENT_TYPE, PR_TRUE, PR_FALSE); + ct = MimeHeaders_get (enc->hdrs, HEADER_CONTENT_TYPE, PR_TRUE, PR_FALSE); body = mime_create((ct ? ct : TEXT_PLAIN), enc->hdrs, obj->options); - + #ifdef MIME_DRAFTS if (obj->options->decompose_file_p) { - if (mime_typep (body, (MimeObjectClass*) &mimeMultipartClass) ) - obj->options->is_multipart_msg = PR_TRUE; - else if (obj->options->decompose_file_init_fn) - obj->options->decompose_file_init_fn(obj->options->stream_closure, - enc->hdrs); + if (mime_typep (body, (MimeObjectClass*) &mimeMultipartClass) ) + obj->options->is_multipart_msg = PR_TRUE; + else if (obj->options->decompose_file_init_fn) + obj->options->decompose_file_init_fn(obj->options->stream_closure, + enc->hdrs); } #endif /* MIME_DRAFTS */ @@ -519,55 +518,55 @@ MimeEncrypted_emit_buffered_child(MimeObject *obj) if (!body) return MIME_OUT_OF_MEMORY; status = ((MimeContainerClass *) obj->clazz)->add_child (obj, body); if (status < 0) - { - mime_free(body); - return status; - } + { + mime_free(body); + return status; + } /* Now that we've added this new object to our list of children, - start its parser going. */ + start its parser going. */ status = body->clazz->parse_begin(body); if (status < 0) return status; /* If this object (or the parent) is being output, then by definition - the child is as well. (This is only necessary because this is such - a funny sort of container...) + the child is as well. (This is only necessary because this is such + a funny sort of container...) */ if (!body->output_p && - (obj->output_p || - (obj->parent && obj->parent->output_p))) - body->output_p = PR_TRUE; + (obj->output_p || + (obj->parent && obj->parent->output_p))) + body->output_p = PR_TRUE; /* If the body is being written raw (not as HTML) then make sure to - write its headers as well. */ + write its headers as well. */ if (body->output_p && obj->output_p && !obj->options->write_html_p) - { - status = MimeObject_write(body, "", 0, PR_FALSE); /* initialize */ - if (status < 0) return status; - status = MimeHeaders_write_raw_headers(body->headers, obj->options, - PR_FALSE); - if (status < 0) return status; - } + { + status = MimeObject_write(body, "", 0, PR_FALSE); /* initialize */ + if (status < 0) return status; + status = MimeHeaders_write_raw_headers(body->headers, obj->options, + PR_FALSE); + if (status < 0) return status; + } if (enc->part_buffer) /* part_buffer is 0 for 0-length encrypted data. */ #ifdef MIME_DRAFTS if (obj->options->decompose_file_p && !obj->options->is_multipart_msg) - status = MimePartBufferRead(enc->part_buffer, - /* The (nsresult (*) ...) cast is to turn the `void' - argument into `MimeObject'. */ - ((nsresult (*) (const char *, PRInt32, void *)) - obj->options->decompose_file_output_fn), - obj->options->stream_closure); + status = MimePartBufferRead(enc->part_buffer, + /* The (nsresult (*) ...) cast is to turn the `void' + argument into `MimeObject'. */ + ((nsresult (*) (const char *, PRInt32, void *)) + obj->options->decompose_file_output_fn), + obj->options->stream_closure); else #endif /* MIME_DRAFTS */ - status = MimePartBufferRead(enc->part_buffer, - /* The (nsresult (*) ...) cast is to turn the `void' - argument into `MimeObject'. */ - ((nsresult (*) (const char *, PRInt32, void *)) - body->clazz->parse_buffer), - body); + status = MimePartBufferRead(enc->part_buffer, + /* The (nsresult (*) ...) cast is to turn the `void' + argument into `MimeObject'. */ + ((nsresult (*) (const char *, PRInt32, void *)) + body->clazz->parse_buffer), + body); if (status < 0) return status; /* The child has been fully processed. Close it off. @@ -580,7 +579,7 @@ MimeEncrypted_emit_buffered_child(MimeObject *obj) #ifdef MIME_DRAFTS if (obj->options->decompose_file_p && !obj->options->is_multipart_msg) - obj->options->decompose_file_close_fn(obj->options->stream_closure); + obj->options->decompose_file_close_fn(obj->options->stream_closure); #endif /* MIME_DRAFTS */ /* Put out a separator after every encrypted object. */ diff --git a/mozilla/mailnews/mime/src/mimedrft.cpp b/mozilla/mailnews/mime/src/mimedrft.cpp index 1cf293e2b6a..1e3c6f61526 100644 --- a/mozilla/mailnews/mime/src/mimedrft.cpp +++ b/mozilla/mailnews/mime/src/mimedrft.cpp @@ -59,7 +59,6 @@ #include "nsIPrefService.h" #include "nsIPrefBranch.h" #include "msgCore.h" -#include "nsCRT.h" #include "nsEscape.h" #include "nsIMsgSend.h" #include "nsMimeStringResources.h" @@ -294,7 +293,7 @@ CreateCompositionFields(const char *from, NS_ENSURE_TRUE(cFields, NS_ERROR_OUT_OF_MEMORY); // Now set all of the passed in stuff... - cFields->SetCharacterSet(!nsCRT::strcasecmp("us-ascii", charset) ? "ISO-8859-1" : charset); + cFields->SetCharacterSet(!PL_strcasecmp("us-ascii", charset) ? "ISO-8859-1" : charset); char *val; @@ -543,7 +542,7 @@ mime_draft_process_attachments(mime_draft_data *mdd) { if (tmpFile->type) { - if (nsCRT::strcasecmp ( tmpFile->type, "text/x-vcard") == 0) + if (PL_strcasecmp ( tmpFile->type, "text/x-vcard") == 0) NS_MsgSACopy (&(tmp->real_name), tmpFile->description); } @@ -783,18 +782,18 @@ mime_insert_all_headers(char **body, /* Back up over whitespace before the colon. */ ocolon = colon; - for (; colon > head && nsCRT::IsAsciiSpace(colon[-1]); colon--) + for (; colon > head && IS_SPACE(colon[-1]); colon--) ; contents = ocolon + 1; } /* Skip over whitespace after colon. */ - while (contents <= end && nsCRT::IsAsciiSpace(*contents)) + while (contents <= end && IS_SPACE(*contents)) contents++; /* Take off trailing whitespace... */ - while (end > contents && nsCRT::IsAsciiSpace(end[-1])) + while (end > contents && IS_SPACE(end[-1])) end--; name = (char *)PR_MALLOC(colon - head + 1); @@ -815,15 +814,15 @@ mime_insert_all_headers(char **body, /* Do not reveal bcc recipients when forwarding a message! See http://bugzilla.mozilla.org/show_bug.cgi?id=41150 */ - if (nsCRT::strcasecmp(name, "bcc") != 0) + if (PL_strcasecmp(name, "bcc") != 0) { if (htmlEdit) mime_fix_up_html_address(&c2); - if (!nsCRT::strcasecmp(name, "resent-from") || !nsCRT::strcasecmp(name, "from") || - !nsCRT::strcasecmp(name, "resent-to") || !nsCRT::strcasecmp(name, "to") || - !nsCRT::strcasecmp(name, "resent-cc") || !nsCRT::strcasecmp(name, "cc") || - !nsCRT::strcasecmp(name, "reply-to")) + if (!PL_strcasecmp(name, "resent-from") || !PL_strcasecmp(name, "from") || + !PL_strcasecmp(name, "resent-to") || !PL_strcasecmp(name, "to") || + !PL_strcasecmp(name, "resent-cc") || !PL_strcasecmp(name, "cc") || + !PL_strcasecmp(name, "reply-to")) UnquoteMimeAddress(parser, &c2); mime_intl_insert_message_header_1(&newBody, &c2, name, name, mailcharset, htmlEdit); @@ -1273,7 +1272,7 @@ mime_parse_stream_complete (nsMIMESession *stream) if ((!mdd->mailcharset || charsetOverride) && mdd->options->default_charset) { PR_Free(mdd->mailcharset); - mdd->mailcharset = nsCRT::strdup(mdd->options->default_charset); + mdd->mailcharset = strdup(mdd->options->default_charset); } // mscott: aren't we leaking a bunch of strings here like the charset strings and such? @@ -1360,12 +1359,12 @@ mime_parse_stream_complete (nsMIMESession *stream) { char *parm = 0; parm = MimeHeaders_get_parameter(draftInfo, "vcard", NULL, NULL); - fields->SetAttachVCard(parm && !nsCRT::strcmp(parm, "1")); + fields->SetAttachVCard(parm && !strcmp(parm, "1")); fields->SetMessageId(id); // keep same message id for editing template. PR_FREEIF(parm); parm = MimeHeaders_get_parameter(draftInfo, "receipt", NULL, NULL); - if (parm && !nsCRT::strcmp(parm, "0")) + if (parm && !strcmp(parm, "0")) fields->SetReturnReceipt(PR_FALSE); else { @@ -1380,7 +1379,7 @@ mime_parse_stream_complete (nsMIMESession *stream) } PR_FREEIF(parm); parm = MimeHeaders_get_parameter(draftInfo, "uuencode", NULL, NULL); - fields->SetUuEncodeAttachments(parm && !nsCRT::strcmp(parm, "1")); + fields->SetUuEncodeAttachments(parm && !strcmp(parm, "1")); PR_FREEIF(parm); parm = MimeHeaders_get_parameter(draftInfo, "html", NULL, NULL); if (parm) @@ -1748,7 +1747,7 @@ mime_decompose_file_init_fn ( void *stream_closure, MimeHeaders *headers ) // if we've been told to use an override charset then do so....otherwise use the charset // inside the message header... if (mdd->options && mdd->options->override_charset) - mdd->mailcharset = nsCRT::strdup(mdd->options->default_charset); + mdd->mailcharset = strdup(mdd->options->default_charset); else { char *contentType = NULL; @@ -1807,9 +1806,9 @@ mime_decompose_file_init_fn ( void *stream_closure, MimeHeaders *headers ) contLoc = MimeHeaders_get( headers, HEADER_CONTENT_BASE, PR_FALSE, PR_FALSE ); if ( (!contLoc) && (newAttachment->real_name) ) - workURLSpec = nsCRT::strdup(newAttachment->real_name); + workURLSpec = strdup(newAttachment->real_name); if ( (contLoc) && (!workURLSpec) ) - workURLSpec = nsCRT::strdup(contLoc); + workURLSpec = strdup(contLoc); PR_FREEIF(contLoc); @@ -1843,7 +1842,7 @@ mime_decompose_file_init_fn ( void *stream_closure, MimeHeaders *headers ) // If we came up empty for description or the orig URL, we should do something about it. // if ( ( (!newAttachment->description) || (!*newAttachment->description) ) && (workURLSpec) ) - newAttachment->description = nsCRT::strdup(workURLSpec); + newAttachment->description = strdup(workURLSpec); nsCOMPtr tmpFile = nsnull; { @@ -1916,9 +1915,9 @@ mime_decompose_file_init_fn ( void *stream_closure, MimeHeaders *headers ) // if (!newAttachment->encoding) ; - else if (!nsCRT::strcasecmp(newAttachment->encoding, ENCODING_BASE64)) + else if (!PL_strcasecmp(newAttachment->encoding, ENCODING_BASE64)) fn = &MimeB64DecoderInit; - else if (!nsCRT::strcasecmp(newAttachment->encoding, ENCODING_QUOTED_PRINTABLE)) + else if (!PL_strcasecmp(newAttachment->encoding, ENCODING_QUOTED_PRINTABLE)) { mdd->decoder_data = MimeQPDecoderInit (/* The (nsresult (*) ...) cast is to turn the `void' argument into `MimeObject'. */ ((nsresult (*) (const char *, PRInt32, void *)) @@ -1926,12 +1925,12 @@ mime_decompose_file_init_fn ( void *stream_closure, MimeHeaders *headers ) if (!mdd->decoder_data) return MIME_OUT_OF_MEMORY; } - else if (!nsCRT::strcasecmp(newAttachment->encoding, ENCODING_UUENCODE) || - !nsCRT::strcasecmp(newAttachment->encoding, ENCODING_UUENCODE2) || - !nsCRT::strcasecmp(newAttachment->encoding, ENCODING_UUENCODE3) || - !nsCRT::strcasecmp(newAttachment->encoding, ENCODING_UUENCODE4)) + else if (!PL_strcasecmp(newAttachment->encoding, ENCODING_UUENCODE) || + !PL_strcasecmp(newAttachment->encoding, ENCODING_UUENCODE2) || + !PL_strcasecmp(newAttachment->encoding, ENCODING_UUENCODE3) || + !PL_strcasecmp(newAttachment->encoding, ENCODING_UUENCODE4)) fn = &MimeUUDecoderInit; - else if (!nsCRT::strcasecmp(newAttachment->encoding, ENCODING_YENCODE)) + else if (!PL_strcasecmp(newAttachment->encoding, ENCODING_YENCODE)) fn = &MimeYDecoderInit; if (fn) @@ -2058,7 +2057,7 @@ mime_bridge_create_draft_stream( if (!mdd->options) goto FAIL; - mdd->options->url = nsCRT::strdup(mdd->url_name); + mdd->options->url = strdup(mdd->url_name); mdd->options->format_out = format_out; // output format mdd->options->decompose_file_p = PR_TRUE; /* new field in MimeDisplayOptions */ mdd->options->stream_closure = mdd; diff --git a/mozilla/mailnews/mime/src/mimeebod.cpp b/mozilla/mailnews/mime/src/mimeebod.cpp index 3b15231168a..72405b4d112 100644 --- a/mozilla/mailnews/mime/src/mimeebod.cpp +++ b/mozilla/mailnews/mime/src/mimeebod.cpp @@ -39,7 +39,6 @@ #include "nsIURL.h" #include "mimeebod.h" #include "prmem.h" -#include "nsCRT.h" #include "plstr.h" #include "prlog.h" #include "prio.h" @@ -50,7 +49,7 @@ #define MIME_SUPERCLASS mimeObjectClass MimeDefClass(MimeExternalBody, MimeExternalBodyClass, - mimeExternalBodyClass, &MIME_SUPERCLASS); + mimeExternalBodyClass, &MIME_SUPERCLASS); #ifdef XP_MACOSX extern MimeObjectClass mimeMultipartAppleDoubleClass; @@ -61,7 +60,7 @@ static void MimeExternalBody_finalize (MimeObject *); static int MimeExternalBody_parse_line (const char *, PRInt32, MimeObject *); static int MimeExternalBody_parse_eof (MimeObject *, PRBool); static PRBool MimeExternalBody_displayable_inline_p (MimeObjectClass *clazz, - MimeHeaders *hdrs); + MimeHeaders *hdrs); #if 0 #if defined(DEBUG) && defined(XP_UNIX) @@ -102,10 +101,10 @@ MimeExternalBody_finalize (MimeObject *object) { MimeExternalBody *bod = (MimeExternalBody *) object; if (bod->hdrs) - { - MimeHeaders_free(bod->hdrs); - bod->hdrs = 0; - } + { + MimeHeaders_free(bod->hdrs); + bod->hdrs = 0; + } PR_FREEIF(bod->body); ((MimeObjectClass*)&MIME_SUPERCLASS)->finalize(object); @@ -123,46 +122,46 @@ MimeExternalBody_parse_line (const char *line, PRInt32 length, MimeObject *obj) if (!obj->output_p) return 0; /* If we're supposed to write this object, but aren't supposed to convert - it to HTML, simply pass it through unaltered. */ + it to HTML, simply pass it through unaltered. */ if (obj->options && - !obj->options->write_html_p && - obj->options->output_fn) - return MimeObject_write(obj, line, length, PR_TRUE); + !obj->options->write_html_p && + obj->options->output_fn) + return MimeObject_write(obj, line, length, PR_TRUE); /* If we already have a `body' then we're done parsing headers, and all - subsequent lines get tacked onto the body. */ + subsequent lines get tacked onto the body. */ if (bod->body) - { - int L = strlen(bod->body); - char *new_str = (char *)PR_Realloc(bod->body, L + length + 1); - if (!new_str) return MIME_OUT_OF_MEMORY; - bod->body = new_str; - memcpy(bod->body + L, line, length); - bod->body[L + length] = 0; - return 0; - } + { + int L = strlen(bod->body); + char *new_str = (char *)PR_Realloc(bod->body, L + length + 1); + if (!new_str) return MIME_OUT_OF_MEMORY; + bod->body = new_str; + memcpy(bod->body + L, line, length); + bod->body[L + length] = 0; + return 0; + } /* Otherwise we don't yet have a body, which means we're not done parsing - our headers. + our headers. */ if (!bod->hdrs) - { - bod->hdrs = MimeHeaders_new(); - if (!bod->hdrs) return MIME_OUT_OF_MEMORY; - } + { + bod->hdrs = MimeHeaders_new(); + if (!bod->hdrs) return MIME_OUT_OF_MEMORY; + } status = MimeHeaders_parse_line(line, length, bod->hdrs); if (status < 0) return status; /* If this line is blank, we're now done parsing headers, and should - create a dummy body to show that. Gag. + create a dummy body to show that. Gag. */ if (*line == '\r' || *line == '\n') - { - bod->body = nsCRT::strdup(""); - if (!bod->body) return MIME_OUT_OF_MEMORY; - } + { + bod->body = strdup(""); + if (!bod->body) return MIME_OUT_OF_MEMORY; + } return 0; } @@ -170,17 +169,17 @@ MimeExternalBody_parse_line (const char *line, PRInt32 length, MimeObject *obj) char * MimeExternalBody_make_url(const char *ct, - const char *at, const char *lexp, const char *size, - const char *perm, const char *dir, const char *mode, - const char *name, const char *url, const char *site, - const char *svr, const char *subj, const char *body) + const char *at, const char *lexp, const char *size, + const char *perm, const char *dir, const char *mode, + const char *name, const char *url, const char *site, + const char *svr, const char *subj, const char *body) { char *s; if (!at) { return 0; } - else if (!nsCRT::strcasecmp(at, "ftp") || !nsCRT::strcasecmp(at, "anon-ftp")) + else if (!PL_strcasecmp(at, "ftp") || !PL_strcasecmp(at, "anon-ftp")) { if (!site || !name) return 0; @@ -196,14 +195,14 @@ MimeExternalBody_make_url(const char *ct, PL_strcat(s, name); return s; } - else if (!nsCRT::strcasecmp(at, "local-file") || !nsCRT::strcasecmp(at, "afs")) + else if (!PL_strcasecmp(at, "local-file") || !PL_strcasecmp(at, "afs")) { char *s2; if (!name) return 0; - + #ifdef XP_UNIX - if (!nsCRT::strcasecmp(at, "afs")) /* only if there is a /afs/ directory */ + if (!PL_strcasecmp(at, "afs")) /* only if there is a /afs/ directory */ { nsCOMPtr fs = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID); PRBool exists = PR_FALSE; @@ -216,7 +215,7 @@ MimeExternalBody_make_url(const char *ct, return 0; } #else /* !XP_UNIX */ -return 0; /* never, if not Unix. */ +return 0; /* never, if not Unix. */ #endif /* !XP_UNIX */ s = (char *) PR_MALLOC(strlen(name)*3 + 20); @@ -227,11 +226,11 @@ s2 = nsEscape(name, url_Path); if (s2) { PL_strcat(s, s2); - nsCRT::free(s2); + NS_Free(s2); } return s; - } -else if (!nsCRT::strcasecmp(at, "mail-server")) + } +else if (!PL_strcasecmp(at, "mail-server")) { char *s2; if (!svr) @@ -241,40 +240,40 @@ else if (!nsCRT::strcasecmp(at, "mail-server")) (body ? strlen(body)*4 : 0) + 20); if (!s) return 0; PL_strcpy(s, "mailto:"); - + s2 = nsEscape(svr, url_XAlphas); if (s2) { PL_strcat(s, s2); - nsCRT::free(s2); + NS_Free(s2); } - + if (subj) - { - s2 = nsEscape(subj, url_XAlphas); - PL_strcat(s, "?subject="); - if (s2) - { + { + s2 = nsEscape(subj, url_XAlphas); + PL_strcat(s, "?subject="); + if (s2) + { PL_strcat(s, s2); - nsCRT::free(s2); - } - } + NS_Free(s2); + } + } if (body) - { - s2 = nsEscape(body, url_XAlphas); - PL_strcat(s, (subj ? "&body=" : "?body=")); - if (s2) - { + { + s2 = nsEscape(body, url_XAlphas); + PL_strcat(s, (subj ? "&body=" : "?body=")); + if (s2) + { PL_strcat(s, s2); - nsCRT::free(s2); - } - } + NS_Free(s2); + } + } return s; } -else if (!nsCRT::strcasecmp(at, "url")) /* RFC 2017 */ +else if (!PL_strcasecmp(at, "url")) /* RFC 2017 */ { if (url) - return nsCRT::strdup(url); /* it's already quoted and everything */ + return strdup(url); /* it's already quoted and everything */ else return 0; } @@ -287,19 +286,19 @@ MimeExternalBody_parse_eof (MimeObject *obj, PRBool abort_p) { int status = 0; MimeExternalBody *bod = (MimeExternalBody *) obj; - + if (obj->closed_p) return 0; - + /* Run parent method first, to flush out any buffered data. */ status = ((MimeObjectClass*)&MIME_SUPERCLASS)->parse_eof(obj, abort_p); if (status < 0) return status; - + #ifdef XP_MACOSX - if (obj->parent && mime_typep(obj->parent, + if (obj->parent && mime_typep(obj->parent, (MimeObjectClass*) &mimeMultipartAppleDoubleClass)) goto done; #endif /* XP_MACOSX */ - + if (!abort_p && obj->output_p && obj->options && @@ -307,16 +306,16 @@ MimeExternalBody_parse_eof (MimeObject *obj, PRBool abort_p) { PRBool all_headers_p = obj->options->headers == MimeHeadersAll; MimeDisplayOptions *newopt = obj->options; /* copy it */ - + char *ct = MimeHeaders_get(obj->headers, HEADER_CONTENT_TYPE, PR_FALSE, PR_FALSE); char *at, *lexp, *size, *perm; char *url, *dir, *mode, *name, *site, *svr, *subj; char *h = 0, *lname = 0, *lurl = 0, *body = 0; MimeHeaders *hdrs = 0; - + if (!ct) return MIME_OUT_OF_MEMORY; - + at = MimeHeaders_get_parameter(ct, "access-type", NULL, NULL); lexp = MimeHeaders_get_parameter(ct, "expiration", NULL, NULL); size = MimeHeaders_get_parameter(ct, "size", NULL, NULL); @@ -329,11 +328,11 @@ MimeExternalBody_parse_eof (MimeObject *obj, PRBool abort_p) subj = MimeHeaders_get_parameter(ct, "subject", NULL, NULL); url = MimeHeaders_get_parameter(ct, "url", NULL, NULL); PR_FREEIF(ct); - + /* the *internal* content-type */ ct = MimeHeaders_get(bod->hdrs, HEADER_CONTENT_TYPE, PR_TRUE, PR_FALSE); - + h = (char *) PR_MALLOC((at ? strlen(at) : 0) + (lexp ? strlen(lexp) : 0) + (size ? strlen(size) : 0) + @@ -351,7 +350,7 @@ MimeExternalBody_parse_eof (MimeObject *obj, PRBool abort_p) status = MIME_OUT_OF_MEMORY; goto FAIL; } - + /* If there's a URL parameter, remove all whitespace from it. (The URL parameter to one of these headers is stored with lines broken every 40 characters or less; it's assumed that @@ -362,18 +361,18 @@ MimeExternalBody_parse_eof (MimeObject *obj, PRBool abort_p) { char *in, *out; for (in = url, out = url; *in; in++) - if (!nsCRT::IsAsciiSpace(*in)) + if (!IS_SPACE(*in)) *out++ = *in; *out = 0; } - + hdrs = MimeHeaders_new(); if (!hdrs) { status = MIME_OUT_OF_MEMORY; goto FAIL; } - + # define FROB(STR,VAR) \ if (VAR) \ { \ @@ -383,23 +382,23 @@ MimeExternalBody_parse_eof (MimeObject *obj, PRBool abort_p) status = MimeHeaders_parse_line(h, strlen(h), hdrs); \ if (status < 0) goto FAIL; \ } - FROB("Access-Type", at); - FROB("URL", url); - FROB("Site", site); - FROB("Server", svr); - FROB("Directory", dir); - FROB("Name", name); - FROB("Type", ct); - FROB("Size", size); - FROB("Mode", mode); - FROB("Permission", perm); - FROB("Expiration", lexp); - FROB("Subject", subj); + FROB("Access-Type", at); + FROB("URL", url); + FROB("Site", site); + FROB("Server", svr); + FROB("Directory", dir); + FROB("Name", name); + FROB("Type", ct); + FROB("Size", size); + FROB("Mode", mode); + FROB("Permission", perm); + FROB("Expiration", lexp); + FROB("Subject", subj); # undef FROB PL_strcpy(h, MSG_LINEBREAK); status = MimeHeaders_parse_line(h, strlen(h), hdrs); if (status < 0) goto FAIL; - + lurl = MimeExternalBody_make_url(ct, at, lexp, size, perm, dir, mode, name, url, site, svr, subj, bod->body); if (lurl) @@ -411,20 +410,20 @@ MimeExternalBody_parse_eof (MimeObject *obj, PRBool abort_p) lname = MimeGetStringByID(MIME_MSG_DOCUMENT_INFO); all_headers_p = PR_TRUE; } - + all_headers_p = PR_TRUE; /* #### just do this all the time? */ - + if (bod->body && all_headers_p) { char *s = bod->body; - while (nsCRT::IsAsciiSpace(*s)) s++; + while (IS_SPACE(*s)) s++; if (*s) { char *s2; const char *pre = "

";
         const char *suf = "
"; PRInt32 i; - for(i = strlen(s)-1; i >= 0 && nsCRT::IsAsciiSpace(s[i]); i--) + for(i = strlen(s)-1; i >= 0 && IS_SPACE(s[i]); i--) s[i] = 0; s2 = nsEscapeHTML(s); if (!s2) goto FAIL; @@ -432,7 +431,7 @@ MimeExternalBody_parse_eof (MimeObject *obj, PRBool abort_p) strlen(suf) + 1); if (!body) { - nsCRT::free(s2); + NS_Free(s2); goto FAIL; } PL_strcpy(body, pre); @@ -440,10 +439,10 @@ MimeExternalBody_parse_eof (MimeObject *obj, PRBool abort_p) PL_strcat(body, suf); } } - + newopt->fancy_headers_p = PR_TRUE; newopt->headers = (all_headers_p ? MimeHeadersAll : MimeHeadersSome); - + FAIL: if (hdrs) MimeHeaders_free(hdrs); @@ -464,11 +463,11 @@ FAIL: PR_FREEIF(svr); PR_FREEIF(subj); } - + #ifdef XP_MACOSX done: #endif - + return status; } @@ -483,24 +482,24 @@ MimeExternalBody_debug_print (MimeObject *obj, PRFileDesc *stream, PRInt32 depth char *addr = mime_part_address(obj); if (obj->headers) - ct = MimeHeaders_get (obj->headers, HEADER_CONTENT_TYPE, PR_FALSE, PR_FALSE); + ct = MimeHeaders_get (obj->headers, HEADER_CONTENT_TYPE, PR_FALSE, PR_FALSE); if (bod->hdrs) - ct2 = MimeHeaders_get (bod->hdrs, HEADER_CONTENT_TYPE, PR_FALSE, PR_FALSE); + ct2 = MimeHeaders_get (bod->hdrs, HEADER_CONTENT_TYPE, PR_FALSE, PR_FALSE); for (i=0; i < depth; i++) - PR_Write(stream, " ", 2); + PR_Write(stream, " ", 2); /*** fprintf(stream, - "<%s %s\n" - "\tcontent-type: %s\n" - "\tcontent-type: %s\n" - "\tBody:%s\n\t0x%08X>\n\n", - obj->clazz->class_name, - addr ? addr : "???", - ct ? ct : "", - ct2 ? ct2 : "", - bod->body ? bod->body : "", - (PRUint32) obj); + "<%s %s\n" + "\tcontent-type: %s\n" + "\tcontent-type: %s\n" + "\tBody:%s\n\t0x%08X>\n\n", + obj->clazz->class_name, + addr ? addr : "???", + ct ? ct : "", + ct2 ? ct2 : "", + bod->body ? bod->body : "", + (PRUint32) obj); ***/ PR_FREEIF(addr); PR_FREEIF(ct); @@ -512,22 +511,22 @@ MimeExternalBody_debug_print (MimeObject *obj, PRFileDesc *stream, PRInt32 depth static PRBool MimeExternalBody_displayable_inline_p (MimeObjectClass *clazz, - MimeHeaders *hdrs) + MimeHeaders *hdrs) { char *ct = MimeHeaders_get (hdrs, HEADER_CONTENT_TYPE, PR_FALSE, PR_FALSE); char *at = MimeHeaders_get_parameter(ct, "access-type", NULL, NULL); PRBool inline_p = PR_FALSE; if (!at) - ; - else if (!nsCRT::strcasecmp(at, "ftp") || - !nsCRT::strcasecmp(at, "anon-ftp") || - !nsCRT::strcasecmp(at, "local-file") || - !nsCRT::strcasecmp(at, "mail-server") || - !nsCRT::strcasecmp(at, "url")) - inline_p = PR_TRUE; + ; + else if (!PL_strcasecmp(at, "ftp") || + !PL_strcasecmp(at, "anon-ftp") || + !PL_strcasecmp(at, "local-file") || + !PL_strcasecmp(at, "mail-server") || + !PL_strcasecmp(at, "url")) + inline_p = PR_TRUE; #ifdef XP_UNIX - else if (!nsCRT::strcasecmp(at, "afs")) /* only if there is a /afs/ directory */ + else if (!PL_strcasecmp(at, "afs")) /* only if there is a /afs/ directory */ { nsCOMPtr fs = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID); PRBool exists = PR_FALSE; diff --git a/mozilla/mailnews/mime/src/mimeenc.cpp b/mozilla/mailnews/mime/src/mimeenc.cpp index dd75f1d8aed..9b6d0860499 100644 --- a/mozilla/mailnews/mime/src/mimeenc.cpp +++ b/mozilla/mailnews/mime/src/mimeenc.cpp @@ -37,7 +37,6 @@ #include #include "modmimee.h" #include "mimei.h" -#include "nsCRT.h" #include "prmem.h" #include "plstr.h" #include "prlog.h" @@ -53,7 +52,7 @@ typedef enum mime_decoder_state { } mime_decoder_state; struct MimeDecoderData { - mime_encoding encoding; /* Which encoding to use */ + mime_encoding encoding; /* Which encoding to use */ /* A read-buffer used for QP and B64. */ char token[4]; @@ -75,8 +74,8 @@ static int mime_decode_qp_buffer (MimeDecoderData *data, const char *buffer, PRInt32 length) { /* Warning, we are overwriting the buffer which was passed in. - This is ok, because decoding these formats will never result - in larger data than the input, only smaller. */ + This is ok, because decoding these formats will never result + in larger data than the input, only smaller. */ const char *in = buffer; char *out = (char *) buffer; char token [3]; @@ -88,17 +87,17 @@ mime_decode_qp_buffer (MimeDecoderData *data, const char *buffer, PRInt32 length /* For the first pass, initialize the token from the unread-buffer. */ i = 0; while (i < 3 && data->token_size > 0) - { - token [i] = data->token[i]; - data->token_size--; - i++; - } + { + token [i] = data->token[i]; + data->token_size--; + i++; + } /* #### BUG: when decoding quoted-printable, we are required to - strip trailing whitespace from lines -- since when encoding in - qp, one is required to quote such trailing whitespace, any - trailing whitespace which remains must have been introduced - by a stupid gateway. */ + strip trailing whitespace from lines -- since when encoding in + qp, one is required to quote such trailing whitespace, any + trailing whitespace which remains must have been introduced + by a stupid gateway. */ /* Treat null bytes as spaces when format_out is nsMimeOutput::nsMimeMessageBodyDisplay (see bug 243199 comment 7) */ @@ -106,100 +105,100 @@ mime_decode_qp_buffer (MimeDecoderData *data, const char *buffer, PRInt32 length data->objectToDecode->options->format_out == nsMimeOutput::nsMimeMessageBodyDisplay; while (length > 0 || i != 0) - { - while (i < 3 && length > 0) - { - token [i++] = *in; - in++; - length--; - } + { + while (i < 3 && length > 0) + { + token [i++] = *in; + in++; + length--; + } - if (i < 3) - { - /* Didn't get enough for a complete token. - If it might be a token, unread it. - Otherwise, just dump it. - */ - memcpy (data->token, token, i); - data->token_size = i; - i = 0; - length = 0; - break; - } - i = 0; + if (i < 3) + { + /* Didn't get enough for a complete token. + If it might be a token, unread it. + Otherwise, just dump it. + */ + memcpy (data->token, token, i); + data->token_size = i; + i = 0; + length = 0; + break; + } + i = 0; - if (token [0] == '=') - { - unsigned char c = 0; - if (token[1] >= '0' && token[1] <= '9') - c = token[1] - '0'; - else if (token[1] >= 'A' && token[1] <= 'F') - c = token[1] - ('A' - 10); - else if (token[1] >= 'a' && token[1] <= 'f') - c = token[1] - ('a' - 10); - else if (token[1] == '\r' || token[1] == '\n') - { - /* =\n means ignore the newline. */ - if (token[1] == '\r' && token[2] == '\n') - ; /* swallow all three chars */ - else - { - in--; /* put the third char back */ - length++; - } - continue; - } - else - { - /* = followed by something other than hex or newline - - pass it through unaltered, I guess. (But, if - this bogus token happened to occur over a buffer - boundary, we can't do this, since we don't have - space for it. Oh well. Screw it.) */ - if (in > out) *out++ = token[0]; - if (in > out) *out++ = token[1]; - if (in > out) *out++ = token[2]; - continue; - } + if (token [0] == '=') + { + unsigned char c = 0; + if (token[1] >= '0' && token[1] <= '9') + c = token[1] - '0'; + else if (token[1] >= 'A' && token[1] <= 'F') + c = token[1] - ('A' - 10); + else if (token[1] >= 'a' && token[1] <= 'f') + c = token[1] - ('a' - 10); + else if (token[1] == '\r' || token[1] == '\n') + { + /* =\n means ignore the newline. */ + if (token[1] == '\r' && token[2] == '\n') + ; /* swallow all three chars */ + else + { + in--; /* put the third char back */ + length++; + } + continue; + } + else + { + /* = followed by something other than hex or newline - + pass it through unaltered, I guess. (But, if + this bogus token happened to occur over a buffer + boundary, we can't do this, since we don't have + space for it. Oh well. Screw it.) */ + if (in > out) *out++ = token[0]; + if (in > out) *out++ = token[1]; + if (in > out) *out++ = token[2]; + continue; + } - /* Second hex digit */ - c = (c << 4); - if (token[2] >= '0' && token[2] <= '9') - c += token[2] - '0'; - else if (token[2] >= 'A' && token[2] <= 'F') - c += token[2] - ('A' - 10); - else if (token[2] >= 'a' && token[2] <= 'f') - c += token[2] - ('a' - 10); - else - { - /* We got =xy where "x" was hex and "y" was not, so - treat that as a literal "=", x, and y. (But, if - this bogus token happened to occur over a buffer - boundary, we can't do this, since we don't have - space for it. Oh well. Screw it.) */ - if (in > out) *out++ = token[0]; - if (in > out) *out++ = token[1]; - if (in > out) *out++ = token[2]; - continue; - } + /* Second hex digit */ + c = (c << 4); + if (token[2] >= '0' && token[2] <= '9') + c += token[2] - '0'; + else if (token[2] >= 'A' && token[2] <= 'F') + c += token[2] - ('A' - 10); + else if (token[2] >= 'a' && token[2] <= 'f') + c += token[2] - ('a' - 10); + else + { + /* We got =xy where "x" was hex and "y" was not, so + treat that as a literal "=", x, and y. (But, if + this bogus token happened to occur over a buffer + boundary, we can't do this, since we don't have + space for it. Oh well. Screw it.) */ + if (in > out) *out++ = token[0]; + if (in > out) *out++ = token[1]; + if (in > out) *out++ = token[2]; + continue; + } - *out++ = c ? (char) c : ((treatNullAsSpace) ? ' ' : (char) c); - } - else - { - *out++ = token[0]; + *out++ = c ? (char) c : ((treatNullAsSpace) ? ' ' : (char) c); + } + else + { + *out++ = token[0]; - token[0] = token[1]; - token[1] = token[2]; - i = 2; - } - } + token[0] = token[1]; + token[1] = token[2]; + i = 2; + } + } /* Now that we've altered the data in place, write it. */ if (out > buffer) - return data->write_buffer (buffer, (out - buffer), data->closure); + return data->write_buffer (buffer, (out - buffer), data->closure); else - return 1; + return 1; } @@ -207,50 +206,50 @@ static int mime_decode_base64_token (const char *in, char *out) { /* reads 4, writes 0-3. Returns bytes written. - (Writes less than 3 only at EOF.) */ + (Writes less than 3 only at EOF.) */ int j; int eq_count = 0; unsigned long num = 0; for (j = 0; j < 4; j++) - { - unsigned char c = 0; - if (in[j] >= 'A' && in[j] <= 'Z') c = in[j] - 'A'; - else if (in[j] >= 'a' && in[j] <= 'z') c = in[j] - ('a' - 26); - else if (in[j] >= '0' && in[j] <= '9') c = in[j] - ('0' - 52); - else if (in[j] == '+') c = 62; - else if (in[j] == '/') c = 63; - else if (in[j] == '=') c = 0, eq_count++; - else - NS_ASSERTION(0, "1.1 19 Mar 1999 12:00"); - num = (num << 6) | c; - } + { + unsigned char c = 0; + if (in[j] >= 'A' && in[j] <= 'Z') c = in[j] - 'A'; + else if (in[j] >= 'a' && in[j] <= 'z') c = in[j] - ('a' - 26); + else if (in[j] >= '0' && in[j] <= '9') c = in[j] - ('0' - 52); + else if (in[j] == '+') c = 62; + else if (in[j] == '/') c = 63; + else if (in[j] == '=') c = 0, eq_count++; + else + NS_ASSERTION(0, "1.1 19 Mar 1999 12:00"); + num = (num << 6) | c; + } *out++ = (char) (num >> 16); *out++ = (char) ((num >> 8) & 0xFF); *out++ = (char) (num & 0xFF); if (eq_count == 0) - return 3; /* No "=" padding means 4 bytes mapped to 3. */ + return 3; /* No "=" padding means 4 bytes mapped to 3. */ else if (eq_count == 1) - return 2; /* "xxx=" means 3 bytes mapped to 2. */ + return 2; /* "xxx=" means 3 bytes mapped to 2. */ else if (eq_count == 2) - return 1; /* "xx==" means 2 bytes mapped to 1. */ + return 1; /* "xx==" means 2 bytes mapped to 1. */ else - { /* "x===" can't happen, because "x" would then */ - NS_ASSERTION(0, "1.1 19 Mar 1999 12:00"); /* be encoding only 6 bits, not the min of 8. */ - return 1; - } + { /* "x===" can't happen, because "x" would then */ + NS_ASSERTION(0, "1.1 19 Mar 1999 12:00"); /* be encoding only 6 bits, not the min of 8. */ + return 1; + } } static int mime_decode_base64_buffer (MimeDecoderData *data, - const char *buffer, PRInt32 length) + const char *buffer, PRInt32 length) { /* Warning, we are overwriting the buffer which was passed in. - This is ok, because decoding these formats will never result - in larger data than the input, only smaller. */ + This is ok, because decoding these formats will never result + in larger data than the input, only smaller. */ const char *in = buffer; char *out = (char *) buffer; char token [4]; @@ -262,83 +261,83 @@ mime_decode_base64_buffer (MimeDecoderData *data, /* For the first pass, initialize the token from the unread-buffer. */ i = 0; while (i < 4 && data->token_size > 0) - { - token [i] = data->token[i]; - data->token_size--; - i++; - } + { + token [i] = data->token[i]; + data->token_size--; + i++; + } while (length > 0) - { - while (i < 4 && length > 0) - { - if ((*in >= 'A' && *in <= 'Z') || - (*in >= 'a' && *in <= 'z') || - (*in >= '0' && *in <= '9') || - *in == '+' || *in == '/' || *in == '=') - token [i++] = *in; - in++; - length--; - } + { + while (i < 4 && length > 0) + { + if ((*in >= 'A' && *in <= 'Z') || + (*in >= 'a' && *in <= 'z') || + (*in >= '0' && *in <= '9') || + *in == '+' || *in == '/' || *in == '=') + token [i++] = *in; + in++; + length--; + } - if (i < 4) - { - /* Didn't get enough for a complete token. */ - memcpy (data->token, token, i); - data->token_size = i; - length = 0; - break; - } - i = 0; + if (i < 4) + { + /* Didn't get enough for a complete token. */ + memcpy (data->token, token, i); + data->token_size = i; + length = 0; + break; + } + i = 0; - if (leftover) - { - /* If there are characters left over from the last time around, - we might not have space in the buffer to do our dirty work - (if there were 2 or 3 left over, then there is only room for - 1 or 2 in the buffer right now, and we need 3.) This is only - a problem for the first chunk in each buffer, so in that - case, just write prematurely. */ - int n; - n = mime_decode_base64_token (token, token); - n = data->write_buffer (token, n, data->closure); - if (n < 0) /* abort */ - return n; + if (leftover) + { + /* If there are characters left over from the last time around, + we might not have space in the buffer to do our dirty work + (if there were 2 or 3 left over, then there is only room for + 1 or 2 in the buffer right now, and we need 3.) This is only + a problem for the first chunk in each buffer, so in that + case, just write prematurely. */ + int n; + n = mime_decode_base64_token (token, token); + n = data->write_buffer (token, n, data->closure); + if (n < 0) /* abort */ + return n; - /* increment buffer so that we don't write the 1 or 2 unused - characters now at the front. */ - buffer = in; - out = (char *) buffer; + /* increment buffer so that we don't write the 1 or 2 unused + characters now at the front. */ + buffer = in; + out = (char *) buffer; - leftover = PR_FALSE; - } - else - { - int n = mime_decode_base64_token (token, out); - /* Advance "out" by the number of bytes just written to it. */ - out += n; - } - } + leftover = PR_FALSE; + } + else + { + int n = mime_decode_base64_token (token, out); + /* Advance "out" by the number of bytes just written to it. */ + out += n; + } + } /* Now that we've altered the data in place, write it. */ if (out > buffer) - return data->write_buffer (buffer, (out - buffer), data->closure); + return data->write_buffer (buffer, (out - buffer), data->closure); else - return 1; + return 1; } static int mime_decode_uue_buffer (MimeDecoderData *data, - const char *input_buffer, PRInt32 input_length) + const char *input_buffer, PRInt32 input_length) { /* First, copy input_buffer into state->line_buffer until we have - a complete line. + a complete line. - Then decode that line in place (in the line_buffer) and write - it out. + Then decode that line in place (in the line_buffer) and write + it out. - Then pull the next line into line_buffer and continue. + Then pull the next line into line_buffer and continue. */ if (!data->line_buffer) { @@ -357,202 +356,202 @@ mime_decode_uue_buffer (MimeDecoderData *data, if (data->encoding != mime_uuencode) return -1; if (data->ds_state == DS_END) - { - status = 0; - goto DONE; - } + { + status = 0; + goto DONE; + } while (input_length > 0) - { - /* Copy data from input_buffer to `line' until we have a complete line, - or until we've run out of input. + { + /* Copy data from input_buffer to `line' until we have a complete line, + or until we've run out of input. - (line may have data in it already if the last time we were called, - we weren't called with a buffer that ended on a line boundary.) - */ - { - char *out = line + strlen(line); - while (input_length > 0 && - out < line_end) - { - *out++ = *input_buffer++; - input_length--; + (line may have data in it already if the last time we were called, + we weren't called with a buffer that ended on a line boundary.) + */ + { + char *out = line + strlen(line); + while (input_length > 0 && + out < line_end) + { + *out++ = *input_buffer++; + input_length--; - if (out[-1] == '\r' || out[-1] == '\n') - { - /* If we just copied a CR, and an LF is waiting, grab it too. - */ - if (out[-1] == '\r' && - input_length > 0 && - *input_buffer == '\n') - input_buffer++, input_length--; + if (out[-1] == '\r' || out[-1] == '\n') + { + /* If we just copied a CR, and an LF is waiting, grab it too. + */ + if (out[-1] == '\r' && + input_length > 0 && + *input_buffer == '\n') + input_buffer++, input_length--; - /* We have a line. */ - break; - } - } - *out = 0; + /* We have a line. */ + break; + } + } + *out = 0; - /* Ignore blank lines. - */ - if (*line == '\r' || *line == '\n') - { - *line = 0; - continue; - } + /* Ignore blank lines. + */ + if (*line == '\r' || *line == '\n') + { + *line = 0; + continue; + } - /* If this line was bigger than our buffer, truncate it. - (This means the data was way corrupted, and there's basically - no chance of decoding it properly, but give it a shot anyway.) - */ - if (out == line_end) - { - out--; - out[-1] = '\r'; - out[0] = 0; - } + /* If this line was bigger than our buffer, truncate it. + (This means the data was way corrupted, and there's basically + no chance of decoding it properly, but give it a shot anyway.) + */ + if (out == line_end) + { + out--; + out[-1] = '\r'; + out[0] = 0; + } - /* If we didn't get a complete line, simply return; we'll be called - with the rest of this line next time. - */ - if (out[-1] != '\r' && out[-1] != '\n') - { - NS_ASSERTION (input_length == 0, "1.1 19 Mar 1999 12:00"); - break; - } - } + /* If we didn't get a complete line, simply return; we'll be called + with the rest of this line next time. + */ + if (out[-1] != '\r' && out[-1] != '\n') + { + NS_ASSERTION (input_length == 0, "1.1 19 Mar 1999 12:00"); + break; + } + } - /* Now we have a complete line. Deal with it. - */ + /* Now we have a complete line. Deal with it. + */ - if (data->ds_state == DS_BODY && - line[0] == 'e' && - line[1] == 'n' && - line[2] == 'd' && - (line[3] == '\r' || - line[3] == '\n')) - { - /* done! */ - data->ds_state = DS_END; - *line = 0; - break; - } - else if (data->ds_state == DS_BEGIN) - { - if (!strncmp (line, "begin ", 6)) - data->ds_state = DS_BODY; - *line = 0; - continue; - } - else - { - /* We're in DS_BODY. Decode the line. */ - char *in, *out; - PRInt32 i; - long lost; + if (data->ds_state == DS_BODY && + line[0] == 'e' && + line[1] == 'n' && + line[2] == 'd' && + (line[3] == '\r' || + line[3] == '\n')) + { + /* done! */ + data->ds_state = DS_END; + *line = 0; + break; + } + else if (data->ds_state == DS_BEGIN) + { + if (!strncmp (line, "begin ", 6)) + data->ds_state = DS_BODY; + *line = 0; + continue; + } + else + { + /* We're in DS_BODY. Decode the line. */ + char *in, *out; + PRInt32 i; + long lost; - NS_ASSERTION (data->ds_state == DS_BODY, "1.1 19 Mar 1999 12:00"); + NS_ASSERTION (data->ds_state == DS_BODY, "1.1 19 Mar 1999 12:00"); - /* We map down `line', reading four bytes and writing three. - That means that `out' always stays safely behind `in'. - */ - in = line; - out = line; + /* We map down `line', reading four bytes and writing three. + That means that `out' always stays safely behind `in'. + */ + in = line; + out = line; # undef DEC # define DEC(c) (((c) - ' ') & 077) - i = DEC (*in); /* get length */ + i = DEC (*in); /* get length */ - /* all the parens and casts are because gcc was doing something evil. - */ - lost = ((long) i) - (((((long) strlen (in)) - 2L) * 3L) / 4L); + /* all the parens and casts are because gcc was doing something evil. + */ + lost = ((long) i) - (((((long) strlen (in)) - 2L) * 3L) / 4L); - if (lost > 0) /* Short line!! */ - { - /* If we get here, then the line is shorter than the length byte - at the beginning says it should be. However, the case where - the line is short because it was at the end of the buffer and - we didn't get the whole line was handled earlier (up by the - "didn't get a complete line" comment.) So if we've gotten - here, then this is a complete line which is internally - inconsistent. We will parse from it what we can... + if (lost > 0) /* Short line!! */ + { + /* If we get here, then the line is shorter than the length byte + at the beginning says it should be. However, the case where + the line is short because it was at the end of the buffer and + we didn't get the whole line was handled earlier (up by the + "didn't get a complete line" comment.) So if we've gotten + here, then this is a complete line which is internally + inconsistent. We will parse from it what we can... - This probably happened because some gateway stripped trailing - whitespace from the end of the line -- so pretend the line - was padded with spaces (which map to \000.) - */ - i -= lost; - } + This probably happened because some gateway stripped trailing + whitespace from the end of the line -- so pretend the line + was padded with spaces (which map to \000.) + */ + i -= lost; + } - for (++in; i > 0; in += 4, i -= 3) - { - char ch; - NS_ASSERTION(out <= in, "1.1 19 Mar 1999 12:00"); + for (++in; i > 0; in += 4, i -= 3) + { + char ch; + NS_ASSERTION(out <= in, "1.1 19 Mar 1999 12:00"); - if (i >= 3) - { - /* We read four; write three. */ - ch = DEC (in[0]) << 2 | DEC (in[1]) >> 4; - *out++ = ch; + if (i >= 3) + { + /* We read four; write three. */ + ch = DEC (in[0]) << 2 | DEC (in[1]) >> 4; + *out++ = ch; - NS_ASSERTION(out <= in+1, "1.1 19 Mar 1999 12:00"); + NS_ASSERTION(out <= in+1, "1.1 19 Mar 1999 12:00"); - ch = DEC (in[1]) << 4 | DEC (in[2]) >> 2; - *out++ = ch; + ch = DEC (in[1]) << 4 | DEC (in[2]) >> 2; + *out++ = ch; - NS_ASSERTION(out <= in+2, "1.1 19 Mar 1999 12:00"); + NS_ASSERTION(out <= in+2, "1.1 19 Mar 1999 12:00"); - ch = DEC (in[2]) << 6 | DEC (in[3]); - *out++ = ch; + ch = DEC (in[2]) << 6 | DEC (in[3]); + *out++ = ch; - NS_ASSERTION(out <= in+3, "1.1 19 Mar 1999 12:00"); - } - else - { - /* Handle a line that isn't a multiple of 4 long. - (We read 1, 2, or 3, and will write 1 or 2.) - */ - NS_ASSERTION (i > 0 && i < 3, "1.1 19 Mar 1999 12:00"); + NS_ASSERTION(out <= in+3, "1.1 19 Mar 1999 12:00"); + } + else + { + /* Handle a line that isn't a multiple of 4 long. + (We read 1, 2, or 3, and will write 1 or 2.) + */ + NS_ASSERTION (i > 0 && i < 3, "1.1 19 Mar 1999 12:00"); - ch = DEC (in[0]) << 2 | DEC (in[1]) >> 4; - *out++ = ch; + ch = DEC (in[0]) << 2 | DEC (in[1]) >> 4; + *out++ = ch; - NS_ASSERTION(out <= in+1, "1.1 19 Mar 1999 12:00"); + NS_ASSERTION(out <= in+1, "1.1 19 Mar 1999 12:00"); - if (i == 2) - { - ch = DEC (in[1]) << 4 | DEC (in[2]) >> 2; - *out++ = ch; + if (i == 2) + { + ch = DEC (in[1]) << 4 | DEC (in[2]) >> 2; + *out++ = ch; - NS_ASSERTION(out <= in+2, "1.1 19 Mar 1999 12:00"); - } - } - } + NS_ASSERTION(out <= in+2, "1.1 19 Mar 1999 12:00"); + } + } + } - /* If the line was truncated, pad the missing bytes with 0 (SPC). */ - while (lost > 0) - { - *out++ = 0; - lost--; - in = out+1; /* just to prevent the assert, below. */ - } + /* If the line was truncated, pad the missing bytes with 0 (SPC). */ + while (lost > 0) + { + *out++ = 0; + lost--; + in = out+1; /* just to prevent the assert, below. */ + } # undef DEC - /* Now write out what we decoded for this line. - */ - NS_ASSERTION(out >= line && out < in, "1.1 19 Mar 1999 12:00"); - if (out > line) - status = data->write_buffer (line, (out - line), data->closure); + /* Now write out what we decoded for this line. + */ + NS_ASSERTION(out >= line && out < in, "1.1 19 Mar 1999 12:00"); + if (out > line) + status = data->write_buffer (line, (out - line), data->closure); - /* Reset the line so that we don't think it's partial next time. */ - *line = 0; + /* Reset the line so that we don't think it's partial next time. */ + *line = 0; - if (status < 0) /* abort */ - goto DONE; - } - } + if (status < 0) /* abort */ + goto DONE; + } + } status = 1; @@ -563,15 +562,15 @@ mime_decode_uue_buffer (MimeDecoderData *data, static int mime_decode_yenc_buffer (MimeDecoderData *data, - const char *input_buffer, PRInt32 input_length) + const char *input_buffer, PRInt32 input_length) { /* First, copy input_buffer into state->line_buffer until we have - a complete line. + a complete line. - Then decode that line in place (in the line_buffer) and write - it out. + Then decode that line in place (in the line_buffer) and write + it out. - Then pull the next line into line_buffer and continue. + Then pull the next line into line_buffer and continue. */ if (!data->line_buffer) { @@ -650,17 +649,17 @@ mime_decode_yenc_buffer (MimeDecoderData *data, } - /* Now we have a complete line. Deal with it. - */ + /* Now we have a complete line. Deal with it. + */ const char * endOfLine = line + strlen(line); - if (data->ds_state == DS_BEGIN) - { + if (data->ds_state == DS_BEGIN) + { int new_line_size = 0; /* this yenc decoder does not support yenc v2 or multipart yenc. Therefore, we are looking first for "=ybegin line=" */ - if ((endOfLine - line) >= 13 && !strncmp (line, "=ybegin line=", 13)) + if ((endOfLine - line) >= 13 && !strncmp (line, "=ybegin line=", 13)) { /* ...then couple digits. */ for (line += 13; line < endOfLine; line ++) @@ -684,7 +683,7 @@ mime_decode_yenc_buffer (MimeDecoderData *data, /* we have found the yenc header line. Now check if we need to grow our buffer line */ - data->ds_state = DS_BODY; + data->ds_state = DS_BODY; if (new_line_size > data->line_buffer_size && new_line_size <= 997) /* don't let bad value hurt us! */ { PR_Free(data->line_buffer); @@ -697,21 +696,21 @@ mime_decode_yenc_buffer (MimeDecoderData *data, } } - *data->line_buffer = 0; - continue; - } + *data->line_buffer = 0; + continue; + } if (data->ds_state == DS_BODY && line[0] == '=') { /* look if this this the final line */ - if (!strncmp (line, "=yend size=", 11)) + if (!strncmp (line, "=yend size=", 11)) { - /* done! */ - data->ds_state = DS_END; - *line = 0; - break; + /* done! */ + data->ds_state = DS_END; + *line = 0; + break; } - } + } /* We're in DS_BODY. Decode the line in place. */ { @@ -736,18 +735,18 @@ mime_decode_yenc_buffer (MimeDecoderData *data, *dest = c; dest ++; } - - /* Now write out what we decoded for this line. */ - NS_ASSERTION(dest >= line && dest < src, "nothing to write!"); - if (dest > line) + + /* Now write out what we decoded for this line. */ + NS_ASSERTION(dest >= line && dest < src, "nothing to write!"); + if (dest > line) { - status = data->write_buffer (line, dest - line, data->closure); - if (status < 0) /* abort */ - return status; + status = data->write_buffer (line, dest - line, data->closure); + if (status < 0) /* abort */ + return status; } - /* Reset the line so that we don't think it's partial next time. */ - *line = 0; + /* Reset the line so that we don't think it's partial next time. */ + *line = 0; } } @@ -760,16 +759,16 @@ MimeDecoderDestroy (MimeDecoderData *data, PRBool abort_p) int status = 0; /* Flush out the last few buffered characters. */ if (!abort_p && - data->token_size > 0 && - data->token[0] != '=') - { - if (data->encoding == mime_Base64) - while ((unsigned int)data->token_size < sizeof (data->token)) - data->token [data->token_size++] = '='; + data->token_size > 0 && + data->token[0] != '=') + { + if (data->encoding == mime_Base64) + while ((unsigned int)data->token_size < sizeof (data->token)) + data->token [data->token_size++] = '='; - status = data->write_buffer (data->token, data->token_size, - data->closure); - } + status = data->write_buffer (data->token, data->token_size, + data->closure); + } if (data->line_buffer) PR_Free(data->line_buffer); @@ -780,8 +779,8 @@ MimeDecoderDestroy (MimeDecoderData *data, PRBool abort_p) static MimeDecoderData * mime_decoder_init (mime_encoding which, - nsresult (*output_fn) (const char *, PRInt32, void *), - void *closure) + nsresult (*output_fn) (const char *, PRInt32, void *), + void *closure) { MimeDecoderData *data = PR_NEW(MimeDecoderData); if (!data) return 0; @@ -797,14 +796,14 @@ mime_decoder_init (mime_encoding which, MimeDecoderData * MimeB64DecoderInit (nsresult (*output_fn) (const char *, PRInt32, void *), - void *closure) + void *closure) { return mime_decoder_init (mime_Base64, output_fn, closure); } MimeDecoderData * MimeQPDecoderInit (nsresult (*output_fn) (const char *, PRInt32, void *), - void *closure, MimeObject *object) + void *closure, MimeObject *object) { MimeDecoderData *retData = mime_decoder_init (mime_QuotedPrintable, output_fn, closure); if (retData) @@ -814,14 +813,14 @@ MimeQPDecoderInit (nsresult (*output_fn) (const char *, PRInt32, void *), MimeDecoderData * MimeUUDecoderInit (nsresult (*output_fn) (const char *, PRInt32, void *), - void *closure) + void *closure) { return mime_decoder_init (mime_uuencode, output_fn, closure); } MimeDecoderData * MimeYDecoderInit (nsresult (*output_fn) (const char *, PRInt32, void *), - void *closure) + void *closure) { return mime_decoder_init (mime_yencode, output_fn, closure); } @@ -832,19 +831,19 @@ MimeDecoderWrite (MimeDecoderData *data, const char *buffer, PRInt32 size) NS_ASSERTION(data, "1.1 19 Mar 1999 12:00"); if (!data) return -1; switch(data->encoding) - { - case mime_Base64: - return mime_decode_base64_buffer (data, buffer, size); - case mime_QuotedPrintable: - return mime_decode_qp_buffer (data, buffer, size); - case mime_uuencode: - return mime_decode_uue_buffer (data, buffer, size); - case mime_yencode: - return mime_decode_yenc_buffer (data, buffer, size); - default: - NS_ASSERTION(0, "1.1 19 Mar 1999 12:00"); - return -1; - } + { + case mime_Base64: + return mime_decode_base64_buffer (data, buffer, size); + case mime_QuotedPrintable: + return mime_decode_qp_buffer (data, buffer, size); + case mime_uuencode: + return mime_decode_uue_buffer (data, buffer, size); + case mime_yencode: + return mime_decode_yenc_buffer (data, buffer, size); + default: + NS_ASSERTION(0, "1.1 19 Mar 1999 12:00"); + return -1; + } } @@ -853,18 +852,18 @@ MimeDecoderWrite (MimeDecoderData *data, const char *buffer, PRInt32 size) */ struct MimeEncoderData { - mime_encoding encoding; /* Which encoding to use */ + mime_encoding encoding; /* Which encoding to use */ /* Buffer for the base64 encoder. */ unsigned char in_buffer[3]; PRInt32 in_buffer_count; - /* Buffer for uuencoded data. (Need a line because of the length byte.) */ - unsigned char uue_line_buf[128]; - PRBool uue_wrote_begin; - + /* Buffer for uuencoded data. (Need a line because of the length byte.) */ + unsigned char uue_line_buf[128]; + PRBool uue_wrote_begin; + PRInt32 current_column, line_byte_count; - + char *filename; /* filename for use with uuencoding */ /* Where to write the encoded data */ @@ -881,125 +880,125 @@ struct MimeEncoderData { void mime_uuencode_write_line(MimeEncoderData *data) { - /* Set the length byte at the beginning: - encoded (data->line_byte_count). */ - data->uue_line_buf[0] = ENC(data->line_byte_count); + /* Set the length byte at the beginning: + encoded (data->line_byte_count). */ + data->uue_line_buf[0] = ENC(data->line_byte_count); - /* Tack a CRLF onto the end. */ - data->uue_line_buf[data->current_column++] = '\r'; - data->uue_line_buf[data->current_column++] = '\n'; + /* Tack a CRLF onto the end. */ + data->uue_line_buf[data->current_column++] = '\r'; + data->uue_line_buf[data->current_column++] = '\n'; - /* Write the line to output. */ - data->write_buffer((const char*)data->uue_line_buf, data->current_column, - data->closure); + /* Write the line to output. */ + data->write_buffer((const char*)data->uue_line_buf, data->current_column, + data->closure); - /* Reset data based on having just written a complete line. */ - data->in_buffer_count = 0; - data->line_byte_count = 0; - data->current_column = 1; + /* Reset data based on having just written a complete line. */ + data->in_buffer_count = 0; + data->line_byte_count = 0; + data->current_column = 1; } void mime_uuencode_convert_triplet(MimeEncoderData *data) { - /* - If we have 3 bytes, encode them and add them to the current - line. The way we want to encode them is like this - (each digit corresponds to a bit in the binary source): - 11111111 -> 00111111 + ' ' (six highest bits of 1) - 22222222 00112222 + ' ' (low 2 of 1, high 4 of 2) - 33333333 00222233 + ' ' (low 4 of 2, high 2 of 3) - 00333333 + ' ' (low 6 of 3) - */ - char outData[4]; - int i; - - outData[0] = data->in_buffer[0] >> 2; - - outData[1] = ((data->in_buffer[0] << 4) & 0x30); - outData[1] |= data->in_buffer[1] >> 4; + /* + If we have 3 bytes, encode them and add them to the current + line. The way we want to encode them is like this + (each digit corresponds to a bit in the binary source): + 11111111 -> 00111111 + ' ' (six highest bits of 1) + 22222222 00112222 + ' ' (low 2 of 1, high 4 of 2) + 33333333 00222233 + ' ' (low 4 of 2, high 2 of 3) + 00333333 + ' ' (low 6 of 3) + */ + char outData[4]; + int i; - outData[2] = ((data->in_buffer[1] << 2) & 0x3C); - outData[2] |= data->in_buffer[2] >> 6; + outData[0] = data->in_buffer[0] >> 2; - outData[3] = data->in_buffer[2] & 0x3F; + outData[1] = ((data->in_buffer[0] << 4) & 0x30); + outData[1] |= data->in_buffer[1] >> 4; - for(i=0;i<4;i++) - data->uue_line_buf[data->current_column++] = ENC(outData[i]); + outData[2] = ((data->in_buffer[1] << 2) & 0x3C); + outData[2] |= data->in_buffer[2] >> 6; - data->in_buffer_count = 0; + outData[3] = data->in_buffer[2] & 0x3F; + + for(i=0;i<4;i++) + data->uue_line_buf[data->current_column++] = ENC(outData[i]); + + data->in_buffer_count = 0; } int mime_uuencode_buffer(MimeEncoderData *data, - const char *buffer, PRInt32 size) + const char *buffer, PRInt32 size) { - /* If this is the first time through, write a begin statement. */ - if (!(data->uue_wrote_begin)) - { - char firstLine[256]; - PR_snprintf(firstLine, sizeof(firstLine), "begin 644 %s\015\012", data->filename ? data->filename : ""); - data->write_buffer(firstLine, strlen(firstLine), data->closure); - data->uue_wrote_begin = PR_TRUE; - data->current_column = 1; /* initialization unique to uuencode */ - } + /* If this is the first time through, write a begin statement. */ + if (!(data->uue_wrote_begin)) + { + char firstLine[256]; + PR_snprintf(firstLine, sizeof(firstLine), "begin 644 %s\015\012", data->filename ? data->filename : ""); + data->write_buffer(firstLine, strlen(firstLine), data->closure); + data->uue_wrote_begin = PR_TRUE; + data->current_column = 1; /* initialization unique to uuencode */ + } - /* Pick up where we left off. */ - while(size > 0) - { - /* If we've reached the end of a line, write the line out. */ - if (data->current_column >= UUENCODE_LINE_LIMIT) - { - /* End of a line. Write the line out. */ - mime_uuencode_write_line(data); - } + /* Pick up where we left off. */ + while(size > 0) + { + /* If we've reached the end of a line, write the line out. */ + if (data->current_column >= UUENCODE_LINE_LIMIT) + { + /* End of a line. Write the line out. */ + mime_uuencode_write_line(data); + } - /* Get the next 3 bytes if we have them, or whatever we can get. */ - while(size > 0 && data->in_buffer_count < 3) - { - data->in_buffer[data->in_buffer_count++] = *(buffer++); - size--; data->line_byte_count++; - } - - if (data->in_buffer_count == 3) - { - mime_uuencode_convert_triplet(data); - } - } - return 0; + /* Get the next 3 bytes if we have them, or whatever we can get. */ + while(size > 0 && data->in_buffer_count < 3) + { + data->in_buffer[data->in_buffer_count++] = *(buffer++); + size--; data->line_byte_count++; + } + + if (data->in_buffer_count == 3) + { + mime_uuencode_convert_triplet(data); + } + } + return 0; } int mime_uuencode_finish(MimeEncoderData *data) { - int i; - static const char *endStr = "end\015\012"; + int i; + static const char *endStr = "end\015\012"; - /* If we have converted binary data to write to output, do it now. */ - if (data->line_byte_count > 0) - { - /* If we have binary data yet to be converted, - pad and convert it. */ - if (data->in_buffer_count > 0) - { - for(i=data->in_buffer_count;i<3;i++) - data->in_buffer[i] = '\0'; /* pad with zeroes */ + /* If we have converted binary data to write to output, do it now. */ + if (data->line_byte_count > 0) + { + /* If we have binary data yet to be converted, + pad and convert it. */ + if (data->in_buffer_count > 0) + { + for(i=data->in_buffer_count;i<3;i++) + data->in_buffer[i] = '\0'; /* pad with zeroes */ - mime_uuencode_convert_triplet(data); - } + mime_uuencode_convert_triplet(data); + } - mime_uuencode_write_line(data); - } + mime_uuencode_write_line(data); + } - /* Write 'end' on a line by itself. */ - return data->write_buffer(endStr, strlen(endStr), data->closure); + /* Write 'end' on a line by itself. */ + return data->write_buffer(endStr, strlen(endStr), data->closure); } #undef ENC int mime_encode_base64_buffer (MimeEncoderData *data, - const char *buffer, PRInt32 size) + const char *buffer, PRInt32 size) { int status = 0; const unsigned char *in = (unsigned char *) buffer; @@ -1010,24 +1009,24 @@ mime_encode_base64_buffer (MimeEncoderData *data, PRUint32 off; if (size == 0) - return 0; + return 0; else if (size < 0) - { - NS_ASSERTION(0, "1.1 19 Mar 1999 12:00"); - return -1; - } + { + NS_ASSERTION(0, "1.1 19 Mar 1999 12:00"); + return -1; + } /* If this input buffer is too small, wait until next time. */ if (size < (3 - data->in_buffer_count)) - { - NS_ASSERTION(size < 3 && size > 0, "1.1 19 Mar 1999 12:00"); - data->in_buffer[data->in_buffer_count++] = buffer[0]; - if (size > 1) - data->in_buffer[data->in_buffer_count++] = buffer[1]; - NS_ASSERTION(data->in_buffer_count < 3, "1.1 19 Mar 1999 12:00"); - return 0; - } + { + NS_ASSERTION(size < 3 && size > 0, "1.1 19 Mar 1999 12:00"); + data->in_buffer[data->in_buffer_count++] = buffer[0]; + if (size > 1) + data->in_buffer[data->in_buffer_count++] = buffer[1]; + NS_ASSERTION(data->in_buffer_count < 3, "1.1 19 Mar 1999 12:00"); + return 0; + } /* If there are bytes that were put back last time, take them now. @@ -1042,61 +1041,61 @@ mime_encode_base64_buffer (MimeEncoderData *data, */ off = ((size + i) % 3); if (off) - { - data->in_buffer[0] = buffer [size - off]; - if (off > 1) - data->in_buffer [1] = buffer [size - off + 1]; - data->in_buffer_count = off; - size -= off; - NS_ASSERTION (! ((size + i) % 3), "1.1 19 Mar 1999 12:00"); - end = (unsigned char *) (buffer + size); - } + { + data->in_buffer[0] = buffer [size - off]; + if (off > 1) + data->in_buffer [1] = buffer [size - off + 1]; + data->in_buffer_count = off; + size -= off; + NS_ASSERTION (! ((size + i) % 3), "1.1 19 Mar 1999 12:00"); + end = (unsigned char *) (buffer + size); + } /* Populate the out_buffer with base64 data, one line at a time. */ while (in < end) - { - PRInt32 j; + { + PRInt32 j; - while (i < 3) - { - n = (n << 8) | *in++; - i++; - } - i = 0; + while (i < 3) + { + n = (n << 8) | *in++; + i++; + } + i = 0; - for (j = 18; j >= 0; j -= 6) - { - unsigned int k = (n >> j) & 0x3F; - if (k < 26) *out++ = k + 'A'; - else if (k < 52) *out++ = k - 26 + 'a'; - else if (k < 62) *out++ = k - 52 + '0'; - else if (k == 62) *out++ = '+'; - else if (k == 63) *out++ = '/'; - else abort (); - } + for (j = 18; j >= 0; j -= 6) + { + unsigned int k = (n >> j) & 0x3F; + if (k < 26) *out++ = k + 'A'; + else if (k < 52) *out++ = k - 26 + 'a'; + else if (k < 62) *out++ = k - 52 + '0'; + else if (k == 62) *out++ = '+'; + else if (k == 63) *out++ = '/'; + else abort (); + } - data->current_column += 4; - if (data->current_column >= 72) - { - /* Do a linebreak before column 76. Flush out the line buffer. */ - data->current_column = 0; - *out++ = '\015'; - *out++ = '\012'; - status = data->write_buffer (out_buffer, (out - out_buffer), - data->closure); - out = out_buffer; - if (status < 0) return status; - } - } + data->current_column += 4; + if (data->current_column >= 72) + { + /* Do a linebreak before column 76. Flush out the line buffer. */ + data->current_column = 0; + *out++ = '\015'; + *out++ = '\012'; + status = data->write_buffer (out_buffer, (out - out_buffer), + data->closure); + out = out_buffer; + if (status < 0) return status; + } + } /* Write out the unwritten portion of the last line buffer. */ if (out > out_buffer) - { - status = data->write_buffer (out_buffer, (out - out_buffer), - data->closure); - if (status < 0) return status; - } + { + status = data->write_buffer (out_buffer, (out - out_buffer), + data->closure); + if (status < 0) return status; + } return 0; } @@ -1113,67 +1112,67 @@ mime_encode_qp_buffer (MimeEncoderData *data, const char *buffer, PRInt32 size) char *out = out_buffer; PRBool white = PR_FALSE; PRBool mb_p = PR_FALSE; - + /* #### I don't know how to hook this back up: - #### mb_p = INTL_DefaultWinCharSetID(state->context) & 0x300 ; + #### mb_p = INTL_DefaultWinCharSetID(state->context) & 0x300 ; */ - - + + NS_ASSERTION(data->in_buffer_count == 0, "1.1 19 Mar 1999 12:00"); - + /* Populate the out_buffer with quoted-printable data, one line at a time. */ for (; in < end; in++) { if (*in == '\r' || *in == '\n') { - - /* Whitespace cannot be allowed to occur at the end of - the line, so we backup and replace the whitespace with - its code. - */ - if (white) - { - out--; - char whitespace_char = *out; - *out++ = '='; - *out++ = hexdigits[whitespace_char >> 4]; - *out++ = hexdigits[whitespace_char & 0xF]; - } - + + /* Whitespace cannot be allowed to occur at the end of + the line, so we backup and replace the whitespace with + its code. + */ + if (white) + { + out--; + char whitespace_char = *out; + *out++ = '='; + *out++ = hexdigits[whitespace_char >> 4]; + *out++ = hexdigits[whitespace_char & 0xF]; + } + /* Now write out the newline. */ *out++ = '\r'; *out++ = '\n'; white = PR_FALSE; - + status = data->write_buffer (out_buffer, (out - out_buffer), data->closure); if (status < 0) return status; out = out_buffer; - + /* If it's CRLF, swallow two chars instead of one. */ if (in[0] == '\r' && in[1] == '\n') in++; - + out = out_buffer; white = PR_FALSE; data->current_column = 0; } else if (data->current_column == 0 && *in == '.') { - /* Just to be SMTP-safe, if "." appears in column 0, encode it. + /* Just to be SMTP-safe, if "." appears in column 0, encode it. (mmencode does this too.) */ goto HEX; } else if (data->current_column == 0 && *in == 'F' - && (in >= end-1 || in[1] == 'r') + && (in >= end-1 || in[1] == 'r') && (in >= end-2 || in[2] == 'o') && (in >= end-3 || in[3] == 'm') && (in >= end-4 || in[4] == ' ')) { - /* If this line begins with 'F' and we cannot determine that + /* If this line begins with 'F' and we cannot determine that this line does not begin with "From " then do the safe thing and assume that it does, and encode the 'F' in hex to avoid BSD mailbox lossage. (We might not be able to tell that it @@ -1185,38 +1184,38 @@ mime_encode_qp_buffer (MimeEncoderData *data, const char *buffer, PRInt32 size) */ goto HEX; } - else if ((*in >= 33 && *in <= 60) || /* safe printing chars */ - (*in >= 62 && *in <= 126) || + else if ((*in >= 33 && *in <= 60) || /* safe printing chars */ + (*in >= 62 && *in <= 126) || (mb_p && (*in == 61 || *in == 127 || *in == 0x1B))) { white = PR_FALSE; *out++ = *in; data->current_column++; } - else if (*in == ' ' || *in == '\t') /* whitespace */ + else if (*in == ' ' || *in == '\t') /* whitespace */ { white = PR_TRUE; *out++ = *in; data->current_column++; } - else /* print as =FF */ + else /* print as =FF */ { HEX: - white = PR_FALSE; + white = PR_FALSE; *out++ = '='; *out++ = hexdigits[*in >> 4]; *out++ = hexdigits[*in & 0xF]; data->current_column += 3; } - + NS_ASSERTION (data->current_column <= 76, "1.1 19 Mar 1999 12:00"); /* Hard limit required by spec */ - - if (data->current_column >= 73) /* soft line break: "=\r\n" */ + + if (data->current_column >= 73) /* soft line break: "=\r\n" */ { *out++ = '='; *out++ = '\r'; *out++ = '\n'; - + status = data->write_buffer (out_buffer, (out - out_buffer), data->closure); if (status < 0) return status; @@ -1225,7 +1224,7 @@ HEX: data->current_column = 0; } } - + /* Write out the unwritten portion of the last line buffer. */ if (out > out_buffer) { @@ -1233,7 +1232,7 @@ HEX: data->closure); if (status < 0) return status; } - + return 0; } @@ -1246,55 +1245,55 @@ MimeEncoderDestroy (MimeEncoderData *data, PRBool abort_p) /* If we're uuencoding, we have our own finishing routine. */ if (data->encoding == mime_uuencode) - mime_uuencode_finish(data); + mime_uuencode_finish(data); - /* Since Base64 (and uuencode) output needs to do some buffering to get - a multiple of three bytes on each block, there may be a few bytes - left in the buffer after the last block has been written. We need to - flush those out now. + /* Since Base64 (and uuencode) output needs to do some buffering to get + a multiple of three bytes on each block, there may be a few bytes + left in the buffer after the last block has been written. We need to + flush those out now. */ NS_ASSERTION (data->encoding == mime_Base64 || - data->in_buffer_count == 0, "1.1 19 Mar 1999 12:00"); + data->in_buffer_count == 0, "1.1 19 Mar 1999 12:00"); if (!abort_p && - data->in_buffer_count > 0) - { - char buf2 [6]; - char *buf = buf2 + 2; - char *out = buf; - int j; - /* fixed bug 55998, 61302, 61866 - * type casting to PRUint32 before shifting - */ - PRUint32 n = ((PRUint32) data->in_buffer[0]) << 16; - if (data->in_buffer_count > 1) - n = n | (((PRUint32) data->in_buffer[1]) << 8); + data->in_buffer_count > 0) + { + char buf2 [6]; + char *buf = buf2 + 2; + char *out = buf; + int j; + /* fixed bug 55998, 61302, 61866 + * type casting to PRUint32 before shifting + */ + PRUint32 n = ((PRUint32) data->in_buffer[0]) << 16; + if (data->in_buffer_count > 1) + n = n | (((PRUint32) data->in_buffer[1]) << 8); - buf2[0] = '\r'; - buf2[1] = '\n'; + buf2[0] = '\r'; + buf2[1] = '\n'; - for (j = 18; j >= 0; j -= 6) - { - unsigned int k = (n >> j) & 0x3F; - if (k < 26) *out++ = k + 'A'; - else if (k < 52) *out++ = k - 26 + 'a'; - else if (k < 62) *out++ = k - 52 + '0'; - else if (k == 62) *out++ = '+'; - else if (k == 63) *out++ = '/'; - else abort (); - } + for (j = 18; j >= 0; j -= 6) + { + unsigned int k = (n >> j) & 0x3F; + if (k < 26) *out++ = k + 'A'; + else if (k < 52) *out++ = k - 26 + 'a'; + else if (k < 62) *out++ = k - 52 + '0'; + else if (k == 62) *out++ = '+'; + else if (k == 63) *out++ = '/'; + else abort (); + } - /* Pad with equal-signs. */ - if (data->in_buffer_count == 1) - buf[2] = '='; - buf[3] = '='; + /* Pad with equal-signs. */ + if (data->in_buffer_count == 1) + buf[2] = '='; + buf[3] = '='; - if (data->current_column >= 72) - status = data->write_buffer (buf2, 6, data->closure); - else - status = data->write_buffer (buf, 4, data->closure); - } + if (data->current_column >= 72) + status = data->write_buffer (buf2, 6, data->closure); + else + status = data->write_buffer (buf, 4, data->closure); + } PR_FREEIF(data->filename); PR_Free (data); @@ -1304,8 +1303,8 @@ MimeEncoderDestroy (MimeEncoderData *data, PRBool abort_p) static MimeEncoderData * mime_encoder_init (mime_encoding which, - nsresult (*output_fn) (const char *, PRInt32, void *), - void *closure) + nsresult (*output_fn) (const char *, PRInt32, void *), + void *closure) { MimeEncoderData *data = PR_NEW(MimeEncoderData); if (!data) return 0; @@ -1318,28 +1317,28 @@ mime_encoder_init (mime_encoding which, MimeEncoderData * MimeB64EncoderInit (nsresult (*output_fn) (const char *, PRInt32, void *), - void *closure) + void *closure) { return mime_encoder_init (mime_Base64, output_fn, closure); } MimeEncoderData * MimeQPEncoderInit (nsresult (*output_fn) (const char *, PRInt32, void *), - void *closure) + void *closure) { return mime_encoder_init (mime_QuotedPrintable, output_fn, closure); } MimeEncoderData * MimeUUEncoderInit (char *filename, - nsresult (*output_fn) (const char *, PRInt32, void *), - void *closure) + nsresult (*output_fn) (const char *, PRInt32, void *), + void *closure) { MimeEncoderData *enc = mime_encoder_init (mime_uuencode, output_fn, closure); - + if (filename) - enc->filename = nsCRT::strdup(filename); - + enc->filename = strdup(filename); + return enc; } @@ -1349,15 +1348,15 @@ MimeEncoderWrite (MimeEncoderData *data, const char *buffer, PRInt32 size) NS_ASSERTION(data, "1.1 19 Mar 1999 12:00"); if (!data) return -1; switch(data->encoding) - { - case mime_Base64: - return mime_encode_base64_buffer (data, buffer, size); - case mime_QuotedPrintable: - return mime_encode_qp_buffer (data, buffer, size); - case mime_uuencode: - return mime_uuencode_buffer(data, buffer, size); - default: - NS_ASSERTION(0, "1.1 19 Mar 1999 12:00"); - return -1; - } + { + case mime_Base64: + return mime_encode_base64_buffer (data, buffer, size); + case mime_QuotedPrintable: + return mime_encode_qp_buffer (data, buffer, size); + case mime_uuencode: + return mime_uuencode_buffer(data, buffer, size); + default: + NS_ASSERTION(0, "1.1 19 Mar 1999 12:00"); + return -1; + } } diff --git a/mozilla/mailnews/mime/src/mimeeobj.cpp b/mozilla/mailnews/mime/src/mimeeobj.cpp index 91e72a81375..988d73566c7 100644 --- a/mozilla/mailnews/mime/src/mimeeobj.cpp +++ b/mozilla/mailnews/mime/src/mimeeobj.cpp @@ -42,14 +42,13 @@ #include "prlog.h" #include "nsMimeStringResources.h" #include "mimemoz2.h" -#include "nsCRT.h" #include "mimemapl.h" #include "nsMimeTypes.h" #define MIME_SUPERCLASS mimeLeafClass MimeDefClass(MimeExternalObject, MimeExternalObjectClass, - mimeExternalObjectClass, &MIME_SUPERCLASS); + mimeExternalObjectClass, &MIME_SUPERCLASS); static int MimeExternalObject_initialize (MimeObject *); static void MimeExternalObject_finalize (MimeObject *); @@ -58,7 +57,7 @@ static int MimeExternalObject_parse_buffer (const char *, PRInt32, MimeObject *) static int MimeExternalObject_parse_line (const char *, PRInt32, MimeObject *); static int MimeExternalObject_parse_decoded_buffer (const char*, PRInt32, MimeObject*); static PRBool MimeExternalObject_displayable_inline_p (MimeObjectClass *clazz, - MimeHeaders *hdrs); + MimeHeaders *hdrs); static int MimeExternalObjectClassInitialize(MimeExternalObjectClass *clazz) @@ -95,10 +94,10 @@ static int MimeExternalObject_parse_begin (MimeObject *obj) { int status; - + status = ((MimeObjectClass*)&MIME_SUPERCLASS)->parse_begin(obj); if (status < 0) return status; - + // If we're writing this object, and we're doing it in raw form, then // now is the time to inform the backend what the type of this data is. // @@ -111,7 +110,7 @@ MimeExternalObject_parse_begin (MimeObject *obj) if (status < 0) return status; NS_ASSERTION(obj->options->state->first_data_written_p, "1.1 19 Mar 1999 12:00"); } - + // // If we're writing this object as HTML, do all the work now -- just write // out a table with a link in it. (Later calls to the `parse_buffer' method @@ -122,29 +121,29 @@ MimeExternalObject_parse_begin (MimeObject *obj) obj->options->write_html_p && obj->options->output_fn) { - MimeDisplayOptions newopt = *obj->options; // copy it + MimeDisplayOptions newopt = *obj->options; // copy it char *id = 0; char *id_url = 0; char *id_name = 0; nsCString id_imap; PRBool all_headers_p = obj->options->headers == MimeHeadersAll; - + id = mime_part_address (obj); if (obj->options->missing_parts) id_imap.Adopt(mime_imap_part_address (obj)); if (! id) return MIME_OUT_OF_MEMORY; - + if (obj->options && obj->options->url) { const char *url = obj->options->url; if (!id_imap.IsEmpty() && id) { - // if this is an IMAP part. + // if this is an IMAP part. id_url = mime_set_url_imap_part(url, id_imap.get(), id); } else { - // This is just a normal MIME part as usual. + // This is just a normal MIME part as usual. id_url = mime_set_url_part(url, id, PR_TRUE); } if (!id_url) @@ -153,14 +152,14 @@ MimeExternalObject_parse_begin (MimeObject *obj) return MIME_OUT_OF_MEMORY; } } - if (!nsCRT::strcmp (id, "0")) + if (!strcmp (id, "0")) { PR_Free(id); id = MimeGetStringByID(MIME_MSG_ATTACHMENT); } else { - const char *p = "Part "; + const char *p = "Part "; char *s = (char *)PR_MALLOC(strlen(p) + strlen(id) + 1); if (!s) { @@ -176,7 +175,7 @@ MimeExternalObject_parse_begin (MimeObject *obj) PR_Free(id); id = s; } - + if (all_headers_p && // Don't bother showing all headers on this part if it's the only // part in the message: in that case, we've already shown these @@ -184,11 +183,11 @@ MimeExternalObject_parse_begin (MimeObject *obj) obj->options->state && obj->options->state->root == obj->parent) all_headers_p = PR_FALSE; - - newopt.fancy_headers_p = PR_TRUE; - newopt.headers = (all_headers_p ? MimeHeadersAll : MimeHeadersSome); -/****** + newopt.fancy_headers_p = PR_TRUE; + newopt.headers = (all_headers_p ? MimeHeadersAll : MimeHeadersSome); + +/****** RICHIE SHERRY GOTTA STILL DO THIS FOR QUOTING! status = MimeHeaders_write_attachment_box (obj->headers, &newopt, @@ -205,7 +204,7 @@ GOTTA STILL DO THIS FOR QUOTING! PR_FREEIF(id_name); if (status < 0) return status; } - + return 0; } @@ -216,43 +215,43 @@ MimeExternalObject_parse_buffer (const char *buffer, PRInt32 size, MimeObject *o if (obj->closed_p) return -1; if (obj->output_p && - obj->options && - !obj->options->write_html_p) - { - /* The data will be base64-decoded and passed to - MimeExternalObject_parse_decoded_buffer. */ - return ((MimeObjectClass*)&MIME_SUPERCLASS)->parse_buffer(buffer, size, - obj); - } + obj->options && + !obj->options->write_html_p) + { + /* The data will be base64-decoded and passed to + MimeExternalObject_parse_decoded_buffer. */ + return ((MimeObjectClass*)&MIME_SUPERCLASS)->parse_buffer(buffer, size, + obj); + } else - { - /* Otherwise, simply ignore the data. */ - return 0; - } + { + /* Otherwise, simply ignore the data. */ + return 0; + } } static int MimeExternalObject_parse_decoded_buffer (const char *buf, PRInt32 size, - MimeObject *obj) + MimeObject *obj) { /* This is called (by MimeLeafClass->parse_buffer) with blocks of data - that have already been base64-decoded. This will only be called in - the case where we're not emitting HTML, and want access to the raw - data itself. + that have already been base64-decoded. This will only be called in + the case where we're not emitting HTML, and want access to the raw + data itself. - We override the `parse_decoded_buffer' method provided by MimeLeaf - because, unlike most children of MimeLeaf, we do not want to line- - buffer the decoded data -- we want to simply pass it along to the - backend, without going through our `parse_line' method. + We override the `parse_decoded_buffer' method provided by MimeLeaf + because, unlike most children of MimeLeaf, we do not want to line- + buffer the decoded data -- we want to simply pass it along to the + backend, without going through our `parse_line' method. */ if (!obj->output_p || - !obj->options || - obj->options->write_html_p) - { - NS_ASSERTION(0, "1.1 19 Mar 1999 12:00"); - return -1; - } + !obj->options || + obj->options->write_html_p) + { + NS_ASSERTION(0, "1.1 19 Mar 1999 12:00"); + return -1; + } return MimeObject_write(obj, buf, size, PR_TRUE); } @@ -269,7 +268,7 @@ MimeExternalObject_parse_line (const char *line, PRInt32 length, MimeObject *obj static PRBool MimeExternalObject_displayable_inline_p (MimeObjectClass *clazz, - MimeHeaders *hdrs) + MimeHeaders *hdrs) { return PR_FALSE; } diff --git a/mozilla/mailnews/mime/src/mimefilt.cpp b/mozilla/mailnews/mime/src/mimefilt.cpp index 327493d7add..d7247e958b3 100644 --- a/mozilla/mailnews/mime/src/mimefilt.cpp +++ b/mozilla/mailnews/mime/src/mimefilt.cpp @@ -47,20 +47,20 @@ Some parameters can't be affected that way, so some additional switches may be passed on the command line after the URL: - -fancy whether fancy headers should be generated (default) + -fancy whether fancy headers should be generated (default) - -no-fancy opposite; this uses the headers used in the cases of - FO_SAVE_AS_TEXT or FO_QUOTE_MESSAGE + -no-fancy opposite; this uses the headers used in the cases of + FO_SAVE_AS_TEXT or FO_QUOTE_MESSAGE - -html whether we should convert to HTML (like FO_PRESENT); - this is the default if no ?part= is specified. + -html whether we should convert to HTML (like FO_PRESENT); + this is the default if no ?part= is specified. - -raw don't convert to HTML (FO_SAVE_AS); - this is the default if a ?part= is specified. + -raw don't convert to HTML (FO_SAVE_AS); + this is the default if a ?part= is specified. - -outline at the end, print a debugging overview of the MIME structure + -outline at the end, print a debugging overview of the MIME structure - Before any output comes a blurb listing the content-type, charset, and + Before any output comes a blurb listing the content-type, charset, and various other info that would have been put in the generated URL struct. It's printed to the beginning of the output because otherwise this out- of-band data would have been lost. (So the output of this program is, @@ -78,8 +78,8 @@ #include "nsMimeStringResources.h" #ifndef XP_UNIX -ERROR! This is a unix-only file for the "mimefilt" standalone program. - This does not go into libmime.a. +ERROR! This is a unix-only file for the "mimefilt" standalone program. + This does not go into libmime.a. #endif @@ -88,58 +88,58 @@ test_file_type (const char *filename, void *stream_closure) { const char *suf = PL_strrchr(filename, '.'); if (!suf) - return 0; + return 0; suf++; - if (!nsCRT::strcasecmp(suf, "txt") || - !nsCRT::strcasecmp(suf, "text")) - return nsCRT::strdup("text/plain"); - else if (!nsCRT::strcasecmp(suf, "htm") || - !nsCRT::strcasecmp(suf, "html")) - return nsCRT::strdup("text/html"); - else if (!nsCRT::strcasecmp(suf, "gif")) - return nsCRT::strdup("image/gif"); - else if (!nsCRT::strcasecmp(suf, "jpg") || - !nsCRT::strcasecmp(suf, "jpeg")) - return nsCRT::strdup("image/jpeg"); - else if (!nsCRT::strcasecmp(suf, "pjpg") || - !nsCRT::strcasecmp(suf, "pjpeg")) - return nsCRT::strdup("image/pjpeg"); - else if (!nsCRT::strcasecmp(suf, "xbm")) - return nsCRT::strdup("image/x-xbitmap"); - else if (!nsCRT::strcasecmp(suf, "xpm")) - return nsCRT::strdup("image/x-xpixmap"); - else if (!nsCRT::strcasecmp(suf, "xwd")) - return nsCRT::strdup("image/x-xwindowdump"); - else if (!nsCRT::strcasecmp(suf, "bmp")) - return nsCRT::strdup("image/x-MS-bmp"); - else if (!nsCRT::strcasecmp(suf, "au")) - return nsCRT::strdup("audio/basic"); - else if (!nsCRT::strcasecmp(suf, "aif") || - !nsCRT::strcasecmp(suf, "aiff") || - !nsCRT::strcasecmp(suf, "aifc")) - return nsCRT::strdup("audio/x-aiff"); - else if (!nsCRT::strcasecmp(suf, "ps")) - return nsCRT::strdup("application/postscript"); + if (!PL_strcasecmp(suf, "txt") || + !PL_strcasecmp(suf, "text")) + return strdup("text/plain"); + else if (!PL_strcasecmp(suf, "htm") || + !PL_strcasecmp(suf, "html")) + return strdup("text/html"); + else if (!PL_strcasecmp(suf, "gif")) + return strdup("image/gif"); + else if (!PL_strcasecmp(suf, "jpg") || + !PL_strcasecmp(suf, "jpeg")) + return strdup("image/jpeg"); + else if (!PL_strcasecmp(suf, "pjpg") || + !PL_strcasecmp(suf, "pjpeg")) + return strdup("image/pjpeg"); + else if (!PL_strcasecmp(suf, "xbm")) + return strdup("image/x-xbitmap"); + else if (!PL_strcasecmp(suf, "xpm")) + return strdup("image/x-xpixmap"); + else if (!PL_strcasecmp(suf, "xwd")) + return strdup("image/x-xwindowdump"); + else if (!PL_strcasecmp(suf, "bmp")) + return strdup("image/x-MS-bmp"); + else if (!PL_strcasecmp(suf, "au")) + return strdup("audio/basic"); + else if (!PL_strcasecmp(suf, "aif") || + !PL_strcasecmp(suf, "aiff") || + !PL_strcasecmp(suf, "aifc")) + return strdup("audio/x-aiff"); + else if (!PL_strcasecmp(suf, "ps")) + return strdup("application/postscript"); else - return 0; + return 0; } static char * test_type_icon(const char *type, void *stream_closure) { - if (!nsCRT::strncasecmp(type, "text/", 5)) - return nsCRT::strdup("resource://gre/res/html/gopher-text.gif"); - if (!nsCRT::strncasecmp(type, "image/", 6)) - return nsCRT::strdup("resource://gre/res/html/gopher-image.gif"); - if (!nsCRT::strncasecmp(type, "audio/", 6)) - return nsCRT::strdup("resource://gre/res/html/gopher-sound.gif"); - if (!nsCRT::strncasecmp(type, "video/", 6)) - return nsCRT::strdup("resource://gre/res/html/gopher-movie.gif"); - if (!nsCRT::strncasecmp(type, "application/", 12)) - return nsCRT::strdup("resource://gre/res/html/gopher-binary.gif"); + if (!PL_strncasecmp(type, "text/", 5)) + return strdup("resource://gre/res/html/gopher-text.gif"); + if (!PL_strncasecmp(type, "image/", 6)) + return strdup("resource://gre/res/html/gopher-image.gif"); + if (!PL_strncasecmp(type, "audio/", 6)) + return strdup("resource://gre/res/html/gopher-sound.gif"); + if (!PL_strncasecmp(type, "video/", 6)) + return strdup("resource://gre/res/html/gopher-movie.gif"); + if (!PL_strncasecmp(type, "application/", 12)) + return strdup("resource://gre/res/html/gopher-binary.gif"); - return nsCRT::strdup("resource://gre/res/html/gopher-unknown.gif"); + return strdup("resource://gre/res/html/gopher-unknown.gif"); } static int @@ -147,38 +147,38 @@ test_output_fn(char *buf, PRInt32 size, void *closure) { FILE *out = (FILE *) closure; if (out) - return fwrite(buf, sizeof(*buf), size, out); + return fwrite(buf, sizeof(*buf), size, out); else - return 0; + return 0; } static int test_output_init_fn (const char *type, - const char *charset, - const char *name, - const char *x_mac_type, - const char *x_mac_creator, - void *stream_closure) + const char *charset, + const char *name, + const char *x_mac_type, + const char *x_mac_creator, + void *stream_closure) { FILE *out = (FILE *) stream_closure; fprintf(out, "CONTENT-TYPE: %s", type); if (charset) - fprintf(out, "; charset=\"%s\"", charset); + fprintf(out, "; charset=\"%s\"", charset); if (name) - fprintf(out, "; name=\"%s\"", name); + fprintf(out, "; name=\"%s\"", name); if (x_mac_type || x_mac_creator) - fprintf(out, "; x-mac-type=\"%s\"; x-mac-creator=\"%s\"", - x_mac_type ? x_mac_type : "", - x_mac_creator ? x_mac_type : ""); + fprintf(out, "; x-mac-type=\"%s\"; x-mac-creator=\"%s\"", + x_mac_type ? x_mac_type : "", + x_mac_creator ? x_mac_type : ""); fprintf(out, CRLF CRLF); return 0; } static void * test_image_begin(const char *image_url, const char *content_type, - void *stream_closure) + void *stream_closure) { - return ((void *) nsCRT::strdup(image_url)); + return ((void *) strdup(image_url)); } static void @@ -197,14 +197,14 @@ test_image_make_image_html(void *image_data) const char *suffix = "\">

"; #else const char *prefix = ("

" - "
" - "an inlined image would have gone here for
"); + " BGCOLOR=WHITE>" + "
" + "an inlined image would have gone here for
"); const char *suffix = "

"; #endif char *buf; - buf = (char *) PR_MALLOC (nsCRT::strlen (prefix) + nsCRT::strlen (suffix) + - nsCRT::strlen (url) + 20); + buf = (char *) PR_MALLOC (strlen (prefix) + strlen (suffix) + + strlen (url) + 20); if (!buf) return 0; *buf = 0; PL_strcat (buf, prefix); @@ -225,21 +225,21 @@ test_passwd_prompt (PK11SlotInfo *slot, void *wincx) fprintf(stdout, "#### Password required: "); s = fgets(buf, sizeof(buf)-1, stdin); if (!s) return s; - if (s[nsCRT::strlen(s)-1] == '\r' || - s[nsCRT::strlen(s)-1] == '\n') - s[nsCRT::strlen(s)-1] = '\0'; + if (s[strlen(s)-1] == '\r' || + s[strlen(s)-1] == '\n') + s[strlen(s)-1] = '\0'; return s; } int test(FILE *in, FILE *out, - const char *url, - PRBool fancy_headers_p, - PRBool html_p, - PRBool outline_p, - PRBool dexlate_p, - PRBool variable_width_plaintext_p) + const char *url, + PRBool fancy_headers_p, + PRBool html_p, + PRBool outline_p, + PRBool dexlate_p, + PRBool variable_width_plaintext_p) { int status = 0; MimeObject *obj = 0; @@ -254,80 +254,80 @@ test(FILE *in, FILE *out, status = mime_parse_url_options(url, opt); if (status < 0) - { - PR_Free(opt); - return MIME_OUT_OF_MEMORY; - } + { + PR_Free(opt); + return MIME_OUT_OF_MEMORY; + } - opt->url = url; - opt->write_html_p = html_p; - opt->dexlate_p = dexlate_p; - opt->output_init_fn = test_output_init_fn; - opt->output_fn = test_output_fn; + opt->url = url; + opt->write_html_p = html_p; + opt->dexlate_p = dexlate_p; + opt->output_init_fn = test_output_init_fn; + opt->output_fn = test_output_fn; opt->charset_conversion_fn= 0; opt->rfc1522_conversion_p = PR_FALSE; - opt->file_type_fn = test_file_type; - opt->stream_closure = out; + opt->file_type_fn = test_file_type; + opt->stream_closure = out; - opt->image_begin = test_image_begin; - opt->image_end = test_image_end; - opt->make_image_html = test_image_make_image_html; - opt->image_write_buffer = test_image_write_buffer; + opt->image_begin = test_image_begin; + opt->image_end = test_image_end; + opt->make_image_html = test_image_make_image_html; + opt->image_write_buffer = test_image_write_buffer; opt->variable_width_plaintext_p = variable_width_plaintext_p; obj = mime_new ((MimeObjectClass *)&mimeMessageClass, - (MimeHeaders *) NULL, - MESSAGE_RFC822); + (MimeHeaders *) NULL, + MESSAGE_RFC822); if (!obj) - { - PR_Free(opt); - return MIME_OUT_OF_MEMORY; - } + { + PR_Free(opt); + return MIME_OUT_OF_MEMORY; + } obj->options = opt; status = obj->class->initialize(obj); if (status >= 0) - status = obj->class->parse_begin(obj); + status = obj->class->parse_begin(obj); if (status < 0) - { - PR_Free(opt); - PR_Free(obj); - return MIME_OUT_OF_MEMORY; - } + { + PR_Free(opt); + PR_Free(obj); + return MIME_OUT_OF_MEMORY; + } while (1) - { - char buf[255]; - int size = fread(buf, sizeof(*buf), sizeof(buf), stdin); - if (size <= 0) break; - status = obj->class->parse_buffer(buf, size, obj); - if (status < 0) - { - mime_free(obj); - PR_Free(opt); - return status; - } - } + { + char buf[255]; + int size = fread(buf, sizeof(*buf), sizeof(buf), stdin); + if (size <= 0) break; + status = obj->class->parse_buffer(buf, size, obj); + if (status < 0) + { + mime_free(obj); + PR_Free(opt); + return status; + } + } status = obj->class->parse_eof(obj, PR_FALSE); if (status >= 0) - status = obj->class->parse_end(obj, PR_FALSE); + status = obj->class->parse_end(obj, PR_FALSE); if (status < 0) - { - mime_free(obj); - PR_Free(opt); - return status; - } + { + mime_free(obj); + PR_Free(opt); + return status; + } if (outline_p) - { - fprintf(out, "\n\n" - "###############################################################\n"); - obj->class->debug_print(obj, stderr, 0); - fprintf(out, - "###############################################################\n"); - } + { + fprintf(out, "\n\n" + "###############################################################\n"); + obj->class->debug_print(obj, stderr, 0); + fprintf(out, + "###############################################################\n"); + } mime_free (obj); PR_Free(opt); @@ -340,9 +340,9 @@ test_cdb_name_cb (void *arg, int vers) { static char f[1024]; if (vers <= 4) - sprintf(f, "%s/.netscape/cert.db", getenv("HOME")); + sprintf(f, "%s/.netscape/cert.db", getenv("HOME")); else - sprintf(f, "%s/.netscape/cert%d.db", getenv("HOME"), vers); + sprintf(f, "%s/.netscape/cert%d.db", getenv("HOME"), vers); return f; } @@ -351,9 +351,9 @@ test_kdb_name_cb (void *arg, int vers) { static char f[1024]; if (vers <= 2) - sprintf(f, "%s/.netscape/key.db", getenv("HOME")); + sprintf(f, "%s/.netscape/key.db", getenv("HOME")); else - sprintf(f, "%s/.netscape/key%d.db", getenv("HOME"), vers); + sprintf(f, "%s/.netscape/key%d.db", getenv("HOME"), vers); return f; } @@ -377,7 +377,7 @@ main (int argc, char **argv) cdb_handle = (CERTCertDBHandle *) calloc(1, sizeof(*cdb_handle)); if (SECSuccess != CERT_OpenCertDB(cdb_handle, PR_FALSE, test_cdb_name_cb, NULL)) - CERT_OpenVolatileCertDB(cdb_handle); + CERT_OpenVolatileCertDB(cdb_handle); CERT_SetDefaultCertDB(cdb_handle); RNG_RNGInit(); @@ -394,45 +394,45 @@ main (int argc, char **argv) if (i < argc) - { - if (argv[i][0] == '-') - url = nsCRT::strdup(""); - else - url = argv[i++]; - } + { + if (argv[i][0] == '-') + url = strdup(""); + else + url = argv[i++]; + } if (url && - (PL_strstr(url, "?part=") || - PL_strstr(url, "&part="))) - html_p = PR_FALSE; + (PL_strstr(url, "?part=") || + PL_strstr(url, "&part="))) + html_p = PR_FALSE; while (i < argc) - { - if (!nsCRT::strcmp(argv[i], "-fancy")) - fancy_p = PR_TRUE; - else if (!nsCRT::strcmp(argv[i], "-no-fancy")) - fancy_p = PR_FALSE; - else if (!nsCRT::strcmp(argv[i], "-html")) - html_p = PR_TRUE; - else if (!nsCRT::strcmp(argv[i], "-raw")) - html_p = PR_FALSE; - else if (!nsCRT::strcmp(argv[i], "-outline")) - outline_p = PR_TRUE; - else if (!nsCRT::strcmp(argv[i], "-dexlate")) - dexlate_p = PR_TRUE; - else - { - fprintf(stderr, - "usage: %s [ URL [ -fancy | -no-fancy | -html | -raw | -outline | -dexlate ]]\n" - " < message/rfc822 > output\n", - (PL_strrchr(argv[0], '/') ? - PL_strrchr(argv[0], '/') + 1 : - argv[0])); - i = 1; - goto FAIL; - } - i++; - } + { + if (!strcmp(argv[i], "-fancy")) + fancy_p = PR_TRUE; + else if (!strcmp(argv[i], "-no-fancy")) + fancy_p = PR_FALSE; + else if (!strcmp(argv[i], "-html")) + html_p = PR_TRUE; + else if (!strcmp(argv[i], "-raw")) + html_p = PR_FALSE; + else if (!strcmp(argv[i], "-outline")) + outline_p = PR_TRUE; + else if (!strcmp(argv[i], "-dexlate")) + dexlate_p = PR_TRUE; + else + { + fprintf(stderr, + "usage: %s [ URL [ -fancy | -no-fancy | -html | -raw | -outline | -dexlate ]]\n" + " < message/rfc822 > output\n", + (PL_strrchr(argv[0], '/') ? + PL_strrchr(argv[0], '/') + 1 : + argv[0])); + i = 1; + goto FAIL; + } + i++; + } i = test(stdin, stdout, url, fancy_p, html_p, outline_p, dexlate_p, PR_TRUE); fprintf(stdout, "\n"); diff --git a/mozilla/mailnews/mime/src/mimehdrs.cpp b/mozilla/mailnews/mime/src/mimehdrs.cpp index aacbeacf884..bc7d79c7e5d 100644 --- a/mozilla/mailnews/mime/src/mimehdrs.cpp +++ b/mozilla/mailnews/mime/src/mimehdrs.cpp @@ -43,7 +43,6 @@ #include "mimebuf.h" #include "mimemoz2.h" #include "nsIMimeEmitter.h" -#include "nsCRT.h" #include "nsEscape.h" #include "nsMsgMessageFlags.h" #include "comi18n.h" @@ -53,7 +52,7 @@ #include "mimemoz2.h" #include "nsMsgI18N.h" #include "mimehdrs.h" -#include "nsIMIMEHeaderParam.h" +#include "nsIMIMEHeaderParam.h" #include "nsNetCID.h" // Forward declares... @@ -113,10 +112,10 @@ MimeHeaders_free (MimeHeaders *hdrs) # ifdef DEBUG__ { - int i, size = sizeof(*hdrs); - PRUint32 *array = (PRUint32*) hdrs; - for (i = 0; i < (size / sizeof(*array)); i++) - array[i] = (PRUint32) 0xDEADBEEF; + int i, size = sizeof(*hdrs); + PRUint32 *array = (PRUint32*) hdrs; + for (i = 0; i < (size / sizeof(*array)); i++) + array[i] = (PRUint32) 0xDEADBEEF; } # endif /* DEBUG */ @@ -137,22 +136,22 @@ MimeHeaders_parse_line (const char *buffer, PRInt32 size, MimeHeaders *hdrs) if (hdrs->done_p) return -1; if (!buffer || size == 0 || *buffer == '\r' || *buffer == '\n') - { - /* If this is a blank line, we're done. - */ - hdrs->done_p = PR_TRUE; - return MimeHeaders_build_heads_list(hdrs); - } + { + /* If this is a blank line, we're done. + */ + hdrs->done_p = PR_TRUE; + return MimeHeaders_build_heads_list(hdrs); + } /* Tack this data on to the end of our copy. */ desired_size = hdrs->all_headers_fp + size + 1; if (desired_size >= hdrs->all_headers_size) - { - status = mime_GrowBuffer (desired_size, sizeof(char), 255, - &hdrs->all_headers, &hdrs->all_headers_size); - if (status < 0) return status; - } + { + status = mime_GrowBuffer (desired_size, sizeof(char), 255, + &hdrs->all_headers, &hdrs->all_headers_size); + if (status < 0) return status; + } memcpy(hdrs->all_headers+hdrs->all_headers_fp, buffer, size); hdrs->all_headers_fp += size; @@ -170,39 +169,39 @@ MimeHeaders_copy (MimeHeaders *hdrs) memset(hdrs2, 0, sizeof(*hdrs2)); if (hdrs->all_headers) - { - hdrs2->all_headers = (char *) PR_MALLOC(hdrs->all_headers_fp); - if (!hdrs2->all_headers) - { - PR_Free(hdrs2); - return 0; - } - memcpy(hdrs2->all_headers, hdrs->all_headers, hdrs->all_headers_fp); + { + hdrs2->all_headers = (char *) PR_MALLOC(hdrs->all_headers_fp); + if (!hdrs2->all_headers) + { + PR_Free(hdrs2); + return 0; + } + memcpy(hdrs2->all_headers, hdrs->all_headers, hdrs->all_headers_fp); - hdrs2->all_headers_fp = hdrs->all_headers_fp; - hdrs2->all_headers_size = hdrs->all_headers_fp; - } + hdrs2->all_headers_fp = hdrs->all_headers_fp; + hdrs2->all_headers_size = hdrs->all_headers_fp; + } hdrs2->done_p = hdrs->done_p; if (hdrs->heads) - { - int i; - hdrs2->heads = (char **) PR_MALLOC(hdrs->heads_size - * sizeof(*hdrs->heads)); - if (!hdrs2->heads) - { - PR_FREEIF(hdrs2->all_headers); - PR_Free(hdrs2); - return 0; - } - hdrs2->heads_size = hdrs->heads_size; - for (i = 0; i < hdrs->heads_size; i++) - { - hdrs2->heads[i] = (hdrs2->all_headers + - (hdrs->heads[i] - hdrs->all_headers)); - } - } + { + int i; + hdrs2->heads = (char **) PR_MALLOC(hdrs->heads_size + * sizeof(*hdrs->heads)); + if (!hdrs2->heads) + { + PR_FREEIF(hdrs2->all_headers); + PR_Free(hdrs2); + return 0; + } + hdrs2->heads_size = hdrs->heads_size; + for (i = 0; i < hdrs->heads_size; i++) + { + hdrs2->heads[i] = (hdrs2->all_headers + + (hdrs->heads[i] - hdrs->all_headers)); + } + } return hdrs2; } @@ -217,55 +216,55 @@ MimeHeaders_build_heads_list(MimeHeaders *hdrs) NS_ASSERTION(hdrs->done_p && !hdrs->heads, "1.1 19 Mar 1999 12:00"); if (!hdrs->done_p || hdrs->heads) - return -1; + return -1; if (hdrs->all_headers_fp == 0) - { - /* Must not have been any headers (we got the blank line right away.) */ - PR_FREEIF (hdrs->all_headers); - hdrs->all_headers_size = 0; - return 0; - } + { + /* Must not have been any headers (we got the blank line right away.) */ + PR_FREEIF (hdrs->all_headers); + hdrs->all_headers_size = 0; + return 0; + } /* At this point, we might as well realloc all_headers back down to the - minimum size it must be (it could be up to 1k bigger.) But don't - bother if we're only off by a tiny bit. */ + minimum size it must be (it could be up to 1k bigger.) But don't + bother if we're only off by a tiny bit. */ NS_ASSERTION(hdrs->all_headers_fp <= hdrs->all_headers_size, "1.1 19 Mar 1999 12:00"); if (hdrs->all_headers_fp + 60 <= hdrs->all_headers_size) - { - char *ls = (char *)PR_Realloc(hdrs->all_headers, hdrs->all_headers_fp); - if (ls) /* can this ever fail? we're making it smaller... */ - { - hdrs->all_headers = ls; /* in case it got relocated */ - hdrs->all_headers_size = hdrs->all_headers_fp; - } - } + { + char *ls = (char *)PR_Realloc(hdrs->all_headers, hdrs->all_headers_fp); + if (ls) /* can this ever fail? we're making it smaller... */ + { + hdrs->all_headers = ls; /* in case it got relocated */ + hdrs->all_headers_size = hdrs->all_headers_fp; + } + } /* First go through and count up the number of headers in the block. */ end = hdrs->all_headers + hdrs->all_headers_fp; for (s = hdrs->all_headers; s <= end-1; s++) - { - if (s <= (end-1) && s[0] == '\r' && s[1] == '\n') /* CRLF -> LF */ - s++; + { + if (s <= (end-1) && s[0] == '\r' && s[1] == '\n') /* CRLF -> LF */ + s++; + + if ((s[0] == '\r' || s[0] == '\n') && /* we're at a newline, and */ + (s >= (end-1) || /* we're at EOF, or */ + !(s[1] == ' ' || s[1] == '\t'))) /* next char is nonwhite */ + hdrs->heads_size++; + } - if ((s[0] == '\r' || s[0] == '\n') && /* we're at a newline, and */ - (s >= (end-1) || /* we're at EOF, or */ - !(s[1] == ' ' || s[1] == '\t'))) /* next char is nonwhite */ - hdrs->heads_size++; - } - /* Now allocate storage for the pointers to each of those headers. */ hdrs->heads = (char **) PR_MALLOC((hdrs->heads_size + 1) * sizeof(char *)); if (!hdrs->heads) - return MIME_OUT_OF_MEMORY; + return MIME_OUT_OF_MEMORY; memset(hdrs->heads, 0, (hdrs->heads_size + 1) * sizeof(char *)); /* Now make another pass through the headers, and this time, record the - starting position of each header. + starting position of each header. */ i = 0; @@ -273,51 +272,51 @@ MimeHeaders_build_heads_list(MimeHeaders *hdrs) s = hdrs->all_headers; while (s <= end) - { - SEARCH_NEWLINE: - while (s <= end-1 && *s != '\r' && *s != '\n') - s++; + { + SEARCH_NEWLINE: + while (s <= end-1 && *s != '\r' && *s != '\n') + s++; - if (s+1 >= end) - break; + if (s+1 >= end) + break; - /* If "\r\n " or "\r\n\t" is next, that doesn't terminate the header. */ - else if (s+2 < end && - (s[0] == '\r' && s[1] == '\n') && - (s[2] == ' ' || s[2] == '\t')) - { - s += 3; - goto SEARCH_NEWLINE; - } - /* If "\r " or "\r\t" or "\n " or "\n\t" is next, that doesn't terminate - the header either. */ - else if ((s[0] == '\r' || s[0] == '\n') && - (s[1] == ' ' || s[1] == '\t')) - { - s += 2; - goto SEARCH_NEWLINE; - } + /* If "\r\n " or "\r\n\t" is next, that doesn't terminate the header. */ + else if (s+2 < end && + (s[0] == '\r' && s[1] == '\n') && + (s[2] == ' ' || s[2] == '\t')) + { + s += 3; + goto SEARCH_NEWLINE; + } + /* If "\r " or "\r\t" or "\n " or "\n\t" is next, that doesn't terminate + the header either. */ + else if ((s[0] == '\r' || s[0] == '\n') && + (s[1] == ' ' || s[1] == '\t')) + { + s += 2; + goto SEARCH_NEWLINE; + } - /* At this point, `s' points before a header-terminating newline. - Move past that newline, and store that new position in `heads'. - */ - if (*s == '\r') s++; - if (*s == '\n') s++; + /* At this point, `s' points before a header-terminating newline. + Move past that newline, and store that new position in `heads'. + */ + if (*s == '\r') s++; + if (*s == '\n') s++; - if (s < end) - { - NS_ASSERTION(! (i > hdrs->heads_size), "1.1 19 Mar 1999 12:00"); - if (i > hdrs->heads_size) return -1; - hdrs->heads[i++] = s; - } - } + if (s < end) + { + NS_ASSERTION(! (i > hdrs->heads_size), "1.1 19 Mar 1999 12:00"); + if (i > hdrs->heads_size) return -1; + hdrs->heads[i++] = s; + } + } return 0; } char * MimeHeaders_get (MimeHeaders *hdrs, const char *header_name, - PRBool strip_p, PRBool all_p) + PRBool strip_p, PRBool all_p) { int i; int name_length; @@ -332,177 +331,177 @@ MimeHeaders_get (MimeHeaders *hdrs, const char *header_name, NS_ASSERTION(!(strip_p && all_p), "1.1 19 Mar 1999 12:00"); /* One shouldn't be trying to read headers when one hasn't finished - parsing them yet... but this can happen if the message ended - prematurely, and has no body at all (as opposed to a null body, - which is more normal.) So, if we try to read from the headers, - let's assume that the headers are now finished. If they aren't - in fact finished, then a later attempt to write to them will assert. + parsing them yet... but this can happen if the message ended + prematurely, and has no body at all (as opposed to a null body, + which is more normal.) So, if we try to read from the headers, + let's assume that the headers are now finished. If they aren't + in fact finished, then a later attempt to write to them will assert. */ if (!hdrs->done_p) - { - int status; - hdrs->done_p = PR_TRUE; - status = MimeHeaders_build_heads_list(hdrs); - if (status < 0) return 0; - } + { + int status; + hdrs->done_p = PR_TRUE; + status = MimeHeaders_build_heads_list(hdrs); + if (status < 0) return 0; + } - if (!hdrs->heads) /* Must not have been any headers. */ - { - NS_ASSERTION(hdrs->all_headers_fp == 0, "1.1 19 Mar 1999 12:00"); - return 0; - } + if (!hdrs->heads) /* Must not have been any headers. */ + { + NS_ASSERTION(hdrs->all_headers_fp == 0, "1.1 19 Mar 1999 12:00"); + return 0; + } name_length = strlen(header_name); for (i = 0; i < hdrs->heads_size; i++) - { - char *head = hdrs->heads[i]; - char *end = (i == hdrs->heads_size-1 - ? hdrs->all_headers + hdrs->all_headers_fp - : hdrs->heads[i+1]); - char *colon, *ocolon; + { + char *head = hdrs->heads[i]; + char *end = (i == hdrs->heads_size-1 + ? hdrs->all_headers + hdrs->all_headers_fp + : hdrs->heads[i+1]); + char *colon, *ocolon; - NS_ASSERTION(head, "1.1 19 Mar 1999 12:00"); - if (!head) continue; + NS_ASSERTION(head, "1.1 19 Mar 1999 12:00"); + if (!head) continue; - /* Quick hack to skip over BSD Mailbox delimiter. */ - if (i == 0 && head[0] == 'F' && !strncmp(head, "From ", 5)) - continue; + /* Quick hack to skip over BSD Mailbox delimiter. */ + if (i == 0 && head[0] == 'F' && !strncmp(head, "From ", 5)) + continue; - /* Find the colon. */ - for (colon = head; colon < end; colon++) - if (*colon == ':') break; + /* Find the colon. */ + for (colon = head; colon < end; colon++) + if (*colon == ':') break; - if (colon >= end) continue; + if (colon >= end) continue; - /* Back up over whitespace before the colon. */ - ocolon = colon; - for (; colon > head && nsCRT::IsAsciiSpace(colon[-1]); colon--) - ; + /* Back up over whitespace before the colon. */ + ocolon = colon; + for (; colon > head && IS_SPACE(colon[-1]); colon--) + ; - /* If the strings aren't the same length, it doesn't match. */ - if (name_length != colon - head ) - continue; + /* If the strings aren't the same length, it doesn't match. */ + if (name_length != colon - head ) + continue; - /* If the strings differ, it doesn't match. */ - if (nsCRT::strncasecmp(header_name, head, name_length)) - continue; + /* If the strings differ, it doesn't match. */ + if (PL_strncasecmp(header_name, head, name_length)) + continue; - /* Otherwise, we've got a match. */ - { - char *contents = ocolon + 1; - char *s; + /* Otherwise, we've got a match. */ + { + char *contents = ocolon + 1; + char *s; - /* Skip over whitespace after colon. */ - while (contents <= end && nsCRT::IsAsciiSpace(*contents)) - contents++; + /* Skip over whitespace after colon. */ + while (contents <= end && IS_SPACE(*contents)) + contents++; - /* If we're supposed to strip at the first token, pull `end' back to - the first whitespace or ';' after the first token. - */ - if (strip_p) - { - for (s = contents; - s <= end && *s != ';' && *s != ',' && !nsCRT::IsAsciiSpace(*s); - s++) - ; - end = s; - } + /* If we're supposed to strip at the first token, pull `end' back to + the first whitespace or ';' after the first token. + */ + if (strip_p) + { + for (s = contents; + s <= end && *s != ';' && *s != ',' && !IS_SPACE(*s); + s++) + ; + end = s; + } - /* Now allocate some storage. - If `result' already has a value, enlarge it. - Otherwise, just allocate a block. - `s' gets set to the place where the new data goes. - */ - if (!result) - { - result = (char *) PR_MALLOC(end - contents + 1); - if (!result) - return 0; - s = result; - } - else - { - PRInt32 L = strlen(result); - s = (char *) PR_Realloc(result, (L + (end - contents + 10))); - if (!s) - { - PR_Free(result); - return 0; - } - result = s; - s = result + L; + /* Now allocate some storage. + If `result' already has a value, enlarge it. + Otherwise, just allocate a block. + `s' gets set to the place where the new data goes. + */ + if (!result) + { + result = (char *) PR_MALLOC(end - contents + 1); + if (!result) + return 0; + s = result; + } + else + { + PRInt32 L = strlen(result); + s = (char *) PR_Realloc(result, (L + (end - contents + 10))); + if (!s) + { + PR_Free(result); + return 0; + } + result = s; + s = result + L; - /* Since we are tacking more data onto the end of the header - field, we must make it be a well-formed continuation line, + /* Since we are tacking more data onto the end of the header + field, we must make it be a well-formed continuation line, by separating the old and new data with CR-LF-TAB. - */ - *s++ = ','; /* #### only do this for addr headers? */ - *s++ = MSG_LINEBREAK[0]; + */ + *s++ = ','; /* #### only do this for addr headers? */ + *s++ = MSG_LINEBREAK[0]; # if (MSG_LINEBREAK_LEN == 2) - *s++ = MSG_LINEBREAK[1]; + *s++ = MSG_LINEBREAK[1]; # endif - *s++ = '\t'; - } + *s++ = '\t'; + } - /* Take off trailing whitespace... */ - while (end > contents && nsCRT::IsAsciiSpace(end[-1])) - end--; + /* Take off trailing whitespace... */ + while (end > contents && IS_SPACE(end[-1])) + end--; - if (end > contents) - { - /* Now copy the header's contents in... - */ - memcpy(s, contents, end - contents); - s[end - contents] = 0; - } - else - { - s[0] = 0; - } + if (end > contents) + { + /* Now copy the header's contents in... + */ + memcpy(s, contents, end - contents); + s[end - contents] = 0; + } + else + { + s[0] = 0; + } - /* If we only wanted the first occurence of this header, we're done. */ - if (!all_p) break; - } - } + /* If we only wanted the first occurence of this header, we're done. */ + if (!all_p) break; + } + } if (result && !*result) /* empty string */ - { - PR_Free(result); - return 0; - } + { + PR_Free(result); + return 0; + } return result; } char * -MimeHeaders_get_parameter (const char *header_value, const char *parm_name, +MimeHeaders_get_parameter (const char *header_value, const char *parm_name, char **charset, char **language) { if (!header_value || !parm_name || !*header_value || !*parm_name) return nsnull; nsresult rv; - nsCOMPtr mimehdrpar = + nsCOMPtr mimehdrpar = do_GetService(NS_MIMEHEADERPARAM_CONTRACTID, &rv); if (NS_FAILED(rv)) return nsnull; nsCString result; - rv = mimehdrpar->GetParameterInternal(header_value, parm_name, charset, + rv = mimehdrpar->GetParameterInternal(header_value, parm_name, charset, language, getter_Copies(result)); - return NS_SUCCEEDED(rv) ? PL_strdup(result.get()) : nsnull; + return NS_SUCCEEDED(rv) ? PL_strdup(result.get()) : nsnull; } #define MimeHeaders_write(OPT,DATA,LENGTH) \ - MimeOptions_write((OPT), (DATA), (LENGTH), PR_TRUE); + MimeOptions_write((OPT), (DATA), (LENGTH), PR_TRUE); #define MimeHeaders_grow_obuffer(hdrs, desired_size) \ ((((long) (desired_size)) >= ((long) (hdrs)->obuffer_size)) ? \ mime_GrowBuffer ((desired_size), sizeof(char), 255, \ - &(hdrs)->obuffer, &(hdrs)->obuffer_size) \ + &(hdrs)->obuffer, &(hdrs)->obuffer_size) \ : 0) int @@ -513,7 +512,7 @@ MimeHeaders_write_all_headers (MimeHeaders *hdrs, MimeDisplayOptions *opt, PRBoo PRBool wrote_any_p = PR_FALSE; NS_ASSERTION(hdrs, "1.1 19 Mar 1999 12:00"); - if (!hdrs) + if (!hdrs) return -1; /* One shouldn't be trying to read headers when one hasn't finished @@ -552,7 +551,7 @@ MimeHeaders_write_all_headers (MimeHeaders *hdrs, MimeDisplayOptions *opt, PRBoo : hdrs->heads[i+1]); char *colon, *ocolon; char *contents = end; - + /* Hack for BSD Mailbox delimiter. */ if (i == 0 && head[0] == 'F' && !strncmp(head, "From ", 5)) { @@ -566,23 +565,23 @@ MimeHeaders_write_all_headers (MimeHeaders *hdrs, MimeDisplayOptions *opt, PRBoo /* Find the colon. */ for (colon = head; colon < end && *colon != ':'; colon++) ; - + /* Back up over whitespace before the colon. */ ocolon = colon; - for (; colon > head && nsCRT::IsAsciiSpace(colon[-1]); colon--) + for (; colon > head && IS_SPACE(colon[-1]); colon--) ; - + contents = ocolon + 1; } - + /* Skip over whitespace after colon. */ - while (contents < end && nsCRT::IsAsciiSpace(*contents)) + while (contents < end && IS_SPACE(*contents)) contents++; - + /* Take off trailing whitespace... */ - while (end > contents && nsCRT::IsAsciiSpace(end[-1])) + while (end > contents && IS_SPACE(end[-1])) end--; - + nsCAutoString name(Substring(head, colon)); nsCAutoString hdr_value; @@ -590,7 +589,7 @@ MimeHeaders_write_all_headers (MimeHeaders *hdrs, MimeDisplayOptions *opt, PRBoo { hdr_value = Substring(contents, end); } - + MimeHeaders_convert_header_value(opt, hdr_value); // if we're saving as html, we need to convert headers from utf8 to message charset, if any if (opt->format_out == nsMimeOutput::nsMimeMessageSaveAs && charset) @@ -607,9 +606,9 @@ MimeHeaders_write_all_headers (MimeHeaders *hdrs, MimeDisplayOptions *opt, PRBoo status = mimeEmitterAddAttachmentField(opt, name.get(), hdr_value.get()); else status = mimeEmitterAddHeaderField(opt, name.get(), hdr_value.get()); - + if (status < 0) return status; - if (!wrote_any_p) + if (!wrote_any_p) wrote_any_p = (status > 0); } mimeEmitterAddAllHeaders(opt, hdrs->all_headers, hdrs->all_headers_fp); @@ -629,39 +628,39 @@ HG99401 extern "C" char * MIME_StripContinuations(char *original) { - char *p1, *p2; + char *p1, *p2; - /* If we were given a null string, return it as is */ - if (!original) return NULL; + /* If we were given a null string, return it as is */ + if (!original) return NULL; - /* Start source and dest pointers at the beginning */ - p1 = p2 = original; + /* Start source and dest pointers at the beginning */ + p1 = p2 = original; - while(*p2) - { - /* p2 runs ahead at (CR and/or LF) */ - if ((p2[0] == '\r') || (p2[0] == '\n')) - { + while(*p2) + { + /* p2 runs ahead at (CR and/or LF) */ + if ((p2[0] == '\r') || (p2[0] == '\n')) + { p2++; - } else { + } else { *p1++ = *p2++; } - } - *p1 = '\0'; + } + *p1 = '\0'; - return original; + return original; } extern PRInt16 INTL_DefaultMailToWinCharSetID(PRInt16 csid); /* Given text purporting to be a qtext header value, strip backslashes that - may be escaping other chars in the string. */ + may be escaping other chars in the string. */ char * mime_decode_filename(char *name, const char *charset, MimeDisplayOptions *opt) { nsresult rv; - nsCOMPtr mimehdrpar = + nsCOMPtr mimehdrpar = do_GetService(NS_MIMEHEADERPARAM_CONTRACTID, &rv); if (NS_FAILED(rv)) @@ -670,7 +669,7 @@ mime_decode_filename(char *name, const char *charset, rv = mimehdrpar->DecodeParameter(nsDependentCString(name), charset, opt->default_charset, opt->override_charset, result); - return NS_SUCCEEDED(rv) ? PL_strdup(result.get()) : nsnull; + return NS_SUCCEEDED(rv) ? PL_strdup(result.get()) : nsnull; } /* Pull the name out of some header or another. Order is: @@ -706,7 +705,7 @@ MimeHeaders_get_name(MimeHeaders *hdrs, MimeDisplayOptions *opt) if (! name) name = MimeHeaders_get (hdrs, HEADER_CONTENT_NAME, PR_FALSE, PR_FALSE); - + if (! name) name = MimeHeaders_get (hdrs, HEADER_X_SUN_DATA_NAME, PR_FALSE, PR_FALSE); @@ -714,8 +713,8 @@ MimeHeaders_get_name(MimeHeaders *hdrs, MimeDisplayOptions *opt) { /* First remove continuation delimiters (CR+LF+space), then remove escape ('\\') characters, then attempt to decode - mime-2 encoded-words. The latter two are done in - mime_decode_filename. + mime-2 encoded-words. The latter two are done in + mime_decode_filename. */ MIME_StripContinuations(name); @@ -756,9 +755,9 @@ MimeHeaders_do_unix_display_hook_hack(MimeHeaders *hdrs) if (!cmd) cmd = ""; } - + /* Invoke "cmd" at the end of a pipe, and give it the headers on stdin. - The command is expected to be safe from hostile input!! + The command is expected to be safe from hostile input!! */ if (cmd && *cmd) { @@ -794,54 +793,54 @@ MimeHeaders_compact (MimeHeaders *hdrs) */ int MimeHeaders_write_raw_headers (MimeHeaders *hdrs, MimeDisplayOptions *opt, - PRBool dont_write_content_type) + PRBool dont_write_content_type) { int status; if (hdrs && !hdrs->done_p) - { - hdrs->done_p = PR_TRUE; - status = MimeHeaders_build_heads_list(hdrs); - if (status < 0) return 0; - } + { + hdrs->done_p = PR_TRUE; + status = MimeHeaders_build_heads_list(hdrs); + if (status < 0) return 0; + } if (!dont_write_content_type) - { - char nl[] = MSG_LINEBREAK; - if (hdrs) - { - status = MimeHeaders_write(opt, hdrs->all_headers, - hdrs->all_headers_fp); - if (status < 0) return status; - } - status = MimeHeaders_write(opt, nl, strlen(nl)); - if (status < 0) return status; - } + { + char nl[] = MSG_LINEBREAK; + if (hdrs) + { + status = MimeHeaders_write(opt, hdrs->all_headers, + hdrs->all_headers_fp); + if (status < 0) return status; + } + status = MimeHeaders_write(opt, nl, strlen(nl)); + if (status < 0) return status; + } else if (hdrs) - { - PRInt32 i; - for (i = 0; i < hdrs->heads_size; i++) - { - char *head = hdrs->heads[i]; - char *end = (i == hdrs->heads_size-1 - ? hdrs->all_headers + hdrs->all_headers_fp - : hdrs->heads[i+1]); + { + PRInt32 i; + for (i = 0; i < hdrs->heads_size; i++) + { + char *head = hdrs->heads[i]; + char *end = (i == hdrs->heads_size-1 + ? hdrs->all_headers + hdrs->all_headers_fp + : hdrs->heads[i+1]); - NS_ASSERTION(head, "1.22 22 Aug 1999 08:48"); - if (!head) continue; + NS_ASSERTION(head, "1.22 22 Aug 1999 08:48"); + if (!head) continue; - /* Don't write out any Content- header. */ - if (!nsCRT::strncasecmp(head, "Content-", 8)) - continue; + /* Don't write out any Content- header. */ + if (!PL_strncasecmp(head, "Content-", 8)) + continue; - /* Write out this (possibly multi-line) header. */ - status = MimeHeaders_write(opt, head, end - head); - if (status < 0) return status; - } - } + /* Write out this (possibly multi-line) header. */ + status = MimeHeaders_write(opt, head, end - head); + if (status < 0) return status; + } + } if (hdrs) - MimeHeaders_compact (hdrs); + MimeHeaders_compact (hdrs); return 0; } diff --git a/mozilla/mailnews/mime/src/mimei.cpp b/mozilla/mailnews/mime/src/mimei.cpp index a96f4dd9783..6d22fade295 100644 --- a/mozilla/mailnews/mime/src/mimei.cpp +++ b/mozilla/mailnews/mime/src/mimei.cpp @@ -35,7 +35,7 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** - * This Original Code has been modified by IBM Corporation. Modifications made by IBM + * This Original Code has been modified by IBM Corporation. Modifications made by IBM * described herein are Copyright (c) International Business Machines Corporation, 2000. * Modifications to Mozilla code or documentation identified per MPL Section 3.3 * @@ -44,39 +44,39 @@ */ #include "nsCOMPtr.h" -#include "mimeobj.h" /* MimeObject (abstract) */ -#include "mimecont.h" /* |--- MimeContainer (abstract) */ -#include "mimemult.h" /* | |--- MimeMultipart (abstract) */ -#include "mimemmix.h" /* | | |--- MimeMultipartMixed */ -#include "mimemdig.h" /* | | |--- MimeMultipartDigest */ -#include "mimempar.h" /* | | |--- MimeMultipartParallel */ -#include "mimemalt.h" /* | | |--- MimeMultipartAlternative */ -#include "mimemrel.h" /* | | |--- MimeMultipartRelated */ -#include "mimemapl.h" /* | | |--- MimeMultipartAppleDouble */ -#include "mimesun.h" /* | | |--- MimeSunAttachment */ -#include "mimemsig.h" /* | | |--- MimeMultipartSigned (abstract)*/ +#include "mimeobj.h" /* MimeObject (abstract) */ +#include "mimecont.h" /* |--- MimeContainer (abstract) */ +#include "mimemult.h" /* | |--- MimeMultipart (abstract) */ +#include "mimemmix.h" /* | | |--- MimeMultipartMixed */ +#include "mimemdig.h" /* | | |--- MimeMultipartDigest */ +#include "mimempar.h" /* | | |--- MimeMultipartParallel */ +#include "mimemalt.h" /* | | |--- MimeMultipartAlternative */ +#include "mimemrel.h" /* | | |--- MimeMultipartRelated */ +#include "mimemapl.h" /* | | |--- MimeMultipartAppleDouble */ +#include "mimesun.h" /* | | |--- MimeSunAttachment */ +#include "mimemsig.h" /* | | |--- MimeMultipartSigned (abstract)*/ #ifdef ENABLE_SMIME #include "mimemcms.h" /* | | |---MimeMultipartSignedCMS */ #endif -#include "mimecryp.h" /* | |--- MimeEncrypted (abstract) */ +#include "mimecryp.h" /* | |--- MimeEncrypted (abstract) */ #ifdef ENABLE_SMIME -#include "mimecms.h" /* | | |--- MimeEncryptedPKCS7 */ +#include "mimecms.h" /* | | |--- MimeEncryptedPKCS7 */ #endif -#include "mimemsg.h" /* | |--- MimeMessage */ -#include "mimeunty.h" /* | |--- MimeUntypedText */ -#include "mimeleaf.h" /* |--- MimeLeaf (abstract) */ -#include "mimetext.h" /* | |--- MimeInlineText (abstract) */ -#include "mimetpla.h" /* | | |--- MimeInlineTextPlain */ -#include "mimethpl.h" /* | | | |--- M.I.TextHTMLAsPlaintext */ +#include "mimemsg.h" /* | |--- MimeMessage */ +#include "mimeunty.h" /* | |--- MimeUntypedText */ +#include "mimeleaf.h" /* |--- MimeLeaf (abstract) */ +#include "mimetext.h" /* | |--- MimeInlineText (abstract) */ +#include "mimetpla.h" /* | | |--- MimeInlineTextPlain */ +#include "mimethpl.h" /* | | | |--- M.I.TextHTMLAsPlaintext */ #include "mimetpfl.h" /* | | |--- MimeInlineTextPlainFlowed */ -#include "mimethtm.h" /* | | |--- MimeInlineTextHTML */ -#include "mimethsa.h" /* | | | |--- M.I.TextHTMLSanitized */ -#include "mimetric.h" /* | | |--- MimeInlineTextRichtext */ -#include "mimetenr.h" /* | | | |--- MimeInlineTextEnriched */ +#include "mimethtm.h" /* | | |--- MimeInlineTextHTML */ +#include "mimethsa.h" /* | | | |--- M.I.TextHTMLSanitized */ +#include "mimetric.h" /* | | |--- MimeInlineTextRichtext */ +#include "mimetenr.h" /* | | | |--- MimeInlineTextEnriched */ /* SUPPORTED VIA PLUGIN | | |--- MimeInlineTextVCard */ -#include "mimeiimg.h" /* | |--- MimeInlineImage */ -#include "mimeeobj.h" /* | |--- MimeExternalObject */ -#include "mimeebod.h" /* |--- MimeExternalBody */ +#include "mimeiimg.h" /* | |--- MimeInlineImage */ +#include "mimeeobj.h" /* | |--- MimeExternalObject */ +#include "mimeebod.h" /* |--- MimeExternalBody */ /* If you add classes here,also add them to mimei.h */ #include "prlog.h" #include "prmem.h" @@ -87,7 +87,6 @@ #include "mimecth.h" #include "mimebuf.h" #include "nsIServiceManager.h" -#include "nsCRT.h" #include "mimemoz2.h" #include "nsIMimeContentTypeHandler.h" #include "nsIComponentManager.h" @@ -114,8 +113,8 @@ void getMsgHdrForCurrentURL(MimeDisplayOptions *opts, nsIMsgDBHdr ** aMsgHdr); #endif -#define IMAP_EXTERNAL_CONTENT_HEADER "X-Mozilla-IMAP-Part" -#define EXTERNAL_ATTACHMENT_URL_HEADER "X-Mozilla-External-Attachment-URL" +#define IMAP_EXTERNAL_CONTENT_HEADER "X-Mozilla-IMAP-Part" +#define EXTERNAL_ATTACHMENT_URL_HEADER "X-Mozilla-External-Attachment-URL" /* ========================================================================== Allocation and destruction @@ -123,7 +122,7 @@ void getMsgHdrForCurrentURL(MimeDisplayOptions *opts, nsIMsgDBHdr ** aMsgHdr); */ static int mime_classinit(MimeObjectClass *clazz); -/* +/* * These are the necessary defines/variables for doing * content type handlers in external plugins. */ @@ -133,7 +132,7 @@ typedef struct { } cthandler_struct; nsVoidArray *ctHandlerList = NULL; -PRBool foundIt = PR_FALSE; +PRBool foundIt = PR_FALSE; PRBool force_display = PR_FALSE; PRBool PR_CALLBACK @@ -145,7 +144,7 @@ EnumFunction(void* aElement, void *aData) if ( (!aElement) || (!aData) ) return PR_TRUE; - if (nsCRT::strcasecmp(ctPtr, ptr->content_type) == 0) + if (PL_strcasecmp(ctPtr, ptr->content_type) == 0) { foundIt = PR_TRUE; force_display = ptr->force_inline_display; @@ -157,10 +156,10 @@ EnumFunction(void* aElement, void *aData) /* * This will return TRUE if the content_type is found in the - * list, FALSE if it is not found. + * list, FALSE if it is not found. */ PRBool -find_content_type_attribs(const char *content_type, +find_content_type_attribs(const char *content_type, PRBool *force_inline_display) { *force_inline_display = PR_FALSE; @@ -177,7 +176,7 @@ find_content_type_attribs(const char *content_type, } void -add_content_type_attribs(const char *content_type, +add_content_type_attribs(const char *content_type, contentTypeHandlerInitStruct *ctHandlerInfo) { cthandler_struct *ptr = NULL; @@ -204,7 +203,7 @@ add_content_type_attribs(const char *content_type, ctHandlerList->AppendElement(ptr); } -/* +/* * This routine will find all content type handler for a specifc content * type (if it exists) */ @@ -217,12 +216,12 @@ force_inline_display(const char *content_type) return (force_inline_disp); } -/* +/* * This routine will find all content type handler for a specifc content * type (if it exists) and is defined to the nsRegistry */ MimeObjectClass * -mime_locate_external_content_handler(const char *content_type, +mime_locate_external_content_handler(const char *content_type, contentTypeHandlerInitStruct *ctHandlerInfo) { MimeObjectClass *newObj = NULL; @@ -231,7 +230,7 @@ mime_locate_external_content_handler(const char *content_type, nsresult rv; PR_snprintf(lookupID, sizeof(lookupID), "@mozilla.org/mimecth;1?type=%s", content_type); - + ctHandler = do_CreateInstance(lookupID, &rv); if (NS_FAILED(rv) || !ctHandler) { nsCOMPtr catman = @@ -249,7 +248,7 @@ mime_locate_external_content_handler(const char *content_type, if (NS_FAILED(rv) || !ctHandler) return nsnull; } - + rv = ctHandler->CreateContentTypeHandlerClass(content_type, ctHandlerInfo, &newObj); if (NS_FAILED(rv)) return nsnull; @@ -267,7 +266,7 @@ MIME_MimeObject_write(MimeObject *obj, const char *output, PRInt32 length, PRBoo MimeObject * mime_new (MimeObjectClass *clazz, MimeHeaders *hdrs, - const char *override_content_type) + const char *override_content_type) { int size = clazz->instance_size; MimeObject *object; @@ -278,18 +277,18 @@ mime_new (MimeObjectClass *clazz, MimeHeaders *hdrs, NS_ASSERTION(size > 0 && size < 1000, "1.1 19 Mar 1999 12:00"); if (!clazz->class_initialized) - { - status = mime_classinit(clazz); - if (status < 0) return 0; - } + { + status = mime_classinit(clazz); + if (status < 0) return 0; + } NS_ASSERTION(clazz->initialize && clazz->finalize, "1.1 19 Mar 1999 12:00"); if (hdrs) - { + { hdrs = MimeHeaders_copy (hdrs); - if (!hdrs) return 0; - } + if (!hdrs) return 0; + } object = (MimeObject *) PR_MALLOC(size); if (!object) return 0; @@ -300,15 +299,15 @@ mime_new (MimeObjectClass *clazz, MimeHeaders *hdrs, object->dontShowAsAttachment = PR_FALSE; if (override_content_type && *override_content_type) - object->content_type = nsCRT::strdup(override_content_type); + object->content_type = strdup(override_content_type); status = clazz->initialize(object); if (status < 0) - { - clazz->finalize(object); - PR_Free(object); - return 0; - } + { + clazz->finalize(object); + PR_Free(object); + return 0; + } return object; } @@ -325,7 +324,7 @@ mime_free (MimeObject *object) # ifdef DEBUG__ for (i = 0; i < (size / sizeof(*array)); i++) - array[i] = (PRUint32) 0xDEADBEEF; + array[i] = (PRUint32) 0xDEADBEEF; # endif /* DEBUG */ PR_Free(object); @@ -407,8 +406,8 @@ void getMsgHdrForCurrentURL(MimeDisplayOptions *opts, nsIMsgDBHdr ** aMsgHdr) *aMsgHdr = nsnull; if (!opts) - return; - + return; + mime_stream_data *msd = (mime_stream_data *) (opts->stream_closure); if (!msd) return; @@ -445,14 +444,14 @@ void getMsgHdrForCurrentURL(MimeDisplayOptions *opts, nsIMsgDBHdr ** aMsgHdr) MimeObjectClass * mime_find_class (const char *content_type, MimeHeaders *hdrs, - MimeDisplayOptions *opts, PRBool exact_match_p) + MimeDisplayOptions *opts, PRBool exact_match_p) { MimeObjectClass *clazz = 0; MimeObjectClass *tempClass = 0; contentTypeHandlerInitStruct ctHandlerInfo; // Read some prefs - nsIPrefBranch *prefBranch = GetPrefBranch(opts); + nsIPrefBranch *prefBranch = GetPrefBranch(opts); PRInt32 html_as = 0; // def. see below PRInt32 types_of_classes_to_disallow = 0; /* Let only a few libmime classes process incoming data. This protects from bugs (e.g. buffer overflows) @@ -481,7 +480,7 @@ mime_find_class (const char *content_type, MimeHeaders *hdrs, } #ifdef MOZ_THUNDERBIRD - // first, check to see if the message has been marked as JUNK. If it has, + // first, check to see if the message has been marked as JUNK. If it has, // then force the message to be rendered as simple. PRBool sanitizeJunkMail = PR_FALSE; @@ -506,8 +505,8 @@ mime_find_class (const char *content_type, MimeHeaders *hdrs, #endif /* - * What we do first is check for an external content handler plugin. - * This will actually extend the mime handling by calling a routine + * What we do first is check for an external content handler plugin. + * This will actually extend the mime handling by calling a routine * which will allow us to load an external content type handler * for specific content types. If one is not found, we will drop back * to the default handler. @@ -516,12 +515,12 @@ mime_find_class (const char *content_type, MimeHeaders *hdrs, { #ifdef MOZ_THUNDERBIRD // This is a case where we only want to add this property if we are a thunderbird build AND - // we have found an external mime content handler for text/calendar + // we have found an external mime content handler for text/calendar // This will enable iMIP support in Lightning - if ( hdrs && (!nsCRT::strncasecmp(content_type, "text/calendar", 13))) - { - char *full_content_type = MimeHeaders_get(hdrs, HEADER_CONTENT_TYPE, PR_FALSE, PR_FALSE); - if (full_content_type) + if ( hdrs && (!PL_strncasecmp(content_type, "text/calendar", 13))) + { + char *full_content_type = MimeHeaders_get(hdrs, HEADER_CONTENT_TYPE, PR_FALSE, PR_FALSE); + if (full_content_type) { char *imip_method = MimeHeaders_get_parameter(full_content_type, "method", NULL, NULL); nsCOMPtr msgHdr; @@ -529,14 +528,14 @@ mime_find_class (const char *content_type, MimeHeaders *hdrs, if (msgHdr) msgHdr->SetStringProperty("imip_method", (imip_method) ? imip_method : "nomethod"); // PR_Free checks for null - PR_Free(imip_method); + PR_Free(imip_method); PR_Free(full_content_type); - } + } } #endif if (types_of_classes_to_disallow > 0 - && (!nsCRT::strncasecmp(content_type, "text/x-vcard", 12)) + && (!PL_strncasecmp(content_type, "text/x-vcard", 12)) ) /* Use a little hack to prevent some dangerous plugins, which ship with Mozilla, to run. @@ -552,14 +551,14 @@ mime_find_class (const char *content_type, MimeHeaders *hdrs, else { if (!content_type || !*content_type || - !nsCRT::strcasecmp(content_type, "text")) /* with no / in the type */ + !PL_strcasecmp(content_type, "text")) /* with no / in the type */ clazz = (MimeObjectClass *)&mimeUntypedTextClass; - + /* Subtypes of text... */ - else if (!nsCRT::strncasecmp(content_type, "text/", 5)) + else if (!PL_strncasecmp(content_type, "text/", 5)) { - if (!nsCRT::strcasecmp(content_type+5, "html")) + if (!PL_strcasecmp(content_type+5, "html")) { if (opts && opts->format_out == nsMimeOutput::nsMimeMessageSaveAs) @@ -587,17 +586,17 @@ mime_find_class (const char *content_type, MimeHeaders *hdrs, which is less dangerous than defaulting to the raw HTML. */ clazz = (MimeObjectClass *)&mimeInlineTextHTMLAsPlaintextClass; } - else if (!nsCRT::strcasecmp(content_type+5, "enriched")) + else if (!PL_strcasecmp(content_type+5, "enriched")) clazz = (MimeObjectClass *)&mimeInlineTextEnrichedClass; - else if (!nsCRT::strcasecmp(content_type+5, "richtext")) + else if (!PL_strcasecmp(content_type+5, "richtext")) clazz = (MimeObjectClass *)&mimeInlineTextRichtextClass; - else if (!nsCRT::strcasecmp(content_type+5, "rtf")) + else if (!PL_strcasecmp(content_type+5, "rtf")) clazz = (MimeObjectClass *)&mimeExternalObjectClass; - else if (!nsCRT::strcasecmp(content_type+5, "plain")) + else if (!PL_strcasecmp(content_type+5, "plain")) { // Preliminary use the normal plain text clazz = (MimeObjectClass *)&mimeInlineTextPlainClass; - + if (opts && opts->format_out != nsMimeOutput::nsMimeMessageFilterSniffer && opts->format_out != nsMimeOutput::nsMimeMessageAttach) { @@ -627,7 +626,7 @@ mime_find_class (const char *content_type, MimeHeaders *hdrs, ? MimeHeaders_get_parameter(content_type_row, "format", NULL,NULL) : 0); - if (content_type_format && !nsCRT::strcasecmp(content_type_format, + if (content_type_format && !PL_strcasecmp(content_type_format, "flowed")) clazz = (MimeObjectClass *)&mimeInlineTextPlainFlowedClass; PR_FREEIF(content_type_format); @@ -638,26 +637,26 @@ mime_find_class (const char *content_type, MimeHeaders *hdrs, else if (!exact_match_p) clazz = (MimeObjectClass *)&mimeInlineTextPlainClass; } - + /* Subtypes of multipart... */ - else if (!nsCRT::strncasecmp(content_type, "multipart/", 10)) + else if (!PL_strncasecmp(content_type, "multipart/", 10)) { - if (!nsCRT::strcasecmp(content_type+10, "alternative")) + if (!PL_strcasecmp(content_type+10, "alternative")) clazz = (MimeObjectClass *)&mimeMultipartAlternativeClass; - else if (!nsCRT::strcasecmp(content_type+10, "related")) + else if (!PL_strcasecmp(content_type+10, "related")) clazz = (MimeObjectClass *)&mimeMultipartRelatedClass; - else if (!nsCRT::strcasecmp(content_type+10, "digest")) + else if (!PL_strcasecmp(content_type+10, "digest")) clazz = (MimeObjectClass *)&mimeMultipartDigestClass; - else if (!nsCRT::strcasecmp(content_type+10, "appledouble") || - !nsCRT::strcasecmp(content_type+10, "header-set")) + else if (!PL_strcasecmp(content_type+10, "appledouble") || + !PL_strcasecmp(content_type+10, "header-set")) clazz = (MimeObjectClass *)&mimeMultipartAppleDoubleClass; - else if (!nsCRT::strcasecmp(content_type+10, "parallel")) + else if (!PL_strcasecmp(content_type+10, "parallel")) clazz = (MimeObjectClass *)&mimeMultipartParallelClass; - else if (!nsCRT::strcasecmp(content_type+10, "mixed")) + else if (!PL_strcasecmp(content_type+10, "mixed")) clazz = (MimeObjectClass *)&mimeMultipartMixedClass; -#ifdef ENABLE_SMIME - else if (!nsCRT::strcasecmp(content_type+10, "signed")) +#ifdef ENABLE_SMIME + else if (!PL_strcasecmp(content_type+10, "signed")) { /* Check that the "protocol" and "micalg" parameters are ones we know about. */ @@ -675,27 +674,27 @@ mime_find_class (const char *content_type, MimeHeaders *hdrs, if (proto && ( (/* is a signature */ - !nsCRT::strcasecmp(proto, APPLICATION_XPKCS7_SIGNATURE) + !PL_strcasecmp(proto, APPLICATION_XPKCS7_SIGNATURE) || - !nsCRT::strcasecmp(proto, APPLICATION_PKCS7_SIGNATURE)) + !PL_strcasecmp(proto, APPLICATION_PKCS7_SIGNATURE)) && micalg - && (!nsCRT::strcasecmp(micalg, PARAM_MICALG_MD5) || - !nsCRT::strcasecmp(micalg, PARAM_MICALG_MD5_2) || - !nsCRT::strcasecmp(micalg, PARAM_MICALG_SHA1) || - !nsCRT::strcasecmp(micalg, PARAM_MICALG_SHA1_2) || - !nsCRT::strcasecmp(micalg, PARAM_MICALG_SHA1_3) || - !nsCRT::strcasecmp(micalg, PARAM_MICALG_SHA1_4) || - !nsCRT::strcasecmp(micalg, PARAM_MICALG_SHA1_5) || - !nsCRT::strcasecmp(micalg, PARAM_MICALG_MD2)))) + && (!PL_strcasecmp(micalg, PARAM_MICALG_MD5) || + !PL_strcasecmp(micalg, PARAM_MICALG_MD5_2) || + !PL_strcasecmp(micalg, PARAM_MICALG_SHA1) || + !PL_strcasecmp(micalg, PARAM_MICALG_SHA1_2) || + !PL_strcasecmp(micalg, PARAM_MICALG_SHA1_3) || + !PL_strcasecmp(micalg, PARAM_MICALG_SHA1_4) || + !PL_strcasecmp(micalg, PARAM_MICALG_SHA1_5) || + !PL_strcasecmp(micalg, PARAM_MICALG_MD2)))) clazz = (MimeObjectClass *)&mimeMultipartSignedCMSClass; else - clazz = 0; + clazz = 0; PR_FREEIF(proto); PR_FREEIF(micalg); PR_FREEIF(ct); - } + } #endif - + if (!clazz && !exact_match_p) /* Treat all unknown multipart subtypes as "multipart/mixed" */ clazz = (MimeObjectClass *)&mimeMultipartMixedClass; @@ -705,27 +704,27 @@ mime_find_class (const char *content_type, MimeHeaders *hdrs, if (clazz == (MimeObjectClass *)&mimeMultipartAlternativeClass) clazz = (MimeObjectClass *)&mimeMultipartMixedClass; } - + /* Subtypes of message... */ - else if (!nsCRT::strncasecmp(content_type, "message/", 8)) + else if (!PL_strncasecmp(content_type, "message/", 8)) { - if (!nsCRT::strcasecmp(content_type+8, "rfc822") || - !nsCRT::strcasecmp(content_type+8, "news")) + if (!PL_strcasecmp(content_type+8, "rfc822") || + !PL_strcasecmp(content_type+8, "news")) clazz = (MimeObjectClass *)&mimeMessageClass; - else if (!nsCRT::strcasecmp(content_type+8, "external-body")) + else if (!PL_strcasecmp(content_type+8, "external-body")) clazz = (MimeObjectClass *)&mimeExternalBodyClass; - else if (!nsCRT::strcasecmp(content_type+8, "partial")) + else if (!PL_strcasecmp(content_type+8, "partial")) /* I guess these are most useful as externals, for now... */ clazz = (MimeObjectClass *)&mimeExternalObjectClass; else if (!exact_match_p) /* Treat all unknown message subtypes as "text/plain" */ clazz = (MimeObjectClass *)&mimeInlineTextPlainClass; } - + /* The magic image types which we are able to display internally... */ - else if (!nsCRT::strncasecmp(content_type, "image/", 6)) { + else if (!PL_strncasecmp(content_type, "image/", 6)) { nsCOMPtr loader(do_GetService("@mozilla.org/image/loader;1")); PRBool isReg = PR_FALSE; loader->SupportImageWithMimeType(content_type, &isReg); @@ -734,22 +733,22 @@ mime_find_class (const char *content_type, MimeHeaders *hdrs, else clazz = (MimeObjectClass *)&mimeExternalObjectClass; } - + #ifdef ENABLE_SMIME - else if (!nsCRT::strcasecmp(content_type, APPLICATION_XPKCS7_MIME) - || !nsCRT::strcasecmp(content_type, APPLICATION_PKCS7_MIME)) - clazz = (MimeObjectClass *)&mimeEncryptedCMSClass; + else if (!PL_strcasecmp(content_type, APPLICATION_XPKCS7_MIME) + || !PL_strcasecmp(content_type, APPLICATION_PKCS7_MIME)) + clazz = (MimeObjectClass *)&mimeEncryptedCMSClass; #endif /* A few types which occur in the real world and which we would otherwise treat as non-text types (which would be bad) without this special-case... */ - else if (!nsCRT::strcasecmp(content_type, APPLICATION_PGP) || - !nsCRT::strcasecmp(content_type, APPLICATION_PGP2)) + else if (!PL_strcasecmp(content_type, APPLICATION_PGP) || + !PL_strcasecmp(content_type, APPLICATION_PGP2)) clazz = (MimeObjectClass *)&mimeInlineTextPlainClass; - else if (!nsCRT::strcasecmp(content_type, SUN_ATTACHMENT)) + else if (!PL_strcasecmp(content_type, SUN_ATTACHMENT)) clazz = (MimeObjectClass *)&mimeSunAttachmentClass; - + /* Everything else gets represented as a clickable link. */ else if (!exact_match_p) @@ -765,10 +764,10 @@ mime_find_class (const char *content_type, MimeHeaders *hdrs, clazz = 0; } } - + #ifdef ENABLE_SMIME // see bug #189988 - if (opts && opts->format_out == nsMimeOutput::nsMimeMessageDecrypt && + if (opts && opts->format_out == nsMimeOutput::nsMimeMessageDecrypt && (clazz != (MimeObjectClass *)&mimeEncryptedCMSClass)) { clazz = (MimeObjectClass *)&mimeExternalObjectClass; } @@ -781,10 +780,10 @@ mime_find_class (const char *content_type, MimeHeaders *hdrs, NS_ASSERTION(clazz, "1.1 19 Mar 1999 12:00"); if (clazz && !clazz->class_initialized) - { - int status = mime_classinit(clazz); - if (status < 0) return 0; - } + { + int status = mime_classinit(clazz); + if (status < 0) return 0; + } return clazz; } @@ -792,19 +791,19 @@ mime_find_class (const char *content_type, MimeHeaders *hdrs, MimeObject * mime_create (const char *content_type, MimeHeaders *hdrs, - MimeDisplayOptions *opts) + MimeDisplayOptions *opts) { /* If there is no Content-Disposition header, or if the Content-Disposition - is ``inline'', then we display the part inline (and let mime_find_class() - decide how.) + is ``inline'', then we display the part inline (and let mime_find_class() + decide how.) - If there is any other Content-Disposition (either ``attachment'' or some - disposition that we don't recognise) then we always display the part as - an external link, by using MimeExternalObject to display it. + If there is any other Content-Disposition (either ``attachment'' or some + disposition that we don't recognise) then we always display the part as + an external link, by using MimeExternalObject to display it. - But Content-Disposition is ignored for all containers except `message'. - (including multipart/mixed, and multipart/digest.) It's not clear if - this is to spec, but from a usability standpoint, I think it's necessary. + But Content-Disposition is ignored for all containers except `message'. + (including multipart/mixed, and multipart/digest.) It's not clear if + this is to spec, but from a usability standpoint, I think it's necessary. */ MimeObjectClass *clazz = 0; @@ -814,42 +813,42 @@ mime_create (const char *content_type, MimeHeaders *hdrs, /* There are some clients send out all attachments with a content-type - of application/octet-stream. So, if we have an octet-stream attachment, - try to guess what type it really is based on the file extension. I HATE - that we have to do this... + of application/octet-stream. So, if we have an octet-stream attachment, + try to guess what type it really is based on the file extension. I HATE + that we have to do this... */ if (hdrs && opts && opts->file_type_fn && - /* ### mwelch - don't override AppleSingle */ - (content_type ? nsCRT::strcasecmp(content_type, APPLICATION_APPLEFILE) : PR_TRUE) && - /* ## davidm Apple double shouldn't use this #$%& either. */ - (content_type ? nsCRT::strcasecmp(content_type, MULTIPART_APPLEDOUBLE) : PR_TRUE) && - (!content_type || - !nsCRT::strcasecmp(content_type, APPLICATION_OCTET_STREAM) || - !nsCRT::strcasecmp(content_type, UNKNOWN_CONTENT_TYPE))) - { - char *name = MimeHeaders_get_name(hdrs, opts); - if (name) - { - override_content_type = opts->file_type_fn (name, opts->stream_closure); - PR_FREEIF(name); + /* ### mwelch - don't override AppleSingle */ + (content_type ? PL_strcasecmp(content_type, APPLICATION_APPLEFILE) : PR_TRUE) && + /* ## davidm Apple double shouldn't use this #$%& either. */ + (content_type ? PL_strcasecmp(content_type, MULTIPART_APPLEDOUBLE) : PR_TRUE) && + (!content_type || + !PL_strcasecmp(content_type, APPLICATION_OCTET_STREAM) || + !PL_strcasecmp(content_type, UNKNOWN_CONTENT_TYPE))) + { + char *name = MimeHeaders_get_name(hdrs, opts); + if (name) + { + override_content_type = opts->file_type_fn (name, opts->stream_closure); + PR_FREEIF(name); - // Of, if we got here and it is not the unknown content type from the + // Of, if we got here and it is not the unknown content type from the // file name, lets do some better checking not to inline something bad - // - if (override_content_type && (nsCRT::strcasecmp(override_content_type, UNKNOWN_CONTENT_TYPE))) + // + if (override_content_type && (PL_strcasecmp(override_content_type, UNKNOWN_CONTENT_TYPE))) { // Only inline this if it makes sense to do so! if ( (!content_type) || - (content_type && (!nsCRT::strcasecmp(content_type, UNKNOWN_CONTENT_TYPE))) ) + (content_type && (!PL_strcasecmp(content_type, UNKNOWN_CONTENT_TYPE))) ) { - content_type = override_content_type; + content_type = override_content_type; } else PR_FREEIF(override_content_type); } - } - } + } + } clazz = mime_find_class(content_type, hdrs, opts, PR_FALSE); @@ -857,18 +856,18 @@ mime_create (const char *content_type, MimeHeaders *hdrs, if (!clazz) goto FAIL; if (opts && opts->part_to_load) - /* Always ignore Content-Disposition when we're loading some specific - sub-part (which may be within some container that we wouldn't otherwise - descend into, if the container itself had a Content-Disposition of - `attachment'. */ - content_disposition = 0; + /* Always ignore Content-Disposition when we're loading some specific + sub-part (which may be within some container that we wouldn't otherwise + descend into, if the container itself had a Content-Disposition of + `attachment'. */ + content_disposition = 0; else if (mime_subclass_p(clazz,(MimeObjectClass *)&mimeContainerClass) && - !mime_subclass_p(clazz,(MimeObjectClass *)&mimeMessageClass)) - /* Ignore Content-Disposition on all containers except `message'. - That is, Content-Disposition is ignored for multipart/mixed objects, - but is obeyed for message/rfc822 objects. */ - content_disposition = 0; + !mime_subclass_p(clazz,(MimeObjectClass *)&mimeMessageClass)) + /* Ignore Content-Disposition on all containers except `message'. + That is, Content-Disposition is ignored for multipart/mixed objects, + but is obeyed for message/rfc822 objects. */ + content_disposition = 0; else { @@ -876,21 +875,21 @@ mime_create (const char *content_type, MimeHeaders *hdrs, to make it appear inline. One example is a vcard which has a content disposition of an "attachment;" */ if (force_inline_display(content_type)) - NS_MsgSACopy(&content_disposition, "inline"); + NS_MsgSACopy(&content_disposition, "inline"); else - content_disposition = (hdrs - ? MimeHeaders_get(hdrs, HEADER_CONTENT_DISPOSITION, PR_TRUE, PR_FALSE) - : 0); + content_disposition = (hdrs + ? MimeHeaders_get(hdrs, HEADER_CONTENT_DISPOSITION, PR_TRUE, PR_FALSE) + : 0); } - if (!content_disposition || !nsCRT::strcasecmp(content_disposition, "inline")) - ; /* Use the class we've got. */ + if (!content_disposition || !PL_strcasecmp(content_disposition, "inline")) + ; /* Use the class we've got. */ else - { - // + { + // // rhp: Ok, this is a modification to try to deal with messages // that have content disposition set to "attachment" even though - // we probably should show them inline. + // we probably should show them inline. // if ( (clazz != (MimeObjectClass *)&mimeInlineTextHTMLClass) && (clazz != (MimeObjectClass *)&mimeInlineTextClass) && @@ -934,7 +933,7 @@ mime_create (const char *content_type, MimeHeaders *hdrs, !mime_subclass_p(clazz,(MimeObjectClass *)&mimeMessageClass)) /* Multipart subtypes are ok, except for messages; descend into multiparts, and defer judgement. - + Encrypted blobs are just like other containers (make the crypto layer invisible, and treat them as simple containers. So there's no easy way to save encrypted data directly to disk; it will tend @@ -958,21 +957,21 @@ mime_create (const char *content_type, MimeHeaders *hdrs, FAIL: /* If we decided to ignore the content-type in the headers of this object - (see above) then make sure that our new content-type is stored in the - object itself. (Or free it, if we're in an out-of-memory situation.) + (see above) then make sure that our new content-type is stored in the + object itself. (Or free it, if we're in an out-of-memory situation.) */ if (override_content_type) - { - if (obj) - { - PR_FREEIF(obj->content_type); - obj->content_type = override_content_type; - } - else - { - PR_Free(override_content_type); - } - } + { + if (obj) + { + PR_FREEIF(obj->content_type); + obj->content_type = override_content_type; + } + else + { + PR_Free(override_content_type); + } + } return obj; } @@ -986,22 +985,22 @@ mime_classinit(MimeObjectClass *clazz) { int status; if (clazz->class_initialized) - return 0; + return 0; NS_ASSERTION(clazz->class_initialize, "1.1 19 Mar 1999 12:00"); if (!clazz->class_initialize) - return -1; + return -1; /* First initialize the superclass. */ if (clazz->superclass && !clazz->superclass->class_initialized) - { - status = mime_classinit(clazz->superclass); - if (status < 0) return status; - } + { + status = mime_classinit(clazz->superclass); + if (status < 0) return status; + } /* Now run each of the superclass-init procedures in turn, - parentmost-first. */ + parentmost-first. */ status = mime_classinit_1(clazz, clazz); if (status < 0) return status; @@ -1015,10 +1014,10 @@ mime_classinit_1(MimeObjectClass *clazz, MimeObjectClass *target) { int status; if (clazz->superclass) - { - status = mime_classinit_1(clazz->superclass, target); - if (status < 0) return status; - } + { + status = mime_classinit_1(clazz->superclass, target); + if (status < 0) return status; + } return clazz->class_initialize(target); } @@ -1027,11 +1026,11 @@ PRBool mime_subclass_p(MimeObjectClass *child, MimeObjectClass *parent) { if (child == parent) - return PR_TRUE; + return PR_TRUE; else if (!child->superclass) - return PR_FALSE; + return PR_FALSE; else - return mime_subclass_p(child->superclass, parent); + return mime_subclass_p(child->superclass, parent); } PRBool @@ -1053,52 +1052,52 @@ char * mime_part_address(MimeObject *obj) { if (!obj->parent) - return nsCRT::strdup("0"); + return strdup("0"); else - { - /* Find this object in its parent. */ - PRInt32 i, j = -1; - char buf [20]; - char *higher = 0; - MimeContainer *cont = (MimeContainer *) obj->parent; - NS_ASSERTION(mime_typep(obj->parent, + { + /* Find this object in its parent. */ + PRInt32 i, j = -1; + char buf [20]; + char *higher = 0; + MimeContainer *cont = (MimeContainer *) obj->parent; + NS_ASSERTION(mime_typep(obj->parent, (MimeObjectClass *)&mimeContainerClass), "1.1 19 Mar 1999 12:00"); - for (i = 0; i < cont->nchildren; i++) - if (cont->children[i] == obj) - { - j = i+1; - break; - } - if (j == -1) - { - NS_ASSERTION(0, "1.1 19 Mar 1999 12:00"); - return 0; - } + for (i = 0; i < cont->nchildren; i++) + if (cont->children[i] == obj) + { + j = i+1; + break; + } + if (j == -1) + { + NS_ASSERTION(0, "1.1 19 Mar 1999 12:00"); + return 0; + } - PR_snprintf(buf, sizeof(buf), "%ld", j); - if (obj->parent->parent) - { - higher = mime_part_address(obj->parent); - if (!higher) return 0; /* MIME_OUT_OF_MEMORY */ - } + PR_snprintf(buf, sizeof(buf), "%ld", j); + if (obj->parent->parent) + { + higher = mime_part_address(obj->parent); + if (!higher) return 0; /* MIME_OUT_OF_MEMORY */ + } - if (!higher) - return nsCRT::strdup(buf); - else - { - char *s = (char *)PR_MALLOC(strlen(higher) + strlen(buf) + 3); - if (!s) - { - PR_Free(higher); - return 0; /* MIME_OUT_OF_MEMORY */ - } - PL_strcpy(s, higher); - PL_strcat(s, "."); - PL_strcat(s, buf); - PR_Free(higher); - return s; - } - } + if (!higher) + return strdup(buf); + else + { + char *s = (char *)PR_MALLOC(strlen(higher) + strlen(buf) + 3); + if (!s) + { + PR_Free(higher); + return 0; /* MIME_OUT_OF_MEMORY */ + } + PL_strcpy(s, higher); + PL_strcat(s, "."); + PL_strcat(s, buf); + PR_Free(higher); + return s; + } + } } @@ -1117,10 +1116,10 @@ mime_imap_part_address(MimeObject *obj) } /* Returns a full URL if the current mime object has a EXTERNAL_ATTACHMENT_URL_HEADER - header. + header. Return value must be freed by the caller. */ -char * +char * mime_external_attachment_url(MimeObject *obj) { if (!obj || !obj->headers) @@ -1146,24 +1145,24 @@ mime_crypto_object_p(MimeHeaders *hdrs, PRBool clearsigned_counts) if (!ct) return PR_FALSE; /* Rough cut -- look at the string before doing a more complex comparison. */ - if (nsCRT::strcasecmp(ct, MULTIPART_SIGNED) && - nsCRT::strncasecmp(ct, "application/", 12)) - { - PR_Free(ct); - return PR_FALSE; - } + if (PL_strcasecmp(ct, MULTIPART_SIGNED) && + PL_strncasecmp(ct, "application/", 12)) + { + PR_Free(ct); + return PR_FALSE; + } /* It's a candidate for being a crypto object. Let's find out for sure... */ clazz = mime_find_class (ct, hdrs, 0, PR_TRUE); PR_Free(ct); if (clazz == ((MimeObjectClass *)&mimeEncryptedCMSClass)) - return PR_TRUE; + return PR_TRUE; else if (clearsigned_counts && - clazz == ((MimeObjectClass *)&mimeMultipartSignedCMSClass)) - return PR_TRUE; + clazz == ((MimeObjectClass *)&mimeMultipartSignedCMSClass)) + return PR_TRUE; else - return PR_FALSE; + return PR_FALSE; } /* Whether the given object has written out the HTML version of its headers @@ -1176,9 +1175,9 @@ mime_crypto_stamped_p(MimeObject *obj) { if (!obj) return PR_FALSE; if (mime_typep (obj, (MimeObjectClass *) &mimeMessageClass)) - return ((MimeMessage *) obj)->crypto_stamped_p; + return ((MimeMessage *) obj)->crypto_stamped_p; else - return PR_FALSE; + return PR_FALSE; } #endif // ENABLE_SMIME @@ -1209,63 +1208,63 @@ mime_set_url_part(const char *url, const char *part, PRBool append_p) } for (s = url; *s; s++) - { - if (*s == '?') - { - got_q = PR_TRUE; - if (!nsCRT::strncasecmp(s, "?part=", 6)) - part_begin = (s += 6); - } - else if (got_q && *s == '&' && !nsCRT::strncasecmp(s, "&part=", 6)) - part_begin = (s += 6); + { + if (*s == '?') + { + got_q = PR_TRUE; + if (!PL_strncasecmp(s, "?part=", 6)) + part_begin = (s += 6); + } + else if (got_q && *s == '&' && !PL_strncasecmp(s, "&part=", 6)) + part_begin = (s += 6); - if (part_begin) - { - for (; (*s && *s != '?' && *s != '&'); s++) - ; - part_end = s; - break; + if (part_begin) + { + for (; (*s && *s != '?' && *s != '&'); s++) + ; + part_end = s; + break; } - } + } result = (char *) PR_MALLOC(strlen(url) + strlen(part) + 10); if (!result) return 0; if (part_begin) - { - if (append_p) - { - memcpy(result, url, part_end - url); - result [part_end - url] = '.'; - result [part_end - url + 1] = 0; - } - else - { - memcpy(result, url, part_begin - url); - result [part_begin - url] = 0; - } - } + { + if (append_p) + { + memcpy(result, url, part_end - url); + result [part_end - url] = '.'; + result [part_end - url + 1] = 0; + } + else + { + memcpy(result, url, part_begin - url); + result [part_begin - url] = 0; + } + } else - { - PL_strcpy(result, url); - if (got_q) - PL_strcat(result, "&part="); - else - PL_strcat(result, "?part="); - } + { + PL_strcpy(result, url); + if (got_q) + PL_strcat(result, "&part="); + else + PL_strcat(result, "?part="); + } PL_strcat(result, part); if (part_end && *part_end) - PL_strcat(result, part_end); + PL_strcat(result, part_end); /* Semi-broken kludge to omit a trailing "?part=0". */ { - int L = strlen(result); - if (L > 6 && - (result[L-7] == '?' || result[L-7] == '&') && - !nsCRT::strcmp("part=0", result + L - 6)) - result[L-7] = 0; + int L = strlen(result); + if (L > 6 && + (result[L-7] == '?' || result[L-7] == '&') && + !strcmp("part=0", result + L - 6)) + result[L-7] = 0; } return result; @@ -1283,9 +1282,9 @@ mime_set_url_imap_part(const char *url, const char *imappart, const char *libmim char *whereCurrent = PL_strstr(url, "/;section="); if (whereCurrent) { - *whereCurrent = 0; + *whereCurrent = 0; } - + result = (char *) PR_MALLOC(strlen(url) + strlen(imappart) + strlen(libmimepart) + 17); if (!result) return 0; @@ -1297,7 +1296,7 @@ mime_set_url_imap_part(const char *url, const char *imappart, const char *libmim result[strlen(result)] = 0; if (whereCurrent) - *whereCurrent = '/'; + *whereCurrent = '/'; return result; } @@ -1311,43 +1310,43 @@ MimeObject * mime_address_to_part(const char *part, MimeObject *obj) { /* Note: this is an N^2 operation, but the number of parts in a message - shouldn't ever be large enough that this really matters... */ + shouldn't ever be large enough that this really matters... */ PRBool match; if (!part || !*part) - { - match = !obj->parent; - } + { + match = !obj->parent; + } else - { - char *part2 = mime_part_address(obj); - if (!part2) return 0; /* MIME_OUT_OF_MEMORY */ - match = !nsCRT::strcmp(part, part2); - PR_Free(part2); - } + { + char *part2 = mime_part_address(obj); + if (!part2) return 0; /* MIME_OUT_OF_MEMORY */ + match = !strcmp(part, part2); + PR_Free(part2); + } if (match) - { - /* These are the droids we're looking for. */ - return obj; - } + { + /* These are the droids we're looking for. */ + return obj; + } else if (!mime_typep(obj, (MimeObjectClass *) &mimeContainerClass)) - { - /* Not a container, pull up, pull up! */ - return 0; - } + { + /* Not a container, pull up, pull up! */ + return 0; + } else - { - PRInt32 i; - MimeContainer *cont = (MimeContainer *) obj; - for (i = 0; i < cont->nchildren; i++) - { - MimeObject *o2 = mime_address_to_part(part, cont->children[i]); - if (o2) return o2; - } - return 0; - } + { + PRInt32 i; + MimeContainer *cont = (MimeContainer *) obj; + for (i = 0; i < cont->nchildren; i++) + { + MimeObject *o2 = mime_address_to_part(part, cont->children[i]); + if (o2) return o2; + } + return 0; + } } /* Given a part ID, looks through the MimeObject tree for a sub-part whose ID @@ -1382,82 +1381,82 @@ mime_find_suggested_name_of_part(const char *part, MimeObject *obj) result = (obj->headers ? MimeHeaders_get_name(obj->headers, obj->options) : 0); /* If this part doesn't have a name, but this part is one fork of an - AppleDouble, and the AppleDouble itself has a name, then use that. */ + AppleDouble, and the AppleDouble itself has a name, then use that. */ if (!result && - obj->parent && - obj->parent->headers && - mime_typep(obj->parent, - (MimeObjectClass *) &mimeMultipartAppleDoubleClass)) - result = MimeHeaders_get_name(obj->parent->headers, obj->options); + obj->parent && + obj->parent->headers && + mime_typep(obj->parent, + (MimeObjectClass *) &mimeMultipartAppleDoubleClass)) + result = MimeHeaders_get_name(obj->parent->headers, obj->options); /* Else, if this part is itself an AppleDouble, and one of its children - has a name, then use that (check data fork first, then resource.) */ + has a name, then use that (check data fork first, then resource.) */ if (!result && - mime_typep(obj, (MimeObjectClass *) &mimeMultipartAppleDoubleClass)) - { - MimeContainer *cont = (MimeContainer *) obj; - if (cont->nchildren > 1 && - cont->children[1] && - cont->children[1]->headers) - result = MimeHeaders_get_name(cont->children[1]->headers, obj->options); + mime_typep(obj, (MimeObjectClass *) &mimeMultipartAppleDoubleClass)) + { + MimeContainer *cont = (MimeContainer *) obj; + if (cont->nchildren > 1 && + cont->children[1] && + cont->children[1]->headers) + result = MimeHeaders_get_name(cont->children[1]->headers, obj->options); - if (!result && - cont->nchildren > 0 && - cont->children[0] && - cont->children[0]->headers) - result = MimeHeaders_get_name(cont->children[0]->headers, obj->options); - } + if (!result && + cont->nchildren > 0 && + cont->children[0] && + cont->children[0]->headers) + result = MimeHeaders_get_name(cont->children[0]->headers, obj->options); + } /* Ok, now we have the suggested name, if any. - Now we remove any extensions that correspond to the - Content-Transfer-Encoding. For example, if we see the headers + Now we remove any extensions that correspond to the + Content-Transfer-Encoding. For example, if we see the headers - Content-Type: text/plain - Content-Disposition: inline; filename=foo.text.uue - Content-Transfer-Encoding: x-uuencode + Content-Type: text/plain + Content-Disposition: inline; filename=foo.text.uue + Content-Transfer-Encoding: x-uuencode - then we would look up (in mime.types) the file extensions which are - associated with the x-uuencode encoding, find that "uue" is one of - them, and remove that from the end of the file name, thus returning - "foo.text" as the name. This is because, by the time this file ends - up on disk, its content-transfer-encoding will have been removed; - therefore, we should suggest a file name that indicates that. + then we would look up (in mime.types) the file extensions which are + associated with the x-uuencode encoding, find that "uue" is one of + them, and remove that from the end of the file name, thus returning + "foo.text" as the name. This is because, by the time this file ends + up on disk, its content-transfer-encoding will have been removed; + therefore, we should suggest a file name that indicates that. */ if (result && obj->encoding && *obj->encoding) - { - PRInt32 L = strlen(result); - const char **exts = 0; + { + PRInt32 L = strlen(result); + const char **exts = 0; - /* - I'd like to ask the mime.types file, "what extensions correspond - to obj->encoding (which happens to be "x-uuencode") but doing that - in a non-sphagetti way would require brain surgery. So, since - currently uuencode is the only content-transfer-encoding which we - understand which traditionally has an extension, we just special- - case it here! Icepicks in my forehead! + /* + I'd like to ask the mime.types file, "what extensions correspond + to obj->encoding (which happens to be "x-uuencode") but doing that + in a non-sphagetti way would require brain surgery. So, since + currently uuencode is the only content-transfer-encoding which we + understand which traditionally has an extension, we just special- + case it here! Icepicks in my forehead! - Note that it's special-cased in a similar way in libmsg/compose.c. - */ - if (!nsCRT::strcasecmp(obj->encoding, ENCODING_UUENCODE)) - { - static const char *uue_exts[] = { "uu", "uue", 0 }; - exts = uue_exts; - } + Note that it's special-cased in a similar way in libmsg/compose.c. + */ + if (!PL_strcasecmp(obj->encoding, ENCODING_UUENCODE)) + { + static const char *uue_exts[] = { "uu", "uue", 0 }; + exts = uue_exts; + } - while (exts && *exts) - { - const char *ext = *exts; - PRInt32 L2 = strlen(ext); - if (L > L2 + 1 && /* long enough */ - result[L - L2 - 1] == '.' && /* '.' in right place*/ - !nsCRT::strcasecmp(ext, result + (L - L2))) /* ext matches */ - { - result[L - L2 - 1] = 0; /* truncate at '.' and stop. */ - break; - } - exts++; - } - } + while (exts && *exts) + { + const char *ext = *exts; + PRInt32 L2 = strlen(ext); + if (L > L2 + 1 && /* long enough */ + result[L - L2 - 1] == '.' && /* '.' in right place*/ + !PL_strcasecmp(ext, result + (L - L2))) /* ext matches */ + { + result[L - L2 - 1] = 0; /* truncate at '.' and stop. */ + break; + } + exts++; + } + } return result; } @@ -1469,10 +1468,10 @@ mime_parse_url_options(const char *url, MimeDisplayOptions *options) { const char *q; MimeHeadersState default_headers = options->headers; - + if (!url || !*url) return 0; if (!options) return 0; - + q = PL_strrchr (url, '?'); if (! q) return 0; q++; @@ -1487,26 +1486,26 @@ mime_parse_url_options(const char *url, MimeDisplayOptions *options) if (value < end) value++; if (name_end <= q) ; - else if (!nsCRT::strncasecmp ("headers", q, name_end - q)) + else if (!PL_strncasecmp ("headers", q, name_end - q)) { - if (end > value && !nsCRT::strncasecmp ("only", value, end-value)) + if (end > value && !PL_strncasecmp ("only", value, end-value)) options->headers = MimeHeadersOnly; - else if (end > value && !nsCRT::strncasecmp ("none", value, end-value)) - options->headers = MimeHeadersNone; - else if (end > value && !nsCRT::strncasecmp ("all", value, end - value)) + else if (end > value && !PL_strncasecmp ("none", value, end-value)) + options->headers = MimeHeadersNone; + else if (end > value && !PL_strncasecmp ("all", value, end - value)) options->headers = MimeHeadersAll; - else if (end > value && !nsCRT::strncasecmp ("some", value, end - value)) + else if (end > value && !PL_strncasecmp ("some", value, end - value)) options->headers = MimeHeadersSome; - else if (end > value && !nsCRT::strncasecmp ("micro", value, end - value)) + else if (end > value && !PL_strncasecmp ("micro", value, end - value)) options->headers = MimeHeadersMicro; - else if (end > value && !nsCRT::strncasecmp ("cite", value, end - value)) + else if (end > value && !PL_strncasecmp ("cite", value, end - value)) options->headers = MimeHeadersCitation; - else if (end > value && !nsCRT::strncasecmp ("citation", value, end-value)) + else if (end > value && !PL_strncasecmp ("citation", value, end-value)) options->headers = MimeHeadersCitation; else options->headers = default_headers; } - else if (!nsCRT::strncasecmp ("part", q, name_end - q) && + else if (!PL_strncasecmp ("part", q, name_end - q) && options->format_out != nsMimeOutput::nsMimeMessageBodyQuoting) { PR_FREEIF (options->part_to_load); @@ -1519,20 +1518,20 @@ mime_parse_url_options(const char *url, MimeDisplayOptions *options) options->part_to_load[end-value] = 0; } } - else if (!nsCRT::strncasecmp ("rot13", q, name_end - q)) + else if (!PL_strncasecmp ("rot13", q, name_end - q)) { - options->rot13_p = end <= value || !nsCRT::strncasecmp ("true", value, end - value); + options->rot13_p = end <= value || !PL_strncasecmp ("true", value, end - value); } - + q = end; if (*q) q++; } - - + + /* Compatibility with the "?part=" syntax used in the old (Mozilla 2.0) - MIME parser. - + MIME parser. + Basically, the problem is that the old part-numbering code was totally busted: here's a comparison of the old and new numberings with a pair of hypothetical messages (one with a single part, and one with nested @@ -1540,7 +1539,7 @@ mime_parse_url_options(const char *url, MimeDisplayOptions *options) NEW: OLD: OR: message/rfc822 image/jpeg 1 0 0 - + message/rfc822 multipart/mixed 1 0 0 text/plain 1.1 1 1 @@ -1560,48 +1559,48 @@ mime_parse_url_options(const char *url, MimeDisplayOptions *options) "Attachments As Links" (or used a URL like "?inline=false&part=...") then you got a totally different numbering system (seen in the "OR" column.) Gag! - + So, the problem is, ClariNet had been using these part numbers in their HTML news feeds, as a sleazy way of transmitting both complex HTML layouts and images using NNTP as transport, without invoking HTTP. - + The following clause is to provide some small amount of backward compatibility. By looking at that table, one can see that in the new model, "part=0" has no meaning, and neither does "part=2" or "part=3" and so on. - + "part=1" is ambiguous between the old and new way, as is any part specification that has a "." in it. - + So, the compatibility hack we do here is: if the part is "0", then map that to "1". And if the part is >= "2", then prepend "1." to it (so that we map "2" to "1.2", and "3" to "1.3".) - + This leaves the URLs compatible in the cases of: - + = single part messages = references to elements of a top-level multipart except the first - + and leaves them incompatible for: - + = the first part of a top-level multipart = all elements deeper than the outermost part - + Life s#$%s when you don't properly think out things that end up turning into de-facto standards... */ if (options->part_to_load && - !PL_strchr(options->part_to_load, '.')) /* doesn't contain a dot */ + !PL_strchr(options->part_to_load, '.')) /* doesn't contain a dot */ { - if (!nsCRT::strcmp(options->part_to_load, "0")) /* 0 */ + if (!strcmp(options->part_to_load, "0")) /* 0 */ { PR_Free(options->part_to_load); - options->part_to_load = nsCRT::strdup("1"); + options->part_to_load = strdup("1"); if (!options->part_to_load) return MIME_OUT_OF_MEMORY; } - else if (nsCRT::strcmp(options->part_to_load, "1")) /* not 1 */ + else if (strcmp(options->part_to_load, "1")) /* not 1 */ { const char *prefix = "1."; char *s = (char *) PR_MALLOC(strlen(options->part_to_load) + @@ -1613,7 +1612,7 @@ mime_parse_url_options(const char *url, MimeDisplayOptions *options) options->part_to_load = s; } } - + return 0; } @@ -1623,12 +1622,12 @@ mime_parse_url_options(const char *url, MimeDisplayOptions *options) int MimeOptions_write(MimeDisplayOptions *opt, const char *data, PRInt32 length, - PRBool user_visible_p) + PRBool user_visible_p) { int status = 0; void* closure = 0; if (!opt || !opt->output_fn || !opt->state) - return 0; + return 0; closure = opt->output_closure; if (!closure) closure = opt->stream_closure; @@ -1636,33 +1635,33 @@ MimeOptions_write(MimeDisplayOptions *opt, const char *data, PRInt32 length, // PR_ASSERT(opt->state->first_data_written_p); if (opt->state->separator_queued_p && user_visible_p) - { - opt->state->separator_queued_p = PR_FALSE; - if (opt->state->separator_suppressed_p) - opt->state->separator_suppressed_p = PR_FALSE; - else - { - char sep[] = "



"; - int lstatus = opt->output_fn(sep, strlen(sep), closure); - opt->state->separator_suppressed_p = PR_FALSE; - if (lstatus < 0) return lstatus; - } - } + { + opt->state->separator_queued_p = PR_FALSE; + if (opt->state->separator_suppressed_p) + opt->state->separator_suppressed_p = PR_FALSE; + else + { + char sep[] = "


"; + int lstatus = opt->output_fn(sep, strlen(sep), closure); + opt->state->separator_suppressed_p = PR_FALSE; + if (lstatus < 0) return lstatus; + } + } if (user_visible_p) - opt->state->separator_suppressed_p = PR_FALSE; + opt->state->separator_suppressed_p = PR_FALSE; if (length > 0) - { - status = opt->output_fn(data, length, closure); - if (status < 0) return status; - } + { + status = opt->output_fn(data, length, closure); + if (status < 0) return status; + } return 0; } int MimeObject_write(MimeObject *obj, const char *output, PRInt32 length, - PRBool user_visible_p) + PRBool user_visible_p) { if (!obj->output_p) return 0; @@ -1700,31 +1699,31 @@ int MimeObject_output_init(MimeObject *obj, const char *content_type) { if (obj && - obj->options && - obj->options->state && - !obj->options->state->first_data_written_p) - { - int status; - const char *charset = 0; - char *name = 0, *x_mac_type = 0, *x_mac_creator = 0; + obj->options && + obj->options->state && + !obj->options->state->first_data_written_p) + { + int status; + const char *charset = 0; + char *name = 0, *x_mac_type = 0, *x_mac_creator = 0; - if (!obj->options->output_init_fn) - { - obj->options->state->first_data_written_p = PR_TRUE; - return 0; - } + if (!obj->options->output_init_fn) + { + obj->options->state->first_data_written_p = PR_TRUE; + return 0; + } - if (obj->headers) - { - char *ct; - name = MimeHeaders_get_name(obj->headers, obj->options); + if (obj->headers) + { + char *ct; + name = MimeHeaders_get_name(obj->headers, obj->options); - ct = MimeHeaders_get(obj->headers, HEADER_CONTENT_TYPE, - PR_FALSE, PR_FALSE); - if (ct) - { - x_mac_type = MimeHeaders_get_parameter(ct, PARAM_X_MAC_TYPE, NULL, NULL); - x_mac_creator= MimeHeaders_get_parameter(ct, PARAM_X_MAC_CREATOR, NULL, NULL); + ct = MimeHeaders_get(obj->headers, HEADER_CONTENT_TYPE, + PR_FALSE, PR_FALSE); + if (ct) + { + x_mac_type = MimeHeaders_get_parameter(ct, PARAM_X_MAC_TYPE, NULL, NULL); + x_mac_creator= MimeHeaders_get_parameter(ct, PARAM_X_MAC_CREATOR, NULL, NULL); /* if don't have a x_mac_type and x_mac_creator, we need to try to get it from its parent */ if (!x_mac_type && !x_mac_creator && obj->parent && obj->parent->headers) { @@ -1736,7 +1735,7 @@ MimeObject_output_init(MimeObject *obj, const char *content_type) PR_Free(ctp); } } - + if (!(obj->options->override_charset)) { char *charset = MimeHeaders_get_parameter(ct, "charset", nsnull, nsnull); if (charset) @@ -1745,39 +1744,39 @@ MimeObject_output_init(MimeObject *obj, const char *content_type) obj->options->default_charset = charset; } } - PR_Free(ct); - } - } + PR_Free(ct); + } + } - if (mime_typep(obj, (MimeObjectClass *) &mimeInlineTextClass)) - charset = ((MimeInlineText *)obj)->charset; + if (mime_typep(obj, (MimeObjectClass *) &mimeInlineTextClass)) + charset = ((MimeInlineText *)obj)->charset; - if (!content_type) - content_type = obj->content_type; - if (!content_type) - content_type = TEXT_PLAIN; + if (!content_type) + content_type = obj->content_type; + if (!content_type) + content_type = TEXT_PLAIN; - // - // Set the charset on the channel we are dealing with so people know - // what the charset is set to. Do this for quoting/Printing ONLY! - // + // + // Set the charset on the channel we are dealing with so people know + // what the charset is set to. Do this for quoting/Printing ONLY! + // extern void PR_CALLBACK ResetChannelCharset(MimeObject *obj); - if ( (obj->options) && - ( (obj->options->format_out == nsMimeOutput::nsMimeMessageQuoting) || - (obj->options->format_out == nsMimeOutput::nsMimeMessageBodyQuoting) || - (obj->options->format_out == nsMimeOutput::nsMimeMessageSaveAs) || - (obj->options->format_out == nsMimeOutput::nsMimeMessagePrintOutput) ) ) - ResetChannelCharset(obj); + if ( (obj->options) && + ( (obj->options->format_out == nsMimeOutput::nsMimeMessageQuoting) || + (obj->options->format_out == nsMimeOutput::nsMimeMessageBodyQuoting) || + (obj->options->format_out == nsMimeOutput::nsMimeMessageSaveAs) || + (obj->options->format_out == nsMimeOutput::nsMimeMessagePrintOutput) ) ) + ResetChannelCharset(obj); - status = obj->options->output_init_fn (content_type, charset, name, - x_mac_type, x_mac_creator, - obj->options->stream_closure); - PR_FREEIF(name); - PR_FREEIF(x_mac_type); - PR_FREEIF(x_mac_creator); - obj->options->state->first_data_written_p = PR_TRUE; - return status; - } + status = obj->options->output_init_fn (content_type, charset, name, + x_mac_type, x_mac_creator, + obj->options->stream_closure); + PR_FREEIF(name); + PR_FREEIF(x_mac_type); + PR_FREEIF(x_mac_creator); + obj->options->state->first_data_written_p = PR_TRUE; + return status; + } return 0; } @@ -1794,7 +1793,7 @@ mime_get_base_url(const char *url) s = (nextTerm) ? nextTerm : s + strlen(s) - 1; } // we need to keep the ?number part of the url, or we won't know - // which local message the part belongs to. + // which local message the part belongs to. if (s && *s && *(s+1) && !strncmp(s + 1, "number=", sizeof("number=") - 1)) { const char *nextTerm = strchr(++s, '&'); diff --git a/mozilla/mailnews/mime/src/mimeiimg.cpp b/mozilla/mailnews/mime/src/mimeiimg.cpp index c1745de57ab..fd0532a48ec 100644 --- a/mozilla/mailnews/mime/src/mimeiimg.cpp +++ b/mozilla/mailnews/mime/src/mimeiimg.cpp @@ -42,12 +42,11 @@ #include "prlog.h" #include "nsMimeTypes.h" #include "nsMimeStringResources.h" -#include "nsCRT.h" #include "nsEscape.h" #define MIME_SUPERCLASS mimeLeafClass MimeDefClass(MimeInlineImage, MimeInlineImageClass, - mimeInlineImageClass, &MIME_SUPERCLASS); + mimeInlineImageClass, &MIME_SUPERCLASS); static int MimeInlineImage_initialize (MimeObject *); static void MimeInlineImage_finalize (MimeObject *); @@ -114,7 +113,7 @@ MimeInlineImage_parse_begin (MimeObject *obj) part = mime_part_address(obj); if (!part) return MIME_OUT_OF_MEMORY; - + char *no_part_url = nsnull; if (obj->options->part_to_load && obj->options->format_out == nsMimeOutput::nsMimeMessageBodyDisplay) no_part_url = mime_get_base_url(obj->options->url); @@ -129,15 +128,15 @@ MimeInlineImage_parse_begin (MimeObject *obj) if (!image_url) { - PR_Free(part); + PR_Free(part); return MIME_OUT_OF_MEMORY; } PR_Free(part); - + ct = obj->content_type; if (!ct) ct = IMAGE_GIF; /* Can't happen? Close enough. */ - // Fill in content type and attachment name here. + // Fill in content type and attachment name here. nsCAutoString url_with_filename(image_url); url_with_filename += "&type="; url_with_filename += ct; @@ -148,14 +147,14 @@ MimeInlineImage_parse_begin (MimeObject *obj) if (!escapedName) return MIME_OUT_OF_MEMORY; url_with_filename += "&filename="; url_with_filename += escapedName; - nsCRT::free(escapedName); + NS_Free(escapedName); PR_Free(filename); } // We need to separate images with HR's... MimeObject_write_separator(obj); - img->image_data = + img->image_data = obj->options->image_begin(url_with_filename.get(), ct, obj->options->stream_closure); PR_Free(image_url); @@ -169,7 +168,7 @@ MimeInlineImage_parse_begin (MimeObject *obj) if (status < 0) return status; } - // + // // Now we are going to see if we should set the content type in the // URI for the url being run... // @@ -198,11 +197,11 @@ MimeInlineImage_parse_eof (MimeObject *obj, PRBool abort_p) if (status < 0) abort_p = PR_TRUE; if (img->image_data) - { - obj->options->image_end(img->image_data, - (status < 0 ? status : (abort_p ? -1 : 0))); - img->image_data = 0; - } + { + obj->options->image_end(img->image_data, + (status < 0 ? status : (abort_p ? -1 : 0))); + img->image_data = 0; + } return status; } @@ -212,55 +211,55 @@ static int MimeInlineImage_parse_decoded_buffer (const char *buf, PRInt32 size, MimeObject *obj) { /* This is called (by MimeLeafClass->parse_buffer) with blocks of data - that have already been base64-decoded. Pass this raw image data - along to the backend-specific image display code. + that have already been base64-decoded. Pass this raw image data + along to the backend-specific image display code. */ MimeInlineImage *img = (MimeInlineImage *) obj; int status; if (obj->output_p && - obj->options && - !obj->options->write_html_p) - { - /* in this case, we just want the raw data... - Make the stream, if it's not made, and dump the data out. - */ + obj->options && + !obj->options->write_html_p) + { + /* in this case, we just want the raw data... + Make the stream, if it's not made, and dump the data out. + */ - if (!obj->options->state->first_data_written_p) - { - status = MimeObject_output_init(obj, 0); - if (status < 0) return status; - NS_ASSERTION(obj->options->state->first_data_written_p, "1.1 19 Mar 1999 12:00"); - } - - return MimeObject_write(obj, buf, size, PR_TRUE); - } + if (!obj->options->state->first_data_written_p) + { + status = MimeObject_output_init(obj, 0); + if (status < 0) return status; + NS_ASSERTION(obj->options->state->first_data_written_p, "1.1 19 Mar 1999 12:00"); + } + + return MimeObject_write(obj, buf, size, PR_TRUE); + } if (!obj->options || - !obj->options->image_write_buffer) - return 0; + !obj->options->image_write_buffer) + return 0; /* If we don't have any image data, the image_end method must have already - been called, so don't call image_write_buffer again. */ + been called, so don't call image_write_buffer again. */ if (!img->image_data) return 0; /* Hand this data off to the backend-specific image display stream. */ status = obj->options->image_write_buffer (buf, size, img->image_data); - + /* If the image display stream fails, then close the stream - but do not - return the failure status, and do not give up on parsing this object. - Just because the image data was corrupt doesn't mean we need to give up - on the whole document; we can continue by just skipping over the rest of - this part, and letting our parent continue. + return the failure status, and do not give up on parsing this object. + Just because the image data was corrupt doesn't mean we need to give up + on the whole document; we can continue by just skipping over the rest of + this part, and letting our parent continue. */ if (status < 0) - { - obj->options->image_end (img->image_data, status); - img->image_data = 0; - status = 0; - } + { + obj->options->image_end (img->image_data, status); + img->image_data = 0; + status = 0; + } return status; } diff --git a/mozilla/mailnews/mime/src/mimeleaf.cpp b/mozilla/mailnews/mime/src/mimeleaf.cpp index 2d4321da888..9ec51e878a2 100644 --- a/mozilla/mailnews/mime/src/mimeleaf.cpp +++ b/mozilla/mailnews/mime/src/mimeleaf.cpp @@ -42,7 +42,6 @@ #include "plstr.h" #include "prlog.h" #include "nsMimeStringResources.h" -#include "nsCRT.h" #define MIME_SUPERCLASS mimeObjectClass MimeDefClass(MimeLeaf, MimeLeafClass, mimeLeafClass, &MIME_SUPERCLASS); @@ -55,7 +54,7 @@ static int MimeLeaf_parse_line (const char *, PRInt32, MimeObject *); static int MimeLeaf_close_decoder (MimeObject *); static int MimeLeaf_parse_eof (MimeObject *, PRBool); static PRBool MimeLeaf_displayable_inline_p (MimeObjectClass *clazz, - MimeHeaders *hdrs); + MimeHeaders *hdrs); static int MimeLeafClassInitialize(MimeLeafClass *clazz) @@ -72,12 +71,12 @@ MimeLeafClassInitialize(MimeLeafClass *clazz) clazz->close_decoder = MimeLeaf_close_decoder; /* Default `parse_buffer' method is one which line-buffers the now-decoded - data and passes it on to `parse_line'. (We snarf the implementation of - this method from our superclass's implementation of `parse_buffer', which - inherited it from MimeObject.) + data and passes it on to `parse_line'. (We snarf the implementation of + this method from our superclass's implementation of `parse_buffer', which + inherited it from MimeObject.) */ clazz->parse_decoded_buffer = - ((MimeObjectClass*)&MIME_SUPERCLASS)->parse_buffer; + ((MimeObjectClass*)&MIME_SUPERCLASS)->parse_buffer; return 0; } @@ -100,12 +99,12 @@ MimeLeaf_finalize (MimeObject *object) object->clazz->parse_eof (object, PR_FALSE); /* Free the decoder data, if it's still around. It was probably freed - in MimeLeaf_parse_eof(), but just in case... */ + in MimeLeaf_parse_eof(), but just in case... */ if (leaf->decoder_data) - { - MimeDecoderDestroy(leaf->decoder_data, PR_TRUE); - leaf->decoder_data = 0; - } + { + MimeDecoderDestroy(leaf->decoder_data, PR_TRUE); + leaf->decoder_data = 0; + } ((MimeObjectClass*)&MIME_SUPERCLASS)->finalize (object); } @@ -120,34 +119,34 @@ MimeLeaf_parse_begin (MimeObject *obj) /* Initialize a decoder if necessary. */ if (!obj->encoding) - ; - else if (!nsCRT::strcasecmp(obj->encoding, ENCODING_BASE64)) - fn = &MimeB64DecoderInit; - else if (!nsCRT::strcasecmp(obj->encoding, ENCODING_QUOTED_PRINTABLE)) - leaf->decoder_data = + ; + else if (!PL_strcasecmp(obj->encoding, ENCODING_BASE64)) + fn = &MimeB64DecoderInit; + else if (!PL_strcasecmp(obj->encoding, ENCODING_QUOTED_PRINTABLE)) + leaf->decoder_data = MimeQPDecoderInit(((nsresult (*) (const char *, PRInt32, void *)) ((MimeLeafClass *)obj->clazz)->parse_decoded_buffer), obj, obj); - else if (!nsCRT::strcasecmp(obj->encoding, ENCODING_UUENCODE) || - !nsCRT::strcasecmp(obj->encoding, ENCODING_UUENCODE2) || - !nsCRT::strcasecmp(obj->encoding, ENCODING_UUENCODE3) || - !nsCRT::strcasecmp(obj->encoding, ENCODING_UUENCODE4)) - fn = &MimeUUDecoderInit; - else if (!nsCRT::strcasecmp(obj->encoding, ENCODING_YENCODE)) + else if (!PL_strcasecmp(obj->encoding, ENCODING_UUENCODE) || + !PL_strcasecmp(obj->encoding, ENCODING_UUENCODE2) || + !PL_strcasecmp(obj->encoding, ENCODING_UUENCODE3) || + !PL_strcasecmp(obj->encoding, ENCODING_UUENCODE4)) + fn = &MimeUUDecoderInit; + else if (!PL_strcasecmp(obj->encoding, ENCODING_YENCODE)) fn = &MimeYDecoderInit; if (fn) - { - leaf->decoder_data = - fn (/* The (nsresult (*) ...) cast is to turn the `void' argument - into `MimeObject'. */ - ((nsresult (*) (const char *, PRInt32, void *)) - ((MimeLeafClass *)obj->clazz)->parse_decoded_buffer), - obj); + { + leaf->decoder_data = + fn (/* The (nsresult (*) ...) cast is to turn the `void' argument + into `MimeObject'. */ + ((nsresult (*) (const char *, PRInt32, void *)) + ((MimeLeafClass *)obj->clazz)->parse_decoded_buffer), + obj); - if (!leaf->decoder_data) - return MIME_OUT_OF_MEMORY; - } + if (!leaf->decoder_data) + return MIME_OUT_OF_MEMORY; + } return ((MimeObjectClass*)&MIME_SUPERCLASS)->parse_begin(obj); } @@ -164,18 +163,18 @@ MimeLeaf_parse_buffer (const char *buffer, PRInt32 size, MimeObject *obj) /* If we're not supposed to write this object, bug out now. */ if (!obj->output_p || - !obj->options || - !obj->options->output_fn) - return 0; + !obj->options || + !obj->options->output_fn) + return 0; if (leaf->decoder_data && obj->options && obj->options->format_out != nsMimeOutput::nsMimeMessageDecrypt && obj->options->format_out != nsMimeOutput::nsMimeMessageAttach) - return MimeDecoderWrite (leaf->decoder_data, buffer, size); + return MimeDecoderWrite (leaf->decoder_data, buffer, size); else - return ((MimeLeafClass *)obj->clazz)->parse_decoded_buffer (buffer, size, - obj); + return ((MimeLeafClass *)obj->clazz)->parse_decoded_buffer (buffer, size, + obj); } static int @@ -210,7 +209,7 @@ MimeLeaf_parse_eof (MimeObject *obj, PRBool abort_p) if (obj->closed_p) return 0; /* Close off the decoder, to cause it to give up any buffered data that - it is still holding. + it is still holding. */ if (leaf->decoder_data) { @@ -219,7 +218,7 @@ MimeLeaf_parse_eof (MimeObject *obj, PRBool abort_p) } /* Now run the superclass's parse_eof, which will force out the line - buffer (which we may have just repopulated, above.) + buffer (which we may have just repopulated, above.) */ return ((MimeObjectClass*)&MIME_SUPERCLASS)->parse_eof (obj, abort_p); } diff --git a/mozilla/mailnews/mime/src/mimemalt.cpp b/mozilla/mailnews/mime/src/mimemalt.cpp index 3f18a8e2abe..279b3ece13a 100644 --- a/mozilla/mailnews/mime/src/mimemalt.cpp +++ b/mozilla/mailnews/mime/src/mimemalt.cpp @@ -44,7 +44,6 @@ #include "nsMimeStringResources.h" #include "nsIPrefBranch.h" #include "mimemoz2.h" // for prefs -#include "nsCRT.h" extern "C" MimeObjectClass mimeMultipartRelatedClass; @@ -132,7 +131,7 @@ MimeMultipartAlternative_parse_eof (MimeObject *obj, PRBool abort_p) /* If there's a cached part we haven't written out yet, do it now. */ - if (malt->buffered_hdrs && !abort_p && + if (malt->buffered_hdrs && !abort_p && obj->options->format_out != nsMimeOutput::nsMimeMessageAttach) { status = MimeMultipartAlternative_display_cached_part(obj); @@ -240,16 +239,16 @@ MimeMultipartAlternative_display_part_p(MimeObject *self, */ // prefer_plaintext pref - nsIPrefBranch *prefBranch = GetPrefBranch(self->options); + nsIPrefBranch *prefBranch = GetPrefBranch(self->options); PRBool prefer_plaintext = PR_FALSE; if (prefBranch) prefBranch->GetBoolPref("mailnews.display.prefer_plaintext", &prefer_plaintext); if (prefer_plaintext && self->options->format_out != nsMimeOutput::nsMimeMessageSaveAs - && (!nsCRT::strncasecmp(ct, "text/html", 9) || - !nsCRT::strncasecmp(ct, "text/enriched", 13) || - !nsCRT::strncasecmp(ct, "text/richtext", 13)) + && (!PL_strncasecmp(ct, "text/html", 9) || + !PL_strncasecmp(ct, "text/enriched", 13) || + !PL_strncasecmp(ct, "text/richtext", 13)) ) // if the user prefers plaintext and this is the "rich" (e.g. HTML) part... { @@ -270,7 +269,7 @@ MimeMultipartAlternative_display_part_p(MimeObject *self, return result; } -static int +static int MimeMultipartAlternative_discard_cached_part(MimeObject *obj) { MimeMultipartAlternative *malt = (MimeMultipartAlternative *) obj; @@ -286,7 +285,7 @@ MimeMultipartAlternative_discard_cached_part(MimeObject *obj) return 0; } -static int +static int MimeMultipartAlternative_display_cached_part(MimeObject *obj) { MimeMultipartAlternative *malt = (MimeMultipartAlternative *) obj; diff --git a/mozilla/mailnews/mime/src/mimemapl.cpp b/mozilla/mailnews/mime/src/mimemapl.cpp index f1f4d371185..ddeb31aab4a 100644 --- a/mozilla/mailnews/mime/src/mimemapl.cpp +++ b/mozilla/mailnews/mime/src/mimemapl.cpp @@ -42,15 +42,14 @@ #include "nsMimeStringResources.h" #include "mimemoz2.h" #include "nsMimeTypes.h" -#include "nsCRT.h" #define MIME_SUPERCLASS mimeMultipartClass MimeDefClass(MimeMultipartAppleDouble, MimeMultipartAppleDoubleClass, - mimeMultipartAppleDoubleClass, &MIME_SUPERCLASS); + mimeMultipartAppleDoubleClass, &MIME_SUPERCLASS); static int MimeMultipartAppleDouble_parse_begin (MimeObject *); static PRBool MimeMultipartAppleDouble_output_child_p(MimeObject *, - MimeObject *); + MimeObject *); static int MimeMultipartAppleDoubleClassInitialize(MimeMultipartAppleDoubleClass *clazz) @@ -68,7 +67,7 @@ static int MimeMultipartAppleDouble_parse_begin (MimeObject *obj) { /* #### This method is identical to MimeExternalObject_parse_begin - which kinda s#$%s... + which kinda s#$%s... */ int status; @@ -76,23 +75,23 @@ MimeMultipartAppleDouble_parse_begin (MimeObject *obj) if (status < 0) return status; /* If we're writing this object, and we're doing it in raw form, then - now is the time to inform the backend what the type of this data is. + now is the time to inform the backend what the type of this data is. */ if (obj->output_p && - obj->options && - !obj->options->write_html_p && - !obj->options->state->first_data_written_p) - { - status = MimeObject_output_init(obj, 0); - if (status < 0) return status; - NS_ASSERTION(obj->options->state->first_data_written_p, "first data not written"); - } + obj->options && + !obj->options->write_html_p && + !obj->options->state->first_data_written_p) + { + status = MimeObject_output_init(obj, 0); + if (status < 0) return status; + NS_ASSERTION(obj->options->state->first_data_written_p, "first data not written"); + } #ifdef XP_MACOSX - if (obj->options && obj->options->state) + if (obj->options && obj->options->state) { -// obj->options->state->separator_suppressed_p = PR_TRUE; - goto done; +// obj->options->state->separator_suppressed_p = PR_TRUE; + goto done; } /* * It would be nice to not showing the resource fork links @@ -102,76 +101,75 @@ MimeMultipartAppleDouble_parse_begin (MimeObject *obj) */ #endif /* If we're writing this object as HTML, then emit a link for the - multipart/appledouble part (both links) that looks just like the - links that MimeExternalObject emits for external leaf parts. + multipart/appledouble part (both links) that looks just like the + links that MimeExternalObject emits for external leaf parts. */ if (obj->options && - obj->output_p && - obj->options->write_html_p && - obj->options->output_fn) - { - char *id = 0; - char *id_url = 0; - char *id_imap = 0; + obj->output_p && + obj->options->write_html_p && + obj->options->output_fn) + { + char *id = 0; + char *id_url = 0; + char *id_imap = 0; - id = mime_part_address (obj); - if (! id) return MIME_OUT_OF_MEMORY; - if (obj->options->missing_parts) - id_imap = mime_imap_part_address (obj); + id = mime_part_address (obj); + if (! id) return MIME_OUT_OF_MEMORY; + if (obj->options->missing_parts) + id_imap = mime_imap_part_address (obj); if (obj->options && obj->options->url) - { - const char *url = obj->options->url; - if (id_imap && id) - { - /* if this is an IMAP part. */ - id_url = mime_set_url_imap_part(url, id_imap, id); - } - else - { - /* This is just a normal MIME part as usual. */ - id_url = mime_set_url_part(url, id, PR_TRUE); - } - if (!id_url) - { - PR_Free(id); - return MIME_OUT_OF_MEMORY; - } - } + { + const char *url = obj->options->url; + if (id_imap && id) + { + /* if this is an IMAP part. */ + id_url = mime_set_url_imap_part(url, id_imap, id); + } + else + { + /* This is just a normal MIME part as usual. */ + id_url = mime_set_url_part(url, id, PR_TRUE); + } + if (!id_url) + { + PR_Free(id); + return MIME_OUT_OF_MEMORY; + } + } -/**********************8 -RICHIE SHERRY - if (!nsCRT::strcmp (id, "0")) - { - PR_Free(id); - id = MimeGetStringByID(MIME_MSG_ATTACHMENT); - } - else - { - const char *p = "Part "; - char *s = (char *)PR_MALLOC(nsCRT::strlen(p) + nsCRT::strlen(id) + 1); - if (!s) - { - PR_Free(id); - PR_Free(id_url); - return MIME_OUT_OF_MEMORY; - } - PL_strcpy(s, p); - PL_strcat(s, id); - PR_Free(id); - id = s; - } +/********************** + if (!strcmp (id, "0")) + { + PR_Free(id); + id = MimeGetStringByID(MIME_MSG_ATTACHMENT); + } + else + { + const char *p = "Part "; + char *s = (char *)PR_MALLOC(strlen(p) + strlen(id) + 1); + if (!s) + { + PR_Free(id); + PR_Free(id_url); + return MIME_OUT_OF_MEMORY; + } + PL_strcpy(s, p); + PL_strcat(s, id); + PR_Free(id); + id = s; + } - if (all_headers_p && - // Don't bother showing all headers on this part if it's the only - // part in the message: in that case, we've already shown these - // headers. - obj->options->state && - obj->options->state->root == obj->parent) - all_headers_p = PR_FALSE; + if (all_headers_p && + // Don't bother showing all headers on this part if it's the only + // part in the message: in that case, we've already shown these + // headers. + obj->options->state && + obj->options->state->root == obj->parent) + all_headers_p = PR_FALSE; - newopt.fancy_headers_p = PR_TRUE; - newopt.headers = (all_headers_p ? MimeHeadersAll : MimeHeadersSome); + newopt.fancy_headers_p = PR_TRUE; + newopt.headers = (all_headers_p ? MimeHeadersAll : MimeHeadersSome); // RICHIE SHERRY @@ -183,12 +181,12 @@ GOTTA STILL DO THIS FOR QUOTING! // *********************************************************************************/ -// FAIL: - PR_FREEIF(id); - PR_FREEIF(id_url); - PR_FREEIF(id_imap); - if (status < 0) return status; - } +// FAIL: + PR_FREEIF(id); + PR_FREEIF(id_url); + PR_FREEIF(id_imap); + if (status < 0) return status; + } #ifdef XP_MACOSX done: @@ -203,12 +201,12 @@ MimeMultipartAppleDouble_output_child_p(MimeObject *obj, MimeObject *child) MimeContainer *cont = (MimeContainer *) obj; /* If this is the first child, and it's an application/applefile, then - don't emit a link for it. (There *should* be only two children, and - the first one should always be an application/applefile.) + don't emit a link for it. (There *should* be only two children, and + the first one should always be an application/applefile.) */ if (cont->nchildren >= 1 && cont->children[0] == child && child->content_type && - !nsCRT::strcasecmp(child->content_type, APPLICATION_APPLEFILE)) + !PL_strcasecmp(child->content_type, APPLICATION_APPLEFILE)) { #ifdef XP_MACOSX if (obj->output_p && obj->options && obj->options->write_html_p) //output HTML @@ -218,6 +216,6 @@ MimeMultipartAppleDouble_output_child_p(MimeObject *obj, MimeObject *child) return PR_FALSE; #endif } - + return PR_TRUE; } diff --git a/mozilla/mailnews/mime/src/mimemcms.cpp b/mozilla/mailnews/mime/src/mimemcms.cpp index d9858f5b928..b42719170d3 100644 --- a/mozilla/mailnews/mime/src/mimemcms.cpp +++ b/mozilla/mailnews/mime/src/mimemcms.cpp @@ -19,7 +19,7 @@ * Portions created by the Initial Developer are Copyright (C) 2001 * the Initial Developer. All Rights Reserved. * - * Contributor(s): + * Contributor(s): * Kai Engert * * Alternatively, the contents of this file may be used under the terms of @@ -114,7 +114,7 @@ typedef struct MimeMultCMSdata PRBool parent_is_encrypted_p; PRBool parent_holds_stamp_p; nsCOMPtr smimeHeaderSink; - + MimeMultCMSdata() :hash_type(0), sender_addr(nsnull), @@ -125,7 +125,7 @@ typedef struct MimeMultCMSdata parent_holds_stamp_p(PR_FALSE) { } - + ~MimeMultCMSdata() { PR_FREEIF(sender_addr); @@ -177,16 +177,16 @@ MimeMultCMS_init (MimeObject *obj) ct = 0; if (!micalg) return 0; /* #### bogus message? out of memory? */ - if (!nsCRT::strcasecmp(micalg, PARAM_MICALG_MD5) || - !nsCRT::strcasecmp(micalg, PARAM_MICALG_MD5_2)) + if (!PL_strcasecmp(micalg, PARAM_MICALG_MD5) || + !PL_strcasecmp(micalg, PARAM_MICALG_MD5_2)) hash_type = nsICryptoHash::MD5; - else if (!nsCRT::strcasecmp(micalg, PARAM_MICALG_SHA1) || - !nsCRT::strcasecmp(micalg, PARAM_MICALG_SHA1_2) || - !nsCRT::strcasecmp(micalg, PARAM_MICALG_SHA1_3) || - !nsCRT::strcasecmp(micalg, PARAM_MICALG_SHA1_4) || - !nsCRT::strcasecmp(micalg, PARAM_MICALG_SHA1_5)) + else if (!PL_strcasecmp(micalg, PARAM_MICALG_SHA1) || + !PL_strcasecmp(micalg, PARAM_MICALG_SHA1_2) || + !PL_strcasecmp(micalg, PARAM_MICALG_SHA1_3) || + !PL_strcasecmp(micalg, PARAM_MICALG_SHA1_4) || + !PL_strcasecmp(micalg, PARAM_MICALG_SHA1_5)) hash_type = nsICryptoHash::SHA1; - else if (!nsCRT::strcasecmp(micalg, PARAM_MICALG_MD2)) + else if (!PL_strcasecmp(micalg, PARAM_MICALG_MD2)) hash_type = nsICryptoHash::MD2; else hash_type = -1; @@ -255,7 +255,7 @@ MimeMultCMS_init (MimeObject *obj) // // If we do not find header=filter, we assume the result of the // processing will be shown in the UI. - + if (!strstr(urlSpec.get(), "?header=filter") && !strstr(urlSpec.get(), "&header=filter")&& !strstr(urlSpec.get(), "?header=attach") && @@ -304,11 +304,11 @@ MimeMultCMS_data_eof (void *crypto_closure, PRBool abort_p) nsCAutoString hashString; data->data_hash_context->Finish(PR_FALSE, hashString); PR_SetError(0, 0); - + data->item_len = hashString.Length(); data->item_data = new unsigned char[data->item_len]; if (!data->item_data) return MIME_OUT_OF_MEMORY; - + memcpy(data->item_data, hashString.get(), data->item_len); // Release our reference to nsICryptoHash // @@ -340,8 +340,8 @@ MimeMultCMS_sig_init (void *crypto_closure, /* Verify that the signature object is of the right type. */ if (!ct || /* is not a signature type */ - (nsCRT::strcasecmp(ct, APPLICATION_XPKCS7_SIGNATURE) != 0 - && nsCRT::strcasecmp(ct, APPLICATION_PKCS7_SIGNATURE) != 0)) { + (PL_strcasecmp(ct, APPLICATION_XPKCS7_SIGNATURE) != 0 + && PL_strcasecmp(ct, APPLICATION_PKCS7_SIGNATURE) != 0)) { status = -1; /* #### error msg about bogus message */ } PR_FREEIF(ct); @@ -436,10 +436,10 @@ MimeMultCMS_generate (void *crypto_closure) { // We were not given all parts of the message. // We are therefore unable to verify correctness of the signature. - + if (data->smimeHeaderSink) - data->smimeHeaderSink->SignedStatus(aRelativeNestLevel, - nsICMSMessageErrors::VERIFY_NOT_YET_ATTEMPTED, + data->smimeHeaderSink->SignedStatus(aRelativeNestLevel, + nsICMSMessageErrors::VERIFY_NOT_YET_ATTEMPTED, nsnull); return nsnull; } @@ -453,20 +453,20 @@ MimeMultCMS_generate (void *crypto_closure) */ return nsnull; } - + nsCString from_addr; nsCString from_name; nsCString sender_addr; nsCString sender_name; - - MimeCMSGetFromSender(data->self, + + MimeCMSGetFromSender(data->self, from_addr, from_name, sender_addr, sender_name); - MimeCMSRequestAsyncSignatureVerification(data->content_info, + MimeCMSRequestAsyncSignatureVerification(data->content_info, from_addr.get(), from_name.get(), sender_addr.get(), sender_name.get(), - data->smimeHeaderSink, aRelativeNestLevel, + data->smimeHeaderSink, aRelativeNestLevel, data->item_data, data->item_len); if (data->content_info) diff --git a/mozilla/mailnews/mime/src/mimemoz2.cpp b/mozilla/mailnews/mime/src/mimemoz2.cpp index 1cf788285bc..d3cf7a4be63 100644 --- a/mozilla/mailnews/mime/src/mimemoz2.cpp +++ b/mozilla/mailnews/mime/src/mimemoz2.cpp @@ -38,7 +38,6 @@ #include "prlog.h" #include "nsCOMPtr.h" #include "modlmime.h" -#include "nsCRT.h" #include "mimeobj.h" #include "mimemsg.h" #include "mimetric.h" /* for MIME_RichtextConverter */ @@ -138,13 +137,13 @@ ProcessBodyAsAttachment(MimeObject *obj, nsMsgAttachmentData **data) n = 1; *data = (nsMsgAttachmentData *)PR_Malloc( (n + 1) * sizeof(nsMsgAttachmentData)); - if (!*data) + if (!*data) return NS_ERROR_OUT_OF_MEMORY; tmp = *data; memset(*data, 0, (n + 1) * sizeof(nsMsgAttachmentData)); - tmp->real_type = child->content_type ? nsCRT::strdup(child->content_type) : NULL; - tmp->real_encoding = child->encoding ? nsCRT::strdup(child->encoding) : NULL; + tmp->real_type = child->content_type ? strdup(child->content_type) : NULL; + tmp->real_encoding = child->encoding ? strdup(child->encoding) : NULL; disp = MimeHeaders_get(child->headers, HEADER_CONTENT_DISPOSITION, PR_FALSE, PR_FALSE); tmp->real_name = MimeHeaders_get_parameter(disp, "name", &charset, NULL); if (tmp->real_name) @@ -163,7 +162,7 @@ ProcessBodyAsAttachment(MimeObject *obj, nsMsgAttachmentData **data) tmp->real_name = MimeHeaders_get_name(child->headers, obj->options); } - if ( (!tmp->real_name) && (tmp->real_type) && (nsCRT::strncasecmp(tmp->real_type, "text", 4)) ) + if ( (!tmp->real_name) && (tmp->real_type) && (PL_strncasecmp(tmp->real_type, "text", 4)) ) ValidateRealName(tmp, child->headers); char *tmpURL = nsnull; @@ -187,13 +186,13 @@ ProcessBodyAsAttachment(MimeObject *obj, nsMsgAttachmentData **data) nsresult rv; if (id_imap && id) { - // if this is an IMAP part. + // if this is an IMAP part. tmpURL = mime_set_url_imap_part(url, id_imap, id); rv = nsMimeNewURI(&(tmp->url), tmpURL, nsnull); } else { - // This is just a normal MIME part as usual. + // This is just a normal MIME part as usual. tmpURL = mime_set_url_part(url, id, PR_TRUE); rv = nsMimeNewURI(&(tmp->url), tmpURL, nsnull); } @@ -233,7 +232,7 @@ CountTotalMimeAttachments(MimeContainer *aObj) void ValidateRealName(nsMsgAttachmentData *aAttach, MimeHeaders *aHdrs) -{ +{ // Sanity. if (!aAttach) return; @@ -243,13 +242,13 @@ ValidateRealName(nsMsgAttachmentData *aAttach, MimeHeaders *aHdrs) return; // Internal MIME structures need not be named! - if ( (!aAttach->real_type) || (aAttach->real_type && - !nsCRT::strncasecmp(aAttach->real_type, "multipart", 9)) ) + if ( (!aAttach->real_type) || (aAttach->real_type && + !PL_strncasecmp(aAttach->real_type, "multipart", 9)) ) return; // Special case...if this is a enclosed RFC822 message, give it a nice // name. - if (aAttach->real_type && !nsCRT::strcasecmp(aAttach->real_type, MESSAGE_RFC822)) + if (aAttach->real_type && !PL_strcasecmp(aAttach->real_type, MESSAGE_RFC822)) { NS_ASSERTION(aHdrs, "How comes the object's headers is null!"); if (aHdrs && aHdrs->munged_subject) @@ -259,7 +258,7 @@ ValidateRealName(nsMsgAttachmentData *aAttach, MimeHeaders *aHdrs) return; } - // + // // Now validate any other name we have for the attachment! // if (!aAttach->real_name || *aAttach->real_name == 0) @@ -272,7 +271,7 @@ ValidateRealName(nsMsgAttachmentData *aAttach, MimeHeaders *aHdrs) contentType.SetLength(pos); nsCOMPtr mimeFinder (do_GetService(NS_MIMESERVICE_CONTRACTID, &rv)); - if (NS_SUCCEEDED(rv)) + if (NS_SUCCEEDED(rv)) { nsCAutoString fileExtension; rv = mimeFinder->GetPrimaryExtension(contentType, EmptyCString(), fileExtension); @@ -285,7 +284,7 @@ ValidateRealName(nsMsgAttachmentData *aAttach, MimeHeaders *aHdrs) } aAttach->real_name = ToNewCString(newAttachName); - } + } } static PRInt32 attIndex = 0; @@ -304,7 +303,7 @@ GenerateAttachmentData(MimeObject *object, const char *aMessageURL, MimeDisplayO return NS_OK; part.Adopt(mime_part_address(object)); - if (part.IsEmpty()) + if (part.IsEmpty()) return NS_ERROR_OUT_OF_MEMORY; if (options->missing_parts) @@ -329,7 +328,7 @@ GenerateAttachmentData(MimeObject *object, const char *aMessageURL, MimeDisplayO else { // if the mime object contains an external attachment URL, then use it, otherwise - // fall back to creating an attachment url based on the message URI and the + // fall back to creating an attachment url based on the message URI and the // part number. urlSpec = mime_external_attachment_url(object); isExternalAttachment = urlSpec ? PR_TRUE : PR_FALSE; @@ -341,19 +340,19 @@ GenerateAttachmentData(MimeObject *object, const char *aMessageURL, MimeDisplayO if (!urlSpec) return NS_ERROR_OUT_OF_MEMORY; - if ((options->format_out == nsMimeOutput::nsMimeMessageBodyDisplay) && (nsCRT::strncasecmp(aMessageURL, urlSpec, strlen(urlSpec)) == 0)) + if ((options->format_out == nsMimeOutput::nsMimeMessageBodyDisplay) && (PL_strncasecmp(aMessageURL, urlSpec, strlen(urlSpec)) == 0)) return NS_OK; - + nsMsgAttachmentData *tmp = &(aAttachData[attIndex++]); - tmp->real_type = object->content_type ? nsCRT::strdup(object->content_type) : nsnull; - tmp->real_encoding = object->encoding ? nsCRT::strdup(object->encoding) : nsnull; + tmp->real_type = object->content_type ? strdup(object->content_type) : nsnull; + tmp->real_encoding = object->encoding ? strdup(object->encoding) : nsnull; tmp->isExternalAttachment = isExternalAttachment; - + PRInt32 i; char *charset = nsnull; char *disp = MimeHeaders_get(object->headers, HEADER_CONTENT_DISPOSITION, PR_FALSE, PR_FALSE); - if (disp) + if (disp) { tmp->real_name = MimeHeaders_get_parameter(disp, "filename", &charset, nsnull); if (isAnAppleDoublePart) @@ -392,21 +391,21 @@ GenerateAttachmentData(MimeObject *object, const char *aMessageURL, MimeDisplayO { tmp->x_mac_type = MimeHeaders_get_parameter(disp, PARAM_X_MAC_TYPE, nsnull, nsnull); tmp->x_mac_creator= MimeHeaders_get_parameter(disp, PARAM_X_MAC_CREATOR, nsnull, nsnull); - + if (!tmp->real_name || *tmp->real_name == 0) { PR_FREEIF(tmp->real_name); tmp->real_name = MimeHeaders_get_parameter(disp, "name", &charset, nsnull); if (isAnAppleDoublePart) // the data fork is the 2nd part, and we should ALWAYS look there first for the file name - for (i = 1; i >= 0 && !tmp->real_name; i --) + for (i = 1; i >= 0 && !tmp->real_name; i --) { PR_FREEIF(disp); nsMemory::Free(charset); disp = MimeHeaders_get(((MimeContainer *)object)->children[i]->headers, HEADER_CONTENT_TYPE, PR_FALSE, PR_FALSE); tmp->real_name = MimeHeaders_get_parameter(disp, "name", &charset, nsnull); } - + if (tmp->real_name) { // check encoded type @@ -429,11 +428,11 @@ GenerateAttachmentData(MimeObject *object, const char *aMessageURL, MimeDisplayO PR_FREEIF(disp); } - tmp->description = MimeHeaders_get(object->headers, HEADER_CONTENT_DESCRIPTION, + tmp->description = MimeHeaders_get(object->headers, HEADER_CONTENT_DESCRIPTION, PR_FALSE, PR_FALSE); // Now, do the right thing with the name! - if (!tmp->real_name && nsCRT::strcasecmp(tmp->real_type, MESSAGE_RFC822)) + if (!tmp->real_name && PL_strcasecmp(tmp->real_type, MESSAGE_RFC822)) { /* If this attachment doesn't have a name, just give it one... */ tmp->real_name = MimeGetStringByID(MIME_MSG_DEFAULT_ATTACHMENT_NAME); @@ -482,34 +481,34 @@ BuildAttachmentList(MimeObject *anObject, nsMsgAttachmentData *aAttachData, cons (mime_typep(anObject, (MimeObjectClass *)&mimeExternalBodyClass))) return NS_OK; - for (i = 0; i < cobj->nchildren ; i++) + for (i = 0; i < cobj->nchildren ; i++) { MimeObject *child = cobj->children[i]; // Skip the first child if it's in fact a message body if (i == 0) // it's the first child if (child->content_type) // and it's content-type is one of folowing... - if (!nsCRT::strcasecmp (child->content_type, TEXT_PLAIN) || - !nsCRT::strcasecmp (child->content_type, TEXT_HTML) || - !nsCRT::strcasecmp (child->content_type, TEXT_MDL)) + if (!PL_strcasecmp (child->content_type, TEXT_PLAIN) || + !PL_strcasecmp (child->content_type, TEXT_HTML) || + !PL_strcasecmp (child->content_type, TEXT_MDL)) { - if (child->headers) // and finally, be sure it doesn't have a content-disposition: attachment + if (child->headers) // and finally, be sure it doesn't have a content-disposition: attachment { char * disp = MimeHeaders_get (child->headers, HEADER_CONTENT_DISPOSITION, PR_TRUE, PR_FALSE); - if (!disp || nsCRT::strcasecmp (disp, "attachment")) + if (!disp || PL_strcasecmp (disp, "attachment")) continue; } else continue; } - + // We should generate an attachment for leaf object only but... PRBool isALeafObject = mime_subclass_p(child->clazz, (MimeObjectClass *) &mimeLeafClass); // ...we will generate an attachment for inline message too. PRBool isAnInlineMessage = mime_typep(child, (MimeObjectClass *) &mimeMessageClass); - + // AppleDouble part need special care: we need to fetch the part as well its two // children for the needed info as they could be anywhere, eventually, they won't contain // a name or file name. In any case we need to build only one attachment data @@ -521,7 +520,7 @@ BuildAttachmentList(MimeObject *anObject, nsMsgAttachmentData *aAttachData, cons rv = GenerateAttachmentData(child, aMessageURL, anObject->options, isAnAppleDoublePart, aAttachData); NS_ENSURE_SUCCESS(rv, rv); } - + // Now build the attachment list for the children of our object... if (!isALeafObject && !isAnAppleDoublePart) { @@ -542,7 +541,7 @@ MimeGetAttachmentList(MimeObject *tobj, const char *aMessageURL, nsMsgAttachment PRInt32 n; PRBool isAnInlineMessage; - if (!data) + if (!data) return 0; *data = nsnull; @@ -562,7 +561,7 @@ MimeGetAttachmentList(MimeObject *tobj, const char *aMessageURL, nsMsgAttachment cobj = (MimeContainer*) obj; n = CountTotalMimeAttachments(cobj); - if (n <= 0) + if (n <= 0) return n; //in case of an inline message (as body), we need an extra slot for the message itself @@ -571,12 +570,12 @@ MimeGetAttachmentList(MimeObject *tobj, const char *aMessageURL, nsMsgAttachment n ++; *data = (nsMsgAttachmentData *)PR_Malloc( (n + 1) * sizeof(nsMsgAttachmentData)); - if (!*data) + if (!*data) return NS_ERROR_OUT_OF_MEMORY; attIndex = 0; memset(*data, 0, (n + 1) * sizeof(nsMsgAttachmentData)); - + // Now, build the list! nsresult rv; @@ -592,10 +591,10 @@ MimeGetAttachmentList(MimeObject *tobj, const char *aMessageURL, nsMsgAttachment extern "C" void MimeFreeAttachmentList(nsMsgAttachmentData *data) { - if (data) + if (data) { nsMsgAttachmentData *tmp; - for (tmp = data ; tmp->url ; tmp++) + for (tmp = data ; tmp->url ; tmp++) { /* Can't do PR_FREEIF on `const' values... */ NS_IF_RELEASE(tmp->url); @@ -621,7 +620,7 @@ NotifyEmittersOfAttachmentList(MimeDisplayOptions *opt, PRInt32 i = 0; struct nsMsgAttachmentData *tmp = data; - if (!tmp) + if (!tmp) return; while (tmp->url) @@ -629,20 +628,20 @@ NotifyEmittersOfAttachmentList(MimeDisplayOptions *opt, if (!tmp->real_name) { ++i; - ++tmp; + ++tmp; continue; } nsCAutoString spec; - if ( tmp->url ) + if ( tmp->url ) tmp->url->GetSpec(spec); mimeEmitterStartAttachment(opt, tmp->real_name, tmp->real_type, spec.get(), tmp->isExternalAttachment); mimeEmitterAddAttachmentField(opt, HEADER_X_MOZILLA_PART_URL, spec.get()); - if ( (opt->format_out == nsMimeOutput::nsMimeMessageQuoting) || - (opt->format_out == nsMimeOutput::nsMimeMessageBodyQuoting) || - (opt->format_out == nsMimeOutput::nsMimeMessageSaveAs) || + if ( (opt->format_out == nsMimeOutput::nsMimeMessageQuoting) || + (opt->format_out == nsMimeOutput::nsMimeMessageBodyQuoting) || + (opt->format_out == nsMimeOutput::nsMimeMessageSaveAs) || (opt->format_out == nsMimeOutput::nsMimeMessagePrintOutput)) { mimeEmitterAddAttachmentField(opt, HEADER_CONTENT_DESCRIPTION, tmp->description); @@ -653,9 +652,9 @@ NotifyEmittersOfAttachmentList(MimeDisplayOptions *opt, not necessary printf("URL for Part : %s\n", spec); printf("Real Name : %s\n", tmp->real_name); - printf("Desired Type : %s\n", tmp->desired_type); + printf("Desired Type : %s\n", tmp->desired_type); printf("Real Type : %s\n", tmp->real_type); - printf("Real Encoding : %s\n", tmp->real_encoding); + printf("Real Encoding : %s\n", tmp->real_encoding); printf("Description : %s\n", tmp->description); printf("Mac Type : %s\n", tmp->x_mac_type); printf("Mac Creator : %s\n", tmp->x_mac_creator); @@ -670,22 +669,22 @@ NotifyEmittersOfAttachmentList(MimeDisplayOptions *opt, } // Utility to create a nsIURI object... -extern "C" nsresult +extern "C" nsresult nsMimeNewURI(nsIURI** aInstancePtrResult, const char *aSpec, nsIURI *aBase) -{ +{ nsresult res; - if (nsnull == aInstancePtrResult) + if (nsnull == aInstancePtrResult) return NS_ERROR_NULL_POINTER; - + nsCOMPtr pService(do_GetService(NS_IOSERVICE_CONTRACTID, &res)); - if (NS_FAILED(res)) + if (NS_FAILED(res)) return NS_ERROR_FACTORY_NOT_REGISTERED; return pService->NewURI(nsDependentCString(aSpec), nsnull, aBase, aInstancePtrResult); } -extern "C" nsresult +extern "C" nsresult SetMailCharacterSetToMsgWindow(MimeObject *obj, const char *aCharacterSet) { nsresult rv = NS_OK; @@ -708,7 +707,7 @@ SetMailCharacterSetToMsgWindow(MimeObject *obj, const char *aCharacterSet) nsCOMPtr msgWindow; msgurl->GetMsgWindow(getter_AddRefs(msgWindow)); if (msgWindow) - rv = msgWindow->SetMailCharacterSet(!nsCRT::strcasecmp(aCharacterSet, "us-ascii") ? + rv = msgWindow->SetMailCharacterSet(!PL_strcasecmp(aCharacterSet, "us-ascii") ? NS_LITERAL_CSTRING("ISO-8859-1") : nsDependentCString(aCharacterSet)); } @@ -742,12 +741,12 @@ mime_file_type (const char *filename, void *stream_closure) return retType; } -int ConvertUsingEncoderAndDecoder(const char *stringToUse, PRInt32 inLength, - nsIUnicodeEncoder *encoder, nsIUnicodeDecoder *decoder, +int ConvertUsingEncoderAndDecoder(const char *stringToUse, PRInt32 inLength, + nsIUnicodeEncoder *encoder, nsIUnicodeDecoder *decoder, char **pConvertedString, PRInt32 *outLength) { // buffer size 144 = - // 72 (default line len for compose) + // 72 (default line len for compose) // times 2 (converted byte len might be larger) const int klocalbufsize = 144; // do the conversion @@ -775,7 +774,7 @@ int ConvertUsingEncoderAndDecoder(const char *stringToUse, PRInt32 inLength, else { // convert to unicode, replacing failed chars with 0xFFFD as in // the methode used in nsXMLHttpRequest::ConvertBodyToText and nsScanner::Append - // + // // We will need several pass to convert the whole string if it has invalid characters // 'totalChars' is where the sum of the number of converted characters will be done // 'dataLen' is the number of character left to convert @@ -868,7 +867,7 @@ mime_convert_charset (const char *input_line, PRInt32 input_length, { *output_ret = (char *) convertedString; *output_size_ret = convertedStringLen; - } + } return 0; } @@ -880,11 +879,11 @@ mime_output_fn(const char *buf, PRInt32 size, void *stream_closure) struct mime_stream_data *msd = (struct mime_stream_data *) stream_closure; if ( (!msd->pluginObj2) && (!msd->output_emitter) ) return -1; - + // Fire pending start request ((nsStreamConverter*)msd->pluginObj2)->FirePendingStartRequest(); - - + + // Now, write to the WriteBody method if this is a message body and not // a part retrevial if (!msd->options->part_to_load || msd->options->format_out == nsMimeOutput::nsMimeMessageBodyDisplay) @@ -919,7 +918,7 @@ mime_display_stream_write (nsMIMESession *stream, { struct mime_stream_data *msd = (struct mime_stream_data *) ((nsMIMESession *)stream)->data_object; - MimeObject *obj = (msd ? msd->obj : 0); + MimeObject *obj = (msd ? msd->obj : 0); if (!obj) return -1; // @@ -931,7 +930,7 @@ mime_display_stream_write (nsMIMESession *stream, if (msd->channel) { nsCOMPtr aUri; - if (NS_SUCCEEDED(msd->channel->GetURI(getter_AddRefs(aUri)))) + if (NS_SUCCEEDED(msd->channel->GetURI(getter_AddRefs(aUri)))) { nsCOMPtr imapURL = do_QueryInterface(aUri); if (imapURL) @@ -952,11 +951,11 @@ mime_display_stream_write (nsMIMESession *stream, return obj->clazz->parse_buffer((char *) buf, size, obj); } -extern "C" void +extern "C" void mime_display_stream_complete (nsMIMESession *stream) { struct mime_stream_data *msd = (struct mime_stream_data *) ((nsMIMESession *)stream)->data_object; - MimeObject *obj = (msd ? msd->obj : 0); + MimeObject *obj = (msd ? msd->obj : 0); if (obj) { int status; @@ -967,7 +966,7 @@ mime_display_stream_complete (nsMIMESession *stream) status = obj->clazz->parse_eof(obj, abortNow); obj->clazz->parse_end(obj, (status < 0 ? PR_TRUE : PR_FALSE)); - + // // Ok, now we are going to process the attachment data by getting all // of the attachment info and then driving the emitter with this data. @@ -1002,13 +1001,13 @@ mime_display_stream_complete (nsMIMESession *stream) } if (msd->headers) - MimeHeaders_free (msd->headers); + MimeHeaders_free (msd->headers); if (msd->url_name) - nsCRT::free(msd->url_name); + NS_Free(msd->url_name); if (msd->orig_url_name) - nsCRT::free(msd->orig_url_name); + NS_Free(msd->orig_url_name); PR_FREEIF(msd); } @@ -1017,15 +1016,15 @@ extern "C" void mime_display_stream_abort (nsMIMESession *stream, int status) { struct mime_stream_data *msd = (struct mime_stream_data *) ((nsMIMESession *)stream)->data_object; - - MimeObject *obj = (msd ? msd->obj : 0); + + MimeObject *obj = (msd ? msd->obj : 0); if (obj) { if (!obj->closed_p) obj->clazz->parse_eof(obj, PR_TRUE); if (!obj->parsed_p) obj->clazz->parse_end(obj, PR_TRUE); - + // Destroy code.... PR_ASSERT(msd->options == obj->options); mime_free(obj); @@ -1037,13 +1036,13 @@ mime_display_stream_abort (nsMIMESession *stream, int status) } if (msd->headers) - MimeHeaders_free (msd->headers); + MimeHeaders_free (msd->headers); if (msd->url_name) - nsCRT::free(msd->url_name); + NS_Free(msd->url_name); if (msd->orig_url_name) - nsCRT::free(msd->orig_url_name); + NS_Free(msd->orig_url_name); PR_FREEIF(msd); } @@ -1052,25 +1051,25 @@ mime_display_stream_abort (nsMIMESession *stream, int status) static PRUint32 mime_convert_chars_to_ostype(const char *osTypeStr) { - if (!osTypeStr) - return '????'; + if (!osTypeStr) + return '????'; - PRUint32 result; - const char *p = osTypeStr; + PRUint32 result; + const char *p = osTypeStr; - for (result = 0; *p; p++) - { - char C = *p; + for (result = 0; *p; p++) + { + char C = *p; - PRInt8 unhex = ((C >= '0' && C <= '9') ? C - '0' : - ((C >= 'A' && C <= 'F') ? C - 'A' + 10 : - ((C >= 'a' && C <= 'f') ? C - 'a' + 10 : -1))); - if (unhex < 0) - break; - result = (result << 4) | unhex; - } + PRInt8 unhex = ((C >= '0' && C <= '9') ? C - '0' : + ((C >= 'A' && C <= 'F') ? C - 'A' + 10 : + ((C >= 'a' && C <= 'f') ? C - 'a' + 10 : -1))); + if (unhex < 0) + break; + result = (result << 4) | unhex; + } - return result; + return result; } #endif @@ -1083,7 +1082,7 @@ mime_output_init_fn (const char *type, void *stream_closure) { struct mime_stream_data *msd = (struct mime_stream_data *) stream_closure; - + // Now, all of this stream creation is done outside of libmime, so this // is just a check of the pluginObj member and returning accordingly. if (!msd->pluginObj2) @@ -1126,14 +1125,14 @@ mime_image_begin(const char *image_url, const char *content_type, { struct mime_stream_data *msd = (struct mime_stream_data *) stream_closure; class mime_image_stream_data *mid; - + mid = new mime_image_stream_data; if (!mid) return nsnull; mid->msd = msd; - mid->url = (char *) nsCRT::strdup(image_url); + mid->url = (char *) strdup(image_url); if (!mid->url) { PR_Free(mid); @@ -1193,9 +1192,9 @@ mime_image_end(void *image_closure, int status) { mime_image_stream_data *mid = (mime_image_stream_data *) image_closure; - + PR_ASSERT(mid); - if (!mid) + if (!mid) return; if (mid->memCacheOutputStream) mid->memCacheOutputStream->Close(); @@ -1223,7 +1222,7 @@ mime_image_make_image_html(void *image_closure) /* Internal-external-reconnect only works when going to the screen. */ if (!mid->istream) - return nsCRT::strdup("

\"[Image]\"

"); + return strdup("

\"[Image]\"

"); nsCOMPtr prefBranch; nsCOMPtr prefSvc(do_GetService(NS_PREFSERVICE_CONTRACTID)); @@ -1242,7 +1241,7 @@ mime_image_make_image_html(void *image_closure) buf = (char *) PR_MALLOC (strlen(prefix) + strlen(suffix) + strlen(url) + 20) ; - if (!buf) + if (!buf) return 0; *buf = 0; @@ -1280,7 +1279,7 @@ MimeObject* mime_get_main_object(MimeObject* obj) { MimeContainer *cobj; - if (!(mime_subclass_p(obj->clazz, (MimeObjectClass*) &mimeMessageClass))) + if (!(mime_subclass_p(obj->clazz, (MimeObjectClass*) &mimeMessageClass))) { return obj; } @@ -1300,7 +1299,7 @@ mime_get_main_object(MimeObject* obj) { if (mime_subclass_p(obj->clazz, (MimeObjectClass*)&mimeContainerClass)) { - // We don't care about a signed/smime object; Go inside to the + // We don't care about a signed/smime object; Go inside to the // thing that we signed or smime'ed // cobj = (MimeContainer*) obj; @@ -1321,75 +1320,75 @@ mime_get_main_object(MimeObject* obj) return nsnull; } -PRBool MimeObjectChildIsMessageBody(MimeObject *obj, - PRBool *isAlternativeOrRelated) +PRBool MimeObjectChildIsMessageBody(MimeObject *obj, + PRBool *isAlternativeOrRelated) { - char *disp = 0; - PRBool bRet = PR_FALSE; - MimeObject *firstChild = 0; - MimeContainer *container = (MimeContainer*) obj; + char *disp = 0; + PRBool bRet = PR_FALSE; + MimeObject *firstChild = 0; + MimeContainer *container = (MimeContainer*) obj; - if (isAlternativeOrRelated) - *isAlternativeOrRelated = PR_FALSE; + if (isAlternativeOrRelated) + *isAlternativeOrRelated = PR_FALSE; - if (!container || - !mime_subclass_p(obj->clazz, - (MimeObjectClass*) &mimeContainerClass)) - { - return bRet; - } - else if (mime_subclass_p(obj->clazz, (MimeObjectClass*) - &mimeMultipartRelatedClass)) - { - if (isAlternativeOrRelated) - *isAlternativeOrRelated = PR_TRUE; - return bRet; - } - else if (mime_subclass_p(obj->clazz, (MimeObjectClass*) - &mimeMultipartAlternativeClass)) - { - if (isAlternativeOrRelated) - *isAlternativeOrRelated = PR_TRUE; - return bRet; - } + if (!container || + !mime_subclass_p(obj->clazz, + (MimeObjectClass*) &mimeContainerClass)) + { + return bRet; + } + else if (mime_subclass_p(obj->clazz, (MimeObjectClass*) + &mimeMultipartRelatedClass)) + { + if (isAlternativeOrRelated) + *isAlternativeOrRelated = PR_TRUE; + return bRet; + } + else if (mime_subclass_p(obj->clazz, (MimeObjectClass*) + &mimeMultipartAlternativeClass)) + { + if (isAlternativeOrRelated) + *isAlternativeOrRelated = PR_TRUE; + return bRet; + } - if (container->children) - firstChild = container->children[0]; - - if (!firstChild || - !firstChild->content_type || - !firstChild->headers) - return bRet; + if (container->children) + firstChild = container->children[0]; - disp = MimeHeaders_get (firstChild->headers, - HEADER_CONTENT_DISPOSITION, - PR_TRUE, - PR_FALSE); - if (disp /* && !nsCRT::strcasecmp (disp, "attachment") */) - bRet = PR_FALSE; - else if (!nsCRT::strcasecmp (firstChild->content_type, TEXT_PLAIN) || - !nsCRT::strcasecmp (firstChild->content_type, TEXT_HTML) || - !nsCRT::strcasecmp (firstChild->content_type, TEXT_MDL) || - !nsCRT::strcasecmp (firstChild->content_type, MULTIPART_ALTERNATIVE) || - !nsCRT::strcasecmp (firstChild->content_type, MULTIPART_RELATED) || - !nsCRT::strcasecmp (firstChild->content_type, MESSAGE_NEWS) || - !nsCRT::strcasecmp (firstChild->content_type, MESSAGE_RFC822)) - bRet = PR_TRUE; - else - bRet = PR_FALSE; - PR_FREEIF(disp); - return bRet; + if (!firstChild || + !firstChild->content_type || + !firstChild->headers) + return bRet; + + disp = MimeHeaders_get (firstChild->headers, + HEADER_CONTENT_DISPOSITION, + PR_TRUE, + PR_FALSE); + if (disp /* && !PL_strcasecmp (disp, "attachment") */) + bRet = PR_FALSE; + else if (!PL_strcasecmp (firstChild->content_type, TEXT_PLAIN) || + !PL_strcasecmp (firstChild->content_type, TEXT_HTML) || + !PL_strcasecmp (firstChild->content_type, TEXT_MDL) || + !PL_strcasecmp (firstChild->content_type, MULTIPART_ALTERNATIVE) || + !PL_strcasecmp (firstChild->content_type, MULTIPART_RELATED) || + !PL_strcasecmp (firstChild->content_type, MESSAGE_NEWS) || + !PL_strcasecmp (firstChild->content_type, MESSAGE_RFC822)) + bRet = PR_TRUE; + else + bRet = PR_FALSE; + PR_FREEIF(disp); + return bRet; } // // New Stream Converter Interface // -// Get the connnection to prefs service manager +// Get the connnection to prefs service manager nsIPrefBranch * GetPrefBranch(MimeDisplayOptions *opt) { - if (!opt) + if (!opt) return nsnull; return opt->m_prefBranch; @@ -1399,7 +1398,7 @@ GetPrefBranch(MimeDisplayOptions *opt) mozITXTToHTMLConv * GetTextConverter(MimeDisplayOptions *opt) { - if (!opt) + if (!opt) return nsnull; return opt->conv; @@ -1409,9 +1408,9 @@ MimeDisplayOptions::MimeDisplayOptions() { conv = nsnull; // For text conversion... format_out = 0; // The format out type - url = nsnull; + url = nsnull; - memset(&headers,0, sizeof(headers)); + memset(&headers,0, sizeof(headers)); fancy_headers_p = PR_FALSE; output_vcard_buttons_p = PR_FALSE; @@ -1436,7 +1435,7 @@ MimeDisplayOptions::MimeDisplayOptions() stream_closure = nsnull; /* For setting up the display stream, so that the MIME parser can inform - the caller of the type of the data it will be getting. */ + the caller of the type of the data it will be getting. */ output_init_fn = nsnull; output_fn = nsnull; @@ -1471,7 +1470,7 @@ MimeDisplayOptions::MimeDisplayOptions() decompose_init_count = 0; signed_p = PR_FALSE; - caller_need_root_headers = PR_FALSE; + caller_need_root_headers = PR_FALSE; decompose_headers_info_fn = nsnull; decompose_file_init_fn = nsnull; decompose_file_output_fn = nsnull; @@ -1490,7 +1489,7 @@ MimeDisplayOptions::~MimeDisplayOptions() PR_FREEIF(default_charset); } //////////////////////////////////////////////////////////////// -// Bridge routines for new stream converter XP-COM interface +// Bridge routines for new stream converter XP-COM interface //////////////////////////////////////////////////////////////// extern "C" void * mime_bridge_create_display_stream( @@ -1498,19 +1497,19 @@ mime_bridge_create_display_stream( nsStreamConverter *newPluginObj2, nsIURI *uri, nsMimeOutputType format_out, - PRUint32 whattodo, + PRUint32 whattodo, nsIChannel *aChannel) { int status = 0; MimeObject *obj; struct mime_stream_data *msd; nsMIMESession *stream = 0; - + if (!uri) return nsnull; msd = PR_NEWZAP(struct mime_stream_data); - if (!msd) + if (!msd) return NULL; // Assign the new mime emitter - will handle output operations @@ -1539,10 +1538,10 @@ mime_bridge_create_display_stream( msgUrl->GetOriginalSpec(&msd->orig_url_name); } } - + msd->format_out = format_out; // output format - msd->pluginObj2 = newPluginObj2; // the plugin object pointer - + msd->pluginObj2 = newPluginObj2; // the plugin object pointer + msd->options = new MimeDisplayOptions; if (!msd->options) { @@ -1573,7 +1572,7 @@ mime_bridge_create_display_stream( // MIME_HeaderType = MimeHeadersAll; msd->options->write_html_p = PR_TRUE; - switch (format_out) + switch (format_out) { case nsMimeOutput::nsMimeMessageSplitDisplay: // the wrapper HTML output to produce the split header/body display case nsMimeOutput::nsMimeMessageHeaderDisplay: // the split header/body display @@ -1612,7 +1611,7 @@ mime_bridge_create_display_stream( //////////////////////////////////////////////////////////// // Now, get the libmime prefs... //////////////////////////////////////////////////////////// - + MIME_WrapLongLines = PR_TRUE; MIME_VariableWidthPlaintext = PR_TRUE; msd->options->force_user_charset = PR_FALSE; @@ -1621,13 +1620,13 @@ mime_bridge_create_display_stream( { msd->options->m_prefBranch->GetBoolPref("mail.wrap_long_lines", &MIME_WrapLongLines); msd->options->m_prefBranch->GetBoolPref("mail.fixed_width_messages", &MIME_VariableWidthPlaintext); - // + // // Charset overrides takes place here // // We have a bool pref (mail.force_user_charset) to deal with attachments. // 1) If true - libmime does NO conversion and just passes it through to raptor - // 2) If false, then we try to use the charset of the part and if not available, - // the charset of the root message + // 2) If false, then we try to use the charset of the part and if not available, + // the charset of the root message // msd->options->m_prefBranch->GetBoolPref("mail.force_user_charset", &(msd->options->force_user_charset)); msd->options->m_prefBranch->GetBoolPref("mail.inline_attachments", &(msd->options->show_attachment_inline_p)); @@ -1638,8 +1637,8 @@ mime_bridge_create_display_stream( msd->options->wrap_long_lines_p = MIME_WrapLongLines; msd->options->headers = MIME_HeaderType; - - // We need to have the URL to be able to support the various + + // We need to have the URL to be able to support the various // arguments status = mime_parse_url_options(msd->url_name, msd->options); if (status < 0) @@ -1649,7 +1648,7 @@ mime_bridge_create_display_stream( PR_Free(msd); return 0; } - + if (msd->options->headers == MimeHeadersMicro && (msd->url_name == NULL || (strncmp(msd->url_name, "news:", 5) != 0 && strncmp(msd->url_name, "snews:", 6) != 0)) ) @@ -1657,21 +1656,21 @@ mime_bridge_create_display_stream( msd->options->url = msd->url_name; msd->options->output_init_fn = mime_output_init_fn; - + msd->options->output_fn = mime_output_fn; - msd->options->whattodo = whattodo; + msd->options->whattodo = whattodo; msd->options->charset_conversion_fn = mime_convert_charset; msd->options->rfc1522_conversion_p = PR_TRUE; msd->options->file_type_fn = mime_file_type; msd->options->stream_closure = msd; msd->options->passwd_prompt_fn = 0; - + msd->options->image_begin = mime_image_begin; msd->options->image_end = mime_image_end; msd->options->make_image_html = mime_image_make_image_html; msd->options->image_write_buffer = mime_image_write_buffer; - + msd->options->variable_width_plaintext_p = MIME_VariableWidthPlaintext; // If this is a part, then we should emit the HTML to render the data @@ -1689,10 +1688,10 @@ mime_bridge_create_display_stream( obj->options = msd->options; msd->obj = obj; - + /* Both of these better not be true at the same time. */ PR_ASSERT(! (obj->options->decrypt_p && obj->options->write_html_p)); - + stream = PR_NEW(nsMIMESession); if (!stream) { @@ -1701,14 +1700,14 @@ mime_bridge_create_display_stream( PR_Free(obj); return 0; } - - memset (stream, 0, sizeof (*stream)); + + memset (stream, 0, sizeof (*stream)); stream->name = "MIME Conversion Stream"; stream->complete = mime_display_stream_complete; stream->abort = mime_display_stream_abort; stream->put_block = mime_display_stream_write; stream->data_object = msd; - + status = obj->clazz->initialize(obj); if (status >= 0) status = obj->clazz->parse_begin(obj); @@ -1720,7 +1719,7 @@ mime_bridge_create_display_stream( PR_Free(obj); return 0; } - + return stream; } @@ -1731,7 +1730,7 @@ nsIMimeEmitter * GetMimeEmitter(MimeDisplayOptions *opt) { mime_stream_data *msd = (mime_stream_data *)opt->stream_closure; - if (!msd) + if (!msd) return NULL; nsIMimeEmitter *ptr = (nsIMimeEmitter *)(msd->output_emitter); @@ -1765,7 +1764,7 @@ mimeEmitterAddAttachmentField(MimeDisplayOptions *opt, const char *field, const return NS_OK; mime_stream_data *msd = GetMSD(opt); - if (!msd) + if (!msd) return NS_ERROR_FAILURE; if (msd->output_emitter) @@ -1777,7 +1776,7 @@ mimeEmitterAddAttachmentField(MimeDisplayOptions *opt, const char *field, const return NS_ERROR_FAILURE; } -extern "C" nsresult +extern "C" nsresult mimeEmitterAddHeaderField(MimeDisplayOptions *opt, const char *field, const char *value) { // Check for draft processing... @@ -1785,7 +1784,7 @@ mimeEmitterAddHeaderField(MimeDisplayOptions *opt, const char *field, const char return NS_OK; mime_stream_data *msd = GetMSD(opt); - if (!msd) + if (!msd) return NS_ERROR_FAILURE; if (msd->output_emitter) @@ -1797,7 +1796,7 @@ mimeEmitterAddHeaderField(MimeDisplayOptions *opt, const char *field, const char return NS_ERROR_FAILURE; } -extern "C" nsresult +extern "C" nsresult mimeEmitterAddAllHeaders(MimeDisplayOptions *opt, const char *allheaders, const PRInt32 allheadersize) { // Check for draft processing... @@ -1805,7 +1804,7 @@ mimeEmitterAddAllHeaders(MimeDisplayOptions *opt, const char *allheaders, const return NS_OK; mime_stream_data *msd = GetMSD(opt); - if (!msd) + if (!msd) return NS_ERROR_FAILURE; if (msd->output_emitter) @@ -1817,7 +1816,7 @@ mimeEmitterAddAllHeaders(MimeDisplayOptions *opt, const char *allheaders, const return NS_ERROR_FAILURE; } -extern "C" nsresult +extern "C" nsresult mimeEmitterStartAttachment(MimeDisplayOptions *opt, const char *name, const char *contentType, const char *url, PRBool aIsExternalAttachment) { @@ -1826,7 +1825,7 @@ mimeEmitterStartAttachment(MimeDisplayOptions *opt, const char *name, const char return NS_OK; mime_stream_data *msd = GetMSD(opt); - if (!msd) + if (!msd) return NS_ERROR_FAILURE; if (msd->output_emitter) @@ -1838,7 +1837,7 @@ mimeEmitterStartAttachment(MimeDisplayOptions *opt, const char *name, const char return NS_ERROR_FAILURE; } -extern "C" nsresult +extern "C" nsresult mimeEmitterEndAttachment(MimeDisplayOptions *opt) { // Check for draft processing... @@ -1846,7 +1845,7 @@ mimeEmitterEndAttachment(MimeDisplayOptions *opt) return NS_OK; mime_stream_data *msd = GetMSD(opt); - if (!msd) + if (!msd) return NS_ERROR_FAILURE; if (msd->output_emitter) @@ -1861,7 +1860,7 @@ mimeEmitterEndAttachment(MimeDisplayOptions *opt) return NS_ERROR_FAILURE; } -extern "C" nsresult +extern "C" nsresult mimeEmitterEndAllAttachments(MimeDisplayOptions *opt) { // Check for draft processing... @@ -1869,7 +1868,7 @@ mimeEmitterEndAllAttachments(MimeDisplayOptions *opt) return NS_OK; mime_stream_data *msd = GetMSD(opt); - if (!msd) + if (!msd) return NS_ERROR_FAILURE; if (msd->output_emitter) @@ -1884,7 +1883,7 @@ mimeEmitterEndAllAttachments(MimeDisplayOptions *opt) return NS_ERROR_FAILURE; } -extern "C" nsresult +extern "C" nsresult mimeEmitterStartBody(MimeDisplayOptions *opt, PRBool bodyOnly, const char *msgID, const char *outCharset) { // Check for draft processing... @@ -1892,7 +1891,7 @@ mimeEmitterStartBody(MimeDisplayOptions *opt, PRBool bodyOnly, const char *msgID return NS_OK; mime_stream_data *msd = GetMSD(opt); - if (!msd) + if (!msd) return NS_ERROR_FAILURE; if (msd->output_emitter) @@ -1904,7 +1903,7 @@ mimeEmitterStartBody(MimeDisplayOptions *opt, PRBool bodyOnly, const char *msgID return NS_ERROR_FAILURE; } -extern "C" nsresult +extern "C" nsresult mimeEmitterEndBody(MimeDisplayOptions *opt) { // Check for draft processing... @@ -1912,7 +1911,7 @@ mimeEmitterEndBody(MimeDisplayOptions *opt) return NS_OK; mime_stream_data *msd = GetMSD(opt); - if (!msd) + if (!msd) return NS_ERROR_FAILURE; if (msd->output_emitter) @@ -1924,7 +1923,7 @@ mimeEmitterEndBody(MimeDisplayOptions *opt) return NS_ERROR_FAILURE; } -extern "C" nsresult +extern "C" nsresult mimeEmitterEndHeader(MimeDisplayOptions *opt) { // Check for draft processing... @@ -1932,7 +1931,7 @@ mimeEmitterEndHeader(MimeDisplayOptions *opt) return NS_OK; mime_stream_data *msd = GetMSD(opt); - if (!msd) + if (!msd) return NS_ERROR_FAILURE; if (msd->output_emitter) @@ -1944,7 +1943,7 @@ mimeEmitterEndHeader(MimeDisplayOptions *opt) return NS_ERROR_FAILURE; } -extern "C" nsresult +extern "C" nsresult mimeEmitterUpdateCharacterSet(MimeDisplayOptions *opt, const char *aCharset) { // Check for draft processing... @@ -1952,7 +1951,7 @@ mimeEmitterUpdateCharacterSet(MimeDisplayOptions *opt, const char *aCharset) return NS_OK; mime_stream_data *msd = GetMSD(opt); - if (!msd) + if (!msd) return NS_ERROR_FAILURE; if (msd->output_emitter) @@ -1964,7 +1963,7 @@ mimeEmitterUpdateCharacterSet(MimeDisplayOptions *opt, const char *aCharset) return NS_ERROR_FAILURE; } -extern "C" nsresult +extern "C" nsresult mimeEmitterStartHeader(MimeDisplayOptions *opt, PRBool rootMailHeader, PRBool headerOnly, const char *msgID, const char *outCharset) { @@ -1973,7 +1972,7 @@ mimeEmitterStartHeader(MimeDisplayOptions *opt, PRBool rootMailHeader, PRBool he return NS_OK; mime_stream_data *msd = GetMSD(opt); - if (!msd) + if (!msd) return NS_ERROR_FAILURE; if (msd->output_emitter) @@ -1996,18 +1995,18 @@ mimeSetNewURL(nsMIMESession *stream, char *url) if (!msd) return NS_ERROR_FAILURE; - char *tmpPtr = nsCRT::strdup(url); + char *tmpPtr = strdup(url); if (!tmpPtr) return NS_ERROR_FAILURE; PR_FREEIF(msd->url_name); - msd->url_name = nsCRT::strdup(tmpPtr); + msd->url_name = strdup(tmpPtr); return NS_OK; } #define MIME_URL "chrome://messenger/locale/mime.properties" -extern "C" +extern "C" char * MimeGetStringByID(PRInt32 stringID) { @@ -2019,9 +2018,9 @@ MimeGetStringByID(PRInt32 stringID) { const char* propertyURL = MIME_URL; - nsCOMPtr sBundleService = - do_GetService(NS_STRINGBUNDLE_CONTRACTID, &res); - if (NS_SUCCEEDED(res) && (nsnull != sBundleService)) + nsCOMPtr sBundleService = + do_GetService(NS_STRINGBUNDLE_CONTRACTID, &res); + if (NS_SUCCEEDED(res) && (nsnull != sBundleService)) { res = sBundleService->CreateBundle(propertyURL, getter_AddRefs(stringBundle)); } @@ -2032,7 +2031,7 @@ MimeGetStringByID(PRInt32 stringID) nsString v; res = stringBundle->GetStringFromID(stringID, getter_Copies(v)); - if (NS_SUCCEEDED(res)) + if (NS_SUCCEEDED(res)) tempString = ToNewUTF8String(v); } @@ -2043,16 +2042,16 @@ MimeGetStringByID(PRInt32 stringID) } void PR_CALLBACK -ResetChannelCharset(MimeObject *obj) -{ - if (obj->options && obj->options->stream_closure && - obj->options->default_charset && obj->headers ) - { - mime_stream_data *msd = (mime_stream_data *) (obj->options->stream_closure); - char *ct = MimeHeaders_get (obj->headers, HEADER_CONTENT_TYPE, PR_FALSE, PR_FALSE); - if ( (ct) && (msd) && (msd->channel) ) - { - char *ptr = strstr(ct, "charset="); +ResetChannelCharset(MimeObject *obj) +{ + if (obj->options && obj->options->stream_closure && + obj->options->default_charset && obj->headers ) + { + mime_stream_data *msd = (mime_stream_data *) (obj->options->stream_closure); + char *ct = MimeHeaders_get (obj->headers, HEADER_CONTENT_TYPE, PR_FALSE, PR_FALSE); + if ( (ct) && (msd) && (msd->channel) ) + { + char *ptr = strstr(ct, "charset="); if (ptr) { // First, setup the channel! @@ -2066,19 +2065,19 @@ ResetChannelCharset(MimeObject *obj) // Extract the charset alone char *cSet = nsnull; if (*(ptr+8) == '"') - cSet = nsCRT::strdup(ptr+9); + cSet = strdup(ptr+9); else - cSet = nsCRT::strdup(ptr+8); + cSet = strdup(ptr+8); if (cSet) { char *ptr2 = cSet; - while ( (*cSet) && (*cSet != ' ') && (*cSet != ';') && + while ( (*cSet) && (*cSet != ' ') && (*cSet != ';') && (*cSet != '\r') && (*cSet != '\n') && (*cSet != '"') ) ptr2++; - + if (*cSet) { PR_FREEIF(obj->options->default_charset); - obj->options->default_charset = nsCRT::strdup(cSet); + obj->options->default_charset = strdup(cSet); obj->options->override_charset = PR_TRUE; } @@ -2086,18 +2085,18 @@ ResetChannelCharset(MimeObject *obj) } } } - PR_FREEIF(ct); - } - } + PR_FREEIF(ct); + } + } } //////////////////////////////////////////////////////////// - // Function to get up mail/news fontlang + // Function to get up mail/news fontlang //////////////////////////////////////////////////////////// -nsresult GetMailNewsFont(MimeObject *obj, PRBool styleFixed, PRInt32 *fontPixelSize, - PRInt32 *fontSizePercentage, nsCString& fontLang) +nsresult GetMailNewsFont(MimeObject *obj, PRBool styleFixed, PRInt32 *fontPixelSize, + PRInt32 *fontSizePercentage, nsCString& fontLang) { nsresult rv = NS_OK; @@ -2155,7 +2154,7 @@ nsresult GetMailNewsFont(MimeObject *obj, PRBool styleFixed, PRInt32 *fontPixel return rv; // calculate percentage - *fontSizePercentage = originalSize ? + *fontSizePercentage = originalSize ? (PRInt32)((float)*fontPixelSize / (float)originalSize * 100) : 0; } diff --git a/mozilla/mailnews/mime/src/mimemrel.cpp b/mozilla/mailnews/mime/src/mimemrel.cpp index 5ea83314a55..395880b870e 100644 --- a/mozilla/mailnews/mime/src/mimemrel.cpp +++ b/mozilla/mailnews/mime/src/mimemrel.cpp @@ -35,7 +35,7 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** - * This Original Code has been modified by IBM Corporation. Modifications made by IBM + * This Original Code has been modified by IBM Corporation. Modifications made by IBM * described herein are Copyright (c) International Business Machines Corporation, 2000. * Modifications to Mozilla code or documentation identified per MPL Section 3.3 * @@ -137,7 +137,6 @@ #include "mimemoz2.h" #include "nsString.h" #include "nsIURL.h" -#include "nsCRT.h" #include "msgCore.h" #include "nsMimeStringResources.h" #include "nsMimeTypes.h" @@ -161,7 +160,7 @@ class MimeHashValue public: MimeHashValue(MimeObject *obj, char *url) { m_obj = obj; - m_url = nsCRT::strdup(url); + m_url = strdup(url); } virtual ~MimeHashValue() { if (m_url) @@ -205,9 +204,9 @@ MimeMultipartRelated_initialize(MimeObject* obj) return ((MimeObjectClass*)&MIME_SUPERCLASS)->initialize(obj); } -static PRIntn PR_CALLBACK -mime_multipart_related_nukehash(PLHashEntry *table, - PRIntn indx, void *arg) +static PRIntn PR_CALLBACK +mime_multipart_related_nukehash(PLHashEntry *table, + PRIntn indx, void *arg) { if (table->key) PR_Free((char*) table->key); @@ -233,19 +232,19 @@ MimeMultipartRelated_finalize (MimeObject *obj) relobj->hash = NULL; } - if (relobj->input_file_stream) + if (relobj->input_file_stream) { relobj->input_file_stream->Close(); relobj->input_file_stream = nsnull; } - if (relobj->output_file_stream) + if (relobj->output_file_stream) { relobj->output_file_stream->Close(); relobj->output_file_stream = nsnull; } - if (relobj->file_buffer) + if (relobj->file_buffer) { relobj->file_buffer->Remove(PR_FALSE); relobj->file_buffer = nsnull; @@ -257,7 +256,7 @@ MimeMultipartRelated_finalize (MimeObject *obj) #define ISHEX(c) ( ((c) >= '0' && (c) <= '9') || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F') ) #define NONHEX(c) (!ISHEX(c)) -extern "C" char * +extern "C" char * escape_unescaped_percents(const char *incomingURL) { const char *inC; @@ -273,13 +272,13 @@ escape_unescaped_percents(const char *incomingURL) /* Check if either of the next two characters are non-hex. */ if ( !*(inC+1) || NONHEX(*(inC+1)) || !*(inC+2) || NONHEX(*(inC+2)) ) { - /* Hex characters don't follow, escape the + /* Hex characters don't follow, escape the percent char */ *outC++ = '%'; *outC++ = '2'; *outC++ = '5'; } else { - /* Hex characters follow, so assume the percent + /* Hex characters follow, so assume the percent is escaping something else */ *outC++ = *inC; } @@ -293,18 +292,17 @@ escape_unescaped_percents(const char *incomingURL) return result; } -/* This routine is only necessary because the mailbox URL fed to us +/* This routine is only necessary because the mailbox URL fed to us by the winfe can contain spaces and '>'s in it. It's a hack. */ static char * escape_for_mrel_subst(char *inURL) { char *output, *inC, *outC, *temp; - /* nsCRT::strlen asserts the presence of a string in inURL */ int size = strlen(inURL) + 1; for(inC = inURL; *inC; inC++) - if ((*inC == ' ') || (*inC == '>')) + if ((*inC == ' ') || (*inC == '>')) size += 2; /* space -> '%20', '>' -> '%3E', etc. */ output = (char *)PR_MALLOC(size); @@ -330,7 +328,7 @@ escape_for_mrel_subst(char *inURL) inC++; } *outC = '\0'; - + temp = escape_unescaped_percents(output); if (temp) { @@ -375,18 +373,18 @@ MimeThisIsStartPart(MimeObject *obj, MimeObject* child) else { char *tmp = cst; - if (*tmp == '<') + if (*tmp == '<') { int length; tmp++; length = strlen(tmp); - if (length > 0 && tmp[length - 1] == '>') + if (length > 0 && tmp[length - 1] == '>') { tmp[length - 1] = '\0'; } } - rval = (!nsCRT::strcmp(st, tmp)); + rval = (!strcmp(st, tmp)); } PR_FREEIF(st); @@ -413,16 +411,16 @@ MakeAbsoluteURL(char *base_url, char *relative_url) } nsresult err = nsMimeNewURI(&base, base_url, nsnull); - if (err != NS_OK) + if (err != NS_OK) return nsnull; nsCAutoString spec; nsIURI *url = nsnull; err = nsMimeNewURI(&url, relative_url, base); - if (err != NS_OK) + if (err != NS_OK) goto done; - + err = url->GetSpec(spec); if (err) { @@ -430,7 +428,7 @@ MakeAbsoluteURL(char *base_url, char *relative_url) goto done; } retString = ToNewCString(spec); - + done: NS_IF_RELEASE(url); NS_IF_RELEASE(base); @@ -442,12 +440,12 @@ MimeMultipartRelated_output_child_p(MimeObject *obj, MimeObject* child) { MimeMultipartRelated *relobj = (MimeMultipartRelated *) obj; - /* rhp - Changed from "if (relobj->head_loaded)" alone to support the + /* rhp - Changed from "if (relobj->head_loaded)" alone to support the start parameter */ if ( - (relobj->head_loaded) || - (MimeStartParamExists(obj, child) && !MimeThisIsStartPart(obj, child)) + (relobj->head_loaded) || + (MimeStartParamExists(obj, child) && !MimeThisIsStartPart(obj, child)) ) { /* This is a child part. Just remember the mapping between the URL @@ -502,7 +500,7 @@ MimeMultipartRelated_output_child_p(MimeObject *obj, MimeObject* child) partnum.Append(".2"); char* part; - if (!imappartnum.IsEmpty()) + if (!imappartnum.IsEmpty()) part = mime_set_url_imap_part(obj->options->url, imappartnum.get(), partnum.get()); else { @@ -542,20 +540,20 @@ MimeMultipartRelated_output_child_p(MimeObject *obj, MimeObject* child) { char *tloc; char *tmp = MimeHeaders_get(child->headers, HEADER_CONTENT_ID, PR_FALSE, PR_FALSE); - if (tmp) + if (tmp) { char* tmp2 = tmp; - if (*tmp2 == '<') + if (*tmp2 == '<') { int length; tmp2++; length = strlen(tmp2); - if (length > 0 && tmp2[length - 1] == '>') + if (length > 0 && tmp2[length - 1] == '>') { tmp2[length - 1] = '\0'; } } - + tloc = PR_smprintf("cid:%s", tmp2); PR_Free(tmp); if (tloc) @@ -666,7 +664,7 @@ MimeMultipartRelated_parse_child_line (MimeObject *obj, nsresult rv; /* Ok, if at this point we still don't have either kind of buffer, try and make a file buffer. */ - if (!relobj->head_buffer && !relobj->file_buffer) + if (!relobj->head_buffer && !relobj->file_buffer) { nsCOMPtr file; rv = nsMsgCreateTempFile("nsma", getter_AddRefs(file)); @@ -676,7 +674,7 @@ MimeMultipartRelated_parse_child_line (MimeObject *obj, rv = NS_NewLocalFileOutputStream(getter_AddRefs(relobj->output_file_stream), relobj->file_buffer, PR_WRONLY | PR_CREATE_FILE, 00600); NS_ENSURE_SUCCESS(rv, rv); } - + PR_ASSERT(relobj->head_buffer || relobj->output_file_stream); @@ -691,9 +689,9 @@ MimeMultipartRelated_parse_child_line (MimeObject *obj, /* If the file isn't open yet, open it, and dump the memory buffer to it. */ - if (!relobj->output_file_stream) + if (!relobj->output_file_stream) { - if (!relobj->file_buffer) + if (!relobj->file_buffer) { nsCOMPtr file; rv = nsMsgCreateTempFile("nsma", getter_AddRefs(file)); @@ -704,7 +702,7 @@ MimeMultipartRelated_parse_child_line (MimeObject *obj, nsresult rv = NS_NewLocalFileOutputStream(getter_AddRefs(relobj->output_file_stream), relobj->file_buffer, PR_WRONLY | PR_CREATE_FILE, 00600); NS_ENSURE_SUCCESS(rv, rv); - if (relobj->head_buffer && relobj->head_buffer_fp) + if (relobj->head_buffer && relobj->head_buffer_fp) { PRUint32 bytesWritten; status = relobj->output_file_stream->Write(relobj->head_buffer, @@ -722,7 +720,7 @@ MimeMultipartRelated_parse_child_line (MimeObject *obj, /* Dump this line to the file. */ PRUint32 bytesWritten; rv = relobj->output_file_stream->Write(line, length, &bytesWritten); - if ((PRInt32) bytesWritten < length || NS_FAILED(rv)) + if ((PRInt32) bytesWritten < length || NS_FAILED(rv)) return MIME_UNABLE_TO_OPEN_TMP_FILE; } @@ -743,7 +741,7 @@ real_write(MimeMultipartRelated* relobj, const char* buf, PRInt32 size) obj->options->decompose_file_p && obj->options->decompose_file_output_fn ) { - return obj->options->decompose_file_output_fn + return obj->options->decompose_file_output_fn (buf, size, obj->options->stream_closure); } else @@ -781,7 +779,7 @@ static PRBool accept_related_part(MimeMultipartRelated* relobj, MimeObject* part { if (!relobj || !part_obj) return PR_FALSE; - + /* before accepting it as a valid related part, make sure we are able to display it inline as an embedded object. Else just ignore it, that will prevent any bad surprise... */ @@ -791,7 +789,7 @@ static PRBool accept_related_part(MimeMultipartRelated* relobj, MimeObject* part /* ...but we always accept it if it's referenced by an anchor */ return (relobj->curtag && relobj->curtag_length >= 3 && - (relobj->curtag[1] == 'A' || relobj->curtag[1] == 'a') && nsCRT::IsAsciiSpace(relobj->curtag[2])); + (relobj->curtag[1] == 'A' || relobj->curtag[1] == 'a') && IS_SPACE(relobj->curtag[2])); } static int @@ -800,7 +798,7 @@ flush_tag(MimeMultipartRelated* relobj) int length = relobj->curtag_length; char* buf; int status; - + if (relobj->curtag == NULL || length == 0) return 0; status = push_tag(relobj, "", 1); /* Push on a trailing NULL. */ @@ -821,19 +819,19 @@ flush_tag(MimeMultipartRelated* relobj) quoteDelimiter = *ptr; /* Take up the quote and leading space here as well. */ /* Safe because there's a '>' at the end */ - do {ptr++;} while (nsCRT::IsAsciiSpace(*ptr)); + do {ptr++;} while (IS_SPACE(*ptr)); } } status = real_write(relobj, buf, ptr - buf); if (status < 0) return status; buf = ptr; if (!*buf) break; - if (quoteDelimiter) + if (quoteDelimiter) { ptr = PL_strnchr(buf, quoteDelimiter, length - (buf - relobj->curtag)); } else { for (ptr = buf; *ptr ; ptr++) { - if (*ptr == '>' || nsCRT::IsAsciiSpace(*ptr)) break; + if (*ptr == '>' || IS_SPACE(*ptr)) break; } PR_ASSERT(*ptr); } @@ -846,13 +844,13 @@ flush_tag(MimeMultipartRelated* relobj) substitute the appropriate mailbox part URL in its place. */ ptr2=buf; /* walk from the left end rightward */ - while((ptr2 4) && - ((buf[0]=='c' || buf[0]=='C') && - (buf[1]=='i' || buf[1]=='I') && - (buf[2]=='d' || buf[2]=='D') && + if (((ptr2 - buf) > 4) && + ((buf[0]=='c' || buf[0]=='C') && + (buf[1]=='i' || buf[1]=='I') && + (buf[2]=='d' || buf[2]=='D') && buf[3]==':')) { // Make sure it's lowercase, otherwise it won't be found in the hash table @@ -861,7 +859,7 @@ flush_tag(MimeMultipartRelated* relobj) /* Null terminate the word so we can... */ c = *ptr2; *ptr2 = '\0'; - + /* Construct a URL out of the word. */ absolute = MakeAbsoluteURL(relobj->base_url, buf); @@ -875,7 +873,7 @@ flush_tag(MimeMultipartRelated* relobj) part_url = value ? value->m_url : nsnull; PR_FREEIF(absolute); } - + /*If we found a mailbox part URL, write that out instead.*/ if (part_url && accept_related_part(relobj, value->m_obj)) { @@ -887,18 +885,18 @@ flush_tag(MimeMultipartRelated* relobj) if (value->m_obj) value->m_obj->dontShowAsAttachment = PR_TRUE; } - + /* Restore the character that we nulled. */ *ptr2 = c; } /* rhp - if we get here, we should still check against the hash table! */ - else + else { char holder = *ptr2; char *realout; *ptr2 = '\0'; - + /* Construct a URL out of the word. */ absolute = MakeAbsoluteURL(relobj->base_url, buf); @@ -929,7 +927,7 @@ flush_tag(MimeMultipartRelated* relobj) /* Advance to the beginning of the next word, or to the end of the value string. */ - while((ptr2dontShowAsAttachment = body->clazz->displayable_inline_p(body->clazz, body->headers); #ifdef MIME_DRAFTS - if ( obj->options && + if ( obj->options && obj->options->decompose_file_p && obj->options->decompose_file_init_fn && (relobj->file_buffer || relobj->head_buffer)) @@ -1052,8 +1050,8 @@ MimeMultipartRelated_parse_eof (MimeObject *obj, PRBool abort_p) start its parser going. */ status = body->clazz->parse_begin(body); if (status < 0) goto FAIL; - - if (relobj->head_buffer) + + if (relobj->head_buffer) { /* Read it out of memory. */ PR_ASSERT(!relobj->file_buffer && !relobj->input_file_stream); @@ -1061,8 +1059,8 @@ MimeMultipartRelated_parse_eof (MimeObject *obj, PRBool abort_p) status = body->clazz->parse_buffer(relobj->head_buffer, relobj->head_buffer_fp, body); - } - else if (relobj->file_buffer) + } + else if (relobj->file_buffer) { /* Read it off disk. */ char *buf; @@ -1071,14 +1069,14 @@ MimeMultipartRelated_parse_eof (MimeObject *obj, PRBool abort_p) PR_ASSERT(relobj->head_buffer_size == 0 && relobj->head_buffer_fp == 0); PR_ASSERT(relobj->file_buffer); - if (!relobj->file_buffer) + if (!relobj->file_buffer) { status = -1; goto FAIL; } buf = (char *) PR_MALLOC(buf_size); - if (!buf) + if (!buf) { status = MIME_OUT_OF_MEMORY; goto FAIL; @@ -1089,23 +1087,23 @@ MimeMultipartRelated_parse_eof (MimeObject *obj, PRBool abort_p) relobj->output_file_stream->Close(); nsresult rv = NS_NewLocalFileInputStream(getter_AddRefs(relobj->input_file_stream), relobj->file_buffer); - if (NS_FAILED(rv)) + if (NS_FAILED(rv)) { PR_Free(buf); status = MIME_UNABLE_TO_OPEN_TMP_FILE; goto FAIL; } - while(1) + while(1) { PRUint32 bytesRead = 0; rv = relobj->input_file_stream->Read(buf, buf_size - 1, &bytesRead); - if (NS_FAILED(rv) || !bytesRead) + if (NS_FAILED(rv) || !bytesRead) { status = NS_FAILED(rv) ? -1 : 0; break; - } - else + } + else { /* It would be really nice to be able to yield here, and let some user events and other input sources get processed. @@ -1143,7 +1141,7 @@ FAIL: obj->options->output_closure = relobj->real_output_closure; return status; -} +} diff --git a/mozilla/mailnews/mime/src/mimemsg.cpp b/mozilla/mailnews/mime/src/mimemsg.cpp index 1bfc73dea9b..e81cfc1d8b6 100644 --- a/mozilla/mailnews/mime/src/mimemsg.cpp +++ b/mozilla/mailnews/mime/src/mimemsg.cpp @@ -45,7 +45,6 @@ #include "msgCore.h" #include "prlog.h" #include "prprf.h" -#include "nsCRT.h" #include "nsMimeStringResources.h" #include "nsMimeTypes.h" #include "nsMsgMessageFlags.h" @@ -57,7 +56,7 @@ #define MIME_SUPERCLASS mimeContainerClass MimeDefClass(MimeMessage, MimeMessageClass, mimeMessageClass, - &MIME_SUPERCLASS); + &MIME_SUPERCLASS); static int MimeMessage_initialize (MimeObject *); static void MimeMessage_finalize (MimeObject *); @@ -68,8 +67,8 @@ static int MimeMessage_parse_eof (MimeObject *, PRBool); static int MimeMessage_close_headers (MimeObject *obj); static int MimeMessage_write_headers_html (MimeObject *); static char *MimeMessage_partial_message_html(const char *data, - void *closure, - MimeHeaders *headers); + void *closure, + MimeHeaders *headers); #ifdef MOZ_SECURITY HG56268 @@ -121,7 +120,7 @@ MimeMessage_finalize (MimeObject *object) { MimeMessage *msg = (MimeMessage *)object; if (msg->hdrs) - MimeHeaders_free(msg->hdrs); + MimeHeaders_free(msg->hdrs); msg->hdrs = 0; ((MimeObjectClass*)&MIME_SUPERCLASS)->finalize(object); } @@ -140,7 +139,7 @@ MimeMessage_parse_begin (MimeObject *obj) } /* Messages have separators before the headers, except for the outermost - message. */ + message. */ return MimeObject_write_separator(obj); } @@ -183,93 +182,93 @@ MimeMessage_parse_line (const char *aLine, PRInt32 aLength, MimeObject *obj) } /* If we already have a child object, then we're done parsing headers, - and all subsequent lines get passed to the inferior object without - further processing by us. (Our parent will stop feeding us lines - when this MimeMessage part is out of data.) + and all subsequent lines get passed to the inferior object without + further processing by us. (Our parent will stop feeding us lines + when this MimeMessage part is out of data.) */ if (msg->container.nchildren) - { - MimeObject *kid = msg->container.children[0]; - PRBool nl; - PR_ASSERT(kid); - if (!kid) return -1; + { + MimeObject *kid = msg->container.children[0]; + PRBool nl; + PR_ASSERT(kid); + if (!kid) return -1; msg->bodyLength += length; - /* Don't allow MimeMessage objects to not end in a newline, since it - would be inappropriate for any following part to appear on the same - line as the last line of the message. + /* Don't allow MimeMessage objects to not end in a newline, since it + would be inappropriate for any following part to appear on the same + line as the last line of the message. - #### This assumes that the only time the `parse_line' method is - called with a line that doesn't end in a newline is when that line - is the last line. - */ - nl = (length > 0 && (line[length-1] == '\r' || line[length-1] == '\n')); + #### This assumes that the only time the `parse_line' method is + called with a line that doesn't end in a newline is when that line + is the last line. + */ + nl = (length > 0 && (line[length-1] == '\r' || line[length-1] == '\n')); #ifdef MIME_DRAFTS - if ( !mime_typep (kid, (MimeObjectClass*) &mimeMessageClass) && - obj->options && - obj->options->decompose_file_p && - ! obj->options->is_multipart_msg && - obj->options->decompose_file_output_fn ) - { - if (!obj->options->decrypt_p) { + if ( !mime_typep (kid, (MimeObjectClass*) &mimeMessageClass) && + obj->options && + obj->options->decompose_file_p && + ! obj->options->is_multipart_msg && + obj->options->decompose_file_output_fn ) + { + if (!obj->options->decrypt_p) { //if we are processing a flowed plain text line, we need to remove any stuffed space if (length > 0 && ' ' == *line && mime_typep(kid, (MimeObjectClass *)&mimeInlineTextPlainFlowedClass)) { line ++; length --; } - status = obj->options->decompose_file_output_fn (line, - length, - obj->options->stream_closure); - if (status < 0) return status; - if (!nl) { - status = obj->options->decompose_file_output_fn (MSG_LINEBREAK, - MSG_LINEBREAK_LEN, - obj->options->stream_closure); - if (status < 0) return status; - } - return status; - } - } + status = obj->options->decompose_file_output_fn (line, + length, + obj->options->stream_closure); + if (status < 0) return status; + if (!nl) { + status = obj->options->decompose_file_output_fn (MSG_LINEBREAK, + MSG_LINEBREAK_LEN, + obj->options->stream_closure); + if (status < 0) return status; + } + return status; + } + } #endif /* MIME_DRAFTS */ - if (nl) - return kid->clazz->parse_buffer (line, length, kid); - else - { - /* Hack a newline onto the end. */ - char *s = (char *)PR_MALLOC(length + MSG_LINEBREAK_LEN + 1); - if (!s) return MIME_OUT_OF_MEMORY; - memcpy(s, line, length); - PL_strcpy(s + length, MSG_LINEBREAK); - status = kid->clazz->parse_buffer (s, length + MSG_LINEBREAK_LEN, kid); - PR_Free(s); - return status; - } - } + if (nl) + return kid->clazz->parse_buffer (line, length, kid); + else + { + /* Hack a newline onto the end. */ + char *s = (char *)PR_MALLOC(length + MSG_LINEBREAK_LEN + 1); + if (!s) return MIME_OUT_OF_MEMORY; + memcpy(s, line, length); + PL_strcpy(s + length, MSG_LINEBREAK); + status = kid->clazz->parse_buffer (s, length + MSG_LINEBREAK_LEN, kid); + PR_Free(s); + return status; + } + } /* Otherwise we don't yet have a child object, which means we're not - done parsing our headers yet. + done parsing our headers yet. */ if (!msg->hdrs) - { - msg->hdrs = MimeHeaders_new(); - if (!msg->hdrs) return MIME_OUT_OF_MEMORY; - } + { + msg->hdrs = MimeHeaders_new(); + if (!msg->hdrs) return MIME_OUT_OF_MEMORY; + } #ifdef MIME_DRAFTS if ( obj->options && - obj->options->decompose_file_p && - ! obj->options->is_multipart_msg && - obj->options->done_parsing_outer_headers && - obj->options->decompose_file_output_fn ) + obj->options->decompose_file_p && + ! obj->options->is_multipart_msg && + obj->options->done_parsing_outer_headers && + obj->options->decompose_file_output_fn ) { - status = obj->options->decompose_file_output_fn( line, length, - obj->options->stream_closure ); - if (status < 0) + status = obj->options->decompose_file_output_fn( line, length, + obj->options->stream_closure ); + if (status < 0) return status; } #endif /* MIME_DRAFTS */ @@ -278,13 +277,13 @@ MimeMessage_parse_line (const char *aLine, PRInt32 aLength, MimeObject *obj) if (status < 0) return status; /* If this line is blank, we're now done parsing headers, and should - examine our content-type to create our "body" part. + examine our content-type to create our "body" part. */ if (*line == '\r' || *line == '\n') - { - status = MimeMessage_close_headers(obj); - if (status < 0) return status; - } + { + status = MimeMessage_close_headers(obj); + if (status < 0) return status; + } return 0; } @@ -294,111 +293,111 @@ MimeMessage_close_headers (MimeObject *obj) { MimeMessage *msg = (MimeMessage *) obj; int status = 0; - char *ct = 0; /* Content-Type header */ + char *ct = 0; /* Content-Type header */ MimeObject *body; if (msg->hdrs) - { - PRBool outer_p = !obj->headers; /* is this the outermost message? */ + { + PRBool outer_p = !obj->headers; /* is this the outermost message? */ #ifdef MIME_DRAFTS - if (outer_p && - obj->options && + if (outer_p && + obj->options && (obj->options->decompose_file_p || obj->options->caller_need_root_headers) && - obj->options->decompose_headers_info_fn) - { + obj->options->decompose_headers_info_fn) + { #ifdef ENABLE_SMIME if (obj->options->decrypt_p && !mime_crypto_object_p (msg->hdrs, PR_FALSE)) obj->options->decrypt_p = PR_FALSE; #endif /* ENABLE_SMIME */ if (!obj->options->caller_need_root_headers || (obj == obj->options->state->root)) - status = obj->options->decompose_headers_info_fn ( - obj->options->stream_closure, - msg->hdrs ); - } + status = obj->options->decompose_headers_info_fn ( + obj->options->stream_closure, + msg->hdrs ); + } #endif /* MIME_DRAFTS */ - /* If this is the outermost message, we need to run the - `generate_header' callback. This happens here instead of - in `parse_begin', because it's only now that we've parsed - our headers. However, since this is the outermost message, - we have yet to write any HTML, so that's fine. - */ - if (outer_p && - obj->output_p && - obj->options && - obj->options->write_html_p && - obj->options->generate_header_html_fn) - { - int lstatus = 0; - char *html = 0; + /* If this is the outermost message, we need to run the + `generate_header' callback. This happens here instead of + in `parse_begin', because it's only now that we've parsed + our headers. However, since this is the outermost message, + we have yet to write any HTML, so that's fine. + */ + if (outer_p && + obj->output_p && + obj->options && + obj->options->write_html_p && + obj->options->generate_header_html_fn) + { + int lstatus = 0; + char *html = 0; - /* The generate_header_html_fn might return HTML, so it's important - that the output stream be set up with the proper type before we - make the MimeObject_write() call below. */ - if (!obj->options->state->first_data_written_p) - { - lstatus = MimeObject_output_init (obj, TEXT_HTML); - if (lstatus < 0) return lstatus; - PR_ASSERT(obj->options->state->first_data_written_p); - } + /* The generate_header_html_fn might return HTML, so it's important + that the output stream be set up with the proper type before we + make the MimeObject_write() call below. */ + if (!obj->options->state->first_data_written_p) + { + lstatus = MimeObject_output_init (obj, TEXT_HTML); + if (lstatus < 0) return lstatus; + PR_ASSERT(obj->options->state->first_data_written_p); + } - html = obj->options->generate_header_html_fn(NULL, - obj->options->html_closure, - msg->hdrs); - if (html) - { - lstatus = MimeObject_write(obj, html, strlen(html), PR_FALSE); - PR_Free(html); - if (lstatus < 0) return lstatus; - } - } + html = obj->options->generate_header_html_fn(NULL, + obj->options->html_closure, + msg->hdrs); + if (html) + { + lstatus = MimeObject_write(obj, html, strlen(html), PR_FALSE); + PR_Free(html); + if (lstatus < 0) return lstatus; + } + } - /* Find the content-type of the body of this message. - */ - { - PRBool ok = PR_TRUE; - char *mv = MimeHeaders_get (msg->hdrs, HEADER_MIME_VERSION, - PR_TRUE, PR_FALSE); + /* Find the content-type of the body of this message. + */ + { + PRBool ok = PR_TRUE; + char *mv = MimeHeaders_get (msg->hdrs, HEADER_MIME_VERSION, + PR_TRUE, PR_FALSE); #ifdef REQUIRE_MIME_VERSION_HEADER - /* If this is the outermost message, it must have a MIME-Version - header with the value 1.0 for us to believe what might be in - the Content-Type header. If the MIME-Version header is not - present, we must treat this message as untyped. - */ - ok = (mv && !nsCRT::strcmp(mv, "1.0")); + /* If this is the outermost message, it must have a MIME-Version + header with the value 1.0 for us to believe what might be in + the Content-Type header. If the MIME-Version header is not + present, we must treat this message as untyped. + */ + ok = (mv && !strcmp(mv, "1.0")); #else - /* #### actually, we didn't check this in Mozilla 2.0, and checking - it now could cause some compatibility nonsense, so for now, let's - just believe any Content-Type header we see. - */ - ok = PR_TRUE; + /* #### actually, we didn't check this in Mozilla 2.0, and checking + it now could cause some compatibility nonsense, so for now, let's + just believe any Content-Type header we see. + */ + ok = PR_TRUE; #endif - if (ok) - { - ct = MimeHeaders_get (msg->hdrs, HEADER_CONTENT_TYPE, PR_TRUE, PR_FALSE); + if (ok) + { + ct = MimeHeaders_get (msg->hdrs, HEADER_CONTENT_TYPE, PR_TRUE, PR_FALSE); - /* If there is no Content-Type header, but there is a MIME-Version - header, then assume that this *is* in fact a MIME message. - (I've seen messages with + /* If there is no Content-Type header, but there is a MIME-Version + header, then assume that this *is* in fact a MIME message. + (I've seen messages with - MIME-Version: 1.0 - Content-Transfer-Encoding: quoted-printable + MIME-Version: 1.0 + Content-Transfer-Encoding: quoted-printable - and no Content-Type, and we should treat those as being of type - MimeInlineTextPlain rather than MimeUntypedText.) - */ - if (mv && !ct) - ct = nsCRT::strdup(TEXT_PLAIN); - } + and no Content-Type, and we should treat those as being of type + MimeInlineTextPlain rather than MimeUntypedText.) + */ + if (mv && !ct) + ct = strdup(TEXT_PLAIN); + } - PR_FREEIF(mv); /* done with this now. */ - } + PR_FREEIF(mv); /* done with this now. */ + } /* If this message has a body which is encrypted and we're going to decrypt it (whithout converting it to HTML, since decrypt_p and @@ -420,49 +419,49 @@ MimeMessage_close_headers (MimeObject *obj) obj->options->decrypt_p = PR_FALSE; } - /* Emit the HTML for this message's headers. Do this before - creating the object representing the body. - */ - if (obj->output_p && - obj->options && - obj->options->write_html_p) - { - /* If citation headers are on, and this is not the outermost message, - turn them off. */ - if (obj->options->headers == MimeHeadersCitation && !outer_p) - obj->options->headers = MimeHeadersSome; + /* Emit the HTML for this message's headers. Do this before + creating the object representing the body. + */ + if (obj->output_p && + obj->options && + obj->options->write_html_p) + { + /* If citation headers are on, and this is not the outermost message, + turn them off. */ + if (obj->options->headers == MimeHeadersCitation && !outer_p) + obj->options->headers = MimeHeadersSome; - /* Emit a normal header block. */ - status = MimeMessage_write_headers_html(obj); - if (status < 0) return status; - } - else if (obj->output_p) - { - /* Dump the headers, raw. */ - status = MimeObject_write(obj, "", 0, PR_FALSE); /* initialize */ - if (status < 0) return status; - status = MimeHeaders_write_raw_headers(msg->hdrs, obj->options, - obj->options->decrypt_p); - if (status < 0) return status; - } + /* Emit a normal header block. */ + status = MimeMessage_write_headers_html(obj); + if (status < 0) return status; + } + else if (obj->output_p) + { + /* Dump the headers, raw. */ + status = MimeObject_write(obj, "", 0, PR_FALSE); /* initialize */ + if (status < 0) return status; + status = MimeHeaders_write_raw_headers(msg->hdrs, obj->options, + obj->options->decrypt_p); + if (status < 0) return status; + } #ifdef XP_UNIX - if (outer_p && obj->output_p) - /* Kludge from mimehdrs.c */ - MimeHeaders_do_unix_display_hook_hack(msg->hdrs); + if (outer_p && obj->output_p) + /* Kludge from mimehdrs.c */ + MimeHeaders_do_unix_display_hook_hack(msg->hdrs); #endif /* XP_UNIX */ - } + } /* Never put out a separator after a message header block. */ if (obj->options && obj->options->state) - obj->options->state->separator_suppressed_p = PR_TRUE; + obj->options->state->separator_suppressed_p = PR_TRUE; #ifdef MIME_DRAFTS if ( !obj->headers && /* outer most message header */ - obj->options && - obj->options->decompose_file_p && - ct ) - obj->options->is_multipart_msg = PL_strcasestr(ct, "multipart/") != NULL; + obj->options && + obj->options->decompose_file_p && + ct ) + obj->options->is_multipart_msg = PL_strcasestr(ct, "multipart/") != NULL; #endif /* MIME_DRAFTS */ @@ -472,11 +471,11 @@ MimeMessage_close_headers (MimeObject *obj) if (!body) return MIME_OUT_OF_MEMORY; status = ((MimeContainerClass *) obj->clazz)->add_child (obj, body); if (status < 0) - { - mime_free(body); - return status; - } - + { + mime_free(body); + return status; + } + // Only do this if this is a Text Object! if ( mime_typep(body, (MimeObjectClass *) &mimeInlineTextClass) ) { @@ -484,15 +483,15 @@ MimeMessage_close_headers (MimeObject *obj) } /* Now that we've added this new object to our list of children, - start its parser going. */ + start its parser going. */ status = body->clazz->parse_begin(body); if (status < 0) return status; // Now notify the emitter if this is the outer most message, unless - // it is a part that is not the head of the message. If it's a part, + // it is a part that is not the head of the message. If it's a part, // we need to figure out the content type/charset of the part // - PRBool outer_p = !obj->headers; /* is this the outermost message? */ + PRBool outer_p = !obj->headers; /* is this the outermost message? */ if ( outer_p && (!obj->options->part_to_load || obj->options->format_out == nsMimeOutput::nsMimeMessageBodyDisplay)) @@ -506,7 +505,7 @@ MimeMessage_close_headers (MimeObject *obj) } char *msgID = MimeHeaders_get (msg->hdrs, HEADER_MESSAGE_ID, - PR_FALSE, PR_FALSE); + PR_FALSE, PR_FALSE); const char *outCharset = NULL; if (!obj->options->force_user_charset) /* Only convert if the user prefs is false */ @@ -515,22 +514,22 @@ MimeMessage_close_headers (MimeObject *obj) mimeEmitterStartBody(obj->options, (obj->options->headers == MimeHeadersNone), msgID, outCharset); PR_FREEIF(msgID); - // setting up truncated message html fotter function - char *xmoz = MimeHeaders_get(msg->hdrs, HEADER_X_MOZILLA_STATUS, PR_FALSE, - PR_FALSE); - if (xmoz) - { - PRUint32 flags = 0; - char dummy = 0; - if (sscanf(xmoz, " %lx %c", &flags, &dummy) == 1 && - flags & MSG_FLAG_PARTIAL) - { - obj->options->html_closure = obj; - obj->options->generate_footer_html_fn = - MimeMessage_partial_message_html; - } - PR_FREEIF(xmoz); - } + // setting up truncated message html fotter function + char *xmoz = MimeHeaders_get(msg->hdrs, HEADER_X_MOZILLA_STATUS, PR_FALSE, + PR_FALSE); + if (xmoz) + { + PRUint32 flags = 0; + char dummy = 0; + if (sscanf(xmoz, " %lx %c", &flags, &dummy) == 1 && + flags & MSG_FLAG_PARTIAL) + { + obj->options->html_closure = obj; + obj->options->generate_footer_html_fn = + MimeMessage_partial_message_html; + } + PR_FREEIF(xmoz); + } } return 0; @@ -538,19 +537,19 @@ MimeMessage_close_headers (MimeObject *obj) -static int +static int MimeMessage_parse_eof (MimeObject *obj, PRBool abort_p) { int status; PRBool outer_p; MimeMessage *msg = (MimeMessage *)obj; if (obj->closed_p) return 0; - + /* Run parent method first, to flush out any buffered data. */ status = ((MimeObjectClass*)&MIME_SUPERCLASS)->parse_eof(obj, abort_p); if (status < 0) return status; - outer_p = !obj->headers; /* is this the outermost message? */ + outer_p = !obj->headers; /* is this the outermost message? */ // Hack for messages with truncated headers (bug 244722) // If there is no empty line in a message, the parser can't figure out where @@ -568,50 +567,50 @@ MimeMessage_parse_eof (MimeObject *obj, PRBool abort_p) // body of the message (i.e. not Header ONLY) if (outer_p && obj->options && obj->options->write_html_p) { - if (obj->options->generate_footer_html_fn) - { - mime_stream_data *msd = - (mime_stream_data *) obj->options->stream_closure; - if (msd) - { - char *html = obj->options->generate_footer_html_fn - (msd->orig_url_name, obj->options->html_closure, msg->hdrs); - if (html) - { - int lstatus = MimeObject_write(obj, html, - strlen(html), - PR_FALSE); - PR_Free(html); - if (lstatus < 0) return lstatus; - } - } - } - if ((!obj->options->part_to_load || obj->options->format_out == nsMimeOutput::nsMimeMessageBodyDisplay) && - obj->options->headers != MimeHeadersOnly) - mimeEmitterEndBody(obj->options); + if (obj->options->generate_footer_html_fn) + { + mime_stream_data *msd = + (mime_stream_data *) obj->options->stream_closure; + if (msd) + { + char *html = obj->options->generate_footer_html_fn + (msd->orig_url_name, obj->options->html_closure, msg->hdrs); + if (html) + { + int lstatus = MimeObject_write(obj, html, + strlen(html), + PR_FALSE); + PR_Free(html); + if (lstatus < 0) return lstatus; + } + } + } + if ((!obj->options->part_to_load || obj->options->format_out == nsMimeOutput::nsMimeMessageBodyDisplay) && + obj->options->headers != MimeHeadersOnly) + mimeEmitterEndBody(obj->options); } #ifdef MIME_DRAFTS if ( obj->options && - obj->options->decompose_file_p && - obj->options->done_parsing_outer_headers && - ! obj->options->is_multipart_msg && - ! mime_typep(obj, (MimeObjectClass*) &mimeEncryptedClass) && - obj->options->decompose_file_close_fn ) { - status = obj->options->decompose_file_close_fn ( - obj->options->stream_closure ); + obj->options->decompose_file_p && + obj->options->done_parsing_outer_headers && + ! obj->options->is_multipart_msg && + ! mime_typep(obj, (MimeObjectClass*) &mimeEncryptedClass) && + obj->options->decompose_file_close_fn ) { + status = obj->options->decompose_file_close_fn ( + obj->options->stream_closure ); - if ( status < 0 ) return status; + if ( status < 0 ) return status; } #endif /* MIME_DRAFTS */ /* Put out a separator after every message/rfc822 object. */ if (!abort_p && !outer_p) - { - status = MimeObject_write_separator(obj); - if (status < 0) return status; - } + { + status = MimeObject_write_separator(obj); + if (status < 0) return status; + } return 0; } @@ -630,18 +629,18 @@ MimeMessage_add_child (MimeObject *parent, MimeObject *child) #ifdef MIME_DRAFTS if ( parent->options && - parent->options->decompose_file_p && - ! parent->options->is_multipart_msg && - ! mime_typep(child, (MimeObjectClass*) &mimeEncryptedClass) && - parent->options->decompose_file_init_fn ) { - int status = 0; - status = parent->options->decompose_file_init_fn ( - parent->options->stream_closure, - ((MimeMessage*)parent)->hdrs ); - if ( status < 0 ) return status; + parent->options->decompose_file_p && + ! parent->options->is_multipart_msg && + ! mime_typep(child, (MimeObjectClass*) &mimeEncryptedClass) && + parent->options->decompose_file_init_fn ) { + int status = 0; + status = parent->options->decompose_file_init_fn ( + parent->options->stream_closure, + ((MimeMessage*)parent)->hdrs ); + if ( status < 0 ) return status; } #endif /* MIME_DRAFTS */ - + return ((MimeContainerClass*)&MIME_SUPERCLASS)->add_child (parent, child); } @@ -650,7 +649,7 @@ char * DetermineMailCharset(MimeMessage *msg) { char *retCharset = nsnull; - + if ( (msg) && (msg->hdrs) ) { char *ct = MimeHeaders_get (msg->hdrs, HEADER_CONTENT_TYPE, @@ -660,7 +659,7 @@ DetermineMailCharset(MimeMessage *msg) retCharset = MimeHeaders_get_parameter (ct, "charset", NULL, NULL); PR_Free(ct); } - + if (!retCharset) { // If we didn't find "Content-Type: ...; charset=XX" then look @@ -668,11 +667,11 @@ DetermineMailCharset(MimeMessage *msg) // in MimeSunAttachmentClass, but it's harder there than here.) retCharset = MimeHeaders_get (msg->hdrs, HEADER_X_SUN_CHARSET, PR_FALSE, PR_FALSE); - } + } } - + if (!retCharset) - return nsCRT::strdup("ISO-8859-1"); + return strdup("ISO-8859-1"); else return retCharset; } @@ -685,10 +684,10 @@ MimeMessage_write_headers_html (MimeObject *obj) #ifdef MOZ_SECURITY HG33391 -#endif /* MOZ_SECURITY */ +#endif /* MOZ_SECURITY */ if (!obj->options || !obj->options->output_fn) - return 0; + return 0; PR_ASSERT(obj->output_p && obj->options->write_html_p); @@ -701,7 +700,7 @@ MimeMessage_write_headers_html (MimeObject *obj) // operation ONLY WHEN THE CHARSET OF THE ORIGINAL MESSAGE IS // NOT US-ASCII ("ISO-8859-1") // - // This is only to notify the emitter of the charset of the + // This is only to notify the emitter of the charset of the // original message char *mailCharset = DetermineMailCharset(msg); @@ -713,19 +712,19 @@ MimeMessage_write_headers_html (MimeObject *obj) } if (!obj->options->state->first_data_written_p) - { - status = MimeObject_output_init (obj, TEXT_HTML); - if (status < 0) + { + status = MimeObject_output_init (obj, TEXT_HTML); + if (status < 0) { mimeEmitterEndHeader(obj->options); return status; } - PR_ASSERT(obj->options->state->first_data_written_p); - } + PR_ASSERT(obj->options->state->first_data_written_p); + } // Start the header parsing by the emitter char *msgID = MimeHeaders_get (msg->hdrs, HEADER_MESSAGE_ID, - PR_FALSE, PR_FALSE); + PR_FALSE, PR_FALSE); PRBool outer_p = !obj->headers; /* is this the outermost message? */ if (!outer_p && obj->options->format_out == nsMimeOutput::nsMimeMessageBodyDisplay && obj->options->part_to_load) @@ -744,8 +743,8 @@ MimeMessage_write_headers_html (MimeObject *obj) // reply and forward operations. // char *mailCharset = DetermineMailCharset(msg); - mimeEmitterStartHeader(obj->options, - outer_p, + mimeEmitterStartHeader(obj->options, + outer_p, (obj->options->headers == MimeHeadersOnly), msgID, mailCharset); @@ -753,11 +752,11 @@ MimeMessage_write_headers_html (MimeObject *obj) PR_FREEIF(mailCharset); #ifdef MOZ_SECURITY - HG00919 + HG00919 #endif /* MOZ_SECURITY */ status = MimeHeaders_write_all_headers (msg->hdrs, obj->options, PR_FALSE); - if (status < 0) + if (status < 0) { mimeEmitterEndHeader(obj->options); return status; @@ -767,7 +766,7 @@ MimeMessage_write_headers_html (MimeObject *obj) { #ifdef MOZ_SECURITY HG11995 -#endif /* MOZ_SECURITY */ +#endif /* MOZ_SECURITY */ } else { @@ -776,7 +775,7 @@ MimeMessage_write_headers_html (MimeObject *obj) (Otherwise, it will be run when the xlation-stamp is finally closed off, in MimeXlateed_emit_buffered_child() or MimeMultipartSigned_emit_child().) - */ + */ if (obj->options && obj->options->state && obj->options->generate_post_header_html_fn && @@ -792,13 +791,13 @@ MimeMessage_write_headers_html (MimeObject *obj) { status = MimeObject_write(obj, html, strlen(html), PR_FALSE); PR_Free(html); - if (status < 0) + if (status < 0) { mimeEmitterEndHeader(obj->options); return status; } } - } + } } mimeEmitterEndHeader(obj->options); @@ -820,14 +819,14 @@ MimeMessage_write_headers_html (MimeObject *obj) static char * MimeMessage_partial_message_html(const char *data, void *closure, - MimeHeaders *headers) + MimeHeaders *headers) { MimeMessage *msg = (MimeMessage *)closure; nsCAutoString orig_url(data); char *partialMsgHtml = nsnull; char *uidl = MimeHeaders_get(headers, HEADER_X_UIDL, PR_FALSE, PR_FALSE); char *msgId = MimeHeaders_get(headers, HEADER_MESSAGE_ID, PR_FALSE, - PR_FALSE); + PR_FALSE); char *msgIdPtr = PL_strstr(msgId, "<"); int msgBase; @@ -860,7 +859,7 @@ MimeMessage_partial_message_html(const char *data, void *closure, PR_Free(fmt2); PR_Free(fmt3); - return partialMsgHtml; + return partialMsgHtml; } #if defined(DEBUG) && defined(XP_UNIX) @@ -871,33 +870,33 @@ MimeMessage_debug_print (MimeObject *obj, PRFileDesc *stream, PRInt32 depth) char *addr = mime_part_address(obj); int i; for (i=0; i < depth; i++) - PR_Write(stream, " ", 2); + PR_Write(stream, " ", 2); /* fprintf(stream, "<%s %s%s 0x%08X>\n", - obj->clazz->class_name, - addr ? addr : "???", - (msg->container.nchildren == 0 ? " (no body)" : ""), - (PRUint32) msg); + obj->clazz->class_name, + addr ? addr : "???", + (msg->container.nchildren == 0 ? " (no body)" : ""), + (PRUint32) msg); */ PR_FREEIF(addr); #if 0 if (msg->hdrs) - { - char *s; + { + char *s; - depth++; + depth++; # define DUMP(HEADER) \ - for (i=0; i < depth; i++) \ - PR_Write(stream, " ", 2); \ - s = MimeHeaders_get (msg->hdrs, HEADER, PR_FALSE, PR_TRUE); + for (i=0; i < depth; i++) \ + PR_Write(stream, " ", 2); \ + s = MimeHeaders_get (msg->hdrs, HEADER, PR_FALSE, PR_TRUE); /** \ - PR_Write(stream, HEADER ": %s\n", s ? s : ""); \ + PR_Write(stream, HEADER ": %s\n", s ? s : ""); \ **/ - PR_FREEIF(s) + PR_FREEIF(s) DUMP(HEADER_SUBJECT); DUMP(HEADER_DATE); @@ -908,17 +907,17 @@ MimeMessage_debug_print (MimeObject *obj, PRFileDesc *stream, PRInt32 depth) DUMP(HEADER_MESSAGE_ID); # undef DUMP - PR_Write(stream, "\n", 1); - } + PR_Write(stream, "\n", 1); + } #endif PR_ASSERT(msg->container.nchildren <= 1); if (msg->container.nchildren == 1) - { - MimeObject *kid = msg->container.children[0]; - int status = kid->clazz->debug_print (kid, stream, depth+1); - if (status < 0) return status; - } + { + MimeObject *kid = msg->container.children[0]; + int status = kid->clazz->debug_print (kid, stream, depth+1); + if (status < 0) return status; + } return 0; } #endif diff --git a/mozilla/mailnews/mime/src/mimemsig.cpp b/mozilla/mailnews/mime/src/mimemsig.cpp index fd9da1aa6e0..a00b468fc64 100644 --- a/mozilla/mailnews/mime/src/mimemsig.cpp +++ b/mozilla/mailnews/mime/src/mimemsig.cpp @@ -50,14 +50,14 @@ #define MIME_SUPERCLASS mimeMultipartClass MimeDefClass(MimeMultipartSigned, MimeMultipartSignedClass, - mimeMultipartSignedClass, &MIME_SUPERCLASS); + mimeMultipartSignedClass, &MIME_SUPERCLASS); static int MimeMultipartSigned_initialize (MimeObject *); static int MimeMultipartSigned_create_child (MimeObject *); static int MimeMultipartSigned_close_child(MimeObject *); static int MimeMultipartSigned_parse_line (const char *, PRInt32, MimeObject *); static int MimeMultipartSigned_parse_child_line (MimeObject *, const char *, PRInt32, - PRBool); + PRBool); static int MimeMultipartSigned_parse_eof (MimeObject *, PRBool); static void MimeMultipartSigned_finalize (MimeObject *); @@ -100,20 +100,20 @@ MimeMultipartSigned_cleanup (MimeObject *obj, PRBool finalizing_p) MimeMultipart *mult = (MimeMultipart *) obj; /* #58075. Fix suggested by jwz */ MimeMultipartSigned *sig = (MimeMultipartSigned *) obj; if (sig->part_buffer) - { - MimePartBufferDestroy(sig->part_buffer); - sig->part_buffer = 0; - } + { + MimePartBufferDestroy(sig->part_buffer); + sig->part_buffer = 0; + } if (sig->body_hdrs) - { - MimeHeaders_free (sig->body_hdrs); - sig->body_hdrs = 0; - } + { + MimeHeaders_free (sig->body_hdrs); + sig->body_hdrs = 0; + } if (sig->sig_hdrs) - { - MimeHeaders_free (sig->sig_hdrs); - sig->sig_hdrs = 0; - } + { + MimeHeaders_free (sig->sig_hdrs); + sig->sig_hdrs = 0; + } mult->state = MimeMultipartEpilogue; /* #58075. Fix suggested by jwz */ sig->state = MimeMultipartSignedEpilogue; @@ -127,10 +127,10 @@ MimeMultipartSigned_cleanup (MimeObject *obj, PRBool finalizing_p) } if (sig->sig_decoder_data) - { - MimeDecoderDestroy(sig->sig_decoder_data, PR_TRUE); - sig->sig_decoder_data = 0; - } + { + MimeDecoderDestroy(sig->sig_decoder_data, PR_TRUE); + sig->sig_decoder_data = 0; + } } static int @@ -144,23 +144,23 @@ MimeMultipartSigned_parse_eof (MimeObject *obj, PRBool abort_p) /* Close off the signature, if we've gotten that far. */ if (sig->state == MimeMultipartSignedSignatureHeaders || - sig->state == MimeMultipartSignedSignatureFirstLine || - sig->state == MimeMultipartSignedSignatureLine || - sig->state == MimeMultipartSignedEpilogue) - { + sig->state == MimeMultipartSignedSignatureFirstLine || + sig->state == MimeMultipartSignedSignatureLine || + sig->state == MimeMultipartSignedEpilogue) + { status = (((MimeMultipartSignedClass *) obj->clazz)->crypto_signature_eof) (sig->crypto_closure, abort_p); if (status < 0) return status; - } + } if (!abort_p) - { - /* Now that we've read both the signed object and the signature (and - have presumably verified the signature) write out a blurb, and then - the signed object. - */ - status = MimeMultipartSigned_emit_child(obj); - if (status < 0) return status; - } + { + /* Now that we've read both the signed object and the signature (and + have presumably verified the signature) write out a blurb, and then + the signed object. + */ + status = MimeMultipartSigned_emit_child(obj); + if (status < 0) return status; + } MimeMultipartSigned_cleanup(obj, PR_FALSE); return ((MimeObjectClass*)&MIME_SUPERCLASS)->parse_eof(obj, abort_p); @@ -186,277 +186,277 @@ MimeMultipartSigned_parse_line (const char *line, PRInt32 length, MimeObject *ob int status = 0; /* First do the parsing for normal multipart/ objects by handing it off to - the superclass method. This includes calling the create_child and - close_child methods. + the superclass method. This includes calling the create_child and + close_child methods. */ status = (((MimeObjectClass *)(&MIME_SUPERCLASS)) - ->parse_line (line, length, obj)); + ->parse_line (line, length, obj)); if (status < 0) return status; /* The instance variable MimeMultipartClass->state tracks motion through - the various stages of multipart/ parsing. The instance variable - MimeMultipartSigned->state tracks the difference between the first - part (the body) and the second part (the signature.) This second, - more specific state variable is updated by noticing the transitions - of the first, more general state variable. + the various stages of multipart/ parsing. The instance variable + MimeMultipartSigned->state tracks the difference between the first + part (the body) and the second part (the signature.) This second, + more specific state variable is updated by noticing the transitions + of the first, more general state variable. */ if (old_state != mult->state) /* there has been a state change */ - { - switch (mult->state) - { - case MimeMultipartPreamble: - PR_ASSERT(0); /* can't move *in* to preamble state. */ - sig->state = MimeMultipartSignedPreamble; - break; + { + switch (mult->state) + { + case MimeMultipartPreamble: + PR_ASSERT(0); /* can't move *in* to preamble state. */ + sig->state = MimeMultipartSignedPreamble; + break; - case MimeMultipartHeaders: - /* If we're moving in to the Headers state, then that means - that this line is the preceeding boundary string (and we - should ignore it.) - */ - hash_line_p = PR_FALSE; + case MimeMultipartHeaders: + /* If we're moving in to the Headers state, then that means + that this line is the preceeding boundary string (and we + should ignore it.) + */ + hash_line_p = PR_FALSE; - if (sig->state == MimeMultipartSignedPreamble) - sig->state = MimeMultipartSignedBodyFirstHeader; - else if (sig->state == MimeMultipartSignedBodyFirstLine || - sig->state == MimeMultipartSignedBodyLine) - sig->state = MimeMultipartSignedSignatureHeaders; - else if (sig->state == MimeMultipartSignedSignatureFirstLine || - sig->state == MimeMultipartSignedSignatureLine) - sig->state = MimeMultipartSignedEpilogue; - break; + if (sig->state == MimeMultipartSignedPreamble) + sig->state = MimeMultipartSignedBodyFirstHeader; + else if (sig->state == MimeMultipartSignedBodyFirstLine || + sig->state == MimeMultipartSignedBodyLine) + sig->state = MimeMultipartSignedSignatureHeaders; + else if (sig->state == MimeMultipartSignedSignatureFirstLine || + sig->state == MimeMultipartSignedSignatureLine) + sig->state = MimeMultipartSignedEpilogue; + break; - case MimeMultipartPartFirstLine: - if (sig->state == MimeMultipartSignedBodyFirstHeader) - { - sig->state = MimeMultipartSignedBodyFirstLine; - no_headers_p = PR_TRUE; - } - else if (sig->state == MimeMultipartSignedBodyHeaders) - sig->state = MimeMultipartSignedBodyFirstLine; - else if (sig->state == MimeMultipartSignedSignatureHeaders) - sig->state = MimeMultipartSignedSignatureFirstLine; - else - sig->state = MimeMultipartSignedEpilogue; - break; + case MimeMultipartPartFirstLine: + if (sig->state == MimeMultipartSignedBodyFirstHeader) + { + sig->state = MimeMultipartSignedBodyFirstLine; + no_headers_p = PR_TRUE; + } + else if (sig->state == MimeMultipartSignedBodyHeaders) + sig->state = MimeMultipartSignedBodyFirstLine; + else if (sig->state == MimeMultipartSignedSignatureHeaders) + sig->state = MimeMultipartSignedSignatureFirstLine; + else + sig->state = MimeMultipartSignedEpilogue; + break; - case MimeMultipartPartLine: + case MimeMultipartPartLine: - PR_ASSERT(sig->state == MimeMultipartSignedBodyFirstLine || - sig->state == MimeMultipartSignedBodyLine || - sig->state == MimeMultipartSignedSignatureFirstLine || - sig->state == MimeMultipartSignedSignatureLine); + PR_ASSERT(sig->state == MimeMultipartSignedBodyFirstLine || + sig->state == MimeMultipartSignedBodyLine || + sig->state == MimeMultipartSignedSignatureFirstLine || + sig->state == MimeMultipartSignedSignatureLine); - if (sig->state == MimeMultipartSignedBodyFirstLine) - sig->state = MimeMultipartSignedBodyLine; - else if (sig->state == MimeMultipartSignedSignatureFirstLine) - sig->state = MimeMultipartSignedSignatureLine; - break; + if (sig->state == MimeMultipartSignedBodyFirstLine) + sig->state = MimeMultipartSignedBodyLine; + else if (sig->state == MimeMultipartSignedSignatureFirstLine) + sig->state = MimeMultipartSignedSignatureLine; + break; - case MimeMultipartEpilogue: - sig->state = MimeMultipartSignedEpilogue; - break; + case MimeMultipartEpilogue: + sig->state = MimeMultipartSignedEpilogue; + break; - default: /* bad state */ - PR_ASSERT(0); - return -1; - break; - } - } + default: /* bad state */ + PR_ASSERT(0); + return -1; + break; + } + } /* Perform multipart/signed-related actions on this line based on the state - of the parser. + of the parser. */ switch (sig->state) - { - case MimeMultipartSignedPreamble: - /* Do nothing. */ - break; + { + case MimeMultipartSignedPreamble: + /* Do nothing. */ + break; - case MimeMultipartSignedBodyFirstLine: - /* We have just moved out of the MimeMultipartSignedBodyHeaders - state, so cache away the headers that apply only to the body part. - */ - PR_ASSERT(mult->hdrs); - PR_ASSERT(!sig->body_hdrs); - sig->body_hdrs = mult->hdrs; - mult->hdrs = 0; + case MimeMultipartSignedBodyFirstLine: + /* We have just moved out of the MimeMultipartSignedBodyHeaders + state, so cache away the headers that apply only to the body part. + */ + PR_ASSERT(mult->hdrs); + PR_ASSERT(!sig->body_hdrs); + sig->body_hdrs = mult->hdrs; + mult->hdrs = 0; - /* fall through. */ + /* fall through. */ - case MimeMultipartSignedBodyFirstHeader: - case MimeMultipartSignedBodyHeaders: - case MimeMultipartSignedBodyLine: + case MimeMultipartSignedBodyFirstHeader: + case MimeMultipartSignedBodyHeaders: + case MimeMultipartSignedBodyLine: - if (!sig->crypto_closure) - { - /* Set error change */ - PR_SetError(0, 0); - /* Initialize the signature verification library. */ - sig->crypto_closure = (((MimeMultipartSignedClass *) obj->clazz) - ->crypto_init) (obj); - if (!sig->crypto_closure) - { - status = PR_GetError(); - PR_ASSERT(status < 0); - if (status >= 0) status = -1; - return status; - } - } + if (!sig->crypto_closure) + { + /* Set error change */ + PR_SetError(0, 0); + /* Initialize the signature verification library. */ + sig->crypto_closure = (((MimeMultipartSignedClass *) obj->clazz) + ->crypto_init) (obj); + if (!sig->crypto_closure) + { + status = PR_GetError(); + PR_ASSERT(status < 0); + if (status >= 0) status = -1; + return status; + } + } - if (hash_line_p) - { - /* this is the first hashed line if this is the first header - (that is, if it's the first line in the header state after - a state change.) - */ - PRBool first_line_p - = (no_headers_p || - sig->state == MimeMultipartSignedBodyFirstHeader); + if (hash_line_p) + { + /* this is the first hashed line if this is the first header + (that is, if it's the first line in the header state after + a state change.) + */ + PRBool first_line_p + = (no_headers_p || + sig->state == MimeMultipartSignedBodyFirstHeader); - if (sig->state == MimeMultipartSignedBodyFirstHeader) - sig->state = MimeMultipartSignedBodyHeaders; + if (sig->state == MimeMultipartSignedBodyFirstHeader) + sig->state = MimeMultipartSignedBodyHeaders; - /* The newline issues here are tricky, since both the newlines - before and after the boundary string are to be considered part - of the boundary: this is so that a part can be specified such - that it does not end in a trailing newline. + /* The newline issues here are tricky, since both the newlines + before and after the boundary string are to be considered part + of the boundary: this is so that a part can be specified such + that it does not end in a trailing newline. - To implement this, we send a newline *before* each line instead - of after, except for the first line, which is not preceeded by a - newline. + To implement this, we send a newline *before* each line instead + of after, except for the first line, which is not preceeded by a + newline. - For purposes of cryptographic hashing, we always hash line - breaks as CRLF -- the canonical, on-the-wire linebreaks, since - we have no idea of knowing what line breaks were used on the - originating system (SMTP rightly destroys that information.) - */ + For purposes of cryptographic hashing, we always hash line + breaks as CRLF -- the canonical, on-the-wire linebreaks, since + we have no idea of knowing what line breaks were used on the + originating system (SMTP rightly destroys that information.) + */ - /* Remove the trailing newline... */ - if (length > 0 && line[length-1] == '\n') length--; - if (length > 0 && line[length-1] == '\r') length--; + /* Remove the trailing newline... */ + if (length > 0 && line[length-1] == '\n') length--; + if (length > 0 && line[length-1] == '\r') length--; - PR_ASSERT(sig->crypto_closure); + PR_ASSERT(sig->crypto_closure); - if (!first_line_p) - { - /* Push out a preceeding newline... */ - char nl[] = CRLF; - status = (((MimeMultipartSignedClass *) obj->clazz) - ->crypto_data_hash (nl, 2, sig->crypto_closure)); - if (status < 0) return status; - } + if (!first_line_p) + { + /* Push out a preceeding newline... */ + char nl[] = CRLF; + status = (((MimeMultipartSignedClass *) obj->clazz) + ->crypto_data_hash (nl, 2, sig->crypto_closure)); + if (status < 0) return status; + } - /* Now push out the line sans trailing newline. */ - if (length > 0) - status = (((MimeMultipartSignedClass *) obj->clazz) - ->crypto_data_hash (line,length, sig->crypto_closure)); - if (status < 0) return status; - } - break; + /* Now push out the line sans trailing newline. */ + if (length > 0) + status = (((MimeMultipartSignedClass *) obj->clazz) + ->crypto_data_hash (line,length, sig->crypto_closure)); + if (status < 0) return status; + } + break; - case MimeMultipartSignedSignatureHeaders: + case MimeMultipartSignedSignatureHeaders: - if (sig->crypto_closure && - old_state != mult->state) - { - /* We have just moved out of the MimeMultipartSignedBodyLine - state, so tell the signature verification library that we've - reached the end of the signed data. - */ - status = (((MimeMultipartSignedClass *) obj->clazz) - ->crypto_data_eof) (sig->crypto_closure, PR_FALSE); - if (status < 0) return status; - } - break; + if (sig->crypto_closure && + old_state != mult->state) + { + /* We have just moved out of the MimeMultipartSignedBodyLine + state, so tell the signature verification library that we've + reached the end of the signed data. + */ + status = (((MimeMultipartSignedClass *) obj->clazz) + ->crypto_data_eof) (sig->crypto_closure, PR_FALSE); + if (status < 0) return status; + } + break; - case MimeMultipartSignedSignatureFirstLine: - /* We have just moved out of the MimeMultipartSignedSignatureHeaders - state, so cache away the headers that apply only to the sig part. - */ - PR_ASSERT(mult->hdrs); - PR_ASSERT(!sig->sig_hdrs); - sig->sig_hdrs = mult->hdrs; - mult->hdrs = 0; + case MimeMultipartSignedSignatureFirstLine: + /* We have just moved out of the MimeMultipartSignedSignatureHeaders + state, so cache away the headers that apply only to the sig part. + */ + PR_ASSERT(mult->hdrs); + PR_ASSERT(!sig->sig_hdrs); + sig->sig_hdrs = mult->hdrs; + mult->hdrs = 0; - /* If the signature block has an encoding, set up a decoder for it. - (Similar logic is in MimeLeafClass->parse_begin.) - */ - { - MimeDecoderData *(*fn) (nsresult (*) (const char*, PRInt32,void*), void*) = 0; + /* If the signature block has an encoding, set up a decoder for it. + (Similar logic is in MimeLeafClass->parse_begin.) + */ + { + MimeDecoderData *(*fn) (nsresult (*) (const char*, PRInt32,void*), void*) = 0; nsCString encoding; encoding.Adopt(MimeHeaders_get (sig->sig_hdrs, HEADER_CONTENT_TRANSFER_ENCODING, PR_TRUE, PR_FALSE)); if (encoding.IsEmpty()) ; - else if (!nsCRT::strcasecmp(encoding.get(), ENCODING_BASE64)) + else if (!PL_strcasecmp(encoding.get(), ENCODING_BASE64)) fn = &MimeB64DecoderInit; - else if (!nsCRT::strcasecmp(encoding.get(), ENCODING_QUOTED_PRINTABLE)) + else if (!PL_strcasecmp(encoding.get(), ENCODING_QUOTED_PRINTABLE)) { sig->sig_decoder_data = - MimeQPDecoderInit (((nsresult (*) (const char *, PRInt32, void *)) - (((MimeMultipartSignedClass *) obj->clazz) - ->crypto_signature_hash)), - sig->crypto_closure); + MimeQPDecoderInit (((nsresult (*) (const char *, PRInt32, void *)) + (((MimeMultipartSignedClass *) obj->clazz) + ->crypto_signature_hash)), + sig->crypto_closure); if (!sig->sig_decoder_data) - return MIME_OUT_OF_MEMORY; + return MIME_OUT_OF_MEMORY; } - else if (!nsCRT::strcasecmp(encoding.get(), ENCODING_UUENCODE) || - !nsCRT::strcasecmp(encoding.get(), ENCODING_UUENCODE2) || - !nsCRT::strcasecmp(encoding.get(), ENCODING_UUENCODE3) || - !nsCRT::strcasecmp(encoding.get(), ENCODING_UUENCODE4)) + else if (!PL_strcasecmp(encoding.get(), ENCODING_UUENCODE) || + !PL_strcasecmp(encoding.get(), ENCODING_UUENCODE2) || + !PL_strcasecmp(encoding.get(), ENCODING_UUENCODE3) || + !PL_strcasecmp(encoding.get(), ENCODING_UUENCODE4)) fn = &MimeUUDecoderInit; - else if (!nsCRT::strcasecmp(encoding.get(), ENCODING_YENCODE)) + else if (!PL_strcasecmp(encoding.get(), ENCODING_YENCODE)) fn = &MimeYDecoderInit; - if (fn) - { - sig->sig_decoder_data = - fn (((nsresult (*) (const char *, PRInt32, void *)) - (((MimeMultipartSignedClass *) obj->clazz) - ->crypto_signature_hash)), - sig->crypto_closure); - if (!sig->sig_decoder_data) - return MIME_OUT_OF_MEMORY; - } - } + if (fn) + { + sig->sig_decoder_data = + fn (((nsresult (*) (const char *, PRInt32, void *)) + (((MimeMultipartSignedClass *) obj->clazz) + ->crypto_signature_hash)), + sig->crypto_closure); + if (!sig->sig_decoder_data) + return MIME_OUT_OF_MEMORY; + } + } - /* Show these headers to the crypto module. */ - if (hash_line_p) - { - status = (((MimeMultipartSignedClass *) obj->clazz) - ->crypto_signature_init) (sig->crypto_closure, - obj, sig->sig_hdrs); - if (status < 0) return status; - } + /* Show these headers to the crypto module. */ + if (hash_line_p) + { + status = (((MimeMultipartSignedClass *) obj->clazz) + ->crypto_signature_init) (sig->crypto_closure, + obj, sig->sig_hdrs); + if (status < 0) return status; + } - /* fall through. */ + /* fall through. */ - case MimeMultipartSignedSignatureLine: - if (hash_line_p) - { - /* Feed this line into the signature verification routines. */ + case MimeMultipartSignedSignatureLine: + if (hash_line_p) + { + /* Feed this line into the signature verification routines. */ - if (sig->sig_decoder_data) - status = MimeDecoderWrite (sig->sig_decoder_data, line, length); - else - status = (((MimeMultipartSignedClass *) obj->clazz) - ->crypto_signature_hash (line, length, - sig->crypto_closure)); - if (status < 0) return status; - } - break; + if (sig->sig_decoder_data) + status = MimeDecoderWrite (sig->sig_decoder_data, line, length); + else + status = (((MimeMultipartSignedClass *) obj->clazz) + ->crypto_signature_hash (line, length, + sig->crypto_closure)); + if (status < 0) return status; + } + break; - case MimeMultipartSignedEpilogue: - /* Nothing special to do here. */ - break; + case MimeMultipartSignedEpilogue: + /* Nothing special to do here. */ + break; - default: /* bad state */ - PR_ASSERT(0); - return -1; - } + default: /* bad state */ + PR_ASSERT(0); + return -1; + } return status; } @@ -466,8 +466,8 @@ static int MimeMultipartSigned_create_child (MimeObject *parent) { /* Don't actually create a child -- we call the superclass create_child - method later, after we've fully parsed everything. (And we only call - it once, for part #1, and never for part #2 (the signature.)) + method later, after we've fully parsed everything. (And we only call + it once, for part #1, and never for part #2 (the signature.)) */ MimeMultipart *mult = (MimeMultipart *) parent; mult->state = MimeMultipartPartFirstLine; @@ -479,22 +479,22 @@ static int MimeMultipartSigned_close_child (MimeObject *obj) { /* The close_child method on MimeMultipartSigned doesn't actually do - anything to the children list, since the create_child method also - doesn't do anything. + anything to the children list, since the create_child method also + doesn't do anything. */ MimeMultipart *mult = (MimeMultipart *) obj; MimeContainer *cont = (MimeContainer *) obj; MimeMultipartSigned *msig = (MimeMultipartSigned *) obj; if (msig->part_buffer) - /* Closes the tmp file, if there is one: doesn't free the part_buffer. */ - MimePartBufferClose(msig->part_buffer); + /* Closes the tmp file, if there is one: doesn't free the part_buffer. */ + MimePartBufferClose(msig->part_buffer); - if (mult->hdrs) /* duplicated from MimeMultipart_close_child, ugh. */ - { - MimeHeaders_free(mult->hdrs); - mult->hdrs = 0; - } + if (mult->hdrs) /* duplicated from MimeMultipart_close_child, ugh. */ + { + MimeHeaders_free(mult->hdrs); + mult->hdrs = 0; + } /* Should be no kids yet. */ PR_ASSERT(cont->nchildren == 0); @@ -506,8 +506,8 @@ MimeMultipartSigned_close_child (MimeObject *obj) static int MimeMultipartSigned_parse_child_line (MimeObject *obj, - const char *line, PRInt32 length, - PRBool first_line_p) + const char *line, PRInt32 length, + PRBool first_line_p) { MimeMultipartSigned *sig = (MimeMultipartSigned *) obj; MimeContainer *cont = (MimeContainer *) obj; @@ -518,84 +518,84 @@ MimeMultipartSigned_parse_child_line (MimeObject *obj, if (cont->nchildren != 0) return -1; switch (sig->state) - { - case MimeMultipartSignedPreamble: - case MimeMultipartSignedBodyFirstHeader: - case MimeMultipartSignedBodyHeaders: - PR_ASSERT(0); /* How'd we get here? Oh well, fall through. */ + { + case MimeMultipartSignedPreamble: + case MimeMultipartSignedBodyFirstHeader: + case MimeMultipartSignedBodyHeaders: + PR_ASSERT(0); /* How'd we get here? Oh well, fall through. */ - case MimeMultipartSignedBodyFirstLine: - PR_ASSERT(first_line_p); - if (!sig->part_buffer) - { - sig->part_buffer = MimePartBufferCreate(); - if (!sig->part_buffer) - return MIME_OUT_OF_MEMORY; - } - /* fall through */ + case MimeMultipartSignedBodyFirstLine: + PR_ASSERT(first_line_p); + if (!sig->part_buffer) + { + sig->part_buffer = MimePartBufferCreate(); + if (!sig->part_buffer) + return MIME_OUT_OF_MEMORY; + } + /* fall through */ - case MimeMultipartSignedBodyLine: - { - /* This is the first part; we are buffering it, and will emit it all - at the end (so that we know whether the signature matches before - showing anything to the user.) - */ + case MimeMultipartSignedBodyLine: + { + /* This is the first part; we are buffering it, and will emit it all + at the end (so that we know whether the signature matches before + showing anything to the user.) + */ - /* The newline issues here are tricky, since both the newlines - before and after the boundary string are to be considered part - of the boundary: this is so that a part can be specified such - that it does not end in a trailing newline. + /* The newline issues here are tricky, since both the newlines + before and after the boundary string are to be considered part + of the boundary: this is so that a part can be specified such + that it does not end in a trailing newline. - To implement this, we send a newline *before* each line instead - of after, except for the first line, which is not preceeded by a - newline. - */ + To implement this, we send a newline *before* each line instead + of after, except for the first line, which is not preceeded by a + newline. + */ - /* Remove the trailing newline... */ - if (length > 0 && line[length-1] == '\n') length--; - if (length > 0 && line[length-1] == '\r') length--; + /* Remove the trailing newline... */ + if (length > 0 && line[length-1] == '\n') length--; + if (length > 0 && line[length-1] == '\r') length--; - PR_ASSERT(sig->part_buffer); - PR_ASSERT(first_line_p == - (sig->state == MimeMultipartSignedBodyFirstLine)); + PR_ASSERT(sig->part_buffer); + PR_ASSERT(first_line_p == + (sig->state == MimeMultipartSignedBodyFirstLine)); - if (!first_line_p) - { - /* Push out a preceeding newline... */ - char nl[] = MSG_LINEBREAK; - status = MimePartBufferWrite (sig->part_buffer, nl, MSG_LINEBREAK_LEN); - if (status < 0) return status; - } + if (!first_line_p) + { + /* Push out a preceeding newline... */ + char nl[] = MSG_LINEBREAK; + status = MimePartBufferWrite (sig->part_buffer, nl, MSG_LINEBREAK_LEN); + if (status < 0) return status; + } - /* Now push out the line sans trailing newline. */ - if (length > 0) - status = MimePartBufferWrite (sig->part_buffer, line, length); - if (status < 0) return status; - } - break; + /* Now push out the line sans trailing newline. */ + if (length > 0) + status = MimePartBufferWrite (sig->part_buffer, line, length); + if (status < 0) return status; + } + break; - case MimeMultipartSignedSignatureHeaders: - PR_ASSERT(0); /* How'd we get here? Oh well, fall through. */ + case MimeMultipartSignedSignatureHeaders: + PR_ASSERT(0); /* How'd we get here? Oh well, fall through. */ - case MimeMultipartSignedSignatureFirstLine: - case MimeMultipartSignedSignatureLine: - /* Nothing to do here -- hashing of the signature part is handled up - in MimeMultipartSigned_parse_line(). - */ - break; + case MimeMultipartSignedSignatureFirstLine: + case MimeMultipartSignedSignatureLine: + /* Nothing to do here -- hashing of the signature part is handled up + in MimeMultipartSigned_parse_line(). + */ + break; - case MimeMultipartSignedEpilogue: - /* Too many kids? MimeMultipartSigned_create_child() should have - prevented us from getting here. */ - PR_ASSERT(0); - return -1; - break; + case MimeMultipartSignedEpilogue: + /* Too many kids? MimeMultipartSigned_create_child() should have + prevented us from getting here. */ + PR_ASSERT(0); + return -1; + break; - default: /* bad state */ - PR_ASSERT(0); - return -1; - break; - } + default: /* bad state */ + PR_ASSERT(0); + return -1; + break; + } return status; } @@ -613,62 +613,62 @@ MimeMultipartSigned_emit_child (MimeObject *obj) NS_ASSERTION(sig->crypto_closure, "no crypto closure"); /* Emit some HTML saying whether the signature was cool. - But don't emit anything if in FO_QUOTE_MESSAGE mode. + But don't emit anything if in FO_QUOTE_MESSAGE mode. */ if (obj->options && - obj->options->headers != MimeHeadersCitation && - obj->options->write_html_p && - obj->options->output_fn && - obj->options->headers != MimeHeadersCitation && - sig->crypto_closure) - { - char *html = (((MimeMultipartSignedClass *) obj->clazz) - ->crypto_generate_html (sig->crypto_closure)); + obj->options->headers != MimeHeadersCitation && + obj->options->write_html_p && + obj->options->output_fn && + obj->options->headers != MimeHeadersCitation && + sig->crypto_closure) + { + char *html = (((MimeMultipartSignedClass *) obj->clazz) + ->crypto_generate_html (sig->crypto_closure)); #if 0 // XXX For the moment, no HTML output. Fix this XXX // - if (!html) return -1; /* MIME_OUT_OF_MEMORY? */ + if (!html) return -1; /* MIME_OUT_OF_MEMORY? */ - status = MimeObject_write(obj, html, nsCRT::strlen(html), PR_FALSE); - PR_Free(html); - if (status < 0) return status; + status = MimeObject_write(obj, html, strlen(html), PR_FALSE); + PR_Free(html); + if (status < 0) return status; #endif - /* Now that we have written out the crypto stamp, the outermost header - block is well and truly closed. If this is in fact the outermost - message, then run the post_header_html_fn now. - */ - if (obj->options && - obj->options->state && - obj->options->generate_post_header_html_fn && - !obj->options->state->post_header_html_run_p) - { - MimeHeaders *outer_headers=nsnull; - MimeObject *p; - for (p = obj; p->parent; p = p->parent) - outer_headers = p->headers; - PR_ASSERT(obj->options->state->first_data_written_p); - html = obj->options->generate_post_header_html_fn(NULL, - obj->options->html_closure, - outer_headers); - obj->options->state->post_header_html_run_p = PR_TRUE; - if (html) - { - status = MimeObject_write(obj, html, strlen(html), PR_FALSE); - PR_Free(html); - if (status < 0) return status; - } - } - } + /* Now that we have written out the crypto stamp, the outermost header + block is well and truly closed. If this is in fact the outermost + message, then run the post_header_html_fn now. + */ + if (obj->options && + obj->options->state && + obj->options->generate_post_header_html_fn && + !obj->options->state->post_header_html_run_p) + { + MimeHeaders *outer_headers=nsnull; + MimeObject *p; + for (p = obj; p->parent; p = p->parent) + outer_headers = p->headers; + PR_ASSERT(obj->options->state->first_data_written_p); + html = obj->options->generate_post_header_html_fn(NULL, + obj->options->html_closure, + outer_headers); + obj->options->state->post_header_html_run_p = PR_TRUE; + if (html) + { + status = MimeObject_write(obj, html, strlen(html), PR_FALSE); + PR_Free(html); + if (status < 0) return status; + } + } + } /* Oh, this is fairly nasty. We're skipping over our "create child" method - and using the one our superclass defines. Perhaps instead we should add - a new method on this class, and initialize that method to be the - create_child method of the superclass. Whatever. + and using the one our superclass defines. Perhaps instead we should add + a new method on this class, and initialize that method to be the + create_child method of the superclass. Whatever. */ /* The superclass method expects to find the headers for the part that it's - to create in mult->hdrs, so ensure that they're there. */ + to create in mult->hdrs, so ensure that they're there. */ PR_ASSERT(!mult->hdrs); if (mult->hdrs) MimeHeaders_free(mult->hdrs); mult->hdrs = sig->body_hdrs; @@ -690,13 +690,13 @@ MimeMultipartSigned_emit_child (MimeObject *obj) if (!disposition) { const char *content_type = firstChild->content_type; - if (!nsCRT::strcasecmp (content_type, TEXT_PLAIN) || - !nsCRT::strcasecmp (content_type, TEXT_HTML) || - !nsCRT::strcasecmp (content_type, TEXT_MDL) || - !nsCRT::strcasecmp (content_type, MULTIPART_ALTERNATIVE) || - !nsCRT::strcasecmp (content_type, MULTIPART_RELATED) || - !nsCRT::strcasecmp (content_type, MESSAGE_NEWS) || - !nsCRT::strcasecmp (content_type, MESSAGE_RFC822)) { + if (!PL_strcasecmp (content_type, TEXT_PLAIN) || + !PL_strcasecmp (content_type, TEXT_HTML) || + !PL_strcasecmp (content_type, TEXT_MDL) || + !PL_strcasecmp (content_type, MULTIPART_ALTERNATIVE) || + !PL_strcasecmp (content_type, MULTIPART_RELATED) || + !PL_strcasecmp (content_type, MESSAGE_NEWS) || + !PL_strcasecmp (content_type, MESSAGE_RFC822)) { char *ct = MimeHeaders_get(mult->hdrs, HEADER_CONTENT_TYPE, PR_FALSE, PR_FALSE); if (ct) { char *cset = MimeHeaders_get_parameter (ct, "charset", NULL, NULL); @@ -721,37 +721,37 @@ MimeMultipartSigned_emit_child (MimeObject *obj) #ifdef MIME_DRAFTS if (body->options->decompose_file_p) { - body->options->signed_p = PR_TRUE; - if (!mime_typep(body, (MimeObjectClass*)&mimeMultipartClass) && - body->options->decompose_file_init_fn) - body->options->decompose_file_init_fn ( body->options->stream_closure, body->headers ); + body->options->signed_p = PR_TRUE; + if (!mime_typep(body, (MimeObjectClass*)&mimeMultipartClass) && + body->options->decompose_file_init_fn) + body->options->decompose_file_init_fn ( body->options->stream_closure, body->headers ); } #endif /* MIME_DRAFTS */ /* If there's no part_buffer, this is a zero-length signed message? */ if (sig->part_buffer) - { + { #ifdef MIME_DRAFTS - if (body->options->decompose_file_p && - !mime_typep(body, (MimeObjectClass*)&mimeMultipartClass) && - body->options->decompose_file_output_fn) - status = MimePartBufferRead (sig->part_buffer, - /* The (nsresult (*) ...) cast is to turn the - `void' argument into `MimeObject'. */ - ((nsresult (*) (const char *, PRInt32, void *)) - body->options->decompose_file_output_fn), - body->options->stream_closure); - else + if (body->options->decompose_file_p && + !mime_typep(body, (MimeObjectClass*)&mimeMultipartClass) && + body->options->decompose_file_output_fn) + status = MimePartBufferRead (sig->part_buffer, + /* The (nsresult (*) ...) cast is to turn the + `void' argument into `MimeObject'. */ + ((nsresult (*) (const char *, PRInt32, void *)) + body->options->decompose_file_output_fn), + body->options->stream_closure); + else #endif /* MIME_DRAFTS */ - status = MimePartBufferRead (sig->part_buffer, - /* The (nsresult (*) ...) cast is to turn the - `void' argument into `MimeObject'. */ - ((nsresult (*) (const char *, PRInt32, void *)) - body->clazz->parse_buffer), - body); - if (status < 0) return status; - } + status = MimePartBufferRead (sig->part_buffer, + /* The (nsresult (*) ...) cast is to turn the + `void' argument into `MimeObject'. */ + ((nsresult (*) (const char *, PRInt32, void *)) + body->clazz->parse_buffer), + body); + if (status < 0) return status; + } MimeMultipartSigned_cleanup(obj, PR_FALSE); @@ -763,9 +763,9 @@ MimeMultipartSigned_emit_child (MimeObject *obj) #ifdef MIME_DRAFTS if (body->options->decompose_file_p && - !mime_typep(body, (MimeObjectClass*)&mimeMultipartClass) && - body->options->decompose_file_close_fn) - body->options->decompose_file_close_fn(body->options->stream_closure); + !mime_typep(body, (MimeObjectClass*)&mimeMultipartClass) && + body->options->decompose_file_close_fn) + body->options->decompose_file_close_fn(body->options->stream_closure); #endif /* MIME_DRAFTS */ /* Put out a separator after every multipart/signed object. */ diff --git a/mozilla/mailnews/mime/src/mimemult.cpp b/mozilla/mailnews/mime/src/mimemult.cpp index bd7fea1cb42..7dc18f6d44a 100644 --- a/mozilla/mailnews/mime/src/mimemult.cpp +++ b/mozilla/mailnews/mime/src/mimemult.cpp @@ -53,7 +53,7 @@ #define MIME_SUPERCLASS mimeContainerClass MimeDefClass(MimeMultipart, MimeMultipartClass, - mimeMultipartClass, &MIME_SUPERCLASS); + mimeMultipartClass, &MIME_SUPERCLASS); static int MimeMultipart_initialize (MimeObject *); static void MimeMultipart_finalize (MimeObject *); @@ -61,12 +61,12 @@ static int MimeMultipart_parse_line (const char *line, PRInt32 length, MimeObjec static int MimeMultipart_parse_eof (MimeObject *object, PRBool abort_p); static MimeMultipartBoundaryType MimeMultipart_check_boundary(MimeObject *, - const char *, - PRInt32); + const char *, + PRInt32); static int MimeMultipart_create_child(MimeObject *); static PRBool MimeMultipart_output_child_p(MimeObject *, MimeObject *); static int MimeMultipart_parse_child_line (MimeObject *, const char *, PRInt32, - PRBool); + PRBool); static int MimeMultipart_close_child(MimeObject *); extern "C" MimeObjectClass mimeMultipartAlternativeClass; @@ -116,8 +116,8 @@ MimeMultipart_initialize (MimeObject *object) ct = MimeHeaders_get (object->headers, HEADER_CONTENT_TYPE, PR_FALSE, PR_FALSE); mult->boundary = (ct - ? MimeHeaders_get_parameter (ct, HEADER_PARM_BOUNDARY, NULL, NULL) - : 0); + ? MimeHeaders_get_parameter (ct, HEADER_PARM_BOUNDARY, NULL, NULL) + : 0); PR_FREEIF(ct); mult->state = MimeMultipartPreamble; return ((MimeObjectClass*)&MIME_SUPERCLASS)->initialize(object); @@ -133,14 +133,15 @@ MimeMultipart_finalize (MimeObject *object) PR_FREEIF(mult->boundary); if (mult->hdrs) - MimeHeaders_free(mult->hdrs); + MimeHeaders_free(mult->hdrs); mult->hdrs = 0; ((MimeObjectClass*)&MIME_SUPERCLASS)->finalize(object); } int MimeWriteAString(MimeObject *obj, const nsACString &string) { - return MimeObject_write(obj, nsCString(string).get(), string.Length(), PR_TRUE); + const nsCString &flatString = PromiseFlatCString(string); + return MimeObject_write(obj, flatString.get(), flatString.Length(), PR_TRUE); } static int @@ -159,11 +160,11 @@ MimeMultipart_parse_line (const char *line, PRInt32 length, MimeObject *obj) /* If we're supposed to write this object, but aren't supposed to convert it to HTML, simply pass it through unaltered. */ if (obj->output_p && - obj->options && - !obj->options->write_html_p && - obj->options->output_fn + obj->options && + !obj->options->write_html_p && + obj->options->output_fn && obj->options->format_out != nsMimeOutput::nsMimeMessageAttach) - return MimeObject_write(obj, line, length, PR_TRUE); + return MimeObject_write(obj, line, length, PR_TRUE); if (mult->state == MimeMultipartEpilogue) /* already done */ @@ -234,8 +235,8 @@ MimeMultipart_parse_line (const char *line, PRInt32 length, MimeObject *obj) } /* Otherwise, this isn't a boundary string. So do whatever it is we - should do with this line (parse it as a header, feed it to the - child part, ignore it, etc.) */ + should do with this line (parse it as a header, feed it to the + child part, ignore it, etc.) */ switch (mult->state) { @@ -343,13 +344,13 @@ MimeMultipart_parse_line (const char *line, PRInt32 length, MimeObject *obj) PR_FALSE); if (!disposition) { - if (!nsCRT::strcasecmp (firstChild->content_type, TEXT_PLAIN) || - !nsCRT::strcasecmp (firstChild->content_type, TEXT_HTML) || - !nsCRT::strcasecmp (firstChild->content_type, TEXT_MDL) || - !nsCRT::strcasecmp (firstChild->content_type, MULTIPART_ALTERNATIVE) || - !nsCRT::strcasecmp (firstChild->content_type, MULTIPART_RELATED) || - !nsCRT::strcasecmp (firstChild->content_type, MESSAGE_NEWS) || - !nsCRT::strcasecmp (firstChild->content_type, MESSAGE_RFC822)) + if (!PL_strcasecmp (firstChild->content_type, TEXT_PLAIN) || + !PL_strcasecmp (firstChild->content_type, TEXT_HTML) || + !PL_strcasecmp (firstChild->content_type, TEXT_MDL) || + !PL_strcasecmp (firstChild->content_type, MULTIPART_ALTERNATIVE) || + !PL_strcasecmp (firstChild->content_type, MULTIPART_RELATED) || + !PL_strcasecmp (firstChild->content_type, MESSAGE_NEWS) || + !PL_strcasecmp (firstChild->content_type, MESSAGE_RFC822)) isBody = PR_TRUE; } } @@ -423,25 +424,25 @@ MimeMultipart_check_boundary(MimeObject *obj, const char *line, PRInt32 length) PRBool term_p; if (!mult->boundary || - line[0] != '-' || - line[1] != '-') - return MimeMultipartBoundaryTypeNone; + line[0] != '-' || + line[1] != '-') + return MimeMultipartBoundaryTypeNone; /* This is a candidate line to be a boundary. Check it out... */ blen = strlen(mult->boundary); term_p = PR_FALSE; /* strip trailing whitespace (including the newline.) */ - while(length > 2 && nsCRT::IsAsciiSpace(line[length-1])) - length--; + while(length > 2 && IS_SPACE(line[length-1])) + length--; /* Could this be a terminating boundary? */ if (length == blen + 4 && - line[length-1] == '-' && - line[length-2] == '-') - { - term_p = PR_TRUE; - } + line[length-1] == '-' && + line[length-2] == '-') + { + term_p = PR_TRUE; + } //looks like we have a separator but first, we need to check it's not for one of the part's children. MimeContainer *cont = (MimeContainer *) obj; @@ -477,41 +478,41 @@ MimeMultipart_create_child(MimeObject *obj) MimeMultipart *mult = (MimeMultipart *) obj; int status; char *ct = (mult->hdrs - ? MimeHeaders_get (mult->hdrs, HEADER_CONTENT_TYPE, - PR_TRUE, PR_FALSE) - : 0); + ? MimeHeaders_get (mult->hdrs, HEADER_CONTENT_TYPE, + PR_TRUE, PR_FALSE) + : 0); const char *dct = (((MimeMultipartClass *) obj->clazz)->default_part_type); MimeObject *body = NULL; mult->state = MimeMultipartPartFirstLine; /* Don't pass in NULL as the content-type (this means that the - auto-uudecode-hack won't ever be done for subparts of a - multipart, but only for untyped children of message/rfc822. + auto-uudecode-hack won't ever be done for subparts of a + multipart, but only for untyped children of message/rfc822. */ body = mime_create(((ct && *ct) ? ct : (dct ? dct: TEXT_PLAIN)), - mult->hdrs, obj->options); + mult->hdrs, obj->options); PR_FREEIF(ct); if (!body) return MIME_OUT_OF_MEMORY; status = ((MimeContainerClass *) obj->clazz)->add_child(obj, body); if (status < 0) - { - mime_free(body); - return status; - } + { + mime_free(body); + return status; + } #ifdef MIME_DRAFTS if ( obj->options && - obj->options->decompose_file_p && - obj->options->is_multipart_msg && - obj->options->decompose_file_init_fn ) - { - if ( !mime_typep(obj,(MimeObjectClass*)&mimeMultipartRelatedClass) && + obj->options->decompose_file_p && + obj->options->is_multipart_msg && + obj->options->decompose_file_init_fn ) + { + if ( !mime_typep(obj,(MimeObjectClass*)&mimeMultipartRelatedClass) && !mime_typep(obj,(MimeObjectClass*)&mimeMultipartAlternativeClass) && - !mime_typep(obj,(MimeObjectClass*)&mimeMultipartSignedClass) && + !mime_typep(obj,(MimeObjectClass*)&mimeMultipartSignedClass) && #ifdef MIME_DETAIL_CHECK - !mime_typep(body, (MimeObjectClass*)&mimeMultipartRelatedClass) && - !mime_typep(body, (MimeObjectClass*)&mimeMultipartAlternativeClass) && - !mime_typep(body,(MimeObjectClass*)&mimeMultipartSignedClass) + !mime_typep(body, (MimeObjectClass*)&mimeMultipartRelatedClass) && + !mime_typep(body, (MimeObjectClass*)&mimeMultipartAlternativeClass) && + !mime_typep(body,(MimeObjectClass*)&mimeMultipartSignedClass) #else /* bug 21869 -- due to the fact that we are not generating the correct mime class object for content-typ multipart/signed part @@ -524,37 +525,37 @@ MimeMultipart_create_child(MimeObject *obj) #endif && ! (mime_typep(body, (MimeObjectClass*)&mimeExternalObjectClass) && !strcmp(body->content_type, "text/x-vcard")) ) - { - status = obj->options->decompose_file_init_fn ( obj->options->stream_closure, mult->hdrs ); - if (status < 0) return status; - } - } + { + status = obj->options->decompose_file_init_fn ( obj->options->stream_closure, mult->hdrs ); + if (status < 0) return status; + } + } #endif /* MIME_DRAFTS */ /* Now that we've added this new object to our list of children, - start its parser going (if we want to display it.) + start its parser going (if we want to display it.) */ body->output_p = (((MimeMultipartClass *) obj->clazz)->output_child_p(obj, body)); if (body->output_p) - { - status = body->clazz->parse_begin(body); + { + status = body->clazz->parse_begin(body); #ifdef XP_MACOSX /* if we are saving an apple double attachment, we need to set correctly the conten type of the channel */ if (mime_typep(obj, (MimeObjectClass *) &mimeMultipartAppleDoubleClass)) { struct mime_stream_data *msd = (struct mime_stream_data *)body->options->stream_closure; - if (!body->options->write_html_p && body->content_type && !nsCRT::strcasecmp(body->content_type, APPLICATION_APPLEFILE)) + if (!body->options->write_html_p && body->content_type && !PL_strcasecmp(body->content_type, APPLICATION_APPLEFILE)) { - if (msd && msd->channel) - msd->channel->SetContentType(NS_LITERAL_CSTRING(APPLICATION_APPLEFILE)); + if (msd && msd->channel) + msd->channel->SetContentType(NS_LITERAL_CSTRING(APPLICATION_APPLEFILE)); } } #endif - if (status < 0) return status; - } + if (status < 0) return status; + } return 0; } @@ -564,7 +565,7 @@ static PRBool MimeMultipart_output_child_p(MimeObject *obj, MimeObject *child) { /* if we are saving an apple double attachment, ignore the appledouble wrapper part */ - return obj->options->write_html_p || nsCRT::strcasecmp(child->content_type, MULTIPART_APPLEDOUBLE); + return obj->options->write_html_p || PL_strcasecmp(child->content_type, MULTIPART_APPLEDOUBLE); } @@ -576,36 +577,36 @@ MimeMultipart_close_child(MimeObject *object) MimeContainer *cont = (MimeContainer *) object; if (!mult->hdrs) - return 0; + return 0; MimeHeaders_free(mult->hdrs); mult->hdrs = 0; NS_ASSERTION(cont->nchildren > 0, "badly formed mime message"); if (cont->nchildren > 0) - { - MimeObject *kid = cont->children[cont->nchildren-1]; - if (kid) - { - int status; - status = kid->clazz->parse_eof(kid, PR_FALSE); - if (status < 0) return status; - status = kid->clazz->parse_end(kid, PR_FALSE); - if (status < 0) return status; + { + MimeObject *kid = cont->children[cont->nchildren-1]; + if (kid) + { + int status; + status = kid->clazz->parse_eof(kid, PR_FALSE); + if (status < 0) return status; + status = kid->clazz->parse_end(kid, PR_FALSE); + if (status < 0) return status; #ifdef MIME_DRAFTS - if ( object->options && - object->options->decompose_file_p && - object->options->is_multipart_msg && - object->options->decompose_file_close_fn ) - { - if ( !mime_typep(object,(MimeObjectClass*)&mimeMultipartRelatedClass) && - !mime_typep(object,(MimeObjectClass*)&mimeMultipartAlternativeClass) && - !mime_typep(object,(MimeObjectClass*)&mimeMultipartSignedClass) && + if ( object->options && + object->options->decompose_file_p && + object->options->is_multipart_msg && + object->options->decompose_file_close_fn ) + { + if ( !mime_typep(object,(MimeObjectClass*)&mimeMultipartRelatedClass) && + !mime_typep(object,(MimeObjectClass*)&mimeMultipartAlternativeClass) && + !mime_typep(object,(MimeObjectClass*)&mimeMultipartSignedClass) && #ifdef MIME_DETAIL_CHECK - !mime_typep(kid,(MimeObjectClass*)&mimeMultipartRelatedClass) && - !mime_typep(kid,(MimeObjectClass*)&mimeMultipartAlternativeClass) && - !mime_typep(kid,(MimeObjectClass*)&mimeMultipartSignedClass) + !mime_typep(kid,(MimeObjectClass*)&mimeMultipartRelatedClass) && + !mime_typep(kid,(MimeObjectClass*)&mimeMultipartAlternativeClass) && + !mime_typep(kid,(MimeObjectClass*)&mimeMultipartSignedClass) #else /* bug 21869 -- due to the fact that we are not generating the correct mime class object for content-typ multipart/signed part @@ -618,22 +619,22 @@ MimeMultipart_close_child(MimeObject *object) #endif && !(mime_typep(kid, (MimeObjectClass*)&mimeExternalObjectClass) && !strcmp(kid->content_type, "text/x-vcard")) ) - { - status = object->options->decompose_file_close_fn ( object->options->stream_closure ); - if (status < 0) return status; - } - } + { + status = object->options->decompose_file_close_fn ( object->options->stream_closure ); + if (status < 0) return status; + } + } #endif /* MIME_DRAFTS */ - } - } + } + } return 0; } static int MimeMultipart_parse_child_line (MimeObject *obj, const char *line, PRInt32 length, - PRBool first_line_p) + PRBool first_line_p) { MimeContainer *cont = (MimeContainer *) obj; int status; @@ -641,7 +642,7 @@ MimeMultipart_parse_child_line (MimeObject *obj, const char *line, PRInt32 lengt PR_ASSERT(cont->nchildren > 0); if (cont->nchildren <= 0) - return -1; + return -1; kid = cont->children[cont->nchildren-1]; PR_ASSERT(kid); @@ -649,17 +650,17 @@ MimeMultipart_parse_child_line (MimeObject *obj, const char *line, PRInt32 lengt #ifdef MIME_DRAFTS if ( obj->options && - obj->options->decompose_file_p && - obj->options->is_multipart_msg && - obj->options->decompose_file_output_fn ) + obj->options->decompose_file_p && + obj->options->is_multipart_msg && + obj->options->decompose_file_output_fn ) { - if (!mime_typep(obj,(MimeObjectClass*)&mimeMultipartAlternativeClass) && - !mime_typep(obj,(MimeObjectClass*)&mimeMultipartRelatedClass) && - !mime_typep(obj,(MimeObjectClass*)&mimeMultipartSignedClass) && + if (!mime_typep(obj,(MimeObjectClass*)&mimeMultipartAlternativeClass) && + !mime_typep(obj,(MimeObjectClass*)&mimeMultipartRelatedClass) && + !mime_typep(obj,(MimeObjectClass*)&mimeMultipartSignedClass) && #ifdef MIME_DETAIL_CHECK - !mime_typep(kid,(MimeObjectClass*)&mimeMultipartAlternativeClass) && - !mime_typep(kid,(MimeObjectClass*)&mimeMultipartRelatedClass) && - !mime_typep(kid,(MimeObjectClass*)&mimeMultipartSignedClass) + !mime_typep(kid,(MimeObjectClass*)&mimeMultipartAlternativeClass) && + !mime_typep(kid,(MimeObjectClass*)&mimeMultipartRelatedClass) && + !mime_typep(kid,(MimeObjectClass*)&mimeMultipartSignedClass) #else /* bug 21869 -- due to the fact that we are not generating the correct mime class object for content-typ multipart/signed part @@ -672,18 +673,18 @@ MimeMultipart_parse_child_line (MimeObject *obj, const char *line, PRInt32 lengt #endif && !(mime_typep(kid, (MimeObjectClass*)&mimeExternalObjectClass) && !strcmp(kid->content_type, "text/x-vcard")) ) - return obj->options->decompose_file_output_fn (line, length, obj->options->stream_closure); + return obj->options->decompose_file_output_fn (line, length, obj->options->stream_closure); } #endif /* MIME_DRAFTS */ /* The newline issues here are tricky, since both the newlines before - and after the boundary string are to be considered part of the - boundary: this is so that a part can be specified such that it - does not end in a trailing newline. + and after the boundary string are to be considered part of the + boundary: this is so that a part can be specified such that it + does not end in a trailing newline. - To implement this, we send a newline *before* each line instead - of after, except for the first line, which is not preceeded by a - newline. + To implement this, we send a newline *before* each line instead + of after, except for the first line, which is not preceeded by a + newline. */ /* Remove the trailing newline... */ @@ -691,12 +692,12 @@ MimeMultipart_parse_child_line (MimeObject *obj, const char *line, PRInt32 lengt if (length > 0 && line[length-1] == '\r') length--; if (!first_line_p) - { - /* Push out a preceeding newline... */ - char nl[] = MSG_LINEBREAK; - status = kid->clazz->parse_buffer (nl, MSG_LINEBREAK_LEN, kid); - if (status < 0) return status; - } + { + /* Push out a preceeding newline... */ + char nl[] = MSG_LINEBREAK; + status = kid->clazz->parse_buffer (nl, MSG_LINEBREAK_LEN, kid); + if (status < 0) return status; + } /* Now push out the line sans trailing newline. */ return kid->clazz->parse_buffer (line, length, kid); @@ -712,36 +713,36 @@ MimeMultipart_parse_eof (MimeObject *obj, PRBool abort_p) if (obj->closed_p) return 0; /* Push out one last newline if part of the last line is still in the - ibuffer. If this happens, this object does not end in a trailing newline - (and the parse_line method will be called with a string with no trailing - newline, which isn't the usual case.) + ibuffer. If this happens, this object does not end in a trailing newline + (and the parse_line method will be called with a string with no trailing + newline, which isn't the usual case.) */ if (!abort_p && obj->ibuffer_fp > 0) - { - int status = obj->clazz->parse_buffer (obj->ibuffer, obj->ibuffer_fp, - obj); - obj->ibuffer_fp = 0; - if (status < 0) - { - obj->closed_p = PR_TRUE; - return status; - } - } + { + int status = obj->clazz->parse_buffer (obj->ibuffer, obj->ibuffer_fp, + obj); + obj->ibuffer_fp = 0; + if (status < 0) + { + obj->closed_p = PR_TRUE; + return status; + } + } /* Now call parse_eof for our active child, if there is one. */ if (cont->nchildren > 0 && - (mult->state == MimeMultipartPartLine || - mult->state == MimeMultipartPartFirstLine)) - { - MimeObject *kid = cont->children[cont->nchildren-1]; - PR_ASSERT(kid); - if (kid) - { - int status = kid->clazz->parse_eof(kid, abort_p); - if (status < 0) return status; - } - } + (mult->state == MimeMultipartPartLine || + mult->state == MimeMultipartPartFirstLine)) + { + MimeObject *kid = cont->children[cont->nchildren-1]; + PR_ASSERT(kid); + if (kid) + { + int status = kid->clazz->parse_eof(kid, abort_p); + if (status < 0) return status; + } + } return ((MimeObjectClass*)&MIME_SUPERCLASS)->parse_eof(obj, abort_p); } @@ -756,32 +757,32 @@ MimeMultipart_debug_print (MimeObject *obj, PRFileDesc *stream, PRInt32 depth) char *addr = mime_part_address(obj); int i; for (i=0; i < depth; i++) - PR_Write(stream, " ", 2); + PR_Write(stream, " ", 2); /** fprintf(stream, "<%s %s (%d kid%s) boundary=%s 0x%08X>\n", - obj->clazz->class_name, - addr ? addr : "???", - cont->nchildren, (cont->nchildren == 1 ? "" : "s"), - (mult->boundary ? mult->boundary : "(none)"), - (PRUint32) mult); + obj->clazz->class_name, + addr ? addr : "???", + cont->nchildren, (cont->nchildren == 1 ? "" : "s"), + (mult->boundary ? mult->boundary : "(none)"), + (PRUint32) mult); **/ PR_FREEIF(addr); /* if (cont->nchildren > 0) - fprintf(stream, "\n"); + fprintf(stream, "\n"); */ for (i = 0; i < cont->nchildren; i++) - { - MimeObject *kid = cont->children[i]; - int status = kid->clazz->debug_print (kid, stream, depth+1); - if (status < 0) return status; - } + { + MimeObject *kid = cont->children[i]; + int status = kid->clazz->debug_print (kid, stream, depth+1); + if (status < 0) return status; + } /* if (cont->nchildren > 0) - fprintf(stream, "\n"); + fprintf(stream, "\n"); */ return 0; diff --git a/mozilla/mailnews/mime/src/mimeobj.cpp b/mozilla/mailnews/mime/src/mimeobj.cpp index 4f498a8b974..abb9b0a1cf1 100644 --- a/mozilla/mailnews/mime/src/mimeobj.cpp +++ b/mozilla/mailnews/mime/src/mimeobj.cpp @@ -35,7 +35,7 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** - * This Original Code has been modified by IBM Corporation. Modifications made by IBM + * This Original Code has been modified by IBM Corporation. Modifications made by IBM * described herein are Copyright (c) International Business Machines Corporation, 2000. * Modifications to Mozilla code or documentation identified per MPL Section 3.3 * @@ -50,7 +50,6 @@ #include "mimebuf.h" #include "prlog.h" #include "nsMimeTypes.h" -#include "nsCRT.h" #include "nsMimeStringResources.h" #include "mimemsg.h" #include "mimemapl.h" @@ -70,7 +69,7 @@ static int MimeObject_parse_line (const char *, PRInt32, MimeObject *); static int MimeObject_parse_eof (MimeObject *, PRBool); static int MimeObject_parse_end (MimeObject *, PRBool); static PRBool MimeObject_displayable_inline_p (MimeObjectClass *clazz, - MimeHeaders *hdrs); + MimeHeaders *hdrs); #if defined(DEBUG) && defined(XP_UNIX) static int MimeObject_debug_print (MimeObject *, PRFileDesc *, PRInt32 depth); @@ -104,55 +103,55 @@ MimeObject_initialize (MimeObject *obj) /* Set up the content-type and encoding. */ if (!obj->content_type && obj->headers) - obj->content_type = MimeHeaders_get (obj->headers, HEADER_CONTENT_TYPE, - PR_TRUE, PR_FALSE); + obj->content_type = MimeHeaders_get (obj->headers, HEADER_CONTENT_TYPE, + PR_TRUE, PR_FALSE); if (!obj->encoding && obj->headers) - obj->encoding = MimeHeaders_get (obj->headers, - HEADER_CONTENT_TRANSFER_ENCODING, - PR_TRUE, PR_FALSE); + obj->encoding = MimeHeaders_get (obj->headers, + HEADER_CONTENT_TRANSFER_ENCODING, + PR_TRUE, PR_FALSE); /* Special case to normalize some types and encodings to a canonical form. - (These are nonstandard types/encodings which have been seen to appear in - multiple forms; we normalize them so that things like looking up icons - and extensions has consistent behavior for the receiver, regardless of - the "alias" type that the sender used.) + (These are nonstandard types/encodings which have been seen to appear in + multiple forms; we normalize them so that things like looking up icons + and extensions has consistent behavior for the receiver, regardless of + the "alias" type that the sender used.) */ if (!obj->content_type) - ; - else if (!nsCRT::strcasecmp(obj->content_type, APPLICATION_UUENCODE2) || - !nsCRT::strcasecmp(obj->content_type, APPLICATION_UUENCODE3) || - !nsCRT::strcasecmp(obj->content_type, APPLICATION_UUENCODE4)) - { - PR_Free(obj->content_type); - obj->content_type = nsCRT::strdup(APPLICATION_UUENCODE); - } - else if (!nsCRT::strcasecmp(obj->content_type, IMAGE_XBM2) || - !nsCRT::strcasecmp(obj->content_type, IMAGE_XBM3)) - { - PR_Free(obj->content_type); - obj->content_type = nsCRT::strdup(IMAGE_XBM); - } + ; + else if (!PL_strcasecmp(obj->content_type, APPLICATION_UUENCODE2) || + !PL_strcasecmp(obj->content_type, APPLICATION_UUENCODE3) || + !PL_strcasecmp(obj->content_type, APPLICATION_UUENCODE4)) + { + PR_Free(obj->content_type); + obj->content_type = strdup(APPLICATION_UUENCODE); + } + else if (!PL_strcasecmp(obj->content_type, IMAGE_XBM2) || + !PL_strcasecmp(obj->content_type, IMAGE_XBM3)) + { + PR_Free(obj->content_type); + obj->content_type = strdup(IMAGE_XBM); + } if (!obj->encoding) - ; - else if (!nsCRT::strcasecmp(obj->encoding, ENCODING_UUENCODE2) || - !nsCRT::strcasecmp(obj->encoding, ENCODING_UUENCODE3) || - !nsCRT::strcasecmp(obj->encoding, ENCODING_UUENCODE4)) - { - PR_Free(obj->encoding); - obj->encoding = nsCRT::strdup(ENCODING_UUENCODE); - } - else if (!nsCRT::strcasecmp(obj->encoding, ENCODING_COMPRESS2)) - { - PR_Free(obj->encoding); - obj->encoding = nsCRT::strdup(ENCODING_COMPRESS); - } - else if (!nsCRT::strcasecmp(obj->encoding, ENCODING_GZIP2)) - { - PR_Free(obj->encoding); - obj->encoding = nsCRT::strdup(ENCODING_GZIP); - } + ; + else if (!PL_strcasecmp(obj->encoding, ENCODING_UUENCODE2) || + !PL_strcasecmp(obj->encoding, ENCODING_UUENCODE3) || + !PL_strcasecmp(obj->encoding, ENCODING_UUENCODE4)) + { + PR_Free(obj->encoding); + obj->encoding = strdup(ENCODING_UUENCODE); + } + else if (!PL_strcasecmp(obj->encoding, ENCODING_COMPRESS2)) + { + PR_Free(obj->encoding); + obj->encoding = strdup(ENCODING_COMPRESS); + } + else if (!PL_strcasecmp(obj->encoding, ENCODING_GZIP2)) + { + PR_Free(obj->encoding); + obj->encoding = strdup(ENCODING_GZIP); + } return 0; @@ -165,10 +164,10 @@ MimeObject_finalize (MimeObject *obj) obj->clazz->parse_end (obj, PR_FALSE); if (obj->headers) - { - MimeHeaders_free(obj->headers); - obj->headers = 0; - } + { + MimeHeaders_free(obj->headers); + obj->headers = 0; + } /* Should have been freed by parse_eof, but just in case... */ NS_ASSERTION(!obj->ibuffer, "buffer not freed"); @@ -180,10 +179,10 @@ MimeObject_finalize (MimeObject *obj) PR_FREEIF(obj->encoding); if (obj->options && obj->options->state) - { - delete obj->options->state; - obj->options->state = nsnull; - } + { + delete obj->options->state; + obj->options->state = nsnull; + } } @@ -193,7 +192,7 @@ MimeObject_parse_begin (MimeObject *obj) NS_ASSERTION (!obj->closed_p, "object shouldn't be already closed"); /* If we haven't set up the state object yet, then this should be - the outermost object... */ + the outermost object... */ if (obj->options && !obj->options->state) { NS_ASSERTION(!obj->headers, "headers should be null"); /* should be the outermost object. */ @@ -209,7 +208,7 @@ MimeObject_parse_begin (MimeObject *obj) const char *delEnd = PL_strcasestr(delParts + 1, "&"); if (!delEnd) delEnd = delParts + strlen(delParts); - nsCAutoString partsToDel(Substring(delParts + 5, delEnd)); + nsCAutoString partsToDel(Substring(delParts + 5, delEnd)); obj->options->state->partsToStrip.ParseString(partsToDel.get(), ","); } if (detachLocations) @@ -224,23 +223,23 @@ MimeObject_parse_begin (MimeObject *obj) /* if we are decomposing the message in files and processing a multipart object, we must not output it without parsing it first */ || (obj->options->decompose_file_p && obj->options->decompose_file_output_fn && - mime_typep(obj, (MimeObjectClass*) &mimeMultipartClass)) + mime_typep(obj, (MimeObjectClass*) &mimeMultipartClass)) ) - obj->output_p = PR_FALSE; + obj->output_p = PR_FALSE; else if (!obj->options->part_to_load) - obj->output_p = PR_TRUE; + obj->output_p = PR_TRUE; else - { - char *id = mime_part_address(obj); - if (!id) return MIME_OUT_OF_MEMORY; + { + char *id = mime_part_address(obj); + if (!id) return MIME_OUT_OF_MEMORY; // We need to check if a part is the subpart of the part to load. // If so and this is a raw or body display output operation, then // we should mark the part for subsequent output. // - + // First, check for an exact match - obj->output_p = !strcmp(id, obj->options->part_to_load); + obj->output_p = !strcmp(id, obj->options->part_to_load); if (!obj->output_p && (obj->options->format_out == nsMimeOutput::nsMimeMessageRaw || obj->options->format_out == nsMimeOutput::nsMimeMessageBodyDisplay || obj->options->format_out == nsMimeOutput::nsMimeMessageAttach)) @@ -251,19 +250,19 @@ MimeObject_parse_begin (MimeObject *obj) !strncmp(id, obj->options->part_to_load, partlen); } - PR_Free(id); - } + PR_Free(id); + } /* Way to destroy any notions of modularity or class hierarchy, Terry! */ if (obj->options && obj->options->nice_html_only_p) { - if (!mime_subclass_p(obj->clazz, - (MimeObjectClass*) &mimeInlineTextHTMLClass) && - !mime_subclass_p(obj->clazz, - (MimeObjectClass*) &mimeInlineTextPlainClass) && - !mime_subclass_p(obj->clazz, - (MimeObjectClass*) &mimeContainerClass)) { - obj->output_p = PR_FALSE; - } + if (!mime_subclass_p(obj->clazz, + (MimeObjectClass*) &mimeInlineTextHTMLClass) && + !mime_subclass_p(obj->clazz, + (MimeObjectClass*) &mimeInlineTextPlainClass) && + !mime_subclass_p(obj->clazz, + (MimeObjectClass*) &mimeContainerClass)) { + obj->output_p = PR_FALSE; + } } return 0; @@ -276,12 +275,12 @@ MimeObject_parse_buffer (const char *buffer, PRInt32 size, MimeObject *obj) if (obj->closed_p) return -1; return mime_LineBuffer (buffer, size, - &obj->ibuffer, &obj->ibuffer_size, &obj->ibuffer_fp, - PR_TRUE, - ((int (*PR_CALLBACK) (char *, PRInt32, void *)) - /* This cast is to turn void into MimeObject */ - obj->clazz->parse_line), - obj); + &obj->ibuffer, &obj->ibuffer_size, &obj->ibuffer_fp, + PR_TRUE, + ((int (*PR_CALLBACK) (char *, PRInt32, void *)) + /* This cast is to turn void into MimeObject */ + obj->clazz->parse_line), + obj); } @@ -300,21 +299,21 @@ MimeObject_parse_eof (MimeObject *obj, PRBool abort_p) NS_ASSERTION(!obj->parsed_p, "obj already parsed"); /* If there is still data in the ibuffer, that means that the last line of - this part didn't end in a newline; so push it out anyway (this means that - the parse_line method will be called with a string with no trailing - newline, which isn't the usual case.) + this part didn't end in a newline; so push it out anyway (this means that + the parse_line method will be called with a string with no trailing + newline, which isn't the usual case.) */ if (!abort_p && - obj->ibuffer_fp > 0) - { - int status = obj->clazz->parse_line (obj->ibuffer, obj->ibuffer_fp, obj); - obj->ibuffer_fp = 0; - if (status < 0) - { - obj->closed_p = PR_TRUE; - return status; - } - } + obj->ibuffer_fp > 0) + { + int status = obj->clazz->parse_line (obj->ibuffer, obj->ibuffer_fp, obj); + obj->ibuffer_fp = 0; + if (status < 0) + { + obj->closed_p = PR_TRUE; + return status; + } + } obj->closed_p = PR_TRUE; return 0; @@ -325,10 +324,10 @@ static int MimeObject_parse_end (MimeObject *obj, PRBool abort_p) { if (obj->parsed_p) - { - NS_ASSERTION(obj->closed_p, "object should be closed"); - return 0; - } + { + NS_ASSERTION(obj->closed_p, "object should be closed"); + return 0; + } /* We won't be needing these buffers any more; nuke 'em. */ PR_FREEIF(obj->ibuffer); @@ -359,11 +358,11 @@ MimeObject_debug_print (MimeObject *obj, PRFileDesc *stream, PRInt32 depth) int i; char *addr = mime_part_address(obj); for (i=0; i < depth; i++) - PR_Write(stream, " ", 2); + PR_Write(stream, " ", 2); /* fprintf(stream, "<%s %s 0x%08X>\n", obj->clazz->class_name, - addr ? addr : "???", - (PRUint32) obj); + addr ? addr : "???", + (PRUint32) obj); */ PR_FREEIF(addr); return 0; diff --git a/mozilla/mailnews/mime/src/mimepbuf.cpp b/mozilla/mailnews/mime/src/mimepbuf.cpp index 983b6896628..110d6ede87e 100644 --- a/mozilla/mailnews/mime/src/mimepbuf.cpp +++ b/mozilla/mailnews/mime/src/mimepbuf.cpp @@ -40,7 +40,6 @@ #include "prmem.h" #include "prio.h" #include "plstr.h" -#include "nsCRT.h" #include "nsMimeStringResources.h" #include "nsNetUtil.h" // diff --git a/mozilla/mailnews/mime/src/mimesun.cpp b/mozilla/mailnews/mime/src/mimesun.cpp index 11d92be5a94..19ce5041dae 100644 --- a/mozilla/mailnews/mime/src/mimesun.cpp +++ b/mozilla/mailnews/mime/src/mimesun.cpp @@ -45,14 +45,14 @@ #define MIME_SUPERCLASS mimeMultipartClass MimeDefClass(MimeSunAttachment, MimeSunAttachmentClass, - mimeSunAttachmentClass, &MIME_SUPERCLASS); + mimeSunAttachmentClass, &MIME_SUPERCLASS); static MimeMultipartBoundaryType MimeSunAttachment_check_boundary(MimeObject *, - const char *, - PRInt32); + const char *, + PRInt32); static int MimeSunAttachment_create_child(MimeObject *); static int MimeSunAttachment_parse_child_line (MimeObject *, const char *, PRInt32, - PRBool); + PRBool); static int MimeSunAttachment_parse_begin (MimeObject *); static int MimeSunAttachment_parse_eof (MimeObject *, PRBool); @@ -92,10 +92,10 @@ MimeSunAttachment_parse_eof (MimeObject *obj, PRBool abort_p) /* Sun messages always have separators at the end. */ if (!abort_p) - { - status = MimeObject_write_separator(obj); - if (status < 0) return status; - } + { + status = MimeObject_write_separator(obj); + if (status < 0) return status; + } return 0; } @@ -103,18 +103,18 @@ MimeSunAttachment_parse_eof (MimeObject *obj, PRBool abort_p) static MimeMultipartBoundaryType MimeSunAttachment_check_boundary(MimeObject *obj, const char *line, - PRInt32 length) + PRInt32 length) { /* ten dashes */ if (line && - line[0] == '-' && line[1] == '-' && line[2] == '-' && line[3] == '-' && - line[4] == '-' && line[5] == '-' && line[6] == '-' && line[7] == '-' && - line[8] == '-' && line[9] == '-' && - (line[10] == '\r' || line[10] == '\n')) - return MimeMultipartBoundaryTypeSeparator; + line[0] == '-' && line[1] == '-' && line[2] == '-' && line[3] == '-' && + line[4] == '-' && line[5] == '-' && line[6] == '-' && line[7] == '-' && + line[8] == '-' && line[9] == '-' && + (line[10] == '\r' || line[10] == '\n')) + return MimeMultipartBoundaryTypeSeparator; else - return MimeMultipartBoundaryTypeNone; + return MimeMultipartBoundaryTypeNone; } @@ -132,104 +132,104 @@ MimeSunAttachment_create_child(MimeObject *obj) mult->state = MimeMultipartPartLine; sun_data_type = (mult->hdrs - ? MimeHeaders_get (mult->hdrs, HEADER_X_SUN_DATA_TYPE, - PR_TRUE, PR_FALSE) - : 0); + ? MimeHeaders_get (mult->hdrs, HEADER_X_SUN_DATA_TYPE, + PR_TRUE, PR_FALSE) + : 0); if (sun_data_type) - { - int i; - static const struct { const char *in, *out; } sun_types[] = { + { + int i; + static const struct { const char *in, *out; } sun_types[] = { - /* Convert recognised Sun types to the corresponding MIME types, - and convert unrecognized ones based on the file extension and - the mime.types file. + /* Convert recognised Sun types to the corresponding MIME types, + and convert unrecognized ones based on the file extension and + the mime.types file. - These are the magic types used by MailTool that I can determine. - The only actual written spec I've found only listed the first few. - The rest were found by inspection (both of real-world messages, - and by running `strings' on the MailTool binary, and on the file - /usr/openwin/lib/cetables/cetables (the "Class Engine", Sun's - equivalent to .mailcap and mime.types.) - */ - { "default", TEXT_PLAIN }, - { "default-doc", TEXT_PLAIN }, - { "text", TEXT_PLAIN }, - { "scribe", TEXT_PLAIN }, - { "sgml", TEXT_PLAIN }, - { "tex", TEXT_PLAIN }, - { "troff", TEXT_PLAIN }, - { "c-file", TEXT_PLAIN }, - { "h-file", TEXT_PLAIN }, - { "readme-file", TEXT_PLAIN }, - { "shell-script", TEXT_PLAIN }, - { "cshell-script", TEXT_PLAIN }, - { "makefile", TEXT_PLAIN }, - { "hidden-docs", TEXT_PLAIN }, - { "message", MESSAGE_RFC822 }, - { "mail-message", MESSAGE_RFC822 }, - { "mail-file", TEXT_PLAIN }, - { "gif-file", IMAGE_GIF }, - { "jpeg-file", IMAGE_JPG }, - { "ppm-file", IMAGE_PPM }, - { "pgm-file", "image/x-portable-graymap" }, - { "pbm-file", "image/x-portable-bitmap" }, - { "xpm-file", "image/x-xpixmap" }, - { "ilbm-file", "image/ilbm" }, - { "tiff-file", "image/tiff" }, - { "photocd-file", "image/x-photo-cd" }, - { "sun-raster", "image/x-sun-raster" }, - { "audio-file", AUDIO_BASIC }, - { "postscript", APPLICATION_POSTSCRIPT }, - { "postscript-file", APPLICATION_POSTSCRIPT }, - { "framemaker-document", "application/x-framemaker" }, - { "sundraw-document", "application/x-sun-draw" }, - { "sunpaint-document", "application/x-sun-paint" }, - { "sunwrite-document", "application/x-sun-write" }, - { "islanddraw-document", "application/x-island-draw" }, - { "islandpaint-document", "application/x-island-paint" }, - { "islandwrite-document", "application/x-island-write" }, - { "sun-executable", APPLICATION_OCTET_STREAM }, - { "default-app", APPLICATION_OCTET_STREAM }, - { 0, 0 }}; - for (i = 0; sun_types[i].in; i++) - if (!nsCRT::strcasecmp(sun_data_type, sun_types[i].in)) - { - mime_ct = sun_types[i].out; - break; - } - } + These are the magic types used by MailTool that I can determine. + The only actual written spec I've found only listed the first few. + The rest were found by inspection (both of real-world messages, + and by running `strings' on the MailTool binary, and on the file + /usr/openwin/lib/cetables/cetables (the "Class Engine", Sun's + equivalent to .mailcap and mime.types.) + */ + { "default", TEXT_PLAIN }, + { "default-doc", TEXT_PLAIN }, + { "text", TEXT_PLAIN }, + { "scribe", TEXT_PLAIN }, + { "sgml", TEXT_PLAIN }, + { "tex", TEXT_PLAIN }, + { "troff", TEXT_PLAIN }, + { "c-file", TEXT_PLAIN }, + { "h-file", TEXT_PLAIN }, + { "readme-file", TEXT_PLAIN }, + { "shell-script", TEXT_PLAIN }, + { "cshell-script", TEXT_PLAIN }, + { "makefile", TEXT_PLAIN }, + { "hidden-docs", TEXT_PLAIN }, + { "message", MESSAGE_RFC822 }, + { "mail-message", MESSAGE_RFC822 }, + { "mail-file", TEXT_PLAIN }, + { "gif-file", IMAGE_GIF }, + { "jpeg-file", IMAGE_JPG }, + { "ppm-file", IMAGE_PPM }, + { "pgm-file", "image/x-portable-graymap" }, + { "pbm-file", "image/x-portable-bitmap" }, + { "xpm-file", "image/x-xpixmap" }, + { "ilbm-file", "image/ilbm" }, + { "tiff-file", "image/tiff" }, + { "photocd-file", "image/x-photo-cd" }, + { "sun-raster", "image/x-sun-raster" }, + { "audio-file", AUDIO_BASIC }, + { "postscript", APPLICATION_POSTSCRIPT }, + { "postscript-file", APPLICATION_POSTSCRIPT }, + { "framemaker-document", "application/x-framemaker" }, + { "sundraw-document", "application/x-sun-draw" }, + { "sunpaint-document", "application/x-sun-paint" }, + { "sunwrite-document", "application/x-sun-write" }, + { "islanddraw-document", "application/x-island-draw" }, + { "islandpaint-document", "application/x-island-paint" }, + { "islandwrite-document", "application/x-island-write" }, + { "sun-executable", APPLICATION_OCTET_STREAM }, + { "default-app", APPLICATION_OCTET_STREAM }, + { 0, 0 }}; + for (i = 0; sun_types[i].in; i++) + if (!PL_strcasecmp(sun_data_type, sun_types[i].in)) + { + mime_ct = sun_types[i].out; + break; + } + } /* If we didn't find a type, look at the extension on the file name. */ if (!mime_ct && - obj->options && - obj->options->file_type_fn) - { - char *name = MimeHeaders_get_name(mult->hdrs, obj->options); - if (name) - { - mime_ct2 = obj->options->file_type_fn(name, - obj->options->stream_closure); - mime_ct = mime_ct2; - PR_Free(name); - if (!mime_ct2 || !nsCRT::strcasecmp (mime_ct2, UNKNOWN_CONTENT_TYPE)) - { - PR_FREEIF(mime_ct2); - mime_ct = APPLICATION_OCTET_STREAM; - } - } - } + obj->options && + obj->options->file_type_fn) + { + char *name = MimeHeaders_get_name(mult->hdrs, obj->options); + if (name) + { + mime_ct2 = obj->options->file_type_fn(name, + obj->options->stream_closure); + mime_ct = mime_ct2; + PR_Free(name); + if (!mime_ct2 || !PL_strcasecmp (mime_ct2, UNKNOWN_CONTENT_TYPE)) + { + PR_FREEIF(mime_ct2); + mime_ct = APPLICATION_OCTET_STREAM; + } + } + } if (!mime_ct) - mime_ct = APPLICATION_OCTET_STREAM; + mime_ct = APPLICATION_OCTET_STREAM; PR_FREEIF(sun_data_type); /* Convert recognised Sun encodings to the corresponding MIME encodings. - However, if the X-Sun-Encoding-Info field contains more than one - encoding (that is, contains a comma) then assign it the encoding of - the *rightmost* element in the list; and change its Content-Type to - application/octet-stream. Examples: + However, if the X-Sun-Encoding-Info field contains more than one + encoding (that is, contains a comma) then assign it the encoding of + the *rightmost* element in the list; and change its Content-Type to + application/octet-stream. Examples: Sun Type: Translates To: ================== ==================== @@ -244,102 +244,102 @@ MimeSunAttachment_create_child(MimeObject *obj) */ sun_data_type = (mult->hdrs - ? MimeHeaders_get (mult->hdrs, HEADER_X_SUN_ENCODING_INFO, - PR_FALSE,PR_FALSE) - : 0); + ? MimeHeaders_get (mult->hdrs, HEADER_X_SUN_ENCODING_INFO, + PR_FALSE,PR_FALSE) + : 0); sun_enc_info = sun_data_type; /* this "adpcm-compress" pseudo-encoding is some random junk that - MailTool adds to the encoding description of .AU files: we can - ignore it if it is the leftmost element of the encoding field. - (It looks like it's created via `audioconvert -f g721'. Why? - Who knows.) + MailTool adds to the encoding description of .AU files: we can + ignore it if it is the leftmost element of the encoding field. + (It looks like it's created via `audioconvert -f g721'. Why? + Who knows.) */ - if (sun_enc_info && !nsCRT::strncasecmp (sun_enc_info, "adpcm-compress", 14)) - { - sun_enc_info += 14; - while (nsCRT::IsAsciiSpace(*sun_enc_info) || *sun_enc_info == ',') - sun_enc_info++; - } + if (sun_enc_info && !PL_strncasecmp (sun_enc_info, "adpcm-compress", 14)) + { + sun_enc_info += 14; + while (IS_SPACE(*sun_enc_info) || *sun_enc_info == ',') + sun_enc_info++; + } /* Extract the last element of the encoding field, changing the content - type if necessary (as described above.) + type if necessary (as described above.) */ if (sun_enc_info && *sun_enc_info) - { - const char *prev; - const char *end = PL_strrchr(sun_enc_info, ','); - if (end) - { - const char *start = sun_enc_info; - sun_enc_info = end + 1; - while (nsCRT::IsAsciiSpace(*sun_enc_info)) - sun_enc_info++; - for (prev = end-1; prev > start && *prev != ','; prev--) - ; - if (*prev == ',') prev++; + { + const char *prev; + const char *end = PL_strrchr(sun_enc_info, ','); + if (end) + { + const char *start = sun_enc_info; + sun_enc_info = end + 1; + while (IS_SPACE(*sun_enc_info)) + sun_enc_info++; + for (prev = end-1; prev > start && *prev != ','; prev--) + ; + if (*prev == ',') prev++; - if (!nsCRT::strncasecmp (prev, "uuencode", end-prev)) - mime_ct = APPLICATION_UUENCODE; - else if (!nsCRT::strncasecmp (prev, "gzip", end-prev)) - mime_ct = APPLICATION_GZIP; - else if (!nsCRT::strncasecmp (prev, "compress", end-prev)) - mime_ct = APPLICATION_COMPRESS; - else if (!nsCRT::strncasecmp (prev, "default-compress", end-prev)) - mime_ct = APPLICATION_COMPRESS; - else - mime_ct = APPLICATION_OCTET_STREAM; - } - } + if (!PL_strncasecmp (prev, "uuencode", end-prev)) + mime_ct = APPLICATION_UUENCODE; + else if (!PL_strncasecmp (prev, "gzip", end-prev)) + mime_ct = APPLICATION_GZIP; + else if (!PL_strncasecmp (prev, "compress", end-prev)) + mime_ct = APPLICATION_COMPRESS; + else if (!PL_strncasecmp (prev, "default-compress", end-prev)) + mime_ct = APPLICATION_COMPRESS; + else + mime_ct = APPLICATION_OCTET_STREAM; + } + } /* Convert the remaining Sun encoding to a MIME encoding. - If it isn't known, change the content-type instead. + If it isn't known, change the content-type instead. */ if (!sun_enc_info || !*sun_enc_info) - ; - else if (!nsCRT::strcasecmp(sun_enc_info,"compress")) mime_cte = ENCODING_COMPRESS; - else if (!nsCRT::strcasecmp(sun_enc_info,"uuencode")) mime_cte = ENCODING_UUENCODE; - else if (!nsCRT::strcasecmp(sun_enc_info,"gzip")) mime_cte = ENCODING_GZIP; - else mime_ct = APPLICATION_OCTET_STREAM; + ; + else if (!PL_strcasecmp(sun_enc_info,"compress")) mime_cte = ENCODING_COMPRESS; + else if (!PL_strcasecmp(sun_enc_info,"uuencode")) mime_cte = ENCODING_UUENCODE; + else if (!PL_strcasecmp(sun_enc_info,"gzip")) mime_cte = ENCODING_GZIP; + else mime_ct = APPLICATION_OCTET_STREAM; PR_FREEIF(sun_data_type); /* Now that we know its type and encoding, create a MimeObject to represent - this part. + this part. */ child = mime_create(mime_ct, mult->hdrs, obj->options); if (!child) - { - status = MIME_OUT_OF_MEMORY; - goto FAIL; - } + { + status = MIME_OUT_OF_MEMORY; + goto FAIL; + } /* Fake out the child's content-type and encoding (it probably doesn't have - one right now, because the X-Sun- headers aren't generally recognised by - the rest of this library.) + one right now, because the X-Sun- headers aren't generally recognised by + the rest of this library.) */ PR_FREEIF(child->content_type); PR_FREEIF(child->encoding); PR_ASSERT(mime_ct); - child->content_type = (mime_ct ? nsCRT::strdup(mime_ct) : 0); - child->encoding = (mime_cte ? nsCRT::strdup(mime_cte) : 0); + child->content_type = (mime_ct ? strdup(mime_ct) : 0); + child->encoding = (mime_cte ? strdup(mime_cte) : 0); status = ((MimeContainerClass *) obj->clazz)->add_child(obj, child); if (status < 0) - { - mime_free(child); - child = 0; - goto FAIL; - } + { + mime_free(child); + child = 0; + goto FAIL; + } /* Sun attachments always have separators between parts. */ status = MimeObject_write_separator(obj); if (status < 0) goto FAIL; /* And now that we've added this new object to our list of - children, start its parser going. */ + children, start its parser going. */ status = child->clazz->parse_begin(child); if (status < 0) goto FAIL; @@ -352,18 +352,18 @@ MimeSunAttachment_create_child(MimeObject *obj) static int MimeSunAttachment_parse_child_line (MimeObject *obj, const char *line, PRInt32 length, - PRBool first_line_p) + PRBool first_line_p) { MimeContainer *cont = (MimeContainer *) obj; MimeObject *kid; /* This is simpler than MimeMultipart->parse_child_line in that it doesn't - play games about body parts without trailing newlines. + play games about body parts without trailing newlines. */ PR_ASSERT(cont->nchildren > 0); if (cont->nchildren <= 0) - return -1; + return -1; kid = cont->children[cont->nchildren-1]; PR_ASSERT(kid); diff --git a/mozilla/mailnews/mime/src/mimetext.cpp b/mozilla/mailnews/mime/src/mimetext.cpp index bf9fa51c86e..083bf957f24 100644 --- a/mozilla/mailnews/mime/src/mimetext.cpp +++ b/mozilla/mailnews/mime/src/mimetext.cpp @@ -51,7 +51,6 @@ #include "prlog.h" #include "prmem.h" #include "plstr.h" -#include "nsCRT.h" #include "nsIPrefService.h" #include "nsIPrefBranch.h" #include "nsIServiceManager.h" @@ -62,7 +61,7 @@ #define MIME_SUPERCLASS mimeLeafClass MimeDefClass(MimeInlineText, MimeInlineTextClass, mimeInlineTextClass, - &MIME_SUPERCLASS); + &MIME_SUPERCLASS); static int MimeInlineText_initialize (MimeObject *); static void MimeInlineText_finalize (MimeObject *); @@ -115,7 +114,7 @@ static int MimeInlineText_initializeCharset(MimeObject *obj) { if (obj->options && obj->options->override_charset) { - text->charset = nsCRT::strdup(obj->options->default_charset); + text->charset = strdup(obj->options->default_charset); } else { @@ -155,7 +154,7 @@ static int MimeInlineText_initializeCharset(MimeObject *obj) } if (obj->options && obj->options->default_charset) - text->charset = nsCRT::strdup(obj->options->default_charset); + text->charset = strdup(obj->options->default_charset); else { if (NS_SUCCEEDED(res)) @@ -165,7 +164,7 @@ static int MimeInlineText_initializeCharset(MimeObject *obj) text->charset = ToNewUTF8String(value); } else - text->charset = nsCRT::strdup(""); + text->charset = strdup(""); } } } @@ -269,10 +268,10 @@ MimeInlineText_parse_end (MimeObject *obj, PRBool abort_p) MimeInlineText *text = (MimeInlineText *) obj; if (obj->parsed_p) - { - PR_ASSERT(obj->closed_p); - return 0; - } + { + PR_ASSERT(obj->closed_p); + return 0; + } /* We won't be needing this buffer any more; nuke it. */ PR_FREEIF(text->cbuffer); @@ -312,10 +311,10 @@ MimeInlineText_rot13_line (MimeObject *obj, char *line, PRInt32 length) s = (unsigned char *) line; end = s + length; while (s < end) - { - *s = MimeInlineText_rot13_table[*s]; - s++; - } + { + *s = MimeInlineText_rot13_table[*s]; + s++; + } return 0; } @@ -331,28 +330,28 @@ MimeInlineText_parse_decoded_buffer (const char *buf, PRInt32 size, MimeObject * if (!obj->options) return -1; /* If we're supposed to write this object, but aren't supposed to convert - it to HTML, simply pass it through unaltered. */ + it to HTML, simply pass it through unaltered. */ if (!obj->options->write_html_p && obj->options->format_out != nsMimeOutput::nsMimeMessageAttach) - return MimeObject_write(obj, buf, size, PR_TRUE); + return MimeObject_write(obj, buf, size, PR_TRUE); /* This is just like the parse_decoded_buffer method we inherit from the - MimeLeaf class, except that we line-buffer to our own wrapper on the - `parse_line' method instead of calling the `parse_line' method directly. + MimeLeaf class, except that we line-buffer to our own wrapper on the + `parse_line' method instead of calling the `parse_line' method directly. */ return mime_LineBuffer (buf, size, - &obj->ibuffer, &obj->ibuffer_size, &obj->ibuffer_fp, - PR_TRUE, - ((int (*PR_CALLBACK) (char *, PRInt32, void *)) - /* This cast is to turn void into MimeObject */ - MimeInlineText_rotate_convert_and_parse_line), - obj); + &obj->ibuffer, &obj->ibuffer_size, &obj->ibuffer_fp, + PR_TRUE, + ((int (*PR_CALLBACK) (char *, PRInt32, void *)) + /* This cast is to turn void into MimeObject */ + MimeInlineText_rotate_convert_and_parse_line), + obj); } #define MimeInlineText_grow_cbuffer(text, desired_size) \ (((desired_size) >= (text)->cbuffer_size) ? \ mime_GrowBuffer ((desired_size), sizeof(char), 100, \ - &(text)->cbuffer, &(text)->cbuffer_size) \ + &(text)->cbuffer, &(text)->cbuffer_size) \ : 0) static int @@ -371,13 +370,13 @@ MimeInlineText_convert_and_parse_line(char *line, PRInt32 length, MimeObject *ob MimeInlineTextHTML *textHTML = (MimeInlineTextHTML *) obj; if (textHTML->charset && *textHTML->charset && - nsCRT::strcmp(textHTML->charset, text->charset)) + strcmp(textHTML->charset, text->charset)) { //if meta tag specified charset is different from our detected result, use meta charset. //but we don't want to redo previous lines MIME_get_unicode_decoder(textHTML->charset, getter_AddRefs(text->inputDecoder)); PR_FREEIF(text->charset); - text->charset = nsCRT::strdup(textHTML->charset); + text->charset = strdup(textHTML->charset); //update MsgWindow charset if we are instructed to do so if (text->needUpdateMsgWinCharset && *text->charset) @@ -396,22 +395,22 @@ MimeInlineText_convert_and_parse_line(char *line, PRInt32 length, MimeObject *ob if (text->utf8Encoder == nsnull) MIME_get_unicode_encoder("UTF-8", getter_AddRefs(text->utf8Encoder)); - PRBool useInputCharsetConverter = obj->options->m_inputCharsetToUnicodeDecoder && !nsCRT::strcasecmp(text->charset, obj->options->charsetForCachedInputDecoder.get()); + PRBool useInputCharsetConverter = obj->options->m_inputCharsetToUnicodeDecoder && !PL_strcasecmp(text->charset, obj->options->charsetForCachedInputDecoder.get()); if (useInputCharsetConverter) status = obj->options->charset_conversion_fn(line, length, text->charset, - "UTF-8", - &converted, - &converted_len, + "UTF-8", + &converted, + &converted_len, obj->options->stream_closure, obj->options->m_inputCharsetToUnicodeDecoder, obj->options->m_unicodeToUTF8Encoder); else status = obj->options->charset_conversion_fn(line, length, text->charset, - "UTF-8", - &converted, - &converted_len, + "UTF-8", + &converted, + &converted_len, obj->options->stream_closure, (nsIUnicodeDecoder*)text->inputDecoder, (nsIUnicodeEncoder*)text->utf8Encoder); @@ -428,7 +427,7 @@ MimeInlineText_convert_and_parse_line(char *line, PRInt32 length, MimeObject *ob } /* Now that the line has been converted, call the subclass's parse_line - method with the decoded data. */ + method with the decoded data. */ status = obj->clazz->parse_line(line, length, obj); PR_FREEIF(converted); @@ -459,7 +458,7 @@ MimeInlineText_open_dam(char *line, PRInt32 length, MimeObject *obj) //set the charset for this obj if (NS_SUCCEEDED(res) && detectedCharset && *detectedCharset) { PR_FREEIF(text->charset); - text->charset = nsCRT::strdup(detectedCharset); + text->charset = strdup(detectedCharset); //update MsgWindow charset if we are instructed to do so if (text->needUpdateMsgWinCharset && *text->charset) @@ -496,7 +495,7 @@ MimeInlineText_open_dam(char *line, PRInt32 length, MimeObject *obj) static int MimeInlineText_rotate_convert_and_parse_line(char *line, PRInt32 length, - MimeObject *obj) + MimeObject *obj) { int status = 0; MimeInlineTextClass *textc = (MimeInlineTextClass *) obj->clazz; @@ -505,12 +504,12 @@ MimeInlineText_rotate_convert_and_parse_line(char *line, PRInt32 length, if (obj->closed_p) return -1; /* Rotate the line, if desired (this happens on the raw data, before any - charset conversion.) */ + charset conversion.) */ if (obj->options && obj->options->rot13_p) - { - status = textc->rot13_line(obj, line, length); - if (status < 0) return status; - } + { + status = textc->rot13_line(obj, line, length); + if (status < 0) return status; + } // Now convert to the canonical charset, if desired. // @@ -526,7 +525,7 @@ MimeInlineText_rotate_convert_and_parse_line(char *line, PRInt32 length, (!obj->options->force_user_charset) && (doConvert) ) - { + { MimeInlineText *text = (MimeInlineText *) obj; if (!text->initializeCharset) @@ -558,7 +557,7 @@ MimeInlineText_rotate_convert_and_parse_line(char *line, PRInt32 length, } else status = MimeInlineText_convert_and_parse_line(line, length, obj); - } + } else status = obj->clazz->parse_line(line, length, obj); diff --git a/mozilla/mailnews/mime/src/mimethtm.cpp b/mozilla/mailnews/mime/src/mimethtm.cpp index f6cea1d2f58..62f9ef418d0 100644 --- a/mozilla/mailnews/mime/src/mimethtm.cpp +++ b/mozilla/mailnews/mime/src/mimethtm.cpp @@ -134,7 +134,7 @@ MimeInlineTextHTML_parse_begin (MimeObject *obj) for (in = base_hdr; *in; in++) /* ignore whitespace and quotes */ - if (!nsCRT::IsAsciiSpace(*in) && *in != '"') + if (!IS_SPACE(*in) && *in != '"') *out++ = *in; /* Close the tag and argument. */ @@ -193,8 +193,8 @@ MimeInlineTextHTML_parse_line (const char *line, PRInt32 length, MimeObject *obj // 6 == strlen("UTF-16") or strlen("UTF-32"), this will cover // UTF-16, UTF-16BE, UTF-16LE, UTF-32, UTF-32BE, UTF-32LE if ((charset != nsnull) && - nsCRT::strncasecmp(charset, "UTF-16", 6) && - nsCRT::strncasecmp(charset, "UTF-32", 6)) + PL_strncasecmp(charset, "UTF-16", 6) && + PL_strncasecmp(charset, "UTF-32", 6)) { textHTML->charset = charset; diff --git a/mozilla/mailnews/mime/src/mimetpfl.cpp b/mozilla/mailnews/mime/src/mimetpfl.cpp index e3e85156a14..03dcc828927 100644 --- a/mozilla/mailnews/mime/src/mimetpfl.cpp +++ b/mozilla/mailnews/mime/src/mimetpfl.cpp @@ -135,7 +135,7 @@ MimeInlineTextPlainFlowed_parse_begin (MimeObject *obj) (content_type_row ? MimeHeaders_get_parameter(content_type_row, "delsp", NULL,NULL) : 0); - ((MimeInlineTextPlainFlowed *)obj)->delSp = content_type_delsp && !nsCRT::strcasecmp(content_type_delsp, "yes"); + ((MimeInlineTextPlainFlowed *)obj)->delSp = content_type_delsp && !PL_strcasecmp(content_type_delsp, "yes"); PR_Free(content_type_delsp); PR_Free(content_type_row); @@ -343,7 +343,7 @@ MimeInlineTextPlainFlowed_parse_line (const char *aLine, PRInt32 length, MimeObj (quote marks and) a space count as empty */ { flowed = PR_TRUE; - sigSeparator = (index - (linep - line) + 1 == 3) && !nsCRT::strncmp(linep, "-- ", 3); + sigSeparator = (index - (linep - line) + 1 == 3) && !strncmp(linep, "-- ", 3); if (((MimeInlineTextPlainFlowed *) obj)->delSp && ! sigSeparator) /* If line is flowed and DelSp=yes, logically delete trailing space. Line consisting of @@ -396,7 +396,7 @@ MimeInlineTextPlainFlowed_parse_line (const char *aLine, PRInt32 length, MimeObj ((MimeInlineTextClass*)&mimeInlineTextClass)->initialize_charset(obj); mailCharset = inlinetext->charset; if (mailCharset && *mailCharset) { - rv = nsMsgI18NConvertToUnicode(mailCharset, nsDependentCString(inputStr), lineSource); + rv = nsMsgI18NConvertToUnicode(mailCharset, PromiseFlatCString(inputStr), lineSource); NS_ENSURE_SUCCESS(rv, -1); } else // this probably never happens... diff --git a/mozilla/mailnews/mime/src/mimetric.cpp b/mozilla/mailnews/mime/src/mimetric.cpp index f66ed581283..50bd07701fd 100644 --- a/mozilla/mailnews/mime/src/mimetric.cpp +++ b/mozilla/mailnews/mime/src/mimetric.cpp @@ -38,13 +38,12 @@ #include "mimebuf.h" #include "prmem.h" #include "plstr.h" -#include "nsCRT.h" #include "prlog.h" #include "msgCore.h" #define MIME_SUPERCLASS mimeInlineTextClass MimeDefClass(MimeInlineTextRichtext, MimeInlineTextRichtextClass, - mimeInlineTextRichtextClass, &MIME_SUPERCLASS); + mimeInlineTextRichtextClass, &MIME_SUPERCLASS); static int MimeInlineTextRichtext_parse_line (const char *, PRInt32, MimeObject *); static int MimeInlineTextRichtext_parse_begin (MimeObject *); @@ -66,34 +65,34 @@ MimeInlineTextRichtextClassInitialize(MimeInlineTextRichtextClass *clazz) */ int MimeRichtextConvert (const char *line, PRInt32 length, - int (*output_fn) (const char *buf, PRInt32 size, void *closure), - void *closure, - char **obufferP, - PRInt32 *obuffer_sizeP, - PRBool enriched_p) + int (*output_fn) (const char *buf, PRInt32 size, void *closure), + void *closure, + char **obufferP, + PRInt32 *obuffer_sizeP, + PRBool enriched_p) { /* RFC 1341 (the original MIME spec) defined text/richtext. - RFC 1563 superceded text/richtext with text/enriched. - The changes from text/richtext to text/enriched are: - - CRLF semantics are different - - << maps to < - - These tags were added: - , , , - - These tags were removed: - , , , , , + RFC 1563 superceded text/richtext with text/enriched. + The changes from text/richtext to text/enriched are: + - CRLF semantics are different + - << maps to < + - These tags were added: + , , , + - These tags were removed: + , , , , , , , , , , - , , - This method implements them both. + , , + This method implements them both. - draft-resnick-text-enriched-03.txt is a proposed update to 1563. - - These tags were added: - , , , . - However, all of these rely on the magic tag, which we - don't implement, so we're ignoring all of these. - Interesting fact: it's by Peter W. Resnick from Qualcomm (Eudora). - And it also says "It is fully expected that other text formatting - standards like HTML and SGML will supplant text/enriched in - Internet mail." + draft-resnick-text-enriched-03.txt is a proposed update to 1563. + - These tags were added: + , , , . + However, all of these rely on the magic tag, which we + don't implement, so we're ignoring all of these. + Interesting fact: it's by Peter W. Resnick from Qualcomm (Eudora). + And it also says "It is fully expected that other text formatting + standards like HTML and SGML will supplant text/enriched in + Internet mail." */ int status = 0; char *out; @@ -111,20 +110,20 @@ MimeRichtextConvert (const char *line, PRInt32 length, desired_size = (length * BGROWTH) + 1; #undef BGROWTH if (desired_size >= (PRUint32) *obuffer_sizeP) - status = mime_GrowBuffer (desired_size, sizeof(char), 1024, - obufferP, obuffer_sizeP); + status = mime_GrowBuffer (desired_size, sizeof(char), 1024, + obufferP, obuffer_sizeP); if (status < 0) return status; if (enriched_p) - { - for (this_start = line; this_start < line + length; this_start++) - if (!nsCRT::IsAsciiSpace (*this_start)) break; - if (this_start >= line + length) /* blank line */ - { - PL_strcpy (*obufferP, "
"); - return output_fn (*obufferP, strlen(*obufferP), closure); - } - } + { + for (this_start = line; this_start < line + length; this_start++) + if (!IS_SPACE (*this_start)) break; + if (this_start >= line + length) /* blank line */ + { + PL_strcpy (*obufferP, "
"); + return output_fn (*obufferP, strlen(*obufferP), closure); + } + } out = *obufferP; *out = 0; @@ -134,199 +133,199 @@ MimeRichtextConvert (const char *line, PRInt32 length, this_start = last_end; this_end = this_start; while (this_end < data_end) - { - /* Skip forward to next special character. */ - while (this_start < data_end && - *this_start != '<' && *this_start != '>' && - *this_start != '&') - this_start++; + { + /* Skip forward to next special character. */ + while (this_start < data_end && + *this_start != '<' && *this_start != '>' && + *this_start != '&') + this_start++; - this_end = this_start; + this_end = this_start; - /* Skip to the end of the tag. */ - if (this_start < data_end && *this_start == '<') - { - this_end++; - while (this_end < data_end && - !nsCRT::IsAsciiSpace (*this_end) && - *this_end != '<' && *this_end != '>' && - *this_end != '&') - this_end++; - } + /* Skip to the end of the tag. */ + if (this_start < data_end && *this_start == '<') + { + this_end++; + while (this_end < data_end && + !IS_SPACE(*this_end) && + *this_end != '<' && *this_end != '>' && + *this_end != '&') + this_end++; + } - this_end++; + this_end++; - /* Push out the text preceeding the tag. */ - if (last_end && last_end != this_start) - { - memcpy (out, last_end, this_start - last_end); - out += this_start - last_end; - *out = 0; - } + /* Push out the text preceeding the tag. */ + if (last_end && last_end != this_start) + { + memcpy (out, last_end, this_start - last_end); + out += this_start - last_end; + *out = 0; + } - if (this_start >= data_end) - break; - else if (*this_start == '&') - { - PL_strcpy (out, "&"); out += strlen (out); - } - else if (*this_start == '>') - { - PL_strcpy (out, ">"); out += strlen (out); - } - else if (enriched_p && - this_start < data_end + 1 && - this_start[0] == '<' && - this_start[1] == '<') - { - PL_strcpy (out, "<"); out += strlen (out); - } - else if (this_start != this_end) - { - /* Push out this ID. */ - const char *old = this_start + 1; - const char *tag_open = 0; - const char *tag_close = 0; - if (*old == '/') - { - /* This is */ - old++; - } + if (this_start >= data_end) + break; + else if (*this_start == '&') + { + PL_strcpy (out, "&"); out += strlen (out); + } + else if (*this_start == '>') + { + PL_strcpy (out, ">"); out += strlen (out); + } + else if (enriched_p && + this_start < data_end + 1 && + this_start[0] == '<' && + this_start[1] == '<') + { + PL_strcpy (out, "<"); out += strlen (out); + } + else if (this_start != this_end) + { + /* Push out this ID. */ + const char *old = this_start + 1; + const char *tag_open = 0; + const char *tag_close = 0; + if (*old == '/') + { + /* This is */ + old++; + } - switch (*old) - { - case 'b': case 'B': - if (!nsCRT::strncasecmp ("BIGGER>", old, 7)) - tag_open = "", tag_close = ""; - else if (!nsCRT::strncasecmp ("BLINK>", old, 5)) - /* Of course, both text/richtext and text/enriched must be - enhanced *somehow*... Or else what would people think. */ - tag_open = "", tag_close = ""; - else if (!nsCRT::strncasecmp ("BOLD>", old, 5)) - tag_open = "", tag_close = ""; - break; - case 'c': case 'C': - if (!nsCRT::strncasecmp ("CENTER>", old, 7)) - tag_open = "

", tag_close = "
"; - else if (!enriched_p && - !nsCRT::strncasecmp ("COMMENT>", old, 8)) - tag_open = ""; - break; - case 'e': case 'E': - if (!nsCRT::strncasecmp ("EXCERPT>", old, 8)) - tag_open = "
", tag_close = "
"; - break; - case 'f': case 'F': - if (!nsCRT::strncasecmp ("FIXED>", old, 6)) - tag_open = "", tag_close = ""; - else if (enriched_p && - !nsCRT::strncasecmp ("FLUSHBOTH>", old, 10)) - tag_open = "

", tag_close = "

"; - else if (!nsCRT::strncasecmp ("FLUSHLEFT>", old, 10)) - tag_open = "

", tag_close = "

"; - else if (!nsCRT::strncasecmp ("FLUSHRIGHT>", old, 11)) - tag_open = "

", tag_close = "

"; - else if (!enriched_p && - !nsCRT::strncasecmp ("FOOTING>", old, 8)) - tag_open = "
", tag_close = "
"; - break; - case 'h': case 'H': - if (!enriched_p && - !nsCRT::strncasecmp ("HEADING>", old, 8)) - tag_open = "
", tag_close = "
"; - break; - case 'i': case 'I': - if (!nsCRT::strncasecmp ("INDENT>", old, 7)) - tag_open = "
    ", tag_close = "
"; - else if (!nsCRT::strncasecmp ("INDENTRIGHT>", old, 12)) - tag_open = 0, tag_close = 0; -/* else if (!enriched_p && - !nsCRT::strncasecmp ("ISO-8859-", old, 9)) - tag_open = 0, tag_close = 0; */ - else if (!nsCRT::strncasecmp ("ITALIC>", old, 7)) - tag_open = "", tag_close = ""; - break; - case 'l': case 'L': - if (!enriched_p && - !nsCRT::strncasecmp ("LT>", old, 3)) - tag_open = "<", tag_close = 0; - break; - case 'n': case 'N': - if (!enriched_p && - !nsCRT::strncasecmp ("NL>", old, 3)) - tag_open = "
", tag_close = 0; - if (enriched_p && - !nsCRT::strncasecmp ("NOFILL>", old, 7)) - tag_open = "", tag_close = ""; -/* else if (!enriched_p && - !nsCRT::strncasecmp ("NO-OP>", old, 6)) - tag_open = 0, tag_close = 0; */ -/* else if (!enriched_p && - !nsCRT::strncasecmp ("NP>", old, 3)) - tag_open = 0, tag_close = 0; */ - break; - case 'o': case 'O': - if (!enriched_p && - !nsCRT::strncasecmp ("OUTDENT>", old, 8)) - tag_open = 0, tag_close = 0; - else if (!enriched_p && - !nsCRT::strncasecmp ("OUTDENTRIGHT>", old, 13)) - tag_open = 0, tag_close = 0; - break; - case 'p': case 'P': - if (enriched_p && - !nsCRT::strncasecmp ("PARAM>", old, 6)) - tag_open = ""; - else if (!enriched_p && - !nsCRT::strncasecmp ("PARAGRAPH>", old, 10)) - tag_open = "

", tag_close = 0; - break; - case 's': case 'S': - if (!enriched_p && - !nsCRT::strncasecmp ("SAMEPAGE>", old, 9)) - tag_open = 0, tag_close = 0; - else if (!enriched_p && - !nsCRT::strncasecmp ("SIGNATURE>", old, 10)) - tag_open = "", tag_close = ""; - else if (!nsCRT::strncasecmp ("SMALLER>", old, 8)) - tag_open = "", tag_close = ""; - else if (!enriched_p && - !nsCRT::strncasecmp ("SUBSCRIPT>", old, 10)) - tag_open = "", tag_close = ""; - else if (!enriched_p && - !nsCRT::strncasecmp ("SUPERSCRIPT>", old, 12)) - tag_open = "", tag_close = ""; - break; - case 'u': case 'U': - if (!nsCRT::strncasecmp ("UNDERLINE>", old, 10)) - tag_open = "", tag_close = ""; -/* else if (!enriched_p && - !nsCRT::strncasecmp ("US-ASCII>", old, 10)) - tag_open = 0, tag_close = 0; */ - break; - case 'v': case 'V': - if (enriched_p && - !nsCRT::strncasecmp ("VERBATIM>", old, 9)) - tag_open = "

", tag_close = "
"; - break; - } + switch (*old) + { + case 'b': case 'B': + if (!PL_strncasecmp ("BIGGER>", old, 7)) + tag_open = "", tag_close = ""; + else if (!PL_strncasecmp ("BLINK>", old, 5)) + /* Of course, both text/richtext and text/enriched must be + enhanced *somehow*... Or else what would people think. */ + tag_open = "", tag_close = ""; + else if (!PL_strncasecmp ("BOLD>", old, 5)) + tag_open = "", tag_close = ""; + break; + case 'c': case 'C': + if (!PL_strncasecmp ("CENTER>", old, 7)) + tag_open = "
", tag_close = "
"; + else if (!enriched_p && + !PL_strncasecmp ("COMMENT>", old, 8)) + tag_open = ""; + break; + case 'e': case 'E': + if (!PL_strncasecmp ("EXCERPT>", old, 8)) + tag_open = "
", tag_close = "
"; + break; + case 'f': case 'F': + if (!PL_strncasecmp ("FIXED>", old, 6)) + tag_open = "", tag_close = ""; + else if (enriched_p && + !PL_strncasecmp ("FLUSHBOTH>", old, 10)) + tag_open = "

", tag_close = "

"; + else if (!PL_strncasecmp ("FLUSHLEFT>", old, 10)) + tag_open = "

", tag_close = "

"; + else if (!PL_strncasecmp ("FLUSHRIGHT>", old, 11)) + tag_open = "

", tag_close = "

"; + else if (!enriched_p && + !PL_strncasecmp ("FOOTING>", old, 8)) + tag_open = "
", tag_close = "
"; + break; + case 'h': case 'H': + if (!enriched_p && + !PL_strncasecmp ("HEADING>", old, 8)) + tag_open = "
", tag_close = "
"; + break; + case 'i': case 'I': + if (!PL_strncasecmp ("INDENT>", old, 7)) + tag_open = "
    ", tag_close = "
"; + else if (!PL_strncasecmp ("INDENTRIGHT>", old, 12)) + tag_open = 0, tag_close = 0; +/* else if (!enriched_p && + !PL_strncasecmp ("ISO-8859-", old, 9)) + tag_open = 0, tag_close = 0; */ + else if (!PL_strncasecmp ("ITALIC>", old, 7)) + tag_open = "", tag_close = ""; + break; + case 'l': case 'L': + if (!enriched_p && + !PL_strncasecmp ("LT>", old, 3)) + tag_open = "<", tag_close = 0; + break; + case 'n': case 'N': + if (!enriched_p && + !PL_strncasecmp ("NL>", old, 3)) + tag_open = "
", tag_close = 0; + if (enriched_p && + !PL_strncasecmp ("NOFILL>", old, 7)) + tag_open = "", tag_close = ""; +/* else if (!enriched_p && + !PL_strncasecmp ("NO-OP>", old, 6)) + tag_open = 0, tag_close = 0; */ +/* else if (!enriched_p && + !PL_strncasecmp ("NP>", old, 3)) + tag_open = 0, tag_close = 0; */ + break; + case 'o': case 'O': + if (!enriched_p && + !PL_strncasecmp ("OUTDENT>", old, 8)) + tag_open = 0, tag_close = 0; + else if (!enriched_p && + !PL_strncasecmp ("OUTDENTRIGHT>", old, 13)) + tag_open = 0, tag_close = 0; + break; + case 'p': case 'P': + if (enriched_p && + !PL_strncasecmp ("PARAM>", old, 6)) + tag_open = ""; + else if (!enriched_p && + !PL_strncasecmp ("PARAGRAPH>", old, 10)) + tag_open = "

", tag_close = 0; + break; + case 's': case 'S': + if (!enriched_p && + !PL_strncasecmp ("SAMEPAGE>", old, 9)) + tag_open = 0, tag_close = 0; + else if (!enriched_p && + !PL_strncasecmp ("SIGNATURE>", old, 10)) + tag_open = "", tag_close = ""; + else if (!PL_strncasecmp ("SMALLER>", old, 8)) + tag_open = "", tag_close = ""; + else if (!enriched_p && + !PL_strncasecmp ("SUBSCRIPT>", old, 10)) + tag_open = "", tag_close = ""; + else if (!enriched_p && + !PL_strncasecmp ("SUPERSCRIPT>", old, 12)) + tag_open = "", tag_close = ""; + break; + case 'u': case 'U': + if (!PL_strncasecmp ("UNDERLINE>", old, 10)) + tag_open = "", tag_close = ""; +/* else if (!enriched_p && + !PL_strncasecmp ("US-ASCII>", old, 10)) + tag_open = 0, tag_close = 0; */ + break; + case 'v': case 'V': + if (enriched_p && + !PL_strncasecmp ("VERBATIM>", old, 9)) + tag_open = "

", tag_close = "
"; + break; + } - if (this_start[1] == '/') - { - if (tag_close) PL_strcpy (out, tag_close); - out += strlen (out); - } - else - { - if (tag_open) PL_strcpy (out, tag_open); - out += strlen (out); - } - } + if (this_start[1] == '/') + { + if (tag_close) PL_strcpy (out, tag_close); + out += strlen (out); + } + else + { + if (tag_open) PL_strcpy (out, tag_open); + out += strlen (out); + } + } - /* now go around again */ - last_end = this_end; - this_start = last_end; - } + /* now go around again */ + last_end = this_end; + this_start = last_end; + } *out = 0; return output_fn (*obufferP, out - *obufferP, closure); @@ -337,13 +336,13 @@ static int MimeInlineTextRichtext_parse_line (const char *line, PRInt32 length, MimeObject *obj) { PRBool enriched_p = (((MimeInlineTextRichtextClass *) obj->clazz) - ->enriched_p); + ->enriched_p); return MimeRichtextConvert (line, length, - obj->options->output_fn, - obj->options->stream_closure, - &obj->obuffer, &obj->obuffer_size, - enriched_p); + obj->options->output_fn, + obj->options->stream_closure, + &obj->obuffer, &obj->obuffer_size, + enriched_p); } diff --git a/mozilla/mailnews/mime/src/mimeunty.cpp b/mozilla/mailnews/mime/src/mimeunty.cpp index be0092ec476..a7f04d50a2b 100644 --- a/mozilla/mailnews/mime/src/mimeunty.cpp +++ b/mozilla/mailnews/mime/src/mimeunty.cpp @@ -38,7 +38,6 @@ #include "mimeunty.h" #include "prmem.h" #include "plstr.h" -#include "nsCRT.h" #include "prlog.h" #include "nsMimeTypes.h" #include "msgCore.h" @@ -46,7 +45,7 @@ #define MIME_SUPERCLASS mimeContainerClass MimeDefClass(MimeUntypedText, MimeUntypedTextClass, - mimeUntypedTextClass, &MIME_SUPERCLASS); + mimeUntypedTextClass, &MIME_SUPERCLASS); static int MimeUntypedText_initialize (MimeObject *); static void MimeUntypedText_finalize (MimeObject *); @@ -54,30 +53,30 @@ static int MimeUntypedText_parse_begin (MimeObject *); static int MimeUntypedText_parse_line (const char *, PRInt32, MimeObject *); static int MimeUntypedText_open_subpart (MimeObject *obj, - MimeUntypedTextSubpartType ttype, - const char *type, - const char *enc, - const char *name, - const char *desc); + MimeUntypedTextSubpartType ttype, + const char *type, + const char *enc, + const char *name, + const char *desc); static int MimeUntypedText_close_subpart (MimeObject *obj); static PRBool MimeUntypedText_uu_begin_line_p(const char *line, PRInt32 length, - MimeDisplayOptions *opt, - char **type_ret, - char **name_ret); + MimeDisplayOptions *opt, + char **type_ret, + char **name_ret); static PRBool MimeUntypedText_uu_end_line_p(const char *line, PRInt32 length); static PRBool MimeUntypedText_yenc_begin_line_p(const char *line, PRInt32 length, - MimeDisplayOptions *opt, - char **type_ret, - char **name_ret); + MimeDisplayOptions *opt, + char **type_ret, + char **name_ret); static PRBool MimeUntypedText_yenc_end_line_p(const char *line, PRInt32 length); static PRBool MimeUntypedText_binhex_begin_line_p(const char *line, - PRInt32 length, - MimeDisplayOptions *opt); + PRInt32 length, + MimeDisplayOptions *opt); static PRBool MimeUntypedText_binhex_end_line_p(const char *line, - PRInt32 length); + PRInt32 length); static int MimeUntypedTextClassInitialize(MimeUntypedTextClass *clazz) @@ -104,15 +103,15 @@ MimeUntypedText_finalize (MimeObject *object) MimeUntypedText *uty = (MimeUntypedText *) object; if (uty->open_hdrs) - { - /* Oops, those shouldn't still be here... */ - MimeHeaders_free(uty->open_hdrs); - uty->open_hdrs = 0; - } + { + /* Oops, those shouldn't still be here... */ + MimeHeaders_free(uty->open_hdrs); + uty->open_hdrs = 0; + } /* What about the open_subpart? We're gonna have to assume that it - is also on the MimeContainer->children list, and will get cleaned - up by that class. */ + is also on the MimeContainer->children list, and will get cleaned + up by that class. */ ((MimeObjectClass*)&MIME_SUPERCLASS)->finalize(object); } @@ -135,62 +134,62 @@ MimeUntypedText_parse_line (const char *line, PRInt32 length, MimeObject *obj) if (!line || !*line) return -1; /* If we're supposed to write this object, but aren't supposed to convert - it to HTML, simply pass it through unaltered. */ + it to HTML, simply pass it through unaltered. */ if (obj->output_p && - obj->options && - !obj->options->write_html_p && - obj->options->output_fn) - return MimeObject_write(obj, line, length, PR_TRUE); + obj->options && + !obj->options->write_html_p && + obj->options->output_fn) + return MimeObject_write(obj, line, length, PR_TRUE); /* Open a new sub-part if this line demands it. */ if (line[0] == 'b' && - MimeUntypedText_uu_begin_line_p(line, length, obj->options, - &type, &name)) - { - /* Close the old part and open a new one. */ - status = MimeUntypedText_open_subpart (obj, - MimeUntypedTextSubpartTypeUUE, - type, ENCODING_UUENCODE, - name, NULL); - PR_FREEIF(name); - PR_FREEIF(type); - if (status < 0) return status; - begin_line_p = PR_TRUE; - } + MimeUntypedText_uu_begin_line_p(line, length, obj->options, + &type, &name)) + { + /* Close the old part and open a new one. */ + status = MimeUntypedText_open_subpart (obj, + MimeUntypedTextSubpartTypeUUE, + type, ENCODING_UUENCODE, + name, NULL); + PR_FREEIF(name); + PR_FREEIF(type); + if (status < 0) return status; + begin_line_p = PR_TRUE; + } else if (line[0] == '=' && - MimeUntypedText_yenc_begin_line_p(line, length, obj->options, - &type, &name)) - { - /* Close the old part and open a new one. */ - status = MimeUntypedText_open_subpart (obj, - MimeUntypedTextSubpartTypeYEnc, - type, ENCODING_YENCODE, - name, NULL); - PR_FREEIF(name); - PR_FREEIF(type); - if (status < 0) return status; - begin_line_p = PR_TRUE; - } + MimeUntypedText_yenc_begin_line_p(line, length, obj->options, + &type, &name)) + { + /* Close the old part and open a new one. */ + status = MimeUntypedText_open_subpart (obj, + MimeUntypedTextSubpartTypeYEnc, + type, ENCODING_YENCODE, + name, NULL); + PR_FREEIF(name); + PR_FREEIF(type); + if (status < 0) return status; + begin_line_p = PR_TRUE; + } else if (line[0] == '(' && line[1] == 'T' && - MimeUntypedText_binhex_begin_line_p(line, length, obj->options)) - { - /* Close the old part and open a new one. */ - status = MimeUntypedText_open_subpart (obj, - MimeUntypedTextSubpartTypeBinhex, - APPLICATION_BINHEX, NULL, - NULL, NULL); - if (status < 0) return status; - begin_line_p = PR_TRUE; - } + MimeUntypedText_binhex_begin_line_p(line, length, obj->options)) + { + /* Close the old part and open a new one. */ + status = MimeUntypedText_open_subpart (obj, + MimeUntypedTextSubpartTypeBinhex, + APPLICATION_BINHEX, NULL, + NULL, NULL); + if (status < 0) return status; + begin_line_p = PR_TRUE; + } /* Open a text/plain sub-part if there is no sub-part open. */ if (!uty->open_subpart) - { + { // rhp: If we get here and we are being fed a line ending, we should // just eat it and continue and if we really get more data, we'll open // up the subpart then. @@ -198,48 +197,48 @@ MimeUntypedText_parse_line (const char *line, PRInt32 length, MimeObject *obj) if (line[0] == '\r') return 0; if (line[0] == '\n') return 0; - PR_ASSERT(!begin_line_p); - status = MimeUntypedText_open_subpart (obj, - MimeUntypedTextSubpartTypeText, - TEXT_PLAIN, NULL, NULL, NULL); - PR_ASSERT(uty->open_subpart); - if (!uty->open_subpart) return -1; - if (status < 0) return status; - } + PR_ASSERT(!begin_line_p); + status = MimeUntypedText_open_subpart (obj, + MimeUntypedTextSubpartTypeText, + TEXT_PLAIN, NULL, NULL, NULL); + PR_ASSERT(uty->open_subpart); + if (!uty->open_subpart) return -1; + if (status < 0) return status; + } /* Hand this line to the currently-open sub-part. */ status = uty->open_subpart->clazz->parse_buffer(line, length, - uty->open_subpart); + uty->open_subpart); if (status < 0) return status; /* Close this sub-part if this line demands it. */ if (begin_line_p) - ; + ; else if (line[0] == 'e' && - uty->type == MimeUntypedTextSubpartTypeUUE && - MimeUntypedText_uu_end_line_p(line, length)) - { - status = MimeUntypedText_close_subpart (obj); - if (status < 0) return status; - NS_ASSERTION(!uty->open_subpart, "no open subpart"); - } + uty->type == MimeUntypedTextSubpartTypeUUE && + MimeUntypedText_uu_end_line_p(line, length)) + { + status = MimeUntypedText_close_subpart (obj); + if (status < 0) return status; + NS_ASSERTION(!uty->open_subpart, "no open subpart"); + } else if (line[0] == '=' && - uty->type == MimeUntypedTextSubpartTypeYEnc && - MimeUntypedText_yenc_end_line_p(line, length)) - { - status = MimeUntypedText_close_subpart (obj); - if (status < 0) return status; - NS_ASSERTION(!uty->open_subpart, "no open subpart"); - } + uty->type == MimeUntypedTextSubpartTypeYEnc && + MimeUntypedText_yenc_end_line_p(line, length)) + { + status = MimeUntypedText_close_subpart (obj); + if (status < 0) return status; + NS_ASSERTION(!uty->open_subpart, "no open subpart"); + } else if (uty->type == MimeUntypedTextSubpartTypeBinhex && - MimeUntypedText_binhex_end_line_p(line, length)) - { - status = MimeUntypedText_close_subpart (obj); - if (status < 0) return status; - NS_ASSERTION(!uty->open_subpart, "no open subpart"); - } + MimeUntypedText_binhex_end_line_p(line, length)) + { + status = MimeUntypedText_close_subpart (obj); + if (status < 0) return status; + NS_ASSERTION(!uty->open_subpart, "no open subpart"); + } return 0; } @@ -252,26 +251,26 @@ MimeUntypedText_close_subpart (MimeObject *obj) int status; if (uty->open_subpart) - { - status = uty->open_subpart->clazz->parse_eof(uty->open_subpart, PR_FALSE); - uty->open_subpart = 0; + { + status = uty->open_subpart->clazz->parse_eof(uty->open_subpart, PR_FALSE); + uty->open_subpart = 0; - PR_ASSERT(uty->open_hdrs); - if (uty->open_hdrs) - { - MimeHeaders_free(uty->open_hdrs); - uty->open_hdrs = 0; - } - uty->type = MimeUntypedTextSubpartTypeText; - if (status < 0) return status; + PR_ASSERT(uty->open_hdrs); + if (uty->open_hdrs) + { + MimeHeaders_free(uty->open_hdrs); + uty->open_hdrs = 0; + } + uty->type = MimeUntypedTextSubpartTypeText; + if (status < 0) return status; - /* Never put out a separator between sub-parts of UntypedText. - (This bypasses the rule that text/plain subparts always - have separators before and after them.) - */ - if (obj->options && obj->options->state) - obj->options->state->separator_suppressed_p = PR_TRUE; - } + /* Never put out a separator between sub-parts of UntypedText. + (This bypasses the rule that text/plain subparts always + have separators before and after them.) + */ + if (obj->options && obj->options->state) + obj->options->state->separator_suppressed_p = PR_TRUE; + } PR_ASSERT(!uty->open_hdrs); return 0; @@ -279,52 +278,52 @@ MimeUntypedText_close_subpart (MimeObject *obj) static int MimeUntypedText_open_subpart (MimeObject *obj, - MimeUntypedTextSubpartType ttype, - const char *type, - const char *enc, - const char *name, - const char *desc) + MimeUntypedTextSubpartType ttype, + const char *type, + const char *enc, + const char *name, + const char *desc) { MimeUntypedText *uty = (MimeUntypedText *) obj; int status = 0; char *h = 0; - if (!type || !*type || !nsCRT::strcasecmp(type, UNKNOWN_CONTENT_TYPE)) - type = APPLICATION_OCTET_STREAM; + if (!type || !*type || !PL_strcasecmp(type, UNKNOWN_CONTENT_TYPE)) + type = APPLICATION_OCTET_STREAM; if (enc && !*enc) - enc = 0; + enc = 0; if (desc && !*desc) - desc = 0; + desc = 0; if (name && !*name) - name = 0; + name = 0; if (uty->open_subpart) - { - status = MimeUntypedText_close_subpart (obj); - if (status < 0) return status; - } + { + status = MimeUntypedText_close_subpart (obj); + if (status < 0) return status; + } NS_ASSERTION(!uty->open_subpart, "no open subpart"); NS_ASSERTION(!uty->open_hdrs, "no open headers"); /* To make one of these implicitly-typed sub-objects, we make up a fake - header block, containing only the minimum number of MIME headers needed. - We could do most of this (Type and Encoding) by making a null header - block, and simply setting obj->content_type and obj->encoding; but making - a fake header block is better for two reasons: first, it means that - something will actually be displayed when in `Show All Headers' mode; - and second, it's the only way to communicate the filename parameter, - aside from adding a new slot to MimeObject (which is something to be - avoided when possible.) + header block, containing only the minimum number of MIME headers needed. + We could do most of this (Type and Encoding) by making a null header + block, and simply setting obj->content_type and obj->encoding; but making + a fake header block is better for two reasons: first, it means that + something will actually be displayed when in `Show All Headers' mode; + and second, it's the only way to communicate the filename parameter, + aside from adding a new slot to MimeObject (which is something to be + avoided when possible.) */ uty->open_hdrs = MimeHeaders_new(); if (!uty->open_hdrs) return MIME_OUT_OF_MEMORY; h = (char *) PR_MALLOC(strlen(type) + - (enc ? strlen(enc) : 0) + - (desc ? strlen(desc) : 0) + - (name ? strlen(name) : 0) + - 100); + (enc ? strlen(enc) : 0) + + (desc ? strlen(desc) : 0) + + (name ? strlen(name) : 0) + + 100); if (!h) return MIME_OUT_OF_MEMORY; PL_strcpy(h, HEADER_CONTENT_TYPE ": "); @@ -334,30 +333,30 @@ MimeUntypedText_open_subpart (MimeObject *obj, if (status < 0) goto FAIL; if (enc) - { - PL_strcpy(h, HEADER_CONTENT_TRANSFER_ENCODING ": "); - PL_strcat(h, enc); - PL_strcat(h, MSG_LINEBREAK); - status = MimeHeaders_parse_line(h, strlen(h), uty->open_hdrs); - if (status < 0) goto FAIL; - } + { + PL_strcpy(h, HEADER_CONTENT_TRANSFER_ENCODING ": "); + PL_strcat(h, enc); + PL_strcat(h, MSG_LINEBREAK); + status = MimeHeaders_parse_line(h, strlen(h), uty->open_hdrs); + if (status < 0) goto FAIL; + } if (desc) - { - PL_strcpy(h, HEADER_CONTENT_DESCRIPTION ": "); - PL_strcat(h, desc); - PL_strcat(h, MSG_LINEBREAK); - status = MimeHeaders_parse_line(h, strlen(h), uty->open_hdrs); - if (status < 0) goto FAIL; - } + { + PL_strcpy(h, HEADER_CONTENT_DESCRIPTION ": "); + PL_strcat(h, desc); + PL_strcat(h, MSG_LINEBREAK); + status = MimeHeaders_parse_line(h, strlen(h), uty->open_hdrs); + if (status < 0) goto FAIL; + } if (name) - { - PL_strcpy(h, HEADER_CONTENT_DISPOSITION ": inline; filename=\""); - PL_strcat(h, name); - PL_strcat(h, "\"" MSG_LINEBREAK); - status = MimeHeaders_parse_line(h, strlen(h), uty->open_hdrs); - if (status < 0) goto FAIL; - } + { + PL_strcpy(h, HEADER_CONTENT_DISPOSITION ": inline; filename=\""); + PL_strcat(h, name); + PL_strcat(h, "\"" MSG_LINEBREAK); + status = MimeHeaders_parse_line(h, strlen(h), uty->open_hdrs); + if (status < 0) goto FAIL; + } /* push out a blank line. */ PL_strcpy(h, MSG_LINEBREAK); @@ -367,41 +366,41 @@ MimeUntypedText_open_subpart (MimeObject *obj, /* Create a child... */ { - PRBool horrid_kludge = (obj->options && obj->options->state && - obj->options->state->first_part_written_p); - if (horrid_kludge) - obj->options->state->first_part_written_p = PR_FALSE; + PRBool horrid_kludge = (obj->options && obj->options->state && + obj->options->state->first_part_written_p); + if (horrid_kludge) + obj->options->state->first_part_written_p = PR_FALSE; - uty->open_subpart = mime_create(type, uty->open_hdrs, obj->options); + uty->open_subpart = mime_create(type, uty->open_hdrs, obj->options); - if (horrid_kludge) - obj->options->state->first_part_written_p = PR_TRUE; + if (horrid_kludge) + obj->options->state->first_part_written_p = PR_TRUE; - if (!uty->open_subpart) - { - status = MIME_OUT_OF_MEMORY; - goto FAIL; - } + if (!uty->open_subpart) + { + status = MIME_OUT_OF_MEMORY; + goto FAIL; + } } /* Add it to the list... */ status = ((MimeContainerClass *) obj->clazz)->add_child(obj, - uty->open_subpart); + uty->open_subpart); if (status < 0) - { - mime_free(uty->open_subpart); - uty->open_subpart = 0; - goto FAIL; - } + { + mime_free(uty->open_subpart); + uty->open_subpart = 0; + goto FAIL; + } /* And start its parser going. */ status = uty->open_subpart->clazz->parse_begin(uty->open_subpart); if (status < 0) - { - /* MimeContainer->finalize will take care of shutting it down now. */ - uty->open_subpart = 0; - goto FAIL; - } + { + /* MimeContainer->finalize will take care of shutting it down now. */ + uty->open_subpart = 0; + goto FAIL; + } uty->type = ttype; @@ -409,18 +408,18 @@ MimeUntypedText_open_subpart (MimeObject *obj, PR_FREEIF(h); if (status < 0 && uty->open_hdrs) - { - MimeHeaders_free(uty->open_hdrs); - uty->open_hdrs = 0; - } + { + MimeHeaders_free(uty->open_hdrs); + uty->open_hdrs = 0; + } return status; } static PRBool MimeUntypedText_uu_begin_line_p(const char *line, PRInt32 length, - MimeDisplayOptions *opt, - char **type_ret, char **name_ret) + MimeDisplayOptions *opt, + char **type_ret, char **name_ret) { const char *s; char *name = 0; @@ -439,16 +438,16 @@ MimeUntypedText_uu_begin_line_p(const char *line, PRInt32 length, if (*s < '0' || *s > '7') return PR_FALSE; s++; if (*s == ' ') - s++; + s++; else - { - if (*s < '0' || *s > '7') return PR_FALSE; - s++; - if (*s != ' ') return PR_FALSE; - } + { + if (*s < '0' || *s > '7') return PR_FALSE; + s++; + if (*s != ' ') return PR_FALSE; + } - while (nsCRT::IsAsciiSpace(*s)) - s++; + while (IS_SPACE(*s)) + s++; name = (char *) PR_MALLOC(((line+length)-s) + 1); if (!name) return PR_FALSE; /* grr... */ @@ -462,19 +461,19 @@ MimeUntypedText_uu_begin_line_p(const char *line, PRInt32 length, /* Now try and figure out a type. */ if (opt && opt->file_type_fn) - type = opt->file_type_fn(name, opt->stream_closure); + type = opt->file_type_fn(name, opt->stream_closure); else - type = 0; + type = 0; if (name_ret) - *name_ret = name; + *name_ret = name; else - PR_FREEIF(name); + PR_FREEIF(name); if (type_ret) - *type_ret = type; + *type_ret = type; else - PR_FREEIF(type); + PR_FREEIF(type); return PR_TRUE; } @@ -485,36 +484,36 @@ MimeUntypedText_uu_end_line_p(const char *line, PRInt32 length) #if 0 /* A strictly conforming uuencode end line. */ return (line[0] == 'e' && - line[1] == 'n' && - line[2] == 'd' && - (line[3] == 0 || nsCRT::IsAsciiSpace(line[3]))); + line[1] == 'n' && + line[2] == 'd' && + (line[3] == 0 || IS_SPACE(line[3]))); #else /* ...but, why don't we accept any line that begins with the three - letters "END" in any case: I've seen lots of partial messages - that look like + letters "END" in any case: I've seen lots of partial messages + that look like - BEGIN----- Cut Here----- - begin 644 foo.gif - Mxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx - Mxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx - Mxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx - END------- Cut Here----- + BEGIN----- Cut Here----- + begin 644 foo.gif + Mxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + Mxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + Mxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + END------- Cut Here----- - so let's be lenient here. (This is only for the untyped-text-plain - case -- the uudecode parser itself is strict.) + so let's be lenient here. (This is only for the untyped-text-plain + case -- the uudecode parser itself is strict.) */ return (line[0] == ' ' || - line[0] == '\t' || - ((line[0] == 'e' || line[0] == 'E') && - (line[1] == 'n' || line[1] == 'N') && - (line[2] == 'd' || line[2] == 'D'))); + line[0] == '\t' || + ((line[0] == 'e' || line[0] == 'E') && + (line[1] == 'n' || line[1] == 'N') && + (line[2] == 'd' || line[2] == 'D'))); #endif } static PRBool MimeUntypedText_yenc_begin_line_p(const char *line, PRInt32 length, - MimeDisplayOptions *opt, - char **type_ret, char **name_ret) + MimeDisplayOptions *opt, + char **type_ret, char **name_ret) { const char *s; const char *endofline = line + length; @@ -535,7 +534,7 @@ MimeUntypedText_yenc_begin_line_p(const char *line, PRInt32 length, /* ...next, look for size= */ if ((endofline - s) < 6 || strncmp (s, " size=", 6)) return PR_FALSE; - + /* ...then couple digits. */ for (s += 6; s < endofline; s ++) if (*s < '0' || *s > '9') @@ -558,19 +557,19 @@ MimeUntypedText_yenc_begin_line_p(const char *line, PRInt32 length, /* Now try and figure out a type. */ if (opt && opt->file_type_fn) - type = opt->file_type_fn(name, opt->stream_closure); + type = opt->file_type_fn(name, opt->stream_closure); else - type = 0; + type = 0; if (name_ret) - *name_ret = name; + *name_ret = name; else - PR_FREEIF(name); + PR_FREEIF(name); if (type_ret) - *type_ret = type; + *type_ret = type; else - PR_FREEIF(type); + PR_FREEIF(type); return PR_TRUE; } @@ -580,7 +579,7 @@ MimeUntypedText_yenc_end_line_p(const char *line, PRInt32 length) { if (length < 11 || strncmp (line, "=yend size=", 11)) return PR_FALSE; - return PR_TRUE; + return PR_TRUE; } @@ -589,21 +588,21 @@ MimeUntypedText_yenc_end_line_p(const char *line, PRInt32 length) static PRBool MimeUntypedText_binhex_begin_line_p(const char *line, PRInt32 length, - MimeDisplayOptions *opt) + MimeDisplayOptions *opt) { if (length <= BINHEX_MAGIC_LEN) - return PR_FALSE; + return PR_FALSE; - while(length > 0 && nsCRT::IsAsciiSpace(line[length-1])) - length--; + while(length > 0 && IS_SPACE(line[length-1])) + length--; if (length != BINHEX_MAGIC_LEN) - return PR_FALSE; + return PR_FALSE; if (!strncmp(line, BINHEX_MAGIC, BINHEX_MAGIC_LEN)) - return PR_TRUE; + return PR_TRUE; else - return PR_FALSE; + return PR_FALSE; } static PRBool @@ -613,7 +612,7 @@ MimeUntypedText_binhex_end_line_p(const char *line, PRInt32 length) if (length > 0 && line[length-1] == '\r') length--; if (length != 0 && length != 64) - return PR_TRUE; + return PR_TRUE; else - return PR_FALSE; + return PR_FALSE; } diff --git a/mozilla/mailnews/mime/src/nsMsgHeaderParser.cpp b/mozilla/mailnews/mime/src/nsMsgHeaderParser.cpp index d6e5cfbbe66..1d69ff22442 100644 --- a/mozilla/mailnews/mime/src/nsMsgHeaderParser.cpp +++ b/mozilla/mailnews/mime/src/nsMsgHeaderParser.cpp @@ -39,11 +39,11 @@ #include "msgCore.h" // precompiled header... #include "nsReadableUtils.h" #include "nsMsgHeaderParser.h" -#include "nsISimpleEnumerator.h" +#include "nsISimpleEnumerator.h" #include "comi18n.h" #include "prmem.h" -nsresult FillResultsArray(const char * aName, const char *aAddress, PRUnichar ** aOutgoingEmailAddress, PRUnichar ** aOutgoingName, +nsresult FillResultsArray(const char * aName, const char *aAddress, PRUnichar ** aOutgoingEmailAddress, PRUnichar ** aOutgoingName, PRUnichar ** aOutgoingFullName, nsIMsgHeaderParser *aParser); /* @@ -58,7 +58,7 @@ nsresult FillResultsArray(const char * aName, const char *aAddress, PRUnichar ** memcpy(_D,_S,_LEN); _D += _LEN; } } while (0) //#define NEXT_CHAR(_STR) (_STR = (* (char *) _STR < 128) ? (char *) _STR + 1 : NextChar_UTF8((char *)_STR)) #define NEXT_CHAR(_STR) (_STR = NextChar_UTF8((char *)_STR)) -#define TRIM_WHITESPACE(_S,_E,_T) do { while (_E > _S && nsCRT::IsAsciiSpace(_E[-1])) _E--;\ +#define TRIM_WHITESPACE(_S,_E,_T) do { while (_E > _S && IS_SPACE(_E[-1])) _E--;\ *_E++ = _T; } while (0) /* @@ -98,7 +98,7 @@ nsMsgHeaderParser::~nsMsgHeaderParser() NS_IMPL_ISUPPORTS1(nsMsgHeaderParser, nsIMsgHeaderParser) // helper function called by ParseHeadersWithArray -nsresult FillResultsArray(const char * aName, const char *aAddress, PRUnichar ** aOutgoingEmailAddress, PRUnichar ** aOutgoingName, +nsresult FillResultsArray(const char * aName, const char *aAddress, PRUnichar ** aOutgoingEmailAddress, PRUnichar ** aOutgoingName, PRUnichar ** aOutgoingFullName, nsIMsgHeaderParser *aParser) { NS_ENSURE_ARG(aParser); @@ -111,7 +111,7 @@ nsresult FillResultsArray(const char * aName, const char *aAddress, PRUnichar ** *aOutgoingEmailAddress = ToNewUnicode(NS_ConvertUTF8toUTF16(result ? result : aAddress)); PR_FREEIF(result); } - + if (aName) { result = MIME_DecodeMimeHeader(aName, NULL, PR_FALSE, PR_TRUE); @@ -151,7 +151,7 @@ NS_IMETHODIMP nsMsgHeaderParser::ParseHeadersWithArray(const PRUnichar * aLine, char * utf8String = ToNewUTF8String(tempString); rv = ParseHeaderAddresses("UTF-8", utf8String, &names, &addresses, &numAddresses); - nsCRT::free(utf8String); + NS_Free(utf8String); if (NS_SUCCEEDED(rv) && numAddresses) { // allocate space for our arrays.... @@ -165,7 +165,7 @@ NS_IMETHODIMP nsMsgHeaderParser::ParseHeadersWithArray(const PRUnichar * aLine, PRUnichar ** outgoingFullNames = *aFullNames; // iterate over the results and fill in our arrays.... - PRUint32 index = 0; + PRUint32 index = 0; const char * currentName = names; const char * currentAddress = addresses; char * unquotedName = nsnull; @@ -175,7 +175,7 @@ NS_IMETHODIMP nsMsgHeaderParser::ParseHeadersWithArray(const PRUnichar * aLine, rv = FillResultsArray(unquotedName, currentAddress, &outgoingEmailAddresses[index], &outgoingNames[index], &outgoingFullNames[index], this); else rv = FillResultsArray(currentName, currentAddress, &outgoingEmailAddresses[index], &outgoingNames[index], &outgoingFullNames[index], this); - + PR_FREEIF(unquotedName); currentName += strlen(currentName) + 1; currentAddress += strlen(currentAddress) + 1; @@ -255,7 +255,7 @@ nsresult nsMsgHeaderParser::RemoveDuplicateAddresses (const char *charset, const nsresult nsMsgHeaderParser::MakeFullAddress (const char *charset, const char* name, const char* addr, char ** fullAddress) { NS_ENSURE_ARG_POINTER(fullAddress); - + *fullAddress = msg_make_full_address(name, addr); return NS_OK; } @@ -263,7 +263,7 @@ nsresult nsMsgHeaderParser::MakeFullAddress (const char *charset, const char* na nsresult nsMsgHeaderParser::MakeFullAddressWString (const PRUnichar* name, const PRUnichar* addr, PRUnichar ** fullAddress) { nsCString utf8Str; - nsresult rv = MakeFullAddress(nsnull, NS_ConvertUTF16toUTF8(name).get(), + nsresult rv = MakeFullAddress(nsnull, NS_ConvertUTF16toUTF8(name).get(), NS_ConvertUTF16toUTF8(addr).get(), getter_Copies(utf8Str)); if (NS_SUCCEEDED(rv)) { @@ -313,7 +313,7 @@ nsresult nsMsgHeaderParser::ReformatUnquotedAddresses (const PRUnichar *line, PR char *writePtr = outputStr; const char *endOutputPtr = outputStr + outputMaxLen; const char *endPtr = readPtr + lineLen; - + const char *startRecipient = readPtr; char* reformated; PRBool openQuoteLevel1 = PR_FALSE; @@ -343,7 +343,7 @@ nsresult nsMsgHeaderParser::ReformatUnquotedAddresses (const PRUnichar *line, PR */ char * tempEnd = NS_CONST_CAST(char *, readPtr); *tempEnd = 0; - + reformated = msg_reformat_Header_addresses(startRecipient); if (reformated) { @@ -415,9 +415,9 @@ nsresult NS_NewHeaderParser(nsIMsgHeaderParser ** aInstancePtrResult) return NS_ERROR_NULL_POINTER; /* aInstancePtrResult was NULL....*/ } - + /* - * The remainder of this file is the actual parsing code and it was extracted verbatim from addrutils.cpp + * The remainder of this file is the actual parsing code and it was extracted verbatim from addrutils.cpp */ /* msg_parse_Header_addresses @@ -478,10 +478,10 @@ static int msg_parse_Header_addresses (const char *line, char **names, char **ad name_start = name_buf; addr_start = addr_buf; this_start = line; - + /* Skip over extra whitespace or commas before addresses. */ - while (*line_end && (nsCRT::IsAsciiSpace(*line_end) || *line_end == ',')) + while (*line_end && (IS_SPACE(*line_end) || *line_end == ',')) NEXT_CHAR(line_end); while (*line_end) @@ -501,7 +501,7 @@ static int msg_parse_Header_addresses (const char *line, char **names, char **ad if (!*line_end) /* otherwise, we walk off end of line, right? */ break; } - else if (*line_end == '\"') + else if (*line_end == '\"') { int leave_quotes = 0; @@ -572,18 +572,17 @@ static int msg_parse_Header_addresses (const char *line, char **names, char **ad { const char *s = oparen + 1; - /* Copy the chars inside the parens onto the "name" buffer. - */ + /* Copy the chars inside the parens onto the "name" buffer. */ /* Push out some whitespace before the paren, if - * there is non-whitespace there already. - */ - if (name_out > name_start && !nsCRT::IsAsciiSpace(name_out [-1])) + * there is non-whitespace there already. + */ + if (name_out > name_start && !IS_SPACE(name_out [-1])) *name_out++ = ' '; /* Skip leading whitespace. */ - while (nsCRT::IsAsciiSpace(*s) && s < line_end) + while (IS_SPACE(*s) && s < line_end) s++; while (s < line_end) @@ -599,7 +598,7 @@ static int msg_parse_Header_addresses (const char *line, char **names, char **ad if (*s == '\\') /* remove one \ */ s++; - if (nsCRT::IsAsciiSpace(*s) && name_out > name_start && nsCRT::IsAsciiSpace(name_out[-1])) + if (IS_SPACE(*s) && name_out > name_start && IS_SPACE(name_out[-1])) /* collapse consecutive whitespace */; else COPY_CHAR(name_out, s); @@ -619,8 +618,8 @@ static int msg_parse_Header_addresses (const char *line, char **names, char **ad /* Eat whitespace at the beginning of the line, * and eat consecutive whitespace within the line. */ - if ( nsCRT::IsAsciiSpace(*line_end) - && (addr_out == addr_start || nsCRT::IsAsciiSpace(addr_out[-1]))) + if (IS_SPACE(*line_end) + && (addr_out == addr_start || IS_SPACE(addr_out[-1]))) /* skip it */; else COPY_CHAR(addr_out, line_end); @@ -630,7 +629,7 @@ static int msg_parse_Header_addresses (const char *line, char **names, char **ad NEXT_CHAR(line_end); } - /* Now we have extracted a single address from the comma-separated + /* Now we have extracted a single address from the comma-separated * list of addresses. The characters have been divided among the * various buffers: the parts inside parens have been placed in the * name_buf, and everything else has been placed in the addr_buf. @@ -659,7 +658,7 @@ static int msg_parse_Header_addresses (const char *line, char **names, char **ad /* Skip leading whitespace. */ - while (nsCRT::IsAsciiSpace(*s) && s < mailbox_start) + while (IS_SPACE(*s) && s < mailbox_start) s++; /* Copy up to (not including) the < @@ -678,7 +677,7 @@ static int msg_parse_Header_addresses (const char *line, char **names, char **ad *name_out++ = *s++; continue; } - if (nsCRT::IsAsciiSpace(*s) && name_out > name_start && nsCRT::IsAsciiSpace(name_out[-1])) + if (IS_SPACE(*s) && name_out > name_start && IS_SPACE(name_out[-1])) /* collapse consecutive whitespace */; else COPY_CHAR(name_out, s); @@ -693,7 +692,7 @@ static int msg_parse_Header_addresses (const char *line, char **names, char **ad /* Skip whitespace after > */ - while (nsCRT::IsAsciiSpace(*s) && s < line_end) + while (IS_SPACE(*s) && s < line_end) s++; /* Copy from just after > to the end. @@ -712,7 +711,7 @@ static int msg_parse_Header_addresses (const char *line, char **names, char **ad *name_out++ = *s++; continue; } - if (nsCRT::IsAsciiSpace (*s) && name_out > name_start && nsCRT::IsAsciiSpace (name_out[-1])) + if (IS_SPACE(*s) && name_out > name_start && IS_SPACE(name_out[-1])) /* collapse consecutive whitespace */; else COPY_CHAR(name_out, s); @@ -730,7 +729,7 @@ static int msg_parse_Header_addresses (const char *line, char **names, char **ad /* Skip leading whitespace. */ - while (nsCRT::IsAsciiSpace(*s) && s < mailbox_end) + while (IS_SPACE(*s) && s < mailbox_end) s++; /* Copy up to (not including) the > @@ -774,7 +773,7 @@ static int msg_parse_Header_addresses (const char *line, char **names, char **ad L = msg_quote_phrase_or_addr(name_start, L, PR_FALSE); name_out = name_start + L + 1; } -#endif +#endif if (quote_addrs_p && addresses) { @@ -794,7 +793,7 @@ static int msg_parse_Header_addresses (const char *line, char **names, char **ad NEXT_CHAR(line_end); /* Skip over extra whitespace or commas between addresses. */ - while (*line_end && (nsCRT::IsAsciiSpace(*line_end) || *line_end == ',')) + while (*line_end && (IS_SPACE(*line_end) || *line_end == ',')) line_end++; this_start = line_end; @@ -808,10 +807,10 @@ static int msg_parse_Header_addresses (const char *line, char **names, char **ad { char *s; for (s = name_buf; s < name_out; NEXT_CHAR(s)) - if (nsCRT::IsAsciiSpace(*s) && *s != ' ') + if (IS_SPACE(*s) && *s != ' ') *s = ' '; for (s = addr_buf; s < addr_out; NEXT_CHAR(s)) - if (nsCRT::IsAsciiSpace(*s) && *s != ' ') + if (IS_SPACE(*s) && *s != ' ') *s = ' '; } @@ -862,7 +861,7 @@ msg_quote_phrase_or_addr(char *address, PRInt32 length, PRBool addr_p) address = in; break; } - else if (!nsCRT::IsAsciiDigit(*in) && !nsCRT::IsAsciiAlpha(*in) && *in != '@' && *in != '.') + else if (!IS_DIGIT(*in) && !IS_ALPHA(*in) && *in != '@' && *in != '.') break; } } @@ -904,7 +903,7 @@ msg_quote_phrase_or_addr(char *address, PRInt32 length, PRBool addr_p) else if ( /* *in >= 127 || *in < 0 ducarroz: 8bits characters will be mime encoded therefore they are not a problem ||*/ (*in == ';' && !addr_p) || *in == '$' || *in == '(' || *in == ')' - || *in == '<' || *in == '>' || *in == '@' || *in == ',') + || *in == '<' || *in == '>' || *in == '@' || *in == ',') /* If the name contains control chars or Header specials, it needs to * be enclosed in quotes. Double-quotes and backslashes will be dealt * with separately. @@ -1032,7 +1031,7 @@ msg_unquote_phrase_or_addr(const char *line, PRBool preserveIntegrity, char **li */ if (*line != '\"') { - *lineout = nsCRT::strdup(line); + *lineout = strdup(line); if (!*lineout) return NS_ERROR_OUT_OF_MEMORY; else @@ -1072,7 +1071,7 @@ msg_unquote_phrase_or_addr(const char *line, PRBool preserveIntegrity, char **li if (comma && at_sign) { - *lineout = nsCRT::strdup(line); + *lineout = strdup(line); if (!*lineout) return NS_ERROR_OUT_OF_MEMORY; else @@ -1082,11 +1081,11 @@ msg_unquote_phrase_or_addr(const char *line, PRBool preserveIntegrity, char **li /* Don't copy the first double quote */ - *lineout = nsCRT::strdup(line + 1); + *lineout = strdup(line + 1); if (!*lineout) return NS_ERROR_OUT_OF_MEMORY; - const char *lineptr = line + 1; + const char *lineptr = line + 1; char *outptr = *lineout; PRBool escaped = PR_FALSE; @@ -1111,7 +1110,7 @@ msg_unquote_phrase_or_addr(const char *line, PRBool preserveIntegrity, char **li } } *outptr = '\0'; - + return NS_OK; } @@ -1242,7 +1241,7 @@ msg_extract_Header_address_names(const char *line) /* msg_extract_Header_address_name * * Like MSG_ExtractHeaderAddressNames(), but only returns the first name - * in the list, if there is more than one. + * in the list, if there is more than one. */ static char * msg_extract_Header_address_name(const char *line) @@ -1296,7 +1295,7 @@ msg_format_Header_addresses (const char *names, const char *addrs, len2 = strlen(s2); s1 += len1 + 1; s2 += len2 + 1; - + len1 = (len1 * 2) + 2; //(N*2) + 2 in case we need to quote it len2 = (len2 * 2) + 2; name_maxlen = PR_MAX(name_maxlen, len1); @@ -1322,7 +1321,7 @@ msg_format_Header_addresses (const char *names, const char *addrs, for (i = 0; (int)i < count; i++) { char *o; - + PL_strncpy(aName, s1, name_maxlen); PL_strncpy(anAddr, s2, addr_maxlen); len1 = msg_quote_phrase_or_addr(aName, strlen(s1), PR_FALSE); @@ -1364,10 +1363,10 @@ msg_format_Header_addresses (const char *names, const char *addrs, column += (out - o); } *out = 0; - + PR_FREEIF(aName); PR_FREEIF(anAddr); - + return result; } @@ -1429,7 +1428,7 @@ msg_remove_duplicate_addresses(const char *addrs, const char *other_addrs, if (count1 < 0) goto FAIL; if (count1 == 0) { - result = nsCRT::strdup(""); + result = strdup(""); goto FAIL; } if (other_addrs) @@ -1501,7 +1500,7 @@ msg_remove_duplicate_addresses(const char *addrs, const char *other_addrs, { PRBool found = PR_FALSE; for (j = 0; j < count2; j++) - if (!nsCRT::strcasecmp (a_array1[i], a_array2[j])) + if (!PL_strcasecmp (a_array1[i], a_array2[j])) { found = PR_TRUE; break; @@ -1509,7 +1508,7 @@ msg_remove_duplicate_addresses(const char *addrs, const char *other_addrs, if (!found) for (j = 0; j < count3; j++) - if (!nsCRT::strcasecmp(a_array1[i], a_array3[j])) + if (!PL_strcasecmp(a_array1[i], a_array3[j])) { found = PR_TRUE; break; diff --git a/mozilla/mailnews/mime/src/nsMsgHeaderParser.h b/mozilla/mailnews/mime/src/nsMsgHeaderParser.h index 4ede06845a4..ca0b3c6b4b0 100644 --- a/mozilla/mailnews/mime/src/nsMsgHeaderParser.h +++ b/mozilla/mailnews/mime/src/nsMsgHeaderParser.h @@ -58,11 +58,10 @@ class nsMsgHeaderParser: public nsIMsgHeaderParser { public: nsMsgHeaderParser(); - virtual ~nsMsgHeaderParser(); - - /* this macro defines QueryInterface, AddRef and Release for this class */ - NS_DECL_ISUPPORTS + virtual ~nsMsgHeaderParser(); + /* this macro defines QueryInterface, AddRef and Release for this class */ + NS_DECL_ISUPPORTS NS_DECL_NSIMSGHEADERPARSER }; diff --git a/mozilla/mailnews/mime/src/nsSimpleMimeConverterStub.cpp b/mozilla/mailnews/mime/src/nsSimpleMimeConverterStub.cpp index f062151fc91..124b4e389d7 100644 --- a/mozilla/mailnews/mime/src/nsSimpleMimeConverterStub.cpp +++ b/mozilla/mailnews/mime/src/nsSimpleMimeConverterStub.cpp @@ -43,7 +43,6 @@ #include "nsString.h" #include "nsReadableUtils.h" #include "nsCategoryManagerUtils.h" -#include "nsCRT.h" #include "nsCOMPtr.h" #include "nsAutoPtr.h" #include "nsISimpleMimeConverter.h" diff --git a/mozilla/mailnews/mime/src/nsStreamConverter.cpp b/mozilla/mailnews/mime/src/nsStreamConverter.cpp index 19455346a32..b8ed0788dc5 100644 --- a/mozilla/mailnews/mime/src/nsStreamConverter.cpp +++ b/mozilla/mailnews/mime/src/nsStreamConverter.cpp @@ -238,7 +238,7 @@ bridge_new_new_uri(void *bridgeStream, nsIURI *aURI, PRInt32 aOutputType) { if (!urlString.IsEmpty()) { - CRTFREEIF(*url_name); + NS_Free(*url_name); *url_name = ToNewCString(urlString); if (!(*url_name)) return NS_ERROR_OUT_OF_MEMORY; @@ -712,14 +712,12 @@ NS_IMETHODIMP nsStreamConverter::GetContentType(char **aOutputContentType) return NS_ERROR_NULL_POINTER; // since this method passes a string through an IDL file we need to use nsMemory to allocate it - // and not nsCRT::strdup! + // and not strdup! // (1) check to see if we have a real content type...use it first... if (!mRealContentType.IsEmpty()) *aOutputContentType = ToNewCString(mRealContentType); else if (mOutputFormat.LowerCaseEqualsLiteral("raw")) - { *aOutputContentType = (char *) nsMemory::Clone(UNKNOWN_CONTENT_TYPE, sizeof(UNKNOWN_CONTENT_TYPE)); - } else *aOutputContentType = ToNewCString(mOutputFormat); return NS_OK;