X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Finternet_addressing.c;h=ebc419f6abfbc60444615a81e9b28435cfcaf94c;hb=a2fda4eafb51bbf58c04471522aa2d0f116c797e;hp=3bbf8245423a483b77b05d3c5ab5b205c189913f;hpb=ad9a6c64ba19522bf721195183abe07fba5429bb;p=citadel.git diff --git a/citadel/internet_addressing.c b/citadel/internet_addressing.c index 3bbf82454..ebc419f6a 100644 --- a/citadel/internet_addressing.c +++ b/citadel/internet_addressing.c @@ -30,14 +30,13 @@ #include #include #include +#include #include "citadel.h" #include "server.h" -#include "serv_extensions.h" #include "sysdep_decls.h" #include "citserver.h" #include "support.h" #include "config.h" -#include "tools.h" #include "msgbase.h" #include "internet_addressing.h" #include "user_ops.h" @@ -70,7 +69,7 @@ int CtdlHostAlias(char *fqdn) { char host[256], type[256]; if (fqdn == NULL) return(hostalias_nomatch); - if (strlen(fqdn) == 0) return(hostalias_nomatch); + if (IsEmptyStr(fqdn)) return(hostalias_nomatch); if (!strcasecmp(fqdn, "localhost")) return(hostalias_localhost); if (!strcasecmp(fqdn, config.c_fqdn)) return(hostalias_localhost); if (!strcasecmp(fqdn, config.c_nodename)) return(hostalias_localhost); @@ -116,16 +115,17 @@ int CtdlHostAlias(char *fqdn) { */ int fuzzy_match(struct ctdluser *us, char *matchstring) { int a; + long len; if ( (!strncasecmp(matchstring, "cit", 3)) && (atol(&matchstring[3]) == us->usernum)) { return 0; } - - for (a=0; afullname); ++a) { + len = strlen(matchstring); + for (a=0; !IsEmptyStr(&us->fullname[a]); ++a) { if (!strncasecmp(&us->fullname[a], - matchstring, strlen(matchstring))) { + matchstring, len)) { return 0; } } @@ -175,7 +175,7 @@ void process_rfc822_addr(const char *rfc822, char *user, char *node, char *name) stripout(name, '<', '>'); /* strip anything to the left of a bang */ - while ((strlen(name) > 0) && (haschar(name, '!') > 0)) + while ((!IsEmptyStr(name)) && (haschar(name, '!') > 0)) strcpy(name, &name[1]); /* and anything to the right of a @ or % */ @@ -195,7 +195,7 @@ void process_rfc822_addr(const char *rfc822, char *user, char *node, char *name) /* but if there are a set of quotes, that supersedes everything */ if (haschar(rfc822, 34) == 2) { strcpy(name, rfc822); - while ((strlen(name) > 0) && (name[0] != 34)) { + while ((!IsEmptyStr(name)) && (name[0] != 34)) { strcpy(&name[0], &name[1]); } strcpy(&name[0], &name[1]); @@ -215,7 +215,7 @@ void process_rfc822_addr(const char *rfc822, char *user, char *node, char *name) } /* strip anything to the left of a bang */ - while ((strlen(user) > 0) && (haschar(user, '!') > 0)) + while ((!IsEmptyStr(user)) && (haschar(user, '!') > 0)) strcpy(user, &user[1]); /* and anything to the right of a @ or % */ @@ -250,15 +250,15 @@ void process_rfc822_addr(const char *rfc822, char *user, char *node, char *name) else { /* strip anything to the left of a @ */ - while ((strlen(node) > 0) && (haschar(node, '@') > 0)) + while ((!IsEmptyStr(node)) && (haschar(node, '@') > 0)) strcpy(node, &node[1]); /* strip anything to the left of a % */ - while ((strlen(node) > 0) && (haschar(node, '%') > 0)) + while ((!IsEmptyStr(node)) && (haschar(node, '%') > 0)) strcpy(node, &node[1]); /* reduce multiple system bang paths to node!user */ - while ((strlen(node) > 0) && (haschar(node, '!') > 1)) + while ((!IsEmptyStr(node)) && (haschar(node, '!') > 1)) strcpy(node, &node[1]); /* now get rid of the user portion of a node!user string */ @@ -276,7 +276,7 @@ void process_rfc822_addr(const char *rfc822, char *user, char *node, char *name) * but no name outside the brackets, we now have an empty name. In * this case, use the user portion of the address as the name. */ - if ((strlen(name) == 0) && (strlen(user) > 0)) { + if ((IsEmptyStr(name)) && (!IsEmptyStr(user))) { strcpy(name, user); } } @@ -336,7 +336,7 @@ int convert_field(struct CtdlMessage *msg, int beg, int end) { else if (!strcasecmp(key, "From")) { process_rfc822_addr(value, user, node, name); - lprintf(CTDL_DEBUG, "Converted to <%s@%s> (%s)\n", user, node, name); + CtdlLogPrintf(CTDL_DEBUG, "Converted to <%s@%s> (%s)\n", user, node, name); snprintf(addr, sizeof addr, "%s@%s", user, node); if (msg->cm_fields['A'] == NULL) msg->cm_fields['A'] = strdup(name); @@ -366,7 +366,7 @@ int convert_field(struct CtdlMessage *msg, int beg, int end) { else if (!strcasecmp(key, "Message-ID")) { if (msg->cm_fields['I'] != NULL) { - lprintf(CTDL_WARNING, "duplicate message id\n"); + CtdlLogPrintf(CTDL_WARNING, "duplicate message id\n"); } if (msg->cm_fields['I'] == NULL) { @@ -553,14 +553,14 @@ void directory_key(char *key, char *addr) { int i; int keylen = 0; - for (i=0; i\n", key); + CtdlLogPrintf(CTDL_DEBUG, "Directory key is <%s>\n", key); } @@ -603,7 +603,7 @@ void CtdlDirectoryInit(void) { void CtdlDirectoryAddUser(char *internet_addr, char *citadel_addr) { char key[SIZ]; - lprintf(CTDL_DEBUG, "Dir: %s --> %s\n", + CtdlLogPrintf(CTDL_DEBUG, "Dir: %s --> %s\n", internet_addr, citadel_addr); if (IsDirectory(internet_addr, 0) == 0) return; @@ -708,7 +708,7 @@ char *harvest_collected_addresses(struct CtdlMessage *msg) { if ( (h != hostalias_localhost) && (h != hostalias_directory) ) { coll = realloc(coll, strlen(coll) + strlen(addr) + 4); if (coll == NULL) return(NULL); - if (strlen(coll) > 0) { + if (!IsEmptyStr(coll)) { strcat(coll, ","); } striplt(addr); @@ -718,7 +718,7 @@ char *harvest_collected_addresses(struct CtdlMessage *msg) { } } - if (strlen(coll) == 0) { + if (IsEmptyStr(coll)) { free(coll); return(NULL); }