added default configuration file handling, closes #6

This commit is contained in:
darkeye 2007-01-14 13:01:58 +00:00
parent 0bfed4a3ae
commit cf2d4c85f0
3 changed files with 12 additions and 8 deletions

View File

@ -1,5 +1,7 @@
DarkIce next release DarkIce next release
o added default configuration file handling - if no configuration file
is specified, /etc/darkice.cfg is used
o fix to enable compiling on 64 bit platforms o fix to enable compiling on 64 bit platforms
thanks to Alexander Vlasov <zulu@galaradio.com> and thanks to Alexander Vlasov <zulu@galaradio.com> and
Mariusz Mazur <mmazur@kernel.pl> Mariusz Mazur <mmazur@kernel.pl>

View File

@ -1,4 +1,4 @@
.TH darkice 1 "January 25, 2006" "DarkIce" "DarkIce live audio streamer" .TH darkice 1 "January 14, 2007" "DarkIce" "DarkIce live audio streamer"
.SH NAME .SH NAME
darkice \- an icecast / shoutcast live audio streamer darkice \- an icecast / shoutcast live audio streamer
.SH SYNOPSIS .SH SYNOPSIS
@ -49,6 +49,7 @@ is run as root.
.TP .TP
.BI "\-c " config.file .BI "\-c " config.file
Specifies what configuration file to use. Specifies what configuration file to use.
If not specified, /etc/darkice.cfg will be used.
.TP .TP
.BI "\-v " n .BI "\-v " n

View File

@ -62,6 +62,11 @@
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
static const char fileid[] = "$Id$"; static const char fileid[] = "$Id$";
/*------------------------------------------------------------------------------
* Default config file name
*----------------------------------------------------------------------------*/
static const char *DEFAULT_CONFIG_FILE = "/etc/darkice.cfg";
/* =============================================== local function prototypes */ /* =============================================== local function prototypes */
@ -91,7 +96,7 @@ main (
<< std::endl << std::endl; << std::endl << std::endl;
try { try {
const char * configFileName = 0; const char * configFileName = DEFAULT_CONFIG_FILE;
unsigned int verbosity = 1; unsigned int verbosity = 1;
int i; int i;
const char opts[] = "hc:v:"; const char opts[] = "hc:v:";
@ -115,12 +120,6 @@ main (
} }
} }
if ( !configFileName ) {
showUsage( std::cout);
throw Exception( __FILE__, __LINE__,
"no configuration file specified");
}
std::cout << "Using config file: " << configFileName << std::endl; std::cout << "Using config file: " << configFileName << std::endl;
std::ifstream configFile( configFileName); std::ifstream configFile( configFileName);
@ -153,6 +152,8 @@ showUsage ( std::ostream & os )
<< std::endl << std::endl
<< " -c config.file use configuration file config.file" << " -c config.file use configuration file config.file"
<< std::endl << std::endl
<< " if not specified, /etc/darkice.cfg is used"
<< std::endl
<< " -v n verbosity level (0 = silent, 10 = loud)" << " -v n verbosity level (0 = silent, 10 = loud)"
<< std::endl << std::endl
<< " -h print this message and exit" << " -h print this message and exit"