summaryrefslogtreecommitdiff
path: root/usr/src/head/xlocale.h
blob: 7393a31a156edfdaf772e5277752a1fdce58f3db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
 * This file and its contents are supplied under the terms of the
 * Common Development and Distribution License ("CDDL"), version 1.0.
 * You may only use this file in accordance with the terms of version
 * 1.0 of the CDDL.
 *
 * A full copy of the text of the CDDL should have accompanied this
 * source.  A copy of the CDDL is also available via the Internet at
 * http://www.illumos.org/license/CDDL.
 */

/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 */

#ifndef _XLOCALE_H
#define	_XLOCALE_H

/*
 * This file supplies declarations for extended locale routines, as
 * originally delivered by MacOS X.  Many of these things are now
 * officially part of XPG7.  (Note that while the interfaces are the
 * same as MacOS X, there is no shared implementation.)
 *
 * Those declarations that are part of XPG7 are provided for the in the
 * XPG7-specified location.  This file lists just the declarations that
 * were not part of the standard.  These will be useful in their own right,
 * and will aid porting programs that don't strictly follow the standard.
 *
 * Note that it is an error to include this file in a program with strict
 * symbol visibilty rules (under strict ANSI or POSIX_C_SOURCE rules.)
 * If this is done, the symbols defined here will indeed be exposed to your
 * program, but those symbols that are part of the related standards might
 * not be.
 */

#include <sys/feature_tests.h>
#include <wchar.h>
#include <locale.h>
#include <stdio.h>

#ifdef __cplusplus
extern "C" {
#endif

#ifndef	_LOCALE_T
#define	_LOCALE_T
typedef struct locale *locale_t;
#endif

extern int mbsinit_l(const mbstate_t *, locale_t);

extern size_t mbsrtowcs_l(wchar_t *_RESTRICT_KYWD, const char **_RESTRICT_KYWD,
    size_t, mbstate_t *_RESTRICT_KYWD, locale_t);

extern size_t mbsnrtowcs_l(wchar_t *_RESTRICT_KYWD, const char **_RESTRICT_KYWD,
    size_t, size_t, mbstate_t *_RESTRICT_KYWD, locale_t);

extern char *strptime_l(const char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
    struct tm *_RESTRICT_KYWD, locale_t);

extern int wcwidth_l(wchar_t, locale_t);

extern int wcswidth_l(const wchar_t *, size_t, locale_t);

extern int iswspecial_l(wint_t, locale_t);
extern int iswnumber_l(wint_t, locale_t);
extern int iswhexnumber_l(wint_t, locale_t);
extern int iswideogram_l(wint_t, locale_t);
extern int iswphonogram_l(wint_t, locale_t);

extern wint_t btowc_l(int, locale_t);
extern int wctob_l(wint_t, locale_t);
extern size_t mbrtowc_l(wchar_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
    size_t, mbstate_t *_RESTRICT_KYWD, locale_t);
extern size_t mbstowcs_l(wchar_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
    size_t, locale_t);
extern int mblen_l(const char *, size_t, locale_t);
extern size_t mbrlen_l(const char *_RESTRICT_KYWD, size_t,
    mbstate_t *_RESTRICT_KYWD, locale_t);
extern int mbtowc_l(wchar_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, size_t,
    locale_t);
extern size_t wcsrtombs_l(char *_RESTRICT_KYWD, const wchar_t **_RESTRICT_KYWD,
    size_t len, mbstate_t *_RESTRICT_KYWD, locale_t);
extern size_t wcrtomb_l(char *_RESTRICT_KYWD, wchar_t,
    mbstate_t *_RESTRICT_KYWD, locale_t);
extern size_t wcstombs_l(char *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD,
    size_t, locale_t);
extern int wctomb_l(char *, wchar_t, locale_t);

extern unsigned char __mb_cur_max_l(locale_t);
#ifndef	MB_CUR_MAX_L
#define	MB_CUR_MAX_L(l)	(__mb_cur_max_l(l))
#endif


#if defined(_XPG4) && !defined(_FILEDEFED) || __cplusplus >= 199711L
#define	_FILEDEFED
typedef __FILE FILE;
#endif

extern wint_t fgetwc_l(FILE *, locale_t);
extern wint_t getwc_l(FILE *, locale_t);

#ifndef getwchar_l
#define	getwchar_l(l)	fgetwc_l(stdin, (l))
#endif

#ifdef __cplusplus
}
#endif

#endif /* _XLOCALE_H */