striplt() is now string_trim()
[citadel.git] / citadel / server / internet_addressing.c
index 5acf8b781a38f7d876321cb1dc2c42c27cf68d9c..59a1b91b2eb5cd478ee843ab00585ff494e49f2a 100644 (file)
@@ -174,8 +174,8 @@ int expand_aliases(char *name, char *aliases) {
                        if (bar) {
                                bar[0] = 0;
                                ++bar;
-                               striplt(aaa);
-                               striplt(bar);
+                               string_trim(aaa);
+                               string_trim(bar);
                                if ( (!IsEmptyStr(aaa)) && (!strcasecmp(name, aaa)) ) {
                                        syslog(LOG_DEBUG, "internet_addressing: global alias <%s> to <%s>", name, bar);
                                        strcpy(name, bar);
@@ -191,7 +191,7 @@ int expand_aliases(char *name, char *aliases) {
        safestrncpy(original_name, name, sizeof original_name);
 
        // should these checks still be here, or maybe move them to split_recps() ?
-       striplt(name);
+       string_trim(name);
        remove_any_whitespace_to_the_left_or_right_of_at_symbol(name);
        stripallbut(name, '<', '>');
 
@@ -277,7 +277,7 @@ Array *split_recps(char *addresses, Array *append_to) {
        for (i=0; i<num_addresses; ++i) {
                char this_address[256];
                extract_token(this_address, a, i, ',', sizeof this_address);
-               striplt(this_address);                          // strip leading and trailing whitespace
+               string_trim(this_address);                              // strip leading and trailing whitespace
                stripout(this_address, '(', ')');               // remove any portion in parentheses
                stripallbut(this_address, '<', '>');            // if angle brackets are present, keep only what is inside them
                if (!IsEmptyStr(this_address)) {
@@ -713,9 +713,6 @@ void unfold_rfc822_field(char **field, char **FieldEnd)
 
 
 // Split an RFC822-style address into userid, host, and full name
-//
-// Note: This still handles obsolete address syntaxes such as user%node@node and ...node!user
-//       We should probably remove that.
 void process_rfc822_addr(const char *rfc822, char *user, char *node, char *name) {
        int a;
 
@@ -729,20 +726,12 @@ void process_rfc822_addr(const char *rfc822, char *user, char *node, char *name)
        strcpy(name, rfc822);
        stripout(name, '<', '>');
 
-       // strip anything to the left of a bang
-       while ((!IsEmptyStr(name)) && (haschar(name, '!') > 0))
-               strcpy(name, &name[1]);
-
-       // and anything to the right of a @ or %
+       // and anything to the right of a @
        for (a = 0; name[a] != '\0'; ++a) {
                if (name[a] == '@') {
                        name[a] = 0;
                        break;
                }
-               if (name[a] == '%') {
-                       name[a] = 0;
-                       break;
-               }
        }
 
        // but if there are parentheses, that changes the rules...
@@ -775,23 +764,14 @@ void process_rfc822_addr(const char *rfc822, char *user, char *node, char *name)
                stripallbut(user, '<', '>');
        }
 
-       // strip anything to the left of a bang
-       while ((!IsEmptyStr(user)) && (haschar(user, '!') > 0))
-               strcpy(user, &user[1]);
-
-       // and anything to the right of a @ or %
+       // and anything to the right of a @
        for (a = 0; user[a] != '\0'; ++a) {
                if (user[a] == '@') {
                        user[a] = 0;
                        break;
                }
-               if (user[a] == '%') {
-                       user[a] = 0;
-                       break;
-               }
        }
 
-
        // extract node name
        strcpy(node, rfc822);
 
@@ -804,39 +784,20 @@ void process_rfc822_addr(const char *rfc822, char *user, char *node, char *name)
        }
 
        // If no node specified, tack ours on instead
-       if (
-               (haschar(node, '@')==0)
-               && (haschar(node, '%')==0)
-               && (haschar(node, '!')==0)
-       ) {
+       if (haschar(node, '@') == 0) {
                strcpy(node, CtdlGetConfigStr("c_nodename"));
        }
        else {
-
                // strip anything to the left of a @
-               while ((!IsEmptyStr(node)) && (haschar(node, '@') > 0))
-                       strcpy(node, &node[1]);
-       
-               // strip anything to the left of a %
-               while ((!IsEmptyStr(node)) && (haschar(node, '%') > 0))
-                       strcpy(node, &node[1]);
-       
-               // reduce multiple system bang paths to node!user
-               while ((!IsEmptyStr(node)) && (haschar(node, '!') > 1))
+               while ((!IsEmptyStr(node)) && (haschar(node, '@') > 0)) {
                        strcpy(node, &node[1]);
-       
-               // now get rid of the user portion of a node!user string
-               for (a = 0; node[a] != '\0'; ++a)
-                       if (node[a] == '!') {
-                               node[a] = 0;
-                               break;
-                       }
+               }
        }
 
        // strip leading and trailing spaces in all strings
-       striplt(user);
-       striplt(node);
-       striplt(name);
+       string_trim(user);
+       string_trim(node);
+       string_trim(name);
 
        // If we processed a string that had the address in angle brackets
        // but no name outside the brackets, we now have an empty name.  In
@@ -1180,11 +1141,11 @@ char *rfc822_fetch_field(const char *rfc822, const char *fieldname) {
                strcat(fieldbuf, " ");
                cont = &fieldbuf[strlen(fieldbuf)];
                ptr = cmemreadline(ptr, cont, SIZ-strlen(fieldbuf) );
-               striplt(cont);
+               string_trim(cont);
        }
 
        strcpy(fieldbuf, &fieldbuf[strlen(fieldhdr)]);
-       striplt(fieldbuf);
+       string_trim(fieldbuf);
 
        return(fieldbuf);
 }
@@ -1221,7 +1182,7 @@ int IsDirectory(char *addr, int allow_masq_domains) {
        int h;
 
        extract_token(domain, addr, 1, '@', sizeof domain);
-       striplt(domain);
+       string_trim(domain);
 
        h = CtdlHostAlias(domain);
 
@@ -1347,8 +1308,9 @@ char *harvest_collected_addresses(struct CtdlMessage *msg) {
                if (!CM_IsEmpty(msg, field)) {
                        for (j=0; j<num_tokens(msg->cm_fields[field], ','); ++j) {
                                extract_token(addr, msg->cm_fields[field], j, ',', sizeof addr);
-                               if (strstr(addr, "=?") != NULL)
+                               if (strstr(addr, "=?") != NULL) {
                                        utf8ify_rfc822_string(addr);
+                               }
                                process_rfc822_addr(addr, user, node, name);
                                h = CtdlHostAlias(node);
                                if (h != hostalias_localhost) {
@@ -1357,7 +1319,7 @@ char *harvest_collected_addresses(struct CtdlMessage *msg) {
                                        if (!IsEmptyStr(coll)) {
                                                strcat(coll, ",");
                                        }
-                                       striplt(addr);
+                                       string_trim(addr);
                                        strcat(coll, addr);
                                }
                        }