~ubuntu-branches/debian/stretch/alpine/stretch

« back to all changes in this revision

Viewing changes to imap/src/osdep/mac/dummymac.c

  • Committer: Bazaar Package Importer
  • Author(s): Asheesh Laroia
  • Date: 2007-02-17 13:17:42 UTC
  • Revision ID: james.westby@ubuntu.com-20070217131742-99x5c6cpg1pbkdhw
Tags: upstream-0.82+dfsg
ImportĀ upstreamĀ versionĀ 0.82+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 */
 
13
 
 
14
/*
 
15
 * Program:     Dummy routines for Mac
 
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
 */
 
28
 
 
29
 
 
30
#include <ctype.h>
 
31
#include <stdio.h>
 
32
#include "mail.h"
 
33
#include "osdep.h"
 
34
#include "dummy.h"
 
35
#include "misc.h"
 
36
 
 
37
/* Function prototypes */
 
38
 
 
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);
 
48
 
 
49
/* Dummy routines */
 
50
 
 
51
 
 
52
/* Driver dispatch used by MAIL */
 
53
 
 
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
};
 
92
 
 
93
 
 
94
                                /* prototype stream */
 
95
MAILSTREAM dummyproto = {&dummydriver};
 
96
 
 
97
/* Dummy validate mailbox
 
98
 * Accepts: mailbox name
 
99
 * Returns: our driver if name is valid, NIL otherwise
 
100
 */
 
101
 
 
102
DRIVER *dummy_valid (char *name)
 
103
{
 
104
  char tmp[MAILTMPLEN];
 
105
                                /* must be valid local mailbox */
 
106
  return (name && *name && (*name != '{') && !compare_cstring (name,"INBOX")) ?
 
107
    &dummydriver : NIL;
 
108
}
 
109
 
 
110
 
 
111
/* Dummy manipulate driver parameters
 
112
 * Accepts: function code
 
113
 *          function-dependent value
 
114
 * Returns: function-dependent return value
 
115
 */
 
116
 
 
117
void *dummy_parameters (long function,void *value)
 
118
{
 
119
  return NIL;
 
120
}
 
121
 
 
122
/* Dummy scan mailboxes
 
123
 * Accepts: mail stream
 
124
 *          reference
 
125
 *          pattern to search
 
126
 *          string to scan
 
127
 */
 
128
 
 
129
void dummy_scan (MAILSTREAM *stream,char *ref,char *pat,char *contents)
 
130
{
 
131
                                /* return silently */
 
132
}
 
133
 
 
134
 
 
135
/* Dummy list mailboxes
 
136
 * Accepts: mail stream
 
137
 *          reference
 
138
 *          pattern to search
 
139
 */
 
140
 
 
141
void dummy_list (MAILSTREAM *stream,char *ref,char *pat)
 
142
{
 
143
                                /* return silently */
 
144
}
 
145
 
 
146
 
 
147
/* Dummy list subscribed mailboxes
 
148
 * Accepts: mail stream
 
149
 *          reference
 
150
 *          pattern to search
 
151
 */
 
152
 
 
153
void dummy_lsub (MAILSTREAM *stream,char *ref,char *pat)
 
154
{
 
155
                                /* return silently */
 
156
}
 
157
 
 
158
/* Dummy create mailbox
 
159
 * Accepts: mail stream
 
160
 *          mailbox name to create
 
161
 *          driver type to use
 
162
 * Returns: T on success, NIL on failure
 
163
 */
 
164
 
 
165
long dummy_create (MAILSTREAM *stream,char *mailbox)
 
166
{
 
167
  return NIL;                   /* always fails */
 
168
}
 
169
 
 
170
 
 
171
/* Dummy delete mailbox
 
172
 * Accepts: mail stream
 
173
 *          mailbox name to delete
 
174
 * Returns: T on success, NIL on failure
 
175
 */
 
176
 
 
177
long dummy_delete (MAILSTREAM *stream,char *mailbox)
 
178
{
 
179
  return NIL;                   /* always fails */
 
180
}
 
181
 
 
182
 
 
183
/* Mail rename mailbox
 
184
 * Accepts: mail stream
 
185
 *          old mailbox name
 
186
 *          new mailbox name
 
187
 * Returns: T on success, NIL on failure
 
188
 */
 
189
 
 
190
long dummy_rename (MAILSTREAM *stream,char *old,char *newname)
 
191
{
 
192
  return NIL;                   /* always fails */
 
193
}
 
194
 
 
195
/* Dummy open
 
196
 * Accepts: stream to open
 
197
 * Returns: stream on success, NIL on failure
 
198
 */
 
199
 
 
200
MAILSTREAM *dummy_open (MAILSTREAM *stream)
 
201
{
 
202
  char tmp[MAILTMPLEN];
 
203
                                /* OP_PROTOTYPE call or silence */
 
204
  if (!stream || stream->silent) return NIL;
 
205
  if (compare_cstring (stream->mailbox,"INBOX")) {
 
206
    sprintf (tmp,"Not a mailbox: %s",stream->mailbox);
 
207
    mm_log (tmp,ERROR);
 
208
    return NIL;                 /* always fails */
 
209
  }
 
210
  if (!stream->silent) {        /* only if silence not requested */
 
211
    mail_exists (stream,0);     /* say there are 0 messages */
 
212
    mail_recent (stream,0);
 
213
    stream->uid_validity = time (0);
 
214
  }
 
215
  stream->inbox = T;            /* note that it's an INBOX */
 
216
  return stream;                /* return success */
 
217
}
 
218
 
 
219
 
 
220
/* Dummy close
 
221
 * Accepts: MAIL stream
 
222
 *          options
 
223
 */
 
224
 
 
225
void dummy_close (MAILSTREAM *stream,long options)
 
226
{
 
227
                                /* return silently */
 
228
}
 
229
 
 
230
/* Dummy ping mailbox
 
231
 * Accepts: MAIL stream
 
232
 * Returns: T if stream alive, else NIL
 
233
 * No-op for readonly files, since read/writer can expunge it from under us!
 
234
 */
 
235
 
 
236
long dummy_ping (MAILSTREAM *stream)
 
237
{
 
238
  return T;
 
239
}
 
240
 
 
241
 
 
242
/* Dummy check mailbox
 
243
 * Accepts: MAIL stream
 
244
 * No-op for readonly files, since read/writer can expunge it from under us!
 
245
 */
 
246
 
 
247
void dummy_check (MAILSTREAM *stream)
 
248
{
 
249
  dummy_ping (stream);          /* invoke ping */
 
250
}
 
251
 
 
252
 
 
253
/* Dummy expunge mailbox
 
254
 * Accepts: MAIL stream
 
255
 *          sequence to expunge if non-NIL
 
256
 *          expunge options
 
257
 * Returns: T, always
 
258
 */
 
259
 
 
260
long dummy_expunge (MAILSTREAM *stream,char *sequence,long options)
 
261
{
 
262
  return LONGT;
 
263
}
 
264
 
 
265
/* Dummy copy message(s)
 
266
 * Accepts: MAIL stream
 
267
 *          sequence
 
268
 *          destination mailbox
 
269
 *          options
 
270
 * Returns: T if copy successful, else NIL
 
271
 */
 
272
 
 
273
long dummy_copy (MAILSTREAM *stream,char *sequence,char *mailbox,long options)
 
274
{
 
275
  if ((options & CP_UID) ? mail_uid_sequence (stream,sequence) :
 
276
      mail_sequence (stream,sequence)) fatal ("Impossible dummy_copy");
 
277
  return NIL;
 
278
}
 
279
 
 
280
 
 
281
/* Dummy append message string
 
282
 * Accepts: mail stream
 
283
 *          destination mailbox
 
284
 *          append callback function
 
285
 *          data for callback
 
286
 * Returns: T on success, NIL on failure
 
287
 */
 
288
 
 
289
long dummy_append (MAILSTREAM *stream,char *mailbox,append_t af,void *data)
 
290
{
 
291
  char tmp[MAILTMPLEN];
 
292
  sprintf (tmp,"Can't append to %s",mailbox);
 
293
  mm_log (tmp,ERROR);           /* pass up error */
 
294
  return NIL;                   /* always fails */
 
295
}