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