ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/lookup.h
(Generate patch)

Comparing ray/src/common/lookup.h (file contents):
Revision 2.7 by greg, Tue Feb 25 02:47:21 2003 UTC vs.
Revision 2.15 by greg, Fri Feb 18 00:40:25 2011 UTC

# Line 2 | Line 2
2   /*
3   * Header file for general associative table lookup routines
4   */
5 + #ifndef _RAD_LOOKUP_H_
6 + #define _RAD_LOOKUP_H_
7  
8 < #include "copyright.h"
8 > #ifdef __cplusplus
9 > extern "C" {
10 > #endif
11  
12 + typedef void lut_free_t(void *p);
13 + typedef unsigned long lut_hashf_t(const char *);
14 + typedef int lut_keycmpf_t(const char *, const char *);
15 +
16   typedef struct {
17          char    *key;                   /* key name */
18          unsigned long   hval;           /* key hash value (for efficiency) */
# Line 12 | Line 20 | typedef struct {
20   } LUENT;
21  
22   typedef struct {
23 <        unsigned long   (*hashf)();     /* key hash function */
24 <        int     (*keycmp)();            /* key comparison function */
25 <        void    (*freek)();             /* free a key */
26 <        void    (*freed)();             /* free the data */
23 >        lut_hashf_t *hashf;             /* key hash function */
24 >        lut_keycmpf_t *keycmp;          /* key comparison function */
25 >        lut_free_t *freek;              /* free a key */
26 >        lut_free_t *freed;              /* free the data */
27          int     tsiz;                   /* current table size */
28          LUENT   *tabl;                  /* table, if allocated */
29          int     ndel;                   /* number of deleted entries */
30   } LUTAB;
31  
24 #undef strcmp
25 #define LU_SINIT(fk,fd)         {lu_shash,strcmp,(void (*)())(fk),\
26                                (void (*)())(fd),0,NULL,0}
32  
33   /*
34   * The lu_init routine is called to initialize a table.  The number of
# Line 72 | Line 77 | typedef struct {
77   * allocated table itself.
78   */
79  
80 < extern int      strcmp();
80 > typedef int lut_doallf_t(const LUENT *e, void *p);
81  
77 #ifdef NOPROTO
78
79 extern int      lu_init();
80 extern LUENT    *lu_find();
81 extern void     lu_delete();
82 extern int      lu_doall();
83 extern void     lu_done();
84 extern unsigned long    lu_shash();
85
86 #else
87
82   extern int      lu_init(LUTAB *tbl, int nel);
83 < extern unsigned long    lu_shash(char *s);
84 < extern LUENT    *lu_find(LUTAB *tbl, char *key);
85 < extern void     lu_delete(LUTAB *tbl, char *key);
86 < extern int      lu_doall(LUTAB *tbl, int (*f)());
83 > extern lut_hashf_t      lu_shash;
84 > extern LUENT    *lu_find(LUTAB *tbl, const char *key);
85 > extern void     lu_delete(LUTAB *tbl, const char *key);
86 > extern int      lu_doall(const LUTAB *tbl, lut_doallf_t *f, void *p);
87   extern void     lu_done(LUTAB *tbl);
88  
89 + #define LU_SINIT(fk,fd) {lu_shash,strcmp,fk,fd,0,NULL,0}
90 +
91 + #ifdef __cplusplus
92 + }
93   #endif
94 + #endif /* _RAD_LOOKUP_H_ */
95 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines