tmp->real_type = child->content_type ? PL_strdup(child->content_type) : NULL; tmp->real_encoding = child->encoding ? PL_strdup(child->encoding) : NULL;
tmp->real_type = child->content_type ? nsCRT::strdup(child->content_type) : NULL; tmp->real_encoding = child->encoding ? nsCRT::strdup(child->encoding) : NULL;
MimeGetAttachmentList(MimeObject *tobj, const char *aMessageURL, nsMsgAttachmentData **data){  extern nsresult       nsMimeNewURI(nsIURI** aInstancePtrResult, const char *aSpec);  MimeContainer         *cobj;  nsMsgAttachmentData   *tmp;  PRInt32               n;  PRInt32               i;  char                  *disp;  PRBool                isMsgBody = PR_FALSE, isAlternativeOrRelated = PR_FALSE;  MimeObject            *obj;  if (!data)     return 0;  *data = NULL;  obj = mime_get_main_object(tobj);  if ( (obj) && (!mime_subclass_p(obj->clazz, (MimeObjectClass*) &mimeContainerClass)) )    return 0;  isMsgBody = MimeObjectChildIsMessageBody(obj, &isAlternativeOrRelated);  if (isAlternativeOrRelated)    return 0;    cobj = (MimeContainer*) obj;  n = cobj->nchildren;          /* This is often too big, but that's OK. */  if (n <= 0)     return n;  *data = (nsMsgAttachmentData *)PR_Malloc( (n + 1) * sizeof(MSG_AttachmentData));  if (!*data)     return NS_ERROR_OUT_OF_MEMORY;  nsCRT::memset(*data, 0, (n + 1) * sizeof(MSG_AttachmentData));  tmp = *data;    // let's figure out where to start..  if (isMsgBody)    i = 1;  else    i = 0;    for (; i<cobj->nchildren ; i++, tmp++)   {    MimeObject    *child = cobj->children[i];    char          *part = mime_part_address(child);    char          *imappart = NULL;    if (!part)       return NS_ERROR_OUT_OF_MEMORY;    if (obj->options->missing_parts)      imappart = mime_imap_part_address(child);    char *urlSpec = nsnull;    if (imappart)    {      urlSpec = mime_set_url_imap_part(aMessageURL, imappart, part);    }    else    {      urlSpec = mime_set_url_part(aMessageURL, part, PR_TRUE);    }      if (!urlSpec)      return NS_ERROR_OUT_OF_MEMORY;    nsresult rv = nsMimeNewURI(&(tmp->url), urlSpec);    if ( (NS_FAILED(rv)) || (!tmp->url) )      return NS_ERROR_OUT_OF_MEMORY;    tmp->real_type = child->content_type ? PL_strdup(child->content_type) : NULL;    tmp->real_encoding = child->encoding ? PL_strdup(child->encoding) : NULL;    disp = MimeHeaders_get(child->headers, HEADER_CONTENT_DISPOSITION, PR_FALSE, PR_FALSE);    if (disp)     {      tmp->real_name = MimeHeaders_get_parameter(disp, "filename", NULL, NULL);      if (tmp->real_name)      {        char *fname = NULL;        fname = mime_decode_filename(tmp->real_name);        if (fname && fname != tmp->real_name)        {          PR_FREEIF(tmp->real_name);          tmp->real_name = fname;        }      }      PR_FREEIF(disp);    }    disp = MimeHeaders_get(child->headers, HEADER_CONTENT_TYPE, PR_FALSE, PR_FALSE);    if (disp)    {      tmp->x_mac_type   = MimeHeaders_get_parameter(disp, PARAM_X_MAC_TYPE, NULL, NULL);      tmp->x_mac_creator= MimeHeaders_get_parameter(disp, PARAM_X_MAC_CREATOR, NULL, NULL);      if (!tmp->real_name || *tmp->real_name == 0)      {        PR_FREEIF(tmp->real_name);        tmp->real_name = MimeHeaders_get_parameter(disp, "name", NULL, NULL);        if (tmp->real_name)        {          char *fname = NULL;          fname = mime_decode_filename(tmp->real_name);          if (fname && fname != tmp->real_name)          {            PR_Free(tmp->real_name);            tmp->real_name = fname;          }        }      }      PR_FREEIF(disp);    }    tmp->description = MimeHeaders_get(child->headers, HEADER_CONTENT_DESCRIPTION, PR_FALSE, PR_FALSE);    if (tmp->real_type && !PL_strcasecmp(tmp->real_type, MESSAGE_RFC822) &&        (!tmp->real_name || *tmp->real_name == 0))    {      mime_SACopy(&(tmp->real_name), "forward.msg");    }  }  return NS_OK;}