nsCRT::memset(obj->options->state, 0, sizeof(*obj->options->state));
memset(obj->options->state, 0, sizeof(*obj->options->state));
static int MimeObject_parse_begin (MimeObject *);static int MimeObject_parse_buffer (char *, PRInt32, MimeObject *);static int MimeObject_parse_line (char *, PRInt32, MimeObject *);static int MimeObject_parse_eof (MimeObject *, PRBool);static int MimeObject_parse_end (MimeObject *, PRBool);static PRBool MimeObject_displayable_inline_p (MimeObjectClass *clazz,												MimeHeaders *hdrs);#if defined(DEBUG) && defined(XP_UNIX)static int MimeObject_debug_print (MimeObject *, PRFileDesc *, PRInt32 depth);#endifstatic intMimeObjectClassInitialize(MimeObjectClass *clazz){  NS_ASSERTION(!clazz->class_initialized, "class shouldn't already be initialized");  clazz->initialize   = MimeObject_initialize;  clazz->finalize     = MimeObject_finalize;  clazz->parse_begin  = MimeObject_parse_begin;  clazz->parse_buffer = MimeObject_parse_buffer;  clazz->parse_line   = MimeObject_parse_line;  clazz->parse_eof    = MimeObject_parse_eof;  clazz->parse_end    = MimeObject_parse_end;  clazz->displayable_inline_p = MimeObject_displayable_inline_p;#if defined(DEBUG) && defined(XP_UNIX)  clazz->debug_print  = MimeObject_debug_print;#endif  return 0;}static intMimeObject_initialize (MimeObject *obj){  /* This is an abstract class; it shouldn't be directly instanciated. */  NS_ASSERTION(obj->clazz != &mimeObjectClass, "should directly instantiate abstract class");  /* Set up the content-type and encoding. */  if (!obj->content_type && obj->headers)	obj->content_type = MimeHeaders_get (obj->headers, HEADER_CONTENT_TYPE,										 PR_TRUE, PR_FALSE);  if (!obj->encoding && obj->headers)	obj->encoding = MimeHeaders_get (obj->headers,									 HEADER_CONTENT_TRANSFER_ENCODING,									 PR_TRUE, PR_FALSE);  /* Special case to normalize some types and encodings to a canonical form.	 (These are nonstandard types/encodings which have been seen to appear in	 multiple forms; we normalize them so that things like looking up icons	 and extensions has consistent behavior for the receiver, regardless of	 the "alias" type that the sender used.)   */  if (!obj->content_type)	;  else if (!nsCRT::strcasecmp(obj->content_type, APPLICATION_UUENCODE2) ||		   !nsCRT::strcasecmp(obj->content_type, APPLICATION_UUENCODE3) ||		   !nsCRT::strcasecmp(obj->content_type, APPLICATION_UUENCODE4))	{	  PR_Free(obj->content_type);	  obj->content_type = nsCRT::strdup(APPLICATION_UUENCODE);	}  else if (!nsCRT::strcasecmp(obj->content_type, IMAGE_XBM2) ||		   !nsCRT::strcasecmp(obj->content_type, IMAGE_XBM3))	{	  PR_Free(obj->content_type);	  obj->content_type = nsCRT::strdup(IMAGE_XBM);	}  if (!obj->encoding)	;  else if (!nsCRT::strcasecmp(obj->encoding, ENCODING_UUENCODE2) ||		   !nsCRT::strcasecmp(obj->encoding, ENCODING_UUENCODE3) ||		   !nsCRT::strcasecmp(obj->encoding, ENCODING_UUENCODE4))	{	  PR_Free(obj->encoding);	  obj->encoding = nsCRT::strdup(ENCODING_UUENCODE);	}  else if (!nsCRT::strcasecmp(obj->encoding, ENCODING_COMPRESS2))	{	  PR_Free(obj->encoding);	  obj->encoding = nsCRT::strdup(ENCODING_COMPRESS);	}  else if (!nsCRT::strcasecmp(obj->encoding, ENCODING_GZIP2))	{	  PR_Free(obj->encoding);	  obj->encoding = nsCRT::strdup(ENCODING_GZIP);	}  return 0;}static voidMimeObject_finalize (MimeObject *obj){  obj->clazz->parse_eof (obj, PR_FALSE);  obj->clazz->parse_end (obj, PR_FALSE);  if (obj->headers)	{	  MimeHeaders_free(obj->headers);	  obj->headers = 0;	}  /* Should have been freed by parse_eof, but just in case... */  NS_ASSERTION(!obj->ibuffer, "buffer not freed");  NS_ASSERTION(!obj->obuffer, "buffer not freed");  PR_FREEIF (obj->ibuffer);  PR_FREEIF (obj->obuffer);  PR_FREEIF(obj->content_type);  PR_FREEIF(obj->encoding);  if (obj->options && obj->options->state)	{	  PR_Free(obj->options->state);	  obj->options->state = 0;	}}static intMimeObject_parse_begin (MimeObject *obj){  NS_ASSERTION (!obj->closed_p, "object shouldn't be already closed");  /* If we haven't set up the state object yet, then this should be	 the outermost object... */  if (obj->options && !obj->options->state)	{	  NS_ASSERTION(!obj->headers, "headers should be null");  /* should be the outermost object. */	  obj->options->state = PR_NEW(MimeParseStateObject);	  if (!obj->options->state) return MIME_OUT_OF_MEMORY;    nsCRT::memset(obj->options->state, 0, sizeof(*obj->options->state));	  obj->options->state->root = obj;	  obj->options->state->separator_suppressed_p = PR_TRUE; /* no first sep */	}  /* Decide whether this object should be output or not... */  if (!obj->options || !obj->options->output_fn)	obj->output_p = PR_FALSE;  else if (!obj->options->part_to_load)	obj->output_p = PR_TRUE;  else	{	  char *id = mime_part_address(obj);	  if (!id) return MIME_OUT_OF_MEMORY;    // rhp: We need to check if a part is the subpart of an RFC822 message.    // If so and this is a raw output operation, then we should mark the     // part for subsequent output.    //    obj->output_p = PR_FALSE;	  PRBool exactMatch = !nsCRT::strcmp(id, obj->options->part_to_load);    if (exactMatch)    {      obj->output_p = PR_TRUE;    }    else    {      if (obj->options->format_out == nsMimeOutput::nsMimeMessageRaw)      {        if (obj->parent)          if (mime_typep(obj->parent, (MimeObjectClass*) &mimeMessageClass) ||            mime_typep(obj->parent, (MimeObjectClass*) &mimeMultipartAppleDoubleClass))          {            obj->output_p = !nsCRT::strncmp(id, obj->options->part_to_load,                                             nsCRT::strlen(obj->options->part_to_load));          }      }    }	  PR_Free(id);	}/* Way to destroy any notions of modularity or class hierarchy, Terry! */  if (obj->options && obj->options->nice_html_only_p) {	  if (!mime_subclass_p(obj->clazz,						   (MimeObjectClass*) &mimeInlineTextHTMLClass) &&		  !mime_subclass_p(obj->clazz,						   (MimeObjectClass*) &mimeInlineTextPlainClass) &&		  !mime_subclass_p(obj->clazz,						   (MimeObjectClass*) &mimeContainerClass)) {		  obj->output_p = PR_FALSE;	  }  }  return 0;}