xref: /openbsd-src/include/string.h (revision 4af81b37ced6d7e969e2e8eba245210dae4b89d1)
1*4af81b37Sguenther /*	$OpenBSD: string.h,v 1.34 2024/08/03 20:13:23 guenther Exp $	*/
2df930be7Sderaadt /*	$NetBSD: string.h,v 1.6 1994/10/26 00:56:30 cgd Exp $	*/
3df930be7Sderaadt 
4df930be7Sderaadt /*-
5df930be7Sderaadt  * Copyright (c) 1990 The Regents of the University of California.
6df930be7Sderaadt  * All rights reserved.
7df930be7Sderaadt  *
8df930be7Sderaadt  * Redistribution and use in source and binary forms, with or without
9df930be7Sderaadt  * modification, are permitted provided that the following conditions
10df930be7Sderaadt  * are met:
11df930be7Sderaadt  * 1. Redistributions of source code must retain the above copyright
12df930be7Sderaadt  *    notice, this list of conditions and the following disclaimer.
13df930be7Sderaadt  * 2. Redistributions in binary form must reproduce the above copyright
14df930be7Sderaadt  *    notice, this list of conditions and the following disclaimer in the
15df930be7Sderaadt  *    documentation and/or other materials provided with the distribution.
16e33d3bd3Smillert  * 3. Neither the name of the University nor the names of its contributors
17df930be7Sderaadt  *    may be used to endorse or promote products derived from this software
18df930be7Sderaadt  *    without specific prior written permission.
19df930be7Sderaadt  *
20df930be7Sderaadt  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21df930be7Sderaadt  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22df930be7Sderaadt  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23df930be7Sderaadt  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24df930be7Sderaadt  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25df930be7Sderaadt  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26df930be7Sderaadt  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27df930be7Sderaadt  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28df930be7Sderaadt  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29df930be7Sderaadt  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30df930be7Sderaadt  * SUCH DAMAGE.
31df930be7Sderaadt  *
32df930be7Sderaadt  *	@(#)string.h	5.10 (Berkeley) 3/9/91
33df930be7Sderaadt  */
34df930be7Sderaadt 
35df930be7Sderaadt #ifndef _STRING_H_
36df930be7Sderaadt #define	_STRING_H_
3752a0e603Smillert 
3852a0e603Smillert #include <sys/cdefs.h>
396ecde746Smillert #include <sys/_null.h>
40bc8a30fcSotto #include <sys/_types.h>
41df930be7Sderaadt 
42e7fbb21cSmillert /*
43e7fbb21cSmillert  * POSIX mandates that certain string functions not present in ISO C
44e7fbb21cSmillert  * be prototyped in strings.h.  Historically, we've included them here.
45e7fbb21cSmillert  */
46e7fbb21cSmillert #if __BSD_VISIBLE
47e7fbb21cSmillert #include <strings.h>
48e7fbb21cSmillert #endif
49e7fbb21cSmillert 
50c916d948Smillert #ifndef	_SIZE_T_DEFINED_
51c916d948Smillert #define	_SIZE_T_DEFINED_
52c916d948Smillert typedef	__size_t	size_t;
53df930be7Sderaadt #endif
54df930be7Sderaadt 
553a628b46Sschwarze #if __POSIX_VISIBLE >= 200809
563a628b46Sschwarze #ifndef _LOCALE_T_DEFINED_
573a628b46Sschwarze #define _LOCALE_T_DEFINED_
583a628b46Sschwarze typedef void	*locale_t;
593a628b46Sschwarze #endif
603a628b46Sschwarze #endif
613a628b46Sschwarze 
62df930be7Sderaadt __BEGIN_DECLS
63c72b5b24Smillert void	*memchr(const void *, int, size_t);
64c72b5b24Smillert int	 memcmp(const void *, const void *, size_t);
6582d303adSguenther void	*memcpy(void *__restrict, const void *__restrict, size_t)
6689b95c1cSavsm 		__attribute__ ((__bounded__(__buffer__,1,3)))
6789b95c1cSavsm 		__attribute__ ((__bounded__(__buffer__,2,3)));
6889b95c1cSavsm void	*memmove(void *, const void *, size_t)
6989b95c1cSavsm 		__attribute__ ((__bounded__(__buffer__,1,3)))
7089b95c1cSavsm 		__attribute__ ((__bounded__(__buffer__,2,3)));
7189b95c1cSavsm void	*memset(void *, int, size_t)
7289b95c1cSavsm 		__attribute__ ((__bounded__(__buffer__,1,3)));
7382d303adSguenther char	*strcat(char *__restrict, const char *__restrict);
74c72b5b24Smillert char	*strchr(const char *, int);
75c72b5b24Smillert int	 strcmp(const char *, const char *);
76c72b5b24Smillert int	 strcoll(const char *, const char *);
7782d303adSguenther char	*strcpy(char *__restrict, const char *__restrict);
78c72b5b24Smillert size_t	 strcspn(const char *, const char *);
79c72b5b24Smillert char	*strerror(int);
80c72b5b24Smillert size_t	 strlen(const char *);
8182d303adSguenther char	*strncat(char *__restrict, const char *__restrict, size_t)
8289b95c1cSavsm 		__attribute__ ((__bounded__(__string__,1,3)));
83c72b5b24Smillert int	 strncmp(const char *, const char *, size_t);
8482d303adSguenther char	*strncpy(char *__restrict, const char *__restrict, size_t)
8589b95c1cSavsm 		__attribute__ ((__bounded__(__string__,1,3)));
86c72b5b24Smillert char	*strpbrk(const char *, const char *);
87c72b5b24Smillert char	*strrchr(const char *, int);
88c72b5b24Smillert size_t	 strspn(const char *, const char *);
89c72b5b24Smillert char	*strstr(const char *, const char *);
9082d303adSguenther char	*strtok(char *__restrict, const char *__restrict);
9182d303adSguenther char	*strtok_r(char *__restrict, const char *__restrict, char **__restrict);
9282d303adSguenther size_t	 strxfrm(char *__restrict, const char *__restrict, size_t)
9389b95c1cSavsm 		__attribute__ ((__bounded__(__string__,1,3)));
94df930be7Sderaadt 
9582d303adSguenther #if __XPG_VISIBLE
9682d303adSguenther void	*memccpy(void *__restrict, const void *__restrict, int, size_t)
9752a0e603Smillert 		__attribute__ ((__bounded__(__buffer__,1,4)));
9852a0e603Smillert #endif
9952a0e603Smillert 
10082d303adSguenther #if __POSIX_VISIBLE >= 200112
10152a0e603Smillert int	 strerror_r(int, char *, size_t)
10252a0e603Smillert 	    __attribute__ ((__bounded__(__string__,2,3)));
10352a0e603Smillert #endif
10452a0e603Smillert 
10582d303adSguenther #if __XPG_VISIBLE >= 420 || __POSIX_VISIBLE >= 200809
10682d303adSguenther char	*strdup(const char *);
10782d303adSguenther #endif
10882d303adSguenther 
109243f3935Stedu #if __POSIX_VISIBLE >= 200809
11082d303adSguenther char	*stpcpy(char *__restrict, const char *__restrict);
11182d303adSguenther char	*stpncpy(char *__restrict, const char *__restrict, size_t);
1123a628b46Sschwarze int	 strcoll_l(const char *, const char *, locale_t);
1133a628b46Sschwarze char	*strerror_l(int, locale_t);
114243f3935Stedu char	*strndup(const char *, size_t);
115243f3935Stedu size_t	 strnlen(const char *, size_t);
1161ef6a089Sguenther char	*strsignal(int);
1173a628b46Sschwarze size_t	 strxfrm_l(char *__restrict, const char *__restrict, size_t, locale_t)
1183a628b46Sschwarze 		__attribute__ ((__bounded__(__string__,1,3)));
1191ef6a089Sguenther #endif
1201ef6a089Sguenther 
121*4af81b37Sguenther #if __POSIX_VISIBLE >= 202405 || __BSD_VISIBLE
122*4af81b37Sguenther void	*memmem(const void *, size_t, const void *, size_t);
123*4af81b37Sguenther size_t	 strlcat(char *__restrict, const char *__restrict, size_t)
124*4af81b37Sguenther 		__attribute__ ((__bounded__(__string__,1,3)));
125*4af81b37Sguenther size_t	 strlcpy(char *__restrict, const char *__restrict, size_t)
126*4af81b37Sguenther 		__attribute__ ((__bounded__(__string__,1,3)));
127*4af81b37Sguenther #endif
128*4af81b37Sguenther 
12952a0e603Smillert #if __BSD_VISIBLE
1302fa321beStedu void	 explicit_bzero(void *, size_t)
1312fa321beStedu 		__attribute__ ((__bounded__(__buffer__,1,2)));
13282d303adSguenther void	*memrchr(const void *, int, size_t);
133e31daa15Sderaadt char	*strcasestr(const char *, const char *);
134bc8a30fcSotto void	 strmode(__mode_t, char *);
135c72b5b24Smillert char	*strsep(char **, const char *);
13603cd71adSmatthew int	 timingsafe_bcmp(const void *, const void *, size_t);
137abf4a3adSmatthew int	 timingsafe_memcmp(const void *, const void *, size_t);
138df930be7Sderaadt #endif
139df930be7Sderaadt __END_DECLS
140df930be7Sderaadt 
141df930be7Sderaadt #endif /* _STRING_H_ */
142