2013-12-15 09:09:20 +01:00
|
|
|
/*
|
|
|
|
* string.h
|
|
|
|
*
|
|
|
|
* Definitions for memory and string functions.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _STRING_H_
|
|
|
|
#define _STRING_H_
|
|
|
|
|
|
|
|
#include "_ansi.h"
|
|
|
|
#include <sys/reent.h>
|
|
|
|
#include <sys/cdefs.h>
|
2014-05-11 00:12:19 +02:00
|
|
|
#include <sys/features.h>
|
2013-12-15 09:09:20 +01:00
|
|
|
|
|
|
|
#define __need_size_t
|
2014-05-11 00:12:19 +02:00
|
|
|
#define __need_NULL
|
2013-12-15 09:09:20 +01:00
|
|
|
#include <stddef.h>
|
|
|
|
|
|
|
|
_BEGIN_STD_C
|
|
|
|
|
|
|
|
_PTR _EXFUN(memchr,(const _PTR, int, size_t));
|
|
|
|
int _EXFUN(memcmp,(const _PTR, const _PTR, size_t));
|
2014-05-11 00:12:19 +02:00
|
|
|
_PTR _EXFUN(memcpy,(_PTR __restrict, const _PTR __restrict, size_t));
|
2013-12-15 09:09:20 +01:00
|
|
|
_PTR _EXFUN(memmove,(_PTR, const _PTR, size_t));
|
|
|
|
_PTR _EXFUN(memset,(_PTR, int, size_t));
|
2014-05-11 00:12:19 +02:00
|
|
|
char *_EXFUN(strcat,(char *__restrict, const char *__restrict));
|
2013-12-15 09:09:20 +01:00
|
|
|
char *_EXFUN(strchr,(const char *, int));
|
|
|
|
int _EXFUN(strcmp,(const char *, const char *));
|
|
|
|
int _EXFUN(strcoll,(const char *, const char *));
|
2014-05-11 00:12:19 +02:00
|
|
|
char *_EXFUN(strcpy,(char *__restrict, const char *__restrict));
|
2013-12-15 09:09:20 +01:00
|
|
|
size_t _EXFUN(strcspn,(const char *, const char *));
|
|
|
|
char *_EXFUN(strerror,(int));
|
|
|
|
size_t _EXFUN(strlen,(const char *));
|
2014-05-11 00:12:19 +02:00
|
|
|
char *_EXFUN(strncat,(char *__restrict, const char *__restrict, size_t));
|
2013-12-15 09:09:20 +01:00
|
|
|
int _EXFUN(strncmp,(const char *, const char *, size_t));
|
2014-05-11 00:12:19 +02:00
|
|
|
char *_EXFUN(strncpy,(char *__restrict, const char *__restrict, size_t));
|
2013-12-15 09:09:20 +01:00
|
|
|
char *_EXFUN(strpbrk,(const char *, const char *));
|
|
|
|
char *_EXFUN(strrchr,(const char *, int));
|
|
|
|
size_t _EXFUN(strspn,(const char *, const char *));
|
|
|
|
char *_EXFUN(strstr,(const char *, const char *));
|
|
|
|
#ifndef _REENT_ONLY
|
2014-05-11 00:12:19 +02:00
|
|
|
char *_EXFUN(strtok,(char *__restrict, const char *__restrict));
|
2013-12-15 09:09:20 +01:00
|
|
|
#endif
|
2014-05-11 00:12:19 +02:00
|
|
|
size_t _EXFUN(strxfrm,(char *__restrict, const char *__restrict, size_t));
|
2013-12-15 09:09:20 +01:00
|
|
|
|
2016-01-26 03:29:46 +01:00
|
|
|
#if __POSIX_VISIBLE
|
2014-05-11 00:12:19 +02:00
|
|
|
char *_EXFUN(strtok_r,(char *__restrict, const char *__restrict, char **__restrict));
|
2016-01-26 03:29:46 +01:00
|
|
|
#endif
|
|
|
|
#if __BSD_VISIBLE
|
2013-12-15 09:09:20 +01:00
|
|
|
int _EXFUN(bcmp,(const void *, const void *, size_t));
|
|
|
|
void _EXFUN(bcopy,(const void *, void *, size_t));
|
|
|
|
void _EXFUN(bzero,(void *, size_t));
|
|
|
|
int _EXFUN(ffs,(int));
|
|
|
|
char *_EXFUN(index,(const char *, int));
|
2016-01-26 03:29:46 +01:00
|
|
|
#endif
|
|
|
|
#if __BSD_VISIBLE || __XSI_VISIBLE
|
2014-05-11 00:12:19 +02:00
|
|
|
_PTR _EXFUN(memccpy,(_PTR __restrict, const _PTR __restrict, int, size_t));
|
2016-01-26 03:29:46 +01:00
|
|
|
#endif
|
|
|
|
#if __GNU_VISIBLE
|
2013-12-15 09:09:20 +01:00
|
|
|
_PTR _EXFUN(mempcpy,(_PTR, const _PTR, size_t));
|
|
|
|
_PTR _EXFUN(memmem, (const _PTR, size_t, const _PTR, size_t));
|
2016-01-26 03:29:46 +01:00
|
|
|
#endif
|
2014-05-11 00:12:19 +02:00
|
|
|
_PTR _EXFUN(memrchr,(const _PTR, int, size_t));
|
2016-01-26 03:29:46 +01:00
|
|
|
#if __GNU_VISIBLE
|
2014-05-11 00:12:19 +02:00
|
|
|
_PTR _EXFUN(rawmemchr,(const _PTR, int));
|
2016-01-26 03:29:46 +01:00
|
|
|
#endif
|
|
|
|
#if __BSD_VISIBLE
|
2013-12-15 09:09:20 +01:00
|
|
|
char *_EXFUN(rindex,(const char *, int));
|
2016-01-26 03:29:46 +01:00
|
|
|
#endif
|
2014-05-11 00:12:19 +02:00
|
|
|
char *_EXFUN(stpcpy,(char *__restrict, const char *__restrict));
|
|
|
|
char *_EXFUN(stpncpy,(char *__restrict, const char *__restrict, size_t));
|
2016-01-26 03:29:46 +01:00
|
|
|
#if __BSD_VISIBLE || __POSIX_VISIBLE
|
2013-12-15 09:09:20 +01:00
|
|
|
int _EXFUN(strcasecmp,(const char *, const char *));
|
2016-01-26 03:29:46 +01:00
|
|
|
#endif
|
|
|
|
#if __GNU_VISIBLE
|
2013-12-15 09:09:20 +01:00
|
|
|
char *_EXFUN(strcasestr,(const char *, const char *));
|
|
|
|
char *_EXFUN(strchrnul,(const char *, int));
|
2014-05-11 00:12:19 +02:00
|
|
|
#endif
|
2016-01-26 03:29:46 +01:00
|
|
|
#if __XSI_VISIBLE >= 500
|
2013-12-15 09:09:20 +01:00
|
|
|
char *_EXFUN(strdup,(const char *));
|
2014-05-11 00:12:19 +02:00
|
|
|
#endif
|
|
|
|
#ifndef __STRICT_ANSI__
|
2013-12-15 09:09:20 +01:00
|
|
|
char *_EXFUN(_strdup_r,(struct _reent *, const char *));
|
2014-05-11 00:12:19 +02:00
|
|
|
#endif
|
2016-01-26 03:29:46 +01:00
|
|
|
#if __XSI_VISIBLE >= 700
|
2013-12-15 09:09:20 +01:00
|
|
|
char *_EXFUN(strndup,(const char *, size_t));
|
2014-05-11 00:12:19 +02:00
|
|
|
#endif
|
2016-01-26 03:29:46 +01:00
|
|
|
|
2014-05-11 00:12:19 +02:00
|
|
|
#ifndef __STRICT_ANSI__
|
2013-12-15 09:09:20 +01:00
|
|
|
char *_EXFUN(_strndup_r,(struct _reent *, const char *, size_t));
|
2016-01-26 03:29:46 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if __GNU_VISIBLE
|
|
|
|
int _EXFUN(ffsl,(long));
|
|
|
|
int _EXFUN(ffsll, (long long));
|
|
|
|
#endif
|
|
|
|
|
2013-12-15 09:09:20 +01:00
|
|
|
/* There are two common strerror_r variants. If you request
|
|
|
|
_GNU_SOURCE, you get the GNU version; otherwise you get the POSIX
|
|
|
|
version. POSIX requires that #undef strerror_r will still let you
|
|
|
|
invoke the underlying function, but that requires gcc support. */
|
2016-01-26 03:29:46 +01:00
|
|
|
#if __GNU_VISIBLE
|
|
|
|
char *_EXFUN(strerror_r,(int, char *, size_t));
|
2013-12-15 09:09:20 +01:00
|
|
|
#else
|
|
|
|
# ifdef __GNUC__
|
2016-01-26 03:29:46 +01:00
|
|
|
int _EXFUN(strerror_r,(int, char *, size_t))
|
|
|
|
#ifdef __ASMNAME
|
|
|
|
__asm__ (__ASMNAME ("__xpg_strerror_r"))
|
|
|
|
#endif
|
|
|
|
;
|
2013-12-15 09:09:20 +01:00
|
|
|
# else
|
2016-01-26 03:29:46 +01:00
|
|
|
int _EXFUN(__xpg_strerror_r,(int, char *, size_t));
|
2013-12-15 09:09:20 +01:00
|
|
|
# define strerror_r __xpg_strerror_r
|
|
|
|
# endif
|
|
|
|
#endif
|
2016-01-26 03:29:46 +01:00
|
|
|
|
|
|
|
/* Reentrant version of strerror. */
|
|
|
|
char * _EXFUN(_strerror_r, (struct _reent *, int, int, int *));
|
|
|
|
|
|
|
|
#if __BSD_VISIBLE
|
|
|
|
size_t _EXFUN(strlcat,(char *, const char *, size_t));
|
|
|
|
size_t _EXFUN(strlcpy,(char *, const char *, size_t));
|
|
|
|
#endif
|
|
|
|
#if __BSD_VISIBLE || __POSIX_VISIBLE
|
|
|
|
int _EXFUN(strncasecmp,(const char *, const char *, size_t));
|
|
|
|
#endif
|
|
|
|
#if !defined(__STRICT_ANSI__) || __POSIX_VISIBLE >= 200809 || \
|
|
|
|
__XSI_VISIBLE >= 700
|
2013-12-15 09:09:20 +01:00
|
|
|
size_t _EXFUN(strnlen,(const char *, size_t));
|
2016-01-26 03:29:46 +01:00
|
|
|
#endif
|
|
|
|
#if __BSD_VISIBLE
|
2013-12-15 09:09:20 +01:00
|
|
|
char *_EXFUN(strsep,(char **, const char *));
|
2016-01-26 03:29:46 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The origin of these is unknown to me so I am conditionalizing them
|
|
|
|
* on __STRICT_ANSI__. Finetuning this is definitely needed. --joel
|
|
|
|
*/
|
|
|
|
#if !defined(__STRICT_ANSI__)
|
2013-12-15 09:09:20 +01:00
|
|
|
char *_EXFUN(strlwr,(char *));
|
|
|
|
char *_EXFUN(strupr,(char *));
|
2016-01-26 03:29:46 +01:00
|
|
|
#endif
|
|
|
|
|
2013-12-15 09:09:20 +01:00
|
|
|
#ifndef DEFS_H /* Kludge to work around problem compiling in gdb */
|
2016-01-26 03:29:46 +01:00
|
|
|
char *_EXFUN(strsignal, (int __signo));
|
2013-12-15 09:09:20 +01:00
|
|
|
#endif
|
2016-01-26 03:29:46 +01:00
|
|
|
|
2013-12-15 09:09:20 +01:00
|
|
|
#ifdef __CYGWIN__
|
2016-01-26 03:29:46 +01:00
|
|
|
int _EXFUN(strtosigno, (const char *__name));
|
2013-12-15 09:09:20 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined _GNU_SOURCE && defined __GNUC__
|
|
|
|
#define strdupa(__s) \
|
|
|
|
(__extension__ ({const char *__in = (__s); \
|
|
|
|
size_t __len = strlen (__in) + 1; \
|
|
|
|
char * __out = (char *) __builtin_alloca (__len); \
|
|
|
|
(char *) memcpy (__out, __in, __len);}))
|
|
|
|
#define strndupa(__s, __n) \
|
|
|
|
(__extension__ ({const char *__in = (__s); \
|
|
|
|
size_t __len = strnlen (__in, (__n)) + 1; \
|
|
|
|
char *__out = (char *) __builtin_alloca (__len); \
|
|
|
|
__out[__len-1] = '\0'; \
|
|
|
|
(char *) memcpy (__out, __in, __len-1);}))
|
|
|
|
#endif /* _GNU_SOURCE && __GNUC__ */
|
|
|
|
|
2016-01-26 03:29:46 +01:00
|
|
|
/* There are two common basename variants. If you do NOT #include <libgen.h>
|
|
|
|
and you do
|
2013-12-15 09:09:20 +01:00
|
|
|
|
2016-01-26 03:29:46 +01:00
|
|
|
#define _GNU_SOURCE
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
you get the GNU version. Otherwise you get the POSIX versionfor which you
|
|
|
|
should #include <libgen.h>i for the function prototype. POSIX requires that
|
|
|
|
#undef basename will still let you invoke the underlying function. However,
|
|
|
|
this also implies that the POSIX version is used in this case. That's made
|
|
|
|
sure here. */
|
|
|
|
#if __GNU_VISIBLE && !defined(basename)
|
|
|
|
# define basename basename
|
|
|
|
char *_EXFUN(__nonnull (1) basename,(const char *)) __asm__(__ASMNAME("__gnu_basename"));
|
|
|
|
#endif
|
2013-12-15 09:09:20 +01:00
|
|
|
|
|
|
|
#include <sys/string.h>
|
|
|
|
|
|
|
|
_END_STD_C
|
|
|
|
|
|
|
|
#endif /* _STRING_H_ */
|