| 1 |
/** BEGIN COPYRIGHT BLOCK |
| 2 |
* Copyright (C) 2001 Sun Microsystems, Inc. Used by permission. |
| 3 |
* Copyright (C) 2005 Red Hat, Inc. |
| 4 |
* All rights reserved. |
| 5 |
* |
| 6 |
* License: GPL (version 3 or any later version). |
| 7 |
* See LICENSE for details. |
| 8 |
* END COPYRIGHT BLOCK **/ |
| 9 |
|
| 10 |
#ifdef HAVE_CONFIG_H |
| 11 |
#include <config.h> |
| 12 |
#endif |
| 13 |
|
| 14 |
#ifndef __symbols_h |
| 15 |
#define __symbols_h |
| 16 |
|
| 17 |
/* |
| 18 |
* Description (symbols.h) |
| 19 |
* |
| 20 |
* This file describes the interface to an ACL symbol table |
| 21 |
* implementation. The symbol table provides for storing symbols |
| 22 |
* keyed by name and type, creating a separate name space for |
| 23 |
* each symbol type. |
| 24 |
*/ |
| 25 |
|
| 26 |
#ifdef __PRIVATE_SYMBOLS |
| 27 |
|
| 28 |
#include "plhash.h" |
| 29 |
#include "base/crit.h" |
| 30 |
|
| 31 |
/* |
| 32 |
* Description (SymTable_t) |
| 33 |
* |
| 34 |
* This type describes a symbols table. It contains a pointer to |
| 35 |
* an NSPR hash table and a pointer to a monitor. The monitor is |
| 36 |
* needed even for read access to the symbol table because NSPR |
| 37 |
* modifies the list for a hash bucket when a name is looked up. |
| 38 |
*/ |
| 39 |
|
| 40 |
typedef struct SymTable_s SymTable_t; |
| 41 |
struct SymTable_s |
| 42 |
{ |
| 43 |
CRITICAL stb_crit; /* monitor pointer */ |
| 44 |
PLHashTable *stb_ht; /* hash table pointer */ |
| 45 |
}; |
| 46 |
|
| 47 |
|
| 48 |
/* Private functions defined in symbols.c */ |
| 49 |
/* |
| 50 |
static PLHashEntry * symAllocEntry(void * pool, const void *unused); |
| 51 |
static void * symAllocTable(void * pool, PRSize size); |
| 52 |
static int symCmpName(const void * name1, const void * name2); |
| 53 |
static int symCmpValue(const void * value1, const void * value2); |
| 54 |
static PLHashNumber symHash(const void * symkey); |
| 55 |
static void symFreeEntry(void * pool, PLHashEntry * he, PRUintn flag); |
| 56 |
static void symFreeTable(void * pool, void * item); |
| 57 |
*/ |
| 58 |
#endif /* __PRIVATE_SYMBOLS */ |
| 59 |
|
| 60 |
/* |
| 61 |
* Description (Symbol_t) |
| 62 |
* |
| 63 |
* This type describes a symbol table entry. A symbol is |
| 64 |
* identified by the combination of its name and type. This |
| 65 |
* structure is normally embedded in a structure for a particular |
| 66 |
* symbol type, which will contain the symbol "value" information |
| 67 |
* as well. |
| 68 |
*/ |
| 69 |
|
| 70 |
typedef struct Symbol_s Symbol_t; |
| 71 |
struct Symbol_s |
| 72 |
{ |
| 73 |
const char *sym_name; /* pointer to symbol name string */ |
| 74 |
int sym_type; /* symbol type */ |
| 75 |
void *sym_data; /* symbol data storage */ |
| 76 |
}; |
| 77 |
|
| 78 |
/* Define error return codes */ |
| 79 |
#define SYMERRNOMEM -1 /* insufficient dynamic memory */ |
| 80 |
#define SYMERRDUPSYM -2 /* duplicate symbol name and type */ |
| 81 |
#define SYMERRNOSYM -3 /* symbol name and type not found */ |
| 82 |
|
| 83 |
/* Define return flags for symTableEnumerate() func() */ |
| 84 |
#define SYMENUMSTOP 0x1 /* terminate enumeration */ |
| 85 |
#define SYMENUMREMOVE 0x2 /* remove entry from symbol table */ |
| 86 |
|
| 87 |
NSPR_BEGIN_EXTERN_C |
| 88 |
|
| 89 |
/* Public functions defined in symbols.c */ |
| 90 |
extern int symTableAddSym(void *table, Symbol_t *newsym, void *symref); |
| 91 |
extern void symTableRemoveSym(void *table, Symbol_t *sym); |
| 92 |
extern void symTableDestroy(void *table, int flags); |
| 93 |
extern void symTableEnumerate(void *table, void *argp, int (*func)(Symbol_t *sym, void *parg)); |
| 94 |
extern int symTableFindSym(void *table, const char *symname, int symtype, void **psymref); |
| 95 |
extern int symTableNew(void **ptable); |
| 96 |
|
| 97 |
NSPR_END_EXTERN_C |
| 98 |
|
| 99 |
#endif /* __symbols_h */ |