]> code.citadel.org Git - citadel.git/blobdiff - citadel/server/internet_addressing.c
internet_addressing.c: minor cleanups
[citadel.git] / citadel / server / internet_addressing.c
index f9bd07309c38e8b1e171d08f6fcbda27e3a4839a..09d7fd1315a1ad7b380e84e5c3a644597872dd39 100644 (file)
@@ -3,8 +3,7 @@
 //
 // Copyright (c) 1987-2024 by the citadel.org team
 //
-// This program is open source software.  Use, duplication, or disclosure
-// is subject to the terms of the GNU General Public License, version 3.
+// This program is open source software.  Use, duplication, or disclosure is subject to the GNU General Public License version 3.
 
 #include "sysdep.h"
 #include <stdlib.h>
@@ -88,7 +87,7 @@ int CtdlIsMe(char *addr, int addr_buf_len) {
        struct recptypes *recp;
        int i;
 
-       recp = validate_recipients(addr, NULL, 0);
+       recp = validate_recipients(addr, 0);
        if (recp == NULL) return(0);
 
        if (recp->num_local == 0) {
@@ -296,9 +295,8 @@ Array *split_recps(char *addresses, Array *append_to) {
 //
 // Caller needs to free the result using free_recipients()
 //
-struct recptypes *validate_recipients(char *supplied_recipients, const char *RemoteIdentifier, int Flags) {
+struct recptypes *validate_recipients(char *recipients_in, int Flags) {
        struct recptypes *ret;
-       char *recipients = NULL;
        char append[SIZ];
        long len;
        int mailtype;
@@ -314,14 +312,7 @@ struct recptypes *validate_recipients(char *supplied_recipients, const char *Rem
        if (ret == NULL) return(NULL);
        memset(ret, 0, sizeof(struct recptypes));                                       // set all values to null/zero
 
-       if (supplied_recipients == NULL) {
-               recipients = strdup("");
-       }
-       else {
-               recipients = strdup(supplied_recipients);
-       }
-
-       len = strlen(recipients) + 1024;                                                // allocate memory
+       len = strlen(recipients_in) + 1024;                                             // allocate memory
        ret->errormsg = malloc(len);
        ret->recp_local = malloc(len);
        ret->recp_internet = malloc(len);
@@ -337,7 +328,7 @@ struct recptypes *validate_recipients(char *supplied_recipients, const char *Rem
        ret->display_recp[0] = 0;
        ret->recptypes_magic = RECPTYPES_MAGIC;
 
-       Array *recp_array = split_recps(supplied_recipients, NULL);
+       Array *recp_array = split_recps(recipients_in, NULL);
 
        char *aliases = CtdlGetSysConfig(GLOBAL_ALIASES);                               // First hit the Global Alias Table
 
@@ -347,7 +338,7 @@ struct recptypes *validate_recipients(char *supplied_recipients, const char *Rem
                strncpy(this_recp, org_recp, sizeof this_recp);
 
                int i;
-               for (i=0; i<3; ++i) {                                           // pass three times through the aliaser
+               for (i=0; i<3; ++i) {                                                   // pass three times through the aliaser
                        mailtype = expand_aliases(this_recp, aliases);
        
                        // If an alias expanded to multiple recipients, strip off those recipients and append them
@@ -509,7 +500,6 @@ struct recptypes *validate_recipients(char *supplied_recipients, const char *Rem
                ret->num_local, ret->num_room, ret->num_internet, ret->num_error
        );
 
-       free(recipients);
        if (recp_array) {
                array_free(recp_array);
        }
@@ -676,12 +666,8 @@ void unfold_rfc822_field(char **field, char **FieldEnd)
 
        *FieldEnd = pFieldEnd;
        // convert non-space whitespace to spaces, and remove double blanks
-       for (sField = *field = pField; 
-            sField < pFieldEnd; 
-            pField++, sField++)
-       {
-               if ((*sField=='\r') || (*sField=='\n'))
-               {
+       for (sField = *field = pField; sField < pFieldEnd; pField++, sField++) {
+               if ((*sField=='\r') || (*sField=='\n')) {
                        int offset = 1;
                        while ( ( (*(sField + offset) == '\r') || (*(sField + offset) == '\n' )) && (sField + offset < pFieldEnd) ) {
                                offset ++;
@@ -697,8 +683,7 @@ void unfold_rfc822_field(char **field, char **FieldEnd)
                                        pField++;
                                        sField++;
                                        
-                                       while ((sField < pFieldEnd) && 
-                                              isspace(*sField))
+                                       while ((sField < pFieldEnd) && isspace(*sField))
                                                sField++;
                                        *pField = *sField;
                                }
@@ -953,8 +938,6 @@ int convert_field(struct CtdlMessage *msg, const char *beg, const char *end) {
                processed = 1;
        }
 
-
-
        // Clean up and move on.
        free(key);      // Don't free 'value', it's actually the same buffer
        return processed;
@@ -1049,7 +1032,6 @@ struct CtdlMessage *convert_internet_message_buf(StrBuf **rfc822) {
                        }
 
                        ++pos;
-
                }
 
                // At this point we have a field.  Are we interested in it?
@@ -1066,8 +1048,9 @@ struct CtdlMessage *convert_internet_message_buf(StrBuf **rfc822) {
                        alldone = 1;
        }
        StrBufAppendBufPlain(OtherHeaders, HKEY("\n"), 0);
-       if (pos < totalend)
+       if (pos < totalend) {
                StrBufAppendBufPlain(OtherHeaders, pos, totalend - pos, 0);
+       }
        FreeStrBuf(rfc822);
        CM_SetAsFieldSB(msg, eMessageText, &OtherHeaders);
 
@@ -1238,8 +1221,7 @@ int CtdlDirectoryLookup(char *target, char *internet_addr, size_t targbuflen) {
 }
 
 
-// Harvest any email addresses that someone might want to have in their
-// "collected addresses" book.
+// Harvest any email addresses that someone might want to have in their "collected addresses" book.
 char *harvest_collected_addresses(struct CtdlMessage *msg) {
        char *coll = NULL;
        char addr[256];