string.h revision 1.45
1/*	$NetBSD: string.h,v 1.45 2013/08/19 13:03:12 joerg Exp $	*/
2
3/*-
4 * Copyright (c) 1990, 1993
5 *	The Regents of the University of California.  All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 *    may be used to endorse or promote products derived from this software
17 *    without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 *
31 *	@(#)string.h	8.1 (Berkeley) 6/2/93
32 */
33
34#ifndef _STRING_H_
35#define	_STRING_H_
36#include <machine/ansi.h>
37
38#ifdef	_BSD_SIZE_T_
39typedef	_BSD_SIZE_T_	size_t;
40#undef	_BSD_SIZE_T_
41#endif
42
43#include <sys/null.h>
44
45#include <sys/cdefs.h>
46#include <sys/featuretest.h>
47
48__BEGIN_DECLS
49void	*memchr(const void *, int, size_t);
50int	 memcmp(const void *, const void *, size_t);
51void	*memcpy(void * __restrict, const void * __restrict, size_t);
52void	*memmove(void *, const void *, size_t);
53void	*memset(void *, int, size_t);
54char	*strcat(char * __restrict, const char * __restrict);
55char	*strchr(const char *, int);
56int	 strcmp(const char *, const char *);
57int	 strcoll(const char *, const char *);
58char	*strcpy(char * __restrict, const char * __restrict);
59size_t	 strcspn(const char *, const char *);
60__aconst char *strerror(int);
61size_t	 strlen(const char *);
62char	*strncat(char * __restrict, const char * __restrict, size_t);
63int	 strncmp(const char *, const char *, size_t);
64char	*strncpy(char * __restrict, const char * __restrict, size_t);
65char	*strpbrk(const char *, const char *);
66char	*strrchr(const char *, int);
67size_t	 strspn(const char *, const char *);
68char	*strstr(const char *, const char *);
69char	*strtok(char * __restrict, const char * __restrict);
70#if (_POSIX_C_SOURCE - 0 >= 199506L) || (_XOPEN_SOURCE - 0 >= 500) || \
71    defined(_REENTRANT) || defined(_NETBSD_SOURCE)
72char	*strtok_r(char *, const char *, char **);
73int	 strerror_r(int, char *, size_t);
74#endif /* _POSIX_C_SOURCE >= 199506 || XOPEN_SOURCE >= 500 || ... */
75size_t	 strxfrm(char * __restrict, const char * __restrict, size_t);
76
77#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
78void	*memccpy(void *, const void *, int, size_t);
79char	*strdup(const char *);
80#endif
81
82#if (_POSIX_C_SOURCE - 0 >= 200809L) || (_XOPEN_SOURCE - 0 >= 700) || \
83    defined(_NETBSD_SOURCE)
84char	*stpcpy(char * __restrict, const char * __restrict);
85char	*stpncpy(char * __restrict, const char * __restrict, size_t);
86size_t	strnlen(const char *, size_t);
87#ifndef __STRSIGNAL_DECLARED
88#define __STRSIGNAL_DECLARED
89/* also in unistd.h */
90__aconst char *strsignal(int);
91#endif /* __STRSIGNAL_DECLARED */
92/*
93 * For POSIX compliance, we still need:
94 * strcoll_l
95 * strerror_l
96 * strxfrm_l
97 */
98#endif
99__END_DECLS
100
101#if defined(_NETBSD_SOURCE)
102#include <strings.h>		/* for backwards-compatibilty */
103__BEGIN_DECLS
104void	*memmem(const void *, size_t, const void *, size_t);
105char	*strcasestr(const char *, const char *);
106size_t	 strlcat(char *, const char *, size_t);
107size_t	 strlcpy(char *, const char *, size_t);
108char	*strsep(char **, const char *);
109char	*stresep(char **, const char *, int);
110char	*strndup(const char *, size_t);
111void	*memrchr(const void *, int, size_t);
112void	__explicit_memset(void *, int, size_t);
113int	__consttime_memequal(const void *, const void *, size_t);
114__END_DECLS
115#endif
116
117#if (_POSIX_C_SOURCE - 0) >= 200809L || defined(_NETBSD_SOURCE)
118#  ifndef __LOCALE_T_DECLARED
119typedef struct _locale		*locale_t;
120#  define __LOCALE_T_DECLARED
121#  endif
122__BEGIN_DECLS
123int	 strcoll_l(const char *, const char *, locale_t);
124size_t	 strxfrm_l(char * __restrict, const char * __restrict, size_t, locale_t);
125__aconst char *strerror_l(int, locale_t);
126__END_DECLS
127#endif /* _POSIX_C_SOURCE || _NETBSD_SOURCE */
128
129#if _FORTIFY_SOURCE > 0
130#include <ssp/string.h>
131#endif
132#endif /* !defined(_STRING_H_) */
133