string.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /*
  2. * string.h
  3. *
  4. * Definitions for memory and string functions.
  5. */
  6. #ifndef _STRING_H_
  7. #define _STRING_H_
  8. #include "_ansi.h"
  9. #include <sys/reent.h>
  10. #include <sys/cdefs.h>
  11. #include <sys/features.h>
  12. #define __need_size_t
  13. #define __need_NULL
  14. #include <stddef.h>
  15. #if __POSIX_VISIBLE >= 200809
  16. #include <sys/_locale.h>
  17. #endif
  18. #if __BSD_VISIBLE
  19. #include <strings.h>
  20. #endif
  21. _BEGIN_STD_C
  22. void * memchr (const void *, int, size_t);
  23. int memcmp (const void *, const void *, size_t);
  24. void * memcpy (void *__restrict, const void *__restrict, size_t);
  25. void * memmove (void *, const void *, size_t);
  26. void * memset (void *, int, size_t);
  27. char *strcat (char *__restrict, const char *__restrict);
  28. char *strchr (const char *, int);
  29. int strcmp (const char *, const char *);
  30. int strcoll (const char *, const char *);
  31. char *strcpy (char *__restrict, const char *__restrict);
  32. size_t strcspn (const char *, const char *);
  33. char *strerror (int);
  34. size_t strlen (const char *);
  35. char *strncat (char *__restrict, const char *__restrict, size_t);
  36. int strncmp (const char *, const char *, size_t);
  37. char *strncpy (char *__restrict, const char *__restrict, size_t);
  38. char *strpbrk (const char *, const char *);
  39. char *strrchr (const char *, int);
  40. size_t strspn (const char *, const char *);
  41. char *strstr (const char *, const char *);
  42. #ifndef _REENT_ONLY
  43. char *strtok (char *__restrict, const char *__restrict);
  44. #endif
  45. size_t strxfrm (char *__restrict, const char *__restrict, size_t);
  46. #if __POSIX_VISIBLE >= 200809
  47. int strcoll_l (const char *, const char *, locale_t);
  48. char *strerror_l (int, locale_t);
  49. size_t strxfrm_l (char *__restrict, const char *__restrict, size_t, locale_t);
  50. #endif
  51. #if __MISC_VISIBLE || __POSIX_VISIBLE
  52. char *strtok_r (char *__restrict, const char *__restrict, char **__restrict);
  53. #endif
  54. #if __BSD_VISIBLE
  55. int timingsafe_bcmp (const void *, const void *, size_t);
  56. int timingsafe_memcmp (const void *, const void *, size_t);
  57. #endif
  58. #if __MISC_VISIBLE || __POSIX_VISIBLE
  59. void * memccpy (void *__restrict, const void *__restrict, int, size_t);
  60. #endif
  61. #if __GNU_VISIBLE
  62. void * mempcpy (void *, const void *, size_t);
  63. void * memmem (const void *, size_t, const void *, size_t);
  64. void * memrchr (const void *, int, size_t);
  65. void * rawmemchr (const void *, int);
  66. #endif
  67. #if __POSIX_VISIBLE >= 200809
  68. char *stpcpy (char *__restrict, const char *__restrict);
  69. char *stpncpy (char *__restrict, const char *__restrict, size_t);
  70. #endif
  71. #if __GNU_VISIBLE
  72. char *strcasestr (const char *, const char *);
  73. char *strchrnul (const char *, int);
  74. #endif
  75. #if __MISC_VISIBLE || __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE >= 4
  76. char *strdup (const char *) __malloc_like __result_use_check;
  77. #endif
  78. char *_strdup_r (struct _reent *, const char *);
  79. #if __POSIX_VISIBLE >= 200809
  80. char *strndup (const char *, size_t) __malloc_like __result_use_check;
  81. #endif
  82. char *_strndup_r (struct _reent *, const char *, size_t);
  83. /* There are two common strerror_r variants. If you request
  84. _GNU_SOURCE, you get the GNU version; otherwise you get the POSIX
  85. version. POSIX requires that #undef strerror_r will still let you
  86. invoke the underlying function, but that requires gcc support. */
  87. #if __GNU_VISIBLE
  88. char *strerror_r (int, char *, size_t);
  89. #elif __POSIX_VISIBLE >= 200112
  90. # ifdef __GNUC__
  91. int strerror_r (int, char *, size_t)
  92. #ifdef __ASMNAME
  93. __asm__ (__ASMNAME ("__xpg_strerror_r"))
  94. #endif
  95. ;
  96. # else
  97. int __xpg_strerror_r (int, char *, size_t);
  98. # define strerror_r __xpg_strerror_r
  99. # endif
  100. #endif
  101. /* Reentrant version of strerror. */
  102. char * _strerror_r (struct _reent *, int, int, int *);
  103. #if __BSD_VISIBLE
  104. size_t strlcat (char *, const char *, size_t);
  105. size_t strlcpy (char *, const char *, size_t);
  106. #endif
  107. #if __POSIX_VISIBLE >= 200809
  108. size_t strnlen (const char *, size_t);
  109. #endif
  110. #if __BSD_VISIBLE
  111. char *strsep (char **, const char *);
  112. #endif
  113. #if __BSD_VISIBLE
  114. char *strnstr(const char *, const char *, size_t) __pure;
  115. #endif
  116. #if __MISC_VISIBLE
  117. char *strlwr (char *);
  118. char *strupr (char *);
  119. #endif
  120. #ifndef DEFS_H /* Kludge to work around problem compiling in gdb */
  121. char *strsignal (int __signo);
  122. #endif
  123. #ifdef __CYGWIN__
  124. int strtosigno (const char *__name);
  125. #endif
  126. #if __GNU_VISIBLE
  127. int strverscmp (const char *, const char *);
  128. #endif
  129. #if __GNU_VISIBLE && defined(__GNUC__)
  130. #define strdupa(__s) \
  131. (__extension__ ({const char *__sin = (__s); \
  132. size_t __len = strlen (__sin) + 1; \
  133. char * __sout = (char *) __builtin_alloca (__len); \
  134. (char *) memcpy (__sout, __sin, __len);}))
  135. #define strndupa(__s, __n) \
  136. (__extension__ ({const char *__sin = (__s); \
  137. size_t __len = strnlen (__sin, (__n)) + 1; \
  138. char *__sout = (char *) __builtin_alloca (__len); \
  139. __sout[__len-1] = '\0'; \
  140. (char *) memcpy (__sout, __sin, __len-1);}))
  141. #endif /* __GNU_VISIBLE && __GNUC__ */
  142. /* There are two common basename variants. If you do NOT #include <libgen.h>
  143. and you do
  144. #define _GNU_SOURCE
  145. #include <string.h>
  146. you get the GNU version. Otherwise you get the POSIX versionfor which you
  147. should #include <libgen.h>i for the function prototype. POSIX requires that
  148. #undef basename will still let you invoke the underlying function. However,
  149. this also implies that the POSIX version is used in this case. That's made
  150. sure here. */
  151. #if __GNU_VISIBLE && !defined(basename)
  152. # define basename basename
  153. char *__nonnull ((1)) basename (const char *) __asm__(__ASMNAME("__gnu_basename"));
  154. #endif
  155. #include <sys/string.h>
  156. _END_STD_C
  157. #if __SSP_FORTIFY_LEVEL > 0
  158. #include <ssp/string.h>
  159. #endif
  160. #endif /* _STRING_H_ */