Xct.h revision 6c321187
1/* $Xorg: Xct.h,v 1.4 2001/02/09 02:03:53 xorgcvs Exp $ */ 2 3/* 4 5Copyright 1989, 1998 The Open Group 6 7Permission to use, copy, modify, distribute, and sell this software and its 8documentation for any purpose is hereby granted without fee, provided that 9the above copyright notice appear in all copies and that both that 10copyright notice and this permission notice appear in supporting 11documentation. 12 13The above copyright notice and this permission notice shall be included in 14all copies or substantial portions of the Software. 15 16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 20AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 23Except as contained in this notice, the name of The Open Group shall not be 24used in advertising or otherwise to promote the sale, use or other dealings 25in this Software without prior written authorization from The Open Group. 26 27*/ 28/* $XFree86: xc/lib/Xmu/Xct.h,v 1.6 2001/01/17 19:42:58 dawes Exp $ */ 29 30#ifndef _Xct_h 31#define _Xct_h 32 33#include <X11/Xfuncproto.h> 34 35#define XctVersion 1 36 37typedef unsigned char *XctString; 38 39typedef enum { 40 XctUnspecified, 41 XctLeftToRight, 42 XctRightToLeft 43} XctHDirection; 44 45typedef unsigned long XctFlags; 46 47/* These are bits in XctFlags. */ 48 49#define XctSingleSetSegments 0x0001 50 /* This means that returned segments should contain characters from only 51 * one set (C0, C1, GL, GR). When this is requested, XctSegment is never 52 * returned, instead XctC0Segment, XctC1Segment, XctGlSegment, and 53 * XctGRSegment are returned. C0 and C1 segments are always returned as 54 * singleton characters. 55 */ 56 57#define XctProvideExtensions 0x0002 58 /* This means that if the Compound Text string is from a higher version 59 * than this code is implemented to, then syntactically correct but unknown 60 * control sequences should be returned as XctExtension items. If this 61 * flag is not set, and the Compound Text string version indicates that 62 * extensions cannot be ignored, then each unknown control sequence will be 63 * reported as an XctError. 64 */ 65 66#define XctAcceptC0Extensions 0x0004 67 /* This means that if the Compound Text string is from a higher version 68 * than this code is implemented to, then unknown C0 characters should be 69 * treated as if they were legal, and returned as C0 characters (regardless 70 * of how XctProvideExtensions is set). If this flag is not set, then all 71 * unknown C0 characters are treated according to XctProvideExtensions. 72 */ 73 74#define XctAcceptC1Extensions 0x0008 75 /* This means that if the Compound Text string is from a higher version 76 * than this code is implemented to, then unknown C0 characters should be 77 * treated as if they were legal, and returned as C0 characters (regardless 78 * of how XctProvideExtensions is set). If this flag is not set, then all 79 * unknown C0 characters are treated according to XctProvideExtensions. 80 */ 81 82#define XctHideDirection 0x0010 83 /* This means that horizontal direction changes should be reported as 84 * XctHorizontal items. If this flag is not set, then direction changes are 85 * not returned as items, but the current direction is still maintained and 86 * reported for other items. 87 */ 88 89#define XctFreeString 0x0020 90 /* This means that XctFree should free the Compound Text string (that was 91 * passed to XctCreate. If this flag is not set, the string is not freed. 92 */ 93 94#define XctShiftMultiGRToGL 0x0040 95 /* Translate GR segments on-the-fly into GL segments for the GR sets: 96 * GB2312.1980-1, JISX0208.1983-1, and KSC5601.1987-1. 97 */ 98 99/* This is the return type for XctNextItem. */ 100typedef enum { 101 XctSegment, /* used when XctSingleSetSegments is not requested */ 102 XctC0Segment, /* used when XctSingleSetSegments is requested */ 103 XctGLSegment, /* used when XctSingleSetSegments is requested */ 104 XctC1Segment, /* used when XctSingleSetSegments is requested */ 105 XctGRSegment, /* used when XctSingleSetSegments is requested */ 106 XctExtendedSegment, /* an extended segment */ 107 XctExtension, /* used when XctProvideExtensions is requested */ 108 XctHorizontal, /* horizontal direction or depth change */ 109 XctEndOfText, /* end of text string */ 110 XctError /* syntactic or semantic error */ 111} XctResult; 112 113typedef struct _XctRec { 114 XctString total_string; /* as given to XctCreate */ 115 int total_length; /* as given to XctCreate */ 116 XctFlags flags; /* as given to XctCreate */ 117 int version; /* indicates the version of the CT spec 118 * the string was produced from */ 119 int can_ignore_exts;/* non-zero if ignoring extensions is 120 * acceptable, else zero */ 121 XctString item; /* item returned from XctNextItem */ 122 unsigned item_length; /* length of item in bytes */ 123 int char_size; /* number of bytes per character in 124 * item, with zero meaning variable */ 125 char *encoding; /* Encoding name for item */ 126 XctHDirection horizontal; /* direction of item */ 127 unsigned horz_depth; /* current direction nesting depth */ 128 char *GL; /* "{I} F" string for current GL */ 129 char *GL_encoding; /* Encoding name for current GL */ 130 int GL_set_size; /* 94 or 96 */ 131 int GL_char_size; /* number of bytes per GL character */ 132 char *GR; /* "{I} F" string for current GR */ 133 char *GR_encoding; /* Encoding name for current GR */ 134 int GR_set_size; /* 94 or 96 */ 135 int GR_char_size; /* number of bytes per GR character */ 136 char *GLGR_encoding; /* Encoding name for current GL+GR, 137 * if known */ 138 struct _XctPriv *priv; /* private to parser, don't peek */ 139} *XctData; 140 141/* these are the external routines */ 142_XFUNCPROTOBEGIN 143 144XctData XctCreate 145( 146 _Xconst unsigned char *string, 147 int length, 148 XctFlags flags 149); 150 151XctResult XctNextItem 152( 153 XctData data 154); 155 156void XctFree 157( 158 XctData data 159 ); 160 161void XctReset 162( 163 XctData data 164 ); 165 166_XFUNCPROTOEND 167 168#endif /* _Xct_h */ 169