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