-critical.c: catch (more) invalid use
-impl. sscanf (stolen from wine)
crt:
-use native mingw headers and not private copies of them
-converted some routines to using tchar == impl. many missing unicode routines
-impl. sscanf and friends correctly (stolen from wine)
tchar.h:
-added lotsa missin stuff

svn path=/trunk/; revision=13608
This commit is contained in:
Gunnar Dalsnes 2005-02-16 22:29:48 +00:00
parent 0645d3e055
commit 55fb40a502
388 changed files with 3422 additions and 4595 deletions

View file

@ -6,8 +6,8 @@
* PROGRAMMER: Eric Kohl (Imported from DJGPP)
*/
#include <msvcrt/conio.h>
#include <msvcrt/stdlib.h>
#include <conio.h>
#include <stdlib.h>
/*
* @implemented

View file

@ -6,8 +6,9 @@
* PROGRAMMER: Eric Kohl (Imported from DJGPP)
*/
#include <msvcrt/stdio.h>
#include <msvcrt/conio.h>
#include <stdio.h>
#include <stdarg.h>
#include <conio.h>
/*
* @unimplemented

View file

@ -9,10 +9,10 @@
*/
#include "precomp.h"
#include <msvcrt/conio.h>
#include <msvcrt/string.h>
#include <msvcrt/stdio.h>
#include <msvcrt/internal/file.h>
#include <conio.h>
#include <string.h>
#include <stdio.h>
#include <internal/file.h>
/*
@ -22,7 +22,7 @@ int _cputs(const char *_str)
{
int len = strlen(_str);
DWORD written = 0;
if (!WriteFile(filehnd(stdout->_file),_str,len,&written,NULL))
if (!WriteFile( fdinfo(stdout->_file)->hFile ,_str,len,&written,NULL))
return -1;
return 0;
}

View file

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

View file

@ -9,10 +9,10 @@
*/
#include "precomp.h"
#include <msvcrt/conio.h>
#include <msvcrt/stdio.h>
#include <msvcrt/io.h>
#include <msvcrt/internal/console.h>
#include <conio.h>
#include <stdio.h>
#include <io.h>
#include <internal/console.h>
/*
@ -26,7 +26,7 @@ int _getch(void)
c = ungot_char;
char_avail = 0;
} else {
ReadConsoleA(_get_osfhandle(stdin->_file),
ReadConsoleA((HANDLE)_get_osfhandle(stdin->_file),
&c,
1,
&NumberOfCharsRead,

View file

@ -10,11 +10,11 @@
* 28/12/98: Created
*/
#include <msvcrt/conio.h>
#include <msvcrt/internal/console.h>
#include <conio.h>
#include <internal/console.h>
int getche(void)
int _getche(void)
{
if (char_avail)
/*
@ -26,6 +26,6 @@ int getche(void)
* hasn't been got by a conio function.
* We don't echo again.
*/
return(getch());
return (_putch(getch()));
return(_getch());
return (_putch(_getch()));
}

View file

@ -9,8 +9,8 @@
*/
#include "precomp.h"
#include <msvcrt/conio.h>
#include <msvcrt/internal/console.h>
#include <conio.h>
#include <internal/console.h>
/*

View file

@ -9,7 +9,7 @@
*/
#include "precomp.h"
#include <msvcrt/conio.h>
#include <conio.h>
/*
* @implemented

View file

@ -10,8 +10,8 @@
* 28/12/98: Created
*/
#include <msvcrt/conio.h>
#include <msvcrt/internal/console.h>
#include <conio.h>
#include <internal/console.h>
#define EOF -1

View file

@ -6,7 +6,7 @@
* PROGRAMMER: Copyright (C) 1995 DJ Delorie
*/
#include <msvcrt/ctype.h>
#include <ctype.h>
unsigned short _ctype[] = {
0, /* <EOF>, 0xFFFF */

View file

@ -7,7 +7,7 @@
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include <msvcrt/ctype.h>
#include <ctype.h>
#undef isalnum

View file

@ -8,7 +8,7 @@
* 28/12/98: Created
*/
#include <msvcrt/ctype.h>
#include <ctype.h>
#undef isalpha

View file

@ -8,7 +8,7 @@
* 28/12/98: Created
*/
#include <msvcrt/ctype.h>
#include <ctype.h>
/*
* @implemented

View file

@ -6,7 +6,7 @@
* PROGRAMMER: Copyright (C) 1995 DJ Delorie
*/
#include <msvcrt/ctype.h>
#include <ctype.h>
#undef iscntrl
/*

View file

@ -7,7 +7,7 @@
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include <msvcrt/ctype.h>
#include <ctype.h>
/*

View file

@ -6,7 +6,7 @@
* PROGRAMMER: Copyright (C) 1995 DJ Delorie
*/
#include <msvcrt/ctype.h>
#include <ctype.h>
extern unsigned short _ctype[];
@ -34,7 +34,7 @@ unsigned short **__p__pwctype(void)
/*
* @implemented
*/
int _isctype(unsigned int c, int ctypeFlags)
int _isctype(int c, int ctypeFlags)
{
return (_pctype[(unsigned char)(c & 0xFF)] & ctypeFlags);
}

View file

@ -6,7 +6,7 @@
* PROGRAMMER: Copyright (C) 1995 DJ Delorie
*/
#include <msvcrt/ctype.h>
#include <ctype.h>
#undef isdigit

View file

@ -6,7 +6,7 @@
* PROGRAMMER: Copyright (C) 1995 DJ Delorie
*/
#include <msvcrt/ctype.h>
#include <ctype.h>
#undef isgraph
/*

View file

@ -6,7 +6,7 @@
* PROGRAMMER: Copyright (C) 1995 DJ Delorie
*/
#include <msvcrt/ctype.h>
#include <ctype.h>
#undef islower

View file

@ -6,7 +6,7 @@
* PROGRAMMER: Copyright (C) 1995 DJ Delorie
*/
#include <msvcrt/ctype.h>
#include <ctype.h>
#undef isprint
/*

View file

@ -6,7 +6,7 @@
* PROGRAMMER: Copyright (C) 1995 DJ Delorie
*/
#include <msvcrt/ctype.h>
#include <ctype.h>
#undef ispunct
/*

View file

@ -8,7 +8,7 @@
* 28/12/98: Created
*/
#include <msvcrt/ctype.h>
#include <ctype.h>
#undef isspace

View file

@ -6,7 +6,7 @@
* PROGRAMMER: Copyright (C) 1995 DJ Delorie
*/
#include <msvcrt/ctype.h>
#include <ctype.h>
#undef isupper
/*

View file

@ -6,7 +6,7 @@
* PROGRAMMER: Copyright (C) 1995 DJ Delorie
*/
#include <msvcrt/ctype.h>
#include <ctype.h>
#undef isxdigit
/*

View file

@ -6,7 +6,7 @@
* PROGRAMMER: Copyright (C) 1995 DJ Delorie
*/
#include <msvcrt/ctype.h>
#include <ctype.h>
/*
* @implemented

View file

@ -6,7 +6,7 @@
* PROGRAMMER: Copyright (C) 1995 DJ Delorie
*/
#include <msvcrt/ctype.h>
#include <ctype.h>
#undef tolower
/*

View file

@ -6,7 +6,7 @@
* PROGRAMMER: Copyright (C) 1995 DJ Delorie
*/
#include <msvcrt/ctype.h>
#include <ctype.h>
#undef toupper
/*

View file

@ -1,7 +1,7 @@
#include "precomp.h"
#include <msvcrt/ctype.h>
#include <msvcrt/direct.h>
#include <msvcrt/internal/file.h>
#include <ctype.h>
#include <direct.h>
#include <internal/file.h>
/*
* @implemented

View file

@ -1,9 +1,9 @@
#include "precomp.h"
#include <msvcrt/ctype.h>
#include <msvcrt/direct.h>
#include <msvcrt/stdlib.h>
#include <msvcrt/errno.h>
#include <msvcrt/internal/file.h>
#include <ctype.h>
#include <direct.h>
#include <stdlib.h>
#include <errno.h>
#include <internal/file.h>
int cur_drive = 0;

View file

@ -1,8 +1,8 @@
#include "precomp.h"
#include <msvcrt/direct.h>
#include <msvcrt/stdlib.h>
#include <msvcrt/errno.h>
#include <msvcrt/internal/file.h>
#include <direct.h>
#include <stdlib.h>
#include <errno.h>
#include <internal/file.h>
/*

View file

@ -1,6 +1,6 @@
#include "precomp.h"
#include <msvcrt/direct.h>
#include <msvcrt/internal/file.h>
#include <direct.h>
#include <internal/file.h>
/*
* @implemented

View file

@ -1,6 +1,6 @@
#include "precomp.h"
#include <msvcrt/ctype.h>
#include <msvcrt/direct.h>
#include <ctype.h>
#include <direct.h>
/*

View file

@ -1,6 +1,6 @@
#include "precomp.h"
#include <msvcrt/ctype.h>
#include <msvcrt/direct.h>
#include <ctype.h>
#include <direct.h>
extern int cur_drive;

View file

@ -1,6 +1,6 @@
#include "precomp.h"
#include <msvcrt/direct.h>
#include <msvcrt/internal/file.h>
#include <direct.h>
#include <internal/file.h>
/*

View file

@ -1,6 +1,6 @@
#include "precomp.h"
#include <msvcrt/direct.h>
#include <msvcrt/internal/file.h>
#include <direct.h>
#include <internal/file.h>
/*

View file

@ -1,8 +1,7 @@
#include "precomp.h"
#include <msvcrt/ctype.h>
#include <msvcrt/direct.h>
#include <msvcrt/internal/file.h>
#include <msvcrt/internal/file.h>
#include <ctype.h>
#include <direct.h>
#include <internal/file.h>
/*
* @implemented

View file

@ -1,8 +1,8 @@
#include "precomp.h"
#include <msvcrt/direct.h>
#include <msvcrt/stdlib.h>
#include <msvcrt/errno.h>
#include <msvcrt/internal/file.h>
#include <direct.h>
#include <stdlib.h>
#include <errno.h>
#include <internal/file.h>
/*

View file

@ -1,6 +1,6 @@
#include "precomp.h"
#include <msvcrt/direct.h>
#include <msvcrt/internal/file.h>
#include <direct.h>
#include <internal/file.h>
/*

View file

@ -1,6 +1,6 @@
#include "precomp.h"
#include <msvcrt/direct.h>
#include <msvcrt/internal/file.h>
#include <direct.h>
#include <internal/file.h>
/*

View file

@ -1,6 +1,6 @@
#include "precomp.h"
#include <msvcrt/direct.h>
#include <msvcrt/internal/file.h>
#include <direct.h>
#include <internal/file.h>
/*

View file

@ -1,5 +1,5 @@
#include <msvcrt/float.h>
#include <msvcrt/internal/ieee.h>
#include <float.h>
#include <internal/ieee.h>
/*

View file

@ -1,4 +1,4 @@
#include <msvcrt/float.h>
#include <float.h>
/*
* @implemented

View file

@ -1,6 +1,6 @@
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <msvcrt/float.h>
#include <float.h>
#define X87_CW_IM (1<<0) /* Invalid operation mask */
#define X87_CW_DM (1<<1) /* Denormal operand mask */

View file

@ -1,5 +1,5 @@
#include <msvcrt/float.h>
#include <msvcrt/internal/ieee.h>
#include <float.h>
#include <internal/ieee.h>
/*
* @implemented

View file

@ -1,6 +1,6 @@
#include <msvcrt/float.h>
#include <msvcrt/math.h>
#include <msvcrt/internal/ieee.h>
#include <float.h>
#include <math.h>
#include <internal/ieee.h>
#define _FPCLASS_SNAN 0x0001 /* signaling NaN */

View file

@ -2,8 +2,8 @@
#undef __USE_W32API
#endif
#include <msvcrt/float.h>
#include <msvcrt/internal/tls.h>
#include <float.h>
#include <internal/tls.h>
/*
* @implemented

View file

@ -1,4 +1,4 @@
#include <msvcrt/float.h>
#include <float.h>
/*

View file

@ -16,9 +16,9 @@ License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <msvcrt/math.h>
#include <msvcrt/float.h>
#include <msvcrt/internal/ieee.h>
#include <math.h>
#include <float.h>
#include <internal/ieee.h>
/*

View file

@ -18,7 +18,7 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <msvcrt/float.h>
#include <float.h>
double _logb (double __x)
{

View file

@ -1,4 +1,4 @@
#include <msvcrt/float.h>
#include <float.h>
/*
@ -9,7 +9,7 @@ double _nextafter( double x, double y )
if ( x == y)
return x;
if ( isnan(x) || isnan(y) )
if ( _isnan(x) || _isnan(y) )
return x;
return x;

View file

@ -1,5 +1,5 @@
#include <msvcrt/float.h>
#include <msvcrt/internal/ieee.h>
#include <float.h>
#include <internal/ieee.h>
/*
* @implemented

View file

@ -1,4 +1,4 @@
#include <msvcrt/float.h>
#include <float.h>
/*
* @implemented

View file

@ -1,17 +1,26 @@
#include "precomp.h"
#include <msvcrt/io.h>
#include <msvcrt/errno.h>
#include <io.h>
#include <errno.h>
#include <tchar.h>
#include <internal/file.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
#include <internal/msvcrtdbg.h>
#ifdef _UNICODE
#define _TS S
#else
#define _TS s
#endif
/*
* @implemented
*/
int _access( const char *_path, int _amode )
int _taccess( const _TCHAR *_path, int _amode )
{
DWORD Attributes = GetFileAttributesA(_path);
DPRINT("_access('%s', %x)\n", _path, _amode);
DWORD Attributes = GetFileAttributes(_path);
DPRINT(MK_STR(_taccess)"('%"_TS"', %x)\n", _path, _amode);
if (Attributes == -1) {
_dosmaperr(GetLastError());
@ -23,11 +32,31 @@ int _access( const char *_path, int _amode )
return -1;
}
}
if ((_amode & D_OK) == D_OK) {
if ((Attributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY) {
__set_errno(EACCES);
return -1;
}
}
return 0;
}
/*
* INTERNAL
*/
int access_dirT(const _TCHAR *_path)
{
DWORD Attributes = GetFileAttributes(_path);
DPRINT(MK_STR(is_dirT)"('%"_TS"')\n", _path);
if (Attributes == -1) {
_dosmaperr(GetLastError());
return -1;
}
if ((Attributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY)
{
__set_errno(EACCES);
return -1;
}
return 0;
}

View file

@ -1,9 +1,13 @@
#include "precomp.h"
#include <msvcrt/io.h>
#include <msvcrt/internal/file.h>
#include <io.h>
#include <sys/stat.h>
#include <tchar.h>
#include <internal/file.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
#include <internal/msvcrtdbg.h>
#define mode_t int
@ -11,14 +15,14 @@
/*
* @implemented
*/
int _chmod(const char* filename, mode_t mode)
int _tchmod(const _TCHAR* filename, mode_t mode)
{
DWORD FileAttributes = 0;
BOOLEAN Set = FALSE;
DPRINT("_chmod('%s', %x)\n", filename, mode);
DPRINT(#_tchmod"('%"sT"', %x)\n", filename, mode);
FileAttributes = GetFileAttributesA(filename);
FileAttributes = GetFileAttributes(filename);
if ( FileAttributes == -1 ) {
_dosmaperr(GetLastError());
return -1;
@ -38,7 +42,7 @@ int _chmod(const char* filename, mode_t mode)
Set = TRUE;
}
}
if (Set && SetFileAttributesA(filename, FileAttributes) == FALSE) {
if (Set && SetFileAttributes(filename, FileAttributes) == FALSE) {
_dosmaperr(GetLastError());
return -1;
}

View file

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

View file

@ -1,19 +1,22 @@
#include "precomp.h"
#include <msvcrt/io.h>
#include <msvcrt/internal/file.h>
#include <io.h>
#include <internal/file.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
#include <internal/msvcrtdbg.h>
/*
* @implemented
*/
int _close(int _fd)
{
DPRINT("_close(fd %d)\n", _fd);
if (_fd == -1)
return -1;
if (CloseHandle(_get_osfhandle(_fd)) == FALSE)
return -1;
return __fileno_close(_fd);
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,7 +1,7 @@
#include "precomp.h"
#include <msvcrt/io.h>
#include <msvcrt/errno.h>
#include <msvcrt/internal/file.h>
#include <io.h>
#include <errno.h>
#include <internal/file.h>
/*
@ -9,7 +9,7 @@
*/
int _commit(int _fd)
{
if (! FlushFileBuffers(_get_osfhandle(_fd)) ) {
if (! FlushFileBuffers((HANDLE)_get_osfhandle(_fd)) ) {
__set_errno(EBADF);
return -1;
}

View file

@ -1,8 +1,8 @@
#include <msvcrt/io.h>
#include <msvcrt/fcntl.h>
#include <io.h>
#include <fcntl.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
#include <internal/msvcrtdbg.h>
/*

View file

@ -1,7 +1,7 @@
#include "precomp.h"
#include <msvcrt/io.h>
#include <msvcrt/errno.h>
#include <msvcrt/internal/file.h>
#include <io.h>
#include <errno.h>
#include <internal/file.h>
/*
@ -14,7 +14,7 @@ int _dup(int handle)
BOOL result;
int fd;
hFile = _get_osfhandle(handle);
hFile = (HANDLE)_get_osfhandle(handle);
if (hFile == INVALID_HANDLE_VALUE) {
__set_errno(EBADF);
return -1;
@ -31,7 +31,7 @@ int _dup(int handle)
return -1;
}
fd = __fileno_alloc(hFile, __fileno_getmode(handle));
fd = alloc_fd(hFile, __fileno_getmode(handle));
if (fd < 0)
{
CloseHandle(hFile);

View file

@ -1,5 +1,5 @@
#include <msvcrt/io.h>
#include <msvcrt/internal/file.h>
#include <io.h>
#include <internal/file.h>
/*
* @implemented

View file

@ -1,4 +1,5 @@
#include <msvcrt/io.h>
#include <stdio.h>
#include <io.h>
/*
* @implemented

View file

@ -1,6 +1,6 @@
#include "precomp.h"
#include <msvcrt/io.h>
#include <msvcrt/internal/file.h>
#include <io.h>
#include <internal/file.h>
/*
@ -8,7 +8,7 @@
*/
long _filelength(int _fd)
{
DWORD len = GetFileSize(_get_osfhandle(_fd), NULL);
DWORD len = GetFileSize((HANDLE)_get_osfhandle(_fd), NULL);
if (len == INVALID_FILE_SIZE) {
DWORD oserror = GetLastError();
if (oserror != 0) {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,6 +1,6 @@
#include "precomp.h"
#include <msvcrt/io.h>
#include <msvcrt/internal/file.h>
#include <io.h>
#include <internal/file.h>
/*
@ -8,7 +8,7 @@
*/
long _lseek(int _fildes, long _offset, int _whence)
{
DWORD newpos = SetFilePointer((HANDLE)filehnd(_fildes), _offset, NULL, _whence);
DWORD newpos = SetFilePointer((HANDLE)fdinfo(_fildes)->hFile, _offset, NULL, _whence);
if (newpos == INVALID_SET_FILE_POINTER) {
DWORD oserror = GetLastError();
if (oserror != 0) {

View file

@ -1,6 +1,6 @@
#include "precomp.h"
#include <msvcrt/io.h>
#include <msvcrt/internal/file.h>
#include <io.h>
#include <internal/file.h>
//#define SETFILEPOINTEREX_AVAILABLE
@ -19,7 +19,7 @@ __int64 _lseeki64(int _fildes, __int64 _offset, int _whence)
// __set_errno ( EBADF );
// return -1L;
// }
if (SetFilePointerEx((HANDLE)filehnd(_fildes), offset, &new_pos, _whence)) {
if (SetFilePointerEx((HANDLE)fdinfo(_fildes)->hFile, offset, &new_pos, _whence)) {
} else {
_dosmaperr(error);
return -1L;
@ -34,7 +34,7 @@ __int64 _lseeki64(int _fildes, __int64 _offset, int _whence)
LARGE_INTEGER offset;
offset.QuadPart = _offset;
offset.u.LowPart = SetFilePointer((HANDLE)filehnd(_fildes),
offset.u.LowPart = SetFilePointer((HANDLE)fdinfo(_fildes)->hFile,
offset.u.LowPart, &offset.u.HighPart, _whence);
return ((((__int64)offset.u.HighPart) << 32) + offset.u.LowPart);

View file

@ -13,12 +13,12 @@
/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <msvcrt/stdio.h>
#include <msvcrt/string.h>
#include <msvcrt/io.h>
#include <stdio.h>
#include <string.h>
#include <io.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
#include <internal/msvcrtdbg.h>
/*

View file

@ -8,87 +8,139 @@
* 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 <msvcrt/stdarg.h>
#include <stdarg.h>
#endif
#include <msvcrt/io.h>
#include <msvcrt/fcntl.h>
#include <msvcrt/sys/stat.h>
#include <msvcrt/stdlib.h>
#include <msvcrt/string.h>
#include <msvcrt/share.h>
#include <msvcrt/errno.h>
#include <msvcrt/internal/file.h>
#include <io.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <string.h>
#include <share.h>
#include <errno.h>
#include <internal/file.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
#include <internal/msvcrtdbg.h>
//#define _OLD_BUILD_
#define STD_AUX_HANDLE 3
#define STD_PRINTER_HANDLE 4
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)
/////////////////////////////////////////
#if 0 // from perl sources
#ifndef _INTPTR_T_DEFINED
typedef int intptr_t;
#define _INTPTR_T_DEFINED
#endif
#ifndef _UINTPTR_T_DEFINED
typedef unsigned int uintptr_t;
#define _UINTPTR_T_DEFINED
#endif
static int g_fdstart = 3; /* first unallocated fd */
static int g_fdend = 3; /* highest allocated fd */
/*
* Control structure for lowio file handles
* INTERNAL
*/
typedef struct {
intptr_t osfhnd;/* underlying OS file HANDLE */
char osfile; /* attributes of file (e.g., open in text mode?) */
char pipech; /* one char buffer for handles opened on pipes */
int lockinitflag;
//CRITICAL_SECTION lock;
} ioinfo;
/*
* Array of arrays of control structures for lowio files.
*/
//ioinfo* __pioinfo[];
//ioinfo* __pioinfo[] = { NULL };
#endif
/////////////////////////////////////////
typedef struct _fileno_modes_type
/*
static inline FD_INFO* fdinfo(int fd)
{
HANDLE hFile;
int mode;
char pipech; /* one char buffer for handles opened on pipes */
int lockinitflag;
/*CRITICAL_SECTION*/int lock;
int fd;
} fileno_modes_type;
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));
}
*/
//static fileno_modes_type* fileno_modes = NULL;
fileno_modes_type* __pioinfo = NULL;
/////////////////////////////////////////
int maxfno = 0;
/*
* INTERNAL
*/
inline BOOL is_valid_fd(int fd)
{
BOOL b = (fd >= 0 && fd < g_fdend && (fdinfo(fd)->fdflags & FOPEN));
if (!b){
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);
}
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 || __pioinfo == NULL )
if ( p == NULL || fdinfo_bucket((p)->_file) == NULL )
return FALSE;
return (!((p)->_flag&_IOSTRG) && (__pioinfo[(p)->_file].mode&O_TEXT));
return (!((p)->_flag&_IOSTRG) && (fdinfo((p)->_file)->fdflags & FTEXT));
}
/*
@ -112,7 +164,9 @@ int _open(const char* _path, int _oflag,...)
pmode = va_arg(arg, int);
#endif
// DPRINT("_open('%s', %x, (%x))\n", _path, _oflag, pmode);
TRACE("_open('%s', %x, (%x))\n", _path, _oflag);
if ((_oflag & S_IREAD ) == S_IREAD)
dwShareMode = FILE_SHARE_READ;
@ -188,155 +242,304 @@ int _open(const char* _path, int _oflag,...)
NULL);
if (hFile == (HANDLE)-1) {
_dosmaperr(GetLastError());
return -1;
return( -1);
}
DPRINT("OK\n");
if (!(_oflag & (_O_TEXT|_O_BINARY))) {
_oflag |= __fmode;
_oflag |= _fmode;
}
return __fileno_alloc(hFile,_oflag);
return(alloc_fd(hFile, split_oflags(_oflag)));
}
int __fileno_alloc(HANDLE hFile, int mode)
/*
* INTERNAL
*/
static void init_bucket(FDINFO* entry)
{
int i;
/* Check for bogus values */
if (hFile < 0)
return -1;
for (i = 5; i < maxfno; i++) {
if (__pioinfo[i].fd == -1 ) {
__pioinfo[i].fd = i;
__pioinfo[i].mode = mode;
__pioinfo[i].hFile = hFile;
return i;
}
}
/* See if we need to expand the tables. Check this BEFORE it might fail,
so that when we hit the count'th request, we've already up'd it. */
if (i == maxfno) {
int oldcount = maxfno;
fileno_modes_type* old_fileno_modes = __pioinfo;
maxfno += 255;
__pioinfo = (fileno_modes_type*)malloc(maxfno * sizeof(fileno_modes_type));
if (old_fileno_modes != NULL) {
memcpy(__pioinfo, old_fileno_modes, oldcount * sizeof(fileno_modes_type));
free(old_fileno_modes);
}
memset(__pioinfo + oldcount, -1, (maxfno-oldcount)*sizeof(fileno_modes_type));
}
/* Fill in the value */
__pioinfo[i].fd = i;
__pioinfo[i].mode = mode;
__pioinfo[i].hFile = hFile;
return i;
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;
}
}
void* filehnd(int fileno)
/*
* INTERNAL
*/
static BOOL alloc_init_bucket(int fd)
{
if (fileno < 0 || fileno >= maxfno || __pioinfo[fileno].fd == -1) {
return (void*)-1;
}
return __pioinfo[fileno].hFile;
fdinfo_bucket(fd) = malloc(FDINFO_ENTRIES_PER_BUCKET * sizeof(FDINFO));
if (!fdinfo_bucket(fd)) return FALSE;
init_bucket(fdinfo_bucket(fd));
return TRUE;
}
int __fileno_setmode(int _fd, int _newmode)
/*
* 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)
{
int m;
if (_fd < 0 || _fd >= maxfno) {
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;
}
m = __pioinfo[_fd].mode;
__pioinfo[_fd].mode = _newmode;
return m;
}
int __fileno_getmode(int _fd)
{
if (_fd < 0 || _fd >= maxfno) {
__set_errno(EBADF);
return -1;
}
return __pioinfo[_fd].mode;
return fdinfo(fd)->fdflags;
}
int __fileno_close(int _fd)
/*
* INTERNAL
*/
void free_fd(int fd)
{
if (_fd < 0 || _fd >= maxfno) {
__set_errno(EBADF);
return -1;
}
__pioinfo[_fd].fd = -1;
__pioinfo[_fd].hFile = (HANDLE)-1;
return 0;
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(void* osfhandle, int flags)
int _open_osfhandle(long osfhandle, int oflags)
{
return __fileno_alloc((HANDLE)osfhandle, flags);
/*
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
*/
void* _get_osfhandle( int fileno )
long _get_osfhandle(int fd)
{
return filehnd(fileno);
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 >= maxfno || handle1 < 0 || handle2 >= maxfno || handle2 < 0) {
if (handle1 >= FDINFO_ENTRIES || handle1 < 0 || handle2 >= FDINFO_ENTRIES || handle2 < 0) {
__set_errno(EBADF);
return -1;
}
if (__pioinfo[handle1].fd == -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 (_pioinfo[handle2]->fd != -1) {
if (fdinfo(handle2)->hFile != INVALID_HANDLE_VALUE) {
_close(handle2);
}
hProcess = GetCurrentProcess();
result = DuplicateHandle(hProcess,
__pioinfo[handle1].hFile,
fdinfo(handle1)->hFile,
hProcess,
&__pioinfo[handle2].hFile,
&fdinfo(handle2)->hFile,
0,
TRUE,
DUPLICATE_SAME_ACCESS);
if (result) {
__pioinfo[handle2].fd = handle2;
__pioinfo[handle2].mode = __pioinfo[handle1].mode;
// _pioinfo[handle2]->fd = handle2;
fdinfo(handle2)->fdflags = fdinfo(handle1)->fdflags;
switch (handle2) {
case 0:
SetStdHandle(STD_INPUT_HANDLE, __pioinfo[handle2].hFile);
SetStdHandle(STD_INPUT_HANDLE, fdinfo(handle2)->hFile);
break;
case 1:
SetStdHandle(STD_OUTPUT_HANDLE, __pioinfo[handle2].hFile);
SetStdHandle(STD_OUTPUT_HANDLE, fdinfo(handle2)->hFile);
break;
case 2:
SetStdHandle(STD_ERROR_HANDLE, __pioinfo[handle2].hFile);
break;
case 3:
SetStdHandle(STD_AUX_HANDLE, __pioinfo[handle2].hFile);
break;
case 4:
SetStdHandle(STD_AUX_HANDLE, __pioinfo[handle2].hFile);
SetStdHandle(STD_ERROR_HANDLE, fdinfo(handle2)->hFile);
break;
}
return handle1;
} else {
__set_errno(EMFILE); // Is this the correct error no.?
@ -347,77 +550,172 @@ int __fileno_dup2(int handle1, int handle2)
void* malloc(size_t sizeObject);
/*
* INTERNAL
*/
BOOL __fileno_init(void)
{
ULONG count = 0, i;
HANDLE* pFile;
char* pmode;
STARTUPINFOA StInfo;
STARTUPINFOA si;
int i;
GetStartupInfoA(&StInfo);
if (StInfo.lpReserved2 && StInfo.cbReserved2 >= sizeof(ULONG)) {
count = *(ULONG*)StInfo.lpReserved2;
/*
if (sizeof(ULONG) + count * (sizeof(HANDLE) + sizeof(char)) != StInfo.cbReserved2)
{
count = 0;
}
*/
}
maxfno = 255;
while(count >= maxfno)
maxfno += 255;
init_bucket(first_bucket);
GetStartupInfoA(&si);
if (si.cbReserved2 != 0 && si.lpReserved2 != NULL)
{
#ifdef _OLD_BUILD_
// why was this here ???? - robd.
int result;
result = malloc(50);
#endif
}
//__pioinfo = (fileno_modes_type*)malloc(sizeof(fileno_modes_type) * maxfno);
__pioinfo = malloc(sizeof(fileno_modes_type) * maxfno);
if (__pioinfo == NULL) {
return FALSE;
}
memset(__pioinfo, -1, sizeof(fileno_modes_type) * maxfno);
if (count) {
pFile = (HANDLE*)(StInfo.lpReserved2 + sizeof(ULONG) + count * sizeof(char));
pmode = (char*)(StInfo.lpReserved2 + sizeof(ULONG));
for (i = 0; i < count; i++) {
if (*pFile != INVALID_HANDLE_VALUE) {
__pioinfo[i].fd = i;
__pioinfo[i].mode = ((*pmode << 8) & (_O_TEXT|_O_BINARY)) | (*pmode & _O_ACCMODE);
__pioinfo[i].hFile = *pFile;
}
pFile++;
pmode++;
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;
}
if (__pioinfo[0].fd == -1) {
__pioinfo[0].fd = 0;
__pioinfo[0].hFile = GetStdHandle(STD_INPUT_HANDLE);
__pioinfo[0].mode = _O_RDONLY|_O_TEXT;
InitializeCriticalSection(&g_file_cs);
if (fdinfo(0)->hFile == INVALID_HANDLE_VALUE || !(fdinfo(0)->fdflags & FOPEN)) {
fdinfo(0)->hFile = GetStdHandle(STD_INPUT_HANDLE);
fdinfo(0)->fdflags = FOPEN|FTEXT;
}
if (__pioinfo[1].fd == -1) {
__pioinfo[1].fd = 1;
__pioinfo[1].hFile = GetStdHandle(STD_OUTPUT_HANDLE);
__pioinfo[1].mode = _O_WRONLY|_O_TEXT;
if (fdinfo(1)->hFile == INVALID_HANDLE_VALUE || !(fdinfo(1)->fdflags & FOPEN)) {
fdinfo(1)->hFile = GetStdHandle(STD_OUTPUT_HANDLE);
fdinfo(1)->fdflags = FOPEN|FTEXT;
}
if (__pioinfo[2].fd == -1) {
__pioinfo[2].fd = 2;
__pioinfo[2].hFile = GetStdHandle(STD_ERROR_HANDLE);
__pioinfo[2].mode = _O_WRONLY|_O_TEXT;
if (fdinfo(2)->hFile == INVALID_HANDLE_VALUE || !(fdinfo(2)->fdflags & FOPEN)) {
fdinfo(2)->hFile = GetStdHandle(STD_ERROR_HANDLE);
fdinfo(2)->fdflags = FOPEN|FTEXT;
}
if (__pioinfo[3].fd == -1) {
__pioinfo[3].fd = 3;
__pioinfo[3].hFile = GetStdHandle(STD_AUX_HANDLE);
__pioinfo[3].mode = _O_WRONLY|_O_TEXT;
}
if (__pioinfo[4].fd == -1) {
__pioinfo[4].fd = 4;
__pioinfo[4].hFile = GetStdHandle(STD_PRINTER_HANDLE);
__pioinfo[4].mode = _O_WRONLY|_O_TEXT;
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

@ -10,9 +10,12 @@
*/
#include "precomp.h"
#include <msvcrt/io.h>
#include <msvcrt/errno.h>
#include <msvcrt/internal/file.h>
#include <io.h>
#include <errno.h>
#include <internal/file.h>
#define NDEBUG
#include <internal/msvcrtdbg.h>
/*
@ -23,29 +26,31 @@ 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;
return( -1);
}
if ((_fildes[0] = __fileno_alloc(hReadPipe, mode)) < 0)
if ((_fildes[0] = alloc_fd(hReadPipe, split_oflags(mode))) < 0)
{
CloseHandle(hReadPipe);
CloseHandle(hWritePipe);
__set_errno(EMFILE);
return -1;
return(-1);
}
if ((_fildes[1] = __fileno_alloc(hWritePipe, mode)) < 0)
if ((_fildes[1] = alloc_fd(hWritePipe, split_oflags(mode))) < 0)
{
__fileno_close(_fildes[0]);
free_fd(_fildes[0]);
CloseHandle(hReadPipe);
CloseHandle(hWritePipe);
__set_errno(EMFILE);
return -1;
return(-1);
}
return 0;
return(0);
}

View file

@ -13,16 +13,16 @@
*/
#include <windows.h>
#include <msvcrt/io.h>
#include <msvcrt/internal/file.h>
#include <io.h>
#include <internal/file.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
#include <internal/msvcrtdbg.h>
/*
* @implemented
*/
size_t _read(int _fd, void *_buf, size_t _nbyte)
int _read(int _fd, void *_buf, unsigned int _nbyte)
{
DWORD _rbyte = 0, nbyte = _nbyte;
char *bufp = (char*)_buf;
@ -35,7 +35,7 @@ size_t _read(int _fd, void *_buf, size_t _nbyte)
if(_nbyte == 0)
return 0;
hfile = _get_osfhandle(_fd);
hfile = (HANDLE)_get_osfhandle(_fd);
istext = __fileno_getmode(_fd) & O_TEXT;
/* read data */

View file

@ -9,19 +9,11 @@
* 28/12/98: Created
*/
#include <msvcrt/io.h>
#include <msvcrt/stdio.h>
#include <msvcrt/internal/file.h>
#include <io.h>
#include <stdio.h>
#include <internal/file.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
#include <internal/msvcrtdbg.h>
/*
* @implemented
*/
int _setmode(int _fd, int _newmode)
{
DPRINT("_setmod(fd %d, newmode %x)\n", _fd, _newmode);
return __fileno_setmode(_fd, _newmode);
}

View file

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

View file

@ -1,6 +1,7 @@
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <msvcrt/errno.h>
#include <msvcrt/io.h>
#include <errno.h>
#include <io.h>
#include <stdio.h>
/*

View file

@ -1,5 +1,6 @@
#include <msvcrt/errno.h>
#include <msvcrt/io.h>
#include <errno.h>
#include <io.h>
#include <stdio.h>
/*

View file

@ -1,5 +1,5 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <msvcrt/sys/stat.h>
#include <sys/stat.h>
unsigned _unMode_dll = 022;

View file

@ -9,10 +9,11 @@
*/
#include "precomp.h"
#include <msvcrt/io.h>
#include <io.h>
#include <internal/file.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
#include <internal/msvcrtdbg.h>
/*

View file

@ -1,8 +1,8 @@
#include <msvcrt/stdio.h>
#include <msvcrt/io.h>
#include <msvcrt/errno.h>
#include <msvcrt/sys/utime.h>
#include <msvcrt/internal/file.h>
#include <stdio.h>
#include <io.h>
#include <errno.h>
#include <sys/utime.h>
#include <internal/file.h>
/*

View file

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

View file

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

View file

@ -1,8 +1,8 @@
#include <msvcrt/io.h>
#include <msvcrt/fcntl.h>
#include <io.h>
#include <fcntl.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
#include <internal/msvcrtdbg.h>
/*

View file

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

View file

@ -13,12 +13,12 @@
/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <msvcrt/stdio.h>
#include <msvcrt/string.h>
#include <msvcrt/io.h>
#include <stdio.h>
#include <string.h>
#include <io.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
#include <internal/msvcrtdbg.h>
/*

View file

@ -14,19 +14,19 @@
#include "precomp.h"
#if !defined(NDEBUG) && defined(DBG)
#include <msvcrt/stdarg.h>
#include <stdarg.h>
#endif
#include <msvcrt/io.h>
#include <msvcrt/fcntl.h>
#include <msvcrt/sys/stat.h>
#include <msvcrt/stdlib.h>
#include <msvcrt/internal/file.h>
#include <msvcrt/string.h>
#include <msvcrt/share.h>
#include <msvcrt/errno.h>
#include <io.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <string.h>
#include <share.h>
#include <errno.h>
#include <internal/file.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
#include <internal/msvcrtdbg.h>
/*
@ -136,13 +136,14 @@ int _wopen(const wchar_t* _path, int _oflag, ...)
_dosmaperr(GetLastError());
return -1;
}
return __fileno_alloc(hFile,_oflag);
return alloc_fd(hFile,split_oflags(_oflag));
}
/*
* @implemented
*/
int _wsopen(wchar_t* path, int access, int shflag, int mode)
int _wsopen(const wchar_t* path, int access, int shflag,.../* int mode*/)
{
return _wopen((path), (access)|(shflag), (mode));
//FIXME: vararg
return _wopen((path), (access)|(shflag));//, (mode));
}

View file

@ -9,14 +9,14 @@
*/
#include "precomp.h"
#include <msvcrt/io.h>
#include <msvcrt/stdlib.h>
#include <msvcrt/string.h>
#include <msvcrt/internal/file.h>
#include <msvcrt/errno.h>
#include <io.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <internal/file.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
#include <internal/msvcrtdbg.h>
#define BUFSIZE 4096
/*
@ -38,7 +38,7 @@ void ReportLastError(void)
/*
* @implemented
*/
size_t _write(int _fd, const void* _buf, size_t _nbyte)
int _write(int _fd, const void* _buf, unsigned int _nbyte)
{
char *tmp, *in, *out;
int result;
@ -61,7 +61,7 @@ size_t _write(int _fd, const void* _buf, size_t _nbyte)
*out++ = 0x0d;
count--;
if (count == 0) {
if (!WriteFile(_get_osfhandle(_fd), tmp, BUFSIZE, &wbyte, NULL)) {
if (!WriteFile((HANDLE)_get_osfhandle(_fd), tmp, BUFSIZE, &wbyte, NULL)) {
//ReportLastError();
_dosmaperr(GetLastError());
result = -1;
@ -78,7 +78,7 @@ size_t _write(int _fd, const void* _buf, size_t _nbyte)
*out++ = *in++;
count--;
if (count == 0 || _nbyte == 0) {
if (!WriteFile(_get_osfhandle(_fd), tmp, BUFSIZE - count, &wbyte, NULL)) {
if (!WriteFile((HANDLE)_get_osfhandle(_fd), tmp, BUFSIZE - count, &wbyte, NULL)) {
_dosmaperr(GetLastError());
result = -1;
break;
@ -94,7 +94,7 @@ size_t _write(int _fd, const void* _buf, size_t _nbyte)
free(tmp);
return result;
} else {
if(!WriteFile(_get_osfhandle(_fd), _buf, _nbyte, &wbyte, NULL)) {
if(!WriteFile((HANDLE)_get_osfhandle(_fd), _buf, _nbyte, &wbyte, NULL)) {
_dosmaperr(GetLastError());
return -1;
}

View file

@ -9,11 +9,11 @@
*/
#include "precomp.h"
#include <msvcrt/io.h>
#include <io.h>
#include <internal/file.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
#include <msvcrt/internal/file.h>
#include <internal/msvcrtdbg.h>
/*
* @implemented

View file

@ -1,8 +1,8 @@
#include <msvcrt/stdio.h>
#include <msvcrt/io.h>
#include <msvcrt/errno.h>
#include <msvcrt/sys/utime.h>
#include <msvcrt/internal/file.h>
#include <stdio.h>
#include <io.h>
#include <errno.h>
#include <sys/utime.h>
#include <internal/file.h>
/*

View file

@ -5,15 +5,15 @@
*/
#include "precomp.h"
#include <msvcrt/stdio.h>
#include <msvcrt/locale.h>
#include <msvcrt/string.h>
#include <stdio.h>
#include <locale.h>
#include <string.h>
#include <limits.h>
#include <msvcrt/internal/tls.h>
#include <msvcrt/stdlib.h>
#include <internal/tls.h>
#include <stdlib.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
#include <internal/msvcrtdbg.h>
unsigned int __setlc_active;
unsigned int __unguarded_readlc_active;

View file

@ -10,11 +10,14 @@ TARGET_NAME = crt
TARGET_PCH = precomp.h
TARGET_CFLAGS = -D_MSVCRT_LIB_ -Wall -Werror
TARGET_CFLAGS = -D_MSVCRT_LIB_ -D__MSVCRT__ -Wall -Werror -I./include
#-nostdinc
# require os code to explicitly request A/W version of structs/functions
TARGET_CFLAGS += \
-D_DISABLE_TIDENTS \
-D__MINGW_IMPORT=extern \
-D__USE_W32API \
-D__REACTOS__ \
-D_WIN32_IE=0x600 \
@ -26,7 +29,6 @@ CONIO_OBJECTS = \
conio/cgets.o \
conio/cprintf.o \
conio/cputs.o \
conio/cscanf.o \
conio/getch.o \
conio/getche.o \
conio/kbhit.o \
@ -238,6 +240,7 @@ PROCESS_OBJECTS = \
process/_system.o \
process/dll.o \
process/process.o \
process/wprocess.o \
process/procid.o \
process/thread.o \
process/threadid.o \
@ -275,12 +278,14 @@ STDIO_OBJECTS = \
stdio/fputc.o \
stdio/fputchar.o \
stdio/fputs.o \
stdio/fputws.o \
stdio/fread.o \
stdio/freopen.o \
stdio/fscanf.o \
stdio/wfreopen.o \
stdio/fseek.o \
stdio/fsetpos.o \
stdio/fsopen.o \
stdio/wfsopen.o \
stdio/ftell.o \
stdio/fwalk.o \
stdio/fwrite.o \
@ -290,32 +295,35 @@ STDIO_OBJECTS = \
stdio/getw.o \
stdio/perror.o \
stdio/popen.o \
stdio/wpopen.o \
stdio/printf.o \
stdio/wprintf.o \
stdio/putc.o \
stdio/putchar.o \
stdio/putwchar.o \
stdio/puts.o \
stdio/putw.o \
stdio/remove.o \
stdio/wremove.o \
stdio/rename.o \
stdio/rewind.o \
stdio/rmtmp.o \
stdio/scanf.o \
stdio/setbuf.o \
stdio/setvbuf.o \
stdio/sprintf.o \
stdio/sscanf.o \
stdio/swprintf.o \
stdio/stdhnd.o \
stdio/tempnam.o \
stdio/tmpfile.o \
stdio/tmpnam.o \
stdio/ungetc.o \
stdio/ungetwc.o \
stdio/vfprintf.o \
stdio/vfscanf.o \
stdio/vfwprint.o \
stdio/vprintf.o \
stdio/vscanf.o \
stdio/vwprintf.o \
stdio/vsprintf.o \
stdio/vsscanf.o \
stdio/vswprintf.o \
stdio/wfdopen.o \
stdio/wrename.o \
stdio/wtempnam.o \
@ -330,6 +338,7 @@ STDLIB_OBJECTS = \
stdlib/atoi.o \
stdlib/atoi64.o \
stdlib/atol.o \
stdlib/wtol.o \
stdlib/bsearch.o \
stdlib/div.o \
stdlib/ecvt.o \
@ -437,7 +446,8 @@ WINE_OBJECTS = \
wine/cpp.o \
wine/cppexcept.o \
wine/heap.o \
wine/thread.o
wine/thread.o \
wine/scanf.o
TARGET_OBJECTS = \
$(CONIO_OBJECTS) \

View file

@ -18,7 +18,7 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <msvcrt/math.h>
#include <math.h>
double acos(double __x)

View file

@ -18,7 +18,7 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <msvcrt/math.h>
#include <math.h>
double asin(double __x)

View file

@ -18,7 +18,7 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <msvcrt/math.h>
#include <math.h>
double atan (double __x);

View file

@ -1,5 +1,5 @@
#include <msvcrt/math.h>
#include <math.h>
double atan2 (double __y, double __x);

View file

@ -1,4 +1,4 @@
#include <msvcrt/math.h>
#include <math.h>
/*
* @implemented

View file

@ -1,4 +1,4 @@
#include <msvcrt/math.h>
#include <math.h>
/*
* @implemented

View file

@ -1,4 +1,4 @@
#include <msvcrt/math.h>
#include <math.h>
double cos (double __x);

View file

@ -1,5 +1,5 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <msvcrt/math.h>
#include <math.h>
/*

View file

@ -18,7 +18,7 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <msvcrt/math.h>
#include <math.h>
double exp (double __x);

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