From cf2d4c85f073f7de4c2f96bd4549713fbdedfe64 Mon Sep 17 00:00:00 2001 From: darkeye Date: Sun, 14 Jan 2007 13:01:58 +0000 Subject: [PATCH] added default configuration file handling, closes #6 --- darkice/trunk/ChangeLog | 2 ++ darkice/trunk/man/darkice.1 | 3 ++- darkice/trunk/src/main.cpp | 15 ++++++++------- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/darkice/trunk/ChangeLog b/darkice/trunk/ChangeLog index 4f1312a..28568b7 100644 --- a/darkice/trunk/ChangeLog +++ b/darkice/trunk/ChangeLog @@ -1,5 +1,7 @@ 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 thanks to Alexander Vlasov and Mariusz Mazur diff --git a/darkice/trunk/man/darkice.1 b/darkice/trunk/man/darkice.1 index 92dd668..6545c39 100644 --- a/darkice/trunk/man/darkice.1 +++ b/darkice/trunk/man/darkice.1 @@ -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 darkice \- an icecast / shoutcast live audio streamer .SH SYNOPSIS @@ -49,6 +49,7 @@ is run as root. .TP .BI "\-c " config.file Specifies what configuration file to use. +If not specified, /etc/darkice.cfg will be used. .TP .BI "\-v " n diff --git a/darkice/trunk/src/main.cpp b/darkice/trunk/src/main.cpp index ace0328..b234b10 100644 --- a/darkice/trunk/src/main.cpp +++ b/darkice/trunk/src/main.cpp @@ -62,6 +62,11 @@ *----------------------------------------------------------------------------*/ static const char fileid[] = "$Id$"; +/*------------------------------------------------------------------------------ + * Default config file name + *----------------------------------------------------------------------------*/ +static const char *DEFAULT_CONFIG_FILE = "/etc/darkice.cfg"; + /* =============================================== local function prototypes */ @@ -91,7 +96,7 @@ main ( << std::endl << std::endl; try { - const char * configFileName = 0; + const char * configFileName = DEFAULT_CONFIG_FILE; unsigned int verbosity = 1; int i; 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::ifstream configFile( configFileName); @@ -153,6 +152,8 @@ showUsage ( std::ostream & os ) << std::endl << " -c config.file use configuration file config.file" << std::endl + << " if not specified, /etc/darkice.cfg is used" + << std::endl << " -v n verbosity level (0 = silent, 10 = loud)" << std::endl << " -h print this message and exit"