00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef SSPM_H
00038 #define SSPM_H
00039
00040 enum sspm_major_type {
00041 SSPM_NO_MAJOR_TYPE,
00042 SSPM_TEXT_MAJOR_TYPE,
00043 SSPM_IMAGE_MAJOR_TYPE,
00044 SSPM_AUDIO_MAJOR_TYPE,
00045 SSPM_VIDEO_MAJOR_TYPE,
00046 SSPM_APPLICATION_MAJOR_TYPE,
00047 SSPM_MULTIPART_MAJOR_TYPE,
00048 SSPM_MESSAGE_MAJOR_TYPE,
00049 SSPM_UNKNOWN_MAJOR_TYPE
00050 };
00051
00052 enum sspm_minor_type {
00053 SSPM_NO_MINOR_TYPE,
00054 SSPM_ANY_MINOR_TYPE,
00055 SSPM_PLAIN_MINOR_TYPE,
00056 SSPM_RFC822_MINOR_TYPE,
00057 SSPM_DIGEST_MINOR_TYPE,
00058 SSPM_CALENDAR_MINOR_TYPE,
00059 SSPM_MIXED_MINOR_TYPE,
00060 SSPM_RELATED_MINOR_TYPE,
00061 SSPM_ALTERNATIVE_MINOR_TYPE,
00062 SSPM_PARALLEL_MINOR_TYPE,
00063 SSPM_UNKNOWN_MINOR_TYPE
00064 };
00065
00066 enum sspm_encoding {
00067 SSPM_NO_ENCODING,
00068 SSPM_QUOTED_PRINTABLE_ENCODING,
00069 SSPM_8BIT_ENCODING,
00070 SSPM_7BIT_ENCODING,
00071 SSPM_BINARY_ENCODING,
00072 SSPM_BASE64_ENCODING,
00073 SSPM_UNKNOWN_ENCODING
00074 };
00075
00076 enum sspm_error{
00077 SSPM_NO_ERROR,
00078 SSPM_UNEXPECTED_BOUNDARY_ERROR,
00079 SSPM_WRONG_BOUNDARY_ERROR,
00080 SSPM_NO_BOUNDARY_ERROR,
00081 SSPM_NO_HEADER_ERROR,
00082 SSPM_MALFORMED_HEADER_ERROR
00083 };
00084
00085
00086 struct sspm_header
00087 {
00088 int def;
00089 char* boundary;
00090 enum sspm_major_type major;
00091 enum sspm_minor_type minor;
00092 char *minor_text;
00093 char ** content_type_params;
00094 char* charset;
00095 enum sspm_encoding encoding;
00096 char* filename;
00097 char* content_id;
00098 enum sspm_error error;
00099 char* error_text;
00100 };
00101
00102 struct sspm_part {
00103 struct sspm_header header;
00104 int level;
00105 size_t data_size;
00106 void *data;
00107 };
00108
00109 struct sspm_action_map {
00110 enum sspm_major_type major;
00111 enum sspm_minor_type minor;
00112 void* (*new_part)();
00113 void (*add_line)(void *part, struct sspm_header *header,
00114 const char* line, size_t size);
00115 void* (*end_part)(void* part);
00116 void (*free_part)(void *part);
00117 };
00118
00119 const char* sspm_major_type_string(enum sspm_major_type type);
00120 const char* sspm_minor_type_string(enum sspm_minor_type type);
00121 const char* sspm_encoding_string(enum sspm_encoding type);
00122
00123 int sspm_parse_mime(struct sspm_part *parts,
00124 size_t max_parts,
00125 struct sspm_action_map *actions,
00126 char* (*get_string)(char *s, size_t size, void* data),
00127 void *get_string_data,
00128 struct sspm_header *first_header
00129 );
00130
00131 void sspm_free_parts(struct sspm_part *parts, size_t max_parts);
00132
00133 char *decode_quoted_printable(char *dest,
00134 char *src,
00135 size_t *size);
00136 char *decode_base64(char *dest,
00137 char *src,
00138 size_t *size);
00139
00140
00141 int sspm_write_mime(struct sspm_part *parts,size_t num_parts,
00142 char **output_string, const char* header);
00143
00144 #endif