UTILS

Overview

Provides functions and data structures related to system operations, such as string conversion and I/O, string operations, process operations and so on.

Since:

1.0

Version:

1.0

Summary

Files

File Name

Description

bitsperlong.h

Defines the number of bits of the long data type.

errno.h

Defines error codes.

crypt.h

Encrypts data.

ctype.h

Provides functions used for parameter identification.

fmtmsg.h

Provides a function for printing formatted messages.

fnmatch.h

Provides a function for checking whether a specified string matches a string that contains wildcards.

getopt.h

Provides functions and data structures, such as command-line argument parsing.

inttypes.h

Provides functions and related data structures for conversion between character strings and plural.

limits.h

Declares commonly used macro values.

monetary.h

Provides functions for converting monetary values.

search.h

Provides functions and related data structures, such as creating, destroying, or searching for a hash table.

stdarg.h

Provides functions and data structures, such as applying for and ending a variable-length argument list and obtaining an argument type.

stdlib.h

Declares common functions used for performing I/O operations.

string.h

Declares commonly used functions for string operations.

strings.h

Declares commonly used functions for byte sequence operations.

unistd.h

Provides functions and data structures related to process operations.

wchar.h

Declares commonly used functions related to wide characters.

wctype.h

Provides functions to detect, translate, and map wide characters.

Data Structures

Data Structure Name

Description

option

Defines the command parsing option.

imaxdiv_t

Stores the division result.

entry

Defines a hash table entry.

qelem

Creates a queue from the doubly linked list for insque and remque.

hsearch_data

Defines a hash table.

div_t

Defines the structures of the division operation result.

ldiv_t

Defines the structures of the division operation result.

lldiv_t

Defines the structures of the division operation result.

Macros

Macro Name and Value

Description

BITS_PER_LONG    32

Defines the number of bits of the long data type.

EPERM    1

Operation not permitted.

ENOENT    2

No such file or path.

ESRCH    3

No such process.

EINTR    4

Interrupted function call.

EIO    5

I/O error.

ENXIO    6

No such device or address.

E2BIG    7

Parameter list too long.

ENOEXEC    8

Exec format error.

EBADF    9

Bad file descriptor.

ECHILD    10

No child processes.

EAGAIN    11

Retry.

ENOMEM    12

Not enough memory space.

EACCES    13

Incorrect permission.

EFAULT    14

Invalid address.

ENOTBLK    15

Block device request.

EBUSY    16

Device or resource busy.

EEXIST    17

File exists.

EXDEV    18

Incorrect link.

ENODEV    19

No such device.

ENOTDIR    20

Not a directory.

EISDIR    21

Is a directory.

EINVAL    22

Invalid parameter.

ENFILE    23

Too many opened files in system (the maximum number exceeded)

EMFILE    24

Too many opened files in a process (the maximum number exceeded)

ENOTTY    25

Inappropriate I/O control operation.

ETXTBSY    26

Text file busy.

EFBIG    27

File too large.

ENOSPC    28

No space left on device.

ESPIPE    29

Invalid query.

EROFS    30

Read-only file system.

EMLINK    31

Too many links.

EPIPE    32

The pipe file is incorrect or the read end of the pipe is closed during the write operation.

EDOM    33

Domain error. The value of at least one input parameter is out of the parameter range.

ERANGE    34

The actual return value exceeds the return value range.

EDEADLK    35

Resource deadlock.

ENAMETOOLONG    36

File name too long.

ENOLCK    37

No locks available.

ENOSYS    38

Function not implemented.

ENOTEMPTY    39

Directory not empty.

ELOOP    40

Too many levels of symbolic links.

EWOULDBLOCK    EAGAIN

Operation would block (the same value as EAGAIN)

ENOMSG    42

No message of the desired type.

EIDRM    43

Identifier removed.

ECHRNG    44

Channel number out of range.

EL2NSYNC    45

Level 2 not synchronized.

EL3HLT    46

Level 3 halted.

EL3RST    47

Level 3 reset.

ELNRNG    48

Link ID out of range.

EUNATCH    49

Protocol driver not attached.

ENOCSI    50

No available CSI structure.

EL2HLT    51

Level 2 halted.

EBADE    52

Invalid exchange.

EBADR    53

Invalid request descriptor.

EXFULL    54

Exchange full.

ENOANO    55

No anode.

EBADRQC    56

Invalid request code.

EBADSLT    57

Invalid slot.

EDEADLOCK    EDEADLK

Resource deadlock (the same value as EDEADLK)

EBFONT    59

Incorrect font format.

ENOSTR    60

Not a stream device.

ENODATA    61

No message is available on the stream head read queue.

ETIME    62

Timer expired.

ENOSR    63

No stream resources.

ENONET    64

Machine is disconnected from the network.

ENOPKG    65

Package not installed.

EREMOTE    66

Object is remote.

ENOLINK    67

Link has been severed.

EADV    68

Broadcast error.

ESRMNT    69

srmount error

ECOMM    70

Communication error on send.

EPROTO    71

Protocol error.

EMULTIHOP    72

Multi-hop attempt.

EDOTDOT    73

RFS-specific error.

EBADMSG    74

Non-data message.

EOVERFLOW    75

Value too large to be represented by the defined data type.

ENOTUNIQ    76

Name not unique on the network.

EBADFD    77

File descriptor in the bad state.

EREMCHG    78

Remote address changed.

ELIBACC    79

Cannot access a needed shared library.

ELIBBAD    80

Accessing a corrupted shared library.

ELIBSCN    81

lib section in a.out corrupted

ELIBMAX    82

Attempting to link in too many shared libraries.

ELIBEXEC    83

Cannot execute a shared library directly.

EILSEQ    84

Invalid byte sequence.

ERESTART    85

Interrupted system call should be restarted.

ESTRPIPE    86

Stream pipe error.

EUSERS    87

Too many users.

ENOTSOCK    88

Not a socket.

EDESTADDRREQ    89

Destination address required.

EMSGSIZE    90

Message too long.

EPROTOTYPE    91

Socket protocol error.

ENOPROTOOPT    92

Protocol not available.

EPROTONOSUPPORT    93

Protocol not supported.

ESOCKTNOSUPPORT    94

Socket type not supported.

EOPNOTSUPP    95

Operation not supported on socket.

ENOTSUP    EOPNOTSUPP

Operation not supported on socket. The value is the same as that of EOPNOTSUPP.

EPFNOSUPPORT    96

Protocol family not supported.

EAFNOSUPPORT    97

Address family not supported.

EADDRINUSE    98

Address already in use.

EADDRNOTAVAIL    99

Address not available.

ENETDOWN    100

Network is down.

ENETUNREACH    101

Network unreachable.

ENETRESET    102

Network disconnection caused by restart.

ECONNABORTED    103

Network disconnection caused by software problems.

ECONNRESET    104

Connection reset.

ENOBUFS    105

No buffer space available.

EISCONN    106

Socket is connected.

ENOTCONN    107

Socket disconnected.

ESHUTDOWN    108

Cannot send after transport endpoint shutdown.

ETOOMANYREFS    109

Cannot splice due to too many references.

ETIMEDOUT    110

Connection timed out.

ECONNREFUSED    111

Connection refused.

EHOSTDOWN    112

Host is down.

EHOSTUNREACH    113

Host is unreachable.

EALREADY    114

Operation already in process.

EINPROGRESS    115

Operation in progress.

ESTALE    116

Stale file handle.

EUCLEAN    117

Structure needs cleaning.

ENOTNAM    118

Not a XENIX named type file.

ENAVAIL    119

No XENIX semaphores available.

EISNAM    120

Duplicate file name.

EREMOTEIO    121

Remote I/O error.

EDQUOT    122

Quota exceeded.

ENOMEDIUM    123

No medium found.

EMEDIUMTYPE    124

Wrong medium type.

ECANCELED    125

Operation canceled.

ENOKEY    126

Required key not available.

EKEYEXPIRED    127

Key has expired.

EKEYREVOKED    128

Key has been revoked.

EKEYREJECTED    129

Key was rejected by service.

EOWNERDEAD    130

Resource owner died.

ENOTRECOVERABLE    131

State not recoverable.

ERFKILL    132

Operation not possible due to RF-kill.

EHWPOISON    133

Hardware errors on the memory page.

_tolower(a)   ((a)|0x20)

Converts an uppercase letter to its lowercase equivalent.

_toupper(a)   ((a)&0x5f)

Converts a lowercase letter to its uppercase equivalent.

isascii(a)   (0 ? isascii(a) : (unsigned)(a) < 128)

Checks whether a parameter is an ASCII character.

MM_HARD    1

A hardware error occurred.

MM_SOFT    2

A software error occurred.

MM_FIRM    4

A firmware error occurred.

MM_APPL    8

An error is detected by an application.

MM_UTIL    16

An error is detected by a utility.

MM_OPSYS    32

An error is detected by the operating system.

MM_RECOVER    64

The error is recoverable.

MM_NRECOV    128

The error is non-recoverable.

MM_PRINT    256

Prints error messages on standard error (stderr).

MM_CONSOLE    512

Prints error messages on the system console.

MM_NULLMC    0L

Ignores the classification parameter.

MM_HALT    1

Fatal fault.

MM_ERROR    2

Error-level fault.

MM_WARNING    3

Warning condition.

MM_INFO    4

Informative message.

MM_NOSEV    0

No severity level is set, equivalent to MM_NULLSEV.

MM_OK    0

The function succeeded.

MM_NOTOK    (-1)

The function failed.

MM_NOMSG    1

Error writing to stderr.

MM_NOCON    4

Error writing to the console.

MM_NULLLBL    ((char)0)

Ignores the label parameter.

MM_NULLTXT    ((char)0)

Ignores the text parameter.

MM_NULLACT    ((char)0)

Ignores the action parameter.

MM_NULLTAG    ((char)0)

Ignores the tag parameter.

MM_NULLSEV    0

Ignores the severity parameter.

FNM_PATHNAME    0x1

If this flag is set, a slash (/) in string can be matched by a slash (/) in pattern, but not by an asterisk (), or a question mark (?), or a bracket expression ([]) containing a slash.

FNM_NOESCAPE    0x2

If this flag is set, the backslash () is treated as an ordinary character, instead of an escape character.

FNM_PERIOD    0x4

If this flag is set, a leading period (.) in string can be exactly matched by the period (.) in pattern. A period is considered to be leading if it is the first character in string, or if both FNM_PATHNAME is set and the period immediately follows a slash.

FNM_LEADING_DIR    0x8

If this flag is set, a trailing sequence of characters starting with a slash (/) is ignored in string. For example, if this flag is set, either foo or foobar as a pattern would match the string foobar/frobozz.

FNM_CASEFOLD    0x10

If this flag is set, the pattern is matched case-insensitively.

FNM_FILE_NAME    FNM_PATHNAME

The definition is similar to that of FNM_PATHNAME.

FNM_NOMATCH    1

The string parameter does not match the pattern parameter.

FNM_NOSYS    (-1)

The function does not support the operation.

CHAR_MIN    0

Minimum value of type char.

CHAR_MAX    255

Maximum value of type char.

CHAR_BIT    8

Number of bits in type char.

SCHAR_MIN    (-128)

Minimum value of type signed char.

SCHAR_MAX    127

Maximum value of type signed char.

UCHAR_MAX    255

Maximum value of type unsigned char.

SHRT_MIN    (-1-0x7fff)

Minimum value of type short.

SHRT_MAX    0x7fff

Maximum value of type short.

USHRT_MAX    0xffff

Maximum value of type unsigned short.

INT_MIN    (-1-0x7fffffff)

Minimum value of type int.

INT_MAX    0x7fffffff

Maximum value of type int.

UINT_MAX    0xffffffffU

Maximum value of type unsigned int.

LONG_MAX    0x7fffffffL

Maximum value of type long.

LONG_MIN    (-LONG_MAX-1)

Minimum value of type long.

LONG_MAX    LONG_MAX

Maximum value of type long.

ULONG_MAX    (2ULLONG_MAX+1)

Maximum value of type unsigned long.

LLONG_MIN    (-LLONG_MAX-1)

Minimum value of type long long.

LLONG_MAX    0x7fffffffffffffffLL

Maximum value of type long long.

ULLONG_MAX    (2ULLLLONG_MAX+1)

Maximum value of type unsigned long long.

PIPE_BUF    4096

Buffer length of pipe.

NAME_MAX    255

Maximum length of file or directory name.

PATH_MAX    256

Maximum length of the whole file or directory path.

ARG_MAX    4096

Maximum length of parameter arg.

IOV_MAX    1024

Maximum vector number.

WORD_BIT    32

Number of bits in word.

SSIZE_MAX    LONG_MAX

Maximum value of type ssize_t.

HOST_NAME_MAX    255

Maximum length of host name.

LONG_BIT    32

Number of bits in long.

MQ_PRIO_MAX    1

Maximum priority number of message queue.

PAGESIZE    4096

Page size.

PAGE_SIZE    PAGESIZE

Page size.

va_start(v, l)   builtin_va_start(v,l)

Defines the start position of the variable-length argument list.

va_end(v)   builtin_va_end(v)

Ends a variable-length argument list.

va_arg(v, l)   builtin_va_arg(v,l)

Obtains the next argument in the variable-length argument list.

va_copy(d, s)   __builtin_va_copy(d,s)

Copies the previously initialized variable argument list s to d.

strdupa(x)   strcpy(alloca(strlen(x)+1),x)

Copies a string to a new position.

STDIN_FILENO    0

Descriptor ID of the standard input file.

STDOUT_FILENO    1

Descriptor ID of the standard output file.

STDERR_FILENO    2

Descriptor ID of the standard error file.

SEEK_SET    0

Relocation starts from the file header.

SEEK_CUR    1

Relocation starts from the position of the currently accessed file.

SEEK_END    2

Relocation starts from the end of the file.

NULL    ((void*)0)

NULL.

F_OK    0

Existing file.

R_OK    4

Readable file.

W_OK    2

Writable file.

X_OK    1

Executable file.

Typedefs

Typedef Name

Description

ENTRY

typedef struct entry 

Defines a hash table entry.

Functions

Function Name

Description

crypt (const char key, const char setting)

char  

Encrypts data.

isalnum (int c)

int 

Checks whether a parameter is an alphabetic character or a decimal digit.

isalpha (int c)

int 

Checks whether a parameter is an alphabetic character.

isblank (int c)

int 

Checks whether a parameter is a blank character (space or tap).

iscntrl (int c)

int 

Checks whether a parameter is a control character. A control character is invisible and does not occupy a printing position on a display.

isdigit (int c)

int 

Checks whether a parameter is a decimal digit (0-9).

isgraph (int c)

int 

Checks whether a parameter is any printable character except the space character.

islower (int c)

int 

Checks whether a parameter is a lowercase letter.

isprint (int c)

int 

Checks whether a parameter is a printable character (including space).

ispunct (int c)

int 

Checks whether a parameter is a punctuation or special character.

isspace (int c)

int 

Checks whether a parameter is a space character.

isupper (int c)

int 

Checks whether a parameter is an uppercase letter.

isxdigit (int c)

int 

Checks whether a parameter is a hexadecimal digit.

tolower (int c)

int 

Converts an uppercase letter specified by c to its lowercase equivalent.

toupper (int c)

int 

Converts a lowercase letter specified by c to its uppercase equivalent.

isalnum_l (int c, locale_t locale)

int 

Checks whether a parameter is an alphabetic character or digit for the specified locale.

isalpha_l (int c, locale_t locale)

int 

Checks whether a parameter is an alphabetic character for the specified locale.

isblank_l (int c, locale_t locale)

int 

Checks whether a parameter is a blank character (including spaces and tabs) for the specified locale.

iscntrl_l (int c, locale_t locale)

int 

Checks whether a parameter is a control character for the specified locale.

isdigit_l (int c, locale_t locale)

int 

Checks whether a parameter is a decimal digit for the specified locale.

isgraph_l (int c, locale_t locale)

int 

Checks whether a parameter is any printable character except the space character for the specified locale.

islower_l (int c, locale_t locale)

int 

Checks whether a parameter is a character of lowercase letters for the specified locale.

isprint_l (int c, locale_t locale)

int 

Checks whether a parameter is a printable character (including space) for the specified locale. A printable character is visible and occupies a printing position on a display.

ispunct_l (int c, locale_t locale)

int 

Checks whether a parameter is a punctuation or special character for the specified locale.

isspace_l (int c, locale_t locale)

int 

Checks whether a parameter is a blank character for the specified locale.

isupper_l (int c, locale_t locale)

int 

Checks whether a parameter is a character of uppercase letters for the specified locale.

isxdigit_l (int c, locale_t locale)

int 

Checks whether a parameter is a hexadecimal digit for the specified locale.

tolower_l (int c, locale_t locale)

int 

Converts an upper letter specified by c to its lowercase equivalent for the specified locale.

toupper_l (int c, locale_t locale)

int 

Converts a lowercase letter specified by c to its uppercase equivalent for the specified locale.

toascii (int c)

int 

Converts a parameter of the integer type to an ASCII code.

fmtmsg (long classification, const char label, int severity, const char text, const char action, const char tag)

int 

Prints formatted messages.

fnmatch (const char pattern, const char string, int flags)

int 

Matches a file name or a path name.

getopt_long (int argc, char const argv, const char optstring, const struct optionlongopts, int longindex)

int 

Parses the command-line arguments.

getopt_long_only (int argc, char const argv, const char optstring, const struct optionlongopts, int longindex)

int 

Parses the command-line arguments.

imaxabs (intmax_t j)

intmax_t 

Calculates the absolute value of an input parameter of the integer type.

imaxdiv (intmax_t numerator, intmax_t denominator)

imaxdiv_t 

Calculates the quotient and remainder after the division operation is performed on an integer.

strtoimax (const char str, char endptr, int base)

intmax_t 

Parses a string to a value of the intmax_t type.

strtoumax (const char *str, char endptr, int base)

uintmax_t 

Parses a string to a value of the uintmax_t type.

wcstoimax (const wchar_t str, wchar_t **endptr, int base)

intmax_t 

Parses a string to a value of the intmax_t type.

wcstoumax (const wchar_t str, wchar_t endptr, int base)

uintmax_t 

Parses a string to a value of the uintmax_t type.

strfmon (char s, size_t max, const char format,…)

ssize_t 

Converts a monetary value to a string.

hcreate (size_t nel)

int 

Creates a hash table based on the number of entries.

hdestroy (void)

void 

Destroys a hash table.

hsearch (ENTRY item, ACTION action)

ENTRY 

Adds or searches for a hash entry.

hcreate_r (size_t nel, struct hsearch_data htab)

int 

Creates a hash table based on the number of entries and its description.

hdestroy_r (struct hsearch_data *htab)

void 

Destroys a hash table.

hsearch_r (ENTRY item, ACTION action, ENTRY retval, struct hsearch_datahtab)

int 

Searches for a hash table.

insque (void element, void pred)

void 

Adds an entry to a queue.

remque (void elem)

void 

Removes an entry from a queue.

lsearch (const void key, const void base, size_t nelp, size_t width, int(compar)(const void , const void ))

void  

Performs a linear search for a key in the array and adds a key to the end of the array if the key is not found.

lfind (const void key, const void base, size_t nelp, size_t width, int(compar)(const void , const void ))

void  

Performs a linear search for a key in the array.

tdelete (const void key, void **rootp, int(compar)(const void , const void ))

void  

Deletes a key from the binary tree.

tfind (const void key, void const rootp, int(compar)(const void , const void ))

void  

Searches for a key in the binary tree.

tsearch (const void key, void const rootp, int(compar)(const void , const void ))

void  

Searches for a key in the binary tree and adds a key to the tree if the key is not found.

twalk (const void root, void(action)(const void nodep, VISIT which, int depth))

void 

Traverses a binary tree from left to right.

tdestroy (void root, void(free_node)(void nodep))

void 

Releases all nodes in the binary tree.

atoi (const char nptr)

int 

Converts an input string to an integer.

atol (const char nptr)

long 

Converts an input string to a long integer.

atoll (const char nptr)

long long 

Converts a string to an 8-byte long integer.

atof (const char nptr)

double 

Converts an input string to a double-precision floating-point number.

strtof (const char nptr, char endptr)

float 

Converts an input string to a floating-point number.

strtod (const char *nptr, char endptr)

double 

Converts a string to double.

strtold (const char nptr, char **endptr)

long double 

Converts a string to long double.

strtol (const char nptr, char endptr, int base)

long 

Converts a string to a long integer according to the given base.

strtoul (const char *nptr, char endptr, int base)

unsigned long 

Converts a string to an unsigned long integer according to the given base.

strtoll (const char nptr, char **endptr, int base)

long long 

Converts a string to a long long integer according to the given base.

strtoull (const char nptr, char endptr, int base)

unsigned long long 

Converts a string to an unsigned long long integer according to the given base.

rand (void)

int 

Generates a pseudo-random number.

srand (unsigned int seed)

void 

Initializes a random number generator.

malloc (size_t size)

void  

Dynamically allocates a memory block of size.

calloc (size_t nmemb, size_t size)

void  

Dynamically allocates nmemb memory blocks of size.

realloc (void ptr, size_t size)

void  

Changes the size of the memory block pointed to by ptr to size bytes.

free (void ptr)

void 

Releases the memory space pointed to by ptr.

abort (void)

_Noreturn void 

Terminates an abnormal process and sends the SIGABRT signal to the caller.

atexit (void(func)(void))

int 

Registers a termination function.

exit (int status)

void 

Terminates the calling process, clears the used memory space and various data structures in the kernel, and sends the process end status to the parent process. All functions registered with atexit and on_exit are called in the reverse order.

getenv (const char name)

char  

Obtains the value of an environment variable.

_Exit (int status)

void 

Terminates the calling process, clears the used memory space and various data structures in the kernel, and sends the process end status to the parent process.

assert (scalar expression)

void 

Aborts the program if assertion is false.

secure_getenv (const char name)

char  

Obtains the value of an environment variable.

bsearch (const void key, const void base, size_t nel, size_t width, int(compar)(const void , const void ))

void  

Searches for key using the binary search algorithm from the array element base[0] to base[num-1].

qsort (const void base, size_t nel, size_t width, int(compar)(const void , const void ))

void 

Sorts array elements base[0] to base[num-1] based on the comparison rules of compar.

abs (int i)

int 

Obtains the absolute value of an integer value.

labs (long i)

long 

Calculates the absolute value of a long integer.

llabs (long long i)

long long 

Calculates the absolute value of a long long integer.

div (int numerator, int denominator)

div_t 

Calculates the quotient and remainder of an integer after division.

ldiv (long numerator, long denominator)

ldiv_t 

Calculates the quotient and remainder of a long integer after division.

lldiv (long long numerator, long long denominator)

lldiv_t 

Calculates the quotient and remainder of a long long integer after division.

mblen (const char s, size_t n)

int 

Obtains the number of bytes in the next multi-byte string.

mbtowc (wchar_t pwc, const char s, size_t n)

int 

Converts a string constant to a wide character.

wctomb (char s, wchar_t wc)

int 

Converts a wide character to its multi-byte sequence and stores it in a character array.

mbstowcs (wchar_t dest, const char src, size_t n)

size_t 

Converts a multi-byte string to a wide-character string.

wcstombs (char dest, const wchar_t src, size_t n)

size_t 

Converts a wide-character string to a multi-byte string.

posix_memalign (void memptr, size_t alignment, size_t size)

int 

Allocates memory with the specified size based on the given alignment.

setenv (const char name, const char value, int overwrite)

int 

Add or change an environment variable.

unsetenv (const char name)

int 

Deletes an environment variable.

mkstemp (char template)

int 

Creates and opens a unique temporary file.

mkostemp (char template, int flags)

int 

Creates and opens a unique temporary file.

mkdtemp (char template)

char  

Creates a unique temporary directory based on template.

getsubopt (char **optionp, char const tokens, char **valuep)

int 

Processes the parameters of an option in the command line.

rand_r (unsigned seedp)

int 

Generates a pseudo-random number.

realpath (const char __restrict path, char restrict resolved)

char  

Obtains a normalized absolute path.

random (void)

long int 

Generates a pseudo-random number.

srandom (unsigned int seed)

void 

Initializes a random number generator.

initstate (unsigned int seed, char state, size_t n)

char  

Initializes a random number generator.

setstate (char state)

char  

Sets the current state list for subsequent random use.

putenv (char s)

int 

Configures an environment variable.

unlockpt (int fd)

int 

Unlocks the secondary pseudo terminal corresponding to a primary pseudo terminal.

ptsname (int fd)

char  

Obtains the name of a pseudo terminal.

l64a (long value)

char  

Converts a long integer to a 64-bit ASCII string.

a64l (const char str64)

long 

Converts between a 32-bit long integer and a little-endian 64-bit ASCII string.

drand48 (void)

double 

Obtains a random number.

erand48 (unsigned short xsubi[3])

double 

Obtains a random number.

lrand48 (void)

long int 

Generates pseudo-random numbers evenly distributed between [0, 2^31).

nrand48 (unsigned short xsubi[3])

long int 

Generates pseudo-random numbers evenly distributed between [0, 2^31).

mrand48 (void)

long 

Generates pseudo-random numbers evenly distributed between [-2^31, 2^31).

jrand48 (unsigned short xsubi[3])

long 

Generates pseudo-random numbers evenly distributed between [-2^31, 2^31).

srand48 (long int seedval)

void 

Sets the start seed value for the pseudo-random number generator.

seed48 (unsigned short[3])

unsigned short  

Generates an evenly distributed pseudo-random seed.

lcong48 (unsigned short param[7])

void 

Sets the seed and related algorithm parameters for the pseudo-random number generator.

mktemp (char template)

char  

Creates a unique temporary file name.

mkstemps (char template, int suffixlen)

int 

Creates and opens a unique temporary file.

mkostemps (char template, int suffixlen, int flags)

int 

Creates and opens a unique temporary file.

valloc (size_t size)

void  

Allocates memory with the specified size and aligns the allocated memory by page size.

ecvt (double number, int ndigits, int decpt, int sign)

char  

Converts a double-precision floating-point number into a string.

fcvt (double number, int ndigits, int decpt, int sign)

char  

Converts a floating-point number to a string.

gcvt (double x, int n, char b)

char  

Converts a floating-point number to a string.

memcpy (void restrict dest, const void __restrict src, size_t n)

void  

Copies a string (overlapping not allowed).

memmove (void dest, const void src, size_t n)

void  

Copies a string (overlapping allowed).

memset (void s, int c, size_t n)

void  

Copies a character to the specified memory area.

memcmp (const void s1, const void s2, size_t n)

int 

Compares two memory areas.

memchr (const void s, int c, size_t n)

void  

Searches for a character in the specified memory area.

strcpy (char dest, const char src)

char  

Copies a string.

strncpy (char dest, const char src, size_t n)

char  

Copies n characters of a string.

strcat (char dest, const char src)

char  

Appends a string to another one.

strncat (char dest, const char src, size_t n)

char  

Appends the first n bytes of a string to another one.

strcmp (const char s1, const char s2)

int 

Compares two strings by characters.

strncmp (const char s1, const char s2, size_t n)

int 

Compares the first n characters of two strings.

strcoll (const char s1, const char s2)

int 

Compares two strings by character for the program’s current locale.

strcoll_l (const char s1, const char s2, locale_t locale)

int 

Compares two strings by character for the specified locale.

strxfrm (char dest, const char src, size_t n)

size_t 

Converts the first n characters of the source string pointed to by src based on the program’s current locale specified by LC_COLLATE, and places them in the destination string pointed to by dest.

strchr (const char s, int c)

char  

Locates the first occurrence of a character in a string.

strrchr (const char s, int c)

char  

Locates the last occurrence of a character in a string.

strcspn (const char s, const char reject)

size_t 

Obtains the length of the initial segment of a string that contains characters not in reject.

strspn (const char s, const char accept)

size_t 

Obtains the length of the initial segment of a string that contains characters in accept.

strpbrk (const char s, const char accept)

char  

Searches for any of a set of characters in a string.

strstr (const char haystack, const char needle)

char  

Searches for a needle string in its haystack string.

strtok (char str, const char delim)

char  

Separates a string into a series of tokens separated by a delimiter.

strlen (const char s)

size_t 

Calculates the length of a string.

strerror (int errnum)

char  

Obtains an error description string of the specified error code.

strtok_r (char str, const char delim, char saveptr)

char  

Separates a string into a series of tokens separated by a delimiter, with the saveptr parameter specified.

strerror_l (int errnum, locale_t locale)

char  

Obtains an error description string of the specified error code for the specified locale.

strerror_r (int errnum, char buf, size_t buflen)

char  

Obtains an error description string of the specified error code.

stpcpy (char dest, const char src)

char  

Copies a string.

stpncpy (char dest, const char src, size_t n)

char  

Copies n characters of a string.

strnlen (const char s, size_t maxlen)

size_t 

Calculates the length of a string.

strdup (const char s)

char  

Copies a string to a new position.

strndup (const char s, size_t n)

char  

Copies n characters of a string to a new position.

strsignal (int sig)

char  

Returns a string describing the signal number.

memccpy (void __restrict dest, const void __restrict src, int c, size_t n)

void * 

Copies a memory area to another one.

strsep (char stringp, const char delim)

char  

Separates a string into a series of tokens separated by a delimiter.

strlcat (char d, const char s, size_t n)

size_t 

Appends the first n bytes of a string to another one.

strlcpy (char d, const char s, size_t n)

size_t 

Copies a string.

strverscmp (const char s1, const char s2)

int 

Compares strings of two versions (string 1 and string 2) and returns the comparison result.

strcasestr (const char haystack, const char needle)

char  

Searches for a needle string in its haystack string and returns a pointer.

memmem (const void haystack, size_t haystacklen, const void needle, size_t needlelen)

void  

Searches for a needle string in its haystack string.

memrchr (const void s, int c, size_t n)

void  

Searches for a character in the specified memory area.

mempcpy (void dest, const void src, size_t n)

void  

Copies a string (overlapping not allowed).

bcmp (const void s1, const void s2, size_t n)

int 

Compares byte sequences.

bcopy (const void src, void dest, size_t n)

void 

Copies byte sequences.

bzero (void s, size_t n)

void 

Sets byte sequences to zero.

index (const char s, int c)

char  

Searches for the first position of the matched character in a string.

rindex (const char s, int c)

char  

Searches for the last position of the matched character in a string.

ffs (int i)

int 

Searches for the first bit in a word of the integer type.

ffsl (long int i)

int 

Searches for the first bit in a word of the long integer type.

ffsll (long long int i)

int 

Searches for the first bit in a word of the 8-byte long integer type.

strcasecmp (const char _l, const char _r)

int 

Compares two strings (string 1 and string 2), regardless of the letter case.

strncasecmp (const char _l, const char _r, size_t n)

int 

Compares a specified length of two strings (string 1 and string 2), regardless of the letter case.

pipe (int pipefd[2])

int 

Creates an anonymous pipe.

close (int fd)

int 

Closes a file with a specified file descriptor.

dup (int oldfd)

int 

Copies a specified file descriptor.

dup2 (int oldfd, int newfd)

int 

Copies the descriptor of the target file to a specified descriptor.

lseek (int fd, off_t offset, int whence)

off_t 

Sets the offset of the pointer to the file.

fsync (int fd)

int 

Synchronizes a file associated with a specified file descriptor to the storage device.

read (int fd, void buf, size_t size)

ssize_t 

Reads the file contents and saves them in a specified buffer location.

write (int fd, const void buf, size_t size)

ssize_t 

Writes the specified content to the file.

pread (int fd, void buf, size_t count, off_t offset)

ssize_t 

Reads data whose offset is offset and length is count from fd to the buffer.

pwrite (int fd, const void buf, size_t count, off_t offset)

ssize_t 

Writes data from the buffer to fd whose offset is offset and length is count.

unlink (const char path)

int 

Deletes a specified file.

unlinkat (int fd, const char path, int flag)

int 

Deletes a specified file.

rmdir (const char path)

int 

Deletes a directory.

truncate (const char path, off_t length)

int 

Truncates a file to a specified size based on the file path.

ftruncate (int fd, off_t length)

int 

Truncates a file to a specified length.

access (const char path, int mode)

int 

Checks whether a file has the corresponding permission.

chdir (const char path)

int 

Switches the current working directory to a specified directory.

getcwd (char buf, size_t size)

char  

Obtains the current working directory.

alarm (unsigned int seconds)

unsigned int 

Arranges a signal to be sent to the current process after the number of seconds specified by seconds.

sleep (unsigned seconds)

unsigned 

Sleeps for a period of time.

pause (void)

int 

Waits for signal.

fork (void)

pid_t 

Creates a new process that inherits from the user-mode data of its parent process.

execve (const char path, char const arg[], char const envp[])

int 

Executes a specified user program file in ELF format.

execv (const char path, char const arg[])

int 

Executes a specified user program file in ELF format.

execle (const char path, const char arg,…)

int 

Executes a specified user program file in ELF format.

execl (const char path, const char arg,…)

int 

Executes a specified user program file in ELF format.

execvp (const char path, char const arg[])

int 

Executes a specified user program file in ELF format.

execlp (const char path, const char arg,…)

int 

Executes a specified user program file in ELF format.

_exit (int status)

_Noreturn void 

Exits the process immediately and closes all opened file descriptors in the process.

swab (const void from, void to, ssize_t n)

void 

Swaps bytes.

getpid (void)

pid_t 

Obtains the process ID.

getppid (void)

pid_t 

Obtains the parent process ID.

getpgrp (void)

pid_t 

Obtains the ID of the process group of the calling process.

getpgid (pid_t pid)

pid_t 

Obtains the ID of the process group whose process ID is specified by pid.

setpgid (pid_t pid, pid_t pgid)

int 

Sets the ID of the process group whose process ID is specified by pid.

getopt (int argc, char const argv[], const char optstring)

int 

Parses command-line arguments based on the specified option.

getuid (void)

uid_t 

Obtains the real user ID (UID) of the calling process.

geteuid (void)

uid_t 

Obtains the effective user ID (UID) of the calling process.

getgid (void)

gid_t 

Obtains the real group ID (GID) of the calling process.

getegid (void)

gid_t 

Obtains the effective group ID (GID) of the calling process.

getgroups (int size, gid_t list[])

int 

Obtains a list of supplementary user group IDs specific to the calling process.

setuid (uid_t uid)

int 

Sets the real user ID for the calling process.

seteuid (uid_t euid)

int 

Sets the effective user ID of the calling process.

setgid (gid_t gid)

int 

Sets the user group ID of the calling process.

setegid (gid_t egid)

int 

Sets the effective user group ID of the calling process.

pathconf (const char path, int name)

long 

Obtains the configuration value of a file.

setreuid (uid_t ruid, uid_t euid)

int 

Sets the real and effective user IDs of the calling process.

setregid (gid_t rgid, gid_t egid)

int 

Sets the real and effective user group IDs of the calling process.

setpgrp (void)

pid_t 

Sets the process group ID of the calling process.

usleep (unsigned useconds)

int 

Sleeps for several microseconds.

ualarm (unsigned value, unsigned interval)

unsigned 

Sets a microsecond-level timer.

setgroups (size_t size, const gid_t list)

int 

Sets the supplementary user group list of the calling process.

setresuid (uid_t ruid, uid_t euid, uid_t suid)

int 

Sets the real, effective, and saved user IDs of the calling process.

setresgid (gid_t rgid, gid_t egid, gid_t sgid)

int 

Sets the real, effective, and saved group IDs of the calling process.

getresuid (uid_t ruid, uid_t euid, uid_t suid)

int 

Obtains the real, effective, and saved user IDs of the calling process.

getresgid (gid_t rgid, gid_t egid, gid_t sgid)

int 

Obtains the real, effective, and saved user group IDs of the calling process.

get_current_dir_name (void)

char  

Obtains the name of the current working directory.

sbrk (intptr_t increment)

void  

Adjusts the heap size of a process.

getpagesize (void)

int 

Obtains the memory page size.

chown (const char pathname, uid_t owner, gid_t group)

int 

Changes the user and group ownership of a file.

wcscpy (wchar_t dest, const wchar_t src)

wchar_t  

Copies the wide characters pointed to by src to the wide character array pointed to by dest, including the terminating null character ‘\0’. .

wcsncpy (wchar_t dest, const wchar_t src, size_t n)

wchar_t  

Copies the first n wide characters pointed to by src to the wide character array pointed to by dest.

wcscat (wchar_t dest, const wchar_t src)

wchar_t  

Appends a copy of the wide characters pointed to by src to the end of the wide character array pointed to by dest and adds a terminating null character ‘\0’.

wcsncat (wchar_t dest, const wchar_t src, size_t n)

wchar_t  

Appends a copy of the first n wide characters pointed to by src to the end of the wide characters pointed to by dest and adds a terminating null character ‘\0’.

wcscmp (const wchar_t s1, const wchar_t s2)

int 

Compares each character in the string pointed to by s1 with that in the string pointed to by s2 in ASCII-code order.

wcsncmp (const wchar_t s1, const wchar_t s2, size_t n)

int 

Compares the first n characters in the string pointed to by s1 with those in the string pointed to by s2 in ASCII-code order.

wcscoll (const wchar_t ws1, const wchar_t ws2)

int 

Compares the wide characters in the string pointed to by ws1 with those in the string pointed to by ws2 based on the specified locale LC_COLLATE.

wcsxfrm (wchar_t s1, const wchar_t s2, size_t n)

size_t 

Compares the first n wide characters in the string pointed to by s1 with those in the string pointed to by s2.

wcschr (const wchar_t wcs, wchar_t wc)

wchar_t  

Locates the first occurrence of the wide character pointed to by wc in the wide character string pointed to by wcs.

wcsrchr (const wchar_t wcs, wchar_t wc)

wchar_t  

Locates the last occurrence of the wide character pointed to by wc in the wide character string pointed to by wcs.

wcscspn (const wchar_t wcs, const wchar_t accept)

size_t 

Scans the wide character string pointed to by wcs for any wide characters specified in reject and obtains the number of unmatched characters in wcs.

wcsspn (const wchar_t wcs, const wchar_t accept)

size_t 

Scans the wide character string pointed to by wcs for any wide characters specified in reject and obtains the number matched characters in wcs.

wcspbrk (const wchar_t wcs, const wchar_t accept)

wchar_t  

Scans the wide character string pointed to by wcs for any wide characters specified in accept and obtains the first occurrence of the matched character.

wcstok (wchar_t wcs, const wchar_t delim, wchar_t **ptr)

wchar_t  

Splits a wide character string pointed to by wcs into tokens using the given delimiter.

wcslen (const wchar_t s)

size_t 

Calculates the length of a wide character string pointed to by s.

wcswcs (const wchar_t haystack, const wchar_t needle)

wchar_t  

Searches the wide character string pointed to by dest for the first occurrence of the wide character string pointed to by src.

wmemchr (const wchar_t s, wchar_t c, size_t n)

wchar_t  

Searches for the first position of the matched wide character within the specified number of characters in a wide character string.

wmemcmp (const wchar_t lhs, const wchar_t rhs, size_t count)

int 

Compares the first count characters in the string pointed to by lhs with the first count characters in the string pointed to by rhs.

wmemcpy (wchar_t dest, const wchar_t src, size_t count)

wchar_t  

Copies count successive characters from the wide character array pointed to by src to the wide character array pointed to by dest.

wmemmove (wchar_t dest, const wchar_t src, size_t count)

wchar_t  

Copies count successive characters from the wide character array pointed to by src to the wide character array pointed to by dest (with possible array overlapping).

wmemset (wchar_t dest, wchar_t ch, size_t count)

wchar_t  

Fills count characters specified by ch to the wide character array pointed to by dest.

btowc (int c)

wint_t 

Converts a single-byte character c into its wide-character representation.

wctob (wint_t c)

int 

Converts a wide character c into its single-byte representation.

mbsinit (const mbstate_t ps)

int 

Checks whether the mbstate_t object pointed to by ps is in the initial state.

wcrtomb (char s, wchar_t wc, mbstate_t ps)

size_t 

Converts the wide character specified by wc into a character string and stores the string to the beginning of the character array pointed to by s.

mbrlen (const char s, size_t n, mbstate_t ps)

size_t 

Determines the number of bytes in a character string pointed to by s.

mbsrtowcs (wchar_t dest, const char src, size_t len, mbstate_t ps)

size_t 

Converts a multi-byte character string with a length of len into a wide character string.

wcsrtombs (char dest, const wchar_t src, size_t len, mbstate_t ps)

size_t 

Converts a wide character string into a multi-byte string.

wcstof (const wchar_t str, wchar_t endptr)

float 

Converts a wide character string pointed to by str into a floating-point value and assigns the next character in str after the floating-point value to endptr.

wcstod (const wchar_t *str, wchar_t endptr)

double 

Converts a wide character string pointed to by str into a double value and assigns the next character in str after the double value to endptr.

wcstold (const wchar_t str, wchar_t **endptr)

long double 

Converts a wide character string pointed to by str into a long double value and assigns the next character in str after the long double value to endptr.

wcstol (const wchar_t str, wchar_t endptr, int base)

long 

Converts a wide character string pointed to by str into a long value.

wcstoul (const wchar_t *str, wchar_t endptr, int base)

unsigned long 

Converts a wide character string pointed to by str into an unsigned long value of a specified base.

wcstoll (const wchar_t str, wchar_t **endptr, int base)

long long 

Converts a wide character string pointed to by str into a long long value of a specified base.

wcstoull (const wchar_t str, wchar_t endptr, int base)

unsigned long long 

Converts a wide character string pointed to by str into an unsigned long long value of a specified base.

fwide (FILEstream, int mode)

int 

Sets and determines the orientation of the file stream.

wprintf (const wchar_t format,…)

int 

Prints formatted data to the standard output (stdout).

fwprintf (FILE__restrict fp, const wchar_t restrict fmt,…)

int 

Prints wide character strings to a specified file stream.

swprintf (wchar_t wcs, size_t maxlen, const wchar_t format,…)

int 

Prints formatted data to a specified string.

vwprintf (const wchar_t format, va_list args)

int 

Prints formatted data from a variable argument list to the standard output (stdout).

vfwprintf (FILE stream, const wchar_t *format, isoc_va_list args)

int 

Prints formatted data from a variable argument list specified by args to a specified file stream.

vswprintf (wchar_t wcs, size_t maxlen, const wchar_t format, __isoc_va_list args)

int 

Prints formatted data from a variable argument list specified by args to a specified string.

wscanf (const wchar_t format,…)

int 

Reads formatted data from the standard input (stdin) and stores it based on the wide string format into the locations pointed to by the variable arguments.

fwscanf (FILE stream, const wchar_t format,…)

int 

Reads formatted data from a specified stream and stores it based on the wide string format into the locations pointed to by the variable arguments.

swscanf (const wchar_t ws, const wchar_t format,…)

int 

Reads data from a wide character string pointed to by ws and stores it based on the wide string format into the locations pointed to by the variable arguments.

vwscanf (const wchar_t format, va_list arg)

int 

Reads data from the stdin and stores it based on the wide string format into the locations pointed to by the elements in the variable argument list identified by arg.

vfwscanf (FILEstream, const wchar_t format, va_list arg)

int 

Reads data from a specified file stream and stores it based on the wide string format into the locations pointed to by the elements in the variable argument list identified by arg.

vswscanf (const wchar_t ws, const wchar_t format, va_list arg)

int 

Reads data from a string pointed to by ws and stores it based on the wide string format into the locations pointed to by the elements in the variable argument list identified by arg.

fgetwc (FILEstream)

wint_t 

Reads a wide character from a specified file stream.

getwc (FILE stream)

wint_t 

Reads the first wide character from a specified file stream.

getwchar (void)

wint_t 

Reads a wide character from the stdin.

fputwc (wchar_t wc, FILEstream)

wint_t 

Writes a wide character wc to a specified file stream.

putwc (wchar_t wc, FILE stream)

wint_t 

Writes a wide character wc to a specified file stream.

putwchar (wchar_t wc)

wint_t 

Writes a wide character wc to the stdout.

fgetws (wchar_t ws, int n, FILEstream)

wchar_t  

Reads wide characters from a specified file stream.

fputws (const wchar_t ws, FILEstream)

int 

Writes a wide string pointed to by ws to a specified file stream.

ungetwc (wint_t ch, FILE stream)

wint_t 

Pushes a character back into a specified file stream.

mbrtowc (wchar_t pwc, const char s, size_t n, mbstate_t ps)

size_t 

Converts a multi-byte character string with a length of n into a wide character string.

mbsnrtowcs (wchar_t dest, const char src, size_t nwc, size_t len, mbstate_t ps)

size_t 

Converts a multi-byte character string with a length of n into a wide character string that can hold a total of nwc wide characters.

wcsnrtombs (char dest, const wchar_t *src, size_t nwc, size_t len, mbstate_t ps)

size_t 

Converts nwc wide characters in the string pointed to by src into a character string.

wcsdup (const wchar_t s)

wchar_t  

Copies a specified wide character string to a newly allocated buffer.

wcsnlen (const wchar_t s, size_t maxlen)

size_t 

Calculates the length of a wide character string pointed to by s.

wcpcpy (wchar_t dest, const wchar_t src)

wchar_t  

Copies the wide characters (including the terminating null character ‘\0’) pointed to by src to the wide character array pointed to by dest.

wcpncpy (wchar_t dest, const wchar_t src, size_t n)

wchar_t  

Copies n wide characters (including the terminating null character ‘\0’) pointed to by src to the wide character array pointed to by dest.

wcscasecmp (const wchar_t s1, const wchar_t s2)

int 

Compares the wide characters in the string pointed to by s1 with those in the string pointed to by s2, with their case differences ignored.

wcscasecmp_l (const wchar_t s1, const wchar_t s2, locale_t locale)

int 

Compares the wide characters in the string pointed to by s1 with those in the string pointed to by s2 based on the specified locale environment, with their case differences ignored.

wcsncasecmp (const wchar_t s1, const wchar_t s2, size_t n)

int 

Compares a maximum of n wide characters in the string pointed to by s1 with those in the string pointed to by s2, with their case differences ignored.

wcsncasecmp_l (const wchar_t s1, const wchar_t s2, size_t n, locale_t locale)

int 

Compares a maximum of n wide characters in the string pointed to by s1 with those in the string pointed to by s2 based on the specified locale environment, with their case differences ignored.

wcscoll_l (const wchar_t s1, const wchar_t s2, locale_t locale)

int 

Compares wide characters in the string pointed to by s1 with those in the string pointed to by s2 based on the specified locale environment.

wcsftime (wchar_t restrict wcs, size_t n, const wchar_t *restrict f, const struct tm__restrict tm)

size_t 

Converts the date and time in the tm structure to a wide character string.

wcsxfrm_l (wchar_t s1, const wchar_t s2, size_t n, locale_t locale)

size_t 

Compares the first n wide characters in the string pointed to by s1 with those in the string pointed to by s2 based on the specified locale environment.

iswalnum (wint_t wc)

int 

Checks whether a wide character is a letter or digit.

iswalpha (wint_t wc)

int 

Checks whether a wide character is a letter.

iswblank (wint_t wc)

int 

Checks whether a wide character is a space or tab character (\t).

iswcntrl (wint_t wc)

int 

Checks whether a wide character is a control character.

iswdigit (wint_t wc)

int 

Checks whether a wide character is a decimal digit.

iswgraph (wint_t wc)

int 

Checks whether a wide character is visible.

iswlower (wint_t wc)

int 

Checks whether a wide character is a lowercase letter.

iswprint (wint_t wc)

int 

Checks whether a wide character is printable.

iswpunct (wint_t wc)

int 

Checks whether a wide character is a punctuation mark.

iswupper (wint_t wc)

int 

Checks whether a wide character is an uppercase letter.

iswxdigit (wint_t wc)

int 

Checks whether a wide character is a hexadecimal digit.

iswctype (wint_t wc, wctype_t desc)

int 

Checks whether the character specified by wc belongs to the desc class.

towctrans (wint_t wc, wctrans_t desc)

wint_t 

Translates the type of a wide character based on the conversion mapping relationship.

towlower (wint_t wc)

wint_t 

Converts an uppercase wide character to lowercase.

towupper (wint_t wc)

wint_t 

Converts a lowercase wide character to uppercase.

wctrans (const char name)

wctrans_t 

Determines a mapping which can map a wide character to another wide character.

wctype (const char name)

wctype_t 

Checks whether a wide character type exists in the LC_CTYPE locale.

iswalnum_l (wint_t wc, locale_t locale)

int 

Checks whether a wide character is a letter or digit for the specified locale.

iswalpha_l (wint_t wc, locale_t locale)

int 

Checks whether a wide character is alphabetic for the specified locale.

iswblank_l (wint_t wc, locale_t locale)

int 

Checks whether a wide character is a blank or \t character for the specified locale.

iswcntrl_l (wint_t wc, locale_t locale)

int 

Checks whether a wide character is a control character for the specified locale.

iswdigit_l (wint_t wc, locale_t locale)

int 

Checks whether a wide character is a decimal digit for the specified locale.

iswgraph_l (wint_t wc, locale_t locale)

int 

Checks whether a wide character is visible for the specified locale.

iswlower_l (wint_t wc, locale_t locale)

int 

Checks whether a wide character is in lowercase for the specified locale.

iswprint_l (wint_t wc, locale_t locale)

int 

Checks whether a wide character is printable for the specified locale.

iswpunct_l (wint_t wc, locale_t locale)

int 

Checks whether wc is a punctuation wide character for the specified locale.

iswspace (wint_t wc)

int 

Checks whether a wide character belongs to the wide-character class space.

iswspace_l (wint_t wc, locale_t locale)

int 

Checks whether a wide character belongs to the wide-character class space for the specified locale.

iswupper_l (wint_t wc, locale_t locale)

int 

Checks whether a wide character is in uppercase for the specified locale.

iswxdigit_l (wint_t wc, locale_t locale)

int 

Checks whether a wide character is a hexadecimal digit for the specified locale.

iswctype_l (wint_t wc, wctype_t desc, locale_t locale)

int 

Checks whether the character specified by wc belongs to the desc class for the specified locale.

towlower_l (wint_t wc, locale_t locale)

wint_t 

Converts an uppercase wide character to lowercase for the specified locale.

towupper_l (wint_t wc, locale_t locale)

wint_t 

Converts a lowercase wide character to uppercase for the specified locale.

towctrans_l (wint_t wc, wctype_t desc, locale_t locale)

wint_t 

Translates the type of a wide character based on the translation mapping relationship for the specified locale.

wctrans_l (const char name, locale_t locale)

wctrans_t 

Determines a mapping which can map a wide character to another wide character.

wctype_l (const char *name, locale_t locale)

wctype_t 

Checks whether a wide character type exists for the specified locale.

Details

Macro Definition Documentation

_tolower

  1. #define _tolower( a)((a)|0x20)

Description:

Converts an uppercase letter to its lowercase equivalent.

Parameters:

Name

Description

aIndicates the parameter to convert.

Returns:

Returns the converted lowercase letter if the conversion is successful.

_toupper

  1. #define _toupper( a)((a)&0x5f)

Description:

Converts a lowercase letter to its uppercase equivalent.

Parameters:

Name

Description

aIndicates the parameter to convert.

Returns:

Returns the converted uppercase letter if the conversion is successful.

isascii

  1. #define isascii( a)(0? isascii(a):(unsigned)(a)<128)

Description:

Checks whether a parameter is an ASCII character.

Parameters:

Name

Description

aIndicates the parameter to check.

Returns:

Returns a non-zero value if the operation is successful; returns 0 otherwise.

strdupa

  1. #define strdupa( x)[strcpy]($api-api-SmartVision-Devices-UTILS.md#ga7a82515b5d377be04817715c5465b647)(alloca([strlen]($api-api-SmartVision-Devices-UTILS.md#gaa383452fe445bfae989358c9d7d96f4f)(x)+1),x)

Description:

Copies a string to a new position.

Attention:

strdupa() internally calls alloca() to allocate space for variables. You should pay attention to the stack space size.

Returns:

Returns the pointer to the space allocated for the copied string if the operation is successful; returns NULL if the space fails to be allocated.

va_arg

  1. #define va_arg( v, l ) __builtin_va_arg(v,l)

Description:

Obtains the next argument in the variable-length argument list.

Parameters:

Name

Description

vIndicates the va_list v initialized by va_start(). Each call to va_arg() modifies v so that the next call returns the next argument.
lIndicates the name of the last argument before the variable argument list, that is, the last argument of which the calling function knows the type.

Attention:

va_start must be called first.

va_copy

  1. #define va_copy( d, s ) __builtin_va_copy(d,s)

Description:

Copies the previously initialized variable argument list s to d.

Parameters:

Name

Description

dIndicates the destination variable.
sIndicates the source variable.

va_end

  1. #define va_end( v) __builtin_va_end(v)

Description:

Ends a variable-length argument list.

This function releases a calling function.

Parameters:

Name

Description

vIndicates the va_list v initialized by va_start().

Attention:

After va_end is called, v is a random value.

va_start

  1. #define va_start( v, l ) __builtin_va_start(v,l)

Description:

Defines the start position of the variable-length argument list.

This function initializes v for subsequent use by va_arg and va_end, and must be called first.

Parameters:

Name

Description

vIndicates the argument to be initialized.
lIndicates the name of the last argument before the variable argument list, that is, the last argument of which the calling function knows the type.

Attention:

This function must be used together with va_end.

Function Documentation

_Exit()

  1. void_Exit(int status)

Description:

Terminates the calling process, clears the used memory space and various data structures in the kernel, and sends the process end status to the parent process.

Parameters:

Name

Description

statusIndicates the status sent to the parent process when the calling process ends.

_exit()

  1. _Noreturnvoid _exit (int status)

Description:

Exits the process immediately and closes all opened file descriptors in the process.

The subprocess is taken over by process 1.

Parameters:

Name

Description

statusIndicates the exit status of the process. The status is returned to the parent process of the current process and can be collected by the wait() series functions.

a64l()

  1. long a64l (constchar* str64)

Description:

Converts between a 32-bit long integer and a little-endian 64-bit ASCII string.

Parameters:

Name

Description

str64Indicates the pointer to the character constant.

Attention:

If the length of str64 is greater than 6, only the first six bytes are used.

Returns:

Returns the converted value.

abort()

  1. _Noreturnvoid abort (void)

Description:

Terminates an abnormal process and sends the SIGABRT signal to the caller.

abs()

  1. int abs (int i)

Description:

Obtains the absolute value of an integer value.

Parameters:

Name

Description

iIndicates the integer value.

Returns:

Returns the absolute value.

access()

  1. int access (constchar* path,int mode )

Description:

Checks whether a file has the corresponding permission.

Parameters:

Name

Description

pathIndicates the path of the file to be checked.
modeIndicates the access permission to be checked.

Returns:

Returns 0 if the current file has the permission to be checked; returns -1 and sets errno to a value in the following table if the current file does not have the permission to be checked or other errors occur.

errno

Description

EACCES

The permission bit of the file mode does not allow the requested access, or the search permission is denied on the path prefix component.

EFAULT

Invalid address.

ENOENT

The component of path does not exist or the path is an empty string.

ENOMEM

Insufficient memory.

alarm()

  1. unsignedint alarm (unsignedint seconds)

Description:

Arranges a signal to be sent to the current process after the number of seconds specified by seconds.

Parameters:

Name

Description

secondsIndicates an unsigned integer seconds needs to be transferred.

Attention:

An exception occurs when this function is used together with setitimer(), ualarm(), and sleep(). This function shares a timer with setitimer() and ualarm(). You are not advised to use this function together with sleep().

Returns:

Returns the remaining seconds until the countdown of seconds ends; returns 0 if no alarm clock is set.

assert()

  1. voidassert(scalar expression)

Description:

Aborts the program if assertion is false.

If the NDEBUG macro is not defined and the value of expression is false, an error message is displayed and the process is terminated. In other cases, this macro is expanded but no operation is performed.

Parameters:

Name

Description

expressionIndicates the condition variable. If the value of expression is false, an error message is displayed and the process is terminated.

atexit()

  1. int atexit (void(*)(void) func)

Description:

Registers a termination function.

The registered function is called when the current process is terminated normally. The sequence of the termination function to be called is opposite to the registration sequence.

Parameters:

Name

Description

funcIndicates the pointer to the termination function to be called.

Returns:

Returns 0 if the operation is successful; returns a non-zero value otherwise.

atof()

  1. double atof (constchar* nptr)

Description:

Converts an input string to a double-precision floating-point number.

The conversion stops when a non-numeric character is encountered.

Parameters:

Name

Description

nptrIndicates the string to be converted.

Returns:

Returns the converted value if the operation is successful; returns 0 if the operation fails.

atoi()

  1. int atoi (constchar* nptr)

Description:

Converts an input string to an integer.

The conversion stops when a non-numeric character is encountered.

Parameters:

Name

Description

nptrIndicates the string to be converted.

Returns:

Returns the converted value if the operation is successful; returns 0 if the operation fails.

atol()

  1. long atol (constchar* nptr)

Description:

Converts an input string to a long integer.

Parameters:

Name

Description

nptrIndicates the string to be converted.

Returns:

Returns the converted value if the operation is successful; returns 0 if the operation fails.

atoll()

  1. longlong atoll (constchar* nptr)

Description:

Converts a string to an 8-byte long integer.

The conversion stops when a non-numeric character is encountered.

Parameters:

Name

Description

nptrIndicates the string to be converted.

Returns:

Returns the converted value if the operation is successful; returns 0 if the operation fails.

bcmp()

  1. int bcmp (constvoid* s1,constvoid* s2,size_t n )

Description:

Compares byte sequences.

Specifically, this function checks whether the first n bytes of the two byte sequences pointed to by s1 and s2 are equal. If they are equal or n is 0, this function returns 0. Otherwise, it returns a non-zero value.

Parameters:

Name

Description

s1Indicates the pointer to byte sequence 1 for comparison.
s2Indicates the pointer to byte sequence 2 for comparison.
nIndicates the number of bytes to be compared.

Attention:

This function is deprecated (marked as LEGACY in POSIX.1-2001). Its specifications have been removed since POSIX.1-2008. You can use memcmp() in new projects.

Returns:

Returns 0 if the two byte sequences are equal or n is 0; returns a non-zero value if the operation fails.

bcopy()

  1. void bcopy (constvoid* src,void* dest,size_t n )

Description:

Copies byte sequences.

Specifically, this function copies the first n bytes from the memory area pointed to by src to that pointed to by dest. This function can always be called successfully even if the two specified areas overlap.

Parameters:

Name

Description

srcIndicates the pointer to the source memory area.
destIndicates the pointer to the destination memory area.
nIndicates the number of bytes to be copied.

Attention:

This function is deprecated (marked as LEGACY in POSIX.1-2001). Its specifications have been removed since POSIX.1-2008. You can use memcpy() and memmove() in new projects.

bsearch()

  1. void* bsearch (constvoid* key,constvoid*base,size_t nel,size_t width,int(*)(constvoid*,constvoid*) compar )

Description:

Searches for key using the binary search algorithm from the array element base[0] to base[num-1].

Parameters:

Name

Description

keyIndicates the pointer to the keyword to be searched.
baseIndicates the array to be searched.
nelIndicates the number of elements in the array to be searched.
widthIndicates the length of each element, in bytes.
compareIndicates the pointer to the comparison subfunction used to define comparison rules.

Attention:

Data must have been sorted, following the same rule as the comparison subfunction pointed to by compar.

Returns:

Returns the matching item if the operation is successful; returns NULL if the operation fails.

btowc()

  1. wint_t btowc (int c)

Description:

Converts a single-byte character c into its wide-character representation.

Parameters:

Name

Description

cIndicates the character to be converted.

Attention:

If c is EOF or its length is not 1, WEOF is returned.

Returns:

Returns the wide-character representation if the operation is successful; returns WEOF if c is EOF or its length is not 1.

bzero()

  1. void bzero (void* s,size_t n )

Description:

Sets byte sequences to zero.

Specifically, this function sets the first n bytes in the memory area starting at s to zero.

Parameters:

Name

Description

sIndicates the pointer to the first token in the byte sequence to be set to zero.
nIndicates the number of bytes to be set to zero.

Attention:

This function is deprecated (marked as LEGACY in POSIX.1-2001). Its specifications have been removed since POSIX.1-2008. You can use memset() in new projects.

calloc()

  1. void* calloc (size_t nmemb,size_t size )

Description:

Dynamically allocates nmemb memory blocks of size.

Parameters:

Name

Description

nmembIndicates the number of memory blocks to be allocated.
sizeIndicates the size of the memory block to be allocated.

Returns:

Returns the pointer to the allocated memory block if the operation is successful; returns NULL and sets errno to a value in the following table if the operation fails.

errno

Description

ENOMEM

Insufficient memory.

chdir()

  1. int chdir (constchar* path)

Description:

Switches the current working directory to a specified directory.

Parameters:

Name

Description

pathIndicates the target working directory.

Returns:

Returns 0 if the working directory is switched; returns -1 and sets errno to a value in the following table if the working directory fails to be switched and the current working directory remains unchanged.

errno

Description

EINVAL

path is set to NULL.

ENAMETOOLONG

The length of the path name is greater than PATH_MAX.

ENOMEM

Insufficient memory.

ENOTDIR

path is not a directory name.

ENOENT

The path does not exist.

chown()

  1. int chown (constchar* pathname,uid_t owner,gid_tgroup)

Description:

Changes the user and group ownership of a file.

Parameters:

Name

Description

pathnameIndicates the pointer to the file path.
ownerIndicates the new file owner.
groupIndicates the new file group.

Attention:

This function can be used only in the JFFS2 file system.

Returns:

Returns 0 if the change is successful; returns -1 and sets errno to a value in the following table if the change fails.

errno

Description

EINVAL

pathname is a null pointer or an empty string.

EACCES

The permission bit of the file mode does not allow the requested access, or the search permission is denied on the path prefix directory.

EFAULT

Invalid address.

ENAMETOOLONG

The length of the path name is greater than NAME_MAX.

ENOENT

The directory component in the path name does not exist.

ENOMEM

Insufficient memory.

ENOTDIR

A component of the path prefix is the name of an existing file, which is neither a directory nor a symbolic link of a directory.

EPERM

The operation is not allowed or access is denied because the access is prohibited or the directory is full.

EROFS

The physical drive is write-protected.

EEXIST

The file or directory already exists.

ENOSYS

The operation is not supported.

close()

  1. int close (int fd)

Description:

Closes a file with a specified file descriptor.

Parameters:

Name

Description

fdIndicates the descriptor of the file to be closed.

Returns:

Returns 0 if the file is closed; returns -1 and sets errno to a value in the following table if the file fails to be closed.

errno

Description

EBADF

fd is invalid.

EINVAL

The file is not owned by the current process.

ENOENT

The file does not exist.

ENODEV

The disk partition is not found.

crypt()

  1. char* crypt (constchar* key,constchar* setting )

Description:

Encrypts data.

This function converts the string to be encrypted to one-way hash data that can be stored in the user database.

Parameters:

Name

Description

keyIndicates the data to be encrypted.
settingIndicates the description of the encryption mode. The description consists of the encryption prefix and random characters, which are selected from (., /, 0-9, A-Z, a-z). The details are as follows:

Encryption Algorithm

Encryption Prefix

Number of Random Characters

SHA-2-512

‘$6$’

16

SHA-2-256

‘$5$’

16

MD5

‘$1$’

8

DES

‘’

2

Attention:

The returned string is composed of printable ASCII characters, but does not contain spaces or any of the following characters: {‘:’, ‘;’, ‘*‘, ‘!’, ‘\‘}.

Returns:

Returns the encrypted data if the operation is successful; returns NULL and sets errno to a value in the following table if the operation fails.

Input

Error code

setting is set to NULL.

EINVAL

The hash password or encryption algorithm is not supported.

ENOSYS

The system does not allow the encryption algorithm.

EPERM

div()

  1. [div_t]($api-api-SmartVision-Devices-div_t.md) div (int numerator,int denominator )

Description:

Calculates the quotient and remainder of an integer after division.

Parameters:

Name

Description

numeratorIndicates the numerator.
denominatorIndicates the denominator.

Returns:

Returns a structure variable that has been defined in the function.

drand48()

  1. double drand48 (void)

Description:

Obtains a random number.

This function returns a double-precision random number evenly distributed between (0.0, 1.0).

Attention:

Before calling this function, you need to call one of the initialization functions srand48(), seed48(), and lcong48().

Returns:

Returns the obtained double-precision random number.

dup()

  1. int dup (int oldfd)

Description:

Copies a specified file descriptor.

Parameters:

Name

Description

oldfdIndicates the file descriptor to be copied.

Attention:

This function can be used only in the NFS file system.

Returns:

Returns a non-negative integer (minimum descriptor available to the current process) if the copy is successful; returns -1 and sets errno to a value in the following table if the copy fails.

errno

Description

EBADF

oldfd is invalid.

EMFILE

Failed to allocate file descriptors because too many files are opened.

ENOENT

The index node cannot be found based on the path name associated with oldfd.

ENOSYS

The operation is not supported.

ENOMEM

Insufficient memory.

dup2()

  1. int dup2 (int oldfd,int newfd )

Description:

Copies the descriptor of the target file to a specified descriptor.

Parameters:

Name

Description

oldfdIndicates the file descriptor to be copied.
newfdIndicates the new file descriptor for copying.

Returns:

Returns a non-negative integer (descriptor of the new file) if the copy is successful; returns -1 and sets errno to a value in the following table if the copy fails.

errno

Description

EBADF

oldfd is invalid.

EMFILE

Failed to allocate file descriptors because too many files are opened.

ENOENT

The index node cannot be found based on the path name associated with oldfd.

ENOSYS

The operation is not supported.

ENOMEM

Insufficient memory.

ecvt()

  1. char* ecvt (double number,int ndigits,int* decpt,int* sign )

Description:

Converts a double-precision floating-point number into a string.

The conversion result does not contain decimal places.

Parameters:

Name

Description

numberIndicates the double-precision floating-point number to be converted.
ndigitsIndicates the number of valid digits to be stored.
decptIndicates the decimal point position.
signIndicates the symbol of the number to be converted.

Returns:

Returns the pointer to the generated string.

erand48()

  1. double erand48 (unsignedshort xsubi[3])

Description:

Obtains a random number.

This function returns nonnegative double-precision floating-point values evenly distributed between [0.0, 1.0).

Parameters:

Name

Description

xsubiIndicates the array of the initialized value of Xi.

execl()

  1. int execl (constchar* path,constchar* arg,...)

Description:

Executes a specified user program file in ELF format.

Parameters:

Name

Description

pathIndicates the full path of the ELF file.
argIndicates the list of parameters required by the program, ending with a null pointer.

Returns:

Returns -1 and sets errno to the corresponding error code perror if the operation fails.

execle()

  1. int execle (constchar* path,constchar* arg,...)

Description:

Executes a specified user program file in ELF format.

Parameters:

Name

Description

pathIndicates the full path of the ELF file.
argIndicates the list of parameters required by the program. The arg parameter must point to a new environment variable array, that is, the environment variable of the new program.

Returns:

Returns -1 and sets errno to the corresponding error code perror if the operation fails.

execlp()

  1. int execlp (constchar* path,constchar* arg,...)

Description:

Executes a specified user program file in ELF format.

Parameters:

Name

Description

pathIndicates the name or path name of the program file to be executed.
argIndicates the list of parameters required by the program, ending with a null pointer.

Returns:

Returns -1 and sets errno to the corresponding error code perror if the operation fails. If the specified file name contains a slash (/), the file is executed. If it does not contain a slash (/), the current user program traverses the path list specified by the path environment variable. If the path environment variable is not defined, the current user program traverses (“/usr/local/bin:/bin:/usr/bin”). The path list and file name are combined as an executable file and the file is executed. If the file does not have the execute permission, the system continues to search for other path lists. If no other file is found, EACCES is returned. If no valid executable file exists in the list of all paths, -1 is returned.

execv()

  1. int execv (constchar* path,char*const arg[])

Description:

Executes a specified user program file in ELF format.

Parameters:

Name

Description

pathIndicates the full path of the ELF file.
argIndicates the list of program parameters maintained by the pointer to the array. The last element of the array must be a null pointer.

Attention:

This function is slightly different from execve in input parameters. The arg parameter is a string array for storing new environment variables.

Returns:

Returns -1 and sets errno to the corresponding error code perror if the operation fails.

execve()

  1. int execve (constchar* path,char*const arg[],char*const envp[])

Description:

Executes a specified user program file in ELF format.

Parameters:

Name

Description

pathIndicates the full path of the ELF file.
argIndicates the list of program parameters maintained by the pointer to the array. The last element of the array must be a null pointer.
envpIndicates the pointer to the string for storing new environment variables.

Returns:

Returns -1 and sets errno to the corresponding error code perror if the operation fails.

execvp()

  1. int execvp (constchar* path,char*const arg[])

Description:

Executes a specified user program file in ELF format.

Parameters:

Name

Description

pathIndicates the name or path name of the program file to be executed.
argIndicates the list of parameters required by the program, ending with a null pointer.

Returns:

Returns -1 and sets errno to the corresponding error code perror if the operation fails. If the specified file name contains a slash (/), the file is executed. If it does not contain a slash (/), the current user program traverses the path list specified by the path environment variable. If the path environment variable is not defined, the current user program traverses (“/usr/local/bin:/bin:/usr/bin”). The path list and file name are combined as an executable file and the file is executed. If the file does not have the execute permission, the system continues to search for other path lists. If no other file is found, EACCES is returned. If no valid executable file exists in the list of all paths, -1 is returned.

exit()

  1. voidexit(int status)

Description:

Terminates the calling process, clears the used memory space and various data structures in the kernel, and sends the process end status to the parent process. All functions registered with atexit and on_exit are called in the reverse order.

Parameters:

Name

Description

statusIndicates the status sent to the parent process when the calling process ends.

fcvt()

  1. char* fcvt (double number,int ndigits,int* decpt,int* sign )

Description:

Converts a floating-point number to a string.

Parameters:

Name

Description

numberIndicates the floating-point number to be converted.
ndigitsIndicates the number of decimal places.
decptIndicates the position of the decimal point, which can be obtained by users.
signIndicates the symbol of number, which can be obtained by users. 0 indicates a positive number, and 1 indicates a negative number.

Returns:

Returns the converted string.

ffs()

  1. int ffs (int i)

Description:

Searches for the first bit in a word of the integer type.

Specifically, this function searches for the least significant bit (position 1) set in the word.

Parameters:

Name

Description

iIndicates the long integer to be searched.

Returns:

Returns the position of the first bit if the operation is successful; returns 0 if no bits are set in the word.

ffsl()

  1. int ffsl (longint i)

Description:

Searches for the first bit in a word of the long integer type.

Specifically, this function searches for the least significant bit (position 1) set in the word.

Parameters:

Name

Description

iIndicates the long integer to be searched.

Returns:

Returns the position of the first bit if the operation is successful; returns 0 if no bits are set in the word.

ffsll()

  1. int ffsll (longlongint i)

Description:

Searches for the first bit in a word of the 8-byte long integer type.

Specifically, this function searches for the least significant bit (position 1) set in the word.

Parameters:

Name

Description

iIndicates the 8-byte long integer to be searched.

Returns:

Returns the position of the first bit if the operation is successful; returns 0 if no bits are set in the word.

fgetwc()

  1. wint_t fgetwc ([FILE]($api-api-SmartVision-Devices-IO.md#ga912af5ab9f8a52ddd387b7defc0b49f1) * stream)

Description:

Reads a wide character from a specified file stream.

Parameters:

Name

Description

streamIndicates the pointer to the file object that identifies a stream.

Returns:

Returns the wide character if the operation is successful; returns WEOF if the operation fails or the end-of-file is reached during data reading.

fgetws()

  1. wchar_t* fgetws (wchar_t* ws,int n,[FILE]($api-api-SmartVision-Devices-IO.md#ga912af5ab9f8a52ddd387b7defc0b49f1) * stream )

Description:

Reads wide characters from a specified file stream.

Parameters:

Name

Description

wsIndicates the pointer to the wide character array that stores the characters to read.
nIndicates the number of characters to read.
streamIndicates the pointer to the file object that identifies a stream.

Returns:

Returns the pointer to the read string if the operation is successful; returns a null pointer if no characters are read or the end-of-file is reached during data reading.

fmtmsg()

  1. int fmtmsg (long classification,constchar* label,int severity,constchar* text,constchar* action,constchar* tag )

Description:

Prints formatted messages.

This function is used to print formatted messages to the output device specified by classification. The messages include the message definition, error severity, possible recovery steps, and reference to online documents.

Parameters:

Name

Description

classificationIndicates four types of information, including the output device, error source, problem detector, and problem severity. This parameter is of the long integer type.
labelIndicates the pointer to the message source. This parameter consists of two fields separated by a colon (:). The first field is up to 10 characters, the second is up to 14 characters.
severityIndicates the severity level of an error message. For details, see MM_HALT, MM_ERROR, MM_WARNING, MM_INFO, and MM_NOOSEV.
textIndicates the condition of the error.
actionDescribes possible steps to recover from the error.
tagIndicates the referenced online documents where more information can be found.

Message Type

Macro Definition Corresponding to the Message Description

Message output device

MM_PRINT, MM_CONSOLE or both

Message source

MM_HARD, MM_SOFT, or MM_FIRM

Message detector

MM_APPL, MM_UTIL, or MM_OPSYS

Severity of the incident

MM_RECOVER or MM_NRECOV

Attention:

All parameters in this function can be ignored based on the following definitions: MM_NULLLBL, MM_NULLSEV, MM_NULLTXT, MM_NULLACT, and MM_NULLTAG.

Returns:

The function can return 4 values: MM_OK, MM_NOTOK, MM_NOMSG, and MM_NOCON.

fnmatch()

  1. int fnmatch (constchar* pattern,constchar*string,int flags )

Description:

Matches a file name or a path name.

This function is used to check whether the value specified by string matches the value specified by pattern. Wildcards can be used in pattern, for example, ./foo* and foo*.boo*. You can use flags to set your required matching rule.

Parameters:

Name

Description

patternIndicates the pointer to the pattern to match.
stringIndicates the pointer to the string to match against pattern.
flagsIndicates a combination of flag bits that specify the matching rule. For details, see FNM_NOESCAPE, FNM_PATHNAME, FNM_PERIOD, FNM_LEADING_DIR, FNM_CASEFOLD, and FNM_FILE_NAME.

Returns:

Returns 0 if the matching is successful; returns FNM_NOMATCH if the matching fails; returns a non-zero value if an error occurs.

fork()

  1. pid_t fork (void)

Description:

Creates a new process that inherits from the user-mode data of its parent process.

Returns:

Returns 0 in the child process and returns the ID of the created child process in the parent process if the operation is successful; returns -1 and sets errno to a value in the following table if the operation fails.

errno

Description

EAGAIN

Insufficient process or thread control blocks.

ENOMEM

Insufficient memory.

fputwc()

  1. wint_t fputwc (wchar_t wc,[FILE]($api-api-SmartVision-Devices-IO.md#ga912af5ab9f8a52ddd387b7defc0b49f1) * stream )

Description:

Writes a wide character wc to a specified file stream.

Parameters:

Name

Description

wcIndicates the wide character to write.
streamIndicates the pointer to the file object that identifies a stream.

Returns:

Returns the wide character if the operation is successful; returns WEOF otherwise.

fputws()

  1. int fputws (constwchar_t* ws,[FILE]($api-api-SmartVision-Devices-IO.md#ga912af5ab9f8a52ddd387b7defc0b49f1) * stream )

Description:

Writes a wide string pointed to by ws to a specified file stream.

Parameters:

Name

Description

wsIndicates the pointer to the wide string to write.
streamIndicates the pointer to the file object that identifies a stream.

Returns:

Returns a non-negative value if the operation is successful; returns -1 (EOF) otherwise.

free()

  1. void free (void* ptr)

Description:

Releases the memory space pointed to by ptr.

The memory space was allocated by using calloc(), malloc(), or realloc().

Parameters:

Name

Description

ptrIndicates the pointer to the memory space to be released.

fsync()

  1. int fsync (int fd)

Description:

Synchronizes a file associated with a specified file descriptor to the storage device.

Parameters:

Name

Description

fdIndicates the descriptor of the file to be synchronized.

Returns:

Returns 0 if the operation is successful; returns -1 and sets errno to a value in the following table if the operation fails.

errno

Description

EBADF

fd is invalid.

EINVAL

fd is invalid for this device.

ENOSYS

The operation is not supported.

ftruncate()

  1. int ftruncate (int fd,off_t length )

Description:

Truncates a file to a specified length.

Parameters:

Name

Description

fdIndicates the file descriptor.
lengthIndicates the length of the file to be truncated.

Attention:

This function can be used only in the FAT file system based on the file descriptor.

Returns:

Returns 0 if the operation is successful; returns -1 and sets errno to a value in the following table if the operation fails.

errno

Description

EACCES

The file has no write permission.

EBADF

Failed to open the file in the specified path.

EINVAL

The target length is less than 0.

ENOSYS

The operation is not supported.

EPERM

Failed to obtain the file structure corresponding to the file specified by path, or the file access is rejected.

fwide()

  1. int fwide ([FILE]($api-api-SmartVision-Devices-IO.md#ga912af5ab9f8a52ddd387b7defc0b49f1) * stream, int mode )

Description:

Sets and determines the orientation of the file stream.

Parameters:

Name

Description

streamIndicates the pointer to the file object that identifies a stream.
modeIndicates the orientation of the stream. The value can be: A negative value indicating that the stream is byte-oriented A positive value indicating that the stream is wide-oriented 0 indicating that the stream orientation is not set

Returns:

Returns a positive value if the stream is wide-oriented; returns a negative value if the stream is byte-oriented; returns 0 if the stream has no orientation.

fwprintf()

  1. int fwprintf ([FILE]($api-api-SmartVision-Devices-IO.md#ga912af5ab9f8a52ddd387b7defc0b49f1) *__restrict fp, const wchar_t *__restrict fmt, ... )

Description:

Prints wide character strings to a specified file stream.

Parameters:

Name

Description

fpIndicates the pointer to the stream to print data.
fmtIndicates the pointer to the output format of the data.

Returns:

Returns the number of wide characters that are successfully printed; returns -1 if the operation fails.

fwscanf()

  1. int fwscanf ([FILE]($api-api-SmartVision-Devices-IO.md#ga912af5ab9f8a52ddd387b7defc0b49f1) * stream, const wchar_t * format, ... )

Description:

Reads formatted data from a specified stream and stores it based on the wide string format into the locations pointed to by the variable arguments.

Parameters:

Name

Description

streamIndicates the pointer to the file object that identifies a stream.
formatIndicates the pointer to the string that may contain the format specifiers.
Indicates the variable arguments storing the input data.

Returns:

Returns the number of variable arguments that are successfully stored.

gcvt()

  1. char* gcvt (double x,int n,char* b )

Description:

Converts a floating-point number to a string.

Parameters:

Name

Description

xIndicates the floating-point number to convert.
nIndicates the number of decimal places.
bIndicates the pointer to the output conversion result.

Returns:

Returns the converted string.

get_current_dir_name()

  1. char* get_current_dir_name (void)

Description:

Obtains the name of the current working directory.

Returns:

Returns the name of the current working directory if the operation is successful; returns NULL if the operation fails.

getcwd()

  1. char* getcwd (char* buf,size_t size )

Description:

Obtains the current working directory.

Parameters:

Name

Description

bufIndicates the pointer to the buffer of the array for storing the absolute path name of the current working directory.
sizeIndicates the size of the array to which the buffer points.

Returns:

Returns buf if the operation is successful; returns NULL and sets errno to a value in the following table if the operation fails.

errno

Description

EINVAL

buf is set to NULL.

ERANGE

size is less than the length of the current working directory (including the terminating null byte \0).

ENAMETOOLONG

Failed to copy the name of the current working directory to the buffer using memcpy_s.

getegid()

  1. gid_t getegid (void)

Description:

Obtains the effective group ID (GID) of the calling process.

Returns:

Returns the effective GID.

getenv()

  1. char* getenv (constchar* name)

Description:

Obtains the value of an environment variable.

Parameters:

Name

Description

nameIndicates the pointer to the name of the environment variable whose value needs to be obtained.

Returns:

Returns the pointer to the environment variable value if the operation is successful; returns NULL if there is no match.

geteuid()

  1. uid_t geteuid (void)

Description:

Obtains the effective user ID (UID) of the calling process.

Returns:

Returns the effective UID.

getgid()

  1. gid_t getgid (void)

Description:

Obtains the real group ID (GID) of the calling process.

Returns:

Returns the real GID.

getgroups()

  1. int getgroups (int size,gid_t list[])

Description:

Obtains a list of supplementary user group IDs specific to the calling process.

Parameters:

Name

Description

sizeIndicates the maximum size allowed for the supplementary group list. If the value is 0, this function obtains the total number of supplementary groups.
listIndicates the list of supplementary groups.

Returns:

Returns the number of supplementary groups of the calling process if the operation is successful; returns -1 and sets errno to a value in the following table if the operation fails.

errno

Description

EINVAL

size is invalid.

EFAULT

Invalid address.

ENOMEM

Insufficient memory.

getopt()

  1. int getopt (int argc,char*const argv[],constchar* optstring )

Description:

Parses command-line arguments based on the specified option.

Parameters:

Name

Description

argcIndicates the number of arguments when the file of the function is executed.
argvIndicates the argument content when the file of the function is executed.
optstringIndicates the string containing the optional arguments of the executable file. If this function obtains an option without arguments, the value of optind increases by 1. If this function obtains an option with arguments and the result is saved to optarg, the value of optind increases by 2.

Character Option Expression

Description

Only characters that indicate different options are available.

abc indicates that the file has three options -a, -b, and -c.

The character is followed by a colon.

b indicates that -b must be followed by an argument in the executable file that contains the getopt() function.

The character is followed by two colons.

b indicates that -b can be followed by or without the corresponding argument in the executable file that contains the getopt() function.

Returns:

Returns the parsed option character if the parsing is successful; returns ? if an option character that is not in optstring is encountered during parsing. When an option is encountered but there is no argument during parsing, this function returns : if the first character of optstring is a colon (:); returns ? otherwise. Returns -1 in the following cases: if all options have been parsed or argv[optind] is a null pointer; if the first character of the string to which argv[optind] points is not -, that is, the non-option argv parameter cannot appear in the middle of the parameter list. If a non-option parameter is encountered during parsing, the parsing is terminated. if the string to which argv[optind] points is -.

getopt_long()

  1. int getopt_long (int argc,char*const* argv,constchar* optstring,conststruct[option]($api-api-SmartVision-Devices-option.md)* longopts,int* longindex )

Description:

Parses the command-line arguments.

Parameters:

Name

Description

argcIndicates the number of command-line arguments.
argvIndicates the command-line argument content.
optstringIndicates the string containing the optional arguments of the executable file.
longoptsIndicates the long argument structure.
longindexIndicates the index of the current long argument in longopts.

Character Option Expression

Description

Only characters that indicate different options are available.

abc indicates that the file has three options -a, -b, and -c.

The character is followed by a colon.

b indicates that -b must be followed by an argument in the executable file that contains the getopt() function.

The character is followed by two colons.

b indicates that -b can be followed by or without the corresponding argument in the executable file that contains the getopt() function.

Returns:

Returns the parsed option character if the parsing is successful; returns -1 if all options have been parsed; returns ? if an option character that is not in optstring is encountered during parsing. When an option is encountered but there is no argument during parsing, this function returns : if the first character of optstring is a colon (:); returns ? otherwise.

getopt_long_only()

  1. int getopt_long_only (int argc,char*const* argv,constchar* optstring,conststruct[option]($api-api-SmartVision-Devices-option.md)* longopts,int* longindex )

Description:

Parses the command-line arguments.

Parameters:

Name

Description

argcIndicates the number of command-line arguments.
argvIndicates the command-line argument content.
optstringIndicates the string containing the optional arguments of the executable file.
longoptsIndicates the long argument structure.
longindexIndicates the index of the current long argument in longopts.

Character Option Expression

Description

Only characters that indicate different options are available.

abc indicates that the file has three options -a, -b, and -c.

The character is followed by a colon.

b indicates that -b must be followed by an argument in the executable file that contains the getopt() function.

The character is followed by two colons.

b indicates that -b can be followed by or without the corresponding argument in the executable file that contains the getopt() function.

Attention:

Different from getopt_long, this function matches –name and -name as long arguments.

Returns:

Returns the parsed option character if the parsing is successful; returns -1 if all options have been parsed; returns ? if an option character that is not in optstring is encountered during parsing. When an option is encountered but there is no argument during parsing, this function returns : if the first character of optstring is a colon (:); returns ? otherwise.

getpagesize()

  1. int getpagesize (void)

Description:

Obtains the memory page size.

Returns:

Returns the number of bytes in a memory page.

getpgid()

  1. pid_t getpgid (pid_t pid)

Description:

Obtains the ID of the process group whose process ID is specified by pid.

Parameters:

Name

Description

pidIndicates the process ID. If the value is 0, the process group ID of the current process is obtained.

Returns:

Returns 0 if the operation is successful; returns -1 and sets errno to a value in the following table if the operation fails.

errno

Description

EINVAL

Invalid process ID.

ESRCH

The specified process cannot be found.

getpgrp()

  1. pid_t getpgrp (void)

Description:

Obtains the ID of the process group of the calling process.

Returns:

Returns the process group ID if the operation is successful.

getpid()

  1. pid_t getpid (void)

Description:

Obtains the process ID.

Returns:

Returns the process ID.

getppid()

  1. pid_t getppid (void)

Description:

Obtains the parent process ID.

Returns:

Returns the parent process ID.

getresgid()

  1. int getresgid (gid_t* rgid,gid_t* egid,gid_t* sgid )

Description:

Obtains the real, effective, and saved user group IDs of the calling process.

Parameters:

Name

Description

rgidIndicates the pointer to the real user group ID.
egidIndicates the pointer to the effective user group ID.
sgidIndicates the pointer to the saved user group ID.

Returns:

Returns 0 if the operation is successful; returns -1 and sets errno to a value in the following table if the operation fails.

errno

Description

EFAULT

Invalid address.

getresuid()

  1. int getresuid (uid_t* ruid,uid_t* euid,uid_t* suid )

Description:

Obtains the real, effective, and saved user IDs of the calling process.

Parameters:

Name

Description

ruidIndicates the pointer to the real user ID.
euidIndicates the pointer to the effective user ID.
suidIndicates the pointer to the saved user ID.

Returns:

Returns 0 if the operation is successful; returns -1 and sets errno to a value in the following table if the operation fails.

errno

Description

EFAULT

Invalid address.

getsubopt()

  1. int getsubopt (char** optionp,char*const* tokens,char** valuep )

Description:

Processes the parameters of an option in the command line.

Generally, this function is used together with the getopt() to process the parameters of an option. You are advised to use this function if the parameters of an option are complex.

Parameters:

Name

Description

optionpIndicates the command word option.
tokensIndicates the pointer to the queried token.
valuepIndicates the suboption of the command word value.

Returns:

Returns the index of the matched suboption element in tokens if the operation is successful; returns -1 if the operation fails. 1.0 1.0

getuid()

  1. uid_t getuid (void)

Description:

Obtains the real user ID (UID) of the calling process.

Returns:

Returns the real UID.

getwc()

  1. wint_t getwc ([FILE]($api-api-SmartVision-Devices-IO.md#ga912af5ab9f8a52ddd387b7defc0b49f1) * stream)

Description:

Reads the first wide character from a specified file stream.

Parameters:

Name

Description

streamIndicates the pointer to the file object that identifies a stream.

Attention:

This function is similar to fgetwc except that it is implemented as a macro.

Returns:

Returns the wide character if the operation is successful; returns WEOF if an error occurs.

getwchar()

  1. wint_t getwchar (void)

Description:

Reads a wide character from the stdin.

Attention:

For details about unlocked objects, see unlocked_stdio.

Returns:

Returns the wide character if the operation is successful; returns WEOF if an error occurs.

hcreate()

  1. int hcreate (size_t nel)

Description:

Creates a hash table based on the number of entries.

Parameters:

Name

Description

nelIndicates the maximum number of entries allowed in the hash table.

Returns:

Returns a non-zero value if the operation is successful; returns 0 and sets errno to a value if the operation fails.

hcreate_r()

  1. int hcreate_r (size_t nel,struct[hsearch_data]($api-api-SmartVision-Devices-hsearch_data.md)* htab )

Description:

Creates a hash table based on the number of entries and its description.

Parameters:

Name

Description

nelIndicates the maximum number of entries allowed in the hash table.
htabIndicates the hash table.

Attention:

The hash table must be initialized before use.

Returns:

Returns a non-zero value if the operation is successful; returns 0 and sets errno to a value if the operation fails.

hdestroy()

  1. void hdestroy (void)

Description:

Destroys a hash table.

This function releases the memory for creating a hash table.

hdestroy_r()

  1. void hdestroy_r (struct[hsearch_data]($api-api-SmartVision-Devices-hsearch_data.md)* htab)

Description:

Destroys a hash table.

This function releases the memory occupied by the specified hash table.

Parameters:

Name

Description

htabIndicates the hash table.

hsearch()

  1. [ENTRY]($api-api-SmartVision-Devices-UTILS.md#gaf609835b21489409e39a22ed20313ab8)* hsearch ([ENTRY]($api-api-SmartVision-Devices-UTILS.md#gaf609835b21489409e39a22ed20313ab8) item, ACTION action )

Description:

Adds or searches for a hash entry.

This function searches for the entry in the hash table based on the specified action. If the action is FIND, only the search action is performed. If the action is ENTER, an entry not found is added to the hash table.

Parameters:

Name

Description

itemIndicates the hash table entry to be searched.
actionIndicates the function action. ENTER indicates that an entry is added, and FIND indicates that an entry is searched. For details, see ACTION.

Returns:

Returns the pointer to the hash table if the operation is successful.

hsearch_r()

  1. int hsearch_r ([ENTRY]($api-api-SmartVision-Devices-UTILS.md#gaf609835b21489409e39a22ed20313ab8) item, ACTION action, [ENTRY]($api-api-SmartVision-Devices-UTILS.md#gaf609835b21489409e39a22ed20313ab8) ** retval, struct [hsearch_data]($api-api-SmartVision-Devices-hsearch_data.md) * htab )

Description:

Searches for a hash table.

This function searches for the entry in the hash table based on the specified action. If the action is FIND, only the search action is performed. If the action is ENTER, an entry not found is added to the hash table.

Parameters:

Name

Description

itemIndicates the hash table entry to be searched.
actionIndicates the function action. ENTER indicates that an entry is added, and FIND indicates that an entry is searched. ACTION
htabIndicates the hash table.

Returns:

Returns a non-zero value if the operation is successful; returns 0 if the operation fails.

imaxabs()

  1. intmax_t imaxabs (intmax_t j)

Description:

Calculates the absolute value of an input parameter of the integer type.

This function is used to calculate the absolute value of the input parameter specified by j of the intmax_t type.

Parameters:

Name

Description

jIndicates the input parameter.

Attention:

Pay attention to the parameter type.

Returns:

Returns the absolute value of the input parameter if the operation is successful.

imaxdiv()

  1. [imaxdiv_t]($api-api-SmartVision-Devices-imaxdiv_t.md) imaxdiv (intmax_t numerator,intmax_t denominator )

Description:

Calculates the quotient and remainder after the division operation is performed on an integer.

Parameters:

Name

Description

numeratorIndicates the numerator.
denominatorIndicates the denominator.

Returns:

Returns a structure variable that has been defined in the function.

index()

  1. char* index (constchar* s,int c )

Description:

Searches for the first position of the matched character in a string.

Parameters:

Name

Description

sIndicates the pointer to the string to be searched.
cIndicates the character to be matched.

Returns:

Returns the pointer to the matched character if the operation is successful; returns NULL if the operation fails.

initstate()

  1. char* initstate (unsignedint seed,char* state,size_t n )

Description:

Initializes a random number generator.

This function initializes the state array for subsequent random use.

Parameters:

Name

Description

seedIndicates the seed for initialization, which specifies the start point of the random number sequence and provides the information for restarting at the same point.
Indicatesthe state array used to generate random numbers.
nIndicates the length of the state array.

Returns:

Returns the pointer to the state array if the operation is successful; returns NULL if the operation fails.

insque()

  1. void insque (void* element,void* pred )

Description:

Adds an entry to a queue.

Parameters:

Name

Description

elementIndicates the element to be added to the queue.
predAfter the position of prev to add the element.

isalnum()

  1. int isalnum (int c)

Description:

Checks whether a parameter is an alphabetic character or a decimal digit.

Parameters:

Name

Description

cIndicates the parameter to check.

Returns:

Returns a non-zero value if c is an alphabetic character or a decimal digit; returns 0 otherwise.

isalnum_l()

  1. int isalnum_l (int c,locale_t locale )

Description:

Checks whether a parameter is an alphabetic character or digit for the specified locale.

Parameters:

Name

Description

cIndicates the parameter to check.
localeIndicates the locale. This parameter is ignored currently.

Returns:

Returns a non-zero value if c is an alphabetic character or digit; returns 0 otherwise.

isalpha()

  1. int isalpha (int c)

Description:

Checks whether a parameter is an alphabetic character.

Parameters:

Name

Description

cIndicates the parameter to check.

Returns:

Returns a non-zero value if c is an alphabetic character; returns 0 otherwise.

isalpha_l()

  1. int isalpha_l (int c,locale_t locale )

Description:

Checks whether a parameter is an alphabetic character for the specified locale.

Parameters:

Name

Description

cIndicates the parameter to check.
localeIndicates the locale. This parameter is ignored currently.

Returns:

Returns a non-zero value if c is an alphabetic character; returns 0 otherwise.

isblank()

  1. int isblank (int c)

Description:

Checks whether a parameter is a blank character (space or tap).

Parameters:

Name

Description

cIndicates the parameter to check.

Returns:

Returns a non-zero value if c is a blank character; returns 0 otherwise.

isblank_l()

  1. int isblank_l (int c,locale_t locale )

Description:

Checks whether a parameter is a blank character (including spaces and tabs) for the specified locale.

Parameters:

Name

Description

cIndicates the parameter to check.
localeIndicates the locale. This parameter is ignored currently.

Returns:

Returns a non-zero value if c is a blank character; returns 0 otherwise.

iscntrl()

  1. int iscntrl (int c)

Description:

Checks whether a parameter is a control character. A control character is invisible and does not occupy a printing position on a display.

Parameters:

Name

Description

cIndicates the parameter to check.

Returns:

Returns a non-zero value if c is a control character; returns 0 otherwise.

iscntrl_l()

  1. int iscntrl_l (int c,locale_t locale )

Description:

Checks whether a parameter is a control character for the specified locale.

A control character is invisible and does not occupy a printing position on a display.

Parameters:

Name

Description

cIndicates the parameter to check.
localeIndicates the locale. This parameter is ignored currently.

Returns:

Returns a non-zero value if c is a control character; returns 0 otherwise.

isdigit()

  1. int isdigit (int c)

Description:

Checks whether a parameter is a decimal digit (0-9).

Parameters:

Name

Description

cIndicates the parameter to check.

Returns:

Returns a non-zero value if c is a decimal digit; returns 0 otherwise.

isdigit_l()

  1. int isdigit_l (int c,locale_t locale )

Description:

Checks whether a parameter is a decimal digit for the specified locale.

Parameters:

Name

Description

cIndicates the parameter to check.
localeIndicates the locale. This parameter is ignored currently.

Returns:

Returns a non-zero value if c is a decimal digit; returns 0 otherwise.

isgraph()

  1. int isgraph (int c)

Description:

Checks whether a parameter is any printable character except the space character.

Parameters:

Name

Description

cIndicates the parameter to check.

Returns:

Returns a non-zero value if c is a printable character except the space character; returns 0 otherwise.

isgraph_l()

  1. int isgraph_l (int c,locale_t locale )

Description:

Checks whether a parameter is any printable character except the space character for the specified locale.

Parameters:

Name

Description

cIndicates the parameter to check.
localeIndicates the locale. This parameter is ignored currently.

Returns:

Returns a non-zero value if c is a printable character except the space character; returns 0 otherwise.

islower()

  1. int islower (int c)

Description:

Checks whether a parameter is a lowercase letter.

Parameters:

Name

Description

cIndicates the parameter to check.

Returns:

Returns a non-zero value if c is a lowercase letter; returns 0 otherwise.

islower_l()

  1. int islower_l (int c,locale_t locale )

Description:

Checks whether a parameter is a character of lowercase letters for the specified locale.

Parameters:

Name

Description

cIndicates the parameter to check.
localeIndicates the locale. This parameter is ignored currently.

Returns:

Returns a non-zero value if c is a lowercase letter; returns 0 otherwise.

isprint()

  1. int isprint (int c)

Description:

Checks whether a parameter is a printable character (including space).

A printable character is a character that occupies a printing position on a display.

Parameters:

Name

Description

cIndicates the parameter to check.

Returns:

Returns a non-zero value if c is a printable character; returns 0 otherwise.

isprint_l()

  1. int isprint_l (int c,locale_t locale )

Description:

Checks whether a parameter is a printable character (including space) for the specified locale. A printable character is visible and occupies a printing position on a display.

Parameters:

Name

Description

cIndicates the parameter to check.
localeIndicates the locale. This parameter is ignored currently.

Returns:

Returns a non-zero value if c is a printable character; returns 0 otherwise.

ispunct()

  1. int ispunct (int c)

Description:

Checks whether a parameter is a punctuation or special character.

Parameters:

Name

Description

cIndicates the parameter to check.

Returns:

Returns a non-zero value if c is a punctuation or special character; returns 0 otherwise.

ispunct_l()

  1. int ispunct_l (int c,locale_t locale )

Description:

Checks whether a parameter is a punctuation or special character for the specified locale.

Parameters:

Name

Description

cIndicates the parameter to check.
localeIndicates the locale. This parameter is ignored currently.

Returns:

Returns a non-zero value if c is a punctuation or special character; returns 0 otherwise.

isspace()

  1. int isspace (int c)

Description:

Checks whether a parameter is a space character.

The space characters are: space, horizontal tab (\t), vertical tab (\v), form feed (\f), carriage return (\r), and line feed ().

Parameters:

Name

Description

cIndicates the parameter to check.

Returns:

Returns a non-zero value if c is a space character; returns 0 otherwise.

isspace_l()

  1. int isspace_l (int c,locale_t locale )

Description:

Checks whether a parameter is a blank character for the specified locale.

Blank characters refer to space, horizontal tab (\t), vertical tab (\v), form feed (\f), carriage return (\r), and line feed ().

Parameters:

Name

Description

cIndicates the parameter to check.
localeIndicates the locale. This parameter is ignored currently.

Returns:

Returns a non-zero value if c is a blank character; returns 0 otherwise.

isupper()

  1. int isupper (int c)

Description:

Checks whether a parameter is an uppercase letter.

Parameters:

Name

Description

cIndicates the parameter to check.

Returns:

Returns a non-zero value if c is an uppercase letter; returns 0 otherwise.

isupper_l()

  1. int isupper_l (int c,locale_t locale )

Description:

Checks whether a parameter is a character of uppercase letters for the specified locale.

Parameters:

Name

Description

cIndicates the parameter to check.
localeIndicates the locale. This parameter is ignored currently.

Returns:

Returns a non-zero value if c is in uppercase; returns 0 otherwise.

iswalnum()

  1. int iswalnum (wint_t wc)

Description:

Checks whether a wide character is a letter or digit.

Parameters:

Name

Description

wcIndicates the wide character.

Returns:

Returns a non-zero value if the operation is successful; returns 0 otherwise.

iswalnum_l()

  1. int iswalnum_l (wint_t wc,locale_t locale )

Description:

Checks whether a wide character is a letter or digit for the specified locale.

Parameters:

Name

Description

wcIndicates the wide character.
localeIndicates the locale. This parameter is ignored currently.

Returns:

Returns a non-zero value if the operation is successful; returns 0 otherwise.

iswalpha()

  1. int iswalpha (wint_t wc)

Description:

Checks whether a wide character is a letter.

Parameters:

Name

Description

wcIndicates the wide character.

Returns:

Returns a non-zero value if the operation is successful; returns 0 otherwise.

iswalpha_l()

  1. int iswalpha_l (wint_t wc,locale_t locale )

Description:

Checks whether a wide character is alphabetic for the specified locale.

Parameters:

Name

Description

wcIndicates the wide character.
localeIndicates the locale. This parameter is ignored currently.

Returns:

Returns a non-zero value if the operation is successful; returns 0 otherwise.

iswblank()

  1. int iswblank (wint_t wc)

Description:

Checks whether a wide character is a space or tab character (\t).

Parameters:

Name

Description

wcIndicates the wide character.

Returns:

Returns a non-zero value if the operation is successful; returns 0 otherwise.

iswblank_l()

  1. int iswblank_l (wint_t wc,locale_t locale )

Description:

Checks whether a wide character is a blank or \t character for the specified locale.

Parameters:

Name

Description

wcIndicates the wide character.
localeIndicates the locale. This parameter is ignored currently.

Returns:

Returns a non-zero value if the operation is successful; returns 0 otherwise.

iswcntrl()

  1. int iswcntrl (wint_t wc)

Description:

Checks whether a wide character is a control character.

Parameters:

Name

Description

wcIndicates the wide character.

Returns:

Returns a non-zero value if the operation is successful; returns 0 otherwise.

iswcntrl_l()

  1. int iswcntrl_l (wint_t wc,locale_t locale )

Description:

Checks whether a wide character is a control character for the specified locale.

Parameters:

Name

Description

wcIndicates the wide character.
localeIndicates the locale. This parameter is ignored currently.

Returns:

Returns a non-zero value if the operation is successful; returns 0 otherwise.

iswctype()

  1. int iswctype (wint_t wc,wctype_t desc )

Description:

Checks whether the character specified by wc belongs to the desc class.

Parameters:

Name

Description

wcIndicates the wide character.
descIndicates the wide character class.

Returns:

Returns a non-zero value if the operation is successful; returns 0 otherwise.

iswctype_l()

  1. int iswctype_l (wint_t wc,wctype_t desc,locale_t locale )

Description:

Checks whether the character specified by wc belongs to the desc class for the specified locale.

Parameters:

Name

Description

wcIndicates the wide character.
descIndicates the wide character class.
localeIndicates the locale. This parameter is ignored currently.

Returns:

Returns a non-zero value if the operation is successful; returns 0 otherwise.

iswdigit()

  1. int iswdigit (wint_t wc)

Description:

Checks whether a wide character is a decimal digit.

Parameters:

Name

Description

wcIndicates the wide character.

Returns:

Returns a non-zero value if the operation is successful; returns 0 otherwise.

iswdigit_l()

  1. int iswdigit_l (wint_t wc,locale_t locale )

Description:

Checks whether a wide character is a decimal digit for the specified locale.

Parameters:

Name

Description

wcIndicates the wide character.
localeIndicates the locale. This parameter is ignored currently.

Returns:

Returns a non-zero value if the operation is successful; returns 0 otherwise.

iswgraph()

  1. int iswgraph (wint_t wc)

Description:

Checks whether a wide character is visible.

Parameters:

Name

Description

wcIndicates the wide character.

Returns:

Returns a non-zero value if the operation is successful; returns 0 otherwise.

iswgraph_l()

  1. int iswgraph_l (wint_t wc,locale_t locale )

Description:

Checks whether a wide character is visible for the specified locale.

Parameters:

Name

Description

wcIndicates the wide character.
localeIndicates the locale. This parameter is ignored currently.

Returns:

Returns a non-zero value if the operation is successful; returns 0 otherwise.

iswlower()

  1. int iswlower (wint_t wc)

Description:

Checks whether a wide character is a lowercase letter.

Parameters:

Name

Description

wcIndicates the wide character.

Returns:

Returns a non-zero value if the operation is successful; returns 0 otherwise.

iswlower_l()

  1. int iswlower_l (wint_t wc,locale_t locale )

Description:

Checks whether a wide character is in lowercase for the specified locale.

Parameters:

Name

Description

wcIndicates the wide character.
localeIndicates the locale. This parameter is ignored currently.

Returns:

Returns a non-zero value if the operation is successful; returns 0 otherwise.

iswprint()

  1. int iswprint (wint_t wc)

Description:

Checks whether a wide character is printable.

Parameters:

Name

Description

wcIndicates the wide character.

Returns:

Returns a non-zero value if the operation is successful; returns 0 otherwise.

iswprint_l()

  1. int iswprint_l (wint_t wc,locale_t locale )

Description:

Checks whether a wide character is printable for the specified locale.

Parameters:

Name

Description

wcIndicates the wide character.
localeIndicates the locale. This parameter is ignored currently.

Returns:

Returns a non-zero value if the operation is successful; returns 0 otherwise.

iswpunct()

  1. int iswpunct (wint_t wc)

Description:

Checks whether a wide character is a punctuation mark.

Parameters:

Name

Description

wcIndicates the wide character.

Returns:

Returns a non-zero value if the operation is successful; returns 0 otherwise.

iswpunct_l()

  1. int iswpunct_l (wint_t wc,locale_t locale )

Description:

Checks whether wc is a punctuation wide character for the specified locale.

Parameters:

Name

Description

wcIndicates the wide character.
localeIndicates the locale. This parameter is ignored currently.

Returns:

Returns a non-zero value if the operation is successful; returns 0 otherwise.

iswspace()

  1. int iswspace (wint_t wc)

Description:

Checks whether a wide character belongs to the wide-character class space.

Parameters:

Name

Description

wcIndicates the wide character.

Returns:

Returns a non-zero value if the operation is successful; returns 0 otherwise.

iswspace_l()

  1. int iswspace_l (wint_t wc,locale_t locale )

Description:

Checks whether a wide character belongs to the wide-character class space for the specified locale.

Parameters:

Name

Description

wcIndicates the wide character.
localeIndicates the locale. This parameter is ignored currently.

Returns:

Returns a non-zero value if the operation is successful; returns 0 otherwise.

iswupper()

  1. int iswupper (wint_t wc)

Description:

Checks whether a wide character is an uppercase letter.

Parameters:

Name

Description

wcIndicates the wide character.

Returns:

Returns a non-zero value if the operation is successful; returns 0 otherwise.

iswupper_l()

  1. int iswupper_l (wint_t wc,locale_t locale )

Description:

Checks whether a wide character is in uppercase for the specified locale.

Parameters:

Name

Description

wcIndicates the wide character.
localeIndicates the locale. This parameter is ignored currently.

Returns:

Returns a non-zero value if the operation is successful; returns 0 otherwise.

iswxdigit()

  1. int iswxdigit (wint_t wc)

Description:

Checks whether a wide character is a hexadecimal digit.

Parameters:

Name

Description

wcIndicates the wide character.

Returns:

Returns a non-zero value if the operation is successful; returns 0 otherwise.

iswxdigit_l()

  1. int iswxdigit_l (wint_t wc,locale_t locale )

Description:

Checks whether a wide character is a hexadecimal digit for the specified locale.

Parameters:

Name

Description

wcIndicates the wide character.
localeIndicates the locale. This parameter is ignored currently.

Returns:

Returns a non-zero value if the operation is successful; returns 0 otherwise.

isxdigit()

  1. int isxdigit (int c)

Description:

Checks whether a parameter is a hexadecimal digit.

Parameters:

Name

Description

cIndicates the parameter to check.

Returns:

Returns a non-zero value if c is a hexadecimal digit; returns 0 otherwise.

isxdigit_l()

  1. int isxdigit_l (int c,locale_t locale )

Description:

Checks whether a parameter is a hexadecimal digit for the specified locale.

Parameters:

Name

Description

cIndicates the parameter to check.
localeIndicates the locale. This parameter is ignored currently.

Returns:

Returns a non-zero value if the parameter is a hexadecimal digit; returns 0 otherwise.

jrand48()

  1. long jrand48 (unsignedshort xsubi[3])

Description:

Generates pseudo-random numbers evenly distributed between [-2^31, 2^31).

Parameters:

Name

Description

xsubi[3]Indicates the array of the initialized value of Xi.

Attention:

This function works by generating a 48-bit integer sequence, and X(i+1) must be generated by using the value of Xi. The correlation is obtained by using a linear congruential formula, Xn+1 = (aXn + c) mod m, where n = 0, m = 2^48, a = 0x5DEECE66D, and c = 0xB. Xi is specified by xsubi[3].

Returns:

Returns signed long integers evenly distributed between [-2^31, 2^31) if the operation is successful.

l64a()

  1. char* l64a (long value)

Description:

Converts a long integer to a 64-bit ASCII string.

Parameters:

Name

Description

valueIndicates the long integer to be converted.

Returns:

Returns the pointer to the static buffer if the operation is successful. The content in the buffer is overwritten each time the function is called. For multithreaded programs, this function returns a pointer to thread-specific data.

labs()

  1. long labs (long i)

Description:

Calculates the absolute value of a long integer.

Parameters:

Name

Description

iIndicates the long integer to be converted.

Returns:

Returns the absolute value.

lcong48()

  1. void lcong48 (unsignedshort param[7])

Description:

Sets the seed and related algorithm parameters for the pseudo-random number generator.

Parameters:

Name

Description

param[7]Indicates the parameters of the random number generator.

Attention:

This function works by generating a 48-bit integer sequence, and X(i+1) must be generated by using the value of Xi. The correlation is obtained by using a linear congruential formula, Xn+1 = (aXn + c) mod m, where n = 0, m = 2^48, a = 0x5DEECE66D, and c = 0xB. param[0 - 2] is the initialized value of Xi. param [3-5] specifies the value of a, and param[6] specifies the value of c. After this function is called, calling srand48 () or seed48 () will restore the standard values of a and c.

ldiv()

  1. [ldiv_t]($api-api-SmartVision-Devices-ldiv_t.md) ldiv (long numerator,long denominator )

Description:

Calculates the quotient and remainder of a long integer after division.

Parameters:

Name

Description

numeratorIndicates the numerator.
denominatorIndicates the denominator.

Returns:

Returns a structure variable that has been defined in the function.

lfind()

  1. void* lfind (constvoid* key,constvoid*base,size_t* nelp,size_t width,int(*)(constvoid*,constvoid*) compar )

Description:

Performs a linear search for a key in the array.

Parameters:

Name

Description

keyIndicates the pointer to the key to be searched.
baseIndicates the pointer to the array buffer.
nelpIndicates the pointer to the linear search length.
widthIndicates the pointer to the array buffer width.
comparIndicates the pointer to the function to match.

Returns:

Returns the obtained key if the operation is successful; returns NULL if the operation fails.

llabs()

  1. longlong llabs (longlong i)

Description:

Calculates the absolute value of a long long integer.

Parameters:

Name

Description

iIndicates the long long integer to be converted.

Returns:

Returns the absolute value.

lldiv()

  1. [lldiv_t]($api-api-SmartVision-Devices-lldiv_t.md) lldiv (longlong numerator,longlong denominator )

Description:

Calculates the quotient and remainder of a long long integer after division.

Parameters:

Name

Description

numeratorIndicates the numerator.
denominatorIndicates the denominator.

Returns:

Returns a structure variable that has been defined in the function.

lrand48()

  1. longint lrand48 (void)

Description:

Generates pseudo-random numbers evenly distributed between [0, 2^31).

Attention:

This function works by generating a 48-bit integer sequence, and X(i+1) must be generated by using the value of Xi. The correlation is obtained by using a linear congruential formula, Xn+1 = (aXn + c) mod m, where n = 0, m = 2^48, a = 0x5DEECE66D, and c = 0xB. Before this function is called, one of the functions srand48(), seed48(), and lcong48() must be used to initialize Xi.

Returns:

Returns nonnegative long integers evenly distributed between [0, 2^31) if the operation is successful.

lsearch()

  1. void* lsearch (constvoid* key,constvoid*base,size_t* nelp,size_t width,int(*)(constvoid*,constvoid*) compar )

Description:

Performs a linear search for a key in the array and adds a key to the end of the array if the key is not found.

Parameters:

Name

Description

keyIndicates the pointer to the key to be searched.
baseIndicates the pointer to the array buffer.
nelpIndicates the pointer to the linear search length.
widthIndicates the pointer to the array buffer width.
comparIndicates the pointer to the function to match.

Returns:

Returns the obtained key if the operation is successful.

lseek()

  1. off_t lseek (int fd,off_t offset,int whence )

Description:

Sets the offset of the pointer to the file.

The pointer to the file is used to read and write data.

Parameters:

Name

Description

fdIndicates the file descriptor.
offsetIndicates the pointer offset to be set.
whenceIndicates the pointer position. The value can be SEEK_CUR (current position), SEEK_SET (beginning of the file), or SEEK_END (end of the file).

Returns:

Returns the offset to the beginning of the file if the operation is successful; returns -1 and sets errno to a value in the following table if the operation fails.

errno

Description

EBADF

fd is invalid.

ENOSYS

This operation is not supported.

EINVAL

whence is invalid.

EIO

A hardware error occurs at the I/O layer.

malloc()

  1. void* malloc (size_t size)

Description:

Dynamically allocates a memory block of size.

The allocated memory is not initialized.

Parameters:

Name

Description

sizeIndicates the size of the memory block to be allocated.

Returns:

Returns the pointer to the allocated memory block if the operation is successful; returns NULL and sets errno to a value in the following table if the operation fails.

errno

Description

ENOMEM

Insufficient memory.

mblen()

  1. int mblen (constchar* s,size_t n )

Description:

Obtains the number of bytes in the next multi-byte string.

If s is not NULL, this function inspects at most n bytes of the multi-byte string starting at s.

Parameters:

Name

Description

sIndicates the pointer to a string constant.
nIndicates the number of bytes to be checked. The value cannot be greater than MB_CUR_MAX.

Returns:

Returns the number of bytes of the string constant if the operation is successful; returns 0 if the string constant content is a wide character that is empty; returns -1 if the string constant content is invalid or cannot be parsed.

mbrlen()

  1. size_t mbrlen (constchar* s,size_t n,mbstate_t* ps )

Description:

Determines the number of bytes in a character string pointed to by s.

If s is not NULL, this function checks at most n bytes in the string of s. It also uses a static anonymous shift state pointed to by ps.

Parameters:

Name

Description

sIndicates the pointer to the string to check.
nIndicates the maximum number of bytes to check.
psIndicates the pointer to the mbstate_t object describing the conversion state.

Attention:

The behavior of this function depends on the LC_CTYPE type of the current locale.

Returns:

Returns the number of bytes in the string if the operation is successful. If s is a null pointer, this function returns 0. If the characters in s are invalid or cannot be parsed, this function returns -1. If the first n bytes in the string of s do not contribute to a complete multi-byte character, this function returns (size_t)-2. If the first n bytes in the string of s contain an invalid multi-byte character, this function returns (size_t)-1 and sets errno to EILSEQ.

mbrtowc()

  1. size_t mbrtowc (wchar_t* pwc,constchar* s,size_t n,mbstate_t* ps )

Description:

Converts a multi-byte character string with a length of n into a wide character string.

Parameters:

Name

Description

pwcIndicates the pointer to the destination wide character array to store the converted string.
sIndicates the pointer to the multi-byte character string to be converted.
nIndicates the number of bytes to read from s.
psIndicates the pointer to the mbstate_t object describing the conversion state.

Returns:

Returns the number of characters written to the destination wide character array. If the first n bytes in the string of s do not contribute to a complete multi-byte character, this function returns (size_t)-2. If the first n bytes in the string of s contain an invalid multi-byte character, this function returns (size_t)-1 and sets errno to EILSEQ. If the converted wide character is L’\ 0’, this function returns 0 and resets * ps to the initial state.

mbsinit()

  1. int mbsinit (constmbstate_t* ps)

Description:

Checks whether the mbstate_t object pointed to by ps is in the initial state.

Parameters:

Name

Description

psIndicates the pointer to the mbstate_t object to check.

Returns:

Returns a non-zero value if ps points to an object that is in the initial state or it is a null pointer; returns 0 otherwise.

mbsnrtowcs()

  1. size_t mbsnrtowcs (wchar_t* dest,constchar** src,size_t nwc,size_t len,mbstate_t* ps )

Description:

Converts a multi-byte character string with a length of n into a wide character string that can hold a total of nwc wide characters.

Parameters:

Name

Description

destIndicates the pointer to the destination wide character array to store the converted string.
srcIndicates the double pointer to the source string to be converted.
nwcIndicates the number of wide characters that can be written to the destination wide character array.
lenIndicates the number of characters to be converted.
psIndicates the pointer to the mbstate_t object describing the conversion state.

Attention:

The dest value cannot be NULL.

Returns:

Returns the number of characters written to the destination wide character array. If the first n bytes in the string of s contain an invalid multi-byte character, this function returns (size_t)-1 and sets errno to EILSEQ. If more than nwc characters will be written or more than len characters are to be converted, src points to the next character to be converted, and this function returns the number of characters successfully written to the destination wide character array. If the converted wide character is L’\ 0’, this function returns 0 and resets * ps to the initial state.

mbsrtowcs()

  1. size_t mbsrtowcs (wchar_t* dest,constchar** src,size_t len,mbstate_t* ps )

Description:

Converts a multi-byte character string with a length of len into a wide character string.

Parameters:

Name

Description

destIndicates the pointer to the destination wide character array to store the converted string.
srcIndicates the double pointer to the source string to be converted.
lenIndicates the number of wide characters to be converted.
psIndicates the pointer to the mbstate_t object describing the conversion state.

Attention:

dest cannot be NULL.

Returns:

Returns the number of characters written to the destination wide character array. If an invalid character is encountered, this function returns len-1 and sets errno to EILSEQ. If len non-L’\0’ characters have been successfully written to the destination wide character array, src points to the next character to be converted, and this function returns the number of wide characters successfully written to the destination array. If the converted wide character is L’\0’, this function returns 0 and resets * ps to the initial state.

mbstowcs()

  1. size_t mbstowcs (wchar_t* dest,constchar* src,size_t n )

Description:

Converts a multi-byte string to a wide-character string.

Parameters:

Name

Description

destIndicates the pointer to an array for the wchar_t element. The array length can store a wide-character string whose length is specified by n.
srcIndicates the pointer to the multi-byte string to convert.
nIndicates the maximum number of wide characters to convert.

Returns:

Returns the number of wide characters, excluding the terminating null wide character if the operation is successful; returns -1 if an invalid multibyte character is encountered.

mbtowc()

  1. int mbtowc (wchar_t* pwc,constchar* s,size_t n )

Description:

Converts a string constant to a wide character.

If s is not NULL, this function inspects at most n bytes of the multi-byte string starting at s and converts it to a wide character and stores it.

Parameters:

Name

Description

pwcIndicates the pointer to the string for storing the wide character.
sIndicates the pointer to a string constant.
nIndicates the number of bytes to be checked. The value cannot be greater than MB_CUR_MAX.

Attention:

s and pwc cannot be NULL. If s is NULL, pwc and n are ignored.

Returns:

Returns the number of bytes converted from s if the operation is successful; returns 0 if s points to an empty byte; returns -1 if the string constant content is invalid or cannot be parsed.

memccpy()

  1. void* memccpy (void*__restrict dest,constvoid*__restrict src,int c,size_t n )

Description:

Copies a memory area to another one.

This function copies no more than n bytes from the source memory area pointed to by src to the destination memory area pointed to by dest. The copy stops when a character specified by c is found. The result for two overlapped memory areas is undefined.

Parameters:

Name

Description

destIndicates the pointer to the destination memory area.
srcIndicates the pointer to the source memory area.
cIndicates the character for stopping copying.
nIndicates the size of the string to be copied, in bytes.

Returns:

Returns the pointer to the next character of the character c in the destination memory area if the operation is successful; returns NULL if the character c is not found in the n bytes of the source memory area.

memchr()

  1. void* memchr (constvoid* s,int c,size_t n )

Description:

Searches for a character in the specified memory area.

This function searches for the first occurrence of the character specified by c in the n-byte memory area pointed to by s. Both the character c and the memory area pointed to by s are interpreted as unsigned characters.

Parameters:

Name

Description

sIndicates the pointer to the start of the bytes to be searched.
cIndicates the character to be searched for.
nIndicates the length of the memory area to be searched.

Returns:

Returns the pointer to the character if found; returns NULL if no matching character is found.

memcmp()

  1. int memcmp (constvoid* s1,constvoid* s2,size_t n )

Description:

Compares two memory areas.

This function checks whether the first n bytes of the two memory areas pointed to by s1 and s2 are equal.

Parameters:

Name

Description

s1Indicates the pointer to memory area 1 for comparison.
s2Indicates the pointer to memory area 2 for comparison.
nIndicates the size of the memory area to be compared, in bytes.

Returns:

Returns 0 if the first n bytes of two memory areas are the same or n is 0; returns the difference between the first pair of bytes that differ in s1 and s2 if the contents of two memory areas are different.

memcpy()

  1. void* memcpy (void*__restrict dest,constvoid*__restrict src,size_t n )

Description:

Copies a string (overlapping not allowed).

This function copies n bytes from the source memory area pointed to by src to the destination memory area pointed to by dest. The two memory areas cannot overlap. If they overlap, use memmove() instead.

Parameters:

Name

Description

destIndicates the pointer to the destination memory area.
srcIndicates the pointer to the source memory area.
nIndicates the size of the string to be copied, in bytes.

Returns:

Returns the pointer (dest) to the destination memory area.

memmem()

  1. void* memmem (constvoid* haystack,size_t haystacklen,constvoid* needle,size_t needlelen )

Description:

Searches for a needle string in its haystack string.

This function searches for the start position of the first occurrence of the needle string whose length is needlelen in the memory area holding the haystack string which starts at the position pointed to by haystack.

Parameters:

Name

Description

haystackIndicates the pointer to the start position of the memory area to be searched.
haystacklenIndicates the length (in bytes) of the memory area to be searched.
needleIndicates the pointer to the start position of the needle string to be searched for.
needlelenIndicates the length (in bytes) of the needle string to be searched for.

Attention:

This is an extended GNU function.

Returns:

Returns the start position of the needle string in the memory area if the position is found; returns NULL if the position is not found.

memmove()

  1. void* memmove (void* dest,constvoid* src,size_t n )

Description:

Copies a string (overlapping allowed).

This function copies n bytes from the source memory area pointed to by src to the destination memory area pointed to by dest. The two memory areas can overlap.

Parameters:

Name

Description

destIndicates the pointer to the destination memory area.
srcIndicates the pointer to the source memory area.
nIndicates the size of the string to be copied, in bytes.

Returns:

Returns the pointer (dest) to the destination memory area.

See also:

memcpy()

mempcpy()

  1. void* mempcpy (void* dest,constvoid* src,size_t n )

Description:

Copies a string (overlapping not allowed).

This function copies n bytes from the source memory area pointed to by src to the destination memory area pointed to by dest. The two memory areas cannot overlap. This function is similar to memcpy() except for the return value. This function returns the pointer to the last byte written during the copy.

Parameters:

Name

Description

destIndicates the pointer to the destination memory area.
srcIndicates the pointer to the source memory area.
nIndicates the size of the string to be copied, in bytes.

Returns:

Returns the pointer to the last byte written during the copy.

memrchr()

  1. void* memrchr (constvoid* s,int c,size_t n )

Description:

Searches for a character in the specified memory area.

This function searches for the first occurrence of the character specified by c in the n-byte memory area pointed to by s. This function searches backward from the end of the n bytes pointed to by s, while the memchr() function searches forward from the beginning.

Parameters:

Name

Description

sIndicates the pointer to the start of the bytes to be searched.
cIndicates the character to be searched for.
nIndicates the length of the memory area to be searched.

Returns:

Returns the pointer to the character if found; returns NULL if no matching character is found.

memset()

  1. void* memset (void* s,int c,size_t n )

Description:

Copies a character to the specified memory area.

This function copies the character specified by c to the n-byte memory area pointed to by s.

Parameters:

Name

Description

sIndicates the pointer to the memory area to hold the character.
cIndicates the character to be copied.
nIndicates the size of the memory area.

Returns:

Returns the pointer (s) to the memory area.

mkdtemp()

  1. char* mkdtemp (char*template)

Description:

Creates a unique temporary directory based on template.

Parameters:

Name

Description

templateIndicates the name of the directory to be created. The last six characters must be XXXXXX.

Returns:

Returns the pointer to the modified template string if the operation is successful; returns NULL and sets errno to a value in the following table if the operation fails.

errno

Description

EINVAL

The last six characters are not XXXXXX.

Other

For details, see mkdir.

See also:

mkdir

mkostemp()

  1. int mkostemp (char*template,int flags )

Description:

Creates and opens a unique temporary file.

Different from mkstemp, this function has the flags parameter.

Parameters:

Name

Description

templateIndicates the name of the file to be created. The last six characters must be XXXXXX.
flagsIndicates the flag for creating a file. For details, see open.

Returns:

Returns the descriptor of the opened file if the operation is successful; returns -1 and sets errno to a value in the following table if the operation fails.

errno

Description

EINVAL

The last six characters are not XXXXXX.

EEXIST

Failed to create a unique temporary file name.

Other

For details, see open().

See also:

open

mkostemps()

  1. int mkostemps (char*template,int suffixlen,int flags )

Description:

Creates and opens a unique temporary file.

Parameters:

Name

Description

templateIndicates the name of the file to be created.
suffixlenIndicates the length of the placeholder suffix XXXXXX.
flagsIndicates the flag for creating a file.

Returns:

Returns the descriptor of the opened file if the operation is successful; returns -1 and sets errno to a value in the following table if the operation fails.

errno

Description

EINVAL

The template length is less than (6 + suffixlen), or the last six characters of template are not XXXXXX.

EEXIST

Failed to create a unique temporary file name.

Other

For details, see open().

See also:

open

mkstemp()

  1. int mkstemp (char*template)

Description:

Creates and opens a unique temporary file.

Parameters:

Name

Description

templateIndicates the name of the file to be created. The last six characters must be XXXXXX.

Returns:

Returns the descriptor of the opened file if the operation is successful; returns -1 and sets errno to a value in the following table if the operation fails.

errno

Description

EINVAL

The last six characters are not XXXXXX.

EEXIST

Failed to create a unique temporary file name.

Other

For details, see open().

See also:

open

mkstemps()

  1. int mkstemps (char*template,int suffixlen )

Description:

Creates and opens a unique temporary file.

Parameters:

Name

Description

templateIndicates the name of the file to be created.
suffixlenIndicates the length of the placeholder suffix XXXXXX.

Returns:

Returns the descriptor of the opened file if the operation is successful; returns -1 and sets errno to a value in the following table if the operation fails.

errno

Description

EINVAL

The template length is less than (6 + suffixlen), or the last six characters of template are not XXXXXX.

EEXIST

Failed to create a unique temporary file name.

Other

For details, see open().

See also:

open

mktemp()

  1. char* mktemp (char*template)

Description:

Creates a unique temporary file name.

Parameters:

Name

Description

templateIndicates the name of the file to be created. The last six characters are XXXXXX.

Returns:

Returns the pointer to the created file name if the operation is successful; returns NULL and sets errno to a value in the following table if the operation fails.

errno

Description

EINVAL

The last six characters are not XXXXXX.

ENOENT

The file name already exists.

mrand48()

  1. long mrand48 (void)

Description:

Generates pseudo-random numbers evenly distributed between [-2^31, 2^31).

Attention:

This function works by generating a 48-bit integer sequence, and X(i+1) must be generated by using the value of Xi. The correlation is obtained by using a linear congruential formula, Xn+1 = (aXn + c) mod m, where n = 0, m = 2^48, a = 0x5DEECE66D, and c = 0xB. Before this function is called, one of the functions srand48(), seed48(), and lcong48() must be used to initialize Xi.

Returns:

Returns signed long integers evenly distributed between [-2^31, 2^31) if the operation is successful.

nrand48()

  1. longint nrand48 (unsignedshort xsubi[3])

Description:

Generates pseudo-random numbers evenly distributed between [0, 2^31).

Parameters:

Name

Description

xsubi[3]Indicates the array of the initialized value of Xi.

Attention:

This function works by generating a 48-bit integer sequence, and X(i+1) must be generated by using the value of Xi. The correlation is obtained by using a linear congruential formula, Xn+1 = (aXn + c) mod m, where n = 0, m = 2^48, a = 0x5DEECE66D, and c = 0xB. Xi is specified by xsubi[3].

Returns:

Returns nonnegative long integers evenly distributed between [0, 2^31) if the operation is successful.

pathconf()

  1. long pathconf (constchar* path,int name )

Description:

Obtains the configuration value of a file.

Parameters:

Name

Description

pathIndicates the file path.
nameIndicates the name of the configuration value.

Returns:

Returns the actual value of the configuration file if the operation is successful; returns -1 and sets errno to a value in the following table if the operation fails.

errno

Description

EINVAL

The value of name does not match any existing configuration option.

pause()

  1. int pause (void)

Description:

Waits for signal.

This function is used to stop the current process or thread until a signal is delivered.

Returns:

Returns when a signal was caught and returns -1 and sets errno to EINTR.

errno

Description

EINTR

A signal was caught during execution.

pipe()

  1. int pipe (int pipefd[2])

Description:

Creates an anonymous pipe.

Parameters:

Name

Description

pipefdIndicates the pointer to the buffer for storing the created pipe descriptor. The buffer has two sizes of the int type, one for the read-end descriptor and the other for the write-end descriptor.

Attention:

A maximum of 32 anonymous pipes can be created, and the internal buffer of a pipe is 1023 bytes.

Returns:

Returns 0 if the creation is successful; returns -1 and sets errno to a value in the following table if the creation fails.

errno

Description

EFAULT

pipefd is invalid.

ENOMEM

Creation failed due to insufficient space.

ENFILE

Failed to create an anonymous pipe because the number of anonymous pipes has reached the upper limit.

posix_memalign()

  1. int posix_memalign (void** memptr,size_t alignment,size_t size )

Description:

Allocates memory with the specified size based on the given alignment.

The value of alignment must be a power of 2 and a multiple of sizeof(void *). The allocated memory address is stored in *memptr. If size is 0, *memptr is either NULL or a unique pointer value that can later be successfully passed to free().

Parameters:

Name

Description

memptrIndicates the double pointer to the allocated memory block.
alignmentIndicates the alignment size of the allocated memory block.
sizeIndicates the size of the memory block to be allocated.

Returns:

Returns 0 if the operation is successful; returns an error code if the operation fails.

errno

Description

EINVAL

The value of alignment is not a power of 2, or is not a multiple of sizeof(void *).

ENOMEM

Insufficient memory.

pread()

  1. ssize_t pread (int fd,void* buf,size_t count,off_t offset )

Description:

Reads data whose offset is offset and length is count from fd to the buffer.

Parameters:

Name

Description

fdIndicates the file descriptor to read.
bufIndicates the pointer to the buffer for storing data.
countIndicates the length of the data to read.
offsetIndicates the offset of the file descriptor to read.

Attention:

The fd offset does not change after the function is called. This function is helpful in multithreaded applications. They allow multiple threads to execute the I/O on the same file descriptor without being affected by changes in other file offsets. It is not an error if the number of transferred bytes is less than the number of requested bytes after the function is called.

Returns:

Returns the number of records read if the operation is successful; returns -1 and sets errno to a value if the operation fails.

ptsname()

  1. char* ptsname (int fd)

Description:

Obtains the name of a pseudo terminal.

Parameters:

Name

Description

fdIndicates the terminal descriptor.

Returns:

Returns the pointer to the name if the operation is successful; returns -1 and sets errno to a value in the following table if the operation fails.

errno

Description

ERANGE

fd is too long.

putenv()

  1. int putenv (char* s)

Description:

Configures an environment variable.

Parameters:

Name

Description

sIndicates the content of the environment variable to configure.

Returns:

Returns 0 if the operation is successful; returns -1 otherwise.

putwc()

  1. wint_t putwc (wchar_t wc,[FILE]($api-api-SmartVision-Devices-IO.md#ga912af5ab9f8a52ddd387b7defc0b49f1) * stream )

Description:

Writes a wide character wc to a specified file stream.

Parameters:

Name

Description

wcIndicates the wide character to write.
streamIndicates the pointer to the file object that identifies a stream.

Attention:

This function is similar to fputwc only except that it is implemented as a macro.

Returns:

Returns the wide character if the operation is successful; returns WEOF otherwise.

putwchar()

  1. wint_t putwchar (wchar_t wc)

Description:

Writes a wide character wc to the stdout.

Parameters:

Name

Description

wcIndicates the wide character to write.

Returns:

Returns the wide character if the operation is successful; returns WEOF otherwise.

pwrite()

  1. ssize_t pwrite (int fd,constvoid* buf,size_t count,off_t offset )

Description:

Writes data from the buffer to fd whose offset is offset and length is count.

Parameters:

Name

Description

fdIndicates the file descriptor to write.
bufIndicates the pointer to the buffer to which data is written.
countIndicates the size of the data to write.
offsetIndicates the offset of the file to write.

Attention:

The fd offset does not change after the function is called. This function is helpful in multithreaded applications. They allow multiple threads to execute the I/O on the same file descriptor without being affected by changes in other file offsets. It is not an error if the number of transferred bytes is less than the number of requested bytes after the function is called. For details, see write().

Returns:

Returns the number of records written if the operation is successful; returns -1 and sets errno to a value if the operation fails. Global variables of the int type can be directly obtained.

qsort()

  1. void qsort (constvoid*base,size_t nel,size_t width,int(*)(constvoid*,constvoid*) compar )

Description:

Sorts array elements base[0] to base[num-1] based on the comparison rules of compar.

Parameters:

Name

Description

baseIndicates the array to be sorted.
nelIndicates the number of elements in the array to be searched.
widthIndicates the length of each element, in bytes.
compareIndicates the pointer to the comparison subfunction used to define comparison rules.

rand()

  1. int rand (void)

Description:

Generates a pseudo-random number.

The random number ranges from 0 to RAND_MAX.

Attention:

RAND_MAX is defined in this header file. This function is implemented using the linear congruence method. If the random number seed does not change, the generated random number complies with the normal distribution. The generated random number is not a real random number but a pseudo-random number. Therefore, you need to use the srand() function to initialize the random number seed to the unique values.

Returns:

Returns a non-negative integer that is evenly distributed in the interval [0, RAND_MAX] if the operation is successful.

rand_r()

  1. int rand_r (unsigned* seedp)

Description:

Generates a pseudo-random number.

The random number ranges from 0 to RAND_MAX.

Parameters:

Name

Description

seedpIndicates the random number seed.

Attention:

This function is implemented using the linear congruence method. If the random number seed does not change, the generated random number complies with the normal distribution. The generated random number is not a real random number but a pseudo-random number. Therefore, you need to use srand to initialize the random number seed to the unique values.

Returns:

Returns a non-negative integer that is evenly distributed in the interval [0, RAND_MAX] if the operation is successful.

random()

  1. longint random (void)

Description:

Generates a pseudo-random number.

Attention:

Generally, srandom() is called before this function to generate a random number seed. If srandom() is not called or srandom(0) is used to generate a random number seed, the random number seed generated by srandom(1) is used.

read()

  1. ssize_t read (int fd,void* buf,size_t size )

Description:

Reads the file contents and saves them in a specified buffer location.

Parameters:

Name

Description

fdIndicates the descriptor of the file to read.
bufIndicates the pointer to the buffer for storing the data read.
sizeIndicates the length of the content to read. If the length exceeds that of the buffer, memory corruption may occur.

Returns:

Returns the number of bytes read if the operation is successful; returns -1 and sets errno to a value in the following table if the operation fails.

errno

Description

EBADF

fd is invalid.

EACCES

The file cannot be read.

EFAULT

buf is set to NULL.

ENOMEM

Insufficient memory.

realloc()

  1. void* realloc (void* ptr,size_t size )

Description:

Changes the size of the memory block pointed to by ptr to size bytes.

The contents will remain unchanged in the range from the start of ptr to the minimum of the old and new sizes. If the new size is larger than the old size, the added memory will not be initialized. If ptr is NULL, this function call is equivalent to malloc(size); if size is equal to 0 and ptr is not NULL, the function call is equivalent to free(ptr). If ptr is not NULL, it must be the returned value of malloc(), calloc(), or realloc. If the memory block pointed to by ptr has been moved, free(ptr) is executed.

Parameters:

Name

Description

ptrIndicates the pointer to the memory block to be adjusted.
sizeIndicates the new size of the memory block.

Returns:

Returns the pointer to the new memory block if the operation is successful; returns NULL and sets errno to a value in the following table if the operation fails.

errno

Description

ENOMEM

Insufficient memory.

realpath()

  1. char* realpath (constchar*__restrict path,char*__restrict resolved )

Description:

Obtains a normalized absolute path.

Parameters:

Name

Description

pathIndicates the name of the absolute path to be obtained.
resolvedIndicates the pointer to the obtained absolute path.

Returns:

Returns the pointer to resolved_path if the operation is successful; returns NULL and sets errno to a value in the following table if the operation fails.

errno

Description

EACCES

Read or search permission is denied on a component of the path prefix.

EINVAL

path is NULL.

EIO

An I/O error occurred while reading from the file system.

ELOOP

Too many symbolic links are encountered when the path name is parsed.

ENAMETOOLONG

The path name is too long.

ENOMEM

Insufficient memory.

ENOENT

The file does not exist.

ENOTDIR

The component of the path prefix is not a directory.

remque()

  1. void remque (void* elem)

Description:

Removes an entry from a queue.

Parameters:

Name

Description

elementIndicates the element to be removed from the queue.

rindex()

  1. char* rindex (constchar* s,int c )

Description:

Searches for the last position of the matched character in a string.

Parameters:

Name

Description

sIndicates the pointer to the string to be searched.
cIndicates the character to be matched.

Returns:

Returns the pointer to the matched character if the operation is successful; returns NULL if the operation fails.

rmdir()

  1. int rmdir (constchar* path)

Description:

Deletes a directory.

Parameters:

Name

Description

pathIndicates the name of the directory to be deleted.

Attention:

This function can NOT be used in the PROC file system.

Returns:

Returns 0 if the operation is successful; returns -1 and sets errno to a value in the following table if the operation fails.

errno

Description

EINVAL

path is a null pointer or an empty string.

ENAMETOOLONG

The length of the path name is greater than PATH_MAX.

ENOMEM

Insufficient memory.

ENOENT

The directory does not exist.

EPERM

The path is a mount point, or it is neither a directory nor a file.

ENOSYS

The operation is not supported.

ENOTEMPTY

The directory is not empty.

ENOTDIR

The specified path is not a directory.

ENXIO

No such device or address.

sbrk()

  1. void* sbrk (intptr_t increment)

Description:

Adjusts the heap size of a process.

Parameters:

Name

Description

incrementIndicates the size of the memory space to obtain.

Returns:

Returns the pointer to the memory space if the operation is successful; returns -1 and sets errno to a value in the following table if the operation fails.

errno

Description

ENOMEM

Insufficient memory.

secure_getenv()

  1. char* secure_getenv (constchar* name)

Description:

Obtains the value of an environment variable.

The feature of this function is the same as that of getenv() during non-secure execution.

Parameters:

Name

Description

nameIndicates the pointer to the name of the environment variable whose value needs to be obtained.

Returns:

Returns the pointer to the environment variable value if the operation is successful; returns NULL if there is no match.

seed48()

  1. unsignedshort* seed48 (unsignedshort[3])

Description:

Generates an evenly distributed pseudo-random seed.

Parameters:

Name

Description

seed16vIndicates the 48-bit seed.

Attention:

This function is an initialization function and can be called before calling drand48, lrand48, or mrand48.

Returns:

Returns the pointer to the pseudo-random seed.

setegid()

  1. int setegid (gid_t egid)

Description:

Sets the effective user group ID of the calling process.

Parameters:

Name

Description

egidIndicates the effective user group ID to set.

Attention:

The real user group ID is the same as the effective user group ID and saved user group ID.

Returns:

Returns 0 if the operation is successful; returns -1 and sets errno to a value in the following table if the operation fails.

errno

Description

EINVAL

egid is invalid.

EPERM

No setting permission.

setenv()

  1. int setenv (constchar* name,constchar* value,int overwrite )

Description:

Add or change an environment variable.

This function adds the varible name to environment with string value if name is not exist.

Parameters:

Name

Description

nameIndicates the name of environment variable.
valueIndicates the value of environment variable.
overwriteIf the varible name does exit and the value overwrite is nonzero, then value of name will be change to new value; if overwrite is zero, then the value of name remains unchanged.

Returns:

Returns 0 if the operation is successful; returns -1 and sets errno to a value in the following table if the operation fails

errno

Description

EINVAL

The name is NULL, or its length is zero, or contains an “=” character.

ENOMEM

Insufficient memory.

seteuid()

  1. int seteuid (uid_t euid)

Description:

Sets the effective user ID of the calling process.

Parameters:

Name

Description

euidIndicates the effective user ID to set.

Attention:

The real user ID is the same as the effective user ID and saved user ID.

Returns:

Returns 0 if the operation is successful; returns -1 and sets errno to a value in the following table if the operation fails.

errno

Description

EINVAL

euid is invalid.

EPERM

No setting permission.

setgid()

  1. int setgid (gid_t gid)

Description:

Sets the user group ID of the calling process.

Parameters:

Name

Description

gidIndicates the user group ID to set.

Attention:

The real user group ID is the same as the effective user group ID and saved user group ID.

Returns:

Returns 0 if the operation is successful; returns -1 and sets errno to a value in the following table if the operation fails.

errno

Description

EINVAL

gid is invalid.

EPERM

No setting permission.

setgroups()

  1. int setgroups (size_t size,constgid_t* list )

Description:

Sets the supplementary user group list of the calling process.

Parameters:

Name

Description

sizeIndicates the maximum size of the supplementary user group list. If the value is 0, the list is cleared. The maximum value is 255.
listIndicates the target supplementary group list.

Returns:

Returns 0 if the operation is successful; returns -1 and sets errno to a value in the following table if the operation fails.

errno

Description

EINVAL

size is invalid.

EFAULT

Invalid address.

ENOMEM

Insufficient memory.

setpgid()

  1. int setpgid (pid_t pid,pid_t pgid )

Description:

Sets the ID of the process group whose process ID is specified by pid.

Parameters:

Name

Description

pidIndicates the process ID. If the value is 0, the process group ID of the current process is obtained.
pgidIndicates the process group ID.

Returns:

Returns 0 if the operation is successful; returns -1 and sets errno to a value in the following table if the operation fails.

errno

Description

EINVAL

Invalid process ID.

ESRCH

The specified process cannot be found.

EPERM

No permission to operate the process group.

EACCES

The child process has performed exec, and the parent process does not have the operation permission.

setpgrp()

  1. pid_t setpgrp (void)

Description:

Sets the process group ID of the calling process.

Returns:

Returns 0 if the operation is successful; returns -1 and sets errno to a value if the operation fails.

setregid()

  1. int setregid (gid_t rgid,gid_t egid )

Description:

Sets the real and effective user group IDs of the calling process.

Parameters:

Name

Description

rgidIndicates the real user group ID to set. If the value is -1, the real user group ID is left unchanged.
egidIndicates the effective user group ID to set. If the value is -1, the effective user group ID is left unchanged.

Attention:

The real user group ID is the same as the effective user group ID and saved user group ID.

Returns:

Returns 0 if the operation is successful; returns -1 and sets errno to a value in the following table if the operation fails.

errno

Description

EINVAL

rgid or egid is invalid.

EPERM

No setting permission.

setresgid()

  1. int setresgid (gid_t rgid,gid_t egid,gid_t sgid )

Description:

Sets the real, effective, and saved group IDs of the calling process.

Parameters:

Name

Description

rgidIndicates the real user group ID to set. If the value is -1, the real user group ID is left unchanged.
egidIndicates the effective user group ID to set. If the value is -1, the effective user group ID is left unchanged.
sgidIndicates the saved group ID to set. If the value is -1, the saved user group ID is left unchanged.

Attention:

The real user group ID is the same as the effective user group ID and saved user group ID.

Returns:

Returns 0 if the operation is successful; returns -1 and sets errno to a value in the following table if the operation fails.

errno

Description

EINVAL

rgid, egid, or sgid is invalid.

EPERM

No setting permission.

setresuid()

  1. int setresuid (uid_t ruid,uid_t euid,uid_t suid )

Description:

Sets the real, effective, and saved user IDs of the calling process.

Parameters:

Name

Description

ruidIndicates the real user ID to set. If the value is -1, the real user ID is left unchanged.
euidIndicates the effective user ID to set. If the value is -1, the effective user ID is left unchanged.
suidIndicates the saved user ID to set. If the value is -1, the saved user ID is left unchanged.

Attention:

The real user ID is the same as the effective user ID and saved user ID.

Returns:

Returns 0 if the operation is successful; returns -1 and sets errno to a value in the following table if the operation fails.

errno

Description

EINVAL

ruid, euid, or suid is invalid.

EPERM

No setting permission.

setreuid()

  1. int setreuid (uid_t ruid,uid_t euid )

Description:

Sets the real and effective user IDs of the calling process.

Parameters:

Name

Description

ruidIndicates the real user ID to set. If the value is -1, the real user ID is left unchanged.
euidIndicates the effective user ID to set. If the value is -1, the effective user ID is left unchanged.

Attention:

The real user ID is the same as the effective user ID and saved user ID.

Returns:

Returns 0 if the operation is successful; returns -1 and sets errno to a value in the following table if the operation fails.

errno

Description

EINVAL

ruid or euid is invalid.

EPERM

No setting permission.

setstate()

  1. char* setstate (char* state)

Description:

Sets the current state list for subsequent random use.

Parameters:

Name

Description

stateIndicates the pointer to the state list.

Returns:

Returns the pointer to the current state list if the operation is successful; returns NULL if the operation fails. errno is set to EINVAL if state is empty or the size of the state list is less than 8 bytes.

setuid()

  1. int setuid (uid_t uid)

Description:

Sets the real user ID for the calling process.

Parameters:

Name

Description

uidIndicates the user ID to set.

Attention:

The real user ID is the same as the effective user ID and saved user ID.

Returns:

Returns 0 if the operation is successful; returns -1 and sets errno to a value in the following table if the operation fails.

errno

Description

EINVAL

uid is invalid.

EPERM

No setting permission.

sleep()

  1. unsigned sleep (unsigned seconds)

Description:

Sleeps for a period of time.

This function is used to stop the current thread until the specified time. A sleeping thread cannot be woken up by a signal.

Parameters:

Name

Description

secondsIndicates the sleeping seconds.

Returns:

Returns the seconds if the operation is successful; returns 0 and sets errno to a value in the following table if the operation fails.

errno

Description

EINVAL

Incorrect input.

srand()

  1. void srand (unsignedint seed)

Description:

Initializes a random number generator.

Parameters:

Name

Description

seedIndicates the seed for generating a pseudo-random number.

Attention:

If seed is 0, this function is equivalent to srand(1). Before the rand() function is executed, this function is used to initialize different algorithm seeds to generate true random numbers.

srand48()

  1. void srand48 (longint seedval)

Description:

Sets the start seed value for the pseudo-random number generator.

Parameters:

Name

Description

seedvalIndicates the 48-bit start seed value.

Attention:

This function sets the high order 32 bits of Xi to seedval. The lower order 16 bits are set to 0x330E.

srandom()

  1. void srandom (unsignedint seed)

Description:

Initializes a random number generator.

Parameters:

Name

Description

seedIndicates the seed for generating a pseudo-random number.

stpcpy()

  1. char* stpcpy (char* dest,constchar* src )

Description:

Copies a string.

This function copies the source string to the destination string and returns the pointer to the terminating null byte \0 of the destination string.

Parameters:

Name

Description

destIndicates the pointer to the destination string.
srcIndicates the pointer to the source string.

Attention:

The null byte \0 in the source string is also copied to the destination string. The two strings cannot overlap. The destination string must be large enough to receive the copied string. You should be aware of a buffer overflow.

Returns:

Returns the pointer to the terminating null byte \0 of the destination string.

stpncpy()

  1. char* stpncpy (char* dest,constchar* src,size_t n )

Description:

Copies n characters of a string.

This function copies n characters of the source string to the destination string and returns the pointer to the terminating null byte \0 of the destination string.

Parameters:

Name

Description

destIndicates the pointer to the destination string.
srcIndicates the pointer to the source string.
nIndicates the number of characters to be copied.

Attention:

The null byte \0 in the source string is also copied to the destination string. The two strings cannot overlap. The destination string must be large enough to receive the copied string. You should be aware of a buffer overflow. If the length of the source string is less than n, this function copies the null byte \0 to the destination string.

Returns:

Returns the pointer to the terminating null byte \0 of the destination string if the operation is successful; returns the pointer to the (dest+n) position if the destination string does not end with \0.

strcasecmp()

  1. int strcasecmp (constchar* _l,constchar* _r )

Description:

Compares two strings (string 1 and string 2), regardless of the letter case.

Parameters:

Name

Description

_lIndicates the pointer to string 1 for comparison.
_rIndicates the pointer to string 2 for comparison.

Returns:

Returns 0 if the two strings are equal; returns a value greater than 0 if _l is greater than _r; returns a value less than 0 if _l is less than _r.

strcasestr()

  1. char* strcasestr (constchar* haystack,constchar* needle )

Description:

Searches for a needle string in its haystack string and returns a pointer.

Parameters:

Name

Description

haystackIndicates the pointer to the haystack string.
needleIndicates the pointer to the needle string.

Attention:

The case difference is ignored during comparison.

Returns:

Returns the pointer to the beginning of the first needle string found in the haystack string if the operation is successful; returns NULL if the needle string is not found in the haystack string.

strcat()

  1. char* strcat (char* dest,constchar* src )

Description:

Appends a string to another one.

This function appends the source string to the destination string.

Parameters:

Name

Description

destIndicates the pointer to the destination string.
srcIndicates the pointer to the source string.

Attention:

The null byte \0 of the destination string will be overwritten by the first byte of the source string. The destination string must have enough space for data storage. Otherwise, a buffer overflow may occur. If the destination string is not large enough, the program behavior will be unpredictable, and buffer overflows are the favorite choice for attacking secure programs.

Returns:

Returns the pointer to the destination string.

strchr()

  1. char* strchr (constchar* s,int c )

Description:

Locates the first occurrence of a character in a string.

Parameters:

Name

Description

sIndicates the pointer to the string to be searched.
cIndicates the character to be searched for.

Returns:

Returns the pointer to the position that the character appears for the first time in the string if the operation is successful; returns NULL if the character is not found in the string.

strcmp()

  1. int strcmp (constchar* s1,constchar* s2 )

Description:

Compares two strings by characters.

Parameters:

Name

Description

s1Indicates the pointer to string 1 for comparison.
s2Indicates the pointer to string 2 for comparison.