Skip to content

Commit

Permalink
[CRT] Consistently move the "secure" *_s functions and defines into t…
Browse files Browse the repository at this point in the history
…he *_s.h headers (reactos#5948)
  • Loading branch information
HBelusca committed Nov 11, 2023
1 parent ee11747 commit bead5e0
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 261 deletions.
33 changes: 33 additions & 0 deletions sdk/include/crt/sec_api/string_s.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ extern "C" {
_In_ size_t _Size,
_In_opt_ _locale_t _Locale);

_Check_return_wat_
_CRTIMP
errno_t
__cdecl
strcat_s(
_Inout_updates_z_(_Size) char *_Dst,
_In_ size_t _Size,
_In_z_ const char *_Src);

_Check_return_wat_
_CRTIMP
errno_t
Expand Down Expand Up @@ -150,6 +159,30 @@ extern "C" {
#ifndef _WSTRING_S_DEFINED
#define _WSTRING_S_DEFINED

_CRTIMP
errno_t
__cdecl
wcscat_s(
wchar_t *Dest,
size_t SizeInWords,
const wchar_t *_Source);

_Check_return_wat_
_CRTIMP
errno_t
__cdecl
wcscpy_s(
_Out_writes_z_(SizeInWords) wchar_t *Dest,
_In_ size_t SizeInWords,
_In_z_ const wchar_t *_Source);

_CRTIMP
errno_t
__cdecl
wcsnlen_s(
wchar_t **_Src,
size_t _MaxCount);

_Check_return_
_CRTIMP
wchar_t *
Expand Down
17 changes: 16 additions & 1 deletion sdk/include/crt/sec_api/wchar_s.h
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,17 @@ extern "C" {
_In_z_ const wchar_t *_Mode,
_Inout_ FILE *_OldFile);

_Check_return_wat_
_CRTIMP
errno_t
__cdecl
_wsopen_s(
_Out_ int *_FileHandle,
_In_z_ const wchar_t *_Filename,
_In_ int _OpenFlag,
_In_ int _ShareFlag,
_In_ int _PermissionFlag);

_Check_return_wat_
_CRTIMP
errno_t
Expand Down Expand Up @@ -643,7 +654,7 @@ extern "C" {
__cdecl
_wstrdate_s(
_Out_writes_(_SizeInWords) _Post_readable_size_(9) wchar_t *_Buf,
_In_range_(>= , 9) size_t _SizeInWords);
_In_range_(>=, 9) size_t _SizeInWords);

_CRTIMP
errno_t
Expand All @@ -652,6 +663,8 @@ extern "C" {
_Out_writes_(_SizeInWords) _Post_readable_size_(9) wchar_t *_Buf,
_In_ size_t _SizeInWords);

#if _INTEGRAL_MAX_BITS >= 64

_CRTIMP
errno_t
__cdecl
Expand All @@ -660,6 +673,8 @@ extern "C" {
_In_ size_t _SizeInWords,
_In_ const __time64_t *_Time);

#endif /* _INTEGRAL_MAX_BITS >= 64 */

#if !defined (RC_INVOKED) && !defined (_INC_WTIME_S_INL)
#define _INC_WTIME_S_INL
errno_t __cdecl _wctime_s(wchar_t *, size_t, const time_t *);
Expand Down
196 changes: 3 additions & 193 deletions sdk/include/crt/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -446,90 +446,6 @@ extern "C" {
_In_ size_t _MaxCount,
_In_opt_ _locale_t _Locale);

#if __STDC_WANT_SECURE_LIB__

_Check_return_wat_
_CRTIMP
errno_t
__cdecl
_strset_s(
_Inout_updates_z_(_DstSize) char *_Dst,
_In_ size_t _DstSize,
_In_ int _Value);

_Check_return_wat_
_CRTIMP
errno_t
__cdecl
_strerror_s(
_Out_writes_z_(_SizeInBytes) char *_Buf,
_In_ size_t _SizeInBytes,
_In_opt_z_ const char *_ErrMsg);

_Check_return_wat_
_CRTIMP
errno_t
__cdecl
_strlwr_s(
_Inout_updates_z_(_Size) char *_Str,
_In_ size_t _Size);

_Check_return_wat_
_CRTIMP
errno_t
__cdecl
_strlwr_s_l(
_Inout_updates_z_(_Size) char *_Str,
_In_ size_t _Size,
_In_opt_ _locale_t _Locale);

_Check_return_wat_
_CRTIMP
errno_t
__cdecl
_strnset_s(
_Inout_updates_z_(_Size) char *_Str,
_In_ size_t _Size,
_In_ int _Val,
_In_ size_t _MaxCount);

_Check_return_wat_
_CRTIMP
errno_t
__cdecl
_strupr_s(
_Inout_updates_z_(_Size) char *_Str,
_In_ size_t _Size);

_Check_return_wat_
_CRTIMP
errno_t
__cdecl
_strupr_s_l(
_Inout_updates_z_(_Size) char *_Str,
_In_ size_t _Size,
_In_opt_ _locale_t _Locale);

_Check_return_wat_
_CRTIMP
errno_t
__cdecl
strcpy_s(
_Out_writes_z_(_Size) char *_Dst,
_In_ size_t _Size,
_In_z_ const char *_Src);

_Check_return_wat_
_CRTIMP
errno_t
__cdecl
strcat_s(
_Inout_updates_z_(_Size) char *_Dst,
_In_ size_t _Size,
_In_z_ const char *_Src);

#endif /* __STDC_WANT_SECURE_LIB__ */

#ifndef NO_OLDNAMES

_Check_return_
Expand Down Expand Up @@ -943,115 +859,6 @@ extern "C" {
_In_ size_t _MaxCount,
_In_opt_ _locale_t _Locale);

#if __STDC_WANT_SECURE_LIB__

_CRTIMP
errno_t
__cdecl
wcscat_s(
wchar_t *Dest,
size_t SizeInWords,
const wchar_t *_Source);

_Check_return_wat_
_CRTIMP
errno_t
__cdecl
wcscpy_s(
_Out_writes_z_(SizeInWords) wchar_t *Dest,
_In_ size_t SizeInWords,
_In_z_ const wchar_t *_Source);

_CRTIMP
errno_t
__cdecl
wcsnlen_s(
wchar_t **_Src,
size_t _MaxCount);

_Check_return_wat_
_CRTIMP
errno_t
__cdecl
wcsncpy_s(
_Out_writes_z_(_DstSizeInChars) wchar_t *_Dst,
_In_ size_t _DstSizeInChars,
_In_z_ const wchar_t *_Src,
_In_ size_t _MaxCount);

_Check_return_wat_
_CRTIMP
errno_t
__cdecl
_wcserror_s(
_Out_writes_opt_z_(_SizeInWords) wchar_t *_Buf,
_In_ size_t _SizeInWords,
_In_ int _ErrNum);

_Check_return_wat_
_CRTIMP
errno_t
__cdecl
__wcserror_s(
_Out_writes_opt_z_(_SizeInWords) wchar_t *_Buffer,
_In_ size_t _SizeInWords,
_In_z_ const wchar_t *_ErrMsg);

_Check_return_wat_
_CRTIMP
errno_t
__cdecl
_wcsnset_s(
_Inout_updates_z_(_DstSizeInWords) wchar_t *_Dst,
_In_ size_t _DstSizeInWords,
_In_ wchar_t _Val,
_In_ size_t _MaxCount);

_Check_return_wat_
_CRTIMP
errno_t
__cdecl
_wcsset_s(
_Inout_updates_z_(_SizeInWords) wchar_t *_Str,
_In_ size_t _SizeInWords,
_In_ wchar_t _Val);

_Check_return_wat_
_CRTIMP
errno_t
__cdecl
_wcslwr_s(
_Inout_updates_z_(_SizeInWords) wchar_t *_Str,
_In_ size_t _SizeInWords);

_Check_return_wat_
_CRTIMP
errno_t
__cdecl
_wcslwr_s_l(
_Inout_updates_z_(_SizeInWords) wchar_t *_Str,
_In_ size_t _SizeInWords,
_In_opt_ _locale_t _Locale);

_Check_return_wat_
_CRTIMP
errno_t
__cdecl
_wcsupr_s(
_Inout_updates_z_(_Size) wchar_t *_Str,
_In_ size_t _Size);

_Check_return_wat_
_CRTIMP
errno_t
__cdecl
_wcsupr_s_l(
_Inout_updates_z_(_Size) wchar_t *_Str,
_In_ size_t _Size,
_In_opt_ _locale_t _Locale);

#endif /* __STDC_WANT_SECURE_LIB__ */

#ifndef NO_OLDNAMES

_Check_return_
Expand Down Expand Up @@ -1144,5 +951,8 @@ extern "C" {
#define stricmp _stricmp
#define wcsicmp _wcsicmp

#if __STDC_WANT_SECURE_LIB__
#include <sec_api/string_s.h>
#endif /* __STDC_WANT_SECURE_LIB__ */

#endif
21 changes: 3 additions & 18 deletions sdk/include/crt/tchar.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ extern "C" {
#define _tcscat wcscat
#define _tcschr wcschr
#define _tcscpy wcscpy
#define _tcscpy_s wcscpy_s
#define _tcscspn wcscspn
#define _tcslen wcslen
#define _tcsnlen wcsnlen
Expand Down Expand Up @@ -324,13 +323,6 @@ extern "C" {
#define _tcsftime wcsftime
#define _tcsftime_l _wcsftime_l

#define _tasctime_s _wasctime_s
#define _tctime_s _wctime_s
#define _tctime32_s _wctime32_s
#define _tctime64_s _wctime64_s
#define _tstrdate_s _wstrdate_s
#define _tstrtime_s _wstrtime_s

#define _tchdir _wchdir
#define _tgetcwd _wgetcwd
#define _tgetdcwd _wgetdcwd
Expand All @@ -346,7 +338,6 @@ extern "C" {
#define _tputenv _wputenv
#define _tsearchenv _wsearchenv
#define _tsplitpath _wsplitpath
#define _tsplitpath_s _wsplitpath_s

#define _tfdopen _wfdopen
#define _tfsopen _wfsopen
Expand Down Expand Up @@ -621,7 +612,6 @@ extern "C" {

#define _tcscat strcat
#define _tcscpy strcpy
#define _tcscpy_s strcpy_s
#define _tcsdup _strdup
#define _tcslen strlen
#define _tcsnlen strnlen
Expand Down Expand Up @@ -662,13 +652,6 @@ extern "C" {
#define _tcsftime strftime
#define _tcsftime_l _strftime_l

#define _tasctime_s asctime_s
#define _tctime_s ctime_s
#define _tctime32_s _ctime32_s
#define _tctime64_s _ctime64_s
#define _tstrdate_s _strdate_s
#define _tstrtime_s _strtime_s

#define _tchdir _chdir
#define _tgetcwd _getcwd
#define _tgetdcwd _getdcwd
Expand All @@ -684,7 +667,6 @@ extern "C" {
#define _tputenv _putenv
#define _tsearchenv _searchenv
#define _tsplitpath _splitpath
#define _tsplitpath_s _splitpath_s

#ifdef _POSIX_
#define _tfdopen fdopen
Expand Down Expand Up @@ -1538,5 +1520,8 @@ extern "C" {
}
#endif

#if __STDC_WANT_SECURE_LIB__
#include <sec_api/tchar_s.h>
#endif /* __STDC_WANT_SECURE_LIB__ */

#endif
Loading

0 comments on commit bead5e0

Please sign in to comment.