symtab.h File Reference

Provides a simple memory-based symbol table. More...

#include <isc/lang.h>
#include <isc/types.h>

Go to the source code of this file.

Data Structures

union  isc_symvalue
 Symbol table value. More...

Defines

#define ISC_SYMTAB_H   1

Typedefs

typedef union isc_symvalue isc_symvalue_t
typedef void(* isc_symtabaction_t )(char *key, unsigned int type, isc_symvalue_t value, void *userarg)

Enumerations

enum  isc_symexists_t { isc_symexists_reject = 0, isc_symexists_replace = 1, isc_symexists_add = 2 }
 Symbol table exists. More...

Functions

ISC_LANG_BEGINDECLS isc_result_t isc_symtab_create (isc_mem_t *mctx, unsigned int size, isc_symtabaction_t undefine_action, void *undefine_arg, isc_boolean_t case_sensitive, isc_symtab_t **symtabp)
 Create a symbol table.
void isc_symtab_destroy (isc_symtab_t **symtabp)
 Destroy a symbol table.
isc_result_t isc_symtab_lookup (isc_symtab_t *symtab, const char *key, unsigned int type, isc_symvalue_t *value)
 Lookup a symbol table.
isc_result_t isc_symtab_define (isc_symtab_t *symtab, const char *key, unsigned int type, isc_symvalue_t value, isc_symexists_t exists_policy)
 Define a symbol table.
isc_result_t isc_symtab_undefine (isc_symtab_t *symtab, const char *key, unsigned int type)
 Undefine a symbol table.
unsigned int isc_symtab_count (isc_symtab_t *symtab)
 Return the number of items in a symbol table.


Detailed Description

Provides a simple memory-based symbol table.

Keys are C strings, and key comparisons are case-insensitive. A type may be specified when looking up, defining, or undefining. A type value of 0 means "match any type"; any other value will only match the given type.

It's possible that a client will attempt to define a <key, type, value> tuple when a tuple with the given key and type already exists in the table. What to do in this case is specified by the client. Possible policies are:

A lookup of a key using type 0 will return the most-recently defined symbol with that key. An undefine of a key using type 0 will undefine the most-recently defined symbol with that key. Trying to define a key with type 0 is illegal.

The symbol table library does not make a copy the key field, so the caller must ensure that any key it passes to isc_symtab_define() will not change until it calls isc_symtab_undefine() or isc_symtab_destroy().

A user-specified action will be called (if provided) when a symbol is undefined. It can be used to free memory associated with keys and/or values.

A symbol table is implemented as a hash table of lists; the size of the hash table is set by the 'size' parameter to isc_symtbl_create(). When the number of entries in the symbol table reaches three quarters of this value, the hash table is reallocated with size doubled, in order to optimize lookup performance. This has a negative effect on insertion performance, which can be mitigated by sizing the table appropriately when creating it.

Definition in file symtab.h.


Define Documentation

#define ISC_SYMTAB_H   1

Definition at line 21 of file symtab.h.


Typedef Documentation

typedef union isc_symvalue isc_symvalue_t

typedef void(* isc_symtabaction_t)(char *key, unsigned int type, isc_symvalue_t value, void *userarg)

Definition at line 102 of file symtab.h.


Enumeration Type Documentation

enum isc_symexists_t

Symbol table exists.

Enumerator:
isc_symexists_reject  Disallow the define.
isc_symexists_replace  Replace the old value with the new.
isc_symexists_add  Add the new tuple.

Definition at line 105 of file symtab.h.


Function Documentation

ISC_LANG_BEGINDECLS isc_result_t isc_symtab_create ( isc_mem_t mctx,
unsigned int  size,
isc_symtabaction_t  undefine_action,
void *  undefine_arg,
isc_boolean_t  case_sensitive,
isc_symtab_t **  symtabp 
)

Create a symbol table.

Definition at line 58 of file symtab.c.

References INIT_LIST, isc_mem_attach(), isc_mem_get, isc_mem_putanddetach, ISC_R_NOMEMORY, ISC_R_SUCCESS, REQUIRE, symtab, and SYMTAB_MAGIC.

Referenced by add(), ATF_TC_BODY(), bind9_check_logging(), bind9_check_namedconf(), check_options(), check_viewconf(), create_map(), and validate_masters().

void isc_symtab_destroy ( isc_symtab_t **  symtabp  ) 

Destroy a symbol table.

Definition at line 99 of file symtab.c.

References HEAD, isc_mem_put, isc_mem_putanddetach, elt::key, NEXT, REQUIRE, symtab, elt::type, VALID_SYMTAB, and elt::value.

Referenced by ATF_TC_BODY(), bind9_check_logging(), bind9_check_namedconf(), check_options(), check_viewconf(), free_map(), and validate_masters().

isc_result_t isc_symtab_lookup ( isc_symtab_t symtab,
const char *  key,
unsigned int  type,
isc_symvalue_t value 
)

Lookup a symbol table.

Definition at line 170 of file symtab.c.

References FIND, ISC_R_NOTFOUND, ISC_R_SUCCESS, REQUIRE, VALID_SYMTAB, and elt::value.

Referenced by ATF_TC_BODY(), bind9_check_logging(), bind9_check_namedconf(), cfg_map_get(), cfg_parse_mapbody(), cfg_parser_mapadd(), cfg_print_mapbody(), check_keylist(), check_servers(), fileexist(), logged(), and nameexist().

isc_result_t isc_symtab_define ( isc_symtab_t symtab,
const char *  key,
unsigned int  type,
isc_symvalue_t  value,
isc_symexists_t  exists_policy 
)

Define a symbol table.

Definition at line 231 of file symtab.c.

References DE_CONST, FIND, grow_table(), INSIST, ISC_LINK_INIT, isc_mem_get, ISC_R_EXISTS, ISC_R_NOMEMORY, ISC_R_SUCCESS, isc_symexists_add, isc_symexists_reject, isc_symexists_replace, elt::key, PREPEND, REQUIRE, elt::type, UNLINK, VALID_SYMTAB, and elt::value.

Referenced by add(), ATF_TC_BODY(), bind9_check_logging(), bind9_check_namedconf(), cfg_parse_mapbody(), cfg_parser_mapadd(), check_keylist(), fileexist(), nameexist(), parse_symtab_elt(), and validate_masters().

isc_result_t isc_symtab_undefine ( isc_symtab_t symtab,
const char *  key,
unsigned int  type 
)

Undefine a symbol table.

Definition at line 283 of file symtab.c.

References FIND, isc_mem_put, ISC_R_NOTFOUND, ISC_R_SUCCESS, elt::key, REQUIRE, elt::type, UNLINK, VALID_SYMTAB, and elt::value.

Referenced by ATF_TC_BODY().

unsigned int isc_symtab_count ( isc_symtab_t symtab  ) 

Return the number of items in a symbol table.

Definition at line 306 of file symtab.c.

References REQUIRE, and VALID_SYMTAB.

Referenced by cfg_map_count().


Generated on Tue Apr 28 17:41:16 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha