2023-07-22 09:58:28 +00:00
|
|
|
/* string.h: String and memory 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
|
|
|
|
2023-07-10 13:30:05 +00:00
|
|
|
/* Find the character c in n bytes of memory.*/
|
|
|
|
void* memchr(const void* buf, int c, 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
|
|
|
|
2023-03-12 14:20:44 +00:00
|
|
|
/* Compare two fixed-size null-terminated strings. */
|
|
|
|
int strncmp(const char* a, const char* b, size_t max);
|
|
|
|
|
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
|
|
|
|
2023-03-12 14:20:44 +00:00
|
|
|
/* Copy the fixed-size null-terminated string src into dest. */
|
|
|
|
char* strncpy(char* dest, const char* src, size_t max);
|
|
|
|
|
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
|
|
|
|
2023-03-12 14:20:44 +00:00
|
|
|
/* Concatenate the fixed-size null-terminated string src onto dest. */
|
|
|
|
char* strncat(char* dest, const char* src, size_t max);
|
|
|
|
|
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-07-10 19:39:22 +00:00
|
|
|
/* Return the human-readable description of a signal number. */
|
|
|
|
char* strsignal(int signo);
|
|
|
|
|
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
|
|
|
|
2023-04-12 16:42:25 +00:00
|
|
|
/* Return a pointer to the first occurrence of any of the characters in accept in s. */
|
|
|
|
char* strpbrk(const char* s, const char* delim);
|
|
|
|
|
2023-03-12 09:39:38 +00:00
|
|
|
/* Separate a string into several tokens. */
|
|
|
|
char* strtok(char* str, const char* delim);
|
|
|
|
|
2023-05-20 14:37:07 +00:00
|
|
|
/* Separate a string into several tokens. */
|
|
|
|
char* strtok_r(char* str, const char* delim, char** savep);
|
|
|
|
|
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-07-10 13:30:05 +00:00
|
|
|
/* Locate a string (needle) in another one (haystack). */
|
|
|
|
char* strstr(const char* haystack, const char* needle);
|
|
|
|
|
2023-07-22 09:58:28 +00:00
|
|
|
/* Compare two null-terminated strings, ignoring case. */
|
|
|
|
int strcasecmp(const char* a, const char* b);
|
|
|
|
|
|
|
|
/* Compare two fixed-size null-terminated strings, ignoring case. */
|
|
|
|
int strncasecmp(const char* a, const char* b, size_t max);
|
|
|
|
|
2023-08-08 12:40:14 +00:00
|
|
|
/* Compare two null-terminated strings according to the current locale. */
|
|
|
|
int strcoll(const char* a, const char* b);
|
|
|
|
|
2023-08-08 20:06:11 +00:00
|
|
|
/* Transform a string according to the current locale. */
|
|
|
|
size_t strxfrm(char* dest, const char* src, size_t n);
|
|
|
|
|
2023-01-06 16:35:07 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|