home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / i18nv102.zip / INCLUDE / WCHAR.H < prev   
C/C++ Source or Header  |  1995-09-13  |  9KB  |  296 lines

  1. /** wchar.h National Language Support OS2 Include File
  2. *.
  3. *.      (C) COPYRIGHT International Business Machines Corp. 1985, 1990
  4. *.      All Rights Reserved
  5. *.      Licensed Materials - Property of IBM
  6. *.
  7. *.      US Government Users Restricted Rights - Use, duplication or
  8. *.      disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9. *.
  10. ** Description:
  11. *
  12. *       The wchar.h file is part of the National Language Support
  13. *       system for OS/2 and AIX operating systems. Programmers
  14. *       interested in writing NLS enabled applications would include
  15. *       this file in their source files.
  16. *
  17. **/
  18. /** Constants NLS DataTypes and Constants
  19. *
  20. ** Notes:
  21. *
  22. *) The wchar_t datatype is 16-bits in this implementation, however the
  23. *  the X/OPEN XPG4 standard allows other sizes.
  24. **/
  25.  
  26. #ifndef __H_WCHAR
  27. #define __H_WCHAR
  28.  
  29. #include <errno.h>
  30. #include <stdarg.h>
  31. #include <limits.h>
  32. #include <stdio.h>
  33. #include <time.h>
  34. #include <stddef.h>
  35. #include <nl_types.h>
  36.  
  37. #ifndef     _WCTYPE_T
  38.     #define _WCTYPE_T
  39.       typedef unsigned int wctype_t;
  40. #endif
  41.  
  42.  
  43. #ifndef     _WINT_T
  44.     #define _WINT_T
  45.       typedef int wint_t;
  46. #endif
  47.  
  48.  
  49. #ifndef     fcvt                       /* floating point conversion */
  50.     #define fcvt _fcvt
  51. #endif
  52.  
  53. typedef unsigned  char  uchar_t;
  54. typedef unsigned short ushort_t;
  55. typedef unsigned   int   uint_t;
  56. typedef unsigned  long  ulong_t;
  57.  
  58. typedef   signed   int  ssize_t;
  59.  
  60. #define _ISALPHA  0x001
  61. #define _ISALNUM  0x002
  62. #define _ISBLANK  0x004
  63. #define _ISCNTRL  0x008
  64. #define _ISDIGIT  0x010
  65. #define _ISGRAPH  0x020
  66. #define _ISLOWER  0x040
  67. #define _ISPRINT  0x080
  68. #define _ISPUNCT  0x100
  69. #define _ISSPACE  0x200
  70. #define _ISUPPER  0x400
  71. #define _ISXDIGIT 0x800
  72.  
  73.  
  74. /** Error codes
  75. *
  76. ** Notes:
  77. *
  78. *      The ANSI, POSIX, and XOPEN standards require that certain values be
  79. *      in errno.h.  The standards allow additional macro definitions,
  80. *      beginning with an E and an uppercase letter.
  81. *
  82. **/
  83.  
  84.  
  85. extern int errno;
  86.  
  87. #undef EILSEQ
  88. #define EILSEQ         52
  89. #undef E2BIG
  90. #define E2BIG          53
  91. #undef ENAMETOOLONG
  92. #define ENAMETOOLONG    86      /* File name too long           */
  93. #define ECLONEME  ERESTART /* this is the way we clone a stream ... */
  94.  
  95. #define _IOUNGETWC  0x0008      /* UNGETWC flag mask            */
  96.  
  97. #define MB_MAX_LEN  4
  98.  
  99. #undef MB_LEN_MAX
  100. #define  MB_LEN_MAX 4
  101.  
  102. #undef MB_CUR_MAX
  103. #define MB_CUR_MAX (__getmbcurmax())
  104.  
  105. #ifndef EOF
  106.         #define EOF             (-1)
  107. #endif
  108.  
  109. #ifndef WEOF
  110.         #define WEOF             (-1)
  111. #endif
  112.  
  113. /** Prototypes **/
  114.  
  115. #ifdef __cplusplus
  116. extern "C" {
  117. #endif
  118.  
  119. extern int __getmbcurmax(void);
  120.  
  121. char * setlocale(int, const char *);
  122. size_t strftime(char *s, size_t maxsize, const char *format,
  123.                       const struct tm *timeptr);
  124. ssize_t strfmon(char *s, size_t maxsize, const char *format, ...);
  125. char * strptime(const char *buf, const char *fmt, struct tm *tm);
  126. size_t  wcsftime(wchar_t *ws, size_t maxsize,
  127.                const char *format, const struct tm *timeptr);
  128. size_t   wcscspn (const wchar_t *ws1, const wchar_t *ws2);
  129. size_t   wcslen  (const wchar_t *ws);
  130. wchar_t *wcscat  (wchar_t       *ws1, const wchar_t *ws2);
  131. wchar_t *wcscpy  (wchar_t       *ws1, const wchar_t *ws2);
  132. int      wcscmp  (const wchar_t *ws1, const wchar_t *ws2);
  133. int      wcsncmp (const wchar_t *ws1, const wchar_t *ws2, size_t n);
  134. wchar_t *wcspbrk (const wchar_t *ws1, const wchar_t *ws2);
  135. wchar_t *wcsncpy (wchar_t       *ws1, const wchar_t *ws2, size_t n);
  136. size_t   wcsspn  (const wchar_t *ws1, const wchar_t *ws2);
  137. wchar_t *wcschr  (wchar_t       *ws1, wint_t         wc);
  138. wchar_t *wcsncat (wchar_t       *ws1, const wchar_t *ws2, size_t n);
  139. wchar_t *wcsrchr (wchar_t       *ws1, wint_t         wc);
  140. wchar_t *wcstok  (wchar_t       *ws1, const wchar_t *ws2);
  141. wchar_t *wcswcs  (const wchar_t *ws1, const wchar_t *ws2);
  142. double wcstod ( const wchar_t *nptr, wchar_t **endptr );
  143. long  wcstol (const wchar_t *nptr, wchar_t **endptr, int base);
  144. unsigned long  wcstoul (const wchar_t *nptr, wchar_t **endptr, int base);
  145.  
  146. #undef printf
  147. #undef sprintf
  148. #undef fprintf
  149. #undef vprintf
  150. #undef vsprintf
  151. #undef vfprintf
  152.  
  153. #define printf   wprintf
  154. #define sprintf  wsprintf
  155. #define fprintf  wfprintf
  156. #define vprintf   nls_vprintf
  157. #define vsprintf  nls_vsprintf
  158. #define vfprintf  nls_vfprintf
  159.  
  160. #undef scanf
  161. #undef sscanf
  162. #undef fscanf
  163.  
  164. #define scanf   wscanf
  165. #define sscanf  wsscanf
  166. #define fscanf  wfscanf
  167.  
  168. #undef    _strtodieee
  169. #define   _strtodieee _strtod
  170.  
  171. /* CSET++ defines strtod differently in <stdlib.h> than */
  172. /*  does CSET/2.  This requires the conditional define below.                 */
  173. #ifndef strtod
  174. #define strtod( p1, p2 )  _strtodieee( (p1), (p2) )
  175. #endif
  176.  
  177. int _xprint(char print_type, void * ostream, char * oformat,va_list oargs);
  178. int _xscan(char scan_type, void * ostream, char * oformat, va_list oargs );
  179. double _strtod (const char *nptr, char **endptr);
  180. int  wprintf   (const char * oformat, ...);
  181. int  wsprintf  (char * ostring, const char * oformat, ...);
  182. int  wfprintf  (FILE * ostream, const char * oformat, ...);
  183. int nls_vprintf (const char *format, va_list args);
  184. int nls_vsprintf (char *outp, const char * format, va_list args);
  185. int nls_vfprintf (FILE *outp, const char * format, va_list args);
  186. int  wscanf   (char * oformat, ...);
  187. int  wsscanf  (char * ostring, char * oformat, ...);
  188. int  wfscanf  (FILE * ostream, char * oformat, ...);
  189. wint_t          fgetwc(FILE *stream);
  190. wchar_t *       fgetws(wchar_t *s, int n, FILE *stream);
  191. wint_t          fputwc(const wint_t c, FILE *stream);
  192. int             fputws(const wchar_t *s,FILE *stream);
  193. int             getw(register FILE *stream);
  194. wint_t          getwc (FILE *stream);
  195. wint_t          getwchar (void);
  196. wchar_t *       getws(wchar_t *s);
  197. int             putw(int w, register FILE *stream);
  198. wint_t          putwc(wint_t c, FILE *stream);
  199. wint_t          putwchar(wint_t c);
  200. int             putws(const wchar_t *s);
  201. wint_t          ungetwc(wint_t c, FILE *stream);
  202. size_t mbstowcs(wchar_t *pwcs, const char *s, size_t n);
  203. int mbtowc(wchar_t *pwc, const char *s, size_t len);
  204. int mblen(const char *s, size_t n);
  205. int wcswidth(wchar_t *wcs, size_t n);
  206. int wctomb(char *s, wchar_t pwc);
  207. int wcwidth(wchar_t wc);
  208. size_t wcstombs(char *s, const wchar_t *pwcs, size_t n);
  209. int strcoll(const char *s1, const char *s2);
  210. wint_t towlower(wint_t wc);
  211. int wcscoll(const wchar_t *wcs1, const wchar_t *wcs2);
  212. size_t wcsxfrm(wchar_t *ws1, const wchar_t *ws2, size_t n);
  213.  
  214. #undef isalnum
  215. #undef isalpha
  216. #undef iscntrl
  217. #undef isdigit
  218. #undef isgraph
  219. #undef islower
  220. #undef isprint
  221. #undef ispunct
  222. #undef isspace
  223. #undef isupper
  224. #undef isxdigit
  225. int isalnum(int c);
  226. int isalpha(int c);
  227. int iscntrl(int c);
  228. int isdigit(int c);
  229. int isgraph(int c);
  230. int islower(int c);
  231. int isprint(int c);
  232. int ispunct(int c);
  233. int isspace(int c);
  234. int isupper(int c);
  235. int isxdigit(int c);
  236.  
  237. int iswalnum(wint_t pc);
  238. int iswalpha(wint_t pc);
  239. int iswcntrl(wint_t pc);
  240. int iswdigit(wint_t pc);
  241. int iswgraph(wint_t pc);
  242. int iswlower(wint_t pc);
  243. int iswprint(wint_t pc);
  244. int iswpunct(wint_t pc);
  245. int iswspace(wint_t pc);
  246. int iswupper(wint_t pc);
  247. int iswxdigit(wint_t pc);
  248. int iswctype(wint_t wc, wctype_t mask);
  249. wctype_t wctype(char *name);
  250. int wcsid(wchar_t wc);
  251.  
  252. #undef tolower
  253. #undef toupper
  254. int tolower(int c);
  255. int toupper(int c);
  256.  
  257. wint_t towlower(wint_t wc);
  258. wint_t towupper(wint_t wc);
  259.  
  260. int csid(char *mbs);
  261.  
  262.     /**********************************************
  263.     ** helper functions which work for 16/32 bit **
  264.     **********************************************/
  265.  
  266.     double get_i18n_version(void);
  267.     int find_locale_alias(char *in_str, char *out_str);
  268.     int add_locale_alias(char *the_alias, char *the_name);
  269.     int remove_locale_alias(char *in_str);
  270.     int map_string_to_locale(char *in_str, char *out_str);
  271.     int get_alias_table_path(char *out_str);
  272.  
  273. #define LOCALE_STR_LEN 25               /* Length of locale names and aliases*/
  274.  
  275.                                         /* Return codes for alias APIs.      */
  276. #define ALIAS_OK              0         /* API returned without errors.      */
  277. #define ALIAS_ERROR_NO_VAR    2         /* LOCPATH env var not defined.      */
  278. #define ALIAS_ERROR_NO_OPEN   4         /* Could not open ALIASES file.      */
  279. #define ALIAS_ERROR_NOT_FOUND 8         /* Requested alias not found.        */
  280. #define ALIAS_ERROR_DUPLICATE 16        /* Could not add alias.  Already     */
  281.                                         /*  exists.                          */
  282. #define ALIAS_BAD_PARSE       32        /* Could not properly parse the str. */
  283.  
  284. #ifdef __cplusplus
  285. }
  286. #endif
  287.  
  288.  
  289. #ifdef   _OS2_CORE
  290.     #include <lc_core.h>
  291.     #include <locale.h>
  292.     #include <langinfo.h>
  293. #endif
  294.  
  295. #endif
  296.