safec  3.2
Safe C Library - ISO TR24731 Bounds Checking Interface
strprefix_s.c File Reference
#include "safe_str_lib.h"
+ Include dependency graph for strprefix_s.c:

Functions

EXPORT errno_t strprefix_s (const char *dest, rsize_t dmax, const char *src)
 Determines if the prefix pointed to by src is at the beginning of string pointed to by dest. More...
 

Function Documentation

◆ strprefix_s()

EXPORT errno_t strprefix_s ( const char *  dest,
rsize_t  dmax,
const char *  src 
)

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.

Remarks
EXTENSION TO ISO/IEC TR 24731-1, Programming languages, environments and system software interfaces, Extensions to the C Library, Part I: Bounds-checking interfaces
Parameters
destpointer to string to compare against
dmaxrestricted maximum length of dest
srcpointer to the prefix
Precondition
Neither dest nor src shall be a null pointer.
Neither dmax nor slen shall not be 0.
Neither dmax nor slen shall not be greater than RSIZE_MAX_STR.
Return values
EOKwhen successful operation, substring found.
ESNULLPwhen dest/src/substring is NULL pointer
ESZEROLwhen dmax/slen = 0
ESLEMAXwhen dmax/slen > RSIZE_MAX_STR
ESNOTFNDwhen prefix not found in dest
See also
strspn_s(), strcspn_s(), strpbrk_s(), strstr_s()