Mercurial > otakunoraifu
diff scn2k/gandump.cc @ 52:15a18fbe6f21
* Known bugs added to the README
* Code cleaning (0 -> NULL when needed, indentation, spaces, ...)
author | thib |
---|---|
date | Sat, 18 Apr 2009 18:35:39 +0000 |
parents | 6d1a5b7f0838 |
children |
line wrap: on
line diff
--- a/scn2k/gandump.cc +++ b/scn2k/gandump.cc @@ -25,37 +25,43 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include<stdio.h> -#include<string.h> +#include <stdio.h> +#include <string.h> char* ganname[6] = {"ptn", "x", "y", "time", "alpha", "?"}; int main(int argc, char** argv) { - if (argc != 2) return 0; + if (argc != 2) return NULL; FILE* f = fopen(argv[1],"rb"); - if (f==0) return 0; - fseek(f,0,2); int sz=ftell(f); fseek(f,0,0); + if (f == NULL) return NULL; + fseek(f, 0, 2); + int sz = ftell(f); + fseek(f, 0, SEEK_SET); char* buf = new char[sz]; char* bufo = buf; - fread(buf,1,sz,f); + fread(buf, 1, sz, f); fclose(f); int i; for (i=0; i<16; i++) { printf("%02x ",int(buf[i])&0xff); } + printf("\n"); - buf+=16; + buf += 16; printf("file '%s'\n",buf); buf += strlen(buf)+1; - printf("N1 = %3d\n", *(int*)buf); buf+=4; - int ptns = *(int*)buf; buf += 4; + printf("N1 = %3d\n", *(int*)buf); + buf += 4; + int ptns = *(int*)buf; + buf += 4; for (i=0; i<ptns; i++) { int j; - printf("\tN2 = %3d\n",*(int*)buf); buf += 4; + printf("\tN2 = %3d\n",*(int*)buf); + buf += 4; int n = *(int*)buf; buf += 4; - for (j=0; j<n; j++) { + for (j=0; j < n; j++) { printf("\t%3d: ",j); - int k; int d1,d2; + int k, d1, d2; for (k=0; k<6; k++) { d1 = *(int*)(buf+k*8); d2 = *(int*)(buf+k*8+4);