/[freetype]/freetype2/src/gxvalid/gxvcommn.h
ViewVC logotype

Diff of /freetype2/src/gxvalid/gxvcommn.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by mpsuzuki, Wed Aug 24 04:31:31 2005 UTC revision 1.2 by wl, Wed Aug 31 22:39:23 2005 UTC
# Line 16  Line 16 
16  /***************************************************************************/  /***************************************************************************/
17    
18  /***************************************************************************/  /***************************************************************************/
19    /*                                                                         */
20  /* gxvalid is derived from both gxlayout module and otvalid module.        */  /* gxvalid is derived from both gxlayout module and otvalid module.        */
21  /* Development of gxlayout was support of Information-technology Promotion */  /* Development of gxlayout is supported by the Information-technology      */
22  /* Agency(IPA), Japan.                                                     */  /* Promotion Agency(IPA), Japan.                                           */
23    /*                                                                         */
24  /***************************************************************************/  /***************************************************************************/
25    
26  /*  
27   * keywords in variable naming    /*
28   * ---------------------------     * keywords in variable naming
29   *  table: FT_Bytes typed, pointing the start of this table/subtable.     * ---------------------------
30   *  limit: FT_Bytes typed, pointing the end of this table/subtable     *  table: Of type FT_Bytes, pointing to the start of this table/subtable.
31   *         including padding for alignment.     *  limit: Of type FT_Bytes, pointing to the end of this table/subtable,
32   *  offset: FT_UInt typed, the number of octets from the start to target.     *         including padding for alignment.
33   *  length: FT_UInt typed, the number of octets from the start to the end.     *  offset: Of type FT_UInt, the number of octets from the start to target.
34   *          in this table/subtable, including padding for alignment.     *  length: Of type FT_UInt, the number of octets from the start to the
35   *     *          end in this table/subtable, including padding for alignment.
36   *  _MIN, _MAX: should be added to the tail of macros, as INT_MIN etc.     *
37   */     *  _MIN, _MAX: Should be added to the tail of macros, as INT_MIN, etc.
38       */
39    
40    
41  #ifndef __GXVCOMMN_H__  #ifndef __GXVCOMMN_H__
42  #define __GXVCOMMN_H__  #define __GXVCOMMN_H__
# Line 43  Line 47 
47  #include FT_INTERNAL_DEBUG_H  #include FT_INTERNAL_DEBUG_H
48  #include FT_SFNT_NAMES_H  #include FT_SFNT_NAMES_H
49    
 FT_BEGIN_HEADER  
50    
51    FT_BEGIN_HEADER
52    
53    
54    /*************************************************************************/    /*************************************************************************/
# Line 55  FT_BEGIN_HEADER Line 59  FT_BEGIN_HEADER
59    /*************************************************************************/    /*************************************************************************/
60    /*************************************************************************/    /*************************************************************************/
61    
62    typedef struct GXV_ValidatorRec_*         GXV_Validator;    typedef struct GXV_ValidatorRec_*  GXV_Validator;
63    
64    
65  #define DUMMY_LIMIT 0  #define DUMMY_LIMIT 0
66    typedef void  (*GXV_Validate_Func)( FT_Bytes      table,  
67                                        FT_Bytes      limit,    typedef void
68                                        GXV_Validator valid );    (*GXV_Validate_Func)( FT_Bytes       table,
69                            FT_Bytes       limit,
70                            GXV_Validator  valid );
71    
72    
73    /* ====================== LookupTable Validator ======================== */    /* ====================== LookupTable Validator ======================== */
74    
75    typedef union GXV_LookupValueDesc_    typedef union  GXV_LookupValueDesc_
76    {    {
77      FT_UShort u;      FT_UShort u;
78      FT_Short  s;      FT_Short  s;
# Line 78  FT_BEGIN_HEADER Line 86  FT_BEGIN_HEADER
86    
87    } GXV_LookupValue_SignSpec;    } GXV_LookupValue_SignSpec;
88    
89    typedef void  (*GXV_Lookup_Value_Validate_Func)( FT_UShort           glyph,  
90                                                     GXV_LookupValueDesc value,    typedef void
91                                                     GXV_Validator       valid );    (*GXV_Lookup_Value_Validate_Func)( FT_UShort            glyph,
92                                         GXV_LookupValueDesc  value,
93    typedef GXV_LookupValueDesc (*GXV_Lookup_Fmt4_Transit_Func)                                       GXV_Validator        valid );
94    ( FT_UShort            relative_gindex,  
95      GXV_LookupValueDesc  base_value,    typedef GXV_LookupValueDesc
96      FT_Bytes             lookuptbl_limit,    (*GXV_Lookup_Fmt4_Transit_Func)( FT_UShort            relative_gindex,
97      GXV_Validator        valid );                                     GXV_LookupValueDesc  base_value,
98                                       FT_Bytes             lookuptbl_limit,
99                                       GXV_Validator        valid );
100    
101    
102    /* ====================== StateTable Validator ========================= */    /* ====================== StateTable Validator ========================= */
# Line 104  FT_BEGIN_HEADER Line 114  FT_BEGIN_HEADER
114    } GXV_GlyphOffset_Format;    } GXV_GlyphOffset_Format;
115    
116    
117  #define GXV_GLYPHOFFSET_FMT( table ) \  #define GXV_GLYPHOFFSET_FMT( table )           \
118          ( valid-> table . entry_glyphoffset_fmt )          ( valid->table.entry_glyphoffset_fmt )
119    
120    #define GXV_GLYPHOFFSET_SIZE( table )              \
121            ( valid->table.entry_glyphoffset_fmt / 2 )
122    
 #define GXV_GLYPHOFFSET_SIZE( table ) \  
         ( ( valid-> table . entry_glyphoffset_fmt ) / 2 )  
123    
124    /* ----------------------- 16bit StateTable ---------------------------- */    /* ----------------------- 16bit StateTable ---------------------------- */
125    
126    typedef union  GXV_StateTable_GlyphOffsetDesc_    typedef union  GXV_StateTable_GlyphOffsetDesc_
127    {    {
128      FT_Byte   uc;      FT_Byte    uc;
129      FT_UShort u;   /* same with GXV_LookupValueDesc */      FT_UShort  u;       /* same as GXV_LookupValueDesc */
130      FT_ULong  ul;      FT_ULong   ul;
131      FT_Char   c;      FT_Char    c;
132      FT_Short  s;   /* same with GXV_LookupValueDesc */      FT_Short   s;       /* same as GXV_LookupValueDesc */
133      FT_Long   l;      FT_Long    l;
134    
135    } GXV_StateTable_GlyphOffsetDesc;    } GXV_StateTable_GlyphOffsetDesc;
136    
   typedef void  (*GXV_StateTable_Subtable_Setup_Func)( FT_UShort      table_size,  
                                                        FT_UShort      classTable,  
                                                        FT_UShort      stateArray,  
                                                        FT_UShort      entryTable,  
                                                        FT_UShort*     classTable_length_p,  
                                                        FT_UShort*     stateArray_length_p,  
                                                        FT_UShort*     entryTable_length_p,  
                                                        GXV_Validator  valid );  
   
   typedef void  (*GXV_StateTable_Entry_Validate_Func)( FT_Byte                         state,  
                                                        FT_UShort                       flags,  
                                                        GXV_StateTable_GlyphOffsetDesc  glyphOffset,  
                                                        FT_Bytes                        statetable_table,  
                                                        FT_Bytes                        statetable_limit,  
                                                        GXV_Validator                   valid );  
   
   typedef void  (*GXV_StateTable_OptData_Load_Func)( FT_Bytes       table,  
                                                      FT_Bytes       limit,  
                                                      GXV_Validator  valid );  
137    
138    typedef struct GXV_StateTable_ValidatorRec_    typedef void
139      (*GXV_StateTable_Subtable_Setup_Func)( FT_UShort      table_size,
140                                             FT_UShort      classTable,
141                                             FT_UShort      stateArray,
142                                             FT_UShort      entryTable,
143                                             FT_UShort*     classTable_length_p,
144                                             FT_UShort*     stateArray_length_p,
145                                             FT_UShort*     entryTable_length_p,
146                                             GXV_Validator  valid );
147    
148      typedef void
149      (*GXV_StateTable_Entry_Validate_Func)(
150         FT_Byte                         state,
151         FT_UShort                       flags,
152         GXV_StateTable_GlyphOffsetDesc  glyphOffset,
153         FT_Bytes                        statetable_table,
154         FT_Bytes                        statetable_limit,
155         GXV_Validator                   valid );
156    
157      typedef void
158      (*GXV_StateTable_OptData_Load_Func)( FT_Bytes       table,
159                                           FT_Bytes       limit,
160                                           GXV_Validator  valid );
161    
162      typedef struct  GXV_StateTable_ValidatorRec_
163    {    {
164      GXV_GlyphOffset_Format  entry_glyphoffset_fmt;      GXV_GlyphOffset_Format              entry_glyphoffset_fmt;
165      void*                   optdata;      void*                               optdata;
166      GXV_StateTable_Subtable_Setup_Func  
167                              subtable_setup_func;      GXV_StateTable_Subtable_Setup_Func  subtable_setup_func;
168      GXV_StateTable_Entry_Validate_Func      GXV_StateTable_Entry_Validate_Func  entry_validate_func;
169                              entry_validate_func;      GXV_StateTable_OptData_Load_Func    optdata_load_func;
     GXV_StateTable_OptData_Load_Func  
                             optdata_load_func;  
170    
171    } GXV_StateTable_ValidatorRec, *GXV_StateTable_ValidatorRecData;    } GXV_StateTable_ValidatorRec, *GXV_StateTable_ValidatorRecData;
172    
173    
174    /* ---------------------- 32bit XStateTable ---------------------------- */    /* ---------------------- 32bit XStateTable ---------------------------- */
175    
176    typedef GXV_StateTable_GlyphOffsetDesc GXV_XStateTable_GlyphOffsetDesc;    typedef GXV_StateTable_GlyphOffsetDesc  GXV_XStateTable_GlyphOffsetDesc;
177    
178      typedef void
179      (*GXV_XStateTable_Subtable_Setup_Func)( FT_ULong       table_size,
180                                              FT_ULong       classTable,
181                                              FT_ULong       stateArray,
182                                              FT_ULong       entryTable,
183                                              FT_ULong*      classTable_length_p,
184                                              FT_ULong*      stateArray_length_p,
185                                              FT_ULong*      entryTable_length_p,
186                                              GXV_Validator  valid );
187    
188      typedef void
189      (*GXV_XStateTable_Entry_Validate_Func)(
190         FT_UShort                       state,
191         FT_UShort                       flags,
192         GXV_StateTable_GlyphOffsetDesc  glyphOffset,
193         FT_Bytes                        xstatetable_table,
194         FT_Bytes                        xstatetable_limit,
195         GXV_Validator                   valid );
196    
197    
198    typedef void  (*GXV_XStateTable_Subtable_Setup_Func)( FT_ULong       table_size,    typedef GXV_StateTable_OptData_Load_Func  GXV_XStateTable_OptData_Load_Func;
                                                         FT_ULong       classTable,  
                                                         FT_ULong       stateArray,  
                                                         FT_ULong       entryTable,  
                                                         FT_ULong*      classTable_length_p,  
                                                         FT_ULong*      stateArray_length_p,  
                                                         FT_ULong*      entryTable_length_p,  
                                                         GXV_Validator  valid );  
   
   typedef void  (*GXV_XStateTable_Entry_Validate_Func)( FT_UShort      state,  
                                                         FT_UShort      flags,  
                                                         GXV_StateTable_GlyphOffsetDesc  
                                                                        glyphOffset,  
                                                         FT_Bytes       xstatetable_table,  
                                                         FT_Bytes       xstatetable_limit,  
                                                         GXV_Validator  valid );  
199    
   typedef GXV_StateTable_OptData_Load_Func GXV_XStateTable_OptData_Load_Func;  
200    
201    typedef struct GXV_XStateTable_ValidatorRec_    typedef struct  GXV_XStateTable_ValidatorRec_
202    {    {
203      int        entry_glyphoffset_fmt;      int                                  entry_glyphoffset_fmt;
204      void*      optdata;      void*                                optdata;
205      GXV_XStateTable_Subtable_Setup_Func  
206                 subtable_setup_func;      GXV_XStateTable_Subtable_Setup_Func  subtable_setup_func;
207      GXV_XStateTable_Entry_Validate_Func      GXV_XStateTable_Entry_Validate_Func  entry_validate_func;
208                 entry_validate_func;      GXV_XStateTable_OptData_Load_Func    optdata_load_func;
209      GXV_XStateTable_OptData_Load_Func  
210                 optdata_load_func;      FT_ULong                             nClasses;
211      FT_ULong   nClasses;      FT_UShort                            maxClassID;
     FT_UShort  maxClassID;  
212    
213    } GXV_XStateTable_ValidatorRec, *GXV_XStateTable_ValidatorRecData;    } GXV_XStateTable_ValidatorRec, *GXV_XStateTable_ValidatorRecData;
214    
215    
216    /* ===================================================================== */    /* ===================================================================== */
217    
218    typedef struct GXV_ValidatorRec_    typedef struct  GXV_ValidatorRec_
219    {    {
220      FT_Validator  root;      FT_Validator  root;
221    
# Line 221  FT_BEGIN_HEADER Line 239  FT_BEGIN_HEADER
239    
240    } GXV_ValidatorRec;    } GXV_ValidatorRec;
241    
242  #define GXV_TABLE_DATA( tag, field ) \  
243    #define GXV_TABLE_DATA( tag, field )                           \
244          ( ( (GXV_ ## tag ## _Data)valid->table_data )->field )          ( ( (GXV_ ## tag ## _Data)valid->table_data )->field )
245    
246  #undef  FT_INVALID_  #undef  FT_INVALID_
247  #define FT_INVALID_( _prefix, _error )                         \  #define FT_INVALID_( _prefix, _error )                         \
248            ft_validator_error( valid->root, _prefix ## _error )            ft_validator_error( valid->root, _prefix ## _error )
249    
250  #define GXV_LIMIT_CHECK( _count )                                      \  #define GXV_LIMIT_CHECK( _count )                                     \
251            FT_BEGIN_STMNT                                               \            FT_BEGIN_STMNT                                              \
252              if ( p + _count > ( limit? limit : valid->root->limit ) )  \              if ( p + _count > ( limit? limit : valid->root->limit ) ) \
253                  FT_INVALID_TOO_SHORT;                                  \                FT_INVALID_TOO_SHORT;                                   \
254            FT_END_STMNT            FT_END_STMNT
255    
256    
257  #ifdef FT_DEBUG_LEVEL_TRACE  #ifdef FT_DEBUG_LEVEL_TRACE
258    
259  #define GXV_INIT  valid->debug_indent = 0  #define GXV_INIT  valid->debug_indent = 0
260    
261  #define GXV_NAME_ENTER( name )                             \  #define GXV_NAME_ENTER( name )                             \
# Line 252  FT_BEGIN_HEADER Line 273  FT_BEGIN_HEADER
273              FT_TRACE4( s );                                \              FT_TRACE4( s );                                \
274            FT_END_STMNT            FT_END_STMNT
275    
276  #else   /* !FT_DEBUG_LEVEL_TRACE */  #else /* !FT_DEBUG_LEVEL_TRACE */
277    
278  #define GXV_INIT                do ; while ( 0 )  #define GXV_INIT                do ; while ( 0 )
279  #define GXV_NAME_ENTER( name )  do ; while ( 0 )  #define GXV_NAME_ENTER( name )  do ; while ( 0 )
280  #define GXV_EXIT                do ; while ( 0 )  #define GXV_EXIT                do ; while ( 0 )
# Line 261  FT_BEGIN_HEADER Line 283  FT_BEGIN_HEADER
283    
284  #endif  /* !FT_DEBUG_LEVEL_TRACE */  #endif  /* !FT_DEBUG_LEVEL_TRACE */
285    
286    
287    /*************************************************************************/    /*************************************************************************/
288    /*************************************************************************/    /*************************************************************************/
289    /*****                                                               *****/    /*****                                                               *****/
# Line 269  FT_BEGIN_HEADER Line 292  FT_BEGIN_HEADER
292    /*************************************************************************/    /*************************************************************************/
293    /*************************************************************************/    /*************************************************************************/
294    
295  #define GXV_32BIT_ALIGNMENT_VALIDATE( a )               \  #define GXV_32BIT_ALIGNMENT_VALIDATE( a ) \
296          FT_BEGIN_STMNT                                  \            FT_BEGIN_STMNT                  \
297            {                                             \              {                             \
298              if ( 0 != ( (a) % 4 ) ) FT_INVALID_OFFSET ; \                if ( 0 != ( (a) % 4 ) )     \
299            }                                             \                  FT_INVALID_OFFSET ;       \
300          FT_END_STMNT              }                             \
301              FT_END_STMNT
302    
303    
304    /*************************************************************************/    /*************************************************************************/
# Line 285  FT_BEGIN_HEADER Line 309  FT_BEGIN_HEADER
309    /*************************************************************************/    /*************************************************************************/
310    /*************************************************************************/    /*************************************************************************/
311    
312  #define  GXV_TRACE_HEXDUMP( p, len )                 \  #define GXV_TRACE_HEXDUMP( p, len )                     \
313           FT_BEGIN_STMNT                              \            FT_BEGIN_STMNT                                \
314             {                                         \              {                                           \
315               FT_Bytes b;                             \                FT_Bytes  b;                              \
316               for (b = p; b < (FT_Bytes)p + len; b++) \                                                          \
317                 FT_TRACE1(("\\x%02x", *b)) ;          \                                                          \
318             }                                         \                for ( b = p; b < (FT_Bytes)p + len; b++ ) \
319           FT_END_STMNT                  FT_TRACE1(("\\x%02x", *b)) ;            \
320                }                                           \
321  #define  GXV_TRACE_HEXDUMP_C( p, len )               \            FT_END_STMNT
322           FT_BEGIN_STMNT                              \  
323             {                                         \  #define GXV_TRACE_HEXDUMP_C( p, len )                   \
324               FT_Bytes b;                             \            FT_BEGIN_STMNT                                \
325               for (b = p; b < (FT_Bytes)p + len; b++) \              {                                           \
326                 if (0x40 < *b && *b < 0x7e)           \                FT_Bytes  b;                              \
327                   FT_TRACE1(("%c", *b)) ;             \                                                          \
328                 else                                  \                                                          \
329                   FT_TRACE1(("\\x%02x", *b)) ;        \                for ( b = p; b < (FT_Bytes)p + len; b++ ) \
330             }                                         \                  if ( 0x40 < *b && *b < 0x7e )           \
331           FT_END_STMNT                    FT_TRACE1(("%c", *b)) ;               \
332                    else                                    \
333                      FT_TRACE1(("\\x%02x", *b)) ;          \
334                }                                           \
335              FT_END_STMNT
336    
337    #define GXV_TRACE_HEXDUMP_SFNTNAME( n )               \
338              GXV_TRACE_HEXDUMP( n.string, n.string_len )
339    
 #define  GXV_TRACE_HEXDUMP_SFNTNAME( n )   GXV_TRACE_HEXDUMP( n.string, n.string_len )  
340    
341    /*************************************************************************/    /*************************************************************************/
342    /*************************************************************************/    /*************************************************************************/
# Line 341  FT_BEGIN_HEADER Line 371  FT_BEGIN_HEADER
371    gxv_glyphid_validate( FT_UShort      gid,    gxv_glyphid_validate( FT_UShort      gid,
372                          GXV_Validator  valid );                          GXV_Validator  valid );
373    
374    
375    /*************************************************************************/    /*************************************************************************/
376    /*************************************************************************/    /*************************************************************************/
377    /*****                                                               *****/    /*****                                                               *****/
# Line 392  FT_BEGIN_HEADER Line 423  FT_BEGIN_HEADER
423    /*************************************************************************/    /*************************************************************************/
424    /*************************************************************************/    /*************************************************************************/
425    
426  #define GXV_SUBTABLE_OFFSET_CHECK( _offset )        \  #define GXV_SUBTABLE_OFFSET_CHECK( _offset )          \
427           FT_BEGIN_STMNT                             \            FT_BEGIN_STMNT                              \
428            if ( (_offset) > valid->subtable_length ) \              if ( (_offset) > valid->subtable_length ) \
429              FT_INVALID_OFFSET;                      \                FT_INVALID_OFFSET;                      \
430           FT_END_STMNT            FT_END_STMNT
431    
432  #define GXV_SUBTABLE_LIMIT_CHECK( _count ) \  #define GXV_SUBTABLE_LIMIT_CHECK( _count )                  \
433           FT_BEGIN_STMNT                    \            FT_BEGIN_STMNT                                    \
434            if ( ( p + (_count) - valid->subtable_start ) > valid->subtable_length ) \              if ( ( p + (_count) - valid->subtable_start ) > \
435              FT_INVALID_TOO_SHORT;          \                     valid->subtable_length )                 \
436           FT_END_STMNT                FT_INVALID_TOO_SHORT;                         \
437              FT_END_STMNT
438    
439    #define GXV_USHORT_TO_SHORT( _us )                                    \
440              ( ( 0x8000U < ( _us ) ) ? ( ( _us ) - 0x8000U ) : ( _us ) )
441    
 #define GXV_USHORT_TO_SHORT( _us ) \  
          ( ( 0x8000 < ( _us ) ) ? ( ( _us ) - 0x8000 ) : ( _us ) )  
442    
443    /*************************************************************************/    /*************************************************************************/
444    /*************************************************************************/    /*************************************************************************/
# Line 415  FT_BEGIN_HEADER Line 448  FT_BEGIN_HEADER
448    /*************************************************************************/    /*************************************************************************/
449    /*************************************************************************/    /*************************************************************************/
450    
451    typedef struct GXV_odtect_DataRec_    typedef struct  GXV_odtect_DataRec_
452    {    {
453      FT_Bytes    start;      FT_Bytes    start;
454      FT_ULong    length;      FT_ULong    length;
# Line 423  FT_BEGIN_HEADER Line 456  FT_BEGIN_HEADER
456    
457    } GXV_odtect_DataRec,  *GXV_odtect_Data;    } GXV_odtect_DataRec,  *GXV_odtect_Data;
458    
459    typedef struct GXV_odtect_RangeRec_    typedef struct  GXV_odtect_RangeRec_
460    {    {
461      FT_UInt          nRanges;      FT_UInt          nRanges;
462      GXV_odtect_Data  range;      GXV_odtect_Data  range;
463    
464    } GXV_odtect_RangeRec, *GXV_odtect_Range;    } GXV_odtect_RangeRec, *GXV_odtect_Range;
465    
466  #define GXV_ODTECT( n, odtect )                       \  
467    GXV_odtect_DataRec   odtect ## _range[ n ];         \  #define GXV_ODTECT( n, odtect )                              \
468    GXV_odtect_RangeRec  odtect ## _rec = { 0, NULL };  \            GXV_odtect_DataRec   odtect ## _range[n];          \
469    GXV_odtect_Range     odtect = NULL            GXV_odtect_RangeRec  odtect ## _rec = { 0, NULL }; \
470              GXV_odtect_Range     odtect = NULL
471  #define GXV_ODTECT_INIT( odtect )                     \  
472          FT_BEGIN_STMNT                                \  #define GXV_ODTECT_INIT( odtect )                      \
473            odtect ## _rec.nRanges = 0;                 \            FT_BEGIN_STMNT                               \
474            odtect ## _rec.range   = odtect ## _range;  \              odtect ## _rec.nRanges = 0;                \
475            odtect                 = & odtect ## _rec;  \              odtect ## _rec.range   = odtect ## _range; \
476          FT_END_STMNT              odtect                 = & odtect ## _rec; \
477              FT_END_STMNT
478    
479    
480   /* */   /* */
481    
482  FT_END_HEADER  FT_END_HEADER
483    
484  #endif /* Not def: __GXVCOMMN_H__ */  #endif /* __GXVCOMMN_H__ */
485    
486    
487  /* END */  /* END */

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26