mirror of
https://github.com/reactos/wine.git
synced 2024-11-28 22:20:26 +00:00
d30dfd24d6
Sun Sep 27 14:25:38 1998 Petter Reinholdtsen <pere@td.org.uit.no> * [files/drive.c] Make sure GetDriveType32A() handles param NULL. Added some doc on function. Sun Sep 27 14:07:26 1998 Huw D M Davies <daviesh@abacus.physics.ox.ac.uk> * [controls/edit.c] [windows/win.c] Don't call SetWindowLong() in EDIT_WM_NCREATE. Fix SetWindowLong(GWL_[EX]STYLE) to work for 16bit windows. Remove UpdateWindow() call. Sun Sep 27 13:41:22 1998 Alexandre Julliard <julliard@lrc.epfl.ch> * [scheduler/*.c] [server/event.c] [server/mutex.c] [server/semaphore.c] Implemented server-side synchronisation objects. Sun Sep 27 01:13:35 1998 Alex Priem <alexp@sci.kun.nl> * [dlls/comctl32/treeview.c] [include/treeview.h] [include/comctl.h] Treeview implementation. * [dlls/comctl32/trackbar.c] [include/trackbar.h] Trackbar implementation. Sat Sep 26 20:49:13 1998 Ulrich Weigand <weigand@informatik.uni-erlangen.de> * [if1632/thunk.c] [tools/build.c] [win32/kernel32.c] Bugfix: several problems with flat thunks fixed. * [memory/selector.c] Bugfix: IsBad...Ptr16 didn't work for limit_in_pages segments. * [scheduler/thread.c] Bugfix: CreateThread: Allow id parameter == NULL. * [objects/gdiobj.c] Bugfix: IsGDIObject: Return correct object type for stock objects. * [msdos/dpmi.c] Bugfix: fixed typo in INT_DoRealModeInt. * [msdos/int21.c] Bugfix: int21 READ *must* use WIN16_hread, not _hread16. * [if1632/kernel.spec] [if1632/dummy.c] [if1632/thunk.c] [loader/ne/module.c] [scheduler/event.c] [scheduler/synchro.c] [scheduler/thread.c] [win32/kernel32.c] [win32/ordinals.c] Added names/stubs for all undocumented KERNEL routines (Win95). Added the following undoc. 16-bit equivalents to Win32 routines: KERNEL.441-443,449-453,456-462,471-476,479-486,488. Added stubs for some other KERNEL routines. * [memory/heap.c] [memory/global.c] [include/global.h] Implemented Local32... 32-bit local heap routines (KERNEL.208-215, 229). * [miscemu/instr.c] [loader/module.c] [include/module.h] Implemented __GP fault handling and HasGPHandler (KERNEL.338). * [misc/error.c] Implemented LogParamErrorRegs (KERNEL.327). * [loader/task.c] [include/windows.h] Implemented GetCodeInfo (KERNEL.104). * [loader/task.c] [scheduler/thread.c] [include/thread.h] Implemented [GS]etThreadQueue and [GS]etFastQueue (KERNEL.463/4, 624/5). * [if1632/gdi.spec] [objects/dc.c] [objects/dib.c] [objects/bitmap.c] [include/windows.h] Bugfix: fixed wrong parameter for CreateDIBSection16. Added [GS]etDIBColorTable16, stub for GetBoundsRect16. Partially implemented BITMAP_GetObject16 for DIBs. * [if1632/gdi.spec] [relay32/gdi32.spec] [objects/palette.c] Added some GDI stubs. * [if1632/Makefile.in] [if1632/display.spec] [if1632/mouse.spec] [if1632/keyboard.spec] [if1632/builtin.c] [windows/keyboard.c] Added some stubs for Win16 drivers: KEYBOARD, MOUSE, DISPLAY. * [if1632/wprocs.spec] [msdos/vxd.c] Added some stubs for VxDs: VMM, ConfigMG, TimerAPI. * [msdos/int2f.c] Added some stubs for real-mode network drivers. Sat Sep 26 18:18:18 1998 Marcus Meissner <marcus@jet.franken.de> * [configure.in] Merged in some more of the FreeBSD ports/emulators/wine patches. (Maintainer(s) of this port: You can just submit these patches to Alexandre directly.) * [loader/pe_image.c] Check filesize of image against size derived from header to spot truncated executeables without crashing. * [files/directory.c] Set envvar "COMSPEC". One win32(!!) program crashes without it. * [multimedia/mmio.c] Added mmioSetInfo32. * [include/file.h] Return STD_ERROR_HANDLE for AUX and PRT dos handles. * [loader/module.c] Handle executeables with spaces in their names a bit better in CreateProcess. * [relay32/msvfw32.spec][if1632/msvideo.spec][multimedia/msvideo.c][include/vfw.h] Started on MS Video support (can load Win32 ICMs). * [tools/testrun] A bit smarter use of ps. * [memory/virtual.c] Report PAGE_GUARDed pages as PAGE_PROTECTED (AutoCAD LT R17 fails without that check (since Win95 doesn't know about PAGE_GUARD)). Sat Sep 26 15:04:05 1998 Ove Kaaven <ovek@arcticnet.no> * [include/miscemu.h] [if1632/builtin.c] [loader/task.c] [miscemu/instr.c] [msdos/dpmi.c] [msdos/int21.c] [msdos/interrupts.c] [windows/user.c] INT_[S|G]etHandler was renamed to INT_[S|G]etPMHandler. Added handlers to deal with real-mode interrupts; DOS programs are now able to hook real-mode interrupts. * [loader/dos/module.c] [msdos/dosmem.c] [msdos/int21.c] Moved real-mode interrupt table initialization to msdos/dosmem.c, and made new V86 tasks get a full copy of the existing "system memory" instead of almost empty space. Misc fixes. * [include/dosexe.h] [loader/dos/module.c] [msdos/dpmi.c] [msdos/int2f.c] First shot at letting DOS programs start up DPMI (but DPMI is still disabled for DOS programs, for pkunzip's sake). * [include/debugger.h] [debugger/break.c] [debugger/dbg.y] [debugger/registers.c] [debugger/memory.c] [debugger/info.c] [loader/dos/dosvm.c] First shot at making Wine's debugger work for DOS programs. The -debug flag works, as do "nexti" and "stepi". Sat Sep 26 13:13:13 1998 Juergen Schmied <juergen.schmied@metronet.de> * [dlls/shell32/dataobject.c] New classes IEnumFORMATETC implemented, IDataObject stubs. * [dlls/shell32/*.*][relay32/shell32.spec] Bugfixes. New: ICM_InsertItem(), ILCreateFromPath(). Implemented: ILCloneFirst(). Stubs: ILIsEqual(), ILFindChild(), SHLogILFromFSIL(), PathMatchSpec(), PathIsExe(). Changed: ILGetSize(), _ILIsDesktop(), PathCombine(). * [include/shlobj.h] New SHLGUID's New structures: DVTARGETDEVICE32, STGMEDIUM32, FORMATETC32, CLIPFORMAT32. New interfaces: IEnumFORMATETC, IDataObject, ICommDlgBrowser IDockingWindowFrame, IServiceProvider. * [dlls/shell32/folders.c] Stubs for IShellLink. * [loader/resource.c] Small fixes. * [misc/crtdll.c][relay32/crtdll.spec] New __dllonexit(). * [windows/message.c] SendNotifyMessageA, SendMessageCallBack32A half implemented. * [controls/edit.c] EDIT_WM_SetText set EF_UPDATE flag not for ES_MULTILINE. * [files/file.c] Handling of fileposition fixed. Fri Sep 25 18:13:30 1998 Patrik Stridvall <ps@leissner.se> * [include/windows.h] [include/wintypes.h] [ole/ole2nls.h] [relay32/kernel32.spec] Implemented EnumDateFormats and EnumTimeFormats. Only adds US English support. * [Makefile.in] [configure.in] [dlls/Makefile.in] [dlls/psapi/Makefile.in] [dlls/psapi/psapi_main.c] New files to implement stubs for PSAPI.DLL (NT only). * [relay32/Makefile.in] [relay32/builtin32.c] [relay32/psapi.spec] New spec file for PSAPI.DLL (NT only). * [scheduler/handle.c] HANDLE_GetObjPtr should only interpret the pseudo handles as the current thread or the current process if a thread or a process is requested. * [include/winversion.h] [misc/version.c] Adds the global function VERSION_GetVersion() so functions can have different behavior depending on the -winver flag. * [include/oledlg.h] [ole/oledlg.c] Minor fixes. * [windows/winproc.c] Minor changes. * [include/imm.h] [misc/imm.c] Now returns correct values under both Windows 95 and NT 4.0. Thu Sep 24 22:11:44 1998 Kristian Nielsen <kristian.nielsen@risoe.dk> * [configure.in] [include/acconfig.h] [include/thread.h] [scheduler/sysdeps.c] Autoconfig test for non-reentrant libc. Wed Sep 23 19:52:12 1998 Matthew Becker <mbecker@glasscity.net> * [*/*.c] Miscellaneous documentation updates and debugging output standardizations. * [objects/clipping.c] Added ExtSelectClipRgn. Wed Sep 23 00:03:28 EDT 1998 Pete Ratzlaff <pratzlaff@cfa.harvard.edu> * [include/windows.h] [if1632/user.spec] [relay32/user32.spec] [windows/keyboard.c] Added, marginally implemented, GetKeyboardLayoutName(). Only returns US English keyboard name. Tue Sep 22 16:32:41 1998 Marcel Baur <mbaur@iiic.ethz.ch> * [programs/control/*] New Winelib application. Mon Sep 21 00:29:18 1998 Peter Hunnisett <hunnise@nortel.ca> * [include/dplay.h][multimedia/dplay.c][ole/compobj.c] Added all DirectPlayLobby interfaces and enhanced DirectPlay and DirectPlayLobby support. Still not all that much. Useful enough if you just need to start a program, don't try any real dplay/lobby stuff. * [documentation/status/directplay] Added a very little bit. * [graphics/ddraw.c] - Call to SetWindowLong32A wasn't working because there was no memory set aside when the window class was registered. - Fixed some xlib reference counting and change the behaviour of DirectDrawSurface3_SetPalette to mimic observed behaviour (palette is associated will all backbuffers) - Also stored all palette colour fields and spit back our saved colour fields rather than query X for them. - Added plenty of AddRef and Release traces. - Added Xlib support for using -desktop option. - Fixed Xlib message handling. Messages weren't being passed to the application. Fixes mouse movements in some xlib DDraw games. - Added a few stubs. * [windows/win.c][include/winerror.h] Fixed up some error handling in WIN_SetWindowLong. SetLastError wasn't being used. Could cause problems with 0 return codes. Added new error in winerror (1400). * [AUTHORS] [include/authors.h] Added myself as a Wine author. Sun Sep 20 21:22:44 1998 Alexander Larsson <alla@lysator.liu.se> * [loader/module.c] Changed GetModuleFileName32A so that is returns the long version of the filename. Note that just the name is long, not the directories. Sat Sep 19 20:05:30 1998 Per Ångström <pang@mind.nu> * [controls/menu.c] Made a couple of fixes to make life easier for applications that alter their menus at runtime. * [windows/defdlg.c] Removed the cast of the return value from dialog procedures to a 16-bit bool. The return value needs to retain all its 32 bits, since it is not always a bool, such as when responding to the WM_NCHITTEST message. Fri Sep 18 11:30:38 1998 Sergey Turchanov <turchanov@usa.net> * [loader/resource.c] Fixed very funny bug (though gravely affecting further excecution) with FindResource[Ex]32 functions. * [include/multimon.h] [windows/multimon.c] [relay32/user32.spec] [include/windows.h] [windows/sysmetrics.c] Default implementation for Multimonitor API. * [include/windows.h] [windows/winpos.c] Fixed incorrect declaration (and behaviour) of GetWindowRect32. Wed Sep 16 10:21:15 1998 Gerard Patel <G.Patel@Wanadoo.fr> * [controls/edit.c] Fixed EDIT_EM_GetLine to use correctly length of lines. Tue Sep 15 20:40:16 1998 Eric Kohl <ekohl@abo.rhein-zeitung.de> * [misc/tweak.c][include/tweak.h][controls/menu.c] Replaced the tweak graphic routines by calls to DrawEdge32(). * [misc/tweak.c][include/tweak.h][documentation/win95look] [wine.ini][*/*] Changed "look and feel" selection. Allows Win3.1, Win95 and Win98 (no GUI code implemented) look and feel. * [dlls/comctl32/header.c][include/header.h][include/commctrl.h] Started callback item support and did some minor improvements. * [dlls/comctl32/imagelist.c] Fixed bug in transparent image display. ImageList_GetIcon is still buggy :-( * [dlls/comctl32/toolbar.c] Fixed button drawing (partial hack). * [dlls/comctl32/commctrl.c] Fixed MenuHelp(). * [controls/button.c] Added 3d effect for groupbox. * [windows/msgbox.c] Added font support for message boxes. * [windows/nonclient.c] Fixed window moving bug. * [dlls/comctl32/*.c] Various improvements. * [dlls/comctl32/listview.c][dlls/comctl32/rebar.c] [include/commctrl.h] More messages. * [windows/syscolor.c][include/windows.h] Introduced new Win98 system colors. Tue Sep 15 18:29:45 1998 Wesley Filardo <eightknots@aol.com> * [files/profile.c] Added support in PROFILE_LoadWineIni for -config option * [misc/main.c] [include/options.h] Added -config option. Tue Sep 15 18:22:26 1998 Petter Reinholdtsen <pere@td.org.uit.no> * [documentation/Makefile.in] Make sure directory exists before installing into it. Tue Sep 15 01:47:33 1998 Pablo Saratxaga <pablo.sarachaga@ping.be> * [ole/nls/*] [ole/ole2nls.c] [include/winnls.h] Fixed a few errors and completed some NLS files. Mon Sep 14 01:23:45 1998 Joseph Pranevich <knight@baltimore.wwaves.com> * [include/miscemu.h] [msdos/interrupts.c] Removed a compilation warning, added INT 25 to the list of interrupts callable from DOS applications, added a debug message when unsupported interrupts are used. Sun Sep 13 19:55:22 1998 Lawson Whitney <lawson_whitney@juno.com> * [if1632/relay.c] CallProcEx32W should not reverse arguments. Sun Aug 17 21:18:12 1998 Eric Pouech <eric.pouech@lemel.fr> * [multimedia/midi.c] [multimedia/init.c] [multimedia/mmsys.c] [include/multimedia.h] [include/mmsystem.h] [multimedia/Makefile.in] [multimedia/midipatch.c] [if1632/multimedia.spec] Made MIDI input and output functional on OSS capable systems. * [multimedia/timer.c] Changes to trigger callbacks at the accurate pace even when fake timers are used.
1938 lines
48 KiB
C
1938 lines
48 KiB
C
/*
|
|
* The C RunTime DLL
|
|
*
|
|
* Implements C run-time functionality as known from UNIX.
|
|
*
|
|
* Copyright 1996 Marcus Meissner
|
|
* Copyright 1996 Jukka Iivonen
|
|
* Copyright 1997 Uwe Bonnes
|
|
*/
|
|
|
|
/*
|
|
Unresolved issues Uwe Bonnes 970904:
|
|
- Handling of Binary/Text Files is crude. If in doubt, use fromdos or recode
|
|
- Arguments in crtdll.spec for functions with double argument
|
|
- system-call calls another wine process, but without debugging arguments
|
|
and uses the first wine executable in the path
|
|
- tested with ftp://ftp.remcomp.com/pub/remcomp/lcc-win32.zip, a C-Compiler
|
|
for Win32, based on lcc, from Jacob Navia
|
|
*/
|
|
|
|
/* FIXME: all the file handling is hopelessly broken -- AJ */
|
|
|
|
#include <errno.h>
|
|
#include <stdlib.h>
|
|
#include <stdarg.h>
|
|
#include <string.h>
|
|
#include <sys/stat.h>
|
|
#include <sys/times.h>
|
|
#include <unistd.h>
|
|
#include <time.h>
|
|
#include <ctype.h>
|
|
#include <math.h>
|
|
#include <fcntl.h>
|
|
#include <setjmp.h>
|
|
#include "win.h"
|
|
#include "windows.h"
|
|
#include "winerror.h"
|
|
#include "debug.h"
|
|
#include "module.h"
|
|
#include "heap.h"
|
|
#include "crtdll.h"
|
|
#include "drive.h"
|
|
#include "file.h"
|
|
#include "except.h"
|
|
#include "options.h"
|
|
#include "winnls.h"
|
|
|
|
extern int FILE_GetUnixHandle( HFILE32 );
|
|
|
|
static DOS_FULL_NAME CRTDLL_tmpname;
|
|
|
|
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 */
|
|
UINT32 CRTDLL_commode_dll; /* CRTDLL.59 */
|
|
LPSTR CRTDLL_environ_dll; /* CRTDLL.75 */
|
|
UINT32 CRTDLL_fmode_dll; /* CRTDLL.104 */
|
|
UINT32 CRTDLL_osmajor_dll; /* CRTDLL.241 */
|
|
UINT32 CRTDLL_osminor_dll; /* CRTDLL.242 */
|
|
UINT32 CRTDLL_osmode_dll; /* CRTDLL.243 */
|
|
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 */
|
|
|
|
BYTE CRTDLL_iob[32*3]; /* FIXME */
|
|
|
|
typedef VOID (*new_handler_type)(VOID);
|
|
|
|
static new_handler_type new_handler;
|
|
|
|
/*********************************************************************
|
|
* _GetMainArgs (CRTDLL.022)
|
|
*/
|
|
DWORD __cdecl CRTDLL__GetMainArgs(LPDWORD argc,LPSTR **argv,
|
|
LPSTR *environ,DWORD flag)
|
|
{
|
|
char *cmdline;
|
|
char **xargv;
|
|
int xargc,i,afterlastspace;
|
|
DWORD version;
|
|
|
|
TRACE(crtdll,"(%p,%p,%p,%ld).\n",
|
|
argc,argv,environ,flag
|
|
);
|
|
CRTDLL_acmdln_dll = cmdline = HEAP_strdupA( GetProcessHeap(), 0,
|
|
GetCommandLine32A() );
|
|
TRACE(crtdll,"got '%s'\n", cmdline);
|
|
|
|
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**)HeapReAlloc( GetProcessHeap(), 0, xargv,
|
|
sizeof(char*)*(++xargc));
|
|
cmdline[i]='\0';
|
|
xargv[xargc-1] = HEAP_strdupA( GetProcessHeap(), 0,
|
|
cmdline+afterlastspace);
|
|
i++;
|
|
while (cmdline[i]==' ')
|
|
i++;
|
|
if (cmdline[i])
|
|
afterlastspace=i;
|
|
} else
|
|
i++;
|
|
}
|
|
xargv=(char**)HeapReAlloc( GetProcessHeap(), 0, xargv,
|
|
sizeof(char*)*(++xargc));
|
|
cmdline[i]='\0';
|
|
xargv[xargc-1] = HEAP_strdupA( GetProcessHeap(), 0,
|
|
cmdline+afterlastspace);
|
|
CRTDLL_argc_dll = xargc;
|
|
*argc = xargc;
|
|
CRTDLL_argv_dll = xargv;
|
|
*argv = xargv;
|
|
|
|
TRACE(crtdll,"found %d arguments\n",
|
|
CRTDLL_argc_dll);
|
|
CRTDLL_environ_dll = *environ = GetEnvironmentStrings32A();
|
|
return 0;
|
|
}
|
|
|
|
|
|
typedef void (*_INITTERMFUN)();
|
|
|
|
/*********************************************************************
|
|
* _findfirst (CRTDLL.099)
|
|
*
|
|
* BUGS
|
|
* Unimplemented
|
|
*/
|
|
DWORD __cdecl CRTDLL__findfirst(LPCSTR fname,struct find_t* x2)
|
|
{
|
|
FIXME(crtdll, ":(%s,%p): stub\n",fname,x2);
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
return FALSE;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* _findnext (CRTDLL.100)
|
|
*
|
|
* BUGS
|
|
* Unimplemented
|
|
*/
|
|
INT32 __cdecl CRTDLL__findnext(DWORD hand,struct find_t* x2)
|
|
{
|
|
FIXME(crtdll, ":(%ld,%p): stub\n",hand,x2);
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
return FALSE;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* _fstat (CRTDLL.111)
|
|
*
|
|
* BUGS
|
|
* Unimplemented
|
|
*/
|
|
int __cdecl CRTDLL__fstat(int file, struct stat* buf)
|
|
{
|
|
FIXME(crtdll, ":(%d,%p): stub\n",file,buf);
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
return FALSE;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* _initterm (CRTDLL.135)
|
|
*/
|
|
DWORD __cdecl CRTDLL__initterm(_INITTERMFUN *start,_INITTERMFUN *end)
|
|
{
|
|
_INITTERMFUN *current;
|
|
|
|
TRACE(crtdll,"(%p,%p)\n",start,end);
|
|
current=start;
|
|
while (current<end) {
|
|
if (*current) (*current)();
|
|
current++;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* _fdopen (CRTDLL.91)
|
|
*/
|
|
DWORD __cdecl CRTDLL__fdopen(INT32 handle, LPCSTR mode)
|
|
{
|
|
FILE *file;
|
|
|
|
switch (handle)
|
|
{
|
|
case 0 : file=stdin;
|
|
break;
|
|
case 1 : file=stdout;
|
|
break;
|
|
case 2 : file=stderr;
|
|
break;
|
|
default:
|
|
file=fdopen(handle,mode);
|
|
}
|
|
TRACE(crtdll, "open handle %d mode %s got file %p\n",
|
|
handle, mode, file);
|
|
return (DWORD)file;
|
|
}
|
|
|
|
static FILE *xlat_file_ptr(void *ptr)
|
|
{
|
|
unsigned long dif;
|
|
|
|
/* CRT sizeof(FILE) == 32 */
|
|
dif = ((char *)ptr - (char *)CRTDLL_iob) / 32;
|
|
switch(dif)
|
|
{
|
|
case 0: return stdin;
|
|
case 1: return stdout;
|
|
case 2: return stderr;
|
|
}
|
|
return (FILE*)ptr;
|
|
}
|
|
|
|
/*******************************************************************
|
|
* _global_unwind2 (CRTDLL.129)
|
|
*/
|
|
void __cdecl CRTDLL__global_unwind2( PEXCEPTION_FRAME frame )
|
|
{
|
|
RtlUnwind( frame, 0, NULL, 0 );
|
|
}
|
|
|
|
/*******************************************************************
|
|
* _local_unwind2 (CRTDLL.173)
|
|
*/
|
|
void __cdecl CRTDLL__local_unwind2( PEXCEPTION_FRAME endframe, DWORD nr )
|
|
{
|
|
TRACE(crtdll,"(%p,%ld)\n",endframe,nr);
|
|
}
|
|
/*********************************************************************
|
|
* _read (CRTDLL.256)
|
|
*
|
|
* BUGS
|
|
* Unimplemented
|
|
*/
|
|
INT32 __cdecl CRTDLL__read(INT32 fd, LPVOID buf, UINT32 count)
|
|
{
|
|
FIXME(crtdll,":(%d,%p,%d): stub\n",fd,buf,count);
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
return FALSE;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* fopen (CRTDLL.372)
|
|
*/
|
|
DWORD __cdecl CRTDLL_fopen(LPCSTR path, LPCSTR mode)
|
|
{
|
|
FILE *file;
|
|
HFILE32 dos_fildes;
|
|
#if 0
|
|
DOS_FULL_NAME full_name;
|
|
|
|
if (!DOSFS_GetFullName( path, FALSE, &full_name )) {
|
|
WARN(crtdll, "file %s bad name\n",path);
|
|
return 0;
|
|
}
|
|
|
|
file=fopen(full_name.long_name ,mode);
|
|
#endif
|
|
INT32 flagmode=0;
|
|
int unix_fildes=0;
|
|
|
|
if ((strchr(mode,'r')&&strchr(mode,'a'))||
|
|
(strchr(mode,'r')&&strchr(mode,'w'))||
|
|
(strchr(mode,'w')&&strchr(mode,'a')))
|
|
return 0;
|
|
|
|
if (strstr(mode,"r+")) flagmode=O_RDWR;
|
|
else if (strchr(mode,'r')) flagmode = O_RDONLY;
|
|
else if (strstr(mode,"w+")) flagmode= O_RDWR | O_TRUNC | O_CREAT;
|
|
else if (strchr(mode,'w')) flagmode = O_WRONLY | O_TRUNC | O_CREAT;
|
|
else if (strstr(mode,"a+")) flagmode= O_RDWR | O_CREAT | O_APPEND;
|
|
else if (strchr(mode,'w')) flagmode = O_RDWR | O_CREAT | O_APPEND;
|
|
else if (strchr(mode,'b'))
|
|
TRACE(crtdll, "%s in BINARY mode\n",path);
|
|
|
|
dos_fildes=FILE_Open(path, flagmode);
|
|
unix_fildes=FILE_GetUnixHandle(dos_fildes);
|
|
file = fdopen(unix_fildes,mode);
|
|
|
|
TRACE(crtdll, "file %s mode %s got ufh %d dfh %d file %p\n",
|
|
path,mode,unix_fildes,dos_fildes,file);
|
|
return (DWORD)file;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* fread (CRTDLL.377)
|
|
*/
|
|
DWORD __cdecl CRTDLL_fread(LPVOID ptr, INT32 size, INT32 nmemb, LPVOID vfile)
|
|
{
|
|
size_t ret=1;
|
|
FILE *file=xlat_file_ptr(vfile);
|
|
#if 0
|
|
int i=0;
|
|
void *temp=ptr;
|
|
|
|
/* If we would honour CR/LF <-> LF translation, we could do it like this.
|
|
We should keep track of all files opened, and probably files with \
|
|
known binary extensions must be unchanged */
|
|
while ( (i < (nmemb*size)) && (ret==1)) {
|
|
ret=fread(temp,1,1,file);
|
|
TRACE(crtdll, "got %c 0x%02x ret %d\n",
|
|
(isalpha(*(unsigned char*)temp))? *(unsigned char*)temp:
|
|
' ',*(unsigned char*)temp, ret);
|
|
if (*(unsigned char*)temp != 0xd) { /* skip CR */
|
|
temp++;
|
|
i++;
|
|
}
|
|
else
|
|
TRACE(crtdll, "skipping ^M\n");
|
|
}
|
|
TRACE(crtdll, "0x%08x items of size %d from file %p to %p\n",
|
|
nmemb,size,file,ptr,);
|
|
if(i!=nmemb)
|
|
WARN(crtdll, " failed!\n");
|
|
|
|
return i;
|
|
#else
|
|
|
|
ret=fread(ptr,size,nmemb,file);
|
|
TRACE(crtdll, "0x%08x items of size %d from file %p to %p\n",
|
|
nmemb,size,file,ptr);
|
|
if(ret!=nmemb)
|
|
WARN(crtdll, " failed!\n");
|
|
|
|
return ret;
|
|
#endif
|
|
}
|
|
/*********************************************************************
|
|
* freopen (CRTDLL.379)
|
|
*
|
|
* BUGS
|
|
* Unimplemented
|
|
*/
|
|
DWORD __cdecl CRTDLL_freopen(LPCSTR path, LPCSTR mode, LPVOID stream)
|
|
{
|
|
FIXME(crtdll, ":(%s,%s,%p): stub\n", path, mode, stream);
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
return FALSE;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* fscanf (CRTDLL.381)
|
|
*/
|
|
INT32 __cdecl CRTDLL_fscanf( LPVOID stream, LPSTR format, ... )
|
|
{
|
|
va_list valist;
|
|
INT32 res;
|
|
|
|
va_start( valist, format );
|
|
#ifdef HAVE_VFSCANF
|
|
res = vfscanf( xlat_file_ptr(stream), format, valist );
|
|
#endif
|
|
va_end( valist );
|
|
return res;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* fseek (CRTDLL.382)
|
|
*/
|
|
LONG __cdecl CRTDLL_fseek(LPVOID stream, LONG offset, INT32 whence)
|
|
{
|
|
long ret;
|
|
|
|
ret=fseek(xlat_file_ptr(stream),offset,whence);
|
|
TRACE(crtdll, "file %p to 0x%08lx pos %s\n",
|
|
stream,offset,(whence==SEEK_SET)?"SEEK_SET":
|
|
(whence==SEEK_CUR)?"SEEK_CUR":
|
|
(whence==SEEK_END)?"SEEK_END":"UNKNOWN");
|
|
if(ret)
|
|
WARN(crtdll, " failed!\n");
|
|
|
|
return ret;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* fsetpos (CRTDLL.383)
|
|
*/
|
|
INT32 __cdecl CRTDLL_fsetpos(LPVOID stream, fpos_t *pos)
|
|
{
|
|
TRACE(crtdll, "file %p\n", stream);
|
|
return fseek(xlat_file_ptr(stream), *pos, SEEK_SET);
|
|
}
|
|
|
|
/*********************************************************************
|
|
* ftell (CRTDLL.384)
|
|
*/
|
|
LONG __cdecl CRTDLL_ftell(LPVOID stream)
|
|
{
|
|
long ret;
|
|
|
|
ret=ftell(xlat_file_ptr(stream));
|
|
TRACE(crtdll, "file %p at 0x%08lx\n",
|
|
stream,ret);
|
|
return ret;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* fwrite (CRTDLL.386)
|
|
*/
|
|
DWORD __cdecl CRTDLL_fwrite(LPVOID ptr, INT32 size, INT32 nmemb, LPVOID vfile)
|
|
{
|
|
size_t ret;
|
|
FILE *file=xlat_file_ptr(vfile);
|
|
|
|
ret=fwrite(ptr,size,nmemb,file);
|
|
TRACE(crtdll, "0x%08x items of size %d from %p to file %p\n",
|
|
nmemb,size,ptr,file);
|
|
if(ret!=nmemb)
|
|
WARN(crtdll, " Failed!\n");
|
|
|
|
return ret;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* setbuf (CRTDLL.452)
|
|
*/
|
|
INT32 __cdecl CRTDLL_setbuf(LPVOID file, LPSTR buf)
|
|
{
|
|
TRACE(crtdll, "(file %p buf %p)\n", file, buf);
|
|
/* this doesn't work:"void value not ignored as it ought to be"
|
|
return setbuf(file,buf);
|
|
*/
|
|
setbuf(xlat_file_ptr(file),buf);
|
|
return 0;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* _open_osfhandle (CRTDLL.240)
|
|
*/
|
|
HFILE32 __cdecl CRTDLL__open_osfhandle(LONG osfhandle, INT32 flags)
|
|
{
|
|
HFILE32 handle;
|
|
|
|
switch (osfhandle) {
|
|
case STD_INPUT_HANDLE :
|
|
case 0 :
|
|
handle=0;
|
|
break;
|
|
case STD_OUTPUT_HANDLE:
|
|
case 1:
|
|
handle=1;
|
|
break;
|
|
case STD_ERROR_HANDLE:
|
|
case 2:
|
|
handle=2;
|
|
break;
|
|
default:
|
|
return (-1);
|
|
}
|
|
TRACE(crtdll, "(handle %08lx,flags %d) return %d\n",
|
|
osfhandle,flags,handle);
|
|
return handle;
|
|
|
|
}
|
|
|
|
/*********************************************************************
|
|
* srand (CRTDLL.460)
|
|
*/
|
|
void __cdecl CRTDLL_srand(DWORD seed)
|
|
{
|
|
/* FIXME: should of course be thread? process? local */
|
|
srand(seed);
|
|
}
|
|
|
|
/*********************************************************************
|
|
* fprintf (CRTDLL.373)
|
|
*/
|
|
INT32 __cdecl CRTDLL_fprintf( FILE *file, LPSTR format, ... )
|
|
{
|
|
va_list valist;
|
|
INT32 res;
|
|
|
|
va_start( valist, format );
|
|
res = vfprintf( xlat_file_ptr(file), format, valist );
|
|
va_end( valist );
|
|
return res;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* vfprintf (CRTDLL.373)
|
|
*/
|
|
INT32 __cdecl CRTDLL_vfprintf( FILE *file, LPSTR format, va_list args )
|
|
{
|
|
return vfprintf( xlat_file_ptr(file), format, args );
|
|
}
|
|
|
|
/*********************************************************************
|
|
* time (CRTDLL.488)
|
|
*/
|
|
time_t __cdecl CRTDLL_time(time_t *timeptr)
|
|
{
|
|
time_t curtime = time(NULL);
|
|
|
|
if (timeptr)
|
|
*timeptr = curtime;
|
|
return curtime;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* (CRTDLL.350)
|
|
*/
|
|
clock_t __cdecl CRTDLL_clock(void)
|
|
{
|
|
struct tms alltimes;
|
|
clock_t res;
|
|
|
|
times(&alltimes);
|
|
res = alltimes.tms_utime + alltimes.tms_stime+
|
|
alltimes.tms_cutime + alltimes.tms_cstime;
|
|
/* Fixme: We need some symbolic representation
|
|
for (Hostsystem_)CLOCKS_PER_SEC
|
|
and (Emulated_system_)CLOCKS_PER_SEC
|
|
10 holds only for Windows/Linux_i86)
|
|
*/
|
|
return 10*res;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* _isatty (CRTDLL.137)
|
|
*/
|
|
BOOL32 __cdecl CRTDLL__isatty(DWORD x)
|
|
{
|
|
TRACE(crtdll,"(%ld)\n",x);
|
|
return TRUE;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* _write (CRTDLL.332)
|
|
*/
|
|
INT32 __cdecl CRTDLL__write(INT32 fd,LPCVOID buf,UINT32 count)
|
|
{
|
|
INT32 len=0;
|
|
|
|
if (fd == -1)
|
|
len = -1;
|
|
else if (fd<=2)
|
|
len = (UINT32)write(fd,buf,(LONG)count);
|
|
else
|
|
len = _lwrite32(fd,buf,count);
|
|
TRACE(crtdll,"%d/%d byte to dfh %d from %p,\n",
|
|
len,count,fd,buf);
|
|
return len;
|
|
}
|
|
|
|
|
|
/*********************************************************************
|
|
* _cexit (CRTDLL.49)
|
|
*
|
|
* FIXME: What the heck is the difference between
|
|
* FIXME _c_exit (CRTDLL.47)
|
|
* FIXME _cexit (CRTDLL.49)
|
|
* FIXME _exit (CRTDLL.87)
|
|
* FIXME exit (CRTDLL.359)
|
|
*
|
|
* atexit-processing comes to mind -- MW.
|
|
*
|
|
*/
|
|
void __cdecl CRTDLL__cexit(INT32 ret)
|
|
{
|
|
TRACE(crtdll,"(%d)\n",ret);
|
|
ExitProcess(ret);
|
|
}
|
|
|
|
|
|
/*********************************************************************
|
|
* exit (CRTDLL.359)
|
|
*/
|
|
void __cdecl CRTDLL_exit(DWORD ret)
|
|
{
|
|
TRACE(crtdll,"(%ld)\n",ret);
|
|
ExitProcess(ret);
|
|
}
|
|
|
|
|
|
/*********************************************************************
|
|
* _abnormal_termination (CRTDLL.36)
|
|
*/
|
|
INT32 __cdecl CRTDLL__abnormal_termination(void)
|
|
{
|
|
TRACE(crtdll,"(void)\n");
|
|
return 0;
|
|
}
|
|
|
|
|
|
/*********************************************************************
|
|
* _access (CRTDLL.37)
|
|
*/
|
|
INT32 __cdecl CRTDLL__access(LPCSTR filename, INT32 mode)
|
|
{
|
|
DWORD attr = GetFileAttributes32A(filename);
|
|
|
|
if (attr == -1)
|
|
{
|
|
if (GetLastError() == ERROR_INVALID_ACCESS)
|
|
errno = EACCES;
|
|
else
|
|
errno = ENOENT;
|
|
return -1;
|
|
}
|
|
|
|
if ((attr & FILE_ATTRIBUTE_READONLY) && (mode & W_OK))
|
|
{
|
|
errno = EACCES;
|
|
return -1;
|
|
}
|
|
else
|
|
return 0;
|
|
}
|
|
|
|
|
|
/*********************************************************************
|
|
* fflush (CRTDLL.365)
|
|
*/
|
|
INT32 __cdecl CRTDLL_fflush(LPVOID stream)
|
|
{
|
|
int ret;
|
|
|
|
ret = fflush(xlat_file_ptr(stream));
|
|
TRACE(crtdll,"%p returnd %d\n",stream,ret);
|
|
if(ret)
|
|
WARN(crtdll, " Failed!\n");
|
|
|
|
return ret;
|
|
}
|
|
|
|
|
|
/*********************************************************************
|
|
* gets (CRTDLL.391)
|
|
*/
|
|
LPSTR __cdecl CRTDLL_gets(LPSTR buf)
|
|
{
|
|
char * ret;
|
|
/* BAD, for the whole WINE process blocks... just done this way to test
|
|
* windows95's ftp.exe.
|
|
*/
|
|
ret = gets(buf);
|
|
TRACE(crtdll,"got %s\n",ret);
|
|
return ret;
|
|
}
|
|
|
|
|
|
/*********************************************************************
|
|
* rand (CRTDLL.446)
|
|
*/
|
|
INT32 __cdecl CRTDLL_rand()
|
|
{
|
|
return rand();
|
|
}
|
|
|
|
|
|
/*********************************************************************
|
|
* putchar (CRTDLL.442)
|
|
*/
|
|
void __cdecl CRTDLL_putchar( INT32 x )
|
|
{
|
|
putchar(x);
|
|
}
|
|
|
|
|
|
/*********************************************************************
|
|
* fputc (CRTDLL.374)
|
|
*/
|
|
INT32 __cdecl CRTDLL_fputc( INT32 c, FILE *stream )
|
|
{
|
|
TRACE(crtdll, "%c to file %p\n",c,stream);
|
|
return fputc(c,xlat_file_ptr(stream));
|
|
}
|
|
|
|
|
|
/*********************************************************************
|
|
* fputs (CRTDLL.375)
|
|
*/
|
|
INT32 __cdecl CRTDLL_fputs( LPCSTR s, FILE *stream )
|
|
{
|
|
TRACE(crtdll, "%s to file %p\n",s,stream);
|
|
return fputs(s,xlat_file_ptr(stream));
|
|
}
|
|
|
|
|
|
/*********************************************************************
|
|
* puts (CRTDLL.443)
|
|
*/
|
|
INT32 __cdecl CRTDLL_puts(LPCSTR s)
|
|
{
|
|
TRACE(crtdll, "%s \n",s);
|
|
return puts(s);
|
|
}
|
|
|
|
|
|
/*********************************************************************
|
|
* putc (CRTDLL.441)
|
|
*/
|
|
INT32 __cdecl CRTDLL_putc(INT32 c, FILE *stream)
|
|
{
|
|
TRACE(crtdll, " %c to file %p\n",c,stream);
|
|
return fputc(c,xlat_file_ptr(stream));
|
|
}
|
|
/*********************************************************************
|
|
* fgetc (CRTDLL.366)
|
|
*/
|
|
INT32 __cdecl CRTDLL_fgetc( FILE *stream )
|
|
{
|
|
int ret= fgetc(xlat_file_ptr(stream));
|
|
TRACE(crtdll, "got %d\n",ret);
|
|
return ret;
|
|
}
|
|
|
|
|
|
/*********************************************************************
|
|
* getc (CRTDLL.388)
|
|
*/
|
|
INT32 __cdecl CRTDLL_getc( FILE *stream )
|
|
{
|
|
int ret= fgetc(xlat_file_ptr(stream));
|
|
TRACE(crtdll, "got %d\n",ret);
|
|
return ret;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* _rotl (CRTDLL.259)
|
|
*/
|
|
UINT32 __cdecl CRTDLL__rotl(UINT32 x,INT32 shift)
|
|
{
|
|
unsigned int ret = (x >> shift)|( x >>((sizeof(x))-shift));
|
|
|
|
TRACE(crtdll, "got 0x%08x rot %d ret 0x%08x\n",
|
|
x,shift,ret);
|
|
return ret;
|
|
|
|
}
|
|
/*********************************************************************
|
|
* _lrotl (CRTDLL.176)
|
|
*/
|
|
DWORD __cdecl CRTDLL__lrotl(DWORD x,INT32 shift)
|
|
{
|
|
unsigned long ret = (x >> shift)|( x >>((sizeof(x))-shift));
|
|
|
|
TRACE(crtdll, "got 0x%08lx rot %d ret 0x%08lx\n",
|
|
x,shift,ret);
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
/*********************************************************************
|
|
* fgets (CRTDLL.368)
|
|
*/
|
|
CHAR* __cdecl CRTDLL_fgets(LPSTR s,INT32 size, LPVOID stream)
|
|
{
|
|
char * ret;
|
|
char * control_M;
|
|
|
|
ret=fgets(s, size,xlat_file_ptr(stream));
|
|
/*FIXME: Control with CRTDLL_setmode */
|
|
control_M= strrchr(s,'\r');
|
|
/*delete CR if we read a DOS File */
|
|
if (control_M)
|
|
{
|
|
*control_M='\n';
|
|
*(control_M+1)=0;
|
|
}
|
|
TRACE(crtdll, "got %s for %d chars from file %p\n",
|
|
s,size,stream);
|
|
if(ret)
|
|
WARN(crtdll, " Failed!\n");
|
|
|
|
return ret;
|
|
}
|
|
|
|
|
|
/*********************************************************************
|
|
* _mbsicmp (CRTDLL.204)
|
|
*/
|
|
int __cdecl CRTDLL__mbsicmp(unsigned char *x,unsigned char *y)
|
|
{
|
|
do {
|
|
if (!*x)
|
|
return !!*y;
|
|
if (!*y)
|
|
return !!*x;
|
|
/* FIXME: MBCS handling... */
|
|
if (*x!=*y)
|
|
return 1;
|
|
x++;
|
|
y++;
|
|
} while (1);
|
|
}
|
|
|
|
|
|
/*********************************************************************
|
|
* _mbsinc (CRTDLL.205)
|
|
*/
|
|
unsigned char * __cdecl CRTDLL__mbsinc(unsigned char *x)
|
|
{
|
|
/* FIXME: mbcs */
|
|
return x++;
|
|
}
|
|
|
|
|
|
/*********************************************************************
|
|
* vsprintf (CRTDLL.500)
|
|
*/
|
|
INT32 __cdecl CRTDLL_vsprintf( LPSTR buffer, LPCSTR spec, va_list args )
|
|
{
|
|
return wvsprintf32A( buffer, spec, args );
|
|
}
|
|
|
|
/*********************************************************************
|
|
* vswprintf (CRTDLL.501)
|
|
*/
|
|
INT32 __cdecl CRTDLL_vswprintf( LPWSTR buffer, LPCWSTR spec, va_list args )
|
|
{
|
|
return wvsprintf32W( buffer, spec, args );
|
|
}
|
|
|
|
/*********************************************************************
|
|
* _mbscpy (CRTDLL.200)
|
|
*/
|
|
unsigned char* __cdecl CRTDLL__mbscpy(unsigned char *x,unsigned char *y)
|
|
{
|
|
TRACE(crtdll,"CRTDLL_mbscpy %s and %s\n",x,y);
|
|
return strcpy(x,y);
|
|
}
|
|
|
|
|
|
/*********************************************************************
|
|
* _mbscat (CRTDLL.197)
|
|
*/
|
|
unsigned char* __cdecl CRTDLL__mbscat(unsigned char *x,unsigned char *y)
|
|
{
|
|
return strcat(x,y);
|
|
}
|
|
|
|
|
|
/*********************************************************************
|
|
* _strcmpi (CRTDLL.282) (CRTDLL.287)
|
|
*/
|
|
INT32 __cdecl CRTDLL__strcmpi( LPCSTR s1, LPCSTR s2 )
|
|
{
|
|
return lstrcmpi32A( s1, s2 );
|
|
}
|
|
|
|
|
|
/*********************************************************************
|
|
* _strnicmp (CRTDLL.293)
|
|
*/
|
|
INT32 __cdecl CRTDLL__strnicmp( LPCSTR s1, LPCSTR s2, INT32 n )
|
|
{
|
|
return lstrncmpi32A( s1, s2, n );
|
|
}
|
|
|
|
|
|
/*********************************************************************
|
|
* _strlwr (CRTDLL.293)
|
|
*
|
|
* convert a string in place to lowercase
|
|
*/
|
|
LPSTR __cdecl CRTDLL__strlwr(LPSTR x)
|
|
{
|
|
unsigned char *y =x;
|
|
|
|
TRACE(crtdll, "CRTDLL_strlwr got %s\n", x);
|
|
while (*y) {
|
|
if ((*y > 0x40) && (*y< 0x5b))
|
|
*y = *y + 0x20;
|
|
y++;
|
|
}
|
|
TRACE(crtdll, " returned %s\n", x);
|
|
|
|
return x;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* system (CRTDLL.485)
|
|
*/
|
|
INT32 __cdecl CRTDLL_system(LPSTR x)
|
|
{
|
|
#define SYSBUF_LENGTH 1500
|
|
char buffer[SYSBUF_LENGTH];
|
|
unsigned char *y = x;
|
|
unsigned char *bp;
|
|
int i;
|
|
|
|
sprintf( buffer, "%s \"", Options.argv0 );
|
|
bp = buffer + strlen(buffer);
|
|
i = strlen(buffer) + strlen(x) +2;
|
|
|
|
/* Calculate needed buffer size to prevent overflow. */
|
|
while (*y) {
|
|
if (*y =='\\') i++;
|
|
y++;
|
|
}
|
|
/* If buffer too short, exit. */
|
|
if (i > SYSBUF_LENGTH) {
|
|
TRACE(crtdll,"_system buffer to small\n");
|
|
return 127;
|
|
}
|
|
|
|
y =x;
|
|
|
|
while (*y) {
|
|
*bp = *y;
|
|
bp++; y++;
|
|
if (*(y-1) =='\\') *bp++ = '\\';
|
|
}
|
|
/* Remove spaces from end of string. */
|
|
while (*(y-1) == ' ') {
|
|
bp--;y--;
|
|
}
|
|
*bp++ = '"';
|
|
*bp = 0;
|
|
TRACE(crtdll, "_system got '%s', executing '%s'\n",x,buffer);
|
|
|
|
return system(buffer);
|
|
}
|
|
|
|
/*********************************************************************
|
|
* _strupr (CRTDLL.300)
|
|
*/
|
|
LPSTR __cdecl CRTDLL__strupr(LPSTR x)
|
|
{
|
|
LPSTR y=x;
|
|
|
|
while (*y) {
|
|
*y=toupper(*y);
|
|
y++;
|
|
}
|
|
return x;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* _wcsupr (CRTDLL.328)
|
|
*/
|
|
LPWSTR __cdecl CRTDLL__wcsupr(LPWSTR x)
|
|
{
|
|
LPWSTR y=x;
|
|
|
|
while (*y) {
|
|
*y=towupper(*y);
|
|
y++;
|
|
}
|
|
return x;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* _wcslwr (CRTDLL.323)
|
|
*/
|
|
LPWSTR __cdecl CRTDLL__wcslwr(LPWSTR x)
|
|
{
|
|
LPWSTR y=x;
|
|
|
|
while (*y) {
|
|
*y=towlower(*y);
|
|
y++;
|
|
}
|
|
return x;
|
|
}
|
|
|
|
|
|
/*********************************************************************
|
|
* longjmp (CRTDLL.426)
|
|
*/
|
|
VOID __cdecl CRTDLL_longjmp(jmp_buf env, int val)
|
|
{
|
|
FIXME(crtdll,"CRTDLL_longjmp semistup, expect crash\n");
|
|
return longjmp(env, val);
|
|
}
|
|
|
|
/*********************************************************************
|
|
* malloc (CRTDLL.427)
|
|
*/
|
|
VOID* __cdecl CRTDLL_malloc(DWORD size)
|
|
{
|
|
return HeapAlloc(GetProcessHeap(),0,size);
|
|
}
|
|
|
|
/*********************************************************************
|
|
* new (CRTDLL.001)
|
|
*/
|
|
VOID* __cdecl CRTDLL_new(DWORD size)
|
|
{
|
|
VOID* result;
|
|
if(!(result = HeapAlloc(GetProcessHeap(),0,size)) && new_handler)
|
|
(*new_handler)();
|
|
return result;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* set_new_handler(CRTDLL.003)
|
|
*/
|
|
new_handler_type __cdecl CRTDLL_set_new_handler(new_handler_type func)
|
|
{
|
|
new_handler_type old_handler = new_handler;
|
|
new_handler = func;
|
|
return old_handler;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* calloc (CRTDLL.350)
|
|
*/
|
|
VOID* __cdecl CRTDLL_calloc(DWORD size, DWORD count)
|
|
{
|
|
return HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, size * count );
|
|
}
|
|
|
|
/*********************************************************************
|
|
* realloc (CRTDLL.447)
|
|
*/
|
|
VOID* __cdecl CRTDLL_realloc( VOID *ptr, DWORD size )
|
|
{
|
|
return HeapReAlloc( GetProcessHeap(), 0, ptr, size );
|
|
}
|
|
|
|
/*********************************************************************
|
|
* free (CRTDLL.427)
|
|
*/
|
|
VOID __cdecl CRTDLL_free(LPVOID ptr)
|
|
{
|
|
HeapFree(GetProcessHeap(),0,ptr);
|
|
}
|
|
|
|
/*********************************************************************
|
|
* delete (CRTDLL.002)
|
|
*/
|
|
VOID __cdecl CRTDLL_delete(VOID* ptr)
|
|
{
|
|
HeapFree(GetProcessHeap(),0,ptr);
|
|
}
|
|
|
|
/*********************************************************************
|
|
* _strdup (CRTDLL.285)
|
|
*/
|
|
LPSTR __cdecl CRTDLL__strdup(LPCSTR ptr)
|
|
{
|
|
return HEAP_strdupA(GetProcessHeap(),0,ptr);
|
|
}
|
|
|
|
/*********************************************************************
|
|
* _wcsdup (CRTDLL.320)
|
|
*/
|
|
LPWSTR __cdecl CRTDLL__wcsdup(LPCWSTR ptr)
|
|
{
|
|
return HEAP_strdupW(GetProcessHeap(),0,ptr);
|
|
}
|
|
|
|
/*********************************************************************
|
|
* fclose (CRTDLL.362)
|
|
*/
|
|
INT32 __cdecl CRTDLL_fclose( FILE *stream )
|
|
{
|
|
int unix_handle;
|
|
HFILE32 dos_handle=1;
|
|
HFILE32 ret=EOF;
|
|
|
|
stream=xlat_file_ptr(stream);
|
|
unix_handle=fileno(stream);
|
|
|
|
if (unix_handle<4) ret= fclose(stream);
|
|
else {
|
|
while(FILE_GetUnixHandle(dos_handle) != unix_handle) dos_handle++;
|
|
fclose(stream);
|
|
ret = _lclose32( dos_handle);
|
|
}
|
|
TRACE(crtdll,"(%p) ufh %d dfh %d\n",
|
|
stream,unix_handle,dos_handle);
|
|
|
|
if(ret)
|
|
WARN(crtdll, " Failed!\n");
|
|
|
|
return ret;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* _unlink (CRTDLL.315)
|
|
*/
|
|
INT32 __cdecl CRTDLL__unlink(LPCSTR pathname)
|
|
{
|
|
int ret=0;
|
|
DOS_FULL_NAME full_name;
|
|
|
|
if (!DOSFS_GetFullName( pathname, FALSE, &full_name )) {
|
|
WARN(crtdll, "CRTDLL_unlink file %s bad name\n",pathname);
|
|
return EOF;
|
|
}
|
|
|
|
ret=unlink(full_name.long_name);
|
|
TRACE(crtdll,"(%s unix %s)\n",
|
|
pathname,full_name.long_name);
|
|
if(ret)
|
|
WARN(crtdll, " Failed!\n");
|
|
|
|
return ret;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* rename (CRTDLL.449)
|
|
*/
|
|
INT32 __cdecl CRTDLL_rename(LPCSTR oldpath,LPCSTR newpath)
|
|
{
|
|
BOOL32 ok = MoveFileEx32A( oldpath, newpath, MOVEFILE_REPLACE_EXISTING );
|
|
return ok ? 0 : -1;
|
|
}
|
|
|
|
|
|
/*********************************************************************
|
|
* _stat (CRTDLL.280)
|
|
*/
|
|
|
|
struct win_stat
|
|
{
|
|
UINT16 win_st_dev;
|
|
UINT16 win_st_ino;
|
|
UINT16 win_st_mode;
|
|
INT16 win_st_nlink;
|
|
INT16 win_st_uid;
|
|
INT16 win_st_gid;
|
|
UINT32 win_st_rdev;
|
|
INT32 win_st_size;
|
|
INT32 win_st_atime;
|
|
INT32 win_st_mtime;
|
|
INT32 win_st_ctime;
|
|
};
|
|
|
|
int __cdecl CRTDLL__stat(const char * filename, struct win_stat * buf)
|
|
{
|
|
int ret=0;
|
|
DOS_FULL_NAME full_name;
|
|
struct stat mystat;
|
|
|
|
if (!DOSFS_GetFullName( filename, TRUE, &full_name ))
|
|
{
|
|
WARN(crtdll, "CRTDLL__stat filename %s bad name\n",filename);
|
|
return -1;
|
|
}
|
|
ret=stat(full_name.long_name,&mystat);
|
|
TRACE(crtdll,"CRTDLL__stat %s\n", filename);
|
|
if(ret)
|
|
WARN(crtdll, " Failed!\n");
|
|
|
|
/* FIXME: should check what Windows returns */
|
|
|
|
buf->win_st_dev = mystat.st_dev;
|
|
buf->win_st_ino = mystat.st_ino;
|
|
buf->win_st_mode = mystat.st_mode;
|
|
buf->win_st_nlink = mystat.st_nlink;
|
|
buf->win_st_uid = mystat.st_uid;
|
|
buf->win_st_gid = mystat.st_gid;
|
|
buf->win_st_rdev = mystat.st_rdev;
|
|
buf->win_st_size = mystat.st_size;
|
|
buf->win_st_atime = mystat.st_atime;
|
|
buf->win_st_mtime = mystat.st_mtime;
|
|
buf->win_st_ctime = mystat.st_ctime;
|
|
return ret;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* _open (CRTDLL.239)
|
|
*/
|
|
HFILE32 __cdecl CRTDLL__open(LPCSTR path,INT32 flags)
|
|
{
|
|
HFILE32 ret=0;
|
|
int wineflags=0;
|
|
|
|
/* FIXME:
|
|
the flags in lcc's header differ from the ones in Linux, e.g.
|
|
Linux: define O_APPEND 02000 (= 0x400)
|
|
lcc: define _O_APPEND 0x0008
|
|
so here a scheme to translate them
|
|
Probably lcc is wrong here, but at least a hack to get is going
|
|
*/
|
|
wineflags = (flags & 3);
|
|
if (flags & 0x0008 ) wineflags |= O_APPEND;
|
|
if (flags & 0x0100 ) wineflags |= O_CREAT;
|
|
if (flags & 0x0200 ) wineflags |= O_TRUNC;
|
|
if (flags & 0x0400 ) wineflags |= O_EXCL;
|
|
if (flags & 0xf0f4 )
|
|
TRACE(crtdll,"CRTDLL_open file unsupported flags 0x%04x\n",flags);
|
|
/* End Fixme */
|
|
|
|
ret = FILE_Open(path,wineflags);
|
|
TRACE(crtdll,"CRTDLL_open file %s mode 0x%04x (lccmode 0x%04x) got dfh %d\n",
|
|
path,wineflags,flags,ret);
|
|
return ret;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* _close (CRTDLL.57)
|
|
*/
|
|
INT32 __cdecl CRTDLL__close(HFILE32 fd)
|
|
{
|
|
int ret=_lclose32(fd);
|
|
|
|
TRACE(crtdll,"(%d)\n",fd);
|
|
if(ret)
|
|
WARN(crtdll, " Failed!\n");
|
|
|
|
return ret;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* feof (CRTDLL.363)
|
|
*/
|
|
INT32 __cdecl CRTDLL_feof( FILE *stream )
|
|
{
|
|
int ret;
|
|
|
|
ret=feof(xlat_file_ptr(stream));
|
|
TRACE(crtdll,"(%p) %s\n",stream,(ret)?"true":"false");
|
|
return ret;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* setlocale (CRTDLL.453)
|
|
*/
|
|
LPSTR __cdecl CRTDLL_setlocale(INT32 category,LPCSTR locale)
|
|
{
|
|
LPSTR categorystr;
|
|
|
|
switch (category) {
|
|
case CRTDLL_LC_ALL: categorystr="LC_ALL";break;
|
|
case CRTDLL_LC_COLLATE: categorystr="LC_COLLATE";break;
|
|
case CRTDLL_LC_CTYPE: categorystr="LC_CTYPE";break;
|
|
case CRTDLL_LC_MONETARY: categorystr="LC_MONETARY";break;
|
|
case CRTDLL_LC_NUMERIC: categorystr="LC_NUMERIC";break;
|
|
case CRTDLL_LC_TIME: categorystr="LC_TIME";break;
|
|
default: categorystr = "UNKNOWN?";break;
|
|
}
|
|
FIXME(crtdll,"(%s,%s),stub!\n",categorystr,locale);
|
|
return "C";
|
|
}
|
|
|
|
/*********************************************************************
|
|
* wcscat (CRTDLL.503)
|
|
*/
|
|
LPWSTR __cdecl CRTDLL_wcscat( LPWSTR s1, LPCWSTR s2 )
|
|
{
|
|
return lstrcat32W( s1, s2 );
|
|
}
|
|
|
|
/*********************************************************************
|
|
* wcschr (CRTDLL.504)
|
|
*/
|
|
LPWSTR __cdecl CRTDLL_wcschr(LPCWSTR str,WCHAR xchar)
|
|
{
|
|
LPCWSTR s;
|
|
|
|
s=str;
|
|
do {
|
|
if (*s==xchar)
|
|
return (LPWSTR)s;
|
|
} while (*s++);
|
|
return NULL;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* wcscmp (CRTDLL.505)
|
|
*/
|
|
INT32 __cdecl CRTDLL_wcscmp( LPCWSTR s1, LPCWSTR s2 )
|
|
{
|
|
return lstrcmp32W( s1, s2 );
|
|
}
|
|
|
|
/*********************************************************************
|
|
* wcscpy (CRTDLL.507)
|
|
*/
|
|
LPWSTR __cdecl CRTDLL_wcscpy( LPWSTR s1, LPCWSTR s2 )
|
|
{
|
|
return lstrcpy32W( s1, s2 );
|
|
}
|
|
|
|
/*********************************************************************
|
|
* wcscspn (CRTDLL.508)
|
|
*/
|
|
INT32 __cdecl CRTDLL_wcscspn(LPWSTR str,LPWSTR reject)
|
|
{
|
|
LPWSTR s,t;
|
|
|
|
s=str;
|
|
do {
|
|
t=reject;
|
|
while (*t) { if (*t==*s) break;t++;}
|
|
if (*t) break;
|
|
s++;
|
|
} while (*s);
|
|
return s-str; /* nr of wchars */
|
|
}
|
|
|
|
/*********************************************************************
|
|
* wcslen (CRTDLL.510)
|
|
*/
|
|
INT32 __cdecl CRTDLL_wcslen( LPCWSTR s )
|
|
{
|
|
return lstrlen32W( s );
|
|
}
|
|
|
|
/*********************************************************************
|
|
* wcsncat (CRTDLL.511)
|
|
*/
|
|
LPWSTR __cdecl CRTDLL_wcsncat( LPWSTR s1, LPCWSTR s2, INT32 n )
|
|
{
|
|
return lstrcatn32W( s1, s2, n );
|
|
}
|
|
|
|
/*********************************************************************
|
|
* wcsncmp (CRTDLL.512)
|
|
*/
|
|
INT32 __cdecl CRTDLL_wcsncmp( LPCWSTR s1, LPCWSTR s2, INT32 n )
|
|
{
|
|
return lstrncmp32W( s1, s2, n );
|
|
}
|
|
|
|
/*********************************************************************
|
|
* wcsncpy (CRTDLL.513)
|
|
*/
|
|
LPWSTR __cdecl CRTDLL_wcsncpy( LPWSTR s1, LPCWSTR s2, INT32 n )
|
|
{
|
|
return lstrcpyn32W( s1, s2, n );
|
|
}
|
|
|
|
/*********************************************************************
|
|
* wcsspn (CRTDLL.516)
|
|
*/
|
|
INT32 __cdecl CRTDLL_wcsspn(LPWSTR str,LPWSTR accept)
|
|
{
|
|
LPWSTR s,t;
|
|
|
|
s=str;
|
|
do {
|
|
t=accept;
|
|
while (*t) { if (*t==*s) break;t++;}
|
|
if (!*t) break;
|
|
s++;
|
|
} while (*s);
|
|
return s-str; /* nr of wchars */
|
|
}
|
|
|
|
/*********************************************************************
|
|
* _wcsicmp (CRTDLL.321)
|
|
*/
|
|
DWORD __cdecl CRTDLL__wcsicmp( LPCWSTR s1, LPCWSTR s2 )
|
|
{
|
|
return lstrcmpi32W( s1, s2 );
|
|
}
|
|
|
|
/*********************************************************************
|
|
* _wcsicoll (CRTDLL.322)
|
|
*/
|
|
DWORD __cdecl CRTDLL__wcsicoll(LPCWSTR a1,LPCWSTR a2)
|
|
{
|
|
/* FIXME: handle collates */
|
|
return lstrcmpi32W(a1,a2);
|
|
}
|
|
|
|
/*********************************************************************
|
|
* _wcsnicmp (CRTDLL.324)
|
|
*/
|
|
DWORD __cdecl CRTDLL__wcsnicmp( LPCWSTR s1, LPCWSTR s2, INT32 len )
|
|
{
|
|
return lstrncmpi32W( s1, s2, len );
|
|
}
|
|
|
|
/*********************************************************************
|
|
* wcscoll (CRTDLL.506)
|
|
*/
|
|
DWORD __cdecl CRTDLL_wcscoll(LPWSTR a1,LPWSTR a2)
|
|
{
|
|
/* FIXME: handle collates */
|
|
return lstrcmp32W(a1,a2);
|
|
}
|
|
|
|
/*********************************************************************
|
|
* _wcsrev (CRTDLL.326)
|
|
*/
|
|
VOID __cdecl CRTDLL__wcsrev(LPWSTR s) {
|
|
LPWSTR e;
|
|
|
|
e=s;
|
|
while (*e)
|
|
e++;
|
|
while (s<e) {
|
|
WCHAR a;
|
|
|
|
a=*s;*s=*e;*e=a;
|
|
s++;e--;
|
|
}
|
|
}
|
|
|
|
/*********************************************************************
|
|
* wcsstr (CRTDLL.517)
|
|
*/
|
|
LPWSTR __cdecl CRTDLL_wcsstr(LPWSTR s,LPWSTR b)
|
|
{
|
|
LPWSTR x,y,c;
|
|
|
|
x=s;
|
|
while (*x) {
|
|
if (*x==*b) {
|
|
y=x;c=b;
|
|
while (*y && *c && *y==*c) { c++;y++; }
|
|
if (!*c)
|
|
return x;
|
|
}
|
|
x++;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* wcstombs (CRTDLL.521)
|
|
*/
|
|
INT32 __cdecl CRTDLL_wcstombs( LPSTR dst, LPCWSTR src, INT32 len )
|
|
{
|
|
lstrcpynWtoA( dst, src, len );
|
|
return strlen(dst); /* FIXME: is this right? */
|
|
}
|
|
|
|
/*********************************************************************
|
|
* wcsrchr (CRTDLL.515)
|
|
*/
|
|
LPWSTR __cdecl CRTDLL_wcsrchr(LPWSTR str,WCHAR xchar)
|
|
{
|
|
LPWSTR s;
|
|
|
|
s=str+lstrlen32W(str);
|
|
do {
|
|
if (*s==xchar)
|
|
return s;
|
|
s--;
|
|
} while (s>=str);
|
|
return NULL;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* _setmode (CRTDLL.265)
|
|
* FIXME: At present we ignore the request to translate CR/LF to LF.
|
|
*
|
|
* We allways translate when we read with fgets, we never do with fread
|
|
*
|
|
*/
|
|
INT32 __cdecl CRTDLL__setmode( INT32 fh,INT32 mode)
|
|
{
|
|
/* FIXME */
|
|
#define O_TEXT 0x4000
|
|
#define O_BINARY 0x8000
|
|
|
|
FIXME(crtdll, "on fhandle %d mode %s, STUB.\n",
|
|
fh,(mode=O_TEXT)?"O_TEXT":
|
|
(mode=O_BINARY)?"O_BINARY":"UNKNOWN");
|
|
return -1;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* _fpreset (CRTDLL.107)
|
|
*/
|
|
VOID __cdecl CRTDLL__fpreset(void)
|
|
{
|
|
FIXME(crtdll," STUB.\n");
|
|
}
|
|
|
|
/*********************************************************************
|
|
* atexit (CRTDLL.345)
|
|
*/
|
|
INT32 __cdecl CRTDLL_atexit(LPVOID x)
|
|
{
|
|
FIXME(crtdll,"(%p), STUB.\n",x);
|
|
return 0; /* successful */
|
|
}
|
|
|
|
/*********************************************************************
|
|
* mblen (CRTDLL.428)
|
|
* FIXME: check multibyte support
|
|
*/
|
|
WCHAR __cdecl CRTDLL_mblen(CHAR *mb,INT32 size)
|
|
{
|
|
|
|
int ret=1;
|
|
|
|
if (!mb)
|
|
ret = 0;
|
|
else if ((size<1)||(!*(mb+1)))
|
|
ret = -1;
|
|
else if (!(*mb))
|
|
ret =0;
|
|
|
|
TRACE(crtdll,"CRTDLL_mlen %s for max %d bytes ret %d\n",mb,size,ret);
|
|
|
|
return ret;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* mbstowcs (CRTDLL.429)
|
|
* FIXME: check multibyte support
|
|
*/
|
|
INT32 __cdecl CRTDLL_mbstowcs(LPWSTR wcs, LPCSTR mbs, INT32 size)
|
|
{
|
|
|
|
/* Slightly modified lstrcpynAtoW functions from memory/strings.c
|
|
* We need the number of characters transfered
|
|
* FIXME: No multibyte support yet
|
|
*/
|
|
|
|
LPWSTR p = wcs;
|
|
LPCSTR src= mbs;
|
|
int ret, n=size;
|
|
|
|
while ((n-- > 0) && *src) {
|
|
*p++ = (WCHAR)(unsigned char)*src++;
|
|
}
|
|
p++;
|
|
ret = (p -wcs);
|
|
|
|
TRACE(crtdll,"CRTDLL_mbstowcs %s for %d chars put %d wchars\n",
|
|
mbs,size,ret);
|
|
return ret;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* mbtowc (CRTDLL.430)
|
|
* FIXME: check multibyte support
|
|
*/
|
|
WCHAR __cdecl CRTDLL_mbtowc(WCHAR* wc,CHAR* mb,INT32 size)
|
|
{
|
|
int ret;
|
|
|
|
if (!mb)
|
|
ret = 0;
|
|
else if (!wc)
|
|
ret =-1;
|
|
else
|
|
if ( (ret = mblen(mb,size)) != -1 )
|
|
{
|
|
if (ret <= sizeof(char))
|
|
*wc = (WCHAR) ((unsigned char)*mb);
|
|
else
|
|
ret= -1;
|
|
}
|
|
else
|
|
ret = -1;
|
|
|
|
TRACE(crtdll,"CRTDLL_mbtowc %s for %d chars\n",mb,size);
|
|
|
|
return ret;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* _isctype (CRTDLL.138)
|
|
*/
|
|
BOOL32 __cdecl CRTDLL__isctype(CHAR x,CHAR type)
|
|
{
|
|
if ((type & CRTDLL_SPACE) && isspace(x))
|
|
return TRUE;
|
|
if ((type & CRTDLL_PUNCT) && ispunct(x))
|
|
return TRUE;
|
|
if ((type & CRTDLL_LOWER) && islower(x))
|
|
return TRUE;
|
|
if ((type & CRTDLL_UPPER) && isupper(x))
|
|
return TRUE;
|
|
if ((type & CRTDLL_ALPHA) && isalpha(x))
|
|
return TRUE;
|
|
if ((type & CRTDLL_DIGIT) && isdigit(x))
|
|
return TRUE;
|
|
if ((type & CRTDLL_CONTROL) && iscntrl(x))
|
|
return TRUE;
|
|
/* check CRTDLL_LEADBYTE */
|
|
return FALSE;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* _chdrive (CRTDLL.52)
|
|
*
|
|
* newdir [I] drive to change to, A=1
|
|
*
|
|
*/
|
|
BOOL32 __cdecl CRTDLL__chdrive(INT32 newdrive)
|
|
{
|
|
/* FIXME: generates errnos */
|
|
return DRIVE_SetCurrentDrive(newdrive-1);
|
|
}
|
|
|
|
/*********************************************************************
|
|
* _chdir (CRTDLL.51)
|
|
*/
|
|
INT32 __cdecl CRTDLL__chdir(LPCSTR newdir)
|
|
{
|
|
if (!SetCurrentDirectory32A(newdir))
|
|
return 1;
|
|
return 0;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* _fullpath (CRTDLL.114)
|
|
*/
|
|
LPSTR __cdecl CRTDLL__fullpath(LPSTR buf, LPCSTR name, INT32 size)
|
|
{
|
|
DOS_FULL_NAME full_name;
|
|
|
|
if (!buf)
|
|
{
|
|
size = 256;
|
|
if(!(buf = CRTDLL_malloc(size))) return NULL;
|
|
}
|
|
if (!DOSFS_GetFullName( name, FALSE, &full_name )) return NULL;
|
|
lstrcpyn32A(buf,full_name.short_name,size);
|
|
TRACE(crtdll,"CRTDLL_fullpath got %s\n",buf);
|
|
return buf;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* _splitpath (CRTDLL.279)
|
|
*/
|
|
VOID __cdecl CRTDLL__splitpath(LPCSTR path, LPSTR drive, LPSTR directory, LPSTR filename, LPSTR extension )
|
|
{
|
|
/* drive includes :
|
|
directory includes leading and trailing (forward and backward slashes)
|
|
filename without dot and slashes
|
|
extension with leading dot
|
|
*/
|
|
char * drivechar,*dirchar,*namechar;
|
|
|
|
TRACE(crtdll,"CRTDLL__splitpath got %s\n",path);
|
|
|
|
drivechar = strchr(path,':');
|
|
dirchar = strrchr(path,'/');
|
|
namechar = strrchr(path,'\\');
|
|
dirchar = MAX(dirchar,namechar);
|
|
if (dirchar)
|
|
namechar = strrchr(dirchar,'.');
|
|
else
|
|
namechar = strrchr(path,'.');
|
|
|
|
|
|
if (drive)
|
|
{
|
|
*drive = NULL;
|
|
if (drivechar)
|
|
{
|
|
strncat(drive,path,drivechar-path+1);
|
|
path = drivechar+1;
|
|
}
|
|
}
|
|
if (directory)
|
|
{
|
|
*directory = NULL;
|
|
if (dirchar)
|
|
{
|
|
strncat(directory,path,dirchar-path+1);
|
|
path = dirchar+1;
|
|
}
|
|
}
|
|
if (filename)
|
|
{
|
|
*filename = NULL;
|
|
if (namechar)
|
|
{
|
|
strncat(filename,path,namechar-path);
|
|
if (extension)
|
|
{
|
|
*extension = NULL;
|
|
strcat(extension,namechar);
|
|
}
|
|
}
|
|
}
|
|
|
|
TRACE(crtdll,"CRTDLL__splitpath found %s %s %s %s\n",drive,directory,filename,extension);
|
|
|
|
}
|
|
|
|
/*********************************************************************
|
|
* _getcwd (CRTDLL.120)
|
|
*/
|
|
CHAR* __cdecl CRTDLL__getcwd(LPSTR buf, INT32 size)
|
|
{
|
|
char test[1];
|
|
int len;
|
|
|
|
len = size;
|
|
if (!buf) {
|
|
if (size < 0) /* allocate as big as nescessary */
|
|
len =GetCurrentDirectory32A(1,test) + 1;
|
|
if(!(buf = CRTDLL_malloc(len)))
|
|
{
|
|
/* set error to OutOfRange */
|
|
return( NULL );
|
|
}
|
|
}
|
|
size = len;
|
|
if(!(len =GetCurrentDirectory32A(len,buf)))
|
|
{
|
|
return NULL;
|
|
}
|
|
if (len > size)
|
|
{
|
|
/* set error to ERANGE */
|
|
TRACE(crtdll,"CRTDLL_getcwd buffer to small\n");
|
|
return NULL;
|
|
}
|
|
return buf;
|
|
|
|
}
|
|
|
|
/*********************************************************************
|
|
* _getdrive (CRTDLL.124)
|
|
*
|
|
* Return current drive, 1 for A, 2 for B
|
|
*/
|
|
INT32 __cdecl CRTDLL__getdrive(VOID)
|
|
{
|
|
return DRIVE_GetCurrentDrive() + 1;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* _mkdir (CRTDLL.234)
|
|
*/
|
|
INT32 __cdecl CRTDLL__mkdir(LPCSTR newdir)
|
|
{
|
|
if (!CreateDirectory32A(newdir,NULL))
|
|
return -1;
|
|
return 0;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* _errno (CRTDLL.52)
|
|
* Yes, this is a function.
|
|
*/
|
|
LPINT32 __cdecl CRTDLL__errno()
|
|
{
|
|
static int crtdllerrno;
|
|
|
|
/* FIXME: we should set the error at the failing function call time */
|
|
crtdllerrno = LastErrorToErrno(GetLastError());
|
|
return &crtdllerrno;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* _tempnam (CRTDLL.305)
|
|
*
|
|
*/
|
|
LPSTR __cdecl CRTDLL__tempnam(LPCSTR dir, LPCSTR prefix)
|
|
{
|
|
|
|
char *ret;
|
|
DOS_FULL_NAME tempname;
|
|
|
|
if ((ret = tempnam(dir,prefix))==NULL) {
|
|
WARN(crtdll, "Unable to get unique filename\n");
|
|
return NULL;
|
|
}
|
|
if (!DOSFS_GetFullName(ret,FALSE,&tempname))
|
|
{
|
|
TRACE(crtdll, "Wrong path?\n");
|
|
return NULL;
|
|
}
|
|
free(ret);
|
|
if ((ret = CRTDLL_malloc(strlen(tempname.short_name)+1)) == NULL) {
|
|
WARN(crtdll, "CRTDL_malloc for shortname failed\n");
|
|
return NULL;
|
|
}
|
|
if ((ret = strcpy(ret,tempname.short_name)) == NULL) {
|
|
WARN(crtdll, "Malloc for shortname failed\n");
|
|
return NULL;
|
|
}
|
|
|
|
TRACE(crtdll,"dir %s prefix %s got %s\n",
|
|
dir,prefix,ret);
|
|
return ret;
|
|
|
|
}
|
|
/*********************************************************************
|
|
* tmpnam (CRTDLL.490)
|
|
*
|
|
* lcclnk from lcc-win32 relies on a terminating dot in the name returned
|
|
*
|
|
*/
|
|
LPSTR __cdecl CRTDLL_tmpnam(LPSTR s)
|
|
{
|
|
char *ret;
|
|
|
|
if ((ret =tmpnam(s))== NULL) {
|
|
WARN(crtdll, "Unable to get unique filename\n");
|
|
return NULL;
|
|
}
|
|
if (!DOSFS_GetFullName(ret,FALSE,&CRTDLL_tmpname))
|
|
{
|
|
TRACE(crtdll, "Wrong path?\n");
|
|
return NULL;
|
|
}
|
|
strcat(CRTDLL_tmpname.short_name,".");
|
|
TRACE(crtdll,"for buf %p got %s\n",
|
|
s,CRTDLL_tmpname.short_name);
|
|
TRACE(crtdll,"long got %s\n",
|
|
CRTDLL_tmpname.long_name);
|
|
if ( s != NULL)
|
|
return strcpy(s,CRTDLL_tmpname.short_name);
|
|
else
|
|
return CRTDLL_tmpname.short_name;
|
|
|
|
}
|
|
|
|
/*********************************************************************
|
|
* _itoa (CRTDLL.165)
|
|
*/
|
|
LPSTR __cdecl CRTDLL__itoa(INT32 x,LPSTR buf,INT32 buflen)
|
|
{
|
|
wsnprintf32A(buf,buflen,"%d",x);
|
|
return buf;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* _ltoa (CRTDLL.180)
|
|
*/
|
|
LPSTR __cdecl CRTDLL__ltoa(long x,LPSTR buf,INT32 radix)
|
|
{
|
|
switch(radix) {
|
|
case 2: FIXME(crtdll, "binary format not implemented !\n");
|
|
break;
|
|
case 8: wsnprintf32A(buf,0x80,"%o",x);
|
|
break;
|
|
case 10: wsnprintf32A(buf,0x80,"%d",x);
|
|
break;
|
|
case 16: wsnprintf32A(buf,0x80,"%x",x);
|
|
break;
|
|
default: FIXME(crtdll, "radix %d not implemented !\n", radix);
|
|
}
|
|
return buf;
|
|
}
|
|
|
|
typedef VOID (*sig_handler_type)(VOID);
|
|
|
|
/*********************************************************************
|
|
* signal (CRTDLL.455)
|
|
*/
|
|
VOID __cdecl CRTDLL_signal(int sig, sig_handler_type ptr)
|
|
{
|
|
FIXME(crtdll, "(%d %p):stub.\n", sig, ptr);
|
|
}
|
|
|
|
/*********************************************************************
|
|
* _ftol (CRTDLL.113)
|
|
*/
|
|
LONG __cdecl CRTDLL__ftol(double fl) {
|
|
return (LONG)fl;
|
|
}
|
|
/*********************************************************************
|
|
* _sleep (CRTDLL.267)
|
|
*/
|
|
VOID __cdecl CRTDLL__sleep(unsigned long timeout)
|
|
{
|
|
TRACE(crtdll,"CRTDLL__sleep for %ld milliseconds\n",timeout);
|
|
Sleep((timeout)?timeout:1);
|
|
}
|
|
|
|
/*********************************************************************
|
|
* getenv (CRTDLL.437)
|
|
*/
|
|
LPSTR __cdecl CRTDLL_getenv(const char *name)
|
|
{
|
|
LPSTR environ = GetEnvironmentStrings32A();
|
|
LPSTR pp,pos = NULL;
|
|
unsigned int length;
|
|
|
|
for (pp = environ; (*pp); pp = pp + strlen(pp) +1)
|
|
{
|
|
pos =strchr(pp,'=');
|
|
if (pos)
|
|
length = pos -pp;
|
|
else
|
|
length = strlen(pp);
|
|
if (!strncmp(pp,name,length)) break;
|
|
}
|
|
if ((pp)&& (pos))
|
|
{
|
|
pp = pos+1;
|
|
TRACE(crtdll,"got %s\n",pp);
|
|
}
|
|
FreeEnvironmentStrings32A( environ );
|
|
return pp;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* _mbsrchr (CRTDLL.223)
|
|
*/
|
|
LPSTR __cdecl CRTDLL__mbsrchr(LPSTR s,CHAR x) {
|
|
/* FIXME: handle multibyte strings */
|
|
return strrchr(s,x);
|
|
}
|
|
|
|
/*********************************************************************
|
|
* _memicmp (CRTDLL.233)(NTDLL.868)
|
|
* A stringcompare, without \0 check
|
|
* RETURNS
|
|
* -1:if first string is alphabetically before second string
|
|
* 1:if second '' '' '' '' first ''
|
|
* 0:if both are equal.
|
|
*/
|
|
INT32 __cdecl CRTDLL__memicmp(
|
|
LPCSTR s1, /* [in] first string */
|
|
LPCSTR s2, /* [in] second string */
|
|
DWORD len /* [in] length to compare */
|
|
) {
|
|
int i;
|
|
|
|
for (i=0;i<len;i++) {
|
|
if (tolower(s1[i])<tolower(s2[i]))
|
|
return -1;
|
|
if (tolower(s1[i])>tolower(s2[i]))
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|
|
/*********************************************************************
|
|
* __dllonexit (CRTDLL.25)
|
|
*/
|
|
VOID __cdecl CRTDLL__dllonexit ()
|
|
{ FIXME(crtdll,"stub\n");
|
|
}
|