build msvcrt and crtdll from same source via lib\crt

fix problem with scanf/printf reading/printing doubles

svn path=/trunk/; revision=13340
This commit is contained in:
Gunnar Dalsnes 2005-01-27 21:16:41 +00:00
parent 60d9e9aa67
commit b9d18ec3d7
389 changed files with 15 additions and 27905 deletions

View file

@ -15,9 +15,9 @@ TARGET_BASE = $(TARGET_BASE_LIB_MSVCRT)
# don't remove @nn from exported symbols - needed so dlltool doesn't mess up mangled c++ exports
RM_AT_FROM_SYMBOLS = no
TARGET_LFLAGS = -nostartfiles --enable-stdcall-fixup
TARGET_LFLAGS = -nostartfiles -nostdlib --enable-stdcall-fixup
TARGET_SDKLIBS = wine.a string.a kernel32.a ntdll.a
TARGET_SDKLIBS = crt.a string.a kernel32.a ntdll.a wine.a
TARGET_GCCLIBS = gcc
@ -35,472 +35,16 @@ TARGET_CFLAGS += \
TARGET_OBJECTS = $(TARGET_NAME).o
TARGET_CLEAN = \
conio/*.o \
ctype/*.o \
direct/*.o \
except/*.o \
float/*.o \
io/*.o \
locale/*.o \
math/*.o \
mbstring/*.o \
misc/*.o \
process/*.o \
search/*.o \
setjmp/*.o \
setjmp/i386/*.o \
signal/*.o \
stdio/*.o \
stdlib/*.o \
string/*.o \
sys_stat/*.o \
time/*.o \
wine/*.o \
wstring/*.o
TARGET_CLEAN = dllmain.o
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
CONIO_OBJECTS = \
conio/cgets.o \
conio/cprintf.o \
conio/cputs.o \
conio/cscanf.o \
conio/getch.o \
conio/getche.o \
conio/kbhit.o \
conio/putch.o \
conio/ungetch.o
CTYPE_OBJECTS = \
ctype/ctype.o \
ctype/isalnum.o \
ctype/isalpha.o \
ctype/isascii.o \
ctype/iscntrl.o \
ctype/isdigit.o \
ctype/isgraph.o \
ctype/islower.o \
ctype/isprint.o \
ctype/ispunct.o \
ctype/isspace.o \
ctype/isupper.o \
ctype/isxdigit.o \
ctype/toascii.o \
ctype/tolower.o \
ctype/toupper.o \
ctype/iscsym.o \
ctype/isctype.o
DIRECT_OBJECTS = \
direct/chdir.o \
direct/chdrive.o \
direct/getcwd.o \
direct/getdcwd.o \
direct/getdfree.o \
direct/getdrive.o \
direct/mkdir.o \
direct/rmdir.o \
direct/wchdir.o \
direct/wgetcwd.o \
direct/wgetdcwd.o \
direct/wmkdir.o \
direct/wrmdir.o
EXCEPT_OBJECTS = \
except/seh.o \
except/abnorter.o \
except/exhand2.o \
except/matherr.o \
except/unwind.o \
except/xcptfil.o
FLOAT_OBJECTS = \
float/chgsign.o \
float/clearfp.o \
float/cntrlfp.o \
float/copysign.o \
float/fpclass.o \
float/fpecode.o \
float/fpreset.o \
float/isnan.o \
float/logb.o \
float/nafter.o \
float/scalb.o \
float/statfp.o
IO_OBJECTS = \
io/access.o \
io/chmod.o \
io/chsize.o \
io/close.o \
io/commit.o \
io/create.o \
io/dup.o \
io/dup2.o \
io/eof.o \
io/filelen.o \
io/fileleni.o \
io/find.o \
io/fmode.o \
io/isatty.o \
io/locking.o \
io/lseek.o \
io/lseeki64.o \
io/mktemp.o \
io/open.o \
io/pipe.o \
io/read.o \
io/setmode.o \
io/sopen.o \
io/stubs.o \
io/tell.o \
io/telli64.o \
io/umask.o \
io/unlink.o \
io/utime.o \
io/waccess.o \
io/wchmod.o \
io/wcreate.o \
io/wfind.o \
io/wmktemp.o \
io/wopen.o \
io/write.o \
io/wunlink.o \
io/wutime.o
LOCALE_OBJECTS = \
locale/locale.o
MATH_OBJECTS = \
math/acos.o \
math/adjust.o \
math/asin.o \
math/atan.o \
math/atan2.o \
math/cabs.o \
math/ceil.o \
math/cos.o \
math/cosh.o \
math/exp.o \
math/fabs.o \
math/floor.o \
math/fmod.o \
math/frexp.o \
math/huge_val.o \
math/hypot.o \
math/j0_y0.o \
math/j1_y1.o \
math/jn_yn.o \
math/ldexp.o \
math/log.o \
math/log10.o \
math/modf.o \
math/pow.o \
math/sin.o \
math/sinh.o \
math/sqrt.o \
math/stubs.o \
math/tan.o \
math/tanh.o
MBSTRING_OBJECTS = \
mbstring/hanzen.o \
mbstring/ischira.o \
mbstring/iskana.o \
mbstring/iskpun.o \
mbstring/islead.o \
mbstring/islwr.o \
mbstring/ismbal.o \
mbstring/ismbaln.o \
mbstring/ismbc.o \
mbstring/ismbgra.o \
mbstring/ismbkaln.o \
mbstring/ismblead.o \
mbstring/ismbpri.o \
mbstring/ismbpun.o \
mbstring/ismbtrl.o \
mbstring/isuppr.o \
mbstring/jistojms.o \
mbstring/jmstojis.o \
mbstring/mbbtype.o \
mbstring/mbccpy.o \
mbstring/mbclen.o \
mbstring/mbscat.o \
mbstring/mbschr.o \
mbstring/mbscmp.o \
mbstring/mbscoll.o \
mbstring/mbscpy.o \
mbstring/mbscspn.o \
mbstring/mbsdec.o \
mbstring/mbsdup.o \
mbstring/mbsicmp.o \
mbstring/mbsicoll.o \
mbstring/mbsinc.o \
mbstring/mbslen.o \
mbstring/mbslwr.o \
mbstring/mbsncat.o \
mbstring/mbsnccnt.o \
mbstring/mbsncmp.o \
mbstring/mbsncoll.o \
mbstring/mbsncpy.o \
mbstring/mbsnextc.o \
mbstring/mbsnicmp.o \
mbstring/mbsnicoll.o \
mbstring/mbsninc.o \
mbstring/mbsnset.o \
mbstring/mbspbrk.o \
mbstring/mbsrchr.o \
mbstring/mbsrev.o \
mbstring/mbsset.o \
mbstring/mbsspn.o \
mbstring/mbsspnp.o \
mbstring/mbsstr.o \
mbstring/mbstok.o \
mbstring/mbstrlen.o \
mbstring/mbsupr.o
MISC_OBJECTS = \
misc/amsg.o \
misc/assert.o \
misc/crtmain.o \
misc/dllmain.o \
misc/environ.o \
misc/getargs.o \
misc/initterm.o \
misc/lock.o \
misc/purecall.o \
misc/stubs.o \
misc/tls.o
PROCESS_OBJECTS = \
process/_cwait.o \
process/_system.o \
process/dll.o \
process/process.o \
process/procid.o \
process/thread.o \
process/threadid.o \
process/threadx.o
SEARCH_OBJECTS = \
search/lfind.o \
search/lsearch.o
SETJMP_OBJECTS = \
setjmp/i386/setjmp.o
SIGNAL_OBJECTS = \
signal/signal.o
STDIO_OBJECTS = \
stdio/allocfil.o \
stdio/clearerr.o \
stdio/fclose.o \
stdio/fdopen.o \
stdio/feof.o \
stdio/ferror.o \
stdio/fflush.o \
stdio/fgetc.o \
stdio/fgetchar.o \
stdio/fgetpos.o \
stdio/fgets.o \
stdio/fgetws.o \
stdio/filbuf.o \
stdio/fileno.o \
stdio/flsbuf.o \
stdio/fopen.o \
stdio/fprintf.o \
stdio/fputc.o \
stdio/fputchar.o \
stdio/fputs.o \
stdio/fread.o \
stdio/freopen.o \
stdio/fscanf.o \
stdio/fseek.o \
stdio/fsetpos.o \
stdio/fsopen.o \
stdio/ftell.o \
stdio/fwalk.o \
stdio/fwrite.o \
stdio/getc.o \
stdio/getchar.o \
stdio/gets.o \
stdio/getw.o \
stdio/perror.o \
stdio/popen.o \
stdio/printf.o \
stdio/putc.o \
stdio/putchar.o \
stdio/puts.o \
stdio/putw.o \
stdio/remove.o \
stdio/rename.o \
stdio/rewind.o \
stdio/rmtmp.o \
stdio/scanf.o \
stdio/setbuf.o \
stdio/setvbuf.o \
stdio/sprintf.o \
stdio/sscanf.o \
stdio/stdhnd.o \
stdio/tempnam.o \
stdio/tmpfile.o \
stdio/tmpnam.o \
stdio/ungetc.o \
stdio/vfprintf.o \
stdio/vfscanf.o \
stdio/vfwprint.o \
stdio/vprintf.o \
stdio/vscanf.o \
stdio/vsprintf.o \
stdio/vsscanf.o \
stdio/wfdopen.o \
stdio/wrename.o \
stdio/wtempnam.o \
stdio/wtmpnam.o
STDLIB_OBJECTS = \
stdlib/_exit.o \
stdlib/abort.o \
stdlib/abs.o \
stdlib/atexit.o \
stdlib/atof.o \
stdlib/atoi.o \
stdlib/atoi64.o \
stdlib/atol.o \
stdlib/bsearch.o \
stdlib/div.o \
stdlib/ecvt.o \
stdlib/ecvtbuf.o \
stdlib/errno.o \
stdlib/fcvt.o \
stdlib/fcvtbuf.o \
stdlib/fullpath.o \
stdlib/gcvt.o \
stdlib/getenv.o \
stdlib/itoa.o \
stdlib/itow.o \
stdlib/labs.o \
stdlib/ldiv.o \
stdlib/makepath.o \
stdlib/malloc.o \
stdlib/mbstowcs.o \
stdlib/mbtowc.o \
stdlib/obsol.o \
stdlib/putenv.o \
stdlib/qsort.o \
stdlib/rand.o \
stdlib/rot.o \
stdlib/senv.o \
stdlib/splitp.o \
stdlib/strtod.o \
stdlib/strtol.o \
stdlib/strtoul.o \
stdlib/swab.o \
stdlib/wcstod.o \
stdlib/wcstol.o \
stdlib/wcstombs.o \
stdlib/wcstoul.o \
stdlib/wctomb.o \
stdlib/wfulpath.o \
stdlib/witoa.o \
stdlib/witow.o \
stdlib/wputenv.o \
stdlib/wsenv.o \
stdlib/wsplitp.o \
stdlib/wmakpath.o \
stdlib/wtoi.o \
stdlib/wtoi64.o
STRING_OBJECTS = \
string/lasttok.o \
string/memicmp.o \
string/strcoll.o \
string/strdup.o \
string/strerror.o \
string/stricmp.o \
string/strlwr.o \
string/strncoll.o \
string/strnicmp.o \
string/strpbrk.o \
string/strrev.o\
string/strset.o \
string/strstr.o \
string/strtok.o \
string/strupr.o \
string/strxfrm.o
SYS_STAT_OBJECTS = \
sys_stat/fstat.o \
sys_stat/fstati64.o \
sys_stat/futime.o \
sys_stat/stat.o \
sys_stat/wstat.o
TIME_OBJECTS = \
time/clock.o \
time/ctime.o \
time/difftime.o \
time/ftime.o \
time/strdate.o \
time/strftime.o \
time/strtime.o \
time/time.o \
time/tz_vars.o \
time/wctime.o \
time/wstrdate.o \
time/wstrtime.o
WINE_OBJECTS = \
wine/cpp.o \
wine/cppexcept.o \
wine/heap.o \
wine/thread.o
WSTRING_OBJECTS = \
wstring/wcscoll.o \
wstring/wcscspn.o \
wstring/wcsdup.o \
wstring/wcsicmp.o \
wstring/wcslwr.o \
wstring/wcsnicmp.o \
wstring/wcspbrk.o \
wstring/wcsrev.o \
wstring/wcsset.o \
wstring/wcsspn.o \
wstring/wcsstr.o \
wstring/wcstok.o \
wstring/wcsupr.o \
wstring/wcsxfrm.o \
wstring/wlasttok.o
OBJECTS = \
$(CONIO_OBJECTS) \
$(CTYPE_OBJECTS) \
$(DIRECT_OBJECTS) \
$(EXCEPT_OBJECTS) \
$(FLOAT_OBJECTS) \
$(IO_OBJECTS) \
$(LOCALE_OBJECTS) \
$(MATH_OBJECTS) \
$(MBSTRING_OBJECTS) \
$(MISC_OBJECTS) \
$(PROCESS_OBJECTS) \
$(SEARCH_OBJECTS) \
$(SETJMP_OBJECTS) \
$(SIGNAL_OBJECTS) \
$(STDIO_OBJECTS) \
$(STDLIB_OBJECTS) \
$(STRING_OBJECTS) \
$(SYS_STAT_OBJECTS) \
$(TIME_OBJECTS) \
$(WINE_OBJECTS) \
$(WSTRING_OBJECTS)
OBJECTS = dllmain.o
$(TARGET_NAME).o: $(OBJECTS)
$(LD) -r $(OBJECTS) -o $(TARGET_NAME).o

View file

@ -1,13 +0,0 @@
This file contains information about the status the MSVCRT runtime in ReactOS.
Please note that all of the MSVCRT.DLL runtime sources are license GPL unless
otherwise noted. The sources from WINE are dual licensed GPL/LGPL.
If you update a function in the ~/wine directory please send a patch to wine-patches@winehq.com
TODO List:
Implement the remaining functions that are commented out in the .def file
Update source code headers for the license information.
Compleate the W32API conversion for all source files.
Write a decent regression test suite.
Convert all C++ style comments to C style comments.
????

View file

@ -1,74 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: msvcrt/conio/cgets.c
* PURPOSE: C Runtime
* PROGRAMMER: Eric Kohl (Imported from DJGPP)
*/
#include <msvcrt/conio.h>
#include <msvcrt/stdlib.h>
/*
* @implemented
*/
char *_cgets(char *string)
{
unsigned len = 0;
unsigned int maxlen_wanted;
char *sp;
int c;
/*
* Be smart and check for NULL pointer.
* Don't know wether TURBOC does this.
*/
if (!string)
return(NULL);
maxlen_wanted = (unsigned int)((unsigned char)string[0]);
sp = &(string[2]);
/*
* Should the string be shorter maxlen_wanted including or excluding
* the trailing '\0' ? We don't take any risk.
*/
while(len < maxlen_wanted-1)
{
c=_getch();
/*
* shold we check for backspace here?
* TURBOC does (just checked) but doesn't in cscanf (thats harder
* or even impossible). We do the same.
*/
if (c == '\b')
{
if (len > 0)
{
_cputs("\b \b"); /* go back, clear char on screen with space
and go back again */
len--;
sp[len] = '\0'; /* clear the character in the string */
}
}
else if (c == '\r')
{
sp[len] = '\0';
break;
}
else if (c == 0)
{
/* special character ends input */
sp[len] = '\0';
_ungetch(c); /* keep the char for later processing */
break;
}
else
{
sp[len] = _putch(c);
len++;
}
}
sp[maxlen_wanted-1] = '\0';
string[1] = (char)((unsigned char)len);
return(sp);
}

View file

@ -1,28 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: msvcrt/conio/cprintf.c
* PURPOSE: C Runtime
* PROGRAMMER: Eric Kohl (Imported from DJGPP)
*/
#include <msvcrt/stdio.h>
#include <msvcrt/conio.h>
/*
* @unimplemented
*/
int
_cprintf(const char *fmt, ...)
{
int cnt;
char buf[ 2048 ]; /* this is buggy, because buffer might be too small. */
va_list ap;
va_start(ap, fmt);
cnt = vsprintf(buf, fmt, ap);
va_end(ap);
_cputs(buf);
return cnt;
}

View file

@ -1,28 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/msvcrt/conio/cputs.c
* PURPOSE: Writes a character to stdout
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include "precomp.h"
#include <msvcrt/conio.h>
#include <msvcrt/string.h>
#include <msvcrt/stdio.h>
#include <msvcrt/internal/file.h>
/*
* @implemented
*/
int _cputs(const char *_str)
{
int len = strlen(_str);
DWORD written = 0;
if (!WriteFile(filehnd(stdout->_file),_str,len,&written,NULL))
return -1;
return 0;
}

View file

@ -1,29 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: msvcrt/conio/cscanf.c
* PURPOSE: C Runtime
* PROGRAMMER: Eric Kohl (Imported from DJGPP)
*/
#include <msvcrt/conio.h>
#include <msvcrt/stdarg.h>
#include <msvcrt/stdio.h>
#include <msvcrt/internal/stdio.h>
/*
* @unimplemented
*/
int _cscanf(char *fmt, ...)
{
int cnt;
va_list ap;
//fixme cscanf should scan the console's keyboard
va_start(ap, fmt);
cnt = __vscanf(fmt, ap);
va_end(ap);
return cnt;
}

View file

@ -1,54 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/msvcrt/conio/getch.c
* PURPOSE: Writes a character to stdout
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include "precomp.h"
#include <msvcrt/conio.h>
#include <msvcrt/stdio.h>
#include <msvcrt/io.h>
#include <msvcrt/internal/console.h>
/*
* @implemented
*/
int _getch(void)
{
DWORD NumberOfCharsRead = 0;
char c;
if (char_avail) {
c = ungot_char;
char_avail = 0;
} else {
ReadConsoleA(_get_osfhandle(stdin->_file),
&c,
1,
&NumberOfCharsRead,
NULL);
}
if (c == 10)
c = 13;
putchar(c);
return c;
}
#if 0
/*
* @unimplemented
*/
int _getche(void)
{
int c;
c = _getch();
_putch(c);
return c;
}
#endif

View file

@ -1,31 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details
* PROJECT: ReactOS system libraries
* FILE: lib/msvcrt/conio/getche.c
* PURPOSE: Reads a character from stdin
* PROGRAMER: DJ Delorie
Boudewijn Dekker
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include <msvcrt/conio.h>
#include <msvcrt/internal/console.h>
int getche(void)
{
if (char_avail)
/*
* We don't know, wether the ungot char was already echoed
* we assume yes (for example in cscanf, probably the only
* place where ungetch is ever called.
* There is no way to check for this really, because
* ungetch could have been called with a character that
* hasn't been got by a conio function.
* We don't echo again.
*/
return(getch());
return (_putch(getch()));
}

View file

@ -1,33 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/msvcrt/conio/kbhit.c
* PURPOSE: Checks for keyboard hits
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include "precomp.h"
#include <msvcrt/conio.h>
#include <msvcrt/internal/console.h>
/*
* FIXME PeekConsoleInput returns more than keyboard hits
*
* @unimplemented
*/
int _kbhit(void)
{
//INPUT_RECORD InputRecord;
DWORD NumberRead=0;
if (char_avail)
return(1);
else {
//FIXME PeekConsoleInput might do DeviceIo
//PeekConsoleInput((HANDLE)stdin->_file,&InputRecord,1,&NumberRead);
return NumberRead;
}
return 0;
}

View file

@ -1,25 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/msvcrt/conio/putch.c
* PURPOSE: Writes a character to stdout
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include "precomp.h"
#include <msvcrt/conio.h>
/*
* @implemented
*/
int _putch(int c)
{
DWORD NumberOfCharsWritten;
if (WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),&c,1,&NumberOfCharsWritten,NULL)) {
return -1;
}
return NumberOfCharsWritten;
}

View file

@ -1,32 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details
* PROJECT: ReactOS system libraries
* FILE: lib/msvcrt/conio/ungetch.c
* PURPOSE: Ungets a character from stdin
* PROGRAMER: DJ Delorie
Boudewijn Dekker [ Adapted from djgpp libc ]
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include <msvcrt/conio.h>
#include <msvcrt/internal/console.h>
#define EOF -1
int char_avail = 0;
int ungot_char = 0;
/*
* @implemented
*/
int _ungetch(int c)
{
if (char_avail)
return(EOF);
ungot_char = c;
char_avail = 1;
return(c);
}

View file

@ -1,271 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: msvcrt/ctype/ctype.c
* PURPOSE: C Runtime
* PROGRAMMER: Copyright (C) 1995 DJ Delorie
*/
#include <msvcrt/ctype.h>
unsigned short _ctype[] = {
0, /* <EOF>, 0xFFFF */
_CONTROL, /* CTRL+@, 0x00 */
_CONTROL, /* CTRL+A, 0x01 */
_CONTROL, /* CTRL+B, 0x02 */
_CONTROL, /* CTRL+C, 0x03 */
_CONTROL, /* CTRL+D, 0x04 */
_CONTROL, /* CTRL+E, 0x05 */
_CONTROL, /* CTRL+F, 0x06 */
_CONTROL, /* CTRL+G, 0x07 */
_CONTROL, /* CTRL+H, 0x08 */
_CONTROL | _SPACE, /* CTRL+I, 0x09 */
_CONTROL | _SPACE, /* CTRL+J, 0x0a */
_CONTROL | _SPACE, /* CTRL+K, 0x0b */
_CONTROL | _SPACE, /* CTRL+L, 0x0c */
_CONTROL | _SPACE, /* CTRL+M, 0x0d */
_CONTROL, /* CTRL+N, 0x0e */
_CONTROL, /* CTRL+O, 0x0f */
_CONTROL, /* CTRL+P, 0x10 */
_CONTROL, /* CTRL+Q, 0x11 */
_CONTROL, /* CTRL+R, 0x12 */
_CONTROL, /* CTRL+S, 0x13 */
_CONTROL, /* CTRL+T, 0x14 */
_CONTROL, /* CTRL+U, 0x15 */
_CONTROL, /* CTRL+V, 0x16 */
_CONTROL, /* CTRL+W, 0x17 */
_CONTROL, /* CTRL+X, 0x18 */
_CONTROL, /* CTRL+Y, 0x19 */
_CONTROL, /* CTRL+Z, 0x1a */
_CONTROL, /* CTRL+[, 0x1b */
_CONTROL, /* CTRL+\, 0x1c */
_CONTROL, /* CTRL+], 0x1d */
_CONTROL, /* CTRL+^, 0x1e */
_CONTROL, /* CTRL+_, 0x1f */
_SPACE | _BLANK, /* ` ', 0x20 */
_PUNCT, /* `!', 0x21 */
_PUNCT, /* 0x22 */
_PUNCT, /* `#', 0x23 */
_PUNCT, /* `$', 0x24 */
_PUNCT, /* `%', 0x25 */
_PUNCT, /* `&', 0x26 */
_PUNCT, /* 0x27 */
_PUNCT, /* `(', 0x28 */
_PUNCT, /* `)', 0x29 */
_PUNCT, /* `*', 0x2a */
_PUNCT, /* `+', 0x2b */
_PUNCT, /* `,', 0x2c */
_PUNCT, /* `-', 0x2d */
_PUNCT, /* `.', 0x2e */
_PUNCT, /* `/', 0x2f */
_DIGIT | _HEX, /* `0', 0x30 */
_DIGIT | _HEX, /* `1', 0x31 */
_DIGIT | _HEX, /* `2', 0x32 */
_DIGIT | _HEX, /* `3', 0x33 */
_DIGIT | _HEX, /* `4', 0x34 */
_DIGIT | _HEX, /* `5', 0x35 */
_DIGIT | _HEX, /* `6', 0x36 */
_DIGIT | _HEX, /* `7', 0x37 */
_DIGIT | _HEX, /* `8', 0x38 */
_DIGIT | _HEX, /* `9', 0x39 */
_PUNCT, /* `:', 0x3a */
_PUNCT, /* `;', 0x3b */
_PUNCT, /* `<', 0x3c */
_PUNCT, /* `=', 0x3d */
_PUNCT, /* `>', 0x3e */
_PUNCT, /* `?', 0x3f */
_PUNCT, /* `@', 0x40 */
_UPPER | _HEX, /* `A', 0x41 */
_UPPER | _HEX, /* `B', 0x42 */
_UPPER | _HEX, /* `C', 0x43 */
_UPPER | _HEX, /* `D', 0x44 */
_UPPER | _HEX, /* `E', 0x45 */
_UPPER | _HEX, /* `F', 0x46 */
_UPPER, /* `G', 0x47 */
_UPPER, /* `H', 0x48 */
_UPPER, /* `I', 0x49 */
_UPPER, /* `J', 0x4a */
_UPPER, /* `K', 0x4b */
_UPPER, /* `L', 0x4c */
_UPPER, /* `M', 0x4d */
_UPPER, /* `N', 0x4e */
_UPPER, /* `O', 0x4f */
_UPPER, /* `P', 0x50 */
_UPPER, /* `Q', 0x51 */
_UPPER, /* `R', 0x52 */
_UPPER, /* `S', 0x53 */
_UPPER, /* `T', 0x54 */
_UPPER, /* `U', 0x55 */
_UPPER, /* `V', 0x56 */
_UPPER, /* `W', 0x57 */
_UPPER, /* `X', 0x58 */
_UPPER, /* `Y', 0x59 */
_UPPER, /* `Z', 0x5a */
_PUNCT, /* `[', 0x5b */
_PUNCT, /* 0x5c */
_PUNCT, /* `]', 0x5d */
_PUNCT, /* `^', 0x5e */
_PUNCT, /* `_', 0x5f */
_PUNCT, /* 0x60 */
_LOWER | _HEX, /* `a', 0x61 */
_LOWER | _HEX, /* `b', 0x62 */
_LOWER | _HEX, /* `c', 0x63 */
_LOWER | _HEX, /* `d', 0x64 */
_LOWER | _HEX, /* `e', 0x65 */
_LOWER | _HEX, /* `f', 0x66 */
_LOWER, /* `g', 0x67 */
_LOWER, /* `h', 0x68 */
_LOWER, /* `i', 0x69 */
_LOWER, /* `j', 0x6a */
_LOWER, /* `k', 0x6b */
_LOWER, /* `l', 0x6c */
_LOWER, /* `m', 0x6d */
_LOWER, /* `n', 0x6e */
_LOWER, /* `o', 0x6f */
_LOWER, /* `p', 0x70 */
_LOWER, /* `q', 0x71 */
_LOWER, /* `r', 0x72 */
_LOWER, /* `s', 0x73 */
_LOWER, /* `t', 0x74 */
_LOWER, /* `u', 0x75 */
_LOWER, /* `v', 0x76 */
_LOWER, /* `w', 0x77 */
_LOWER, /* `x', 0x78 */
_LOWER, /* `y', 0x79 */
_LOWER, /* `z', 0x7a */
_PUNCT, /* `{', 0x7b */
_PUNCT, /* `|', 0x7c */
_PUNCT, /* `}', 0x7d */
_PUNCT, /* `~', 0x7e */
_CONTROL, /* 0x7f */
0, /* 0x80 */
0, /* 0x81 */
0, /* 0x82 */
0, /* 0x83 */
0, /* 0x84 */
0, /* 0x85 */
0, /* 0x86 */
0, /* 0x87 */
0, /* 0x88 */
0, /* 0x89 */
0, /* 0x8a */
0, /* 0x8b */
0, /* 0x8c */
0, /* 0x8d */
0, /* 0x8e */
0, /* 0x8f */
0, /* 0x90 */
0, /* 0x91 */
0, /* 0x92 */
0, /* 0x93 */
0, /* 0x94 */
0, /* 0x95 */
0, /* 0x96 */
0, /* 0x97 */
0, /* 0x98 */
0, /* 0x99 */
0, /* 0x9a */
0, /* 0x9b */
0, /* 0x9c */
0, /* 0x9d */
0, /* 0x9e */
0, /* 0x9f */
0, /* 0xa0 */
0, /* 0xa1 */
0, /* 0xa2 */
0, /* 0xa3 */
0, /* 0xa4 */
0, /* 0xa5 */
0, /* 0xa6 */
0, /* 0xa7 */
0, /* 0xa8 */
0, /* 0xa9 */
0, /* 0xaa */
0, /* 0xab */
0, /* 0xac */
0, /* 0xad */
0, /* 0xae */
0, /* 0xaf */
0, /* 0xb0 */
0, /* 0xb1 */
0, /* 0xb2 */
0, /* 0xb3 */
0, /* 0xb4 */
0, /* 0xb5 */
0, /* 0xb6 */
0, /* 0xb7 */
0, /* 0xb8 */
0, /* 0xb9 */
0, /* 0xba */
0, /* 0xbb */
0, /* 0xbc */
0, /* 0xbd */
0, /* 0xbe */
0, /* 0xbf */
0, /* 0xc0 */
0, /* 0xc1 */
0, /* 0xc2 */
0, /* 0xc3 */
0, /* 0xc4 */
0, /* 0xc5 */
0, /* 0xc6 */
0, /* 0xc7 */
0, /* 0xc8 */
0, /* 0xc9 */
0, /* 0xca */
0, /* 0xcb */
0, /* 0xcc */
0, /* 0xcd */
0, /* 0xce */
0, /* 0xcf */
0, /* 0xd0 */
0, /* 0xd1 */
0, /* 0xd2 */
0, /* 0xd3 */
0, /* 0xd4 */
0, /* 0xd5 */
0, /* 0xd6 */
0, /* 0xd7 */
0, /* 0xd8 */
0, /* 0xd9 */
0, /* 0xda */
0, /* 0xdb */
0, /* 0xdc */
0, /* 0xdd */
0, /* 0xde */
0, /* 0xdf */
0, /* 0xe0 */
0, /* 0xe1 */
0, /* 0xe2 */
0, /* 0xe3 */
0, /* 0xe4 */
0, /* 0xe5 */
0, /* 0xe6 */
0, /* 0xe7 */
0, /* 0xe8 */
0, /* 0xe9 */
0, /* 0xea */
0, /* 0xeb */
0, /* 0xec */
0, /* 0xed */
0, /* 0xee */
0, /* 0xef */
0, /* 0xf0 */
0, /* 0xf1 */
0, /* 0xf2 */
0, /* 0xf3 */
0, /* 0xf4 */
0, /* 0xf5 */
0, /* 0xf6 */
0, /* 0xf7 */
0, /* 0xf8 */
0, /* 0xf9 */
0, /* 0xfa */
0, /* 0xfb */
0, /* 0xfc */
0, /* 0xfd */
0, /* 0xfe */
0 /* 0xff */
};
/* EOF */

View file

@ -1,29 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/msvcrt/ctype/isalnum.c
* PURPOSE: Test for a alpha numeric character
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include <msvcrt/ctype.h>
#undef isalnum
/*
* @implemented
*/
int isalnum(int c)
{
return _isctype(c, _ALPHA | _DIGIT);
}
#undef iswalnum
/*
* @implemented
*/
int iswalnum(wint_t c)
{
return iswctype(c, _ALPHA | _DIGIT);
}

View file

@ -1,31 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/mscvrt/ctype/isalpha.c
* PURPOSE: Checks if a character is alphanumeric
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include <msvcrt/ctype.h>
#undef isalpha
/*
* @implemented
*/
int isalpha(int c)
{
return _isctype(c, _ALPHA);
}
#undef iswalpha
/*
* @implemented
*/
int iswalpha(wint_t c)
{
return iswctype(c, _ALPHA);
}

View file

@ -1,27 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/msvcrt/ctype/isascii.c
* PURPOSE: Checks if a character is ascii
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include <msvcrt/ctype.h>
/*
* @implemented
*/
int __isascii(int c)
{
return (!((c)&(~0x7f)));
}
/*
* @implemented
*/
int iswascii(wint_t c)
{
return __isascii(c);
}

View file

@ -1,27 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: msvcrt/ctype/iscntrl.c
* PURPOSE: C Runtime
* PROGRAMMER: Copyright (C) 1995 DJ Delorie
*/
#include <msvcrt/ctype.h>
#undef iscntrl
/*
* @implemented
*/
int iscntrl(int c)
{
return _isctype(c, _CONTROL);
}
#undef iswcntrl
/*
* @implemented
*/
int iswcntrl(wint_t c)
{
return iswctype(c, _CONTROL);
}

View file

@ -1,27 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/msvcrt/ctype/iscsym.c
* PURPOSE: Check for a valid characters in a c symbol
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include <msvcrt/ctype.h>
/*
* @implemented
*/
int __iscsymf(int c)
{
return (isalpha(c) || ( c == '_' )) ;
}
/*
* @implemented
*/
int __iscsym(int c)
{
return (isalnum(c) || ( c == '_' )) ;
}

View file

@ -1,60 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: msvcrt/ctype/isctype.c
* PURPOSE: C Runtime
* PROGRAMMER: Copyright (C) 1995 DJ Delorie
*/
#include <msvcrt/ctype.h>
extern unsigned short _ctype[];
unsigned short *_pctype = _ctype + 1;
unsigned short *_pwctype = _ctype + 1;
/*
* @implemented
*/
unsigned short **__p__pctype(void)
{
return &_pctype;
}
/*
* @implemented
*/
unsigned short **__p__pwctype(void)
{
return &_pwctype;
}
/*
* @implemented
*/
int _isctype(unsigned int c, int ctypeFlags)
{
return (_pctype[(unsigned char)(c & 0xFF)] & ctypeFlags);
}
/*
* @implemented
*/
int iswctype(wint_t wc, wctype_t wctypeFlags)
{
return (_pwctype[(unsigned char)(wc & 0xFF)] & wctypeFlags);
}
/*
* obsolete
*
* @implemented
*/
int is_wctype(wint_t wc, wctype_t wctypeFlags)
{
return (_pwctype[(unsigned char)(wc & 0xFF)] & wctypeFlags);
}
/* EOF */

View file

@ -1,28 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: msvcrt/ctype/isdigit.c
* PURPOSE: C Runtime
* PROGRAMMER: Copyright (C) 1995 DJ Delorie
*/
#include <msvcrt/ctype.h>
#undef isdigit
/*
* @implemented
*/
int isdigit(int c)
{
return _isctype(c, _DIGIT);
}
#undef iswdigit
/*
* @implemented
*/
int iswdigit(wint_t c)
{
return iswctype(c, _DIGIT);
}

View file

@ -1,27 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: msvcrt/ctype/isgraph.c
* PURPOSE: C Runtime
* PROGRAMMER: Copyright (C) 1995 DJ Delorie
*/
#include <msvcrt/ctype.h>
#undef isgraph
/*
* @implemented
*/
int isgraph(int c)
{
return _isctype(c,_PUNCT | _ALPHA | _DIGIT);
}
#undef iswgraph
/*
* @implemented
*/
int iswgraph(wint_t c)
{
return iswctype(c,_PUNCT | _ALPHA | _DIGIT);
}

View file

@ -1,27 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: msvcrt/ctype/islower.c
* PURPOSE: C Runtime
* PROGRAMMER: Copyright (C) 1995 DJ Delorie
*/
#include <msvcrt/ctype.h>
#undef islower
/*
* @implemented
*/
int islower(int c)
{
return _isctype(c, _LOWER);
}
/*
* @implemented
*/
int iswlower(wint_t c)
{
return iswctype(c, _LOWER);
}

View file

@ -1,26 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: msvcrt/ctype/isprint.c
* PURPOSE: C Runtime
* PROGRAMMER: Copyright (C) 1995 DJ Delorie
*/
#include <msvcrt/ctype.h>
#undef isprint
/*
* @implemented
*/
int isprint(int c)
{
return _isctype(c,_BLANK | _PUNCT | _ALPHA | _DIGIT);
}
/*
* @implemented
*/
int iswprint(wint_t c)
{
return iswctype((unsigned short)c,_BLANK | _PUNCT | _ALPHA | _DIGIT);
}

View file

@ -1,27 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: msvcrt/ctype/ispunct.c
* PURPOSE: C Runtime
* PROGRAMMER: Copyright (C) 1995 DJ Delorie
*/
#include <msvcrt/ctype.h>
#undef ispunct
/*
* @implemented
*/
int ispunct(int c)
{
return _isctype(c, _PUNCT);
}
#undef iswpunct
/*
* @implemented
*/
int iswpunct(wint_t c)
{
return iswctype(c, _PUNCT);
}

View file

@ -1,30 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/msvcrt/ctype/isspace.c
* PURPOSE: Test for a space character
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include <msvcrt/ctype.h>
#undef isspace
/*
* @implemented
*/
int isspace(int c)
{
return _isctype(c,_SPACE);
}
#undef iswspace
/*
* @implemented
*/
int iswspace(wint_t c)
{
return iswctype(c,_SPACE);
}

View file

@ -1,26 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: msvcrt/ctype/isupper.c
* PURPOSE: C Runtime
* PROGRAMMER: Copyright (C) 1995 DJ Delorie
*/
#include <msvcrt/ctype.h>
#undef isupper
/*
* @implemented
*/
int isupper(int c)
{
return _isctype(c, _UPPER);
}
/*
* @implemented
*/
int iswupper(wint_t c)
{
return iswctype(c, _UPPER);
}

View file

@ -1,28 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: msvcrt/ctype/isxdigit.c
* PURPOSE: C Runtime
* PROGRAMMER: Copyright (C) 1995 DJ Delorie
*/
#include <msvcrt/ctype.h>
#undef isxdigit
/*
* @implemented
*/
int isxdigit(int c)
{
return _isctype(c, _HEX);
}
#undef iswxdigit
/*
* @implemented
*/
int iswxdigit(wint_t c)
{
return iswctype(c, _HEX);
}

View file

@ -1,17 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: msvcrt/ctype/toascii.c
* PURPOSE: C Runtime
* PROGRAMMER: Copyright (C) 1995 DJ Delorie
*/
#include <msvcrt/ctype.h>
/*
* @implemented
*/
int __toascii(int c)
{
return((unsigned)(c) & 0x7F);
}

View file

@ -1,51 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: msvcrt/ctype/tolower.c
* PURPOSE: C Runtime
* PROGRAMMER: Copyright (C) 1995 DJ Delorie
*/
#include <msvcrt/ctype.h>
#undef tolower
/*
* @implemented
*/
int tolower(int c)
{
if (_isctype (c, _UPPER))
return (c - ('A' - 'a'));
return(c);
}
#undef towlower
/*
* @implemented
*/
wchar_t towlower(wchar_t c)
{
if (iswctype (c, _UPPER))
return (c - (L'A' - L'a'));
return(c);
}
/*
* @implemented
*/
int _tolower(int c)
{
return (c - ('A' - 'a'));
}
/*
int towlower(wint_t);
int towupper(wint_t);
wchar_t _towlower(wchar_t c)
{
return (c - (L'A' - L'a'));
}
*/

View file

@ -1,47 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: msvcrt/ctype/toupper.c
* PURPOSE: C Runtime
* PROGRAMMER: Copyright (C) 1995 DJ Delorie
*/
#include <msvcrt/ctype.h>
#undef toupper
/*
* @implemented
*/
int toupper(int c)
{
if (_isctype (c, _LOWER))
return (c + ('A' - 'a'));
return(c);
}
#undef towupper
/*
* @implemented
*/
wchar_t towupper(wchar_t c)
{
if (iswctype (c, _LOWER))
return (c + (L'A' - L'a'));
return(c);
}
/*
* @implemented
*/
int _toupper(int c)
{
return (c + ('A' - 'a'));
}
/*
wchar_t _towupper(wchar_t c)
{
return (c + (L'A' - L'a'));
}
*/

View file

@ -1,16 +0,0 @@
#include "precomp.h"
#include <msvcrt/ctype.h>
#include <msvcrt/direct.h>
#include <msvcrt/internal/file.h>
/*
* @implemented
*/
int _chdir(const char* _path)
{
if (!SetCurrentDirectoryA((char*)_path)) {
_dosmaperr(GetLastError());
return -1;
}
return 0;
}

View file

@ -1,34 +0,0 @@
#include "precomp.h"
#include <msvcrt/ctype.h>
#include <msvcrt/direct.h>
#include <msvcrt/stdlib.h>
#include <msvcrt/errno.h>
#include <msvcrt/internal/file.h>
int cur_drive = 0;
/*
* @implemented
*/
int _chdrive(int drive)
{
char d[3];
if (!( drive >= 1 && drive <= 26)) {
__set_errno(EINVAL);
return -1;
}
if (cur_drive != drive) {
cur_drive = drive;
d[0] = toupper(cur_drive + '@');
d[1] = ':';
d[2] = 0;
if (!SetCurrentDirectoryA(d)) {
_dosmaperr(GetLastError());
return -1;
}
}
return 0;
}

View file

@ -1,31 +0,0 @@
#include "precomp.h"
#include <msvcrt/direct.h>
#include <msvcrt/stdlib.h>
#include <msvcrt/errno.h>
#include <msvcrt/internal/file.h>
/*
* @implemented
*/
char *_getcwd(char* buffer, int maxlen)
{
char *cwd;
int len;
if (buffer == NULL) {
if ( (cwd = malloc(MAX_PATH)) == NULL ) {
__set_errno(ENOMEM);
return NULL;
}
len = MAX_PATH;
} else {
cwd = buffer;
len = maxlen;
}
if (GetCurrentDirectoryA(len, cwd) == 0) {
_dosmaperr(GetLastError());
return NULL;
}
return cwd;
}

View file

@ -1,27 +0,0 @@
#include "precomp.h"
#include <msvcrt/direct.h>
#include <msvcrt/internal/file.h>
/*
* @implemented
*/
char* _getdcwd(int nDrive, char* caBuffer, int nBufLen)
{
int i =0;
int dr = _getdrive();
if (nDrive < 1 || nDrive > 26)
return NULL;
if (dr != nDrive) {
if ( _chdrive(nDrive) != 0 )
return NULL;
}
i = GetCurrentDirectoryA(nBufLen, caBuffer);
if (i == nBufLen)
return NULL;
if (dr != nDrive) {
if ( _chdrive(dr) != 0 )
return NULL;
}
return caBuffer;
}

View file

@ -1,23 +0,0 @@
#include "precomp.h"
#include <msvcrt/ctype.h>
#include <msvcrt/direct.h>
/*
* @implemented
*/
unsigned int _getdiskfree(unsigned int _drive, struct _diskfree_t* _diskspace)
{
char RootPathName[10];
RootPathName[0] = toupper(_drive +'@');
RootPathName[1] = ':';
RootPathName[2] = '\\';
RootPathName[3] = 0;
if (_diskspace == NULL)
return 0;
if (!GetDiskFreeSpaceA(RootPathName,(LPDWORD)&_diskspace->sectors_per_cluster,(LPDWORD)&_diskspace->bytes_per_sector,
(LPDWORD )&_diskspace->avail_clusters,(LPDWORD )&_diskspace->total_clusters))
return 0;
return _diskspace->avail_clusters;
}

View file

@ -1,30 +0,0 @@
#include "precomp.h"
#include <msvcrt/ctype.h>
#include <msvcrt/direct.h>
extern int cur_drive;
/*
* @implemented
*/
int _getdrive(void)
{
char Buffer[MAX_PATH];
if (cur_drive == 0) {
GetCurrentDirectoryA(MAX_PATH, Buffer);
cur_drive = toupper(Buffer[0] - '@');
}
return cur_drive;
}
/*
* @unimplemented
*/
unsigned long _getdrives(void)
{
//fixme get logical drives
//return GetLogicalDrives();
return 5; // drive A and C
}

View file

@ -1,16 +0,0 @@
#include "precomp.h"
#include <msvcrt/direct.h>
#include <msvcrt/internal/file.h>
/*
* @implemented
*/
int _mkdir(const char* _path)
{
if (!CreateDirectoryA(_path, NULL)) {
_dosmaperr(GetLastError());
return -1;
}
return 0;
}

View file

@ -1,16 +0,0 @@
#include "precomp.h"
#include <msvcrt/direct.h>
#include <msvcrt/internal/file.h>
/*
* @implemented
*/
int _rmdir(const char* _path)
{
if (!RemoveDirectoryA(_path)) {
_dosmaperr(GetLastError());
return -1;
}
return 0;
}

View file

@ -1,17 +0,0 @@
#include "precomp.h"
#include <msvcrt/ctype.h>
#include <msvcrt/direct.h>
#include <msvcrt/internal/file.h>
#include <msvcrt/internal/file.h>
/*
* @implemented
*/
int _wchdir (const wchar_t *_path)
{
if (!SetCurrentDirectoryW((wchar_t *)_path)) {
_dosmaperr(GetLastError());
return -1;
}
return 0;
}

View file

@ -1,28 +0,0 @@
#include "precomp.h"
#include <msvcrt/direct.h>
#include <msvcrt/stdlib.h>
#include <msvcrt/errno.h>
#include <msvcrt/internal/file.h>
/*
* @implemented
*/
wchar_t* _wgetcwd(wchar_t* buffer, int maxlen)
{
wchar_t *cwd;
int len;
if (buffer == NULL) {
if ( (cwd = malloc(MAX_PATH * sizeof(wchar_t))) == NULL ) {
__set_errno(ENOMEM);
return NULL;
}
len = MAX_PATH;
} else {
cwd = buffer;
len = maxlen;
}
if (GetCurrentDirectoryW(len, cwd) == 0)
return NULL;
return cwd;
}

View file

@ -1,32 +0,0 @@
#include "precomp.h"
#include <msvcrt/direct.h>
#include <msvcrt/internal/file.h>
/*
* @implemented
*/
wchar_t* _wgetdcwd(int nDrive, wchar_t* caBuffer, int nBufLen)
{
int i =0;
int dr = _getdrive();
if (nDrive < 1 || nDrive > 26)
return NULL;
if (dr != nDrive) {
if ( _chdrive(nDrive) != 0 )
return NULL;
}
i = GetCurrentDirectoryW(nBufLen, caBuffer);
if (i == nBufLen)
return NULL;
if (dr != nDrive) {
if ( _chdrive(dr) != 0 )
return NULL;
}
return caBuffer;
}

View file

@ -1,16 +0,0 @@
#include "precomp.h"
#include <msvcrt/direct.h>
#include <msvcrt/internal/file.h>
/*
* @implemented
*/
int _wmkdir(const wchar_t* _path)
{
if (!CreateDirectoryW(_path, NULL)) {
_dosmaperr(GetLastError());
return -1;
}
return 0;
}

View file

@ -1,16 +0,0 @@
#include "precomp.h"
#include <msvcrt/direct.h>
#include <msvcrt/internal/file.h>
/*
* @implemented
*/
int _wrmdir(const wchar_t* _path)
{
if (!RemoveDirectoryW(_path)) {
_dosmaperr(GetLastError());
return -1;
}
return 0;
}

View file

@ -23,7 +23,7 @@
#include "precomp.h"
#include <msvcrt/internal/tls.h>
#include <msvcrt/stdlib.h>
#include "../wine/msvcrt.h"
#include <msvcrt/wine/msvcrt.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
@ -91,8 +91,8 @@ DllMain(PVOID hinstDll, ULONG dwReason, PVOID reserved)
return FALSE;
}
_acmdln = strdup(GetCommandLineA());
_wcmdln = wcsdup(GetCommandLineW());
_acmdln = _strdup(GetCommandLineA());
_wcmdln = _wcsdup(GetCommandLineW());
/* FIXME: more initializations... */

View file

@ -1,18 +0,0 @@
#include "precomp.h"
#include <stdio.h>
#ifdef __GNUC__
/*
* @unimplemented
*/
int _abnormal_termination(void)
{
printf("Abnormal Termination\n");
// return AbnormalTermination();
return 0;
}
#else
#endif

View file

@ -1,33 +0,0 @@
#include "precomp.h"
#include <excpt.h>
#ifdef __GNUC__
#else
ULONG DbgPrint(PCH Format,...)
{
return 0;
}
#endif
VOID STDCALL
MsvcrtDebug(ULONG Value)
{
//DbgPrint("MsvcrtDebug 0x%.08x\n", Value);
}
struct _EXCEPTION_RECORD;
struct _CONTEXT;
/*
* @implemented
*/
EXCEPTION_DISPOSITION
_except_handler2(
struct _EXCEPTION_RECORD *ExceptionRecord,
void *Frame,
struct _CONTEXT *ContextRecord,
void *DispatcherContext)
{
//printf("_except_handler2()\n");
return 0;
}

View file

@ -1,42 +0,0 @@
#include "precomp.h"
#include <ntos/except.h>
struct _exception {
int type;
char* name;
double arg1;
double arg2;
double retval;
} ;
int _matherr(struct _exception* e)
{
return 0;
}
/*
* not exported by NTDLL
*
* @unimplemented
*/
void __setusermatherr(int (*handler)(struct _exception*))
{
}
#define _FPIEEE_RECORD void
/*
* @unimplemented
*/
int _fpieee_flt(
unsigned long exception_code,
struct _EXCEPTION_POINTERS* ExceptionPointer,
int (*handler)(_FPIEEE_RECORD*)
)
{
return 0;
}

View file

@ -1,379 +0,0 @@
/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS MSVCRT Runtime Library
* PURPOSE: Runtime library exception support for IA-32
* FILE: lib/msvcrt/except/seh.s
* PROGRAMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
* NOTES: This file is shared with ntoskrnl/rtl/i386/seh.s.
* Please keep them in sync.
*/
#define ExceptionContinueExecution 0
#define ExceptionContinueSearch 1
#define ExceptionNestedException 2
#define ExceptionCollidedUnwind 3
#define EXCEPTION_NONCONTINUABLE 0x01
#define EXCEPTION_UNWINDING 0x02
#define EXCEPTION_EXIT_UNWIND 0x04
#define EXCEPTION_STACK_INVALID 0x08
#define EXCEPTION_NESTED_CALL 0x10
#define EXCEPTION_TARGET_UNWIND 0x20
#define EXCEPTION_COLLIDED_UNWIND 0x40
#define EXCEPTION_UNWIND_MODE \
( EXCEPTION_UNWINDING \
| EXCEPTION_EXIT_UNWIND \
| EXCEPTION_TARGET_UNWIND \
| EXCEPTION_COLLIDED_UNWIND)
#define EREC_CODE 0x00
#define EREC_FLAGS 0x04
#define EREC_RECORD 0x08
#define EREC_ADDRESS 0x0C
#define EREC_NUMPARAMS 0x10
#define EREC_INFO 0x14
#define TRYLEVEL_NONE -1
#define TRYLEVEL_INVALID -2
#define ER_STANDARDESP -0x08
#define ER_EPOINTERS -0x04
#define ER_PREVFRAME 0x00
#define ER_HANDLER 0x04
#define ER_SCOPETABLE 0x08
#define ER_TRYLEVEL 0x0C
#define ER_EBP 0x10
#define ST_TRYLEVEL 0x00
#define ST_FILTER 0x04
#define ST_HANDLER 0x08
#define CONTEXT_EDI 0x9C
#define CONTEXT_EBX 0xA4
#define CONTEXT_EIP 0xB8
.globl __local_unwind2
.globl __except_handler3
.globl __EH_prolog
// EAX = value to print
_do_debug:
pushal
pushl %eax
call _MsvcrtDebug@4
popal
ret
#define LU2_TRYLEVEL 0x08
#define LU2_REGFRAME 0x04
//
// void
// _local_unwind2(PEXCEPTION_REGISTRATION RegistrationFrame,
// LONG TryLevel)
//
// Parameters:
// [EDX+08h] - PEXCEPTION_REGISTRATION RegistrationFrame
// [EDX+04h] - LONG TryLevel
// Registers:
// EBP - EBP of call frame we are unwinding
// Returns:
// Nothing
// Notes:
// Run all termination handlers for a call frame from the current
// try-level up to (but not including) the given stop try-level.
__local_unwind2:
// Setup our call frame so we can access parameters using EDX
//pushl %ebp
movl %esp, %edx
// FIXME: Setup an EXCEPTION_REGISTRATION entry to protect the
// unwinding in case something goes wrong
.lu2_next_scope:
// Keep a pointer to the exception registration in EBX
movl LU2_REGFRAME(%edx), %ebx
// If we have reached the end of the chain or we're asked to stop here
// by the caller then exit
movl ER_TRYLEVEL(%ebx), %eax
cmpl $-1, %eax
je .lu2_done
cmpl LU2_TRYLEVEL(%edx), %eax
je .lu2_done
// Keep a pointer to the scopetable in ESI
movl ER_SCOPETABLE(%ebx), %esi
// Compute the offset of the entry in the scopetable that describes
// the scope that is to be unwound. Put the offset in EDI.
movl ST_TRYLEVEL(%esi), %edi
lea (%edi, %edi, 2), %edi
shll $2, %edi
addl %esi, %edi
// If this is not a termination handler then skip it
cmpl $0, ST_FILTER(%edi)
jne .lu2_next_scope
// Save the previous try-level in the exception registration structure
movl ST_TRYLEVEL(%edi), %eax
movl %eax, ER_TRYLEVEL(%ebx)
// Fetch the address of the termination handler
movl ST_HANDLER(%edi), %eax
// Termination handlers may trash all registers so save the
// important ones and then call the handler
pushl %edx
call *%eax
// Get our base pointer back
popl %edx
jmp .lu2_next_scope
.lu2_done:
// FIXME: Tear down the EXCEPTION_REGISTRATION entry setup to protect
// the unwinding
//movl %esi, %esp
//popl %ebp
ret
#define EH3_DISPCONTEXT 0x14
#define EH3_CONTEXT 0x10
#define EH3_REGFRAME 0x0C
#define EH3_ERECORD 0x08
// Parameters:
// [ESP+14h] - PVOID DispatcherContext
// [ESP+10h] - PCONTEXT Context
// [ESP+0Ch] - PEXCEPTION_REGISTRATION RegistrationFrame
// [ESP+08h] - PEXCEPTION_RECORD ExceptionRecord
// Registers:
// Unknown
// Returns:
// EXCEPTION_DISPOSITION - How this handler handled the exception
// Notes:
// Try to find an exception handler that will handle the exception.
// Traverse the entries in the scopetable that is associated with the
// exception registration passed as a parameter to this function.
// If an exception handler that will handle the exception is found, it
// is called and this function never returns
__except_handler3:
// Setup our call frame so we can access parameters using EBP
pushl %ebp // Standard ESP in frame (considered part of EXCEPTION_REGISTRATION)
movl %esp, %ebp
// Don't trust the direction flag to be cleared
cld
// Either we're called to handle an exception or we're called to unwind
movl EH3_ERECORD(%ebp), %eax
testl $EXCEPTION_UNWIND_MODE, EREC_FLAGS(%eax)
jnz .eh3_unwind
// Keep a pointer to the exception registration in EBX
movl EH3_REGFRAME(%ebp), %ebx
// Build an EXCEPTION_POINTERS structure on the stack and store it's
// address in the EXCEPTION_REGISTRATION structure
movl EH3_CONTEXT(%esp), %eax
pushl %ebx // Registration frame
pushl %eax // Context
movl %esp, ER_EPOINTERS(%ebx) // Pointer to EXCEPTION_REGISTRATION on the stack
// Keep current try-level in EDI
movl ER_TRYLEVEL(%ebx), %edi
// Keep a pointer to the scopetable in ESI
movl ER_SCOPETABLE(%ebx), %esi
.eh3_next_scope:
// If we have reached the end of the chain then exit
cmpl $-1, %edi
je .eh3_search
// Compute the offset of the entry in the scopetable and store
// the absolute address in EAX
lea (%edi, %edi, 2), %eax
shll $2, %eax
addl %esi, %eax
// Fetch the address of the filter routine
movl ST_FILTER(%eax), %eax
// If this is a termination handler then skip it
cmpl $0, %eax
je .eh3_continue
// Filter routines may trash all registers so save the important
// ones before restoring the call frame ebp and calling the handler
pushl %ebp
pushl %edi // Stop try-level
lea ER_EBP(%ebx), %ebp
call *%eax
popl %edi // Stop try-level
popl %ebp
// Reload EBX with registration frame address
movl EH3_REGFRAME(%ebp), %ebx
// Be more flexible here by checking if the return value is less than
// zero, equal to zero, or larger than zero instead of the defined
// values:
// -1 (EXCEPTION_CONTINUE_EXECUTION)
// 0 (EXCEPTION_CONTINUE_SEARCH)
// +1 (EXCEPTION_EXECUTE_HANDLER)
orl %eax, %eax
jz .eh3_continue
js .eh3_dismiss
// Filter returned: EXCEPTION_EXECUTE_HANDLER
// Ask the OS to perform global unwinding.
pushl %edi // Save stop try-level
pushl %ebx // Save registration frame address
pushl %ebx // Registration frame address
call __global_unwind2
popl %eax // Remove parameter to __global_unwind2
popl %ebx // Restore registration frame address
popl %edi // Restore stop try-level
// Change the context structure so _except_finish is called in the
// correct context since we return ExceptionContinueExecution.
movl EH3_CONTEXT(%ebp), %eax
movl %edi, CONTEXT_EDI(%eax) // Stop try-level
movl %ebx, CONTEXT_EBX(%eax) // Registration frame address
movl $_except_finish, CONTEXT_EIP(%eax)
movl $ExceptionContinueExecution, %eax
jmp .eh3_return
// Filter returned: EXCEPTION_CONTINUE_SEARCH
.eh3_continue:
// Reload ESI because the filter routine may have trashed it
movl ER_SCOPETABLE(%ebx), %esi
// Go one try-level closer to the top
lea (%edi, %edi, 2), %edi
shll $2, %edi
addl %esi, %edi
movl ST_TRYLEVEL(%edi), %edi
jmp .eh3_next_scope
// Filter returned: EXCEPTION_CONTINUE_EXECUTION
// Continue execution like nothing happened
.eh3_dismiss:
movl $ExceptionContinueExecution, %eax
jmp .eh3_return
// Tell the OS to search for another handler that will handle the exception
.eh3_search:
movl $ExceptionContinueSearch, %eax
jmp .eh3_return
// Perform local unwinding
.eh3_unwind:
movl $ExceptionContinueSearch, %eax
testl $EXCEPTION_TARGET_UNWIND, EREC_FLAGS(%eax)
jnz .eh3_return
// Save some important registers
pushl %ebp
lea ER_EBP(%ebx), %ebp
pushl $-1
pushl %ebx
call __local_unwind2
addl $8, %esp
// Restore some important registers
popl %ebp
movl $ExceptionContinueSearch, %eax
// Get me out of here
.eh3_return:
movl %ebp, %esp
popl %ebp
ret
// Parameters:
// None
// Registers:
// EBX - Pointer to exception registration structure
// EDI - Stop try-level
// Returns:
// -
// Notes:
// -
_except_finish:
// Setup EBP for the exception handler. By doing this the exception
// handler can access local variables as normal
lea ER_EBP(%ebx), %ebp
// Save some important registers
pushl %ebp
pushl %ebx
pushl %edi
// Stop try-level
pushl %edi
// Pointer to exception registration structure
pushl %ebx
call __local_unwind2
addl $8, %esp
// Restore some important registers
popl %edi
popl %ebx
popl %ebp
// Keep a pointer to the scopetable in ESI
movl ER_SCOPETABLE(%ebx), %esi
// Compute the offset of the entry in the scopetable and store
// the absolute address in EDI
lea (%edi, %edi, 2), %edi
shll $2, %edi
addl %esi, %edi
// Set the current try-level to the previous try-level and call
// the exception handler
movl ST_TRYLEVEL(%edi), %eax
movl %eax, ER_TRYLEVEL(%ebx)
movl ST_HANDLER(%edi), %eax
call *%eax
// We should never get here
ret
// Copied from Wine.
__EH_prolog:
pushl $-1
pushl %eax
pushl %fs:0
movl %esp, %fs:0
movl 12(%esp), %eax
movl %ebp, 12(%esp)
leal 12(%esp), %ebp
pushl %eax
ret

View file

@ -1,76 +0,0 @@
#include "precomp.h"
#include <excpt.h>
#include <wine/winternl.h>
/*
* @implemented
*/
void __cdecl
_global_unwind2(PEXCEPTION_REGISTRATION RegistrationFrame)
{
#ifdef __GNUC__
RtlUnwind(RegistrationFrame, &&__ret_label, NULL, 0);
__ret_label:
// return is important
return;
#else
#endif
}
// This is dragged over from WINE:
typedef struct __EXCEPTION_FRAME
{
struct __EXCEPTION_FRAME *Prev;
PEXCEPTION_HANDLER Handler;
} EXCEPTION_FRAME, *PEXCEPTION_FRAME;
/* VC++ extensions to Win32 SEH */
typedef struct _SCOPETABLE
{
int previousTryLevel;
int (*lpfnFilter)(PEXCEPTION_POINTERS);
int (*lpfnHandler)(void);
} SCOPETABLE, *PSCOPETABLE;
typedef struct _MSVCRT_EXCEPTION_FRAME
{
EXCEPTION_FRAME *prev;
void (*handler)(PEXCEPTION_RECORD, PEXCEPTION_FRAME,
PCONTEXT, PEXCEPTION_RECORD);
PSCOPETABLE scopetable;
int trylevel;
int _ebp;
PEXCEPTION_POINTERS xpointers;
} MSVCRT_EXCEPTION_FRAME;
typedef struct __JUMP_BUFFER
{
unsigned long Ebp;
unsigned long Ebx;
unsigned long Edi;
unsigned long Esi;
unsigned long Esp;
unsigned long Eip;
unsigned long Registration;
unsigned long TryLevel;
/* Start of new struct members */
unsigned long Cookie;
unsigned long UnwindFunc;
unsigned long UnwindData[6];
} _JUMP_BUFFER;
void
_local_unwind2(MSVCRT_EXCEPTION_FRAME *RegistrationFrame,
LONG TryLevel);
/*
* @implemented
*/
void __stdcall _seh_longjmp_unwind(_JUMP_BUFFER *jmp)
{
_local_unwind2((MSVCRT_EXCEPTION_FRAME*) jmp->Registration, jmp->TryLevel);
}

View file

@ -1,15 +0,0 @@
#include "precomp.h"
/*
* @unimplemented
*/
int
_XcptFilter(DWORD ExceptionCode,
struct _EXCEPTION_POINTERS * ExceptionInfo)
{
//fixme XcptFilter
// return UnhandledExceptionFilter(ExceptionInfo);
return 0;
}

View file

@ -1,23 +0,0 @@
#include <msvcrt/float.h>
#include <msvcrt/internal/ieee.h>
/*
* @implemented
*/
double _chgsign( double __x )
{
union
{
double* __x;
double_t *x;
} u;
u.__x = &__x;
if ( u.x->sign == 1 )
u.x->sign = 0;
else
u.x->sign = 1;
return __x;
}

View file

@ -1,17 +0,0 @@
#include <msvcrt/float.h>
/*
* @implemented
*/
unsigned int _clearfp (void)
{
unsigned short __res = _statusfp();
#ifdef __GNUC__
__asm__ __volatile__ (
"fclex \n\t"
);
#else
#endif /*__GNUC__*/
return __res;
}

View file

@ -1,174 +0,0 @@
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <msvcrt/float.h>
#define X87_CW_IM (1<<0) /* Invalid operation mask */
#define X87_CW_DM (1<<1) /* Denormal operand mask */
#define X87_CW_ZM (1<<2) /* Zero divide mask */
#define X87_CW_OM (1<<3) /* Overflow mask */
#define X87_CW_UM (1<<4) /* Underflow mask */
#define X87_CW_PM (1<<5) /* Precision mask */
#define X87_CW_PC_MASK (3<<8) /* precision control mask */
#define X87_CW_PC24 (0<<8) /* 24 bit precision */
#define X87_CW_PC53 (2<<8) /* 53 bit precision */
#define X87_CW_PC64 (3<<8) /* 64 bit precision */
#define X87_CW_RC_MASK (3<<10) /* rounding control mask */
#define X87_CW_RC_NEAREST (0<<10) /* round to nearest */
#define X87_CW_RC_DOWN (1<<10) /* round down */
#define X87_CW_RC_UP (2<<10) /* round up */
#define X87_CW_RC_ZERO (3<<10) /* round toward zero (chop) */
#define X87_CW_IC (1<<12) /* infinity control flag */
/*
* @implemented
*/
unsigned int _controlfp(unsigned int unNew, unsigned int unMask)
{
return _control87(unNew,unMask);
}
/*
* @implemented
*/
unsigned int _control87(unsigned int unNew, unsigned int unMask)
{
unsigned int FpuCw;
unsigned int DummyCw = 0;
/* get the controlword */
asm volatile("fstcw %0\n\t" : "=m"(FpuCw));
FpuCw &= 0x0000ffff;
/* translate it into _control87 format */
if (FpuCw & X87_CW_IM)
DummyCw |= _EM_INVALID;
if (FpuCw & X87_CW_DM)
DummyCw |= _EM_DENORMAL;
if (FpuCw & X87_CW_ZM)
DummyCw |= _EM_ZERODIVIDE;
if (FpuCw & X87_CW_OM)
DummyCw |= _EM_OVERFLOW;
if (FpuCw & X87_CW_UM)
DummyCw |= _EM_UNDERFLOW;
if (FpuCw & X87_CW_PM)
DummyCw |= _EM_INEXACT;
switch (FpuCw & X87_CW_PC_MASK)
{
case X87_CW_PC24:
DummyCw |= _PC_24;
break;
case X87_CW_PC53:
DummyCw |= _PC_53;
break;
case X87_CW_PC64:
DummyCw |= _PC_64;
break;
}
switch (FpuCw & X87_CW_RC_MASK)
{
case X87_CW_RC_NEAREST:
DummyCw |= _RC_NEAR;
break;
case X87_CW_RC_DOWN:
DummyCw |= _RC_DOWN;
break;
case X87_CW_RC_UP:
DummyCw |= _RC_UP;
break;
case X87_CW_RC_ZERO:
DummyCw |= _RC_CHOP;
break;
}
/* unset (un)masked bits */
DummyCw &= ~unMask;
unNew &= unMask;
/* set new bits */
DummyCw |= unNew;
/* translate back into x87 format
* FIXME: translate infinity control!
*/
FpuCw = 0;
if (DummyCw & _EM_INVALID)
FpuCw |= X87_CW_IM;
if (DummyCw & _EM_DENORMAL)
FpuCw |= X87_CW_DM;
if (DummyCw & _EM_ZERODIVIDE)
FpuCw |= X87_CW_ZM;
if (DummyCw & _EM_OVERFLOW)
FpuCw |= X87_CW_OM;
if (DummyCw & _EM_UNDERFLOW)
FpuCw |= X87_CW_UM;
if (DummyCw & _EM_INEXACT)
FpuCw |= X87_CW_PM;
switch (DummyCw & _MCW_PC)
{
case _PC_24:
FpuCw |= X87_CW_PC24;
break;
case _PC_53:
FpuCw |= X87_CW_PC53;
break;
case _PC_64:
default:
FpuCw |= X87_CW_PC64;
break;
}
switch (DummyCw & _MCW_RC)
{
case _RC_NEAR:
FpuCw |= X87_CW_RC_NEAREST;
break;
case _RC_DOWN:
FpuCw |= X87_CW_RC_DOWN;
break;
case _RC_UP:
FpuCw |= X87_CW_RC_UP;
break;
case _RC_CHOP:
FpuCw |= X87_CW_RC_ZERO;
break;
}
/* set controlword */
asm volatile("fldcw %0" : : "m"(FpuCw));
return DummyCw;
#if 0 /* The follwing is the original code, broken I think! -blight */
register unsigned int __res;
#ifdef __GNUC__
__asm__ __volatile__ (
"pushl %%eax \n\t" /* make room on stack */
"fstcw (%%esp) \n\t"
"fwait \n\t"
"popl %%eax \n\t"
"andl $0xffff, %%eax \n\t" /* OK; we have the old value ready */
"movl %1, %%ecx \n\t"
"notl %%ecx \n\t"
"andl %%eax, %%ecx \n\t" /* the bits we want to keep */
"movl %2, %%edx \n\t"
"andl %1, %%edx \n\t" /* the bits we want to change */
"orl %%ecx, %%edx\n\t" /* the new value */
"pushl %%edx \n\t"
"fldcw (%%esp) \n\t"
"popl %%edx \n\t"
:"=a" (__res):"r" (unNew),"r" (unMask): "dx", "cx");
#else
#endif /*__GNUC__*/
return __res;
#endif
}

View file

@ -1,26 +0,0 @@
#include <msvcrt/float.h>
#include <msvcrt/internal/ieee.h>
/*
* @implemented
*/
double _copysign (double __d, double __s)
{
union
{
double* __d;
double_t* d;
} d;
union
{
double* __s;
double_t* s;
} s;
d.__d = &__d;
s.__s = &__s;
d.d->sign = s.s->sign;
return __d;
}

View file

@ -1,71 +0,0 @@
#include <msvcrt/float.h>
#include <msvcrt/math.h>
#include <msvcrt/internal/ieee.h>
#define _FPCLASS_SNAN 0x0001 /* signaling NaN */
#define _FPCLASS_QNAN 0x0002 /* quiet NaN */
#define _FPCLASS_NINF 0x0004 /* negative infinity */
#define _FPCLASS_NN 0x0008 /* negative normal */
#define _FPCLASS_ND 0x0010 /* negative denormal */
#define _FPCLASS_NZ 0x0020 /* -0 */
#define _FPCLASS_PZ 0x0040 /* +0 */
#define _FPCLASS_PD 0x0080 /* positive denormal */
#define _FPCLASS_PN 0x0100 /* positive normal */
#define _FPCLASS_PINF 0x0200 /* positive infinity */
#define FP_SNAN 0x0001 // signaling NaN
#define FP_QNAN 0x0002 // quiet NaN
#define FP_NINF 0x0004 // negative infinity
#define FP_PINF 0x0200 // positive infinity
#define FP_NDENORM 0x0008 // negative denormalized non-zero
#define FP_PDENORM 0x0010 // positive denormalized non-zero
#define FP_NZERO 0x0020 // negative zero
#define FP_PZERO 0x0040 // positive zero
#define FP_NNORM 0x0080 // negative normalized non-zero
#define FP_PNORM 0x0100 // positive normalized non-zero
typedef int fpclass_t;
/*
* @implemented
*/
fpclass_t _fpclass(double __d)
{
union
{
double* __d;
double_t* d;
} d;
d.__d = &__d;
if ( d.d->exponent == 0 ) {
if ( d.d->mantissah == 0 && d.d->mantissal == 0 ) {
if ( d.d->sign ==0 )
return FP_NZERO;
else
return FP_PZERO;
} else {
if ( d.d->sign ==0 )
return FP_NDENORM;
else
return FP_PDENORM;
}
}
if (d.d->exponent == 0x7ff ) {
if ( d.d->mantissah == 0 && d.d->mantissal == 0 ) {
if ( d.d->sign ==0 )
return FP_NINF;
else
return FP_PINF;
}
else if ( d.d->mantissah == 0 && d.d->mantissal != 0 ) {
return FP_QNAN;
}
else if ( d.d->mantissah == 0 && d.d->mantissal != 0 ) {
return FP_SNAN;
}
}
return 0;
}

View file

@ -1,14 +0,0 @@
#ifdef __USE_W32API
#undef __USE_W32API
#endif
#include <msvcrt/float.h>
#include <msvcrt/internal/tls.h>
/*
* @implemented
*/
int * __fpecode(void)
{
return(&(GetThreadData()->fpecode));
}

View file

@ -1,12 +0,0 @@
#include <msvcrt/float.h>
/*
* @unimplemented
*/
void _fpreset(void)
{
/* FIXME: This causes an exception */
// __asm__ __volatile__("fninit\n\t");
return;
}

View file

@ -1,98 +0,0 @@
/* Copyright (C) 1991, 1992, 1995 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <msvcrt/math.h>
#include <msvcrt/float.h>
#include <msvcrt/internal/ieee.h>
/*
* @implemented
*/
int _isnan(double __x)
{
union
{
double* __x;
double_t* x;
} x;
x.__x = &__x;
return ( x.x->exponent == 0x7ff && ( x.x->mantissah != 0 || x.x->mantissal != 0 ));
}
int _isnanl(long double __x)
{
/* Intel's extended format has the normally implicit 1 explicit
present. Sigh! */
union
{
long double* __x;
long_double_t* x;
} x;
x.__x = &__x;
/* IEEE 854 NaN's have the maximum possible
exponent and a nonzero mantissa. */
return (( x.x->exponent == 0x7fff)
&& ( (x.x->mantissah & 0x80000000) != 0)
&& ( (x.x->mantissah & (unsigned int)0x7fffffff) != 0 || x.x->mantissal != 0 ));
}
int _isinf(double __x)
{
union
{
double* __x;
double_t* x;
} x;
x.__x = &__x;
return ( x.x->exponent == 0x7ff && ( x.x->mantissah == 0 && x.x->mantissal == 0 ));
}
/*
* @implemented
*/
int _finite( double x )
{
return !_isinf(x);
}
int _isinfl(long double __x)
{
/* Intel's extended format has the normally implicit 1 explicit
present. Sigh! */
union
{
long double* __x;
long_double_t* x;
} x;
x.__x = &__x;
/* An IEEE 854 infinity has an exponent with the
maximum possible value and a zero mantissa. */
if ( x.x->exponent == 0x7fff && ( (x.x->mantissah == 0x80000000 ) && x.x->mantissal == 0 ))
return x.x->sign ? -1 : 1;
return 0;
}

View file

@ -1,34 +0,0 @@
/* Math functions for i387.
Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by John C. Bowman <bowman@ipp-garching.mpg.de>, 1995.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <msvcrt/float.h>
double _logb (double __x)
{
register double __value;
#ifdef __GNUC__
register double __junk;
__asm __volatile__
("fxtract\n\t"
: "=t" (__junk), "=u" (__value) : "0" (__x));
#else
#endif /*__GNUC__*/
return __value;
}

View file

@ -1,16 +0,0 @@
#include <msvcrt/float.h>
/*
* @implemented
*/
double _nextafter( double x, double y )
{
if ( x == y)
return x;
if ( isnan(x) || isnan(y) )
return x;
return x;
}

View file

@ -1,20 +0,0 @@
#include <msvcrt/float.h>
#include <msvcrt/internal/ieee.h>
/*
* @implemented
*/
double _scalb( double __x, long e )
{
union
{
double* __x;
double_t* x;
} x;
x.__x = &__x;
x.x->exponent += e;
return __x;
}

View file

@ -1,19 +0,0 @@
#include <msvcrt/float.h>
/*
* @implemented
*/
unsigned int _statusfp (void)
{
register unsigned short __res;
#ifdef __GNUC__
__asm__ __volatile__ (
"fstsw %0 \n\t"
// "movzwl %ax, %eax"
:"=a" (__res)
);
#else
#endif /*__GNUC__*/
return __res;
}

View file

@ -1,33 +0,0 @@
#include "precomp.h"
#include <msvcrt/io.h>
#include <msvcrt/errno.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
/*
* @implemented
*/
int _access( const char *_path, int _amode )
{
DWORD Attributes = GetFileAttributesA(_path);
DPRINT("_access('%s', %x)\n", _path, _amode);
if (Attributes == -1) {
_dosmaperr(GetLastError());
return -1;
}
if ((_amode & W_OK) == W_OK) {
if ((Attributes & FILE_ATTRIBUTE_READONLY) == FILE_ATTRIBUTE_READONLY) {
__set_errno(EACCES);
return -1;
}
}
if ((_amode & D_OK) == D_OK) {
if ((Attributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY) {
__set_errno(EACCES);
return -1;
}
}
return 0;
}

View file

@ -1,46 +0,0 @@
#include "precomp.h"
#include <msvcrt/io.h>
#include <msvcrt/internal/file.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
#define mode_t int
/*
* @implemented
*/
int _chmod(const char* filename, mode_t mode)
{
DWORD FileAttributes = 0;
BOOLEAN Set = FALSE;
DPRINT("_chmod('%s', %x)\n", filename, mode);
FileAttributes = GetFileAttributesA(filename);
if ( FileAttributes == -1 ) {
_dosmaperr(GetLastError());
return -1;
}
if ( mode == 0 )
return -1;
if (mode & _S_IWRITE) {
if (FileAttributes & FILE_ATTRIBUTE_READONLY) {
FileAttributes &= ~FILE_ATTRIBUTE_READONLY;
Set = TRUE;
}
} else {
if (!(FileAttributes & FILE_ATTRIBUTE_READONLY)) {
FileAttributes |= FILE_ATTRIBUTE_READONLY;
Set = TRUE;
}
}
if (Set && SetFileAttributesA(filename, FileAttributes) == FALSE) {
_dosmaperr(GetLastError());
return -1;
}
return 0;
}

View file

@ -1,18 +0,0 @@
/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
#include <msvcrt/io.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
/*
* @implemented
*/
int _chsize(int _fd, long size)
{
DPRINT("_chsize(fd %d, size %d)\n", _fd, size);
if (lseek(_fd, size, 0) == -1)
return -1;
if (_write(_fd, 0, 0) < 0)
return -1;
return 0;
}

View file

@ -1,19 +0,0 @@
#include "precomp.h"
#include <msvcrt/io.h>
#include <msvcrt/internal/file.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
/*
* @implemented
*/
int _close(int _fd)
{
DPRINT("_close(fd %d)\n", _fd);
if (_fd == -1)
return -1;
if (CloseHandle(_get_osfhandle(_fd)) == FALSE)
return -1;
return __fileno_close(_fd);
}

View file

@ -1,18 +0,0 @@
#include "precomp.h"
#include <msvcrt/io.h>
#include <msvcrt/errno.h>
#include <msvcrt/internal/file.h>
/*
* @implemented
*/
int _commit(int _fd)
{
if (! FlushFileBuffers(_get_osfhandle(_fd)) ) {
__set_errno(EBADF);
return -1;
}
return 0;
}

View file

@ -1,15 +0,0 @@
#include <msvcrt/io.h>
#include <msvcrt/fcntl.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
/*
* @implemented
*/
int _creat(const char* filename, int mode)
{
DPRINT("_creat('%s', mode %x)\n", filename, mode);
return _open(filename,_O_CREAT|_O_TRUNC,mode);
}

View file

@ -1,40 +0,0 @@
#include "precomp.h"
#include <msvcrt/io.h>
#include <msvcrt/errno.h>
#include <msvcrt/internal/file.h>
/*
* @implemented
*/
int _dup(int handle)
{
HANDLE hFile;
HANDLE hProcess = GetCurrentProcess();
BOOL result;
int fd;
hFile = _get_osfhandle(handle);
if (hFile == INVALID_HANDLE_VALUE) {
__set_errno(EBADF);
return -1;
}
result = DuplicateHandle(hProcess,
hFile,
hProcess,
&hFile,
0,
TRUE,
DUPLICATE_SAME_ACCESS);
if (result == FALSE) {
_dosmaperr(GetLastError());
return -1;
}
fd = __fileno_alloc(hFile, __fileno_getmode(handle));
if (fd < 0)
{
CloseHandle(hFile);
}
return fd;
}

View file

@ -1,10 +0,0 @@
#include <msvcrt/io.h>
#include <msvcrt/internal/file.h>
/*
* @implemented
*/
int _dup2(int handle1, int handle2)
{
return __fileno_dup2(handle1, handle2);
}

View file

@ -1,17 +0,0 @@
#include <msvcrt/io.h>
/*
* @implemented
*/
int _eof(int _fd)
{
__int64 cur_pos = _lseeki64(_fd, 0, SEEK_CUR);
__int64 end_pos = _lseeki64(_fd, 0, SEEK_END);
if ( cur_pos == -1 || end_pos == -1)
return -1;
if (cur_pos == end_pos)
return 1;
return 0;
}

View file

@ -1,20 +0,0 @@
#include "precomp.h"
#include <msvcrt/io.h>
#include <msvcrt/internal/file.h>
/*
* @implemented
*/
long _filelength(int _fd)
{
DWORD len = GetFileSize(_get_osfhandle(_fd), NULL);
if (len == INVALID_FILE_SIZE) {
DWORD oserror = GetLastError();
if (oserror != 0) {
_dosmaperr(oserror);
return -1L;
}
}
return (long)len;
}

View file

@ -1,22 +0,0 @@
#include "precomp.h"
#include <msvcrt/io.h>
#include <msvcrt/internal/file.h>
/*
* @implemented
*/
__int64 _filelengthi64(int _fd)
{
DWORD lo_length, hi_length;
lo_length = GetFileSize(_get_osfhandle(_fd), &hi_length);
if (lo_length == INVALID_FILE_SIZE) {
DWORD oserror = GetLastError();
if (oserror != 0) {
_dosmaperr(oserror);
return (__int64)-1;
}
}
return((((__int64)hi_length) << 32) + lo_length);
}

View file

@ -1,89 +0,0 @@
#include "precomp.h"
#include <msvcrt/io.h>
#include <msvcrt/string.h>
#include <msvcrt/internal/file.h>
/*
* @implemented
*/
int _findclose(int handle)
{
// check no wildcards or invalid handle
if (handle == 0 || handle == -1)
return 0;
return FindClose((void*)handle);
}
/*
* @implemented
*/
int _findfirst(const char* _name, struct _finddata_t* result)
{
WIN32_FIND_DATAA FindFileData;
char dir[MAX_PATH];
long hFindFile;
int len = 0;
if (_name == NULL || _name[0] == 0) {
len = GetCurrentDirectoryA(MAX_PATH-4,dir);
if (dir[len-1] != '\\') {
dir[len] = '\\';
dir[len+1] = 0;
}
strcat(dir,"*.*");
} else {
strcpy(dir,_name);
}
hFindFile = (long)FindFirstFileA(dir, &FindFileData);
if (hFindFile == -1) {
memset(result,0,sizeof(struct _finddata_t));
_dosmaperr(GetLastError());
return -1;
}
result->attrib = FindFileData.dwFileAttributes;
result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
result->size = FindFileData.nFileSizeLow;
strncpy(result->name,FindFileData.cFileName,MAX_PATH);
// if no wildcard the find file handle can be closed right away
// a return value of 0 can flag this.
if (!strchr(dir,'*') && !strchr(dir,'?')) {
_findclose(hFindFile);
return 0;
}
return hFindFile;
}
/*
* @implemented
*/
int _findnext(int handle, struct _finddata_t* result)
{
WIN32_FIND_DATAA FindFileData;
// check no wildcards or invalid handle
if (handle == 0 || handle == -1)
return 0;
if (!FindNextFileA((void*)handle, &FindFileData)) {
_dosmaperr(GetLastError());
return -1;
}
result->attrib = FindFileData.dwFileAttributes;
result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
result->size = FindFileData.nFileSizeLow;
strncpy(result->name,FindFileData.cFileName, MAX_PATH);
return 0;
}

View file

@ -1,14 +0,0 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <msvcrt/fcntl.h>
#include <msvcrt/io.h>
#undef _fmode
unsigned int _fmode = O_TEXT;
/*
* @implemented
*/
unsigned int *__p__fmode(void)
{
return &_fmode;
}

View file

@ -1,19 +0,0 @@
#include <msvcrt/io.h>
#include <msvcrt/sys/stat.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
/*
* @implemented
*/
int _isatty( int fd )
{
struct stat buf;
DPRINT("_isatty(fd %d)\n", fd);
if (_fstat (fd, &buf) < 0)
return 0;
if (S_ISCHR (buf.st_mode))
return 1;
return 0;
}

View file

@ -1,20 +0,0 @@
#include "precomp.h"
#include <msvcrt/io.h>
#include <msvcrt/internal/file.h>
/*
* @implemented
*/
int _locking(int _fd, int mode, long nbytes)
{
long offset = _lseek(_fd, 0L, 1);
if (offset == -1L)
return -1;
if (!LockFile(_get_osfhandle(_fd),offset,0,nbytes,0)) {
_dosmaperr(GetLastError());
return -1;
}
return 0;
}

View file

@ -1,20 +0,0 @@
#include "precomp.h"
#include <msvcrt/io.h>
#include <msvcrt/internal/file.h>
/*
* @implemented
*/
long _lseek(int _fildes, long _offset, int _whence)
{
DWORD newpos = SetFilePointer((HANDLE)filehnd(_fildes), _offset, NULL, _whence);
if (newpos == INVALID_SET_FILE_POINTER) {
DWORD oserror = GetLastError();
if (oserror != 0) {
_dosmaperr(oserror);
return -1L;
}
}
return newpos;
}

View file

@ -1,42 +0,0 @@
#include "precomp.h"
#include <msvcrt/io.h>
#include <msvcrt/internal/file.h>
//#define SETFILEPOINTEREX_AVAILABLE
/*
* @implemented
*/
__int64 _lseeki64(int _fildes, __int64 _offset, int _whence)
{
#ifdef SETFILEPOINTEREX_AVAILABLE
LARGE_INTEGER new_pos;
LARGE_INTEGER offset;
offset.QuadPart = _offset;
// if (invalid_filehnd(_fildes)) {
// __set_errno ( EBADF );
// return -1L;
// }
if (SetFilePointerEx((HANDLE)filehnd(_fildes), offset, &new_pos, _whence)) {
} else {
_dosmaperr(error);
return -1L;
}
return new_pos.QuadPart;
#else
//ULONG lo_pos;
//DWORD hi_pos = 0; // must equal 0 or -1 if supplied, -1 for negative 32 seek value
//lo_pos = SetFilePointer((HANDLE)filehnd(_fildes), _offset, &hi_pos, _whence);
//return((((__int64)hi_pos) << 32) + lo_pos);
LARGE_INTEGER offset;
offset.QuadPart = _offset;
offset.u.LowPart = SetFilePointer((HANDLE)filehnd(_fildes),
offset.u.LowPart, &offset.u.HighPart, _whence);
return ((((__int64)offset.u.HighPart) << 32) + offset.u.LowPart);
#endif /*SETFILEPOINTEREX_AVAILABLE*/
}

View file

@ -1,78 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details
* PROJECT: ReactOS system libraries
* FILE: lib/msvcrt/io/mktemp.c
* PURPOSE: Makes a temp file based on a template
* PROGRAMER: DJ Delorie
Boudewijn Dekker
* UPDATE HISTORY:
* 28/12/98: Appropriated for the Reactos Kernel
*/
/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <msvcrt/stdio.h>
#include <msvcrt/string.h>
#include <msvcrt/io.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
/*
* @implemented
*/
char* _mktemp(char* _template)
{
static int count = 0;
char *cp, *dp;
int i, len, xcount, loopcnt;
DPRINT("_mktemp('%s')\n", _template);
len = strlen (_template);
cp = _template + len;
xcount = 0;
while (xcount < 6 && cp > _template && cp[-1] == 'X')
xcount++, cp--;
if (xcount) {
dp = cp;
while (dp > _template && dp[-1] != '/' && dp[-1] != '\\' && dp[-1] != ':')
dp--;
/* Keep the first characters of the template, but turn the rest into
Xs. */
while (cp > dp + 8 - xcount) {
*--cp = 'X';
xcount = (xcount >= 6) ? 6 : 1 + xcount;
}
/* If dots occur too early -- squash them. */
while (dp < cp) {
if (*dp == '.') *dp = 'a';
dp++;
}
/* Try to add ".tmp" to the filename. Truncate unused Xs. */
if (cp + xcount + 3 < _template + len)
strcpy (cp + xcount, ".tmp");
else
cp[xcount] = 0;
/* This loop can run up to 2<<(5*6) times, or about 10^9 times. */
for (loopcnt = 0; loopcnt < (1 << (5 * xcount)); loopcnt++) {
int c = count++;
for (i = 0; i < xcount; i++, c >>= 5)
cp[i] = "abcdefghijklmnopqrstuvwxyz012345"[c & 0x1f];
if (_access(_template,0) == -1)
return _template;
}
}
/* Failure: truncate the template and return NULL. */
*_template = 0;
return 0;
}

View file

@ -1,423 +0,0 @@
/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/msvcrt/io/open.c
* PURPOSE: Opens a file and translates handles to fileno
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
* 28/12/98: Created
*/
// rember to interlock the allocation of fileno when making this thread safe
// possibly store extra information at the handle
#include "precomp.h"
#if !defined(NDEBUG) && defined(DBG)
#include <msvcrt/stdarg.h>
#endif
#include <msvcrt/io.h>
#include <msvcrt/fcntl.h>
#include <msvcrt/sys/stat.h>
#include <msvcrt/stdlib.h>
#include <msvcrt/internal/file.h>
#include <msvcrt/string.h>
#include <msvcrt/share.h>
#include <msvcrt/errno.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
//#define _OLD_BUILD_
#define STD_AUX_HANDLE 3
#define STD_PRINTER_HANDLE 4
/////////////////////////////////////////
#if 0 // from perl sources
#ifndef _INTPTR_T_DEFINED
typedef int intptr_t;
#define _INTPTR_T_DEFINED
#endif
#ifndef _UINTPTR_T_DEFINED
typedef unsigned int uintptr_t;
#define _UINTPTR_T_DEFINED
#endif
/*
* Control structure for lowio file handles
*/
typedef struct {
intptr_t osfhnd;/* underlying OS file HANDLE */
char osfile; /* attributes of file (e.g., open in text mode?) */
char pipech; /* one char buffer for handles opened on pipes */
int lockinitflag;
//CRITICAL_SECTION lock;
} ioinfo;
/*
* Array of arrays of control structures for lowio files.
*/
//ioinfo* __pioinfo[];
//ioinfo* __pioinfo[] = { NULL };
#endif
/////////////////////////////////////////
typedef struct _fileno_modes_type
{
HANDLE hFile;
int mode;
char pipech; /* one char buffer for handles opened on pipes */
int lockinitflag;
/*CRITICAL_SECTION*/int lock;
int fd;
} fileno_modes_type;
//static fileno_modes_type* fileno_modes = NULL;
fileno_modes_type* __pioinfo = NULL;
/////////////////////////////////////////
int maxfno = 0;
char __is_text_file(FILE* p)
{
if ( p == NULL || __pioinfo == NULL )
return FALSE;
return (!((p)->_flag&_IOSTRG) && (__pioinfo[(p)->_file].mode&O_TEXT));
}
/*
* @implemented
*/
int _open(const char* _path, int _oflag,...)
{
#if !defined(NDEBUG) && defined(DBG)
va_list arg;
int pmode;
#endif
HANDLE hFile;
DWORD dwDesiredAccess = 0;
DWORD dwShareMode = 0;
DWORD dwCreationDistribution = 0;
DWORD dwFlagsAndAttributes = 0;
SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE};
#if !defined(NDEBUG) && defined(DBG)
va_start(arg, _oflag);
pmode = va_arg(arg, int);
#endif
// DPRINT("_open('%s', %x, (%x))\n", _path, _oflag, pmode);
if ((_oflag & S_IREAD ) == S_IREAD)
dwShareMode = FILE_SHARE_READ;
else if ((_oflag & S_IWRITE) == S_IWRITE) {
dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
}
/*
*
* _O_BINARY Opens file in binary (untranslated) mode. (See fopen for a description of binary mode.)
* _O_TEXT Opens file in text (translated) mode. (For more information, see Text and Binary Mode File I/O and fopen.)
*
* _O_APPEND Moves file pointer to end of file before every write operation.
*/
#ifdef _OLD_BUILD_
if ((_oflag & _O_RDWR) == _O_RDWR)
dwDesiredAccess |= GENERIC_WRITE|GENERIC_READ;
else if ((_oflag & O_RDONLY) == O_RDONLY)
dwDesiredAccess |= GENERIC_READ;
else if ((_oflag & _O_WRONLY) == _O_WRONLY)
dwDesiredAccess |= GENERIC_WRITE ;
#else
if ((_oflag & _O_WRONLY) == _O_WRONLY )
dwDesiredAccess |= GENERIC_WRITE ;
else if ((_oflag & _O_RDWR) == _O_RDWR )
dwDesiredAccess |= GENERIC_WRITE|GENERIC_READ;
else //if ((_oflag & O_RDONLY) == O_RDONLY)
dwDesiredAccess |= GENERIC_READ;
#endif
if (( _oflag & (_O_CREAT | _O_EXCL)) == (_O_CREAT | _O_EXCL))
dwCreationDistribution |= CREATE_NEW;
else if ((_oflag & O_TRUNC ) == O_TRUNC) {
if ((_oflag & O_CREAT ) == O_CREAT)
dwCreationDistribution |= CREATE_ALWAYS;
else if ((_oflag & O_RDONLY ) != O_RDONLY)
dwCreationDistribution |= TRUNCATE_EXISTING;
}
else if ((_oflag & _O_APPEND) == _O_APPEND)
dwCreationDistribution |= OPEN_EXISTING;
else if ((_oflag & _O_CREAT) == _O_CREAT)
dwCreationDistribution |= OPEN_ALWAYS;
else
dwCreationDistribution |= OPEN_EXISTING;
if ((_oflag & _O_RANDOM) == _O_RANDOM )
dwFlagsAndAttributes |= FILE_FLAG_RANDOM_ACCESS;
if ((_oflag & _O_SEQUENTIAL) == _O_SEQUENTIAL)
dwFlagsAndAttributes |= FILE_FLAG_SEQUENTIAL_SCAN;
if ((_oflag & _O_TEMPORARY) == _O_TEMPORARY) {
dwFlagsAndAttributes |= FILE_FLAG_DELETE_ON_CLOSE;
DPRINT("FILE_FLAG_DELETE_ON_CLOSE\n");
}
if ((_oflag & _O_SHORT_LIVED) == _O_SHORT_LIVED) {
dwFlagsAndAttributes |= FILE_FLAG_DELETE_ON_CLOSE;
DPRINT("FILE_FLAG_DELETE_ON_CLOSE\n");
}
if (_oflag & _O_NOINHERIT)
sa.bInheritHandle = FALSE;
if (dwCreationDistribution == OPEN_EXISTING &&
(dwDesiredAccess & (GENERIC_WRITE|GENERIC_READ)) == GENERIC_READ) {
/* Allow always shared read for a file which is opened for read only */
dwShareMode |= FILE_SHARE_READ;
}
hFile = CreateFileA(_path,
dwDesiredAccess,
dwShareMode,
&sa,
dwCreationDistribution,
dwFlagsAndAttributes,
NULL);
if (hFile == (HANDLE)-1) {
_dosmaperr(GetLastError());
return -1;
}
DPRINT("OK\n");
if (!(_oflag & (_O_TEXT|_O_BINARY))) {
_oflag |= _fmode;
}
return __fileno_alloc(hFile,_oflag);
}
int __fileno_alloc(HANDLE hFile, int mode)
{
int i;
/* Check for bogus values */
if (hFile < 0)
return -1;
for (i = 5; i < maxfno; i++) {
if (__pioinfo[i].fd == -1 ) {
__pioinfo[i].fd = i;
__pioinfo[i].mode = mode;
__pioinfo[i].hFile = hFile;
return i;
}
}
/* See if we need to expand the tables. Check this BEFORE it might fail,
so that when we hit the count'th request, we've already up'd it. */
if (i == maxfno) {
int oldcount = maxfno;
fileno_modes_type* old_fileno_modes = __pioinfo;
maxfno += 255;
__pioinfo = (fileno_modes_type*)malloc(maxfno * sizeof(fileno_modes_type));
if (old_fileno_modes != NULL) {
memcpy(__pioinfo, old_fileno_modes, oldcount * sizeof(fileno_modes_type));
free(old_fileno_modes);
}
memset(__pioinfo + oldcount, -1, (maxfno-oldcount)*sizeof(fileno_modes_type));
}
/* Fill in the value */
__pioinfo[i].fd = i;
__pioinfo[i].mode = mode;
__pioinfo[i].hFile = hFile;
return i;
}
void* filehnd(int fileno)
{
if (fileno < 0 || fileno >= maxfno || __pioinfo[fileno].fd == -1) {
return (void*)-1;
}
return __pioinfo[fileno].hFile;
}
int __fileno_setmode(int _fd, int _newmode)
{
int m;
if (_fd < 0 || _fd >= maxfno) {
__set_errno(EBADF);
return -1;
}
m = __pioinfo[_fd].mode;
__pioinfo[_fd].mode = _newmode;
return m;
}
int __fileno_getmode(int _fd)
{
if (_fd < 0 || _fd >= maxfno) {
__set_errno(EBADF);
return -1;
}
return __pioinfo[_fd].mode;
}
int __fileno_close(int _fd)
{
if (_fd < 0 || _fd >= maxfno) {
__set_errno(EBADF);
return -1;
}
__pioinfo[_fd].fd = -1;
__pioinfo[_fd].hFile = (HANDLE)-1;
return 0;
}
/*
* @implemented
*/
int _open_osfhandle(void* osfhandle, int flags)
{
return __fileno_alloc((HANDLE)osfhandle, flags);
}
/*
* @implemented
*/
void* _get_osfhandle( int fileno )
{
return filehnd(fileno);
}
int __fileno_dup2(int handle1, int handle2)
{
HANDLE hProcess;
BOOL result;
if (handle1 >= maxfno || handle1 < 0 || handle2 >= maxfno || handle2 < 0) {
__set_errno(EBADF);
return -1;
}
if (__pioinfo[handle1].fd == -1) {
__set_errno(EBADF);
return -1;
}
if (handle1 == handle2)
return handle1;
if (__pioinfo[handle2].fd != -1) {
_close(handle2);
}
hProcess = GetCurrentProcess();
result = DuplicateHandle(hProcess,
__pioinfo[handle1].hFile,
hProcess,
&__pioinfo[handle2].hFile,
0,
TRUE,
DUPLICATE_SAME_ACCESS);
if (result) {
__pioinfo[handle2].fd = handle2;
__pioinfo[handle2].mode = __pioinfo[handle1].mode;
switch (handle2) {
case 0:
SetStdHandle(STD_INPUT_HANDLE, __pioinfo[handle2].hFile);
break;
case 1:
SetStdHandle(STD_OUTPUT_HANDLE, __pioinfo[handle2].hFile);
break;
case 2:
SetStdHandle(STD_ERROR_HANDLE, __pioinfo[handle2].hFile);
break;
case 3:
SetStdHandle(STD_AUX_HANDLE, __pioinfo[handle2].hFile);
break;
case 4:
SetStdHandle(STD_AUX_HANDLE, __pioinfo[handle2].hFile);
break;
}
return handle1;
} else {
__set_errno(EMFILE); // Is this the correct error no.?
return -1;
}
}
void* malloc(size_t sizeObject);
BOOL __fileno_init(void)
{
ULONG count = 0, i;
HANDLE* pFile;
char* pmode;
STARTUPINFOA StInfo;
GetStartupInfoA(&StInfo);
if (StInfo.lpReserved2 && StInfo.cbReserved2 >= sizeof(ULONG)) {
count = *(ULONG*)StInfo.lpReserved2;
/*
if (sizeof(ULONG) + count * (sizeof(HANDLE) + sizeof(char)) != StInfo.cbReserved2)
{
count = 0;
}
*/
}
maxfno = 255;
while(count >= maxfno)
maxfno += 255;
{
#ifdef _OLD_BUILD_
// why was this here ???? - robd.
int result;
result = malloc(50);
#endif
}
//__pioinfo = (fileno_modes_type*)malloc(sizeof(fileno_modes_type) * maxfno);
__pioinfo = malloc(sizeof(fileno_modes_type) * maxfno);
if (__pioinfo == NULL) {
return FALSE;
}
memset(__pioinfo, -1, sizeof(fileno_modes_type) * maxfno);
if (count) {
pFile = (HANDLE*)(StInfo.lpReserved2 + sizeof(ULONG) + count * sizeof(char));
pmode = (char*)(StInfo.lpReserved2 + sizeof(ULONG));
for (i = 0; i < count; i++) {
if (*pFile != INVALID_HANDLE_VALUE) {
__pioinfo[i].fd = i;
__pioinfo[i].mode = ((*pmode << 8) & (_O_TEXT|_O_BINARY)) | (*pmode & _O_ACCMODE);
__pioinfo[i].hFile = *pFile;
}
pFile++;
pmode++;
}
}
if (__pioinfo[0].fd == -1) {
__pioinfo[0].fd = 0;
__pioinfo[0].hFile = GetStdHandle(STD_INPUT_HANDLE);
__pioinfo[0].mode = _O_RDONLY|_O_TEXT;
}
if (__pioinfo[1].fd == -1) {
__pioinfo[1].fd = 1;
__pioinfo[1].hFile = GetStdHandle(STD_OUTPUT_HANDLE);
__pioinfo[1].mode = _O_WRONLY|_O_TEXT;
}
if (__pioinfo[2].fd == -1) {
__pioinfo[2].fd = 2;
__pioinfo[2].hFile = GetStdHandle(STD_ERROR_HANDLE);
__pioinfo[2].mode = _O_WRONLY|_O_TEXT;
}
if (__pioinfo[3].fd == -1) {
__pioinfo[3].fd = 3;
__pioinfo[3].hFile = GetStdHandle(STD_AUX_HANDLE);
__pioinfo[3].mode = _O_WRONLY|_O_TEXT;
}
if (__pioinfo[4].fd == -1) {
__pioinfo[4].fd = 4;
__pioinfo[4].hFile = GetStdHandle(STD_PRINTER_HANDLE);
__pioinfo[4].mode = _O_WRONLY|_O_TEXT;
}
return TRUE;
}

View file

@ -1,51 +0,0 @@
/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/msvcrt/io/pipe.c
* PURPOSE: Creates a pipe
* PROGRAMER: DJ Delorie
* UPDATE HISTORY:
* 28/12/98: Appropriated for Reactos
*/
#include "precomp.h"
#include <msvcrt/io.h>
#include <msvcrt/errno.h>
#include <msvcrt/internal/file.h>
/*
* @implemented
*/
int _pipe(int _fildes[2], unsigned int size, int mode )
{
HANDLE hReadPipe, hWritePipe;
SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE};
if (mode & O_NOINHERIT)
sa.bInheritHandle = FALSE;
if (!CreatePipe(&hReadPipe,&hWritePipe,&sa,size)) {
_dosmaperr(GetLastError());
return -1;
}
if ((_fildes[0] = __fileno_alloc(hReadPipe, mode)) < 0)
{
CloseHandle(hReadPipe);
CloseHandle(hWritePipe);
__set_errno(EMFILE);
return -1;
}
if ((_fildes[1] = __fileno_alloc(hWritePipe, mode)) < 0)
{
__fileno_close(_fildes[0]);
CloseHandle(hReadPipe);
CloseHandle(hWritePipe);
__set_errno(EMFILE);
return -1;
}
return 0;
}

View file

@ -1,102 +0,0 @@
/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/msvcrt/io/read.c
* PURPOSE: Reads a file
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
* 28/12/1998: Created
* 03/05/2002: made _read() non-greedy - it now returns as soon as
* any amount of data has been read. It's the expected
* behavior for line-buffered streams (KJK::Hyperion)
*/
#include "precomp.h"
#include <msvcrt/io.h>
#include <msvcrt/internal/file.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
/*
* @implemented
*/
size_t _read(int _fd, void *_buf, size_t _nbyte)
{
DWORD _rbyte = 0, nbyte = _nbyte;
char *bufp = (char*)_buf;
HANDLE hfile;
int istext, error;
DPRINT("_read(fd %d, buf %x, nbyte %d)\n", _fd, _buf, _nbyte);
/* null read */
if(_nbyte == 0)
return 0;
hfile = _get_osfhandle(_fd);
istext = __fileno_getmode(_fd) & O_TEXT;
/* read data */
if (!ReadFile(hfile, bufp, nbyte, &_rbyte, NULL))
{
/* failure */
error = GetLastError();
if (error == ERROR_BROKEN_PIPE)
{
return 0;
}
_dosmaperr(error);
return -1;
}
/* text mode */
if (_rbyte && istext)
{
int found_cr = 0;
int cr = 0;
DWORD count = _rbyte;
/* repeat for all bytes in the buffer */
for(; count; bufp++, count--)
{
#if 1
/* carriage return */
if (*bufp == '\r') {
found_cr = 1;
if (cr != 0) {
*(bufp - cr) = *bufp;
}
continue;
}
if (found_cr) {
found_cr = 0;
if (*bufp == '\n') {
cr++;
*(bufp - cr) = *bufp;
} else {
}
} else if (cr != 0) {
*(bufp - cr) = *bufp;
}
#else
/* carriage return */
if (*bufp == '\r') {
cr++;
}
/* shift characters back, to ignore carriage returns */
else if (cr != 0) {
*(bufp - cr) = *bufp;
}
#endif
}
if (found_cr) {
cr++;
}
/* ignore the carriage returns */
_rbyte -= cr;
}
DPRINT("%d\n", _rbyte);
return _rbyte;
}

View file

@ -1,27 +0,0 @@
/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/msvcrt/io/setmode.c
* PURPOSE: Sets the file translation mode
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include <msvcrt/io.h>
#include <msvcrt/stdio.h>
#include <msvcrt/internal/file.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
/*
* @implemented
*/
int _setmode(int _fd, int _newmode)
{
DPRINT("_setmod(fd %d, newmode %x)\n", _fd, _newmode);
return __fileno_setmode(_fd, _newmode);
}

View file

@ -1,10 +0,0 @@
#include <msvcrt/io.h>
/*
* @implemented
*/
int _sopen(char *path, int access, int shflag, int mode)
{
return _open((path), (access)|(shflag), (mode));
}

View file

@ -1 +0,0 @@
void *__badioinfo;

View file

@ -1,12 +0,0 @@
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <msvcrt/errno.h>
#include <msvcrt/io.h>
/*
* @implemented
*/
off_t _tell(int _file)
{
return _lseek(_file, 0, SEEK_CUR);
}

View file

@ -1,11 +0,0 @@
#include <msvcrt/errno.h>
#include <msvcrt/io.h>
/*
* @implemented
*/
__int64 _telli64(int _file)
{
return _lseeki64(_file, 0, SEEK_CUR);
}

View file

@ -1,14 +0,0 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <msvcrt/sys/stat.h>
unsigned _unMode_dll = 022;
/*
* @implemented
*/
unsigned _umask (unsigned unMode)
{
unsigned old_mask = _unMode_dll;
_unMode_dll = unMode;
return old_mask;
}

View file

@ -1,29 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/msvcrt/io/unlink.c
* PURPOSE: Deletes a file
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include "precomp.h"
#include <msvcrt/io.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
/*
* @implemented
*/
int _unlink(const char* filename)
{
DPRINT("_unlink('%s')\n", filename);
if (!DeleteFileA(filename)) {
_dosmaperr(GetLastError());
return -1;
}
return 0;
}

View file

@ -1,25 +0,0 @@
#include <msvcrt/stdio.h>
#include <msvcrt/io.h>
#include <msvcrt/errno.h>
#include <msvcrt/sys/utime.h>
#include <msvcrt/internal/file.h>
/*
* @implemented
*/
int _utime(const char* filename, struct _utimbuf* buf)
{
int fn;
int ret;
fn = _open(filename, _O_RDWR);
if (fn == -1) {
__set_errno(EBADF);
return -1;
}
ret = _futime(fn, buf);
if (_close(fn) < 0)
return -1;
return ret;
}

View file

@ -1,32 +0,0 @@
#include "precomp.h"
#include <msvcrt/io.h>
#include <msvcrt/errno.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
/*
* @implemented
*/
int _waccess(const wchar_t *_path, int _amode)
{
DWORD Attributes = GetFileAttributesW(_path);
if (Attributes == -1) {
_dosmaperr(GetLastError());
return -1;
}
if ((_amode & W_OK) == W_OK) {
if ((Attributes & FILE_ATTRIBUTE_READONLY) == FILE_ATTRIBUTE_READONLY) {
__set_errno(EACCES);
return -1;
}
}
if ((_amode & D_OK) == D_OK) {
if ((Attributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY) {
__set_errno(EACCES);
return -1;
}
}
return 0;
}

View file

@ -1,47 +0,0 @@
#include "precomp.h"
#include <msvcrt/io.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
#define mode_t int
/*
* @implemented
*/
int _wchmod(const wchar_t* filename, mode_t mode)
{
DWORD FileAttributes = 0;
BOOLEAN Set = FALSE;
DPRINT("_wchmod('%S', %x)\n", filename, mode);
FileAttributes = GetFileAttributesW(filename);
if ( FileAttributes == -1 ) {
_dosmaperr(GetLastError());
return -1;
}
if ( mode == 0 )
return -1;
if (mode & _S_IWRITE) {
if (FileAttributes & FILE_ATTRIBUTE_READONLY) {
FileAttributes &= ~FILE_ATTRIBUTE_READONLY;
Set = TRUE;
}
} else {
if (!(FileAttributes & FILE_ATTRIBUTE_READONLY)) {
FileAttributes |= FILE_ATTRIBUTE_READONLY;
Set = TRUE;
}
}
if (Set && SetFileAttributesW(filename, FileAttributes) == FALSE) {
_dosmaperr(GetLastError());
return -1;
}
return 0;
}

View file

@ -1,15 +0,0 @@
#include <msvcrt/io.h>
#include <msvcrt/fcntl.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
/*
* @implemented
*/
int _wcreat(const wchar_t* filename, int mode)
{
DPRINT("_wcreat('%S', mode %x)\n", filename, mode);
return _wopen(filename,_O_CREAT|_O_TRUNC,mode);
}

View file

@ -1,226 +0,0 @@
#include "precomp.h"
#include <msvcrt/io.h>
#include <msvcrt/string.h>
#include <msvcrt/internal/file.h>
/*
* @implemented
*/
int _wfindfirst(const wchar_t* _name, struct _wfinddata_t* result)
{
WIN32_FIND_DATAW FindFileData;
wchar_t dir[MAX_PATH];
long hFindFile;
int len = 0;
if ( _name == NULL || _name[0] == 0 ) {
len = GetCurrentDirectoryW(MAX_PATH-4, dir);
if (dir[len-1] != L'\\') {
dir[len] = L'\\';
dir[len+1] = 0;
}
wcscat(dir, L"*.*");
} else {
wcscpy(dir, _name);
}
hFindFile = (long)FindFirstFileW(dir, &FindFileData);
if (hFindFile == -1) {
memset(result,0,sizeof(struct _wfinddata_t));
_dosmaperr(GetLastError());
return -1;
}
result->attrib = FindFileData.dwFileAttributes;
result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
result->size = FindFileData.nFileSizeLow;
wcsncpy(result->name,FindFileData.cFileName,MAX_PATH);
// if no wildcard the find file handle can be closed right away
// a return value of 0 can flag this.
if (!wcschr(dir, L'*') && !wcschr(dir, L'?')) {
_findclose(hFindFile);
return 0;
}
return hFindFile;
}
/*
* @implemented
*/
int _findfirsti64(const char *_name, struct _finddatai64_t *result)
{
WIN32_FIND_DATAA FindFileData;
char dir[MAX_PATH];
long hFindFile;
int len = 0;
if ( _name == NULL || _name[0] == 0 )
{
len = GetCurrentDirectoryA(MAX_PATH-4,dir);
if (dir[len-1] != '\\')
{
dir[len] = '\\';
dir[len+1] = 0;
}
strcat(dir, "*.*");
}
else
strcpy(dir, _name);
hFindFile = (long)FindFirstFileA(dir, &FindFileData);
if (hFindFile == -1)
{
memset(result,0,sizeof(struct _finddatai64_t));
_dosmaperr(GetLastError());
return -1;
}
result->attrib = FindFileData.dwFileAttributes;
result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
result->size =
(((__int64)FindFileData.nFileSizeLow)<<32) + FindFileData.nFileSizeLow;
strncpy(result->name,FindFileData.cFileName,MAX_PATH);
// if no wildcard the find file handle can be closed right away
// a return value of 0 can flag this.
if (!strchr(dir,'*') && !strchr(dir,'?')) {
_findclose(hFindFile);
return 0;
}
return hFindFile;
}
/*
* @implemented
*/
int _findnexti64(int handle, struct _finddatai64_t *result)
{
WIN32_FIND_DATAA FindFileData;
// check no wildcards or invalid handle
if (handle == 0 || handle == -1)
return 0;
if (!FindNextFileA((void *)handle, &FindFileData)) {
_dosmaperr(GetLastError());
return -1;
}
result->attrib = FindFileData.dwFileAttributes;
result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
result->size =
(((__int64)FindFileData.nFileSizeLow)<<32) + FindFileData.nFileSizeLow;
strncpy(result->name,FindFileData.cFileName,MAX_PATH);
return 0;
}
/*
* @implemented
*/
int _wfindfirsti64(const wchar_t *_name, struct _wfinddatai64_t *result)
{
WIN32_FIND_DATAW FindFileData;
wchar_t dir[MAX_PATH];
long hFindFile;
int len = 0;
if (_name == NULL || _name[0] == 0)
{
len = GetCurrentDirectoryW(MAX_PATH-4,dir);
if (dir[len-1] != L'\\')
{
dir[len] = L'\\';
dir[len+1] = 0;
}
wcscat(dir, L"*.*");
}
else
wcscpy(dir, _name);
hFindFile = (long)FindFirstFileW(dir, &FindFileData);
if (hFindFile == -1)
{
memset(result,0,sizeof(struct _wfinddatai64_t));
_dosmaperr(GetLastError());
return -1;
}
result->attrib = FindFileData.dwFileAttributes;
result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
result->size =
(((__int64)FindFileData.nFileSizeLow)<<32) + FindFileData.nFileSizeLow;
wcsncpy(result->name,FindFileData.cFileName,MAX_PATH);
// if no wildcard the find file handle can be closed right away
// a return value of 0 can flag this.
if (!wcschr(dir,L'*') && !wcschr(dir,L'?'))
{
_findclose(hFindFile);
return 0;
}
return hFindFile;
}
/*
* @implemented
*/
int _wfindnext(int handle, struct _wfinddata_t *result)
{
WIN32_FIND_DATAW FindFileData;
// check no wildcards or invalid handle
if (handle == 0 || handle == -1)
return 0;
if (!FindNextFileW((void *)handle, &FindFileData))
return -1;
result->attrib = FindFileData.dwFileAttributes;
result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
result->size = FindFileData.nFileSizeLow;
wcsncpy(result->name,FindFileData.cFileName, MAX_PATH);
return 0;
}
/*
* @implemented
*/
int _wfindnexti64(int handle, struct _wfinddatai64_t *result)
{
WIN32_FIND_DATAW FindFileData;
// check no wildcards or invalid handle
if (handle == 0 || handle == -1)
return 0;
if (!FindNextFileW((void *)handle, &FindFileData))
return -1;
result->attrib = FindFileData.dwFileAttributes;
result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
result->size =
(((__int64)FindFileData.nFileSizeLow)<<32) + FindFileData.nFileSizeLow;
wcsncpy(result->name,FindFileData.cFileName,MAX_PATH);
return 0;
}

View file

@ -1,78 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details
* PROJECT: ReactOS system libraries
* FILE: lib/msvcrt/io/mktemp.c
* PURPOSE: Makes a temp file based on a template
* PROGRAMER: DJ Delorie
Boudewijn Dekker
* UPDATE HISTORY:
* 28/12/98: Appropriated for the Reactos Kernel
*/
/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <msvcrt/stdio.h>
#include <msvcrt/string.h>
#include <msvcrt/io.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
/*
* @implemented
*/
wchar_t* _wmktemp (wchar_t *_template)
{
static int count = 0;
wchar_t *cp, *dp;
int i, len, xcount, loopcnt;
DPRINT("_wmktemp('%S')\n", _template);
len = wcslen (_template);
cp = _template + len;
xcount = 0;
while (xcount < 6 && cp > _template && cp[-1] == L'X')
xcount++, cp--;
if (xcount) {
dp = cp;
while (dp > _template && dp[-1] != L'/' && dp[-1] != L'\\' && dp[-1] != L':')
dp--;
/* Keep the first characters of the template, but turn the rest into
Xs. */
while (cp > dp + 8 - xcount) {
*--cp = L'X';
xcount = (xcount >= 6) ? 6 : 1 + xcount;
}
/* If dots occur too early -- squash them. */
while (dp < cp) {
if (*dp == L'.') *dp = L'a';
dp++;
}
/* Try to add ".tmp" to the filename. Truncate unused Xs. */
if (cp + xcount + 3 < _template + len)
wcscpy (cp + xcount, L".tmp");
else
cp[xcount] = 0;
/* This loop can run up to 2<<(5*6) times, or about 10^9 times. */
for (loopcnt = 0; loopcnt < (1 << (5 * xcount)); loopcnt++) {
int c = count++;
for (i = 0; i < xcount; i++, c >>= 5)
cp[i] = L"abcdefghijklmnopqrstuvwxyz012345"[c & 0x1f];
if (_waccess(_template,0) == -1)
return _template;
}
}
/* Failure: truncate the template and return NULL. */
*_template = 0;
return 0;
}

View file

@ -1,148 +0,0 @@
/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/msvcrt/io/open.c
* PURPOSE: Opens a file and translates handles to fileno
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
* 28/12/98: Created
*/
// rember to interlock the allocation of fileno when making this thread safe
// possibly store extra information at the handle
#include "precomp.h"
#if !defined(NDEBUG) && defined(DBG)
#include <msvcrt/stdarg.h>
#endif
#include <msvcrt/io.h>
#include <msvcrt/fcntl.h>
#include <msvcrt/sys/stat.h>
#include <msvcrt/stdlib.h>
#include <msvcrt/internal/file.h>
#include <msvcrt/string.h>
#include <msvcrt/share.h>
#include <msvcrt/errno.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
/*
* @implemented
*/
int _wopen(const wchar_t* _path, int _oflag, ...)
{
#if !defined(NDEBUG) && defined(DBG)
va_list arg;
int pmode;
#endif
HANDLE hFile;
DWORD dwDesiredAccess = 0;
DWORD dwShareMode = 0;
DWORD dwCreationDistribution = 0;
DWORD dwFlagsAndAttributes = 0;
SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE};
#if !defined(NDEBUG) && defined(DBG)
va_start(arg, _oflag);
pmode = va_arg(arg, int);
#endif
// DPRINT("_wopen('%S', %x, (%x))\n", _path, _oflag, pmode);
if ((_oflag & S_IREAD) == S_IREAD)
dwShareMode = FILE_SHARE_READ;
else if ( ( _oflag & S_IWRITE) == S_IWRITE) {
dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
}
/*
*
* _O_BINARY Opens file in binary (untranslated) mode. (See fopen for a description of binary mode.)
* _O_TEXT Opens file in text (translated) mode. (For more information, see Text and Binary Mode File I/O and fopen.)
*
* _O_APPEND Moves file pointer to end of file before every write operation.
*/
#if 0
if ((_oflag & _O_RDWR) == _O_RDWR)
dwDesiredAccess |= GENERIC_WRITE|GENERIC_READ | FILE_READ_DATA |
FILE_WRITE_DATA | FILE_READ_ATTRIBUTES |
FILE_WRITE_ATTRIBUTES;
else if ((_oflag & O_RDONLY) == O_RDONLY)
dwDesiredAccess |= GENERIC_READ | FILE_READ_DATA | FILE_READ_ATTRIBUTES |
FILE_WRITE_ATTRIBUTES;
else if ((_oflag & _O_WRONLY) == _O_WRONLY)
dwDesiredAccess |= GENERIC_WRITE | FILE_WRITE_DATA |
FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES;
#else
if ((_oflag & _O_WRONLY) == _O_WRONLY)
dwDesiredAccess |= GENERIC_WRITE | FILE_WRITE_DATA |
FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES;
else if ((_oflag & _O_RDWR) == _O_RDWR)
dwDesiredAccess |= GENERIC_WRITE|GENERIC_READ | FILE_READ_DATA |
FILE_WRITE_DATA | FILE_READ_ATTRIBUTES |
FILE_WRITE_ATTRIBUTES;
else //if ((_oflag & O_RDONLY) == O_RDONLY)
dwDesiredAccess |= GENERIC_READ | FILE_READ_DATA | FILE_READ_ATTRIBUTES |
FILE_WRITE_ATTRIBUTES;
#endif
if ((_oflag & S_IREAD) == S_IREAD)
dwShareMode |= FILE_SHARE_READ;
if ((_oflag & S_IWRITE) == S_IWRITE)
dwShareMode |= FILE_SHARE_WRITE;
if ((_oflag & (_O_CREAT | _O_EXCL)) == (_O_CREAT | _O_EXCL))
dwCreationDistribution |= CREATE_NEW;
else if ((_oflag & O_TRUNC) == O_TRUNC) {
if ((_oflag & O_CREAT) == O_CREAT)
dwCreationDistribution |= CREATE_ALWAYS;
else if ((_oflag & O_RDONLY) != O_RDONLY)
dwCreationDistribution |= TRUNCATE_EXISTING;
}
else if ((_oflag & _O_APPEND) == _O_APPEND)
dwCreationDistribution |= OPEN_EXISTING;
else if ((_oflag & _O_CREAT) == _O_CREAT)
dwCreationDistribution |= OPEN_ALWAYS;
else
dwCreationDistribution |= OPEN_EXISTING;
if ((_oflag & _O_RANDOM) == _O_RANDOM)
dwFlagsAndAttributes |= FILE_FLAG_RANDOM_ACCESS;
if ((_oflag & _O_SEQUENTIAL) == _O_SEQUENTIAL)
dwFlagsAndAttributes |= FILE_FLAG_SEQUENTIAL_SCAN;
if ((_oflag & _O_TEMPORARY) == _O_TEMPORARY)
dwFlagsAndAttributes |= FILE_FLAG_DELETE_ON_CLOSE;
if ((_oflag & _O_SHORT_LIVED) == _O_SHORT_LIVED)
dwFlagsAndAttributes |= FILE_FLAG_DELETE_ON_CLOSE;
if (_oflag & _O_NOINHERIT)
sa.bInheritHandle = FALSE;
hFile = CreateFileW(_path,
dwDesiredAccess,
dwShareMode,
&sa,
dwCreationDistribution,
dwFlagsAndAttributes,
NULL);
if (hFile == (HANDLE)-1) {
_dosmaperr(GetLastError());
return -1;
}
return __fileno_alloc(hFile,_oflag);
}
/*
* @implemented
*/
int _wsopen(wchar_t* path, int access, int shflag, int mode)
{
return _wopen((path), (access)|(shflag), (mode));
}

View file

@ -1,103 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/msvcrt/io/write.c
* PURPOSE: Writes to a file
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include "precomp.h"
#include <msvcrt/io.h>
#include <msvcrt/stdlib.h>
#include <msvcrt/string.h>
#include <msvcrt/internal/file.h>
#include <msvcrt/errno.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
#define BUFSIZE 4096
/*
void ReportLastError(void)
{
DWORD error = GetLastError();
if (error != ERROR_SUCCESS) {
PTSTR msg;
if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
0, error, MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT), (PTSTR)&msg, 0, NULL)) {
printf("ReportLastError() %d - %s\n", error, msg);
} else {
printf("ReportLastError() %d - unknown error\n", error);
}
LocalFree(msg);
}
}
*/
/*
* @implemented
*/
size_t _write(int _fd, const void* _buf, size_t _nbyte)
{
char *tmp, *in, *out;
int result;
unsigned int count;
DWORD wbyte;
DPRINT("_write(fd %d, buf %x, nbyte %d)\n", _fd, _buf, _nbyte);
if (__fileno_getmode(_fd) & O_TEXT) {
result = _nbyte;
tmp = (char*) malloc(BUFSIZE);
if (tmp == NULL) {
__set_errno(ENOMEM);
return -1;
}
count = BUFSIZE;
out = tmp;
in = (char*) _buf;
while (_nbyte--) {
if (*in == 0x0a) {
*out++ = 0x0d;
count--;
if (count == 0) {
if (!WriteFile(_get_osfhandle(_fd), tmp, BUFSIZE, &wbyte, NULL)) {
//ReportLastError();
_dosmaperr(GetLastError());
result = -1;
break;
}
if (wbyte < BUFSIZE) {
result = in - (char*)_buf;
break;
}
count = BUFSIZE;
out = tmp;
}
}
*out++ = *in++;
count--;
if (count == 0 || _nbyte == 0) {
if (!WriteFile(_get_osfhandle(_fd), tmp, BUFSIZE - count, &wbyte, NULL)) {
_dosmaperr(GetLastError());
result = -1;
break;
}
if (wbyte < (BUFSIZE - count)) {
result = in - (char*)_buf;
break;
}
count = BUFSIZE;
out = tmp;
}
}
free(tmp);
return result;
} else {
if(!WriteFile(_get_osfhandle(_fd), _buf, _nbyte, &wbyte, NULL)) {
_dosmaperr(GetLastError());
return -1;
}
return wbyte;
}
}

View file

@ -1,29 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/msvcrt/io/unlink.c
* PURPOSE: Deletes a file
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include "precomp.h"
#include <msvcrt/io.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
#include <msvcrt/internal/file.h>
/*
* @implemented
*/
int _wunlink(const wchar_t* filename)
{
DPRINT("_wunlink('%S')\n", filename);
if (!DeleteFileW(filename)) {
_dosmaperr(GetLastError());
return -1;
}
return 0;
}

View file

@ -1,25 +0,0 @@
#include <msvcrt/stdio.h>
#include <msvcrt/io.h>
#include <msvcrt/errno.h>
#include <msvcrt/sys/utime.h>
#include <msvcrt/internal/file.h>
/*
* @implemented
*/
int _wutime(const wchar_t* filename, struct _utimbuf* buf)
{
int fn;
int ret;
fn = _wopen(filename, _O_RDWR);
if (fn == -1) {
__set_errno(EBADF);
return -1;
}
ret = _futime(fn, buf);
if (_close(fn) < 0)
return -1;
return ret;
}

View file

@ -1,203 +0,0 @@
#include "precomp.h"
#include <msvcrt/stdio.h>
#include <msvcrt/locale.h>
#include <msvcrt/string.h>
#include <limits.h>
#include <msvcrt/internal/tls.h>
#include <msvcrt/stdlib.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
unsigned int __setlc_active;
unsigned int __unguarded_readlc_active;
int _current_category; /* used by setlocale */
const char *_current_locale;
int parse_locale(char *locale, char *lang, char *country, char *code_page);
/*
* @unimplemented
*/
char *setlocale(int category, const char *locale)
{
char lang[100];
char country[100];
char code_page[100];
if (NULL != locale) {
parse_locale((char *)locale,lang,country,code_page);
}
//printf("%s %s %s %s\n",locale,lang,country,code_page);
switch ( category )
{
case LC_COLLATE:
break;
case LC_CTYPE:
break;
case LC_MONETARY:
break;
case LC_NUMERIC:
break;
case LC_TIME:
break;
case LC_ALL:
break;
default:
break;
}
return "C";
}
/*
locale "lang[_country[.code_page]]"
| ".code_page"
| ""
| NULL
*/
int parse_locale(char *locale, char *lang, char *country, char *code_page)
{
while ( *locale != 0 && *locale != '.' && *locale != '_' )
{
*lang = *locale;
lang++;
locale++;
}
*lang = 0;
if ( *locale == '_' ) {
locale++;
while ( *locale != 0 && *locale != '.' )
{
*country = *locale;
country++;
locale++;
}
}
*country = 0;
if ( *locale == '.' ) {
locale++;
while ( *locale != 0 && *locale != '.' )
{
*code_page = *locale;
code_page++;
locale++;
}
}
*code_page = 0;
return 0;
}
const struct map_lcid2str {
short langid;
const char *langname;
const char *country;
} languages[]={
{0x0409,"English", "United States"},
{0x0809,"English", "United Kingdom"},
{0x0000,"Unknown", "Unknown"}
};
const struct map_cntr {
const char *abrev;
const char *country;
} abrev[] = {
{"britain", "united kingdom"},
{"england", "united kingdom"},
{"gbr", "united kingdom"},
{"great britain", "united kingdom"},
{"uk", "united kingdom"},
{"united kingdom", "united kingdom"},
{"united-kingdom", "united kingdom"},
{"america", "united states" },
{"united states", "united states"},
{"united-states", "united states"},
{"us", "united states"},
{"usa" "united states"}
};
struct lconv _lconv = {
".", // decimal_point
",", // thousands_sep
"", // grouping;
"DOL", // int_curr_symbol
"$", // currency_symbol
".", // mon_decimal_point
",", // mon_thousands_sep
"", // mon_grouping;
"+", // positive_sign
"-", // negative_sign
127, // int_frac_digits
127, // frac_digits
127, // p_cs_precedes
127, // p_sep_by_space
127, // n_cs_precedes
127, // n_sep_by_space
127, // p_sign_posn;
127 // n_sign_posn;
};
/*
* @implemented
*/
struct lconv *localeconv(void)
{
return (struct lconv *) &_lconv;
}
/*********************************************************************
* _setmbcp (MSVCRT.@)
*
* @unimplemented
*/
void _setmbcp(int cp)
{
DPRINT1("_setmbcp - stub\n");
return;
}
/*********************************************************************
* __lc_collate_cp (MSVCRT.@)
*
* @unimplemented
*/
void __lc_collate_cp(int cp)
{
DPRINT1("__lc_collate_cp - stub\n");
return;
}
/*********************************************************************
* __lc_handle (MSVCRT.@)
*
* @unimplemented
*/
void __lc_handle(void)
{
DPRINT1("__lc_handle - stub\n");
return;
}
/*********************************************************************
* __lc_codepage (MSVCRT.@)
*
* @unimplemented
*/
void __lc_codepage(void)
{
DPRINT1("__lc_codepage - stub\n");
return;
}

Some files were not shown because too many files have changed in this diff Show more