]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/vcard/serv_vcard.c
* strlen holy war: loops. in loops it's very evil. the easy ones go away now.
[citadel.git] / citadel / modules / vcard / serv_vcard.c
index d6a29a196b9f81fc490279b33510156a8eeecc8f..99ed9026a6db0f55a5228aca77cdcbc93e95aaa6 100644 (file)
@@ -111,7 +111,7 @@ void vcard_extract_internet_addresses(struct CtdlMessage *msg,
                if (s != NULL) {
                        addr = strdup(s);
                        striplt(addr);
-                       if (strlen(addr) > 0) {
+                       if (!IsEmptyStr(addr)) {
                                if (callback != NULL) {
                                        callback(addr, citadel_address);
                                }
@@ -225,7 +225,7 @@ void extract_inet_email_addrs(char *emailaddrbuf, size_t emailaddrbuf_len,
        while (s = vcard_get_prop(v, "email;internet", 0, instance++, 0),  s != NULL) {
                addr = strdup(s);
                striplt(addr);
-               if (strlen(addr) > 0) {
+               if (!IsEmptyStr(addr)) {
                        if ( (IsDirectory(addr, 1)) || 
                             (!local_addrs_only) ) {
                                ++saved_instance;
@@ -404,7 +404,7 @@ int vcard_upload_beforesave(struct CtdlMessage *msg) {
                sprintf(buf, "http://%s/%s.vfb",
                        config.c_fqdn,
                        usbuf.fullname);
-               for (i=0; i<strlen(buf); ++i) {
+               for (i=0; !IsEmptyStr(&buf[i]); ++i) {
                        if (buf[i] == ' ') buf[i] = '_';
                }
                vcard_set_prop(v, "FBURL;PREF", buf, 0);
@@ -675,7 +675,7 @@ void cmd_regi(char *argbuf) {
                if (a==2) strcpy(tmpcity, buf);
                if (a==3) strcpy(tmpstate, buf);
                if (a==4) {
-                       for (c=0; c<strlen(buf); ++c) {
+                       for (c=0; !IsEmptyStr(&buf[c]); ++c) {
                                if ((buf[c]>='0') && (buf[c]<='9')) {
                                        b = strlen(tmpzip);
                                        tmpzip[b] = buf[c];
@@ -789,7 +789,7 @@ void vcard_newuser(struct ctdluser *usbuf) {
        v = vcard_new();
        if (v == NULL) return;
        sprintf(buf, "%s@%s", usbuf->fullname, config.c_fqdn);
-       for (i=0; i<strlen(buf); ++i) {
+       for (i=0; !IsEmptyStr(&buf[i]); ++i) {
                if (buf[i] == ' ') buf[i] = '_';
        }
        vcard_add_prop(v, "fn", usbuf->fullname);
@@ -881,6 +881,8 @@ void vcard_delete_remove(char *room, long msgnum) {
        int linelen;
 
        if (msgnum <= 0L) return;
+       
+       if (room == NULL) return;
 
        if (strcasecmp(room, ADDRESS_BOOK_ROOM)) {
                return;
@@ -921,7 +923,7 @@ void cmd_gvsn(char *argbuf)
 
        cprintf("%d valid screen names:\n", LISTING_FOLLOWS);
        cprintf("%s\n", CC->user.fullname);
-       if ( (strlen(CC->cs_inet_fn) > 0) && (strcasecmp(CC->user.fullname, CC->cs_inet_fn)) ) {
+       if ( (!IsEmptyStr(CC->cs_inet_fn)) && (strcasecmp(CC->user.fullname, CC->cs_inet_fn)) ) {
                cprintf("%s\n", CC->cs_inet_fn);
        }
        cprintf("000\n");
@@ -940,10 +942,10 @@ void cmd_gvea(char *argbuf)
        if (CtdlAccessCheck(ac_logged_in)) return;
 
        cprintf("%d valid email addresses:\n", LISTING_FOLLOWS);
-       if (strlen(CC->cs_inet_email) > 0) {
+       if (!IsEmptyStr(CC->cs_inet_email)) {
                cprintf("%s\n", CC->cs_inet_email);
        }
-       if (strlen(CC->cs_inet_other_emails) > 0) {
+       if (!IsEmptyStr(CC->cs_inet_other_emails)) {
                num_secondary_emails = num_tokens(CC->cs_inet_other_emails, '|');
                for (i=0; i<num_secondary_emails; ++i) {
                        extract_token(buf, CC->cs_inet_other_emails,i,'|',sizeof CC->cs_inet_other_emails);
@@ -1176,7 +1178,7 @@ struct vCard *vcard_new_from_rfc822_addr(char *addr) {
        vcard_set_prop(v, "email;internet", email, 0);
 
        snprintf(uid, sizeof uid, "collected: %s %s@%s", name, user, node);
-       for (i=0; i<strlen(uid); ++i) {
+       for (i=0; !IsEmptyStr(&uid[i]); ++i) {
                if (isspace(uid[i])) uid[i] = '_';
                uid[i] = tolower(uid[i]);
        }
@@ -1243,7 +1245,7 @@ void store_this_ha(struct addresses_to_be_filed *aptr) {
        CtdlForEachMessage(MSGS_ALL, 0, NULL, "^[Tt][Ee][Xx][Tt]/.*[Vv][Cc][Aa][Rr][Dd]$", NULL,
                strip_addresses_already_have, aptr->collected_addresses);
 
-       if (strlen(aptr->collected_addresses) > 0)
+       if (!IsEmptyStr(aptr->collected_addresses))
           for (i=0; i<num_tokens(aptr->collected_addresses, ','); ++i) {
 
                /* Make a vCard out of each address */