home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ETKEXP.ZIP / ATTR.H next >
Text File  |  1991-11-21  |  3KB  |  72 lines

  1. #ifndef ATTR_INCLUDED
  2.    #define ATTR_INCLUDED
  3.    typedef unsigned char   AttribClassType;
  4.    typedef signed long     AttribValueType;
  5.    #define INVALIDCLASS    ((AttribClassType)0)
  6.    #define COLORCLASS      ((AttribClassType)1)
  7.    #define MAXCOLOR        ((AttribValueType)255)
  8.    #define FLOWCLASS       ((AttribClassType)2)
  9.    #define JUSTIFYCLASS    ((AttribClassType)3)
  10.    #define FONTCLASS       ((AttribClassType)16)
  11.    #define BREAKCLASS      ((AttribClassType)17)
  12.    #define LINEBREAKLEVEL  0x10
  13.    #define COLMBREAKLEVEL  0x40
  14.    #define STACKBREAKLEVEL 0x60
  15.    #define DIVNBREAKLEVEL  0x80
  16.    #define HSPACECLASS     ((AttribClassType)18)
  17.    #define DIVISIONCLASS   ((AttribClassType)19)
  18.  
  19.    // pack the following structures on byte boundaries.
  20.    #pragma pack(1)
  21.  
  22.    typedef struct AttribRecType {
  23.      USHORT          Col;
  24.      AttribClassType Class;
  25.      UCHAR           IsPush;
  26.      AttribValueType Value;
  27.    } AttribRecType;
  28.  
  29.    #define MAXATTRBPL       255
  30.    #define MAXATTRBSPACE    (MAXATTRBPL*sizeof(AttribRecType))
  31.  
  32.    // the following type is allocated by AllocNullAttrString() and freed
  33.    // via FreeAttrString(); The Text will grow from s[0] toward the
  34.    // end of the record and the attributes will positioned so that
  35.    // the last one is flush with the end of the allocated space for
  36.    // this structure.
  37.    typedef struct _attrstring_t {
  38.       AttribRecType *ALAttr;
  39.       AttribRecType *Attrs;
  40.       PCHAR SelfPtr;      // this is a redundant field that points to itself.
  41.                           //   This field is automatically initialized when
  42.                           //   when the attrstring is created.
  43.                           // procedures that receive attrstring's that
  44.                           //   may have been created before the previous
  45.                           //   heap compact should check this field to
  46.                           //   insure that it still points to the Text
  47.                           //   field.  They can do this by using the
  48.                           //   ATTRSTRING_REVALIDATE() macro.  This is
  49.                           //   necessary since the Attrs and ALAttr fields
  50.                           //   become invalid when the heap compacter moves
  51.                           //   the attrstring.
  52.       SHORT  TextLen;
  53.       CHAR   Text[1];
  54.    } attrstring_t;
  55.    typedef attrstring_t   *attrstring_ftp;
  56.    typedef attrstring_ftp *attrstring_ftpp;
  57.    #define access_as(a)   (*((attrstring_ftpp)(a)))
  58.    #define ATTRSTRING_REVALIDATE(ina) \
  59.           { \
  60.              attrstring_ftp as = *(ina); \
  61.              if (((PVOID)&(as->SelfPtr))!=(PVOID)as->SelfPtr) { \
  62.                 as->Attrs  = (AttribRecType*)((PCHAR)&(as->SelfPtr) + ((PCHAR)as->Attrs  - as->SelfPtr)); \
  63.                 as->ALAttr = (AttribRecType*)((PCHAR)&(as->SelfPtr) + ((PCHAR)as->ALAttr - as->SelfPtr)); \
  64.                 as->SelfPtr= (PCHAR)&(as->SelfPtr); \
  65.              } /* endif */ \
  66.           }
  67.  
  68.    // return to the type of packing specified on the command line.
  69.    #pragma pack()
  70. #endif
  71.  
  72.