[db] Keep track of the current gsm_network

This commit is contained in:
Holger Freyther 2009-04-19 06:35:16 +00:00
parent ef7f7ce452
commit 36650b872f
4 changed files with 6 additions and 4 deletions

View File

@ -26,7 +26,7 @@
#include <openbsc/gsm_subscriber.h>
/* one time initialisation */
int db_init(const char *name);
int db_init(const char *name, struct gsm_network *network);
int db_prepare();
int db_fini();

View File

@ -916,7 +916,7 @@ static int bootstrap_network(void)
paging_init(bts);
bts->paging.channel_allocated = bsc_hack_channel_allocated;
if (db_init(database_name)) {
if (db_init(database_name, gsmnet)) {
printf("DB: Failed to init database. Please check the option settings.\n");
return -1;
}

View File

@ -32,6 +32,7 @@
static char *db_basename = NULL;
static char *db_dirname = NULL;
dbi_conn conn;
static struct gsm_network *current_network = NULL;
static char *create_stmts[] = {
"CREATE TABLE IF NOT EXISTS Meta ("
@ -86,7 +87,7 @@ void db_error_func(dbi_conn conn, void* data) {
printf("DBI: %s\n", msg);
}
int db_init(const char *name) {
int db_init(const char *name, struct gsm_network *network) {
dbi_initialize(NULL);
conn = dbi_conn_new("sqlite3");
if (conn==NULL) {
@ -117,6 +118,7 @@ int db_init(const char *name) {
return 1;
}
current_network = network;
return 0;
}

View File

@ -50,7 +50,7 @@
int main() {
if (db_init("hlr.sqlite3")) {
if (db_init("hlr.sqlite3", NULL)) {
printf("DB: Failed to init database. Please check the option settings.\n");
return 1;
}