xref: /freebsd/usr.bin/localedef/localedef.h (revision 057ca2d4372f94cc0911c140cd4d8f117fe9b26a)
1*057ca2d4SBaptiste Daroussin /*
2*057ca2d4SBaptiste Daroussin  * Copyright 2010 Nexenta Systems, Inc.  All rights reserved.
3*057ca2d4SBaptiste Daroussin  * Copyright 2015 John Marino <draco@marino.st>
4*057ca2d4SBaptiste Daroussin  *
5*057ca2d4SBaptiste Daroussin  * This source code is derived from the illumos localedef command, and
6*057ca2d4SBaptiste Daroussin  * provided under BSD-style license terms by Nexenta Systems, Inc.
7*057ca2d4SBaptiste Daroussin  *
8*057ca2d4SBaptiste Daroussin  * Redistribution and use in source and binary forms, with or without
9*057ca2d4SBaptiste Daroussin  * modification, are permitted provided that the following conditions
10*057ca2d4SBaptiste Daroussin  * are met:
11*057ca2d4SBaptiste Daroussin  *
12*057ca2d4SBaptiste Daroussin  * 1. Redistributions of source code must retain the above copyright
13*057ca2d4SBaptiste Daroussin  *    notice, this list of conditions and the following disclaimer.
14*057ca2d4SBaptiste Daroussin  * 2. Redistributions in binary form must reproduce the above copyright
15*057ca2d4SBaptiste Daroussin  *    notice, this list of conditions and the following disclaimer in the
16*057ca2d4SBaptiste Daroussin  *    documentation and/or other materials provided with the distribution.
17*057ca2d4SBaptiste Daroussin  *
18*057ca2d4SBaptiste Daroussin  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19*057ca2d4SBaptiste Daroussin  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20*057ca2d4SBaptiste Daroussin  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21*057ca2d4SBaptiste Daroussin  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22*057ca2d4SBaptiste Daroussin  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23*057ca2d4SBaptiste Daroussin  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24*057ca2d4SBaptiste Daroussin  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25*057ca2d4SBaptiste Daroussin  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26*057ca2d4SBaptiste Daroussin  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27*057ca2d4SBaptiste Daroussin  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28*057ca2d4SBaptiste Daroussin  * POSSIBILITY OF SUCH DAMAGE.
29*057ca2d4SBaptiste Daroussin  *
30*057ca2d4SBaptiste Daroussin  * $FreeBSD$
31*057ca2d4SBaptiste Daroussin  */
32*057ca2d4SBaptiste Daroussin 
33*057ca2d4SBaptiste Daroussin /*
34*057ca2d4SBaptiste Daroussin  * POSIX localedef.
35*057ca2d4SBaptiste Daroussin  */
36*057ca2d4SBaptiste Daroussin 
37*057ca2d4SBaptiste Daroussin /* Common header files. */
38*057ca2d4SBaptiste Daroussin #include <stdio.h>
39*057ca2d4SBaptiste Daroussin #include <stdlib.h>
40*057ca2d4SBaptiste Daroussin #include <stdarg.h>
41*057ca2d4SBaptiste Daroussin #include <sys/types.h>
42*057ca2d4SBaptiste Daroussin 
43*057ca2d4SBaptiste Daroussin extern int com_char;
44*057ca2d4SBaptiste Daroussin extern int esc_char;
45*057ca2d4SBaptiste Daroussin extern int mb_cur_max;
46*057ca2d4SBaptiste Daroussin extern int mb_cur_min;
47*057ca2d4SBaptiste Daroussin extern int last_kw;
48*057ca2d4SBaptiste Daroussin extern int verbose;
49*057ca2d4SBaptiste Daroussin extern int yydebug;
50*057ca2d4SBaptiste Daroussin extern int lineno;
51*057ca2d4SBaptiste Daroussin extern int undefok;	/* mostly ignore undefined symbols */
52*057ca2d4SBaptiste Daroussin extern int warnok;
53*057ca2d4SBaptiste Daroussin extern int warnings;
54*057ca2d4SBaptiste Daroussin 
55*057ca2d4SBaptiste Daroussin int yylex(void);
56*057ca2d4SBaptiste Daroussin void yyerror(const char *);
57*057ca2d4SBaptiste Daroussin void errf(const char *, ...);
58*057ca2d4SBaptiste Daroussin void warn(const char *, ...);
59*057ca2d4SBaptiste Daroussin 
60*057ca2d4SBaptiste Daroussin int putl_category(const char *, FILE *);
61*057ca2d4SBaptiste Daroussin int wr_category(void *, size_t, FILE *);
62*057ca2d4SBaptiste Daroussin FILE *open_category(void);
63*057ca2d4SBaptiste Daroussin void close_category(FILE *);
64*057ca2d4SBaptiste Daroussin void copy_category(char *);
65*057ca2d4SBaptiste Daroussin const char *category_name(void);
66*057ca2d4SBaptiste Daroussin 
67*057ca2d4SBaptiste Daroussin int get_category(void);
68*057ca2d4SBaptiste Daroussin int get_symbol(void);
69*057ca2d4SBaptiste Daroussin int get_escaped(int);
70*057ca2d4SBaptiste Daroussin int get_wide(void);
71*057ca2d4SBaptiste Daroussin void reset_scanner(const char *);
72*057ca2d4SBaptiste Daroussin void scan_to_eol(void);
73*057ca2d4SBaptiste Daroussin void add_wcs(wchar_t);
74*057ca2d4SBaptiste Daroussin void add_tok(int);
75*057ca2d4SBaptiste Daroussin wchar_t *get_wcs(void);
76*057ca2d4SBaptiste Daroussin 
77*057ca2d4SBaptiste Daroussin /* charmap.c - CHARMAP handling */
78*057ca2d4SBaptiste Daroussin void init_charmap(void);
79*057ca2d4SBaptiste Daroussin void add_charmap(char *, int);
80*057ca2d4SBaptiste Daroussin void add_charmap_undefined(char *);
81*057ca2d4SBaptiste Daroussin void add_charmap_posix(void);
82*057ca2d4SBaptiste Daroussin void add_charmap_range(char *, char *, int);
83*057ca2d4SBaptiste Daroussin void add_charmap_char(char *name, int val);
84*057ca2d4SBaptiste Daroussin int lookup_charmap(const char *, wchar_t *);
85*057ca2d4SBaptiste Daroussin int check_charmap_undefined(char *);
86*057ca2d4SBaptiste Daroussin int check_charmap(wchar_t);
87*057ca2d4SBaptiste Daroussin 
88*057ca2d4SBaptiste Daroussin /* collate.o - LC_COLLATE handling */
89*057ca2d4SBaptiste Daroussin typedef struct collelem collelem_t;
90*057ca2d4SBaptiste Daroussin typedef struct collsym collsym_t;
91*057ca2d4SBaptiste Daroussin void init_collate(void);
92*057ca2d4SBaptiste Daroussin void define_collsym(char *);
93*057ca2d4SBaptiste Daroussin void define_collelem(char *, wchar_t *);
94*057ca2d4SBaptiste Daroussin void add_order_directive(void);
95*057ca2d4SBaptiste Daroussin void add_order_bit(int);
96*057ca2d4SBaptiste Daroussin void dump_collate(void);
97*057ca2d4SBaptiste Daroussin collsym_t *lookup_collsym(char *);
98*057ca2d4SBaptiste Daroussin collelem_t *lookup_collelem(char *);
99*057ca2d4SBaptiste Daroussin void start_order_collelem(collelem_t *);
100*057ca2d4SBaptiste Daroussin void start_order_undefined(void);
101*057ca2d4SBaptiste Daroussin void start_order_symbol(char *);
102*057ca2d4SBaptiste Daroussin void start_order_char(wchar_t);
103*057ca2d4SBaptiste Daroussin void start_order_ellipsis(void);
104*057ca2d4SBaptiste Daroussin void end_order_collsym(collsym_t *);
105*057ca2d4SBaptiste Daroussin void end_order(void);
106*057ca2d4SBaptiste Daroussin void add_weight(int32_t, int);
107*057ca2d4SBaptiste Daroussin void add_weights(int32_t *);
108*057ca2d4SBaptiste Daroussin void add_weight_num(int);
109*057ca2d4SBaptiste Daroussin void add_order_collelem(collelem_t *);
110*057ca2d4SBaptiste Daroussin void add_order_collsym(collsym_t *);
111*057ca2d4SBaptiste Daroussin void add_order_char(wchar_t);
112*057ca2d4SBaptiste Daroussin void add_order_ignore(void);
113*057ca2d4SBaptiste Daroussin void add_order_ellipsis(void);
114*057ca2d4SBaptiste Daroussin void add_order_symbol(char *);
115*057ca2d4SBaptiste Daroussin void add_order_subst(void);
116*057ca2d4SBaptiste Daroussin void add_subst_char(wchar_t);
117*057ca2d4SBaptiste Daroussin void add_subst_collsym(collsym_t *);
118*057ca2d4SBaptiste Daroussin void add_subst_collelem(collelem_t *);
119*057ca2d4SBaptiste Daroussin void add_subst_symbol(char *);
120*057ca2d4SBaptiste Daroussin int32_t get_weight(int32_t, int);
121*057ca2d4SBaptiste Daroussin wchar_t * wsncpy(wchar_t *, const wchar_t *, size_t);
122*057ca2d4SBaptiste Daroussin 
123*057ca2d4SBaptiste Daroussin 
124*057ca2d4SBaptiste Daroussin /* ctype.c - LC_CTYPE handling */
125*057ca2d4SBaptiste Daroussin void init_ctype(void);
126*057ca2d4SBaptiste Daroussin void add_ctype(int);
127*057ca2d4SBaptiste Daroussin void add_ctype_range(int);
128*057ca2d4SBaptiste Daroussin void add_width(int, int);
129*057ca2d4SBaptiste Daroussin void add_width_range(int, int, int);
130*057ca2d4SBaptiste Daroussin void add_caseconv(int, int);
131*057ca2d4SBaptiste Daroussin void dump_ctype(void);
132*057ca2d4SBaptiste Daroussin 
133*057ca2d4SBaptiste Daroussin /* messages.c - LC_MESSAGES handling */
134*057ca2d4SBaptiste Daroussin void init_messages(void);
135*057ca2d4SBaptiste Daroussin void add_message(wchar_t *);
136*057ca2d4SBaptiste Daroussin void dump_messages(void);
137*057ca2d4SBaptiste Daroussin 
138*057ca2d4SBaptiste Daroussin /* monetary.c - LC_MONETARY handling */
139*057ca2d4SBaptiste Daroussin void init_monetary(void);
140*057ca2d4SBaptiste Daroussin void add_monetary_str(wchar_t *);
141*057ca2d4SBaptiste Daroussin void add_monetary_num(int);
142*057ca2d4SBaptiste Daroussin void reset_monetary_group(void);
143*057ca2d4SBaptiste Daroussin void add_monetary_group(int);
144*057ca2d4SBaptiste Daroussin void dump_monetary(void);
145*057ca2d4SBaptiste Daroussin 
146*057ca2d4SBaptiste Daroussin /* numeric.c - LC_NUMERIC handling */
147*057ca2d4SBaptiste Daroussin void init_numeric(void);
148*057ca2d4SBaptiste Daroussin void add_numeric_str(wchar_t *);
149*057ca2d4SBaptiste Daroussin void reset_numeric_group(void);
150*057ca2d4SBaptiste Daroussin void add_numeric_group(int);
151*057ca2d4SBaptiste Daroussin void dump_numeric(void);
152*057ca2d4SBaptiste Daroussin 
153*057ca2d4SBaptiste Daroussin /* time.c - LC_TIME handling */
154*057ca2d4SBaptiste Daroussin void init_time(void);
155*057ca2d4SBaptiste Daroussin void add_time_str(wchar_t *);
156*057ca2d4SBaptiste Daroussin void reset_time_list(void);
157*057ca2d4SBaptiste Daroussin void add_time_list(wchar_t *);
158*057ca2d4SBaptiste Daroussin void check_time_list(void);
159*057ca2d4SBaptiste Daroussin void dump_time(void);
160*057ca2d4SBaptiste Daroussin 
161*057ca2d4SBaptiste Daroussin /* wide.c -  Wide character handling. */
162*057ca2d4SBaptiste Daroussin int to_wide(wchar_t *, const char *);
163*057ca2d4SBaptiste Daroussin int to_mbs(char *, wchar_t);
164*057ca2d4SBaptiste Daroussin int to_mb(char *, wchar_t);
165*057ca2d4SBaptiste Daroussin char *to_mb_string(const wchar_t *);
166*057ca2d4SBaptiste Daroussin void set_wide_encoding(const char *);
167*057ca2d4SBaptiste Daroussin void werr(const char *, ...);
168*057ca2d4SBaptiste Daroussin const char *get_wide_encoding(void);
169*057ca2d4SBaptiste Daroussin int max_wide(void);
170*057ca2d4SBaptiste Daroussin 
171*057ca2d4SBaptiste Daroussin //#define	_(x)	gettext(x)
172*057ca2d4SBaptiste Daroussin #define	INTERR	fprintf(stderr,"internal fault (%s:%d)", __FILE__, __LINE__)
173