comparison src/readpst.c @ 197:07ceebd115ce

remove readpst -C switch, obsolete debugging code
author Carl Byington <carl@five-ten-sg.com>
date Wed, 06 May 2009 10:37:46 -0700
parents 320cfcba8058
children 7c60d6d1c681
comparison
equal deleted inserted replaced
196:ffd1503a7530 197:07ceebd115ce
78 // separate mode creates the same directory structure as recurse. The emails are stored in 78 // separate mode creates the same directory structure as recurse. The emails are stored in
79 // separate files, numbering from 1 upward. Attachments belonging to the emails are 79 // separate files, numbering from 1 upward. Attachments belonging to the emails are
80 // saved as email_no-filename (e.g. 1-samplefile.doc or 000001-Attachment2.zip) 80 // saved as email_no-filename (e.g. 1-samplefile.doc or 000001-Attachment2.zip)
81 #define MODE_SEPARATE 3 81 #define MODE_SEPARATE 3
82 82
83 // Decrypt the whole file (even the parts that aren't encrypted) and ralph it to stdout
84 #define MODE_DECSPEW 4
85
86 83
87 // Output Normal just prints the standard information about what is going on 84 // Output Normal just prints the standard information about what is going on
88 #define OUTPUT_NORMAL 0 85 #define OUTPUT_NORMAL 0
89 86
90 // Output Quiet is provided so that only errors are printed 87 // Output Quiet is provided so that only errors are printed
267 printf("cannot compile regex pattern to find content charset in html bodies\n"); 264 printf("cannot compile regex pattern to find content charset in html bodies\n");
268 exit(3); 265 exit(3);
269 } 266 }
270 267
271 // command-line option handling 268 // command-line option handling
272 while ((c = getopt(argc, argv, "bCc:Dd:hko:qrSMVw"))!= -1) { 269 while ((c = getopt(argc, argv, "bc:Dd:hko:qrSMVw"))!= -1) {
273 switch (c) { 270 switch (c) {
274 case 'b': 271 case 'b':
275 save_rtf_body = 0; 272 save_rtf_body = 0;
276 break;
277 case 'C':
278 mode = MODE_DECSPEW;
279 break; 273 break;
280 case 'c': 274 case 'c':
281 if (optarg && optarg[0]=='v') { 275 if (optarg && optarg[0]=='v') {
282 contact_mode=CMODE_VCARD; 276 contact_mode=CMODE_VCARD;
283 contact_mode_specified = 1; 277 contact_mode_specified = 1;
347 if (!d_log) d_log = "readpst.log"; 341 if (!d_log) d_log = "readpst.log";
348 #endif // defined DEBUG_ALL 342 #endif // defined DEBUG_ALL
349 DEBUG_INIT(d_log); 343 DEBUG_INIT(d_log);
350 DEBUG_REGISTER_CLOSE(); 344 DEBUG_REGISTER_CLOSE();
351 DEBUG_ENT("main"); 345 DEBUG_ENT("main");
352
353 if (mode == MODE_DECSPEW) {
354 FILE *fp;
355 char buf[1024];
356 size_t l = 0;
357 if (NULL == (fp = fopen(fname, "rb"))) {
358 WARN(("Couldn't open file %s\n", fname));
359 DEBUG_RET();
360 return 1;
361 }
362
363 while (0 != (l = fread(buf, 1, 1024, fp))) {
364 if (0 != pst_decrypt(0, buf, l, PST_COMP_ENCRYPT))
365 WARN(("pst_decrypt() failed (I'll try to continue)\n"));
366
367 if (l != pst_fwrite(buf, 1, l, stdout)) {
368 WARN(("Couldn't output to stdout?\n"));
369 DEBUG_RET();
370 return 1;
371 }
372 }
373 DEBUG_RET();
374 return 0;
375 }
376 346
377 if (output_mode != OUTPUT_QUIET) printf("Opening PST file and indexes...\n"); 347 if (output_mode != OUTPUT_QUIET) printf("Opening PST file and indexes...\n");
378 348
379 RET_DERROR(pst_open(&pstfile, fname), 1, ("Error opening File\n")); 349 RET_DERROR(pst_open(&pstfile, fname), 1, ("Error opening File\n"));
380 RET_DERROR(pst_load_index(&pstfile), 2, ("Index Error\n")); 350 RET_DERROR(pst_load_index(&pstfile), 2, ("Index Error\n"));