syntax cleanup internet_addressing.c
authorArt Cancro <ajc@citadel.org>
Fri, 5 Feb 2021 15:15:57 +0000 (10:15 -0500)
committerArt Cancro <ajc@citadel.org>
Fri, 5 Feb 2021 15:15:57 +0000 (10:15 -0500)
citadel/internet_addressing.c
citadel/modules/listdeliver/serv_listdeliver.c
citadel/modules/smtp/serv_smtp.c
citadel/msgbase.c

index 6eb6de6..afa637a 100644 (file)
@@ -394,8 +394,7 @@ void remove_any_whitespace_to_the_left_or_right_of_at_symbol(char *name) {
 /*
  * Aliasing for network mail.
  */
-int alias(char *name)
-{                              /* process alias and routing info for mail */
+int alias(char *name) {                                /* process alias and routing info for mail */
        int a;
        char aaa[SIZ];
        int at = 0;
@@ -722,8 +721,7 @@ void free_recipients(struct recptypes *valid) {
 }
 
 
-char *qp_encode_email_addrs(char *source)
-{
+char *qp_encode_email_addrs(char *source) {
        char *user, *node, *name;
        const char headerStr[] = "=?UTF-8?Q?";
        char *Encoded;
@@ -758,20 +756,19 @@ char *qp_encode_email_addrs(char *source)
                        free (AddrPtr), AddrPtr = ptr;
 
                        ptr = (long *) malloc(sizeof (long) * nAddrPtrMax * 2);
-                       memset(&ptr[nAddrPtrMax], 0, 
-                              sizeof (long) * nAddrPtrMax);
+                       memset(&ptr[nAddrPtrMax], 0, sizeof (long) * nAddrPtrMax);
 
                        memcpy (ptr, AddrUtf8, sizeof (long) * nAddrPtrMax);
                        free (AddrUtf8), AddrUtf8 = ptr;
                        nAddrPtrMax *= 2;                               
                }
-               if (((unsigned char) source[i] < 32) || 
-                   ((unsigned char) source[i] > 126)) {
+               if (((unsigned char) source[i] < 32) || ((unsigned char) source[i] > 126)) {
                        need_to_encode = 1;
                        AddrUtf8[nColons] = 1;
                }
-               if (source[i] == '"')
+               if (source[i] == '"') {
                        InQuotes = !InQuotes;
+               }
                if (!InQuotes && source[i] == ',') {
                        AddrPtr[nColons] = i;
                        nColons++;
@@ -801,28 +798,19 @@ char *qp_encode_email_addrs(char *source)
        for (i = 0; i < nColons && nPtr != NULL; i++) {
                nmax = EncodedMaxLen - (nPtr - Encoded);
                if (AddrUtf8[i]) {
-                       process_rfc822_addr(&source[AddrPtr[i]], 
-                                           user,
-                                           node,
-                                           name);
+                       process_rfc822_addr(&source[AddrPtr[i]], user, node, name);
                        /* TODO: libIDN here ! */
                        if (IsEmptyStr(name)) {
-                               n = snprintf(nPtr, nmax, 
-                                            (i==0)?"%s@%s" : ",%s@%s",
-                                            user, node);
+                               n = snprintf(nPtr, nmax, (i==0)?"%s@%s" : ",%s@%s", user, node);
                        }
                        else {
                                EncodedName = rfc2047encode(name, strlen(name));                        
-                               n = snprintf(nPtr, nmax, 
-                                            (i==0)?"%s <%s@%s>" : ",%s <%s@%s>",
-                                            EncodedName, user, node);
+                               n = snprintf(nPtr, nmax, (i==0)?"%s <%s@%s>" : ",%s <%s@%s>", EncodedName, user, node);
                                free(EncodedName);
                        }
                }
                else { 
-                       n = snprintf(nPtr, nmax, 
-                                    (i==0)?"%s" : ",%s",
-                                    &source[AddrPtr[i]]);
+                       n = snprintf(nPtr, nmax, (i==0)?"%s" : ",%s", &source[AddrPtr[i]]);
                }
                if (n > 0 )
                        nPtr += n;
@@ -884,8 +872,7 @@ void unfold_rfc822_field(char **field, char **FieldEnd)
                else {
                        if (*sField=='\"') quote = 1 - quote;
                        if (!quote) {
-                               if (isspace(*sField))
-                               {
+                               if (isspace(*sField)) {
                                        *pField = ' ';
                                        pField++;
                                        sField++;
@@ -909,8 +896,7 @@ void unfold_rfc822_field(char **field, char **FieldEnd)
  * Split an RFC822-style address into userid, host, and full name
  *
  */
-void process_rfc822_addr(const char *rfc822, char *user, char *node, char *name)
-{
+void process_rfc822_addr(const char *rfc822, char *user, char *node, char *name) {
        int a;
 
        strcpy(user, "");
@@ -1005,7 +991,6 @@ void process_rfc822_addr(const char *rfc822, char *user, char *node, char *name)
        ) {
                strcpy(node, CtdlGetConfigStr("c_nodename"));
        }
-
        else {
 
                /* strip anything to the left of a @ */
index 793291b..e63a3b5 100644 (file)
@@ -53,18 +53,37 @@ struct lddata {
 
 void listdeliver_do_msg(long msgnum, void *userdata) {
        struct lddata *ld = (struct lddata *) userdata;
-       ld->msgnum = msgnum;
+       if (!ld) return;
        char buf[SIZ];
 
-       struct CtdlMessage *TheMessage = CtdlFetchMessage(msgnum, 1);
+       ld->msgnum = msgnum;
+       if (msgnum <= 0) return;
 
-       int config_lines = num_tokens(ld->netconf, '\n');
-       for (int i=0; i<config_lines; ++i) {
-               extract_token(buf, ld->netconf, i, '\n', sizeof buf);
-               if ( (!strncasecmp(buf, "listrecp|", 9)) || (!strncasecmp(buf, "digestrecp|", 11)) ) {
-                       syslog(LOG_DEBUG, "\033[32mDeliver %ld to %s\033[0m", msgnum, buf);
-                       // FIXME
+       struct CtdlMessage *TheMessage = CtdlFetchMessage(msgnum, 1);
+       if (!TheMessage) return;
+
+       char *recipients = malloc(strlen(ld->netconf));
+       if (recipients) {
+               recipients[0] = 0;
+
+               int config_lines = num_tokens(ld->netconf, '\n');
+               for (int i=0; i<config_lines; ++i) {
+                       extract_token(buf, ld->netconf, i, '\n', sizeof buf);
+                       if (!strncasecmp(buf, "listrecp|", 9)) {
+                               if (recipients[0] != 0) {
+                                       strcat(recipients, ",");
+                               }
+                               strcat(recipients, &buf[9]);
+                       }
+                       if (!strncasecmp(buf, "digestrecp|", 11)) {
+                               if (recipients[0] != 0) {
+                                       strcat(recipients, ",");
+                               }
+                               strcat(recipients, &buf[11]);
+                       }
                }
+               syslog(LOG_DEBUG, "\033[33m%s\033[0m", recipients);
+               free(recipients);
        }
        CM_Free(TheMessage);
 }
index 15110cd..a698065 100644 (file)
@@ -891,10 +891,12 @@ void smtp_data(long offset, long flags)
                        CM_SetField(msg, eAuthor, CCC->user.fullname, strlen(CCC->user.fullname));
 
                if (!validemail) {
-                       if (sSMTP->preferred_sender_email != NULL)
+                       if (sSMTP->preferred_sender_email != NULL) {
                                CM_SetField(msg, erFc822Addr, SKEY(sSMTP->preferred_sender_email));
-                       else
+                       }
+                       else {
                                CM_SetField(msg, erFc822Addr, CCC->cs_inet_email, strlen(CCC->cs_inet_email));
+                       }
                }
        }
 
index 901ee07..cd15f7c 100644 (file)
@@ -2659,7 +2659,7 @@ void ReplicationChecks(struct CtdlMessage *msg) {
  * Save a message to disk and submit it into the delivery system.
  */
 long CtdlSubmitMsg(struct CtdlMessage *msg,    /* message to save */
-                  struct recptypes *recps,             /* recipients (if mail) */
+                  struct recptypes *recps,     /* recipients (if mail) */
                   const char *force            /* force a particular room? */
 ) {
        char hold_rm[ROOMNAMELEN];