safec
3.2
Safe C Library - ISO TR24731 Bounds Checking Interface
|
#include "safe_str_lib.h"
Functions | |
EXPORT int | swprintf_s (wchar_t *restrict dest, rsize_t dmax, const wchar_t *restrict fmt,...) |
The swprintf_s function composes a wide string with same test that would be printed if format was used on wprintf . More... | |
EXPORT int swprintf_s | ( | wchar_t *restrict | dest, |
rsize_t | dmax, | ||
const wchar_t *restrict | fmt, | ||
... | |||
) |
The swprintf_s
function composes a wide string with same test that would be printed if format was used on wprintf
.
Instead of being printed, the content is stored in dest. With SAFECLIB_STR_NULL_SLACK
defined all elements following the terminating null character (if any) written by swprintf_s
in the array of dmax wide characters pointed to by dest
are nulled when swprintf_s
returns.
errno
is set on error. However, the safeclib extended ES*
errors do not set errno
, only when the underlying system vswprintf
call fails, errno
is set.[out] | dest | pointer to wide string that will be written into. |
[in] | dmax | restricted maximum length of dest |
[in] | fmt | format-control wide string. |
[in] | ... | optional arguments |
dest
nor fmt
shall be a null pointer. dmax
shall not be greater than RSIZE_MAX_WSTR
. dmax
shall not equal zero. dmax
shall be greater than wcsnlen_s(dest, dmax)
. fmt
shall not contain the conversion specifier n
s
is a null pointer. (not yet) snprintf
, which makes it possible to determine the required output buffer size, there is no equivalent for wide strings (until C11's swprintf_s
), and in order to determine the buffer size, the program may need to call swprintf
, check the result value, and reallocate a larger buffer, trying again until successful.dest
is too small for the formatted text, including the terminating null, then the buffer is set to an empty string by placing a null wide character at dest
[0], and the invalid parameter handler is invoked.errno: ESNULLP when dest/fmt
is NULL pointer ESZEROL when dmax
= 0 ESLEMAX when dmax
> RSIZE_MAX_WSTR
ESNOSPC when return value exceeds dmax EINVAL when fmt
contains n
-1 | if an encoding error occurred or if n or more wide characters are requested to be written. |
0 | on some other error |