]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/entry.c
Very crude LDIF changes:
[openldap] / servers / slapd / entry.c
index 3755272d1f738b0e057da7291359b1e595305cf2..e0465230e95cb4f072292a9d574c1b7737801ad9 100644 (file)
@@ -49,7 +49,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 +98,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 +106,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 +129,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 +137,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 );
@@ -217,7 +218,6 @@ entry2str(
 void
 entry_free( Entry *e )
 {
-       int             i;
        Attribute       *a, *next;
 
        if ( e->e_dn != NULL ) {
@@ -237,3 +237,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) );
+}
+