home *** CD-ROM | disk | FTP | other *** search
/ RISCWORLD 7 / RISCWORLD_VOL7.iso / Software / Issue6 / SDL.ZIP / !gcc / include / unixlib / h / string < prev    next >
Encoding:
Text File  |  2006-09-17  |  9.6 KB  |  276 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /usr/local/cvsroot/gccsdk/unixlib/source/clib/string.h,v $
  4.  * $Date: 2004/12/25 10:28:13 $
  5.  * $Revision: 1.14 $
  6.  * $State: Exp $
  7.  * $Author: peter $
  8.  *
  9.  ***************************************************************************/
  10.  
  11. /* ANSI Standard 4.11: String Handling <string.h>.  */
  12.  
  13. #ifndef __STRING_H
  14. #define __STRING_H 1
  15.  
  16. #ifndef __UNIXLIB_FEATURES_H
  17. #include <features.h>
  18. #endif
  19.  
  20. #define __need_size_t
  21. #define __need_NULL
  22. #include <stddef.h>
  23.  
  24. __BEGIN_DECLS
  25.  
  26. __BEGIN_NAMESPACE_STD
  27.  
  28. /* Copy n bytes from src to dest.  */
  29. extern void *memcpy (void *__restrict __dest, const void *__restrict __src,
  30.              size_t __n) __THROW __nonnull ((1, 2));
  31.  
  32. /* Copy n bytes from src to dest, guaranteeing correct
  33.    behaviour for overlapping data.  */
  34. extern void *memmove (void *__dest, const void *__src, size_t __n)
  35.      __THROW __nonnull ((1, 2));
  36.  
  37. /* Set n bytes of s to c.  */
  38. extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));
  39.  
  40. /* Compare n bytes of s1 and s2.  */
  41. extern int memcmp (const void *__s1, const void *__s2, size_t __n)
  42.      __THROW __attribute_pure__ __nonnull ((1, 2)) __wur;
  43.  
  44. /* Search n bytes of s for c.  */
  45. extern void *memchr (const void *__s, int __c, size_t __n)
  46.      __THROW __attribute_pure__ __nonnull ((1)) __wur;
  47. __END_NAMESPACE_STD
  48.  
  49. #ifdef __USE_GNU
  50. /* Search in S for C.  This is similar to `memchr' but there is no
  51.    length limit.  */
  52. extern void *rawmemchr (__const void *__s, int __c)
  53.      __THROW __attribute_pure__ __nonnull ((1)) __wur;
  54.  
  55. /* Search N bytes of S for the final occurrence of C.  */
  56. #define __memrchr memrchr
  57. extern void *memrchr (__const void *__s, int __c, size_t __n)
  58.       __THROW __attribute_pure__ __nonnull ((1)) __wur;
  59. #endif
  60.  
  61.  
  62. __BEGIN_NAMESPACE_STD
  63. /* Copy SRC to DEST.  */
  64. extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
  65.      __THROW __nonnull ((1, 2));
  66.  
  67. /* Copy no more than n chars of src to dest.  */
  68. extern char *strncpy (char *__restrict __dest, const char *__restrict __src,
  69.               size_t __n) __THROW __nonnull ((1, 2));
  70.  
  71. /* Append SRC onto DEST.  */
  72. extern char *strcat (char *__restrict __dest, const char *__restrict __src)
  73.      __THROW __nonnull ((1, 2));
  74.  
  75. /* Append no more than n chars from src to dest. */
  76. extern char *strncat (char *__restrict __dest, const char *__restrict __src,
  77.               size_t __n) __THROW __nonnull ((1, 2));
  78.  
  79. /* Compare S1 and S2.  */
  80. extern int strcmp (const char *__s1, __const char *__s2)
  81.      __THROW __attribute_pure__ __nonnull ((1, 2)) __wur;
  82.  
  83. /* Compare N characters of S1 and S2.  */
  84. extern int strncmp (const char *__s1, __const char *__s2, size_t __n)
  85.      __THROW __attribute_pure__ __nonnull ((1, 2)) __wur;
  86.  
  87. /* Compare the collated forms of S1 and S2.  */
  88. extern int strcoll (const char *__s1, __const char *__s2)
  89.      __THROW __attribute_pure__ __nonnull ((1, 2)) __wur;
  90.  
  91. /* Put a transformation of SRC into no more than N bytes of DEST.  */
  92. extern size_t strxfrm (char *__restrict __dest,
  93.                const char *__restrict __src, size_t __n)
  94.      __THROW __nonnull ((2));
  95.  
  96. /* Find the first occurrence of c in s. */
  97. extern char *strchr (const char *__s, int __c)
  98.      __THROW __attribute_pure__ __nonnull ((1)) __wur;
  99.  
  100. /* Find the last occurrence of c in s.  */
  101. extern char *strrchr (const char *__s, int __c)
  102.      __THROW __attribute_pure__ __nonnull ((1)) __wur;
  103.  
  104. /* Return the length of the initial segment of s that consists
  105.    entirely of chars in accept.  */
  106. extern size_t strspn (const char *__s, const char *__accept)
  107.      __THROW __attribute_pure__ __nonnull ((1, 2)) __wur;
  108.  
  109. /* Return the length of the initial segment of s that consists
  110.    entirely of chars not in reject.  */
  111. extern size_t strcspn (const char *__s, const char *__reject)
  112.      __THROW __attribute_pure__ __nonnull ((1, 2)) __wur;
  113.  
  114. /* Find the first occurence in s of any char in accept.  */
  115. extern char *strpbrk (const char *__s, const char *__accept)
  116.      __THROW __attribute_pure__ __nonnull ((1, 2)) __wur;
  117.  
  118. /* Find the first occurrence of s in s1.  */
  119. extern char *strstr (const char *__s, const char *__s1)
  120.      __THROW __attribute_pure__ __nonnull ((1, 2)) __wur;
  121.  
  122. /* Divide s into tokens separated by chars in delim.  */
  123. extern char *strtok (char *__restrict __s, const char *__restrict __delim)
  124.      __THROW __nonnull ((2)) __wur;
  125.  
  126. __END_NAMESPACE_STD
  127.  
  128. #if defined __USE_POSIX || defined __USE_MISC
  129. /* Re-entrant version of strtok.  */
  130. extern char *strtok_r (char *__restrict __s, const char *__restrict __delim,
  131.                char **__restrict __save_ptr)
  132.      __THROW __nonnull ((2, 3));
  133. #endif
  134.  
  135. __BEGIN_NAMESPACE_STD
  136. /* Return the length of s. */
  137. extern size_t strlen (const char *__s)
  138.      __THROW __attribute_pure__ __nonnull ((1)) __wur;
  139.  
  140. #ifdef __USE_GNU
  141. /* Find the length of STRING, but scan at most MAXLEN characters.
  142.    If no '\0' terminator is found in that many characters, return MAXLEN.  */
  143. extern size_t strnlen (const char *__string, size_t __maxlen)
  144.      __THROW __attribute_pure__ __nonnull ((1)) __wur;
  145. #endif
  146.  
  147. __END_NAMESPACE_STD
  148.  
  149. /* Compare S1 and S2, ignoring case.  */
  150. extern int stricmp (const char *, const char *) __THROW __wur;
  151.  
  152. /* Compare n chars of S1 and S2, ignoring case.  */
  153. extern int strnicmp (const char *, const char *, size_t) __THROW __wur;
  154.  
  155. extern char *strichr (const char *, int) __THROW __wur;
  156. extern char *strrichr (const char *, int) __THROW __wur;
  157.  
  158. #ifdef __USE_GNU
  159. /* Copy src to dest return a pointer to the terminating null
  160.    character of dest.  */
  161. extern char *stpcpy (char *__restrict __dest, const char *__restrict __src)
  162.      __THROW __nonnull ((1, 2));
  163.  
  164. /* Copy no more than n chars of src to dest. Return a pointer
  165.    to the terminating null character of dest. */
  166. extern char *stpncpy (char *__restrict __dest, const char *__restrict __src,
  167.               size_t __n) __THROW __nonnull ((1, 2));
  168. #endif
  169.  
  170.  
  171. /* BSD enhancements.  */
  172.  
  173. #if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN
  174. /* Copy no more than n bytes of src to dest, stopping when c is found.
  175.    Return the position in dest one byte past where c was copied,
  176.    or null if C was not in the string.  */
  177. extern void *memccpy (void *__dest, const void *__src, int __c, size_t __n)
  178.      __THROW __nonnull ((1, 2));
  179. #endif
  180.  
  181. #if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED
  182. /* Duplicate s, returning an identical malloc'd string.  */
  183. extern char *strdup (const char *__s)
  184.      __THROW __attribute_malloc__ __nonnull ((1)) __wur;
  185. #endif
  186.  
  187. #ifdef __USE_BSD
  188. /* Return the next DELIM-delimited token from *STRINGP,
  189.    terminating it with a '\0', and update *STRINGP to point past it.  */
  190. extern char *strsep (char **__restrict __stringp,
  191.              const char *__restrict __delim)
  192.      __THROW __nonnull ((1, 2)) __wur;
  193. #endif
  194.  
  195. /* GNU enhancements.  */
  196.  
  197. #ifdef __USE_GNU
  198. /* This function is similar to `strdup' but always copies at most
  199.    __n characters into the newly allocated string.
  200.  
  201.    If the length of __s is more than __n, then `strndup' copies just
  202.    the first __n characters and adds a closing null terminator.
  203.    Otherwise all characters are copied and the string is terminated.
  204.  
  205.    This function is different to `strncpy' in that it always
  206.    terminates the destination string.  */
  207. extern char *strndup (const char *__s, size_t __n)
  208.      __THROW __attribute_malloc__ __nonnull ((1)) __wur;
  209.  
  210. #endif
  211.  
  212. /* This function is similar to `strchr'.  But it returns a pointer to
  213.    the closing NUL byte in case C is not found in S.  */
  214. extern char *strchrnul (const char *__s, int __c)
  215.      __THROW __attribute_pure__ __nonnull ((1)) __wur;
  216.  
  217. /* Return a string describing the meaning of the signal number sig.  */
  218. extern char *strsignal (int __sig) __THROW __wur;
  219.  
  220. __BEGIN_NAMESPACE_STD
  221. /* Return the descriptive error message string for an error code.  */
  222. extern char *strerror (int __errnum) __THROW __wur;
  223. __END_NAMESPACE_STD
  224.  
  225. /* Set N bytes of S to 0.  */
  226. extern void bzero (void *__s, size_t __n) __THROW __nonnull ((1));
  227.  
  228. #if defined __USE_BSD
  229. /* Copy N bytes of SRC to DEST (like memmove, but args reversed).  */
  230. extern void bcopy (const void *__src, void *__dest, size_t __n)
  231.      __THROW __nonnull ((1, 2));
  232.  
  233. /* Compare N bytes of S1 and S2 (same as memcmp).  */
  234. extern int bcmp (const void *__s1, __const void *__s2, size_t __n)
  235.      __THROW __attribute_pure__ __nonnull ((1, 2)) __wur;
  236.  
  237. /* Find the first occurrence of C in S (same as strchr).  */
  238. extern char *index (const char *__s, int __c)
  239.      __THROW __attribute_pure__ __nonnull ((1)) __wur;
  240.  
  241. /* Find the last occurrence of C in S (same as strrchr).  */
  242. extern char *rindex (const char *__s, int __c)
  243.      __THROW __attribute_pure__ __nonnull ((1)) __wur;
  244.  
  245. /* Return the position of the first bit set in I, or 0 if none are set.
  246.    The least-significant bit is position 1, the most-significant 32.  */
  247. extern int ffs (int __i) __THROW __attribute__ ((__const__)) __wur;
  248.  
  249. /* The following two functions are non-standard but necessary for non-32 bit
  250.    platforms.  */
  251. # ifdef __USE_GNU
  252. extern int ffsl (long int __l) __THROW __attribute__ ((__const__)) __wur;
  253.  
  254. __extension__ extern int ffsll (long long int __ll)
  255.      __THROW __attribute__ ((__const__)) __wur;
  256. # endif
  257.  
  258. /* Compare S1 and S2, ignoring case.  */
  259. extern int strcasecmp (const char *__s1, const char *__s2)
  260.      __THROW __attribute_pure__ __nonnull ((1, 2)) __wur;
  261.  
  262. /* Compare no more than N chars of S1 and S2, ignoring case.  */
  263. extern int strncasecmp (const char *__s1, const char *__s2, size_t __n)
  264.      __THROW __attribute_pure__ __nonnull ((1, 2)) __wur;
  265. #endif /* Use BSD.  */
  266.  
  267. #if defined __USE_XOPEN2K || defined __USE_MISC
  268. /* Re-entrant version of strerror */
  269. extern int strerror_r (int __errnum, char *__strerrbuf, size_t __buflen)
  270.      __THROW __nonnull ((2));
  271. #endif
  272.  
  273. __END_DECLS
  274.  
  275. #endif
  276.