regretting my brief fling with BSD style braces
authorArt Cancro <ajc@citadel.org>
Wed, 3 Mar 2021 16:03:28 +0000 (11:03 -0500)
committerArt Cancro <ajc@citadel.org>
Wed, 3 Mar 2021 16:03:28 +0000 (11:03 -0500)
citadel/modules/image/serv_image.c
citadel/modules/smtp/serv_smtpclient.c
citadel/modules/smtp/smtp_util.c

index 0751010d5876edf5a3ffed7507fd50886e4887af..6be5afc307a2da4057f9aed88c777ccd62837b8e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1987-2020 by the citadel.org team
+ * Copyright (c) 1987-2021 by the citadel.org team
  *
  * This program is open source software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -23,8 +23,7 @@
  * DownLoad Room Image (see its icon or whatever)
  * If this command succeeds, it follows the same protocol as the DLAT command.
  */
-void cmd_dlri(char *cmdbuf)
-{
+void cmd_dlri(char *cmdbuf) {
        if (CtdlAccessCheck(ac_logged_in_or_guest)) return;
        if (CC->room.msgnum_pic < 1) {
                cprintf("%d No image found.\n", ERROR + FILE_NOT_FOUND);
@@ -50,8 +49,7 @@ void cmd_dlri(char *cmdbuf)
 /*
  * UpLoad Room Image (avatar or photo or whatever)
  */
-void cmd_ulri(char *cmdbuf)
-{
+void cmd_ulri(char *cmdbuf) {
        long data_length;
        char mimetype[SIZ];
 
@@ -107,8 +105,7 @@ void cmd_ulri(char *cmdbuf)
  * DownLoad User Image (see their avatar or photo or whatever)
  * If this command succeeds, it follows the same protocol as the DLAT command.
  */
-void cmd_dlui(char *cmdbuf)
-{
+void cmd_dlui(char *cmdbuf) {
        struct ctdluser ruser;
        char buf[SIZ];
 
@@ -142,8 +139,7 @@ void cmd_dlui(char *cmdbuf)
 /*
  * UpLoad User Image (avatar or photo or whatever)
  */
-void cmd_ului(char *cmdbuf)
-{
+void cmd_ului(char *cmdbuf) {
        long data_length;
        char mimetype[SIZ];
        char username[USERNAME_SIZE];
@@ -151,8 +147,7 @@ void cmd_ului(char *cmdbuf)
 
        if (CtdlAccessCheck(ac_logged_in_or_guest)) return;
 
-       if (num_parms(cmdbuf) < 2)
-       {
+       if (num_parms(cmdbuf) < 2) {
                cprintf("%d Usage error\n", ERROR + ILLEGAL_VALUE);
                return;
        }
@@ -225,8 +220,7 @@ void cmd_ului(char *cmdbuf)
 /*
  * Import function called by import_old_userpic_files() for a single user
  */
-void import_one_userpic_file(char *username, long usernum, char *path)
-{
+void import_one_userpic_file(char *username, long usernum, char *path) {
        syslog(LOG_DEBUG, "Import legacy userpic for %s, usernum=%ld, filename=%s", username, usernum, path);
 
        FILE *fp = fopen(path, "r");
@@ -273,8 +267,7 @@ void import_one_userpic_file(char *username, long usernum, char *path)
 /*
  * Look for old-format "userpic" files and import them into the message base
  */
-void import_old_userpic_files(void)
-{
+void import_old_userpic_files(void) {
        DIR *filedir = NULL;
        struct dirent *filedir_entry;
        size_t d_namelen;
index 8e87ce4c2f4da626569a4842c602db51aaf7af51..bdc2fb75452f400dbae96f6f8118645aae40bf73 100644 (file)
@@ -322,8 +322,9 @@ int smtp_attempt_delivery(long msgid, char *recp, char *envelope_from, char *res
        }
 
        FreeStrBuf(&s.TheMessage);
-       if (fromaddr)
+       if (fromaddr) {
                free(fromaddr);
+       }
        return ((int) response_code);
 }
 
@@ -388,11 +389,13 @@ void smtp_process_one_msg(long qmsgnum) {
        int should_try_now = 0;
        if (attempted < submitted) {    // If no attempts have been made yet, try now
                should_try_now = 1;
-       } else if ((attempted - submitted) <= 14400) {
+       }
+       else if ((attempted - submitted) <= 14400) {
                if ((time(NULL) - attempted) > 1800) {  // First four hours, retry every 30 minutes
                        should_try_now = 1;
                }
-       } else {
+       }
+       else {
                if ((time(NULL) - attempted) > 14400) { // After that, retry once every 4 hours
                        should_try_now = 1;
                }
@@ -404,11 +407,12 @@ void smtp_process_one_msg(long qmsgnum) {
                StrBufAppendPrintf(NewInstr, "Content-type: " SPOOLMIME "\n\n");
                StrBufAppendPrintf(NewInstr, "msgid|%ld\n", msgid);
                StrBufAppendPrintf(NewInstr, "submitted|%ld\n", submitted);
-               if (bounceto)
+               if (bounceto) {
                        StrBufAppendPrintf(NewInstr, "bounceto|%s\n", bounceto);
-               if (envelope_from)
+               }
+               if (envelope_from) {
                        StrBufAppendPrintf(NewInstr, "envelope_from|%s\n", envelope_from);
-
+               }
                for (i = 0; i < num_tokens(instr, '\n'); ++i) {
                        extract_token(cfgline, instr, i, '\n', sizeof cfgline);
                        if (!strncasecmp(cfgline, HKEY("remote|"))) {
@@ -423,10 +427,12 @@ void smtp_process_one_msg(long qmsgnum) {
                                               "smtpclient: recp: <%s> , result: %d (%s)", recp, new_result, server_response);
                                        if ((new_result / 100) == 2) {
                                                ++num_success;
-                                       } else {
+                                       }
+                                       else {
                                                if ((new_result / 100) == 5) {
                                                        ++num_fail;
-                                               } else {
+                                               }
+                                               else {
                                                        ++num_delayed;
                                                }
                                                StrBufAppendPrintf
@@ -477,7 +483,8 @@ void smtp_process_one_msg(long qmsgnum) {
                        deletes[1] = msgid;
                        CtdlDeleteMessages(SMTP_SPOOLOUT_ROOM, deletes, 2, "");
                        FreeStrBuf(&NewInstr);  // We have to free NewInstr here, no longer needed
-               } else {
+               }
+               else {
                        // replace the old queue entry with the new one
                        syslog(LOG_DEBUG, "smtpclient: %ld rewriting", qmsgnum);
                        msg = convert_internet_message_buf(&NewInstr);  // This function will free NewInstr for us
@@ -485,14 +492,17 @@ void smtp_process_one_msg(long qmsgnum) {
                        CM_Free(msg);
                        CtdlDeleteMessages(SMTP_SPOOLOUT_ROOM, &qmsgnum, 1, "");
                }
-       } else {
+       }
+       else {
                syslog(LOG_DEBUG, "smtpclient: %ld retry time not reached", qmsgnum);
        }
 
-       if (bounceto != NULL)
+       if (bounceto != NULL) {
                free(bounceto);
-       if (envelope_from != NULL)
+       }
+       if (envelope_from != NULL) {
                free(envelope_from);
+       }
        free(instr);
 }
 
@@ -529,8 +539,9 @@ void smtp_do_queue(void) {
         * don't really require extremely fine granularity here, we'll do it
         * with a static variable instead.
         */
-       if (doing_smtpclient)
+       if (doing_smtpclient) {
                return;
+       }
        doing_smtpclient = 1;
 
        syslog(LOG_DEBUG, "smtpclient: start queue run");
index 440084454d9e779ba947b3883bfadfb19e354be0..a77f73dd6d5e095c136c2361968f66f6594df4c4 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Utility functions for the Citadel SMTP implementation
  *
- * Copyright (c) 1998-2020 by the citadel.org team
+ * Copyright (c) 1998-2021 by the citadel.org team
  *
  * 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.
@@ -50,8 +50,7 @@
 #include "ctdl_module.h"
 #include "smtp_util.h"
 
-const char *smtp_get_Recipients(void)
-{
+const char *smtp_get_Recipients(void) {
        struct citsmtp *sSMTP = SMTP;
 
        if (sSMTP == NULL)
@@ -70,8 +69,7 @@ const char *smtp_get_Recipients(void)
  *     SDB_BOUNCE_ALL          Advise the sender that all deliveries have failed and will not be retried
  *     SDB_WARN                Warn the sender about all 4XX transient delays
  */
-void smtp_do_bounce(const char *instr, int is_final)
-{
+void smtp_do_bounce(const char *instr, int is_final) {
        int i;
        int lines;
        int status;
@@ -96,7 +94,6 @@ void smtp_do_bounce(const char *instr, int is_final)
 
        StrBufAppendPrintf(boundary, "%s_%04x%04x", CtdlGetConfigStr("c_fqdn"), getpid(), ++seq);
 
-
        /* Start building our bounce message */
 
        bmsg = (struct CtdlMessage *) malloc(sizeof(struct CtdlMessage));
@@ -121,8 +118,7 @@ void smtp_do_bounce(const char *instr, int is_final)
        StrBufAppendBufPlain(BounceMB, HKEY("\r\n"), 0);
        StrBufAppendBufPlain(BounceMB, HKEY("Content-type: text/plain\r\n\r\n"), 0);
 
-       if (is_final == SDB_BOUNCE_ALL)
-       {
+       if (is_final == SDB_BOUNCE_ALL) {
                StrBufAppendBufPlain(
                        BounceMB,
                        HKEY(   "A message you sent could not be delivered "
@@ -131,8 +127,7 @@ void smtp_do_bounce(const char *instr, int is_final)
                                "Giving up on the following addresses:\n\n"),
                        0);
        }
-       else if (is_final == SDB_BOUNCE_FATALS)
-       {
+       else if (is_final == SDB_BOUNCE_FATALS) {
                StrBufAppendBufPlain(
                        BounceMB,
                        HKEY(   "A message you sent could not be delivered "
@@ -140,8 +135,7 @@ void smtp_do_bounce(const char *instr, int is_final)
                                "The following addresses were undeliverable:\n\n"),
                        0);
        }
-       else if (is_final == SDB_WARN)
-       {
+       else if (is_final == SDB_WARN) {
                StrBufAppendBufPlain(
                        BounceMB,
                        HKEY("A message you sent has not been delivered "
@@ -150,8 +144,7 @@ void smtp_do_bounce(const char *instr, int is_final)
                                "The following addresses were undeliverable:\n\n"),
                        0);
        }
-       else    // should never get here
-       {
+       else {  // should never get here
                StrBufAppendBufPlain(BounceMB, HKEY("This message should never occur.\n\n"), 0);
        }
 
@@ -257,9 +250,6 @@ void smtp_do_bounce(const char *instr, int is_final)
 }
 
 
-
-
-
 char *smtpcodes[][2] = {
        { "211 - System status / system help reply" },
        { "214", "Help message" },
@@ -312,7 +302,6 @@ char *smtpcodes[][2] = {
 };
 
 
-
 char *smtpstatus(int code) {
        int i;
 
@@ -324,4 +313,3 @@ char *smtpstatus(int code) {
        
        return("Unknown or other SMTP status");
 }
-