annotate src/lspst.c @ 209:5ee62ba37705

build requires boost-devel
author Carl Byington <carl@five-ten-sg.com>
date Sat, 06 Jun 2009 13:15:37 -0700
parents 2f38c4ce606f
children 94bde95d7e18
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
1 /***
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
2 * lspst.c
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
3 * Part of the LibPST project
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
4 * Author: Joe Nahmias <joe@nahmias.net>
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
5 * Based on readpst.c by by David Smith <dave.s@earthcorp.com>
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
6 *
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
7 */
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
8
122
bdb38b434c0a more changes from Fridrich Strba to avoid installing our config.h
Carl Byington <carl@five-ten-sg.com>
parents: 120
diff changeset
9 #include "define.h"
bdb38b434c0a more changes from Fridrich Strba to avoid installing our config.h
Carl Byington <carl@five-ten-sg.com>
parents: 120
diff changeset
10
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
11 struct file_ll {
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
12 char *dname;
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
13 int32_t stored_count;
167
40e9de445038 improve consistency checking when fetching items from the pst file.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
14 int32_t item_count;
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
15 int32_t skip_count;
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
16 int32_t type;
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
17 };
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
18
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
19
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
20 void canonicalize_filename(char *fname);
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
21 void debug_print(char *fmt, ...);
118
0f1492b7fe8b patch from Fridrich Strba for building on mingw and general cleanup of autoconf files
Carl Byington <carl@five-ten-sg.com>
parents: 110
diff changeset
22 void usage(char *prog_name);
0f1492b7fe8b patch from Fridrich Strba for building on mingw and general cleanup of autoconf files
Carl Byington <carl@five-ten-sg.com>
parents: 110
diff changeset
23 void version();
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
24
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
25 // global settings
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
26 pst_file pstfile;
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
27
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
28
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
29 void create_enter_dir(struct file_ll* f, pst_item *item)
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
30 {
151
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 150
diff changeset
31 pst_convert_utf8(item, &item->file_as);
167
40e9de445038 improve consistency checking when fetching items from the pst file.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
32 f->item_count = 0;
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
33 f->skip_count = 0;
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
34 f->type = item->type;
167
40e9de445038 improve consistency checking when fetching items from the pst file.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
35 f->stored_count = (item->folder) ? item->folder->item_count : 0;
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 167
diff changeset
36 f->dname = strdup(item->file_as.str);
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
37 }
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
38
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
39
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
40 void close_enter_dir(struct file_ll *f)
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
41 {
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
42 free(f->dname);
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
43 }
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
44
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
45
186
0a4f7ecd7452 more cleanup of external names in the shared library
Carl Byington <carl@five-ten-sg.com>
parents: 172
diff changeset
46 void process(pst_item *outeritem, pst_desc_tree *d_ptr)
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
47 {
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
48 struct file_ll ff;
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
49 pst_item *item = NULL;
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
50
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
51 DEBUG_ENT("process");
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
52 memset(&ff, 0, sizeof(ff));
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
53 create_enter_dir(&ff, outeritem);
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
54
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
55 while (d_ptr) {
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
56 if (!d_ptr->desc) {
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 199
diff changeset
57 DEBUG_WARN(("ERROR item's desc record is NULL\n"));
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
58 ff.skip_count++;
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
59 }
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
60 else {
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 199
diff changeset
61 DEBUG_INFO(("Desc Email ID %"PRIx64" [d_ptr->d_id = %"PRIx64"]\n", d_ptr->desc->i_id, d_ptr->d_id));
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
62
143
fdc58ad2c758 fix embedded rfc822 messages with attachments
Carl Byington <carl@five-ten-sg.com>
parents: 129
diff changeset
63 item = pst_parse_item(&pstfile, d_ptr, NULL);
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 199
diff changeset
64 DEBUG_INFO(("About to process item @ %p.\n", item));
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
65 if (item) {
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
66 if (item->message_store) {
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
67 // there should only be one message_store, and we have already done it
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 199
diff changeset
68 DIE(("A second message_store has been found. Sorry, this must be an error.\n"));
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
69 }
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
70
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
71 if (item->folder && d_ptr->child) {
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
72 // if this is a folder, we want to recurse into it
151
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 150
diff changeset
73 pst_convert_utf8(item, &item->file_as);
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 150
diff changeset
74 printf("Folder \"%s\"\n", item->file_as.str);
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
75 process(item, d_ptr->child);
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
76
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
77 } else if (item->contact && (item->type == PST_TYPE_CONTACT)) {
198
7c60d6d1c681 decode more recurrence mapi elements
Carl Byington <carl@five-ten-sg.com>
parents: 195
diff changeset
78 if (!ff.type) ff.type = item->type;
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
79 // Process Contact item
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
80 if (ff.type != PST_TYPE_CONTACT) {
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 199
diff changeset
81 DEBUG_INFO(("I have a contact, but the folder isn't a contacts folder. Processing anyway\n"));
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
82 }
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
83 printf("Contact");
151
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 150
diff changeset
84 if (item->contact->fullname.str)
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 150
diff changeset
85 printf("\t%s", pst_rfc2426_escape(item->contact->fullname.str));
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
86 printf("\n");
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
87
198
7c60d6d1c681 decode more recurrence mapi elements
Carl Byington <carl@five-ten-sg.com>
parents: 195
diff changeset
88 } else if (item->email && ((item->type == PST_TYPE_NOTE) || (item->type == PST_TYPE_SCHEDULE) || (item->type == PST_TYPE_REPORT))) {
7c60d6d1c681 decode more recurrence mapi elements
Carl Byington <carl@five-ten-sg.com>
parents: 195
diff changeset
89 if (!ff.type) ff.type = item->type;
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
90 // Process Email item
198
7c60d6d1c681 decode more recurrence mapi elements
Carl Byington <carl@five-ten-sg.com>
parents: 195
diff changeset
91 if ((ff.type != PST_TYPE_NOTE) && (ff.type != PST_TYPE_SCHEDULE) && (ff.type != PST_TYPE_REPORT)) {
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 199
diff changeset
92 DEBUG_INFO(("I have an email, but the folder isn't an email folder. Processing anyway\n"));
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
93 }
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
94 printf("Email");
151
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 150
diff changeset
95 if (item->email->outlook_sender_name.str)
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 150
diff changeset
96 printf("\tFrom: %s", item->email->outlook_sender_name.str);
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 150
diff changeset
97 if (item->subject.str)
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 150
diff changeset
98 printf("\tSubject: %s", item->subject.str);
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
99 printf("\n");
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
100
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
101 } else if (item->journal && (item->type == PST_TYPE_JOURNAL)) {
198
7c60d6d1c681 decode more recurrence mapi elements
Carl Byington <carl@five-ten-sg.com>
parents: 195
diff changeset
102 if (!ff.type) ff.type = item->type;
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
103 // Process Journal item
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
104 if (ff.type != PST_TYPE_JOURNAL) {
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 199
diff changeset
105 DEBUG_INFO(("I have a journal entry, but folder isn't specified as a journal type. Processing...\n"));
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
106 }
151
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 150
diff changeset
107 if (item->subject.str)
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 150
diff changeset
108 printf("Journal\t%s\n", pst_rfc2426_escape(item->subject.str));
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
109
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
110 } else if (item->appointment && (item->type == PST_TYPE_APPOINTMENT)) {
199
e3a46f66332b more changes in recurrence decoding
Carl Byington <carl@five-ten-sg.com>
parents: 198
diff changeset
111 char time_buffer[30];
198
7c60d6d1c681 decode more recurrence mapi elements
Carl Byington <carl@five-ten-sg.com>
parents: 195
diff changeset
112 if (!ff.type) ff.type = item->type;
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
113 // Process Calendar Appointment item
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 199
diff changeset
114 DEBUG_INFO(("Processing Appointment Entry\n"));
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
115 if (ff.type != PST_TYPE_APPOINTMENT) {
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 199
diff changeset
116 DEBUG_INFO(("I have an appointment, but folder isn't specified as an appointment type. Processing...\n"));
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
117 }
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
118 printf("Appointment");
151
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 150
diff changeset
119 if (item->subject.str)
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 150
diff changeset
120 printf("\tSUMMARY: %s", pst_rfc2426_escape(item->subject.str));
50
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
121 if (item->appointment->start)
199
e3a46f66332b more changes in recurrence decoding
Carl Byington <carl@five-ten-sg.com>
parents: 198
diff changeset
122 printf("\tSTART: %s", pst_rfc2445_datetime_format(item->appointment->start, sizeof(time_buffer), time_buffer));
50
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
123 if (item->appointment->end)
199
e3a46f66332b more changes in recurrence decoding
Carl Byington <carl@five-ten-sg.com>
parents: 198
diff changeset
124 printf("\tEND: %s", pst_rfc2445_datetime_format(item->appointment->end, sizeof(time_buffer), time_buffer));
50
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
125 printf("\tALL DAY: %s", (item->appointment->all_day==1 ? "Yes" : "No"));
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
126 printf("\n");
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
127
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
128 } else {
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
129 ff.skip_count++;
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 199
diff changeset
130 DEBUG_INFO(("Unknown item type. %i. Ascii1=\"%s\"\n",
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
131 item->type, item->ascii_type));
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
132 }
46
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
133 pst_freeItem(item);
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
134 } else {
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
135 ff.skip_count++;
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 199
diff changeset
136 DEBUG_INFO(("A NULL item was seen\n"));
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
137 }
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
138 d_ptr = d_ptr->next;
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
139 }
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
140 }
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
141 close_enter_dir(&ff);
52
034641c26ab9 code cleanup
carl
parents: 50
diff changeset
142 DEBUG_RET();
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
143 }
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
144
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
145
118
0f1492b7fe8b patch from Fridrich Strba for building on mingw and general cleanup of autoconf files
Carl Byington <carl@five-ten-sg.com>
parents: 110
diff changeset
146 void usage(char *prog_name) {
50
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
147 DEBUG_ENT("usage");
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
148 version();
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
149 printf("Usage: %s [OPTIONS] {PST FILENAME}\n", prog_name);
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
150 printf("OPTIONS:\n");
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
151 printf("\t-d <filename> \t- Debug to file. This is a binary log. Use readlog to print it\n");
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
152 printf("\t-h\t- Help. This screen\n");
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
153 printf("\t-V\t- Version. Display program version\n");
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
154 DEBUG_RET();
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
155 }
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
156
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
157
118
0f1492b7fe8b patch from Fridrich Strba for building on mingw and general cleanup of autoconf files
Carl Byington <carl@five-ten-sg.com>
parents: 110
diff changeset
158 void version() {
50
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
159 DEBUG_ENT("version");
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
160 printf("lspst / LibPST v%s\n", VERSION);
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
161 #if BYTE_ORDER == BIG_ENDIAN
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
162 printf("Big Endian implementation being used.\n");
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
163 #elif BYTE_ORDER == LITTLE_ENDIAN
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
164 printf("Little Endian implementation being used.\n");
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
165 #else
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
166 # error "Byte order not supported by this library"
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
167 #endif
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
168 #ifdef __GNUC__
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
169 printf("GCC %d.%d : %s %s\n", __GNUC__, __GNUC_MINOR__, __DATE__, __TIME__);
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
170 #endif
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
171 DEBUG_RET();
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
172 }
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
173
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
174
118
0f1492b7fe8b patch from Fridrich Strba for building on mingw and general cleanup of autoconf files
Carl Byington <carl@five-ten-sg.com>
parents: 110
diff changeset
175 int main(int argc, char* const* argv) {
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
176 pst_item *item = NULL;
186
0a4f7ecd7452 more cleanup of external names in the shared library
Carl Byington <carl@five-ten-sg.com>
parents: 172
diff changeset
177 pst_desc_tree *d_ptr;
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
178 char *temp = NULL; //temporary char pointer
50
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
179 int c;
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
180 char *d_log = NULL;
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
181
50
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
182 while ((c = getopt(argc, argv, "d:hV"))!= -1) {
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
183 switch (c) {
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
184 case 'd':
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
185 d_log = optarg;
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
186 break;
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
187 case 'h':
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
188 usage(argv[0]);
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
189 exit(0);
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
190 break;
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
191 case 'V':
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
192 version();
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
193 exit(0);
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
194 break;
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
195 default:
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
196 usage(argv[0]);
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
197 exit(1);
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
198 break;
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
199 }
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
200 }
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
201
48
f66078abed38 more fixes for 64 bit format
carl
parents: 46
diff changeset
202 #ifdef DEBUG_ALL
f66078abed38 more fixes for 64 bit format
carl
parents: 46
diff changeset
203 // force a log file
f66078abed38 more fixes for 64 bit format
carl
parents: 46
diff changeset
204 if (!d_log) d_log = "lspst.log";
f66078abed38 more fixes for 64 bit format
carl
parents: 46
diff changeset
205 #endif // defined DEBUG_ALL
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 199
diff changeset
206 DEBUG_INIT(d_log, NULL);
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
207 DEBUG_ENT("main");
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
208
50
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
209 if (argc <= optind) {
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
210 usage(argv[0]);
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
211 exit(2);
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
212 }
fb3818370dd6 more fixes for 64 bit format
carl
parents: 48
diff changeset
213
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
214 // Open PST file
59
7d5c637aaafb General cleanup and code fixes.
Carl Byington <carl@five-ten-sg.com>
parents: 52
diff changeset
215 if (pst_open(&pstfile, argv[optind])) DIE(("Error opening File\n"));
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
216
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
217 // Load PST index
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
218 if (pst_load_index(&pstfile)) DIE(("Index Error\n"));
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
219
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
220 pst_load_extended_attributes(&pstfile);
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
221
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
222 d_ptr = pstfile.d_head; // first record is main record
143
fdc58ad2c758 fix embedded rfc822 messages with attachments
Carl Byington <carl@five-ten-sg.com>
parents: 129
diff changeset
223 item = pst_parse_item(&pstfile, d_ptr, NULL);
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
224 if (!item || !item->message_store) {
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
225 DEBUG_RET();
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 199
diff changeset
226 DIE(("Could not get root record\n"));
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
227 }
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
228
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
229 // default the file_as to the same as the main filename if it doesn't exist
151
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 150
diff changeset
230 if (!item->file_as.str) {
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
231 if (!(temp = strrchr(argv[1], '/')))
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
232 if (!(temp = strrchr(argv[1], '\\')))
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
233 temp = argv[1];
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
234 else
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
235 temp++; // get past the "\\"
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
236 else
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
237 temp++; // get past the "/"
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 167
diff changeset
238 item->file_as.str = strdup(temp);
151
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 150
diff changeset
239 item->file_as.is_utf8 = 1;
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
240 }
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
241
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
242 d_ptr = pst_getTopOfFolders(&pstfile, item);
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
243 if (!d_ptr) DIE(("Top of folders record not found. Cannot continue\n"));
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
244
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
245 process(item, d_ptr->child); // do the childred of TOPF
46
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
246 pst_freeItem(item);
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
247 pst_close(&pstfile);
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
248
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
249 DEBUG_RET();
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
250 return 0;
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
251 }
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
252
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
253
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
254 // This function will make sure that a filename is in cannonical form. That
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
255 // is, it will replace any slashes, backslashes, or colons with underscores.
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
256 void canonicalize_filename(char *fname) {
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
257 DEBUG_ENT("canonicalize_filename");
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
258 if (fname == NULL) {
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
259 DEBUG_RET();
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
260 return;
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
261 }
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
262 while ((fname = strpbrk(fname, "/\\:")))
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
263 *fname = '_';
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
264 DEBUG_RET();
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
265 }
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
266
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
267