13 all_ascii(const uint8_t *p, size_t n)
15 for (size_t i = 0; i < n; i++)
16 if (p[i] < 32 || p[i] > 126)
22 try_find(const char *target, size_t target_len)
24 const uint8_t *pos = (const uint8_t *) memmem (data, n, target, target_len);
25 return pos ? pos - data : 0;
29 try_find_tail(const char *target, size_t target_len)
31 size_t pos = try_find(target, target_len);
32 return pos ? pos + target_len : 0;
36 find(const char *target, size_t target_len)
38 size_t pos = try_find(target, target_len);
41 fprintf (stderr, "not found\n");
48 find_tail(const char *target, size_t target_len)
50 size_t pos = try_find_tail(target, target_len);
53 fprintf (stderr, "not found\n");
62 #define STR(x) XSTR(x)
63 #define WHERE __FILE__":" STR(__LINE__)
69 memcpy(&x, &data[pos], 4);
78 memcpy(&x, &data[pos], 8);
93 match_u32_assert(uint32_t x, const char *where)
95 unsigned int y = get_u32();
98 fprintf(stderr, "%s: 0x%x: expected i%u, got i%u\n", where, pos - 4, x, y);
102 #define match_u32_assert(x) match_u32_assert(x, WHERE)
105 match_byte(uint8_t b)
107 if (pos < n && data[pos] == b)
117 match_byte_assert(uint8_t b, const char *where)
121 fprintf(stderr, "%s: 0x%x: expected %02x, got %02x\n", where, pos, b, data[pos]);
125 #define match_byte_assert(b) match_byte_assert(b, WHERE)
128 get_string(const char *where)
131 /*data[pos + 1] == 0 && data[pos + 2] == 0 && data[pos + 3] == 0*/
132 /*&& all_ascii(&data[pos + 4], data[pos])*/)
134 int len = data[pos] + data[pos + 1] * 256;
135 char *s = malloc(len + 1);
137 memcpy(s, &data[pos + 4], len);
144 fprintf(stderr, "%s: 0x%x: expected string\n", where, pos);
148 #define get_string() get_string(WHERE)
151 dump_value(int level)
153 for (int i = 0; i <= level; i++)
162 char *s1 = get_string();
163 if (match_byte (0x31))
167 printf("(footnote %d) ", get_u32());
168 match_byte_assert (0);
169 match_byte_assert (0);
170 int subn = get_u32 ();
171 printf ("nested %d bytes", subn);
174 else if (match_u32 (2))
176 printf("(special 2)");
177 match_byte_assert(0);
178 match_byte_assert(0);
180 match_byte_assert(0);
181 match_byte_assert(0);
182 int subn = get_u32 ();
183 printf ("nested %d bytes", subn);
189 printf("(special 3)");
190 match_byte_assert(0);
191 match_byte_assert(0);
192 match_byte_assert(1);
193 match_byte_assert(0);
194 int subn = get_u32 ();
195 printf ("nested %d bytes, ", subn);
198 printf ("nested %d bytes, ", subn);
203 match_byte_assert (0x58);
204 char *s2 = get_string();
205 char *s3 = get_string();
207 printf("strings \"%s\", \"%s\" and \"%s\"", s1, s2, s3);
209 printf("string \"%s\" and \"%s\"", s1, s2);
220 else if (match_byte (5))
222 match_byte_assert (0x58);
223 printf ("variable \"%s\"", get_string());
225 if (!match_byte(1) && !match_byte(2))
226 match_byte_assert(3);
232 else if (match_byte (2))
238 match_byte_assert (0x58);
240 value = get_double ();
242 vallab = get_string ();
243 printf ("value %g format %d(%d.%d) var \"%s\" vallab \"%s\"",
244 value, format >> 16, (format >> 8) & 0xff, format & 0xff, var, vallab);
245 if (!match_byte (1) && !match_byte(2))
246 match_byte_assert (3);
255 else if (match_byte (4))
258 char *var, *vallab, *value;
260 match_byte_assert (0x58);
262 vallab = get_string ();
264 if (!match_byte(1) && !match_byte(2))
265 match_byte_assert (3);
266 value = get_string ();
267 printf ("value \"%s\" format %d(%d.%d) var \"%s\" vallab \"%s\"",
268 value, format >> 16, (format >> 8) & 0xff, format & 0xff, var, vallab);
274 else if (match_byte (1))
279 if (match_byte (0x31))
283 printf("(footnote %d) ", get_u32());
284 match_byte_assert (0);
285 match_byte_assert (0);
286 int subn = get_u32 ();
287 printf ("nested %d bytes", subn);
292 match_byte_assert (0x58);
294 value = get_double ();
295 printf ("value %g format %d(%d.%d)", value, format >> 16, (format >> 8) & 0xff, format & 0xff);
302 else if (match_byte (0x31))
306 printf("(footnote %d) ", get_u32());
307 match_byte_assert (0);
308 match_byte_assert (0);
309 int subn = get_u32 ();
310 printf ("nested %d bytes", subn);
315 match_u32_assert (0);
316 match_u32_assert (0);
317 int subn = get_u32 ();
318 printf ("nested %d bytes", subn);
321 char *base = get_string();
323 printf ("\"%s\"; %d variables:\n", base, x);
326 for (int i = 0; i < x; i++)
328 dump_value (level+1);
334 for (int i = 0; i < x; i++)
338 for (int j = 0; j <= level; j++)
340 printf("variable %d has %d values:\n", i, y);
341 for (int j = 0; j < y; j++)
345 char *a = get_string();
346 match_byte_assert(0x58);
347 char *b = get_string();
348 char *c = get_string();
349 for (int k = 0; k <= level + 1; k++)
351 printf ("\"%s\", \"%s\", \"%s\"", a, b, c);
359 dump_value (level+1);
368 match_byte_assert (0x58);
369 char *base = get_string();
371 printf ("\"%s\" with %d variables:\n", base, x);
374 for (int i = 0; i < x; i++)
376 dump_value (level+1);
382 for (int i = 0; i < x; i++)
386 for (int j = 0; j <= level; j++)
388 printf("variable %d has %d values:\n", i, y);
389 for (int j = 0; j < y; j++)
393 char *a = get_string();
394 match_byte_assert(0x58);
395 char *b = get_string();
396 char *c = get_string();
397 for (int k = 0; k <= level + 1; k++)
399 printf ("\"%s\", \"%s\", \"%s\"", a, b, c);
407 dump_value (level+1);
416 dump_dim_value(int level)
418 for (int i = 0; i <= level; i++)
424 if (match_byte (0x31))
427 printf("(footnote %d) ", get_u32());
428 match_byte_assert (0);
429 match_byte_assert (0);
430 int subn = get_u32 ();
431 printf ("nested %d bytes", subn);
435 match_byte_assert (0x58);
437 printf("string \"%s\"", get_string());
439 match_byte_assert (1);
445 else if (match_byte (5))
447 match_byte_assert (0x58);
448 printf ("variable \"%s\"", get_string());
450 match_byte_assert (2);
452 else if (match_byte (2))
458 match_byte_assert (0x58);
460 value = get_double ();
462 vallab = get_string ();
463 printf ("value %g format %d(%d.%d) var \"%s\" vallab \"%s\"",
464 value, format >> 16, (format >> 8) & 0xff, format & 0xff, var, vallab);
466 match_u32_assert (2);
469 else if (match_byte (1))
474 match_byte_assert (0x58);
476 value = get_double ();
477 printf ("value %g format %d(%d.%d)", value, format >> 16, (format >> 8) & 0xff, format & 0xff);
489 match_byte_assert (0x31);
490 match_u32_assert (0);
491 match_u32_assert (0);
493 printf ("nested %d bytes", subn);
495 printf ("; \"%s\", substitutions:", get_string());
496 int total_subs = get_u32();
500 total_subs = (total_subs - 1) + x;
501 match_u32_assert (0);
503 printf (" (total %d)", total_subs);
505 for (int i = 0; i < total_subs; i++)
508 dump_value (level + 1);
514 dump_category(int level)
524 else if (match_u32 (1))
531 else if (match_byte (1))
535 match_u32_assert (1);
541 match_u32_assert (0);
545 int n_categories = get_u32();
546 if (n_categories > 0)
547 printf (", %d subcategories:", n_categories);
549 for (int i = 0; i < n_categories; i++)
550 dump_category (level + 1);
557 printf("next dim\n");
562 match_byte_assert(0x58);
564 printf("string \"%s\": ", get_string());
565 match_byte(1) || match_byte(0);
567 else if (match_byte(5))
569 match_byte_assert(0x58);
570 printf("variable \"%s\": ", get_string());
573 match_byte_assert(3);
575 else if (match_byte(0x31))
580 match_u32_assert (0);
581 match_u32_assert (0);
583 printf ("nested %d bytes", subn);
585 printf ("; \"%s\", substitutions:", get_string());
588 int n_subst = get_u32();
591 printf (" %d", n_subst);
592 total_subs *= n_subst;
595 for (int i = 0; i < total_subs; i++)
605 match_byte_assert (0x58);
606 printf ("\"%s\" with substitutions:", get_string());
609 int n_subst = get_u32();
612 printf (" %d", n_subst);
613 total_subs *= n_subst;
616 for (int i = 0; i < total_subs; i++)
623 /* This byte is usually 0x02 but 0x00 and 0x75 (!) have also been spotted. */
626 if (!match_byte(0) && !match_byte(1))
627 match_byte_assert(2);
631 match_byte_assert(1);
641 n_categories = get_u32();
642 printf("%d nested categories\n", n_categories);
643 for (int i = 0; i < n_categories; i++)
652 printf ("%u dimensions\n", n_dims);
653 for (int i = 0; i < n_dims; i++)
661 dump_data_value_31(void)
663 if (match_byte (0x31))
670 match_u32_assert (0);
671 int subn = get_u32 ();
672 printf ("nested %d bytes", subn);
675 else if (match_u32 (1))
677 printf("(footnote %d) ", get_u32());
678 match_byte_assert (0);
679 match_byte_assert (0);
680 int subn = get_u32 ();
681 printf ("nested %d bytes", subn);
684 else if (match_u32 (2))
686 printf("(special 2)");
687 match_byte_assert(0);
688 match_byte_assert(0);
690 match_byte_assert(0);
691 match_byte_assert(0);
692 int subn = get_u32 ();
693 printf ("nested %d bytes", subn);
699 printf("(special 3)");
700 match_byte_assert(0);
701 match_byte_assert(0);
702 match_byte_assert(1);
703 match_byte_assert(0);
704 int subn = get_u32 ();
705 printf ("nested %d bytes, ", subn);
708 printf ("nested %d bytes, ", subn);
713 match_byte_assert (0x58);
721 for (int i = 0; i < 3 + n_dims; i++)
723 printf ("data intro:");
724 for (int i = 0; i < 3 + n_dims; i++)
728 fprintf (stderr,"data intro (%d dims):", n_dims);
729 for (int i = 0; i < 3+n_dims; i++)
730 fprintf (stderr," %d", get_u32());
731 fprintf(stderr,"\n");
734 printf ("%d data values, starting at %08x\n", x, pos);
735 for (int i = 0; i < x; i++)
737 printf("%08x, index %d:\n", pos, get_u32());
748 dump_data_value_31();
750 value = get_double ();
751 printf (" value %g format %d(%d.%d)", value, format >> 16, (format >> 8) & 0xff, format & 0xff);
753 else if (match_byte (3))
756 dump_data_value_31();
758 printf("string \"%s\"", get_string());
761 else if (match_byte (2))
767 match_byte_assert (0x58);
769 value = get_double ();
771 vallab = get_string ();
772 printf ("value %g format %d(%d.%d) var \"%s\" vallab \"%s\"",
773 value, format >> 16, (format >> 8) & 0xff, format & 0xff, var, vallab);
774 if (!match_byte (1) && !match_byte(2))
775 match_byte_assert (3);
777 else if (match_byte (4))
780 char *var, *vallab, *value;
782 match_byte_assert (0x58);
784 vallab = get_string ();
786 if (!match_byte(1) && !match_byte(2))
787 match_byte_assert (3);
788 value = get_string ();
789 printf ("value \"%s\" format %d(%d.%d) var \"%s\" vallab \"%s\"",
790 value, format >> 16, (format >> 8) & 0xff, format & 0xff, var, vallab);
792 else if (match_byte (5))
794 match_byte_assert (0x58);
795 printf ("variable \"%s\"", get_string());
797 if (!match_byte(1) && !match_byte(2))
798 match_byte_assert(3);
806 dump_data_value_31();
807 char *base = get_string();
809 printf ("\"%s\"; %d variables:\n", base, x);
810 for (int i = 0; i < x; i++)
817 for (int j = 0; j <= 0; j++)
819 printf("variable %d has %d values:\n", i, y);
820 for (int j = 0; j < y; j++)
827 dump_data_value_31();
829 value = get_double ();
830 printf (" value %g format %d(%d.%d)", value, format >> 16, (format >> 8) & 0xff, format & 0xff);
832 else if (match_byte(3))
834 char *a = get_string();
835 match_byte_assert(0x58);
836 char *b = get_string();
837 char *c = get_string();
838 for (int k = 0; k <= 1; k++)
840 printf ("\"%s\", \"%s\", \"%s\"", a, b, c);
846 else if (match_byte(5))
848 match_byte_assert (0x58);
849 printf ("variable \"%s\"", get_string());
851 if (!match_byte(1) && !match_byte(2))
852 match_byte_assert(3);
869 dump_title_value_31(int level)
871 if (match_byte (0x31))
875 match_u32_assert (0);
876 int subn = get_u32 ();
877 printf ("nested %d bytes", subn);
880 else if (match_u32 (1))
882 printf("(footnote %d) ", get_u32());
883 match_byte_assert (0);
884 match_byte_assert (0);
885 int subn = get_u32 ();
886 printf ("nested %d bytes", subn);
889 else if (match_u32 (2))
891 printf("(special 2)");
892 match_byte_assert(0);
893 match_byte_assert(0);
896 match_byte_assert(0);
897 match_byte_assert(0);
898 int subn = get_u32 ();
899 printf ("nested %d bytes", subn);
905 printf("(special 3)");
906 match_byte_assert(0);
907 match_byte_assert(0);
908 match_byte_assert(1);
909 match_byte_assert(0);
910 int subn = get_u32 ();
911 printf ("nested %d bytes, ", subn);
914 printf ("nested %d bytes, ", subn);
919 match_byte_assert (0x58);
923 dump_title_value(int level)
925 for (int i = 0; i <= level; i++)
936 dump_title_value_31(level);
938 printf("string \"%s\"", get_string());
949 else if (match_byte (5))
951 dump_title_value_31(level);
952 printf ("variable \"%s\"", get_string());
954 if (!match_byte(1) && !match_byte(2))
955 match_byte_assert(3);
957 else if (match_byte (2))
963 match_byte_assert (0x58);
965 value = get_double ();
967 vallab = get_string ();
968 printf ("value %g format %d(%d.%d) var \"%s\" vallab \"%s\"",
969 value, format >> 16, (format >> 8) & 0xff, format & 0xff, var, vallab);
970 if (!match_byte (1) && !match_byte(2))
971 match_byte_assert (3);
980 else if (match_byte (4))
983 char *var, *vallab, *value;
985 match_byte_assert (0x58);
987 vallab = get_string ();
989 if (!match_byte(1) && !match_byte(2))
990 match_byte_assert (3);
991 value = get_string ();
992 printf ("value \"%s\" format %d(%d.%d) var \"%s\" vallab \"%s\"",
993 value, format >> 16, (format >> 8) & 0xff, format & 0xff, var, vallab);
999 else if (match_byte (1))
1001 unsigned int format;
1004 dump_title_value_31(level);
1005 format = get_u32 ();
1006 value = get_double ();
1007 printf ("value %g format %d(%d.%d)", value, format >> 16, (format >> 8) & 0xff, format & 0xff);
1016 dump_title_value_31(level);
1018 char *base = get_string();
1020 printf ("\"%s\" with %d variables:\n", base, x);
1021 for (int i = 0; i < x; i++)
1027 match_u32_assert(0);
1028 for (int j = 0; j <= level; j++)
1030 printf("variable %d has %d values:\n", i, y);
1031 for (int j = 0; j < y; j++)
1036 char *a = get_string();
1037 match_byte_assert(0x58);
1038 char *b = get_string();
1039 char *c = get_string();
1040 for (int k = 0; k <= level + 1; k++)
1042 printf ("\"%s\", \"%s\", \"%s\"", a, b, c);
1045 dump_title_value (level+1);
1053 dump_footnote_value(int level)
1055 for (int i = 0; i <= level; i++)
1065 if (match_byte (0x31))
1069 printf("(footnote %d) ", get_u32());
1070 match_byte_assert (0);
1071 match_byte_assert (0);
1072 int subn = get_u32 ();
1073 printf ("nested %d bytes", subn);
1076 else if (match_u32 (2))
1078 printf("(special 2)");
1079 match_byte_assert(0);
1080 match_byte_assert(0);
1081 match_u32_assert(1);
1082 match_byte_assert(0);
1083 match_byte_assert(0);
1084 int subn = get_u32 ();
1085 printf ("nested %d bytes", subn);
1090 match_u32_assert(3);
1091 printf("(special 3)");
1092 match_byte_assert(0);
1093 match_byte_assert(0);
1094 match_byte_assert(1);
1095 match_byte_assert(0);
1096 int subn = get_u32 ();
1097 printf ("nested %d bytes, ", subn);
1100 printf ("nested %d bytes, ", subn);
1105 match_byte_assert (0x58);
1107 printf("string \"%s\"", get_string());
1108 if (!match_byte (0))
1109 match_byte_assert (1);
1111 else if (match_byte (5))
1113 match_byte_assert (0x58);
1114 printf ("variable \"%s\"", get_string());
1116 if (!match_byte(1) && !match_byte(2))
1117 match_byte_assert(3);
1119 else if (match_byte (2))
1121 unsigned int format;
1125 match_byte_assert (0x58);
1126 format = get_u32 ();
1127 value = get_double ();
1128 var = get_string ();
1129 vallab = get_string ();
1130 printf ("value %g format %d(%d.%d) var \"%s\" vallab \"%s\"",
1131 value, format >> 16, (format >> 8) & 0xff, format & 0xff, var, vallab);
1132 if (!match_byte (1) && !match_byte(2))
1133 match_byte_assert (3);
1142 else if (match_byte (4))
1144 unsigned int format;
1145 char *var, *vallab, *value;
1147 match_byte_assert (0x58);
1148 format = get_u32 ();
1149 vallab = get_string ();
1150 var = get_string ();
1151 if (!match_byte(1) && !match_byte(2))
1152 match_byte_assert (3);
1153 value = get_string ();
1154 printf ("value \"%s\" format %d(%d.%d) var \"%s\" vallab \"%s\"",
1155 value, format >> 16, (format >> 8) & 0xff, format & 0xff, var, vallab);
1161 else if (match_byte (1))
1163 unsigned int format;
1166 if (match_byte (0x31))
1170 printf("(footnote %d) ", get_u32());
1171 match_byte_assert (0);
1172 match_byte_assert (0);
1173 int subn = get_u32 ();
1174 printf ("nested %d bytes", subn);
1179 match_byte_assert (0x58);
1180 format = get_u32 ();
1181 value = get_double ();
1182 printf ("value %g format %d(%d.%d)", value, format >> 16, (format >> 8) & 0xff, format & 0xff);
1184 else if (match_byte (0x31))
1188 printf("(footnote %d) ", get_u32());
1189 match_byte_assert (0);
1190 match_byte_assert (0);
1191 int subn = get_u32 ();
1192 printf ("nested %d bytes", subn);
1197 match_u32_assert (0);
1198 match_u32_assert (0);
1199 int subn = get_u32 ();
1200 printf ("nested %d bytes", subn);
1203 char *base = get_string();
1205 printf ("\"%s\"; %d variables:\n", base, x);
1206 for (int i = 0; i < x; i++)
1212 match_u32_assert(0);
1213 for (int j = 0; j <= level; j++)
1215 printf("variable %d has %d values:\n", i, y);
1216 for (int j = 0; j < y; j++)
1220 char *a = get_string();
1221 match_byte_assert(0x58);
1222 char *b = get_string();
1223 char *c = get_string();
1224 for (int k = 0; k <= level + 1; k++)
1226 printf ("\"%s\", \"%s\", \"%s\"", a, b, c);
1228 match_byte_assert(0);
1231 dump_footnote_value (level+1);
1239 match_byte_assert (0x58);
1240 char *base = get_string();
1242 printf ("\"%s\" with %d variables:\n", base, x);
1243 for (int i = 0; i < x; i++)
1249 match_u32_assert(0);
1250 for (int j = 0; j <= level; j++)
1252 printf("variable %d has %d values:\n", i, y);
1253 for (int j = 0; j < y; j++)
1257 char *a = get_string();
1258 match_byte_assert(0x58);
1259 char *b = get_string();
1260 char *c = get_string();
1261 for (int k = 0; k <= level + 1; k++)
1263 printf ("\"%s\", \"%s\", \"%s\"", a, b, c);
1264 match_byte_assert(0);
1267 dump_footnote_value (level+1);
1278 dump_title_value(0); putchar('\n');
1279 dump_title_value(0); putchar('\n');
1280 match_byte_assert(0x31);
1281 dump_title_value(0); putchar('\n');
1283 match_byte_assert(0x58);
1284 if (match_byte(0x31))
1286 dump_footnote_value(0); putchar('\n');
1289 match_byte_assert(0x58);
1292 int n_footnotes = get_u32();
1293 if (n_footnotes >= 20)
1295 fprintf(stderr, "%08x: %d footnotes\n", pos - 4, n_footnotes);
1299 printf("------\n%d footnotes\n", n_footnotes);
1300 if (n_footnotes < 20)
1302 for (int i = 0; i < n_footnotes; i++)
1304 printf("footnote %d:\n", i);
1305 dump_footnote_value(0);
1312 unsigned int format;
1315 if (match_byte (0x31))
1319 printf("(footnote %d) ", get_u32());
1320 match_byte_assert (0);
1321 match_byte_assert (0);
1322 int subn = get_u32 ();
1323 printf ("nested %d bytes", subn);
1328 match_byte_assert (0x58);
1329 format = get_u32 ();
1330 value = get_double ();
1331 printf ("value %g format %d(%d.%d)", value, format >> 16, (format >> 8) & 0xff, format & 0xff);
1338 else if (match_byte (0x31))
1340 match_byte_assert(3);
1342 match_byte_assert(0x58);
1343 match_u32_assert(0);
1348 match_byte_assert (0x58);
1349 printf("(%d)\n", get_u32());
1355 find_dimensions(void)
1358 const char dimensions[] = "-,,,.\0";
1359 int x = try_find_tail(dimensions, sizeof dimensions - 1);
1364 const char dimensions[] = "-,,, .\0";
1365 return find_tail(dimensions, sizeof dimensions - 1);
1371 printf("fonts: offset=%08x\n", pos);
1373 for (int i = 1; i <= 8; i++)
1375 printf("%08x: font %d, ", pos, i);
1376 match_byte_assert(i);
1377 match_byte_assert(0x31);
1378 printf("%s, ", get_string());
1379 match_byte_assert(0);
1380 match_byte_assert(0);
1381 if (!match_byte(0x40) && !match_byte(0x20) && !match_byte(0x80) && !match_byte(0x10))
1382 match_byte_assert(0x50);
1383 if (!match_byte(0x41))
1384 match_byte_assert(0x51);
1386 printf ("%s, ", get_string());
1387 printf ("%s, ", get_string());
1388 match_u32_assert(0);
1389 match_u32_assert(0);
1398 match_u32_assert(240);
1401 match_u32_assert(18);
1408 match_u32_assert(142);
1412 int count = get_u32();
1415 char *encoding = get_string();
1416 printf("encoding=%s\n", encoding);
1419 match_u32_assert(UINT32_MAX);
1421 match_byte_assert(1);
1422 match_byte_assert(0);
1424 match_byte_assert(1);
1425 if (!match_byte(0x99) && !match_byte(0x98))
1426 match_byte_assert(0x97);
1427 match_byte_assert(7);
1428 match_byte_assert(0);
1429 match_byte_assert(0);
1430 if (match_byte('.'))
1431 match_byte_assert(',');
1434 match_byte_assert(',');
1435 if (!match_byte('.'))
1436 match_byte_assert(' ');
1438 match_u32_assert(5);
1439 for (int i = 0; i < 5; i++)
1442 if (pos != find_dimensions())
1443 fprintf (stderr, "%08x / %08x\n", pos, find_dimensions());
1447 main(int argc, char *argv[])
1452 if (isatty(STDIN_FILENO))
1454 fprintf(stderr, "redirect stdin from a .bin file\n");
1457 if (fstat(STDIN_FILENO, &s))
1469 if (read(STDIN_FILENO, data, n) != n)
1477 if (!strcmp(argv[1], "title0"))
1480 if (match_byte (0x03)
1481 || (match_byte (0x05) && match_byte (0x58)))
1482 printf ("%s\n", get_string());
1484 printf ("<unknown>\n");
1487 else if (!strcmp(argv[1], "title"))
1492 else if (!strcmp(argv[1], "titleraw"))
1494 const char fonts[] = "\x01\x31\x09\0\0\0SansSerif";
1496 n = find(fonts, sizeof fonts - 1);
1498 else if (!strcmp(argv[1], "fonts"))
1500 const char fonts[] = "\x01\x31\x09\0\0\0SansSerif";
1501 const char styles[] = "\xf0\0\0\0";
1502 start = find(fonts, sizeof fonts - 1);
1503 n = find(styles, sizeof styles - 1);
1505 else if (!strcmp(argv[1], "styles"))
1507 const char styles[] = "\xf0\0\0\0";
1508 const char dimensions[] = "-,,,.\0";
1509 start = find(styles, sizeof styles - 1);
1510 n = find(dimensions, sizeof dimensions - 1) + sizeof dimensions - 1;
1512 else if (!strcmp(argv[1], "dimensions") || !strcmp(argv[1], "all"))
1515 match_byte_assert(1);
1516 match_byte_assert(0);
1517 match_u32_assert(3);
1518 match_byte_assert(1);
1520 match_byte_assert(1);
1521 match_byte_assert(0);
1522 match_byte_assert(0);
1524 match_byte_assert(1);
1526 match_byte_assert(0);
1527 match_byte_assert(0);
1528 match_byte_assert(0);
1532 printf("\n\ndata:\n");
1535 match_byte_assert (1);
1538 fprintf (stderr, "%x / %x\n", pos, n);
1545 fprintf (stderr, "unknown section %s\n", argv[1]);
1552 for (size_t i = start; i < n; )
1559 && i + 4 + data[i] + data[i + 1] * 256 <= n
1560 && all_ascii(&data[i + 4], data[i] + data[i + 1] * 256))
1562 fputs("\n\"", stdout);
1563 fwrite(&data[i + 4], 1, data[i] + data[i + 1] * 256, stdout);
1564 fputs("\" ", stdout);
1566 i += 4 + data[i] + data[i + 1] * 256;
1568 else if (i + 12 <= n
1569 && data[i + 1] == 40
1571 && data[i + 3] == 0)
1575 memcpy (&d, &data[i + 4], 8);
1576 printf ("F40.%d(%.*f)\n", data[i], data[i], d);
1579 else if (i + 12 <= n
1580 && data[i + 1] == 40
1581 && data[i + 2] == 31
1582 && data[i + 3] == 0)
1586 memcpy (&d, &data[i + 4], 8);
1587 printf ("PCT40.%d(%.*f)\n", data[i], data[i], d);
1591 && (data[i] && data[i] != 88 && data[i] != 0x41)
1596 printf ("i%d ", data[i]);
1601 printf("%02x ", data[i]);