comparison src/getidblock.c @ 149:f9773b6368e0

improve documentation of .pst format. remove decrypt option from getidblock - we always decrypt.
author Carl Byington <carl@five-ten-sg.com>
date Sat, 28 Feb 2009 11:55:48 -0800
parents 0695de3b5a98
children 06aa84023b48
comparison
equal deleted inserted replaced
148:b47d04257b43 149:f9773b6368e0
1 1
2 #include "define.h" 2 #include "define.h"
3 3
4 int decrypt = 0, process = 0, binary = 0; 4 int process = 0, binary = 0;
5 pst_file pstfile; 5 pst_file pstfile;
6 6
7 7
8 void usage(); 8 void usage();
9 void usage() 9 void usage()
10 { 10 {
11 printf("usage: getidblock [options] filename id\n"); 11 printf("usage: getidblock [options] filename id\n");
12 printf("\tfilename - name of the file to access\n"); 12 printf("\tfilename - name of the file to access\n");
13 printf("\tid - ID of the block to fetch (0 to fetch all) - can begin with 0x for hex\n"); 13 printf("\tid - ID of the block to fetch (0 to fetch all) - can begin with 0x for hex\n");
14 printf("\toptions\n"); 14 printf("\toptions\n");
15 printf("\t\t-d\tDecrypt the block before printing\n");
16 printf("\t\t-p\tProcess the block before finishing.\n"); 15 printf("\t\t-p\tProcess the block before finishing.\n");
17 printf("\t\t\tView the debug log for information\n"); 16 printf("\t\t\tView the debug log for information\n");
18 } 17 }
19 18
20 19
25 size_t readSize; 24 size_t readSize;
26 pst_desc_ll *ptr; 25 pst_desc_ll *ptr;
27 26
28 DEBUG_MAIN(("\n\n\nLooking at block index1 id %#"PRIx64"\n", id)); 27 DEBUG_MAIN(("\n\n\nLooking at block index1 id %#"PRIx64"\n", id));
29 28
30 if ((readSize = pst_ff_getIDblock(&pstfile, id, &buf)) <= 0 || buf == 0) { 29 if ((readSize = pst_ff_getIDblock_dec(&pstfile, id, &buf)) <= 0 || buf == 0) {
31 DIE(("Error loading block\n")); 30 DIE(("Error loading block\n"));
32 } 31 }
33
34 if (decrypt)
35 if (pst_decrypt(id, buf, readSize, (int) pstfile.encryption) != 0) {
36 DIE(("Error decrypting block\n"));
37 }
38 32
39 DEBUG_MAIN(("Printing block id %#"PRIx64", size %#"PRIx64"\n", id, (uint64_t)readSize)); 33 DEBUG_MAIN(("Printing block id %#"PRIx64", size %#"PRIx64"\n", id, (uint64_t)readSize));
40 if (binary) { 34 if (binary) {
41 if (fwrite(buf, 1, readSize, stdout) != 0) { 35 if (fwrite(buf, 1, readSize, stdout) != 0) {
42 DIE(("Error occured during writing of buf to stdout\n")); 36 DIE(("Error occured during writing of buf to stdout\n"));
96 switch (c) { 90 switch (c) {
97 case 'b': 91 case 'b':
98 // enable binary output 92 // enable binary output
99 binary = 1; 93 binary = 1;
100 break; 94 break;
101 case 'd':
102 //enable decrypt
103 decrypt = 1;
104 break;
105 case 'p': 95 case 'p':
106 // enable procesing of block 96 // enable procesing of block
107 process = 1; 97 process = 1;
108 break; 98 break;
109 default: 99 default: