From: Howard Chu Date: Mon, 6 Dec 2004 07:25:33 +0000 (+0000) Subject: bdb_tool_dn2id_get should use bdb_dn2id, not duplicate the code X-Git-Tag: OPENLDAP_REL_ENG_2_3_0ALPHA~119 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=3e5a2904e8df6f94d27881cc5164a54d45140502;p=openldap bdb_tool_dn2id_get should use bdb_dn2id, not duplicate the code --- diff --git a/servers/slapd/back-bdb/tools.c b/servers/slapd/back-bdb/tools.c index 6093bb95b4..791ae83d1a 100644 --- a/servers/slapd/back-bdb/tools.c +++ b/servers/slapd/back-bdb/tools.c @@ -138,34 +138,18 @@ ID bdb_tool_dn2id_get( struct berval *dn ) { - struct bdb_info *bdb = (struct bdb_info *) be->be_private; - DB *db = bdb->bi_dn2id->bdi_db; - int rc; - DBT key, data; - ID id; - - DBTzero( &key ); - key.size = dn->bv_len + 2; - key.data = ch_malloc( key.size ); - ((char*)key.data)[0] = DN_BASE_PREFIX; - AC_MEMCPY( &((char*)key.data)[1], dn->bv_val, key.size - 1 ); - - DBTzero( &data ); - data.data = &id; - data.ulen = sizeof(ID); - data.flags = DB_DBT_USERMEM; - - rc = db->get( db, NULL, &key, &data, bdb->bi_db_opflags ); + Operation op = {0}; + Opheader ohdr = {0}; + EntryInfo ei = {0}; - if( rc != 0 ) { - Debug( LDAP_DEBUG_TRACE, LDAP_XSTRING(bdb_tool_dn2id_get) - ": get failed: %s (%d)\n", - db_strerror( rc ), rc, 0 ); - id = NOID; - } + op.o_hdr = &ohdr; + op.o_bd = be; + op.o_tmpmemctx = NULL; + op.o_tmpmfuncs = &ch_mfuncs; - ch_free( key.data ); - return id; + bdb_dn2id( &op, NULL, dn, &ei ); + + return ei.bei_id; } int bdb_tool_id2entry_get(