xref: /haiku/headers/posix/string.h (revision 23d878482ed22e55dad6d1fca1df7bea42eb157c)
1 /*
2  * Copyright 2004-2010 Haiku Inc. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _STRING_H_
6 #define _STRING_H_
7 
8 
9 #include <sys/types.h>
10 
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 
17 /* memXXX() functions */
18 extern void		*memchr(const void *source, int value, size_t length);
19 extern int		memcmp(const void *buffer1, const void *buffer2, size_t length);
20 extern void		*memcpy(void *dest, const void *source, size_t length);
21 extern void		*memccpy(void *dest, const void *source, int stopByte, size_t length);
22 extern void		*memmove(void *dest, const void *source, size_t length);
23 extern void		*memset(void *dest, int value, size_t length);
24 
25 #ifdef __USE_GNU
26 extern void		*memrchr(const void *source, int value, size_t length);
27 #endif
28 
29 /* string functions */
30 extern char		*strcpy(char *dest, const char *source);
31 extern char		*strncpy(char *dest, const char *source, size_t length);
32 extern char		*strcat(char *dest, const char *source);
33 extern char		*strncat(char *dest, const char *source, size_t length);
34 
35 extern size_t	strlen(const char *string);
36 extern int		strcmp(const char *string1, const char *string2);
37 extern int		strncmp(const char *string1, const char *string2, size_t length);
38 
39 extern char		*strchr(const char *string, int character);
40 extern char		*strrchr(const char *string, int character);
41 extern char		*strstr(const char *string, const char *searchString);
42 
43 #ifdef __USE_GNU
44 extern char		*strchrnul(const char *string, int character);
45 #endif
46 
47 extern char		*strpbrk(const char *string, const char *set);
48 extern char		*strtok(char *string, const char *set);
49 extern char		*strtok_r(char *string, const char *set, char **savePointer);
50 extern size_t	strspn(const char *string, const char *set);
51 extern size_t	strcspn(const char *string, const char *set);
52 
53 extern int		strcoll(const char *string1, const char *string2);
54 extern size_t	strxfrm(char *string1, const char *string2, size_t length);
55 
56 extern char		*strerror(int errorCode);
57 extern int		strerror_r(int errorCode, char *buffer, size_t bufferSize);
58 
59 /* non-standard string functions */
60 extern int		strcasecmp(const char *string1, const char *string2);
61 extern int		strncasecmp(const char *string1, const char *string2, size_t length);
62 
63 extern char		*strcasestr(const char *string, const char *searchString);
64 
65 extern char		*strdup(const char *string);
66 extern char		*strndup(const char* string, size_t size);
67 extern char		*stpcpy(char *dest, const char *source);
68 
69 extern size_t	strlcat(char *dest, const char *source, size_t length);
70 extern size_t	strlcpy(char *dest, const char *source, size_t length);
71 
72 extern size_t	strnlen(const char *string, size_t count);
73 
74 extern char		*strlwr(char *string);
75 extern char		*strupr(char *string);
76 
77 /* extern char		*strsep(char **stringPointer, const char *delimiter); */
78 
79 extern const char	*strsignal(int signal);
80 
81 /* legacy compatibility -- might be removed one day */
82 #define bcmp(a, b, length) memcmp((a), (b), (length))
83 #define bcopy(source, dest, length) memmove((dest), (source), (length))
84 #define bzero(buffer, length) memset((buffer), 0, (length))
85 
86 extern int ffs(int i);
87 extern char 		*index(const char *s, int c);
88 extern char 		*rindex(char const *s, int c);
89 
90 #ifdef __cplusplus
91 }
92 #endif
93 
94 #endif  /* _STRING_H_ */
95