+static void
+dump_data(void)
+{
+ /* The first three numbers add to the number of dimensions. */
+ int t = get_u32();
+ t += get_u32();
+ match_u32_assert(n_dims - t);
+
+ /* The next n_dims numbers are a permutation of the dimension numbers. */
+ int a[n_dims];
+ for (int i = 0; i < n_dims; i++)
+ a[i] = get_u32();
+ check_permutation(a, n_dims, "dimensions");
+
+ int x = get_u32();
+ printf ("%d data values, starting at %08x\n", x, pos);
+ for (int i = 0; i < x; i++)
+ {
+ printf("%08x, index %d:\n", pos, get_u32());
+ match_u32_assert(0);
+ dump_value__(0, false);
+ putchar('\n');
+ }
+}
+
+static void
+dump_title(void)
+{
+ pos = 0x27;
+ dump_value__(0, true); putchar('\n');
+ dump_value__(0, true); putchar('\n');
+ match_byte_assert(0x31);
+ dump_value__(0, true); putchar('\n');
+ match_byte(0);
+ match_byte_assert(0x58);
+ if (match_byte(0x31))
+ {
+ dump_value__(0, false); putchar('\n');
+ }
+ else
+ match_byte_assert(0x58);
+
+
+ int n_footnotes = get_u32();
+ if (n_footnotes >= 20)
+ {
+ fprintf(stderr, "%08x: %d footnotes\n", pos - 4, n_footnotes);
+ exit(1);
+ }
+
+ printf("------\n%d footnotes\n", n_footnotes);
+ if (n_footnotes < 20)
+ {
+ for (int i = 0; i < n_footnotes; i++)
+ {
+ printf("footnote %d:\n", i);
+ dump_value__(0, false);
+ if (match_byte (0x31))
+ {
+ /* Custom footnote marker string. */
+ match_byte_assert(3);
+ get_string();
+ match_byte_assert(0x58);
+ match_u32_assert(0);
+ get_string();
+ }
+ else
+ match_byte_assert (0x58);
+ printf("(%d)\n", get_u32());
+ }
+ }
+}
+
+static int
+find_dimensions(void)
+{
+ {
+ const char dimensions[] = "-,,,.\0";
+ int x = try_find_tail(dimensions, sizeof dimensions - 1);
+ if (x)
+ return x;
+ }
+
+ const char dimensions[] = "-,,, .\0";
+ return find_tail(dimensions, sizeof dimensions - 1);
+}
+
+static void
+dump_fonts(void)
+{
+ printf("fonts: offset=%08x\n", pos);
+ match_byte(0);
+ for (int i = 1; i <= 8; i++)
+ {
+ printf("%08x: font %d, ", pos, i);
+ match_byte_assert(i);
+ match_byte_assert(0x31);
+ printf("%s, ", get_string());
+ match_byte_assert(0);
+ match_byte_assert(0);
+ if (!match_byte(0x40) && !match_byte(0x20) && !match_byte(0x80) && !match_byte(0x10))
+ match_byte_assert(0x50);
+ if (!match_byte(0x41))
+ match_byte_assert(0x51);
+ pos += 13;
+ printf ("%s, ", get_string());
+ printf ("%s, ", get_string());
+ match_u32_assert(0);
+ match_u32_assert(0);
+ pos++;
+ get_u32();
+ get_u32();
+ get_u32();
+ get_u32();
+ putchar('\n');
+ }
+
+ match_u32_assert(240);
+ pos += 240;
+
+ match_u32_assert(18);
+ pos += 18;
+
+ if (match_u32(117))
+ pos += 117;
+ else
+ {
+ match_u32_assert(142);
+ pos += 142;
+ }
+
+ int count = get_u32();
+ pos += 4 * count;
+
+ char *encoding = get_string();
+ printf("encoding=%s\n", encoding);
+
+ if (!match_u32(0))
+ match_u32_assert(UINT32_MAX);
+ if (!match_byte(0))
+ match_byte_assert(1);
+ match_byte_assert(0);
+ if (!match_byte(0))
+ match_byte_assert(1);
+ if (!match_byte(0x99) && !match_byte(0x98))
+ match_byte_assert(0x97);
+ match_byte_assert(7);
+ match_byte_assert(0);
+ match_byte_assert(0);
+ if (match_byte('.'))
+ match_byte_assert(',');
+ else
+ {
+ match_byte_assert(',');
+ if (!match_byte('.'))
+ match_byte_assert(' ');
+ }
+ match_u32_assert(5);
+ for (int i = 0; i < 5; i++)
+ get_string();
+ pos += get_u32();
+ if (pos != find_dimensions())
+ fprintf (stderr, "%08x / %08x\n", pos, find_dimensions());
+}
+