add: much

This commit is contained in:
Tobias Reisinger 2020-02-10 00:58:17 +01:00
parent 7b6ee283c6
commit cbb4ac7a86
15 changed files with 159 additions and 56 deletions

30
database.c Normal file
View file

@ -0,0 +1,30 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <lmdb.h>
#include <config.h>
void
database_setup(MDB_env **mdb_env)
{
int err;
if(mdb_env_create(mdb_env) != 0)
{
perror("Can't create mdb handle");
exit(1);
}
if((err = mdb_env_set_maxdbs(*mdb_env, MDB_MAXDBS)) != 0)
{
fprintf(stderr, "mdb_env_set_maxdbs error %s\n", mdb_strerror(err));
exit(1);
}
if(mdb_env_open(*mdb_env, "db.lmdb", MDB_NOSUBDIR, 0700) != 0)
{
perror("Can't open mdb file");
exit(1);
}
}