Luna/libc/include/string.h

64 lines
2.1 KiB
C
Raw Normal View History

/* string.h: String 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);
/* Return the length of a null-terminated string. */
size_t strlen(const char* str);
/* Compare two null-terminated strings. */
int strcmp(const char* a, const char* b);
/* Copy the null-terminated string src into dest. Should be avoided to prevent buffer overflow attacks. */
__deprecated char* strcpy(char* dest, const char* src);
/* Concatenate the null-terminated string src onto dest. Should be avoided to prevent buffer overflow attacks. */
__deprecated char* strcat(char* dest, const char* src);
/* 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 length of the initial segment of str which consists only of bytes in accept. */
usize strspn(const char* str, const char* accept);
/* Return the length of the initial segment of str which consists only of bytes not in reject. */
usize strcspn(const char* str, const char* reject);
/* Separate a string into several tokens. */
char* strtok(char* str, const char* delim);
#ifdef __cplusplus
}
#endif
#endif