2020-02-09 23:58:17 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <lmdb.h>
|
|
|
|
|
2020-04-16 23:38:25 +00:00
|
|
|
#include <constants.h>
|
2020-02-09 23:58:17 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|