mirror of
https://github.com/owntone/owntone-server.git
synced 2025-04-23 12:05:47 -04:00
start plugin infrastructure
This commit is contained in:
parent
b60b439102
commit
fd0d5cbbd9
@ -49,7 +49,7 @@ mtd_update_SOURCES = mtd-update.c conf.c conf.h ll.c ll.h \
|
|||||||
db-sql.c db-sql.h db-generic.c db-generic.h smart-parser.c \
|
db-sql.c db-sql.h db-generic.c db-generic.h smart-parser.c \
|
||||||
smart-parser.h err.c err.h os-unix.c os.h xml-rpc.c xml-rpc.h \
|
smart-parser.h err.c err.h os-unix.c os.h xml-rpc.c xml-rpc.h \
|
||||||
restart.c restart.h uici.c uici.h ssc.c ssc.h \
|
restart.c restart.h uici.c uici.h ssc.c ssc.h \
|
||||||
webserver.c webserver.h compat.c compat.h \
|
webserver.c webserver.h compat.c compat.h plugin.c plugin.h \
|
||||||
$(PRENDSRC) $(ORENDSRC) $(HRENDSRC) \
|
$(PRENDSRC) $(ORENDSRC) $(HRENDSRC) \
|
||||||
$(SQLITEDB) $(SQLITE3DB)
|
$(SQLITEDB) $(SQLITE3DB)
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ 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 \
|
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 \
|
smart-parser.c smart-parser.h xml-rpc.c xml-rpc.h \
|
||||||
os.h ll.c ll.h conf.c conf.h compat.c compat.h \
|
os.h ll.c ll.h conf.c conf.h compat.c compat.h \
|
||||||
os-unix.h os-unix.c os.h \
|
os-unix.h os-unix.c os.h plugin.c plugin.h \
|
||||||
$(PRENDSRC) $(ORENDSRC) $(HRENDSRC) $(OGGVORBISSRC) $(FLACSRC) \
|
$(PRENDSRC) $(ORENDSRC) $(HRENDSRC) $(OGGVORBISSRC) $(FLACSRC) \
|
||||||
$(MUSEPACKSRC) $(SQLITEDB) $(SQLITE3DB) $(SQLDB) $(GDBM)
|
$(MUSEPACKSRC) $(SQLITEDB) $(SQLITE3DB) $(SQLDB) $(GDBM)
|
||||||
|
|
||||||
|
@ -113,6 +113,8 @@ static CONF_ELEMENTS conf_elements[] = {
|
|||||||
{ 0, 0, CONF_T_STRING,"general","password" },
|
{ 0, 0, CONF_T_STRING,"general","password" },
|
||||||
{ 0, 0, CONF_T_MULTICOMMA,"general","compdirs" },
|
{ 0, 0, CONF_T_MULTICOMMA,"general","compdirs" },
|
||||||
{ 0, 0, CONF_T_STRING,"general","logfile" },
|
{ 0, 0, CONF_T_STRING,"general","logfile" },
|
||||||
|
{ 0, 0, CONF_T_EXISTPATH,"plugins","plugin_dir" },
|
||||||
|
{ 0, 0, CONF_T_MULTICOMMA,"plugins","plugins" },
|
||||||
{ 0, 0, CONF_T_INT, NULL, NULL }
|
{ 0, 0, CONF_T_INT, NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ static unsigned int err_debugmask=0xFFFFFFFF; /**< modules to debug, see \ref lo
|
|||||||
/** text list of modules to match for setting debug mask */
|
/** text list of modules to match for setting debug mask */
|
||||||
static char *err_categorylist[] = {
|
static char *err_categorylist[] = {
|
||||||
"config","webserver","database","scan","query","index","browse",
|
"config","webserver","database","scan","query","index","browse",
|
||||||
"playlist","art","daap","main","rend","xml","parse",NULL
|
"playlist","art","daap","main","rend","xml","parse","plugin",NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -56,6 +56,7 @@
|
|||||||
#define L_REND 0x00000800 /**< rendezvous -- rend-unix.c, rend-posix.c, etc */
|
#define L_REND 0x00000800 /**< rendezvous -- rend-unix.c, rend-posix.c, etc */
|
||||||
#define L_XML 0x00001000 /**< xml - xml-rpc.c */
|
#define L_XML 0x00001000 /**< xml - xml-rpc.c */
|
||||||
#define L_PARSE 0x00002000 /**< smart playlist parser */
|
#define L_PARSE 0x00002000 /**< smart playlist parser */
|
||||||
|
#define L_PLUG 0x00004000 /**< plugins */
|
||||||
#define L_MISC 0x80000000 /**< anything else */
|
#define L_MISC 0x80000000 /**< anything else */
|
||||||
|
|
||||||
#ifndef TRUE
|
#ifndef TRUE
|
||||||
|
26
src/main.c
26
src/main.c
@ -81,6 +81,7 @@
|
|||||||
#include "dynamic-art.h"
|
#include "dynamic-art.h"
|
||||||
#include "db-generic.h"
|
#include "db-generic.h"
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
#include "plugin.h"
|
||||||
|
|
||||||
#ifdef HAVE_GETOPT_H
|
#ifdef HAVE_GETOPT_H
|
||||||
# include "getopt.h"
|
# include "getopt.h"
|
||||||
@ -188,9 +189,14 @@ int main(int argc, char *argv[]) {
|
|||||||
char *logfile,*db_type,*db_parms,*web_root,*runas;
|
char *logfile,*db_type,*db_parms,*web_root,*runas;
|
||||||
char **mp3_dir_array;
|
char **mp3_dir_array;
|
||||||
char *servername,*iface;
|
char *servername,*iface;
|
||||||
|
int index;
|
||||||
|
|
||||||
char txtrecord[255];
|
char txtrecord[255];
|
||||||
|
|
||||||
|
char *plugindir;
|
||||||
|
char plugin[PATH_MAX];
|
||||||
|
char **pluginarray;
|
||||||
|
|
||||||
int err;
|
int err;
|
||||||
char *perr=NULL;
|
char *perr=NULL;
|
||||||
|
|
||||||
@ -296,6 +302,26 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* load plugins before we drop privs? Maybe... let the
|
||||||
|
* plugins do stuff they might need to */
|
||||||
|
if((plugindir=conf_alloc_string("plugins","plugin_dir",NULL)) != NULL) {
|
||||||
|
if(conf_get_array("plugins","plugins",&pluginarray)==TRUE) {
|
||||||
|
index = 0;
|
||||||
|
while(pluginarray[index]) {
|
||||||
|
sprintf(plugin,"%s/%s",plugindir,pluginarray[index]);
|
||||||
|
if(plugin_load(&perr,plugin) != PLUGIN_E_SUCCESS) {
|
||||||
|
DPRINTF(E_LOG,L_MAIN,"Error loading plugin %s: %s\n",
|
||||||
|
plugin, perr);
|
||||||
|
free(perr);
|
||||||
|
perr = NULL;
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
free(plugindir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
runas = conf_alloc_string("general","runas","nobody");
|
runas = conf_alloc_string("general","runas","nobody");
|
||||||
|
|
||||||
#ifndef WITHOUT_MDNS
|
#ifndef WITHOUT_MDNS
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <dlfcn.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
@ -420,3 +421,22 @@ int _os_start_signal_handler(pthread_t *handler_tid) {
|
|||||||
_os_pidfile = file;
|
_os_pidfile = file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* load a shared library
|
||||||
|
*
|
||||||
|
* @param
|
||||||
|
*/
|
||||||
|
void *os_loadlib(char *path) {
|
||||||
|
return dlopen(path,RTLD_LAZY);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *os_libfunc(void *handle, char *function) {
|
||||||
|
return dlsym(handle,function);
|
||||||
|
}
|
||||||
|
|
||||||
|
int *os_unload(void *handle) {
|
||||||
|
return dlclose(handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
5
src/os.h
5
src/os.h
@ -33,6 +33,11 @@ extern int os_closesyslog(void);
|
|||||||
extern int os_syslog(int level, char *msg);
|
extern int os_syslog(int level, char *msg);
|
||||||
extern int os_chown(char *path, char *user);
|
extern int os_chown(char *path, char *user);
|
||||||
|
|
||||||
|
/* library loading functions */
|
||||||
|
extern void *os_loadlib(char *path);
|
||||||
|
extern void *os_libfunc(void *handle, char *function);
|
||||||
|
extern void *os_unload(void *handle);
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
# include "os-win32.h"
|
# include "os-win32.h"
|
||||||
#else
|
#else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user