- Update file.c to recent wine. (now with locking!)
- implement/enable __wcserror, __wcserror_s, _access_s, _ctime32_s, _ctime64_s,
_cwprintf, _fseeki64, _ftelli64, _get_osplatform, _get_output_format,
_get_pgmptr, _get_wpgmptr, _get_terminate, _get_tzname, _get_unexpected,
_gmtime64_s, _i64toa_s, _i64tow_s, _initterm_e, _itoa_s, _itow_s,
_localtime32_s, _localtime64_s, _ltoa_s, _ltow_s, _putwch, _searchenv_s,
_sopen_s, _ui64toa_s, _ui64tow_s, _vcwprintf, _vsprintf_p, _waccess_s,
_wcserror, _wcserror_s, _wfopen_s, _wsopen_s, fopen_s, fprintf_s, fwprintf_s,
printf_s, strerror_s, strncpy_s, strtok_s, vfprintf_s, vfwprintf_s, vprintf_s,
vwprintf_s, wcscat_s, wcsncat_s, wcstok_s, wprintf_s. Most code comes from
wine.
- Fix __set_errno -> _set_errno and export it.
- Remove unneeded files.
[CRT_HEADERS]
- add threadmbcinfo struct.
- update some sec_api headers from mingw64 due to missing or incorrect
functions.

Patch by Samuel Serapion.
Changes to msvcrt spec by me due to winebuild.
CRLF/LF fixes.

svn path=/trunk/; revision=54651
This commit is contained in:
Sylvain Petreolle 2011-12-14 22:09:24 +00:00
parent 838328b1ed
commit b30bf6de31
100 changed files with 2782 additions and 1270 deletions

View file

@ -120,7 +120,7 @@
@ cdecl -i386 -norelay __CxxFrameHandler(ptr ptr ptr ptr)
@ cdecl -i386 -norelay __CxxFrameHandler2(ptr ptr ptr ptr) __CxxFrameHandler
@ cdecl -i386 -norelay __CxxFrameHandler3(ptr ptr ptr ptr) __CxxFrameHandler
@ stdcall -arch=x86_64 __C_specific_handler(ptr long ptr ptr) ntdll.__C_specific_handler
@ stdcall -arch=x86_64 __C_specific_handler(ptr long ptr ptr)
@ stdcall -i386 __CxxLongjmpUnwind(ptr)
@ cdecl __CxxQueryExceptionSize()
# stub __CxxRegisterExceptionObject
@ -145,13 +145,14 @@
@ cdecl __crtGetStringTypeW(long long wstr long ptr)
@ cdecl __crtLCMapStringA(long long str long ptr long long long)
# stub __crtLCMapStringW
@ cdecl __daylight() __p__daylight
@ cdecl __dllonexit(ptr ptr ptr)
@ cdecl __doserrno()
@ cdecl __fpecode()
@ cdecl __get_app_type()
@ cdecl __getmainargs(ptr ptr ptr long ptr)
@ extern __initenv
@ cdecl __iob_func() __p__iob
@ cdecl __iob_func()
@ cdecl __isascii(long)
@ cdecl __iscsym(long)
@ cdecl __iscsymf(long)
@ -196,7 +197,7 @@
@ cdecl -arch=i386 __p__environ()
@ cdecl -arch=i386 __p__fileinfo()
@ cdecl -arch=i386 __p__fmode()
@ cdecl -arch=i386 __p__iob()
@ cdecl -arch=i386 __p__iob() __iob_func
@ cdecl -arch=i386 __p__mbcasemap()
@ cdecl -arch=i386 __p__mbctype()
@ cdecl -arch=i386 __p__osver()
@ -227,15 +228,15 @@
@ cdecl __unDNameEx(ptr str long ptr ptr ptr long)
@ extern __unguarded_readlc_active
@ extern __wargv __wargv
# stub __wcserror
# stub __wcserror_s
@ cdecl __wcserror(wstr)
@ cdecl __wcserror_s(ptr long wstr)
# stub __wcsncnt
@ cdecl __wgetmainargs(ptr ptr ptr long ptr)
@ extern __winitenv
@ cdecl _abnormal_termination()
# stub _abs64
@ cdecl _access(str long)
# stub _access_s
@ cdecl _access_s(str long)
@ extern _acmdln
@ stdcall -arch=i386 _adj_fdiv_m16i(long)
@ stdcall -arch=i386 _adj_fdiv_m32(long)
@ -320,12 +321,12 @@
# @ varargs _cscanf_s(str)
# @ varargs _cscanf_s_l(str ptr)
@ cdecl _ctime32(ptr)
# stub _ctime32_s
@ cdecl _ctime32_s(str long ptr)
@ cdecl _ctime64(ptr)
# stub _ctime64_s
@ cdecl _ctime64_s(str long ptr)
@ extern _ctype
@ cdecl _cwait(ptr long long)
# stub _cwprintf
@ varargs _cwprintf(wstr)
# stub _cwprintf_l
# stub _cwprintf_p
# stub _cwprintf_p_l
@ -399,11 +400,12 @@
# stub _fscanf_l
# @ varargs _fscanf_l(ptr str ptr)
# @ varargs _fscanf_s_l(ptr str ptr)
# stub _fseeki64
@ cdecl _fseeki64(ptr long long long)
@ cdecl _fsopen(str str long)
@ cdecl _fstat(long ptr)
@ cdecl _fstat64(long ptr)
@ cdecl _fstati64(long ptr)
@ cdecl -ret64 _ftelli64(ptr)
@ cdecl _ftime(ptr)
@ cdecl _ftime32(ptr)
# stub _ftime32_s
@ -433,18 +435,19 @@
# stub _get_fmode
# @ cdecl _get_heap_handle()
@ cdecl _get_osfhandle(long)
# stub _get_osplatform
@ cdecl _get_osplatform(ptr)
# stub _get_osver
# stub _get_output_format
# stub _get_pgmptr
@ cdecl _get_output_format()
@ cdecl _get_pgmptr(ptr)
@ cdecl _get_sbh_threshold()
# stub _get_wenviron
# stub _get_winmajor
# stub _get_winminor
# stub _get_winver
# stub _get_wpgmptr
# @ stub _get_terminate # not in XP / 7
# @ stub _get_unexpected # not in XP / 7
@ cdecl _get_wpgmptr(ptr)
@ cdecl _get_terminate()
@ cdecl _get_tzname(ptr str long long)
@ cdecl _get_unexpected()
@ cdecl _getch()
@ cdecl _getche()
@ cdecl _getcwd(str long)
@ -465,7 +468,7 @@
@ cdecl _gmtime32(ptr)
# stub _gmtime32_s
@ cdecl _gmtime64(ptr)
# stub _gmtime64_s
@ cdecl _gmtime64_s(ptr ptr)
@ cdecl _heapadd(ptr long)
@ cdecl _heapchk()
@ cdecl _heapmin()
@ -474,11 +477,11 @@
@ cdecl _heapwalk(ptr)
@ cdecl _hypot(double double)
@ cdecl _i64toa(long long ptr long)
# stub _i64toa_s
@ cdecl _i64toa_s(long long ptr long long)
@ cdecl _i64tow(long long ptr long)
# stub _i64tow_s
@ cdecl _i64tow_s(long long ptr long long)
@ cdecl _initterm(ptr ptr)
# stub _initterm_e
@ cdecl _initterm_e(ptr ptr)
@ cdecl -arch=i386 _inp(long) MSVCRT__inp
@ cdecl -arch=i386 _inpd(long) MSVCRT__inpd
@ cdecl -arch=i386 _inpw(long) MSVCRT__inpw
@ -570,9 +573,9 @@
# stub _iswxdigit_l
# stub _isxdigit_l
@ cdecl _itoa(long ptr long)
# stub _itoa_s
@ cdecl _itoa_s(long ptr long long)
@ cdecl _itow(long ptr long)
# stub _itow_s
@ cdecl _itow_s(long ptr long long)
@ cdecl _j0(double)
@ cdecl _j1(double)
@ cdecl _jn(long double)
@ -583,9 +586,9 @@
@ cdecl -i386 _local_unwind2(ptr long)
@ cdecl -i386 _local_unwind4(ptr ptr long)
@ cdecl _localtime32(ptr)
# stub _localtime32_s
@ cdecl _localtime32_s(ptr ptr)
@ cdecl _localtime64(ptr)
# stub _localtime64_s
@ cdecl _localtime64_s(ptr ptr)
@ cdecl _lock(long)
@ cdecl _locking(long long long)
@ cdecl _logb(double)
@ -597,9 +600,9 @@
@ cdecl _lseek(long long long)
@ cdecl -ret64 _lseeki64(long double long)
@ cdecl _ltoa(long ptr long)
# stub _ltoa_s
@ cdecl _ltoa_s(long ptr long long)
@ cdecl _ltow(long ptr long)
# stub _ltow_s
@ cdecl _ltow_s(long ptr long long)
@ cdecl _makepath(ptr str str str str)
@ cdecl _makepath_s(ptr long str str str str)
# stub _malloc_dbg
@ -778,7 +781,7 @@
@ cdecl _putenv(str)
# stub _putenv_s
@ cdecl _putw(long ptr)
# stub _putwch
@ cdecl _putwch(long)
@ cdecl _putws(wstr)
# extern _pwctype
@ cdecl _read(long ptr long)
@ -804,13 +807,13 @@
# stub _scwprintf_l
# stub _scwprintf_p_l
@ cdecl _searchenv(str str ptr)
# stub _searchenv_s
@ cdecl _searchenv_s(str str ptr long)
@ stdcall -i386 _seh_longjmp_unwind4(ptr)
@ stdcall -i386 _seh_longjmp_unwind(ptr)
# stub _set_SSE2_enable
# stub _set_controlfp
# stub _set_doserrno
# stub _set_errno
@ cdecl _set_errno(long)
@ cdecl _set_error_mode(long)
# stub _set_fileinfo
# stub _set_fmode
@ -844,7 +847,7 @@
# stub _snwscanf_s
# stub _snwscanf_s_l
@ varargs _sopen(str long long)
# stub _sopen_s
@ cdecl _sopen_s(ptr str long long long)
@ varargs _spawnl(long str str)
@ varargs _spawnle(long str str)
@ varargs _spawnlp(long str str)
@ -931,9 +934,9 @@
@ extern _tzname
@ cdecl _tzset()
@ cdecl _ui64toa(long long ptr long)
# stub _ui64toa_s
@ cdecl _ui64toa_s(long long ptr long long)
@ cdecl _ui64tow(long long ptr long)
# stub _ui64tow_s
@ cdecl _ui64tow_s(long long ptr long long)
@ cdecl _ultoa(long ptr long)
# stub _ultoa_s
@ cdecl _ultow(long ptr long)
@ -953,7 +956,7 @@
# stub _vcprintf_p_l
# stub _vcprintf_s
# stub _vcprintf_s_l
# stub _vcwprintf
@ cdecl _vcwprintf(wstr ptr)
# stub _vcwprintf_l
# stub _vcwprintf_p
# stub _vcwprintf_p_l
@ -989,7 +992,7 @@
# @ cdecl _vsnwprintf_s(ptr long long wstr ptr)
# @ cdecl _vsnwprintf_s_l(ptr long long wstr ptr ptr)
# stub _vsprintf_l
# stub _vsprintf_p
@ cdecl _vsprintf_p(ptr long str ptr)
# stub _vsprintf_p_l
# stub _vsprintf_s_l
# @ cdecl _vswprintf(ptr wstr ptr)
@ -1003,7 +1006,7 @@
# stub _vwprintf_p_l
# stub _vwprintf_s_l
@ cdecl _waccess(wstr long)
# stub _waccess_s
@ cdecl _waccess_s(wstr long)
@ cdecl _wasctime(ptr)
# stub _wasctime_s
# stub _wassert
@ -1014,8 +1017,8 @@
# stub _wcscoll_l
@ cdecl _wcsdup(wstr)
# stub _wcsdup_dbg
# stub _wcserror
# stub _wcserror_s
@ cdecl _wcserror(long)
@ cdecl _wcserror_s(ptr long long)
# stub _wcsftime_l
@ cdecl _wcsicmp(wstr wstr)
# stub _wcsicmp_l
@ -1074,7 +1077,7 @@
# stub _wfindnext64
@ cdecl _wfindnexti64(long ptr)
@ cdecl _wfopen(wstr wstr)
# @ cdecl _wfopen_s(ptr wstr wstr)
@ cdecl _wfopen_s(ptr wstr wstr)
@ cdecl _wfreopen(wstr wstr ptr)
# stub _wfreopen_s
@ cdecl _wfsopen(wstr wstr long)
@ -1114,7 +1117,7 @@
# stub _wsearchenv_s
@ cdecl _wsetlocale(long wstr)
@ varargs _wsopen(wstr long long)
# stub _wsopen_s
@ cdecl _wsopen_s(ptr wstr long long long)
@ varargs _wspawnl(long wstr wstr)
@ varargs _wspawnle(long wstr wstr)
@ varargs _wspawnlp(long wstr wstr)
@ -1196,9 +1199,9 @@
@ cdecl fmod(double double)
@ cdecl -arch=x86_64 fmodf(long)
@ cdecl fopen(str str)
# @ cdecl fopen_s(ptr str str)
@ cdecl fopen_s(ptr str str)
@ varargs fprintf(ptr str)
# stub fprintf_s
@ varargs fprintf_s(ptr str)
@ cdecl fputc(long ptr)
@ cdecl fputs(str ptr)
@ cdecl fputwc(long ptr)
@ -1214,7 +1217,7 @@
@ cdecl fsetpos(ptr ptr)
@ cdecl ftell(ptr)
@ varargs fwprintf(ptr wstr)
# stub fwprintf_s
@ varargs fwprintf_s(ptr wstr)
@ cdecl fwrite(ptr long long ptr)
@ varargs fwscanf(ptr wstr)
# @ varargs fwscanf_s(ptr wstr)
@ -1284,7 +1287,7 @@
@ cdecl pow(double double)
@ cdecl -arch=x86_64 powf(long)
@ varargs printf(str)
# stub printf_s
@ varargs printf_s(str)
@ cdecl putc(long ptr)
@ cdecl putchar(long)
@ cdecl puts(str)
@ -1325,14 +1328,14 @@
@ cdecl strcpy_s(ptr long str)
@ cdecl strcspn(str str)
@ cdecl strerror(long)
# stub strerror_s
@ cdecl strerror_s(ptr long long)
@ cdecl strftime(str long str ptr)
@ cdecl strlen(str)
@ cdecl strncat(str str long)
# stub strncat_s
@ cdecl strncmp(str str long)
@ cdecl strncpy(ptr str long)
# @ cdecl strncpy_s(ptr long str long)
@ cdecl strncpy_s(ptr long str long)
@ cdecl strnlen(str long)
@ cdecl strpbrk(str str)
@ cdecl strrchr(str long)
@ -1340,7 +1343,7 @@
@ cdecl strstr(str str)
@ cdecl strtod(str ptr)
@ cdecl strtok(str str)
# @ cdecl strtok_s(ptr str ptr)
@ cdecl strtok_s(ptr str ptr)
@ cdecl strtol(str ptr long)
@ cdecl strtoul(str ptr long)
@ cdecl strxfrm(ptr str long)
@ -1364,22 +1367,22 @@
@ cdecl ungetwc(long ptr)
# stub utime
@ cdecl vfprintf(ptr str ptr)
# stub vfprintf_s
@ cdecl vfprintf_s(ptr str ptr)
@ cdecl vfwprintf(ptr wstr ptr)
# stub vfwprintf_s
@ cdecl vfwprintf_s(ptr wstr ptr)
@ cdecl vprintf(str ptr)
# stub vprintf_s
@ cdecl vprintf_s(str ptr)
# stub vsnprintf
@ cdecl vsprintf(ptr str ptr)
# @ cdecl vsprintf_s(ptr long str ptr)
@ cdecl vswprintf(ptr wstr ptr)
# @ cdecl vswprintf_s(ptr long wstr ptr)
@ cdecl vwprintf(wstr ptr)
# stub vwprintf_s
@ cdecl vwprintf_s(wstr ptr)
# stub wcrtomb
# stub wcrtomb_s
@ cdecl wcscat(wstr wstr)
# @ cdecl wcscat_s(wstr long wstr)
@ cdecl wcscat_s(wstr long wstr)
@ cdecl wcschr(wstr long)
@ cdecl wcscmp(wstr wstr)
@ cdecl wcscoll(wstr wstr)
@ -1389,7 +1392,7 @@
@ cdecl wcsftime(ptr long wstr ptr)
@ cdecl wcslen(wstr)
@ cdecl wcsncat(wstr wstr long)
# stub wcsncat_s
@ cdecl wcsncat_s(wstr long wstr long)
@ cdecl wcsncmp(wstr wstr long)
@ cdecl wcsncpy(ptr wstr long)
@ cdecl wcsncpy_s(ptr long wstr long)
@ -1402,7 +1405,7 @@
@ cdecl wcsstr(wstr wstr)
@ cdecl wcstod(wstr ptr)
@ cdecl wcstok(wstr wstr)
# stub wcstok_s
@ cdecl wcstok_s(ptr wstr ptr)
@ cdecl wcstol(wstr ptr long)
@ cdecl wcstombs(ptr ptr long)
# @ cdecl wcstombs_s(ptr ptr long wstr long)
@ -1412,7 +1415,7 @@
@ cdecl wctomb(ptr long)
# stub wctomb_s
@ varargs wprintf(wstr)
# stub wprintf_s
@ varargs wprintf_s(wstr)
@ varargs wscanf(wstr)
# @ varargs wscanf_s(wstr)

View file

@ -485,7 +485,7 @@
@ cdecl -arch=i386 __p__daylight()
@ cdecl -arch=i386 __p__environ()
@ cdecl -arch=i386 __p__fmode()
@ cdecl -arch=i386 __p__iob()
@ cdecl -arch=i386 __p__iob() __iob_func
@ cdecl -arch=i386 __p__mbctype()
@ cdecl -arch=i386 __p__osver()
@ cdecl -arch=i386 __p__pctype()

View file

@ -534,7 +534,7 @@
@ cdecl -arch=i386 __p__dstbias()
@ cdecl -arch=i386 __p__environ()
@ cdecl -arch=i386 __p__fmode()
@ cdecl -arch=i386 __p__iob()
@ cdecl -arch=i386 __p__iob() __iob_func
@ cdecl -arch=i386 __p__mbctype()
@ cdecl -arch=i386 __p__osver()
@ cdecl -arch=i386 __p__pctype()

View file

@ -351,18 +351,16 @@ extern "C" {
#endif
#endif
struct threadlocaleinfostruct;
typedef struct threadlocaleinfostruct *pthreadlocinfo;
typedef struct threadmbcinfostruct {
int refcount;
int mbcodepage;
int ismbcodepage;
int mblcid;
unsigned short mbulinfo[6];
char mbctype[257];
char mbcasemap[256];
} threadmbcinfo, *pthreadmbcinfo;
struct threadmbcinfostruct;
typedef struct threadmbcinfostruct *pthreadmbcinfo;
struct __lc_time_data;
typedef struct localeinfo_struct {
pthreadlocinfo locinfo;
pthreadmbcinfo mbcinfo;
} _locale_tstruct,*_locale_t;
#ifndef _TAGLC_ID_DEFINED
#define _TAGLC_ID_DEFINED
@ -399,9 +397,15 @@ extern "C" {
const unsigned char *pclmap;
const unsigned char *pcumap;
struct __lc_time_data *lc_time_curr;
} threadlocinfo;
} threadlocinfo, *pthreadlocinfo;
#endif
struct __lc_time_data;
typedef struct localeinfo_struct {
pthreadlocinfo locinfo;
pthreadmbcinfo mbcinfo;
}_locale_tstruct,*_locale_t;
#ifdef __cplusplus
}

View file

@ -74,12 +74,14 @@ extern "C" {
_CRTIMP int __cdecl _snprintf_c_l(char *_DstBuf,size_t _MaxCount,const char *_Format,_locale_t _Locale,...);
_CRTIMP int __cdecl _vsnprintf_l(char *_DstBuf,size_t _MaxCount,const char *_Format,_locale_t _Locale,va_list _ArgList);
_CRTIMP int __cdecl _vsnprintf_c_l(char *_DstBuf,size_t _MaxCount,const char *,_locale_t _Locale,va_list _ArgList);
_CRTIMP errno_t __cdecl fopen_s(FILE **_File,const char *_Filename,const char *_Mode);
#ifndef _WSTDIO_S_DEFINED
#define _WSTDIO_S_DEFINED
_CRTIMP wchar_t *__cdecl _getws_s(wchar_t *_Str,size_t _SizeInWords);
int __cdecl fwprintf_s(FILE *_File,const wchar_t *_Format,...);
int __cdecl wprintf_s(const wchar_t *_Format,...);
int __cdecl vfwprintf_s(FILE *_File,const wchar_t *_Format,va_list _ArgList);
int __cdecl vwprintf_s(const wchar_t *_Format,va_list _ArgList);
int __cdecl swprintf_s(wchar_t *_Dst,size_t _SizeInWords,const wchar_t *_Format,...);
int __cdecl vswprintf_s(wchar_t *_Dst,size_t _SizeInWords,const wchar_t *_Format,va_list _ArgList);
@ -133,6 +135,7 @@ extern "C" {
_CRTIMP int __cdecl _swscanf_l(const wchar_t *_Src,const wchar_t *_Format,_locale_t _Locale,...);
_CRTIMP int __cdecl _snwscanf_l(const wchar_t *_Src,size_t _MaxCount,const wchar_t *_Format,_locale_t _Locale,...);
_CRTIMP int __cdecl _wscanf_l(const wchar_t *_Format,_locale_t _Locale,...);
_CRTIMP errno_t __cdecl _wfopen_s(FILE ** _File,const wchar_t *_Filename,const wchar_t *_Mode);
#endif
#endif

View file

@ -16,10 +16,8 @@ extern "C" {
_CRTIMP errno_t __cdecl _dupenv_s(char **_PBuffer,size_t *_PBufferSizeInBytes,const char *_VarName);
_CRTIMP errno_t __cdecl _itoa_s(int _Value,char *_DstBuf,size_t _Size,int _Radix);
#if _INTEGRAL_MAX_BITS >= 64
_CRTIMP errno_t __cdecl _i64toa_s(__int64 _Val,char *_DstBuf,size_t _Size,int _Radix);
_CRTIMP errno_t __cdecl _ui64toa_s(unsigned __int64 _Val,char *_DstBuf,size_t _Size,int _Radix);
#endif
_CRTIMP errno_t __cdecl _ltoa_s(long _Val,char *_DstBuf,size_t _Size,int _Radix);
_CRTIMP errno_t __cdecl mbstowcs_s(size_t *_PtNumOfCharConverted,wchar_t *_DstBuf,size_t _SizeInWords,const char *_SrcBuf,size_t _MaxCount);
_CRTIMP errno_t __cdecl _mbstowcs_s_l(size_t *_PtNumOfCharConverted,wchar_t *_DstBuf,size_t _SizeInWords,const char *_SrcBuf,size_t _MaxCount,_locale_t _Locale);
@ -35,11 +33,9 @@ extern "C" {
_CRTIMP errno_t __cdecl _ultow_s (unsigned long _Val,wchar_t *_DstBuf,size_t _SizeInWords,int _Radix);
_CRTIMP errno_t __cdecl _wgetenv_s(size_t *_ReturnSize,wchar_t *_DstBuf,size_t _DstSizeInWords,const wchar_t *_VarName);
_CRTIMP errno_t __cdecl _wdupenv_s(wchar_t **_Buffer,size_t *_BufferSizeInWords,const wchar_t *_VarName);
#if _INTEGRAL_MAX_BITS >= 64
_CRTIMP errno_t __cdecl _i64tow_s(__int64 _Val,wchar_t *_DstBuf,size_t _SizeInWords,int _Radix);
_CRTIMP errno_t __cdecl _ui64tow_s(unsigned __int64 _Val,wchar_t *_DstBuf,size_t _SizeInWords,int _Radix);
#endif
#endif
#ifndef _POSIX_
_CRTIMP errno_t __cdecl _ecvt_s(char *_DstBuf,size_t _Size,double _Val,int _NumOfDights,int *_PtDec,int *_PtSign);

View file

@ -14,7 +14,7 @@
extern "C" {
#endif
#if !defined(I_X86_) && defined(_WSTRING_S_DEFINED)
#if !defined(_X86_) && defined(_WSTRING_S_DEFINED)
#if defined(__cplusplus) && defined(_WConst_Return)
static __inline PUWSTR ua_wcscpy_s(PUWSTR Destination,size_t DestinationSize,PCUWSTR Source) {
if(WSTR_ALIGNED(Source) && WSTR_ALIGNED(Destination)) return (wcscpy_s((PWSTR)Destination,DestinationSize,(PCWSTR)Source)==0 ? Destination : NULL);

View file

@ -21,8 +21,14 @@ extern "C" {
_CRTIMP errno_t __cdecl _strnset_s(char *_Str,size_t _Size,int _Val,size_t _MaxCount);
_CRTIMP errno_t __cdecl _strupr_s(char *_Str,size_t _Size);
_CRTIMP errno_t __cdecl _strupr_s_l(char *_Str,size_t _Size,_locale_t _Locale);
_CRTIMP errno_t __cdecl strcpy_s(char *_Dst, size_t _Size, const char *_Src);
_CRTIMP errno_t __cdecl strcat_s(char *_Dst, size_t _Size, const char *_Src);
_CRTIMP errno_t __cdecl strncat_s(char *_Dst,size_t _DstSizeInChars,const char *_Src,size_t _MaxCount);
_CRTIMP errno_t __cdecl _strncat_s_l(char *_Dst,size_t _DstSizeInChars,const char *_Src,size_t _MaxCount,_locale_t _Locale);
_CRTIMP errno_t __cdecl strcpy_s(char *_Dst, size_t _SizeInBytes, const char *_Src);
_CRTIMP errno_t __cdecl strncpy_s(char *_Dst,size_t _DstSizeInChars,const char *_Src,size_t _MaxCount);
_CRTIMP errno_t __cdecl _strncpy_s_l(char *_Dst,size_t _DstSizeInChars,const char *_Src,size_t _MaxCount,_locale_t _Locale);
_CRTIMP char *__cdecl strtok_s(char *_Str,const char *_Delim,char **_Context);
_CRTIMP char *__cdecl _strtok_s_l(char *_Str,const char *_Delim,char **_Context,_locale_t _Locale);
#ifndef _WSTRING_S_DEFINED
#define _WSTRING_S_DEFINED
@ -35,6 +41,15 @@ extern "C" {
_CRTIMP errno_t __cdecl _wcslwr_s_l(wchar_t *_Str,size_t _SizeInWords,_locale_t _Locale);
_CRTIMP errno_t __cdecl _wcsupr_s(wchar_t *_Str,size_t _Size);
_CRTIMP errno_t __cdecl _wcsupr_s_l(wchar_t *_Str,size_t _Size,_locale_t _Locale);
_CRTIMP errno_t __cdecl wcsncat_s(wchar_t *_Dst,size_t _DstSizeInChars,const wchar_t *_Src,size_t _MaxCount);
_CRTIMP errno_t __cdecl _wcsncat_s_l(wchar_t *_Dst,size_t _DstSizeInChars,const wchar_t *_Src,size_t _MaxCount,_locale_t _Locale);
_CRTIMP errno_t __cdecl wcsncpy_s(wchar_t *_Dst,size_t _DstSizeInChars,const wchar_t *_Src,size_t _MaxCount);
_CRTIMP errno_t __cdecl _wcsncpy_s_l(wchar_t *_Dst,size_t _DstSizeInChars,const wchar_t *_Src,size_t _MaxCount,_locale_t _Locale);
_CRTIMP wchar_t *__cdecl _wcstok_s_l(wchar_t *_Str,const wchar_t *_Delim,wchar_t **_Context,_locale_t _Locale);
_CRTIMP errno_t __cdecl _wcsset_s_l(wchar_t *_Str,size_t _SizeInChars,unsigned int _Val,_locale_t _Locale);
_CRTIMP errno_t __cdecl _wcsnset_s_l(wchar_t *_Str,size_t _SizeInChars,unsigned int _Val, size_t _Count,_locale_t _Locale);
#endif
#ifdef __cplusplus

View file

@ -15,15 +15,11 @@ extern "C" {
#if defined(MINGW_HAS_SECURE_API)
#ifdef _USE_32BIT_TIME_T
#define _ftime_s _ftime32_s
#else
#define _ftime_s _ftime64_s
#endif
_CRTIMP errno_t __cdecl _ftime32_s(struct __timeb32 *_Time);
#if _INTEGRAL_MAX_BITS >= 64
_CRTIMP errno_t __cdecl _ftime64_s(struct __timeb64 *_Time);
#ifndef _USE_32BIT_TIME_T
#define _ftime_s _ftime64_s
#endif
#endif

View file

@ -14,17 +14,14 @@
extern "C" {
#endif
_CRTIMP errno_t __cdecl asctime_s(char *_Buf,size_t _SizeInWords,const struct tm *_Tm);
_CRTIMP errno_t __cdecl _ctime32_s(char *_Buf,size_t _SizeInBytes,const __time32_t *_Time);
_CRTIMP errno_t __cdecl _gmtime32_s(struct tm *_Tm,const __time32_t *_Time);
_CRTIMP errno_t __cdecl _localtime32_s(struct tm *_Tm,const __time32_t *_Time);
_CRTIMP errno_t __cdecl _strdate_s(char *_Buf,size_t _SizeInBytes);
_CRTIMP errno_t __cdecl _strtime_s(char *_Buf ,size_t _SizeInBytes);
#if _INTEGRAL_MAX_BITS >= 64
_CRTIMP errno_t __cdecl _ctime64_s(char *_Buf,size_t _SizeInBytes,const __time64_t *_Time);
_CRTIMP errno_t __cdecl _gmtime64_s(struct tm *_Tm,const __time64_t *_Time);
_CRTIMP errno_t __cdecl _localtime64_s(struct tm *_Tm,const __time64_t *_Time);
#endif
#ifndef _WTIME_S_DEFINED
#define _WTIME_S_DEFINED
@ -32,16 +29,13 @@ extern "C" {
_CRTIMP errno_t __cdecl _wctime32_s(wchar_t *_Buf,size_t _SizeInWords,const __time32_t *_Time);
_CRTIMP errno_t __cdecl _wstrdate_s(wchar_t *_Buf,size_t _SizeInWords);
_CRTIMP errno_t __cdecl _wstrtime_s(wchar_t *_Buf,size_t _SizeInWords);
#if _INTEGRAL_MAX_BITS >= 64
_CRTIMP errno_t __cdecl _wctime64_s(wchar_t *_Buf,size_t _SizeInWords,const __time64_t *_Time);
#endif
#if !defined (RC_INVOKED) && !defined (_INC_WTIME_S_INL)
#define _INC_WTIME_S_INL
#ifdef _USE_32BIT_TIME_T
__CRT_INLINE errno_t __cdecl _wctime_s(wchar_t *_Buffer,size_t _SizeInWords,const time_t *_Time) { return _wctime32_s(_Buffer,_SizeInWords,_Time); }
#else
// __CRT_INLINE errno_t __cdecl _wctime_s(wchar_t *_Buffer,size_t _SizeInWords,const time_t *_Time) { return _wctime64_s(_Buffer,_SizeInWords,_Time); }
errno_t __cdecl _wctime_s(wchar_t *, size_t, const time_t *);
#ifndef _USE_32BIT_TIME_T
__CRT_INLINE errno_t __cdecl _wctime_s(wchar_t *_Buffer,size_t _SizeInWords,const time_t *_Time) { return _wctime64_s(_Buffer,_SizeInWords,_Time); }
#endif
#endif
#endif

View file

@ -67,11 +67,9 @@ extern "C" {
_CRTIMP errno_t __cdecl _ultow_s (unsigned long _Val,wchar_t *_DstBuf,size_t _SizeInWords,int _Radix);
_CRTIMP errno_t __cdecl _wgetenv_s(size_t *_ReturnSize,wchar_t *_DstBuf,size_t _DstSizeInWords,const wchar_t *_VarName);
_CRTIMP errno_t __cdecl _wdupenv_s(wchar_t **_Buffer,size_t *_BufferSizeInWords,const wchar_t *_VarName);
#if _INTEGRAL_MAX_BITS >= 64
_CRTIMP errno_t __cdecl _i64tow_s(__int64 _Val,wchar_t *_DstBuf,size_t _SizeInWords,int _Radix);
_CRTIMP errno_t __cdecl _ui64tow_s(unsigned __int64 _Val,wchar_t *_DstBuf,size_t _SizeInWords,int _Radix);
#endif
#endif
#ifndef _POSIX_
#ifndef _WSTDLIBP_S_DEFINED
@ -94,13 +92,29 @@ extern "C" {
_CRTIMP errno_t __cdecl _wcslwr_s_l(wchar_t *_Str,size_t _SizeInWords,_locale_t _Locale);
_CRTIMP errno_t __cdecl _wcsupr_s(wchar_t *_Str,size_t _Size);
_CRTIMP errno_t __cdecl _wcsupr_s_l(wchar_t *_Str,size_t _Size,_locale_t _Locale);
_CRTIMP errno_t __cdecl wcsncat_s(wchar_t *_Dst,size_t _DstSizeInChars,const wchar_t *_Src,size_t _MaxCount);
_CRTIMP errno_t __cdecl _wcsncat_s_l(wchar_t *_Dst,size_t _DstSizeInChars,const wchar_t *_Src,size_t _MaxCount,_locale_t _Locale);
_CRTIMP errno_t __cdecl wcsncpy_s(wchar_t *_Dst,size_t _DstSizeInChars,const wchar_t *_Src,size_t _MaxCount);
_CRTIMP errno_t __cdecl _wcsncpy_s_l(wchar_t *_Dst,size_t _DstSizeInChars,const wchar_t *_Src,size_t _MaxCount,_locale_t _Locale);
_CRTIMP wchar_t *__cdecl _wcstok_s_l(wchar_t *_Str,const wchar_t *_Delim,wchar_t **_Context,_locale_t _Locale);
_CRTIMP errno_t __cdecl _wcsset_s_l(wchar_t *_Str,size_t _SizeInChars,unsigned int _Val,_locale_t _Locale);
_CRTIMP errno_t __cdecl _wcsnset_s_l(wchar_t *_Str,size_t _SizeInChars,unsigned int _Val, size_t _Count,_locale_t _Locale);
#endif
#ifndef _WTIME_S_DEFINED
#define _WTIME_S_DEFINED
_CRTIMP errno_t __cdecl _wasctime_s(wchar_t *_Buf,size_t _SizeInWords,const struct tm *_Tm);
_CRTIMP errno_t __cdecl _wctime32_s(wchar_t *_Buf,size_t _SizeInWords,const __time32_t *_Time);
_CRTIMP errno_t __cdecl _wstrdate_s(wchar_t *_Buf,size_t _SizeInWords);
_CRTIMP errno_t __cdecl _wstrtime_s(wchar_t *_Buf,size_t _SizeInWords);
_CRTIMP errno_t __cdecl _wctime64_s(wchar_t *_Buf,size_t _SizeInWords,const __time64_t *_Time);
#if !defined (RC_INVOKED) && !defined (_INC_WTIME_S_INL)
#define _INC_WTIME_S_INL
#ifdef _USE_32BIT_TIME_T
__CRT_INLINE errno_t __cdecl _wctime_s(wchar_t *_Buffer,size_t _SizeInWords,const time_t *_Time) { return _wctime32_s(_Buffer,_SizeInWords,_Time); }
#else
errno_t __cdecl _wctime_s(wchar_t *, size_t, const time_t *);
#ifndef _USE_32BIT_TIME_T
__CRT_INLINE errno_t __cdecl _wctime_s(wchar_t *_Buffer,size_t _SizeInWords,const time_t *_Time) { return _wctime64_s(_Buffer,_SizeInWords,_Time); }
#endif
#endif

View file

@ -820,5 +820,5 @@ __CRT_INLINE wchar_t *__cdecl _wctime(const time_t *_Time) { return _wctime64(_T
#pragma pack(pop)
//#include <sec_api/wchar_s.h>
#include <sec_api/wchar_s.h>
#endif

View file

@ -8,28 +8,19 @@
#include <precomp.h>
extern FDINFO *fdesc;
/*
* @implemented
*/
int _cputs(const char *_str)
{
#if 0
DWORD count;
int retval = EOF;
HANDLE console_out = GetStdHandle(STD_OUTPUT_HANDLE);
LOCK_CONSOLE;
if (WriteConsoleA(console_out, str, strlen(str), &count, NULL)
//LOCK_CONSOLE;
if (WriteConsoleA(console_out, _str, strlen(_str), &count, NULL)
&& count == 1)
retval = 0;
UNLOCK_CONSOLE;
//UNLOCK_CONSOLE;
return retval;
#else
int len = (int)strlen(_str);
DWORD written = 0;
if (!WriteFile( fdesc[stdout->_file].hFile ,_str,len,&written,NULL))
return -1;
return 0;
#endif
}

View file

@ -20,7 +20,6 @@ list(APPEND CRT_SOURCE
direct/wgetdcwd.c
direct/wmkdir.c
direct/wrmdir.c
except/abnorter.c
except/cpp.c
except/cppexcept.c
except/except.c
@ -135,6 +134,7 @@ list(APPEND CRT_SOURCE
printf/_snprintf.c
printf/_snwprintf.c
printf/_vcprintf.c
printf/_vsprintf_p.c
printf/_vsnprintf.c
printf/_vsnwprintf.c
printf/fprintf.c
@ -173,7 +173,6 @@ list(APPEND CRT_SOURCE
stdio/find64.c
stdio/findi64.c
stdio/fmode.c
stdio/lock_file.c
stdio/perror.c
stdio/popen.c
stdio/stat.c
@ -275,7 +274,6 @@ list(APPEND CRT_SOURCE
time/time64.c
time/time.c
time/timezone.c
time/tzname.c
time/utime32.c
time/utime64.c
time/utime.c

View file

@ -34,6 +34,7 @@
<file>_snprintf.c</file>
<file>_snwprintf.c</file>
<file>_vcprintf.c</file>
<file>_vsprintf_p.c</file>
<file>_vsnprintf.c</file>
<file>_vsnwprintf.c</file>
<file>fprintf.c</file>
@ -77,7 +78,6 @@
<file>wrmdir.c</file>
</directory>
<directory name="except">
<file>abnorter.c</file>
<file>cpp.c</file>
<file>cppexcept.c</file>
<file>except.c</file>
@ -374,7 +374,6 @@
<file>wpopen.c</file>
<file>wstat.c</file>
<file>wstat64.c</file>
<file>lock_file.c</file>
</directory>
<directory name="stdlib">
<file>_exit.c</file>
@ -519,7 +518,6 @@
<file>time64.c</file>
<file>time.c</file>
<file>timezone.c</file>
<file>tzname.c</file>
<file>utime32.c</file>
<file>utime64.c</file>
<file>utime.c</file>

View file

@ -1,7 +1,6 @@
#include <precomp.h>
#include <ctype.h>
#include <direct.h>
#include <tchar.h>
#include <process.h>
/*
* @implemented

View file

@ -37,7 +37,7 @@ int _chdrive(int newdrive)
_dosmaperr(GetLastError());
if (newdrive <= 0)
{
__set_errno(EACCES);
_set_errno(EACCES);
}
return -1;
}

View file

@ -1,6 +1,6 @@
#include <precomp.h>
#include <direct.h>
#include <stdlib.h>
#include <process.h>
#include <tchar.h>
/*
@ -24,7 +24,7 @@ _TCHAR* _tgetcwd(_TCHAR* buf, int size)
if (dir_len >= (DWORD)size)
{
__set_errno(ERANGE);
_set_errno(ERANGE);
return NULL; /* buf too small */
}

View file

@ -36,7 +36,7 @@ _TCHAR* _tgetdcwd(int drive, _TCHAR * buf, int size)
drivespec[0] += drive - 1;
if (GetDriveType(drivespec) < DRIVE_REMOVABLE)
{
__set_errno(EACCES);
_set_errno(EACCES);
return NULL;
}
@ -46,7 +46,7 @@ _TCHAR* _tgetdcwd(int drive, _TCHAR * buf, int size)
dir_len = GetFullPathName(drivespec,MAX_PATH,dir,&dummy);
if (dir_len >= size || dir_len < 1)
{
__set_errno(ERANGE);
_set_errno(ERANGE);
return NULL; /* buf too small */
}

View file

@ -1 +0,0 @@
#include <precomp.h>

View file

@ -1,4 +1,3 @@
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#ifndef __CRT_INTERNAL_ATEXIT_H
#define __CRT_INTERNAL_ATEXIT_H
@ -6,12 +5,13 @@
#error DO NOT INCLUDE THIS HEADER DIRECTLY
#endif
struct __atexit {
struct __atexit* __next;
void (*__function)(void);
};
#define LOCK_EXIT _mlock(_EXIT_LOCK1)
#define UNLOCK_EXIT _munlock(_EXIT_LOCK1)
extern struct __atexit* __atexit_ptr;
extern _onexit_t *atexit_table;
extern int atexit_table_size;
extern int atexit_registered; /* Points to free slot */
void __call_atexit(void);
#endif

View file

@ -1,177 +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))
int __set_errno(int err);
int __set_doserrno(int error);
void* filehnd(int fn);
char __is_text_file(FILE*);
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 sigabort_handler(int sig);
void UnixTimeToFileTime(time_t unix_time, 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);
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
#undef MB_CUR_MAX
#define MB_CUR_MAX __mb_cur_max
int _isnanl(long double x);
int _isinfl(long 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,22 +0,0 @@
#ifndef _CRT_PRINTF_H
#define _CRT_PRINTF_H
/* Implementation of a printf appropriated from Linux kernel */
int lnx_sprintf(char *str, const char *fmt, ...);
int lnx__vsprintf(char *str, const char *fmt, va_list ap);
int lnx__vswprintf(wchar_t *str, const wchar_t *fmt, va_list ap);
int lnx__vsnprintf(char *str, size_t maxlen, const char *fmt, va_list ap);
int lnx__vsnwprintf(wchar_t *str, size_t maxlen, const char *fmt, va_list ap);
int lnx_vfprintf(FILE* f, const char* fmt, va_list ap);
int lnx_vfwprintf(FILE *f, const wchar_t *fmt, va_list ap);
#ifdef _UNICODE
#define lnx_vftprintf lnx_vfwprintf
#define lnx__vstprintf lnx__vswprintf
#else
#define lnx_vftprintf lnx_vfprintf
#define lnx__vstprintf lnx__vsprintf
#endif
#endif /* _CRT_PRINTF_H */

View file

@ -27,5 +27,7 @@
void _amsg_exit (int errnum);
/* not in any other header */
void _dosmaperr(unsigned long oserrcode);
#endif /* __MSVCRT_INTERNAL_RTERROR_H */

View file

@ -8,3 +8,11 @@ void _invalid_parameter(
unsigned int line,
uintptr_t pReserved);
#ifndef _LIBCNT_
#define MSVCRT_INVALID_PMT(x) _invalid_parameter(NULL, NULL, NULL, 0, 0)
#define MSVCRT_CHECK_PMT(x) ((x) || (MSVCRT_INVALID_PMT(0),FALSE))
#else
/* disable secure crt parameter checks */
#define MSVCRT_CHECK_PMT
#define MSVCRT_INVALID_PMT
#endif

View file

@ -34,19 +34,32 @@ void __cdecl _purecall(void);
void __cdecl _amsg_exit(int errnum);
extern char **_environ;
#ifndef __REACTOS__
extern wchar_t **_wenviron;
extern char ** SnapshotOfEnvironmentA(char **);
extern wchar_t ** SnapshotOfEnvironmentW(wchar_t **);
#endif
wchar_t *wstrdupa(const char *);
/* Application type flags */
#define _UNKNOWN_APP 0
#define _CONSOLE_APP 1
#define _GUI_APP 2
/* 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 __cdecl _set_new_mode(int mode);
/* I/O Streamming flags missing from stdio.h */
#define _IOYOURBUF 0x0100
#define _IOAPPEND 0x0200
#define _IOSETVBUF 0x0400
#define _IOFEOF 0x0800
#define _IOFLRTN 0x1000
#define _IOCTRLZ 0x2000
#define _IOCOMMIT 0x4000
#define _IOFREE 0x10000
//wchar_t *wstrdupa(const char *);
//
///* 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 __cdecl _set_new_mode(int mode);
//
void* __cdecl MSVCRT_operator_new(size_t);
void __cdecl MSVCRT_operator_delete(void*);
typedef void* (*__cdecl malloc_func_t)(size_t);

View file

@ -55,6 +55,7 @@ LCID MSVCRT_current_lc_all_lcid = 0;
int MSVCRT___lc_codepage = 0;
int MSVCRT___lc_collate_cp = 0;
HANDLE MSVCRT___lc_handle[MSVCRT_LC_MAX - MSVCRT_LC_MIN + 1] = { 0 };
int __mb_cur_max = 1;
/* MT */
#define LOCK_LOCALE _mlock(_SETLOCALE_LOCK);
@ -668,7 +669,7 @@ int CDECL _setmbcp(int cp)
if (!GetCPInfo(newcp, &cpi))
{
ERR("Codepage %d not found\n", newcp);
__set_errno(EINVAL);
_set_errno(EINVAL);
return -1;
}

View file

@ -9,7 +9,11 @@
*/
#include <mbstring.h>
int colldif(unsigned short c1, unsigned short c2);
int colldif(unsigned short c1, unsigned short c2)
{
return c1 - c2;
}
/*
* @implemented
@ -109,7 +113,3 @@ int _mbsnbcoll(const unsigned char *str1, const unsigned char *str2, size_t n)
return 0;
}
int colldif(unsigned short c1, unsigned short c2)
{
return c1 - c2;
}

View file

@ -1,15 +1,11 @@
/* $Id$
*
/*
* environ.c
*
* ReactOS MSVCRT.DLL Compatibility Library
*/
#include <precomp.h>
#include <internal/tls.h>
#include <stdlib.h>
#include <string.h>
#include <internal/wine/msvcrt.h>
unsigned int _osplatform = 0;
unsigned int _osver = 0;
@ -17,7 +13,8 @@ unsigned int _winminor = 0;
unsigned int _winmajor = 0;
unsigned int _winver = 0;
unsigned int __setlc_active = 0;
unsigned int __unguarded_readlc_active = 0;
char *_acmdln = NULL; /* pointer to ascii command line */
wchar_t *_wcmdln = NULL; /* pointer to wide character command line */
#undef _environ
@ -30,9 +27,7 @@ wchar_t **__winitenv = NULL; /* pointer to initial environment block */
char *_pgmptr = NULL; /* pointer to program name */
#undef _wpgmptr
wchar_t *_wpgmptr = NULL; /* pointer to program name */
int __app_type = 0; //_UNKNOWN_APP; /* application type */
int __mb_cur_max = 1;
int __app_type = _UNKNOWN_APP; /* application type */
int _commode = _IOCOMMIT;
@ -412,6 +407,20 @@ wchar_t ***__p___winitenv(void)
return &__winitenv;
}
/*
* @implemented
*/
errno_t _get_osplatform(unsigned int *pValue)
{
if (!MSVCRT_CHECK_PMT(pValue != NULL)) {
*_errno() = EINVAL;
return EINVAL;
}
*pValue = _osplatform;
return 0;
}
/*
* @implemented
*/
@ -436,6 +445,21 @@ char **__p__pgmptr(void)
return &_pgmptr;
}
/*
* @implemented
*/
int _get_pgmptr(char** p)
{
if (!MSVCRT_CHECK_PMT(p))
{
*_errno() = EINVAL;
return EINVAL;
}
*p = _pgmptr;
return 0;
}
/*
* @implemented
*/
@ -444,6 +468,21 @@ wchar_t **__p__wpgmptr(void)
return &_wpgmptr;
}
/*
* @implemented
*/
int _get_wpgmptr(WCHAR** p)
{
if (!MSVCRT_CHECK_PMT(p))
{
*_errno() = EINVAL;
return EINVAL;
}
*p = _wpgmptr;
return 0;
}
/*
* @implemented
*/

View file

@ -1,20 +1,49 @@
#include <stdlib.h>
#include <precomp.h>
typedef void (CDECL *_INITTERMFUN)(void);
typedef int (CDECL *_INITTERM_E_FN)(void);
/*
* @implemented
/*********************************************************************
* _initterm (MSVCRT.@)
*/
void _initterm(void (*fStart[])(void), void (*fEnd[])(void))
void CDECL _initterm(_INITTERMFUN *start,_INITTERMFUN *end)
{
int i = 0;
_INITTERMFUN* current = start;
if ( fStart == NULL || fEnd == NULL )
return;
while ( &fStart[i] < fEnd )
{
if ( fStart[i] != NULL )
(*fStart[i])();
i++;
}
TRACE("(%p,%p)\n",start,end);
while (current<end)
{
if (*current)
{
TRACE("Call init function %p\n",*current);
(**current)();
TRACE("returned\n");
}
current++;
}
}
/*********************************************************************
* _initterm_e (MSVCRT.@)
*
* call an array of application initialization functions and report the return value
*/
int CDECL _initterm_e(_INITTERM_E_FN *table, _INITTERM_E_FN *end)
{
int res = 0;
TRACE("(%p, %p)\n", table, end);
while (!res && table < end) {
if (*table) {
TRACE("calling %p\n", **table);
res = (**table)();
if (res)
TRACE("function %p failed: 0x%x\n", *table, res);
}
table++;
}
return res;
}

View file

@ -1,10 +1,27 @@
#include <internal/rterror.h>
#include <precomp.h>
/*
* @implemented
*/
void _purecall(void)
typedef void (__cdecl *MSVCRT_purecall_handler)(void);
static MSVCRT_purecall_handler purecall_handler = NULL;
/* _set_purecall_handler - not exported in native msvcrt */
MSVCRT_purecall_handler CDECL _set_purecall_handler(MSVCRT_purecall_handler function)
{
_amsg_exit(_RT_PUREVIRT);
MSVCRT_purecall_handler ret = purecall_handler;
TRACE("(%p)\n", function);
purecall_handler = function;
return ret;
}
/*********************************************************************
* _purecall (MSVCRT.@)
*/
void CDECL _purecall(void)
{
if(purecall_handler)
purecall_handler();
_amsg_exit( 25 );
}

View file

@ -1,5 +1,19 @@
#include <precomp.h>
static BOOL n_format_enabled = TRUE;
int CDECL _get_printf_count_output( void )
{
return n_format_enabled ? 1 : 0;
}
int CDECL _set_printf_count_output( int enable )
{
BOOL old = n_format_enabled;
n_format_enabled = (enable ? TRUE : FALSE);
return old ? 1 : 0;
}
int __STRINGTOLD( long double *value, char **endptr, const char *str, int flags )
{
FIXME("%p %p %s %x stub\n", value, endptr, str, flags );
@ -16,3 +30,8 @@ void stub(void)
FIXME("stub\n");
}
unsigned int _get_output_format(void)
{
return 0;
}

View file

@ -7,9 +7,13 @@
#define _INC_UTIME_INL
#define _INC_TIME_INL
/* needed to expose _s api definitions */
#define MINGW_HAS_SECURE_API 1
/* Headers to be compiled */
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <conio.h>
#include <errno.h>
@ -33,11 +37,10 @@
#include <stdint.h>
#endif
/* kernelmode libcnt should not include Wine stuff */
#ifndef _LIBCNT_
#include "wine/unicode.h"
#include "wine/config.h"
/* kernelmode libcnt should not include Wine-debugging crap */
#ifndef _LIBCNT_
#define WINE_NO_TRACE_MSGS
#include "wine/debug.h"
#ifndef __WINE_DEBUG_CHANNEL__
@ -53,7 +56,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
/* CRT Internal data */
#include <internal/atexit.h>
#include <internal/console.h>
#include <internal/file.h>
#include <internal/ieee.h>
#include <internal/math.h>
#include <internal/mbstring.h>
@ -64,6 +66,5 @@ WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
#if !defined(_LIBCNT_) && !defined(_MSVCRTEX_)
#include <internal/tls.h>
#endif
#include <internal/printf.h>
#endif /* _CRT_PRECOMP_H */

View file

@ -1,17 +1,17 @@
/*
* COPYRIGHT: GNU GPL, see COPYING in the top level directory
* PROJECT: ReactOS crt library
* FILE: lib/sdk/crt/printf/_vcprintf.c
* PURPOSE: Implementation of _vcprintf
* FILE: lib/sdk/crt/printf/_cprintf.c
* PURPOSE: Implementation of _cprintf
* PROGRAMMER: Timo Kreuzer
* Samuel Serapión
*/
#include <conio.h>
#include <stdarg.h>
int _vcprintf(const char* format, va_list argptr);
int
_cdecl
__cdecl
_cprintf(const char * format, ...)
{
va_list argptr;
@ -23,3 +23,16 @@ _cprintf(const char * format, ...)
return result;
}
int
__cdecl
_cwprintf(const wchar_t* format, ...)
{
int retval;
va_list valist;
va_start( valist, format );
retval = _vcwprintf(format, valist);
va_end(valist);
return retval;
}

View file

@ -3,16 +3,22 @@
* PROJECT: ReactOS crt library
* FILE: lib/sdk/crt/printf/_vcprintf.c
* PURPOSE: Implementation of _vcprintf
* PROGRAMMER: Timo Kreuzer
* PROGRAMMER: Samuel Serapión
*/
#include <stdio.h>
#include <stdarg.h>
int
_cdecl
__cdecl
_vcprintf(const char* format, va_list va)
{
return 0;
return vfprintf(stdout, format, va);
}
int
__cdecl
_vcwprintf(const wchar_t* format, va_list va)
{
return vfwprintf(stdout, format, va);
}

View file

@ -0,0 +1,13 @@
/*
* COPYRIGHT: GNU GPL, see COPYING in the top level directory
* PROJECT: ReactOS crt library
* FILE: lib/sdk/crt/printf/_vsprintf_p.c
* PURPOSE: Implementation of _vsprintf_p
* PROGRAMMER: Samuel Serapión
*/
#define _sxprintf _vsprintf_p
#define USE_COUNT 1
#define USE_VARARGS 1
#include "_sxprintf.c"

View file

@ -4,21 +4,32 @@
* FILE: lib/sdk/crt/printf/fprintf.c
* PURPOSE: Implementation of fprintf
* PROGRAMMER: Timo Kreuzer
* Samuel Serapión
*/
#include <stdio.h>
#include <stdarg.h>
#include <precomp.h>
int
_cdecl
fprintf(FILE *stream, const char *format, ...)
__cdecl
fprintf(FILE *file, const char *format, ...)
{
va_list argptr;
int result;
va_start(argptr, format);
result = vfprintf(stream, format, argptr);
result = vfprintf(file, format, argptr);
va_end(argptr);
return result;
}
int
__cdecl
fprintf_s(FILE* file, const char *format, ...)
{
va_list argptr;
int result;
va_start(argptr, format);
result = vfprintf_s(file, format, argptr);
va_end(argptr);
return result;
}

View file

@ -4,10 +4,10 @@
* FILE: lib/sdk/crt/printf/fwprintf.c
* PURPOSE: Implementation of fwprintf
* PROGRAMMER: Timo Kreuzer
* Samuel Serapión
*/
#include <stdio.h>
#include <stdarg.h>
#include <precomp.h>
int
__cdecl
@ -21,3 +21,15 @@ fwprintf(FILE* file, const wchar_t *format, ...)
va_end(argptr);
return result;
}
int
__cdecl
fwprintf_s(FILE* file, const wchar_t *format, ...)
{
va_list valist;
int res;
va_start(valist, format);
res = vfwprintf_s(file, format, valist);
va_end(valist);
return res;
}

View file

@ -4,13 +4,10 @@
* FILE: lib/sdk/crt/printf/printf.c
* PURPOSE: Implementation of printf
* PROGRAMMER: Timo Kreuzer
* Samuel Serapión
*/
#include <stdio.h>
#include <stdarg.h>
#include <tchar.h>
int _cdecl streamout(FILE *stream, const char *format, va_list argptr);
#include <precomp.h>
int
_cdecl
@ -20,9 +17,22 @@ printf(const char *format, ...)
int result;
va_start(argptr, format);
result = streamout(stdout, format, argptr);
result = vprintf(format, argptr);
va_end(argptr);
return result;
}
int
_cdecl
printf_s(const char *format, ...)
{
va_list argptr;
int res;
va_start(argptr, format);
res = vprintf_s(format, argptr);
va_end(argptr);
return res;
}

View file

@ -4,26 +4,42 @@
* FILE: lib/sdk/crt/printf/vfprintf.c
* PURPOSE: Implementation of vfprintf
* PROGRAMMER: Timo Kreuzer
* Samuel Serapión
*/
#include <stdio.h>
#include <stdarg.h>
#include <precomp.h>
void _cdecl _lock_file(FILE* file);
void _cdecl _unlock_file(FILE* file);
int _cdecl streamout(FILE *stream, const char *format, va_list argptr);
void CDECL _lock_file(FILE* file);
void CDECL _unlock_file(FILE* file);
int CDECL streamout(FILE *stream, const char *format, va_list argptr);
int
_cdecl
vfprintf(FILE *stream, const char *format, va_list argptr)
CDECL
vfprintf(FILE *file, const char *format, va_list argptr)
{
int result;
_lock_file(stream);
result = streamout(stream, format, argptr);
_unlock_file(stream);
_lock_file(file);
result = streamout(file, format, argptr);
_unlock_file(file);
return result;
}
int
CDECL
vfprintf_s(FILE* file, const char *format, va_list argptr)
{
int result;
if(!MSVCRT_CHECK_PMT(format != NULL)) {
*_errno() = EINVAL;
return -1;
}
_lock_file(file);
result = streamout(file, format, argptr);
_unlock_file(file);
return result;
}

View file

@ -4,17 +4,43 @@
* FILE: lib/sdk/crt/printf/vfwprintf.c
* PURPOSE: Implementation of vfwprintf
* PROGRAMMER: Timo Kreuzer
* Samuel Serapión
*/
#include <stdio.h>
#include <stdarg.h>
#include <precomp.h>
#include <wchar.h>
int _cdecl wstreamout(FILE *stream, const wchar_t *format, va_list argptr);
void CDECL _lock_file(FILE* file);
void CDECL _unlock_file(FILE* file);
int CDECL wstreamout(FILE *stream, const wchar_t *format, va_list argptr);
int
__cdecl
CDECL
vfwprintf(FILE* file, const wchar_t *format, va_list argptr)
{
return wstreamout(file, format, argptr);
int ret;
_lock_file(file);
ret = wstreamout(file, format, argptr);
_unlock_file(file);
return ret;
}
int
CDECL
vfwprintf_s(FILE* file, const wchar_t *format, va_list argptr)
{
int ret;
if(!MSVCRT_CHECK_PMT( file != NULL)) {
*_errno() = EINVAL;
return -1;
}
_lock_file(file);
ret = wstreamout(file, format, argptr);
_unlock_file(file);
return ret;
}

View file

@ -4,16 +4,21 @@
* FILE: lib/sdk/crt/printf/vprintf.c
* PURPOSE: Implementation of vprintf
* PROGRAMMER: Timo Kreuzer
* Samuel Serapión
*/
#include <stdio.h>
#include <stdarg.h>
int _cdecl streamout(FILE *stream, const char *format, va_list argptr);
#include <precomp.h>
int
__cdecl
vprintf(const char *format, va_list argptr)
{
return streamout(stdout, format, argptr);
return vfprintf(stdout, format, argptr);
}
int
__cdecl
vprintf_s(const char *format, va_list valist)
{
return vfprintf_s(stdout,format,valist);
}

View file

@ -4,16 +4,21 @@
* FILE: lib/sdk/crt/printf/vwprintf.c
* PURPOSE: Implementation of vwprintf
* PROGRAMMER: Timo Kreuzer
* Samuel Serapión
*/
#include <stdio.h>
#include <stdarg.h>
int _cdecl wstreamout(FILE *stream, const wchar_t *format, va_list argptr);
#include <precomp.h>
int
__cdecl
vwprintf(const wchar_t *format, va_list argptr)
vwprintf(const wchar_t *format, va_list valist)
{
return wstreamout(stdout, format, argptr);
return vfwprintf(stdout,format,valist);
}
int
__cdecl
vwprintf_s(const wchar_t *format, va_list valist)
{
return vfwprintf_s(stdout,format,valist);
}

View file

@ -4,12 +4,10 @@
* FILE: lib/sdk/crt/printf/wprintf.c
* PURPOSE: Implementation of wprintf
* PROGRAMMER: Timo Kreuzer
* Samuel Serapión
*/
#include <stdio.h>
#include <stdarg.h>
int _cdecl wstreamout(FILE *stream, const wchar_t *format, va_list argptr);
#include <precomp.h>
int
__cdecl
@ -19,7 +17,19 @@ wprintf(const wchar_t *format, ...)
int result;
va_start(argptr, format);
result = wstreamout(stdout, format, argptr);
result = vwprintf(format, argptr);
va_end(argptr);
return result;
}
int
__cdecl
wprintf_s(const wchar_t *format, ...)
{
va_list argptr;
int res;
va_start(argptr, format);
res = vwprintf_s(format, argptr);
va_end(argptr);
return res;
}

View file

@ -19,7 +19,7 @@ int _cwait(int* pnStatus, int hProc, int nAction)
nAction = 0;
if (WaitForSingleObject((void*)ULongToPtr(hProc), INFINITE) != WAIT_OBJECT_0) {
__set_errno(ECHILD);
_set_errno(ECHILD);
return -1;
}

View file

@ -1,5 +1,4 @@
/* $Id$
*
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/msvcrt/process/system.c
@ -45,7 +44,7 @@ int system(const char *command)
return -1;
// should return 127 or 0 ( MS ) if the shell is not found
// __set_errno(ENOENT);
// _set_errno(ENOENT);
if (szComSpec == NULL)
{
@ -62,7 +61,7 @@ int system(const char *command)
szCmdLine = malloc(strlen(s) + 4 + strlen(command) + 1);
if (szCmdLine == NULL)
{
__set_errno(ENOMEM);
_set_errno(ENOMEM);
return -1;
}

View file

@ -29,6 +29,8 @@
#define MK_STR(s) #s
int access_dirT(const _TCHAR *_path);
_TCHAR const* extT[] =
{
_T(""),
@ -200,18 +202,18 @@ do_spawnT(int mode, const _TCHAR* cmdname, const _TCHAR* args, const _TCHAR* env
if (mode != _P_NOWAIT && mode != _P_NOWAITO && mode != _P_WAIT && mode != _P_DETACH && mode != _P_OVERLAY)
{
__set_errno ( EINVAL );
_set_errno ( EINVAL );
return( -1);
}
if (0 != _taccess(cmdname, F_OK))
{
__set_errno ( ENOENT );
_set_errno ( ENOENT );
return(-1);
}
if (0 == access_dirT(cmdname))
{
__set_errno ( EISDIR );
_set_errno ( EISDIR );
return(-1);
}
@ -234,7 +236,7 @@ do_spawnT(int mode, const _TCHAR* cmdname, const _TCHAR* args, const _TCHAR* env
StartupInfo.lpReserved2 = malloc(StartupInfo.cbReserved2);
if (StartupInfo.lpReserved2 == NULL)
{
__set_errno ( ENOMEM );
_set_errno ( ENOMEM );
return -1;
}

View file

@ -37,14 +37,14 @@ __p_sig_fn_t signal(int sig, __p_sig_fn_t func)
break;
default:
__set_errno(EINVAL);
_set_errno(EINVAL);
return SIG_ERR;
}
// check with IsBadCodePtr
if ( (uintptr_t)func < 4096 && func != SIG_DFL && func != SIG_IGN)
{
__set_errno(EINVAL);
_set_errno(EINVAL);
return SIG_ERR;
}
@ -59,7 +59,7 @@ __p_sig_fn_t signal(int sig, __p_sig_fn_t func)
}
/* should be impossible to get here */
__set_errno(EINVAL);
_set_errno(EINVAL);
return SIG_ERR;
}

View file

@ -6,9 +6,7 @@
* PROGRAMMER: Timo Kreuzer
*/
#include <stdio.h>
#include <io.h>
#include <tchar.h>
#include <precomp.h>
void __cdecl alloc_buffer(FILE *stream);

View file

@ -26,7 +26,7 @@ int access_dirT(const _TCHAR *_path)
if ((Attributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY)
{
__set_errno(EACCES);
_set_errno(EACCES);
return -1;
}

File diff suppressed because it is too large Load diff

View file

@ -1,15 +0,0 @@
#include <stdio.h>
void
_cdecl
_lock_file(FILE* file)
{
}
void
_cdecl
_unlock_file(FILE* file)
{
}

View file

@ -1,18 +1,6 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <precomp.h>
#ifdef perror
#undef perror
void perror(const char *s);
#endif
/*
* @implemented
*/
void perror(const char *s)
{
fprintf(stderr, "%s: %s\n", s, _strerror(NULL));
}
/*
* @implemented

View file

@ -1,55 +1,55 @@
/* taken from wine exit.c */
#include <precomp.h>
#include <internal/atexit.h>
extern void _atexit_cleanup(void);
struct __atexit *__atexit_ptr = 0;
/*
* @implemented
*/
void exit(int status)
{
//int i;
/*
if (__stdio_cleanup_hook)
__stdio_cleanup_hook();
for (i=0; i<djgpp_last_dtor-djgpp_first_dtor; i++)
djgpp_first_dtor[i]();
*/
/* in case the program set it this way */
_setmode(0, _O_TEXT);
_atexit_cleanup();
_exit(status);
for(;;);
}
/*
* @implemented
*/
void _exit(int _status)
{
// FIXME: _exit and _c_exit should prevent atexit routines from being called during DLL unload
ExitProcess(_status);
for(;;);
}
/*
* @unimplemented
*/
void _cexit( void )
{
_atexit_cleanup();
// flush
LOCK_EXIT;
__call_atexit();
UNLOCK_EXIT;
}
/*
* @unimplemented
* @implemented
*/
void _c_exit( void )
{
// FIXME: _exit and _c_exit should prevent atexit routines from being called during DLL unload
// reset interup vectors
/* All cleanup is done on DLL detach; Return to caller */
}
/*
* @implemented
*/
void _exit(int exitcode)
{
ExitProcess(exitcode);
}
/*
* @implemented
*/
void exit(int exitcode)
{
#if 0
HMODULE hmscoree;
static const WCHAR mscoreeW[] = {'m','s','c','o','r','e','e',0};
void (WINAPI *pCorExitProcess)(int);
#endif
WARN("exit(%d) called\n",exitcode);
_cexit();
#if 0
hmscoree = GetModuleHandleW(mscoreeW);
if (hmscoree)
{
pCorExitProcess = (void*)GetProcAddress(hmscoree, "CorExitProcess");
if (pCorExitProcess)
pCorExitProcess(exitcode);
}
#endif
ExitProcess(exitcode);
}

View file

@ -1,27 +1,114 @@
/*
* 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
* FILE: lib/crt/stdlib/abort.c
* PURPOSE: Abnormal termination message
* PROGRAMER: Jon Griffiths
* Samuel Serapión
*/
/* based on wine exit.c */
#include <precomp.h>
#include <signal.h>
#include <internal/wine/msvcrt.h>
char *msg ="Abort\n\r";
extern int msvcrt_error_mode;
extern int __app_type;
unsigned int msvcrt_abort_behavior = MSVCRT__WRITE_ABORT_MSG | MSVCRT__CALL_REPORTFAULT;
/* avoid linking to user32 */
typedef HWND (WINAPI *GetActiveWindowPtr)(void);
static GetActiveWindowPtr pGetActiveWindow = NULL;
typedef int (WINAPI *MessageBoxIndirectWPtr)(const MSGBOXPARAMSW*);
static MessageBoxIndirectWPtr pMessageBoxIndirectW = NULL;
static void DoMessageBoxW(const wchar_t *lead, const wchar_t *message)
{
const char szMsgBoxTitle[] = "ReactOS C++ Runtime Library";
const wchar_t message_format[] = {'%','s','\n','\n','P','r','o','g','r','a','m',':',' ','%','s','\n',
'%','s','\n','\n','P','r','e','s','s',' ','O','K',' ','t','o',' ','e','x','i','t',' ','t','h','e',' ',
'p','r','o','g','r','a','m',',',' ','o','r',' ','C','a','n','c','e','l',' ','t','o',' ','s','t','a','r','t',' ',
't','h','e',' ','d','e','b','b','u','g','e','r','.','\n',0};
MSGBOXPARAMSW msgbox;
wchar_t text[2048];
INT ret;
_snwprintf(text,sizeof(text),message_format, lead, _wpgmptr, message);
msgbox.cbSize = sizeof(msgbox);
msgbox.hwndOwner = pGetActiveWindow();
msgbox.hInstance = 0;
msgbox.lpszText = (LPCWSTR)text;
msgbox.lpszCaption = (LPCWSTR)szMsgBoxTitle;
msgbox.dwStyle = MB_OKCANCEL|MB_ICONERROR;
msgbox.lpszIcon = NULL;
msgbox.dwContextHelpId = 0;
msgbox.lpfnMsgBoxCallback = NULL;
msgbox.dwLanguageId = LANG_NEUTRAL;
ret = pMessageBoxIndirectW(&msgbox);
if (ret == IDCANCEL)
DebugBreak();
}
static void DoMessageBox(const char *lead, const char *message)
{
wchar_t leadW[1024], messageW[1024];
HMODULE huser32 = LoadLibrary("user32.dll");
if(huser32) {
pGetActiveWindow = (GetActiveWindowPtr)GetProcAddress(huser32, "GetActiveWindow");
pMessageBoxIndirectW = (MessageBoxIndirectWPtr)GetProcAddress(huser32, "MessageBoxIndirectW");
if(!pGetActiveWindow || !pMessageBoxIndirectW) {
FreeLibrary(huser32);
ERR("GetProcAddress failed!\n");
return;
}
}
else
{
ERR("Loading user32 failed!\n");
return;
}
mbstowcs(leadW, lead, 1024);
mbstowcs(messageW, message, 1024);
DoMessageBoxW(leadW, messageW);
FreeLibrary(huser32);
}
/*
* @implemented
*/
void abort()
{
fflush(NULL);
_fcloseall();
raise(SIGABRT);
_write(stderr->_file, msg, sizeof(msg)-1);
exit(3);
if (msvcrt_abort_behavior & MSVCRT__WRITE_ABORT_MSG)
{
if ((msvcrt_error_mode == MSVCRT__OUT_TO_MSGBOX) ||
((msvcrt_error_mode == MSVCRT__OUT_TO_DEFAULT) && (__app_type == 2)))
{
DoMessageBox("Runtime error!", "abnormal program termination");
}
else
_cputs("\nabnormal program termination\n");
}
raise(SIGABRT);
/* in case raise() returns */
_exit(3);
}
unsigned int CDECL _set_abort_behavior(unsigned int flags, unsigned int mask)
{
unsigned int old = msvcrt_abort_behavior;
TRACE("%x, %x\n", flags, mask);
if (mask & MSVCRT__CALL_REPORTFAULT)
FIXME("_WRITE_CALL_REPORTFAULT unhandled\n");
msvcrt_abort_behavior = (msvcrt_abort_behavior & ~mask) | (flags & mask);
return old;
}

View file

@ -1,69 +1,98 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
/* taken from wine exit.c */
#include <precomp.h>
void _atexit_cleanup(void)
_onexit_t *atexit_table = NULL;
int atexit_table_size = 0;
int atexit_registered = 0; /* Points to free slot */
/* INTERNAL: call atexit functions */
void __call_atexit(void)
{
struct __atexit *next, *a = __atexit_ptr;
__atexit_ptr = 0; /* to prevent infinite loops */
while (a)
/* Note: should only be called with the exit lock held */
TRACE("%d atext functions to call\n", atexit_registered);
/* Last registered gets executed first */
while (atexit_registered > 0)
{
(a->__function)();
next = a->__next;
free(a);
a = next;
atexit_registered--;
TRACE("next is %p\n",atexit_table[atexit_registered]);
if (atexit_table[atexit_registered])
(*atexit_table[atexit_registered])();
TRACE("returned\n");
}
}
/*
* @implemented
*
* Ported from WINE
* Copyright (C) 2000 Jon Griffiths
/*********************************************************************
* __dllonexit (MSVCRT.@)
*/
_onexit_t __dllonexit(_onexit_t func, _onexit_t **start, _onexit_t **end)
_onexit_t CDECL __dllonexit(_onexit_t func, _onexit_t **start, _onexit_t **end)
{
_onexit_t *tmp;
size_t len;
if (!start || !*start || !end || !*end)
return NULL;
TRACE("(%p,%p,%p)\n", func, start, end);
len = (*end - *start);
if (++len <= 0)
return NULL;
if (!start || !*start || !end || !*end)
{
FIXME("bad table\n");
return NULL;
}
tmp = (_onexit_t *)realloc(*start, len * sizeof(tmp));
if (!tmp)
return NULL;
len = (*end - *start);
*start = tmp;
*end = tmp + len;
tmp[len - 1] = func;
TRACE("table start %p-%p, %d entries\n", *start, *end, len);
return func;
}
/*
* @implemented
*/
_onexit_t _onexit(_onexit_t a)
{
struct __atexit *ap;
if (a == 0)
if (++len <= 0)
return NULL;
ap = (struct __atexit *)malloc(sizeof(struct __atexit));
if (!ap)
tmp = realloc(*start, len * sizeof(tmp));
if (!tmp)
return NULL;
ap->__next = __atexit_ptr;
ap->__function = (void (*)(void))a;
__atexit_ptr = ap;
return a;
*start = tmp;
*end = tmp + len;
tmp[len - 1] = func;
TRACE("new table start %p-%p, %d entries\n", *start, *end, len);
return func;
}
/*
* @implemented
/*********************************************************************
* _onexit (MSVCRT.@)
*/
int atexit(void (*a)(void))
_onexit_t CDECL _onexit(_onexit_t func)
{
return _onexit((_onexit_t)a) == (_onexit_t)a ? 0 : -1;
TRACE("(%p)\n",func);
if (!func)
return NULL;
LOCK_EXIT;
if (atexit_registered > atexit_table_size - 1)
{
_onexit_t *newtable;
TRACE("expanding table\n");
newtable = calloc(sizeof(void *),atexit_table_size + 32);
if (!newtable)
{
TRACE("failed!\n");
UNLOCK_EXIT;
return NULL;
}
memcpy (newtable, atexit_table, atexit_table_size);
atexit_table_size += 32;
free (atexit_table);
atexit_table = newtable;
}
atexit_table[atexit_registered] = func;
atexit_registered++;
UNLOCK_EXIT;
return func;
}
/*********************************************************************
* atexit (MSVCRT.@)
*/
int CDECL atexit(void (*func)(void))
{
TRACE("(%p)\n", func);
return _onexit((_onexit_t)func) == (_onexit_t)func ? 0 : -1;
}

View file

@ -65,7 +65,7 @@ errno_t CDECL _get_errno(int *pValue)
/*
* @implemented
*/
int CDECL __set_errno(int error)
int CDECL _set_errno(int error)
{
*_errno() = error;
return error;
@ -88,7 +88,7 @@ void CDECL _dosmaperr(unsigned long oserror)
for (base=0, lim=sizeof(doserrmap)/sizeof(doserrmap[0]); lim; lim >>= 1) {
pos = base+(lim >> 1);
if (doserrmap[pos].winerr == oserror) {
__set_errno(doserrmap[pos].en);
_set_errno(doserrmap[pos].en);
return;
} else if (doserrmap[pos].winerr < oserror) {
base = pos + 1;
@ -96,7 +96,7 @@ void CDECL _dosmaperr(unsigned long oserror)
}
}
/* EINVAL appears to be the default */
__set_errno(EINVAL);
_set_errno(EINVAL);
}
/******************************************************************************

View file

@ -21,7 +21,6 @@
#define MK_STR(s) #s
/*
* @implemented
*/
@ -50,3 +49,74 @@ void _tsearchenv(const _TCHAR* file,const _TCHAR* var,_TCHAR* path)
}
return;
}
/*********************************************************************
* _searchenv_s (MSVCRT.@)
*/
int _tsearchenv_s(const _TCHAR* file, const _TCHAR* env, _TCHAR *buf, size_t count)
{
_TCHAR *envVal, *penv;
_TCHAR curPath[MAX_PATH];
if (!MSVCRT_CHECK_PMT(file != NULL) || !MSVCRT_CHECK_PMT(buf != NULL) ||
!MSVCRT_CHECK_PMT(count > 0))
{
*_errno() = EINVAL;
return EINVAL;
}
*buf = '\0';
/* Try CWD first */
if (GetFileAttributes( file ) != INVALID_FILE_ATTRIBUTES)
{
GetFullPathName( file, MAX_PATH, buf, NULL );
_set_errno(GetLastError());
return 0;
}
/* Search given environment variable */
envVal = _tgetenv(env);
if (!envVal)
{
_set_errno(ENOENT);
return ENOENT;
}
penv = envVal;
do
{
_TCHAR *end = penv;
while(*end && *end != ';') end++; /* Find end of next path */
if (penv == end || !*penv)
{
_set_errno(ENOENT);
return ENOENT;
}
memcpy(curPath, penv, (end - penv) * sizeof(_TCHAR));
if (curPath[end - penv] != '/' && curPath[end - penv] != '\\')
{
curPath[end - penv] = '\\';
curPath[end - penv + 1] = '\0';
}
else
curPath[end - penv] = '\0';
_tcscat(curPath, file);
if (GetFileAttributes( curPath ) != INVALID_FILE_ATTRIBUTES)
{
if (_tcslen(curPath) + 1 > count)
{
MSVCRT_INVALID_PMT("buf[count] is too small");
*_errno() = ERANGE;
return ERANGE;
}
_tcscpy(buf, curPath);
return 0;
}
penv = *end ? end + 1 : end;
} while(1);
}

View file

@ -1,5 +1,5 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <stdlib.h>
#include <precomp.h>
/*
* @implemented
@ -9,9 +9,16 @@ long atol(const char *str)
return (long)_atoi64(str);
}
/*
* @unimplemented
*/
int _atoldbl(_LDOUBLE *value, char *str)
{
/* FIXME needs error checking for huge/small values */
//*value = strtold(str,0);
return -1;
/* FIXME needs error checking for huge/small values */
#if 0
long double ld;
ld = strtold(str,0);
memcpy(value, &ld, 10);
#endif
return 0;
}

View file

@ -1,17 +1,9 @@
/*
* 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
*/
/* taken from wine ntdll and msvcrt string.c */
#include <precomp.h>
/*
* @implemented
* copy _i64toa from wine cvs 2006 month 05 day 21
*/
char *
_i64toa(__int64 value, char *string, int radix)
@ -51,10 +43,89 @@ _i64toa(__int64 value, char *string, int radix)
return string;
}
/*
* @implemented
*/
int CDECL _i64toa_s(__int64 value, char *str, size_t size, int radix)
{
unsigned __int64 val;
unsigned int digit;
int is_negative;
char buffer[65], *pos;
size_t len;
if (!MSVCRT_CHECK_PMT(str != NULL) || !MSVCRT_CHECK_PMT(size > 0) ||
!MSVCRT_CHECK_PMT(radix >= 2) || !MSVCRT_CHECK_PMT(radix <= 36))
{
if (str && size)
str[0] = '\0';
#ifndef _LIBCNT_
*_errno() = EINVAL;
#endif
return EINVAL;
}
if (value < 0 && radix == 10)
{
is_negative = 1;
val = -value;
}
else
{
is_negative = 0;
val = value;
}
pos = buffer + 64;
*pos = '\0';
do
{
digit = val % radix;
val /= radix;
if (digit < 10)
*--pos = '0' + digit;
else
*--pos = 'a' + digit - 10;
}
while (val != 0);
if (is_negative)
*--pos = '-';
len = buffer + 65 - pos;
if (len > size)
{
size_t i;
char *p = str;
/* Copy the temporary buffer backwards up to the available number of
* characters. Don't copy the negative sign if present. */
if (is_negative)
{
p++;
size--;
}
for (pos = buffer + 63, i = 0; i < size; i++)
*p++ = *pos--;
str[0] = '\0';
MSVCRT_INVALID_PMT("str[size] is too small");
#ifndef _LIBCNT_
*_errno() = ERANGE;
#endif
return ERANGE;
}
memcpy(str, pos, len);
return 0;
}
/*
* @implemented
* copy _i64toa from wine cvs 2006 month 05 day 21
*/
char *
_ui64toa(unsigned __int64 value, char *string, int radix)
@ -80,6 +151,55 @@ _ui64toa(unsigned __int64 value, char *string, int radix)
return string;
}
/*
* @implemented
*/
int CDECL _ui64toa_s(unsigned __int64 value, char *str,
size_t size, int radix)
{
char buffer[65], *pos;
int digit;
if (!MSVCRT_CHECK_PMT(str != NULL) || !MSVCRT_CHECK_PMT(size > 0) ||
!MSVCRT_CHECK_PMT(radix>=2) || !MSVCRT_CHECK_PMT(radix<=36)) {
#ifndef _LIBCNT_
*_errno() = EINVAL;
#endif
return EINVAL;
}
pos = buffer+64;
*pos = '\0';
do {
digit = value%radix;
value /= radix;
if(digit < 10)
*--pos = '0'+digit;
else
*--pos = 'a'+digit-10;
}while(value != 0);
if((unsigned)(buffer-pos+65) > size) {
MSVCRT_INVALID_PMT("str[size] is too small");
#ifndef _LIBCNT_
*_errno() = EINVAL;
#endif
return EINVAL;
}
memcpy(str, pos, buffer-pos+65);
return 0;
}
/*
* @implemented
*/
int CDECL _itoa_s(int value, char *str, size_t size, int radix)
{
return _ltoa_s(value, str, size, radix);
}
/*
* @implemented
@ -90,7 +210,6 @@ _itoa(int value, char *string, int radix)
return _ltoa(value, string, radix);
}
/*
* @implemented
*/
@ -132,10 +251,90 @@ _ltoa(long value, char *string, int radix)
return string;
}
/*
* @implemented
*/
int CDECL _ltoa_s(long value, char *str, size_t size, int radix)
{
unsigned long val;
unsigned int digit;
int is_negative;
char buffer[33], *pos;
size_t len;
if (!MSVCRT_CHECK_PMT(str != NULL) || !MSVCRT_CHECK_PMT(size > 0) ||
!MSVCRT_CHECK_PMT(radix >= 2) || !MSVCRT_CHECK_PMT(radix <= 36))
{
if (str && size)
str[0] = '\0';
#ifndef _LIBCNT_
*_errno() = EINVAL;
#endif
return EINVAL;
}
if (value < 0 && radix == 10)
{
is_negative = 1;
val = -value;
}
else
{
is_negative = 0;
val = value;
}
pos = buffer + 32;
*pos = '\0';
do
{
digit = val % radix;
val /= radix;
if (digit < 10)
*--pos = '0' + digit;
else
*--pos = 'a' + digit - 10;
}
while (val != 0);
if (is_negative)
*--pos = '-';
len = buffer + 33 - pos;
if (len > size)
{
size_t i;
char *p = str;
/* Copy the temporary buffer backwards up to the available number of
* characters. Don't copy the negative sign if present. */
if (is_negative)
{
p++;
size--;
}
for (pos = buffer + 31, i = 0; i < size; i++)
*p++ = *pos--;
str[0] = '\0';
MSVCRT_INVALID_PMT("str[size] is too small");
#ifndef _LIBCNT_
*_errno() = EINVAL;
#endif
return ERANGE;
}
memcpy(str, pos, len);
return 0;
}
/*
* @implemented
* copy it from wine 0.9.0 with small modifcations do check for NULL
*/
char *
_ultoa(unsigned long value, char *string, int radix)
@ -147,11 +346,6 @@ _ultoa(unsigned long value, char *string, int radix)
pos = &buffer[32];
*pos = '\0';
if (string == NULL)
{
return NULL;
}
do {
digit = value % radix;
value = value / radix;

View file

@ -11,7 +11,6 @@
/*
* @implemented
* from wine cvs 2006-05-21
*/
wchar_t *
_i64tow(__int64 value, wchar_t *string, int radix)
@ -53,6 +52,88 @@ _i64tow(__int64 value, wchar_t *string, int radix)
return string;
}
/*
* @implemented
*/
int
_i64tow_s(__int64 value, wchar_t *str, size_t size, int radix)
{
unsigned __int64 val;
unsigned int digit;
int is_negative;
wchar_t buffer[65], *pos;
size_t len;
if (!MSVCRT_CHECK_PMT(str != NULL) || !MSVCRT_CHECK_PMT(size > 0) ||
!MSVCRT_CHECK_PMT(radix >= 2) || !MSVCRT_CHECK_PMT(radix <= 36))
{
if (str && size)
str[0] = '\0';
#ifndef _LIBCNT_
*_errno() = EINVAL;
#endif
return EINVAL;
}
if (value < 0 && radix == 10)
{
is_negative = 1;
val = -value;
}
else
{
is_negative = 0;
val = value;
}
pos = buffer + 64;
*pos = '\0';
do
{
digit = val % radix;
val /= radix;
if (digit < 10)
*--pos = '0' + digit;
else
*--pos = 'a' + digit - 10;
}
while (val != 0);
if (is_negative)
*--pos = '-';
len = buffer + 65 - pos;
if (len > size)
{
size_t i;
wchar_t *p = str;
/* Copy the temporary buffer backwards up to the available number of
* characters. Don't copy the negative sign if present. */
if (is_negative)
{
p++;
size--;
}
for (pos = buffer + 63, i = 0; i < size; i++)
*p++ = *pos--;
MSVCRT_INVALID_PMT("str[size] is too small");
str[0] = '\0';
#ifndef _LIBCNT_
*_errno() = ERANGE;
#endif
return ERANGE;
}
memcpy(str, pos, len * sizeof(wchar_t));
return 0;
}
/*
* @implemented
@ -83,10 +164,50 @@ _ui64tow(unsigned __int64 value, wchar_t *string, int radix)
return string;
}
/*
* @implemented
*/
int
_ui64tow_s( unsigned __int64 value, wchar_t *str,
size_t size, int radix )
{
wchar_t buffer[65], *pos;
int digit;
if (!MSVCRT_CHECK_PMT(str != NULL) || !MSVCRT_CHECK_PMT(size > 0) ||
!MSVCRT_CHECK_PMT(radix>=2) || !MSVCRT_CHECK_PMT(radix<=36)) {
#ifndef _LIBCNT_
*_errno() = EINVAL;
#endif
return EINVAL;
}
pos = &buffer[64];
*pos = '\0';
do {
digit = value % radix;
value = value / radix;
if (digit < 10)
*--pos = '0' + digit;
else
*--pos = 'a' + digit - 10;
} while (value != 0);
if(buffer-pos+65 > size) {
MSVCRT_INVALID_PMT("str[size] is too small");
#ifndef _LIBCNT_
*_errno() = EINVAL;
#endif
return EINVAL;
}
memcpy(str, pos, buffer-pos+65);
return 0;
}
/*
* @implemented
* from wine cvs 2006-05-21
*/
wchar_t *
_itow(int value, wchar_t *string, int radix)
@ -94,10 +215,17 @@ _itow(int value, wchar_t *string, int radix)
return _ltow(value, string, radix);
}
/*
* @implemented
*/
int
_itow_s(int value, wchar_t *str, size_t size, int radix)
{
return _ltow_s(value, str, size, radix);
}
/*
* @implemented
* from wine cvs 2006-05-21
*/
wchar_t *
_ltow(long value, wchar_t *string, int radix)
@ -139,10 +267,91 @@ _ltow(long value, wchar_t *string, int radix)
return string;
}
/*
* @implemented
*/
int
_ltow_s(long value, wchar_t *str, size_t size, int radix)
{
unsigned long val;
unsigned int digit;
int is_negative;
wchar_t buffer[33], *pos;
size_t len;
if (!MSVCRT_CHECK_PMT(str != NULL) || !MSVCRT_CHECK_PMT(size > 0) ||
!MSVCRT_CHECK_PMT(radix >= 2) || !MSVCRT_CHECK_PMT(radix <= 36))
{
if (str && size)
str[0] = '\0';
#ifndef _LIBCNT_
*_errno() = EINVAL;
#endif
return EINVAL;
}
if (value < 0 && radix == 10)
{
is_negative = 1;
val = -value;
}
else
{
is_negative = 0;
val = value;
}
pos = buffer + 32;
*pos = '\0';
do
{
digit = val % radix;
val /= radix;
if (digit < 10)
*--pos = '0' + digit;
else
*--pos = 'a' + digit - 10;
}
while (val != 0);
if (is_negative)
*--pos = '-';
len = buffer + 33 - pos;
if (len > size)
{
size_t i;
wchar_t *p = str;
/* Copy the temporary buffer backwards up to the available number of
* characters. Don't copy the negative sign if present. */
if (is_negative)
{
p++;
size--;
}
for (pos = buffer + 31, i = 0; i < size; i++)
*p++ = *pos--;
MSVCRT_INVALID_PMT("str[size] is too small");
str[0] = '\0';
#ifndef _LIBCNT_
*_errno() = ERANGE;
#endif
return ERANGE;
}
memcpy(str, pos, len * sizeof(wchar_t));
return 0;
}
/*
* @implemented
* from wine cvs 2006-05-21
*/
wchar_t *
_ultow(unsigned long value, wchar_t *string, int radix)

View file

@ -26,7 +26,7 @@ void _tsplitpath(const _TCHAR* path, _TCHAR* drive, _TCHAR* dir, _TCHAR* fname,
if (!path)
{
#ifndef _LIBCNT_
__set_errno(EINVAL);
_set_errno(EINVAL);
#endif
return;
}

View file

@ -1,4 +1,23 @@
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
/*
* msvcrt.dll errno functions
*
* Copyright 2000 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <precomp.h>
char __syserr00[] = "No Error";
@ -45,9 +64,6 @@ char __syserr40[] = "Function not implemented (ENOSYS)";
char __syserr41[] = "Directory not empty (ENOTEMPTY)";
char __syserr42[] = "Illegal byte sequence (EILSEQ)";
char *_sys_errlist[] = {
__syserr00, __syserr01, __syserr02, __syserr03, __syserr04,
__syserr05, __syserr06, __syserr07, __syserr08, __syserr09,
@ -60,52 +76,164 @@ __syserr35, __syserr36, __syserr37, __syserr38, __syserr39,
__syserr40, __syserr41, __syserr42
};
//int __sys_nerr = sizeof(_sys_errlist) / sizeof(_sys_errlist[0]);
int _sys_nerr = sizeof(_sys_errlist) / sizeof(_sys_errlist[0]) - 1;
int/***/ _sys_nerr = sizeof(_sys_errlist) / sizeof(_sys_errlist[0]);//&__sys_nerr;
/*
* @implemented
/*********************************************************************
* strerror (MSVCRT.@)
*/
char *strerror(int errnum)
char* CDECL strerror(int err)
{
static char ebuf[40]; /* 64-bit number + slop */
char *cp;
int v=1000000, lz=0;
thread_data_t *data = msvcrt_get_thread_data();
if (errnum >= 0 && errnum < _sys_nerr)
return((char *)_sys_errlist[errnum]);
if (!data->strerror_buffer)
if (!(data->strerror_buffer = malloc(256))) return NULL;
strcpy(ebuf, "Unknown error: ");
cp = ebuf + 15;
if (errnum < 0)
{
*cp++ = '-';
errnum = -errnum;
}
while (v)
{
int d = errnum / v;
if (d || lz || (v == 1))
if (err < 0 || err > _sys_nerr) err = _sys_nerr;
strcpy( data->strerror_buffer, _sys_errlist[err] );
return data->strerror_buffer;
}
/**********************************************************************
* strerror_s (MSVCRT.@)
*/
int CDECL strerror_s(char *buffer, size_t numberOfElements, int errnum)
{
char *ptr;
if (!buffer || !numberOfElements)
{
*cp++ = d+'0';
lz = 1;
*_errno() = EINVAL;
return EINVAL;
}
errnum %= v;
v /= 10;
}
return ebuf;
if (errnum < 0 || errnum > _sys_nerr)
errnum = _sys_nerr;
ptr = _sys_errlist[errnum];
while (*ptr && numberOfElements > 1)
{
*buffer++ = *ptr++;
numberOfElements--;
}
*buffer = '\0';
return 0;
}
/*
* @implemented
/**********************************************************************
* _strerror (MSVCRT.@)
*/
char *_strerror(const char *s)
char* CDECL _strerror(const char* str)
{
if ( s == NULL )
return strerror(*_errno());
thread_data_t *data = msvcrt_get_thread_data();
int err;
return strerror(atoi(s));
if (!data->strerror_buffer)
if (!(data->strerror_buffer = malloc(256))) return NULL;
err = data->thread_errno;
if (err < 0 || err > _sys_nerr) err = _sys_nerr;
if (str && *str)
sprintf( data->strerror_buffer, "%s: %s\n", str, _sys_errlist[err] );
else
sprintf( data->strerror_buffer, "%s\n", _sys_errlist[err] );
return data->strerror_buffer;
}
/*********************************************************************
* perror (MSVCRT.@)
*/
void CDECL perror(const char* str)
{
int err = *_errno();
if (err < 0 || err > _sys_nerr) err = _sys_nerr;
if (str && *str)
{
_write( 2, str, strlen(str) );
_write( 2, ": ", 2 );
}
_write( 2, _sys_errlist[err], strlen(_sys_errlist[err]) );
_write( 2, "\n", 1 );
}
/*********************************************************************
* _wcserror_s (MSVCRT.@)
*/
int CDECL _wcserror_s(wchar_t* buffer, size_t nc, int err)
{
if (!MSVCRT_CHECK_PMT(buffer != NULL) || !MSVCRT_CHECK_PMT(nc > 0))
{
_set_errno(EINVAL);
return EINVAL;
}
if (err < 0 || err > _sys_nerr) err = _sys_nerr;
MultiByteToWideChar(CP_ACP, 0, _sys_errlist[err], -1, buffer, nc);
return 0;
}
/*********************************************************************
* _wcserror (MSVCRT.@)
*/
wchar_t* CDECL _wcserror(int err)
{
thread_data_t *data = msvcrt_get_thread_data();
if (!data->wcserror_buffer)
if (!(data->wcserror_buffer = malloc(256 * sizeof(wchar_t)))) return NULL;
_wcserror_s(data->wcserror_buffer, 256, err);
return data->wcserror_buffer;
}
/**********************************************************************
* __wcserror_s (MSVCRT.@)
*/
int CDECL __wcserror_s(wchar_t* buffer, size_t nc, const wchar_t* str)
{
int err;
static const WCHAR colonW[] = {':', ' ', '\0'};
static const WCHAR nlW[] = {'\n', '\0'};
size_t len;
err = *_errno();
if (err < 0 || err > _sys_nerr) err = _sys_nerr;
len = MultiByteToWideChar(CP_ACP, 0, _sys_errlist[err], -1, NULL, 0) + 1 /* \n */;
if (str && *str) len += lstrlenW(str) + 2 /* ': ' */;
if (len > nc)
{
MSVCRT_INVALID_PMT("buffer[nc] is too small");
_set_errno(ERANGE);
return ERANGE;
}
if (str && *str)
{
lstrcpyW(buffer, str);
lstrcatW(buffer, colonW);
}
else buffer[0] = '\0';
len = lstrlenW(buffer);
MultiByteToWideChar(CP_ACP, 0, _sys_errlist[err], -1, buffer + len, 256 - len);
lstrcatW(buffer, nlW);
return 0;
}
/**********************************************************************
* __wcserror (MSVCRT.@)
*/
wchar_t* CDECL __wcserror(const wchar_t* str)
{
thread_data_t *data = msvcrt_get_thread_data();
int err;
if (!data->wcserror_buffer)
if (!(data->wcserror_buffer = malloc(256 * sizeof(wchar_t)))) return NULL;
err = __wcserror_s(data->wcserror_buffer, 256, str);
if (err) FIXME("bad wcserror call (%d)\n", err);
return data->wcserror_buffer;
}

View file

@ -22,3 +22,31 @@ char * CDECL strtok( char *str, const char *delim )
data->strtok_next = str;
return ret;
}
/*********************************************************************
* strtok_s (MSVCRT.@)
*/
char * CDECL strtok_s(char *str, const char *delim, char **ctx)
{
if (!MSVCRT_CHECK_PMT(delim != NULL) || !MSVCRT_CHECK_PMT(ctx != NULL) ||
!MSVCRT_CHECK_PMT(str != NULL || *ctx != NULL)) {
*_errno() = EINVAL;
return NULL;
}
if(!str)
str = *ctx;
while(*str && strchr(delim, *str))
str++;
if(!*str)
return NULL;
*ctx = str+1;
while(**ctx && !strchr(delim, **ctx))
(*ctx)++;
if(**ctx)
*(*ctx)++ = 0;
return str;
}

View file

@ -80,7 +80,7 @@ strtol(const char *nptr, char **endptr, int base)
{
acc = neg ? LONG_MIN : LONG_MAX;
#ifndef _LIBCNT_
__set_errno(ERANGE);
_set_errno(ERANGE);
#endif
}
else if (neg)

View file

@ -64,7 +64,7 @@ strtoul(const char *nptr, char **endptr, int base)
{
acc = ULONG_MAX;
#ifndef _LIBCNT_
__set_errno(ERANGE);
_set_errno(ERANGE);
#endif
}
else if (neg)

View file

@ -55,7 +55,7 @@ strtoull(const char *nptr, char **endptr, int base)
{
acc = ULLONG_MAX;
#ifndef _LIBCNT_
__set_errno(ERANGE);
_set_errno(ERANGE);
#endif
}
else if (neg)

View file

@ -35,11 +35,6 @@
#endif
#include "wine/unicode.h"
//#include "wine/debug.h"
//WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
#undef sprintf
#undef wsprintf
#undef snprintf
@ -124,7 +119,7 @@ INT CDECL _wcsupr_s( wchar_t* str, size_t n )
if (!str || !n)
{
if (str) *str = '\0';
__set_errno(EINVAL);
_set_errno(EINVAL);
return EINVAL;
}
@ -138,7 +133,7 @@ INT CDECL _wcsupr_s( wchar_t* str, size_t n )
/* MSDN claims that the function should return and set errno to
* ERANGE, which doesn't seem to be true based on the tests. */
*str = '\0';
__set_errno(EINVAL);
_set_errno(EINVAL);
return EINVAL;
}
@ -266,7 +261,7 @@ INT CDECL wctomb(char *mbchar, wchar_t wchar)
/* If the default character was used, set errno to EILSEQ and return -1. */
if(bUsedDefaultChar)
{
__set_errno(EILSEQ);
_set_errno(EILSEQ);
return -1;
}
@ -422,4 +417,85 @@ INT CDECL wcsncpy_s( wchar_t* wcDest, size_t numElement, const wchar_t *wcSrc,
return 0;
}
/******************************************************************
* wcscat_s (MSVCRT.@)
*
*/
INT CDECL wcscat_s(wchar_t* dst, size_t elem, const wchar_t* src)
{
wchar_t* ptr = dst;
if (!dst || elem == 0) return EINVAL;
if (!src)
{
dst[0] = '\0';
return EINVAL;
}
/* seek to end of dst string (or elem if no end of string is found */
while (ptr < dst + elem && *ptr != '\0') ptr++;
while (ptr < dst + elem)
{
if ((*ptr++ = *src++) == '\0') return 0;
}
/* not enough space */
dst[0] = '\0';
return ERANGE;
}
/*********************************************************************
* wcsncat_s (MSVCRT.@)
*
*/
INT CDECL wcsncat_s(wchar_t *dst, size_t elem,
const wchar_t *src, size_t count)
{
size_t srclen;
wchar_t dststart;
INT ret = 0;
if (!MSVCRT_CHECK_PMT(dst != NULL) || !MSVCRT_CHECK_PMT(elem > 0))
{
#ifndef _LIBCNT_
_set_errno(EINVAL);
#endif
return EINVAL;
}
if (!MSVCRT_CHECK_PMT(src != NULL || count == 0))
return EINVAL;
if (count == 0)
return 0;
for (dststart = 0; dststart < elem; dststart++)
{
if (dst[dststart] == '\0')
break;
}
if (dststart == elem)
{
MSVCRT_INVALID_PMT("dst[elem] is not NULL terminated\n");
return EINVAL;
}
if (count == _TRUNCATE)
{
srclen = strlenW(src);
if (srclen >= (elem - dststart))
{
srclen = elem - dststart - 1;
ret = STRUNCATE;
}
}
else
srclen = min(strlenW(src), count);
if (srclen < (elem - dststart))
{
memcpy(&dst[dststart], src, srclen*sizeof(wchar_t));
dst[dststart+srclen] = '\0';
return ret;
}
MSVCRT_INVALID_PMT("dst[elem] is too small");
dst[0] = '\0';
return ERANGE;
}

View file

@ -16,7 +16,7 @@ long
wcstol(const wchar_t *nptr, wchar_t **endptr, int base)
{
const wchar_t *s = nptr;
unsigned long acc;
long acc;
int c;
unsigned long cutoff;
int neg = 0, any, cutlim;
@ -76,7 +76,7 @@ wcstol(const wchar_t *nptr, wchar_t **endptr, int base)
break;
if (c >= base)
break;
if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
if (any < 0 || (unsigned long)acc > cutoff || (acc == cutoff && c > cutlim))
any = -1;
else
{

View file

@ -27,7 +27,7 @@ wchar_t* _i64tow(__int64 value, wchar_t* string, int radix)
wchar_t* sp;
if (radix > 36 || radix <= 1) {
__set_errno(EDOM);
_set_errno(EDOM);
return 0;
}
@ -69,7 +69,7 @@ wchar_t* _ui64tow(unsigned __int64 value, wchar_t* string, int radix)
wchar_t* sp;
if (radix > 36 || radix <= 1) {
__set_errno(EDOM);
_set_errno(EDOM);
return 0;
}

View file

@ -6,7 +6,7 @@
* PROGRAMERS: Timo Kreuzer
*/
#if defined(_USE_EXPLITIT_32BIT_TIME) || defined(_USE_EXPLITIT_64BIT_TIME)
#if defined(_USE_EXPLICIT_32BIT_TIME) || defined(_USE_EXPLICIT_64BIT_TIME)
#undef _timeb
#undef _ftime
#undef _tctime
@ -17,7 +17,7 @@
#define _time time
#endif
#ifdef _USE_EXPLITIT_32BIT_TIME
#ifdef _USE_EXPLICIT_32BIT_TIME
#define time_t __time32_t
#define _timeb __timeb32
#define _utimbuf __utimbuf32
@ -37,7 +37,7 @@
#endif
#ifdef _USE_EXPLITIT_64BIT_TIME
#ifdef _USE_EXPLICIT_64BIT_TIME
#define time_t __time64_t
#define _timeb __timeb64
#define _utimbuf __utimbuf64

View file

@ -5,5 +5,5 @@
* PURPOSE: Implementation of _ctime32()
* PROGRAMERS: Timo Kreuzer
*/
#define _USE_EXPLITIT_32BIT_TIME
#define _USE_EXPLICIT_32BIT_TIME
#include "ctime.c"

View file

@ -5,5 +5,5 @@
* PURPOSE: Implementation of _ctime64
* PROGRAMERS: Timo Kreuzer
*/
#define _USE_EXPLITIT_64BIT_TIME
#define _USE_EXPLICIT_64BIT_TIME
#include "ctime.c"

View file

@ -5,5 +5,5 @@
* PURPOSE: Implementation of _difftime32
* PROGRAMERS: Timo Kreuzer
*/
#define _USE_EXPLITIT_32BIT_TIME
#define _USE_EXPLICIT_32BIT_TIME
#include "difftime.c"

View file

@ -5,5 +5,5 @@
* PURPOSE: Implementation of _difftime64
* PROGRAMERS: Timo Kreuzer
*/
#define _USE_EXPLITIT_64BIT_TIME
#define _USE_EXPLICIT_64BIT_TIME
#include "difftime.c"

View file

@ -6,7 +6,6 @@
* PROGRAMERS: Timo Kreuzer
*/
#include <precomp.h>
#include <sec_api/time_s.h>
#include <sys/timeb.h>
#include "bitsfixup.h"
@ -18,6 +17,7 @@
* \sa http://msdn.microsoft.com/en-us/library/95e68951.aspx
*/
errno_t
CDECL
_ftime_s(struct _timeb *ptimeb)
{
DWORD ret;
@ -25,15 +25,9 @@ _ftime_s(struct _timeb *ptimeb)
FILETIME SystemTime;
/* Validate parameters */
if (!ptimeb)
if (!MSVCRT_CHECK_PMT( ptimeb != NULL ))
{
#if 0
_invalid_parameter(0,
0,//__FUNCTION__,
_CRT_WIDE(__FILE__),
__LINE__,
0);
#endif
*_errno() = EINVAL;
return EINVAL;
}
@ -57,6 +51,7 @@ _ftime_s(struct _timeb *ptimeb)
* \sa http://msdn.microsoft.com/en-us/library/z54t9z5f.aspx
*/
void
CDECL
_ftime(struct _timeb *ptimeb)
{
_ftime_s(ptimeb);

View file

@ -5,5 +5,5 @@
* PURPOSE: Implementation of _ftime32
* PROGRAMERS: Timo Kreuzer
*/
#define _USE_EXPLITIT_32BIT_TIME
#define _USE_EXPLICIT_32BIT_TIME
#include "ftime.c"

View file

@ -5,5 +5,5 @@
* PURPOSE: Implementation of _ftime64
* PROGRAMERS: Timo Kreuzer
*/
#define _USE_EXPLITIT_64BIT_TIME
#define _USE_EXPLICIT_64BIT_TIME
#include "ftime.c"

View file

@ -86,7 +86,7 @@ _futime(int fd, struct _utimbuf *filetime)
if (!SetFileTime(handle, NULL, &at, &wt))
{
__set_errno(GetLastError());
_set_errno(GetLastError());
return -1 ;
}

View file

@ -5,5 +5,5 @@
* PURPOSE: Implementation of _futime32
* PROGRAMERS: Timo Kreuzer
*/
#define _USE_EXPLITIT_32BIT_TIME
#define _USE_EXPLICIT_32BIT_TIME
#include "futime.c"

View file

@ -5,5 +5,5 @@
* PURPOSE: Implementation of _futime64
* PROGRAMERS: Timo Kreuzer
*/
#define _USE_EXPLITIT_64BIT_TIME
#define _USE_EXPLICIT_64BIT_TIME
#include "futime.c"

View file

@ -118,6 +118,31 @@ _gmtime64(const __time64_t * ptime)
return _gmtime_worker(data->time_buffer, *ptime, 0);
}
errno_t
_gmtime64_s(
struct tm* ptm,
const __time64_t* ptime)
{
__time64_t time = *ptime;
if (!ptm)
{
_set_errno(ERROR_BAD_COMMAND);
MSVCRT_INVALID_PMT("ptm == NULL");
return ERROR_BAD_COMMAND;
}
if (!ptime)
{
_set_errno(ERROR_BAD_COMMAND);
MSVCRT_INVALID_PMT("ptime == NULL");
return ERROR_BAD_COMMAND;
}
_gmtime_worker(ptm, time, 0);
return ERROR_SUCCESS;
}
/******************************************************************************
* \name _gmtime32
* \brief
@ -134,6 +159,31 @@ _gmtime32(const __time32_t * ptime)
return _gmtime64(&time64);
}
errno_t
_gmtime32_s(
struct tm* ptm,
const __time32_t* ptime)
{
__time64_t time = *ptime;
if (!ptm)
{
_set_errno(ERROR_BAD_COMMAND);
MSVCRT_INVALID_PMT("ptm == NULL");
return ERROR_BAD_COMMAND;
}
if (!ptime)
{
_set_errno(ERROR_BAD_COMMAND);
MSVCRT_INVALID_PMT("ptime == NULL");
return ERROR_BAD_COMMAND;
}
_gmtime_worker(ptm, time, 0);
return ERROR_SUCCESS;
}
/******************************************************************************
* \name gmtime
* \brief

View file

@ -4,29 +4,41 @@
* FILE: lib/sdk/crt/time/localtime.c
* PURPOSE: Implementation of localtime, localtime_s
* PROGRAMERS: Timo Kreuzer
* Samuel Serapión
*/
#include <precomp.h>
#include <time.h>
#include "bitsfixup.h"
//fix me: header?
#define _MAX__TIME64_T 0x793406fffLL /* number of seconds from
00:00:00, 01/01/1970 UTC to
23:59:59. 12/31/3000 UTC */
errno_t
localtime_s(struct tm* _tm, const time_t *ptime)
{
/* Validate parameters */
if (!_tm || !ptime)
/* check for NULL */
if (!_tm || !ptime )
{
#if 0
if(_tm) memset(_tm, 0xFF, sizeof(struct tm));
_invalid_parameter(NULL,
0,//__FUNCTION__,
_CRT_WIDE(__FILE__),
__LINE__,
0);
#endif
return EINVAL;
}
/* Validate input */
if (*ptime < 0 || *ptime > _MAX__TIME64_T)
{
memset(_tm, 0xFF, sizeof(struct tm));
return EINVAL;
}
_tm = localtime(ptime);
return 0;
}

View file

@ -5,5 +5,5 @@
* PURPOSE: Implementation of _localtime32
* PROGRAMERS: Timo Kreuzer
*/
#define _USE_EXPLITIT_32BIT_TIME
#define _USE_EXPLICIT_32BIT_TIME
#include "localtime.c"

View file

@ -5,5 +5,5 @@
* PURPOSE: Implementation of _localtime64
* PROGRAMERS: Timo Kreuzer
*/
#define _USE_EXPLITIT_64BIT_TIME
#define _USE_EXPLICIT_64BIT_TIME
#include "localtime.c"

View file

@ -21,3 +21,25 @@ char* _strdate(char* date)
return date;
}
/*
* @implemented
*/
int CDECL _strdate_s(char* date, size_t size)
{
if(date && size)
date[0] = '\0';
if(!date) {
*_errno() = EINVAL;
return EINVAL;
}
if(size < 9) {
*_errno() = ERANGE;
return ERANGE;
}
_strdate(date);
return 0;
}

View file

@ -20,3 +20,22 @@ char* _strtime(char* time)
return time;
}
int CDECL _strtime_s(char* time, size_t size)
{
if(time && size)
time[0] = '\0';
if(!time) {
*_errno() = EINVAL;
return EINVAL;
}
if(size < 9) {
*_errno() = ERANGE;
return ERANGE;
}
_strtime(time);
return 0;
}

View file

@ -6,5 +6,5 @@
* PROGRAMER:
*/
#define _USE_EXPLITIT_32BIT_TIME
#define _USE_EXPLICIT_32BIT_TIME
#include "time.c"

View file

@ -6,5 +6,5 @@
* PROGRAMER:
*/
#define _USE_EXPLITIT_64BIT_TIME
#define _USE_EXPLICIT_64BIT_TIME
#include "time.c"

View file

@ -27,7 +27,7 @@ char * _tzname[2] = {
/******************************************************************************
* \var _daylight
*/
int _daylight = 1;
int _daylight = 0;
/******************************************************************************
* \name __p__daylight
@ -214,3 +214,36 @@ _tzset(void)
_tz_is_set = 1;
}
/*********************************************************************
* _get_tzname (MSVCRT.@)
*/
int CDECL _get_tzname(size_t *ret, char *buf, size_t bufsize, int index)
{
char *timezone;
switch(index)
{
case 0:
timezone = tz_name;
break;
case 1:
timezone = tz_dst_name;
break;
default:
*_errno() = EINVAL;
return EINVAL;
}
if(!ret || (!buf && bufsize > 0) || (buf && !bufsize))
{
*_errno() = EINVAL;
return EINVAL;
}
*ret = strlen(timezone)+1;
if(!buf && !bufsize)
return 0;
strcpy(buf, timezone);
return 0;
}

View file

@ -1,9 +0,0 @@
/*
* COPYRIGHT: LGPL, See LGPL.txt in the top level directory
* PROJECT: ReactOS CRT library
* FILE: lib/sdk/crt/time/ctime.c
* PURPOSE: Implementation of ctime
* PROGRAMERS: Timo Kreuzer
*/
#include <precomp.h>

View file

@ -6,5 +6,5 @@
* PROGRAMERS: Timo Kreuzer
*/
#define _USE_EXPLITIT_32BIT_TIME
#define _USE_EXPLICIT_32BIT_TIME
#include "utime.c"

View file

@ -5,5 +5,5 @@
* PURPOSE: Implementation of _utime64
* PROGRAMERS: Timo Kreuzer
*/
#define _USE_EXPLITIT_64BIT_TIME
#define _USE_EXPLICIT_64BIT_TIME
#include "utime.c"

View file

@ -8,5 +8,5 @@
#define UNICODE
#define _UNICODE
#define _USE_EXPLITIT_32BIT_TIME
#define _USE_EXPLICIT_32BIT_TIME
#include "ctime.c"

View file

@ -8,5 +8,5 @@
#define UNICODE
#define _UNICODE
#define _USE_EXPLITIT_64BIT_TIME
#define _USE_EXPLICIT_64BIT_TIME
#include "ctime.c"

View file

@ -21,3 +21,22 @@ wchar_t* _wstrdate(wchar_t* date)
return date;
}
int CDECL _wstrdate_s(wchar_t* date, size_t size)
{
if(date && size)
date[0] = '\0';
if(!date) {
*_errno() = EINVAL;
return EINVAL;
}
if(size < 9) {
*_errno() = ERANGE;
return ERANGE;
}
_wstrdate(date);
return 0;
}

View file

@ -8,5 +8,5 @@
#define UNICODE
#define _UNICODE
#define _USE_EXPLITIT_32BIT_TIME
#define _USE_EXPLICIT_32BIT_TIME
#include "utime.c"

View file

@ -8,5 +8,5 @@
#define UNICODE
#define _UNICODE
#define _USE_EXPLITIT_64BIT_TIME
#define _USE_EXPLICIT_64BIT_TIME
#include "utime.c"

View file

@ -173,7 +173,7 @@ int CDECL _heapchk(void)
{
if (!HeapValidate( GetProcessHeap(), 0, NULL))
{
__set_errno(GetLastError());
_set_errno(GetLastError());
return _HEAPBADNODE;
}
return _HEAPOK;
@ -187,7 +187,7 @@ int CDECL _heapmin(void)
if (!HeapCompact( GetProcessHeap(), 0 ))
{
if (GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
__set_errno(GetLastError());
_set_errno(GetLastError());
return -1;
}
return 0;
@ -209,7 +209,7 @@ int CDECL _heapwalk(_HEAPINFO* next)
!HeapValidate( GetProcessHeap(), 0, phe.lpData ))
{
UNLOCK_HEAP;
__set_errno(GetLastError());
_set_errno(GetLastError());
return _HEAPBADNODE;
}
@ -220,7 +220,7 @@ int CDECL _heapwalk(_HEAPINFO* next)
UNLOCK_HEAP;
if (GetLastError() == ERROR_NO_MORE_ITEMS)
return _HEAPEND;
__set_errno(GetLastError());
_set_errno(GetLastError());
if (!phe.lpData)
return _HEAPBADBEGIN;
return _HEAPBADNODE;
@ -583,8 +583,8 @@ int CDECL strncpy_s(char *dest, size_t numberOfElements,
if(!count)
return 0;
if(!dest || !src || !numberOfElements) {
_invalid_parameter(NULL, NULL, NULL, 0, 0);
if (!MSVCRT_CHECK_PMT(dest != NULL) || !MSVCRT_CHECK_PMT(src != NULL) ||
!MSVCRT_CHECK_PMT(numberOfElements != 0)) {
*_errno() = EINVAL;
return EINVAL;
}
@ -602,7 +602,7 @@ int CDECL strncpy_s(char *dest, size_t numberOfElements,
return 0;
}
_invalid_parameter(NULL, NULL, NULL, 0, 0);
MSVCRT_INVALID_PMT("dest[numberOfElements] is too small");
dest[0] = '\0';
*_errno() = EINVAL;
return EINVAL;

View file

@ -10,14 +10,12 @@ wchar_t * CDECL wcstok_s( wchar_t *str, const wchar_t *delim,
{
wchar_t *ret;
#if 0
if (!MSVCRT_CHECK_PMT(delim != NULL) || !MSVCRT_CHECK_PMT(next_token != NULL) ||
!MSVCRT_CHECK_PMT(str != NULL || *next_token != NULL))
{
_set_errno(EINVAL);
return NULL;
}
#endif
if (!str) str = *next_token;
while (*str && strchrW( delim, *str )) str++;