diff options
author | dotnet-bot <dotnet-bot@microsoft.com> | 2015-01-30 14:14:42 -0800 |
---|---|---|
committer | dotnet-bot <dotnet-bot@microsoft.com> | 2015-01-30 14:14:42 -0800 |
commit | ef1e2ab328087c61a6878c1e84f4fc5d710aebce (patch) | |
tree | dee1bbb89e9d722e16b0d1485e3cdd1b6c8e2cfa /src/pal/inc/mbusafecrt.h | |
download | coreclr-ef1e2ab328087c61a6878c1e84f4fc5d710aebce.tar.gz coreclr-ef1e2ab328087c61a6878c1e84f4fc5d710aebce.tar.bz2 coreclr-ef1e2ab328087c61a6878c1e84f4fc5d710aebce.zip |
Initial commit to populate CoreCLR repo
[tfs-changeset: 1407945]
Diffstat (limited to 'src/pal/inc/mbusafecrt.h')
-rw-r--r-- | src/pal/inc/mbusafecrt.h | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/src/pal/inc/mbusafecrt.h b/src/pal/inc/mbusafecrt.h new file mode 100644 index 0000000000..53fcd40739 --- /dev/null +++ b/src/pal/inc/mbusafecrt.h @@ -0,0 +1,119 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +/*** +* mbusafecrt.h - public declarations for SafeCRT lib +* + +* +* Purpose: +* This file contains the public declarations SafeCRT +* functions ported to MacOS. These are the safe versions of +* functions standard functions banned by SWI +* + +****/ + +/* shields! */ + +#ifndef MBUSAFECRT_H +#define MBUSAFECRT_H + +//#include <wchar.h> + +/* MacOS does not define a specifc type for errnos, but SafeCRT does */ +typedef int errno_t; + +/* errno value that specific to SafeCRT */ +#define STRUNCATE 80 + +// define the return value for success +#define SAFECRT_SUCCESS 0 + +/* + * Sizes for buffers used by the _makepath() and _splitpath() functions. + * note that the sizes include space for 0-terminator + */ +//#define _MAX_PATH 260 /* max. length of full pathname */ +//#define _MAX_DRIVE 3 /* max. length of drive component */ +//#define _MAX_DIR 256 /* max. length of path component */ +//#define _MAX_FNAME 256 /* max. length of file name component */ +//#define _MAX_EXT 256 /* max. length of extension component */ + +#ifdef __cplusplus + extern "C" { +#endif + +typedef void ( *tSafeCRT_AssertFuncPtr )( const char* inExpression, const char* inComment, const char* inFile, const unsigned long inLineNum ); +void MBUSafeCRTSetAssertFunc( tSafeCRT_AssertFuncPtr inAssertFuncPtr ); + +extern errno_t strcat_s( char* ioDest, size_t inDestBufferSize, const char* inSrc ); +extern errno_t wcscat_s( wchar_t* ioDest, size_t inDestBufferSize, const wchar_t* inSrc ); + +extern errno_t strncat_s( char* ioDest, size_t inDestBufferSize, const char* inSrc, size_t inCount ); +extern errno_t wcsncat_s( wchar_t* ioDest, size_t inDestBufferSize, const wchar_t* inSrc, size_t inCount ); + +extern errno_t strcpy_s( char* outDest, size_t inDestBufferSize, const char* inSrc ); +extern errno_t wcscpy_s( wchar_t* outDest, size_t inDestBufferSize, const wchar_t* inSrc ); + +extern errno_t strncpy_s( char* outDest, size_t inDestBufferSize, const char* inSrc, size_t inCount ); +extern errno_t wcsncpy_s( wchar_t* outDest, size_t inDestBufferSize, const wchar_t* inSrc, size_t inCount ); + +extern char* strtok_s( char* inString, const char* inControl, char** ioContext ); +extern wchar_t* wcstok_s( wchar_t* inString, const wchar_t* inControl, wchar_t** ioContext ); + +// strnlen is not required unless the source string is completely untrusted (e.g. anonymous input on a website) +#ifndef SUPPRESS_STRNLEN + extern size_t strnlen( const char* inString, size_t inMaxSize ); + extern size_t wcsnlen( const wchar_t* inString, size_t inMaxSize ); +#endif + +extern errno_t _itoa_s( int inValue, char* outBuffer, size_t inDestBufferSize, int inRadix ); +extern errno_t _itow_s( int inValue, wchar_t* outBuffer, size_t inDestBufferSize, int inRadix ); + +extern errno_t _ltoa_s( long inValue, char* outBuffer, size_t inDestBufferSize, int inRadix ); +extern errno_t _ltow_s( long inValue, wchar_t* outBuffer, size_t inDestBufferSize, int inRadix ); + +extern errno_t _ultoa_s( unsigned long inValue, char* outBuffer, size_t inDestBufferSize, int inRadix ); +extern errno_t _ultow_s( unsigned long inValue, wchar_t* outBuffer, size_t inDestBufferSize, int inRadix ); + +extern errno_t _i64toa_s( long long inValue, char* outBuffer, size_t inDestBufferSize, int inRadix ); +extern errno_t _i64tow_s( long long inValue, wchar_t* outBuffer, size_t inDestBufferSize, int inRadix ); + +extern errno_t _ui64toa_s( unsigned long long inValue, char* outBuffer, size_t inDestBufferSize, int inRadix ); +extern errno_t _ui64tow_s( unsigned long long inValue, wchar_t* outBuffer, size_t inDestBufferSize, int inRadix ); + +extern errno_t _makepath_s( char* outDest, size_t inDestBufferSize, const char* inDrive, const char* inDirectory, const char* inFilename, const char* inExtension ); +extern errno_t _wmakepath_s( wchar_t* outDest, size_t inDestBufferSize, const wchar_t* inDrive, const wchar_t* inDirectory, const wchar_t* inFilename, const wchar_t* inExtension ); + +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 ); +extern errno_t _wsplitpath_s( const wchar_t* inPath, wchar_t* outDrive, size_t inDriveSize, wchar_t* outDirectory, size_t inDirectorySize, wchar_t* outFilename, size_t inFilenameSize, wchar_t* outExtension, size_t inExtensionSize ); + +extern int sprintf_s( char *string, size_t sizeInBytes, const char *format, ... ); +extern int swprintf_s( wchar_t *string, size_t sizeInWords, const wchar_t *format, ... ); + +extern int _snprintf_s( char *string, size_t sizeInBytes, size_t count, const char *format, ... ); +extern int _snwprintf_s( wchar_t *string, size_t sizeInWords, size_t count, const wchar_t *format, ... ); + +extern int _vsprintf_s( char* string, size_t sizeInBytes, const char* format, va_list arglist ); +extern int _vsnprintf_s( char* string, size_t sizeInBytes, size_t count, const char* format, va_list arglist ); + +extern int _vswprintf_s( wchar_t* string, size_t sizeInWords, const wchar_t* format, va_list arglist ); +extern int _vsnwprintf_s( wchar_t* string, size_t sizeInWords, size_t count, const wchar_t* format, va_list arglist ); + +extern int sscanf_s( const char *string, const char *format, ... ); +extern int swscanf_s( const wchar_t *string, const wchar_t *format, ... ); + +extern int _snscanf_s( const char *string, size_t count, const char *format, ... ); +extern int _snwscanf_s( const wchar_t *string, size_t count, const wchar_t *format, ... ); + +extern errno_t memcpy_s( void * dst, size_t sizeInBytes, const void * src, size_t count ); +extern errno_t memmove_s( void * dst, size_t sizeInBytes, const void * src, size_t count ); + +#ifdef __cplusplus + } +#endif + +#endif /* MBUSAFECRT_H */ |