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.
35 /* Common header files. */
39 #include <sys/types.h>
43 extern int mb_cur_max
;
44 extern int mb_cur_min
;
49 extern int undefok
; /* mostly ignore undefined symbols */
54 void yyerror(const char *);
55 void errf(const char *, ...) __dead2
;
56 void warn(const char *, ...);
58 int putl_category(const char *, FILE *);
59 int wr_category(void *, size_t, FILE *);
60 FILE *open_category(void);
61 void close_category(FILE *);
62 void copy_category(char *);
63 const char *category_name(void);
65 int get_category(void);
69 void reset_scanner(const char *);
70 void scan_to_eol(void);
71 void add_wcs(wchar_t);
73 wchar_t *get_wcs(void);
75 /* charmap.c - CHARMAP handling */
76 void init_charmap(void);
77 void add_charmap(const char *, int);
78 void add_charmap_undefined(char *);
79 void add_charmap_posix(void);
80 void add_charmap_range(char *, char *, int);
81 void add_charmap_char(const char *name
, int val
);
82 int lookup_charmap(const char *, wchar_t *);
83 int check_charmap_undefined(char *);
84 int check_charmap(wchar_t);
86 /* collate.o - LC_COLLATE handling */
87 typedef struct collelem collelem_t
;
88 typedef struct collsym collsym_t
;
89 void init_collate(void);
90 void define_collsym(char *);
91 void define_collelem(char *, wchar_t *);
92 void add_order_directive(void);
93 void add_order_bit(int);
94 void dump_collate(void);
95 collsym_t
*lookup_collsym(char *);
96 collelem_t
*lookup_collelem(char *);
97 void start_order_collelem(collelem_t
*);
98 void start_order_undefined(void);
99 void start_order_symbol(char *);
100 void start_order_char(wchar_t);
101 void start_order_ellipsis(void);
102 void end_order_collsym(collsym_t
*);
103 void end_order(void);
104 void add_weight(int32_t, int);
105 void add_weights(int32_t *);
106 void add_weight_num(int);
107 void add_order_collelem(collelem_t
*);
108 void add_order_collsym(collsym_t
*);
109 void add_order_char(wchar_t);
110 void add_order_ignore(void);
111 void add_order_ellipsis(void);
112 void add_order_symbol(char *);
113 void add_order_subst(void);
114 void add_subst_char(wchar_t);
115 void add_subst_collsym(collsym_t
*);
116 void add_subst_collelem(collelem_t
*);
117 void add_subst_symbol(char *);
118 int32_t get_weight(int32_t, int);
119 wchar_t * wsncpy(wchar_t *, const wchar_t *, size_t);
122 /* ctype.c - LC_CTYPE handling */
123 void init_ctype(void);
125 void add_ctype_range(wchar_t);
126 void add_width(int, int);
127 void add_width_range(int, int, int);
128 void add_caseconv(int, int);
129 void dump_ctype(void);
131 /* messages.c - LC_MESSAGES handling */
132 void init_messages(void);
133 void add_message(wchar_t *);
134 void dump_messages(void);
136 /* monetary.c - LC_MONETARY handling */
137 void init_monetary(void);
138 void add_monetary_str(wchar_t *);
139 void add_monetary_num(int);
140 void reset_monetary_group(void);
141 void add_monetary_group(int);
142 void dump_monetary(void);
144 /* numeric.c - LC_NUMERIC handling */
145 void init_numeric(void);
146 void add_numeric_str(wchar_t *);
147 void reset_numeric_group(void);
148 void add_numeric_group(int);
149 void dump_numeric(void);
151 /* time.c - LC_TIME handling */
152 void init_time(void);
153 void add_time_str(wchar_t *);
154 void reset_time_list(void);
155 void add_time_list(wchar_t *);
156 void check_time_list(void);
157 void dump_time(void);
159 /* wide.c - Wide character handling. */
160 int to_wide(wchar_t *, const char *);
161 int to_mbs(char *, wchar_t);
162 int to_mb(char *, wchar_t);
163 char *to_mb_string(const wchar_t *);
164 void set_wide_encoding(const char *);
165 void werr(const char *, ...);
166 const char *get_wide_encoding(void);
169 //#define _(x) gettext(x)
170 #define INTERR fprintf(stderr,"internal fault (%s:%d)", __FILE__, __LINE__)