]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/open.c
Add lber_log_print support to libldap.
[openldap] / libraries / libldap / open.c
index 2aa8eafcb259dc01894da1ca5b3b0b1481af666d..913c07fcfed5b091a48ccb14c70ed8f80071c78a 100644 (file)
@@ -1,4 +1,8 @@
 /*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/*  Portions
  *  Copyright (c) 1995 Regents of the University of Michigan.
  *  All rights reserved.
  *
@@ -7,10 +11,6 @@
 
 #include "portable.h"
 
-#ifndef lint 
-static char copyright[] = "@(#) Copyright (c) 1995 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
-
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -24,11 +24,6 @@ static char copyright[] = "@(#) Copyright (c) 1995 Regents of the University of
 
 #include "ldap-int.h"
 
-#ifdef LDAP_DEBUG
-int    ldap_debug;
-#endif
-
-
 /*
  * ldap_open - initialize and connect to an ldap server.  A magic cookie to
  * be used for future communication is returned on success, NULL on failure.
@@ -59,7 +54,7 @@ ldap_open( char *host, int port )
 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
        if (( srv = (LDAPServer *)calloc( 1, sizeof( LDAPServer ))) ==
            NULL || ( ld->ld_defhost != NULL && ( srv->lsrv_host =
-           ldap_strdup( ld->ld_defhost )) == NULL )) {
+           strdup( ld->ld_defhost )) == NULL )) {
                ldap_ld_free( ld, 0 );
                return( NULL );
        }
@@ -158,9 +153,9 @@ ldap_init( char *defhost, int defport )
        ld->ld_options.ldo_defhost = NULL;
 
        if ( defhost != NULL ) {
-               ld->ld_options.ldo_defhost = ldap_strdup( defhost );
+               ld->ld_options.ldo_defhost = strdup( defhost );
        } else {
-               ld->ld_options.ldo_defhost = ldap_strdup(
+               ld->ld_options.ldo_defhost = strdup(
                        openldap_ldap_global_options.ldo_defhost);
        }
 
@@ -170,10 +165,17 @@ ldap_init( char *defhost, int defport )
                return( NULL );
        }
 
+       if ( openldap_ldap_global_options.ldo_defbase != NULL ) {
+               ld->ld_options.ldo_defbase = strdup(
+                       openldap_ldap_global_options.ldo_defbase);
+       }
+
 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
        if (( ld->ld_selectinfo = ldap_new_select_info()) == NULL ) {
                free( (char*) ld->ld_options.ldo_defhost );
-               free( (char*) ld->ld_options.ldo_defbase );
+               if ( ld->ld_options.ldo_defbase == NULL ) {
+                       free( (char*) ld->ld_options.ldo_defbase );
+               }
                free( (char*) ld );
            WSACleanup( );
                return( NULL );