]> git.sur5r.net Git - openldap/blob - servers/slapd/tools/slapindex.c
Fix cargv leak in recursive read_config()
[openldap] / servers / slapd / tools / slapindex.c
1 /* $OpenLDAP$ */
2 /*
3  * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
4  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
5  */
6 #include "portable.h"
7
8 #include <stdio.h>
9
10 #include <ac/stdlib.h>
11
12 #include <ac/ctype.h>
13 #include <ac/string.h>
14 #include <ac/socket.h>
15 #include <ac/unistd.h>
16
17 #include "slapcommon.h"
18
19 int
20 main( int argc, char **argv )
21 {
22         ID id;
23         int rc = EXIT_SUCCESS;
24
25         slap_tool_init( "slapindex", SLAPINDEX, argc, argv );
26
27         if( !be->be_entry_open ||
28                 !be->be_entry_close ||
29                 !be->be_entry_first ||
30                 !be->be_entry_next  ||
31                 !be->be_entry_reindex )
32         {
33                 fprintf( stderr, "%s: database doesn't support necessary operations.\n",
34                         progname );
35                 exit( EXIT_FAILURE );
36         }
37
38         if( be->be_entry_open( be, 0 ) != 0 ) {
39                 fprintf( stderr, "%s: could not open database.\n",
40                         progname );
41                 exit( EXIT_FAILURE );
42         }
43
44         for ( id = be->be_entry_first( be );
45                 id != NOID;
46                 id = be->be_entry_next( be ) )
47         {
48                 int rtn;
49
50                 if( verbose ) {
51                         printf("indexing id=%08lx\n", (long) id );
52                 }
53
54                 rtn =  be->be_entry_reindex( be, id );
55
56                 if( rtn != LDAP_SUCCESS ) {
57                         rc = EXIT_FAILURE;
58                         if( continuemode ) continue;
59                         break;
60                 }
61         }
62
63         (void) be->be_entry_close( be );
64
65         slap_tool_destroy();
66         return( rc );
67 }