kb_symbol.c File Reference

This module provides primitive to handle symbol table. More...

Include dependency graph for kb_symbol.c:

Go to the source code of this file.

Functions

kb_symbol_table_tkb_create_symbol_table (kb_symbol_table_t *table)
void kb_destroy_symbol_table (kb_symbol_table_t *table)
unsigned long kb_hash (const char *name)
int kb_add_symbol (kb_symbol_table_t *table, kb_symbol_t *knew)
kb_symbol_tkb_lookup_symbol (kb_symbol_table_t *table, const char *name)
void kb_dump_symbol_table (kb_symbol_table_t *table)

Variables

const char * kb_symbol_type_names []


Detailed Description

This module provides primitive to handle symbol table.

Symbol Table Management

Author:
CÚdric Gaudin (K-Team SA)
Note:
Copyright (C) 2004 K-TEAM SA
Bug:
none discovered
Todo:
nothing.

Definition in file kb_symbol.c.


Function Documentation

int kb_add_symbol ( kb_symbol_table_t table,
kb_symbol_t knew 
)

This function adds a given symbol into a given table.

Parameters:
table A symbol table
new A new symbol
Returns:
A value:
  • 0 symbol already defined
  • 1 new symbol added

Definition at line 128 of file kb_symbol.c.

References kb_table_s::count, kb_hash(), KB_SYMBOL_TABLE_SIZE, kb_table_s::lock, kb_symbol_s::name, kb_symbol_s::next, and kb_table_s::symbols.

Referenced by kb_parse_alias(), kb_parse_device(), kb_parse_register(), and kb_parse_section().

Here is the call graph for this function:

kb_symbol_table_t* kb_create_symbol_table ( kb_symbol_table_t table  ) 

This function initializes a given table of symbol.

Parameters:
table A pointer to a symbol table or NULL.
Returns:
A pointer to the initialized symbol table

Definition at line 42 of file kb_symbol.c.

References kb_table_s::count, KB_ALLOC, KB_SYMBOL_TABLE_SIZE, kb_table_s::lock, and kb_table_s::symbols.

Referenced by kb_config_init().

void kb_destroy_symbol_table ( kb_symbol_table_t table  ) 

This function destroys all elements in a given symbol table.

Parameters:
table A pointer to the given symbol table
Remarks:
table is never freed.

Definition at line 67 of file kb_symbol.c.

References kb_symbol_s::alloc, kb_table_s::count, kb_free, KB_SYMBOL_TABLE_SIZE, kb_table_s::lock, kb_symbol_s::next, kb_table_s::symbols, and kb_symbol_s::value.

Referenced by kb_config_exit().

void kb_dump_symbol_table ( kb_symbol_table_t table  ) 

This function dumps the symbol table

Parameters:
table A symbol table

Definition at line 192 of file kb_symbol.c.

References kb_msg(), KB_SYMBOL_TABLE_SIZE, kb_symbol_type_names, kb_symbol_s::name, kb_symbol_s::next, kb_table_s::symbols, and kb_symbol_s::type.

Here is the call graph for this function:

unsigned long kb_hash ( const char *  name  ) 

This function calculates the hash value of a key.

Parameters:
name A string containing the key to hash
Returns:
a hash value
Remarks:
The hash function is case insensitive.

Definition at line 107 of file kb_symbol.c.

Referenced by kb_add_symbol(), and kb_lookup_symbol().

kb_symbol_t* kb_lookup_symbol ( kb_symbol_table_t table,
const char *  name 
)

This function find a symbol into a given table.

Parameters:
table A symbol table
name A string containing the name of the symbol to find.
Returns:
A Pointer to the symbol found or NULL if the symbol is not defined.

Definition at line 165 of file kb_symbol.c.

References kb_hash(), KB_SYMBOL_TABLE_SIZE, kb_symbol_s::name, kb_symbol_s::next, and kb_table_s::symbols.

Referenced by kb_enum_alias(), kb_enum_device(), kb_enum_register(), kb_lookup_device(), kb_lookup_register(), kb_parse_alias(), kb_parse_device(), kb_parse_register(), and kb_parse_section().

Here is the call graph for this function:


Variable Documentation

const char* kb_symbol_type_names[]

Initial value:

 {
  "section" , "alias" , "device" , "register" , NULL
}
Symbol Type Names

Definition at line 31 of file kb_symbol.c.

Referenced by kb_dump_symbol_table().


Generated on Wed Dec 15 11:49:28 2010 for KoreBot Library by  doxygen 1.5.5