1 /**	$MirOS: src/include/string.h,v 1.11 2014/02/09 16:15:32 tg Exp $ */
2 /*	$OpenBSD: string.h,v 1.15 2005/03/30 03:04:16 deraadt Exp $	*/
3 /*	$NetBSD: string.h,v 1.6 1994/10/26 00:56:30 cgd Exp $	*/
4 
5 /*-
6  * Copyright © 2013, 2014
7  *	Thorsten “mirabilos” Glaser <tg@mirbsd.org>
8  * Copyright (c) 1990 The Regents of the University of California.
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  * 3. Neither the name of the University nor the names of its contributors
20  *    may be used to endorse or promote products derived from this software
21  *    without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33  * SUCH DAMAGE.
34  *
35  *	@(#)string.h	5.10 (Berkeley) 3/9/91
36  */
37 
38 #ifndef _STRING_H_
39 #define	_STRING_H_
40 
41 #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
42 #include <sys/types.h>		/* for mode_t */
43 #else
44 #include <sys/cdefs.h>
45 #include <machine/ansi.h>
46 #endif
47 
48 #if !defined(_GCC_SIZE_T)
49 #define	_GCC_SIZE_T
50 typedef	__SIZE_TYPE__	size_t;
51 #endif
52 
53 /* C11 optional */
54 #if !defined(__STDC_WANT_LIB_EXT1__) || (__STDC_WANT_LIB_EXT1__)
55 #ifndef rsize_t
56 #define rsize_t		rsize_t
57 typedef size_t		rsize_t;
58 #endif
59 #endif /* __STDC_WANT_LIB_EXT1__ */
60 
61 #ifndef NULL
62 #ifdef 	__GNUG__
63 #define	NULL	__null
64 #elif defined(lint)
65 #define	NULL	0
66 #else
67 #define	NULL	((void *)((__PTRDIFF_TYPE__)0UL))
68 #endif
69 #endif
70 
71 __BEGIN_DECLS
72 void	*memchr(const void *, int, size_t);
73 int	 memcmp(const void *, const void *, size_t);
74 void	*memcpy(void *, const void *, size_t)
75 		__attribute__((__bounded__(__buffer__, 1, 3)))
76 		__attribute__((__bounded__(__buffer__, 2, 3)));
77 void	*memmove(void *, const void *, size_t)
78 		__attribute__((__bounded__(__buffer__, 1, 3)))
79 		__attribute__((__bounded__(__buffer__, 2, 3)));
80 void	*memset(void *, int, size_t)
81 		__attribute__((__bounded__(__buffer__, 1, 3)));
82 char	*strcat(char *, const char *);
83 char	*strchr(const char *, int);
84 int	 strcmp(const char *, const char *);
85 int	 strcoll(const char *, const char *);
86 char	*strcpy(char *, const char *);
87 size_t	 strcspn(const char *, const char *);
88 char	*strerror(int);
89 int	 strerror_r(int, char *, size_t)
90 		__attribute__((__bounded__(__string__, 2, 3)));
91 size_t	 strlen(const char *);
92 char	*strncat(char *, const char *, size_t)
93 		__attribute__((__bounded__(__string__, 1, 3)));
94 int	 strncmp(const char *, const char *, size_t);
95 char	*strncpy(char *, const char *, size_t)
96 		__attribute__((__bounded__(__string__, 1, 3)));
97 char	*strpbrk(const char *, const char *);
98 char	*strrchr(const char *, int);
99 size_t	 strspn(const char *, const char *);
100 char	*strstr(const char *, const char *);
101 char	*strtok(char *, const char *);
102 char	*strtok_r(char *, const char *, char **);
103 size_t	 strxfrm(char *, const char *, size_t)
104 		__attribute__((__bounded__(__string__, 1, 3)));
105 
106 /* Nonstandard routines */
107 #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
108 int	 bcmp(const void *, const void *, size_t);
109 void	 bcopy(const void *, void *, size_t)
110 		__attribute__((__bounded__(__buffer__, 1, 3)))
111 		__attribute__((__bounded__(__buffer__, 2, 3)));
112 void	 bzero(void *, size_t)
113 		__attribute__((__bounded__(__buffer__, 1, 2)));
114 int	 ffs(int);
115 char	*index(const char *, int);
116 void	*memccpy(void *, const void *, int, size_t)
117 		__attribute__((__bounded__(__buffer__, 1, 4)));
118 char	*rindex(const char *, int);
119 int	 strcasecmp(const char *, const char *);
120 char	*strdup(const char *);
121 char	*strcasestr(const char *, const char *);
122 size_t	 strlcat(char *, const char *, size_t)
123 		__attribute__((__bounded__(__string__, 1, 3)));
124 size_t	 strlcpy(char *, const char *, size_t)
125 		__attribute__((__bounded__(__string__, 1, 3)));
126 void	 strmode(mode_t, char *);
127 int	 strncasecmp(const char *, const char *, size_t);
128 #if __OPENBSD_VISIBLE
129 char	*strndup(const char *, size_t);
130 #endif
131 char	*strsep(char **, const char *);
132 char	*strsignal(int);
133 #endif
134 __END_DECLS
135 
136 #if defined(_GNU_SOURCE) && !defined(__STRICT_ANSI__)
137 __BEGIN_DECLS
138 char *stpcpy(char *, const char *);
139 char *stpncpy(char *, const char *, size_t)
140     __attribute__((__bounded__(__string__, 1, 3)));
141 void *mempcpy(void *, const void *, size_t)
142     __attribute__((__bounded__(__buffer__, 1, 3)))
143     __attribute__((__bounded__(__buffer__, 2, 3)));
144 __END_DECLS
145 #endif
146 
147 #endif /* _STRING_H_ */
148