charset.h revision a8fdb4bc
1/*
2Copyright (c) 2001 by Juliusz Chroboczek
3
4Permission is hereby granted, free of charge, to any person obtaining a copy
5of this software and associated documentation files (the "Software"), to deal
6in the Software without restriction, including without limitation the rights
7to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8copies of the Software, and to permit persons to whom the Software is
9furnished to do so, subject to the following conditions:
10
11The above copyright notice and this permission notice shall be included in
12all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
17AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20THE SOFTWARE.
21*/
22/* $XFree86: xc/programs/luit/charset.h,v 1.3 2002/07/01 02:25:59 tsi Exp $ */
23
24#define T_FAILED 0
25#define T_94 1
26#define T_96 2
27#define T_128 3
28#define T_9494 4
29#define T_9696 5
30/* Big 5 */
31#define T_94192 6
32#define T_OTHER 7
33
34/* True for charsets that pass control chars unchanged, at least in
35   the first byte */
36#define CHARSET_REGULAR(c) ((c)->type != T_128)
37
38typedef struct _Charset {
39    char *name;
40    int type;
41    unsigned char final;
42    unsigned int (*recode)(unsigned int, struct _Charset *self);
43    int (*reverse)(unsigned int, struct _Charset *self);
44    void *data;
45    int (*other_stack)(unsigned char c, OtherStatePtr aux);
46    OtherState *other_aux;
47    unsigned int (*other_recode)(unsigned int c, OtherStatePtr aux);
48    unsigned int (*other_reverse)(unsigned int c, OtherStatePtr aux);
49    struct _Charset *next;
50} CharsetRec, *CharsetPtr;
51
52typedef struct _LocaleCharset {
53    const char *name;
54    int gl;
55    int gr;
56    const char *g0;
57    const char *g1;
58    const char *g2;
59    const char *g3;
60    const char *other;
61} LocaleCharsetRec, *LocaleCharsetPtr;
62
63CharsetPtr getUnknownCharset(int);
64CharsetPtr getCharset(unsigned char, int);
65CharsetPtr getCharsetByName(const char*);
66void reportCharsets(void);
67int getLocaleState(const char *locale, char *charset,
68                   int *gl_return, int *gr_return,
69                   CharsetPtr *g0_return, CharsetPtr *g1_return,
70                   CharsetPtr *g2_return, CharsetPtr *g3_return,
71                   CharsetPtr *other_return);
72