tdump*
ndump*
pspp.jnl
-
+dump2
CFLAGS = -std=gnu99 -Wall -Werror -g -D_GNU_SOURCE=1
+all: dump dump2
dump: dump.o
+dump2: dump2.o
match_byte (0);
if (match_byte (3))
{
- get_string();
+ char *s1 = get_string();
if (match_byte (0x31))
{
if (match_u32 (1))
}
else
match_byte_assert (0x58);
- get_string();
- printf("string \"%s\"", get_string());
+ char *s2 = get_string();
+ char *s3 = get_string();
+ if (strcmp(s1, s3))
+ printf("strings \"%s\", \"%s\" and \"%s\"", s1, s2, s3);
+ else
+ printf("string \"%s\" and \"%s\"", s1, s2);
match_byte (0);
match_byte (0);
match_byte (0);
dump_title(void)
{
pos = 0x27;
- dump_title_value(0); putchar('\n'); putchar('\n');
- dump_title_value(0); putchar('\n'); putchar('\n');
+ dump_title_value(0); putchar('\n');
+ dump_title_value(0); putchar('\n');
match_byte_assert(0x31);
- dump_title_value(0); putchar('\n'); putchar('\n');
+ dump_title_value(0); putchar('\n');
match_byte(0);
match_byte_assert(0x58);
if (match_byte(0x31))
--- /dev/null
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+static uint8_t *data;
+static size_t n;
+
+int
+main(int argc, char **argv)
+{
+ size_t start;
+ struct stat s;
+
+ if (isatty(STDIN_FILENO))
+ {
+ fprintf(stderr, "redirect stdin from a .bin file\n");
+ exit(1);
+ }
+ if (fstat(STDIN_FILENO, &s))
+ {
+ perror("fstat");
+ exit(1);
+ }
+ n = s.st_size;
+ data = malloc(n);
+ if (!data)
+ {
+ perror("malloc");
+ exit(1);
+ }
+ if (read(STDIN_FILENO, data, n) != n)
+ {
+ perror("read");
+ exit(1);
+ }
+
+ if (argc < 3)
+ {
+ fprintf(stderr, "bad arguments");
+ exit(1);
+ }
+
+ start = strtol(argv[1], NULL, 0);
+ int end = strtol(argv[2], NULL, 0);
+ for (int pos = start; pos < end; pos += 8)
+ {
+ double d;
+ memcpy(&d, &data[pos], sizeof d);
+ printf("%g\n", d);
+ }
+ return 0;
+}
--- /dev/null
+0000: magic number 00 b0 01 00
+0004: file size in bytes
+0008: number of data cells, <N>
+000c: ?
+0010: 58 00 00 00
+0014: "tableData"
+0050: 00 00 00 00 00
+0055: three random-ish bytes that sometimes resemble ASCII and might just be garbage
+0058: "cell" (note pointer header from 0x10)
+0178: First bytes of data; <N> doubles
+
+
+
+./web/0e2ecc3c2b47dbd86a1bdceb89b8a4d4/00000000085_-4179390934077669371_tableData.bin:
+
+80 cells
+80 cell formats
+80 dimension0categories
+80 dimension0labels
+80 dimension1categories
+80 dimension1labels
+80 dimension2categories
+80 dimension2labels
+80 dimension3categories
+80 dimension3labels
+80 footnotes
+i1 tableData
+
+
+
+
+
+./web/0e2ecc3c2b47dbd86a1bdceb89b8a4d4/00000000013_-4179390934085009405_tableData.bin:
+
+8 cells
+4 formats
+8 dimension0categories
+8 dimension0group0
+8 dimension0group0Label
+8 dimension0labels
+8 dimension1categories
+8 dimension1labels
+i1 tabledata
+i8 cell
+i0 cellFormat
+i0 dimension0categories
+i0 dimension0group0
+i0 dimension0group0Label
+
+
+
+0000: 00 b0 01 00 56 0d
+0010: "X"
+0014: "tableData"
+0055: 14"cell
+0170: 0 1231 1232 1 0 0 0 1 2
+01b8: "cellFormat"
+02d8: 5(40.0) * 8
+0318: "dimension0categories"
+0448: 1 1 2 2 3 3
+0478: "dimension0group0"
+0598: 2 2 2 2 3 3 3 3 3
+05d8: "dimension0group0label"
+06f8: sysmis * 8
+0738: "dimension0labels"
+0858: sysmis * 8
+0898: "dimension1categories"
+09c0: 1 0 1 0 1 0 1
+09f8: "dimension1labels"
+0b18: sysmis * 8
+0b58: i1 i9 "tableData" i8 i4 "cell" i0 i10 "cellFormat" i0 i20 "dimension0categories" i0 i16 "dimension0group0"
+ i0 i21 "dimension0group0Label" i8 i0 i6 i1 i6 i2 i6 i3 i6 i4 i7 i5 i7 i6 i7 i7 i7 i16 "dimension0labels" i8 i0 i0 i1
+ i0 i2 i3 i3 i3 i4 i4 i5 i4 i6 i5 i7 i5 i20 "dimension1categories" i0 i16 "dimension1labels" i8 i0 i1
+ i1 i2 i2 i1 i3 i2 i4 i1 i5 i2 i6 i1 i7 i2 i8 i2 i5 "Valid" i4 i6 "Gender" i4 i9 "Education" i2 i7 "Missing" i2 i7
+ "Minimum" i2 i7 "Maximum" i4 i1 "N" i4 i0