static void ravl_print LDAP_P(( Avlnode *root, int depth ));
static void myprint LDAP_P(( Avlnode *root ));
+static int avl_strcmp LDAP_P(( const void *s, const void *t ));
int
main( int argc, char **argv )
if ( fgets( name, sizeof( name ), stdin ) == NULL )
exit( EXIT_SUCCESS );
name[ strlen( name ) - 1 ] = '\0';
- if ( (p = (char *) avl_find( tree, name, (AVL_CMP) strcmp ))
+ if ( (p = (char *) avl_find( tree, name, avl_strcmp ))
== NULL )
printf( "Not found.\n\n" );
else
if ( fgets( name, sizeof( name ), stdin ) == NULL )
exit( EXIT_SUCCESS );
name[ strlen( name ) - 1 ] = '\0';
- if ( avl_insert( &tree, strdup( name ), (AVL_CMP) strcmp,
+ if ( avl_insert( &tree, strdup( name ), avl_strcmp,
avl_dup_error ) != 0 )
printf( "\nNot inserted!\n" );
break;
if ( fgets( name, sizeof( name ), stdin ) == NULL )
exit( EXIT_SUCCESS );
name[ strlen( name ) - 1 ] = '\0';
- if ( avl_delete( &tree, name, (AVL_CMP) strcmp ) == NULL )
+ if ( avl_delete( &tree, name, avl_strcmp ) == NULL )
printf( "\nNot found!\n" );
break;
case 'q': /* quit */
printf( "********\n" );
}
+
+static int avl_strcmp( const void *s, const void *t )
+{
+ return strcmp( s, t );
+}
*/
static void
rewrite_var_free(
- struct rewrite_var *var
+ void *v_var
)
{
+ struct rewrite_var *var = v_var;
assert( var != NULL );
assert( var->lv_name != NULL );
Avlnode *tree
)
{
- avl_free( tree, ( AVL_FREE )rewrite_var_free );
+ avl_free( tree, rewrite_var_free );
return REWRITE_SUCCESS;
}
static int
attr_index_cmp(
- struct aindexrec *air1,
- struct aindexrec *air2
+ const void *v_air1,
+ const void *v_air2
)
{
+ const struct aindexrec *air1 = v_air1;
+ const struct aindexrec *air2 = v_air2;
int i = air1->air_name.bv_len - air2->air_name.bv_len;
if (i)
return i;
static int
attr_index_name_cmp(
- struct berval *type,
- struct aindexrec *air
+ const void *v_type,
+ const void *v_air
)
{
+ const struct berval *type = v_type;
+ const struct aindexrec *air = v_air;
int i = type->bv_len - air->air_name.bv_len;
if (i)
return i;
{
struct aindexrec *air;
- air = (struct aindexrec *) avl_find( attr_index, name,
- (AVL_CMP) attr_index_name_cmp );
+ air = avl_find( attr_index, name, attr_index_name_cmp );
return air != NULL ? air->air_at : NULL;
}
air->air_name.bv_len = strlen(sat->sat_oid);
air->air_at = sat;
if ( avl_insert( &attr_index, (caddr_t) air,
- (AVL_CMP) attr_index_cmp,
- (AVL_DUP) avl_dup_error ) ) {
+ attr_index_cmp, avl_dup_error ) ) {
*err = sat->sat_oid;
ldap_memfree(air);
return SLAP_SCHERR_ATTR_DUP;
air->air_name.bv_len = strlen(*names);
air->air_at = sat;
if ( avl_insert( &attr_index, (caddr_t) air,
- (AVL_CMP) attr_index_cmp,
- (AVL_DUP) avl_dup_error ) ) {
+ attr_index_cmp, avl_dup_error ) ) {
*err = *names;
ldap_memfree(air);
return SLAP_SCHERR_ATTR_DUP;
#ifdef LDAP_DEBUG
static int
-at_index_printnode( struct aindexrec *air )
+at_index_printnode( void *v_air, void *ignore )
{
-
+ struct aindexrec *air = v_air;
printf("%s = %s\n",
air->air_name.bv_val,
ldap_attributetype2str(&air->air_at->sat_atype) );
at_index_print( void )
{
printf("Printing attribute type index:\n");
- (void) avl_apply( attr_index, (AVL_APPLY) at_index_printnode,
- 0, -1, AVL_INORDER );
+ (void) avl_apply( attr_index, at_index_printnode, 0, -1, AVL_INORDER );
}
#endif
static int
ainfo_type_cmp(
- AttributeDescription *desc,
- AttrInfo *a
+ const void *v_desc,
+ const void *v_a
)
{
+ const AttributeDescription *desc = v_desc;
+ const AttrInfo *a = v_a;
return desc - a->ai_desc;
}
static int
ainfo_cmp(
- AttrInfo *a,
- AttrInfo *b
+ const void *v_a,
+ const void *v_b
)
{
+ const AttrInfo *a = v_a, *b = v_b;
return a->ai_desc - b->ai_desc;
}
{
AttrInfo *a;
- a = (AttrInfo *) avl_find( bdb->bi_attrs, desc,
- (AVL_CMP) ainfo_type_cmp );
+ a = (AttrInfo *) avl_find( bdb->bi_attrs, desc, ainfo_type_cmp );
*indexmask = a != NULL ? a->ai_indexmask : 0;
}
a->ai_indexmask = mask;
rc = avl_insert( &bdb->bi_attrs, (caddr_t) a,
- (AVL_CMP) ainfo_cmp, (AVL_DUP) avl_dup_error );
+ ainfo_cmp, avl_dup_error );
if( rc ) {
fprintf( stderr, "%s: line %d: duplicate index definition "
}
if ( avl_insert( &cache->c_dntree, (caddr_t) e,
- (AVL_CMP) entry_dn_cmp, avl_dup_error ) != 0 )
+ entry_dn_cmp, avl_dup_error ) != 0 )
{
/* free cache write lock */
ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
/* id tree */
if ( avl_insert( &cache->c_idtree, (caddr_t) e,
- (AVL_CMP) entry_id_cmp, avl_dup_error ) != 0 )
+ entry_id_cmp, avl_dup_error ) != 0 )
{
#ifdef NEW_LOGGING
LDAP_LOG( CACHE, DETAIL1,
/* delete from dn tree inserted above */
if ( avl_delete( &cache->c_dntree, (caddr_t) e,
- (AVL_CMP) entry_dn_cmp ) == NULL )
+ entry_dn_cmp ) == NULL )
{
#ifdef NEW_LOGGING
LDAP_LOG( CACHE, INFO,
case DB_LOCK_NOTGRANTED :
/* undo avl changes immediately */
if ( avl_delete( &cache->c_idtree, (caddr_t) e,
- (AVL_CMP) entry_id_cmp ) == NULL ) {
+ entry_id_cmp ) == NULL ) {
#ifdef NEW_LOGGING
LDAP_LOG( CACHE, INFO,
"bdb_cache_add_entry: can't delete (%s) from cache.\n",
#endif
}
if ( avl_delete( &cache->c_dntree, (caddr_t) e,
- (AVL_CMP) entry_dn_cmp ) == NULL ) {
+ entry_dn_cmp ) == NULL ) {
#ifdef NEW_LOGGING
LDAP_LOG( CACHE, INFO,
"bdb_cache_add_entry: can't delete (%s) from cache.\n",
assert( e->e_private );
if ( avl_insert( &cache->c_dntree, (caddr_t) e,
- (AVL_CMP) entry_dn_cmp, avl_dup_error ) != 0 )
+ entry_dn_cmp, avl_dup_error ) != 0 )
{
#ifdef NEW_LOGGING
LDAP_LOG( CACHE, DETAIL1,
/* id tree */
if ( avl_insert( &cache->c_idtree, (caddr_t) e,
- (AVL_CMP) entry_id_cmp, avl_dup_error ) != 0 )
+ entry_id_cmp, avl_dup_error ) != 0 )
{
#ifdef NEW_LOGGING
LDAP_LOG( CACHE, DETAIL1,
/* delete from dn tree inserted above */
if ( avl_delete( &cache->c_dntree, (caddr_t) e,
- (AVL_CMP) entry_dn_cmp ) == NULL )
+ entry_dn_cmp ) == NULL )
{
#ifdef NEW_LOGGING
LDAP_LOG( CACHE, INFO,
ldap_pvt_thread_rdwr_rlock( &cache->c_rwlock );
if ( (ep = (Entry *) avl_find( cache->c_dntree, (caddr_t) &e,
- (AVL_CMP) entry_dn_cmp )) != NULL )
+ entry_dn_cmp )) != NULL )
{
int state;
count++;
ldap_pvt_thread_rdwr_rlock( &cache->c_rwlock );
if ( (ep = (Entry *) avl_find( cache->c_idtree, (caddr_t) &e,
- (AVL_CMP) entry_id_cmp )) != NULL )
+ entry_id_cmp )) != NULL )
{
int state;
ID ep_id;
int rc = 0; /* return code */
/* dn tree */
- if ( avl_delete( &cache->c_dntree, (caddr_t) e, (AVL_CMP) entry_dn_cmp )
- == NULL )
+ if ( avl_delete( &cache->c_dntree, (caddr_t) e, entry_dn_cmp ) == NULL )
{
rc = -1;
}
/* id tree */
- if ( avl_delete( &cache->c_idtree, (caddr_t) e, (AVL_CMP) entry_id_cmp )
- == NULL )
+ if ( avl_delete( &cache->c_idtree, (caddr_t) e, entry_id_cmp ) == NULL )
{
rc = -1;
}
static int
node_frdn_cmp(
- struct berval *nrdn,
- idNode *n
+ const void *v_nrdn,
+ const void *v_n
)
{
+ const struct berval *nrdn = v_nrdn;
+ const idNode *n = v_n;
return ber_bvcmp(nrdn, &n->i_rdn->nrdn);
}
static int
node_add_cmp(
- idNode *a,
- idNode *b
+ const void *v_a,
+ const void *v_b
)
{
+ const idNode *a = v_a, *b = v_b;
return a->i_id - b->i_id;
}
static int
node_rdn_cmp(
- idNode *a,
- idNode *b
+ const void *v_a,
+ const void *v_b
)
{
+ const idNode *a = v_a, *b = v_b;
/* should be slightly better without ordering drawbacks */
return ber_bvcmp(&a->i_rdn->nrdn, &b->i_rdn->nrdn);
}
Avlnode *tree
)
{
- return avl_find(tree, (const void *)nrdn, (AVL_CMP)node_frdn_cmp);
+ return avl_find(tree, nrdn, node_frdn_cmp);
}
/* This function links a node into its parent's i_kids tree. */
-int bdb_insert_kid(
- idNode *a,
- Avlnode *tree
+static int bdb_insert_kid(
+ void *v_a,
+ void *v_tree
)
{
+ idNode *a = v_a;
+ Avlnode *tree = v_tree;
int rc;
if (a->i_rdn->parent == 0)
return -1;
ldap_pvt_thread_rdwr_wlock(&a->i_parent->i_kids_rdwr);
rc = avl_insert( &a->i_parent->i_kids, (caddr_t) a,
- (AVL_CMP)node_rdn_cmp, (AVL_DUP) avl_dup_error );
+ node_rdn_cmp, avl_dup_error );
ldap_pvt_thread_rdwr_wunlock(&a->i_parent->i_kids_rdwr);
return rc;
}
node->i_rdn->rdn.bv_val += (long)d;
node->i_rdn->nrdn.bv_val += (long)d;
ldap_pvt_thread_rdwr_init(&node->i_kids_rdwr);
- avl_insert( &bdb->bi_tree, (caddr_t) node,
- (AVL_CMP)node_add_cmp, (AVL_DUP) avl_dup_error );
+ avl_insert( &bdb->bi_tree, (caddr_t) node, node_add_cmp, avl_dup_error );
if (id == 1)
bdb->bi_troot = node;
return node;
}
cursor->c_close( cursor );
- rc = avl_apply(bdb->bi_tree, (AVL_APPLY)bdb_insert_kid, bdb->bi_tree,
+ rc = avl_apply(bdb->bi_tree, bdb_insert_kid, bdb->bi_tree,
-1, AVL_INORDER );
return rc;
if (n) {
if (n->i_parent) {
ldap_pvt_thread_rdwr_wlock(&n->i_parent->i_kids_rdwr);
- avl_delete(&n->i_parent->i_kids, &n->i_rdn->nrdn,
- (AVL_CMP)node_frdn_cmp);
+ avl_delete(&n->i_parent->i_kids, &n->i_rdn->nrdn, node_frdn_cmp);
ldap_pvt_thread_rdwr_wunlock(&n->i_parent->i_kids_rdwr);
}
free(n->i_rdn);
*/
static int
insert_one(
- idNode *n,
- ID *ids
+ void *v_n,
+ void *v_ids
)
{
+ idNode *n = v_n;
+ ID *ids = v_ids;
return bdb_idl_insert(ids, n->i_id);
}
static int
insert_sub(
- idNode *n,
- ID *ids
+ void *v_n,
+ void *v_ids
)
{
+ idNode *n = v_n;
+ ID *ids = v_ids;
int rc;
rc = bdb_idl_insert(ids, n->i_id);
if (rc == 0) {
ldap_pvt_thread_rdwr_rlock(&n->i_kids_rdwr);
- rc = avl_apply(n->i_kids, (AVL_APPLY)insert_sub, ids, -1,
- AVL_INORDER);
+ rc = avl_apply(n->i_kids, insert_sub, ids, -1, AVL_INORDER);
ldap_pvt_thread_rdwr_runlock(&n->i_kids_rdwr);
}
return rc;
ids[0] = 0;
ldap_pvt_thread_rdwr_rlock(&n->i_kids_rdwr);
if (prefix == DN_ONE_PREFIX) {
- rc = avl_apply(n->i_kids, (AVL_APPLY)insert_one, ids, -1,
- AVL_INORDER);
+ rc = avl_apply(n->i_kids, insert_one, ids, -1, AVL_INORDER);
} else {
- rc = avl_apply(n->i_kids, (AVL_APPLY)insert_sub, ids, -1,
- AVL_INORDER);
+ rc = avl_apply(n->i_kids, insert_sub, ids, -1, AVL_INORDER);
}
ldap_pvt_thread_rdwr_runlock(&n->i_kids_rdwr);
return rc;
} while ( 0 )
static int
-bdb_idl_entry_cmp( bdb_idl_cache_entry_t* idl1, bdb_idl_cache_entry_t* idl2 )
+bdb_idl_entry_cmp( const void *v_idl1, const void *v_idl2 )
{
+ const bdb_idl_cache_entry_t *idl1 = v_idl1, *idl2 = v_idl2;
int rc;
if ((rc = idl1->db - idl2->db )) return rc;
DBT2bv( key, &idl_tmp.kstr );
idl_tmp.db = db;
ldap_pvt_thread_mutex_lock( &bdb->bi_idl_tree_mutex );
- matched_idl_entry = avl_find( bdb->bi_idl_tree, &idl_tmp, (AVL_CMP) bdb_idl_entry_cmp );
+ matched_idl_entry = avl_find( bdb->bi_idl_tree, &idl_tmp,
+ bdb_idl_entry_cmp );
if ( matched_idl_entry != NULL ) {
BDB_IDL_CPY( ids, matched_idl_entry->idl );
IDL_LRU_DELETE( bdb, matched_idl_entry );
BDB_IDL_CPY( ee->idl, ids );
ber_dupbv( &ee->kstr, &idl_tmp.kstr );
ldap_pvt_thread_mutex_lock( &bdb->bi_idl_tree_mutex );
- if ( avl_insert( &bdb->bi_idl_tree, (caddr_t) ee, (AVL_CMP) bdb_idl_entry_cmp, avl_dup_error )) {
+ if ( avl_insert( &bdb->bi_idl_tree, (caddr_t) ee,
+ bdb_idl_entry_cmp, avl_dup_error )) {
free( ee->kstr.bv_val );
free( ee->idl );
free( ee );
int i = 0;
while ( bdb->bi_idl_lru_tail != NULL && i < 10 ) {
ee = bdb->bi_idl_lru_tail;
- avl_delete( &bdb->bi_idl_tree, (caddr_t) ee, (AVL_CMP) bdb_idl_entry_cmp );
+ avl_delete( &bdb->bi_idl_tree, (caddr_t) ee,
+ bdb_idl_entry_cmp );
IDL_LRU_DELETE( bdb, ee );
i++;
--bdb->bi_idl_cache_size;
DBT2bv( key, &idl_tmp.kstr );
idl_tmp.db = db;
ldap_pvt_thread_mutex_lock( &bdb->bi_idl_tree_mutex );
- matched_idl_entry = avl_find( bdb->bi_idl_tree, &idl_tmp, (AVL_CMP) bdb_idl_entry_cmp );
+ matched_idl_entry = avl_find( bdb->bi_idl_tree, &idl_tmp,
+ bdb_idl_entry_cmp );
if ( matched_idl_entry != NULL ) {
- avl_delete( &bdb->bi_idl_tree, (caddr_t) matched_idl_entry, (AVL_CMP) bdb_idl_entry_cmp );
+ avl_delete( &bdb->bi_idl_tree, (caddr_t) matched_idl_entry,
+ bdb_idl_entry_cmp );
--bdb->bi_idl_cache_size;
IDL_LRU_DELETE( bdb, matched_idl_entry );
free( matched_idl_entry->kstr.bv_val );
DBT2bv( key, &idl_tmp.kstr );
idl_tmp.db = db;
ldap_pvt_thread_mutex_lock( &bdb->bi_idl_tree_mutex );
- matched_idl_entry = avl_find( bdb->bi_idl_tree, &idl_tmp, (AVL_CMP) bdb_idl_entry_cmp );
+ matched_idl_entry = avl_find( bdb->bi_idl_tree, &idl_tmp,
+ bdb_idl_entry_cmp );
if ( matched_idl_entry != NULL ) {
- avl_delete( &bdb->bi_idl_tree, (caddr_t) matched_idl_entry, (AVL_CMP) bdb_idl_entry_cmp );
+ avl_delete( &bdb->bi_idl_tree, (caddr_t) matched_idl_entry,
+ bdb_idl_entry_cmp );
--bdb->bi_idl_cache_size;
IDL_LRU_DELETE( bdb, matched_idl_entry );
free( matched_idl_entry->kstr.bv_val );
int remap
);
-extern void mapping_free ( struct ldapmapping *mapping );
+extern void mapping_free ( void *mapping );
#ifdef ENABLE_REWRITE
extern int suffix_massage_config( struct rewrite_info *info,
static void
conn_free(
- struct ldapconn *lc
+ void *v_lc
)
{
+ struct ldapconn *lc = v_lc;
ldap_unbind( lc->ld );
if ( lc->bound_dn.bv_val ) {
ch_free( lc->bound_dn.bv_val );
}
void
-mapping_free ( struct ldapmapping *mapping )
+mapping_free( void *v_mapping )
{
+ struct ldapmapping *mapping = v_mapping;
ch_free( mapping->src.bv_val );
ch_free( mapping->dst.bv_val );
ch_free( mapping );
li->bindpw = NULL;
}
if (li->conntree) {
- avl_free( li->conntree, (AVL_FREE) conn_free );
+ avl_free( li->conntree, conn_free );
}
#ifdef ENABLE_REWRITE
if (li->rwinfo) {
#endif /* !ENABLE_REWRITE */
avl_free( li->oc_map.remap, NULL );
- avl_free( li->oc_map.map, (AVL_FREE) mapping_free );
+ avl_free( li->oc_map.map, mapping_free );
avl_free( li->at_map.remap, NULL );
- avl_free( li->at_map.map, (AVL_FREE) mapping_free );
+ avl_free( li->at_map.map, mapping_free );
ldap_pvt_thread_mutex_unlock( &li->conn_mutex );
ldap_pvt_thread_mutex_destroy( &li->conn_mutex );
static int
ainfo_type_cmp(
- AttributeDescription *desc,
- AttrInfo *a
+ const void *v_desc,
+ const void *v_a
)
{
+ const AttributeDescription *desc = v_desc;
+ const AttrInfo *a = v_a;
return desc - a->ai_desc;
}
static int
ainfo_cmp(
- AttrInfo *a,
- AttrInfo *b
+ const void *v_a,
+ const void *v_b
)
{
+ const AttrInfo *a = v_a, *b = v_b;
return a->ai_desc - b->ai_desc;
}
{
AttrInfo *a;
- a = (AttrInfo *) avl_find( li->li_attrs, desc,
- (AVL_CMP) ainfo_type_cmp );
+ a = avl_find( li->li_attrs, desc, ainfo_type_cmp );
*indexmask = a != NULL ? a->ai_indexmask : 0;
}
a->ai_indexmask = mask;
rc = avl_insert( &li->li_attrs, (caddr_t) a,
- (AVL_CMP) ainfo_cmp, (AVL_DUP) avl_dup_error );
+ ainfo_cmp, avl_dup_error );
if( rc ) {
fprintf( stderr, "%s: line %d: duplicate index definition "
}
if ( avl_insert( &cache->c_dntree, (caddr_t) e,
- (AVL_CMP) entry_dn_cmp, avl_dup_error ) != 0 )
+ entry_dn_cmp, avl_dup_error ) != 0 )
{
/* free cache mutex */
ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
/* id tree */
if ( avl_insert( &cache->c_idtree, (caddr_t) e,
- (AVL_CMP) entry_id_cmp, avl_dup_error ) != 0 )
+ entry_id_cmp, avl_dup_error ) != 0 )
{
#ifdef NEW_LOGGING
LDAP_LOG( CACHE, DETAIL1,
/* delete from dn tree inserted above */
if ( avl_delete( &cache->c_dntree, (caddr_t) e,
- (AVL_CMP) entry_dn_cmp ) == NULL )
+ entry_dn_cmp ) == NULL )
{
#ifdef NEW_LOGGING
LDAP_LOG( CACHE, INFO,
assert( e->e_private );
if ( avl_insert( &cache->c_dntree, (caddr_t) e,
- (AVL_CMP) entry_dn_cmp, avl_dup_error ) != 0 )
+ entry_dn_cmp, avl_dup_error ) != 0 )
{
#ifdef NEW_LOGGING
LDAP_LOG( CACHE, DETAIL1,
/* id tree */
if ( avl_insert( &cache->c_idtree, (caddr_t) e,
- (AVL_CMP) entry_id_cmp, avl_dup_error ) != 0 )
+ entry_id_cmp, avl_dup_error ) != 0 )
{
#ifdef NEW_LOGGING
LDAP_LOG( CACHE, DETAIL1,
/* delete from dn tree inserted above */
if ( avl_delete( &cache->c_dntree, (caddr_t) e,
- (AVL_CMP) entry_dn_cmp ) == NULL )
+ entry_dn_cmp ) == NULL )
{
#ifdef NEW_LOGGING
LDAP_LOG( CACHE, INFO,
ldap_pvt_thread_mutex_lock( &cache->c_mutex );
if ( (ep = (Entry *) avl_find( cache->c_dntree, (caddr_t) &e,
- (AVL_CMP) entry_dn_cmp )) != NULL )
+ entry_dn_cmp )) != NULL )
{
int state;
count++;
ldap_pvt_thread_mutex_lock( &cache->c_mutex );
if ( (ep = (Entry *) avl_find( cache->c_idtree, (caddr_t) &e,
- (AVL_CMP) entry_id_cmp )) != NULL )
+ entry_id_cmp )) != NULL )
{
int state;
ID ep_id;
int rc = 0; /* return code */
/* dn tree */
- if ( avl_delete( &cache->c_dntree, (caddr_t) e, (AVL_CMP) entry_dn_cmp )
- == NULL )
+ if ( avl_delete( &cache->c_dntree, (caddr_t) e, entry_dn_cmp ) == NULL )
{
rc = -1;
}
/* id tree */
- if ( avl_delete( &cache->c_idtree, (caddr_t) e, (AVL_CMP) entry_id_cmp )
- == NULL )
+ if ( avl_delete( &cache->c_idtree, (caddr_t) e, entry_id_cmp ) == NULL )
{
rc = -1;
}
static void
conn_free(
- struct metaconn *lc
+ void *v_lc
)
{
+ struct metaconn *lc = v_lc;
struct metasingleconn *lsc;
for ( lsc = lc->conns; !META_LAST(lsc); lsc++ ) {
rewrite_info_delete( lt->rwinfo );
}
avl_free( lt->oc_map.remap, NULL );
- avl_free( lt->oc_map.map, ( AVL_FREE )mapping_free );
+ avl_free( lt->oc_map.map, mapping_free );
avl_free( lt->at_map.remap, NULL );
- avl_free( lt->at_map.map, ( AVL_FREE )mapping_free );
+ avl_free( lt->at_map.map, mapping_free );
}
int
ldap_pvt_thread_mutex_lock( &li->conn_mutex );
if ( li->conntree ) {
- avl_free( li->conntree,
- ( AVL_FREE )conn_free );
+ avl_free( li->conntree, conn_free );
}
/*
ldap_pvt_thread_mutex_lock( &li->cache.mutex );
if ( li->cache.tree ) {
- avl_free( li->cache.tree,
- ( AVL_FREE )meta_dncache_free );
+ avl_free( li->cache.tree, meta_dncache_free );
}
ldap_pvt_thread_mutex_unlock( &li->cache.mutex );
return rc;
}
-int
-backsql_get_attr_vals( backsql_at_map_rec *at, backsql_srch_info *bsi )
+static int
+backsql_get_attr_vals( void *v_at, void *v_bsi )
{
+ backsql_at_map_rec *at = v_at;
+ backsql_srch_info *bsi = v_bsi;
RETCODE rc;
SQLHSTMT sth;
BACKSQL_ROW_NTS row;
} else {
Debug( LDAP_DEBUG_TRACE, "backsql_id2entry(): "
"retrieving all attributes\n", 0, 0, 0 );
- avl_apply( bsi->oc->attrs, (AVL_APPLY)backsql_get_attr_vals,
+ avl_apply( bsi->oc->attrs, backsql_get_attr_vals,
bsi, 0, AVL_INORDER );
}
* Uses the pointer to the ObjectClass structure
*/
static int
-backsql_cmp_oc( backsql_oc_map_rec *m1, backsql_oc_map_rec *m2 )
+backsql_cmp_oc( const void *v_m1, const void *v_m2 )
{
+ const backsql_oc_map_rec *m1 = v_m1, *m2 = v_m2;
return ( m1->oc < m2->oc ? -1 : ( m1->oc > m2->oc ? 1 : 0 ) );
}
static int
-backsql_cmp_oc_id( backsql_oc_map_rec *m1, backsql_oc_map_rec *m2 )
+backsql_cmp_oc_id( const void *v_m1, const void *v_m2 )
{
+ const backsql_oc_map_rec *m1 = v_m1, *m2 = v_m2;
return ( m1->id < m2->id ? -1 : ( m1->id > m2->id ? 1 : 0 ) );
}
* Uses the pointer to the AttributeDescription structure
*/
static int
-backsql_cmp_attr( backsql_at_map_rec *m1, backsql_at_map_rec *m2 )
+backsql_cmp_attr( const void *v_m1, const void *v_m2 )
{
+ const backsql_at_map_rec *m1 = v_m1, *m2 = v_m2;
return ( m1->ad < m2->ad ? -1 : ( m1->ad > m2->ad ? 1 : 0 ) );
}
at_map->param_order = 0;
at_map->expect_return = 0;
backsql_make_attr_query( oc_map, at_map );
- avl_insert( &oc_map->attrs, at_map,
- (AVL_CMP)backsql_cmp_attr, NULL );
+ avl_insert( &oc_map->attrs, at_map, backsql_cmp_attr, NULL );
at_map = (backsql_at_map_rec *)ch_calloc( 1,
sizeof( backsql_at_map_rec ) );
at_map->param_order = 0;
at_map->expect_return = 0;
backsql_make_attr_query( oc_map, at_map );
- avl_insert( &oc_map->attrs, at_map,
- (AVL_CMP)backsql_cmp_attr, NULL );
+ avl_insert( &oc_map->attrs, at_map, backsql_cmp_attr, NULL );
return 1;
}
*/
oc_map->attrs = NULL;
- avl_insert( &si->oc_by_oc, oc_map,
- (AVL_CMP)backsql_cmp_oc, NULL );
- avl_insert( &si->oc_by_id, oc_map,
- (AVL_CMP)backsql_cmp_oc_id, NULL );
+ avl_insert( &si->oc_by_oc, oc_map, backsql_cmp_oc, NULL );
+ avl_insert( &si->oc_by_id, oc_map, backsql_cmp_oc_id, NULL );
oc_id = oc_map->id;
Debug( LDAP_DEBUG_TRACE, "load_schema_map(): "
"objectClass '%s': keytbl='%s' keycol='%s'\n",
Debug( LDAP_DEBUG_TRACE, "load_schema_map(): "
"preconstructed query '%s'\n",
at_map->query, 0, 0 );
- avl_insert( &oc_map->attrs, at_map,
- (AVL_CMP)backsql_cmp_attr, NULL );
+ avl_insert( &oc_map->attrs, at_map, backsql_cmp_attr, NULL );
}
backsql_FreeRow( &at_row );
SQLFreeStmt( at_sth, SQL_CLOSE );
#endif /* BACKSQL_TRACE */
tmp.oc = oc;
- res = (backsql_oc_map_rec *)avl_find( si->oc_by_oc, &tmp,
- (AVL_CMP)backsql_cmp_oc );
+ res = (backsql_oc_map_rec *)avl_find( si->oc_by_oc, &tmp, backsql_cmp_oc );
#ifdef BACKSQL_TRACE
if ( res != NULL ) {
Debug( LDAP_DEBUG_TRACE, "<==backsql_oc2oc(): "
return NULL;
}
- res = (backsql_oc_map_rec *)avl_find( si->oc_by_oc, &tmp,
- (AVL_CMP)backsql_cmp_oc );
+ res = (backsql_oc_map_rec *)avl_find( si->oc_by_oc, &tmp, backsql_cmp_oc );
#ifdef BACKSQL_TRACE
if ( res != NULL ) {
Debug( LDAP_DEBUG_TRACE, "<==oc_with_name(): "
tmp.id = id;
res = (backsql_oc_map_rec *)avl_find( si->oc_by_id, &tmp,
- (AVL_CMP)backsql_cmp_oc_id );
+ backsql_cmp_oc_id );
#ifdef BACKSQL_TRACE
if ( res != NULL ) {
tmp.ad = ad;
res = (backsql_at_map_rec *)avl_find( objclass->attrs, &tmp,
- (AVL_CMP)backsql_cmp_attr );
+ backsql_cmp_attr );
#ifdef BACKSQL_TRACE
if ( res != NULL ) {
}
res = (backsql_at_map_rec *)avl_find( objclass->attrs, &tmp,
- (AVL_CMP)backsql_cmp_attr );
+ backsql_cmp_attr );
#ifdef BACKSQL_TRACE
if ( res != NULL ) {
}
static void
-backsql_free_attr( backsql_at_map_rec *at )
+backsql_free_attr( void *v_at )
{
+ backsql_at_map_rec *at = v_at;
Debug( LDAP_DEBUG_TRACE, "==>free_attr(): '%s'\n",
at->ad->ad_cname.bv_val, 0, 0 );
ch_free( at->sel_expr.bv_val );
}
static void
-backsql_free_oc( backsql_oc_map_rec *oc )
+backsql_free_oc( void *v_oc )
{
+ backsql_oc_map_rec *oc = v_oc;
Debug( LDAP_DEBUG_TRACE, "==>free_oc(): '%s'\n",
BACKSQL_OC_NAME( oc ), 0, 0 );
- avl_free( oc->attrs, (AVL_FREE)backsql_free_attr );
+ avl_free( oc->attrs, backsql_free_attr );
ch_free( oc->keytbl.bv_val );
ch_free( oc->keycol.bv_val );
if ( oc->create_proc != NULL ) {
backsql_destroy_schema_map( backsql_info *si )
{
Debug( LDAP_DEBUG_TRACE, "==>destroy_schema_map()\n", 0, 0, 0 );
- avl_free( si->oc_by_oc, NULL );
- avl_free( si->oc_by_id, (AVL_FREE)backsql_free_oc );
+ avl_free( si->oc_by_oc, 0 );
+ avl_free( si->oc_by_id, backsql_free_oc );
Debug( LDAP_DEBUG_TRACE, "<==destroy_schema_map()\n", 0, 0, 0 );
return 0;
}
return ( query->bv_val == NULL ? 1 : 0 );
}
-int
-backsql_oc_get_candidates( backsql_oc_map_rec *oc, backsql_srch_info *bsi )
+static int
+backsql_oc_get_candidates( void *v_oc, void *v_bsi )
{
+ backsql_oc_map_rec *oc = v_oc;
+ backsql_srch_info *bsi = v_bsi;
struct berval query;
SQLHSTMT sth;
RETCODE rc;
*/
srch_info.n_candidates = ( isroot ? -2 : limit->lms_s_unchecked == -1
? -2 : limit->lms_s_unchecked );
- avl_apply( bi->oc_by_oc, (AVL_APPLY)backsql_oc_get_candidates,
+ avl_apply( bi->oc_by_oc, backsql_oc_get_candidates,
&srch_info, BACKSQL_STOP, AVL_INORDER );
if ( !isroot && limit->lms_s_unchecked != -1 ) {
if ( srch_info.n_candidates == -1 ) {
}
static int
-backsql_cmp_connid( backsql_db_conn *c1, backsql_db_conn *c2 )
+backsql_cmp_connid( const void *v_c1, const void *v_c2 )
{
+ const backsql_db_conn *c1 = v_c1, *c2 = v_c2;
if ( c1->ldap_cid > c2->ldap_cid ) {
return 1;
}
Debug( LDAP_DEBUG_TRACE, "backsql_open_db_conn(): "
"connected, adding to tree\n", 0, 0, 0 );
ldap_pvt_thread_mutex_lock( &si->dbconn_mutex );
- avl_insert( &si->db_conns, dbc, (AVL_CMP)backsql_cmp_connid, NULL );
+ avl_insert( &si->db_conns, dbc, backsql_cmp_connid, NULL );
ldap_pvt_thread_mutex_unlock( &si->dbconn_mutex );
Debug( LDAP_DEBUG_TRACE, "<==backsql_open_db_conn()\n", 0, 0, 0 );
Debug( LDAP_DEBUG_TRACE, "==>backsql_free_db_conn()\n", 0, 0, 0 );
tmp.ldap_cid = ldapc->c_connid;
ldap_pvt_thread_mutex_lock( &si->dbconn_mutex );
- conn = (backsql_db_conn *)avl_delete( &si->db_conns, &tmp,
- (AVL_CMP)backsql_cmp_connid );
+ conn = avl_delete( &si->db_conns, &tmp, backsql_cmp_connid );
ldap_pvt_thread_mutex_unlock( &si->dbconn_mutex );
/*
* we have one thread per connection, as I understand --
* so we do not need locking here
*/
- dbc = (backsql_db_conn *)avl_find( si->db_conns, &tmp,
- (AVL_CMP)backsql_cmp_connid );
+ dbc = avl_find( si->db_conns, &tmp, backsql_cmp_connid );
if ( !dbc ) {
rc = backsql_open_db_conn( si, ldapc->c_connid, &dbc );
if ( rc != LDAP_SUCCESS) {
static int
cr_index_cmp(
- struct cindexrec *cir1,
- struct cindexrec *cir2 )
+ const void *v_cir1,
+ const void *v_cir2 )
{
+ const struct cindexrec *cir1 = v_cir1;
+ const struct cindexrec *cir2 = v_cir2;
int i = cir1->cir_name.bv_len - cir2->cir_name.bv_len;
if (i)
return i;
static int
cr_index_name_cmp(
- struct berval *name,
- struct cindexrec *cir )
+ const void *v_name,
+ const void *v_cir )
{
+ const struct berval *name = v_name;
+ const struct cindexrec *cir = v_cir;
int i = name->bv_len - cir->cir_name.bv_len;
if (i)
return i;
{
struct cindexrec *cir;
- cir = (struct cindexrec *) avl_find( cr_index, crname,
- (AVL_CMP) cr_index_name_cmp );
+ cir = avl_find( cr_index, crname, cr_index_name_cmp );
if ( cir != NULL ) {
return( cir->cir_cr );
assert( cir->cir_cr );
if ( avl_insert( &cr_index, (caddr_t) cir,
- (AVL_CMP) cr_index_cmp,
- (AVL_DUP) avl_dup_error ) )
+ cr_index_cmp, avl_dup_error ) )
{
*err = scr->scr_oid;
ldap_memfree(cir);
assert( cir->cir_cr );
if ( avl_insert( &cr_index, (caddr_t) cir,
- (AVL_CMP) cr_index_cmp,
- (AVL_DUP) avl_dup_error ) )
+ cr_index_cmp, avl_dup_error ) )
{
*err = *names;
ldap_memfree(cir);
}
int
-entry_dn_cmp( Entry *e1, Entry *e2 )
+entry_dn_cmp( const void *v_e1, const void *v_e2 )
{
/* compare their normalized UPPERCASED dn's */
+ const Entry *e1 = v_e1, *e2 = v_e2;
int rc = e1->e_nname.bv_len - e2->e_nname.bv_len;
if (rc) return rc;
return( strcmp( e1->e_ndn, e2->e_ndn ) );
}
int
-entry_id_cmp( Entry *e1, Entry *e2 )
+entry_id_cmp( const void *v_e1, const void *v_e2 )
{
+ const Entry *e1 = v_e1, *e2 = v_e2;
return( e1->e_id < e2->e_id ? -1 : (e1->e_id > e2->e_id ? 1 : 0) );
}
static int
mr_index_cmp(
- struct mindexrec *mir1,
- struct mindexrec *mir2
+ const void *v_mir1,
+ const void *v_mir2
)
{
+ const struct mindexrec *mir1 = v_mir1;
+ const struct mindexrec *mir2 = v_mir2;
int i = mir1->mir_name.bv_len - mir2->mir_name.bv_len;
if (i) return i;
return (strcmp( mir1->mir_name.bv_val, mir2->mir_name.bv_val ));
static int
mr_index_name_cmp(
- struct berval *name,
- struct mindexrec *mir
+ const void *v_name,
+ const void *v_mir
)
{
+ const struct berval *name = v_name;
+ const struct mindexrec *mir = v_mir;
int i = name->bv_len - mir->mir_name.bv_len;
if (i) return i;
return (strncmp( name->bv_val, mir->mir_name.bv_val, name->bv_len ));
{
struct mindexrec *mir = NULL;
- if ( (mir = (struct mindexrec *) avl_find( mr_index, mrname,
- (AVL_CMP) mr_index_name_cmp )) != NULL ) {
+ if ( (mir = avl_find( mr_index, mrname, mr_index_name_cmp )) != NULL ) {
return( mir->mir_mr );
}
return( NULL );
mir->mir_name.bv_len = strlen( smr->smr_oid );
mir->mir_mr = smr;
if ( avl_insert( &mr_index, (caddr_t) mir,
- (AVL_CMP) mr_index_cmp,
- (AVL_DUP) avl_dup_error ) ) {
+ mr_index_cmp, avl_dup_error ) ) {
*err = smr->smr_oid;
ldap_memfree(mir);
return SLAP_SCHERR_MR_DUP;
mir->mir_name.bv_len = strlen( *names );
mir->mir_mr = smr;
if ( avl_insert( &mr_index, (caddr_t) mir,
- (AVL_CMP) mr_index_cmp,
- (AVL_DUP) avl_dup_error ) ) {
+ mr_index_cmp, avl_dup_error ) ) {
*err = *names;
ldap_memfree(mir);
return SLAP_SCHERR_MR_DUP;
static int
oc_index_cmp(
- struct oindexrec *oir1,
- struct oindexrec *oir2 )
+ const void *v_oir1,
+ const void *v_oir2 )
{
+ const struct oindexrec *oir1 = v_oir1, *oir2 = v_oir2;
int i = oir1->oir_name.bv_len - oir2->oir_name.bv_len;
if (i)
return i;
static int
oc_index_name_cmp(
- struct berval *name,
- struct oindexrec *oir )
+ const void *v_name,
+ const void *v_oir )
{
+ const struct berval *name = v_name;
+ const struct oindexrec *oir = v_oir;
int i = name->bv_len - oir->oir_name.bv_len;
if (i)
return i;
{
struct oindexrec *oir;
- oir = (struct oindexrec *) avl_find( oc_index, ocname,
- (AVL_CMP) oc_index_name_cmp );
+ oir = avl_find( oc_index, ocname, oc_index_name_cmp );
if ( oir != NULL ) {
return( oir->oir_oc );
assert( oir->oir_oc );
if ( avl_insert( &oc_index, (caddr_t) oir,
- (AVL_CMP) oc_index_cmp,
- (AVL_DUP) avl_dup_error ) )
+ oc_index_cmp, avl_dup_error ) )
{
*err = soc->soc_oid;
ldap_memfree(oir);
assert( oir->oir_oc );
if ( avl_insert( &oc_index, (caddr_t) oir,
- (AVL_CMP) oc_index_cmp,
- (AVL_DUP) avl_dup_error ) )
+ oc_index_cmp, avl_dup_error ) )
{
*err = *names;
ldap_memfree(oir);
LDAP_SLAPD_F (void) entry_free LDAP_P(( Entry *e ));
LDAP_SLAPD_F (int) entry_cmp LDAP_P(( Entry *a, Entry *b ));
-LDAP_SLAPD_F (int) entry_dn_cmp LDAP_P(( Entry *a, Entry *b ));
-LDAP_SLAPD_F (int) entry_id_cmp LDAP_P(( Entry *a, Entry *b ));
+LDAP_SLAPD_F (int) entry_dn_cmp LDAP_P(( const void *v_a, const void *v_b ));
+LDAP_SLAPD_F (int) entry_id_cmp LDAP_P(( const void *v_a, const void *v_b ));
/*
* extended.c
static int
syn_index_cmp(
- struct sindexrec *sir1,
- struct sindexrec *sir2
+ const void *v_sir1,
+ const void *v_sir2
)
{
+ const struct sindexrec *sir1 = v_sir1, *sir2 = v_sir2;
return (strcmp( sir1->sir_name, sir2->sir_name ));
}
static int
syn_index_name_cmp(
- const char *name,
- struct sindexrec *sir
+ const void *name,
+ const void *sir
)
{
- return (strcmp( name, sir->sir_name ));
+ return (strcmp( name, ((const struct sindexrec *)sir)->sir_name ));
}
Syntax *
{
struct sindexrec *sir = NULL;
- if ( (sir = (struct sindexrec *) avl_find( syn_index, synname,
- (AVL_CMP) syn_index_name_cmp )) != NULL ) {
+ if ( (sir = avl_find( syn_index, synname, syn_index_name_cmp )) != NULL ) {
return( sir->sir_syn );
}
return( NULL );
sir->sir_name = ssyn->ssyn_oid;
sir->sir_syn = ssyn;
if ( avl_insert( &syn_index, (caddr_t) sir,
- (AVL_CMP) syn_index_cmp,
- (AVL_DUP) avl_dup_error ) ) {
+ syn_index_cmp, avl_dup_error ) ) {
*err = ssyn->ssyn_oid;
ldap_memfree(sir);
return SLAP_SCHERR_SYN_DUP;