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