Commit c702f0e6 authored by Jon Griffiths's avatar Jon Griffiths Committed by Alexandre Julliard

- Fix ctype(), make is* functions binary compatible

- Add 13 functions, set errno in math calls
parent 024d6c50
......@@ -83,6 +83,42 @@
#define _FPCLASS_PN 256
#define _FPCLASS_PINF 512
/* _statusfp bit flags */
#define _SW_INEXACT 0x1
#define _SW_UNDERFLOW 0x2
#define _SW_OVERFLOW 0x4
#define _SW_ZERODIVIDE 0x8
#define _SW_INVALID 0x10
#define _SW_DENORMAL 0x80000
/* _controlfp masks and bitflags - x86 only so far*/
#ifdef __i386__
#define _MCW_EM 0x8001f
#define _EM_INEXACT 0x1
#define _EM_UNDERFLOW 0x2
#define _EM_OVERFLOW 0x4
#define _EM_ZERODIVIDE 0x8
#define _EM_INVALID 0x10
#define _MCW_RC 0x300
#define _RC_NEAR 0x0
#define _RC_DOWN 0x100
#define _RC_UP 0x200
#define _RC_CHOP 0x300
#define _MCW_PC 0x30000
#define _PC_64 0x0
#define _PC_53 0x10000
#define _PC_24 0x20000
#define _MCW_IC 0x40000
#define _IC_AFFINE 0x40000
#define _IC_PROJECTIVE 0x0
#define _EM_DENORMAL 0x80000
#endif
/* CRTDLL Globals */
extern INT CRTDLL_doserrno;
extern INT CRTDLL_errno;
......@@ -188,6 +224,16 @@ struct _utimbuf
time_t modtime;
};
/* _matherr exception type */
struct _exception
{
int type;
char *name;
double arg1;
double arg2;
double retval;
};
typedef VOID (*sig_handler_type)(VOID);
typedef VOID (*new_handler_type)(VOID);
......@@ -196,7 +242,7 @@ typedef VOID (*_INITTERMFUN)();
typedef VOID (*atexit_function)(VOID);
typedef INT (__cdecl *comp_func)(LPVOID *,LPVOID *);
typedef INT (__cdecl *comp_func)(LPCVOID, LPCVOID );
/* CRTDLL functions */
......@@ -229,12 +275,14 @@ atexit_function __cdecl CRTDLL__onexit( atexit_function func);
CRTDLL_FILE* __cdecl CRTDLL__iob( VOID );
CRTDLL_FILE* __cdecl CRTDLL__fsopen( LPCSTR path, LPCSTR mode, INT share );
CRTDLL_FILE* __cdecl CRTDLL__fdopen( INT fd, LPCSTR mode );
LPSTR __cdecl CRTDLL__mktemp( LPSTR pattern );
CRTDLL_FILE* __cdecl CRTDLL_fopen( LPCSTR path, LPCSTR mode );
CRTDLL_FILE* __cdecl CRTDLL_freopen( LPCSTR path,LPCSTR mode,CRTDLL_FILE* f );
INT __cdecl CRTDLL__fgetchar( VOID );
DWORD __cdecl CRTDLL_fread( LPVOID ptr,INT size,INT nmemb,CRTDLL_FILE* file );
INT __cdecl CRTDLL_fscanf( CRTDLL_FILE* stream, LPSTR format, ... );
INT __cdecl CRTDLL__filbuf( CRTDLL_FILE* file );
LONG __cdecl CRTDLL__filelength( INT fd );
INT __cdecl CRTDLL__fileno( CRTDLL_FILE* file );
INT __cdecl CRTDLL__flsbuf( INT c, CRTDLL_FILE* file );
INT __cdecl CRTDLL__fputchar( INT c );
......@@ -250,6 +298,7 @@ INT __cdecl CRTDLL_setbuf( CRTDLL_FILE* file, LPSTR buf );
INT __cdecl CRTDLL__open_osfhandle( HANDLE osfhandle, INT flags );
INT __cdecl CRTDLL_vfprintf( CRTDLL_FILE* file, LPCSTR format,va_list args);
INT __cdecl CRTDLL_fprintf( CRTDLL_FILE* file, LPCSTR format, ... );
INT __cdecl CRTDLL__putw( INT val, CRTDLL_FILE* file );
INT __cdecl CRTDLL__read( INT fd, LPVOID buf, UINT count );
UINT __cdecl CRTDLL__write( INT fd,LPCVOID buf,UINT count );
INT __cdecl CRTDLL__access( LPCSTR filename, INT mode );
......@@ -269,11 +318,12 @@ INT __cdecl CTRDLL__creat( LPCSTR path, INT flags );
INT __cdecl CRTDLL__eof( INT fd );
LONG __cdecl CRTDLL__tell(INT fd);
INT __cdecl CRTDLL__umask(INT umask);
INT __cdecl CRTDLL__utime(LPCSTR path, struct _utimbuf *t);
INT __cdecl CRTDLL__utime( LPCSTR path, struct _utimbuf *t );
INT __cdecl CRTDLL__unlink( LPCSTR pathname );
INT __cdecl CRTDLL_rename( LPCSTR oldpath,LPCSTR newpath );
int __cdecl CRTDLL__stat( LPCSTR filename, struct _stat * buf );
INT __cdecl CRTDLL__open( LPCSTR path,INT flags );
INT __cdecl CRTDLL__chmod( LPCSTR path, INT flags );
INT __cdecl CRTDLL__close( INT fd );
INT __cdecl CRTDLL_feof( CRTDLL_FILE* file );
INT __cdecl CRTDLL__setmode( INT fh,INT mode );
......@@ -289,6 +339,7 @@ VOID __cdecl CRTDLL__global_unwind2( PEXCEPTION_FRAME frame );
VOID __cdecl CRTDLL__local_unwind2( PEXCEPTION_FRAME endframe, DWORD nr );
INT __cdecl CRTDLL__setjmp( LPDWORD *jmpbuf );
VOID __cdecl CRTDLL_srand( DWORD seed );
INT __cdecl CRTDLL__getw( CRTDLL_FILE* file );
INT __cdecl CRTDLL__isatty(INT fd);
VOID __cdecl CRTDLL__beep( UINT freq, UINT duration );
INT __cdecl CRTDLL_rand( VOID );
......@@ -301,14 +352,19 @@ INT __cdecl CRTDLL__mbsicmp( unsigned char *x,unsigned char *y );
INT __cdecl CRTDLL_vswprintf( LPWSTR buffer, LPCWSTR spec, va_list args );
VOID __cdecl CRTDLL_longjmp( jmp_buf env, int val );
LPSTR __cdecl CRTDLL_setlocale( INT category,LPCSTR locale );
BOOL __cdecl CRTDLL__isctype( CHAR x,CHAR type );
INT __cdecl CRTDLL__isctype( INT c, UINT type );
LPSTR __cdecl CRTDLL__fullpath( LPSTR buf, LPCSTR name, INT size );
VOID __cdecl CRTDLL__splitpath( LPCSTR path, LPSTR drive, LPSTR directory,
LPSTR filename, LPSTR extension );
INT __cdecl CRTDLL__matherr( struct _exception *e );
VOID __cdecl CRTDLL__makepath( LPSTR path, LPCSTR drive,
LPCSTR directory, LPCSTR filename,
LPCSTR extension );
LPINT __cdecl CRTDLL__errno( VOID );
LPINT __cdecl CRTDLL___doserrno( VOID );
LPCSTR**__cdecl CRTDLL__sys_errlist( VOID );
VOID __cdecl CRTDLL_perror( LPCSTR err );
UINT __cdecl CRTDLL__statusfp( VOID );
LPSTR __cdecl CRTDLL__strerror( LPCSTR err );
LPSTR __cdecl CRTDLL_strerror( INT err );
LPSTR __cdecl CRTDLL__tempnam( LPCSTR dir, LPCSTR prefix );
......@@ -316,27 +372,40 @@ LPSTR __cdecl CRTDLL_tmpnam( LPSTR s );
LPVOID __cdecl CRTDLL_signal( INT sig, sig_handler_type ptr );
VOID __cdecl CRTDLL__sleep( ULONG timeout );
LPSTR __cdecl CRTDLL_getenv( LPCSTR name );
INT __cdecl CRTDLL_isalnum( INT c );
INT __cdecl CRTDLL_isalpha( INT c );
INT __cdecl CRTDLL_iscntrl( INT c );
INT __cdecl CRTDLL_isdigit( INT c );
INT __cdecl CRTDLL_isgraph( INT c );
INT __cdecl CRTDLL_islower( INT c);
INT __cdecl CRTDLL_isprint( INT c);
INT __cdecl CRTDLL_ispunct( INT c);
INT __cdecl CRTDLL_isspace( INT c);
INT __cdecl CRTDLL_isupper( INT c);
INT __cdecl CRTDLL_isxdigit( INT c );
double __cdecl CRTDLL_ldexp( double x, LONG y );
LPSTR __cdecl CRTDLL__mbsrchr( LPSTR s,CHAR x );
VOID __cdecl CRTDLL___dllonexit ( VOID );
VOID __cdecl CRTDLL__mbccpy( LPSTR dest, LPSTR src );
INT __cdecl CRTDLL___isascii( INT c );
INT __cdecl CRTDLL___toascii( INT c );
INT __cdecl CRTDLL_iswascii( LONG c );
INT __cdecl CRTDLL___iscsym( LONG c );
INT __cdecl CRTDLL___iscsymf( LONG c );
INT __cdecl CRTDLL___iscsym( UCHAR c );
INT __cdecl CRTDLL___iscsymf( UCHAR c );
INT __cdecl CRTDLL__loaddll( LPSTR dllname );
INT __cdecl CRTDLL__unloaddll( HANDLE dll );
WCHAR* __cdecl CRTDLL__itow( INT value,WCHAR* out,INT base );
WCHAR* __cdecl CRTDLL__ltow( LONG value,WCHAR* out,INT base );
WCHAR* __cdecl CRTDLL__ultow(ULONG value,WCHAR* out,INT base);
WCHAR* __cdecl CRTDLL__ultow( ULONG value,WCHAR* out,INT base );
CHAR __cdecl CRTDLL__toupper( CHAR c );
CHAR __cdecl CRTDLL__tolower( CHAR c );
double __cdecl CRTDLL__cabs( struct complex c );
double __cdecl CRTDLL__chgsign( double d );
UINT __cdecl CRTDLL__control87( UINT, UINT );
UINT __cdecl CRTDLL__controlfp( UINT, UINT );
double __cdecl CRTDLL__copysign(double x, double sign);
UINT __cdecl CRTDLL__control87( UINT newVal, UINT mask);
UINT __cdecl CRTDLL__controlfp( UINT newVal, UINT mask);
double __cdecl CRTDLL__copysign( double x, double sign );
INT __cdecl CRTDLL__finite( double d );
UINT __cdecl CRTDLL__clearfp( VOID );
INT __cdecl CRTDLL__fpclass( double d );
VOID __cdecl CRTDLL__fpreset( void );
INT __cdecl CRTDLL__isnan( double d );
......
......@@ -21,13 +21,13 @@ debug_channels (crtdll)
@ cdecl _CIfmod() CRTDLL__CIfmod
@ cdecl _CIlog() CRTDLL__CIlog
@ cdecl _CIlog10() CRTDLL__CIlog10
@ forward _CIpow ntdll._CIpow
@ cdecl _CIpow() CRTDLL__CIpow
@ cdecl _CIsin() CRTDLL__CIsin
@ cdecl _CIsinh() CRTDLL__CIsinh
@ cdecl _CIsqrt() CRTDLL__CIsqrt
@ cdecl _CItan() CRTDLL__CItan
@ cdecl _CItanh() CRTDLL__CItanh
@ stub _HUGE_dll
@ extern _HUGE_dll CRTDLL_HUGE_dll
@ stub _XcptFilter
@ cdecl __GetMainArgs(ptr ptr ptr long) CRTDLL__GetMainArgs
@ extern __argc_dll CRTDLL_argc_dll
......@@ -61,9 +61,9 @@ debug_channels (crtdll)
@ cdecl _chdir(str) CRTDLL__chdir
@ cdecl _chdrive(long) CRTDLL__chdrive
@ cdecl _chgsign(double) CRTDLL__chgsign
@ stub _chmod
@ cdecl _chmod(str long) CRTDLL__chmod
@ stub _chsize
@ stub _clearfp
@ cdecl _clearfp() CRTDLL__clearfp
@ cdecl _close(long) CRTDLL__close
@ cdecl _commit(long) CRTDLL__commit
@ extern _commode_dll CRTDLL_commode_dll
......@@ -75,12 +75,12 @@ debug_channels (crtdll)
@ stub _cputs
@ cdecl _creat(str long) CTRDLL__creat
@ stub _cscanf
@ stub _ctype
@ extern _ctype CRTDLL_ctype
@ stub _cwait
@ stub _daylight_dll
@ stub _dup
@ stub _dup2
@ stub _ecvt
@ cdecl _ecvt(double long ptr ptr) ecvt
@ stub _endthread
@ extern _environ_dll CRTDLL_environ_dll
@ cdecl _eof(long) CRTDLL__eof
......@@ -97,13 +97,13 @@ debug_channels (crtdll)
@ cdecl _exit(long) CRTDLL__exit
@ cdecl _expand(ptr long) CRTDLL__expand
@ cdecl _fcloseall() CRTDLL__fcloseall
@ stub _fcvt
@ cdecl _fcvt(double long ptr ptr) fcvt
@ cdecl _fdopen(long ptr) CRTDLL__fdopen
@ cdecl _fgetchar() CRTDLL__fgetchar
@ stub _fgetwchar
@ cdecl _filbuf(ptr) CRTDLL__filbuf
@ stub _fileinfo_dll
@ stub _filelength
@ cdecl _filelength(long) CRTDLL__filelength
@ cdecl _fileno(ptr) CRTDLL__fileno
@ cdecl _findclose(long) CRTDLL__findclose
@ cdecl _findfirst(str ptr) CRTDLL__findfirst
......@@ -123,7 +123,7 @@ debug_channels (crtdll)
@ forward _ftol ntdll._ftol
@ cdecl _fullpath(ptr str long) CRTDLL__fullpath
@ cdecl _futime(long ptr) CRTDLL__futime
@ stub _gcvt
@ cdecl _gcvt(double long str) gcvt
@ cdecl _get_osfhandle(long) CRTDLL__get_osfhandle
@ stub _getch
@ stub _getche
......@@ -135,7 +135,7 @@ debug_channels (crtdll)
@ forward _getdrives kernel32.GetLogicalDrives
@ forward _getpid kernel32.GetCurrentProcessId
@ stub _getsystime
@ stub _getw
@ cdecl _getw(ptr) CRTDLL__getw
@ cdecl _global_unwind2(ptr) CRTDLL__global_unwind2
@ cdecl _heapchk() CRTDLL__heapchk
@ cdecl _heapmin() CRTDLL__heapmin
......@@ -178,7 +178,7 @@ debug_channels (crtdll)
@ cdecl _j1(double) j1
@ cdecl _jn(long double) jn
@ stub _kbhit
@ stub _lfind
@ cdecl _lfind(ptr ptr ptr long ptr) CRTDLL__lfind
@ cdecl _loaddll(str) CRTDLL__loaddll
@ cdecl _local_unwind2(ptr long) CRTDLL__local_unwind2
@ stub _locking
......@@ -190,7 +190,7 @@ debug_channels (crtdll)
@ forward _ltoa ntdll._ltoa
@ cdecl _ltow(long str long) CRTDLL__ltow
@ cdecl _makepath (ptr str str str str) CRTDLL__makepath
@ stub _matherr
@ cdecl _matherr(ptr) CRTDLL__matherr
@ stub _mbbtombc
@ stub _mbbtype
@ cdecl _mbccpy (str str) CRTDLL__mbccpy
......@@ -242,7 +242,7 @@ debug_channels (crtdll)
@ cdecl _memccpy(ptr ptr long long) memccpy
@ forward _memicmp ntdll._memicmp
@ cdecl _mkdir(str) CRTDLL__mkdir
@ stub _mktemp
@ cdecl _mktemp(str) CRTDLL__mktemp
@ cdecl _msize(ptr) CRTDLL__msize
@ cdecl _nextafter(double double) nextafter
@ cdecl _onexit(ptr) CRTDLL__onexit
......@@ -261,7 +261,7 @@ debug_channels (crtdll)
@ cdecl _purecall() CRTDLL__purecall
@ stub _putch
@ stub _putenv
@ stub _putw
@ cdecl _putw(long ptr) CRTDLL__putw
@ stub _pwctype_dll
@ cdecl _read(long ptr long) CRTDLL__read
@ cdecl _rmdir(str) CRTDLL__rmdir
......@@ -288,7 +288,7 @@ debug_channels (crtdll)
@ stub _spawnvpe
@ cdecl _splitpath (str ptr ptr ptr ptr) CRTDLL__splitpath
@ cdecl _stat (str ptr) CRTDLL__stat
@ stub _statusfp
@ cdecl _statusfp() CRTDLL__statusfp
@ cdecl _strcmpi(str str) strcasecmp
@ cdecl _strdate(str) CRTDLL__strdate
@ cdecl _strdec(str str) CRTDLL__strdec
......@@ -365,7 +365,7 @@ debug_channels (crtdll)
@ cdecl cosh(double) cosh
@ cdecl ctime(ptr) ctime
@ cdecl difftime(long long) CRTDLL_difftime
@ cdecl div(long long) div
@ cdecl div(long long) CRTDLL_div
@ cdecl exit(long) CRTDLL_exit
@ cdecl exp(double) exp
@ cdecl fabs(double) fabs
......@@ -401,17 +401,17 @@ debug_channels (crtdll)
@ cdecl gets(ptr) CRTDLL_gets
@ cdecl gmtime(ptr) gmtime
@ forward is_wctype ntdll.iswctype
@ cdecl isalnum(long) isalnum
@ cdecl isalpha(long) isalpha
@ cdecl iscntrl(long) iscntrl
@ cdecl isdigit(long) isdigit
@ cdecl isgraph(long) isgraph
@ cdecl isalnum(long) CRTDLL_isalnum
@ cdecl isalpha(long) CRTDLL_isalpha
@ cdecl iscntrl(long) CRTDLL_iscntrl
@ cdecl isdigit(long) CRTDLL_isdigit
@ cdecl isgraph(long) CRTDLL_isgraph
@ stub isleadbyte
@ cdecl islower(long) islower
@ cdecl isprint(long) isprint
@ cdecl ispunct(long) ispunct
@ cdecl isspace(long) isspace
@ cdecl isupper(long) isupper
@ cdecl islower(long) CRTDLL_islower
@ cdecl isprint(long) CRTDLL_isprint
@ cdecl ispunct(long) CRTDLL_ispunct
@ cdecl isspace(long) CRTDLL_isspace
@ cdecl isupper(long) CRTDLL_isupper
@ cdecl iswalnum(long) CRTDLL_iswalnum
@ forward iswalpha ntdll.iswalpha
@ cdecl iswascii(long) CRTDLL_iswascii
......@@ -425,10 +425,10 @@ debug_channels (crtdll)
@ cdecl iswspace(long) CRTDLL_iswspace
@ cdecl iswupper(long) CRTDLL_iswupper
@ cdecl iswxdigit(long) CRTDLL_iswxdigit
@ cdecl isxdigit(long) isxdigit
@ cdecl isxdigit(long) CRTDLL_isxdigit
@ cdecl labs(long) labs
@ cdecl ldexp(double long) ldexp
@ cdecl ldiv(long long) ldiv
@ cdecl ldexp(double long) CRTDLL_ldexp
@ cdecl ldiv(long long) CRTDLL_ldiv
@ stub localeconv
@ cdecl localtime(ptr) localtime
@ cdecl log(double) log
......
......@@ -215,6 +215,28 @@ INT __cdecl CRTDLL__access(LPCSTR filename, INT mode)
/*********************************************************************
* _chmod (CRTDLL.054)
*
* Change a files permissions.
*/
INT __cdecl CRTDLL__chmod(LPCSTR path, INT flags)
{
DWORD oldFlags = GetFileAttributesA(path);
if (oldFlags != 0x0FFFFFFFF)
{
DWORD newFlags = (flags & _S_IWRITE)? oldFlags & ~FILE_ATTRIBUTE_READONLY:
oldFlags | FILE_ATTRIBUTE_READONLY;
if (newFlags == oldFlags || SetFileAttributesA( path, newFlags ))
return 0;
}
__CRTDLL__set_errno(GetLastError());
return -1;
}
/*********************************************************************
* _close (CRTDLL.57)
*
* Close an open file descriptor.
......@@ -383,6 +405,27 @@ INT __cdecl CRTDLL__filbuf(CRTDLL_FILE* file)
return CRTDLL_fgetc(file);
}
/*********************************************************************
* _filelength (CRTDLL.097)
*
* Get the length of an open file.
*/
LONG __cdecl CRTDLL__filelength(INT fd)
{
LONG curPos = CRTDLL__lseek(fd, 0, SEEK_CUR);
if (curPos != -1)
{
LONG endPos = CRTDLL__lseek(fd, 0, SEEK_END);
if (endPos != -1)
{
if (endPos != curPos)
CRTDLL__lseek(fd, curPos, SEEK_SET);
return endPos;
}
}
return -1;
}
/*********************************************************************
* _fileno (CRTDLL.097)
......@@ -576,6 +619,20 @@ HANDLE CRTDLL__get_osfhandle(INT fd)
/*********************************************************************
* _getw (CRTDLL.128)
*
* Read an integter from a FILE*.
*/
INT __cdecl CRTDLL__getw( CRTDLL_FILE* file )
{
INT i;
if (CRTDLL__read(file->_file, &i, sizeof(INT)) != 1)
return EOF;
return i;
}
/*********************************************************************
* _isatty (CRTDLL.137)
*
* Return non zero if fd is a character device (e.g console).
......@@ -639,6 +696,41 @@ LONG __cdecl CRTDLL__lseek( INT fd, LONG offset, INT whence)
return -1;
}
/*********************************************************************
* _mktemp (CRTDLL.239)
*
* Create a temporary file name.
*/
LPSTR __cdecl CRTDLL__mktemp(LPSTR pattern)
{
int numX = 0;
LPSTR retVal = pattern;
INT id;
char letter = 'a';
while(*pattern)
numX = (*pattern++ == 'X')? numX + 1 : 0;
if (numX < 5)
return NULL;
pattern--;
id = GetCurrentProcessId();
numX = 6;
while(numX--)
{
INT tempNum = id / 10;
*pattern-- = id - (tempNum * 10) + '0';
id = tempNum;
}
pattern++;
do
{
if (GetFileAttributesA( retVal ) == 0xFFFFFFFF &&
GetLastError() == ERROR_FILE_NOT_FOUND)
return retVal;
*pattern = letter++;
} while(letter != '|');
return NULL;
}
/*********************************************************************
* _open (CRTDLL.239)
......@@ -739,6 +831,17 @@ INT __cdecl CRTDLL__open_osfhandle(HANDLE hand, INT flags)
/*********************************************************************
* _putw (CRTDLL.254)
*
* Write an int to a FILE*.
*/
INT __cdecl CRTDLL__putw(INT val, CRTDLL_FILE* file)
{
return CRTDLL__write(file->_file, &val, sizeof(val)) == 1? val : EOF;
}
/*********************************************************************
* _read (CRTDLL.256)
*
* Read data from a file.
......@@ -1542,7 +1645,8 @@ LPSTR __cdecl CRTDLL_tmpnam(LPSTR s)
return NULL;
}
TRACE(":got tmpnam %s\n",CRTDLL_tmpname);
return CRTDLL_tmpname;
s = CRTDLL_tmpname;
return s;
}
......
......@@ -58,6 +58,7 @@ LPSTR __cdecl CRTDLL__strdec(LPSTR str1, LPSTR str2)
/* Hmm. While the docs suggest that the following should work... */
/* return (str2<=str1?0:str2-1); */
/* ...Version 2.50.4170 (NT) from win98 constantly decrements! */
str1 = str1; /* remove warning */
return str2-1;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment