Remove old config framwork include and wrappers

This commit is contained in:
Julien BLACHE 2009-05-05 15:54:28 +02:00
parent 9fce6d7abd
commit 524bdd3f0d
3 changed files with 0 additions and 305 deletions

View File

@ -33,5 +33,4 @@ mt_daapd_SOURCES = main.c daapd.h \
EXTRA_DIST = scan-mpc.c \ EXTRA_DIST = scan-mpc.c \
scan-flac.c \ scan-flac.c \
conf.h \
ff-dbstruct.h ff-dbstruct.h

View File

@ -1,61 +0,0 @@
/*
* Functions for reading and writing the config file
*
* Copyright (C) 2006 Ron Pedde (ron@pedde.com)
*
* 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
*/
#ifndef _CONF_H_
#define _CONF_H_
#define CONF_E_SUCCESS 0
#define CONF_E_FOPEN 1
#define CONF_E_UNKNOWN 2
#define CONF_E_BADHEADER 3
#define CONF_E_PARSE 4
#define CONF_E_OVERFLOW 5 /** <Buffer passed too small */
#define CONF_E_NOCONF 6 /** <No open config file */
#define CONF_E_NOTFOUND 7
#define CONF_E_NOTWRITABLE 8
#define CONF_E_BADELEMENT 9
#define CONF_E_PATHEXPECTED 10
#define CONF_E_INTEXPECTED 11
#define CONF_E_BADCONFIG 12
#define CONF_E_NOTSUPP 13
extern int conf_reload(void);
extern int conf_get_int(char *section, char *key, int dflt);
extern int conf_get_string(char *section, char *key, char *dflt,
char *out, int *size);
extern char *conf_alloc_string(char *section, char *key, char *dflt);
extern int conf_set_int(char *section, char *key, int value, int verify);
extern int conf_set_string(char *section, char *key, char *value, int verify);
extern int conf_isset(char *section, char *key);
extern int conf_iswritable(void);
extern int conf_write(void);
extern char *conf_implode(char *section, char *key, char *delimiter);
extern int conf_get_array(char *section, char *key, char ***argvp);
extern void conf_dispose_array(char **argv);
extern char *conf_get_filename(void);
/* FIXME: well used config reading stuff... */
extern char *conf_get_servername(void);
#endif /* _CONF_H_ */

View File

@ -331,246 +331,3 @@ conffile_unload(void)
{ {
cfg_free(cfg); cfg_free(cfg);
} }
/* Wrappers for old configfile handling */
#include "conf.h"
int
conf_get_int(char *section, char *key, int dflt)
{
cfg_t *lib;
if ((strcmp(section, "general") == 0)
&& (strcmp(key, "port") == 0))
{
lib = cfg_getnsec(cfg, "library", 0);
return cfg_getint(lib, "port");
}
/* Return default for everything else */
return dflt;
}
int conf_get_string(char *section, char *key, char *dflt, char *out, int *size)
{
cfg_t *lib;
size_t len;
char *val = NULL;
if (strcmp(section, "general") == 0)
{
if (strcmp(key, "admin_pw") == 0)
{
val = cfg_getstr(cfg_getsec(cfg, "general"), "admin_password");
}
else if (strcmp(key, "password") == 0)
{
lib = cfg_getnsec(cfg, "library", 0);
val = cfg_getstr(lib, "password");
}
else if (strcmp(key, "extensions") == 0)
{
val = ".mp3,.m4a,.m4p,.ogg,.flac,.mpc";
}
else if (strcmp(key, "runas") == 0)
{
val = cfg_getstr(cfg_getsec(cfg, "general"), "uid");
}
else if (strcmp(key, "db_type") == 0)
{
val = "sqlite3";
}
else if (strcmp(key, "db_parms") == 0)
{
val = "/var/cache/mt-daapd";
}
/* web_root now static */
else if (strcmp(key, "web_root") == 0)
{
val = "/usr/share/mt-daapd/admin-root";
}
}
else if (strcmp(section, "plugins") == 0)
{
/* plugin_dir now static, going away */
if (strcmp(key, "plugin_dir") == 0)
{
val = "/usr/lib/mt-daapd/plugins";
}
}
/* Default value */
if (val == NULL)
val = dflt;
if (val == NULL)
{
*size = 0;
return 0;
}
len = strlen(val) + 1;
if (len <= *size)
{
strcpy(out, val);
*size = len;
}
else
{
*size = len;
return CONF_E_OVERFLOW;
}
return 0;
}
char *
conf_alloc_string(char *section, char *key, char *dflt)
{
char *val;
int len;
int ret;
len = 256;
val = (char *)malloc(len);
if (!val)
return NULL;
memset(val, 0, len);
ret = conf_get_string(section, key, dflt, val, &len);
if (ret != 0)
return NULL;
if (len == 0)
{
free(val);
val = NULL;
}
return val;
}
int
conf_get_array(char *section, char *key, char ***argvp)
{
cfg_t *lib;
int nelem;
char *opt;
char **a;
int i;
lib = cfg_getnsec(cfg, "library", 0);
if (strcmp(section, "general") == 0)
{
if (strcmp(key, "mp3_dir") == 0)
{
nelem = cfg_size(lib, "directories");
if (nelem == 0)
return 0;
opt = "directories";
}
else if (strcmp(key, "compdirs") == 0)
{
nelem = cfg_size(lib, "compilations");
if (nelem == 0)
return 0;
opt = "compilations";
}
else
{
return 0;
}
}
else
return 0;
a = (char **)malloc((nelem + 1) * sizeof(char *));
if (!a)
return 0;
memset(a, 0, (nelem + 1) * sizeof(char *));
for (i = 0; i < nelem; i++)
{
a[i] = strdup(cfg_getnstr(lib, opt, i));
}
*argvp = a;
return 1;
}
void
conf_dispose_array(char **argv)
{
int i;
for (i = 0; argv[i]; i++)
free(argv[i]);
free(argv);
}
char *
conf_get_servername(void)
{
cfg_t *lib;
lib = cfg_getnsec(cfg, "library", 0);
return strdup(cfg_getstr(lib, "name"));
}
/* Not supported */
int
conf_reload(void)
{
/* Not supported */
return CONF_E_NOTSUPP;
}
int
conf_set_int(char *section, char *key, int value, int verify)
{
/* Not supported */
return CONF_E_NOTSUPP;
}
int
conf_set_string(char *section, char *key, char *value, int verify)
{
/* Not supported */
return CONF_E_NOTSUPP;
}
int
conf_iswritable(void)
{
/* Not supported */
return 0;
}
int
conf_isset(char *section, char *key)
{
/* Not pertinent */
return 1;
}
int
conf_write(void)
{
/* Not supported */
return CONF_E_NOTSUPP;
}
char *
conf_get_filename(void)
{
return "NOT SUPPORTED";
}