source: svn/trunk/newcon3bcm2_21bu/toolchain/mips-linux-uclibc/include/string.h @ 12

Last change on this file since 12 was 2, checked in by phkim, 11 years ago

1.phkim

  1. revision copy newcon3sk r27
  • Property svn:executable set to *
File size: 15.9 KB
Line 
1/* Copyright (C) 1991-1993, 1995-2003, 2004 Free Software Foundation, Inc.
2   This file is part of the GNU C Library.
3
4   The GNU C Library is free software; you can redistribute it and/or
5   modify it under the terms of the GNU Lesser General Public
6   License as published by the Free Software Foundation; either
7   version 2.1 of the License, or (at your option) any later version.
8
9   The GNU C Library is distributed in the hope that it will be useful,
10   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12   Lesser General Public License for more details.
13
14   You should have received a copy of the GNU Lesser General Public
15   License along with the GNU C Library; if not, write to the Free
16   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17   02111-1307 USA.  */
18
19/*
20 *      ISO C99 Standard: 7.21 String handling  <string.h>
21 */
22
23#ifndef _STRING_H
24#define _STRING_H       1
25
26#include <features.h>
27
28__BEGIN_DECLS
29
30/* Get size_t and NULL from <stddef.h>.  */
31#define __need_size_t
32#define __need_NULL
33#include <stddef.h>
34
35
36__BEGIN_NAMESPACE_STD
37/* Copy N bytes of SRC to DEST.  */
38extern void *memcpy (void *__restrict __dest,
39                     __const void *__restrict __src, size_t __n)
40     __THROW __nonnull ((1, 2));
41/* Copy N bytes of SRC to DEST, guaranteeing
42   correct behavior for overlapping strings.  */
43extern void *memmove (void *__dest, __const void *__src, size_t __n)
44     __THROW __nonnull ((1, 2));
45__END_NAMESPACE_STD
46
47/* Copy no more than N bytes of SRC to DEST, stopping when C is found.
48   Return the position in DEST one byte past where C was copied,
49   or NULL if C was not found in the first N bytes of SRC.  */
50#if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN
51extern void *memccpy (void *__restrict __dest, __const void *__restrict __src,
52                      int __c, size_t __n)
53     __THROW __nonnull ((1, 2));
54#endif /* SVID.  */
55
56
57__BEGIN_NAMESPACE_STD
58/* Set N bytes of S to C.  */
59extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));
60
61/* Compare N bytes of S1 and S2.  */
62extern int memcmp (__const void *__s1, __const void *__s2, size_t __n)
63     __THROW __attribute_pure__ __nonnull ((1, 2));
64
65/* Search N bytes of S for C.  */
66extern void *memchr (__const void *__s, int __c, size_t __n)
67      __THROW __attribute_pure__ __nonnull ((1));
68__END_NAMESPACE_STD
69
70#ifdef __USE_GNU
71/* Search in S for C.  This is similar to `memchr' but there is no
72   length limit.  */
73extern void *rawmemchr (__const void *__s, int __c)
74     __THROW __attribute_pure__ __nonnull ((1));
75
76/* Search N bytes of S for the final occurrence of C.  */
77extern void *memrchr (__const void *__s, int __c, size_t __n)
78      __THROW __attribute_pure__ __nonnull ((1));
79#endif
80
81
82__BEGIN_NAMESPACE_STD
83/* Copy SRC to DEST.  */
84extern char *strcpy (char *__restrict __dest, __const char *__restrict __src)
85     __THROW __nonnull ((1, 2));
86/* Copy no more than N characters of SRC to DEST.  */
87extern char *strncpy (char *__restrict __dest,
88                      __const char *__restrict __src, size_t __n)
89     __THROW __nonnull ((1, 2));
90
91/* Append SRC onto DEST.  */
92extern char *strcat (char *__restrict __dest, __const char *__restrict __src)
93     __THROW __nonnull ((1, 2));
94/* Append no more than N characters from SRC onto DEST.  */
95extern char *strncat (char *__restrict __dest, __const char *__restrict __src,
96                      size_t __n) __THROW __nonnull ((1, 2));
97
98/* Compare S1 and S2.  */
99extern int strcmp (__const char *__s1, __const char *__s2)
100     __THROW __attribute_pure__ __nonnull ((1, 2));
101/* Compare N characters of S1 and S2.  */
102extern int strncmp (__const char *__s1, __const char *__s2, size_t __n)
103     __THROW __attribute_pure__ __nonnull ((1, 2));
104
105/* Compare the collated forms of S1 and S2.  */
106extern int strcoll (__const char *__s1, __const char *__s2)
107     __THROW __attribute_pure__ __nonnull ((1, 2));
108/* Put a transformation of SRC into no more than N bytes of DEST.  */
109extern size_t strxfrm (char *__restrict __dest,
110                       __const char *__restrict __src, size_t __n)
111     __THROW __nonnull ((2));
112__END_NAMESPACE_STD
113
114#ifdef __UCLIBC_HAS_XLOCALE__
115#ifdef __USE_GNU
116/* The following functions are equivalent to the both above but they
117   take the locale they use for the collation as an extra argument.
118   This is not standardsized but something like will come.  */
119# include <xlocale.h>
120
121/* Compare the collated forms of S1 and S2 using rules from L.  */
122extern int strcoll_l (__const char *__s1, __const char *__s2, __locale_t __l)
123     __THROW __attribute_pure__ __nonnull ((1, 2, 3));
124extern int __strcoll_l (__const char *__s1, __const char *__s2, __locale_t __l)
125     __THROW __attribute_pure__ __nonnull ((1, 2, 3));
126
127/* Put a transformation of SRC into no more than N bytes of DEST.  */
128extern size_t strxfrm_l (char *__dest, __const char *__src, size_t __n,
129                         __locale_t __l) __THROW __nonnull ((2, 4));
130extern size_t __strxfrm_l (char *__dest, __const char *__src, size_t __n,
131                         __locale_t __l) __THROW __nonnull ((2, 4));
132
133#endif
134#endif /* __UCLIBC_HAS_XLOCALE__ */
135
136#if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED
137/* Duplicate S, returning an identical malloc'd string.  */
138extern char *strdup (__const char *__s)
139     __THROW __attribute_malloc__ __nonnull ((1));
140#endif
141
142/* Return a malloc'd copy of at most N bytes of STRING.  The
143   resultant string is terminated even if no null terminator
144   appears before STRING[N].  */
145#if defined __USE_GNU
146extern char *strndup (__const char *__string, size_t __n)
147     __THROW __attribute_malloc__ __nonnull ((1));
148#endif
149
150#if defined __USE_GNU && defined __GNUC__
151/* Duplicate S, returning an identical alloca'd string.  */
152# define strdupa(s)                                                           \
153  (__extension__                                                              \
154    ({                                                                        \
155      __const char *__old = (s);                                              \
156      size_t __len = strlen (__old) + 1;                                      \
157      char *__new = (char *) __builtin_alloca (__len);                        \
158      (char *) memcpy (__new, __old, __len);                                  \
159    }))
160
161/* Return an alloca'd copy of at most N bytes of string.  */
162# define strndupa(s, n)                                                       \
163  (__extension__                                                              \
164    ({                                                                        \
165      __const char *__old = (s);                                              \
166      size_t __len = strnlen (__old, (n));                                    \
167      char *__new = (char *) __builtin_alloca (__len + 1);                    \
168      __new[__len] = '\0';                                                    \
169      (char *) memcpy (__new, __old, __len);                                  \
170    }))
171#endif
172
173__BEGIN_NAMESPACE_STD
174/* Find the first occurrence of C in S.  */
175extern char *strchr (__const char *__s, int __c)
176     __THROW __attribute_pure__ __nonnull ((1));
177/* Find the last occurrence of C in S.  */
178extern char *strrchr (__const char *__s, int __c)
179     __THROW __attribute_pure__ __nonnull ((1));
180__END_NAMESPACE_STD
181
182#ifdef __USE_GNU
183/* This function is similar to `strchr'.  But it returns a pointer to
184   the closing NUL byte in case C is not found in S.  */
185extern char *strchrnul (__const char *__s, int __c)
186     __THROW __attribute_pure__ __nonnull ((1));
187#endif
188
189__BEGIN_NAMESPACE_STD
190/* Return the length of the initial segment of S which
191   consists entirely of characters not in REJECT.  */
192extern size_t strcspn (__const char *__s, __const char *__reject)
193     __THROW __attribute_pure__ __nonnull ((1, 2));
194/* Return the length of the initial segment of S which
195   consists entirely of characters in ACCEPT.  */
196extern size_t strspn (__const char *__s, __const char *__accept)
197     __THROW __attribute_pure__ __nonnull ((1, 2));
198/* Find the first occurrence in S of any character in ACCEPT.  */
199extern char *strpbrk (__const char *__s, __const char *__accept)
200     __THROW __attribute_pure__ __nonnull ((1, 2));
201/* Find the first occurrence of NEEDLE in HAYSTACK.  */
202extern char *strstr (__const char *__haystack, __const char *__needle)
203     __THROW __attribute_pure__ __nonnull ((1, 2));
204
205
206/* Divide S into tokens separated by characters in DELIM.  */
207extern char *strtok (char *__restrict __s, __const char *__restrict __delim)
208     __THROW __nonnull ((2));
209__END_NAMESPACE_STD
210
211/* Divide S into tokens separated by characters in DELIM.  Information
212   passed between calls are stored in SAVE_PTR.  */
213extern char *__strtok_r (char *__restrict __s,
214                         __const char *__restrict __delim,
215                         char **__restrict __save_ptr)
216     __THROW __nonnull ((2, 3));
217#if defined __USE_POSIX || defined __USE_MISC
218extern char *strtok_r (char *__restrict __s, __const char *__restrict __delim,
219                       char **__restrict __save_ptr)
220     __THROW __nonnull ((2, 3));
221#endif
222
223#ifdef __USE_GNU
224/* Similar to `strstr' but this function ignores the case of both strings.  */
225extern char *strcasestr (__const char *__haystack, __const char *__needle)
226     __THROW __attribute_pure__ __nonnull ((1, 2));
227#endif
228
229#ifdef __USE_GNU
230/* Find the first occurrence of NEEDLE in HAYSTACK.
231   NEEDLE is NEEDLELEN bytes long;
232   HAYSTACK is HAYSTACKLEN bytes long.  */
233extern void *memmem (__const void *__haystack, size_t __haystacklen,
234                     __const void *__needle, size_t __needlelen)
235     __THROW __attribute_pure__ __nonnull ((1, 3));
236
237/* Copy N bytes of SRC to DEST, return pointer to bytes after the
238   last written byte.  */
239extern void *__mempcpy (void *__restrict __dest,
240                        __const void *__restrict __src, size_t __n)
241     __THROW __nonnull ((1, 2));
242extern void *mempcpy (void *__restrict __dest,
243                      __const void *__restrict __src, size_t __n)
244     __THROW __nonnull ((1, 2));
245#endif
246
247
248__BEGIN_NAMESPACE_STD
249/* Return the length of S.  */
250extern size_t strlen (__const char *__s)
251     __THROW __attribute_pure__ __nonnull ((1));
252__END_NAMESPACE_STD
253
254#ifdef  __USE_GNU
255/* Find the length of STRING, but scan at most MAXLEN characters.
256   If no '\0' terminator is found in that many characters, return MAXLEN.  */
257extern size_t strnlen (__const char *__string, size_t __maxlen)
258     __THROW __attribute_pure__ __nonnull ((1));
259#endif
260
261
262__BEGIN_NAMESPACE_STD
263/* Return a string describing the meaning of the `errno' code in ERRNUM.  */
264extern char *strerror (int __errnum) __THROW;
265__END_NAMESPACE_STD
266
267extern char *__glibc_strerror_r (int __errnum, char *__buf, size_t __buflen)
268     __THROW __nonnull ((2));
269extern int __xpg_strerror_r (int __errnum, char *__buf, size_t __buflen)
270     __THROW __nonnull ((2));
271
272#if defined __USE_XOPEN2K || defined __USE_MISC
273/* Reentrant version of `strerror'.
274   There are 2 flavors of `strerror_r', GNU which returns the string
275   and may or may not use the supplied temporary buffer and POSIX one
276   which fills the string into the buffer.
277   To use the POSIX version, -D_XOPEN_SOURCE=600 or -D_POSIX_C_SOURCE=200112L
278   without -D_GNU_SOURCE is needed, otherwise the GNU version is
279   preferred.  */
280# if defined __USE_XOPEN2K && !defined __USE_GNU
281/* Fill BUF with a string describing the meaning of the `errno' code in
282   ERRNUM.  */
283#  ifdef __REDIRECT_NTH
284extern int __REDIRECT_NTH (strerror_r,
285                           (int __errnum, char *__buf, size_t __buflen),
286                           __xpg_strerror_r) __nonnull ((2));
287#  else
288#   define strerror_r __xpg_strerror_r
289#  endif
290# else
291/* If a temporary buffer is required, at most BUFLEN bytes of BUF will be
292   used.  */
293#  ifdef __REDIRECT_NTH
294extern char * __REDIRECT_NTH (strerror_r,
295                           (int __errnum, char *__buf, size_t __buflen),
296                           __glibc_strerror_r) __nonnull ((2));
297#  else
298#   define strerror_r __glibc_strerror_r
299#  endif
300# endif
301#endif
302
303/* We define this function always since `bzero' is sometimes needed when
304   the namespace rules does not allow this.  */
305extern void __bzero (void *__s, size_t __n) __THROW __nonnull ((1));
306
307#ifdef __USE_BSD
308/* Copy N bytes of SRC to DEST (like memmove, but args reversed).  */
309extern void bcopy (__const void *__src, void *__dest, size_t __n)
310     __THROW __nonnull ((1, 2));
311
312/* Set N bytes of S to 0.  */
313extern void bzero (void *__s, size_t __n) __THROW __nonnull ((1));
314
315/* Compare N bytes of S1 and S2 (same as memcmp).  */
316extern int bcmp (__const void *__s1, __const void *__s2, size_t __n)
317     __THROW __attribute_pure__ __nonnull ((1, 2));
318
319/* Find the first occurrence of C in S (same as strchr).  */
320extern char *index (__const char *__s, int __c)
321     __THROW __attribute_pure__ __nonnull ((1));
322
323/* Find the last occurrence of C in S (same as strrchr).  */
324extern char *rindex (__const char *__s, int __c)
325     __THROW __attribute_pure__ __nonnull ((1));
326
327/* Return the position of the first bit set in I, or 0 if none are set.
328   The least-significant bit is position 1, the most-significant 32.  */
329extern int ffs (int __i) __THROW __attribute__ ((__const__));
330
331/* The following two functions are non-standard but necessary for non-32 bit
332   platforms.  */
333# ifdef __USE_GNU
334extern int ffsl (long int __l) __THROW __attribute__ ((__const__));
335#  ifdef __GNUC__
336__extension__ extern int ffsll (long long int __ll)
337     __THROW __attribute__ ((__const__));
338#  endif
339# endif
340
341/* Compare S1 and S2, ignoring case.  */
342extern int strcasecmp (__const char *__s1, __const char *__s2)
343     __THROW __attribute_pure__ __nonnull ((1, 2));
344
345/* Compare no more than N chars of S1 and S2, ignoring case.  */
346extern int strncasecmp (__const char *__s1, __const char *__s2, size_t __n)
347     __THROW __attribute_pure__ __nonnull ((1, 2));
348#endif /* Use BSD.  */
349
350#ifdef __UCLIBC_HAS_XLOCALE__
351#ifdef  __USE_GNU
352/* Again versions of a few functions which use the given locale instead
353   of the global one.  */
354extern int strcasecmp_l (__const char *__s1, __const char *__s2,
355                         __locale_t __loc)
356     __THROW __attribute_pure__ __nonnull ((1, 2, 3));
357extern int __strcasecmp_l (__const char *__s1, __const char *__s2,
358                         __locale_t __loc)
359     __THROW __attribute_pure__ __nonnull ((1, 2, 3));
360
361extern int strncasecmp_l (__const char *__s1, __const char *__s2,
362                          size_t __n, __locale_t __loc)
363     __THROW __attribute_pure__ __nonnull ((1, 2, 4));
364extern int __strncasecmp_l (__const char *__s1, __const char *__s2,
365                          size_t __n, __locale_t __loc)
366     __THROW __attribute_pure__ __nonnull ((1, 2, 4));
367#endif
368#endif /* __UCLIBC_HAS_XLOCALE__ */
369
370#ifdef  __USE_BSD
371/* Return the next DELIM-delimited token from *STRINGP,
372   terminating it with a '\0', and update *STRINGP to point past it.  */
373extern char *strsep (char **__restrict __stringp,
374                     __const char *__restrict __delim)
375     __THROW __nonnull ((1, 2));
376#endif
377
378#ifdef  __USE_GNU
379/* Compare S1 and S2 as strings holding name & indices/version numbers.  */
380extern int strverscmp (__const char *__s1, __const char *__s2)
381     __THROW __attribute_pure__ __nonnull ((1, 2));
382
383/* Return a string describing the meaning of the signal number in SIG.  */
384extern char *strsignal (int __sig) __THROW;
385
386/* Copy SRC to DEST, returning the address of the terminating '\0' in DEST.  */
387extern char *__stpcpy (char *__restrict __dest, __const char *__restrict __src)
388     __THROW __nonnull ((1, 2));
389extern char *stpcpy (char *__restrict __dest, __const char *__restrict __src)
390     __THROW __nonnull ((1, 2));
391
392/* Copy no more than N characters of SRC to DEST, returning the address of
393   the last character written into DEST.  */
394extern char *__stpncpy (char *__restrict __dest,
395                        __const char *__restrict __src, size_t __n)
396     __THROW __nonnull ((1, 2));
397extern char *stpncpy (char *__restrict __dest,
398                      __const char *__restrict __src, size_t __n)
399     __THROW __nonnull ((1, 2));
400
401#if 0                                                   /* uClibc does not support strfry or memfrob. */
402/* Sautee STRING briskly.  */
403extern char *strfry (char *__string) __THROW __nonnull ((1));
404
405/* Frobnicate N bytes of S.  */
406extern void *memfrob (void *__s, size_t __n) __THROW __nonnull ((1));
407#endif
408
409# ifndef basename
410/* Return the file name within directory of FILENAME.  We don't
411   declare the function if the `basename' macro is available (defined
412   in <libgen.h>) which makes the XPG version of this function
413   available.  */
414extern char *basename (__const char *__filename) __THROW __nonnull ((1));
415# endif
416#endif
417
418
419#ifdef  __USE_BSD
420/* Two OpenBSD extension functions. */
421extern size_t strlcat(char *__restrict dst, const char *__restrict src,
422                      size_t n) __THROW __nonnull ((1, 2));
423extern size_t strlcpy(char *__restrict dst, const char *__restrict src,
424                      size_t n) __THROW __nonnull ((1, 2));
425#endif
426
427__END_DECLS
428
429#endif /* string.h  */
Note: See TracBrowser for help on using the repository browser.