##
## tests Makefile.in for OpenLDAP
-UNIX_PRGS = slapd-tester slapd-search slapd-read slapd-addel
-PROGRAMS = $(@PLAT@_PRGS)
+PROGRAMS = slapd-tester slapd-search slapd-read slapd-addel
SRCS = slapd-tester.c slapd-search.c slapd-read.c slapd-addel.c
LDAP_INCDIR= ../../include
LDAP_LIBDIR= ../../libraries
-XLIBS = $(LDAP_LIBLDAP_LA) $(LDAP_LIBLBER_LA)
+NT_XLIBS = $(LDAP_LIBLUTIL_A)
+
+XLIBS = $(LDAP_LIBLDAP_LA) $(LDAP_LIBLBER_LA) $(@PLAT@_XLIBS)
XXLIBS = $(SECURITY_LIBS) $(LUTIL_LIBS)
# build-tools: FORCE
static int maxkids = 20;
static int nkids;
+#ifdef HAVE_WINSOCK
+static HANDLE *children;
+static char argbuf[BUFSIZ];
+#define ArgDup(x) strdup(strcat(strcat(strcpy(argbuf,"\""),x),"\""))
+#else
+#define ArgDup(x) strdup(x)
+#endif
+
static void
usage( char *name )
{
break;
case 'D': /* slapd manager */
- manager = strdup( optarg );
+ manager = ArgDup( optarg );
break;
case 'w': /* the managers passwd */
- passwd = strdup( optarg );
+ passwd = ArgDup( optarg );
break;
case 'b': /* the base DN */
- sbase = strdup( optarg );
+ sbase = ArgDup( optarg );
break;
case 'd': /* data directory */
( manager == NULL ) || ( passwd == NULL ) || ( progdir == NULL ))
usage( argv[0] );
+#ifdef HAVE_WINSOCK
+ children = malloc( maxkids * sizeof(HANDLE) );
+#endif
/* get the file list */
if ( ( datadir = opendir( dirname )) == NULL ) {
if ( j < snum ) {
sargs[sanum - 2] = sreqs[j];
- fork_child( scmd, sargs );
+ fork_child( scmd, &sargs[0] );
}
if ( j < rnum ) {
rargs[ranum - 2] = rreqs[j];
- fork_child( rcmd, rargs );
+ fork_child( rcmd, &rargs[0] );
}
if ( j < anum ) {
aargs[aanum - 2] = afiles[j];
- fork_child( acmd, aargs );
+ fork_child( acmd, &aargs[0] );
}
if (( nl = strchr( line, '\r' )) || ( nl = strchr( line, '\n' )))
*nl = '\0';
- filters[filter++] = strdup( line );
+ filters[filter++] = ArgDup( line );
}
fclose( fp );
if (( nl = strchr( line, '\r' )) || ( nl = strchr( line, '\n' )))
*nl = '\0';
- entries[entry++] = strdup( line );
+ entries[entry++] = ArgDup( line );
}
fclose( fp );
return( entry );
}
-
+#ifndef HAVE_WINSOCK
static void
fork_child( char *prog, char *args[] )
{
}
}
}
+#else
+
+static void
+wait4kids( int nkidval )
+{
+ int rc, i;
+
+ while ( nkids >= nkidval ) {
+ rc = WaitForMultipleObjects( nkids, children, FALSE, INFINITE );
+ for ( i=rc - WAIT_OBJECT_0; i<nkids-1; i++)
+ children[i] = children[i+1];
+ nkids--;
+ }
+}
+
+static void
+fork_child( char *prog, char *args[] )
+{
+ int rc;
+
+ wait4kids( maxkids );
+
+ rc = _spawnvp( _P_NOWAIT, prog, args );
+
+ if ( rc == -1 ) {
+ fprintf( stderr, "%s: ", prog );
+ perror("spawnvp");
+ } else {
+ children[nkids++] = (HANDLE)rc;
+ }
+}
+#endif