10 #include <ac/unistd.h>
12 #include "ldif2common.h"
13 #include "../back-bdb2/back-bdb2.h"
17 main( int argc, char **argv )
20 char *linep, *buf, *attr;
23 int lmax, lcur, indexmask, syntaxmask;
28 struct berval *vals[2];
30 slap_ldif_init( argc, argv, LDIF2INDEX, "bdb2", SLAP_TOOL_MODE );
31 attr = attr_normalize( argv[argc - 1] );
35 be = &backends[dbnum];
37 /* disable write sync'ing */
38 li = (struct ldbminfo *) be->be_private;
39 li->li_dbcachewsync = 0;
41 bdb2i_attr_masks( be->be_private, attr, &indexmask, &syntaxmask );
42 if ( indexmask == 0 ) {
57 if ( fgets( line, sizeof(line), stdin ) != NULL ) {
62 while ( lcur + len + 1 > lmax ) {
64 buf = (char *) ch_realloc( buf, lmax );
66 strcpy( buf + lcur, line );
71 if ( line[0] == '\n' || stop && buf && *buf ) {
73 if (isdigit((unsigned char) *buf)) {
80 while ( (linep = ldif_getline( &s )) != NULL ) {
82 if ( ldif_parse_line( linep, &type, &val,
84 Debug( LDAP_DEBUG_PARSE,
85 "bad line %d in entry ending at line %d ignored\n",
86 elineno, elineno, 0 );
90 if ( strcasecmp( type, attr ) == 0 ) {
93 bdb2i_index_add_values( be, attr,
103 slap_shutdown(dbnum);
106 exit( EXIT_SUCCESS );