]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/ldap/serv_ldap.c
* strlen holy war: loops. in loops it's very evil. the easy ones go away now.
[citadel.git] / citadel / modules / ldap / serv_ldap.c
index b79be37bd9625b6a3d83783066195418628b2507..06cf124e1d284e4aeaf89623dc8a74001e8189b1 100644 (file)
@@ -82,10 +82,13 @@ void CtdlCreateLdapRoot(void) {
 
        /* We just want the top-level dc, not the whole hierarchy */
        strcpy(topdc, config.c_ldap_base_dn);
-       for (i=0; i<strlen(topdc); ++i) {
-               if (topdc[i] == ',') topdc[i] = 0;
+       for (i=0; !IsEmptyStr(&topdc[i]); ++i) {
+               if (topdc[i] == ',') {
+                       topdc[i] = 0;
+                       break;
+               }
        }
-       for (i=0; i<strlen(topdc); ++i) {
+       for (i=0; !IsEmptyStr(&topdc[i]); ++i) {
                if (topdc[i] == '=') strcpy(topdc, &topdc[i+1]);
        }
 
@@ -468,7 +471,7 @@ void ctdl_vcard_to_ldap(struct CtdlMessage *msg, int op) {
                 */
                if ( (!strcasecmp(v->prop[i].name, "fburl"))
                   ||(!strncasecmp(v->prop[i].name, "fburl;", 6)) ) {
-                       if ( (strlen(calFBURL) == 0)
+                       if ( (IsEmptyStr(calFBURL))
                           || (!strncasecmp(v->prop[i].name, "fburl;pref", 10)) ) {
                                safestrncpy(calFBURL, v->prop[i].value, sizeof calFBURL);
                        }
@@ -488,8 +491,8 @@ void ctdl_vcard_to_ldap(struct CtdlMessage *msg, int op) {
        attrs[num_attrs-1]->mod_values[1]       = NULL;
 
        /* "givenname" (first name) based on info in vCard */
-       if (strlen(givenname) == 0) strcpy(givenname, "_");
-       if (strlen(sn) == 0) strcpy(sn, "_");
+       if (IsEmptyStr(givenname)) strcpy(givenname, "_");
+       if (IsEmptyStr(sn)) strcpy(sn, "_");
        attrs = realloc(attrs, (sizeof(LDAPMod *) * ++num_attrs) );
        attrs[num_attrs-1] = malloc(sizeof(LDAPMod));
        memset(attrs[num_attrs-1], 0, sizeof(LDAPMod));
@@ -524,7 +527,7 @@ void ctdl_vcard_to_ldap(struct CtdlMessage *msg, int op) {
        }
 
        /* Add a "calFBURL" attribute if a calendar free/busy URL exists */
-       if (strlen(calFBURL) > 0) {
+       if (!IsEmptyStr(calFBURL)) {
                attrs = realloc(attrs, (sizeof(LDAPMod *) * ++num_attrs) );
                attrs[num_attrs-1] = malloc(sizeof(LDAPMod));
                memset(attrs[num_attrs-1], 0, sizeof(LDAPMod));
@@ -597,7 +600,7 @@ CTDL_MODULE_INIT(ldap)
 #ifdef HAVE_LDAP
        CtdlRegisterCleanupHook(serv_ldap_cleanup);
 
-       if (strlen(config.c_ldap_host) > 0) {
+       if (!IsEmptyStr(config.c_ldap_host)) {
                CtdlConnectToLdap();
        }