2023-01-07 10:39:15 +00:00
|
|
|
/* string.h: String manipulation. */
|
2023-01-06 19:02:07 +00:00
|
|
|
|
2023-01-06 16:35:07 +00:00
|
|
|
#ifndef _STRING_H
|
|
|
|
#define _STRING_H
|
|
|
|
|
|
|
|
#include <bits/attrs.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#endif
|
|
|
|
|
2023-01-06 19:02:07 +00:00
|
|
|
/* Copy n bytes of memory from src to dest. */
|
2023-01-06 16:35:07 +00:00
|
|
|
void* memcpy(void* dest, const void* src, size_t n);
|
2023-01-06 19:02:07 +00:00
|
|
|
|
|
|
|
/* Set n bytes of memory to the character c. */
|
2023-01-06 16:35:07 +00:00
|
|
|
void* memset(void* buf, int c, size_t n);
|
2023-01-06 19:02:07 +00:00
|
|
|
|
|
|
|
/* Compare n bytes of two memory locations. */
|
2023-01-06 16:35:07 +00:00
|
|
|
int memcmp(const void* a, const void* b, size_t n);
|
2023-01-06 19:02:07 +00:00
|
|
|
|
|
|
|
/* Copy n bytes of memory from src to dest, where src and dest may overlap. */
|
2023-01-06 16:35:07 +00:00
|
|
|
void* memmove(void* dest, const void* src, size_t n);
|
2023-01-06 19:02:07 +00:00
|
|
|
|
|
|
|
/* Return the length of a null-terminated string. */
|
2023-01-06 16:35:07 +00:00
|
|
|
size_t strlen(const char* str);
|
|
|
|
|
2023-03-12 10:10:18 +00:00
|
|
|
/* Return the length of a fixed-size null-terminated string. */
|
|
|
|
size_t strnlen(const char* str, size_t max);
|
|
|
|
|
2023-01-06 19:02:07 +00:00
|
|
|
/* Compare two null-terminated strings. */
|
2023-01-06 16:35:07 +00:00
|
|
|
int strcmp(const char* a, const char* b);
|
2023-01-06 19:02:07 +00:00
|
|
|
|
|
|
|
/* Copy the null-terminated string src into dest. Should be avoided to prevent buffer overflow attacks. */
|
2023-01-06 16:35:07 +00:00
|
|
|
__deprecated char* strcpy(char* dest, const char* src);
|
2023-01-06 19:02:07 +00:00
|
|
|
|
|
|
|
/* Concatenate the null-terminated string src onto dest. Should be avoided to prevent buffer overflow attacks. */
|
2023-01-06 16:35:07 +00:00
|
|
|
__deprecated char* strcat(char* dest, const char* src);
|
2023-01-06 19:02:07 +00:00
|
|
|
|
|
|
|
/* Return a pointer to the first occurrence of the character c in str, or NULL if it could not be found. */
|
2023-01-06 16:35:07 +00:00
|
|
|
char* strchr(const char* str, int c);
|
|
|
|
|
2023-03-12 09:27:07 +00:00
|
|
|
/* Return a pointer to the last occurrence of the character c in str, or NULL if it could not be found. */
|
|
|
|
char* strrchr(const char* str, int c);
|
|
|
|
|
2023-01-06 19:02:07 +00:00
|
|
|
/* Return a heap-allocated copy of a string. */
|
2023-01-06 16:35:07 +00:00
|
|
|
char* strdup(const char* str);
|
|
|
|
|
2023-01-06 19:02:07 +00:00
|
|
|
/* Return the human-readable description of an error number. */
|
2023-01-06 16:35:07 +00:00
|
|
|
char* strerror(int errnum);
|
|
|
|
|
2023-03-12 09:39:38 +00:00
|
|
|
/* Return the length of the initial segment of str which consists only of bytes in accept. */
|
2023-03-12 09:43:13 +00:00
|
|
|
size_t strspn(const char* str, const char* accept);
|
2023-03-12 09:39:38 +00:00
|
|
|
|
|
|
|
/* Return the length of the initial segment of str which consists only of bytes not in reject. */
|
2023-03-12 09:43:13 +00:00
|
|
|
size_t strcspn(const char* str, const char* reject);
|
2023-03-12 09:39:38 +00:00
|
|
|
|
|
|
|
/* Separate a string into several tokens. */
|
|
|
|
char* strtok(char* str, const char* delim);
|
|
|
|
|
2023-03-12 10:10:18 +00:00
|
|
|
/* Return a heap-allocated copy of a fixed-size string. */
|
|
|
|
char* strndup(const char* str, size_t max);
|
|
|
|
|
|
|
|
/* Copy up to max bytes of src into dest, adding a null terminator at the end. */
|
|
|
|
size_t strlcpy(char* dest, const char* src, size_t max);
|
|
|
|
|
2023-01-06 16:35:07 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|