Mercurial > libpst
comparison lspst.c @ 10:a818f3c2e589
fix tree walk, we now use the item counts in the node blocks
author | carl |
---|---|
date | Fri, 17 Feb 2006 15:48:38 -0800 |
parents | fac01758bd41 |
children |
comparison
equal
deleted
inserted
replaced
9:8c724896a28a | 10:a818f3c2e589 |
---|---|
35 int chr_count(char *str, char x); | 35 int chr_count(char *str, char x); |
36 void debug_print(char *fmt, ...); | 36 void debug_print(char *fmt, ...); |
37 char *rfc2426_escape(char *str); | 37 char *rfc2426_escape(char *str); |
38 char *rfc2445_datetime_format(FILETIME *ft); | 38 char *rfc2445_datetime_format(FILETIME *ft); |
39 // }}}1 | 39 // }}}1 |
40 #define DEBUG_MAIN(x) debug_print x; | 40 #ifndef DEBUG_MAIN |
41 #define DEBUG_MAIN(x) debug_print x; | |
42 #endif | |
41 // int main(int argc, char** argv) {{{1 | 43 // int main(int argc, char** argv) {{{1 |
42 int main(int argc, char** argv) { | 44 int main(int argc, char** argv) { |
43 | 45 |
44 // declarations {{{2 | 46 // declarations {{{2 |
45 pst_item *item = NULL; | 47 pst_item *item = NULL; |
46 pst_file pstfile; | 48 pst_file pstfile; |
47 pst_desc_ll *d_ptr; | 49 pst_desc_ll *d_ptr; |
48 char *temp = NULL; //temporary char pointer | 50 char *temp = NULL; //temporary char pointer |
49 int skip_child = 0; | 51 int skip_child = 0; |
50 struct file_ll *f, *head; | 52 struct file_ll *f, *head; |
51 // }}}2 | 53 // }}}2 |
52 | 54 |
53 if (argc <= 1) | 55 if (argc <= 1) |
54 DIE(("Missing PST filename.\n")); | 56 DIE(("Missing PST filename.\n")); |
55 | 57 |
63 | 65 |
64 d_ptr = pstfile.d_head; // first record is main record | 66 d_ptr = pstfile.d_head; // first record is main record |
65 if ((item = _pst_parse_item(&pstfile, d_ptr)) == NULL || item->message_store == NULL) { | 67 if ((item = _pst_parse_item(&pstfile, d_ptr)) == NULL || item->message_store == NULL) { |
66 DIE(("main: Could not get root record\n")); | 68 DIE(("main: Could not get root record\n")); |
67 } | 69 } |
68 | 70 |
69 // default the file_as to the same as the main filename if it doesn't exist | 71 // default the file_as to the same as the main filename if it doesn't exist |
70 if (item->file_as == NULL) { | 72 if (item->file_as == NULL) { |
71 if ((temp = strrchr(argv[1], '/')) == NULL) | 73 if ((temp = strrchr(argv[1], '/')) == NULL) |
72 if ((temp = strrchr(argv[1], '\\')) == NULL) | 74 if ((temp = strrchr(argv[1], '\\')) == NULL) |
73 temp = argv[1]; | 75 temp = argv[1]; |
159 if (f->output != NULL) | 161 if (f->output != NULL) |
160 fclose(f->output); | 162 fclose(f->output); |
161 free(f->dname); | 163 free(f->dname); |
162 free(f->name); | 164 free(f->name); |
163 free(f); | 165 free(f); |
164 | 166 |
165 f = head; | 167 f = head; |
166 } | 168 } |
167 _pst_freeItem(item); | 169 _pst_freeItem(item); |
168 item = NULL; // just for the odd situations! | 170 item = NULL; // just for the odd situations! |
169 goto check_parent; | 171 goto check_parent; |
184 if (item->contact->fullname != NULL) | 186 if (item->contact->fullname != NULL) |
185 printf("\t%s", rfc2426_escape(item->contact->fullname)); | 187 printf("\t%s", rfc2426_escape(item->contact->fullname)); |
186 printf("\n"); | 188 printf("\n"); |
187 // }}}3 | 189 // }}}3 |
188 } else if (item->email != NULL && | 190 } else if (item->email != NULL && |
189 (item->type == PST_TYPE_NOTE || item->type == PST_TYPE_REPORT)) { | 191 (item->type == PST_TYPE_NOTE || item->type == PST_TYPE_REPORT)) { |
190 // Process Email item {{{3 | 192 // Process Email item {{{3 |
191 printf("Email"); | 193 printf("Email"); |
192 if (item->email->outlook_sender_name != NULL) | 194 if (item->email->outlook_sender_name != NULL) |
193 printf("\tFrom: %s", item->email->outlook_sender_name); | 195 printf("\tFrom: %s", item->email->outlook_sender_name); |
194 if (item->email->subject->subj != NULL) | 196 if (item->email->subject->subj != NULL) |
229 f->skip_count++; | 231 f->skip_count++; |
230 DEBUG_MAIN(("main: A NULL item was seen\n")); | 232 DEBUG_MAIN(("main: A NULL item was seen\n")); |
231 } | 233 } |
232 | 234 |
233 check_parent: | 235 check_parent: |
234 // _pst_freeItem(item); | 236 // _pst_freeItem(item); |
235 while (!skip_child && d_ptr->next == NULL && d_ptr->parent != NULL) { | 237 while (!skip_child && d_ptr->next == NULL && d_ptr->parent != NULL) { |
236 DEBUG_MAIN(("main: Going to Parent\n")); | 238 DEBUG_MAIN(("main: Going to Parent\n")); |
237 head = f->next; | 239 head = f->next; |
238 if (f->output != NULL) | 240 if (f->output != NULL) |
239 fclose(f->output); | 241 fclose(f->output); |
261 item = NULL; | 263 item = NULL; |
262 } | 264 } |
263 | 265 |
264 if (!skip_child) | 266 if (!skip_child) |
265 d_ptr = d_ptr->next; | 267 d_ptr = d_ptr->next; |
266 else | 268 else |
267 skip_child = 0; | 269 skip_child = 0; |
268 | 270 |
269 if (d_ptr == NULL) { DEBUG_MAIN(("main: d_ptr is now NULL\n")); } | 271 if (d_ptr == NULL) { DEBUG_MAIN(("main: d_ptr is now NULL\n")); } |
270 | 272 |
271 // }}}2 | 273 // }}}2 |
272 } // end while(d_ptr != NULL) | 274 } // end while(d_ptr != NULL) |
273 DEBUG_MAIN(("main: Finished.\n")); | 275 DEBUG_MAIN(("main: Finished.\n")); |
289 | 291 |
290 return 0; | 292 return 0; |
291 } | 293 } |
292 // }}}1 | 294 // }}}1 |
293 // void canonicalize_filename(char *fname) {{{1 | 295 // void canonicalize_filename(char *fname) {{{1 |
294 // This function will make sure that a filename is in cannonical form. That | 296 // This function will make sure that a filename is in cannonical form. That |
295 // is, it will replace any slashes, backslashes, or colons with underscores. | 297 // is, it will replace any slashes, backslashes, or colons with underscores. |
296 void canonicalize_filename(char *fname) { | 298 void canonicalize_filename(char *fname) { |
297 DEBUG_ENT("canonicalize_filename"); | 299 DEBUG_ENT("canonicalize_filename"); |
298 if (fname == NULL) { | 300 if (fname == NULL) { |
299 DEBUG_RET(); | 301 DEBUG_RET(); |
396 // skip | 398 // skip |
397 break; | 399 break; |
398 default: | 400 default: |
399 *b = *a; | 401 *b = *a; |
400 } | 402 } |
401 *b = '\0'; // NUL-terminate the string | 403 *b = '\0'; // NUL-terminate the string |
402 | 404 |
403 DEBUG_RET(); | 405 DEBUG_RET(); |
404 return buf; | 406 return buf; |
405 } | 407 } |
406 // }}}1 | 408 // }}}1 |
407 // char *rfc2445_datetime_format(FILETIME *ft) {{{1 | 409 // char *rfc2445_datetime_format(FILETIME *ft) {{{1 |
408 char *rfc2445_datetime_format(FILETIME *ft) { | 410 char *rfc2445_datetime_format(FILETIME *ft) { |
409 static char* buffer = NULL; | 411 static char* buffer = NULL; |
410 struct tm *stm = NULL; | 412 struct tm *stm = NULL; |