1*0a6a1f1dSLionel Sambuc /* $NetBSD: string.h,v 1.49 2014/09/24 18:16:36 christos Exp $ */ 22fe8fb19SBen Gras 32fe8fb19SBen Gras /*- 42fe8fb19SBen Gras * Copyright (c) 1990, 1993 52fe8fb19SBen Gras * The Regents of the University of California. All rights reserved. 62fe8fb19SBen Gras * 72fe8fb19SBen Gras * Redistribution and use in source and binary forms, with or without 82fe8fb19SBen Gras * modification, are permitted provided that the following conditions 92fe8fb19SBen Gras * are met: 102fe8fb19SBen Gras * 1. Redistributions of source code must retain the above copyright 112fe8fb19SBen Gras * notice, this list of conditions and the following disclaimer. 122fe8fb19SBen Gras * 2. Redistributions in binary form must reproduce the above copyright 132fe8fb19SBen Gras * notice, this list of conditions and the following disclaimer in the 142fe8fb19SBen Gras * documentation and/or other materials provided with the distribution. 152fe8fb19SBen Gras * 3. Neither the name of the University nor the names of its contributors 162fe8fb19SBen Gras * may be used to endorse or promote products derived from this software 172fe8fb19SBen Gras * without specific prior written permission. 182fe8fb19SBen Gras * 192fe8fb19SBen Gras * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 202fe8fb19SBen Gras * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 212fe8fb19SBen Gras * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 222fe8fb19SBen Gras * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 232fe8fb19SBen Gras * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 242fe8fb19SBen Gras * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 252fe8fb19SBen Gras * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 262fe8fb19SBen Gras * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 272fe8fb19SBen Gras * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 282fe8fb19SBen Gras * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 292fe8fb19SBen Gras * SUCH DAMAGE. 302fe8fb19SBen Gras * 312fe8fb19SBen Gras * @(#)string.h 8.1 (Berkeley) 6/2/93 329865aeaaSBen Gras */ 339865aeaaSBen Gras 342fe8fb19SBen Gras #ifndef _STRING_H_ 352fe8fb19SBen Gras #define _STRING_H_ 362fe8fb19SBen Gras #include <machine/ansi.h> 379865aeaaSBen Gras 382fe8fb19SBen Gras #ifdef _BSD_SIZE_T_ 392fe8fb19SBen Gras typedef _BSD_SIZE_T_ size_t; 402fe8fb19SBen Gras #undef _BSD_SIZE_T_ 412fe8fb19SBen Gras #endif 422fe8fb19SBen Gras 4388e7725cSArun Thomas #include <sys/null.h> 449865aeaaSBen Gras 452fe8fb19SBen Gras #include <sys/cdefs.h> 462fe8fb19SBen Gras #include <sys/featuretest.h> 479865aeaaSBen Gras 482fe8fb19SBen Gras __BEGIN_DECLS 492fe8fb19SBen Gras void *memchr(const void *, int, size_t); 502fe8fb19SBen Gras int memcmp(const void *, const void *, size_t); 512fe8fb19SBen Gras void *memcpy(void * __restrict, const void * __restrict, size_t); 522fe8fb19SBen Gras void *memmove(void *, const void *, size_t); 532fe8fb19SBen Gras void *memset(void *, int, size_t); 542fe8fb19SBen Gras char *strcat(char * __restrict, const char * __restrict); 552fe8fb19SBen Gras char *strchr(const char *, int); 562fe8fb19SBen Gras int strcmp(const char *, const char *); 572fe8fb19SBen Gras int strcoll(const char *, const char *); 582fe8fb19SBen Gras char *strcpy(char * __restrict, const char * __restrict); 592fe8fb19SBen Gras size_t strcspn(const char *, const char *); 602fe8fb19SBen Gras __aconst char *strerror(int); 612fe8fb19SBen Gras size_t strlen(const char *); 622fe8fb19SBen Gras char *strncat(char * __restrict, const char * __restrict, size_t); 632fe8fb19SBen Gras int strncmp(const char *, const char *, size_t); 642fe8fb19SBen Gras char *strncpy(char * __restrict, const char * __restrict, size_t); 652fe8fb19SBen Gras char *strpbrk(const char *, const char *); 662fe8fb19SBen Gras char *strrchr(const char *, int); 672fe8fb19SBen Gras size_t strspn(const char *, const char *); 682fe8fb19SBen Gras char *strstr(const char *, const char *); 692fe8fb19SBen Gras char *strtok(char * __restrict, const char * __restrict); 702fe8fb19SBen Gras #if (_POSIX_C_SOURCE - 0 >= 199506L) || (_XOPEN_SOURCE - 0 >= 500) || \ 712fe8fb19SBen Gras defined(_REENTRANT) || defined(_NETBSD_SOURCE) 722fe8fb19SBen Gras char *strtok_r(char *, const char *, char **); 732fe8fb19SBen Gras int strerror_r(int, char *, size_t); 742fe8fb19SBen Gras #endif /* _POSIX_C_SOURCE >= 199506 || XOPEN_SOURCE >= 500 || ... */ 752fe8fb19SBen Gras size_t strxfrm(char * __restrict, const char * __restrict, size_t); 762fe8fb19SBen Gras 772fe8fb19SBen Gras #if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) 782fe8fb19SBen Gras void *memccpy(void *, const void *, int, size_t); 792fe8fb19SBen Gras char *strdup(const char *); 809865aeaaSBen Gras #endif 819865aeaaSBen Gras 822fe8fb19SBen Gras #if (_POSIX_C_SOURCE - 0 >= 200809L) || (_XOPEN_SOURCE - 0 >= 700) || \ 832fe8fb19SBen Gras defined(_NETBSD_SOURCE) 842fe8fb19SBen Gras char *stpcpy(char * __restrict, const char * __restrict); 852fe8fb19SBen Gras char *stpncpy(char * __restrict, const char * __restrict, size_t); 862fe8fb19SBen Gras size_t strnlen(const char *, size_t); 872fe8fb19SBen Gras #ifndef __STRSIGNAL_DECLARED 882fe8fb19SBen Gras #define __STRSIGNAL_DECLARED 892fe8fb19SBen Gras /* also in unistd.h */ 902fe8fb19SBen Gras __aconst char *strsignal(int); 912fe8fb19SBen Gras #endif /* __STRSIGNAL_DECLARED */ 9211cbb6faSPhilip Homburg #endif 93f14fb602SLionel Sambuc __END_DECLS 9411cbb6faSPhilip Homburg 952fe8fb19SBen Gras #if defined(_NETBSD_SOURCE) 962fe8fb19SBen Gras #include <strings.h> /* for backwards-compatibilty */ 97f14fb602SLionel Sambuc __BEGIN_DECLS 982fe8fb19SBen Gras void *memmem(const void *, size_t, const void *, size_t); 992fe8fb19SBen Gras char *strcasestr(const char *, const char *); 1002fe8fb19SBen Gras size_t strlcat(char *, const char *, size_t); 1012fe8fb19SBen Gras size_t strlcpy(char *, const char *, size_t); 1022fe8fb19SBen Gras char *strsep(char **, const char *); 1032fe8fb19SBen Gras char *stresep(char **, const char *, int); 1042fe8fb19SBen Gras char *strndup(const char *, size_t); 105*0a6a1f1dSLionel Sambuc char *strnstr(const char *, const char *, size_t); 1062fe8fb19SBen Gras void *memrchr(const void *, int, size_t); 10784d9c625SLionel Sambuc void *explicit_memset(void *, int, size_t); 10884d9c625SLionel Sambuc int consttime_memequal(const void *, const void *, size_t); 1092fe8fb19SBen Gras __END_DECLS 110f14fb602SLionel Sambuc #endif 1119865aeaaSBen Gras 11284d9c625SLionel Sambuc #if (_POSIX_C_SOURCE - 0) >= 200809L || defined(_NETBSD_SOURCE) 11384d9c625SLionel Sambuc # ifndef __LOCALE_T_DECLARED 11484d9c625SLionel Sambuc typedef struct _locale *locale_t; 11584d9c625SLionel Sambuc # define __LOCALE_T_DECLARED 11684d9c625SLionel Sambuc # endif 11784d9c625SLionel Sambuc __BEGIN_DECLS 11884d9c625SLionel Sambuc int strcoll_l(const char *, const char *, locale_t); 11984d9c625SLionel Sambuc size_t strxfrm_l(char * __restrict, const char * __restrict, size_t, locale_t); 12084d9c625SLionel Sambuc __aconst char *strerror_l(int, locale_t); 12184d9c625SLionel Sambuc __END_DECLS 12284d9c625SLionel Sambuc #endif /* _POSIX_C_SOURCE || _NETBSD_SOURCE */ 12384d9c625SLionel Sambuc 1242fe8fb19SBen Gras #if _FORTIFY_SOURCE > 0 1252fe8fb19SBen Gras #include <ssp/string.h> 1262fe8fb19SBen Gras #endif 1272fe8fb19SBen Gras #endif /* !defined(_STRING_H_) */ 128