]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/entry.c
Kill lber_debug
[openldap] / servers / slapd / entry.c
index 3755272d1f738b0e057da7291359b1e595305cf2..ce08b132d1afed1754a8314e0eb3ccfb11df7e52 100644 (file)
@@ -24,7 +24,8 @@ str2entry( char       *s )
        char            *type;
        char            *value;
        char            *next;
-       int             vlen, nvals, maxvals;
+       ber_len_t       vlen;
+       int             nvals, maxvals;
        struct berval   bval;
        struct berval   *vals[2];
        char            ptype[64];
@@ -49,7 +50,7 @@ str2entry( char       *s )
 
        /* check to see if there's an id included */
        next = s;
-       if ( isdigit( *s ) ) {
+       if ( isdigit( (unsigned char) *s ) ) {
                id = atoi( s );
                if ( (s = ldif_getline( &next )) == NULL ) {
                        Debug( LDAP_DEBUG_TRACE,
@@ -98,7 +99,7 @@ str2entry( char       *s )
                if ( strcasecmp( type, "dn" ) == 0 ) {
                        if ( e->e_dn != NULL ) {
                                Debug( LDAP_DEBUG_ANY,
- "str2entry: entry %lu has multiple dns \"%s\" and \"%s\" (second ignored)\n",
+ "str2entry: entry %ld has multiple dns \"%s\" and \"%s\" (second ignored)\n",
                                    e->e_id, e->e_dn, value );
                                continue;
                        }
@@ -106,11 +107,12 @@ str2entry( char   *s )
 
                        if ( e->e_ndn != NULL ) {
                                Debug( LDAP_DEBUG_ANY,
- "str2entry: entry %lu already has a normalized dn \"%s\" for \"%s\" (first ignored)\n",
+ "str2entry: entry %ld already has a normalized dn \"%s\" for \"%s\" (first ignored)\n",
                                    e->e_id, e->e_ndn, value );
                                free( e->e_ndn );
                        }
-                       e->e_ndn = dn_normalize_case( ch_strdup( value ) );
+                       e->e_ndn = ch_strdup( value );
+                       (void) dn_normalize_case( e->e_ndn );
                        continue;
                }
 
@@ -128,7 +130,7 @@ str2entry( char     *s )
 
        /* check to make sure there was a dn: line */
        if ( e->e_dn == NULL ) {
-               Debug( LDAP_DEBUG_ANY, "str2entry: entry %lu has no dn\n",
+               Debug( LDAP_DEBUG_ANY, "str2entry: entry %ld has no dn\n",
                    e->e_id, 0, 0 );
                entry_free( e );
                return( NULL );
@@ -136,13 +138,13 @@ str2entry( char   *s )
 
        if ( e->e_ndn == NULL ) {
                Debug( LDAP_DEBUG_ANY,
-                       "str2entry: entry %lu (\"%s\") has no normalized dn\n",
+                       "str2entry: entry %ld (\"%s\") has no normalized dn\n",
                    e->e_id, e->e_dn, 0 );
                entry_free( e );
                return( NULL );
        }
 
-       Debug(LDAP_DEBUG_TRACE, "<= str2entry(%s) -> %lu (0x%lx)\n",
+       Debug(LDAP_DEBUG_TRACE, "<= str2entry(%s) -> %ld (0x%lx)\n",
                e->e_dn, e->e_id, (unsigned long)e );
 
        return( e );
@@ -193,7 +195,7 @@ entry2str(
                /* put "dn: <dn>" */
                tmplen = strlen( e->e_dn );
                MAKE_SPACE( LDIF_SIZE_NEEDED( 2, tmplen ));
-               ldif_put_type_and_value( (char **) &ecur, "dn", e->e_dn, tmplen );
+               ldif_sput( (char **) &ecur, LDIF_PUT_VALUE, "dn", e->e_dn, tmplen );
        }
 
        /* put the attributes */
@@ -203,7 +205,7 @@ entry2str(
                        bv = a->a_vals[i];
                        tmplen = strlen( a->a_type );
                        MAKE_SPACE( LDIF_SIZE_NEEDED( tmplen, bv->bv_len ));
-                       ldif_put_type_and_value( (char **) &ecur, a->a_type,
+                       ldif_sput( (char **) &ecur, LDIF_PUT_VALUE, a->a_type,
                            bv->bv_val, bv->bv_len );
                }
        }
@@ -217,7 +219,6 @@ entry2str(
 void
 entry_free( Entry *e )
 {
-       int             i;
        Attribute       *a, *next;
 
        if ( e->e_dn != NULL ) {
@@ -237,3 +238,35 @@ entry_free( Entry *e )
        free( e );
 }
 
+/*
+ * These routines are used only by Backend.
+ *
+ * the Entry has three entry points (ways to find things):
+ *
+ *     by entry        e.g., if you already have an entry from the cache
+ *                     and want to delete it. (really by entry ptr)
+ *     by dn           e.g., when looking for the base object of a search
+ *     by id           e.g., for search candidates
+ *
+ * these correspond to three different avl trees that are maintained.
+ */
+
+int
+entry_cmp( Entry *e1, Entry *e2 )
+{
+       return( e1 < e2 ? -1 : (e1 > e2 ? 1 : 0) );
+}
+
+int
+entry_dn_cmp( Entry *e1, Entry *e2 )
+{
+       /* compare their normalized UPPERCASED dn's */
+       return( strcmp( e1->e_ndn, e2->e_ndn ) );
+}
+
+int
+entry_id_cmp( Entry *e1, Entry *e2 )
+{
+       return( e1->e_id < e2->e_id ? -1 : (e1->e_id > e2->e_id ? 1 : 0) );
+}
+