aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/fit.c21
-rw-r--r--src/zdab-cat.c22
-rw-r--r--src/zebra.c7
-rw-r--r--src/zebra.h2
4 files changed, 23 insertions, 29 deletions
diff --git a/src/fit.c b/src/fit.c
index 7fdf994..e791480 100644
--- a/src/fit.c
+++ b/src/fit.c
@@ -6131,25 +6131,18 @@ int main(int argc, char **argv)
break;
}
- rv = zebra_get_bank(f, &bmast, f->first_bank);
+ if (f->mast_bank == -1) {
+ fprintf(stderr, "no MAST bank in logical record! Skipping...\n");
+ continue;
+ }
+
+ rv = zebra_get_bank(f, &bmast, f->mast_bank);
if (rv) {
fprintf(stderr, "error getting MAST bank: %s\n", zebra_err);
goto err;
}
- if (!strncmp(bmast.name,"MAST",4)) {
- ;
- } else if (!strncmp(bmast.name,"ZDAB",4)) {
- /* Not sure why, but occasionally some of the zdabs output by
- * SNOMAN have logical records which start with a ZDAB record
- * instead of a MAST record. */
- continue;
- } else {
- fprintf(stderr, "logical record starts with unknown bank '%s'\n", bmast.name);
- goto err;
- }
-
if (bmast.links[KMAST_EV-1] == 0) {
/* First logical record in SNOCR files don't have an EV bank. */
continue;
@@ -6378,7 +6371,7 @@ skip_event:
/* Note the origin link for the first EV bank points back to the
* structural link location in the MAST bank. These links are super
* confusing! */
- if ((b.orig == f->first_bank - KMAST_EV) || skip_second_event) break;
+ if ((b.orig == f->mast_bank - KMAST_EV) || skip_second_event) break;
rv = zebra_get_bank(f,&b,b.orig);
diff --git a/src/zdab-cat.c b/src/zdab-cat.c
index 7b0b714..12729d2 100644
--- a/src/zdab-cat.c
+++ b/src/zdab-cat.c
@@ -155,26 +155,18 @@ int main(int argc, char **argv)
break;
}
- rv = zebra_get_bank(f, &bmast, f->first_bank);
+ if (f->mast_bank == -1) {
+ fprintf(stderr, "no MAST bank in logical record! Skipping...\n");
+ continue;
+ }
+
+ rv = zebra_get_bank(f, &bmast, f->mast_bank);
if (rv) {
fprintf(stderr, "error getting MAST bank: %s\n", zebra_err);
goto err;
}
- if (!strncmp(bmast.name,"MAST",4)) {
- ;
- } else if (!strncmp(bmast.name,"ZDAB",4)) {
- /* Not sure why, but occasionally some of the zdabs output by
- * SNOMAN have logical records which start with a ZDAB record
- * instead of a MAST record. */
- continue;
- } else {
- continue;
- fprintf(stderr, "logical record starts with unknown bank '%s'\n", bmast.name);
- goto err;
- }
-
if (bmast.links[KMAST_EV-1] == 0) {
/* First logical record in SNOCR files doesn't have an EV bank. */
continue;
@@ -365,7 +357,7 @@ skip_event:
/* Note the origin link for the first EV bank points back to the
* structural link location in the MAST bank. These links are super
* confusing! */
- if ((b.orig == f->first_bank - KMAST_EV) || skip_second_event) break;
+ if ((b.orig == f->mast_bank - KMAST_EV) || skip_second_event) break;
rv = zebra_get_bank(f,&b,b.orig);
diff --git a/src/zebra.c b/src/zebra.c
index a3a068f..5e02310 100644
--- a/src/zebra.c
+++ b/src/zebra.c
@@ -187,6 +187,7 @@ static int rewrite_links(zebraFile *z)
offset = z->lr_offset*4;
+ z->mast_bank = -1;
while (offset < z->lr_size) {
io = unpacki32(z->buf+offset);
offset += 4;
@@ -199,6 +200,12 @@ static int rewrite_links(zebraFile *z)
rv = zebra_get_bank(z, &b, offset/4);
+ if (!strncmp(b.name,"MAST",4)) {
+ if (z->mast_bank != -1)
+ fprintf(stderr, "Warning: found more than one MAST bank in a single logical record!\n");
+ z->mast_bank = offset/4;
+ }
+
if (rv) return rv;
/* Rewrite the next, up, and orig pointers. */
diff --git a/src/zebra.h b/src/zebra.h
index 16b120f..25c35ed 100644
--- a/src/zebra.h
+++ b/src/zebra.h
@@ -145,6 +145,8 @@ typedef struct zebraFile {
size_t nwtab;
/* Link to first bank. */
uint32_t first_bank;
+ /* Link to the MAST bank. */
+ int32_t mast_bank;
/* Number of words from the start of the buffer to the first bank word. */
uint32_t lr_offset;
} zebraFile;