aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/etisnoop.cpp204
-rw-r--r--src/fig0_0.cpp4
-rw-r--r--src/fig0_1.cpp4
-rw-r--r--src/fig0_10.cpp6
-rw-r--r--src/fig0_11.cpp16
-rw-r--r--src/fig0_13.cpp6
-rw-r--r--src/fig0_14.cpp4
-rw-r--r--src/fig0_16.cpp4
-rw-r--r--src/fig0_17.cpp4
-rw-r--r--src/fig0_18.cpp10
-rw-r--r--src/fig0_19.cpp6
-rw-r--r--src/fig0_2.cpp14
-rw-r--r--src/fig0_21.cpp14
-rw-r--r--src/fig0_22.cpp10
-rw-r--r--src/fig0_24.cpp6
-rw-r--r--src/fig0_25.cpp10
-rw-r--r--src/fig0_26.cpp6
-rw-r--r--src/fig0_27.cpp8
-rw-r--r--src/fig0_28.cpp4
-rw-r--r--src/fig0_3.cpp4
-rw-r--r--src/fig0_31.cpp14
-rw-r--r--src/fig0_5.cpp6
-rw-r--r--src/fig0_6.cpp18
-rw-r--r--src/fig0_8.cpp4
-rw-r--r--src/fig0_9.cpp12
-rw-r--r--src/fig1.cpp14
-rw-r--r--src/figs.cpp52
-rw-r--r--src/figs.hpp54
-rw-r--r--src/utils.cpp32
-rw-r--r--src/utils.hpp26
30 files changed, 296 insertions, 280 deletions
diff --git a/src/etisnoop.cpp b/src/etisnoop.cpp
index 600f503..74d84de 100644
--- a/src/etisnoop.cpp
+++ b/src/etisnoop.cpp
@@ -41,8 +41,10 @@
#include <string.h>
#include <cinttypes>
#include <string>
+#include <boost/regex.hpp>
#include <vector>
#include <map>
+#include <list>
#include <sstream>
#include <time.h>
extern "C" {
@@ -54,93 +56,7 @@ extern "C" {
#include "figs.hpp"
#include "watermarkdecoder.hpp"
#include "repetitionrate.hpp"
-
-struct FIG
-{
- int type;
- int ext;
- int len;
-};
-
-class FIGalyser
-{
- public:
- FIGalyser()
- {
- clear();
- }
-
- void set_fib(int fib)
- {
- m_fib = fib;
- }
-
- void push_back(int type, int ext, int len)
- {
- struct FIG fig = {
- .type = type,
- .ext = ext,
- .len = len };
-
- m_figs[m_fib].push_back(fig);
- }
-
- void analyse()
- {
- printf("FIC ");
-
- for (size_t fib = 0; fib < m_figs.size(); fib++) {
- int consumed = 7;
- int fic_size = 0;
- printf("[%1zu ", fib);
-
- for (size_t i = 0; i < m_figs[fib].size(); i++) {
- FIG &f = m_figs[fib][i];
- printf("%01d/%02d (%2d) ", f.type, f.ext, f.len);
-
- consumed += 10;
-
- fic_size += f.len;
- }
-
- printf(" ");
-
- int align = 60 - consumed;
- if (align > 0) {
- while (align--) {
- printf(" ");
- }
- }
-
- printf("|");
-
- for (int i = 0; i < 15; i++) {
- if (2*i < fic_size) {
- printf("#");
- }
- else {
- printf("-");
- }
- }
-
- printf("| ] ");
-
- }
-
- printf("\n");
- }
-
- void clear()
- {
- m_figs.clear();
- m_figs.resize(3);
- }
-
- private:
- int m_fib;
- std::vector<std::vector<FIG> > m_figs;
-};
-
+#include "figalyser.hpp"
struct FIG0_13_shortAppInfo
{
@@ -167,22 +83,36 @@ struct eti_analyse_config_t {
FILE* etifd;
bool ignore_error;
std::map<int, StreamSnoop> streams_to_decode;
+ std::list<std::pair<int, int> > figs_to_display;
bool analyse_fic_carousel;
bool analyse_fig_rates;
bool analyse_fig_rates_per_second;
bool decode_watermark;
+
+ bool is_fig_to_be_printed(int type, int extension) const {
+ if (figs_to_display.empty()) {
+ return true;
+ }
+
+ return std::find(
+ figs_to_display.begin(),
+ figs_to_display.end(),
+ make_pair(type, extension)) != figs_to_display.end();
+ }
};
// Function prototypes
-void decodeFIG(FIGalyser &figs,
- WatermarkDecoder &wm_decoder,
- uint8_t* figdata,
- uint8_t figlen,
- uint16_t figtype,
- int indent);
+void decodeFIG(
+ const eti_analyse_config_t &config,
+ FIGalyser &figs,
+ WatermarkDecoder &wm_decoder,
+ uint8_t* figdata,
+ uint8_t figlen,
+ uint16_t figtype,
+ int indent);
-int eti_analyse(eti_analyse_config_t& config);
+int eti_analyse(eti_analyse_config_t &config);
const char *get_programme_type_str(size_t int_table_Id, size_t pty);
int sprintfMJD(char *dst, int mjd);
@@ -191,10 +121,13 @@ int sprintfMJD(char *dst, int mjd);
#define required_argument 1
#define optional_argument 2
const struct option longopts[] = {
+ {"analyse-figs", no_argument, 0, 'f'},
{"help", no_argument, 0, 'h'},
- {"verbose", no_argument, 0, 'v'},
{"ignore-error", no_argument, 0, 'e'},
+ {"input-file", no_argument, 0, 'i'},
+ {"verbose", no_argument, 0, 'v'},
{"decode-stream", required_argument, 0, 'd'},
+ {"filter-fig", required_argument, 0, 'F'},
{"input", required_argument, 0, 'i'}
};
@@ -214,7 +147,11 @@ void usage(void)
" -f analyse FIC carousel\n"
" -r analyse FIG rates in FIGs per second\n"
" -R analyse FIG rates in frames per FIG\n"
- " -w decode CRC-DABMUX and ODR-DabMux watermark.\n",
+ " -w decode CRC-DABMUX and ODR-DabMux watermark.\n"
+ " -F <type>/<ext>\n"
+ " add FIG type/ext to list of FIGs to display.\n"
+ " if the option is not given, all FIGs are displayed.\n"
+ "\n",
#if defined(GITVERSION)
GITVERSION,
#else
@@ -232,7 +169,7 @@ int main(int argc, char *argv[])
eti_analyse_config_t config;
while(ch != -1) {
- ch = getopt_long(argc, argv, "d:efhrRvwi:", longopts, &index);
+ ch = getopt_long(argc, argv, "d:efF:hrRvwi:", longopts, &index);
switch (ch) {
case 'd':
{
@@ -250,6 +187,26 @@ int main(int argc, char *argv[])
case 'f':
config.analyse_fic_carousel = true;
break;
+ case 'F':
+ {
+ const string type_ext(optarg);
+ const boost::regex regex("^([0-9]+)/([0-9]+)$");
+ boost::smatch match;
+ bool is_match = boost::regex_search(type_ext, match, regex);
+ if (not is_match) {
+ fprintf(stderr, "Incorrect -F format\n");
+ return 1;
+ }
+
+ const string type_str = match[1];
+ const int type = std::atoi(type_str.c_str());
+ const string extension_str = match[2];
+ const int extension = std::atoi(extension_str.c_str());
+
+ fprintf(stderr, "Adding FIG %d/%d to filter\n", type, extension);
+ config.figs_to_display.emplace_back(type, extension);
+ }
+ break;
case 'r':
config.analyse_fig_rates = true;
config.analyse_fig_rates_per_second = true;
@@ -290,7 +247,7 @@ int main(int argc, char *argv[])
fclose(etifd);
}
-int eti_analyse(eti_analyse_config_t& config)
+int eti_analyse(eti_analyse_config_t &config)
{
uint8_t p[ETINIPACKETSIZE];
string desc;
@@ -597,7 +554,7 @@ int eti_analyse(eti_analyse_config_t& config)
figlen = fig[0] & 0x1F;
sprintf(sdesc, "FIG %d [%d bytes]", figtype, figlen);
printbuf(sdesc, 3, fig+1, figlen);
- decodeFIG(figs, wm_decoder, fig+1, figlen, figtype, 4);
+ decodeFIG(config, figs, wm_decoder, fig+1, figlen, figtype, 4);
fig += figlen + 1;
figcount += figlen + 1;
if (figcount >= 29)
@@ -710,12 +667,14 @@ int eti_analyse(eti_analyse_config_t& config)
return 0;
}
-void decodeFIG(FIGalyser &figs,
- WatermarkDecoder &wm_decoder,
- uint8_t* f,
- uint8_t figlen,
- uint16_t figtype,
- int indent)
+void decodeFIG(
+ const eti_analyse_config_t &config,
+ FIGalyser &figs,
+ WatermarkDecoder &wm_decoder,
+ uint8_t* f,
+ uint8_t figlen,
+ uint16_t figtype,
+ int indent)
{
char desc[512];
@@ -724,13 +683,17 @@ void decodeFIG(FIGalyser &figs,
{
fig0_common_t fig0(f, figlen, wm_decoder);
- sprintf(desc, "FIG %d/%d: C/N=%d OE=%d P/D=%d",
- figtype, fig0.ext(), fig0.cn(), fig0.oe(), fig0.pd());
- printbuf(desc, indent, f+1, figlen-1);
+ const display_settings_t disp(config.is_fig_to_be_printed(figtype, fig0.ext()), indent);
+
+ if (disp.print) {
+ sprintf(desc, "FIG %d/%d: C/N=%d OE=%d P/D=%d",
+ figtype, fig0.ext(), fig0.cn(), fig0.oe(), fig0.pd());
+ printbuf(desc, disp.indent, f+1, figlen-1);
+ }
figs.push_back(figtype, fig0.ext(), figlen);
- bool complete = fig0_select(fig0, indent);
+ bool complete = fig0_select(fig0, disp);
rate_announce_fig(figtype, fig0.ext(), complete);
}
break;
@@ -739,9 +702,11 @@ void decodeFIG(FIGalyser &figs,
{// SHORT LABELS
fig1_common_t fig1(f, figlen);
+ const display_settings_t disp(config.is_fig_to_be_printed(figtype, fig1.ext()), indent);
+
figs.push_back(figtype, fig1.ext(), figlen);
- bool complete = fig1_select(fig1, indent);
+ bool complete = fig1_select(fig1, disp);
rate_announce_fig(figtype, fig1.ext(), complete);
}
break;
@@ -753,11 +718,15 @@ void decodeFIG(FIGalyser &figs,
uint8_t segment_index = (f[0] & 0x70) >> 4;
oe = (f[0] & 0x08) >> 3;
ext = f[0] & 0x07;
- sprintf(desc,
- "FIG %d/%d: Toggle flag=%d, Segment_index=%d, OE=%d",
- figtype, ext, toggle_flag, segment_index, oe);
- printbuf(desc, indent, f+1, figlen-1);
+ const display_settings_t disp(config.is_fig_to_be_printed(figtype, ext), indent);
+ if (disp.print) {
+ sprintf(desc,
+ "FIG %d/%d: Toggle flag=%d, Segment_index=%d, OE=%d",
+ figtype, ext, toggle_flag, segment_index, oe);
+
+ printbuf(desc, disp.indent, f+1, figlen-1);
+ }
figs.push_back(figtype, ext, figlen);
@@ -773,11 +742,16 @@ void decodeFIG(FIGalyser &figs,
uint8_t d2 = (f[0] & 0x40) >> 6;
uint8_t tcid = (f[0] & 0x38) >> 5;
ext = f[0] & 0x07;
+
+ const display_settings_t disp(config.is_fig_to_be_printed(figtype, ext), indent);
+
sprintf(desc,
"FIG %d/%d: D1=%d, D2=%d, TCId=%d",
figtype, ext, d1, d2, tcid);
- printbuf(desc, indent, f+1, figlen-1);
+ if (disp.print) {
+ printbuf(desc, disp.indent, f+1, figlen-1);
+ }
figs.push_back(figtype, ext, figlen);
diff --git a/src/fig0_0.cpp b/src/fig0_0.cpp
index 82bfadf..83f7efa 100644
--- a/src/fig0_0.cpp
+++ b/src/fig0_0.cpp
@@ -29,7 +29,7 @@
// FIG 0/0 Ensemble information
// ETSI EN 300 401 6.4
-bool fig0_0(fig0_common_t& fig0, int indent)
+bool fig0_0(fig0_common_t& fig0, const display_settings_t &disp)
{
uint8_t cid, al, ch, hic, lowc, occ;
uint16_t eid, eref;
@@ -55,7 +55,7 @@ bool fig0_0(fig0_common_t& fig0, int indent)
"Ensemble ID=0x%02x (Country id=%d, Ensemble reference=%d), Change flag=%d, Alarm flag=%d, CIF Count=%d/%d",
eid, cid, eref, ch, al, hic, lowc);
}
- printbuf(desc, indent+1, NULL, 0);
+ printbuf(desc, disp+1, NULL, 0);
return true;
}
diff --git a/src/fig0_1.cpp b/src/fig0_1.cpp
index 944849f..80ed906 100644
--- a/src/fig0_1.cpp
+++ b/src/fig0_1.cpp
@@ -46,7 +46,7 @@ bool fig0_1_is_complete(int subch_id)
// FIG 0/1 Basic sub-channel organization
// ETSI EN 300 401 6.2.1
-bool fig0_1(fig0_common_t& fig0, int indent)
+bool fig0_1(fig0_common_t& fig0, const display_settings_t &disp)
{
int i = 1;
uint8_t* f = fig0.f;
@@ -104,7 +104,7 @@ bool fig0_1(fig0_common_t& fig0, int indent)
i += 3;
}
- printbuf(desc, indent+1, NULL, 0);
+ printbuf(desc, disp+1, NULL, 0);
}
return complete;
diff --git a/src/fig0_10.cpp b/src/fig0_10.cpp
index b02edfa..3c01547 100644
--- a/src/fig0_10.cpp
+++ b/src/fig0_10.cpp
@@ -31,7 +31,7 @@
// FIG 0/10 Date and time
// ETSI EN 300 401 8.1.3.1
-bool fig0_10(fig0_common_t& fig0, int indent)
+bool fig0_10(fig0_common_t& fig0, const display_settings_t &disp)
{
char desc[256];
char dateStr[256];
@@ -61,12 +61,12 @@ bool fig0_10(fig0_common_t& fig0, int indent)
sprintf(desc, "FIG 0/%d(long): MJD=0x%X %s, LSI %u, ConfInd %u, UTC Time: %02d:%02d:%02d.%d",
fig0.ext(), MJD, dateStr, LSI, ConfInd, hours, minutes, seconds, milliseconds);
- printbuf(desc, indent+1, NULL, 0);
+ printbuf(desc, disp+1, NULL, 0);
}
else {
sprintf(desc, "FIG 0/%d(short): MJD=0x%X %s, LSI %u, ConfInd %u, UTC Time: %02d:%02d",
fig0.ext(), MJD, dateStr, LSI, ConfInd, hours, minutes);
- printbuf(desc, indent+1, NULL, 0);
+ printbuf(desc, disp+1, NULL, 0);
}
return true;
diff --git a/src/fig0_11.cpp b/src/fig0_11.cpp
index 40136c3..d26795f 100644
--- a/src/fig0_11.cpp
+++ b/src/fig0_11.cpp
@@ -49,7 +49,7 @@ bool fig0_11_is_complete(int region_id)
// FIG 0/11 Region definition
// ETSI EN 300 401 8.1.16.1
-bool fig0_11(fig0_common_t& fig0, int indent)
+bool fig0_11(fig0_common_t& fig0, const display_settings_t &disp)
{
Lat_Lng gps_pos = {0, 0};
int16_t Latitude_coarse, Longitude_coarse;
@@ -88,7 +88,7 @@ bool fig0_11(fig0_common_t& fig0, int indent)
if (Length_TII_list == 0) {
strcat(desc, ", CEI");
}
- printbuf(desc, indent+1, NULL, 0);
+ printbuf(desc, disp+1, NULL, 0);
i++;
for(j = 0;(i < (fig0.figlen - 1)) && (j < Length_TII_list); j++) {
@@ -125,7 +125,7 @@ bool fig0_11(fig0_common_t& fig0, int indent)
Length_SubId_list = f[i+1] & 0x1F;
sprintf(tmpbuf, ", Length of SubId=%d", Length_SubId_list);
strcat(desc, tmpbuf);
- printbuf(desc, indent+2, NULL, 0);
+ printbuf(desc, disp+2, NULL, 0);
i += 2;
bit_pos = 3;
@@ -139,7 +139,7 @@ bool fig0_11(fig0_common_t& fig0, int indent)
if ((SubId == 0) || (SubId > 23)) {
strcat(desc, " invalid value");
}
- printbuf(desc, indent+3, NULL, 0);
+ printbuf(desc, disp+3, NULL, 0);
bit_pos -= 5;
SubId = 0;
}
@@ -155,13 +155,13 @@ bool fig0_11(fig0_common_t& fig0, int indent)
}
if (k < Length_SubId_list) {
sprintf(desc, "%d SubId missing, fig length too short !", (Length_SubId_list - k));
- printbuf(desc, indent+3, NULL, 0);
+ printbuf(desc, disp+3, NULL, 0);
fprintf(stderr, "WARNING: FIG 0/%d length %d too short !\n", fig0.ext(), fig0.figlen);
}
}
if (j < Length_TII_list) {
sprintf(desc, "%d Transmitter group missing, fig length too short !", (Length_TII_list - j));
- printbuf(desc, indent+2, NULL, 0);
+ printbuf(desc, disp+2, NULL, 0);
fprintf(stderr, "WARNING: FIG 0/%d length %d too short !\n", fig0.ext(), fig0.figlen);
}
}
@@ -191,14 +191,14 @@ bool fig0_11(fig0_common_t& fig0, int indent)
strcat(desc, tmpbuf);
fprintf(stderr, "WARNING: FIG 0/%d length %d too short !\n", fig0.ext(), fig0.figlen);
}
- printbuf(desc, indent+1, NULL, 0);
+ printbuf(desc, disp+1, NULL, 0);
i += 7;
}
else {
// Rfu
sprintf(desc, "GATy=%d reserved for future use of the geographical, G/E flag=%d %s coverage area, RegionId=0x%X, database key=0x%X, stop Region definition iteration %d/%d",
GATy, GE_flag, GE_flag?"Global":"Ensemble", Region_Id, key, i, fig0.figlen);
- printbuf(desc, indent+1, NULL, 0);
+ printbuf(desc, disp+1, NULL, 0);
// stop Region definition iteration
i = fig0.figlen;
}
diff --git a/src/fig0_13.cpp b/src/fig0_13.cpp
index ffb5b89..36c36df 100644
--- a/src/fig0_13.cpp
+++ b/src/fig0_13.cpp
@@ -73,7 +73,7 @@ std::string get_fig_0_13_userapp(int user_app_type)
// FIG 0/13 User application information
// ETSI EN 300 401 8.1.20
-bool fig0_13(fig0_common_t& fig0, int indent)
+bool fig0_13(fig0_common_t& fig0, const display_settings_t &disp)
{
uint32_t SId;
uint8_t SCIdS;
@@ -111,7 +111,7 @@ bool fig0_13(fig0_common_t& fig0, int indent)
sprintf(desc, "FIG %d/%d: SId=0x%X SCIdS=%u No=%u",
figtype, fig0.ext(), SId, SCIdS, No);
- printbuf(desc, indent+1, NULL, 0);
+ printbuf(desc, disp+1, NULL, 0);
for (int numapp = 0; numapp < No; numapp++) {
uint16_t user_app_type = ((f[k] << 8) |
@@ -123,7 +123,7 @@ bool fig0_13(fig0_common_t& fig0, int indent)
user_app_type,
get_fig_0_13_userapp(user_app_type).c_str(),
user_app_len);
- printbuf(desc, indent+2, NULL, 0);
+ printbuf(desc, disp+2, NULL, 0);
}
return complete;
diff --git a/src/fig0_14.cpp b/src/fig0_14.cpp
index e72d121..029a21c 100644
--- a/src/fig0_14.cpp
+++ b/src/fig0_14.cpp
@@ -58,7 +58,7 @@ const char *FEC_schemes_str[4] = {
// FIG 0/14 FEC sub-channel organization
// ETSI EN 300 401 6.2.2
-bool fig0_14(fig0_common_t& fig0, int indent)
+bool fig0_14(fig0_common_t& fig0, const display_settings_t &disp)
{
uint8_t i = 1, SubChId, FEC_scheme;
uint8_t* f = fig0.f;
@@ -72,7 +72,7 @@ bool fig0_14(fig0_common_t& fig0, int indent)
FEC_scheme = f[i] & 0x3;
sprintf(desc, "SubChId=0x%X, FEC scheme=%d %s",
SubChId, FEC_scheme, FEC_schemes_str[FEC_scheme]);
- printbuf(desc, indent+1, NULL, 0);
+ printbuf(desc, disp+1, NULL, 0);
i++;
}
diff --git a/src/fig0_16.cpp b/src/fig0_16.cpp
index 24c9040..4583fc7 100644
--- a/src/fig0_16.cpp
+++ b/src/fig0_16.cpp
@@ -54,7 +54,7 @@ bool fig0_16_is_complete(SId_t SId, PNum_t PNum)
// FIG 0/16 Programme Number & fig0.oe() Programme Number
// ETSI EN 300 401 8.1.4 & 8.1.10.3
-bool fig0_16(fig0_common_t& fig0, int indent)
+bool fig0_16(fig0_common_t& fig0, const display_settings_t &disp)
{
uint16_t SId, PNum, New_SId, New_PNum;
uint8_t i = 1, Rfa, Rfu;
@@ -119,7 +119,7 @@ bool fig0_16(fig0_common_t& fig0, int indent)
i += 4;
}
- printbuf(desc, indent+1, NULL, 0);
+ printbuf(desc, disp+1, NULL, 0);
}
return complete;
diff --git a/src/fig0_17.cpp b/src/fig0_17.cpp
index 01fa954..772b804 100644
--- a/src/fig0_17.cpp
+++ b/src/fig0_17.cpp
@@ -48,7 +48,7 @@ bool fig0_17_is_complete(int services_id)
// FIG 0/17 Programme Type
// ETSI EN 300 401 8.1.5
-bool fig0_17(fig0_common_t& fig0, int indent)
+bool fig0_17(fig0_common_t& fig0, const display_settings_t &disp)
{
uint16_t SId;
uint8_t i = 1, Rfa, Language, Int_code, Comp_code;
@@ -130,7 +130,7 @@ bool fig0_17(fig0_common_t& fig0, int indent)
strcat(desc, tmpbuf);
}
}
- printbuf(desc, indent+1, NULL, 0);
+ printbuf(desc, disp+1, NULL, 0);
}
return complete;
diff --git a/src/fig0_18.cpp b/src/fig0_18.cpp
index 46a399c..abbf9f7 100644
--- a/src/fig0_18.cpp
+++ b/src/fig0_18.cpp
@@ -49,7 +49,7 @@ bool fig0_18_is_complete(int services_id)
// FIG 0/18 Announcement support
// ETSI EN 300 401 8.1.6.1
-bool fig0_18(fig0_common_t& fig0, int indent)
+bool fig0_18(fig0_common_t& fig0, const display_settings_t &disp)
{
uint32_t key;
uint16_t SId, Asu_flags;
@@ -83,18 +83,18 @@ bool fig0_18(fig0_common_t& fig0, int indent)
sprintf(tmpbuf, ", CEI");
strcat(desc, tmpbuf);
}
- printbuf(desc, indent+1, NULL, 0);
+ printbuf(desc, disp+1, NULL, 0);
i += 5;
for(j = 0; (j < Number_clusters) && (i < fig0.figlen); j++) {
// iterate over Cluster Id
sprintf(desc, "Cluster Id=0x%X", f[i]);
- printbuf(desc, indent+2, NULL, 0);
+ printbuf(desc, disp+2, NULL, 0);
i++;
}
if (j < Number_clusters) {
sprintf(desc, "missing Cluster Id, fig length too short !");
- printbuf(desc, indent+1, NULL, 0);
+ printbuf(desc, disp+1, NULL, 0);
fprintf(stderr, "WARNING: FIG %d/%d length %d too short !\n", figtype, fig0.ext(), fig0.figlen);
}
@@ -102,7 +102,7 @@ bool fig0_18(fig0_common_t& fig0, int indent)
for(j = 0; j < 16; j++) {
if (Asu_flags & (1 << j)) {
sprintf(desc, "Announcement support=%s", get_announcement_type(j));
- printbuf(desc, indent+2, NULL, 0);
+ printbuf(desc, disp+2, NULL, 0);
}
}
}
diff --git a/src/fig0_19.cpp b/src/fig0_19.cpp
index 31b4ca1..272f230 100644
--- a/src/fig0_19.cpp
+++ b/src/fig0_19.cpp
@@ -48,7 +48,7 @@ bool fig0_19_is_complete(int clusters_id)
// FIG 0/19 Announcement switching
// ETSI EN 300 401 8.1.6.2
-bool fig0_19(fig0_common_t& fig0, int indent)
+bool fig0_19(fig0_common_t& fig0, const display_settings_t &disp)
{
uint16_t Asw_flags;
uint8_t i = 1, j, Cluster_Id, SubChId, Rfa, RegionId_LP;
@@ -89,12 +89,12 @@ bool fig0_19(fig0_common_t& fig0, int indent)
fprintf(stderr, "WARNING: FIG %d/%d length %d too short !\n", figtype, fig0.ext(), fig0.figlen);
}
}
- printbuf(desc, indent+1, NULL, 0);
+ printbuf(desc, disp+1, NULL, 0);
// decode announcement switching types
for(j = 0; j < 16; j++) {
if (Asw_flags & (1 << j)) {
sprintf(desc, "Announcement switching=%s", get_announcement_type(j));
- printbuf(desc, indent+2, NULL, 0);
+ printbuf(desc, disp+2, NULL, 0);
}
}
i += (4 + Region_flag);
diff --git a/src/fig0_2.cpp b/src/fig0_2.cpp
index 27f01ac..128396e 100644
--- a/src/fig0_2.cpp
+++ b/src/fig0_2.cpp
@@ -48,7 +48,7 @@ bool fig0_2_is_complete(int services_id)
// FIG 0/2 Basic service and service component definition
// ETSI EN 300 401 6.3.1
-bool fig0_2(fig0_common_t& fig0, int indent)
+bool fig0_2(fig0_common_t& fig0, const display_settings_t &disp)
{
uint16_t sref, sid;
uint8_t cid, ecc, local, caid, ncomp, timd, ps, ca, subchid, scty;
@@ -96,7 +96,7 @@ bool fig0_2(fig0_common_t& fig0, int indent)
sprintf(desc,
"Service ID=0x%X (ECC=%d, Country id=%d, Service reference=%d), Number of components=%d, Local flag=%d, CAID=%d",
sid, ecc, cid, sref, ncomp, local, caid);
- printbuf(desc, indent+1, NULL, 0);
+ printbuf(desc, disp+1, NULL, 0);
k++;
for (int i=0; i<ncomp; i++) {
@@ -104,7 +104,7 @@ bool fig0_2(fig0_common_t& fig0, int indent)
memcpy(scomp, f+k, 2);
sprintf(desc, "Component[%d]", i);
- printbuf(desc, indent+2, scomp, 2, "");
+ printbuf(desc, disp+2, scomp, 2, "");
timd = (scomp[0] & 0xC0) >> 6;
ps = (scomp[1] & 0x02) >> 1;
ca = scomp[1] & 0x01;
@@ -140,24 +140,24 @@ bool fig0_2(fig0_common_t& fig0, int indent)
sprintf(sctydesc, "Unknown ASCTy (%d)", scty);
sprintf(desc, "Stream audio mode, %s, %s, SubChannel ID=%02X, CA=%d", psdesc.c_str(), sctydesc, subchid, ca);
- printbuf(desc, indent+3, NULL, 0);
+ printbuf(desc, disp+3, NULL, 0);
}
else if (timd == 1) {
// MSC stream data
sprintf(sctydesc, "DSCTy=%d %s", scty, get_dscty_type(scty));
sprintf(desc, "Stream data mode, %s, %s, SubChannel ID=%02X, CA=%d", psdesc.c_str(), sctydesc, subchid, ca);
- printbuf(desc, indent+3, NULL, 0);
+ printbuf(desc, disp+3, NULL, 0);
}
else if (timd == 2) {
// FIDC
sprintf(sctydesc, "DSCTy=%d %s", scty, get_dscty_type(scty));
sprintf(desc, "FIDC mode, %s, %s, Fast Information Data Channel ID=%02X, CA=%d", psdesc.c_str(), sctydesc, subchid, ca);
- printbuf(desc, indent+3, NULL, 0);
+ printbuf(desc, disp+3, NULL, 0);
}
else if (timd == 3) {
// MSC Packet mode
sprintf(desc, "MSC Packet Mode, %s, Service Component ID=%02X, CA=%d", psdesc.c_str(), subchid, ca);
- printbuf(desc, indent+3, NULL, 0);
+ printbuf(desc, disp+3, NULL, 0);
}
k += 2;
}
diff --git a/src/fig0_21.cpp b/src/fig0_21.cpp
index 69f18b9..088bb23 100644
--- a/src/fig0_21.cpp
+++ b/src/fig0_21.cpp
@@ -49,7 +49,7 @@ bool fig0_21_is_complete(int region_id)
// FIG 0/21 Frequency Information
// ETSI EN 300 401 8.1.8
-bool fig0_21(fig0_common_t& fig0, int indent)
+bool fig0_21(fig0_common_t& fig0, const display_settings_t &disp)
{
float freq;
uint32_t ifreq;
@@ -70,7 +70,7 @@ bool fig0_21(fig0_common_t& fig0, int indent)
complete |= fig0_21_is_complete(RegionId);
Length_FI_list = (f[i+1] & 0x1F);
sprintf(desc, "RegionId=0x%03x", RegionId);
- printbuf(desc, indent+1, NULL, 0);
+ printbuf(desc, disp+1, NULL, 0);
i += 2;
if ((i + Length_FI_list) <= fig0.figlen) {
j = i;
@@ -196,7 +196,7 @@ bool fig0_21(fig0_common_t& fig0, int indent)
strcat(tmpbuf, ", CEI");
}
strcat(desc, tmpbuf);
- printbuf(desc, indent+2, NULL, 0);
+ printbuf(desc, disp+2, NULL, 0);
j += 3; // add header
k = j;
@@ -236,7 +236,7 @@ bool fig0_21(fig0_common_t& fig0, int indent)
else {
sprintf(desc, "Frequency not to be used (0)");
}
- printbuf(desc, indent+3, NULL, 0);
+ printbuf(desc, disp+3, NULL, 0);
k += 3;
}
break;
@@ -263,7 +263,7 @@ bool fig0_21(fig0_common_t& fig0, int indent)
else {
sprintf(desc, "Frequency not to be used (0)");
}
- printbuf(desc, indent+3, NULL, 0);
+ printbuf(desc, disp+3, NULL, 0);
k++;
}
break;
@@ -277,7 +277,7 @@ bool fig0_21(fig0_common_t& fig0, int indent)
else {
sprintf(desc, "Frequency not to be used (0)");
}
- printbuf(desc, indent+3, NULL, 0);
+ printbuf(desc, disp+3, NULL, 0);
k += 2;
}
break;
@@ -305,7 +305,7 @@ bool fig0_21(fig0_common_t& fig0, int indent)
sprintf(tmpbuf, ", invalid Rfu b15 set to 1 instead of 0");
strcat(desc, tmpbuf);
}
- printbuf(desc, indent+3, NULL, 0);
+ printbuf(desc, disp+3, NULL, 0);
k += 3;
}
break;
diff --git a/src/fig0_22.cpp b/src/fig0_22.cpp
index dfee52b..c5e8c3f 100644
--- a/src/fig0_22.cpp
+++ b/src/fig0_22.cpp
@@ -59,7 +59,7 @@ void fig0_22_cleardb()
// FIG 0/22 Transmitter Identification Information (TII) database
// ETSI EN 300 401 8.1.9
-bool fig0_22(fig0_common_t& fig0, int indent)
+bool fig0_22(fig0_common_t& fig0, const display_settings_t &disp)
{
Lat_Lng gps_pos = {0, 0};
double latitude_sub, longitude_sub;
@@ -122,7 +122,7 @@ bool fig0_22(fig0_common_t& fig0, int indent)
else {
strcat(desc, ", invalid length of Latitude Longitude coarse fine");
}
- printbuf(desc, indent+1, NULL, 0);
+ printbuf(desc, disp+1, NULL, 0);
}
else { // MS == 1
// Sub-identifier
@@ -137,7 +137,7 @@ bool fig0_22(fig0_common_t& fig0, int indent)
sprintf(tmpbuf, ", Number of SubId fields=%d%s",
Nb_SubId_fields, (Nb_SubId_fields == 0)?", CEI":"");
strcat(desc, tmpbuf);
- printbuf(desc, indent+1, NULL, 0);
+ printbuf(desc, disp+1, NULL, 0);
i++;
for(j = i; ((j < (i + (Nb_SubId_fields * 6))) && (j < (fig0.figlen - 5))); j += 6) {
@@ -170,13 +170,13 @@ bool fig0_22(fig0_common_t& fig0, int indent)
sprintf(tmpbuf, " => Lat Lng=%f, %f wrong value because Main identifier latitude/longitude not available in database", latitude_sub, longitude_sub);
strcat(desc, tmpbuf);
}
- printbuf(desc, indent+2, NULL, 0);
+ printbuf(desc, disp+2, NULL, 0);
}
i += (Nb_SubId_fields * 6);
}
else {
strcat(desc, ", invalid fig length or Number of SubId fields length");
- printbuf(desc, indent+1, NULL, 0);
+ printbuf(desc, disp+1, NULL, 0);
}
}
}
diff --git a/src/fig0_24.cpp b/src/fig0_24.cpp
index 7867d9e..d9d0284 100644
--- a/src/fig0_24.cpp
+++ b/src/fig0_24.cpp
@@ -48,7 +48,7 @@ bool fig0_24_is_complete(int services_id)
// FIG 0/24 fig0.oe() Services
// ETSI EN 300 401 8.1.10.2
-bool fig0_24(fig0_common_t& fig0, int indent)
+bool fig0_24(fig0_common_t& fig0, const display_settings_t &disp)
{
uint64_t key;
uint32_t SId;
@@ -92,14 +92,14 @@ bool fig0_24(fig0_common_t& fig0, int indent)
sprintf(tmpbuf, ", CEI");
strcat(desc, tmpbuf);
}
- printbuf(desc, indent+1, NULL, 0);
+ printbuf(desc, disp+1, NULL, 0);
i++;
for(j = i; ((j < (i + (Number_of_EIds * 2))) && (j < fig0.figlen)); j += 2) {
// iterate over EIds
EId = ((uint16_t)f[j] <<8) | (uint16_t)f[j+1];
sprintf(desc, "EId 0x%04x", EId);
- printbuf(desc, indent+2, NULL, 0);
+ printbuf(desc, disp+2, NULL, 0);
}
i += (Number_of_EIds * 2);
}
diff --git a/src/fig0_25.cpp b/src/fig0_25.cpp
index 7859868..bd98f70 100644
--- a/src/fig0_25.cpp
+++ b/src/fig0_25.cpp
@@ -49,7 +49,7 @@ bool fig0_25_is_complete(int services_id)
// FIG 0/25 fig0.oe() Announcement support
// ETSI EN 300 401 8.1.10.5.1
-bool fig0_25(fig0_common_t& fig0, int indent)
+bool fig0_25(fig0_common_t& fig0, const display_settings_t &disp)
{
uint32_t key;
uint16_t SId, Asu_flags, EId;
@@ -82,19 +82,19 @@ bool fig0_25(fig0_common_t& fig0, int indent)
sprintf(tmpbuf, ", CEI");
strcat(desc, tmpbuf);
}
- printbuf(desc, indent+1, NULL, 0);
+ printbuf(desc, disp+1, NULL, 0);
i += 5;
for(j = 0; (j < Number_EIds) && (i < (fig0.figlen - 1)); j++) {
// iterate over EIds
EId = ((uint16_t)f[i] << 8) | (uint16_t)f[i+1];
sprintf(desc, "EId=0x%X", EId);
- printbuf(desc, indent+2, NULL, 0);
+ printbuf(desc, disp+2, NULL, 0);
i += 2;
}
if (j < Number_EIds) {
sprintf(desc, "missing EId, fig length too short !");
- printbuf(desc, indent+1, NULL, 0);
+ printbuf(desc, disp+1, NULL, 0);
fprintf(stderr, "WARNING: FIG 0/%d length %d too short !\n", fig0.ext(), fig0.figlen);
}
@@ -102,7 +102,7 @@ bool fig0_25(fig0_common_t& fig0, int indent)
for(j = 0; j < 16; j++) {
if (Asu_flags & (1 << j)) {
sprintf(desc, "fig0.oe() Announcement support=%s", get_announcement_type(j));
- printbuf(desc, indent+2, NULL, 0);
+ printbuf(desc, disp+2, NULL, 0);
}
}
}
diff --git a/src/fig0_26.cpp b/src/fig0_26.cpp
index c2e4316..1ad85dc 100644
--- a/src/fig0_26.cpp
+++ b/src/fig0_26.cpp
@@ -49,7 +49,7 @@ bool fig0_26_is_complete(int cluster_id)
// FIG 0/26 fig0.oe() Announcement switching
// ETSI EN 300 401 8.1.10.5.2
-bool fig0_26(fig0_common_t& fig0, int indent)
+bool fig0_26(fig0_common_t& fig0, const display_settings_t &disp)
{
uint16_t Asw_flags, EId_Other_Ensemble;
uint8_t i = 1, j, Rfa, Cluster_Id_Current_Ensemble, Region_Id_Current_Ensemble;
@@ -94,12 +94,12 @@ bool fig0_26(fig0_common_t& fig0, int indent)
}
i++;
}
- printbuf(desc, indent+1, NULL, 0);
+ printbuf(desc, disp+1, NULL, 0);
// decode announcement switching types
for(j = 0; j < 16; j++) {
if (Asw_flags & (1 << j)) {
sprintf(desc, "Announcement switching=%s", get_announcement_type(j));
- printbuf(desc, indent+2, NULL, 0);
+ printbuf(desc, disp+2, NULL, 0);
}
}
}
diff --git a/src/fig0_27.cpp b/src/fig0_27.cpp
index 1f3f08d..dfe4468 100644
--- a/src/fig0_27.cpp
+++ b/src/fig0_27.cpp
@@ -49,7 +49,7 @@ bool fig0_27_is_complete(int services_id)
// FIG 0/27 FM Announcement support
// ETSI EN 300 401 8.1.11.2.1
-bool fig0_27(fig0_common_t& fig0, int indent)
+bool fig0_27(fig0_common_t& fig0, const display_settings_t &disp)
{
uint16_t SId, PI;
uint8_t i = 1, j, Rfu, Number_PI_codes, key;
@@ -83,18 +83,18 @@ bool fig0_27(fig0_common_t& fig0, int indent)
// The Change Event Indication (CEI) is signalled by the Number of PI codes field = 0
strcat(desc, ", CEI");
}
- printbuf(desc, indent+1, NULL, 0);
+ printbuf(desc, disp+1, NULL, 0);
i += 3;
for(j = 0; (j < Number_PI_codes) && (i < (fig0.figlen - 1)); j++) {
// iterate over PI
PI = ((uint16_t)f[i] << 8) | (uint16_t)f[i+1];
sprintf(desc, "PI=0x%X", PI);
- printbuf(desc, indent+2, NULL, 0);
+ printbuf(desc, disp+2, NULL, 0);
i += 2;
}
if (j != Number_PI_codes) {
sprintf(desc, "fig length too short !");
- printbuf(desc, indent+2, NULL, 0);
+ printbuf(desc, disp+2, NULL, 0);
fprintf(stderr, "WARNING: FIG 0/%d length %d too short !\n", fig0.ext(), fig0.figlen);
}
}
diff --git a/src/fig0_28.cpp b/src/fig0_28.cpp
index 68798c4..f0cbbdd 100644
--- a/src/fig0_28.cpp
+++ b/src/fig0_28.cpp
@@ -49,7 +49,7 @@ bool fig0_28_is_complete(int cluster_id)
// FIG 0/28 FM Announcement switching
// ETSI EN 300 401 8.1.11.2.2
-bool fig0_28(fig0_common_t& fig0, int indent)
+bool fig0_28(fig0_common_t& fig0, const display_settings_t &disp)
{
uint16_t PI;
uint8_t i = 1, Cluster_Id_Current_Ensemble, Region_Id_Current_Ensemble;
@@ -81,7 +81,7 @@ bool fig0_28(fig0_common_t& fig0, int indent)
}
sprintf(tmpbuf, ", Region Id Current Ensemble=0x%X, PI=0x%X", Region_Id_Current_Ensemble, PI);
strcat(desc, tmpbuf);
- printbuf(desc, indent+1, NULL, 0);
+ printbuf(desc, disp+1, NULL, 0);
i += 4;
}
diff --git a/src/fig0_3.cpp b/src/fig0_3.cpp
index adc502f..349b9e9 100644
--- a/src/fig0_3.cpp
+++ b/src/fig0_3.cpp
@@ -48,7 +48,7 @@ bool fig0_3_is_complete(int components_id)
// FIG 0/3 Service component in packet mode with or without Conditional Access
// ETSI EN 300 401 6.3.2
-bool fig0_3(fig0_common_t& fig0, int indent)
+bool fig0_3(fig0_common_t& fig0, const display_settings_t &disp)
{
uint16_t SCId, Packet_address, CAOrg;
uint8_t i = 1, Rfa, DSCTy, SubChId, CAMode, SharedFlag;
@@ -102,7 +102,7 @@ bool fig0_3(fig0_common_t& fig0, int indent)
}
i += 2;
}
- printbuf(desc, indent+1, NULL, 0);
+ printbuf(desc, disp+1, NULL, 0);
}
return complete;
diff --git a/src/fig0_31.cpp b/src/fig0_31.cpp
index cbaf296..6d0a68c 100644
--- a/src/fig0_31.cpp
+++ b/src/fig0_31.cpp
@@ -48,7 +48,7 @@ bool fig0_31_is_complete(uint64_t figtype_flags)
// FIG 0/31 FIC re-direction
// ETSI EN 300 401 8.1.12
-bool fig0_31(fig0_common_t& fig0, int indent)
+bool fig0_31(fig0_common_t& fig0, const display_settings_t &disp)
{
uint32_t FIG_type0_flag_field = 0, flag_field;
uint8_t i = 1, j, FIG_type1_flag_field = 0, FIG_type2_flag_field = 0;
@@ -68,7 +68,7 @@ bool fig0_31(fig0_common_t& fig0, int indent)
sprintf(desc, "FIG type 0 flag field=0x%X, FIG type 1 flag field=0x%X, FIG type 2 flag field=0x%X",
FIG_type0_flag_field, FIG_type1_flag_field, FIG_type2_flag_field);
- printbuf(desc, indent+1, NULL, 0);
+ printbuf(desc, disp+1, NULL, 0);
for(j = 0; j < 32; j++) {
// iterate over FIG type 0 re-direction
@@ -78,12 +78,12 @@ bool fig0_31(fig0_common_t& fig0, int indent)
(j == 19) || (j == 26) || (j == 28))) {
sprintf(desc, "fig0.oe()=%d FIG 0/%d carried in AIC, invalid configuration, shall always be carried entirely in the FIC",
fig0.oe(), j);
- printbuf(desc, indent+2, NULL, 0);
+ printbuf(desc, disp+2, NULL, 0);
fprintf(stderr, "WARNING: FIG 0/%d FIG re-direction of fig0.oe()=%d FIG0/%d not allowed\n", fig0.ext(), fig0.oe(), j);
}
else if ((flag_field != 0) && ((j == 21) || (j == 24))) {
sprintf(desc, "fig0.oe()=%d FIG 0/%d carried in AIC, same shall be carried in FIC", fig0.oe(), j);
- printbuf(desc, indent+2, NULL, 0);
+ printbuf(desc, disp+2, NULL, 0);
}
else if (flag_field != 0) {
if (fig0.oe() == 0) {
@@ -92,7 +92,7 @@ bool fig0_31(fig0_common_t& fig0, int indent)
else { // fig0.oe() == 1
sprintf(desc, "fig0.oe()=%d FIG 0/%d carried in AIC, may be carried entirely in AIC", fig0.oe(), j);
}
- printbuf(desc, indent+2, NULL, 0);
+ printbuf(desc, disp+2, NULL, 0);
}
}
@@ -106,7 +106,7 @@ bool fig0_31(fig0_common_t& fig0, int indent)
else { // fig0.oe() == 1
sprintf(desc, "fig0.oe()=%d FIG 1/%d carried in AIC, may be carried entirely in AIC", fig0.oe(), j);
}
- printbuf(desc, indent+2, NULL, 0);
+ printbuf(desc, disp+2, NULL, 0);
}
}
@@ -120,7 +120,7 @@ bool fig0_31(fig0_common_t& fig0, int indent)
else { // fig0.oe() == 1
sprintf(desc, "fig0.oe()=%d FIG 2/%d carried in AIC, may be carried entirely in AIC", fig0.oe(), j);
}
- printbuf(desc, indent+2, NULL, 0);
+ printbuf(desc, disp+2, NULL, 0);
}
}
}
diff --git a/src/fig0_5.cpp b/src/fig0_5.cpp
index 8d966a6..d70cca1 100644
--- a/src/fig0_5.cpp
+++ b/src/fig0_5.cpp
@@ -48,7 +48,7 @@ bool fig0_5_is_complete(int components_id)
// FIG 0/5 Service component language
// ETSI EN 300 401 8.1.2
-bool fig0_5(fig0_common_t& fig0, int indent)
+bool fig0_5(fig0_common_t& fig0, const display_settings_t &disp)
{
uint16_t SCId;
uint8_t i = 1, SubChId, FIDCId, Language, Rfa;
@@ -83,7 +83,7 @@ bool fig0_5(fig0_common_t& fig0, int indent)
int key = (MSC_FIC_flag << 7) | (f[i] % 0x3F);
complete |= fig0_5_is_complete(key);
- printbuf(desc, indent+1, NULL, 0);
+ printbuf(desc, disp+1, NULL, 0);
i += 2;
}
else {
@@ -103,7 +103,7 @@ bool fig0_5(fig0_common_t& fig0, int indent)
SCId, Language,
get_language_name(Language));
strcat(desc, tmpbuf);
- printbuf(desc, indent+1, NULL, 0);
+ printbuf(desc, disp+1, NULL, 0);
}
i += 3;
}
diff --git a/src/fig0_6.cpp b/src/fig0_6.cpp
index 69d937e..921e36d 100644
--- a/src/fig0_6.cpp
+++ b/src/fig0_6.cpp
@@ -56,7 +56,7 @@ void fig0_6_cleardb()
// FIG 0/6 Service linking information
// ETSI EN 300 401 8.1.15
-bool fig0_6(fig0_common_t& fig0, int indent)
+bool fig0_6(fig0_common_t& fig0, const display_settings_t &disp)
{
uint32_t j;
uint16_t LSN, key;
@@ -99,7 +99,7 @@ bool fig0_6(fig0_common_t& fig0, int indent)
SH, SH ? "Hard" : "Soft",
ILS, ILS ? "international" : "national",
LSN, key, signal_link);
- printbuf(desc, indent+1, NULL, 0);
+ printbuf(desc, disp+1, NULL, 0);
}
else { // Id_list_flag == 1
if (i < fig0.figlen) {
@@ -116,7 +116,7 @@ bool fig0_6(fig0_common_t& fig0, int indent)
LSN, key, IdLQ,
Shd, (Shd)?"b11-8 in 4-F are different services":"single service",
Number_of_Ids, signal_link);
- printbuf(desc, indent+1, NULL, 0);
+ printbuf(desc, disp+1, NULL, 0);
if (ILS == 0) {
// read Id list
for(j = 0; ((j < Number_of_Ids) && ((i+2+(j*2)) < fig0.figlen)); j++) {
@@ -138,12 +138,12 @@ bool fig0_6(fig0_common_t& fig0, int indent)
sprintf(desc, "DRM-AMSS service 0x%X",
((f[i+1+(j*2)] << 8) | f[i+2+(j*2)]));
}
- printbuf(desc, indent+2, NULL, 0);
+ printbuf(desc, disp+2, NULL, 0);
}
// check deadlink
if ((Number_of_Ids == 0) && (IdLQ == 1)) {
sprintf(desc, "deadlink");
- printbuf(desc, indent+2, NULL, 0);
+ printbuf(desc, disp+2, NULL, 0);
}
i += (Number_of_Ids * 2) + 1;
}
@@ -163,12 +163,12 @@ bool fig0_6(fig0_common_t& fig0, int indent)
else { // IdLQ == 3
sprintf(desc, "DRM/AMSS service ecc 0x%02X Id 0x%04X", f[i+1+(j*3)], ((f[i+2+(j*3)] << 8) | f[i+3+(j*3)]));
}
- printbuf(desc, indent+2, NULL, 0);
+ printbuf(desc, disp+2, NULL, 0);
}
// check deadlink
if ((Number_of_Ids == 0) && (IdLQ == 1)) {
sprintf(desc, "deadlink");
- printbuf(desc, indent+2, NULL, 0);
+ printbuf(desc, disp+2, NULL, 0);
}
i += (Number_of_Ids * 3) + 1;
}
@@ -176,13 +176,13 @@ bool fig0_6(fig0_common_t& fig0, int indent)
else { // fig0.pd() == 1
sprintf(desc, "Id list flag=%d, LA=%d %s, S/H=%d %s, ILS=%d %s, LSN=%d, database key=0x%04x, Number of Ids=%d%s",
Id_list_flag, LA, (LA)?"active":"inactive", SH, (SH)?"Hard":"Soft", ILS, (ILS)?"international":"national", LSN, key, Number_of_Ids, signal_link);
- printbuf(desc, indent+1, NULL, 0);
+ printbuf(desc, disp+1, NULL, 0);
if (Number_of_Ids > 0) {
// read Id list
for(j = 0; ((j < Number_of_Ids) && ((i+4+(j*4)) < fig0.figlen)); j++) {
sprintf(desc, "SId 0x%X",
((f[i+1+(j*4)] << 24) | (f[i+2+(j*4)] << 16) | (f[i+3+(j*4)] << 8) | f[i+4+(j*4)]));
- printbuf(desc, indent+2, NULL, 0);
+ printbuf(desc, disp+2, NULL, 0);
}
}
i += (Number_of_Ids * 4) + 1;
diff --git a/src/fig0_8.cpp b/src/fig0_8.cpp
index 60f2e0c..eb157de 100644
--- a/src/fig0_8.cpp
+++ b/src/fig0_8.cpp
@@ -57,7 +57,7 @@ bool fig0_8_is_complete(SId_t SId, SCIdS_t SCIdS)
// FIG 0/8 Service component global definition
// ETSI EN 300 401 6.3.5
-bool fig0_8(fig0_common_t& fig0, int indent)
+bool fig0_8(fig0_common_t& fig0, const display_settings_t &disp)
{
uint32_t SId;
uint16_t SCId;
@@ -139,7 +139,7 @@ bool fig0_8(fig0_common_t& fig0, int indent)
i += 2;
}
}
- printbuf(desc, indent+1, NULL, 0);
+ printbuf(desc, disp+1, NULL, 0);
}
return complete;
diff --git a/src/fig0_9.cpp b/src/fig0_9.cpp
index 5c8271c..6e642ee 100644
--- a/src/fig0_9.cpp
+++ b/src/fig0_9.cpp
@@ -37,7 +37,7 @@ bool LTO_uniq;
// FIG 0/9 Country, LTO and International table
// ETSI EN 300 401 8.1.3.2
-bool fig0_9(fig0_common_t& fig0, int indent)
+bool fig0_9(fig0_common_t& fig0, const display_settings_t &disp)
{
uint32_t SId;
uint8_t i = 1, j, key, Number_of_services, ECC;
@@ -71,7 +71,7 @@ bool fig0_9(fig0_common_t& fig0, int indent)
sprintf(tmpbuf, ", Ensemble ECC=0x%X, International Table Id=0x%X, database key=0x%x",
Ensemble_ECC, International_Table_Id, key);
strcat(desc, tmpbuf);
- printbuf(desc, indent+1, NULL, 0);
+ printbuf(desc, disp+1, NULL, 0);
i += 3;
if (Ext_flag == 1) {
// extended field present
@@ -101,26 +101,26 @@ bool fig0_9(fig0_common_t& fig0, int indent)
ECC = f[i];
sprintf(tmpbuf, ", ECC=0x%X", ECC);
strcat(desc, tmpbuf);
- printbuf(desc, indent+2, NULL, 0);
+ printbuf(desc, disp+2, NULL, 0);
i++;
for(j = i; ((j < (i + (Number_of_services * 2))) && (j < fig0.figlen)); j += 2) {
// iterate over SId
SId = ((uint32_t)f[j] << 8) | (uint32_t)f[j+1];
sprintf(desc, "SId 0x%X", SId);
- printbuf(desc, indent+3, NULL, 0);
+ printbuf(desc, disp+3, NULL, 0);
}
i += (Number_of_services * 2);
}
}
else {
// Data services, 32 bit SId
- printbuf(desc, indent+2, NULL, 0);
+ printbuf(desc, disp+2, NULL, 0);
for(j = i; ((j < (i + (Number_of_services * 4))) && (j < fig0.figlen)); j += 4) {
// iterate over SId
SId = ((uint32_t)f[j] << 24) | ((uint32_t)f[j+1] << 16) |
((uint32_t)f[j+2] << 8) | (uint32_t)f[j+3];
sprintf(desc, "SId 0x%X", SId);
- printbuf(desc, indent+3, NULL, 0);
+ printbuf(desc, disp+3, NULL, 0);
}
i += (Number_of_services * 4);
}
diff --git a/src/fig1.cpp b/src/fig1.cpp
index 6bb095c..be2c2ba 100644
--- a/src/fig1.cpp
+++ b/src/fig1.cpp
@@ -32,7 +32,7 @@
using namespace std;
// SHORT LABELS
-bool fig1_select(fig1_common_t& fig1, int indent)
+bool fig1_select(fig1_common_t& fig1, const display_settings_t &disp)
{
uint16_t ext,oe,charset;
uint16_t flag;
@@ -48,7 +48,7 @@ bool fig1_select(fig1_common_t& fig1, int indent)
"FIG %d/%d: OE=%d, Charset=%d",
figtype, ext, oe, charset);
- printbuf(desc, indent, f+1, fig1.figlen-1);
+ printbuf(desc, disp, f+1, fig1.figlen-1);
memcpy(label, f+fig1.figlen-18, 16);
label[16] = 0x00;
flag = f[fig1.figlen-2] * 256 + \
@@ -60,7 +60,7 @@ bool fig1_select(fig1_common_t& fig1, int indent)
uint16_t eid;
eid = f[1] * 256 + f[2];
sprintf(desc, "Ensemble ID 0x%04X label: \"%s\", Short label mask: 0x%04X", eid, label, flag);
- printinfo(desc, indent+1, 1);
+ printinfo(desc, disp+1, 1);
}
break;
@@ -69,7 +69,7 @@ bool fig1_select(fig1_common_t& fig1, int indent)
uint16_t sid;
sid = f[1] * 256 + f[2];
sprintf(desc, "Service ID 0x%X label: \"%s\", Short label mask: 0x%04X", sid, label, flag);
- printinfo(desc, indent+1, 1);
+ printinfo(desc, disp+1, 1);
}
break;
@@ -92,7 +92,7 @@ bool fig1_select(fig1_common_t& fig1, int indent)
sprintf(desc,
"Service ID 0x%X , Service Component ID 0x%04X Short, label: \"%s\", label mask: 0x%04X",
sid, SCIdS, label, flag);
- printinfo(desc, indent+1, 1);
+ printinfo(desc, disp+1, 1);
}
break;
@@ -107,7 +107,7 @@ bool fig1_select(fig1_common_t& fig1, int indent)
sprintf(desc,
"Service ID 0x%X label: \"%s\", Short label mask: 0x%04X",
sid, label, flag);
- printinfo(desc, indent+1, 1);
+ printinfo(desc, disp+1, 1);
}
break;
@@ -146,7 +146,7 @@ bool fig1_select(fig1_common_t& fig1, int indent)
sprintf(desc,"Service ID 0x%X , Service Component ID 0x%04X Short, X-PAD App %02X (%s), label: \"%s\", label mask: 0x%04X",
sid, SCIdS, xpadapp, xpadappdesc.c_str(), label, flag);
- printbuf(desc,indent+1,NULL,0,"");
+ printbuf(desc,disp+1,NULL,0,"");
}
break;
}
diff --git a/src/figs.cpp b/src/figs.cpp
index a1557d7..b418cc2 100644
--- a/src/figs.cpp
+++ b/src/figs.cpp
@@ -74,37 +74,37 @@ void figs_cleardb()
}
-bool fig0_select(fig0_common_t& fig0, int indent)
+bool fig0_select(fig0_common_t& fig0, const display_settings_t &disp)
{
switch (fig0.ext()) {
- case 0: return fig0_0(fig0, indent); break;
- case 1: return fig0_1(fig0, indent); break;
- case 2: return fig0_2(fig0, indent); break;
- case 3: return fig0_3(fig0, indent); break;
- case 5: return fig0_5(fig0, indent); break;
- case 6: return fig0_6(fig0, indent); break;
- case 8: return fig0_8(fig0, indent); break;
- case 9: return fig0_9(fig0, indent); break;
- case 10: return fig0_10(fig0, indent); break;
- case 11: return fig0_11(fig0, indent); break;
- case 13: return fig0_13(fig0, indent); break;
- case 14: return fig0_14(fig0, indent); break;
- case 16: return fig0_16(fig0, indent); break;
- case 17: return fig0_17(fig0, indent); break;
- case 18: return fig0_18(fig0, indent); break;
- case 19: return fig0_19(fig0, indent); break;
- case 21: return fig0_21(fig0, indent); break;
- case 22: return fig0_22(fig0, indent); break;
- case 24: return fig0_24(fig0, indent); break;
- case 25: return fig0_25(fig0, indent); break;
- case 26: return fig0_26(fig0, indent); break;
- case 27: return fig0_27(fig0, indent); break;
- case 28: return fig0_28(fig0, indent); break;
- case 31: return fig0_31(fig0, indent); break;
+ case 0: return fig0_0(fig0, disp); break;
+ case 1: return fig0_1(fig0, disp); break;
+ case 2: return fig0_2(fig0, disp); break;
+ case 3: return fig0_3(fig0, disp); break;
+ case 5: return fig0_5(fig0, disp); break;
+ case 6: return fig0_6(fig0, disp); break;
+ case 8: return fig0_8(fig0, disp); break;
+ case 9: return fig0_9(fig0, disp); break;
+ case 10: return fig0_10(fig0, disp); break;
+ case 11: return fig0_11(fig0, disp); break;
+ case 13: return fig0_13(fig0, disp); break;
+ case 14: return fig0_14(fig0, disp); break;
+ case 16: return fig0_16(fig0, disp); break;
+ case 17: return fig0_17(fig0, disp); break;
+ case 18: return fig0_18(fig0, disp); break;
+ case 19: return fig0_19(fig0, disp); break;
+ case 21: return fig0_21(fig0, disp); break;
+ case 22: return fig0_22(fig0, disp); break;
+ case 24: return fig0_24(fig0, disp); break;
+ case 25: return fig0_25(fig0, disp); break;
+ case 26: return fig0_26(fig0, disp); break;
+ case 27: return fig0_27(fig0, disp); break;
+ case 28: return fig0_28(fig0, disp); break;
+ case 31: return fig0_31(fig0, disp); break;
default: {
char desc[256];
sprintf(desc, "FIG 0/%d: unknown", fig0.ext());
- printbuf(desc, indent, fig0.f+1, fig0.figlen-1);
+ printbuf(desc, disp, fig0.f+1, fig0.figlen-1);
break;
}
}
diff --git a/src/figs.hpp b/src/figs.hpp
index 7bd5fd0..f8f8d97 100644
--- a/src/figs.hpp
+++ b/src/figs.hpp
@@ -80,34 +80,34 @@ void set_international_table(size_t intl_table);
void set_mode_identity(uint8_t mid);
uint8_t get_mode_identity();
-bool fig0_select(fig0_common_t& fig0, int indent);
+bool fig0_select(fig0_common_t& fig0, const display_settings_t &disp);
-bool fig0_0(fig0_common_t& fig0, int indent);
-bool fig0_1(fig0_common_t& fig0, int indent);
-bool fig0_2(fig0_common_t& fig0, int indent);
-bool fig0_3(fig0_common_t& fig0, int indent);
-bool fig0_5(fig0_common_t& fig0, int indent);
+bool fig0_0(fig0_common_t& fig0, const display_settings_t &disp);
+bool fig0_1(fig0_common_t& fig0, const display_settings_t &disp);
+bool fig0_2(fig0_common_t& fig0, const display_settings_t &disp);
+bool fig0_3(fig0_common_t& fig0, const display_settings_t &disp);
+bool fig0_5(fig0_common_t& fig0, const display_settings_t &disp);
void fig0_6_cleardb();
-bool fig0_6(fig0_common_t& fig0, int indent);
-bool fig0_8(fig0_common_t& fig0, int indent);
-bool fig0_9(fig0_common_t& fig0, int indent);
-bool fig0_10(fig0_common_t& fig0, int indent);
-bool fig0_11(fig0_common_t& fig0, int indent);
-bool fig0_13(fig0_common_t& fig0, int indent);
-bool fig0_14(fig0_common_t& fig0, int indent);
-bool fig0_16(fig0_common_t& fig0, int indent);
-bool fig0_17(fig0_common_t& fig0, int indent);
-bool fig0_18(fig0_common_t& fig0, int indent);
-bool fig0_19(fig0_common_t& fig0, int indent);
-bool fig0_21(fig0_common_t& fig0, int indent);
+bool fig0_6(fig0_common_t& fig0, const display_settings_t &disp);
+bool fig0_8(fig0_common_t& fig0, const display_settings_t &disp);
+bool fig0_9(fig0_common_t& fig0, const display_settings_t &disp);
+bool fig0_10(fig0_common_t& fig0, const display_settings_t &disp);
+bool fig0_11(fig0_common_t& fig0, const display_settings_t &disp);
+bool fig0_13(fig0_common_t& fig0, const display_settings_t &disp);
+bool fig0_14(fig0_common_t& fig0, const display_settings_t &disp);
+bool fig0_16(fig0_common_t& fig0, const display_settings_t &disp);
+bool fig0_17(fig0_common_t& fig0, const display_settings_t &disp);
+bool fig0_18(fig0_common_t& fig0, const display_settings_t &disp);
+bool fig0_19(fig0_common_t& fig0, const display_settings_t &disp);
+bool fig0_21(fig0_common_t& fig0, const display_settings_t &disp);
void fig0_22_cleardb();
-bool fig0_22(fig0_common_t& fig0, int indent);
-bool fig0_24(fig0_common_t& fig0, int indent);
-bool fig0_25(fig0_common_t& fig0, int indent);
-bool fig0_26(fig0_common_t& fig0, int indent);
-bool fig0_27(fig0_common_t& fig0, int indent);
-bool fig0_28(fig0_common_t& fig0, int indent);
-bool fig0_31(fig0_common_t& fig0, int indent);
-
-bool fig1_select(fig1_common_t& fig1, int indent);
+bool fig0_22(fig0_common_t& fig0, const display_settings_t &disp);
+bool fig0_24(fig0_common_t& fig0, const display_settings_t &disp);
+bool fig0_25(fig0_common_t& fig0, const display_settings_t &disp);
+bool fig0_26(fig0_common_t& fig0, const display_settings_t &disp);
+bool fig0_27(fig0_common_t& fig0, const display_settings_t &disp);
+bool fig0_28(fig0_common_t& fig0, const display_settings_t &disp);
+bool fig0_31(fig0_common_t& fig0, const display_settings_t &disp);
+
+bool fig1_select(fig1_common_t& fig1, const display_settings_t &disp);
diff --git a/src/utils.cpp b/src/utils.cpp
index 71df396..7ea00bb 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -44,14 +44,29 @@ int get_verbosity()
return verbosity;
}
+display_settings_t display_settings_t::operator+(int indent_offset) const
+{
+ return display_settings_t(print, indent+indent_offset);
+}
+
+void printbuf(std::string header,
+ int indent,
+ uint8_t* buffer,
+ size_t size,
+ std::string desc)
+{
+ display_settings_t disp(true, indent);
+ printbuf(header, disp, buffer, size, desc);
+}
+
void printbuf(string header,
- int indent_level,
+ const display_settings_t &disp,
uint8_t* buffer,
size_t size,
string desc)
{
if (verbosity > 0) {
- for (int i = 0; i < indent_level; i++) {
+ for (int i = 0; i < disp.indent; i++) {
printf("\t");
}
@@ -75,18 +90,25 @@ void printbuf(string header,
}
}
-void printinfo(string header,
- int indent_level,
+void printinfo(const string &header,
+ const display_settings_t &disp,
int min_verb)
{
if (verbosity >= min_verb) {
- for (int i = 0; i < indent_level; i++) {
+ for (int i = 0; i < disp.indent; i++) {
printf("\t");
}
printf("%s\n", header.c_str());
}
}
+void printinfo(const std::string &header,
+ int min_verb)
+{
+ const display_settings_t disp(true, 0);
+ printinfo(header, min_verb);
+}
+
int sprintfMJD(char *dst, int mjd) {
// EN 62106 Annex G
// These formulas are applicable between the inclusive dates: 1st March 1900 to 28th February 2100
diff --git a/src/utils.hpp b/src/utils.hpp
index 057447f..557453d 100644
--- a/src/utils.hpp
+++ b/src/utils.hpp
@@ -36,14 +36,34 @@
void set_verbosity(int v);
int get_verbosity(void);
+struct display_settings_t {
+ display_settings_t(bool _print, int _indent) :
+ print(_print), indent(_indent) {}
+
+ display_settings_t operator+(int indent_offset) const;
+
+ bool print;
+ int indent;
+};
+
+
void printbuf(std::string header,
- int indent_level,
+ const display_settings_t &disp,
uint8_t* buffer,
size_t size,
std::string desc="");
-void printinfo(std::string header,
- int indent_level,
+void printbuf(std::string header,
+ int indent,
+ uint8_t* buffer,
+ size_t size,
+ std::string desc="");
+
+void printinfo(const std::string &header,
+ const display_settings_t &disp,
+ int min_verb);
+
+void printinfo(const std::string &header,
int min_verb);
// sprintfMJD: convert MJD (Modified Julian Date) into date string