Did away with lprintf all together now its called CtdlLogPrintf()
[citadel.git] / citadel / internet_addressing.c
index c4bfc9b51210b9ceeccec77037f3f304bc680883..ebc419f6abfbc60444615a81e9b28435cfcaf94c 100644 (file)
 #include <sys/wait.h>
 #include <string.h>
 #include <limits.h>
+#include <libcitadel.h>
 #include "citadel.h"
 #include "server.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"
@@ -115,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; a<strlen(us->fullname); ++a) {
+       len = strlen(matchstring);
+       for (a=0; !IsEmptyStr(&us->fullname[a]); ++a) {
                if (!strncasecmp(&us->fullname[a],
-                  matchstring, strlen(matchstring))) {
+                  matchstring, len)) {
                        return 0;
                }
        }
@@ -335,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);
@@ -365,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) {
@@ -552,14 +553,14 @@ void directory_key(char *key, char *addr) {
        int i;
        int keylen = 0;
 
-       for (i=0; i<strlen(addr); ++i) {
+       for (i=0; !IsEmptyStr(&addr[i]); ++i) {
                if (!isspace(addr[i])) {
                        key[keylen++] = tolower(addr[i]);
                }
        }
        key[keylen++] = 0;
 
-       lprintf(CTDL_DEBUG, "Directory key is <%s>\n", key);
+       CtdlLogPrintf(CTDL_DEBUG, "Directory key is <%s>\n", key);
 }
 
 
@@ -602,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;