Luna/libc/include/string.h

106 lines
3.8 KiB
C
Raw Normal View History

/* string.h: String and memory manipulation. */
#ifndef _STRING_H
#define _STRING_H
#include <bits/attrs.h>
#include <sys/types.h>
#ifdef __cplusplus
extern "C"
{
#endif
/* Copy n bytes of memory from src to dest. */
void* memcpy(void* dest, const void* src, size_t n);
/* Set n bytes of memory to the character c. */
void* memset(void* buf, int c, size_t n);
/* Compare n bytes of two memory locations. */
int memcmp(const void* a, const void* b, size_t n);
/* Copy n bytes of memory from src to dest, where src and dest may overlap. */
void* memmove(void* dest, const void* src, size_t n);
/* Find the character c in n bytes of memory.*/
void* memchr(const void* buf, int c, size_t n);
/* Return the length of a null-terminated string. */
size_t strlen(const char* str);
/* Return the length of a fixed-size null-terminated string. */
size_t strnlen(const char* str, size_t max);
/* Compare two null-terminated strings. */
int strcmp(const char* a, const char* b);
/* Compare two fixed-size null-terminated strings. */
int strncmp(const char* a, const char* b, size_t max);
/* Copy the null-terminated string src into dest. Should be avoided to prevent buffer overflow attacks. */
__deprecated char* strcpy(char* dest, const char* src);
/* Copy the fixed-size null-terminated string src into dest. */
char* strncpy(char* dest, const char* src, size_t max);
/* Concatenate the null-terminated string src onto dest. Should be avoided to prevent buffer overflow attacks. */
__deprecated char* strcat(char* dest, const char* src);
/* Concatenate the fixed-size null-terminated string src onto dest. */
char* strncat(char* dest, const char* src, size_t max);
/* Return a pointer to the first occurrence of the character c in str, or NULL if it could not be found. */
char* strchr(const char* str, int c);
/* 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);
/* Return a heap-allocated copy of a string. */
char* strdup(const char* str);
/* Return the human-readable description of an error number. */
char* strerror(int errnum);
/* Return the human-readable description of a signal number. */
char* strsignal(int signo);
/* Return the length of the initial segment of str which consists only of bytes in accept. */
size_t strspn(const char* str, const char* accept);
/* Return the length of the initial segment of str which consists only of bytes not in reject. */
size_t strcspn(const char* str, const char* reject);
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);
/* 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);
/* 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);
/* Locate a string (needle) in another one (haystack). */
char* strstr(const char* haystack, const char* needle);
/* 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);
#ifdef __cplusplus
}
#endif
#endif