847dcac45c96ebb568ad515d3429edce9f2c018d
[pspp] / dump-spo2.c
1 #include <assert.h>
2 #include <errno.h>
3 #include <fcntl.h>
4 #include <float.h>
5 #include <inttypes.h>
6 #include <stdbool.h>
7 #include <stdint.h>
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <string.h>
11 #include <sys/stat.h>
12 #include <time.h>
13 #include <unistd.h>
14 #include "u8-mbtouc.h"
15
16 static const char *filename;
17 static uint8_t *data;
18 static size_t n;
19
20 int version;
21
22 unsigned int pos;
23
24 #define XSTR(x) #x
25 #define STR(x) XSTR(x)
26 #define WHERE __FILE__":" STR(__LINE__)
27
28 static uint8_t
29 get_byte(void)
30 {
31   return data[pos++];
32 }
33
34 static unsigned int
35 get_u32(void)
36 {
37   uint32_t x;
38   memcpy(&x, &data[pos], 4);
39   pos += 4;
40   return x;
41 }
42
43 static unsigned long long int
44 get_u64(void)
45 {
46   uint64_t x;
47   memcpy(&x, &data[pos], 8);
48   pos += 8;
49   return x;
50 }
51
52 static unsigned int
53 get_be32(void)
54 {
55   uint32_t x;
56   x = (data[pos] << 24) | (data[pos + 1] << 16) | (data[pos + 2] << 8) | data[pos + 3];
57   pos += 4;
58   return x;
59 }
60
61 static unsigned int
62 get_u16(void)
63 {
64   uint16_t x;
65   memcpy(&x, &data[pos], 2);
66   pos += 2;
67   return x;
68 }
69
70 static double
71 get_double(void)
72 {
73   double x;
74   memcpy(&x, &data[pos], 8);
75   pos += 8;
76   return x;
77 }
78
79 static double __attribute__((unused))
80 get_float(void)
81 {
82   float x;
83   memcpy(&x, &data[pos], 4);
84   pos += 4;
85   return x;
86 }
87
88 static bool
89 match_u32(uint32_t x)
90 {
91   if (get_u32() == x)
92     return true;
93   pos -= 4;
94   return false;
95 }
96
97 bool
98 match_u16(uint16_t x)
99 {
100   if (get_u16() == x)
101     return true;
102   pos -= 2;
103   return false;
104 }
105
106 static void
107 match_u32_assert(uint32_t x, const char *where)
108 {
109   unsigned int y = get_u32();
110   if (x != y)
111     {
112       fprintf(stderr, "%s: 0x%x: expected i%u, got i%u\n", where, pos - 4, x, y);
113       exit(1);
114     }
115 }
116 #define match_u32_assert(x) match_u32_assert(x, WHERE)
117
118 static void
119 match_u16_assert(uint16_t x, const char *where)
120 {
121   unsigned int y = get_u16();
122   if (x != y)
123     {
124       fprintf(stderr, "%s: 0x%x: expected u16:%u, got u16:%u\n", where, pos - 2, x, y);
125       exit(1);
126     }
127 }
128 #define match_u16_assert(x) match_u16_assert(x, WHERE)
129
130 static bool __attribute__((unused))
131 match_u64(uint64_t x)
132 {
133   if (get_u64() == x)
134     return true;
135   pos -= 8;
136   return false;
137 }
138
139 static void __attribute__((unused))
140 match_u64_assert(uint64_t x, const char *where)
141 {
142   unsigned long long int y = get_u64();
143   if (x != y)
144     {
145       fprintf(stderr, "%s: 0x%x: expected u64:%lu, got u64:%llu\n", where, pos - 8, x, y);
146       exit(1);
147     }
148 }
149 #define match_u64_assert(x) match_u64_assert(x, WHERE)
150
151 static bool __attribute__((unused))
152 match_be32(uint32_t x)
153 {
154   if (get_be32() == x)
155     return true;
156   pos -= 4;
157   return false;
158 }
159
160 static void
161 match_be32_assert(uint32_t x, const char *where)
162 {
163   unsigned int y = get_be32();
164   if (x != y)
165     {
166       fprintf(stderr, "%s: 0x%x: expected be%u, got be%u\n", where, pos - 4, x, y);
167       exit(1);
168     }
169 }
170 #define match_be32_assert(x) match_be32_assert(x, WHERE)
171
172 static bool
173 match_byte(uint8_t b)
174 {
175   if (pos < n && data[pos] == b)
176     {
177       pos++;
178       return true;
179     }
180   else
181     return false;
182 }
183
184 static void
185 match_byte_assert(uint8_t b, const char *where)
186 {
187   if (!match_byte(b))
188     {
189       fprintf(stderr, "%s: 0x%x: expected %02x, got %02x\n", where, pos, b, data[pos]);
190       exit(1);
191     }
192 }
193 #define match_byte_assert(b) match_byte_assert(b, WHERE)
194
195 static bool
196 match_bytes(int start, const int *bytes, size_t n_bytes)
197 {
198   for (size_t i = 0; i < n_bytes; i++)
199     if (bytes[i] >= 0 && data[start + i] != bytes[i])
200       return false;
201   return true;
202 }
203
204 static char *
205 xmemdup0(const void *p, size_t n)
206 {
207   char *s = malloc(n + 1);
208   memcpy(s, p, n);
209   s[n] = 0;
210   return s;
211 }
212
213 static bool
214 get_bool(void)
215 {
216   if (match_byte(0))
217     return false;
218   match_byte_assert(1);
219   return true;
220 }
221
222 static bool __attribute__((unused))
223 is_ascii(uint8_t p)
224 {
225   return (p >= ' ' && p < 127) || p == '\r' || p == '\n' || p == '\t';
226 }
227
228 static int
229 count_zeros(const uint8_t *p)
230 {
231   size_t n = 0;
232   while (p[n] == 0)
233     n++;
234   return n;
235 }
236
237 static bool __attribute__((unused))
238 all_utf8(const char *p_, size_t len)
239 {
240   const uint8_t *p = (const uint8_t *) p_;
241   for (size_t ofs = 0, mblen; ofs < len; ofs += mblen)
242     {
243       ucs4_t uc;
244
245       mblen = u8_mbtouc (&uc, p + ofs, len - ofs);
246       if ((uc < 32 && uc != '\n') || uc == 127 || uc == 0xfffd)
247         return false;
248     }
249   return true;
250 }
251
252 static char *
253 get_string2(void)
254 {
255   int len = data[pos] + data[pos + 1] * 256;
256   char *s = xmemdup0(&data[pos + 2], len);
257   pos += 2 + len;
258   return s;
259 }
260
261 static char *
262 get_string1(void)
263 {
264   int len = data[pos++];
265   if (len == 0xff)
266     return get_string2();
267   else
268     {
269       char *s = xmemdup0(&data[pos], len);
270       pos += len;
271       return s;
272     }
273 }
274
275 static void
276 match_string1_assert(const char *exp, const char *where)
277 {
278   int start = pos;
279   char *act = get_string1();
280   if (strcmp(act, exp)) 
281     {
282       fprintf(stderr, "%s: 0x%x: expected \"%s\", got \"%s\"\n",
283               where, start, exp, act);
284       exit(1);
285     }
286 }
287 #define match_string1_assert(x) match_string1_assert(x, WHERE)
288
289 static void
290 match_string2_assert(const char *exp, const char *where)
291 {
292   int start = pos;
293   char *act = get_string2();
294   if (strcmp(act, exp)) 
295     {
296       fprintf(stderr, "%s: 0x%x: expected \"%s\", got \"%s\"\n",
297               where, start, exp, act);
298       exit(1);
299     }
300 }
301 #define match_string2_assert(x) match_string2_assert(x, WHERE)
302
303 static char *
304 get_string4(const char *where)
305 {
306   if (1
307       /*data[pos + 1] == 0 && data[pos + 2] == 0 && data[pos + 3] == 0*/
308       /*&& all_ascii(&data[pos + 4], data[pos])*/)
309     {
310       int len = data[pos] + data[pos + 1] * 256;
311       char *s = malloc(len + 1);
312
313       memcpy(s, &data[pos + 4], len);
314       s[len] = 0;
315       pos += 4 + len;
316       return s;
317     }
318   else
319     {
320       fprintf(stderr, "%s: 0x%x: expected string\n", where, pos);
321       exit(1);
322     }
323 }
324 #define get_string4() get_string4(WHERE)
325
326 static char *
327 get_padded_string(int len)
328 {
329   char *s = xmemdup0(&data[pos], len);
330   pos += len;
331   return s;
332 }
333
334 static char *
335 get_string_be(const char *where)
336 {
337   if (1
338       /*data[pos + 1] == 0 && data[pos + 2] == 0 && data[pos + 3] == 0*/
339       /*&& all_ascii(&data[pos + 4], data[pos])*/)
340     {
341       int len = data[pos + 2] * 256 + data[pos + 3];
342       char *s = malloc(len + 1);
343
344       memcpy(s, &data[pos + 4], len);
345       s[len] = 0;
346       pos += 4 + len;
347       return s;
348     }
349   else
350     {
351       fprintf(stderr, "%s: 0x%x: expected string\n", where, pos);
352       exit(1);
353     }
354 }
355 #define get_string_be() get_string_be(WHERE)
356
357 static int
358 get_end(void)
359 {
360   int len = get_u32();
361   return pos + len;
362 }
363
364 static void __attribute__((unused))
365 hex_dump(FILE *stream, int ofs, int n)
366 {
367   int n_ascii = 0;
368   for (int i = 0; i < n; i++)
369     {
370       int c = data[ofs + i];
371       n_ascii += is_ascii(c);
372       fprintf(stream, " %02x", c);
373     }
374   if (n_ascii >= 3)
375     {
376       putc(' ', stream);
377       for (int i = 0; i < n; i++)
378         {
379           int c = data[ofs + i];
380           putc(c >= 32 && c < 127 ? c : '.', stream);
381         }
382     }
383   putc('\n', stream);
384 }
385
386 static void __attribute__((unused))
387 char_dump(FILE *stream, int ofs, int n)
388 {
389   for (int i = 0; i < n; i++)
390     {
391       int c = data[ofs + i];
392       putc(c >= 32 && c < 127 ? c : '.', stream);
393     }
394   putc('\n', stream);
395 }
396
397
398 static int
399 compare_int(const void *a_, const void *b_)
400 {
401   const int *a = a_;
402   const int *b = b_;
403   return *a < *b ? -1 : *a > *b;
404 }
405
406
407 static const char *
408 format_name (int format, char *buf)
409 {
410   switch (format)
411     {
412     case 1: return "A";
413     case 2: return "AHEX";
414     case 3: return "COMMA";
415     case 4: return "DOLLAR";
416     case 5: case 40: return "F";
417     case 6: return "IB";
418     case 7: return "PIBHEX";
419     case 8: return "P";
420     case 9: return "PIB";
421     case 10: return "PK";
422     case 11: return "RB";
423     case 12: return "RBHEX";
424     case 15: return "Z";
425     case 16: return "N";
426     case 17: return "E";
427     case 20: return "DATE";
428     case 21: return "TIME";
429     case 22: return "DATETIME";
430     case 23: return "ADATE";
431     case 24: return "JDATE";
432     case 25: return "DTIME";
433     case 26: return "WKDAY";
434     case 27: return "MONTH";
435     case 28: return "MOYR";
436     case 29: return "QYR";
437     case 30: return "WKYR";
438     case 31: return "PCT";
439     case 32: return "DOT";
440     case 33: return "CCA";
441     case 34: return "CCB";
442     case 35: return "CCC";
443     case 36: return "CCD";
444     case 37: return "CCE";
445     case 38: return "EDATE";
446     case 39: return "SDATE";
447     default: sprintf(buf, "(%d)", format); return buf;
448     }
449 }
450
451 static void
452 parse_format(void)
453 {
454   int d = data[pos++];
455   int w = data[pos++];
456   int fmt = data[pos++];
457   char buf[32];
458   printf ("%s%d.%d", format_name(fmt, buf), w, d);
459 }
460
461 static void
462 parse_heading(const char *name)
463 {
464   match_u16_assert(0xffff);
465   match_u16_assert(0);
466   match_string2_assert(name);
467 }
468
469 static void
470 match_zeros_assert(int count, const char *where)
471 {
472   for (int i = 0; i < count; i++)
473     if (data[pos + i])
474       {
475         fprintf (stderr,
476                  "%s: %#x: expected %d zeros here but offset %d is %#"PRIx8"\n",
477                  where, pos, count, i, data[pos + i]);
478         exit (1);
479       }
480   pos += count;
481 }
482 #define match_zeros_assert(count) match_zeros_assert(count, WHERE)
483
484 static void
485 put_safe(const char *s)
486 {
487   while (*s)
488     {
489       if (*s == '\n')
490         printf ("\\n");
491       else if (*s == '\r')
492         printf ("\\r");
493       else if (*s < 0x20 || *s > 0x7e)
494         printf ("\\x%02"PRIx8, (uint8_t) *s);
495       else
496         putchar (*s);
497       s++;
498     }
499 }
500
501 static void
502 parse_DspString(void)
503 {
504   if (match_byte(2))
505     {
506       printf("DspString(%f, \"", get_double());
507       printf("%s\")\n", get_string1());
508     }
509   else
510     {
511       match_byte_assert(1);
512       printf ("DspString(");
513       parse_format();
514       printf(" \"");
515       match_byte_assert(0);
516       match_byte_assert(1);
517       put_safe(get_string1());
518       printf("\")\n");
519     }
520 }
521
522 static void
523 match_DspString(void)
524 {                               /* 05 80 */
525   match_byte_assert(5);
526   match_byte_assert(0x80);
527   parse_DspString();
528 }
529
530 static void
531 match_DspSimpleText(void)
532 {                               /* 03 80 */
533   match_byte_assert(3);
534   match_byte_assert(0x80);
535   match_zeros_assert(5);
536   if (!match_byte(0x10))
537     match_byte_assert(0);
538   match_zeros_assert(4);
539 }
540
541 static void
542 match_NavTreeViewItem(void)
543 {                               /* 07 80 */
544   match_byte_assert(7);
545   match_byte_assert(0x80);
546   match_zeros_assert(1);
547   if (!match_byte(0) && !match_byte(7))
548     match_byte_assert(8);
549   match_zeros_assert(3);
550   pos++;
551   match_byte_assert(0);
552   match_byte_assert(1);
553   match_zeros_assert(3);
554   if (!match_byte(0))
555     match_byte_assert(1);
556   match_zeros_assert(5);
557   match_byte_assert(1);
558   match_zeros_assert(5);
559
560   put_safe(get_string1());
561   putc('\n', stdout);
562 }
563
564 static void
565 parse_DspNumber(void)
566 {
567   match_byte_assert(1);
568   printf("DspNumber(");
569   parse_format();
570   match_byte_assert(0x80);
571   match_byte(2);
572   printf (" %f", get_double());
573   printf (" \"%s\")\n", get_string1());
574 }
575
576 static void
577 match_DspNumber(void)
578 {
579   match_byte_assert(0x2a);
580   match_byte_assert(0x80);
581   parse_DspNumber();
582 }
583
584 static void parse_flexible(void);
585
586 static void
587 parse_DspCell(void)
588 {
589   match_byte_assert(0);
590   match_DspSimpleText();
591   parse_flexible();             /* DspString or DspNumber. */
592 }
593
594 static void
595 match_DspCell(void)
596 {                               /* 27 80 */
597   match_byte_assert(0x27);
598   match_byte_assert(0x80);
599   parse_DspCell();
600 }
601
602 static void
603 parse_PMModelItemInfo(void)
604 {                               /* 54 80 */
605   match_byte_assert(0);
606   pos += 1;                     /* Counter */
607   match_zeros_assert(7);
608   pos += 3;
609   if (!match_byte(0))
610     match_byte_assert(0xe);
611   match_byte_assert(0);
612 }
613
614 static void
615 match_PMModelItemInfo(void)
616 {                               /* 54 80 */
617   match_byte_assert(0x54);
618   match_byte_assert(0x80);
619   parse_PMModelItemInfo();
620   match_DspSimpleText();
621   match_DspString();
622 }
623
624 static void
625 match_PMPivotItemTree(void)
626 {                               /* 52 80 */
627   match_byte_assert(0x52);
628   match_byte_assert(0x80);
629   match_byte_assert(0);
630   match_PMModelItemInfo();
631 }
632
633 static void
634 parse_flexible(void)
635 {
636   if (data[pos] == 0xff && data[pos + 1] == 0xff)
637     {
638       match_u16_assert(0xffff);
639       match_u16_assert(0);
640       char *heading = get_string2();
641       if (!strcmp(heading, "DspCell"))
642         parse_DspCell();
643       else if (!strcmp(heading, "DspNumber"))
644         parse_DspNumber();
645       else if (!strcmp(heading, "DspString"))
646         parse_DspString();
647       else
648         assert(0);
649     }
650   else if (data[pos] == 0x2a && data[pos + 1] == 0x80)
651     match_DspNumber();
652   else if (data[pos] == 0x27 && data[pos + 1] == 0x80)
653     match_DspCell();
654   else if (data[pos] == 0x5 && data[pos + 1] == 0x80)
655     match_DspString();
656   else if ((data[pos] == 0x3c || data[pos] == 0x39)
657             && data[pos + 1] == 0x80)
658     {
659       /* 3c 80 */
660       /* 39 80 */
661       pos += 2;
662       parse_format();
663 /*      match_byte_assert(0x01);
664       match_byte_assert(0x02);
665       match_byte_assert(0x0d); */
666     }
667   else if (data[pos] == 0x15 && data[pos + 1] == 0x80)
668     {
669       /* 15 80 */
670       data += 2;
671       match_byte_assert(2);
672       printf ("15 80(%f", get_double());
673       printf (" %s)\n", get_string1());
674     }
675   else
676     {
677       fprintf (stderr, "bad data cell 0x%02x at offset %x\n",
678                data[pos], pos);
679       hex_dump (stderr, pos, 64);
680       assert(0);
681     }
682 }
683
684 int
685 main(int argc, char *argv[])
686 {
687   bool print_offsets = false;
688   for (;;)
689     {
690       int c = getopt (argc, argv, "o");
691       if (c == -1)
692         break;
693
694       switch (c)
695         {
696         case 'o':
697           print_offsets = true;
698           break;
699
700         case '?':
701           exit (-1);
702         }
703     }
704   if (argc - optind != 1)
705     {
706       fprintf (stderr, "usage: %s FILE.bin", argv[0]);
707       exit (1);
708     }
709
710   const char *filename = argv[optind];
711   int fd = open(filename, O_RDONLY);
712   if (fd < 0)
713     {
714       fprintf (stderr, "%s: open failed (%s)", filename, strerror (errno));
715       exit (1);
716     }
717
718   struct stat s;
719   if (fstat(fd, &s))
720     {
721       perror("fstat");
722       exit(1);
723     }
724   n = s.st_size;
725   data = malloc(n);
726   if (!data)
727     {
728       perror("malloc");
729       exit(1);
730     }
731   if (read(fd, data, n) != n)
732     {
733       perror("read");
734       exit(1);
735     }
736   close(fd);
737
738   setvbuf (stdout, NULL, _IOLBF, 0);
739
740   match_byte_assert(4);
741   match_u32_assert(0);
742   match_string1_assert("SPSS Output Document");
743   match_u32_assert(1);
744   match_byte_assert(0x63);
745
746   parse_heading("NavRoot");
747   match_byte_assert(2);
748   match_zeros_assert(32);
749
750   parse_heading("DspSimpleText");
751   match_zeros_assert(10);
752
753   parse_heading("DspString");
754   parse_DspString();
755
756   parse_heading("NavTreeViewItem");
757   match_byte_assert(0);
758   match_u32_assert(0);
759   match_byte_assert(2);
760   match_byte_assert(0);
761   match_byte_assert(1);
762   match_zeros_assert(9);
763   match_u32_assert(1);
764   assert (pos == 0xb0);
765
766   pos += 0x28;
767   match_zeros_assert(5);
768   if (match_u32(8500))
769     match_u32_assert(11000);
770   else
771     {
772       match_u32_assert(11000);
773       match_u32_assert(8500);
774     }
775   pos = 0x105;
776   match_string1_assert("(Continued)");
777   match_byte_assert(1);
778   match_byte_assert(1);
779   match_zeros_assert(3);
780   get_string4();                /* page title */
781   match_byte_assert(1);
782   match_byte_assert(1);
783   match_zeros_assert(3);
784   get_string4();                /* page number */
785   match_byte_assert(0);
786   pos += 2;
787   match_u16_assert(2);
788
789   parse_heading("NavLog");
790   pos = 0x36b;
791   puts(get_padded_string(32));
792   if (!match_u32(80))
793     match_u32_assert(132);
794   match_zeros_assert(8);
795   match_u32_assert(1);
796   get_string4();
797   match_byte_assert(0);
798
799   parse_heading("NavHead");
800   match_byte_assert(2);
801   match_zeros_assert(24);
802   match_u32_assert(1);
803   match_u32_assert(0);
804   match_DspSimpleText();
805   match_DspString();
806   match_NavTreeViewItem();
807   match_zeros_assert(3);
808
809   parse_heading("NavTitle");
810   pos += 33;
811   match_DspSimpleText();
812   match_DspString();
813   match_NavTreeViewItem();
814
815   match_byte_assert(1);
816   match_byte_assert(1);
817   match_u32_assert(-19);
818   match_zeros_assert(12);
819   match_byte_assert(0xbc);
820   match_byte_assert(2);
821   match_zeros_assert(9);
822   match_byte_assert(0x22);
823   puts(get_padded_string(32));
824   match_u32_assert(80);
825   match_zeros_assert(8);
826   match_u32_assert(1);
827   get_string4();
828   match_byte_assert(0);
829
830   parse_heading("NavNote");
831   match_byte_assert(2);
832   match_zeros_assert(8);
833   match_u32_assert(24);
834   if (!match_u32(0))
835     match_u32_assert(-40);
836   pos += 8;
837   match_u32_assert(2);
838   match_u32_assert(1);
839   match_DspSimpleText();
840   match_DspString();
841   match_NavTreeViewItem();
842   match_byte_assert(1);
843
844   parse_heading("PTPivotController");
845   match_byte_assert(2);
846   pos += 8;
847   match_u32_assert(100);
848   match_u32_assert(100);
849   match_u32_assert(100);
850   match_u32_assert(100);
851
852   parse_heading("PVPivotView");
853   match_u32_assert(5);
854   match_byte_assert(0);
855
856   parse_heading("PMPivotModel");
857   match_byte_assert(3);
858
859   parse_heading("NDimensional__DspCell");
860   match_byte_assert(0);
861   match_u32_assert(1);
862
863   parse_heading("IndexedCollection");
864   match_byte_assert(0);
865   pos++;
866   match_zeros_assert(3);
867   match_byte_assert(1);
868   match_byte_assert(0);
869
870   while (data[pos] != 1)
871     {
872       if (data[pos] == 0)
873         pos++;
874       else
875         parse_flexible();
876     }
877
878   match_byte_assert(1);
879   match_byte_assert(0);
880   puts(get_string1());
881   if (!match_u32(0))
882     match_u32_assert(2);
883   puts(get_string1());
884
885   match_byte_assert(0);
886   match_byte_assert(1);
887   match_byte_assert(0);
888   match_byte_assert(0);
889   match_byte_assert(0);
890   match_byte_assert(1);
891   match_byte_assert(0);
892
893   exit (0);
894
895   parse_heading("PMPivotItemTree");
896   match_byte_assert(0);
897
898   parse_heading("AbstractTreeBranch");
899   match_byte_assert(0);
900
901   parse_heading("PMModelItemInfo");
902   parse_PMModelItemInfo();
903   match_DspSimpleText();
904   match_DspString();
905
906   match_u32_assert(7);
907   match_PMPivotItemTree();
908
909   match_u32_assert(0);
910   match_PMPivotItemTree();
911
912   match_u32_assert(0);
913   match_PMPivotItemTree();
914
915   match_u32_assert(6);
916   match_PMPivotItemTree();
917
918   match_u32_assert(0);
919   match_PMPivotItemTree();
920
921   match_u32_assert(0);
922   match_PMPivotItemTree();
923
924   match_u32_assert(0);
925   match_PMPivotItemTree();
926
927   match_u32_assert(0);
928   match_PMPivotItemTree();
929
930   match_u32_assert(0);
931   match_PMPivotItemTree();
932
933   match_u32_assert(0);
934   match_PMPivotItemTree();
935
936   match_u32_assert(2);
937   match_PMPivotItemTree();
938
939   match_u32_assert(0);
940   match_PMPivotItemTree();
941
942   match_u32_assert(0);
943   match_PMPivotItemTree();
944
945   match_u32_assert(0);
946   match_PMPivotItemTree();
947
948   match_u32_assert(0);
949   match_PMPivotItemTree();
950
951   match_u32_assert(2);
952   match_PMPivotItemTree();
953
954   match_u32_assert(0);
955   match_PMPivotItemTree();
956
957   match_u32_assert(0);
958
959   /* ...unknown... */
960
961   while (data[pos] != 0xff || data[pos + 1] != 0xff)
962     pos++;
963   parse_heading("PVViewDimension");
964
965   int i;
966   for (i = 0; data[pos + i] != 0xff || data[pos + i + 1] != 0xff; i++)
967     ;
968   hex_dump(stdout, pos, i);
969
970   printf ("%#x: end of successful parse\n", pos);
971
972   return 0;
973 }