symbols.h 3.0 KB

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