]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/init.c
A little cleanup of last 2 commits
[openldap] / libraries / libldap / init.c
index 82778a79dd0bc5568960ca65b875629147cf13f9..093cedf32f4f47bbeb537e9a352bb0bcfc981c68 100644 (file)
@@ -1,6 +1,6 @@
 /* $OpenLDAP$ */
 /*
- * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
  */
 #include "portable.h"
@@ -115,7 +115,12 @@ static void openldap_ldap_init_w_conf(
                return;
        }
 
+#ifdef NEW_LOGGING
+       LDAP_LOG ( CONFIG, DETAIL1, 
+               "openldap_init_w_conf: trying %s\n", file, 0, 0 );
+#else
        Debug(LDAP_DEBUG_TRACE, "ldap_init: trying %s\n", file, 0, 0);
+#endif
 
        fp = fopen(file, "r");
        if(fp == NULL) {
@@ -123,7 +128,11 @@ static void openldap_ldap_init_w_conf(
                return;
        }
 
+#ifdef NEW_LOGGING
+       LDAP_LOG ( CONFIG, DETAIL1, "openldap_init_w_conf: using %s\n", file, 0, 0 );
+#else
        Debug(LDAP_DEBUG_TRACE, "ldap_init: using %s\n", file, 0, 0);
+#endif
 
        while((start = fgets(linebuf, sizeof(linebuf), fp)) != NULL) {
                /* skip lines starting with '#' */
@@ -251,23 +260,33 @@ static void openldap_ldap_init_w_userconf(const char *file)
        home = getenv("HOME");
 
        if (home != NULL) {
+#ifdef NEW_LOGGING
+       LDAP_LOG ( CONFIG, ARGS, 
+               "openldap_init_w_userconf: HOME env is %s\n", home, 0, 0 );
+#else
                Debug(LDAP_DEBUG_TRACE, "ldap_init: HOME env is %s\n",
                      home, 0, 0);
-               path = LDAP_MALLOC(strlen(home) + strlen(file) + 3);
+#endif
+               path = LDAP_MALLOC(strlen(home) + strlen(file) + sizeof( LDAP_DIRSEP "."));
        } else {
+#ifdef NEW_LOGGING
+       LDAP_LOG ( CONFIG, ARGS, "openldap_init_w_userconf: HOME env is NULL\n",
+               0, 0, 0 );
+#else
                Debug(LDAP_DEBUG_TRACE, "ldap_init: HOME env is NULL\n",
                      0, 0, 0);
+#endif
        }
 
        if(home != NULL && path != NULL) {
                /* we assume UNIX path syntax is used... */
 
                /* try ~/file */
-               sprintf(path, "%s%s%s", home, LDAP_DIRSEP, file);
+               sprintf(path, "%s" LDAP_DIRSEP "%s", home, file);
                openldap_ldap_init_w_conf(path, 1);
 
                /* try ~/.file */
-               sprintf(path, "%s%s.%s", home, LDAP_DIRSEP, file);
+               sprintf(path, "%s" LDAP_DIRSEP ".%s", home, file);
                openldap_ldap_init_w_conf(path, 1);
        }
 
@@ -464,6 +483,8 @@ void ldap_int_initialize( struct ldapoptions *gopts, int *dbglvl )
 
        ldap_int_error_init();
 
+       ldap_int_utils_init();
+
 #ifdef HAVE_WINSOCK2
 {      WORD wVersionRequested;
        WSADATA wsaData;
@@ -502,8 +523,6 @@ void ldap_int_initialize( struct ldapoptions *gopts, int *dbglvl )
        || defined(HAVE_TLS) || defined(HAVE_CYRUS_SASL)
        ldap_int_hostname = ldap_pvt_get_fqdn( ldap_int_hostname );
 #endif
-       ldap_int_utils_init();
-
        if ( ldap_int_tblsize == 0 )
                ldap_int_ip_init();
 
@@ -534,26 +553,50 @@ void ldap_int_initialize( struct ldapoptions *gopts, int *dbglvl )
                char *altfile = getenv(LDAP_ENV_PREFIX "CONF");
 
                if( altfile != NULL ) {
+#ifdef NEW_LOGGING
+                       LDAP_LOG ( CONFIG, DETAIL1, 
+                               "openldap_init_w_userconf: %sCONF env is %s\n",
+                               LDAP_ENV_PREFIX, altfile, 0 );
+#else
                        Debug(LDAP_DEBUG_TRACE, "ldap_init: %s env is %s\n",
                              LDAP_ENV_PREFIX "CONF", altfile, 0);
+#endif
                        openldap_ldap_init_w_sysconf( altfile );
                }
                else
+#ifdef NEW_LOGGING
+                       LDAP_LOG ( CONFIG, DETAIL1, 
+                               "openldap_init_w_userconf: %sCONF env is NULL\n",
+                               LDAP_ENV_PREFIX, 0, 0 );
+#else
                        Debug(LDAP_DEBUG_TRACE, "ldap_init: %s env is NULL\n",
                              LDAP_ENV_PREFIX "CONF", 0, 0);
+#endif
        }
 
        {
                char *altfile = getenv(LDAP_ENV_PREFIX "RC");
 
                if( altfile != NULL ) {
+#ifdef NEW_LOGGING
+                       LDAP_LOG ( CONFIG, DETAIL1, 
+                               "openldap_init_w_userconf: %sRC env is %s\n",
+                               LDAP_ENV_PREFIX, altfile, 0 );
+#else
                        Debug(LDAP_DEBUG_TRACE, "ldap_init: %s env is %s\n",
                              LDAP_ENV_PREFIX "RC", altfile, 0);
+#endif
                        openldap_ldap_init_w_userconf( altfile );
                }
                else
+#ifdef NEW_LOGGING
+                       LDAP_LOG ( CONFIG, DETAIL1, 
+                               "openldap_init_w_userconf: %sRC env is NULL\n",
+                               LDAP_ENV_PREFIX, 0, 0 );
+#else
                        Debug(LDAP_DEBUG_TRACE, "ldap_init: %s env is NULL\n",
                              LDAP_ENV_PREFIX "RC", 0, 0);
+#endif
        }
 
        openldap_ldap_init_w_env(gopts, NULL);