Skip to content
Permalink
Browse files

Simplify xxx_is_same() functions.

  • Loading branch information...
gfto committed Jan 31, 2015
1 parent f69e34f commit 45e7e999a17c1954915295bd13b242bbd937cf28
Showing with 34 additions and 17 deletions.
  1. +4 −2 cat.c
  2. +4 −2 eit.c
  3. +4 −2 nit.c
  4. +4 −2 pat.c
  5. +4 −2 pmt.c
  6. +6 −3 privsec.c
  7. +4 −2 sdt.c
  8. +4 −2 tdt.c
6 cat.c
@@ -185,8 +185,10 @@ void ts_cat_dump(struct ts_cat *cat) {

int ts_cat_is_same(struct ts_cat *cat1, struct ts_cat *cat2) {
if (cat1 == cat2) return 1; // Same
if ((!cat1 && cat2) || (cat1 && !cat2)) return 0; // Not same (one is NULL)
return ts_section_is_same(cat1->section_header, cat2->section_header);
if (cat1 && cat2)
return ts_section_is_same(cat1->section_header, cat2->section_header);
else
return 0;
}

enum CA_system ts_get_CA_sys(uint16_t CA_id) {
6 eit.c
@@ -310,6 +310,8 @@ void ts_eit_dump(struct ts_eit *eit) {

int ts_eit_is_same(struct ts_eit *eit1, struct ts_eit *eit2) {
if (eit1 == eit2) return 1; // Same
if ((!eit1 && eit2) || (eit1 && !eit2)) return 0; // Not same (one is NULL)
return ts_section_is_same(eit1->section_header, eit2->section_header);
if (eit1 && eit2)
return ts_section_is_same(eit1->section_header, eit2->section_header);
else
return 0;
}
6 nit.c
@@ -294,6 +294,8 @@ void ts_nit_dump(struct ts_nit *nit) {

int ts_nit_is_same(struct ts_nit *nit1, struct ts_nit *nit2) {
if (nit1 == nit2) return 1; // Same
if ((!nit1 && nit2) || (nit1 && !nit2)) return 0; // Not same (one is NULL)
return ts_section_is_same(nit1->section_header, nit2->section_header);
if (nit1 && nit2)
return ts_section_is_same(nit1->section_header, nit2->section_header);
else
return 0;
}
6 pat.c
@@ -231,6 +231,8 @@ void ts_pat_dump(struct ts_pat *pat) {

int ts_pat_is_same(struct ts_pat *pat1, struct ts_pat *pat2) {
if (pat1 == pat2) return 1; // Same
if ((!pat1 && pat2) || (pat1 && !pat2)) return 0; // Not same (one is NULL)
return ts_section_is_same(pat1->section_header, pat2->section_header);
if (pat1 && pat2)
return ts_section_is_same(pat1->section_header, pat2->section_header);
else
return 0;
}
6 pmt.c
@@ -295,6 +295,8 @@ void ts_pmt_dump(struct ts_pmt *pmt) {

int ts_pmt_is_same(struct ts_pmt *pmt1, struct ts_pmt *pmt2) {
if (pmt1 == pmt2) return 1; // Same
if ((!pmt1 && pmt2) || (pmt1 && !pmt2)) return 0; // Not same (one is NULL)
return ts_section_is_same(pmt1->section_header, pmt2->section_header);
if (pmt1 && pmt2)
return ts_section_is_same(pmt1->section_header, pmt2->section_header);
else
return 0;
}
@@ -87,9 +87,12 @@ struct ts_privsec *ts_privsec_push_packet(struct ts_privsec *privsec, uint8_t *t

int ts_privsec_is_same(struct ts_privsec *p1, struct ts_privsec *p2) {
if (p1 == p2) return 1; // Same
if ((!p1 && p2) || (p1 && !p2)) return 0; // Not same (one is NULL)
if (p1->section_header->section_length != p1->section_header->section_length) return 0; // Not same
return memcmp(p1->section_header->section_data, p2->section_header->section_data, p1->section_header->section_length) == 0;
if (p1 && p2) {
if (p1->section_header->section_length != p2->section_header->section_length) return 0; // Not same
return memcmp(p1->section_header->section_data, p2->section_header->section_data, p1->section_header->section_length) == 0;
} else {
return 0;
}
}

void ts_privsec_dump(struct ts_privsec *privsec) {
6 sdt.c
@@ -267,6 +267,8 @@ void ts_sdt_dump(struct ts_sdt *sdt) {

int ts_sdt_is_same(struct ts_sdt *sdt1, struct ts_sdt *sdt2) {
if (sdt1 == sdt2) return 1; // Same
if ((!sdt1 && sdt2) || (sdt1 && !sdt2)) return 0; // Not same (one is NULL)
return ts_section_is_same(sdt1->section_header, sdt2->section_header);
if (sdt1 && sdt2)
return ts_section_is_same(sdt1->section_header, sdt2->section_header);
else
return 0;
}
6 tdt.c
@@ -234,6 +234,8 @@ void ts_tdt_dump(struct ts_tdt *tdt) {

int ts_tdt_is_same(struct ts_tdt *tdt1, struct ts_tdt *tdt2) {
if (tdt1 == tdt2) return 1; // Same
if ((!tdt1 && tdt2) || (tdt1 && !tdt2)) return 0; // Not same (one is NULL)
return ts_section_is_same(tdt1->section_header, tdt2->section_header);
if (tdt1 && tdt2)
return ts_section_is_same(tdt1->section_header, tdt2->section_header);
else
return 0;
}

0 comments on commit 45e7e99

Please sign in to comment.
You can’t perform that action at this time.