OSDN Git Service

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