Libical API Documentation  3.0
sspm.h
1 /*======================================================================
2  FILE: sspm.h Mime Parser
3  CREATOR: eric 25 June 2000
4 
5  (C) COPYRIGHT 2000, Eric Busboom <eric@softwarestudio.org>
6  http://www.softwarestudio.org
7 
8  This library is free software; you can redistribute it and/or modify
9  it under the terms of either:
10 
11  The LGPL as published by the Free Software Foundation, version
12  2.1, available at: http://www.gnu.org/licenses/lgpl-2.1.html
13 
14  Or:
15 
16  The Mozilla Public License Version 2.0. You may obtain a copy of
17  the License at http://www.mozilla.org/MPL/
18 
19  This library is free software; you can redistribute it and/or modify
20  it under the terms of either:
21 
22  The LGPL as published by the Free Software Foundation, version
23  2.1, available at: http://www.gnu.org/licenses/lgpl-2.1.html
24 
25  Or:
26 
27  The Mozilla Public License Version 2.0. You may obtain a copy of
28  the License at http://www.mozilla.org/MPL/
29 
30  The Initial Developer of the Original Code is Eric Busboom
31 ======================================================================*/
32 
33 #ifndef ICAL_SSPM_H
34 #define ICAL_SSPM_H
35 
36 #include "libical_ical_export.h"
37 
38 enum sspm_major_type
39 {
40  SSPM_NO_MAJOR_TYPE,
41  SSPM_TEXT_MAJOR_TYPE,
42  SSPM_IMAGE_MAJOR_TYPE,
43  SSPM_AUDIO_MAJOR_TYPE,
44  SSPM_VIDEO_MAJOR_TYPE,
45  SSPM_APPLICATION_MAJOR_TYPE,
46  SSPM_MULTIPART_MAJOR_TYPE,
47  SSPM_MESSAGE_MAJOR_TYPE,
48  SSPM_UNKNOWN_MAJOR_TYPE
49 };
50 
51 enum sspm_minor_type
52 {
53  SSPM_NO_MINOR_TYPE,
54  SSPM_ANY_MINOR_TYPE,
55  SSPM_PLAIN_MINOR_TYPE,
56  SSPM_RFC822_MINOR_TYPE,
57  SSPM_DIGEST_MINOR_TYPE,
58  SSPM_CALENDAR_MINOR_TYPE,
59  SSPM_MIXED_MINOR_TYPE,
60  SSPM_RELATED_MINOR_TYPE,
61  SSPM_ALTERNATIVE_MINOR_TYPE,
62  SSPM_PARALLEL_MINOR_TYPE,
63  SSPM_UNKNOWN_MINOR_TYPE
64 };
65 
66 enum sspm_encoding
67 {
68  SSPM_NO_ENCODING,
69  SSPM_QUOTED_PRINTABLE_ENCODING,
70  SSPM_8BIT_ENCODING,
71  SSPM_7BIT_ENCODING,
72  SSPM_BINARY_ENCODING,
73  SSPM_BASE64_ENCODING,
74  SSPM_UNKNOWN_ENCODING
75 };
76 
77 enum sspm_error
78 {
79  SSPM_NO_ERROR,
80  SSPM_UNEXPECTED_BOUNDARY_ERROR,
81  SSPM_WRONG_BOUNDARY_ERROR,
82  SSPM_NO_BOUNDARY_ERROR,
83  SSPM_NO_HEADER_ERROR,
84  SSPM_MALFORMED_HEADER_ERROR
85 };
86 
88 {
89  int def;
90  char *boundary;
91  enum sspm_major_type major;
92  enum sspm_minor_type minor;
93  char *minor_text;
94  char **content_type_params;
95  char *charset;
96  enum sspm_encoding encoding;
97  char *filename;
98  char *content_id;
99  enum sspm_error error;
100  char *error_text;
101 };
102 
103 struct sspm_part
104 {
105  struct sspm_header header;
106  int level;
107  size_t data_size;
108  void *data;
109 };
110 
112 {
113  enum sspm_major_type major;
114  enum sspm_minor_type minor;
115  void *(*new_part) (void);
116  void (*add_line) (void *part, struct sspm_header * header, const char *line, size_t size);
117  void *(*end_part) (void *part);
118  void (*free_part) (void *part);
119 };
120 
121 LIBICAL_ICAL_EXPORT const char *sspm_major_type_string(enum sspm_major_type type);
122 
123 LIBICAL_ICAL_EXPORT const char *sspm_minor_type_string(enum sspm_minor_type type);
124 
125 LIBICAL_ICAL_EXPORT const char *sspm_encoding_string(enum sspm_encoding type);
126 
127 LIBICAL_ICAL_EXPORT int sspm_parse_mime(struct sspm_part *parts,
128  size_t max_parts,
129  const struct sspm_action_map *actions,
130  char *(*get_string) (char *s, size_t size, void *data),
131  void *get_string_data, struct sspm_header *first_header);
132 
133 LIBICAL_ICAL_EXPORT void sspm_free_parts(struct sspm_part *parts, size_t max_parts);
134 
135 LIBICAL_ICAL_EXPORT char *decode_quoted_printable(char *dest, char *src, size_t *size);
136 
137 LIBICAL_ICAL_EXPORT char *decode_base64(char *dest, char *src, size_t *size);
138 
139 LIBICAL_ICAL_EXPORT int sspm_write_mime(struct sspm_part *parts, size_t num_parts,
140  char **output_string, const char *header);
141 
142 #endif /* ICAL_SSPM_H */
Definition: sspm.h:87
Definition: sspm.h:111
Definition: sspm.h:103