style cleanup
[citadel.git] / citadel / modules / imap / serv_imap.c
index 60584df2750235c6f611586b144e94a09751e4ba..33a3f3ba7a34c26142b828116253b9d484d19564 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * IMAP server for the Citadel system
  *
- * Copyright (C) 2000-2015 by Art Cancro and others.
+ * Copyright (C) 2000-2017 by Art Cancro and others.
  * This code is released under the terms of the GNU General Public License.
  *
  * WARNING: the IMAP protocol is badly designed.  No implementation of it
@@ -65,7 +65,6 @@
 #include "imap_misc.h"
 
 #include "ctdl_module.h"
-int IMAPDebugEnabled = 0;
 HashList *ImapCmds = NULL;
 void registerImapCMD(const char *First, long FLen, 
                     const char *Second, long SLen,
@@ -109,33 +108,31 @@ const imap_handler_hook *imap_lookup(int num_parms, ConstStr *Params)
        StrBufPlain(Imap->Reply, CKEY(Params[1]));
        StrBufUpCase(Imap->Reply);
 
-       IMAP_syslog(LOG_DEBUG, "---- Looking up [%s] -----", 
-                     ChrPtr(Imap->Reply));
+       syslog(LOG_DEBUG, "---- Looking up [%s] -----", ChrPtr(Imap->Reply));
        if (GetHash(ImapCmds, SKEY(Imap->Reply), &v))
        {
-               IMAPM_syslog(LOG_DEBUG, "Found."); 
+               syslog(LOG_DEBUG, "Found."); 
                FlushStrBuf(Imap->Reply);
                return (imap_handler_hook *) v;
        }
 
        if (num_parms == 1)
        {
-               IMAPM_syslog(LOG_DEBUG, "NOT Found."); 
+               syslog(LOG_DEBUG, "NOT Found."); 
                FlushStrBuf(Imap->Reply);
                return NULL;
        }
        
-       IMAP_syslog(LOG_DEBUG, "---- Looking up [%s] -----", 
-                     ChrPtr(Imap->Reply));
+       syslog(LOG_DEBUG, "---- Looking up [%s] -----", ChrPtr(Imap->Reply));
        StrBufAppendBufPlain(Imap->Reply, CKEY(Params[2]), 0);
        StrBufUpCase(Imap->Reply);
        if (GetHash(ImapCmds, SKEY(Imap->Reply), &v))
        {
-               IMAPM_syslog(LOG_DEBUG, "Found."); 
+               syslog(LOG_DEBUG, "Found."); 
                FlushStrBuf(Imap->Reply);
                return (imap_handler_hook *) v;
        }
-       IMAPM_syslog(LOG_DEBUG, "NOT Found."); 
+       syslog(LOG_DEBUG, "NOT Found."); 
        FlushStrBuf(Imap->Reply);
                return NULL;
 }
@@ -307,7 +304,7 @@ void imap_load_msgids(void)
        citimap *Imap = CCCIMAP;
 
        if (Imap->selected == 0) {
-               IMAPM_syslog(LOG_ERR, "imap_load_msgids() can't run; no room selected");
+               syslog(LOG_ERR, "imap_load_msgids() can't run; no room selected");
                return;
        }
 
@@ -350,7 +347,7 @@ void imap_rescan_msgids(void)
        int num_recent = 0;
 
        if (Imap->selected == 0) {
-               IMAPM_syslog(LOG_ERR, "imap_load_msgids() can't run; no room selected");
+               syslog(LOG_ERR, "imap_load_msgids() can't run; no room selected");
                return;
        }
 
@@ -482,7 +479,7 @@ void imap_cleanup_function(void)
                imap_do_expunge();
        }
 
-       IMAPM_syslog(LOG_DEBUG, "Performing IMAP cleanup hook");
+       syslog(LOG_DEBUG, "Performing IMAP cleanup hook");
        imap_free_msgids();
        imap_free_transmitted_message();
 
@@ -502,7 +499,7 @@ void imap_cleanup_function(void)
        FreeStrBuf(&Imap->Reply);
        if (Imap->Cmd.Params != NULL) free(Imap->Cmd.Params);
        free(Imap);
-       IMAPM_syslog(LOG_DEBUG, "Finished IMAP cleanup hook");
+       syslog(LOG_DEBUG, "Finished IMAP cleanup hook");
 }
 
 
@@ -945,7 +942,7 @@ int imap_do_expunge(void)
        long *delmsgs = NULL;
        int num_delmsgs = 0;
 
-       IMAPM_syslog(LOG_DEBUG, "imap_do_expunge() called");
+       syslog(LOG_DEBUG, "imap_do_expunge() called");
        if (Imap->selected == 0) {
                return (0);
        }
@@ -968,7 +965,7 @@ int imap_do_expunge(void)
                imap_rescan_msgids();
        }
 
-       IMAP_syslog(LOG_DEBUG, "Expunged %d messages from <%s>", num_expunged, CC->room.QRname);
+       syslog(LOG_DEBUG, "Expunged %d messages from <%s>", num_expunged, CC->room.QRname);
        return (num_expunged);
 }
 
@@ -1049,7 +1046,6 @@ void imap_namespace(int num_parms, ConstStr *Params)
  */
 void imap_create(int num_parms, ConstStr *Params)
 {
-       struct CitContext *CCC = CC;
        int ret;
        char roomname[ROOMNAMELEN];
        int floornum;
@@ -1065,14 +1061,14 @@ void imap_create(int num_parms, ConstStr *Params)
 
        if (strchr(Params[2].Key, '\\') != NULL) {
                IReply("NO Invalid character in folder name");
-               IMAPM_syslog(LOG_ERR, "invalid character in folder name");
+               syslog(LOG_ERR, "invalid character in folder name");
                return;
        }
 
        ret = imap_roomname(roomname, sizeof roomname, Params[2].Key);
        if (ret < 0) {
                IReply("NO Invalid mailbox name or location");
-               IMAPM_syslog(LOG_ERR, "invalid mailbox name or location");
+               syslog(LOG_ERR, "invalid mailbox name or location");
                return;
        }
        floornum = (ret & 0x00ff);      /* lower 8 bits = floor number */
@@ -1081,7 +1077,7 @@ void imap_create(int num_parms, ConstStr *Params)
        if (flags & IR_MAILBOX) {
                if (strncasecmp(Params[2].Key, "INBOX/", 6)) {
                        IReply("NO Personal folders must be created under INBOX");
-                       IMAPM_syslog(LOG_ERR, "not subordinate to inbox");
+                       syslog(LOG_ERR, "not subordinate to inbox");
                        return;
                }
        }
@@ -1094,7 +1090,7 @@ void imap_create(int num_parms, ConstStr *Params)
                newroomview = VIEW_BBS;
        }
 
-       IMAP_syslog(LOG_INFO, "Create new room <%s> on floor <%d> with type <%d>",
+       syslog(LOG_INFO, "Create new room <%s> on floor <%d> with type <%d>",
                    roomname, floornum, newroomtype);
 
        ret = CtdlCreateRoom(roomname, newroomtype, "", floornum, 1, 0, newroomview);
@@ -1116,7 +1112,7 @@ void imap_create(int num_parms, ConstStr *Params)
                CtdlAideMessage(notification_message, "Room Creation Message");
                free(notification_message);
        }
-       IMAPM_syslog(LOG_DEBUG, "imap_create() completed");
+       syslog(LOG_DEBUG, "imap_create() completed");
 }
 
 
@@ -1481,9 +1477,8 @@ void imap_rename(int num_parms, ConstStr *Params)
                                           irl->irl_newroom,
                                           irl->irl_newfloor);
                        if (r != crr_ok) {
-                               struct CitContext *CCC = CC;
                                /* FIXME handle error returns better */
-                               IMAP_syslog(LOG_ERR, "CtdlRenameRoom() error %d", r);
+                               syslog(LOG_ERR, "CtdlRenameRoom() error %d", r);
                        }
                        irlp = irl;
                        irl = irl->next;
@@ -1525,23 +1520,23 @@ void imap_command_loop(void)
                FlushStrBuf(Imap->Cmd.CmdBuf);
 
        if (CtdlClientGetLine(Imap->Cmd.CmdBuf) < 1) {
-               IMAPM_syslog(LOG_ERR, "client disconnected: ending session.");
+               syslog(LOG_ERR, "client disconnected: ending session.");
                CC->kill_me = KILLME_CLIENT_DISCONNECTED;
                return;
        }
 
        if (Imap->authstate == imap_as_expecting_password) {
-               IMAPM_syslog(LOG_INFO, "<password>");
+               syslog(LOG_INFO, "<password>");
        }
        else if (Imap->authstate == imap_as_expecting_plainauth) {
-               IMAPM_syslog(LOG_INFO, "<plain_auth>");
+               syslog(LOG_INFO, "<plain_auth>");
        }
        else if ((Imap->authstate == imap_as_expecting_multilineusername) || 
                 cbmstrcasestr(ChrPtr(Imap->Cmd.CmdBuf), " LOGIN ")) {
-               IMAPM_syslog(LOG_INFO, "LOGIN...");
+               syslog(LOG_INFO, "LOGIN...");
        }
        else {
-               IMAP_syslog(LOG_DEBUG, "%s", ChrPtr(Imap->Cmd.CmdBuf));
+               syslog(LOG_DEBUG, "%s", ChrPtr(Imap->Cmd.CmdBuf));
        }
 
        pchs = ChrPtr(Imap->Cmd.CmdBuf);
@@ -1593,16 +1588,16 @@ void imap_command_loop(void)
 /* debug output the parsed vector */
        {
                int i;
-               IMAP_syslog(LOG_DEBUG, "----- %ld params", Imap->Cmd.num_parms);
+               syslog(LOG_DEBUG, "----- %ld params", Imap->Cmd.num_parms);
 
        for (i=0; i < Imap->Cmd.num_parms; i++) {
                if (Imap->Cmd.Params[i].len != strlen(Imap->Cmd.Params[i].Key))
-                       IMAP_syslog(LOG_DEBUG, "*********** %ld != %ld : %s",
+                       syslog(LOG_DEBUG, "*********** %ld != %ld : %s",
                                    Imap->Cmd.Params[i].len, 
                                    strlen(Imap->Cmd.Params[i].Key),
                                      Imap->Cmd.Params[i].Key);
                else
-                       IMAP_syslog(LOG_DEBUG, "%ld : %s",
+                       syslog(LOG_DEBUG, "%ld : %s",
                                    Imap->Cmd.Params[i].len, 
                                    Imap->Cmd.Params[i].Key);
        }}
@@ -1655,7 +1650,7 @@ BAIL:
 
        gettimeofday(&tv2, NULL);
        total_time = (tv2.tv_usec + (tv2.tv_sec * 1000000)) - (tv1.tv_usec + (tv1.tv_sec * 1000000));
-       IMAP_syslog(LOG_DEBUG, "IMAP command completed in %ld.%ld seconds",
+       syslog(LOG_DEBUG, "IMAP command completed in %ld.%ld seconds",
                    (total_time / 1000000),
                    (total_time % 1000000)
                );
@@ -1680,10 +1675,6 @@ void imap_logout(int num_parms, ConstStr *Params)
 const char *CitadelServiceIMAP="IMAP";
 const char *CitadelServiceIMAPS="IMAPS";
 
-void SetIMAPDebugEnabled(const int n)
-{
-       IMAPDebugEnabled = n;
-}
 /*
  * This function is called to register the IMAP extension with Citadel.
  */
@@ -1739,7 +1730,6 @@ CTDL_MODULE_INIT(imap)
 
        if (!threading)
        {
-               CtdlRegisterDebugFlagHook(HKEY("imapsrv"), SetIMAPDebugEnabled, &IMAPDebugEnabled);
                CtdlRegisterServiceHook(CtdlGetConfigInt("c_imap_port"),
                                        NULL, imap_greeting, imap_command_loop, NULL, CitadelServiceIMAP);
 #ifdef HAVE_OPENSSL