strings.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /* Copyright (C) 1991,92,96,97,99,2000,2001 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. /* The following two functions are non-standard but necessary for non-32 bit
  57. platforms. */
  58. #if 0 /*def __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. /* Compare no more than N chars of S1 and S2, ignoring case. */
  69. extern int strncasecmp (__const char *__s1, __const char *__s2, size_t __n)
  70. __THROW __attribute_pure__ __nonnull ((1, 2));
  71. __END_DECLS
  72. #ifdef UCLIBC_INTERNAL
  73. #error "<strings.h> should not be included from libc."
  74. #endif
  75. #endif /* string.h */
  76. #endif /* strings.h */