]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/references.c
Add char* ldap_pvt_get_fqdn(char*) which returns the FQDN of the
[openldap] / libraries / libldap / references.c
index dfb901535f7f375e9ce29ad8a04dd056f271b655..6a6d723356bdd161edc524303f995e1af03e9e7f 100644 (file)
@@ -1,5 +1,6 @@
+/* $OpenLDAP$ */
 /*
- * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
  */
 /*
 #include "portable.h"
 
 #include <stdio.h>
-#include <stdlib.h>
 
-#include <ac/ctype.h>
+#include <ac/stdlib.h>
+
 #include <ac/socket.h>
 #include <ac/string.h>
 #include <ac/time.h>
 
 #include "ldap-int.h"
 
-/* ARGSUSED */
 LDAPMessage *
 ldap_first_reference( LDAP *ld, LDAPMessage *chain )
 {
        assert( ld != NULL );
+       assert( LDAP_VALID( ld ) );
        assert( chain !=  NULL );
 
-       if ( ld == NULL || chain == NULLMSG ) {
-               return NULLMSG;
+       if ( ld == NULL || chain == NULL ) {
+               return NULL;
        }
 
        return chain->lm_msgtype == LDAP_RES_SEARCH_REFERENCE
@@ -38,15 +39,16 @@ LDAPMessage *
 ldap_next_reference( LDAP *ld, LDAPMessage *ref )
 {
        assert( ld != NULL );
+       assert( LDAP_VALID( ld ) );
        assert( ref !=  NULL );
 
-       if ( ld == NULL || ref == NULLMSG ) {
-               return NULLMSG;
+       if ( ld == NULL || ref == NULL ) {
+               return NULL;
        }
 
        for (
                ref = ref->lm_chain;
-               ref != NULLMSG;
+               ref != NULL;
                ref = ref->lm_chain )
        {
                if( ref->lm_msgtype == LDAP_RES_SEARCH_REFERENCE ) {
@@ -54,7 +56,7 @@ ldap_next_reference( LDAP *ld, LDAPMessage *ref )
                }
        }
 
-       return( NULLMSG );
+       return( NULL );
 }
 
 int
@@ -63,12 +65,14 @@ ldap_count_references( LDAP *ld, LDAPMessage *chain )
        int     i;
 
        assert( ld != NULL );
+       assert( LDAP_VALID( ld ) );
        assert( chain !=  NULL );
 
        if ( ld == NULL ) {
                return -1;
        }
 
+       
        for ( i = 0; chain != NULL; chain = chain->lm_chain ) {
                if( chain->lm_msgtype == LDAP_RES_SEARCH_REFERENCE ) {
                        i++;
@@ -91,6 +95,7 @@ ldap_parse_reference(
        int rc;
 
        assert( ld != NULL );
+       assert( LDAP_VALID( ld ) );
        assert( ref !=  NULL );
 
        if( ld == NULL || ref == NULL ||
@@ -100,7 +105,7 @@ ldap_parse_reference(
        }
 
        /* make a private copy of BerElement */
-       SAFEMEMCPY(&be, ref->lm_ber, sizeof(be));
+       AC_MEMCPY(&be, ref->lm_ber, sizeof(be));
        
        if ( ber_scanf( &be, "{v" /*}*/, &refs ) == LBER_ERROR ) {
                rc = LDAP_DECODING_ERROR;
@@ -126,7 +131,7 @@ free_and_return:
                *referralsp = refs;
 
        } else {
-               ldap_value_free( refs );
+               LDAP_VFREE( refs );
        }
 
        if( freeit ) {
@@ -136,15 +141,15 @@ free_and_return:
        if( rc != LDAP_SUCCESS ) {
                ld->ld_errno = rc;
 
-               if( ld->ld_matched != NULL )
-                       free( ld->ld_matched );
-
-               ld->ld_matched = NULL;
-
-               if( ld->ld_error != NULL )
-                       free( ld->ld_error );
+               if( ld->ld_matched != NULL ) {
+                       LDAP_FREE( ld->ld_matched );
+                       ld->ld_matched = NULL;
+               }
 
-               ld->ld_error = NULL;
+               if( ld->ld_error != NULL ) {
+                       LDAP_FREE( ld->ld_error );
+                       ld->ld_error = NULL;
+               }
        }
 
        return rc;