Rev 4874 | Rev 6099 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4874 | Rev 4921 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * string.h |
2 | * string.h |
3 | * |
3 | * |
4 | * Definitions for memory and string functions. |
4 | * Definitions for memory and string functions. |
5 | */ |
5 | */ |
6 | 6 | ||
7 | #ifndef _STRING_H_ |
7 | #ifndef _STRING_H_ |
8 | #define _STRING_H_ |
8 | #define _STRING_H_ |
9 | 9 | ||
10 | #include "_ansi.h" |
10 | #include "_ansi.h" |
11 | #include |
11 | #include |
12 | #include |
12 | #include |
- | 13 | #include |
|
13 | 14 | ||
- | 15 | #define __need_size_t |
|
14 | #define __need_size_t |
16 | #define __need_NULL |
15 | #include |
- | |
16 | - | ||
17 | #ifndef NULL |
- | |
18 | #define NULL 0 |
- | |
19 | #endif |
17 | #include |
20 | 18 | ||
21 | _BEGIN_STD_C |
19 | _BEGIN_STD_C |
22 | 20 | ||
23 | _PTR _EXFUN(memchr,(const _PTR, int, size_t)); |
21 | _PTR _EXFUN(memchr,(const _PTR, int, size_t)); |
24 | int _EXFUN(memcmp,(const _PTR, const _PTR, size_t)); |
22 | int _EXFUN(memcmp,(const _PTR, const _PTR, size_t)); |
25 | _PTR _EXFUN(memcpy,(_PTR, const _PTR, size_t)); |
23 | _PTR _EXFUN(memcpy,(_PTR __restrict, const _PTR __restrict, size_t)); |
26 | _PTR _EXFUN(memmove,(_PTR, const _PTR, size_t)); |
24 | _PTR _EXFUN(memmove,(_PTR, const _PTR, size_t)); |
27 | _PTR _EXFUN(memset,(_PTR, int, size_t)); |
25 | _PTR _EXFUN(memset,(_PTR, int, size_t)); |
28 | char *_EXFUN(strcat,(char *, const char *)); |
26 | char *_EXFUN(strcat,(char *__restrict, const char *__restrict)); |
29 | char *_EXFUN(strchr,(const char *, int)); |
27 | char *_EXFUN(strchr,(const char *, int)); |
30 | int _EXFUN(strcmp,(const char *, const char *)); |
28 | int _EXFUN(strcmp,(const char *, const char *)); |
31 | int _EXFUN(strcoll,(const char *, const char *)); |
29 | int _EXFUN(strcoll,(const char *, const char *)); |
32 | char *_EXFUN(strcpy,(char *, const char *)); |
30 | char *_EXFUN(strcpy,(char *__restrict, const char *__restrict)); |
33 | size_t _EXFUN(strcspn,(const char *, const char *)); |
31 | size_t _EXFUN(strcspn,(const char *, const char *)); |
34 | char *_EXFUN(strerror,(int)); |
32 | char *_EXFUN(strerror,(int)); |
35 | size_t _EXFUN(strlen,(const char *)); |
33 | size_t _EXFUN(strlen,(const char *)); |
36 | char *_EXFUN(strncat,(char *, const char *, size_t)); |
34 | char *_EXFUN(strncat,(char *__restrict, const char *__restrict, size_t)); |
37 | int _EXFUN(strncmp,(const char *, const char *, size_t)); |
35 | int _EXFUN(strncmp,(const char *, const char *, size_t)); |
38 | char *_EXFUN(strncpy,(char *, const char *, size_t)); |
36 | char *_EXFUN(strncpy,(char *__restrict, const char *__restrict, size_t)); |
39 | char *_EXFUN(strpbrk,(const char *, const char *)); |
37 | char *_EXFUN(strpbrk,(const char *, const char *)); |
40 | char *_EXFUN(strrchr,(const char *, int)); |
38 | char *_EXFUN(strrchr,(const char *, int)); |
41 | size_t _EXFUN(strspn,(const char *, const char *)); |
39 | size_t _EXFUN(strspn,(const char *, const char *)); |
42 | char *_EXFUN(strstr,(const char *, const char *)); |
40 | char *_EXFUN(strstr,(const char *, const char *)); |
43 | 41 | ||
44 | #ifndef _REENT_ONLY |
42 | #ifndef _REENT_ONLY |
45 | char *_EXFUN(strtok,(char *, const char *)); |
43 | char *_EXFUN(strtok,(char *__restrict, const char *__restrict)); |
46 | #endif |
44 | #endif |
47 | 45 | ||
48 | size_t _EXFUN(strxfrm,(char *, const char *, size_t)); |
46 | size_t _EXFUN(strxfrm,(char *__restrict, const char *__restrict, size_t)); |
49 | 47 | ||
50 | #ifndef __STRICT_ANSI__ |
48 | #ifndef __STRICT_ANSI__ |
51 | char *_EXFUN(strtok_r,(char *, const char *, char **)); |
49 | char *_EXFUN(strtok_r,(char *__restrict, const char *__restrict, char **__restrict)); |
52 | 50 | ||
53 | int _EXFUN(bcmp,(const void *, const void *, size_t)); |
51 | int _EXFUN(bcmp,(const void *, const void *, size_t)); |
54 | void _EXFUN(bcopy,(const void *, void *, size_t)); |
52 | void _EXFUN(bcopy,(const void *, void *, size_t)); |
55 | void _EXFUN(bzero,(void *, size_t)); |
53 | void _EXFUN(bzero,(void *, size_t)); |
56 | int _EXFUN(ffs,(int)); |
54 | int _EXFUN(ffs,(int)); |
57 | char *_EXFUN(index,(const char *, int)); |
55 | char *_EXFUN(index,(const char *, int)); |
58 | _PTR _EXFUN(memccpy,(_PTR, const _PTR, int, size_t)); |
56 | _PTR _EXFUN(memccpy,(_PTR __restrict, const _PTR __restrict, int, size_t)); |
59 | _PTR _EXFUN(mempcpy,(_PTR, const _PTR, size_t)); |
57 | _PTR _EXFUN(mempcpy,(_PTR, const _PTR, size_t)); |
60 | _PTR _EXFUN(memmem, (const _PTR, size_t, const _PTR, size_t)); |
58 | _PTR _EXFUN(memmem, (const _PTR, size_t, const _PTR, size_t)); |
- | 59 | _PTR _EXFUN(memrchr,(const _PTR, int, size_t)); |
|
- | 60 | _PTR _EXFUN(rawmemchr,(const _PTR, int)); |
|
61 | char *_EXFUN(rindex,(const char *, int)); |
61 | char *_EXFUN(rindex,(const char *, int)); |
62 | char *_EXFUN(stpcpy,(char *, const char *)); |
62 | char *_EXFUN(stpcpy,(char *__restrict, const char *__restrict)); |
63 | char *_EXFUN(stpncpy,(char *, const char *, size_t)); |
63 | char *_EXFUN(stpncpy,(char *__restrict, const char *__restrict, size_t)); |
64 | int _EXFUN(strcasecmp,(const char *, const char *)); |
64 | int _EXFUN(strcasecmp,(const char *, const char *)); |
65 | char *_EXFUN(strcasestr,(const char *, const char *)); |
65 | char *_EXFUN(strcasestr,(const char *, const char *)); |
66 | char *_EXFUN(strchrnul,(const char *, int)); |
66 | char *_EXFUN(strchrnul,(const char *, int)); |
- | 67 | #endif |
|
- | 68 | #if !defined(__STRICT_ANSI__) || (_XOPEN_SOURCE - 0) >= 500 |
|
67 | char *_EXFUN(strdup,(const char *)); |
69 | char *_EXFUN(strdup,(const char *)); |
- | 70 | #endif |
|
- | 71 | #ifndef __STRICT_ANSI__ |
|
68 | char *_EXFUN(_strdup_r,(struct _reent *, const char *)); |
72 | char *_EXFUN(_strdup_r,(struct _reent *, const char *)); |
- | 73 | #endif |
|
- | 74 | #if !defined(__STRICT_ANSI__) || (_XOPEN_SOURCE - 0) >= 700 |
|
69 | char *_EXFUN(strndup,(const char *, size_t)); |
75 | char *_EXFUN(strndup,(const char *, size_t)); |
- | 76 | #endif |
|
- | 77 | #ifndef __STRICT_ANSI__ |
|
70 | char *_EXFUN(_strndup_r,(struct _reent *, const char *, size_t)); |
78 | char *_EXFUN(_strndup_r,(struct _reent *, const char *, size_t)); |
71 | /* There are two common strerror_r variants. If you request |
79 | /* There are two common strerror_r variants. If you request |
72 | _GNU_SOURCE, you get the GNU version; otherwise you get the POSIX |
80 | _GNU_SOURCE, you get the GNU version; otherwise you get the POSIX |
73 | version. POSIX requires that #undef strerror_r will still let you |
81 | version. POSIX requires that #undef strerror_r will still let you |
74 | invoke the underlying function, but that requires gcc support. */ |
82 | invoke the underlying function, but that requires gcc support. */ |
75 | #ifdef _GNU_SOURCE |
83 | #ifdef _GNU_SOURCE |
76 | char *_EXFUN(strerror_r,(int, char *, size_t)); |
84 | char *_EXFUN(strerror_r,(int, char *, size_t)); |
77 | #else |
85 | #else |
78 | # ifdef __GNUC__ |
86 | # ifdef __GNUC__ |
79 | int _EXFUN(strerror_r,(int, char *, size_t)) __asm__ (__ASMNAME ("__xpg_strerror_r")); |
87 | int _EXFUN(strerror_r,(int, char *, size_t)) __asm__ (__ASMNAME ("__xpg_strerror_r")); |
80 | # else |
88 | # else |
81 | int _EXFUN(__xpg_strerror_r,(int, char *, size_t)); |
89 | int _EXFUN(__xpg_strerror_r,(int, char *, size_t)); |
82 | # define strerror_r __xpg_strerror_r |
90 | # define strerror_r __xpg_strerror_r |
83 | # endif |
91 | # endif |
84 | #endif |
92 | #endif |
85 | size_t _EXFUN(strlcat,(char *, const char *, size_t)); |
93 | size_t _EXFUN(strlcat,(char *, const char *, size_t)); |
86 | size_t _EXFUN(strlcpy,(char *, const char *, size_t)); |
94 | size_t _EXFUN(strlcpy,(char *, const char *, size_t)); |
87 | int _EXFUN(strncasecmp,(const char *, const char *, size_t)); |
95 | int _EXFUN(strncasecmp,(const char *, const char *, size_t)); |
88 | size_t _EXFUN(strnlen,(const char *, size_t)); |
96 | size_t _EXFUN(strnlen,(const char *, size_t)); |
89 | char *_EXFUN(strsep,(char **, const char *)); |
97 | char *_EXFUN(strsep,(char **, const char *)); |
90 | char *_EXFUN(strlwr,(char *)); |
98 | char *_EXFUN(strlwr,(char *)); |
91 | char *_EXFUN(strupr,(char *)); |
99 | char *_EXFUN(strupr,(char *)); |
92 | #ifndef DEFS_H /* Kludge to work around problem compiling in gdb */ |
100 | #ifndef DEFS_H /* Kludge to work around problem compiling in gdb */ |
93 | char *_EXFUN(strsignal, (int __signo)); |
101 | char *_EXFUN(strsignal, (int __signo)); |
94 | #endif |
102 | #endif |
95 | #ifdef __CYGWIN__ |
103 | #ifdef __CYGWIN__ |
96 | int _EXFUN(strtosigno, (const char *__name)); |
104 | int _EXFUN(strtosigno, (const char *__name)); |
97 | #endif |
105 | #endif |
98 | 106 | ||
99 | /* Recursive version of strerror. */ |
107 | /* Recursive version of strerror. */ |
100 | char * _EXFUN(_strerror_r, (struct _reent *, int, int, int *)); |
108 | char * _EXFUN(_strerror_r, (struct _reent *, int, int, int *)); |
101 | 109 | ||
102 | #if defined _GNU_SOURCE && defined __GNUC__ |
110 | #if defined _GNU_SOURCE && defined __GNUC__ |
103 | #define strdupa(__s) \ |
111 | #define strdupa(__s) \ |
104 | (__extension__ ({const char *__in = (__s); \ |
112 | (__extension__ ({const char *__in = (__s); \ |
105 | size_t __len = strlen (__in) + 1; \ |
113 | size_t __len = strlen (__in) + 1; \ |
106 | char * __out = (char *) __builtin_alloca (__len); \ |
114 | char * __out = (char *) __builtin_alloca (__len); \ |
107 | (char *) memcpy (__out, __in, __len);})) |
115 | (char *) memcpy (__out, __in, __len);})) |
108 | #define strndupa(__s, __n) \ |
116 | #define strndupa(__s, __n) \ |
109 | (__extension__ ({const char *__in = (__s); \ |
117 | (__extension__ ({const char *__in = (__s); \ |
110 | size_t __len = strnlen (__in, (__n)) + 1; \ |
118 | size_t __len = strnlen (__in, (__n)) + 1; \ |
111 | char *__out = (char *) __builtin_alloca (__len); \ |
119 | char *__out = (char *) __builtin_alloca (__len); \ |
112 | __out[__len-1] = '\0'; \ |
120 | __out[__len-1] = '\0'; \ |
113 | (char *) memcpy (__out, __in, __len-1);})) |
121 | (char *) memcpy (__out, __in, __len-1);})) |
114 | #endif /* _GNU_SOURCE && __GNUC__ */ |
122 | #endif /* _GNU_SOURCE && __GNUC__ */ |
115 | 123 | ||
116 | /* These function names are used on Windows and perhaps other systems. */ |
124 | /* These function names are used on Windows and perhaps other systems. */ |
117 | #ifndef strcmpi |
125 | #ifndef strcmpi |
118 | #define strcmpi strcasecmp |
126 | #define strcmpi strcasecmp |
119 | #endif |
127 | #endif |
120 | #ifndef stricmp |
128 | #ifndef stricmp |
121 | #define stricmp strcasecmp |
129 | #define stricmp strcasecmp |
122 | #endif |
130 | #endif |
123 | #ifndef strncmpi |
131 | #ifndef strncmpi |
124 | #define strncmpi strncasecmp |
132 | #define strncmpi strncasecmp |
125 | #endif |
133 | #endif |
126 | #ifndef strnicmp |
134 | #ifndef strnicmp |
127 | #define strnicmp strncasecmp |
135 | #define strnicmp strncasecmp |
128 | #endif |
136 | #endif |
129 | 137 | ||
130 | #endif /* ! __STRICT_ANSI__ */ |
138 | #endif /* ! __STRICT_ANSI__ */ |
131 | 139 | ||
132 | #include |
140 | #include |
133 | 141 | ||
134 | _END_STD_C |
142 | _END_STD_C |
135 | 143 | ||
136 | #endif /* _STRING_H_ */ |
144 | #endif /* _STRING_H_ */ |