1 /* $OpenLDAP: pkg/ldap/servers/slapd/slapindex.c,v 1.3.2.3 2008/02/11 23:26:44 kurt Exp $ */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 1998-2008 The OpenLDAP Foundation.
5 * Portions Copyright 1998-2003 Kurt D. Zeilenga.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
17 * This work was initially developed by Kurt Zeilenga for inclusion
18 * in OpenLDAP Software.
25 #include <ac/stdlib.h>
28 #include <ac/string.h>
29 #include <ac/socket.h>
30 #include <ac/unistd.h>
32 #include "slapcommon.h"
35 slapindex( int argc
, char **argv
)
38 int rc
= EXIT_SUCCESS
;
39 const char *progname
= "slapindex";
40 AttributeDescription
*ad
, **adv
= NULL
;
42 slap_tool_init( progname
, SLAPINDEX
, argc
, argv
);
44 if( !be
->be_entry_open
||
45 !be
->be_entry_close
||
46 !be
->be_entry_first
||
48 !be
->be_entry_reindex
)
50 fprintf( stderr
, "%s: database doesn't support necessary operations.\n",
61 adv
= (AttributeDescription
**)argv
;
63 for (i
= 0; i
< argc
; i
++ ) {
65 rc
= slap_str2ad( argv
[i
], &ad
, &text
);
66 if ( rc
!= LDAP_SUCCESS
) {
67 fprintf( stderr
, "slap_str2ad(%s) failed %d (%s)\n",
68 argv
[i
], rc
, ldap_err2string( rc
));
75 if( be
->be_entry_open( be
, 0 ) != 0 ) {
76 fprintf( stderr
, "%s: could not open database.\n",
81 for ( id
= be
->be_entry_first( be
);
83 id
= be
->be_entry_next( be
) )
88 printf("indexing id=%08lx\n", (long) id
);
91 rtn
= be
->be_entry_reindex( be
, id
, adv
);
93 if( rtn
!= LDAP_SUCCESS
) {
95 if( continuemode
) continue;
100 (void) be
->be_entry_close( be
);