safec  2.1
Safe C Library - ISO TR24731 Bounds Checking Interface
snprintf_s.c File Reference
#include "config.h"
#include "safe_str_lib.h"
#include "safe_str_constraint.h"
#include <stdarg.h>
+ Include dependency graph for snprintf_s.c:

Go to the source code of this file.

Functions

int snprintf_s (char *restrict dest, rsize_t dmax, const char *restrict fmt,...)
 The snprintf_s function composes a string with same test that would be printed if format was used on printf. More...
 

Function Documentation

◆ snprintf_s()

int snprintf_s ( char *restrict  dest,
rsize_t  dmax,
const char *restrict  fmt,
  ... 
)

The snprintf_s function composes a string with same test that would be printed if format was used on printf.

Instead of being printed, the content is stored in dest. More than dmax - 1 characters might be written, so this variant is unsafe! Always use sprintf_s instead. The resulting character string will be terminated with a null character, unless dmax is zero. If dmax is zero, nothing is written and dest may be a null pointer, however the return value (number of bytes that would be written) is still calculated and returned.

Remarks
SPECIFIED IN
Parameters
deststorage location for output buffer.
dmaxmaximum number of characters to store in buffer.
fmtformat-control string.
...optional arguments
Returns
Number of characters not including the terminating null character (which is always written as long as buffer is not a null pointer and bufsz is not zero and not greater than RSIZE_MAX_STR), which would have been written to buffer if bufsz was ignored, or a negative value if a runtime constraints violation or an encoding error occurred.
Return values
ESNULLPwhen dest/fmt is NULL pointer
ESZEROLwhen dmax = 0
ESLEMAXwhen dmax > RSIZE_MAX_STR

Definition at line 74 of file snprintf_s.c.