Back to index

citadel  8.12
serv_imap.h
Go to the documentation of this file.
00001 #define GLOBAL_UIDVALIDITY_VALUE   1L
00002 
00003 
00004 void imap_cleanup_function(void);
00005 void imap_greeting(void);
00006 void imap_command_loop(void);
00007 int imap_grabroom(char *returned_roomname, const char *foldername, int zapped_ok);
00008 void imap_free_transmitted_message(void);
00009 int imap_do_expunge(void);
00010 void imap_rescan_msgids(void);
00011 
00012 /*
00013  * FDELIM defines which character we want to use as a folder delimiter
00014  * in room names.  Originally we used a forward slash, but that caused
00015  * rooms with names like "Sent/Received Pages" to get delimited, so we
00016  * changed it to a backslash.  This is completely irrelevant to how Citadel
00017  * speaks to IMAP clients -- the delimiter used in the IMAP protocol is
00018  * a vertical bar, which is illegal in Citadel room names anyway.
00019  */
00020 
00021 typedef void (*imap_handler)(int num_parms, ConstStr *Params);
00022 
00023 typedef struct _imap_handler_hook {
00024        imap_handler h;
00025        int Flags;
00026 } imap_handler_hook;
00027 
00028 typedef struct __citimap_command {
00029        StrBuf *CmdBuf;                    /* our current commandline; gets chopped into: */
00030        ConstStr *Params;           /* Commandline tokens */
00031        int num_parms;                     /* Number of Commandline tokens available */
00032        int avail_parms;            /* Number of ConstStr args is big */
00033        const imap_handler_hook *hh;
00034 } citimap_command;
00035 
00036 
00037 typedef struct __citimap {
00038        StrBuf *Reply;
00039        int authstate;
00040        char authseq[SIZ];
00041        int selected;               /* set to 1 if in the SELECTED state */
00042        int readonly;               /* mailbox is open read only */
00043        int num_msgs;               /* Number of messages being mapped */
00044        int num_alloc;                     /* Number of messages for which we've allocated space */
00045        time_t last_mtime;          /* For checking whether the room was modified... */
00046        long *msgids;
00047        unsigned int *flags;
00048 
00049        StrBuf *TransmittedMessage; /* for APPEND command... */
00050 
00051        citimap_command Cmd;            /* our current commandline */
00052 
00053        /* Cache most recent RFC822 FETCH because client might load in pieces */
00054        StrBuf *cached_rfc822;
00055        long cached_rfc822_msgnum;
00056        char cached_rfc822_withbody;       /* 1 = body cached; 0 = only headers cached */
00057 
00058        /* Cache most recent BODY FETCH because client might load in pieces */
00059        char *cached_body;
00060        size_t cached_body_len;
00061        char cached_bodypart[SIZ];
00062        long cached_bodymsgnum;
00063        char cached_body_withbody;  /* 1 = body cached; 0 = only headers cached */
00064 } citimap;
00065 
00066 /*
00067  * values of 'authstate'
00068  */
00069 enum {
00070        imap_as_normal,
00071        imap_as_expecting_username,
00072        imap_as_expecting_password,
00073        imap_as_expecting_plainauth,
00074        imap_as_expecting_multilineusername,
00075        imap_as_expecting_multilinepassword
00076 };
00077 
00078 /* Flags for the above struct.  Note that some of these are for internal use,
00079  * and are not to be reported to IMAP clients.
00080  */
00081 #define IMAP_ANSWERED              1      /* reportable and setable */
00082 #define IMAP_FLAGGED        2      /* reportable and setable */
00083 #define IMAP_DELETED        4      /* reportable and setable */
00084 #define IMAP_DRAFT          8      /* reportable and setable */
00085 #define IMAP_SEEN           16     /* reportable and setable */
00086 
00087 #define IMAP_MASK_SETABLE   0x1f
00088 #define IMAP_MASK_SYSTEM    0xe0
00089 
00090 #define IMAP_SELECTED              32     /* neither reportable nor setable */
00091 #define IMAP_RECENT         64     /* reportable but not setable */
00092 
00093 
00094 /*
00095  * Flags that may be returned by imap_roomname()
00096  * (the lower eight bits will be the floor number)
00097  */
00098 #define IR_MAILBOX   0x0100        /* Mailbox                       */
00099 #define IR_EXISTS    0x0200        /* Room exists (not implemented) */
00100 #define IR_BABOON    0x0000        /* Just had to put this here :)  */
00101 
00102 #define FDELIM '\\'
00103 
00104 extern int IMAPDebugEnabled;
00105 
00106 #define IMAP ((citimap *)CC->session_specific_data)
00107 #define CCCIMAP ((citimap *)CCC->session_specific_data)
00108 
00109 #define IMAPDBGLOG(LEVEL) if ((LEVEL != LOG_DEBUG) || (IMAPDebugEnabled != 0))
00110 #define CCCID CCC->cs_pid
00111 #define IMAP_syslog(LEVEL, FORMAT, ...)                 \
00112        IMAPDBGLOG(LEVEL) syslog(LEVEL,                  \
00113                              "IMAPCC[%d] " FORMAT,      \
00114                              CCCID, __VA_ARGS__)
00115 
00116 #define IMAPM_syslog(LEVEL, FORMAT)                     \
00117        IMAPDBGLOG(LEVEL) syslog(LEVEL,                  \
00118                              "IMAPCC[%d] " FORMAT,      \
00119                              CCCID)
00120 
00121 #define I_FLAG_NONE          (0)
00122 #define I_FLAG_LOGGED_IN  (1<<0)
00123 #define I_FLAG_SELECT     (1<<1)
00124 /* RFC3501 says that we cannot output untagged data during these commands */
00125 #define I_FLAG_UNTAGGED   (1<<2)
00126 
00127 /*
00128  * When loading arrays of message ID's into memory, increase the buffer to
00129  * hold this many additional messages instead of calling realloc() each time.
00130  */
00131 #define REALLOC_INCREMENT 100
00132 
00133 
00134 void registerImapCMD(const char *First, long FLen, 
00135                    const char *Second, long SLen,
00136                    imap_handler H,
00137                    int Flags);
00138 
00139 #define RegisterImapCMD(First, Second, H, Flags) \
00140        registerImapCMD(HKEY(First), HKEY(Second), H, Flags)