47#if !defined(MBEDTLS_CONFIG_FILE)
50#include MBEDTLS_CONFIG_FILE
53#if defined(MBEDTLS_PLATFORM_C)
62#if defined(MBEDTLS_PLATFORM_MEMORY) && \
63 !( defined(MBEDTLS_PLATFORM_CALLOC_MACRO) && \
64 defined(MBEDTLS_PLATFORM_FREE_MACRO) )
66#if !defined(MBEDTLS_PLATFORM_STD_CALLOC)
67static void *platform_calloc_uninit(
size_t n,
size_t size )
74#define MBEDTLS_PLATFORM_STD_CALLOC platform_calloc_uninit
77#if !defined(MBEDTLS_PLATFORM_STD_FREE)
78static void platform_free_uninit(
void *
ptr )
83#define MBEDTLS_PLATFORM_STD_FREE platform_free_uninit
91 return (*mbedtls_calloc_func)( nmemb,
size );
96 (*mbedtls_free_func)(
ptr );
99int mbedtls_platform_set_calloc_free(
void * (*calloc_func)(
size_t,
size_t ),
102 mbedtls_calloc_func = calloc_func;
112int mbedtls_platform_win32_snprintf(
char *
s,
size_t n,
const char *
fmt, ... )
122#if defined(_TRUNCATE) && !defined(__MINGW32__)
126 if(
ret < 0 || (
size_t)
ret ==
n )
138#if defined(MBEDTLS_PLATFORM_SNPRINTF_ALT)
139#if !defined(MBEDTLS_PLATFORM_STD_SNPRINTF)
143static int platform_snprintf_uninit(
char *
s,
size_t n,
144 const char *
format, ... )
152#define MBEDTLS_PLATFORM_STD_SNPRINTF platform_snprintf_uninit
159int mbedtls_platform_set_snprintf(
int (*snprintf_func)(
char *
s,
size_t n,
168#if defined(MBEDTLS_PLATFORM_PRINTF_ALT)
169#if !defined(MBEDTLS_PLATFORM_STD_PRINTF)
173static int platform_printf_uninit(
const char *
format, ... )
179#define MBEDTLS_PLATFORM_STD_PRINTF platform_printf_uninit
184int mbedtls_platform_set_printf(
int (*printf_func)(
const char *, ... ) )
191#if defined(MBEDTLS_PLATFORM_FPRINTF_ALT)
192#if !defined(MBEDTLS_PLATFORM_STD_FPRINTF)
203#define MBEDTLS_PLATFORM_STD_FPRINTF platform_fprintf_uninit
209int mbedtls_platform_set_fprintf(
int (*fprintf_func)(
FILE *,
const char *, ... ) )
216#if defined(MBEDTLS_PLATFORM_EXIT_ALT)
217#if !defined(MBEDTLS_PLATFORM_STD_EXIT)
221static void platform_exit_uninit(
int status )
226#define MBEDTLS_PLATFORM_STD_EXIT platform_exit_uninit
231int mbedtls_platform_set_exit(
void (*exit_func)(
int status ) )
238#if defined(MBEDTLS_HAVE_TIME)
240#if defined(MBEDTLS_PLATFORM_TIME_ALT)
241#if !defined(MBEDTLS_PLATFORM_STD_TIME)
251#define MBEDTLS_PLATFORM_STD_TIME platform_time_uninit
265#if defined(MBEDTLS_ENTROPY_NV_SEED)
266#if !defined(MBEDTLS_PLATFORM_NO_STD_FUNCTIONS) && defined(MBEDTLS_FS_IO)
270int mbedtls_platform_std_nv_seed_read(
unsigned char *
buf,
size_t buf_len )
275 if( (
file =
fopen( MBEDTLS_PLATFORM_STD_NV_SEED_FILE,
"rb" ) ) ==
NULL )
289int mbedtls_platform_std_nv_seed_write(
unsigned char *
buf,
size_t buf_len )
294 if( (
file =
fopen( MBEDTLS_PLATFORM_STD_NV_SEED_FILE,
"w" ) ) ==
NULL )
308#if defined(MBEDTLS_PLATFORM_NV_SEED_ALT)
309#if !defined(MBEDTLS_PLATFORM_STD_NV_SEED_READ)
313static int platform_nv_seed_read_uninit(
unsigned char *
buf,
size_t buf_len )
320#define MBEDTLS_PLATFORM_STD_NV_SEED_READ platform_nv_seed_read_uninit
323#if !defined(MBEDTLS_PLATFORM_STD_NV_SEED_WRITE)
327static int platform_nv_seed_write_uninit(
unsigned char *
buf,
size_t buf_len )
334#define MBEDTLS_PLATFORM_STD_NV_SEED_WRITE platform_nv_seed_write_uninit
337int (*mbedtls_nv_seed_read)(
unsigned char *
buf,
size_t buf_len ) =
338 MBEDTLS_PLATFORM_STD_NV_SEED_READ;
339int (*mbedtls_nv_seed_write)(
unsigned char *
buf,
size_t buf_len ) =
340 MBEDTLS_PLATFORM_STD_NV_SEED_WRITE;
342int mbedtls_platform_set_nv_seed(
343 int (*nv_seed_read_func)(
unsigned char *
buf,
size_t buf_len ),
344 int (*nv_seed_write_func)(
unsigned char *
buf,
size_t buf_len ) )
346 mbedtls_nv_seed_read = nv_seed_read_func;
347 mbedtls_nv_seed_write = nv_seed_write_func;
353#if !defined(MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT)
int _vsnprintf_s(char *buffer, size_t sizeOfBuffer, size_t count, const char *format, va_list argptr)
void(* free_func)(voidpf opaque, voidpf address)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
GLenum GLuint GLenum GLsizei const GLchar * buf
_Check_return_opt_ _CRTIMP size_t __cdecl fread(_Out_writes_bytes_(_ElementSize *_Count) void *_DstBuf, _In_ size_t _ElementSize, _In_ size_t _Count, _Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP size_t __cdecl fwrite(_In_reads_bytes_(_Size *_Count) const void *_Str, _In_ size_t _Size, _In_ size_t _Count, _Inout_ FILE *_File)
Configuration options (set of defines)
The platform context structure.