changeset 316:c4537664ff50

merge .msg generation code
author Carl Byington <carl@five-ten-sg.com>
date Mon, 24 Dec 2012 17:51:12 -0800
parents db6db9a26a19 (diff) 3e6cdd543857 (current diff)
children af6ae20be5ba
files ChangeLog NEWS configure.in libpst.spec.in regression/regression-tests.bash src/Makefile.am src/libpst.c src/libpst.h src/readpst.c xml/libpst.in
diffstat 32 files changed, 1856 insertions(+), 644 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Thu Jun 03 19:09:29 2010 -0700
+++ b/.hgtags	Mon Dec 24 17:51:12 2012 -0800
@@ -54,3 +54,11 @@
 093e0e9248bb63b52d59af0a97bd80cc2be702dc stable-0-6-43
 75a27d2add601818909bc6dd624bfa55ad98b960 stable-0-6-44
 67b24d6a45d6d31ac49ddd4ef4117959c30975d2 stable-0-6-45
+f2ae612fa62b3702429669414619cba95b52a38e stable-0-6-46
+c47bba52460f0f2288e5d561c7b38873a6848868 stable-0-6-47
+ab87f9070ed280a36bee70172ece6980b3aa4a01 stable-0-6-49
+345dab73b5c881d52ecd4e1e1f053d8877ee9556 stable-0-6-51
+6a9f92d4e449a52619cb9f380dee8c6b4d8f1459 stable-0-6-52
+54cd1f6b215262591a43bfe1f9b2017e5b7ba81e stable-0-6-53
+507a42e3c48ec27b736b649f0584595610ebf709 stable-0-6-54
+996f314adeec09defd50e39b0c13114fb7f6b4c0 stable-0-6-55
--- a/AUTHORS	Thu Jun 03 19:09:29 2010 -0700
+++ b/AUTHORS	Mon Dec 24 17:51:12 2012 -0800
@@ -32,7 +32,8 @@
     Roberto Polli <robipolli@gmail.com>
     Lee Ayres <ayres@interhack.com>
     Hugo DesRosiers <info@akralogic.com>
-
+    Kenneth Berland <ken@hero.com>
+    Leo 'costela' Antunes <costela@debian.org>
 
 Testing team:
     Mac OSX - Michael Watson <mike@mikeandgayle.com>
--- a/COPYING	Thu Jun 03 19:09:29 2010 -0700
+++ b/COPYING	Mon Dec 24 17:51:12 2012 -0800
@@ -1,12 +1,12 @@
-		    GNU GENERAL PUBLIC LICENSE
-		       Version 2, June 1991
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 2, June 1991
 
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
-                          675 Mass Ave, Cambridge, MA 02139, USA
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  Everyone is permitted to copy and distribute verbatim copies
  of this license document, but changing it is not allowed.
 
-			    Preamble
+                            Preamble
 
   The licenses for most software are designed to take away your
 freedom to share and change it.  By contrast, the GNU General Public
@@ -15,7 +15,7 @@
 General Public License applies to most of the Free Software
 Foundation's software and to any other program whose authors commit to
 using it.  (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.)  You can apply it to
+the GNU Lesser General Public License instead.)  You can apply it to
 your programs, too.
 
   When we speak of free software, we are referring to freedom, not
@@ -55,8 +55,8 @@
 
   The precise terms and conditions for copying, distribution and
 modification follow.
-
-		    GNU GENERAL PUBLIC LICENSE
+
+                    GNU GENERAL PUBLIC LICENSE
    TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
 
   0. This License applies to any program or other work which contains
@@ -110,7 +110,7 @@
     License.  (Exception: if the Program itself is interactive but
     does not normally print such an announcement, your work based on
     the Program is not required to print an announcement.)
-
+
 These requirements apply to the modified work as a whole.  If
 identifiable sections of that work are not derived from the Program,
 and can be reasonably considered independent and separate works in
@@ -168,7 +168,7 @@
 access to copy the source code from the same place counts as
 distribution of the source code, even though third parties are not
 compelled to copy the source along with the object code.
-
+
   4. You may not copy, modify, sublicense, or distribute the Program
 except as expressly provided under this License.  Any attempt
 otherwise to copy, modify, sublicense or distribute the Program is
@@ -225,7 +225,7 @@
 
 This section is intended to make thoroughly clear what is believed to
 be a consequence of the rest of this License.
-
+
   8. If the distribution and/or use of the Program is restricted in
 certain countries either by patents or by copyrighted interfaces, the
 original copyright holder who places the Program under this License
@@ -255,7 +255,7 @@
 of preserving the free status of all derivatives of our free software and
 of promoting the sharing and reuse of software generally.
 
-			    NO WARRANTY
+                            NO WARRANTY
 
   11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
 FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
@@ -277,4 +277,4 @@
 PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
 POSSIBILITY OF SUCH DAMAGES.
 
-		     END OF TERMS AND CONDITIONS
+                     END OF TERMS AND CONDITIONS
--- a/ChangeLog	Thu Jun 03 19:09:29 2010 -0700
+++ b/ChangeLog	Mon Dec 24 17:51:12 2012 -0800
@@ -1,3 +1,59 @@
+LibPST 0.6.55 (2012-05-08)
+===============================
+    * preserve bcc headers
+    * document -C switch to set default character set
+    * space after colon is not required in header fields
+
+LibPST 0.6.54 (2011-11-04)
+===============================
+    * embedded rfc822 messages might contain rtf encoded bodies
+
+LibPST 0.6.53 (2011-07-10)
+===============================
+    * add Status: header in output
+    * allow fork for parallel processing of individual email folders
+      in separate mode
+    * proper handling of --with-boost-python option
+
+LibPST 0.6.52 (2011-05-22)
+===============================
+    * fix dangling freed pointer in embedded rfc822 message processing
+    * allow broken outlook internet header field - it sometimes contains
+      fragments of the message body rather than headers
+
+LibPST 0.6.51 (2011-04-17)
+===============================
+    * fix for buffer overrun; attachment size from the secondary
+      list of mapi elements overwrote proper size from the primary
+      list of mapi elements.
+      fedora bugzilla 696263
+
+LibPST 0.6.50 (2010-12-24)
+===============================
+    * rfc2047 and rfc2231 encoding for non-ascii headers and attachment filenames
+
+LibPST 0.6.49 (2010-09-13)
+===============================
+    * fix to ignore embedded objects that are not email messages
+
+LibPST 0.6.48 (2010-09-02)
+===============================
+    * fix for broken internet headers from Outlook.
+    * fix ax_python.m4 to look for python2.7
+    * Subpackage Licensing, add COPYING to -libs.
+    * use mboxrd from quoting for output formats with multiple messages per file
+    * use no from quoting for output formats with single message per file
+
+LibPST 0.6.47 (2010-05-07)
+===============================
+    * patches from Kenneth Berland for solaris.
+    * fix output file name numbering to start at 1 rather than 2.
+
+LibPST 0.6.46 (2010-02-13)
+===============================
+    * prefer libpthread over librt for finding sem_init function.
+    * rebuild for fedora 13 change in implicit dso linking semantics.
+
 LibPST 0.6.48 (2010-05-24)
 ===============================
     * fix to/cc/bcc recipients in .msg file output format
--- a/Doxyfile	Thu Jun 03 19:09:29 2010 -0700
+++ b/Doxyfile	Mon Dec 24 17:51:12 2012 -0800
@@ -1,4 +1,4 @@
-# Doxyfile 1.3.9.1
+# Doxyfile 1.6.1
 
 # This file describes the settings to be used by the documentation system
 # doxygen (www.doxygen.org) for a project
@@ -14,6 +14,14 @@
 # Project related configuration options
 #---------------------------------------------------------------------------
 
+# This tag specifies the encoding used for all characters in the config file
+# that follow. The default is UTF-8 which is also the encoding used for all
+# text before the first occurrence of this tag. Doxygen uses libiconv (or the
+# iconv built into libc) for the transcoding. See
+# http://www.gnu.org/software/libiconv for the list of possible encodings.
+
+DOXYFILE_ENCODING      = UTF-8
+
 # The PROJECT_NAME tag is a single word (or a sequence of words surrounded
 # by quotes) that should identify the project.
 
@@ -35,9 +43,9 @@
 # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
 # 4096 sub-directories (in 2 levels) under the output directory of each output
 # format and will distribute the generated files over these directories.
-# Enabling this option can be useful when feeding doxygen a huge amount of source
-# files, where putting all generated files in the same directory would otherwise
-# cause performance problems for the file system.
+# Enabling this option can be useful when feeding doxygen a huge amount of
+# source files, where putting all generated files in the same directory would
+# otherwise cause performance problems for the file system.
 
 CREATE_SUBDIRS         = NO
 
@@ -45,24 +53,15 @@
 # documentation generated by doxygen is written. Doxygen will use this
 # information to generate all constant output in the proper language.
 # The default language is English, other supported languages are:
-# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish,
-# Dutch, Finnish, French, German, Greek, Hungarian, Italian, Japanese,
-# Japanese-en (Japanese with English messages), Korean, Korean-en, Norwegian,
-# Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish,
-# Swedish, and Ukrainian.
+# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,
+# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German,
+# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English
+# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian,
+# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak,
+# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.
 
 OUTPUT_LANGUAGE        = English
 
-# This tag can be used to specify the encoding used in the generated output.
-# The encoding is not always determined by the language that is chosen,
-# but also whether or not the output is meant for Windows or non-Windows users.
-# In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES
-# forces the Windows encoding (this is the default for the Windows binary),
-# whereas setting the tag to NO uses a Unix-style encoding (the default for
-# all platforms other than Windows).
-
-USE_WINDOWS_ENCODING   = NO
-
 # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
 # include brief member descriptions after the members that are listed in
 # the file and class documentation (similar to JavaDoc).
@@ -80,11 +79,12 @@
 # This tag implements a quasi-intelligent brief description abbreviator
 # that is used to form the text in various listings. Each string
 # in this list, if found as the leading text of the brief description, will be
-# stripped from the text and the result after processing the whole list, is used
-# as the annotated text. Otherwise, the brief description is used as-is. If left
-# blank, the following values are used ("$name" is automatically replaced with the
-# name of the entity): "The $name class" "The $name widget" "The $name file"
-# "is" "provides" "specifies" "contains" "represents" "a" "an" "the"
+# stripped from the text and the result after processing the whole list, is
+# used as the annotated text. Otherwise, the brief description is used as-is.
+# If left blank, the following values are used ("$name" is automatically
+# replaced with the name of the entity): "The $name class" "The $name widget"
+# "The $name file" "is" "provides" "specifies" "contains"
+# "represents" "a" "an" "the"
 
 ABBREVIATE_BRIEF       =
 
@@ -94,10 +94,10 @@
 
 ALWAYS_DETAILED_SEC    = NO
 
-# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all inherited
-# members of a class in the documentation of that class as if those members were
-# ordinary class members. Constructors, destructors and assignment operators of
-# the base classes will not be shown.
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
+# inherited members of a class in the documentation of that class as if those
+# members were ordinary class members. Constructors, destructors and assignment
+# operators of the base classes will not be shown.
 
 INLINE_INHERITED_MEMB  = NO
 
@@ -134,11 +134,19 @@
 # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
 # will interpret the first line (until the first dot) of a JavaDoc-style
 # comment as the brief description. If set to NO, the JavaDoc
-# comments will behave just like the Qt-style comments (thus requiring an
-# explicit @brief command for a brief description.
+# comments will behave just like regular Qt-style comments
+# (thus requiring an explicit @brief command for a brief description.)
 
 JAVADOC_AUTOBRIEF      = YES
 
+# If the QT_AUTOBRIEF tag is set to YES then Doxygen will
+# interpret the first line (until the first dot) of a Qt-style
+# comment as the brief description. If set to NO, the comments
+# will behave just like regular Qt-style comments (thus requiring
+# an explicit \brief command for a brief description.)
+
+QT_AUTOBRIEF           = NO
+
 # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
 # treat a multi-line C++ special comment block (i.e. a block of //! or ///
 # comments) as a brief description. This used to be the default behaviour.
@@ -147,25 +155,17 @@
 
 MULTILINE_CPP_IS_BRIEF = NO
 
-# If the DETAILS_AT_TOP tag is set to YES then Doxygen
-# will output the detailed description near the top, like JavaDoc.
-# If set to NO, the detailed description appears after the member
-# documentation.
-
-DETAILS_AT_TOP         = NO
-
 # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
 # member inherits the documentation from any documented member that it
 # re-implements.
 
 INHERIT_DOCS           = YES
 
-# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
-# tag is set to YES, then doxygen will reuse the documentation of the first
-# member in the group (if any) for the other members of the group. By default
-# all members of a group must be documented explicitly.
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
+# a new page for each member. If set to NO, the documentation of a member will
+# be part of the file/class/namespace that contains it.
 
-DISTRIBUTE_GROUP_DOC   = NO
+SEPARATE_MEMBER_PAGES  = NO
 
 # The TAB_SIZE tag can be used to set the number of spaces in a tab.
 # Doxygen uses this value to replace tabs by spaces in code fragments.
@@ -181,20 +181,79 @@
 
 ALIASES                =
 
-# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources
-# only. Doxygen will then generate output that is more tailored for C.
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
+# sources only. Doxygen will then generate output that is more tailored for C.
 # For instance, some of the names that are used will be different. The list
 # of all members will be omitted, etc.
 
 OPTIMIZE_OUTPUT_FOR_C  = YES
 
-# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources
-# only. Doxygen will then generate output that is more tailored for Java.
-# For instance, namespaces will be presented as packages, qualified scopes
-# will look different, etc.
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
+# sources only. Doxygen will then generate output that is more tailored for
+# Java. For instance, namespaces will be presented as packages, qualified
+# scopes will look different, etc.
 
 OPTIMIZE_OUTPUT_JAVA   = NO
 
+# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
+# sources only. Doxygen will then generate output that is more tailored for
+# Fortran.
+
+OPTIMIZE_FOR_FORTRAN   = NO
+
+# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
+# sources. Doxygen will then generate output that is tailored for
+# VHDL.
+
+OPTIMIZE_OUTPUT_VHDL   = NO
+
+# Doxygen selects the parser to use depending on the extension of the files it parses.
+# With this tag you can assign which parser to use for a given extension.
+# Doxygen has a built-in mapping, but you can override or extend it using this tag.
+# The format is ext=language, where ext is a file extension, and language is one of
+# the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP,
+# Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat
+# .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran),
+# use: inc=Fortran f=C. Note that for custom extensions you also need to set FILE_PATTERNS otherwise the files are not read by doxygen.
+
+EXTENSION_MAPPING      =
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
+# to include (a tag file for) the STL sources as input, then you should
+# set this tag to YES in order to let doxygen match functions declarations and
+# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
+# func(std::string) {}). This also make the inheritance and collaboration
+# diagrams that involve STL classes more complete and accurate.
+
+BUILTIN_STL_SUPPORT    = NO
+
+# If you use Microsoft's C++/CLI language, you should set this option to YES to
+# enable parsing support.
+
+CPP_CLI_SUPPORT        = NO
+
+# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only.
+# Doxygen will parse them like normal C++ but will assume all classes use public
+# instead of private inheritance when no explicit protection keyword is present.
+
+SIP_SUPPORT            = NO
+
+# For Microsoft's IDL there are propget and propput attributes to indicate getter
+# and setter methods for a property. Setting this option to YES (the default)
+# will make doxygen to replace the get and set methods by a property in the
+# documentation. This will only work if the methods are indeed getting or
+# setting a simple type. If this is not the case, or you want to show the
+# methods anyway, you should set this option to NO.
+
+IDL_PROPERTY_SUPPORT   = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
+# tag is set to YES, then doxygen will reuse the documentation of the first
+# member in the group (if any) for the other members of the group. By default
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC   = NO
+
 # Set the SUBGROUPING tag to YES (the default) to allow class member groups of
 # the same type (for instance a group of public functions) to be put as a
 # subgroup of that type (e.g. under the Public Functions section). Set it to
@@ -203,6 +262,32 @@
 
 SUBGROUPING            = YES
 
+# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum
+# is documented as struct, union, or enum with the name of the typedef. So
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
+# with name TypeT. When disabled the typedef will appear as a member of a file,
+# namespace, or class. And the struct will be named TypeS. This can typically
+# be useful for C code in case the coding convention dictates that all compound
+# types are typedef'ed and only the typedef is referenced, never the tag name.
+
+TYPEDEF_HIDES_STRUCT   = NO
+
+# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to
+# determine which symbols to keep in memory and which to flush to disk.
+# When the cache is full, less often used symbols will be written to disk.
+# For small to medium size projects (<1000 input files) the default value is
+# probably good enough. For larger projects a too small cache size can cause
+# doxygen to be busy swapping symbols to and from disk most of the time
+# causing a significant performance penality.
+# If the system has enough physical memory increasing the cache will improve the
+# performance by keeping more symbols in memory. Note that the value works on
+# a logarithmic scale so increasing the size by one will rougly double the
+# memory usage. The cache size is given by this formula:
+# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,
+# corresponding to a cache size of 2^16 = 65536 symbols
+
+SYMBOL_CACHE_SIZE      = 0
+
 #---------------------------------------------------------------------------
 # Build related configuration options
 #---------------------------------------------------------------------------
@@ -237,6 +322,14 @@
 
 EXTRACT_LOCAL_METHODS  = NO
 
+# If this flag is set to YES, the members of anonymous namespaces will be
+# extracted and appear in the documentation as a namespace called
+# 'anonymous_namespace{file}', where file will be replaced with the base
+# name of the file that contains the anonymous namespace. By default
+# anonymous namespace are hidden.
+
+EXTRACT_ANON_NSPACES   = NO
+
 # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
 # undocumented members of documented classes, files or namespaces.
 # If set to NO (the default) these members will be included in the
@@ -312,6 +405,16 @@
 
 SORT_BRIEF_DOCS        = NO
 
+# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the (brief and detailed) documentation of class members so that constructors and destructors are listed first. If set to NO (the default) the constructors will appear in the respective orders defined by SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO.
+
+SORT_MEMBERS_CTORS_1ST = NO
+
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the
+# hierarchy of group names into alphabetical order. If set to NO (the default)
+# the group names will appear in their defined order.
+
+SORT_GROUP_NAMES       = NO
+
 # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
 # sorted by fully-qualified names, including namespaces. If set to
 # NO (the default), the class list will be sorted only by class name,
@@ -369,10 +472,42 @@
 
 # If the sources in your project are distributed over multiple directories
 # then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy
-# in the documentation.
+# in the documentation. The default is NO.
 
 SHOW_DIRECTORIES       = YES
 
+# Set the SHOW_FILES tag to NO to disable the generation of the Files page.
+# This will remove the Files entry from the Quick Index and from the
+# Folder Tree View (if specified). The default is YES.
+
+SHOW_FILES             = YES
+
+# Set the SHOW_NAMESPACES tag to NO to disable the generation of the
+# Namespaces page.
+# This will remove the Namespaces entry from the Quick Index
+# and from the Folder Tree View (if specified). The default is YES.
+
+SHOW_NAMESPACES        = YES
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that
+# doxygen should invoke to get the current version for each file (typically from
+# the version control system). Doxygen will invoke the program by executing (via
+# popen()) the command <command> <input-file>, where <command> is the value of
+# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file
+# provided by doxygen. Whatever the program writes to standard output
+# is used as the file version. See the manual for examples.
+
+FILE_VERSION_FILTER    =
+
+# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by
+# doxygen. The layout file controls the global structure of the generated output files
+# in an output format independent way. The create the layout file that represents
+# doxygen's defaults, run doxygen with the -l option. You can optionally specify a
+# file name after the option, if omitted DoxygenLayout.xml will be used as the name
+# of the layout file.
+
+LAYOUT_FILE            =
+
 #---------------------------------------------------------------------------
 # configuration options related to warning and progress messages
 #---------------------------------------------------------------------------
@@ -401,10 +536,20 @@
 
 WARN_IF_DOC_ERROR      = YES
 
+# This WARN_NO_PARAMDOC option can be abled to get warnings for
+# functions that are documented, but have no documentation for their parameters
+# or return value. If set to NO (the default) doxygen will only warn about
+# wrong or incomplete parameter documentation, but not about the absence of
+# documentation.
+
+WARN_NO_PARAMDOC       = NO
+
 # The WARN_FORMAT tag determines the format of the warning messages that
 # doxygen can produce. The string should contain the $file, $line, and $text
 # tags, which will be replaced by the file and line number from which the
-# warning originated and the warning text.
+# warning originated and the warning text. Optionally the format may contain
+# $version, which will be replaced by the version of the file (if it could
+# be obtained via FILE_VERSION_FILTER)
 
 WARN_FORMAT            = "$file:$line: $text"
 
@@ -423,14 +568,23 @@
 # directories like "/usr/src/myproject". Separate the files or directories
 # with spaces.
 
-INPUT = config.h src
+INPUT                  = config.h \
+                         src
+
+# This tag can be used to specify the character encoding of the source files
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
+# also the default input encoding. Doxygen uses libiconv (or the iconv built
+# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for
+# the list of possible encodings.
+
+INPUT_ENCODING         = UTF-8
 
 # If the value of the INPUT tag contains directories, you can use the
 # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
 # and *.h) to filter out the source-files in the directories. If left
 # blank the following patterns are tested:
-# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp
-# *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm
+# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx
+# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90
 
 FILE_PATTERNS          =
 
@@ -446,17 +600,28 @@
 
 EXCLUDE                =
 
-# The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories
-# that are symbolic links (a Unix filesystem feature) are excluded from the input.
+# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
+# directories that are symbolic links (a Unix filesystem feature) are excluded
+# from the input.
 
 EXCLUDE_SYMLINKS       = NO
 
 # If the value of the INPUT tag contains directories, you can use the
 # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
-# certain files from those directories.
+# certain files from those directories. Note that the wildcards are matched
+# against the file with absolute path, so to exclude all test directories
+# for example use the pattern */test/*
 
 EXCLUDE_PATTERNS       =
 
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
+# (namespaces, classes, functions, etc.) that should be excluded from the
+# output. The symbol name can be a fully qualified name, a word, or if the
+# wildcard * is used, a substring. Examples: ANamespace, AClass,
+# AClass::ANamespace, ANamespace::*Test
+
+EXCLUDE_SYMBOLS        =
+
 # The EXAMPLE_PATH tag can be used to specify one or more files or
 # directories that contain example code fragments that are included (see
 # the \include command).
@@ -488,14 +653,17 @@
 # by executing (via popen()) the command <filter> <input-file>, where <filter>
 # is the value of the INPUT_FILTER tag, and <input-file> is the name of an
 # input file. Doxygen will then use the output that the filter program writes
-# to standard output.  If FILTER_PATTERNS is specified, this tag will be
+# to standard output.
+# If FILTER_PATTERNS is specified, this tag will be
 # ignored.
 
 INPUT_FILTER           =
 
 # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
-# basis.  Doxygen will compare the file name with each pattern and apply the
-# filter if there is a match.  The filters are a list of the form:
+# basis.
+# Doxygen will compare the file name with each pattern and apply the
+# filter if there is a match.
+# The filters are a list of the form:
 # pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
 # info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER
 # is applied to all files.
@@ -530,18 +698,34 @@
 
 STRIP_CODE_COMMENTS    = YES
 
-# If the REFERENCED_BY_RELATION tag is set to YES (the default)
+# If the REFERENCED_BY_RELATION tag is set to YES
 # then for each documented function all documented
 # functions referencing it will be listed.
 
 REFERENCED_BY_RELATION = YES
 
-# If the REFERENCES_RELATION tag is set to YES (the default)
+# If the REFERENCES_RELATION tag is set to YES
 # then for each documented function all documented entities
 # called/used by that function will be listed.
 
 REFERENCES_RELATION    = YES
 
+# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
+# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
+# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
+# link to the source code.
+# Otherwise they will link to the documentation.
+
+REFERENCES_LINK_SOURCE = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code
+# will point to the HTML generated by the htags(1) tool instead of doxygen
+# built-in source browser. The htags tool is part of GNU's global source
+# tagging system (see http://www.gnu.org/software/global/global.html). You
+# will need version 4.8.6 or higher.
+
+USE_HTAGS              = NO
+
 # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
 # will generate a verbatim copy of the header file for each class for
 # which an include is specified. Set to NO to disable this.
@@ -604,6 +788,11 @@
 
 HTML_FOOTER            =
 
+# If the HTML_TIMESTAMP tag is set to YES then the generated HTML
+# documentation will contain the timesstamp.
+
+HTML_TIMESTAMP         = NO
+
 # The HTML_STYLESHEET tag can be used to specify a user-defined cascading
 # style sheet that is used by each HTML page. It can be used to
 # fine-tune the look of the HTML output. If the tag is left blank doxygen
@@ -619,9 +808,43 @@
 
 HTML_ALIGN_MEMBERS     = YES
 
+# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
+# documentation will contain sections that can be hidden and shown after the
+# page has loaded. For this to work a browser that supports
+# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox
+# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
+
+HTML_DYNAMIC_SECTIONS  = NO
+
+# If the GENERATE_DOCSET tag is set to YES, additional index files
+# will be generated that can be used as input for Apple's Xcode 3
+# integrated development environment, introduced with OSX 10.5 (Leopard).
+# To create a documentation set, doxygen will generate a Makefile in the
+# HTML output directory. Running make will produce the docset in that
+# directory and running "make install" will install the docset in
+# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find
+# it at startup.
+# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information.
+
+GENERATE_DOCSET        = NO
+
+# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the
+# feed. A documentation feed provides an umbrella under which multiple
+# documentation sets from a single provider (such as a company or product suite)
+# can be grouped.
+
+DOCSET_FEEDNAME        = "Doxygen generated docs"
+
+# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that
+# should uniquely identify the documentation set bundle. This should be a
+# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen
+# will append .docset to the name.
+
+DOCSET_BUNDLE_ID       = org.doxygen.Project
+
 # If the GENERATE_HTMLHELP tag is set to YES, additional index files
 # will be generated that can be used as input for tools like the
-# Microsoft HTML help workshop to generate a compressed HTML help file (.chm)
+# Microsoft HTML help workshop to generate a compiled HTML help file (.chm)
 # of the generated HTML documentation.
 
 GENERATE_HTMLHELP      = NO
@@ -646,6 +869,12 @@
 
 GENERATE_CHI           = NO
 
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING
+# is used to encode HtmlHelp index (hhk), content (hhc) and project file
+# content.
+
+CHM_INDEX_ENCODING     =
+
 # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
 # controls whether a binary table of contents is generated (YES) or a
 # normal table of contents (NO) in the .chm file.
@@ -657,6 +886,55 @@
 
 TOC_EXPAND             = NO
 
+# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER
+# are set, an additional index file will be generated that can be used as input for
+# Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated
+# HTML documentation.
+
+GENERATE_QHP           = NO
+
+# If the QHG_LOCATION tag is specified, the QCH_FILE tag can
+# be used to specify the file name of the resulting .qch file.
+# The path specified is relative to the HTML output folder.
+
+QCH_FILE               =
+
+# The QHP_NAMESPACE tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#namespace
+
+QHP_NAMESPACE          =
+
+# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#virtual-folders
+
+QHP_VIRTUAL_FOLDER     = doc
+
+# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add.
+# For more information please see
+# http://doc.trolltech.com/qthelpproject.html#custom-filters
+
+QHP_CUST_FILTER_NAME   =
+
+# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see
+# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters">Qt Help Project / Custom Filters</a>.
+
+QHP_CUST_FILTER_ATTRS  =
+
+# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's
+# filter section matches.
+# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes">Qt Help Project / Filter Attributes</a>.
+
+QHP_SECT_FILTER_ATTRS  =
+
+# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can
+# be used to specify the location of Qt's qhelpgenerator.
+# If non-empty doxygen will try to run qhelpgenerator on the generated
+# .qhp file.
+
+QHG_LOCATION           =
+
 # The DISABLE_INDEX tag can be used to turn on/off the condensed index at
 # top of each HTML page. The value NO (the default) enables the index and
 # the value YES disables it.
@@ -668,21 +946,42 @@
 
 ENUM_VALUES_PER_LINE   = 4
 
-# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be
-# generated containing a tree-like index structure (just like the one that
+# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
+# structure should be generated to display hierarchical information.
+# If the tag value is set to YES, a side panel will be generated
+# containing a tree-like index structure (just like the one that
 # is generated for HTML Help). For this to work a browser that supports
-# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+,
-# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are
-# probably better off using the HTML help feature.
+# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser).
+# Windows users are probably better off using the HTML help feature.
 
 GENERATE_TREEVIEW      = YES
 
+# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories,
+# and Class Hierarchy pages using a tree view instead of an ordered list.
+
+USE_INLINE_TREES       = NO
+
 # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
 # used to set the initial width (in pixels) of the frame in which the tree
 # is shown.
 
 TREEVIEW_WIDTH         = 250
 
+# Use this tag to change the font size of Latex formulas included
+# as images in the HTML documentation. The default is 10. Note that
+# when you change the font size after a successful doxygen run you need
+# to manually remove any form_*.png images from the HTML output directory
+# to force them to be regenerated.
+
+FORMULA_FONTSIZE       = 10
+
+# When the SEARCHENGINE tag is enable doxygen will generate a search box for the HTML output. The underlying search engine uses javascript
+# and DHTML and should work on any modern browser. Note that when using HTML help (GENERATE_HTMLHELP) or Qt help (GENERATE_QHP)
+# there is already a search function so this one should typically
+# be disabled.
+
+SEARCHENGINE           = NO
+
 #---------------------------------------------------------------------------
 # configuration options related to the LaTeX output
 #---------------------------------------------------------------------------
@@ -759,6 +1058,10 @@
 
 LATEX_HIDE_INDICES     = NO
 
+# If LATEX_SOURCE_CODE is set to YES then doxygen will include source code with syntax highlighting in the LaTeX output. Note that which sources are shown also depends on other settings such as SOURCE_BROWSER.
+
+LATEX_SOURCE_CODE      = NO
+
 #---------------------------------------------------------------------------
 # configuration options related to the RTF output
 #---------------------------------------------------------------------------
@@ -895,8 +1198,10 @@
 PERLMOD_LATEX          = NO
 
 # If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
-# nicely formatted so it can be parsed by a human reader.  This is useful
-# if you want to understand what is going on.  On the other hand, if this
+# nicely formatted so it can be parsed by a human reader.
+# This is useful
+# if you want to understand what is going on.
+# On the other hand, if this
 # tag is set to NO the size of the Perl module output will be much smaller
 # and Perl will parse it just the same.
 
@@ -928,7 +1233,7 @@
 
 # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
 # then the macro expansion is limited to the macros specified with the
-# PREDEFINED and EXPAND_AS_PREDEFINED tags.
+# PREDEFINED and EXPAND_AS_DEFINED tags.
 
 EXPAND_ONLY_PREDEF     = NO
 
@@ -970,8 +1275,8 @@
 # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
 # doxygen's preprocessor will remove all function-like macros that are alone
 # on a line, have an all uppercase name, and do not end with a semicolon. Such
-# function macros are typically used for boiler-plate code, and will confuse the
-# parser if not removed.
+# function macros are typically used for boiler-plate code, and will confuse
+# the parser if not removed.
 
 SKIP_FUNCTION_MACROS   = YES
 
@@ -983,9 +1288,11 @@
 # Optionally an initial location of the external documentation
 # can be added for each tagfile. The format of a tag file without
 # this location is as follows:
-#   TAGFILES = file1 file2 ...
+#
+# TAGFILES = file1 file2 ...
 # Adding location for the tag files is done as follows:
-#   TAGFILES = file1=loc1 "file2 = loc2" ...
+#
+# TAGFILES = file1=loc1 "file2 = loc2" ...
 # where "loc1" and "loc2" can be relative or absolute paths or
 # URLs. If a location is present for each tag, the installdox tool
 # does not have to be run to correct the links.
@@ -1023,13 +1330,23 @@
 #---------------------------------------------------------------------------
 
 # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
-# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base or
-# super classes. Setting the tag to NO turns the diagrams off. Note that this
-# option is superseded by the HAVE_DOT option below. This is only a fallback. It is
-# recommended to install and use dot, since it yields more powerful graphs.
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
+# or super classes. Setting the tag to NO turns the diagrams off. Note that
+# this option is superseded by the HAVE_DOT option below. This is only a
+# fallback. It is recommended to install and use dot, since it yields more
+# powerful graphs.
 
 CLASS_DIAGRAMS         = YES
 
+# You can define message sequence charts within doxygen comments using the \msc
+# command. Doxygen will then run the mscgen tool (see
+# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the
+# documentation. The MSCGEN_PATH tag allows you to specify the directory where
+# the mscgen tool resides. If left empty the tool is assumed to be found in the
+# default search path.
+
+MSCGEN_PATH            =
+
 # If set to YES, the inheritance and collaboration graphs will hide
 # inheritance and usage relations if the target is undocumented
 # or is not a class.
@@ -1043,6 +1360,29 @@
 
 HAVE_DOT               = YES
 
+# By default doxygen will write a font called FreeSans.ttf to the output
+# directory and reference it in all dot files that doxygen generates. This
+# font does not include all possible unicode characters however, so when you need
+# these (or just want a differently looking font) you can specify the font name
+# using DOT_FONTNAME. You need need to make sure dot is able to find the font,
+# which can be done by putting it in a standard location or by setting the
+# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory
+# containing the font.
+
+DOT_FONTNAME           = FreeSans
+
+# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs.
+# The default size is 10pt.
+
+DOT_FONTSIZE           = 10
+
+# By default doxygen will tell dot to use the output directory to look for the
+# FreeSans.ttf font (which doxygen will put there itself). If you specify a
+# different font using DOT_FONTNAME you can set the path where dot
+# can find it using this tag.
+
+DOT_FONTPATH           =
+
 # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
 # will generate a graph for each documented class showing the direct and
 # indirect inheritance relations. Setting this tag to YES will force the
@@ -1057,6 +1397,11 @@
 
 COLLABORATION_GRAPH    = YES
 
+# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for groups, showing the direct groups dependencies
+
+GROUP_GRAPHS           = YES
+
 # If the UML_LOOK tag is set to YES doxygen will generate inheritance and
 # collaboration diagrams in a style similar to the OMG's Unified Modeling
 # Language.
@@ -1082,19 +1427,34 @@
 
 INCLUDED_BY_GRAPH      = YES
 
-# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will
-# generate a call dependency graph for every global function or class method.
-# Note that enabling this option will significantly increase the time of a run.
-# So in most cases it will be better to enable call graphs for selected
-# functions only using the \callgraph command.
+# If the CALL_GRAPH and HAVE_DOT options are set to YES then
+# doxygen will generate a call dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable call graphs
+# for selected functions only using the \callgraph command.
 
 CALL_GRAPH             = YES
 
+# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then
+# doxygen will generate a caller dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable caller
+# graphs for selected functions only using the \callergraph command.
+
+CALLER_GRAPH           = NO
+
 # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
 # will graphical hierarchy of all classes instead of a textual one.
 
 GRAPHICAL_HIERARCHY    = YES
 
+# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES
+# then doxygen will show the dependencies a directory has on other directories
+# in a graphical way. The dependency relations are determined by the #include
+# relations between the files in the directories.
+
+DIRECTORY_GRAPH        = YES
+
 # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
 # generated by dot. Possible values are png, jpg, or gif
 # If left blank png will be used.
@@ -1102,7 +1462,7 @@
 DOT_IMAGE_FORMAT       = png
 
 # The tag DOT_PATH can be used to specify the path where the dot tool can be
-# found. If left blank, it is assumed the dot tool can be found on the path.
+# found. If left blank, it is assumed the dot tool can be found in the path.
 
 DOT_PATH               =
 
@@ -1112,33 +1472,41 @@
 
 DOTFILE_DIRS           =
 
-# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width
-# (in pixels) of the graphs generated by dot. If a graph becomes larger than
-# this value, doxygen will try to truncate the graph, so that it fits within
-# the specified constraint. Beware that most browsers cannot cope with very
-# large images.
-
-MAX_DOT_GRAPH_WIDTH    = 1024
+# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of
+# nodes that will be shown in the graph. If the number of nodes in a graph
+# becomes larger than this value, doxygen will truncate the graph, which is
+# visualized by representing a node as a red box. Note that doxygen if the
+# number of direct children of the root node in a graph is already larger than
+# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note
+# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
 
-# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height
-# (in pixels) of the graphs generated by dot. If a graph becomes larger than
-# this value, doxygen will try to truncate the graph, so that it fits within
-# the specified constraint. Beware that most browsers cannot cope with very
-# large images.
-
-MAX_DOT_GRAPH_HEIGHT   = 1024
+DOT_GRAPH_MAX_NODES    = 50
 
 # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
 # graphs generated by dot. A depth value of 3 means that only nodes reachable
-# from the root by following a path via at most 3 edges will be shown. Nodes that
-# lay further from the root node will be omitted. Note that setting this option to
-# 1 or 2 may greatly reduce the computation time needed for large code bases. Also
-# note that a graph may be further truncated if the graph's image dimensions are
-# not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH and MAX_DOT_GRAPH_HEIGHT).
-# If 0 is used for the depth value (the default), the graph is not depth-constrained.
+# from the root by following a path via at most 3 edges will be shown. Nodes
+# that lay further from the root node will be omitted. Note that setting this
+# option to 1 or 2 may greatly reduce the computation time needed for large
+# code bases. Also note that the size of a graph can be further restricted by
+# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
 
 MAX_DOT_GRAPH_DEPTH    = 0
 
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
+# background. This is disabled by default, because dot on Windows does not
+# seem to support this out of the box. Warning: Depending on the platform used,
+# enabling this option may lead to badly anti-aliased labels on the edges of
+# a graph (i.e. they become hard to read).
+
+DOT_TRANSPARENT        = NO
+
+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
+# files in one run (i.e. multiple -o and -T options on the command line). This
+# makes dot run faster, but since only newer versions of dot (>1.8.10)
+# support this, this feature is disabled by default.
+
+DOT_MULTI_TARGETS      = NO
+
 # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
 # generate a legend page explaining the meaning of the various boxes and
 # arrows in the dot generated graphs.
@@ -1150,12 +1518,3 @@
 # the various graphs.
 
 DOT_CLEANUP            = YES
-
-#---------------------------------------------------------------------------
-# Configuration::additions related to the search engine
-#---------------------------------------------------------------------------
-
-# The SEARCHENGINE tag specifies whether or not a search engine should be
-# used. If set to NO the values of all tags below this one will be ignored.
-
-SEARCHENGINE           = NO
--- a/Makefile.am	Thu Jun 03 19:09:29 2010 -0700
+++ b/Makefile.am	Mon Dec 24 17:51:12 2012 -0800
@@ -1,3 +1,5 @@
+ACLOCAL_AMFLAGS = -I m4
+
 SUBDIRS = src python man html debian
 htmldir = ${datadir}/doc/@PACKAGE@-@VERSION@
 html_DATA = AUTHORS COPYING ChangeLog NEWS README
--- a/NEWS	Thu Jun 03 19:09:29 2010 -0700
+++ b/NEWS	Mon Dec 24 17:51:12 2012 -0800
@@ -1,3 +1,13 @@
+0.6.55  2012-05-08 preserve bcc headers, space after colon is not required in header fields
+0.6.54  2011-11-04 embedded rfc822 messages might contain rtf encoded bodies
+0.6.53  2011-07-10 allow fork for parallel processing of individual email folders in separate mode
+0.6.52  2011-05-22 fix dangling freed pointer; allow broken outlook internet header field
+0.6.51  2011-04-17 fix for buffer overrun; attachment size fetched twice
+0.6.50  2010-12-24 rfc2047 and rfc2231 encoding for non-ascii headers and attachment filenames
+0.6.49  2010-09-13 fix to ignore embedded objects that are not email messages
+0.6.48  2010-09-02 fix for broken internet headers from Outlook, change to mboxrd quoting
+0.6.47  2010-05-07 patches from Kenneth Berland for solaris
+0.6.46  2010-02-13 fixes for fedora 13 change in implicit dso linking semantics
 0.6.48  2010-05-24 fix to/cc/bcc recipients in .msg file output format
 0.6.46  2009-12-11 add readpst -m switch to produce Outlook .msg files
 0.6.45  2009-11-18 patch from Hugo DesRosiers to export categories and notes into vcards
@@ -9,7 +19,7 @@
 0.6.39  2009-06-21 fedora > 10 moved to boost-python-devel
 0.6.39  2009-06-21 fedora > 10 moved to boost-python-devel
 0.6.38  2009-06-21 many changes including shared library soname
-0.6.37  2009-04-17 add pst_attach_to_mem() back into the shared library interface.
+0.6.37  2009-04-17 add pst_attach_to_mem() back into the shared library interface
 0.6.36  2009-04-14 build separate -doc and -devel-doc subpackages
 0.6.35  2009-04-08 properly add trailing mime boundary in all modes, build separate rpms with libpst.so shared.
 0.6.34  2009-03-19 avoid putting mixed item types into the same output folder
@@ -18,7 +28,7 @@
 0.6.31  2009-03-14 bump version for fedora cvs tagging mistake
 0.6.30  2009-03-14 track character set individually for each mapi element, avoid emitting bogus empty email messages into contacts and calendar files.
 0.6.29  2009-02-24 fix for 64bit on Fedora 11
-0.6.28  2009-02-24 improve decoding of multipart/report and message/rfc822 mime types.
+0.6.28  2009-02-24 improve decoding of multipart/report and message/rfc822 mime types
 0.6.27  2009-02-07 fix for const correctness on Fedora 11
 0.6.26  2009-02-07 patch from Fridrich Strba for building on mingw, and autoconf cleanup, better mime headers
 0.6.25  2009-01-16 improve handling of content-type charset values in mime parts
@@ -29,10 +39,10 @@
 0.6.20  2008-10-09 add configure option --enable-dii=no, fixes from Robert Harris for pst2ldif.
 0.6.19  2008-09-14 Initial work on a .so shared library from Bharath Acharya.
 0.6.18  2008-08-28 Fixes for iconv on Mac from Justin Greer.
-0.6.17  2008-08-05 More fixes for 32/64 bit portability on big endian ppc.
-0.6.16  2008-08-05 Use inttypes.h for portable printing of 64 bit items.
-0.6.15  2008-07-30 Fix file handle leak in error case, missing length on lz decompression.
-0.6.14  2008-06-15 Fix my mistake in debian packaging.
+0.6.17  2008-08-05 More fixes for 32/64 bit portability on big endian ppc
+0.6.16  2008-08-05 Use inttypes.h for portable printing of 64 bit items
+0.6.15  2008-07-30 Fix file handle leak in error case, missing length on lz decompression
+0.6.14  2008-06-15 Fix my mistake in debian packaging
 0.6.13  2008-06-13 Patch from Robert Simpson for encryption type 2.
 0.6.12  2008-06-10 Patch from Joachim Metz for debian packaging, and fix for incorrect length on lz decompression.
 0.6.11  2008-06-03 Use ftello/fseeko to properly handle large files.
--- a/configure.in	Thu Jun 03 19:09:29 2010 -0700
+++ b/configure.in	Mon Dec 24 17:51:12 2012 -0800
@@ -1,5 +1,5 @@
 AC_PREREQ(2.59)
-AC_INIT(libpst,0.6.48,carl@five-ten-sg.com)
+AC_INIT(libpst,0.6.55,carl@five-ten-sg.com)
 AC_CONFIG_SRCDIR([src/libpst.c])
 AC_CONFIG_HEADER([config.h])
 AM_INIT_AUTOMAKE
@@ -19,7 +19,7 @@
 #  6. libtool will build libpst.so.x.y.z where the SONAME is libpst.so.x
 #     and x=current-age, y=age, z=revision
 
-libpst_version_info='4:2:0'
+libpst_version_info='5:5:1'
 AC_SUBST(LIBPST_VERSION_INFO, [$libpst_version_info])
 libpst_so_major='4'
 AC_SUBST(LIBPST_SO_MAJOR, [$libpst_so_major])
@@ -32,9 +32,31 @@
 # 0.6.40    libpst.so.4     libpst.so.4.0.0
 # 0.6.43    libpst.so.4     libpst.so.4.0.1
 # 0.6.47    libpst.so.4     libpst.so.4.0.2
+# 0.6.48    libpst.so.4     libpst.so.4.0.3
+# 0.6.49    libpst.so.4     libpst.so.4.0.4
+# 0.6.50    libpst.so.4     libpst.so.4.1.0
+# 0.6.51    libpst.so.4     libpst.so.4.1.1
+# 0.6.52    libpst.so.4     libpst.so.4.1.2
+# 0.6.53    libpst.so.4     libpst.so.4.1.3
+# 0.6.54    libpst.so.4     libpst.so.4.1.4
+# 0.6.55    libpst.so.4     libpst.so.4.1.5
 
 
 
+# Check for solaris
+AC_MSG_CHECKING([for Solaris])
+case "$host" in
+    *solaris*)
+        os_solaris=yes
+        ;;
+    *)
+        os_solaris=no
+        ;;
+esac
+AC_MSG_RESULT($os_solaris)
+AM_CONDITIONAL(OS_SOLARIS, [test "$os_solaris" = "yes"])
+
+
 # Check for win32
 AC_MSG_CHECKING([for Win32])
 case "$host" in
@@ -137,7 +159,7 @@
 AC_HEADER_DIRENT
 AC_HEADER_STDC
 AC_CHECK_HEADERS([ctype.h dirent.h errno.h fcntl.h inttypes.h limits.h regex.h semaphore.h signal.h stdarg.h stdint.h stdio.h stdlib.h string.h sys/param.h sys/shm.h sys/stat.h sys/types.h time.h unistd.h wchar.h])
-AC_SEARCH_LIBS([sem_init],rt)
+AC_SEARCH_LIBS([sem_init],[pthread rt])
 
 
 # Checks for typedefs, structures, and compiler characteristics.
@@ -249,7 +271,7 @@
         case "${enableval}" in
           yes) ;;
           no)  ;;
-          *)   AC_MSG_ERROR(bad value ${enableval} for --static-tools) ;;
+          *)   AC_MSG_ERROR(bad value ${enableval} for --enable-static-tools) ;;
         esac
     ],
     [
@@ -304,6 +326,35 @@
     AC_SUBST(PYTHON_VERSION, [$ax_python_bin])
 fi
 
+
+# The following lines adds the --enable-profiling option to configure:
+#
+# Give the user the choice to enter one of these:
+# --enable-profiling
+# --enable-profiling=yes
+# --enable-profiling=no
+#
+AC_MSG_CHECKING([whether to link with gprof profiling])
+AC_ARG_ENABLE([profiling],
+    AC_HELP_STRING([--enable-profiling], [link with gprof profiling]),
+    [
+        case "${enableval}" in
+          yes)
+              CFLAGS="$CFLAGS -pg"
+              CPPFLAGS="$CPPFLAGS -pg"
+              CXXFLAGS="$CXXFLAGS -pg"
+              ;;
+          no)
+              ;;
+          *)   AC_MSG_ERROR(bad value ${enableval} for --profiling) ;;
+        esac
+    ],
+    [
+        enable_profiling=no
+    ])
+AC_MSG_RESULT([$enable_profiling])
+AM_CONDITIONAL(GPROF_PROFILING, [test "$enable_profiling" = "yes"])
+
 gsf_flags="`pkg-config libgsf-1 --cflags`"
 gsf_libs="`pkg-config libgsf-1 --libs`"
 AC_SUBST(GSF_FLAGS, [$gsf_flags])
--- a/libpst.spec.in	Thu Jun 03 19:09:29 2010 -0700
+++ b/libpst.spec.in	Mon Dec 24 17:51:12 2012 -0800
@@ -1,7 +1,7 @@
 Summary:            Utilities to convert Outlook .pst files to other formats
 Name:               @PACKAGE@
 Version:            @VERSION@
-Release:            1%{?dist}
+Release:            3%{?dist}
 License:            GPLv2+
 Group:              Applications/Productivity
 Source:             http://www.five-ten-sg.com/%{name}/packages/%{name}-%{version}.tar.gz
@@ -38,6 +38,8 @@
 Requires:           python
 Requires:           %{name}-libs = %{version}-%{release}
 
+%filter_provides_in %{python_sitearch}/_*.so
+
 %description python
 The libpst-python package allows you to use the libpst shared object
 from python code.
@@ -113,6 +115,7 @@
 %files libs
 %defattr(-,root,root,-)
 %{_libdir}/libpst.so.*
+%doc COPYING
 
 
 %files python
@@ -146,11 +149,102 @@
 
 
 %changelog
-* Mon May 24 2010 Carl Byington <carl@five-ten-sg.com> - 0.6.48-1
-- fix to/cc/bcc recipients in .msg file output format
+* Mon Dec 24 2012 Carl Byington <carl@five-ten-sg.com> - 0.6.55-3
+- filter private provides from rpm
+
+* Tue Aug 09 2012 Carl Byington <carl@five-ten-sg.com> - 0.6.55-2
+- rebuild for python
+
+* Thu Jul 19 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.6.54-6
+- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild
+
+* Tue May 08 2012 Carl Byington <carl@five-ten-sg.com> - 0.6.55-1
+- preserve bcc headers
+- document -C switch to set default character set
+- space after colon is not required in header fields
+
+* Tue Feb 28 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.6.54-5
+- Rebuilt for c++ ABI breakage
+
+* Fri Jan 13 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.6.54-4
+- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
+
+* Sat Dec 24 2011 Carl Byington <carl@five-ten-sg.com> - 0.6.54-3
+- bump versions and prep for fedora build
+
+* Wed Nov 30 2011 Petr Pisar <ppisar@redhat.com> - 0.6.53-3
+- Rebuild against boost-1.48
+
+* Wed Nov 14 2011 Carl Byington <carl@five-ten-sg.com> - 0.6.54-2
+- failed to bump version number
+
+* Fri Nov 04 2011 Carl Byington <carl@five-ten-sg.com> - 0.6.54-1
+- embedded rfc822 messages might contain rtf encoded bodies
+
+* Fri Sep 02 2011 Petr Pisar <ppisar@redhat.com> - 0.6.53-2
+- Rebuild against boost-1.47
+
+* Sun Jul 10 2011 Carl Byington <carl@five-ten-sg.com> - 0.6.53-1
+- add Status: header in output
+- allow fork for parallel processing of individual email folders
+  in separate mode
+- proper handling of --with-boost-python option
+
+* Sun May 22 2011 Carl Byington <carl@five-ten-sg.com> - 0.6.52-1
+- fix dangling freed pointer in embedded rfc822 message processing
+- allow broken outlook internet header field - it sometimes contains
+  fragments of the message body rather than headers
 
-* Fri Dec 11 2009 Carl Byington <carl@five-ten-sg.com> - 0.6.46-1
-- add readpst -m switch to produce Outlook .msg files
+* Sun Apr 17 2011 Carl Byington <carl@five-ten-sg.com> - 0.6.51-1
+- fix for buffer overrun; attachment size from the secondary
+  list of mapi elements overwrote proper size from the primary
+  list of mapi elements.
+  fedora bugzilla 696263
+
+* Tue Feb 08 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.6.49-4
+- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
+
+* Mon Feb 07 2011 Thomas Spura <tomspur@fedoraproject.org> - 0.6.49-3
+- rebuild for new boost
+
+* Fri Dec 24 2010 Carl Byington <carl@five-ten-sg.com> - 0.6.50-1
+- rfc2047 and rfc2231 encoding for non-ascii headers and
+  attachment filenames.
+
+* Wed Sep 29 2010 jkeating - 0.6.49-2
+- Rebuilt for gcc bug 634757
+
+* Mon Sep 13 2010 Carl Byington <carl@five-ten-sg.com> - 0.6.49-1
+- fix to ignore embedded objects that are not email messages
+  fedora bugzilla 633498
+
+* Thu Sep 02 2010 Carl Byington <carl@five-ten-sg.com> - 0.6.48-1
+- fix for broken internet headers from Outlook
+- fix ax_python.m4 to look for python2.7
+- use mboxrd from quoting for output formats with multiple messages per file
+- use no from quoting for output formats with single message per file
+
+* Sat Jul 31 2010 Carl Byington <carl@five-ten-sg.com> - 0.6.47-6
+- rebuild for python dependencies
+
+* Mon Jul 26 2010 David Malcolm <dmalcolm@redhat.com> - 0.6.47-4
+- hack up configure so that it looks for python 2.7
+
+* Wed Jul 21 2010 David Malcolm <dmalcolm@redhat.com> - 0.6.47-3
+- Rebuilt for https://fedoraproject.org/wiki/Features/Python_2.7/MassRebuild
+
+* Wed Jul 07 2010 Carl Byington <carl@five-ten-sg.com> - 0.6.47-2
+- Subpackage Licensing, add COPYING to -libs.
+- patches from Kenneth Berland for solaris
+
+* Fri May 07 2010 Carl Byington <carl@five-ten-sg.com> - 0.6.47-1
+- patches from Kenneth Berland for solaris
+
+* Thu Jan 21 2010 Carl Byington <carl@five-ten-sg.com> - 0.6.46-1
+- prefer libpthread over librt for finding sem_init function.
+
+* Thu Jan 21 2010 Carl Byington <carl@five-ten-sg.com> - 0.6.45-2
+- rebuild for new boost package
 
 * Wed Nov 18 2009 Carl Byington <carl@five-ten-sg.com> - 0.6.45-1
 - patch from Hugo DesRosiers to export categories and notes into vcards.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m4/acx_pthread.m4	Mon Dec 24 17:51:12 2012 -0800
@@ -0,0 +1,280 @@
+##### http://autoconf-archive.cryp.to/acx_pthread.html
+#
+# SYNOPSIS
+#
+#   ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
+#
+# DESCRIPTION
+#
+#   This macro figures out how to build C programs using POSIX threads.
+#   It sets the PTHREAD_LIBS output variable to the threads library and
+#   linker flags, and the PTHREAD_CFLAGS output variable to any special
+#   C compiler flags that are needed. (The user can also force certain
+#   compiler flags/libs to be tested by setting these environment
+#   variables.)
+#
+#   Also sets PTHREAD_CC to any special C compiler that is needed for
+#   multi-threaded programs (defaults to the value of CC otherwise).
+#   (This is necessary on AIX to use the special cc_r compiler alias.)
+#
+#   NOTE: You are assumed to not only compile your program with these
+#   flags, but also link it with them as well. e.g. you should link
+#   with $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS
+#   $LIBS
+#
+#   If you are only building threads programs, you may wish to use
+#   these variables in your default LIBS, CFLAGS, and CC:
+#
+#          LIBS="$PTHREAD_LIBS $LIBS"
+#          CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+#          CC="$PTHREAD_CC"
+#
+#   In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute
+#   constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to
+#   that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
+#
+#   ACTION-IF-FOUND is a list of shell commands to run if a threads
+#   library is found, and ACTION-IF-NOT-FOUND is a list of commands to
+#   run it if it is not found. If ACTION-IF-FOUND is not specified, the
+#   default action will define HAVE_PTHREAD.
+#
+#   Please let the authors know if this macro fails on any platform, or
+#   if you have any other suggestions or comments. This macro was based
+#   on work by SGJ on autoconf scripts for FFTW (http://www.fftw.org/)
+#   (with help from M. Frigo), as well as ac_pthread and hb_pthread
+#   macros posted by Alejandro Forero Cuervo to the autoconf macro
+#   repository. We are also grateful for the helpful feedback of
+#   numerous users.
+#
+# LAST MODIFICATION
+#
+#   2006-05-29
+#
+# COPYLEFT
+#
+#   Copyright (c) 2006 Steven G. Johnson <stevenj@alum.mit.edu>
+#
+#   This program is free software; you can redistribute it and/or
+#   modify it under the terms of the GNU General Public License as
+#   published by the Free Software Foundation; either version 2 of the
+#   License, or (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be useful, but
+#   WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+#   General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program; if not, write to the Free Software
+#   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+#   02111-1307, USA.
+#
+#   As a special exception, the respective Autoconf Macro's copyright
+#   owner gives unlimited permission to copy, distribute and modify the
+#   configure scripts that are the output of Autoconf when processing
+#   the Macro. You need not follow the terms of the GNU General Public
+#   License when using or distributing such scripts, even though
+#   portions of the text of the Macro appear in them. The GNU General
+#   Public License (GPL) does govern all other use of the material that
+#   constitutes the Autoconf Macro.
+#
+#   This special exception to the GPL applies to versions of the
+#   Autoconf Macro released by the Autoconf Macro Archive. When you
+#   make and distribute a modified version of the Autoconf Macro, you
+#   may extend this special exception to the GPL to apply to your
+#   modified version as well.
+
+AC_DEFUN([ACX_PTHREAD], [
+AC_REQUIRE([AC_CANONICAL_HOST])
+AC_LANG_SAVE
+AC_LANG_C
+acx_pthread_ok=no
+
+# We used to check for pthread.h first, but this fails if pthread.h
+# requires special compiler flags (e.g. on True64 or Sequent).
+# It gets checked for in the link test anyway.
+
+# First of all, check if the user has set any of the PTHREAD_LIBS,
+# etcetera environment variables, and if threads linking works using
+# them:
+if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
+        save_CFLAGS="$CFLAGS"
+        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+        save_LIBS="$LIBS"
+        LIBS="$PTHREAD_LIBS $LIBS"
+        AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
+        AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)
+        AC_MSG_RESULT($acx_pthread_ok)
+        if test x"$acx_pthread_ok" = xno; then
+                PTHREAD_LIBS=""
+                PTHREAD_CFLAGS=""
+        fi
+        LIBS="$save_LIBS"
+        CFLAGS="$save_CFLAGS"
+fi
+
+# We must check for the threads library under a number of different
+# names; the ordering is very important because some systems
+# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
+# libraries is broken (non-POSIX).
+
+# Create a list of thread flags to try.  Items starting with a "-" are
+# C compiler flags, and other items are library names, except for "none"
+# which indicates that we try without any flags at all, and "pthread-config"
+# which is a program returning the flags for the Pth emulation library.
+
+acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
+
+# The ordering *is* (sometimes) important.  Some notes on the
+# individual items follow:
+
+# pthreads: AIX (must check this before -lpthread)
+# none: in case threads are in libc; should be tried before -Kthread and
+#       other compiler flags to prevent continual compiler warnings
+# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
+# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
+# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
+# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
+# -pthreads: Solaris/gcc
+# -mthreads: Mingw32/gcc, Lynx/gcc
+# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
+#      doesn't hurt to check since this sometimes defines pthreads too;
+#      also defines -D_REENTRANT)
+#      ... -mt is also the pthreads flag for HP/aCC
+# pthread: Linux, etcetera
+# --thread-safe: KAI C++
+# pthread-config: use pthread-config program (for GNU Pth library)
+
+case "${host_cpu}-${host_os}" in
+        *solaris*)
+
+        # On Solaris (at least, for some versions), libc contains stubbed
+        # (non-functional) versions of the pthreads routines, so link-based
+        # tests will erroneously succeed.  (We need to link with -pthreads/-mt/
+        # -lpthread.)  (The stubs are missing pthread_cleanup_push, or rather
+        # a function called by this macro, so we could check for that, but
+        # who knows whether they'll stub that too in a future libc.)  So,
+        # we'll just look for -pthreads and -lpthread first:
+
+        acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags"
+        ;;
+esac
+
+if test x"$acx_pthread_ok" = xno; then
+for flag in $acx_pthread_flags; do
+
+        case $flag in
+                none)
+                AC_MSG_CHECKING([whether pthreads work without any flags])
+                ;;
+
+                -*)
+                AC_MSG_CHECKING([whether pthreads work with $flag])
+                PTHREAD_CFLAGS="$flag"
+                ;;
+
+		pthread-config)
+		AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no)
+		if test x"$acx_pthread_config" = xno; then continue; fi
+		PTHREAD_CFLAGS="`pthread-config --cflags`"
+		PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
+		;;
+
+                *)
+                AC_MSG_CHECKING([for the pthreads library -l$flag])
+                PTHREAD_LIBS="-l$flag"
+                ;;
+        esac
+
+        save_LIBS="$LIBS"
+        save_CFLAGS="$CFLAGS"
+        LIBS="$PTHREAD_LIBS $LIBS"
+        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+
+        # Check for various functions.  We must include pthread.h,
+        # since some functions may be macros.  (On the Sequent, we
+        # need a special flag -Kthread to make this header compile.)
+        # We check for pthread_join because it is in -lpthread on IRIX
+        # while pthread_create is in libc.  We check for pthread_attr_init
+        # due to DEC craziness with -lpthreads.  We check for
+        # pthread_cleanup_push because it is one of the few pthread
+        # functions on Solaris that doesn't have a non-functional libc stub.
+        # We try pthread_create on general principles.
+        AC_TRY_LINK([#include <pthread.h>],
+                    [pthread_t th; pthread_join(th, 0);
+                     pthread_attr_init(0); pthread_cleanup_push(0, 0);
+                     pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
+                    [acx_pthread_ok=yes])
+
+        LIBS="$save_LIBS"
+        CFLAGS="$save_CFLAGS"
+
+        AC_MSG_RESULT($acx_pthread_ok)
+        if test "x$acx_pthread_ok" = xyes; then
+                break;
+        fi
+
+        PTHREAD_LIBS=""
+        PTHREAD_CFLAGS=""
+done
+fi
+
+# Various other checks:
+if test "x$acx_pthread_ok" = xyes; then
+        save_LIBS="$LIBS"
+        LIBS="$PTHREAD_LIBS $LIBS"
+        save_CFLAGS="$CFLAGS"
+        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+
+        # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
+	AC_MSG_CHECKING([for joinable pthread attribute])
+	attr_name=unknown
+	for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
+	    AC_TRY_LINK([#include <pthread.h>], [int attr=$attr; return attr;],
+                        [attr_name=$attr; break])
+	done
+        AC_MSG_RESULT($attr_name)
+        if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
+            AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
+                               [Define to necessary symbol if this constant
+                                uses a non-standard name on your system.])
+        fi
+
+        AC_MSG_CHECKING([if more special flags are required for pthreads])
+        flag=no
+        case "${host_cpu}-${host_os}" in
+            *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
+            *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
+        esac
+        AC_MSG_RESULT(${flag})
+        if test "x$flag" != xno; then
+            PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
+        fi
+
+        LIBS="$save_LIBS"
+        CFLAGS="$save_CFLAGS"
+
+        # More AIX lossage: must compile with xlc_r or cc_r
+	if test x"$GCC" != xyes; then
+          AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC})
+        else
+          PTHREAD_CC=$CC
+	fi
+else
+        PTHREAD_CC="$CC"
+fi
+
+AC_SUBST(PTHREAD_LIBS)
+AC_SUBST(PTHREAD_CFLAGS)
+AC_SUBST(PTHREAD_CC)
+
+# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
+if test x"$acx_pthread_ok" = xyes; then
+        ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
+        :
+else
+        acx_pthread_ok=no
+        $2
+fi
+AC_LANG_RESTORE
+])dnl ACX_PTHREAD
--- a/m4/ax_boost_python.m4	Thu Jun 03 19:09:29 2010 -0700
+++ b/m4/ax_boost_python.m4	Mon Dec 24 17:51:12 2012 -0800
@@ -77,6 +77,7 @@
 if test "$ac_cv_boost_python" = "yes"; then
   AC_DEFINE(HAVE_BOOST_PYTHON,,[define if the Boost::Python library is available])
   ax_python_lib=boost_python
+  BOOST_PYTHON_LIB=$ax_python_lib
   AC_ARG_WITH([boost-python],AS_HELP_STRING([--with-boost-python],[specify the boost python library or suffix to use]),
   [if test "x$with_boost_python" != "xno"; then
      ax_python_lib=$with_boost_python
--- a/m4/ax_python.m4	Thu Jun 03 19:09:29 2010 -0700
+++ b/m4/ax_python.m4	Mon Dec 24 17:51:12 2012 -0800
@@ -59,7 +59,7 @@
 [
 AC_MSG_CHECKING(for python build information)
 AC_MSG_RESULT([])
-for python in python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python; do
+for python in python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python; do
     AC_CHECK_PROGS(PYTHON_BIN, [$python])
     ax_python_bin=$PYTHON_BIN
     if test x$ax_python_bin != x; then
--- a/python/Makefile.am	Thu Jun 03 19:09:29 2010 -0700
+++ b/python/Makefile.am	Mon Dec 24 17:51:12 2012 -0800
@@ -10,7 +10,7 @@
 pythonlib_LTLIBRARIES   = _libpst.la
 _libpst_la_LDFLAGS      = -module $(NO_UNDEFINED) -avoid-version
 _libpst_la_SOURCES      = python-libpst.cpp
-_libpst_la_LIBADD       = -lboost_python ../src/libpst.la
+_libpst_la_LIBADD       = -l@BOOST_PYTHON_LIB@ ../src/libpst.la
 
 # set the include path found by configure
 INCLUDES= -I$(srcdir)/.. -I$(srcdir)/../src $(all_includes) -I$(PYTHON_INCLUDE_DIR)
--- a/python/python-libpst.cpp	Thu Jun 03 19:09:29 2010 -0700
+++ b/python/python-libpst.cpp	Mon Dec 24 17:51:12 2012 -0800
@@ -27,7 +27,7 @@
 
 class pst {
 public:
-                    pst(const string filename);
+                    pst(const string filename, const string charset);
     virtual         ~pst();
     pst_desc_tree*  pst_getTopOfFolders();
     ppst_binary     pst_attach_to_mem(pst_item_attach *attach);
@@ -61,9 +61,8 @@
 };
 
 
-pst::pst(const string filename) {
-    char *f = (char *)filename.c_str(); // ok, since pst_open does not actually modify this buffer, and newer versions will change the signature to const anyway
-    is_open = (::pst_open(&pf, f) == 0);
+pst::pst(const string filename, const string charset) {
+    is_open = (::pst_open(&pf, filename.c_str(), charset.c_str()) == 0);
     root = NULL;
     topf = NULL;
     if (is_open) {
@@ -187,7 +186,7 @@
             ss = string(s.data, s.size);
             return boost::python::incref(boost::python::object(ss).ptr());
         }
-        return NULL;
+        return boost::python::incref(boost::python::object().ptr());
     }
 };
 
@@ -199,42 +198,42 @@
             free(s.data);
             return boost::python::incref(boost::python::object(ss).ptr());
         }
-        return NULL;
+        return boost::python::incref(boost::python::object().ptr());
     }
 };
 
 struct make_python_pst_item_email {
     static PyObject* convert(pst_item_email* const &s) {
         if (s) return to_python_indirect<pst_item_email*, detail::make_reference_holder>()(s);
-        return NULL;
+        return boost::python::incref(boost::python::object().ptr());
     }
 };
 
 struct make_python_pst_item_attach {
     static PyObject* convert(pst_item_attach* const &s) {
         if (s) return to_python_indirect<pst_item_attach*, detail::make_reference_holder>()(s);
-        return NULL;
+        return boost::python::incref(boost::python::object().ptr());
     }
 };
 
 struct make_python_pst_desc_tree {
     static PyObject* convert(pst_desc_tree* const &s) {
         if (s) return to_python_indirect<pst_desc_tree*, detail::make_reference_holder>()(s);
-        return NULL;
+        return boost::python::incref(boost::python::object().ptr());
     }
 };
 
 struct make_python_pst_index_ll {
     static PyObject* convert(pst_index_ll* const &s) {
         if (s) return to_python_indirect<pst_index_ll*, detail::make_reference_holder>()(s);
-        return NULL;
+        return boost::python::incref(boost::python::object().ptr());
     }
 };
 
 struct make_python_FILE {
     static PyObject* convert(FILE* const &s) {
         if (s) return to_python_indirect<FILE*, detail::make_reference_holder>()(s);
-        return NULL;
+        return boost::python::incref(boost::python::object().ptr());
     }
 };
 
@@ -255,116 +254,116 @@
         ;
 
     class_<FILETIME>("FILETIME")
-        .def_readwrite("dwLowDateTime",  &FILETIME::dwLowDateTime)
-        .def_readwrite("dwHighDateTime", &FILETIME::dwHighDateTime)
+        .def_readwrite("dwLowDateTime",         &FILETIME::dwLowDateTime)
+        .def_readwrite("dwHighDateTime",        &FILETIME::dwHighDateTime)
         ;
 
     class_<pst_entryid>("pst_entryid")
-        .def_readonly("u1",      &pst_entryid::u1)
-        .def_readonly("entryid", &pst_entryid::entryid)
-        .def_readonly("id",      &pst_entryid::id)
+        .def_readonly("u1",                     &pst_entryid::u1)
+        .def_readonly("entryid",                &pst_entryid::entryid)
+        .def_readonly("id",                     &pst_entryid::id)
         ;
 
     class_<pst_index_ll>("pst_index_ll")
-        .def_readonly("i_id",               &pst_index_ll::i_id)
-        .def_readonly("offset",             &pst_index_ll::offset)
-        .def_readonly("size",               &pst_index_ll::size)
-        .def_readonly("u1",                 &pst_index_ll::u1)
-        .add_property("next",   make_getter(&pst_index_ll::next, return_value_policy<reference_existing_object>()))
+        .def_readonly("i_id",                   &pst_index_ll::i_id)
+        .def_readonly("offset",                 &pst_index_ll::offset)
+        .def_readonly("size",                   &pst_index_ll::size)
+        .def_readonly("u1",                     &pst_index_ll::u1)
+        .add_property("next",                   make_getter(&pst_index_ll::next, return_value_policy<reference_existing_object>()))
         ;
 
     class_<pst_id2_tree>("pst_id2_tree")
-        .def_readonly("id2",               &pst_id2_tree::id2)
-        .add_property("id",    make_getter(&pst_id2_tree::id,    return_value_policy<reference_existing_object>()))
-        .add_property("child", make_getter(&pst_id2_tree::child, return_value_policy<reference_existing_object>()))
-        .add_property("next",  make_getter(&pst_id2_tree::next,  return_value_policy<reference_existing_object>()))
+        .def_readonly("id2",                    &pst_id2_tree::id2)
+        .add_property("id",                     make_getter(&pst_id2_tree::id,    return_value_policy<reference_existing_object>()))
+        .add_property("child",                  make_getter(&pst_id2_tree::child, return_value_policy<reference_existing_object>()))
+        .add_property("next",                   make_getter(&pst_id2_tree::next,  return_value_policy<reference_existing_object>()))
         ;
 
     class_<pst_desc_tree>("pst_desc_tree")
-        .def_readonly("d_id",                    &pst_desc_tree::d_id)
-        .def_readonly("parent_d_id",             &pst_desc_tree::parent_d_id)
-        .add_property("desc",        make_getter(&pst_desc_tree::desc,       return_value_policy<reference_existing_object>()))
-        .add_property("assoc_tree",  make_getter(&pst_desc_tree::assoc_tree, return_value_policy<reference_existing_object>()))
-        .def_readonly("no_child",                &pst_desc_tree::no_child)
-        .add_property("prev",        make_getter(&pst_desc_tree::prev,       return_value_policy<reference_existing_object>()))
-        .add_property("next",        make_getter(&pst_desc_tree::next,       return_value_policy<reference_existing_object>()))
-        .add_property("parent",      make_getter(&pst_desc_tree::parent,     return_value_policy<reference_existing_object>()))
-        .add_property("child",       make_getter(&pst_desc_tree::child,      return_value_policy<reference_existing_object>()))
-        .add_property("child_tail",  make_getter(&pst_desc_tree::child_tail, return_value_policy<reference_existing_object>()))
+        .def_readonly("d_id",                   &pst_desc_tree::d_id)
+        .def_readonly("parent_d_id",            &pst_desc_tree::parent_d_id)
+        .add_property("desc",                   make_getter(&pst_desc_tree::desc,       return_value_policy<reference_existing_object>()))
+        .add_property("assoc_tree",             make_getter(&pst_desc_tree::assoc_tree, return_value_policy<reference_existing_object>()))
+        .def_readonly("no_child",               &pst_desc_tree::no_child)
+        .add_property("prev",                   make_getter(&pst_desc_tree::prev,       return_value_policy<reference_existing_object>()))
+        .add_property("next",                   make_getter(&pst_desc_tree::next,       return_value_policy<reference_existing_object>()))
+        .add_property("parent",                 make_getter(&pst_desc_tree::parent,     return_value_policy<reference_existing_object>()))
+        .add_property("child",                  make_getter(&pst_desc_tree::child,      return_value_policy<reference_existing_object>()))
+        .add_property("child_tail",             make_getter(&pst_desc_tree::child_tail, return_value_policy<reference_existing_object>()))
         ;
 
     class_<pst_string>("pst_string")
-        .def_readonly("is_utf8", &pst_string::is_utf8)
-        .def_readonly("str",     &pst_string::str)
+        .def_readonly("is_utf8",                &pst_string::is_utf8)
+        .def_readonly("str",                    &pst_string::str)
         ;
 
     class_<pst_item_email>("pst_item_email")
-        .add_property("arrival_date",    make_getter(&pst_item_email::arrival_date, return_value_policy<reference_existing_object>()))
-        .def_readonly("autoforward",                 &pst_item_email::autoforward)
-        .def_readonly("cc_address",                  &pst_item_email::cc_address)
-        .def_readonly("bcc_address",                 &pst_item_email::bcc_address)
-        .def_readonly("conversation_index",          &pst_item_email::conversation_index)
-        .def_readonly("conversion_prohibited",       &pst_item_email::conversion_prohibited)
-        .def_readonly("delete_after_submit",         &pst_item_email::delete_after_submit)
-        .def_readonly("delivery_report",             &pst_item_email::delivery_report)
-        .def_readonly("encrypted_body",              &pst_item_email::encrypted_body)
-        .def_readonly("encrypted_htmlbody",          &pst_item_email::encrypted_htmlbody)
-        .def_readonly("header",                      &pst_item_email::header)
-        .def_readonly("htmlbody",                    &pst_item_email::htmlbody)
-        .def_readonly("importance",                  &pst_item_email::importance)
-        .def_readonly("in_reply_to",                 &pst_item_email::in_reply_to)
-        .def_readonly("message_cc_me",               &pst_item_email::message_cc_me)
-        .def_readonly("message_recip_me",            &pst_item_email::message_recip_me)
-        .def_readonly("message_to_me",               &pst_item_email::message_to_me)
-        .def_readonly("messageid",                   &pst_item_email::messageid)
-        .def_readonly("original_sensitivity",        &pst_item_email::original_sensitivity)
-        .def_readonly("original_bcc",                &pst_item_email::original_bcc)
-        .def_readonly("original_cc",                 &pst_item_email::original_cc)
-        .def_readonly("original_to",                 &pst_item_email::original_to)
-        .def_readonly("outlook_recipient",           &pst_item_email::outlook_recipient)
-        .def_readonly("outlook_recipient_name",      &pst_item_email::outlook_recipient_name)
-        .def_readonly("outlook_recipient2",          &pst_item_email::outlook_recipient2)
-        .def_readonly("outlook_sender",              &pst_item_email::outlook_sender)
-        .def_readonly("outlook_sender_name",         &pst_item_email::outlook_sender_name)
-        .def_readonly("outlook_sender2",             &pst_item_email::outlook_sender2)
-        .def_readonly("priority",                    &pst_item_email::priority)
-        .def_readonly("processed_subject",           &pst_item_email::processed_subject)
-        .def_readonly("read_receipt",                &pst_item_email::read_receipt)
-        .def_readonly("recip_access",                &pst_item_email::recip_access)
-        .def_readonly("recip_address",               &pst_item_email::recip_address)
-        .def_readonly("recip2_access",               &pst_item_email::recip2_access)
-        .def_readonly("recip2_address",              &pst_item_email::recip2_address)
-        .def_readonly("reply_requested",             &pst_item_email::reply_requested)
-        .def_readonly("reply_to",                    &pst_item_email::reply_to)
-        .def_readonly("return_path_address",         &pst_item_email::return_path_address)
-        .def_readonly("rtf_body_char_count",         &pst_item_email::rtf_body_char_count)
-        .def_readonly("rtf_body_crc",                &pst_item_email::rtf_body_crc)
-        .def_readonly("rtf_body_tag",                &pst_item_email::rtf_body_tag)
-        .def_readonly("rtf_compressed",              &pst_item_email::rtf_compressed)
-        .def_readonly("rtf_in_sync",                 &pst_item_email::rtf_in_sync)
-        .def_readonly("rtf_ws_prefix_count",         &pst_item_email::rtf_ws_prefix_count)
-        .def_readonly("rtf_ws_trailing_count",       &pst_item_email::rtf_ws_trailing_count)
-        .def_readonly("sender_access",               &pst_item_email::sender_access)
-        .def_readonly("sender_address",              &pst_item_email::sender_address)
-        .def_readonly("sender2_access",              &pst_item_email::sender2_access)
-        .def_readonly("sender2_address",             &pst_item_email::sender2_address)
-        .def_readonly("sensitivity",                 &pst_item_email::sensitivity)
-        .add_property("sent_date",       make_getter(&pst_item_email::sent_date, return_value_policy<reference_existing_object>()))
-        .add_property("sentmail_folder", make_getter(&pst_item_email::sentmail_folder, return_value_policy<reference_existing_object>()))
-        .def_readonly("sentto_address",              &pst_item_email::sentto_address)
-        .def_readonly("report_text",                 &pst_item_email::report_text)
-        .add_property("report_time",     make_getter(&pst_item_email::report_time, return_value_policy<reference_existing_object>()))
-        .def_readonly("ndr_reason_code",             &pst_item_email::ndr_reason_code)
-        .def_readonly("ndr_diag_code",               &pst_item_email::ndr_diag_code)
-        .def_readonly("supplementary_info",          &pst_item_email::supplementary_info)
-        .def_readonly("ndr_status_code",             &pst_item_email::ndr_status_code)
+        .add_property("arrival_date",           make_getter(&pst_item_email::arrival_date, return_value_policy<reference_existing_object>()))
+        .def_readonly("autoforward",            &pst_item_email::autoforward)
+        .def_readonly("cc_address",             &pst_item_email::cc_address)
+        .def_readonly("bcc_address",            &pst_item_email::bcc_address)
+        .add_property("conversation_index",     make_getter(&pst_item_email::conversation_index, return_value_policy<return_by_value>()))
+        .def_readonly("conversion_prohibited",  &pst_item_email::conversion_prohibited)
+        .def_readonly("delete_after_submit",    &pst_item_email::delete_after_submit)
+        .def_readonly("delivery_report",        &pst_item_email::delivery_report)
+        .add_property("encrypted_body",         make_getter(&pst_item_email::encrypted_body, return_value_policy<return_by_value>()))
+        .add_property("encrypted_htmlbody",     make_getter(&pst_item_email::encrypted_htmlbody, return_value_policy<return_by_value>()))
+        .def_readonly("header",                 &pst_item_email::header)
+        .def_readonly("htmlbody",               &pst_item_email::htmlbody)
+        .def_readonly("importance",             &pst_item_email::importance)
+        .def_readonly("in_reply_to",            &pst_item_email::in_reply_to)
+        .def_readonly("message_cc_me",          &pst_item_email::message_cc_me)
+        .def_readonly("message_recip_me",       &pst_item_email::message_recip_me)
+        .def_readonly("message_to_me",          &pst_item_email::message_to_me)
+        .def_readonly("messageid",              &pst_item_email::messageid)
+        .def_readonly("original_sensitivity",   &pst_item_email::original_sensitivity)
+        .def_readonly("original_bcc",           &pst_item_email::original_bcc)
+        .def_readonly("original_cc",            &pst_item_email::original_cc)
+        .def_readonly("original_to",            &pst_item_email::original_to)
+        .def_readonly("outlook_recipient",      &pst_item_email::outlook_recipient)
+        .def_readonly("outlook_recipient_name", &pst_item_email::outlook_recipient_name)
+        .def_readonly("outlook_recipient2",     &pst_item_email::outlook_recipient2)
+        .def_readonly("outlook_sender",         &pst_item_email::outlook_sender)
+        .def_readonly("outlook_sender_name",    &pst_item_email::outlook_sender_name)
+        .def_readonly("outlook_sender2",        &pst_item_email::outlook_sender2)
+        .def_readonly("priority",               &pst_item_email::priority)
+        .def_readonly("processed_subject",      &pst_item_email::processed_subject)
+        .def_readonly("read_receipt",           &pst_item_email::read_receipt)
+        .def_readonly("recip_access",           &pst_item_email::recip_access)
+        .def_readonly("recip_address",          &pst_item_email::recip_address)
+        .def_readonly("recip2_access",          &pst_item_email::recip2_access)
+        .def_readonly("recip2_address",         &pst_item_email::recip2_address)
+        .def_readonly("reply_requested",        &pst_item_email::reply_requested)
+        .def_readonly("reply_to",               &pst_item_email::reply_to)
+        .def_readonly("return_path_address",    &pst_item_email::return_path_address)
+        .def_readonly("rtf_body_char_count",    &pst_item_email::rtf_body_char_count)
+        .def_readonly("rtf_body_crc",           &pst_item_email::rtf_body_crc)
+        .def_readonly("rtf_body_tag",           &pst_item_email::rtf_body_tag)
+        .add_property("rtf_compressed",         make_getter(&pst_item_email::rtf_compressed, return_value_policy<return_by_value>()))
+        .def_readonly("rtf_in_sync",            &pst_item_email::rtf_in_sync)
+        .def_readonly("rtf_ws_prefix_count",    &pst_item_email::rtf_ws_prefix_count)
+        .def_readonly("rtf_ws_trailing_count",  &pst_item_email::rtf_ws_trailing_count)
+        .def_readonly("sender_access",          &pst_item_email::sender_access)
+        .def_readonly("sender_address",         &pst_item_email::sender_address)
+        .def_readonly("sender2_access",         &pst_item_email::sender2_access)
+        .def_readonly("sender2_address",        &pst_item_email::sender2_address)
+        .def_readonly("sensitivity",            &pst_item_email::sensitivity)
+        .add_property("sent_date",              make_getter(&pst_item_email::sent_date, return_value_policy<reference_existing_object>()))
+        .add_property("sentmail_folder",        make_getter(&pst_item_email::sentmail_folder, return_value_policy<reference_existing_object>()))
+        .def_readonly("sentto_address",         &pst_item_email::sentto_address)
+        .def_readonly("report_text",            &pst_item_email::report_text)
+        .add_property("report_time",            make_getter(&pst_item_email::report_time, return_value_policy<reference_existing_object>()))
+        .def_readonly("ndr_reason_code",        &pst_item_email::ndr_reason_code)
+        .def_readonly("ndr_diag_code",          &pst_item_email::ndr_diag_code)
+        .def_readonly("supplementary_info",     &pst_item_email::supplementary_info)
+        .def_readonly("ndr_status_code",        &pst_item_email::ndr_status_code)
         ;
 
     class_<pst_item_folder>("pst_item_folder")
-        .def_readonly("item_count",        &pst_item_folder::item_count)
-        .def_readonly("unseen_item_count", &pst_item_folder::unseen_item_count)
-        .def_readonly("assoc_count",       &pst_item_folder::assoc_count)
-        .def_readonly("subfolder",         &pst_item_folder::subfolder)
+        .def_readonly("item_count",             &pst_item_folder::item_count)
+        .def_readonly("unseen_item_count",      &pst_item_folder::unseen_item_count)
+        .def_readonly("assoc_count",            &pst_item_folder::assoc_count)
+        .def_readonly("subfolder",              &pst_item_folder::subfolder)
         ;
 
     class_<pst_item_message_store>("pst_item_message_store")
@@ -376,249 +375,250 @@
         .add_property("common_view_folder",     make_getter(&pst_item_message_store::common_view_folder, return_value_policy<reference_existing_object>()))
         .add_property("search_root_folder",     make_getter(&pst_item_message_store::search_root_folder, return_value_policy<reference_existing_object>()))
         .add_property("top_of_folder",          make_getter(&pst_item_message_store::top_of_folder, return_value_policy<reference_existing_object>()))
-        .def_readonly("valid_mask",                         &pst_item_message_store::valid_mask)
-        .def_readonly("pwd_chksum",                         &pst_item_message_store::pwd_chksum)
+        .def_readonly("valid_mask",             &pst_item_message_store::valid_mask)
+        .def_readonly("pwd_chksum",             &pst_item_message_store::pwd_chksum)
         ;
 
     class_<pst_item_contact>("pst_item_contact")
-        .def_readonly("account_name",                    &pst_item_contact::account_name)
-        .def_readonly("address1",                        &pst_item_contact::address1)
-        .def_readonly("address1a",                       &pst_item_contact::address1a)
-        .def_readonly("address1_desc",                   &pst_item_contact::address1_desc)
-        .def_readonly("address1_transport",              &pst_item_contact::address1_transport)
-        .def_readonly("address2",                        &pst_item_contact::address2)
-        .def_readonly("address2a",                       &pst_item_contact::address2a)
-        .def_readonly("address2_desc",                   &pst_item_contact::address2_desc)
-        .def_readonly("address2_transport",              &pst_item_contact::address2_transport)
-        .def_readonly("address3",                        &pst_item_contact::address3)
-        .def_readonly("address3a",                       &pst_item_contact::address3a)
-        .def_readonly("address3_desc",                   &pst_item_contact::address3_desc)
-        .def_readonly("address3_transport",              &pst_item_contact::address3_transport)
-        .def_readonly("assistant_name",                  &pst_item_contact::assistant_name)
-        .def_readonly("assistant_phone",                 &pst_item_contact::assistant_phone)
-        .def_readonly("billing_information",             &pst_item_contact::billing_information)
-        .add_property("birthday",            make_getter(&pst_item_contact::birthday, return_value_policy<reference_existing_object>()))
-        .def_readonly("business_address",                &pst_item_contact::business_address)
-        .def_readonly("business_city",                   &pst_item_contact::business_city)
-        .def_readonly("business_country",                &pst_item_contact::business_country)
-        .def_readonly("business_fax",                    &pst_item_contact::business_fax)
-        .def_readonly("business_homepage",               &pst_item_contact::business_homepage)
-        .def_readonly("business_phone",                  &pst_item_contact::business_phone)
-        .def_readonly("business_phone2",                 &pst_item_contact::business_phone2)
-        .def_readonly("business_po_box",                 &pst_item_contact::business_po_box)
-        .def_readonly("business_postal_code",            &pst_item_contact::business_postal_code)
-        .def_readonly("business_state",                  &pst_item_contact::business_state)
-        .def_readonly("business_street",                 &pst_item_contact::business_street)
-        .def_readonly("callback_phone",                  &pst_item_contact::callback_phone)
-        .def_readonly("car_phone",                       &pst_item_contact::car_phone)
-        .def_readonly("company_main_phone",              &pst_item_contact::company_main_phone)
-        .def_readonly("company_name",                    &pst_item_contact::company_name)
-        .def_readonly("computer_name",                   &pst_item_contact::computer_name)
-        .def_readonly("customer_id",                     &pst_item_contact::customer_id)
-        .def_readonly("def_postal_address",              &pst_item_contact::def_postal_address)
-        .def_readonly("department",                      &pst_item_contact::department)
-        .def_readonly("display_name_prefix",             &pst_item_contact::display_name_prefix)
-        .def_readonly("first_name",                      &pst_item_contact::first_name)
-        .def_readonly("followup",                        &pst_item_contact::followup)
-        .def_readonly("free_busy_address",               &pst_item_contact::free_busy_address)
-        .def_readonly("ftp_site",                        &pst_item_contact::ftp_site)
-        .def_readonly("fullname",                        &pst_item_contact::fullname)
-        .def_readonly("gender",                          &pst_item_contact::gender)
-        .def_readonly("gov_id",                          &pst_item_contact::gov_id)
-        .def_readonly("hobbies",                         &pst_item_contact::hobbies)
-        .def_readonly("home_address",                    &pst_item_contact::home_address)
-        .def_readonly("home_city",                       &pst_item_contact::home_city)
-        .def_readonly("home_country",                    &pst_item_contact::home_country)
-        .def_readonly("home_fax",                        &pst_item_contact::home_fax)
-        .def_readonly("home_phone",                      &pst_item_contact::home_phone)
-        .def_readonly("home_phone2",                     &pst_item_contact::home_phone2)
-        .def_readonly("home_po_box",                     &pst_item_contact::home_po_box)
-        .def_readonly("home_postal_code",                &pst_item_contact::home_postal_code)
-        .def_readonly("home_state",                      &pst_item_contact::home_state)
-        .def_readonly("home_street",                     &pst_item_contact::home_street)
-        .def_readonly("initials",                        &pst_item_contact::initials)
-        .def_readonly("isdn_phone",                      &pst_item_contact::isdn_phone)
-        .def_readonly("job_title",                       &pst_item_contact::job_title)
-        .def_readonly("keyword",                         &pst_item_contact::keyword)
-        .def_readonly("language",                        &pst_item_contact::language)
-        .def_readonly("location",                        &pst_item_contact::location)
-        .def_readonly("mail_permission",                 &pst_item_contact::mail_permission)
-        .def_readonly("manager_name",                    &pst_item_contact::manager_name)
-        .def_readonly("middle_name",                     &pst_item_contact::middle_name)
-        .def_readonly("mileage",                         &pst_item_contact::mileage)
-        .def_readonly("mobile_phone",                    &pst_item_contact::mobile_phone)
-        .def_readonly("nickname",                        &pst_item_contact::nickname)
-        .def_readonly("office_loc",                      &pst_item_contact::office_loc)
-        .def_readonly("common_name",                     &pst_item_contact::common_name)
-        .def_readonly("org_id",                          &pst_item_contact::org_id)
-        .def_readonly("other_address",                   &pst_item_contact::other_address)
-        .def_readonly("other_city",                      &pst_item_contact::other_city)
-        .def_readonly("other_country",                   &pst_item_contact::other_country)
-        .def_readonly("other_phone",                     &pst_item_contact::other_phone)
-        .def_readonly("other_po_box",                    &pst_item_contact::other_po_box)
-        .def_readonly("other_postal_code",               &pst_item_contact::other_postal_code)
-        .def_readonly("other_state",                     &pst_item_contact::other_state)
-        .def_readonly("other_street",                    &pst_item_contact::other_street)
-        .def_readonly("pager_phone",                     &pst_item_contact::pager_phone)
-        .def_readonly("personal_homepage",               &pst_item_contact::personal_homepage)
-        .def_readonly("pref_name",                       &pst_item_contact::pref_name)
-        .def_readonly("primary_fax",                     &pst_item_contact::primary_fax)
-        .def_readonly("primary_phone",                   &pst_item_contact::primary_phone)
-        .def_readonly("profession",                      &pst_item_contact::profession)
-        .def_readonly("radio_phone",                     &pst_item_contact::radio_phone)
-        .def_readonly("rich_text",                       &pst_item_contact::rich_text)
-        .def_readonly("spouse_name",                     &pst_item_contact::spouse_name)
-        .def_readonly("suffix",                          &pst_item_contact::suffix)
-        .def_readonly("surname",                         &pst_item_contact::surname)
-        .def_readonly("telex",                           &pst_item_contact::telex)
-        .def_readonly("transmittable_display_name",      &pst_item_contact::transmittable_display_name)
-        .def_readonly("ttytdd_phone",                    &pst_item_contact::ttytdd_phone)
-        .add_property("wedding_anniversary", make_getter(&pst_item_contact::wedding_anniversary, return_value_policy<reference_existing_object>()))
-        .def_readonly("work_address_street",             &pst_item_contact::work_address_street)
-        .def_readonly("work_address_city",               &pst_item_contact::work_address_city)
-        .def_readonly("work_address_state",              &pst_item_contact::work_address_state)
-        .def_readonly("work_address_postalcode",         &pst_item_contact::work_address_postalcode)
-        .def_readonly("work_address_country",            &pst_item_contact::work_address_country)
-        .def_readonly("work_address_postofficebox",      &pst_item_contact::work_address_postofficebox)
+        .def_readonly("account_name",           &pst_item_contact::account_name)
+        .def_readonly("address1",               &pst_item_contact::address1)
+        .def_readonly("address1a",              &pst_item_contact::address1a)
+        .def_readonly("address1_desc",          &pst_item_contact::address1_desc)
+        .def_readonly("address1_transport",     &pst_item_contact::address1_transport)
+        .def_readonly("address2",               &pst_item_contact::address2)
+        .def_readonly("address2a",              &pst_item_contact::address2a)
+        .def_readonly("address2_desc",          &pst_item_contact::address2_desc)
+        .def_readonly("address2_transport",     &pst_item_contact::address2_transport)
+        .def_readonly("address3",               &pst_item_contact::address3)
+        .def_readonly("address3a",              &pst_item_contact::address3a)
+        .def_readonly("address3_desc",          &pst_item_contact::address3_desc)
+        .def_readonly("address3_transport",     &pst_item_contact::address3_transport)
+        .def_readonly("assistant_name",         &pst_item_contact::assistant_name)
+        .def_readonly("assistant_phone",        &pst_item_contact::assistant_phone)
+        .def_readonly("billing_information",    &pst_item_contact::billing_information)
+        .add_property("birthday",               make_getter(&pst_item_contact::birthday, return_value_policy<reference_existing_object>()))
+        .def_readonly("business_address",       &pst_item_contact::business_address)
+        .def_readonly("business_city",          &pst_item_contact::business_city)
+        .def_readonly("business_country",       &pst_item_contact::business_country)
+        .def_readonly("business_fax",           &pst_item_contact::business_fax)
+        .def_readonly("business_homepage",      &pst_item_contact::business_homepage)
+        .def_readonly("business_phone",         &pst_item_contact::business_phone)
+        .def_readonly("business_phone2",        &pst_item_contact::business_phone2)
+        .def_readonly("business_po_box",        &pst_item_contact::business_po_box)
+        .def_readonly("business_postal_code",   &pst_item_contact::business_postal_code)
+        .def_readonly("business_state",         &pst_item_contact::business_state)
+        .def_readonly("business_street",        &pst_item_contact::business_street)
+        .def_readonly("callback_phone",         &pst_item_contact::callback_phone)
+        .def_readonly("car_phone",              &pst_item_contact::car_phone)
+        .def_readonly("company_main_phone",     &pst_item_contact::company_main_phone)
+        .def_readonly("company_name",           &pst_item_contact::company_name)
+        .def_readonly("computer_name",          &pst_item_contact::computer_name)
+        .def_readonly("customer_id",            &pst_item_contact::customer_id)
+        .def_readonly("def_postal_address",     &pst_item_contact::def_postal_address)
+        .def_readonly("department",             &pst_item_contact::department)
+        .def_readonly("display_name_prefix",    &pst_item_contact::display_name_prefix)
+        .def_readonly("first_name",             &pst_item_contact::first_name)
+        .def_readonly("followup",               &pst_item_contact::followup)
+        .def_readonly("free_busy_address",      &pst_item_contact::free_busy_address)
+        .def_readonly("ftp_site",               &pst_item_contact::ftp_site)
+        .def_readonly("fullname",               &pst_item_contact::fullname)
+        .def_readonly("gender",                 &pst_item_contact::gender)
+        .def_readonly("gov_id",                 &pst_item_contact::gov_id)
+        .def_readonly("hobbies",                &pst_item_contact::hobbies)
+        .def_readonly("home_address",           &pst_item_contact::home_address)
+        .def_readonly("home_city",              &pst_item_contact::home_city)
+        .def_readonly("home_country",           &pst_item_contact::home_country)
+        .def_readonly("home_fax",               &pst_item_contact::home_fax)
+        .def_readonly("home_phone",             &pst_item_contact::home_phone)
+        .def_readonly("home_phone2",            &pst_item_contact::home_phone2)
+        .def_readonly("home_po_box",            &pst_item_contact::home_po_box)
+        .def_readonly("home_postal_code",       &pst_item_contact::home_postal_code)
+        .def_readonly("home_state",             &pst_item_contact::home_state)
+        .def_readonly("home_street",            &pst_item_contact::home_street)
+        .def_readonly("initials",               &pst_item_contact::initials)
+        .def_readonly("isdn_phone",             &pst_item_contact::isdn_phone)
+        .def_readonly("job_title",              &pst_item_contact::job_title)
+        .def_readonly("keyword",                &pst_item_contact::keyword)
+        .def_readonly("language",               &pst_item_contact::language)
+        .def_readonly("location",               &pst_item_contact::location)
+        .def_readonly("mail_permission",        &pst_item_contact::mail_permission)
+        .def_readonly("manager_name",           &pst_item_contact::manager_name)
+        .def_readonly("middle_name",            &pst_item_contact::middle_name)
+        .def_readonly("mileage",                &pst_item_contact::mileage)
+        .def_readonly("mobile_phone",           &pst_item_contact::mobile_phone)
+        .def_readonly("nickname",               &pst_item_contact::nickname)
+        .def_readonly("office_loc",             &pst_item_contact::office_loc)
+        .def_readonly("common_name",            &pst_item_contact::common_name)
+        .def_readonly("org_id",                 &pst_item_contact::org_id)
+        .def_readonly("other_address",          &pst_item_contact::other_address)
+        .def_readonly("other_city",             &pst_item_contact::other_city)
+        .def_readonly("other_country",          &pst_item_contact::other_country)
+        .def_readonly("other_phone",            &pst_item_contact::other_phone)
+        .def_readonly("other_po_box",           &pst_item_contact::other_po_box)
+        .def_readonly("other_postal_code",      &pst_item_contact::other_postal_code)
+        .def_readonly("other_state",            &pst_item_contact::other_state)
+        .def_readonly("other_street",           &pst_item_contact::other_street)
+        .def_readonly("pager_phone",            &pst_item_contact::pager_phone)
+        .def_readonly("personal_homepage",      &pst_item_contact::personal_homepage)
+        .def_readonly("pref_name",              &pst_item_contact::pref_name)
+        .def_readonly("primary_fax",            &pst_item_contact::primary_fax)
+        .def_readonly("primary_phone",          &pst_item_contact::primary_phone)
+        .def_readonly("profession",             &pst_item_contact::profession)
+        .def_readonly("radio_phone",            &pst_item_contact::radio_phone)
+        .def_readonly("rich_text",              &pst_item_contact::rich_text)
+        .def_readonly("spouse_name",            &pst_item_contact::spouse_name)
+        .def_readonly("suffix",                 &pst_item_contact::suffix)
+        .def_readonly("surname",                &pst_item_contact::surname)
+        .def_readonly("telex",                  &pst_item_contact::telex)
+        .def_readonly("transmittable_display_name", &pst_item_contact::transmittable_display_name)
+        .def_readonly("ttytdd_phone",               &pst_item_contact::ttytdd_phone)
+        .add_property("wedding_anniversary",        make_getter(&pst_item_contact::wedding_anniversary, return_value_policy<reference_existing_object>()))
+        .def_readonly("work_address_street",        &pst_item_contact::work_address_street)
+        .def_readonly("work_address_city",          &pst_item_contact::work_address_city)
+        .def_readonly("work_address_state",         &pst_item_contact::work_address_state)
+        .def_readonly("work_address_postalcode",    &pst_item_contact::work_address_postalcode)
+        .def_readonly("work_address_country",       &pst_item_contact::work_address_country)
+        .def_readonly("work_address_postofficebox", &pst_item_contact::work_address_postofficebox)
         ;
 
     class_<pst_item_attach>("pst_item_attach")
-        .def_readonly("filename1",             &pst_item_attach::filename1)
-        .def_readonly("filename2",             &pst_item_attach::filename2)
-        .def_readonly("mimetype",              &pst_item_attach::mimetype)
-        .def_readonly("data",                  &pst_item_attach::data)
-        .def_readonly("id2_val",               &pst_item_attach::id2_val)
-        .def_readonly("i_id",                  &pst_item_attach::i_id)
-        .add_property("id2_head",  make_getter(&pst_item_attach::id2_head, return_value_policy<reference_existing_object>()))
-        .def_readonly("method",                &pst_item_attach::method)
-        .def_readonly("position",              &pst_item_attach::position)
-        .def_readonly("sequence",              &pst_item_attach::sequence)
-        .add_property("next",      make_getter(&pst_item_attach::next, return_value_policy<reference_existing_object>()))
+        .def_readonly("filename1",              &pst_item_attach::filename1)
+        .def_readonly("filename2",              &pst_item_attach::filename2)
+        .def_readonly("mimetype",               &pst_item_attach::mimetype)
+        .add_property("data",                   make_getter(&pst_item_attach::data, return_value_policy<return_by_value>()))
+        .def_readonly("id2_val",                &pst_item_attach::id2_val)
+        .def_readonly("i_id",                   &pst_item_attach::i_id)
+        .add_property("id2_head",               make_getter(&pst_item_attach::id2_head, return_value_policy<reference_existing_object>()))
+        .def_readonly("method",                 &pst_item_attach::method)
+        .def_readonly("position",               &pst_item_attach::position)
+        .def_readonly("sequence",               &pst_item_attach::sequence)
+        .add_property("next",                   make_getter(&pst_item_attach::next, return_value_policy<reference_existing_object>()))
         ;
 
     class_<pst_item_extra_field>("pst_item_extra_field")
-        .def_readonly("field_name",       &pst_item_extra_field::field_name)
-        .def_readonly("value",            &pst_item_extra_field::value)
-        .add_property("next", make_getter(&pst_item_extra_field::next, return_value_policy<reference_existing_object>()))
+        .def_readonly("field_name",             &pst_item_extra_field::field_name)
+        .def_readonly("value",                  &pst_item_extra_field::value)
+        .add_property("next",                   make_getter(&pst_item_extra_field::next, return_value_policy<reference_existing_object>()))
         ;
 
     class_<pst_item_journal>("pst_item_journal")
-        .add_property("start", make_getter(&pst_item_journal::start, return_value_policy<reference_existing_object>()))
-        .add_property("end",   make_getter(&pst_item_journal::end, return_value_policy<reference_existing_object>()))
-        .def_readonly("type",              &pst_item_journal::type)
-        .def_readonly("description",       &pst_item_journal::description)
+        .add_property("start",                  make_getter(&pst_item_journal::start, return_value_policy<reference_existing_object>()))
+        .add_property("end",                    make_getter(&pst_item_journal::end, return_value_policy<reference_existing_object>()))
+        .def_readonly("type",                   &pst_item_journal::type)
+        .def_readonly("description",            &pst_item_journal::description)
         ;
 
     class_<pst_recurrence>("pst_recurrence")
-        .def_readonly("signature",                    &pst_recurrence::signature)
-        .def_readonly("type",                         &pst_recurrence::type)
-        .def_readonly("sub_type",                     &pst_recurrence::sub_type)
-        .def_readonly("parm1",                        &pst_recurrence::parm1)
-        .def_readonly("parm2",                        &pst_recurrence::parm2)
-        .def_readonly("parm3",                        &pst_recurrence::parm3)
-        .def_readonly("parm4",                        &pst_recurrence::parm4)
-        .def_readonly("parm5",                        &pst_recurrence::parm5)
-        .def_readonly("termination",                  &pst_recurrence::termination)
-        .def_readonly("interval",                     &pst_recurrence::interval)
-        .def_readonly("bydaymask",                    &pst_recurrence::bydaymask)
-        .def_readonly("dayofmonth",                   &pst_recurrence::dayofmonth)
-        .def_readonly("monthofyear",                  &pst_recurrence::monthofyear)
-        .def_readonly("position",                     &pst_recurrence::position)
-        .def_readonly("count",                        &pst_recurrence::count)
+        .def_readonly("signature",              &pst_recurrence::signature)
+        .def_readonly("type",                   &pst_recurrence::type)
+        .def_readonly("sub_type",               &pst_recurrence::sub_type)
+        .def_readonly("parm1",                  &pst_recurrence::parm1)
+        .def_readonly("parm2",                  &pst_recurrence::parm2)
+        .def_readonly("parm3",                  &pst_recurrence::parm3)
+        .def_readonly("parm4",                  &pst_recurrence::parm4)
+        .def_readonly("parm5",                  &pst_recurrence::parm5)
+        .def_readonly("termination",            &pst_recurrence::termination)
+        .def_readonly("interval",               &pst_recurrence::interval)
+        .def_readonly("bydaymask",              &pst_recurrence::bydaymask)
+        .def_readonly("dayofmonth",             &pst_recurrence::dayofmonth)
+        .def_readonly("monthofyear",            &pst_recurrence::monthofyear)
+        .def_readonly("position",               &pst_recurrence::position)
+        .def_readonly("count",                  &pst_recurrence::count)
         ;
 
     class_<pst_item_appointment>("pst_item_appointment")
-        .add_property("start",            make_getter(&pst_item_appointment::start, return_value_policy<reference_existing_object>()))
-        .add_property("end",              make_getter(&pst_item_appointment::end, return_value_policy<reference_existing_object>()))
-        .def_readonly("location",                     &pst_item_appointment::location)
-        .def_readonly("alarm",                        &pst_item_appointment::alarm)
-        .add_property("reminder",         make_getter(&pst_item_appointment::reminder, return_value_policy<reference_existing_object>()))
-        .def_readonly("alarm_minutes",                &pst_item_appointment::alarm_minutes)
-        .def_readonly("alarm_filename",               &pst_item_appointment::alarm_filename)
-        .def_readonly("timezonestring",               &pst_item_appointment::timezonestring)
-        .def_readonly("showas",                       &pst_item_appointment::showas)
-        .def_readonly("label",                        &pst_item_appointment::label)
-        .def_readonly("all_day",                      &pst_item_appointment::all_day)
-        .def_readonly("is_recurring",                 &pst_item_appointment::is_recurring)
-        .def_readonly("recurrence_type",              &pst_item_appointment::recurrence_type)
-        .def_readonly("recurrence_description",       &pst_item_appointment::recurrence_description)
-        .def_readonly("recurrence_data",              &pst_item_appointment::recurrence_data)
-        .add_property("recurrence_start", make_getter(&pst_item_appointment::recurrence_start, return_value_policy<reference_existing_object>()))
-        .add_property("recurrence_end",   make_getter(&pst_item_appointment::recurrence_end, return_value_policy<reference_existing_object>()))
+        .add_property("start",                  make_getter(&pst_item_appointment::start, return_value_policy<reference_existing_object>()))
+        .add_property("end",                    make_getter(&pst_item_appointment::end, return_value_policy<reference_existing_object>()))
+        .def_readonly("location",               &pst_item_appointment::location)
+        .def_readonly("alarm",                  &pst_item_appointment::alarm)
+        .add_property("reminder",               make_getter(&pst_item_appointment::reminder, return_value_policy<reference_existing_object>()))
+        .def_readonly("alarm_minutes",          &pst_item_appointment::alarm_minutes)
+        .def_readonly("alarm_filename",         &pst_item_appointment::alarm_filename)
+        .def_readonly("timezonestring",         &pst_item_appointment::timezonestring)
+        .def_readonly("showas",                 &pst_item_appointment::showas)
+        .def_readonly("label",                  &pst_item_appointment::label)
+        .def_readonly("all_day",                &pst_item_appointment::all_day)
+        .def_readonly("is_recurring",           &pst_item_appointment::is_recurring)
+        .def_readonly("recurrence_type",        &pst_item_appointment::recurrence_type)
+        .def_readonly("recurrence_description", &pst_item_appointment::recurrence_description)
+        .add_property("recurrence_data",        make_getter(&pst_item_appointment::recurrence_data, return_value_policy<return_by_value>()))
+        .add_property("recurrence_start",       make_getter(&pst_item_appointment::recurrence_start, return_value_policy<reference_existing_object>()))
+        .add_property("recurrence_end",         make_getter(&pst_item_appointment::recurrence_end, return_value_policy<reference_existing_object>()))
         ;
 
     class_<pst_item>("pst_item")
-        .add_property("email",           make_getter(&pst_item::email,         return_value_policy<reference_existing_object>()))
-        .add_property("folder",          make_getter(&pst_item::folder,        return_value_policy<reference_existing_object>()))
-        .add_property("contact",         make_getter(&pst_item::contact,       return_value_policy<reference_existing_object>()))
-        .add_property("attach",          make_getter(&pst_item::attach,        return_value_policy<reference_existing_object>()))
-        .add_property("message_store",   make_getter(&pst_item::message_store, return_value_policy<reference_existing_object>()))
-        .add_property("extra_fields",    make_getter(&pst_item::extra_fields,  return_value_policy<reference_existing_object>()))
-        .add_property("journal",         make_getter(&pst_item::journal,       return_value_policy<reference_existing_object>()))
-        .add_property("appointment",     make_getter(&pst_item::appointment,   return_value_policy<reference_existing_object>()))
-        .def_readonly("type",                        &pst_item::type)
-        .def_readonly("ascii_type",                  &pst_item::ascii_type)
-        .def_readonly("flags",                       &pst_item::flags)
-        .def_readonly("file_as",                     &pst_item::file_as)
-        .def_readonly("comment",                     &pst_item::comment)
-        .def_readonly("body_charset",                &pst_item::body_charset)
-        .def_readonly("body",                        &pst_item::body)
-        .def_readonly("subject",                     &pst_item::subject)
-        .def_readonly("internet_cpid",               &pst_item::internet_cpid)
-        .def_readonly("message_codepage",            &pst_item::message_codepage)
-        .def_readonly("message_size",                &pst_item::message_size)
-        .def_readonly("outlook_version",             &pst_item::outlook_version)
-        .def_readonly("record_key",                  &pst_item::record_key)
-        .def_readonly("predecessor_change",          &pst_item::predecessor_change)
-        .def_readonly("response_requested",          &pst_item::response_requested)
-        .add_property("create_date",     make_getter(&pst_item::create_date, return_value_policy<reference_existing_object>()))
-        .add_property("modify_date",     make_getter(&pst_item::modify_date, return_value_policy<reference_existing_object>()))
-        .def_readonly("private_member",              &pst_item::private_member)
+        .add_property("email",                  make_getter(&pst_item::email,         return_value_policy<reference_existing_object>()))
+        .add_property("folder",                 make_getter(&pst_item::folder,        return_value_policy<reference_existing_object>()))
+        .add_property("contact",                make_getter(&pst_item::contact,       return_value_policy<reference_existing_object>()))
+        .add_property("attach",                 make_getter(&pst_item::attach,        return_value_policy<reference_existing_object>()))
+        .add_property("message_store",          make_getter(&pst_item::message_store, return_value_policy<reference_existing_object>()))
+        .add_property("extra_fields",           make_getter(&pst_item::extra_fields,  return_value_policy<reference_existing_object>()))
+        .add_property("journal",                make_getter(&pst_item::journal,       return_value_policy<reference_existing_object>()))
+        .add_property("appointment",            make_getter(&pst_item::appointment,   return_value_policy<reference_existing_object>()))
+        .def_readonly("block_id",               &pst_item::block_id)
+        .def_readonly("type",                   &pst_item::type)
+        .def_readonly("ascii_type",             &pst_item::ascii_type)
+        .def_readonly("flags",                  &pst_item::flags)
+        .def_readonly("file_as",                &pst_item::file_as)
+        .def_readonly("comment",                &pst_item::comment)
+        .def_readonly("body_charset",           &pst_item::body_charset)
+        .def_readonly("body",                   &pst_item::body)
+        .def_readonly("subject",                &pst_item::subject)
+        .def_readonly("internet_cpid",          &pst_item::internet_cpid)
+        .def_readonly("message_codepage",       &pst_item::message_codepage)
+        .def_readonly("message_size",           &pst_item::message_size)
+        .def_readonly("outlook_version",        &pst_item::outlook_version)
+        .add_property("record_key",             make_getter(&pst_item::record_key, return_value_policy<return_by_value>()))
+        .add_property("predecessor_change",     make_getter(&pst_item::predecessor_change, return_value_policy<return_by_value>()))
+        .def_readonly("response_requested",     &pst_item::response_requested)
+        .add_property("create_date",            make_getter(&pst_item::create_date, return_value_policy<reference_existing_object>()))
+        .add_property("modify_date",            make_getter(&pst_item::modify_date, return_value_policy<reference_existing_object>()))
+        .def_readonly("private_member",         &pst_item::private_member)
         ;
 
     class_<pst_x_attrib_ll>("pst_x_attrib_ll")
-        .def_readonly("mytype",            &pst_x_attrib_ll::mytype)
-        .def_readonly("map",               &pst_x_attrib_ll::map)
-        .def_readonly("data",              &pst_x_attrib_ll::data)
-        .add_property("next",  make_getter(&pst_x_attrib_ll::next, return_value_policy<reference_existing_object>()))
+        .def_readonly("mytype",                 &pst_x_attrib_ll::mytype)
+        .def_readonly("map",                    &pst_x_attrib_ll::map)
+        .def_readonly("data",                   &pst_x_attrib_ll::data)
+        .add_property("next",                   make_getter(&pst_x_attrib_ll::next, return_value_policy<reference_existing_object>()))
         ;
 
     class_<pst_file>("pst_file")
-        .def_readonly("cwd",         &pst_file::cwd)
-        .def_readonly("fname",       &pst_file::fname)
-        .add_property("i_head",      make_getter(&pst_file::i_head, return_value_policy<reference_existing_object>()))
-        .add_property("i_tail",      make_getter(&pst_file::i_tail, return_value_policy<reference_existing_object>()))
-        .add_property("d_head",      make_getter(&pst_file::d_head, return_value_policy<reference_existing_object>()))
-        .add_property("d_tail",      make_getter(&pst_file::d_tail, return_value_policy<reference_existing_object>()))
-        .add_property("x_head",      make_getter(&pst_file::x_head, return_value_policy<reference_existing_object>()))
-        .def_readonly("do_read64",   &pst_file::do_read64)
-        .def_readonly("index1",      &pst_file::index1)
-        .def_readonly("index1_back", &pst_file::index1_back)
-        .def_readonly("index2",      &pst_file::index2)
-        .def_readonly("index2_back", &pst_file::index2_back)
-        .def_readonly("size",        &pst_file::size)
-        .def_readonly("encryption",  &pst_file::encryption)
-        .def_readonly("ind_type",    &pst_file::ind_type)
+        .def_readonly("cwd",                    &pst_file::cwd)
+        .def_readonly("fname",                  &pst_file::fname)
+        .add_property("i_head",                 make_getter(&pst_file::i_head, return_value_policy<reference_existing_object>()))
+        .add_property("i_tail",                 make_getter(&pst_file::i_tail, return_value_policy<reference_existing_object>()))
+        .add_property("d_head",                 make_getter(&pst_file::d_head, return_value_policy<reference_existing_object>()))
+        .add_property("d_tail",                 make_getter(&pst_file::d_tail, return_value_policy<reference_existing_object>()))
+        .add_property("x_head",                 make_getter(&pst_file::x_head, return_value_policy<reference_existing_object>()))
+        .def_readonly("do_read64",              &pst_file::do_read64)
+        .def_readonly("index1",                 &pst_file::index1)
+        .def_readonly("index1_back",            &pst_file::index1_back)
+        .def_readonly("index2",                 &pst_file::index2)
+        .def_readonly("index2_back",            &pst_file::index2_back)
+        .def_readonly("size",                   &pst_file::size)
+        .def_readonly("encryption",             &pst_file::encryption)
+        .def_readonly("ind_type",               &pst_file::ind_type)
         ;
 
-    class_<pst>("pst", init<string>())
-        .def("pst_getTopOfFolders",         &pst::pst_getTopOfFolders, return_value_policy<reference_existing_object>())
-        .def("pst_attach_to_mem",           &pst::pst_attach_to_mem)
-        .def("pst_attach_to_file",          &pst::pst_attach_to_file)
-        .def("pst_attach_to_file_base64",   &pst::pst_attach_to_file_base64)
-        .def("pst_getNextDptr",             &pst::pst_getNextDptr,     return_value_policy<reference_existing_object>())
-        .def("pst_parse_item",              &pst::pst_parse_item,      return_value_policy<reference_existing_object>())
-        .def("pst_freeItem",                &pst::pst_freeItem)
-        .def("pst_getID",                   &pst::pst_getID,           return_value_policy<reference_existing_object>())
-        .def("pst_ff_getIDblock_dec",       &pst::pst_ff_getIDblock_dec)
-        .def("pst_rfc2426_escape",          &pst::pst_rfc2426_escape)
-        .def("pst_rfc2425_datetime_format", &pst::pst_rfc2425_datetime_format)
-        .def("pst_rfc2445_datetime_format", &pst::pst_rfc2445_datetime_format)
-        .def("pst_default_charset",         &pst::pst_default_charset)
-        .def("pst_convert_utf8_null",       &pst::pst_convert_utf8_null)
-        .def("pst_convert_utf8",            &pst::pst_convert_utf8)
-        .def("ppst_open_file",              &pst::ppst_open_file,      return_value_policy<reference_existing_object>())
-        .def("ppst_close_file",             &pst::ppst_close_file)
+    class_<pst>("pst", init<string,string>())
+        .def("pst_getTopOfFolders",             &pst::pst_getTopOfFolders, return_value_policy<reference_existing_object>())
+        .def("pst_attach_to_mem",               &pst::pst_attach_to_mem)
+        .def("pst_attach_to_file",              &pst::pst_attach_to_file)
+        .def("pst_attach_to_file_base64",       &pst::pst_attach_to_file_base64)
+        .def("pst_getNextDptr",                 &pst::pst_getNextDptr,     return_value_policy<reference_existing_object>())
+        .def("pst_parse_item",                  &pst::pst_parse_item,      return_value_policy<reference_existing_object>())
+        .def("pst_freeItem",                    &pst::pst_freeItem)
+        .def("pst_getID",                       &pst::pst_getID,           return_value_policy<reference_existing_object>())
+        .def("pst_ff_getIDblock_dec",           &pst::pst_ff_getIDblock_dec)
+        .def("pst_rfc2426_escape",              &pst::pst_rfc2426_escape)
+        .def("pst_rfc2425_datetime_format",     &pst::pst_rfc2425_datetime_format)
+        .def("pst_rfc2445_datetime_format",     &pst::pst_rfc2445_datetime_format)
+        .def("pst_default_charset",             &pst::pst_default_charset)
+        .def("pst_convert_utf8_null",           &pst::pst_convert_utf8_null)
+        .def("pst_convert_utf8",                &pst::pst_convert_utf8)
+        .def("ppst_open_file",                  &pst::ppst_open_file,      return_value_policy<reference_existing_object>())
+        .def("ppst_close_file",                 &pst::ppst_close_file)
         ;
 }
 
--- a/python/test.py	Thu Jun 03 19:09:29 2010 -0700
+++ b/python/test.py	Mon Dec 24 17:51:12 2012 -0800
@@ -7,7 +7,7 @@
 
 for i in range(1,len(sys.argv)):
     print "try file %s" % (sys.argv[i])
-    pst = _libpst.pst(sys.argv[i])
+    pst = _libpst.pst(sys.argv[i], "")
     topf = pst.pst_getTopOfFolders()
 
     print pst.pst_rfc2425_datetime_format(ft)
@@ -27,6 +27,8 @@
                     if (em.messageid.str):
                         print "message id is <%s>" % (em.messageid.str)
                     subj = item.subject;
+                    rtf  = em.rtf_compressed;
+                    if rtf and (len(rtf) > 0): print "rtf compressed size", len(rtf)
                     if (subj and subj.str):
                         was = subj.is_utf8;
                         pst.pst_convert_utf8(item, subj)
@@ -38,13 +40,13 @@
                     #if (body.str):
                     #    print "message body is %s" % (body.str)
                     att = item.attach
+                    att = None
                     while (att):
-                        attid   = att.i_id
-                        print "attachment id %d" % (attid)
-                        att1 = att.filename1
-                        att2 = att.filename2
-                        print "attachment file name short '%s' long '%s'" % (att1.str, att2.str)
-                        if (0):
+                        attid = att.i_id
+                        att1  = att.filename1
+                        att2  = att.filename2
+                        print "attachment id %d file name short '%s' long '%s'" % (attid, att1.str, att2.str)
+                        if (1):
                             attdata = pst.pst_attach_to_mem(att)
                             if (attdata):
                                 print "data size %d" % (len(attdata))
@@ -54,7 +56,7 @@
                                 si = pst.pst_attach_to_file_base64(att, f)
                                 pst.ppst_close_file(f)
                                 print "wrote %d bytes in %s" % (si, att2.str)
-                        if (1):
+                        if (0):
                             f = pst.ppst_open_file(att2.str, 'w')
                             if (f):
                                 si = pst.pst_attach_to_file(att, f)
--- a/regression/regression-tests.bash	Thu Jun 03 19:09:29 2010 -0700
+++ b/regression/regression-tests.bash	Mon Dec 24 17:51:12 2012 -0800
@@ -54,9 +54,8 @@
     size=$(stat -c %s $fn)
     jobs=""
     [ -n "$val" ] && jobs="-j 0"
-    jobs="-j 0"
     rm -rf output$n
-    if [ -z "$val" ] || [ $size -lt 10000000 ]; then
+    if [ -z "$val" ] || [ $size -lt 100000000 ]; then
         echo $fn
         mkdir output$n
         if [ "$regression" == "yes" ]; then
@@ -66,13 +65,18 @@
             #$val ../src/readpst $jobs -te -r -D -cv -o output$n -d $ba.log $fn >$ba.err 2>&1
 
             ## normal recursive dump
-            #$val ../src/readpst $jobs     -r    -cv -o output$n -d $ba.log $fn >$ba.err 2>&1
+            char='us-ascii'
+            char='BIG-5'
+            echo $val ../src/readpst -C $char -j 0 -r -cv -o output$n -d $ba.log $fn
+                 $val ../src/readpst -C $char -j 0 -r -cv -o output$n -d $ba.log $fn >$ba.err 2>&1
 
-             # separate mode with filename extensions
-             $val ../src/readpst $jobs     -r -m -D -cv -o output$n -d $ba.log $fn >$ba.err 2>&1
+            ## separate mode with filename extensions
+            #echo $val ../src/readpst $jobs     -r -e -D -cv -o output$n -d $ba.log $fn
+            #     $val ../src/readpst $jobs     -r -e -D -cv -o output$n -d $ba.log $fn >$ba.err 2>&1
 
             ## separate mode where we decode all attachments to binary files
-            #$val ../src/readpst $jobs     -r -S -D -cv -o output$n -d $ba.log $fn >$ba.err 2>&1
+            #echo $val ../src/readpst $jobs      -r -S -D -cv -o output$n -d $ba.log $fn
+            #     $val ../src/readpst $jobs      -r -S -D -cv -o output$n -d $ba.log $fn >$ba.err 2>&1
 
             ## testing idblock
             #../src/getidblock -p $fn 0 >$ba.fulldump
@@ -102,9 +106,35 @@
 [ "$2" == "reg" ] && regression="yes"
 [ "$regression" == "yes" ] && val=""
 
-#$func   1 mark.pst
-$func   2 mark-small.pst
+#$func   1 ams.pst
+#$func   2 sample_64.pst
+#$func   3 test.pst
+#$func   4 big_mail.pst
+#$func   5 mbmg.archive.pst
+#$func   6 Single2003-read.pst
+#$func   7 Single2003-unread.pst
+#$func   8 ol2k3high.pst
 #$func   9 ol97high.pst
+#$func  10 returned_message.pst
+#$func  11 flow.pst
+#$func  12 test-html.pst
+#$func  13 test-text.pst
+#$func  14 joe.romanowski.pst
+#$func  15 hourig1.pst
+#$func  16 test-mac.pst
+#$func  18 spam.pst
+#$func  19 rendgen.pst           # single email appointment
+#$func  20 rendgen2.pst          # email appointment with no termination date
+#$func  21 rendgen3.pst          # mime signed email
+#$func  22 rendgen4.pst          # appointment test cases
+#$func  23 rendgen5.pst          # appointment test cases
+#$func  24 paul.sheer.pst        # embedded rfc822 attachment
+#$func  25 jerry.pst             # non ascii subject lines
+#$func  26 phill.bertolus.pst    # possible segfault in forked process, cannot reproduce
+#$func  27 kaiser.pst            # appointments with other character sets
+#$func  28 pstsample.pst         # character set issue
+#$func  29 pstsample2.pst        # embedded image in rtf data
+$func  30 pstsample3.pst        # exports of rtf and html
 
 [ -n "$val" ] && grep 'lost:' *err | grep -v 'lost: 0 '
 
--- a/src/Makefile.am	Thu Jun 03 19:09:29 2010 -0700
+++ b/src/Makefile.am	Mon Dec 24 17:51:12 2012 -0800
@@ -4,12 +4,20 @@
     NO_UNDEFINED =
 endif
 
+
+if OS_SOLARIS
+    AM_CFLAGS = -D_POSIX_PTHREAD_SEMANTICS
+endif
+
+
+
 if STATIC_TOOLS
     PSTLIB = @PST_OBJDIR@/libpst.a
 else
     PSTLIB = libpst.la
 endif
 
+
 common_header = common.h        \
                 define.h        \
                 libpst.h        \
@@ -32,7 +40,7 @@
 endif
 
 noinst_PROGRAMS     = deltasearch dumpblocks getidblock
-bin_PROGRAMS        = lspst readpst pst2ldif
+bin_PROGRAMS        = lspst readpst pst2ldif nick2ldif
 if BUILD_DII
     bin_PROGRAMS   += pst2dii
 endif
@@ -43,6 +51,7 @@
 deltasearch_SOURCES = deltasearch.cpp  $(common_header)
 dumpblocks_SOURCES  = dumpblocks.c     $(common_header)
 getidblock_SOURCES  = getidblock.c     $(common_header)
+nick2ldif_SOURCES   = nick2ldif.cpp    $(common_header)
 
 readpst_CPPFLAGS    = $(AM_CPPFLAGS) $(GSF_FLAGS)
 
@@ -53,6 +62,7 @@
 deltasearch_DEPENDENCIES  = libpst.la
 dumpblocks_DEPENDENCIES   = libpst.la
 getidblock_DEPENDENCIES   = libpst.la
+nick2ldif_DEPENDENCIES    = libpst.la
 
 if STATIC_TOOLS
     noinst_LTLIBRARIES    = libpst.la
@@ -85,8 +95,9 @@
 readpst_LDADD     = $(all_libraries) $(PSTLIB) $(LTLIBICONV) $(REGEXLIB) $(GSF_LIBS)
 pst2ldif_LDADD    = $(all_libraries) $(PSTLIB) $(LTLIBICONV)
 pst2dii_LDADD     = $(all_libraries) $(PSTLIB) $(LTLIBICONV) -lgd
+deltasearch_LDADD = $(all_libraries) $(PSTLIB) $(LTLIBICONV)
 dumpblocks_LDADD  = $(all_libraries) $(PSTLIB) $(LTLIBICONV)
 getidblock_LDADD  = $(all_libraries) $(PSTLIB) $(LTLIBICONV)
-deltasearch_LDADD = $(all_libraries) $(PSTLIB) $(LTLIBICONV)
+nick2ldif_LDADD   = $(all_libraries) $(PSTLIB) $(LTLIBICONV)
 
 
--- a/src/common.h	Thu Jun 03 19:09:29 2010 -0700
+++ b/src/common.h	Mon Dec 24 17:51:12 2012 -0800
@@ -47,3 +47,8 @@
 
 
 #endif
+
+#if defined (__SVR4) && defined (__sun)
+    #define LITTLE_ENDIAN 1234
+    #define BYTE_ORDER LITTLE_ENDIAN
+#endif
--- a/src/debug.c	Thu Jun 03 19:09:29 2010 -0700
+++ b/src/debug.c	Mon Dec 24 17:51:12 2012 -0800
@@ -39,8 +39,8 @@
     #ifdef HAVE_SEMAPHORE_H
         debug_mutex = (sem_t*)output_mutex;
     #endif
-    memset(indent, ' ', MAX_DEPTH);
-    indent[MAX_DEPTH] = '\0';
+    memset(indent, ' ', MAX_DEPTH*4);
+    indent[MAX_DEPTH*4] = '\0';
     if (debug_fp) pst_debug_close();
     if (!fname) return;
     if ((debug_fp = fopen(fname, "wb")) == NULL) {
@@ -164,3 +164,12 @@
     return mem;
 }
 
+
+void *pst_realloc(void *ptr, size_t size) {
+    void *mem = realloc(ptr, size);
+    if (!mem) {
+        fprintf(stderr, "pst_realloc: Out Of memory [req: %ld]\n", (long)size);
+        exit(1);
+    }
+    return mem;
+}
--- a/src/define.h	Thu Jun 03 19:09:29 2010 -0700
+++ b/src/define.h	Mon Dec 24 17:51:12 2012 -0800
@@ -143,6 +143,7 @@
 void  pst_debug_hexdumper(FILE* out, const char* buf, size_t size, int cols, int delta);
 void  pst_debug_close(void);
 void* pst_malloc(size_t size);
+void *pst_realloc(void *ptr, size_t size);
 
 #define MESSAGEPRINT(...) pst_debug(__LINE__, __FILE__,  __VA_ARGS__)
 
--- a/src/dumpblocks.c	Thu Jun 03 19:09:29 2010 -0700
+++ b/src/dumpblocks.c	Mon Dec 24 17:51:12 2012 -0800
@@ -33,7 +33,7 @@
     DEBUG_ENT("main");
 
     printf("Opening file %s\n", file);
-    if (pst_open(&pstfile, file)) {
+    if (pst_open(&pstfile, file, NULL)) {
         printf("Failed to open file %s\n", file);
         exit(1);
     }
--- a/src/getidblock.c	Thu Jun 03 19:09:29 2010 -0700
+++ b/src/getidblock.c	Mon Dec 24 17:51:12 2012 -0800
@@ -31,7 +31,7 @@
         DIE(("Error loading block\n"));
     }
 
-    DEBUG_INFO(("Printing block id %#"PRIx64", size %#"PRIx64"\n", i_id, (uint64_t)readSize));
+    DEBUG_INFO(("Printing block i_id %#"PRIx64", size %#"PRIx64"\n", i_id, (uint64_t)readSize));
     if (binary) {
         if (fwrite(buf, 1, readSize, stdout) != 0) {
             DIE(("Error occured during writing of buf to stdout\n"));
@@ -63,14 +63,18 @@
 }
 
 
-void dump_desc(pst_desc_tree *ptr);
-void dump_desc(pst_desc_tree *ptr)
+void dump_desc(pst_desc_tree *ptr, pst_desc_tree *parent);
+void dump_desc(pst_desc_tree *ptr, pst_desc_tree *parent)
 {
     while (ptr) {
-        DEBUG_INFO(("\n\n\nLooking at block desc id %#"PRIx64"\n", ptr->d_id));
+        uint64_t parent_d_id = (parent) ? parent->d_id : 0;
+        printf("Descriptor block d_id %#"PRIx64" parent d_id %#"PRIx64" children %i desc.i_id=%#"PRIx64", assoc tree.i_id=%#"PRIx64"\n",
+            ptr->d_id, parent_d_id, ptr->no_child,
+            (ptr->desc       ? ptr->desc->i_id       : (uint64_t)0),
+            (ptr->assoc_tree ? ptr->assoc_tree->i_id : (uint64_t)0));
         if (ptr->desc       && ptr->desc->i_id)       dumper(ptr->desc->i_id);
         if (ptr->assoc_tree && ptr->assoc_tree->i_id) dumper(ptr->assoc_tree->i_id);
-        if (ptr->child) dump_desc(ptr->child);
+        if (ptr->child) dump_desc(ptr->child, ptr);
         ptr = ptr->next;
     }
 }
@@ -113,7 +117,7 @@
 
     DEBUG_INFO(("Opening file\n"));
     memset(&pstfile, 0, sizeof(pstfile));
-    if (pst_open(&pstfile, fname)) {
+    if (pst_open(&pstfile, fname, NULL)) {
         DIE(("Error opening file\n"));
     }
 
@@ -131,7 +135,7 @@
             dumper(ptr->i_id);
             ptr = ptr->next;
         }
-        dump_desc(pstfile.d_head);
+        dump_desc(pstfile.d_head, NULL);
     }
 
     if (pst_close(&pstfile) != 0) {
--- a/src/libpst.c	Thu Jun 03 19:09:29 2010 -0700
+++ b/src/libpst.c	Mon Dec 24 17:51:12 2012 -0800
@@ -50,8 +50,8 @@
 
 
 typedef struct pst_block_offset {
-    int16_t from;
-    int16_t to;
+    uint16_t from;
+    uint16_t to;
 } pst_block_offset;
 
 
@@ -281,7 +281,7 @@
 static pst_mapi_object* pst_parse_block(pst_file *pf, uint64_t block_id, pst_id2_tree *i2_head);
 static void             pst_printDptr(pst_file *pf, pst_desc_tree *ptr);
 static void             pst_printID2ptr(pst_id2_tree *ptr);
-static int              pst_process(pst_mapi_object *list, pst_item *item, pst_item_attach *attach);
+static int              pst_process(uint64_t block_id, pst_mapi_object *list, pst_item *item, pst_item_attach *attach);
 static size_t           pst_read_block_size(pst_file *pf, int64_t offset, size_t size, char **buf);
 static int              pst_decrypt(uint64_t i_id, char *buf, size_t size, unsigned char type);
 static int              pst_stricmp(char *a, char *b);
@@ -290,7 +290,7 @@
 
 
 
-int pst_open(pst_file *pf, const char *name) {
+int pst_open(pst_file *pf, const char *name, const char *charset) {
     int32_t sig;
 
     pst_unicode_init();
@@ -303,6 +303,7 @@
         return -1;
     }
     memset(pf, 0, sizeof(*pf));
+    pf->charset = charset;
 
     if ((pf->fp = fopen(name, "rb")) == NULL) {
         perror("Error opening PST file");
@@ -1245,8 +1246,9 @@
 
     item = (pst_item*) pst_malloc(sizeof(pst_item));
     memset(item, 0, sizeof(pst_item));
-
-    if (pst_process(list, item, NULL)) {
+    item->pf = pf;
+
+    if (pst_process(d_ptr->desc->i_id, list, item, NULL)) {
         DEBUG_WARN(("pst_process() returned non-zero value. That is an error\n"));
         pst_freeItem(item);
         pst_free_list(list);
@@ -1267,7 +1269,7 @@
                 attach->next = item->attach;
                 item->attach = attach;
             }
-            if (pst_process(list, item, item->attach)) {
+            if (pst_process(id2_ptr->id->i_id, list, item, item->attach)) {
                 DEBUG_WARN(("ERROR pst_process() failed with DSN/MDN attachments\n"));
                 pst_freeItem(item);
                 pst_free_list(list);
@@ -1299,7 +1301,7 @@
             attach->next = item->attach;
             item->attach = attach;
         }
-        if (pst_process(list, item, item->attach)) {
+        if (pst_process(id2_ptr->id->i_id, list, item, item->attach)) {
             DEBUG_WARN(("ERROR pst_process() failed with attachments\n"));
             pst_freeItem(item);
             pst_free_list(list);
@@ -1327,7 +1329,9 @@
                 if (list->count_objects > 1) {
                     DEBUG_WARN(("ERROR probably fatal, list count array will overrun attach structure.\n"));
                 }
-                if (pst_process(list, item, attach)) {
+                // reprocess the same attachment list against new data
+                // this might update attach->id2_val
+                if (pst_process(id2_ptr->id->i_id, list, item, attach)) {
                     DEBUG_WARN(("ERROR pst_process() failed with an attachment\n"));
                     pst_free_list(list);
                     continue;
@@ -1335,9 +1339,8 @@
                 pst_free_list(list);
                 id2_ptr = pst_getID2(id2_head, attach->id2_val);
                 if (id2_ptr) {
-                    DEBUG_WARN(("second pass attachment updating id2 found i_id %#"PRIx64"\n", id2_ptr->id->i_id));
-                    // id2_val has been updated to the ID2 value of the datablock containing the
-                    // attachment data
+                    DEBUG_WARN(("second pass attachment updating id2 %#"PRIx64" found i_id %#"PRIx64"\n", attach->id2_val, id2_ptr->id->i_id));
+                    // i_id has been updated to the datablock containing the attachment data
                     attach->i_id     = id2_ptr->id->i_id;
                     attach->id2_head = deep_copy(id2_ptr->child);
                 } else {
@@ -1868,7 +1871,7 @@
 
 // malloc space and copy the current item's data null terminated
 #define LIST_COPY(targ, type) {                                    \
-    targ = type realloc(targ, list->elements[x]->size+1);          \
+    targ = type pst_realloc(targ, list->elements[x]->size+1);      \
     memcpy(targ, list->elements[x]->data, list->elements[x]->size);\
     memset(((char*)targ)+list->elements[x]->size, 0, (size_t)1);   \
 }
@@ -2051,7 +2054,7 @@
         DEBUG_WARN(("src not 0x40 for filetime dst\n"));                    \
         DEBUG_HEXDUMP(list->elements[x]->data, list->elements[x]->size);    \
     }                                                                       \
-    targ = (FILETIME*) realloc(targ, sizeof(FILETIME));                     \
+    targ = (FILETIME*) pst_realloc(targ, sizeof(FILETIME));                 \
     memcpy(targ, list->elements[x]->data, list->elements[x]->size);         \
     LE32_CPU(targ->dwLowDateTime);                                          \
     LE32_CPU(targ->dwHighDateTime);                                         \
@@ -2082,7 +2085,7 @@
 #define LIST_COPY_BIN(targ) {                                       \
     targ.size = list->elements[x]->size;                            \
     if (targ.size) {                                                \
-        targ.data = (char*)realloc(targ.data, targ.size);           \
+        targ.data = (char*)pst_realloc(targ.data, targ.size);       \
         memcpy(targ.data, list->elements[x]->data, targ.size);      \
     }                                                               \
     else {                                                          \
@@ -2109,6 +2112,7 @@
 /**
  * process the list of MAPI objects produced from parse_block()
  *
+ * @param block_id  block number used by parse_block() to produce these MAPI objects
  * @param list  pointer to the list of MAPI objects from parse_block()
  * @param item  pointer to the high level item to be updated from the list.
  *              this item may be an email, contact or other sort of item.
@@ -2120,7 +2124,7 @@
  *
  * @return 0 for ok, -1 for error.
  */
-static int pst_process(pst_mapi_object *list, pst_item *item, pst_item_attach *attach) {
+static int pst_process(uint64_t block_id, pst_mapi_object *list, pst_item *item, pst_item_attach *attach) {
     DEBUG_ENT("pst_process");
     if (!item) {
         DEBUG_WARN(("item cannot be NULL.\n"));
@@ -2128,11 +2132,13 @@
         return -1;
     }
 
+    item->block_id = block_id;
     while (list) {
         int32_t x;
         char time_buffer[30];
         for (x=0; x<list->count_elements; x++) {
             int32_t t;
+            uint32_t ut;
             DEBUG_INFO(("#%d - mapi-id: %#x type: %#x length: %#x\n", x, list->elements[x]->mapi_id, list->elements[x]->type, list->elements[x]->size));
 
             switch (list->elements[x]->mapi_id) {
@@ -2149,7 +2155,7 @@
                                 offset      = PST_LE_GET_INT32(list->elements[x]->data + p); p+=4;
                                 next_offset = (i == array_element_count) ? list->elements[x]->size : PST_LE_GET_INT32(list->elements[x]->data + p);;
                                 string_length = next_offset - offset;
-                                ef->value = malloc(string_length + 1);
+                                ef->value = pst_malloc(string_length + 1);
                                 memcpy(ef->value, list->elements[x]->data + offset, string_length);
                                 ef->value[string_length] = '\0';
                                 ef->field_name = strdup(list->elements[x]->extra);
@@ -2442,7 +2448,8 @@
                 case 0x0E20: // PR_ATTACH_SIZE binary Attachment data in record
                     NULL_CHECK(attach);
                     LIST_COPY_INT32("Attachment Size", t);
-                    attach->data.size = (size_t)t;
+                    // ignore this. we either get data and size from 0x3701
+                    // or id codes from 0x3701 or 0x67f2
                     break;
                 case 0x0FF9: // PR_RECORD_KEY Record Header 1
                     LIST_COPY_BIN(item->record_key);
@@ -2868,16 +2875,10 @@
                     DEBUG_INFO(("Predecessor Change\n"));
                     DEBUG_HEXDUMP(item->predecessor_change.data, item->predecessor_change.size);
                     break;
-                case 0x67F2: // ID2 value of the attachments proper record
-                    if (attach) {
-                        uint32_t tempid;
-                        memcpy(&(tempid), list->elements[x]->data, sizeof(tempid));
-                        LE32_CPU(tempid);
-                        attach->id2_val = tempid;
-                        DEBUG_INFO(("Attachment ID2 value - %#"PRIx64"\n", attach->id2_val));
-                    } else {
-                        DEBUG_WARN(("NOT AN ATTACHMENT: %#x\n", list->elements[x]->mapi_id));
-                    }
+                case 0x67F2: // ID2 value of the attachment
+                    NULL_CHECK(attach);
+                    LIST_COPY_INT32("Attachment ID2 value", ut);
+                    attach->id2_val = ut;
                     break;
                 case 0x67FF: // Extra Property Identifier (Password CheckSum)
                     LIST_COPY_STORE_INT32("Password checksum", item->message_store->pwd_chksum);
@@ -3200,7 +3201,7 @@
     pst_id2_tree *t;
     DEBUG_ENT("pst_free_id2");
     while (head) {
-        if (head->child) pst_free_id2(head->child);
+        pst_free_id2(head->child);
         t = head->next;
         free(head);
         head = t;
@@ -3225,20 +3226,9 @@
     pst_desc_tree *t;
     DEBUG_ENT("pst_free_desc");
     while (head) {
-        while (head->child) {
-            head = head->child;
-        }
-
-        // point t to the next item
+        pst_free_desc(head->child);
         t = head->next;
-        if (!t && head->parent) {
-            t = head->parent;
-            t->child = NULL; // set the child to NULL so we don't come back here again!
-        }
-
-        if (head) free(head);
-        else      DIE(("head is NULL"));
-
+        free(head);
         head = t;
     }
     DEBUG_RET();
@@ -3983,7 +3973,7 @@
         free(b);
     } else {
         // here we will assume it is an indirection block that points to others
-        DEBUG_INFO(("Assuming it is a multi-block record because of it's id\n"));
+        DEBUG_INFO(("Assuming it is a multi-block record because of it's id %#"PRIx64"\n", ptr->i_id));
         ret = pst_ff_compile_ID(pf, ptr->i_id, h, (size_t)0);
     }
     ret = pst_finish_cleanup_holder(h, ret);
@@ -4083,7 +4073,7 @@
 
     // raw append to a buffer
     if (h->buf) {
-        *(h->buf) = realloc(*(h->buf), size+z+1);
+        *(h->buf) = pst_realloc(*(h->buf), size+z+1);
         DEBUG_INFO(("appending read data of size %i onto main buffer from pos %i\n", z, size));
         memcpy(*(h->buf)+size, *buf, z);
 
@@ -4092,7 +4082,7 @@
         //
         if (h->base64_extra) {
             // include any bytes left over from the last encoding
-            *buf = (char*)realloc(*buf, z+h->base64_extra);
+            *buf = (char*)pst_realloc(*buf, z+h->base64_extra);
             memmove(*buf+h->base64_extra, *buf, z);
             memcpy(*buf, h->base64_extra_chars, h->base64_extra);
             z += h->base64_extra;
@@ -4234,7 +4224,7 @@
     else {
         x = strlen(str) + y - z + 1; // don't forget room for the NUL
         if (x > *buflen) {
-            *buf = (char*) realloc(*buf, x);
+            *buf = (char*)pst_realloc(*buf, x);
             *buflen = x;
         }
         a = str;
@@ -4366,16 +4356,88 @@
 
 /** Get the default character set for this item. This is used to find
  *  the charset for pst_string elements that are not already in utf8 encoding.
+ *
  *  @param  item   pointer to the mapi item of interest
  *  @param[in]  buflen  length of the output buffer
  *  @param[out] result  pointer to output buffer, must be at least 30 bytes
  *  @return default character set as a string useable by iconv()
  */
 const char*    pst_default_charset(pst_item *item, int buflen, char* result) {
-    return (item->body_charset.str) ? item->body_charset.str :
-           (item->message_codepage) ? codepage(item->message_codepage, buflen, result) :
-           (item->internet_cpid)    ? codepage(item->internet_cpid, buflen, result) :
-           "utf-8";
+    return (item->body_charset.str)         ? item->body_charset.str :
+           (item->message_codepage)         ? codepage(item->message_codepage, buflen, result) :
+           (item->internet_cpid)            ? codepage(item->internet_cpid, buflen, result) :
+           (item->pf && item->pf->charset)  ? item->pf->charset :
+           "iso-8859-1";
+}
+
+
+/** Convert str to rfc2231 encoding of str
+ *
+ *  @param str   pointer to the mapi string of interest
+ */
+void pst_rfc2231(pst_string *str) {
+    int needs = 0;
+    const int8_t *x = (int8_t *)str->str;
+    while (*x) {
+        if (*x <= 32) needs++;
+        x++;
+    }
+    int n = strlen(str->str) + 2*needs + 15;
+    char *buffer = pst_malloc(n);
+    strcpy(buffer, "utf-8''");
+    x = (int8_t *)str->str;
+    const uint8_t *y = (uint8_t *)str->str;
+    uint8_t *z = (uint8_t *)buffer;
+    z += strlen(buffer);    // skip the utf8 prefix
+    while (*y) {
+        if (*x <= 32) {
+            *(z++) = (uint8_t)'%';
+            snprintf(z, 3, "%2x", *y);
+            z += 2;
+        }
+        else {
+            *(z++) = *y;
+        }
+        x++;
+        y++;
+    }
+    *z = '\0';
+    free(str->str);
+    str->str = buffer;
+}
+
+
+/** Convert str to rfc2047 encoding of str, possibly enclosed in quotes if it contains spaces
+ *
+ *  @param item          pointer to the containing mapi item
+ *  @param str           pointer to the mapi string of interest
+ *  @param needs_quote   true if strings containing spaces should be wrapped in quotes
+ */
+void pst_rfc2047(pst_item *item, pst_string *str, int needs_quote) {
+    int has_space = 0;
+    int needs_coding = 0;
+    pst_convert_utf8(item, str);
+    const int8_t *x = (int8_t *)str->str;
+    while (*x) {
+        if (*x == 32) has_space = 1;
+        if (*x < 32)  needs_coding = 1;
+        x++;
+    }
+    if (needs_coding) {
+        char *enc = pst_base64_encode_single(str->str, strlen(str->str));
+        free(str->str);
+        int n = strlen(enc) + 20;
+        str->str = pst_malloc(n);
+        snprintf(str->str, n, "=?utf-8?B?%s?=", enc);
+        free(enc);
+    }
+    else if (has_space && needs_quote) {
+        int n = strlen(str->str) + 10;
+        char *buffer = pst_malloc(n);
+        snprintf(buffer, n, "\"%s\"", str->str);
+        free(str->str);
+        str->str = buffer;
+    }
 }
 
 
@@ -4396,15 +4458,25 @@
  *  @param str   pointer to the mapi string of interest
  */
 void pst_convert_utf8(pst_item *item, pst_string *str) {
+    DEBUG_ENT("pst_convert_utf8");
     char buffer[30];
-    if (str->is_utf8) return;
+    if (str->is_utf8) {
+        DEBUG_WARN(("Already utf8\n"));
+        DEBUG_RET();
+        return;
+    }
     if (!str->str) {
         str->str = strdup("");
+        DEBUG_WARN(("null to empty string\n"));
+        DEBUG_RET();
         return;
     }
     const char *charset = pst_default_charset(item, sizeof(buffer), buffer);
-    if (!strcasecmp("utf-8", charset)) return;  // already utf8
-    DEBUG_ENT("pst_convert_utf8");
+    DEBUG_WARN(("default charset is %s\n", charset));
+    if (!strcasecmp("utf-8", charset)) {
+        DEBUG_RET();
+        return;
+    }
     pst_vbuf *newer = pst_vballoc(2);
     size_t rc = pst_vb_8bit2utf8(newer, str->str, strlen(str->str) + 1, charset);
     if (rc == (size_t)-1) {
--- a/src/libpst.h	Thu Jun 03 19:09:29 2010 -0700
+++ b/src/libpst.h	Mon Dec 24 17:51:12 2012 -0800
@@ -80,6 +80,18 @@
 #define PST_ATTACH_EMBEDDED         5
 #define PST_ATTACH_OLE              6
 
+// define flags
+#define PST_FLAG_READ			0x01
+#define PST_FLAG_UNMODIFIED		0x02
+#define PST_FLAG_SUBMIT			0x04
+#define PST_FLAG_UNSENT			0x08
+#define PST_FLAG_HAS_ATTACHMENT	0x10
+#define PST_FLAG_FROM_ME		0x20
+#define PST_FLAG_ASSOCIATED		0x40
+#define PST_FLAG_RESEND			0x80
+#define PST_FLAG_RN_PENDING		0x100
+#define PST_FLAG_NRN_PENDING	0x200
+
 
 typedef struct pst_entryid {
     int32_t u1;
@@ -758,6 +770,10 @@
  *  each major mapi item type. It represents a complete mapi object.
  */
 typedef struct pst_item {
+    /** pointer to the pst_file */
+    struct pst_file        *pf;
+    /** block id that can be used to generate uid */
+    uint64_t               block_id;
     /** email mapi elements */
     pst_item_email         *email;
     /** folder mapi elements */
@@ -874,6 +890,8 @@
     char*   cwd;
     /** original file name when the file was opened */
     char*   fname;
+    /** default character set for items without one */
+    char*   charset;
     /** the head and tail of the linked list of index structures */
     pst_index_ll *i_head, *i_tail;
     /** the head and tail of the top level of the descriptor tree */
@@ -912,12 +930,13 @@
 
 
 /** Open a pst file.
- * @param pf   pointer to uninitialized pst_file structure. This structure
- *             will be filled in by this function.
- * @param name name of the file, suitable for fopen().
+ * @param pf       pointer to uninitialized pst_file structure. This structure
+ *                 will be filled in by this function.
+ * @param name     name of the file, suitable for fopen().
+ * @param charset  default charset for item with unspecified character sets
  * @return 0 if ok, -1 if error
  */
-int             pst_open(pst_file *pf, const char *name);
+int             pst_open(pst_file *pf, const char *name, const char *charset);
 
 
 /** Reopen the pst file after a fork
@@ -1080,6 +1099,20 @@
 const char*     pst_default_charset(pst_item *item, int buflen, char* result);
 
 
+/** Convert str to rfc2231 encoding of str
+ *  @param str   pointer to the mapi string of interest
+ */
+void            pst_rfc2231(pst_string *str);
+
+
+/** Convert str to rfc2047 encoding of str, possibly enclosed in quotes if it contains spaces
+ *  @param item          pointer to the containing mapi item
+ *  @param str           pointer to the mapi string of interest
+ *  @param needs_quote   true if strings containing spaces should be wrapped in quotes
+ */
+void            pst_rfc2047(pst_item *item, pst_string *str, int needs_quote);
+
+
 /** Convert str to utf8 if possible; null strings are preserved.
  * @param item  pointer to the containing mapi item
  * @param str   pointer to the mapi string of interest
--- a/src/libstrfunc.c	Thu Jun 03 19:09:29 2010 -0700
+++ b/src/libstrfunc.c	Mon Dec 24 17:51:12 2012 -0800
@@ -14,7 +14,7 @@
         *line_count = 0;
     }
     *(*ou)++ = data;
-    (*line_count)++;
+    if (*line_count >= 0) (*line_count)++;
 }
 
 
@@ -25,6 +25,13 @@
 }
 
 
+char *pst_base64_encode_single(void *data, size_t size)
+{
+    int line_count = -1;
+    return pst_base64_encode_multiple(data, size, &line_count);
+}
+
+
 char *pst_base64_encode_multiple(void *data, size_t size, int *line_count)
 {
     char *output;
--- a/src/libstrfunc.h	Thu Jun 03 19:09:29 2010 -0700
+++ b/src/libstrfunc.h	Mon Dec 24 17:51:12 2012 -0800
@@ -5,6 +5,7 @@
 #include "common.h"
 
 char *pst_base64_encode(void *data, size_t size);
+char *pst_base64_encode_single(void *data, size_t size);
 char *pst_base64_encode_multiple(void *data, size_t size, int *line_count);
 
 #endif
--- a/src/lspst.c	Thu Jun 03 19:09:29 2010 -0700
+++ b/src/lspst.c	Mon Dec 24 17:51:12 2012 -0800
@@ -168,9 +168,6 @@
 #else
 #  error "Byte order not supported by this library"
 #endif
-#ifdef __GNUC__
-			 printf("GCC %d.%d : %s %s\n", __GNUC__, __GNUC_MINOR__, __DATE__, __TIME__);
-#endif
 	 DEBUG_RET();
 }
 
@@ -215,7 +212,7 @@
 	}
 
     // Open PST file
-    if (pst_open(&pstfile, argv[optind])) DIE(("Error opening File\n"));
+    if (pst_open(&pstfile, argv[optind], NULL)) DIE(("Error opening File\n"));
 
     // Load PST index
     if (pst_load_index(&pstfile)) DIE(("Index Error\n"));
--- a/src/nick2ldif.cpp	Thu Jun 03 19:09:29 2010 -0700
+++ b/src/nick2ldif.cpp	Mon Dec 24 17:51:12 2012 -0800
@@ -18,7 +18,7 @@
 
 using namespace std;
 
-int main(int argc, const char** argv) {
+int main(int argc, char* const* argv) {
 	char c;
 	char *temp;
 	while ((c = getopt(argc, argv, "b:c:"))!= -1) {
@@ -46,6 +46,7 @@
 		cin.getline(line, LINE_SIZE);
 		int n = strlen(line);
 		if (!n) continue;
+        if (strncmp(line, "alias", 5) != 0) continue;   // not alias
 		char *f = line + 6; 	// skip alias keyword
 		char *e;
 		if (*f == '"') {
@@ -60,11 +61,22 @@
 		char *m = e+1;
 		while (*m == ' ') m++;
 		if (*m != '\0') {
-			char cn[1000];
-			snprintf(cn, sizeof(cn), "email %s", f);
+			char cn[1000], givenName[1000], sn[1000];
+			snprintf(cn, sizeof(cn), "%s", f);
+            char *ff = strchr(f, ' ');
+            if (ff) {
+                strncpy(givenName, ff+1, sizeof(givenName)-1);
+                *ff = '\0';
+                strncpy(sn, f, sizeof(sn)-1);
+            }
+            else {
+                strcpy(givenName, cn);
+                strcpy(sn, cn);
+            }
 			printf("dn: cn=%s, %s\n", cn, ldap_base);
 			printf("cn: %s\n", cn);
-			printf("sn: %s\n", f);
+            printf("givenName: %s\n", givenName);
+			printf("sn: %s\n", sn);
 			printf("mail: %s\n", m);
 			printf("objectClass: %s\n\n", ldap_class);
 		}
--- a/src/pst2dii.cpp.in	Thu Jun 03 19:09:29 2010 -0700
+++ b/src/pst2dii.cpp.in	Mon Dec 24 17:51:12 2012 -0800
@@ -88,9 +88,6 @@
 #else
 #  error "Byte order not supported by this library"
 #endif
-#ifdef __GNUC__
-    printf("GCC %d.%d : %s %s\n", __GNUC__, __GNUC_MINOR__, __DATE__, __TIME__);
-#endif
 }
 
 
@@ -183,7 +180,7 @@
     DEBUG_INFO(("dirname=%s, pathname=%s, filename=%s\n", output_directory, f_name, attach_filename));
     int len = strlen(output_directory) + 1 + strlen(f_name) + 15;
     if (!attach_filename) {
-        // generate our own (dummy) filename for the attachement
+        // generate our own (dummy) filename for the attachment
         temp = (char*)pst_malloc(len);
         sprintf(temp, "%s/%s_attach%i", output_directory, f_name, attach_num);
     } else {
@@ -697,7 +694,7 @@
     #endif
     DEBUG_INIT(d_log, NULL);
     DEBUG_ENT("main");
-    RET_DERROR(pst_open(&pstfile, fname), 1, ("Error opening File\n"));
+    RET_DERROR(pst_open(&pstfile, fname, NULL), 1, ("Error opening File\n"));
     RET_DERROR(pst_load_index(&pstfile), 2, ("Index Error\n"));
 
     pst_load_extended_attributes(&pstfile);
--- a/src/pst2ldif.cpp	Thu Jun 03 19:09:29 2010 -0700
+++ b/src/pst2ldif.cpp	Mon Dec 24 17:51:12 2012 -0800
@@ -629,7 +629,7 @@
     #endif
     DEBUG_INIT(d_log, NULL);
     DEBUG_ENT("main");
-    RET_DERROR(pst_open(&pstfile, fname), 1, ("Error opening File\n"));
+    RET_DERROR(pst_open(&pstfile, fname, NULL), 1, ("Error opening File\n"));
     RET_DERROR(pst_load_index(&pstfile), 2, ("Index Error\n"));
 
     pst_load_extended_attributes(&pstfile);
@@ -699,9 +699,6 @@
 #else
 #  error "Byte order not supported by this library"
 #endif
-#ifdef __GNUC__
-    printf("GCC %d.%d : %s %s\n", __GNUC__, __GNUC_MINOR__, __DATE__, __TIME__);
-#endif
 }
 
 
--- a/src/readpst.c	Thu Jun 03 19:09:29 2010 -0700
+++ b/src/readpst.c	Mon Dec 24 17:51:12 2012 -0800
@@ -40,12 +40,14 @@
 int       close_recurse_dir();
 char*     mk_separate_dir(char *dir);
 int       close_separate_dir();
-int       mk_separate_file(struct file_ll *f, char *extension, int openit);
+void      mk_separate_file(struct file_ll *f, char *extension, int openit);
+void      close_separate_file(struct file_ll *f);
 char*     my_stristr(char *haystack, char *needle);
 void      check_filename(char *fname);
 void      write_separate_attachment(char f_name[], pst_item_attach* attach, int attach_num, pst_file* pst);
-void      write_embedded_message(FILE* f_output, pst_item_attach* attach, char *boundary, pst_file* pf, char** extra_mime_headers);
+void      write_embedded_message(FILE* f_output, pst_item_attach* attach, char *boundary, pst_file* pf, int save_rtf, char** extra_mime_headers);
 void      write_inline_attachment(FILE* f_output, pst_item_attach* attach, char *boundary, pst_file* pst);
+int       valid_headers(char *header);
 void      header_has_field(char *header, char *field, int *flag);
 void      header_get_subfield(char *field, const char *subfield, char *body_subfield, size_t size_subfield);
 char*     header_get_field(char *header, char *field);
@@ -78,7 +80,7 @@
 #define MODE_KMAIL 1
 
 // recurse mode creates a directory structure like the PST file. Each directory
-// contains only one file which stores the emails in mbox format.
+// contains only one file which stores the emails in mboxrd format.
 #define MODE_RECURSE 2
 
 // separate mode creates the same directory structure as recurse. The emails are stored in
@@ -133,6 +135,7 @@
 int         file_name_len = 10;     // enough room for MODE_SPEARATE file name
 pst_file    pstfile;
 regex_t     meta_charset_pattern;
+char*       default_charset = NULL;
 
 int         number_processors = 1;  // number of cpus we have
 int         max_children  = 0;      // based on number of cpus and command line args
@@ -153,14 +156,27 @@
 #ifdef HAVE_FORK
 #ifdef HAVE_SEMAPHORE_H
     if (global_children) {
-        sem_getvalue(global_children, &available);
+        //sem_getvalue(global_children, &available);
         //printf("grim reaper %s for pid %d (parent %d) with %d children, %d available\n", (waitall) ? "all" : "", getpid(), getppid(), active_children, available);
         //fflush(stdout);
         int i,j;
         for (i=0; i<active_children; i++) {
+            int status;
             pid_t child = child_processes[i];
-            pid_t ch = waitpid(child, NULL, ((waitall) ? 0 : WNOHANG));
+            pid_t ch = waitpid(child, &status, ((waitall) ? 0 : WNOHANG));
             if (ch == child) {
+                // check termination status
+                //if (WIFEXITED(status)) {
+                //    int ext = WEXITSTATUS(status);
+                //    printf("Process %d exited with status  %d\n", child, ext);
+                //    fflush(stdout);
+                //}
+                if (WIFSIGNALED(status)) {
+                    int sig = WTERMSIG(status);
+                    DEBUG_INFO(("Process %d terminated with signal %d\n", child, sig));
+                    //printf("Process %d terminated with signal %d\n", child, sig);
+                    //fflush(stdout);
+                }
                 // this has terminated, remove it from the list
                 for (j=i; j<active_children-1; j++) {
                     child_processes[j] = child_processes[j+1];
@@ -302,6 +318,7 @@
                         pst_convert_utf8(item, &item->contact->address1);
                         fprintf(ff.output, "%s <%s>\n", item->contact->fullname.str, item->contact->address1.str);
                     }
+                    if (mode == MODE_SEPARATE) close_separate_file(&ff);
                 }
             }
 
@@ -320,11 +337,37 @@
                 else {
                     char *extra_mime_headers = NULL;
                     ff.item_count++;
-                    if (mode == MODE_SEPARATE) mk_separate_file(&ff, (mode_EX) ? ".eml" : "", 1);
-                    write_normal_email(ff.output, ff.name, item, mode, mode_MH, &pstfile, save_rtf_body, &extra_mime_headers);
-                    if ((mode == MODE_SEPARATE) && (mode_MSG)) {
-                        mk_separate_file(&ff, ".msg", 0);
-                        write_msg_email(ff.name, item, &pstfile);
+                    if (mode == MODE_SEPARATE) {
+                        // process this single email message, possibly forking
+                        pid_t parent = getpid();
+                        pid_t child = try_fork(item->file_as.str);
+                        if (child == 0) {
+                            // we are the child process, or the original parent if no children were available
+                            pid_t me = getpid();
+                            mk_separate_file(&ff, (mode_EX) ? ".eml" : "", 1);
+                            write_normal_email(ff.output, ff.name, item, mode, mode_MH, &pstfile, save_rtf_body, &extra_mime_headers);
+                            close_separate_file(&ff);
+                            if (mode_MSG) {
+                                mk_separate_file(&ff, ".msg", 0);
+                                write_msg_email(ff.name, item, &pstfile);
+                            }
+#ifdef HAVE_FORK
+#ifdef HAVE_SEMAPHORE_H
+                            if (me != parent) {
+                                // we really were a child, forked for the sole purpose of processing this message
+                                // free my child count slot before really exiting, since
+                                // all I am doing here is waiting for my children to exit
+                                sem_post(global_children);
+                                grim_reaper(1); // wait for all my child processes to exit - there should not be any
+                                exit(0);        // really exit
+                            }
+#endif
+#endif
+                        }
+                    }
+                    else {
+                        // process this single email message, cannot fork since not separate mode
+                        write_normal_email(ff.output, ff.name, item, mode, mode_MH, &pstfile, save_rtf_body, &extra_mime_headers);
                     }
                 }
             }
@@ -346,6 +389,7 @@
                     if (mode == MODE_SEPARATE) mk_separate_file(&ff, (mode_EX) ? ".ics" : "", 1);
                     write_journal(ff.output, item);
                     fprintf(ff.output, "\n");
+                    if (mode == MODE_SEPARATE) close_separate_file(&ff);
                 }
             }
 
@@ -366,6 +410,7 @@
                     if (mode == MODE_SEPARATE) mk_separate_file(&ff, (mode_EX) ? ".ics" : "", 1);
                     write_schedule_part_data(ff.output, item, NULL, NULL);
                     fprintf(ff.output, "\n");
+                    if (mode == MODE_SEPARATE) close_separate_file(&ff);
                 }
             }
 
@@ -405,11 +450,20 @@
     }
 
     // command-line option handling
-    while ((c = getopt(argc, argv, "bc:Dd:emhj:kMo:qrSt:uVw"))!= -1) {
+    while ((c = getopt(argc, argv, "bC:c:Dd:emhj:kMo:qrSt:uVw"))!= -1) {
         switch (c) {
         case 'b':
             save_rtf_body = 0;
             break;
+        case 'C':
+            if (optarg) {
+                default_charset = optarg;
+            }
+            else {
+                usage();
+                exit(0);
+            }
+            break;
         case 'c':
             if (optarg && optarg[0]=='v') {
                 contact_mode=CMODE_VCARD;
@@ -568,8 +622,7 @@
     DEBUG_ENT("main");
 
     if (output_mode != OUTPUT_QUIET) printf("Opening PST file and indexes...\n");
-
-    RET_DERROR(pst_open(&pstfile, fname), 1, ("Error opening File\n"));
+    RET_DERROR(pst_open(&pstfile, fname, default_charset), 1, ("Error opening File\n"));
     RET_DERROR(pst_load_index(&pstfile), 2, ("Index Error\n"));
 
     pst_load_extended_attributes(&pstfile);
@@ -633,13 +686,16 @@
 void write_email_body(FILE *f, char *body) {
     char *n = body;
     DEBUG_ENT("write_email_body");
-    while (n) {
-        if (strncmp(body, "From ", 5) == 0)
-            fprintf(f, ">");
-        if ((n = strchr(body, '\n'))) {
-            n++;
-            pst_fwrite(body, n-body, 1, f); //write just a line
-            body = n;
+    if (mode != MODE_SEPARATE) {
+        while (n) {
+            char *p = body;
+            while (*p == '>') p++;
+            if (strncmp(p, "From ", 5) == 0) fprintf(f, ">");
+            if ((n = strchr(body, '\n'))) {
+                n++;
+                pst_fwrite(body, n-body, 1, f); //write just a line
+                body = n;
+            }
         }
     }
     pst_fwrite(body, strlen(body), 1, f);
@@ -668,6 +724,7 @@
     printf("Usage: %s [OPTIONS] {PST FILENAME}\n", prog_name);
     printf("OPTIONS:\n");
     printf("\t-V\t- Version. Display program version\n");
+    printf("\t-C charset\t- character set for items with an unspecified character set\n");
     printf("\t-D\t- Include deleted items in output\n");
     printf("\t-M\t- Write emails in the MH (rfc822) format\n");
     printf("\t-S\t- Separate. Write emails in the separate format\n");
@@ -701,9 +758,6 @@
 #else
 #  error "Byte order not supported by this library"
 #endif
-#ifdef __GNUC__
-    printf("GCC %d.%d : %s %s\n", __GNUC__, __GNUC_MINOR__, __DATE__, __TIME__);
-#endif
     DEBUG_RET();
 }
 
@@ -720,7 +774,7 @@
         x = errno;
         DIE(("mk_kmail_dir: Cannot change to directory %s: %s\n", kmail_chdir, strerror(x)));
     }
-    dir = malloc(strlen(fname)+strlen(OUTPUT_KMAIL_DIR_TEMPLATE)+1);
+    dir = pst_malloc(strlen(fname)+strlen(OUTPUT_KMAIL_DIR_TEMPLATE)+1);
     sprintf(dir, OUTPUT_KMAIL_DIR_TEMPLATE, fname);
     check_filename(dir);
     if (D_MKDIR(dir)) {
@@ -729,17 +783,17 @@
             DIE(("mk_kmail_dir: Cannot create directory %s: %s\n", dir, strerror(x)));
         }
     }
-    kmail_chdir = realloc(kmail_chdir, strlen(dir)+1);
+    kmail_chdir = pst_realloc(kmail_chdir, strlen(dir)+1);
     strcpy(kmail_chdir, dir);
     free (dir);
 
     //we should remove any existing indexes created by KMail, cause they might be different now
-    index = malloc(strlen(fname)+strlen(KMAIL_INDEX)+1);
+    index = pst_malloc(strlen(fname)+strlen(KMAIL_INDEX)+1);
     sprintf(index, KMAIL_INDEX, fname);
     unlink(index);
     free(index);
 
-    out_name = malloc(strlen(fname)+strlen(OUTPUT_TEMPLATE)+1);
+    out_name = pst_malloc(strlen(fname)+strlen(OUTPUT_TEMPLATE)+1);
     sprintf(out_name, OUTPUT_TEMPLATE, fname);
     DEBUG_RET();
     return out_name;
@@ -827,7 +881,7 @@
         if (y == 0)
             snprintf(dir_name, dirsize, "%s", dir);
         else
-      snprintf(dir_name, dirsize, "%s" SEP_MAIL_FILE_TEMPLATE, dir, y, ""); // enough for 9 digits allocated above
+            snprintf(dir_name, dirsize, "%s" SEP_MAIL_FILE_TEMPLATE, dir, y, ""); // enough for 9 digits allocated above
 
         check_filename(dir_name);
         DEBUG_INFO(("about to try creating %s\n", dir_name));
@@ -887,15 +941,13 @@
 }
 
 
-int mk_separate_file(struct file_ll *f, char *extension, int openit) {
+void mk_separate_file(struct file_ll *f, char *extension, int openit) {
     DEBUG_ENT("mk_separate_file");
     DEBUG_INFO(("opening next file to save email\n"));
     if (f->item_count > 999999999) { // bigger than nine 9's
         DIE(("mk_separate_file: The number of emails in this folder has become too high to handle\n"));
     }
     sprintf(f->name, SEP_MAIL_FILE_TEMPLATE, f->item_count, extension);
-    if (f->output) fclose(f->output);
-    f->output = NULL;
     check_filename(f->name);
     if (openit) {
         if (!(f->output = fopen(f->name, "w"))) {
@@ -903,7 +955,22 @@
         }
     }
     DEBUG_RET();
-    return 0;
+}
+
+
+void close_separate_file(struct file_ll *f) {
+    DEBUG_ENT("close_separate_file");
+    if (f->output) {
+        struct stat st;
+        fclose(f->output);
+        stat(f->name, &st);
+        if (!st.st_size) {
+            DEBUG_WARN(("removing empty output file %s\n", f->name));
+            remove(f->name);
+        }
+        f->output = NULL;
+    }
+    DEBUG_RET();
 }
 
 
@@ -958,6 +1025,7 @@
     char *attach_filename = (attach->filename2.str) ? attach->filename2.str
                                                     : attach->filename1.str;
     DEBUG_ENT("write_separate_attachment");
+    DEBUG_INFO(("Attachment %s Size is %#"PRIx64", data = %#"PRIxPTR", id %#"PRIx64"\n", attach_filename, (uint64_t)attach->data.size, attach->data.data, attach->i_id));
 
     if (!attach->data.data) {
         // make sure we can fetch data from the id
@@ -1000,7 +1068,7 @@
 }
 
 
-void write_embedded_message(FILE* f_output, pst_item_attach* attach, char *boundary, pst_file* pf, char** extra_mime_headers)
+void write_embedded_message(FILE* f_output, pst_item_attach* attach, char *boundary, pst_file* pf, int save_rtf, char** extra_mime_headers)
 {
     pst_index_ll *ptr;
     DEBUG_ENT("write_embedded_message");
@@ -1028,9 +1096,13 @@
     if (!item) {
         DEBUG_WARN(("write_embedded_message: pst_parse_item was unable to parse the embedded message in attachment ID %llu", attach->i_id));
     } else {
-        fprintf(f_output, "\n--%s\n", boundary);
-        fprintf(f_output, "Content-Type: %s\n\n", attach->mimetype.str);
-        write_normal_email(f_output, "", item, MODE_NORMAL, 0, pf, 0, extra_mime_headers);
+        if (!item->email) {
+            DEBUG_WARN(("write_embedded_message: pst_parse_item returned type %d, not an email message", item->type));
+        } else {
+            fprintf(f_output, "\n--%s\n", boundary);
+            fprintf(f_output, "Content-Type: %s\n\n", attach->mimetype.str);
+            write_normal_email(f_output, "", item, MODE_NORMAL, 0, pf, save_rtf, extra_mime_headers);
+        }
         pst_freeItem(item);
     }
 
@@ -1040,9 +1112,8 @@
 
 void write_inline_attachment(FILE* f_output, pst_item_attach* attach, char *boundary, pst_file* pst)
 {
-    char *attach_filename;
     DEBUG_ENT("write_inline_attachment");
-    DEBUG_INFO(("Attachment Size is %"PRIu64", id %#"PRIx64"\n", (uint64_t)attach->data.size, attach->i_id));
+    DEBUG_INFO(("Attachment Size is %#"PRIx64", data = %#"PRIxPTR", id %#"PRIx64"\n", (uint64_t)attach->data.size, attach->data.data, attach->i_id));
 
     if (!attach->data.data) {
         // make sure we can fetch data from the id
@@ -1062,13 +1133,19 @@
     }
     fprintf(f_output, "Content-Transfer-Encoding: base64\n");
 
-    // If there is a long filename (filename2) use that, otherwise
-    // use the 8.3 filename (filename1)
-    attach_filename = (attach->filename2.str) ? attach->filename2.str : attach->filename1.str;
-    if (!attach_filename) {
+    if (attach->filename2.str) {
+        // use the long filename, converted to proper encoding if needed.
+        // it is already utf8
+        pst_rfc2231(&attach->filename2);
+        fprintf(f_output, "Content-Disposition: attachment; \n        filename*=%s\n\n", attach->filename2.str);
+    }
+    else if (attach->filename1.str) {
+        // short filename never needs encoding
+        fprintf(f_output, "Content-Disposition: attachment; filename=\"%s\"\n\n", attach->filename1.str);
+    }
+    else {
+        // no filename is inline
         fprintf(f_output, "Content-Disposition: inline\n\n");
-    } else {
-        fprintf(f_output, "Content-Disposition: attachment; filename=\"%s\"\n\n", attach_filename);
     }
 
     (void)pst_attach_to_file_base64(pst, attach, f_output);
@@ -1077,6 +1154,36 @@
 }
 
 
+int  valid_headers(char *header)
+{
+    // headers are sometimes really bogus - they seem to be fragments of the
+    // message body, so we only use them if they seem to be real rfc822 headers.
+    // this list is composed of ones that we have seen in real pst files.
+    // there are surely others. the problem is - given an arbitrary character
+    // string, is it a valid (or even reasonable) set of rfc822 headers?
+    if (header) {
+        if ((strncasecmp(header, "X-Barracuda-URL: ", 17) == 0) ||
+            (strncasecmp(header, "X-ASG-Debug-ID: ",  16) == 0) ||
+            (strncasecmp(header, "Return-Path: ",     13) == 0) ||
+            (strncasecmp(header, "Received: ",        10) == 0) ||
+            (strncasecmp(header, "Subject: ",          9) == 0) ||
+            (strncasecmp(header, "Date: ",             6) == 0) ||
+            (strncasecmp(header, "From: ",             6) == 0) ||
+            (strncasecmp(header, "X-x: ",              5) == 0) ||
+            (strncasecmp(header, "Microsoft Mail Internet Headers", 31) == 0)) {
+            return 1;
+        }
+        else {
+            if (strlen(header) > 2) {
+                DEBUG_INFO(("Ignore bogus headers = %s\n", header));
+            }
+            return 0;
+        }
+    }
+    else return 0;
+}
+
+
 void header_has_field(char *header, char *field, int *flag)
 {
     DEBUG_ENT("header_has_field");
@@ -1166,7 +1273,7 @@
     int b64 = 0;
     uint8_t *b = (uint8_t *)body;
     DEBUG_ENT("test_base64");
-    while (*b != 0) {
+    while (*b) {
         if ((*b < 32) && (*b != 9) && (*b != 10)) {
             DEBUG_INFO(("found base64 byte %d\n", (int)*b));
             DEBUG_HEXDUMPC(body, strlen(body), 0x10);
@@ -1217,7 +1324,7 @@
         char *temp, *t;
         while ((temp = strstr(headers, "\n\n"))) {
             temp[1] = '\0';
-            t = header_get_field(headers, "\nContent-Type: ");
+            t = header_get_field(headers, "\nContent-Type:");
             if (t) {
                 t++;
                 DEBUG_INFO(("found content type header\n"));
@@ -1297,7 +1404,13 @@
     fprintf(f_output, "PRODID:LibPST v%s\n", VERSION);
     if (method) fprintf(f_output, "METHOD:%s\n", method);
     fprintf(f_output, "BEGIN:VEVENT\n");
-    if (sender) fprintf(f_output, "ORGANIZER;CN=\"%s\":MAILTO:%s\n", item->email->outlook_sender_name.str, sender);
+    if (sender) {
+        if (item->email->outlook_sender_name.str) {
+            fprintf(f_output, "ORGANIZER;CN=\"%s\":MAILTO:%s\n", item->email->outlook_sender_name.str, sender);
+        } else {
+            fprintf(f_output, "ORGANIZER;CN=\"\":MAILTO:%s\n", sender);
+        }
+    }
     write_appointment(f_output, item);
     fprintf(f_output, "END:VCALENDAR\n");
 }
@@ -1345,7 +1458,9 @@
     DEBUG_ENT("write_normal_email");
 
     pst_convert_utf8_null(item, &item->email->header);
-    headers = (item->email->header.str) ? item->email->header.str : *extra_mime_headers;
+    headers = valid_headers(item->email->header.str) ? item->email->header.str :
+              valid_headers(*extra_mime_headers)     ? *extra_mime_headers     :
+              NULL;
 
     // setup default body character set and report type
     strncpy(body_charset, pst_default_charset(item, sizeof(buffer_charset), buffer_charset), sizeof(body_charset));
@@ -1374,7 +1489,7 @@
         else
             c_time = "Fri Dec 28 12:06:21 2001";
     } else
-        c_time= "Fri Dec 28 12:06:21 2001";
+        c_time = "Fri Dec 28 12:06:21 2001";
 
     // create our MIME boundaries here.
     snprintf(boundary, sizeof(boundary), "--boundary-LibPST-iamunique-%i_-_-", rand());
@@ -1391,26 +1506,27 @@
             temp[1] = '\0';
             // pointer to all the embedded MIME headers.
             // we use these to find the actual rfc822 headers for embedded message/rfc822 mime parts
-            *extra_mime_headers = temp+2;
+            // but only for the outermost message
+            if (!*extra_mime_headers) *extra_mime_headers = temp+2;
             DEBUG_INFO(("Found extra mime headers\n%s\n", temp+2));
         }
 
         // Check if the headers have all the necessary fields
-        header_has_field(headers, "\nFrom: ",        &has_from);
-        header_has_field(headers, "\nTo: ",          &has_to);
-        header_has_field(headers, "\nSubject: ",     &has_subject);
-        header_has_field(headers, "\nDate: ",        &has_date);
-        header_has_field(headers, "\nCC: ",          &has_cc);
-        header_has_field(headers, "\nMessage-Id: ",  &has_msgid);
+        header_has_field(headers, "\nFrom:",        &has_from);
+        header_has_field(headers, "\nTo:",          &has_to);
+        header_has_field(headers, "\nSubject:",     &has_subject);
+        header_has_field(headers, "\nDate:",        &has_date);
+        header_has_field(headers, "\nCC:",          &has_cc);
+        header_has_field(headers, "\nMessage-Id:",  &has_msgid);
 
         // look for charset and report-type in Content-Type header
-        t = header_get_field(headers, "\nContent-Type: ");
+        t = header_get_field(headers, "\nContent-Type:");
         header_get_subfield(t, "charset", body_charset, sizeof(body_charset));
         header_get_subfield(t, "report-type", body_report, sizeof(body_report));
 
         // derive a proper sender email address
         if (!sender_known) {
-            t = header_get_field(headers, "\nFrom: ");
+            t = header_get_field(headers, "\nFrom:");
             if (t) {
                 // assume address is on the first line, rather than on a continuation line
                 t++;
@@ -1428,13 +1544,12 @@
 
         // Strip out the mime headers and some others that we don't want to emit
         header_strip_field(headers, "\nMicrosoft Mail Internet Headers");
-        header_strip_field(headers, "\nMIME-Version: ");
-        header_strip_field(headers, "\nContent-Type: ");
-        header_strip_field(headers, "\nContent-Transfer-Encoding: ");
-        header_strip_field(headers, "\nContent-class: ");
-        header_strip_field(headers, "\nX-MimeOLE: ");
-        header_strip_field(headers, "\nBcc:");
-        header_strip_field(headers, "\nX-From_: ");
+        header_strip_field(headers, "\nMIME-Version:");
+        header_strip_field(headers, "\nContent-Type:");
+        header_strip_field(headers, "\nContent-Transfer-Encoding:");
+        header_strip_field(headers, "\nContent-class:");
+        header_strip_field(headers, "\nX-MimeOLE:");
+        header_strip_field(headers, "\nX-From_:");
     }
 
     DEBUG_INFO(("About to print Header\n"));
@@ -1459,17 +1574,40 @@
             fprintf(f_output, "%s", headers);
             // make sure the headers end with a \n
             if (headers[len-1] != '\n') fprintf(f_output, "\n");
+            //char *h = headers;
+            //while (*h) {
+            //    char *e = strchr(h, '\n');
+            //    int   d = 1;    // normally e points to trailing \n
+            //    if (!e) {
+            //        e = h + strlen(h);  // e points to trailing null
+            //        d = 0;
+            //    }
+            //    // we could do rfc2047 encoding here if needed
+            //    fprintf(f_output, "%.*s\n", (int)(e-h), h);
+            //    h = e + d;
+            //}
         }
     }
 
+    // record read status
+    if ((item->flags & PST_FLAG_READ) == PST_FLAG_READ) {
+        fprintf(f_output, "Status: RO\n");
+    }
+
     // create required header fields that are not already written
 
     if (!has_from) {
-        fprintf(f_output, "From: \"%s\" <%s>\n", item->email->outlook_sender_name.str, sender);
+        if (item->email->outlook_sender_name.str){
+            pst_rfc2047(item, &item->email->outlook_sender_name, 1);
+            fprintf(f_output, "From: %s <%s>\n", item->email->outlook_sender_name.str, sender);
+        } else {
+            fprintf(f_output, "From: <%s>\n", sender);
+        }
     }
 
     if (!has_subject) {
         if (item->subject.str) {
+            pst_rfc2047(item, &item->subject, 0);
             fprintf(f_output, "Subject: %s\n", item->subject.str);
         } else {
             fprintf(f_output, "Subject: \n");
@@ -1477,12 +1615,12 @@
     }
 
     if (!has_to && item->email->sentto_address.str) {
-        pst_convert_utf8(item, &item->email->sentto_address);
+        pst_rfc2047(item, &item->email->sentto_address, 0);
         fprintf(f_output, "To: %s\n", item->email->sentto_address.str);
     }
 
     if (!has_cc && item->email->cc_address.str) {
-        pst_convert_utf8(item, &item->email->cc_address);
+        pst_rfc2047(item, &item->email->cc_address, 0);
         fprintf(f_output, "Cc: %s\n", item->email->cc_address.str);
     }
 
@@ -1510,7 +1648,7 @@
 
     if (item->email->bcc_address.str) {
         pst_convert_utf8(item, &item->email->bcc_address);
-        fprintf(f_output, "Bcc: %s\n", item->email->bcc_address.str);
+        fprintf(f_output, "X-libpst-forensic-bcc: %s\n", item->email->bcc_address.str);
     }
 
     // add our own mime headers
@@ -1613,7 +1751,7 @@
                 attach->mimetype.str = strdup(RFC822);
                 attach->mimetype.is_utf8 = 1;
                 find_rfc822_headers(extra_mime_headers);
-                write_embedded_message(f_output, attach, boundary, pst, extra_mime_headers);
+                write_embedded_message(f_output, attach, boundary, pst, save_rtf, extra_mime_headers);
             }
             else if (attach->data.data || attach->i_id) {
                 if (mode == MODE_SEPARATE && !mode_MH)
@@ -1855,6 +1993,7 @@
     pst_convert_utf8_null(item, &item->body);
     pst_convert_utf8_null(item, &appointment->location);
 
+    fprintf(f_output, "UID:%#"PRIx64"\n", item->block_id);
     fprintf(f_output, "DTSTAMP:%s\n",                     pst_rfc2445_datetime_format_now(sizeof(time_buffer), time_buffer));
     if (item->create_date)
         fprintf(f_output, "CREATED:%s\n",                 pst_rfc2445_datetime_format(item->create_date, sizeof(time_buffer), time_buffer));
@@ -1948,6 +2087,14 @@
                 fprintf(f_output, "CATEGORIES:PHONE-CALL\n");
                 break;
         }
+        // ignore bogus alarms
+        if (appointment->alarm && (appointment->alarm_minutes >= 0) && (appointment->alarm_minutes < 1440)) {
+            fprintf(f_output, "BEGIN:VALARM\n");
+            fprintf(f_output, "TRIGGER:-PT%dM\n", appointment->alarm_minutes);
+            fprintf(f_output, "ACTION:DISPLAY\n");
+            fprintf(f_output, "DESCRIPTION:Reminder\n");
+            fprintf(f_output, "END:VALARM\n");
+        }
     }
     fprintf(f_output, "END:VEVENT\n");
     if (result) free(result);
@@ -2030,6 +2177,7 @@
         pst_debug_unlock();
     }
     if (f->output) {
+        if (mode == MODE_SEPARATE) DEBUG_WARN(("close_enter_dir finds open separate file\n"));
         struct stat st;
         fclose(f->output);
         stat(f->name, &st);
@@ -2037,6 +2185,7 @@
             DEBUG_WARN(("removing empty output file %s\n", f->name));
             remove(f->name);
         }
+        f->output = NULL;
     }
     free(f->name);
     free(f->dname);
--- a/xml/libpst.in	Thu Jun 03 19:09:29 2010 -0700
+++ b/xml/libpst.in	Mon Dec 24 17:51:12 2012 -0800
@@ -35,7 +35,7 @@
 
     <refentry id="readpst.1">
         <refentryinfo>
-            <date>2009-09-14</date>
+            <date>2011-05-27</date>
         </refentryinfo>
 
         <refmeta>
@@ -53,6 +53,7 @@
             <title>Synopsis</title>
             <cmdsynopsis>
                 <command>readpst</command>
+                <arg><option>-C <replaceable class="parameter">default-charset</replaceable></option></arg>
                 <arg><option>-D</option></arg>
                 <arg><option>-M</option></arg>
                 <arg><option>-S</option></arg>
@@ -86,6 +87,12 @@
             <title>Options</title>
             <variablelist>
                 <varlistentry>
+                    <term>-C <replaceable class="parameter">default-charset</replaceable></term>
+                    <listitem><para>
+                        Set the character set to be used for items with an unspecified character set.
+                    </para></listitem>
+                </varlistentry>
+                <varlistentry>
                     <term>-D</term>
                     <listitem><para>
                         Include deleted items in the output.
@@ -97,7 +104,7 @@
                         Output messages in MH (rfc822) format as separate files.  This will create
                         folders as named in the PST file, and will put each email together with
                         any attachments into its own file.  These files will be numbered from 1
-                        to n with no leading zeros.
+                        to n with no leading zeros. This format has no from quoting.
                     </para></listitem>
                 </varlistentry>
                 <varlistentry>
@@ -105,12 +112,12 @@
                     <listitem><para>
                         Output messages into separate files.  This will create folders as
                         named in the PST file, and will put each email in its own file.  These
-                        files will be numbered from 1 to n with no leading zeros. So the email
-                        contents for message $m are saved in a file named $m.  Attachments
+                        files will be numbered from 1 to n with no leading zeros.  Attachments
                         will also be saved in the same folder as the email message. The
                         attachments for message $m are saved as $m-$name where $name is (the
                         original name of the attachment, or 'attach$n' if the attachment had
                         no name), where $n is another sequential index with no leading zeros.
+                        This format has no from quoting.
                     </para></listitem>
                 </varlistentry>
                 <varlistentry>
@@ -142,7 +149,7 @@
                     <term>-e</term>
                     <listitem><para>
                         Same as the M option, but each output file will include an extension
-                        from (.eml, .ics, .vcf).
+                        from (.eml, .ics, .vcf). This format has no from quoting.
                     </para></listitem>
                 </varlistentry>
                 <varlistentry>
@@ -155,13 +162,15 @@
                     <term>-j <replaceable class="parameter">jobs</replaceable></term>
                     <listitem><para>
                         Specifies the maximum number of parallel jobs. Specify 0 to suppress
-                        running parallel jobs.
+                        running parallel jobs. Folders may be processed in parallel. Output
+                        formats that place each mail message in a separate file (-M, -S, -e)
+                        may process the contents of individual folders in parallel.
                     </para></listitem>
                 </varlistentry>
                 <varlistentry>
                     <term>-k</term>
                     <listitem><para>
-                        Changes the output format to KMail.
+                        Changes the output format to KMail. This format uses mboxrd from quoting.
                     </para></listitem>
                 </varlistentry>
                 <varlistentry>
@@ -191,7 +200,7 @@
                         Changes the output format to Recursive. This will create folders as
                         named in the PST file, and will put all emails in a file called "mbox"
                         inside each folder. These files are then compatible with all
-                        mbox-compatible email clients.
+                        mbox-compatible email clients. This format uses mboxrd from quoting.
                     </para></listitem>
                 </varlistentry>
                 <varlistentry>
@@ -206,7 +215,8 @@
                     <term>-u</term>
                     <listitem><para>
                         Sets Thunderbird mode, a submode of recursive mode. This causes
-                        two extra .type and .size meta files to be created.
+                        two extra .type and .size meta files to be created. This format uses
+                        mboxrd from quoting.
                     </para></listitem>
                 </varlistentry>
                 <varlistentry>
@@ -220,6 +230,19 @@
             </variablelist>
         </refsect1>
 
+        <refsect1 id='readpst.quoting.1'>
+            <title>From Quoting</title>
+            <para>
+                Output formats that place each mail message in a separate file (-M, -S, -e)
+                don't do any from quoting.
+                Output formats that place multiple email messages in a single file (-k, -r, -u)
+                now use mboxrd from quoting rules.
+                If none of those switches are specified, the default output format uses mboxrd
+                from quoting rules, since it produces multiple email messages in a single file.
+                Earlier versions used mboxo from quoting rules for all output formats.
+            </para>
+        </refsect1>
+
         <refsect1 id='readpst.author.1'>
             <title>Author</title>
             <para>
@@ -261,7 +284,7 @@
 
     <refentry id="lspst.1">
         <refentryinfo>
-            <date>2009-09-14</date>
+            <date>2011-05-27</date>
         </refentryinfo>
 
         <refmeta>
@@ -356,7 +379,7 @@
 
     <refentry id="pst2ldif.1">
         <refentryinfo>
-            <date>2009-09-14</date>
+            <date>2011-05-27</date>
         </refentryinfo>
 
         <refmeta>
@@ -524,7 +547,7 @@
 
     <refentry id="pst2dii.1">
         <refentryinfo>
-            <date>2009-09-14</date>
+            <date>2011-05-27</date>
         </refentryinfo>
 
         <refmeta>
@@ -657,7 +680,7 @@
 
     <refentry id="pst.5">
         <refentryinfo>
-            <date>2009-09-14</date>
+            <date>2011-05-27</date>
         </refentryinfo>
 
         <refmeta>