Remove extra newlines
authorArt Cancro <ajc@uncensored.citadel.org>
Tue, 28 Feb 2012 03:50:10 +0000 (22:50 -0500)
committerArt Cancro <ajc@uncensored.citadel.org>
Tue, 28 Feb 2012 03:50:10 +0000 (22:50 -0500)
citadel/modules/sieve/serv_sieve.c

index 82c084c9ad957b457a6934761960ea5d7e23065a..557efa4aae950432b874d928878f0eb6c6807cf3 100644 (file)
@@ -6,17 +6,11 @@
  *
  * This program is open source software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 3.
- * 
- * 
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- *
- * 
- * 
- * 
  */
 
 #include "sysdep.h"
@@ -64,7 +58,7 @@ char *msiv_extensions = NULL;
  */
 int ctdl_debug(sieve2_context_t *s, void *my)
 {
-       syslog(LOG_DEBUG, "Sieve: %s\n", sieve2_getvalue_string(s, "message"));
+       syslog(LOG_DEBUG, "Sieve: %s", sieve2_getvalue_string(s, "message"));
        return SIEVE2_OK;
 }
 
@@ -74,7 +68,7 @@ int ctdl_debug(sieve2_context_t *s, void *my)
  */
 int ctdl_errparse(sieve2_context_t *s, void *my)
 {
-       syslog(LOG_WARNING, "Error in script, line %d: %s\n",
+       syslog(LOG_WARNING, "Error in script, line %d: %s",
                sieve2_getvalue_int(s, "lineno"),
                sieve2_getvalue_string(s, "message")
        );
@@ -87,7 +81,7 @@ int ctdl_errparse(sieve2_context_t *s, void *my)
  */
 int ctdl_errexec(sieve2_context_t *s, void *my)
 {
-       syslog(LOG_WARNING, "Error executing script: %s\n",
+       syslog(LOG_WARNING, "Error executing script: %s",
                sieve2_getvalue_string(s, "message")
        );
        return SIEVE2_OK;
@@ -106,22 +100,22 @@ int ctdl_redirect(sieve2_context_t *s, void *my)
 
        safestrncpy(recp, sieve2_getvalue_string(s, "address"), sizeof recp);
 
-       syslog(LOG_DEBUG, "Action is REDIRECT, recipient <%s>\n", recp);
+       syslog(LOG_DEBUG, "Action is REDIRECT, recipient <%s>", recp);
 
        valid = validate_recipients(recp, NULL, 0);
        if (valid == NULL) {
-               syslog(LOG_WARNING, "REDIRECT failed: bad recipient <%s>\n", recp);
+               syslog(LOG_WARNING, "REDIRECT failed: bad recipient <%s>", recp);
                return SIEVE2_ERROR_BADARGS;
        }
        if (valid->num_error > 0) {
-               syslog(LOG_WARNING, "REDIRECT failed: bad recipient <%s>\n", recp);
+               syslog(LOG_WARNING, "REDIRECT failed: bad recipient <%s>", recp);
                free_recipients(valid);
                return SIEVE2_ERROR_BADARGS;
        }
 
        msg = CtdlFetchMessage(cs->msgnum, 1);
        if (msg == NULL) {
-               syslog(LOG_WARNING, "REDIRECT failed: unable to fetch msg %ld\n", cs->msgnum);
+               syslog(LOG_WARNING, "REDIRECT failed: unable to fetch msg %ld", cs->msgnum);
                free_recipients(valid);
                return SIEVE2_ERROR_BADARGS;
        }
@@ -141,7 +135,7 @@ int ctdl_keep(sieve2_context_t *s, void *my)
 {
        struct ctdl_sieve *cs = (struct ctdl_sieve *)my;
        
-       syslog(LOG_DEBUG, "Action is KEEP\n");
+       syslog(LOG_DEBUG, "Action is KEEP");
 
        cs->keep = 1;
        cs->cancel_implicit_keep = 1;
@@ -160,7 +154,7 @@ int ctdl_fileinto(sieve2_context_t *s, void *my)
        char foldername[256];
        char original_room_name[ROOMNAMELEN];
 
-       syslog(LOG_DEBUG, "Action is FILEINTO, destination is <%s>\n", dest_folder);
+       syslog(LOG_DEBUG, "Action is FILEINTO, destination is <%s>", dest_folder);
 
        /* FILEINTO 'INBOX' is the same thing as KEEP */
        if ( (!strcasecmp(dest_folder, "INBOX")) || (!strcasecmp(dest_folder, MAILROOM)) ) {
@@ -183,7 +177,7 @@ int ctdl_fileinto(sieve2_context_t *s, void *my)
        }
 
        if (c != 0) {
-               syslog(LOG_WARNING, "FILEINTO failed: target <%s> does not exist\n", dest_folder);
+               syslog(LOG_WARNING, "FILEINTO failed: target <%s> does not exist", dest_folder);
                return SIEVE2_ERROR_BADARGS;
        }
 
@@ -214,7 +208,7 @@ int ctdl_discard(sieve2_context_t *s, void *my)
 {
        struct ctdl_sieve *cs = (struct ctdl_sieve *)my;
 
-       syslog(LOG_DEBUG, "Action is DISCARD\n");
+       syslog(LOG_DEBUG, "Action is DISCARD");
 
        /* Cancel the implicit keep.  That's all there is to it. */
        cs->cancel_implicit_keep = 1;
@@ -231,11 +225,11 @@ int ctdl_reject(sieve2_context_t *s, void *my)
        struct ctdl_sieve *cs = (struct ctdl_sieve *)my;
        char *reject_text = NULL;
 
-       syslog(LOG_DEBUG, "Action is REJECT\n");
+       syslog(LOG_DEBUG, "Action is REJECT");
 
        /* If we don't know who sent the message, do a DISCARD instead. */
        if (IsEmptyStr(cs->sender)) {
-               syslog(LOG_INFO, "Unknown sender.  Doing DISCARD instead of REJECT.\n");
+               syslog(LOG_INFO, "Unknown sender.  Doing DISCARD instead of REJECT.");
                return ctdl_discard(s, my);
        }
 
@@ -286,7 +280,7 @@ int ctdl_vacation(sieve2_context_t *s, void *my)
        char *vacamsg_text = NULL;
        char vacamsg_subject[1024];
 
-       syslog(LOG_DEBUG, "Action is VACATION\n");
+       syslog(LOG_DEBUG, "Action is VACATION");
 
        message = sieve2_getvalue_string(s, "message");
        if (message == NULL) return SIEVE2_ERROR_BADARGS;
@@ -306,7 +300,7 @@ int ctdl_vacation(sieve2_context_t *s, void *my)
        for (vptr = cs->u->first_vacation; vptr != NULL; vptr = vptr->next) {
                if (!strcasecmp(vptr->fromaddr, cs->sender)) {
                        if ( (time(NULL) - vptr->timestamp) < (days * 86400) ) {
-                               syslog(LOG_DEBUG, "Already alerted <%s> recently.\n", cs->sender);
+                               syslog(LOG_DEBUG, "Already alerted <%s> recently.", cs->sender);
                                return SIEVE2_OK;
                        }
                }
@@ -391,8 +385,9 @@ int ctdl_getenvelope(sieve2_context_t *s, void *my)
 {
        struct ctdl_sieve *cs = (struct ctdl_sieve *)my;
 
-       syslog(LOG_DEBUG, "Action is GETENVELOPE\nEnvFrom: %s\n  EnvTo: %s\n",
-               cs->envelope_from, cs->envelope_to);
+       syslog(LOG_DEBUG, "Action is GETENVELOPE");
+       syslog(LOG_DEBUG, "EnvFrom: %s", cs->envelope_from);
+       syslog(LOG_DEBUG, "EnvTo: %s", cs->envelope_to);
 
        if (cs->envelope_from != NULL) {
                if ((cs->envelope_from[0] != '@')&&(cs->envelope_from[strlen(cs->envelope_from)-1] != '@')) {
@@ -463,13 +458,13 @@ int ctdl_getscript(sieve2_context_t *s, void *my) {
 
        for (sptr=cs->u->first_script; sptr!=NULL; sptr=sptr->next) {
                if (sptr->script_active > 0) {
-                       syslog(LOG_DEBUG, "ctdl_getscript() is using script '%s'\n", sptr->script_name);
+                       syslog(LOG_DEBUG, "ctdl_getscript() is using script '%s'", sptr->script_name);
                        sieve2_setvalue_string(s, "script", sptr->script_content);
                        return SIEVE2_OK;
                }
        }
                
-       syslog(LOG_DEBUG, "ctdl_getscript() found no active script\n");
+       syslog(LOG_DEBUG, "ctdl_getscript() found no active script");
        return SIEVE2_ERROR_GETSCRIPT;
 }
 
@@ -480,7 +475,7 @@ int ctdl_getheaders(sieve2_context_t *s, void *my) {
 
        struct ctdl_sieve *cs = (struct ctdl_sieve *)my;
 
-       syslog(LOG_DEBUG, "ctdl_getheaders() was called\n");
+       syslog(LOG_DEBUG, "ctdl_getheaders() was called");
        sieve2_setvalue_string(s, "allheaders", cs->rfc822headers);
        return SIEVE2_OK;
 }
@@ -501,7 +496,7 @@ void sieve_queue_room(struct ctdlroom *which_room) {
        ptr->next = sieve_list;
        sieve_list = ptr;
        end_critical_section(S_SIEVELIST);
-       syslog(LOG_DEBUG, "<%s> queued for Sieve processing\n", which_room->QRname);
+       syslog(LOG_DEBUG, "<%s> queued for Sieve processing", which_room->QRname);
 }
 
 
@@ -521,13 +516,13 @@ void sieve_do_msg(long msgnum, void *userdata) {
 
        if (u == NULL)
        {
-               syslog(LOG_EMERG, "Can't process message <%ld> without userdata!\n", msgnum);
+               syslog(LOG_EMERG, "Can't process message <%ld> without userdata!", msgnum);
                return;
        }
 
        sieve2_context = u->sieve2_context;
 
-       syslog(LOG_DEBUG, "Performing sieve processing on msg <%ld>\n", msgnum);
+       syslog(LOG_DEBUG, "Performing sieve processing on msg <%ld>", msgnum);
 
        /*
         * Make sure you include message body so you can get those second-level headers ;)
@@ -636,10 +631,10 @@ void sieve_do_msg(long msgnum, void *userdata) {
 
        CtdlFreeMessage(msg);
        
-       syslog(LOG_DEBUG, "Calling sieve2_execute()\n");
+       syslog(LOG_DEBUG, "Calling sieve2_execute()");
        res = sieve2_execute(sieve2_context, &my);
        if (res != SIEVE2_OK) {
-               syslog(LOG_CRIT, "sieve2_execute() returned %d: %s\n", res, sieve2_errstr(res));
+               syslog(LOG_CRIT, "sieve2_execute() returned %d: %s", res, sieve2_errstr(res));
        }
 
        free(my.rfc822headers);
@@ -650,11 +645,11 @@ void sieve_do_msg(long msgnum, void *userdata) {
         * if no other action was successfully taken.
         */
        if ( (!my.keep) && (my.cancel_implicit_keep) ) {
-               syslog(LOG_DEBUG, "keep is 0 -- deleting message from inbox\n");
+               syslog(LOG_DEBUG, "keep is 0 -- deleting message from inbox");
                CtdlDeleteMessages(CC->room.QRname, &msgnum, 1, "");
        }
 
-       syslog(LOG_DEBUG, "Completed sieve processing on msg <%ld>\n", msgnum);
+       syslog(LOG_DEBUG, "Completed sieve processing on msg <%ld>", msgnum);
        u->lastproc = msgnum;
 
        return;
@@ -863,7 +858,7 @@ void sieve_do_room(char *roomname) {
         */
        snprintf(u.config_roomname, sizeof u.config_roomname, "%010ld.%s", atol(roomname), USERCONFIGROOM);
        if (CtdlGetRoom(&CC->room, u.config_roomname) != 0) {
-               syslog(LOG_DEBUG, "<%s> does not exist.  No processing is required.\n", u.config_roomname);
+               syslog(LOG_DEBUG, "<%s> does not exist.  No processing is required.", u.config_roomname);
                return;
        }
 
@@ -875,14 +870,16 @@ void sieve_do_room(char *roomname) {
                get_sieve_config_backend, (void *)&u );
 
        if (u.config_msgnum < 0) {
-               syslog(LOG_DEBUG, "No Sieve rules exist.  No processing is required.\n");
+               syslog(LOG_DEBUG, "No Sieve rules exist.  No processing is required.");
                return;
        }
 
-       syslog(LOG_DEBUG, "Rules found.  Performing Sieve processing for <%s>\n", roomname);
+       /* FIXME this is where we have to check for empty scripts */
+
+       syslog(LOG_DEBUG, "Rules found.  Performing Sieve processing for <%s>", roomname);
 
        if (CtdlGetRoom(&CC->room, roomname) != 0) {
-               syslog(LOG_CRIT, "ERROR: cannot load <%s>\n", roomname);
+               syslog(LOG_CRIT, "ERROR: cannot load <%s>", roomname);
                return;
        }
 
@@ -890,13 +887,13 @@ void sieve_do_room(char *roomname) {
        
        res = sieve2_alloc(&sieve2_context);
        if (res != SIEVE2_OK) {
-               syslog(LOG_CRIT, "sieve2_alloc() returned %d: %s\n", res, sieve2_errstr(res));
+               syslog(LOG_CRIT, "sieve2_alloc() returned %d: %s", res, sieve2_errstr(res));
                return;
        }
 
        res = sieve2_callbacks(sieve2_context, ctdl_sieve_callbacks);
        if (res != SIEVE2_OK) {
-               syslog(LOG_CRIT, "sieve2_callbacks() returned %d: %s\n", res, sieve2_errstr(res));
+               syslog(LOG_CRIT, "sieve2_callbacks() returned %d: %s", res, sieve2_errstr(res));
                goto BAIL;
        }
 
@@ -907,7 +904,7 @@ void sieve_do_room(char *roomname) {
        my.u = &u;
        res = sieve2_validate(sieve2_context, &my);
        if (res != SIEVE2_OK) {
-               syslog(LOG_CRIT, "sieve2_validate() returned %d: %s\n", res, sieve2_errstr(res));
+               syslog(LOG_CRIT, "sieve2_validate() returned %d: %s", res, sieve2_errstr(res));
                goto BAIL;
        }
 
@@ -922,7 +919,7 @@ void sieve_do_room(char *roomname) {
 BAIL:
        res = sieve2_free(&sieve2_context);
        if (res != SIEVE2_OK) {
-               syslog(LOG_CRIT, "sieve2_free() returned %d: %s\n", res, sieve2_errstr(res));
+               syslog(LOG_CRIT, "sieve2_free() returned %d: %s", res, sieve2_errstr(res));
        }
 
        /* Rewrite the config if we have to */
@@ -937,7 +934,7 @@ void perform_sieve_processing(void) {
        struct RoomProcList *ptr = NULL;
 
        if (sieve_list != NULL) {
-               syslog(LOG_DEBUG, "Begin Sieve processing\n");
+               syslog(LOG_DEBUG, "Begin Sieve processing");
                while (sieve_list != NULL) {
                        char spoolroomname[ROOMNAMELEN];
                        safestrncpy(spoolroomname, sieve_list->name, sizeof spoolroomname);
@@ -1254,7 +1251,7 @@ void ctdl_sieve_init(void) {
                strcpy(&cred[55], "...");
        }
 
-       syslog(LOG_INFO, "%s\n",cred);
+       syslog(LOG_INFO, "%s",cred);
        free(cred);
 
        /* Briefly initialize a Sieve parser instance just so we can list the
@@ -1262,22 +1259,22 @@ void ctdl_sieve_init(void) {
         */
        res = sieve2_alloc(&sieve2_context);
        if (res != SIEVE2_OK) {
-               syslog(LOG_CRIT, "sieve2_alloc() returned %d: %s\n", res, sieve2_errstr(res));
+               syslog(LOG_CRIT, "sieve2_alloc() returned %d: %s", res, sieve2_errstr(res));
                return;
        }
 
        res = sieve2_callbacks(sieve2_context, ctdl_sieve_callbacks);
        if (res != SIEVE2_OK) {
-               syslog(LOG_CRIT, "sieve2_callbacks() returned %d: %s\n", res, sieve2_errstr(res));
+               syslog(LOG_CRIT, "sieve2_callbacks() returned %d: %s", res, sieve2_errstr(res));
                goto BAIL;
        }
 
        msiv_extensions = strdup(sieve2_listextensions(sieve2_context));
-       syslog(LOG_INFO, "Extensions: %s\n", msiv_extensions);
+       syslog(LOG_INFO, "Extensions: %s", msiv_extensions);
 
 BAIL:  res = sieve2_free(&sieve2_context);
        if (res != SIEVE2_OK) {
-               syslog(LOG_CRIT, "sieve2_free() returned %d: %s\n", res, sieve2_errstr(res));
+               syslog(LOG_CRIT, "sieve2_free() returned %d: %s", res, sieve2_errstr(res));
        }
 
 }