]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/entry.c
BDB_INDEX code does no harm (but no good yet, not used by filters yet).
[openldap] / servers / slapd / entry.c
index a7cb17baefeebc678c2022e897e9ad7243b0506d..2c9ce52b6f07200e56d8e004f9e044ace37ae87c 100644 (file)
@@ -15,6 +15,7 @@
 #include <ac/string.h>
 
 #include "slap.h"
+#include "ldif.h"
 
 static unsigned char   *ebuf;  /* buf returned by entry2str             */
 static unsigned char   *ecur;  /* pointer to end of currently used ebuf */
@@ -114,13 +115,15 @@ str2entry( char *s )
 
                        if ( e->e_dn != NULL ) {
 #ifdef NEW_LOGGING
-                               LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1,
-                                          "str2entry: entry %ld has multiple dns \"%s\" and \"%s\" (second ignored)\n",
-                                          e->e_id, e->e_dn, value.bv_val != NULL ? value.bv_val : "" ));
+                               LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, "str2entry: "
+                                       "entry %ld has multiple dns \"%s\" and \"%s\" "
+                                       "(second ignored)\n",
+                                       (long) e->e_id, e->e_dn, value.bv_val != NULL ? value.bv_val : "" ));
 #else
-                               Debug( LDAP_DEBUG_ANY,
- "str2entry: entry %ld has multiple dns \"%s\" and \"%s\" (second ignored)\n",
-                                   e->e_id, e->e_dn,
+                               Debug( LDAP_DEBUG_ANY, "str2entry: "
+                                       "entry %ld has multiple dns \"%s\" and \"%s\" "
+                                       "(second ignored)\n",
+                                   (long) e->e_id, e->e_dn,
                                        value.bv_val != NULL ? value.bv_val : "" );
 #endif
                                if( value.bv_val != NULL ) free( value.bv_val );
@@ -236,10 +239,11 @@ str2entry( char *s )
        if ( e->e_dn == NULL ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_INFO,
-                          "str2entry:  entry %ld has no dn.\n", e->e_id ));
+                          "str2entry:  entry %ld has no dn.\n",
+                               (long) e->e_id ));
 #else
                Debug( LDAP_DEBUG_ANY, "str2entry: entry %ld has no dn\n",
-                   e->e_id, 0, 0 );
+                   (long) e->e_id, 0, 0 );
 #endif
                entry_free( e );
                return( NULL );
@@ -320,8 +324,14 @@ entry2str(
 void
 entry_free( Entry *e )
 {
-       Attribute       *a, *next;
+       /* free an entry structure */
+       assert( e != NULL );
 
+       /* e_private must be freed by the caller */
+       assert( e->e_private == NULL );
+       e->e_private = NULL;
+
+       /* free DNs */
        if ( e->e_dn != NULL ) {
                free( e->e_dn );
                e->e_dn = NULL;
@@ -330,12 +340,11 @@ entry_free( Entry *e )
                free( e->e_ndn );
                e->e_ndn = NULL;
        }
-       for ( a = e->e_attrs; a != NULL; a = next ) {
-               next = a->a_next;
-               attr_free( a );
-       }
+
+       /* free attributes */
+       attrs_free( e->e_attrs );
        e->e_attrs = NULL;
-       e->e_private = NULL;
+
        free( e );
 }
 
@@ -371,21 +380,20 @@ entry_id_cmp( Entry *e1, Entry *e2 )
        return( e1->e_id < e2->e_id ? -1 : (e1->e_id > e2->e_id ? 1 : 0) );
 }
 
-#define SLAPD_SLEEPY 1
-#ifdef SLAPD_SLEEPY
+#ifdef SLAPD_BDB
 
-/* a DER encoded entry looks like:
+/* a LBER encoded entry looks like:
  *
- * entry :== SEQUENCE {
- *             dn              DistinguishedName,
- *             ndn             NormalizedDistinguishedName,
- *             attrs   SEQUENCE OF SEQUENCE {
- *                     type    AttributeType,
- *                     values  SET OF AttributeValue
- *             }
- * }
+ *      entry :== SEQUENCE {
+ *                     dn              DistinguishedName,
+ *                     ndn             NormalizedDistinguishedName,
+ *                     attrs   SEQUENCE OF SEQUENCE {
+ *                             type    AttributeType,
+ *                             values  SET OF AttributeValue
+ *                     }
+ *      }
  *
- * Encoding/Decoding of DER should be much faster than LDIF
+ * Encoding/Decoding of LBER should be much faster than LDIF
  */
 
 int entry_decode( struct berval *bv, Entry **entry )
@@ -397,8 +405,13 @@ int entry_decode( struct berval *bv, Entry **entry )
        ber_len_t       len;
        char *last;
 
+       assert( bv != NULL );
+       assert( entry != NULL );
+
        ber = ber_init( bv );
        if( ber == NULL ) {
+               assert( 0 );    /* XXYYZ: Temporary assert */
+
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
                           "entry_decode: ber_init failed\n" ));
@@ -560,11 +573,11 @@ int entry_encode(
        
 #ifdef NEW_LOGGING
        LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1,
-                  "entry_encode: id: 0x%08lx  \"%s\"\n",
-                  e->e_id, e->e_dn ));
+               "entry_encode: id: 0x%08lx  \"%s\"\n",
+               (long) e->e_id, e->e_dn ));
 #else
        Debug( LDAP_DEBUG_TRACE, "=> entry_encode(0x%08lx): %s\n",
-               e->e_id, e->e_dn, 0 );
+               (long) e->e_id, e->e_dn, 0 );
 #endif
        ber = ber_alloc_t( LBER_USE_DER );
        if( ber == NULL ) {
@@ -597,10 +610,11 @@ done:
        if( rc ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_INFO,
-                          "entry_encode: id=0x%08lx  failed (%d)\n", e->e_id, rc ));
+                       "entry_encode: id=0x%08lx  failed (%d)\n",
+                       (long) e->e_id, rc ));
 #else
                Debug( LDAP_DEBUG_ANY, "=> entry_encode(0x%08lx): failed (%d)\n",
-                       e->e_id, rc, 0 );
+                       (long) e->e_id, rc, 0 );
 #endif
        }
        return rc;