strings.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /* Copyright (C) 1991,92,96,97,99,2000,2001,2009 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <http://www.gnu.org/licenses/>. */
  14. #ifndef _STRINGS_H
  15. #define _STRINGS_H 1
  16. /* We don't need and should not read this file if <string.h> was already
  17. read. The one exception being that if __USE_BSD isn't defined, then
  18. these aren't defined in string.h, so we need to define them here. */
  19. /* keep this file in sync w/ string.h, the glibc version is out of date */
  20. #if !defined _STRING_H || !defined __USE_BSD
  21. # include <features.h>
  22. # define __need_size_t
  23. # include <stddef.h>
  24. __BEGIN_DECLS
  25. # ifdef __UCLIBC_SUSV3_LEGACY__
  26. /* Copy N bytes of SRC to DEST (like memmove, but args reversed). */
  27. extern void bcopy (const void *__src, void *__dest, size_t __n)
  28. __THROW __nonnull ((1, 2));
  29. /* Set N bytes of S to 0. */
  30. extern void bzero (void *__s, size_t __n) __THROW __nonnull ((1));
  31. /* Compare N bytes of S1 and S2 (same as memcmp). */
  32. extern int bcmp (const void *__s1, const void *__s2, size_t __n)
  33. __THROW __attribute_pure__ __nonnull ((1, 2));
  34. /* Find the first occurrence of C in S (same as strchr). */
  35. extern char *index (const char *__s, int __c)
  36. __THROW __attribute_pure__ __nonnull ((1));
  37. /* Find the last occurrence of C in S (same as strrchr). */
  38. extern char *rindex (const char *__s, int __c)
  39. __THROW __attribute_pure__ __nonnull ((1));
  40. # else
  41. # ifdef __UCLIBC_SUSV3_LEGACY_MACROS__
  42. /* bcopy/bzero/bcmp/index/rindex are marked LEGACY in SuSv3.
  43. * They are replaced as proposed by SuSv3. Don't sync this part
  44. * with glibc and keep it in sync with string.h. */
  45. # define bcopy(src,dest,n) (memmove((dest), (src), (n)), (void) 0)
  46. # define bzero(s,n) (memset((s), '\0', (n)), (void) 0)
  47. # define bcmp(s1,s2,n) memcmp((s1), (s2), (size_t)(n))
  48. # define index(s,c) strchr((s), (c))
  49. # define rindex(s,c) strrchr((s), (c))
  50. # endif
  51. # endif
  52. /* Return the position of the first bit set in I, or 0 if none are set.
  53. The least-significant bit is position 1, the most-significant 32. */
  54. extern int ffs (int __i) __THROW __attribute__ ((__const__));
  55. libc_hidden_proto(ffs)
  56. /* The following two functions are non-standard but necessary for non-32 bit
  57. platforms. */
  58. # ifdef __USE_GNU
  59. extern int ffsl (long int __l) __THROW __attribute__ ((__const__));
  60. # ifdef __GNUC__
  61. __extension__ extern int ffsll (long long int __ll)
  62. __THROW __attribute__ ((__const__));
  63. # endif
  64. # endif
  65. /* Compare S1 and S2, ignoring case. */
  66. extern int strcasecmp (const char *__s1, const char *__s2)
  67. __THROW __attribute_pure__ __nonnull ((1, 2));
  68. libc_hidden_proto(strcasecmp)
  69. /* Compare no more than N chars of S1 and S2, ignoring case. */
  70. extern int strncasecmp (const char *__s1, const char *__s2, size_t __n)
  71. __THROW __attribute_pure__ __nonnull ((1, 2));
  72. libc_hidden_proto(strncasecmp)
  73. #if defined __USE_XOPEN2K8 && defined __UCLIBC_HAS_XLOCALE__
  74. /* The following functions are equivalent to the both above but they
  75. take the locale they use for the collation as an extra argument.
  76. This is not standardsized but something like will come. */
  77. # include <xlocale.h>
  78. /* Again versions of a few functions which use the given locale instead
  79. of the global one. */
  80. extern int strcasecmp_l (const char *__s1, const char *__s2,
  81. __locale_t __loc)
  82. __THROW __attribute_pure__ __nonnull ((1, 2, 3));
  83. libc_hidden_proto(strcasecmp_l)
  84. extern int strncasecmp_l (const char *__s1, const char *__s2,
  85. size_t __n, __locale_t __loc)
  86. __THROW __attribute_pure__ __nonnull ((1, 2, 4));
  87. libc_hidden_proto(strncasecmp_l)
  88. #endif
  89. __END_DECLS
  90. #ifdef _LIBC
  91. /* comment is wrong and will face this, when HAS_GNU option will be added
  92. * header is SuSv standard */
  93. #error "<strings.h> should not be included from libc."
  94. #endif
  95. #endif /* string.h */
  96. #endif /* strings.h */