From ac58a458c37149be22c906539872014766682b27 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 24 Jun 2020 05:58:55 +0000 Subject: [PATCH] now reads past cells and dimensions! --- dump-spo2.c | 202 +++++++++++++++++++++++++++++++++++++++++++++++++--- spo-notes | 37 ++++++---- 2 files changed, 217 insertions(+), 22 deletions(-) diff --git a/dump-spo2.c b/dump-spo2.c index a76aff9762..da9e731917 100644 --- a/dump-spo2.c +++ b/dump-spo2.c @@ -476,6 +476,23 @@ match_zeros_assert(int count, const char *where) } #define match_zeros_assert(count) match_zeros_assert(count, WHERE) +static void +put_safe(const char *s) +{ + while (*s) + { + if (*s == '\n') + printf ("\\n"); + else if (*s == '\r') + printf ("\\r"); + else if (*s < 0x20 || *s > 0x7e) + printf ("\\x%02"PRIx8, (uint8_t) *s); + else + putchar (*s); + s++; + } +} + static void parse_DspString(void) { @@ -486,7 +503,9 @@ parse_DspString(void) match_byte_assert(5); match_byte_assert(0); match_byte_assert(1); - printf ("DspString(\"%s\")\n", get_string1()); + printf ("DspString(\""); + put_safe(get_string1()); + printf("\")\n"); } static void @@ -502,7 +521,10 @@ match_DspSimpleText(void) { /* 03 80 */ match_byte_assert(3); match_byte_assert(0x80); - match_zeros_assert(10); + match_zeros_assert(5); + if (!match_byte(0x10)) + match_byte_assert(0); + match_zeros_assert(4); } static void @@ -523,7 +545,74 @@ match_NavTreeViewItem(void) match_zeros_assert(5); match_byte_assert(1); match_zeros_assert(5); - puts(get_string1()); + + put_safe(get_string1()); + putc('\n', stdout); +} + +static void +parse_DspNumber(void) +{ + match_byte_assert(1); + parse_format(); + match_byte_assert(0x80); + match_byte(2); + printf (" %f", get_double()); + printf (" \"%s\"\n", get_string1()); +} + +static void +match_DspNumber(void) +{ + match_byte_assert(0x2a); + match_byte_assert(0x80); + parse_DspNumber(); +} + +static void +match_DspCell(void) +{ /* 27 80 */ + match_byte_assert(0x27); + match_byte_assert(0x80); + match_byte_assert(0); + match_DspSimpleText(); + if (data[pos] == 5) + match_DspString(); + else if (data[pos] == 0x2a) + match_DspNumber(); + else + assert(0); +} + +static void +parse_PMModelItemInfo(void) +{ /* 54 80 */ + match_byte_assert(0); + pos += 1; /* Counter */ + match_zeros_assert(7); + pos += 3; + if (!match_byte(0)) + match_byte_assert(0xe); + match_byte_assert(0); +} + +static void +match_PMModelItemInfo(void) +{ /* 54 80 */ + match_byte_assert(0x54); + match_byte_assert(0x80); + parse_PMModelItemInfo(); + match_DspSimpleText(); + match_DspString(); +} + +static void +match_PMPivotItemTree(void) +{ /* 52 80 */ + match_byte_assert(0x52); + match_byte_assert(0x80); + match_byte_assert(0); + match_PMModelItemInfo(); } int @@ -717,12 +806,109 @@ main(int argc, char *argv[]) match_DspSimpleText(); parse_heading("DspNumber"); + parse_DspNumber(); + + match_DspCell(); + match_DspCell(); + match_DspCell(); + match_DspCell(); + match_DspCell(); + match_DspCell(); + match_DspCell(); + while (data[pos] == 0) + pos++; + + match_DspCell(); + match_DspCell(); + while (data[pos] == 0) + pos++; + match_DspCell(); + match_DspCell(); + match_DspCell(); + match_byte_assert(1); - parse_format(); - match_byte_assert(0x80); - match_byte(2); - printf (" %f", get_double()); - printf (" \"%s\"\n", get_string1()); + match_byte_assert(0); + puts(get_string1()); + match_u32_assert(0); + puts(get_string1()); + + match_byte_assert(0); + match_byte_assert(1); + match_byte_assert(0); + match_byte_assert(0); + match_byte_assert(0); + match_byte_assert(1); + match_byte_assert(0); + + parse_heading("PMPivotItemTree"); + match_byte_assert(0); + + parse_heading("AbstractTreeBranch"); + match_byte_assert(0); + + parse_heading("PMModelItemInfo"); + parse_PMModelItemInfo(); + match_DspSimpleText(); + match_DspString(); + + match_u32_assert(7); + match_PMPivotItemTree(); + + match_u32_assert(0); + match_PMPivotItemTree(); + + match_u32_assert(0); + match_PMPivotItemTree(); + + match_u32_assert(6); + match_PMPivotItemTree(); + + match_u32_assert(0); + match_PMPivotItemTree(); + + match_u32_assert(0); + match_PMPivotItemTree(); + + match_u32_assert(0); + match_PMPivotItemTree(); + + match_u32_assert(0); + match_PMPivotItemTree(); + + match_u32_assert(0); + match_PMPivotItemTree(); + + match_u32_assert(0); + match_PMPivotItemTree(); + + match_u32_assert(2); + match_PMPivotItemTree(); + + match_u32_assert(0); + match_PMPivotItemTree(); + + match_u32_assert(0); + match_PMPivotItemTree(); + + match_u32_assert(0); + match_PMPivotItemTree(); + + match_u32_assert(0); + match_PMPivotItemTree(); + + match_u32_assert(2); + match_PMPivotItemTree(); + + match_u32_assert(0); + match_PMPivotItemTree(); + + match_u32_assert(0); + + /* ...unknown... */ + + while (data[pos] != 0xff || data[pos + 1] != 0xff) + pos++; + parse_heading("PVViewDimension"); printf ("%#x: end of successful parse\n", pos); diff --git a/spo-notes b/spo-notes index 869eb14175..b70a71d4b3 100644 --- a/spo-notes +++ b/spo-notes @@ -806,8 +806,9 @@ Fork: cell contains number ("as-number"): 00c5 80 02 00c7 double # seconds since 1582... 00cf b"16-APR-2007 15:20:00" # or whatever -00e4 27 80 00 03 80 00 00 00 00 00 00 00 00 00 00 -00f3 05 80 01 02 28 05 00 01 01 20 +00e4 27 80 00 + 03 80 00*10 +00f3 05 80 01 02 28 05 00 01 b" " # Some files have extra 00 00 here # but we're only considering as-number-nozeros 00fd 27 80 00 @@ -818,13 +819,13 @@ Fork: cell contains number ("as-number"): as-number-nozeros, after filename: 0000 27 80 00 -0003 03 80 00*10 05 -0010 80 01 02 28 05 00 01 b" or DataSet1 or whatever" +0003 03 80 00*10 +000a 05 80 01 02 28 05 00 01 b" or DataSet1 or whatever" as-number-nozeros, after dataset name: 0000 27 80 00 -0003 03 80 00*10 05 -0010 80 01 02 28 05 00 01 b"" +0003 03 80 00*10 +000a 05 80 01 02 28 05 00 01 b"" # Some files have extra 00*8 here, we skip it: 0000 27 80 00 @@ -861,22 +862,27 @@ processor-time, after previous string: 0007 ffff 0000 "PMPivotItemTree" 00 001d ffff 0000 "AbstractTreeBranch" 00 0036 ffff 0000 "PMModelItemInfo" - 00*9 byte*3 0e 00 03 80 00*10 + 00*9 byte*3 0e 00 + 03 80 00*10 0065 05 80 01 02 28 05 00 01 b"Contents" i7 52 80 00 - 54 80 00 00*9 07 00 74 0e 00 03 80 00*10 + 54 80 00*9 07 00 74 0e 00 + 03 80 00*10 0099 05 80 01 02 28 05 00 01 b"Output Created" i0 52 80 00 - 54 80 00 01 00*7 08 00 74 0e 00 03 80 00*10 + 54 80 00 01 00*7 08 00 74 0e 00 + 03 80 00*10 00d3 05 80 01 02 28 05 00 01 b"Comments" i0 00e8 52 80 00 - 54 80 00*9 09 00 74 0e 00 03 80 00*10 + 54 80 00*9 09 00 74 0e 00 + 03 80 00*10 05 80 01 02 28 05 00 01 b"Input" i6 52 80 00 54 80 00 02 00*7 0a 00 74 0e 00 03 80 00*10 0138 05 80 01 02 28 05 00 01 b"Data" i0 52 80 00 - 54 80 00 03 00*12 03 80 00*10 + 54 80 00 03 00*12 + 03 80 00*10 05 80 01 02 28 05 00 01 b"Active Dataset" i0 0183 52 80 00 54 80 00 04 00*7 0e 00 74 0e 00 03 80 00*9 @@ -920,8 +926,9 @@ processor-time, after previous string: 03f6 00 00 00 00 52 80 00 54 80 00 0400 0d 00 00 00 00 00 00 00 00 00 00 00 00 03 80 00 0410 00 00 00 00 00 00 00 00 00 05 80 01 02 28 05 00 -0420 01 b"Processor Time" -0430 00 00 00 00 00 00 00 00 00 00 0e 00 00 00 01 00 +0420 01 b"Processor Time" i0 + +0434 00 00 00 00 00 00 0e 00 00 00 01 00 0440 58 00 5c 00 64 00 68 00 6c 00 70 00 74 00 78 00 0450 80 00 84 00 88 00 8c 00 94 00 98 00 00 0e 00 00 0460 00 00 00 00 00 00 00 01 00 00 00 02 00 00 00 03 @@ -932,7 +939,9 @@ processor-time, after previous string: 04b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04c0 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 04d0 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 -04e0 00 01 00 ff ff 00 00 b"PVViewDimension" +04e0 00 01 00 + +04e3 ffff 0000 b"PVViewDimension" 04f8 00 51 00 00 00 00 00 00 0500 00 00 00 00 0e 00 00 00 00 00 69 00 00 00 54 00 0510 00 00 4b 00 00 00 63 00 00 00 4b 00 00 00 4b 00 -- 2.30.2