--- ray/src/common/lookup.h 1998/09/02 18:42:11 2.5 +++ ray/src/common/lookup.h 2003/07/30 10:11:06 2.11 @@ -1,11 +1,18 @@ -/* Copyright (c) 1998 Silicon Graphics, Inc. */ - -/* SCCSid "$SunId$ SGI" */ - +/* RCSid $Id: lookup.h,v 2.11 2003/07/30 10:11:06 schorsch Exp $ */ /* * Header file for general associative table lookup routines */ +#ifndef _RAD_LOOKUP_H_ +#define _RAD_LOOKUP_H_ +#include /* strcmp() */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void lut_free_t(void*); + typedef struct { char *key; /* key name */ unsigned long hval; /* key hash value (for efficiency) */ @@ -13,18 +20,18 @@ typedef struct { } LUENT; typedef struct { - unsigned long (*hashf)(); /* key hash function */ - int (*keycmp)(); /* key comparison function */ - void (*freek)(); /* free a key */ - void (*freed)(); /* free the data */ + unsigned long (*hashf)(char*); /* key hash function */ + int (*keycmp)(const char*, const char*); /* key comparison function */ + lut_free_t *freek; /* free a key */ + lut_free_t *freed; /* free the data */ int tsiz; /* current table size */ LUENT *tabl; /* table, if allocated */ int ndel; /* number of deleted entries */ } LUTAB; #undef strcmp -#define LU_SINIT(fk,fd) {lu_shash,strcmp,(void (*)())(fk),\ - (void (*)())(fd),0,NULL,0} +#define LU_SINIT(fk,fd) {lu_shash,strcmp,fk,\ + fd,0,NULL,0} /* * The lu_init routine is called to initialize a table. The number of @@ -73,11 +80,16 @@ typedef struct { * allocated table itself. */ -extern int lu_init(); -extern LUENT *lu_find(); -extern void lu_delete(); -extern int lu_doall(); -extern void lu_done(); -extern unsigned long lu_shash(); +extern int lu_init(LUTAB *tbl, int nel); +extern unsigned long lu_shash(char *s); +extern LUENT *lu_find(LUTAB *tbl, char *key); +extern void lu_delete(LUTAB *tbl, char *key); +extern int lu_doall(LUTAB *tbl, int (*f)(LUENT*)); +extern void lu_done(LUTAB *tbl); -extern int strcmp(); + +#ifdef __cplusplus +} +#endif +#endif /* _RAD_LOOKUP_H_ */ +