#ifndef TAGLIST_H
#define TAGLIST_H 1
/*
**	$Filename: libraries/taglist.h
**  $Release: 1.1 $
**	$Revision: 1.4 $
**	$Date: 1993/11/03 18:26:19 $
**	$Author: shepherd $
**
**	(C) Copyright 1992 Zeal-Computer.
**	All Rights Reserved
**
**	Disclaimer:
**    This  code  is  freely  redistributable upon the conditions that this
**    notice  remains intact and that modified versions of this file not be
**    distributed in any way. The author makes no warranty of any kind with
**    respect   to  this  product  and  explicitly  disclaims  any  implied
**    warranties of merchantability or fitness for any particular purpose.
**
**	History:
**	  92/11/12 First public release.
**	  93/11/6 Second public release.
*/

/*
** Include
*/
#ifndef EXEC_TYPES_H
#include <exec/types.h>
#endif

#ifndef UTILITY_TAGITEM_H
#define UTILITY_TAGITEM_H 1

typedef ULONG	Tag;

struct TagItem
{
	Tag		ti_Tag;
	ULONG	ti_Data;
};

#define TAG_DONE   		(0L)
#define TAG_END    		(0L)
#define	TAG_IGNORE 		(1L)
#define	TAG_MORE   		(2L)
#define	TAG_SKIP   		(3L)
#define TAG_USER 		(0x80000000L)

#define TAGFILTER_AND	(0L)
#define TAGFILTER_NOT	(1L)

#endif


/*
** When  opening  TagListLibrary use the following version number to ensure
** that the opened library will be compatible with this include file.
*/
#define TAGLIST_VERSION (2)

/*
** TagMapItem structure
*/
typedef struct TagMapItem TAGMAPITEM;
typedef struct TagItem TAGITEM;
typedef ULONG TAGDATA;
typedef ULONG TAGID;

struct TagMapItem
{
	ULONG	tmi_ID;
	WORD	tmi_Offset;
	UBYTE	tmi_Miss;
	UBYTE	tmi_Type;
	ULONG	tmi_Default;
};

/*
** TagMapItem types
*/
#define TMI_BYTE		(0)		/* store tagvalue in byte	*/
#define TMI_WORD		(4)		/* store tagvalue in word	*/
#define TMI_LONG		(8)		/* store tagvalue in long	*/
#define TMI_INT			(0)		/* tagvalue is an integer	*/
#define TMI_BOOL		(12)	/* TRUE sets bits			*/
#define TMI_bool		(24)	/* TRUE clears bits			*/
#define TMI_NODEFAULT	(0)		/* default undefined		*/
#define TMI_DEFAULT		(36)	/* default is TRUE 			*/
#define TMI_default		(60)	/* default is FALSE 		*/

/*
** Old name of TMI_INT
*/
#define TMI_REAL		TMI_INT

/*
** New TAG command (only to be used in TAGMAP items)
*/
#define TAG_INIT		(1)		/* copy default value */

/*
** TAGMAP(id,struct,entry,missbits,BYTE|WORD|LONG,INT|BOOL|bool,NODEFAULT|DEFAULT|default,value)
*/
#define TAGMAP(a,b,c,d,e,f,g,h) {a,OFFSET(b,c),(d)&0xFF,(((d)>>1)&0x80)+TMI_##e+TMI_##f+TMI_##g,h}

/*
** TAGMAPINIT(struct,entry,BYTE|WORD|LONG,INT|BOOL|bool,value)
*/
#define TAGMAPINIT(a,b,c,d,e) {TAG_INIT,OFFSET(a,b),0,TMI_##c+TMI_##d+(TMI_##d!=TMI_bool?TMI_DEFAULT:TMI_default),e}


/*
** TAGBUILD(id,struct,entry,BYTE|WORD|LONG,INT|BOOL|bool,bits)
*/
#define TAGBUILD(a,b,c,d,e,f) {a,OFFSET(b,c),0,TMI_##d+TMI_##e,f}

/*
** TAGBUILDINIT(id,value)
*/
#define TAGBUILDINIT(a,b) {TAG_INIT,((a)>>16),((a)>>8)&0xFF,(a)&0xFF,b}

/*
** How to use the TAGMAP macro
** ---------------------------
**
** The TAGMAP macro is used to define tagmaplists, if you don't know what a
** tagmaplist is I recommend that you read the autodocs for TagListLibrary.
**
** This  example  will  show  you  how  to  define  a tagmaplist with three
** tagmapitems.  The  "..."  signs indicate that something must be inserted
** here, and if you read on you will learn what it is.
**
**	TAGMAPITEM mytagmaplist[] =
**	{
**		TAGMAP(...),
**		TAGMAP(...),
**		TAG_DONE
**	};
**
** You  have  a structure named "NewWindow".  In this structure you have an
** entry named "LeftEdge" containing a 16 bit integer.  Now, you have a tag
** named  "WA_Left"  that  should  be maped into "LeftEdge".  If the tag is
** missing the value "0" should be store in "LeftEdge.  To do this you must
** create a TAGMAP item like this:
**
** TAGMAP(WA_Left,NewWindow,LeftEdge,0,        INT,   WORD,DEFAULT,0)
**        ^       ^         ^        ^         ^      ^    ^       ^
**        ID      Structure Entry    MissFlag  Number Size Default=0
**
** If  "LeftEdge"  is  the  position  of  the left edge of the window to be
** created,  it  may  be a better idea to center the window if no "WA_Left"
** tag  is found.  However to center a window you need to know the width of
** it  and  the  screen it will be created on.  So, if the "WA_Left" tag is
** missing  we  must know this.  The following TAGMAP item set bit 0 of the
** missflags.
**
** TAGMAP(WA_Left,NewWindow,LeftEdge,1,       INT,   WORD,NODEFAULT, 0)
**        ^       ^         ^        ^        ^      ^    ^          ^
**        ID      Structure Entry    MissFlag Number Size No default Ignored
** 
** The  "NewWindow"  structure  may also contain a flag like WFLG_ACTIVATE.
** The  tag "WA_Activate" should set the WFLG_ACTIVATE bit if it is TRUE of
** clear it if it is FALSE. By default we want the flag to be set. No other
** bits in the "Flags" entry will be changed. Please notice "Flags" is a 32
** bit number.
**
** TAGMAP(WA_Activate,NewWindow,Flags,0,       BOOL,LONG,DEFAULT,    WFLG_ACTIVATE)
**        ^           ^         ^     ^        ^    ^    ^           ^
**        ID          Structure Entry MissFlag Type Size Default=set Bits
** 
** If we want the flag to be cleared by default we should replace "DEFAULT"
** by its inverse "default" and write:
**
** TAGMAP(WA_Activate,NewWindow,Flags,0,       BOOL,LONG,default,    WFLG_ACTIVATE)
**        ^           ^         ^     ^        ^    ^    ^           ^
**        ID          Structure Entry MissFlag Type Size Default=clr Bits
**
** It possibile to create tags that clear flags when they are TRUE and set flags
** when they are FALSE. A tag called "WA_NoActivate" would look like this:
**
** TAGMAP(WA_NoActivate,NewWindow,Flags,0,       bool,LONG,default,    WFLG_ACTIVATE)
**        ^             ^         ^     ^        ^    ^    ^           ^
**        ID            Structure Entry MissFlag Type Size Default=set Bits
**
** When  you  use  inverse booleans you must remember to negate the deafult
** entry,  thus  the  combination  "bool"  / "default" will set the flag by
** default  and  the  combination "bool" / "DEFAULT" will clear the flag by
** default.
**
**
**
** How to use the TAGMAPINIT macro
** -------------------------------
**
** This macro is used to initialize a structure entry to some value and can
** do nothing which could not be done with use of the default feature found
** in the "TAGMAP" macro.
**
** If our "NewWindow" structure contained the following entries "LeftEdge",
** "TopEdge", "Width", and "Height" these four entries could be initialized
** using the following code:
**
**	TAGMAPITEM mytagmaplist[] =
**	{
**		TAGMAPINIT(NewWindow,LeftEdge,0),
**		TAGMAPINIT(NewWindow,TopEdge,0),
**		TAGMAPINIT(NewWindow,Width,640),
**		TAGMAPINIT(NewWindow,Height,200),
**		// add some TAGMAP macros here
**		TAG_DONE
**	};
**
**
** How to use the TAGBUILD macro
** -----------------------------
**
** The TAGBUILD macro is used to define tagmaplists, if you don't know what
** a   tagmaplist   is   I   recommend  that  you  read  the  autodocs  for
** TagListLibrary.
**
** This  example  will  show  you  how  to  define  a tagmaplist with three
** tagmapitems.  The  "..."  signs indicate that something must be inserted
** here, and if you read on you will learn what it is.
**
**	TAGMAPITEM mytagbuildlist[] =
**	{
**		TAGBUILD(...),
**		TAGBUILD(...),
**		TAG_DONE
**	};
**
** You  have  a structure named "NewWindow".  In this structure you have an
** entry named "LeftEdge" containing a 16 bit integer.  Now, you want to
** copy the value of "LeftEdge" into a tag called "WA_LeftEdge":
**
** TAGBUILD(WA_Left,NewWindow,LeftEdge,INT,   WORD,0)
**          ^       ^         ^        ^      ^    ^
**          ID      Structure Entry    Number Size Ignored
**
** The  "NewWindow"  structure  may also contain a flag like WFLG_ACTIVATE stored
** in the entry "Flags" which is a ULONG. If WFLG_ACTIVATE is set we want create
** a tag called "WA_Activate" with a tag value of TRUE, otherwise we want to create the
** tag with the value FALSE.
**
** TAGMAP(WA_Activate,NewWindow,Flags, BOOL, LONG,WFLG_ACTIVATE)
**        ^           ^         ^      ^     ^    ^
**        ID          Structure Offset Type  Size Bits
** 
** Maybe we would create a tag called "WA_NoActivate" instead of "WA_Activate". The tag value
** should of course be FLASE if WFLG_ACTIVATE is set and TRUE otherwise.
**
** TAGMAP(WA_NoActivate,NewWindow,Flags, bool,LONG,WFLG_ACTIVATE)
**        ^             ^         ^      ^    ^    ^
**        ID            Structure Offset Type Size Bits
**
**
** How to use the TAGBUILDINIT macro
** ---------------------------------
**
** This  macro is used to create tag with values read from the tagbuildlist
** and not from the structure.
**
**	TAGMAPITEM mytagbuildlist[] =
**	{
**		TAGBUILDINIT(WA_LeftEdge,0),
**		TAGBUILDINIT(WA_TopEdge,0),
**		TAGBUILDINIT(WA_Width,640),
**		TAGBUILDINIT(WA_Height,200),
**		// add some TAGBUILD macros here
**		TAG_DONE
**	};
*/


#endif /* TAGLIST_H */
