home *** CD-ROM | disk | FTP | other *** search
/ ftp.uv.es / 2014.11.ftp.uv.es.tar / ftp.uv.es / pub / unix / pine4.10.tar.gz / pine4.10.tar / pine4.10 / imap / src / osdep / mac / dummymac.c < prev    next >
C/C++ Source or Header  |  1998-09-16  |  8KB  |  303 lines

  1. /*
  2.  * Program:    Dummy routines for Mac
  3.  *
  4.  * Author:    Mark Crispin
  5.  *        6158 Lariat Loop NE
  6.  *        Bainbridge Island, WA  98110-2098
  7.  *        Internet: MRC@Panda.COM
  8.  *
  9.  * Date:    24 May 1993
  10.  * Last Edited:    18 May 1998
  11.  *
  12.  * Copyright 1998 by Mark Crispin
  13.  *
  14.  *  Permission to use, copy, modify, and distribute this software and its
  15.  * documentation for any purpose and without fee is hereby granted, provided
  16.  * that the above copyright notice appears in all copies and that both the
  17.  * above copyright notices and this permission notice appear in supporting
  18.  * documentation, and that the name of Mark Crispin not be used in advertising
  19.  * or publicity pertaining to distribution of the software without specific,
  20.  * written prior permission.  This software is made available "as is", and
  21.  * MARK CRISPIN DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, WITH REGARD TO
  22.  * THIS SOFTWARE, INCLUDING WITHOUT LIMITATION ALL IMPLIED WARRANTIES OF
  23.  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, AND IN NO EVENT SHALL
  24.  * MARK CRISPIN BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES
  25.  * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  26.  * WHETHER IN AN ACTION OF CONTRACT, TORT (INCLUDING NEGLIGENCE) OR STRICT
  27.  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
  28.  * THIS SOFTWARE.
  29.  *
  30.  */
  31.  
  32.  
  33. #include <ctype.h>
  34. #include <stdio.h>
  35. #include "mail.h"
  36. #include "osdep.h"
  37. #include "dummy.h"
  38. #include "misc.h"
  39.  
  40. /* Dummy routines */
  41.  
  42.  
  43. /* Driver dispatch used by MAIL */
  44.  
  45. DRIVER dummydriver = {
  46.   "dummy",            /* driver name */
  47.   DR_LOCAL|DR_MAIL,        /* driver flags */
  48.   (DRIVER *) NIL,        /* next driver */
  49.   dummy_valid,            /* mailbox is valid for us */
  50.   dummy_parameters,        /* manipulate parameters */
  51.   dummy_scan,            /* scan mailboxes */
  52.   dummy_list,            /* list mailboxes */
  53.   dummy_lsub,            /* list subscribed mailboxes */
  54.   NIL,                /* subscribe to mailbox */
  55.   NIL,                /* unsubscribe from mailbox */
  56.   dummy_create,            /* create mailbox */
  57.   dummy_delete,            /* delete mailbox */
  58.   dummy_rename,            /* rename mailbox */
  59.   NIL,                /* status of mailbox */
  60.   dummy_open,            /* open mailbox */
  61.   dummy_close,            /* close mailbox */
  62.   NIL,                /* fetch message "fast" attributes */
  63.   NIL,                /* fetch message flags */
  64.   NIL,                /* fetch overview */
  65.   NIL,                /* fetch message structure */
  66.   NIL,                /* fetch header */
  67.   NIL,                /* fetch text */
  68.   NIL,                /* fetch message data */
  69.   NIL,                /* unique identifier */
  70.   NIL,                /* message number from UID */
  71.   NIL,                /* modify flags */
  72.   NIL,                /* per-message modify flags */
  73.   NIL,                /* search for message based on criteria */
  74.   NIL,                /* sort messages */
  75.   NIL,                /* thread messages */
  76.   dummy_ping,            /* ping mailbox to see if still alive */
  77.   dummy_check,            /* check for new messages */
  78.   dummy_expunge,        /* expunge deleted messages */
  79.   dummy_copy,            /* copy messages to another mailbox */
  80.   dummy_append,            /* append string message to mailbox */
  81.   NIL                /* garbage collect stream */
  82. };
  83.  
  84.  
  85.                 /* prototype stream */
  86. MAILSTREAM dummyproto = {&dummydriver};
  87.  
  88. /* Dummy validate mailbox
  89.  * Accepts: mailbox name
  90.  * Returns: our driver if name is valid, NIL otherwise
  91.  */
  92.  
  93. DRIVER *dummy_valid (char *name)
  94. {
  95.   char tmp[MAILTMPLEN];
  96.                 /* must be valid local mailbox */
  97.   return (name && *name && (*name != '{') &&
  98.                 /* INBOX is always accepted */
  99.       ((!strcmp (ucase (strcpy (tmp,name)),"INBOX"))))
  100.     ? &dummydriver : NIL;
  101. }
  102.  
  103.  
  104. /* Dummy manipulate driver parameters
  105.  * Accepts: function code
  106.  *        function-dependent value
  107.  * Returns: function-dependent return value
  108.  */
  109.  
  110. void *dummy_parameters (long function,void *value)
  111. {
  112.   return NIL;
  113. }
  114.  
  115. /* Dummy scan mailboxes
  116.  * Accepts: mail stream
  117.  *        reference
  118.  *        pattern to search
  119.  *        string to scan
  120.  */
  121.  
  122. void dummy_scan (MAILSTREAM *stream,char *ref,char *pat,char *contents)
  123. {
  124.                 /* return silently */
  125. }
  126.  
  127.  
  128. /* Dummy list mailboxes
  129.  * Accepts: mail stream
  130.  *        reference
  131.  *        pattern to search
  132.  */
  133.  
  134. void dummy_list (MAILSTREAM *stream,char *ref,char *pat)
  135. {
  136.                 /* return silently */
  137. }
  138.  
  139.  
  140. /* Dummy list subscribed mailboxes
  141.  * Accepts: mail stream
  142.  *        reference
  143.  *        pattern to search
  144.  */
  145.  
  146. void dummy_lsub (MAILSTREAM *stream,char *ref,char *pat)
  147. {
  148.                 /* return silently */
  149. }
  150.  
  151. /* Dummy create mailbox
  152.  * Accepts: mail stream
  153.  *        mailbox name to create
  154.  *        driver type to use
  155.  * Returns: T on success, NIL on failure
  156.  */
  157.  
  158. long dummy_create (MAILSTREAM *stream,char *mailbox)
  159. {
  160.   return NIL;            /* always fails */
  161. }
  162.  
  163.  
  164. /* Dummy delete mailbox
  165.  * Accepts: mail stream
  166.  *        mailbox name to delete
  167.  * Returns: T on success, NIL on failure
  168.  */
  169.  
  170. long dummy_delete (MAILSTREAM *stream,char *mailbox)
  171. {
  172.   return NIL;            /* always fails */
  173. }
  174.  
  175.  
  176. /* Mail rename mailbox
  177.  * Accepts: mail stream
  178.  *        old mailbox name
  179.  *        new mailbox name
  180.  * Returns: T on success, NIL on failure
  181.  */
  182.  
  183. long dummy_rename (MAILSTREAM *stream,char *old,char *newname)
  184. {
  185.   return NIL;            /* always fails */
  186. }
  187.  
  188. /* Dummy open
  189.  * Accepts: stream to open
  190.  * Returns: stream on success, NIL on failure
  191.  */
  192.  
  193. MAILSTREAM *dummy_open (MAILSTREAM *stream)
  194. {
  195.   char tmp[MAILTMPLEN];
  196.                 /* OP_PROTOTYPE call or silence */
  197.   if (!stream || stream->silent) return NIL;
  198.   if (strcmp (ucase (strcpy (tmp,stream->mailbox)),"INBOX")) {
  199.     sprintf (tmp,"Not a mailbox: %s",stream->mailbox);
  200.     mm_log (tmp,ERROR);
  201.     return NIL;            /* always fails */
  202.   }
  203.   if (!stream->silent) {    /* only if silence not requested */
  204.     mail_exists (stream,0);    /* say there are 0 messages */
  205.     mail_recent (stream,0);
  206.     stream->uid_validity = 1;
  207.   }
  208.   return stream;        /* return success */
  209. }
  210.  
  211.  
  212. /* Dummy close
  213.  * Accepts: MAIL stream
  214.  *        options
  215.  */
  216.  
  217. void dummy_close (MAILSTREAM *stream,long options)
  218. {
  219.                 /* return silently */
  220. }
  221.  
  222. /* Dummy ping mailbox
  223.  * Accepts: MAIL stream
  224.  * Returns: T if stream alive, else NIL
  225.  * No-op for readonly files, since read/writer can expunge it from under us!
  226.  */
  227.  
  228. long dummy_ping (MAILSTREAM *stream)
  229. {
  230.   return T;
  231. }
  232.  
  233.  
  234. /* Dummy check mailbox
  235.  * Accepts: MAIL stream
  236.  * No-op for readonly files, since read/writer can expunge it from under us!
  237.  */
  238.  
  239. void dummy_check (MAILSTREAM *stream)
  240. {
  241.   dummy_ping (stream);        /* invoke ping */
  242. }
  243.  
  244.  
  245. /* Dummy expunge mailbox
  246.  * Accepts: MAIL stream
  247.  */
  248.  
  249. void dummy_expunge (MAILSTREAM *stream)
  250. {
  251.                 /* return silently */
  252. }
  253.  
  254. /* Dummy copy message(s)
  255.  * Accepts: MAIL stream
  256.  *        sequence
  257.  *        destination mailbox
  258.  *        options
  259.  * Returns: T if copy successful, else NIL
  260.  */
  261.  
  262. long dummy_copy (MAILSTREAM *stream,char *sequence,char *mailbox,long options)
  263. {
  264.   if ((options & CP_UID) ? mail_uid_sequence (stream,sequence) :
  265.       mail_sequence (stream,sequence)) fatal ("Impossible dummy_copy");
  266.   return NIL;
  267. }
  268.  
  269.  
  270. /* Dummy append message string
  271.  * Accepts: mail stream
  272.  *        destination mailbox
  273.  *        optional flags
  274.  *        optional date
  275.  *        stringstruct of message to append
  276.  * Returns: T on success, NIL on failure
  277.  */
  278.  
  279. long dummy_append (MAILSTREAM *stream,char *mailbox,char *flags,char *date,
  280.            STRING *message)
  281. {
  282.   char tmp[MAILTMPLEN];
  283.   sprintf (tmp,"Can't append to %s",mailbox);
  284.   mm_log (tmp,ERROR);        /* pass up error */
  285.   return NIL;            /* always fails */
  286. }
  287.  
  288. /* Dummy canonicalize name
  289.  * Accepts: buffer to write name
  290.  *        reference
  291.  *        pattern
  292.  * Returns: T if success, NIL if failure
  293.  */
  294.  
  295. long dummy_canonicalize (char *tmp,char *ref,char *pat)
  296. {
  297.   if (*pat == '{' || (ref && (*ref == '{'))) return NIL;
  298.                 /* write name with reference */
  299.   if (ref && *ref) sprintf (tmp,"%s%s",ref,pat);
  300.   else strcpy (tmp,pat);    /* ignore reference, only need mailbox name */
  301.   return T;
  302. }
  303.