Extract tableid.
[pspp] / dump.c
diff --git a/dump.c b/dump.c
index 6cc9e52abe4e5a9767b5d008841ba462a14893cc..1b7a8ed8e78c5ddd68affbf69ccc3ede8b55e8fa 100644 (file)
--- a/dump.c
+++ b/dump.c
@@ -63,6 +63,15 @@ get_u32(void)
   return x;
 }
 
+static unsigned long long int
+get_u64(void)
+{
+  uint64_t x;
+  memcpy(&x, &data[pos], 8);
+  pos += 8;
+  return x;
+}
+
 static unsigned int
 get_be32(void)
 {
@@ -1031,19 +1040,7 @@ dump_fonts(void)
   match_byte_assert(0);
   if (!match_byte(0))
     match_byte_assert(1);
-  if (version > 1)
-    {
-      if (!match_byte(0x97) && !match_byte(0x98)
-          && !match_byte(0x99) && !match_byte(0x9a) && !match_byte(0x9b))
-        match_byte_assert(0x9c);
-      match_byte_assert(7);
-      match_byte_assert(0);
-      match_byte_assert(0);
-    }
-  else
-    {
-      printf("%x\n", get_u32());
-    }
+  printf("<epoch>%d</epoch>\n", get_u32());
 
   int decimal = data[pos];
   int grouping = data[pos + 1];
@@ -1105,12 +1102,7 @@ dump_fonts(void)
       if (!match_byte(0))
         match_byte_assert(1);
 
-      if (!match_byte(0x97) && !match_byte(0x98)
-          && !match_byte(0x99) && !match_byte(0x9a) && !match_byte(0x9b))
-        match_byte_assert(0x9c);
-      match_byte_assert(7);
-      match_byte_assert(0);
-      match_byte_assert(0);
+      printf("<epoch2>%d</epoch2>\n", get_u32());
 
       if (match_byte('.'))
         {
@@ -1307,14 +1299,8 @@ main(int argc, char *argv[])
       pos++;
       pos++;
 
-      /* Offset 31.
-
-         This is the tableId, e.g. -4154297861994971133 would be 0xdca00003.
-         We don't have enough context to validate it. */
-      pos += 4;
-
-      /* Offset 35. */
-      pos += 4;
+      /* Offset 31. */
+      printf("<tableid>%lld</tableid>", get_u64());
 
       dump_title ();
       dump_fonts();