Hash :
e57ca7de
Author :
Date :
2002-11-07T01:36:29
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205
#ifndef __OT_LAYOUT_H__
#define __OT_LAYOUT_H__
#include "otlconf.h"
OTL_BEGIN_HEADER
/************************************************************************/
/************************************************************************/
/***** *****/
/***** BASE DATA TYPES *****/
/***** *****/
/************************************************************************/
/************************************************************************/
typedef unsigned char OTL_Byte;
typedef const OTL_Byte* OTL_Bytes;
typedef int OTL_Error;
typedef void* OTL_Pointer;
typedef int OTL_Int;
typedef unsigned int OTL_UInt;
typedef long OTL_Long;
typedef unsigned long OTL_ULong;
typedef short OTL_Int16;
typedef unsigned short OTL_UInt16;
#if OTL_SIZEOF_INT == 4
typedef int OTL_Int32;
typedef unsigned int OTL_UInt32;
#elif OTL_SIZEOF_LONG == 4
typedef long OTL_Int32;
typedef unsigned long OTL_UInt32;
#else
# error "no 32-bits type found"
#endif
typedef OTL_UInt32 OTL_Tag;
/************************************************************************/
/************************************************************************/
/***** *****/
/***** ERROR CODES *****/
/***** *****/
/************************************************************************/
/************************************************************************/
typedef enum
{
OTL_Err_Ok = 0,
OTL_Err_InvalidArgument,
OTL_Err_InvalidFormat,
OTL_Err_InvalidOffset,
OTL_Err_Max
} OTL_Error;
/************************************************************************/
/************************************************************************/
/***** *****/
/***** MEMORY MANAGEMENT *****/
/***** *****/
/************************************************************************/
/************************************************************************/
typedef OTL_Pointer (*OTL_AllocFunc)( OTL_ULong size,
OTL_Pointer data );
typedef OTL_Pointer (*OTL_ReallocFunc)( OTL_Pointer block,
OTL_ULong size,
OTL_Pointer data );
typedef void (*OTL_FreeFunc)( OTL_Pointer block,
OTL_Pointer data );
typedef struct OTL_MemoryRec_
{
OTL_Pointer mem_data;
OTL_AllocFunc mem_alloc;
OTL_ReallocFunc mem_realloc;
OTL_FreeFunc mem_free;
} OTL_MemoryRec, *OTL_Memory;
/************************************************************************/
/************************************************************************/
/***** *****/
/***** ENUMERATIONS *****/
/***** *****/
/************************************************************************/
/************************************************************************/
/* re-define OTL_MAKE_TAG to something different if you're not */
/* using an ASCII-based character set (Vaxes anyone ?) */
#ifndef OTL_MAKE_TAG
#define OTL_MAKE_TAG(c1,c2,c3,c4) \
( ( (OTL_UInt32)(c1) << 24 ) | \
(OTL_UInt32)(c2) << 16 ) | \
(OTL_UInt32)(c3) << 8 ) | \
(OTL_UInt32)(c4) )
#endif
typedef enum OTL_ScriptTag_
{
OTL_SCRIPT_NONE = 0,
#define OTL_SCRIPT_TAG(c1,c2,c3,c4,s,n) OTL_SCRIPT_TAG_ ## n = OTL_MAKE_TAG(c1,c2,c3,c4),
#include "otltags.h"
OTL_SCRIPT_MAX
} OTL_ScriptTag;
typedef enum OTL_LangTag_
{
OTL_LANG_DEFAULT = 0,
#define OTL_LANG_TAG(c1,c2,c3,c4,s,n) OTL_LANG_TAG_ ## n = OTL_MAKE_TAG(c1,c2,c3,c4),
#include "otltags.h"
OTL_LANG_MAX
} OTL_LangTag;
/************************************************************************/
/************************************************************************/
/***** *****/
/***** MEMORY READS *****/
/***** *****/
/************************************************************************/
/************************************************************************/
#define OTL_PEEK_USHORT(p) ( ((OTL_UInt)((p)[0]) << 8) | \
((OTL_UInt)((p)[1]) ) )
#define OTL_PEEK_ULONG(p) ( ((OTL_UInt32)((p)[0]) << 24) | \
((OTL_UInt32)((p)[1]) << 16) | \
((OTL_UInt32)((p)[2]) << 8) | \
((OTL_UInt32)((p)[3]) ) )
#define OTL_PEEK_SHORT(p) ((OTL_Int16)OTL_PEEK_USHORT(p))
#define OTL_PEEK_LONG(p) ((OTL_Int32)OTL_PEEK_ULONG(p))
#define OTL_NEXT_USHORT(p) ( (p) += 2, OTL_PEEK_USHORT((p)-2) )
#define OTL_NEXT_ULONG(p) ( (p) += 4, OTL_PEEK_ULONG((p)-4) )
#define OTL_NEXT_SHORT(p) ((OTL_Int16)OTL_NEXT_USHORT(p))
#define OTL_NEXT_LONG(p) ((OTL_Int32)OTL_NEXT_ULONG(p))
/************************************************************************/
/************************************************************************/
/***** *****/
/***** VALIDATION *****/
/***** *****/
/************************************************************************/
/************************************************************************/
typedef struct OTL_ValidatorRec_* OTL_Validator;
typedef struct OTL_ValidatorRec_
{
OTL_Bytes limit;
OTL_Bytes base;
OTL_Error error;
OTL_jmp_buf jump_buffer;
} OTL_ValidatorRec;
typedef void (*OTL_ValidateFunc)( OTL_Bytes table,
OTL_Valid valid );
OTL_API( void )
otl_validator_error( OTL_Validator validator,
OTL_Error error );
#define OTL_INVALID(e) otl_validator_error( valid, e )
#define OTL_INVALID_TOO_SHORT OTL_INVALID( OTL_Err_InvalidOffset )
#define OTL_INVALID_DATA OTL_INVALID( OTL_Err_InvalidFormat )
#define OTL_CHECK(_count) OTL_BEGIN_STMNT \
if ( p + (_count) > valid->limit ) \
OTL_INVALID_TOO_SHORT; \
OTL_END_STMNT
/* */
OTL_END_HEADER
#endif /* __OPENTYPE_LAYOUT_H__ */