From f70cf8613dd5f205340fe318bfb3d64f6e08f055 Mon Sep 17 00:00:00 2001 From: "ducarroz%netscape.com" Date: Tue, 11 Dec 2001 03:35:20 +0000 Subject: [PATCH] Fix for bug 112784. The linked string array got broken which cause us to leak a bunch of strings. R=varada, SR=mscott --- mailnews/mime/cthandlers/vcard/mimevcrd.cpp | 2312 +++++++++-------- mailnews/mime/cthandlers/vcard/nsVCardObj.cpp | 989 ++++--- mailnews/mime/cthandlers/vcard/nsVCardObj.h | 404 ++- 3 files changed, 1845 insertions(+), 1860 deletions(-) diff --git a/mailnews/mime/cthandlers/vcard/mimevcrd.cpp b/mailnews/mime/cthandlers/vcard/mimevcrd.cpp index 4c204f3dc4bf..725debef0380 100644 --- a/mailnews/mime/cthandlers/vcard/mimevcrd.cpp +++ b/mailnews/mime/cthandlers/vcard/mimevcrd.cpp @@ -91,10 +91,10 @@ static int WriteOutVCardPhoneProperties (MimeObject *obj, VObject* v); static int WriteOutEachVCardPhoneProperty (MimeObject *obj, VObject* o); typedef struct - { - const char *attributeName; - int resourceId; - } AttributeName; + { + const char *attributeName; + int resourceId; + } AttributeName; #define kNumAttributes 12 @@ -110,7 +110,7 @@ static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID); /* This is the object definition. Note: we will set the superclass to NULL and manually set this on the class creation */ MimeDefClass(MimeInlineTextVCard, MimeInlineTextVCardClass, - mimeInlineTextVCardClass, NULL); + mimeInlineTextVCardClass, NULL); extern "C" MimeObjectClass * MIME_VCardCreateContentTypeHandlerClass(const char *content_type, @@ -165,9 +165,9 @@ MimeInlineTextVCard_parse_begin (MimeObject *obj) char *strcpySafe (char *dest, const char *src, size_t destLength) { - char *result = strncpy (dest, src, --destLength); - dest[destLength] = '\0'; - return result; + char *result = strncpy (dest, src, --destLength); + dest[destLength] = '\0'; + return result; } static int @@ -300,592 +300,592 @@ MimeInlineTextVCard_parse_eof (MimeObject *obj, PRBool abort_p) static int WriteEachLineToStream (MimeObject *obj, const char *line) { - int status = 0; - char *htmlLine; - int htmlLen = nsCRT::strlen(line) + 1; + int status = 0; + char *htmlLine; + int htmlLen = nsCRT::strlen(line) + 1; - htmlLine = (char *) PR_MALLOC (htmlLen); - if (htmlLine) - { - htmlLine[0] = '\0'; - PL_strcat (htmlLine, line); - status = COM_MimeObject_write(obj, htmlLine, nsCRT::strlen(htmlLine), PR_TRUE); - PR_Free ((void*) htmlLine); - } - else - status = VCARD_OUT_OF_MEMORY; + htmlLine = (char *) PR_MALLOC (htmlLen); + if (htmlLine) + { + htmlLine[0] = '\0'; + PL_strcat (htmlLine, line); + status = COM_MimeObject_write(obj, htmlLine, nsCRT::strlen(htmlLine), PR_TRUE); + PR_Free ((void*) htmlLine); + } + else + status = VCARD_OUT_OF_MEMORY; - return status; + return status; } static int OutputTable (MimeObject *obj, PRBool endTable, PRBool border, char *cellspacing, char *cellpadding, char *bgcolor) { - int status = 0; - char * htmlLine = NULL; + int status = 0; + char * htmlLine = NULL; - if (endTable) - { - status = WriteEachLineToStream (obj, ""); - } - else - { - int htmlLen = nsCRT::strlen("") + 1; - if (border) - htmlLen += nsCRT::strlen (" BORDER"); - if (cellspacing) - htmlLen += nsCRT::strlen(" CELLSPACING=") + nsCRT::strlen(cellspacing); - if (cellpadding) - htmlLen += nsCRT::strlen(" CELLPADDING=") + nsCRT::strlen(cellpadding); - if (bgcolor) - htmlLen += nsCRT::strlen(" BGCOLOR=") + nsCRT::strlen(bgcolor); - if (border || cellspacing || cellpadding || bgcolor) - htmlLen++; + if (endTable) + { + status = WriteEachLineToStream (obj, "
"); + } + else + { + int htmlLen = nsCRT::strlen("") + 1; + if (border) + htmlLen += nsCRT::strlen (" BORDER"); + if (cellspacing) + htmlLen += nsCRT::strlen(" CELLSPACING=") + nsCRT::strlen(cellspacing); + if (cellpadding) + htmlLen += nsCRT::strlen(" CELLPADDING=") + nsCRT::strlen(cellpadding); + if (bgcolor) + htmlLen += nsCRT::strlen(" BGCOLOR=") + nsCRT::strlen(bgcolor); + if (border || cellspacing || cellpadding || bgcolor) + htmlLen++; - htmlLine = (char *) PR_MALLOC (htmlLen); - if (htmlLine) - { - htmlLine[0] = '\0'; - PL_strcat (htmlLine, ""); + PL_strcat (htmlLine, ">"); - status = COM_MimeObject_write(obj, htmlLine, nsCRT::strlen(htmlLine), PR_TRUE); - PR_Free ((void*) htmlLine); - } - else - status = VCARD_OUT_OF_MEMORY; - } - return status; + status = COM_MimeObject_write(obj, htmlLine, nsCRT::strlen(htmlLine), PR_TRUE); + PR_Free ((void*) htmlLine); + } + else + status = VCARD_OUT_OF_MEMORY; + } + return status; } static int OutputTableRowOrData(MimeObject *obj, PRBool outputRow, - PRBool end, char * align, - char* valign, char* colspan, - char* width) + PRBool end, char * align, + char* valign, char* colspan, + char* width) { - int status = 0; - char * htmlLine = NULL; + int status = 0; + char * htmlLine = NULL; - if (end) - if (outputRow) - status = WriteEachLineToStream (obj, ""); - else - status = WriteEachLineToStream (obj, ""); - else - { - int htmlLen = nsCRT::strlen("") + 1; - if (align) - htmlLen += nsCRT::strlen(" ALIGN=") + nsCRT::strlen(align); - if (colspan) - htmlLen += nsCRT::strlen(" COLSPAN=") + nsCRT::strlen(colspan); - if (width) - htmlLen += nsCRT::strlen(" WIDTH=") + nsCRT::strlen(width); - if (valign) - htmlLen += nsCRT::strlen(" VALIGN=") + nsCRT::strlen(valign); - if (align || valign || colspan || width) - htmlLen++; + if (end) + if (outputRow) + status = WriteEachLineToStream (obj, ""); + else + status = WriteEachLineToStream (obj, ""); + else + { + int htmlLen = nsCRT::strlen("") + 1; + if (align) + htmlLen += nsCRT::strlen(" ALIGN=") + nsCRT::strlen(align); + if (colspan) + htmlLen += nsCRT::strlen(" COLSPAN=") + nsCRT::strlen(colspan); + if (width) + htmlLen += nsCRT::strlen(" WIDTH=") + nsCRT::strlen(width); + if (valign) + htmlLen += nsCRT::strlen(" VALIGN=") + nsCRT::strlen(valign); + if (align || valign || colspan || width) + htmlLen++; - htmlLine = (char *) PR_MALLOC (htmlLen); - if (htmlLine) - { - htmlLine[0] = '\0'; - if (outputRow) - PL_strcat (htmlLine, ""); + PL_strcat (htmlLine, ">"); - status = COM_MimeObject_write(obj, htmlLine, nsCRT::strlen(htmlLine), PR_TRUE); - PR_Free ((void*) htmlLine); - } - else - status = VCARD_OUT_OF_MEMORY; - } + status = COM_MimeObject_write(obj, htmlLine, nsCRT::strlen(htmlLine), PR_TRUE); + PR_Free ((void*) htmlLine); + } + else + status = VCARD_OUT_OF_MEMORY; + } - return status; + return status; } static int OutputFont(MimeObject *obj, PRBool endFont, char * size, char* color) { - int status = 0; - char * htmlLine = NULL; + int status = 0; + char * htmlLine = NULL; - if (endFont) - status = WriteEachLineToStream (obj, ""); - else - { - int htmlLen = nsCRT::strlen("") + 1; - if (size) - htmlLen += nsCRT::strlen(" SIZE=") + nsCRT::strlen(size); - if (color) - htmlLen += nsCRT::strlen(" COLOR=") + nsCRT::strlen(color); - if (size || color) - htmlLen++; + if (endFont) + status = WriteEachLineToStream (obj, ""); + else + { + int htmlLen = nsCRT::strlen("") + 1; + if (size) + htmlLen += nsCRT::strlen(" SIZE=") + nsCRT::strlen(size); + if (color) + htmlLen += nsCRT::strlen(" COLOR=") + nsCRT::strlen(color); + if (size || color) + htmlLen++; - htmlLine = (char *) PR_MALLOC (htmlLen); - if (htmlLine) - { - htmlLine[0] = '\0'; - PL_strcat (htmlLine, ""); + PL_strcat (htmlLine, ">"); - status = COM_MimeObject_write(obj, htmlLine, nsCRT::strlen(htmlLine), PR_TRUE); - PR_Free ((void*) htmlLine); - } - else - status = VCARD_OUT_OF_MEMORY; - } + status = COM_MimeObject_write(obj, htmlLine, nsCRT::strlen(htmlLine), PR_TRUE); + PR_Free ((void*) htmlLine); + } + else + status = VCARD_OUT_OF_MEMORY; + } - return status; + return status; } static int OutputVcardAttribute(MimeObject *obj, VObject *v, const char* id) { - int status = 0; - VObject *prop = NULL; - char *string = NULL; + int status = 0; + VObject *prop = NULL; + char *string = NULL; - prop = isAPropertyOf(v, id); - if (prop) - if (VALUE_TYPE(prop)) - { - if (VALUE_TYPE(prop) != VCVT_RAW) - string = fakeCString (vObjectUStringZValue(prop)); - else - { - string = (char *)PR_MALLOC(nsCRT::strlen((char *) vObjectAnyValue(prop)) + 1); - if (string) - PL_strcpy(string, (char *) vObjectAnyValue(prop)); - } - if (string) { - status = OutputFont(obj, PR_FALSE, "-1", NULL); - if (status < 0) { - PR_FREEIF (string); - return status; - } - status = WriteLineToStream (obj, string, PR_TRUE); - PR_FREEIF (string); - if (status < 0) return status; - status = OutputFont(obj, PR_TRUE, NULL, NULL); - if (status < 0) return status; - } - } + prop = isAPropertyOf(v, id); + if (prop) + if (VALUE_TYPE(prop)) + { + if (VALUE_TYPE(prop) != VCVT_RAW) + string = fakeCString (vObjectUStringZValue(prop)); + else + { + string = (char *)PR_MALLOC(nsCRT::strlen((char *) vObjectAnyValue(prop)) + 1); + if (string) + PL_strcpy(string, (char *) vObjectAnyValue(prop)); + } + if (string) { + status = OutputFont(obj, PR_FALSE, "-1", NULL); + if (status < 0) { + PR_FREEIF (string); + return status; + } + status = WriteLineToStream (obj, string, PR_TRUE); + PR_FREEIF (string); + if (status < 0) return status; + status = OutputFont(obj, PR_TRUE, NULL, NULL); + if (status < 0) return status; + } + } - return 0; + return 0; } static int OutputBasicVcard(MimeObject *obj, VObject *v) { - int status = 0; - char * htmlLine1 = NULL; - char * htmlLine2 = NULL; - char * htmlLine = NULL; - VObject *prop = NULL; - VObject* prop2 = NULL; - char * urlstring = NULL; - char * namestring = NULL; - char * emailstring = NULL; + int status = 0; + char * htmlLine1 = NULL; + char * htmlLine2 = NULL; + char * htmlLine = NULL; + VObject *prop = NULL; + VObject* prop2 = NULL; + char * urlstring = NULL; + char * namestring = NULL; + char * emailstring = NULL; - /* get the name and email */ - prop = isAPropertyOf(v, VCFullNameProp); - if (prop) - { - if (VALUE_TYPE(prop)) - { - if (VALUE_TYPE(prop) != VCVT_RAW) - namestring = fakeCString (vObjectUStringZValue(prop)); - else - { - namestring = (char *)PR_MALLOC(nsCRT::strlen((char *) vObjectAnyValue(prop)) + 1); - if (namestring) - PL_strcpy(namestring, (char *) vObjectAnyValue(prop)); - } - if (namestring) - { - prop = isAPropertyOf(v, VCURLProp); - if (prop) - { - urlstring = fakeCString (vObjectUStringZValue(prop)); - if (urlstring) - htmlLine1 = PR_smprintf ("%s ", urlstring, namestring); - else - htmlLine1 = PR_smprintf ("%s ", namestring); - PR_FREEIF (urlstring); - } - else - htmlLine1 = PR_smprintf ("%s ", namestring); + /* get the name and email */ + prop = isAPropertyOf(v, VCFullNameProp); + if (prop) + { + if (VALUE_TYPE(prop)) + { + if (VALUE_TYPE(prop) != VCVT_RAW) + namestring = fakeCString (vObjectUStringZValue(prop)); + else + { + namestring = (char *)PR_MALLOC(nsCRT::strlen((char *) vObjectAnyValue(prop)) + 1); + if (namestring) + PL_strcpy(namestring, (char *) vObjectAnyValue(prop)); + } + if (namestring) + { + prop = isAPropertyOf(v, VCURLProp); + if (prop) + { + urlstring = fakeCString (vObjectUStringZValue(prop)); + if (urlstring) + htmlLine1 = PR_smprintf ("%s ", urlstring, namestring); + else + htmlLine1 = PR_smprintf ("%s ", namestring); + PR_FREEIF (urlstring); + } + else + htmlLine1 = PR_smprintf ("%s ", namestring); - /* get the email address */ - prop = isAPropertyOf(v, VCEmailAddressProp); - if (prop) - { - emailstring = fakeCString (vObjectUStringZValue(prop)); - if (emailstring) - { - /* if its an internet address prepend the mailto url */ - prop2 = isAPropertyOf(prop, VCInternetProp); - if (prop2) - htmlLine2 = PR_smprintf ("<%s>", emailstring, emailstring); - else - htmlLine2 = PR_smprintf ("%s", emailstring); - PR_FREEIF (emailstring); - } - } + /* get the email address */ + prop = isAPropertyOf(v, VCEmailAddressProp); + if (prop) + { + emailstring = fakeCString (vObjectUStringZValue(prop)); + if (emailstring) + { + /* if its an internet address prepend the mailto url */ + prop2 = isAPropertyOf(prop, VCInternetProp); + if (prop2) + htmlLine2 = PR_smprintf ("<%s>", emailstring, emailstring); + else + htmlLine2 = PR_smprintf ("%s", emailstring); + PR_FREEIF (emailstring); + } + } - if (!htmlLine1 && !htmlLine2) - { - PR_FREEIF (htmlLine1); - PR_FREEIF (htmlLine2); - return VCARD_OUT_OF_MEMORY; - } - else - { - htmlLine = NS_MsgSACat (&htmlLine, htmlLine1); - htmlLine = NS_MsgSACat (&htmlLine, htmlLine2); - } + PR_FREEIF (namestring); + if (!htmlLine1 && !htmlLine2) + { + PR_FREEIF (htmlLine1); + PR_FREEIF (htmlLine2); + return VCARD_OUT_OF_MEMORY; + } + else + { + htmlLine = NS_MsgSACat (&htmlLine, htmlLine1); + htmlLine = NS_MsgSACat (&htmlLine, htmlLine2); + } - PR_FREEIF (htmlLine1); - PR_FREEIF (htmlLine2); - PR_FREEIF (namestring); - } - } - } + PR_FREEIF (htmlLine1); + PR_FREEIF (htmlLine2); + } + } + } - status = OutputTable (obj, PR_FALSE, PR_FALSE, "0", "0", NULL); - if (status < 0) { - PR_FREEIF (htmlLine); - return status; - } - if (htmlLine) - { - status = OutputTableRowOrData(obj, PR_TRUE, PR_FALSE, "LEFT", "TOP", NULL, NULL); - if (status < 0) { - PR_Free (htmlLine); - return status; - } - status = OutputTableRowOrData (obj, PR_FALSE, PR_FALSE, NULL, NULL, NULL, NULL); - if (status < 0) { - PR_Free (htmlLine); - return status; - } + status = OutputTable (obj, PR_FALSE, PR_FALSE, "0", "0", NULL); + if (status < 0) { + PR_FREEIF (htmlLine); + return status; + } + if (htmlLine) + { + status = OutputTableRowOrData(obj, PR_TRUE, PR_FALSE, "LEFT", "TOP", NULL, NULL); + if (status < 0) { + PR_Free (htmlLine); + return status; + } + status = OutputTableRowOrData (obj, PR_FALSE, PR_FALSE, NULL, NULL, NULL, NULL); + if (status < 0) { + PR_Free (htmlLine); + return status; + } - status = WriteLineToStream (obj, htmlLine, PR_TRUE); - PR_Free (htmlLine); - if (status < 0) return status; - status = OutputTableRowOrData (obj, PR_FALSE, PR_TRUE, NULL, NULL, NULL, NULL); - if (status < 0) return status; - status = OutputTableRowOrData(obj, PR_TRUE, PR_TRUE, NULL, NULL, NULL, NULL); - if (status < 0) return status; - } - else - status = VCARD_OUT_OF_MEMORY; + status = WriteLineToStream (obj, htmlLine, PR_TRUE); + PR_Free (htmlLine); + if (status < 0) return status; + status = OutputTableRowOrData (obj, PR_FALSE, PR_TRUE, NULL, NULL, NULL, NULL); + if (status < 0) return status; + status = OutputTableRowOrData(obj, PR_TRUE, PR_TRUE, NULL, NULL, NULL, NULL); + if (status < 0) return status; + } + else + status = VCARD_OUT_OF_MEMORY; - status = OutputTableRowOrData(obj, PR_TRUE, PR_FALSE, NULL, NULL, NULL, NULL); - if (status < 0) return status; - status = OutputTableRowOrData (obj, PR_FALSE, PR_FALSE, NULL, NULL, NULL, NULL); - if (status < 0) return status; - /* output the title */ - status = OutputVcardAttribute (obj, v, VCTitleProp); - if (status < 0) return status; - /* write out the org name and company name */ - prop = isAPropertyOf(v, VCOrgProp); - if (prop) - { - status = OutputVcardAttribute (obj, prop, VCOrgNameProp); - if (status < 0) return status; - status = OutputVcardAttribute (obj, prop, VCOrgUnitProp); - if (status < 0) return status; - status = OutputVcardAttribute (obj, prop, VCOrgUnit2Prop); - if (status < 0) return status; - status = OutputVcardAttribute (obj, prop, VCOrgUnit3Prop); - if (status < 0) return status; - } - status = OutputTableRowOrData (obj, PR_FALSE, PR_TRUE, NULL, NULL, NULL, NULL); - if (status < 0) return status; - status = OutputTableRowOrData (obj, PR_TRUE, PR_TRUE, NULL, NULL, NULL, NULL); - if (status < 0) return status; - status = OutputTable (obj, PR_TRUE, PR_FALSE, NULL, NULL, NULL); - if (status < 0) return status; + status = OutputTableRowOrData(obj, PR_TRUE, PR_FALSE, NULL, NULL, NULL, NULL); + if (status < 0) return status; + status = OutputTableRowOrData (obj, PR_FALSE, PR_FALSE, NULL, NULL, NULL, NULL); + if (status < 0) return status; + /* output the title */ + status = OutputVcardAttribute (obj, v, VCTitleProp); + if (status < 0) return status; + /* write out the org name and company name */ + prop = isAPropertyOf(v, VCOrgProp); + if (prop) + { + status = OutputVcardAttribute (obj, prop, VCOrgNameProp); + if (status < 0) return status; + status = OutputVcardAttribute (obj, prop, VCOrgUnitProp); + if (status < 0) return status; + status = OutputVcardAttribute (obj, prop, VCOrgUnit2Prop); + if (status < 0) return status; + status = OutputVcardAttribute (obj, prop, VCOrgUnit3Prop); + if (status < 0) return status; + } + status = OutputTableRowOrData (obj, PR_FALSE, PR_TRUE, NULL, NULL, NULL, NULL); + if (status < 0) return status; + status = OutputTableRowOrData (obj, PR_TRUE, PR_TRUE, NULL, NULL, NULL, NULL); + if (status < 0) return status; + status = OutputTable (obj, PR_TRUE, PR_FALSE, NULL, NULL, NULL); + if (status < 0) return status; - return 0; + return 0; } static int OutputAdvancedVcard(MimeObject *obj, VObject *v) { - int status = 0; - char * htmlLine1 = NULL; - char * htmlLine2 = NULL; - VObject *prop = NULL; - VObject* prop2 = NULL; - char * urlstring = NULL; - char * namestring = NULL; - char * emailstring = NULL; - int numEmail = 0; + int status = 0; + char * htmlLine1 = NULL; + char * htmlLine2 = NULL; + VObject *prop = NULL; + VObject* prop2 = NULL; + char * urlstring = NULL; + char * namestring = NULL; + char * emailstring = NULL; + int numEmail = 0; - status = OutputTable (obj, PR_FALSE, PR_FALSE, "0", "0", NULL); - if (status < 0) return status; - /* beginning of first row */ - status = OutputTableRowOrData(obj, PR_TRUE, PR_FALSE, "LEFT", "TOP", NULL, NULL); - if (status < 0) return status; - status = OutputTableRowOrData (obj, PR_FALSE, PR_FALSE, "LEFT", "TOP", "3", NULL); - if (status < 0) return status; + status = OutputTable (obj, PR_FALSE, PR_FALSE, "0", "0", NULL); + if (status < 0) return status; + /* beginning of first row */ + status = OutputTableRowOrData(obj, PR_TRUE, PR_FALSE, "LEFT", "TOP", NULL, NULL); + if (status < 0) return status; + status = OutputTableRowOrData (obj, PR_FALSE, PR_FALSE, "LEFT", "TOP", "3", NULL); + if (status < 0) return status; - /* get the name and email */ - prop = isAPropertyOf(v, VCFullNameProp); - if (prop) - { - if (VALUE_TYPE(prop)) - { - if (VALUE_TYPE(prop) != VCVT_RAW) - namestring = fakeCString (vObjectUStringZValue(prop)); - else - { - namestring = (char *)PR_MALLOC(nsCRT::strlen((char *) vObjectAnyValue(prop)) + 1); - if (namestring) - PL_strcpy(namestring, (char *) vObjectAnyValue(prop)); - } - if (namestring) - { - prop = isAPropertyOf(v, VCURLProp); - if (prop) - { - urlstring = fakeCString (vObjectUStringZValue(prop)); - if (urlstring) - htmlLine1 = PR_smprintf ("%s ", urlstring, namestring); - else - htmlLine1 = PR_smprintf ("%s ", namestring); - PR_FREEIF (urlstring); - } - else - htmlLine1 = PR_smprintf ("%s ", namestring); + /* get the name and email */ + prop = isAPropertyOf(v, VCFullNameProp); + if (prop) + { + if (VALUE_TYPE(prop)) + { + if (VALUE_TYPE(prop) != VCVT_RAW) + namestring = fakeCString (vObjectUStringZValue(prop)); + else + { + namestring = (char *)PR_MALLOC(nsCRT::strlen((char *) vObjectAnyValue(prop)) + 1); + if (namestring) + PL_strcpy(namestring, (char *) vObjectAnyValue(prop)); + } + if (namestring) + { + prop = isAPropertyOf(v, VCURLProp); + if (prop) + { + urlstring = fakeCString (vObjectUStringZValue(prop)); + if (urlstring) + htmlLine1 = PR_smprintf ("%s ", urlstring, namestring); + else + htmlLine1 = PR_smprintf ("%s ", namestring); + PR_FREEIF (urlstring); + } + else + htmlLine1 = PR_smprintf ("%s ", namestring); - PR_FREEIF (namestring); - } - if (!htmlLine1) - { - return VCARD_OUT_OF_MEMORY; - } - } - } - /* output the name if there was one */ - if (htmlLine1) - { - status = WriteLineToStream (obj, htmlLine1, PR_TRUE); - PR_FREEIF (htmlLine1); - if (status < 0) return status; - } + PR_FREEIF (namestring); + } + if (!htmlLine1) + { + return VCARD_OUT_OF_MEMORY; + } + } + } + /* output the name if there was one */ + if (htmlLine1) + { + status = WriteLineToStream (obj, htmlLine1, PR_TRUE); + PR_FREEIF (htmlLine1); + if (status < 0) return status; + } - status = OutputTableRowOrData (obj, PR_FALSE, PR_TRUE, NULL, NULL, NULL, NULL); - if (status < 0) return status; - status = OutputTableRowOrData(obj, PR_TRUE, PR_TRUE, NULL, NULL, NULL, NULL); - if (status < 0) return status; - - /* beginning of second row */ - status = OutputTableRowOrData(obj, PR_TRUE, PR_FALSE, "LEFT", "TOP", NULL, NULL); - if (status < 0) return status; - status = OutputTableRowOrData (obj, PR_FALSE, PR_FALSE, "LEFT", "TOP", NULL, NULL); - if (status < 0) return status; - /* output the title */ - status = OutputVcardAttribute (obj, v, VCTitleProp); - if (status < 0) return status; - /* write out the org name and company name */ - prop = isAPropertyOf(v, VCOrgProp); - if (prop) - { - status = OutputVcardAttribute (obj, prop, VCOrgNameProp); - if (status < 0) return status; - status = OutputVcardAttribute (obj, prop, VCOrgUnitProp); - if (status < 0) return status; - status = OutputVcardAttribute (obj, prop, VCOrgUnit2Prop); - if (status < 0) return status; - status = OutputVcardAttribute (obj, prop, VCOrgUnit3Prop); - if (status < 0) return status; - } - status = OutputTableRowOrData (obj, PR_FALSE, PR_TRUE, NULL, NULL, NULL, NULL); - if (status < 0) return status; + status = OutputTableRowOrData (obj, PR_FALSE, PR_TRUE, NULL, NULL, NULL, NULL); + if (status < 0) return status; + status = OutputTableRowOrData(obj, PR_TRUE, PR_TRUE, NULL, NULL, NULL, NULL); + if (status < 0) return status; + + /* beginning of second row */ + status = OutputTableRowOrData(obj, PR_TRUE, PR_FALSE, "LEFT", "TOP", NULL, NULL); + if (status < 0) return status; + status = OutputTableRowOrData (obj, PR_FALSE, PR_FALSE, "LEFT", "TOP", NULL, NULL); + if (status < 0) return status; + /* output the title */ + status = OutputVcardAttribute (obj, v, VCTitleProp); + if (status < 0) return status; + /* write out the org name and company name */ + prop = isAPropertyOf(v, VCOrgProp); + if (prop) + { + status = OutputVcardAttribute (obj, prop, VCOrgNameProp); + if (status < 0) return status; + status = OutputVcardAttribute (obj, prop, VCOrgUnitProp); + if (status < 0) return status; + status = OutputVcardAttribute (obj, prop, VCOrgUnit2Prop); + if (status < 0) return status; + status = OutputVcardAttribute (obj, prop, VCOrgUnit3Prop); + if (status < 0) return status; + } + status = OutputTableRowOrData (obj, PR_FALSE, PR_TRUE, NULL, NULL, NULL, NULL); + if (status < 0) return status; - status = OutputTableRowOrData (obj, PR_FALSE, PR_FALSE , "LEFT", "TOP", NULL, "\"10\""); - if (status < 0) return status; - status = OutputTableRowOrData (obj, PR_FALSE, PR_TRUE, NULL, NULL, NULL, NULL); - if (status < 0) return status; + status = OutputTableRowOrData (obj, PR_FALSE, PR_FALSE , "LEFT", "TOP", NULL, "\"10\""); + if (status < 0) return status; + status = OutputTableRowOrData (obj, PR_FALSE, PR_TRUE, NULL, NULL, NULL, NULL); + if (status < 0) return status; - status = OutputTableRowOrData (obj, PR_FALSE, PR_FALSE, "LEFT", "TOP", NULL, NULL); - if (status < 0) return status; + status = OutputTableRowOrData (obj, PR_FALSE, PR_FALSE, "LEFT", "TOP", NULL, NULL); + if (status < 0) return status; - /* get the email address */ - prop = isAPropertyOf(v, VCEmailAddressProp); - if (prop) - { - emailstring = fakeCString (vObjectUStringZValue(prop)); - if (emailstring) - { - numEmail++; - /* if its an internet address prepend the mailto url */ - prop2 = isAPropertyOf(prop, VCInternetProp); - if (prop2) - htmlLine2 = PR_smprintf ("<%s>", emailstring, emailstring); - else - htmlLine2 = PR_smprintf ("%s", emailstring); + /* get the email address */ + prop = isAPropertyOf(v, VCEmailAddressProp); + if (prop) + { + emailstring = fakeCString (vObjectUStringZValue(prop)); + if (emailstring) + { + numEmail++; + /* if its an internet address prepend the mailto url */ + prop2 = isAPropertyOf(prop, VCInternetProp); + if (prop2) + htmlLine2 = PR_smprintf ("<%s>", emailstring, emailstring); + else + htmlLine2 = PR_smprintf ("%s", emailstring); - PR_FREEIF (emailstring); - } - if (!htmlLine2) - { - return VCARD_OUT_OF_MEMORY; - } - } - /* output email address */ - if (htmlLine2) - { - status = OutputFont(obj, PR_FALSE, "-1", NULL); - if (status < 0) { - PR_FREEIF (htmlLine2); - return status; - } - status = WriteLineToStream (obj, htmlLine2, PR_TRUE); - PR_FREEIF (htmlLine2); - if (status < 0) return status; - status = OutputFont(obj, PR_TRUE, NULL, NULL); - if (status < 0) return status; - /* output html mail setting only if its true */ - prop = isAPropertyOf(v, VCUseHTML); - if (prop) - { - if (VALUE_TYPE(prop)) - { - namestring = fakeCString (vObjectUStringZValue(prop)); - if (namestring) - if (nsCRT::strcasecmp (namestring, "TRUE") == 0) - { - PR_FREEIF (namestring); - status = OutputFont(obj, PR_FALSE, "-1", NULL); - if (status < 0) return status; + PR_FREEIF (emailstring); + } + if (!htmlLine2) + { + return VCARD_OUT_OF_MEMORY; + } + } + /* output email address */ + if (htmlLine2) + { + status = OutputFont(obj, PR_FALSE, "-1", NULL); + if (status < 0) { + PR_FREEIF (htmlLine2); + return status; + } + status = WriteLineToStream (obj, htmlLine2, PR_TRUE); + PR_FREEIF (htmlLine2); + if (status < 0) return status; + status = OutputFont(obj, PR_TRUE, NULL, NULL); + if (status < 0) return status; + /* output html mail setting only if its true */ + prop = isAPropertyOf(v, VCUseHTML); + if (prop) + { + if (VALUE_TYPE(prop)) + { + namestring = fakeCString (vObjectUStringZValue(prop)); + if (namestring) + if (nsCRT::strcasecmp (namestring, "TRUE") == 0) + { + PR_FREEIF (namestring); + status = OutputFont(obj, PR_FALSE, "-1", NULL); + if (status < 0) return status; char *tString = VCardGetStringByID(VCARD_LDAP_USEHTML); - status = WriteLineToStream (obj, tString, PR_FALSE); + status = WriteLineToStream (obj, tString, PR_FALSE); PR_FREEIF(tString); - if (status < 0) return status; - status = OutputFont(obj, PR_TRUE, NULL, NULL); - if (status < 0) return status; - } - else - PR_FREEIF (namestring); - } - } - } - status = OutputTableRowOrData (obj, PR_FALSE, PR_TRUE, NULL, NULL, NULL, NULL); - if (status < 0) return status; - status = OutputTableRowOrData(obj, PR_TRUE, PR_TRUE, NULL, NULL, NULL, NULL); - if (status < 0) return status; + if (status < 0) return status; + status = OutputFont(obj, PR_TRUE, NULL, NULL); + if (status < 0) return status; + } + else + PR_FREEIF (namestring); + } + } + } + status = OutputTableRowOrData (obj, PR_FALSE, PR_TRUE, NULL, NULL, NULL, NULL); + if (status < 0) return status; + status = OutputTableRowOrData(obj, PR_TRUE, PR_TRUE, NULL, NULL, NULL, NULL); + if (status < 0) return status; - /* beginning of third row */ - /* write out address information if we have any */ - status = OutputTableRowOrData(obj, PR_TRUE, PR_FALSE, "LEFT", "TOP", NULL, NULL); - if (status < 0) return status; - /* first column */ - status = OutputTableRowOrData (obj, PR_FALSE, PR_FALSE, "LEFT", "TOP", NULL, NULL); - if (status < 0) return status; - prop = isAPropertyOf(v, VCAdrProp); - if (prop) - { - status = OutputVcardAttribute (obj, prop, VCPostalBoxProp); - if (status < 0) return status; - status = OutputVcardAttribute (obj, prop, VCExtAddressProp); - if (status < 0) return status; - status = OutputVcardAttribute (obj, prop, VCStreetAddressProp); - if (status < 0) return status; - status = OutputVcardAttribute (obj, prop, VCCityProp); - if (status < 0) return status; - status = OutputVcardAttribute (obj, prop, VCRegionProp); - if (status < 0) return status; - status = OutputVcardAttribute (obj, prop, VCPostalCodeProp); - if (status < 0) return status; - status = OutputVcardAttribute (obj, prop, VCCountryNameProp); - if (status < 0) return status; - } - status = OutputTableRowOrData (obj, PR_FALSE, PR_TRUE, NULL, NULL, NULL, NULL); - if (status < 0) return status; + /* beginning of third row */ + /* write out address information if we have any */ + status = OutputTableRowOrData(obj, PR_TRUE, PR_FALSE, "LEFT", "TOP", NULL, NULL); + if (status < 0) return status; + /* first column */ + status = OutputTableRowOrData (obj, PR_FALSE, PR_FALSE, "LEFT", "TOP", NULL, NULL); + if (status < 0) return status; + prop = isAPropertyOf(v, VCAdrProp); + if (prop) + { + status = OutputVcardAttribute (obj, prop, VCPostalBoxProp); + if (status < 0) return status; + status = OutputVcardAttribute (obj, prop, VCExtAddressProp); + if (status < 0) return status; + status = OutputVcardAttribute (obj, prop, VCStreetAddressProp); + if (status < 0) return status; + status = OutputVcardAttribute (obj, prop, VCCityProp); + if (status < 0) return status; + status = OutputVcardAttribute (obj, prop, VCRegionProp); + if (status < 0) return status; + status = OutputVcardAttribute (obj, prop, VCPostalCodeProp); + if (status < 0) return status; + status = OutputVcardAttribute (obj, prop, VCCountryNameProp); + if (status < 0) return status; + } + status = OutputTableRowOrData (obj, PR_FALSE, PR_TRUE, NULL, NULL, NULL, NULL); + if (status < 0) return status; - /* second column */ - status = OutputTableRowOrData (obj, PR_FALSE, PR_FALSE , NULL, NULL, NULL, NULL); - if (status < 0) return status; - status = OutputTableRowOrData (obj, PR_FALSE, PR_TRUE, NULL, NULL, NULL, NULL); - if (status < 0) return status; + /* second column */ + status = OutputTableRowOrData (obj, PR_FALSE, PR_FALSE , NULL, NULL, NULL, NULL); + if (status < 0) return status; + status = OutputTableRowOrData (obj, PR_FALSE, PR_TRUE, NULL, NULL, NULL, NULL); + if (status < 0) return status; - /* third column */ - status = OutputTableRowOrData (obj, PR_FALSE, PR_FALSE, "LEFT", "TOP", NULL, NULL); - if (status < 0) return status; - /* output telephone fields */ - status = WriteOutVCardPhoneProperties (obj, v); - if (status < 0) return status; - /* output conference fields */ - status = OutputFont(obj, PR_FALSE, "-1", NULL); - if (status < 0) return status; - prop = isAPropertyOf(v, VCCooltalk); - if (prop) - { + /* third column */ + status = OutputTableRowOrData (obj, PR_FALSE, PR_FALSE, "LEFT", "TOP", NULL, NULL); + if (status < 0) return status; + /* output telephone fields */ + status = WriteOutVCardPhoneProperties (obj, v); + if (status < 0) return status; + /* output conference fields */ + status = OutputFont(obj, PR_FALSE, "-1", NULL); + if (status < 0) return status; + prop = isAPropertyOf(v, VCCooltalk); + if (prop) + { char *tString = VCardGetStringByID(VCARD_ADDR_CONFINFO); - WriteLineToStream (obj, tString, PR_FALSE); + WriteLineToStream (obj, tString, PR_FALSE); PR_FREEIF(tString); - if (status < 0) return status; - prop2 = isAPropertyOf(prop, VCUseServer); + if (status < 0) return status; + prop2 = isAPropertyOf(prop, VCUseServer); if (prop2) { if (VALUE_TYPE(prop2)) @@ -914,378 +914,378 @@ static int OutputAdvancedVcard(MimeObject *obj, VObject *v) if (status < 0) return status; } } - status = OutputVcardAttribute (obj, prop, VCCooltalkAddress); - if (status < 0) return status; - } + status = OutputVcardAttribute (obj, prop, VCCooltalkAddress); + if (status < 0) return status; + } - status = OutputFont(obj, PR_TRUE, NULL, NULL); - if (status < 0) return status; - status = OutputTableRowOrData (obj, PR_FALSE, PR_TRUE, NULL, NULL, NULL, NULL); - if (status < 0) return status; + status = OutputFont(obj, PR_TRUE, NULL, NULL); + if (status < 0) return status; + status = OutputTableRowOrData (obj, PR_FALSE, PR_TRUE, NULL, NULL, NULL, NULL); + if (status < 0) return status; - status = OutputTableRowOrData(obj, PR_TRUE, PR_TRUE, NULL, NULL, NULL, NULL); - if (status < 0) return status; + status = OutputTableRowOrData(obj, PR_TRUE, PR_TRUE, NULL, NULL, NULL, NULL); + if (status < 0) return status; - /* beginning of last row */ - /* output notes field */ - prop = isAPropertyOf(v, VCCommentProp); - if (prop) - { - status = OutputTableRowOrData(obj, PR_TRUE, PR_FALSE, "LEFT", "TOP", NULL, NULL); - if (status < 0) return status; - status = OutputTableRowOrData (obj, PR_FALSE, PR_FALSE, "LEFT", "TOP", "3", NULL); - if (status < 0) return status; - status = OutputVcardAttribute (obj, v, VCCommentProp); - if (status < 0) return status; - status = OutputTableRowOrData (obj, PR_FALSE, PR_TRUE, NULL, NULL, NULL, NULL); - if (status < 0) return status; - status = OutputTableRowOrData(obj, PR_TRUE, PR_TRUE, NULL, NULL, NULL, NULL); - if (status < 0) return status; - } + /* beginning of last row */ + /* output notes field */ + prop = isAPropertyOf(v, VCCommentProp); + if (prop) + { + status = OutputTableRowOrData(obj, PR_TRUE, PR_FALSE, "LEFT", "TOP", NULL, NULL); + if (status < 0) return status; + status = OutputTableRowOrData (obj, PR_FALSE, PR_FALSE, "LEFT", "TOP", "3", NULL); + if (status < 0) return status; + status = OutputVcardAttribute (obj, v, VCCommentProp); + if (status < 0) return status; + status = OutputTableRowOrData (obj, PR_FALSE, PR_TRUE, NULL, NULL, NULL, NULL); + if (status < 0) return status; + status = OutputTableRowOrData(obj, PR_TRUE, PR_TRUE, NULL, NULL, NULL, NULL); + if (status < 0) return status; + } - status = OutputTable (obj, PR_TRUE, PR_FALSE, NULL, NULL, NULL); - if (status < 0) return status; + status = OutputTable (obj, PR_TRUE, PR_FALSE, NULL, NULL, NULL); + if (status < 0) return status; - /* output second table containing all the additional info */ - status = OutputTable (obj, PR_FALSE, PR_FALSE, "0", "0", NULL); - if (status < 0) return status; - /* beginning of first row */ - status = OutputTableRowOrData(obj, PR_TRUE, PR_FALSE, "LEFT", "TOP", NULL, NULL); - if (status < 0) return status; - status = OutputTableRowOrData (obj, PR_FALSE, PR_FALSE, "LEFT", "TOP", "2", NULL); - if (status < 0) return status; - /* output the additional info header */ - status = OutputFont(obj, PR_FALSE, "-1", NULL); - if (status < 0) return status; + /* output second table containing all the additional info */ + status = OutputTable (obj, PR_FALSE, PR_FALSE, "0", "0", NULL); + if (status < 0) return status; + /* beginning of first row */ + status = OutputTableRowOrData(obj, PR_TRUE, PR_FALSE, "LEFT", "TOP", NULL, NULL); + if (status < 0) return status; + status = OutputTableRowOrData (obj, PR_FALSE, PR_FALSE, "LEFT", "TOP", "2", NULL); + if (status < 0) return status; + /* output the additional info header */ + status = OutputFont(obj, PR_FALSE, "-1", NULL); + if (status < 0) return status; char *tString = VCardGetStringByID(VCARD_ADDR_ADDINFO); - status = WriteLineToStream (obj, tString, PR_FALSE); + status = WriteLineToStream (obj, tString, PR_FALSE); PR_FREEIF(tString); - if (status < 0) return status; - status = OutputFont(obj, PR_TRUE, NULL, NULL); - if (status < 0) return status; - status = OutputTableRowOrData (obj, PR_FALSE, PR_TRUE, NULL, NULL, NULL, NULL); - if (status < 0) return status; - status = OutputTableRowOrData(obj, PR_TRUE, PR_TRUE, NULL, NULL, NULL, NULL); - if (status < 0) return status; - - /* beginning of remaining rows */ - status = WriteOutVCardProperties (obj, v, &numEmail); - if (status < 0) return status; + if (status < 0) return status; + status = OutputFont(obj, PR_TRUE, NULL, NULL); + if (status < 0) return status; + status = OutputTableRowOrData (obj, PR_FALSE, PR_TRUE, NULL, NULL, NULL, NULL); + if (status < 0) return status; + status = OutputTableRowOrData(obj, PR_TRUE, PR_TRUE, NULL, NULL, NULL, NULL); + if (status < 0) return status; + + /* beginning of remaining rows */ + status = WriteOutVCardProperties (obj, v, &numEmail); + if (status < 0) return status; - status = OutputTable (obj, PR_TRUE, PR_FALSE, NULL, NULL, NULL); - if (status < 0) return status; + status = OutputTable (obj, PR_TRUE, PR_FALSE, NULL, NULL, NULL); + if (status < 0) return status; - return 0; + return 0; } static int OutputButtons(MimeObject *obj, PRBool basic, VObject *v) { - int status = 0; - char * htmlLine1 = NULL; - char * htmlLine2 = NULL; - char* vCard = NULL; - char* vEscCard = NULL; - int len = 0; - char* rsrcString = NULL; + int status = 0; + char * htmlLine1 = NULL; + char * htmlLine2 = NULL; + char* vCard = NULL; + char* vEscCard = NULL; + int len = 0; + char* rsrcString = NULL; - if (!obj->options->output_vcard_buttons_p) - return status; + if (!obj->options->output_vcard_buttons_p) + return status; - vCard = writeMemoryVObjects(0, &len, v, PR_FALSE); + vCard = writeMemoryVObjects(0, &len, v, PR_FALSE); - if (!vCard) - return VCARD_OUT_OF_MEMORY; + if (!vCard) + return VCARD_OUT_OF_MEMORY; - vEscCard = nsEscape (vCard, url_XAlphas); + vEscCard = nsEscape (vCard, url_XAlphas); - PR_FREEIF (vCard); + PR_FREEIF (vCard); - if (!vEscCard) - return VCARD_OUT_OF_MEMORY; + if (!vEscCard) + return VCARD_OUT_OF_MEMORY; - if (basic) - { - rsrcString = VCardGetStringByID(VCARD_ADDR_VIEW_COMPLETE_VCARD); + if (basic) + { + rsrcString = VCardGetStringByID(VCARD_ADDR_VIEW_COMPLETE_VCARD); htmlLine1 = PR_smprintf ("
", - rsrcString, s_unique); - } - else - { - rsrcString = VCardGetStringByID(VCARD_ADDR_VIEW_CONDENSED_VCARD); - htmlLine1 = PR_smprintf ("
", - rsrcString, s_unique); - } + rsrcString, s_unique); + } + else + { + rsrcString = VCardGetStringByID(VCARD_ADDR_VIEW_CONDENSED_VCARD); + htmlLine1 = PR_smprintf ("
", + rsrcString, s_unique); + } PR_FREEIF(rsrcString); /**** RICHIE: When we get the addbook:add protocol into the product, we need to turn this stuff back on! - rsrcString = VCardGetStringByID(VCARD_MSG_ADD_TO_ADDR_BOOK); - htmlLine2 = PR_smprintf ("
", - vEscCard, rsrcString); + rsrcString = VCardGetStringByID(VCARD_MSG_ADD_TO_ADDR_BOOK); + htmlLine2 = PR_smprintf ("
", + vEscCard, rsrcString); PR_FREEIF(rsrcString); - if (!htmlLine1 && !htmlLine2) + if (!htmlLine1 && !htmlLine2) ******/ if (!htmlLine1) { - nsCRT::free (vEscCard); - PR_FREEIF (htmlLine1); - // PR_FREEIF (htmlLine2); - return VCARD_OUT_OF_MEMORY; - } - - status = OutputTableRowOrData (obj, PR_FALSE, PR_FALSE, "LEFT", "TOP", NULL, NULL); - if (status < 0) goto FAIL; + nsCRT::free (vEscCard); + PR_FREEIF (htmlLine1); + // PR_FREEIF (htmlLine2); + return VCARD_OUT_OF_MEMORY; + } + + status = OutputTableRowOrData (obj, PR_FALSE, PR_FALSE, "LEFT", "TOP", NULL, NULL); + if (status < 0) goto FAIL; - /* - * WARNING: This HTML is written to the stream using JavaScript, - * because we don't want this button to be displayed when JS has - * been switched off (in the whole client or just in email). The - * button won't work when JS is switched off (since it calls a JS - * function), so then we don't want the button to be displayed. - * -- erik (and jfriend) - */ - status = WriteEachLineToStream (obj, ""); - if (status < 0) goto FAIL; + status = WriteEachLineToStream (obj, "\")"); + if (status < 0) goto FAIL; // RICHIE - this goes back in when the addcard feature is done! - // status = WriteLineToStream (obj, htmlLine2, PR_FALSE); - // if (status < 0) goto FAIL; + // status = WriteLineToStream (obj, htmlLine2, PR_FALSE); + // if (status < 0) goto FAIL; - status = OutputTableRowOrData (obj, PR_FALSE, PR_TRUE, NULL, NULL, NULL, NULL); - if (status < 0) goto FAIL; + status = OutputTableRowOrData (obj, PR_FALSE, PR_TRUE, NULL, NULL, NULL, NULL); + if (status < 0) goto FAIL; - FAIL: - PR_FREEIF (vEscCard); - PR_FREEIF (htmlLine1); + FAIL: + PR_FREEIF (vEscCard); + PR_FREEIF (htmlLine1); // RICHIE - this goes back in when the addcard feature is done! // PR_FREEIF (htmlLine2); - return status; + return status; } static int BeginLayer(MimeObject *obj, PRBool basic) { - int status = 0; - char * captionLine = NULL; + int status = 0; + char * captionLine = NULL; - if (basic) - { - //CSS: START OF DIV + if (basic) + { + //CSS: START OF DIV captionLine = PR_smprintf ("
", s_unique); - } - else - { - //CSS: START OF DIV - captionLine = PR_smprintf ("
", s_unique); + } + else + { + //CSS: START OF DIV + captionLine = PR_smprintf ("
", s_unique); } - if (captionLine) - { - status = WriteEachLineToStream (obj, captionLine); - PR_Free(captionLine); - if (status < 0) return status; - status = OutputTable (obj, PR_FALSE, PR_FALSE, NULL, NULL, NULL); - if (status < 0) return status; - status = OutputTableRowOrData (obj, PR_TRUE, PR_FALSE, NULL, NULL, NULL, NULL); - if (status < 0) return status; - status = OutputTableRowOrData (obj, PR_FALSE, PR_FALSE, NULL, "TOP", NULL, NULL); - if (status < 0) return status; - status = OutputTable (obj, PR_FALSE, PR_TRUE, "0", "0", "#FFFFFF"); - if (status < 0) return status; - if (basic) - { - status = OutputTableRowOrData(obj, PR_TRUE, PR_FALSE, "LEFT", "TOP", NULL, NULL); - if (status < 0) return status; - status = OutputTableRowOrData(obj, PR_FALSE, PR_FALSE, "LEFT", "TOP", NULL, NULL); - if (status < 0) return status; - } - else - { - status = OutputTableRowOrData(obj, PR_TRUE, PR_FALSE, NULL, NULL, NULL, NULL); - if (status < 0) return status; - status = OutputTableRowOrData(obj, PR_FALSE, PR_FALSE, NULL, NULL, NULL, NULL); - if (status < 0) return status; - } + if (captionLine) + { + status = WriteEachLineToStream (obj, captionLine); + PR_Free(captionLine); + if (status < 0) return status; + status = OutputTable (obj, PR_FALSE, PR_FALSE, NULL, NULL, NULL); + if (status < 0) return status; + status = OutputTableRowOrData (obj, PR_TRUE, PR_FALSE, NULL, NULL, NULL, NULL); + if (status < 0) return status; + status = OutputTableRowOrData (obj, PR_FALSE, PR_FALSE, NULL, "TOP", NULL, NULL); + if (status < 0) return status; + status = OutputTable (obj, PR_FALSE, PR_TRUE, "0", "0", "#FFFFFF"); + if (status < 0) return status; + if (basic) + { + status = OutputTableRowOrData(obj, PR_TRUE, PR_FALSE, "LEFT", "TOP", NULL, NULL); + if (status < 0) return status; + status = OutputTableRowOrData(obj, PR_FALSE, PR_FALSE, "LEFT", "TOP", NULL, NULL); + if (status < 0) return status; + } + else + { + status = OutputTableRowOrData(obj, PR_TRUE, PR_FALSE, NULL, NULL, NULL, NULL); + if (status < 0) return status; + status = OutputTableRowOrData(obj, PR_FALSE, PR_FALSE, NULL, NULL, NULL, NULL); + if (status < 0) return status; + } - status = OutputTable (obj, PR_FALSE, PR_FALSE, "4", NULL, NULL); - if (status < 0) return status; - status = OutputTableRowOrData (obj, PR_TRUE, PR_FALSE, NULL, NULL, NULL, NULL); - if (status < 0) return status; - status = OutputTableRowOrData (obj, PR_FALSE, PR_FALSE, NULL, NULL, NULL, NULL); - if (status < 0) return status; - } - else - status = VCARD_OUT_OF_MEMORY; + status = OutputTable (obj, PR_FALSE, PR_FALSE, "4", NULL, NULL); + if (status < 0) return status; + status = OutputTableRowOrData (obj, PR_TRUE, PR_FALSE, NULL, NULL, NULL, NULL); + if (status < 0) return status; + status = OutputTableRowOrData (obj, PR_FALSE, PR_FALSE, NULL, NULL, NULL, NULL); + if (status < 0) return status; + } + else + status = VCARD_OUT_OF_MEMORY; - return status; + return status; } static int EndLayer(MimeObject *obj, PRBool basic, VObject* v) { - int status = 0; - char * captionLine = NULL; + int status = 0; + char * captionLine = NULL; - status = OutputTableRowOrData (obj, PR_FALSE, PR_TRUE, NULL, NULL, NULL, NULL); - if (status < 0) return status; - status = OutputTableRowOrData (obj, PR_TRUE, PR_TRUE, NULL, NULL, NULL, NULL); - if (status < 0) return status; - status = OutputTable (obj, PR_TRUE, PR_FALSE, NULL, NULL, NULL); - if (status < 0) return status; + status = OutputTableRowOrData (obj, PR_FALSE, PR_TRUE, NULL, NULL, NULL, NULL); + if (status < 0) return status; + status = OutputTableRowOrData (obj, PR_TRUE, PR_TRUE, NULL, NULL, NULL, NULL); + if (status < 0) return status; + status = OutputTable (obj, PR_TRUE, PR_FALSE, NULL, NULL, NULL); + if (status < 0) return status; - status = OutputTableRowOrData (obj, PR_FALSE, PR_TRUE, NULL, NULL, NULL, NULL); - if (status < 0) return status; - status = OutputTableRowOrData (obj, PR_TRUE, PR_TRUE, NULL, NULL, NULL, NULL); - if (status < 0) return status; - status = OutputTable (obj, PR_TRUE, PR_FALSE, NULL, NULL, NULL); - if (status < 0) return status; - status = OutputTableRowOrData (obj, PR_FALSE, PR_TRUE, NULL, NULL, NULL, NULL); - if (status < 0) return status; + status = OutputTableRowOrData (obj, PR_FALSE, PR_TRUE, NULL, NULL, NULL, NULL); + if (status < 0) return status; + status = OutputTableRowOrData (obj, PR_TRUE, PR_TRUE, NULL, NULL, NULL, NULL); + if (status < 0) return status; + status = OutputTable (obj, PR_TRUE, PR_FALSE, NULL, NULL, NULL); + if (status < 0) return status; + status = OutputTableRowOrData (obj, PR_FALSE, PR_TRUE, NULL, NULL, NULL, NULL); + if (status < 0) return status; - status = OutputButtons(obj, basic, v); - if (status < 0) return status; + status = OutputButtons(obj, basic, v); + if (status < 0) return status; - status = OutputTableRowOrData (obj, PR_TRUE, PR_TRUE, NULL, NULL, NULL, NULL); - if (status < 0) return status; - status = OutputTable (obj, PR_TRUE, PR_FALSE, NULL, NULL, NULL); - if (status < 0) return status; + status = OutputTableRowOrData (obj, PR_TRUE, PR_TRUE, NULL, NULL, NULL, NULL); + if (status < 0) return status; + status = OutputTable (obj, PR_TRUE, PR_FALSE, NULL, NULL, NULL); + if (status < 0) return status; - if (!basic) - { - //CSS: END OF DIV - status = WriteEachLineToStream (obj, "
"); + if (!basic) + { + //CSS: END OF DIV + status = WriteEachLineToStream (obj, "
"); + if (status < 0) return status; + status = WriteEachLineToStream (obj, "

"); - } - else { + status = WriteEachLineToStream (obj, "

"); + } + else { //CSS: END DIV - status = WriteEachLineToStream (obj, "
"); + status = WriteEachLineToStream (obj, ""); } - if (status < 0) return status; - return 0; + if (status < 0) return status; + return 0; } static int EndVCard (MimeObject *obj) { - int status = 0; + int status = 0; - /* Scribble HTML-ending stuff into the stream */ - char htmlFooters[32]; - PR_snprintf (htmlFooters, sizeof(htmlFooters), "%s%s", MSG_LINEBREAK, MSG_LINEBREAK); - status = COM_MimeObject_write(obj, htmlFooters, nsCRT::strlen(htmlFooters), PR_FALSE); + /* Scribble HTML-ending stuff into the stream */ + char htmlFooters[32]; + PR_snprintf (htmlFooters, sizeof(htmlFooters), "%s%s", MSG_LINEBREAK, MSG_LINEBREAK); + status = COM_MimeObject_write(obj, htmlFooters, nsCRT::strlen(htmlFooters), PR_FALSE); - if (status < 0) return status; + if (status < 0) return status; - return 0; + return 0; } static int BeginVCard (MimeObject *obj) { - int status = 0; + int status = 0; - /* Scribble HTML-starting stuff into the stream */ - char htmlHeaders[32]; + /* Scribble HTML-starting stuff into the stream */ + char htmlHeaders[32]; - s_unique++; - PR_snprintf (htmlHeaders, sizeof(htmlHeaders), "%s%s", MSG_LINEBREAK, MSG_LINEBREAK); + s_unique++; + PR_snprintf (htmlHeaders, sizeof(htmlHeaders), "%s%s", MSG_LINEBREAK, MSG_LINEBREAK); status = COM_MimeObject_write(obj, htmlHeaders, nsCRT::strlen(htmlHeaders), PR_TRUE); - if (status < 0) return status; + if (status < 0) return status; - return 0; + return 0; } static int WriteOutVCard (MimeObject *obj, VObject* v) { - int status = 0; + int status = 0; - status = BeginVCard (obj); - if (status < 0) return status; - - /* write out basic layer */ - status = BeginLayer(obj, PR_TRUE); - if (status < 0) return status; + status = BeginVCard (obj); + if (status < 0) return status; + + /* write out basic layer */ + status = BeginLayer(obj, PR_TRUE); + if (status < 0) return status; status = OutputBasicVcard(obj, v); - if (status < 0) return status; - status = EndLayer(obj, PR_TRUE, v); - if (status < 0) return status; + if (status < 0) return status; + status = EndLayer(obj, PR_TRUE, v); + if (status < 0) return status; - /* write out advanced layer */ - status = BeginLayer(obj, PR_FALSE); - if (status < 0) return status; - status = OutputAdvancedVcard(obj, v); - if (status < 0) return status; - status = EndLayer(obj, PR_FALSE, v); - if (status < 0) return status; + /* write out advanced layer */ + status = BeginLayer(obj, PR_FALSE); + if (status < 0) return status; + status = OutputAdvancedVcard(obj, v); + if (status < 0) return status; + status = EndLayer(obj, PR_FALSE, v); + if (status < 0) return status; - status = EndVCard (obj); - if (status < 0) return status; + status = EndVCard (obj); + if (status < 0) return status; - return 0; + return 0; } static void GetAddressProperties (VObject* o, char ** attribName) { - VObject* domProp = isAPropertyOf(o, VCDomesticProp); - VObject* intlProp = isAPropertyOf(o, VCInternationalProp); - VObject* postal = isAPropertyOf(o, VCPostalProp); - VObject* parcel = isAPropertyOf(o, VCParcelProp); - VObject* home = isAPropertyOf(o, VCHomeProp); - VObject* work = isAPropertyOf(o, VCWorkProp); + VObject* domProp = isAPropertyOf(o, VCDomesticProp); + VObject* intlProp = isAPropertyOf(o, VCInternationalProp); + VObject* postal = isAPropertyOf(o, VCPostalProp); + VObject* parcel = isAPropertyOf(o, VCParcelProp); + VObject* home = isAPropertyOf(o, VCHomeProp); + VObject* work = isAPropertyOf(o, VCWorkProp); char *tString = NULL; - if (domProp) { + if (domProp) { tString = VCardGetStringByID(VCARD_LDAP_DOM_TYPE); - } - if (intlProp) { - tString = VCardGetStringByID(VCARD_LDAP_INTL_TYPE); - } - if (postal) { - tString = VCardGetStringByID(VCARD_LDAP_POSTAL_TYPE); - } - if (parcel) { - tString = VCardGetStringByID(VCARD_LDAP_PARCEL_TYPE); - } - if (home) { - tString = VCardGetStringByID(VCARD_LDAP_HOME_TYPE); - } - if (work) { - tString = VCardGetStringByID(VCARD_LDAP_WORK_TYPE); - } + } + if (intlProp) { + tString = VCardGetStringByID(VCARD_LDAP_INTL_TYPE); + } + if (postal) { + tString = VCardGetStringByID(VCARD_LDAP_POSTAL_TYPE); + } + if (parcel) { + tString = VCardGetStringByID(VCARD_LDAP_PARCEL_TYPE); + } + if (home) { + tString = VCardGetStringByID(VCARD_LDAP_HOME_TYPE); + } + if (work) { + tString = VCardGetStringByID(VCARD_LDAP_WORK_TYPE); + } if (tString) { @@ -1298,44 +1298,44 @@ static void GetAddressProperties (VObject* o, char ** attribName) static void GetTelephoneProperties (VObject* o, char ** attribName) { - VObject* prefProp = isAPropertyOf(o, VCPreferredProp); - VObject* home = isAPropertyOf(o, VCHomeProp); - VObject* work = isAPropertyOf(o, VCWorkProp); - VObject* voiceProp = isAPropertyOf(o, VCVoiceProp); - VObject* fax = isAPropertyOf(o, VCFaxProp); - VObject* msg = isAPropertyOf(o, VCMessageProp); - VObject* cell = isAPropertyOf(o, VCCellularProp); - VObject* pager = isAPropertyOf(o, VCPagerProp); - VObject* bbs = isAPropertyOf(o, VCBBSProp); + VObject* prefProp = isAPropertyOf(o, VCPreferredProp); + VObject* home = isAPropertyOf(o, VCHomeProp); + VObject* work = isAPropertyOf(o, VCWorkProp); + VObject* voiceProp = isAPropertyOf(o, VCVoiceProp); + VObject* fax = isAPropertyOf(o, VCFaxProp); + VObject* msg = isAPropertyOf(o, VCMessageProp); + VObject* cell = isAPropertyOf(o, VCCellularProp); + VObject* pager = isAPropertyOf(o, VCPagerProp); + VObject* bbs = isAPropertyOf(o, VCBBSProp); char *tString = NULL; - if (prefProp) { - tString = VCardGetStringByID(VCARD_LDAP_PREF_TYPE); - } - if (home) { - tString = VCardGetStringByID(VCARD_LDAP_HOME_TYPE); - } - if (work) { - tString = VCardGetStringByID(VCARD_LDAP_WORK_TYPE); - } - if (voiceProp) { - tString = VCardGetStringByID(VCARD_LDAP_VOICE_TYPE); - } - if (fax) { - tString = VCardGetStringByID(VCARD_LDAP_FAX_TYPE); - } - if (msg) { - tString = VCardGetStringByID(VCARD_LDAP_MSG_TYPE); - } - if (cell) { - tString = VCardGetStringByID(VCARD_LDAP_CELL_TYPE); - } - if (pager) { - tString = VCardGetStringByID(VCARD_LDAP_PAGER_TYPE); - } - if (bbs) { - tString = VCardGetStringByID(VCARD_LDAP_BBS_TYPE); - } + if (prefProp) { + tString = VCardGetStringByID(VCARD_LDAP_PREF_TYPE); + } + if (home) { + tString = VCardGetStringByID(VCARD_LDAP_HOME_TYPE); + } + if (work) { + tString = VCardGetStringByID(VCARD_LDAP_WORK_TYPE); + } + if (voiceProp) { + tString = VCardGetStringByID(VCARD_LDAP_VOICE_TYPE); + } + if (fax) { + tString = VCardGetStringByID(VCARD_LDAP_FAX_TYPE); + } + if (msg) { + tString = VCardGetStringByID(VCARD_LDAP_MSG_TYPE); + } + if (cell) { + tString = VCardGetStringByID(VCARD_LDAP_CELL_TYPE); + } + if (pager) { + tString = VCardGetStringByID(VCARD_LDAP_PAGER_TYPE); + } + if (bbs) { + tString = VCardGetStringByID(VCARD_LDAP_BBS_TYPE); + } if (tString) { @@ -1347,69 +1347,69 @@ static void GetTelephoneProperties (VObject* o, char ** attribName) static void GetEmailProperties (VObject* o, char ** attribName) { - - VObject* prefProp = isAPropertyOf(o, VCPreferredProp); - VObject* home = isAPropertyOf(o, VCHomeProp); - VObject* work = isAPropertyOf(o, VCWorkProp); - VObject* aol = isAPropertyOf(o, VCAOLProp); - VObject* applelink = isAPropertyOf(o, VCAppleLinkProp); - VObject* att = isAPropertyOf(o, VCATTMailProp); - VObject* cis = isAPropertyOf(o, VCCISProp); - VObject* eworld = isAPropertyOf(o, VCEWorldProp); - VObject* internet = isAPropertyOf(o, VCInternetProp); - VObject* ibmmail = isAPropertyOf(o, VCIBMMailProp); - VObject* mcimail = isAPropertyOf(o, VCMCIMailProp); - VObject* powershare = isAPropertyOf(o, VCPowerShareProp); - VObject* prodigy = isAPropertyOf(o, VCProdigyProp); - VObject* telex = isAPropertyOf(o, VCTLXProp); - VObject* x400 = isAPropertyOf(o, VCX400Prop); + + VObject* prefProp = isAPropertyOf(o, VCPreferredProp); + VObject* home = isAPropertyOf(o, VCHomeProp); + VObject* work = isAPropertyOf(o, VCWorkProp); + VObject* aol = isAPropertyOf(o, VCAOLProp); + VObject* applelink = isAPropertyOf(o, VCAppleLinkProp); + VObject* att = isAPropertyOf(o, VCATTMailProp); + VObject* cis = isAPropertyOf(o, VCCISProp); + VObject* eworld = isAPropertyOf(o, VCEWorldProp); + VObject* internet = isAPropertyOf(o, VCInternetProp); + VObject* ibmmail = isAPropertyOf(o, VCIBMMailProp); + VObject* mcimail = isAPropertyOf(o, VCMCIMailProp); + VObject* powershare = isAPropertyOf(o, VCPowerShareProp); + VObject* prodigy = isAPropertyOf(o, VCProdigyProp); + VObject* telex = isAPropertyOf(o, VCTLXProp); + VObject* x400 = isAPropertyOf(o, VCX400Prop); char *tString = NULL; - if (prefProp) { - tString = VCardGetStringByID(VCARD_LDAP_PREF_TYPE); - } - if (home) { - tString = VCardGetStringByID(VCARD_LDAP_HOME_TYPE); - } - if (work) { - tString = VCardGetStringByID(VCARD_LDAP_WORK_TYPE); - } - if (aol) { - tString = VCardGetStringByID(VCARD_LDAP_AOL_TYPE); - } - if (applelink) { - tString = VCardGetStringByID(VCARD_LDAP_APPLELINK_TYPE); - } - if (att) { - tString = VCardGetStringByID(VCARD_LDAP_ATTMAIL_TYPE); - } - if (cis) { - tString = VCardGetStringByID(VCARD_LDAP_CSI_TYPE); - } - if (eworld) { - tString = VCardGetStringByID(VCARD_LDAP_EWORLD_TYPE); - } - if (internet) { - tString = VCardGetStringByID(VCARD_LDAP_INTERNET_TYPE); - } - if (ibmmail) { - tString = VCardGetStringByID(VCARD_LDAP_IBMMAIL_TYPE); - } - if (mcimail) { - tString = VCardGetStringByID(VCARD_LDAP_MCIMAIL_TYPE); - } - if (powershare) { - tString = VCardGetStringByID(VCARD_LDAP_POWERSHARE_TYPE); - } - if (prodigy) { - tString = VCardGetStringByID(VCARD_LDAP_PRODIGY_TYPE); - } - if (telex) { - tString = VCardGetStringByID(VCARD_LDAP_TLX_TYPE); - } - if (x400) { - tString = VCardGetStringByID(VCARD_LDAP_X400); - } + if (prefProp) { + tString = VCardGetStringByID(VCARD_LDAP_PREF_TYPE); + } + if (home) { + tString = VCardGetStringByID(VCARD_LDAP_HOME_TYPE); + } + if (work) { + tString = VCardGetStringByID(VCARD_LDAP_WORK_TYPE); + } + if (aol) { + tString = VCardGetStringByID(VCARD_LDAP_AOL_TYPE); + } + if (applelink) { + tString = VCardGetStringByID(VCARD_LDAP_APPLELINK_TYPE); + } + if (att) { + tString = VCardGetStringByID(VCARD_LDAP_ATTMAIL_TYPE); + } + if (cis) { + tString = VCardGetStringByID(VCARD_LDAP_CSI_TYPE); + } + if (eworld) { + tString = VCardGetStringByID(VCARD_LDAP_EWORLD_TYPE); + } + if (internet) { + tString = VCardGetStringByID(VCARD_LDAP_INTERNET_TYPE); + } + if (ibmmail) { + tString = VCardGetStringByID(VCARD_LDAP_IBMMAIL_TYPE); + } + if (mcimail) { + tString = VCardGetStringByID(VCARD_LDAP_MCIMAIL_TYPE); + } + if (powershare) { + tString = VCardGetStringByID(VCARD_LDAP_POWERSHARE_TYPE); + } + if (prodigy) { + tString = VCardGetStringByID(VCARD_LDAP_PRODIGY_TYPE); + } + if (telex) { + tString = VCardGetStringByID(VCARD_LDAP_TLX_TYPE); + } + if (x400) { + tString = VCardGetStringByID(VCARD_LDAP_X400); + } if (tString) { @@ -1421,294 +1421,298 @@ static void GetEmailProperties (VObject* o, char ** attribName) static int WriteOutEachVCardPhoneProperty (MimeObject *obj, VObject* o) { - char *attribName = NULL; - char *value = NULL; - int status = 0; + char *attribName = NULL; + char *value = NULL; + int status = 0; - if (vObjectName(o)) - { - if (nsCRT::strcasecmp (VCTelephoneProp, vObjectName(o)) == 0) - { - if (VALUE_TYPE(o)) - { - GetTelephoneProperties(o, &attribName); - if (!attribName) - attribName = VCardGetStringByID(VCARD_LDAP_PHONE_NUMBER); - attribName = NS_MsgSACat(&attribName, ": "); - value = fakeCString (vObjectUStringZValue(o)); - if (value) - { - if (attribName) - { - status = OutputFont(obj, PR_FALSE, "-1", NULL); - if (status < 0) { - PR_FREEIF (attribName); - return status; - } - // write a label without charset conversion - status = WriteLineToStream (obj, attribName, PR_FALSE); - if (status < 0) { - PR_FREEIF (attribName); - return status; - } - // write value with charset conversion - status = WriteLineToStream (obj, value, PR_TRUE); - if (status < 0) { - PR_FREEIF (value); - return status; - } - status = OutputFont(obj, PR_TRUE, NULL, NULL); - if (status < 0) { - PR_FREEIF (attribName); - return status; - } - } - PR_FREEIF (attribName); - } - PR_FREEIF (value); - } - } - } - return status; + if (vObjectName(o)) + { + if (nsCRT::strcasecmp (VCTelephoneProp, vObjectName(o)) == 0) + { + if (VALUE_TYPE(o)) + { + GetTelephoneProperties(o, &attribName); + if (!attribName) + attribName = VCardGetStringByID(VCARD_LDAP_PHONE_NUMBER); + attribName = NS_MsgSACat(&attribName, ": "); + value = fakeCString (vObjectUStringZValue(o)); + if (value) + { + if (attribName) + { + status = OutputFont(obj, PR_FALSE, "-1", NULL); + if (status < 0) { + PR_FREEIF (value); + PR_FREEIF (attribName); + return status; + } + // write a label without charset conversion + status = WriteLineToStream (obj, attribName, PR_FALSE); + if (status < 0) { + PR_FREEIF (value); + PR_FREEIF (attribName); + return status; + } + // write value with charset conversion + status = WriteLineToStream (obj, value, PR_TRUE); + if (status < 0) { + PR_FREEIF (value); + PR_FREEIF (attribName); + return status; + } + status = OutputFont(obj, PR_TRUE, NULL, NULL); + if (status < 0) { + PR_FREEIF (value); + PR_FREEIF (attribName); + return status; + } + } + PR_FREEIF (attribName); + } + PR_FREEIF (value); + } + } + } + return status; } static int WriteOutVCardPhoneProperties (MimeObject *obj, VObject* v) { - int status = 0; - VObjectIterator t; - VObject *eachProp; + int status = 0; + VObjectIterator t; + VObject *eachProp; WriteOutEachVCardPhoneProperty (obj, v); - initPropIterator(&t,v); - while (moreIteration(&t) && status >= 0) - { - eachProp = nextVObject(&t); - status = WriteOutEachVCardPhoneProperty (obj, eachProp); - } + initPropIterator(&t,v); + while (moreIteration(&t) && status >= 0) + { + eachProp = nextVObject(&t); + status = WriteOutEachVCardPhoneProperty (obj, eachProp); + } - if (status < 0) return status; + if (status < 0) return status; - return 0; + return 0; } static int WriteOutEachVCardProperty (MimeObject *obj, VObject* o, int* numEmail) { - char *attribName = NULL; - char * url = NULL; - char *value = NULL; - int status = 0; + char *attribName = NULL; + char * url = NULL; + char *value = NULL; + int status = 0; - if (vObjectName(o)) { + if (vObjectName(o)) { - if (nsCRT::strcasecmp (VCPhotoProp, vObjectName(o)) == 0) { - VObject* urlProp = isAPropertyOf(o, VCURLProp); - if (urlProp) { - attribName = VCardGetStringByID(VCARD_LDAP_PHOTOGRAPH); - /* format the value string to the url */ - value = fakeCString (vObjectUStringZValue(o)); - if (value) - url = PR_smprintf ("= 0) - { - eachProp = nextVObject(&t); - status = WriteOutVCardProperties (obj, eachProp, numEmail); - } + initPropIterator(&t,v); + while (moreIteration(&t) && status >= 0) + { + eachProp = nextVObject(&t); + status = WriteOutVCardProperties (obj, eachProp, numEmail); + } - if (status < 0) return status; + if (status < 0) return status; - return 0; + return 0; } char * @@ -1828,21 +1832,21 @@ WriteLineToStream (MimeObject *obj, const char *line, PRBool aDoCharConversion) static int WriteAttribute (MimeObject *obj, const char *attrib) { - int status = 0; - OutputFont(obj, PR_FALSE, "-1", NULL); - status = WriteLineToStream (obj, attrib, PR_FALSE); - OutputFont(obj, PR_TRUE, NULL, NULL); - return status; + int status = 0; + OutputFont(obj, PR_FALSE, "-1", NULL); + status = WriteLineToStream (obj, attrib, PR_FALSE); + OutputFont(obj, PR_TRUE, NULL, NULL); + return status; } static int WriteValue (MimeObject *obj, const char *value) { - int status = 0; - OutputFont(obj, PR_FALSE, "-1", NULL); - status = WriteLineToStream (obj, value, PR_TRUE); - OutputFont(obj, PR_TRUE, NULL, NULL); - return status; + int status = 0; + OutputFont(obj, PR_FALSE, "-1", NULL); + status = WriteLineToStream (obj, value, PR_TRUE); + OutputFont(obj, PR_TRUE, NULL, NULL); + return status; } // @@ -1853,41 +1857,41 @@ char * VCardGetStringByID(PRInt32 aMsgId) { char *tempString = nsnull; - nsresult res = NS_OK; + nsresult res = NS_OK; #ifdef XP_MAC nsCOMPtr stringBundle = nsnull; #endif - if (!stringBundle) - { - char* propertyURL = NULL; + if (!stringBundle) + { + char* propertyURL = NULL; - propertyURL = VCARD_URL; + propertyURL = VCARD_URL; - nsCOMPtr sBundleService = - do_GetService(kStringBundleServiceCID, &res); - if (NS_SUCCEEDED(res) && (nsnull != sBundleService)) - { - res = sBundleService->CreateBundle(propertyURL, getter_AddRefs(stringBundle)); - } - } + nsCOMPtr sBundleService = + do_GetService(kStringBundleServiceCID, &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)) + if (NS_FAILED(res)) return nsCRT::strdup("???"); - else + else { nsAutoString v; v.Append(ptrv); - PR_FREEIF(ptrv); + PR_FREEIF(ptrv); tempString = ToNewUTF8String(v); } - } + } if (!tempString) return nsCRT::strdup("???"); diff --git a/mailnews/mime/cthandlers/vcard/nsVCardObj.cpp b/mailnews/mime/cthandlers/vcard/nsVCardObj.cpp index 03b559683da3..c027a09bcb18 100644 --- a/mailnews/mime/cthandlers/vcard/nsVCardObj.cpp +++ b/mailnews/mime/cthandlers/vcard/nsVCardObj.cpp @@ -84,7 +84,7 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. #include "plstr.h" #include "msgCore.h" #include "prprf.h" -#define NOT_NULL(X) X +#define NOT_NULL(X) X /* debugging utilities */ #define DBG_(x) @@ -109,28 +109,28 @@ static void initVObjectIterator(VObjectIterator *i, VObject *o); /*---------------------------------------------------------------------- The following functions involve with memory allocation: - newVObject - deleteVObject - dupStr - deleteString - newStrItem - deleteStrItem + newVObject + deleteVObject + dupStr + deleteString + newStrItem + deleteStrItem ----------------------------------------------------------------------*/ static PRBool needsQuotedPrintable (const char *s) { const unsigned char *p = (const unsigned char *)s; - if (PL_strstr (s, MSG_LINEBREAK)) - return PR_TRUE; + if (PL_strstr (s, MSG_LINEBREAK)) + return PR_TRUE; - while (*p) { - if (*p & 0x80) - return PR_TRUE; - p++; - } + while (*p) { + if (*p & 0x80) + return PR_TRUE; + p++; + } - return PR_FALSE; + return PR_FALSE; } VObject* newVObject_(const char *id) @@ -140,7 +140,7 @@ VObject* newVObject_(const char *id) p->id = id; p->prop = 0; VALUE_TYPE(p) = 0; - ANY_VALUE_OF(p) = 0; + ANY_VALUE_OF(p) = 0; return p; } @@ -152,24 +152,24 @@ VObject* newVObject(const char *id) void deleteVObject(VObject *p) { unUseStr(p->id); - PR_FREEIF (p); + delete (p); } char* dupStr(const char *s, unsigned int size) { char *t; if (size == 0) { - size = PL_strlen(s); - } - t = (char*)PR_CALLOC(size+1); - if (t) { - memcpy(t,s,size); - t[size] = 0; - return t; - } + size = PL_strlen(s); + } + t = (char*)PR_CALLOC(size+1); + if (t) { + memcpy(t,s,size); + t[size] = 0; + return t; + } else { - return (char*)0; - } + return (char*)0; + } } static StrItem* newStrItem(const char *s, StrItem *next) @@ -307,32 +307,32 @@ VObject* addVObjectProp(VObject *o, VObject *p) /* o {next,id,prop,val} V - pn {next,id,prop,val} + pn {next,id,prop,val} V - ... - p1 {next,id,prop,val} + ... + p1 {next,id,prop,val} V - pn + pn --> o {next,id,prop,val} V - pn {next,id,prop,val} + pn {next,id,prop,val} V - p {next,id,prop,val} - ... - p1 {next,id,prop,val} + p {next,id,prop,val} + ... + p1 {next,id,prop,val} V - pn + pn */ VObject *tail = o->prop; if (tail) { - p->next = tail->next; - o->prop = tail->next = p; - } + p->next = tail->next; + o->prop = tail->next = p; + } else { - o->prop = p->next = p; - } + o->prop = p->next = p; + } return p; } @@ -350,15 +350,15 @@ void addList(VObject **o, VObject *p) { p->next = 0; if (*o == 0) { - *o = p; - } + *o = p; + } else { - VObject *t = *o; - while (t->next) { - t = t->next; - } - t->next = p; - } + VObject *t = *o; + while (t->next) { + t = t->next; + } + t->next = p; + } } VObject* nextVObjectInList(VObject *o) @@ -377,7 +377,7 @@ VObject* setValueWithSize_(VObject *prop, void *val, unsigned int size) VObject* setValueWithSize(VObject *prop, void *val, unsigned int size) { - void *p = dupStr((const char *)val,size); + void *p = dupStr((const char *)val,size); return setValueWithSize_(prop,p,p?size:0); } @@ -403,15 +403,15 @@ int moreIteration(VObjectIterator *i) VObject* nextVObject(VObjectIterator *i) { if (i->start && i->next != i->start) { - if (i->next == 0) { - i->next = i->start->next; - return i->next; - } - else { - i->next = i->next->next; - return i->next; - } - } + if (i->next == 0) { + i->next = i->start->next; + return i->next; + } + else { + i->next = i->next->next; + return i->next; + } + } else return (VObject*)0; } @@ -420,72 +420,72 @@ VObject* isAPropertyOf(VObject *o, const char *id) VObjectIterator i; initPropIterator(&i,o); while (moreIteration(&i)) { - VObject *each = nextVObject(&i); - if (!PL_strcasecmp(id,each->id)) - return each; - } + VObject *each = nextVObject(&i); + if (!PL_strcasecmp(id,each->id)) + return each; + } return (VObject*)0; } VObject* addGroup(VObject *o, const char *g) { /* - a.b.c - --> - prop(c) - prop(VCGrouping=b) - prop(VCGrouping=a) + a.b.c + --> + prop(c) + prop(VCGrouping=b) + prop(VCGrouping=a) */ char *dot = PL_strrchr(g,'.'); if (dot) { - VObject *p, *t; - char *gs, *n = dot+1; - gs = dupStr(g,0); /* so we can write to it. */ - t = p = addProp_(o,lookupProp(n)); - dot = PL_strrchr(gs,'.'); - *dot = 0; - do { - dot = PL_strrchr(gs,'.'); - if (dot) { - n = dot+1; - *dot=0; - } - else - n = gs; - /* property(VCGroupingProp=n); - * and the value may have VCGrouping property - */ - t = addProp(t,VCGroupingProp); - setVObjectStringZValue(t,lookupProp_(n)); - } while (n != gs); - deleteString(gs); - return p; - } + VObject *p, *t; + char *gs, *n = dot+1; + gs = dupStr(g,0); /* so we can write to it. */ + t = p = addProp_(o,lookupProp(n)); + dot = PL_strrchr(gs,'.'); + *dot = 0; + do { + dot = PL_strrchr(gs,'.'); + if (dot) { + n = dot+1; + *dot=0; + } + else + n = gs; + /* property(VCGroupingProp=n); + * and the value may have VCGrouping property + */ + t = addProp(t,VCGroupingProp); + setVObjectStringZValue(t,lookupProp_(n)); + } while (n != gs); + deleteString(gs); + return p; + } else - return addProp_(o,lookupProp(g)); + return addProp_(o,lookupProp(g)); } VObject* addPropValue(VObject *o, const char *p, const char *v) { VObject *prop; prop = addProp(o,p); - if (v) { - setVObjectUStringZValue_(prop, fakeUnicode(v,0)); - if (needsQuotedPrintable (v)) { - if (PL_strcasecmp (VCCardProp, vObjectName(o)) == 0) - addProp (prop, VCQuotedPrintableProp); - else - addProp (o, VCQuotedPrintableProp); - } - } - else - setVObjectUStringZValue_(prop, fakeUnicode("",0)); + if (v) { + setVObjectUStringZValue_(prop, fakeUnicode(v,0)); + if (needsQuotedPrintable (v)) { + if (PL_strcasecmp (VCCardProp, vObjectName(o)) == 0) + addProp (prop, VCQuotedPrintableProp); + else + addProp (o, VCQuotedPrintableProp); + } + } + else + setVObjectUStringZValue_(prop, fakeUnicode("",0)); return prop; } VObject* addPropSizedValue_(VObject *o, const char *p, const char *v, - unsigned int size) + unsigned int size) { VObject *prop; prop = addProp(o,p); @@ -494,7 +494,7 @@ VObject* addPropSizedValue_(VObject *o, const char *p, const char *v, } VObject* addPropSizedValue(VObject *o, const char *p, const char *v, - unsigned int size) + unsigned int size) { return addPropSizedValue_(o,p,dupStr(v,size),size); } @@ -663,44 +663,44 @@ void cleanVObject(VObject *o) { if (o == 0) return; if (o->prop) { - /* destroy time: cannot use the iterator here. - Have to break the cycle in the circular link - list and turns it into regular NULL-terminated - list -- since at some point of destruction, - the reference entry for the iterator to work - will not longer be valid. - */ - VObject *p; - p = o->prop->next; - o->prop->next = 0; - do { - VObject *t = p->next; - cleanVObject(p); - p = t; - } while (p); - } + /* destroy time: cannot use the iterator here. + Have to break the cycle in the circular link + list and turns it into regular NULL-terminated + list -- since at some point of destruction, + the reference entry for the iterator to work + will not longer be valid. + */ + VObject *p; + p = o->prop->next; + o->prop->next = 0; + do { + VObject *t = p->next; + cleanVObject(p); + p = t; + } while (p); + } switch (VALUE_TYPE(o)) { - case VCVT_USTRINGZ: - case VCVT_STRINGZ: - case VCVT_RAW: - /* assume they are all allocated by malloc. */ - if ((char*) STRINGZ_VALUE_OF(o)) + case VCVT_USTRINGZ: + case VCVT_STRINGZ: + case VCVT_RAW: + /* assume they are all allocated by malloc. */ + if ((char*) STRINGZ_VALUE_OF(o)) PR_Free ((char*)STRINGZ_VALUE_OF(o)); - break; - case VCVT_VOBJECT: - cleanVObject(VOBJECT_VALUE_OF(o)); - break; - } + break; + case VCVT_VOBJECT: + cleanVObject(VOBJECT_VALUE_OF(o)); + break; + } deleteVObject(o); } void cleanVObjects(VObject *list) { while (list) { - VObject *t = list; - list = nextVObjectInList(list); - cleanVObject(t); - } + VObject *t = list; + list = nextVObjectInList(list); + cleanVObject(t); + } } /*---------------------------------------------------------------------- @@ -716,55 +716,38 @@ static unsigned int hashStr(const char *s) unsigned int h = 0; int i; for (i=0;s[i];i++) { - h += s[i]*i; - } + h += s[i]*i; + } return h % STRTBLSIZE; } void unUseStr(const char *s) { - StrItem *t, *p; - unsigned int h = hashStr(s); - if ((t = strTbl[h]) != 0) { - p = t; - do { - if (PL_strcasecmp(t->s,s) == 0) { - t->refCnt--; - if (t->refCnt == 0) { - if (p == strTbl[h]) { - strTbl[h] = t->next; - } - else { - p->next = t->next; - } - deleteString((char *)t->s); - deleteStrItem(t); - return; - } - } - p = t; - t = t->next; - } while (t); - } + StrItem *t, *p; + unsigned int h = hashStr(s); + if ((t = strTbl[h]) != 0) { + p = t; + do { + if (PL_strcasecmp(t->s,s) == 0) { + t->refCnt--; + if (t->refCnt == 0) { + if (t == strTbl[h]) { + strTbl[h] = t->next; + } + else { + p->next = t->next; + } + deleteString((char *)t->s); + deleteStrItem(t); + return; + } + } + p = t; + t = t->next; + } while (t); + } } -void cleanStrTbl() -{ - int i; - for (i=0; is); - p = t; - t = t->next; - deleteStrItem(p); - } while (t) {} - strTbl[i] = 0; - } -} - - struct PreDefProp { const char *name; const char *alias; @@ -773,8 +756,8 @@ struct PreDefProp { }; /* flags in PreDefProp */ -#define PD_BEGIN 0x1 -#define PD_INTERNAL 0x2 +#define PD_BEGIN 0x1 +#define PD_INTERNAL 0x2 static const char *adrFields[] = { VCPostalBoxProp, @@ -815,7 +798,7 @@ static const char *AAlarmFields[] = { static const char *coolTalkFields[] = { VCCooltalkAddress, - VCUseServer, + VCUseServer, 0 }; @@ -849,7 +832,7 @@ static const char *PAlarmFields[] = { static struct PreDefProp propNames[] = { { VC7bitProp, 0, 0, 0 }, - { VC8bitProp, 0, 0, 0 }, + { VC8bitProp, 0, 0, 0 }, { VCAAlarmProp, 0, AAlarmFields, 0 }, { VCAdditionalNamesProp, 0, 0, 0 }, { VCAdrProp, 0, adrFields, 0 }, @@ -857,7 +840,7 @@ static struct PreDefProp propNames[] = { { VCAIFFProp, 0, 0, 0 }, { VCAOLProp, 0, 0, 0 }, { VCAppleLinkProp, 0, 0, 0 }, - { VCAttachProp, 0, 0, 0 }, + { VCAttachProp, 0, 0, 0 }, { VCAttendeeProp, 0, 0, 0 }, { VCATTMailProp, 0, 0, 0 }, { VCAudioContentProp, 0, 0, 0 }, @@ -886,7 +869,7 @@ static struct PreDefProp propNames[] = { { VCCountryNameProp, 0, 0, 0 }, { VCDAlarmProp, 0, DAlarmFields, 0 }, { VCDataSizeProp, 0, 0, PD_INTERNAL }, - { VCDayLightProp, 0, 0 ,0 }, + { VCDayLightProp, 0, 0 ,0 }, { VCDCreatedProp, 0, 0, 0 }, { VCDeliveryLabelProp, 0, 0, 0 }, { VCDescriptionProp, 0, 0, 0 }, @@ -1006,10 +989,10 @@ static struct PreDefProp propNames[] = { { VCX400Prop, 0, 0, 0 }, { VCX509Prop, 0, 0, 0 }, { VCXRuleProp, 0, 0, 0 }, - { VCCooltalk, 0, coolTalkFields, 0 }, - { VCCooltalkAddress, 0, 0, 0 }, - { VCUseServer, 0, 0, 0 }, - { VCUseHTML, 0, 0, 0 }, + { VCCooltalk, 0, coolTalkFields, 0 }, + { VCCooltalkAddress, 0, 0, 0 }, + { VCUseServer, 0, 0, 0 }, + { VCUseHTML, 0, 0, 0 }, { 0,0,0,0 } }; @@ -1018,11 +1001,11 @@ static struct PreDefProp* lookupPropInfo(const char* str) { /* brute force for now, could use a hash table here. */ int i; - + for (i = 0; propNames[i].name; i++) - if (PL_strcasecmp(str, propNames[i].name) == 0) { - return &propNames[i]; - } + if (PL_strcasecmp(str, propNames[i].name) == 0) { + return &propNames[i]; + } return 0; } @@ -1031,13 +1014,13 @@ static struct PreDefProp* lookupPropInfo(const char* str) const char* lookupProp_(const char* str) { int i; - + for (i = 0; propNames[i].name; i++) - if (PL_strcasecmp(str, propNames[i].name) == 0) { - const char* s; - s = propNames[i].alias?propNames[i].alias:propNames[i].name; - return lookupStr(s); - } + if (PL_strcasecmp(str, propNames[i].name) == 0) { + const char* s; + s = propNames[i].alias?propNames[i].alias:propNames[i].name; + return lookupStr(s); + } return lookupStr(str); } @@ -1045,14 +1028,14 @@ const char* lookupProp_(const char* str) const char* lookupProp(const char* str) { int i; - + for (i = 0; propNames[i].name; i++) - if (PL_strcasecmp(str, propNames[i].name) == 0) { - const char *s; - fieldedProp = (char **)propNames[i].fields; - s = propNames[i].alias?propNames[i].alias:propNames[i].name; - return lookupStr(s); - } + if (PL_strcasecmp(str, propNames[i].name) == 0) { + const char *s; + fieldedProp = (char **)propNames[i].fields; + s = propNames[i].alias?propNames[i].alias:propNames[i].name; + return lookupStr(s); + } fieldedProp = 0; return lookupStr(str); } @@ -1101,14 +1084,14 @@ static void appendcOFile(OFile *fp, char c) { /* int i = 0; */ if (c == '\n') { - /* write out as */ - /* for (i = 0; i < LINEBREAK_LEN; i++) - appendcOFile_(fp,LINEBREAK [ i ]); */ - appendcOFile_(fp,0xd); - appendcOFile_(fp,0xa); - } + /* write out as */ + /* for (i = 0; i < LINEBREAK_LEN; i++) + appendcOFile_(fp,LINEBREAK [ i ]); */ + appendcOFile_(fp,0xd); + appendcOFile_(fp,0xa); + } else - appendcOFile_(fp,c); + appendcOFile_(fp,c); } static void appendsOFile(OFile *fp, const char *s) @@ -1116,8 +1099,8 @@ static void appendsOFile(OFile *fp, const char *s) int i, slen; slen = PL_strlen (s); for (i=0; i= 0; i--) { - b = (unsigned char)(trip & 0x3F); - trip = trip >> 6; - if ((3 - i) < (cur - len)) - quad[i] = '='; /* pad char */ - else if (b < 26) quad[i] = (char)b + 'A'; - else if (b < 52) quad[i] = (char)(b - 26) + 'a'; - else if (b < 62) quad[i] = (char)(b - 52) + '0'; - else if (b == 62) quad[i] = '+'; - else quad[i] = '/'; - } - /* now output 'quad' with appropriate whitespace and line ending */ - appendsOFile(fp, (numQuads == 0 ? " " : "")); - appendsOFile(fp, quad); - appendsOFile(fp, ((cur >= len)?"\n" :(numQuads==PR_MAXQUADS-1?"\n" : ""))); - numQuads = (numQuads + 1) % PR_MAXQUADS; - } + /* collect the triplet of bytes into 'trip' */ + trip = 0; + for (i = 0; i < 3; i++) { + b = (cur < len) ? *(s + cur) : 0; + cur++; + trip = trip << 8 | b; + } + /* fill in 'quad' with the appropriate four characters */ + for (i = 3; i >= 0; i--) { + b = (unsigned char)(trip & 0x3F); + trip = trip >> 6; + if ((3 - i) < (cur - len)) + quad[i] = '='; /* pad char */ + else if (b < 26) quad[i] = (char)b + 'A'; + else if (b < 52) quad[i] = (char)(b - 26) + 'a'; + else if (b < 62) quad[i] = (char)(b - 52) + '0'; + else if (b == 62) quad[i] = '+'; + else quad[i] = '/'; + } + /* now output 'quad' with appropriate whitespace and line ending */ + appendsOFile(fp, (numQuads == 0 ? " " : "")); + appendsOFile(fp, quad); + appendsOFile(fp, ((cur >= len)?"\n" :(numQuads==PR_MAXQUADS-1?"\n" : ""))); + numQuads = (numQuads + 1) % PR_MAXQUADS; + } appendcOFile(fp,'\n'); return 1; @@ -1186,112 +1169,112 @@ static int writeBase64(OFile *fp, unsigned char *s, long len) static void writeQPString(OFile *fp, const char *s) { const unsigned char *p = (const unsigned char *)s; - int current_column = 0; - static const char hexdigits[] = "0123456789ABCDEF"; - PRBool white = PR_FALSE; - PRBool contWhite = PR_FALSE; - PRBool mb_p = PR_FALSE; + int current_column = 0; + static const char hexdigits[] = "0123456789ABCDEF"; + PRBool white = PR_FALSE; + PRBool contWhite = PR_FALSE; + PRBool mb_p = PR_FALSE; - if (needsQuotedPrintable (s)) - { - while (*p) { - if (*p == nsCRT::CR || *p == nsCRT::LF) - { - /* Whitespace cannot be allowed to occur at the end of the line. - So we encode " \n" as " =\n\n", that is, the whitespace, a - soft line break, and then a hard line break. - */ + if (needsQuotedPrintable (s)) + { + while (*p) { + if (*p == nsCRT::CR || *p == nsCRT::LF) + { + /* Whitespace cannot be allowed to occur at the end of the line. + So we encode " \n" as " =\n\n", that is, the whitespace, a + soft line break, and then a hard line break. + */ - if (white) - { - appendcOFile(fp,'='); - appendcOFile(fp,'\n'); - appendcOFile(fp,'\t'); - appendsOFile(fp,"=0D"); - appendsOFile(fp,"=0A"); - appendcOFile(fp,'='); - appendcOFile(fp,'\n'); - appendcOFile(fp,'\t'); - } - else - { - appendsOFile(fp,"=0D"); - appendsOFile(fp,"=0A"); - appendcOFile(fp,'='); - appendcOFile(fp,'\n'); - appendcOFile(fp,'\t'); - contWhite = PR_FALSE; - } + if (white) + { + appendcOFile(fp,'='); + appendcOFile(fp,'\n'); + appendcOFile(fp,'\t'); + appendsOFile(fp,"=0D"); + appendsOFile(fp,"=0A"); + appendcOFile(fp,'='); + appendcOFile(fp,'\n'); + appendcOFile(fp,'\t'); + } + else + { + appendsOFile(fp,"=0D"); + appendsOFile(fp,"=0A"); + appendcOFile(fp,'='); + appendcOFile(fp,'\n'); + appendcOFile(fp,'\t'); + contWhite = PR_FALSE; + } - /* If its CRLF, swallow two chars instead of one. */ - if (*p == nsCRT::CR && *(p+1) == nsCRT::LF) - p++; - white = PR_FALSE; - current_column = 0; - } - else - { - if ((*p >= 33 && *p <= 60) || /* safe printing chars */ - (*p >= 62 && *p <= 126) || - (mb_p && (*p == 61 || *p == 127 || *p == 0x1B))) - { - appendcOFile(fp,*p); - current_column++; - white = PR_FALSE; - contWhite = PR_FALSE; - } - else if (*p == ' ' || *p == '\t') /* whitespace */ - { - if (contWhite) - { - appendcOFile(fp,'='); - appendcOFile(fp,hexdigits[*p >> 4]); - appendcOFile(fp,hexdigits[*p & 0xF]); - current_column += 3; - contWhite = PR_FALSE; - } - else - { - appendcOFile(fp,*p); - current_column++; - } - white = PR_TRUE; - } - else /* print as =FF */ - { - appendcOFile(fp,'='); - appendcOFile(fp,hexdigits[*p >> 4]); - appendcOFile(fp,hexdigits[*p & 0xF]); - current_column += 3; - white = PR_FALSE; - contWhite = PR_FALSE; - } + /* If its CRLF, swallow two chars instead of one. */ + if (*p == nsCRT::CR && *(p+1) == nsCRT::LF) + p++; + white = PR_FALSE; + current_column = 0; + } + else + { + if ((*p >= 33 && *p <= 60) || /* safe printing chars */ + (*p >= 62 && *p <= 126) || + (mb_p && (*p == 61 || *p == 127 || *p == 0x1B))) + { + appendcOFile(fp,*p); + current_column++; + white = PR_FALSE; + contWhite = PR_FALSE; + } + else if (*p == ' ' || *p == '\t') /* whitespace */ + { + if (contWhite) + { + appendcOFile(fp,'='); + appendcOFile(fp,hexdigits[*p >> 4]); + appendcOFile(fp,hexdigits[*p & 0xF]); + current_column += 3; + contWhite = PR_FALSE; + } + else + { + appendcOFile(fp,*p); + current_column++; + } + white = PR_TRUE; + } + else /* print as =FF */ + { + appendcOFile(fp,'='); + appendcOFile(fp,hexdigits[*p >> 4]); + appendcOFile(fp,hexdigits[*p & 0xF]); + current_column += 3; + white = PR_FALSE; + contWhite = PR_FALSE; + } - PR_ASSERT(current_column <= 76); /* Hard limit required by spec */ + PR_ASSERT(current_column <= 76); /* Hard limit required by spec */ - if (current_column >= 73 || ((*(p+1) == ' ') && (current_column + 3 >= 73))) /* soft line break: "=\r\n" */ - { - appendcOFile(fp,'='); - appendcOFile(fp,'\n'); - appendcOFile(fp,'\t'); - current_column = 0; - if (white) - contWhite = PR_TRUE; - else - contWhite = PR_FALSE; - white = PR_FALSE; - } - } - p++; - } /* while */ - } /* if */ - else - { - while (*p) { - appendcOFile(fp,*p); - p++; - } - } + if (current_column >= 73 || ((*(p+1) == ' ') && (current_column + 3 >= 73))) /* soft line break: "=\r\n" */ + { + appendcOFile(fp,'='); + appendcOFile(fp,'\n'); + appendcOFile(fp,'\t'); + current_column = 0; + if (white) + contWhite = PR_TRUE; + else + contWhite = PR_FALSE; + white = PR_FALSE; + } + } + p++; + } /* while */ + } /* if */ + else + { + while (*p) { + appendcOFile(fp,*p); + p++; + } + } } @@ -1299,67 +1282,67 @@ static void writeValue(OFile *fp, VObject *o, unsigned long size) { if (o == 0) return; switch (VALUE_TYPE(o)) { - case VCVT_USTRINGZ: { - char *s = fakeCString(USTRINGZ_VALUE_OF(o)); - writeQPString(fp, s); - deleteString(s); - break; - } - case VCVT_STRINGZ: { - writeQPString(fp, STRINGZ_VALUE_OF(o)); - break; - } - case VCVT_UINT: { - char buf[16]; - sprintf(buf,"%u", INTEGER_VALUE_OF(o)); - appendsOFile(fp,buf); - break; - } - case VCVT_ULONG: { - char buf[16]; - sprintf(buf,"%lu", LONG_VALUE_OF(o)); - appendsOFile(fp,buf); - break; - } - case VCVT_RAW: { - appendcOFile(fp,'\n'); - writeBase64(fp,(unsigned char*)(ANY_VALUE_OF(o)),size); - break; - } - case VCVT_VOBJECT: - appendcOFile(fp,'\n'); - writeVObject_(fp,VOBJECT_VALUE_OF(o)); - break; - } + case VCVT_USTRINGZ: { + char *s = fakeCString(USTRINGZ_VALUE_OF(o)); + writeQPString(fp, s); + deleteString(s); + break; + } + case VCVT_STRINGZ: { + writeQPString(fp, STRINGZ_VALUE_OF(o)); + break; + } + case VCVT_UINT: { + char buf[16]; + sprintf(buf,"%u", INTEGER_VALUE_OF(o)); + appendsOFile(fp,buf); + break; + } + case VCVT_ULONG: { + char buf[16]; + sprintf(buf,"%lu", LONG_VALUE_OF(o)); + appendsOFile(fp,buf); + break; + } + case VCVT_RAW: { + appendcOFile(fp,'\n'); + writeBase64(fp,(unsigned char*)(ANY_VALUE_OF(o)),size); + break; + } + case VCVT_VOBJECT: + appendcOFile(fp,'\n'); + writeVObject_(fp,VOBJECT_VALUE_OF(o)); + break; + } } static void writeAttrValue(OFile *fp, VObject *o, int* length) { - int ilen = 0; + int ilen = 0; if (NAME_OF(o)) { - struct PreDefProp *pi; - pi = lookupPropInfo(NAME_OF(o)); - if (pi && ((pi->flags & PD_INTERNAL) != 0)) return; - appendcOFile(fp,';'); - if (*length != -1) - (*length)++; - appendsOFile(fp,NAME_OF(o)); - if (*length != -1) - (*length) += PL_strlen (NAME_OF(o)); - } + struct PreDefProp *pi; + pi = lookupPropInfo(NAME_OF(o)); + if (pi && ((pi->flags & PD_INTERNAL) != 0)) return; + appendcOFile(fp,';'); + if (*length != -1) + (*length)++; + appendsOFile(fp,NAME_OF(o)); + if (*length != -1) + (*length) += PL_strlen (NAME_OF(o)); + } else { - appendcOFile(fp,';'); - (*length)++; - } + appendcOFile(fp,';'); + (*length)++; + } if (VALUE_TYPE(o)) { - appendcOFile(fp,'='); - if (*length != -1) { - (*length)++; - for (ilen = 0; ilen < MAXMOZPROPNAMESIZE - (*length); ilen++) - appendcOFile(fp,' '); - } - writeValue(fp,o,0); - } + appendcOFile(fp,'='); + if (*length != -1) { + (*length)++; + for (ilen = 0; ilen < MAXMOZPROPNAMESIZE - (*length); ilen++) + appendcOFile(fp,' '); + } + writeValue(fp,o,0); + } } static void writeGroup(OFile *fp, VObject *o) @@ -1368,11 +1351,11 @@ static void writeGroup(OFile *fp, VObject *o) char buf2[256]; PL_strcpy(buf1,NAME_OF(o)); while ((o=isAPropertyOf(o,VCGroupingProp)) != 0) { - PL_strcpy(buf2,STRINGZ_VALUE_OF(o)); - PL_strcat(buf2,"."); - PL_strcat(buf2,buf1); - PL_strcpy(buf1,buf2); - } + PL_strcpy(buf2,STRINGZ_VALUE_OF(o)); + PL_strcat(buf2,"."); + PL_strcat(buf2,buf1); + PL_strcpy(buf1,buf2); + } appendsOFile(fp,buf1); } @@ -1380,66 +1363,66 @@ static int inList(const char **list, const char *s) { if (list == 0) return 0; while (*list) { - if (PL_strcasecmp(*list,s) == 0) return 1; - list++; - } + if (PL_strcasecmp(*list,s) == 0) return 1; + list++; + } return 0; } static void writeProp(OFile *fp, VObject *o) { - int length = -1; - //int ilen = 0; + int length = -1; + //int ilen = 0; if (NAME_OF(o)) { - struct PreDefProp *pi; - VObjectIterator t; - const char **fields_ = 0; - pi = lookupPropInfo(NAME_OF(o)); - if (pi && ((pi->flags & PD_BEGIN) != 0)) { - writeVObject_(fp,o); - return; - } - if (isAPropertyOf(o,VCGroupingProp)) - writeGroup(fp,o); - else - appendsOFile(fp,NAME_OF(o)); - if (pi) fields_ = pi->fields; - initPropIterator(&t,o); - while (moreIteration(&t)) { - const char *s; - VObject *eachProp = nextVObject(&t); - s = NAME_OF(eachProp); - if (PL_strcasecmp(VCGroupingProp,s) && !inList(fields_,s)) - writeAttrValue(fp,eachProp, &length); - } - if (fields_) { - int i = 0, n = 0; - const char** fields = fields_; - /* output prop as fields */ - appendcOFile(fp,':'); - while (*fields) { - VObject *tt = isAPropertyOf(o,*fields); - i++; - if (tt) n = i; - fields++; - } - fields = fields_; - for (i=0;iflags & PD_BEGIN) != 0)) { + writeVObject_(fp,o); + return; + } + if (isAPropertyOf(o,VCGroupingProp)) + writeGroup(fp,o); + else + appendsOFile(fp,NAME_OF(o)); + if (pi) fields_ = pi->fields; + initPropIterator(&t,o); + while (moreIteration(&t)) { + const char *s; + VObject *eachProp = nextVObject(&t); + s = NAME_OF(eachProp); + if (PL_strcasecmp(VCGroupingProp,s) && !inList(fields_,s)) + writeAttrValue(fp,eachProp, &length); + } + if (fields_) { + int i = 0, n = 0; + const char** fields = fields_; + /* output prop as fields */ + appendcOFile(fp,':'); + while (*fields) { + VObject *tt = isAPropertyOf(o,*fields); + i++; + if (tt) n = i; + fields++; + } + fields = fields_; + for (i=0;iflags & PD_BEGIN) != 0)) { - VObjectIterator t; - const char *begin = NAME_OF(o); - appendsOFile(fp,"begin:"); - appendsOFile(fp,begin); - appendcOFile(fp,'\n'); - initPropIterator(&t,o); - while (moreIteration(&t)) { - VObject *eachProp = nextVObject(&t); - writeProp(fp, eachProp); - } - appendsOFile(fp,"end:"); - appendsOFile(fp,begin); - appendsOFile(fp,"\n\n"); - } - } + if (pi && ((pi->flags & PD_BEGIN) != 0)) { + VObjectIterator t; + const char *begin = NAME_OF(o); + appendsOFile(fp,"begin:"); + appendsOFile(fp,begin); + appendcOFile(fp,'\n'); + initPropIterator(&t,o); + while (moreIteration(&t)) { + VObject *eachProp = nextVObject(&t); + writeProp(fp, eachProp); + } + appendsOFile(fp,"end:"); + appendsOFile(fp,begin); + appendsOFile(fp,"\n\n"); + } + } } void writeVObject(nsOutputFileStream *fp, VObject *o) @@ -1494,14 +1477,14 @@ void writeVObjectsToFile(nsFileSpec *fname, VObject *list) #if !defined(MOZADDRSTANDALONE) nsOutputFileStream *fp = new nsOutputFileStream(*fname, PR_WRONLY | PR_CREATE_FILE, 00600); if (fp) { - while (list) { - writeVObject(fp,list); - list = nextVObjectInList(list); - } - fp->close(); - } + while (list) { + writeVObject(fp,list); + list = nextVObjectInList(list); + } + fp->close(); + } #else - PR_ASSERT(PR_FALSE); + PR_ASSERT(PR_FALSE); #endif } @@ -1521,9 +1504,9 @@ char * writeMemoryVObjects(char *s, int *len, VObject *list, PRBool expandSpaces OFile ofp; initMemOFile(&ofp,s,len?*len:0); while (list) { - writeVObject_(&ofp,list); - list = nextVObjectInList(list); - } + writeVObject_(&ofp,list); + list = nextVObjectInList(list); + } if (len) *len = ofp.len; appendcOFile(&ofp,0); return ofp.s; @@ -1539,19 +1522,19 @@ vwchar_t* fakeUnicode(const char *ps, int *bytes) pw = r = (vwchar_t*)PR_CALLOC(sizeof(vwchar_t)*len); if (bytes) - *bytes = len * sizeof(vwchar_t); + *bytes = len * sizeof(vwchar_t); while (*ps) { - if (*ps == '\n') - *pw = (vwchar_t)0x2028; - else if (*ps == '\r') - *pw = (vwchar_t)0x2029; - else - *pw = (vwchar_t)(unsigned char)*ps; - ps++; pw++; - } + if (*ps == '\n') + *pw = (vwchar_t)0x2028; + else if (*ps == '\r') + *pw = (vwchar_t)0x2029; + else + *pw = (vwchar_t)(unsigned char)*ps; + ps++; pw++; + } *pw = (vwchar_t)0; - + return r; } @@ -1568,14 +1551,14 @@ char* fakeCString(const vwchar_t *u) int len = uStrLen(u) + 1; t = s = (char*)PR_CALLOC(len); while (*u) { - if (*u == (vwchar_t)0x2028) - *t = '\n'; - else if (*u == (vwchar_t)0x2029) - *t = '\r'; - else - *t = (char)*u; - u++; t++; - } + if (*u == (vwchar_t)0x2028) + *t = '\n'; + else if (*u == (vwchar_t)0x2029) + *t = '\r'; + else + *t = (char)*u; + u++; t++; + } *t = 0; return s; } @@ -1585,14 +1568,14 @@ const char* lookupStr(const char *s) StrItem *t; unsigned int h = hashStr(s); if ((t = strTbl[h]) != 0) { - do { - if (PL_strcasecmp(t->s,s) == 0) { - t->refCnt++; - return t->s; - } - t = t->next; - } while (t); - } + do { + if (PL_strcasecmp(t->s,s) == 0) { + t->refCnt++; + return t->s; + } + t = t->next; + } while (t); + } s = dupStr(s,0); strTbl[h] = newStrItem(s,strTbl[h]); return s; diff --git a/mailnews/mime/cthandlers/vcard/nsVCardObj.h b/mailnews/mime/cthandlers/vcard/nsVCardObj.h index 4f5d2fc68d10..6c7165148989 100644 --- a/mailnews/mime/cthandlers/vcard/nsVCardObj.h +++ b/mailnews/mime/cthandlers/vcard/nsVCardObj.h @@ -105,8 +105,8 @@ which accompanied this distribution. Also visit: - http://www.versit.com - http://www.ralden.com + http://www.versit.com + http://www.ralden.com */ @@ -137,193 +137,193 @@ class nsOutputFileStream; XP_BEGIN_PROTOS -#define VC7bitProp "7bit" -#define VC8bitProp "8bit" -#define VCAAlarmProp "aalarm" -#define VCAdditionalNamesProp "addn" -#define VCAdrProp "adr" -#define VCAgentProp "agent" -#define VCAIFFProp "aiff" -#define VCAOLProp "aol" -#define VCAppleLinkProp "applelink" -#define VCAttachProp "attach" -#define VCAttendeeProp "attendee" -#define VCATTMailProp "attmail" -#define VCAudioContentProp "audiocontent" -#define VCAVIProp "avi" -#define VCBase64Prop "base64" -#define VCBBSProp "bbs" -#define VCBirthDateProp "bday" -#define VCBMPProp "bmp" -#define VCBodyProp "body" -#define VCBusinessRoleProp "role" -#define VCCalProp "vcalendar" -#define VCCaptionProp "cap" -#define VCCardProp "vcard" -#define VCCarProp "car" -#define VCCategoriesProp "categories" -#define VCCellularProp "cell" -#define VCCGMProp "cgm" -#define VCCharSetProp "cs" -#define VCCIDProp "cid" -#define VCCISProp "cis" -#define VCCityProp "l" -#define VCClassProp "class" -#define VCCommentProp "note" -#define VCCompletedProp "completed" -#define VCContentIDProp "content-id" -#define VCCountryNameProp "c" -#define VCDAlarmProp "dalarm" -#define VCDataSizeProp "datasize" -#define VCDayLightProp "daylight" -#define VCDCreatedProp "dcreated" +#define VC7bitProp "7bit" +#define VC8bitProp "8bit" +#define VCAAlarmProp "aalarm" +#define VCAdditionalNamesProp "addn" +#define VCAdrProp "adr" +#define VCAgentProp "agent" +#define VCAIFFProp "aiff" +#define VCAOLProp "aol" +#define VCAppleLinkProp "applelink" +#define VCAttachProp "attach" +#define VCAttendeeProp "attendee" +#define VCATTMailProp "attmail" +#define VCAudioContentProp "audiocontent" +#define VCAVIProp "avi" +#define VCBase64Prop "base64" +#define VCBBSProp "bbs" +#define VCBirthDateProp "bday" +#define VCBMPProp "bmp" +#define VCBodyProp "body" +#define VCBusinessRoleProp "role" +#define VCCalProp "vcalendar" +#define VCCaptionProp "cap" +#define VCCardProp "vcard" +#define VCCarProp "car" +#define VCCategoriesProp "categories" +#define VCCellularProp "cell" +#define VCCGMProp "cgm" +#define VCCharSetProp "cs" +#define VCCIDProp "cid" +#define VCCISProp "cis" +#define VCCityProp "l" +#define VCClassProp "class" +#define VCCommentProp "note" +#define VCCompletedProp "completed" +#define VCContentIDProp "content-id" +#define VCCountryNameProp "c" +#define VCDAlarmProp "dalarm" +#define VCDataSizeProp "datasize" +#define VCDayLightProp "daylight" +#define VCDCreatedProp "dcreated" #define VCDeliveryLabelProp "label" -#define VCDescriptionProp "description" -#define VCDIBProp "dib" -#define VCDisplayStringProp "displaystring" -#define VCDomesticProp "dom" -#define VCDTendProp "dtend" -#define VCDTstartProp "dtstart" -#define VCDueProp "due" -#define VCEmailAddressProp "email" -#define VCEncodingProp "encoding" -#define VCEndProp "end" -#define VCEventProp "vevent" -#define VCEWorldProp "eworld" -#define VCExNumProp "exnum" -#define VCExpDateProp "exdate" -#define VCExpectProp "expect" -#define VCExtAddressProp "ext add" -#define VCFamilyNameProp "f" -#define VCFaxProp "fax" -#define VCFullNameProp "fn" -#define VCGeoProp "geo" -#define VCGeoLocationProp "geo" -#define VCGIFProp "gif" -#define VCGivenNameProp "g" -#define VCGroupingProp "grouping" -#define VCHomeProp "home" -#define VCIBMMailProp "ibmmail" -#define VCInlineProp "inline" -#define VCInternationalProp "intl" -#define VCInternetProp "internet" -#define VCISDNProp "isdn" -#define VCJPEGProp "jpeg" -#define VCLanguageProp "lang" -#define VCLastModifiedProp "last-modified" -#define VCLastRevisedProp "rev" -#define VCLocationProp "location" -#define VCLogoProp "logo" -#define VCMailerProp "mailer" -#define VCMAlarmProp "malarm" -#define VCMCIMailProp "mcimail" -#define VCMessageProp "msg" -#define VCMETProp "met" -#define VCModemProp "modem" -#define VCMPEG2Prop "mpeg2" -#define VCMPEGProp "mpeg" -#define VCMSNProp "msn" -#define VCNamePrefixesProp "npre" -#define VCNameProp "n" -#define VCNameSuffixesProp "nsuf" -#define VCNoteProp "note" -#define VCOrgNameProp "orgname" -#define VCOrgProp "org" -#define VCOrgUnit2Prop "oun2" -#define VCOrgUnit3Prop "oun3" -#define VCOrgUnit4Prop "oun4" -#define VCOrgUnitProp "oun" -#define VCPagerProp "pager" -#define VCPAlarmProp "palarm" -#define VCParcelProp "parcel" -#define VCPartProp "part" -#define VCPCMProp "pcm" -#define VCPDFProp "pdf" -#define VCPGPProp "pgp" -#define VCPhotoProp "photo" -#define VCPICTProp "pict" -#define VCPMBProp "pmb" -#define VCPostalBoxProp "box" -#define VCPostalCodeProp "pc" -#define VCPostalProp "postal" -#define VCPowerShareProp "powershare" -#define VCPreferredProp "pref" -#define VCPriorityProp "priority" -#define VCProcedureNameProp "procedurename" -#define VCProdIdProp "prodid" -#define VCProdigyProp "prodigy" -#define VCPronunciationProp "sound" -#define VCPSProp "ps" -#define VCPublicKeyProp "key" -#define VCQPProp "qp" -#define VCQuickTimeProp "qtime" -#define VCQuotedPrintableProp "quoted-printable" -#define VCRDateProp "rdate" -#define VCRegionProp "r" -#define VCRelatedToProp "related-to" -#define VCRepeatCountProp "repeatcount" -#define VCResourcesProp "resources" -#define VCRNumProp "rnum" -#define VCRoleProp "role" -#define VCRRuleProp "rrule" -#define VCRSVPProp "rsvp" -#define VCRunTimeProp "runtime" -#define VCSequenceProp "sequence" -#define VCSnoozeTimeProp "snoozetime" -#define VCStartProp "start" -#define VCStatusProp "status" -#define VCStreetAddressProp "street" -#define VCSubTypeProp "subtype" -#define VCSummaryProp "summary" -#define VCTelephoneProp "tel" -#define VCTIFFProp "tiff" -#define VCTimeZoneProp "tz" -#define VCTitleProp "title" -#define VCTLXProp "tlx" -#define VCTodoProp "vtodo" -#define VCTranspProp "transp" -#define VCUniqueStringProp "uid" -#define VCURLProp "url" -#define VCURLValueProp "urlval" -#define VCValueProp "value" -#define VCVersionProp "version" -#define VCVideoProp "video" -#define VCVoiceProp "voice" -#define VCWAVEProp "wave" -#define VCWMFProp "wmf" -#define VCWorkProp "work" -#define VCX400Prop "x400" -#define VCX509Prop "x509" -#define VCXRuleProp "xrule" -#define VCCooltalk "x-mozilla-cpt" -#define VCCooltalkAddress "x-moxilla-cpadr" -#define VCUseServer "x-mozilla-cpsrv" -#define VCUseHTML "x-mozilla-html" +#define VCDescriptionProp "description" +#define VCDIBProp "dib" +#define VCDisplayStringProp "displaystring" +#define VCDomesticProp "dom" +#define VCDTendProp "dtend" +#define VCDTstartProp "dtstart" +#define VCDueProp "due" +#define VCEmailAddressProp "email" +#define VCEncodingProp "encoding" +#define VCEndProp "end" +#define VCEventProp "vevent" +#define VCEWorldProp "eworld" +#define VCExNumProp "exnum" +#define VCExpDateProp "exdate" +#define VCExpectProp "expect" +#define VCExtAddressProp "ext add" +#define VCFamilyNameProp "f" +#define VCFaxProp "fax" +#define VCFullNameProp "fn" +#define VCGeoProp "geo" +#define VCGeoLocationProp "geo" +#define VCGIFProp "gif" +#define VCGivenNameProp "g" +#define VCGroupingProp "grouping" +#define VCHomeProp "home" +#define VCIBMMailProp "ibmmail" +#define VCInlineProp "inline" +#define VCInternationalProp "intl" +#define VCInternetProp "internet" +#define VCISDNProp "isdn" +#define VCJPEGProp "jpeg" +#define VCLanguageProp "lang" +#define VCLastModifiedProp "last-modified" +#define VCLastRevisedProp "rev" +#define VCLocationProp "location" +#define VCLogoProp "logo" +#define VCMailerProp "mailer" +#define VCMAlarmProp "malarm" +#define VCMCIMailProp "mcimail" +#define VCMessageProp "msg" +#define VCMETProp "met" +#define VCModemProp "modem" +#define VCMPEG2Prop "mpeg2" +#define VCMPEGProp "mpeg" +#define VCMSNProp "msn" +#define VCNamePrefixesProp "npre" +#define VCNameProp "n" +#define VCNameSuffixesProp "nsuf" +#define VCNoteProp "note" +#define VCOrgNameProp "orgname" +#define VCOrgProp "org" +#define VCOrgUnit2Prop "oun2" +#define VCOrgUnit3Prop "oun3" +#define VCOrgUnit4Prop "oun4" +#define VCOrgUnitProp "oun" +#define VCPagerProp "pager" +#define VCPAlarmProp "palarm" +#define VCParcelProp "parcel" +#define VCPartProp "part" +#define VCPCMProp "pcm" +#define VCPDFProp "pdf" +#define VCPGPProp "pgp" +#define VCPhotoProp "photo" +#define VCPICTProp "pict" +#define VCPMBProp "pmb" +#define VCPostalBoxProp "box" +#define VCPostalCodeProp "pc" +#define VCPostalProp "postal" +#define VCPowerShareProp "powershare" +#define VCPreferredProp "pref" +#define VCPriorityProp "priority" +#define VCProcedureNameProp "procedurename" +#define VCProdIdProp "prodid" +#define VCProdigyProp "prodigy" +#define VCPronunciationProp "sound" +#define VCPSProp "ps" +#define VCPublicKeyProp "key" +#define VCQPProp "qp" +#define VCQuickTimeProp "qtime" +#define VCQuotedPrintableProp "quoted-printable" +#define VCRDateProp "rdate" +#define VCRegionProp "r" +#define VCRelatedToProp "related-to" +#define VCRepeatCountProp "repeatcount" +#define VCResourcesProp "resources" +#define VCRNumProp "rnum" +#define VCRoleProp "role" +#define VCRRuleProp "rrule" +#define VCRSVPProp "rsvp" +#define VCRunTimeProp "runtime" +#define VCSequenceProp "sequence" +#define VCSnoozeTimeProp "snoozetime" +#define VCStartProp "start" +#define VCStatusProp "status" +#define VCStreetAddressProp "street" +#define VCSubTypeProp "subtype" +#define VCSummaryProp "summary" +#define VCTelephoneProp "tel" +#define VCTIFFProp "tiff" +#define VCTimeZoneProp "tz" +#define VCTitleProp "title" +#define VCTLXProp "tlx" +#define VCTodoProp "vtodo" +#define VCTranspProp "transp" +#define VCUniqueStringProp "uid" +#define VCURLProp "url" +#define VCURLValueProp "urlval" +#define VCValueProp "value" +#define VCVersionProp "version" +#define VCVideoProp "video" +#define VCVoiceProp "voice" +#define VCWAVEProp "wave" +#define VCWMFProp "wmf" +#define VCWorkProp "work" +#define VCX400Prop "x400" +#define VCX509Prop "x509" +#define VCXRuleProp "xrule" +#define VCCooltalk "x-mozilla-cpt" +#define VCCooltalkAddress "x-moxilla-cpadr" +#define VCUseServer "x-mozilla-cpsrv" +#define VCUseHTML "x-mozilla-html" /* return type of vObjectValueType: */ -#define VCVT_NOVALUE 0 - /* if the VObject has no value associated with it. */ -#define VCVT_STRINGZ 1 - /* if the VObject has value set by setVObjectStringZValue. */ -#define VCVT_USTRINGZ 2 - /* if the VObject has value set by setVObjectUStringZValue. */ -#define VCVT_UINT 3 - /* if the VObject has value set by setVObjectIntegerValue. */ -#define VCVT_ULONG 4 - /* if the VObject has value set by setVObjectLongValue. */ -#define VCVT_RAW 5 - /* if the VObject has value set by setVObjectAnyValue. */ -#define VCVT_VOBJECT 6 - /* if the VObject has value set by setVObjectVObjectValue. */ +#define VCVT_NOVALUE 0 + /* if the VObject has no value associated with it. */ +#define VCVT_STRINGZ 1 + /* if the VObject has value set by setVObjectStringZValue. */ +#define VCVT_USTRINGZ 2 + /* if the VObject has value set by setVObjectUStringZValue. */ +#define VCVT_UINT 3 + /* if the VObject has value set by setVObjectIntegerValue. */ +#define VCVT_ULONG 4 + /* if the VObject has value set by setVObjectLongValue. */ +#define VCVT_RAW 5 + /* if the VObject has value set by setVObjectAnyValue. */ +#define VCVT_VOBJECT 6 + /* if the VObject has value set by setVObjectVObjectValue. */ -#define NAME_OF(o) o->id -#define VALUE_TYPE(o) o->valType -#define STRINGZ_VALUE_OF(o) o->val.strs -#define USTRINGZ_VALUE_OF(o) o->val.ustrs -#define INTEGER_VALUE_OF(o) o->val.i -#define LONG_VALUE_OF(o) o->val.l -#define ANY_VALUE_OF(o) o->val.any -#define VOBJECT_VALUE_OF(o) o->val.vobj +#define NAME_OF(o) o->id +#define VALUE_TYPE(o) o->valType +#define STRINGZ_VALUE_OF(o) o->val.strs +#define USTRINGZ_VALUE_OF(o) o->val.ustrs +#define INTEGER_VALUE_OF(o) o->val.i +#define LONG_VALUE_OF(o) o->val.l +#define ANY_VALUE_OF(o) o->val.any +#define VOBJECT_VALUE_OF(o) o->val.vobj typedef struct VObject VObject; @@ -366,22 +366,22 @@ typedef struct VObjectIterator { VObject* next; } VObjectIterator; -VObject* newVObject(const char *id); -void deleteVObject(VObject *p); -char* dupStr(const char *s, unsigned int size); -extern "C" void deleteString(char *p); -void unUseStr(const char *s); +VObject* newVObject(const char *id); +void deleteVObject(VObject *p); +char* dupStr(const char *s, unsigned int size); +extern "C" void deleteString(char *p); +void unUseStr(const char *s); -void setVObjectName(VObject *o, const char* id); -void setVObjectStringZValue(VObject *o, const char *s); -void setVObjectStringZValue_(VObject *o, const char *s); -void setVObjectUStringZValue(VObject *o, const vwchar_t *s); -void setVObjectUStringZValue_(VObject *o, const vwchar_t *s); -void setVObjectIntegerValue(VObject *o, unsigned int i); -void setVObjectLongValue(VObject *o, unsigned long l); -void setVObjectAnyValue(VObject *o, void *t); -VObject* setValueWithSize(VObject *prop, void *val, unsigned int size); -VObject* setValueWithSize_(VObject *prop, void *val, unsigned int size); +void setVObjectName(VObject *o, const char* id); +void setVObjectStringZValue(VObject *o, const char *s); +void setVObjectStringZValue_(VObject *o, const char *s); +void setVObjectUStringZValue(VObject *o, const vwchar_t *s); +void setVObjectUStringZValue_(VObject *o, const vwchar_t *s); +void setVObjectIntegerValue(VObject *o, unsigned int i); +void setVObjectLongValue(VObject *o, unsigned long l); +void setVObjectAnyValue(VObject *o, void *t); +VObject* setValueWithSize(VObject *prop, void *val, unsigned int size); +VObject* setValueWithSize_(VObject *prop, void *val, unsigned int size); const char* vObjectName(VObject *o); const char* vObjectStringZValue(VObject *o); @@ -418,8 +418,6 @@ extern "C" char* writeMemoryVObjects(char *s, int *len, VObject *list, PRBool ex const char* lookupStr(const char *s); -void cleanStrTbl(); - void cleanVObject(VObject *o); void cleanVObjects(VObject *list); @@ -435,7 +433,7 @@ void printVObjectsToFile(nsFileSpec *fname,VObject *list); void writeVObjectToFile(nsFileSpec *fname, VObject *o); void writeVObjectsToFile(nsFileSpec *fname, VObject *list); -#define MAXPROPNAMESIZE 256 +#define MAXPROPNAMESIZE 256 #define MAXMOZPROPNAMESIZE 16 XP_END_PROTOS