s = (char *) PR_MALLOC(PL_strlen(svr)*4 + (subj ? PL_strlen(subj)*4 : 0) + (body ? PL_strlen(body)*4 : 0) + 20);
s = (char *) PR_MALLOC(nsCRT::strlen(svr)*4 + (subj ? nsCRT::strlen(subj)*4 : 0) + (body ? nsCRT::strlen(body)*4 : 0) + 20);
MimeExternalBody_make_url(const char *ct,						  const char *at, const char *lexp, const char *size,						  const char *perm, const char *dir, const char *mode,						  const char *name, const char *url, const char *site,						  const char *svr, const char *subj, const char *body){  char *s;  if (!at)    {	  return 0;    }  else if (!PL_strcasecmp(at, "ftp") || !PL_strcasecmp(at, "anon-ftp"))	{	  if (!site || !name)		return 0;	  s = (char *) PR_MALLOC(PL_strlen(name) + PL_strlen(site) +							(dir  ? PL_strlen(dir) : 0) + 20);	  if (!s) return 0;	  PL_strcpy(s, "ftp://");	  PL_strcat(s, site);	  PL_strcat(s, "/");	  if (dir) PL_strcat(s, (dir[0] == '/' ? dir+1 : dir));	  if (s[PL_strlen(s)-1] != '/')		PL_strcat(s, "/");	  PL_strcat(s, name);	  return s;	}  else if (!PL_strcasecmp(at, "local-file") || !PL_strcasecmp(at, "afs"))	{	  char *s2;	  if (!name)		return 0;#ifdef XP_UNIX	  if (!PL_strcasecmp(at, "afs"))   /* only if there is a /afs/ directory */		{      nsFileSpec    fs("/afs/.");            if  (!fs.Exists())        return 0;		}#else  /* !XP_UNIX */	  return 0;						/* never, if not Unix. */#endif /* !XP_UNIX */	  s = (char *) PR_MALLOC(PL_strlen(name)*3 + 20);	  if (!s) return 0;	  PL_strcpy(s, "file:");	  s2 = nsEscape(name, url_Path);	  if (s2)	  {	      PL_strcat(s, s2);	      nsCRT::free(s2);	  }	  return s;	}  else if (!PL_strcasecmp(at, "mail-server"))	{	  char *s2;	  if (!svr)		return 0;	  s = (char *) PR_MALLOC(PL_strlen(svr)*4 +							(subj ? PL_strlen(subj)*4 : 0) +							(body ? PL_strlen(body)*4 : 0) + 20);	  if (!s) return 0;	  PL_strcpy(s, "mailto:");	  s2 = nsEscape(svr, url_XAlphas);	  if (s2)	  {	      PL_strcat(s, s2);	      nsCRT::free(s2);	  }	  if (subj)		{		  s2 = nsEscape(subj, url_XAlphas);		  PL_strcat(s, "?subject=");		  if (s2)		  {		      PL_strcat(s, s2);		      nsCRT::free(s2);		  }		}	  if (body)		{		  s2 = nsEscape(body, url_XAlphas);		  PL_strcat(s, (subj ? "&body=" : "?body="));		  if (s2)		  {		      PL_strcat(s, s2);		      nsCRT::free(s2);		  }		}	  return s;	}  else if (!PL_strcasecmp(at, "url"))	    /* RFC 2017 */	{	  if (url)		return PL_strdup(url);		   /* it's already quoted and everything */	  else		return 0;	}  else	return 0;}