summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibC/string.h
blob: c3681c89ca66abe4daa1c89449f27b5f132869dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
 * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
 * Copyright (c) 2021-2022, Brian Gianforcaro <bgianf@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <sys/cdefs.h>
#include <sys/types.h>

__BEGIN_DECLS

// A few C Standard Libraries include this header in <string.h>, and hence expect
// `strcasecmp` etcetera to be available as part of a <string.h> include, so let's
// do the same here to maintain compatibility
#include <strings.h>

size_t strlen(char const*);
size_t strnlen(char const*, size_t maxlen);

int strcmp(char const*, char const*);
int strncmp(char const*, char const*, size_t);

int memcmp(void const*, void const*, size_t);
int timingsafe_memcmp(void const*, void const*, size_t);
void* memcpy(void*, void const*, size_t);
void* memmove(void*, void const*, size_t);
void* memchr(void const*, int c, size_t);
void const* memmem(void const* haystack, size_t, void const* needle, size_t);

void* memset(void*, int, size_t);
void explicit_bzero(void*, size_t) __attribute__((nonnull(1)));

__attribute__((malloc)) char* strdup(char const*);
__attribute__((malloc)) char* strndup(char const*, size_t);

char* strcpy(char* dest, char const* src);
char* strncpy(char* dest, char const* src, size_t);
__attribute__((warn_unused_result)) size_t strlcpy(char* dest, char const* src, size_t);

char* strchr(char const*, int c);
char* strchrnul(char const*, int c);
char* strstr(char const* haystack, char const* needle);
char* strrchr(char const*, int c);

char* index(char const* str, int ch);
char* rindex(char const* str, int ch);

char* strcat(char* dest, char const* src);
char* strncat(char* dest, char const* src, size_t);

size_t strspn(char const*, char const* accept);
size_t strcspn(char const*, char const* reject);
int strerror_r(int, char*, size_t);
char* strerror(int errnum);
char* strsignal(int signum);
char* strpbrk(char const*, char const* accept);
char* strtok_r(char* str, char const* delim, char** saved_str);
char* strtok(char* str, char const* delim);
int strcoll(char const* s1, char const* s2);
size_t strxfrm(char* dest, char const* src, size_t n);
char* strsep(char** str, char const* delim);

__END_DECLS