|
| 1 | +/* |
| 2 | + * PROJECT: ReactOS CRT |
| 3 | + * LICENSE: MIT (https://spdx.org/licenses/MIT) |
| 4 | + * PURPOSE: Instantiation of CRT stdio inline functions |
| 5 | + * COPYRIGHT: Copyright 2023-2024 Timo Kreuzer <[email protected]> |
| 6 | + */ |
| 7 | + |
| 8 | +#define _NO_CRT_STDIO_INLINE |
| 9 | +#include <stdio.h> |
| 10 | + |
| 11 | +// These 2 functions are inlined in UCRT headers, but they are referenced by |
| 12 | +// external code in the legacy CRT, so we need to provide them as non-inline |
| 13 | +// functions here. |
| 14 | + |
| 15 | +_Success_(return >= 0) |
| 16 | +_Check_return_opt_ |
| 17 | +int __CRTDECL sprintf( |
| 18 | + _Pre_notnull_ _Always_(_Post_z_) char* const _Buffer, |
| 19 | + _In_z_ _Printf_format_string_ char const* const _Format, |
| 20 | + ...) |
| 21 | +{ |
| 22 | + int _Result; |
| 23 | + va_list _ArgList; |
| 24 | + |
| 25 | + __crt_va_start(_ArgList, _Format); |
| 26 | + |
| 27 | + _Result = __stdio_common_vsprintf( |
| 28 | + _CRT_INTERNAL_LOCAL_PRINTF_OPTIONS | _CRT_INTERNAL_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION, |
| 29 | + _Buffer, (size_t)-1, _Format, NULL, _ArgList); |
| 30 | + |
| 31 | + __crt_va_end(_ArgList); |
| 32 | + return _Result < 0 ? -1 : _Result; |
| 33 | +} |
| 34 | + |
| 35 | +_Success_(return >= 0) |
| 36 | +_Check_return_opt_ |
| 37 | +int __CRTDECL _vsnprintf( |
| 38 | + _Out_writes_opt_(_BufferCount) _Post_maybez_ char* const _Buffer, |
| 39 | + _In_ size_t const _BufferCount, |
| 40 | + _In_z_ _Printf_format_string_ char const* const _Format, |
| 41 | + va_list _ArgList |
| 42 | + ) |
| 43 | +{ |
| 44 | + int _Result = __stdio_common_vsprintf( |
| 45 | + _CRT_INTERNAL_LOCAL_PRINTF_OPTIONS | _CRT_INTERNAL_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION, |
| 46 | + _Buffer, _BufferCount, _Format, NULL, _ArgList); |
| 47 | + |
| 48 | + return _Result < 0 ? -1 : _Result; |
| 49 | +} |
0 commit comments