Index: trunk/src/crtdll/crtdll.cpp
===================================================================
--- trunk/src/crtdll/crtdll.cpp	(revision 1899)
+++ trunk/src/crtdll/crtdll.cpp	(revision 1900)
@@ -1,3 +1,3 @@
-/* $Id: crtdll.cpp,v 1.13 1999-11-30 20:19:52 sandervl Exp $ */
+/* $Id: crtdll.cpp,v 1.14 1999-11-30 20:42:10 sandervl Exp $ */
 
 /*
@@ -24,4 +24,5 @@
 #include <ctype.h>
 #include <setjmp.h>
+#include <ntddk.h>
 #include <debugtools.h>
 
@@ -48,5 +49,4 @@
 #include "crtinc.h"
 #include "ieee.h"
-#include <ntddk.h>
 
 DEFAULT_DEBUG_CHANNEL(crtdll)
@@ -335,6 +335,6 @@
 	CRTDLL_argv_dll	= xargv;
 	*argv		= xargv;
+	CRTDLL_environ_dll = *environ = GetEnvironmentStringsA();
 	dprintf(("CRTDLL: GetMainArgs end\n"));
-	CRTDLL_environ_dll = *environ = GetEnvironmentStringsA();
 	return 0;
 }
@@ -652,11 +652,11 @@
  *                  CRTDLL__commit    (CRTDLL.58)
  */
-int CDECL CRTDLL__commit( int handle )
-{
-  dprintf(("CRTDLL: _commit not implemented.\n"));
-//  if (! FlushFileBuffers(_get_osfhandle(_fd)) ) {
-//	__set_errno(EBADF);
-//	return -1;
-//  }
+int CDECL CRTDLL__commit( int _fd )
+{
+  dprintf(("CRTDLL: _commit\n"));
+  if (! FlushFileBuffers((HFILE)CRTDLL__get_osfhandle(_fd)) ) {
+	__set_errno(EBADF);
+	return -1;
+  }
   return 0;
 }
@@ -863,9 +863,29 @@
  *           CRTDLL__execle   (CRTDLL.80)
  */
-int CDECL CRTDLL__execle( char *s1, char *s2, ...)
-{
-  dprintf(("CRTDLL: _execle not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return FALSE;
+int CDECL CRTDLL__execle(char *path, char *szArgv0, ...)
+{
+  dprintf(("CRTDLL: _execle not correct implemented.\n"));
+  char *szArg[100];
+  const char *a;
+  char *ptr;
+  int i = 0;
+  va_list l = 0;
+  va_start(l,szArgv0);
+  do {
+  	a = (const char *)va_arg(l,const char *);
+	szArg[i++] = (char *)a;
+  } while ( a != NULL && i < 100 );
+
+
+// szArg0 is passed and not environment if there is only one parameter;
+
+  if ( i >=2 ) {
+  	ptr = szArg[i-2];
+  	szArg[i-2] = NULL;
+  }
+  else
+	ptr = NULL;
+
+  return _spawnve(P_OVERLAY, path, szArg, (char**)ptr);
 }
 
@@ -893,9 +913,28 @@
  *           CRTDLL__execlpe   (CRTDLL.82)
  */
-int CDECL CRTDLL__execlpe( char *s1, char *s2, ...)
-{
-  dprintf(("CRTDLL: _execlpe not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return FALSE;
+int CDECL CRTDLL__execlpe( char *path, char *szArgv0, ...)
+{
+  dprintf(("CRTDLL: _execlpe not correct implemented.\n"));
+  char *szArg[100];
+  const char *a;
+  char *ptr;
+  int i = 0;
+  va_list l = 0;
+  va_start(l,szArgv0);
+  do {
+  	a = (const char *)va_arg(l,const char *);
+	szArg[i++] = (char *)a;
+  } while ( a != NULL && i < 100 );
+
+
+// szArg0 is passed and not environment if there is only one parameter;
+
+  if ( i >=2 ) {
+  	ptr = szArg[i-2];
+  	szArg[i-2] = NULL;
+  }
+  else
+	ptr = NULL;
+  return spawnvpe(P_OVERLAY, path, szArg, (char**)ptr);
 }
 
@@ -1239,5 +1278,5 @@
  *                  _ftime        (CRTDLL.112)
  */
-int CDECL CRTDLL__ftime( struct timeb *timeptr )
+int CDECL CRTDLL__ftime( struct timeb *timebuf )
 {
   dprintf(("CRTDLL: _ftime not implemented.\n"));
@@ -1281,9 +1320,8 @@
  *                  _get_osfhandle     (CRTDLL.117)
  */
-long CDECL CRTDLL__get_osfhandle( int posixhandle )
-{
-  dprintf(("CRTDLL: _get_osfhandle not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return FALSE;
+void* CDECL CRTDLL__get_osfhandle( int fileno )
+{
+  dprintf(("CRTDLL: _get_osfhandle\n"));
+  return filehnd(fileno);
 }
 
@@ -2017,8 +2055,4 @@
  *                  _matherr	(CRTDLL.181)
  */
-#if (__IBMCPP__ > 300)
-#define exception _exception
-#endif
-
 double CDECL CRTDLL__matherr( struct exception * excep )
 {
@@ -3520,9 +3554,29 @@
  *           CRTDLL__spawnle 	 (CRTDLL.270)
  */
-int CDECL CRTDLL__spawnle( int i, char *s1, char *s2, ... )
-{
-  dprintf(("CRTDLL: _spawnle not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return FALSE;
+int CDECL CRTDLL__spawnle( int mode, char *path, char **szArgv0, ... )
+{
+  dprintf(("CRTDLL: _spawnle not correct implemented.\n"));
+  char *szArg[100];
+  char *a;
+  char *ptr;
+  int i = 0;
+  va_list l = 0;
+  va_start(l,szArgv0);
+  do {
+  	a = (char*)va_arg(l,const char *);
+	szArg[i++] = (char *)a;
+  } while ( a != NULL && i < 100 );
+
+
+// szArg0 is passed and not environment if there is only one parameter;
+
+  if ( i >=2 ) {
+  	ptr = szArg[i-2];
+  	szArg[i-2] = NULL;
+  }
+  else
+	ptr = NULL;
+
+  return _spawnve(mode, path, szArg, (char**)ptr);
 }
 
@@ -3550,9 +3604,29 @@
  *           CRTDLL__spawnlpe 	 (CRTDLL.272)
  */
-int CDECL CRTDLL__spawnlpe( int i, char *s1, char *s2, ... )
-{
-  dprintf(("CRTDLL: _spawnlpe not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return FALSE;
+int CDECL CRTDLL__spawnlpe( int mode, char *path, char *szArgv0, ... )
+{
+  dprintf(("CRTDLL: _spawnlpe not correct implemented.\n"));
+  char *szArg[100];
+  const char *a;
+  char *ptr;
+  int i = 0;
+  va_list l = 0;
+  va_start(l,szArgv0);
+  do {
+  	a = (char *)va_arg(l,const char *);
+	szArg[i++] = (char *)a;
+  } while ( a != NULL && i < 100 );
+
+
+// szArg0 is passed and not environment if there is only one parameter;
+
+  if ( i >=2 ) {
+  	ptr = szArg[i-2];
+  	szArg[i-2] = NULL;
+  }
+  else
+	ptr = NULL;
+
+  return _spawnvpe(mode, path, szArg, (char**)ptr);
 }
 
@@ -4859,5 +4933,5 @@
 int CDECL CRTDLL_printf( const char *format, ... )
 {
-  dprintf(("CRTDLL: printf not implemented.\n"));
+  dprintf(("CRTDLL: printf\n"));
   va_list arg;
   int done;
@@ -5374,2 +5448,37 @@
 	return ( x->exponent == 0x7ff  && ( x->mantissah == 0 && x->mantissal == 0 ));	
 }
+
+
+/*********************************************************************
+ *                  _filehnd    (INTERNAL-#6)
+ */
+void* filehnd(int fileno)
+{
+	if ( fileno < 0 )
+		return (void *)-1;
+#define STD_AUX_HANDLE 3
+#define STD_PRINTER_HANDLE 4
+
+	switch(fileno)
+	{
+	case 0:
+		return (void*)GetStdHandle(STD_INPUT_HANDLE);
+	case 1:
+		return (void*)GetStdHandle(STD_OUTPUT_HANDLE);
+	case 2:
+		return (void*)GetStdHandle(STD_ERROR_HANDLE);
+	case 3:
+		return (void*)GetStdHandle(STD_AUX_HANDLE);
+	case 4:
+		return (void*)GetStdHandle(STD_PRINTER_HANDLE);
+	default:
+		break;
+	}
+		
+	if ( fileno >= maxfno )
+		return (void *)-1;
+
+	if ( fileno_modes[fileno].fd == -1 )
+		return (void *)-1;
+	return (void*)fileno_modes[fileno].hFile;
+}
Index: trunk/src/crtdll/crtinc.h
===================================================================
--- trunk/src/crtdll/crtinc.h	(revision 1899)
+++ trunk/src/crtdll/crtinc.h	(revision 1900)
@@ -1,3 +1,3 @@
-/* $Id: crtinc.h,v 1.9 1999-11-30 14:16:45 sandervl Exp $ */
+/* $Id: crtinc.h,v 1.10 1999-11-30 20:42:10 sandervl Exp $ */
 
 /* Definitions for the CRTDLL library (CRTDLL.DLL)
@@ -108,4 +108,8 @@
 #endif
 
+#if (__IBMCPP__ > 300)
+#define exception _exception
+#endif
+
 typedef struct
 {
@@ -129,5 +133,4 @@
 	double	y;	/* Imaginary part */
 };
-
 
 #ifndef _DISKFREE_T_DEFINED
@@ -211,5 +214,5 @@
 char * 		CDECL CRTDLL_getenv( const char *name );
 int 		CDECL CRTDLL__isnan( double __x );
-
+void * 		CDECL CRTDLL__get_osfhandle( int fileno );
 
 //
@@ -221,4 +224,21 @@
 size_t 		_mbclen2(const unsigned int s);
 int 		_isinf(double __x);
+void 		*filehnd(int fileno);
+
+
+//
+// Defs for filehnd
+//
+typedef struct _fileno_modes_type
+{
+	HANDLE hFile;
+	int mode;
+	int fd;
+} fileno_modes_type;
+
+fileno_modes_type *fileno_modes = NULL;
+
+int maxfno = 5;
+int minfno = 5;
 
 
