Mercurial > libpst
comparison src/dumpblocks.c @ 46:b2a7f2e0926a
more fixes for 64 bit format
author | carl |
---|---|
date | Sat, 12 Jan 2008 15:20:53 -0800 |
parents | c508ee15dfca |
children | f66078abed38 |
comparison
equal
deleted
inserted
replaced
45:b961bcdadd0e | 46:b2a7f2e0926a |
---|---|
32 exit(1); | 32 exit(1); |
33 } | 33 } |
34 DEBUG_INIT("dumpblocks.log"); | 34 DEBUG_INIT("dumpblocks.log"); |
35 DEBUG_REGISTER_CLOSE(); | 35 DEBUG_REGISTER_CLOSE(); |
36 DEBUG_ENT("main"); | 36 DEBUG_ENT("main"); |
37 | 37 |
38 printf("Opening file %s\n",file); | 38 printf("Opening file %s\n",file); |
39 if (pst_open(&pstfile, file, "r")) { | 39 if (pst_open(&pstfile, file, "r")) { |
40 printf("Failed to open file %s\n", file); | 40 printf("Failed to open file %s\n", file); |
41 exit(1); | 41 exit(1); |
42 } | 42 } |
44 printf("Reading Indexes\n"); | 44 printf("Reading Indexes\n"); |
45 if (pst_load_index(&pstfile)) { | 45 if (pst_load_index(&pstfile)) { |
46 printf("Failed to load indexes in file %s\n", argv[1]); | 46 printf("Failed to load indexes in file %s\n", argv[1]); |
47 exit(1); | 47 exit(1); |
48 } | 48 } |
49 | 49 |
50 if (outdir != NULL) | 50 if (outdir != NULL) |
51 if (chdir(outdir)) { | 51 if (chdir(outdir)) { |
52 printf("Failed to change into directory %s\n", outdir); | 52 printf("Failed to change into directory %s\n", outdir); |
53 exit(1); | 53 exit(1); |
54 } | 54 } |
55 | 55 |
56 ptr = pstfile.i_head; | 56 ptr = pstfile.i_head; |
57 outname = (char*) xmalloc(OUT_BUF); | 57 outname = (char*) xmalloc(OUT_BUF); |
58 printf("Saving blocks\n"); | 58 printf("Saving blocks\n"); |
59 while (ptr != NULL) { | 59 while (ptr != NULL) { |
60 /* if (pstfile.encryption == PST_ENC) { | 60 /* if (pstfile.encryption == PST_ENC) { |
61 c = _pst_ff_getIDblock_dec(&pstfile, ptr->id, buf); | 61 c = pst_ff_getIDblock_dec(&pstfile, ptr->id, buf); |
62 } else {*/ | 62 } else {*/ |
63 if ((ptr->id & 0x02)==0 && pstfile.encryption == PST_ENC) { | 63 if ((ptr->id & 0x02)==0 && pstfile.encryption == PST_ENC) { |
64 c = _pst_ff_getIDblock_dec(&pstfile, ptr->id, &buf); | 64 c = pst_ff_getIDblock_dec(&pstfile, ptr->id, &buf); |
65 } else { | 65 } else { |
66 c = _pst_ff_getIDblock(&pstfile, ptr->id, &buf); | 66 c = pst_ff_getIDblock(&pstfile, ptr->id, &buf); |
67 } | 67 } |
68 | 68 |
69 if (c > 0) { | 69 if (c > 0) { |
70 snprintf(outname, OUT_BUF, "%x", ptr->id); | 70 snprintf(outname, OUT_BUF, "%llx", ptr->id); |
71 if ((fp = fopen(outname, "wb")) == NULL) { | 71 if ((fp = fopen(outname, "wb")) == NULL) { |
72 printf("Failed to open file %s\n", outname); | 72 printf("Failed to open file %s\n", outname); |
73 continue; | 73 continue; |
74 } | 74 } |
75 fwrite(buf, 1, c, fp); | 75 fwrite(buf, 1, c, fp); |
76 fclose(fp); | 76 fclose(fp); |
77 } else { | 77 } else { |
78 printf("Failed to read block id %#x\n", ptr->id); | 78 printf("Failed to read block id %#llx\n", ptr->id); |
79 } | 79 } |
80 ptr = ptr->next; | 80 ptr = ptr->next; |
81 } | 81 } |
82 pst_close(&pstfile); | 82 pst_close(&pstfile); |
83 DEBUG_RET(); | 83 DEBUG_RET(); |