IMAP: make debug logging configurable.
[citadel.git] / citadel / modules / imap / serv_imap.h
index 5d96ea95d77c37ee952025e3b991cb64553443fd..371dbeb2ef3e772782ca6a26c4a7b47b6ff69727 100644 (file)
@@ -1,7 +1,3 @@
-/* $Id$ 
- */
-
-
 #define GLOBAL_UIDVALIDITY_VALUE       1L
 
 
@@ -13,9 +9,33 @@ void imap_free_transmitted_message(void);
 int imap_do_expunge(void);
 void imap_rescan_msgids(void);
 
+/*
+ * FDELIM defines which character we want to use as a folder delimiter
+ * in room names.  Originally we used a forward slash, but that caused
+ * rooms with names like "Sent/Received Pages" to get delimited, so we
+ * changed it to a backslash.  This is completely irrelevant to how Citadel
+ * speaks to IMAP clients -- the delimiter used in the IMAP protocol is
+ * a vertical bar, which is illegal in Citadel room names anyway.
+ */
+
+typedef void (*imap_handler)(int num_parms, ConstStr *Params);
+
+typedef struct _imap_handler_hook {
+       imap_handler h;
+       int Flags;
+} imap_handler_hook;
+
+typedef struct __citimap_command {
+       StrBuf *CmdBuf;                 /* our current commandline; gets chopped into: */
+       ConstStr *Params;               /* Commandline tokens */
+       int num_parms;                  /* Number of Commandline tokens available */
+       int avail_parms;                /* Number of ConstStr args is big */
+       const imap_handler_hook *hh;
+} citimap_command;
 
 
 typedef struct __citimap {
+       StrBuf *Reply;
        int authstate;
        char authseq[SIZ];
        int selected;                   /* set to 1 if in the SELECTED state */
@@ -25,6 +45,7 @@ typedef struct __citimap {
        time_t last_mtime;              /* For checking whether the room was modified... */
        long *msgids;
        unsigned int *flags;
+
        StrBuf *TransmittedMessage;     /* for APPEND command... */
 
        citimap_command Cmd;            /* our current commandline */
@@ -70,10 +91,50 @@ enum {
 #define IMAP_RECENT            64      /* reportable but not setable */
 
 
+/*
+ * Flags that may be returned by imap_roomname()
+ * (the lower eight bits will be the floor number)
+ */
+#define IR_MAILBOX     0x0100          /* Mailbox                       */
+#define IR_EXISTS      0x0200          /* Room exists (not implemented) */
+#define IR_BABOON      0x0000          /* Just had to put this here :)  */
+
+#define FDELIM '\\'
+
+extern int IMAPDebugEnabled;
+
 #define IMAP ((citimap *)CC->session_specific_data)
+#define CCCIMAP ((citimap *)CCC->session_specific_data)
+
+#define IMAPDBGLOG(LEVEL) if ((LEVEL != LOG_DEBUG) || (IMAPDebugEnabled != 0))
+#define CCCID CCC->cs_pid
+#define IMAP_syslog(LEVEL, FORMAT, ...)                        \
+       IMAPDBGLOG(LEVEL) syslog(LEVEL,                 \
+                                "IMAPCC[%d] " FORMAT,  \
+                                CCCID, __VA_ARGS__)
+
+#define IMAPM_syslog(LEVEL, FORMAT)                    \
+       IMAPDBGLOG(LEVEL) syslog(LEVEL,                 \
+                                "IMAPCC[%d] " FORMAT,  \
+                                CCCID)
+
+#define I_FLAG_NONE          (0)
+#define I_FLAG_LOGGED_IN  (1<<0)
+#define I_FLAG_SELECT     (1<<1)
+/* RFC3501 says that we cannot output untagged data during these commands */
+#define I_FLAG_UNTAGGED   (1<<2)
 
 /*
  * When loading arrays of message ID's into memory, increase the buffer to
  * hold this many additional messages instead of calling realloc() each time.
  */
 #define REALLOC_INCREMENT 100
+
+
+void registerImapCMD(const char *First, long FLen, 
+                    const char *Second, long SLen,
+                    imap_handler H,
+                    int Flags);
+
+#define RegisterImapCMD(First, Second, H, Flags) \
+       registerImapCMD(HKEY(First), HKEY(Second), H, Flags)