xref: /haiku/headers/posix/string.h (revision 1c09002cbee8e797a0f8bbfc5678dfadd39ee1a7)
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 /* string functions */
26 extern char		*strcpy(char *dest, const char *source);
27 extern char		*strncpy(char *dest, const char *source, size_t length);
28 extern char		*strcat(char *dest, const char *source);
29 extern char		*strncat(char *dest, const char *source, size_t length);
30 
31 extern size_t	strlen(const char *string);
32 extern int		strcmp(const char *string1, const char *string2);
33 extern int		strncmp(const char *string1, const char *string2, size_t length);
34 
35 extern char		*strchr(const char *string, int character);
36 extern char		*strrchr(const char *string, int character);
37 extern char		*strstr(const char *string, const char *searchString);
38 
39 extern char		*strchrnul(const char *string, int character);
40 	/* this is a GNU extension */
41 
42 extern char		*strpbrk(const char *string, const char *set);
43 extern char		*strtok(char *string, const char *set);
44 extern char		*strtok_r(char *string, const char *set, char **savePointer);
45 extern size_t	strspn(const char *string, const char *set);
46 extern size_t	strcspn(const char *string, const char *set);
47 
48 extern int		strcoll(const char *string1, const char *string2);
49 extern size_t	strxfrm(char *string1, const char *string2, size_t length);
50 
51 extern char		*strerror(int errorCode);
52 extern int		strerror_r(int errorCode, char *buffer, size_t bufferSize);
53 
54 /* non-standard string functions */
55 extern int		strcasecmp(const char *string1, const char *string2);
56 extern int		strncasecmp(const char *string1, const char *string2, size_t length);
57 
58 extern char		*strcasestr(const char *string, const char *searchString);
59 
60 extern char		*strdup(const char *string);
61 extern char		*strndup(const char* string, size_t size);
62 extern char		*stpcpy(char *dest, const char *source);
63 
64 extern size_t	strlcat(char *dest, const char *source, size_t length);
65 extern size_t	strlcpy(char *dest, const char *source, size_t length);
66 
67 extern size_t	strnlen(const char *string, size_t count);
68 
69 extern char		*strlwr(char *string);
70 extern char		*strupr(char *string);
71 
72 /* extern char		*strsep(char **stringPointer, const char *delimiter); */
73 
74 extern const char	*strsignal(int signal);
75 
76 /* legacy compatibility -- might be removed one day */
77 #define bcmp(a, b, length) memcmp((a), (b), (length))
78 #define bcopy(source, dest, length) memmove((dest), (source), (length))
79 #define bzero(buffer, length) memset((buffer), 0, (length))
80 
81 extern int ffs(int i);
82 extern char 		*index(const char *s, int c);
83 extern char 		*rindex(char const *s, int c);
84 
85 #ifdef __cplusplus
86 }
87 #endif
88 
89 #endif  /* _STRING_H_ */
90