protect sqlite code with compile-time flag so easier to disable.

This commit is contained in:
Eric House 2012-07-29 08:37:08 -07:00
parent 8f04bfadaf
commit d25916ae5f
5 changed files with 30 additions and 3 deletions

View file

@ -51,6 +51,7 @@ endif
SVN_REV ?= "$(shell ../scripts/gitversion.sh)"
SVNDEF = -D'SVN_REV=$(SVN_REV)'
USE_SQLITE = 1
ifdef CURSES_ONLY
DO_GTK =
@ -99,6 +100,8 @@ DEFINES += -DHASH_STREAM
### Enable zero or one of these two ###
#DEFINES += -DXWFEATURE_TRAYUNDO_ALL
DEFINES += -DXWFEATURE_TRAYUNDO_ONE
# DEFINES += -DXWFEATURE_BONUSALL
# DEFINES += -DXWFEATURE_BONUSALLHINT
# MAX_ROWS controls STREAM_VERS_BIGBOARD and with it move hashing
DEFINES += -DMAX_ROWS=32
@ -189,7 +192,11 @@ OBJ = \
$(PLATFORM)/linuxutl.o \
$(CURSES_OBJS) $(GTK_OBJS) $(MAIN_OBJS)
LIBS = -lm -luuid -lsqlite3 $(GPROFFLAG)
LIBS = -lm -luuid $(GPROFFLAG)
ifdef USE_SQLITE
LIBS += -lsqlite3
DEFINES += -DUSE_SQLITE
endif
# Turn this off for now. I apparently have a memory problem, but it
# doesn't make the app unusable for testing while crash on boot does.
# LIBS += -lmcheck

View file

@ -1781,8 +1781,10 @@ cursesmain( XP_Bool isServer, LaunchParams* params )
if ( !!params->fileName && file_exists( params->fileName ) ) {
stream = streamFromFile( &g_globals.cGlobals, params->fileName,
&g_globals );
#ifdef USE_SQLITE
} else if ( !!params->dbFileName && file_exists( params->dbFileName ) ) {
stream = streamFromDB( &g_globals.cGlobals, &g_globals );
#endif
}
if ( !!stream ) {

View file

@ -418,8 +418,10 @@ createOrLoadObjects( GtkAppGlobals* globals )
if ( !!params->fileName && file_exists( params->fileName ) ) {
stream = streamFromFile( &globals->cGlobals, params->fileName, globals );
#ifdef USE_SQLITE
} else if ( !!params->dbFileName && file_exists( params->dbFileName ) ) {
stream = streamFromDB( &globals->cGlobals, globals );
#endif
}
if ( !!stream ) {

View file

@ -36,7 +36,9 @@
#include <syslog.h>
#include <stdarg.h>
#include <linux/un.h>
#include <sqlite3.h>
#ifdef USE_SQLITE
# include <sqlite3.h>
#endif
#ifdef XWFEATURE_BLUETOOTH
# include <bluetooth/bluetooth.h>
@ -105,6 +107,7 @@ streamFromFile( CommonGlobals* cGlobals, char* name, void* closure )
return stream;
} /* streamFromFile */
#ifdef USE_SQLITE
XWStreamCtxt*
streamFromDB( CommonGlobals* cGlobals, void* closure )
{
@ -140,6 +143,7 @@ streamFromDB( CommonGlobals* cGlobals, void* closure )
return stream;
}
#endif
void
writeToFile( XWStreamCtxt* stream, void* closure )
@ -451,8 +455,10 @@ typedef enum {
,CMD_SEED
,CMD_GAMESEED
,CMD_GAMEFILE
#ifdef USE_SQLITE
,CMD_GAMEDB_FILE
,CMD_GAMEDB_ID
#endif
,CMD_NOMMAP
,CMD_PRINTHISORY
,CMD_SKIPWARNINGS
@ -540,8 +546,10 @@ static CmdInfoRec CmdInfoRecs[] = {
,{ CMD_SEED, true, "seed", "random seed" }
,{ CMD_GAMESEED, true, "game-seed", "game seed (for relay play)" }
,{ CMD_GAMEFILE, true, "file", "file to save to/read from" }
#ifdef USE_SQLITE
,{ CMD_GAMEDB_FILE, true, "game-db-file", "sqlite3 file, android format, holding game" }
,{ CMD_GAMEDB_ID, true, "game-db-id", "id of row of game we want (defaults to first)" }
#endif
,{ CMD_NOMMAP, false, "no-mmap", "copy dicts to memory rather than mmap them" }
,{ CMD_PRINTHISORY, false, "print-history", "print history on game over" }
,{ CMD_SKIPWARNINGS, false, "skip-warnings", "no modals on phonies" }
@ -1493,11 +1501,13 @@ main( int argc, char** argv )
case CMD_GAMEFILE:
mainParams.fileName = optarg;
break;
#ifdef USE_SQLITE
case CMD_GAMEDB_FILE:
mainParams.dbFileName = optarg;
case CMD_GAMEDB_ID:
mainParams.dbFileID = atoi(optarg);
break;
#endif
case CMD_NOMMAP:
mainParams.useMmap = false;
break;
@ -1721,7 +1731,11 @@ main( int argc, char** argv )
/* sanity checks */
totalPlayerCount = mainParams.nLocalPlayers
+ mainParams.info.serverInfo.nRemotePlayers;
if ( !mainParams.fileName && !mainParams.dbFileName ) {
if ( !mainParams.fileName
#ifdef USE_SQLITE
&& !mainParams.dbFileName
#endif
) {
if ( (totalPlayerCount < 1) ||
(totalPlayerCount > MAX_NUM_PLAYERS) ) {
mainParams.needsNewGame = XP_TRUE;

View file

@ -49,8 +49,10 @@ typedef struct LaunchParams {
CurGameInfo gi;
PlayerDicts dicts;
char* fileName;
#ifdef USE_SQLITE
char* dbFileName;
XP_U32 dbFileID;
#endif
char* pipe;
char* nbs;
char* bonusFile;