* mailbox2/header.c: Put the stubs.
* mailbox2/include/mailutils/header.h: Prototypes. * mailbox2/include/mailutils/sys/header.h: Prototype
Showing
5 changed files
with
403 additions
and
0 deletions
mailbox2/header.c
0 → 100644
1 | /* GNU mailutils - a suite of utilities for electronic mail | ||
2 | Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. | ||
3 | |||
4 | This program is free software; you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Library Public License as published by | ||
6 | the Free Software Foundation; either version 2, or (at your option) | ||
7 | any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU Library General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this program; if not, write to the Free Software | ||
16 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | ||
17 | |||
18 | |||
19 | #ifdef HAVE_CONFIG_H | ||
20 | # include <config.h> | ||
21 | #endif | ||
22 | |||
23 | #include <stdlib.h> | ||
24 | #include <string.h> | ||
25 | #include <mailutils/error.h> | ||
26 | #include <mailutils/sys/header.h> | ||
27 | |||
28 | int | ||
29 | (header_add_ref) (header_t header) | ||
30 | { | ||
31 | if (header == NULL || header->vtable == NULL | ||
32 | || header->vtable->add_ref == NULL) | ||
33 | return MU_ERROR_NOT_SUPPORTED; | ||
34 | return header->vtable->add_ref (header); | ||
35 | } | ||
36 | |||
37 | int | ||
38 | (header_release) (header_t header) | ||
39 | { | ||
40 | if (header == NULL || header->vtable == NULL | ||
41 | || header->vtable->release == NULL) | ||
42 | return MU_ERROR_NOT_SUPPORTED; | ||
43 | return header->vtable->release (header); | ||
44 | } | ||
45 | |||
46 | int | ||
47 | (header_destroy) (header_t header) | ||
48 | { | ||
49 | if (header == NULL || header->vtable == NULL | ||
50 | || header->vtable->destroy == NULL) | ||
51 | return MU_ERROR_NOT_SUPPORTED; | ||
52 | return header->vtable->destroy (header); | ||
53 | } | ||
54 | |||
55 | int | ||
56 | (header_is_modified) (header_t header) | ||
57 | { | ||
58 | if (header == NULL || header->vtable == NULL | ||
59 | || header->vtable->is_modified == NULL) | ||
60 | return MU_ERROR_NOT_SUPPORTED; | ||
61 | return header->vtable->is_modified (header); | ||
62 | } | ||
63 | |||
64 | int | ||
65 | (header_clear_modified) (header_t header) | ||
66 | { | ||
67 | if (header == NULL || header->vtable == NULL | ||
68 | || header->vtable->clear_modified == NULL) | ||
69 | return MU_ERROR_NOT_SUPPORTED; | ||
70 | return header->vtable->clear_modified (header); | ||
71 | } | ||
72 | |||
73 | int | ||
74 | (header_set_value) (header_t header, const char *fn, const char *fv, | ||
75 | int replace) | ||
76 | { | ||
77 | if (header == NULL || header->vtable == NULL | ||
78 | || header->vtable->set_value == NULL) | ||
79 | return MU_ERROR_NOT_SUPPORTED; | ||
80 | return header->vtable->set_value (header, fn, fv, replace); | ||
81 | } | ||
82 | |||
83 | int | ||
84 | (header_get_value) (header_t header, const char *name, char *buffer, | ||
85 | size_t buflen, size_t *pn) | ||
86 | { | ||
87 | if (header == NULL || header->vtable == NULL | ||
88 | || header->vtable->get_value == NULL) | ||
89 | return MU_ERROR_NOT_SUPPORTED; | ||
90 | return header->vtable->get_value (header, name, buffer, buflen, pn); | ||
91 | } | ||
92 | |||
93 | int | ||
94 | header_aget_value (header_t header, const char *name, char **pvalue) | ||
95 | { | ||
96 | char *value; | ||
97 | size_t n = 0; | ||
98 | int status = header_get_value (header, name, NULL, 0, &n); | ||
99 | if (status == 0) | ||
100 | { | ||
101 | value = calloc (n + 1, 1); | ||
102 | if (value == NULL) | ||
103 | return MU_ERROR_NO_MEMORY; | ||
104 | header_get_value (header, name, value, n + 1, NULL); | ||
105 | } | ||
106 | else | ||
107 | { | ||
108 | value = malloc (1); | ||
109 | if (value == NULL) | ||
110 | return MU_ERROR_NO_MEMORY; | ||
111 | *value = '\0'; | ||
112 | } | ||
113 | *pvalue = value; | ||
114 | return 0; | ||
115 | } | ||
116 | |||
117 | int | ||
118 | (header_get_field_count) (header_t header, size_t *pcount) | ||
119 | { | ||
120 | if (header == NULL || header->vtable == NULL | ||
121 | || header->vtable->get_field_count == NULL) | ||
122 | return MU_ERROR_NOT_SUPPORTED; | ||
123 | return header->vtable->get_field_count (header, pcount); | ||
124 | } | ||
125 | |||
126 | int | ||
127 | (header_get_field_name) (header_t header, size_t num, char *buf, | ||
128 | size_t buflen, size_t *pn) | ||
129 | { | ||
130 | if (header == NULL || header->vtable == NULL | ||
131 | || header->vtable->get_field_name == NULL) | ||
132 | return MU_ERROR_NOT_SUPPORTED; | ||
133 | return header->vtable->get_field_name (header, num, buf, buflen, pn); | ||
134 | } | ||
135 | |||
136 | int | ||
137 | header_aget_field_name (header_t header, size_t num, char **pvalue) | ||
138 | { | ||
139 | char *value; | ||
140 | size_t n = 0; | ||
141 | int status = header_get_field_name (header, num, NULL, 0, &n); | ||
142 | if (status == 0) | ||
143 | { | ||
144 | value = calloc (n + 1, 1); | ||
145 | if (value == NULL) | ||
146 | return MU_ERROR_NO_MEMORY; | ||
147 | header_get_field_name (header, num, value, n + 1, NULL); | ||
148 | } | ||
149 | else | ||
150 | { | ||
151 | value = malloc (1); | ||
152 | if (value == NULL) | ||
153 | return MU_ERROR_NO_MEMORY; | ||
154 | *value = '\0'; | ||
155 | } | ||
156 | *pvalue = value; | ||
157 | return 0; | ||
158 | } | ||
159 | |||
160 | int | ||
161 | (header_get_field_value) (header_t header, size_t num, char *buf, | ||
162 | size_t buflen, size_t *pn) | ||
163 | { | ||
164 | if (header == NULL || header->vtable == NULL | ||
165 | || header->vtable->get_field_value == NULL) | ||
166 | return MU_ERROR_NOT_SUPPORTED; | ||
167 | return header->vtable->get_field_value (header, num, buf, buflen, pn); | ||
168 | } | ||
169 | |||
170 | int | ||
171 | header_aget_field_value (header_t header, size_t num, char **pvalue) | ||
172 | { | ||
173 | char *value; | ||
174 | size_t n = 0; | ||
175 | int status = header_get_field_value (header, num, NULL, 0, &n); | ||
176 | if (status == 0) | ||
177 | { | ||
178 | value = calloc (n + 1, 1); | ||
179 | if (value == NULL) | ||
180 | return MU_ERROR_NO_MEMORY; | ||
181 | header_get_field_value (header, num, value, n + 1, NULL); | ||
182 | } | ||
183 | else | ||
184 | { | ||
185 | value = malloc (1); | ||
186 | if (value == NULL) | ||
187 | return MU_ERROR_NO_MEMORY; | ||
188 | *value = '\0'; | ||
189 | } | ||
190 | *pvalue = value; | ||
191 | return status; | ||
192 | } | ||
193 | |||
194 | int | ||
195 | (header_get_lines) (header_t header, size_t *plines) | ||
196 | { | ||
197 | if (header == NULL || header->vtable == NULL | ||
198 | || header->vtable->get_lines == NULL) | ||
199 | return MU_ERROR_NOT_SUPPORTED; | ||
200 | return header->vtable->get_lines (header, plines); | ||
201 | } | ||
202 | |||
203 | int | ||
204 | (header_get_size) (header_t header, size_t *psize) | ||
205 | { | ||
206 | if (header == NULL || header->vtable == NULL | ||
207 | || header->vtable->get_size == NULL) | ||
208 | return MU_ERROR_NOT_SUPPORTED; | ||
209 | return header->vtable->get_size (header, psize); | ||
210 | } | ||
211 | |||
212 | int | ||
213 | (header_get_stream) (header_t header, stream_t *pstream) | ||
214 | { | ||
215 | if (header == NULL || header->vtable == NULL | ||
216 | || header->vtable->get_stream == NULL) | ||
217 | return MU_ERROR_NOT_SUPPORTED; | ||
218 | return header->vtable->get_stream (header, pstream); | ||
219 | } |
mailbox2/include/mailutils/header.h
0 → 100644
1 | /* GNU mailutils - a suite of utilities for electronic mail | ||
2 | Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. | ||
3 | |||
4 | This program is free software; you can redistribute it and/or modify | ||
5 | it under the terms of the GNU Library General Public License as published by | ||
6 | the Free Software Foundation; either version 2, or (at your option) | ||
7 | any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this program; if not, write to the Free Software | ||
16 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | ||
17 | |||
18 | #ifndef _MAILUTILS_HEADER_H | ||
19 | #define _MAILUTILS_HEADER_H | ||
20 | |||
21 | #include <sys/types.h> | ||
22 | #include <mailutils/stream.h> | ||
23 | |||
24 | #ifndef __P | ||
25 | #ifdef __STDC__ | ||
26 | #define __P(args) args | ||
27 | #else | ||
28 | #define __P(args) () | ||
29 | #endif | ||
30 | #endif /*__P */ | ||
31 | |||
32 | #ifdef __cplusplus | ||
33 | extern "C" { | ||
34 | #endif | ||
35 | |||
36 | #define MU_HEADER_UNIX_FROM "From " | ||
37 | #define MU_HEADER_RETURN_PATH "Return-Path" | ||
38 | #define MU_HEADER_RECEIVED "Received" | ||
39 | #define MU_HEADER_DATE "Date" | ||
40 | #define MU_HEADER_FROM "From" | ||
41 | #define MU_HEADER_SENDER "Sender" | ||
42 | #define MU_HEADER_RESENT_FROM "Resent-From" | ||
43 | #define MU_HEADER_SUBJECT "Subject" | ||
44 | #define MU_HEADER_SENDER "Sender" | ||
45 | #define MU_HEADER_RESENT_SENDER "Resent-SENDER" | ||
46 | #define MU_HEADER_TO "To" | ||
47 | #define MU_HEADER_RESENT_TO "Resent-To" | ||
48 | #define MU_HEADER_CC "Cc" | ||
49 | #define MU_HEADER_RESENT_CC "Resent-Cc" | ||
50 | #define MU_HEADER_BCC "Bcc" | ||
51 | #define MU_HEADER_RESENT_BCC "Resent-Bcc" | ||
52 | #define MU_HEADER_REPLY_TO "Reply-To" | ||
53 | #define MU_HEADER_RESENT_REPLY_TO "Resent-Reply-To" | ||
54 | #define MU_HEADER_MESSAGE_ID "Message-ID" | ||
55 | #define MU_HEADER_RESENT_MESSAGE_ID "Resent-Message-ID" | ||
56 | #define MU_HEADER_IN_REPLY_TO "In-Reply-To" | ||
57 | #define MU_HEADER_REFERENCE "Reference" | ||
58 | #define MU_HEADER_ENCRYPTED "Encrypted" | ||
59 | #define MU_HEADER_PRECEDENCE "Precedence" | ||
60 | #define MU_HEADER_STATUS "Status" | ||
61 | #define MU_HEADER_CONTENT_LENGTH "Content-Length" | ||
62 | #define MU_HEADER_CONTENT_LANGUAGE "Content-Language" | ||
63 | #define MU_HEADER_CONTENT_TRANSFER_ENCODING "Content-transfer-encoding" | ||
64 | #define MU_HEADER_CONTENT_ID "Content-ID" | ||
65 | #define MU_HEADER_CONTENT_TYPE "Content-Type" | ||
66 | #define MU_HEADER_CONTENT_DESCRIPTION "Content-Description" | ||
67 | #define MU_HEADER_CONTENT_DISPOSITION "Content-Disposition" | ||
68 | #define MU_HEADER_CONTENT_MD5 "Content-MD5" | ||
69 | #define MU_HEADER_MIME_VERSION "MIME-Version" | ||
70 | #define MU_HEADER_X_UIDL "X-UIDL" | ||
71 | #define MU_HEADER_X_UID "X-UID" | ||
72 | #define MU_HEADER_X_IMAPBASE "X-IMAPbase" | ||
73 | |||
74 | /* Mime support header attribute */ | ||
75 | |||
76 | /* forward declaration */ | ||
77 | struct _header; | ||
78 | typedef struct _header * header_t; | ||
79 | |||
80 | extern int header_add_ref __P ((header_t)); | ||
81 | extern int header_release __P ((header_t)); | ||
82 | extern int header_destroy __P ((header_t)); | ||
83 | |||
84 | extern int header_is_modified __P ((header_t)); | ||
85 | extern int header_clear_modified __P ((header_t)); | ||
86 | |||
87 | extern int header_set_value __P ((header_t, const char *, | ||
88 | const char *, int)); | ||
89 | extern int header_get_value __P ((header_t, const char *, char *, | ||
90 | size_t, size_t *)); | ||
91 | extern int header_aget_value __P ((header_t, const char *, char **)); | ||
92 | |||
93 | extern int header_get_field_count __P ((header_t, size_t *)); | ||
94 | extern int header_get_field_value __P ((header_t, size_t, char *, | ||
95 | size_t, size_t *)); | ||
96 | extern int header_aget_field_value __P ((header_t, size_t, char **)); | ||
97 | extern int header_get_field_name __P ((header_t, size_t, char *, | ||
98 | size_t, size_t *)); | ||
99 | extern int header_aget_field_name __P ((header_t, size_t, char **)); | ||
100 | |||
101 | extern int header_get_stream __P ((header_t, stream_t *)); | ||
102 | extern int header_set_stream __P ((header_t, stream_t, void *)); | ||
103 | |||
104 | extern int header_get_size __P ((header_t, size_t *)); | ||
105 | |||
106 | extern int header_get_lines __P ((header_t, size_t *)); | ||
107 | |||
108 | |||
109 | extern int header_create __P ((header_t *, const char *, size_t)); | ||
110 | |||
111 | |||
112 | #ifdef __cplusplus | ||
113 | } | ||
114 | #endif | ||
115 | |||
116 | #endif /* _MAILUTILS_HEADER_H */ |
mailbox2/include/mailutils/sys/header.h
0 → 100644
1 | /* GNU mailutils - a suite of utilities for electronic mail | ||
2 | Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. | ||
3 | |||
4 | This program is free software; you can redistribute it and/or modify | ||
5 | it under the terms of the GNU Library General Public License as published by | ||
6 | the Free Software Foundation; either version 2, or (at your option) | ||
7 | any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this program; if not, write to the Free Software | ||
16 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | ||
17 | |||
18 | #ifndef _MAILUTILS_SYS_HEADER_H | ||
19 | #define _MAILUTILS_SYS_HEADER_H | ||
20 | |||
21 | #include <mailutils/header.h> | ||
22 | |||
23 | #ifndef __P | ||
24 | #ifdef __STDC__ | ||
25 | #define __P(args) args | ||
26 | #else | ||
27 | #define __P(args) () | ||
28 | #endif | ||
29 | #endif /*__P */ | ||
30 | |||
31 | #ifdef __cplusplus | ||
32 | extern "C" { | ||
33 | #endif | ||
34 | |||
35 | struct _header_vtable | ||
36 | { | ||
37 | int (*add_ref) __P ((header_t)); | ||
38 | int (*release) __P ((header_t)); | ||
39 | int (*destroy) __P ((header_t)); | ||
40 | |||
41 | int (*is_modified) __P ((header_t)); | ||
42 | int (*clear_modified) __P ((header_t)); | ||
43 | |||
44 | int (*set_value) __P ((header_t, const char *, const char *, int)); | ||
45 | int (*get_value) __P ((header_t, const char *, char *, size_t, size_t *)); | ||
46 | |||
47 | int (*get_field_count) __P ((header_t, size_t *)); | ||
48 | int (*get_field_value) __P ((header_t, size_t, char *, size_t, size_t *)); | ||
49 | int (*get_field_name) __P ((header_t, size_t, char *, size_t, size_t *)); | ||
50 | |||
51 | int (*get_stream) __P ((header_t, stream_t *)); | ||
52 | |||
53 | int (*get_size) __P ((header_t, size_t *)); | ||
54 | int (*get_lines) __P ((header_t, size_t *)); | ||
55 | }; | ||
56 | |||
57 | struct _header | ||
58 | { | ||
59 | struct _header_vtable *vtable; | ||
60 | }; | ||
61 | |||
62 | #ifdef __cplusplus | ||
63 | } | ||
64 | #endif | ||
65 | |||
66 | #endif /* _MAILUTILS_SYS_HEADER_H */ |
-
Please register or sign in to post a comment