1 #ifndef __OT_LAYOUT_H__
2 #define __OT_LAYOUT_H__
9 /************************************************************************/
10 /************************************************************************/
12 /***** BASE DATA TYPES *****/
14 /************************************************************************/
15 /************************************************************************/
17 typedef unsigned char OTL_Byte
;
18 typedef const OTL_Byte
* OTL_Bytes
;
20 typedef int OTL_Error
;
22 typedef void* OTL_Pointer
;
25 typedef unsigned int OTL_UInt
;
27 typedef long OTL_Long
;
28 typedef unsigned long OTL_ULong
;
30 typedef short OTL_Int16
;
31 typedef unsigned short OTL_UInt16
;
34 #if OTL_SIZEOF_INT == 4
36 typedef int OTL_Int32
;
37 typedef unsigned int OTL_UInt32
;
39 #elif OTL_SIZEOF_LONG == 4
41 typedef long OTL_Int32
;
42 typedef unsigned long OTL_UInt32
;
45 # error "no 32-bits type found"
48 typedef OTL_UInt32 OTL_Tag
;
50 /************************************************************************/
51 /************************************************************************/
53 /***** ERROR CODES *****/
55 /************************************************************************/
56 /************************************************************************/
61 OTL_Err_InvalidArgument
,
62 OTL_Err_InvalidFormat
,
63 OTL_Err_InvalidOffset
,
70 /************************************************************************/
71 /************************************************************************/
73 /***** MEMORY MANAGEMENT *****/
75 /************************************************************************/
76 /************************************************************************/
78 typedef OTL_Pointer (*OTL_AllocFunc
)( OTL_ULong size
,
81 typedef OTL_Pointer (*OTL_ReallocFunc
)( OTL_Pointer block
,
85 typedef void (*OTL_FreeFunc
)( OTL_Pointer block
,
88 typedef struct OTL_MemoryRec_
91 OTL_AllocFunc mem_alloc
;
92 OTL_ReallocFunc mem_realloc
;
93 OTL_FreeFunc mem_free
;
95 } OTL_MemoryRec
, *OTL_Memory
;
97 /************************************************************************/
98 /************************************************************************/
100 /***** ENUMERATIONS *****/
102 /************************************************************************/
103 /************************************************************************/
105 /* re-define OTL_MAKE_TAG to something different if you're not */
106 /* using an ASCII-based character set (Vaxes anyone ?) */
108 #define OTL_MAKE_TAG(c1,c2,c3,c4) \
109 ( ( (OTL_UInt32)(c1) << 24 ) | \
110 (OTL_UInt32)(c2) << 16 ) | \
111 (OTL_UInt32)(c3) << 8 ) | \
115 typedef enum OTL_ScriptTag_
119 #define OTL_SCRIPT_TAG(c1,c2,c3,c4,s,n) OTL_SCRIPT_TAG_ ## n = OTL_MAKE_TAG(c1,c2,c3,c4),
127 typedef enum OTL_LangTag_
129 OTL_LANG_DEFAULT
= 0,
131 #define OTL_LANG_TAG(c1,c2,c3,c4,s,n) OTL_LANG_TAG_ ## n = OTL_MAKE_TAG(c1,c2,c3,c4),
139 /************************************************************************/
140 /************************************************************************/
142 /***** MEMORY READS *****/
144 /************************************************************************/
145 /************************************************************************/
147 #define OTL_PEEK_USHORT(p) ( ((OTL_UInt)((p)[0]) << 8) | \
148 ((OTL_UInt)((p)[1]) ) )
150 #define OTL_PEEK_ULONG(p) ( ((OTL_UInt32)((p)[0]) << 24) | \
151 ((OTL_UInt32)((p)[1]) << 16) | \
152 ((OTL_UInt32)((p)[2]) << 8) | \
153 ((OTL_UInt32)((p)[3]) ) )
155 #define OTL_PEEK_SHORT(p) ((OTL_Int16)OTL_PEEK_USHORT(p))
157 #define OTL_PEEK_LONG(p) ((OTL_Int32)OTL_PEEK_ULONG(p))
159 #define OTL_NEXT_USHORT(p) ( (p) += 2, OTL_PEEK_USHORT((p)-2) )
160 #define OTL_NEXT_ULONG(p) ( (p) += 4, OTL_PEEK_ULONG((p)-4) )
162 #define OTL_NEXT_SHORT(p) ((OTL_Int16)OTL_NEXT_USHORT(p))
163 #define OTL_NEXT_LONG(p) ((OTL_Int32)OTL_NEXT_ULONG(p))
165 /************************************************************************/
166 /************************************************************************/
168 /***** VALIDATION *****/
170 /************************************************************************/
171 /************************************************************************/
173 typedef struct OTL_ValidatorRec_
* OTL_Validator
;
175 typedef struct OTL_ValidatorRec_
180 OTL_jmp_buf jump_buffer
;
184 typedef void (*OTL_ValidateFunc
)( OTL_Bytes table
,
188 otl_validator_error( OTL_Validator validator
,
191 #define OTL_INVALID(e) otl_validator_error( valid, e )
193 #define OTL_INVALID_TOO_SHORT OTL_INVALID( OTL_Err_InvalidOffset )
194 #define OTL_INVALID_DATA OTL_INVALID( OTL_Err_InvalidFormat )
196 #define OTL_CHECK(_count) OTL_BEGIN_STMNT \
197 if ( p + (_count) > valid->limit ) \
198 OTL_INVALID_TOO_SHORT; \
205 #endif /* __OPENTYPE_LAYOUT_H__ */