| 2875 |
dpurdie |
1 |
#pragma force_top_level
|
|
|
2 |
#pragma include_only_once
|
|
|
3 |
|
|
|
4 |
/* string.h: ANSI 'C' (X3J11 Oct 88) library header, section 4.11 */
|
|
|
5 |
/* Copyright (C) Codemist Ltd., 1988-1993. */
|
|
|
6 |
/* Copyright (C) Advanced Risc Machines Ltd., 1991-1993. */
|
|
|
7 |
/* version 0.04 */
|
|
|
8 |
|
|
|
9 |
/*
|
|
|
10 |
* RCS $Revision: 1.4 $
|
|
|
11 |
* Checkin $Date: 1998/01/09 11:36:51 $
|
|
|
12 |
*/
|
|
|
13 |
|
|
|
14 |
/*
|
|
|
15 |
* string.h declares one type and several functions, and defines one macro
|
|
|
16 |
* useful for manipulating character arrays and other objects treated as
|
|
|
17 |
* character arrays. Various methods are used for determining the lengths of
|
|
|
18 |
* the arrays, but in all cases a char * or void * argument points to the
|
|
|
19 |
* initial (lowest addresses) character of the array. If an array is written
|
|
|
20 |
* beyond the end of an object, the behaviour is undefined.
|
|
|
21 |
*/
|
|
|
22 |
|
|
|
23 |
#ifndef __string_h
|
|
|
24 |
#define __string_h
|
|
|
25 |
|
|
|
26 |
#ifdef __cplusplus
|
|
|
27 |
extern "C" {
|
|
|
28 |
#endif
|
|
|
29 |
|
|
|
30 |
#ifndef __size_t
|
|
|
31 |
#define __size_t 1
|
|
|
32 |
typedef unsigned int size_t; /* from <stddef.h> */
|
|
|
33 |
#endif
|
|
|
34 |
|
|
|
35 |
#ifndef NULL
|
|
|
36 |
# define NULL 0
|
|
|
37 |
#endif
|
|
|
38 |
|
|
|
39 |
extern void *memcpy(void * /*s1*/, const void * /*s2*/, size_t /*n*/);
|
|
|
40 |
/*
|
|
|
41 |
* copies n characters from the object pointed to by s2 into the object
|
|
|
42 |
* pointed to by s1. If copying takes place between objects that overlap,
|
|
|
43 |
* the behaviour is undefined.
|
|
|
44 |
* Returns: the value of s1.
|
|
|
45 |
*/
|
|
|
46 |
extern void *memmove(void * /*s1*/, const void * /*s2*/, size_t /*n*/);
|
|
|
47 |
/*
|
|
|
48 |
* copies n characters from the object pointed to by s2 into the object
|
|
|
49 |
* pointed to by s1. Copying takes place as if the n characters from the
|
|
|
50 |
* object pointed to by s2 are first copied into a temporary array of n
|
|
|
51 |
* characters that does not overlap the objects pointed to by s1 and s2,
|
|
|
52 |
* and then the n characters from the temporary array are copied into the
|
|
|
53 |
* object pointed to by s1.
|
|
|
54 |
* Returns: the value of s1.
|
|
|
55 |
*/
|
|
|
56 |
extern char *strcpy(char * /*s1*/, const char * /*s2*/);
|
|
|
57 |
/*
|
|
|
58 |
* copies the string pointed to by s2 (including the terminating nul
|
|
|
59 |
* character) into the array pointed to by s1. If copying takes place
|
|
|
60 |
* between objects that overlap, the behaviour is undefined.
|
|
|
61 |
* Returns: the value of s1.
|
|
|
62 |
*/
|
|
|
63 |
extern char *strncpy(char * /*s1*/, const char * /*s2*/, size_t /*n*/);
|
|
|
64 |
/*
|
|
|
65 |
* copies not more than n characters (characters that follow a null
|
|
|
66 |
* character are not copied) from the array pointed to by s2 into the array
|
|
|
67 |
* pointed to by s1. If copying takes place between objects that overlap,
|
|
|
68 |
* the behaviour is undefined.
|
|
|
69 |
* Returns: the value of s1.
|
|
|
70 |
*/
|
|
|
71 |
|
|
|
72 |
extern char *strcat(char * /*s1*/, const char * /*s2*/);
|
|
|
73 |
/*
|
|
|
74 |
* appends a copy of the string pointed to by s2 (including the terminating
|
|
|
75 |
* null character) to the end of the string pointed to by s1. The initial
|
|
|
76 |
* character of s2 overwrites the null character at the end of s1.
|
|
|
77 |
* Returns: the value of s1.
|
|
|
78 |
*/
|
|
|
79 |
extern char *strncat(char * /*s1*/, const char * /*s2*/, size_t /*n*/);
|
|
|
80 |
/*
|
|
|
81 |
* appends not more than n characters (a null character and characters that
|
|
|
82 |
* follow it are not appended) from the array pointed to by s2 to the end of
|
|
|
83 |
* the string pointed to by s1. The initial character of s2 overwrites the
|
|
|
84 |
* null character at the end of s1. A terminating null character is always
|
|
|
85 |
* appended to the result.
|
|
|
86 |
* Returns: the value of s1.
|
|
|
87 |
*/
|
|
|
88 |
|
|
|
89 |
/*
|
|
|
90 |
* The sign of a nonzero value returned by the comparison functions is
|
|
|
91 |
* determined by the sign of the difference between the values of the first
|
|
|
92 |
* pair of characters (both interpreted as unsigned char) that differ in the
|
|
|
93 |
* objects being compared.
|
|
|
94 |
*/
|
|
|
95 |
|
|
|
96 |
extern int memcmp(const void * /*s1*/, const void * /*s2*/, size_t /*n*/);
|
|
|
97 |
/*
|
|
|
98 |
* compares the first n characters of the object pointed to by s1 to the
|
|
|
99 |
* first n characters of the object pointed to by s2.
|
|
|
100 |
* Returns: an integer greater than, equal to, or less than zero, according
|
|
|
101 |
* as the object pointed to by s1 is greater than, equal to, or
|
|
|
102 |
* less than the object pointed to by s2.
|
|
|
103 |
*/
|
|
|
104 |
extern int strcmp(const char * /*s1*/, const char * /*s2*/);
|
|
|
105 |
/*
|
|
|
106 |
* compares the string pointed to by s1 to the string pointed to by s2.
|
|
|
107 |
* Returns: an integer greater than, equal to, or less than zero, according
|
|
|
108 |
* as the string pointed to by s1 is greater than, equal to, or
|
|
|
109 |
* less than the string pointed to by s2.
|
|
|
110 |
*/
|
|
|
111 |
extern int strncmp(const char * /*s1*/, const char * /*s2*/, size_t /*n*/);
|
|
|
112 |
/*
|
|
|
113 |
* compares not more than n characters (characters that follow a null
|
|
|
114 |
* character are not compared) from the array pointed to by s1 to the array
|
|
|
115 |
* pointed to by s2.
|
|
|
116 |
* Returns: an integer greater than, equal to, or less than zero, according
|
|
|
117 |
* as the string pointed to by s1 is greater than, equal to, or
|
|
|
118 |
* less than the string pointed to by s2.
|
|
|
119 |
*/
|
|
|
120 |
extern int strcoll(const char * /*s1*/, const char * /*s2*/);
|
|
|
121 |
/*
|
|
|
122 |
* compares the string pointed to by s1 to the string pointed to by s2, both
|
|
|
123 |
* interpreted as appropriate to the LC_COLLATE category of the current
|
|
|
124 |
* locale.
|
|
|
125 |
* Returns: an integer greater than, equal to, or less than zero, according
|
|
|
126 |
* as the string pointed to by s1 is greater than, equal to, or
|
|
|
127 |
* less than the string pointed to by s2 when both are interpreted
|
|
|
128 |
* as appropriate to the current locale.
|
|
|
129 |
*/
|
|
|
130 |
|
|
|
131 |
extern size_t strxfrm(char * /*s1*/, const char * /*s2*/, size_t /*n*/);
|
|
|
132 |
/*
|
|
|
133 |
* transforms the string pointed to by s2 and places the resulting string
|
|
|
134 |
* into the array pointed to by s1. The transformation function is such that
|
|
|
135 |
* if the strcmp function is applied to two transformed strings, it returns
|
|
|
136 |
* a value greater than, equal to or less than zero, corresponding to the
|
|
|
137 |
* result of the strcoll function applied to the same two original strings.
|
|
|
138 |
* No more than n characters are placed into the resulting array pointed to
|
|
|
139 |
* by s1, including the terminating null character. If n is zero, s1 is
|
|
|
140 |
* permitted to be a null pointer. If copying takes place between objects
|
|
|
141 |
* that overlap, the behaviour is undefined.
|
|
|
142 |
* Returns: The length of the transformed string is returned (not including
|
|
|
143 |
* the terminating null character). If the value returned is n or
|
|
|
144 |
* more, the contents of the array pointed to by s1 are
|
|
|
145 |
* indeterminate.
|
|
|
146 |
*/
|
|
|
147 |
|
|
|
148 |
|
|
|
149 |
#ifdef __cplusplus
|
|
|
150 |
extern const char *memchr(const void * /*s*/, int /*c*/, size_t /*n*/);
|
|
|
151 |
extern "C++" inline char *memchr(void * __s, int __c, size_t __n)
|
|
|
152 |
{ return /*const_cast<char *>*/(char *)(
|
|
|
153 |
memchr(/*const_cast<const void *>*/(const void *)(__s), __c, __n)); }
|
|
|
154 |
#else
|
|
|
155 |
extern void *memchr(const void * /*s*/, int /*c*/, size_t /*n*/);
|
|
|
156 |
#endif
|
|
|
157 |
/*
|
|
|
158 |
* locates the first occurence of c (converted to an unsigned char) in the
|
|
|
159 |
* initial n characters (each interpreted as unsigned char) of the object
|
|
|
160 |
* pointed to by s.
|
|
|
161 |
* Returns: a pointer to the located character, or a null pointer if the
|
|
|
162 |
* character does not occur in the object.
|
|
|
163 |
*/
|
|
|
164 |
|
|
|
165 |
#ifdef __cplusplus
|
|
|
166 |
extern const char *strchr(const char * /*s*/, int /*c*/);
|
|
|
167 |
extern "C++" inline char *strchr(char * __s, int __c)
|
|
|
168 |
{ return /*const_cast<char *>*/(char *)(
|
|
|
169 |
strchr(/*const_cast<const char *>*/(const char *)(__s), __c)); }
|
|
|
170 |
#else
|
|
|
171 |
extern char *strchr(const char * /*s*/, int /*c*/);
|
|
|
172 |
#endif
|
|
|
173 |
/*
|
|
|
174 |
* locates the first occurence of c (converted to an char) in the string
|
|
|
175 |
* pointed to by s (including the terminating null character).
|
|
|
176 |
* Returns: a pointer to the located character, or a null pointer if the
|
|
|
177 |
* character does not occur in the string.
|
|
|
178 |
*/
|
|
|
179 |
|
|
|
180 |
extern size_t strcspn(const char * /*s1*/, const char * /*s2*/);
|
|
|
181 |
/*
|
|
|
182 |
* computes the length of the initial segment of the string pointed to by s1
|
|
|
183 |
* which consists entirely of characters not from the string pointed to by
|
|
|
184 |
* s2. The terminating null character is not considered part of s2.
|
|
|
185 |
* Returns: the length of the segment.
|
|
|
186 |
*/
|
|
|
187 |
|
|
|
188 |
#ifdef __cplusplus
|
|
|
189 |
extern const char *strpbrk(const char * /*s1*/, const char * /*s2*/);
|
|
|
190 |
extern "C++" inline char *strpbrk(char * __s1, const char * __s2)
|
|
|
191 |
{ return /*const_cast<char *>*/(char *)(
|
|
|
192 |
strpbrk(/*const_cast<const char *>*/(const char *)(__s1), __s2)); }
|
|
|
193 |
#else
|
|
|
194 |
extern char *strpbrk(const char * /*s1*/, const char * /*s2*/);
|
|
|
195 |
#endif
|
|
|
196 |
/*
|
|
|
197 |
* locates the first occurence in the string pointed to by s1 of any
|
|
|
198 |
* character from the string pointed to by s2.
|
|
|
199 |
* Returns: returns a pointer to the character, or a null pointer if no
|
|
|
200 |
* character form s2 occurs in s1.
|
|
|
201 |
*/
|
|
|
202 |
|
|
|
203 |
#ifdef __cplusplus
|
|
|
204 |
extern const char *strrchr(const char * /*s*/, int /*c*/);
|
|
|
205 |
extern "C++" inline char *strrchr(char * __s, int __c)
|
|
|
206 |
{ return /*const_cast<char *>*/(char *)(
|
|
|
207 |
strrchr(/*const_cast<const char *>*/(const char *)(__s), __c)); }
|
|
|
208 |
#else
|
|
|
209 |
extern char *strrchr(const char * /*s*/, int /*c*/);
|
|
|
210 |
#endif
|
|
|
211 |
/*
|
|
|
212 |
* locates the last occurence of c (converted to a char) in the string
|
|
|
213 |
* pointed to by s. The terminating null character is considered part of
|
|
|
214 |
* the string.
|
|
|
215 |
* Returns: returns a pointer to the character, or a null pointer if c does
|
|
|
216 |
* not occur in the string.
|
|
|
217 |
*/
|
|
|
218 |
|
|
|
219 |
extern size_t strspn(const char * /*s1*/, const char * /*s2*/);
|
|
|
220 |
/*
|
|
|
221 |
* computes the length of the initial segment of the string pointed to by s1
|
|
|
222 |
* which consists entirely of characters from the string pointed to by S2
|
|
|
223 |
* Returns: the length of the segment.
|
|
|
224 |
*/
|
|
|
225 |
|
|
|
226 |
#ifdef __cplusplus
|
|
|
227 |
extern const char *strstr(const char * /*s1*/, const char * /*s2*/);
|
|
|
228 |
extern "C++" inline char *strstr(char * __s1, const char * __s2)
|
|
|
229 |
{ return /*const_cast<char *>*/(char *)(
|
|
|
230 |
strstr(/*const_cast<const char *>*/(const char *)(__s1), __s2)); }
|
|
|
231 |
#else
|
|
|
232 |
extern char *strstr(const char * /*s1*/, const char * /*s2*/);
|
|
|
233 |
#endif
|
|
|
234 |
/*
|
|
|
235 |
* locates the first occurence in the string pointed to by s1 of the
|
|
|
236 |
* sequence of characters (excluding the terminating null character) in the
|
|
|
237 |
* string pointed to by s2.
|
|
|
238 |
* Returns: a pointer to the located string, or a null pointer if the string
|
|
|
239 |
* is not found.
|
|
|
240 |
*/
|
|
|
241 |
|
|
|
242 |
extern char *strtok(char * /*s1*/, const char * /*s2*/);
|
|
|
243 |
/*
|
|
|
244 |
* A sequence of calls to the strtok function breaks the string pointed to
|
|
|
245 |
* by s1 into a sequence of tokens, each of which is delimited by a
|
|
|
246 |
* character from the string pointed to by s2. The first call in the
|
|
|
247 |
* sequence has s1 as its first argument, and is followed by calls with a
|
|
|
248 |
* null pointer as their first argument. The separator string pointed to by
|
|
|
249 |
* s2 may be different from call to call.
|
|
|
250 |
* The first call in the sequence searches for the first character that is
|
|
|
251 |
* not contained in the current separator string s2. If no such character
|
|
|
252 |
* is found, then there are no tokens in s1 and the strtok function returns
|
|
|
253 |
* a null pointer. If such a character is found, it is the start of the
|
|
|
254 |
* first token.
|
|
|
255 |
* The strtok function then searches from there for a character that is
|
|
|
256 |
* contained in the current separator string. If no such character is found,
|
|
|
257 |
* the current token extends to the end of the string pointed to by s1, and
|
|
|
258 |
* subsequent searches for a token will fail. If such a character is found,
|
|
|
259 |
* it is overwritten by a null character, which terminates the current
|
|
|
260 |
* token. The strtok function saves a pointer to the following character,
|
|
|
261 |
* from which the next search for a token will start.
|
|
|
262 |
* Each subsequent call, with a null pointer as the value for the first
|
|
|
263 |
* argument, starts searching from the saved pointer and behaves as
|
|
|
264 |
* described above.
|
|
|
265 |
* Returns: pointer to the first character of a token, or a null pointer if
|
|
|
266 |
* there is no token.
|
|
|
267 |
*/
|
|
|
268 |
|
|
|
269 |
extern void *memset(void * /*s*/, int /*c*/, size_t /*n*/);
|
|
|
270 |
/*
|
|
|
271 |
* copies the value of c (converted to an unsigned char) into each of the
|
|
|
272 |
* first n charactes of the object pointed to by s.
|
|
|
273 |
* Returns: the value of s.
|
|
|
274 |
*/
|
|
|
275 |
extern char *strerror(int /*errnum*/);
|
|
|
276 |
/*
|
|
|
277 |
* maps the error number in errnum to an error message string.
|
|
|
278 |
* Returns: a pointer to the string, the contents of which are
|
|
|
279 |
* implementation-defined (under RISCOS/Arthur/Brazil the strings
|
|
|
280 |
* for the given ernums are as follows
|
|
|
281 |
* 0 "No error (errno = 0)"
|
|
|
282 |
* EDOM "EDOM - function argument out of range"
|
|
|
283 |
* ERANGE "ERANGE - function result not representable"
|
|
|
284 |
* ESIGNUM "ESIGNUM - illegal signal number to signal() or raise()"
|
|
|
285 |
* others "Error code (errno) %d has no associated message"
|
|
|
286 |
* ). The array pointed to shall not be
|
|
|
287 |
* modified by the program, but may be overwritten by a subsequent
|
|
|
288 |
* call to the strerror function.
|
|
|
289 |
*/
|
|
|
290 |
extern size_t strlen(const char * /*s*/);
|
|
|
291 |
/*
|
|
|
292 |
* computes the length of the string pointed to by s.
|
|
|
293 |
* Returns: the number of characters that precede the terminating null
|
|
|
294 |
* character.
|
|
|
295 |
*/
|
|
|
296 |
|
|
|
297 |
#ifdef __cplusplus
|
|
|
298 |
}
|
|
|
299 |
#endif
|
|
|
300 |
|
|
|
301 |
#endif
|
|
|
302 |
|
|
|
303 |
/* end of string.h */
|