imapext-2007

view src/osdep/wce/dummywce.c @ 0:ada5e610ab86

imap-2007e
author yuuji@gentei.org
date Mon, 14 Sep 2009 15:17:45 +0900
parents
children
line source
1 /* ========================================================================
2 * Copyright 1988-2006 University of Washington
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 *
11 * ========================================================================
12 */
14 /*
15 * Program: Dummy routines for WCE
16 *
17 * Author: Mark Crispin
18 * Networks and Distributed Computing
19 * Computing & Communications
20 * University of Washington
21 * Administration Building, AG-44
22 * Seattle, WA 98195
23 * Internet: MRC@CAC.Washington.EDU
24 *
25 * Date: 24 May 1993
26 * Last Edited: 30 August 2006
27 */
30 #include <ctype.h>
31 #include <stdio.h>
32 #include <errno.h>
33 #include <fcntl.h>
34 #include <direct.h>
35 #include "mail.h"
36 #include "osdep.h"
37 #include <sys\stat.h>
38 #include <dos.h>
39 #include "dummy.h"
40 #include "misc.h"
42 /* Function prototypes */
44 DRIVER *dummy_valid (char *name);
45 void *dummy_parameters (long function,void *value);
46 MAILSTREAM *dummy_open (MAILSTREAM *stream);
47 void dummy_close (MAILSTREAM *stream,long options);
48 long dummy_ping (MAILSTREAM *stream);
49 void dummy_check (MAILSTREAM *stream);
50 long dummy_expunge (MAILSTREAM *stream,char *sequence,long options);
51 long dummy_copy (MAILSTREAM *stream,char *sequence,char *mailbox,long options);
52 long dummy_append (MAILSTREAM *stream,char *mailbox,append_t af,void *data);
54 /* Dummy routines */
57 /* Driver dispatch used by MAIL */
59 DRIVER dummydriver = {
60 "dummy", /* driver name */
61 DR_LOCAL|DR_MAIL, /* driver flags */
62 (DRIVER *) NIL, /* next driver */
63 dummy_valid, /* mailbox is valid for us */
64 dummy_parameters, /* manipulate parameters */
65 dummy_scan, /* scan mailboxes */
66 dummy_list, /* list mailboxes */
67 dummy_lsub, /* list subscribed mailboxes */
68 NIL, /* subscribe to mailbox */
69 NIL, /* unsubscribe from mailbox */
70 dummy_create, /* create mailbox */
71 dummy_delete, /* delete mailbox */
72 dummy_rename, /* rename mailbox */
73 mail_status_default, /* status of mailbox */
74 dummy_open, /* open mailbox */
75 dummy_close, /* close mailbox */
76 NIL, /* fetch message "fast" attributes */
77 NIL, /* fetch message flags */
78 NIL, /* fetch overview */
79 NIL, /* fetch message structure */
80 NIL, /* fetch header */
81 NIL, /* fetch text */
82 NIL, /* fetch message data */
83 NIL, /* unique identifier */
84 NIL, /* message number from UID */
85 NIL, /* modify flags */
86 NIL, /* per-message modify flags */
87 NIL, /* search for message based on criteria */
88 NIL, /* sort messages */
89 NIL, /* thread messages */
90 dummy_ping, /* ping mailbox to see if still alive */
91 dummy_check, /* check for new messages */
92 dummy_expunge, /* expunge deleted messages */
93 dummy_copy, /* copy messages to another mailbox */
94 dummy_append, /* append string message to mailbox */
95 NIL /* garbage collect stream */
96 };
99 /* prototype stream */
100 MAILSTREAM dummyproto = {&dummydriver};
102 /* driver parameters */
103 static char *file_extension = NIL;
105 /* Dummy validate mailbox
106 * Accepts: mailbox name
107 * Returns: our driver if name is valid, NIL otherwise
108 */
110 DRIVER *dummy_valid (char *name)
111 {
112 char *s,tmp[MAILTMPLEN];
113 struct stat sbuf;
114 /* must be valid local mailbox */
115 return (name && *name && (*name != '{') &&
116 (s = mailboxfile (tmp,name)) && (!*s || !stat (s,&sbuf))) ?
117 &dummydriver : NIL;
118 }
121 /* Dummy manipulate driver parameters
122 * Accepts: function code
123 * function-dependent value
124 * Returns: function-dependent return value
125 */
127 void *dummy_parameters (long function,void *value)
128 {
129 return value;
130 }
132 /* Dummy scan mailboxes
133 * Accepts: mail stream
134 * reference
135 * pattern to search
136 * string to scan
137 */
139 void dummy_scan (MAILSTREAM *stream,char *ref,char *pat,char *contents)
140 {
141 /* return silently */
142 }
144 /* Dummy list mailboxes
145 * Accepts: mail stream
146 * reference
147 * pattern to search
148 */
150 void dummy_list (MAILSTREAM *stream,char *ref,char *pat)
151 {
152 /* return silently */
153 }
156 /* Dummy list subscribed mailboxes
157 * Accepts: mail stream
158 * pattern to search
159 */
161 void dummy_lsub (MAILSTREAM *stream,char *ref,char *pat)
162 {
163 /* return silently */
164 }
166 /* Dummy create mailbox
167 * Accepts: mail stream
168 * mailbox name to create
169 * Returns: T on success, NIL on failure
170 */
172 long dummy_create (MAILSTREAM *stream,char *mailbox)
173 {
174 return NIL; /* always fails */
175 }
178 /* Dummy delete mailbox
179 * Accepts: mail stream
180 * mailbox name to delete
181 * Returns: T on success, NIL on failure
182 */
184 long dummy_delete (MAILSTREAM *stream,char *mailbox)
185 {
186 return NIL; /* always fails */
187 }
190 /* Mail rename mailbox
191 * Accepts: mail stream
192 * old mailbox name
193 * new mailbox name
194 * Returns: T on success, NIL on failure
195 */
197 long dummy_rename (MAILSTREAM *stream,char *old,char *newname)
198 {
199 return NIL; /* always fails */
200 }
202 /* Dummy open
203 * Accepts: stream to open
204 * Returns: stream on success, NIL on failure
205 */
207 MAILSTREAM *dummy_open (MAILSTREAM *stream)
208 {
209 char tmp[MAILTMPLEN];
210 /* OP_PROTOTYPE call or silence */
211 if (!stream || stream->silent) return NIL;
212 if (compare_cstring (stream->mailbox,"INBOX")) {
213 sprintf (tmp,"Not a mailbox: %s",stream->mailbox);
214 mm_log (tmp,ERROR);
215 return NIL; /* always fails */
216 }
217 if (!stream->silent) { /* only if silence not requested */
218 mail_exists (stream,0); /* say there are 0 messages */
219 mail_recent (stream,0);
220 stream->uid_validity = time (0);
221 }
222 stream->inbox = T; /* note that it's an INBOX */
223 return stream; /* return success */
224 }
227 /* Dummy close
228 * Accepts: MAIL stream
229 * options
230 */
232 void dummy_close (MAILSTREAM *stream,long options)
233 {
234 /* return silently */
235 }
237 /* Dummy ping mailbox
238 * Accepts: MAIL stream
239 * Returns: T if stream alive, else NIL
240 * No-op for readonly files, since read/writer can expunge it from under us!
241 */
243 long dummy_ping (MAILSTREAM *stream)
244 {
245 return T;
246 }
249 /* Dummy check mailbox
250 * Accepts: MAIL stream
251 * No-op for readonly files, since read/writer can expunge it from under us!
252 */
254 void dummy_check (MAILSTREAM *stream)
255 {
256 dummy_ping (stream); /* invoke ping */
257 }
260 /* Dummy expunge mailbox
261 * Accepts: MAIL stream
262 * sequence to expunge if non-NIL
263 * expunge options
264 * Returns: T, always
265 */
267 long dummy_expunge (MAILSTREAM *stream,char *sequence,long options)
268 {
269 return LONGT;
270 }
272 /* Dummy copy message(s)
273 * Accepts: MAIL stream
274 * sequence
275 * destination mailbox
276 * options
277 * Returns: T if copy successful, else NIL
278 */
280 long dummy_copy (MAILSTREAM *stream,char *sequence,char *mailbox,long options)
281 {
282 if ((options & CP_UID) ? mail_uid_sequence (stream,sequence) :
283 mail_sequence (stream,sequence)) fatal ("Impossible dummy_copy");
284 return NIL;
285 }
288 /* Dummy append message string
289 * Accepts: mail stream
290 * destination mailbox
291 * stringstruct of message to append
292 * Returns: T on success, NIL on failure
293 */
295 long dummy_append (MAILSTREAM *stream,char *mailbox,append_t af,void *data)
296 {
297 char tmp[MAILTMPLEN];
298 sprintf (tmp,"Can't append to %s",mailbox);
299 mm_log (tmp,ERROR); /* pass up error */
300 return NIL; /* always fails */
301 }

UW-IMAP'd extensions by yuuji