2000-02-18 03:39:52 +08:00
|
|
|
/*
|
|
|
|
* string.h
|
|
|
|
*
|
|
|
|
* Definitions for memory and string functions.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _STRING_H_
|
|
|
|
#define _STRING_H_
|
|
|
|
|
|
|
|
#include "_ansi.h"
|
|
|
|
#include <sys/reent.h>
|
2011-03-03 19:11:41 +08:00
|
|
|
#include <sys/cdefs.h>
|
2012-10-22 23:16:48 +08:00
|
|
|
#include <sys/features.h>
|
2000-02-18 03:39:52 +08:00
|
|
|
|
|
|
|
#define __need_size_t
|
2012-11-01 19:51:12 +08:00
|
|
|
#define __need_NULL
|
2000-02-18 03:39:52 +08:00
|
|
|
#include <stddef.h>
|
|
|
|
|
2016-07-25 17:47:36 +08:00
|
|
|
#if __POSIX_VISIBLE >= 200809
|
2019-06-13 04:31:14 +08:00
|
|
|
#include <sys/_locale.h>
|
2016-07-25 02:00:34 +08:00
|
|
|
#endif
|
|
|
|
|
2017-07-04 17:49:58 +08:00
|
|
|
#if __BSD_VISIBLE
|
|
|
|
#include <strings.h>
|
|
|
|
#endif
|
|
|
|
|
2002-06-28 07:58:38 +08:00
|
|
|
_BEGIN_STD_C
|
|
|
|
|
2017-12-04 13:54:48 +08:00
|
|
|
void * memchr (const void *, int, size_t);
|
|
|
|
int memcmp (const void *, const void *, size_t);
|
|
|
|
void * memcpy (void *__restrict, const void *__restrict, size_t);
|
|
|
|
void * memmove (void *, const void *, size_t);
|
|
|
|
void * memset (void *, int, size_t);
|
|
|
|
char *strcat (char *__restrict, const char *__restrict);
|
|
|
|
char *strchr (const char *, int);
|
|
|
|
int strcmp (const char *, const char *);
|
|
|
|
int strcoll (const char *, const char *);
|
|
|
|
char *strcpy (char *__restrict, const char *__restrict);
|
|
|
|
size_t strcspn (const char *, const char *);
|
|
|
|
char *strerror (int);
|
|
|
|
size_t strlen (const char *);
|
|
|
|
char *strncat (char *__restrict, const char *__restrict, size_t);
|
|
|
|
int strncmp (const char *, const char *, size_t);
|
|
|
|
char *strncpy (char *__restrict, const char *__restrict, size_t);
|
|
|
|
char *strpbrk (const char *, const char *);
|
|
|
|
char *strrchr (const char *, int);
|
|
|
|
size_t strspn (const char *, const char *);
|
|
|
|
char *strstr (const char *, const char *);
|
2000-02-18 03:39:52 +08:00
|
|
|
#ifndef _REENT_ONLY
|
2017-12-04 13:54:48 +08:00
|
|
|
char *strtok (char *__restrict, const char *__restrict);
|
2000-02-18 03:39:52 +08:00
|
|
|
#endif
|
2017-12-04 13:54:48 +08:00
|
|
|
size_t strxfrm (char *__restrict, const char *__restrict, size_t);
|
2000-02-18 03:39:52 +08:00
|
|
|
|
2016-07-25 02:00:34 +08:00
|
|
|
#if __POSIX_VISIBLE >= 200809
|
2016-08-25 04:36:31 +08:00
|
|
|
int strcoll_l (const char *, const char *, locale_t);
|
|
|
|
char *strerror_l (int, locale_t);
|
|
|
|
size_t strxfrm_l (char *__restrict, const char *__restrict, size_t, locale_t);
|
|
|
|
#endif
|
2016-03-15 06:13:42 +08:00
|
|
|
#if __MISC_VISIBLE || __POSIX_VISIBLE
|
2017-12-04 13:54:48 +08:00
|
|
|
char *strtok_r (char *__restrict, const char *__restrict, char **__restrict);
|
2014-08-18 22:18:10 +08:00
|
|
|
#endif
|
2016-03-18 18:49:25 +08:00
|
|
|
#if __BSD_VISIBLE
|
2017-12-04 13:54:48 +08:00
|
|
|
int timingsafe_bcmp (const void *, const void *, size_t);
|
|
|
|
int timingsafe_memcmp (const void *, const void *, size_t);
|
2016-03-18 18:49:25 +08:00
|
|
|
#endif
|
2016-03-15 06:13:42 +08:00
|
|
|
#if __MISC_VISIBLE || __POSIX_VISIBLE
|
2017-12-04 13:54:48 +08:00
|
|
|
void * memccpy (void *__restrict, const void *__restrict, int, size_t);
|
2014-08-18 22:18:10 +08:00
|
|
|
#endif
|
|
|
|
#if __GNU_VISIBLE
|
2017-12-04 13:54:48 +08:00
|
|
|
void * mempcpy (void *, const void *, size_t);
|
|
|
|
void * memmem (const void *, size_t, const void *, size_t);
|
|
|
|
void * memrchr (const void *, int, size_t);
|
|
|
|
void * rawmemchr (const void *, int);
|
2014-08-18 22:18:10 +08:00
|
|
|
#endif
|
2016-04-14 12:50:11 +08:00
|
|
|
#if __POSIX_VISIBLE >= 200809
|
2017-12-04 13:54:48 +08:00
|
|
|
char *stpcpy (char *__restrict, const char *__restrict);
|
|
|
|
char *stpncpy (char *__restrict, const char *__restrict, size_t);
|
2016-04-14 12:50:11 +08:00
|
|
|
#endif
|
2014-08-18 22:18:10 +08:00
|
|
|
#if __GNU_VISIBLE
|
2017-12-04 13:54:48 +08:00
|
|
|
char *strcasestr (const char *, const char *);
|
|
|
|
char *strchrnul (const char *, int);
|
2012-10-22 23:16:48 +08:00
|
|
|
#endif
|
2016-03-15 06:13:42 +08:00
|
|
|
#if __MISC_VISIBLE || __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE >= 4
|
2018-09-28 17:12:48 +08:00
|
|
|
char *strdup (const char *) __malloc_like __result_use_check;
|
2012-10-22 23:16:48 +08:00
|
|
|
#endif
|
2017-12-04 13:54:48 +08:00
|
|
|
char *_strdup_r (struct _reent *, const char *);
|
2016-03-15 06:13:42 +08:00
|
|
|
#if __POSIX_VISIBLE >= 200809
|
2018-09-28 17:12:48 +08:00
|
|
|
char *strndup (const char *, size_t) __malloc_like __result_use_check;
|
2012-10-22 23:16:48 +08:00
|
|
|
#endif
|
2017-12-04 13:54:48 +08:00
|
|
|
char *_strndup_r (struct _reent *, const char *, size_t);
|
2014-08-18 22:18:10 +08:00
|
|
|
|
2011-02-11 00:48:18 +08: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. */
|
2014-08-18 22:18:10 +08:00
|
|
|
#if __GNU_VISIBLE
|
2017-12-04 13:54:48 +08:00
|
|
|
char *strerror_r (int, char *, size_t);
|
2016-03-15 06:13:42 +08:00
|
|
|
#elif __POSIX_VISIBLE >= 200112
|
2011-02-11 00:48:18 +08:00
|
|
|
# ifdef __GNUC__
|
2017-12-04 13:54:48 +08:00
|
|
|
int strerror_r (int, char *, size_t)
|
2015-02-07 00:14:04 +08:00
|
|
|
#ifdef __ASMNAME
|
|
|
|
__asm__ (__ASMNAME ("__xpg_strerror_r"))
|
|
|
|
#endif
|
|
|
|
;
|
2011-02-11 00:48:18 +08:00
|
|
|
# else
|
2017-12-04 13:54:48 +08:00
|
|
|
int __xpg_strerror_r (int, char *, size_t);
|
2011-02-11 00:48:18 +08:00
|
|
|
# define strerror_r __xpg_strerror_r
|
|
|
|
# endif
|
|
|
|
#endif
|
2014-08-18 22:18:10 +08:00
|
|
|
|
|
|
|
/* Reentrant version of strerror. */
|
2017-12-04 13:54:48 +08:00
|
|
|
char * _strerror_r (struct _reent *, int, int, int *);
|
2014-08-18 22:18:10 +08:00
|
|
|
|
|
|
|
#if __BSD_VISIBLE
|
2017-12-04 13:54:48 +08:00
|
|
|
size_t strlcat (char *, const char *, size_t);
|
|
|
|
size_t strlcpy (char *, const char *, size_t);
|
2014-08-18 22:18:10 +08:00
|
|
|
#endif
|
2016-03-15 06:13:42 +08:00
|
|
|
#if __POSIX_VISIBLE >= 200809
|
2017-12-04 13:54:48 +08:00
|
|
|
size_t strnlen (const char *, size_t);
|
2014-08-18 22:18:10 +08:00
|
|
|
#endif
|
|
|
|
#if __BSD_VISIBLE
|
2017-12-04 13:54:48 +08:00
|
|
|
char *strsep (char **, const char *);
|
2014-08-18 22:18:10 +08:00
|
|
|
#endif
|
2017-08-25 15:35:39 +08:00
|
|
|
#if __BSD_VISIBLE
|
|
|
|
char *strnstr(const char *, const char *, size_t) __pure;
|
|
|
|
#endif
|
2014-08-18 22:18:10 +08:00
|
|
|
|
2016-03-15 06:13:42 +08:00
|
|
|
#if __MISC_VISIBLE
|
2017-12-04 13:54:48 +08:00
|
|
|
char *strlwr (char *);
|
|
|
|
char *strupr (char *);
|
2014-08-18 22:18:10 +08:00
|
|
|
#endif
|
|
|
|
|
2021-10-28 00:41:22 +08:00
|
|
|
#if __POSIX_VISIBLE >= 200809
|
2017-12-04 13:54:48 +08:00
|
|
|
char *strsignal (int __signo);
|
2000-06-03 11:03:03 +08:00
|
|
|
#endif
|
2014-08-18 22:18:10 +08:00
|
|
|
|
2011-01-10 18:59:42 +08:00
|
|
|
#ifdef __CYGWIN__
|
2017-12-04 13:54:48 +08:00
|
|
|
int strtosigno (const char *__name);
|
2000-02-18 03:39:52 +08:00
|
|
|
#endif
|
|
|
|
|
2017-06-15 04:22:00 +08:00
|
|
|
#if __GNU_VISIBLE
|
2017-12-04 13:54:48 +08:00
|
|
|
int strverscmp (const char *, const char *);
|
2017-06-15 04:22:00 +08:00
|
|
|
#endif
|
|
|
|
|
2016-03-15 06:13:42 +08:00
|
|
|
#if __GNU_VISIBLE && defined(__GNUC__)
|
2011-06-11 02:30:38 +08:00
|
|
|
#define strdupa(__s) \
|
2017-07-07 16:47:02 +08:00
|
|
|
(__extension__ ({const char *__sin = (__s); \
|
|
|
|
size_t __len = strlen (__sin) + 1; \
|
|
|
|
char * __sout = (char *) __builtin_alloca (__len); \
|
|
|
|
(char *) memcpy (__sout, __sin, __len);}))
|
2011-06-11 02:30:38 +08:00
|
|
|
#define strndupa(__s, __n) \
|
2017-07-07 16:47:02 +08:00
|
|
|
(__extension__ ({const char *__sin = (__s); \
|
|
|
|
size_t __len = strnlen (__sin, (__n)) + 1; \
|
|
|
|
char *__sout = (char *) __builtin_alloca (__len); \
|
|
|
|
__sout[__len-1] = '\0'; \
|
|
|
|
(char *) memcpy (__sout, __sin, __len-1);}))
|
2016-03-15 06:13:42 +08:00
|
|
|
#endif /* __GNU_VISIBLE && __GNUC__ */
|
2011-06-11 02:30:38 +08:00
|
|
|
|
2015-04-22 16:05:16 +08:00
|
|
|
/* There are two common basename variants. If you do NOT #include <libgen.h>
|
|
|
|
and you do
|
|
|
|
|
|
|
|
#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)
|
2015-07-07 03:58:51 +08:00
|
|
|
# define basename basename
|
2017-12-04 13:54:48 +08:00
|
|
|
char *__nonnull ((1)) basename (const char *) __asm__(__ASMNAME("__gnu_basename"));
|
2015-03-26 07:19:38 +08:00
|
|
|
#endif
|
|
|
|
|
2005-01-25 02:46:09 +08:00
|
|
|
#include <sys/string.h>
|
|
|
|
|
2002-06-28 07:58:38 +08:00
|
|
|
_END_STD_C
|
|
|
|
|
2017-11-28 13:14:15 +08:00
|
|
|
#if __SSP_FORTIFY_LEVEL > 0
|
|
|
|
#include <ssp/string.h>
|
|
|
|
#endif
|
|
|
|
|
2000-02-18 03:39:52 +08:00
|
|
|
#endif /* _STRING_H_ */
|