Mercurial > libpst
comparison src/readpst.c @ 52:034641c26ab9
code cleanup
author | carl |
---|---|
date | Thu, 31 Jan 2008 08:03:30 -0800 |
parents | fb3818370dd6 |
children | 7d5c637aaafb |
comparison
equal
deleted
inserted
replaced
51:06c0262ad689 | 52:034641c26ab9 |
---|---|
328 FILE *fp; | 328 FILE *fp; |
329 char buf[1024]; | 329 char buf[1024]; |
330 int l=0; | 330 int l=0; |
331 if (NULL == (fp = fopen(fname, "rb"))) { | 331 if (NULL == (fp = fopen(fname, "rb"))) { |
332 fprintf(stderr, "Couldn't open file %s\n", fname ); | 332 fprintf(stderr, "Couldn't open file %s\n", fname ); |
333 DEBUG_RET(); | |
333 return 1; | 334 return 1; |
334 } | 335 } |
335 | 336 |
336 while (0 != ( l = fread( buf, 1, 1024, fp))) { | 337 while (0 != ( l = fread( buf, 1, 1024, fp))) { |
337 if (0 != pst_decrypt( buf, l, PST_COMP_ENCRYPT)) | 338 if (0 != pst_decrypt( buf, l, PST_COMP_ENCRYPT)) |
338 fprintf(stderr, "pst_decrypt() failed (I'll try to continue)\n"); | 339 fprintf(stderr, "pst_decrypt() failed (I'll try to continue)\n"); |
339 | 340 |
340 if (l != fwrite( buf, 1, l, stdout)) { | 341 if (l != fwrite( buf, 1, l, stdout)) { |
341 fprintf(stderr, "Couldn't output to stdout?\n"); | 342 fprintf(stderr, "Couldn't output to stdout?\n"); |
343 DEBUG_RET(); | |
342 return 1; | 344 return 1; |
343 } | 345 } |
344 } | 346 } |
347 DEBUG_RET(); | |
345 return 0; | 348 return 0; |
346 } | 349 } |
347 | 350 |
348 if (output_mode != OUTPUT_QUIET) printf("Opening PST file and indexes...\n"); | 351 if (output_mode != OUTPUT_QUIET) printf("Opening PST file and indexes...\n"); |
349 | 352 |
660 | 663 |
661 char *my_stristr(char *haystack, char *needle) { | 664 char *my_stristr(char *haystack, char *needle) { |
662 // my_stristr varies from strstr in that its searches are case-insensitive | 665 // my_stristr varies from strstr in that its searches are case-insensitive |
663 char *x=haystack, *y=needle, *z = NULL; | 666 char *x=haystack, *y=needle, *z = NULL; |
664 DEBUG_ENT("my_stristr"); | 667 DEBUG_ENT("my_stristr"); |
665 if (!haystack || !needle) | 668 if (!haystack || !needle) { |
669 DEBUG_RET(); | |
666 return NULL; | 670 return NULL; |
671 } | |
667 while (*y != '\0' && *x != '\0') { | 672 while (*y != '\0' && *x != '\0') { |
668 if (tolower(*y) == tolower(*x)) { | 673 if (tolower(*y) == tolower(*x)) { |
669 // move y on one | 674 // move y on one |
670 y++; | 675 y++; |
671 if (!z) { | 676 if (!z) { |
685 void check_filename(char *fname) { | 690 void check_filename(char *fname) { |
686 char *t = fname; | 691 char *t = fname; |
687 DEBUG_ENT("check_filename"); | 692 DEBUG_ENT("check_filename"); |
688 if (!t) { | 693 if (!t) { |
689 DEBUG_RET(); | 694 DEBUG_RET(); |
695 return; | |
690 } | 696 } |
691 while ((t = strpbrk(t, "/\\:"))) { | 697 while ((t = strpbrk(t, "/\\:"))) { |
692 // while there are characters in the second string that we don't want | 698 // while there are characters in the second string that we don't want |
693 *t = '_'; //replace them with an underscore | 699 *t = '_'; //replace them with an underscore |
694 } | 700 } |
765 DEBUG_EMAIL(("Attachment Pointer is %p\n", current_attach->data)); | 771 DEBUG_EMAIL(("Attachment Pointer is %p\n", current_attach->data)); |
766 if (current_attach->data) { | 772 if (current_attach->data) { |
767 enc = base64_encode (current_attach->data, current_attach->size); | 773 enc = base64_encode (current_attach->data, current_attach->size); |
768 if (!enc) { | 774 if (!enc) { |
769 DEBUG_EMAIL(("ERROR base64_encode returned NULL. Must have failed\n")); | 775 DEBUG_EMAIL(("ERROR base64_encode returned NULL. Must have failed\n")); |
776 DEBUG_RET(); | |
770 return; | 777 return; |
771 } | 778 } |
772 } | 779 } |
773 if (boundary) { | 780 if (boundary) { |
774 char *attach_filename; | 781 char *attach_filename; |