comparison scn2k/gandump.cc @ 0:223b71206888

Initial import
author thib
date Fri, 01 Aug 2008 16:32:45 +0000
parents
children 6d1a5b7f0838
comparison
equal deleted inserted replaced
-1:000000000000 0:223b71206888
1 #include<stdio.h>
2 #include<string.h>
3
4 char* ganname[6] = {"ptn", "x", "y", "time", "alpha", "?"};
5 int main(int argc, char** argv) {
6 if (argc != 2) return 0;
7 FILE* f = fopen(argv[1],"rb");
8 if (f==0) return 0;
9 fseek(f,0,2); int sz=ftell(f); fseek(f,0,0);
10 char* buf = new char[sz];
11 char* bufo = buf;
12 fread(buf,1,sz,f);
13 fclose(f);
14
15 int i;
16 for (i=0; i<16; i++) {
17 printf("%02x ",int(buf[i])&0xff);
18 }
19 printf("\n");
20 buf+=16;
21 printf("file '%s'\n",buf);
22 buf += strlen(buf)+1;
23 printf("N1 = %3d\n", *(int*)buf); buf+=4;
24 int ptns = *(int*)buf; buf += 4;
25 for (i=0; i<ptns; i++) {
26 int j;
27 printf("\tN2 = %3d\n",*(int*)buf); buf += 4;
28 int n = *(int*)buf; buf += 4;
29 for (j=0; j<n; j++) {
30 printf("\t%3d: ",j);
31 int k; int d1,d2;
32 for (k=0; k<6; k++) {
33 d1 = *(int*)(buf+k*8);
34 d2 = *(int*)(buf+k*8+4);
35 if (d1 != 30100+k) printf("err: d1 %d\n",d1);
36 printf("%s: %5d, ",ganname[k],d2);
37 }
38 printf("\n");
39 buf += 6*8;
40 int d = *(int*)buf; buf += 4;
41 if (d != 999999) printf("err: dd %d\n",d);
42 }
43 }
44 if (buf != bufo+sz) { printf("orig sz %d read %d\n",sz,buf-bufo);}
45 }