1 /*------------------------------------------------------------------------ 2 Copyright (C) 2002-2016 SIL International. All rights reserved. 3 4 Distributable under the terms of either the Common Public License or the 5 GNU Lesser General Public License, as specified in the LICENSING.txt file. 6 7 File: TECkit_Common.h 8 Responsibility: Jonathan Kew 9 Last reviewed: Not yet. 10 11 Description: 12 Public definitions used by TECkit engine and compiler 13 -------------------------------------------------------------------------*/ 14 15 /* 16 Common types and defines for the engine and compiler 17 18 History: 19 16-Sep-2006 jk updated version to 2.4 (adding new compiler APIs for Bob E) 20 23-May-2005 jk patch for 64-bit architectures (thanks to Ulrik P) 21 18-Mar-2005 jk updated minor version for 2.3 (engine unchanged, XML option in compiler) 22 23-Sep-2003 jk updated for version 2.1 - extended status values 23 xx-xxx-2002 jk version 2.0 initial release 24 */ 25 26 #ifndef __TECkit_Common_H__ 27 #define __TECkit_Common_H__ 28 29 #define kCurrentTECkitVersion 0x00020004 /* 16.16 version number */ 30 31 #ifndef __MACTYPES__ 32 #ifndef MAC_TYPES /* these are all predefined if using a Mac prefix */ 33 typedef unsigned char UInt8; 34 typedef unsigned short UInt16; 35 typedef unsigned int UInt32; /* NB: assumes int is 4 bytes */ 36 #ifndef ZCONF_H /* n.b. if also using zlib.h, it must precede TECkit headers */ 37 typedef UInt8 Byte; 38 #endif 39 typedef Byte* BytePtr; 40 typedef UInt16 UniChar; 41 42 typedef char* Ptr; 43 typedef Byte* TextPtr; 44 #endif 45 #endif 46 47 /* 48 all public functions return a status code 49 */ 50 typedef long TECkit_Status; 51 52 /* 53 possible TECkit_Status return values 54 */ 55 #define kStatus_NoError 0 /* this is usually the desired result! */ 56 57 /* positive values are informational status values */ 58 /* low byte is the basic status of the conversion process */ 59 #define kStatusMask_Basic 0x000000FF 60 #define kStatus_OutputBufferFull 1 /* ConvertBuffer or Flush: output buffer full, so not all input was processed */ 61 #define kStatus_NeedMoreInput 2 /* ConvertBuffer: processed all input data, ready for next chunk */ 62 63 /* only returned in version 2.1 or later, with DontUseReplacementChar option */ 64 #define kStatus_UnmappedChar 3 /* ConvertBuffer or Flush: stopped at unmapped character */ 65 66 /* additional warning status in 2.1, only returned if 2.1-specific options are used */ 67 /* one byte of the status value is used for warning flags */ 68 #define kStatusMask_Warning 0x0000FF00 69 #define kStatus_UsedReplacement 0x00000100 /* ConvertBuffer or Flush: used default replacement character during mapping */ 70 71 /* negative values are errors */ 72 #define kStatus_InvalidForm -1 /* inForm or outForm parameter doesn't match mapping (bytes/Unicode mismatch) */ 73 #define kStatus_ConverterBusy -2 /* can't initiate a conversion, as the converter is already in the midst of an operation */ 74 #define kStatus_InvalidConverter -3 /* converter object is corrupted (or not really a TECkit_Converter at all) */ 75 #define kStatus_InvalidMapping -4 /* compiled mapping data is not recognizable */ 76 #define kStatus_BadMappingVersion -5 /* compiled mapping is not a version we can handle */ 77 #define kStatus_Exception -6 /* an internal error has occurred */ 78 #define kStatus_NameNotFound -7 /* couldn't find the requested name in the compiled mapping */ 79 #define kStatus_IncompleteChar -8 /* bad input data (lone surrogate, incomplete UTF8 sequence) */ 80 #define kStatus_CompilationFailed -9 /* mapping compilation failed (syntax errors, etc) */ 81 #define kStatus_OutOfMemory -10 /* unable to allocate required memory */ 82 83 /* 84 encoding form constants for TECkit_CreateConverter and TECkit_Compile 85 */ 86 #define kForm_EncodingFormMask 0x000F 87 #define kForm_Unspecified 0 /* invalid as argument to TECkit_CreateConverter */ 88 #define kForm_Bytes 1 89 #define kForm_UTF8 2 90 #define kForm_UTF16BE 3 91 #define kForm_UTF16LE 4 92 #define kForm_UTF32BE 5 93 #define kForm_UTF32LE 6 94 95 #endif 96