mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-11 15:03:24 -05:00
Minor updates
This commit is contained in:
parent
a636d86826
commit
b5abd3faf9
58
src/conf.c
58
src/conf.c
@ -31,6 +31,7 @@
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "conf.h"
|
||||
#include "err.h"
|
||||
@ -47,7 +48,8 @@ static LL_HANDLE config_main=NULL;
|
||||
#define CONF_T_STRING 1
|
||||
|
||||
/** Forwards */
|
||||
static int _ll_verify(LL_HANDLE pll);
|
||||
static int _conf_verify(LL_HANDLE pll);
|
||||
static int _conf_exists(LL_HANDLE pll, char *section, char *term);
|
||||
|
||||
|
||||
|
||||
@ -83,19 +85,59 @@ static CONF_ELEMENTS conf_elements[] = {
|
||||
{ 0, 0, CONF_T_STRING,"general","ssc_prog" },
|
||||
{ 0, 0, CONF_T_STRING,"general","password" },
|
||||
{ 0, 0, CONF_T_STRING,"general","compdirs" },
|
||||
{ 0, 0, CONF_T_STRING,"general","logfile" }
|
||||
{ 0, 0, CONF_T_STRING,"general","logfile" },
|
||||
{ 0, 0, CONF_T_INT, NULL, NULL }
|
||||
};
|
||||
|
||||
int _conf_exists(LL_HANDLE pll, char *section, char *term) {
|
||||
LL_ITEM *pitem;
|
||||
|
||||
if(!(pitem = ll_fetch_item(pll,section)))
|
||||
return FALSE;
|
||||
|
||||
if(!ll_fetch_item(pitem->value.as_ll,term))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* check a tree and make sure it doesn't have any obviously bad
|
||||
* configuration information
|
||||
* Verify that the configuration isn't obviously wrong.
|
||||
* Type checking has already been done, this just checks
|
||||
* required stuff isn't missing.
|
||||
*
|
||||
* @param pll tree to check
|
||||
* @returns TRUE if configuration appears valid, FALSE otherwise
|
||||
*/
|
||||
int _ll_verify(LL_HANDLE pll) {
|
||||
int _conf_verify(LL_HANDLE pll) {
|
||||
LL_ITEM *pi = NULL;
|
||||
CONF_ELEMENTS *pce;
|
||||
int is_valid=TRUE;
|
||||
|
||||
/* first, walk through the elements and make sure
|
||||
* all required elements are there */
|
||||
pce = &conf_elements[0];
|
||||
while(pce->section) {
|
||||
if(pce->required) {
|
||||
if(!_conf_exists(pll,pce->section, pce->term))
|
||||
DPRINTF(E_LOG,L_CONF,"Missing configuration entry "
|
||||
" %s/%s. Please review the sample config\n",
|
||||
pce->section, pce->term);
|
||||
is_valid=FALSE;
|
||||
}
|
||||
if(pce->deprecated) {
|
||||
DPRINTF(E_LOG,L_CONF,"Config entry %s/%s is deprecated. Please "
|
||||
"review the sample config\n",
|
||||
pce->section, pce->term);
|
||||
}
|
||||
pce++;
|
||||
}
|
||||
|
||||
/* here we would walk through derived sections, if there
|
||||
* were any */
|
||||
|
||||
|
||||
return LL_E_SUCCESS;
|
||||
return is_valid;
|
||||
}
|
||||
|
||||
|
||||
@ -207,7 +249,7 @@ int config_read(char *file) {
|
||||
fclose(fin);
|
||||
|
||||
/* Sanity check */
|
||||
_ll_verify(pllnew);
|
||||
_conf_verify(pllnew);
|
||||
|
||||
ll_dump(pllnew);
|
||||
ll_destroy(pllnew);
|
||||
|
18
src/ll.c
18
src/ll.c
@ -252,3 +252,21 @@ void _ll_dump(LL *pl, int depth) {
|
||||
pli = pli->next;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Given an item (or NULL for first item), fetch
|
||||
* the next item
|
||||
*
|
||||
* @param pl ll to fetch from
|
||||
* @param prev last item we fetched
|
||||
*/
|
||||
LL_ITEM *ll_get_next(LL *pl, LL_ITEM *prev) {
|
||||
if(!pl)
|
||||
return NULL;
|
||||
|
||||
if(!prev)
|
||||
return pl->itemlist.next;
|
||||
|
||||
return prev->next;
|
||||
}
|
||||
|
1
src/ll.h
1
src/ll.h
@ -67,6 +67,7 @@ extern int ll_set_flags(LL *pl, unsigned int flags);
|
||||
extern int ll_get_flags(LL *pl, unsigned int *flags);
|
||||
|
||||
extern LL_ITEM *ll_fetch_item(LL *pl, char *key);
|
||||
extern LL_ITEM *ll_get_next(LL *pl, LL_ITEM *prev);
|
||||
|
||||
extern void ll_dump(LL *pl);
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
CC=gcc
|
||||
CFLAGS := $(CFLAGS) -g -I/sw/include -DHAVE_CONFIG_H -I. -I..
|
||||
LDFLAGS := $(LDFLAGS) -L/sw/lib -lid3tag -logg -lvorbisfile -lFLAC -lvorbis -ltag_c
|
||||
CFLAGS := $(CFLAGS) -g -I/opt/local/include -DHAVE_CONFIG_H -I. -I..
|
||||
LDFLAGS := $(LDFLAGS) -L/opt/local/lib -lid3tag -logg -lvorbisfile -lFLAC -lvorbis -ltag_c
|
||||
TARGET = scanner
|
||||
OBJECTS=scanner-driver.o restart.o err.o scan-wma.o scan-aac.o scan-wav.o scan-flac.o scan-ogg.o scan-mp3.o scan-url.o scan-mpc.o
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user