File lib/table.c

Functions for a table data structure, which is similar to a hash (only with no indexing).


Included Files


Global Variable PROCNAME

char PROCNAME[128]
Included from include/ubs.h

Global Variable CUR_TIME

struct tm* CUR_TIME
Included from include/ubs.h

Global Variable GLOBAL

ubs_table GLOBAL
Included from include/ubs.h

Global Variable LOGLEVEL

int LOGLEVEL
Included from include/ubs.h

Global Function ubs_table_add()

Adds a new keypair (key, value) to a table

int ubs_table_add ( ubs_table* t, char* key, char* value )

int ubs_table_add
Returns OK on success, NO_MEM if memory allocation fails
ubs_table* t
Table to add the keypair to
char* key
The key
char* value
Value for the key
Prototyped in: include/ubs.h
Calls: realloc(), strcasecmp(), strncpy()
Called by: read_config()lib/read_config.c
  set_defaults()lib/common.c

Global Function ubs_table_change()

Changes the value of a key in a ubs_table structure

int ubs_table_change ( ubs_table* t, char* key, char* newval )

int ubs_table_change
Returns OK if successful, FAIL if the key does not exist in the table already
ubs_table* t
Table to read from
char* key
The key to change the value for
char* newval
New value for this key
Prototyped in: include/ubs.h
Calls: strcasecmp(), strncpy()

Global Function ubs_table_data()

Returns the value for a key in a ubs_table

char* ubs_table_data ( ubs_table* t, char* key )

char* ubs_table_data
Returns the string corresponding to the key passed in, or NULL if no such key exists
ubs_table* t
Table to read from
char* key
The key to seek
Prototyped in: include/ubs.h
Calls: strcasecmp()
Called by: check_against_queue()lib/get_song.c
  log_error_msg()lib/logging.c
  log_event()lib/logging.c
  ping_pid()lib/exec_proc.c
  queue_chop()lib/queue.c
  queue_init()lib/queue.c
  queue_length()lib/queue.c
  queue_pop()lib/queue.c
  queue_prepush()lib/queue.c
  queue_push()lib/queue.c
  read_config()lib/read_config.c

Global Function ubs_table_exists()

Checks to see if a key is present in the table

int ubs_table_exists ( ubs_table* t, char* key )

int ubs_table_exists
Returns YES if the key is found, NO if not
ubs_table* t
Table to read from
char* key
The key to seek
Prototyped in: include/ubs.h
Calls: strcasecmp()

Global Function ubs_table_init()

Creates memory and initializes a new ubs_table data structure. This function must be called before the ubs_table can be used.

int ubs_table_init ( ubs_table* t )

ubs_table* t
Pointer to the table to be initialized
int ubs_table Returns OK on success, NO_MEM if memory allocation failed

Prototyped in: include/ubs.h
Calls: malloc()


Global Function ubs_table_remove()

int ubs_table_remove ( ubs_table* t, char* key )