1 /*
   2  * This file and its contents are supplied under the terms of the
   3  * Common Development and Distribution License ("CDDL"), version 1.0.
   4  * You may only use this file in accordance with the terms of version
   5  * 1.0 of the CDDL.
   6  *
   7  * A full copy of the text of the CDDL should have accompanied this
   8  * source.  A copy of the CDDL is also available via the Internet at
   9  * http://www.illumos.org/license/CDDL.
  10  */
  11 
  12 /*
  13  * Copyright 2014 Garrett D'Amore <garrett@damore.org>
  14  */
  15 
  16 #ifndef _XLOCALE_H
  17 #define _XLOCALE_H
  18 
  19 /*
  20  * This file supplies declarations for extended locale routines, as
  21  * originally delivered by MacOS X.  Many of these things are now
  22  * officially part of XPG7.  (Note that while the interfaces are the
  23  * same as MacOS X, there is no shared implementation.)
  24  *
  25  * Those declarations that are part of XPG7 are provided for the in the
  26  * XPG7-specified location.  This file lists just the declarations that
  27  * were not part of the standard.  These will be useful in their own right,
  28  * and will aid porting programs that don't strictly follow the standard.
  29  *
  30  * Note that it is an error to include this file in a program with strict
  31  * symbol visibilty rules (under strict ANSI or POSIX_C_SOURCE rules.)
  32  * If this is done, the symbols defined here will indeed be exposed to your
  33  * program, but those symbols that are part of the related standards might
  34  * not be.
  35  */
  36 
  37 #include <sys/feature_tests.h>
  38 #include <wchar.h>
  39 #include <locale.h>
  40 #include <stdio.h>
  41 
  42 #ifdef __cplusplus
  43 extern "C" {
  44 #endif
  45 
  46 #ifndef _LOCALE_T
  47 #define _LOCALE_T
  48 typedef struct locale *locale_t;
  49 #endif
  50 
  51 int mbsinit_l(const mbstate_t *, locale_t);
  52 
  53 size_t mbsrtowcs_l(wchar_t *_RESTRICT_KYWD, const char **_RESTRICT_KYWD,
  54     size_t, mbstate_t *_RESTRICT_KYWD, locale_t);
  55 
  56 size_t mbsnrtowcs_l(wchar_t *_RESTRICT_KYWD, const char **_RESTRICT_KYWD,
  57     size_t, size_t, mbstate_t *_RESTRICT_KYWD, locale_t);
  58 
  59 char *strptime_l(const char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
  60     struct tm *_RESTRICT_KYWD, locale_t);
  61 
  62 int wcwidth_l(wchar_t, locale_t);
  63 
  64 int wcswidth_l(const wchar_t *, size_t, locale_t);
  65 
  66 int iswspecial_l(wint_t, locale_t);
  67 int iswnumber_l(wint_t, locale_t);
  68 int iswhexnumber_l(wint_t, locale_t);
  69 int iswideogram_l(wint_t, locale_t);
  70 int iswphonogram_l(wint_t, locale_t);
  71 
  72 wint_t btowc_l(int, locale_t);
  73 int wctob_l(wint_t, locale_t);
  74 size_t mbrtowc_l(wchar_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, size_t,
  75     mbstate_t *_RESTRICT_KYWD, locale_t);
  76 size_t mbstowcs_l(wchar_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, size_t,
  77     locale_t);
  78 int mblen_l(const char *, size_t, locale_t);
  79 size_t mbrlen_l(const char *_RESTRICT_KYWD, size_t, mbstate_t *_RESTRICT_KYWD,
  80     locale_t);
  81 int mbtowc_l(wchar_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, size_t,
  82     locale_t);
  83 size_t wcsrtombs_l(char *_RESTRICT_KYWD, const wchar_t **_RESTRICT_KYWD,
  84     size_t len, mbstate_t *_RESTRICT_KYWD, locale_t);
  85 size_t wcrtomb_l(char *_RESTRICT_KYWD, wchar_t, mbstate_t *_RESTRICT_KYWD,
  86     locale_t);
  87 size_t wcstombs_l(char *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD, size_t,
  88     locale_t);
  89 int wctomb_l(char *, wchar_t, locale_t);
  90 
  91 unsigned char __mb_cur_max_l(locale_t);
  92 #ifndef MB_CUR_MAX_L
  93 #define MB_CUR_MAX_L(l) (__mb_cur_max_l(l))
  94 #endif
  95 
  96 
  97 #if defined(_XPG4) && !defined(_FILEDEFED) || __cplusplus >= 199711L
  98 #define _FILEDEFED
  99 typedef __FILE FILE;
 100 #endif
 101 
 102 wint_t fgetwc_l(FILE *, locale_t);
 103 wint_t getwc_l(FILE *, locale_t);
 104 
 105 #ifndef getwchar_l
 106 #define getwchar_l(l)   fgetwc_l(stdin, (l))
 107 #endif
 108 
 109 #ifdef __cplusplus
 110 }
 111 #endif
 112 
 113 #endif /* _XLOCALE_H */