#ifndef _STRING_H #define _STRING_H #include #include #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 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 the string src into dest. This function is unsafe, use strncpy instead. */ __lc_deprecated("strcpy is unsafe and should not be used; use strncpy instead") char* strcpy(char* dest, const char* src); /* 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); /* 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); /* Concatenates at most max bytes of the string src into dest. */ char* strncat(char* dest, const char* src, size_t max); /* 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); /* 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); /* Clears n bytes of buf. */ void* bzero(void* buf, size_t n); #ifdef __cplusplus } #endif #endif