else if (!nsCRT::strcasecmp(obj->encoding, ENCODING_YENCODE)) fn = &MimeYDecoderInit;
static void MimeEncrypted_finalize (MimeObject *);static int MimeEncrypted_parse_begin (MimeObject *);static int MimeEncrypted_parse_buffer (char *, PRInt32, MimeObject *);static int MimeEncrypted_parse_line (char *, PRInt32, MimeObject *);static int MimeEncrypted_parse_decoded_buffer (char *, PRInt32, MimeObject *);static int MimeEncrypted_parse_eof (MimeObject *, PRBool);static int MimeEncrypted_parse_end (MimeObject *, PRBool);static int MimeEncrypted_add_child (MimeObject *, MimeObject *);static int MimeHandleDecryptedOutput (const char *, PRInt32, void *);static int MimeHandleDecryptedOutputLine (char *, PRInt32, MimeObject *);static int MimeEncrypted_close_headers (MimeObject *);static int MimeEncrypted_emit_buffered_child(MimeObject *);static intMimeEncryptedClassInitialize(MimeEncryptedClass *clazz){  MimeObjectClass    *oclass = (MimeObjectClass *)    clazz;  MimeContainerClass *cclass = (MimeContainerClass *) clazz;  NS_ASSERTION(!oclass->class_initialized, "1.2 <mscott@netscape.com> 01 Nov 2001 17:59");  oclass->initialize   = MimeEncrypted_initialize;  oclass->finalize     = MimeEncrypted_finalize;  oclass->parse_begin  = MimeEncrypted_parse_begin;  oclass->parse_buffer = MimeEncrypted_parse_buffer;  oclass->parse_line   = MimeEncrypted_parse_line;  oclass->parse_eof    = MimeEncrypted_parse_eof;  oclass->parse_end    = MimeEncrypted_parse_end;  cclass->add_child    = MimeEncrypted_add_child;  clazz->parse_decoded_buffer = MimeEncrypted_parse_decoded_buffer;  return 0;}static intMimeEncrypted_initialize (MimeObject *obj){  return ((MimeObjectClass*)&MIME_SUPERCLASS)->initialize(obj);}static intMimeEncrypted_parse_begin (MimeObject *obj){  MimeEncrypted *enc = (MimeEncrypted *) obj;  MimeDecoderData *(*fn) (nsresult (*) (const char*, PRInt32, void*), void*) = 0;  if (enc->crypto_closure)	return -1;  enc->crypto_closure = (((MimeEncryptedClass *) obj->clazz)->crypto_init) (obj, MimeHandleDecryptedOutput, obj);  if (!enc->crypto_closure)	return -1;  /* (Mostly duplicated from MimeLeaf, see comments in mimecryp.h.)     Initialize a decoder if necessary.   */  if (!obj->encoding)	;  else if (!nsCRT::strcasecmp(obj->encoding, ENCODING_BASE64))	fn = &MimeB64DecoderInit;  else if (!nsCRT::strcasecmp(obj->encoding, ENCODING_QUOTED_PRINTABLE))	fn = &MimeQPDecoderInit;  else if (!nsCRT::strcasecmp(obj->encoding, ENCODING_UUENCODE) ||		   !nsCRT::strcasecmp(obj->encoding, ENCODING_UUENCODE2) ||		   !nsCRT::strcasecmp(obj->encoding, ENCODING_UUENCODE3) ||		   !nsCRT::strcasecmp(obj->encoding, ENCODING_UUENCODE4))	fn = &MimeUUDecoderInit;  if (fn)	{	  enc->decoder_data =		fn (/* The (int (*) ...) cast is to turn the `void' argument			   into `MimeObject'. */			((nsresult (*) (const char *, PRInt32, void *))			 ((MimeEncryptedClass *)obj->clazz)->parse_decoded_buffer),			obj);	  if (!enc->decoder_data)		return MIME_OUT_OF_MEMORY;	}  return ((MimeObjectClass*)&MIME_SUPERCLASS)->parse_begin(obj);}static intMimeEncrypted_parse_buffer (char *buffer, PRInt32 size, MimeObject *obj){  /* (Duplicated from MimeLeaf, see comments in mimecryp.h.)   */  MimeEncrypted *enc = (MimeEncrypted *) obj;  if (obj->closed_p) return -1;  /* Don't consult output_p here, since at this point we're behaving as a	 simple container object -- the output_p decision should be made by	 the child of this object. */  if (enc->decoder_data)	return MimeDecoderWrite (enc->decoder_data, buffer, size);  else	return ((MimeEncryptedClass *)obj->clazz)->parse_decoded_buffer (buffer,																	 size,																	 obj);}static intMimeEncrypted_parse_line (char *line, PRInt32 length, MimeObject *obj){  NS_ASSERTION(0, "1.2 <mscott@netscape.com> 01 Nov 2001 17:59");  /* This method shouldn't ever be called. */  return -1;}static intMimeEncrypted_parse_decoded_buffer (char *buffer, PRInt32 size, MimeObject *obj){  MimeEncrypted *enc = (MimeEncrypted *) obj;  return	((MimeEncryptedClass *) obj->clazz)->crypto_write (buffer, size,													   enc->crypto_closure);}static intMimeEncrypted_parse_eof (MimeObject *obj, PRBool abort_p){  int status = 0;  MimeEncrypted *enc = (MimeEncrypted *) obj;  if (obj->closed_p) return 0;  NS_ASSERTION(!obj->parsed_p, "1.2 <mscott@netscape.com> 01 Nov 2001 17:59");  /* (Duplicated from MimeLeaf, see comments in mimecryp.h.)     Close off the decoder, to cause it to give up any buffered data that	 it is still holding.   */  if (enc->decoder_data)	{	  int status = MimeDecoderDestroy(enc->decoder_data, PR_FALSE);	  enc->decoder_data = 0;	  if (status < 0) return status;	}  /* If there is still data in the ibuffer, that means that the last	 *decrypted* line of this part didn't end in a newline; so push it out	 anyway (this means that the parse_line method will be called with a	 string with no trailing newline, which isn't the usual case.)  */  if (!abort_p &&	  obj->ibuffer_fp > 0)	{	  int status = MimeHandleDecryptedOutputLine (obj->ibuffer,												  obj->ibuffer_fp, obj);	  obj->ibuffer_fp = 0;	  if (status < 0)		{		  obj->closed_p = PR_TRUE;		  return status;		}	}  /* Now run the superclass's parse_eof, which (because we've already taken	 care of ibuffer in a way appropriate for this class, immediately above)	 will ony set closed_p to true.   */  status = ((MimeObjectClass*)&MIME_SUPERCLASS)->parse_eof (obj, abort_p);  if (status < 0) return status;  /* Now close off the underlying crypto module.  At this point, the crypto	 module has all of the input.  (DecoderDestroy called parse_decoded_buffer	 which called crypto_write, with the last of the data.)   */  if (enc->crypto_closure)	{	  status =		((MimeEncryptedClass *) obj->clazz)->crypto_eof (enc->crypto_closure,														 abort_p);	  if (status < 0 && !abort_p)		return status;	}  /* Now we have the entire child part in the part buffer.	 We are now able to verify its signature, emit a blurb, and then	 emit the part.   */  if (abort_p)	return 0;  else	return MimeEncrypted_emit_buffered_child (obj);}static intMimeEncrypted_parse_end (MimeObject *obj, PRBool abort_p){  return ((MimeObjectClass*)&MIME_SUPERCLASS)->parse_end (obj, abort_p);}static voidMimeEncrypted_cleanup (MimeObject *obj, PRBool finalizing_p){  MimeEncrypted *enc = (MimeEncrypted *) obj;  if (enc->part_buffer)	{	  MimePartBufferDestroy(enc->part_buffer);	  enc->part_buffer = 0;	}  if (finalizing_p && enc->crypto_closure)	{	  /* Don't free these until this object is really going away -- keep them		 around for the lifetime of the MIME object, so that we can get at the		 security info of sub-parts of the currently-displayed message. */	  ((MimeEncryptedClass *) obj->clazz)->crypto_free (enc->crypto_closure);	  enc->crypto_closure = 0;	}  /* (Duplicated from MimeLeaf, see comments in mimecryp.h.)	 Free the decoder data, if it's still around. */  if (enc->decoder_data)	{	  MimeDecoderDestroy(enc->decoder_data, PR_TRUE);	  enc->decoder_data = 0;	}  if (enc->hdrs)	{	  MimeHeaders_free(enc->hdrs);	  enc->hdrs = 0;	}}static voidMimeEncrypted_finalize (MimeObject *obj){  MimeEncrypted_cleanup (obj, PR_TRUE);  ((MimeObjectClass*)&MIME_SUPERCLASS)->finalize (obj);}