namestring = (char *)PR_MALLOC(PL_strlen((char *) vObjectAnyValue(prop)) + 1);
namestring = (char *)PR_MALLOC(nsCRT::strlen((char *) vObjectAnyValue(prop)) + 1);
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;	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(PL_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 ("<A HREF=""%s"" PRIVATE>%s</A> ", 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_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_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;	/* 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 ("&lt;<A HREF=""mailto:%s"" PRIVATE>%s</A>&gt;", 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_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 (PL_strcasecmp (namestring, "PR_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_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;	/* 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;	/* 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_FREEIF(tString);		if (status < 0) return status;		prop2 = isAPropertyOf(prop, VCUseServer);		if (prop2)		{			if (VALUE_TYPE(prop2)) {				namestring  = fakeCString (vObjectUStringZValue(prop2));        char *tString1 = NULL;				if (PL_strcmp (namestring, "0") == 0)        {          tString1 = VCardGetStringByID(VCARD_ADDR_DEFAULT_DLS);        }				else         {					if (PL_strcmp (namestring, "1") == 0)						tString1 = VCardGetStringByID(VCARD_ADDR_SPECIFIC_DLS);					else						if (PL_strcmp (namestring, "2") == 0)							tString1 = VCardGetStringByID(VCARD_ADDR_HOSTNAMEIP);				}        status = WriteLineToStream (obj, tString1);        PR_FREEIF(tString1);				PR_FREEIF (namestring);				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 = 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;	/* 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_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;	status = OutputTable (obj, PR_TRUE, PR_FALSE, NULL, NULL, NULL);	if (status < 0) return status;	return 0;}