+ indexes[(*n_indexes)++] = indx;
+ }
+ if (n_categories == 0)
+ {
+ for (int i = 0; i <= level + 1; i++)
+ fprintf (stdout, " ");
+ fprintf (stdout, "<category-index>%d</category-index>\n", indx);
+ }
+ for (int i = 0; i < n_categories; i++)
+ dump_category (level + 1, indexes, n_indexes, max_indexes);
+ for (int i = 0; i <= level; i++)
+ fprintf (stdout, " ");
+ printf ("</category>\n");
+}
+
+static void
+dump_dim(int indx)
+{
+ int n_categories;
+
+ printf ("<dimension index=\"%d\">\n", indx);
+ dump_value (stdout, 0, false);
+
+ /* This byte is usually 0x02 but many other values have been spotted. */
+ pos++;
+
+ if (!match_byte(0) && !match_byte(1))
+ match_byte_assert(2);
+ if (!match_u32(0))
+ match_u32_assert(2);
+ if (!match_byte(0))
+ match_byte_assert(1);
+ if (!match_byte(0))
+ match_byte_assert(1);
+ match_byte_assert(1);
+ if (!match_u32(UINT32_MAX))
+ match_u32_assert(indx);
+ n_categories = get_u32();
+
+ int indexes[2048];
+ int n_indexes = 0;
+ for (int i = 0; i < n_categories; i++)
+ dump_category (0, indexes, &n_indexes, sizeof indexes / sizeof *indexes);
+ check_permutation(indexes, n_indexes, "categories");
+
+ fprintf (stdout, "</dimension>\n");
+}
+
+int n_dims;
+static void
+dump_dims(void)
+{
+ n_dims = get_u32();
+ for (int i = 0; i < n_dims; i++)
+ dump_dim (i);
+}
+
+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 ("<data>\n");
+ for (int i = 0; i < x; i++)
+ {
+ printf (" <datum index=\"%d\">\n", get_u32());
+ match_u32_assert(0);
+ if (version == 1)
+ match_byte(0);
+ dump_value(stdout, 1, false);
+ fprintf (stdout, " </datum>\n");