Ignore:
Timestamp:
Nov 30, 1999, 9:42:10 PM (26 years ago)
Author:
sandervl
Message:

JW's update

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/crtdll/crtdll.cpp

    r1898 r1900  
    1 /* $Id: crtdll.cpp,v 1.13 1999-11-30 20:19:52 sandervl Exp $ */
     1/* $Id: crtdll.cpp,v 1.14 1999-11-30 20:42:10 sandervl Exp $ */
    22
    33/*
     
    2424#include <ctype.h>
    2525#include <setjmp.h>
     26#include <ntddk.h>
    2627#include <debugtools.h>
    2728
     
    4849#include "crtinc.h"
    4950#include "ieee.h"
    50 #include <ntddk.h>
    5151
    5252DEFAULT_DEBUG_CHANNEL(crtdll)
     
    335335        CRTDLL_argv_dll = xargv;
    336336        *argv           = xargv;
     337        CRTDLL_environ_dll = *environ = GetEnvironmentStringsA();
    337338        dprintf(("CRTDLL: GetMainArgs end\n"));
    338         CRTDLL_environ_dll = *environ = GetEnvironmentStringsA();
    339339        return 0;
    340340}
     
    652652 *                  CRTDLL__commit    (CRTDLL.58)
    653653 */
    654 int CDECL CRTDLL__commit( int handle )
    655 {
    656   dprintf(("CRTDLL: _commit not implemented.\n"));
    657 //  if (! FlushFileBuffers(_get_osfhandle(_fd)) ) {
    658 //      __set_errno(EBADF);
    659 //      return -1;
    660 //  }
     654int CDECL CRTDLL__commit( int _fd )
     655{
     656  dprintf(("CRTDLL: _commit\n"));
     657  if (! FlushFileBuffers((HFILE)CRTDLL__get_osfhandle(_fd)) ) {
     658        __set_errno(EBADF);
     659        return -1;
     660  }
    661661  return 0;
    662662}
     
    863863 *           CRTDLL__execle   (CRTDLL.80)
    864864 */
    865 int CDECL CRTDLL__execle( char *s1, char *s2, ...)
    866 {
    867   dprintf(("CRTDLL: _execle not implemented.\n"));
    868   SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
    869   return FALSE;
     865int CDECL CRTDLL__execle(char *path, char *szArgv0, ...)
     866{
     867  dprintf(("CRTDLL: _execle not correct implemented.\n"));
     868  char *szArg[100];
     869  const char *a;
     870  char *ptr;
     871  int i = 0;
     872  va_list l = 0;
     873  va_start(l,szArgv0);
     874  do {
     875        a = (const char *)va_arg(l,const char *);
     876        szArg[i++] = (char *)a;
     877  } while ( a != NULL && i < 100 );
     878
     879
     880// szArg0 is passed and not environment if there is only one parameter;
     881
     882  if ( i >=2 ) {
     883        ptr = szArg[i-2];
     884        szArg[i-2] = NULL;
     885  }
     886  else
     887        ptr = NULL;
     888
     889  return _spawnve(P_OVERLAY, path, szArg, (char**)ptr);
    870890}
    871891
     
    893913 *           CRTDLL__execlpe   (CRTDLL.82)
    894914 */
    895 int CDECL CRTDLL__execlpe( char *s1, char *s2, ...)
    896 {
    897   dprintf(("CRTDLL: _execlpe not implemented.\n"));
    898   SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
    899   return FALSE;
     915int CDECL CRTDLL__execlpe( char *path, char *szArgv0, ...)
     916{
     917  dprintf(("CRTDLL: _execlpe not correct implemented.\n"));
     918  char *szArg[100];
     919  const char *a;
     920  char *ptr;
     921  int i = 0;
     922  va_list l = 0;
     923  va_start(l,szArgv0);
     924  do {
     925        a = (const char *)va_arg(l,const char *);
     926        szArg[i++] = (char *)a;
     927  } while ( a != NULL && i < 100 );
     928
     929
     930// szArg0 is passed and not environment if there is only one parameter;
     931
     932  if ( i >=2 ) {
     933        ptr = szArg[i-2];
     934        szArg[i-2] = NULL;
     935  }
     936  else
     937        ptr = NULL;
     938  return spawnvpe(P_OVERLAY, path, szArg, (char**)ptr);
    900939}
    901940
     
    12391278 *                  _ftime        (CRTDLL.112)
    12401279 */
    1241 int CDECL CRTDLL__ftime( struct timeb *timeptr )
     1280int CDECL CRTDLL__ftime( struct timeb *timebuf )
    12421281{
    12431282  dprintf(("CRTDLL: _ftime not implemented.\n"));
     
    12811320 *                  _get_osfhandle     (CRTDLL.117)
    12821321 */
    1283 long CDECL CRTDLL__get_osfhandle( int posixhandle )
    1284 {
    1285   dprintf(("CRTDLL: _get_osfhandle not implemented.\n"));
    1286   SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
    1287   return FALSE;
     1322void* CDECL CRTDLL__get_osfhandle( int fileno )
     1323{
     1324  dprintf(("CRTDLL: _get_osfhandle\n"));
     1325  return filehnd(fileno);
    12881326}
    12891327
     
    20172055 *                  _matherr    (CRTDLL.181)
    20182056 */
    2019 #if (__IBMCPP__ > 300)
    2020 #define exception _exception
    2021 #endif
    2022 
    20232057double CDECL CRTDLL__matherr( struct exception * excep )
    20242058{
     
    35203554 *           CRTDLL__spawnle     (CRTDLL.270)
    35213555 */
    3522 int CDECL CRTDLL__spawnle( int i, char *s1, char *s2, ... )
    3523 {
    3524   dprintf(("CRTDLL: _spawnle not implemented.\n"));
    3525   SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
    3526   return FALSE;
     3556int CDECL CRTDLL__spawnle( int mode, char *path, char **szArgv0, ... )
     3557{
     3558  dprintf(("CRTDLL: _spawnle not correct implemented.\n"));
     3559  char *szArg[100];
     3560  char *a;
     3561  char *ptr;
     3562  int i = 0;
     3563  va_list l = 0;
     3564  va_start(l,szArgv0);
     3565  do {
     3566        a = (char*)va_arg(l,const char *);
     3567        szArg[i++] = (char *)a;
     3568  } while ( a != NULL && i < 100 );
     3569
     3570
     3571// szArg0 is passed and not environment if there is only one parameter;
     3572
     3573  if ( i >=2 ) {
     3574        ptr = szArg[i-2];
     3575        szArg[i-2] = NULL;
     3576  }
     3577  else
     3578        ptr = NULL;
     3579
     3580  return _spawnve(mode, path, szArg, (char**)ptr);
    35273581}
    35283582
     
    35503604 *           CRTDLL__spawnlpe    (CRTDLL.272)
    35513605 */
    3552 int CDECL CRTDLL__spawnlpe( int i, char *s1, char *s2, ... )
    3553 {
    3554   dprintf(("CRTDLL: _spawnlpe not implemented.\n"));
    3555   SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
    3556   return FALSE;
     3606int CDECL CRTDLL__spawnlpe( int mode, char *path, char *szArgv0, ... )
     3607{
     3608  dprintf(("CRTDLL: _spawnlpe not correct implemented.\n"));
     3609  char *szArg[100];
     3610  const char *a;
     3611  char *ptr;
     3612  int i = 0;
     3613  va_list l = 0;
     3614  va_start(l,szArgv0);
     3615  do {
     3616        a = (char *)va_arg(l,const char *);
     3617        szArg[i++] = (char *)a;
     3618  } while ( a != NULL && i < 100 );
     3619
     3620
     3621// szArg0 is passed and not environment if there is only one parameter;
     3622
     3623  if ( i >=2 ) {
     3624        ptr = szArg[i-2];
     3625        szArg[i-2] = NULL;
     3626  }
     3627  else
     3628        ptr = NULL;
     3629
     3630  return _spawnvpe(mode, path, szArg, (char**)ptr);
    35573631}
    35583632
     
    48594933int CDECL CRTDLL_printf( const char *format, ... )
    48604934{
    4861   dprintf(("CRTDLL: printf not implemented.\n"));
     4935  dprintf(("CRTDLL: printf\n"));
    48624936  va_list arg;
    48634937  int done;
     
    53745448        return ( x->exponent == 0x7ff  && ( x->mantissah == 0 && x->mantissal == 0 )); 
    53755449}
     5450
     5451
     5452/*********************************************************************
     5453 *                  _filehnd    (INTERNAL-#6)
     5454 */
     5455void* filehnd(int fileno)
     5456{
     5457        if ( fileno < 0 )
     5458                return (void *)-1;
     5459#define STD_AUX_HANDLE 3
     5460#define STD_PRINTER_HANDLE 4
     5461
     5462        switch(fileno)
     5463        {
     5464        case 0:
     5465                return (void*)GetStdHandle(STD_INPUT_HANDLE);
     5466        case 1:
     5467                return (void*)GetStdHandle(STD_OUTPUT_HANDLE);
     5468        case 2:
     5469                return (void*)GetStdHandle(STD_ERROR_HANDLE);
     5470        case 3:
     5471                return (void*)GetStdHandle(STD_AUX_HANDLE);
     5472        case 4:
     5473                return (void*)GetStdHandle(STD_PRINTER_HANDLE);
     5474        default:
     5475                break;
     5476        }
     5477               
     5478        if ( fileno >= maxfno )
     5479                return (void *)-1;
     5480
     5481        if ( fileno_modes[fileno].fd == -1 )
     5482                return (void *)-1;
     5483        return (void*)fileno_modes[fileno].hFile;
     5484}
Note: See TracChangeset for help on using the changeset viewer.