changeset 120:6395ced2b8b2

disable building pst2dii on cygwin consistent ordering of our include files all system includes protected by ifdef HAVE_ from autoconf
author Carl Byington <carl@five-ten-sg.com>
date Sun, 01 Feb 2009 11:24:22 -0800
parents f50f4321aa2d
children 8399ef94c11b
files ChangeLog configure.in regression/regression-tests.bash src/common.h src/define.h src/dumpblocks.c src/getidblock.c src/libpst.c src/libpst.h src/lspst.c src/lzfu.c src/pst2dii.cpp.in src/pst2ldif.cpp src/readpst.c src/timeconv.h src/vbuf.c src/vbuf.h
diffstat 17 files changed, 241 insertions(+), 251 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Jan 31 12:23:46 2009 -0800
+++ b/ChangeLog	Sun Feb 01 11:24:22 2009 -0800
@@ -1,291 +1,270 @@
 LibPST 0.6.26 (2009-01-31)
 ===============================
-        * patch from Fridrich Strba for building on mingw and
-    	  general cleanup of autoconf files
-	* add processing for pst files of type 0x0f
-	* start adding support for properly building and installing
-          libpst.so and the header files required to use it.
-	* remove version.h since the version number is now in config.h
-	* more const correctness issues regarding getopt()
+    * patch from Fridrich Strba for building on mingw and
+      general cleanup of autoconf files
+    * add processing for pst files of type 0x0f
+    * start adding support for properly building and installing
+      libpst.so and the header files required to use it.
+    * remove version.h since the version number is now in config.h
+    * more const correctness issues regarding getopt()
+    * disable building pst2dii on cygwin, since the convert program
+      on the path is part of windows, not image magic.
+    * consistent ordering of our include files. all systems includes
+      protected by ifdef HAVE_ from autoconf.
 
 LibPST 0.6.25 (2009-01-16)
 ===============================
-        * improve handling of content-type charset values in mime parts
+    * improve handling of content-type charset values in mime parts
 
 LibPST 0.6.24 (2008-12-11)
 ===============================
-        * patch from Chris Eagle to build on cygwin
+    * patch from Chris Eagle to build on cygwin
 
 LibPST 0.6.23 (2008-12-04)
 ===============================
-        * bump version to avoid cvs tagging mistake in fedora
+    * bump version to avoid cvs tagging mistake in fedora
 
 LibPST 0.6.22 (2008-11-28)
 ===============================
-        * patch from David Cuadrado to process emails with type PST_TYPE_OTHER
-        * base64_encode_multiple() may insert newline, needs larger malloc
-	* subject lines shorter than 2 bytes could segfault
+    * patch from David Cuadrado to process emails with type PST_TYPE_OTHER
+    * base64_encode_multiple() may insert newline, needs larger malloc
+    * subject lines shorter than 2 bytes could segfault
 
 LibPST 0.6.21 (2008-10-21)
 ===============================
-        * fix title bug with old schema in pst2ldif.
-	* also escape commas in distinguished names per rfc4514.
+    * fix title bug with old schema in pst2ldif.
+    * also escape commas in distinguished names per rfc4514.
 
 LibPST 0.6.20 (2008-10-09)
 ===============================
-        * add configure option --enable-dii=no to remove dependency on libgd.
-        * many fixes in pst2ldif by Robert Harris.
-        * add -D option to include deleted items, from Justin Greer
-        * fix from Justin Greer to add missing email headers
-        * fix from Justin Greer for my_stristr()
-        * fix for orphan children when building descriptor tree
-        * avoid writing uninitialized data to debug log file
-        * remove unreachable code
-        * create dummy top-of-folder descriptor if needed for corrupt pst files
+    * add configure option --enable-dii=no to remove dependency on libgd.
+    * many fixes in pst2ldif by Robert Harris.
+    * add -D option to include deleted items, from Justin Greer
+    * fix from Justin Greer to add missing email headers
+    * fix from Justin Greer for my_stristr()
+    * fix for orphan children when building descriptor tree
+    * avoid writing uninitialized data to debug log file
+    * remove unreachable code
+    * create dummy top-of-folder descriptor if needed for corrupt pst files
 
 LibPST 0.6.19 (2008-09-14)
 ===============================
-        * Fix base64 encoding that could create long lines
-        * Initial work on a .so shared library from Bharath Acharya.
+    * Fix base64 encoding that could create long lines
+    * Initial work on a .so shared library from Bharath Acharya.
 
 LibPST 0.6.18 (2008-08-28)
 ===============================
-        * Fixes for iconv on Mac from Justin Greer.
+    * Fixes for iconv on Mac from Justin Greer.
 
 LibPST 0.6.17 (2008-08-05)
 ===============================
-        * More fixes for 32/64 bit portability on big endian ppc.
+    * More fixes for 32/64 bit portability on big endian ppc.
 
 LibPST 0.6.16 (2008-08-05)
 ===============================
-        * Use inttypes.h for portable printing of 64 bit items.
+    * Use inttypes.h for portable printing of 64 bit items.
 
 LibPST 0.6.15 (2008-07-30)
 ===============================
-        * Patch from Robert Simpson for file handle leak in error case.
-        * Fix for missing length on lz decompression, bug found by Chris White.
+    * Patch from Robert Simpson for file handle leak in error case.
+    * Fix for missing length on lz decompression, bug found by Chris White.
 
 LibPST 0.6.14 (2008-06-15)
 ===============================
-        * Fix my mistake in debian packaging.
+    * Fix my mistake in debian packaging.
 
 LibPST 0.6.13 (2008-06-13)
 ===============================
-        * Patch from Robert Simpson for encryption type 2.
-        * Fix the order of testing item types to avoid claiming
-        there are multiple message stores.
+    * Patch from Robert Simpson for encryption type 2.
+    * Fix the order of testing item types to avoid claiming
+    there are multiple message stores.
 
 LibPST 0.6.12 (2008-06-10)
 ===============================
-        * Patch from Joachim Metz for debian packaging, and fix
-        for incorrect length on lz decompression.
+    * Patch from Joachim Metz for debian packaging, and fix
+    for incorrect length on lz decompression.
 
 LibPST 0.6.11 (2008-06-03)
 ===============================
-        * Use ftello/fseeko to properly handle large files.
-        * Document and properly use datasize field in b5 blocks.
-        * Fix some MSVC compile issues and collect MSVC dependencies into one place.
+    * Use ftello/fseeko to properly handle large files.
+    * Document and properly use datasize field in b5 blocks.
+    * Fix some MSVC compile issues and collect MSVC dependencies into one place.
 
 LibPST 0.6.10 (2008-05-29)
 ===============================
-        * Patch from Robert Simpson <rsimpson@idiscoverglobal.com>
-        fix doubly-linked list in the cache_ptr code, and allow
-        arrays of unicode strings (without converting them).
-        * More changes for Fedora packaging (#434727)
-        * Fixes for const correctness.
+    * Patch from Robert Simpson <rsimpson@idiscoverglobal.com>
+    fix doubly-linked list in the cache_ptr code, and allow
+    arrays of unicode strings (without converting them).
+    * More changes for Fedora packaging (#434727)
+    * Fixes for const correctness.
 
 LibPST 0.6.9 (2008-05-16)
 ===============================
-        * Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit
-        compile.
-        * Signed/unsigned cleanup from 'CFLAGS=-Wextra ./configure'.
-        * Reindent vbuf.c to make it readable.
-        * Fix pst format documentation for 8 byte backpointers.
+    * Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit
+      compile.
+    * Signed/unsigned cleanup from 'CFLAGS=-Wextra ./configure'.
+    * Reindent vbuf.c to make it readable.
+    * Fix pst format documentation for 8 byte backpointers.
 
 LibPST 0.6.8 (2008-03-05)
 ===============================
-        * Initial version of pst2dii to convert to Summation dii load file format.
-        * Changes for Fedora packaging (#434727)
+    * Initial version of pst2dii to convert to Summation dii load file format.
+    * Changes for Fedora packaging (#434727)
 
 LibPST 0.6.7 (2008-02-16)
 ===============================
-        * Work around bogus 7c.b5 blocks in some messages that have been
-        read. They appear to have attachments, but of some unknown format.
-        Before the message was read, it did not have any attachments.
-        * Use autoscan to cleanup our autoconf system.
-        * Use autoconf to detect when we need to use our XGetopt files
-        and other header files.
-        * More fields, including BCC.
-        * Fix missing LE32_CPU byte swapping for FILETIME types.
+    * Work around bogus 7c.b5 blocks in some messages that have been
+      read. They appear to have attachments, but of some unknown format.
+      Before the message was read, it did not have any attachments.
+    * Use autoscan to cleanup our autoconf system.
+    * Use autoconf to detect when we need to use our XGetopt files
+      and other header files.
+    * More fields, including BCC.
+    * Fix missing LE32_CPU byte swapping for FILETIME types.
 
 LibPST 0.6.6 (2008-01-31)
 ===============================
-
-        * More code cleanup, removing unnecessary null terminations on
-        binary buffers. All pst file reads now go thru one function.
-        Logging all pst reads to detect cases where we read the same data
-        multiple times - discovers node sizes are actually 512 bytes.
-        * Switch from cvs to mercurial source control.
+    * More code cleanup, removing unnecessary null terminations on
+      binary buffers. All pst file reads now go thru one function.
+      Logging all pst reads to detect cases where we read the same data
+      multiple times - discovers node sizes are actually 512 bytes.
+    * Switch from cvs to mercurial source control.
 
 LibPST 0.6.5 (2008-01-22)
 ===============================
-
-        * More code cleanup, removing obsolete code. All the boolean flags
-        of type 0xb have length 4, so these are all 32 bits in the file.
-        Libpst treats them all as 16 bits, but at least we are consistent.
-        * More fields decoded - for example, see
-        <http://msdn2.microsoft.com/en-us/library/aa454925.aspx>
-        We should be able to use that data for much more complete decoding.
-        * Move the rpm group to Applications/Productivity consistent with
-        Evolution.
+    * More code cleanup, removing obsolete code. All the boolean flags
+      of type 0xb have length 4, so these are all 32 bits in the file.
+      Libpst treats them all as 16 bits, but at least we are consistent.
+    * More fields decoded - for example, see
+      <http://msdn2.microsoft.com/en-us/library/aa454925.aspx>
+      We should be able to use that data for much more complete decoding.
+    * Move the rpm group to Applications/Productivity consistent with
+      Evolution.
 
 LibPST 0.6.4 (2008-01-19)
 ===============================
-
-        * More fixes for Outlook 2003 64 bit parsing. We observed cases of
-        compressed RTF bodies (type 0x1009) with zero length.
-        * Document type 0x0101 descriptor blocks and process them.
-        * Fix large file support - we need to include config.h before any
-        standard headers.
-        * Merge following changes from svn snapshot from Alioth:
-            * Add new fields to appointment for recurring events
-              (SourceForge #304198)
-            * Map IPM.Task items to PST_TYPE_TASK.
-            * Applied patch to remove compiler warnings, thanks!
-              (SourceForge #304314)
-            * Fix crash with unknown reference type
-            * Fix more memory issues detected by valgrind
-            * lspst - add usage mesage and option parsing using getopt
-                (SourceForge #304199)
-            * Fix crash caused by invalid free calls
-            * Fix crash when email subject is empty
-            * Fix memory and information leak in hex debug dump
+    * More fixes for Outlook 2003 64 bit parsing. We observed cases of
+      compressed RTF bodies (type 0x1009) with zero length.
+    * Document type 0x0101 descriptor blocks and process them.
+    * Fix large file support - we need to include config.h before any
+      standard headers.
+    * Merge following changes from svn snapshot from Alioth:
+        * Add new fields to appointment for recurring events
+          (SourceForge #304198)
+        * Map IPM.Task items to PST_TYPE_TASK.
+        * Applied patch to remove compiler warnings, thanks!
+          (SourceForge #304314)
+        * Fix crash with unknown reference type
+        * Fix more memory issues detected by valgrind
+        * lspst - add usage mesage and option parsing using getopt
+            (SourceForge #304199)
+        * Fix crash caused by invalid free calls
+        * Fix crash when email subject is empty
+        * Fix memory and information leak in hex debug dump
 
 LibPST 0.6.3 (2008-01-13)
 ===============================
-
-        * More type consistency issues found by splint.
+    * More type consistency issues found by splint.
 
 LibPST 0.6.2 (2008-01-12)
 ===============================
-
-        * More fixes for Outlook 2003 64 bit parsing.
-        * All buffer sizes changed to size_t, all file offsets changed to off_t,
-        all function names start with pst_, many other type consistency issues
-        found by splint. Many changes to #llx in debug printing for 64 bit items.
-        All id values are now uint64_t.
+    * More fixes for Outlook 2003 64 bit parsing.
+    * All buffer sizes changed to size_t, all file offsets changed to off_t,
+      all function names start with pst_, many other type consistency issues
+      found by splint. Many changes to #llx in debug printing for 64 bit items.
+      All id values are now uint64_t.
 
 LibPST 0.6.1 (2008-01-06)
 ===============================
-
-        * Outlook 2003 64 bit parsing. Some documentation from Alexander Grau
-        <alexandergrau@gmx.de> and patches from Sean Loaring <sloaring@tec-man.com>.
-        * fix from Antonio Palama <palama@inwind.it> for email items
-        that happen to have item->contact non null, and were being processed
-        as contacts.
-        * Add large file support so we can read .pst files larger than 2gb.
-        * Change lspst to be similar to readpst, properly using recursion to walk
-        the tree, and testing item types. Add a man page for lspst.
+    * Outlook 2003 64 bit parsing. Some documentation from Alexander Grau
+      <alexandergrau@gmx.de> and patches from Sean Loaring <sloaring@tec-man.com>.
+    * fix from Antonio Palama <palama@inwind.it> for email items
+      that happen to have item->contact non null, and were being processed
+      as contacts.
+    * Add large file support so we can read .pst files larger than 2gb.
+    * Change lspst to be similar to readpst, properly using recursion to walk
+      the tree, and testing item types. Add a man page for lspst.
 
 LibPST 0.5.12 (2007-10-02)
 ===============================
-
-        * security fix from Brad Hards <bradh@frogmouth.net> for buffer
-        overruns in liv-zemple decoding for corrupted or malicious pst files.
+    * security fix from Brad Hards <bradh@frogmouth.net> for buffer
+      overruns in liv-zemple decoding for corrupted or malicious pst files.
 
 LibPST 0.5.11 (2007-08-24)
 ===============================
-
-        * fix from Stevens Miller <smiller@novadatalabs.com>
-        for unitialized variable.
+    * fix from Stevens Miller <smiller@novadatalabs.com>
+      for unitialized variable.
 
 LibPST 0.5.10 (2007-08-20)
 ===============================
-
-        * fix yet more valgrind errors - finally have a clean memory check.
-        * restructure readpst.c for proper recursive tree walk.
-        * buffer overrun test was backwards, introduced at 0.5.6
-        * fix broken email attachments, introduced at 0.5.6
+    * fix yet more valgrind errors - finally have a clean memory check.
+    * restructure readpst.c for proper recursive tree walk.
+    * buffer overrun test was backwards, introduced at 0.5.6
+    * fix broken email attachments, introduced at 0.5.6
 
 LibPST 0.5.9 (2007-08-12)
 ===============================
-
-        * fix more valgrind errors.
+    * fix more valgrind errors.
 
 LibPST 0.5.8 (2007-08-10)
 ===============================
-
-        * fix more valgrind errors. lzfu_decompress needs to return the
-        actual buffer size, since the lz header overestimates the size.
-        This caused base64_encode to encode undefined bytes into the
-        email attachment.
+    * fix more valgrind errors. lzfu_decompress needs to return the
+      actual buffer size, since the lz header overestimates the size.
+      This caused base64_encode to encode undefined bytes into the
+      email attachment.
 
 LibPST 0.5.7 (2007-08-09)
 ===============================
-
-        * fix valgrind errors, using uninitialized data.
-        * improve debug logging and readpstlog for indented listings.
-        * cleanup documentation.
+    * fix valgrind errors, using uninitialized data.
+    * improve debug logging and readpstlog for indented listings.
+    * cleanup documentation.
 
 LibPST 0.5.6 (2007-07-15)
 ===============================
-
-        * Fix to allow very small pst files with only one node in the
-        tree. We were mixing signed/unsigned types in comparisons.
-        * More progress decoding the basic structure 7c blocks. Many
-        four byte values may be ID2 indices with data outside the buffer.
-        * Start using doxygen to generate internal documentation.
+    * Fix to allow very small pst files with only one node in the
+      tree. We were mixing signed/unsigned types in comparisons.
+    * More progress decoding the basic structure 7c blocks. Many
+      four byte values may be ID2 indices with data outside the buffer.
+    * Start using doxygen to generate internal documentation.
 
 LibPST 0.5.5 (2007-07-10)
 ===============================
-
-        * merge the following changes from Joe Nahmias version:
-        * Lots of memory fixes.  Thanks to Nigel Horne for his assistance
-        tracking these down!
-        * Fixed creation of vCards from contacts, thanks to Nigel Horne for
-        his help with this!
-        * fix for MIME multipart/alternative attachments.
-        * added -c options to readpst manpage.
-        * use 8.3 attachment filename if long filename isn't available.
-        * new -b option to skip rtf-body.rtf attachments.
-        * fix format of From header lines in mbox files.
-        * Add more appointment fields, thanks to Chris Halls for tracking
-        them down!
-
+    * merge the following changes from Joe Nahmias version:
+    * Lots of memory fixes.  Thanks to Nigel Horne for his assistance
+      tracking these down!
+    * Fixed creation of vCards from contacts, thanks to Nigel Horne for
+      his help with this!
+    * fix for MIME multipart/alternative attachments.
+    * added -c options to readpst manpage.
+    * use 8.3 attachment filename if long filename isn't available.
+    * new -b option to skip rtf-body.rtf attachments.
+    * fix format of From header lines in mbox files.
+    * Add more appointment fields, thanks to Chris Halls for tracking
+      them down!
 
 LibPST 0.5.4 (2006-02-25)
 ===============================
-
-        * patches from Arne, adding MH mode, remove leading zeros
-        from the generated numbered filenames starting with one
-        rather than zero. Miscellaneous code cleanup.
-
-        * document the "7c" descriptor block format.
+    * patches from Arne, adding MH mode, remove leading zeros
+      from the generated numbered filenames starting with one
+      rather than zero. Miscellaneous code cleanup.
+    * document the "7c" descriptor block format.
 
 LibPST 0.5.3 (2006-02-20)
 ===============================
-
-        * switch to gnu autoconf/automake. This breaks the MS VC++ projects
-        since the source code is now in the src subdirectory.
-
-        * documentation switched to xml, building man pages and html
-        from the master xml copy.
-
-        * include rpm .spec file for building src and binary rpms.
-
+    * switch to gnu autoconf/automake. This breaks the MS VC++ projects
+      since the source code is now in the src subdirectory.
+    * documentation switched to xml, building man pages and html
+      from the master xml copy.
+    * include rpm .spec file for building src and binary rpms.
 
 LibPST 0.5.2 (2006-02-18)
 ===============================
-
-        * Added pst2ldif to convert the contacts to ldif format for import
-        into ldap databases.
-
-        * Major changes to libpst.c to properly use the node depth values
-        from the b-tree nodes. We also use the item count values in the nodes
-        rather than trying to guess how many items are active.
-
-        * Cleanup whitespace - using tabs for every four columns.
-
+    * Added pst2ldif to convert the contacts to ldif format for import
+      into ldap databases.
+    * Major changes to libpst.c to properly use the node depth values
+      from the b-tree nodes. We also use the item count values in the nodes
+      rather than trying to guess how many items are active.
+    * Cleanup whitespace - using tabs for every four columns.
 
 LibPST 0.5.1 (17 November 2004)
 ===============================
--- a/configure.in	Sat Jan 31 12:23:46 2009 -0800
+++ b/configure.in	Sun Feb 01 11:24:22 2009 -0800
@@ -7,12 +7,16 @@
 
 AC_CANONICAL_HOST
 
-# Check for Win32
+# Check for win32 which needs iconv library specified on the link line
 AC_MSG_CHECKING([for Win32])
 case "$host" in
     *-mingw*)
         os_win32=yes
         ;;
+    *cygwin*)
+        os_win32=yes
+        enable_dii=no   # cygwin would find windir/system32/convert, not image magick convert
+        ;;
     *)
         os_win32=no
         ;;
@@ -80,7 +84,7 @@
     )
 AC_HEADER_DIRENT
 AC_HEADER_STDC
-AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h stdint.h stdlib.h string.h sys/param.h unistd.h wchar.h])
+AC_CHECK_HEADERS([ctype.h dirent.h errno.h fcntl.h inttypes.h limits.h signal.h stdarg.h stdint.h stdio.h stdlib.h string.h sys/param.h sys/stat.h sys/types.h time.h unistd.h wchar.h])
 
 # Checks for typedefs, structures, and compiler characteristics.
 AC_HEADER_STDBOOL
--- a/regression/regression-tests.bash	Sat Jan 31 12:23:46 2009 -0800
+++ b/regression/regression-tests.bash	Sun Feb 01 11:24:22 2009 -0800
@@ -21,7 +21,7 @@
     ba=$(basename "$fn" .pst)
     rm -rf output$n
     mkdir output$n
-    #../src/readpst -cv -o output$n $fn >$ba.err 2>&1
+    #    ../src/readpst -cv -o output$n $fn >$ba.err 2>&1
     $val ../src/readpst -cv -o output$n -d dumper $fn >$ba.err 2>&1
          ../src/readpstlog -f I dumper >$ba.log
     #$val ../src/pst2ldif -d dumper -b 'o=ams-cc.com, c=US' -c 'newPerson' -o $fn >$ba.ldif.err 2>&1
@@ -33,7 +33,7 @@
 
 
 val="valgrind --leak-check=full"
-val=''
+#val=''
 
 pushd ..
 make || exit
@@ -60,7 +60,7 @@
    #dopst  13 test-text.pst
    #dopst  14 joe.romanowski.pst
    #dopst  15 hourig1.pst
-   #dopst  16 hourig2.pst
+   dopst  16 hourig2.pst
    dopst  17 hourig3.pst
 fi
 
--- a/src/common.h	Sat Jan 31 12:23:46 2009 -0800
+++ b/src/common.h	Sun Feb 01 11:24:22 2009 -0800
@@ -11,7 +11,7 @@
 # pragma pack (1)
 
 #ifndef FILETIME_DEFINED
-#define FILETIME_DEFINED
+    #define FILETIME_DEFINED
     /*Win32 Filetime struct - copied from WINE*/
     typedef struct {
         DWORD  dwLowDateTime;
--- a/src/define.h	Sat Jan 31 12:23:46 2009 -0800
+++ b/src/define.h	Sun Feb 01 11:24:22 2009 -0800
@@ -5,6 +5,9 @@
  *            dave.s@earthcorp.com
  */
 
+#ifndef DEFINEH_H
+#define DEFINEH_H
+
 #ifdef HAVE_CONFIG_H
     #include <libpst/config.h>
 #endif
@@ -15,9 +18,6 @@
     #define HAVE_WINDOWS_H
 #endif
 
-#ifndef DEFINEH_H
-#define DEFINEH_H
-
 #define DEBUG_MODE_GEN
 #define DEBUGPRINT
 #define DEBUG_MODE_WARN
@@ -45,16 +45,46 @@
 #define DEBUG_FUNCRET_NO 10
 #define DEBUG_HEXDUMP_NO 11
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <time.h>
-#include <string.h>
-#include <ctype.h>
-#include <limits.h>
-#include <wchar.h>
-#include <signal.h>
-#include <errno.h>
+#ifdef HAVE_STDIO_H
+    #include <stdio.h>
+#endif
+
+#ifdef HAVE_STDLIB_H
+    #include <stdlib.h>
+#endif
+
+#ifdef HAVE_STDARG_H
+    #include <stdarg.h>
+#endif
+
+#ifdef HAVE_TIME_H
+    #include <time.h>
+#endif
+
+#ifdef HAVE_STRING_H
+    #include <string.h>
+#endif
+
+#ifdef HAVE_CTYPE_H
+    #include <ctype.h>
+#endif
+
+#ifdef HAVE_LIMITS_H
+    #include <limits.h>
+#endif
+
+#ifdef HAVE_WCHAR_H
+    #include <wchar.h>
+#endif
+
+#ifdef HAVE_SIGNAL_H
+    #include <signal.h>
+#endif
+
+#ifdef HAVE_ERRNO_H
+    #include <errno.h>
+#endif
+
 
 #define PERM_DIRS 0777
 
@@ -103,6 +133,9 @@
 
     #include <windows.h>
 #else
+    #ifdef HAVE_STDINT_H
+        #include <stdint.h>
+    #endif
     #ifdef HAVE_INTTYPES_H
         #include <inttypes.h>
     #endif
--- a/src/dumpblocks.c	Sat Jan 31 12:23:46 2009 -0800
+++ b/src/dumpblocks.c	Sun Feb 01 11:24:22 2009 -0800
@@ -1,8 +1,5 @@
 #include "define.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
+#include "common.h"
 #include "libpst.h"
 
 #define OUT_BUF 20
--- a/src/getidblock.c	Sat Jan 31 12:23:46 2009 -0800
+++ b/src/getidblock.c	Sun Feb 01 11:24:22 2009 -0800
@@ -1,5 +1,6 @@
 
 #include "define.h"
+#include "common.h"
 #include "libpst.h"
 
 static void usage();
--- a/src/libpst.c	Sat Jan 31 12:23:46 2009 -0800
+++ b/src/libpst.c	Sun Feb 01 11:24:22 2009 -0800
@@ -6,11 +6,11 @@
  */
 
 #include "define.h"
+#include "common.h"
+#include "libpst.h"
+#include "timeconv.h"
 #include "libstrfunc.h"
 #include "vbuf.h"
-#include "libpst.h"
-#include "common.h"
-#include "timeconv.h"
 
 #define ASSERT(x) { if(!(x)) raise( SIGSEGV ); }
 
--- a/src/libpst.h	Sat Jan 31 12:23:46 2009 -0800
+++ b/src/libpst.h	Sun Feb 01 11:24:22 2009 -0800
@@ -10,25 +10,14 @@
 #ifndef LIBPST_H
 #define LIBPST_H
 
-#ifndef  _WIN32
-    #include <stdint.h>
-    #include <inttypes.h>
-    #ifndef FILETIME_DEFINED
-	#define FILETIME_DEFINED
-	//Win32 Filetime struct - copied from WINE
-	typedef struct {
-	  uint32_t dwLowDateTime;
-	  uint32_t dwHighDateTime;
-	} FILETIME;
-    #endif
-#endif
-
 // According to Jan Wolter, sys/param.h is the most portable source of endian
 // information on UNIX systems. see http://www.unixpapa.com/incnote/byteorder.html
 #ifdef _WIN32
-  #define BYTE_ORDER LITTLE_ENDIAN
+    #define BYTE_ORDER LITTLE_ENDIAN
 #else
-  #include <sys/param.h>
+    #ifdef HAVE_SYS_PARAM_H
+        #include <sys/param.h>
+    #endif
 #endif // defined _WIN32
 
 #if BYTE_ORDER == BIG_ENDIAN
--- a/src/lspst.c	Sat Jan 31 12:23:46 2009 -0800
+++ b/src/lspst.c	Sun Feb 01 11:24:22 2009 -0800
@@ -7,17 +7,8 @@
  */
 
 #include "define.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
-#include <string.h>
-#include <ctype.h>
-#include <errno.h>
-#include <unistd.h>
-
+#include "common.h"
 #include "libpst.h"
-#include "common.h"
 #include "timeconv.h"
 
 struct file_ll {
--- a/src/lzfu.c	Sat Jan 31 12:23:46 2009 -0800
+++ b/src/lzfu.c	Sun Feb 01 11:24:22 2009 -0800
@@ -10,13 +10,14 @@
   */
 
 #include "define.h"
+#include "common.h"
 #include "libpst.h"
+#include "lzfu.h"
 
-#include <sys/types.h>
-#include <string.h>
-#include <stdio.h>
+#ifdef HAVE_SYS_TYPES_H
+    #include <sys/types.h>
+#endif
 
-#include "lzfu.h"
 
 #define LZFU_COMPRESSED 		0x75465a4c
 #define LZFU_UNCOMPRESSED		0x414c454d
--- a/src/pst2dii.cpp.in	Sat Jan 31 12:23:46 2009 -0800
+++ b/src/pst2dii.cpp.in	Sun Feb 01 11:24:22 2009 -0800
@@ -18,11 +18,11 @@
 
 extern "C" {
     #include "define.h"
-    #include "libstrfunc.h"
+    #include "common.h"
     #include "libpst.h"
-    #include "common.h"
     #include "timeconv.h"
     #include "lzfu.h"
+    #include "libstrfunc.h"
 }
 
 struct file_ll {
--- a/src/pst2ldif.cpp	Sat Jan 31 12:23:46 2009 -0800
+++ b/src/pst2ldif.cpp	Sun Feb 01 11:24:22 2009 -0800
@@ -17,13 +17,12 @@
 
 extern "C" {
     #include "define.h"
-    #include "libstrfunc.h"
+    #include "common.h"
     #include "libpst.h"
-    #include "common.h"
     #include "timeconv.h"
     #include "lzfu.h"
-    #include "stdarg.h"
-    #include "iconv.h"
+    #include "libstrfunc.h"
+    #include "vbuf.h"
 }
 
 void       usage(void);
--- a/src/readpst.c	Sat Jan 31 12:23:46 2009 -0800
+++ b/src/readpst.c	Sun Feb 01 11:24:22 2009 -0800
@@ -5,12 +5,12 @@
  *            dave.s@earthcorp.com
  */
 #include "define.h"
+#include "common.h"
+#include "libpst.h"
+#include "timeconv.h"
+#include "lzfu.h"
 #include "libstrfunc.h"
 #include "vbuf.h"
-#include "libpst.h"
-#include "common.h"
-#include "timeconv.h"
-#include "lzfu.h"
 
 #define OUTPUT_TEMPLATE "%s"
 #define OUTPUT_KMAIL_DIR_TEMPLATE ".%s.directory"
@@ -1080,6 +1080,7 @@
                 DEBUG_EMAIL(("Failed to convert plain text utf-8 to %s\n", item->email->body_charset));
             }
             else {
+                // unable to convert, maybe it is already in that character set
                 free(item->email->body);
                 item->email->body = newer->b;
             }
--- a/src/timeconv.h	Sat Jan 31 12:23:46 2009 -0800
+++ b/src/timeconv.h	Sun Feb 01 11:24:22 2009 -0800
@@ -1,8 +1,6 @@
 #ifndef __TIMECONV_H
 #define __TIMECONV_H
 
-#include <time.h>
-
 #ifdef __cplusplus
 extern "C" {
 #endif
--- a/src/vbuf.c	Sat Jan 31 12:23:46 2009 -0800
+++ b/src/vbuf.c	Sun Feb 01 11:24:22 2009 -0800
@@ -98,7 +98,7 @@
 
     if (-1 == len) {
         vshexdump(errbuf, str, 0, length, 1);
-        WARN(("String is not zero terminated (probably broken data from registry) %s.", errbuf->b));
+        DEBUG_WARN(("String is not zero terminated (probably broken data from registry) %s.\n", errbuf->b));
     }
 
     return (-1 == len) ? 0 : 1;
@@ -130,7 +130,7 @@
     } while ((size_t)-1 == icresult && E2BIG == errno);
 
     if (icresult == (size_t)-1) {
-        WARN(("iconv failure: %s", strerror(errno)));
+        DEBUG_WARN(("iconv failure: %s\n", strerror(errno)));
         unicode_init();
         return (size_t)-1;
     }
@@ -170,7 +170,7 @@
     } while ((size_t)-1 == icresult && E2BIG == errno);
 
     if (icresult == (size_t)-1) {
-        WARN(("iconv failure: %s", strerror(errno)));
+        WARN(("iconv failure: %s\n", strerror(errno)));
         unicode_init();
         return (size_t)-1;
     }
--- a/src/vbuf.h	Sat Jan 31 12:23:46 2009 -0800
+++ b/src/vbuf.h	Sun Feb 01 11:24:22 2009 -0800
@@ -12,9 +12,6 @@
 #ifndef VBUF_H
 #define VBUF_H
 #define SZ_MAX     4096
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdarg.h>
 /***************************************************/