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 );
29 if( !be->be_entry_open &&
30 !be->be_entry_close &&
31 !be->be_entry_first &&
35 !be->be_index_change )
37 fprintf( stderr, "%s: database doesn't support necessary operations.\n",
42 type = attr_normalize( argv[argc - 1] );
44 if ( !be->be_index_attr( be, type ) ) {
45 fprintf( stderr, "attribute type \"%s\": no indices to generate\n",
50 if( be->be_entry_open( be, 0 ) != 0 ) {
51 fprintf( stderr, "%s: could not open database.\n",
56 for ( id = be->be_entry_first( be );
58 id = be->be_entry_next( be ) )
61 struct berval **values;
62 Entry* e = be->be_entry_get( be, id );
64 struct berval *bvals[2];
68 "entry id=%08lx: no data\n", (long) id );
70 if( continuemode ) continue;
75 printf("indexing id=%08lx dn=\"%s\"\n",
79 if( strcasecmp( type, "dn" ) == 0 ) {
80 attr = attr_find( e->e_attrs, type );
87 values = attr->a_vals;
91 bv.bv_len = strlen( bv.bv_val );
98 if ( be->be_index_change( be,
99 type, attr->a_vals, id, SLAP_INDEX_ADD_OP ) )
103 if( !continuemode ) {
112 (void) be->be_entry_close( be );