Commit 9d01189d 9d01189d9c635a0d5ba920e7935afc2016f19fd9 by Alain Magloire

mailbox.c mailbox.h mailboxi.c mbx_imap.c mbx_imap.h mbx_pop.c

 	mbx_pop.h
Draft of the Mailbox API
1 parent c30118f3
1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 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 <mbx_unix.h>
23 #include <mbx_pop.h>
24 #include <mbx_imap.h>
25
26 #include <stdlib.h>
27 #include <errno.h>
28
29 /* forward prototypes */
30 static int mbx_open (mailbox_t, int flag);
31 static int mbx_close (mailbox_t, int flag);
32
33 /* name */
34 static int mbx_get_name (mailbox_t, int *id, char *name, int offset, int n);
35
36 /* passwd */
37 static int mbx_get_passwd (mailbox_t, char * passwd, int offset, int len);
38 static int mbx_get_mpasswd (mailbox_t, char ** passwd, int *len);
39 static int mbx_set_passwd (mailbox_t, const char * passwd, int offset, int n);
40
41 /* deleting */
42 static int mbx_delete (mailbox_t, int);
43 static int mbx_undelete (mailbox_t, int);
44 static int mbx_expunge (mailbox_t);
45 static int mbx_is_deleted (mailbox_t, int);
46
47 /* appending */
48 static int mbx_new_msg (mailbox_t, int * id);
49 static int mbx_set_header (mailbox_t, int id, const char *h,
50 int offset, int n, int replace);
51 static int mbx_set_body (mailbox_t, int id, const char *b,
52 int offset, int n, int replace);
53 static int mbx_append (mailbox_t, int id);
54 static int mbx_destroy_msg (mailbox_t, int id);
55
56 /* reading */
57 static int mbx_get_body (mailbox_t, int id, char *b, int offset, int n);
58 static int mbx_get_header (mailbox_t, int id, char *h, int offset, int n);
59
60 /* locking */
61 static int mbx_lock (mailbox_t, int flag);
62 static int mbx_unlock (mailbox_t);
63
64 /* misc */
65 static int mbx_scan (mailbox_t, int *msgs);
66 static int mbx_is_updated (mailbox_t);
67 static int mbx_get_timeout (mailbox_t, int *timeout);
68 static int mbx_set_timeout (mailbox_t, int timeout);
69 static int mbx_get_refresh (mailbox_t, int *refresh);
70 static int mbx_set_refresh (mailbox_t, int refresh);
71 static int mbx_set_notification (mailbox_t, int (*notif) (mailbox_t));
72
73 static void mbx_check_struct (mailbox_t);
74
75 /*
76 Builtin mailbox types.
77 A circular list is use for the builtin.
78 Proper locking is not done when accessing the list.
79 FIXME: not thread-safe. */
80 static struct mailbox_builtin
81 {
82 const struct mailbox_type *mtype;
83 int is_malloc;
84 struct mailbox_builtin * next;
85 } mailbox_builtin [] = {
86 { NULL, 0, &url_builtin[1] }, /* sentinel, head list */
87 { &_mailbox_unix_type, 0, &mailbox_builtin[2] },
88 { &_mailbox_pop_type, 0, &mailbox_builtin[3] },
89 { &_mailbox_imap_type, 0, &mailbox_builtin[0] },
90 };
91
92 int
93 malibox_add_type (struct mailbox_type *mtype)
94 {
95 struct mailbox_builtin *current = malloc (sizeof (*current));
96 if (current == NULL)
97 return -1;
98 if (mtype->utype)
99 {
100 if (url_add_type (mtype->utype) < 0)
101 {
102 free (current);
103 return -1;
104 }
105 mtype->id = url_get_id (mtype->utype); /* same ID as the url_tupe */
106 }
107 else
108 {
109 mtype->id = (int)mtype; /* just need to be uniq */
110 }
111 current->mtype = mtype;
112 current->is_malloc = 1;
113 current->next = mailbox_builtin->next;
114 mailbox_builtin->next = current;
115 return 0;
116 }
117
118 int
119 mailbox_remove_type (const struct mailbox_type *mtype)
120 {
121 struct mailbox_builtin *current, *previous;
122 for (previous = mailbox_builtin, current = mailbox_builtin->next;
123 current != mailbox_builtin;
124 previous = current, current = current->next)
125 {
126 if (current->mtype == mtype)
127 {
128 previous->next = current->next;
129 if (current->is_malloc)
130 free (current);
131 return 0;;
132 }
133 }
134 return -1;
135 }
136
137 int
138 mailbox_list_type (struct mailbox_type *list, int n)
139 {
140 struct mailbox_builtin *current;
141 int i;
142 for (i = 0, current = mailbox_builtin->next; current != mailbox_builtin;
143 current = current->next, i++)
144 {
145 if (list)
146 if (i < n)
147 list[i] = *(current->mtype);
148 }
149 return i;
150 }
151
152 int
153 mailbox_list_mtype (struct url_type **mlist, int *n)
154 {
155 struct mailbox_type *mtype;
156 int i;
157
158 if ((i = mailbox_list_type (NULL, 0)) <= 0 || (mtype = malloc (i)) == NULL)
159 {
160 return -1;
161 }
162 *mlist = mtype;
163 return *n = mailbox_list_type (mtype, i);
164 }
165
166 int
167 mailbox_get_type (struct mailbox_type * const *mtype, int id)
168 {
169 struct mailbox_builtin *current;
170 for (current = mailbox_builtin->next; current != mailbox_builtin;
171 current = current->next)
172 {
173 if (current->mtype->type == type)
174 {
175 *mtype = current->mtype;
176 return 0;;
177 }
178 }
179 return -1;
180 }
181
182
183 int
184 mailbox_init (mailbox_t *mbox, const char *name, int id)
185 {
186 int status = -1; /* -1 means error */
187
188 /* 1st run: if they know what they want, shortcut */
189 if (id)
190 {
191 struct mailbox_type *mtype;
192 status = mailbox_get_type (&mtype, id);
193 if (status == 0)
194 {
195 status = mtype->_init (mbox, name);
196 if (status == 0)
197 mbx_check_struct (*mbox);
198 }
199 }
200
201 /* 2nd run: try heuristic URL discovery */
202 if (status != 0)
203 {
204 url_t url;
205 status = url_init (&url, name);
206 if (status == 0)
207 {
208 int id;
209 struct mailbox_type *mtype;
210 /* We've found a match get it */
211 if (url_get_id (url, &id) == 0
212 && (status = mailbox_get_type (&mtype, id)) == 0)
213 {
214 status = mtype->_init (mbox, name);
215 if (status == 0)
216 mbx_check_struct (*mbox);
217 }
218 url_destroy (url);
219 }
220 }
221
222 /* 3nd run: nothing yet ?? try unixmbox/maildir directly as the last resort.
223 this should take care of the case where the filename is use */
224 if (status != 0 )
225 {
226 status = mailbox_unix_init (mbox, name);
227 if (status == 0)
228 mbx_check_struct (*mbox);
229 }
230 return status;
231 }
232
233 void
234 mailbox_destroy (mailbox_t * mbox)
235 {
236 return mbox->_destroy (mbox);
237 }
238
239 /* stub functions */
240 static void
241 mbx_check_struct (mailbox_t)
242 {
243 }
244
245 static int
246 mbx_open (mailbox_t, int flag)
247 {
248 return -1;
249 }
250
251 static int
252 mbx_close (mailbox_t, int flag)
253 {
254 return -1;
255 }
256
257
258 /* name */
259 static int
260 mbx_get_name (mailbox_t, int *id, char *name, int offset, int n)
261 {
262 return -1;
263 }
264
265 /* passwd */
266 static int
267 mbx_get_passwd (mailbox_t, char * passwd, int offset, int len)
268 {
269 return -1;
270 }
271
272 static int
273 mbx_get_mpasswd (mailbox_t, char ** passwd, int *len)
274 {
275 return -1;
276 }
277
278 static int
279 mbx_set_passwd (mailbox_t, const char * passwd, int offset, int n)
280 {
281 return -1;
282 }
283
284 /* deleting */
285 static int
286 mbx_delete (mailbox_t, int)
287 {
288 return -1;
289 }
290
291 static int
292 mbx_undelete (mailbox_t, int)
293 {
294 return -1;
295 }
296
297 static int
298 mbx_expunge (mailbox_t)
299 {
300 return -1;
301 }
302
303 static int
304 mbx_is_deleted (mailbox_t, int)
305 {
306 return -1;
307 }
308
309
310 /* appending */
311 static int
312 mbx_new_msg (mailbox_t, int * id)
313 {
314 return -1;
315 }
316
317 static int
318 mbx_set_header (mailbox_t, int id, const char *h,
319 int offset, int n, int replace)
320 {
321 return -1;
322 }
323
324 static int
325 mbx_set_body (mailbox_t, int id, const char *b,
326 int offset, int n, int replace)
327 {
328 return -1;
329 }
330
331 static int
332 mbx_append (mailbox_t, int id)
333 {
334 return -1;
335 }
336
337 static int
338 mbx_destroy_msg (mailbox_t, int id)
339 {
340 return -1;
341 }
342
343 /* reading */
344 static int
345 mbx_get_body (mailbox_t, int id, char *b, int offset, int n)
346 {
347 return -1;
348 }
349
350 static int
351 mbx_get_header (mailbox_t, int id, char *h, int offset, int n)
352 {
353 return -1;
354 }
355
356 /* locking */
357 static int
358 mbx_lock (mailbox_t, int flag)
359 {
360 return -1;
361 }
362
363 static int
364 mbx_unlock (mailbox_t)
365 {
366 return -1;
367 }
368
369 /* misc */
370 static int
371 mbx_scan (mailbox_t, int *msgs)
372 {
373 return -1;
374 }
375
376 static int
377 mbx_is_updated (mailbox_t)
378 {
379 return -1;
380 }
381
382 static int
383 mbx_get_timeout (mailbox_t, int *timeout)
384 {
385 return -1;
386 }
387
388 static int
389 mbx_set_timeout (mailbox_t, int timeout)
390 {
391 return -1;
392 }
393
394 static int
395 mbx_get_refresh (mailbox_t, int *refresh)
396 {
397 return -1;
398 }
399
400 static int
401 mbx_set_refresh (mailbox_t, int refresh)
402 {
403 return -1;
404 }
405
406 static int
407 mbx_set_notification (mailbox_t, int (*notif) (mailbox_t))
408 {
409 return -1;
410 }
1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 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 _MAILBOX_H
19 # define _MAILBOX_H
20
21 #include <url.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 /* forward declaration */
36 struct _mailbox;
37 typedef struct _mailbox *mailbox_t;
38
39 /* Lock settings */
40 typedef enum { MB_ULOCK, MB_RLOCK, MB_WLOCK } mailbox_lock_t;
41
42 struct mailbox_type
43 {
44 char *name;
45 int id;
46 struct url_type *utype;
47 int (*_init) __P ((mailbox_t *, const char *name, int id));
48 int (*_destroy) __P ((mailbox_t *);
49 };
50
51 struct _mailbox
52 {
53 /* Data */
54 char *name;
55 int messages;
56 int num_deleted;
57 long size;
58 int timeout;
59 int refresh;
60 mailbox_lock_t lock;
61 int (*notif) __P ((mailbox_t));
62
63 void *data;
64 struct mailbox_type *mtype;
65
66 /* Functions */
67
68 void (*_destroy) __P ((maibox_t *));
69
70 int (*_open) __P ((mailbox_t, int flag));
71 int (*_close) __P ((mailbox_t, int flag));
72
73 /* type */
74 int (*_get_type) __P ((mailbox_t, int *type, char *desc,
75 int offset, int len));
76 int (*_get_mtype) __P ((mailbox_t, int *type, char **desc,
77 int *len));
78
79 /* passwd if needed */
80 int (*_get_passwd) __P ((mailbox_t, char * passwd, int offset, int n));
81 int (*_get_mpasswd) __P ((mailbox_t, char ** passwd, int *n));
82 int (*_set_passwd) __P ((mailbox_t, const char * passwd,
83 int offset, int n));
84 /* deleting mesgs */
85 int (*_delete) __P ((mailbox_t, int id));
86 int (*_undelete) __P ((mailbox_t, int id));
87 int (*_is_deleted) __P ((mailbox_t, int id));
88 int (*_expunge) __P ((mailbox_t));
89
90 /* appending messages */
91 int (*_new_msg) __P ((mailbox_t, int *id));
92 int (*_set_header) __P ((mailbox_t, int id, const char *h,
93 int offset, int n, int replace));
94 int (*_set_body) __P ((mailbox_t, int id, const char *b,
95 int offset, int n, int replace));
96 int (*_append) __P ((mailbox_t, int id));
97 int (*_destroy_msg) __P ((mailbox_t, int id));
98
99 /* locking */
100 int (*_lock) __P ((mailbox_t, int flag));
101 int (*_unlock) __P ((mailbox_t));
102
103 /* reading mesgs */
104 int (*_get_body) __P ((mailbox_t, int id, char *v,
105 int offset, int n));
106 int (*_get_mbody) __P ((mailbox_t, int id, char **v, int *n));
107 int (*_get_header) __P ((mailbox_t, int id, char *h,
108 int offset, int n));
109 int (*_get_mheader) __P ((mailbox_t, int id, char **h, int *n));
110
111 /* misc */
112 int (*_scan) __P ((mailbox_t, int *msgs));
113 int (*_is_updated) __P ((mailbox_t));
114 int (*_get_timeout) __P ((mailbox_t, int *timeout));
115 int (*_set_timeout) __P ((mailbox_t, int timeout));
116 int (*_get_size) __P ((mailbox_t, int id, long *size));
117 int (*_get_refresh) __P ((mailbox_t, int *refresh));
118 int (*_set_refresh) __P ((mailbox_t, int refresh));
119 int (*_set_notification) __P ((mailbox_t, int (*notif) __P ((mailbox_t))));
120 };
121
122 /* constructor/destructor and possible types */
123 extern int mailbox_init __P ((mailbox_t *, const char *name, int id));
124 extern void mailbox_destroy __P ((mailbox_t *));
125
126 /* mailbox registration */
127 extern int mailbox_list_type __P ((struct mailbox_type mtype[], int size));
128 extern int mailbox_list_mtype __P ((struct mailbox_type **mtype, int *size));
129 extern int mailbox_add_type __P ((struct mailbox_type *mlist));
130 extern int mailbox_remove_type __P ((const struct mailbox_type *mlist));
131
132 #ifndef INLINE
133 # ifdef __GNUC__
134 # define INLINE __inline__
135 # else
136 # define INLINE
137 # endif
138 #endif
139
140 extern INLINE int mailbox_open __P ((mailbox_t, int flag));
141 extern INLINE int mailbox_close __P ((mailbox_t, int flag));
142
143 /* type */
144 extern INLINE int mailbox_get_type __P ((mailbox_t, int *type, char *desc,
145 int offset, int len));
146 extern INLINE int mailbox_get_mtype __P ((mailbox_t, int *type, char **desc,
147 int *len));
148
149 /* passwd */
150 extern INLINE int mailbox_get_passwd __P ((mailbox_t, char * passwd,
151 int offset, int len));
152 extern INLINE int mailbox_get_mpasswd __P ((mailbox_t, char ** passwd,
153 int *len));
154 extern INLINE int mailbox_set_passwd __P ((mailbox_t, const char * passwd,
155 int offset, int len));
156
157 /* deleting */
158 extern INLINE int mailbox_delete __P ((mailbox_t, int));
159 extern INLINE int mailbox_undelete __P ((mailbox_t, int));
160 extern INLINE int mailbox_expunge __P ((mailbox_t));
161 extern INLINE int mailbox_is_deleted __P ((mailbox_t, int));
162
163 /* appending */
164 extern INLINE int mailbox_new_msg __P ((mailbox_t, int * id));
165 extern INLINE int mailbox_set_header __P ((mailbox_t, int id, const char *h,
166 int offset, int n, int replace));
167 extern INLINE int mailbox_set_body __P ((mailbox_t, int id, const char *b,
168 int offset, int n, int replace));
169 extern INLINE int mailbox_append __P ((mailbox_t, int id));
170 extern INLINE int mailbox_destroy_msg __P ((mailbox_t, int id));
171
172 /* reading */
173 extern INLINE int mailbox_get_body __P ((mailbox_t, int id, char *b,
174 int offset, int n));
175 extern INLINE int mailbox_get_header __P ((mailbox_t, int id, char *h,
176 int offset, int n));
177
178 /* locking */
179 extern INLINE int mailbox_lock __P ((mailbox_t, int flag));
180 extern INLINE int mailbox_unlock __P ((mailbox_t));
181
182 /* misc */
183 extern INLINE int mailbox_scan __P ((mailbox_t, int *msgs));
184 extern INLINE int mailbox_is_updated __P ((mailbox_t));
185 extern INLINE int mailbox_get_timeout __P ((mailbox_t, int *timeout));
186 extern INLINE int mailbox_set_timeout __P ((mailbox_t, int timeout));
187 extern INLINE int mailbox_get_refresh __P ((mailbox_t, int *refresh));
188 extern INLINE int mailbox_set_refresh __P ((mailbox_t, int refresh));
189 extern INLINE int mailbox_set_notification __P ((mailbox_t, int
190 (*notif) __P ((mailbox_t))));
191
192 #ifdef MU_USE_MACROS
193 #define mailbox_open(m, f) m->_open (m, f)
194 #define mailbox_close(m, f) m->_close (m, f)
195
196 /* type */
197 #define mailbox_get_type(m, t, d, o, n) m->_get_type (m, t, d, o, n)
198 #define mailbox_get_mtype(m, t, d, n) m->_get_mtype (m, t, d, n)
199
200 /* passwd */
201 #define mailbox_get_passwd(m, p, o, n) m->_get_passwd (m, p, o, n)
202 #define mailbox_get_mpasswd(m, p, n) m->_get_mpasswd (m, p, n)
203 #define mailbox_set_passwd(m, p, o, n) m->_set_passwd (m, p, o, n)
204
205 /* deleting */
206 #define mailbox_delete(m, id) m->_delete (m, id)
207 #define mailbox_undelete(m, id) m->_undelete (m, id)
208 #define mailbox_is_deleted(m, id) m->_is_deleted (m, id)
209 #define mailbox_expunge(m) m->_expunge (m)
210
211 /* appending */
212 #define mailbox_new_msg(m, id) m->_new_msg (m, id)
213 #define mailbox_set_header(m, id, h, o, n, r) m->_set_header(m, id, h, o, n, r)
214 #define mailbox_set_body(m, id, b, o, n, r) m->_set_body (m, id, b, o, n, r)
215 #define mailbox_append(m, id) m->_append (m, id)
216 #define mailbox_destroy_msg(m, id) m->_destroy_msg (m, id)
217
218 /* locking */
219 #define mailbox_lock(m, f) m->_lock (m, f)
220 #define mailbox_unlock(m) m->_unlock (m)
221
222 /* reading */
223 #define mailbox_get_header(m, id, h, o, n) m->_get_header (m, id, h, o, n)
224 #define mailbox_get_mheader(m, id, h, n) m->_get_header (m, id, h, n)
225 #define mailbox_get_body(m, id, b, o, n) m->_get_body (m, id, b, o, n)
226 #define mailbox_get_mbody(m, id, b, n) m->_get_body (m, id, b, n)
227
228 /* misc */
229 #define mailbox_scan(m, t) m->_scan (m, t)
230 #define mailbox_is_updated(m) m->_is_updated (m)
231 #define mailbox_get_timeout(m, t) m->_get_timeout (m, t)
232 #define mailbox_set_timeout(m, t) m->_set_timeout (m, t)
233 #define mailbox_get_refresh(m, r) m->_get_refresh (m, r)
234 #define mailbox_set_refresh(m, r) m->_set_refresh (m, r)
235 #define mailbox_set_notification(m, notif) m->_set_notification (m, notif)
236 #endif /* MU_USE_MACROS */
237
238 #ifdef __cplusplus
239 }
240 #endif
241
242 #endif /* _MAILBOX_H */
1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 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 <mailbox.h>
19
20 int
21 mailbox_open (mailbox_t mbox, int flag)
22 {
23 return mbox->_open (mbox, flag);
24 }
25
26 int
27 mailbox_close (mailbox_t mbox, int flag)
28 {
29 return mbox->_close (mbox, flag);
30 }
31
32
33 /* type */
34 int
35 mailbox_get_type (mailbox_t mbox, int *type, char *desc, int offset, int len)
36 {
37 return mbox->_get_type (mbox, type, desc, offset, len);
38 }
39
40 int
41 mailbox_get_mtype (mailbox_t mbox, int *type, char **desc, int *len)
42 {
43 return mbox->_get_mtype (mbox, type, desc, offset, len);
44 }
45
46
47 /* passwd */
48 int
49 mailbox_get_passwd (mailbox_t mbox, char *passwd, int offset, int len)
50 {
51 return mbox->_get_passwd (mbox, passwd, offset, len);
52 }
53
54 int
55 mailbox_get_mpasswd (mailbox_t mbox, char **passwd, int *len)
56 {
57 return mbox->_get_mpasswd (mbox, passwd, len);
58 }
59
60 int
61 mailbox_set_passwd (mailbox_t mbox, const char *passwd, int offset, int len)
62 {
63 return mbox->_set_passwd (mbox, passwd, offset, len);
64 }
65
66
67 /* deleting */
68 int
69 mailbox_delete (mailbox_t mbox, int id)
70 {
71 return mbox->_delete (mbox, id);
72 }
73
74 int
75 mailbox_undelete (mailbox_t mbox, int id)
76 {
77 return mbox->_undelete (mbox, id);
78 }
79
80 int
81 mailbox_expunge (mailbox_t mbox)
82 {
83 return mbox->_expunge (mbox);
84 }
85
86 int
87 mailbox_is_deleted (mailbox_t mbox, int)
88 {
89 return mbox->_is_deleted (mbox, int);
90 }
91
92
93 /* appending */
94 int
95 mailbox_new_msg (mailbox_t mbox, int * id)
96 {
97 return mbox->_new_msg (mbox, id);
98 }
99
100 int
101 mailbox_set_header (mailbox_t mbox, int id, const char *h,
102 int offset, int n, int replace)
103 {
104 return mbox->_set_header (mbox, id, h, offset, n, replace);
105 }
106
107 int
108 mailbox_set_body (mailbox_t mbox, int id, const char *b,
109 int offset, int n, int replace)
110 {
111 return mbox->_set_body (mbox, id, b, offset, n, replace);
112 }
113
114 int
115 mailbox_append (mailbox_t mbox, int id)
116 {
117 return mbox->_append (mbox, id);
118 }
119
120 int
121 mailbox_destroy_msg (mailbox_t mbox, int id)
122 {
123 return mbox->_destroy_msg (mbox, id);
124 }
125
126
127 /* reading */
128 int
129 mailbox_get_body (mailbox_t mbox, int id, char *b, int offset, int n)
130 {
131 return mbox->_get_body (mbox, id, b, offset, n);
132 }
133
134 int
135 mailbox_get_mbody (mailbox_t mbox, int id, char **b, int *n)
136 {
137 return mbox->_get_body (mbox, id, b, n);
138 }
139
140 int
141 mailbox_get_header (mailbox_t mbox, int id, char *h, int offset, int n)
142 {
143 return mbox->_get_header (mbox, id, h, offset, n);
144 }
145
146 int
147 mailbox_get_mheader (mailbox_t mbox, int id, char **h, int *n)
148 {
149 return mbox->_get_header (mbox, id, h, n);
150 }
151
152
153 /* locking */
154 int
155 mailbox_lock (mailbox_t mbox, int flag)
156 {
157 return mbox->_lock (mbox, flag);
158 }
159
160 int
161 mailbox_unlock (mailbox_t mbox)
162 {
163 return mbox->_unlock (mbox);
164 }
165
166
167 /* misc */
168 int
169 mailbox_scan (mailbox_t mbox, int *msgs)
170 {
171 return mbox->_scan (mbox, msgs);
172 }
173
174 int
175 mailbox_is_updated (mailbox_t mbox)
176 {
177 return mbox->_is_updated (mbox);
178 }
179
180 int
181 mailbox_get_timeout (mailbox_t mbox, int *timeout)
182 {
183 return mbox->_get_timeout (mbox, timeout);
184 }
185
186 int
187 mailbox_set_timeout (mailbox_t mbox, int timeout)
188 {
189 return mbox->_set_timeout (mbox, timeout);
190 }
191
192 int
193 mailbox_get_refresh (mailbox_t mbox, int *refresh)
194 {
195 return mbox->_get_refresh (mbox, refresh);
196 }
197
198 int
199 mailbox_set_refresh (mailbox_t mbox, int refresh)
200 {
201 return mbox->_set_refresh (mbox, refresh);
202 }
203
204 int
205 mailbox_set_notification (mailbox_t mbox, int (*notif) __P ((mailbox_t mbox)))
206 {
207 return mbox->_set_notification (mbox, notif);
208 }
1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 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 <mbx_imap.h>
19
20
21 struct mailbox_type _mailbox_imap_type =
22 {
23 "IMAP",
24 (int)&_url_imap_type, &_url_imap_type,
25 mailbox_imap_init, mailbox_imap_destroy
26 };
27
28 int
29 mailbox_imap_destroy (mailbox_t *mbox)
30 {
31 return;
32 }
33
34 int
35 mailbox_imap_init (mailbox_t *mbox, const char *name)
36 {
37 return -1;
38 }
1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 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 _MBX_IMAP_H
19 #define _MBX_IMAP_H 1
20
21 #include <mailbox.h>
22
23 extern int mailbox_imap_init __P ((mailbox_t *mbox, const char *name));
24 extern int mailbox_imap_destroy __P ((mailbox_t *mbox));
25
26 extern struct mailbox_type _mailbox_imap_type;
27
28 #endif /* _MBX_IMAP_H */
1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 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 #include <mbx_pop.h>
19
20 struct mailbox_type _mailbox_pop_type =
21 {
22 "POP",
23 (int)&_url_pop_type, &_url_pop_type,
24 mailbox_pop_init, mailbox_pop_destroy
25 };
26
27 void
28 mailbox_pop_destroy (mailbox_t *mbox)
29 {
30 return;
31 }
32
33 int
34 mailbox_pop_init (mailbox_t *mbox)
35 {
36 return -1;
37 }
1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 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 _MBX_POP_H
19 #define _MBX_POP_H 1
20
21 #include <mailbox.h>
22
23 extern int mailbox_pop_init __P ((mailbox_t *mbox, const char *name));
24 extern int mailbox_pop_destroy __P ((mailbox_t *mbox));
25
26 extern struct mailbox_type _mailbox_pop_type;
27
28 #endif /* _MBX_POP_H */