Moar cleanup
authorArt Cancro <ajc@citadel.org>
Sun, 9 Apr 2017 18:33:49 +0000 (14:33 -0400)
committerArt Cancro <ajc@citadel.org>
Sun, 9 Apr 2017 18:33:49 +0000 (14:33 -0400)
citadel/citserver.c
citadel/internet_addressing.c
citadel/netconfig.c
citadel/server_main.c

index 447d68f066850b15e15e895795b36c2f289e3c94..59dc31443f72ec494c2be44c38c4b51a21264402 100644 (file)
@@ -52,10 +52,12 @@ void cit_backtrace(void)
        size = backtrace(stack_frames, sizeof(stack_frames) / sizeof(void*));
        strings = backtrace_symbols(stack_frames, size);
        for (i = 0; i < size; i++) {
-               if (strings != NULL)
-                       syslog(LOG_ALERT, "%s %s\n", p, strings[i]);
-               else
-                       syslog(LOG_ALERT, "%s %p\n", p, stack_frames[i]);
+               if (strings != NULL) {
+                       syslog(LOG_DEBUG, "citserver: %s %s", p, strings[i]);
+               }
+               else {
+                       syslog(LOG_DEBUG, "citserver: %s %p", p, stack_frames[i]);
+               }
        }
        free(strings);
 #endif
@@ -81,12 +83,13 @@ void cit_oneline_backtrace(void)
                                StrBufAppendPrintf(Buf, "%p : ", stack_frames[i]);
                }
                free(strings);
-               syslog(LOG_ALERT, "%s %s\n", IOSTR, ChrPtr(Buf));
+               syslog(LOG_DEBUG, "citserver: %s %s", IOSTR, ChrPtr(Buf));
                FreeStrBuf(&Buf);
        }
 #endif
 }
 
+
 /*
  * print the actual stack frame.
  */
@@ -101,10 +104,12 @@ void cit_panic_backtrace(int SigNum)
        size = backtrace(stack_frames, sizeof(stack_frames) / sizeof(void*));
        strings = backtrace_symbols(stack_frames, size);
        for (i = 0; i < size; i++) {
-               if (strings != NULL)
-                       syslog(LOG_ALERT, "%s\n", strings[i]);
-               else
-                       syslog(LOG_ALERT, "%p\n", stack_frames[i]);
+               if (strings != NULL) {
+                       syslog(LOG_DEBUG, "%s", strings[i]);
+               }
+               else {
+                       syslog(LOG_DEBUG, "%p", stack_frames[i]);
+               }
        }
        free(strings);
 #endif
index 7914da90668cfeaa359115bbb0f9d07c439dcfb1..355656ab52d888ee93297c9771a7285ca730a6f7 100644 (file)
@@ -83,12 +83,12 @@ void utf8ify_rfc822_string(char *buf) {
        char encoding[16];
        char istr[1024];
        iconv_t ic = (iconv_t)(-1) ;
-       char *ibuf;                     /**< Buffer of characters to be converted */
-       char *obuf;                     /**< Buffer for converted characters */
-       size_t ibuflen;                 /**< Length of input buffer */
-       size_t obuflen;                 /**< Length of output buffer */
-       char *isav;                     /**< Saved pointer to input buffer */
-       char *osav;                     /**< Saved pointer to output buffer */
+       char *ibuf;                     // Buffer of characters to be converted
+       char *obuf;                     // Buffer for converted characters
+       size_t ibuflen;                 // Length of input buffer
+       size_t obuflen;                 // Length of output buffer
+       char *isav;                     // Saved pointer to input buffer
+       char *osav;                     // Saved pointer to output buffer
        int passes = 0;
        int i, len, delta;
        int illegal_non_rfc2047_encoding = 0;
@@ -103,7 +103,7 @@ void utf8ify_rfc822_string(char *buf) {
        for (i=0; i<len; ++i) {
                if ((buf[i] < 32) || (buf[i] > 126)) {
                        illegal_non_rfc2047_encoding = 1;
-                       i = len; ///< take a shortcut, it won't be more than one.
+                       i = len;        // take a shortcut, it won't be more than one.
                }
        }
        if (illegal_non_rfc2047_encoding) {
@@ -189,10 +189,10 @@ void utf8ify_rfc822_string(char *buf) {
 
                ibuf = malloc(1024);
                isav = ibuf;
-               if (!strcasecmp(encoding, "B")) {       /**< base64 */
+               if (!strcasecmp(encoding, "B")) {       // base64
                        ibuflen = CtdlDecodeBase64(ibuf, istr, strlen(istr));
                }
-               else if (!strcasecmp(encoding, "Q")) {  /**< quoted-printable */
+               else if (!strcasecmp(encoding, "Q")) {  // quoted-printable
                        size_t len;
                        unsigned long pos;
                        
@@ -207,7 +207,7 @@ void utf8ify_rfc822_string(char *buf) {
                        ibuflen = CtdlDecodeQuotedPrintable(ibuf, istr, len);
                }
                else {
-                       strcpy(ibuf, istr);             /**< unknown encoding */
+                       strcpy(ibuf, istr);             // unknown encoding
                        ibuflen = strlen(istr);
                }
 
@@ -269,7 +269,6 @@ inline void utf8ify_rfc822_string(char *a){};
 #endif
 
 
-
 struct trynamebuf {
        char buffer1[SIZ];
        char buffer2[SIZ];
@@ -325,7 +324,6 @@ int CtdlHostAlias(char *fqdn) {
 }
 
 
-
 /*
  * Determine whether a given Internet address belongs to the current user
  */
@@ -379,9 +377,6 @@ void sanitize_truncated_recipient(char *str)
 }
 
 
-
-
-
 /*
  * This function is self explanatory.
  * (What can I say, I'm in a weird mood today...)
@@ -406,7 +401,6 @@ void remove_any_whitespace_to_the_left_or_right_of_at_symbol(char *name)
 
 /*
  * Aliasing for network mail.
- * (Error messages have been commented out, because this is a server.)
  */
 int alias(char *name)
 {                              /* process alias and routing info for mail */
@@ -522,7 +516,6 @@ int alias(char *name)
 }
 
 
-
 /*
  * Validate recipients, count delivery types and errors, and handle aliasing
  * FIXME check for dupes!!!!!
@@ -876,8 +869,9 @@ char *qp_encode_email_addrs(char *source)
        EncodedMaxLen = nColons * (sizeof(headerStr) + 3) + SourceLen * 3;
        Encoded = (char*) malloc (EncodedMaxLen);
 
-       for (i = 0; i < nColons; i++)
+       for (i = 0; i < nColons; i++) {
                source[AddrPtr[i]++] = '\0';
+       }
        /* TODO: if libidn, this might get larger*/
        user = malloc(SourceLen + 1);
        node = malloc(SourceLen + 1);
@@ -994,7 +988,6 @@ void unfold_rfc822_field(char **field, char **FieldEnd)
 }
 
 
-
 /*
  * Split an RFC822-style address into userid, host, and full name
  *
@@ -1133,7 +1126,6 @@ void process_rfc822_addr(const char *rfc822, char *user, char *node, char *name)
 }
 
 
-
 /*
  * convert_field() is a helper function for convert_internet_message().
  * Given start/end positions for an rfc822 field, it converts it to a Citadel
@@ -1339,7 +1331,6 @@ struct CtdlMessage *convert_internet_message(char *rfc822) {
 }
 
 
-
 struct CtdlMessage *convert_internet_message_buf(StrBuf **rfc822)
 {
        struct CtdlMessage *msg;
@@ -1434,7 +1425,6 @@ struct CtdlMessage *convert_internet_message_buf(StrBuf **rfc822)
 }
 
 
-
 /*
  * Look for a particular header field in an RFC822 message text.  If the
  * requested field is found, it is unfolded (if necessary) and returned to
@@ -1486,7 +1476,6 @@ char *rfc822_fetch_field(const char *rfc822, const char *fieldname) {
 }
 
 
-
 /*****************************************************************************
  *                      DIRECTORY MANAGEMENT FUNCTIONS                       *
  *****************************************************************************/
index a6dd412874a7e96d907a431c6c8c9842c2f4b5eb..e59337f2740cb4b96f0d99ce2834fa88a384b1c6 100644 (file)
@@ -205,7 +205,7 @@ void write_netconfig_to_configdb(long roomnum, const char *raw_netconfig)
                if ((enc_len > 1) && (enc[enc_len-2] == 13)) enc[enc_len-2] = 0;
                if ((enc_len > 0) && (enc[enc_len-1] == 10)) enc[enc_len-1] = 0;
                enc[enc_len] = 0;
-               syslog(LOG_DEBUG, "Writing key '%s' (length=%d)", keyname, enc_len);
+               syslog(LOG_DEBUG, "netconfig: writing key '%s' (length=%d)", keyname, enc_len);
                CtdlSetConfigStr(keyname, enc);
                free(enc);
        }
@@ -651,7 +651,7 @@ void cmd_netp(char *cmdbuf)
                        "An unknown Citadel server called \"%s\" attempted to connect from %s [%s].\n",
                        node, CCC->cs_host, CCC->cs_addr
                );
-               syslog(LOG_WARNING, "%s", err_buf);
+               syslog(LOG_WARNING, "netconfig: %s", err_buf);
                cprintf("%d authentication failed\n", ERROR + PASSWORD_REQUIRED);
                CtdlAideMessage(err_buf, "IGNet Networking");
                DeleteHash(&working_ignetcfg);
@@ -665,7 +665,7 @@ void cmd_netp(char *cmdbuf)
                        "A Citadel server at %s [%s] failed to authenticate as network node \"%s\".\n",
                        CCC->cs_host, CCC->cs_addr, node
                );
-               syslog(LOG_WARNING, "%s", err_buf);
+               syslog(LOG_WARNING, "netconfig: %s", err_buf);
                cprintf("%d authentication failed\n", ERROR + PASSWORD_REQUIRED);
 
                CtdlAideMessage(err_buf, "IGNet Networking");
@@ -675,7 +675,7 @@ void cmd_netp(char *cmdbuf)
        }
 
        if (CtdlNetworkTalkingTo(node, nodelen, NTT_CHECK)) {
-               syslog(LOG_WARNING, "Duplicate session for network node <%s>", node);
+               syslog(LOG_WARNING, "netconfig: duplicate session for network node <%s>", node);
                cprintf("%d Already talking to %s right now\n", ERROR + RESOURCE_BUSY, node);
                DeleteHash(&working_ignetcfg);
                FreeStrBuf(&NodeStr);
@@ -683,7 +683,7 @@ void cmd_netp(char *cmdbuf)
        }
        nodelen = safestrncpy(CCC->net_node, node, sizeof CCC->net_node);
        CtdlNetworkTalkingTo(CCC->net_node, nodelen, NTT_ADD);
-       syslog(LOG_NOTICE, "Network node <%s> logged in from %s [%s]",
+       syslog(LOG_INFO, "netconfig: network node <%s> logged in from %s [%s]",
                CCC->net_node, CCC->cs_host, CCC->cs_addr
        );
        cprintf("%d authenticated as network node '%s'\n", CIT_OK, CCC->net_node);
@@ -845,7 +845,7 @@ int CtdlIsValidNode(const StrBuf **nexthop,
         * First try the neighbor nodes
         */
        if (GetCount(IgnetCfg) == 0) {
-               syslog(LOG_INFO, "IgnetCfg is empty!");
+               syslog(LOG_INFO, "netconfig: IgnetCfg is empty!");
                if (nexthop != NULL) {
                        *nexthop = NULL;
                }
@@ -877,7 +877,7 @@ int CtdlIsValidNode(const StrBuf **nexthop,
        /*
         * If we get to this point, the supplied node name is bogus.
         */
-       syslog(LOG_ERR, "Invalid node name <%s>", ChrPtr(node));
+       syslog(LOG_ERR, "netconfig: invalid node name <%s>", ChrPtr(node));
        return(-1);
 }
 
@@ -898,7 +898,7 @@ void convert_legacy_netcfg_files(void)
        dh = opendir(ctdl_netcfg_dir);
        if (!dh) return;
 
-       syslog(LOG_INFO, "Legacy netconfig files exist - converting them!");
+       syslog(LOG_INFO, "netconfig: legacy netconfig files exist - converting them!");
 
        while (dit = readdir(dh), dit != NULL) {                // yes, we use the non-reentrant version; we're not in threaded mode yet
                roomnum = atol(dit->d_name);
index 10915b3c4ecfc5e626029f2d4c8de343de09c18f..f1b458e5a98ce2ac1fea353f8841d6ee3eab3b95 100644 (file)
 uid_t ctdluid = 0;
 const char *CitadelServiceUDS="citadel-UDS";
 const char *CitadelServiceTCP="citadel-TCP";
-
-
-
 void go_threading(void);
 
 
-
 /*
  * Create or remove a lock file, so we only have one Citadel Server running at a time.
  */
@@ -47,7 +43,6 @@ void ctdl_lockfile(int yo) {
        static char lockfilename[SIZ];
        static FILE *fp;
 
-
        if (yo) {
                syslog(LOG_DEBUG, "main: creating lockfile");
                snprintf(lockfilename, sizeof lockfilename, "%s/citadel.lock", ctdl_run_dir);
@@ -70,10 +65,6 @@ void ctdl_lockfile(int yo) {
 }
 
 
-
-
-
-
 /*
  * Here's where it all begins.
  */
@@ -216,15 +207,13 @@ int main(int argc, char **argv)
        }
 
        /* Tell 'em who's in da house */
-       syslog(LOG_NOTICE, " ");
-       syslog(LOG_NOTICE, " ");
-       syslog(LOG_NOTICE, "*** Citadel server engine ***\n");
-       syslog(LOG_NOTICE, "Version %d (build %s) ***", REV_LEVEL, svn_revision());
-       syslog(LOG_NOTICE, "Copyright (C) 1987-2017 by the Citadel development team.");
-       syslog(LOG_NOTICE, "This program is distributed under the terms of the GNU "
-                                       "General Public License.");
-       syslog(LOG_NOTICE, " ");
-       syslog(LOG_DEBUG, "Called as: %s", argv[0]);
+       syslog(LOG_INFO, " ");
+       syslog(LOG_INFO, " ");
+       syslog(LOG_INFO, "*** Citadel server engine ***\n");
+       syslog(LOG_INFO, "Version %d (build %s) ***", REV_LEVEL, svn_revision());
+       syslog(LOG_INFO, "Copyright (C) 1987-2017 by the Citadel development team.");
+       syslog(LOG_INFO, "This program is distributed under the terms of the GNU General Public License.");
+       syslog(LOG_INFO, " ");
        syslog(LOG_INFO, "%s", libcitadel_version_string());
 
 #ifdef HAVE_RUN_DIR