/*-*-C-*-
 * resformat include file - defines overall resource file format
 */

#define MAX_OBJECT_NAME 12         /* as defined by Resource file format */
                                   /* includes terminating NUL */

/* ----------------------- Abstract field types -------------------------- */

typedef unsigned int Opaque;   /* Used for document & object IDs in msgs */

typedef int ObjectClass;       /* the abstract class of an Object */

/* fields of these types only appear inside object template bodies */

typedef int ComponentID;         /* component ID within an Object */
typedef int Offset;              /* relocatable offsets within objects; eg a
                                     pointer to a gadget in a window */
typedef int StringReference;     /* offset into Object's string table,
                                     or -1 for null reference*/
typedef int MessageReference;    /* offset into Object's messages table,
                                   or -1 for null reference */

#define  CLIENT_SPRITEAREA  (0)
#define  WIMP_SPRITEAREA   (-1)

typedef int SpriteAreaReference; /* possible vaues are given above */



/* ---------------------- Resource file format --------------------------- */


/* object template flags - common to all object classes */

#define OBJECT_CREATEONLOAD      0x00000001
#define OBJECT_SHOWONCREATE      0x00000002
#define OBJECT_SHARED            0x00000004
#define OBJECT_ANCESTOR          0x00000008
                        

/* object template header */

typedef struct
{
    ObjectClass class;           /* class of the object */
    int flags;                   /* generic flags (see above) */
    int version;                 /* object class module version */
    char name[MAX_OBJECT_NAME];  /* object's name */
    int totalsize;               /* size of whole object (inc header) */
    int bodyoffset;              /* object body */
    int bodysize;                /* size of body */

    /* object template body data follows - see CSE for format definition */

} ObjectTemplateHeaderRec, *ObjectTemplateHeaderPtr;


/* relocation directives */

#define RELOCATE_STRINGREFERENCE     1  /* add address of string table */
#define RELOCATE_MSGREFERENCE        2  /* add address of messages table */
#define RELOCATE_SPRITEAREAREFERENCE 3  /* insert client sprite area address
                                            if value is 0 */
#define RELOCATE_OBJECTOFFSET        4  /* add address of object body */


/* a relocation record */

typedef struct
{
    int  wordtorelocate;   /* as offset relative to base of object body */
    int  directive;
} RelocationRec, *RelocationPtr;


/* the relocation table */

typedef struct
{
    int numrelocations;               /* will always be > 0 */
    RelocationRec relocations[1];
} RelocationTableRec, *RelocationTablePtr;


/* object template */

typedef struct
{
    int stringtableoffset;      /* -1 if no string table  */
    int messagetableoffset;     /* -1 if no message table */
    int relocationtableoffset;  /* -1 if no relocations   */
    ObjectTemplateHeaderRec hdr;

 /* followed by object's body and string, messages and relocations tables */

} ResourceFileObjectTemplateHeaderRec, *ResourceFileObjectTemplateHeaderPtr;


/* resource file header */

typedef struct
{
    int fileid;         /* should be 'RESF' */
    int versionnumber;  /* resource file version number * 100 */
    int objectoffset;   /* byte offset of first template from file start, or
                             -1 if none */
} ResourceFileHeaderRec, *ResourceFileHeaderPtr;

/* ----------------------------------------------------------------------- */
