Xct.h revision e120bd27
1/* 2 3Copyright 1989, 1998 The Open Group 4 5Permission to use, copy, modify, distribute, and sell this software and its 6documentation for any purpose is hereby granted without fee, provided that 7the above copyright notice appear in all copies and that both that 8copyright notice and this permission notice appear in supporting 9documentation. 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 17OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 18AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 21Except as contained in this notice, the name of The Open Group shall not be 22used in advertising or otherwise to promote the sale, use or other dealings 23in this Software without prior written authorization from The Open Group. 24 25*/ 26 27#ifndef _Xct_h 28#define _Xct_h 29 30#include <X11/Xfuncproto.h> 31 32#define XctVersion 1 33 34typedef unsigned char *XctString; 35 36typedef enum { 37 XctUnspecified, 38 XctLeftToRight, 39 XctRightToLeft 40} XctHDirection; 41 42typedef unsigned long XctFlags; 43 44/* These are bits in XctFlags. */ 45 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. 52 */ 53 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. 61 */ 62 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. 69 */ 70 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. 77 */ 78 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. 84 */ 85 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. 89 */ 90 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. 94 */ 95 96/* This is the return type for XctNextItem. */ 97typedef enum { 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 */ 108} XctResult; 109 110typedef 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, 134 * if known */ 135 struct _XctPriv *priv; /* private to parser, don't peek */ 136} *XctData; 137 138/* these are the external routines */ 139_XFUNCPROTOBEGIN 140 141XctData XctCreate 142( 143 _Xconst unsigned char *string, 144 int length, 145 XctFlags flags 146); 147 148XctResult XctNextItem 149( 150 XctData data 151); 152 153void XctFree 154( 155 XctData data 156 ); 157 158void XctReset 159( 160 XctData data 161 ); 162 163_XFUNCPROTOEND 164 165#endif /* _Xct_h */ 166