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 / wce / dummywce.c < prev    next >
C/C++ Source or Header  |  1998-09-16  |  9KB  |  340 lines

  1. /*
  2.  * Program:    Dummy routines for WCE
  3.  *
  4.  * Author:    Mark Crispin
  5.  *        Networks and Distributed Computing
  6.  *        Computing & Communications
  7.  *        University of Washington
  8.  *        Administration Building, AG-44
  9.  *        Seattle, WA  98195
  10.  *        Internet: MRC@CAC.Washington.EDU
  11.  *
  12.  * Date:    24 May 1993
  13.  * Last Edited:    18 May 1998
  14.  *
  15.  * Copyright 1998 by the University of Washington
  16.  *
  17.  *  Permission to use, copy, modify, and distribute this software and its
  18.  * documentation for any purpose and without fee is hereby granted, provided
  19.  * that the above copyright notice appears in all copies and that both the
  20.  * above copyright notice and this permission notice appear in supporting
  21.  * documentation, and that the name of the University of Washington not be
  22.  * used in advertising or publicity pertaining to distribution of the software
  23.  * without specific, written prior permission.  This software is made
  24.  * available "as is", and
  25.  * THE UNIVERSITY OF WASHINGTON DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED,
  26.  * WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT LIMITATION ALL IMPLIED
  27.  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, AND IN
  28.  * NO EVENT SHALL THE UNIVERSITY OF WASHINGTON BE LIABLE FOR ANY SPECIAL,
  29.  * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  30.  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, TORT
  31.  * (INCLUDING NEGLIGENCE) OR STRICT LIABILITY, ARISING OUT OF OR IN CONNECTION
  32.  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  33.  *
  34.  */
  35.  
  36.  
  37. #include <ctype.h>
  38. #include <stdio.h>
  39. #include <errno.h>
  40. #include <fcntl.h>
  41. #include <direct.h>
  42. #include "mail.h"
  43. #include "osdep.h"
  44. #include <sys\stat.h>
  45. #include <dos.h>
  46. #include "dummy.h"
  47. #include "misc.h"
  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.   NIL,                /* 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.                 /* driver parameters */
  98. static char *file_extension = NIL;
  99.  
  100. /* Dummy validate mailbox
  101.  * Accepts: mailbox name
  102.  * Returns: our driver if name is valid, NIL otherwise
  103.  */
  104.  
  105. DRIVER *dummy_valid (char *name)
  106. {
  107.   char *s,tmp[MAILTMPLEN];
  108.   struct stat sbuf;
  109.                 /* must be valid local mailbox */
  110.   return (name && *name && (*name != '{') &&
  111.       (s = mailboxfile (tmp,name)) && (!*s || !stat (s,&sbuf))) ?
  112.         &dummydriver : NIL;
  113. }
  114.  
  115.  
  116. /* Dummy manipulate driver parameters
  117.  * Accepts: function code
  118.  *        function-dependent value
  119.  * Returns: function-dependent return value
  120.  */
  121.  
  122. void *dummy_parameters (long function,void *value)
  123. {
  124.   return value;
  125. }
  126.  
  127. /* Dummy scan mailboxes
  128.  * Accepts: mail stream
  129.  *        reference
  130.  *        pattern to search
  131.  *        string to scan
  132.  */
  133.  
  134. void dummy_scan (MAILSTREAM *stream,char *ref,char *pat,char *contents)
  135. {
  136.                 /* return silently */
  137. }
  138.  
  139. /* Dummy list mailboxes
  140.  * Accepts: mail stream
  141.  *        reference
  142.  *        pattern to search
  143.  */
  144.  
  145. void dummy_list (MAILSTREAM *stream,char *ref,char *pat)
  146. {
  147.                 /* return silently */
  148. }
  149.  
  150.  
  151. /* Dummy list subscribed mailboxes
  152.  * Accepts: mail stream
  153.  *        pattern to search
  154.  */
  155.  
  156. void dummy_lsub (MAILSTREAM *stream,char *ref,char *pat)
  157. {
  158.                 /* return silently */
  159. }
  160.  
  161. /* Dummy create mailbox
  162.  * Accepts: mail stream
  163.  *        mailbox name to create
  164.  * Returns: T on success, NIL on failure
  165.  */
  166.  
  167. long dummy_create (MAILSTREAM *stream,char *mailbox)
  168. {
  169.   return NIL;            /* always fails */
  170. }
  171.  
  172.  
  173. /* Dummy delete mailbox
  174.  * Accepts: mail stream
  175.  *        mailbox name to delete
  176.  * Returns: T on success, NIL on failure
  177.  */
  178.  
  179. long dummy_delete (MAILSTREAM *stream,char *mailbox)
  180. {
  181.   return NIL;            /* always fails */
  182. }
  183.  
  184.  
  185. /* Mail rename mailbox
  186.  * Accepts: mail stream
  187.  *        old mailbox name
  188.  *        new mailbox name
  189.  * Returns: T on success, NIL on failure
  190.  */
  191.  
  192. long dummy_rename (MAILSTREAM *stream,char *old,char *newname)
  193. {
  194.   return NIL;            /* always fails */
  195. }
  196.  
  197. /* Dummy open
  198.  * Accepts: stream to open
  199.  * Returns: stream on success, NIL on failure
  200.  */
  201.  
  202. MAILSTREAM *dummy_open (MAILSTREAM *stream)
  203. {
  204.   char tmp[MAILTMPLEN];
  205.                 /* OP_PROTOTYPE call or silence */
  206.   if (!stream || stream->silent) return NIL;
  207.   if (strcmp (ucase (strcpy (tmp,stream->mailbox)),"INBOX")) {
  208.     sprintf (tmp,"Not a mailbox: %s",stream->mailbox);
  209.     mm_log (tmp,ERROR);
  210.     return NIL;            /* always fails */
  211.   }
  212.   if (!stream->silent) {    /* only if silence not requested */
  213.     mail_exists (stream,0);    /* say there are 0 messages */
  214.     mail_recent (stream,0);
  215.     stream->uid_validity = 1;
  216.   }
  217.   return stream;        /* return success */
  218. }
  219.  
  220.  
  221. /* Dummy close
  222.  * Accepts: MAIL stream
  223.  *        options
  224.  */
  225.  
  226. void dummy_close (MAILSTREAM *stream,long options)
  227. {
  228.                 /* return silently */
  229. }
  230.  
  231. /* Dummy ping mailbox
  232.  * Accepts: MAIL stream
  233.  * Returns: T if stream alive, else NIL
  234.  * No-op for readonly files, since read/writer can expunge it from under us!
  235.  */
  236.  
  237. long dummy_ping (MAILSTREAM *stream)
  238. {
  239.   return T;
  240. }
  241.  
  242.  
  243. /* Dummy check mailbox
  244.  * Accepts: MAIL stream
  245.  * No-op for readonly files, since read/writer can expunge it from under us!
  246.  */
  247.  
  248. void dummy_check (MAILSTREAM *stream)
  249. {
  250.   dummy_ping (stream);        /* invoke ping */
  251. }
  252.  
  253.  
  254. /* Dummy expunge mailbox
  255.  * Accepts: MAIL stream
  256.  */
  257.  
  258. void dummy_expunge (MAILSTREAM *stream)
  259. {
  260.                 /* return silently */
  261. }
  262.  
  263. /* Dummy copy message(s)
  264.  * Accepts: MAIL stream
  265.  *        sequence
  266.  *        destination mailbox
  267.  *        options
  268.  * Returns: T if copy successful, else NIL
  269.  */
  270.  
  271. long dummy_copy (MAILSTREAM *stream,char *sequence,char *mailbox,long options)
  272. {
  273.   if ((options & CP_UID) ? mail_uid_sequence (stream,sequence) :
  274.       mail_sequence (stream,sequence)) fatal ("Impossible dummy_copy");
  275.   return NIL;
  276. }
  277.  
  278.  
  279. /* Dummy append message string
  280.  * Accepts: mail stream
  281.  *        destination mailbox
  282.  *        stringstruct of message to append
  283.  * Returns: T on success, NIL on failure
  284.  */
  285.  
  286. long dummy_append (MAILSTREAM *stream,char *mailbox,char *flags,char *date,
  287.            STRING *message)
  288. {
  289.   char tmp[MAILTMPLEN];
  290.   sprintf (tmp,"Can't append to %s",mailbox);
  291.   mm_log (tmp,ERROR);        /* pass up error */
  292.   return NIL;            /* always fails */
  293. }
  294.  
  295. /* Dummy canonicalize name
  296.  * Accepts: buffer to write name
  297.  *        reference
  298.  *        pattern
  299.  * Returns: T if success, NIL if failure
  300.  */
  301.  
  302. long dummy_canonicalize (char *tmp,char *ref,char *pat)
  303. {
  304.   char dev[4];
  305.                 /* initially no device */
  306.   dev[0] = dev[1] = dev[2] = dev[3] = '\0';
  307.   if (ref) switch (*ref) {    /* preliminary reference check */
  308.   case '{':            /* remote names not allowed */
  309.     return NIL;            /* disallowed */
  310.   case '\0':            /* empty reference string */
  311.     break;
  312.   default:            /* all other names */
  313.     if (ref[1] == ':') {    /* start with device name? */
  314.       dev[0] = *ref++; dev[1] = *ref++;
  315.     }
  316.     break;
  317.   }
  318.   if (pat[1] == ':') {        /* device name in pattern? */
  319.     dev[0] = *pat++; dev[1] = *pat++;
  320.     ref = NIL;            /* ignore reference */
  321.   }
  322.   switch (*pat) {
  323.   case '#':            /* namespace names */
  324.     if (mailboxfile (tmp,pat)) strcpy (tmp,pat);
  325.     else return NIL;        /* unknown namespace */
  326.     break;
  327.   case '{':            /* remote names not allowed */
  328.     return NIL;
  329.   case '\\':            /* rooted name */
  330.     ref = NIL;            /* ignore reference */
  331.     break;
  332.   }
  333.                 /* make sure device names are rooted */
  334.   if (dev[0] && (*(ref ? ref : pat) != '\\')) dev[2] = '\\';
  335.                 /* build name */
  336.   sprintf (tmp,"%s%s%s",dev,ref ? ref : "",pat);
  337.   ucase (tmp);            /* force upper case */
  338.   return T;
  339. }
  340.