]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/open.c
Fix ldap_send_initial_request() to open connection if not already
[openldap] / libraries / libldap / open.c
index f66b8dba3f00ffea2a48d8d5c83c6333d6c86a75..5792b92e0a5a6a41efc5308b776ef08e36eaaa26 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.
@@ -53,13 +48,11 @@ ldap_open( char *host, int port )
                return( NULL );
        }
 
-       /* we'll assume we're talking version 2 for now */
-       ld->ld_version = LDAP_VERSION2;
-
 #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 )) {
+               if(srv != NULL) free( (char*) srv );
                ldap_ld_free( ld, 0 );
                return( NULL );
        }
@@ -158,9 +151,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);
        }
 
@@ -171,7 +164,7 @@ ldap_init( char *defhost, int defport )
        }
 
        if ( openldap_ldap_global_options.ldo_defbase != NULL ) {
-               ld->ld_options.ldo_defbase = ldap_strdup(
+               ld->ld_options.ldo_defbase = strdup(
                        openldap_ldap_global_options.ldo_defbase);
        }
 
@@ -200,6 +193,10 @@ ldap_init( char *defhost, int defport )
 #endif /* LDAP_CHARSET_8859 == LDAP_DEFAULT_CHARSET */
 #endif /* STR_TRANSLATION && LDAP_DEFAULT_CHARSET */
 
+       /* we'll assume we're talking version 2 for now */
+       ld->ld_version = LDAP_VERSION2;
+
+       ld->ld_sb.sb_sd = -1;
        return( ld );
 }