#define TMODRDNFILE "do_modrdn.0"
static char *get_file_name( char *dirname, char *filename );
-static int get_search_filters( char *filename, char *filters[] );
+static int get_search_filters( char *filename, char *filters[], char *bases[] );
static int get_read_entries( char *filename, char *entries[] );
static void fork_child( char *prog, char **args );
static void wait4kids( int nkidval );
static void
usage( char *name )
{
- fprintf( stderr, "usage: %s [-h <host>] -p <port> -D <manager> -w <passwd> -d <datadir> -b <baseDN> [-j <maxchild>] [-l <loops>] -P <progdir>\n", name );
+ fprintf( stderr, "usage: %s -H <uri> | ([-h <host>] -p <port>) -D <manager> -w <passwd> -d <datadir> [-j <maxchild>] [-l <loops>] -P <progdir>\n", name );
exit( EXIT_FAILURE );
}
char *manager = NULL;
char *passwd = NULL;
char *dirname = NULL;
- char *sbase = NULL;
char *progdir = NULL;
char *loops = LOOPS;
DIR *datadir;
struct dirent *file;
char *sfile = NULL;
char *sreqs[MAXREQS];
+ char *sbase[MAXREQS];
int snum = 0;
char *rfile = NULL;
char *rreqs[MAXREQS];
passwd = ArgDup( optarg );
break;
- case 'b': /* the base DN */
- sbase = ArgDup( optarg );
- break;
-
case 'd': /* data directory */
dirname = strdup( optarg );
break;
}
}
- if (( dirname == NULL ) || ( sbase == NULL ) || ( port == NULL && uri == NULL ) ||
+ if (( dirname == NULL ) || ( port == NULL && uri == NULL ) ||
( manager == NULL ) || ( passwd == NULL ) || ( progdir == NULL ))
usage( argv[0] );
/* look for search requests */
if ( sfile ) {
- snum = get_search_filters( sfile, sreqs );
+ snum = get_search_filters( sfile, sreqs, sbase );
}
/* look for read requests */
sargs[sanum++] = "-p";
sargs[sanum++] = port;
}
- sargs[sanum++] = "-b";
- sargs[sanum++] = sbase;
sargs[sanum++] = "-l";
sargs[sanum++] = loops;
+ sargs[sanum++] = "-b";
+ sargs[sanum++] = NULL; /* will hold the search base */
sargs[sanum++] = "-f";
sargs[sanum++] = NULL; /* will hold the search request */
sargs[sanum++] = NULL;
if ( j < snum ) {
sargs[sanum - 2] = sreqs[j];
+ sargs[sanum - 4] = sbase[j];
fork_child( scmd, sargs );
}
static int
-get_search_filters( char *filename, char *filters[] )
+get_search_filters( char *filename, char *filters[], char *bases[] )
{
FILE *fp;
int filter = 0;
if (( nl = strchr( line, '\r' )) || ( nl = strchr( line, '\n' )))
*nl = '\0';
+ bases[filter] = ArgDup( line );
+ fgets( line, BUFSIZ, fp );
+ if (( nl = strchr( line, '\r' )) || ( nl = strchr( line, '\n' )))
+ *nl = '\0';
+
filters[filter++] = ArgDup( line );
}