X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=dump-spo2.c;h=a76aff97621ba9a17efa4d7299a662a4eeee1ad7;hb=044a792171add4cdec5f5ee1e2d4d47059665232;hp=d50d861fa428260e4d99bdde812da3517da056c7;hpb=6fbf3ec9ce0176ef805a18086b4cfe66df9cfbba;p=pspp diff --git a/dump-spo2.c b/dump-spo2.c index d50d861fa4..a76aff9762 100644 --- a/dump-spo2.c +++ b/dump-spo2.c @@ -296,7 +296,7 @@ match_string2_assert(const char *exp, const char *where) #define match_string2_assert(x) match_string2_assert(x, WHERE) static char * -get_string(const char *where) +get_string4(const char *where) { if (1 /*data[pos + 1] == 0 && data[pos + 2] == 0 && data[pos + 3] == 0*/ @@ -316,7 +316,15 @@ get_string(const char *where) exit(1); } } -#define get_string() get_string(WHERE) +#define get_string4() get_string4(WHERE) + +static char * +get_padded_string(int len) +{ + char *s = xmemdup0(&data[pos], len); + pos += len; + return s; +} static char * get_string_be(const char *where) @@ -435,6 +443,16 @@ format_name (int format, char *buf) } } +static void +parse_format(void) +{ + int d = data[pos++]; + int w = data[pos++]; + int fmt = data[pos++]; + char buf[32]; + printf ("%s%d.%d", format_name(fmt, buf), w, d); +} + static void parse_heading(const char *name) { @@ -444,18 +462,19 @@ parse_heading(const char *name) } static void -match_zeros_assert(int count) +match_zeros_assert(int count, const char *where) { for (int i = 0; i < count; i++) if (data[pos + i]) { fprintf (stderr, - "%#x: expected %d zeros here but offset %d is %#"PRIx8"\n", - pos, count, i, data[pos + i]); + "%s: %#x: expected %d zeros here but offset %d is %#"PRIx8"\n", + where, pos, count, i, data[pos + i]); exit (1); } pos += count; } +#define match_zeros_assert(count) match_zeros_assert(count, WHERE) static void parse_DspString(void) @@ -470,6 +489,43 @@ parse_DspString(void) printf ("DspString(\"%s\")\n", get_string1()); } +static void +match_DspString(void) +{ /* 05 80 */ + match_byte_assert(5); + match_byte_assert(0x80); + parse_DspString(); +} + +static void +match_DspSimpleText(void) +{ /* 03 80 */ + match_byte_assert(3); + match_byte_assert(0x80); + match_zeros_assert(10); +} + +static void +match_NavTreeViewItem(void) +{ /* 07 80 */ + match_byte_assert(7); + match_byte_assert(0x80); + match_zeros_assert(1); + if (!match_byte(0) && !match_byte(7)) + match_byte_assert(8); + match_zeros_assert(3); + pos++; + match_byte_assert(0); + match_byte_assert(1); + match_zeros_assert(3); + if (!match_byte(0)) + match_byte_assert(1); + match_zeros_assert(5); + match_byte_assert(1); + match_zeros_assert(5); + puts(get_string1()); +} + int main(int argc, char *argv[]) { @@ -543,7 +599,130 @@ main(int argc, char *argv[]) parse_DspString(); parse_heading("NavTreeViewItem"); - + match_byte_assert(0); + match_u32_assert(0); + match_byte_assert(2); + match_byte_assert(0); + match_byte_assert(1); + match_zeros_assert(9); + match_u32_assert(1); + assert (pos == 0xb0); + + pos += 0x28; + match_zeros_assert(5); + if (match_u32(8500)) + match_u32_assert(11000); + else + { + match_u32_assert(11000); + match_u32_assert(8500); + } + pos = 0x105; + match_string1_assert("(Continued)"); + match_byte_assert(1); + match_byte_assert(1); + match_zeros_assert(3); + get_string4(); /* page title */ + match_byte_assert(1); + match_byte_assert(1); + match_zeros_assert(3); + get_string4(); /* page number */ + match_byte_assert(0); + pos += 2; + match_u16_assert(2); + + parse_heading("NavLog"); + pos = 0x36b; + puts(get_padded_string(32)); + if (!match_u32(80)) + match_u32_assert(132); + match_zeros_assert(8); + match_u32_assert(1); + get_string4(); + match_byte_assert(0); + + parse_heading("NavHead"); + match_byte_assert(2); + match_zeros_assert(24); + match_u32_assert(1); + match_u32_assert(0); + match_DspSimpleText(); + match_DspString(); + match_NavTreeViewItem(); + match_zeros_assert(3); + + parse_heading("NavTitle"); + pos += 33; + match_DspSimpleText(); + match_DspString(); + match_NavTreeViewItem(); + + match_byte_assert(1); + match_byte_assert(1); + match_u32_assert(-19); + match_zeros_assert(12); + match_byte_assert(0xbc); + match_byte_assert(2); + match_zeros_assert(9); + match_byte_assert(0x22); + puts(get_padded_string(32)); + match_u32_assert(80); + match_zeros_assert(8); + match_u32_assert(1); + get_string4(); + match_byte_assert(0); + + parse_heading("NavNote"); + match_byte_assert(2); + match_zeros_assert(8); + match_u32_assert(24); + if (!match_u32(0)) + match_u32_assert(-40); + pos += 8; + match_u32_assert(2); + match_u32_assert(1); + match_DspSimpleText(); + match_DspString(); + match_NavTreeViewItem(); + match_byte_assert(1); + + parse_heading("PTPivotController"); + match_byte_assert(2); + pos += 8; + match_u32_assert(100); + match_u32_assert(100); + match_u32_assert(100); + match_u32_assert(100); + + parse_heading("PVPivotView"); + match_u32_assert(5); + match_byte_assert(0); + + parse_heading("PMPivotModel"); + match_byte_assert(3); + + parse_heading("NDimensional__DspCell"); + match_byte_assert(0); + match_u32_assert(1); + + parse_heading("IndexedCollection"); + match_byte_assert(0); + pos++; + match_zeros_assert(3); + match_byte_assert(1); + match_byte_assert(0); + + parse_heading("DspCell"); + match_byte_assert(0); + match_DspSimpleText(); + + parse_heading("DspNumber"); + match_byte_assert(1); + parse_format(); + match_byte_assert(0x80); + match_byte(2); + printf (" %f", get_double()); + printf (" \"%s\"\n", get_string1()); printf ("%#x: end of successful parse\n", pos);