Association List For Storing Name-Value Pairs

/*
**	(c) COPYRIGHT MIT 1995.
**	Please first read the full copyright statement in the file COPYRIGH.
*/
Lookups from association list are not case-sensitive.

This module is implemented by HTAssoc.c, and it is a part of the W3C Reference Library.

#ifndef HTASSOC_H
#define HTASSOC_H

#include "HTList.h"

typedef HTList HTAssocList;

typedef struct {
    char * name;
    char * value;
} HTAssoc;

extern HTAssocList *HTAssocList_new (void);
extern BOOL HTAssocList_delete	(HTAssocList * alist);

extern BOOL HTAssocList_add	(HTAssocList * alist,
				 const char * name, const char * value);

extern char *HTAssocList_lookup	(HTAssocList * alist, const char * name);

Get Name and Values

Use this to get the name and value of a assoc object
#define HTAssoc_name(me)	((me) ? (me)->name : NULL)
#define HTAssoc_value(me)	((me) ? (me)->value : NULL)

Traverse list

Fast macro to traverse the list. Call it first with copy of list header: it returns the first object and increments the passed list pointer. Call it with the same variable until it returns NULL.
#define	HTAssocList_nextObject(me) \
	((me) && ((me) = (me)->next) ? (me)->object : NULL)
#endif /* not HTASSOC_H */

@(#) $Id: HTAssoc.html,v 2.14 1996/04/12 17:45:53 frystyk Exp $