comparison src/getidblock.c @ 79:56fa05fd5271

Patch from Robert Simpson for encryption type 2. Fix the order of testing item types to avoid claiming there are multiple message stores.
author Carl Byington <carl@five-ten-sg.com>
date Fri, 13 Jun 2008 20:47:01 -0700
parents 987aa872294e
children 3ec5ad97e926
comparison
equal deleted inserted replaced
78:535075b4d261 79:56fa05fd5271
7 int main(int argc, char **argv) 7 int main(int argc, char **argv)
8 { 8 {
9 // pass the id number to display on the command line 9 // pass the id number to display on the command line
10 char *fname, *sid; 10 char *fname, *sid;
11 pst_file pstfile; 11 pst_file pstfile;
12 unsigned int id; 12 uint64_t id;
13 int decrypt = 0, process = 0, binary = 0, c; 13 int decrypt = 0, process = 0, binary = 0, c;
14 char *buf = NULL; 14 char *buf = NULL;
15 size_t readSize; 15 size_t readSize;
16 pst_item *item; 16 pst_item *item;
17 pst_desc_ll *ptr; 17 pst_desc_ll *ptr;
44 // no more items on the cmd 44 // no more items on the cmd
45 usage(); 45 usage();
46 exit(EXIT_FAILURE); 46 exit(EXIT_FAILURE);
47 } 47 }
48 fname = argv[optind]; 48 fname = argv[optind];
49 sid = argv[optind + 1]; 49 sid = argv[optind + 1];
50 id = (unsigned int) strtol(sid, NULL, 0); 50 id = (uint64_t)strtoll(sid, NULL, 0);
51 51
52 DEBUG_MAIN(("Opening file\n")); 52 DEBUG_MAIN(("Opening file\n"));
53 memset(&pstfile, 0, sizeof(pstfile)); 53 memset(&pstfile, 0, sizeof(pstfile));
54 if (pst_open(&pstfile, fname)) { 54 if (pst_open(&pstfile, fname)) {
55 DIE(("Error opening file\n")); 55 DIE(("Error opening file\n"));
71 } 71 }
72 if (binary == 0) 72 if (binary == 0)
73 printf("Block %#x, size %#x[%i]\n", id, (unsigned int) readSize, (int) readSize); 73 printf("Block %#x, size %#x[%i]\n", id, (unsigned int) readSize, (int) readSize);
74 74
75 if (decrypt != 0) 75 if (decrypt != 0)
76 if (pst_decrypt(buf, readSize, (int) pstfile.encryption) != 0) { 76 if (pst_decrypt(id, buf, readSize, (int) pstfile.encryption) != 0) {
77 DIE(("Error decrypting block\n")); 77 DIE(("Error decrypting block\n"));
78 } 78 }
79 79
80 DEBUG_MAIN(("Printing block... [id %#x, size %#x]\n", id, readSize)); 80 DEBUG_MAIN(("Printing block... [id %#x, size %#x]\n", id, readSize));
81 if (binary == 0) { 81 if (binary == 0) {