mirror of
https://github.com/owntone/owntone-server.git
synced 2025-02-09 20:58:10 -05:00
Load all plugins in plugin dir, rather than relying on a plugins entry
This commit is contained in:
parent
c90e2394c5
commit
f7e3db6861
44
src/main.c
44
src/main.c
@ -60,6 +60,9 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#ifdef HAVE_DIRENT_H
|
||||||
|
#include <dirent.h>
|
||||||
|
#endif
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
@ -216,14 +219,16 @@ int main(int argc, char *argv[]) {
|
|||||||
char **mp3_dir_array;
|
char **mp3_dir_array;
|
||||||
char *servername, *iface;
|
char *servername, *iface;
|
||||||
char *ffid = NULL;
|
char *ffid = NULL;
|
||||||
int index;
|
|
||||||
int appdir = 0;
|
int appdir = 0;
|
||||||
|
|
||||||
char txtrecord[255];
|
char txtrecord[255];
|
||||||
|
|
||||||
char *plugindir;
|
char *plugindir;
|
||||||
char plugin[PATH_MAX];
|
char plugin[PATH_MAX];
|
||||||
char **pluginarray;
|
DIR *d_plugin;
|
||||||
|
char de[sizeof(struct dirent) + MAXNAMLEN + 1]; /* ?? solaris */
|
||||||
|
struct dirent *pde;
|
||||||
|
char *pext;
|
||||||
|
|
||||||
int err;
|
int err;
|
||||||
char *perr=NULL;
|
char *perr=NULL;
|
||||||
@ -354,21 +359,30 @@ int main(int argc, char *argv[]) {
|
|||||||
* plugins do stuff they might need to */
|
* plugins do stuff they might need to */
|
||||||
plugin_init();
|
plugin_init();
|
||||||
if((plugindir=conf_alloc_string("plugins","plugin_dir",NULL)) != NULL) {
|
if((plugindir=conf_alloc_string("plugins","plugin_dir",NULL)) != NULL) {
|
||||||
if(conf_get_array("plugins","plugins",&pluginarray)==TRUE) {
|
/* instead of specifying plugins, let's walk through the directory
|
||||||
index = 0;
|
* and load each of them */
|
||||||
while(pluginarray[index]) {
|
if((d_plugin=opendir(plugindir)) == NULL) {
|
||||||
sprintf(plugin,"%s/%s",plugindir,pluginarray[index]);
|
DPRINTF(E_LOG,L_MAIN,"Error opening plugin dir. Ignoring\n");
|
||||||
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 {
|
} else {
|
||||||
free(plugindir);
|
while((readdir_r(d_plugin,(struct dirent *)de,&pde) != 1) && pde) {
|
||||||
|
pext = strrchr(pde->d_name,'.');
|
||||||
|
if((strcasecmp(pext,".so") == 0) ||
|
||||||
|
(strcasecmp(pext,".dylib") == 0) ||
|
||||||
|
(strcasecmp(pext,".dll") == 0)) {
|
||||||
|
/* must be a plugin */
|
||||||
|
snprintf(plugin,PATH_MAX,"%s%c%s",plugindir,
|
||||||
|
PATHSEP,pde->d_name);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
closedir(d_plugin);
|
||||||
}
|
}
|
||||||
|
free(plugindir);
|
||||||
}
|
}
|
||||||
|
|
||||||
runas = conf_alloc_string("general","runas","nobody");
|
runas = conf_alloc_string("general","runas","nobody");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user