Luna/libs/libc/include/string.h
2022-10-22 21:13:22 +02:00

95 lines
3.8 KiB
C

#ifndef _STRING_H
#define _STRING_H
#include <bits/macros.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C"
{
#endif
/* Copies n bytes from src to dst. */
void* memcpy(void* dest, const void* src, size_t n);
/* Sets n bytes of buf to c, cast to a character. */
void* memset(void* buf, int c, size_t n);
/* Searches for the character c in n bytes of buf. */
void* memchr(const void* buf, int c, size_t n);
/* Compares n bytes of memory at a and b. */
int memcmp(const void* a, const void* b, size_t n);
/* Copies n bytes from src to dst. Can be used if src and dst overlap. */
void* memmove(void* dest, const void* src, size_t n);
/* Returns a heap-allocated copy of the string str. Should be freed when it is not used anymore. */
char* strdup(const char* str);
/* Returns a heap-allocated copy of the string str, copying at maximum max bytes. Should be freed when it is not
* used anymore. */
char* strndup(const char* str, size_t max);
/* Returns the length of the string str. */
size_t strlen(const char* str);
/* Returns the length of the string str, while examining at most max bytes of str. */
size_t strnlen(const char* str, size_t max);
/* Copies at most size-1 bytes from the string src into dest, null-terminating the result. */
size_t strlcpy(char* dst, const char* src, size_t size);
/* Copies at most max bytes from the string src into dest. */
char* strncpy(char* dest, const char* src, size_t max);
/* Returns a pointer to the first occurrence of the character c in str, or NULL if it is not found. */
char* strchr(const char* str, int c);
/* Returns a pointer to the last occurrence of the character c in str, or NULL if it is not found. */
char* strrchr(const char* str, int c);
/* Returns a pointer to the first occurrence of the character c in str, or a pointer to the terminating null byte of
* str if it is not found. */
char* strchrnul(const char* str, int c);
/* Concatenates at most max bytes of the string src into dest. */
char* strncat(char* dest, const char* src, size_t max);
/* Returns the length of the initial segment of str which consists entirely of bytes not in reject. */
size_t strcspn(const char* str, const char* reject);
/* Returns the length of the initial segment of str which consists entirely of bytes in accept. */
size_t strspn(const char* str, const char* accept);
/* Returns a pointer to the first occurrence of any character of b in a. */
char* strpbrk(const char* a, const char* b);
/* Compares strings a and b. You might prefer to use the safer strncmp function. */
int strcmp(const char* a, const char* b);
/* Compares at most max bytes of the strings a and b. */
int strncmp(const char* a, const char* b, size_t max);
/* Compares a and b based on the current locale. */
int strcoll(const char* a, const char* b);
/* Searches for the needle string in the haystack string. */
char* strstr(const char* haystack, const char* needle);
/* Returns the error string associated with the error number err. */
char* strerror(int err);
/* Copies the string src into dest. This function is unsafe, use strlcpy instead. */
__lc_deprecated("strcpy is unsafe and should not be used; use strlcpy instead") char* strcpy(char* dest,
const char* src);
/* Concatenates the string src into dest. This function is unsafe, use strncat instead. */
__lc_deprecated("strcat is unsafe and should not be used; use strncat instead") char* strcat(char* dest,
const char* src);
#ifdef __cplusplus
}
#endif
#endif