home *** CD-ROM | disk | FTP | other *** search
/ RISCWORLD 7 / RISCWORLD_VOL7.iso / Software / Issue4 / SDL / gcc346 / !gcc / include / unixlib / h / wchar < prev    next >
Encoding:
Text File  |  2006-09-17  |  11.0 KB  |  305 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /usr/local/cvsroot/gccsdk/unixlib/source/clib/wchar.h,v $
  4.  * $Date: 2004/08/16 21:01:26 $
  5.  * $Revision: 1.6 $
  6.  * $State: Exp $
  7.  * $Author: joty $
  8.  *
  9.  ***************************************************************************/
  10.  
  11. /* Copyright (C) 1995, 1996 Free Software Foundation, Inc.
  12.    This file is part of the GNU C Library.
  13.  
  14.    The GNU C Library is free software; you can redistribute it and/or
  15.    modify it under the terms of the GNU Library General Public License as
  16.    published by the Free Software Foundation; either version 2 of the
  17.    License, or (at your option) any later version.
  18.  
  19.    The GNU C Library is distributed in the hope that it will be useful,
  20.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  21.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  22.    Library General Public License for more details.
  23.  
  24.    You should have received a copy of the GNU Library General Public
  25.    License along with the GNU C Library; see the file COPYING.LIB.  If not,
  26.    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  27.    Boston, MA 02111-1307, USA.  */
  28.  
  29. /*
  30.  *      ISO C Standard, Amendment 1, 7.16.4
  31.  *    General wide-string utilities    <wchar.h>
  32.  */
  33.  
  34. #ifndef __WCHAR_H
  35. #define __WCHAR_H 1
  36.  
  37. #ifndef __UNIXLIB_FEATURES_H
  38. #include <features.h>
  39. #endif
  40.  
  41. __BEGIN_DECLS
  42.  
  43. /* Get size_t, wchar_t, wint_t and NULL from <stddef.h>.  */
  44. #define __need_size_t
  45. #define __need_wchar_t
  46. #define __need_wint_t
  47. #define __need_NULL
  48. #include <stddef.h>
  49.  
  50.  
  51. /* Conversion state information.  */
  52. typedef struct
  53. {
  54.   int count;        /* Number of bytes needed for the current character. */
  55.   wint_t value;        /* Value so far.  */
  56. } mbstate_t;
  57.  
  58. #ifndef WCHAR_MIN
  59. /* These constants might also be defined in <stdint.h> */
  60. # define WCHAR_MIN    (-2147483647-1)
  61. # define WCHAR_MAX    (2147483647)
  62. #endif
  63.  
  64. #ifndef WEOF
  65. # define WEOF (0xffffffffu)
  66. #endif
  67.  
  68.  
  69. /* Copy SRC to DEST.  */
  70. extern wchar_t *wcscpy (wchar_t *__dest, const wchar_t *__src);
  71. /* Copy no more than N wide-characters of SRC to DEST.  */
  72. extern wchar_t *wcsncpy (wchar_t *__dest, const wchar_t *__src,
  73.                   size_t __n);
  74.  
  75. /* Append SRC onto DEST.  */
  76. extern wchar_t *wcscat (wchar_t *__dest, const wchar_t *__src);
  77. /* Append no more than N wide-characters of SRC onto DEST.  */
  78. extern wchar_t *wcsncat (wchar_t *__dest, const wchar_t *__src,
  79.                   size_t __n);
  80.  
  81. /* Compare S1 and S2.  */
  82. extern int wcscmp (const wchar_t *__s1, const wchar_t *__s2);
  83. /* Compare N wide-characters of S1 and S2.  */
  84. extern int wcsncmp (const wchar_t *__s1, const wchar_t *__s2,
  85.              size_t __n);
  86.  
  87. /* Compare S1 and S2, both interpreted as appropriate to the
  88.    LC_COLLATE category of the current locale.  */
  89. extern int wcscoll (const wchar_t *__s1, const wchar_t *__s2);
  90. /* Transform S2 into array pointed to by S1 such that if wcscmp is
  91.    applied to two transformed strings the result is the as applying
  92.    `wcscoll' to the original strings.  */
  93. extern size_t wcsxfrm (wchar_t *__s1, const wchar_t *__s2, size_t __n);
  94.  
  95. /* Duplicate S, returning an identical malloc'd string.  */
  96. extern wchar_t *wcsdup (const wchar_t *__s);
  97.  
  98. /* Find the first occurrence of WC in WCS.  */
  99. extern wchar_t *wcschr (const wchar_t *__wcs, wchar_t __wc);
  100. /* Find the last occurrence of WC in WCS.  */
  101. extern wchar_t *wcsrchr (const wchar_t *__wcs, wchar_t __wc);
  102.  
  103. /* Return the length of the initial segmet of WCS which
  104.    consists entirely of wide-characters not in REJECT.  */
  105. extern size_t wcscspn (const wchar_t *__wcs,
  106.                 const wchar_t *__reject);
  107. /* Return the length of the initial segmet of WCS which
  108.    consists entirely of wide-characters in  ACCEPT.  */
  109. extern size_t wcsspn (const wchar_t *__wcs, const wchar_t *__accept);
  110. /* Find the first occurrence in WCS of any character in ACCEPT.  */
  111. extern wchar_t *wcspbrk (const wchar_t *__wcs,
  112.                   const wchar_t *__accept);
  113. /* Find the first occurrence of NEEDLE in HAYSTACK.  */
  114. extern wchar_t *wcsstr (const wchar_t *__haystack,
  115.                  const wchar_t *__needle);
  116. /* Divide WCS into tokens separated by characters in DELIM.  */
  117. extern wchar_t *wcstok (wchar_t *__s, const wchar_t *__delim,
  118.                  wchar_t **ptr);
  119.  
  120. /* Return the number of wide-characters in S.  */
  121. extern size_t wcslen (const wchar_t *__s);
  122.  
  123.  
  124. /* Search N bytes of S for C.  */
  125. extern wchar_t *wmemchr (const wchar_t *__s, wchar_t __c, size_t __n);
  126.  
  127. /* Compare N bytes of S1 and S2.  */
  128. extern int wmemcmp (const wchar_t *__s1, const wchar_t *__s2,
  129.              size_t __n);
  130.  
  131. /* Copy N bytes of SRC to DEST.  */
  132. extern wchar_t *wmemcpy (wchar_t *__s1, const wchar_t *__s2,
  133.                   size_t __n);
  134.  
  135. /* Copy N bytes of SRC to DEST, guaranteeing
  136.    correct behavior for overlapping strings.  */
  137. extern wchar_t *wmemmove (wchar_t *__s1, const wchar_t *__s2,
  138.                    size_t __n);
  139.  
  140. /* Set N bytes of S to C.  */
  141. extern wchar_t *wmemset (wchar_t *__s, wchar_t __c, size_t __n);
  142.  
  143.  
  144. /* Determine whether C constitutes a valid (one-byte) multibyte
  145.    character.  */
  146. extern wint_t btowc (int __c);
  147.  
  148. /* Determine whether C corresponds to a member of the extended
  149.    character set whose multibyte representation is a single byte.  */
  150. extern int wctob (wint_t __c);
  151.  
  152. /* Determine whether PS points to an object representing the initial
  153.    state.  */
  154. extern int mbsinit (const mbstate_t *__ps);
  155.  
  156. /* Write wide character representation of multibyte character pointed
  157.    to by S to PWC.  */
  158. extern size_t __mbrtowc (wchar_t *__pwc, const char *__s, size_t __n,
  159.                   mbstate_t *__p);
  160. extern size_t mbrtowc (wchar_t *__pwc, const char *__s, size_t __n,
  161.                 mbstate_t *__p);
  162.  
  163. /* Write multibyte representation of wide character WC to S.  */
  164. extern size_t __wcrtomb (char *__s, wchar_t __wc, mbstate_t *__ps);
  165. extern size_t wcrtomb (char *__s, wchar_t __wc, mbstate_t *__ps);
  166.  
  167. /* Return number of bytes in multibyte character pointed to by S.  */
  168. extern size_t __mbrlen (const char *__s, size_t __n, mbstate_t *__ps);
  169. extern size_t mbrlen (const char *__s, size_t __n, mbstate_t *__ps);
  170.  
  171. #if 0
  172. #if defined (__OPTIMIZE__) && defined (__GNUC__)
  173. /* Define inline function as optimization.  */
  174. extern __inline size_t mbrlen (const char *s, size_t n, mbstate_t *ps)
  175. { return ps != NULL ? __mbrtowc (NULL, s, n, ps) : __mbrlen (s, n, NULL); }
  176. #endif
  177. #endif
  178.  
  179. /* Write wide character representation of multibyte character string
  180.    SRC to DST.  */
  181. extern size_t __mbsrtowcs (wchar_t *__dst, const char **__src,
  182.                 size_t __len, mbstate_t *__ps);
  183. extern size_t mbsrtowcs (wchar_t *__dst, const char **__src,
  184.                   size_t __len, mbstate_t *__ps);
  185.  
  186. /* Write multibyte character representation of wide character string
  187.    SRC to DST.  */
  188. extern size_t __wcsrtombs (char *__dst, const wchar_t **__src,
  189.                 size_t __len, mbstate_t *__ps);
  190. extern size_t wcsrtombs (char *__dst, const wchar_t **__src,
  191.                   size_t __len, mbstate_t *__ps);
  192.  
  193. /* Write wide character representation of at most NMC bytes of the
  194.    multibyte character string SRC to DST.  */
  195. extern size_t __mbsnrtowcs (wchar_t *__dst, const char **__src,
  196.                  size_t __nmc, size_t __len, mbstate_t *__ps);
  197. extern size_t mbsnrtowcs (wchar_t *__dst, const char **__src,
  198.                    size_t __nmc, size_t __len, mbstate_t *__ps);
  199.  
  200. /* Write multibyte character representation of at most NWC characters
  201.    from the wide character string SRC to DST.  */
  202. extern size_t __wcsnrtombs (char *__dst, const wchar_t **__src,
  203.                  size_t __nwc, size_t __len, mbstate_t *__ps);
  204. extern size_t wcsnrtombs (char *__dst, const wchar_t **__src,
  205.                    size_t __nwc, size_t __len, mbstate_t *__ps);
  206.  
  207.  
  208. /* The following functions are extensions found in X/Open CAE.  */
  209.  
  210. /* Determine number of column positions required for C.  */
  211. extern int wcwidth (wint_t __c);
  212.  
  213. /* Determine number of column positions required for first N wide
  214.    characters (or fewer if S ends before this) in S.  */
  215. extern int wcswidth (const wchar_t *__s, size_t __n);
  216.  
  217.  
  218. /* Convert initial portion of the wide string NPTR to `double'
  219.    representation.  */
  220. extern double wcstod (const wchar_t *__nptr, wchar_t **__endptr);
  221.  
  222. /* Likewise for `float' and `long double' sizes of floating-point numbers.  */
  223. extern float wcstof (const wchar_t *__nptr, wchar_t **__endptr);
  224. extern long double wcstold (const wchar_t *__nptr,
  225.                      wchar_t **__endptr);
  226.  
  227.  
  228. /* Convert initial portion of wide string NPTR to `long int'
  229.    representation.  */
  230. extern long int wcstol (const wchar_t *__nptr, wchar_t **__endptr,
  231.                  int __base);
  232.  
  233. /* Convert initial portion of wide string NPTR to `unsigned long int'
  234.    representation.  */
  235. extern unsigned long int wcstoul (const wchar_t *__nptr,
  236.                        wchar_t **__endptr, int __base);
  237.  
  238. #if defined (__GNUC__)
  239. /* Convert initial portion of wide string NPTR to `long int'
  240.    representation.  */
  241. __extension__ extern long long int wcstoq (const wchar_t *__nptr,
  242.                        wchar_t **__endptr,
  243.                        int __base);
  244.  
  245. /* Convert initial portion of wide string NPTR to `unsigned long long int'
  246.    representation.  */
  247. __extension__ extern unsigned long long int wcstouq (const wchar_t *__nptr,
  248.                              wchar_t **__endptr,
  249.                              int __base);
  250. #endif /* GCC.  */
  251.  
  252.  
  253. /* The internal entry points for `wcstoX' take an extra flag argument
  254.    saying whether or not to parse locale-dependent number grouping.  */
  255. extern double __wcstod_internal (const wchar_t *__nptr,
  256.                       wchar_t **__endptr, int __group);
  257. extern float __wcstof_internal (const wchar_t *__nptr,
  258.                      wchar_t **__endptr, int __group);
  259.  
  260. #if 0
  261. #if defined (__OPTIMIZE__) && defined (__GNUC__)
  262. /* Define inline functions which call the internal entry points.  */
  263.  
  264. extern inline double wcstod (const wchar_t *__nptr, wchar_t **__endptr)
  265. { return __wcstod_internal (__nptr, __endptr, 0); }
  266. extern inline long int wcstol (const wchar_t *__nptr,
  267.                                  wchar_t **__endptr, int __base)
  268. { return __wcstol_internal (__nptr, __endptr, __base, 0); }
  269. extern inline unsigned long int wcstoul (const wchar_t *__nptr,
  270.                                            wchar_t **__endptr, int __base)
  271. { return __wcstoul_internal (__nptr, __endptr, __base, 0); }
  272.  
  273. extern inline float wcstof (const wchar_t *__nptr, wchar_t **__endptr)
  274. { return __wcstof_internal (__nptr, __endptr, 0); }
  275. extern inline __long_double_t wcstold (const wchar_t *__nptr,
  276.                        wchar_t **__endptr)
  277.  
  278. { return __wcstold_internal (__nptr, __endptr, 0); }
  279.  
  280.  
  281. extern inline long long int wcstoq (const wchar_t *__nptr,
  282.                       wchar_t **__endptr, int __base)
  283. { return __wcstoq_internal (__nptr, __endptr, __base, 0); }
  284. extern inline unsigned long long int wcstouq (const wchar_t *__nptr,
  285.                         wchar_t **__endptr, int __base)
  286. { return __wcstouq_internal (__nptr, __endptr, __base, 0); }
  287. #endif /* Optimizing GCC >=2.  */
  288. #endif
  289.  
  290. /* Copy SRC to DEST, returning the address of the terminating L'\0' in
  291.    DEST.  */
  292. extern wchar_t *__wcpcpy (wchar_t *__dest, const wchar_t *__src);
  293. extern wchar_t *wcpcpy (wchar_t *__dest, const wchar_t *__src);
  294.  
  295. /* Copy no more than N characters of SRC to DEST, returning the address of
  296.    the last character written into DEST.  */
  297. extern wchar_t *__wcpncpy (wchar_t *__dest, const wchar_t *__src,
  298.                 size_t __n);
  299. extern wchar_t *wcpncpy (wchar_t *__dest, const wchar_t *__src,
  300.                   size_t __n);
  301.  
  302. __END_DECLS
  303.  
  304. #endif /* wchar.h  */
  305.