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