/* * The C RunTime DLL * * Implements C run-time functionality as known from UNIX. * * Copyright 1996 Marcus Meissner * Copyright 1996 Jukka Iivonen */ #include #include #include #include #include #include #include #include "win.h" #include "windows.h" #include "stddebug.h" #include "debug.h" #include "module.h" #include "xmalloc.h" #include "heap.h" #include "crtdll.h" UINT32 CRTDLL_argc_dll; /* CRTDLL.23 */ LPSTR *CRTDLL_argv_dll; /* CRTDLL.24 */ LPSTR CRTDLL_acmdln_dll; /* CRTDLL.38 */ UINT32 CRTDLL_basemajor_dll; /* CRTDLL.42 */ UINT32 CRTDLL_baseminor_dll; /* CRTDLL.43 */ UINT32 CRTDLL_baseversion_dll; /* CRTDLL.44 */ LPSTR CRTDLL_environ_dll; /* CRTDLL.75 */ UINT32 CRTDLL_osmajor_dll; /* CRTDLL.241 */ UINT32 CRTDLL_osminor_dll; /* CRTDLL.242 */ UINT32 CRTDLL_osver_dll; /* CRTDLL.244 */ UINT32 CRTDLL_osversion_dll; /* CRTDLL.245 */ UINT32 CRTDLL_winmajor_dll; /* CRTDLL.329 */ UINT32 CRTDLL_winminor_dll; /* CRTDLL.330 */ UINT32 CRTDLL_winver_dll; /* CRTDLL.331 */ typedef VOID (*new_handler_type)(VOID); static new_handler_type new_handler; /********************************************************************* * _GetMainArgs (CRTDLL.022) */ DWORD CRTDLL__GetMainArgs(LPDWORD argc,LPSTR **argv,LPSTR *environ,DWORD flag) { char *cmdline; char **xargv; int xargc,i,afterlastspace; DWORD version; dprintf_crtdll(stderr,"__GetMainArgs(%p,%p,%p,%ld).\n", argc,argv,environ,flag ); CRTDLL_acmdln_dll = cmdline = xstrdup( GetCommandLine32A() ); version = GetVersion32(); CRTDLL_osver_dll = version >> 16; CRTDLL_winminor_dll = version & 0xFF; CRTDLL_winmajor_dll = (version>>8) & 0xFF; CRTDLL_baseversion_dll = version >> 16; CRTDLL_winver_dll = ((version >> 8) & 0xFF) + ((version & 0xFF) << 8); CRTDLL_baseminor_dll = (version >> 16) & 0xFF; CRTDLL_basemajor_dll = (version >> 24) & 0xFF; CRTDLL_osversion_dll = version & 0xFFFF; CRTDLL_osminor_dll = version & 0xFF; CRTDLL_osmajor_dll = (version>>8) & 0xFF; /* missing threading init */ i=0;xargv=NULL;xargc=0;afterlastspace=0; while (cmdline[i]) { if (cmdline[i]==' ') { xargv=(char**)xrealloc(xargv,sizeof(char*)*(++xargc)); cmdline[i]='\0'; xargv[xargc-1] = xstrdup(cmdline+afterlastspace); i++; while (cmdline[i]==' ') i++; if (cmdline[i]) afterlastspace=i; } else i++; } xargv=(char**)xrealloc(xargv,sizeof(char*)*(++xargc)); cmdline[i]='\0'; xargv[xargc-1] = xstrdup(cmdline+afterlastspace); CRTDLL_argc_dll = xargc; *argc = xargc; CRTDLL_argv_dll = xargv; *argv = xargv; /* FIXME ... use real environment */ *environ = xmalloc(sizeof(LPSTR)); CRTDLL_environ_dll = *environ; (*environ)[0] = NULL; return 0; } typedef void (*_INITTERMFUN)(); /********************************************************************* * _initterm (CRTDLL.135) */ DWORD CRTDLL__initterm(_INITTERMFUN *start,_INITTERMFUN *end) { _INITTERMFUN *current; dprintf_crtdll(stddeb,"_initterm(%p,%p)\n",start,end); current=start; while (current=str); return NULL; } /********************************************************************* * _setmode (CRTDLL.265) * FIXME: dunno what this is. */ DWORD CRTDLL__setmode(LPVOID x,INT32 y) { /* FIXME */ fprintf(stdnimp,"CRTDLL._setmode(%p,%d), STUB.\n",x,y); return 0; } /********************************************************************* * atexit (CRTDLL.345) */ INT32 CRTDLL_atexit(LPVOID x) { /* FIXME */ fprintf(stdnimp,"CRTDLL.atexit(%p), STUB.\n",x); return 0; /* successful */ }