libTagList

DOWNLOAD
Tarball (7.4 kB)
ABOUT LIBTAGLIST
This is a reverse engineered port of the beautiful concept of tag lists on the Amiga. A tag list is an array with pairs of tag identifier and tag data. To make it really beautiful one uses variable argument lists and hands the list there. The tags that the function don't care about it just ignores. There are several functions to manipulate these lists. If you are already familiar with the concept you will feel right at home as I've used the same function names.
STATUS
Almost finished. A few functions is still left to do... will do them later =).
EXAMPLE
This is what a program using tags could look like.

#define ATTR_COLOR (TAG_USER|0x01L)
#define ATTR_SHAPE (TAG_USER|0x02L)
#define ATTR_LTYPE (TAG_USER|0x03L)
#deinfe ATTR_WIDTH (TAG_USER|0x04L)
#define ATTR_HEIGHT (TAG_USER|0x05L)

#define SHAPE_DOT 0
#define SHAPE_BOX 1
#define SHAPE_CIRCLE 2


char *defaultcol="#008080";

/* Varargs stub */
int TestFunc( int x, int y, ... )
{
	struct TagItem *tags=&y+1;
	return( TestFuncA( x, y, tags ) );
}

int TestFuncA( int x, int y, struct TagItem *tags )
{
	char *color;

	/* If a tag with ATTR_COLOR is found it's value is used */
	/* otherwise the default value will be used */
	color=(char *)GetTagData( ATTR_COLOR, defaultcol, tags );
	...
	DoSomeImportantStuff(TM);
	...
	return(...);
}

void main( void )
{
	TestFunc( 40, 25,
		ATTR_COLOR,"#804000",
		ATTR_SHAPE, SHAPE_BOX,
		ATTR_WIDTH, 19,
		ATTR_HEIGHT, 25,
		TAG_DONE
	);
}
You see that it's great for optional values. There are ofcause a bunch more functions than GetTagData. Manual included =).
LICENSE
It's licensed under Do what ever you like with it as long as you don't hold me responsible, and use it at your own risk-license

Copyright © 1999-2004 Fredrik Rambris <fredrik at rambris.com>. All rights reserved.

http:// last changed  2007-Jan-22 13:36