2.5-18.1
[jlayton/glibc.git] / locale / programs / charmap.h
1 /* Copyright (C) 1996-1999,2001,2003,2005,2006 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3    Contributed by Ulrich Drepper <drepper@gnu.org>, 1996.
4
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License version 2 as
7    published by the Free Software Foundation.
8
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with this program; if not, write to the Free Software Foundation,
16    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
17
18 #ifndef _CHARMAP_H
19 #define _CHARMAP_H
20
21 #include <obstack.h>
22 #include <stdbool.h>
23
24 #include "repertoire.h"
25 #include "simple-hash.h"
26
27
28 struct width_rule
29 {
30   struct charseq *from;
31   struct charseq *to;
32   unsigned int width;
33 };
34
35
36 struct charmap_t
37 {
38   const char *code_set_name;
39   const char *repertoiremap;
40   int mb_cur_min;
41   int mb_cur_max;
42
43   struct width_rule *width_rules;
44   size_t nwidth_rules;
45   size_t nwidth_rules_max;
46   unsigned int width_default;
47
48   struct obstack mem_pool;
49   hash_table char_table;
50   hash_table byte_table;
51   hash_table ucs4_table;
52 };
53
54
55 /* This is the structure used for entries in the hash table.  It represents
56    the sequence of bytes used for the coded character.  */
57 struct charseq
58 {
59   const char *name;
60   uint32_t ucs4;
61   int nbytes;
62   unsigned char bytes[0];
63 };
64
65
66 /* True if the encoding is not ASCII compatible.  */
67 extern bool enc_not_ascii_compatible;
68
69
70 /* Prototypes for charmap handling functions.  */
71 extern struct charmap_t *charmap_read (const char *filename, int verbose,
72                                        int error_not_found, int be_quiet,
73                                        int use_default);
74
75 /* Return the value stored under the given key in the hashing table.  */
76 extern struct charseq *charmap_find_value (const struct charmap_t *charmap,
77                                            const char *name, size_t len);
78
79 /* Return symbol for given multibyte sequence.  */
80 extern struct charseq *charmap_find_symbol (const struct charmap_t *charmap,
81                                             const char *name, size_t len);
82
83 #endif /* charmap.h */