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 * Copyright 2025 Bill Sommerfeld <sommerfeld@hamachi.org> 15 */ 16 17 #ifndef _XLOCALE_H 18 #define _XLOCALE_H 19 20 /* 21 * This file supplies declarations for extended locale routines, as 22 * originally delivered by MacOS X. Many of these things are now 23 * officially part of XPG7. (Note that while the interfaces are the 24 * same as MacOS X, there is no shared implementation.) 25 * 26 * Those declarations that are part of XPG7 are provided for the in the 27 * XPG7-specified location. This file lists just the declarations that 28 * were not part of the standard. These will be useful in their own right, 29 * and will aid porting programs that don't strictly follow the standard. 30 * 31 * Note that it is an error to include this file in a program with strict 32 * symbol visibilty rules (under strict ANSI or POSIX_C_SOURCE rules.) 33 * If this is done, the symbols defined here will indeed be exposed to your 34 * program, but those symbols that are part of the related standards might 35 * not be. 36 */ 37 38 #include <sys/feature_tests.h> 39 #include <wchar.h> 40 #include <locale.h> 41 #include <stdio.h> 42 #include <floatingpoint.h> 43 44 #ifdef __cplusplus 45 extern "C" { 46 #endif 47 48 #ifndef _LOCALE_T 49 #define _LOCALE_T 50 typedef struct _locale *locale_t; 51 #endif 52 53 extern int mbsinit_l(const mbstate_t *, locale_t); 54 55 extern size_t mbsrtowcs_l(wchar_t *_RESTRICT_KYWD, const char **_RESTRICT_KYWD, 56 size_t, mbstate_t *_RESTRICT_KYWD, locale_t); 57 58 extern size_t mbsnrtowcs_l(wchar_t *_RESTRICT_KYWD, const char **_RESTRICT_KYWD, 59 size_t, size_t, mbstate_t *_RESTRICT_KYWD, locale_t); 60 61 extern char *strptime_l(const char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, 62 struct tm *_RESTRICT_KYWD, locale_t); 63 64 extern int wcwidth_l(wchar_t, locale_t); 65 66 extern int wcswidth_l(const wchar_t *, size_t, locale_t); 67 68 extern int iswspecial_l(wint_t, locale_t); 69 extern int iswnumber_l(wint_t, locale_t); 70 extern int iswhexnumber_l(wint_t, locale_t); 71 extern int iswideogram_l(wint_t, locale_t); 72 extern int iswphonogram_l(wint_t, locale_t); 73 74 extern wint_t btowc_l(int, locale_t); 75 extern int wctob_l(wint_t, locale_t); 76 extern size_t mbrtowc_l(wchar_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, 77 size_t, mbstate_t *_RESTRICT_KYWD, locale_t); 78 extern size_t mbstowcs_l(wchar_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, 79 size_t, locale_t); 80 extern int mblen_l(const char *, size_t, locale_t); 81 extern size_t mbrlen_l(const char *_RESTRICT_KYWD, size_t, 82 mbstate_t *_RESTRICT_KYWD, locale_t); 83 extern int mbtowc_l(wchar_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, size_t, 84 locale_t); 85 extern size_t wcsrtombs_l(char *_RESTRICT_KYWD, const wchar_t **_RESTRICT_KYWD, 86 size_t, mbstate_t *_RESTRICT_KYWD, locale_t); 87 extern size_t wcsnrtombs_l(char *_RESTRICT_KYWD, const wchar_t **_RESTRICT_KYWD, 88 size_t, size_t, mbstate_t *_RESTRICT_KYWD, locale_t); 89 extern size_t wcrtomb_l(char *_RESTRICT_KYWD, wchar_t, 90 mbstate_t *_RESTRICT_KYWD, locale_t); 91 extern size_t wcstombs_l(char *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD, 92 size_t, locale_t); 93 extern int wctomb_l(char *, wchar_t, locale_t); 94 95 extern unsigned char __mb_cur_max_l(locale_t); 96 #ifndef MB_CUR_MAX_L 97 #define MB_CUR_MAX_L(l) (__mb_cur_max_l(l)) 98 #endif 99 100 extern struct lconv *localeconv_l(locale_t); 101 102 extern size_t wcsftime_l(wchar_t *_RESTRICT_KYWD, 103 size_t, const wchar_t *_RESTRICT_KYWD, const struct tm *_RESTRICT_KYWD, 104 locale_t); 105 106 /* these three are also in stdlib.h */ 107 extern float strtof_l(const char *, char **, locale_t); 108 extern double strtod_l(const char *, char **, locale_t); 109 extern long double strtold_l(const char *, char **, locale_t); 110 111 extern void string_to_decimal_l(char **, int, int, decimal_record *, 112 enum decimal_string_form *, char **, locale_t); 113 114 #if defined(_XPG4) && !defined(_FILEDEFED) || __cplusplus >= 199711L 115 #define _FILEDEFED 116 typedef __FILE FILE; 117 #endif 118 119 extern wint_t fgetwc_l(FILE *, locale_t); 120 extern wint_t getwc_l(FILE *, locale_t); 121 122 #ifndef getwchar_l 123 #define getwchar_l(l) fgetwc_l(stdin, (l)) 124 #endif 125 126 #ifdef __cplusplus 127 } 128 #endif 129 130 #endif /* _XLOCALE_H */ 131