xref: /freebsd/usr.bin/localedef/localedef.h (revision cc7edd258c2564fe9e3c4a0dc839acc4a71caff9)
1e12a957fSPedro F. Giffuni /*-
24644f9beSYuri Pankov  * Copyright 2018 Nexenta Systems, Inc.
3057ca2d4SBaptiste Daroussin  * Copyright 2015 John Marino <draco@marino.st>
4057ca2d4SBaptiste Daroussin  *
5057ca2d4SBaptiste Daroussin  * This source code is derived from the illumos localedef command, and
6057ca2d4SBaptiste Daroussin  * provided under BSD-style license terms by Nexenta Systems, Inc.
7057ca2d4SBaptiste Daroussin  *
8057ca2d4SBaptiste Daroussin  * Redistribution and use in source and binary forms, with or without
9057ca2d4SBaptiste Daroussin  * modification, are permitted provided that the following conditions
10057ca2d4SBaptiste Daroussin  * are met:
11057ca2d4SBaptiste Daroussin  *
12057ca2d4SBaptiste Daroussin  * 1. Redistributions of source code must retain the above copyright
13057ca2d4SBaptiste Daroussin  *    notice, this list of conditions and the following disclaimer.
14057ca2d4SBaptiste Daroussin  * 2. Redistributions in binary form must reproduce the above copyright
15057ca2d4SBaptiste Daroussin  *    notice, this list of conditions and the following disclaimer in the
16057ca2d4SBaptiste Daroussin  *    documentation and/or other materials provided with the distribution.
17057ca2d4SBaptiste Daroussin  *
18057ca2d4SBaptiste Daroussin  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19057ca2d4SBaptiste Daroussin  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20057ca2d4SBaptiste Daroussin  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21057ca2d4SBaptiste Daroussin  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22057ca2d4SBaptiste Daroussin  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23057ca2d4SBaptiste Daroussin  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24057ca2d4SBaptiste Daroussin  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25057ca2d4SBaptiste Daroussin  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26057ca2d4SBaptiste Daroussin  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27057ca2d4SBaptiste Daroussin  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28057ca2d4SBaptiste Daroussin  * POSSIBILITY OF SUCH DAMAGE.
29057ca2d4SBaptiste Daroussin  *
30057ca2d4SBaptiste Daroussin  * $FreeBSD$
31057ca2d4SBaptiste Daroussin  */
32057ca2d4SBaptiste Daroussin 
33057ca2d4SBaptiste Daroussin /*
34057ca2d4SBaptiste Daroussin  * POSIX localedef.
35057ca2d4SBaptiste Daroussin  */
36057ca2d4SBaptiste Daroussin 
37057ca2d4SBaptiste Daroussin /* Common header files. */
38ead8d64aSEnji Cooper #include <sys/cdefs.h>
396d284c01SEnji Cooper #include <sys/types.h>
406d284c01SEnji Cooper #include <stdarg.h>
41057ca2d4SBaptiste Daroussin #include <stdio.h>
42057ca2d4SBaptiste Daroussin #include <stdlib.h>
43057ca2d4SBaptiste Daroussin 
44057ca2d4SBaptiste Daroussin extern int com_char;
45057ca2d4SBaptiste Daroussin extern int esc_char;
46057ca2d4SBaptiste Daroussin extern int mb_cur_max;
47057ca2d4SBaptiste Daroussin extern int mb_cur_min;
48057ca2d4SBaptiste Daroussin extern int last_kw;
49057ca2d4SBaptiste Daroussin extern int verbose;
50d836a9dbSJung-uk Kim #if YYDEBUG
51057ca2d4SBaptiste Daroussin extern int yydebug;
52d836a9dbSJung-uk Kim #endif
53057ca2d4SBaptiste Daroussin extern int lineno;
54057ca2d4SBaptiste Daroussin extern int undefok;	/* mostly ignore undefined symbols */
55057ca2d4SBaptiste Daroussin extern int warnok;
56057ca2d4SBaptiste Daroussin extern int warnings;
57057ca2d4SBaptiste Daroussin 
58*cc7edd25SThomas Munro extern char *version;
59*cc7edd25SThomas Munro 
60057ca2d4SBaptiste Daroussin int yylex(void);
61057ca2d4SBaptiste Daroussin void yyerror(const char *);
62ead8d64aSEnji Cooper _Noreturn void errf(const char *, ...) __printflike(1, 2);
63ead8d64aSEnji Cooper void warn(const char *, ...) __printflike(1, 2);
64057ca2d4SBaptiste Daroussin 
65057ca2d4SBaptiste Daroussin int putl_category(const char *, FILE *);
66057ca2d4SBaptiste Daroussin int wr_category(void *, size_t, FILE *);
67057ca2d4SBaptiste Daroussin FILE *open_category(void);
68057ca2d4SBaptiste Daroussin void close_category(FILE *);
69057ca2d4SBaptiste Daroussin void copy_category(char *);
70057ca2d4SBaptiste Daroussin const char *category_name(void);
71057ca2d4SBaptiste Daroussin 
72057ca2d4SBaptiste Daroussin int get_category(void);
73057ca2d4SBaptiste Daroussin int get_symbol(void);
74057ca2d4SBaptiste Daroussin int get_escaped(int);
75057ca2d4SBaptiste Daroussin int get_wide(void);
76057ca2d4SBaptiste Daroussin void reset_scanner(const char *);
77057ca2d4SBaptiste Daroussin void scan_to_eol(void);
78057ca2d4SBaptiste Daroussin void add_wcs(wchar_t);
79057ca2d4SBaptiste Daroussin void add_tok(int);
80057ca2d4SBaptiste Daroussin wchar_t *get_wcs(void);
81057ca2d4SBaptiste Daroussin 
824644f9beSYuri Pankov uint32_t htote(uint32_t);
834644f9beSYuri Pankov 
84057ca2d4SBaptiste Daroussin /* charmap.c - CHARMAP handling */
85057ca2d4SBaptiste Daroussin void init_charmap(void);
86a0e395a4SBaptiste Daroussin void add_charmap(const char *, int);
87057ca2d4SBaptiste Daroussin void add_charmap_undefined(char *);
88057ca2d4SBaptiste Daroussin void add_charmap_posix(void);
89057ca2d4SBaptiste Daroussin void add_charmap_range(char *, char *, int);
90a0e395a4SBaptiste Daroussin void add_charmap_char(const char *name, int val);
91057ca2d4SBaptiste Daroussin int lookup_charmap(const char *, wchar_t *);
92057ca2d4SBaptiste Daroussin int check_charmap_undefined(char *);
93057ca2d4SBaptiste Daroussin int check_charmap(wchar_t);
94057ca2d4SBaptiste Daroussin 
95057ca2d4SBaptiste Daroussin /* collate.o - LC_COLLATE handling */
96057ca2d4SBaptiste Daroussin typedef struct collelem collelem_t;
97057ca2d4SBaptiste Daroussin typedef struct collsym collsym_t;
98057ca2d4SBaptiste Daroussin void init_collate(void);
99057ca2d4SBaptiste Daroussin void define_collsym(char *);
100057ca2d4SBaptiste Daroussin void define_collelem(char *, wchar_t *);
101057ca2d4SBaptiste Daroussin void add_order_directive(void);
102057ca2d4SBaptiste Daroussin void add_order_bit(int);
103057ca2d4SBaptiste Daroussin void dump_collate(void);
104057ca2d4SBaptiste Daroussin collsym_t *lookup_collsym(char *);
105057ca2d4SBaptiste Daroussin collelem_t *lookup_collelem(char *);
106057ca2d4SBaptiste Daroussin void start_order_collelem(collelem_t *);
107057ca2d4SBaptiste Daroussin void start_order_undefined(void);
108057ca2d4SBaptiste Daroussin void start_order_symbol(char *);
109057ca2d4SBaptiste Daroussin void start_order_char(wchar_t);
110057ca2d4SBaptiste Daroussin void start_order_ellipsis(void);
111057ca2d4SBaptiste Daroussin void end_order_collsym(collsym_t *);
112057ca2d4SBaptiste Daroussin void end_order(void);
113057ca2d4SBaptiste Daroussin void add_weight(int32_t, int);
114057ca2d4SBaptiste Daroussin void add_weights(int32_t *);
115057ca2d4SBaptiste Daroussin void add_weight_num(int);
116057ca2d4SBaptiste Daroussin void add_order_collelem(collelem_t *);
117057ca2d4SBaptiste Daroussin void add_order_collsym(collsym_t *);
118057ca2d4SBaptiste Daroussin void add_order_char(wchar_t);
119057ca2d4SBaptiste Daroussin void add_order_ignore(void);
120057ca2d4SBaptiste Daroussin void add_order_ellipsis(void);
121057ca2d4SBaptiste Daroussin void add_order_symbol(char *);
122057ca2d4SBaptiste Daroussin void add_order_subst(void);
123057ca2d4SBaptiste Daroussin void add_subst_char(wchar_t);
124057ca2d4SBaptiste Daroussin void add_subst_collsym(collsym_t *);
125057ca2d4SBaptiste Daroussin void add_subst_collelem(collelem_t *);
126057ca2d4SBaptiste Daroussin void add_subst_symbol(char *);
127057ca2d4SBaptiste Daroussin int32_t get_weight(int32_t, int);
128057ca2d4SBaptiste Daroussin wchar_t * wsncpy(wchar_t *, const wchar_t *, size_t);
129057ca2d4SBaptiste Daroussin 
130057ca2d4SBaptiste Daroussin 
131057ca2d4SBaptiste Daroussin /* ctype.c - LC_CTYPE handling */
132057ca2d4SBaptiste Daroussin void init_ctype(void);
133057ca2d4SBaptiste Daroussin void add_ctype(int);
1348c859b07SBaptiste Daroussin void add_ctype_range(wchar_t);
135057ca2d4SBaptiste Daroussin void add_width(int, int);
136057ca2d4SBaptiste Daroussin void add_width_range(int, int, int);
137057ca2d4SBaptiste Daroussin void add_caseconv(int, int);
138057ca2d4SBaptiste Daroussin void dump_ctype(void);
139057ca2d4SBaptiste Daroussin 
140057ca2d4SBaptiste Daroussin /* messages.c - LC_MESSAGES handling */
141057ca2d4SBaptiste Daroussin void init_messages(void);
142057ca2d4SBaptiste Daroussin void add_message(wchar_t *);
143057ca2d4SBaptiste Daroussin void dump_messages(void);
144057ca2d4SBaptiste Daroussin 
145057ca2d4SBaptiste Daroussin /* monetary.c - LC_MONETARY handling */
146057ca2d4SBaptiste Daroussin void init_monetary(void);
147057ca2d4SBaptiste Daroussin void add_monetary_str(wchar_t *);
148057ca2d4SBaptiste Daroussin void add_monetary_num(int);
149057ca2d4SBaptiste Daroussin void reset_monetary_group(void);
150057ca2d4SBaptiste Daroussin void add_monetary_group(int);
151057ca2d4SBaptiste Daroussin void dump_monetary(void);
152057ca2d4SBaptiste Daroussin 
153057ca2d4SBaptiste Daroussin /* numeric.c - LC_NUMERIC handling */
154057ca2d4SBaptiste Daroussin void init_numeric(void);
155057ca2d4SBaptiste Daroussin void add_numeric_str(wchar_t *);
156057ca2d4SBaptiste Daroussin void reset_numeric_group(void);
157057ca2d4SBaptiste Daroussin void add_numeric_group(int);
158057ca2d4SBaptiste Daroussin void dump_numeric(void);
159057ca2d4SBaptiste Daroussin 
160057ca2d4SBaptiste Daroussin /* time.c - LC_TIME handling */
161057ca2d4SBaptiste Daroussin void init_time(void);
162057ca2d4SBaptiste Daroussin void add_time_str(wchar_t *);
163057ca2d4SBaptiste Daroussin void reset_time_list(void);
164057ca2d4SBaptiste Daroussin void add_time_list(wchar_t *);
165057ca2d4SBaptiste Daroussin void check_time_list(void);
166057ca2d4SBaptiste Daroussin void dump_time(void);
167057ca2d4SBaptiste Daroussin 
168057ca2d4SBaptiste Daroussin /* wide.c -  Wide character handling. */
169057ca2d4SBaptiste Daroussin int to_wide(wchar_t *, const char *);
170057ca2d4SBaptiste Daroussin int to_mbs(char *, wchar_t);
171057ca2d4SBaptiste Daroussin int to_mb(char *, wchar_t);
172057ca2d4SBaptiste Daroussin char *to_mb_string(const wchar_t *);
173057ca2d4SBaptiste Daroussin void set_wide_encoding(const char *);
174057ca2d4SBaptiste Daroussin void werr(const char *, ...);
175057ca2d4SBaptiste Daroussin const char *get_wide_encoding(void);
176057ca2d4SBaptiste Daroussin int max_wide(void);
177057ca2d4SBaptiste Daroussin 
178057ca2d4SBaptiste Daroussin //#define	_(x)	gettext(x)
179057ca2d4SBaptiste Daroussin #define	INTERR	fprintf(stderr,"internal fault (%s:%d)", __FILE__, __LINE__)
180