3 Copyright 1989, 1998 The Open Group
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 Except as contained in this notice, the name of The Open Group shall not be
22 used in advertising or otherwise to promote the sale, use or other dealings
23 in this Software without prior written authorization from The Open Group.
30 #include <X11/Xfuncproto.h>
34 typedef unsigned char *XctString;
42 typedef unsigned long XctFlags;
44 /* These are bits in XctFlags. */
46 #define XctSingleSetSegments 0x0001
47 /* This means that returned segments should contain characters from only
48 * one set (C0, C1, GL, GR). When this is requested, XctSegment is never
49 * returned, instead XctC0Segment, XctC1Segment, XctGlSegment, and
50 * XctGRSegment are returned. C0 and C1 segments are always returned as
51 * singleton characters.
54 #define XctProvideExtensions 0x0002
55 /* This means that if the Compound Text string is from a higher version
56 * than this code is implemented to, then syntactically correct but unknown
57 * control sequences should be returned as XctExtension items. If this
58 * flag is not set, and the Compound Text string version indicates that
59 * extensions cannot be ignored, then each unknown control sequence will be
60 * reported as an XctError.
63 #define XctAcceptC0Extensions 0x0004
64 /* This means that if the Compound Text string is from a higher version
65 * than this code is implemented to, then unknown C0 characters should be
66 * treated as if they were legal, and returned as C0 characters (regardless
67 * of how XctProvideExtensions is set). If this flag is not set, then all
68 * unknown C0 characters are treated according to XctProvideExtensions.
71 #define XctAcceptC1Extensions 0x0008
72 /* This means that if the Compound Text string is from a higher version
73 * than this code is implemented to, then unknown C0 characters should be
74 * treated as if they were legal, and returned as C0 characters (regardless
75 * of how XctProvideExtensions is set). If this flag is not set, then all
76 * unknown C0 characters are treated according to XctProvideExtensions.
79 #define XctHideDirection 0x0010
80 /* This means that horizontal direction changes should be reported as
81 * XctHorizontal items. If this flag is not set, then direction changes are
82 * not returned as items, but the current direction is still maintained and
83 * reported for other items.
86 #define XctFreeString 0x0020
87 /* This means that XctFree should free the Compound Text string (that was
88 * passed to XctCreate. If this flag is not set, the string is not freed.
91 #define XctShiftMultiGRToGL 0x0040
92 /* Translate GR segments on-the-fly into GL segments for the GR sets:
93 * GB2312.1980-1, JISX0208.1983-1, and KSC5601.1987-1.
96 /* This is the return type for XctNextItem. */
98 XctSegment, /* used when XctSingleSetSegments is not requested */
99 XctC0Segment, /* used when XctSingleSetSegments is requested */
100 XctGLSegment, /* used when XctSingleSetSegments is requested */
101 XctC1Segment, /* used when XctSingleSetSegments is requested */
102 XctGRSegment, /* used when XctSingleSetSegments is requested */
103 XctExtendedSegment, /* an extended segment */
104 XctExtension, /* used when XctProvideExtensions is requested */
105 XctHorizontal, /* horizontal direction or depth change */
106 XctEndOfText, /* end of text string */
107 XctError /* syntactic or semantic error */
110 typedef struct _XctRec {
111 XctString total_string; /* as given to XctCreate */
112 int total_length; /* as given to XctCreate */
113 XctFlags flags; /* as given to XctCreate */
114 int version; /* indicates the version of the CT spec
115 * the string was produced from */
116 int can_ignore_exts;/* non-zero if ignoring extensions is
117 * acceptable, else zero */
118 XctString item; /* item returned from XctNextItem */
119 unsigned item_length; /* length of item in bytes */
120 int char_size; /* number of bytes per character in
121 * item, with zero meaning variable */
122 char *encoding; /* Encoding name for item */
123 XctHDirection horizontal; /* direction of item */
124 unsigned horz_depth; /* current direction nesting depth */
125 char *GL; /* "{I} F" string for current GL */
126 char *GL_encoding; /* Encoding name for current GL */
127 int GL_set_size; /* 94 or 96 */
128 int GL_char_size; /* number of bytes per GL character */
129 char *GR; /* "{I} F" string for current GR */
130 char *GR_encoding; /* Encoding name for current GR */
131 int GR_set_size; /* 94 or 96 */
132 int GR_char_size; /* number of bytes per GR character */
133 char *GLGR_encoding; /* Encoding name for current GL+GR,
135 struct _XctPriv *priv; /* private to parser, don't peek */
138 /* these are the external routines */
143 _Xconst unsigned char *string,
148 XctResult XctNextItem