1 /*- 2 * Copyright (c) 2011 The FreeBSD Foundation 3 * All rights reserved. 4 * 5 * This software was developed by David Chisnall under sponsorship from 6 * the FreeBSD Foundation. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright notice, 12 * this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright notice, 14 * this list of conditions and the following disclaimer in the documentation 15 * and/or other materials provided with the distribution. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * $FreeBSD$ 30 */ 31 32 #ifndef _XLOCALE_H_ 33 #define _XLOCALE_H_ 34 35 #include <locale.h> 36 37 __BEGIN_DECLS 38 39 /* 40 * Extended locale versions of the locale-aware functions from string.h. 41 * 42 * Include <string.h> before <xlocale.h> to expose these. 43 */ 44 #ifdef _STRING_H_ 45 int strcoll_l(const char *, const char *, locale_t); 46 size_t strxfrm_l(char *, const char *, size_t, locale_t); 47 int strcasecmp_l(const char *, const char *, locale_t); 48 char *strcasestr_l(const char *, const char *, locale_t); 49 int strncasecmp_l(const char *, const char *, size_t, locale_t); 50 #endif 51 /* 52 * Extended locale versions of the locale-aware functions from inttypes.h. 53 * 54 * Include <inttypes.h> before <xlocale.h> to expose these. 55 */ 56 #ifdef _INTTYPES_H_ 57 intmax_t 58 strtoimax_l(const char * __restrict, char ** __restrict, int, locale_t); 59 uintmax_t 60 strtoumax_l(const char * __restrict, char ** __restrict, int, locale_t); 61 intmax_t 62 wcstoimax_l(const wchar_t * __restrict, wchar_t ** __restrict, int , locale_t); 63 uintmax_t 64 wcstoumax_l(const wchar_t * __restrict, wchar_t ** __restrict, int, locale_t); 65 #endif 66 /* 67 * Extended locale versions of the locale-aware functions from monetary.h. 68 * 69 * Include <monetary.h> before <xlocale.h> to expose these. 70 */ 71 #ifdef _MONETARY_H_ 72 ssize_t strfmon_l(char *, size_t, locale_t, const char *, ...) 73 # if __GNUC__ > 2 || __GNUC__ == 2 && __GNUC_MINOR__ >= 7 74 __attribute__((__format__ (__strfmon__, 4, 5))) 75 # endif 76 ; 77 #endif 78 79 /* 80 * Extended locale versions of the locale-aware functions from stdlib.h. 81 * 82 * Include <stdlib.h> before <xlocale.h> to expose these. 83 */ 84 #ifdef _STDLIB_H_ 85 double atof_l(const char *, locale_t); 86 int atoi_l(const char *, locale_t); 87 long atol_l(const char *, locale_t); 88 long long atoll_l(const char *, locale_t); 89 int mblen_l(const char *, size_t, locale_t); 90 size_t 91 mbstowcs_l(wchar_t * __restrict, const char * __restrict, size_t, locale_t); 92 int 93 mbtowc_l(wchar_t * __restrict, const char * __restrict, size_t, locale_t); 94 double strtod_l(const char *, char **, locale_t); 95 float strtof_l(const char *, char **, locale_t); 96 long strtol_l(const char *, char **, int, locale_t); 97 long double strtold_l(const char *, char **, locale_t); 98 long long strtoll_l(const char *, char **, int, locale_t); 99 unsigned long strtoul_l(const char *, char **, int, locale_t); 100 unsigned long long strtoull_l(const char *, char **, int, locale_t); 101 size_t 102 wcstombs_l(char * __restrict, const wchar_t * __restrict, size_t, locale_t); 103 int wctomb_l(char *, wchar_t, locale_t); 104 105 int ___mb_cur_max_l(locale_t); 106 #define MB_CUR_MAX_L(x) (___mb_cur_max_l(x)) 107 108 #endif 109 /* 110 * Extended locale versions of the locale-aware functions from time.h. 111 * 112 * Include <time.h> before <xlocale.h> to expose these. 113 */ 114 #ifdef _TIME_H_ 115 size_t 116 strftime_l(char * __restrict, size_t, const char * __restrict, const 117 struct tm * __restrict, locale_t) 118 # if __GNUC__ > 2 || __GNUC__ == 2 && __GNUC_MINOR__ >= 7 119 __attribute__((__format__ (__strftime__, 3, 0))) 120 # endif 121 ; 122 char * 123 strptime_l(const char * __restrict, const char * __restrict, 124 struct tm * __restrict, locale_t); 125 #endif 126 #ifdef _LANGINFO_H_ 127 char *nl_langinfo_l(nl_item, locale_t); 128 #endif 129 #ifdef _CTYPE_H_ 130 #include <_xlocale_ctype.h> 131 #endif 132 #ifdef _WCTYPE_H_ 133 #define XLOCALE_WCTYPES 1 134 #include <_xlocale_ctype.h> 135 #endif 136 137 #ifdef _STDIO_H_ 138 int fprintf_l(FILE * __restrict, locale_t, const char * __restrict, ...) 139 __printflike(3, 4); 140 int fscanf_l(FILE * __restrict, locale_t, const char * __restrict, ...) 141 __scanflike(3, 4); 142 int printf_l(locale_t, const char * __restrict, ...) __printflike(2, 3); 143 int scanf_l(locale_t, const char * __restrict, ...) __scanflike(2, 3); 144 int sprintf_l(char * __restrict, locale_t, const char * __restrict, ...) 145 __printflike(3, 4); 146 int sscanf_l(const char * __restrict, locale_t, const char * __restrict, ...) 147 __scanflike(3, 4); 148 int vfprintf_l(FILE * __restrict, locale_t, const char * __restrict, __va_list) 149 __printflike(3, 0); 150 int vprintf_l(locale_t, const char * __restrict, __va_list) __printflike(2, 0); 151 int vsprintf_l(char * __restrict, locale_t, const char * __restrict, __va_list) 152 __printflike(3, 0); 153 154 int snprintf_l(char * __restrict, size_t, locale_t, const char * __restrict, 155 ...) __printflike(4, 5); 156 int vfscanf_l(FILE * __restrict, locale_t, const char * __restrict, __va_list) 157 __scanflike(3, 0); 158 int vscanf_l(locale_t, const char * __restrict, __va_list) __scanflike(2, 0); 159 int vsnprintf_l(char * __restrict, size_t, locale_t, const char * __restrict, 160 va_list) __printflike(4, 0); 161 int vsscanf_l(const char * __restrict, locale_t, const char * __restrict, 162 va_list) __scanflike(3, 0); 163 int dprintf_l(int, locale_t, const char * __restrict, ...) __printflike(3, 4); 164 int vdprintf_l(int, locale_t, const char * __restrict, __va_list) 165 __printflike(3, 0); 166 int asprintf_l(char **, locale_t, const char *, ...) __printflike(3, 4); 167 int vasprintf_l(char **, locale_t, const char *, __va_list) __printflike(3, 0); 168 #endif 169 #ifdef _WCHAR_H_ 170 wint_t btowc_l(int, locale_t); 171 wint_t fgetwc_l(FILE *, locale_t); 172 wchar_t * 173 fgetws_l(wchar_t * __restrict, int, FILE * __restrict, locale_t); 174 wint_t fputwc_l(wchar_t, FILE *, locale_t); 175 int 176 fputws_l(const wchar_t * __restrict, FILE * __restrict, locale_t); 177 int 178 fwprintf_l(FILE * __restrict, locale_t, const wchar_t * __restrict, 179 ...); 180 int 181 fwscanf_l(FILE * __restrict, locale_t, const wchar_t * __restrict, ...); 182 wint_t getwc_l(FILE *, locale_t); 183 wint_t getwchar_l(locale_t); 184 size_t 185 mbrlen_l(const char * __restrict, size_t, mbstate_t * __restrict, locale_t); 186 size_t 187 mbrtowc_l(wchar_t * __restrict, const char * __restrict, size_t, 188 mbstate_t * __restrict, locale_t); 189 int mbsinit_l(const mbstate_t *, locale_t); 190 size_t 191 mbsrtowcs_l(wchar_t * __restrict, const char ** __restrict, size_t, 192 mbstate_t * __restrict, locale_t); 193 wint_t putwc_l(wchar_t, FILE *, locale_t); 194 wint_t putwchar_l(wchar_t, locale_t); 195 int 196 swprintf_l(wchar_t * __restrict, size_t n, locale_t, 197 const wchar_t * __restrict, ...); 198 int 199 swscanf_l(const wchar_t * __restrict, locale_t, const wchar_t * __restrict, 200 ...); 201 wint_t ungetwc_l(wint_t, FILE *, locale_t); 202 int 203 vfwprintf_l(FILE * __restrict, locale_t, const wchar_t * __restrict, 204 __va_list); 205 int 206 vswprintf_l(wchar_t * __restrict, size_t n, locale_t, 207 const wchar_t * __restrict, __va_list); 208 int vwprintf_l(locale_t, const wchar_t * __restrict, __va_list); 209 size_t 210 wcrtomb_l(char * __restrict, wchar_t, mbstate_t * __restrict, locale_t); 211 int wcscoll_l(const wchar_t *, const wchar_t *, locale_t); 212 size_t 213 wcsftime_l(wchar_t * __restrict, size_t, const wchar_t * __restrict, 214 const struct tm * __restrict, locale_t); 215 size_t 216 wcsrtombs_l(char * __restrict, const wchar_t ** __restrict, size_t, 217 mbstate_t * __restrict, locale_t); 218 double wcstod_l(const wchar_t * __restrict, wchar_t ** __restrict, locale_t); 219 long 220 wcstol_l(const wchar_t * __restrict, wchar_t ** __restrict, int, locale_t); 221 unsigned long 222 wcstoul_l(const wchar_t * __restrict, wchar_t ** __restrict, int, locale_t); 223 int wcswidth_l(const wchar_t *, size_t, locale_t); 224 size_t 225 wcsxfrm_l(wchar_t * __restrict, const wchar_t * __restrict, size_t, locale_t); 226 int wctob_l(wint_t, locale_t); 227 int wcwidth_l(wchar_t, locale_t); 228 int wprintf_l(locale_t, const wchar_t * __restrict, ...); 229 int wscanf_l(locale_t, const wchar_t * __restrict, ...); 230 231 int 232 vfwscanf_l(FILE * __restrict, locale_t, const wchar_t * __restrict, 233 __va_list); 234 int vswscanf_l(const wchar_t * __restrict, locale_t, 235 const wchar_t *__restrict, __va_list); 236 int vwscanf_l(locale_t, const wchar_t * __restrict, __va_list); 237 float wcstof_l(const wchar_t * __restrict, wchar_t ** __restrict, locale_t); 238 long double 239 wcstold_l(const wchar_t * __restrict, wchar_t ** __restrict, locale_t); 240 long long 241 wcstoll_l(const wchar_t * __restrict, wchar_t ** __restrict, int, locale_t); 242 unsigned long long 243 wcstoull_l(const wchar_t * __restrict, wchar_t ** __restrict, int, locale_t); 244 size_t 245 mbsnrtowcs_l(wchar_t * __restrict, const char ** __restrict, size_t, size_t, 246 mbstate_t * __restrict, locale_t); 247 int wcscasecmp_l(const wchar_t *, const wchar_t *, locale_t); 248 int wcsncasecmp_l(const wchar_t *, const wchar_t *, size_t, locale_t); 249 size_t 250 wcsnrtombs_l(char * __restrict, const wchar_t ** __restrict, size_t, size_t, 251 mbstate_t * __restrict, locale_t); 252 253 #endif 254 255 struct lconv *localeconv_l(locale_t); 256 __END_DECLS 257 258 #endif 259