2022-04-01 Fred Gleason <fredg@paravelsystems.com>

* Fixed a bug in rdlogmanager(1) where attempting to generate
	a SoundExchange Statutory License report using the command-line
	option would cause a crash.
	* Added an '-h' option to rdlogmanager(1).

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason
2022-04-01 20:26:44 -04:00
parent 91345cb991
commit 3cc7806db1
8 changed files with 109 additions and 16 deletions

View File

@@ -31,7 +31,8 @@
#include <globals.h>
int RunReportOperation(int argc,char *argv[],const QString &rptname,
bool protect_existing,int start_offset,int end_offset)
bool protect_existing,int start_offset,int end_offset,
double aggregate_tuning_hours)
{
QString out_path;
QString err_msg;
@@ -59,6 +60,14 @@ int RunReportOperation(int argc,char *argv[],const QString &rptname,
return RDApplication::ExitNoReport;
}
//
// Check for Aggregate Tuning Hours
//
if((aggregate_tuning_hours<0)&&(report->aggregateTuningHoursRequired())) {
fprintf(stderr,"rdlogmanager: -h option required\n");
return RDApplication::ExitInvalidOption;
}
//
// Generate Report
//
@@ -71,7 +80,7 @@ int RunReportOperation(int argc,char *argv[],const QString &rptname,
}
if(!report->generateReport(yesterday.addDays(start_offset),
yesterday.addDays(end_offset),rda->station(),
&out_path)) {
&out_path,aggregate_tuning_hours)) {
fprintf(stderr,"rdlogmanager: report generation failed [%s]\n",
RDReport::errorText(report->errorCode()).toUtf8().constData());
return RDApplication::ExitReportFailed;

View File

@@ -2,7 +2,7 @@
//
// The Log Generator Utility for Rivendell.
//
// (C) Copyright 2002-2021 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2022 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@@ -288,6 +288,8 @@ int main(int argc,char *argv[])
QString cmd_report=NULL;
int cmd_start_offset=0;
int cmd_end_offset=0;
double cmd_hours=-1.0;
bool ok=false;
RDCmdSwitch *cmd=
new RDCmdSwitch(argc,argv,"rdlogmanager",RDLOGMANAGER_USAGE);
@@ -366,6 +368,21 @@ int main(int argc,char *argv[])
}
cmd->setProcessed(i,true);
}
if (cmd->key(i)=="-h") {
if (i+1<cmd->keys()) {
i++;
cmd_hours=cmd->key(i).toDouble(&ok);
if((!ok)||(cmd_hours<0.0)) {
fprintf(stderr,"rdlogmanager: invalid argument to -h\n");
exit(RDApplication::ExitInvalidOption);
}
}
else {
fprintf(stderr,"rdlogmanager: missing argument to \"-h\"\n");
exit(RDApplication::ExitInvalidOption);
}
cmd->setProcessed(i,true);
}
if(!cmd->processed(i)) {
fprintf(stderr,"rdlogmanager: unknown command option \"%s\"\n",
cmd->key(i).toUtf8().constData());
@@ -388,7 +405,7 @@ int main(int argc,char *argv[])
}
if(!cmd_report.isEmpty()) {
return RunReportOperation(argc,argv,cmd_report,cmd_protect_existing,
cmd_start_offset,cmd_end_offset);
cmd_start_offset,cmd_end_offset,cmd_hours);
}
return gui_main(argc,argv);
}

View File

@@ -2,7 +2,7 @@
//
// The Log Manager Utility for Rivendell.
//
// (C) Copyright 2002-2021 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2022 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@@ -38,7 +38,7 @@ extern int RunLogOperation(int argc,char *argv[],const QString &svcname,
bool merge_mus,bool merge_tfc);
extern int RunReportOperation(int argc,char *argv[],const QString &rptname,
bool protect_existing,int start_offset,
int end_offset);
int end_offset,double aggregate_tuning_hours);
class MainWidget : public RDMainWindow
{