]> git.sur5r.net Git - openldap/commitdiff
add section for NT to create processes
authorGary Williams <gwilliams@openldap.org>
Tue, 13 Apr 1999 21:34:00 +0000 (21:34 +0000)
committerGary Williams <gwilliams@openldap.org>
Tue, 13 Apr 1999 21:34:00 +0000 (21:34 +0000)
servers/slapd/tools/ldif2ldbm.c

index 5dda59d83cc28ef2a83613b62640f91b86e1334c..d958721b7f544868ce45c9b4ef9b05ed258df9e9 100644 (file)
@@ -8,7 +8,9 @@
 #include <ac/unistd.h>
 #include <ac/wait.h>
 
+#ifdef HAVE_SYS_PARAM_H
 #include <sys/param.h>
+#endif
 
 #include "ldapconfig.h"
 #include "../slap.h"
@@ -28,6 +30,10 @@ static char  *inputfile;
 static int      maxkids = 1;
 static int      nkids;
 
+#ifdef WIN32
+time_t starttime;
+#endif
+
 static void
 usage( char *name )
 {
@@ -271,9 +277,50 @@ main( int argc, char **argv )
 
        slap_destroy();
 
-       exit( 0 );
+       return( 0 );
 }
 
+#ifdef WIN32
+
+static HANDLE processes[MAXIMUM_WAIT_OBJECTS];
+static int nprocesses=0;
+
+static void
+fork_child( char *prog, char *args[] )
+{
+    PROCESS_INFORMATION proc_info;
+    PROCESS_INFORMATION *pinfo = &proc_info;
+
+    int i = 0;
+    char cmdLine[2048];
+    memset( cmdLine, 0, sizeof(cmdLine) );
+    strcpy( cmdLine, prog );
+    while ( args[i] != NULL );
+    {
+        strcat( cmdLine, " " );
+        strcat( cmdLine, args[i] );
+    }
+
+    if ( !CreateProcess( NULL, cmdLine, NULL, NULL,
+                         TRUE, CREATE_NEW_CONSOLE,
+                         NULL, NULL, NULL, pinfo ) )
+    {
+        fprintf( stderr, "Could not create %s: ", prog );
+        perror( "CreateProcess" );
+        exit (-1);
+    }
+    processes[nprocesses] = proc_info.hProcess;
+    nprocesses++;
+}
+
+static void
+wait4kids( int nkidval )
+{
+    WaitForMultipleObjects( nprocesses, processes, TRUE, INFINITE );
+}
+
+#else
+
 static void
 fork_child( char *prog, char *args[] )
 {
@@ -328,3 +375,5 @@ wait4kids( int nkidval )
                }
        }
 }
+
+#endif