/******************************************************************************/
/*
                                  mime.h
*/
/******************************************************************************/

#ifndef INCLUDE_MIME_H
#define INCLUDE_MIME_H

/*************/
/* constants */
/*************/

#define MIME_CONTENT_TEXT_PLAIN      1
#define MIME_CONTENT_TEXT_HTML       2
#define MIME_CONTENT_OCTET_STREAM    3
#define MIME_CONTENT_MULTIPART       4
#define MIME_CONTENT_MULTIPART_ALT   5
#define MIME_CONTENT_MULTIPART_MIX   6
#define MIME_CONTENT_MESSAGE_RFC822  7
#define MIME_CONTENT_OTHER          99

#define MIME_TRANSENC_7BIT           1
#define MIME_TRANSENC_8BIT           2
#define MIME_TRANSENC_BASE64         3
#define MIME_TRANSENC_QUOTED         4
#define MIME_TRANSENC_OTHER         99

/*******************/
/* data structures */
/*******************/

#ifndef __VAX
#   pragma member_alignment __save
#   pragma member_alignment
#endif

typedef struct STRUCT_MIME_DATA
{
   BOOL  /* this content has been created from non-MIME content */
         ManufacturedMime,
         /* keep track of what's been done to the MIME content */
         MessageParsed,
         /* keep track of what's been done to the MIME content */
         PartDecoded;

   /* zero in message MIME header, one to whatever are MIME parts */
   int  HtmlCount,
        PartCount,
        PlainCount;

   /* the MIME part body in the in-memory message */
   char  *PartContentPtr;
   int  PartContentLength;

   /* boundary string */
   char  *BoundaryPtr;
   int  BoundaryLength;

   /* any character set associated with a textual content-type */
   char  *CharSetPtr;

   /* content-type (e.g. text/plain, image/jpeg) */
   char  *ContentTypePtr;
   int  ContentTypeIs;
   BOOL  ContentTypeIsMultipart;

   /* arbitrary textual description of entity */
   char  *ContentDescriptionPtr;

   /* presentation (inline or attachement) */
   char  *ContentDispositionPtr;

   /* opaque identifier string for the entity */
   char  *ContentIdPtr;

   /* length of the entity in bytes */
   char  *ContentLengthPtr;
   int  ContentLength;

   /* URL location of content */
   char  *ContentLocationPtr;

   /* name of entity (as supplied with content-type, ";name=<..>", etc.) */
   char  *NamePtr;
   char  *FileNamePtr;

   /* encoding (e.g. 7bit, 8bit/binary, quoted-printable, base64, etc.) */
   char  *TransferEncodingPtr;
   int  TransferEncodingIs;
   char  *EncodedContentPtr;

   /* format (e.g. "flowed") */
   char  *FormatPtr;

   /* unnamed (no name= or filename=) part, "part1" ... "partn" */
   char  PartName [64];
   /* this part is the displayed message */
   BOOL  MessagePart;

   /* MIME version */
   char  *VersionPtr;
   int  VersionNumber;  /* 10 for 1.0 */

   /* if this part is plain text converted from an HTML part */
   struct STRUCT_MIME_DATA  *HtmlToPlainMimePtr;

   struct STRUCT_MIME_DATA  *NextMimePtr;

} MIME_DATA;

/* forward reference */
typedef struct STRUCT_VMS_MAIL_MSG VMS_MAIL_MSG;

#ifndef __VAX
#   pragma member_alignment __restore
#endif

/**************/
/* prototypes */
/**************/

int MimeDecParseBody (MIME_DATA*);
void MimeDecParseError (MIME_DATA*, char*, char*, int);
void MimeDecParseFree (MIME_DATA*);
int MimeDec7bit (MIME_DATA*);
int MimeDec8bit (MIME_DATA*);
int MimeDecBase64 (char*);
int MimeDecIsoString (char*);
MIME_DATA* MimeDecManufacTextPlain (char*, int, int);
MIME_DATA* MimeDecManufacTextHtml (char*, int, int);
MIME_DATA* MimeDecManufacVmsForeign (char*, int);
int MimeDecProcessPart (MIME_DATA*);
int MimeDecQuotedPrintable (char*);
char* MimeEncIsoString (char*, char*);
int MimeEncNeedsQuotedPrintable (char*);
char* MimeEncQuotedPrintable (char*, int);
char* MimeEncBase64 (char*, int, char*);

#endif /* INCLUDE_MIME_H */

/******************************************************************************/

