strings.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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, write to the Free
  13. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  14. 02111-1307 USA. */
  15. #ifndef _STRINGS_H
  16. #define _STRINGS_H 1
  17. /* We don't need and should not read this file if <string.h> was already
  18. read. The one exception being that if __USE_BSD isn't defined, then
  19. these aren't defined in string.h, so we need to define them here. */
  20. /* keep this file in sync w/ string.h, the glibc version is out of date */
  21. #if !defined _STRING_H || !defined __USE_BSD
  22. # include <features.h>
  23. # define __need_size_t
  24. # include <stddef.h>
  25. __BEGIN_DECLS
  26. # ifdef __UCLIBC_SUSV3_LEGACY__
  27. /* Copy N bytes of SRC to DEST (like memmove, but args reversed). */
  28. extern void bcopy (__const void *__src, void *__dest, size_t __n)
  29. __THROW __nonnull ((1, 2));
  30. /* Set N bytes of S to 0. */
  31. extern void bzero (void *__s, size_t __n) __THROW __nonnull ((1));
  32. /* Compare N bytes of S1 and S2 (same as memcmp). */
  33. extern int bcmp (__const void *__s1, __const void *__s2, size_t __n)
  34. __THROW __attribute_pure__ __nonnull ((1, 2));
  35. /* Find the first occurrence of C in S (same as strchr). */
  36. extern char *index (__const char *__s, int __c)
  37. __THROW __attribute_pure__ __nonnull ((1));
  38. /* Find the last occurrence of C in S (same as strrchr). */
  39. extern char *rindex (__const char *__s, int __c)
  40. __THROW __attribute_pure__ __nonnull ((1));
  41. # else
  42. # ifdef __UCLIBC_SUSV3_LEGACY_MACROS__
  43. /* bcopy/bzero/bcmp/index/rindex are marked LEGACY in SuSv3.
  44. * They are replaced as proposed by SuSv3. Don't sync this part
  45. * with glibc and keep it in sync with string.h. */
  46. # define bcopy(src,dest,n) (memmove((dest), (src), (n)), (void) 0)
  47. # define bzero(s,n) (memset((s), '\0', (n)), (void) 0)
  48. # define bcmp(s1,s2,n) memcmp((s1), (s2), (size_t)(n))
  49. # define index(s,c) strchr((s), (c))
  50. # define rindex(s,c) strrchr((s), (c))
  51. # endif
  52. # endif
  53. /* Return the position of the first bit set in I, or 0 if none are set.
  54. The least-significant bit is position 1, the most-significant 32. */
  55. extern int ffs (int __i) __THROW __attribute__ ((__const__));
  56. libc_hidden_proto(ffs)
  57. /* The following two functions are non-standard but necessary for non-32 bit
  58. platforms. */
  59. # ifdef __USE_GNU
  60. extern int ffsl (long int __l) __THROW __attribute__ ((__const__));
  61. # ifdef __GNUC__
  62. __extension__ extern int ffsll (long long int __ll)
  63. __THROW __attribute__ ((__const__));
  64. # endif
  65. # endif
  66. /* Compare S1 and S2, ignoring case. */
  67. extern int strcasecmp (__const char *__s1, __const char *__s2)
  68. __THROW __attribute_pure__ __nonnull ((1, 2));
  69. libc_hidden_proto(strcasecmp)
  70. /* Compare no more than N chars of S1 and S2, ignoring case. */
  71. extern int strncasecmp (__const char *__s1, __const char *__s2, size_t __n)
  72. __THROW __attribute_pure__ __nonnull ((1, 2));
  73. libc_hidden_proto(strncasecmp)
  74. #if defined __USE_XOPEN2K8 && defined __UCLIBC_HAS_XLOCALE__
  75. /* The following functions are equivalent to the both above but they
  76. take the locale they use for the collation as an extra argument.
  77. This is not standardsized but something like will come. */
  78. # include <xlocale.h>
  79. /* Again versions of a few functions which use the given locale instead
  80. of the global one. */
  81. extern int strcasecmp_l (__const char *__s1, __const char *__s2,
  82. __locale_t __loc)
  83. __THROW __attribute_pure__ __nonnull ((1, 2, 3));
  84. libc_hidden_proto(strcasecmp_l)
  85. extern int strncasecmp_l (__const char *__s1, __const char *__s2,
  86. size_t __n, __locale_t __loc)
  87. __THROW __attribute_pure__ __nonnull ((1, 2, 4));
  88. libc_hidden_proto(strncasecmp_l)
  89. #endif
  90. __END_DECLS
  91. #ifdef _LIBC
  92. /* comment is wrong and will face this, when HAS_GNU option will be added
  93. * header is SuSv standard */
  94. #error "<strings.h> should not be included from libc."
  95. #endif
  96. #endif /* string.h */
  97. #endif /* strings.h */