* More complex cache handling for IMAP fetch operations -- now we can
[citadel.git] / citadel / serv_imap.h
1 /* $Id$ 
2  */
3
4
5 void imap_cleanup_function(void);
6 void imap_greeting(void);
7 void imap_command_loop(void);
8 int imap_grabroom(char *returned_roomname, char *foldername, int zapped_ok);
9 void imap_free_transmitted_message(void);
10 int imap_do_expunge(void);
11
12
13 struct citimap {
14         int authstate;
15         char authseq[SIZ];
16         int selected;                   /* set to 1 if in the SELECTED state */
17         int readonly;                   /* mailbox is open read only */
18         int num_msgs;                   /* Number of messages being mapped */
19         int num_alloc;                  /* Number of messages for which we've allocated space */
20         time_t last_mtime;              /* For checking whether the room was modified... */
21         long *msgids;
22         unsigned int *flags;
23         char *transmitted_message;      /* for APPEND command... */
24         size_t transmitted_length;
25
26         /* Cache most recent RFC822 FETCH because client might load in pieces */
27         char *cached_rfc822_data;
28         long cached_rfc822_msgnum;
29         size_t cached_rfc822_len;
30         char cached_rfc822_withbody;    /* 1 = body cached; 0 = only headers cached */
31
32         /* Cache most recent BODY FETCH because client might load in pieces */
33         char *cached_body;
34         size_t cached_body_len;
35         char cached_bodypart[SIZ];
36         long cached_bodymsgnum;
37         char cached_body_withbody;      /* 1 = body cached; 0 = only headers cached */
38 };
39
40 /*
41  * values of 'authstate'
42  */
43 enum {
44         imap_as_normal,
45         imap_as_expecting_username,
46         imap_as_expecting_password
47 };
48
49 /* Flags for the above struct.  Note that some of these are for internal use,
50  * and are not to be reported to IMAP clients.
51  */
52 #define IMAP_ANSWERED           1       /* reportable and setable */
53 #define IMAP_FLAGGED            2       /* reportable and setable */
54 #define IMAP_DELETED            4       /* reportable and setable */
55 #define IMAP_DRAFT              8       /* reportable and setable */
56 #define IMAP_SEEN               16      /* reportable and setable */
57
58 #define IMAP_MASK_SETABLE       0x1f
59 #define IMAP_MASK_SYSTEM        0xe0
60
61 #define IMAP_SELECTED           32      /* neither reportable nor setable */
62 #define IMAP_RECENT             64      /* reportable but not setable */
63
64
65 #define IMAP CC->IMAP
66
67 /*
68  * When loading arrays of message ID's into memory, increase the buffer to
69  * hold this many additional messages instead of calling realloc() each time.
70  */
71 #define REALLOC_INCREMENT 100