symtab.h File Reference

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

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

Go to the source code of this file.

Data Structures

union  isccc_symvalue

Defines

#define ISCCC_SYMTAB_H   1

Typedefs

typedef union isccc_symvalue isccc_symvalue_t
typedef void(* isccc_symtabundefaction_t )(char *key, unsigned int type, isccc_symvalue_t value, void *userarg)
typedef isc_boolean_t(* isccc_symtabforeachaction_t )(char *key, unsigned int type, isccc_symvalue_t value, void *userarg)

Enumerations

enum  isccc_symexists_t { isccc_symexists_reject = 0, isccc_symexists_replace = 1, isccc_symexists_add = 2 }

Functions

ISC_LANG_BEGINDECLS isc_result_t isccc_symtab_create (unsigned int size, isccc_symtabundefaction_t undefine_action, void *undefine_arg, isc_boolean_t case_sensitive, isccc_symtab_t **symtabp)
void isccc_symtab_destroy (isccc_symtab_t **symtabp)
isc_result_t isccc_symtab_lookup (isccc_symtab_t *symtab, const char *key, unsigned int type, isccc_symvalue_t *value)
isc_result_t isccc_symtab_define (isccc_symtab_t *symtab, char *key, unsigned int type, isccc_symvalue_t value, isccc_symexists_t exists_policy)
isc_result_t isccc_symtab_undefine (isccc_symtab_t *symtab, const char *key, unsigned int type)
void isccc_symtab_foreach (isccc_symtab_t *symtab, isccc_symtabforeachaction_t action, void *arg)


Detailed Description

Provides a simple memory-based symbol table.

Keys are C strings. 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 isccc_symtab_define() will not change until it calls isccc_symtab_undefine() or isccc_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.

Definition in file symtab.h.


Define Documentation

#define ISCCC_SYMTAB_H   1

Definition at line 35 of file symtab.h.


Typedef Documentation

typedef union isccc_symvalue isccc_symvalue_t

typedef void(* isccc_symtabundefaction_t)(char *key, unsigned int type, isccc_symvalue_t value, void *userarg)

Definition at line 94 of file symtab.h.

typedef isc_boolean_t(* isccc_symtabforeachaction_t)(char *key, unsigned int type, isccc_symvalue_t value, void *userarg)

Definition at line 97 of file symtab.h.


Enumeration Type Documentation

enum isccc_symexists_t

Enumerator:
isccc_symexists_reject 
isccc_symexists_replace 
isccc_symexists_add 

Definition at line 102 of file symtab.h.


Function Documentation

ISC_LANG_BEGINDECLS isc_result_t isccc_symtab_create ( unsigned int  size,
isccc_symtabundefaction_t  undefine_action,
void *  undefine_arg,
isc_boolean_t  case_sensitive,
isccc_symtab_t **  symtabp 
)

Definition at line 71 of file symtab.c.

References free(), ISC_LIST_INIT, ISC_R_NOMEMORY, ISC_R_SUCCESS, REQUIRE, symtab, and SYMTAB_MAGIC.

Referenced by isccc_cc_createsymtab().

void isccc_symtab_destroy ( isccc_symtab_t **  symtabp  ) 

Definition at line 114 of file symtab.c.

References free(), free_elt(), ISC_LIST_HEAD, ISC_LIST_NEXT, REQUIRE, symtab, and VALID_SYMTAB.

Referenced by ns_controls_destroy().

isc_result_t isccc_symtab_lookup ( isccc_symtab_t symtab,
const char *  key,
unsigned int  type,
isccc_symvalue_t value 
)

Definition at line 195 of file symtab.c.

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

isc_result_t isccc_symtab_define ( isccc_symtab_t symtab,
char *  key,
unsigned int  type,
isccc_symvalue_t  value,
isccc_symexists_t  exists_policy 
)

Definition at line 216 of file symtab.c.

References FIND, INSIST, ISC_LINK_INIT, ISC_LIST_PREPEND, ISC_LIST_UNLINK, ISC_R_EXISTS, ISC_R_NOMEMORY, ISC_R_SUCCESS, isccc_symexists_add, isccc_symexists_reject, isccc_symexists_replace, elt::key, REQUIRE, elt::type, VALID_SYMTAB, and elt::value.

Referenced by isccc_cc_checkdup().

isc_result_t isccc_symtab_undefine ( isccc_symtab_t symtab,
const char *  key,
unsigned int  type 
)

Definition at line 257 of file symtab.c.

References FIND, free_elt(), ISC_R_NOTFOUND, ISC_R_SUCCESS, REQUIRE, and VALID_SYMTAB.

void isccc_symtab_foreach ( isccc_symtab_t symtab,
isccc_symtabforeachaction_t  action,
void *  arg 
)

Definition at line 275 of file symtab.c.

References free_elt(), ISC_LIST_HEAD, ISC_LIST_NEXT, elt::key, REQUIRE, elt::type, VALID_SYMTAB, and elt::value.

Referenced by isccc_cc_cleansymtab().


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