imapext-2007

view src/osdep/tops-20/dummyt20.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 TOPS-20
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: 13 June 1995
26 * Last Edited: 30 August 2006
27 */
30 #include <ctype.h>
31 #include <stdio.h>
32 #include "mail.h"
33 #include "osdep.h"
34 #include "dummy.h"
35 #include "misc.h"
37 /* Function prototypes */
39 DRIVER *dummy_valid (char *name);
40 void *dummy_parameters (long function,void *value);
41 MAILSTREAM *dummy_open (MAILSTREAM *stream);
42 void dummy_close (MAILSTREAM *stream,long options);
43 long dummy_ping (MAILSTREAM *stream);
44 void dummy_check (MAILSTREAM *stream);
45 long dummy_expunge (MAILSTREAM *stream,char *sequence,long options);
46 long dummy_copy (MAILSTREAM *stream,char *sequence,char *mailbox,long options);
47 long dummy_append (MAILSTREAM *stream,char *mailbox,append_t af,void *data);
49 /* Dummy routines */
52 /* Driver dispatch used by MAIL */
54 DRIVER dummydriver = {
55 "dummy", /* driver name */
56 DR_LOCAL|DR_MAIL, /* driver flags */
57 (DRIVER *) NIL, /* next driver */
58 dummy_valid, /* mailbox is valid for us */
59 dummy_parameters, /* manipulate parameters */
60 dummy_scan, /* scan mailboxes */
61 dummy_list, /* list mailboxes */
62 dummy_lsub, /* list subscribed mailboxes */
63 NIL, /* subscribe to mailbox */
64 NIL, /* unsubscribe from mailbox */
65 dummy_create, /* create mailbox */
66 dummy_delete, /* delete mailbox */
67 dummy_rename, /* rename mailbox */
68 mail_status_default, /* status of mailbox */
69 dummy_open, /* open mailbox */
70 dummy_close, /* close mailbox */
71 NIL, /* fetch message "fast" attributes */
72 NIL, /* fetch message flags */
73 NIL, /* fetch overview */
74 NIL, /* fetch message structure */
75 NIL, /* fetch header */
76 NIL, /* fetch text */
77 NIL, /* fetch message data */
78 NIL, /* unique identifier */
79 NIL, /* message number from UID */
80 NIL, /* modify flags */
81 NIL, /* per-message modify flags */
82 NIL, /* search for message based on criteria */
83 NIL, /* sort messages */
84 NIL, /* thread messages */
85 dummy_ping, /* ping mailbox to see if still alive */
86 dummy_check, /* check for new messages */
87 dummy_expunge, /* expunge deleted messages */
88 dummy_copy, /* copy messages to another mailbox */
89 dummy_append, /* append string message to mailbox */
90 NIL /* garbage collect stream */
91 };
94 /* prototype stream */
95 MAILSTREAM dummyproto = {&dummydriver};
97 /* Dummy validate mailbox
98 * Accepts: mailbox name
99 * Returns: our driver if name is valid, NIL otherwise
100 */
102 DRIVER *dummy_valid (char *name)
103 {
104 /* must be valid local mailbox */
105 return (name && *name && (*name != '{') && !compare_cstring (name,"INBOX")) ?
106 &dummydriver : NIL;
107 }
110 /* Dummy manipulate driver parameters
111 * Accepts: function code
112 * function-dependent value
113 * Returns: function-dependent return value
114 */
116 void *dummy_parameters (long function,void *value)
117 {
118 return NIL;
119 }
121 /* Dummy scan mailboxes
122 * Accepts: mail stream
123 * reference
124 * pattern to search
125 * string to scan
126 */
128 void dummy_scan (MAILSTREAM *stream,char *ref,char *pat,char *contents)
129 {
130 /* return silently */
131 }
134 /* Dummy list mailboxes
135 * Accepts: mail stream
136 * reference
137 * pattern to search
138 */
140 void dummy_list (MAILSTREAM *stream,char *ref,char *pat)
141 {
142 /* return silently */
143 }
146 /* Dummy list subscribed mailboxes
147 * Accepts: mail stream
148 * reference
149 * pattern to search
150 */
152 void dummy_lsub (MAILSTREAM *stream,char *ref,char *pat)
153 {
154 /* return silently */
155 }
157 /* Dummy create mailbox
158 * Accepts: mail stream
159 * mailbox name to create
160 * driver type to use
161 * Returns: T on success, NIL on failure
162 */
164 long dummy_create (MAILSTREAM *stream,char *mailbox)
165 {
166 return NIL; /* always fails */
167 }
170 /* Dummy delete mailbox
171 * Accepts: mail stream
172 * mailbox name to delete
173 * Returns: T on success, NIL on failure
174 */
176 long dummy_delete (MAILSTREAM *stream,char *mailbox)
177 {
178 return NIL; /* always fails */
179 }
182 /* Mail rename mailbox
183 * Accepts: mail stream
184 * old mailbox name
185 * new mailbox name
186 * Returns: T on success, NIL on failure
187 */
189 long dummy_rename (MAILSTREAM *stream,char *old,char *newname)
190 {
191 return NIL; /* always fails */
192 }
194 /* Dummy open
195 * Accepts: stream to open
196 * Returns: stream on success, NIL on failure
197 */
199 MAILSTREAM *dummy_open (MAILSTREAM *stream)
200 {
201 char tmp[MAILTMPLEN];
202 /* OP_PROTOTYPE call or silence */
203 if (!stream || stream->silent) return NIL;
204 if (compare_cstring (stream->mailbox,"INBOX")) {
205 sprintf (tmp,"Not a mailbox: %s",stream->mailbox);
206 mm_log (tmp,ERROR);
207 return NIL; /* always fails */
208 }
209 if (!stream->silent) { /* only if silence not requested */
210 mail_exists (stream,0); /* say there are 0 messages */
211 mail_recent (stream,0);
212 stream->uid_validity = time (0);
213 }
214 stream->inbox = T; /* note that it's an INBOX */
215 return stream; /* return success */
216 }
219 /* Dummy close
220 * Accepts: MAIL stream
221 * options
222 */
224 void dummy_close (MAILSTREAM *stream,long options)
225 {
226 /* return silently */
227 }
229 /* Dummy ping mailbox
230 * Accepts: MAIL stream
231 * Returns: T if stream alive, else NIL
232 * No-op for readonly files, since read/writer can expunge it from under us!
233 */
235 long dummy_ping (MAILSTREAM *stream)
236 {
237 return T;
238 }
241 /* Dummy check mailbox
242 * Accepts: MAIL stream
243 * No-op for readonly files, since read/writer can expunge it from under us!
244 */
246 void dummy_check (MAILSTREAM *stream)
247 {
248 dummy_ping (stream); /* invoke ping */
249 }
252 /* Dummy expunge mailbox
253 * Accepts: MAIL stream
254 * sequence to expunge if non-NIL
255 * expunge options
256 * Returns: T, always
257 */
259 long dummy_expunge (MAILSTREAM *stream,char *sequence,long options)
260 {
261 return LONGT;
262 }
264 /* Dummy copy message(s)
265 * Accepts: MAIL stream
266 * sequence
267 * destination mailbox
268 * options
269 * Returns: T if copy successful, else NIL
270 */
272 long dummy_copy (MAILSTREAM *stream,char *sequence,char *mailbox,long options)
273 {
274 if ((options & CP_UID) ? mail_uid_sequence (stream,sequence) :
275 mail_sequence (stream,sequence)) fatal ("Impossible dummy_copy");
276 return NIL;
277 }
280 /* Dummy append message string
281 * Accepts: mail stream
282 * destination mailbox
283 * append callback function
284 * data for callback
285 * Returns: T on success, NIL on failure
286 */
288 long dummy_append (MAILSTREAM *stream,char *mailbox,append_t af,void *data)
289 {
290 char tmp[MAILTMPLEN];
291 sprintf (tmp,"Can't append to %s",mailbox);
292 mm_log (tmp,ERROR); /* pass up error */
293 return NIL; /* always fails */
294 }

UW-IMAP'd extensions by yuuji