1 #define GLOBAL_UIDVALIDITY_VALUE 1L
4 void imap_cleanup_function(void);
5 void imap_greeting(void);
6 void imap_command_loop(void);
7 int imap_grabroom(char *returned_roomname, const char *foldername, int zapped_ok);
8 void imap_free_transmitted_message(void);
9 int imap_do_expunge(void);
10 void imap_rescan_msgids(void);
13 * FDELIM defines which character we want to use as a folder delimiter
14 * in room names. Originally we used a forward slash, but that caused
15 * rooms with names like "Sent/Received Pages" to get delimited, so we
16 * changed it to a backslash. This is completely irrelevant to how Citadel
17 * speaks to IMAP clients -- the delimiter used in the IMAP protocol is
18 * a vertical bar, which is illegal in Citadel room names anyway.
21 typedef void (*imap_handler)(int num_parms, ConstStr *Params);
23 typedef struct _imap_handler_hook {
28 typedef struct __citimap_command {
29 StrBuf *CmdBuf; /* our current commandline; gets chopped into: */
30 ConstStr *Params; /* Commandline tokens */
31 int num_parms; /* Number of Commandline tokens available */
32 int avail_parms; /* Number of ConstStr args is big */
33 const imap_handler_hook *hh;
37 typedef struct __citimap {
41 int selected; /* set to 1 if in the SELECTED state */
42 int readonly; /* mailbox is open read only */
43 int num_msgs; /* Number of messages being mapped */
44 int num_alloc; /* Number of messages for which we've allocated space */
45 time_t last_mtime; /* For checking whether the room was modified... */
49 StrBuf *TransmittedMessage; /* for APPEND command... */
51 citimap_command Cmd; /* our current commandline */
53 /* Cache most recent RFC822 FETCH because client might load in pieces */
54 StrBuf *cached_rfc822;
55 long cached_rfc822_msgnum;
56 char cached_rfc822_withbody; /* 1 = body cached; 0 = only headers cached */
58 /* Cache most recent BODY FETCH because client might load in pieces */
60 size_t cached_body_len;
61 char cached_bodypart[SIZ];
62 long cached_bodymsgnum;
63 char cached_body_withbody; /* 1 = body cached; 0 = only headers cached */
67 * values of 'authstate'
71 imap_as_expecting_username,
72 imap_as_expecting_password,
73 imap_as_expecting_plainauth,
74 imap_as_expecting_multilineusername,
75 imap_as_expecting_multilinepassword
78 /* Flags for the above struct. Note that some of these are for internal use,
79 * and are not to be reported to IMAP clients.
81 #define IMAP_ANSWERED 1 /* reportable and setable */
82 #define IMAP_FLAGGED 2 /* reportable and setable */
83 #define IMAP_DELETED 4 /* reportable and setable */
84 #define IMAP_DRAFT 8 /* reportable and setable */
85 #define IMAP_SEEN 16 /* reportable and setable */
87 #define IMAP_MASK_SETABLE 0x1f
88 #define IMAP_MASK_SYSTEM 0xe0
90 #define IMAP_SELECTED 32 /* neither reportable nor setable */
91 #define IMAP_RECENT 64 /* reportable but not setable */
95 * Flags that may be returned by imap_roomname()
96 * (the lower eight bits will be the floor number)
98 #define IR_MAILBOX 0x0100 /* Mailbox */
99 #define IR_EXISTS 0x0200 /* Room exists (not implemented) */
100 #define IR_BABOON 0x0000 /* Just had to put this here :) */
104 extern int IMAPDebugEnabled;
106 #define IMAP ((citimap *)CC->session_specific_data)
107 #define CCCIMAP ((citimap *)CCC->session_specific_data)
109 #define IMAPDBGLOG(LEVEL) if ((LEVEL != LOG_DEBUG) || (IMAPDebugEnabled != 0))
110 #define CCCID CCC->cs_pid
111 #define IMAP_syslog(LEVEL, FORMAT, ...) \
112 IMAPDBGLOG(LEVEL) syslog(LEVEL, \
113 "IMAP %s CC[%d] " FORMAT, \
114 IOSTR, CCCID, __VA_ARGS__)
116 #define IMAPM_syslog(LEVEL, FORMAT) \
117 IMAPDBGLOG(LEVEL) syslog(LEVEL, \
118 "IMAP %s CC[%d] " FORMAT, \
121 #define I_FLAG_NONE (0)
122 #define I_FLAG_LOGGED_IN (1<<0)
123 #define I_FLAG_SELECT (1<<1)
124 /* RFC3501 says that we cannot output untagged data during these commands */
125 #define I_FLAG_UNTAGGED (1<<2)
128 * When loading arrays of message ID's into memory, increase the buffer to
129 * hold this many additional messages instead of calling realloc() each time.
131 #define REALLOC_INCREMENT 100
134 void registerImapCMD(const char *First, long FLen,
135 const char *Second, long SLen,
139 #define RegisterImapCMD(First, Second, H, Flags) \
140 registerImapCMD(HKEY(First), HKEY(Second), H, Flags)