posix-next API 0.1.0
Out-of-tree Zephyr POSIX module
Loading...
Searching...
No Matches
POSIX_C_LIB_EXT
Implementation completeness: 100.0%100IMPLLine coverage: 90.7%91COVLinux compatibility tests: passing🐧

POSIX C Library Extension option group. More...

Files

file  monetary.h
 POSIX monetary formatting functions (<monetary.h>)
 
file  strings.h
 POSIX string operations (<strings.h>)
 

Macros

#define FNM_NOMATCH   1
 Return value of fnmatch() indicating the string did not match the pattern.
 
#define FNM_NOESCAPE   0x01
 Flag: treat backslash as an ordinary character rather than an escape character.
 
#define FNM_PATHNAME   0x02
 Flag: a slash must be matched by a slash (not '?' or '*' or a bracket expression).
 
#define FNM_PERIOD   0x04
 Flag: a leading '.
 
#define FNM_IGNORECASE   FNM_CASEFOLD
 Alias for FNM_CASEFOLD.
 

Functions

int fnmatch (const char *pattern, const char *string, int flags)
 Match a filename or path against a shell-style pattern.
 
ssize_t strfmon (char *ZRESTRICT s, size_t maxsize, const char *ZRESTRICT format,...)
 Format a monetary value into a string according to the current locale.
 
ssize_t strfmon_l (char *ZRESTRICT s, size_t maxsize, locale_t locale, const char *ZRESTRICT format,...)
 Format a monetary value using the specified locale.
 
int dprintf (int fildes, const char *ZRESTRICT format,...)
 Print formatted output to a file descriptor.
 
FILE * fmemopen (void *ZRESTRICT buf, size_t size, const char *ZRESTRICT mode)
 Open a memory-backed stream.
 
ssize_t getdelim (char **ZRESTRICT lineptr, size_t *ZRESTRICT n, int delimiter, FILE *ZRESTRICT stream)
 Read a delimited record from a stream.
 
ssize_t getline (char **ZRESTRICT lineptr, size_t *ZRESTRICT n, FILE *ZRESTRICT stream)
 Read a line from a stream.
 
FILE * open_memstream (char **bufp, size_t *sizep)
 Open a dynamic memory output stream.
 
int vdprintf (int fildes, const char *ZRESTRICT format, va_list ap)
 Print formatted output to a file descriptor.
 
int getsubopt (char **optionp, char *const *keylistp, char **valuep)
 Parse sub-options from a command-line argument string.
 
char * stpcpy (char *ZRESTRICT s1, const char *ZRESTRICT s2)
 Copy a string and return a pointer to the terminating NUL byte.
 
char * stpncpy (char *ZRESTRICT s1, const char *ZRESTRICT s2, size_t n)
 Copy at most n bytes of a string and return a pointer to the terminating NUL byte.
 
char * strdup (const char *s)
 Duplicate a string.
 
char * strndup (const char *s, size_t n)
 Duplicate at most n bytes of a string.
 
size_t strnlen (const char *s, size_t maxlen)
 Determine the length of a fixed-size string.
 
size_t strftime_l (char *ZRESTRICT s, size_t maxsize, const char *ZRESTRICT format, const struct tm *ZRESTRICT timeptr, locale_t locale)
 Format broken-down time into a string using the specified locale.
 
int strcasecmp (const char *s1, const char *s2)
 Compare two strings, ignoring case.
 
int strncasecmp (const char *s1, const char *s2, size_t n)
 Compare two strings, ignoring case, up to a maximum length.
 
int getentropy (void *buffer, size_t length)
 Fill a buffer with cryptographically secure random bytes.
 
int getopt (int argc, char *const argv[], const char *optstring)
 Parse command-line options.
 

Variables

char * optarg
 Argument for the current option from getopt().
 
int opterr
 Error flag for getopt() (non-zero enables error messages).
 
int optind
 Index of the next element to be processed by getopt().
 
int optopt
 Unrecognised option character from getopt().
 

Detailed Description

POSIX C Library Extension option group.

Covers XSI string and option-parsing extensions such as strdup(), strcasecmp(), and getsubopt().

Macro Definition Documentation

◆ FNM_IGNORECASE

#define FNM_IGNORECASE   FNM_CASEFOLD

Alias for FNM_CASEFOLD.

Definition at line 48 of file fnmatch.h.

◆ FNM_NOESCAPE

#define FNM_NOESCAPE   0x01

Flag: treat backslash as an ordinary character rather than an escape character.

Definition at line 28 of file fnmatch.h.

◆ FNM_NOMATCH

#define FNM_NOMATCH   1

Return value of fnmatch() indicating the string did not match the pattern.

Definition at line 25 of file fnmatch.h.

◆ FNM_PATHNAME

#define FNM_PATHNAME   0x02

Flag: a slash must be matched by a slash (not '?' or '*' or a bracket expression).

Definition at line 31 of file fnmatch.h.

◆ FNM_PERIOD

#define FNM_PERIOD   0x04

Flag: a leading '.

' must be matched explicitly.

Definition at line 34 of file fnmatch.h.

Function Documentation

◆ dprintf()

int dprintf ( int  fildes,
const char *ZRESTRICT  format,
  ... 
)

Print formatted output to a file descriptor.

Parameters
fildesOpen file descriptor to write to.
formatFormat string.
...Additional arguments for the format string.
Returns
Number of bytes written, or -1 on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/dprintf.html

◆ fmemopen()

FILE * fmemopen ( void *ZRESTRICT  buf,
size_t  size,
const char *ZRESTRICT  mode 
)

Open a memory-backed stream.

Parameters
bufInitial buffer, or NULL to allocate automatically.
sizeSize of buf when supplied by the caller.
modeMode string as for fopen().
Returns
Pointer to the stream, or NULL on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/fmemopen.html

◆ fnmatch()

int fnmatch ( const char *  pattern,
const char *  string,
int  flags 
)
fnmatch line coverage: 100.0%100Linux compatibility tests: passing🐧

Match a filename or path against a shell-style pattern.

Parameters
patternShell pattern (using ?, *, and bracket expressions).
stringString to test against pattern.
flagsCombination of FNM_* flags, or 0 for default matching.
Returns
0 if string matches pattern, FNM_NOMATCH if it does not, or a non-zero value on error.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/fnmatch.html

◆ getdelim()

ssize_t getdelim ( char **ZRESTRICT  lineptr,
size_t *ZRESTRICT  n,
int  delimiter,
FILE *ZRESTRICT  stream 
)

Read a delimited record from a stream.

Parameters
lineptrPointer to the buffer pointer; updated on return.
nPointer to the buffer size; updated on return.
delimiterRecord delimiter byte.
streamStream to read from.
Returns
Number of bytes read, excluding the delimiter and NUL terminator, 0 at end-of-file with no data read, or -1 on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/getdelim.html

◆ getentropy()

int getentropy ( void *  buffer,
size_t  length 
)

Fill a buffer with cryptographically secure random bytes.

See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/getentropy.html

◆ getline()

ssize_t getline ( char **ZRESTRICT  lineptr,
size_t *ZRESTRICT  n,
FILE *ZRESTRICT  stream 
)

Read a line from a stream.

Parameters
lineptrPointer to the buffer pointer; updated on return.
nPointer to the buffer size; updated on return.
streamStream to read from.
Returns
Number of bytes read, excluding the newline and NUL terminator, 0 at end-of-file with no data read, or -1 on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/getline.html

◆ getopt()

int getopt ( int  argc,
char *const  argv[],
const char *  optstring 
)
getopt line coverage: 100.0%100Linux compatibility tests: passing🐧

Parse command-line options.

See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/getopt.html

◆ getsubopt()

int getsubopt ( char **  optionp,
char *const *  keylistp,
char **  valuep 
)
getsubopt line coverage: 94.7%95Linux compatibility tests: passing🐧

Parse sub-options from a command-line argument string.

Modifies *optionp in place, separating comma-delimited sub-options.

Parameters
optionpPointer to the option string; advanced past each parsed token.
keylistpNULL-terminated array of recognised keyword strings.
valuepOutput: pointer to the value part after '=', or NULL.
Returns
Index into keylistp of the matched keyword, or -1 if not found.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/getsubopt.html

◆ open_memstream()

FILE * open_memstream ( char **  bufp,
size_t *  sizep 
)

Open a dynamic memory output stream.

Parameters
bufpPointer to the buffer pointer; updated on return.
sizepPointer to the buffer size; updated on return.
Returns
Pointer to the stream, or NULL on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/open_memstream.html

◆ stpcpy()

char * stpcpy ( char *ZRESTRICT  s1,
const char *ZRESTRICT  s2 
)
Linux compatibility tests: passing🐧

Copy a string and return a pointer to the terminating NUL byte.

Parameters
s1Destination buffer.
s2Source string.
Returns
Pointer to the terminating NUL byte written to s1.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/stpcpy.html

◆ stpncpy()

char * stpncpy ( char *ZRESTRICT  s1,
const char *ZRESTRICT  s2,
size_t  n 
)
stpncpy line coverage: 90.9%91Linux compatibility tests: passing🐧

Copy at most n bytes of a string and return a pointer to the terminating NUL byte.

Parameters
s1Destination buffer.
s2Source string.
nMaximum number of bytes to copy from s2.
Returns
Pointer to the terminating NUL byte written to s1, or NULL if n is zero.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/stpncpy.html

◆ strcasecmp()

int strcasecmp ( const char *  s1,
const char *  s2 
)
strcasecmp line coverage: 100.0%100Linux compatibility tests: passing🐧

Compare two strings, ignoring case.

Parameters
s1First string.
s2Second string.
Returns
An integer less than, equal to, or greater than zero if s1 is found, respectively, to be less than, equal to, or greater than s2.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/strcasecmp.html

◆ strdup()

char * strdup ( const char *  s)
Linux compatibility tests: passing🐧

Duplicate a string.

Parameters
sSource string.
Returns
Pointer to newly allocated memory containing the duplicate, or NULL on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/strdup.html

◆ strfmon()

ssize_t strfmon ( char *ZRESTRICT  s,
size_t  maxsize,
const char *ZRESTRICT  format,
  ... 
)
strfmon line coverage: 90.9%91Linux compatibility tests: passing🐧

Format a monetary value into a string according to the current locale.

Parameters
sOutput buffer.
maxsizeMaximum number of bytes (including NUL) to write.
formatConversion format string (%-based, similar to printf).
...Monetary values to format (type double).
Returns
Number of bytes written (excluding NUL) on success, or -1 on error.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/strfmon.html

◆ strfmon_l()

ssize_t strfmon_l ( char *ZRESTRICT  s,
size_t  maxsize,
locale_t  locale,
const char *ZRESTRICT  format,
  ... 
)

Format a monetary value using the specified locale.

Parameters
sOutput buffer.
maxsizeMaximum number of bytes (including NUL) to write.
localeLocale to use for formatting.
formatConversion format string.
...Monetary values to format (type double).
Returns
Number of bytes written (excluding NUL) on success, or -1 on error.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/strfmon_l.html

◆ strftime_l()

size_t strftime_l ( char *ZRESTRICT  s,
size_t  maxsize,
const char *ZRESTRICT  format,
const struct tm *ZRESTRICT  timeptr,
locale_t  locale 
)

Format broken-down time into a string using the specified locale.

Parameters
sOutput buffer.
maxsizeMaximum number of bytes to write including the NUL terminator.
formatFormat string (same syntax as strftime()).
timeptrBroken-down time to format.
localeLocale to use for formatting.
Returns
Number of bytes written (excluding NUL) on success, or 0 if maxsize was exceeded.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/strftime_l.html

◆ strncasecmp()

int strncasecmp ( const char *  s1,
const char *  s2,
size_t  n 
)
strncasecmp line coverage: 100.0%100Linux compatibility tests: passing🐧

Compare two strings, ignoring case, up to a maximum length.

Parameters
s1First string.
s2Second string.
nMaximum number of bytes to compare.
Returns
An integer less than, equal to, or greater than zero if the first n bytes of s1 are found, respectively, to be less than, equal to, or greater than those of s2.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/strncasecmp.html

◆ strndup()

char * strndup ( const char *  s,
size_t  n 
)
strndup line coverage: 100.0%100Linux compatibility tests: passing🐧

Duplicate at most n bytes of a string.

Parameters
sSource string.
nMaximum number of bytes to copy from s.
Returns
Pointer to newly allocated memory containing the duplicate, or NULL on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/strndup.html

◆ strnlen()

size_t strnlen ( const char *  s,
size_t  maxlen 
)
strnlen line coverage: 100.0%100Linux compatibility tests: passing🐧

Determine the length of a fixed-size string.

Parameters
sSource string.
maxlenMaximum number of bytes to examine.
Returns
Number of bytes in s, excluding the terminating NUL byte, if that number is less than maxlen; otherwise maxlen.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/strnlen.html

◆ vdprintf()

int vdprintf ( int  fildes,
const char *ZRESTRICT  format,
va_list  ap 
)

Print formatted output to a file descriptor.

Parameters
fildesOpen file descriptor to write to.
formatFormat string.
apArguments for the format string.
Returns
Number of bytes written, or -1 on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/vdprintf.html

Variable Documentation

◆ optarg

char* optarg
extern

Argument for the current option from getopt().

◆ opterr

int opterr
extern

Error flag for getopt() (non-zero enables error messages).

◆ optind

int optind
extern

Index of the next element to be processed by getopt().

◆ optopt

int optopt
extern

Unrecognised option character from getopt().