change database selection, fix in-memory db

This commit is contained in:
Enno Rehling 2018-09-29 09:56:05 +02:00
parent b47a41541f
commit b18f8ca9fb
3 changed files with 40 additions and 4 deletions

View File

@ -1,13 +1,46 @@
#!/bin/sh
ERESSEA_DB=db
ERESSEA_DB=memory
pkg-config --exists sqlite3 && ERESSEA_DB=sqlite
GETOPT=getopt
GETOPT_LONG=1
if [ "Darwin" = "$(uname)" ] ; then
if [ -x "/usr/local/opt/gnu-getopt/bin/getopt" ] ; then
GETOPT="/usr/local/opt/gnu-getopt/bin/getopt"
else
GETOPT_LONG=0
fi
fi
if [ $GETOPT_LONG -eq 1 ]; then
options=$(${GETOPT} -o d: -l db: -- "$@")
else # assume GNU getopt (long arguments)
options=$(${GETOPT} d: "$@")
fi
# Parse command line arguments
eval set -- "$options"
until [ -z "$1" ] ; do
case $1 in
-d|--db)
ERESSEA_DB=$2
shift
;;
--) shift; break;;
(-*) echo "$0: error - unrecognized option $1" 1>&2; exit 1;;
(*) break;;
esac
shift
done
while [ ! -z "$1" ] ; do
if [ "$1" = "--with-db" ] ; then
ERESSEA_DB=db
elif [ "$1" = "--with-sqlite" ] ; then
ERESSEA_DB=sqlite
elif [ "$1" = "--with-memory" ] ; then
ERESSEA_DB=memory
fi
shift 1
done

View File

@ -184,8 +184,10 @@ endif()
add_library(version STATIC ${VERSION_SRC})
add_library(game ${ERESSEA_SRC})
#add_executable(checker ${CHECK_SRC})
add_executable(eressea ${SERVER_SRC})
add_executable(checker ${CHECK_SRC})
if (IWYU_PATH)
set_property(TARGET eressea PROPERTY C_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
endif(IWYU_PATH)

View File

@ -1,4 +1,6 @@
#ifdef _MSC_VER
#include <platform.h>
#endif
#include "driver.h"
#include <util/log.h>
@ -40,11 +42,10 @@ int db_driver_faction_save(int id, int no, int turn, const char *email, const ch
return -1;
}
static int free_data_cb(const void *match)
static void free_data_cb(void *match)
{
char *str = (char *)match;
free(str);
return 0;
}
int db_driver_open(database_t db, const char *dbname)