]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/init.c
Add libtool support based upon patch by Bart Hartgers <Hartgers@kfm1.phys.tue.nl>
[openldap] / libraries / libldap / init.c
index 603e510ba38e9627955ea18cfb37c6f1a2185592..3801899ceba76c077f8fbd809be377f4f4b09558 100644 (file)
@@ -5,6 +5,7 @@
 
 #include <ac/socket.h>
 #include <ac/string.h>
+#include <ac/ctype.h>
 #include <ac/time.h>
 
 #include "ldap-int.h"
@@ -28,7 +29,7 @@ struct ol_keyvalue {
        int                     value;
 };
 
-struct ol_keyvalue deref_kv[] = {
+static struct ol_keyvalue deref_kv[] = {
        {"never", LDAP_DEREF_NEVER},
        {"searching", LDAP_DEREF_SEARCHING},
        {"finding", LDAP_DEREF_FINDING},
@@ -36,13 +37,13 @@ struct ol_keyvalue deref_kv[] = {
        {NULL, 0}
 };
 
-struct ol_attribute {
+static struct ol_attribute {
        int                     type;
        char*           name;
        void*           data;
        size_t          offset;
 } attrs[] = {
-       {ATTR_KV,               "DEREF",                &deref_kv,
+       {ATTR_KV,               "DEREF",        deref_kv, /* or &deref_kv[0] */
                offsetof(struct ldapoptions, ldo_deref)},
        {ATTR_INT,              "SIZELIMIT",    NULL,
                offsetof(struct ldapoptions, ldo_sizelimit)},
@@ -57,7 +58,7 @@ struct ol_attribute {
        {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_NONE,     NULL, 0}
+       {ATTR_NONE,             NULL,           NULL,   0}
 };
 
 #define MAX_LDAP_ATTR_LEN  sizeof("SIZELIMIT")
@@ -155,7 +156,7 @@ static void openldap_ldap_init_w_conf(const char *file)
 
                        case ATTR_STRING:
                                if (* (char**) p != NULL) free(* (char**) p);
-                               * (char**) p = strdup(opt);
+                               * (char**) p = ldap_strdup(opt);
                                break;
                        }
                }
@@ -186,12 +187,6 @@ static void openldap_ldap_init_w_userconf(const char *file)
 
        /* try file */
        openldap_ldap_init_w_conf(file);
-
-       if(path == NULL) {
-               /* try .file */
-               sprintf(path, ".%s", file);
-               openldap_ldap_init_w_conf(path);
-       }
 }
 
 static void openldap_ldap_init_w_env(const char *prefix)
@@ -256,7 +251,7 @@ static void openldap_ldap_init_w_env(const char *prefix)
                        if (*value == '\0') {
                                * (char**) p = NULL;
                        } else {
-                               * (char**) p = strdup(value);
+                               * (char**) p = ldap_strdup(value);
                        }
                        break;
                }
@@ -274,7 +269,7 @@ void openldap_ldap_initialize( void )
        gopts.ldo_timelimit = LDAP_NO_LIMIT;
        gopts.ldo_sizelimit = LDAP_NO_LIMIT;
 
-       gopts.ldo_defhost = strdup("localhost");
+       gopts.ldo_defhost = ldap_strdup("localhost");
        gopts.ldo_defport = LDAP_PORT;
 
        gopts.ldo_refhoplimit = LDAP_DEFAULT_REFHOPLIMIT;
@@ -288,6 +283,15 @@ void openldap_ldap_initialize( void )
 
        openldap_ldap_init_w_conf(DEFAULT_LDAP_CONF_FILE);
        openldap_ldap_init_w_userconf(DEFAULT_LDAP_USERRC_FILE);
+
+       {
+               char *altfile = getenv("LDAPRC");
+
+               if( altfile != NULL ) {
+                       openldap_ldap_init_w_conf( altfile );
+               }
+       }
+
        openldap_ldap_init_w_env(NULL);
 
        openldap_ldap_initialized = 1;