h = (char *) PR_MALLOC((at ? PL_strlen(at) : 0) + (lexp ? PL_strlen(lexp) : 0) + (size ? PL_strlen(size) : 0) + (perm ? PL_strlen(perm) : 0) + (dir ? PL_strlen(dir) : 0) + (mode ? PL_strlen(mode) : 0) + (name ? PL_strlen(name) : 0) + (site ? PL_strlen(site) : 0) + (svr ? PL_strlen(svr) : 0) + (subj ? PL_strlen(subj) : 0) + (url ? PL_strlen(url) : 0) + 100);
h = (char *) PR_MALLOC((at ? nsCRT::strlen(at) : 0) + (lexp ? nsCRT::strlen(lexp) : 0) + (size ? nsCRT::strlen(size) : 0) + (perm ? nsCRT::strlen(perm) : 0) + (dir ? nsCRT::strlen(dir) : 0) + (mode ? nsCRT::strlen(mode) : 0) + (name ? nsCRT::strlen(name) : 0) + (site ? nsCRT::strlen(site) : 0) + (svr ? nsCRT::strlen(svr) : 0) + (subj ? nsCRT::strlen(subj) : 0) + (url ? nsCRT::strlen(url) : 0) + 100);
MimeExternalBody_parse_eof (MimeObject *obj, PRBool abort_p){  int status = 0;  MimeExternalBody *bod = (MimeExternalBody *) obj;  if (obj->closed_p) return 0;  /* Run parent method first, to flush out any buffered data. */  status = ((MimeObjectClass*)&MIME_SUPERCLASS)->parse_eof(obj, abort_p);  if (status < 0) return status;#ifdef XP_MAC  if (obj->parent && mime_typep(obj->parent, 	  (MimeObjectClass*) &mimeMultipartAppleDoubleClass))	  goto done;#endif /* XP_MAC */  if (!abort_p &&	  obj->output_p &&	  obj->options &&	  obj->options->write_html_p)	{	  PRBool all_headers_p = obj->options->headers == MimeHeadersAll;	  MimeDisplayOptions newopt = *obj->options;  /* copy it */	  char *ct = MimeHeaders_get(obj->headers, HEADER_CONTENT_TYPE,								 PR_FALSE, PR_FALSE);	  char *at, *lexp, *size, *perm;	  char *url, *dir, *mode, *name, *site, *svr, *subj;	  char *h = 0, *lname = 0, *lurl = 0, *body = 0;	  MimeHeaders *hdrs = 0;	  if (!ct) return MIME_OUT_OF_MEMORY;	  at   = MimeHeaders_get_parameter(ct, "access-type", NULL, NULL);	  lexp  = MimeHeaders_get_parameter(ct, "expiration", NULL, NULL);	  size = MimeHeaders_get_parameter(ct, "size", NULL, NULL);	  perm = MimeHeaders_get_parameter(ct, "permission", NULL, NULL);	  dir  = MimeHeaders_get_parameter(ct, "directory", NULL, NULL);	  mode = MimeHeaders_get_parameter(ct, "mode", NULL, NULL);	  name = MimeHeaders_get_parameter(ct, "name", NULL, NULL);	  site = MimeHeaders_get_parameter(ct, "site", NULL, NULL);	  svr  = MimeHeaders_get_parameter(ct, "server", NULL, NULL);	  subj = MimeHeaders_get_parameter(ct, "subject", NULL, NULL);	  url  = MimeHeaders_get_parameter(ct, "url", NULL, NULL);	  PR_FREEIF(ct);	  /* the *internal* content-type */	  ct = MimeHeaders_get(bod->hdrs, HEADER_CONTENT_TYPE,						   PR_TRUE, PR_FALSE);	  h = (char *) PR_MALLOC((at ? PL_strlen(at) : 0) +							(lexp ? PL_strlen(lexp) : 0) +							(size ? PL_strlen(size) : 0) +							(perm ? PL_strlen(perm) : 0) +							(dir ? PL_strlen(dir) : 0) +							(mode ? PL_strlen(mode) : 0) +							(name ? PL_strlen(name) : 0) +							(site ? PL_strlen(site) : 0) +							(svr ? PL_strlen(svr) : 0) +							(subj ? PL_strlen(subj) : 0) +							(url ? PL_strlen(url) : 0) + 100);	  if (!h)		{		  status = MIME_OUT_OF_MEMORY;		  goto FAIL;		}	  /* If there's a URL parameter, remove all whitespace from it.		 (The URL parameter to one of these headers is stored with		 lines broken every 40 characters or less; it's assumed that		 all significant whitespace was URL-hex-encoded, and all the		 rest of it was inserted just to keep the lines short.)	   */	  if (url)		{		  char *in, *out;		  for (in = url, out = url; *in; in++)			if (!IS_SPACE(*in))			  *out++ = *in;		  *out = 0;		}	  hdrs = MimeHeaders_new();	  if (!hdrs)		{		  status = MIME_OUT_OF_MEMORY;		  goto FAIL;		}# define FROB(STR,VAR) \	  if (VAR) \		{ \		  PL_strcpy(h, STR ": "); \		  PL_strcat(h, VAR); \		  PL_strcat(h, MSG_LINEBREAK); \		  status = MimeHeaders_parse_line(h, PL_strlen(h), hdrs); \		  if (status < 0) goto FAIL; \		}	  FROB("Access-Type",	at);	  FROB("URL",			url);	  FROB("Site",			site);	  FROB("Server",		svr);	  FROB("Directory",		dir);	  FROB("Name",			name);      FROB("Type",			ct);	  FROB("Size",			size);	  FROB("Mode",			mode);	  FROB("Permission",	perm);	  FROB("Expiration",	lexp);	  FROB("Subject",		subj);# undef FROB	  PL_strcpy(h, MSG_LINEBREAK);	  status = MimeHeaders_parse_line(h, PL_strlen(h), hdrs);	  if (status < 0) goto FAIL;	  lurl = MimeExternalBody_make_url(ct, at, lexp, size, perm, dir, mode,									   name, url, site, svr, subj, bod->body);	  if (lurl)		{		  lname = MimeGetStringByID(MIME_MSG_LINK_TO_DOCUMENT);		}	  else		{		  lname = MimeGetStringByID(MIME_MSG_DOCUMENT_INFO);		  all_headers_p = PR_TRUE;		}			  all_headers_p = PR_TRUE;  /* #### just do this all the time? */	  if (bod->body && all_headers_p)		{		  char *s = bod->body;		  while (IS_SPACE(*s)) s++;		  if (*s)			{			  char *s2;			  const char *pre = "<P><PRE>";			  const char *suf = "</PRE>";			  PRInt32 i;			  for(i = PL_strlen(s)-1; i >= 0 && IS_SPACE(s[i]); i--)				s[i] = 0; 			  s2 = nsEscapeHTML(s);			  if (!s2) goto FAIL;			  body = (char *) PR_MALLOC(PL_strlen(pre) + PL_strlen(s2) +									   PL_strlen(suf) + 1);			  if (!body)				{				  nsCRT::free(s2);				  goto FAIL;				}			  PL_strcpy(body, pre);			  PL_strcat(body, s2);			  PL_strcat(body, suf);			}		}	  newopt.fancy_headers_p = PR_TRUE;	  newopt.headers = (all_headers_p ? MimeHeadersAll : MimeHeadersSome);	  {		char p[] = "<P>";		status = MimeObject_write(obj, p, 3, PR_FALSE);		if (status < 0) goto FAIL;	  }	  status = MimeHeaders_write_attachment_box (hdrs, &newopt, ct, 0,												 lname, lurl, body);	  if (status < 0) goto FAIL;	  {		char p[] = "<P>";		status = MimeObject_write(obj, p, 3, PR_FALSE);		if (status < 0) goto FAIL;	  }	FAIL:	  if (hdrs)		MimeHeaders_free(hdrs);	  PR_FREEIF(h);	  PR_FREEIF(lname);	  PR_FREEIF(lurl);	  PR_FREEIF(body);	  PR_FREEIF(ct);	  PR_FREEIF(at);	  PR_FREEIF(lexp);	  PR_FREEIF(size);	  PR_FREEIF(perm);	  PR_FREEIF(dir);	  PR_FREEIF(mode);	  PR_FREEIF(name);	  PR_FREEIF(url);	  PR_FREEIF(site);	  PR_FREEIF(svr);	  PR_FREEIF(subj);	}#ifdef XP_MACdone:#endif /* XP_MAC */  return status;}