#include <config.h>
#include <ctype.h>
#include <stdlib.h>
#include <isc/assertions.h>
#include <isc/magic.h>
#include <isc/string.h>
#include <isccc/result.h>
#include <isccc/symtab.h>
#include <isccc/util.h>
Go to the source code of this file.
Data Structures | |
struct | elt |
Defines | |
#define | SYMTAB_MAGIC ISC_MAGIC('S', 'y', 'm', 'T') |
#define | VALID_SYMTAB(st) ISC_MAGIC_VALID(st, SYMTAB_MAGIC) |
#define | FIND(s, k, t, b, e) |
Typedefs | |
typedef struct elt | elt_t |
Functions | |
typedef | ISC_LIST (elt_t) |
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) |
static void | free_elt (isccc_symtab_t *symtab, unsigned int bucket, elt_t *elt) |
void | isccc_symtab_destroy (isccc_symtab_t **symtabp) |
static unsigned int | hash (const char *key, isc_boolean_t case_sensitive) |
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) |
Definition in file symtab.c.
#define SYMTAB_MAGIC ISC_MAGIC('S', 'y', 'm', 'T') |
#define VALID_SYMTAB | ( | st | ) | ISC_MAGIC_VALID(st, SYMTAB_MAGIC) |
#define FIND | ( | s, | |||
k, | |||||
t, | |||||
b, | |||||
e | ) |
Value:
b = hash((k), (s)->case_sensitive) % (s)->size; \ if ((s)->case_sensitive) { \ for (e = ISC_LIST_HEAD((s)->table[b]); \ e != NULL; \ e = ISC_LIST_NEXT(e, link)) { \ if (((t) == 0 || e->type == (t)) && \ strcmp(e->key, (k)) == 0) \ break; \ } \ } else { \ for (e = ISC_LIST_HEAD((s)->table[b]); \ e != NULL; \ e = ISC_LIST_NEXT(e, link)) { \ if (((t) == 0 || e->type == (t)) && \ strcasecmp(e->key, (k)) == 0) \ break; \ } \ }
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().
static void free_elt | ( | isccc_symtab_t * | symtab, | |
unsigned int | bucket, | |||
elt_t * | elt | |||
) | [inline, static] |
Definition at line 105 of file symtab.c.
References free(), ISC_LIST_UNLINK, elt::key, elt::type, and elt::value.
Referenced by isccc_symtab_destroy(), isccc_symtab_foreach(), and isccc_symtab_undefine().
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().
static unsigned int hash | ( | const char * | key, | |
isc_boolean_t | case_sensitive | |||
) | [inline, static] |
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().