applied fileDateFormat patch, closes #8

This commit is contained in:
darkeye 2007-02-25 15:46:31 +00:00
parent ed22b57ef0
commit 2b2ae392e0
7 changed files with 79 additions and 15 deletions

View File

@ -27,5 +27,5 @@ with contributions by:
<jochen2@users.sourceforge.net>
Alexander Vlasov <zulu@galaradio.com>
Mariusz Mazur <mmazur@kernel.pl>
<derrick@csociety.org>
dsk <derrick@csociety.org>

View File

@ -1,5 +1,7 @@
DarkIce next release
o added user-defined date formatting for the fileAddDate options,
thanks to dsk <derrick@csociety.org>
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 <zulu@galaradio.com> and
Mariusz Mazur <mmazur@kernel.pl>
o fix to enable file dump feature using ogg vorbis.
thanks to <derrick@csociety.org>
thanks to dsk <derrick@csociety.org>
19-05-2006 DarkIce 0.17.1 released

View File

@ -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
@ -101,7 +101,7 @@ Developed with contributions by
<jochen2@users.sourceforge.net>
Alexander Vlasov <zulu@galaradio.com>
Mariusz Mazur <mmazur@kernel.pl>
<derrick@csociety.org>
dsk <derrick@csociety.org>
.SH LINKS
Project homepage:

View File

@ -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]

View File

@ -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,8 +316,14 @@ DarkIce :: configIceCast ( const Config & config,
// check for and create the local dump file if needed
if ( localDumpName != 0 ) {
if ( fileAddDate ) {
if (fileDateFormat == 0) {
localDumpName = Util::fileAddDate(localDumpName);
}
else {
localDumpName = Util::fileAddDate( localDumpName,
fileDateFormat );
}
}
localDumpFile = new FileSink( stream, localDumpName);
if ( !localDumpFile->exists() ) {
@ -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,8 +526,14 @@ DarkIce :: configIceCast2 ( const Config & config,
// check for and create the local dump file if needed
if ( localDumpName != 0 ) {
if ( fileAddDate ) {
if (fileDateFormat == 0) {
localDumpName = Util::fileAddDate(localDumpName);
}
else {
localDumpName = Util::fileAddDate( localDumpName,
fileDateFormat );
}
}
localDumpFile = new FileSink( stream, localDumpName);
if ( !localDumpFile->exists() ) {
@ -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,8 +777,14 @@ DarkIce :: configShoutCast ( const Config & config,
// check for and create the local dump file if needed
if ( localDumpName != 0 ) {
if ( fileAddDate ) {
if (fileDateFormat == 0) {
localDumpName = Util::fileAddDate(localDumpName);
}
else {
localDumpName = Util::fileAddDate( localDumpName,
fileDateFormat );
}
}
localDumpFile = new FileSink( stream, localDumpName);
if ( !localDumpFile->exists() ) {
@ -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() ) {

View File

@ -267,11 +267,13 @@ 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 )
Util :: fileAddDate ( const char * str,
const char * format ) throw ( Exception )
{
unsigned int size;
char * s;
@ -285,7 +287,7 @@ Util :: fileAddDate ( const char * str ) throw ( Exception )
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, '.')) ) {

View File

@ -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.