Back to index

lightning-sunbird  0.9+nobinonly
sspm.h
Go to the documentation of this file.
00001 /* -*- Mode: C -*-
00002   ======================================================================
00003   FILE: sspm.h Mime Parser
00004   CREATOR: eric 25 June 2000
00005   
00006   $Id: sspm.h,v 1.2 2001/01/23 07:03:17 ebusboom Exp $
00007   $Locker:  $
00008     
00009  The contents of this file are subject to the Mozilla Public License
00010  Version 1.0 (the "License"); you may not use this file except in
00011  compliance with the License. You may obtain a copy of the License at
00012  http://www.mozilla.org/MPL/
00013  
00014  Software distributed under the License is distributed on an "AS IS"
00015  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00016  the License for the specific language governing rights and
00017  limitations under the License.
00018  
00019 
00020  This program is free software; you can redistribute it and/or modify
00021  it under the terms of either: 
00022 
00023     The LGPL as published by the Free Software Foundation, version
00024     2.1, available at: http://www.fsf.org/copyleft/lesser.html
00025 
00026   Or:
00027 
00028     The Mozilla Public License Version 1.0. You may obtain a copy of
00029     the License at http://www.mozilla.org/MPL/
00030 
00031   The Initial Developer of the Original Code is Eric Busboom
00032 
00033  (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
00034  ======================================================================*/
00035 
00036 #ifndef SSPM_H
00037 #define SSPM_H
00038 
00039 enum sspm_major_type {
00040     SSPM_NO_MAJOR_TYPE,
00041     SSPM_TEXT_MAJOR_TYPE,
00042     SSPM_IMAGE_MAJOR_TYPE,
00043     SSPM_AUDIO_MAJOR_TYPE,
00044     SSPM_VIDEO_MAJOR_TYPE,
00045     SSPM_APPLICATION_MAJOR_TYPE,
00046     SSPM_MULTIPART_MAJOR_TYPE,
00047     SSPM_MESSAGE_MAJOR_TYPE,
00048     SSPM_UNKNOWN_MAJOR_TYPE
00049 };
00050 
00051 enum sspm_minor_type {
00052     SSPM_NO_MINOR_TYPE,
00053     SSPM_ANY_MINOR_TYPE,
00054     SSPM_PLAIN_MINOR_TYPE,
00055     SSPM_RFC822_MINOR_TYPE,
00056     SSPM_DIGEST_MINOR_TYPE,
00057     SSPM_CALENDAR_MINOR_TYPE,
00058     SSPM_MIXED_MINOR_TYPE,
00059     SSPM_RELATED_MINOR_TYPE,
00060     SSPM_ALTERNATIVE_MINOR_TYPE,
00061     SSPM_PARALLEL_MINOR_TYPE,
00062     SSPM_UNKNOWN_MINOR_TYPE
00063 };
00064 
00065 enum sspm_encoding {
00066     SSPM_NO_ENCODING,
00067     SSPM_QUOTED_PRINTABLE_ENCODING,
00068     SSPM_8BIT_ENCODING,
00069     SSPM_7BIT_ENCODING,
00070     SSPM_BINARY_ENCODING,
00071     SSPM_BASE64_ENCODING,
00072     SSPM_UNKNOWN_ENCODING
00073 };
00074 
00075 enum sspm_error{
00076     SSPM_NO_ERROR,
00077     SSPM_UNEXPECTED_BOUNDARY_ERROR,
00078     SSPM_WRONG_BOUNDARY_ERROR,
00079     SSPM_NO_BOUNDARY_ERROR,
00080     SSPM_NO_HEADER_ERROR,
00081     SSPM_MALFORMED_HEADER_ERROR
00082 };
00083 
00084 
00085 struct sspm_header
00086 {
00087        int def;
00088        char* boundary;
00089        enum sspm_major_type major;
00090        enum sspm_minor_type minor;
00091        char *minor_text;
00092        char ** content_type_params;
00093        char* charset;
00094        enum sspm_encoding encoding;
00095        char* filename;
00096        char* content_id;
00097        enum sspm_error error;
00098        char* error_text;
00099 };
00100 
00101 struct sspm_part {
00102        struct sspm_header header;
00103        int level;
00104        size_t data_size;
00105        void *data;
00106 };
00107 
00108 struct sspm_action_map {
00109        enum sspm_major_type major;
00110        enum sspm_minor_type minor;
00111        void* (*new_part)();
00112        void (*add_line)(void *part, struct sspm_header *header, 
00113                       char* line, size_t size);
00114        void* (*end_part)(void* part);
00115        void (*free_part)(void *part);
00116 };
00117 
00118 char* sspm_major_type_string(enum sspm_major_type type);
00119 char* sspm_minor_type_string(enum sspm_minor_type type);
00120 char* sspm_encoding_string(enum sspm_encoding type);
00121 
00122 int sspm_parse_mime(struct sspm_part *parts, 
00123                   size_t max_parts,
00124                   struct sspm_action_map *actions,
00125                   char* (*get_string)(char *s, size_t size, void* data),
00126                   void *get_string_data,
00127                   struct sspm_header *first_header
00128     );
00129 
00130 void sspm_free_parts(struct sspm_part *parts, size_t max_parts);
00131 
00132 char *decode_quoted_printable(char *dest, 
00133                                    char *src,
00134                                    size_t *size);
00135 char *decode_base64(char *dest, 
00136                           char *src,
00137                           size_t *size);
00138 
00139 
00140 int sspm_write_mime(struct sspm_part *parts,size_t num_parts,
00141                   char **output_string, char* header);
00142 
00143 #endif /*SSPM_H*/