home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / pine / imap-3.0 / ANSI / c-client / imap2.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-19  |  8.7 KB  |  224 lines

  1. /*
  2.  * Program:    Interactive Mail Access Protocol 2 (IMAP2) routines
  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:    15 June 1988
  13.  * Last Edited:    19 June 1993
  14.  *
  15.  * Sponsorship:    The original version of this work was developed in the
  16.  *        Symbolic Systems Resources Group of the Knowledge Systems
  17.  *        Laboratory at Stanford University in 1987-88, and was funded
  18.  *        by the Biomedical Research Technology Program of the National
  19.  *        Institutes of Health under grant number RR-00785.
  20.  *
  21.  * Original version Copyright 1988 by The Leland Stanford Junior University
  22.  * Copyright 1993 by the University of Washington
  23.  *
  24.  *  Permission to use, copy, modify, and distribute this software and its
  25.  * documentation for any purpose and without fee is hereby granted, provided
  26.  * that the above copyright notices appear in all copies and that both the
  27.  * above copyright notices and this permission notice appear in supporting
  28.  * documentation, and that the name of the University of Washington or The
  29.  * Leland Stanford Junior University not be used in advertising or publicity
  30.  * pertaining to distribution of the software without specific, written prior
  31.  * permission.  This software is made available "as is", and
  32.  * THE UNIVERSITY OF WASHINGTON AND THE LELAND STANFORD JUNIOR UNIVERSITY
  33.  * DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, WITH REGARD TO THIS SOFTWARE,
  34.  * INCLUDING WITHOUT LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  35.  * FITNESS FOR A PARTICULAR PURPOSE, AND IN NO EVENT SHALL THE UNIVERSITY OF
  36.  * WASHINGTON OR THE LELAND STANFORD JUNIOR UNIVERSITY BE LIABLE FOR ANY
  37.  * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
  38.  * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
  39.  * CONTRACT, TORT (INCLUDING NEGLIGENCE) OR STRICT LIABILITY, ARISING OUT OF
  40.  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  41.  *
  42.  */
  43.  
  44. /* Parameters */
  45.  
  46. #define MAXLOGINTRIALS 3    /* maximum number of login trials */
  47. #define SET_MAXLOGINTRIALS 100
  48. #define GET_MAXLOGINTRIALS 101
  49. #define MAPLOOKAHEAD 20        /* fetch lookahead */
  50. #define SET_LOOKAHEAD 102
  51. #define GET_LOOKAHEAD 103
  52. #define IMAPTCPPORT 143        /* assigned TCP contact port */
  53. #define SET_PORT 104
  54. #define GET_PORT 105
  55.  
  56.  
  57. /* IMAP2 specific definitions */
  58.  
  59.  
  60. /* Parsed reply message from imap_reply */
  61.  
  62. typedef struct imap_parsed_reply {
  63.   char *line;            /* original reply string pointer */
  64.   char *tag;            /* command tag this reply is for */
  65.   char *key;            /* reply keyword */
  66.   char *text;            /* subsequent text */
  67. } IMAPPARSEDREPLY;
  68.  
  69.  
  70. #define IMAPTMPLEN 16*MAILTMPLEN
  71.  
  72. /* IMAP2 I/O stream local data */
  73.     
  74. typedef struct imap_local {
  75.   void *tcpstream;        /* TCP I/O stream */
  76.   IMAPPARSEDREPLY reply;    /* last parsed reply */
  77.   unsigned int use_body : 1;    /* server supports structured bodies */
  78.   unsigned int use_find : 1;    /* server supports FIND command */
  79.   unsigned int use_bboard : 1;    /* server supports BBOARD command */
  80.   unsigned int use_purge : 1;    /* server supports PURGE command */
  81.   char *prefix;            /* find prefix */
  82.   char tmp[IMAPTMPLEN];        /* temporary buffer */
  83. } IMAPLOCAL;
  84.  
  85.  
  86. /* Convenient access to local data */
  87.  
  88. #define LOCAL ((IMAPLOCAL *) stream->local)
  89.  
  90. /* Coddle certain compilers' 6-character symbol limitation */
  91.  
  92. #ifdef __COMPILER_KCC__
  93. #define map_valid ivalid
  94. #define map_parameters iparam
  95. #define map_find ifind
  96. #define map_find_bboards ifindb
  97. #define map_find_all ifnda
  98. #define map_find_all_bboards ifndab
  99. #define map_subscribe isubsc
  100. #define map_unsubscribe iunsub
  101. #define map_subscribe_bboard isubbb
  102. #define map_unsubscribe_bboard iusbbb
  103. #define map_create icreat
  104. #define map_delete idelet
  105. #define map_rename irenam
  106. #define map_manage imanag
  107. #define map_open iopen
  108. #define map_close iclose
  109. #define map_fetchfast iffast
  110. #define map_fetchflags ifflags
  111. #define map_fetchstructure ifenv
  112. #define map_fetchheader ifhead
  113. #define map_fetchtext iftext
  114. #define map_fetchbody ifbody
  115. #define map_setflag isflag
  116. #define map_clearflag icflag
  117. #define map_search isearch
  118. #define map_ping iping
  119. #define map_check icheck
  120. #define map_expunge iexpun
  121. #define map_copy icopy
  122. #define map_move imove
  123. #define map_append iappnd
  124. #define map_gc igc
  125. #define map_do_gc idogc
  126. #define map_gc_body igcb
  127.  
  128. #define imap_host imhost
  129. #define imap_select imsele
  130. #define imap_send imsend
  131. #define imap_send_literal imsndl
  132. #define imap_reply imrepl
  133. #define imap_parse_reply imprep
  134. #define imap_fake imfake
  135. #define imap_OK imok
  136. #define imap_parse_unsolicited impuns
  137. #define imap_parse_flaglst impflg
  138. #define imap_searched imsear
  139. #define imap_expunged imexpu
  140. #define imap_parse_data impdat
  141. #define imap_parse_prop imppro
  142. #define imap_parse_envelope impenv
  143. #define imap_parse_adrlist impadl
  144. #define imap_parse_address impadr
  145. #define imap_parse_flags impfla
  146. #define imap_parse_sys_flag impsfl
  147. #define imap_parse_user_flag impufl
  148. #define imap_parse_string impstr
  149. #define imap_parse_number impnum
  150. #define imap_parse_enclist impecl
  151. #define imap_parse_encoding impenc
  152. #define imap_parse_body impbod
  153. #define imap_parse_body_structure impbst
  154. #endif
  155.  
  156. /* Function prototypes */
  157.  
  158. DRIVER *map_valid (char *name);
  159. void *map_parameters (long function,void *value);
  160. void map_find (MAILSTREAM *stream,char *pat);
  161. void map_find_bboards (MAILSTREAM *stream,char *pat);
  162. void map_find_all (MAILSTREAM *stream,char *pat);
  163. void map_find_all_bboards (MAILSTREAM *stream,char *pat);
  164. long map_subscribe (MAILSTREAM *stream,char *mailbox);
  165. long map_unsubscribe (MAILSTREAM *stream,char *mailbox);
  166. long map_subscribe_bboard (MAILSTREAM *stream,char *mailbox);
  167. long map_unsubscribe_bboard (MAILSTREAM *stream,char *mailbox);
  168. long map_create (MAILSTREAM *stream,char *mailbox);
  169. long map_delete (MAILSTREAM *stream,char *mailbox);
  170. long map_rename (MAILSTREAM *stream,char *old,char *new);
  171. long map_manage (MAILSTREAM *stream,char *mailbox,char *command,char *arg2);
  172. MAILSTREAM *map_open (MAILSTREAM *stream);
  173. void map_close (MAILSTREAM *stream);
  174. void map_fetchfast (MAILSTREAM *stream,char *sequence);
  175. void map_fetchflags (MAILSTREAM *stream,char *sequence);
  176. ENVELOPE *map_fetchstructure (MAILSTREAM *stream,long msgno,BODY **body);
  177. char *map_fetchheader (MAILSTREAM *stream,long msgno);
  178. char *map_fetchtext (MAILSTREAM *stream,long msgno);
  179. char *map_fetchbody (MAILSTREAM *stream,long m,char *sec,unsigned long *len);
  180. void map_setflag (MAILSTREAM *stream,char *sequence,char *flag);
  181. void map_clearflag (MAILSTREAM *stream,char *sequence,char *flag);
  182. void map_search (MAILSTREAM *stream,char *criteria);
  183. long map_ping (MAILSTREAM *stream);
  184. void map_check (MAILSTREAM *stream);
  185. void map_expunge (MAILSTREAM *stream);
  186. long map_copy (MAILSTREAM *stream,char *sequence,char *mailbox);
  187. long map_move (MAILSTREAM *stream,char *sequence,char *mailbox);
  188. long map_append (MAILSTREAM *stream,char *mailbox,STRING *message);
  189. void map_gc (MAILSTREAM *stream,long gcflags);
  190. void map_do_gc (MAILSTREAM *stream,long gcflags);
  191. void map_gc_body (BODY *body);
  192.  
  193. char *imap_host (MAILSTREAM *stream);
  194. IMAPPARSEDREPLY *imap_send (MAILSTREAM *stream,char *cmd,char *arg,char *arg2);
  195. IMAPPARSEDREPLY *imap_send_literal (MAILSTREAM *stream,char *cmd,char *arg,
  196.                     STRING *arg2);
  197. IMAPPARSEDREPLY *imap_reply (MAILSTREAM *stream,char *tag);
  198. IMAPPARSEDREPLY *imap_parse_reply (MAILSTREAM *stream,char *text);
  199. IMAPPARSEDREPLY *imap_fake (MAILSTREAM *stream,char *tag,char *text);
  200. long imap_OK (MAILSTREAM *stream,IMAPPARSEDREPLY *reply);
  201. void imap_parse_unsolicited (MAILSTREAM *stream,IMAPPARSEDREPLY *reply);
  202. void imap_parse_flaglst (MAILSTREAM *stream,IMAPPARSEDREPLY *reply);
  203. void imap_searched (MAILSTREAM *stream,char *text);
  204. void imap_expunged (MAILSTREAM *stream,long msgno);
  205. void imap_parse_data (MAILSTREAM *stream,long msgno,char *text,
  206.               IMAPPARSEDREPLY *reply);
  207. void imap_parse_prop (MAILSTREAM *stream,MESSAGECACHE *elt,char *prop,
  208.               char **txtptr,IMAPPARSEDREPLY *reply);
  209. void imap_parse_envelope (MAILSTREAM *stream,ENVELOPE **env,char **txtptr,
  210.               IMAPPARSEDREPLY *reply);
  211. ADDRESS *imap_parse_adrlist (MAILSTREAM *stream,char **txtptr,
  212.                  IMAPPARSEDREPLY *reply);
  213. ADDRESS *imap_parse_address (MAILSTREAM *stream,char **txtptr,
  214.                  IMAPPARSEDREPLY *reply);
  215. void imap_parse_flags (MAILSTREAM *stream,MESSAGECACHE *elt,char **txtptr);
  216. void imap_parse_user_flag (MAILSTREAM *stream,MESSAGECACHE *elt,char *flag);
  217. char *imap_parse_string (MAILSTREAM *stream,char **txtptr,
  218.              IMAPPARSEDREPLY *reply,long special);
  219. unsigned long imap_parse_number (MAILSTREAM *stream,char **txtptr);
  220. void imap_parse_body (MAILSTREAM *stream,long msgno,BODY **body,char *seg,
  221.               char **txtptr,IMAPPARSEDREPLY *reply);
  222. void imap_parse_body_structure (MAILSTREAM *stream,BODY *body,char **txtptr,
  223.                 IMAPPARSEDREPLY *reply);
  224.