Source File modules/mm/mm.h

    1    | /***************************************
    2    |   $Revision: 1.6 $
    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: NOT COMPLETE, NOT REVUED, NOT TESTED
    9    |
    10   |   Design and implementation by: Daniele Arena
    11   |
    12   |   ******************/ /******************
    13   |   Copyright (c) 2000                              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   |
    34   | /* Included headers: */
    35   |
    36   | /* These come from c-client */
    37   | #include "mail.h"
    38   | #include "osdep.h"
    39   | #include "misc.h"
    40   | /*#include "rfc822.h"*/
    41   | /*#include "smtp.h"*/
    42   | /*#include "nntp.h"*/
    43   |
    44   |
    45   | /* Local #defines */
    46   |
    47   | #define NO_DEBUG 0
    48   | #define DO_DEBUG 1
    49   | #define DEFAULT_DEBUG DO_DEBUG
    50   | #define TEMPDIR "/tmp"
    51   | #define FILENAMELEN 1024
    52   | #define GLOBALPREFIX "mime"
    53   |
    54   | /* String sizes */
    55   | #define STR_S   63
    56   | #define STR_M   255
    57   | #define STR_L   1023
    58   | #define STR_XL  4095
    59   | #define STR_XXL 16383
    60   |
    61   |
    62   | /* Structure definition */
    63   |
    64   | typedef struct MM_body_section *sectptr;
    65   |
    66   | typedef struct MM_body_section {
    67   |   char *number;
    68   |   char *type;
    69   |   unsigned long size;
    70   |   char *mime_headers;
    71   |   char *contents;
    72   |   short supported;
    73   |   sectptr next;
    74   | } MM_b_section;
    75   |
    76   | typedef struct MM_body_section_list {
    77   |   int size;
    78   |   MM_b_section *head;
    79   |   MM_b_section *tail;
    80   | } MM_bs_list;
    81   |
    82   |
    83   | typedef struct MM_extracted_mimepart *partptr;
    84   |
    85   | typedef struct MM_extracted_mimepart {
    86   |   char *number;
    87   |   char *type;
    88   |   char *file;
    89   |   short supported;
    90   |   partptr next;
    91   | } MM_xmp;
    92   |
    93   | typedef struct MM_extracted_mimepart_list {
    94   |   int size;
    95   |   MM_xmp *head;
    96   |   MM_xmp *tail;
    97   | } MM_xmp_list;
    98   |
    99   |
    100  | typedef struct MM_mail_header {
    101  |   char *from;
    102  |   char *subject;
    103  |   char *date;
    104  |   char *message_id;
    105  |   char *reply_to;
    106  |   char *cc;
    107  | } MM_header;
    108  |
    109  |
    110  | #ifdef __cplusplus
    111  | extern "C" {
    112  | #endif
    113  |
    114  |
    115  | /* Function definition */
    116  |
    117  | /* API functions */
    118  | int MM_decode (char *mail_file, MM_header *mail_header, MM_xmp_list *part_list, long mesgno, long debug);
    119  | void MM_store (char *destination_file, long debug);
    120  | void MM_cleanup (MM_xmp_list *part_list, long debug);
    121  |
    122  | /* Internal support functions */
    123  | int mm (MAILSTREAM *stream, MM_header *hdr, MM_xmp_list *part_list, long mesgno, long debug);
    124  | void get_body_info (BODY *body,char *pfx,long i, MM_bs_list *sect_list, long debug);
    125  | void status (MAILSTREAM *stream);
    126  | void MM_bs_list_init (MM_bs_list *section_list);
    127  | void MM_bs_list_ins_last (MM_bs_list *section_list, MM_b_section *newsection);
    128  | void MM_xmp_list_init (MM_xmp_list *part_list);
    129  | void MM_xmp_list_ins_last (MM_xmp_list *part_list, MM_xmp *newpart);
    130  | char *get_header_line (MAILSTREAM *stream, long mesgno, STRINGLIST *cur, char *hdr_title);
    131  | void write_file (char *filename, char *text, size_t text_size);
    132  | void read_file (char *filename);
    133  | void put_in_file (char *fileprefix, char *extension, char *text, size_t text_size);
    134  | static int perform_regex_test(const char *pattern, char *string);
    135  |
    136  | #ifdef __cplusplus
    137  | }
    138  | #endif
    139  |
    140  |