Source File mm/mm.h

    1    | /***************************************
    2    |   $Revision: 2.17 $
    3    |
    4    |   mm - MIME Parser module. Functions to parse a mail message,
    5    |   find if it is MIME-encapsulated, and return the parts of
    6    |   the message which are supported by the UP module.
    7    |
    8    |   Status: COMPLETE, NOT REVUED, TESTED
    9    |
    10   |   Design and implementation by: daniele@ripe.net
    11   |
    12   |   ******************/ /******************
    13   |   Copyright (c) 2000,2001,2002                    RIPE NCC
    14   |
    15   |   All Rights Reserved
    16   |
    17   |   Permission to use, copy, modify, and distribute this software and its
    18   |   documentation for any purpose and without fee is hereby granted,
    19   |   provided that the above copyright notice appear in all copies and that
    20   |   both that copyright notice and this permission notice appear in
    21   |   supporting documentation, and that the name of the author not be
    22   |   used in advertising or publicity pertaining to distribution of the
    23   |   software without specific, written prior permission.
    24   |
    25   |   THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
    26   |   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS; IN NO EVENT SHALL
    27   |   AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
    28   |   DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
    29   |   AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    30   |   OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
    31   |   ***************************************/
    32   |
    33   | #ifndef _MM_H
    34   | #define _MM_H
    35   |
    36   |
    37   | /* Included headers: */
    38   |
    39   | /* These come from c-client */
    40   | #include "mail.h"
    41   | #include "osdep.h"
    42   | /*#include "misc.h"*/
    43   | /*#include "rfc822.h"*/
    44   | /*#include "smtp.h"*/
    45   | /*#include "nntp.h"*/
    46   |
    47   | /* Other RIP headers */
    48   | #include "gpg.h"
    49   | #include "mail_parser.h"
    50   | #include "memwrap.h"
    51   |
    52   | /* GLib */
    53   | #include "glib.h"
    54   |
    55   |
    56   |
    57   | /* String sizes */
    58   | #define STR_S   63
    59   | #define STR_M   255
    60   | #define STR_L   1023
    61   | #define STR_XL  4095
    62   | #define STR_XXL 16383
    63   |
    64   | #define LINELENGTH 80
    65   |
    66   | /* Set this as the max buffer size when you want to
    67   |    avoid buffer overflows */
    68   | #define MAXBUFSIZE 102400
    69   |
    70   | /* Local #defines */
    71   |
    72   | #define NO_DEBUG 0
    73   | #define DO_DEBUG 1
    74   | #define DEFAULT_DEBUG NO_DEBUG
    75   | #define TEMPDIR "/tmp"
    76   | #define FILENAMELEN STR_L
    77   | #define GLOBALPREFIX "mime"
    78   | #define MAXSUPPTYPES 50
    79   |
    80   |
    81   | /* Structure definition */
    82   |
    83   |
    84   |
    85   |
    86   | typedef struct MM_mail_header {
    87   |   char *from;
    88   |   char *subject;
    89   |   char *date;
    90   |   char *message_id;
    91   |   char *reply_to;
    92   |   char *cc;
    93   |   char *content_type;
    94   | } MM_header;
    95   |
    96   |
    97   | /* Needed for dbupdate, written in C++ */
    98   |
    99   | #ifdef __cplusplus
    100  | extern "C" {
    101  | #endif
    102  |
    103  |
    104  | /* Function definition */
    105  |
    106  | /* API functions */
    107  | int MM_store (char *source_file, char *destination_file,
    108  |               long custom_debug, int networkupdate);
    109  | int MM_get_msg_headers(const char *mail_file, EP_Mail_Descr *mail_descr, long mesgno, long custom_debug);
    110  | #define MM_get_headers(mail_file, mail_descr, custom_debug) MM_get_msg_headers(mail_file, mail_descr, (long) 1, custom_debug)
    111  | int MM_extract_mime (const char *sourcefile, char *pfx, EP_mail_node *mailnode, long custom_debug);
    112  |
    113  | /* Internal support functions */
    114  | void status (MAILSTREAM *stream);
    115  | Mail_Header_Field *get_mail_hdr_field (MAILSTREAM *stream, long mesgno, STRINGLIST *cur, const char *hdr_title);
    116  | char *get_header_line (MAILSTREAM *stream, long mesgno, STRINGLIST *cur, const char *hdr_title);
    117  | void write_file (char *filename, char *text, size_t text_size);
    118  | void read_file (const char *filename);
    119  | void put_in_file (char *fileprefix, char *extension, char *text, size_t text_size);
    120  | int do_regex_test(const char *pattern, char *string);
    121  | t_MM_type is_supported_MIMEtype (BODY *body);
    122  | void dispatch_to_driver(MAILSTREAM *stream, BODY *body, char *pfx, EP_mail_node *mailnode);
    123  |
    124  |
    125  | /* The drivers */
    126  | void parse_text_plain(MAILSTREAM *stream, BODY *body, char *pfx, EP_mail_node *mailnode);
    127  | void parse_multipart_alternative (MAILSTREAM *stream, BODY *body, char *pfx, EP_mail_node *mailnode);
    128  | void parse_multipart_signed (MAILSTREAM *stream, BODY *body, char *pfx, EP_mail_node *mailnode);
    129  | void parse_message_rfc822 (MAILSTREAM *stream, BODY *body, char *pfx, EP_mail_node *mailnode);
    130  | #define parse_application_pgp(stream, body, part_number, mailnode) parse_text_plain(stream, body, part_number, mailnode)
    131  | #define parse_unknown_unknown(stream, body, part_number, mailnode) parse_text_plain(stream, body, part_number, mailnode) /* We give a chance to the unsupported MIMEtypes to contain plain text updates... */
    132  | #define parse_multipart_mixed(stream, body, part_number, mailnode) parse_multipart_alternative(stream, body, part_number, mailnode)
    133  | #define parse_multipart_digest(stream, body, part_number, mailnode) parse_multipart_alternative(stream, body, part_number, mailnode)
    134  |
    135  | /* Needed for dbupdate, written in C++ */
    136  |
    137  | #ifdef __cplusplus
    138  | }
    139  | #endif
    140  |
    141  |
    142  | #endif /* _MM_H */