- Remove leftovers.

svn path=/trunk/; revision=26096
This commit is contained in:
Alex Ionescu 2007-03-14 20:28:28 +00:00
parent 85985d712e
commit f96362240e
386 changed files with 0 additions and 27521 deletions

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,73 +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 <precomp.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,36 +0,0 @@
/*
* COPYRIGHT: Winehq
* PROJECT: wine
* FILE: msvcrt/conio/cprintf.c
* PURPOSE: C Runtime
* PROGRAMMER: Magnus Olsen (Imported from wine cvs 2006-05-23)
*/
#include <precomp.h>
/*
* @implemented
*/
int
_cprintf(const char *fmt, ...)
{
char buf[2048], *mem = buf;
int written, resize = sizeof(buf), retval;
va_list valist;
while ((written = _vsnprintf( mem, resize, fmt, valist )) == -1 ||
written > resize)
{
resize = (written == -1 ? resize * 2 : written + 1);
if (mem != buf)
free (mem);
if (!(mem = (char *)malloc(resize)))
return EOF;
va_start( valist, fmt );
}
va_end(valist);
retval = _cputs( mem );
if (mem != buf)
free (mem);
return retval;
}

View file

@ -1,23 +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: Ariadne
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include <precomp.h>
/*
* @implemented
*/
int _cputs(const char *_str)
{
int len = strlen(_str);
DWORD written = 0;
if (!WriteFile( fdinfo(stdout->_file)->hFile ,_str,len,&written,NULL))
return -1;
return 0;
}

View file

@ -1,55 +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: Ariadne
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include <precomp.h>
/*
* @implemented
*/
int _getch(void)
{
DWORD NumberOfCharsRead = 0;
char c;
HANDLE ConsoleHandle;
BOOL RestoreMode;
DWORD ConsoleMode;
if (char_avail) {
c = ungot_char;
char_avail = 0;
} else {
/*
* _getch() is documented to NOT echo characters. Testing shows it
* doesn't wait for a CR either. So we need to switch off
* ENABLE_ECHO_INPUT and ENABLE_LINE_INPUT if they're currently
* switched on.
*/
ConsoleHandle = (HANDLE) _get_osfhandle(stdin->_file);
RestoreMode = GetConsoleMode(ConsoleHandle, &ConsoleMode) &&
(0 != (ConsoleMode &
(ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT)));
if (RestoreMode) {
SetConsoleMode(ConsoleHandle,
ConsoleMode & (~ (ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT)));
}
ReadConsoleA((HANDLE)_get_osfhandle(stdin->_file),
&c,
1,
&NumberOfCharsRead,
NULL);
if (RestoreMode) {
SetConsoleMode(ConsoleHandle, ConsoleMode);
}
}
if (c == 10)
c = 13;
return c;
}

View file

@ -1,29 +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
Ariadne
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include <precomp.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,30 +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: Ariadne
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include <precomp.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,24 +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: Ariadne
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include <precomp.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,29 +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
Ariadne [ Adapted from djgpp libc ]
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include <precomp.h>
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,415 +0,0 @@
<module name="crt" type="staticlibrary">
<include base="crt">.</include>
<include base="crt">include</include>
<define name="_DISABLE_TIDENTS" />
<define name="__MINGW_IMPORT">extern</define>
<define name="__USE_W32API" />
<define name="_WIN32_IE">0x600</define>
<define name="_WIN32_WINNT">0x501</define>
<define name="__REACTOS__" />
<define name="USE_MSVCRT_PREFIX" />
<define name="_MSVCRT_LIB_" />
<define name="_MSVCRT_" />
<define name="_MT" />
<pch>precomp.h</pch>
<directory name="conio">
<file>cgets.c</file>
<file>cprintf.c</file>
<file>cputs.c</file>
<file>getch.c</file>
<file>getche.c</file>
<file>kbhit.c</file>
<file>putch.c</file>
<file>ungetch.c</file>
</directory>
<directory name="direct">
<file>chdir.c</file>
<file>chdrive.c</file>
<file>getcwd.c</file>
<file>getdcwd.c</file>
<file>getdfree.c</file>
<file>getdrive.c</file>
<file>mkdir.c</file>
<file>rmdir.c</file>
<file>wchdir.c</file>
<file>wgetcwd.c</file>
<file>wgetdcwd.c</file>
<file>wmkdir.c</file>
<file>wrmdir.c</file>
</directory>
<directory name="except">
<file>abnorter.c</file>
<file>exhand2.c</file>
<file>matherr.c</file>
<if property="ARCH" value="i386">
<directory name="i386">
<file>seh.s</file>
<file>unwind.c</file>
</directory>
</if>
<file>xcptfil.c</file>
</directory>
<directory name="float">
<file>chgsign.c</file>
<file>copysign.c</file>
<file>fpclass.c</file>
<file>fpecode.c</file>
<file>fpreset.c</file>
<file>isnan.c</file>
<file>nafter.c</file>
<file>scalb.c</file>
<if property="ARCH" value="i386">
<directory name="i386">
<file>clearfp.c</file>
<file>cntrlfp.c</file>
<file>logb.c</file>
<file>statfp.c</file>
</directory>
</if>
</directory>
<directory name="io">
<file>access.c</file>
<file>chmod.c</file>
<file>chsize.c</file>
<file>close.c</file>
<file>commit.c</file>
<file>create.c</file>
<file>dup.c</file>
<file>dup2.c</file>
<file>eof.c</file>
<file>filelen.c</file>
<file>fileleni.c</file>
<file>find.c</file>
<file>fmode.c</file>
<file>isatty.c</file>
<file>locking.c</file>
<file>lseek.c</file>
<file>lseeki64.c</file>
<file>mktemp.c</file>
<file>open.c</file>
<file>pipe.c</file>
<file>read.c</file>
<file>setmode.c</file>
<file>sopen.c</file>
<file>stubs.c</file>
<file>tell.c</file>
<file>telli64.c</file>
<file>umask.c</file>
<file>unlink.c</file>
<file>utime.c</file>
<file>waccess.c</file>
<file>wchmod.c</file>
<file>wcreate.c</file>
<file>wfind.c</file>
<file>wmktemp.c</file>
<file>wopen.c</file>
<file>write.c</file>
<file>wunlink.c</file>
<file>wutime.c</file>
</directory>
<directory name="locale">
<file>locale.c</file>
</directory>
<directory name="math">
<file>acos.c</file>
<file>adjust.c</file>
<file>asin.c</file>
<file>cabs.c</file>
<file>cosh.c</file>
<file>frexp.c</file>
<file>huge_val.c</file>
<file>hypot.c</file>
<file>j0_y0.c</file>
<file>j1_y1.c</file>
<file>jn_yn.c</file>
<file>modf.c</file>
<file>s_modf.c</file>
<file>sinh.c</file>
<file>stubs.c</file>
<file>tanh.c</file>
<file>pow_asm.c</file>
<if property="ARCH" value="i386">
<directory name="i386">
<file>atan2.c</file>
<file>exp.c</file>
<file>fmod.c</file>
<file>ldexp.c</file>
<file>atan_asm.s</file>
<file>pow_asm.s</file>
<file>log10_asm.s</file>
</directory>
</if>
<ifnot property="ARCH" value="i386">
</ifnot>
</directory>
<directory name="mbstring">
<file>hanzen.c</file>
<file>ischira.c</file>
<file>iskana.c</file>
<file>iskmoji.c</file>
<file>iskpun.c</file>
<file>islead.c</file>
<file>islwr.c</file>
<file>ismbal.c</file>
<file>ismbaln.c</file>
<file>ismbc.c</file>
<file>ismbgra.c</file>
<file>ismbkaln.c</file>
<file>ismblead.c</file>
<file>ismbpri.c</file>
<file>ismbpun.c</file>
<file>ismbtrl.c</file>
<file>isuppr.c</file>
<file>jistojms.c</file>
<file>jmstojis.c</file>
<file>mbbtype.c</file>
<file>mbccpy.c</file>
<file>mbclen.c</file>
<file>mbscat.c</file>
<file>mbschr.c</file>
<file>mbscmp.c</file>
<file>mbscoll.c</file>
<file>mbscpy.c</file>
<file>mbscspn.c</file>
<file>mbsdec.c</file>
<file>mbsdup.c</file>
<file>mbsicmp.c</file>
<file>mbsicoll.c</file>
<file>mbsinc.c</file>
<file>mbslen.c</file>
<file>mbslwr.c</file>
<file>mbsncat.c</file>
<file>mbsnccnt.c</file>
<file>mbsncmp.c</file>
<file>mbsncoll.c</file>
<file>mbsncpy.c</file>
<file>mbsnextc.c</file>
<file>mbsnicmp.c</file>
<file>mbsnicoll.c</file>
<file>mbsninc.c</file>
<file>mbsnset.c</file>
<file>mbspbrk.c</file>
<file>mbsrchr.c</file>
<file>mbsrev.c</file>
<file>mbsset.c</file>
<file>mbsspn.c</file>
<file>mbsspnp.c</file>
<file>mbsstr.c</file>
<file>mbstok.c</file>
<file>mbstrlen.c</file>
<file>mbsupr.c</file>
</directory>
<directory name="misc">
<file>amsg.c</file>
<file>assert.c</file>
<file>crtmain.c</file>
<file>environ.c</file>
<file>getargs.c</file>
<file>initterm.c</file>
<file>lock.c</file>
<file>purecall.c</file>
<file>stubs.c</file>
<file>tls.c</file>
</directory>
<directory name="process">
<file>_cwait.c</file>
<file>_system.c</file>
<file>dll.c</file>
<file>process.c</file>
<file>procid.c</file>
<file>thread.c</file>
<file>threadid.c</file>
<file>threadx.c</file>
<file>wprocess.c</file>
</directory>
<directory name="search">
<file>lfind.c</file>
<file>lsearch.c</file>
</directory>
<directory name="setjmp">
<if property="ARCH" value="i386">
<directory name="i386">
<file>setjmp.s</file>
</directory>
</if>
</directory>
<directory name="signal">
<file>signal.c</file>
<file>xcptinfo.c</file>
</directory>
<directory name="stdio">
<file>allocfil.c</file>
<file>clearerr.c</file>
<file>fclose.c</file>
<file>fdopen.c</file>
<file>feof.c</file>
<file>ferror.c</file>
<file>fflush.c</file>
<file>fgetc.c</file>
<file>fgetchar.c</file>
<file>fgetpos.c</file>
<file>fgets.c</file>
<file>fgetws.c</file>
<file>filbuf.c</file>
<file>fileno.c</file>
<file>flsbuf.c</file>
<file>fopen.c</file>
<file>fprintf.c</file>
<file>fputc.c</file>
<file>fputchar.c</file>
<file>fputs.c</file>
<file>fputws.c</file>
<file>fread.c</file>
<file>freopen.c</file>
<file>fseek.c</file>
<file>fsetpos.c</file>
<file>fsopen.c</file>
<file>ftell.c</file>
<file>fwalk.c</file>
<file>fwprintf.c</file>
<file>fwrite.c</file>
<file>getc.c</file>
<file>getchar.c</file>
<file>gets.c</file>
<file>getw.c</file>
<file>perror.c</file>
<file>popen.c</file>
<file>printf.c</file>
<file>putc.c</file>
<file>putchar.c</file>
<file>puts.c</file>
<file>putw.c</file>
<file>putwchar.c</file>
<file>remove.c</file>
<file>rename.c</file>
<file>rewind.c</file>
<file>rmtmp.c</file>
<file>setbuf.c</file>
<file>setvbuf.c</file>
<file>sprintf.c</file>
<file>swprintf.c</file>
<file>stdhnd.c</file>
<file>tempnam.c</file>
<file>tmpfile.c</file>
<file>tmpnam.c</file>
<file>ungetc.c</file>
<file>ungetwc.c</file>
<file>vfprintf.c</file>
<file>vfwprint.c</file>
<file>vprintf.c</file>
<file>vsprintf.c</file>
<file>vswprintf.c</file>
<file>vwprintf.c</file>
<file>wfdopen.c</file>
<file>wfopen.c</file>
<file>wfreopen.c</file>
<file>wfsopen.c</file>
<file>wpopen.c</file>
<file>wprintf.c</file>
<file>wremove.c</file>
<file>wrename.c</file>
<file>wtempnam.c</file>
<file>wtmpnam.c</file>
</directory>
<directory name="stdlib">
<file>_exit.c</file>
<file>abort.c</file>
<file>atexit.c</file>
<file>atof.c</file>
<file>div.c</file>
<file>ecvt.c</file>
<file>ecvtbuf.c</file>
<file>errno.c</file>
<file>fcvt.c</file>
<file>fcvtbuf.c</file>
<file>fullpath.c</file>
<file>gcvt.c</file>
<file>getenv.c</file>
<file>ldiv.c</file>
<file>makepath.c</file>
<file>malloc.c</file>
<file>mbtowc.c</file>
<file>obsol.c</file>
<file>putenv.c</file>
<file>rand.c</file>
<file>rot.c</file>
<file>senv.c</file>
<file>strtod.c</file>
<file>strtoul.c</file>
<file>strtoull.c</file>
<file>swab.c</file>
<file>wcstod.c</file>
<file>wcstombs.c</file>
<file>wctomb.c</file>
<file>wfulpath.c</file>
<file>wputenv.c</file>
<file>wsenv.c</file>
<file>wsplitp.c</file>
<file>wmakpath.c</file>
</directory>
<directory name="string">
<file>lasttok.c</file>
<file>strcoll.c</file>
<file>strdup.c</file>
<file>strerror.c</file>
<file>strncoll.c</file>
<file>strrev.c</file>
<file>strset.c</file>
<file>strstr.c</file>
<file>strtok.c</file>
<file>strupr.c</file>
<file>strxfrm.c</file>
</directory>
<directory name="sys_stat">
<file>fstat.c</file>
<file>fstati64.c</file>
<file>futime.c</file>
<file>stat.c</file>
<file>wstat.c</file>
<file>systime.c</file>
</directory>
<directory name="time">
<file>clock.c</file>
<file>ctime.c</file>
<file>difftime.c</file>
<file>ftime.c</file>
<file>strdate.c</file>
<file>strftime.c</file>
<file>strtime.c</file>
<file>time.c</file>
<file>tz_vars.c</file>
<file>wctime.c</file>
<file>wstrdate.c</file>
<file>wstrtime.c</file>
</directory>
<directory name="wstring">
<file>wcscoll.c</file>
<file>wcscspn.c</file>
<file>wcsdup.c</file>
<file>wcsicmp.c</file>
<file>wcslwr.c</file>
<file>wcsnicmp.c</file>
<file>wcspbrk.c</file>
<file>wcsrev.c</file>
<file>wcsset.c</file>
<file>wcsspn.c</file>
<file>wcsstr.c</file>
<file>wcstok.c</file>
<file>wcsupr.c</file>
<file>wcsxfrm.c</file>
<file>wlasttok.c</file>
</directory>
<directory name="wine">
<file>cpp.c</file>
<file>cppexcept.c</file>
<file>heap.c</file>
<file>scanf.c</file>
<file>thread.c</file>
<file>undname.c</file>
</directory>
</module>

View file

@ -1,16 +0,0 @@
#include <precomp.h>
#include <ctype.h>
#include <direct.h>
#include <tchar.h>
/*
* @implemented
*/
int _tchdir(const _TCHAR* _path)
{
if (!SetCurrentDirectory(_path)) {
_dosmaperr(_path?GetLastError():0);
return -1;
}
return 0;
}

View file

@ -1,45 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crt/??????
* PURPOSE: Unknown
* PROGRAMER: Unknown
* UPDATE HISTORY:
* 25/11/05: Added license header
*/
#include <precomp.h>
/*
* @implemented
*
* _chdrive (MSVCRT.@)
*
* Change the current drive.
*
* PARAMS
* newdrive [I] Drive number to change to (1 = 'A', 2 = 'B', ...)
*
* RETURNS
* Success: 0. The current drive is set to newdrive.
* Failure: -1. errno indicates the error.
*
* NOTES
* See SetCurrentDirectoryA.
*/
int _chdrive(int newdrive)
{
WCHAR buffer[] = L"A:";
buffer[0] += newdrive - 1;
if (!SetCurrentDirectoryW( buffer ))
{
_dosmaperr(GetLastError());
if (newdrive <= 0)
{
__set_errno(EACCES);
}
return -1;
}
return 0;
}

View file

@ -1,33 +0,0 @@
#include <precomp.h>
#include <direct.h>
#include <stdlib.h>
#include <tchar.h>
/*
* @implemented
*/
_TCHAR* _tgetcwd(_TCHAR* buf, int size)
{
_TCHAR dir[MAX_PATH];
DWORD dir_len = GetCurrentDirectory(MAX_PATH,dir);
if (dir_len == 0)
{
_dosmaperr(GetLastError());
return NULL; /* FIXME: Real return value untested */
}
if (!buf)
{
return _tcsdup(dir);
}
if (dir_len >= (DWORD)size)
{
__set_errno(ERANGE);
return NULL; /* buf too small */
}
_tcscpy(buf,dir);
return buf;
}

View file

@ -1,62 +0,0 @@
#include <precomp.h>
#include <direct.h>
#include <internal/debug.h>
#include <tchar.h>
/*
* @implemented
*
* _getdcwd (MSVCRT.@)
*
* Get the current working directory on a given disk.
*
* PARAMS
* drive [I] Drive letter to get the current working directory from.
* buf [O] Destination for the current working directory.
* size [I] Length of drive in characters.
*
* RETURNS
* Success: If drive is NULL, returns an allocated string containing the path.
* Otherwise populates drive with the path and returns it.
* Failure: NULL. errno indicates the error.
*/
_TCHAR* _tgetdcwd(int drive, _TCHAR * buf, int size)
{
static _TCHAR* dummy;
TRACE(":drive %d(%c), size %d\n",drive, drive + 'A' - 1, size);
if (!drive || drive == _getdrive())
return _tgetcwd(buf,size); /* current */
else
{
_TCHAR dir[MAX_PATH];
_TCHAR drivespec[] = _T("A:");
int dir_len;
drivespec[0] += drive - 1;
if (GetDriveType(drivespec) < DRIVE_REMOVABLE)
{
__set_errno(EACCES);
return NULL;
}
/* GetFullPathName for X: means "get working directory on drive X",
* just like passing X: to SetCurrentDirectory means "switch to working
* directory on drive X". -Gunnar */
dir_len = GetFullPathName(drivespec,MAX_PATH,dir,&dummy);
if (dir_len >= size || dir_len < 1)
{
__set_errno(ERANGE);
return NULL; /* buf too small */
}
TRACE(":returning '%s'\n", dir);
if (!buf)
return _tcsdup(dir); /* allocate */
_tcscpy(buf,dir);
}
return buf;
}

View file

@ -1,23 +0,0 @@
#include <precomp.h>
#include <ctype.h>
#include <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,35 +0,0 @@
#include <precomp.h>
#include <ctype.h>
#include <direct.h>
/*
* @implemented
*
* _getdrive (MSVCRT.@)
*
* Get the current drive number.
*
* PARAMS
* None.
*
* RETURNS
* Success: The drive letter number from 1 to 26 ("A:" to "Z:").
* Failure: 0.
*/
int _getdrive(void)
{
WCHAR buffer[MAX_PATH];
if (GetCurrentDirectoryW( MAX_PATH, buffer ) &&
buffer[0] >= 'A' && buffer[0] <= 'z' && buffer[1] == ':')
return towupper(buffer[0]) - 'A' + 1;
return 0;
}
/*
* @implemented
*/
unsigned long _getdrives(void)
{
return GetLogicalDrives();
}

View file

@ -1,15 +0,0 @@
#include <precomp.h>
#include <direct.h>
#include <tchar.h>
/*
* @implemented
*/
int _tmkdir(const _TCHAR* _path)
{
if (!CreateDirectory(_path, NULL)) {
_dosmaperr(GetLastError());
return -1;
}
return 0;
}

View file

@ -1,15 +0,0 @@
#include <precomp.h>
#include <direct.h>
#include <tchar.h>
/*
* @implemented
*/
int _trmdir(const _TCHAR* _path)
{
if (!RemoveDirectory(_path)) {
_dosmaperr(GetLastError());
return -1;
}
return 0;
}

View file

@ -1,5 +0,0 @@
#define UNICODE
#define _UNICODE
#include "chdir.c"

View file

@ -1,5 +0,0 @@
#define UNICODE
#define _UNICODE
#include "getcwd.c"

View file

@ -1,5 +0,0 @@
#define UNICODE
#define _UNICODE
#include "getdcwd.c"

View file

@ -1,4 +0,0 @@
#define UNICODE
#define _UNICODE
#include "mkdir.c"

View file

@ -1,4 +0,0 @@
#define UNICODE
#define _UNICODE
#include "rmdir.c"

View file

@ -1,16 +0,0 @@
#include <precomp.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,380 +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
test %ebx, %ebx
je .lu2_done
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:
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,72 +0,0 @@
#define WIN32_NO_STATUS
#include <precomp.h>
#include <windows.h>
#define NTOS_MODE_USER
#include <ndk/umtypes.h>
#include <ndk/extypes.h>
#include <ndk/rtlfuncs.h>
/*
* @implemented
*/
void __cdecl
_global_unwind2(PEXCEPTION_REGISTRATION_RECORD RegistrationFrame)
{
#ifdef __GNUC__
RtlUnwind(RegistrationFrame, &&__ret_label, NULL, 0);
__ret_label:
// return is important
return;
#else
#endif
}
/* VC++ extensions to Win32 SEH */
typedef struct _SCOPETABLE
{
int previousTryLevel;
int (*lpfnFilter)(PEXCEPTION_POINTERS);
int (*lpfnHandler)(void);
} SCOPETABLE, *PSCOPETABLE;
typedef struct _MSVCRT_EXCEPTION_FRAME
{
PEXCEPTION_REGISTRATION_RECORD *prev;
void (*handler)(PEXCEPTION_RECORD, PEXCEPTION_REGISTRATION_RECORD,
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,33 +0,0 @@
#include <precomp.h>
#include <math.h>
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,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,33 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crt/??????
* PURPOSE: Unknown
* PROGRAMER: Unknown
* UPDATE HISTORY:
* 25/11/05: Added license header
*/
#include <precomp.h>
#include <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,36 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crt/??????
* PURPOSE: Unknown
* PROGRAMER: Unknown
* UPDATE HISTORY:
* 25/11/05: Added license header
*/
#include <precomp.h>
#include <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,86 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crt/??????
* PURPOSE: Unknown
* PROGRAMER: Unknown
* UPDATE HISTORY:
* 25/11/05: Added license header
*/
#include <precomp.h>
#include <math.h>
#include <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 */
#if __MINGW32_MAJOR_VERSION < 3 || __MINGW32_MINOR_VERSION < 3
#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
#endif
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,20 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crt/??????
* PURPOSE: Unknown
* PROGRAMER: Unknown
* UPDATE HISTORY:
* 25/11/05: Added license header
*/
#include <precomp.h>
#include <internal/tls.h>
/*
* @implemented
*/
int * __fpecode(void)
{
return(&(GetThreadData()->fpecode));
}

View file

@ -1,21 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crt/??????
* PURPOSE: Unknown
* PROGRAMER: Unknown
* UPDATE HISTORY:
* 25/11/05: Added license header
*/
#include <precomp.h>
/*
* @unimplemented
*/
void _fpreset(void)
{
/* FIXME: This causes an exception */
// __asm__ __volatile__("fninit\n\t");
return;
}

View file

@ -1,29 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crt/??????
* PURPOSE: Unknown
* PROGRAMER: Unknown
* UPDATE HISTORY:
* 25/11/05: Added license header
*/
#include <precomp.h>
unsigned int _statusfp( void );
/*
* @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 <precomp.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,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 <precomp.h>
double _logb (double __x)
{
register double __val;
#ifdef __GNUC__
register double __junk;
__asm __volatile__
("fxtract\n\t"
: "=t" (__junk), "=u" (__val) : "0" (__x));
#else
#endif /*__GNUC__*/
return __val;
}

View file

@ -1,29 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crt/??????
* PURPOSE: Unknown
* PROGRAMER: Unknown
* UPDATE HISTORY:
* 25/11/05: Added license header
*/
#include <precomp.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,96 +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 <precomp.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,25 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crt/??????
* PURPOSE: Unknown
* PROGRAMER: Unknown
* UPDATE HISTORY:
* 25/11/05: Added license header
*/
#include <precomp.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,30 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crt/??????
* PURPOSE: Unknown
* PROGRAMER: Unknown
* UPDATE HISTORY:
* 25/11/05: Added license header
*/
#include <precomp.h>
#include <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,171 +0,0 @@
/*
* float.h
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
* Constants related to floating point arithmetic.
*
* Also included here are some non-ANSI bits for accessing the floating
* point controller.
*
* NOTE: GCC provides float.h, but it doesn't include the non-standard
* stuff for accessing the fp controller. We include_next the
* GCC-supplied header and just define the MS-specific extensions
* here.
*
*/
#ifdef __GNUC__
#include_next <float.h>
#endif
#ifndef _MINGW_FLOAT_H_
#define _MINGW_FLOAT_H_
/* All the headers include this file. */
#ifdef __GNUC__
#include <_mingw.h>
#endif
/*
* Functions and definitions for controlling the FPU.
*/
#ifndef __STRICT_ANSI__
/* TODO: These constants are only valid for x86 machines */
/* Control word masks for unMask */
#define _MCW_EM 0x0008001F /* Error masks */
#define _MCW_IC 0x00040000 /* Infinity */
#define _MCW_RC 0x00000300 /* Rounding */
#define _MCW_PC 0x00030000 /* Precision */
/* Control word values for unNew (use with related unMask above) */
#define _EM_INVALID 0x00000010
#define _EM_DENORMAL 0x00080000
#define _EM_ZERODIVIDE 0x00000008
#define _EM_OVERFLOW 0x00000004
#define _EM_UNDERFLOW 0x00000002
#define _EM_INEXACT 0x00000001
#define _IC_AFFINE 0x00040000
#define _IC_PROJECTIVE 0x00000000
#define _RC_CHOP 0x00000300
#define _RC_UP 0x00000200
#define _RC_DOWN 0x00000100
#define _RC_NEAR 0x00000000
#define _PC_24 0x00020000
#define _PC_53 0x00010000
#define _PC_64 0x00000000
/* These are also defined in Mingw math.h, needed to work around
GCC build issues. */
/* Return values for fpclass. */
#ifndef __MINGW_FPCLASS_DEFINED
#define __MINGW_FPCLASS_DEFINED 1
#define _FPCLASS_SNAN 0x0001 /* Signaling "Not a Number" */
#define _FPCLASS_QNAN 0x0002 /* Quiet "Not a Number" */
#define _FPCLASS_NINF 0x0004 /* Negative Infinity */
#define _FPCLASS_NN 0x0008 /* Negative Normal */
#define _FPCLASS_ND 0x0010 /* Negative Denormal */
#define _FPCLASS_NZ 0x0020 /* Negative Zero */
#define _FPCLASS_PZ 0x0040 /* Positive Zero */
#define _FPCLASS_PD 0x0080 /* Positive Denormal */
#define _FPCLASS_PN 0x0100 /* Positive Normal */
#define _FPCLASS_PINF 0x0200 /* Positive Infinity */
#endif /* __MINGW_FPCLASS_DEFINED */
/* invalid subconditions (_SW_INVALID also set) */
#define _SW_UNEMULATED 0x0040 /* unemulated instruction */
#define _SW_SQRTNEG 0x0080 /* square root of a neg number */
#define _SW_STACKOVERFLOW 0x0200 /* FP stack overflow */
#define _SW_STACKUNDERFLOW 0x0400 /* FP stack underflow */
/* Floating point error signals and return codes */
#define _FPE_INVALID 0x81
#define _FPE_DENORMAL 0x82
#define _FPE_ZERODIVIDE 0x83
#define _FPE_OVERFLOW 0x84
#define _FPE_UNDERFLOW 0x85
#define _FPE_INEXACT 0x86
#define _FPE_UNEMULATED 0x87
#define _FPE_SQRTNEG 0x88
#define _FPE_STACKOVERFLOW 0x8a
#define _FPE_STACKUNDERFLOW 0x8b
#define _FPE_EXPLICITGEN 0x8c /* raise( SIGFPE ); */
#ifndef DBL_MAX_10_EXP
#define DBL_MAX_10_EXP 308
#endif
#ifndef S_IFIFO
#define S_IFIFO -1
#endif
#ifndef UINT64_MAX
#define UINT64_MAX 0xffffffffffffffff
#endif
#ifndef RC_INVOKED
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _CRTIMP
#ifdef _DLL
#define _CRTIMP __declspec(dllimport)
#else
#define _CRTIMP
#endif /* _DLL */
#endif
/* Set the FPU control word as cw = (cw & ~unMask) | (unNew & unMask),
* i.e. change the bits in unMask to have the values they have in unNew,
* leaving other bits unchanged. */
_CRTIMP unsigned int __cdecl _controlfp (unsigned int unNew, unsigned int unMask);
_CRTIMP unsigned int __cdecl _control87 (unsigned int unNew, unsigned int unMask);
_CRTIMP unsigned int __cdecl _clearfp (void); /* Clear the FPU status word */
_CRTIMP unsigned int __cdecl _statusfp (void); /* Report the FPU status word */
#define _clear87 _clearfp
#define _status87 _statusfp
/*
MSVCRT.dll _fpreset initializes the control register to 0x27f,
the status register to zero and the tag word to 0FFFFh.
This differs from asm instruction finit/fninit which set control
word to 0x37f (64 bit mantissa precison rather than 53 bit).
By default, the mingw version of _fpreset sets fp control as
per fninit. To use the MSVCRT.dll _fpreset, include CRT_fp8.o when
building your application.
*/
void __cdecl _fpreset (void);
void __cdecl fpreset (void);
/* Global 'variable' for the current floating point error code. */
_CRTIMP int * __cdecl __fpecode(void);
#define _fpecode (*(__fpecode()))
/*
* IEEE recommended functions. MS puts them in float.h
* but they really belong in math.h.
*/
_CRTIMP double __cdecl _chgsign (double);
_CRTIMP double __cdecl _copysign (double, double);
_CRTIMP double __cdecl _logb (double);
_CRTIMP double __cdecl _nextafter (double, double);
_CRTIMP double __cdecl _scalb (double, long);
_CRTIMP int __cdecl _finite (double);
_CRTIMP int __cdecl _fpclass (double);
_CRTIMP int __cdecl _isnan (double);
#ifdef __cplusplus
}
#endif
#endif /* Not RC_INVOKED */
#endif /* Not __STRICT_ANSI__ */
#endif /* _FLOAT_H_ */

View file

@ -1,17 +0,0 @@
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#ifndef __CRT_INTERNAL_ATEXIT_H
#define __CRT_INTERNAL_ATEXIT_H
#ifndef _CRT_PRECOMP_H
#error DO NOT INCLUDE THIS HEADER DIRECTLY
#endif
struct __atexit {
struct __atexit* __next;
void (*__function)(void);
};
extern struct __atexit* __atexit_ptr;
#endif

View file

@ -1,16 +0,0 @@
/* console.h */
#ifndef __CRT_INTERNAL_CONSOLE_H
#define __CRT_INTERNAL_CONSOLE_H
#ifndef _CRT_PRECOMP_H
#error DO NOT INCLUDE THIS HEADER DIRECTLY
#endif
extern int char_avail;
extern int ungot_char;
#endif
/* EOF */

View file

@ -1,97 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: include/msvcrt/msvcrtdbg.h
* PURPOSE: Useful debugging macros
* PROGRAMMER:
* UPDATE HISTORY:
*
*/
/*
* NOTE: Define NDEBUG before including this header to disable debugging
* macros
*/
#ifndef __MSVCRT_DEBUG
#define __MSVCRT_DEBUG
#include <roscfg.h>
#include <windows.h>
#define MK_STR(s) #s
#ifdef _UNICODE
#define sT "S"
#else
#define sT "s"
#endif
unsigned long DbgPrint(const char *Format,...);
#ifdef __GNUC__
#define TRACE(...)
#endif
#ifdef DBG
#ifdef __GNUC__
#define DPRINT1(args...) do { DbgPrint("(MSVCRT:%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0);
#else
#define DPRINT1 DbgPrint
#endif
#define CHECKPOINT1 do { DbgPrint("MSVCRT:%s:%d\n",__FILE__,__LINE__); } while(0);
#else
#ifdef __GNUC__
#define DPRINT1(args...)
#else
#define DPRINT DbgPrint
#endif
#define CHECKPOINT1
#endif
#if !defined(NDEBUG) && defined(DBG)
#ifdef __GNUC__
#define DPRINT(args...) do { DbgPrint("(MSVCRT:%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0);
#endif
#define CHECKPOINT do { DbgPrint("MSVCRT:%s:%d\n",__FILE__,__LINE__); } while(0);
#else
#ifdef __GNUC__
#define DPRINT(args...)
#else
#define DPRINT DbgPrint
#endif
#define CHECKPOINT
#endif /* NDEBUG */
#if 0
#define TRACE_RETURN(format_str, ret_type) \
ret_type __return_value__; \
static char* __return_format_str__ = "%s ret: "format_str"\n"
#define FUNCTION(func) \
static char* __func_name__ = #func
#define TRACE(a,b...) DPRINT1(a"\n", b)
#define RETURN(a) \
do{ __return_value__ = (a); DPRINT1(__return_format_str__ ,__func_name__,__return_value__); return __return_value__ ; }while(0)
#endif
/* ULONG CDECL DbgPrint(PCH Format, ...); */
ULONG DbgPrint(PCCH Format,...);
/* unsigned long DbgPrint(const char* Format, ...); */
/* #define TRACE 0 ? (void)0 : Trace */
/* void Trace(TCHAR* lpszFormat, ...); */
#endif /* __MSVCRT_DEBUG */

View file

@ -1,190 +0,0 @@
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
/*
* Some stuff taken from active perl: perl\win32.c (ioinfo stuff)
*
* (c) 1995 Microsoft Corporation. All rights reserved.
* Developed by hip communications inc., http://info.hip.com/info/
* Portions (c) 1993 Intergraph Corporation. All rights reserved.
*
* You may distribute under the terms of either the GNU General Public
* License or the Artistic License, as specified in the README file.
*/
#ifndef __CRT_INTERNAL_FILE_H
#define __CRT_INTERNAL_FILE_H
#ifndef _CRT_PRECOMP_H
#error DO NOT INCLUDE THIS HEADER DIRECTLY
#endif
#include <stdarg.h>
#include <time.h>
#ifndef _IORMONCL
#define _IORMONCL 004000 /* remove on close, for temp files */
#endif
/* if _flag & _IORMONCL, ._name_to_remove needs freeing */
#ifndef _IOUNGETC
#define _IOUNGETC 010000 /* there is an ungetc'ed character in the buffer */
#endif
/* might need check for IO_APPEND aswell */
#define OPEN4WRITING(f) ((((f)->_flag & _IOWRT) == _IOWRT))
#define OPEN4READING(f) ((((f)->_flag & _IOREAD) == _IOREAD))
/* might need check for IO_APPEND aswell */
#define WRITE_STREAM(f) ((((f)->_flag & _IOWRT) == _IOWRT))
#define READ_STREAM(f) ((((f)->_flag & _IOREAD) == _IOREAD))
char __validfp(FILE*);
int __set_errno(int err);
int __set_doserrno(int error);
void* filehnd(int fn);
char __is_text_file(FILE*);
int alloc_fd(void* hFile, char mode);
int _doprnt(const char* fmt, va_list args, FILE *);
int _doscan(FILE* iop, const char* fmt, va_list argp);
int __fileno_dup2(int handle1, int handle2);
char __fileno_getmode(int _fd);
int __fileno_setmode(int _fd, int _newmode);
void free_fd(int _fd);
void sigabort_handler(int sig);
char split_oflags(int oflags);
unsigned create_io_inherit_block(STARTUPINFOA* si);
void UnixTimeToFileTime(time_t unix_time, FILETIME* filetime, DWORD remainder);
time_t FileTimeToUnixTime(const FILETIME* filetime, DWORD *remainder);
#define __FILE_REC_MAX 20
typedef struct __file_rec
{
struct __file_rec* next;
int count;
FILE* files[__FILE_REC_MAX];
} __file_rec;
extern __file_rec* __file_rec_list;
typedef struct _FDINFO
{
HANDLE hFile;
char fdflags;
char pipechar; /* one char buffer for handles opened on pipes */
int lockinitflag;
CRITICAL_SECTION lock;
} FDINFO;
#define FDINFO_ENTRIES_PER_BUCKET_SHIFT 5 /* log2(32) = 5 */
#define FDINFO_BUCKETS 64
#define FDINFO_ENTRIES_PER_BUCKET 32
#define FDINFO_ENTRIES (FDINFO_BUCKETS * FDINFO_ENTRIES_PER_BUCKET)
/* pipech */
#define LF 10 /* line feed */
#define CR 13 /* carriage return */
#define CTRLZ 26 /* ctrl-z means eof for text */
/* mode */
#define FOPEN 0x01 /* file handle open */
#define FEOFLAG 0x02 /* end of file has been encountered */
#define FCRLF 0x04 /* CR-LF across read buffer (in text mode) */
#define FPIPE 0x08 /* file refers to a pipe */
#define FNOINHERIT 0x10 /* file handle opened _O_NOINHERIT */
#define FAPPEND 0x20 /* file opened O_APPEND */
#define FDEV 0x40 /* file refers to device */
#define FTEXT 0x80 /* file is in text mode (absence = binary) */
/* get bucket index (0-63) from an fd */
#define fdinfo_bucket_idx(i) ((i) >> FDINFO_ENTRIES_PER_BUCKET_SHIFT)
/* get position inside a bucket (0-31) from an fd */
#define fdinfo_bucket_entry_idx(i) ((i) & (FDINFO_ENTRIES_PER_BUCKET - 1))
/* get bucket ptr. (ptr. to first fdinfo inside a bucket) from an fd */
#define fdinfo_bucket(i) ( __pioinfo[fdinfo_bucket_idx(i)])
/* get fdinfo ptr. from an fd */
#define fdinfo(i) (fdinfo_bucket(i) + fdinfo_bucket_entry_idx(i))
extern FDINFO* __pioinfo[];
void _dosmaperr(unsigned long oserrcode);
FILE* __alloc_file(void);
int access_dirA(const char *_path);
int access_dirW(const wchar_t *_path);
#ifdef _UNICODE
#define access_dirT access_dirW
#else
#define access_dirT access_dirA
#endif
void _fwalk(void (*func)(FILE*)); // not exported
#undef MB_CUR_MAX
#define MB_CUR_MAX __mb_cur_max
int _isnanl(long double x);
int _isinfl(long double x);
int _isnan(double x);
int _isinf(double x);
/* Flags for the iobuf structure (for reference) */
#if 0
#define _IOREAD 1 /* currently reading */
#define _IOWRT 2 /* currently writing */
#define _IORW 0x0080 /* opened as "r+w" */
#endif
#ifndef F_OK
#define F_OK 0 /* Check for file existence */
#endif
#ifndef W_OK
#define W_OK 2 /* Check for write permission */
#endif
/* internal FILE->_flag flags */
#define _IOMYBUF 0x0008 /* stdio malloc()'d buffer */
#define _IOEOF 0x0010 /* EOF reached on read */
#define _IOERR 0x0020 /* I/O error from system */
#define _IOSTRG 0x0040 /* Strange or no file descriptor */
#define _IOBINARY 0x040000
#define _IOTEXT 0x000000
#define _IOCOMMIT 0x100000
#define _IODIRTY 0x010000
#define _IOAHEAD 0x020000
/*
* The three possible buffering mode (nMode) values for setvbuf.
* NOTE: _IOFBF works, but _IOLBF seems to work like unbuffered...
* maybe I'm testing it wrong?
*/
#define _IOFBF 0x0000 /* full buffered */
#define _IOLBF 0x0040 /* line buffered */
#define _IONBF 0x0004 /* not buffered */
#define _IO_LBF 0x80000 /* this value is used insteat of _IOLBF within the
structure FILE as value for _flags,
because _IOLBF has the same value as _IOSTRG */
wint_t _filwbuf(FILE *f);
#if __MINGW32_MAJOR_VERSION < 3 || __MINGW32_MINOR_VERSION < 2
int __cdecl _filbuf (FILE*);
int __cdecl _flsbuf (int, FILE*);
#endif
#endif /* __dj_include_libc_file_h__ */

View file

@ -1,25 +0,0 @@
#ifndef __CRT_INTERNAL_IEEE_H
#define __CRT_INTERNAL_IEEE_H
typedef struct {
unsigned int mantissa:23;
unsigned int exponent:8;
unsigned int sign:1;
} float_t;
typedef struct {
unsigned int mantissal:32;
unsigned int mantissah:20;
unsigned int exponent:11;
unsigned int sign:1;
} double_t;
typedef struct {
unsigned int mantissal:32;
unsigned int mantissah:32;
unsigned int exponent:15;
unsigned int sign:1;
unsigned int empty:16;
} long_double_t;
#endif

View file

@ -1,12 +0,0 @@
#ifndef __CRT_INTERNAL_MATH_H
#define __CRT_INTERNAL_MATH_H
#ifndef _CRT_PRECOMP_H
#error DO NOT INCLUDE THIS HEADER DIRECTLY
#endif
int _isinf (double); /* not exported */
int _isnanl (long double); /* not exported */
int _isinfl (long double); /* not exported */
#endif

View file

@ -1,37 +0,0 @@
#ifndef __CRT_INTERNAL_MBSTRING_H
#define __CRT_INTERNAL_MBSTRING_H
#define _KNJ_M ((char)0x01) /* Non-punctuation of Kana-set */
#define _KNJ_P ((char)0x02) /* Punctuation of Kana-set */
#define _KNJ_1 ((char)0x04) /* Legal 1st byte of double byte stream */
#define _KNJ_2 ((char)0x08) /* Legal 2nd btye of double byte stream */
#define ___ 0
#define _1_ _KNJ_1 /* Legal 1st byte of double byte code */
#define __2 _KNJ_2 /* Legal 2nd byte of double byte code */
#define _M_ _KNJ_M /* Non-puntuation in Kana-set */
#define _P_ _KNJ_P /* Punctuation of Kana-set */
#define _12 (_1_|__2)
#ifndef _M2
#define _M2 (_M_|__2)
#endif
#define _P2 (_P_|__2)
#if defined (_MSC_VER)
#undef _ismbbkana
#undef _ismbbkpunct
#undef _ismbbalpha
#undef _ismbbalnum
#undef _ismbbgraph
#undef _ismbbkalnum
#undef _ismbblead
#undef _ismbbprint
#undef _ismbbpunct
#undef _ismbbtrail
#endif
#endif

View file

@ -1,72 +0,0 @@
/*
* Copyright (c) 2002, TransGaming Technologies Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __CRT_INTERNAL_WINE_MTDLL_H
#define __CRT_INTERNAL_WINE_MTDLL_H
#if defined(_MT)
#define _mlock(locknum) _lock(locknum)
#define _munlock(locknum) _unlock(locknum)
void _unlock( int locknum );
void _lock( int locknum );
#else
#define _mlock(locknum) do {} while(0)
#define _munlock(locknum) do {} while(0)
#endif
#define _SIGNAL_LOCK 1
#define _IOB_SCAN_LOCK 2
#define _TMPNAM_LOCK 3
#define _INPUT_LOCK 4
#define _OUTPUT_LOCK 5
#define _CSCANF_LOCK 6
#define _CPRINTF_LOCK 7
#define _CONIO_LOCK 8
#define _HEAP_LOCK 9
#define _BHEAP_LOCK 10 /* No longer used? */
#define _TIME_LOCK 11
#define _ENV_LOCK 12
#define _EXIT_LOCK1 13
#define _EXIT_LOCK2 14
#define _THREADDATA_LOCK 15 /* No longer used? */
#define _POPEN_LOCK 16
#define _LOCKTAB_LOCK 17
#define _OSFHND_LOCK 18
#define _SETLOCALE_LOCK 19
#define _LC_COLLATE_LOCK 20 /* No longer used? */
#define _LC_CTYPE_LOCK 21 /* No longer used? */
#define _LC_MONETARY_LOCK 22 /* No longer used? */
#define _LC_NUMERIC_LOCK 23 /* No longer used? */
#define _LC_TIME_LOCK 24 /* No longer used? */
#define _MB_CP_LOCK 25
#define _NLG_LOCK 26
#define _TYPEINFO_LOCK 27
#define _STREAM_LOCKS 28
/* Must match definition in msvcrt/stdio.h */
#define _IOB_ENTRIES 20
#define _LAST_STREAM_LOCK (_STREAM_LOCKS+_IOB_ENTRIES-1)
#define _TOTAL_LOCKS (_LAST_STREAM_LOCK+1)
#endif /* WINE_MTDLL_H */

View file

@ -1,31 +0,0 @@
/* rterror.h */
#ifndef __CRT_INTERNAL_RTERROR_H
#define __CRT_INTERNAL_RTERROR_H
#define _RT_STACK 0 /* stack overflow */
#define _RT_NULLPTR 1 /* null pointer assignment */
#define _RT_FLOAT 2 /* floating point not loaded */
#define _RT_INTDIV 3 /* integer divide by 0 */
#define _RT_SPACEARG 4 /* not enough space for arguments */
#define _RT_SPACEENV 5 /* not enough space for environment */
#define _RT_ABORT 6 /* abnormal program termination */
#define _RT_THREAD 7 /* not enough space for thread data */
#define _RT_LOCK 8 /* unexpected multi-thread lock error */
#define _RT_HEAP 9 /* unexpected heap error */
#define _RT_OPENCON 10 /* unable to open console device */
#define _RT_NONCONT 11 /* non-continuable exception */
#define _RT_INVALDISP 12 /* invalid disposition of exception */
#define _RT_ONEXIT 13 /* insufficient heap to allocate
* initial table of function pointers
* used by _onexit()/atexit(). */
#define _RT_PUREVIRT 14 /* pure virtual function call attempted
* (C++ error) */
#define _RT_STDIOINIT 15 /* not enough space for stdio initialization */
#define _RT_LOWIOINIT 16 /* not enough space for lowio initialization */
void _amsg_exit (int errnum);
#endif /* __MSVCRT_INTERNAL_RTERROR_H */

View file

@ -1,50 +0,0 @@
/* tls.h */
#ifndef __CRT_INTERNAL_TLS_H
#define __CRT_INTERNAL_TLS_H
#ifndef _CRT_PRECOMP_H
#error DO NOT INCLUDE THIS HEADER DIRECTLY
#endif
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <winnt.h>
#include <stddef.h>
typedef struct _ThreadData
{
int terrno; /* *nix error code */
unsigned long tdoserrno; /* Win32 error code (for I/O only) */
unsigned __int64 tnext; /* used by rand/srand */
char *lasttoken; /* used by strtok */
wchar_t *wlasttoken; /* used by wcstok */
int fpecode; /* fp exception code */
/* qsort variables */
int (*qcmp)(const void *, const void *); /* the comparison routine */
int qsz; /* size of each record */
int thresh; /* THRESHold in chars */
int mthresh; /* MTHRESHold in chars */
EXCEPTION_RECORD *exc_record; /* Head of exception record list */
} THREADDATA, *PTHREADDATA;
int CreateThreadData(void);
void DestroyThreadData(void);
void FreeThreadData(PTHREADDATA ptd);
PTHREADDATA GetThreadData(void);
#endif /* __MSVCRT_INTERNAL_TLS_H */
/* EOF */

View file

@ -1,124 +0,0 @@
/*
* msvcrt C++ exception handling
*
* Copyright 2002 Alexandre Julliard
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __MSVCRT_CPPEXCEPT_H
#define __MSVCRT_CPPEXCEPT_H
#define CXX_FRAME_MAGIC 0x19930520
#define CXX_EXCEPTION 0xe06d7363
typedef void (*vtable_ptr)();
/* type_info object, see cpp.c for inplementation */
typedef struct __type_info
{
vtable_ptr *vtable;
char *name; /* Unmangled name, allocated lazily */
char mangled[32]; /* Variable length, but we declare it large enough for static RTTI */
} type_info;
/* the exception frame used by CxxFrameHandler */
typedef struct __cxx_exception_frame
{
EXCEPTION_REGISTRATION_RECORD frame; /* the standard exception frame */
int trylevel;
DWORD ebp;
} cxx_exception_frame;
/* info about a single catch {} block */
typedef struct __catchblock_info
{
UINT flags; /* flags (see below) */
type_info *type_info; /* C++ type caught by this block */
int offset; /* stack offset to copy exception object to */
void (*handler)(); /* catch block handler code */
} catchblock_info;
#define TYPE_FLAG_CONST 1
#define TYPE_FLAG_VOLATILE 2
#define TYPE_FLAG_REFERENCE 8
/* info about a single try {} block */
typedef struct __tryblock_info
{
int start_level; /* start trylevel of that block */
int end_level; /* end trylevel of that block */
int catch_level; /* initial trylevel of the catch block */
int catchblock_count; /* count of catch blocks in array */
catchblock_info *catchblock; /* array of catch blocks */
} tryblock_info;
/* info about the unwind handler for a given trylevel */
typedef struct __unwind_info
{
int prev; /* prev trylevel unwind handler, to run after this one */
void (*handler)(); /* unwind handler */
} unwind_info;
/* descriptor of all try blocks of a given function */
typedef struct __cxx_function_descr
{
UINT magic; /* must be CXX_FRAME_MAGIC */
UINT unwind_count; /* number of unwind handlers */
unwind_info *unwind_table; /* array of unwind handlers */
UINT tryblock_count; /* number of try blocks */
tryblock_info *tryblock; /* array of try blocks */
UINT unknown[3];
} cxx_function_descr;
typedef void (*cxx_copy_ctor)(void);
/* complete information about a C++ type */
typedef struct __cxx_type_info
{
UINT flags; /* flags (see CLASS_* flags below) */
type_info *type_info; /* C++ type info */
int this_offset; /* offset of base class this pointer from start of object */
int vbase_descr; /* offset of virtual base class descriptor */
int vbase_offset; /* offset of this pointer offset in virtual base class descriptor */
size_t size; /* object size */
cxx_copy_ctor copy_ctor; /* copy constructor */
} cxx_type_info;
#define CLASS_IS_SIMPLE_TYPE 1
#define CLASS_HAS_VIRTUAL_BASE_CLASS 4
/* table of C++ types that apply for a given object */
typedef struct __cxx_type_info_table
{
UINT count; /* number of types */
const cxx_type_info *info[3]; /* variable length, we declare it large enough for static RTTI */
} cxx_type_info_table;
typedef DWORD (*cxx_exc_custom_handler)( PEXCEPTION_RECORD, cxx_exception_frame*,
PCONTEXT, EXCEPTION_REGISTRATION_RECORD**,
cxx_function_descr*, int nested_trylevel,
EXCEPTION_REGISTRATION_RECORD *nested_frame, DWORD unknown3 );
/* type information for an exception object */
typedef struct __cxx_exception_type
{
UINT flags; /* TYPE_FLAG flags */
void (*destructor)(); /* exception object destructor */
cxx_exc_custom_handler custom_handler; /* custom handler for this exception */
const cxx_type_info_table *type_info_table; /* list of types for this exception object */
} cxx_exception_type;
void _CxxThrowException(void*,const cxx_exception_type*);
#endif /* __MSVCRT_CPPEXCEPT_H */

View file

@ -1,53 +0,0 @@
/*
* C++ exception handling facility
*
* Copyright 2000 Francois Gouget.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __WINE_EH_H
#define __WINE_EH_H
#ifndef __WINE_USE_MSVCRT
#define __WINE_USE_MSVCRT
#endif
#if !defined(__cplusplus) && !defined(USE_MSVCRT_PREFIX)
#error "eh.h is meant only for C++ applications"
#endif
#ifndef MSVCRT
# ifdef USE_MSVCRT_PREFIX
# define MSVCRT(x) MSVCRT_##x
# else
# define MSVCRT(x) x
# endif
#endif
struct _EXCEPTION_POINTERS;
typedef void (*terminate_handler)();
typedef void (*terminate_function)();
typedef void (*unexpected_handler)();
typedef void (*unexpected_function)();
typedef void (*_se_translator_function)(unsigned int code, struct _EXCEPTION_POINTERS *info);
terminate_function MSVCRT(set_terminate)(terminate_function func);
unexpected_function MSVCRT(set_unexpected)(unexpected_function func);
_se_translator_function MSVCRT(_set_se_translator)(_se_translator_function func);
void MSVCRT(terminate)();
void MSVCRT(unexpected)();
#endif /* __WINE_EH_H */

View file

@ -1,135 +0,0 @@
/*
* Copyright 2001 Jon Griffiths
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __WINE_MSVCRT_H
#define __WINE_MSVCRT_H
#include <stdarg.h>
#include <ctype.h>
#include <string.h>
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "winnls.h"
//#include "msvcrt/string.h"
#include "eh.h"
/* TLS data */
extern DWORD MSVCRT_tls_index;
typedef struct __MSVCRT_thread_data
{
int _errno; // ros
unsigned long doserrno;
char *mbstok_next; /* next ptr for mbstok() */
char *efcvt_buffer; /* buffer for ecvt/fcvt */
terminate_function terminate_handler;
unexpected_function unexpected_handler;
_se_translator_function se_translator;
EXCEPTION_RECORD *exc_record;
} MSVCRT_thread_data;
extern MSVCRT_thread_data *msvcrt_get_thread_data(void);
extern int MSVCRT_current_lc_all_cp;
void _purecall(void);
void MSVCRT__set_errno(int);
char* msvcrt_strndup(const char*,unsigned int);
#ifndef __REACTOS__
MSVCRT_wchar_t *msvcrt_wstrndup(const MSVCRT_wchar_t*, unsigned int);
#endif
void MSVCRT__amsg_exit(int errnum);
extern char **MSVCRT__environ;
#ifndef __REACTOS__
extern MSVCRT_wchar_t **MSVCRT__wenviron;
extern char ** msvcrt_SnapshotOfEnvironmentA(char **);
extern MSVCRT_wchar_t ** msvcrt_SnapshotOfEnvironmentW(MSVCRT_wchar_t **);
#endif
/* FIXME: This should be declared in new.h but it's not an extern "C" so
* it would not be much use anyway. Even for Winelib applications.
*/
int MSVCRT__set_new_mode(int mode);
void* MSVCRT_operator_new(unsigned long size);
void MSVCRT_operator_delete(void*);
#ifndef __REACTOS__
typedef void* (*MSVCRT_malloc_func)(MSVCRT_size_t);
#endif
typedef void (*MSVCRT_free_func)(void*);
#ifndef __REACTOS__
extern char* MSVCRT___unDName(int,const char*,int,MSVCRT_malloc_func,MSVCRT_free_func,unsigned int);
#endif
/* Setup and teardown multi threaded locks */
extern void msvcrt_init_mt_locks(void);
extern void msvcrt_free_mt_locks(void);
extern void msvcrt_init_io(void);
extern void msvcrt_free_io(void);
extern void msvcrt_init_console(void);
extern void msvcrt_free_console(void);
extern void msvcrt_init_args(void);
extern void msvcrt_free_args(void);
/* run-time error codes */
#define _RT_STACK 0
#define _RT_NULLPTR 1
#define _RT_FLOAT 2
#define _RT_INTDIV 3
#define _RT_EXECMEM 5
#define _RT_EXECFORM 6
#define _RT_EXECENV 7
#define _RT_SPACEARG 8
#define _RT_SPACEENV 9
#define _RT_ABORT 10
#define _RT_NPTR 12
#define _RT_FPTR 13
#define _RT_BREAK 14
#define _RT_INT 15
#define _RT_THREAD 16
#define _RT_LOCK 17
#define _RT_HEAP 18
#define _RT_OPENCON 19
#define _RT_QWIN 20
#define _RT_NOMAIN 21
#define _RT_NONCONT 22
#define _RT_INVALDISP 23
#define _RT_ONEXIT 24
#define _RT_PUREVIRT 25
#define _RT_STDIOINIT 26
#define _RT_LOWIOINIT 27
#define _RT_HEAPINIT 28
#define _RT_DOMAIN 120
#define _RT_SING 121
#define _RT_TLOSS 122
#define _RT_CRNL 252
#define _RT_BANNER 255
typedef void* (*malloc_func_t)(size_t);
typedef void (*free_func_t)(void*);
#define MSVCRT_malloc malloc
#define MSVCRT_free free
NTSYSAPI VOID NTAPI RtlAssert(PVOID FailedAssertion,PVOID FileName,ULONG LineNumber,PCHAR Message);
extern char* __unDName(char *,const char*,int,malloc_func_t,free_func_t,unsigned short int);
#endif /* __WINE_MSVCRT_H */

View file

@ -1,59 +0,0 @@
#include <precomp.h>
#include <tchar.h>
#define NDEBUG
#include <internal/debug.h>
#ifdef _UNICODE
#define _TS S
#else
#define _TS s
#endif
/*
* @implemented
*/
int _taccess( const _TCHAR *_path, int _amode )
{
DWORD Attributes = GetFileAttributes(_path);
DPRINT(MK_STR(_taccess)"('%"sT"', %x)\n", _path, _amode);
if (Attributes == (DWORD)-1) {
_dosmaperr(GetLastError());
return -1;
}
if ((_amode & W_OK) == W_OK) {
if ((Attributes & FILE_ATTRIBUTE_READONLY) == FILE_ATTRIBUTE_READONLY) {
__set_errno(EACCES);
return -1;
}
}
return 0;
}
/*
* INTERNAL
*/
int access_dirT(const _TCHAR *_path)
{
DWORD Attributes = GetFileAttributes(_path);
DPRINT(MK_STR(is_dirT)"('%"sT"')\n", _path);
if (Attributes == (DWORD)-1) {
_dosmaperr(GetLastError());
return -1;
}
if ((Attributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY)
{
__set_errno(EACCES);
return -1;
}
return 0;
}

View file

@ -1,57 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crt/??????
* PURPOSE: Unknown
* PROGRAMER: Unknown
* UPDATE HISTORY:
* 25/11/05: Created
*/
#include <precomp.h>
#include <sys/stat.h>
#include <tchar.h>
#define NDEBUG
#include <internal/debug.h>
#define mode_t int
/*
* @implemented
*/
int _tchmod(const _TCHAR* filename, mode_t mode)
{
DWORD FileAttributes = 0;
BOOLEAN Set = FALSE;
DPRINT(MK_STR(_tchmod)"('%"sT"', %x)\n", filename, mode);
FileAttributes = GetFileAttributes(filename);
if ( FileAttributes == (DWORD)-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 && SetFileAttributes(filename, FileAttributes) == FALSE) {
_dosmaperr(GetLastError());
return -1;
}
return 0;
}

View file

@ -1,21 +0,0 @@
/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
#include <precomp.h>
#define NDEBUG
#include <internal/debug.h>
/*
* @implemented
*/
int _chsize(int _fd, long size)
{
DPRINT("_chsize(fd %d, size %d)\n", _fd, size);
long location = _lseek(_fd, 0, SEEK_CUR);
if (location == -1) return -1;
if (_lseek(_fd, size, 0) == -1)
return -1;
if (!SetEndOfFile((HANDLE)_get_osfhandle(_fd)))
return -1;
_lseek(_fd, location, SEEK_SET);
return 0;
}

View file

@ -1,20 +0,0 @@
#include <precomp.h>
#define NDEBUG
#include <internal/debug.h>
/*
* @implemented
*/
int _close(int _fd)
{
TRACE("_close(%i)", _fd);
if (_fd == -1)
return(-1);
if (CloseHandle((HANDLE)_get_osfhandle(_fd)) == FALSE)
return(-1);
//return
free_fd(_fd);
return(0);
}

View file

@ -1,14 +0,0 @@
#include <precomp.h>
/*
* @implemented
*/
int _commit(int _fd)
{
if (! FlushFileBuffers((HANDLE)_get_osfhandle(_fd)) ) {
__set_errno(EBADF);
return -1;
}
return 0;
}

View file

@ -1,24 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crt/??????
* PURPOSE: Unknown
* PROGRAMER: Unknown
* UPDATE HISTORY:
* 25/11/05: Created
*/
#include <precomp.h>
#define NDEBUG
#include <internal/debug.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,38 +0,0 @@
#include <precomp.h>
/*
* @implemented
*/
int _dup(int handle)
{
HANDLE hFile;
HANDLE hProcess = GetCurrentProcess();
BOOL result;
int fd;
int mode;
hFile = (HANDLE)_get_osfhandle(handle);
if (hFile == INVALID_HANDLE_VALUE) {
__set_errno(EBADF);
return -1;
}
mode = __fileno_getmode(handle);
result = DuplicateHandle(hProcess,
hFile,
hProcess,
&hFile,
0,
mode & FNOINHERIT ? FALSE : TRUE,
DUPLICATE_SAME_ACCESS);
if (result == FALSE) {
_dosmaperr(GetLastError());
return -1;
}
fd = alloc_fd(hFile, mode);
if (fd < 0)
{
CloseHandle(hFile);
}
return fd;
}

View file

@ -1,9 +0,0 @@
#include <precomp.h>
/*
* @implemented
*/
int _dup2(int handle1, int handle2)
{
return __fileno_dup2(handle1, handle2);
}

View file

@ -1,27 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crt/??????
* PURPOSE: Unknown
* PROGRAMER: Unknown
* UPDATE HISTORY:
* 25/11/05: Created
*/
#include <precomp.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,17 +0,0 @@
#include <precomp.h>
/*
* @implemented
*/
long _filelength(int _fd)
{
DWORD len = GetFileSize((HANDLE)_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,19 +0,0 @@
#include <precomp.h>
/*
* @implemented
*/
__int64 _filelengthi64(int _fd)
{
DWORD lo_length, hi_length;
lo_length = GetFileSize((HANDLE)_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,189 +0,0 @@
#include <precomp.h>
#include <tchar.h>
/*
* @implemented
*/
#if defined(_UNICODE) || !(__MINGW32_MAJOR_VERSION < 3 || __MINGW32_MINOR_VERSION < 3)
long
#else
int
#endif
_tfindfirst(const _TCHAR* _name, struct _tfinddata_t* result)
{
WIN32_FIND_DATA FindFileData;
_TCHAR dir[MAX_PATH];
long hFindFile;
int len = 0;
if (_name == NULL || _name[0] == 0) {
len = GetCurrentDirectory(MAX_PATH-4,dir);
if (dir[len-1] != '\\') {
dir[len] = '\\';
dir[len+1] = 0;
}
_tcscat(dir,_T("*.*"));
} else {
_tcscpy(dir,_name);
}
hFindFile = (long)FindFirstFile(dir, &FindFileData);
if (hFindFile == -1) {
memset(result,0,sizeof(struct _tfinddata_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;
_tcsncpy(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 (!_tcschr(dir,'*') && !_tcschr(dir,'?')) {
_findclose(hFindFile);
return 0;
}
return hFindFile;
}
/*
* @implemented
*/
int _tfindnext(
#if defined(_UNICODE) || !(__MINGW32_MAJOR_VERSION < 3 || __MINGW32_MINOR_VERSION < 3)
long handle,
#else
int handle,
#endif
struct _tfinddata_t* result)
{
WIN32_FIND_DATA FindFileData;
// check no wildcards or invalid handle
if (handle == 0 || handle == -1)
return 0;
if (!FindNextFile((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;
_tcsncpy(result->name,FindFileData.cFileName, MAX_PATH);
return 0;
}
/*
* @implemented
*/
long _tfindfirsti64(const _TCHAR *_name, struct _tfinddatai64_t *result)
{
WIN32_FIND_DATA FindFileData;
_TCHAR dir[MAX_PATH];
long hFindFile;
int len = 0;
if ( _name == NULL || _name[0] == 0 )
{
len = GetCurrentDirectory(MAX_PATH-4,dir);
if (dir[len-1] != '\\')
{
dir[len] = '\\';
dir[len+1] = 0;
}
_tcscat(dir, _T("*.*"));
}
else
_tcscpy(dir, _name);
hFindFile = (long)FindFirstFile(dir, &FindFileData);
if (hFindFile == -1)
{
memset(result,0,sizeof(struct _tfinddatai64_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;
_tcsncpy(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 (!_tcschr(dir,'*') && !_tcschr(dir,'?')) {
_findclose(hFindFile);
return 0;
}
return hFindFile;
}
//_CRTIMP long __cdecl _findfirsti64(const char*, struct _finddatai64_t*);
//_CRTIMP int __cdecl _findnexti64(long, struct _finddatai64_t*);
/*
* @implemented
*/
int _tfindnexti64(long handle, struct _tfinddatai64_t *result)
{
WIN32_FIND_DATA FindFileData;
// check no wildcards or invalid handle
if (handle == 0 || handle == -1)
return 0;
if (!FindNextFile((HANDLE)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;
_tcsncpy(result->name,FindFileData.cFileName,MAX_PATH);
return 0;
}
#ifndef _UNICODE
/*
* @implemented
*/
int _findclose(
#if __MINGW32_MAJOR_VERSION < 3 || __MINGW32_MINOR_VERSION < 3
int handle
#else
long handle
#endif
)
{
// check no wildcards or invalid handle
if (handle == 0 || handle == -1)
return 0;
return FindClose((void*)handle);
}
#endif

View file

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

View file

@ -1,15 +0,0 @@
#include <precomp.h>
#define NDEBUG
#include <internal/debug.h>
/*
* @implemented
*/
int _isatty(int fd)
{
HANDLE hFile = fdinfo(fd)->hFile;
if (hFile == INVALID_HANDLE_VALUE)
return 0;
return GetFileType(hFile) == FILE_TYPE_CHAR ? 1 : 0;
}

View file

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

View file

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

View file

@ -1,39 +0,0 @@
#include <precomp.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)fdinfo(_fildes)->hFile, 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)fdinfo(_fildes)->hFile,
offset.u.LowPart, &offset.u.HighPart, _whence);
return ((((__int64)offset.u.HighPart) << 32) + offset.u.LowPart);
#endif /*SETFILEPOINTEREX_AVAILABLE*/
}

View file

@ -1,75 +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
Ariadne
* 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 <precomp.h>
#define NDEBUG
#include <internal/debug.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,729 +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: Ariadne
* UPDATE HISTORY:
* 28/12/98: Created
*/
/*
* Some stuff taken from active perl: perl\win32.c (ioinfo stuff)
*
* (c) 1995 Microsoft Corporation. All rights reserved.
* Developed by hip communications inc., http://info.hip.com/info/
* Portions (c) 1993 Intergraph Corporation. All rights reserved.
*
* You may distribute under the terms of either the GNU General Public
* License or the Artistic License, as specified in the README file.
*/
/*
* Some functions taken from/based on wine\dlls\msvcrt\file.c:
* split_oflags
* _open_osfhandle
* many more...
*
* Copyright 1996,1998 Marcus Meissner
* Copyright 1996 Jukka Iivonen
* Copyright 1997,2000 Uwe Bonnes
* Copyright 2000 Jon Griffiths
* Copyright 2004 Eric Pouech
* Copyright 2004 Juan Lang
*/
// 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 <stdarg.h>
#endif
#include <sys/stat.h>
#include <string.h>
#include <share.h>
#define NDEBUG
#include <internal/debug.h>
FDINFO first_bucket[FDINFO_ENTRIES_PER_BUCKET];
FDINFO* __pioinfo[FDINFO_BUCKETS] = {first_bucket};
/* This critical section protects the tables MSVCRT_fdesc and MSVCRT_fstreams,
* and their related indexes, MSVCRT_fdstart, MSVCRT_fdend,
* and MSVCRT_stream_idx, from race conditions.
* It doesn't protect against race conditions manipulating the underlying files
* or flags; doing so would probably be better accomplished with per-file
* protection, rather than locking the whole table for every change.
*/
static CRITICAL_SECTION g_file_cs;
#define LOCK_FILES() do { EnterCriticalSection(&g_file_cs); } while (0)
#define UNLOCK_FILES() do { LeaveCriticalSection(&g_file_cs); } while (0)
/////////////////////////////////////////
static int g_fdstart = 3; /* first unallocated fd */
static int g_fdend = 3; /* highest allocated fd */
/*
* INTERNAL
*/
/*
static __inline FD_INFO* fdinfo(int fd)
{
FD_INFO* bucket = __pioinfo[fd >> FDINFO_ENTRIES_PER_BUCKET_SHIFT];
if (!bucket){
bucket = alloc_init_bucket(fd);
}
return bucket + (fd & (FDINFO_ENTRIES_PER_BUCKET - 1));
}
*/
/*
* INTERNAL
*/
__inline BOOL is_valid_fd(int fd)
{
BOOL b = (fd >= 0 && fd < g_fdend && (fdinfo(fd)->fdflags & FOPEN));
if (!b){
if (fd >= 0 && fd < g_fdend)
{
DPRINT1("not valid fd %i, g_fdend %i, fdinfo %x, bucket %x, fdflags %x\n",
fd,g_fdend,fdinfo(fd),fdinfo_bucket(fd),fdinfo(fd)->fdflags);
}
else
{
DPRINT1("not valid fd %i, g_fdend %i\n",fd,g_fdend);
}
}
return b;
}
/*
* INTERNAL
*/
char split_oflags(int oflags)
{
char fdflags = 0;
if (oflags & _O_APPEND) fdflags |= FAPPEND;
if (oflags & _O_BINARY) ;
else if (oflags & _O_TEXT) fdflags |= FTEXT;
else if (_fmode& _O_BINARY) ;
else fdflags |= FTEXT; /* default to TEXT*/
if (oflags & _O_NOINHERIT) fdflags |= FNOINHERIT;
if (oflags & ~(_O_BINARY|_O_TEXT|_O_APPEND|_O_TRUNC|
_O_EXCL|_O_CREAT|_O_RDWR|_O_WRONLY|
_O_TEMPORARY|_O_NOINHERIT))
DPRINT1(":unsupported oflags 0x%04x\n",oflags);
return fdflags;
}
/*
* INTERNAL
*/
char __is_text_file(FILE* p)
{
if ( p == NULL || fdinfo_bucket((p)->_file) == NULL )
return FALSE;
return (!((p)->_flag&_IOSTRG) && (fdinfo((p)->_file)->fdflags & FTEXT));
}
/*
* @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
TRACE("_open('%s', %x, (%x))\n", _path, _oflag);
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(alloc_fd(hFile, split_oflags(_oflag)));
}
/*
* INTERNAL
*/
static void init_bucket(FDINFO* entry)
{
int i;
for(i=0;
i < FDINFO_ENTRIES_PER_BUCKET;
i++, entry++)
{
entry->hFile = INVALID_HANDLE_VALUE;
entry->fdflags = 0;
entry->pipechar = LF;
entry->lockinitflag = 0;
}
}
/*
* INTERNAL
*/
static BOOL alloc_init_bucket(int fd)
{
fdinfo_bucket(fd) = malloc(FDINFO_ENTRIES_PER_BUCKET * sizeof(FDINFO));
if (!fdinfo_bucket(fd)) return FALSE;
init_bucket(fdinfo_bucket(fd));
return TRUE;
}
/*
* INTERNAL
* Allocate an fd slot from a Win32 HANDLE, starting from fd
* caller must hold the files lock
*/
static int alloc_fd_from(HANDLE hand, char flag, int fd)
{
if (fd >= FDINFO_ENTRIES)
{
DPRINT1("files exhausted!\n");
return -1;
}
if (!fdinfo_bucket(fd))
{
if (!alloc_init_bucket(fd)){
//errno = ENOMEM
return -1;
}
}
fdinfo(fd)->hFile = hand;
fdinfo(fd)->fdflags = FOPEN | (flag & (FNOINHERIT | FAPPEND | FTEXT));
fdinfo(fd)->pipechar = LF;
fdinfo(fd)->lockinitflag = 0;
//fdinfo(fd)->lock
/* locate next free slot */
if (fd == g_fdstart && fd == g_fdend)
{
g_fdstart = g_fdend + 1;
}
else
{
#if 0 /* alternate (untested) impl. maybe a tiny bit faster? -Gunnar */
int i, bidx;
for (bidx = fdinfo_bucket_idx(g_fdstart); bidx < FDINFO_BUCKETS && __pioinfo[bidx]; bidx++)
{
for (i = fdinfo_bucket_entry_idx(g_fdstart);
g_fdstart < g_fdend && fdinfo(g_fdstart)->fdflags & FOPEN && i < FDINFO_BUCKET_ENTRIES;
i++)
{
g_fdstart++;
}
}
#else
while (g_fdstart < g_fdend &&
fdinfo_bucket(g_fdstart) &&
(fdinfo(g_fdstart)->fdflags & FOPEN))
{
g_fdstart++;
}
#endif
}
/* update last fd in use */
if (fd >= g_fdend)
g_fdend = fd + 1;
/* alloc more fdinfo buckets by demand.
* FIXME: should we dealloc buckets when they become unused also? */
if (!fdinfo_bucket(g_fdstart) && g_fdstart < FDINFO_ENTRIES)
{
alloc_init_bucket(g_fdstart);
}
DPRINT("fdstart is %d, fdend is %d\n", g_fdstart, g_fdend);
switch (fd)
{
case 0: SetStdHandle(STD_INPUT_HANDLE, hand); break;
case 1: SetStdHandle(STD_OUTPUT_HANDLE, hand); break;
case 2: SetStdHandle(STD_ERROR_HANDLE, hand); break;
}
return fd;
}
/*
* INTERNAL: Allocate an fd slot from a Win32 HANDLE
*/
int alloc_fd(HANDLE hand, char flag)
{
int ret;
LOCK_FILES();
// TRACE(":handle (%p) allocating fd (%d)\n",hand,MSVCRT_fdstart);
ret = alloc_fd_from(hand, flag, g_fdstart);
UNLOCK_FILES();
return ret;
}
/*
* INTERNAL
*/
char __fileno_getmode(int fd)
{
if (!is_valid_fd(fd)) {
__set_errno(EBADF);
return -1;
}
return fdinfo(fd)->fdflags;
}
/*
* INTERNAL
*/
void free_fd(int fd)
{
LOCK_FILES();
fdinfo(fd)->hFile = INVALID_HANDLE_VALUE;
fdinfo(fd)->fdflags = 0;
if (fd < 3) /* don't use 0,1,2 for user files */
{
switch (fd)
{
case 0: SetStdHandle(STD_INPUT_HANDLE, NULL); break;
case 1: SetStdHandle(STD_OUTPUT_HANDLE, NULL); break;
case 2: SetStdHandle(STD_ERROR_HANDLE, NULL); break;
}
}
else
{
if (fd == g_fdend - 1)
g_fdend--;
if (fd < g_fdstart)
g_fdstart = fd;
}
UNLOCK_FILES();
}
/*
* @implemented
*/
int _open_osfhandle(long osfhandle, int oflags)
{
/*
PREV:
The _open_osfhandle() function in MSVCRT is expected to take the absence
of either _O_TEXT or _O_BINARY to mean _O_BINARY. Currently it defaults to
_O_TEXT.
An example of this is MFC's CStdioFile::Open in binary mode - it passes flags
of 0 when it wants to write a binary file - under WINE we do text mode conversions!
The attached patch ensures that _O_BINARY is set if neither is set in the passed-in
flags.
* file, so set the write flag. It also only sets _O_TEXT if it wants
* text - it never sets _O_BINARY.
*/
/* FIXME: handle more flags */
/*
flags |= MSVCRT__IOREAD|MSVCRT__IOWRT;
if ( !( flags & _O_TEXT ) ) flags |= _O_BINARY;
fd = msvcrt_alloc_fd((HANDLE)hand,flags);
TRACE(":handle (%ld) fd (%d) flags 0x%08x\n",hand,fd, flags);
*/
/* MSVCRT__O_RDONLY (0) always matches, so set the read flag
* MFC's CStdioFile clears O_RDONLY (0)! if it wants to write to the
* file, so set the write flag. It also only sets MSVCRT__O_TEXT if it wants
* text - it never sets MSVCRT__O_BINARY.
*/
/* FIXME: handle more flags */
/*
LAG TEST SOM TESTER UT ALT DETTE flag tingern
*/
if (!(oflags & (_O_BINARY | _O_TEXT)) && (_fmode & _O_BINARY))
oflags |= _O_BINARY;
else
oflags |= _O_TEXT;
return alloc_fd((HANDLE)osfhandle, split_oflags(oflags));
}
/*
* @implemented
*/
long _get_osfhandle(int fd)
{
TRACE("_get_osfhandle(%i)",fd);
if (!is_valid_fd(fd)) {
return( -1 );
}
return( (long)fdinfo(fd)->hFile );
}
/*
* INTERNAL
*/
int __fileno_dup2(int handle1, int handle2)
{
HANDLE hProcess;
BOOL result;
if (handle1 >= FDINFO_ENTRIES || handle1 < 0 || handle2 >= FDINFO_ENTRIES || handle2 < 0) {
__set_errno(EBADF);
return -1;
}
// if (_pioinfo[handle1]->fd == -1) {
if (fdinfo(handle1)->hFile == INVALID_HANDLE_VALUE) {
__set_errno(EBADF);
return -1;
}
if (handle1 == handle2)
return handle1;
// if (_pioinfo[handle2]->fd != -1) {
if (fdinfo(handle2)->hFile != INVALID_HANDLE_VALUE) {
_close(handle2);
}
hProcess = GetCurrentProcess();
result = DuplicateHandle(hProcess,
fdinfo(handle1)->hFile,
hProcess,
&fdinfo(handle2)->hFile,
0,
fdinfo(handle1)->fdflags & FNOINHERIT ? FALSE : TRUE,
DUPLICATE_SAME_ACCESS);
if (result) {
// _pioinfo[handle2]->fd = handle2;
fdinfo(handle2)->fdflags = fdinfo(handle1)->fdflags;
switch (handle2) {
case 0:
SetStdHandle(STD_INPUT_HANDLE, fdinfo(handle2)->hFile);
break;
case 1:
SetStdHandle(STD_OUTPUT_HANDLE, fdinfo(handle2)->hFile);
break;
case 2:
SetStdHandle(STD_ERROR_HANDLE, fdinfo(handle2)->hFile);
break;
}
return handle1;
} else {
__set_errno(EMFILE); // Is this the correct error no.?
return -1;
}
}
void* malloc(size_t sizeObject);
/*
* INTERNAL
*/
BOOL __fileno_init(void)
{
STARTUPINFOA si;
int i;
init_bucket(first_bucket);
GetStartupInfoA(&si);
if (si.cbReserved2 != 0 && si.lpReserved2 != NULL)
{
char* fdflags_ptr;
HANDLE* handle_ptr;
g_fdend = *(unsigned*)si.lpReserved2;
fdflags_ptr= (char*)(si.lpReserved2 + sizeof(unsigned));
handle_ptr = (HANDLE*)(fdflags_ptr + g_fdend * sizeof(char));
g_fdend = min(g_fdend, FDINFO_ENTRIES);
for (i = 0; i < g_fdend; i++)
{
if (!fdinfo_bucket(i))
{
if (!alloc_init_bucket(i)){
/* FIXME: free other buckets? */
return FALSE;
}
}
if ((*fdflags_ptr & FOPEN) && *handle_ptr != INVALID_HANDLE_VALUE)
{
fdinfo(i)->fdflags = *fdflags_ptr;
fdinfo(i)->hFile = *handle_ptr;
}
/*
else
{
fdinfo(i)->fdflags = 0;
fdinfo(i)->hFile = INVALID_HANDLE_VALUE;
}
*/
fdflags_ptr++; handle_ptr++;
}
for (g_fdstart = 3; g_fdstart < g_fdend; g_fdstart++)
if (fdinfo(g_fdstart)->hFile == INVALID_HANDLE_VALUE) break;
}
InitializeCriticalSection(&g_file_cs);
if (fdinfo(0)->hFile == INVALID_HANDLE_VALUE || !(fdinfo(0)->fdflags & FOPEN)) {
fdinfo(0)->hFile = GetStdHandle(STD_INPUT_HANDLE);
if (fdinfo(0)->hFile == NULL)
fdinfo(0)->hFile = INVALID_HANDLE_VALUE;
fdinfo(0)->fdflags = FOPEN|FTEXT;
}
if (fdinfo(1)->hFile == INVALID_HANDLE_VALUE || !(fdinfo(1)->fdflags & FOPEN)) {
fdinfo(1)->hFile = GetStdHandle(STD_OUTPUT_HANDLE);
if (fdinfo(1)->hFile == NULL)
fdinfo(1)->hFile = INVALID_HANDLE_VALUE;
fdinfo(1)->fdflags = FOPEN|FTEXT;
}
if (fdinfo(2)->hFile == INVALID_HANDLE_VALUE || !(fdinfo(2)->fdflags & FOPEN)) {
fdinfo(2)->hFile = GetStdHandle(STD_ERROR_HANDLE);
if (fdinfo(2)->hFile == NULL)
fdinfo(2)->hFile = INVALID_HANDLE_VALUE;
fdinfo(2)->fdflags = FOPEN|FTEXT;
}
for (i = 0; i < 3; i++)
{
/* FILE structs for stdin/out/err are static and never deleted */
// MSVCRT_fstreams[i] = &MSVCRT__iob[i];
}
// MSVCRT_stream_idx = 3;
return TRUE;
}
/* INTERNAL: Create an inheritance data block (for spawned process)
* The inheritance block is made of:
* 00 int nb of file descriptor (NBFD)
* 04 char file flags (wxflag): repeated for each fd
* 4+NBFD HANDLE file handle: repeated for each fd
*/
unsigned create_io_inherit_block(STARTUPINFOA* si)
{
int fd;
char* fdflags_ptr;
HANDLE* handle_ptr;
TRACE("create_io_inherit_block(%x)",si);
si->cbReserved2 = sizeof(unsigned) + (sizeof(char) + sizeof(HANDLE)) * g_fdend;
si->lpReserved2 = calloc(si->cbReserved2, 1);
if (!si->lpReserved2)
{
si->cbReserved2 = 0;
return( FALSE );
}
fdflags_ptr = (char*)si->lpReserved2 + sizeof(unsigned);
handle_ptr = (HANDLE*)(fdflags_ptr + g_fdend * sizeof(char));
*(unsigned*)si->lpReserved2 = g_fdend;
for (fd = 0; fd < g_fdend; fd++)
{
/* to be inherited, we need it to be open, and that DONTINHERIT isn't set */
if ((fdinfo(fd)->fdflags & (FOPEN | FNOINHERIT)) == FOPEN)
{
*fdflags_ptr = fdinfo(fd)->fdflags;
*handle_ptr = fdinfo(fd)->hFile;
}
else
{
*fdflags_ptr = 0;
*handle_ptr = INVALID_HANDLE_VALUE;
}
fdflags_ptr++; handle_ptr++;
}
return( TRUE );
}
/*
* @implemented
*/
int _setmode(int fd, int newmode)
{
int prevmode;
TRACE("_setmode(%d, %d)", fd, newmode);
if (!is_valid_fd(fd))
{
DPRINT1("_setmode: inval fd (%d)\n",fd);
//errno = EBADF;
return(-1);
}
if (newmode & ~(_O_TEXT|_O_BINARY))
{
DPRINT1("_setmode: fd (%d) mode (0x%08x) unknown\n",fd,newmode);
/* FIXME: Should we fail with EINVAL here? */
}
prevmode = fdinfo(fd)->fdflags & FTEXT ? _O_TEXT : _O_BINARY;
if ((newmode & _O_TEXT) == _O_TEXT)
{
fdinfo(fd)->fdflags |= FTEXT;
}
else
{
/* FIXME: If both _O_TEXT and _O_BINARY are set, we get here.
* Should we fail with EINVAL instead? -Gunnar
*/
fdinfo(fd)->fdflags &= ~FTEXT;
}
return(prevmode);
}

View file

@ -1,53 +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>
#define NDEBUG
#include <internal/debug.h>
/*
* @implemented
*/
int _pipe(int _fildes[2], unsigned int size, int mode )
{
HANDLE hReadPipe, hWritePipe;
SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE};
TRACE("_pipe((%i,%i), %ui, %i)", _fildes[0], _fildes[1], size, mode);
if (mode & O_NOINHERIT)
sa.bInheritHandle = FALSE;
if (!CreatePipe(&hReadPipe,&hWritePipe,&sa,size)) {
_dosmaperr(GetLastError());
return( -1);
}
if ((_fildes[0] = alloc_fd(hReadPipe, split_oflags(mode))) < 0)
{
CloseHandle(hReadPipe);
CloseHandle(hWritePipe);
__set_errno(EMFILE);
return(-1);
}
if ((_fildes[1] = alloc_fd(hWritePipe, split_oflags(mode))) < 0)
{
free_fd(_fildes[0]);
CloseHandle(hReadPipe);
CloseHandle(hWritePipe);
__set_errno(EMFILE);
return(-1);
}
return(0);
}

View file

@ -1,100 +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: Ariadne
* 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>
#define NDEBUG
#include <internal/debug.h>
/*
* @implemented
*/
int _read(int _fd, void *_buf, unsigned int _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 = (HANDLE)_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,16 +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: Ariadne
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include <precomp.h>
#define NDEBUG
#include <internal/debug.h>

View file

@ -1,20 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crt/??????
* PURPOSE: Unknown
* PROGRAMER: Unknown
* UPDATE HISTORY:
* 25/11/05: Created
*/
#include <precomp.h>
/*
* @implemented
*/
int _sopen(const char *path, int access, int shflag, ... /*mode, permissin*/)
{
//FIXME: vararg
return _open((path), (access)|(shflag));//, (mode));
}

View file

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

View file

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

View file

@ -1,19 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crt/??????
* PURPOSE: Unknown
* PROGRAMER: Unknown
* UPDATE HISTORY:
* 25/11/05: Created
*/
#include <precomp.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 <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,28 +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: Ariadne
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include <precomp.h>
#define NDEBUG
#include <internal/debug.h>
/*
* @implemented
*/
int _unlink(const char* filename)
{
DPRINT("_unlink('%s')\n", filename);
if (!DeleteFileA(filename)) {
_dosmaperr(GetLastError());
return -1;
}
return 0;
}

View file

@ -1,31 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crt/??????
* PURPOSE: Unknown
* PROGRAMER: Unknown
* UPDATE HISTORY:
* 25/11/05: Created
*/
#include <precomp.h>
#include <sys/utime.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,4 +0,0 @@
#define UNICODE
#define _UNICODE
#include "access.c"

View file

@ -1,4 +0,0 @@
#define _UNICODE
#define UNICODE
#include "chmod.c"

View file

@ -1,24 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crt/??????
* PURPOSE: Unknown
* PROGRAMER: Unknown
* UPDATE HISTORY:
* 25/11/05: Created
*/
#include <precomp.h>
#define NDEBUG
#include <internal/debug.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,5 +0,0 @@
#define UNICODE
#define _UNICODE
#include "find.c"

View file

@ -1,76 +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
Ariadne
* 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 <precomp.h>
#define NDEBUG
#include <internal/debug.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,143 +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: Ariadne
* 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 <stdarg.h>
#endif
#include <sys/stat.h>
#include <share.h>
#define NDEBUG
#include <internal/debug.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 alloc_fd(hFile,split_oflags(_oflag));
}
/*
* @implemented
*/
int _wsopen(const wchar_t* path, int access, int shflag,.../* int mode*/)
{
//FIXME: vararg
return _wopen((path), (access)|(shflag));//, (mode));
}

View file

@ -1,98 +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: Ariadne
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include <precomp.h>
#define NDEBUG
#include <internal/debug.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
*/
int _write(int _fd, const void* _buf, unsigned int _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((HANDLE)_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((HANDLE)_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((HANDLE)_get_osfhandle(_fd), _buf, _nbyte, &wbyte, NULL)) {
_dosmaperr(GetLastError());
return -1;
}
return wbyte;
}
}

View file

@ -1,27 +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: Ariadne
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include <precomp.h>
#define NDEBUG
#include <internal/debug.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,32 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crt/??????
* PURPOSE: Unknown
* PROGRAMER: Unknown
* UPDATE HISTORY:
* 25/11/05: Created
*/
#include <precomp.h>
#include <sys/utime.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,276 +0,0 @@
/*
* Some stuff takem from wine msvcrt\locale.c
*
* Copyright 2000 Jon Griffiths
*/
#include <precomp.h>
#include <locale.h>
#include <internal/tls.h>
#define NDEBUG
#include <internal/debug.h>
unsigned int __setlc_active;
unsigned int __unguarded_readlc_active;
int _current_category; /* used by setlocale */
const char *_current_locale;
int parse_locale(const 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(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(const 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;
}
/*********************************************************************
* _Gettnames (MSVCRT.@)
*/
void *_Gettnames(void)
{
DPRINT1("(void), stub!\n");
return NULL;
}
/*********************************************************************
* __lconv_init (MSVCRT.@)
*/
void __lconv_init(void)
{
DPRINT1(" stub\n");
}
/*********************************************************************
* _Strftime (MSVCRT.@)
*/
const char* _Strftime(char *out, unsigned int len, const char *fmt,
const void *tm, void *foo)
{
/* FIXME: */
DPRINT1("(%p %d %s %p %p) stub\n", out, len, fmt, tm, foo);
return "";
}
/*********************************************************************
* _Getdays (MSVCRT.@)
*/
const char* _Getdays(void)
{
static const char *MSVCRT_days = ":Sun:Sunday:Mon:Monday:Tue:Tuesday:Wed:"
"Wednesday:Thu:Thursday:Fri:Friday:Sat:Saturday";
/* FIXME: Use locale */
DPRINT1("(void) semi-stub\n");
return MSVCRT_days;
}
/*********************************************************************
* _Getmonths (MSVCRT.@)
*/
const char* _Getmonths(void)
{
static const char *MSVCRT_months = ":Jan:January:Feb:February:Mar:March:Apr:"
"April:May:May:Jun:June:Jul:July:Aug:August:Sep:September:Oct:"
"October:Nov:November:Dec:December";
/* FIXME: Use locale */
DPRINT1("(void) semi-stub\n");
return MSVCRT_months;
}
/*********************************************************************
* __crtLCMapStringA (MSVCRT.@)
*/
int __crtLCMapStringA(
LCID lcid, DWORD mapflags, const char* src, int srclen, char* dst,
int dstlen, unsigned int codepage, int xflag
) {
DPRINT1("(lcid %lx, flags %lx, %s(%d), %p(%d), %x, %d), partial stub!\n",
lcid,mapflags,src,srclen,dst,dstlen,codepage,xflag);
/* FIXME: A bit incorrect. But msvcrt itself just converts its
* arguments to wide strings and then calls LCMapStringW
*/
return LCMapStringA(lcid,mapflags,src,srclen,dst,dstlen);
}

View file

@ -1,27 +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 <math.h>
double acos(double __x)
{
return atan2(sqrt(1.0 - __x * __x), __x);
}

View file

@ -1,7 +0,0 @@
/* $Id$
*
*/
int _adjust_fdiv = 0;
/* EOF */

View file

@ -1,27 +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 <math.h>
double asin(double __x)
{
return atan2(__x, sqrt(1.0 - __x * __x));
}

View file

@ -1,14 +0,0 @@
#include <math.h>
/*
* @implemented
*/
double _cabs( struct _complex z )
{
return sqrt( z.x*z.x + z.y*z.y );
// return hypot(z.x,z.y);
}

View file

@ -1,12 +0,0 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <math.h>
/*
* @implemented
*/
double cosh(double x)
{
const double ebig = exp(fabs(x));
return (ebig + 1.0/ebig) / 2.0;
}

View file

@ -1,29 +0,0 @@
#include <math.h>
#include <stdlib.h>
#include <internal/ieee.h>
/*
* @implemented
*/
double
frexp(double __x, int *exptr)
{
union
{
double* __x;
double_t* x;
} x;
x.__x = &__x;
if ( exptr != NULL )
*exptr = x.x->exponent - 0x3FE;
x.x->exponent = 0x3FE;
return __x;
}

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