1 | // Licensed to the .NET Foundation under one or more agreements. |
2 | // The .NET Foundation licenses this file to you under the MIT license. |
3 | // See the LICENSE file in the project root for more information. |
4 | |
5 | /*** |
6 | * mbusafecrt.h - public declarations for SafeCRT lib |
7 | * |
8 | |
9 | * |
10 | * Purpose: |
11 | * This file contains the public declarations SafeCRT |
12 | * functions ported to MacOS. These are the safe versions of |
13 | * functions standard functions banned by SWI |
14 | * |
15 | |
16 | ****/ |
17 | |
18 | /* shields! */ |
19 | |
20 | #ifndef MBUSAFECRT_H |
21 | #define MBUSAFECRT_H |
22 | |
23 | //#include <wchar.h> |
24 | |
25 | /* MacOS does not define a specifc type for errnos, but SafeCRT does */ |
26 | typedef int errno_t; |
27 | |
28 | /* errno value that specific to SafeCRT */ |
29 | #define STRUNCATE 80 |
30 | |
31 | // define the return value for success |
32 | #define SAFECRT_SUCCESS 0 |
33 | |
34 | #ifdef __cplusplus |
35 | extern "C" { |
36 | #endif |
37 | |
38 | typedef void ( *tSafeCRT_AssertFuncPtr )( const char* inExpression, const char* , const char* inFile, const unsigned long inLineNum ); |
39 | void MBUSafeCRTSetAssertFunc( tSafeCRT_AssertFuncPtr inAssertFuncPtr ); |
40 | |
41 | extern errno_t strcat_s( char* ioDest, size_t inDestBufferSize, const char* inSrc ); |
42 | extern errno_t wcscat_s( WCHAR* ioDest, size_t inDestBufferSize, const WCHAR* inSrc ); |
43 | |
44 | extern errno_t strncat_s( char* ioDest, size_t inDestBufferSize, const char* inSrc, size_t inCount ); |
45 | extern errno_t wcsncat_s( WCHAR* ioDest, size_t inDestBufferSize, const WCHAR* inSrc, size_t inCount ); |
46 | |
47 | extern errno_t strcpy_s( char* outDest, size_t inDestBufferSize, const char* inSrc ); |
48 | extern errno_t wcscpy_s( WCHAR* outDest, size_t inDestBufferSize, const WCHAR* inSrc ); |
49 | |
50 | extern errno_t strncpy_s( char* outDest, size_t inDestBufferSize, const char* inSrc, size_t inCount ); |
51 | extern errno_t wcsncpy_s( WCHAR* outDest, size_t inDestBufferSize, const WCHAR* inSrc, size_t inCount ); |
52 | |
53 | extern char* strtok_s( char* inString, const char* inControl, char** ioContext ); |
54 | extern WCHAR* wcstok_s( WCHAR* inString, const WCHAR* inControl, WCHAR** ioContext ); |
55 | |
56 | // strnlen is not required unless the source string is completely untrusted (e.g. anonymous input on a website) |
57 | #ifndef SUPPRESS_STRNLEN |
58 | extern size_t PAL_strnlen( const char* inString, size_t inMaxSize ); |
59 | extern size_t PAL_wcsnlen( const WCHAR* inString, size_t inMaxSize ); |
60 | #endif |
61 | |
62 | extern errno_t _itoa_s( int inValue, char* outBuffer, size_t inDestBufferSize, int inRadix ); |
63 | extern errno_t _itow_s( int inValue, WCHAR* outBuffer, size_t inDestBufferSize, int inRadix ); |
64 | |
65 | extern errno_t _ltoa_s( long inValue, char* outBuffer, size_t inDestBufferSize, int inRadix ); |
66 | extern errno_t _ltow_s( long inValue, WCHAR* outBuffer, size_t inDestBufferSize, int inRadix ); |
67 | |
68 | extern errno_t _ultoa_s( unsigned long inValue, char* outBuffer, size_t inDestBufferSize, int inRadix ); |
69 | extern errno_t _ultow_s( unsigned long inValue, WCHAR* outBuffer, size_t inDestBufferSize, int inRadix ); |
70 | |
71 | extern errno_t _i64toa_s( long long inValue, char* outBuffer, size_t inDestBufferSize, int inRadix ); |
72 | extern errno_t _i64tow_s( long long inValue, WCHAR* outBuffer, size_t inDestBufferSize, int inRadix ); |
73 | |
74 | extern errno_t _ui64toa_s( unsigned long long inValue, char* outBuffer, size_t inDestBufferSize, int inRadix ); |
75 | extern errno_t _ui64tow_s( unsigned long long inValue, WCHAR* outBuffer, size_t inDestBufferSize, int inRadix ); |
76 | |
77 | extern errno_t _makepath_s( char* outDest, size_t inDestBufferSize, const char* inDrive, const char* inDirectory, const char* inFilename, const char* inExtension ); |
78 | extern errno_t _wmakepath_s( WCHAR* outDest, size_t inDestBufferSize, const WCHAR* inDrive, const WCHAR* inDirectory, const WCHAR* inFilename, const WCHAR* inExtension ); |
79 | |
80 | extern errno_t _splitpath_s( const char* inPath, char* outDrive, size_t inDriveSize, char* outDirectory, size_t inDirectorySize, char* outFilename, size_t inFilenameSize, char* outExtension, size_t inExtensionSize ); |
81 | extern errno_t _wsplitpath_s( const WCHAR* inPath, WCHAR* outDrive, size_t inDriveSize, WCHAR* outDirectory, size_t inDirectorySize, WCHAR* outFilename, size_t inFilenameSize, WCHAR* outExtension, size_t inExtensionSize ); |
82 | |
83 | extern int sprintf_s( char *string, size_t sizeInBytes, const char *format, ... ); |
84 | extern int swprintf_s( WCHAR *string, size_t sizeInWords, const WCHAR *format, ... ); |
85 | |
86 | extern int _snprintf_s( char *string, size_t sizeInBytes, size_t count, const char *format, ... ); |
87 | extern int _snwprintf_s( WCHAR *string, size_t sizeInWords, size_t count, const WCHAR *format, ... ); |
88 | |
89 | extern int vsprintf_s( char* string, size_t sizeInBytes, const char* format, va_list arglist ); |
90 | extern int _vsnprintf_s( char* string, size_t sizeInBytes, size_t count, const char* format, va_list arglist ); |
91 | |
92 | extern int vswprintf_s( WCHAR* string, size_t sizeInWords, const WCHAR* format, va_list arglist ); |
93 | extern int _vsnwprintf_s( WCHAR* string, size_t sizeInWords, size_t count, const WCHAR* format, va_list arglist ); |
94 | |
95 | extern int sscanf_s( const char *string, const char *format, ... ); |
96 | extern int swscanf_s( const WCHAR *string, const WCHAR *format, ... ); |
97 | |
98 | extern int _snscanf_s( const char *string, size_t count, const char *format, ... ); |
99 | extern int _snwscanf_s( const WCHAR *string, size_t count, const WCHAR *format, ... ); |
100 | |
101 | extern errno_t memcpy_s( void * dst, size_t sizeInBytes, const void * src, size_t count ); |
102 | extern errno_t memmove_s( void * dst, size_t sizeInBytes, const void * src, size_t count ); |
103 | |
104 | #ifdef __cplusplus |
105 | } |
106 | #endif |
107 | |
108 | #endif /* MBUSAFECRT_H */ |
109 | |