diff --git a/darkice/trunk/AUTHORS b/darkice/trunk/AUTHORS index 56c755c..eaa272d 100644 --- a/darkice/trunk/AUTHORS +++ b/darkice/trunk/AUTHORS @@ -25,7 +25,7 @@ with contributions by: Nicholas J. Humfrey Joel Ebel - Alexander Vlasov + Alexander Vlasov Mariusz Mazur - + dsk diff --git a/darkice/trunk/ChangeLog b/darkice/trunk/ChangeLog index b6fdad2..a305087 100644 --- a/darkice/trunk/ChangeLog +++ b/darkice/trunk/ChangeLog @@ -1,5 +1,7 @@ DarkIce next release + o added user-defined date formatting for the fileAddDate options, + thanks to dsk o added logging facility - [file-X] targets will cut the saved file and rename it as needed when darkice recieves the SIGUSR1 signal o added default configuration file handling - if no configuration file @@ -8,7 +10,7 @@ DarkIce next release thanks to Alexander Vlasov and Mariusz Mazur o fix to enable file dump feature using ogg vorbis. - thanks to + thanks to dsk 19-05-2006 DarkIce 0.17.1 released diff --git a/darkice/trunk/man/darkice.1 b/darkice/trunk/man/darkice.1 index a59f288..5dad2a2 100644 --- a/darkice/trunk/man/darkice.1 +++ b/darkice/trunk/man/darkice.1 @@ -1,4 +1,4 @@ -.TH darkice 1 "January 14, 2007" "DarkIce" "DarkIce live audio streamer" +.TH darkice 1 "February 25, 2007" "DarkIce" "DarkIce live audio streamer" .SH NAME darkice \- an icecast / shoutcast live audio streamer .SH SYNOPSIS @@ -99,9 +99,9 @@ Developed with contributions by Nicholas J. Humfrey Joel Ebel - Alexander Vlasov + Alexander Vlasov Mariusz Mazur - + dsk .SH LINKS Project homepage: diff --git a/darkice/trunk/man/darkice.cfg.5 b/darkice/trunk/man/darkice.cfg.5 index 704860c..14e7263 100644 --- a/darkice/trunk/man/darkice.cfg.5 +++ b/darkice/trunk/man/darkice.cfg.5 @@ -1,4 +1,4 @@ -.TH darkice.cfg 5 "January 14, 2007" "DarkIce" "DarkIce live audio streamer" +.TH darkice.cfg 5 "February 25, 2007" "DarkIce" "DarkIce live audio streamer" .SH NAME darkice.cfg \- configuration file for darkice .SH DESCRIPTION @@ -181,6 +181,12 @@ server to this local file. the localDumpFile name before its extension or at the end of file name if no extension present .TP +.I fileDateFormat +The date format to use for appending the date to the dump file name. +Defaults to "[%m-%d-%Y-%H-%M-%S]". All format strings acceptable by strftime() +can be used, see the strftime man page for details. Only applicable is +fileAddDate is "true". +.TP .I lowpass Lowpass filter setting for the lame encoder, in Hz. Frequencies above the specified value will be cut. @@ -295,6 +301,12 @@ server to this local file. the localDumpFile name before its extension or at the end of file name if no extension present .TP +.I fileDateFormat +The date format to use for appending the date to the dump file name. +Defaults to "[%m-%d-%Y-%H-%M-%S]". All format strings acceptable by strftime() +can be used, see the strftime man page for details. Only applicable is +fileAddDate is "true". +.TP .I lowpass Lowpass filter setting for the lame encoder, in Hz. Frequencies above the specified value will be cut. @@ -406,6 +418,12 @@ server to this local file. "yes" or "no" if you want to automaticaly insert a date string in the localDumpFile name before its extension or at the end of file name if no extension present +.TP +.I fileDateFormat +The date format to use for appending the date to the dump file name. +Defaults to "[%m-%d-%Y-%H-%M-%S]". All format strings acceptable by strftime() +can be used, see the strftime man page for details. Only applicable is +fileAddDate is "true". .PP .B [file-x] diff --git a/darkice/trunk/src/DarkIce.cpp b/darkice/trunk/src/DarkIce.cpp index 1a18181..10ba2e7 100644 --- a/darkice/trunk/src/DarkIce.cpp +++ b/darkice/trunk/src/DarkIce.cpp @@ -240,6 +240,7 @@ DarkIce :: configIceCast ( const Config & config, const char * localDumpName = 0; FileSink * localDumpFile = 0; bool fileAddDate = false; + const char * fileDateFormat = 0; str = cs->get( "sampleRate"); sampleRate = str ? Util::strToL( str) : dsp->getSampleRate(); @@ -306,6 +307,7 @@ DarkIce :: configIceCast ( const Config & config, highpass = str ? Util::strToL( str) : 0; str = cs->get("fileAddDate"); fileAddDate = str ? (Util::strEq( str, "yes") ? true : false) : false; + fileDateFormat = cs->get("fileDateFormat"); localDumpName = cs->get( "localDumpFile"); @@ -314,7 +316,13 @@ DarkIce :: configIceCast ( const Config & config, // check for and create the local dump file if needed if ( localDumpName != 0 ) { if ( fileAddDate ) { - localDumpName = Util::fileAddDate(localDumpName); + if (fileDateFormat == 0) { + localDumpName = Util::fileAddDate(localDumpName); + } + else { + localDumpName = Util::fileAddDate( localDumpName, + fileDateFormat ); + } } localDumpFile = new FileSink( stream, localDumpName); @@ -432,6 +440,7 @@ DarkIce :: configIceCast2 ( const Config & config, const char * localDumpName = 0; FileSink * localDumpFile = 0; bool fileAddDate = false; + const char * fileDateFormat = 0; str = cs->getForSure( "format", " missing in section ", stream); if ( Util::strEq( str, "vorbis") ) { @@ -508,6 +517,7 @@ DarkIce :: configIceCast2 ( const Config & config, highpass = str ? Util::strToL( str) : 0; str = cs->get( "fileAddDate"); fileAddDate = str ? (Util::strEq( str, "yes") ? true : false) : false; + fileDateFormat = cs->get( "fileDateFormat"); localDumpName = cs->get( "localDumpFile"); @@ -516,7 +526,13 @@ DarkIce :: configIceCast2 ( const Config & config, // check for and create the local dump file if needed if ( localDumpName != 0 ) { if ( fileAddDate ) { - localDumpName = Util::fileAddDate(localDumpName); + if (fileDateFormat == 0) { + localDumpName = Util::fileAddDate(localDumpName); + } + else { + localDumpName = Util::fileAddDate( localDumpName, + fileDateFormat ); + } } localDumpFile = new FileSink( stream, localDumpName); @@ -689,6 +705,7 @@ DarkIce :: configShoutCast ( const Config & config, const char * localDumpName = 0; FileSink * localDumpFile = 0; bool fileAddDate = false; + const char * fileDateFormat = 0; str = cs->get( "sampleRate"); sampleRate = str ? Util::strToL( str) : dsp->getSampleRate(); @@ -751,6 +768,7 @@ DarkIce :: configShoutCast ( const Config & config, icq = cs->get( "icq"); str = cs->get("fileAddDate"); fileAddDate = str ? (Util::strEq( str, "yes") ? true : false) : false; + fileDateFormat = cs->get( "fileDateFormat"); localDumpName = cs->get( "localDumpFile"); @@ -759,7 +777,13 @@ DarkIce :: configShoutCast ( const Config & config, // check for and create the local dump file if needed if ( localDumpName != 0 ) { if ( fileAddDate ) { - localDumpName = Util::fileAddDate(localDumpName); + if (fileDateFormat == 0) { + localDumpName = Util::fileAddDate(localDumpName); + } + else { + localDumpName = Util::fileAddDate( localDumpName, + fileDateFormat ); + } } localDumpFile = new FileSink( stream, localDumpName); @@ -841,6 +865,8 @@ DarkIce :: configFileCast ( const Config & config ) unsigned int sampleRate = 0; int lowpass = 0; int highpass = 0; + bool fileAddDate = false; + const char * fileDateFormat = 0; format = cs->getForSure( "format", " missing in section ", stream); if ( !Util::strEq( format, "vorbis") @@ -856,6 +882,11 @@ DarkIce :: configFileCast ( const Config & config ) targetFileName = cs->getForSure( "fileName", " missing in section ", stream); + + str = cs->get( "fileAddDate"); + fileAddDate = str ? (Util::strEq( str, "yes") ? true : false) : false; + fileDateFormat = cs->get( "fileDateFormat"); + str = cs->get( "sampleRate"); sampleRate = str ? Util::strToL( str) : dsp->getSampleRate(); @@ -907,6 +938,16 @@ DarkIce :: configFileCast ( const Config & config ) // go on and create the things // the underlying file + if ( fileAddDate ) { + if (fileDateFormat == 0) { + targetFileName = Util::fileAddDate( targetFileName); + } + else { + targetFileName = Util::fileAddDate( targetFileName, + fileDateFormat ); + } + } + FileSink * targetFile = new FileSink( stream, targetFileName); if ( !targetFile->exists() ) { if ( !targetFile->create() ) { diff --git a/darkice/trunk/src/Util.cpp b/darkice/trunk/src/Util.cpp index ebd0e78..b30eb55 100644 --- a/darkice/trunk/src/Util.cpp +++ b/darkice/trunk/src/Util.cpp @@ -267,25 +267,27 @@ Util :: strToD( const char * str ) throw ( Exception ) return val; } + /*------------------------------------------------------------------------------ * add current date to a file name, before the file extension (if any) *----------------------------------------------------------------------------*/ -char * -Util :: fileAddDate ( const char * str ) throw ( Exception ) +char * +Util :: fileAddDate ( const char * str, + const char * format ) throw ( Exception ) { unsigned int size; char * s; char * strdate; char * last; time_t now; - + if ( !str ) { throw Exception( __FILE__, __LINE__, "no str"); } strdate = new char[128]; now = time(NULL); - strftime( strdate, 128, "[%m-%d-%Y-%H-%M-%S]", localtime (&now)); + strftime( strdate, 128, format, localtime (&now)); // search for the part before the extension of the file name if ( !(last = strrchr( str, '.')) ) { diff --git a/darkice/trunk/src/Util.h b/darkice/trunk/src/Util.h index 9543a59..08c8af4 100644 --- a/darkice/trunk/src/Util.h +++ b/darkice/trunk/src/Util.h @@ -215,7 +215,8 @@ class Util * @exception Exception */ static char * - fileAddDate ( const char * str ) throw ( Exception ); + fileAddDate ( const char * str, + const char * format = "[%m-%d-%Y-%H-%M-%S]" ) throw ( Exception ); /** * Convert a string into base64 encoding.