2 * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
3 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
12 #include <ac/string.h>
13 #include <ac/socket.h>
14 #include <ac/unistd.h>
16 #include "slapcommon.h"
19 main( int argc, char **argv )
23 int rc = EXIT_SUCCESS;
25 slap_tool_init( "slapindex", SLAPINDEX, argc, argv );
27 if( !be->be_entry_open &&
28 !be->be_entry_close &&
29 !be->be_entry_first &&
33 !be->be_index_change )
35 fprintf( stderr, "%s: database doesn't support necessary operations.\n",
40 type = attr_normalize( argv[argc - 1] );
42 if ( !be->be_index_attr( be, type ) ) {
43 fprintf( stderr, "attribute type \"%s\": no indices to generate\n",
48 if( be->be_entry_open( be, 0 ) != 0 ) {
49 fprintf( stderr, "%s: could not open database.\n",
54 for ( id = be->be_entry_first( be );
56 id = be->be_entry_next( be ) )
59 struct berval **values;
60 Entry* e = be->be_entry_get( be, id );
62 struct berval *bvals[2];
66 "entry id=%08lx: no data\n", (long) id );
68 if( continuemode ) continue;
73 printf("indexing id=%08lx dn=\"%s\"\n",
77 if( strcasecmp( type, "dn" ) == 0 ) {
78 attr = attr_find( e->e_attrs, type );
85 values = attr->a_vals;
89 bv.bv_len = strlen( bv.bv_val );
96 if ( be->be_index_change( be,
97 type, attr->a_vals, id, SLAP_INDEX_ADD_OP ) )
101 if( !continuemode ) {
110 (void) be->be_entry_close( be );