move debug.c
[apps/madmutt.git] / lib-mime / mime.h
index 464a840..4e678e4 100644 (file)
 #define MUTT_LIB_MIME_MIME_H
 
 #include <stdlib.h>
+#include <stdio.h>
 
-#include <lib-lib/mem.h>
-#include <lib-lib/buffer.h>
-#include <lib-lib/list.h>
-
-/* Content-Type */
-enum {
-    TYPEOTHER,
-    TYPEAUDIO,
-    TYPEAPPLICATION,
-    TYPEIMAGE,
-    TYPEMESSAGE,
-    TYPEMODEL,
-    TYPEMULTIPART,
-    TYPETEXT,
-    TYPEVIDEO,
-    TYPEANY
-};
-
-/* Content-Transfer-Encoding */
-enum {
-    ENCOTHER,
-    ENC7BIT,
-    ENC8BIT,
-    ENCQUOTEDPRINTABLE,
-    ENCBASE64,
-    ENCBINARY,
-    ENCUUENCODED
-};
-
-/* Content-Disposition values */
-enum {
-    DISPINLINE,
-    DISPATTACH,
-    DISPFORMDATA
-};
-
-typedef struct parameter {
-    char *attribute;
-    char *value;
-    struct parameter *next;
-} PARAMETER;
-
-typedef struct address_t {
-    char *personal;               /* real name of address */
-    char *mailbox;                /* mailbox and host address */
-    int group;                    /* group mailbox? */
-    struct address_t *next;
-} address_t;
-
-typedef struct envelope_t {
-    address_t *return_path;
-    address_t *from;
-    address_t *to;
-    address_t *cc;
-    address_t *bcc;
-    address_t *sender;
-    address_t *reply_to;
-    address_t *mail_followup_to;
-    char *list_post;              /* this stores a mailto URL, or nothing */
-    char *subject;
-    char *real_subj;              /* offset of the real subject */
-    char *message_id;
-    char *supersedes;
-    char *date;
-    char *x_label;
-    char *organization;
-#ifdef USE_NNTP
-    char *newsgroups;
-    char *xref;
-    char *followup_to;
-    char *x_comment_to;
-#endif
-    BUFFER *spam;
-    LIST *references;             /* message references (in reverse order) */
-    LIST *in_reply_to;            /* in-reply-to header content */
-    LIST *userhdrs;               /* user defined headers */
-    unsigned int irt_changed:1;   /* In-Reply-To changed to link/break threads */
-    unsigned int refs_changed:1;  /* References changed to break thread */
-} ENVELOPE;
-
-
-DO_INIT(address_t, address);
-void address_wipe(address_t *);
-
-DO_NEW(address_t, address);
-DO_DELETE(address_t, address);
-DO_SLIST(address_t, address);
-
+#include "mime-types.h"
+#include "mime-token.h"
 
 extern const char MimeSpecials[];
 extern const char *BodyTypes[];
@@ -129,8 +44,10 @@ extern const char *BodyEncodings[];
 
 #define is_multipart(x) \
     ((x)->type == TYPEMULTIPART \
-     || ((x)->type == TYPEMESSAGE && (!strcasecmp((x)->subtype, "rfc822") \
-                                      || !strcasecmp((x)->subtype, "news"))))
+     || ((x)->type == TYPEMESSAGE && \
+         ((!mime_which_token((x)->subtype, -1) == MIME_RFC822) \
+         || !mime_which_token((x)->subtype, -1) == MIME_NEWS)))
+
 #define TYPE(X) ((X->type == TYPEOTHER) && (X->xtype != NULL) ? X->xtype : BodyTypes[(X->type)])
 #define ENCODING(X) BodyEncodings[(X)]
 
@@ -139,6 +56,25 @@ extern const char *BodyEncodings[];
 /*                Standard for ARPA Internet Text Messages                  */
 /****************************************************************************/
 
+extern const char RFC822Specials[];
+
+ssize_t mutt_read_rfc822_line(FILE*, char**, ssize_t*);
+LIST *mutt_parse_references(char *, int);
+int mutt_check_encoding(const char *);
+int mutt_check_mime_type(const char *);
+void mutt_parse_content_type(char *, BODY *);
+BODY *mutt_read_mime_header (FILE *, int);
+void mutt_parse_part(FILE *, BODY *);
+BODY *mutt_parse_messageRFC822(FILE *, BODY *);
+BODY *mutt_parse_multipart(FILE *, const char *, off_t, int);
+LIST **mutt_parse_rfc822_line(ENVELOPE *, HEADER *, char *line, char *p,
+                              short weed, short do_2047, LIST **);
+ENVELOPE *mutt_read_rfc822_header(FILE *, HEADER *, short, short);
+int mutt_count_body_parts (HEADER *hdr, int flags);
+
+/*** addresses ***/
+
+address_t *mutt_parse_adrlist (address_t *, const char *);
 address_t *address_dup(address_t *addr);
 address_t *address_list_dup(address_t *addr);
 void rfc822_qualify(address_t *, const char *);
@@ -149,8 +85,6 @@ ssize_t rfc822_write_address(char *, ssize_t, address_t *, int);
 ssize_t rfc822_write_address_single(char *, ssize_t, address_t *, int);
 ssize_t rfc822_strcpy(char *, ssize_t, const char *, const char *);
 
-extern const char RFC822Specials[];
-
 /****************************************************************************/
 /* RFC 2047                                                                 */
 /*       MIME (Multipurpose Internet Mail Extensions) Part Three:           */
@@ -158,7 +92,7 @@ extern const char RFC822Specials[];
 /****************************************************************************/
 
 char *mutt_choose_charset(const char *fromcode, const char *charsets,
-                          char *u, size_t ulen, char **d, size_t *dlen);
+                          char *u, ssize_t ulen, char **d, ssize_t *dlen);
 
 void rfc2047_encode_string(char **);
 void rfc2047_encode_adrlist(address_t *, const char *);