2002-12-22 Jeff Bailey <jbailey@nisa.net>
* mailbox/mbx_maildir.c: Initial checkin of template * mailbox/Makefile.am: (libmailbox_la_SOURCES) Add mbx_maildir.c
Showing
3 changed files
with
231 additions
and
0 deletions
1 | 2002-12-22 Jeff Bailey <jbailey@nisa.net> | ||
2 | |||
3 | * mailbox/mbx_maildir.c: Initial checkin of template | ||
4 | |||
5 | * mailbox/Makefile.am: (libmailbox_la_SOURCES) Add mbx_maildir.c | ||
6 | |||
1 | 2002-12-20 Sergey Poznyakoff | 7 | 2002-12-20 Sergey Poznyakoff |
2 | 8 | ||
3 | * libsieve/sieve.l: Implemented shell-like extension for | 9 | * libsieve/sieve.l: Implemented shell-like extension for | ... | ... |
mailbox/mbx_maildir.c
0 → 100644
1 | /* GNU mailutils - a suite of utilities for electronic mail | ||
2 | Copyright (C) 1999, 2000, 2001, 2002 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 General Public License | ||
15 | along with this program; if not, write to the Free Software Foundation, | ||
16 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | ||
17 | |||
18 | /* First draft by Jeff Bailey based on mbox by Alain Magloire */ | ||
19 | |||
20 | #ifdef HAVE_CONFIG_H | ||
21 | # include <config.h> | ||
22 | #endif | ||
23 | |||
24 | #include <stdlib.h> | ||
25 | #include <stdio.h> | ||
26 | #include <time.h> | ||
27 | #include <sys/stat.h> | ||
28 | #include <fcntl.h> | ||
29 | #include <unistd.h> | ||
30 | #include <signal.h> | ||
31 | #include <time.h> | ||
32 | #include <string.h> | ||
33 | #include <ctype.h> | ||
34 | #include <limits.h> | ||
35 | #include <errno.h> | ||
36 | |||
37 | #ifdef WITH_PTHREAD | ||
38 | # ifdef HAVE_PTHREAD_H | ||
39 | # define _XOPEN_SOURCE 500 | ||
40 | # include <pthread.h> | ||
41 | # endif | ||
42 | #endif | ||
43 | |||
44 | #ifdef HAVE_ALLOCA_H | ||
45 | # include <alloca.h> | ||
46 | #endif | ||
47 | |||
48 | #ifdef HAVE_STRINGS_H | ||
49 | # include <strings.h> | ||
50 | #endif | ||
51 | |||
52 | #include <mailbox0.h> | ||
53 | #include <registrar0.h> | ||
54 | |||
55 | #include <mailutils/address.h> | ||
56 | #include <mailutils/attribute.h> | ||
57 | #include <mailutils/body.h> | ||
58 | #include <mailutils/debug.h> | ||
59 | #include <mailutils/envelope.h> | ||
60 | #include <mailutils/errno.h> | ||
61 | #include <mailutils/error.h> | ||
62 | #include <mailutils/header.h> | ||
63 | #include <mailutils/locker.h> | ||
64 | #include <mailutils/message.h> | ||
65 | #include <mailutils/mutil.h> | ||
66 | #include <mailutils/observer.h> | ||
67 | #include <mailutils/property.h> | ||
68 | #include <mailutils/stream.h> | ||
69 | #include <mailutils/url.h> | ||
70 | |||
71 | /* Mailbox concrete implementation. */ | ||
72 | static int maildir_open __P ((mailbox_t, int)); | ||
73 | static int maildir_close __P ((mailbox_t)); | ||
74 | static void maildir_destroy __P ((mailbox_t)); | ||
75 | static int maildir_get_message __P ((mailbox_t, size_t, message_t *)); | ||
76 | /* static int maildir_get_message_by_uid __P ((mailbox_t, size_t, message_t *)); */ | ||
77 | static int maildir_append_message __P ((mailbox_t, message_t)); | ||
78 | static int maildir_messages_count __P ((mailbox_t, size_t *)); | ||
79 | static int maildir_messages_recent __P ((mailbox_t, size_t *)); | ||
80 | static int maildir_message_unseen __P ((mailbox_t, size_t *)); | ||
81 | static int maildir_expunge __P ((mailbox_t)); | ||
82 | static int maildir_save_attributes __P ((mailbox_t)); | ||
83 | static int maildir_uidvalidity __P ((mailbox_t, unsigned long *)); | ||
84 | static int maildir_uidnext __P ((mailbox_t, size_t *)); | ||
85 | static int maildir_scan __P ((mailbox_t, size_t, size_t *)); | ||
86 | static int maildir_is_updated __P ((mailbox_t)); | ||
87 | static int maildir_get_size __P ((mailbox_t, off_t *)); | ||
88 | |||
89 | int | ||
90 | _mailbox_maildir_init (mailbox_t mailbox) | ||
91 | { | ||
92 | |||
93 | if (mailbox == NULL) | ||
94 | return EINVAL; | ||
95 | |||
96 | /* Overloading the defaults. */ | ||
97 | mailbox->_destroy = maildir_destroy; | ||
98 | |||
99 | mailbox->_open = maildir_open; | ||
100 | mailbox->_close = maildir_close; | ||
101 | |||
102 | /* Overloading of the entire mailbox object methods. */ | ||
103 | mailbox->_get_message = maildir_get_message; | ||
104 | mailbox->_append_message = maildir_append_message; | ||
105 | mailbox->_messages_count = maildir_messages_count; | ||
106 | mailbox->_messages_recent = maildir_messages_recent; | ||
107 | mailbox->_message_unseen = maildir_message_unseen; | ||
108 | mailbox->_expunge = maildir_expunge; | ||
109 | mailbox->_save_attributes = maildir_save_attributes; | ||
110 | mailbox->_uidvalidity = maildir_uidvalidity; | ||
111 | mailbox->_uidnext = maildir_uidnext; | ||
112 | |||
113 | mailbox->_scan = maildir_scan; | ||
114 | mailbox->_is_updated = maildir_is_updated; | ||
115 | |||
116 | mailbox->_get_size = maildir_get_size; | ||
117 | |||
118 | return 0; /* okdoke */ | ||
119 | } | ||
120 | |||
121 | /* Destruct maildir setup */ | ||
122 | static void | ||
123 | maildir_destroy (mailbox_t mailbox) | ||
124 | { | ||
125 | return; | ||
126 | } | ||
127 | |||
128 | /* Open the file. For MU_STREAM_READ, the code tries mmap() first and fall | ||
129 | back to normal file. */ | ||
130 | static int | ||
131 | maildir_open (mailbox_t mailbox, int flags) | ||
132 | { | ||
133 | return -1; | ||
134 | } | ||
135 | |||
136 | static int | ||
137 | maildir_close (mailbox_t mailbox) | ||
138 | { | ||
139 | return -1; | ||
140 | } | ||
141 | |||
142 | /* Cover function that call the real thing, maildir_scan(), with | ||
143 | notification set. */ | ||
144 | static int | ||
145 | maildir_scan (mailbox_t mailbox, size_t msgno, size_t *pcount) | ||
146 | { | ||
147 | return 0; | ||
148 | } | ||
149 | |||
150 | /* FIXME: How to handle a shrink ? meaning, the &^$^@%#@^& user start two | ||
151 | browsers and deleted emails in one session. My views is that we should | ||
152 | scream bloody murder and hunt them with a machette. But for now just play | ||
153 | dumb, but maybe the best approach is to pack our things and leave | ||
154 | .i.e exit()/abort(). */ | ||
155 | static int | ||
156 | maildir_is_updated (mailbox_t mailbox) | ||
157 | { | ||
158 | return -1; | ||
159 | } | ||
160 | |||
161 | static int | ||
162 | maildir_expunge (mailbox_t mailbox) | ||
163 | { | ||
164 | return -1; | ||
165 | } | ||
166 | |||
167 | static int | ||
168 | maildir_get_size (mailbox_t mailbox, off_t *psize) | ||
169 | { | ||
170 | return -1; | ||
171 | } | ||
172 | |||
173 | static int | ||
174 | maildir_save_attributes (mailbox_t mailbox) | ||
175 | { | ||
176 | return -1; | ||
177 | } | ||
178 | |||
179 | static int | ||
180 | maildir_get_message (mailbox_t mailbox, size_t msgno, message_t *pmsg) | ||
181 | { | ||
182 | return -1; | ||
183 | } | ||
184 | |||
185 | static int | ||
186 | maildir_append_message (mailbox_t mailbox, message_t msg) | ||
187 | { | ||
188 | return -1; | ||
189 | } | ||
190 | |||
191 | static int | ||
192 | maildir_messages_count (mailbox_t mailbox, size_t *pcount) | ||
193 | { | ||
194 | return -1; | ||
195 | } | ||
196 | |||
197 | /* A "recent" message is the one not marked with MU_ATTRIBUTE_SEEN | ||
198 | ('O' in the Status header), i.e. a message that is first seen | ||
199 | by the current session (see attributes.h) */ | ||
200 | static int | ||
201 | maildir_messages_recent (mailbox_t mailbox, size_t *pcount) | ||
202 | { | ||
203 | return -1; | ||
204 | } | ||
205 | |||
206 | /* An "unseen" message is the one that has not been read yet */ | ||
207 | static int | ||
208 | maildir_message_unseen (mailbox_t mailbox, size_t *pmsgno) | ||
209 | { | ||
210 | return -1; | ||
211 | } | ||
212 | |||
213 | static int | ||
214 | maildir_uidvalidity (mailbox_t mailbox, unsigned long *puidvalidity) | ||
215 | { | ||
216 | return -1; | ||
217 | } | ||
218 | |||
219 | static int | ||
220 | maildir_uidnext (mailbox_t mailbox, size_t *puidnext) | ||
221 | { | ||
222 | return -1; | ||
223 | } | ||
224 |
-
Please register or sign in to post a comment