3 * Copyright 1998-2000 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 )
23 AttributeDescription *desc;
26 int rc = EXIT_SUCCESS;
28 slap_tool_init( "slapindex", SLAPINDEX, argc, argv );
30 if( !be->be_entry_open &&
31 !be->be_entry_close &&
32 !be->be_entry_first &&
36 !be->be_index_change )
38 fprintf( stderr, "%s: database doesn't support necessary operations.\n",
43 type = argv[argc - 1];
45 rc = slap_str2ad( type, &desc, &text );
47 if( rc != LDAP_SUCCESS ) {
48 fprintf( stderr, "%s: unrecognized attribute type: %s\n",
53 if ( !be->be_index_attr( be, desc ) ) {
54 fprintf( stderr, "attribute type \"%s\": no indices to generate\n",
59 if( be->be_entry_open( be, 0 ) != 0 ) {
60 fprintf( stderr, "%s: could not open database.\n",
65 for ( id = be->be_entry_first( be );
67 id = be->be_entry_next( be ) )
69 Entry* e = be->be_entry_get( be, id );
73 "entry id=%08lx: no data\n", (long) id );
75 if( continuemode ) continue;
80 printf("indexing id=%08lx dn=\"%s\"\n",
87 for( attr = attrs_find( e->e_attrs, desc );
89 attr = attrs_find( attr->a_next, desc ) )
92 if ( be->be_index_change( be,
93 desc, attr->a_vals, id, SLAP_INDEX_ADD_OP ) )
109 (void) be->be_entry_close( be );