3 * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
10 #include <ac/stdlib.h>
13 #include <ac/string.h>
14 #include <ac/socket.h>
15 #include <ac/unistd.h>
17 #include "slapcommon.h"
20 main( int argc, char **argv )
24 int rc = EXIT_SUCCESS;
26 slap_tool_init( "slapindex", SLAPINDEX, argc, argv );
28 if( !be->be_entry_open &&
29 !be->be_entry_close &&
30 !be->be_entry_first &&
34 !be->be_index_change )
36 fprintf( stderr, "%s: database doesn't support necessary operations.\n",
41 type = attr_normalize( argv[argc - 1] );
43 if ( !be->be_index_attr( be, type ) ) {
44 fprintf( stderr, "attribute type \"%s\": no indices to generate\n",
49 if( be->be_entry_open( be, 0 ) != 0 ) {
50 fprintf( stderr, "%s: could not open database.\n",
55 for ( id = be->be_entry_first( be );
57 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 ) {
79 bv.bv_len = strlen( bv.bv_val );
86 Attribute *attr = attr_find( e->e_attrs, type );
93 values = attr->a_vals;
96 if ( be->be_index_change( be,
97 type, values, id, SLAP_INDEX_ADD_OP ) )
101 if( !continuemode ) {
110 (void) be->be_entry_close( be );