mirror of
https://github.com/owntone/owntone-server.git
synced 2025-11-10 05:59:45 -05:00
Remove gdbm database backend
This commit is contained in:
@@ -31,10 +31,6 @@ if COND_SQL
|
||||
SQLDB=db-sql.c db-sql.h
|
||||
endif
|
||||
|
||||
if COND_GDBM
|
||||
GDBM=db-gdbm.c db-gdbm.h
|
||||
endif
|
||||
|
||||
if COND_UPNP
|
||||
UPNP=upnp.c upnp.h
|
||||
endif
|
||||
@@ -54,11 +50,10 @@ mt_daapd_SOURCES = main.c daapd.h rend.h webserver.c \
|
||||
memdebug.c memdebug.h ssl.h io.h io.c io-errors.h io-plugin.h \
|
||||
bsd-snprintf.c bsd-snprintf.h \
|
||||
$(ARENDSRC) $(OGGVORBISSRC) \
|
||||
$(FLACSRC) $(MUSEPACKSRC) $(SQLITE3DB) $(SQLDB) $(GDBM) \
|
||||
$(FLACSRC) $(MUSEPACKSRC) $(SQLITE3DB) $(SQLDB) \
|
||||
$(UPNP)
|
||||
|
||||
EXTRA_DIST = scan-mpc.c \
|
||||
scan-ogg.c scan-flac.c db-sql.c db-sql.h \
|
||||
db-sql-sqlite3.h db-sql-sqlite3.c \
|
||||
db-gdbm.c db-gdbm.h \
|
||||
ff-plugins.h ff-dbstruct.h upnp.c upnp.h ff-plugin-events.h
|
||||
|
||||
@@ -1132,10 +1132,6 @@ void config_emit_flags(WS_CONNINFO *pwsc, void *value, char *arg) {
|
||||
ws_writefd(pwsc,"%s ","--enable-musepack");
|
||||
#endif
|
||||
|
||||
#ifdef WITH_GDBM
|
||||
ws_writefd(pwsc,"%s ","--with-gdbm");
|
||||
#endif
|
||||
|
||||
#ifdef NSLU2
|
||||
ws_writefd(pwsc,"%s ","--enable-nslu2");
|
||||
#endif
|
||||
|
||||
208
src/db-gdbm.c
208
src/db-gdbm.c
@@ -1,208 +0,0 @@
|
||||
/*
|
||||
* $Id: $
|
||||
* simple gdbm database implementation
|
||||
*
|
||||
* Copyright (C) 2003-2006 Ron Pedde (rpedde@sourceforge.net)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <gdbm.h>
|
||||
#include <limits.h>
|
||||
#include <pthread.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "daapd.h"
|
||||
#include "err.h"
|
||||
#include "mp3-scanner.h"
|
||||
#include "redblack.h"
|
||||
#include "db-generic.h"
|
||||
#include "db-gdbm.h"
|
||||
|
||||
#ifndef GDBM_SYNC
|
||||
# define GDBM_SYNC 0
|
||||
#endif
|
||||
|
||||
#ifndef GDBM_NOLOCK
|
||||
# define GDBM_NOLOCK 0
|
||||
#endif
|
||||
|
||||
|
||||
/* Typedefs */
|
||||
/* Globals */
|
||||
static pthread_mutex_t _gdbm_mutex = PTHREAD_MUTEX_INITIALIZER; /**< gdbm not reentrant */
|
||||
static GDBM_FILE _gdbm_songs;
|
||||
|
||||
/* Forwards */
|
||||
void _gdbm_lock(void);
|
||||
void _gdbm_unlock(void);
|
||||
|
||||
/**
|
||||
* lock the db_mutex
|
||||
*/
|
||||
void _gdbm_lock(void) {
|
||||
int err;
|
||||
|
||||
if((err=pthread_mutex_lock(&_gdbm_mutex))) {
|
||||
DPRINTF(E_FATAL,L_DB,"cannot lock gdbm lock: %s\n",strerror(err));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* unlock the db_mutex
|
||||
*/
|
||||
void _gdbm_unlock(void) {
|
||||
int err;
|
||||
|
||||
if((err=pthread_mutex_unlock(&_gdbm_mutex))) {
|
||||
DPRINTF(E_FATAL,L_DB,"cannot unlock gdbm lock: %s\n",strerror(err));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* open the gdbm database
|
||||
*
|
||||
* @param pe error buffer
|
||||
* @param parameters db-specific parameter. In this case,
|
||||
* the path to use
|
||||
* @returns DB_E_SUCCESS on success, DB_E_* otherwise.
|
||||
*/
|
||||
int db_gdbm_open(char **pe, char *parameters) {
|
||||
char db_path[PATH_MAX + 1];
|
||||
int result = DB_E_SUCCESS;
|
||||
|
||||
snprintf(db_path,sizeof(db_path),"%s/%s",parameters,"songs.gdb");
|
||||
|
||||
// reload = reload ? GDBM_NEWDB : GDBM_WRCREAT;
|
||||
_gdbm_lock();
|
||||
_gdbm_songs = gdbm_open(db_path, 0, GDBM_WRCREAT | GDBM_SYNC | GDBM_NOLOCK,
|
||||
0600,NULL);
|
||||
|
||||
if(!_gdbm_songs) {
|
||||
/* let's try creating it! */
|
||||
_gdbm_songs = gdbm_open(db_path,0,GDBM_NEWDB | GDBM_SYNC | GDBM_NOLOCK,
|
||||
0600,NULL);
|
||||
}
|
||||
|
||||
if(!_gdbm_songs) {
|
||||
DPRINTF(E_FATAL,L_DB,"Could not open songs database (%s): %s\n",
|
||||
db_path,strerror(errno));
|
||||
db_get_error(pe,DB_E_DB_ERROR,gdbm_strerror(gdbm_errno));
|
||||
result = DB_E_DB_ERROR;
|
||||
}
|
||||
_gdbm_unlock();
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't really have a db initialization separate from opening.
|
||||
*/
|
||||
int db_gdbm_init(int reload) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the database
|
||||
*/
|
||||
int db_gdbm_deinit(void) {
|
||||
_gdbm_lock();
|
||||
gdbm_close(_gdbm_songs);
|
||||
_gdbm_unlock();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* given an id, fetch the associated MP3FILE
|
||||
*
|
||||
* @param pe error buffer
|
||||
* @param id id of item to fetch
|
||||
* @returns pointer to MP3FILE. Must be disposed of with db_dispose
|
||||
*/
|
||||
PACKED_MP3FILE *db_gdbm_fetch_item(char **pe, int id) {
|
||||
datum key, content;
|
||||
int content_size;
|
||||
PACKED_MP3FILE *ppmp3;
|
||||
char **char_array;
|
||||
char *element_ptr;
|
||||
int done=0;
|
||||
|
||||
/* pull a row that looks like a sql row out of the table */
|
||||
key.dptr = (void*)&id;
|
||||
key.dsize = sizeof(unsigned int);
|
||||
|
||||
_gdbm_lock();
|
||||
content = gdbm_fetch(_gdbm_songs,key);
|
||||
_gdbm_unlock();
|
||||
|
||||
if(content.dptr) {
|
||||
/* have a "packed" row.... let's unpack it */
|
||||
ppmp3=(PACKED_MP3FILE*)malloc(sizeof(PACKED_MP3FILE));
|
||||
if(!ppmp3) {
|
||||
DPRINTF(E_FATAL,L_DB,"db_gdbm_fetch_item: malloc\n");
|
||||
return NULL; /* lol */
|
||||
}
|
||||
memset(ppmp3,0x0,sizeof(PACKED_MP3FILE));
|
||||
content_size = content.dsize;
|
||||
element_ptr = content.dptr;
|
||||
char_array = (char**)(ppmp3);
|
||||
|
||||
/* walk through and set each element */
|
||||
while(!done) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
/**
|
||||
* start a full scan through the database
|
||||
*
|
||||
* @parm pe error buffer
|
||||
* @returns DB_E_SUCCESS or DB_E* on failure
|
||||
*/
|
||||
int db_gdbm_enum_start(char **pe) {
|
||||
return DB_E_DB_ERROR;
|
||||
}
|
||||
|
||||
PACKED_MP3FILE *db_gdbm_enum_fetch(char **pe) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int db_gdbm_enum_end(char **pe) {
|
||||
return DB_E_DB_ERROR;
|
||||
}
|
||||
|
||||
/* Required for read-write (fs scanning) support */
|
||||
int db_gdbm_add(char **pe, MP3FILE *pmp3) {
|
||||
return DB_E_DB_ERROR;
|
||||
}
|
||||
|
||||
extern int db_gdbm_delete(char **pe, int id) {
|
||||
return DB_E_DB_ERROR;
|
||||
}
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* $Id: $
|
||||
* implement gdbm backend. This will be an implementation based on the
|
||||
* absolute minimum API. This will be used as a template for the "worst-case"
|
||||
* backend. Writing a full backend might be faster, but this will be guaranteed
|
||||
* to work.
|
||||
*
|
||||
* To use a separate database as authoritative, you'll only need to implement the
|
||||
* read-only functions
|
||||
*/
|
||||
|
||||
#ifndef _DB_GDBM_H_
|
||||
#define _DB_GDBM_H_
|
||||
|
||||
#include "mp3-scanner.h"
|
||||
|
||||
/* Always required */
|
||||
extern int db_gdbm_open(char **pe, char *parameters);
|
||||
extern int db_gdbm_init(int reload);
|
||||
extern int db_gdbm_deinit(void);
|
||||
|
||||
/* Required for read-only support */
|
||||
extern PACKED_MP3FILE *db_gdbm_fetch_item(char **pe, int id);
|
||||
extern int db_gdbm_enum_start(char **pe);
|
||||
extern PACKED_MP3FILE *db_gdbm_enum_fetch(char **pe);
|
||||
extern int db_gdbm_enum_end(char **pe);
|
||||
|
||||
/* Required for read-write (fs scanning) support */
|
||||
extern int db_gdbm_add(char **pe, MP3FILE *pmp3);
|
||||
extern int db_gdbm_delete(char **pe, int id);
|
||||
|
||||
#endif /* _DB_GDBM_H_ */
|
||||
|
||||
@@ -122,7 +122,6 @@ extern int db_force_rescan(char **pe);
|
||||
#define DB_E_PROC 0x0A /**< could not start threadpool */
|
||||
#define DB_E_SIZE 0x0B /**< passed buffer too small */
|
||||
#define DB_E_WRONGVERSION 0x0C /**< must upgrade db */
|
||||
#define DB_E_DB_ERROR 0x0D /**< gdbm error */
|
||||
#define DB_E_MALLOC 0x0E /**< malloc error */
|
||||
#define DB_E_NOTFOUND 0x0F /**< path not found */
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
/** @anchor log_categories */
|
||||
#define L_CONF 0x00000001 /**< configuration - configfile.c */
|
||||
#define L_WS 0x00000002 /**< webserver - webserver.c */
|
||||
#define L_DB 0x00000004 /**< database - db-gdbm.c, db-memory.c */
|
||||
#define L_DB 0x00000004 /**< database */
|
||||
#define L_SCAN 0x00000008 /**< scanner - mp3-scanner.c */
|
||||
#define L_QRY 0x00000010 /**< query - query.c */
|
||||
#define L_IND 0x00000020 /**< index - daap.c */
|
||||
|
||||
Reference in New Issue
Block a user