add sqlite3 support

This commit is contained in:
Ron Pedde 2006-01-06 17:43:38 +00:00
parent 45797a4403
commit 3a6ec603a1
6 changed files with 97 additions and 7 deletions

View File

@ -17,6 +17,7 @@ AM_CONDITIONAL(COND_REND_OSX,false)
rend_posix=true
db_sqlite=true
db_sqlite3=false
STATIC_LIBS=no
CPPFLAGS="${CPPFLAGS} -g -Wall"
@ -32,6 +33,13 @@ AC_ARG_ENABLE(sqlite,[ --enable-sqlite Enable the sqlite db backend],
*) AC_MSG_ERROR(bad value ${enableval} for --enable-sqlite);;
esac ])
AC_ARG_ENABLE(sqlite3,[ --enable-sqlite3 Enable sqlite3 db backend],
[ case "${enableval}" in
yes) db_sqlite3=true;;
no) db_sqlite3=false;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-sqlite3);;
esac ])
AC_ARG_ENABLE(mdns,[ --enable-mdns Enable mDNS support],
[ case "${enableval}" in
yes) ;;
@ -72,9 +80,14 @@ AM_CONDITIONAL(COND_OGGVORBIS, test x$use_oggvorbis = xtrue)
AM_CONDITIONAL(COND_FLAC, test x$use_flac = xtrue)
AM_CONDITIONAL(COND_MUSEPACK, test x$use_musepack = xtrue)
AM_CONDITIONAL(COND_SQLITE,test x$db_sqlite = xtrue)
AM_CONDITIONAL(COND_SQLITE3,test x$db_sqlite3 = xtrue)
AM_CONDITIONAL(COND_NEED_STRCASESTR,false)
AM_CONDITIONAL(COND_NEED_STRSEP,false)
if test x$db_sqlite = xtrue -o x$db_sqlite3 = xtrue; then
AM_CONDITIONAL(COND_SQL,true)
fi
dnl Darwin's stupid cpp preprocessor....
echo Host type is $host
CPPFLAGS="$CPPFLAGS -DHOST='\"$host\"'"
@ -167,6 +180,19 @@ if test x$db_sqlite = xtrue; then
fi
fi
if test x$db_sqlite3 = xtrue; then
AC_CHECK_HEADERS(sqlite3.h,, [
AC_MSG_ERROR([sqlite3.h not found... Must have sqlite3 headers installed])])
AC_CHECK_LIB(sqlite3,sqlite3_open,,echo "Must have sqlite3 libraries installed";exit)
if test x"$STATIC_LIBS" != x"no"; then
LDFLAGS="${LDFLAGS} ${STATIC_LIBS}/libsqlite3.a"
else
LDFLAGS="${LDFLAGS} -lsqlite3"
fi
fi
if test x$use_oggvorbis = xtrue; then
AC_CHECK_HEADERS(ogg/ogg.h,, [
AC_MSG_ERROR([ogg/ogg.h not found... Must have libogg installed for Ogg/Vorbis support])])

View File

@ -30,9 +30,18 @@ MUSEPACKSRC=scan-mpc.c
endif
if COND_SQLITE
SQLITEDB=db-sql.c db-sql.h db-sql-sqlite2.c db-sql-sqlite2.h
SQLITEDB=db-sql-sqlite2.c db-sql-sqlite2.h
endif
if COND_SQLITE3
SQLITE3DB=db-sql-sqlite3.c db-sql-sqlite3.h
endif
if COND_SQL
SQLDB=db-sql.c db-sql.h
endif
wavstreamer_SOURCES = wavstreamer.c
mt_daapd_SOURCES = main.c daapd.h rend.h uici.c uici.h webserver.c \
@ -44,9 +53,12 @@ mt_daapd_SOURCES = main.c daapd.h rend.h uici.c uici.h webserver.c \
scan-xml.c scan-wma.c scan-aac.c scan-aac.h scan-wav.c scan-url.c \
smart-parser.c smart-parser.h xml-rpc.c xml-rpc.h \
$(PRENDSRC) $(ORENDSRC) $(HRENDSRC) $(OGGVORBISSRC) $(FLACSRC) \
$(MUSEPACKSRC) $(SQLITEDB)
$(MUSEPACKSRC) $(SQLITEDB) $(SQLITE3DB) $(SQLDB)
EXTRA_DIST = mDNS.c mDNSClientAPI.h mDNSDebug.h mDNSPosix.c \
mDNSUNP.c mDNSPlatformFunctions.h mDNSPosix.h mDNSUNP.h \
rend-howl.c rend-posix.c rend-osx.c scan-mpc.c \
strcasestr.h scan-ogg.c scan-flac.c dbs-sqlite.c dbs-sqlite.h
strcasestr.h scan-ogg.c scan-flac.c db-sql.c db-sql.h \
db-sql-sqlite2.h db-sql-sqlite2.c \
db-sql-sqlite3.h db-sql-sqlite3.c

View File

@ -70,8 +70,8 @@ typedef struct tag_db_functions {
/** All supported backend databases, and pointers to the db specific implementations */
DB_FUNCTIONS db_functions[] = {
{
#ifdef HAVE_LIBSQLITE
{
"sqlite",
db_sql_open_sqlite2,
db_sql_init,
@ -99,6 +99,32 @@ DB_FUNCTIONS db_functions[] = {
},
#endif
#ifdef HAVE_LIBSQLITE3
{
"sqlite3",
db_sql_open_sqlite3,
db_sql_init,
db_sql_deinit,
db_sql_add,
db_sql_add_playlist,
db_sql_add_playlist_item,
db_sql_delete_playlist,
db_sql_delete_playlist_item,
db_sql_edit_playlist,
db_sql_enum_start,
db_sql_enum_size,
db_sql_enum_fetch,
db_sql_enum_reset,
db_sql_enum_end,
db_sql_start_scan,
db_sql_end_song_scan,
db_sql_end_scan,
db_sql_get_count,
db_sql_fetch_item,
db_sql_fetch_path,
db_sql_fetch_playlist,
db_sql_dispose_item,
db_sql_dispose_playlist
},
#endif
{ NULL,NULL }
};

View File

@ -70,7 +70,7 @@ static char db_sqlite2_path[PATH_MAX + 1];
/* Forwards */
void db_sqlite2_lock(void);
void db_sqlite2_unlock(void);
extern char *db_initial;
extern char *db_sqlite2_initial;
/**
* lock the db_mutex
@ -326,7 +326,7 @@ int db_sqlite2_event(int event_type) {
db_sqlite2_exec(NULL,E_DBG,"vacuum");
db_sqlite2_exec(NULL,E_DBG,db_initial);
db_sqlite2_exec(NULL,E_DBG,db_sqlite2_initial);
db_sqlite2_reload=1;
break;
@ -385,7 +385,7 @@ int db_sqlite2_event(int event_type) {
return DB_E_SUCCESS;
}
char *db_initial =
char *db_sqlite2_initial =
"create table songs (\n"
" id INTEGER PRIMARY KEY NOT NULL,\n"
" path VARCHAR(4096) UNIQUE NOT NULL,\n"

View File

@ -46,6 +46,10 @@
#include "db-sql-sqlite2.h"
#endif
#ifdef HAVE_LIBSQLITE3
#include "db-sql-sqlite3.h"
#endif
/* Globals */
static int db_sql_reload=0;
static int db_sql_in_playlist_scan=0;
@ -99,6 +103,25 @@ int db_sql_open_sqlite2(char **pe, char *parameters) {
}
#endif
#ifdef HAVE_LIBSQLITE3
int db_sql_open_sqlite3(char **pe, char *parameters) {
/* first, set our external links to sqlite2 */
db_sql_open_fn = db_sqlite3_open;
db_sql_close_fn = db_sqlite3_close;
db_sql_exec_fn = db_sqlite3_exec;
db_sql_vmquery_fn = db_sqlite3_vmquery;
db_sql_vmfree_fn = db_sqlite3_vmfree;
db_sql_enum_begin_fn = db_sqlite3_enum_begin;
db_sql_enum_fetch_fn = db_sqlite3_enum_fetch;
db_sql_enum_end_fn = db_sqlite3_enum_end;
db_sql_enum_restart_fn = db_sqlite3_enum_restart;
db_sql_event_fn = db_sqlite3_event;
return db_sql_open(pe,parameters);
}
#endif
/**
* fetch a single row, using the underlying database enum
* functions

View File

@ -27,6 +27,9 @@ typedef char** SQL_ROW;
#ifdef HAVE_LIBSQLITE
extern int db_sql_open_sqlite2(char **pe, char *parameters);
#endif
#ifdef HAVE_LIBSQLITE3
extern int db_sql_open_sqlite3(char **pe, char *parameters);
#endif
extern int db_sql_open(char **pe, char *parameters);
extern int db_sql_init(int reload);