1/*
2Copyright (c) 2002 by Tomohiro KUBOTA
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
23#ifndef LUIT_OTHER_H
24#define LUIT_OTHER_H 1
25
26#ifdef HAVE_CONFIG_H
27#include "config.h"		/* include this, for self-contained headers */
28#endif
29
30#ifndef GCC_UNUSED
31#define GCC_UNUSED		/* ARGSUSED */
32#endif
33
34#include <X11/fonts/fontenc.h>
35
36#define UChar(n) ((unsigned char)(n))
37
38typedef struct {
39    FontMapPtr mapping;
40    FontMapReversePtr reverse;
41    int buf;
42} aux_gbk;
43
44typedef struct {
45    unsigned char buf[4];
46    int buf_ptr, len;
47} aux_utf8;
48
49typedef struct {
50    FontMapPtr x0208mapping;
51    FontMapPtr x0201mapping;
52    FontMapReversePtr x0208reverse;
53    FontMapReversePtr x0201reverse;
54    int buf;
55} aux_sjis;
56
57typedef struct {
58    FontMapPtr mapping;
59    FontMapReversePtr reverse;
60    int buf;
61} aux_hkscs;
62
63typedef struct {
64    FontMapPtr cs0_mapping;	/* gb18030.2000-0 */
65    FontMapReversePtr cs0_reverse;
66
67    FontMapPtr cs1_mapping;	/* gb18030.2000-1 */
68    FontMapReversePtr cs1_reverse;
69
70    int linear;			/* set to '1' if stack_gb18030 linearized a 4bytes seq */
71    int buf[3];
72    int buf_ptr;
73} aux_gb18030;
74
75typedef union {
76    aux_gbk gbk;
77    aux_utf8 utf8;
78    aux_sjis sjis;
79    aux_hkscs hkscs;
80    aux_gb18030 gb18030;
81} OtherState, *OtherStatePtr;
82
83int init_gbk(OtherStatePtr);
84unsigned int mapping_gbk(unsigned int, OtherStatePtr);
85unsigned int reverse_gbk(unsigned int, OtherStatePtr);
86int stack_gbk(unsigned, OtherStatePtr);
87
88int init_utf8(OtherStatePtr);
89unsigned int mapping_utf8(unsigned int, OtherStatePtr);
90unsigned int reverse_utf8(unsigned int, OtherStatePtr);
91int stack_utf8(unsigned, OtherStatePtr);
92
93int init_sjis(OtherStatePtr);
94unsigned int mapping_sjis(unsigned int, OtherStatePtr);
95unsigned int reverse_sjis(unsigned int, OtherStatePtr);
96int stack_sjis(unsigned, OtherStatePtr);
97
98int init_hkscs(OtherStatePtr);
99unsigned int mapping_hkscs(unsigned int, OtherStatePtr);
100unsigned int reverse_hkscs(unsigned int, OtherStatePtr);
101int stack_hkscs(unsigned, OtherStatePtr);
102
103int init_gb18030(OtherStatePtr);
104unsigned int mapping_gb18030(unsigned int, OtherStatePtr);
105unsigned int reverse_gb18030(unsigned int, OtherStatePtr);
106int stack_gb18030(unsigned, OtherStatePtr);
107
108#endif /* LUIT_OTHER_H */
109