home *** CD-ROM | disk | FTP | other *** search
/ RISCWORLD 7 / RISCWORLD_VOL7.iso / Software / Issue2 / SDL.ARC / !unixlib / source / clib / h / string < prev    next >
Encoding:
Text File  |  2004-09-05  |  7.9 KB  |  229 lines

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