11 #include "u8-mbtouc.h"
19 all_ascii(const uint8_t *p, size_t n)
21 for (size_t i = 0; i < n; i++)
22 if (p[i] < 32 || p[i] > 126)
28 try_find(const char *target, size_t target_len)
30 const uint8_t *pos = (const uint8_t *) memmem (data, n, target, target_len);
31 return pos ? pos - data : 0;
35 find(const char *target, size_t target_len)
37 size_t pos = try_find(target, target_len);
40 fprintf (stderr, "not found\n");
49 #define STR(x) XSTR(x)
50 #define WHERE __FILE__":" STR(__LINE__)
62 memcpy(&x, &data[pos], 4);
67 static unsigned long long int
71 memcpy(&x, &data[pos], 8);
80 x = (data[pos] << 24) | (data[pos + 1] << 16) | (data[pos + 2] << 8) | data[pos + 3];
89 memcpy(&x, &data[pos], 2);
98 memcpy(&x, &data[pos], 8);
103 static double __attribute__((unused))
107 memcpy(&x, &data[pos], 4);
113 match_u32(uint32_t x)
122 match_u32_assert(uint32_t x, const char *where)
124 unsigned int y = get_u32();
127 fprintf(stderr, "%s: 0x%x: expected i%u, got i%u\n", where, pos - 4, x, y);
131 #define match_u32_assert(x) match_u32_assert(x, WHERE)
133 static bool __attribute__((unused))
134 match_be32(uint32_t x)
143 match_be32_assert(uint32_t x, const char *where)
145 unsigned int y = get_be32();
148 fprintf(stderr, "%s: 0x%x: expected be%u, got be%u\n", where, pos - 4, x, y);
152 #define match_be32_assert(x) match_be32_assert(x, WHERE)
155 match_byte(uint8_t b)
157 if (pos < n && data[pos] == b)
167 match_byte_assert(uint8_t b, const char *where)
171 fprintf(stderr, "%s: 0x%x: expected %02x, got %02x\n", where, pos, b, data[pos]);
175 #define match_byte_assert(b) match_byte_assert(b, WHERE)
178 newline(FILE *stream, int pos)
180 fprintf(stream, "\n%08x: ", pos);
184 dump_raw(FILE *stream, int start, int end)
186 for (size_t i = start; i < end; )
193 && i + 4 + data[i] + data[i + 1] * 256 <= end
194 && all_ascii(&data[i + 4], data[i] + data[i + 1] * 256))
197 fprintf(stream, "\"");
198 fwrite(&data[i + 4], 1, data[i] + data[i + 1] * 256, stream);
199 fputs("\" ", stream);
201 i += 4 + data[i] + data[i + 1] * 256;
203 else if (i + 12 <= end
210 memcpy (&d, &data[i + 4], 8);
211 fprintf (stream, "F40.%d(%.*f)", data[i], data[i], d);
215 else if (i + 12 <= end
222 memcpy (&d, &data[i + 4], 8);
223 fprintf (stream, "PCT40.%d(%.*f)", data[i], data[i], d);
227 else if (i + 4 <= end
228 && (data[i] && data[i] != 88 && data[i] != 0x41)
233 fprintf (stream, "i%d ", data[i]);
238 fprintf(stream, "%02x ", data[i]);
246 static bool __attribute__((unused))
247 all_utf8(const char *p_)
249 const uint8_t *p = (const uint8_t *) p_;
250 size_t len = strlen ((char *) p);
251 for (size_t ofs = 0, mblen; ofs < len; ofs += mblen)
255 mblen = u8_mbtouc (&uc, p + ofs, len - ofs);
256 if ((uc < 32 && uc != '\n') || uc == 127 || uc == 0xfffd)
263 get_string(const char *where)
266 /*data[pos + 1] == 0 && data[pos + 2] == 0 && data[pos + 3] == 0*/
267 /*&& all_ascii(&data[pos + 4], data[pos])*/)
269 int len = data[pos] + data[pos + 1] * 256;
270 char *s = malloc(len + 1);
272 memcpy(s, &data[pos + 4], len);
279 fprintf(stderr, "%s: 0x%x: expected string\n", where, pos);
283 #define get_string() get_string(WHERE)
286 get_string_be(const char *where)
289 /*data[pos + 1] == 0 && data[pos + 2] == 0 && data[pos + 3] == 0*/
290 /*&& all_ascii(&data[pos + 4], data[pos])*/)
292 int len = data[pos + 2] * 256 + data[pos + 3];
293 char *s = malloc(len + 1);
295 memcpy(s, &data[pos + 4], len);
302 fprintf(stderr, "%s: 0x%x: expected string\n", where, pos);
306 #define get_string_be() get_string_be(WHERE)
315 static void __attribute__((unused))
316 hex_dump(int ofs, int n)
318 for (int i = 0; i < n; i++)
320 int c = data[ofs + i];
323 fprintf(stderr, "-");
325 fprintf(stderr, " ");
327 fprintf(stderr, "%02x", c);
329 for (int i = 0; i < n; i++)
331 int c = data[ofs + i];
332 fprintf(stderr, "%c", c >= 32 && c < 127 ? c : '.');
334 fprintf(stderr, "\n");
338 dump_counted_string(void)
341 int inner_end = get_end();
342 if (pos != inner_end)
347 match_byte_assert(0x58);
351 if (match_byte(0x31))
354 match_byte_assert(0x58);
355 if (pos != inner_end)
357 fprintf(stderr, "inner end discrepancy\n");
365 dump_style(FILE *stream)
371 match_byte_assert(1);
372 char *fg = get_string(); /* foreground */
373 char *bg = get_string(); /* background */
374 char *font = get_string(); /* font */
375 int size = data[pos];
377 match_byte_assert(12); /* size? */
378 fprintf(stream, " fgcolor=\"%s\" bgcolor=\"%s\" font=\"%s\" size=\"%d\"",
383 dump_nested_string(FILE *stream)
387 match_byte_assert (0);
388 match_byte_assert (0);
389 int outer_end = get_end();
390 s = dump_counted_string();
392 fprintf(stream, " \"%s\"", s);
393 if (match_byte(0x31))
396 match_byte_assert(0x58);
397 match_byte_assert(0x58);
398 if (pos != outer_end)
400 fprintf(stderr, "outer end discrepancy\n");
408 dump_value_modifier(FILE *stream)
410 if (match_byte (0x31))
414 fprintf(stream, "<special0");
417 /* Corpus frequencies:
422 The given text is appended to the cell in a subscript font.
424 fprintf(stream, " subscript=\"%s\"", get_string());
427 match_u32_assert (0);
431 /* We only have one SPV file for this version (with many
438 if (!match_u32(0) && !match_u32(1) && !match_u32(2) && !match_u32(3) && !match_u32(4) && !match_u32(5) && !match_u32(6) && !match_u32(7) && !match_u32(8) && !match_u32(9))
439 match_u32_assert(10);
442 fprintf(stream, "/>\n");
446 int outer_end = get_end();
448 /* This counted-string appears to be a template string,
449 e.g. "Design\: [:^1:]1 Within Subjects Design\: [:^1:]2". */
450 char *template = dump_counted_string();
452 fprintf(stream, " template=\"%s\"", template);
454 if (match_byte(0x31))
457 match_byte_assert(0x58);
458 if (match_byte(0x31))
460 /* Only two SPV files have anything like this, so it's hard to
466 match_byte_assert(1);
467 match_byte_assert(0);
468 if (!match_byte(8) && !match_byte(1))
469 match_byte_assert(2);
470 match_byte_assert(0);
471 match_byte_assert(8);
472 match_byte_assert(0);
473 match_byte_assert(10);
474 match_byte_assert(0);
477 match_byte_assert(0x58);
478 if (pos != outer_end)
480 fprintf(stderr, "outer end discrepancy\n");
483 fprintf(stream, "/>\n");
487 int count = get_u32();
488 fprintf(stream, "<footnote-ref indexes=\"");
489 for (int i = 0; i < count; i++)
493 fprintf(stream, "%d", get_u16());
496 match_byte_assert(0);
497 match_byte_assert(0);
498 dump_nested_string(stream);
499 fprintf(stream, "/>\n");
503 match_byte_assert (0x58);
507 format_to_string (int type)
513 case 2: return "AHEX";
514 case 3: return "COMMA";
515 case 4: return "DOLLAR";
516 case 5: case 40: return "F";
518 case 7: return "PIBHEX";
520 case 9: return "PIB";
521 case 10: return "PK";
522 case 11: return "RB";
523 case 12: return "RBHEX";
527 case 20: return "DATE";
528 case 21: return "TIME";
529 case 22: return "DATETIME";
530 case 23: return "ADATE";
531 case 24: return "JDATE";
532 case 25: return "DTIME";
533 case 26: return "WKDAY";
534 case 27: return "MONTH";
535 case 28: return "MOYR";
536 case 29: return "QYR";
537 case 30: return "WKYR";
538 case 31: return "PCT";
539 case 32: return "DOT";
540 case 33: return "CCA";
541 case 34: return "CCB";
542 case 35: return "CCC";
543 case 36: return "CCD";
544 case 37: return "CCE";
545 case 38: return "EDATE";
546 case 39: return "SDATE";
549 sprintf(tmp, "<%d>", type);
555 dump_value(FILE *stream, int level)
562 for (int i = 0; i <= level; i++)
563 fprintf (stream, " ");
570 dump_value_modifier(stream);
572 value = get_double ();
573 fprintf (stream, "<number value=\"%.*g\" format=\"%s%d.%d\"/>\n",
574 DBL_DIG, value, format_to_string(format >> 16), (format >> 8) & 0xff, format & 0xff);
576 else if (match_byte (2))
582 dump_value_modifier (stream);
584 value = get_double ();
586 vallab = get_string ();
587 fprintf (stream, "<numeric-datum value=\"%.*g\" format=\"%s%d.%d\"",
588 DBL_DIG, value, format_to_string(format >> 16), (format >> 8) & 0xff, format & 0xff);
590 fprintf (stream, " variable=\"%s\"", var);
592 fprintf (stream, " label=\"%s\"", vallab);
593 fprintf (stream, "/>\n");
594 if (!match_byte (1) && !match_byte(2))
595 match_byte_assert (3);
597 else if (match_byte (3))
599 char *text = get_string();
600 dump_value_modifier(stream);
601 char *identifier = get_string();
602 char *text_eng = get_string();
603 fprintf (stream, "<string c=\"%s\"", text_eng);
605 fprintf (stream, " identifier=\"%s\"", identifier);
606 if (strcmp(text_eng, text))
607 fprintf (stream, " local=\"%s\"", text);
608 fprintf (stream, "/>\n");
610 match_byte_assert(1);
612 else if (match_byte (4))
615 char *var, *vallab, *value;
617 dump_value_modifier(stream);
619 vallab = get_string ();
621 if (!match_byte(1) && !match_byte(2))
622 match_byte_assert (3);
623 value = get_string ();
624 fprintf (stream, "<string-datum value=\"%s\" format=\"%s%d.%d\"",
625 value, format_to_string(format >> 16), (format >> 8) & 0xff, format & 0xff);
627 fprintf (stream, " variable=\"%s\"", var);
629 fprintf (stream, " label=\"%s\"/>\n", vallab);
630 fprintf (stream, "/>\n");
632 else if (match_byte (5))
634 dump_value_modifier(stream);
635 char *name = get_string ();
636 char *label = get_string ();
637 fprintf (stream, "<variable name=\"%s\"", name);
639 fprintf (stream, " label=\"%s\"", label);
640 fprintf (stream, "/>\n");
641 if (!match_byte(1) && !match_byte(2))
642 match_byte_assert(3);
646 dump_value_modifier(stream);
648 char *base = get_string();
650 fprintf (stream, "<template format=\"%s\">\n", base);
651 for (int i = 0; i < x; i++)
658 for (int j = 0; j <= level + 1; j++)
659 fprintf (stream, " ");
660 fprintf (stream, "<substitution index=\"%d\">\n", i + 1);
661 for (int j = 0; j < y; j++)
662 dump_value (stream, level + 2);
663 for (int j = 0; j <= level + 1; j++)
664 fprintf (stream, " ");
665 fprintf (stream, "</substitution>\n");
667 for (int j = 0; j <= level; j++)
668 fprintf (stream, " ");
669 fprintf (stream, "</template>\n");
674 compare_int(const void *a_, const void *b_)
678 return *a < *b ? -1 : *a > *b;
682 check_permutation(int *a, int n, const char *name)
685 memcpy(b, a, n * sizeof *a);
686 qsort(b, n, sizeof *b, compare_int);
687 for (int i = 0; i < n; i++)
690 fprintf(stderr, "bad %s permutation:", name);
691 for (int i = 0; i < n; i++)
692 fprintf(stderr, " %d", a[i]);
699 dump_category(FILE *stream, int level, int **indexes, int *allocated_indexes,
702 for (int i = 0; i <= level; i++)
703 fprintf (stream, " ");
704 printf ("<category>\n");
705 dump_value (stream, level + 1);
707 int merge = data[pos];
709 match_byte_assert (1);
711 match_byte_assert (0);
713 int unindexed = data[pos];
715 match_byte_assert (1);
720 match_u32_assert (2);
722 int indx = get_u32();
723 int n_categories = get_u32();
728 for (int i = 0; i <= level + 1; i++)
729 fprintf (stream, " ");
730 fprintf (stream, "<merge/>\n");
737 fprintf(stderr, "index not -1 but merged\n");
742 fprintf(stderr, "index not -1 but x != 2\n");
745 if (n_categories != 0)
747 fprintf(stderr, "index not -1 but subcategories\n");
750 if (*n_indexes >= *allocated_indexes)
752 *allocated_indexes = *allocated_indexes ? 2 * *allocated_indexes : 16;
753 *indexes = realloc(*indexes, *allocated_indexes * sizeof **indexes);
755 (*indexes)[(*n_indexes)++] = indx;
758 int expected_unindexed = indx == -1;
759 if (unindexed != expected_unindexed)
761 fprintf(stderr, "unindexed (%d) mismatch with indx (%d)\n",
766 if (n_categories == 0)
768 for (int i = 0; i <= level + 1; i++)
769 fprintf (stream, " ");
770 fprintf (stream, "<category-index>%d</category-index>\n", indx);
772 for (int i = 0; i < n_categories; i++)
773 dump_category (stream, level + 1, indexes, allocated_indexes, n_indexes);
774 for (int i = 0; i <= level; i++)
775 fprintf (stream, " ");
776 printf ("</category>\n");
784 printf ("<dimension index=\"%d\">\n", indx);
785 dump_value (stdout, 0);
787 /* This byte is usually 0 but many other values have been spotted. */
790 if (!match_byte(0) && !match_byte(1))
791 match_byte_assert(2);
795 match_byte_assert(1);
797 match_byte_assert(1);
798 match_byte_assert(1);
799 if (!match_u32(UINT32_MAX))
800 match_u32_assert(indx);
801 n_categories = get_u32();
805 int allocated_indexes = 0;
806 for (int i = 0; i < n_categories; i++)
807 dump_category (stdout, 0, &indexes, &allocated_indexes, &n_indexes);
808 check_permutation(indexes, n_indexes, "categories");
810 fprintf (stdout, "</dimension>\n");
815 static int dim_n_cats[64];
816 #define MAX_DIMS (sizeof dim_n_cats / sizeof *dim_n_cats)
822 assert(n_dims < MAX_DIMS);
823 for (int i = 0; i < n_dims; i++)
824 dim_n_cats[i] = dump_dim (i);
830 /* The first three numbers add to the number of dimensions. */
833 int c = n_dims - l - r;
836 /* The next n_dims numbers are a permutation of the dimension numbers. */
838 for (int i = 0; i < n_dims; i++)
843 const char *name = i < l ? "layer" : i < l + r ? "row" : "column";
844 printf ("<%s dimension=\"%d\"/>\n", name, dim);
846 check_permutation(a, n_dims, "dimensions");
850 for (int i = 0; i < x; i++)
852 unsigned int indx = get_u32();
853 printf (" <datum index=\"%d\" coords=", indx);
855 int coords[MAX_DIMS];
856 for (int i = n_dims; i-- > 0; )
858 coords[i] = indx % dim_n_cats[i];
859 indx /= dim_n_cats[i];
861 for (int i = 0; i < n_dims; i++)
862 printf("%c%d", i ? ',' : '"', coords[i]);
868 dump_value(stdout, 1);
869 fprintf (stdout, " </datum>\n");
871 printf ("</data>\n");
877 printf ("<title-local>\n");
878 dump_value(stdout, 0);
880 printf ("</title-local>\n");
882 printf ("<subtype>\n");
883 dump_value(stdout, 0);
885 printf ("</subtype>\n");
887 match_byte_assert(0x31);
889 printf ("<title-c>\n");
890 dump_value(stdout, 0);
892 printf ("</title-c>\n");
894 if (match_byte(0x31))
896 printf ("<user-caption>\n");
897 dump_value(stdout, 0);
898 printf ("</user-caption>\n");
901 match_byte_assert(0x58);
902 if (match_byte(0x31))
904 printf ("<caption>\n");
905 dump_value(stdout, 0);
906 printf ("</caption>\n");
909 match_byte_assert(0x58);
911 int n_footnotes = get_u32();
912 for (int i = 0; i < n_footnotes; i++)
914 printf ("<footnote index=\"%d\">\n", i);
915 dump_value(stdout, 0);
916 /* Custom footnote marker string. */
917 if (match_byte (0x31))
918 dump_value(stdout, 0);
920 match_byte_assert (0x58);
922 printf ("</footnote>\n");
930 for (int i = 1; i <= 8; i++)
932 printf ("<style index=\"%d\"", i);
933 match_byte_assert(i);
934 match_byte_assert(0x31);
935 printf(" font=\"%s\"", get_string());
937 printf(" size=\"%gpt\"", get_float());
939 int style = get_u32();
941 printf(" bold=\"true\"");
943 printf(" italic=\"true\"");
945 bool underline = data[pos++];
947 printf(" underline=\"true\"");
949 int halign = get_u32();
950 printf("\nhalign=%d\n", halign);
952 int valign = get_u32();
953 printf("\nvalign=%d\n", valign);
955 printf (" fgcolor=\"%s\"", get_string());
956 printf (" bgcolor=\"%s\"", get_string());
959 match_byte_assert(1);
961 char *othercolor = get_string();
963 printf(" othercolor=\"%s\"", othercolor);
968 for (int i = 0; i < 4; i++)
969 printf(" %2d", get_u32());
977 int x1_end = pos + x1;
978 printf("<borders>\n");
979 match_be32_assert(1);
980 int n_borders = get_be32();
981 for (int i = 0; i < n_borders; i++)
983 int type = get_be32();
984 int stroke = get_be32();
985 int color = get_be32();
986 printf(" <border type=\"%d\" stroke=\"%s\" color=\"#%06x\"/>\n",
988 (stroke == 0 ? "none"
989 : stroke == 1 ? "solid"
990 : stroke == 2 ? "dashed"
991 : stroke == 3 ? "thick"
992 : stroke == 4 ? "thin"
993 : stroke == 5 ? "double"
997 bool grid = get_byte();
999 printf(" <grid show=\"%s\">\n", grid ? "yes" : "no");
1000 printf("</borders>\n");
1001 assert(pos == x1_end);
1003 int skip = get_u32();
1004 assert(skip == 18 || skip == 25);
1008 int x3_end = pos + x3;
1011 match_be32_assert(1);
1013 printf("<settings layer=\"%d\"", get_be32());
1015 printf(" skipempty=\"false\"");
1017 printf(" showdimensionincorner=\"false\"");
1019 printf(" markers=\"numeric\"");
1021 printf(" footnoteposition=\"subscript\"");
1025 char *look = get_string_be();
1027 printf(" look=\"%s\"", look);
1032 int count = get_u32();
1035 const char *locale = get_string();
1036 printf ("<locale>%s</locale>\n", locale);
1038 get_u32(); /* Seen: 0, UINT32_MAX, 2, 3, 4, 5, 6, 8, 9, 21, 24. */
1040 match_byte_assert(1);
1041 match_byte_assert(0);
1043 match_byte_assert(1);
1044 printf("<epoch>%d</epoch>\n", get_u32());
1046 int decimal = data[pos];
1047 int grouping = data[pos + 1];
1048 if (match_byte('.'))
1050 if (!match_byte(',') && !match_byte('\''))
1051 match_byte_assert(' ');
1055 match_byte_assert(',');
1056 if (!match_byte('.') && !match_byte(' ') && !match_byte(','))
1057 match_byte_assert(0);
1059 printf("<format decimal=\"%c\" grouping=\"", decimal);
1065 for (int i = 0; i < 5; i++)
1066 printf("<CC%c>%s</CC%c>\n", 'A' + i, get_string(), 'A' + i);
1069 match_u32_assert(0);
1071 /* The last chunk is an outer envelope that contains two inner envelopes.
1072 The second inner envelope has some interesting data like the encoding and
1076 int outer_end = get_end();
1078 /* First inner envelope: byte*33 int[n] int*[n]. */
1081 /* Second inner envelope. */
1082 assert(get_end() == outer_end);
1084 match_byte_assert(1);
1085 match_byte_assert(0);
1086 if (!match_byte(3) && !match_byte(4))
1087 match_byte_assert(5);
1088 match_byte_assert(0);
1089 match_byte_assert(0);
1090 match_byte_assert(0);
1092 printf("<command>%s</command>\n", get_string());
1093 printf("<subcommand>%s</subcommand>\n", get_string());
1094 printf("<language>%s</language>\n", get_string());
1095 printf("<charset>%s</charset>\n", get_string());
1096 printf("<locale>%s</locale>\n", get_string());
1099 match_byte_assert(1);
1100 match_byte_assert(0);
1102 match_byte_assert(1);
1104 match_byte_assert(1);
1106 printf("<epoch2>%d</epoch2>\n", get_u32());
1108 if (match_byte('.'))
1110 if (!match_byte(',') && !match_byte('\''))
1111 match_byte_assert(' ');
1115 match_byte_assert(',');
1116 if (!match_byte('.') && !match_byte(' ') && !match_byte(','))
1117 match_byte_assert(0);
1121 match_byte_assert(1);
1123 if (outer_end - pos > 6)
1125 /* There might be a pair of strings representing a dataset and
1126 datafile name, or there might be a set of custom currency strings.
1127 The custom currency strings start with a pair of integers, so we
1128 can distinguish these from a string by checking for a null byte; a
1129 small 32-bit integer will always contain a null and a text string
1132 int len = get_u32();
1133 bool has_dataset = !memchr(&data[pos], '\0', len);
1138 printf("<dataset>%s</dataset>\n", get_string());
1139 printf("<datafile>%s</datafile>\n", get_string());
1141 match_u32_assert(0);
1143 time_t date = get_u32();
1144 struct tm tm = *localtime(&date);
1146 strftime(s, sizeof s, "%a, %d %b %Y %H:%M:%S %z", &tm);
1147 printf("<date>%s</date>\n", s);
1149 match_u32_assert(0);
1155 for (int i = 0; i < 5; i++)
1156 printf("<CC%c>%s</CC%c>\n", 'A' + i, get_string(), 'A' + i);
1159 match_u32_assert(0);
1161 match_byte_assert(0x2e);
1163 match_byte_assert(1);
1165 if (pos < outer_end)
1167 printf("<seed>%d</seed>\n", get_u32());
1168 match_u32_assert(0);
1170 assert(pos == outer_end);
1181 main(int argc, char *argv[])
1186 if (isatty(STDIN_FILENO))
1188 fprintf(stderr, "redirect stdin from a .bin file\n");
1191 if (fstat(STDIN_FILENO, &s))
1203 if (read(STDIN_FILENO, data, n) != n)
1211 fprintf (stderr, "usage: %s TYPE < .bin", argv[0]);
1215 if (!strcmp(argv[1], "title0"))
1218 if (match_byte (0x03)
1219 || (match_byte (0x05) && match_byte (0x58)))
1220 printf ("%s\n", get_string());
1222 printf ("<unknown>\n");
1225 else if (!strcmp(argv[1], "title"))
1231 else if (!strcmp(argv[1], "titleraw"))
1233 const char fonts[] = "\x01\x31\x09\0\0\0SansSerif";
1235 n = find(fonts, sizeof fonts - 1);
1237 else if (!strcmp(argv[1], "fonts"))
1239 const char fonts[] = "\x01\x31\x09\0\0\0SansSerif";
1240 const char styles[] = "\xf0\0\0\0";
1241 start = find(fonts, sizeof fonts - 1);
1242 n = find(styles, sizeof styles - 1);
1244 else if (!strcmp(argv[1], "styles"))
1246 const char styles[] = "\xf0\0\0\0";
1247 const char dimensions[] = "-,,,.\0";
1248 start = find(styles, sizeof styles - 1);
1249 n = find(dimensions, sizeof dimensions - 1) + sizeof dimensions - 1;
1251 else if (!strcmp(argv[1], "dimensions") || !strcmp(argv[1], "all"))
1254 match_byte_assert(1);
1255 match_byte_assert(0);
1257 /* This might be a version number of some kind, because value 1 seems
1258 to only appear in an SPV file that also required its own weird
1259 special cases in dump_value_modifier(). */
1260 version = get_u32();
1263 match_u32_assert(3);
1265 match_byte_assert(1);
1267 match_byte_assert(1);
1270 match_byte_assert(0);
1272 match_byte_assert(1);
1274 match_byte_assert(1);
1278 match_byte_assert(0);
1279 match_byte_assert(0);
1280 match_byte_assert(0);
1285 match_byte_assert(1);
1286 match_byte_assert(0);
1287 match_byte_assert(0);
1292 match_byte_assert(1);
1293 match_byte_assert(0);
1294 match_byte_assert(0);
1299 match_byte_assert(1);
1300 match_byte_assert(0);
1301 match_byte_assert(0);
1310 printf("<tableid>%lld</tableid>", get_u64());
1319 fprintf (stderr, "%x / %x\n", pos, n);
1324 else if (!strcmp(argv[1], "raw"))
1328 dump_raw(stdout, start, n);
1332 fprintf (stderr, "unknown section %s\n", argv[1]);