safec
3.3
Safe C Library - ISO TR24731 Bounds Checking Interface
|
#include "safe_config.h"
#include "safe_lib_errno.h"
#include "safe_types.h"
#include "safe_compile.h"
#include <stdarg.h>
#include <time.h>
#include <wchar.h>
Macros | |
#define | EXTERN extern |
#define | RSIZE_MIN_STR ( 1 ) |
The shortest string is a null string!! More... | |
#define | RSIZE_MAX_WSTR ( RSIZE_MAX_STR/sizeof(wchar_t) ) |
wide chars More... | |
#define | SAFE_STR_MIN_LOWERCASE ( 2 ) |
The makeup of a password. More... | |
#define | SAFE_STR_MIN_UPPERCASE ( 2 ) |
#define | SAFE_STR_MIN_NUMBERS ( 1 ) |
#define | SAFE_STR_MIN_SPECIALS ( 1 ) |
#define | SAFE_STR_PASSWORD_MIN_LENGTH ( 6 ) |
#define | SAFE_STR_PASSWORD_MAX_LENGTH ( 32 ) |
#define | sl_default_handler ignore_handler_s |
#define | strcat_s(dest, dmax, src) _strcat_s_chk(dest,dmax,src,BOS(dest)) |
The strcat_s function appends a copy of the string pointed to by src (including the terminating null character) to the end of the string pointed to by dest. More... | |
#define | strcpy_s(dest, dmax, src) _strcpy_s_chk(dest,dmax,src,BOS(dest)) |
The strcpy_s function copies the string pointed to by src (including the terminating null character) into the array pointed to by dest. More... | |
#define | strncat_s(dest, dmax, src, slen) _strncat_s_chk(dest,dmax,src,slen,BOS(dest),BOS(src)) |
The strncat_s function appends a copy of the string pointed to by src (including the terminating null character) to the end of the string pointed to by dest. More... | |
#define | strncpy_s(dest, dmax, src, slen) _strncpy_s_chk(dest,dmax,src,slen,BOS(dest),BOS(src)) |
The strncpy_s function copies not more than slen successive characters (characters that follow a null character are not copied) from the array pointed to by src to the array pointed to by dest. More... | |
#define | strnlen_s(str, smax) _strnlen_s_chk(str,smax,BOS(str)) |
The strnlen_s function computes the length of the string pointed to by str , refusing to read past smax. More... | |
#define | strtok_s(dest, dmaxp, delim, ptr) _strtok_s_chk(dest,dmaxp,delim,ptr,BOS(dest)) |
A sequence of calls to the strtok_s function breaks the string pointed to by dest into a sequence of tokens, each of which is delimited by a character from the string pointed to by delim. More... | |
#define | vsprintf_s(dest, dmax, fmt, ap) _vsprintf_s_chk(dest,dmax,BOS(dest),fmt,ap) |
The vsprintf_s function composes a string with the same content that would be printed if format was used on printf . More... | |
#define | vsnprintf_s(dest, dmax, fmt, ap) _vsnprintf_s_chk(dest,dmax,BOS(dest),fmt,ap) |
The truncating vsnprintf_s function composes a string with same test that would be printed if format was used on printf . More... | |
#define | strerror_s(dest, dmax, errnum) _strerror_s_chk(dest,dmax,errnum,BOS(dest)) |
The strerror_s function returns a pointer to the textual description of the system error code errnum, identical to the description that would be printed by perror(). More... | |
#define | strcmp_s(dest, dmax, src, resultp) _strcmp_s_chk(dest,dmax,src,resultp,BOS(dest),BOS(src)) |
Compares string src to string dest. More... | |
#define | strcasecmp_s(dest, dmax, src, resultp) _strcasecmp_s_chk(dest,dmax,src,resultp,BOS(dest)) |
Case insensitive string comparison by converting to uppercase prior to the compare. More... | |
#define | strnatcmp_s(dest, dmax, src, resultp) _strnatcmp_s_chk(dest,dmax,src,0,resultp,BOS(dest),BOS(src)) |
Natural order comparison of strings. More... | |
#define | strnatcasecmp_s(dest, dmax, src, resultp) _strnatcasecmp_s_chk(dest,dmax,src,1,resultp,BOS(dest),BOS(src)) |
#define | strcasestr_s(dest, dmax, src, slen, substring) _strcasestr_s_chk(dest,dmax,src,slen,substring,BOS(dest),BOS(src)) |
The strcasestr_s() function locates the first occurrence of the substring pointed to by src which would be located in the string pointed to by dest. More... | |
#define | strcmpfld_s(dest, dmax, src, resultp) _strcmpfld_s_chk(dest,dmax,src,resultp,BOS(dest)) |
Compares the character array pointed to by src to the character array pointed to by dest for dmax characters. More... | |
#define | strcpyfld_s(dest, dmax, src, slen) _strcpyfld_s_chk(dest,dmax,src,slen,BOS(dest)) |
#define | strcpyfldin_s(dest, dmax, src, slen) _strcpyfldin_s_chk(dest,dmax,src,slen,BOS(dest)) |
#define | strcpyfldout_s(dest, dmax, src, slen) _strcpyfldout_s_chk(dest,dmax,src,slen,BOS(dest)) |
#define | strcspn_s(dest, dmax, src, slen, countp) _strcspn_s_chk(dest,dmax,src,slen,countp,BOS(dest),BOS(src)) |
This function computes the prefix length of the string pointed to by dest which consists entirely of characters that are excluded from the string pointed to by src. More... | |
#define | strfirstchar_s(dest, dmax, c, firstp) _strfirstchar_s_chk(dest,dmax,c,firstp,BOS(dest)) |
This function returns a pointer to the first occurrence of character c in dest. More... | |
#define | strfirstdiff_s(dest, dmax, src, resultp) _strfirstdiff_s_chk(dest,dmax,src,resultp,BOS(dest)) |
Returns the index of the first character that is different between dest and src. More... | |
#define | strisalphanumeric_s(dest, dmax) _strisalphanumeric_s_chk(dest,dmax,BOS(dest)) |
This function checks if the entire string contains alphanumerics. More... | |
#define | strisascii_s(dest, dmax) _strisascii_s_chk(dest,dmax,BOS(dest)) |
This function checks if the entire string contains ascii characters. More... | |
#define | strisdigit_s(dest, dmax) _strisdigit_s_chk(dest,dmax,BOS(dest)) |
This function checks that the entire string contains digits. More... | |
#define | strishex_s(dest, dmax) _strishex_s_chk(dest,dmax,BOS(dest)) |
This function checks that the entire string contains hex characters. More... | |
#define | strislowercase_s(dest, dmax) _strislowercase_s_chk(dest,dmax,BOS(dest)) |
This function checks if entire string is lowercase. More... | |
#define | strismixedcase_s(dest, dmax) _strismixedcase_s_chk(dest,dmax,BOS(dest)) |
This function checks that the entire string is mixed case. More... | |
#define | strispassword_s(dest, dmax) _strispassword_s_chk(dest,dmax,BOS(dest)) |
This function validates the make-up of a password string. More... | |
#define | strisuppercase_s(dest, dmax) _strisuppercase_s_chk(dest,dmax,BOS(dest)) |
This function checks if entire string is uppercase The scanning stops at the first null or after dmax characters. More... | |
#define | strlastchar_s(dest, dmax, c, lastp) _strlastchar_s_chk(dest,dmax,c,lastp,BOS(dest)) |
Returns a pointer to the last occurrence of character c in dest. More... | |
#define | strlastdiff_s(dest, dmax, src, resultp) _strlastdiff_s_chk(dest,dmax,src,resultp,BOS(dest)) |
Returns the index of the last character that is different between dest and src. More... | |
#define | strljustify_s(dest, dmax) _strljustify_s_chk(dest,dmax,BOS(dest)) |
Removes beginning whitespace from the string pointed to by dest by shifting the text left over writting the beginning whitespace, left justifying the text. More... | |
#define | strnterminate_s(dest, dmax) _strnterminate_s_chk(dest,dmax,BOS(dest)) |
The strnterminate_s function will terminate the string if a null is not encountered before dmax characters. More... | |
#define | strpbrk_s(dest, dmax, src, slen, firstp) _strpbrk_s_chk(dest,dmax,src,slen,firstp,BOS(dest),BOS(src)) |
Returns a pointer, first, to the first ocurrence of any character in src which is contained in dest. More... | |
#define | strfirstsame_s(dest, dmax, src, resultp) _strfirstsame_s_chk(dest,dmax,src,resultp,BOS(dest)) |
Returns the index of the first character that is the same between dest and src. More... | |
#define | strlastsame_s(dest, dmax, src, resultp) _strlastsame_s_chk(dest,dmax,src,resultp,BOS(dest)) |
Returns the index of the last character that is the same between dest and src. More... | |
#define | strprefix_s(dest, dmax, src) _strprefix_s_chk(dest,dmax,src,BOS(dest)) |
Determines if the prefix pointed to by src is at the beginning of string pointed to by dest. More... | |
#define | strremovews_s(dest, dmax) _strremovews_s_chk(dest,dmax,BOS(dest)) |
Removes beginning and trailing whitespace from the string pointed to by dest by shifting the text left over writting the beginning whitespace (space or tab). More... | |
#define | strspn_s(dest, dmax, src, slen, countp) _strspn_s_chk(dest,dmax,src,slen,countp,BOS(dest),BOS(src)) |
This function computes the prefix length of the string pointed to by dest which consists entirely of characters that are included from the string pointed to by src. More... | |
#define | strstr_s(dest, dmax, src, slen, substringp) _strstr_s_chk(dest,dmax,src,slen,substringp,BOS(dest),BOS(src)) |
The strstr_s() function locates the first occurrence of the substring pointed to by src which would be located in the string pointed to by dest. More... | |
#define | strchr_s(dest, dmax, ch, resultp) _strchr_s_chk(dest,dmax,ch,resultp,BOS(dest)) |
Finds the first occurrence of ch (after conversion to char as if by (char)ch) in the null-terminated byte string pointed to by dest (each character interpreted as unsigned char). More... | |
#define | strrchr_s(dest, dmax, ch, resultp) _strrchr_s_chk(dest,dmax,ch,resultp,BOS(dest)) |
Finds the last occurrence of ch (after conversion to char as if by (char)ch) in the null-terminated byte string pointed to by dest (each character interpreted as unsigned char). More... | |
#define | strtolowercase_s(dest, dmax) _strtolowercase_s_chk(dest,dmax,BOS(dest)) |
Converts all uppercase characters to lowercase, leaving all other characters unchanged. More... | |
#define | strtouppercase_s(dest, dmax) _strtouppercase_s_chk(dest,dmax,BOS(dest)) |
Converts all lowercase characters to uppercase, leaving all other characters unchanged. More... | |
#define | strlwr_s(str, slen) strtolowercase_s((str), (slen)) |
#define | strupr_s(str, slen) strtouppercase_s((str), (slen)) |
#define | strzero_s(dest, dmax) _strzero_s_chk(dest,dmax,BOS(dest)) |
Nulls maximal dmax characters of dest. More... | |
#define | strcoll_s(dest, dmax, src, resultp) _strcoll_s_chk(dest,dmax,src,resultp,BOS(dest)) |
Compares two null-terminated byte strings according to the current locale as defined by the LC_COLLATE category. More... | |
#define | strset_s(dest, dmax, value) _strset_s_chk(dest,dmax,value,BOS(dest)) |
Sets maximal dmax characters of dest to a character value, but not the final NULL character. More... | |
#define | strnset_s(dest, dmax, value, n) _strnset_s_chk(dest,dmax,value,n,BOS(dest)) |
Sets maximal n characters of dest to a character value, but not the final NULL character. More... | |
#define | mbstowcs_s(retvalp, dest, dmax, src, len) _mbstowcs_s_chk(retvalp,dest,dmax,src,len,BOS(dest)) |
#define | mbsrtowcs_s(retvalp, dest, dmax, srcp, len, ps) _mbsrtowcs_s_chk(retvalp,dest,dmax,srcp,len,ps,BOS(dest)) |
Does not permit the ps parameter (the pointer to the conversion state) to be a null pointer. More... | |
#define | wcsrtombs_s(retvalp, dest, dmax, srcp, len, ps) _wcsrtombs_s_chk(retvalp,dest,dmax,srcp,len,ps,BOS(dest)) |
Does not permit the ps parameter (the pointer to the conversion state) to be a null pointer. More... | |
#define | wcstombs_s(retvalp, dest, dmax, src, len) _wcstombs_s_chk(retvalp,dest,dmax,src,len,BOS(dest)) |
The wcstombs_s function converts a sequence of wide characters from the array whose first element is pointed to by src to to its narrow multibyte representation from the current LC_CTYPE locale. More... | |
#define | wcrtomb_s(retvalp, dest, dmax, wc, ps) _wcrtomb_s_chk(retvalp,dest,dmax,wc,ps,BOS(dest)) |
Does not permit the ps parameter (the pointer to the conversion state) to be a null pointer. More... | |
#define | wctomb_s(retvalp, dest, dmax, wc) _wctomb_s_chk(retvalp,dest,dmax,wc,BOS(dest)) |
The wctomb_s function converts a single wide character to its narrow multibyte representation from the current LC_CTYPE locale. More... | |
#define | wcsnlen_s(dest, dmax) _wcsnlen_s_chk(dest,dmax,BOS(dest)) |
The wcsnlen_s function computes the length of the wide string pointed to by dest, providing limited support for non-null terminated strings. More... | |
#define | wcscpy_s(dest, dmax, src) _wcscpy_s_chk(dest,dmax,src,BOS(dest)) |
The wcscpy_s function copies the string pointed to by src (including the terminating null character) into the array pointed to by dest. More... | |
#define | wcsncpy_s(dest, dmax, src, slen) _wcsncpy_s_chk(dest,dmax,src,slen,BOS(dest),BOS(src)) |
The wcsncpy_s function copies the wide string pointed to by src (including the terminating null character) into the wide string pointed to by dest. More... | |
#define | wcscat_s(dest, dmax, src) _wcscat_s_chk(dest,dmax,src,BOS(dest)) |
The wcscat_s function appends a copy of the wide string pointed to by src (including the terminating null character) to the end of the wide string pointed to by dest. More... | |
#define | wcsncat_s(dest, dmax, src, slen) _wcsncat_s_chk(dest,dmax,src,slen,BOS(dest),BOS(src)) |
The wcsncat_s function appends a copy of the wide string pointed to by src (including the terminating null wide character) to the end of the wide string pointed to by dest. More... | |
#define | wcstok_s(dest, dmaxp, delim, ptr) _wcstok_s_chk(dest,dmaxp,delim,ptr,BOS(dest)) |
A sequence of calls to the wcstok_s function breaks the string pointed to by dest into a sequence of tokens, each of which is delimited by a character from the string pointed to by delim. More... | |
#define | vswprintf_s(dest, dmax, fmt, ap) _vswprintf_s_chk(dest,dmax,BOS(dest),fmt,ap) |
#define | vsnwprintf_s(dest, dmax, fmt, ap) _vsnwprintf_s_chk(dest,dmax,BOS(dest),fmt,ap) |
The truncating vsnwprintf_s function composes a wide string with same test that would be printed if format was used on wprintf . More... | |
#define | wcsstr_s(dest, dmax, src, slen, substringp) _wcsstr_s_chk(dest,dmax,src,slen,substringp,BOS(dest),BOS(src)) |
The wcsstr_s() function locates the first occurrence of the wide substring pointed to by src which would be located in the wide string pointed to by dest . More... | |
#define | wcscmp_s(dest, dmax, src, smax, resultp) _wcscmp_s_chk(dest,dmax,src,smax,resultp,BOS(dest),BOS(src)) |
Compares wide string src to wide string dest. More... | |
#define | wcsncmp_s(dest, dmax, src, smax, count, resultp) _wcsncmp_s_chk(dest,dmax,src,smax,count,resultp,BOS(dest),BOS(src)) |
Compares at most count wide characters of wide string src with wide string dest, and returns if difference in the last parameter. More... | |
#define | wcsicmp_s(dest, dmax, src, smax, resultp) _wcsicmp_s_chk(dest,dmax,src,smax,resultp,BOS(dest),BOS(src)) |
Compares two wide strings case-folded, via wcsfc_s() , i.e. More... | |
#define | wcsnatcmp_s(dest, dmax, src, smax, resultp) _wcsnatcmp_s_chk(dest,dmax,src,smax,0,resultp,BOS(dest),BOS(src)) |
#define | wcsnaticmp_s(dest, dmax, src, smax, resultp) _wcsnatcmp_s_chk(dest,dmax,src,smax,1,resultp,BOS(dest),BOS(src)) |
Natural order comparison of strings. More... | |
#define | wcsset_s(dest, dmax, value) _wcsset_s_chk(dest,dmax,value,BOS(dest)) |
Sets maximal dmax wide characters of dest to a wide character value, but not the final NULL character. More... | |
#define | wcsnset_s(dest, dmax, value, n) _wcsnset_s_chk(dest,dmax,value,n,BOS(dest)) |
Sets maximal n wide characters of dest to a wide character value, but not the final NULL character. More... | |
#define | wcscoll_s(dest, dmax, src, smax, resultp) _wcscoll_s_chk(dest,dmax,src,smax,resultp,BOS(dest),BOS(src)) |
Compares two null-terminated wide strings according to the current locale as defined by the LC_COLLATE category. More... | |
#define | wcslwr_s(src, slen) _wcslwr_s_chk(src,slen,BOS(src)) |
Scans the string converting uppercase characters to simple lowercase, leaving all other characters unchanged. More... | |
#define | wcsupr_s(src, slen) _wcsupr_s_chk(src,slen,BOS(src)) |
Scans the string converting lowercase characters to uppercase, leaving all other characters unchanged. More... | |
#define | towfc_s(dest, dmax, src) _towfc_s_chk(dest,dmax,src,BOS(dest)) |
towfc_s() converts a wide character to fully fold-cased (lowercased with possible expansions), according to the Unicode 10.0 CaseFolding table. More... | |
#define | wcsfc_s(dest, dmax, src, lenp) _wcsfc_s_chk(dest,dmax,src,lenp,BOS(dest)) |
Converts the wide string via full case-folding NFD normalized to lowercase. More... | |
#define | wcsnorm_decompose_s(dest, dmax, src, lenp, iscompat) _wcsnorm_decompose_s_chk(dest,dmax,src,lenp,iscompat,BOS(dest)) |
Converts the wide string to the canonical NFD normalization, as defined in the latest Unicode standard, latest 10.0. More... | |
#define | wcsnorm_reorder_s(dest, dmax, src, len) _wcsnorm_reorder_s_chk(dest,dmax,src,len,BOS(dest)) |
Reorder all decomposed sequences in a wide string to NFD, as defined in the latest Unicode standard, latest 10.0. More... | |
#define | wcsnorm_compose_s(dest, dmax, src, lenp, iscontig) _wcsnorm_compose_s_chk(dest,dmax,src,lenp,iscontig,BOS(dest)) |
Combine all decomposed sequences in a wide string to NFC, as defined in the latest Unicode standard, latest 10.0. More... | |
#define | wcsnorm_s(dest, dmax, src, mode, lenp) _wcsnorm_s_chk(dest,dmax,src,mode,lenp,BOS(dest)) |
Converts the wide string to the canonical NFC or NFD normalization, as defined in the latest Unicode standard, latest 10.0. More... | |
Functions | |
EXTERN void | abort_handler_s (const char *restrict msg, void *restrict ptr, errno_t error) |
This function writes a message on the standard error stream in an implementation-defined format. More... | |
EXTERN void | ignore_handler_s (const char *restrict msg, void *restrict ptr, errno_t error) |
This function simply returns to the caller. More... | |
EXTERN constraint_handler_t | set_str_constraint_handler_s (constraint_handler_t handler) |
The set_str_constraint_handler_s function sets the runtime-constraint handler to be handler. More... | |
EXTERN errno_t | _strcat_s_chk (char *restrict dest, rsize_t dmax, const char *restrict src, const size_t destbos) BOS_CHK(dest) BOS_NULL(src) |
EXTERN errno_t | _strcpy_s_chk (char *restrict dest, rsize_t dmax, const char *restrict src, const size_t destbos) BOS_CHK(dest) BOS_NULL(src) |
EXTERN errno_t | _strncat_s_chk (char *restrict dest, rsize_t dmax, const char *restrict src, rsize_t slen, const size_t destbos, const size_t srcbos) BOS_ATTR((slen||dest||dmax) &&(_BOS_NULL(dest)||_BOS_ZERO(dest |
EXTERN errno_t empty dest or dmax | BOS_ATTR ((slen||dest||dmax) &&_BOS_OVR(dest, dmax), "dest overflow") BOS_OVR2_BUTZERO(src |
EXTERN errno_t | _strncpy_s_chk (char *restrict dest, rsize_t dmax, const char *restrict src, rsize_t slen, const size_t destbos, const size_t srcbos) BOS_CHK(dest) BOS_OVR2_BUTZERO(src |
EXTERN rsize_t | _strnlen_s_chk (const char *str, rsize_t smax, const size_t strbos) BOS_CHK2(str |
EXTERN char * | _strtok_s_chk (char *restrict dest, rsize_t *restrict dmaxp, const char *restrict delim, char **restrict ptr, const size_t destbos) BOS_NULL(ptr) |
EXTERN int | sprintf_s (char *restrict dest, rsize_t dmax, const char *restrict fmt,...) BOS_CHK(dest) BOS_FMT(fmt) |
EXTERN int | _vsprintf_s_chk (char *restrict dest, rsize_t dmax, const size_t destbos, const char *restrict fmt, va_list ap) BOS_CHK(dest) BOS_FMT(fmt) |
EXTERN int | snprintf_s (char *restrict dest, rsize_t dmax, const char *restrict fmt,...) BOS_CHK(dest) BOS_FMT(fmt) |
EXTERN int | _vsnprintf_s_chk (char *restrict dest, rsize_t dmax, const size_t destbos, const char *restrict fmt, va_list ap) BOS_CHK(dest) BOS_FMT(fmt) |
EXTERN int | sscanf_s (const char *restrict buffer, const char *restrict fmt,...) BOS_NULL(buffer) BOS_FMT(fmt) |
The sscanf_s function reads a formatted string, and writes to a list of arguments. More... | |
EXTERN int | fscanf_s (FILE *restrict stream, const char *restrict fmt,...) BOS_NULL(stream) BOS_FMT(fmt) |
The fscanf_s function reads a formatted string from a buffered FILE stream, and writes to a list of arguments. More... | |
EXTERN int | scanf_s (const char *restrict fmt,...) BOS_FMT(fmt) |
The scanf_s function reads a formatted string from stdin, and writes to a list of arguments. More... | |
EXTERN int | vscanf_s (const char *restrict fmt, va_list ap) BOS_FMT(fmt) |
The vscanf_s function reads a formatted string from stdin, and writes to a list of arguments. More... | |
EXTERN int | vfscanf_s (FILE *restrict stream, const char *restrict fmt, va_list ap) BOS_NULL(stream) BOS_FMT(fmt) |
The vfscanf_s function reads a formatted string from a buffered FILE stream, and writes to a list of arguments. More... | |
EXTERN int | vsscanf_s (const char *restrict dest, const char *restrict fmt, va_list ap) BOS_NULL(dest) BOS_FMT(fmt) |
The vsscanf_s function reads a formatted string, and writes to a list of arguments. More... | |
EXTERN int | printf_s (const char *restrict fmt,...) BOS_FMT(fmt) |
The printf_s function composes a string via the format string and writes it to a FILE buffer. More... | |
EXTERN int | fprintf_s (FILE *restrict stream, const char *restrict fmt,...) BOS_FMT(fmt) |
The fprintf_s function composes a string via the format string and writes it to a FILE buffer. More... | |
EXTERN int | vprintf_s (const char *restrict fmt, va_list ap) BOS_FMT(fmt) |
The vprintf_s function composes a string via the format string and writes it to a FILE buffer. More... | |
EXTERN int | vfprintf_s (FILE *restrict stream, const char *restrict fmt, va_list arg) BOS_FMT(fmt) |
The vfprintf_s function composes a string via the format string and writes it to a FILE buffer. More... | |
EXTERN errno_t | _strerror_s_chk (char *dest, rsize_t dmax, errno_t errnum, const size_t destbos) BOS_CHK(dest) |
EXTERN size_t | strerrorlen_s (errno_t errnum) |
The strerrorlen_s function returns the untruncated length of the textual description of the system error code errnum , identical to the description that would be printed by perror() . More... | |
EXTERN errno_t | _strcmp_s_chk (const char *dest, rsize_t dmax, const char *src, int *resultp, const size_t destbos, const size_t srcbos) BOS_CHK(dest) BOS_NULL(src) BOS_NULL(resultp) |
EXTERN errno_t | _strcasecmp_s_chk (const char *dest, rsize_t dmax, const char *src, int *resultp, const size_t destbos) BOS_CHK(dest) BOS_NULL(src) BOS_NULL(resultp) |
EXTERN errno_t | _strnatcmp_s_chk (const char *dest, rsize_t dmax, const char *src, const int fold_case, int *resultp, const size_t destbos, const size_t srcbos) BOS_CHK(dest) BOS_NULL(src) BOS_NULL(resultp) |
EXTERN errno_t | _strcasestr_s_chk (char *dest, rsize_t dmax, const char *src, rsize_t slen, char **substring, const size_t destbos, const size_t srcbos) BOS_CHK(dest) BOS_CHK2(src |
EXTERN errno_t slen | BOS_NULL (substring) |
EXTERN errno_t | _strcmpfld_s_chk (const char *dest, rsize_t dmax, const char *src, int *resultp, const size_t destbos) BOS_CHK(dest) BOS_NULL(src) BOS_NULL(resultp) |
EXTERN errno_t | _strcpyfld_s_chk (char *dest, const rsize_t dmax, const char *src, rsize_t slen, const size_t destbos) BOS_CHK_BUTZERO(dest |
EXTERN errno_t slen | BOS_OVR2_BUTZERO (src, slen) VAL_OVR2(slen |
EXTERN errno_t | _strcpyfldin_s_chk (char *dest, rsize_t dmax, const char *src, rsize_t slen, const size_t destbos) BOS_CHK_BUTZERO(dest |
EXTERN errno_t | _strcpyfldout_s_chk (char *dest, rsize_t dmax, const char *src, rsize_t slen, const size_t destbos) BOS_CHK_BUTZERO(dest |
EXTERN errno_t | _strcspn_s_chk (const char *dest, rsize_t dmax, const char *src, rsize_t slen, rsize_t *countp, const size_t destbos, const size_t srcbos) BOS_CHK(dest) BOS_OVR2(src |
EXTERN errno_t slen | BOS_NULL (countp) |
EXTERN errno_t | _strfirstchar_s_chk (char *dest, rsize_t dmax, char c, char **firstp, const size_t destbos) BOS_CHK(dest) BOS_NULL(firstp) |
EXTERN errno_t | _strfirstdiff_s_chk (const char *dest, rsize_t dmax, const char *src, rsize_t *resultp, const size_t destbos) BOS_CHK(dest) BOS_NULL(src) BOS_NULL(resultp) |
EXTERN bool | _strisalphanumeric_s_chk (const char *dest, rsize_t dmax, const size_t destbos) BOS_CHK2(dest |
EXTERN bool | _strisascii_s_chk (const char *dest, rsize_t dmax, const size_t destbos) BOS_CHK2(dest |
EXTERN bool | _strisdigit_s_chk (const char *dest, rsize_t dmax, const size_t destbos) BOS_CHK2(dest |
EXTERN bool | _strishex_s_chk (const char *dest, rsize_t dmax, const size_t destbos) BOS_CHK2(dest |
EXTERN bool | _strislowercase_s_chk (const char *dest, rsize_t dmax, const size_t destbos) BOS_CHK2(dest |
EXTERN bool | _strismixedcase_s_chk (const char *dest, rsize_t dmax, const size_t destbos) BOS_CHK2(dest |
EXTERN bool | _strispassword_s_chk (const char *dest, rsize_t dmax, const size_t destbos) BOS_CHK2(dest |
EXTERN bool | _strisuppercase_s_chk (const char *dest, rsize_t dmax, const size_t destbos) BOS_CHK2(dest |
EXTERN errno_t | _strlastchar_s_chk (char *dest, rsize_t dmax, char c, char **lastp, const size_t destbos) BOS_CHK(dest) BOS_NULL(lastp) |
EXTERN errno_t | _strlastdiff_s_chk (const char *dest, rsize_t dmax, const char *src, rsize_t *resultp, const size_t destbos) BOS_CHK(dest) BOS_NULL(src) BOS_NULL(resultp) |
EXTERN errno_t | _strljustify_s_chk (char *dest, rsize_t dmax, const size_t destbos) BOS_CHK(dest) |
EXTERN rsize_t | _strnterminate_s_chk (char *dest, rsize_t dmax, const size_t destbos) BOS_CHK2(dest |
EXTERN errno_t | _strpbrk_s_chk (char *dest, rsize_t dmax, char *src, rsize_t slen, char **firstp, const size_t destbos, const size_t srcbos) BOS_CHK(dest) BOS_OVR2(src |
EXTERN errno_t slen | BOS_NULL (firstp) |
EXTERN errno_t | _strfirstsame_s_chk (const char *dest, rsize_t dmax, const char *src, rsize_t *resultp, const size_t destbos) BOS_CHK(dest) BOS_NULL(src) BOS_NULL(resultp) |
EXTERN errno_t | _strlastsame_s_chk (const char *dest, rsize_t dmax, const char *src, rsize_t *resultp, const size_t destbos) BOS_CHK(dest) BOS_NULL(src) BOS_NULL(resultp) |
EXTERN errno_t | _strprefix_s_chk (const char *dest, rsize_t dmax, const char *src, const size_t destbos) BOS_CHK(dest) BOS_NULL(src) |
EXTERN errno_t | _strremovews_s_chk (char *dest, rsize_t dmax, const size_t destbos) BOS_CHK(dest) |
EXTERN errno_t | _strspn_s_chk (const char *dest, rsize_t dmax, const char *src, rsize_t slen, rsize_t *countp, const size_t destbos, const size_t srcbos) BOS_CHK(dest) BOS_CHK2(src |
EXTERN errno_t | _strstr_s_chk (char *dest, rsize_t dmax, const char *src, rsize_t slen, char **substringp, const size_t destbos, const size_t srcbos) BOS_CHK(dest) BOS_OVR2(src |
EXTERN errno_t slen | BOS_NULL (substringp) |
EXTERN errno_t | _strchr_s_chk (const char *restrict dest, rsize_t dmax, const int ch, char **restrict resultp, const size_t destbos) BOS_CHK(dest) VAL_OVR2(ch |
EXTERN errno_t | BOS_NULL (resultp) |
EXTERN errno_t | _strrchr_s_chk (const char *restrict dest, rsize_t dmax, const int ch, char **restrict resultp, const size_t destbos) BOS_CHK(dest) VAL_OVR2(ch |
EXTERN errno_t | _strtolowercase_s_chk (char *dest, rsize_t dmax, const size_t destbos) BOS_CHK2(dest |
EXTERN errno_t | _strtouppercase_s_chk (char *dest, rsize_t dmax, const size_t destbos) BOS_CHK2(dest |
EXTERN errno_t | _strzero_s_chk (char *dest, rsize_t dmax, const size_t destbos) BOS_CHK(dest) |
EXTERN errno_t | _strcoll_s_chk (const char *restrict dest, rsize_t dmax, const char *restrict src, int *resultp, const size_t destbos) BOS_CHK(dest) BOS_NULL(src) BOS_NULL(resultp) |
EXTERN errno_t | _strset_s_chk (char *restrict dest, rsize_t dmax, int value, const size_t destbos) BOS_CHK(dest) VAL_OVR2(value |
EXTERN errno_t | _strnset_s_chk (char *restrict dest, rsize_t dmax, int value, rsize_t n, const size_t destbos) BOS_CHK(dest) BOS_OVR2_BUTZERO(dest |
EXTERN errno_t n | VAL_OVR2 (value, 255) VAL_OVR2_BUTZERO(n |
EXTERN errno_t | _mbstowcs_s_chk (size_t *restrict retvalp, wchar_t *restrict dest, rsize_t dmax, const char *restrict src, rsize_t len, const size_t destbos) BOS_ATTR(!_BOS_NULL(dest) &&_BOS_ZERO(dest |
EXTERN errno_t empty dmax | BOS_ATTR (!_BOS_NULL(dest) &&_BOSW_OVR(dest, dmax), "dest overflow") BOS_ATTR(!_BOS_NULL(dest) &&(void *) dest == *srcp |
EXTERN errno_t empty dmax dest overlap | BOS_CHK2 (src, len) |
EXTERN errno_t | _mbsrtowcs_s_chk (size_t *restrict retvalp, wchar_t *restrict dest, rsize_t dmax, const char **restrict srcp, rsize_t len, mbstate_t *restrict ps, const size_t destbos) BOS_NULL(retvalp) BOS_NULL(srcp) BOS_NULL(ps) BOS_ATTR(!_BOS_NULL(dest) &&_BOS_ZERO(dest |
EXTERN errno_t empty dmax dest overlap | BOS_ATTR (dmax &&len > dmax, "len overflow >dmax") |
EXTERN errno_t | _wcsrtombs_s_chk (size_t *restrict retvalp, char *restrict dest, rsize_t dmax, const wchar_t **restrict srcp, rsize_t len, mbstate_t *restrict ps, const size_t destbos) BOS_NULL(retvalp) BOS_NULL(ps) BOS_ATTR(!_BOS_NULL(dest) &&_BOS_OVR(dest |
EXTERN errno_t dest overflow | BOS_ATTR (!_BOS_NULL(dest) &&(void *) dest==(void *) srcp, "dest overlap") BOS_ATTR(dmax &&len > dmax |
EXTERN errno_t | _wcstombs_s_chk (size_t *restrict retvalp, char *restrict dest, rsize_t dmax, const wchar_t *restrict src, rsize_t len, const size_t destbos) BOS_NULL(retvalp) BOS_CHK(dest) BOSW_CHK2(src |
EXTERN errno_t | _wcrtomb_s_chk (size_t *restrict retvalp, char *restrict dest, rsize_t dmax, wchar_t wc, mbstate_t *restrict ps, const size_t destbos) BOS_NULL(retvalp) BOS_CHK(dest) BOS_NULL(ps) VAL_OVR2(wc |
EXTERN errno_t | _wctomb_s_chk (int *restrict retvalp, char *restrict dest, rsize_t dmax, wchar_t wc, const size_t destbos) BOS_ATTR(!_BOS_NULL(dest) &&(!dmax||dmax > RSIZE_MAX_STR||_BOS_OVR(dest |
EXTERN errno_t dest overflow or empty | VAL_OVR2 (wc, 0x10ffff) |
EXTERN size_t | _wcsnlen_s_chk (const wchar_t *dest, size_t dmax, const size_t destbos) BOSW_CHK(dest) |
EXTERN errno_t | _wcscpy_s_chk (wchar_t *restrict dest, rsize_t dmax, const wchar_t *restrict src, const size_t destbos) BOSW_CHK(dest) BOS_NULL(src) |
EXTERN errno_t | _wcsncpy_s_chk (wchar_t *restrict dest, rsize_t dmax, const wchar_t *restrict src, rsize_t slen, const size_t destbos, const size_t srcbos) BOSW_CHK(dest) BOSW_OVR2(src |
EXTERN errno_t | _wcscat_s_chk (wchar_t *restrict dest, rsize_t dmax, const wchar_t *restrict src, const size_t destbos) BOSW_CHK(dest) BOS_NULL(src) |
EXTERN errno_t | _wcsncat_s_chk (wchar_t *restrict dest, rsize_t dmax, const wchar_t *restrict src, rsize_t slen, const size_t destbos, const size_t srcbos) BOS_ATTR(slen &&(_BOS_NULL(dest)||_BOS_ZERO(dest |
EXTERN errno_t dmax empty dest or dmax | BOS_ATTR (slen &&(_BOSW_OVR(src, slen)||_BOS_NULL(src)), "src overflow or empty") |
EXTERN wchar_t * | _wcstok_s_chk (wchar_t *restrict dest, rsize_t *restrict dmaxp, const wchar_t *restrict delim, wchar_t **restrict ptr, const size_t destbos) BOS_NULL(ptr) |
EXTERN int | swprintf_s (wchar_t *restrict dest, rsize_t dmax, const wchar_t *restrict fmt,...) BOSW_CHK(dest) BOS_FMT(fmt) |
EXTERN int | _vswprintf_s_chk (wchar_t *restrict dest, rsize_t dmax, const size_t destbos, const wchar_t *restrict fmt, va_list ap) BOSW_CHK(dest) BOS_FMT(fmt) |
EXTERN int | snwprintf_s (wchar_t *restrict dest, rsize_t dmax, const wchar_t *restrict fmt,...) BOSW_CHK(dest) BOS_FMT(fmt) |
EXTERN int | _vsnwprintf_s_chk (wchar_t *restrict dest, rsize_t dmax, const size_t destbos, const wchar_t *restrict fmt, va_list ap) BOSW_CHK(dest) BOS_FMT(fmt) |
EXTERN int | wprintf_s (const wchar_t *restrict fmt,...) BOS_FMT(fmt) |
The wprintf_s function prints formatted output to stdout as wide string. More... | |
EXTERN int | vwprintf_s (const wchar_t *restrict fmt, va_list ap) BOS_FMT(fmt) |
The vwprintf_s function prints formatted output to stdout as wide string. More... | |
EXTERN int | fwprintf_s (FILE *restrict stream, const wchar_t *restrict fmt,...) BOS_NULL(stream) BOS_FMT(fmt) |
The fwprintf_s function prints formatted output to a wide stream. More... | |
EXTERN int | vfwprintf_s (FILE *restrict stream, const wchar_t *restrict fmt, va_list ap) BOS_NULL(stream) BOS_FMT(fmt) |
The vfwprintf_s function prints formatted output to a wide stream. More... | |
EXTERN int | swscanf_s (const wchar_t *restrict src, const wchar_t *restrict fmt,...) BOS_NULL(src) BOS_FMT(fmt) |
The swscanf_s function reads a formatted wide string. More... | |
EXTERN int | vswscanf_s (const wchar_t *restrict src, const wchar_t *restrict fmt, va_list ap) BOS_NULL(src) BOS_FMT(fmt) |
The vswscanf_s function reads a formatted wide string. More... | |
EXTERN int | wscanf_s (const wchar_t *restrict fmt,...) BOS_FMT(fmt) |
The wscanf_s function reads a formatted wide string from stdin. More... | |
EXTERN int | vwscanf_s (const wchar_t *restrict fmt, va_list ap) BOS_FMT(fmt) |
The vwscanf_s function reads a formatted wide string from stdin. More... | |
EXTERN int | fwscanf_s (FILE *restrict stream, const wchar_t *restrict fmt,...) BOS_NULL(stream) BOS_FMT(fmt) |
The fwscanf_s function reads a formatted wide string. More... | |
EXTERN int | vfwscanf_s (FILE *restrict stream, const wchar_t *restrict fmt, va_list ap) BOS_NULL(stream) BOS_FMT(fmt) |
The vfwscanf_s function reads a formatted wide string. More... | |
EXTERN errno_t | _wcsstr_s_chk (wchar_t *restrict dest, rsize_t dmax, const wchar_t *restrict src, rsize_t slen, wchar_t **restrict substringp, const size_t destbos, const size_t srcbos) BOSW_CHK(dest) BOSW_OVR2(src |
EXTERN errno_t | _wcscmp_s_chk (const wchar_t *restrict dest, rsize_t dmax, const wchar_t *restrict src, rsize_t smax, int *resultp, const size_t destbos, const size_t srcbos) BOSW_CHK(dest) BOSW_CHK2(src |
EXTERN errno_t | _wcsncmp_s_chk (const wchar_t *restrict dest, rsize_t dmax, const wchar_t *restrict src, rsize_t smax, rsize_t count, int *resultp, const size_t destbos, const size_t srcbos) BOSW_CHK(dest) BOSW_CHK2(src |
EXTERN errno_t | _wcsicmp_s_chk (const wchar_t *restrict dest, rsize_t dmax, const wchar_t *restrict src, rsize_t smax, int *resultp, const size_t destbos, const size_t srcbos) BOSW_CHK(dest) BOSW_CHK2(src |
EXTERN errno_t | _wcsnatcmp_s_chk (const wchar_t *restrict dest, rsize_t dmax, const wchar_t *restrict src, rsize_t smax, const int fold_case, int *resultp, const size_t destbos, const size_t srcbos) BOSW_CHK(dest) BOSW_CHK2(src |
EXTERN errno_t | _wcsset_s_chk (wchar_t *restrict dest, rsize_t dmax, const wchar_t value, const size_t destbos) BOSW_CHK(dest) VAL_OVR2(value |
EXTERN errno_t | _wcsnset_s_chk (wchar_t *restrict dest, rsize_t dmax, const wchar_t value, size_t n, const size_t destbos) BOSW_CHK(dest) VAL_OVR2(value |
EXTERN errno_t | _wcscoll_s_chk (const wchar_t *restrict dest, rsize_t dmax, const wchar_t *restrict src, rsize_t smax, int *resultp, const size_t destbos, const size_t srcbos) BOSW_CHK(dest) BOSW_CHK2(src |
EXTERN errno_t | _wcslwr_s_chk (wchar_t *restrict src, rsize_t slen, const size_t srcbos) BOSW_OVR2_BUTZERO(src |
EXTERN errno_t | _wcsupr_s_chk (wchar_t *restrict src, rsize_t slen, const size_t srcbos) BOSW_OVR2_BUTZERO(src |
EXTERN int | iswfc (const uint32_t wc) VAL_OVR2(wc |
EXTERN int EXTERN int | _towfc_s_chk (wchar_t *restrict dest, rsize_t dmax, const uint32_t src, const size_t destbos) BOSW_CHK(dest) BOS_ATTR(dmax< 4 |
Variables | |
EXTERN errno_t | dmax |
EXTERN errno_t empty dest or dmax | slen |
EXTERN rsize_t | smax |
EXTERN errno_t empty * | dest |
EXTERN errno_t dmax | !dmax |
#define EXTERN extern |
#define RSIZE_MIN_STR ( 1 ) |
The shortest string is a null string!!
#define RSIZE_MAX_WSTR ( RSIZE_MAX_STR/sizeof(wchar_t) ) |
wide chars
#define SAFE_STR_MIN_LOWERCASE ( 2 ) |
The makeup of a password.
#define SAFE_STR_MIN_UPPERCASE ( 2 ) |
#define SAFE_STR_MIN_NUMBERS ( 1 ) |
#define SAFE_STR_MIN_SPECIALS ( 1 ) |
#define SAFE_STR_PASSWORD_MIN_LENGTH ( 6 ) |
#define SAFE_STR_PASSWORD_MAX_LENGTH ( 32 ) |
#define sl_default_handler ignore_handler_s |
The strcat_s function appends a copy of the string pointed to by src (including the terminating null character) to the end of the string pointed to by dest.
The initial character from src overwrites the null character at the end of dest.
All elements following the terminating null character (if any) written by strcat_s in the array of dmax characters pointed to by dest take unspecified values when strcat_s returns. With SAFECLIB_STR_NULL_SLACK defined the rest of dest is cleared with NULL bytes. With modern compilers and constant arguments most errors will be caught at compile-time.
[out] | dest | pointer to string that will be extended by src if dmax allows. The string is null terminated. If the resulting concatenated string is less than dmax, the remaining slack space is nulled. |
[in] | dmax | restricted maximum length of the resulting dest, including the null |
[in] | src | pointer to the string that will be concatenaed to string dest |
strncat_s
.EOK | when successful operation, all the characters from src were appended to dest and the result in dest is null terminated. |
ESNULLP | when dest or src is a NULL pointer |
ESZEROL | when dmax = 0 |
ESLEMAX | when dmax > RSIZE_MAX_STR |
EOVERFLOW | when dmax > size of dest (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != sizeof(dest) and –enable-error-dmax |
ESUNTERM | when dest not terminated in the first dmax bytes |
ESOVRLP | when src overlaps with dest |
The strcpy_s function copies the string pointed to by src (including the terminating null character) into the array pointed to by dest.
With SAFECLIB_STR_NULL_SLACK defined all elements following the terminating null character (if any) written by strcpy_s in the array of dmax characters pointed to by dest are nulled when strcpy_s returns. With modern compilers and constant arguments most errors will be caught at compile-time.
[out] | dest | pointer to string that will be replaced by src. |
[in] | dmax | restricted maximum length of dest |
[in] | src | pointer to the string that will be copied to dest |
EOK | when successful operation, the characters in src were copied into dest and the result is null terminated. |
ESNULLP | when dest or src is a NULL pointer |
ESZEROL | when dmax = 0 |
ESLEMAX | when dmax > RSIZE_MAX_STR |
EOVERFLOW | when dmax > size of dest (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != size of dest and –enable-error-dmax |
ESOVRLP | when strings overlap |
ESNOSPC | when dest < src |
The strncat_s function appends a copy of the string pointed to by src (including the terminating null character) to the end of the string pointed to by dest.
The initial character from src overwrites the null character at the end of dest.
All elements following the terminating null character (if any) written by strncat_s in the array of dmax characters pointed to by dest take unspecified values when strncat_s returns. With SAFECLIB_STR_NULL_SLACK defined the rest is cleared with NULL bytes. With modern compilers and constant arguments most errors will be caught at compile-time.
[out] | dest | pointer to string that will be extended by src if dmax allows. The string is null terminated. If the resulting concatenated string is less than dmax, the remaining slack space is nulled. |
[in] | dmax | restricted maximum length of the resulting dest, including the null |
[in] | src | pointer to the string that will be concatenaed to string dest |
[in] | slen | maximum characters to append |
EOK | successful operation, when slen == 0 or all the characters are copied from src and dest is null terminated. As special case, analog to msvcrt: when slen == 0 and dmax is big enough for dest, also return EOK, but clear dest. |
ESNULLP | when dest/src is NULL pointer |
ESZEROL | when dmax = 0 |
ESLEMAX | when dmax/slen > RSIZE_MAX_STR |
EOVERFLOW | when dmax/slen > size of dest/src (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != size of dest and –enable-error-dmax |
ESUNTERM | when dest not terminated |
ESOVRLP | when src overlaps with dest |
If dmax != sizeof(dest): With –enable-warn-dmax ESLEWRNG will be passed to the constraint handler. With –enable-error-dmax this error will be fatal, but dest will not be cleared. With clang-5 and/or diagnose_if and __builtin_object_size() support wrong dmax values will be caught at compile-time.
The strncpy_s function copies not more than slen successive characters (characters that follow a null character are not copied) from the array pointed to by src to the array pointed to by dest.
If no null character was copied from src, then dest[n] is set to a null character, thus guaranteeing null termination.
All elements following the terminating null character (if any) written by strncpy_s in the array of dmax characters pointed to by dest take unspecified values when strncpy_s returns. With SAFECLIB_STR_NULL_SLACK defined the rest is cleared with NULL bytes. With modern compilers and constant arguments most errors will be caught at compile-time.
[out] | dest | pointer to string that will be replaced by src. |
[in] | dmax | restricted maximum length of dest |
[in] | src | pointer to the string that will be copied to dest |
[in] | slen | the maximum number of characters to copy from src |
EOK | successful operation, when slen == 0 or the characters in src were copied to dest and the result is null terminated. |
ESNULLP | when dest/src is NULL pointer |
ESZEROL | when dmax = 0 |
ESLEMAX | when dmax/slen > RSIZE_MAX_STR |
EOVERFLOW | when dmax/slen > size of dest/src (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != size of dest and –enable-error-dmax |
ESOVRLP | when strings overlap |
ESNOSPC | when src longer than dest |
If dmax != sizeof(dest): With –enable-warn-dmax ESLEWRNG will be passed to the constraint handler. With –enable-error-dmax this error will be fatal, but dest will not be cleared.
#define strnlen_s | ( | str, | |
smax | |||
) | _strnlen_s_chk(str,smax,BOS(str)) |
The strnlen_s function computes the length of the string pointed to by str
, refusing to read past smax.
str | pointer to string |
smax | maximum length of string |
str
is NULL, then strnlen_s
returns 0
. Otherwise, the strnlen_s
function returns the number of characters that precede the terminating null character. If there is no null character in the first smax
characters of str
then strnlen_s
returns smax. At most the first smax
or sizeof(str)
characters of str are accessed by strnlen_s
.#define strtok_s | ( | dest, | |
dmaxp, | |||
delim, | |||
ptr | |||
) | _strtok_s_chk(dest,dmaxp,delim,ptr,BOS(dest)) |
A sequence of calls to the strtok_s function breaks the string pointed to by dest into a sequence of tokens, each of which is delimited by a character from the string pointed to by delim.
The fourth argument points to a caller-provided char pointer into which the strtok_s function stores information necessary for it to continue scanning the same string.
The first call in a sequence has a non-null first argument and dmax points to an object whose value is the number of elements in the character array pointed to by the first argument. The first call stores an initial value in the object pointed to by ptr and updates the value pointed to by dmax to reflect the number of elements that remain in relation to ptr. Subsequent calls in the sequence have a null first argument and the objects pointed to by dmax and ptr are required to have the values stored by the previous call in the sequence, which are then updated. The separator string pointed to by delim may be different from call to call.
The first call in the sequence searches the string pointed to by dest for the first character that is not contained in the current separator string pointed to by delim. If no such character is found, then there are no tokens in the string pointed to by dest and the strtok_s function returns a null pointer. If such a character is found, it is the start of the first token.
The strtok_s function then searches from there for the first character in dest that is contained in the current separator string. If no such character is found, the current token extends to the end of the string pointed to by dest, and subsequent searches in the same string for a token return a null pointer. If such a character is found, it is overwritten by a null character, which terminates the current token.
In all cases, the strtok_s function stores sufficient information in the pointer pointed to by ptr so that subsequent calls, with a null pointer for dest and the unmodified pointer value for ptr, shall start searching just past the element overwritten by a null character (if any).
delim uses a STRTOK_DELIM_MAX_LEN of 16.
[in] | dest | pointer to string to tokenize |
[out] | dmaxp | pointer to restricted maximum length of dest string |
[in] | delim | pointer to delimiter string (len < 255) |
[out] | ptr | returned pointer to token |
char* strtok_s (char *str, const char *delim, char **ctx)
errno is set to: ESNULLP when dest/delim/ptr is NULL pointer ESZEROL when *dmax = 0 ESLEMAX when *dmax > RSIZE_MAX_STR EOVERFLOW when *dmax > size of dest ESLEWRNG when *dmax != size of dest and –enable-error-dmax ESUNTERM when unterminated string C11 just returns EINVAL
The vsprintf_s function composes a string with the same content that would be printed if format was used on printf
.
Instead of being printed, the content is stored in dest. 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.
[out] | dest | pointer to string that will be written into. |
[in] | dmax | restricted maximum length of dest |
[in] | fmt | format-control string. |
[in] | ap | optional arguments |
-ESNULLP | when fmt is NULL pointer -ESNULLP when dest is NULL and dmax > 0 -ESZEROL when dmax = 0 and dest is not NULL -ESLEMAX when dmax > RSIZE_MAX_STR -EOVERFLOW when dmax > size of dest -ESNOSPC when return value exceeds dmax unless dmax is zero and dest is NULL -EINVAL when fmt contains n |
-1 | if an encoding error or a runtime constraint violation in the libc function vsnprintf occured. |
errno
.The truncating vsnprintf_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. At most dmax characters are written. It is guaranteed that dest will be null-terminated.
errno
is set on error. However, the safeclib extended ES*
errors do not set errno
, only when the underlying system vsnprintf
call fails, errno
is set.[out] | dest | pointer to string that will be written into. |
[in] | dmax | restricted maximum length of dest |
[in] | fmt | format-control string. |
[in] | ap | optional arguments |
fmt
shall not be a null pointer. dest
shall not be a null pointer. dmax
shall not be zero. dmax
shall not be greater than RSIZE_MAX_STR
and the size of dest. fmt
shall not contain the conversion specifier n
. s
is a null pointer. (not yet) dest
is too small for the formatted text, including the terminating null, then the buffer is truncated and null terminated.-ESNULLP | when dest/fmt is NULL pointer |
-ESZEROL | when dmax == 0 |
-ESLEMAX | when dmax > RSIZE_MAX_STR |
-EOVERFLOW | when dmax > size of dest |
-EINVAL | when fmt contains n |
The strerror_s
function returns a pointer to the textual description of the system error code errnum, identical to the description that would be printed by perror().
In addition to strerror()
it adds the size of the destination array in order to prevent buffer overflow, and it truncates overlong error messages with "...".
No more than dmax-1 bytes are written, the buffer is always null-terminated. If the message had to be truncated to fit the buffer and dmax is greater than 3, then only dmax-4 bytes are written, and the characters "..." are appended before the null terminator. The behavior is undefined if writing to dest occurs past the end of the array, which can happen when the size of the buffer pointed to by dest is less than the number of characters in the error message which in turn is less than dmax.
[out] | dest | pointer to a user-provided string buffer |
[in] | dmax | restricted maximum length of dest |
[in] | errnum | integer value referring to an error code |
EOK | on success |
ESNULLP | when dest is a NULL pointer |
ESZEROL | when dmax = 0 |
ESLEMAX | when dmax > RSIZE_MAX_STR |
EOVERFLOW | when dmax > size of dest (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != size of dest and –enable-error-dmax |
ESLEMIN | when the result would be longer than 4 and dmax < 4 |
#define strcmp_s | ( | dest, | |
dmax, | |||
src, | |||
resultp | |||
) | _strcmp_s_chk(dest,dmax,src,resultp,BOS(dest),BOS(src)) |
Compares string src to string dest.
[in] | dest | pointer to string to compare against |
[in] | dmax | restricted maximum length of string dest |
[in] | src | pointer to the string to be compared to dest |
[out] | resultp | pointer to int result, greater than 0, equal to 0 or less than 0, if the string pointed to by dest is greater than, equal to or less than the string pointed to by src respectively. |
>0 | when dest greater than src |
0 | when strings the same |
<0 | when dest less than src |
EOK | when comparison is complete |
ESUNTERM | when dest or src is unterminated, or dmax is too small. |
ESNULLP | when dest/src/resultp is NULL pointer |
ESZEROL | when dmax = 0 |
ESLEMAX | when dmax > RSIZE_MAX_STR |
EOVERFLOW | when dmax > size of dest (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != sizeof(dest) and –enable-error-dmax |
#define strcasecmp_s | ( | dest, | |
dmax, | |||
src, | |||
resultp | |||
) | _strcasecmp_s_chk(dest,dmax,src,resultp,BOS(dest)) |
Case insensitive string comparison by converting to uppercase prior to the compare.
[in] | dest | pointer to string to compare against |
[in] | dmax | restricted maximum length of string dest |
[in] | src | pointer to the string to be compared to dest |
[out] | resultp | pointer to int result, greater than 0, equal to 0 or less than 0, if the string pointed to by dest is greater than, equal to or less than the string pointed to by src respectively. |
>0 | when dest greater than src |
0 | when strings the same |
<0 | when dest less than src |
EOK | when comparison is complete |
ESNULLP | when dest/src/resultp is NULL pointer |
ESZEROL | when dmax = 0 |
ESLEMAX | when dmax > RSIZE_MAX_STR |
EOVERFLOW | when dmax > size of dest (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != size of dest and –enable-error-dmax |
#define strnatcmp_s | ( | dest, | |
dmax, | |||
src, | |||
resultp | |||
) | _strnatcmp_s_chk(dest,dmax,src,0,resultp,BOS(dest),BOS(src)) |
Natural order comparison of strings.
The longest run of numbers wins over alpha chars.
[in] | dest | pointer to string to compare against |
[in] | dmax | restricted maximum length of string dest |
[in] | src | pointer to the string to be compared to dest |
[out] | resultp | pointer to int result, greater than 0, equal to 0 or less than 0, if the string pointed to by dest is greater than, equal to or less than the string pointed to by src respectively. |
EOK | when comparison is complete |
ESUNTERM | when dest or src is unterminated, or dmax is too small. |
ESNULLP | when dest/src/resultp is NULL pointer |
ESZEROL | when dmax = 0 |
ESLEMAX | when dmax > RSIZE_MAX_STR |
EOVERFLOW | when dmax > size of dest (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != size of dest and –enable-error-dmax |
#define strnatcasecmp_s | ( | dest, | |
dmax, | |||
src, | |||
resultp | |||
) | _strnatcasecmp_s_chk(dest,dmax,src,1,resultp,BOS(dest),BOS(src)) |
#define strcasestr_s | ( | dest, | |
dmax, | |||
src, | |||
slen, | |||
substring | |||
) | _strcasestr_s_chk(dest,dmax,src,slen,substring,BOS(dest),BOS(src)) |
The strcasestr_s() function locates the first occurrence of the substring pointed to by src which would be located in the string pointed to by dest.
The comparison is case insensitive.
[in] | dest | pointer to string to be searched for the substring |
[in] | dmax | restricted maximum length of dest string |
[in] | src | pointer to the substring |
[in] | slen | maximum length of src string |
[out] | substring | returned pointer to the substring |
EOK | when successful operation, substring found. |
ESNULLP | when dst/src/substring is NULL pointer |
ESZEROL | when dmax/slen = 0 |
ESLEMAX | when dmax/slen > RSIZE_MAX_STR |
EOVERFLOW | when dmax/slen > size of dest/src (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != size of dest and –enable-error-dmax |
ESNOTFND | when substring not found |
Compares the character array pointed to by src to the character array pointed to by dest for dmax characters.
The null terminator does not stop the comparison.
[in] | dest | pointer to string to compare against |
[in] | dmax | restricted maximum length of string dest |
[in] | src | pointer to the string to be compared to dest |
[out] | resultp | pointer to int result. greater than 0, equal to 0 or less than 0, if the string pointed to by dest is greater than, equal to or less than the string pointed to by src respectively. |
>0 | when dest greater than src |
0 | when the strings are the same |
<0 | when dest less than src |
EOK | when comparison is complete |
ESNULLP | when dest/src/resultp is NULL pointer |
ESZEROL | when dmax = 0 |
ESLEMAX | when dmax > RSIZE_MAX_STR |
EOVERFLOW | when dmax > size of dest (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != size of dest and –enable-error-dmax |
#define strcspn_s | ( | dest, | |
dmax, | |||
src, | |||
slen, | |||
countp | |||
) | _strcspn_s_chk(dest,dmax,src,slen,countp,BOS(dest),BOS(src)) |
This function computes the prefix length of the string pointed to by dest which consists entirely of characters that are excluded from the string pointed to by src.
The scanning stops at the first null in dest or after dmax characters. The exclusion string is checked to the null or after slen characters.
[in] | dest | pointer to string to determine the prefix |
[in] | dmax | restricted maximum length of string dest |
[in] | src | pointer to exclusion string |
[in] | slen | restricted maximum length of string src |
[out] | countp | pointer to a count variable that will be updated with the dest substring length |
EOK | when operation is successful |
ESNULLP | when dest/src/count is NULL pointer |
ESZEROL | when dmax/slen = 0 |
ESLEMAX | when dmax/slen > RSIZE_MAX_STR |
EOVERFLOW | when dmax > size of dest (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != sizeof(dest) and –enable-error-dmax |
This function returns a pointer to the first occurrence of character c in dest.
The scanning stops at the first null or after dmax characters.
[in] | dest | pointer to string to compare against |
[in] | dmax | restricted maximum length of string |
[in] | c | character to locate |
[out] | firstp | returned pointer to first occurrence of c |
EOK | when pointer to first occurrence is returned |
ESNULLP | when dest/firstp is NULL pointer |
ESZEROL | when dmax = 0 |
ESLEMAX | when dmax > RSIZE_MAX_STR |
EOVERFLOW | when dmax > size of dest (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != sizeof(dest) and –enable-error-dmax |
#define strfirstdiff_s | ( | dest, | |
dmax, | |||
src, | |||
resultp | |||
) | _strfirstdiff_s_chk(dest,dmax,src,resultp,BOS(dest)) |
Returns the index of the first character that is different between dest and src.
Index is valid only for OK. The scanning stops at the first null in dest or src, or after dmax characters.
[in] | dest | pointer to string to compare against |
[in] | dmax | restricted maximum length of string dest |
[in] | src | pointer to the string to be compared to dest |
[out] | resultp | pointer to returned index to first difference |
EOK | when index to first diff is returned in resultp |
ESNODIFF | when no difference |
ESNULLP | when dest/src/resultp is NULL pointer |
ESZEROL | when dmax = 0 |
ESLEMAX | when dmax > RSIZE_MAX_STR |
EOVERFLOW | when dmax > size of dest (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != sizeof(dest) and –enable-error-dmax |
This function checks if the entire string contains alphanumerics.
The scanning stops at the first null or after smax characters.
dest | pointer to string |
dmax | maximum length of string |
This function checks if the entire string contains ascii characters.
The scanning stops at the first null or at most dmax characters.
dest | pointer to string |
dmax | maximum length of string |
This function checks that the entire string contains digits.
The scanning stops at the first null or after dmax characters.
dest | pointer to string |
dmax | maximum length of string |
This function checks that the entire string contains hex characters.
The scanning stops at the first null or after dmax characters.
dest | pointer to string |
dmax | maximum length of string |
This function checks if entire string is lowercase.
The scanning stops at the first null or after dmax characters.
dest | pointer to string |
dmax | maximum length of string |
This function checks that the entire string is mixed case.
The scanning stops at the first null or after dmax characters.
dest | pointer to string |
dmax | maximum length of string |
This function validates the make-up of a password string.
-Password must have mininmum SAFE_STR_PASSWORD_MIN_LENGTH characters
-Password can have maximum SAFE_STR_PASSWORD_MAX_LENGTH characters
-Password must have at least SAFE_STR_MIN_LOWERCASE lower case characters
-Password must have at least SAFE_STR_MIN_UPPERCASE upper case characters
-Password must have at least SAFE_STR_MIN_NUMBERS numbers
-Password must have at least SAFE_STR_MIN_SPECIALS special characters
dest | pointer to string |
dmax | maximum length of password string |
This function checks if entire string is uppercase The scanning stops at the first null or after dmax characters.
dest | pointer to string |
dmax | maximum length of string |
Returns a pointer to the last occurrence of character c in dest.
The scanning stops at null or after dmax characters.
[in] | dest | pointer to string to compare against |
[in] | dmax | restricted maximum length of string |
[in] | c | character to locate |
[out] | lastp | returned pointer to last occurrence of c |
EOK | when pointer to last occurrence is returned |
ESNULLP | when dst/first is NULL pointer |
ESZEROL | when dmax = 0 |
ESLEMAX | when dmax > RSIZE_MAX_STR |
EOVERFLOW | when dmax > size of dest (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != size of dest and –enable-error-dmax |
#define strlastdiff_s | ( | dest, | |
dmax, | |||
src, | |||
resultp | |||
) | _strlastdiff_s_chk(dest,dmax,src,resultp,BOS(dest)) |
Returns the index of the last character that is different between dest and src.
Index is valid only for EOK. The scanning stops at the first null in dest or src, or after dmax characters.
[in] | dest | pointer to string to compare against |
[in] | dmax | restricted maximum length of string dest |
[in] | src | pointer to the string to be compared to dest |
[out] | resultp | pointer to returned index to last difference |
EOK | when index to last diff is returned in resultp |
ESNODIFF | when no difference |
ESNULLP | when dest/src/idx is NULL pointer |
ESZEROL | when dmax = 0 |
ESLEMAX | when dmax > RSIZE_MAX_STR |
EOVERFLOW | when dmax > size of dest (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != sizeof(dest) and –enable-error-dmax |
Removes beginning whitespace from the string pointed to by dest by shifting the text left over writting the beginning whitespace, left justifying the text.
The left justified text is null terminated. The text is shifted so the original pointer can continue to be used.
[out] | dest | pointer to string to left justify |
[in] | dmax | restricted maximum length of string |
EOK | when successful operation |
ESNULLP | when dest is NULL pointer |
ESZEROL | when dmax = 0 |
ESLEMAX | when dmax > RSIZE_MAX_STR |
EOVERFLOW | when dmax > size of dest (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != sizeof(dest) and –enable-error-dmax |
ESUNTERM | when dest was not null terminated |
The strnterminate_s function will terminate the string if a null is not encountered before dmax characters.
dest | pointer to string |
dmax | maximum length of string |
#define strpbrk_s | ( | dest, | |
dmax, | |||
src, | |||
slen, | |||
firstp | |||
) | _strpbrk_s_chk(dest,dmax,src,slen,firstp,BOS(dest),BOS(src)) |
Returns a pointer, first, to the first ocurrence of any character in src which is contained in dest.
dest | pointer to string to compare against |
dmax | restricted maximum length of string dest |
src | pointer to the string |
slen | restricted length of string src |
firstp | returned pointer to first occurence |
EOK | when successful operation |
ESNULLP | when dest/src/firstp is NULL pointer |
ESZEROL | when dmax/slen = 0 |
ESLEMAX | when dmax/slen > RSIZE_MAX_STR |
EOVERFLOW | when dmax > size of dest (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != sizeof(dest) and –enable-error-dmax |
#define strfirstsame_s | ( | dest, | |
dmax, | |||
src, | |||
resultp | |||
) | _strfirstsame_s_chk(dest,dmax,src,resultp,BOS(dest)) |
Returns the index of the first character that is the same between dest and src.
The scanning stops at the first null in dest or src, or after dmax characters.
[in] | dest | pointer to string to compare against |
[in] | dmax | restricted maximum length of string dest |
[in] | src | pointer to the string to be compared to dest |
[out] | resultp | pointer to returned index |
EOK | when index to first same char is returned |
ESNULLP | when dest/src/resultp is NULL pointer |
ESZEROL | when dmax = 0 |
ESLEMAX | when dmax > RSIZE_MAX_STR |
EOVERFLOW | when dmax > size of dest (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != sizeof(dest) and –enable-error-dmax |
ESNOTFND | when not found |
#define strlastsame_s | ( | dest, | |
dmax, | |||
src, | |||
resultp | |||
) | _strlastsame_s_chk(dest,dmax,src,resultp,BOS(dest)) |
Returns the index of the last character that is the same between dest and src.
The scanning stops at the first nul in dest or src, or after dmax characters.
[in] | dest | pointer to string to compare against |
[in] | dmax | restricted maximum length of string dest |
[in] | src | pointer to the string to be compared to dest |
[out] | resultp | pointer to returned index |
EOK | when index to last same char is returned |
ESNULLP | when dst/src/resultp is NULL pointer |
ESZEROL | when dmax = 0 |
ESLEMAX | when dmax > RSIZE_MAX_STR |
EOVERFLOW | when dmax > size of dest (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != sizeof(dest) and –enable-error-dmax |
ESNOTFND | when not found |
Determines if the prefix pointed to by src is at the beginning of string pointed to by dest.
The prefix must be a complete match in dest. Useful for command or user input parsing. The scanning stops at the first null in dest or src, or after dmax characters.
dest | pointer to string to compare against |
dmax | restricted maximum length of dest |
src | pointer to the prefix |
EOK | when successful operation, substring found. |
ESNULLP | when dest/src is NULL pointer |
ESZEROL | when dmax = 0 |
ESLEMAX | when dmax > RSIZE_MAX_STR |
EOVERFLOW | when dmax > size of dest (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != size of dest and –enable-error-dmax |
ESNOTFND | when prefix not found in dest |
Removes beginning and trailing whitespace from the string pointed to by dest by shifting the text left over writting the beginning whitespace (space or tab).
The shifted-trimmed text is null terminated. The text is shifted so the original pointer can continue to be used. This is useful when the memory was malloc'ed and will need to be freed.
[out] | dest | pointer to string to left justify |
[in] | dmax | restricted maximum length of string |
EOK | when successful operation |
ESNULLP | when dest is NULL pointer |
ESZEROL | when dmax = 0 |
ESLEMAX | when dmax > RSIZE_MAX_STR |
EOVERFLOW | when dmax > size of dest (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != sizeof(dest) and –enable-error-dmax |
ESUNTERM | when dest was not null terminated |
#define strspn_s | ( | dest, | |
dmax, | |||
src, | |||
slen, | |||
countp | |||
) | _strspn_s_chk(dest,dmax,src,slen,countp,BOS(dest),BOS(src)) |
This function computes the prefix length of the string pointed to by dest which consists entirely of characters that are included from the string pointed to by src.
[in] | dest | pointer to string to determine the prefix |
[in] | dmax | restricted maximum length of string dest |
[in] | src | pointer to exclusion string |
[in] | slen | restricted maximum length of string src |
[out] | countp | pointer to a count variable that will be updated with the dest substring length |
EOK | when successful operation, substring found. |
ESNULLP | when dest/src/countp is NULL pointer |
ESZEROL | when dmax/slen = 0 |
ESLEMAX | when dmax/slen > RSIZE_MAX_STR |
EOVERFLOW | when dmax/slen > size of dest/src (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != sizeof(dest) and –enable-error-dmax |
#define strstr_s | ( | dest, | |
dmax, | |||
src, | |||
slen, | |||
substringp | |||
) | _strstr_s_chk(dest,dmax,src,slen,substringp,BOS(dest),BOS(src)) |
The strstr_s() function locates the first occurrence of the substring pointed to by src which would be located in the string pointed to by dest.
[in] | dest | pointer to string to be searched for the substring |
[in] | dmax | restricted maximum length of dest string |
[in] | src | pointer to the sub string |
[in] | slen | the maximum number of characters to use from src |
[out] | substringp | the returned substring pointer |
EOK | when successful operation, substring found. |
ESNULLP | when dest/src/substring is NULL pointer |
ESZEROL | when dmax/slen = 0, unless *src = 0 |
ESLEMAX | when dmax/slen > RSIZE_MAX_STR |
EOVERFLOW | when dmax/slen > size of dest/src (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != sizeof(dest) and –enable-error-dmax |
ESNOTFND | when substring not found |
Finds the first occurrence of ch (after conversion to char as if by (char)ch) in the null-terminated byte string pointed to by dest (each character interpreted as unsigned char).
The terminating null character is considered to be a part of the string and can be found when searching for '\0'.
[in] | dest | pointer to string to compare against |
[in] | dmax | restricted maximum length of dest |
[in] | ch | character to search for |
[out] | resultp | pointer to char* in dest |
EOK | when successfully character found. |
ESNULLP | when dest/resultp is a NULL pointer |
ESZEROL | when dmax = 0 |
ESLEMAX | when dmax > RSIZE_MAX_STR |
EOVERFLOW | when dmax > size of dest (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != size of dest and –enable-error-dmax |
ESLEMAX | when ch > 255 |
ESNOTFND | when ch not found in dest |
Finds the last occurrence of ch (after conversion to char as if by (char)ch) in the null-terminated byte string pointed to by dest (each character interpreted as unsigned char).
The terminating null character is considered to be a part of the string and can be found when searching for '\0'. Unlike strrchr() it honors dmax as maximal string length.
[in] | dest | pointer to string to compare against |
[in] | dmax | restricted maximum length of dest |
[in] | ch | character to search for |
[out] | resultp | pointer to char* in dest |
EOK | when successfully character found. |
ESNULLP | when dest/resultp is a NULL pointer |
ESZEROL | when dmax = 0 or strnlen_s = 0 |
ESLEMAX | when dmax > RSIZE_MAX_STR |
EOVERFLOW | when dmax > size of dest (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != size of dest and –enable-error-dmax |
ESLEMAX | when ch > 255 |
ESNOTFND | when ch not found in dest |
Converts all uppercase characters to lowercase, leaving all other characters unchanged.
The conversion stops at the first null or after dmax characters.
[out] | dest | pointer to string |
[in] | dmax | maximum length of string |
EOK | when successful operation |
ESNULLP | when dest is NULL pointer |
ESZEROL | when dmax = 0 |
ESLEMAX | when dmax > RSIZE_MAX_STR |
EOVERFLOW | when dmax > size of dest (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != sizeof(dest) and –enable-error-dmax |
Converts all lowercase characters to uppercase, leaving all other characters unchanged.
The conversion stops at the first null or after dmax characters.
[out] | dest | pointer to string |
[in] | dmax | maximum length of string |
EOK | when successful operation |
ESNULLP | when dest is NULL pointer |
ESZEROL | when dmax = 0 |
ESLEMAX | when dmax > RSIZE_MAX_STR |
EOVERFLOW | when dmax > size of dest (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != sizeof(dest) and –enable-error-dmax |
ALSO SEE strtolowercase_s()
#define strlwr_s | ( | str, | |
slen | |||
) | strtolowercase_s((str), (slen)) |
#define strupr_s | ( | str, | |
slen | |||
) | strtouppercase_s((str), (slen)) |
Nulls maximal dmax characters of dest.
This function can be used to clear strings that contained sensitive data, until the terminating NULL character. With SAFECLIB_STR_NULL_SLACK defined all elements following the terminating null character (if any) written in the array of dmax characters pointed to by dest are nulled.
[out] | dest | pointer to string that will be nulled. |
[in] | dmax | restricted maximum length of dest |
EOK | when successful operation |
ESNULLP | when dest is NULL pointer |
ESZEROL | when dmax = 0 |
ESLEMAX | when dmax > RSIZE_MAX_STR |
EOVERFLOW | when dmax > size of dest (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != sizeof(dest) and –enable-error-dmax |
Compares two null-terminated byte strings according to the current locale as defined by the LC_COLLATE
category.
Collation order is the dictionary order: the position of the letter in the national alphabet (its equivalence class) has higher priority than its case or variant. Within an equivalence class, lowercase characters collate before their uppercase equivalents and locale-specific order may apply to the characters with diacritics. In some locales, groups of characters compare as single collation units. For example, "ch" in Czech follows "h" and precedes "i", and "dzs" in Hungarian follows "dz" and precedes "g".
[in] | dest | pointer to string to compare against |
[in] | dmax | restricted maximum length of string dest |
[in] | src | pointer to the string to be compared to dest |
[out] | resultp | pointer to result indicator, greater than 0, equal to 0 or less than 0, if the string pointed to by dest is greater than, equal to or less than the string pointed to by src respectively. |
>0 | when dest greater than src |
0 | when strings the same |
<0 | when dest less than src |
EOK | when comparison is complete |
ESNULLP | when dest/src/resultp is NULL pointer |
ESZEROL | when dmax = 0 |
ESLEMAX | when dmax > RSIZE_MAX_STR |
EOVERFLOW | when dmax > size of dest (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != sizeof(dest) and –enable-error-dmax |
Sets maximal dmax characters of dest to a character value, but not the final NULL character.
With SAFECLIB_STR_NULL_SLACK defined all elements following the terminating null character (if any) written in the array of dmax characters pointed to by dest are nulled.
[out] | dest | string that will be set. |
[in] | dmax | restricted maximum length of dest |
[in] | value | character value to write |
EOK | when successful |
ESNULLP | when dest is NULL pointer |
ESZEROL | when dmax = 0 |
ESLEMAX | when value > 255 |
ESLEMAX | when dmax > RSIZE_MAX_STR |
EOVERFLOW | when dmax > size of dest (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != sizeof(dest) and –enable-error-dmax |
Sets maximal n characters of dest to a character value, but not the final NULL character.
With SAFECLIB_STR_NULL_SLACK defined all elements following the terminating null character (if any) written in the array of dmax characters pointed to by dest are nulled.
[out] | dest | string that will be set. |
[in] | dmax | restricted maximum length of dest |
[in] | value | character value to write |
[in] | n | number of characters to be written |
EOK | when successful |
ESNULLP | when dest is NULL pointer |
ESZEROL | when dmax = 0 |
ESLEMAX | when value > 255 |
ESLEMAX | when dmax > RSIZE_MAX_STR |
EOVERFLOW | when dmax > size of dest (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != sizeof(dest) and –enable-error-dmax |
ESNOSPC | when n > dmax |
#define mbstowcs_s | ( | retvalp, | |
dest, | |||
dmax, | |||
src, | |||
len | |||
) | _mbstowcs_s_chk(retvalp,dest,dmax,src,len,BOS(dest)) |
#define mbsrtowcs_s | ( | retvalp, | |
dest, | |||
dmax, | |||
srcp, | |||
len, | |||
ps | |||
) | _mbsrtowcs_s_chk(retvalp,dest,dmax,srcp,len,ps,BOS(dest)) |
Does not permit the ps
parameter (the pointer to the conversion state) to be a null pointer.
The restartable mbsrtowcs_s
function converts a null-terminated multibyte character sequence from the current LC_CTYPE locale to wchar, which begins in the conversion state described by *ps
, from the array whose first element is pointed to by *srcp
to its wide character representation. If dest is not null, converted characters are stored in the successive elements of the wchar_t
array pointed to by dest
. No more than len
wide characters are written to the destination array. Each multibyte character is converted as if by a call to mbrtowc
. mbsrtowcs_s
clobbers the destination array from the terminating null and until dmax
. In extension to mbstowc_s
you can re-use the state via ps
. With SAFECLIB_STR_NULL_SLACK defined the rest is cleared with 0.
The conversion stops if:
*srcp
is set to NULL
and *ps
represents the initial shift state.*srcp
is set to point at the beginning of the first unconverted multibyte character.len
. *srcp
is set to point at the beginning of the first unconverted multibyte character. This condition is not checked if dest==NULL
.[out] | retvalp | pointer to a size_t object where the result will be stored |
[out] | dest | pointer to wide character array where the results will be stored |
[in] | dmax | restricted maximum length of dest |
[in] | srcp | pointer to the string that will be copied to dest |
[in] | len | maximal number of wide characters to be copied to dest |
[in] | ps | pointer to the conversion state object |
RSIZE_MAX_WSTR
(unless dest is null). wcsnlen_s(*srcp, dmax)
. len
. In other libc's len
is ignored.mbsrtowcs_s
nulls dest. EOK | on successful conversion. |
ESNULLP | when retvalp, ps, srcp or *srcp are a NULL pointer |
ESZEROL | when dmax = 0, unless dest is NULL |
ESLEMAX | when dmax > RSIZE_MAX_WSTR, unless dest is NULL |
EOVERFLOW | when dmax > size of dest (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != size of dest and –enable-error-dmax and dest != NULL |
ESOVRLP | when *srcp and dest overlap |
ESNOSPC | when there is no null character in the first dmax multibyte characters in the *srcp array and len is greater than dmax (unless dest is null) |
#define wcsrtombs_s | ( | retvalp, | |
dest, | |||
dmax, | |||
srcp, | |||
len, | |||
ps | |||
) | _wcsrtombs_s_chk(retvalp,dest,dmax,srcp,len,ps,BOS(dest)) |
Does not permit the ps
parameter (the pointer to the conversion state) to be a null pointer.
The restartable wcsrtombs_s
function converts a sequence of wide characters from the array whose first element is pointed to by *srcp
to to its narrow multibyte representation from the current LC_CTYPE locale that begins in the conversion state described by *ps
. If dest
is not null, converted characters are stored in the successive elements of dest
. No more than len
bytes written to the destination array. Each wide character is converted as if by a call to wcrtomb
. wcsrtombs_s
clobbers the destination array from the terminating null and until dmax
. In extension to wcstombs_s
you can re-use the state via ps
.
The conversion stops if:
L'\0'
was converted and stored. The bytes stored in this case are the unshift sequence (if necessary) followed by '\0'
, *srcp
is set to NULL
and *ps
represents the initial shift state.wchar_t
was found that does not correspond to a valid character in the current LC_CTYPE locale. *srcp
is set to point at the first unconverted wide character.len
. *srcp
is set to point at the beginning of the first unconverted wide character. This condition is not checked if dst==NULL
.With SAFECLIB_STR_NULL_SLACK defined all elements following the terminating null character (if any) written in the array of dmax characters pointed to by dest are nulled. Also in the error cases for srcp = NULL, *srcp = NULL, ESNOSPC and EILSEQ.
[out] | retvalp | pointer to a size_t object where the result will be stored |
[out] | dest | pointer to character array where the result will be stored |
[in] | dmax | restricted maximum length of dest |
[in] | srcp | pointer to the wide string that will be copied to dest |
[in] | len | maximum number of bytes to be written to dest |
[in] | ps | pointer to the conversion state object |
RSIZE_MAX_STR
(unless dest is null). len
. len
. In other libc's len
is ignored.dest
is not a null pointer and dmax
is greater than zero and not greater than RSIZE_MAX_STR, then wcsrtombs_s
nulls dest
. Then the number of bytes excluding terminating zero that were, or would be written to dest
, is stored in *retvalp
. EOK | on successful conversion. |
ESNULLP | when retvalp, ps, srcp or *srcp are a NULL pointer |
ESZEROL | when dmax = 0, unless dest is NULL |
ESLEMAX | when dmax > RSIZE_MAX_STR, unless dest is NULL |
EOVERFLOW | when dmax or len > size of dest (optionally, when the compiler knows the object_size statically), unless dest is NULL |
ESLEWRNG | when dmax != size of dest and –enable-error-dmax |
ESOVRLP | when *srcp and dest overlap |
ESNOSPC | when there is no null character in the first dmax multibyte characters in the *srcp array and len is greater than dmax (unless dest is null) |
EILSEQ | if returned by wctomb() |
#define wcstombs_s | ( | retvalp, | |
dest, | |||
dmax, | |||
src, | |||
len | |||
) | _wcstombs_s_chk(retvalp,dest,dmax,src,len,BOS(dest)) |
The wcstombs_s
function converts a sequence of wide characters from the array whose first element is pointed to by src
to to its narrow multibyte representation from the current LC_CTYPE locale.
If dest
is not null, converted characters are stored in the successive elements of dest
. No more than len
bytes are written to the destination array. Each wide character is converted as if by a call to wcrtomb
. wcstombs_s
clobbers the destination array from the terminating null and until dmax
.
The conversion stops if:
L'\0'
was converted and stored. The bytes stored in this case are the unshift sequence (if necessary) followed by '\0'
.wchar_t
was found that does not correspond to a valid character in the current LC_CTYPE locale.len
. This condition is not checked if dest==NULL
.With SAFECLIB_STR_NULL_SLACK defined all elements following the terminating null character (if any) written in the array of dmax characters pointed to by dest are nulled. Also in the error cases for src = NULL, ESNOSPC and EILSEQ.
[out] | retvalp | the number of characters converted |
[out] | dest | buffer for the resulting converted multibyte character string |
[in] | dmax | The size in bytes of dest |
[in] | src | wide string that will be converted to dest |
[in] | len | number of bytes to be stored in dest , not including the terminating null character. |
retvalp
and src
shall not be a null pointer. RSIZE_MAX_STR
(unless dest
is null). dmax
shall not equal zero (unless dest
is null). dmax
shall be greater than len
. dest
is not a null pointer and dmax
is greater than zero and not greater than RSIZE_MAX_STR, then wcstombs_s
nulls dest
. Then the number of bytes excluding terminating zero that were, or would be written to dest
, is stored in *retvalp
. EOK | on successful conversion. |
ESNULLP | when retvalp or src are a NULL pointer |
ESZEROL | when dmax = 0, unless dest is NULL |
ESLEMAX | when dmax > RSIZE_MAX_STR, unless dest is NULL |
EOVERFLOW | when dmax or len > size of dest (optionally, when the compiler knows the object_size statically), unless dest is NULL |
ESLEWRNG | when dmax != size of dest and –enable-error-dmax |
ESOVRLP | when src and dest overlap |
ESNOSPC | when there is no null character in the first dmax multibyte characters in the src array and len is greater than dmax (unless dest is null) |
EILSEQ | if returned by wcstombs() |
Does not permit the ps
parameter (the pointer to the conversion state) to be a null pointer.
The restartable wcrtomb_s
function converts a single wide character to its narrow multibyte representation from the current LC_CTYPE locale that begins in the conversion state described by *ps
. If dest
is not null, the converted multibyte characters are stored in dest
. Max. MB_CUR_MAX
will be written to dest
.
If dest
is a null pointer, the call is equivalent to wcrtomb_s(&retval, buf, sizeof buf, L'\0', ps)
with internal variables retval
and buf
(whose size is greater than MB_CUR_MAX
).
If wc is the null wide character L'\0', a null byte is stored, preceded by any shift sequence necessary to restore the initial shift state and the conversion state parameter *ps is updated to represent the initial shift state.
If the environment macro STDC_ISO_10646 is defined, the values of type wchar_t are the same as the short identifiers of the characters in the Unicode required set (typically UTF-32 encoding); otherwise, it is implementation-defined. In any case, the multibyte character encoding used by this function is specified by the currently active C locale.
If the environment macro STDC_MB_MIGHT_NEQ_WC is defined, then for members of the basic character set multibyte-character encoding might not equal wide-character encoding (non-ASCII-based systems, such as EBCDIC-based systems, may use Unicode for their wide character encoding and still be conforming). ASCII-based systems with STDC_ISO_10646 defined leave STDC_MB_MIGHT_NEQ_WC undefined.
With SAFECLIB_STR_NULL_SLACK defined all elements following the terminating null character (if any) written in the array of dmax characters pointed to by dest are nulled.
[out] | retvalp | pointer to a size_t object where the result will be stored |
[out] | dest | pointer to bytes where the result will be stored |
[in] | dmax | restricted maximum length of dest |
[in] | wc | the wide character to convert |
[in] | ps | pointer to the conversion state object |
RSIZE_MAX_STR
and size of dest (unless dest is null). dest
[0] is set to '\0' (unless dest is null or dmax is invalid) and *retvalp
is set to (size_t)-1 (unless retvalp is null).EOK | on successful conversion. |
ESNULLP | when retvalp or ps are a NULL pointer |
ESZEROL | when dmax = 0, unless dest is NULL |
EOVERFLOW | when dmax > size of dest (optionally, when the compiler knows the object_size statically), unless dest is NULL |
ESLEMAX | when dmax > RSIZE_MAX_STR, unless dest is NULL |
EOVERFLOW | when dmax > size of dest (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != size of dest and –enable-error-dmax and dest != NULL |
ESNOSPC | when dmax is smaller than the number of required bytes |
The wctomb_s
function converts a single wide character to its narrow multibyte representation from the current LC_CTYPE locale.
If dest
is not null, the converted multibyte characters are stored in dest
. Max. MB_CUR_MAX
will be written to dest
.
If dest
is a null pointer, the call is equivalent to wcrtomb_s(&retval, buf, sizeof buf, L'\0', ps)
with internal variables retval
and buf
(whose size is greater than MB_CUR_MAX
).
If the environment macro STDC_ISO_10646 is defined, the values of type wchar_t are the same as the short identifiers of the characters in the Unicode required set (typically UTF-32 encoding); otherwise, it is implementation-defined. In any case, the multibyte character encoding used by this function is specified by the currently active C locale.
If the environment macro STDC_MB_MIGHT_NEQ_WC is defined, then for members of the basic character set multibyte-character encoding might not equal wide-character encoding (non-ASCII-based systems, such as EBCDIC-based systems, may use Unicode for their wide character encoding and still be conforming). ASCII-based systems with STDC_ISO_10646 defined leave STDC_MB_MIGHT_NEQ_WC undefined.
With SAFECLIB_STR_NULL_SLACK defined all elements following the terminating null character (if any) written in the array of dmax characters pointed to by dest are nulled. Also in the error cases for ESNOSPC and EILSEQ.
[out] | retvalp | pointer to a size_t object where the result will be stored |
[out] | dest | pointer to bytes where the result will be stored |
[in] | dmax | restricted maximum length of dest |
[in] | wc | the wide character to convert |
RSIZE_MAX_STR
and size of dest (unless dest is null). dest
[0] is set to '\0' (unless dest is null or dmax is invalid) and *retvalp
is set to (size_t)-1 (unless retvalp is null).EOK | on successful conversion. |
ESNULLP | when retvalp is a NULL pointer |
ESZEROL | when dmax = 0, unless dest is NULL |
ESLEMAX | when dmax > RSIZE_MAX_STR, unless dest is NULL |
EOVERFLOW | when dmax > size of dest (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != size of dest and –enable-error-dmax |
ESNOSPC | when dmax is smaller than the number of required bytes |
EILSEQ | if returned by wctomb() |
The wcsnlen_s function computes the length of the wide string pointed to by dest, providing limited support for non-null terminated strings.
dest | pointer to wide string |
dmax | maximum length of wide string, incl. the final null |
MINGW_HAS_SECURE_API
this API is forceinline'd and the native wcsnlen_s
with the msvcrt has a different dmax limit: INT_MAX
. dest
is NULL, then wcsnlen_s
returns 0. Otherwise, the wcsnlen_s
function returns the number of wide characters that precede the terminating null character. If there is no null character in the first dmax
characters of dest then wcsnlen_s
returns dmax
. At most the first dmax
characters of dest are accessed by wcsnlen_s
.The wcscpy_s
function copies the string pointed to by src
(including the terminating null character) into the array pointed to by dest.
With SAFECLIB_STR_NULL_SLACK
defined all elements following the terminating null character (if any) written by wcscpy_s
in the array of dmax
characters pointed to by dest
are nulled when wcscpy_s
returns.
[out] | dest | pointer to wide string that will be replaced by src. |
[in] | dmax | restricted maximum length of dest |
[in] | src | pointer to the wide string that will be copied to dest |
EOK | when successful operation, the wide characters in src were copied into dest and the result is null terminated. |
-ESNULLP | when dest or src is a NULL pointer |
-ESZEROL | when dmax = 0 |
-ESLEMAX | when dmax > RSIZE_MAX_WSTR |
-ESOVRLP | when buffers overlap |
-ESNOSPC | when dest < src |
The wcsncpy_s function copies the wide string pointed to by src (including the terminating null character) into the wide string pointed to by dest.
With SAFECLIB_STR_NULL_SLACK defined all elements following the terminating null character (if any) written by wcsncpy_s in the array of dmax characters pointed to by dest are nulled when wcsncpy_s returns.
[out] | dest | pointer to wide string that will be replaced by src. |
[in] | dmax | restricted maximum length of dest |
[in] | src | pointer to the wide string that will be copied to dest |
[in] | slen | maximum number of wide characters to copy |
EOK | successful operation, when slen == 0 or the wide characters in src were copied into dest and the result is null terminated. |
ESNULLP | when dest/src is a NULL pointer |
ESZEROL | when dmax = 0 |
ESLEMAX | when dmax > RSIZE_MAX_WSTR |
EOVERFLOW | when dmax/slen > size of dest/src (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != size of dest and –enable-error-dmax |
ESOVRLP | when buffers overlap |
ESNOSPC | when src > dest |
The wcscat_s function appends a copy of the wide string pointed to by src (including the terminating null character) to the end of the wide string pointed to by dest.
The initial wide character from src overwrites the null character at the end of dest.
All elements following the terminating null wide character (if any) written by wcscat_s in the array of dmax characters pointed to by dest take unspecified values when wcscat_s returns. With SAFECLIB_STR_NULL_SLACK defined the rest is cleared with 0.
[out] | dest | pointer to wide string that will be extended by src if dmax allows. The wide string is null terminated. If the resulting concatenated wide string is less than dmax, the remaining slack space is nulled. |
[in] | dmax | restricted maximum wchar_t length of the resulting dest, including the null |
[in] | src | pointer to the wide string that will be concatenaed to string dest |
EOK | when successful operation, all the wide characters from src were appended to dest and the result in dest is null terminated. |
ESNULLP | when dest or src is a NULL pointer |
ESZEROL | when dmax = 0 |
ESLEMAX | when dmax > RSIZE_MAX_WSTR |
EOVERFLOW | when dmax > size of dest (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != size of dest and –enable-error-dmax |
ESUNTERM | when dest not terminated in the first dmax wide characters |
ESOVRLP | when src overlaps with dest |
The wcsncat_s function appends a copy of the wide string pointed to by src (including the terminating null wide character) to the end of the wide string pointed to by dest.
The initial character from src overwrites the null wide character at the end of dest.
All elements following the terminating null wide character (if any) written by wcsncat_s in the array of dmax wide characters pointed to by dest take unspecified values when wcsncat_s returns. With SAFECLIB_STR_NULL_SLACK defined the rest is cleared with 0.
[out] | dest | pointer to wide string that will be extended by src if dmax allows. The string is null terminated. If the resulting concatenated wide string is less than dmax, the remaining slack space is nulled. |
[in] | dmax | restricted maximum length of the resulting dest, including the null |
[in] | src | pointer to the wide string that will be concatenaed to string dest |
[in] | slen | maximum wide characters to append |
EOK | successful operation, when slen == 0 or all the wide characters are copied from src and dest is null terminated. As special case, analog to msvcrt: when slen == 0 and dmax is big enough for dest, also return EOK, but clear dest. |
ESNULLP | when dest/src is NULL pointer and slen > 0 |
ESZEROL | when dmax = 0 and slen > 0 |
ESLEMAX | when dmax/slen > RSIZE_MAX_WSTR and slen > 0 |
EOVERFLOW | when dmax/slen > size of dest/src (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != size of dest and –enable-error-dmax |
ESUNTERM | when dest not terminated and slen > 0 |
ESOVRLP | when src overlaps with dest and slen > 0 |
#define wcstok_s | ( | dest, | |
dmaxp, | |||
delim, | |||
ptr | |||
) | _wcstok_s_chk(dest,dmaxp,delim,ptr,BOS(dest)) |
A sequence of calls to the wcstok_s function breaks the string pointed to by dest into a sequence of tokens, each of which is delimited by a character from the string pointed to by delim.
The fourth argument points to a caller-provided char pointer into which the wcstok_s function stores information necessary for it to continue scanning the same string.
The first call in a sequence has a non-null first argument and dmax points to an object whose value is the number of elements in the character array pointed to by the first argument. The first call stores an initial value in the object pointed to by ptr and updates the value pointed to by dmax to reflect the number of elements that remain in relation to ptr. Subsequent calls in the sequence have a null first argument and the objects pointed to by dmax and ptr are required to have the values stored by the previous call in the sequence, which are then updated. The separator string pointed to by delim may be different from call to call.
The first call in the sequence searches the string pointed to by dest for the first character that is not contained in the current separator string pointed to by delim. If no such character is found, then there are no tokens in the string pointed to by dest and the wcstok_s function returns a null pointer. If such a character is found, it is the start of the first token.
The wcstok_s function then searches from there for the first character in dest that is contained in the current separator string. If no such character is found, the current token extends to the end of the string pointed to by dest, and subsequent searches in the same string for a token return a null pointer. If such a character is found, it is overwritten by a null character, which terminates the current token.
In all cases, the wcstok_s function stores sufficient information in the pointer pointed to by ptr so that subsequent calls, with a null pointer for dest and the unmodified pointer value for ptr, shall start searching just past the element overwritten by a null character (if any).
delim uses a STRTOK_DELIM_MAX_LEN of 16.
[in] | dest | pointer to wide string to tokenize |
[out] | dmaxp | pointer to the restricted maximum length of dest |
[in] | delim | pointer to wide delimiter string (len < 255) |
[out] | ptr | returned pointer to token |
wchar_t* wcstok_s(wchar_t *str, const wchar_t *delim, wchar_t **next_token)
errno is set to: ESNULLP when dest/delim/ptr is NULL pointer ESZEROL when *dmax = 0 ESLEMAX when *dmax > RSIZE_MAX_WSTR EOVERFLOW when *dmax > size of dest if dest != NULL ESUNTERM when unterminated string C11 just returns EINVAL
The truncating vsnwprintf_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. dest will be terminated with a null character. With SAFECLIB_STR_NULL_SLACK
defined all elements following the terminating null character (if any) written by vsnwprintf_s
in the array of dmax wide characters pointed to by dest
are nulled when vsnwprintf_s
returns.
errno
is set on error. However, the safeclib extended ES*
errors do not set errno
, only when the underlying system vswprintf
or vsnwprintf
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] | ap | optional arguments |
snprintf
, which makes it possible to determine the required output buffer size, there is no equivalent for wide strings (until C11's snwprintf_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.snwprintf_s
, unlike swprintf_s
, will truncate the result to fit within the array pointed to by buffer, even though truncation is treated as an error by most bounds-checked functions.vsnwprintf
, vswprintf_s
guarantees that the buffer will be null-terminated unless the buffer size is zero.-ESNULLP | when dest/fmt is NULL pointer |
-ESZEROL | when dmax = 0 |
-ESLEMAX | when dmax > RSIZE_MAX_WSTR |
-EOVERFLOW | when dmax > size of dest |
-EINVAL | when fmt contains n |
-1 | on some other error. errno is set then |
#define wcsstr_s | ( | dest, | |
dmax, | |||
src, | |||
slen, | |||
substringp | |||
) | _wcsstr_s_chk(dest,dmax,src,slen,substringp,BOS(dest),BOS(src)) |
The wcsstr_s() function locates the first occurrence of the wide substring pointed to by src
which would be located in the wide string pointed to by dest
.
[in] | dest | wide string to be searched for the substring |
[in] | dmax | restricted maximum length of dest |
[in] | src | pointer to the wide sub string |
[in] | slen | the maximum number of wide characters to use from src |
[out] | substringp | the returned substring pointer |
EOK | when successful operation, substring found. |
ESNULLP | when dest/src/substringp is NULL pointer |
ESZEROL | when dmax/slen = 0 |
ESLEMAX | when dmax/slen > RSIZE_MAX_WSTR |
EOVERFLOW | when dmax/slen > size of dest/src (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != size of dest and –enable-error-dmax |
ESNOTFND | when substring not found |
#define wcscmp_s | ( | dest, | |
dmax, | |||
src, | |||
smax, | |||
resultp | |||
) | _wcscmp_s_chk(dest,dmax,src,smax,resultp,BOS(dest),BOS(src)) |
Compares wide string src to wide string dest.
[in] | dest | wide string to compare against |
[in] | dmax | restricted maximum length of wide string dest |
[in] | src | wide string to be compared to dest |
[in] | smax | restricted maximum length of wide string src |
[out] | resultp | pointer to result diff, greater than 0, equal to 0 or less than 0, if the dest is greater than, equal to or less than src respectively. |
EOK | when comparison is complete |
ESNULLP | when dest/src/resultp is NULL pointer |
ESZEROL | when dmax/smax = 0 |
ESLEMAX | when dmax/smax > RSIZE_MAX_WSTR |
EOVERFLOW | when dmax/smax > size of dest/src (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != size of dest and –enable-error-dmax |
#define wcsncmp_s | ( | dest, | |
dmax, | |||
src, | |||
smax, | |||
count, | |||
resultp | |||
) | _wcsncmp_s_chk(dest,dmax,src,smax,count,resultp,BOS(dest),BOS(src)) |
Compares at most count wide characters of wide string src with wide string dest, and returns if difference in the last parameter.
[in] | dest | wide string to compare against |
[in] | dmax | restricted maximum length of wide string dest |
[in] | src | wide string to be compared to dest |
[in] | smax | restricted maximum length of wide string src |
[in] | count | maximum number of wide characters to compare |
[out] | resultp | pointer to result diff, greater than 0, equal to 0 or less than 0, if the dest is greater than, equal to or less than src respectively. |
EOK | when comparison is complete |
ESNULLP | when dest/src/resultp is NULL pointer |
ESZEROL | when dmax/smax = 0 |
ESLEMAX | when dmax/smax > RSIZE_MAX_WSTR |
EOVERFLOW | when dmax/smax > size of dest/src (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != size of dest and –enable-error-dmax |
#define wcsicmp_s | ( | dest, | |
dmax, | |||
src, | |||
smax, | |||
resultp | |||
) | _wcsicmp_s_chk(dest,dmax,src,smax,resultp,BOS(dest),BOS(src)) |
Compares two wide strings case-folded, via wcsfc_s()
, i.e.
case-folded and normalized, and returns if difference in the last parameter. The two strings may overlap.
[in] | dest | wide string to compare against |
[in] | dmax | restricted maximum length of wide string dest |
[in] | src | wide string to be compared to dest |
[in] | smax | restricted maximum length of wide string src |
[out] | resultp | pointer to result diff, greater than 0, equal to 0 or less than 0, if the dest is greater than, equal to or less than src respectively. |
EOK | when comparison is complete |
ESNULLP | when dest/src/resultp is NULL pointer |
ESZEROL | when dmax/smax = 0 |
ESLEMAX | when dmax/smax > RSIZE_MAX_WSTR |
EOVERFLOW | when dmax/smax > size of dest/src (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != size of dest and –enable-error-dmax |
#define wcsnatcmp_s | ( | dest, | |
dmax, | |||
src, | |||
smax, | |||
resultp | |||
) | _wcsnatcmp_s_chk(dest,dmax,src,smax,0,resultp,BOS(dest),BOS(src)) |
#define wcsnaticmp_s | ( | dest, | |
dmax, | |||
src, | |||
smax, | |||
resultp | |||
) | _wcsnatcmp_s_chk(dest,dmax,src,smax,1,resultp,BOS(dest),BOS(src)) |
Natural order comparison of strings.
The longest run of numbers wins over alpha chars.
[in] | dest | pointer to wide string to compare against |
[in] | dmax | restricted maximum length of wide string dest |
[in] | src | pointer to the wide string to be compared to dest |
[in] | smax | restricted maximum length of wide string src |
[out] | resultp | pointer to int result, greater than 0, equal to 0 or less than 0, if the string pointed to by dest is greater than, equal to or less than the string pointed to by src respectively. |
EOK | when comparison is complete |
ESUNTERM | when dest or src is unterminated, or dmax is too small. |
ESNULLP | when dest/src/resultp is NULL pointer |
ESZEROL | when dmax = 0 |
ESZEROL | when dmax/smax = 0 |
ESLEMAX | when dmax/smax > RSIZE_MAX_WSTR |
EOVERFLOW | when dmax/smax > size of dest/src (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != size of dest and –enable-error-dmax |
Sets maximal dmax wide characters of dest to a wide character value, but not the final NULL character.
With SAFECLIB_STR_NULL_SLACK defined all elements following the terminating null character (if any) written in the array of dmax wide characters pointed to by dest are nulled.
[out] | dest | wide string that will be set. |
[in] | dmax | restricted maximum length of dest |
[in] | value | wide character value to write |
EOK | when successful |
ESNULLP | when dest is NULL pointer |
ESZEROL | when dmax = 0 |
ESLEMAX | when dmax > RSIZE_MAX_WSTR or value > _UNICODE_MAX |
EOVERFLOW | when dmax > size of dest (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != size of dest and –enable-error-dmax |
Sets maximal n wide characters of dest to a wide character value, but not the final NULL character.
With SAFECLIB_STR_NULL_SLACK defined all elements following the terminating null character (if any) written in the array of dmax wide characters pointed to by dest are nulled.
[out] | dest | wide string that will be set. |
[in] | dmax | restricted maximum length of dest |
[in] | value | wide character value to write |
[in] | n | number of wide characters to be written |
EOK | when successful |
ESNULLP | when dest is NULL pointer |
ESZEROL | when dmax = 0 |
ESLEMAX | when dmax > RSIZE_MAX_WSTR or value > _UNICODE_MAX |
EOVERFLOW | when dmax > size of dest (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != size of dest and –enable-error-dmax |
ESNOSPC | when n > dmax |
#define wcscoll_s | ( | dest, | |
dmax, | |||
src, | |||
smax, | |||
resultp | |||
) | _wcscoll_s_chk(dest,dmax,src,smax,resultp,BOS(dest),BOS(src)) |
Compares two null-terminated wide strings according to the current locale as defined by the LC_COLLATE
category.
Collation order is the dictionary order: the position of the letter in the national alphabet (its equivalence class) has higher priority than its case or variant. Within an equivalence class, lowercase characters collate before their uppercase equivalents and locale-specific order may apply to the characters with diacritics. In some locales, groups of characters compare as single collation units. For example, "ch" in Czech follows "h" and precedes "i", and "dzs" in Hungarian follows "dz" and precedes "g".
[in] | dest | wide string to compare against |
[in] | dmax | restricted maximum length of dest |
[in] | src | wide string to be compared to dest |
[in] | smax | restricted maximum length of src |
[out] | resultp | pointer to result indicator, greater than 0, equal to 0 or less than 0, if the string pointed to by dest is greater than, equal to or less than the string pointed to by src respectively. |
EOK | when comparison is complete |
ESNULLP | when dest/src/resultp is NULL pointer |
ESZEROL | when dmax/smax = 0 |
ESLEMAX | when dmax/smax > RSIZE_MAX_WSTR |
EOVERFLOW | when dmax/smax > size of dest/src (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != size of dest and –enable-error-dmax |
Scans the string converting uppercase characters to simple lowercase, leaving all other characters unchanged.
The scanning stops at the first null or after slen characters. The conversion is determined by the LC_CTYPE category setting of the locale. Other characters are not affected. It only performs simple case folding via towlower()
, it does not do full multi-char folding and does not obey the special casing rules for context. See wcsfc_s()
instead. Thus the length of buffer stays the same. It returns a pointer to the altered string. Because the modification is done in place, the pointer returned is the same as the pointer passed as the input argument.
[out] | src | wide string |
[in] | slen | maximum length of string |
EOK | on successful operation or slen = 0 |
ESNULLP | when src is NULL pointer |
ESLEMAX | when slen > RSIZE_MAX_WSTR |
EOVERFLOW | when slen > size of src (optionally, when the compiler knows the object_size statically) |
Scans the string converting lowercase characters to uppercase, leaving all other characters unchanged.
The scanning stops at the first null or after slen characters. The conversion is determined by the LC_CTYPE category setting of the locale. Other characters are not affected. It converts only single chars via towupper()
. It returns a pointer to the altered string. Because the modification is done in place, the pointer returned is the same as the pointer passed as the input argument.
[out] | src | wide string |
[in] | slen | maximum length of string |
EOK | on successful operation or slen = 0 |
ESNULLP | when src is NULL pointer |
ESLEMAX | when slen > RSIZE_MAX_WSTR |
EOVERFLOW | when slen > size of src (optionally, when the compiler knows the object_size statically) |
towfc_s()
converts a wide character to fully fold-cased (lowercased with possible expansions), according to the Unicode 10.0 CaseFolding table.
Even in most the unsuccessul cases, just not with with ESNULLP and ESZEROL dest is being written to.
As of Unicode 10.0 there are no possible results as surrogate pairs with sizeof(wchar_t)==2
, all results are below U+10000.
[out] | dest | wide string buffer to store result |
[in] | dmax | maximum size of dest, should be 4. (3 + NULL) |
[in] | src | wide character to convert to lowercase |
>=0 | on successful operation, returns the number of converted wide characters: 0-3 |
-ESNULLP | when dest is NULL pointer |
-ESZEROL | when dmax = 0 |
-ESLEMIN | when dmax < 4 |
-ESLEMAX | when dmax > RSIZE_MAX_WSTR |
-EOVERFLOW | when dmax > size of dest (optionally, when the compiler knows the object_size statically) |
-ESLEWRNG | when dmax != size of dest and –enable-error-dmax |
-ESNOTFND | when no mapping for src was found, iswfc is wrong. |
Converts the wide string via full case-folding NFD normalized to lowercase.
The conversion stops at the first null or after dmax characters. The conversion is determined by the LC_CTYPE category setting of the locale. Other characters are not affected. fold-case performs full case folding, i.e. if iswfc() of a character > 1, the length of dest might be greater than the length of src (max 4 per char), the conversion is done via towfc_s()
and Unicode 10.0, the Unicode special-casing rules are obeyed, and composed characters are normalized to NFD via wcsnorm_decompose_s()
and wcsnorm_reorder_s()
. If not, the conversion is per character done via normal towlower()
. Note that decomposition creates larger strings, typically 2-3 chars more.
With SAFECLIB_STR_NULL_SLACK defined all elements following the terminating null character (if any) written in the array of dmax characters pointed to by dest are nulled.
SpecialCasing checks for conditional boundary context at the begin or end of certain characters (final greek sigma), and locale sensitive rules for the Lithuanian and the Turkish/Azeri I-dot.
Composed characters are checked for the left-hand-side of the Decomposition_Mapping Unicode property, which means the codepoint will be normalized to NFD if any codepoint is composed. Technically only FCD as all FC expansions are already properly ordered, and all mangled marks will not be reordered, as the have the same Combining Class.
[out] | dest | wide string to hold the result (~130% larger than src) |
[in] | dmax | maximum result buffer size |
[in] | src | wide string |
[out] | lenp | pointer to length of the result, may be NULL |
EOK | on successful operation |
ESNULLP | when dest or src is NULL pointer |
ESZEROL | when dmax = 0 |
ESLEMAX | when dmax > RSIZE_MAX_WSTR or a cp > 0x10ffff |
EOVERFLOW | when dmax > size of dest (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != size of dest and –enable-error-dmax |
ESNOSPC | when dmax is too small for the decomposition. *lenp is still written, to know how much space is needed. |
ESNOTFND | Internal error as returned by towfc_s() for multi-char foldings. happens only when the internal implementations of iswfc() and towfc_s() are mismatched. |
#define wcsnorm_decompose_s | ( | dest, | |
dmax, | |||
src, | |||
lenp, | |||
iscompat | |||
) | _wcsnorm_decompose_s_chk(dest,dmax,src,lenp,iscompat,BOS(dest)) |
Converts the wide string to the canonical NFD normalization, as defined in the latest Unicode standard, latest 10.0.
The conversion stops at the first null or after dmax characters.
Composed characters are checked for the left-hand-size of the Decomposition_Mapping Unicode property, which means the codepoint will be normalized if the sequence is composed. This is equivalent to all 1963 combining mark characters, plus some remaining 869 non-mark and non-hangul normalizables. Hangul has some special normalization logic.
This function is used by wcsnorm_s()
to do the argument checking, overlap checking and to do the first of three passes for NFC.
[out] | dest | wide string to hold the result |
[in] | dmax | maximum result buffer size |
[in] | src | wide string |
[out] | lenp | pointer to length of the result, may be NULL |
[in] | iscompat | do NFKD, and not NFD (with –enable-norm-compat ) |
EOK | on success |
ESNULLP | when dest or src is NULL pointer |
ESZEROL | when dmax = 0 |
ESLEMIN | when dmax < 5 or 19 with a compat mode |
ESLEMAX | when dmax > RSIZE_MAX_WSTR |
EOVERFLOW | when dmax > size of dest (optionally, when the compiler knows the object_size statically) |
ESLEWRNG | when dmax != size of dest and –enable-error-dmax |
ESOVRLP | when buffers overlap |
ESNOSPC | when dmax too small for the result buffer |
EOF | on some normalization error |
#define wcsnorm_reorder_s | ( | dest, | |
dmax, | |||
src, | |||
len | |||
) | _wcsnorm_reorder_s_chk(dest,dmax,src,len,BOS(dest)) |
Reorder all decomposed sequences in a wide string to NFD, as defined in the latest Unicode standard, latest 10.0.
The conversion stops at the first null or after dmax characters.
[out] | dest | wide string to hold the result |
[in] | dmax | maximum result buffer size |
[in] | src | wide string to be converted |
[in] | len | length of src |
wcsnorm_reorder_s
nulls dest. EOK | on success |
ESNOSPC | when dmax too small for the result buffer |
EOF | on some normalization error |
#define wcsnorm_compose_s | ( | dest, | |
dmax, | |||
src, | |||
lenp, | |||
iscontig | |||
) | _wcsnorm_compose_s_chk(dest,dmax,src,lenp,iscontig,BOS(dest)) |
Combine all decomposed sequences in a wide string to NFC, as defined in the latest Unicode standard, latest 10.0.
The conversion stops at the first null or after dmax characters.
[out] | dest | wide string to hold the result |
[in] | dmax | maximum result buffer size |
[in] | src | wide string to be converted |
[out] | lenp | pointer to length of p and the result length. |
[in] | iscontig | if true, the result will only be a fast FCC |
wcsnorm_reorder_s
nulls dest. EOK | on success |
ESNOSPC | when dmax too small for the result buffer |
EOF | on some normalization error |
Converts the wide string to the canonical NFC or NFD normalization, as defined in the latest Unicode standard, latest 10.0.
The conversion stops at the first null or after dmax characters.
Decomposed characters are checked for the left-hand-size and then right-hand-side of the Decomposition_Mapping Unicode property, which means the codepoint will be normalized if the sequence is composed or decomposed (NFD or NFKD). This is equivalent to all 1963 combining mark characters, plus some remaining 869 non-mark and non-hangul normalizables. Hangul has some special normalization logic.
The compat tables for NFKC or NFKD are too large for a libc, and mostly unused. As default we only provide the smaller canonical conversions, but it can be enabled with –enable-norm-compat
. The compat modes also don't roundtrip.
[out] | dest | wide string to hold the result |
[in] | dmax | maximum length of string |
[in] | src | wide string |
[in] | mode | convert to nfc or just nfd. experimentally to fast modes FCD or FCC. optionally to compat modes NFKD, NFKC with –enable-norm-compat |
wcsnorm_mode
. [out] | lenp | pointer to length of the result, may be NULL |
EOK | on success |
ESNULLP | when dest or src is NULL pointer |
ESZEROL | when dmax = 0 |
ESLEMIN | when dmax < 5 |
ESLEMAX | when dmax > RSIZE_MAX_WSTR |
ESOVRLP | when buffers overlap |
ESNOSPC | when dmax too small for the result buffer |
EOF | any other normalization error |
EXTERN void abort_handler_s | ( | const char *restrict | msg, |
void *restrict | ptr, | ||
errno_t | error | ||
) |
This function writes a message on the standard error stream in an implementation-defined format.
The message shall include the string pointed to by msg. The abort_handler_s function then calls the abort function.
[in] | msg | Pointer to the message describing the error |
[in] | ptr | Pointer to aassociated data. Can be NULL. |
[in] | error | The error code encountered. |
EXTERN void ignore_handler_s | ( | const char *restrict | msg, |
void *restrict | ptr, | ||
errno_t | error | ||
) |
This function simply returns to the caller.
[in] | msg | Pointer to the message describing the error |
[in] | ptr | Pointer to aassociated data. Can be NULL. |
[in] | error | The error code encountered. |
EXTERN constraint_handler_t set_str_constraint_handler_s | ( | constraint_handler_t | handler | ) |
The set_str_constraint_handler_s function sets the runtime-constraint handler to be handler.
The runtime-constraint handler is the function to be called when a library function detects a runtime-constraint violation. Only the most recent handler registered with set_str_constraint_handler_s is called when a runtime-constraint violation occurs. When the handler is called, it is passed the following arguments in the following order:
EXTERN errno_t _strcat_s_chk | ( | char *restrict | dest, |
rsize_t | dmax, | ||
const char *restrict | src, | ||
const size_t | destbos | ||
) |
EXTERN errno_t _strcpy_s_chk | ( | char *restrict | dest, |
rsize_t | dmax, | ||
const char *restrict | src, | ||
const size_t | destbos | ||
) |
EXTERN errno_t _strncat_s_chk | ( | char *restrict | dest, |
rsize_t | dmax, | ||
const char *restrict | src, | ||
rsize_t | slen, | ||
const size_t | destbos, | ||
const size_t | srcbos | ||
) | && |
EXTERN errno_t empty dest or dmax BOS_ATTR | ( | (slen||dest||dmax) &&_BOS_OVR(dest, dmax) | , |
"dest overflow" | |||
) |
EXTERN errno_t _strncpy_s_chk | ( | char *restrict | dest, |
rsize_t | dmax, | ||
const char *restrict | src, | ||
rsize_t | slen, | ||
const size_t | destbos, | ||
const size_t | srcbos | ||
) |
EXTERN char* _strtok_s_chk | ( | char *restrict | dest, |
rsize_t *restrict | dmaxp, | ||
const char *restrict | delim, | ||
char **restrict | ptr, | ||
const size_t | destbos | ||
) |
EXTERN int _vsprintf_s_chk | ( | char *restrict | dest, |
rsize_t | dmax, | ||
const size_t | destbos, | ||
const char *restrict | fmt, | ||
va_list | ap | ||
) |
EXTERN int _vsnprintf_s_chk | ( | char *restrict | dest, |
rsize_t | dmax, | ||
const size_t | destbos, | ||
const char *restrict | fmt, | ||
va_list | ap | ||
) |
EXTERN int sscanf_s | ( | const char *restrict | buffer, |
const char *restrict | fmt, | ||
... | |||
) |
The sscanf_s
function reads a formatted string, and writes to a list of arguments.
Reaching the end of the string is equivalent to reaching the end-of-file condition for fscanf
.
[in] | buffer | pointer to a null-terminated string to read from |
[in] | fmt | format-control string. |
[out] | ... | arguments to write to |
buffer
nor fmt
shall be a null pointer. fmt
shall not contain the conversion specifier n
s
is a null pointer. (not yet) c
, s
, and %
[ conversion specifiers each expect two arguments (the usual pointer and a value of type rsize_t
indicating the size of the receiving array, which may be 1 when reading with a c
into a single character) and except that the following errors are detected at runtime and call the currently installed constraint handler function.EOF
if read failure occurs before the first receiving argument was assigned or if there is a runtime constraint violation.> | 0 on success, the number of arguments assigned |
EOF | on error |
EXTERN int fscanf_s | ( | FILE *restrict | stream, |
const char *restrict | fmt, | ||
... | |||
) |
The fscanf_s
function reads a formatted string from a buffered FILE stream, and writes to a list of arguments.
[in] | stream | pointer to a FILE stream to read from |
[in] | fmt | format-control string. |
[out] | ... | arguments to write to |
stream
nor fmt
shall be a null pointer. fmt
shall not contain the conversion specifier n
s
is a null pointer. (not yet) c
, s
, and %
[ conversion specifiers each expect two arguments (the usual pointer and a value of type rsize_t
indicating the size of the receiving array, which may be 1 when reading with a c
into a single character) and except that the following errors are detected at runtime and call the currently installed constraint handler function.EOF
if read failure occurs before the first receiving argument was assigned or if there is a runtime constraint violation.> | 0 on success, the number of arguments assigned |
EOF | on error |
EXTERN int scanf_s | ( | const char *restrict | fmt, |
... | |||
) |
The scanf_s
function reads a formatted string from stdin, and writes to a list of arguments.
Reaching the end of the io buffer is equivalent to reaching the end-of-file condition for fscanf
.
[in] | fmt | format-control string. |
[out] | ... | arguments to write to |
fmt
shall be a null pointer. fmt
shall not contain the conversion specifier n
s
is a null pointer. (not yet) c
, s
, and %
[ conversion specifiers each expect two arguments (the usual pointer and a value of type rsize_t
indicating the size of the receiving array, which may be 1 when reading with a c
into a single character) and except that the following errors are detected at runtime and call the currently installed constraint handler function.EOF
if read failure occurs before the first receiving argument was assigned or if there is a runtime constraint violation.> | 0 on success, the number of arguments assigned |
EOF | on error |
EXTERN int vscanf_s | ( | const char *restrict | fmt, |
va_list | ap | ||
) |
The vscanf_s
function reads a formatted string from stdin, and writes to a list of arguments.
Reaching the end of the io buffer is equivalent to reaching the end-of-file condition for fscanf
.
[in] | fmt | format-control string. |
[out] | ap | arguments to write to |
fmt
shall be a null pointer. fmt
shall not contain the conversion specifier n
s
is a null pointer. (not yet) c
, s
, and %
[ conversion specifiers each expect two arguments (the usual pointer and a value of type rsize_t
indicating the size of the receiving array, which may be 1 when reading with a c
into a single character) and except that the following errors are detected at runtime and call the currently installed constraint handler function.EOF
if read failure occurs before the first receiving argument was assigned or if there is a runtime constraint violation.> | 0 on success, the number of arguments assigned |
EOF | on error |
EXTERN int vfscanf_s | ( | FILE *restrict | stream, |
const char *restrict | fmt, | ||
va_list | ap | ||
) |
The vfscanf_s
function reads a formatted string from a buffered FILE stream, and writes to a list of arguments.
[in] | stream | pointer to a FILE stream to read from |
[in] | fmt | format-control string. |
[out] | ap | arguments to write to |
stream
nor fmt
shall be a null pointer. fmt
shall not contain the conversion specifier n
s
is a null pointer. (not yet) c
, s
, and %
[ conversion specifiers each expect two arguments (the usual pointer and a value of type rsize_t
indicating the size of the receiving array, which may be 1 when reading with a c
into a single character) and except that the following errors are detected at runtime and call the currently installed constraint handler function.EOF
if read failure occurs before the first receiving argument was assigned or if there is a runtime constraint violation.> | 0 on success, the number of arguments assigned |
EOF | on error |
EXTERN int vsscanf_s | ( | const char *restrict | buffer, |
const char *restrict | fmt, | ||
va_list | ap | ||
) |
The vsscanf_s
function reads a formatted string, and writes to a list of arguments.
Reaching the end of the string is equivalent to reaching the end-of-file condition for fscanf
.
[in] | buffer | pointer to a null-terminated string to read from |
[in] | fmt | format-control string. |
[out] | ap | arguments to write to |
buffer
nor fmt
shall be a null pointer. fmt
shall not contain the conversion specifier n
s
is a null pointer. (not yet) c
, s
, and %
[ conversion specifiers each expect two arguments (the usual pointer and a value of type rsize_t
indicating the size of the receiving array, which may be 1 when reading with a c
into a single character) and except that the following errors are detected at runtime and call the currently installed constraint handler function.EOF
if read failure occurs before the first receiving argument was assigned or if there is a runtime constraint violation.> | 0 on success, the number of arguments assigned |
EOF | on error |
EXTERN int printf_s | ( | const char *restrict | fmt, |
... | |||
) |
The printf_s function composes a string via the format string and writes it to a FILE buffer.
errno
is set on error. However, the safeclib extended ES*
errors do not set errno
, only when the underlying system vprintf
call fails, errno
is set.[in] | fmt | format-control string |
[in] | ... | optional arguments |
-ESNULLP | when fmt is NULL pointer |
-EINVAL | when fmt contains n |
-1 | on some other error. errno is set then. |
EXTERN int fprintf_s | ( | FILE *restrict | stream, |
const char *restrict | fmt, | ||
... | |||
) |
The fprintf_s function composes a string via the format string and writes it to a FILE buffer.
errno
is set on error. However, the safeclib extended ES*
errors do not set errno
, only when the underlying system vfprintf
call fails, errno
is set.[out] | stream | output file stream to write to |
[in] | fmt | format-control string. |
[in] | ... | optional arguments |
-ESNULLP | when stream/fmt is NULL pointer |
-EINVAL | when fmt contains n |
-1 | on some other error. errno is set then. |
EXTERN int vprintf_s | ( | const char *restrict | fmt, |
va_list | ap | ||
) |
The vprintf_s function composes a string via the format string and writes it to a FILE buffer.
errno
is set on error. However, the safeclib extended ES*
errors do not set errno
, only when the underlying system vprintf
call fails, errno
is set.[in] | fmt | format-control string |
[in] | ap | optional arguments |
-ESNULLP | when fmt is NULL pointer |
-EINVAL | when fmt contains n |
-1 | on some other error. errno is set then. |
EXTERN int vfprintf_s | ( | FILE *restrict | stream, |
const char *restrict | fmt, | ||
va_list | ap | ||
) |
The vfprintf_s function composes a string via the format string and writes it to a FILE buffer.
errno
is set on error. However, the safeclib extended ES*
errors do not set errno
, only when the underlying system vfprintf
call fails, errno
is set.[out] | stream | output file stream to write to |
[in] | fmt | format-control string. |
[in] | ap | optional arguments |
-ESNULLP | when stream/fmt is NULL pointer |
-EINVAL | when fmt contains n |
-1 | on some other error. errno is set then. |
EXTERN size_t strerrorlen_s | ( | errno_t | errnum | ) |
The strerrorlen_s
function returns the untruncated length of the textual description of the system error code errnum
, identical to the description that would be printed by perror()
.
[in] | errnum | integer value referring to an error code |
EXTERN errno_t _strcmp_s_chk | ( | const char * | dest, |
rsize_t | dmax, | ||
const char * | src, | ||
int * | resultp, | ||
const size_t | destbos, | ||
const size_t | srcbos | ||
) |
EXTERN errno_t _strcasecmp_s_chk | ( | const char * | dest, |
rsize_t | dmax, | ||
const char * | src, | ||
int * | resultp, | ||
const size_t | destbos | ||
) |
EXTERN errno_t _strnatcmp_s_chk | ( | const char * | dest, |
rsize_t | dmax, | ||
const char * | src, | ||
const int | fold_case, | ||
int * | resultp, | ||
const size_t | destbos, | ||
const size_t | srcbos | ||
) |
EXTERN errno_t _strcasestr_s_chk | ( | char * | dest, |
rsize_t | dmax, | ||
const char * | src, | ||
rsize_t | slen, | ||
char ** | substring, | ||
const size_t | destbos, | ||
const size_t | srcbos | ||
) |
EXTERN errno_t _strcmpfld_s_chk | ( | const char * | dest, |
rsize_t | dmax, | ||
const char * | src, | ||
int * | resultp, | ||
const size_t | destbos | ||
) |
EXTERN errno_t _strcpyfld_s_chk | ( | char * | dest, |
const rsize_t | dmax, | ||
const char * | src, | ||
rsize_t | slen, | ||
const size_t | destbos | ||
) |
EXTERN errno_t _strcpyfldin_s_chk | ( | char * | dest, |
rsize_t | dmax, | ||
const char * | src, | ||
rsize_t | slen, | ||
const size_t | destbos | ||
) |
EXTERN errno_t _strcpyfldout_s_chk | ( | char * | dest, |
rsize_t | dmax, | ||
const char * | src, | ||
rsize_t | slen, | ||
const size_t | destbos | ||
) |
EXTERN errno_t _strcspn_s_chk | ( | const char * | dest, |
rsize_t | dmax, | ||
const char * | src, | ||
rsize_t | slen, | ||
rsize_t * | countp, | ||
const size_t | destbos, | ||
const size_t | srcbos | ||
) |
EXTERN errno_t _strfirstchar_s_chk | ( | char * | dest, |
rsize_t | dmax, | ||
char | c, | ||
char ** | firstp, | ||
const size_t | destbos | ||
) |
EXTERN errno_t _strfirstdiff_s_chk | ( | const char * | dest, |
rsize_t | dmax, | ||
const char * | src, | ||
rsize_t * | resultp, | ||
const size_t | destbos | ||
) |
EXTERN errno_t _strlastchar_s_chk | ( | char * | dest, |
rsize_t | dmax, | ||
char | c, | ||
char ** | lastp, | ||
const size_t | destbos | ||
) |
EXTERN errno_t _strlastdiff_s_chk | ( | const char * | dest, |
rsize_t | dmax, | ||
const char * | src, | ||
rsize_t * | resultp, | ||
const size_t | destbos | ||
) |
EXTERN errno_t _strpbrk_s_chk | ( | char * | dest, |
rsize_t | dmax, | ||
char * | src, | ||
rsize_t | slen, | ||
char ** | firstp, | ||
const size_t | destbos, | ||
const size_t | srcbos | ||
) |
EXTERN errno_t _strfirstsame_s_chk | ( | const char * | dest, |
rsize_t | dmax, | ||
const char * | src, | ||
rsize_t * | resultp, | ||
const size_t | destbos | ||
) |
EXTERN errno_t _strlastsame_s_chk | ( | const char * | dest, |
rsize_t | dmax, | ||
const char * | src, | ||
rsize_t * | resultp, | ||
const size_t | destbos | ||
) |
EXTERN errno_t _strprefix_s_chk | ( | const char * | dest, |
rsize_t | dmax, | ||
const char * | src, | ||
const size_t | destbos | ||
) |
EXTERN errno_t _strspn_s_chk | ( | const char * | dest, |
rsize_t | dmax, | ||
const char * | src, | ||
rsize_t | slen, | ||
rsize_t * | countp, | ||
const size_t | destbos, | ||
const size_t | srcbos | ||
) |
EXTERN errno_t _strstr_s_chk | ( | char * | dest, |
rsize_t | dmax, | ||
const char * | src, | ||
rsize_t | slen, | ||
char ** | substringp, | ||
const size_t | destbos, | ||
const size_t | srcbos | ||
) |
EXTERN errno_t _strchr_s_chk | ( | const char *restrict | dest, |
rsize_t | dmax, | ||
const int | ch, | ||
char **restrict | resultp, | ||
const size_t | destbos | ||
) |
EXTERN errno_t _strrchr_s_chk | ( | const char *restrict | dest, |
rsize_t | dmax, | ||
const int | ch, | ||
char **restrict | resultp, | ||
const size_t | destbos | ||
) |
EXTERN errno_t _strcoll_s_chk | ( | const char *restrict | dest, |
rsize_t | dmax, | ||
const char *restrict | src, | ||
int * | resultp, | ||
const size_t | destbos | ||
) |
EXTERN errno_t _strnset_s_chk | ( | char *restrict | dest, |
rsize_t | dmax, | ||
int | value, | ||
rsize_t | n, | ||
const size_t | destbos | ||
) |
EXTERN errno_t n VAL_OVR2 | ( | value | , |
255 | |||
) |
EXTERN errno_t _mbstowcs_s_chk | ( | size_t *restrict | retvalp, |
wchar_t *restrict | dest, | ||
rsize_t | dmax, | ||
const char *restrict | src, | ||
rsize_t | len, | ||
const size_t | destbos | ||
) | && |
EXTERN errno_t empty dmax BOS_ATTR | ( | ! | _BOS_NULLdest) &&_BOSW_OVR(dest, dmax, |
"dest overflow" | |||
) | && == *srcp |
EXTERN errno_t _mbsrtowcs_s_chk | ( | size_t *restrict | retvalp, |
wchar_t *restrict | dest, | ||
rsize_t | dmax, | ||
const char **restrict | srcp, | ||
rsize_t | len, | ||
mbstate_t *restrict | ps, | ||
const size_t | destbos | ||
) | && |
EXTERN errno_t _wcsrtombs_s_chk | ( | size_t *restrict | retvalp, |
char *restrict | dest, | ||
rsize_t | dmax, | ||
const wchar_t **restrict | srcp, | ||
rsize_t | len, | ||
mbstate_t *restrict | ps, | ||
const size_t | destbos | ||
) | && |
EXTERN errno_t dest overflow BOS_ATTR | ( | !_BOS_NULL(dest) &&(void *) | dest = = (void*)srcp , |
"dest overlap" | |||
) | && |
EXTERN errno_t _wcstombs_s_chk | ( | size_t *restrict | retvalp, |
char *restrict | dest, | ||
rsize_t | dmax, | ||
const wchar_t *restrict | src, | ||
rsize_t | len, | ||
const size_t | destbos | ||
) |
EXTERN errno_t _wcrtomb_s_chk | ( | size_t *restrict | retvalp, |
char *restrict | dest, | ||
rsize_t | dmax, | ||
wchar_t | wc, | ||
mbstate_t *restrict | ps, | ||
const size_t | destbos | ||
) |
EXTERN errno_t _wctomb_s_chk | ( | int *restrict | retvalp, |
char *restrict | dest, | ||
rsize_t | dmax, | ||
wchar_t | wc, | ||
const size_t | destbos | ||
) | && |
EXTERN size_t _wcsnlen_s_chk | ( | const wchar_t * | dest, |
size_t | dmax, | ||
const size_t | destbos | ||
) |
EXTERN errno_t _wcscpy_s_chk | ( | wchar_t *restrict | dest, |
rsize_t | dmax, | ||
const wchar_t *restrict | src, | ||
const size_t | destbos | ||
) |
EXTERN errno_t _wcsncpy_s_chk | ( | wchar_t *restrict | dest, |
rsize_t | dmax, | ||
const wchar_t *restrict | src, | ||
rsize_t | slen, | ||
const size_t | destbos, | ||
const size_t | srcbos | ||
) |
EXTERN errno_t _wcscat_s_chk | ( | wchar_t *restrict | dest, |
rsize_t | dmax, | ||
const wchar_t *restrict | src, | ||
const size_t | destbos | ||
) |
EXTERN errno_t _wcsncat_s_chk | ( | wchar_t *restrict | dest, |
rsize_t | dmax, | ||
const wchar_t *restrict | src, | ||
rsize_t | slen, | ||
const size_t | destbos, | ||
const size_t | srcbos | ||
) | && |
EXTERN errno_t dmax empty dest or dmax BOS_ATTR | ( | slen && | _BOSW_OVR(src, slen)||_BOS_NULL(src), |
"src overflow or empty" | |||
) |
EXTERN wchar_t* _wcstok_s_chk | ( | wchar_t *restrict | dest, |
rsize_t *restrict | dmaxp, | ||
const wchar_t *restrict | delim, | ||
wchar_t **restrict | ptr, | ||
const size_t | destbos | ||
) |
EXTERN int _vswprintf_s_chk | ( | wchar_t *restrict | dest, |
rsize_t | dmax, | ||
const size_t | destbos, | ||
const wchar_t *restrict | fmt, | ||
va_list | ap | ||
) |
EXTERN int _vsnwprintf_s_chk | ( | wchar_t *restrict | dest, |
rsize_t | dmax, | ||
const size_t | destbos, | ||
const wchar_t *restrict | fmt, | ||
va_list | ap | ||
) |
EXTERN int wprintf_s | ( | const wchar_t *restrict | fmt, |
... | |||
) |
The wprintf_s function prints formatted output to stdout as wide string.
errno
is set on error. However, the safeclib extended ES*
errors do not set errno
, only when the underlying system vwprintf
call fails, errno
is set.[in] | fmt | format-control wide string. |
[in] | ... | optional arguments |
n
s
is a null pointer (not yet) -ESNULLP | when fmt is NULL pointer |
-EINVAL | when fmt contains n |
-1 | some other error. errno: EINVAL or EOVERFLOW |
EXTERN int vwprintf_s | ( | const wchar_t *restrict | fmt, |
va_list | ap | ||
) |
The vwprintf_s function prints formatted output to stdout as wide string.
[in] | fmt | format-control wide string. |
[in] | ap | optional arguments |
fmt
shall not be a null pointer. fmt
shall not contain the conversion specifier n
s
is a null pointer (not yet) -ESNULLP | when fmt is NULL pointer |
-EINVAL | when fmt contains n |
-1 | some other error. errno: EINVAL or EOVERFLOW |
EXTERN int fwprintf_s | ( | FILE *restrict | stream, |
const wchar_t *restrict | fmt, | ||
... | |||
) |
The fwprintf_s function prints formatted output to a wide stream.
errno
is set on error. However, the safeclib extended ES*
errors do not set errno
, only when the underlying system vfwprintf
call fails, errno
is set.[in] | stream | output wide stream to write to |
[in] | fmt | format-control wide string. |
[in] | ... | optional arguments |
n
s
is a null pointer (not yet) -ESNULLP | when fmt is NULL pointer |
-EINVAL | when fmt contains n |
-1 | some other error. errno: EINVAL or EOVERFLOW |
EXTERN int vfwprintf_s | ( | FILE *restrict | stream, |
const wchar_t *restrict | fmt, | ||
va_list | ap | ||
) |
The vfwprintf_s function prints formatted output to a wide stream.
errno
is set on error. However, the safeclib extended ES*
errors do not set errno
, only when the underlying system vfwprintf
call fails, errno
is set.[in] | stream | output wide stream to write to |
[in] | fmt | format-control wide string. |
[in] | ap | optional arguments |
n
s
is a null pointer (not yet) -ESNULLP | when stream or fmt is a NULL pointer |
-EINVAL | when fmt contains n |
-1 | some other error. errno: EINVAL or EOVERFLOW |
EXTERN int swscanf_s | ( | const wchar_t *restrict | src, |
const wchar_t *restrict | fmt, | ||
... | |||
) |
The swscanf_s function reads a formatted wide string.
Reaching the end of the string is equivalent to reaching the end-of-file condition for fwscanf
.
[in] | src | pointer to a null-terminated wide string to read from |
[in] | fmt | format-control wide string. |
[out] | ... | arguments to write to |
src
nor fmt
shall be a null pointer. fmt
shall not contain the conversion specifier n
s
is a null pointer. (not yet) c
, s
, and %
[ conversion specifiers each expect two arguments (the usual pointer and a value of type rsize_t
indicating the size of the receiving array, which may be 1 when reading with a lc
into a single wide character) and except that the following errors are detected at runtime and call the currently installed constraint handler function.EOF
if read failure occurs before the first receiving argument was assigned or if there is a runtime constraint violation.> | 0 on success, the number of arguments assigned |
EOF | on error |
EXTERN int vswscanf_s | ( | const wchar_t *restrict | src, |
const wchar_t *restrict | fmt, | ||
va_list | ap | ||
) |
The vswscanf_s function reads a formatted wide string.
Reaching the end of the string is equivalent to reaching the end-of-file condition for fwscanf
.
[in] | src | pointer to a null-terminated wide string to read from |
[in] | fmt | format-control wide string. |
[in] | ap | arguments to write to |
src
nor fmt
shall be a null pointer. fmt
shall not contain the conversion specifier n
s
is a null pointer. (not yet) c
, s
, and %
[ conversion specifiers each expect two arguments (the usual pointer and a value of type rsize_t
indicating the size of the receiving array, which may be 1 when reading with a lc
into a single wide character) and except that the following errors are detected at runtime and call the currently installed constraint handler function.EOF
if read failure occurs before the first receiving argument was assigned or if there is a runtime constraint violation.> | 0 on success, the number of arguments assigned |
EOF | on error |
EXTERN int wscanf_s | ( | const wchar_t *restrict | fmt, |
... | |||
) |
The wscanf_s
function reads a formatted wide string from stdin.
Reaching the end of the stdin buffer is equivalent to reaching the end-of-file condition for wscanf
.
[in] | fmt | format-control wide string. |
[out] | ... | arguments to write to |
fmt
shall be a null pointer. fmt
shall not contain the conversion specifier n
s
is a null pointer. (not yet) c
, s
, and %
[ conversion specifiers each expect two arguments (the usual pointer and a value of type rsize_t
indicating the size of the receiving array, which may be 1 when reading with a lc
into a single wide character) and except that the following errors are detected at runtime and call the currently installed constraint handler function.EOF
if read failure occurs before the first receiving argument was assigned or if there is a runtime constraint violation.> | 0 on success, the number of arguments assigned |
EOF | on error |
EXTERN int vwscanf_s | ( | const wchar_t *restrict | fmt, |
va_list | ap | ||
) |
The vwscanf_s
function reads a formatted wide string from stdin.
Reaching the end of the stdin buffer is equivalent to reaching the end-of-file condition for vwscanf
.
[in] | fmt | format-control wide string. |
[out] | ap | arguments to write to |
stream
nor fmt
shall be a null pointer. fmt
shall not contain the conversion specifier n
s
is a null pointer. (not yet) c
, s
, and %
[ conversion specifiers each expect two arguments (the usual pointer and a value of type rsize_t
indicating the size of the receiving array, which may be 1 when reading with a lc
into a single wide character) and except that the following errors are detected at runtime and call the currently installed constraint handler function.EOF
if read failure occurs before the first receiving argument was assigned or if there is a runtime constraint violation.> | 0 on success, the number of arguments assigned |
EOF | on error |
EXTERN int fwscanf_s | ( | FILE *restrict | stream, |
const wchar_t *restrict | fmt, | ||
... | |||
) |
The fwscanf_s
function reads a formatted wide string.
Reaching the end of the string is equivalent to reaching the end-of-file condition for fwscanf
.
[in] | stream | pointer to a FILE stream to read from |
[in] | fmt | format-control wide string. |
[out] | ... | arguments to write to |
stream
nor fmt
shall be a null pointer. fmt
shall not contain the conversion specifier n
s
is a null pointer. (not yet) Note it currently even crashes with a NULL pointer. c
, s
, and %
[ conversion specifiers each expect two arguments (the usual pointer and a value of type rsize_t
indicating the size of the receiving array, which may be 1 when reading with a lc
into a single wide character) and except that the following errors are detected at runtime and call the currently installed constraint handler function.EOF
if read failure occurs before the first receiving argument was assigned or if there is a runtime constraint violation.> | 0 on success, the number of arguments assigned |
EOF | on error |
EXTERN int vfwscanf_s | ( | FILE *restrict | stream, |
const wchar_t *restrict | fmt, | ||
va_list | ap | ||
) |
The vfwscanf_s
function reads a formatted wide string.
Reaching the end of the string is equivalent to reaching the end-of-file condition for fwscanf
.
[in] | stream | pointer to a FILE stream to read from |
[in] | fmt | format-control wide string. |
[out] | ap | arguments to write to |
stream
nor fmt
shall be a null pointer. fmt
shall not contain the conversion specifier n
s
is a null pointer. (not yet) c
, s
, and %
[ conversion specifiers each expect two arguments (the usual pointer and a value of type rsize_t
indicating the size of the receiving array, which may be 1 when reading with a lc
into a single wide character) and except that the following errors are detected at runtime and call the currently installed constraint handler function.EOF
if read failure occurs before the first receiving argument was assigned or if there is a runtime constraint violation.> | 0 on success, the number of arguments assigned |
EOF | on error |
EXTERN errno_t _wcsstr_s_chk | ( | wchar_t *restrict | dest, |
rsize_t | dmax, | ||
const wchar_t *restrict | src, | ||
rsize_t | slen, | ||
wchar_t **restrict | substringp, | ||
const size_t | destbos, | ||
const size_t | srcbos | ||
) |
EXTERN errno_t _wcscmp_s_chk | ( | const wchar_t *restrict | dest, |
rsize_t | dmax, | ||
const wchar_t *restrict | src, | ||
rsize_t | smax, | ||
int * | resultp, | ||
const size_t | destbos, | ||
const size_t | srcbos | ||
) |
EXTERN errno_t _wcsncmp_s_chk | ( | const wchar_t *restrict | dest, |
rsize_t | dmax, | ||
const wchar_t *restrict | src, | ||
rsize_t | smax, | ||
rsize_t | count, | ||
int * | resultp, | ||
const size_t | destbos, | ||
const size_t | srcbos | ||
) |
EXTERN errno_t _wcsicmp_s_chk | ( | const wchar_t *restrict | dest, |
rsize_t | dmax, | ||
const wchar_t *restrict | src, | ||
rsize_t | smax, | ||
int * | resultp, | ||
const size_t | destbos, | ||
const size_t | srcbos | ||
) |
EXTERN errno_t _wcsnatcmp_s_chk | ( | const wchar_t *restrict | dest, |
rsize_t | dmax, | ||
const wchar_t *restrict | src, | ||
rsize_t | smax, | ||
const int | fold_case, | ||
int * | resultp, | ||
const size_t | destbos, | ||
const size_t | srcbos | ||
) |
EXTERN errno_t _wcsset_s_chk | ( | wchar_t *restrict | dest, |
rsize_t | dmax, | ||
const wchar_t | value, | ||
const size_t | destbos | ||
) |
EXTERN errno_t _wcsnset_s_chk | ( | wchar_t *restrict | dest, |
rsize_t | dmax, | ||
const wchar_t | value, | ||
size_t | n, | ||
const size_t | destbos | ||
) |
EXTERN errno_t _wcscoll_s_chk | ( | const wchar_t *restrict | dest, |
rsize_t | dmax, | ||
const wchar_t *restrict | src, | ||
rsize_t | smax, | ||
int * | resultp, | ||
const size_t | destbos, | ||
const size_t | srcbos | ||
) |
EXTERN int iswfc | ( | const uint32_t | wc | ) |
EXTERN int EXTERN int _towfc_s_chk | ( | wchar_t *restrict | dest, |
rsize_t | dmax, | ||
const uint32_t | src, | ||
const size_t | destbos | ||
) |
EXTERN errno_t dmax |
EXTERN errno_t slen |
EXTERN errno_t empty* dest |