#define ATTR_STRING 4
struct ol_keyvalue {
- char* key;
+ const char * key;
int value;
};
-static struct ol_keyvalue deref_kv[] = {
+static const struct ol_keyvalue deref_kv[] = {
{"never", LDAP_DEREF_NEVER},
{"searching", LDAP_DEREF_SEARCHING},
{"finding", LDAP_DEREF_FINDING},
{NULL, 0}
};
-static struct ol_attribute {
+static const struct ol_attribute {
int type;
- char* name;
- void* data;
+ const char * name;
+ const void * data;
size_t offset;
} attrs[] = {
{ATTR_KV, "DEREF", deref_kv, /* or &deref_kv[0] */
offsetof(struct ldapoptions, ldo_defhost)},
{ATTR_INT, "PORT", NULL,
offsetof(struct ldapoptions, ldo_defport)},
- {ATTR_BOOL, "REFERRALS", (void *) LDAP_BOOL_REFERRALS, 0},
- {ATTR_BOOL, "RESTART", (void *) LDAP_BOOL_RESTART, 0},
- {ATTR_BOOL, "DNS", (void *) LDAP_BOOL_DNS, 0},
+ {ATTR_BOOL, "REFERRALS", NULL, LDAP_BOOL_REFERRALS},
+ {ATTR_BOOL, "RESTART", NULL, LDAP_BOOL_RESTART},
+ {ATTR_BOOL, "DNS", NULL, LDAP_BOOL_DNS},
{ATTR_NONE, NULL, NULL, 0}
};
continue;
}
- p = &((char *) &gopts)[attrs[i].offset];
-
switch(attrs[i].type) {
case ATTR_BOOL:
if((strcasecmp(opt, "on") == 0)
|| (strcasecmp(opt, "yes") == 0)
|| (strcasecmp(opt, "true") == 0))
{
- LDAP_BOOL_SET(&gopts, (int) attrs[i].data);
+ LDAP_BOOL_SET(&gopts, attrs[i].offset);
} else {
- LDAP_BOOL_CLR(&gopts, (int) attrs[i].data);
+ LDAP_BOOL_CLR(&gopts, attrs[i].offset);
}
break;
case ATTR_INT:
+ p = &((char *) &gopts)[attrs[i].offset];
* (int*) p = atoi(opt);
break;
case ATTR_KV: {
- struct ol_keyvalue *kv;
+ const struct ol_keyvalue *kv;
- for(kv = (struct ol_keyvalue *) attrs[i].data;
+ for(kv = attrs[i].data;
kv->key != NULL;
kv++) {
if(strcasecmp(opt, kv->key) == 0) {
+ p = &((char *) &gopts)[attrs[i].offset];
* (int*) p = kv->value;
break;
}
} break;
case ATTR_STRING:
+ p = &((char *) &gopts)[attrs[i].offset];
if (* (char**) p != NULL) free(* (char**) p);
* (char**) p = strdup(opt);
break;
}
}
}
+
+ fclose(fp);
}
static void openldap_ldap_init_w_userconf(const char *file)
continue;
}
- p = &((char *) &gopts)[attrs[i].offset];
-
switch(attrs[i].type) {
case ATTR_BOOL:
if((strcasecmp(value, "on") == 0)
|| (strcasecmp(value, "yes") == 0)
|| (strcasecmp(value, "true") == 0))
{
- LDAP_BOOL_SET(&gopts, (int) attrs[i].data);
+ LDAP_BOOL_SET(&gopts, attrs[i].offset);
} else {
- LDAP_BOOL_CLR(&gopts, (int) attrs[i].data);
+ LDAP_BOOL_CLR(&gopts, attrs[i].offset);
}
break;
case ATTR_INT:
+ p = &((char *) &gopts)[attrs[i].offset];
* (int*) p = atoi(value);
break;
case ATTR_KV: {
- struct ol_keyvalue *kv;
+ const struct ol_keyvalue *kv;
- for(kv = (struct ol_keyvalue *) attrs[i].data;
+ for(kv = attrs[i].data;
kv->key != NULL;
kv++) {
if(strcasecmp(value, kv->key) == 0) {
+ p = &((char *) &gopts)[attrs[i].offset];
* (int*) p = kv->value;
break;
}
} break;
case ATTR_STRING:
+ p = &((char *) &gopts)[attrs[i].offset];
if (* (char**) p != NULL) free(* (char**) p);
if (*value == '\0') {
* (char**) p = NULL;
return;
}
- ldap_pvt_init_utils();
+ ldap_int_utils_init();
gopts.ldo_version = LDAP_VERSION2;
gopts.ldo_deref = LDAP_DEREF_NEVER;
LDAP_BOOL_ZERO(&gopts);
-#if defined( LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS ) || \
- LDAP_VERSION_MAX > LDAP_VERSION2
LDAP_BOOL_SET(&gopts, LDAP_BOOL_REFERRALS);
-#endif
openldap_ldap_initialized = 1;