string.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #ifndef __STRING_H
  2. #define __STRING_H
  3. #include <features.h>
  4. #include <sys/types.h>
  5. #include <stddef.h>
  6. /* Basic string functions */
  7. /* Return the length of S. */
  8. extern size_t strlen __P ((__const char *__s));
  9. /* Append SRC onto DEST. */
  10. extern char *strcat __P ((char *__restrict __dest,
  11. __const char *__restrict __src));
  12. /* Append no more than N characters from SRC onto DEST. */
  13. extern char *strncat __P ((char *__restrict __dest,
  14. __const char *__restrict __src, size_t __n));
  15. /* Copy SRC to DEST. */
  16. extern char *strcpy __P ((char *__restrict __dest,
  17. __const char *__restrict __src));
  18. /* Copy no more than N characters of SRC to DEST. */
  19. extern char *strncpy __P ((char *__restrict __dest,
  20. __const char *__restrict __src, size_t __n));
  21. /* Compare S1 and S2. */
  22. extern int strcmp __P ((__const char *__s1, __const char *__s2));
  23. /* Compare N characters of S1 and S2. */
  24. extern int strncmp __P ((__const char *__s1, __const char *__s2, size_t __n));
  25. /* Find the first occurrence of C in S. */
  26. extern char *strchr __P ((__const char *__s, int __c));
  27. /* Find the last occurrence of C in S. */
  28. extern char *strrchr __P ((__const char *__s, int __c));
  29. /* Duplicate S, returning an identical malloc'd string. */
  30. extern char *strdup __P ((__const char *__s));
  31. /* Basic mem functions */
  32. /* Copy N bytes of SRC to DEST. */
  33. extern __ptr_t memcpy __P ((__ptr_t __restrict __dest,
  34. __const __ptr_t __restrict __src, size_t __n));
  35. /* Copy no more than N bytes of SRC to DEST, stopping when C is found.
  36. Return the position in DEST one byte past where C was copied,
  37. or NULL if C was not found in the first N bytes of SRC. */
  38. extern __ptr_t memccpy __P ((__ptr_t __dest, __const __ptr_t __src,
  39. int __c, size_t __n));
  40. /* Search N bytes of S for C. */
  41. extern __ptr_t memchr __P ((__const __ptr_t __s, int __c, size_t __n));
  42. /* Set N bytes of S to C. */
  43. extern __ptr_t memset __P ((__ptr_t __s, int __c, size_t __n));
  44. /* Compare N bytes of S1 and S2. */
  45. extern int memcmp __P ((__const __ptr_t __s1, __const __ptr_t __s2,
  46. size_t __n));
  47. /* Copy N bytes of SRC to DEST, guaranteeing
  48. correct behavior for overlapping strings. */
  49. extern __ptr_t memmove __P ((__ptr_t __dest, __const __ptr_t __src,
  50. size_t __n));
  51. /* Minimal (very!) locale support */
  52. #define strcoll strcmp
  53. #define strxfrm strncpy
  54. /* BSDisms */
  55. #define index strchr
  56. #define rindex strrchr
  57. /* Return the position of the first bit set in I, or 0 if none are set.
  58. The least-significant bit is position 1, the most-significant 32. */
  59. extern int ffs __P ((int __i)) __attribute__ ((const));
  60. /* Other common BSD functions */
  61. /* Set N bytes of S to 0. */
  62. extern void bzero __P ((__ptr_t __s, size_t __n));
  63. /* Copy N bytes of SRC to DEST (like memmove, but args reversed). */
  64. extern void bcopy __P ((__const __ptr_t __src, __ptr_t __dest, size_t __n));
  65. /* Compare S1 and S2, ignoring case. */
  66. extern int strcasecmp __P ((__const char *__s1, __const char *__s2));
  67. /* Compare no more than N chars of S1 and S2, ignoring case. */
  68. extern int strncasecmp __P ((__const char *__s1, __const char *__s2,
  69. size_t __n));
  70. /* Find the first occurrence in S of any character in ACCEPT. */
  71. extern char *strpbrk __P ((__const char *__s, __const char *__accept));
  72. /* Return the next DELIM-delimited token from *STRINGP,
  73. terminating it with a '\0', and update *STRINGP to point past it. */
  74. extern char *strsep __P ((char **__restrict __stringp,
  75. __const char *__restrict __delim));
  76. /* Find the first occurrence of NEEDLE in HAYSTACK. */
  77. extern char *strstr __P ((__const char *__haystack, __const char *__needle));
  78. /* Divide S into tokens separated by characters in DELIM. */
  79. extern char *strtok __P ((char *__restrict __s,
  80. __const char *__restrict __delim));
  81. /* Return the length of the initial segment of S which
  82. consists entirely of characters not in REJECT. */
  83. extern size_t strcspn __P ((__const char *__s, __const char *__reject));
  84. /* Return the length of the initial segment of S which
  85. consists entirely of characters in ACCEPT. */
  86. extern size_t strspn __P ((__const char *__s, __const char *__accept));
  87. /* Return a string describing the meaning of the signal number in SIG. */
  88. extern char *strsignal __P ((int __sig));
  89. /* More BSD compatabilty */
  90. int bcmp(const void *s1, const void *s2, size_t n);
  91. /* Linux silly hour */
  92. char *strfry __P ((char *));
  93. #endif