Mercurial > libpst
annotate src/getidblock.c @ 315:3e6cdd543857
date sent property is fixed size, so the value is stored directly in the property stream
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Thu, 03 Jun 2010 19:09:29 -0700 |
parents | 2f38c4ce606f |
children | 4573b536177f |
rev | line source |
---|---|
75
987aa872294e
Use ftello/fseeko to properly handle large files.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
1 |
48 | 2 #include "define.h" |
16 | 3 |
149
f9773b6368e0
improve documentation of .pst format.
Carl Byington <carl@five-ten-sg.com>
parents:
146
diff
changeset
|
4 int process = 0, binary = 0; |
142
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
5 pst_file pstfile; |
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
6 |
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
7 |
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
8 void usage(); |
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
9 void usage() |
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
10 { |
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
11 printf("usage: getidblock [options] filename id\n"); |
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
12 printf("\tfilename - name of the file to access\n"); |
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
13 printf("\tid - ID of the block to fetch (0 to fetch all) - can begin with 0x for hex\n"); |
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
14 printf("\toptions\n"); |
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
15 printf("\t\t-p\tProcess the block before finishing.\n"); |
202
2f38c4ce606f
remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents:
186
diff
changeset
|
16 printf("\t\t-b\tDump the blocks in binary to stdout.\n"); |
142
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
17 printf("\t\t\tView the debug log for information\n"); |
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
18 } |
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
19 |
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
20 |
164
ab384fed78c5
Compensate for iconv conversion to utf-7 that produces strings that are not null terminated.
Carl Byington <carl@five-ten-sg.com>
parents:
150
diff
changeset
|
21 void dumper(uint64_t i_id); |
ab384fed78c5
Compensate for iconv conversion to utf-7 that produces strings that are not null terminated.
Carl Byington <carl@five-ten-sg.com>
parents:
150
diff
changeset
|
22 void dumper(uint64_t i_id) |
142
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
23 { |
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
24 char *buf = NULL; |
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
25 size_t readSize; |
186
0a4f7ecd7452
more cleanup of external names in the shared library
Carl Byington <carl@five-ten-sg.com>
parents:
172
diff
changeset
|
26 pst_desc_tree *ptr; |
142
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
27 |
202
2f38c4ce606f
remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents:
186
diff
changeset
|
28 DEBUG_INFO(("\n\n\nLooking at block index1 id %#"PRIx64"\n", i_id)); |
142
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
29 |
164
ab384fed78c5
Compensate for iconv conversion to utf-7 that produces strings that are not null terminated.
Carl Byington <carl@five-ten-sg.com>
parents:
150
diff
changeset
|
30 if ((readSize = pst_ff_getIDblock_dec(&pstfile, i_id, &buf)) <= 0 || buf == 0) { |
142
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
31 DIE(("Error loading block\n")); |
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
32 } |
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
33 |
202
2f38c4ce606f
remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents:
186
diff
changeset
|
34 DEBUG_INFO(("Printing block id %#"PRIx64", size %#"PRIx64"\n", i_id, (uint64_t)readSize)); |
142
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
35 if (binary) { |
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
36 if (fwrite(buf, 1, readSize, stdout) != 0) { |
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
37 DIE(("Error occured during writing of buf to stdout\n")); |
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
38 } |
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
39 } else { |
164
ab384fed78c5
Compensate for iconv conversion to utf-7 that produces strings that are not null terminated.
Carl Byington <carl@five-ten-sg.com>
parents:
150
diff
changeset
|
40 printf("Block id %#"PRIx64", size %#"PRIx64"\n", i_id, (uint64_t)readSize); |
142
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
41 pst_debug_hexdumper(stdout, buf, readSize, 0x10, 0); |
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
42 } |
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
43 if (buf) free(buf); |
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
44 |
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
45 if (process) { |
202
2f38c4ce606f
remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents:
186
diff
changeset
|
46 DEBUG_INFO(("Parsing block id %#"PRIx64"\n", i_id)); |
142
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
47 ptr = pstfile.d_head; |
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
48 while (ptr) { |
164
ab384fed78c5
Compensate for iconv conversion to utf-7 that produces strings that are not null terminated.
Carl Byington <carl@five-ten-sg.com>
parents:
150
diff
changeset
|
49 if (ptr->assoc_tree && ptr->assoc_tree->i_id == i_id) |
142
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
50 break; |
164
ab384fed78c5
Compensate for iconv conversion to utf-7 that produces strings that are not null terminated.
Carl Byington <carl@five-ten-sg.com>
parents:
150
diff
changeset
|
51 if (ptr->desc && ptr->desc->i_id == i_id) |
142
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
52 break; |
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
53 ptr = pst_getNextDptr(ptr); |
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
54 } |
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
55 if (!ptr) { |
186
0a4f7ecd7452
more cleanup of external names in the shared library
Carl Byington <carl@five-ten-sg.com>
parents:
172
diff
changeset
|
56 ptr = (pst_desc_tree *) pst_malloc(sizeof(pst_desc_tree)); |
0a4f7ecd7452
more cleanup of external names in the shared library
Carl Byington <carl@five-ten-sg.com>
parents:
172
diff
changeset
|
57 memset(ptr, 0, sizeof(pst_desc_tree)); |
164
ab384fed78c5
Compensate for iconv conversion to utf-7 that produces strings that are not null terminated.
Carl Byington <carl@five-ten-sg.com>
parents:
150
diff
changeset
|
58 ptr->desc = pst_getID(&pstfile, i_id); |
142
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
59 } |
143
fdc58ad2c758
fix embedded rfc822 messages with attachments
Carl Byington <carl@five-ten-sg.com>
parents:
142
diff
changeset
|
60 pst_item *item = pst_parse_item(&pstfile, ptr, NULL); |
142
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
61 if (item) pst_freeItem(item); |
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
62 } |
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
63 } |
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
64 |
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
65 |
186
0a4f7ecd7452
more cleanup of external names in the shared library
Carl Byington <carl@five-ten-sg.com>
parents:
172
diff
changeset
|
66 void dump_desc(pst_desc_tree *ptr); |
0a4f7ecd7452
more cleanup of external names in the shared library
Carl Byington <carl@five-ten-sg.com>
parents:
172
diff
changeset
|
67 void dump_desc(pst_desc_tree *ptr) |
142
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
68 { |
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
69 while (ptr) { |
202
2f38c4ce606f
remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents:
186
diff
changeset
|
70 DEBUG_INFO(("\n\n\nLooking at block desc id %#"PRIx64"\n", ptr->d_id)); |
164
ab384fed78c5
Compensate for iconv conversion to utf-7 that produces strings that are not null terminated.
Carl Byington <carl@five-ten-sg.com>
parents:
150
diff
changeset
|
71 if (ptr->desc && ptr->desc->i_id) dumper(ptr->desc->i_id); |
ab384fed78c5
Compensate for iconv conversion to utf-7 that produces strings that are not null terminated.
Carl Byington <carl@five-ten-sg.com>
parents:
150
diff
changeset
|
72 if (ptr->assoc_tree && ptr->assoc_tree->i_id) dumper(ptr->assoc_tree->i_id); |
142
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
73 if (ptr->child) dump_desc(ptr->child); |
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
74 ptr = ptr->next; |
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
75 } |
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
76 } |
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
77 |
16 | 78 |
118
0f1492b7fe8b
patch from Fridrich Strba for building on mingw and general cleanup of autoconf files
Carl Byington <carl@five-ten-sg.com>
parents:
87
diff
changeset
|
79 int main(int argc, char* const* argv) |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
80 { |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
81 // pass the id number to display on the command line |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
82 char *fname, *sid; |
164
ab384fed78c5
Compensate for iconv conversion to utf-7 that produces strings that are not null terminated.
Carl Byington <carl@five-ten-sg.com>
parents:
150
diff
changeset
|
83 uint64_t i_id; |
142
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
84 int c; |
16 | 85 |
202
2f38c4ce606f
remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents:
186
diff
changeset
|
86 DEBUG_INIT("getidblock.log", NULL); |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
87 DEBUG_ENT("main"); |
16 | 88 |
202
2f38c4ce606f
remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents:
186
diff
changeset
|
89 while ((c = getopt(argc, argv, "bp")) != -1) { |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
90 switch (c) { |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
91 case 'b': |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
92 // enable binary output |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
93 binary = 1; |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
94 break; |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
95 case 'p': |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
96 // enable procesing of block |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
97 process = 1; |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
98 break; |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
99 default: |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
100 usage(); |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
101 exit(EXIT_FAILURE); |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
102 } |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
103 } |
16 | 104 |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
105 if (optind + 1 >= argc) { |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
106 // no more items on the cmd |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
107 usage(); |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
108 exit(EXIT_FAILURE); |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
109 } |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
110 fname = argv[optind]; |
79
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
75
diff
changeset
|
111 sid = argv[optind + 1]; |
164
ab384fed78c5
Compensate for iconv conversion to utf-7 that produces strings that are not null terminated.
Carl Byington <carl@five-ten-sg.com>
parents:
150
diff
changeset
|
112 i_id = (uint64_t)strtoll(sid, NULL, 0); |
16 | 113 |
202
2f38c4ce606f
remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents:
186
diff
changeset
|
114 DEBUG_INFO(("Opening file\n")); |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
115 memset(&pstfile, 0, sizeof(pstfile)); |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
116 if (pst_open(&pstfile, fname)) { |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
117 DIE(("Error opening file\n")); |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
118 } |
16 | 119 |
202
2f38c4ce606f
remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents:
186
diff
changeset
|
120 DEBUG_INFO(("Loading Index\n")); |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
121 if (pst_load_index(&pstfile) != 0) { |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
122 DIE(("Error loading file index\n")); |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
123 } |
16 | 124 |
164
ab384fed78c5
Compensate for iconv conversion to utf-7 that produces strings that are not null terminated.
Carl Byington <carl@five-ten-sg.com>
parents:
150
diff
changeset
|
125 if (i_id) { |
ab384fed78c5
Compensate for iconv conversion to utf-7 that produces strings that are not null terminated.
Carl Byington <carl@five-ten-sg.com>
parents:
150
diff
changeset
|
126 dumper(i_id); |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
127 } |
142
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
128 else { |
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
129 pst_index_ll *ptr = pstfile.i_head; |
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
130 while (ptr) { |
164
ab384fed78c5
Compensate for iconv conversion to utf-7 that produces strings that are not null terminated.
Carl Byington <carl@five-ten-sg.com>
parents:
150
diff
changeset
|
131 dumper(ptr->i_id); |
142
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
132 ptr = ptr->next; |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
133 } |
142
2189a6b8134e
improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode.
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
134 dump_desc(pstfile.d_head); |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
135 } |
16 | 136 |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
137 if (pst_close(&pstfile) != 0) { |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
138 DIE(("pst_close failed\n")); |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
139 } |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
140 |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
141 DEBUG_RET(); |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
142 return 0; |
16 | 143 } |
144 |