bdb_lib.h File Reference

#include <stdlib.h>
#include <syslog.h>
#include <sys/stat.h>
#include <db.h>
#include "../../str.h"
#include "../../db/db.h"
#include "../../db/db_val.h"
#include "../../locking.h"

Include dependency graph for bdb_lib.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  _column
struct  _database
struct  _db_parms
struct  _row
struct  _table
struct  _tbl_cache

Defines

#define DELIM   "|"
#define DELIM_LEN   (sizeof(DELIM)-1)
#define JLOG_DELETE   2
#define JLOG_FILE   8
#define JLOG_INSERT   1
#define JLOG_NONE   0
#define JLOG_STDOUT   16
#define JLOG_SYSLOG   32
#define JLOG_UPDATE   4
#define MAX_NUM_COLS   32
#define MAX_ROW_SIZE   2048
#define MAX_TABLENAME_SIZE   64
#define METADATA_COLUMNS   "METADATA_COLUMNS"
#define METADATA_DEFAULTS   "METADATA_DEFAULTS"
#define METADATA_KEY   "METADATA_KEY"
#define METADATA_LOGFLAGS   "METADATA_LOGFLAGS"
#define METADATA_READONLY   "METADATA_READONLY"

Typedefs

typedef db_val_tbdb_val_p
typedef db_val_t bdb_val_t
typedef struct _columncolumn_p
typedef struct _column column_t
typedef struct _databasedatabase_p
typedef struct _database database_t
typedef struct _db_parmsdb_parms_p
typedef struct _db_parms db_parms_t
typedef struct _rowrow_p
typedef struct _row row_t
typedef struct _tabletable_p
typedef struct _table table_t
typedef struct _tbl_cachetbl_cache_p
typedef struct _tbl_cache tbl_cache_t

Functions

int bdblib_close (char *_n)
int bdblib_create_dbenv (DB_ENV **dbenv, char *home)
int bdblib_create_journal (table_p _tp)
table_p bdblib_create_table (database_p _db, str *_s)
int bdblib_destroy (void)
database_p bdblib_get_db (str *_s)
tbl_cache_p bdblib_get_table (database_p _db, str *_s)
int bdblib_init (db_parms_p _parms)
void bdblib_log (int op, table_p _tp, char *_msg, int len)
int bdblib_recover (table_p _tp, int error_code)
int bdblib_reopen (char *_n)
int bdblib_valtochar (table_p _tp, int *_lres, char *_k, int *_klen, db_val_t *_v, int _n, int _ko)
int db_free (database_p _dbp)
int load_metadata_columns (table_p _tp)
int load_metadata_defaults (table_p _tp)
int load_metadata_keys (table_p _tp)
int load_metadata_logflags (table_p _tp)
int load_metadata_readonly (table_p _tp)
int tbl_cache_free (tbl_cache_p _tbc)
int tbl_free (table_p _tp)


Define Documentation

#define DELIM   "|"

#define DELIM_LEN   (sizeof(DELIM)-1)

Definition at line 69 of file bdb_lib.h.

Referenced by bdb_update(), and bdblib_valtochar().

#define JLOG_DELETE   2

Definition at line 62 of file bdb_lib.h.

Referenced by bdb_delete(), and bdblib_log().

#define JLOG_FILE   8

Definition at line 64 of file bdb_lib.h.

Referenced by bdblib_create_table().

#define JLOG_INSERT   1

Definition at line 61 of file bdb_lib.h.

Referenced by bdb_insert(), and bdblib_log().

#define JLOG_NONE   0

Definition at line 60 of file bdb_lib.h.

Referenced by bdblib_log().

#define JLOG_STDOUT   16

Definition at line 65 of file bdb_lib.h.

Referenced by bdblib_log().

#define JLOG_SYSLOG   32

Definition at line 66 of file bdb_lib.h.

Referenced by bdblib_log().

#define JLOG_UPDATE   4

Definition at line 63 of file bdb_lib.h.

Referenced by bdb_update(), and bdblib_log().

#define MAX_NUM_COLS   32

Definition at line 45 of file bdb_lib.h.

Referenced by bdblib_create_table(), and load_metadata_columns().

#define MAX_ROW_SIZE   2048

#define MAX_TABLENAME_SIZE   64

Definition at line 51 of file bdb_lib.h.

Referenced by bdb_check_reload(), and bdblib_create_table().

#define METADATA_COLUMNS   "METADATA_COLUMNS"

Definition at line 53 of file bdb_lib.h.

Referenced by load_metadata_columns().

#define METADATA_DEFAULTS   "METADATA_DEFAULTS"

Definition at line 57 of file bdb_lib.h.

Referenced by load_metadata_defaults().

#define METADATA_KEY   "METADATA_KEY"

Definition at line 54 of file bdb_lib.h.

Referenced by load_metadata_keys().

#define METADATA_LOGFLAGS   "METADATA_LOGFLAGS"

Definition at line 56 of file bdb_lib.h.

Referenced by load_metadata_logflags().

#define METADATA_READONLY   "METADATA_READONLY"

Definition at line 55 of file bdb_lib.h.

Referenced by load_metadata_readonly().


Typedef Documentation

typedef db_val_t * bdb_val_p

Definition at line 71 of file bdb_lib.h.

Definition at line 71 of file bdb_lib.h.

typedef struct _column * column_p

typedef struct _column column_t

typedef struct _database * database_p

typedef struct _database database_t

typedef struct _db_parms * db_parms_p

typedef struct _db_parms db_parms_t

typedef struct _row * row_p

typedef struct _row row_t

typedef struct _table * table_p

typedef struct _table table_t

typedef struct _tbl_cache * tbl_cache_p

typedef struct _tbl_cache tbl_cache_t


Function Documentation

int bdblib_close ( char *  _n  ) 

closes the underlying Berkeley DB. assumes the lib data-structures are already initialzed; used to sync and reload the db file.

Definition at line 104 of file bdb_lib.c.

References _table::db, _database::dbenv, _tbl_cache::dtp, _str::len, LM_CRIT, LM_DBG, _table::name, _database::name, _tbl_cache::next, NULL, _str::s, s, _table::sem, and _database::tables.

Referenced by bdb_reload().

int bdblib_create_dbenv ( DB_ENV **  dbenv,
char *  home 
)

Definition at line 298 of file bdb_lib.c.

References _db_parms::cache_size, and LM_ERR.

Referenced by bdblib_get_db(), and bdblib_reopen().

int bdblib_create_journal ( table_p  _tp  ) 

table_p bdblib_create_table ( database_p  _db,
str _s 
)

The function is called to create a handle to a db table.

On startup, we do not create any of the db handles. Instead it is done on first-use (lazy-initialized) to only create handles to files (db) that we require.

There is one db file per openser table (eg. acc), and they should exist in your DB_PATH (refer to kamctlrc) directory.

This function does _not_ create the underlying binary db tables. Creating the tables MUST be manually performed before openser startup by 'kamdbctl create'

Function returns NULL on error, which will cause openser to exit.

Definition at line 562 of file bdb_lib.c.

References bdblib_create_journal(), _table::colp, _table::db, _database::dbenv, _table::fp, _table::ino, JLOG_FILE, _str::len, LM_DBG, LM_ERR, LM_INFO, load_metadata_columns(), load_metadata_defaults(), load_metadata_keys(), load_metadata_logflags(), load_metadata_readonly(), _table::logflags, MAX_NUM_COLS, MAX_TABLENAME_SIZE, _table::name, _table::ncols, _table::nkeys, NULL, pkg_free, pkg_malloc, _table::ro, _str::s, _table::sem, and _table::t.

Referenced by bdblib_get_table().

int bdblib_destroy ( void   ) 

close all DBs and then the DBENV; free all memory

Definition at line 92 of file bdb_lib.c.

References db_free(), and pkg_free.

Referenced by bdblib_recover(), and destroy().

database_p bdblib_get_db ( str _s  ) 

tbl_cache_p bdblib_get_table ( database_p  _db,
str _s 
)

look thru a linked list for the table. if dne, create a new one and add to the list

Definition at line 421 of file bdb_lib.c.

References bdblib_create_table(), _database::dbenv, _tbl_cache::dtp, _str::len, LM_DBG, LM_ERR, _table::name, _tbl_cache::next, NULL, pkg_free, pkg_malloc, _str::s, _tbl_cache::sem, and _database::tables.

Referenced by _bdb_delete_cursor(), bdb_check_reload(), bdb_delete(), bdb_insert(), bdb_query(), and bdb_update().

int bdblib_init ( db_parms_p  _parms  ) 

void bdblib_log ( int  op,
table_p  _tp,
char *  _msg,
int  len 
)

int bdblib_recover ( table_p  _tp,
int  error_code 
)

Definition at line 1309 of file bdb_lib.c.

References bdblib_destroy(), and LM_ERR.

Referenced by _bdb_delete_cursor(), bdb_delete(), bdb_insert(), bdb_query(), bdb_update(), and bdblib_reopen().

int bdblib_reopen ( char *  _n  ) 

opens the underlying Berkeley DB. assumes the lib data-structures are already initialzed; used to sync and reload the db file.

Definition at line 188 of file bdb_lib.c.

References bdblib_create_dbenv(), bdblib_recover(), _table::db, _database::dbenv, _tbl_cache::dtp, _str::len, LM_CRIT, LM_DBG, _table::name, _database::name, _tbl_cache::next, NULL, _str::s, s, _table::sem, and _database::tables.

Referenced by bdb_reload().

int bdblib_valtochar ( table_p  _tp,
int *  _lres,
char *  _k,
int *  _klen,
db_val_t _v,
int  _n,
int  _ko 
)

int db_free ( database_p  _dbp  ) 

int load_metadata_columns ( table_p  _tp  ) 

int load_metadata_defaults ( table_p  _tp  ) 

int load_metadata_keys ( table_p  _tp  ) 

Definition at line 857 of file bdb_lib.c.

References _table::colp, _table::db, _column::flag, LM_ERR, MAX_ROW_SIZE, METADATA_KEY, _table::nkeys, NULL, and s.

Referenced by bdblib_create_table().

int load_metadata_logflags ( table_p  _tp  ) 

Definition at line 934 of file bdb_lib.c.

References _table::db, _table::logflags, MAX_ROW_SIZE, METADATA_LOGFLAGS, and NULL.

Referenced by bdblib_create_table().

int load_metadata_readonly ( table_p  _tp  ) 

Definition at line 902 of file bdb_lib.c.

References _table::db, MAX_ROW_SIZE, METADATA_READONLY, NULL, and _table::ro.

Referenced by bdblib_create_table().

int tbl_cache_free ( tbl_cache_p  _tbc  ) 

Definition at line 1263 of file bdb_lib.c.

References _tbl_cache::dtp, pkg_free, _tbl_cache::sem, and tbl_free().

Referenced by db_free().

int tbl_free ( table_p  _tp  ) 

close DB (sync data to disk) and free mem

Definition at line 1283 of file bdb_lib.c.

References _table::colp, _table::db, _column::dv, _table::fp, _column::name, _table::name, _table::ncols, pkg_free, and _str::s.

Referenced by tbl_cache_free().


Generated on Thu May 17 12:00:35 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6