diff options
Diffstat (limited to 'nserver/src/db.c')
-rw-r--r-- | nserver/src/db.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/nserver/src/db.c b/nserver/src/db.c new file mode 100644 index 0000000..315bf7b --- /dev/null +++ b/nserver/src/db.c @@ -0,0 +1,20 @@ +#include <db.h> + + +static const char *DB_FILE = "nserver.db"; + +int db_init() +{ + // Create DB if it's not already created. + GDBM_FILE gf = gdbm_open(DB_FILE, 0, GDBM_WRCREAT, + S_IRUSR|S_IWUSR, NULL); + check(gf != NULL, "unable to init db"); + + // Close the DB. + int rc = gdbm_close(gf); + check(rc == 0, "error closing db after init"); + + return 0; + error: + return -1; +} |