To much to add log entries.
Showing
46 changed files
with
3537 additions
and
171 deletions
... | @@ -13,15 +13,26 @@ lib_LTLIBRARIES = libmailbox.la | ... | @@ -13,15 +13,26 @@ lib_LTLIBRARIES = libmailbox.la |
13 | libmailbox_la_SOURCES = \ | 13 | libmailbox_la_SOURCES = \ |
14 | address.c \ | 14 | address.c \ |
15 | attribute.c \ | 15 | attribute.c \ |
16 | authority.c \ | ||
16 | bstream.c \ | 17 | bstream.c \ |
18 | dotlock.c \ | ||
17 | envelope.c \ | 19 | envelope.c \ |
20 | folder.c \ | ||
18 | fstream.c \ | 21 | fstream.c \ |
22 | header.c \ | ||
19 | iterator.c \ | 23 | iterator.c \ |
20 | list.c \ | 24 | list.c \ |
25 | locker.c \ | ||
26 | mailbox.c \ | ||
21 | md5-rsa.c \ | 27 | md5-rsa.c \ |
28 | memstream.c \ | ||
29 | message.c \ | ||
22 | mstream.c \ | 30 | mstream.c \ |
31 | mutil.c \ | ||
23 | observable.c \ | 32 | observable.c \ |
24 | observer.c \ | 33 | observer.c \ |
25 | parse822.c \ | 34 | parse822.c \ |
35 | pticket.c \ | ||
26 | stream.c \ | 36 | stream.c \ |
27 | tcpstream.c | 37 | tcpstream.c \ |
38 | ticket.c | ... | ... |
mailbox2/authority.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 | #ifdef HAVE_CONFIG_H | ||
18 | # include <config.h> | ||
19 | #endif | ||
20 | |||
21 | #include <stdlib.h> | ||
22 | #include <mailutils/error.h> | ||
23 | #include <mailutils/sys/authority.h> | ||
24 | |||
25 | int | ||
26 | authority_add_ref (authority_t authority) | ||
27 | { | ||
28 | if (authority == NULL || authority->vtable == NULL | ||
29 | || authority->vtable->add_ref == NULL) | ||
30 | return MU_ERROR_NOT_SUPPORTED; | ||
31 | return authority->vtable->add_ref (authority); | ||
32 | } | ||
33 | |||
34 | int | ||
35 | authority_release (authority_t authority) | ||
36 | { | ||
37 | if (authority == NULL || authority->vtable == NULL | ||
38 | || authority->vtable->release == NULL) | ||
39 | return MU_ERROR_NOT_SUPPORTED; | ||
40 | return authority->vtable->release (authority); | ||
41 | } | ||
42 | |||
43 | int | ||
44 | authority_destroy (authority_t authority) | ||
45 | { | ||
46 | if (authority == NULL || authority->vtable == NULL | ||
47 | || authority->vtable->destroy == NULL) | ||
48 | return MU_ERROR_NOT_SUPPORTED; | ||
49 | return authority->vtable->destroy (authority); | ||
50 | } | ||
51 | |||
52 | int | ||
53 | authority_set_ticket (authority_t authority, ticket_t ticket) | ||
54 | { | ||
55 | if (authority == NULL || authority->vtable == NULL | ||
56 | || authority->vtable->set_ticket == NULL) | ||
57 | return MU_ERROR_NOT_SUPPORTED; | ||
58 | return authority->vtable->set_ticket (authority, ticket); | ||
59 | } | ||
60 | |||
61 | int | ||
62 | authority_get_ticket (authority_t authority, ticket_t *pticket) | ||
63 | { | ||
64 | if (authority == NULL || authority->vtable == NULL | ||
65 | || authority->vtable->get_ticket == NULL) | ||
66 | return MU_ERROR_NOT_SUPPORTED; | ||
67 | return authority->vtable->get_ticket (authority, pticket); | ||
68 | } | ||
69 | |||
70 | int | ||
71 | authority_authenticate (authority_t authority) | ||
72 | { | ||
73 | if (authority == NULL || authority->vtable == NULL | ||
74 | || authority->vtable->authenticate == NULL) | ||
75 | return MU_ERROR_NOT_SUPPORTED; | ||
76 | return authority->vtable->authenticate (authority); | ||
77 | } |
mailbox2/dotlock.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 | #ifdef HAVE_CONFIG_H | ||
19 | # include <config.h> | ||
20 | #endif | ||
21 | |||
22 | #include <errno.h> | ||
23 | #include <sys/types.h> | ||
24 | #include <stdlib.h> | ||
25 | #include <string.h> | ||
26 | #include <stdio.h> | ||
27 | #include <fcntl.h> | ||
28 | #include <limits.h> | ||
29 | #include <sys/stat.h> | ||
30 | #include <unistd.h> | ||
31 | #include <time.h> | ||
32 | #include <utime.h> | ||
33 | #include <signal.h> | ||
34 | |||
35 | #include <mailutils/error.h> | ||
36 | #include <mailutils/sys/locker.h> | ||
37 | #include <mailutils/monitor.h> | ||
38 | |||
39 | /* locking flags */ | ||
40 | #define MU_DOTLOCK_PID 1 | ||
41 | #define MU_DOTLOCK_FCNTL 2 | ||
42 | #define MU_DOTLOCK_TIME 4 | ||
43 | |||
44 | #define MU_DOTLOCK_EXPIRE_TIME (5 * 60) | ||
45 | |||
46 | #define LOCKFILE_ATTR 0444 | ||
47 | |||
48 | /* First draft by Brian Edmond. */ | ||
49 | |||
50 | struct _dotlock | ||
51 | { | ||
52 | struct _locker base; | ||
53 | monitor_t lock; | ||
54 | int fd; | ||
55 | int ref; | ||
56 | int refcnt; | ||
57 | char *fname; | ||
58 | int flags; | ||
59 | }; | ||
60 | |||
61 | static int | ||
62 | _dotlock_add_ref (locker_t locker) | ||
63 | { | ||
64 | int status; | ||
65 | struct _dotlock *dotlock = (struct _dotlock *)locker; | ||
66 | monitor_lock (dotlock->lock); | ||
67 | status = ++dotlock->ref; | ||
68 | monitor_unlock (dotlock->lock); | ||
69 | return status; | ||
70 | } | ||
71 | |||
72 | static int | ||
73 | _dotlock_destroy (locker_t locker) | ||
74 | { | ||
75 | struct _dotlock *dotlock = (struct _dotlock *)locker; | ||
76 | free (dotlock->fname); | ||
77 | monitor_destroy (dotlock->lock); | ||
78 | free (dotlock); | ||
79 | return 0; | ||
80 | } | ||
81 | |||
82 | static int | ||
83 | _dotlock_release (locker_t locker) | ||
84 | { | ||
85 | int status; | ||
86 | struct _dotlock *dotlock = (struct _dotlock *)locker; | ||
87 | monitor_lock (dotlock->lock); | ||
88 | status = --dotlock->ref; | ||
89 | if (status <= 0) | ||
90 | { | ||
91 | monitor_unlock (dotlock->lock); | ||
92 | _dotlock_destroy (locker); | ||
93 | return 0; | ||
94 | } | ||
95 | monitor_unlock (dotlock->lock); | ||
96 | return status; | ||
97 | } | ||
98 | |||
99 | static int | ||
100 | _dotlock_lock (locker_t locker) | ||
101 | { | ||
102 | struct _dotlock *dotlock = (struct _dotlock *)locker; | ||
103 | int fd = -1; | ||
104 | char buf[16]; | ||
105 | pid_t pid; | ||
106 | int removed = 0; | ||
107 | |||
108 | if (dotlock == NULL) | ||
109 | return MU_ERROR_INVALID_PARAMETER; | ||
110 | |||
111 | /* Is the lock already applied? | ||
112 | FIXME: should we check flags != lock->flags ?? */ | ||
113 | if (dotlock->fd != -1) | ||
114 | { | ||
115 | dotlock->refcnt++; | ||
116 | return 0; | ||
117 | } | ||
118 | |||
119 | /* | ||
120 | Check for lock existance: | ||
121 | if it exists but the process is gone the lock can be removed, | ||
122 | if the lock is expired, remove it. */ | ||
123 | fd = open (dotlock->fname, O_RDONLY); | ||
124 | if (fd != -1) | ||
125 | { | ||
126 | /* Check to see if this process is still running. */ | ||
127 | if (dotlock->flags & MU_DOTLOCK_PID) | ||
128 | { | ||
129 | int nread = read (fd, buf, sizeof (buf) - 1); | ||
130 | if (nread > 0) | ||
131 | { | ||
132 | buf[nread] = '\0'; | ||
133 | pid = strtol (buf, NULL, 10); | ||
134 | if (pid > 0) | ||
135 | { | ||
136 | /* Process is gone so we try to remove the lock. */ | ||
137 | if (kill (pid, 0) == -1) | ||
138 | removed = 1; | ||
139 | } | ||
140 | else | ||
141 | removed = 1; /* Corrupted file, remove the lock. */ | ||
142 | } | ||
143 | } | ||
144 | /* Check to see if the lock expired. */ | ||
145 | if (dotlock->flags & MU_DOTLOCK_TIME) | ||
146 | { | ||
147 | struct stat stbuf; | ||
148 | |||
149 | fstat (fd, &stbuf); | ||
150 | /* The lock has expired. */ | ||
151 | if ((time (NULL) - stbuf.st_mtime) > MU_DOTLOCK_EXPIRE_TIME) | ||
152 | removed = 1; | ||
153 | } | ||
154 | |||
155 | close (fd); | ||
156 | if (removed) | ||
157 | unlink (dotlock->fname); | ||
158 | } | ||
159 | |||
160 | /* Try to create the lockfile. */ | ||
161 | fd = open (dotlock->fname, O_WRONLY | O_CREAT | O_EXCL, LOCKFILE_ATTR); | ||
162 | if (fd == -1) | ||
163 | return errno; | ||
164 | else | ||
165 | { | ||
166 | struct stat fn_stat; | ||
167 | struct stat fd_stat; | ||
168 | |||
169 | if (lstat (dotlock->fname, &fn_stat) | ||
170 | || fstat(fd, &fd_stat) | ||
171 | || fn_stat.st_nlink != 1 | ||
172 | || fn_stat.st_dev != fd_stat.st_dev | ||
173 | || fn_stat.st_ino != fd_stat.st_ino | ||
174 | || fn_stat.st_uid != fd_stat.st_uid | ||
175 | || fn_stat.st_gid != fd_stat.st_gid) | ||
176 | { | ||
177 | close (fd); | ||
178 | unlink (dotlock->fname); | ||
179 | return EPERM; | ||
180 | } | ||
181 | } | ||
182 | |||
183 | /* Success. */ | ||
184 | sprintf (buf, "%ld", (long)getpid ()); | ||
185 | write (fd, buf, strlen (buf)); | ||
186 | |||
187 | /* Try to get a file lock. */ | ||
188 | if (dotlock->flags & MU_DOTLOCK_FCNTL) | ||
189 | { | ||
190 | struct flock fl; | ||
191 | |||
192 | memset (&fl, 0, sizeof (struct flock)); | ||
193 | fl.l_type = F_WRLCK; | ||
194 | if (fcntl (fd, F_SETLK, &fl) == -1) | ||
195 | { | ||
196 | int err = errno; | ||
197 | /* Could not get the file lock. */ | ||
198 | close (fd); | ||
199 | unlink (dotlock->fname); /* Remove the file I created. */ | ||
200 | return err; | ||
201 | } | ||
202 | } | ||
203 | |||
204 | dotlock->fd = fd; | ||
205 | dotlock->refcnt++; | ||
206 | return 0; | ||
207 | } | ||
208 | |||
209 | static int | ||
210 | _dotlock_touchlock (locker_t locker) | ||
211 | { | ||
212 | struct _dotlock *dotlock = (struct _dotlock *)locker; | ||
213 | if (!dotlock || !dotlock->fname || dotlock->fd == -1) | ||
214 | return MU_ERROR_INVALID_PARAMETER; | ||
215 | return utime (dotlock->fname, NULL); | ||
216 | } | ||
217 | |||
218 | static int | ||
219 | _dotlock_unlock (locker_t locker) | ||
220 | { | ||
221 | struct _dotlock *dotlock = (struct _dotlock *)locker; | ||
222 | if (!dotlock || !dotlock->fname || dotlock->fd == -1 || dotlock->refcnt <= 0) | ||
223 | return EINVAL; | ||
224 | |||
225 | if (--dotlock->refcnt > 0) | ||
226 | return 0; | ||
227 | |||
228 | if (dotlock->flags & MU_DOTLOCK_FCNTL) | ||
229 | { | ||
230 | struct flock fl; | ||
231 | |||
232 | memset (&fl, 0, sizeof (struct flock)); | ||
233 | fl.l_type = F_UNLCK; | ||
234 | /* Unlock failed? */ | ||
235 | if (fcntl (dotlock->fd, F_SETLK, &fl) == -1) | ||
236 | return errno; | ||
237 | } | ||
238 | close (dotlock->fd); | ||
239 | dotlock->fd = -1; | ||
240 | unlink (dotlock->fname); | ||
241 | return 0; | ||
242 | } | ||
243 | |||
244 | static struct _locker_vtable _dotlock_vtable = | ||
245 | { | ||
246 | _dotlock_add_ref, | ||
247 | _dotlock_release, | ||
248 | _dotlock_destroy, | ||
249 | |||
250 | _dotlock_lock, | ||
251 | _dotlock_touchlock, | ||
252 | _dotlock_unlock, | ||
253 | }; | ||
254 | |||
255 | int | ||
256 | locker_dotlock_create (locker_t *plocker, const char *filename) | ||
257 | { | ||
258 | struct _dotlock *dotlock; | ||
259 | |||
260 | if (plocker == NULL || filename == NULL) | ||
261 | return MU_ERROR_INVALID_PARAMETER; | ||
262 | |||
263 | dotlock = calloc (1, sizeof *dotlock); | ||
264 | if (dotlock == NULL) | ||
265 | return MU_ERROR_NO_MEMORY; | ||
266 | |||
267 | dotlock->fname = calloc (strlen (filename) + 5 /*strlen(".lock")*/ + 1, 1); | ||
268 | if (dotlock->fname == NULL) | ||
269 | { | ||
270 | free (dotlock); | ||
271 | return MU_ERROR_NO_MEMORY; | ||
272 | } | ||
273 | strcpy (dotlock->fname, filename); | ||
274 | strcat (dotlock->fname, ".lock"); | ||
275 | |||
276 | dotlock->base.vtable = &_dotlock_vtable; | ||
277 | dotlock->flags = MU_DOTLOCK_PID | MU_DOTLOCK_TIME | MU_DOTLOCK_FCNTL; | ||
278 | dotlock->fd = -1; | ||
279 | dotlock->ref = 1; | ||
280 | dotlock->refcnt = 0; | ||
281 | *plocker = &dotlock->base; | ||
282 | return 0; | ||
283 | } |
mailbox2/folder.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 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 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 | #include <stdlib.h> | ||
19 | #include <mailutils/error.h> | ||
20 | #include <mailutils/sys/folder.h> | ||
21 | |||
22 | int | ||
23 | folder_add_ref (folder_t folder) | ||
24 | { | ||
25 | if (folder == NULL || folder->vtable == NULL | ||
26 | || folder->vtable->add_ref == NULL) | ||
27 | return MU_ERROR_NOT_SUPPORTED; | ||
28 | return folder->vtable->add_ref (folder); | ||
29 | } | ||
30 | |||
31 | int | ||
32 | folder_release (folder_t folder) | ||
33 | { | ||
34 | if (folder == NULL || folder->vtable == NULL | ||
35 | || folder->vtable->release == NULL) | ||
36 | return MU_ERROR_NOT_SUPPORTED; | ||
37 | return folder->vtable->release (folder); | ||
38 | } | ||
39 | |||
40 | int | ||
41 | folder_destroy (folder_t folder) | ||
42 | { | ||
43 | if (folder == NULL || folder->vtable == NULL | ||
44 | || folder->vtable->destroy == NULL) | ||
45 | return MU_ERROR_NOT_SUPPORTED; | ||
46 | return folder->vtable->destroy (folder); | ||
47 | } | ||
48 | |||
49 | int | ||
50 | folder_open (folder_t folder, int flag) | ||
51 | { | ||
52 | if (folder == NULL || folder->vtable == NULL | ||
53 | || folder->vtable->open == NULL) | ||
54 | return MU_ERROR_NOT_SUPPORTED; | ||
55 | return folder->vtable->open (folder, flag); | ||
56 | } | ||
57 | |||
58 | int | ||
59 | folder_close (folder_t folder) | ||
60 | { | ||
61 | if (folder == NULL || folder->vtable == NULL | ||
62 | || folder->vtable->close == NULL) | ||
63 | return MU_ERROR_NOT_SUPPORTED; | ||
64 | return folder->vtable->close (folder); | ||
65 | } | ||
66 | |||
67 | int | ||
68 | folder_delete (folder_t folder, const char *name) | ||
69 | { | ||
70 | if (folder == NULL || folder->vtable == NULL | ||
71 | || folder->vtable->delete == NULL) | ||
72 | return MU_ERROR_NOT_SUPPORTED; | ||
73 | return folder->vtable->delete (folder, name); | ||
74 | } | ||
75 | |||
76 | int | ||
77 | folder_rename (folder_t folder, const char *oldname, const char *newname) | ||
78 | { | ||
79 | if (folder == NULL || folder->vtable == NULL | ||
80 | || folder->vtable->rename == NULL) | ||
81 | return MU_ERROR_NOT_SUPPORTED; | ||
82 | return folder->vtable->rename (folder, oldname, newname); | ||
83 | } | ||
84 | |||
85 | int | ||
86 | folder_subscribe (folder_t folder, const char *name) | ||
87 | { | ||
88 | if (folder == NULL || folder->vtable == NULL | ||
89 | || folder->vtable->subscribe == NULL) | ||
90 | return MU_ERROR_NOT_SUPPORTED; | ||
91 | return folder->vtable->subscribe (folder, name); | ||
92 | } | ||
93 | |||
94 | int | ||
95 | folder_unsubscribe (folder_t folder, const char *name) | ||
96 | { | ||
97 | if (folder == NULL || folder->vtable == NULL | ||
98 | || folder->vtable->unsubscribe == NULL) | ||
99 | return MU_ERROR_NOT_SUPPORTED; | ||
100 | return folder->vtable->unsubscribe (folder, name); | ||
101 | } | ||
102 | |||
103 | int | ||
104 | folder_list (folder_t folder, const char *dir, const char *name, | ||
105 | iterator_t *iterator) | ||
106 | { | ||
107 | if (folder == NULL || folder->vtable == NULL | ||
108 | || folder->vtable->list == NULL) | ||
109 | return MU_ERROR_NOT_SUPPORTED; | ||
110 | return folder->vtable->list (folder, dir, name, iterator); | ||
111 | } | ||
112 | |||
113 | int | ||
114 | folder_lsub (folder_t folder, const char *dir, const char *name, | ||
115 | iterator_t *iterator) | ||
116 | { | ||
117 | if (folder == NULL || folder->vtable == NULL | ||
118 | || folder->vtable->lsub == NULL) | ||
119 | return MU_ERROR_NOT_SUPPORTED; | ||
120 | return folder->vtable->lsub (folder, dir, name, iterator); | ||
121 | } | ||
122 | |||
123 | /* Stream settings. */ | ||
124 | int | ||
125 | folder_get_stream (folder_t folder, stream_t *stream) | ||
126 | { | ||
127 | if (folder == NULL || folder->vtable == NULL | ||
128 | || folder->vtable->get_stream == NULL) | ||
129 | return MU_ERROR_NOT_SUPPORTED; | ||
130 | return folder->vtable->get_stream (folder, stream); | ||
131 | } | ||
132 | |||
133 | int | ||
134 | folder_set_stream (folder_t folder, stream_t stream) | ||
135 | { | ||
136 | if (folder == NULL || folder->vtable == NULL | ||
137 | || folder->vtable->set_stream == NULL) | ||
138 | return MU_ERROR_NOT_SUPPORTED; | ||
139 | return folder->vtable->set_stream (folder, stream); | ||
140 | } | ||
141 | |||
142 | |||
143 | /* Notifications. */ | ||
144 | int | ||
145 | folder_get_observable (folder_t folder, observable_t *observable) | ||
146 | { | ||
147 | if (folder == NULL || folder->vtable == NULL | ||
148 | || folder->vtable->get_observable == NULL) | ||
149 | return MU_ERROR_NOT_SUPPORTED; | ||
150 | return folder->vtable->get_observable (folder, observable); | ||
151 | } | ||
152 | |||
153 | int | ||
154 | folder_get_debug (folder_t folder, mu_debug_t *debug) | ||
155 | { | ||
156 | if (folder == NULL || folder->vtable == NULL | ||
157 | || folder->vtable->get_debug == NULL) | ||
158 | return MU_ERROR_NOT_SUPPORTED; | ||
159 | return folder->vtable->get_debug (folder, debug); | ||
160 | } | ||
161 | |||
162 | int | ||
163 | folder_set_debug (folder_t folder, mu_debug_t debug) | ||
164 | { | ||
165 | if (folder == NULL || folder->vtable == NULL | ||
166 | || folder->vtable->set_debug == NULL) | ||
167 | return MU_ERROR_NOT_SUPPORTED; | ||
168 | return folder->vtable->set_debug (folder, debug); | ||
169 | } | ||
170 | |||
171 | |||
172 | /* Authentication. */ | ||
173 | int | ||
174 | folder_get_authority (folder_t folder, authority_t *authority) | ||
175 | { | ||
176 | if (folder == NULL || folder->vtable == NULL | ||
177 | || folder->vtable->get_authority == NULL) | ||
178 | return MU_ERROR_NOT_SUPPORTED; | ||
179 | return folder->vtable->get_authority (folder, authority); | ||
180 | } | ||
181 | |||
182 | int | ||
183 | folder_set_authority (folder_t folder, authority_t authority) | ||
184 | { | ||
185 | if (folder == NULL || folder->vtable == NULL | ||
186 | || folder->vtable->set_authority == NULL) | ||
187 | return MU_ERROR_NOT_SUPPORTED; | ||
188 | return folder->vtable->set_authority (folder, authority); | ||
189 | } | ||
190 | |||
191 | |||
192 | /* URL. */ | ||
193 | int | ||
194 | folder_get_url (folder_t folder, url_t *url) | ||
195 | { | ||
196 | if (folder == NULL || folder->vtable == NULL | ||
197 | || folder->vtable->get_url == NULL) | ||
198 | return MU_ERROR_NOT_SUPPORTED; | ||
199 | return folder->vtable->get_url (folder, url); | ||
200 | } |
... | @@ -148,7 +148,7 @@ static int | ... | @@ -148,7 +148,7 @@ static int |
148 | _fs_truncate (stream_t stream, off_t len) | 148 | _fs_truncate (stream_t stream, off_t len) |
149 | { | 149 | { |
150 | struct _fs *fs = (struct _fs *)stream; | 150 | struct _fs *fs = (struct _fs *)stream; |
151 | if (fs->file && ftruncate (fileno(fs->file), len) != 0) | 151 | if (fs->file && ftruncate (fileno (fs->file), len) != 0) |
152 | return MU_ERROR_IO; | 152 | return MU_ERROR_IO; |
153 | return 0; | 153 | return 0; |
154 | } | 154 | } |
... | @@ -162,7 +162,7 @@ _fs_get_size (stream_t stream, off_t *psize) | ... | @@ -162,7 +162,7 @@ _fs_get_size (stream_t stream, off_t *psize) |
162 | if (fs->file) | 162 | if (fs->file) |
163 | { | 163 | { |
164 | fflush (fs->file); | 164 | fflush (fs->file); |
165 | if (fstat(fileno(fs->file), &stbuf) == -1) | 165 | if (fstat (fileno (fs->file), &stbuf) == -1) |
166 | return errno; | 166 | return errno; |
167 | } | 167 | } |
168 | if (psize) | 168 | if (psize) |
... | @@ -404,6 +404,7 @@ stream_file_create (stream_t *pstream) | ... | @@ -404,6 +404,7 @@ stream_file_create (stream_t *pstream) |
404 | fs->ref = 1; | 404 | fs->ref = 1; |
405 | fs->file = NULL; | 405 | fs->file = NULL; |
406 | fs->flags = 0; | 406 | fs->flags = 0; |
407 | monitor_create (&(fs->lock)); | ||
407 | *pstream = &fs->base; | 408 | *pstream = &fs->base; |
408 | return 0; | 409 | return 0; |
409 | } | 410 | } | ... | ... |
... | @@ -6,17 +6,27 @@ SUBDIRS = sys | ... | @@ -6,17 +6,27 @@ SUBDIRS = sys |
6 | pkginclude_HEADERS = \ | 6 | pkginclude_HEADERS = \ |
7 | address.h \ | 7 | address.h \ |
8 | attribute.h \ | 8 | attribute.h \ |
9 | base.h \ | 9 | authority.h \ |
10 | body.h \ | ||
11 | debug.h \ | ||
10 | envelope.h \ | 12 | envelope.h \ |
11 | error.h \ | 13 | error.h \ |
14 | folder.h \ | ||
12 | header.h \ | 15 | header.h \ |
13 | iterator.h \ | 16 | iterator.h \ |
14 | list.h \ | 17 | list.h \ |
18 | locker.h \ | ||
19 | mailbox.h \ | ||
15 | mbox.h \ | 20 | mbox.h \ |
16 | md5-rsa.h \ | 21 | md5-rsa.h \ |
22 | message.h \ | ||
17 | monitor.h \ | 23 | monitor.h \ |
18 | mutil.h \ | 24 | mutil.h \ |
25 | observable.h \ | ||
19 | observer.h \ | 26 | observer.h \ |
20 | parse822.h \ | 27 | parse822.h \ |
21 | pop3.h \ | 28 | pop3.h \ |
22 | stream.h | 29 | property.h \ |
30 | stream.h \ | ||
31 | ticket.h \ | ||
32 | url.h | ... | ... |
mailbox2/include/mailutils/authority.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 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 | #ifndef _MAILUTILS_AUTHORITY_H | ||
19 | #define _MAILUTILS_AUTHORITY_H | ||
20 | |||
21 | #include <sys/types.h> | ||
22 | #include <mailutils/ticket.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 | /* forward declaration */ | ||
37 | struct _authority; | ||
38 | typedef struct _authority *authority_t; | ||
39 | |||
40 | extern int authority_add_ref __P ((authority_t)); | ||
41 | extern int authority_release __P ((authority_t)); | ||
42 | extern int authority_destroy __P ((authority_t)); | ||
43 | extern int authority_set_ticket __P ((authority_t, ticket_t)); | ||
44 | extern int authority_get_ticket __P ((authority_t, ticket_t *)); | ||
45 | extern int authority_authenticate __P ((authority_t)); | ||
46 | |||
47 | extern int authority_userpass_create __P ((authority_t *)); | ||
48 | |||
49 | #ifdef __cplusplus | ||
50 | } | ||
51 | #endif | ||
52 | |||
53 | #endif /* _MAILUTILS_AUTHORITY_H */ |
mailbox2/include/mailutils/base.h
deleted
100644 → 0
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 | #ifndef _MAILUTILS_BASE_H | ||
19 | #define _MAILUTILS_BASE_H | ||
20 | |||
21 | #include <sys/types.h> | ||
22 | |||
23 | #ifdef __cplusplus | ||
24 | # define __MAILUTILS_START_DECLS extern "C" { | ||
25 | # define __MAILUTILS_END_DECLS } | ||
26 | #else | ||
27 | # define __MAILUTILS_BEGIN_DECLS | ||
28 | # define __MAILUTILS_END_DECLS | ||
29 | #endif | ||
30 | |||
31 | #ifndef __P | ||
32 | # ifdef __STDC__ | ||
33 | # define __P(args) args | ||
34 | # else | ||
35 | # define __P(args) () | ||
36 | # endif | ||
37 | #endif /*__P */ | ||
38 | |||
39 | __MAILUTILS_BEGIN_DECLS | ||
40 | |||
41 | /* Forward declarations. */ | ||
42 | struct _url; | ||
43 | typedef struct _url *url_t; | ||
44 | |||
45 | struct _mailer; | ||
46 | typedef struct _mailer *mailer_t; | ||
47 | |||
48 | struct _folder; | ||
49 | typedef struct _folder *folder_t; | ||
50 | |||
51 | struct _mailbox; | ||
52 | typedef struct _mailbox *mailbox_t; | ||
53 | |||
54 | struct _mime; | ||
55 | struct _mime *mime_t; | ||
56 | |||
57 | struct _message; | ||
58 | typedef struct _message *message_t; | ||
59 | |||
60 | struct _header; | ||
61 | typedef struct _header *header_t; | ||
62 | |||
63 | struct _body; | ||
64 | typedef struct _body *body_t; | ||
65 | |||
66 | struct _ticket; | ||
67 | typedef struct _ticket *ticket_t; | ||
68 | |||
69 | struct _authority; | ||
70 | typedef struct _authority *authority_t; | ||
71 | |||
72 | struct _locker; | ||
73 | typedef struct _locker *locker_t; | ||
74 | |||
75 | struct _debug; | ||
76 | typedef struct _debug *mu_debug_t; | ||
77 | |||
78 | struct _filter; | ||
79 | typedef struct _filter *filter_t; | ||
80 | |||
81 | struct _property; | ||
82 | typedef struct _property *property_t; | ||
83 | |||
84 | __MAILUTILS_END_DECLS | ||
85 | |||
86 | #endif /*_MAILUTILS_BASE_H */ |
mailbox2/include/mailutils/body.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 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 | #ifndef _MAILUTILS_BODY_H | ||
19 | #define _MAILUTILS_BODY_H | ||
20 | |||
21 | #include <sys/types.h> | ||
22 | #include <mailutils/property.h> | ||
23 | #include <mailutils/stream.h> | ||
24 | |||
25 | #ifndef __P | ||
26 | # ifdef __STDC__ | ||
27 | # define __P(args) args | ||
28 | # else | ||
29 | # define __P(args) () | ||
30 | # endif | ||
31 | #endif /* __P */ | ||
32 | |||
33 | #ifdef __cplusplus | ||
34 | extern "C" { | ||
35 | #endif | ||
36 | |||
37 | /* forward declaration */ | ||
38 | struct _body; | ||
39 | typedef struct _body *body_t; | ||
40 | |||
41 | extern int body_add_ref __P ((body_t)); | ||
42 | extern int body_release __P ((body_t)); | ||
43 | extern int body_destroy __P ((body_t)); | ||
44 | |||
45 | extern int body_is_modified __P ((body_t)); | ||
46 | extern int body_clear_modified __P ((body_t)); | ||
47 | |||
48 | extern int body_get_stream __P ((body_t, stream_t *)); | ||
49 | |||
50 | extern int body_get_property __P ((body_t, property_t *)); | ||
51 | |||
52 | extern int body_get_size __P ((body_t, size_t*)); | ||
53 | extern int body_get_lines __P ((body_t, size_t *)); | ||
54 | |||
55 | #ifdef __cplusplus | ||
56 | } | ||
57 | #endif | ||
58 | |||
59 | #endif /* _MAILUTILS_BODY_H */ |
mailbox2/include/mailutils/debug.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 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 | #ifndef _MAILUTILS_DEBUG_H | ||
19 | #define _MAILUTILS_DEBUG_H | ||
20 | |||
21 | #include <sys/types.h> | ||
22 | #include <stdarg.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 | struct _debug; | ||
37 | typedef struct _debug* mu_debug_t; | ||
38 | |||
39 | #define MU_DEBUG_TRACE 1 | ||
40 | #define MU_DEBUG_PROT 2 | ||
41 | extern int mu_debug_add_ref __P ((mu_debug_t)); | ||
42 | extern int mu_debug_release __P ((mu_debug_t)); | ||
43 | extern int mu_debug_destroy __P ((mu_debug_t)); | ||
44 | extern int mu_debug_set_level __P ((mu_debug_t, size_t level)); | ||
45 | extern int mu_debug_get_level __P ((mu_debug_t, size_t *plevel)); | ||
46 | extern int mu_debug_print __P ((mu_debug_t debug, size_t level, | ||
47 | const char *format, ...)); | ||
48 | extern int mu_debug_printv __P ((mu_debug_t debug, size_t level, | ||
49 | const char *format, va_list argp)); | ||
50 | extern int mu_debug_stderr_create __P ((mu_debug_t *)); | ||
51 | |||
52 | #ifdef __cplusplus | ||
53 | } | ||
54 | #endif | ||
55 | |||
56 | #endif /* _MAILUTILS_DEBUG_H */ |
mailbox2/include/mailutils/folder.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 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 | #ifndef _MAILUTILS_FOLDER_H | ||
19 | # define _MAILUTILS_FOLDER_H | ||
20 | |||
21 | #include <sys/types.h> | ||
22 | |||
23 | #include <mailutils/url.h> | ||
24 | #include <mailutils/observable.h> | ||
25 | #include <mailutils/debug.h> | ||
26 | #include <mailutils/stream.h> | ||
27 | #include <mailutils/authority.h> | ||
28 | #include <mailutils/stream.h> | ||
29 | #include <mailutils/iterator.h> | ||
30 | |||
31 | |||
32 | #ifdef __cplusplus | ||
33 | extern "C" { | ||
34 | #endif | ||
35 | |||
36 | #ifndef __P | ||
37 | # ifdef __STDC__ | ||
38 | # define __P(args) args | ||
39 | # else | ||
40 | # define __P(args) () | ||
41 | # endif | ||
42 | #endif /*__P */ | ||
43 | |||
44 | /* Forward declaration. */ | ||
45 | struct _folder; | ||
46 | typedef struct _folder *folder_t; | ||
47 | |||
48 | #define MU_FOLDER_ATTRIBUTE_DIRECTORY 0x001 | ||
49 | #define MU_FOLDER_ATTRIBUTE_FILE 0x002 | ||
50 | struct list_response | ||
51 | { | ||
52 | int type; | ||
53 | int separator; | ||
54 | char *name; | ||
55 | }; | ||
56 | |||
57 | extern int folder_create __P ((folder_t *, const char *)); | ||
58 | |||
59 | extern int folder_add_ref __P ((folder_t)); | ||
60 | extern int folder_release __P ((folder_t)); | ||
61 | extern int folder_destroy __P ((folder_t)); | ||
62 | |||
63 | extern int folder_open __P ((folder_t, int flag)); | ||
64 | extern int folder_close __P ((folder_t)); | ||
65 | |||
66 | extern int folder_delete __P ((folder_t, const char *)); | ||
67 | extern int folder_rename __P ((folder_t, const char *, const char *)); | ||
68 | extern int folder_subscribe __P ((folder_t, const char *)); | ||
69 | extern int folder_unsubscribe __P ((folder_t, const char *)); | ||
70 | extern int folder_list __P ((folder_t, const char *, const char *, | ||
71 | iterator_t *)); | ||
72 | extern int folder_lsub __P ((folder_t, const char *, const char *, | ||
73 | iterator_t *)); | ||
74 | |||
75 | /* Stream settings. */ | ||
76 | extern int folder_get_stream __P ((folder_t, stream_t *)); | ||
77 | extern int folder_set_stream __P ((folder_t, stream_t)); | ||
78 | |||
79 | /* Notifications. */ | ||
80 | extern int folder_get_observable __P ((folder_t, observable_t *)); | ||
81 | extern int folder_get_debug __P ((folder_t, mu_debug_t *)); | ||
82 | extern int folder_set_debug __P ((folder_t, mu_debug_t)); | ||
83 | |||
84 | /* Authentication. */ | ||
85 | extern int folder_get_authority __P ((folder_t, authority_t *)); | ||
86 | extern int folder_set_authority __P ((folder_t, authority_t)); | ||
87 | |||
88 | /* URL. */ | ||
89 | extern int folder_get_url __P ((folder_t, url_t *)); | ||
90 | |||
91 | #ifdef __cplusplus | ||
92 | } | ||
93 | #endif | ||
94 | |||
95 | #endif /* _MAILUTILS_FOLDER_H */ |
mailbox2/include/mailutils/locker.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 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 | #ifndef _MAILUTILS_LOCKER_H | ||
19 | #define _MAILUTILS_LOCKER_H | ||
20 | |||
21 | #include <sys/types.h> | ||
22 | |||
23 | #ifdef __cplusplus | ||
24 | extern "C" { | ||
25 | #endif | ||
26 | |||
27 | #ifndef __P | ||
28 | # ifdef __STDC__ | ||
29 | # define __P(args) args | ||
30 | # else | ||
31 | # define __P(args) () | ||
32 | # endif | ||
33 | #endif /*__P */ | ||
34 | |||
35 | struct _locker; | ||
36 | typedef struct _locker *locker_t; | ||
37 | |||
38 | extern int locker_add_ref __P ((locker_t)); | ||
39 | extern int locker_release __P ((locker_t)); | ||
40 | extern int locker_destroy __P ((locker_t)); | ||
41 | |||
42 | extern int locker_lock __P ((locker_t)); | ||
43 | extern int locker_touchlock __P ((locker_t)); | ||
44 | extern int locker_unlock __P ((locker_t)); | ||
45 | |||
46 | extern int locker_dotlock_create __P ((locker_t *, const char *filename)); | ||
47 | extern int locker_nfslock_create __P ((locker_t *, const char *filename)); | ||
48 | |||
49 | #ifdef __cplusplus | ||
50 | } | ||
51 | #endif | ||
52 | |||
53 | #endif /* _MAILUTILS_MAILBOX_H */ |
mailbox2/include/mailutils/mailbox.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 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 | #ifndef _MAILUTILS_MAILBOX_H | ||
19 | #define _MAILUTILS_MAILBOX_H | ||
20 | |||
21 | #include <sys/types.h> | ||
22 | |||
23 | /* Forward declaration. */ | ||
24 | struct _mailbox; | ||
25 | typedef struct _mailbox *mailbox_t; | ||
26 | |||
27 | #include <mailutils/url.h> | ||
28 | #include <mailutils/observer.h> | ||
29 | #include <mailutils/debug.h> | ||
30 | #include <mailutils/property.h> | ||
31 | #include <mailutils/message.h> | ||
32 | #include <mailutils/authority.h> | ||
33 | #include <mailutils/stream.h> | ||
34 | #include <mailutils/folder.h> | ||
35 | |||
36 | #ifdef __cplusplus | ||
37 | extern "C" { | ||
38 | #endif | ||
39 | |||
40 | #ifndef __P | ||
41 | # ifdef __STDC__ | ||
42 | # define __P(args) args | ||
43 | # else | ||
44 | # define __P(args) () | ||
45 | # endif | ||
46 | #endif /*__P */ | ||
47 | |||
48 | /* Constructor/destructor and possible types. */ | ||
49 | extern int mailbox_add_ref __P ((mailbox_t)); | ||
50 | extern int mailbox_release __P ((mailbox_t)); | ||
51 | extern int mailbox_destroy __P ((mailbox_t)); | ||
52 | extern int mailbox_get_folder __P ((mailbox_t, folder_t *)); | ||
53 | |||
54 | extern int mailbox_open __P ((mailbox_t, int flag)); | ||
55 | extern int mailbox_close __P ((mailbox_t)); | ||
56 | extern int mailbox_uidvalidity __P ((mailbox_t, unsigned long *)); | ||
57 | extern int mailbox_uidnext __P ((mailbox_t, size_t *)); | ||
58 | |||
59 | /* Messages. */ | ||
60 | extern int mailbox_get_message __P ((mailbox_t, size_t msgno, message_t *)); | ||
61 | extern int mailbox_append_message __P ((mailbox_t, message_t)); | ||
62 | extern int mailbox_messages_count __P ((mailbox_t, size_t *)); | ||
63 | extern int mailbox_messages_recent __P ((mailbox_t, size_t *)); | ||
64 | extern int mailbox_messages_unseen __P ((mailbox_t, size_t *)); | ||
65 | extern int mailbox_expunge __P ((mailbox_t)); | ||
66 | extern int mailbox_save_attributes __P ((mailbox_t)); | ||
67 | |||
68 | /* Update and scanning. */ | ||
69 | extern int mailbox_get_size __P ((mailbox_t, off_t *size)); | ||
70 | extern int mailbox_is_updated __P ((mailbox_t)); | ||
71 | extern int mailbox_scan __P ((mailbox_t, size_t no, size_t *count)); | ||
72 | |||
73 | /* Mailbox Stream. */ | ||
74 | extern int mailbox_get_stream __P ((mailbox_t, stream_t *)); | ||
75 | |||
76 | /* Authentication. */ | ||
77 | extern int mailbox_get_authority __P ((mailbox_t, authority_t *)); | ||
78 | extern int mailbox_set_authority __P ((mailbox_t, authority_t)); | ||
79 | |||
80 | /* Property. */ | ||
81 | extern int mailbox_get_property __P ((mailbox_t, property_t *)); | ||
82 | |||
83 | /* URL. */ | ||
84 | extern int mailbox_get_url __P ((mailbox_t, url_t *)); | ||
85 | |||
86 | /* For any debuging */ | ||
87 | extern int mailbox_get_debug __P ((mailbox_t, mu_debug_t *)); | ||
88 | extern int mailbox_set_debug __P ((mailbox_t, mu_debug_t)); | ||
89 | |||
90 | /* Events. */ | ||
91 | extern int mailbox_get_observable __P ((mailbox_t, observable_t *)); | ||
92 | |||
93 | extern int mailbox_create __P ((mailbox_t *, const char *)); | ||
94 | extern int mailbox_create_default __P ((mailbox_t *, const char *)); | ||
95 | |||
96 | #ifdef __cplusplus | ||
97 | } | ||
98 | #endif | ||
99 | |||
100 | #endif /* _MAILUTILS_MAILBOX_H */ |
... | @@ -18,14 +18,26 @@ | ... | @@ -18,14 +18,26 @@ |
18 | #ifndef _MAILUTILS_MBOX_H | 18 | #ifndef _MAILUTILS_MBOX_H |
19 | #define _MAILUTILS_MBOX_H | 19 | #define _MAILUTILS_MBOX_H |
20 | 20 | ||
21 | #include <mailutils/iterator.h> | ||
22 | #include <mailutils/stream.h> | ||
23 | #include <mailutils/message.h> | 21 | #include <mailutils/message.h> |
24 | #include <mailutils/observer.h> | 22 | #include <mailutils/observer.h> |
25 | 23 | ||
26 | __MAILUTILS_BEGIN_DECLS | 24 | #ifdef __cplusplus |
25 | extern "C" { | ||
26 | #endif | ||
27 | 27 | ||
28 | extern int mbox_create __P ((mbox_t)); | 28 | #ifndef __P |
29 | # ifdef __STDC__ | ||
30 | # define __P(args) args | ||
31 | # else | ||
32 | # define __P(args) () | ||
33 | # endif | ||
34 | #endif /*__P */ | ||
35 | |||
36 | struct _mbox; | ||
37 | typedef struct _mbox *mbox_t; | ||
38 | |||
39 | |||
40 | extern int mbox_create __P ((mbox_t *)); | ||
29 | extern int mbox_destroy __P ((mbox_t)); | 41 | extern int mbox_destroy __P ((mbox_t)); |
30 | 42 | ||
31 | extern int mbox_uidvalidity __P ((mbox_t, unsigned long *)); | 43 | extern int mbox_uidvalidity __P ((mbox_t, unsigned long *)); |
... | @@ -34,35 +46,28 @@ extern int mbox_uidnext __P ((mbox_t, unsigned long)); | ... | @@ -34,35 +46,28 @@ extern int mbox_uidnext __P ((mbox_t, unsigned long)); |
34 | extern int mbox_open __P ((mbox_t, const char *, int)); | 46 | extern int mbox_open __P ((mbox_t, const char *, int)); |
35 | extern int mbox_close __P ((mbox_t)); | 47 | extern int mbox_close __P ((mbox_t)); |
36 | 48 | ||
49 | extern int mbox_get_message __P ((mbox_t, unsigned int, message_t *)); | ||
37 | extern int mbox_get_envelope __P ((mbox_t, unsigned int, envelope_t *)); | 50 | extern int mbox_get_envelope __P ((mbox_t, unsigned int, envelope_t *)); |
38 | extern int mbox_set_envelope __P ((mbox_t, unsigned int, envelope_t)); | 51 | extern int mbox_get_header __P ((mbox_t, unsigned int, header_t *)); |
39 | 52 | extern int mbox_get_body __P ((mbox_t, unsigned int, body_t *)); | |
40 | extern int mbox_get_header __P ((mbox_t, unsigned int, stream_t *)); | ||
41 | extern int mbox_set_header __P ((mbox_t, unsigned int, stream_t)); | ||
42 | extern int mbox_header_size __P ((mbox_t, unsigned int, size_t *)); | ||
43 | extern int mbox_hdr_get_value __P ((mbox_t, unsigned int, char *, size_t, size_t *)); | ||
44 | extern int mbox_hdr_set_value __P ((mbox_t, unsigned int, char *, size_t, int)); | ||
45 | |||
46 | extern int mbox_get_body __P ((mbox_t, unsigned int, stream_t *)); | ||
47 | extern int mbox_set_body __P ((mbox_t, unsigned int, stream_t)); | ||
48 | extern int mbox_body_size __P ((mbox_t, unsigned int, size_t *)); | ||
49 | 53 | ||
50 | extern int mbox_get_flags __P ((mbox_t, unsigned int, int *)); | 54 | extern int mbox_get_flags __P ((mbox_t, unsigned int, int *)); |
51 | extern int mbox_set_flags __P ((mbox_t, unsigned int, int)); | ||
52 | 55 | ||
53 | extern int mbox_size __P ((mbox_t, unsigned long *)); | 56 | extern int mbox_get_size __P ((mbox_t, unsigned long *)); |
54 | 57 | ||
55 | extern int mbox_save_attributes __P ((mbox_t)); | 58 | extern int mbox_save_attributes __P ((mbox_t)); |
56 | extern int mbox_expunge __P ((mbox_t)); | 59 | extern int mbox_expunge __P ((mbox_t)); |
57 | extern int mbox_is_modified __P ((mbox_t)); | 60 | extern int mbox_is_modified __P ((mbox_t)); |
58 | 61 | ||
59 | extern int mbox_scan __P ((mbox_t, unsigned int, unsigned int *)); | 62 | extern int mbox_scan __P ((mbox_t, unsigned int, unsigned int *)); |
60 | extern int mbox_get_count __P ((mbox_t, unsigned int *)); | 63 | extern int mbox_messages_count __P ((mbox_t, unsigned int *)); |
61 | extern int mbox_get_oberver __P ((mbox_t, observer_t)); | 64 | extern int mbox_get_obervable __P ((mbox_t, observable_t *)); |
62 | 65 | ||
63 | extern int mbox_append __P ((mbox_t, stream_t)); | 66 | extern int mbox_append __P ((mbox_t, message_t)); |
64 | 67 | ||
65 | 68 | ||
66 | __MAILUTILS_END_DECLS | 69 | #ifdef __cplusplus |
70 | } | ||
71 | #endif | ||
67 | 72 | ||
68 | #endif /* _MAILUTILS_MBOX_H */ | 73 | #endif /* _MAILUTILS_MBOX_H */ | ... | ... |
mailbox2/include/mailutils/message.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 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 | #ifndef _MAILUTILS_MESSAGE_H | ||
19 | #define _MAILUTILS_MESSAGE_H | ||
20 | |||
21 | #include <sys/types.h> | ||
22 | |||
23 | /* forward declaration */ | ||
24 | struct _message; | ||
25 | typedef struct _message *message_t; | ||
26 | |||
27 | #include <mailutils/envelope.h> | ||
28 | #include <mailutils/header.h> | ||
29 | #include <mailutils/body.h> | ||
30 | #include <mailutils/stream.h> | ||
31 | #include <mailutils/attribute.h> | ||
32 | #include <mailutils/mailbox.h> | ||
33 | |||
34 | #ifndef __P | ||
35 | # ifdef __STDC__ | ||
36 | # define __P(args) args | ||
37 | # else | ||
38 | # define __P(args) () | ||
39 | # endif | ||
40 | #endif /* __P */ | ||
41 | |||
42 | #ifdef __cplusplus | ||
43 | extern "C" { | ||
44 | #endif | ||
45 | |||
46 | /* A message is considered to be a container for: | ||
47 | header_t, body_t, and its attribute_t. */ | ||
48 | |||
49 | extern int message_add_ref __P ((message_t)); | ||
50 | extern int message_release __P ((message_t)); | ||
51 | extern int message_destroy __P ((message_t)); | ||
52 | |||
53 | extern int message_is_modified __P ((message_t)); | ||
54 | extern int message_clear_modified __P ((message_t)); | ||
55 | extern int message_get_mailbox __P ((message_t, mailbox_t *)); | ||
56 | |||
57 | extern int message_get_envelope __P ((message_t, envelope_t *)); | ||
58 | extern int message_get_header __P ((message_t, header_t *)); | ||
59 | extern int message_get_body __P ((message_t, body_t *)); | ||
60 | extern int message_get_attribute __P ((message_t, attribute_t *)); | ||
61 | |||
62 | extern int message_get_stream __P ((message_t, stream_t *)); | ||
63 | |||
64 | extern int message_get_property __P ((message_t, property_t *)); | ||
65 | |||
66 | extern int message_is_multipart __P ((message_t, int *)); | ||
67 | |||
68 | extern int message_get_size __P ((message_t, size_t *)); | ||
69 | |||
70 | extern int message_get_lines __P ((message_t, size_t *)); | ||
71 | |||
72 | extern int message_get_num_parts __P ((message_t, size_t *nparts)); | ||
73 | |||
74 | extern int message_get_part __P ((message_t, size_t, message_t *)); | ||
75 | |||
76 | extern int message_get_uidl __P ((message_t, char *, size_t, size_t *)); | ||
77 | extern int message_get_uid __P ((message_t, size_t *)); | ||
78 | |||
79 | /* misc functions */ | ||
80 | extern int message_create_attachment __P ((const char *content_type, | ||
81 | const char *encoding, | ||
82 | const char *filename, | ||
83 | message_t *newmsg)); | ||
84 | extern int message_save_attachment __P ((message_t msg, | ||
85 | const char *filename, void **data)); | ||
86 | extern int message_encapsulate __P ((message_t msg, message_t *newmsg, | ||
87 | void **data)); | ||
88 | extern int message_unencapsulate __P ((message_t msg, message_t *newmsg, | ||
89 | void **data)); | ||
90 | |||
91 | #ifdef __cplusplus | ||
92 | } | ||
93 | #endif | ||
94 | |||
95 | #endif /* _MAILUTILS_MESSAGE_H */ |
mailbox2/include/mailutils/mutil.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 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 | #ifndef _MAILUTILS_MUTIL_H | ||
19 | #define _MAILUTILS_MUTIL_H | ||
20 | |||
21 | /* | ||
22 | Collection of useful utility routines that are worth sharing, | ||
23 | but don't have a natural home somewhere else. | ||
24 | */ | ||
25 | |||
26 | #include <time.h> | ||
27 | |||
28 | #ifndef __P | ||
29 | # ifdef __STDC__ | ||
30 | # define __P(args) args | ||
31 | # else | ||
32 | # define __P(args) () | ||
33 | # endif | ||
34 | #endif /*__P */ | ||
35 | |||
36 | #ifdef __cplusplus | ||
37 | extern "C" { | ||
38 | #endif | ||
39 | |||
40 | extern unsigned long mu_hex2ul __P ((char hex)); | ||
41 | extern size_t mu_hexstr2ul __P ((unsigned long* ul, const char* hex, size_t len)); | ||
42 | |||
43 | struct mu_timezone | ||
44 | { | ||
45 | int utc_offset; | ||
46 | /* Seconds east of UTC. */ | ||
47 | |||
48 | const char *tz_name; | ||
49 | /* Nickname for this timezone, if known. It is always considered | ||
50 | * to be a pointer to static string, so will never be freed. */ | ||
51 | }; | ||
52 | |||
53 | typedef struct mu_timezone mu_timezone; | ||
54 | |||
55 | extern int mu_parse_imap_date_time __P ((const char **p, struct tm * tm, | ||
56 | mu_timezone * tz)); | ||
57 | extern int mu_parse_ctime_date_time __P ((const char **p, struct tm * tm, | ||
58 | mu_timezone * tz)); | ||
59 | |||
60 | extern time_t mu_utc_offset __P ((void)); | ||
61 | extern time_t mu_tm2time __P ((struct tm * timeptr, mu_timezone * tz)); | ||
62 | extern char * mu_get_homedir __P ((void)); | ||
63 | extern char * mu_tilde_expansion __P ((const char *ref, const char *delim, const char *homedir)); | ||
64 | |||
65 | extern size_t util_cpystr __P ((char *dst, const char *src, size_t size)); | ||
66 | |||
67 | #ifdef __cplusplus | ||
68 | } | ||
69 | #endif | ||
70 | |||
71 | #endif /* _MAILUTILS_MUTIL_H */ | ||
72 |
mailbox2/include/mailutils/observable.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 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 | #ifndef _MAILUTILS_OBSERVABLE_H | ||
19 | #define _MAILUTILS_OBSERVABLE_H | ||
20 | |||
21 | #include <sys/types.h> | ||
22 | #include <mailutils/observer.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 | struct _observable; | ||
37 | typedef struct _observable *observable_t; | ||
38 | |||
39 | extern int observable_create __P ((observable_t *)); | ||
40 | extern int observable_release __P ((observable_t)); | ||
41 | extern int observable_destroy __P ((observable_t)); | ||
42 | |||
43 | extern int observable_attach __P ((observable_t, int, observer_t)); | ||
44 | extern int observable_detach __P ((observable_t, observer_t)); | ||
45 | extern int observable_notify_all __P ((observable_t, struct event)); | ||
46 | |||
47 | #ifdef __cplusplus | ||
48 | } | ||
49 | #endif | ||
50 | |||
51 | #endif /* _MAILUTILS_OBSERVABLE_H */ |
... | @@ -19,7 +19,6 @@ | ... | @@ -19,7 +19,6 @@ |
19 | #define _MAILUTILS_OBSERVER_H | 19 | #define _MAILUTILS_OBSERVER_H |
20 | 20 | ||
21 | #include <sys/types.h> | 21 | #include <sys/types.h> |
22 | #include <mailutils/base.h> | ||
23 | 22 | ||
24 | #ifndef __P | 23 | #ifndef __P |
25 | #ifdef __STDC__ | 24 | #ifdef __STDC__ |
... | @@ -34,19 +33,17 @@ extern "C" { | ... | @@ -34,19 +33,17 @@ extern "C" { |
34 | #endif | 33 | #endif |
35 | 34 | ||
36 | struct _observer; | 35 | struct _observer; |
37 | struct _observable; | ||
38 | typedef struct _observer * observer_t; | 36 | typedef struct _observer * observer_t; |
39 | typedef struct _observable * observable_t; | ||
40 | 37 | ||
41 | struct event | 38 | struct event |
42 | { | 39 | { |
43 | int type; | 40 | int type; |
44 | union | 41 | union |
45 | { | 42 | { |
46 | mailbox_t mailbox; /* For corrupted mailbox. */ | 43 | void *mailbox; /* For corrupted mailbox. */ |
47 | int msgno; /* For new message. */ | 44 | int msgno; /* For new message. */ |
48 | int percentage; /* Scan progress. */ | 45 | int percentage; /* Scan progress. */ |
49 | message_t message; /* message sent. */ | 46 | void *message; /* message sent. */ |
50 | } data ; | 47 | } data ; |
51 | }; | 48 | }; |
52 | 49 | ||
... | @@ -65,15 +62,6 @@ extern int observer_destroy __P ((observer_t)); | ... | @@ -65,15 +62,6 @@ extern int observer_destroy __P ((observer_t)); |
65 | 62 | ||
66 | extern int observer_action __P ((observer_t, struct event)); | 63 | extern int observer_action __P ((observer_t, struct event)); |
67 | 64 | ||
68 | |||
69 | extern int observable_create __P ((observable_t *)); | ||
70 | extern int observable_release __P ((observable_t)); | ||
71 | extern int observable_destroy __P ((observable_t)); | ||
72 | |||
73 | extern int observable_attach __P ((observable_t, int, observer_t)); | ||
74 | extern int observable_detach __P ((observable_t, observer_t)); | ||
75 | extern int observable_notify_all __P ((observable_t, struct event)); | ||
76 | |||
77 | #ifdef __cplusplus | 65 | #ifdef __cplusplus |
78 | } | 66 | } |
79 | #endif | 67 | #endif | ... | ... |
mailbox2/include/mailutils/property.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 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 | #ifndef _MAILUTILS_PROPERTY_H | ||
19 | #define _MAILUTILS_PROPERTY_H | ||
20 | |||
21 | #include <sys/types.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 _property; | ||
36 | typedef struct _property *property_t; | ||
37 | |||
38 | extern int property_create __P ((property_t *)); | ||
39 | extern int property_destroy __P ((property_t)); | ||
40 | |||
41 | extern int property_set_value __P ((property_t, const char *, const char *, | ||
42 | int)); | ||
43 | extern int property_get_value __P ((property_t, const char *, char * const *)); | ||
44 | |||
45 | /* Helper functions. */ | ||
46 | extern int property_set __P ((property_t, const char *)); | ||
47 | extern int property_unset __P ((property_t, const char *)); | ||
48 | extern int property_is_set __P ((property_t, const char *)); | ||
49 | |||
50 | #ifdef __cplusplus | ||
51 | } | ||
52 | #endif | ||
53 | |||
54 | #endif /* _MAILUTILS_PROPERTY_H */ |
... | @@ -3,15 +3,24 @@ | ... | @@ -3,15 +3,24 @@ |
3 | pkginclude_HEADERS = \ | 3 | pkginclude_HEADERS = \ |
4 | address.h \ | 4 | address.h \ |
5 | attribute.h \ | 5 | attribute.h \ |
6 | authority.h \ | ||
6 | bstream.h \ | 7 | bstream.h \ |
7 | envelope.h \ | 8 | envelope.h \ |
9 | folder.h \ | ||
8 | fstream.h \ | 10 | fstream.h \ |
9 | header.h \ | 11 | header.h \ |
10 | iterator.h \ | 12 | iterator.h \ |
11 | list.h \ | 13 | list.h \ |
14 | locker.h \ | ||
15 | mailbox.h \ | ||
12 | mbox.h \ | 16 | mbox.h \ |
17 | memstream.h \ | ||
18 | message.h \ | ||
13 | mstream.h \ | 19 | mstream.h \ |
20 | observable.h \ | ||
14 | observer.h \ | 21 | observer.h \ |
15 | pop3.h \ | 22 | pop3.h \ |
16 | stream.h \ | 23 | stream.h \ |
17 | tcpstream.h | 24 | tcpstream.h \ |
25 | ticket.h \ | ||
26 | url.h | ... | ... |
... | @@ -63,16 +63,6 @@ struct _da | ... | @@ -63,16 +63,6 @@ struct _da |
63 | monitor_t lock; | 63 | monitor_t lock; |
64 | }; | 64 | }; |
65 | 65 | ||
66 | #define attribute_add_ref(a) ((a)->vtable->add_ref)(s) | ||
67 | #define attribute_release(a) ((a)->vtable->release)(s) | ||
68 | #define attribute_destroy(a) ((a)->vtable->destroy)(s) | ||
69 | |||
70 | #define attribute_get_flags(a,pf) ((a)->vtable->get_flags)(a,pf) | ||
71 | #define attribute_set_flags(a,f) ((a)->vtable->set_flags)(a,f) | ||
72 | #define attribute_unset_flags(a,f) ((a)->vtable->unset_flags)(a,f) | ||
73 | #define attribute_clear_flags(a) ((a)->vtable->clear_flags)(a) | ||
74 | |||
75 | |||
76 | #ifdef __cplusplus | 66 | #ifdef __cplusplus |
77 | } | 67 | } |
78 | #endif | 68 | #endif | ... | ... |
mailbox2/include/mailutils/sys/authority.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 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 | #ifndef _MAILUTILS_SYS_AUTHORITY_H | ||
19 | #define _MAILUTILS_SYS_AUTHORITY_H | ||
20 | |||
21 | #ifdef DMALLOC | ||
22 | #include <dmalloc.h> | ||
23 | #endif | ||
24 | |||
25 | #include <mailutils/authority.h> | ||
26 | |||
27 | #ifdef __cplusplus | ||
28 | extern "C" { | ||
29 | #endif | ||
30 | |||
31 | #ifndef __P | ||
32 | # ifdef __STDC__ | ||
33 | # define __P(args) args | ||
34 | # else | ||
35 | # define __P(args) () | ||
36 | # endif | ||
37 | #endif /*__P */ | ||
38 | |||
39 | struct _authority_vtable | ||
40 | { | ||
41 | int (*add_ref) __P ((authority_t)); | ||
42 | int (*release) __P ((authority_t)); | ||
43 | int (*destroy) __P ((authority_t)); | ||
44 | |||
45 | int (*set_ticket) __P ((authority_t, ticket_t)); | ||
46 | int (*get_ticket) __P ((authority_t, ticket_t *)); | ||
47 | int (*authenticate) __P ((authority_t)); | ||
48 | }; | ||
49 | |||
50 | struct _authority | ||
51 | { | ||
52 | struct _authority_vtable *vtable; | ||
53 | }; | ||
54 | |||
55 | #ifdef __cplusplus | ||
56 | } | ||
57 | #endif | ||
58 | |||
59 | #endif /* _MAILUTILS_SYS_AUTHORITY_H */ |
mailbox2/include/mailutils/sys/folder.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 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 | #ifndef _MAILUTILS_SYS_FOLDER_H | ||
19 | #define _MAILUTILS_SYS_FOLDER_H | ||
20 | |||
21 | #include <mailutils/folder.h> | ||
22 | |||
23 | |||
24 | #ifdef __cplusplus | ||
25 | extern "C" { | ||
26 | #endif | ||
27 | |||
28 | #ifndef __P | ||
29 | # ifdef __STDC__ | ||
30 | # define __P(args) args | ||
31 | # else | ||
32 | # define __P(args) () | ||
33 | # endif | ||
34 | #endif /*__P */ | ||
35 | |||
36 | struct _folder_vtable | ||
37 | { | ||
38 | int (*add_ref) __P ((folder_t)); | ||
39 | int (*release) __P ((folder_t)); | ||
40 | int (*destroy) __P ((folder_t)); | ||
41 | |||
42 | int (*open) __P ((folder_t, int flag)); | ||
43 | int (*close) __P ((folder_t)); | ||
44 | |||
45 | int (*delete) __P ((folder_t, const char *)); | ||
46 | int (*rename) __P ((folder_t, const char *, const char *)); | ||
47 | int (*subscribe) __P ((folder_t, const char *)); | ||
48 | int (*unsubscribe) __P ((folder_t, const char *)); | ||
49 | int (*list) __P ((folder_t, const char *, const char *, iterator_t *)); | ||
50 | int (*lsub) __P ((folder_t, const char *, const char *, iterator_t *)); | ||
51 | |||
52 | /* Stream settings. */ | ||
53 | int (*get_stream) __P ((folder_t, stream_t *)); | ||
54 | int (*set_stream) __P ((folder_t, stream_t)); | ||
55 | |||
56 | /* Notifications. */ | ||
57 | int (*get_observable) __P ((folder_t, observable_t *)); | ||
58 | int (*get_debug) __P ((folder_t, mu_debug_t *)); | ||
59 | int (*set_debug) __P ((folder_t, mu_debug_t)); | ||
60 | |||
61 | /* Authentication. */ | ||
62 | int (*get_authority) __P ((folder_t, authority_t *)); | ||
63 | int (*set_authority) __P ((folder_t, authority_t)); | ||
64 | |||
65 | /* URL. */ | ||
66 | int (*get_url) __P ((folder_t, url_t *)); | ||
67 | |||
68 | }; | ||
69 | |||
70 | struct _folder | ||
71 | { | ||
72 | struct _folder_vtable *vtable; | ||
73 | }; | ||
74 | |||
75 | #ifdef __cplusplus | ||
76 | } | ||
77 | #endif | ||
78 | |||
79 | #endif /* _MAILUTILS_SYS_FOLDER_H */ |
... | @@ -42,16 +42,6 @@ struct _iterator | ... | @@ -42,16 +42,6 @@ struct _iterator |
42 | struct _iterator_vtable *vtable; | 42 | struct _iterator_vtable *vtable; |
43 | }; | 43 | }; |
44 | 44 | ||
45 | /* Use macros for the implentation. */ | ||
46 | #define iterator_add_ref(i) ((i)->vtable->add_ref)(i) | ||
47 | #define iterator_release(i) ((i)->vtable->release)(i) | ||
48 | #define iterator_destroy(i) ((i)->vtable->destroy)(i) | ||
49 | |||
50 | #define iterator_first(i) ((i)->vtable->first)(i) | ||
51 | #define iterator_next(i) ((i)->vtable->next)(i) | ||
52 | #define iterator_current(i,a) ((i)->vtable->current)(i,a) | ||
53 | #define iterator_is_done(i) ((i)->vtable->is_done)(i) | ||
54 | |||
55 | #ifdef __cplusplus | 45 | #ifdef __cplusplus |
56 | } | 46 | } |
57 | #endif | 47 | #endif | ... | ... |
mailbox2/include/mailutils/sys/locker.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 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 | #ifndef _MAILUTILS_SYS_LOCKER_H | ||
19 | #define _MAILUTILS_SYS_LOCKER_H | ||
20 | |||
21 | #ifdef DMALLOC | ||
22 | #include <dmalloc.h> | ||
23 | #endif | ||
24 | |||
25 | #include <mailutils/locker.h> | ||
26 | |||
27 | #ifdef __cplusplus | ||
28 | extern "C" { | ||
29 | #endif | ||
30 | |||
31 | #ifndef __P | ||
32 | # ifdef __STDC__ | ||
33 | # define __P(args) args | ||
34 | # else | ||
35 | # define __P(args) () | ||
36 | # endif | ||
37 | #endif /*__P */ | ||
38 | |||
39 | struct _locker_vtable | ||
40 | { | ||
41 | int (*add_ref) __P ((locker_t)); | ||
42 | int (*release) __P ((locker_t)); | ||
43 | int (*destroy) __P ((locker_t)); | ||
44 | |||
45 | int (*lock) __P ((locker_t)); | ||
46 | int (*touchlock) __P ((locker_t)); | ||
47 | int (*unlock) __P ((locker_t)); | ||
48 | }; | ||
49 | |||
50 | struct _locker | ||
51 | { | ||
52 | struct _locker_vtable *vtable; | ||
53 | }; | ||
54 | |||
55 | #ifdef __cplusplus | ||
56 | } | ||
57 | #endif | ||
58 | |||
59 | #endif /* _MAILUTILS_SYS_ENVELOPE_H */ |
mailbox2/include/mailutils/sys/mailbox.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 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 | #ifndef _MAILUTILS_SYS_MAILBOX_H | ||
19 | #define _MAILUTILS_SYS_MAILBOX_H | ||
20 | |||
21 | #include <mailutils/mailbox.h> | ||
22 | |||
23 | #ifdef __cplusplus | ||
24 | extern "C" { | ||
25 | #endif | ||
26 | |||
27 | #ifndef __P | ||
28 | # ifdef __STDC__ | ||
29 | # define __P(args) args | ||
30 | # else | ||
31 | # define __P(args) () | ||
32 | # endif | ||
33 | #endif /*__P */ | ||
34 | |||
35 | struct _mailbox_vtable | ||
36 | { | ||
37 | /* Constructor/destructor and possible types. */ | ||
38 | int (*add_ref) __P ((mailbox_t)); | ||
39 | int (*release) __P ((mailbox_t)); | ||
40 | int (*destroy) __P ((mailbox_t)); | ||
41 | int (*get_folder) __P ((mailbox_t, folder_t *)); | ||
42 | |||
43 | int (*open) __P ((mailbox_t, int flag)); | ||
44 | int (*close) __P ((mailbox_t)); | ||
45 | int (*uidvalidity) __P ((mailbox_t, unsigned long *)); | ||
46 | int (*uidnext) __P ((mailbox_t, size_t *)); | ||
47 | |||
48 | /* Messages. */ | ||
49 | int (*get_message) __P ((mailbox_t, size_t msgno, message_t *)); | ||
50 | int (*append_message) __P ((mailbox_t, message_t)); | ||
51 | int (*messages_count) __P ((mailbox_t, size_t *)); | ||
52 | int (*messages_recent) __P ((mailbox_t, size_t *)); | ||
53 | int (*messages_unseen) __P ((mailbox_t, size_t *)); | ||
54 | int (*expunge) __P ((mailbox_t)); | ||
55 | int (*save_attributes) __P ((mailbox_t)); | ||
56 | |||
57 | /* Update and scanning. */ | ||
58 | int (*get_size) __P ((mailbox_t, off_t *size)); | ||
59 | int (*is_updated) __P ((mailbox_t)); | ||
60 | int (*scan) __P ((mailbox_t, size_t no, size_t *count)); | ||
61 | |||
62 | /* Mailbox Stream. */ | ||
63 | int (*get_stream) __P ((mailbox_t, stream_t *)); | ||
64 | |||
65 | /* Authentication. */ | ||
66 | int (*get_authority) __P ((mailbox_t, authority_t *)); | ||
67 | int (*set_authority) __P ((mailbox_t, authority_t)); | ||
68 | |||
69 | /* Property. */ | ||
70 | int (*get_property) __P ((mailbox_t, property_t *)); | ||
71 | |||
72 | /* URL. */ | ||
73 | int (*get_url) __P ((mailbox_t, url_t *)); | ||
74 | |||
75 | /* For any debuging */ | ||
76 | int (*get_debug) __P ((mailbox_t, mu_debug_t *)); | ||
77 | int (*set_debug) __P ((mailbox_t, mu_debug_t)); | ||
78 | |||
79 | /* Events. */ | ||
80 | int (*get_observable) __P ((mailbox_t, observable_t *)); | ||
81 | }; | ||
82 | |||
83 | struct _mailbox | ||
84 | { | ||
85 | struct _mailbox_vtable *vtable; | ||
86 | }; | ||
87 | |||
88 | #ifdef __cplusplus | ||
89 | } | ||
90 | #endif | ||
91 | |||
92 | #endif /* _MAILUTILS_SYS_MAILBOX_H */ |
mailbox2/include/mailutils/sys/mbox.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 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 | #ifndef _MAILUTILS_SYS_MBOX_H | ||
19 | #define _MAILUTILS_SYS_MBOX_H | ||
20 | |||
21 | #include <time.h> | ||
22 | #include <mailutils/mbox.h> | ||
23 | |||
24 | #ifdef __cplusplus | ||
25 | extern "C" { | ||
26 | #endif | ||
27 | |||
28 | typedef struct _mbox_message* mbox_message_t; | ||
29 | |||
30 | /* Below are the headers field-names that we are caching for speed, it is | ||
31 | more or less the list of headers in ENVELOPE command from IMAP. */ | ||
32 | #define HDRSIZE 15 | ||
33 | |||
34 | const char *fhdr_table[] = | ||
35 | { | ||
36 | #define H_BCC 0 | ||
37 | "Bcc", | ||
38 | #define H_CC 1 | ||
39 | "Cc", | ||
40 | #define H_CONTENT_LANGUAGE 2 | ||
41 | "Content-Language", | ||
42 | #define H_CONTENT_TRANSFER_ENCODING 3 | ||
43 | "Content-Transfer-Encoding", | ||
44 | #define H_CONTENT_TYPE 4 | ||
45 | "Content-Type", | ||
46 | #define H_DATE 5 | ||
47 | "Date", | ||
48 | #define H_FROM 6 | ||
49 | "From", | ||
50 | #define H_IN_REPLY_TO 7 | ||
51 | "In-Reply-To", | ||
52 | #define H_MESSAGE_ID 8 | ||
53 | "Message-ID", | ||
54 | #define H_REFERENCE 9 | ||
55 | "Reply-To", | ||
56 | #define H_REPLY_TO 10 | ||
57 | "Reply-To", | ||
58 | #define H_SENDER 11 | ||
59 | "Sender", | ||
60 | #define H_SUBJECT 12 | ||
61 | "Subject", | ||
62 | #define H_TO 13 | ||
63 | "To", | ||
64 | #define H_X_UIDL 14 | ||
65 | "X-UIDL" | ||
66 | }; | ||
67 | |||
68 | /* Keep the file positions of where the headers and bodies start and end. | ||
69 | attr_flags is the "Status:" message. */ | ||
70 | struct _mbox_message | ||
71 | { | ||
72 | /* Offset of the messages in the mailbox. */ | ||
73 | off_t header_from; | ||
74 | off_t header_from_end; | ||
75 | off_t body; | ||
76 | off_t body_end; | ||
77 | |||
78 | /* Fast header retrieve, we save here the most common headers. This will | ||
79 | speed the header search. The entire headers are copied, when modified, | ||
80 | by the header_t object, we do not have to worry about updating them. */ | ||
81 | char *fhdr[HDRSIZE]; | ||
82 | |||
83 | size_t uid; /* IMAP uid. */ | ||
84 | |||
85 | int attr_flags; /* The attr_flags contains the "Status:" attribute */ | ||
86 | |||
87 | size_t header_lines; | ||
88 | size_t body_lines; | ||
89 | |||
90 | message_t message; /* A message attach to it. */ | ||
91 | mbox_t mud; /* Back pointer. */ | ||
92 | }; | ||
93 | |||
94 | /* The umessages is an array of pointers that contains umessages_count of | ||
95 | mbox_message_t*; umessages[umessages_count]. We do it this way because | ||
96 | realloc() can move everything to a new memory region and invalidate all | ||
97 | the pointers. Thanks to <Dave Inglis> for pointing this out. The | ||
98 | messages_count is the count number of messages parsed so far. */ | ||
99 | struct _mbox | ||
100 | { | ||
101 | mbox_message_t *umessages; /* Array. */ | ||
102 | size_t umessages_count; /* How big is the umessages[]. */ | ||
103 | size_t messages_count; /* How many valid entry in umessages[]. */ | ||
104 | |||
105 | stream_t stream; | ||
106 | off_t size; /* Size of the mailbox. */ | ||
107 | time_t mtime; /* Modified time. */ | ||
108 | unsigned long uidvalidity; | ||
109 | size_t uidnext; | ||
110 | char *filename; | ||
111 | |||
112 | /* The variables below are use to hold the state when appending messages. */ | ||
113 | enum mbox_state | ||
114 | { | ||
115 | MBOX_NO_STATE = 0, | ||
116 | MBOX_STATE_APPEND_SENDER, MBOX_STATE_APPEND_DATE, MBOX_STATE_APPEND_HEADER, | ||
117 | MBOX_STATE_APPEND_ATTRIBUTE, MBOX_STATE_APPEND_UID, MBOX_STATE_APPEND_BODY, | ||
118 | MBOX_STATE_APPEND_MESSAGE | ||
119 | } state ; | ||
120 | char *sender; | ||
121 | char *to; | ||
122 | char *date; | ||
123 | off_t off; | ||
124 | monitor_t lock; | ||
125 | locker_t dotlock; | ||
126 | }; | ||
127 | |||
128 | #ifdef __cplusplus | ||
129 | } | ||
130 | #endif | ||
131 | |||
132 | #endif /* _MAILUTILS_SYS_MBOX_H */ |
mailbox2/include/mailutils/sys/memstream.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_MEMSTREAM_H | ||
19 | #define MAILUTILS_SYS_MEMSTREAM_H | ||
20 | |||
21 | #include <sys/types.h> | ||
22 | |||
23 | #include <mailutils/monitor.h> | ||
24 | #include <mailutils/sys/stream.h> | ||
25 | |||
26 | struct _memory_stream | ||
27 | { | ||
28 | struct _stream base; | ||
29 | int ref; | ||
30 | char *ptr; | ||
31 | size_t size; | ||
32 | off_t offset; | ||
33 | int flags; | ||
34 | monitor_t lock; | ||
35 | }; | ||
36 | |||
37 | #endif /* _MAILUTILS_SYS_MEMSTREAM_H */ |
mailbox2/include/mailutils/sys/message.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 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 | #ifndef _MAILUTILS_SYS_MESSAGE_H | ||
19 | #define _MAILUTILS_SYS_MESSAGE_H | ||
20 | |||
21 | #include <mailutils/message.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 | /* A message is considered to be a container for: | ||
36 | header_t, body_t, and its attribute_t. */ | ||
37 | |||
38 | struct _message_vtable | ||
39 | { | ||
40 | int (*add_ref) __P ((message_t)); | ||
41 | int (*release) __P ((message_t)); | ||
42 | int (*destroy) __P ((message_t)); | ||
43 | |||
44 | int (*is_modified) __P ((message_t)); | ||
45 | int (*clear_modified) __P ((message_t)); | ||
46 | int (*get_mailbox) __P ((message_t, mailbox_t *)); | ||
47 | |||
48 | int (*get_envelope) __P ((message_t, envelope_t *)); | ||
49 | int (*get_header) __P ((message_t, header_t *)); | ||
50 | int (*get_body) __P ((message_t, body_t *)); | ||
51 | int (*get_attribute) __P ((message_t, attribute_t *)); | ||
52 | |||
53 | int (*get_stream) __P ((message_t, stream_t *)); | ||
54 | |||
55 | int (*get_property) __P ((message_t, property_t *)); | ||
56 | |||
57 | int (*is_multipart) __P ((message_t, int *)); | ||
58 | |||
59 | int (*get_size) __P ((message_t, size_t *)); | ||
60 | |||
61 | int (*get_lines) __P ((message_t, size_t *)); | ||
62 | |||
63 | int (*get_num_parts) __P ((message_t, size_t *nparts)); | ||
64 | |||
65 | int (*get_part) __P ((message_t, size_t, message_t *)); | ||
66 | |||
67 | int (*get_uidl) __P ((message_t, char *, size_t, size_t *)); | ||
68 | int (*get_uid) __P ((message_t, size_t *)); | ||
69 | }; | ||
70 | |||
71 | struct _message | ||
72 | { | ||
73 | struct _message_vtable *vtable; | ||
74 | }; | ||
75 | |||
76 | |||
77 | #ifdef __cplusplus | ||
78 | } | ||
79 | #endif | ||
80 | |||
81 | #endif /* _MAILUTILS_SYS_MESSAGE_H */ |
mailbox2/include/mailutils/sys/observable.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 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 | #ifndef _MAILUTILS_SYS_OBSERVABLE_H | ||
19 | #define _MAILUTILS_SYS_OBSERVABLE_H | ||
20 | |||
21 | #ifdef DMALLOC | ||
22 | # include <dmalloc.h> | ||
23 | #endif | ||
24 | |||
25 | #include <mailutils/monitor.h> | ||
26 | #include <mailutils/list.h> | ||
27 | #include <mailutils/observable.h> | ||
28 | |||
29 | #ifndef __P | ||
30 | #ifdef __STDC__ | ||
31 | #define __P(args) args | ||
32 | #else | ||
33 | #define __P(args) () | ||
34 | #endif | ||
35 | #endif /*__P */ | ||
36 | |||
37 | #ifdef __cplusplus | ||
38 | extern "C" { | ||
39 | #endif | ||
40 | |||
41 | struct _observable | ||
42 | { | ||
43 | list_t list; | ||
44 | }; | ||
45 | |||
46 | #ifdef __cplusplus | ||
47 | } | ||
48 | #endif | ||
49 | |||
50 | #endif /* _MAILUTILS_SYS_OBSERVER_H */ |
... | @@ -54,28 +54,6 @@ struct _stream | ... | @@ -54,28 +54,6 @@ struct _stream |
54 | struct _stream_vtable *vtable; | 54 | struct _stream_vtable *vtable; |
55 | }; | 55 | }; |
56 | 56 | ||
57 | #define stream_add_ref(s) ((s)->vtable->add_ref)(s) | ||
58 | #define stream_release(s) ((s)->vtable->release)(s) | ||
59 | #define stream_destroy(s) ((s)->vtable->destroy)(s) | ||
60 | |||
61 | #define stream_open(s,h,p,f) ((s)->vtable->open)(s,h,p,f) | ||
62 | #define stream_close(s) ((s)->vtable->close)(s) | ||
63 | |||
64 | #define stream_read(s,b,l,n) ((s)->vtable->read)(s,b,l,n) | ||
65 | #define stream_readline(s,b,l,n) ((s)->vtable->readline)(s,b,l,n) | ||
66 | #define stream_write(s,b,l,n) ((s)->vtable->write)(s,b,l,n) | ||
67 | |||
68 | #define stream_seek(s,o,w) ((s)->vtable->seek)(s,o,w) | ||
69 | #define stream_tell(s,o) ((s)->vtable->tell)(s,o) | ||
70 | |||
71 | #define stream_get_size(s,o) ((s)->vtable->get_size)(s,o) | ||
72 | #define stream_flush(s) ((s)->vtable->flush)(s) | ||
73 | #define stream_truncate(s,o) ((s)->vtable->truncate)(s,o) | ||
74 | |||
75 | #define stream_get_fd(s,f) ((s)->vtable->get_fd)(s,f) | ||
76 | #define stream_get_flags(s,f) ((s)->vtable->get_flags)(s,f) | ||
77 | #define stream_get_state(s,f) ((s)->vtable->get_state)(s,f) | ||
78 | |||
79 | #ifdef __cplusplus | 57 | #ifdef __cplusplus |
80 | } | 58 | } |
81 | #endif | 59 | #endif | ... | ... |
mailbox2/include/mailutils/sys/ticket.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 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 | #ifndef _MAILUTILS_SYS_TICKET_H | ||
19 | #define _MAILUTILS_SYS_TICKET_H | ||
20 | |||
21 | #ifdef DMALLOC | ||
22 | #include <dmalloc.h> | ||
23 | #endif | ||
24 | |||
25 | #include <mailutils/ticket.h> | ||
26 | |||
27 | #ifdef __cplusplus | ||
28 | extern "C" { | ||
29 | #endif | ||
30 | |||
31 | #ifndef __P | ||
32 | # ifdef __STDC__ | ||
33 | # define __P(args) args | ||
34 | # else | ||
35 | # define __P(args) () | ||
36 | # endif | ||
37 | #endif /*__P */ | ||
38 | |||
39 | struct _ticket_vtable | ||
40 | { | ||
41 | int (*add_ref) __P ((ticket_t)); | ||
42 | int (*release) __P ((ticket_t)); | ||
43 | int (*destroy) __P ((ticket_t)); | ||
44 | |||
45 | int (*pop) __P ((ticket_t, const char *, char **)); | ||
46 | }; | ||
47 | |||
48 | struct _ticket | ||
49 | { | ||
50 | struct _ticket_vtable *vtable; | ||
51 | }; | ||
52 | |||
53 | #ifdef __cplusplus | ||
54 | } | ||
55 | #endif | ||
56 | |||
57 | #endif /* _MAILUTILS_SYS_TICKET_H */ |
mailbox2/include/mailutils/sys/url.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 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 | #ifndef _MAILUTILS_SYS_URL_H | ||
19 | #define _MAILUTILS_SYS_URL_H 1 | ||
20 | |||
21 | #ifdef DMALLOC | ||
22 | # include <dmalloc.h> | ||
23 | #endif | ||
24 | |||
25 | #include <mailutils/url.h> | ||
26 | |||
27 | #ifdef __cplusplus | ||
28 | extern "C" { | ||
29 | #endif | ||
30 | |||
31 | #ifndef __P | ||
32 | # if __STDC__ | ||
33 | # define __P(args) args | ||
34 | # else | ||
35 | # define __P(args) () | ||
36 | # endif | ||
37 | #endif /*!__P */ | ||
38 | |||
39 | struct _url | ||
40 | { | ||
41 | /* Data */ | ||
42 | char *name; | ||
43 | char *scheme; | ||
44 | char *user; | ||
45 | char *passwd; | ||
46 | char *auth; | ||
47 | char *host; | ||
48 | long port; | ||
49 | char *path; | ||
50 | char *query; | ||
51 | |||
52 | |||
53 | void *data; | ||
54 | |||
55 | void (*_destroy) __P ((url_t url)); | ||
56 | |||
57 | /* Methods */ | ||
58 | int (*_get_scheme) __P ((const url_t, char *, size_t, size_t *)); | ||
59 | int (*_get_user) __P ((const url_t, char *, size_t, size_t *)); | ||
60 | int (*_get_passwd) __P ((const url_t, char *, size_t, size_t *)); | ||
61 | int (*_get_auth) __P ((const url_t, char *, size_t, size_t *)); | ||
62 | int (*_get_host) __P ((const url_t, char *, size_t, size_t *)); | ||
63 | int (*_get_port) __P ((const url_t, long *)); | ||
64 | int (*_get_path) __P ((const url_t, char *, size_t, size_t *)); | ||
65 | int (*_get_query) __P ((const url_t, char *, size_t, size_t *)); | ||
66 | }; | ||
67 | |||
68 | |||
69 | #ifdef __cplusplus | ||
70 | } | ||
71 | #endif | ||
72 | |||
73 | #endif /* _MAILUTILS_SYS_URL_H */ |
mailbox2/include/mailutils/ticket.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 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 | #ifndef _MAILUTILS_TICKET_H | ||
19 | #define _MAILUTILS_TICKET_H | ||
20 | |||
21 | #include <sys/types.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 | /* forward declaration */ | ||
36 | struct _ticket; | ||
37 | typedef struct _ticket *ticket_t; | ||
38 | |||
39 | extern int ticket_add_ref __P ((ticket_t)); | ||
40 | extern int ticket_release __P ((ticket_t)); | ||
41 | extern int ticket_destroy __P ((ticket_t)); | ||
42 | |||
43 | extern int ticket_pop __P ((ticket_t, const char *, char **)); | ||
44 | |||
45 | extern int ticket_prompt_create __P ((ticket_t *)); | ||
46 | |||
47 | #ifdef __cplusplus | ||
48 | } | ||
49 | #endif | ||
50 | |||
51 | #endif /* _MAILUTILS_TICKET_H */ |
mailbox2/include/mailutils/url.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 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 | #ifndef _MAILUTILS_URL_H | ||
19 | #define _MAILUTILS_URL_H 1 | ||
20 | |||
21 | #include <sys/types.h> | ||
22 | |||
23 | #ifdef __cplusplus | ||
24 | extern "C" { | ||
25 | #endif | ||
26 | |||
27 | #ifndef __P | ||
28 | # if __STDC__ | ||
29 | # define __P(args) args | ||
30 | # else | ||
31 | # define __P(args) () | ||
32 | # endif | ||
33 | #endif /*!__P */ | ||
34 | |||
35 | /* Forward declaration. */ | ||
36 | struct _url; | ||
37 | typedef struct _url * url_t; | ||
38 | |||
39 | extern int url_destroy __P ((url_t)); | ||
40 | extern int url_parse __P ((url_t)); | ||
41 | |||
42 | extern int url_get_scheme __P ((const url_t, char *, size_t, size_t *)); | ||
43 | extern int url_get_user __P ((const url_t, char *, size_t, size_t *)); | ||
44 | extern int url_get_passwd __P ((const url_t, char *, size_t, size_t *)); | ||
45 | extern int url_get_auth __P ((const url_t, char *, size_t, size_t *)); | ||
46 | extern int url_get_host __P ((const url_t, char *, size_t, size_t *)); | ||
47 | extern int url_get_port __P ((const url_t, long *)); | ||
48 | extern int url_get_path __P ((const url_t, char *, size_t, size_t *)); | ||
49 | extern int url_get_query __P ((const url_t, char *, size_t, size_t *)); | ||
50 | extern const char* url_to_string __P ((const url_t)); | ||
51 | |||
52 | extern int url_is_same_scheme __P ((url_t, url_t)); | ||
53 | extern int url_is_same_user __P ((url_t, url_t)); | ||
54 | extern int url_is_same_path __P ((url_t, url_t)); | ||
55 | extern int url_is_same_host __P ((url_t, url_t)); | ||
56 | extern int url_is_same_port __P ((url_t, url_t)); | ||
57 | |||
58 | extern char* url_decode __P ((const char *s)); | ||
59 | |||
60 | extern int url_imap_create __P ((url_t *, const char *)); | ||
61 | extern int url_pop_create __P ((url_t *, const char *)); | ||
62 | extern int url_file_create __P ((url_t *, const char *)); | ||
63 | extern int url_path_create __P ((url_t *, const char *)); | ||
64 | extern int url_mbox_create __P ((url_t *, const char *)); | ||
65 | extern int url_smtp_create __P ((url_t *, const char *)); | ||
66 | |||
67 | #ifdef __cplusplus | ||
68 | } | ||
69 | #endif | ||
70 | |||
71 | #endif /* _MAILUTILS_URL_H */ |
mailbox2/locker.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 | #ifdef HAVE_CONFIG_H | ||
19 | # include <config.h> | ||
20 | #endif | ||
21 | |||
22 | #include <stdlib.h> | ||
23 | #include <mailutils/error.h> | ||
24 | #include <mailutils/sys/locker.h> | ||
25 | |||
26 | int | ||
27 | (locker_add_ref) (locker_t locker) | ||
28 | { | ||
29 | if (locker == NULL || locker->vtable == NULL | ||
30 | || locker->vtable->add_ref == NULL) | ||
31 | return MU_ERROR_NOT_SUPPORTED; | ||
32 | return locker->vtable->add_ref (locker); | ||
33 | } | ||
34 | |||
35 | int | ||
36 | (locker_release) (locker_t locker) | ||
37 | { | ||
38 | if (locker == NULL || locker->vtable == NULL | ||
39 | || locker->vtable->release == NULL) | ||
40 | return MU_ERROR_NOT_SUPPORTED; | ||
41 | return locker->vtable->release (locker); | ||
42 | } | ||
43 | |||
44 | int | ||
45 | (locker_destroy) (locker_t locker) | ||
46 | { | ||
47 | if (locker == NULL || locker->vtable == NULL | ||
48 | || locker->vtable->destroy == NULL) | ||
49 | return MU_ERROR_NOT_SUPPORTED; | ||
50 | return locker->vtable->destroy (locker); | ||
51 | } | ||
52 | |||
53 | int | ||
54 | (locker_lock) (locker_t locker) | ||
55 | { | ||
56 | if (locker == NULL || locker->vtable == NULL | ||
57 | || locker->vtable->lock == NULL) | ||
58 | return MU_ERROR_NOT_SUPPORTED; | ||
59 | return locker->vtable->lock (locker); | ||
60 | } | ||
61 | |||
62 | int | ||
63 | (locker_touchlock) (locker_t locker) | ||
64 | { | ||
65 | if (locker == NULL || locker->vtable == NULL | ||
66 | || locker->vtable->lock == NULL) | ||
67 | return MU_ERROR_NOT_SUPPORTED; | ||
68 | return locker->vtable->lock (locker); | ||
69 | } | ||
70 | |||
71 | int | ||
72 | (locker_unlock) (locker_t locker) | ||
73 | { | ||
74 | if (locker == NULL || locker->vtable == NULL | ||
75 | || locker->vtable->lock == NULL) | ||
76 | return MU_ERROR_NOT_SUPPORTED; | ||
77 | return locker->vtable->lock (locker); | ||
78 | } |
mailbox2/mailbox.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 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 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 | #include <mailutils/error.h> | ||
19 | #include <mailutils/sys/mailbox.h> | ||
20 | |||
21 | int | ||
22 | mailbox_add_ref (mailbox_t mailbox) | ||
23 | { | ||
24 | if (mailbox == NULL || mailbox->vtable == NULL | ||
25 | || mailbox->vtable->add_ref == NULL) | ||
26 | return MU_ERROR_NOT_SUPPORTED; | ||
27 | return mailbox->vtable->add_ref (mailbox); | ||
28 | } | ||
29 | |||
30 | int | ||
31 | mailbox_release (mailbox_t mailbox) | ||
32 | { | ||
33 | if (mailbox == NULL || mailbox->vtable == NULL | ||
34 | || mailbox->vtable->release == NULL) | ||
35 | return MU_ERROR_NOT_SUPPORTED; | ||
36 | return mailbox->vtable->release (mailbox); | ||
37 | } | ||
38 | |||
39 | int | ||
40 | mailbox_destroy (mailbox_t mailbox) | ||
41 | { | ||
42 | if (mailbox == NULL || mailbox->vtable == NULL | ||
43 | || mailbox->vtable->destroy == NULL) | ||
44 | return MU_ERROR_NOT_SUPPORTED; | ||
45 | return mailbox->vtable->destroy (mailbox); | ||
46 | } | ||
47 | |||
48 | int | ||
49 | mailbox_get_folder (mailbox_t mailbox, folder_t *folder) | ||
50 | { | ||
51 | if (mailbox == NULL || mailbox->vtable == NULL | ||
52 | || mailbox->vtable->get_folder == NULL) | ||
53 | return MU_ERROR_NOT_SUPPORTED; | ||
54 | return mailbox->vtable->get_folder (mailbox, folder); | ||
55 | } | ||
56 | |||
57 | int | ||
58 | mailbox_open (mailbox_t mailbox, int flag) | ||
59 | { | ||
60 | if (mailbox == NULL || mailbox->vtable == NULL | ||
61 | || mailbox->vtable->open == NULL) | ||
62 | return MU_ERROR_NOT_SUPPORTED; | ||
63 | return mailbox->vtable->open (mailbox, flag); | ||
64 | } | ||
65 | |||
66 | int | ||
67 | mailbox_close (mailbox_t mailbox) | ||
68 | { | ||
69 | if (mailbox == NULL || mailbox->vtable == NULL | ||
70 | || mailbox->vtable->close == NULL) | ||
71 | return MU_ERROR_NOT_SUPPORTED; | ||
72 | return mailbox->vtable->close (mailbox); | ||
73 | } | ||
74 | |||
75 | int | ||
76 | mailbox_uidvalidity (mailbox_t mailbox, unsigned long *uidvalidity) | ||
77 | { | ||
78 | if (mailbox == NULL || mailbox->vtable == NULL | ||
79 | || mailbox->vtable->uidvalidity == NULL) | ||
80 | return MU_ERROR_NOT_SUPPORTED; | ||
81 | return mailbox->vtable->uidvalidity (mailbox, uidvalidity); | ||
82 | } | ||
83 | |||
84 | int | ||
85 | mailbox_uidnext (mailbox_t mailbox, size_t *uidnext) | ||
86 | { | ||
87 | if (mailbox == NULL || mailbox->vtable == NULL | ||
88 | || mailbox->vtable->uidnext == NULL) | ||
89 | return MU_ERROR_NOT_SUPPORTED; | ||
90 | return mailbox->vtable->uidnext (mailbox, uidnext); | ||
91 | } | ||
92 | |||
93 | /* Messages. */ | ||
94 | int | ||
95 | mailbox_get_message (mailbox_t mailbox, size_t msgno, message_t *msg) | ||
96 | { | ||
97 | if (mailbox == NULL || mailbox->vtable == NULL | ||
98 | || mailbox->vtable->get_message == NULL) | ||
99 | return MU_ERROR_NOT_SUPPORTED; | ||
100 | return mailbox->vtable->get_message (mailbox, msgno, msg); | ||
101 | } | ||
102 | |||
103 | int | ||
104 | mailbox_append_message (mailbox_t mailbox, message_t msg) | ||
105 | { | ||
106 | if (mailbox == NULL || mailbox->vtable == NULL | ||
107 | || mailbox->vtable->append_message == NULL) | ||
108 | return MU_ERROR_NOT_SUPPORTED; | ||
109 | return mailbox->vtable->append_message (mailbox, msg); | ||
110 | } | ||
111 | |||
112 | int | ||
113 | mailbox_messages_count (mailbox_t mailbox, size_t *count) | ||
114 | { | ||
115 | if (mailbox == NULL || mailbox->vtable == NULL | ||
116 | || mailbox->vtable->messages_count == NULL) | ||
117 | return MU_ERROR_NOT_SUPPORTED; | ||
118 | return mailbox->vtable->messages_count (mailbox, count); | ||
119 | } | ||
120 | |||
121 | int | ||
122 | mailbox_messages_recent (mailbox_t mailbox, size_t *recent) | ||
123 | { | ||
124 | if (mailbox == NULL || mailbox->vtable == NULL | ||
125 | || mailbox->vtable->messages_recent == NULL) | ||
126 | return MU_ERROR_NOT_SUPPORTED; | ||
127 | return mailbox->vtable->messages_recent (mailbox, recent); | ||
128 | } | ||
129 | |||
130 | int | ||
131 | mailbox_messages_unseen (mailbox_t mailbox, size_t *unseen) | ||
132 | { | ||
133 | if (mailbox == NULL || mailbox->vtable == NULL | ||
134 | || mailbox->vtable->messages_unseen == NULL) | ||
135 | return MU_ERROR_NOT_SUPPORTED; | ||
136 | return mailbox->vtable->messages_unseen (mailbox, unseen); | ||
137 | } | ||
138 | |||
139 | int | ||
140 | mailbox_expunge (mailbox_t mailbox) | ||
141 | { | ||
142 | if (mailbox == NULL || mailbox->vtable == NULL | ||
143 | || mailbox->vtable->expunge == NULL) | ||
144 | return MU_ERROR_NOT_SUPPORTED; | ||
145 | return mailbox->vtable->expunge (mailbox); | ||
146 | } | ||
147 | |||
148 | int | ||
149 | mailbox_save_attributes (mailbox_t mailbox) | ||
150 | { | ||
151 | if (mailbox == NULL || mailbox->vtable == NULL | ||
152 | || mailbox->vtable->save_attributes == NULL) | ||
153 | return MU_ERROR_NOT_SUPPORTED; | ||
154 | return mailbox->vtable->save_attributes (mailbox); | ||
155 | } | ||
156 | |||
157 | /* Update and scanning. */ | ||
158 | int | ||
159 | mailbox_get_size (mailbox_t mailbox, off_t *size) | ||
160 | { | ||
161 | if (mailbox == NULL || mailbox->vtable == NULL | ||
162 | || mailbox->vtable->get_size == NULL) | ||
163 | return MU_ERROR_NOT_SUPPORTED; | ||
164 | return mailbox->vtable->get_size (mailbox, size); | ||
165 | } | ||
166 | |||
167 | int | ||
168 | mailbox_is_updated (mailbox_t mailbox) | ||
169 | { | ||
170 | if (mailbox == NULL || mailbox->vtable == NULL | ||
171 | || mailbox->vtable->is_updated == NULL) | ||
172 | return MU_ERROR_NOT_SUPPORTED; | ||
173 | return mailbox->vtable->is_updated (mailbox); | ||
174 | } | ||
175 | |||
176 | int | ||
177 | mailbox_scan (mailbox_t mailbox, size_t no, size_t *count) | ||
178 | { | ||
179 | if (mailbox == NULL || mailbox->vtable == NULL | ||
180 | || mailbox->vtable->scan == NULL) | ||
181 | return MU_ERROR_NOT_SUPPORTED; | ||
182 | return mailbox->vtable->scan (mailbox, no, count); | ||
183 | } | ||
184 | |||
185 | |||
186 | /* Mailbox Stream. */ | ||
187 | int | ||
188 | mailbox_get_stream (mailbox_t mailbox, stream_t *stream) | ||
189 | { | ||
190 | if (mailbox == NULL || mailbox->vtable == NULL | ||
191 | || mailbox->vtable->get_stream == NULL) | ||
192 | return MU_ERROR_NOT_SUPPORTED; | ||
193 | return mailbox->vtable->get_stream (mailbox, stream); | ||
194 | } | ||
195 | |||
196 | |||
197 | /* Authentication. */ | ||
198 | int | ||
199 | mailbox_get_authority (mailbox_t mailbox, authority_t *authority) | ||
200 | { | ||
201 | if (mailbox == NULL || mailbox->vtable == NULL | ||
202 | || mailbox->vtable->get_authority == NULL) | ||
203 | return MU_ERROR_NOT_SUPPORTED; | ||
204 | return mailbox->vtable->get_authority (mailbox, authority); | ||
205 | } | ||
206 | |||
207 | int | ||
208 | mailbox_set_authority (mailbox_t mailbox, authority_t authority) | ||
209 | { | ||
210 | if (mailbox == NULL || mailbox->vtable == NULL | ||
211 | || mailbox->vtable->set_authority == NULL) | ||
212 | return MU_ERROR_NOT_SUPPORTED; | ||
213 | return mailbox->vtable->set_authority (mailbox, authority); | ||
214 | } | ||
215 | |||
216 | /* Property. */ | ||
217 | int | ||
218 | mailbox_get_property (mailbox_t mailbox, property_t *property) | ||
219 | { | ||
220 | if (mailbox == NULL || mailbox->vtable == NULL | ||
221 | || mailbox->vtable->get_property == NULL) | ||
222 | return MU_ERROR_NOT_SUPPORTED; | ||
223 | return mailbox->vtable->get_property (mailbox, property); | ||
224 | } | ||
225 | |||
226 | |||
227 | /* URL. */ | ||
228 | int | ||
229 | mailbox_get_url (mailbox_t mailbox, url_t *url) | ||
230 | { | ||
231 | if (mailbox == NULL || mailbox->vtable == NULL | ||
232 | || mailbox->vtable->get_url == NULL) | ||
233 | return MU_ERROR_NOT_SUPPORTED; | ||
234 | return mailbox->vtable->get_url (mailbox, url); | ||
235 | } | ||
236 | |||
237 | |||
238 | /* For any debuging */ | ||
239 | int | ||
240 | mailbox_get_debug (mailbox_t mailbox, mu_debug_t *debug) | ||
241 | { | ||
242 | if (mailbox == NULL || mailbox->vtable == NULL | ||
243 | || mailbox->vtable->get_debug == NULL) | ||
244 | return MU_ERROR_NOT_SUPPORTED; | ||
245 | return mailbox->vtable->get_debug (mailbox, debug); | ||
246 | } | ||
247 | |||
248 | int | ||
249 | mailbox_set_debug (mailbox_t mailbox, mu_debug_t debug) | ||
250 | { | ||
251 | if (mailbox == NULL || mailbox->vtable == NULL | ||
252 | || mailbox->vtable->set_debug == NULL) | ||
253 | return MU_ERROR_NOT_SUPPORTED; | ||
254 | return mailbox->vtable->set_debug (mailbox, debug); | ||
255 | } | ||
256 | |||
257 | |||
258 | /* Events. */ | ||
259 | int | ||
260 | mailbox_get_observable (mailbox_t mailbox, observable_t *observable) | ||
261 | { | ||
262 | if (mailbox == NULL || mailbox->vtable == NULL | ||
263 | || mailbox->vtable->get_observable == NULL) | ||
264 | return MU_ERROR_NOT_SUPPORTED; | ||
265 | return mailbox->vtable->get_observable (mailbox, observable); | ||
266 | } |
mailbox2/memstream.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 | #ifdef HAVE_CONFIG_H | ||
19 | # include <config.h> | ||
20 | #endif | ||
21 | |||
22 | #include <errno.h> | ||
23 | #include <stdlib.h> | ||
24 | #include <string.h> | ||
25 | |||
26 | #include <mailutils/error.h> | ||
27 | #include <mailutils/sys/memstream.h> | ||
28 | |||
29 | static int | ||
30 | _memory_add_ref (stream_t stream) | ||
31 | { | ||
32 | int status; | ||
33 | struct _memory_stream *mem = (struct _memory_stream *)stream; | ||
34 | monitor_lock (mem->lock); | ||
35 | status = ++mem->ref; | ||
36 | monitor_unlock (mem->lock); | ||
37 | return status; | ||
38 | } | ||
39 | |||
40 | static int | ||
41 | _memory_destroy (stream_t stream) | ||
42 | { | ||
43 | struct _memory_stream *mem = (struct _memory_stream *)stream; | ||
44 | if (mem && mem->ptr != NULL) | ||
45 | free (mem->ptr); | ||
46 | free (mem); | ||
47 | return 0; | ||
48 | } | ||
49 | |||
50 | static int | ||
51 | _memory_release (stream_t stream) | ||
52 | { | ||
53 | int status; | ||
54 | struct _memory_stream *mem = (struct _memory_stream *)stream; | ||
55 | monitor_lock (mem->lock); | ||
56 | status = --mem->ref; | ||
57 | if (status <= 0) | ||
58 | { | ||
59 | monitor_unlock (mem->lock); | ||
60 | _memory_destroy (stream); | ||
61 | return 0; | ||
62 | } | ||
63 | monitor_unlock (mem->lock); | ||
64 | return status; | ||
65 | } | ||
66 | |||
67 | static int | ||
68 | _memory_read (stream_t stream, void *optr, size_t osize, size_t *nbytes) | ||
69 | { | ||
70 | struct _memory_stream *mem = (struct _memory_stream *)stream; | ||
71 | size_t n = 0; | ||
72 | if (mem->ptr != NULL && (mem->offset < (off_t)mem->size)) | ||
73 | { | ||
74 | n = ((mem->offset + osize) > mem->size) ? | ||
75 | mem->size - mem->offset : osize; | ||
76 | memcpy (optr, mem->ptr + mem->offset, n); | ||
77 | mem->offset += n; | ||
78 | } | ||
79 | if (nbytes) | ||
80 | *nbytes = n; | ||
81 | return 0; | ||
82 | } | ||
83 | |||
84 | static int | ||
85 | _memory_readline (stream_t stream, char *optr, size_t osize, size_t *nbytes) | ||
86 | { | ||
87 | struct _memory_stream *mem = (struct _memory_stream *)stream; | ||
88 | char *nl; | ||
89 | size_t n = 0; | ||
90 | if (mem->ptr && (mem->offset < (off_t)mem->size)) | ||
91 | { | ||
92 | /* Save space for the null byte. */ | ||
93 | osize--; | ||
94 | nl = memchr (mem->ptr + mem->offset, '\n', mem->size - mem->offset); | ||
95 | n = (nl) ? nl - (mem->ptr + mem->offset) + 1 : mem->size - mem->offset; | ||
96 | n = (n > osize) ? osize : n; | ||
97 | memcpy (optr, mem->ptr + mem->offset, n); | ||
98 | optr[n] = '\0'; | ||
99 | mem->offset += n; | ||
100 | } | ||
101 | if (nbytes) | ||
102 | *nbytes = n; | ||
103 | return 0; | ||
104 | } | ||
105 | |||
106 | static int | ||
107 | _memory_write (stream_t stream, const void *iptr, size_t isize, size_t *nbytes) | ||
108 | { | ||
109 | struct _memory_stream *mem = (struct _memory_stream *)stream; | ||
110 | |||
111 | /* Bigger we have to realloc. */ | ||
112 | if (mem->size < (mem->offset + isize)) | ||
113 | { | ||
114 | char *tmp = realloc (mem->ptr, mem->offset + isize); | ||
115 | if (tmp == NULL) | ||
116 | return ENOMEM; | ||
117 | mem->ptr = tmp; | ||
118 | mem->size = mem->offset + isize; | ||
119 | } | ||
120 | |||
121 | memcpy (mem->ptr + mem->offset, iptr, isize); | ||
122 | mem->offset += isize; | ||
123 | if (nbytes) | ||
124 | *nbytes = isize; | ||
125 | return 0; | ||
126 | } | ||
127 | |||
128 | static int | ||
129 | _memory_truncate (stream_t stream, off_t len) | ||
130 | { | ||
131 | struct _memory_stream *mem = (struct _memory_stream *)stream; | ||
132 | |||
133 | if (len == 0) | ||
134 | { | ||
135 | free (mem->ptr); | ||
136 | mem->ptr = NULL; | ||
137 | } | ||
138 | else | ||
139 | { | ||
140 | char *tmp = realloc (mem, len); | ||
141 | if (tmp == NULL) | ||
142 | return ENOMEM; | ||
143 | mem->ptr = tmp; | ||
144 | } | ||
145 | mem->size = len; | ||
146 | mem->offset = len; | ||
147 | return 0; | ||
148 | } | ||
149 | |||
150 | static int | ||
151 | _memory_get_size (stream_t stream, off_t *psize) | ||
152 | { | ||
153 | struct _memory_stream *mem = (struct _memory_stream *)stream; | ||
154 | if (psize) | ||
155 | *psize = mem->size; | ||
156 | return 0; | ||
157 | } | ||
158 | |||
159 | static int | ||
160 | _memory_close (stream_t stream) | ||
161 | { | ||
162 | struct _memory_stream *mem = (struct _memory_stream *)stream; | ||
163 | if (mem->ptr) | ||
164 | free (mem->ptr); | ||
165 | mem->ptr = NULL; | ||
166 | mem->size = 0; | ||
167 | mem->offset = 0; | ||
168 | return 0; | ||
169 | } | ||
170 | |||
171 | static int | ||
172 | _memory_flush (stream_t stream) | ||
173 | { | ||
174 | (void)stream; | ||
175 | return 0; | ||
176 | } | ||
177 | |||
178 | static int | ||
179 | _memory_get_fd (stream_t stream, int *pfd) | ||
180 | { | ||
181 | (void)stream; (void)pfd; | ||
182 | return MU_ERROR_NOT_SUPPORTED; | ||
183 | } | ||
184 | |||
185 | static int | ||
186 | _memory_get_flags (stream_t stream, int *flags) | ||
187 | { | ||
188 | struct _memory_stream *mem = (struct _memory_stream *)stream; | ||
189 | if (flags == NULL) | ||
190 | return MU_ERROR_INVALID_PARAMETER; | ||
191 | *flags = mem->flags; | ||
192 | return 0; | ||
193 | } | ||
194 | |||
195 | static int | ||
196 | _memory_get_state (stream_t stream, enum stream_state *state) | ||
197 | { | ||
198 | (void)stream; | ||
199 | if (state == NULL) | ||
200 | return MU_ERROR_INVALID_PARAMETER; | ||
201 | *state = MU_STREAM_NO_STATE; | ||
202 | return 0; | ||
203 | } | ||
204 | |||
205 | static int | ||
206 | _memory_seek (stream_t stream, off_t off, enum stream_whence whence) | ||
207 | { | ||
208 | struct _memory_stream *mem = (struct _memory_stream *)stream; | ||
209 | off_t noff = mem->offset; | ||
210 | int err = 0; | ||
211 | if (whence == MU_STREAM_WHENCE_SET) | ||
212 | noff = off; | ||
213 | else if (whence == MU_STREAM_WHENCE_CUR) | ||
214 | noff += off; | ||
215 | else if (whence == MU_STREAM_WHENCE_END) | ||
216 | noff = mem->size + off; | ||
217 | else | ||
218 | noff = -1; /* error. */ | ||
219 | if (noff >= 0) | ||
220 | { | ||
221 | if (noff > mem->offset) | ||
222 | _memory_truncate (stream, noff); | ||
223 | mem->offset = noff; | ||
224 | } | ||
225 | else | ||
226 | err = MU_ERROR_INVALID_PARAMETER; | ||
227 | return err; | ||
228 | } | ||
229 | |||
230 | static int | ||
231 | _memory_tell (stream_t stream, off_t *off) | ||
232 | { | ||
233 | struct _memory_stream *mem = (struct _memory_stream *)stream; | ||
234 | if (off == NULL) | ||
235 | return MU_ERROR_INVALID_PARAMETER; | ||
236 | *off = mem->offset; | ||
237 | return 0; | ||
238 | } | ||
239 | |||
240 | static int | ||
241 | _memory_open (stream_t stream, const char *filename, int port, int flags) | ||
242 | { | ||
243 | struct _memory_stream *mem = (struct _memory_stream *)stream; | ||
244 | |||
245 | (void)port; /* Ignored. */ | ||
246 | (void)filename; /* Ignored. */ | ||
247 | (void)flags; /* Ignored. */ | ||
248 | |||
249 | /* Close any previous file. */ | ||
250 | if (mem->ptr) | ||
251 | free (mem->ptr); | ||
252 | mem->ptr = NULL; | ||
253 | mem->size = 0; | ||
254 | mem->offset = 0; | ||
255 | mem->flags = flags; | ||
256 | return 0; | ||
257 | } | ||
258 | |||
259 | static struct _stream_vtable _mem_vtable = | ||
260 | { | ||
261 | _memory_add_ref, | ||
262 | _memory_release, | ||
263 | _memory_destroy, | ||
264 | |||
265 | _memory_open, | ||
266 | _memory_close, | ||
267 | |||
268 | _memory_read, | ||
269 | _memory_readline, | ||
270 | _memory_write, | ||
271 | |||
272 | _memory_seek, | ||
273 | _memory_tell, | ||
274 | |||
275 | _memory_get_size, | ||
276 | _memory_truncate, | ||
277 | _memory_flush, | ||
278 | |||
279 | _memory_get_fd, | ||
280 | _memory_get_flags, | ||
281 | _memory_get_state | ||
282 | }; | ||
283 | |||
284 | int | ||
285 | stream_memory_create (stream_t *pstream) | ||
286 | { | ||
287 | struct _memory_stream *mem; | ||
288 | |||
289 | if (pstream == NULL) | ||
290 | return MU_ERROR_INVALID_PARAMETER; | ||
291 | |||
292 | mem = calloc (1, sizeof (*mem)); | ||
293 | if (mem == NULL) | ||
294 | return MU_ERROR_NO_MEMORY; | ||
295 | |||
296 | mem->base.vtable = &_mem_vtable; | ||
297 | mem->ref = 1; | ||
298 | mem->ptr = NULL; | ||
299 | mem->size = 0; | ||
300 | mem->offset = 0; | ||
301 | mem->flags = 0; | ||
302 | monitor_create (&(mem->lock)); | ||
303 | *pstream = &mem->base; | ||
304 | |||
305 | return 0; | ||
306 | } |
mailbox2/message.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 | #ifdef HAVE_CONFIG_H | ||
19 | # include <config.h> | ||
20 | #endif | ||
21 | |||
22 | #include <stdlib.h> | ||
23 | #include <mailutils/error.h> | ||
24 | #include <mailutils/sys/message.h> | ||
25 | |||
26 | int | ||
27 | message_add_ref (message_t msg) | ||
28 | { | ||
29 | if (msg == NULL || msg->vtable == NULL | ||
30 | || msg->vtable->add_ref == NULL) | ||
31 | return MU_ERROR_NOT_SUPPORTED; | ||
32 | return msg->vtable->add_ref (msg); | ||
33 | } | ||
34 | |||
35 | int | ||
36 | message_release (message_t msg) | ||
37 | { | ||
38 | if (msg == NULL || msg->vtable == NULL | ||
39 | || msg->vtable->release == NULL) | ||
40 | return MU_ERROR_NOT_SUPPORTED; | ||
41 | return msg->vtable->release (msg); | ||
42 | } | ||
43 | |||
44 | int | ||
45 | message_destroy (message_t msg) | ||
46 | { | ||
47 | if (msg == NULL || msg->vtable == NULL | ||
48 | || msg->vtable->destroy == NULL) | ||
49 | return MU_ERROR_NOT_SUPPORTED; | ||
50 | return msg->vtable->destroy (msg); | ||
51 | } | ||
52 | |||
53 | int | ||
54 | message_is_modified (message_t msg) | ||
55 | { | ||
56 | if (msg == NULL || msg->vtable == NULL | ||
57 | || msg->vtable->is_modified == NULL) | ||
58 | return MU_ERROR_NOT_SUPPORTED; | ||
59 | return msg->vtable->is_modified (msg); | ||
60 | } | ||
61 | |||
62 | int | ||
63 | message_clear_modified (message_t msg) | ||
64 | { | ||
65 | if (msg == NULL || msg->vtable == NULL | ||
66 | || msg->vtable->clear_modified == NULL) | ||
67 | return MU_ERROR_NOT_SUPPORTED; | ||
68 | return msg->vtable->clear_modified (msg); | ||
69 | } | ||
70 | |||
71 | int | ||
72 | message_get_mailbox (message_t msg, mailbox_t *mbox) | ||
73 | { | ||
74 | if (msg == NULL || msg->vtable == NULL | ||
75 | || msg->vtable->get_mailbox == NULL) | ||
76 | return MU_ERROR_NOT_SUPPORTED; | ||
77 | return msg->vtable->get_mailbox (msg, mbox); | ||
78 | } | ||
79 | |||
80 | int | ||
81 | message_get_envelope (message_t msg, envelope_t *envelope) | ||
82 | { | ||
83 | if (msg == NULL || msg->vtable == NULL | ||
84 | || msg->vtable->get_envelope == NULL) | ||
85 | return MU_ERROR_NOT_SUPPORTED; | ||
86 | return msg->vtable->get_envelope (msg, envelope); | ||
87 | } | ||
88 | |||
89 | int | ||
90 | message_get_header (message_t msg, header_t *header) | ||
91 | { | ||
92 | if (msg == NULL || msg->vtable == NULL | ||
93 | || msg->vtable->get_header == NULL) | ||
94 | return MU_ERROR_NOT_SUPPORTED; | ||
95 | return msg->vtable->get_header (msg, header); | ||
96 | } | ||
97 | |||
98 | int | ||
99 | message_get_body (message_t msg, body_t *body) | ||
100 | { | ||
101 | if (msg == NULL || msg->vtable == NULL | ||
102 | || msg->vtable->get_body == NULL) | ||
103 | return MU_ERROR_NOT_SUPPORTED; | ||
104 | return msg->vtable->get_body (msg, body); | ||
105 | } | ||
106 | |||
107 | int | ||
108 | message_get_attribute (message_t msg, attribute_t *attribute) | ||
109 | { | ||
110 | if (msg == NULL || msg->vtable == NULL | ||
111 | || msg->vtable->get_attribute == NULL) | ||
112 | return MU_ERROR_NOT_SUPPORTED; | ||
113 | return msg->vtable->get_attribute (msg, attribute); | ||
114 | } | ||
115 | |||
116 | int | ||
117 | message_get_stream (message_t msg, stream_t *stream) | ||
118 | { | ||
119 | if (msg == NULL || msg->vtable == NULL | ||
120 | || msg->vtable->get_stream == NULL) | ||
121 | return MU_ERROR_NOT_SUPPORTED; | ||
122 | return msg->vtable->get_stream (msg, stream); | ||
123 | } | ||
124 | |||
125 | int | ||
126 | message_get_property (message_t msg, property_t *property) | ||
127 | { | ||
128 | if (msg == NULL || msg->vtable == NULL | ||
129 | || msg->vtable->get_property == NULL) | ||
130 | return MU_ERROR_NOT_SUPPORTED; | ||
131 | return msg->vtable->get_property (msg, property); | ||
132 | } | ||
133 | |||
134 | int | ||
135 | message_is_multipart (message_t msg, int *ismulti) | ||
136 | { | ||
137 | if (msg == NULL || msg->vtable == NULL | ||
138 | || msg->vtable->is_multipart == NULL) | ||
139 | return MU_ERROR_NOT_SUPPORTED; | ||
140 | return msg->vtable->is_multipart (msg, ismulti); | ||
141 | } | ||
142 | |||
143 | int | ||
144 | message_get_size (message_t msg, size_t *size) | ||
145 | { | ||
146 | if (msg == NULL || msg->vtable == NULL | ||
147 | || msg->vtable->get_size == NULL) | ||
148 | return MU_ERROR_NOT_SUPPORTED; | ||
149 | return msg->vtable->get_size (msg, size); | ||
150 | } | ||
151 | |||
152 | int | ||
153 | message_get_lines (message_t msg, size_t *lines) | ||
154 | { | ||
155 | if (msg == NULL || msg->vtable == NULL | ||
156 | || msg->vtable->get_lines == NULL) | ||
157 | return MU_ERROR_NOT_SUPPORTED; | ||
158 | return msg->vtable->get_lines (msg, lines); | ||
159 | } | ||
160 | |||
161 | int | ||
162 | message_get_num_parts (message_t msg, size_t *nparts) | ||
163 | { | ||
164 | if (msg == NULL || msg->vtable == NULL | ||
165 | || msg->vtable->get_num_parts == NULL) | ||
166 | return MU_ERROR_NOT_SUPPORTED; | ||
167 | return msg->vtable->get_num_parts (msg, nparts); | ||
168 | } | ||
169 | |||
170 | int | ||
171 | message_get_part (message_t msg, size_t partno, message_t *submsg) | ||
172 | { | ||
173 | if (msg == NULL || msg->vtable == NULL | ||
174 | || msg->vtable->get_part == NULL) | ||
175 | return MU_ERROR_NOT_SUPPORTED; | ||
176 | return msg->vtable->get_part (msg, partno, submsg); | ||
177 | } | ||
178 | |||
179 | int | ||
180 | message_get_uidl (message_t msg, char *uidl, size_t len, size_t *plen) | ||
181 | { | ||
182 | if (msg == NULL || msg->vtable == NULL | ||
183 | || msg->vtable->get_uidl == NULL) | ||
184 | return MU_ERROR_NOT_SUPPORTED; | ||
185 | return msg->vtable->get_uidl (msg, uidl, len, plen); | ||
186 | } | ||
187 | |||
188 | int | ||
189 | message_get_uid (message_t msg, size_t *uid) | ||
190 | { | ||
191 | if (msg == NULL || msg->vtable == NULL | ||
192 | || msg->vtable->get_uid == NULL) | ||
193 | return MU_ERROR_NOT_SUPPORTED; | ||
194 | return msg->vtable->get_uid (msg, uid); | ||
195 | } |
... | @@ -471,6 +471,7 @@ stream_mapfile_create (stream_t *pstream) | ... | @@ -471,6 +471,7 @@ stream_mapfile_create (stream_t *pstream) |
471 | ms->offset = -1; | 471 | ms->offset = -1; |
472 | ms->flags = 0; | 472 | ms->flags = 0; |
473 | ms->mflags = 0; | 473 | ms->mflags = 0; |
474 | monitor_create (&(ms->lock)); | ||
474 | *pstream = &ms->base; | 475 | *pstream = &ms->base; |
475 | 476 | ||
476 | return 0; | 477 | return 0; | ... | ... |
mailbox2/mutil.c
0 → 100644
1 | /* Copyright (C) 2001 Free Software Foundation, Inc. | ||
2 | A wrapper for mktime function allowing to specify the timezone. | ||
3 | |||
4 | The GNU C Library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Library General Public License as | ||
6 | published by the Free Software Foundation; either version 2 of the | ||
7 | License, or (at your option) any later version. | ||
8 | |||
9 | The GNU C Library 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 GNU | ||
12 | Library General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Library General Public | ||
15 | License along with the GNU C Library; see the file COPYING.LIB. If not, | ||
16 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
17 | Boston, MA 02111-1307, USA. */ | ||
18 | |||
19 | #if HAVE_CONFIG_H | ||
20 | # include <config.h> | ||
21 | #endif | ||
22 | |||
23 | #include <stdio.h> | ||
24 | #include <stdlib.h> | ||
25 | #ifdef HAVE_STRINGS_H | ||
26 | #include <strings.h> | ||
27 | #endif | ||
28 | #include <string.h> | ||
29 | #include <time.h> | ||
30 | #include <pwd.h> | ||
31 | #include <unistd.h> | ||
32 | |||
33 | #include <mailutils/mutil.h> | ||
34 | |||
35 | /* convert a sequence of hex characters into an integer */ | ||
36 | |||
37 | unsigned long mu_hex2ul(char hex) | ||
38 | { | ||
39 | if (hex >= '0' && hex <= '9') | ||
40 | return hex - '0'; | ||
41 | |||
42 | if (hex >= 'a' && hex <= 'z') | ||
43 | return hex - 'a'; | ||
44 | |||
45 | if (hex >= 'A' && hex <= 'Z') | ||
46 | return hex - 'A'; | ||
47 | |||
48 | return -1; | ||
49 | } | ||
50 | |||
51 | size_t mu_hexstr2ul(unsigned long* ul, const char* hex, size_t len) | ||
52 | { | ||
53 | size_t r; | ||
54 | |||
55 | *ul = 0; | ||
56 | |||
57 | for (r = 0; r < len; r++) | ||
58 | { | ||
59 | unsigned long v = mu_hex2ul(hex[r]); | ||
60 | |||
61 | if (v == (unsigned long)-1) | ||
62 | return r; | ||
63 | |||
64 | *ul = *ul * 16 + v; | ||
65 | } | ||
66 | return r; | ||
67 | } | ||
68 | |||
69 | /* Convert struct tm into time_t, taking into account timezone offset. | ||
70 | |||
71 | mktime() always treats tm as if it was localtime, so convert it | ||
72 | to UTC, then adjust by the tm's real timezone, if it is known. | ||
73 | |||
74 | NOTE: 1. mktime converts localtime struct tm to *time_t in UTC* | ||
75 | 2. adding mu_utc_offset() compensates for the localtime | ||
76 | corrections in mktime(), i.e. it yields the time_t in | ||
77 | the current zone of struct tm. | ||
78 | 3. finally, subtracting TZ offset yields the UTC. | ||
79 | */ | ||
80 | time_t | ||
81 | mu_tm2time (struct tm *timeptr, mu_timezone* tz) | ||
82 | { | ||
83 | int offset = tz ? tz->utc_offset : 0; | ||
84 | |||
85 | return mktime(timeptr) + mu_utc_offset() - offset; | ||
86 | } | ||
87 | |||
88 | /* Convert time 0 at UTC to our localtime, that tells us the offset | ||
89 | of our current timezone from UTC. */ | ||
90 | time_t | ||
91 | mu_utc_offset(void) | ||
92 | { | ||
93 | time_t t = 0; | ||
94 | struct tm* tm = gmtime(&t); | ||
95 | |||
96 | return - mktime(tm); | ||
97 | } | ||
98 | |||
99 | static const char *months[] = | ||
100 | { | ||
101 | "Jan", "Feb", "Mar", "Apr", "May", "Jun", | ||
102 | "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", NULL | ||
103 | }; | ||
104 | |||
105 | static const char *wdays[] = | ||
106 | { | ||
107 | "Mon", "Teu", "Wed", "Thr", "Fri", "Sat", "Sun", NULL | ||
108 | }; | ||
109 | |||
110 | int | ||
111 | mu_parse_imap_date_time (const char **p, struct tm *tm, mu_timezone *tz) | ||
112 | { | ||
113 | int year, mon, day, hour, min, sec; | ||
114 | char zone[6] = "+0000"; /* ( "+" / "-" ) hhmm */ | ||
115 | char month[5] = ""; | ||
116 | int hh = 0; | ||
117 | int mm = 0; | ||
118 | int sign = 1; | ||
119 | int scanned = 0, scanned3; | ||
120 | int i; | ||
121 | int tzoffset; | ||
122 | |||
123 | day = mon = year = hour = min = sec = 0; | ||
124 | |||
125 | memset (tm, 0, sizeof (*tm)); | ||
126 | |||
127 | switch (sscanf (*p, | ||
128 | "%2d-%3s-%4d%n %2d:%2d:%2d %5s%n", | ||
129 | &day, month, &year, &scanned3, &hour, &min, &sec, zone, | ||
130 | &scanned)) | ||
131 | { | ||
132 | case 3: | ||
133 | scanned = scanned3; | ||
134 | break; | ||
135 | case 7: | ||
136 | break; | ||
137 | default: | ||
138 | return -1; | ||
139 | } | ||
140 | |||
141 | tm->tm_sec = sec; | ||
142 | tm->tm_min = min; | ||
143 | tm->tm_hour = hour; | ||
144 | tm->tm_mday = day; | ||
145 | |||
146 | for (i = 0; i < 12; i++) | ||
147 | { | ||
148 | if (strncasecmp (month, months[i], 3) == 0) | ||
149 | { | ||
150 | mon = i; | ||
151 | break; | ||
152 | } | ||
153 | } | ||
154 | tm->tm_mon = mon; | ||
155 | tm->tm_year = (year > 1900) ? year - 1900 : year; | ||
156 | tm->tm_yday = 0; /* unknown. */ | ||
157 | tm->tm_wday = 0; /* unknown. */ | ||
158 | #if HAVE_TM_ISDST | ||
159 | tm->tm_isdst = -1; /* unknown. */ | ||
160 | #endif | ||
161 | |||
162 | hh = (zone[1] - '0') * 10 + (zone[2] - '0'); | ||
163 | mm = (zone[3] - '0') * 10 + (zone[4] - '0'); | ||
164 | sign = (zone[0] == '-') ? -1 : +1; | ||
165 | tzoffset = sign * (hh * 60 * 60 + mm * 60); | ||
166 | |||
167 | #if HAVE_TM_GMTOFFSET | ||
168 | tm->tm_gmtoffset = tzoffset; | ||
169 | #endif | ||
170 | |||
171 | if (tz) | ||
172 | { | ||
173 | tz->utc_offset = tzoffset; | ||
174 | tz->tz_name = NULL; | ||
175 | } | ||
176 | |||
177 | *p += scanned; | ||
178 | |||
179 | return 0; | ||
180 | } | ||
181 | |||
182 | /* "ctime" format is: Thu Jul 01 15:58:27 1999, with no trailing \n. */ | ||
183 | int | ||
184 | mu_parse_ctime_date_time (const char **p, struct tm *tm, mu_timezone * tz) | ||
185 | { | ||
186 | int wday = 0; | ||
187 | int year = 0; | ||
188 | int mon = 0; | ||
189 | int day = 0; | ||
190 | int hour = 0; | ||
191 | int min = 0; | ||
192 | int sec = 0; | ||
193 | int n = 0; | ||
194 | int i; | ||
195 | char weekday[5] = ""; | ||
196 | char month[5] = ""; | ||
197 | |||
198 | if (sscanf (*p, "%3s %3s %2d %2d:%2d:%2d %d%n\n", | ||
199 | weekday, month, &day, &hour, &min, &sec, &year, &n) != 7) | ||
200 | return -1; | ||
201 | |||
202 | *p += n; | ||
203 | |||
204 | for (i = 0; i < 7; i++) | ||
205 | { | ||
206 | if (strncasecmp (weekday, wdays[i], 3) == 0) | ||
207 | { | ||
208 | wday = i; | ||
209 | break; | ||
210 | } | ||
211 | } | ||
212 | |||
213 | for (i = 0; i < 12; i++) | ||
214 | { | ||
215 | if (strncasecmp (month, months[i], 3) == 0) | ||
216 | { | ||
217 | mon = i; | ||
218 | break; | ||
219 | } | ||
220 | } | ||
221 | |||
222 | if (tm) | ||
223 | { | ||
224 | memset (tm, 0, sizeof (struct tm)); | ||
225 | |||
226 | tm->tm_sec = sec; | ||
227 | tm->tm_min = min; | ||
228 | tm->tm_hour = hour; | ||
229 | tm->tm_mday = day; | ||
230 | tm->tm_wday = wday; | ||
231 | tm->tm_mon = mon; | ||
232 | tm->tm_year = (year > 1900) ? year - 1900 : year; | ||
233 | #ifdef HAVE_TM_ISDST | ||
234 | tm->tm_isdst = -1; /* unknown. */ | ||
235 | #endif | ||
236 | } | ||
237 | |||
238 | /* ctime has no timezone information, set tz to UTC if they ask. */ | ||
239 | if (tz) | ||
240 | memset (tz, 0, sizeof (struct mu_timezone)); | ||
241 | |||
242 | return 0; | ||
243 | } | ||
244 | |||
245 | |||
246 | char * | ||
247 | mu_get_homedir (void) | ||
248 | { | ||
249 | char *homedir = getenv ("HOME"); | ||
250 | if (!homedir) | ||
251 | { | ||
252 | struct passwd *pwd; | ||
253 | |||
254 | pwd = getpwuid(getuid()); | ||
255 | if (!pwd) | ||
256 | return NULL; | ||
257 | homedir = pwd->pw_dir; | ||
258 | } | ||
259 | return homedir; | ||
260 | } | ||
261 | |||
262 | /* NOTE: Allocates Memory. */ | ||
263 | /* Expand: ~ --> /home/user and to ~guest --> /home/guest. */ | ||
264 | char * | ||
265 | mu_tilde_expansion (const char *ref, const char *delim, const char *homedir) | ||
266 | { | ||
267 | char *p = strdup (ref); | ||
268 | |||
269 | if (*p == '~') | ||
270 | { | ||
271 | p++; | ||
272 | if (*p == delim[0] || *p == '\0') | ||
273 | { | ||
274 | char *s; | ||
275 | if (!homedir) | ||
276 | { | ||
277 | homedir = mu_get_homedir (); | ||
278 | if (!homedir) | ||
279 | return NULL; | ||
280 | } | ||
281 | s = calloc (strlen (homedir) + strlen (p) + 1, 1); | ||
282 | strcpy (s, homedir); | ||
283 | strcat (s, p); | ||
284 | free (--p); | ||
285 | p = s; | ||
286 | } | ||
287 | else | ||
288 | { | ||
289 | struct passwd *pw; | ||
290 | char *s = p; | ||
291 | char *name; | ||
292 | while (*s && *s != delim[0]) | ||
293 | s++; | ||
294 | name = calloc (s - p + 1, 1); | ||
295 | memcpy (name, p, s - p); | ||
296 | name [s - p] = '\0'; | ||
297 | pw = getpwnam (name); | ||
298 | free (name); | ||
299 | if (pw) | ||
300 | { | ||
301 | char *buf = calloc (strlen (pw->pw_dir) + strlen (s) + 1, 1); | ||
302 | strcpy (buf, pw->pw_dir); | ||
303 | strcat (buf, s); | ||
304 | free (--p); | ||
305 | p = buf; | ||
306 | } | ||
307 | else | ||
308 | p--; | ||
309 | } | ||
310 | } | ||
311 | return p; | ||
312 | } | ||
313 | |||
314 | /* Smart strncpy that always add the null and returns the number of bytes | ||
315 | written. */ | ||
316 | size_t | ||
317 | util_cpystr (char *dst, const char *src, size_t size) | ||
318 | { | ||
319 | size_t len = src ? strlen (src) : 0 ; | ||
320 | if (dst == NULL || size == 0) | ||
321 | return len; | ||
322 | if (len >= size) | ||
323 | len = size - 1; | ||
324 | memcpy (dst, src, len); | ||
325 | dst[len] = '\0'; | ||
326 | return len; | ||
327 | } |
... | @@ -23,7 +23,7 @@ | ... | @@ -23,7 +23,7 @@ |
23 | #include <stdlib.h> | 23 | #include <stdlib.h> |
24 | #include <mailutils/iterator.h> | 24 | #include <mailutils/iterator.h> |
25 | #include <mailutils/error.h> | 25 | #include <mailutils/error.h> |
26 | #include <mailutils/sys/observer.h> | 26 | #include <mailutils/sys/observable.h> |
27 | 27 | ||
28 | struct observer_info | 28 | struct observer_info |
29 | { | 29 | { | ... | ... |
mailbox2/pticket.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 | #ifdef HAVE_CONFIG_H | ||
18 | # include <config.h> | ||
19 | #endif | ||
20 | |||
21 | #include <errno.h> | ||
22 | #include <sys/types.h> | ||
23 | #include <string.h> | ||
24 | #include <stdlib.h> | ||
25 | #include <stdio.h> | ||
26 | #include <termios.h> | ||
27 | |||
28 | #include <mailutils/error.h> | ||
29 | #include <mailutils/monitor.h> | ||
30 | #include <mailutils/sys/ticket.h> | ||
31 | |||
32 | struct _prompt_ticket | ||
33 | { | ||
34 | struct _ticket base; | ||
35 | int ref; | ||
36 | monitor_t lock; | ||
37 | }; | ||
38 | |||
39 | static void | ||
40 | echo_off(struct termios *stored_settings) | ||
41 | { | ||
42 | struct termios new_settings; | ||
43 | tcgetattr (0, stored_settings); | ||
44 | new_settings = *stored_settings; | ||
45 | new_settings.c_lflag &= (~ECHO); | ||
46 | tcsetattr (0, TCSANOW, &new_settings); | ||
47 | } | ||
48 | |||
49 | static void | ||
50 | echo_on(struct termios *stored_settings) | ||
51 | { | ||
52 | tcsetattr (0, TCSANOW, stored_settings); | ||
53 | } | ||
54 | |||
55 | static int | ||
56 | _prompt_add_ref (ticket_t ticket) | ||
57 | { | ||
58 | int status; | ||
59 | struct _prompt_ticket *prompt = (struct _prompt_ticket *)ticket; | ||
60 | monitor_lock (prompt->lock); | ||
61 | status = ++prompt->ref; | ||
62 | monitor_unlock (prompt->lock); | ||
63 | return status; | ||
64 | } | ||
65 | |||
66 | static int | ||
67 | _prompt_destroy (ticket_t ticket) | ||
68 | { | ||
69 | struct _prompt_ticket *prompt = (struct _prompt_ticket *)ticket; | ||
70 | monitor_destroy (prompt->lock); | ||
71 | free (prompt); | ||
72 | return 0; | ||
73 | } | ||
74 | |||
75 | static int | ||
76 | _prompt_release (ticket_t ticket) | ||
77 | { | ||
78 | int status; | ||
79 | struct _prompt_ticket *prompt = (struct _prompt_ticket *)ticket; | ||
80 | monitor_lock (prompt->lock); | ||
81 | status = --prompt->ref; | ||
82 | if (status <= 0) | ||
83 | { | ||
84 | monitor_unlock (prompt->lock); | ||
85 | _prompt_destroy (ticket); | ||
86 | return 0; | ||
87 | } | ||
88 | monitor_unlock (prompt->lock); | ||
89 | return status; | ||
90 | } | ||
91 | |||
92 | static int | ||
93 | _prompt_pop (ticket_t ticket, const char *challenge, char **parg) | ||
94 | { | ||
95 | char arg[256]; | ||
96 | struct termios stored_settings; | ||
97 | int echo = 1; | ||
98 | (void)ticket; | ||
99 | |||
100 | /* Being smart if we see "Passwd" and turning off echo. */ | ||
101 | if (strstr (challenge, "ass") != NULL | ||
102 | || strstr (challenge, "ASS") != NULL) | ||
103 | echo = 0; | ||
104 | fprintf (stdout, "%s", challenge); | ||
105 | fflush (stdout); | ||
106 | if (!echo) | ||
107 | echo_off (&stored_settings); | ||
108 | fgets (arg, sizeof (arg), stdin); | ||
109 | if (!echo) | ||
110 | { | ||
111 | echo_on (&stored_settings); | ||
112 | fputc ('\n', stdout); | ||
113 | fflush (stdout); | ||
114 | } | ||
115 | arg [strlen (arg) - 1] = '\0'; /* nuke the trailing line. */ | ||
116 | *parg = strdup (arg); | ||
117 | return 0; | ||
118 | } | ||
119 | |||
120 | static struct _ticket_vtable _prompt_vtable = | ||
121 | { | ||
122 | _prompt_add_ref, | ||
123 | _prompt_release, | ||
124 | _prompt_destroy, | ||
125 | |||
126 | _prompt_pop, | ||
127 | }; | ||
128 | |||
129 | int | ||
130 | ticket_prompt_create (ticket_t *pticket) | ||
131 | { | ||
132 | struct _prompt_ticket *prompt; | ||
133 | |||
134 | if (pticket == NULL) | ||
135 | return MU_ERROR_INVALID_PARAMETER; | ||
136 | |||
137 | prompt = calloc (1, sizeof *prompt); | ||
138 | if (prompt == NULL) | ||
139 | return MU_ERROR_NO_MEMORY; | ||
140 | |||
141 | prompt->base.vtable = &_prompt_vtable; | ||
142 | prompt->ref = 1; | ||
143 | monitor_create (&(prompt->lock)); | ||
144 | *pticket = &prompt->base; | ||
145 | return 0; | ||
146 | } | ||
147 |
... | @@ -376,7 +376,7 @@ static struct _stream_vtable _tcp_vtable = | ... | @@ -376,7 +376,7 @@ static struct _stream_vtable _tcp_vtable = |
376 | 376 | ||
377 | _tcp_get_fd, | 377 | _tcp_get_fd, |
378 | _tcp_get_flags, | 378 | _tcp_get_flags, |
379 | _tcp_get_state, | 379 | _tcp_get_state |
380 | }; | 380 | }; |
381 | 381 | ||
382 | int | 382 | int |
... | @@ -397,6 +397,7 @@ stream_tcp_create (stream_t *pstream) | ... | @@ -397,6 +397,7 @@ stream_tcp_create (stream_t *pstream) |
397 | tcp->host = NULL; | 397 | tcp->host = NULL; |
398 | tcp->port = -1; | 398 | tcp->port = -1; |
399 | tcp->state = TCP_STATE_INIT; | 399 | tcp->state = TCP_STATE_INIT; |
400 | monitor_create (&(tcp->lock)); | ||
400 | *pstream = &tcp->base; | 401 | *pstream = &tcp->base; |
401 | return 0; | 402 | return 0; |
402 | } | 403 | } | ... | ... |
mailbox2/ticket.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 | #ifdef HAVE_CONFIG_H | ||
18 | # include <config.h> | ||
19 | #endif | ||
20 | |||
21 | #include <stdlib.h> | ||
22 | |||
23 | #include <mailutils/error.h> | ||
24 | #include <mailutils/sys/ticket.h> | ||
25 | |||
26 | int | ||
27 | ticket_add_ref (ticket_t ticket) | ||
28 | { | ||
29 | if (ticket == NULL || ticket->vtable == NULL | ||
30 | || ticket->vtable->add_ref == NULL) | ||
31 | return MU_ERROR_NOT_SUPPORTED; | ||
32 | return ticket->vtable->add_ref (ticket); | ||
33 | } | ||
34 | |||
35 | int | ||
36 | ticket_release (ticket_t ticket) | ||
37 | { | ||
38 | if (ticket == NULL || ticket->vtable == NULL | ||
39 | || ticket->vtable->release == NULL) | ||
40 | return MU_ERROR_NOT_SUPPORTED; | ||
41 | return ticket->vtable->release (ticket); | ||
42 | } | ||
43 | |||
44 | int | ||
45 | ticket_destroy (ticket_t ticket) | ||
46 | { | ||
47 | if (ticket == NULL || ticket->vtable == NULL | ||
48 | || ticket->vtable->destroy == NULL) | ||
49 | return MU_ERROR_NOT_SUPPORTED; | ||
50 | return ticket->vtable->destroy (ticket); | ||
51 | } | ||
52 | |||
53 | int | ||
54 | ticket_pop (ticket_t ticket, const char *challenge, char **parg) | ||
55 | { | ||
56 | if (ticket == NULL || ticket->vtable == NULL | ||
57 | || ticket->vtable->pop == NULL) | ||
58 | return MU_ERROR_NOT_SUPPORTED; | ||
59 | return ticket->vtable->pop (ticket, challenge, parg); | ||
60 | } |
-
Please register or sign in to post a comment