localedef.h revision 363536
1/*
2 * Copyright 2010 Nexenta Systems, Inc.  All rights reserved.
3 * Copyright 2015 John Marino <draco@marino.st>
4 *
5 * This source code is derived from the illumos localedef command, and
6 * provided under BSD-style license terms by Nexenta Systems, Inc.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
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.
17 *
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.
29 *
30 * $FreeBSD: stable/11/usr.bin/localedef/localedef.h 363536 2020-07-25 23:08:51Z truckman $
31 */
32
33/*
34 * POSIX localedef.
35 */
36
37/* Common header files. */
38#include <sys/cdefs.h>
39#include <sys/types.h>
40#include <stdarg.h>
41#include <stdio.h>
42#include <stdlib.h>
43
44extern int com_char;
45extern int esc_char;
46extern int mb_cur_max;
47extern int mb_cur_min;
48extern int last_kw;
49extern int verbose;
50#if YYDEBUG
51extern int yydebug;
52#endif
53extern int lineno;
54extern int undefok;	/* mostly ignore undefined symbols */
55extern int warnok;
56extern int warnings;
57
58int yylex(void);
59void yyerror(const char *);
60_Noreturn void errf(const char *, ...) __printflike(1, 2);
61void warn(const char *, ...) __printflike(1, 2);
62
63int putl_category(const char *, FILE *);
64int wr_category(void *, size_t, FILE *);
65FILE *open_category(void);
66void close_category(FILE *);
67void copy_category(char *);
68const char *category_name(void);
69
70int get_category(void);
71int get_symbol(void);
72int get_escaped(int);
73int get_wide(void);
74void reset_scanner(const char *);
75void scan_to_eol(void);
76void add_wcs(wchar_t);
77void add_tok(int);
78wchar_t *get_wcs(void);
79
80/* charmap.c - CHARMAP handling */
81void init_charmap(void);
82void add_charmap(const char *, int);
83void add_charmap_undefined(char *);
84void add_charmap_posix(void);
85void add_charmap_range(char *, char *, int);
86void add_charmap_char(const char *name, int val);
87int lookup_charmap(const char *, wchar_t *);
88int check_charmap_undefined(char *);
89int check_charmap(wchar_t);
90
91/* collate.o - LC_COLLATE handling */
92typedef struct collelem collelem_t;
93typedef struct collsym collsym_t;
94void init_collate(void);
95void define_collsym(char *);
96void define_collelem(char *, wchar_t *);
97void add_order_directive(void);
98void add_order_bit(int);
99void dump_collate(void);
100collsym_t *lookup_collsym(char *);
101collelem_t *lookup_collelem(char *);
102void start_order_collelem(collelem_t *);
103void start_order_undefined(void);
104void start_order_symbol(char *);
105void start_order_char(wchar_t);
106void start_order_ellipsis(void);
107void end_order_collsym(collsym_t *);
108void end_order(void);
109void add_weight(int32_t, int);
110void add_weights(int32_t *);
111void add_weight_num(int);
112void add_order_collelem(collelem_t *);
113void add_order_collsym(collsym_t *);
114void add_order_char(wchar_t);
115void add_order_ignore(void);
116void add_order_ellipsis(void);
117void add_order_symbol(char *);
118void add_order_subst(void);
119void add_subst_char(wchar_t);
120void add_subst_collsym(collsym_t *);
121void add_subst_collelem(collelem_t *);
122void add_subst_symbol(char *);
123int32_t get_weight(int32_t, int);
124wchar_t * wsncpy(wchar_t *, const wchar_t *, size_t);
125
126
127/* ctype.c - LC_CTYPE handling */
128void init_ctype(void);
129void add_ctype(int);
130void add_ctype_range(wchar_t);
131void add_width(int, int);
132void add_width_range(int, int, int);
133void add_caseconv(int, int);
134void dump_ctype(void);
135
136/* messages.c - LC_MESSAGES handling */
137void init_messages(void);
138void add_message(wchar_t *);
139void dump_messages(void);
140
141/* monetary.c - LC_MONETARY handling */
142void init_monetary(void);
143void add_monetary_str(wchar_t *);
144void add_monetary_num(int);
145void reset_monetary_group(void);
146void add_monetary_group(int);
147void dump_monetary(void);
148
149/* numeric.c - LC_NUMERIC handling */
150void init_numeric(void);
151void add_numeric_str(wchar_t *);
152void reset_numeric_group(void);
153void add_numeric_group(int);
154void dump_numeric(void);
155
156/* time.c - LC_TIME handling */
157void init_time(void);
158void add_time_str(wchar_t *);
159void reset_time_list(void);
160void add_time_list(wchar_t *);
161void check_time_list(void);
162void dump_time(void);
163
164/* wide.c -  Wide character handling. */
165int to_wide(wchar_t *, const char *);
166int to_mbs(char *, wchar_t);
167int to_mb(char *, wchar_t);
168char *to_mb_string(const wchar_t *);
169void set_wide_encoding(const char *);
170void werr(const char *, ...);
171const char *get_wide_encoding(void);
172int max_wide(void);
173
174//#define	_(x)	gettext(x)
175#define	INTERR	fprintf(stderr,"internal fault (%s:%d)", __FILE__, __LINE__)
176