diff --git a/ChangeLog b/ChangeLog index 0a767ed..97ccf78 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,683 +1,685 @@ LibPST 0.6.30 (2009-xx-xx) =============================== * improve documentation of .pst format. * remove decrypt option from getidblock - we always decrypt. * rename some structure fields to reflect our better understanding of the pst format. * track character set individually for each mapi element, since some could be unicode (therefore utf8) and others sbcs with character set specified by the mapi object. remove charset option from pst2ldif since we get that from each object now. * more code cleanup. + * use AM_ICONV for better portability of the library location. + * structure renaming to be more specific. LibPST 0.6.29 (2009-02-24) =============================== * fix for 64bit on Fedora 11 LibPST 0.6.28 (2009-02-24) =============================== * add X-libpst-forensic-* headers to capture items of interest that are not used by normal mail clients. * improve decoding of multipart/report and message/rfc822 mime types. * improve character set handling - don't try to convert utf-8 to single byte for fields that were not originally unicode. if the conversion fails, leave the data in utf-8. * fix embedded rfc822 messages with attachments. LibPST 0.6.27 (2009-02-07) =============================== * fix for const correctness on Fedora 11 LibPST 0.6.26 (2009-02-07) =============================== * patch from Fridrich Strba for building on mingw and general cleanup of autoconf files * add processing for pst files of type 0x0f * start adding support for properly building and installing libpst.so and the header files required to use it. * remove version.h since the version number is now in config.h * more const correctness issues regarding getopt() * consistent ordering of our include files. all system includes protected by ifdef HAVE_ from autoconf. * strip and regenerate all MIME headers to avoid duplicates. problem found by Michael Watson on Mac OSX. * do a better job of making unique MIME boundaries. * only use base64 coding when strictly necessary. * more cleanup of #include files. common.h is the only file allowed to include system .h files unprotected by autoconf HAVE_ symbols. define.h is the only other file allowed to include system .h files. define.h is never installed; common.h is installed if we are building the shared library. * recover dropped pragma pack line, use int64_t rather than off_t to avoid forcing users of the shared library to enable large file support. * add pragma packing support for sun compilers. * fix initial from header in mbox format. * start moving to PST_LE_GET* rather than LE*_CPU macros so we can eventually remove the pragma packing. * patch from Fridrich Strba, some systems need extra library for regex. LibPST 0.6.25 (2009-01-16) =============================== * improve handling of content-type charset values in mime parts LibPST 0.6.24 (2008-12-11) =============================== * patch from Chris Eagle to build on cygwin LibPST 0.6.23 (2008-12-04) =============================== * bump version to avoid cvs tagging mistake in fedora LibPST 0.6.22 (2008-11-28) =============================== * patch from David Cuadrado to process emails with type PST_TYPE_OTHER * base64_encode_multiple() may insert newline, needs larger malloc * subject lines shorter than 2 bytes could segfault LibPST 0.6.21 (2008-10-21) =============================== * fix title bug with old schema in pst2ldif. * also escape commas in distinguished names per rfc4514. LibPST 0.6.20 (2008-10-09) =============================== * add configure option --enable-dii=no to remove dependency on libgd. * many fixes in pst2ldif by Robert Harris. * add -D option to include deleted items, from Justin Greer * fix from Justin Greer to add missing email headers * fix from Justin Greer for my_stristr() * fix for orphan children when building descriptor tree * avoid writing uninitialized data to debug log file * remove unreachable code * create dummy top-of-folder descriptor if needed for corrupt pst files LibPST 0.6.19 (2008-09-14) =============================== * Fix base64 encoding that could create long lines * Initial work on a .so shared library from Bharath Acharya. LibPST 0.6.18 (2008-08-28) =============================== * Fixes for iconv on Mac from Justin Greer. LibPST 0.6.17 (2008-08-05) =============================== * More fixes for 32/64 bit portability on big endian ppc. LibPST 0.6.16 (2008-08-05) =============================== * Use inttypes.h for portable printing of 64 bit items. LibPST 0.6.15 (2008-07-30) =============================== * Patch from Robert Simpson for file handle leak in error case. * Fix for missing length on lz decompression, bug found by Chris White. LibPST 0.6.14 (2008-06-15) =============================== * Fix my mistake in debian packaging. LibPST 0.6.13 (2008-06-13) =============================== * Patch from Robert Simpson for encryption type 2. * Fix the order of testing item types to avoid claiming there are multiple message stores. LibPST 0.6.12 (2008-06-10) =============================== * Patch from Joachim Metz for debian packaging, and fix for incorrect length on lz decompression. LibPST 0.6.11 (2008-06-03) =============================== * Use ftello/fseeko to properly handle large files. * Document and properly use datasize field in b5 blocks. * Fix some MSVC compile issues and collect MSVC dependencies into one place. LibPST 0.6.10 (2008-05-29) =============================== * Patch from Robert Simpson fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them). * More changes for Fedora packaging (#434727) * Fixes for const correctness. LibPST 0.6.9 (2008-05-16) =============================== * Patch from Joachim Metz for 64 bit compile. * Signed/unsigned cleanup from 'CFLAGS=-Wextra ./configure'. * Reindent vbuf.c to make it readable. * Fix pst format documentation for 8 byte backpointers. LibPST 0.6.8 (2008-03-05) =============================== * Initial version of pst2dii to convert to Summation dii load file format. * Changes for Fedora packaging (#434727) LibPST 0.6.7 (2008-02-16) =============================== * Work around bogus 7c.b5 blocks in some messages that have been read. They appear to have attachments, but of some unknown format. Before the message was read, it did not have any attachments. * Use autoscan to cleanup our autoconf system. * Use autoconf to detect when we need to use our XGetopt files and other header files. * More fields, including BCC. * Fix missing LE32_CPU byte swapping for FILETIME types. LibPST 0.6.6 (2008-01-31) =============================== * More code cleanup, removing unnecessary null terminations on binary buffers. All pst file reads now go thru one function. Logging all pst reads to detect cases where we read the same data multiple times - discovers node sizes are actually 512 bytes. * Switch from cvs to mercurial source control. LibPST 0.6.5 (2008-01-22) =============================== * More code cleanup, removing obsolete code. All the boolean flags of type 0xb have length 4, so these are all 32 bits in the file. Libpst treats them all as 16 bits, but at least we are consistent. * More fields decoded - for example, see We should be able to use that data for much more complete decoding. * Move the rpm group to Applications/Productivity consistent with Evolution. LibPST 0.6.4 (2008-01-19) =============================== * More fixes for Outlook 2003 64 bit parsing. We observed cases of compressed RTF bodies (type 0x1009) with zero length. * Document type 0x0101 descriptor blocks and process them. * Fix large file support - we need to include config.h before any standard headers. * Merge following changes from svn snapshot from Alioth: * Add new fields to appointment for recurring events (SourceForge #304198) * Map IPM.Task items to PST_TYPE_TASK. * Applied patch to remove compiler warnings, thanks! (SourceForge #304314) * Fix crash with unknown reference type * Fix more memory issues detected by valgrind * lspst - add usage mesage and option parsing using getopt (SourceForge #304199) * Fix crash caused by invalid free calls * Fix crash when email subject is empty * Fix memory and information leak in hex debug dump LibPST 0.6.3 (2008-01-13) =============================== * More type consistency issues found by splint. LibPST 0.6.2 (2008-01-12) =============================== * More fixes for Outlook 2003 64 bit parsing. * All buffer sizes changed to size_t, all file offsets changed to off_t, all function names start with pst_, many other type consistency issues found by splint. Many changes to #llx in debug printing for 64 bit items. All id values are now uint64_t. LibPST 0.6.1 (2008-01-06) =============================== * Outlook 2003 64 bit parsing. Some documentation from Alexander Grau and patches from Sean Loaring . * fix from Antonio Palama for email items that happen to have item->contact non null, and were being processed as contacts. * Add large file support so we can read .pst files larger than 2gb. * Change lspst to be similar to readpst, properly using recursion to walk the tree, and testing item types. Add a man page for lspst. LibPST 0.5.12 (2007-10-02) =============================== * security fix from Brad Hards for buffer overruns in liv-zemple decoding for corrupted or malicious pst files. LibPST 0.5.11 (2007-08-24) =============================== * fix from Stevens Miller for unitialized variable. LibPST 0.5.10 (2007-08-20) =============================== * fix yet more valgrind errors - finally have a clean memory check. * restructure readpst.c for proper recursive tree walk. * buffer overrun test was backwards, introduced at 0.5.6 * fix broken email attachments, introduced at 0.5.6 LibPST 0.5.9 (2007-08-12) =============================== * fix more valgrind errors. LibPST 0.5.8 (2007-08-10) =============================== * fix more valgrind errors. lzfu_decompress needs to return the actual buffer size, since the lz header overestimates the size. This caused base64_encode to encode undefined bytes into the email attachment. LibPST 0.5.7 (2007-08-09) =============================== * fix valgrind errors, using uninitialized data. * improve debug logging and readpstlog for indented listings. * cleanup documentation. LibPST 0.5.6 (2007-07-15) =============================== * Fix to allow very small pst files with only one node in the tree. We were mixing signed/unsigned types in comparisons. * More progress decoding the basic structure 7c blocks. Many four byte values may be ID2 indices with data outside the buffer. * Start using doxygen to generate internal documentation. LibPST 0.5.5 (2007-07-10) =============================== * merge the following changes from Joe Nahmias version: * Lots of memory fixes. Thanks to Nigel Horne for his assistance tracking these down! * Fixed creation of vCards from contacts, thanks to Nigel Horne for his help with this! * fix for MIME multipart/alternative attachments. * added -c options to readpst manpage. * use 8.3 attachment filename if long filename isn't available. * new -b option to skip rtf-body.rtf attachments. * fix format of From header lines in mbox files. * Add more appointment fields, thanks to Chris Halls for tracking them down! LibPST 0.5.4 (2006-02-25) =============================== * patches from Arne, adding MH mode, remove leading zeros from the generated numbered filenames starting with one rather than zero. Miscellaneous code cleanup. * document the "7c" descriptor block format. LibPST 0.5.3 (2006-02-20) =============================== * switch to gnu autoconf/automake. This breaks the MS VC++ projects since the source code is now in the src subdirectory. * documentation switched to xml, building man pages and html from the master xml copy. * include rpm .spec file for building src and binary rpms. LibPST 0.5.2 (2006-02-18) =============================== * Added pst2ldif to convert the contacts to ldif format for import into ldap databases. * Major changes to libpst.c to properly use the node depth values from the b-tree nodes. We also use the item count values in the nodes rather than trying to guess how many items are active. * Cleanup whitespace - using tabs for every four columns. LibPST 0.5.1 (17 November 2004) =============================== Well, alot has happened since the last release of libpst. Release / Management: * The project has forked! The new maintainer is Joseph Nahmias. * We have changed hosting sites, thanks to sourceforge for hosting to this point. From this point forward we will be using alioth.debian.org. * The project is now using SubVersioN for source control. You can get the latest code by running: svn co svn://svn.debian.org/svn/libpst/trunk . * See for more information. Code Changes: * Added lspst program to list items in a PST. Still incomplete. * Added vim folding markers to readpst.c * avoid the pseudo-prologue that MS prepends to the email headers * fix build on msvc, since it doesn't have sys/param.h * Re-vamped Makefile: * Only define CFLAGS in Makefileif missing * fixed {un,}install targets in Makefile * Fixed up build process in Makefile * Added mozilla conversion script from David Binard * Fixed bogus creation of readpst.log on every invocation * escaped dashes and apostrophe in manpages * Updated TODO * added manpages from debian pkg * fix escaped-string length count to consider '\n', thanks to Paul Bakker . * ensure there's a blank line between header and body patch from (SourceForge #890745). * Apply accumulated endian-related patches * Removed unused files, upstream's debian/ dir -- Joe Nahmias LibPST v0.5 =========== It is with GREAT relief that I bring you version 0.5 of the LibPST tools! Through great difficulties, this tool has survived and expanded to become even better. The changes are as follows: * RTF support. We can now decompress RTF bodies in emails, and are saved as attachments * Better support in reading the indexes. Fixed many bugs with them * Improved reliability. "Now we are getting somewhere!" * Improved compiling. Hopefully we won't be hitting too many compile errors now. * vCard handling. Contacts are now exported as vCard entries. * vEvent handling. Support has begun on exporting Calendar entries as events * Support for Journal entries has also begun If you have any problems with this release, don't hesitate to contact me. These changes come to you, as always, free under the GPL license!! What a wonderful thing it is. It does mean that you can write your own program off of this library and distribute it also for free. However, anyone with commercial interests for developing applications they will be charging for are encouraged to get in touch with me, as I am sure we can come to some arrangement. Dave Smith LibPST v0.4.3 ============= Bug fix release. No extra functionality Dave Smith LibPST v0.4.2 ============= The debug system has had an overhaul. The debug messages are no longer printed to the screen when they are enabled. They are dumped to a binary file. There is another utility called "readlog" that I have written to handle these log files. It should make it easier to selectively view bits of a log file. It also shows the position that the log message was printed from. There is a new switch in readpst. It is -d. It enables the user to specify the log file which the binary log is written to. If the switch isn't used, the default file of "readpst.log" is used. The code is now Visual C++ compatible. It has compiled on Visual C++ .net Standard edition, and produces the readpst.exe file. Use the project file included in this distribution. There have been minor improvements elsewhere too. LibPST v0.4.1 ============= Fixed a couple more bugs. Is it me or do bugs just insert themselves in random, hard to find places! Cured a few problems with regard to emails with multiple embeded items. They are not fully re-created using Mime-types, but are accessible with the -S switch (which saves everything as seperate items) Fixed a problem reading the first index. Back sliders are now detected. (ie when the value following the current one is smaller, not bigger!) Added some error messages when we try and read outside of the PST file, this was causing a few problems before, cause the return value wasn't always checked, so it was possible to be reading random data, and trying to make sense of it! Anyway, if you find any problems, don't hesitate to mail me Dave Smith LibPST v0.4 =========== Fixed a nasty bug that occasionally corrupted attachments. Another bug with regard to reading of indexes (also occasional). Another output method has been added which is called "Seperate". It is activated with the -S switch. It operates in the following manor: |--Inbox-->000000 | 000001 | 000002 |--Sentmail-->0000000 | 0000001 | 0000002 All the emails are stored in seperate files counting from 0 upwards, in a folder named as the PST folder. When an email has an attachment, it is saved as a seperate file. The filename for the attachment is made up of 2 parts, the first is the email number to which it belongs, the second is its filename. The should now be runnable on big-endian machines, if the define.h file is first modified. The #define LITTLE_ENDIAN must be commented out, and the #define BIG_ENDIAN must be uncommented. More verbose error messages have been added. Apparently people got confused when the program stopped for no visible reason. This has now been resolved. Thanks for the continued support of all people involved. Dave Smith Libpst v0.3.4 ============= Several more fixes. An Infinite loop and incorrect interpreting of item index attributes. Work has started on making the code executable on big endian CPUs. At present it should work with Linux on these CPUs, but I would appreciate it if you could provide feedback with regard to it's performance. I am also working with some other people at make it operate on Solaris. A whole load more items are now recognized by the Item records. With more items in Emails and Folders. I haven't got to the Contacts yet. Anyway, this is what I would call a minor feature enhancment and bugfix release. Dave Smith LibPST v0.3.3 ============= Fixed several items. Mainly memory leaks. Loads of them! oops.. I have added a new program, mainly of debugging, which when passed an ID value and a pst file, will extract and decrypt that ID from the pst file. I don't see it being a huge attraction, or of much use to most people, but it is another example of writing an application to use the libpst interface. Another fix was in the reading of the item index. This has hopefully now been corrected. The result of this bug was that not all the emails in a folder were converted. Hopefully you should have more luck now. Dave Smith LibPST v0.3.2 ============= Quick bugfix release. There was a bug in the decryption of the basic encryption that outlook uses. One byte, 0x6c, was incorrectly decrypted to 0x6c instead of 0xcd. This release fixes this bug. Sorry... LibPST v0.3.1 ============= Minor improvements. Fixed bug when linking multiple blocks together, so now the linking blocks are not "encrypted" when trying to read them. LibPST v0.3 =========== A lot of bug fixing has been done for this release. Testing has been done on the creation of the files by readpst. Better handling of large binaries being extracted from the PST file has been implemented. Quite a few reports have come in about not being able to compile on Darwin. This could be down to using macros with variable parameter lists. This has now been changed to use C functions with variable parameters. I hope this fixes a lot of problems. Added support for recreating the folder structure into normal directories. For Instance: Personal Folders |-Inbox | |-Jokes | |-Meetings |-Send Items each folder containing an mbox file with the correct emails for that folder. Dave Smith LibPST v0.3 beta1 ================= Again, a shed load of enhancements. More work has been done on the mime creation. A bug has been fixed that was letting part of the attachments that were created disappear. A major enhancement is that "compressible encryption" support has been added. This was an incredibly simple method to use. It is basically a ceasar cipher. It has been noted by several users already that the PST password that Outlook uses, serves *no purpose*. It is not used to encrypt the PST, it is mearly stored there. This means that the readpst application is able to convert PST files without knowing the password. Microsoft have some explaning to do! Output files are now not overwritten if they already exist. This means that if you have two folders in your PST file named "fred", the first one encountered will be named "fred" and the second one will be named "fred00000001". As you can see, there is enough room there for many duplicate names! Output filenames are now restricted. Any "/" or "\" characters in the name are replaced with "_". If you find that there are any other characters that need to be changed, could you please make me aware! Thanks to Berry Wizard for help with supporting the encryption. Thanks to Auke Kok, Carolus Walraven and Yogesh Kumar Guatam for providing debugging information and testing. Dave Smith LibPST v0.2 beta1 ================= Hello once more... Attachments are now re-created in mime format. The method is very crude and could be prone to over generalisation. Please test this version, and if attachments are not recreated correctly, please send me the email (complete message source) of the original and converted. Cheers. I hope this will work for everyone who uses this program, but reality can be very different! Let us see how it goes... Dave Smith LibPST v0.2 alpha1 =========== Hello! Some improvements. The internal code has been changed so that attachments are now processed and loaded into the structures. The readpst program is not finished yet. It needs to convert these binary structs into mime data. At present it just saves them to the current directory, overwriting any previous files with the attachment name. Improvements over previous version: * KMail output is supported - if the "-k" flag is specified, all the directory hierarchy is created using the KMail standard * Lots of bugs and memory leaks fixed Usage: ReadPST v0.2alpha1 implementing LibPST v0.2alpha1 Usage: ./readpst [OPTIONS] {PST FILENAME} OPTIONS: -h - Help. This screen -k - KMail. Output in kmail format -o - Output Dir. Directory to write files to. CWD is changed *after* opening pst file -V - Version. Display program version If you want to view lots of debug output, modify a line in "define.h" from "//#define DEBUG_ALL" to "#define DEBUG_ALL". It would then be advisable to pipe all output to a log file: ./readpst -o out pst_file &> logfile Dave Smith LibPST v0.1 =========== Hi Folks! This has been a long, hard slog, but I now feel that I have got somewhere useful. The included program "main" is able to read an Outlook PST file and dump the emails into mbox files, separating each folder into a different mbox file. All the mbox files are stored in the current directory and no attempt is yet made to organise these files into a directory hierarchy. This would not be too difficult to achieve though. Email attachments are not yet handled, neither are Contacts. There is no pretty interface yet, but you can convert a PST file in the following manner ./main {path to PST file} This is very much a work in progress, but I thought I should release this code so that people can lose their conception that outlook files will never be converted to Linux. I am intending that the code I am writing will be developed into greater applications to provide USEFUL tools for accessing and converting PST files into a variety of formats. One point I feel I should make is that Outlook, by default, creates "Compressible Encryption" PST files. I have not, as yet, attempted to write any decryption routines, so you will not be able to convert these files. However, if you create a new PST file and choose not to make an encrypted one, you can copy all your emails into this new one and then convert the unencrypted one. I hope you enjoy, Dave Smith diff --git a/Makefile.am b/Makefile.am index 7e8c026..327ee81 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,11 +1,11 @@ SUBDIRS = src man html info debian htmldir = ${datadir}/doc/@PACKAGE@-@VERSION@ html_DATA = AUTHORS COPYING ChangeLog NEWS README CLEANFILES = xml/libpst xml/Makefile -EXTRA_DIST = Doxyfile libpst.html.tar.gz libpst.spec $(wildcard xml/M*) $(wildcard xml/h*) $(wildcard xml/lib*) +EXTRA_DIST = config.rpath Doxyfile libpst.html.tar.gz libpst.spec $(wildcard xml/M*) $(wildcard xml/h*) $(wildcard xml/lib*) if !STATIC_TOOLS pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libpst.pc endif diff --git a/Makefile.cvs b/Makefile.cvs index 798b1e1..fd630f8 100644 --- a/Makefile.cvs +++ b/Makefile.cvs @@ -1,13 +1,13 @@ default: all HOST=$(shell hostname) all: libtoolize --force --copy - aclocal + aclocal -I m4 autoheader automake autoconf rm -rf html.internal doxygen tar cfz libpst.html.tar.gz html.internal diff --git a/TODO b/TODO index 7af853c..b81b4d0 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,9 @@ Need testing on big-endian machines. We may be missing some LEnn_CPU() calls. pst2diii needs header and mime type updates from readpst. +Change more c symbols to reflect mapi_element and mapi_object. A +mapi_object (email etc.) is composed of a list of mapi_elements +(subject, charset, etc.). diff --git a/config.rpath b/config.rpath new file mode 100644 index 0000000..c547c68 --- /dev/null +++ b/config.rpath @@ -0,0 +1,666 @@ +#! /bin/sh +# Output a system dependent set of variables, describing how to set the +# run time search path of shared libraries in an executable. +# +# Copyright 1996-2007 Free Software Foundation, Inc. +# Taken from GNU libtool, 2001 +# Originally by Gordon Matzigkeit , 1996 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# The first argument passed to this file is the canonical host specification, +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld +# should be set by the caller. +# +# The set of defined variables is at the end of this script. + +# Known limitations: +# - On IRIX 6.5 with CC="cc", the run time search patch must not be longer +# than 256 bytes, otherwise the compiler driver will dump core. The only +# known workaround is to choose shorter directory names for the build +# directory and/or the installation directory. + +# All known linkers require a `.a' archive for static linking (except MSVC, +# which needs '.lib'). +libext=a +shrext=.so + +host="$1" +host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + +# Code taken from libtool.m4's _LT_CC_BASENAME. + +for cc_temp in $CC""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`echo "$cc_temp" | sed -e 's%^.*/%%'` + +# Code taken from libtool.m4's AC_LIBTOOL_PROG_COMPILER_PIC. + +wl= +if test "$GCC" = yes; then + wl='-Wl,' +else + case "$host_os" in + aix*) + wl='-Wl,' + ;; + darwin*) + case $cc_basename in + xlc*) + wl='-Wl,' + ;; + esac + ;; + mingw* | cygwin* | pw32* | os2*) + ;; + hpux9* | hpux10* | hpux11*) + wl='-Wl,' + ;; + irix5* | irix6* | nonstopux*) + wl='-Wl,' + ;; + newsos6) + ;; + linux* | k*bsd*-gnu) + case $cc_basename in + icc* | ecc*) + wl='-Wl,' + ;; + pgcc | pgf77 | pgf90) + wl='-Wl,' + ;; + ccc*) + wl='-Wl,' + ;; + como) + wl='-lopt=' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + wl='-Wl,' + ;; + esac + ;; + esac + ;; + osf3* | osf4* | osf5*) + wl='-Wl,' + ;; + rdos*) + ;; + solaris*) + wl='-Wl,' + ;; + sunos4*) + wl='-Qoption ld ' + ;; + sysv4 | sysv4.2uw2* | sysv4.3*) + wl='-Wl,' + ;; + sysv4*MP*) + ;; + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + wl='-Wl,' + ;; + unicos*) + wl='-Wl,' + ;; + uts4*) + ;; + esac +fi + +# Code taken from libtool.m4's AC_LIBTOOL_PROG_LD_SHLIBS. + +hardcode_libdir_flag_spec= +hardcode_libdir_separator= +hardcode_direct=no +hardcode_minus_L=no + +case "$host_os" in + cygwin* | mingw* | pw32*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$GCC" != yes; then + with_gnu_ld=no + fi + ;; + interix*) + # we just hope/assume this is gcc and not c89 (= MSVC++) + with_gnu_ld=yes + ;; + openbsd*) + with_gnu_ld=no + ;; +esac + +ld_shlibs=yes +if test "$with_gnu_ld" = yes; then + # Set some defaults for GNU ld with shared library support. These + # are reset later if shared libraries are not supported. Putting them + # here allows them to be overridden if necessary. + # Unlike libtool, we use -rpath here, not --rpath, since the documented + # option of GNU ld is called -rpath, not --rpath. + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + case "$host_os" in + aix3* | aix4* | aix5*) + # On AIX/PPC, the GNU linker is very broken + if test "$host_cpu" != ia64; then + ld_shlibs=no + fi + ;; + amigaos*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + # Samuel A. Falvo II reports + # that the semantics of dynamic libraries on AmigaOS, at least up + # to version 4, is to share data among multiple programs linked + # with the same dynamic library. Since this doesn't match the + # behavior of shared libraries on other platforms, we cannot use + # them. + ld_shlibs=no + ;; + beos*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + cygwin* | mingw* | pw32*) + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec='-L$libdir' + if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + interix[3-9]*) + hardcode_direct=no + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + ;; + gnu* | linux* | k*bsd*-gnu) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + netbsd*) + ;; + solaris*) + if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then + ld_shlibs=no + elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) + case `$LD -v 2>&1` in + *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) + ld_shlibs=no + ;; + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`' + else + ld_shlibs=no + fi + ;; + esac + ;; + sunos4*) + hardcode_direct=yes + ;; + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + esac + if test "$ld_shlibs" = no; then + hardcode_libdir_flag_spec= + fi +else + case "$host_os" in + aix3*) + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L=yes + if test "$GCC" = yes; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + hardcode_direct=unsupported + fi + ;; + aix4* | aix5*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + else + aix_use_runtimelinking=no + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[23]|aix4.[23].*|aix5*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + ;; + esac + fi + hardcode_direct=yes + hardcode_libdir_separator=':' + if test "$GCC" = yes; then + case $host_os in aix4.[012]|aix4.[012].*) + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + hardcode_direct=unsupported + hardcode_minus_L=yes + hardcode_libdir_flag_spec='-L$libdir' + hardcode_libdir_separator= + fi + ;; + esac + fi + # Begin _LT_AC_SYS_LIBPATH_AIX. + echo 'int main () { return 0; }' > conftest.c + ${CC} ${LDFLAGS} conftest.c -o conftest + aix_libpath=`dump -H conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` + if test -z "$aix_libpath"; then + aix_libpath=`dump -HX64 conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` + fi + if test -z "$aix_libpath"; then + aix_libpath="/usr/lib:/lib" + fi + rm -f conftest.c conftest + # End _LT_AC_SYS_LIBPATH_AIX. + if test "$aix_use_runtimelinking" = yes; then + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + else + if test "$host_cpu" = ia64; then + hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' + else + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + fi + fi + ;; + amigaos*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + # see comment about different semantics on the GNU ld section + ld_shlibs=no + ;; + bsdi[45]*) + ;; + cygwin* | mingw* | pw32*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec=' ' + libext=lib + ;; + darwin* | rhapsody*) + hardcode_direct=no + if test "$GCC" = yes ; then + : + else + case $cc_basename in + xlc*) + ;; + *) + ld_shlibs=no + ;; + esac + fi + ;; + dgux*) + hardcode_libdir_flag_spec='-L$libdir' + ;; + freebsd1*) + ld_shlibs=no + ;; + freebsd2.2*) + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + ;; + freebsd2*) + hardcode_direct=yes + hardcode_minus_L=yes + ;; + freebsd* | dragonfly*) + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + ;; + hpux9*) + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + ;; + hpux10*) + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + fi + ;; + hpux11*) + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + case $host_cpu in + hppa*64*|ia64*) + hardcode_direct=no + ;; + *) + hardcode_direct=yes + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + ;; + esac + fi + ;; + irix5* | irix6* | nonstopux*) + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + netbsd*) + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + ;; + newsos6) + hardcode_direct=yes + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + openbsd*) + if test -f /usr/libexec/ld.so; then + hardcode_direct=yes + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + else + case "$host_os" in + openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) + hardcode_libdir_flag_spec='-R$libdir' + ;; + *) + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + ;; + esac + fi + else + ld_shlibs=no + fi + ;; + os2*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + ;; + osf3*) + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + osf4* | osf5*) + if test "$GCC" = yes; then + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + else + # Both cc and cxx compiler support -rpath directly + hardcode_libdir_flag_spec='-rpath $libdir' + fi + hardcode_libdir_separator=: + ;; + solaris*) + hardcode_libdir_flag_spec='-R$libdir' + ;; + sunos4*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_direct=yes + hardcode_minus_L=yes + ;; + sysv4) + case $host_vendor in + sni) + hardcode_direct=yes # is this really true??? + ;; + siemens) + hardcode_direct=no + ;; + motorola) + hardcode_direct=no #Motorola manual says yes, but my tests say they lie + ;; + esac + ;; + sysv4.3*) + ;; + sysv4*MP*) + if test -d /usr/nec; then + ld_shlibs=yes + fi + ;; + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) + ;; + sysv5* | sco3.2v5* | sco5v6*) + hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' + hardcode_libdir_separator=':' + ;; + uts4*) + hardcode_libdir_flag_spec='-L$libdir' + ;; + *) + ld_shlibs=no + ;; + esac +fi + +# Check dynamic linker characteristics +# Code taken from libtool.m4's AC_LIBTOOL_SYS_DYNAMIC_LINKER. +# Unlike libtool.m4, here we don't care about _all_ names of the library, but +# only about the one the linker finds when passed -lNAME. This is the last +# element of library_names_spec in libtool.m4, or possibly two of them if the +# linker has special search rules. +library_names_spec= # the last element of library_names_spec in libtool.m4 +libname_spec='lib$name' +case "$host_os" in + aix3*) + library_names_spec='$libname.a' + ;; + aix4* | aix5*) + library_names_spec='$libname$shrext' + ;; + amigaos*) + library_names_spec='$libname.a' + ;; + beos*) + library_names_spec='$libname$shrext' + ;; + bsdi[45]*) + library_names_spec='$libname$shrext' + ;; + cygwin* | mingw* | pw32*) + shrext=.dll + library_names_spec='$libname.dll.a $libname.lib' + ;; + darwin* | rhapsody*) + shrext=.dylib + library_names_spec='$libname$shrext' + ;; + dgux*) + library_names_spec='$libname$shrext' + ;; + freebsd1*) + ;; + freebsd* | dragonfly*) + case "$host_os" in + freebsd[123]*) + library_names_spec='$libname$shrext$versuffix' ;; + *) + library_names_spec='$libname$shrext' ;; + esac + ;; + gnu*) + library_names_spec='$libname$shrext' + ;; + hpux9* | hpux10* | hpux11*) + case $host_cpu in + ia64*) + shrext=.so + ;; + hppa*64*) + shrext=.sl + ;; + *) + shrext=.sl + ;; + esac + library_names_spec='$libname$shrext' + ;; + interix[3-9]*) + library_names_spec='$libname$shrext' + ;; + irix5* | irix6* | nonstopux*) + library_names_spec='$libname$shrext' + case "$host_os" in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= ;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 ;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 ;; + *) libsuff= shlibsuff= ;; + esac + ;; + esac + ;; + linux*oldld* | linux*aout* | linux*coff*) + ;; + linux* | k*bsd*-gnu) + library_names_spec='$libname$shrext' + ;; + knetbsd*-gnu) + library_names_spec='$libname$shrext' + ;; + netbsd*) + library_names_spec='$libname$shrext' + ;; + newsos6) + library_names_spec='$libname$shrext' + ;; + nto-qnx*) + library_names_spec='$libname$shrext' + ;; + openbsd*) + library_names_spec='$libname$shrext$versuffix' + ;; + os2*) + libname_spec='$name' + shrext=.dll + library_names_spec='$libname.a' + ;; + osf3* | osf4* | osf5*) + library_names_spec='$libname$shrext' + ;; + rdos*) + ;; + solaris*) + library_names_spec='$libname$shrext' + ;; + sunos4*) + library_names_spec='$libname$shrext$versuffix' + ;; + sysv4 | sysv4.3*) + library_names_spec='$libname$shrext' + ;; + sysv4*MP*) + library_names_spec='$libname$shrext' + ;; + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + library_names_spec='$libname$shrext' + ;; + uts4*) + library_names_spec='$libname$shrext' + ;; +esac + +sed_quote_subst='s/\(["`$\\]\)/\\\1/g' +escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"` +shlibext=`echo "$shrext" | sed -e 's,^\.,,'` +escaped_libname_spec=`echo "X$libname_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` +escaped_library_names_spec=`echo "X$library_names_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` +escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` + +LC_ALL=C sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <&1 | grep -i imagemagick >/dev/null ; echo $?`" != "x0"; then if test "$enable_dii" = "yes"; then enable_dii=no AC_MSG_WARN([wrong convert program found. pst2dii disabled]) fi fi fi AC_CHECK_HEADER([gd.h], [ AC_DEFINE([HAVE_GD_H], [1], [Define to 1 if you have the header file.]) ], [ if test "$enable_dii" = "yes"; then enable_dii=no AC_MSG_WARN([gd.h not found. pst2dii disabled]) fi ]) AM_CONDITIONAL(BUILD_DII, [test "$enable_dii" = "yes"]) # Checks for programs. AC_PROG_CXX AC_PROG_CC AM_PROG_CC_C_O AC_PROG_CPP AC_PROG_INSTALL AC_PROG_LN_S AC_PROG_LIBTOOL AC_PROG_MAKE_SET AC_PROG_RANLIB # make sure we get large file support AC_SYS_LARGEFILE AC_CHECK_SIZEOF(off_t) # Checks for header files. AC_CHECK_HEADER([unistd.h], AM_CONDITIONAL(NEED_XGETOPT, [test yes = no]), AM_CONDITIONAL(NEED_XGETOPT, [test yes = yes]) ) AC_HEADER_DIRENT AC_HEADER_STDC -AC_CHECK_HEADERS([ctype.h dirent.h errno.h fcntl.h iconv.h inttypes.h limits.h regex.h signal.h stdarg.h stdint.h stdio.h stdlib.h string.h sys/param.h sys/stat.h sys/types.h time.h unistd.h wchar.h]) +AC_CHECK_HEADERS([ctype.h dirent.h errno.h fcntl.h inttypes.h limits.h regex.h signal.h stdarg.h stdint.h stdio.h stdlib.h string.h sys/param.h sys/stat.h sys/types.h time.h unistd.h wchar.h]) # Checks for typedefs, structures, and compiler characteristics. AC_HEADER_STDBOOL AC_C_CONST AC_TYPE_OFF_T AC_TYPE_SIZE_T AC_STRUCT_TM # Checks for library functions. AC_FUNC_FSEEKO AC_FUNC_LSTAT AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK if test "$cross_compiling" != "yes"; then AC_FUNC_MALLOC AC_FUNC_MKTIME AC_FUNC_REALLOC fi AC_FUNC_STRFTIME AC_FUNC_VPRINTF AC_CHECK_FUNCS([memchr memmove memset regcomp strcasecmp strncasecmp strchr strdup strerror strpbrk strrchr strstr strtol]) - - -# iconv on mac is a library -SAVELIBS="$LIBS" -AC_SEARCH_LIBS([iconv_open], [iconv]) -if test "$SAVELIBS" != "$LIBS"; then - all_libraries="-L/usr/lib $all_libraries" - AC_SUBST(all_libraries) - AC_MSG_WARN([This should be building on Mac OSX, adding /usr/lib to the library path]) +AM_ICONV +if test "$am_cv_func_iconv" != "yes"; then + AC_MSG_ERROR([libpst requires iconv which is missing]) fi -AC_MSG_CHECKING([if iconv uses const arguments]) -AC_LANG_PUSH([C++]) -AC_COMPILE_IFELSE([ - #include - #include - int main(int argc, char* const* argv) - { - size_t inlen = 100; - char buffer[[inlen]]; - char *p = buffer; - size_t utf8_len = 2 * inlen + 1; - char utf8_buffer[[utf8_len]]; - char *utf8_p = utf8_buffer; - iconv_t cd = 0; - iconv(cd, (const char**)&p, &inlen, &utf8_p, &utf8_len); - } - ], - [AC_DEFINE(ICONV_CONST,const,[do we have const headers]) - AC_MSG_RESULT([yes]) - ], - [AC_DEFINE(ICONV_CONST,,[do we have const headers]) - AC_MSG_RESULT([no]) - ]) -AC_LANG_POP([C++]) - AC_CHECK_FUNCS(regexec,,[AC_CHECK_LIB(regex,regexec, [REGEXLIB=-lregex AC_DEFINE(HAVE_REGEXEC,1,[Define to 1 if you have the regexec function.])], [AC_MSG_ERROR([No regex library found])])]) AC_SUBST(REGEXLIB) # The following lines adds the --enable-pst-debug option to configure: # # Give the user the choice to enter one of these: # --enable-pst-debug # --enable-pst-debug=yes # --enable-pst-debug=no # AC_MSG_CHECKING([whether we are forcing debug dump file creation]) AC_ARG_ENABLE(pst-debug, AC_HELP_STRING([--enable-pst-debug], [force debug dump file creation]), [ case "${enableval}" in yes) ;; no) ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-pst-debug) ;; esac ], # default if not specified enable_pst_debug=no ) AC_MSG_RESULT([$enable_pst_debug]) if test "$enable_pst_debug" = "yes"; then AC_DEFINE(DEBUG_ALL, 1, Define to 1 to force debug dump file creation) fi # The following lines adds the --enable-libpst-shared option to configure: # # Give the user the choice to enter one of these: # --enable-libpst-shared # --enable-libpst-shared=yes # --enable-libpst-shared=no # AC_MSG_CHECKING([whether we are building libpst shared object]) AC_ARG_ENABLE(libpst-shared, AC_HELP_STRING([--enable-libpst-shared], [build libpst shared object]), [ case "${enableval}" in yes) ;; no) ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-libpst-shared) ;; esac ], # default if not specified enable_libpst_shared=no ) AC_MSG_RESULT([$enable_libpst_shared]) enable_static_tools=yes if test "$enable_libpst_shared" = "yes"; then enable_shared=yes enable_static_tools=no fi # needed by STATIC_TOOLS in src/Makefile.am AC_SUBST(PST_OBJDIR, [$objdir]) # The following lines adds the --enable-static-tools option to configure: # # Give the user the choice to enter one of these: # --enable-static-tools # --enable-static-tools=yes # --enable-static-tools=no # AC_MSG_CHECKING([whether to link command line tools with libpst statically]) AC_ARG_ENABLE([static-tools], AC_HELP_STRING([--enable-static-tools], [link command line tools with libpst statically]), [ case "${enableval}" in yes) ;; no) ;; *) AC_MSG_ERROR(bad value ${enableval} for --static-tools) ;; esac ], [ enable_static_tools=no ]) AC_MSG_RESULT([$enable_static_tools]) AM_CONDITIONAL(STATIC_TOOLS, [test "$enable_static_tools" = "yes"]) if test "$enable_static_tools" = "yes"; then enable_static="yes" fi AC_OUTPUT( \ Makefile \ debian/Makefile \ debian/changelog \ html/Makefile \ info/Makefile \ libpst.pc \ libpst.spec \ man/Makefile \ src/Makefile \ src/pst2dii.cpp \ xml/Makefile \ xml/libpst \ ) diff --git a/m4/iconv.m4 b/m4/iconv.m4 new file mode 100644 index 0000000..3cc6268 --- /dev/null +++ b/m4/iconv.m4 @@ -0,0 +1,180 @@ +# iconv.m4 serial AM7 (gettext-0.18) +dnl Copyright (C) 2000-2002, 2007-2009 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +AC_DEFUN([AM_ICONV_LINKFLAGS_BODY], +[ + dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + AC_REQUIRE([AC_LIB_RPATH]) + + dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV + dnl accordingly. + AC_LIB_LINKFLAGS_BODY([iconv]) +]) + +AC_DEFUN([AM_ICONV_LINK], +[ + dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and + dnl those with the standalone portable GNU libiconv installed). + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + + dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV + dnl accordingly. + AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) + + dnl Add $INCICONV to CPPFLAGS before performing the following checks, + dnl because if the user has installed libiconv and not disabled its use + dnl via --without-libiconv-prefix, he wants to use it. The first + dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed. + am_save_CPPFLAGS="$CPPFLAGS" + AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV]) + + AC_CACHE_CHECK([for iconv], [am_cv_func_iconv], [ + am_cv_func_iconv="no, consider installing GNU libiconv" + am_cv_lib_iconv=no + AC_TRY_LINK([#include +#include ], + [iconv_t cd = iconv_open("",""); + iconv(cd,NULL,NULL,NULL,NULL); + iconv_close(cd);], + [am_cv_func_iconv=yes]) + if test "$am_cv_func_iconv" != yes; then + am_save_LIBS="$LIBS" + LIBS="$LIBS $LIBICONV" + AC_TRY_LINK([#include +#include ], + [iconv_t cd = iconv_open("",""); + iconv(cd,NULL,NULL,NULL,NULL); + iconv_close(cd);], + [am_cv_lib_iconv=yes] + [am_cv_func_iconv=yes]) + LIBS="$am_save_LIBS" + fi + ]) + if test "$am_cv_func_iconv" = yes; then + AC_CACHE_CHECK([for working iconv], [am_cv_func_iconv_works], [ + dnl This tests against bugs in AIX 5.1 and HP-UX 11.11. + am_save_LIBS="$LIBS" + if test $am_cv_lib_iconv = yes; then + LIBS="$LIBS $LIBICONV" + fi + AC_TRY_RUN([ +#include +#include +int main () +{ + /* Test against AIX 5.1 bug: Failures are not distinguishable from successful + returns. */ + { + iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8"); + if (cd_utf8_to_88591 != (iconv_t)(-1)) + { + static const char input[] = "\342\202\254"; /* EURO SIGN */ + char buf[10]; + const char *inptr = input; + size_t inbytesleft = strlen (input); + char *outptr = buf; + size_t outbytesleft = sizeof (buf); + size_t res = iconv (cd_utf8_to_88591, + (char **) &inptr, &inbytesleft, + &outptr, &outbytesleft); + if (res == 0) + return 1; + } + } +#if 0 /* This bug could be worked around by the caller. */ + /* Test against HP-UX 11.11 bug: Positive return value instead of 0. */ + { + iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591"); + if (cd_88591_to_utf8 != (iconv_t)(-1)) + { + static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; + char buf[50]; + const char *inptr = input; + size_t inbytesleft = strlen (input); + char *outptr = buf; + size_t outbytesleft = sizeof (buf); + size_t res = iconv (cd_88591_to_utf8, + (char **) &inptr, &inbytesleft, + &outptr, &outbytesleft); + if ((int)res > 0) + return 1; + } + } +#endif + /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is + provided. */ + if (/* Try standardized names. */ + iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1) + /* Try IRIX, OSF/1 names. */ + && iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1) + /* Try AIX names. */ + && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1) + /* Try HP-UX names. */ + && iconv_open ("utf8", "eucJP") == (iconv_t)(-1)) + return 1; + return 0; +}], [am_cv_func_iconv_works=yes], [am_cv_func_iconv_works=no], + [case "$host_os" in + aix* | hpux*) am_cv_func_iconv_works="guessing no" ;; + *) am_cv_func_iconv_works="guessing yes" ;; + esac]) + LIBS="$am_save_LIBS" + ]) + case "$am_cv_func_iconv_works" in + *no) am_func_iconv=no am_cv_lib_iconv=no ;; + *) am_func_iconv=yes ;; + esac + else + am_func_iconv=no am_cv_lib_iconv=no + fi + if test "$am_func_iconv" = yes; then + AC_DEFINE([HAVE_ICONV], [1], + [Define if you have the iconv() function and it works.]) + fi + if test "$am_cv_lib_iconv" = yes; then + AC_MSG_CHECKING([how to link with libiconv]) + AC_MSG_RESULT([$LIBICONV]) + else + dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV + dnl either. + CPPFLAGS="$am_save_CPPFLAGS" + LIBICONV= + LTLIBICONV= + fi + AC_SUBST([LIBICONV]) + AC_SUBST([LTLIBICONV]) +]) + +AC_DEFUN([AM_ICONV], +[ + AM_ICONV_LINK + if test "$am_cv_func_iconv" = yes; then + AC_MSG_CHECKING([for iconv declaration]) + AC_CACHE_VAL([am_cv_proto_iconv], [ + AC_TRY_COMPILE([ +#include +#include +extern +#ifdef __cplusplus +"C" +#endif +#if defined(__STDC__) || defined(__cplusplus) +size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); +#else +size_t iconv(); +#endif +], [], [am_cv_proto_iconv_arg1=""], [am_cv_proto_iconv_arg1="const"]) + am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"]) + am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` + AC_MSG_RESULT([${ac_t:- + }$am_cv_proto_iconv]) + AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1], + [Define as const if the declaration of iconv() needs const.]) + fi +]) diff --git a/m4/lib-ld.m4 b/m4/lib-ld.m4 new file mode 100644 index 0000000..11d0ce7 --- /dev/null +++ b/m4/lib-ld.m4 @@ -0,0 +1,110 @@ +# lib-ld.m4 serial 2 (gettext-0.12) +dnl Copyright (C) 1996-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl Subroutines of libtool.m4, +dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision +dnl with libtool.m4. + +dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no. +AC_DEFUN([AC_LIB_PROG_LD_GNU], +[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], acl_cv_prog_gnu_ld, +[# I'd rather use --version here, but apparently some GNU ld's only accept -v. +if $LD -v 2>&1 &5; then + acl_cv_prog_gnu_ld=yes +else + acl_cv_prog_gnu_ld=no +fi]) +with_gnu_ld=$acl_cv_prog_gnu_ld +]) + +dnl From libtool-1.4. Sets the variable LD. +AC_DEFUN([AC_LIB_PROG_LD], +[AC_ARG_WITH(gnu-ld, +[ --with-gnu-ld assume the C compiler uses GNU ld [default=no]], +test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no) +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +# Prepare PATH_SEPARATOR. +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + AC_MSG_CHECKING([for ld used by GCC]) + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [[\\/]* | [A-Za-z]:[\\/]*)] + [re_direlt='/[^/][^/]*/\.\./'] + # Canonicalize the path of ld + ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + AC_MSG_CHECKING([for GNU ld]) +else + AC_MSG_CHECKING([for non-GNU ld]) +fi +AC_CACHE_VAL(acl_cv_path_LD, +[if test -z "$LD"; then + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + acl_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some GNU ld's only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then + test "$with_gnu_ld" != no && break + else + test "$with_gnu_ld" != yes && break + fi + fi + done + IFS="$ac_save_ifs" +else + acl_cv_path_LD="$LD" # Let the user override the test with a path. +fi]) +LD="$acl_cv_path_LD" +if test -n "$LD"; then + AC_MSG_RESULT($LD) +else + AC_MSG_RESULT(no) +fi +test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH]) +AC_LIB_PROG_LD_GNU +]) diff --git a/m4/lib-link.m4 b/m4/lib-link.m4 new file mode 100644 index 0000000..eeb200d --- /dev/null +++ b/m4/lib-link.m4 @@ -0,0 +1,551 @@ +# lib-link.m4 serial 4 (gettext-0.12) +dnl Copyright (C) 2001-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Bruno Haible. + +dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and +dnl the libraries corresponding to explicit and implicit dependencies. +dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and +dnl augments the CPPFLAGS variable. +AC_DEFUN([AC_LIB_LINKFLAGS], +[ + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + AC_REQUIRE([AC_LIB_RPATH]) + define([Name],[translit([$1],[./-], [___])]) + define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [ + AC_LIB_LINKFLAGS_BODY([$1], [$2]) + ac_cv_lib[]Name[]_libs="$LIB[]NAME" + ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME" + ac_cv_lib[]Name[]_cppflags="$INC[]NAME" + ]) + LIB[]NAME="$ac_cv_lib[]Name[]_libs" + LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs" + INC[]NAME="$ac_cv_lib[]Name[]_cppflags" + AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) + AC_SUBST([LIB]NAME) + AC_SUBST([LTLIB]NAME) + dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the + dnl results of this search when this library appears as a dependency. + HAVE_LIB[]NAME=yes + undefine([Name]) + undefine([NAME]) +]) + +dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode) +dnl searches for libname and the libraries corresponding to explicit and +dnl implicit dependencies, together with the specified include files and +dnl the ability to compile and link the specified testcode. If found, it +dnl sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} and +dnl LTLIB${NAME} variables and augments the CPPFLAGS variable, and +dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs +dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty. +AC_DEFUN([AC_LIB_HAVE_LINKFLAGS], +[ + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + AC_REQUIRE([AC_LIB_RPATH]) + define([Name],[translit([$1],[./-], [___])]) + define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + + dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME + dnl accordingly. + AC_LIB_LINKFLAGS_BODY([$1], [$2]) + + dnl Add $INC[]NAME to CPPFLAGS before performing the following checks, + dnl because if the user has installed lib[]Name and not disabled its use + dnl via --without-lib[]Name-prefix, he wants to use it. + ac_save_CPPFLAGS="$CPPFLAGS" + AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) + + AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [ + ac_save_LIBS="$LIBS" + LIBS="$LIBS $LIB[]NAME" + AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name=no]) + LIBS="$ac_save_LIBS" + ]) + if test "$ac_cv_lib[]Name" = yes; then + HAVE_LIB[]NAME=yes + AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the $1 library.]) + AC_MSG_CHECKING([how to link with lib[]$1]) + AC_MSG_RESULT([$LIB[]NAME]) + else + HAVE_LIB[]NAME=no + dnl If $LIB[]NAME didn't lead to a usable library, we don't need + dnl $INC[]NAME either. + CPPFLAGS="$ac_save_CPPFLAGS" + LIB[]NAME= + LTLIB[]NAME= + fi + AC_SUBST([HAVE_LIB]NAME) + AC_SUBST([LIB]NAME) + AC_SUBST([LTLIB]NAME) + undefine([Name]) + undefine([NAME]) +]) + +dnl Determine the platform dependent parameters needed to use rpath: +dnl libext, shlibext, hardcode_libdir_flag_spec, hardcode_libdir_separator, +dnl hardcode_direct, hardcode_minus_L. +AC_DEFUN([AC_LIB_RPATH], +[ + AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS + AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld + AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host + AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir + AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [ + CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ + ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh + . ./conftest.sh + rm -f ./conftest.sh + acl_cv_rpath=done + ]) + wl="$acl_cv_wl" + libext="$acl_cv_libext" + shlibext="$acl_cv_shlibext" + hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" + hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" + hardcode_direct="$acl_cv_hardcode_direct" + hardcode_minus_L="$acl_cv_hardcode_minus_L" + dnl Determine whether the user wants rpath handling at all. + AC_ARG_ENABLE(rpath, + [ --disable-rpath do not hardcode runtime library paths], + :, enable_rpath=yes) +]) + +dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and +dnl the libraries corresponding to explicit and implicit dependencies. +dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables. +AC_DEFUN([AC_LIB_LINKFLAGS_BODY], +[ + define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + dnl By default, look in $includedir and $libdir. + use_additional=yes + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + AC_LIB_ARG_WITH([lib$1-prefix], +[ --with-lib$1-prefix[=DIR] search for lib$1 in DIR/include and DIR/lib + --without-lib$1-prefix don't search for lib$1 in includedir and libdir], +[ + if test "X$withval" = "Xno"; then + use_additional=no + else + if test "X$withval" = "X"; then + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + else + additional_includedir="$withval/include" + additional_libdir="$withval/lib" + fi + fi +]) + dnl Search the library and its dependencies in $additional_libdir and + dnl $LDFLAGS. Using breadth-first-seach. + LIB[]NAME= + LTLIB[]NAME= + INC[]NAME= + rpathdirs= + ltrpathdirs= + names_already_handled= + names_next_round='$1 $2' + while test -n "$names_next_round"; do + names_this_round="$names_next_round" + names_next_round= + for name in $names_this_round; do + already_handled= + for n in $names_already_handled; do + if test "$n" = "$name"; then + already_handled=yes + break + fi + done + if test -z "$already_handled"; then + names_already_handled="$names_already_handled $name" + dnl See if it was already located by an earlier AC_LIB_LINKFLAGS + dnl or AC_LIB_HAVE_LINKFLAGS call. + uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'` + eval value=\"\$HAVE_LIB$uppername\" + if test -n "$value"; then + if test "$value" = yes; then + eval value=\"\$LIB$uppername\" + test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value" + eval value=\"\$LTLIB$uppername\" + test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value" + else + dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined + dnl that this library doesn't exist. So just drop it. + : + fi + else + dnl Search the library lib$name in $additional_libdir and $LDFLAGS + dnl and the already constructed $LIBNAME/$LTLIBNAME. + found_dir= + found_la= + found_so= + found_a= + if test $use_additional = yes; then + if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then + found_dir="$additional_libdir" + found_so="$additional_libdir/lib$name.$shlibext" + if test -f "$additional_libdir/lib$name.la"; then + found_la="$additional_libdir/lib$name.la" + fi + else + if test -f "$additional_libdir/lib$name.$libext"; then + found_dir="$additional_libdir" + found_a="$additional_libdir/lib$name.$libext" + if test -f "$additional_libdir/lib$name.la"; then + found_la="$additional_libdir/lib$name.la" + fi + fi + fi + fi + if test "X$found_dir" = "X"; then + for x in $LDFLAGS $LTLIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + case "$x" in + -L*) + dir=`echo "X$x" | sed -e 's/^X-L//'` + if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then + found_dir="$dir" + found_so="$dir/lib$name.$shlibext" + if test -f "$dir/lib$name.la"; then + found_la="$dir/lib$name.la" + fi + else + if test -f "$dir/lib$name.$libext"; then + found_dir="$dir" + found_a="$dir/lib$name.$libext" + if test -f "$dir/lib$name.la"; then + found_la="$dir/lib$name.la" + fi + fi + fi + ;; + esac + if test "X$found_dir" != "X"; then + break + fi + done + fi + if test "X$found_dir" != "X"; then + dnl Found the library. + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name" + if test "X$found_so" != "X"; then + dnl Linking with a shared library. We attempt to hardcode its + dnl directory into the executable's runpath, unless it's the + dnl standard /usr/lib. + if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then + dnl No hardcoding is needed. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + else + dnl Use an explicit option to hardcode DIR into the resulting + dnl binary. + dnl Potentially add DIR to ltrpathdirs. + dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $found_dir" + fi + dnl The hardcoding into $LIBNAME is system dependent. + if test "$hardcode_direct" = yes; then + dnl Using DIR/libNAME.so during linking hardcodes DIR into the + dnl resulting binary. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + else + if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then + dnl Use an explicit option to hardcode DIR into the resulting + dnl binary. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + dnl Potentially add DIR to rpathdirs. + dnl The rpathdirs will be appended to $LIBNAME at the end. + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $found_dir" + fi + else + dnl Rely on "-L$found_dir". + dnl But don't add it if it's already contained in the LDFLAGS + dnl or the already constructed $LIBNAME + haveit= + for x in $LDFLAGS $LIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir" + fi + if test "$hardcode_minus_L" != no; then + dnl FIXME: Not sure whether we should use + dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" + dnl here. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + else + dnl We cannot use $hardcode_runpath_var and LD_RUN_PATH + dnl here, because this doesn't fit in flags passed to the + dnl compiler. So give up. No hardcoding. This affects only + dnl very old systems. + dnl FIXME: Not sure whether we should use + dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" + dnl here. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" + fi + fi + fi + fi + else + if test "X$found_a" != "X"; then + dnl Linking with a static library. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a" + else + dnl We shouldn't come here, but anyway it's good to have a + dnl fallback. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name" + fi + fi + dnl Assume the include files are nearby. + additional_includedir= + case "$found_dir" in + */lib | */lib/) + basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'` + additional_includedir="$basedir/include" + ;; + esac + if test "X$additional_includedir" != "X"; then + dnl Potentially add $additional_includedir to $INCNAME. + dnl But don't add it + dnl 1. if it's the standard /usr/include, + dnl 2. if it's /usr/local/include and we are using GCC on Linux, + dnl 3. if it's already present in $CPPFLAGS or the already + dnl constructed $INCNAME, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_includedir" != "X/usr/include"; then + haveit= + if test "X$additional_includedir" = "X/usr/local/include"; then + if test -n "$GCC"; then + case $host_os in + linux*) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + for x in $CPPFLAGS $INC[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-I$additional_includedir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_includedir"; then + dnl Really add $additional_includedir to $INCNAME. + INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir" + fi + fi + fi + fi + fi + dnl Look for dependencies. + if test -n "$found_la"; then + dnl Read the .la file. It defines the variables + dnl dlname, library_names, old_library, dependency_libs, current, + dnl age, revision, installed, dlopen, dlpreopen, libdir. + save_libdir="$libdir" + case "$found_la" in + */* | *\\*) . "$found_la" ;; + *) . "./$found_la" ;; + esac + libdir="$save_libdir" + dnl We use only dependency_libs. + for dep in $dependency_libs; do + case "$dep" in + -L*) + additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` + dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME. + dnl But don't add it + dnl 1. if it's the standard /usr/lib, + dnl 2. if it's /usr/local/lib and we are using GCC on Linux, + dnl 3. if it's already present in $LDFLAGS or the already + dnl constructed $LIBNAME, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_libdir" != "X/usr/lib"; then + haveit= + if test "X$additional_libdir" = "X/usr/local/lib"; then + if test -n "$GCC"; then + case $host_os in + linux*) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + haveit= + for x in $LDFLAGS $LIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + dnl Really add $additional_libdir to $LIBNAME. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir" + fi + fi + haveit= + for x in $LDFLAGS $LTLIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + dnl Really add $additional_libdir to $LTLIBNAME. + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir" + fi + fi + fi + fi + ;; + -R*) + dir=`echo "X$dep" | sed -e 's/^X-R//'` + if test "$enable_rpath" != no; then + dnl Potentially add DIR to rpathdirs. + dnl The rpathdirs will be appended to $LIBNAME at the end. + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $dir" + fi + dnl Potentially add DIR to ltrpathdirs. + dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $dir" + fi + fi + ;; + -l*) + dnl Handle this in the next round. + names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` + ;; + *.la) + dnl Handle this in the next round. Throw away the .la's + dnl directory; it is already contained in a preceding -L + dnl option. + names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` + ;; + *) + dnl Most likely an immediate library name. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep" + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep" + ;; + esac + done + fi + else + dnl Didn't find the library; assume it is in the system directories + dnl known to the linker and runtime loader. (All the system + dnl directories known to the linker should also be known to the + dnl runtime loader, otherwise the system is severely misconfigured.) + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name" + fi + fi + fi + done + done + if test "X$rpathdirs" != "X"; then + if test -n "$hardcode_libdir_separator"; then + dnl Weird platform: only the last -rpath option counts, the user must + dnl pass all path elements in one option. We can arrange that for a + dnl single library, but not when more than one $LIBNAMEs are used. + alldirs= + for found_dir in $rpathdirs; do + alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir" + done + dnl Note: hardcode_libdir_flag_spec uses $libdir and $wl. + acl_save_libdir="$libdir" + libdir="$alldirs" + eval flag=\"$hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" + else + dnl The -rpath options are cumulative. + for found_dir in $rpathdirs; do + acl_save_libdir="$libdir" + libdir="$found_dir" + eval flag=\"$hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" + done + fi + fi + if test "X$ltrpathdirs" != "X"; then + dnl When using libtool, the option that works for both libraries and + dnl executables is -R. The -R options are cumulative. + for found_dir in $ltrpathdirs; do + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir" + done + fi +]) + +dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR, +dnl unless already present in VAR. +dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes +dnl contains two or three consecutive elements that belong together. +AC_DEFUN([AC_LIB_APPENDTOVAR], +[ + for element in [$2]; do + haveit= + for x in $[$1]; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X$element"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + [$1]="${[$1]}${[$1]:+ }$element" + fi + done +]) diff --git a/m4/lib-prefix.m4 b/m4/lib-prefix.m4 new file mode 100644 index 0000000..3bdc0fc --- /dev/null +++ b/m4/lib-prefix.m4 @@ -0,0 +1,221 @@ +# lib-prefix.m4 serial 6 (gettext-0.18) +dnl Copyright (C) 2001-2005, 2008 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and +dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't +dnl require excessive bracketing. +ifdef([AC_HELP_STRING], +[AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])], +[AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])]) + +dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed +dnl to access previously installed libraries. The basic assumption is that +dnl a user will want packages to use other packages he previously installed +dnl with the same --prefix option. +dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate +dnl libraries, but is otherwise very convenient. +AC_DEFUN([AC_LIB_PREFIX], +[ + AC_BEFORE([$0], [AC_LIB_LINKFLAGS]) + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + dnl By default, look in $includedir and $libdir. + use_additional=yes + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + AC_LIB_ARG_WITH([lib-prefix], +[ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib + --without-lib-prefix don't search for libraries in includedir and libdir], +[ + if test "X$withval" = "Xno"; then + use_additional=no + else + if test "X$withval" = "X"; then + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + else + additional_includedir="$withval/include" + additional_libdir="$withval/$acl_libdirstem" + fi + fi +]) + if test $use_additional = yes; then + dnl Potentially add $additional_includedir to $CPPFLAGS. + dnl But don't add it + dnl 1. if it's the standard /usr/include, + dnl 2. if it's already present in $CPPFLAGS, + dnl 3. if it's /usr/local/include and we are using GCC on Linux, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_includedir" != "X/usr/include"; then + haveit= + for x in $CPPFLAGS; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-I$additional_includedir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test "X$additional_includedir" = "X/usr/local/include"; then + if test -n "$GCC"; then + case $host_os in + linux* | gnu* | k*bsd*-gnu) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + if test -d "$additional_includedir"; then + dnl Really add $additional_includedir to $CPPFLAGS. + CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir" + fi + fi + fi + fi + dnl Potentially add $additional_libdir to $LDFLAGS. + dnl But don't add it + dnl 1. if it's the standard /usr/lib, + dnl 2. if it's already present in $LDFLAGS, + dnl 3. if it's /usr/local/lib and we are using GCC on Linux, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then + haveit= + for x in $LDFLAGS; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then + if test -n "$GCC"; then + case $host_os in + linux*) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + dnl Really add $additional_libdir to $LDFLAGS. + LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir" + fi + fi + fi + fi + fi +]) + +dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix, +dnl acl_final_exec_prefix, containing the values to which $prefix and +dnl $exec_prefix will expand at the end of the configure script. +AC_DEFUN([AC_LIB_PREPARE_PREFIX], +[ + dnl Unfortunately, prefix and exec_prefix get only finally determined + dnl at the end of configure. + if test "X$prefix" = "XNONE"; then + acl_final_prefix="$ac_default_prefix" + else + acl_final_prefix="$prefix" + fi + if test "X$exec_prefix" = "XNONE"; then + acl_final_exec_prefix='${prefix}' + else + acl_final_exec_prefix="$exec_prefix" + fi + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" + prefix="$acl_save_prefix" +]) + +dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the +dnl variables prefix and exec_prefix bound to the values they will have +dnl at the end of the configure script. +AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX], +[ + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + $1 + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" +]) + +dnl AC_LIB_PREPARE_MULTILIB creates +dnl - a variable acl_libdirstem, containing the basename of the libdir, either +dnl "lib" or "lib64" or "lib/64", +dnl - a variable acl_libdirstem2, as a secondary possible value for +dnl acl_libdirstem, either the same as acl_libdirstem or "lib/sparcv9" or +dnl "lib/amd64". +AC_DEFUN([AC_LIB_PREPARE_MULTILIB], +[ + dnl There is no formal standard regarding lib and lib64. + dnl On glibc systems, the current practice is that on a system supporting + dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under + dnl $prefix/lib64 and 32-bit libraries go under $prefix/lib. We determine + dnl the compiler's default mode by looking at the compiler's library search + dnl path. If at least one of its elements ends in /lib64 or points to a + dnl directory whose absolute pathname ends in /lib64, we assume a 64-bit ABI. + dnl Otherwise we use the default, namely "lib". + dnl On Solaris systems, the current practice is that on a system supporting + dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under + dnl $prefix/lib/64 (which is a symlink to either $prefix/lib/sparcv9 or + dnl $prefix/lib/amd64) and 32-bit libraries go under $prefix/lib. + AC_REQUIRE([AC_CANONICAL_HOST]) + acl_libdirstem=lib + acl_libdirstem2= + case "$host_os" in + solaris*) + dnl See Solaris 10 Software Developer Collection > Solaris 64-bit Developer's Guide > The Development Environment + dnl . + dnl "Portable Makefiles should refer to any library directories using the 64 symbolic link." + dnl But we want to recognize the sparcv9 or amd64 subdirectory also if the + dnl symlink is missing, so we set acl_libdirstem2 too. + AC_CACHE_CHECK([for 64-bit host], [gl_cv_solaris_64bit], + [AC_EGREP_CPP([sixtyfour bits], [ +#ifdef _LP64 +sixtyfour bits +#endif + ], [gl_cv_solaris_64bit=yes], [gl_cv_solaris_64bit=no]) + ]) + if test $gl_cv_solaris_64bit = yes; then + acl_libdirstem=lib/64 + case "$host_cpu" in + sparc*) acl_libdirstem2=lib/sparcv9 ;; + i*86 | x86_64) acl_libdirstem2=lib/amd64 ;; + esac + fi + ;; + *) + searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` + if test -n "$searchpath"; then + acl_save_IFS="${IFS= }"; IFS=":" + for searchdir in $searchpath; do + if test -d "$searchdir"; then + case "$searchdir" in + */lib64/ | */lib64 ) acl_libdirstem=lib64 ;; + *) searchdir=`cd "$searchdir" && pwd` + case "$searchdir" in + */lib64 ) acl_libdirstem=lib64 ;; + esac ;; + esac + fi + done + IFS="$acl_save_IFS" + fi + ;; + esac + test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem" +]) diff --git a/regression/regression-tests.bash b/regression/regression-tests.bash index 7db5f7d..ce1df8c 100644 --- a/regression/regression-tests.bash +++ b/regression/regression-tests.bash @@ -1,106 +1,106 @@ #!/bin/bash function dodii() { n="$1" fn="$2" rm -rf output$n mkdir output$n $val ../src/pst2dii -f /usr/share/fonts/bitstream-vera/VeraMono.ttf -B "bates-" -o output$n -O mydii$n -d dumper $fn >$fn.dii.err 2>&1 ../src/readpstlog -f I dumper >$fn.log rm -f dumper } function doldif() { n="$1" fn="$2" echo $fn ba=$(basename "$fn" .pst) rm -rf output$n mkdir output$n #$val ../src/pst2ldif -d dumper -b 'o=ams-cc.com, c=US' -c 'newPerson' -o $fn >$ba.ldif.err 2>&1 $val ../src/pst2ldif -d dumper -b 'o=ams-cc.com, c=US' -c 'inetOrgPerson' $fn >$ba.ldif.err 2>&1 ../src/readpstlog -f I dumper >$ba.ldif.log rm -f dumper } function dopst() { n="$1" fn="$2" echo $fn ba=$(basename "$fn" .pst) rm -rf output$n mkdir output$n # ../src/readpst -cv -o output$n $fn >$ba.err 2>&1 # readpst -cv -o output$n -d dumper $fn >$ba.err 2>&1 $val ../src/readpst -cv -o output$n -d dumper $fn >$ba.err 2>&1 ../src/readpstlog -f I dumper >$ba.log #../src/getidblock -d -p $fn 0 >$ba.fulldump #../src/readpstlog -f I getidblock.log >$ba.fulldump.log rm -f dumper } val="valgrind --leak-check=full" -val='' +#val='' pushd .. make || exit popd if [ "$1" == "dii" ]; then dodii 1 ams.pst dodii 2 sample_64.pst dodii 3 test.pst dodii 4 big_mail.pst elif [ "$1" == "ldif" ]; then doldif 1 ams.pst #doldif 2 sample_64.pst #doldif 3 test.pst #doldif 4 big_mail.pst #doldif 5 mbmg.archive.pst #doldif 6 Single2003-read.pst #doldif 7 Single2003-unread.pst #doldif 8 ol2k3high.pst #doldif 9 ol97high.pst #doldif 10 returned_message.pst #doldif 11 flow.pst #doldif 12 test-html.pst #doldif 13 test-text.pst #doldif 14 joe.romanowski.pst #doldif 15 hourig1.pst ##doldif 16 hourig2.pst ##doldif 17 hourig3.pst #doldif 18 test-mac.pst - doldif 19 harris.pst + #doldif 19 harris.pst else dopst 1 ams.pst dopst 2 sample_64.pst dopst 3 test.pst dopst 4 big_mail.pst dopst 5 mbmg.archive.pst dopst 6 Single2003-read.pst dopst 7 Single2003-unread.pst dopst 8 ol2k3high.pst dopst 9 ol97high.pst dopst 10 returned_message.pst dopst 11 flow.pst dopst 12 test-html.pst dopst 13 test-text.pst dopst 14 joe.romanowski.pst dopst 15 hourig1.pst #dopst 16 hourig2.pst #dopst 17 hourig3.pst dopst 18 test-mac.pst dopst 19 harris.pst fi grep 'lost:' *err | grep -v 'lost: 0 ' diff --git a/src/Makefile.am b/src/Makefile.am index 2cbf08b..34316ea 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,104 +1,102 @@ if PLATFORM_WIN32 - ICONVLIB = -liconv NO_UNDEFINED = -no-undefined else - ICONVLIB = NO_UNDEFINED = endif if STATIC_TOOLS PSTLIB = @PST_OBJDIR@/libpst.a else PSTLIB = libpst.la endif common_header = common.h \ define.h \ libpst.h \ libstrfunc.h \ lzfu.h \ timeconv.h \ vbuf.h common_source = debug.c \ libpst.c \ libstrfunc.c \ lzfu.c \ timeconv.c \ vbuf.c if NEED_XGETOPT common_source += XGetopt.c common_header += XGetopt.h endif noinst_PROGRAMS = deltasearch dumpblocks getidblock bin_PROGRAMS = lspst readpst readpstlog pst2ldif if BUILD_DII bin_PROGRAMS += pst2dii endif lspst_SOURCES = lspst.c $(common_header) readpst_SOURCES = readpst.c $(common_header) readpstlog_SOURCES = readpstlog.c $(common_header) pst2ldif_SOURCES = pst2ldif.cpp $(common_header) pst2dii_SOURCES = pst2dii.cpp $(common_header) deltasearch_SOURCES = deltasearch.cpp $(common_header) dumpblocks_SOURCES = dumpblocks.c $(common_header) getidblock_SOURCES = getidblock.c $(common_header) lspst_CFLAGS = $(AM_CFLAGS) readpst_CFLAGS = $(AM_CFLAGS) readpstlog_CFLAGS = $(AM_CFLAGS) pst2ldif_CFLAGS = $(AM_CFLAGS) pst2dii_CFLAGS = $(AM_CFLAGS) deltasearch_CFLAGS = $(AM_CFLAGS) dumpblocks_CFLAGS = $(AM_CFLAGS) getidblock_CFLAGS = $(AM_CFLAGS) lspst_DEPENDENCIES = libpst.la readpst_DEPENDENCIES = libpst.la readpstlog_DEPENDENCIES = libpst.la pst2ldif_DEPENDENCIES = libpst.la pst2dii_DEPENDENCIES = libpst.la deltasearch_DEPENDENCIES = libpst.la dumpblocks_DEPENDENCIES = libpst.la getidblock_DEPENDENCIES = libpst.la if STATIC_TOOLS noinst_LTLIBRARIES = libpst.la else lib_LTLIBRARIES = libpst.la libpstincludedir = $(includedir)/libpst libpstinclude_HEADERS = \ common.h \ libpst.h \ libstrfunc.h\ timeconv.h \ vbuf.h libpst_la_LDFLAGS = $(NO_UNDEFINED) -version-info 1:2:0 endif libpst_la_SOURCES = $(common_source) $(common_header) -libpst_la_LIBADD = $(ICONVLIB) +libpst_la_LIBADD = $(LTLIBICONV) EXTRA_DIST = testdebug.c if !NEED_XGETOPT EXTRA_DIST += XGetopt.c XGetopt.h endif # set the include path found by configure INCLUDES= -I$(srcdir)/.. $(all_includes) # the library search path. -lspst_LDADD = $(all_libraries) $(PSTLIB) $(ICONVLIB) -readpst_LDADD = $(all_libraries) $(PSTLIB) $(ICONVLIB) $(REGEXLIB) -readpstlog_LDADD = $(all_libraries) $(PSTLIB) $(ICONVLIB) -pst2ldif_LDADD = $(all_libraries) $(PSTLIB) $(ICONVLIB) -pst2dii_LDADD = $(all_libraries) $(PSTLIB) $(ICONVLIB) -lgd -dumpblocks_LDADD = $(all_libraries) $(PSTLIB) $(ICONVLIB) -getidblock_LDADD = $(all_libraries) $(PSTLIB) $(ICONVLIB) -deltasearch_LDADD = $(all_libraries) $(PSTLIB) $(ICONVLIB) +lspst_LDADD = $(all_libraries) $(PSTLIB) $(LTLIBICONV) +readpst_LDADD = $(all_libraries) $(PSTLIB) $(LTLIBICONV) $(REGEXLIB) +readpstlog_LDADD = $(all_libraries) $(PSTLIB) $(LTLIBICONV) +pst2ldif_LDADD = $(all_libraries) $(PSTLIB) $(LTLIBICONV) +pst2dii_LDADD = $(all_libraries) $(PSTLIB) $(LTLIBICONV) -lgd +dumpblocks_LDADD = $(all_libraries) $(PSTLIB) $(LTLIBICONV) +getidblock_LDADD = $(all_libraries) $(PSTLIB) $(LTLIBICONV) +deltasearch_LDADD = $(all_libraries) $(PSTLIB) $(LTLIBICONV) diff --git a/src/define.h b/src/define.h index 29c51aa..671440d 100644 --- a/src/define.h +++ b/src/define.h @@ -1,372 +1,372 @@ /*** * define.h * Part of the LibPST project * Written by David Smith * dave.s@earthcorp.com */ #ifndef DEFINEH_H #define DEFINEH_H #include "libpst.h" #include "timeconv.h" #include "libstrfunc.h" #include "vbuf.h" #ifdef HAVE_CONFIG_H #include "config.h" #endif #define DEBUG_MODE_GEN #define DEBUGPRINT #define DEBUG_MODE_WARN #define DEBUG_MODE_READ #define DEBUG_MODE_EMAIL #define DEBUG_MODE_MAIN #define DEBUG_MODE_INDEX #define DEBUG_MODE_CODE #define DEBUG_MODE_INFO #define DEBUG_MODE_HEXDUMP #define DEBUG_MODE_FUNC //number of items to save in memory between writes #define DEBUG_MAX_ITEMS 0 #define DEBUG_FILE_NO 1 #define DEBUG_INDEX_NO 2 #define DEBUG_EMAIL_NO 3 #define DEBUG_WARN_NO 4 #define DEBUG_READ_NO 5 #define DEBUG_INFO_NO 6 #define DEBUG_MAIN_NO 7 #define DEBUG_DECRYPT_NO 8 #define DEBUG_FUNCENT_NO 9 #define DEBUG_FUNCRET_NO 10 #define DEBUG_HEXDUMP_NO 11 #ifdef HAVE_TIME_H #include #endif #ifdef HAVE_STRING_H #include #endif #ifdef HAVE_CTYPE_H #include #endif #ifdef HAVE_LIMITS_H #include #endif #ifdef HAVE_WCHAR_H #include #endif #ifdef HAVE_SIGNAL_H #include #endif #ifdef HAVE_ERRNO_H #include #endif -#ifdef HAVE_ICONV_H +#ifdef HAVE_ICONV #include #endif #ifdef HAVE_REGEX_H #include #endif #ifdef HAVE_GD_H #include #endif #define PERM_DIRS 0777 #ifdef _WIN32 #include #define D_MKDIR(x) mkdir(x) #define chdir _chdir #define strcasecmp _stricmp #define vsnprintf _vsnprintf #define snprintf _snprintf #ifdef _MSC_VER #define ftello _ftelli64 #define fseeko _fseeki64 #elif defined (__MINGW32__) #define ftello ftello64 #define fseeko fseeko64 #else #error Only MSC and mingw supported for Windows #endif #ifndef __MINGW32__ #define size_t __int64 #endif #ifndef UINT64_MAX #define UINT64_MAX ((uint64_t)0xffffffffffffffff) #endif #define PRIx64 "I64x" int __cdecl _fseeki64(FILE *, __int64, int); __int64 __cdecl _ftelli64(FILE *); #ifdef __MINGW32__ #include #else #include "XGetopt.h" #endif #else #ifdef HAVE_UNISTD_H #include #else #include "XGetopt.h" #endif #define D_MKDIR(x) mkdir(x, PERM_DIRS) #endif #ifdef HAVE_SYS_STAT_H #include #endif #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_DIRENT_H #include #endif void pst_debug(const char *fmt, ...); void pst_debug_hexdumper(FILE* out, char* buf, size_t size, int col, int delta); void pst_debug_hexprint(char *data, int size); void pst_debug_init(const char *fname); void pst_debug_msg_info (int line, const char *file, int type); void pst_debug_msg_text(const char* fmt, ...); void pst_debug_hexdump(char *x, size_t y, int cols, int delta); void pst_debug_func(const char *function); void pst_debug_func_ret(); void pst_debug_close(void); void pst_debug_write(); size_t pst_debug_fwrite(const void *ptr, size_t size, size_t nitems, FILE *stream); void * xmalloc(size_t size); #define MESSAGEPRINT(x,y) {pst_debug_msg_info(__LINE__,__FILE__,y);\ pst_debug_msg_text x;} #define LOGSTOP() {MESSAGESTOP();DEBUGSTOP();} #define DIE(x) {\ MESSAGEPRINT(x, 0);\ printf x;\ exit(EXIT_FAILURE);\ } #define WARN(x) {\ MESSAGEPRINT(x, 0);\ printf x;\ } #ifdef DEBUGPRINT #define DEBUG_PRINT(x) pst_debug x; #else #define DEBUG_PRINT(x) {} #endif #ifdef DEBUG_MODE_GEN #define DEBUG(x) {DEBUG_PRINT(x);} #else #define DEBUG(x) {} #endif #ifdef DEBUG_MODE_INDEX #define DEBUG_INDEX(x) MESSAGEPRINT(x, DEBUG_INDEX_NO); #else #define DEBUG_INDEX(x) {} #endif #ifdef DEBUG_MODE_EMAIL #define DEBUG_EMAIL(x) MESSAGEPRINT(x, DEBUG_EMAIL_NO); #define DEBUG_EMAIL_HEXPRINT(x,y) {pst_debug_msg_info(__LINE__, __FILE__, 11);\ pst_debug_hexdump((char*)x, y, 0x10, 0);} #else #define DEBUG_EMAIL(x) {} #define DEBUG_EMAIL_HEXPRINT(x,y) {} #endif #ifdef DEBUG_MODE_WARN #define DEBUG_WARN(x) MESSAGEPRINT(x, DEBUG_WARN_NO); #else #define DEBUG_WARN(x) {} #endif #ifdef DEBUG_MODE_READ #define DEBUG_READ(x) MESSAGEPRINT(x, DEBUG_READ_NO); #else #define DEBUG_READ(x) {} #endif #ifdef DEBUG_MODE_INFO #define DEBUG_INFO(x) MESSAGEPRINT(x, DEBUG_INFO_NO); #else #define DEBUG_INFO(x) {} #endif #ifdef DEBUG_MODE_MAIN #define DEBUG_MAIN(x) MESSAGEPRINT(x, DEBUG_MAIN_NO); #else #define DEBUG_MAIN(x) {} #endif #ifdef DEBUG_MODE_CODE #define DEBUG_CODE(x) {x} #else #define DEBUG_CODE(x) {} #endif #ifdef DEBUG_MODE_DECRYPT #define DEBUG_DECRYPT(x) MESSAGEPRINT(x, DEBUG_DECRYPT_NO); #else #define DEBUG_DECRYPT(x) {} #endif #ifdef DEBUG_MODE_HEXDUMP #define DEBUG_HEXDUMP(x, s)\ {pst_debug_msg_info(__LINE__, __FILE__, DEBUG_HEXDUMP_NO);\ pst_debug_hexdump((char*)x, s, 0x10, 0);} #define DEBUG_HEXDUMPC(x, s, c)\ {pst_debug_msg_info(__LINE__, __FILE__, DEBUG_HEXDUMP_NO);\ pst_debug_hexdump((char*)x, s, c, 0);} #else #define DEBUG_HEXDUMP(x, s) {} #define DEBUG_HEXDUMPC(x, s, c) {} #endif #define DEBUG_FILE(x) {pst_debug_msg_info(__LINE__, __FILE__, DEBUG_FILE_NO);\ pst_debug_msg_text x;} #ifdef DEBUG_MODE_FUNC # define DEBUG_ENT(x) \ { \ pst_debug_func(x); \ MESSAGEPRINT(("Entering function %s\n",x),DEBUG_FUNCENT_NO); \ } # define DEBUG_RET() \ { \ MESSAGEPRINT(("Leaving function\n"),DEBUG_FUNCRET_NO); \ pst_debug_func_ret(); \ } #else # define DEBUG_ENT(x) {} # define DEBUG_RET() {} #endif #define DEBUG_INIT(fname) {pst_debug_init(fname);} #define DEBUG_CLOSE() {pst_debug_close();} #define DEBUG_REGISTER_CLOSE() {if(atexit(pst_debug_close)!=0) fprintf(stderr, "Error registering atexit function\n");} #define RET_DERROR(res, ret_val, x)\ if (res) { DIE(x);} #define RET_ERROR(res, ret_val)\ if (res) {return ret_val;} #define DEBUG_VERSION 1 struct pst_debug_file_rec_m { unsigned short int funcname; unsigned short int filename; unsigned short int text; unsigned short int end; unsigned int line; unsigned int type; }; struct pst_debug_file_rec_l { unsigned int funcname; unsigned int filename; unsigned int text; unsigned int end; unsigned int line; unsigned int type; }; #if BYTE_ORDER == BIG_ENDIAN # define LE64_CPU(x) \ x = ((((x) & UINT64_C(0xff00000000000000)) >> 56) | \ (((x) & UINT64_C(0x00ff000000000000)) >> 40) | \ (((x) & UINT64_C(0x0000ff0000000000)) >> 24) | \ (((x) & UINT64_C(0x000000ff00000000)) >> 8 ) | \ (((x) & UINT64_C(0x00000000ff000000)) << 8 ) | \ (((x) & UINT64_C(0x0000000000ff0000)) << 24) | \ (((x) & UINT64_C(0x000000000000ff00)) << 40) | \ (((x) & UINT64_C(0x00000000000000ff)) << 56)); # define LE32_CPU(x) \ x = ((((x) & 0xff000000) >> 24) | \ (((x) & 0x00ff0000) >> 8 ) | \ (((x) & 0x0000ff00) << 8 ) | \ (((x) & 0x000000ff) << 24)); # define LE16_CPU(x) \ x = ((((x) & 0xff00) >> 8) | \ (((x) & 0x00ff) << 8)); #elif BYTE_ORDER == LITTLE_ENDIAN # define LE64_CPU(x) {} # define LE32_CPU(x) {} # define LE16_CPU(x) {} #else # error "Byte order not supported by this library" #endif // BYTE_ORDER #define PST_LE_GET_UINT64(p) \ (uint64_t)((((uint8_t const *)(p))[0] << 0) | \ (((uint8_t const *)(p))[1] << 8) | \ (((uint8_t const *)(p))[2] << 16) | \ (((uint8_t const *)(p))[3] << 24) | \ (((uint8_t const *)(p))[4] << 32) | \ (((uint8_t const *)(p))[5] << 40) | \ (((uint8_t const *)(p))[6] << 48) | \ (((uint8_t const *)(p))[7] << 56)) #define PST_LE_GET_INT64(p) \ (int64_t)((((uint8_t const *)(p))[0] << 0) | \ (((uint8_t const *)(p))[1] << 8) | \ (((uint8_t const *)(p))[2] << 16) | \ (((uint8_t const *)(p))[3] << 24) | \ (((uint8_t const *)(p))[4] << 32) | \ (((uint8_t const *)(p))[5] << 40) | \ (((uint8_t const *)(p))[6] << 48) | \ (((uint8_t const *)(p))[7] << 56)) #define PST_LE_GET_UINT32(p) \ (uint32_t)((((uint8_t const *)(p))[0] << 0) | \ (((uint8_t const *)(p))[1] << 8) | \ (((uint8_t const *)(p))[2] << 16) | \ (((uint8_t const *)(p))[3] << 24)) #define PST_LE_GET_INT32(p) \ (int32_t)((((uint8_t const *)(p))[0] << 0) | \ (((uint8_t const *)(p))[1] << 8) | \ (((uint8_t const *)(p))[2] << 16) | \ (((uint8_t const *)(p))[3] << 24)) #define PST_LE_GET_UINT16(p) \ (uint16_t)((((uint8_t const *)(p))[0] << 0) | \ (((uint8_t const *)(p))[1] << 8)) #define PST_LE_GET_INT16(p) \ (int16_t)((((uint8_t const *)(p))[0] << 0) | \ (((uint8_t const *)(p))[1] << 8)) #define PST_LE_GET_UINT8(p) (*(uint8_t const *)(p)) #define PST_LE_GET_INT8(p) (*(int8_t const *)(p)) #endif //DEFINEH_H diff --git a/src/libpst.c b/src/libpst.c index a74fa5c..29ad0d6 100644 --- a/src/libpst.c +++ b/src/libpst.c @@ -1,4191 +1,4199 @@ /*** * libpst.c * Part of the LibPST project * Written by David Smith * dave.s@earthcorp.com */ #include "define.h" // switch to maximal packing for our own internal structures // use the same code as in libpst.h #ifdef _MSC_VER #pragma pack(push, 1) #endif #if defined(__GNUC__) || defined (__SUNPRO_C) || defined(__SUNPRO_CC) #pragma pack(1) #endif #define ASSERT(x) { if(!(x)) raise( SIGSEGV ); } #define INDEX_TYPE32 0x0E #define INDEX_TYPE32A 0x0F // unknown, but assumed to be similar for now #define INDEX_TYPE64 0x17 #define INDEX_TYPE64A 0x15 // http://sourceforge.net/projects/libpff/ #define INDEX_TYPE_OFFSET (int64_t)0x0A #define FILE_SIZE_POINTER32 (int64_t)0xA8 #define INDEX_POINTER32 (int64_t)0xC4 #define INDEX_BACK32 (int64_t)0xC0 #define SECOND_POINTER32 (int64_t)0xBC #define SECOND_BACK32 (int64_t)0xB8 #define ENC_TYPE32 (int64_t)0x1CD #define FILE_SIZE_POINTER64 (int64_t)0xB8 #define INDEX_POINTER64 (int64_t)0xF0 #define INDEX_BACK64 (int64_t)0xE8 #define SECOND_POINTER64 (int64_t)0xE0 #define SECOND_BACK64 (int64_t)0xD8 #define ENC_TYPE64 (int64_t)0x201 #define FILE_SIZE_POINTER ((pf->do_read64) ? FILE_SIZE_POINTER64 : FILE_SIZE_POINTER32) #define INDEX_POINTER ((pf->do_read64) ? INDEX_POINTER64 : INDEX_POINTER32) #define INDEX_BACK ((pf->do_read64) ? INDEX_BACK64 : INDEX_BACK32) #define SECOND_POINTER ((pf->do_read64) ? SECOND_POINTER64 : SECOND_POINTER32) #define SECOND_BACK ((pf->do_read64) ? SECOND_BACK64 : SECOND_BACK32) #define ENC_TYPE ((pf->do_read64) ? ENC_TYPE64 : ENC_TYPE32) #define PST_SIGNATURE 0x4E444221 struct pst_table_ptr_struct32{ uint32_t start; uint32_t u1; uint32_t offset; }; struct pst_table_ptr_structn{ uint64_t start; uint64_t u1; uint64_t offset; }; typedef struct pst_block_header { uint16_t type; uint16_t count; } pst_block_header; typedef struct pst_id2_assoc32 { uint32_t id2; uint32_t id; uint32_t child_id; } pst_id2_assoc32; typedef struct pst_id2_assoc { uint32_t id2; // only 32 bit here uint16_t unknown1; uint16_t unknown2; uint64_t id; uint64_t child_id; } pst_id2_assoc; typedef struct pst_table3_rec32 { uint32_t id; } pst_table3_rec32; //for type 3 (0x0101) blocks typedef struct pst_table3_rec { uint64_t id; } pst_table3_rec; //for type 3 (0x0101) blocks typedef struct pst_block_hdr { uint16_t index_offset; uint16_t type; uint32_t offset; } pst_block_hdr; /** for "compressible" encryption, just a simple substitution cipher, * plaintext = comp_enc[ciphertext]; * for "strong" encryption, this is the first rotor of an Enigma 3 rotor cipher. */ static unsigned char comp_enc [] = { 0x47, 0xf1, 0xb4, 0xe6, 0x0b, 0x6a, 0x72, 0x48, 0x85, 0x4e, 0x9e, 0xeb, 0xe2, 0xf8, 0x94, 0x53, 0xe0, 0xbb, 0xa0, 0x02, 0xe8, 0x5a, 0x09, 0xab, 0xdb, 0xe3, 0xba, 0xc6, 0x7c, 0xc3, 0x10, 0xdd, 0x39, 0x05, 0x96, 0x30, 0xf5, 0x37, 0x60, 0x82, 0x8c, 0xc9, 0x13, 0x4a, 0x6b, 0x1d, 0xf3, 0xfb, 0x8f, 0x26, 0x97, 0xca, 0x91, 0x17, 0x01, 0xc4, 0x32, 0x2d, 0x6e, 0x31, 0x95, 0xff, 0xd9, 0x23, 0xd1, 0x00, 0x5e, 0x79, 0xdc, 0x44, 0x3b, 0x1a, 0x28, 0xc5, 0x61, 0x57, 0x20, 0x90, 0x3d, 0x83, 0xb9, 0x43, 0xbe, 0x67, 0xd2, 0x46, 0x42, 0x76, 0xc0, 0x6d, 0x5b, 0x7e, 0xb2, 0x0f, 0x16, 0x29, 0x3c, 0xa9, 0x03, 0x54, 0x0d, 0xda, 0x5d, 0xdf, 0xf6, 0xb7, 0xc7, 0x62, 0xcd, 0x8d, 0x06, 0xd3, 0x69, 0x5c, 0x86, 0xd6, 0x14, 0xf7, 0xa5, 0x66, 0x75, 0xac, 0xb1, 0xe9, 0x45, 0x21, 0x70, 0x0c, 0x87, 0x9f, 0x74, 0xa4, 0x22, 0x4c, 0x6f, 0xbf, 0x1f, 0x56, 0xaa, 0x2e, 0xb3, 0x78, 0x33, 0x50, 0xb0, 0xa3, 0x92, 0xbc, 0xcf, 0x19, 0x1c, 0xa7, 0x63, 0xcb, 0x1e, 0x4d, 0x3e, 0x4b, 0x1b, 0x9b, 0x4f, 0xe7, 0xf0, 0xee, 0xad, 0x3a, 0xb5, 0x59, 0x04, 0xea, 0x40, 0x55, 0x25, 0x51, 0xe5, 0x7a, 0x89, 0x38, 0x68, 0x52, 0x7b, 0xfc, 0x27, 0xae, 0xd7, 0xbd, 0xfa, 0x07, 0xf4, 0xcc, 0x8e, 0x5f, 0xef, 0x35, 0x9c, 0x84, 0x2b, 0x15, 0xd5, 0x77, 0x34, 0x49, 0xb6, 0x12, 0x0a, 0x7f, 0x71, 0x88, 0xfd, 0x9d, 0x18, 0x41, 0x7d, 0x93, 0xd8, 0x58, 0x2c, 0xce, 0xfe, 0x24, 0xaf, 0xde, 0xb8, 0x36, 0xc8, 0xa1, 0x80, 0xa6, 0x99, 0x98, 0xa8, 0x2f, 0x0e, 0x81, 0x65, 0x73, 0xe4, 0xc2, 0xa2, 0x8a, 0xd4, 0xe1, 0x11, 0xd0, 0x08, 0x8b, 0x2a, 0xf2, 0xed, 0x9a, 0x64, 0x3f, 0xc1, 0x6c, 0xf9, 0xec }; /** for "strong" encryption, this is the second rotor of an Enigma 3 rotor cipher. */ static unsigned char comp_high1 [] = { 0x41, 0x36, 0x13, 0x62, 0xa8, 0x21, 0x6e, 0xbb, 0xf4, 0x16, 0xcc, 0x04, 0x7f, 0x64, 0xe8, 0x5d, 0x1e, 0xf2, 0xcb, 0x2a, 0x74, 0xc5, 0x5e, 0x35, 0xd2, 0x95, 0x47, 0x9e, 0x96, 0x2d, 0x9a, 0x88, 0x4c, 0x7d, 0x84, 0x3f, 0xdb, 0xac, 0x31, 0xb6, 0x48, 0x5f, 0xf6, 0xc4, 0xd8, 0x39, 0x8b, 0xe7, 0x23, 0x3b, 0x38, 0x8e, 0xc8, 0xc1, 0xdf, 0x25, 0xb1, 0x20, 0xa5, 0x46, 0x60, 0x4e, 0x9c, 0xfb, 0xaa, 0xd3, 0x56, 0x51, 0x45, 0x7c, 0x55, 0x00, 0x07, 0xc9, 0x2b, 0x9d, 0x85, 0x9b, 0x09, 0xa0, 0x8f, 0xad, 0xb3, 0x0f, 0x63, 0xab, 0x89, 0x4b, 0xd7, 0xa7, 0x15, 0x5a, 0x71, 0x66, 0x42, 0xbf, 0x26, 0x4a, 0x6b, 0x98, 0xfa, 0xea, 0x77, 0x53, 0xb2, 0x70, 0x05, 0x2c, 0xfd, 0x59, 0x3a, 0x86, 0x7e, 0xce, 0x06, 0xeb, 0x82, 0x78, 0x57, 0xc7, 0x8d, 0x43, 0xaf, 0xb4, 0x1c, 0xd4, 0x5b, 0xcd, 0xe2, 0xe9, 0x27, 0x4f, 0xc3, 0x08, 0x72, 0x80, 0xcf, 0xb0, 0xef, 0xf5, 0x28, 0x6d, 0xbe, 0x30, 0x4d, 0x34, 0x92, 0xd5, 0x0e, 0x3c, 0x22, 0x32, 0xe5, 0xe4, 0xf9, 0x9f, 0xc2, 0xd1, 0x0a, 0x81, 0x12, 0xe1, 0xee, 0x91, 0x83, 0x76, 0xe3, 0x97, 0xe6, 0x61, 0x8a, 0x17, 0x79, 0xa4, 0xb7, 0xdc, 0x90, 0x7a, 0x5c, 0x8c, 0x02, 0xa6, 0xca, 0x69, 0xde, 0x50, 0x1a, 0x11, 0x93, 0xb9, 0x52, 0x87, 0x58, 0xfc, 0xed, 0x1d, 0x37, 0x49, 0x1b, 0x6a, 0xe0, 0x29, 0x33, 0x99, 0xbd, 0x6c, 0xd9, 0x94, 0xf3, 0x40, 0x54, 0x6f, 0xf0, 0xc6, 0x73, 0xb8, 0xd6, 0x3e, 0x65, 0x18, 0x44, 0x1f, 0xdd, 0x67, 0x10, 0xf1, 0x0c, 0x19, 0xec, 0xae, 0x03, 0xa1, 0x14, 0x7b, 0xa9, 0x0b, 0xff, 0xf8, 0xa3, 0xc0, 0xa2, 0x01, 0xf7, 0x2e, 0xbc, 0x24, 0x68, 0x75, 0x0d, 0xfe, 0xba, 0x2f, 0xb5, 0xd0, 0xda, 0x3d }; /** for "strong" encryption, this is the third rotor of an Enigma 3 rotor cipher. */ static unsigned char comp_high2 [] = { 0x14, 0x53, 0x0f, 0x56, 0xb3, 0xc8, 0x7a, 0x9c, 0xeb, 0x65, 0x48, 0x17, 0x16, 0x15, 0x9f, 0x02, 0xcc, 0x54, 0x7c, 0x83, 0x00, 0x0d, 0x0c, 0x0b, 0xa2, 0x62, 0xa8, 0x76, 0xdb, 0xd9, 0xed, 0xc7, 0xc5, 0xa4, 0xdc, 0xac, 0x85, 0x74, 0xd6, 0xd0, 0xa7, 0x9b, 0xae, 0x9a, 0x96, 0x71, 0x66, 0xc3, 0x63, 0x99, 0xb8, 0xdd, 0x73, 0x92, 0x8e, 0x84, 0x7d, 0xa5, 0x5e, 0xd1, 0x5d, 0x93, 0xb1, 0x57, 0x51, 0x50, 0x80, 0x89, 0x52, 0x94, 0x4f, 0x4e, 0x0a, 0x6b, 0xbc, 0x8d, 0x7f, 0x6e, 0x47, 0x46, 0x41, 0x40, 0x44, 0x01, 0x11, 0xcb, 0x03, 0x3f, 0xf7, 0xf4, 0xe1, 0xa9, 0x8f, 0x3c, 0x3a, 0xf9, 0xfb, 0xf0, 0x19, 0x30, 0x82, 0x09, 0x2e, 0xc9, 0x9d, 0xa0, 0x86, 0x49, 0xee, 0x6f, 0x4d, 0x6d, 0xc4, 0x2d, 0x81, 0x34, 0x25, 0x87, 0x1b, 0x88, 0xaa, 0xfc, 0x06, 0xa1, 0x12, 0x38, 0xfd, 0x4c, 0x42, 0x72, 0x64, 0x13, 0x37, 0x24, 0x6a, 0x75, 0x77, 0x43, 0xff, 0xe6, 0xb4, 0x4b, 0x36, 0x5c, 0xe4, 0xd8, 0x35, 0x3d, 0x45, 0xb9, 0x2c, 0xec, 0xb7, 0x31, 0x2b, 0x29, 0x07, 0x68, 0xa3, 0x0e, 0x69, 0x7b, 0x18, 0x9e, 0x21, 0x39, 0xbe, 0x28, 0x1a, 0x5b, 0x78, 0xf5, 0x23, 0xca, 0x2a, 0xb0, 0xaf, 0x3e, 0xfe, 0x04, 0x8c, 0xe7, 0xe5, 0x98, 0x32, 0x95, 0xd3, 0xf6, 0x4a, 0xe8, 0xa6, 0xea, 0xe9, 0xf3, 0xd5, 0x2f, 0x70, 0x20, 0xf2, 0x1f, 0x05, 0x67, 0xad, 0x55, 0x10, 0xce, 0xcd, 0xe3, 0x27, 0x3b, 0xda, 0xba, 0xd7, 0xc2, 0x26, 0xd4, 0x91, 0x1d, 0xd2, 0x1c, 0x22, 0x33, 0xf8, 0xfa, 0xf1, 0x5a, 0xef, 0xcf, 0x90, 0xb6, 0x8b, 0xb5, 0xbd, 0xc0, 0xbf, 0x08, 0x97, 0x1e, 0x6c, 0xe2, 0x61, 0xe0, 0xc6, 0xc1, 0x59, 0xab, 0xbb, 0x58, 0xde, 0x5f, 0xdf, 0x60, 0x79, 0x7e, 0xb2, 0x8a }; int pst_open(pst_file *pf, char *name) { int32_t sig; unicode_init(); DEBUG_ENT("pst_open"); if (!pf) { WARN (("cannot be passed a NULL pst_file\n")); DEBUG_RET(); return -1; } memset(pf, 0, sizeof(*pf)); if ((pf->fp = fopen(name, "rb")) == NULL) { - WARN(("cannot open PST file. Error\n")); + perror("Error opening PST file"); DEBUG_RET(); return -1; } // Check pst file magic if (pst_getAtPos(pf, 0, &sig, sizeof(sig)) != sizeof(sig)) { (void)fclose(pf->fp); WARN(("cannot read signature from PST file. Closing on error\n")); DEBUG_RET(); return -1; } LE32_CPU(sig); DEBUG_INFO(("sig = %X\n", sig)); if (sig != (int32_t)PST_SIGNATURE) { (void)fclose(pf->fp); WARN(("not a PST file that I know. Closing with error\n")); DEBUG_RET(); return -1; } // read index type (void)pst_getAtPos(pf, INDEX_TYPE_OFFSET, &(pf->ind_type), sizeof(pf->ind_type)); DEBUG_INFO(("index_type = %i\n", pf->ind_type)); switch (pf->ind_type) { case INDEX_TYPE32 : case INDEX_TYPE32A : pf->do_read64 = 0; break; case INDEX_TYPE64 : case INDEX_TYPE64A : pf->do_read64 = 1; break; default: (void)fclose(pf->fp); WARN(("unknown .pst format, possibly newer than Outlook 2003 PST file?\n")); DEBUG_RET(); return -1; } // read encryption setting (void)pst_getAtPos(pf, ENC_TYPE, &(pf->encryption), sizeof(pf->encryption)); DEBUG_INFO(("encrypt = %i\n", pf->encryption)); pf->index2_back = pst_getIntAtPos(pf, SECOND_BACK); pf->index2 = pst_getIntAtPos(pf, SECOND_POINTER); pf->size = pst_getIntAtPos(pf, FILE_SIZE_POINTER); DEBUG_INFO(("Pointer2 is %#"PRIx64", back pointer2 is %#"PRIx64"\n", pf->index2, pf->index2_back)); pf->index1_back = pst_getIntAtPos(pf, INDEX_BACK); pf->index1 = pst_getIntAtPos(pf, INDEX_POINTER); DEBUG_INFO(("Pointer1 is %#"PRIx64", back pointer2 is %#"PRIx64"\n", pf->index1, pf->index1_back)); DEBUG_RET(); return 0; } int pst_close(pst_file *pf) { DEBUG_ENT("pst_close"); if (!pf->fp) { WARN(("cannot close NULL fp\n")); DEBUG_RET(); return -1; } if (fclose(pf->fp)) { WARN(("fclose returned non-zero value\n")); DEBUG_RET(); return -1; } // we must free the id linklist and the desc tree pst_free_id (pf->i_head); pst_free_desc (pf->d_head); pst_free_xattrib (pf->x_head); DEBUG_RET(); return 0; } /** * add a pst descriptor node to a linked list of such nodes. * * @param node pointer to the node to be added to the list * @param head pointer to the list head pointer * @param tail pointer to the list tail pointer */ static void add_descriptor_to_list(pst_desc_ll *node, pst_desc_ll **head, pst_desc_ll **tail); static void add_descriptor_to_list(pst_desc_ll *node, pst_desc_ll **head, pst_desc_ll **tail) { DEBUG_ENT("add_descriptor_to_list"); //DEBUG_INDEX(("Added node %#"PRIx64" parent %#"PRIx64" real parent %#"PRIx64" prev %#"PRIx64" next %#"PRIx64"\n", // node->id, node->parent_id, // (node->parent ? node->parent->id : (uint64_t)0), // (node->prev ? node->prev->id : (uint64_t)0), // (node->next ? node->next->id : (uint64_t)0))); if (*tail) (*tail)->next = node; if (!(*head)) *head = node; node->prev = *tail; node->next = NULL; *tail = node; DEBUG_RET(); } /** * add a pst descriptor node into the global tree. * * @param pf global pst file pointer * @param node pointer to the new node to be added to the tree */ static void record_descriptor(pst_file *pf, pst_desc_ll *node); static void record_descriptor(pst_file *pf, pst_desc_ll *node) { DEBUG_ENT("record_descriptor"); // finish node initialization node->parent = NULL; node->child = NULL; node->child_tail = NULL; node->no_child = 0; // find any orphan children of this node, and collect them pst_desc_ll *n = pf->d_head; while (n) { if (n->parent_d_id == node->d_id) { // found a child of this node DEBUG_INDEX(("Found orphan child %#"PRIx64" of parent %#"PRIx64"\n", n->d_id, node->d_id)); pst_desc_ll *nn = n->next; pst_desc_ll *pp = n->prev; node->no_child++; n->parent = node; add_descriptor_to_list(n, &node->child, &node->child_tail); if (pp) pp->next = nn; else pf->d_head = nn; if (nn) nn->prev = pp; else pf->d_tail = pp; n = nn; } else { n = n->next; } } // now hook this node into the global tree if (node->parent_d_id == 0) { // add top level node to the descriptor tree //DEBUG_INDEX(("Null parent\n")); add_descriptor_to_list(node, &pf->d_head, &pf->d_tail); } else if (node->parent_d_id == node->d_id) { // add top level node to the descriptor tree DEBUG_INDEX(("%#"PRIx64" is its own parent. What is this world coming to?\n")); add_descriptor_to_list(node, &pf->d_head, &pf->d_tail); } else { //DEBUG_INDEX(("Searching for parent %#"PRIx64" of %#"PRIx64"\n", node->parent_id, node->id)); pst_desc_ll *parent = pst_getDptr(pf, node->parent_d_id); if (parent) { //DEBUG_INDEX(("Found parent %#"PRIx64"\n", node->parent_id)); parent->no_child++; node->parent = parent; add_descriptor_to_list(node, &parent->child, &parent->child_tail); } else { DEBUG_INDEX(("No parent %#"PRIx64", have an orphan child %#"PRIx64"\n", node->parent_d_id, node->d_id)); add_descriptor_to_list(node, &pf->d_head, &pf->d_tail); } } DEBUG_RET(); } /** * make a deep copy of part of the id2 mapping tree, for use * by an attachment containing an embedded rfc822 message. * * @param head pointer to the subtree to be copied * @return pointer to the new copy of the subtree */ static pst_id2_ll* deep_copy(pst_id2_ll *head); static pst_id2_ll* deep_copy(pst_id2_ll *head) { if (!head) return NULL; pst_id2_ll* me = (pst_id2_ll*) xmalloc(sizeof(pst_id2_ll)); me->id2 = head->id2; me->id = head->id; me->child = deep_copy(head->child); me->next = deep_copy(head->next); return me; } pst_desc_ll* pst_getTopOfFolders(pst_file *pf, pst_item *root) { pst_desc_ll *topnode; uint32_t topid; DEBUG_ENT("pst_getTopOfFolders"); if (!root || !root->message_store) { DEBUG_INDEX(("There isn't a top of folder record here.\n")); DEBUG_RET(); return NULL; } if (!root->message_store->top_of_personal_folder) { // this is the OST way // ASSUMPTION: Top Of Folders record in PST files is *always* descid 0x2142 topid = 0x2142; } else { topid = root->message_store->top_of_personal_folder->id; } DEBUG_INDEX(("looking for top of folder descriptor %#"PRIx32"\n", topid)); topnode = pst_getDptr(pf, (uint64_t)topid); if (!topnode) { // add dummy top record to pickup orphan children topnode = (pst_desc_ll*) xmalloc(sizeof(pst_desc_ll)); topnode->d_id = topid; topnode->parent_d_id = 0; topnode->assoc_tree = NULL; topnode->desc = NULL; record_descriptor(pf, topnode); // add to the global tree } DEBUG_RET(); return topnode; } size_t pst_attach_to_mem(pst_file *pf, pst_item_attach *attach, char **b){ size_t size=0; pst_index_ll *ptr; pst_holder h = {b, NULL, 0}; DEBUG_ENT("pst_attach_to_mem"); if (attach->id_val != (uint64_t)-1) { ptr = pst_getID(pf, attach->id_val); if (ptr) { size = pst_ff_getID2data(pf, ptr, &h); } else { DEBUG_WARN(("Couldn't find ID pointer. Cannot handle attachment\n")); size = 0; } attach->size = size; } else { size = attach->size; } DEBUG_RET(); return size; } size_t pst_attach_to_file(pst_file *pf, pst_item_attach *attach, FILE* fp) { pst_index_ll *ptr; pst_holder h = {NULL, fp, 0}; size_t size = 0; DEBUG_ENT("pst_attach_to_file"); if (attach->id_val != (uint64_t)-1) { ptr = pst_getID(pf, attach->id_val); if (ptr) { size = pst_ff_getID2data(pf, ptr, &h); } else { DEBUG_WARN(("Couldn't find ID pointer. Cannot save attachment to file\n")); } attach->size = size; } else { // save the attachment to the file size = attach->size; (void)pst_fwrite(attach->data, (size_t)1, size, fp); } DEBUG_RET(); return size; } size_t pst_attach_to_file_base64(pst_file *pf, pst_item_attach *attach, FILE* fp) { pst_index_ll *ptr; pst_holder h = {NULL, fp, 1}; size_t size = 0; DEBUG_ENT("pst_attach_to_file_base64"); if (attach->id_val != (uint64_t)-1) { ptr = pst_getID(pf, attach->id_val); if (ptr) { size = pst_ff_getID2data(pf, ptr, &h); } else { DEBUG_WARN(("Couldn't find ID pointer. Cannot save attachment to Base64\n")); } attach->size = size; } else { // encode the attachment to the file char *c = base64_encode(attach->data, attach->size); if (c) { (void)pst_fwrite(c, (size_t)1, strlen(c), fp); free(c); // caught by valgrind } size = attach->size; } DEBUG_RET(); return size; } int pst_load_index (pst_file *pf) { int x; DEBUG_ENT("pst_load_index"); if (!pf) { WARN(("Cannot load index for a NULL pst_file\n")); DEBUG_RET(); return -1; } x = pst_build_id_ptr(pf, pf->index1, 0, pf->index1_back, 0, UINT64_MAX); DEBUG_INDEX(("build id ptr returns %i\n", x)); x = pst_build_desc_ptr(pf, pf->index2, 0, pf->index2_back, (uint64_t)0x21, UINT64_MAX); DEBUG_INDEX(("build desc ptr returns %i\n", x)); DEBUG_CODE((void)pst_printDptr(pf, pf->d_head);); DEBUG_RET(); return 0; } pst_desc_ll* pst_getNextDptr(pst_desc_ll* d) { pst_desc_ll* r = NULL; DEBUG_ENT("pst_getNextDptr"); if (d) { if ((r = d->child) == NULL) { while (!d->next && d->parent) d = d->parent; r = d->next; } } DEBUG_RET(); return r; } typedef struct pst_x_attrib { uint32_t extended; uint16_t type; uint16_t map; } pst_x_attrib; int pst_load_extended_attributes(pst_file *pf) { // for PST files this will load up ID2 0x61 and check it's "list" attribute. pst_desc_ll *p; - pst_num_array *na; + pst_mapi_object *na; pst_id2_ll *id2_head = NULL; char *buffer=NULL, *headerbuffer=NULL; size_t bsize=0, hsize=0, bptr=0; pst_x_attrib xattrib; int32_t tint, err=0, x; pst_x_attrib_ll *ptr, *p_head=NULL, *p_sh=NULL, *p_sh2=NULL; DEBUG_ENT("pst_loadExtendedAttributes"); p = pst_getDptr(pf, (uint64_t)0x61); if (!p) { DEBUG_WARN(("Cannot find DescID 0x61 for loading the Extended Attributes\n")); DEBUG_RET(); return 0; } if (!p->desc) { DEBUG_WARN(("desc is NULL for item 0x61. Cannot load Extended Attributes\n")); DEBUG_RET(); return 0; } if (p->assoc_tree) { id2_head = pst_build_id2(pf, p->assoc_tree); pst_printID2ptr(id2_head); } else { DEBUG_WARN(("Have not been able to fetch any id2 values for item 0x61. Brace yourself!\n")); } - na = pst_parse_block(pf, p->desc->id, id2_head, NULL); + na = pst_parse_block(pf, p->desc->id, id2_head); if (!na) { DEBUG_WARN(("Cannot process desc block for item 0x61. Not loading extended Attributes\n")); pst_free_id2(id2_head); DEBUG_RET(); return 0; } - for (x=0; x < na->count_item; x++) { - if (na->items[x]->id == (uint32_t)0x0003) { - buffer = na->items[x]->data; - bsize = na->items[x]->size; - } else if (na->items[x]->id == (uint32_t)0x0004) { - headerbuffer = na->items[x]->data; - hsize = na->items[x]->size; + for (x=0; x < na->count_elements; x++) { + if (na->elements[x]->mapi_id == (uint32_t)0x0003) { + buffer = na->elements[x]->data; + bsize = na->elements[x]->size; + } else if (na->elements[x]->mapi_id == (uint32_t)0x0004) { + headerbuffer = na->elements[x]->data; + hsize = na->elements[x]->size; } else { // leave them null } } if (!buffer) { pst_free_list(na); DEBUG_WARN(("No extended attributes buffer found. Not processing\n")); DEBUG_RET(); return 0; } xattrib.extended= PST_LE_GET_UINT32(buffer+bptr), bptr += 4; xattrib.type = PST_LE_GET_UINT16(buffer+bptr), bptr += 2; xattrib.map = PST_LE_GET_UINT16(buffer+bptr), bptr += 2; while (xattrib.type != 0 && bptr < bsize) { ptr = (pst_x_attrib_ll*) xmalloc(sizeof(*ptr)); memset(ptr, 0, sizeof(*ptr)); ptr->type = xattrib.type; ptr->map = xattrib.map+0x8000; ptr->next = NULL; DEBUG_INDEX(("xattrib: ext = %#x, type = %#hx, map = %#hx\n", xattrib.extended, xattrib.type, xattrib.map)); err=0; if (xattrib.type & 0x0001) { // if the Bit 1 is set // pointer to Unicode field in buffer if (xattrib.extended < hsize) { char *wt; // copy the size of the header. It is 32 bit int memcpy(&tint, &(headerbuffer[xattrib.extended]), sizeof(tint)); LE32_CPU(tint); wt = (char*) xmalloc((size_t)(tint+2)); // plus 2 for a uni-code zero memset(wt, 0, (size_t)(tint+2)); memcpy(wt, &(headerbuffer[xattrib.extended+sizeof(tint)]), (size_t)tint); ptr->data = pst_wide_to_single(wt, (size_t)tint); free(wt); DEBUG_INDEX(("Read string (converted from UTF-16): %s\n", ptr->data)); } else { DEBUG_INDEX(("Cannot read outside of buffer [%i !< %i]\n", xattrib.extended, hsize)); } ptr->mytype = PST_MAP_HEADER; } else { // contains the attribute code to map to. ptr->data = (uint32_t*)xmalloc(sizeof(uint32_t)); memset(ptr->data, 0, sizeof(uint32_t)); *((uint32_t*)ptr->data) = xattrib.extended; ptr->mytype = PST_MAP_ATTRIB; DEBUG_INDEX(("Mapped attribute %#x to %#x\n", ptr->map, *((int32_t*)ptr->data))); } if (err==0) { // add it to the list p_sh = p_head; p_sh2 = NULL; while (p_sh && ptr->map > p_sh->map) { p_sh2 = p_sh; p_sh = p_sh->next; } if (!p_sh2) { // needs to go before first item ptr->next = p_head; p_head = ptr; } else { // it will go after p_sh2 ptr->next = p_sh2->next; p_sh2->next = ptr; } } else { free(ptr); ptr = NULL; } memcpy(&xattrib, &(buffer[bptr]), sizeof(xattrib)); LE32_CPU(xattrib.extended); LE16_CPU(xattrib.type); LE16_CPU(xattrib.map); bptr += sizeof(xattrib); } pst_free_id2(id2_head); pst_free_list(na); pf->x_head = p_head; DEBUG_RET(); return 1; } #define ITEM_COUNT_OFFSET32 0x1f0 // count byte #define LEVEL_INDICATOR_OFFSET32 0x1f3 // node or leaf #define BACKLINK_OFFSET32 0x1f8 // backlink u1 value #define ITEM_SIZE32 12 #define DESC_SIZE32 16 #define INDEX_COUNT_MAX32 41 // max active items #define DESC_COUNT_MAX32 31 // max active items #define ITEM_COUNT_OFFSET64 0x1e8 // count byte #define LEVEL_INDICATOR_OFFSET64 0x1eb // node or leaf #define BACKLINK_OFFSET64 0x1f8 // backlink u1 value #define ITEM_SIZE64 24 #define DESC_SIZE64 32 #define INDEX_COUNT_MAX64 20 // max active items #define DESC_COUNT_MAX64 15 // max active items #define BLOCK_SIZE 512 // index blocks #define DESC_BLOCK_SIZE 512 // descriptor blocks #define ITEM_COUNT_OFFSET (size_t)((pf->do_read64) ? ITEM_COUNT_OFFSET64 : ITEM_COUNT_OFFSET32) #define LEVEL_INDICATOR_OFFSET (size_t)((pf->do_read64) ? LEVEL_INDICATOR_OFFSET64 : LEVEL_INDICATOR_OFFSET32) #define BACKLINK_OFFSET (size_t)((pf->do_read64) ? BACKLINK_OFFSET64 : BACKLINK_OFFSET32) #define ITEM_SIZE (size_t)((pf->do_read64) ? ITEM_SIZE64 : ITEM_SIZE32) #define DESC_SIZE (size_t)((pf->do_read64) ? DESC_SIZE64 : DESC_SIZE32) #define INDEX_COUNT_MAX (int32_t)((pf->do_read64) ? INDEX_COUNT_MAX64 : INDEX_COUNT_MAX32) #define DESC_COUNT_MAX (int32_t)((pf->do_read64) ? DESC_COUNT_MAX64 : DESC_COUNT_MAX32) static size_t pst_decode_desc(pst_file *pf, pst_descn *desc, char *buf); static size_t pst_decode_desc(pst_file *pf, pst_descn *desc, char *buf) { size_t r; if (pf->do_read64) { DEBUG_INDEX(("Decoding desc64\n")); DEBUG_HEXDUMPC(buf, sizeof(pst_descn), 0x10); memcpy(desc, buf, sizeof(pst_descn)); LE64_CPU(desc->d_id); LE64_CPU(desc->desc_id); LE64_CPU(desc->list_id); LE32_CPU(desc->parent_id); LE32_CPU(desc->u1); r = sizeof(pst_descn); } else { pst_desc32 d32; DEBUG_INDEX(("Decoding desc32\n")); DEBUG_HEXDUMPC(buf, sizeof(pst_desc32), 0x10); memcpy(&d32, buf, sizeof(pst_desc32)); LE32_CPU(d32.d_id); LE32_CPU(d32.desc_id); LE32_CPU(d32.tree_id); LE32_CPU(d32.parent_d_id); desc->d_id = d32.d_id; desc->desc_id = d32.desc_id; desc->tree_id = d32.tree_id; desc->parent_d_id = d32.parent_d_id; desc->u1 = 0; r = sizeof(pst_desc32); } return r; } static size_t pst_decode_table(pst_file *pf, struct pst_table_ptr_structn *table, char *buf); static size_t pst_decode_table(pst_file *pf, struct pst_table_ptr_structn *table, char *buf) { size_t r; if (pf->do_read64) { DEBUG_INDEX(("Decoding table64\n")); DEBUG_HEXDUMPC(buf, sizeof(struct pst_table_ptr_structn), 0x10); memcpy(table, buf, sizeof(struct pst_table_ptr_structn)); LE64_CPU(table->start); LE64_CPU(table->u1); LE64_CPU(table->offset); r =sizeof(struct pst_table_ptr_structn); } else { struct pst_table_ptr_struct32 t32; DEBUG_INDEX(("Decoding table32\n")); DEBUG_HEXDUMPC(buf, sizeof( struct pst_table_ptr_struct32), 0x10); memcpy(&t32, buf, sizeof(struct pst_table_ptr_struct32)); LE32_CPU(t32.start); LE32_CPU(t32.u1); LE32_CPU(t32.offset); table->start = t32.start; table->u1 = t32.u1; table->offset = t32.offset; r = sizeof(struct pst_table_ptr_struct32); } return r; } static size_t pst_decode_index(pst_file *pf, pst_index *index, char *buf); static size_t pst_decode_index(pst_file *pf, pst_index *index, char *buf) { size_t r; if (pf->do_read64) { DEBUG_INDEX(("Decoding index64\n")); DEBUG_HEXDUMPC(buf, sizeof(pst_index), 0x10); memcpy(index, buf, sizeof(pst_index)); LE64_CPU(index->id); LE64_CPU(index->offset); LE16_CPU(index->size); LE16_CPU(index->u0); LE32_CPU(index->u1); r = sizeof(pst_index); } else { pst_index32 index32; DEBUG_INDEX(("Decoding index32\n")); DEBUG_HEXDUMPC(buf, sizeof(pst_index32), 0x10); memcpy(&index32, buf, sizeof(pst_index32)); LE32_CPU(index32.id); LE32_CPU(index32.offset); LE16_CPU(index32.size); LE16_CPU(index32.u1); index->id = index32.id; index->offset = index32.offset; index->size = index32.size; index->u0 = 0; index->u1 = index32.u1; r = sizeof(pst_index32); } return r; } static size_t pst_decode_assoc(pst_file *pf, pst_id2_assoc *assoc, char *buf); static size_t pst_decode_assoc(pst_file *pf, pst_id2_assoc *assoc, char *buf) { size_t r; if (pf->do_read64) { DEBUG_INDEX(("Decoding assoc64\n")); DEBUG_HEXDUMPC(buf, sizeof(pst_id2_assoc), 0x10); memcpy(assoc, buf, sizeof(pst_id2_assoc)); LE32_CPU(assoc->id2); LE64_CPU(assoc->id); LE64_CPU(assoc->child_id); r = sizeof(pst_id2_assoc); } else { pst_id2_assoc32 assoc32; DEBUG_INDEX(("Decoding assoc32\n")); DEBUG_HEXDUMPC(buf, sizeof(pst_id2_assoc32), 0x10); memcpy(&assoc32, buf, sizeof(pst_id2_assoc32)); LE32_CPU(assoc32.id2); LE32_CPU(assoc32.id); LE32_CPU(assoc32.table2); assoc->id2 = assoc32.id2; assoc->id = assoc32.id; assoc->child_id = assoc32.child_id; r = sizeof(pst_id2_assoc32); } return r; } static size_t pst_decode_type3(pst_file *pf, pst_table3_rec *table3_rec, char *buf); static size_t pst_decode_type3(pst_file *pf, pst_table3_rec *table3_rec, char *buf) { size_t r; if (pf->do_read64) { DEBUG_INDEX(("Decoding table3 64\n")); DEBUG_HEXDUMPC(buf, sizeof(pst_table3_rec), 0x10); memcpy(table3_rec, buf, sizeof(pst_table3_rec)); LE64_CPU(table3_rec->id); r = sizeof(pst_table3_rec); } else { pst_table3_rec32 table3_rec32; DEBUG_INDEX(("Decoding table3 32\n")); DEBUG_HEXDUMPC(buf, sizeof(pst_table3_rec32), 0x10); memcpy(&table3_rec32, buf, sizeof(pst_table3_rec32)); LE32_CPU(table3_rec32.id); table3_rec->id = table3_rec32.id; r = sizeof(pst_table3_rec32); } return r; } /** Process the index1 b-tree from the pst file and create the * pf->i_head linked list from it. This tree holds the location * (offset and size) of lower level objects (0xbcec descriptor * blocks, etc) in the pst file. */ int pst_build_id_ptr(pst_file *pf, int64_t offset, int32_t depth, uint64_t linku1, uint64_t start_val, uint64_t end_val) { struct pst_table_ptr_structn table, table2; pst_index_ll *i_ptr=NULL; pst_index index; int32_t x, item_count; uint64_t old = start_val; char *buf = NULL, *bptr; DEBUG_ENT("pst_build_id_ptr"); DEBUG_INDEX(("offset %#"PRIx64" depth %i linku1 %#"PRIx64" start %#"PRIx64" end %#"PRIx64"\n", offset, depth, linku1, start_val, end_val)); if (end_val <= start_val) { DEBUG_WARN(("The end value is BEFORE the start value. This function will quit. Soz. [start:%#"PRIx64", end:%#"PRIx64"]\n", start_val, end_val)); DEBUG_RET(); return -1; } DEBUG_INDEX(("Reading index block\n")); if (pst_read_block_size(pf, offset, BLOCK_SIZE, &buf) < BLOCK_SIZE) { DEBUG_WARN(("Failed to read %i bytes\n", BLOCK_SIZE)); if (buf) free(buf); DEBUG_RET(); return -1; } bptr = buf; DEBUG_HEXDUMPC(buf, BLOCK_SIZE, ITEM_SIZE32); item_count = (int32_t)(unsigned)(buf[ITEM_COUNT_OFFSET]); if (item_count > INDEX_COUNT_MAX) { DEBUG_WARN(("Item count %i too large, max is %i\n", item_count, INDEX_COUNT_MAX)); if (buf) free(buf); DEBUG_RET(); return -1; } index.id = pst_getIntAt(pf, buf+BACKLINK_OFFSET); if (index.id != linku1) { DEBUG_WARN(("Backlink %#"PRIx64" in this node does not match required %#"PRIx64"\n", index.id, linku1)); if (buf) free(buf); DEBUG_RET(); return -1; } if (buf[LEVEL_INDICATOR_OFFSET] == '\0') { // this node contains leaf pointers x = 0; while (x < item_count) { bptr += pst_decode_index(pf, &index, bptr); x++; if (index.id == 0) break; DEBUG_INDEX(("[%i]%i Item [id = %#"PRIx64", offset = %#"PRIx64", u1 = %#x, size = %i(%#x)]\n", depth, x, index.id, index.offset, index.u1, index.size, index.size)); // if (index.id & 0x02) DEBUG_INDEX(("two-bit set!!\n")); if ((index.id >= end_val) || (index.id < old)) { DEBUG_WARN(("This item isn't right. Must be corruption, or I got it wrong!\n")); if (buf) free(buf); DEBUG_RET(); return -1; } old = index.id; if (x == (int32_t)1) { // first entry if ((start_val) && (index.id != start_val)) { DEBUG_WARN(("This item isn't right. Must be corruption, or I got it wrong!\n")); if (buf) free(buf); DEBUG_RET(); return -1; } } i_ptr = (pst_index_ll*) xmalloc(sizeof(pst_index_ll)); i_ptr->id = index.id; i_ptr->offset = index.offset; i_ptr->u1 = index.u1; i_ptr->size = index.size; i_ptr->next = NULL; if (pf->i_tail) pf->i_tail->next = i_ptr; if (!pf->i_head) pf->i_head = i_ptr; pf->i_tail = i_ptr; } } else { // this node contains node pointers x = 0; while (x < item_count) { bptr += pst_decode_table(pf, &table, bptr); x++; if (table.start == 0) break; if (x < item_count) { (void)pst_decode_table(pf, &table2, bptr); } else { table2.start = end_val; } DEBUG_INDEX(("[%i] %i Index Table [start id = %#"PRIx64", u1 = %#"PRIx64", offset = %#"PRIx64", end id = %#"PRIx64"]\n", depth, x, table.start, table.u1, table.offset, table2.start)); if ((table.start >= end_val) || (table.start < old)) { DEBUG_WARN(("This table isn't right. Must be corruption, or I got it wrong!\n")); if (buf) free(buf); DEBUG_RET(); return -1; } old = table.start; if (x == (int32_t)1) { // first entry if ((start_val) && (table.start != start_val)) { DEBUG_WARN(("This table isn't right. Must be corruption, or I got it wrong!\n")); if (buf) free(buf); DEBUG_RET(); return -1; } } (void)pst_build_id_ptr(pf, table.offset, depth+1, table.u1, table.start, table2.start); } } if (buf) free (buf); DEBUG_RET(); return 0; } /** Process the index2 b-tree from the pst file and create the * pf->d_head tree from it. This tree holds descriptions of the * higher level objects (email, contact, etc) in the pst file. */ int pst_build_desc_ptr (pst_file *pf, int64_t offset, int32_t depth, uint64_t linku1, uint64_t start_val, uint64_t end_val) { struct pst_table_ptr_structn table, table2; pst_descn desc_rec; int32_t item_count; uint64_t old = start_val; int x; char *buf = NULL, *bptr; DEBUG_ENT("pst_build_desc_ptr"); DEBUG_INDEX(("offset %#"PRIx64" depth %i linku1 %#"PRIx64" start %#"PRIx64" end %#"PRIx64"\n", offset, depth, linku1, start_val, end_val)); if (end_val <= start_val) { DEBUG_WARN(("The end value is BEFORE the start value. This function will quit. Soz. [start:%#"PRIx64", end:%#"PRIx64"]\n", start_val, end_val)); DEBUG_RET(); return -1; } DEBUG_INDEX(("Reading desc block\n")); if (pst_read_block_size(pf, offset, DESC_BLOCK_SIZE, &buf) < DESC_BLOCK_SIZE) { DEBUG_WARN(("Failed to read %i bytes\n", DESC_BLOCK_SIZE)); if (buf) free(buf); DEBUG_RET(); return -1; } bptr = buf; item_count = (int32_t)(unsigned)(buf[ITEM_COUNT_OFFSET]); desc_rec.d_id = pst_getIntAt(pf, buf+BACKLINK_OFFSET); if (desc_rec.d_id != linku1) { DEBUG_WARN(("Backlink %#"PRIx64" in this node does not match required %#"PRIx64"\n", desc_rec.d_id, linku1)); if (buf) free(buf); DEBUG_RET(); return -1; } if (buf[LEVEL_INDICATOR_OFFSET] == '\0') { // this node contains leaf pointers DEBUG_HEXDUMPC(buf, DESC_BLOCK_SIZE, DESC_SIZE32); if (item_count > DESC_COUNT_MAX) { DEBUG_WARN(("Item count %i too large, max is %i\n", item_count, DESC_COUNT_MAX)); if (buf) free(buf); DEBUG_RET(); return -1; } for (x=0; x= end_val) || (desc_rec.d_id < old)) { DEBUG_WARN(("This item isn't right. Must be corruption, or I got it wrong!\n")); DEBUG_HEXDUMPC(buf, DESC_BLOCK_SIZE, 16); if (buf) free(buf); DEBUG_RET(); return -1; } old = desc_rec.d_id; if (x == 0) { // first entry if (start_val && (desc_rec.d_id != start_val)) { DEBUG_WARN(("This item isn't right. Must be corruption, or I got it wrong!\n")); if (buf) free(buf); DEBUG_RET(); return -1; } } DEBUG_INDEX(("New Record %#"PRIx64" with parent %#x\n", desc_rec.d_id, desc_rec.parent_d_id)); { pst_desc_ll *d_ptr = (pst_desc_ll*) xmalloc(sizeof(pst_desc_ll)); d_ptr->d_id = desc_rec.d_id; d_ptr->parent_d_id = desc_rec.parent_d_id; d_ptr->assoc_tree = pst_getID(pf, desc_rec.tree_id); d_ptr->desc = pst_getID(pf, desc_rec.desc_id); record_descriptor(pf, d_ptr); // add to the global tree } } } else { // this node contains node pointers DEBUG_HEXDUMPC(buf, DESC_BLOCK_SIZE, ITEM_SIZE32); if (item_count > INDEX_COUNT_MAX) { DEBUG_WARN(("Item count %i too large, max is %i\n", item_count, INDEX_COUNT_MAX)); if (buf) free(buf); DEBUG_RET(); return -1; } for (x=0; x= end_val) || (table.start < old)) { DEBUG_WARN(("This table isn't right. Must be corruption, or I got it wrong!\n")); if (buf) free(buf); DEBUG_RET(); return -1; } old = table.start; if (x == 0) { // first entry if (start_val && (table.start != start_val)) { DEBUG_WARN(("This table isn't right. Must be corruption, or I got it wrong!\n")); if (buf) free(buf); DEBUG_RET(); return -1; } } (void)pst_build_desc_ptr(pf, table.offset, depth+1, table.u1, table.start, table2.start); } } if (buf) free(buf); DEBUG_RET(); return 0; } /** Process a high level object from the pst file. */ pst_item* pst_parse_item(pst_file *pf, pst_desc_ll *d_ptr, pst_id2_ll *m_head) { - pst_num_array * list; + pst_mapi_object * list; pst_id2_ll *id2_head = m_head; pst_id2_ll *id2_ptr = NULL; pst_item *item = NULL; pst_item_attach *attach = NULL; int32_t x; DEBUG_ENT("pst_parse_item"); if (!d_ptr) { DEBUG_WARN(("you cannot pass me a NULL! I don't want it!\n")); DEBUG_RET(); return NULL; } if (!d_ptr->desc) { DEBUG_WARN(("why is d_ptr->desc == NULL? I don't want to do anything else with this record\n")); DEBUG_RET(); return NULL; } if (d_ptr->assoc_tree) { if (m_head) { DEBUG_WARN(("supplied master head, but have a list that is building a new id2_head")); m_head = NULL; } id2_head = pst_build_id2(pf, d_ptr->assoc_tree); } pst_printID2ptr(id2_head); - list = pst_parse_block(pf, d_ptr->desc->id, id2_head, NULL); + list = pst_parse_block(pf, d_ptr->desc->id, id2_head); if (!list) { DEBUG_WARN(("pst_parse_block() returned an error for d_ptr->desc->id [%#"PRIx64"]\n", d_ptr->desc->id)); if (!m_head) pst_free_id2(id2_head); DEBUG_RET(); return NULL; } item = (pst_item*) xmalloc(sizeof(pst_item)); memset(item, 0, sizeof(pst_item)); if (pst_process(list, item, NULL)) { DEBUG_WARN(("pst_process() returned non-zero value. That is an error\n")); pst_freeItem(item); pst_free_list(list); if (!m_head) pst_free_id2(id2_head); DEBUG_RET(); return NULL; } pst_free_list(list); if ((id2_ptr = pst_getID2(id2_head, (uint64_t)0x692))) { // DSN/MDN reports? DEBUG_EMAIL(("DSN/MDN processing\n")); - list = pst_parse_block(pf, id2_ptr->id->id, id2_head, NULL); + list = pst_parse_block(pf, id2_ptr->id->id, id2_head); if (!list) { DEBUG_WARN(("ERROR error processing main DSN/MDN record\n")); if (!m_head) pst_free_id2(id2_head); DEBUG_RET(); return item; } - for (x=0; x < list->count_array; x++) { + for (x=0; x < list->count_objects; x++) { attach = (pst_item_attach*) xmalloc(sizeof(pst_item_attach)); memset(attach, 0, sizeof(pst_item_attach)); attach->next = item->attach; item->attach = attach; } if (pst_process(list, item, item->attach)) { DEBUG_WARN(("ERROR pst_process() failed with DSN/MDN attachments\n")); pst_freeItem(item); pst_free_list(list); if (!m_head) pst_free_id2(id2_head); DEBUG_RET(); return NULL; } pst_free_list(list); } if ((id2_ptr = pst_getID2(id2_head, (uint64_t)0x671))) { DEBUG_EMAIL(("ATTACHMENT processing attachment\n")); - list = pst_parse_block(pf, id2_ptr->id->id, id2_head, NULL); + list = pst_parse_block(pf, id2_ptr->id->id, id2_head); if (!list) { DEBUG_WARN(("ERROR error processing main attachment record\n")); if (!m_head) pst_free_id2(id2_head); DEBUG_RET(); return item; } - for (x=0; x < list->count_array; x++) { + for (x=0; x < list->count_objects; x++) { attach = (pst_item_attach*) xmalloc(sizeof(pst_item_attach)); memset(attach, 0, sizeof(pst_item_attach)); attach->next = item->attach; item->attach = attach; } if (pst_process(list, item, item->attach)) { DEBUG_WARN(("ERROR pst_process() failed with attachments\n")); pst_freeItem(item); pst_free_list(list); if (!m_head) pst_free_id2(id2_head); DEBUG_RET(); return NULL; } pst_free_list(list); // now we will have initial information of each attachment stored in item->attach... // we must now read the secondary record for each based on the id2 val associated with // each attachment attach = item->attach; while (attach) { DEBUG_WARN(("initial attachment id2 %#"PRIx64"\n", attach->id2_val)); if ((id2_ptr = pst_getID2(id2_head, attach->id2_val))) { DEBUG_WARN(("initial attachment id2 found id %#"PRIx64"\n", id2_ptr->id->id)); // id_ptr is a record describing the attachment // we pass NULL instead of id2_head cause we don't want it to // load all the extra stuff here. - list = pst_parse_block(pf, id2_ptr->id->id, NULL, NULL); + list = pst_parse_block(pf, id2_ptr->id->id, NULL); if (!list) { DEBUG_WARN(("ERROR error processing an attachment record\n")); attach = attach->next; continue; } - if (list->count_array > 1) { + if (list->count_objects > 1) { DEBUG_WARN(("ERROR probably fatal, list count array will overrun attach structure.\n")); } if (pst_process(list, item, attach)) { DEBUG_WARN(("ERROR pst_process() failed with an attachment\n")); pst_free_list(list); attach = attach->next; continue; } pst_free_list(list); id2_ptr = pst_getID2(id2_head, attach->id2_val); if (id2_ptr) { DEBUG_WARN(("second pass attachment updating id2 found id %#"PRIx64"\n", id2_ptr->id->id)); // id2_val has been updated to the ID2 value of the datablock containing the // attachment data attach->id_val = id2_ptr->id->id; attach->id2_head = deep_copy(id2_ptr->child); } else { DEBUG_WARN(("have not located the correct value for the attachment [%#"PRIx64"]\n", attach->id2_val)); } } else { DEBUG_WARN(("ERROR cannot locate id2 value %#"PRIx64"\n", attach->id2_val)); attach->id2_val = 0; // suppress this missing attachment } attach = attach->next; } } if (!m_head) pst_free_id2(id2_head); DEBUG_RET(); return item; } static void freeall(pst_subblocks *subs, pst_block_offset_pointer *p1, pst_block_offset_pointer *p2, pst_block_offset_pointer *p3, pst_block_offset_pointer *p4, pst_block_offset_pointer *p5, pst_block_offset_pointer *p6, pst_block_offset_pointer *p7); static void freeall(pst_subblocks *subs, pst_block_offset_pointer *p1, pst_block_offset_pointer *p2, pst_block_offset_pointer *p3, pst_block_offset_pointer *p4, pst_block_offset_pointer *p5, pst_block_offset_pointer *p6, pst_block_offset_pointer *p7) { size_t i; for (i=0; isubblock_count; i++) { if (subs->subs[i].buf) free(subs->subs[i].buf); } free(subs->subs); if (p1->needfree) free(p1->from); if (p2->needfree) free(p2->from); if (p3->needfree) free(p3->from); if (p4->needfree) free(p4->from); if (p5->needfree) free(p5->from); if (p6->needfree) free(p6->from); if (p7->needfree) free(p7->from); } /** Process a low level descriptor block (0x0101, 0xbcec, 0x7cec) into a - * list of objects, each of which contains a list of MAPI elements. + * list of MAPI objects, each of which contains a list of MAPI elements. * - * @return list of objects + * @return list of MAPI objects */ -pst_num_array * pst_parse_block(pst_file *pf, uint64_t block_id, pst_id2_ll *i2_head, pst_num_array *na_head) { +pst_mapi_object * pst_parse_block(pst_file *pf, uint64_t block_id, pst_id2_ll *i2_head) { + pst_mapi_object *mo_head = NULL; char *buf = NULL; size_t read_size = 0; pst_subblocks subblocks; - pst_num_array *na_ptr = NULL; + pst_mapi_object *mo_ptr = NULL; pst_block_offset_pointer block_offset1; pst_block_offset_pointer block_offset2; pst_block_offset_pointer block_offset3; pst_block_offset_pointer block_offset4; pst_block_offset_pointer block_offset5; pst_block_offset_pointer block_offset6; pst_block_offset_pointer block_offset7; int32_t x; int num_recs; int count_rec; int32_t num_list; int32_t cur_list; int block_type; uint32_t rec_size = 0; char* list_start; char* fr_ptr; char* to_ptr; char* ind2_end = NULL; char* ind2_ptr = NULL; pst_x_attrib_ll *mapptr; pst_block_hdr block_hdr; pst_table3_rec table3_rec; //for type 3 (0x0101) blocks struct { unsigned char seven_c; unsigned char item_count; uint16_t u1; uint16_t u2; uint16_t u3; uint16_t rec_size; uint32_t b_five_offset; uint32_t ind2_offset; uint16_t u7; uint16_t u8; } seven_c_blk; struct _type_d_rec { uint32_t id; uint32_t u1; } * type_d_rec; struct { uint16_t type; uint16_t ref_type; uint32_t value; } table_rec; //for type 1 (0xBCEC) blocks struct { uint16_t ref_type; uint16_t type; uint16_t ind2_off; uint8_t size; uint8_t slot; } table2_rec; //for type 2 (0x7CEC) blocks DEBUG_ENT("pst_parse_block"); if ((read_size = pst_ff_getIDblock_dec(pf, block_id, &buf)) == 0) { WARN(("Error reading block id %#"PRIx64"\n", block_id)); if (buf) free (buf); DEBUG_RET(); return NULL; } block_offset1.needfree = 0; block_offset2.needfree = 0; block_offset3.needfree = 0; block_offset4.needfree = 0; block_offset5.needfree = 0; block_offset6.needfree = 0; block_offset7.needfree = 0; memcpy(&block_hdr, buf, sizeof(block_hdr)); LE16_CPU(block_hdr.index_offset); LE16_CPU(block_hdr.type); LE32_CPU(block_hdr.offset); DEBUG_EMAIL(("block header (index_offset=%#hx, type=%#hx, offset=%#hx)\n", block_hdr.index_offset, block_hdr.type, block_hdr.offset)); if (block_hdr.index_offset == (uint16_t)0x0101) { //type 3 size_t i; char *b_ptr = buf + 8; subblocks.subblock_count = block_hdr.type; subblocks.subs = malloc(sizeof(pst_subblock) * subblocks.subblock_count); for (i=0; inext = na_head; - na_head = na_ptr; - // allocate an array of count num_recs to contain sizeof(pst_num_item) - na_ptr->items = (pst_num_item**) xmalloc(sizeof(pst_num_item)*num_list); - na_ptr->count_item = num_list; - na_ptr->orig_count = num_list; - na_ptr->count_array = (int32_t)num_recs; // each record will have a record of the total number of records - for (x=0; xitems[x] = NULL; + mo_ptr = (pst_mapi_object*) xmalloc(sizeof(pst_mapi_object)); + memset(mo_ptr, 0, sizeof(pst_mapi_object)); + mo_ptr->next = mo_head; + mo_head = mo_ptr; + // allocate an array of count num_recs to contain sizeof(pst_mapi_element) + mo_ptr->elements = (pst_mapi_element**) xmalloc(sizeof(pst_mapi_element)*num_list); + mo_ptr->count_elements = num_list; + mo_ptr->orig_count = num_list; + mo_ptr->count_objects = (int32_t)num_recs; // each record will have a record of the total number of records + for (x=0; xelements[x] = NULL; x = 0; - DEBUG_EMAIL(("going to read %i (%#x) items\n", na_ptr->count_item, na_ptr->count_item)); + DEBUG_EMAIL(("going to read %i (%#x) items\n", mo_ptr->count_elements, mo_ptr->count_elements)); fr_ptr = list_start; // initialize fr_ptr to the start of the list. for (cur_list=0; cur_list= (int)(table2_rec.ind2_off + table2_rec.size)) { size_t n = table2_rec.size; size_t m = sizeof(table_rec.value); if (n <= m) { memcpy(&table_rec.value, ind2_ptr + table2_rec.ind2_off, n); } else { value_pointer = ind2_ptr + table2_rec.ind2_off; value_size = n; } //LE32_CPU(table_rec.value); // done later, some may be order invariant } else { DEBUG_WARN (("Trying to read outside buffer, buffer size %#x, offset %#x, data size %#x\n", read_size, ind2_end-ind2_ptr+table2_rec.ind2_off, table2_rec.size)); } fr_ptr += sizeof(table2_rec); } else { WARN(("Missing code for block_type %i\n", block_type)); freeall(&subblocks, &block_offset1, &block_offset2, &block_offset3, &block_offset4, &block_offset5, &block_offset6, &block_offset7); - pst_free_list(na_head); + pst_free_list(mo_head); DEBUG_RET(); return NULL; } DEBUG_EMAIL(("reading block %i (type=%#x, ref_type=%#x, value=%#x)\n", x, table_rec.type, table_rec.ref_type, table_rec.value)); - if (!na_ptr->items[x]) { - na_ptr->items[x] = (pst_num_item*) xmalloc(sizeof(pst_num_item)); + if (!mo_ptr->elements[x]) { + mo_ptr->elements[x] = (pst_mapi_element*) xmalloc(sizeof(pst_mapi_element)); } - memset(na_ptr->items[x], 0, sizeof(pst_num_item)); //init it + memset(mo_ptr->elements[x], 0, sizeof(pst_mapi_element)); //init it // check here to see if the id of the attribute is a mapped one mapptr = pf->x_head; while (mapptr && (mapptr->map < table_rec.type)) mapptr = mapptr->next; if (mapptr && (mapptr->map == table_rec.type)) { if (mapptr->mytype == PST_MAP_ATTRIB) { - na_ptr->items[x]->id = *((uint32_t*)mapptr->data); - DEBUG_EMAIL(("Mapped attrib %#x to %#x\n", table_rec.type, na_ptr->items[x]->id)); + mo_ptr->elements[x]->mapi_id = *((uint32_t*)mapptr->data); + DEBUG_EMAIL(("Mapped attrib %#x to %#x\n", table_rec.type, mo_ptr->elements[x]->mapi_id)); } else if (mapptr->mytype == PST_MAP_HEADER) { DEBUG_EMAIL(("Internet Header mapping found %#x\n", table_rec.type)); - na_ptr->items[x]->id = (uint32_t)PST_ATTRIB_HEADER; - na_ptr->items[x]->extra = mapptr->data; + mo_ptr->elements[x]->mapi_id = (uint32_t)PST_ATTRIB_HEADER; + mo_ptr->elements[x]->extra = mapptr->data; } else { DEBUG_WARN(("Missing assertion failure\n")); // nothing, should be assertion failure here } } else { - na_ptr->items[x]->id = table_rec.type; + mo_ptr->elements[x]->mapi_id = table_rec.type; } - na_ptr->items[x]->type = 0; // checked later before it is set + mo_ptr->elements[x]->type = 0; // checked later before it is set /* Reference Types 0x0002 - Signed 16bit value 0x0003 - Signed 32bit value 0x0004 - 4-byte floating point 0x0005 - Floating point double 0x0006 - Signed 64-bit int 0x0007 - Application Time 0x000A - 32-bit error value 0x000B - Boolean (non-zero = true) 0x000D - Embedded Object 0x0014 - 8-byte signed integer (64-bit) 0x001E - Null terminated String 0x001F - Unicode string 0x0040 - Systime - Filetime structure 0x0048 - OLE Guid 0x0102 - Binary data 0x1003 - Array of 32bit values 0x1014 - Array of 64bit values 0x101E - Array of Strings 0x1102 - Array of Binary data */ if (table_rec.ref_type == (uint16_t)0x0002 || table_rec.ref_type == (uint16_t)0x0003 || table_rec.ref_type == (uint16_t)0x000b) { //contains 32 bits of data - na_ptr->items[x]->size = sizeof(int32_t); - na_ptr->items[x]->type = table_rec.ref_type; - na_ptr->items[x]->data = xmalloc(sizeof(int32_t)); - memcpy(na_ptr->items[x]->data, &(table_rec.value), sizeof(int32_t)); + mo_ptr->elements[x]->size = sizeof(int32_t); + mo_ptr->elements[x]->type = table_rec.ref_type; + mo_ptr->elements[x]->data = xmalloc(sizeof(int32_t)); + memcpy(mo_ptr->elements[x]->data, &(table_rec.value), sizeof(int32_t)); // are we missing an LE32_CPU() call here? table_rec.value is still // in the original order. } else if (table_rec.ref_type == (uint16_t)0x0005 || table_rec.ref_type == (uint16_t)0x000d || table_rec.ref_type == (uint16_t)0x0014 || table_rec.ref_type == (uint16_t)0x001e || table_rec.ref_type == (uint16_t)0x001f || table_rec.ref_type == (uint16_t)0x0040 || table_rec.ref_type == (uint16_t)0x0048 || table_rec.ref_type == (uint16_t)0x0102 || table_rec.ref_type == (uint16_t)0x1003 || table_rec.ref_type == (uint16_t)0x1014 || table_rec.ref_type == (uint16_t)0x101e || table_rec.ref_type == (uint16_t)0x101f || table_rec.ref_type == (uint16_t)0x1102) { //contains index reference to data LE32_CPU(table_rec.value); if (value_pointer) { // in a type 2 block, with a value that is more than 4 bytes // directly stored in this block. - na_ptr->items[x]->size = value_size; - na_ptr->items[x]->type = table_rec.ref_type; - na_ptr->items[x]->data = xmalloc(value_size); - memcpy(na_ptr->items[x]->data, value_pointer, value_size); + mo_ptr->elements[x]->size = value_size; + mo_ptr->elements[x]->type = table_rec.ref_type; + mo_ptr->elements[x]->data = xmalloc(value_size); + memcpy(mo_ptr->elements[x]->data, value_pointer, value_size); } else if (pst_getBlockOffsetPointer(pf, i2_head, &subblocks, table_rec.value, &block_offset7)) { if ((table_rec.value & 0xf) == (uint32_t)0xf) { DEBUG_WARN(("failed to get block offset for table_rec.value of %#x to be read later.\n", table_rec.value)); - na_ptr->items[x]->size = 0; - na_ptr->items[x]->data = NULL; - na_ptr->items[x]->type = table_rec.value; + mo_ptr->elements[x]->size = 0; + mo_ptr->elements[x]->data = NULL; + mo_ptr->elements[x]->type = table_rec.value; } else { if (table_rec.value) { DEBUG_WARN(("failed to get block offset for table_rec.value of %#x\n", table_rec.value)); } - na_ptr->count_item --; //we will be skipping a row + mo_ptr->count_elements --; //we will be skipping a row continue; } } else { value_size = (size_t)(block_offset7.to - block_offset7.from); - na_ptr->items[x]->size = value_size; - na_ptr->items[x]->type = table_rec.ref_type; - na_ptr->items[x]->data = xmalloc(value_size+1); - memcpy(na_ptr->items[x]->data, block_offset7.from, value_size); - na_ptr->items[x]->data[value_size] = '\0'; // it might be a string, null terminate it. + mo_ptr->elements[x]->size = value_size; + mo_ptr->elements[x]->type = table_rec.ref_type; + mo_ptr->elements[x]->data = xmalloc(value_size+1); + memcpy(mo_ptr->elements[x]->data, block_offset7.from, value_size); + mo_ptr->elements[x]->data[value_size] = '\0'; // it might be a string, null terminate it. } if (table_rec.ref_type == (uint16_t)0xd) { // there is still more to do for the type of 0xD embedded objects - type_d_rec = (struct _type_d_rec*) na_ptr->items[x]->data; + type_d_rec = (struct _type_d_rec*) mo_ptr->elements[x]->data; LE32_CPU(type_d_rec->id); - na_ptr->items[x]->size = pst_ff_getID2block(pf, type_d_rec->id, i2_head, &(na_ptr->items[x]->data)); - if (!na_ptr->items[x]->size){ + mo_ptr->elements[x]->size = pst_ff_getID2block(pf, type_d_rec->id, i2_head, &(mo_ptr->elements[x]->data)); + if (!mo_ptr->elements[x]->size){ DEBUG_WARN(("not able to read the ID2 data. Setting to be read later. %#x\n", type_d_rec->id)); - na_ptr->items[x]->type = type_d_rec->id; // fetch before freeing data, alias pointer - free(na_ptr->items[x]->data); - na_ptr->items[x]->data = NULL; + mo_ptr->elements[x]->type = type_d_rec->id; // fetch before freeing data, alias pointer + free(mo_ptr->elements[x]->data); + mo_ptr->elements[x]->data = NULL; } } if (table_rec.ref_type == (uint16_t)0x1f) { // there is more to do for the type 0x1f unicode strings size_t rc; static vbuf *strbuf = NULL; static vbuf *unibuf = NULL; if (!strbuf) strbuf=vballoc((size_t)1024); if (!unibuf) unibuf=vballoc((size_t)1024); // splint barfed on the following lines //VBUF_STATIC(strbuf, 1024); //VBUF_STATIC(unibuf, 1024); //need UTF-16 zero-termination - vbset(strbuf, na_ptr->items[x]->data, na_ptr->items[x]->size); + vbset(strbuf, mo_ptr->elements[x]->data, mo_ptr->elements[x]->size); vbappend(strbuf, "\0\0", (size_t)2); DEBUG_INDEX(("Iconv in:\n")); DEBUG_HEXDUMPC(strbuf->b, strbuf->dlen, 0x10); rc = vb_utf16to8(unibuf, strbuf->b, strbuf->dlen); if (rc == (size_t)-1) { free(unibuf->b); DEBUG_EMAIL(("Failed to convert utf-16 to utf-8\n")); } else { - free(na_ptr->items[x]->data); - na_ptr->items[x]->size = unibuf->dlen; - na_ptr->items[x]->data = xmalloc(unibuf->dlen); - memcpy(na_ptr->items[x]->data, unibuf->b, unibuf->dlen); + free(mo_ptr->elements[x]->data); + mo_ptr->elements[x]->size = unibuf->dlen; + mo_ptr->elements[x]->data = xmalloc(unibuf->dlen); + memcpy(mo_ptr->elements[x]->data, unibuf->b, unibuf->dlen); } DEBUG_INDEX(("Iconv out:\n")); - DEBUG_HEXDUMPC(na_ptr->items[x]->data, na_ptr->items[x]->size, 0x10); + DEBUG_HEXDUMPC(mo_ptr->elements[x]->data, mo_ptr->elements[x]->size, 0x10); } - if (na_ptr->items[x]->type == 0) na_ptr->items[x]->type = table_rec.ref_type; + if (mo_ptr->elements[x]->type == 0) mo_ptr->elements[x]->type = table_rec.ref_type; } else { WARN(("ERROR Unknown ref_type %#hx\n", table_rec.ref_type)); freeall(&subblocks, &block_offset1, &block_offset2, &block_offset3, &block_offset4, &block_offset5, &block_offset6, &block_offset7); - pst_free_list(na_head); + pst_free_list(mo_head); DEBUG_RET(); return NULL; } x++; } DEBUG_EMAIL(("increasing ind2_ptr by %i [%#x] bytes. Was %#x, Now %#x\n", rec_size, rec_size, ind2_ptr, ind2_ptr+rec_size)); ind2_ptr += rec_size; } freeall(&subblocks, &block_offset1, &block_offset2, &block_offset3, &block_offset4, &block_offset5, &block_offset6, &block_offset7); DEBUG_RET(); - return na_head; + return mo_head; } // This version of free does NULL check first #define SAFE_FREE(x) {if (x) free(x);} #define SAFE_FREE_STR(x) SAFE_FREE(x.str) // check if item->email is NULL, and init if so #define MALLOC_EMAIL(x) { if (!x->email) { x->email = (pst_item_email*) xmalloc(sizeof(pst_item_email)); memset(x->email, 0, sizeof(pst_item_email) );} } #define MALLOC_FOLDER(x) { if (!x->folder) { x->folder = (pst_item_folder*) xmalloc(sizeof(pst_item_folder)); memset(x->folder, 0, sizeof(pst_item_folder) );} } #define MALLOC_CONTACT(x) { if (!x->contact) { x->contact = (pst_item_contact*) xmalloc(sizeof(pst_item_contact)); memset(x->contact, 0, sizeof(pst_item_contact) );} } #define MALLOC_MESSAGESTORE(x) { if (!x->message_store) { x->message_store = (pst_item_message_store*) xmalloc(sizeof(pst_item_message_store)); memset(x->message_store, 0, sizeof(pst_item_message_store));} } #define MALLOC_JOURNAL(x) { if (!x->journal) { x->journal = (pst_item_journal*) xmalloc(sizeof(pst_item_journal)); memset(x->journal, 0, sizeof(pst_item_journal) );} } #define MALLOC_APPOINTMENT(x) { if (!x->appointment) { x->appointment = (pst_item_appointment*) xmalloc(sizeof(pst_item_appointment)); memset(x->appointment, 0, sizeof(pst_item_appointment) );} } // malloc space and copy the current item's data null terminated #define LIST_COPY(targ, type) { \ - targ = type realloc(targ, list->items[x]->size+1); \ - memcpy(targ, list->items[x]->data, list->items[x]->size); \ - memset(((char*)targ)+list->items[x]->size, 0, (size_t)1); \ + targ = type 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); \ } #define LIST_COPY_BOOL(label, targ) { \ - if (*(int16_t*)list->items[x]->data) { \ + if (*(int16_t*)list->elements[x]->data) { \ DEBUG_EMAIL((label" - True\n")); \ targ = 1; \ } else { \ DEBUG_EMAIL((label" - False\n")); \ targ = 0; \ } \ } #define LIST_COPY_EMAIL_BOOL(label, targ) { \ MALLOC_EMAIL(item); \ LIST_COPY_BOOL(label, targ) \ } #define LIST_COPY_CONTACT_BOOL(label, targ) { \ MALLOC_CONTACT(item); \ LIST_COPY_BOOL(label, targ) \ } #define LIST_COPY_APPT_BOOL(label, targ) { \ MALLOC_APPOINTMENT(item); \ LIST_COPY_BOOL(label, targ) \ } #define LIST_COPY_INT16_N(label, targ) { \ - memcpy(&(targ), list->items[x]->data, sizeof(targ)); \ + memcpy(&(targ), list->elements[x]->data, sizeof(targ)); \ LE16_CPU(targ); \ } #define LIST_COPY_INT16(label, targ) { \ LIST_COPY_INT16_N(label, targ); \ DEBUG_EMAIL((label" - %i %#x\n", (int)targ, (int)targ)); \ } #define LIST_COPY_INT32_N(label, targ) { \ - memcpy(&(targ), list->items[x]->data, sizeof(targ)); \ + memcpy(&(targ), list->elements[x]->data, sizeof(targ)); \ LE32_CPU(targ); \ } #define LIST_COPY_INT32(label, targ) { \ LIST_COPY_INT32_N(label, targ); \ DEBUG_EMAIL((label" - %i %#x\n", (int)targ, (int)targ)); \ } #define LIST_COPY_EMAIL_INT32(label, targ) { \ MALLOC_EMAIL(item); \ LIST_COPY_INT32(label, targ); \ } #define LIST_COPY_APPT_INT32(label, targ) { \ MALLOC_APPOINTMENT(item); \ LIST_COPY_INT32(label, targ); \ } #define LIST_COPY_FOLDER_INT32(label, targ) { \ MALLOC_FOLDER(item); \ LIST_COPY_INT32(label, targ); \ } #define LIST_COPY_STORE_INT32(label, targ) { \ MALLOC_MESSAGESTORE(item); \ LIST_COPY_INT32(label, targ); \ } #define LIST_COPY_ENUM(label, targ, delta, count, ...) { \ char *tlabels[] = {__VA_ARGS__}; \ LIST_COPY_INT32_N(label, targ); \ targ += delta; \ DEBUG_EMAIL((label" - %s [%i]\n", \ (((int)targ < 0) || ((int)targ >= count)) \ ? "**invalid" \ : tlabels[(int)targ], (int)targ)); \ } #define LIST_COPY_EMAIL_ENUM(label, targ, delta, count, ...) { \ MALLOC_EMAIL(item); \ LIST_COPY_ENUM(label, targ, delta, count, __VA_ARGS__); \ } #define LIST_COPY_APPT_ENUM(label, targ, delta, count, ...) { \ MALLOC_APPOINTMENT(item); \ LIST_COPY_ENUM(label, targ, delta, count, __VA_ARGS__); \ } #define LIST_COPY_ENUM16(label, targ, delta, count, ...) { \ char *tlabels[] = {__VA_ARGS__}; \ LIST_COPY_INT16_N(label, targ); \ targ += delta; \ DEBUG_EMAIL((label" - %s [%i]\n", \ (((int)targ < 0) || ((int)targ >= count)) \ ? "**invalid" \ : tlabels[(int)targ], (int)targ)); \ } #define LIST_COPY_CONTACT_ENUM16(label, targ, delta, count, ...) { \ MALLOC_CONTACT(item); \ LIST_COPY_ENUM16(label, targ, delta, count, __VA_ARGS__); \ } #define LIST_COPY_ENTRYID(label, targ) { \ MALLOC_MESSAGESTORE(item); \ LIST_COPY(targ, (pst_entryid*)); \ LE32_CPU(targ->u1); \ LE32_CPU(targ->id); \ DEBUG_EMAIL((label" u1=%#x, id=%#x\n", targ->u1, targ->id));\ } #define LIST_COPY_EMAIL_ENTRYID(label, targ) { \ MALLOC_EMAIL(item); \ LIST_COPY_ENTRYID(label, targ); \ } #define LIST_COPY_STORE_ENTRYID(label, targ) { \ MALLOC_MESSAGESTORE(item); \ LIST_COPY_ENTRYID(label, targ); \ } // malloc space and copy the current item's data null terminated // including the utf8 flag #define LIST_COPY_STR(label, targ) { \ LIST_COPY(targ.str, (char*)); \ - targ.is_utf8 = (list->items[x]->type == 0x1f) ? 1 : 0; \ + targ.is_utf8 = (list->elements[x]->type == 0x1f) ? 1 : 0; \ DEBUG_EMAIL((label" - unicode %d - %s\n", targ.is_utf8, targ.str)); \ } #define LIST_COPY_EMAIL_STR(label, targ) { \ MALLOC_EMAIL(item); \ LIST_COPY_STR(label, targ); \ } #define LIST_COPY_CONTACT_STR(label, targ) { \ MALLOC_CONTACT(item); \ LIST_COPY_STR(label, targ); \ } #define LIST_COPY_APPT_STR(label, targ) { \ MALLOC_APPOINTMENT(item); \ LIST_COPY_STR(label, targ); \ } #define LIST_COPY_JOURNAL_STR(label, targ) { \ MALLOC_JOURNAL(item); \ LIST_COPY_STR(label, targ); \ } // malloc space and copy the item filetime #define LIST_COPY_TIME(label, targ) { \ targ = (FILETIME*) realloc(targ, sizeof(FILETIME)); \ - memcpy(targ, list->items[x]->data, list->items[x]->size); \ + memcpy(targ, list->elements[x]->data, list->elements[x]->size); \ LE32_CPU(targ->dwLowDateTime); \ LE32_CPU(targ->dwHighDateTime); \ DEBUG_EMAIL((label" - %s", fileTimeToAscii(targ))); \ } #define LIST_COPY_EMAIL_TIME(label, targ) { \ MALLOC_EMAIL(item); \ LIST_COPY_TIME(label, targ); \ } #define LIST_COPY_CONTACT_TIME(label, targ) { \ MALLOC_CONTACT(item); \ LIST_COPY_TIME(label, targ); \ } #define LIST_COPY_APPT_TIME(label, targ) { \ MALLOC_APPOINTMENT(item); \ LIST_COPY_TIME(label, targ); \ } #define LIST_COPY_JOURNAL_TIME(label, targ) { \ MALLOC_JOURNAL(item); \ LIST_COPY_TIME(label, targ); \ } // malloc space and copy the current item's data and size #define LIST_COPY_SIZE(targ, type, mysize) { \ - mysize = list->items[x]->size; \ + mysize = list->elements[x]->size; \ if (mysize) { \ targ = type realloc(targ, mysize); \ - memcpy(targ, list->items[x]->data, mysize); \ + memcpy(targ, list->elements[x]->data, mysize); \ } \ else { \ SAFE_FREE(targ); \ targ = NULL; \ } \ } #define LIST_COPY_EMAIL_SIZE(label, targ, mysize) { \ MALLOC_EMAIL(item); \ LIST_COPY_SIZE(targ, (char*), mysize); \ DEBUG_EMAIL((label"\n")); \ } #define NULL_CHECK(x) { if (!x) { DEBUG_EMAIL(("NULL_CHECK: Null Found\n")); break;} } /** - * process the list of objects produced from parse_block() + * process the list of MAPI objects produced from parse_block() * - * @param list pointer to the list of objects from parse_block() + * @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. * the type of this item is generally set by the MAPI elements * from the list. * @param attach pointer to the list of attachment records. If * this is non-null, the length of the this attachment list - * must be at least as large as the length of the objects list. + * must be at least as large as the length of the MAPI objects list. * * @return 0 for ok, -1 for error. */ -int pst_process(pst_num_array *list, pst_item *item, pst_item_attach *attach) { +int pst_process(pst_mapi_object *list, pst_item *item, pst_item_attach *attach) { DEBUG_ENT("pst_process"); if (!item) { DEBUG_EMAIL(("item cannot be NULL.\n")); DEBUG_RET(); return -1; } while (list) { int32_t x; - for (x=0; xcount_item; x++) { + for (x=0; xcount_elements; x++) { int32_t t; pst_item_extra_field *ef; // check here to see if the id is one that is mapped. - DEBUG_EMAIL(("#%d - id: %#x type: %#x length: %#x\n", x, list->items[x]->id, list->items[x]->type, list->items[x]->size)); + DEBUG_EMAIL(("#%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->items[x]->id) { + switch (list->elements[x]->mapi_id) { case PST_ATTRIB_HEADER: // CUSTOM attribute for saying the Extra Headers - if (list->items[x]->extra) { + if (list->elements[x]->extra) { ef = (pst_item_extra_field*) xmalloc(sizeof(pst_item_extra_field)); memset(ef, 0, sizeof(pst_item_extra_field)); - ef->field_name = (char*) xmalloc(strlen(list->items[x]->extra)+1); - strcpy(ef->field_name, list->items[x]->extra); + ef->field_name = (char*) xmalloc(strlen(list->elements[x]->extra)+1); + strcpy(ef->field_name, list->elements[x]->extra); LIST_COPY(ef->value, (char*)); ef->next = item->extra_fields; item->extra_fields = ef; DEBUG_EMAIL(("Extra Field - \"%s\" = \"%s\"\n", ef->field_name, ef->value)); if (strcmp(ef->field_name, "content-type") == 0) { char *p = strstr(ef->value, "charset=\""); if (p) { p += 9; // skip over charset=" char *pp = strchr(p, '"'); if (pp) { *pp = '\0'; char *set = strdup(p); *pp = '"'; if (item->body_charset.str) free(item->body_charset.str); item->body_charset.str = set; item->body_charset.is_utf8 = 1; DEBUG_EMAIL(("body charset %s from content-type extra field\n", set)); } } } } else { DEBUG_EMAIL(("NULL extra field\n")); } break; case 0x0002: // PR_ALTERNATE_RECIPIENT_ALLOWED // If set to true, the sender allows this email to be autoforwarded LIST_COPY_EMAIL_BOOL("AutoForward allowed", item->email->autoforward); if (!item->email->autoforward) item->email->autoforward = -1; break; case 0x0003: // Extended Attributes table DEBUG_EMAIL(("Extended Attributes Table - NOT PROCESSED\n")); break; case 0x0017: // PR_IMPORTANCE - How important the sender deems it to be LIST_COPY_EMAIL_ENUM("Importance Level", item->email->importance, 0, 3, "Low", "Normal", "High"); break; case 0x001A: // PR_MESSAGE_CLASS Ascii type of messages - NOT FOLDERS // must be case insensitive LIST_COPY(item->ascii_type, (char*)); if (pst_strincmp("IPM.Note", item->ascii_type, 8) == 0) // the string begins with IPM.Note... item->type = PST_TYPE_NOTE; else if (pst_stricmp("IPM", item->ascii_type) == 0) // the whole string is just IPM item->type = PST_TYPE_NOTE; else if (pst_strincmp("IPM.Contact", item->ascii_type, 11) == 0) // the string begins with IPM.Contact... item->type = PST_TYPE_CONTACT; else if (pst_strincmp("REPORT.IPM.Note", item->ascii_type, 15) == 0) // the string begins with the above item->type = PST_TYPE_REPORT; else if (pst_strincmp("IPM.Activity", item->ascii_type, 12) == 0) item->type = PST_TYPE_JOURNAL; else if (pst_strincmp("IPM.Appointment", item->ascii_type, 15) == 0) item->type = PST_TYPE_APPOINTMENT; else if (pst_strincmp("IPM.Task", item->ascii_type, 8) == 0) item->type = PST_TYPE_TASK; else item->type = PST_TYPE_OTHER; DEBUG_EMAIL(("IPM.x - %s\n", item->ascii_type)); break; case 0x0023: // PR_ORIGINATOR_DELIVERY_REPORT_REQUESTED // set if the sender wants a delivery report from all recipients LIST_COPY_EMAIL_BOOL("Global Delivery Report", item->email->delivery_report); break; case 0x0026: // PR_PRIORITY // Priority of a message // -1 NonUrgent // 0 Normal // 1 Urgent LIST_COPY_EMAIL_ENUM("Priority", item->email->priority, 1, 3, "NonUrgent", "Normal", "Urgent"); break; case 0x0029: // PR_READ_RECEIPT_REQUESTED LIST_COPY_EMAIL_BOOL("Read Receipt", item->email->read_receipt); break; case 0x002B: // PR_RECIPIENT_REASSIGNMENT_PROHIBITED LIST_COPY_BOOL("Reassignment Prohibited (Private)", item->private_member); break; case 0x002E: // PR_ORIGINAL_SENSITIVITY - the sensitivity of the message before being replied to or forwarded LIST_COPY_EMAIL_ENUM("Original Sensitivity", item->email->orig_sensitivity, 0, 4, "None", "Personal", "Private", "Company Confidential"); break; case 0x0032: // PR_REPORT_TIME LIST_COPY_EMAIL_TIME("Report time", item->email->report_time); break; case 0x0036: // PR_SENSITIVITY - sender's opinion of the sensitivity of an email LIST_COPY_EMAIL_ENUM("Sensitivity", item->email->sensitivity, 0, 4, "None", "Personal", "Private", "Company Confidential"); break; case 0x0037: // PR_SUBJECT raw subject { int off = 0; - if ((list->items[x]->size > 2) && (((uint8_t)list->items[x]->data[0]) < 0x20)) { + if ((list->elements[x]->size > 2) && (((uint8_t)list->elements[x]->data[0]) < 0x20)) { off = 2; } - list->items[x]->data += off; - list->items[x]->size -= off; + list->elements[x]->data += off; + list->elements[x]->size -= off; LIST_COPY_STR("Raw Subject", item->subject); - list->items[x]->size += off; - list->items[x]->data -= off; + list->elements[x]->size += off; + list->elements[x]->data -= off; } break; case 0x0039: // PR_CLIENT_SUBMIT_TIME Date Email Sent/Created LIST_COPY_EMAIL_TIME("Date sent", item->email->sent_date); break; case 0x003B: // PR_SENT_REPRESENTING_SEARCH_KEY Sender address 1 LIST_COPY_EMAIL_STR("Sent on behalf of address 1", item->email->outlook_sender); break; case 0x003F: // PR_RECEIVED_BY_ENTRYID Structure containing Recipient DEBUG_EMAIL(("Recipient Structure 1 -- NOT HANDLED\n")); break; case 0x0040: // PR_RECEIVED_BY_NAME Name of Recipient Structure DEBUG_EMAIL(("Received By Name 1 -- NOT HANDLED\n")); break; case 0x0041: // PR_SENT_REPRESENTING_ENTRYID Structure containing Sender DEBUG_EMAIL(("Sent on behalf of Structure 1 -- NOT HANDLED\n")); break; case 0x0042: // PR_SENT_REPRESENTING_NAME LIST_COPY_EMAIL_STR("Sent on behalf of", item->email->outlook_sender_name); break; case 0x0043: // PR_RCVD_REPRESENTING_ENTRYID Recipient Structure 2 DEBUG_EMAIL(("Received on behalf of Structure -- NOT HANDLED\n")); break; case 0x0044: // PR_RCVD_REPRESENTING_NAME LIST_COPY_EMAIL_STR("Received on behalf of", item->email->outlook_recipient_name); break; case 0x004F: // PR_REPLY_RECIPIENT_ENTRIES Reply-To Structure DEBUG_EMAIL(("Reply-To Structure -- NOT HANDLED\n")); break; case 0x0050: // PR_REPLY_RECIPIENT_NAMES Name of Reply-To Structure LIST_COPY_EMAIL_STR("Reply-To", item->email->reply_to); break; case 0x0051: // PR_RECEIVED_BY_SEARCH_KEY Recipient Address 1 LIST_COPY_EMAIL_STR("Recipient's Address 1", item->email->outlook_recipient); break; case 0x0052: // PR_RCVD_REPRESENTING_SEARCH_KEY Recipient Address 2 LIST_COPY_EMAIL_STR("Recipient's Address 2", item->email->outlook_recipient2); break; case 0x0057: // PR_MESSAGE_TO_ME // this user is listed explicitly in the TO address LIST_COPY_EMAIL_BOOL("My address in TO field", item->email->message_to_me); break; case 0x0058: // PR_MESSAGE_CC_ME // this user is listed explicitly in the CC address LIST_COPY_EMAIL_BOOL("My address in CC field", item->email->message_cc_me); break; case 0x0059: // PR_MESSAGE_RECIP_ME // this user appears in TO, CC or BCC address list LIST_COPY_EMAIL_BOOL("Message addressed to me", item->email->message_recip_me); break; case 0x0063: // PR_RESPONSE_REQUESTED LIST_COPY_BOOL("Response requested", item->response_requested); break; case 0x0064: // PR_SENT_REPRESENTING_ADDRTYPE Access method for Sender Address LIST_COPY_EMAIL_STR("Sent on behalf of address type", item->email->sender_access); break; case 0x0065: // PR_SENT_REPRESENTING_EMAIL_ADDRESS Sender Address LIST_COPY_EMAIL_STR("Sent on behalf of address", item->email->sender_address); break; case 0x0070: // PR_CONVERSATION_TOPIC Processed Subject LIST_COPY_EMAIL_STR("Processed Subject (Conversation Topic)", item->email->processed_subject); break; case 0x0071: // PR_CONVERSATION_INDEX LIST_COPY_EMAIL_INT32("Conversation Index", item->email->conversation_index); break; case 0x0072: // PR_ORIGINAL_DISPLAY_BCC LIST_COPY_EMAIL_STR("Original display bcc", item->email->original_bcc); break; case 0x0073: // PR_ORIGINAL_DISPLAY_CC LIST_COPY_EMAIL_STR("Original display cc", item->email->original_cc); break; case 0x0074: // PR_ORIGINAL_DISPLAY_TO LIST_COPY_EMAIL_STR("Original display to", item->email->original_to); break; case 0x0075: // PR_RECEIVED_BY_ADDRTYPE Recipient Access Method LIST_COPY_EMAIL_STR("Received by Address type", item->email->recip_access); break; case 0x0076: // PR_RECEIVED_BY_EMAIL_ADDRESS Recipient Address LIST_COPY_EMAIL_STR("Received by Address", item->email->recip_address); break; case 0x0077: // PR_RCVD_REPRESENTING_ADDRTYPE Recipient Access Method 2 LIST_COPY_EMAIL_STR("Received on behalf of Address type", item->email->recip2_access); break; case 0x0078: // PR_RCVD_REPRESENTING_EMAIL_ADDRESS Recipient Address 2 LIST_COPY_EMAIL_STR("Received on behalf of Address", item->email->recip2_address); break; case 0x007D: // PR_TRANSPORT_MESSAGE_HEADERS Internet Header LIST_COPY_EMAIL_STR("Internet Header", item->email->header); break; case 0x0C04: // PR_NDR_REASON_CODE LIST_COPY_EMAIL_INT32("NDR reason code", item->email->ndr_reason_code); break; case 0x0C05: // PR_NDR_DIAG_CODE LIST_COPY_EMAIL_INT32("NDR diag code", item->email->ndr_diag_code); break; case 0x0C06: // PR_NON_RECEIPT_NOTIFICATION_REQUESTED DEBUG_EMAIL(("Non-Receipt Notification Requested - (ignored) - ")); break; case 0x0C17: // PR_REPLY_REQUESTED LIST_COPY_EMAIL_BOOL("Reply Requested", item->email->reply_requested); break; case 0x0C19: // PR_SENDER_ENTRYID Sender Structure 2 DEBUG_EMAIL(("Sender Structure 2 -- NOT HANDLED\n")); break; case 0x0C1A: // PR_SENDER_NAME Name of Sender Structure 2 DEBUG_EMAIL(("Name of Sender Structure 2 -- NOT HANDLED\n")); break; case 0x0C1B: // PR_SUPPLEMENTARY_INFO LIST_COPY_EMAIL_STR("Supplementary info", item->email->supplementary_info); break; case 0x0C1D: // PR_SENDER_SEARCH_KEY Name of Sender Address 2 LIST_COPY_EMAIL_STR("Name of Sender Address 2 (Sender search key)", item->email->outlook_sender2); break; case 0x0C1E: // PR_SENDER_ADDRTYPE Sender Address 2 access method LIST_COPY_EMAIL_STR("Sender Address type", item->email->sender2_access); break; case 0x0C1F: // PR_SENDER_EMAIL_ADDRESS Sender Address 2 LIST_COPY_EMAIL_STR("Sender Address", item->email->sender2_address); break; case 0x0C20: // PR_NDR_STATUS_CODE LIST_COPY_EMAIL_INT32("NDR status code", item->email->ndr_status_code); break; case 0x0E01: // PR_DELETE_AFTER_SUBMIT LIST_COPY_EMAIL_BOOL("Delete after submit", item->email->delete_after_submit); break; case 0x0E02: // PR_DISPLAY_BCC BCC Addresses LIST_COPY_EMAIL_STR("Display BCC Addresses", item->email->bcc_address); break; case 0x0E03: // PR_DISPLAY_CC CC Addresses LIST_COPY_EMAIL_STR("Display CC Addresses", item->email->cc_address); break; case 0x0E04: // PR_DISPLAY_TO Address Sent-To LIST_COPY_EMAIL_STR("Display Sent-To Address", item->email->sentto_address); break; case 0x0E06: // PR_MESSAGE_DELIVERY_TIME Date 3 - Email Arrival Date LIST_COPY_EMAIL_TIME("Date 3 (Delivery Time)", item->email->arrival_date); break; case 0x0E07: // PR_MESSAGE_FLAGS Email Flag // 0x01 - Read // 0x02 - Unmodified // 0x04 - Submit // 0x08 - Unsent // 0x10 - Has Attachments // 0x20 - From Me // 0x40 - Associated // 0x80 - Resend // 0x100 - RN Pending // 0x200 - NRN Pending LIST_COPY_EMAIL_INT32("Message Flags", item->email->flag); break; case 0x0E08: // PR_MESSAGE_SIZE Total size of a message object - LIST_COPY_EMAIL_INT32("Message Size", item->message_size); + LIST_COPY_INT32("Message Size", item->message_size); break; case 0x0E0A: // PR_SENTMAIL_ENTRYID // folder that this message is sent to after submission LIST_COPY_EMAIL_ENTRYID("Sentmail EntryID", item->email->sentmail_folder); break; case 0x0E1F: // PR_RTF_IN_SYNC // True means that the rtf version is same as text body // False means rtf version is more up-to-date than text body // if this value doesn't exist, text body is more up-to-date than rtf and // cannot update to the rtf LIST_COPY_EMAIL_BOOL("Compressed RTF in Sync", item->email->rtf_in_sync); break; case 0x0E20: // PR_ATTACH_SIZE binary Attachment data in record DEBUG_EMAIL(("Attachment Size - ")); NULL_CHECK(attach); LIST_COPY_INT32("Attachment Size", t); attach->size = (size_t)t; break; case 0x0FF9: // PR_RECORD_KEY Record Header 1 DEBUG_EMAIL(("Record Key 1 - ")); LIST_COPY(item->record_key, (char*)); - item->record_key_size = list->items[x]->size; + item->record_key_size = list->elements[x]->size; DEBUG_EMAIL_HEXPRINT(item->record_key, item->record_key_size); DEBUG_EMAIL(("\n")); break; case 0x1000: // PR_BODY - LIST_COPY_EMAIL_STR("Plain Text body", item->body); + LIST_COPY_STR("Plain Text body", item->body); break; case 0x1001: // PR_REPORT_TEXT LIST_COPY_EMAIL_STR("Report Text", item->email->report_text); break; case 0x1006: // PR_RTF_SYNC_BODY_CRC LIST_COPY_EMAIL_INT32("RTF Sync Body CRC", item->email->rtf_body_crc); break; case 0x1007: // PR_RTF_SYNC_BODY_COUNT // a count of the *significant* charcters in the rtf body. Doesn't count // whitespace and other ignorable characters LIST_COPY_EMAIL_INT32("RTF Sync Body character count", item->email->rtf_body_char_count); break; case 0x1008: // PR_RTF_SYNC_BODY_TAG // the first couple of lines of RTF body so that after modification, then beginning can // once again be found LIST_COPY_EMAIL_STR("RTF Sync body tag", item->email->rtf_body_tag); break; case 0x1009: // PR_RTF_COMPRESSED - rtf data is lzw compressed LIST_COPY_EMAIL_SIZE("RTF Compressed body", item->email->rtf_compressed, item->email->rtf_compressed_size); break; case 0x1010: // PR_RTF_SYNC_PREFIX_COUNT // a count of the ignored characters before the first significant character LIST_COPY_EMAIL_INT32("RTF whitespace prefix count", item->email->rtf_ws_prefix_count); break; case 0x1011: // PR_RTF_SYNC_TRAILING_COUNT // a count of the ignored characters after the last significant character LIST_COPY_EMAIL_INT32("RTF whitespace tailing count", item->email->rtf_ws_trailing_count); break; case 0x1013: // HTML body LIST_COPY_EMAIL_STR("HTML body", item->email->htmlbody); break; case 0x1035: // Message ID LIST_COPY_EMAIL_STR("Message ID", item->email->messageid); break; case 0x1042: // in-reply-to LIST_COPY_EMAIL_STR("In-Reply-To", item->email->in_reply_to); break; case 0x1046: // Return Path - this seems to be the message-id of the rfc822 mail that is being returned LIST_COPY_EMAIL_STR("Return Path", item->email->return_path_address); break; case 0x3001: // PR_DISPLAY_NAME File As LIST_COPY_STR("Display Name", item->file_as); break; case 0x3002: // PR_ADDRTYPE LIST_COPY_CONTACT_STR("Address Type", item->contact->address1_transport); break; case 0x3003: // PR_EMAIL_ADDRESS LIST_COPY_CONTACT_STR("Contact email Address", item->contact->address1); break; case 0x3004: // PR_COMMENT Comment for item - usually folders LIST_COPY_STR("Comment", item->comment); break; case 0x3007: // PR_CREATION_TIME Date 4 - Creation Date? - LIST_COPY_EMAIL_TIME("Date 4 (Item Creation Date)", item->create_date); + LIST_COPY_TIME("Date 4 (Item Creation Date)", item->create_date); break; case 0x3008: // PR_LAST_MODIFICATION_TIME Date 5 - Modify Date - LIST_COPY_EMAIL_TIME("Date 5 (Modify Date)", item->modify_date); + LIST_COPY_TIME("Date 5 (Modify Date)", item->modify_date); break; case 0x300B: // PR_SEARCH_KEY Record Header 2 DEBUG_EMAIL(("Record Search 2 -- NOT HANDLED\n")); break; case 0x35DF: // PR_VALID_FOLDER_MASK // States which folders are valid for this message store // FOLDER_IPM_SUBTREE_VALID 0x1 // FOLDER_IPM_INBOX_VALID 0x2 // FOLDER_IPM_OUTBOX_VALID 0x4 // FOLDER_IPM_WASTEBOX_VALID 0x8 // FOLDER_IPM_SENTMAIL_VALID 0x10 // FOLDER_VIEWS_VALID 0x20 // FOLDER_COMMON_VIEWS_VALID 0x40 // FOLDER_FINDER_VALID 0x80 LIST_COPY_STORE_INT32("Valid Folder Mask", item->message_store->valid_mask); break; case 0x35E0: // PR_IPM_SUBTREE_ENTRYID Top of Personal Folder Record LIST_COPY_STORE_ENTRYID("Top of Personal Folder Record", item->message_store->top_of_personal_folder); break; case 0x35E2: // PR_IPM_OUTBOX_ENTRYID LIST_COPY_STORE_ENTRYID("Default Outbox Folder record", item->message_store->default_outbox_folder); break; case 0x35E3: // PR_IPM_WASTEBASKET_ENTRYID LIST_COPY_STORE_ENTRYID("Deleted Items Folder record", item->message_store->deleted_items_folder); break; case 0x35E4: // PR_IPM_SENTMAIL_ENTRYID LIST_COPY_STORE_ENTRYID("Sent Items Folder record", item->message_store->sent_items_folder); break; case 0x35E5: // PR_VIEWS_ENTRYID LIST_COPY_STORE_ENTRYID("User Views Folder record", item->message_store->user_views_folder); break; case 0x35E6: // PR_COMMON_VIEWS_ENTRYID LIST_COPY_STORE_ENTRYID("Common View Folder record", item->message_store->common_view_folder); break; case 0x35E7: // PR_FINDER_ENTRYID LIST_COPY_STORE_ENTRYID("Search Root Folder record", item->message_store->search_root_folder); break; case 0x3602: // PR_CONTENT_COUNT Number of emails stored in a folder LIST_COPY_FOLDER_INT32("Folder Email Count", item->folder->email_count); break; case 0x3603: // PR_CONTENT_UNREAD Number of unread emails LIST_COPY_FOLDER_INT32("Unread Email Count", item->folder->unseen_email_count); break; case 0x360A: // PR_SUBFOLDERS Has children MALLOC_FOLDER(item); LIST_COPY_BOOL("Has Subfolders", item->folder->subfolder); break; case 0x3613: // PR_CONTAINER_CLASS IPF.x DEBUG_EMAIL(("IPF.x - ")); LIST_COPY(item->ascii_type, (char*)); if (strncmp("IPF.Note", item->ascii_type, 8) == 0) item->type = PST_TYPE_NOTE; else if (strncmp("IPF.Contact", item->ascii_type, 11) == 0) item->type = PST_TYPE_CONTACT; else if (strncmp("IPF.Journal", item->ascii_type, 11) == 0) item->type = PST_TYPE_JOURNAL; else if (strncmp("IPF.Appointment", item->ascii_type, 15) == 0) item->type = PST_TYPE_APPOINTMENT; else if (strncmp("IPF.StickyNote", item->ascii_type, 14) == 0) item->type = PST_TYPE_STICKYNOTE; else if (strncmp("IPF.Task", item->ascii_type, 8) == 0) item->type = PST_TYPE_TASK; else item->type = PST_TYPE_OTHER; DEBUG_EMAIL(("%s [%i]\n", item->ascii_type, item->type)); break; case 0x3617: // PR_ASSOC_CONTENT_COUNT // associated content are items that are attached to this folder // but are hidden from users LIST_COPY_FOLDER_INT32("Associate Content count", item->folder->assoc_count); break; case 0x3701: // PR_ATTACH_DATA_OBJ binary data of attachment - DEBUG_EMAIL(("Binary Data [Size %i] - ", list->items[x]->size)); + DEBUG_EMAIL(("Binary Data [Size %i] - ", list->elements[x]->size)); NULL_CHECK(attach); - if (!list->items[x]->data) { //special case - attach->id2_val = list->items[x]->type; + if (!list->elements[x]->data) { //special case + attach->id2_val = list->elements[x]->type; DEBUG_EMAIL(("Seen a Reference. The data hasn't been loaded yet. [%#"PRIx64"][%#x]\n", - attach->id2_val, list->items[x]->type)); + attach->id2_val, list->elements[x]->type)); } else { LIST_COPY(attach->data, (char*)); - attach->size = list->items[x]->size; + attach->size = list->elements[x]->size; DEBUG_EMAIL(("NOT PRINTED\n")); } break; case 0x3704: // PR_ATTACH_FILENAME Attachment filename (8.3) NULL_CHECK(attach); LIST_COPY_STR("Attachment Filename", attach->filename1); break; case 0x3705: // PR_ATTACH_METHOD NULL_CHECK(attach); LIST_COPY_ENUM("Attachment method", attach->method, 0, 7, "No Attachment", "Attach By Value", "Attach By Reference", "Attach by Reference Resolve", "Attach by Reference Only", "Embedded Message", "OLE"); break; case 0x3707: // PR_ATTACH_LONG_FILENAME Attachment filename (long?) NULL_CHECK(attach); LIST_COPY_STR("Attachment Filename long", attach->filename2); break; case 0x370B: // PR_RENDERING_POSITION // position in characters that the attachment appears in the plain text body NULL_CHECK(attach); LIST_COPY_INT32("Attachment Position", attach->position); break; case 0x370E: // PR_ATTACH_MIME_TAG Mime type of encoding NULL_CHECK(attach); LIST_COPY_STR("Attachment mime encoding", attach->mimetype); break; case 0x3710: // PR_ATTACH_MIME_SEQUENCE // sequence number for mime parts. Includes body NULL_CHECK(attach); LIST_COPY_INT32("Attachment Mime Sequence", attach->sequence); break; case 0x3A00: // PR_ACCOUNT LIST_COPY_CONTACT_STR("Contact's Account name", item->contact->account_name); break; case 0x3A01: // PR_ALTERNATE_RECIPIENT DEBUG_EMAIL(("Contact Alternate Recipient - NOT PROCESSED\n")); break; case 0x3A02: // PR_CALLBACK_TELEPHONE_NUMBER LIST_COPY_CONTACT_STR("Callback telephone number", item->contact->callback_phone); break; case 0x3A03: // PR_CONVERSION_PROHIBITED LIST_COPY_EMAIL_BOOL("Message Conversion Prohibited", item->email->conversion_prohibited); break; case 0x3A05: // PR_GENERATION suffix LIST_COPY_CONTACT_STR("Contacts Suffix", item->contact->suffix); break; case 0x3A06: // PR_GIVEN_NAME Contact's first name LIST_COPY_CONTACT_STR("Contacts First Name", item->contact->first_name); break; case 0x3A07: // PR_GOVERNMENT_ID_NUMBER LIST_COPY_CONTACT_STR("Contacts Government ID Number", item->contact->gov_id); break; case 0x3A08: // PR_BUSINESS_TELEPHONE_NUMBER LIST_COPY_CONTACT_STR("Business Telephone Number", item->contact->business_phone); break; case 0x3A09: // PR_HOME_TELEPHONE_NUMBER LIST_COPY_CONTACT_STR("Home Telephone Number", item->contact->home_phone); break; case 0x3A0A: // PR_INITIALS Contact's Initials LIST_COPY_CONTACT_STR("Contacts Initials", item->contact->initials); break; case 0x3A0B: // PR_KEYWORD LIST_COPY_CONTACT_STR("Keyword", item->contact->keyword); break; case 0x3A0C: // PR_LANGUAGE LIST_COPY_CONTACT_STR("Contact's Language", item->contact->language); break; case 0x3A0D: // PR_LOCATION LIST_COPY_CONTACT_STR("Contact's Location", item->contact->location); break; case 0x3A0E: // PR_MAIL_PERMISSION - Can the recipient receive and send email LIST_COPY_CONTACT_BOOL("Mail Permission", item->contact->mail_permission); break; case 0x3A0F: // PR_MHS_COMMON_NAME LIST_COPY_CONTACT_STR("MHS Common Name", item->contact->common_name); break; case 0x3A10: // PR_ORGANIZATIONAL_ID_NUMBER LIST_COPY_CONTACT_STR("Organizational ID #", item->contact->org_id); break; case 0x3A11: // PR_SURNAME Contact's Surname LIST_COPY_CONTACT_STR("Contacts Surname", item->contact->surname); break; case 0x3A12: // PR_ORIGINAL_ENTRY_ID DEBUG_EMAIL(("Original Entry ID - NOT PROCESSED\n")); break; case 0x3A13: // PR_ORIGINAL_DISPLAY_NAME DEBUG_EMAIL(("Original Display Name - NOT PROCESSED\n")); break; case 0x3A14: // PR_ORIGINAL_SEARCH_KEY DEBUG_EMAIL(("Original Search Key - NOT PROCESSED\n")); break; case 0x3A15: // PR_POSTAL_ADDRESS LIST_COPY_CONTACT_STR("Default Postal Address", item->contact->def_postal_address); break; case 0x3A16: // PR_COMPANY_NAME LIST_COPY_CONTACT_STR("Company Name", item->contact->company_name); break; case 0x3A17: // PR_TITLE - Job Title LIST_COPY_CONTACT_STR("Job Title", item->contact->job_title); break; case 0x3A18: // PR_DEPARTMENT_NAME LIST_COPY_CONTACT_STR("Department Name", item->contact->department); break; case 0x3A19: // PR_OFFICE_LOCATION LIST_COPY_CONTACT_STR("Office Location", item->contact->office_loc); break; case 0x3A1A: // PR_PRIMARY_TELEPHONE_NUMBER LIST_COPY_CONTACT_STR("Primary Telephone", item->contact->primary_phone); break; case 0x3A1B: // PR_BUSINESS2_TELEPHONE_NUMBER LIST_COPY_CONTACT_STR("Business Phone Number 2", item->contact->business_phone2); break; case 0x3A1C: // PR_MOBILE_TELEPHONE_NUMBER LIST_COPY_CONTACT_STR("Mobile Phone Number", item->contact->mobile_phone); break; case 0x3A1D: // PR_RADIO_TELEPHONE_NUMBER LIST_COPY_CONTACT_STR("Radio Phone Number", item->contact->radio_phone); break; case 0x3A1E: // PR_CAR_TELEPHONE_NUMBER LIST_COPY_CONTACT_STR("Car Phone Number", item->contact->car_phone); break; case 0x3A1F: // PR_OTHER_TELEPHONE_NUMBER LIST_COPY_CONTACT_STR("Other Phone Number", item->contact->other_phone); break; case 0x3A20: // PR_TRANSMITTABLE_DISPLAY_NAME LIST_COPY_CONTACT_STR("Transmittable Display Name", item->contact->transmittable_display_name); break; case 0x3A21: // PR_PAGER_TELEPHONE_NUMBER LIST_COPY_CONTACT_STR("Pager Phone Number", item->contact->pager_phone); break; case 0x3A22: // PR_USER_CERTIFICATE DEBUG_EMAIL(("User Certificate - NOT PROCESSED")); break; case 0x3A23: // PR_PRIMARY_FAX_NUMBER LIST_COPY_CONTACT_STR("Primary Fax Number", item->contact->primary_fax); break; case 0x3A24: // PR_BUSINESS_FAX_NUMBER LIST_COPY_CONTACT_STR("Business Fax Number", item->contact->business_fax); break; case 0x3A25: // PR_HOME_FAX_NUMBER LIST_COPY_CONTACT_STR("Home Fax Number", item->contact->home_fax); break; case 0x3A26: // PR_BUSINESS_ADDRESS_COUNTRY LIST_COPY_CONTACT_STR("Business Address Country", item->contact->business_country); break; case 0x3A27: // PR_BUSINESS_ADDRESS_CITY LIST_COPY_CONTACT_STR("Business Address City", item->contact->business_city); break; case 0x3A28: // PR_BUSINESS_ADDRESS_STATE_OR_PROVINCE LIST_COPY_CONTACT_STR("Business Address State", item->contact->business_state); break; case 0x3A29: // PR_BUSINESS_ADDRESS_STREET LIST_COPY_CONTACT_STR("Business Address Street", item->contact->business_street); break; case 0x3A2A: // PR_BUSINESS_POSTAL_CODE LIST_COPY_CONTACT_STR("Business Postal Code", item->contact->business_postal_code); break; case 0x3A2B: // PR_BUSINESS_PO_BOX LIST_COPY_CONTACT_STR("Business PO Box", item->contact->business_po_box); break; case 0x3A2C: // PR_TELEX_NUMBER LIST_COPY_CONTACT_STR("Telex Number", item->contact->telex); break; case 0x3A2D: // PR_ISDN_NUMBER LIST_COPY_CONTACT_STR("ISDN Number", item->contact->isdn_phone); break; case 0x3A2E: // PR_ASSISTANT_TELEPHONE_NUMBER LIST_COPY_CONTACT_STR("Assistant Phone Number", item->contact->assistant_phone); break; case 0x3A2F: // PR_HOME2_TELEPHONE_NUMBER LIST_COPY_CONTACT_STR("Home Phone 2", item->contact->home_phone2); break; case 0x3A30: // PR_ASSISTANT LIST_COPY_CONTACT_STR("Assistant's Name", item->contact->assistant_name); break; case 0x3A40: // PR_SEND_RICH_INFO LIST_COPY_CONTACT_BOOL("Can receive Rich Text", item->contact->rich_text); break; case 0x3A41: // PR_WEDDING_ANNIVERSARY LIST_COPY_CONTACT_TIME("Wedding Anniversary", item->contact->wedding_anniversary); break; case 0x3A42: // PR_BIRTHDAY LIST_COPY_CONTACT_TIME("Birthday", item->contact->birthday); break; case 0x3A43: // PR_HOBBIES LIST_COPY_CONTACT_STR("Hobbies", item->contact->hobbies); break; case 0x3A44: // PR_MIDDLE_NAME LIST_COPY_CONTACT_STR("Middle Name", item->contact->middle_name); break; case 0x3A45: // PR_DISPLAY_NAME_PREFIX LIST_COPY_CONTACT_STR("Display Name Prefix (Title)", item->contact->display_name_prefix); break; case 0x3A46: // PR_PROFESSION LIST_COPY_CONTACT_STR("Profession", item->contact->profession); break; case 0x3A47: // PR_PREFERRED_BY_NAME LIST_COPY_CONTACT_STR("Preferred By Name", item->contact->pref_name); break; case 0x3A48: // PR_SPOUSE_NAME LIST_COPY_CONTACT_STR("Spouse's Name", item->contact->spouse_name); break; case 0x3A49: // PR_COMPUTER_NETWORK_NAME LIST_COPY_CONTACT_STR("Computer Network Name", item->contact->computer_name); break; case 0x3A4A: // PR_CUSTOMER_ID LIST_COPY_CONTACT_STR("Customer ID", item->contact->customer_id); break; case 0x3A4B: // PR_TTYTDD_PHONE_NUMBER LIST_COPY_CONTACT_STR("TTY/TDD Phone", item->contact->ttytdd_phone); break; case 0x3A4C: // PR_FTP_SITE LIST_COPY_CONTACT_STR("Ftp Site", item->contact->ftp_site); break; case 0x3A4D: // PR_GENDER LIST_COPY_CONTACT_ENUM16("Gender", item->contact->gender, 0, 3, "Unspecified", "Female", "Male"); break; case 0x3A4E: // PR_MANAGER_NAME LIST_COPY_CONTACT_STR("Manager's Name", item->contact->manager_name); break; case 0x3A4F: // PR_NICKNAME LIST_COPY_CONTACT_STR("Nickname", item->contact->nickname); break; case 0x3A50: // PR_PERSONAL_HOME_PAGE LIST_COPY_CONTACT_STR("Personal Home Page", item->contact->personal_homepage); break; case 0x3A51: // PR_BUSINESS_HOME_PAGE LIST_COPY_CONTACT_STR("Business Home Page", item->contact->business_homepage); break; case 0x3A57: // PR_COMPANY_MAIN_PHONE_NUMBER LIST_COPY_CONTACT_STR("Company Main Phone", item->contact->company_main_phone); break; case 0x3A58: // PR_CHILDRENS_NAMES DEBUG_EMAIL(("Children's Names - NOT PROCESSED\n")); break; case 0x3A59: // PR_HOME_ADDRESS_CITY LIST_COPY_CONTACT_STR("Home Address City", item->contact->home_city); break; case 0x3A5A: // PR_HOME_ADDRESS_COUNTRY LIST_COPY_CONTACT_STR("Home Address Country", item->contact->home_country); break; case 0x3A5B: // PR_HOME_ADDRESS_POSTAL_CODE LIST_COPY_CONTACT_STR("Home Address Postal Code", item->contact->home_postal_code); break; case 0x3A5C: // PR_HOME_ADDRESS_STATE_OR_PROVINCE LIST_COPY_CONTACT_STR("Home Address State or Province", item->contact->home_state); break; case 0x3A5D: // PR_HOME_ADDRESS_STREET LIST_COPY_CONTACT_STR("Home Address Street", item->contact->home_street); break; case 0x3A5E: // PR_HOME_ADDRESS_POST_OFFICE_BOX LIST_COPY_CONTACT_STR("Home Address Post Office Box", item->contact->home_po_box); break; case 0x3A5F: // PR_OTHER_ADDRESS_CITY LIST_COPY_CONTACT_STR("Other Address City", item->contact->other_city); break; case 0x3A60: // PR_OTHER_ADDRESS_COUNTRY LIST_COPY_CONTACT_STR("Other Address Country", item->contact->other_country); break; case 0x3A61: // PR_OTHER_ADDRESS_POSTAL_CODE LIST_COPY_CONTACT_STR("Other Address Postal Code", item->contact->other_postal_code); break; case 0x3A62: // PR_OTHER_ADDRESS_STATE_OR_PROVINCE LIST_COPY_CONTACT_STR("Other Address State", item->contact->other_state); break; case 0x3A63: // PR_OTHER_ADDRESS_STREET LIST_COPY_CONTACT_STR("Other Address Street", item->contact->other_street); break; case 0x3A64: // PR_OTHER_ADDRESS_POST_OFFICE_BOX LIST_COPY_CONTACT_STR("Other Address Post Office box", item->contact->other_po_box); break; case 0x3FDE: // PR_INTERNET_CPID LIST_COPY_INT32("Internet code page", item->internet_cpid); break; case 0x3FFD: // PR_MESSAGE_CODEPAGE LIST_COPY_INT32("Message code page", item->message_codepage); break; case 0x65E3: // Entry ID? DEBUG_EMAIL(("Entry ID - ")); item->record_key = (char*) xmalloc(16+1); - memcpy(item->record_key, &(list->items[x]->data[1]), 16); //skip first byte + memcpy(item->record_key, &(list->elements[x]->data[1]), 16); //skip first byte item->record_key[16]='\0'; item->record_key_size=16; DEBUG_EMAIL_HEXPRINT((char*)item->record_key, 16); break; case 0x67F2: // ID2 value of the attachments proper record DEBUG_EMAIL(("Attachment ID2 value - ")); if (attach) { uint32_t tempid; - memcpy(&(tempid), list->items[x]->data, sizeof(tempid)); + memcpy(&(tempid), list->elements[x]->data, sizeof(tempid)); LE32_CPU(tempid); attach->id2_val = tempid; DEBUG_EMAIL(("%#"PRIx64"\n", attach->id2_val)); } else { - DEBUG_EMAIL(("NOT AN ATTACHMENT: %#x\n", list->items[x]->id)); + DEBUG_EMAIL(("NOT AN ATTACHMENT: %#x\n", list->elements[x]->mapi_id)); } break; case 0x67FF: // Extra Property Identifier (Password CheckSum) LIST_COPY_STORE_INT32("Password checksum", item->message_store->pwd_chksum); break; case 0x6F02: // Secure HTML Body LIST_COPY_EMAIL_SIZE("Secure HTML Body", item->email->encrypted_htmlbody, item->email->encrypted_htmlbody_size); break; case 0x6F04: // Secure Text Body LIST_COPY_EMAIL_SIZE("Secure Text Body", item->email->encrypted_body, item->email->encrypted_body_size); break; case 0x7C07: // top of folders ENTRYID LIST_COPY_ENTRYID("Top of folders RecID", item->message_store->top_of_folder); break; case 0x8005: // Contact's Fullname LIST_COPY_CONTACT_STR("Contact Fullname", item->contact->fullname); break; case 0x801A: // Full Home Address LIST_COPY_CONTACT_STR("Home Address", item->contact->home_address); break; case 0x801B: // Full Business Address LIST_COPY_CONTACT_STR("Business Address", item->contact->business_address); break; case 0x801C: // Full Other Address LIST_COPY_CONTACT_STR("Other Address", item->contact->other_address); break; case 0x8045: // Work address street LIST_COPY_CONTACT_STR("Work address street", item->contact->work_address_street); break; case 0x8046: // Work address city LIST_COPY_CONTACT_STR("Work address city", item->contact->work_address_city); break; case 0x8047: // Work address state LIST_COPY_CONTACT_STR("Work address state", item->contact->work_address_state); break; case 0x8048: // Work address postalcode LIST_COPY_CONTACT_STR("Work address postalcode", item->contact->work_address_postalcode); break; case 0x8049: // Work address country LIST_COPY_CONTACT_STR("Work address country", item->contact->work_address_country); break; case 0x804A: // Work address postofficebox LIST_COPY_CONTACT_STR("Work address postofficebox", item->contact->work_address_postofficebox); break; case 0x8082: // Email Address 1 Transport LIST_COPY_CONTACT_STR("Email Address 1 Transport", item->contact->address1_transport); break; case 0x8083: // Email Address 1 Address LIST_COPY_CONTACT_STR("Email Address 1 Address", item->contact->address1); break; case 0x8084: // Email Address 1 Description LIST_COPY_CONTACT_STR("Email Address 1 Description", item->contact->address1_desc); break; case 0x8085: // Email Address 1 Record LIST_COPY_CONTACT_STR("Email Address 1 Record", item->contact->address1a); break; case 0x8092: // Email Address 2 Transport LIST_COPY_CONTACT_STR("Email Address 2 Transport", item->contact->address2_transport); break; case 0x8093: // Email Address 2 Address LIST_COPY_CONTACT_STR("Email Address 2 Address", item->contact->address2); break; case 0x8094: // Email Address 2 Description LIST_COPY_CONTACT_STR("Email Address 2 Description", item->contact->address2_desc); break; case 0x8095: // Email Address 2 Record LIST_COPY_CONTACT_STR("Email Address 2 Record", item->contact->address2a); break; case 0x80A2: // Email Address 3 Transport LIST_COPY_CONTACT_STR("Email Address 3 Transport", item->contact->address3_transport); break; case 0x80A3: // Email Address 3 Address LIST_COPY_CONTACT_STR("Email Address 3 Address", item->contact->address3); break; case 0x80A4: // Email Address 3 Description LIST_COPY_CONTACT_STR("Email Address 3 Description", item->contact->address3_desc); break; case 0x80A5: // Email Address 3 Record LIST_COPY_CONTACT_STR("Email Address 3 Record", item->contact->address3a); break; case 0x80D8: // Internet Free/Busy LIST_COPY_CONTACT_STR("Internet Free/Busy", item->contact->free_busy_address); break; case 0x8205: // Show on Free/Busy as LIST_COPY_APPT_ENUM("Appointment shows as", item->appointment->showas, 0, 4, "Free", "Tentative", "Busy", "Out Of Office"); break; case 0x8208: // Location of an appointment LIST_COPY_APPT_STR("Appointment Location", item->appointment->location); break; case 0x820d: // Appointment start LIST_COPY_APPT_TIME("Appointment Date Start", item->appointment->start); break; case 0x820e: // Appointment end LIST_COPY_APPT_TIME("Appointment Date End", item->appointment->end); break; case 0x8214: // Label for an appointment LIST_COPY_APPT_ENUM("Label for appointment", item->appointment->label, 0, 11, "None", "Important", "Business", "Personal", "Vacation", "Must Attend", "Travel Required", "Needs Preparation", "Birthday", "Anniversary", "Phone Call"); break; case 0x8215: // All day appointment flag LIST_COPY_APPT_BOOL("All day flag", item->appointment->all_day); break; case 0x8231: // Recurrence type LIST_COPY_APPT_ENUM("Appointment reccurs", item->appointment->recurrence_type, 0, 5, "None", "Daily", "Weekly", "Monthly", "Yearly"); break; case 0x8232: // Recurrence description LIST_COPY_APPT_STR("Appointment recurrence description", item->appointment->recurrence); break; case 0x8234: // TimeZone as String LIST_COPY_APPT_STR("TimeZone of times", item->appointment->timezonestring); break; case 0x8235: // Recurrence start date LIST_COPY_APPT_TIME("Recurrence Start Date", item->appointment->recurrence_start); break; case 0x8236: // Recurrence end date LIST_COPY_APPT_TIME("Recurrence End Date", item->appointment->recurrence_end); break; case 0x8501: // Reminder minutes before appointment start LIST_COPY_APPT_INT32("Alarm minutes", item->appointment->alarm_minutes); break; case 0x8503: // Reminder alarm LIST_COPY_APPT_BOOL("Reminder alarm", item->appointment->alarm); break; case 0x8516: // Common start - DEBUG_EMAIL(("Common Start Date - %s\n", fileTimeToAscii((FILETIME*)list->items[x]->data))); + DEBUG_EMAIL(("Common Start Date - %s\n", fileTimeToAscii((FILETIME*)list->elements[x]->data))); break; case 0x8517: // Common end - DEBUG_EMAIL(("Common End Date - %s\n", fileTimeToAscii((FILETIME*)list->items[x]->data))); + DEBUG_EMAIL(("Common End Date - %s\n", fileTimeToAscii((FILETIME*)list->elements[x]->data))); break; case 0x851f: // Play reminder sound filename LIST_COPY_APPT_STR("Appointment reminder sound filename", item->appointment->alarm_filename); break; case 0x8530: // Followup LIST_COPY_CONTACT_STR("Followup String", item->contact->followup); break; case 0x8534: // Mileage LIST_COPY_CONTACT_STR("Mileage", item->contact->mileage); break; case 0x8535: // Billing Information LIST_COPY_CONTACT_STR("Billing Information", item->contact->billing_information); break; case 0x8554: // Outlook Version LIST_COPY_STR("Outlook Version", item->outlook_version); break; case 0x8560: // Appointment Reminder Time LIST_COPY_APPT_TIME("Appointment Reminder Time", item->appointment->reminder); break; case 0x8700: // Journal Type LIST_COPY_JOURNAL_STR("Journal Entry Type", item->journal->type); break; case 0x8706: // Journal Start date/time LIST_COPY_JOURNAL_TIME("Start Timestamp", item->journal->start); break; case 0x8708: // Journal End date/time LIST_COPY_JOURNAL_TIME("End Timestamp", item->journal->end); break; case 0x8712: // Journal Type Description LIST_COPY_JOURNAL_STR("Journal description", item->journal->description); break; default: - if (list->items[x]->type == (uint32_t)0x0002) { - DEBUG_EMAIL(("Unknown type %#x 16bit int = %hi\n", list->items[x]->id, - *(int16_t*)list->items[x]->data)); - - } else if (list->items[x]->type == (uint32_t)0x0003) { - DEBUG_EMAIL(("Unknown type %#x 32bit int = %i\n", list->items[x]->id, - *(int32_t*)list->items[x]->data)); - - } else if (list->items[x]->type == (uint32_t)0x0004) { - DEBUG_EMAIL(("Unknown type %#x 4-byte floating [size = %#x]\n", list->items[x]->id, - list->items[x]->size)); - DEBUG_HEXDUMP(list->items[x]->data, list->items[x]->size); - - } else if (list->items[x]->type == (uint32_t)0x0005) { - DEBUG_EMAIL(("Unknown type %#x double floating [size = %#x]\n", list->items[x]->id, - list->items[x]->size)); - DEBUG_HEXDUMP(list->items[x]->data, list->items[x]->size); - - } else if (list->items[x]->type == (uint32_t)0x0006) { - DEBUG_EMAIL(("Unknown type %#x signed 64bit int = %"PRIi64"\n", list->items[x]->id, - *(int64_t*)list->items[x]->data)); - DEBUG_HEXDUMP(list->items[x]->data, list->items[x]->size); - - } else if (list->items[x]->type == (uint32_t)0x0007) { - DEBUG_EMAIL(("Unknown type %#x application time [size = %#x]\n", list->items[x]->id, - list->items[x]->size)); - DEBUG_HEXDUMP(list->items[x]->data, list->items[x]->size); - - } else if (list->items[x]->type == (uint32_t)0x000a) { - DEBUG_EMAIL(("Unknown type %#x 32bit error value = %i\n", list->items[x]->id, - *(int32_t*)list->items[x]->data)); - - } else if (list->items[x]->type == (uint32_t)0x000b) { - DEBUG_EMAIL(("Unknown type %#x 16bit boolean = %s [%hi]\n", list->items[x]->id, - (*((int16_t*)list->items[x]->data)!=0?"True":"False"), - *((int16_t*)list->items[x]->data))); - - } else if (list->items[x]->type == (uint32_t)0x000d) { - DEBUG_EMAIL(("Unknown type %#x Embedded object [size = %#x]\n", list->items[x]->id, - list->items[x]->size)); - DEBUG_HEXDUMP(list->items[x]->data, list->items[x]->size); - - } else if (list->items[x]->type == (uint32_t)0x0014) { - DEBUG_EMAIL(("Unknown type %#x signed 64bit int = %"PRIi64"\n", list->items[x]->id, - *(int64_t*)list->items[x]->data)); - DEBUG_HEXDUMP(list->items[x]->data, list->items[x]->size); - - } else if (list->items[x]->type == (uint32_t)0x001e) { - DEBUG_EMAIL(("Unknown type %#x String Data = \"%s\"\n", list->items[x]->id, - list->items[x]->data)); - - } else if (list->items[x]->type == (uint32_t)0x001f) { - DEBUG_EMAIL(("Unknown type %#x Unicode String Data [size = %#x]\n", list->items[x]->id, - list->items[x]->size)); - DEBUG_HEXDUMP(list->items[x]->data, list->items[x]->size); - - } else if (list->items[x]->type == (uint32_t)0x0040) { - DEBUG_EMAIL(("Unknown type %#x Date = \"%s\"\n", list->items[x]->id, - fileTimeToAscii((FILETIME*)list->items[x]->data))); - - } else if (list->items[x]->type == (uint32_t)0x0048) { - DEBUG_EMAIL(("Unknown type %#x OLE GUID [size = %#x]\n", list->items[x]->id, - list->items[x]->size)); - DEBUG_HEXDUMP(list->items[x]->data, list->items[x]->size); - - } else if (list->items[x]->type == (uint32_t)0x0102) { - DEBUG_EMAIL(("Unknown type %#x Binary Data [size = %#x]\n", list->items[x]->id, - list->items[x]->size)); - DEBUG_HEXDUMP(list->items[x]->data, list->items[x]->size); - - } else if (list->items[x]->type == (uint32_t)0x1003) { - DEBUG_EMAIL(("Unknown type %#x Array of 32 bit values [size = %#x]\n", list->items[x]->id, - list->items[x]->size)); - DEBUG_HEXDUMP(list->items[x]->data, list->items[x]->size); - - } else if (list->items[x]->type == (uint32_t)0x1014) { - DEBUG_EMAIL(("Unknown type %#x Array of 64 bit values [siize = %#x]\n", list->items[x]->id, - list->items[x]->size)); - DEBUG_HEXDUMP(list->items[x]->data, list->items[x]->size); - - } else if (list->items[x]->type == (uint32_t)0x101E) { - DEBUG_EMAIL(("Unknown type %#x Array of Strings [size = %#x]\n", list->items[x]->id, - list->items[x]->size)); - DEBUG_HEXDUMP(list->items[x]->data, list->items[x]->size); - - } else if (list->items[x]->type == (uint32_t)0x101F) { - DEBUG_EMAIL(("Unknown type %#x Array of Unicode Strings [size = %#x]\n", list->items[x]->id, - list->items[x]->size)); - DEBUG_HEXDUMP(list->items[x]->data, list->items[x]->size); - - } else if (list->items[x]->type == (uint32_t)0x1102) { - DEBUG_EMAIL(("Unknown type %#x Array of binary data blobs [size = %#x]\n", list->items[x]->id, - list->items[x]->size)); - DEBUG_HEXDUMP(list->items[x]->data, list->items[x]->size); + if (list->elements[x]->type == (uint32_t)0x0002) { + DEBUG_EMAIL(("Unknown type %#x 16bit int = %hi\n", list->elements[x]->mapi_id, + *(int16_t*)list->elements[x]->data)); + + } else if (list->elements[x]->type == (uint32_t)0x0003) { + DEBUG_EMAIL(("Unknown type %#x 32bit int = %i\n", list->elements[x]->mapi_id, + *(int32_t*)list->elements[x]->data)); + + } else if (list->elements[x]->type == (uint32_t)0x0004) { + DEBUG_EMAIL(("Unknown type %#x 4-byte floating [size = %#x]\n", list->elements[x]->mapi_id, + list->elements[x]->size)); + DEBUG_HEXDUMP(list->elements[x]->data, list->elements[x]->size); + + } else if (list->elements[x]->type == (uint32_t)0x0005) { + DEBUG_EMAIL(("Unknown type %#x double floating [size = %#x]\n", list->elements[x]->mapi_id, + list->elements[x]->size)); + DEBUG_HEXDUMP(list->elements[x]->data, list->elements[x]->size); + + } else if (list->elements[x]->type == (uint32_t)0x0006) { + DEBUG_EMAIL(("Unknown type %#x signed 64bit int = %"PRIi64"\n", list->elements[x]->mapi_id, + *(int64_t*)list->elements[x]->data)); + DEBUG_HEXDUMP(list->elements[x]->data, list->elements[x]->size); + + } else if (list->elements[x]->type == (uint32_t)0x0007) { + DEBUG_EMAIL(("Unknown type %#x application time [size = %#x]\n", list->elements[x]->mapi_id, + list->elements[x]->size)); + DEBUG_HEXDUMP(list->elements[x]->data, list->elements[x]->size); + + } else if (list->elements[x]->type == (uint32_t)0x000a) { + DEBUG_EMAIL(("Unknown type %#x 32bit error value = %i\n", list->elements[x]->mapi_id, + *(int32_t*)list->elements[x]->data)); + + } else if (list->elements[x]->type == (uint32_t)0x000b) { + DEBUG_EMAIL(("Unknown type %#x 16bit boolean = %s [%hi]\n", list->elements[x]->mapi_id, + (*((int16_t*)list->elements[x]->data)!=0?"True":"False"), + *((int16_t*)list->elements[x]->data))); + + } else if (list->elements[x]->type == (uint32_t)0x000d) { + DEBUG_EMAIL(("Unknown type %#x Embedded object [size = %#x]\n", list->elements[x]->mapi_id, + list->elements[x]->size)); + DEBUG_HEXDUMP(list->elements[x]->data, list->elements[x]->size); + + } else if (list->elements[x]->type == (uint32_t)0x0014) { + DEBUG_EMAIL(("Unknown type %#x signed 64bit int = %"PRIi64"\n", list->elements[x]->mapi_id, + *(int64_t*)list->elements[x]->data)); + DEBUG_HEXDUMP(list->elements[x]->data, list->elements[x]->size); + + } else if (list->elements[x]->type == (uint32_t)0x001e) { + DEBUG_EMAIL(("Unknown type %#x String Data = \"%s\"\n", list->elements[x]->mapi_id, + list->elements[x]->data)); + + } else if (list->elements[x]->type == (uint32_t)0x001f) { + DEBUG_EMAIL(("Unknown type %#x Unicode String Data [size = %#x]\n", list->elements[x]->mapi_id, + list->elements[x]->size)); + DEBUG_HEXDUMP(list->elements[x]->data, list->elements[x]->size); + + } else if (list->elements[x]->type == (uint32_t)0x0040) { + DEBUG_EMAIL(("Unknown type %#x Date = \"%s\"\n", list->elements[x]->mapi_id, + fileTimeToAscii((FILETIME*)list->elements[x]->data))); + + } else if (list->elements[x]->type == (uint32_t)0x0048) { + DEBUG_EMAIL(("Unknown type %#x OLE GUID [size = %#x]\n", list->elements[x]->mapi_id, + list->elements[x]->size)); + DEBUG_HEXDUMP(list->elements[x]->data, list->elements[x]->size); + + } else if (list->elements[x]->type == (uint32_t)0x0102) { + DEBUG_EMAIL(("Unknown type %#x Binary Data [size = %#x]\n", list->elements[x]->mapi_id, + list->elements[x]->size)); + DEBUG_HEXDUMP(list->elements[x]->data, list->elements[x]->size); + + } else if (list->elements[x]->type == (uint32_t)0x1003) { + DEBUG_EMAIL(("Unknown type %#x Array of 32 bit values [size = %#x]\n", list->elements[x]->mapi_id, + list->elements[x]->size)); + DEBUG_HEXDUMP(list->elements[x]->data, list->elements[x]->size); + + } else if (list->elements[x]->type == (uint32_t)0x1014) { + DEBUG_EMAIL(("Unknown type %#x Array of 64 bit values [siize = %#x]\n", list->elements[x]->mapi_id, + list->elements[x]->size)); + DEBUG_HEXDUMP(list->elements[x]->data, list->elements[x]->size); + + } else if (list->elements[x]->type == (uint32_t)0x101E) { + DEBUG_EMAIL(("Unknown type %#x Array of Strings [size = %#x]\n", list->elements[x]->mapi_id, + list->elements[x]->size)); + DEBUG_HEXDUMP(list->elements[x]->data, list->elements[x]->size); + + } else if (list->elements[x]->type == (uint32_t)0x101F) { + DEBUG_EMAIL(("Unknown type %#x Array of Unicode Strings [size = %#x]\n", list->elements[x]->mapi_id, + list->elements[x]->size)); + DEBUG_HEXDUMP(list->elements[x]->data, list->elements[x]->size); + + } else if (list->elements[x]->type == (uint32_t)0x1102) { + DEBUG_EMAIL(("Unknown type %#x Array of binary data blobs [size = %#x]\n", list->elements[x]->mapi_id, + list->elements[x]->size)); + DEBUG_HEXDUMP(list->elements[x]->data, list->elements[x]->size); } else { - DEBUG_EMAIL(("Unknown type %#x Not Printable [%#x]\n", list->items[x]->id, - list->items[x]->type)); - DEBUG_HEXDUMP(list->items[x]->data, list->items[x]->size); + DEBUG_EMAIL(("Unknown type %#x Not Printable [%#x]\n", list->elements[x]->mapi_id, + list->elements[x]->type)); + DEBUG_HEXDUMP(list->elements[x]->data, list->elements[x]->size); } - if (list->items[x]->data) { - free(list->items[x]->data); - list->items[x]->data = NULL; + if (list->elements[x]->data) { + free(list->elements[x]->data); + list->elements[x]->data = NULL; } } } list = list->next; if (attach) attach = attach->next; } DEBUG_RET(); return 0; } -void pst_free_list(pst_num_array *list) { - pst_num_array *l; +void pst_free_list(pst_mapi_object *list) { + pst_mapi_object *l; DEBUG_ENT("pst_free_list"); while (list) { - if (list->items) { + if (list->elements) { int32_t x; for (x=0; x < list->orig_count; x++) { - if (list->items[x]) { - if (list->items[x]->data) free(list->items[x]->data); - free(list->items[x]); + if (list->elements[x]) { + if (list->elements[x]->data) free(list->elements[x]->data); + free(list->elements[x]); } } - free(list->items); + free(list->elements); } l = list->next; free (list); list = l; } DEBUG_RET(); } void pst_free_id2(pst_id2_ll * head) { pst_id2_ll *t; DEBUG_ENT("pst_free_id2"); while (head) { if (head->child) pst_free_id2(head->child); t = head->next; free(head); head = t; } DEBUG_RET(); } void pst_free_id (pst_index_ll *head) { pst_index_ll *t; DEBUG_ENT("pst_free_id"); while (head) { t = head->next; free(head); head = t; } DEBUG_RET(); } void pst_free_desc (pst_desc_ll *head) { pst_desc_ll *t; DEBUG_ENT("pst_free_desc"); while (head) { while (head->child) { head = head->child; } // point t to the next item 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")); head = t; } DEBUG_RET(); } void pst_free_xattrib(pst_x_attrib_ll *x) { pst_x_attrib_ll *t; DEBUG_ENT("pst_free_xattrib"); while (x) { if (x->data) free(x->data); t = x->next; free(x); x = t; } DEBUG_RET(); } pst_id2_ll * pst_build_id2(pst_file *pf, pst_index_ll* list) { pst_block_header block_head; pst_id2_ll *head = NULL, *tail = NULL; uint16_t x = 0; char *b_ptr = NULL; char *buf = NULL; pst_id2_assoc id2_rec; pst_index_ll *i_ptr = NULL; pst_id2_ll *i2_ptr = NULL; DEBUG_ENT("pst_build_id2"); if (pst_read_block_size(pf, list->offset, list->size, &buf) < list->size) { //an error occured in block read WARN(("block read error occured. offset = %#"PRIx64", size = %#"PRIx64"\n", list->offset, list->size)); if (buf) free(buf); DEBUG_RET(); return NULL; } DEBUG_HEXDUMPC(buf, list->size, 16); memcpy(&block_head, buf, sizeof(block_head)); LE16_CPU(block_head.type); LE16_CPU(block_head.count); if (block_head.type != (uint16_t)0x0002) { // some sort of constant? WARN(("Unknown constant [%#hx] at start of id2 values [offset %#"PRIx64"].\n", block_head.type, list->offset)); if (buf) free(buf); DEBUG_RET(); return NULL; } DEBUG_INDEX(("ID %#"PRIx64" is likely to be a description record. Count is %i (offset %#"PRIx64")\n", list->id, block_head.count, list->offset)); x = 0; b_ptr = buf + ((pf->do_read64) ? 0x08 : 0x04); while (x < block_head.count) { b_ptr += pst_decode_assoc(pf, &id2_rec, b_ptr); DEBUG_INDEX(("id2 = %#x, id = %#"PRIx64", child id = %#"PRIx64"\n", id2_rec.id2, id2_rec.id, id2_rec.child_id)); if ((i_ptr = pst_getID(pf, id2_rec.id)) == NULL) { DEBUG_WARN(("%#"PRIx64" - Not Found\n", id2_rec.id)); } else { DEBUG_INDEX(("%#"PRIx64" - Offset %#"PRIx64", u1 %#"PRIx64", Size %"PRIi64"(%#"PRIx64")\n", i_ptr->id, i_ptr->offset, i_ptr->u1, i_ptr->size, i_ptr->size)); // add it to the tree i2_ptr = (pst_id2_ll*) xmalloc(sizeof(pst_id2_ll)); i2_ptr->id2 = id2_rec.id2; i2_ptr->id = i_ptr; i2_ptr->child = NULL; i2_ptr->next = NULL; if (!head) head = i2_ptr; if (tail) tail->next = i2_ptr; tail = i2_ptr; if (id2_rec.child_id) { if ((i_ptr = pst_getID(pf, id2_rec.child_id)) == NULL) { DEBUG_WARN(("child id [%#"PRIi64"] not found\n", id2_rec.child_id)); } else { i2_ptr->child = pst_build_id2(pf, i_ptr); } } } x++; } if (buf) free (buf); DEBUG_RET(); return head; } void pst_free_attach(pst_item_attach *attach) { while (attach) { pst_item_attach *t; SAFE_FREE_STR(attach->filename1); SAFE_FREE_STR(attach->filename2); SAFE_FREE_STR(attach->mimetype); SAFE_FREE(attach->data); pst_free_id2(attach->id2_head); t = attach->next; free(attach); attach = t; } } void pst_freeItem(pst_item *item) { pst_item_extra_field *et; DEBUG_ENT("pst_freeItem"); if (item) { if (item->email) { SAFE_FREE(item->email->arrival_date); SAFE_FREE_STR(item->email->cc_address); SAFE_FREE_STR(item->email->bcc_address); SAFE_FREE(item->email->encrypted_body); SAFE_FREE(item->email->encrypted_htmlbody); SAFE_FREE_STR(item->email->header); SAFE_FREE_STR(item->email->htmlbody); SAFE_FREE_STR(item->email->in_reply_to); SAFE_FREE_STR(item->email->messageid); SAFE_FREE_STR(item->email->original_bcc); SAFE_FREE_STR(item->email->original_cc); SAFE_FREE_STR(item->email->original_to); SAFE_FREE_STR(item->email->outlook_recipient); SAFE_FREE_STR(item->email->outlook_recipient_name); SAFE_FREE_STR(item->email->outlook_recipient2); SAFE_FREE_STR(item->email->outlook_sender); SAFE_FREE_STR(item->email->outlook_sender_name); SAFE_FREE_STR(item->email->outlook_sender2); SAFE_FREE_STR(item->email->processed_subject); SAFE_FREE_STR(item->email->recip_access); SAFE_FREE_STR(item->email->recip_address); SAFE_FREE_STR(item->email->recip2_access); SAFE_FREE_STR(item->email->recip2_address); SAFE_FREE_STR(item->email->reply_to); SAFE_FREE_STR(item->email->rtf_body_tag); SAFE_FREE(item->email->rtf_compressed); SAFE_FREE_STR(item->email->return_path_address); SAFE_FREE_STR(item->email->sender_access); SAFE_FREE_STR(item->email->sender_address); SAFE_FREE_STR(item->email->sender2_access); SAFE_FREE_STR(item->email->sender2_address); SAFE_FREE(item->email->sent_date); SAFE_FREE(item->email->sentmail_folder); SAFE_FREE_STR(item->email->sentto_address); SAFE_FREE_STR(item->email->report_text); SAFE_FREE(item->email->report_time); SAFE_FREE_STR(item->email->supplementary_info); free(item->email); } if (item->folder) { free(item->folder); } if (item->message_store) { SAFE_FREE(item->message_store->top_of_personal_folder); SAFE_FREE(item->message_store->default_outbox_folder); SAFE_FREE(item->message_store->deleted_items_folder); SAFE_FREE(item->message_store->sent_items_folder); SAFE_FREE(item->message_store->user_views_folder); SAFE_FREE(item->message_store->common_view_folder); SAFE_FREE(item->message_store->search_root_folder); SAFE_FREE(item->message_store->top_of_folder); free(item->message_store); } if (item->contact) { SAFE_FREE_STR(item->contact->access_method); SAFE_FREE_STR(item->contact->account_name); SAFE_FREE_STR(item->contact->address1); SAFE_FREE_STR(item->contact->address1a); SAFE_FREE_STR(item->contact->address1_desc); SAFE_FREE_STR(item->contact->address1_transport); SAFE_FREE_STR(item->contact->address2); SAFE_FREE_STR(item->contact->address2a); SAFE_FREE_STR(item->contact->address2_desc); SAFE_FREE_STR(item->contact->address2_transport); SAFE_FREE_STR(item->contact->address3); SAFE_FREE_STR(item->contact->address3a); SAFE_FREE_STR(item->contact->address3_desc); SAFE_FREE_STR(item->contact->address3_transport); SAFE_FREE_STR(item->contact->assistant_name); SAFE_FREE_STR(item->contact->assistant_phone); SAFE_FREE_STR(item->contact->billing_information); SAFE_FREE(item->contact->birthday); SAFE_FREE_STR(item->contact->business_address); SAFE_FREE_STR(item->contact->business_city); SAFE_FREE_STR(item->contact->business_country); SAFE_FREE_STR(item->contact->business_fax); SAFE_FREE_STR(item->contact->business_homepage); SAFE_FREE_STR(item->contact->business_phone); SAFE_FREE_STR(item->contact->business_phone2); SAFE_FREE_STR(item->contact->business_po_box); SAFE_FREE_STR(item->contact->business_postal_code); SAFE_FREE_STR(item->contact->business_state); SAFE_FREE_STR(item->contact->business_street); SAFE_FREE_STR(item->contact->callback_phone); SAFE_FREE_STR(item->contact->car_phone); SAFE_FREE_STR(item->contact->company_main_phone); SAFE_FREE_STR(item->contact->company_name); SAFE_FREE_STR(item->contact->computer_name); SAFE_FREE_STR(item->contact->customer_id); SAFE_FREE_STR(item->contact->def_postal_address); SAFE_FREE_STR(item->contact->department); SAFE_FREE_STR(item->contact->display_name_prefix); SAFE_FREE_STR(item->contact->first_name); SAFE_FREE_STR(item->contact->followup); SAFE_FREE_STR(item->contact->free_busy_address); SAFE_FREE_STR(item->contact->ftp_site); SAFE_FREE_STR(item->contact->fullname); SAFE_FREE_STR(item->contact->gov_id); SAFE_FREE_STR(item->contact->hobbies); SAFE_FREE_STR(item->contact->home_address); SAFE_FREE_STR(item->contact->home_city); SAFE_FREE_STR(item->contact->home_country); SAFE_FREE_STR(item->contact->home_fax); SAFE_FREE_STR(item->contact->home_po_box); SAFE_FREE_STR(item->contact->home_phone); SAFE_FREE_STR(item->contact->home_phone2); SAFE_FREE_STR(item->contact->home_postal_code); SAFE_FREE_STR(item->contact->home_state); SAFE_FREE_STR(item->contact->home_street); SAFE_FREE_STR(item->contact->initials); SAFE_FREE_STR(item->contact->isdn_phone); SAFE_FREE_STR(item->contact->job_title); SAFE_FREE_STR(item->contact->keyword); SAFE_FREE_STR(item->contact->language); SAFE_FREE_STR(item->contact->location); SAFE_FREE_STR(item->contact->manager_name); SAFE_FREE_STR(item->contact->middle_name); SAFE_FREE_STR(item->contact->mileage); SAFE_FREE_STR(item->contact->mobile_phone); SAFE_FREE_STR(item->contact->nickname); SAFE_FREE_STR(item->contact->office_loc); SAFE_FREE_STR(item->contact->common_name); SAFE_FREE_STR(item->contact->org_id); SAFE_FREE_STR(item->contact->other_address); SAFE_FREE_STR(item->contact->other_city); SAFE_FREE_STR(item->contact->other_country); SAFE_FREE_STR(item->contact->other_phone); SAFE_FREE_STR(item->contact->other_po_box); SAFE_FREE_STR(item->contact->other_postal_code); SAFE_FREE_STR(item->contact->other_state); SAFE_FREE_STR(item->contact->other_street); SAFE_FREE_STR(item->contact->pager_phone); SAFE_FREE_STR(item->contact->personal_homepage); SAFE_FREE_STR(item->contact->pref_name); SAFE_FREE_STR(item->contact->primary_fax); SAFE_FREE_STR(item->contact->primary_phone); SAFE_FREE_STR(item->contact->profession); SAFE_FREE_STR(item->contact->radio_phone); SAFE_FREE_STR(item->contact->spouse_name); SAFE_FREE_STR(item->contact->suffix); SAFE_FREE_STR(item->contact->surname); SAFE_FREE_STR(item->contact->telex); SAFE_FREE_STR(item->contact->transmittable_display_name); SAFE_FREE_STR(item->contact->ttytdd_phone); SAFE_FREE(item->contact->wedding_anniversary); SAFE_FREE_STR(item->contact->work_address_street); SAFE_FREE_STR(item->contact->work_address_city); SAFE_FREE_STR(item->contact->work_address_state); SAFE_FREE_STR(item->contact->work_address_postalcode); SAFE_FREE_STR(item->contact->work_address_country); SAFE_FREE_STR(item->contact->work_address_postofficebox); free(item->contact); } pst_free_attach(item->attach); while (item->extra_fields) { SAFE_FREE(item->extra_fields->field_name); SAFE_FREE(item->extra_fields->value); et = item->extra_fields->next; free(item->extra_fields); item->extra_fields = et; } if (item->journal) { SAFE_FREE(item->journal->end); SAFE_FREE(item->journal->start); SAFE_FREE_STR(item->journal->type); free(item->journal); } if (item->appointment) { SAFE_FREE_STR(item->appointment->location); SAFE_FREE(item->appointment->reminder); SAFE_FREE_STR(item->appointment->alarm_filename); SAFE_FREE(item->appointment->start); SAFE_FREE(item->appointment->end); SAFE_FREE_STR(item->appointment->timezonestring); SAFE_FREE_STR(item->appointment->recurrence); SAFE_FREE(item->appointment->recurrence_start); SAFE_FREE(item->appointment->recurrence_end); free(item->appointment); } SAFE_FREE(item->ascii_type); SAFE_FREE_STR(item->body_charset); SAFE_FREE_STR(item->body); SAFE_FREE_STR(item->subject); SAFE_FREE_STR(item->comment); SAFE_FREE(item->create_date); SAFE_FREE_STR(item->file_as); SAFE_FREE(item->modify_date); SAFE_FREE_STR(item->outlook_version); SAFE_FREE(item->record_key); free(item); } DEBUG_RET(); } /** * The offset might be zero, in which case we have no data, so return a pair of null pointers. * Or, the offset might end in 0xf, so it is an id2 pointer, in which case we read the id2 block. * Otherwise, the high order 16 bits of offset is the index into the subblocks, and * the (low order 16 bits of offset)>>4 is an index into the table of offsets in the subblock. */ int pst_getBlockOffsetPointer(pst_file *pf, pst_id2_ll *i2_head, pst_subblocks *subblocks, uint32_t offset, pst_block_offset_pointer *p) { size_t size; pst_block_offset block_offset; DEBUG_ENT("pst_getBlockOffsetPointer"); if (p->needfree) free(p->from); p->from = NULL; p->to = NULL; p->needfree = 0; if (!offset) { // no data p->from = p->to = NULL; } else if ((offset & 0xf) == (uint32_t)0xf) { // external index reference DEBUG_WARN(("Found id2 %#x value. Will follow it\n", offset)); size = pst_ff_getID2block(pf, offset, i2_head, &(p->from)); if (size) { p->to = p->from + size; p->needfree = 1; } else { if (p->from) { DEBUG_WARN(("size zero but non-null pointer\n")); free(p->from); } p->from = p->to = NULL; } } else { // internal index reference size_t subindex = offset >> 16; size_t suboffset = offset & 0xffff; if (subindex < subblocks->subblock_count) { if (pst_getBlockOffset(subblocks->subs[subindex].buf, subblocks->subs[subindex].read_size, subblocks->subs[subindex].i_offset, suboffset, &block_offset)) { p->from = subblocks->subs[subindex].buf + block_offset.from; p->to = subblocks->subs[subindex].buf + block_offset.to; } } } DEBUG_RET(); return (p->from) ? 0 : 1; } int pst_getBlockOffset(char *buf, size_t read_size, uint32_t i_offset, uint32_t offset, pst_block_offset *p) { uint32_t low = offset & 0xf; uint32_t of1 = offset >> 4; DEBUG_ENT("pst_getBlockOffset"); if (!p || !buf || !i_offset || low || (i_offset+2+of1+sizeof(*p) > read_size)) { DEBUG_WARN(("p is NULL or buf is NULL or offset is 0 or offset has low bits or beyond read size (%p, %p, %#x, %i, %i)\n", p, buf, offset, read_size, i_offset)); DEBUG_RET(); return 0; } memcpy(&(p->from), &(buf[(i_offset+2)+of1]), sizeof(p->from)); memcpy(&(p->to), &(buf[(i_offset+2)+of1+sizeof(p->from)]), sizeof(p->to)); LE16_CPU(p->from); LE16_CPU(p->to); DEBUG_WARN(("get block offset finds from=%i(%#x), to=%i(%#x)\n", p->from, p->from, p->to, p->to)); if (p->from > p->to) { DEBUG_WARN(("get block offset from > to")); DEBUG_RET(); return 0; } DEBUG_RET(); return 1; } pst_index_ll* pst_getID(pst_file* pf, uint64_t id) { pst_index_ll *ptr; DEBUG_ENT("pst_getID"); if (id == 0) { DEBUG_RET(); return NULL; } //if (id & 1) DEBUG_INDEX(("have odd id bit %#"PRIx64"\n", id)); //if (id & 2) DEBUG_INDEX(("have two id bit %#"PRIx64"\n", id)); id -= (id & 1); DEBUG_INDEX(("Trying to find %#"PRIx64"\n", id)); ptr = pf->i_head; while (ptr && (ptr->id != id)) { ptr = ptr->next; } if (ptr) {DEBUG_INDEX(("Found Value %#"PRIx64"\n", id)); } else {DEBUG_INDEX(("ERROR: Value %#"PRIx64" not found\n", id)); } DEBUG_RET(); return ptr; } pst_id2_ll *pst_getID2(pst_id2_ll *head, uint64_t id2) { DEBUG_ENT("pst_getID2"); DEBUG_INDEX(("looking for id2 = %#"PRIx64"\n", id2)); pst_id2_ll *ptr = head; while (ptr) { if (ptr->id2 == id2) break; if (ptr->child) { pst_id2_ll *rc = pst_getID2(ptr->child, id2); if (rc) { DEBUG_RET(); return rc; } } ptr = ptr->next; } if (ptr && ptr->id) { DEBUG_INDEX(("Found value %#"PRIx64"\n", ptr->id->id)); DEBUG_RET(); return ptr; } DEBUG_INDEX(("ERROR Not Found\n")); DEBUG_RET(); return NULL; } /** * find the id in the descriptor tree rooted at pf->d_head * * @param pf global pst file pointer * @param d_id the id we are looking for * * @return pointer to the pst_desc_ll node in the descriptor tree */ pst_desc_ll* pst_getDptr(pst_file *pf, uint64_t d_id) { pst_desc_ll *ptr = pf->d_head; DEBUG_ENT("pst_getDptr"); while (ptr && (ptr->d_id != d_id)) { //DEBUG_INDEX(("Looking for %#"PRIx64" at node %#"PRIx64" with parent %#"PRIx64"\n", id, ptr->d_id, ptr->parent_d_id)); if (ptr->child) { ptr = ptr->child; continue; } while (!ptr->next && ptr->parent) { ptr = ptr->parent; } ptr = ptr->next; } DEBUG_RET(); return ptr; // will be NULL or record we are looking for } void pst_printDptr(pst_file *pf, pst_desc_ll *ptr) { DEBUG_ENT("pst_printDptr"); while (ptr) { DEBUG_INDEX(("%#"PRIx64" [%i] desc=%#"PRIx64", assoc tree=%#"PRIx64"\n", ptr->d_id, ptr->no_child, (ptr->desc ? ptr->desc->id : (uint64_t)0), (ptr->assoc_tree ? ptr->assoc_tree->id : (uint64_t)0))); if (ptr->child) { pst_printDptr(pf, ptr->child); } ptr = ptr->next; } DEBUG_RET(); } void pst_printIDptr(pst_file* pf) { pst_index_ll *ptr = pf->i_head; DEBUG_ENT("pst_printIDptr"); while (ptr) { DEBUG_INDEX(("%#"PRIx64" offset=%#"PRIx64" size=%#"PRIx64"\n", ptr->id, ptr->offset, ptr->size)); ptr = ptr->next; } DEBUG_RET(); } void pst_printID2ptr(pst_id2_ll *ptr) { DEBUG_ENT("pst_printID2ptr"); while (ptr) { DEBUG_INDEX(("%#"PRIx64" id=%#"PRIx64"\n", ptr->id2, (ptr->id ? ptr->id->id : (uint64_t)0))); if (ptr->child) pst_printID2ptr(ptr->child); ptr = ptr->next; } DEBUG_RET(); } /** * Read a block of data from file into memory * @param pf PST file * @param offset offset in the pst file of the data * @param size size of the block to be read * @param buf reference to pointer to buffer. If this pointer is non-NULL, it will first be free()d * @return size of block read into memory */ size_t pst_read_block_size(pst_file *pf, int64_t offset, size_t size, char **buf) { size_t rsize; DEBUG_ENT("pst_read_block_size"); DEBUG_READ(("Reading block from %#"PRIx64", %x bytes\n", offset, size)); if (*buf) { DEBUG_READ(("Freeing old memory\n")); free(*buf); } *buf = (char*) xmalloc(size); rsize = pst_getAtPos(pf, offset, *buf, size); if (rsize != size) { DEBUG_WARN(("Didn't read all the data. fread returned less [%i instead of %i]\n", rsize, size)); if (feof(pf->fp)) { DEBUG_WARN(("We tried to read past the end of the file at [offset %#"PRIx64", size %#x]\n", offset, size)); } else if (ferror(pf->fp)) { DEBUG_WARN(("Error is set on file stream.\n")); } else { DEBUG_WARN(("I can't tell why it failed\n")); } } DEBUG_RET(); return rsize; } int pst_decrypt(uint64_t id, char *buf, size_t size, unsigned char type) { size_t x = 0; unsigned char y; DEBUG_ENT("pst_decrypt"); if (!buf) { DEBUG_RET(); return -1; } if (type == PST_COMP_ENCRYPT) { x = 0; while (x < size) { y = (unsigned char)(buf[x]); buf[x] = (char)comp_enc[y]; // transpose from encrypt array x++; } } else if (type == PST_ENCRYPT) { // The following code was based on the information at // http://www.passcape.com/outlook_passwords.htm uint16_t salt = (uint16_t) (((id & 0x00000000ffff0000) >> 16) ^ (id & 0x000000000000ffff)); x = 0; while (x < size) { uint8_t losalt = (salt & 0x00ff); uint8_t hisalt = (salt & 0xff00) >> 8; y = (unsigned char)buf[x]; y += losalt; y = comp_high1[y]; y += hisalt; y = comp_high2[y]; y -= hisalt; y = comp_enc[y]; y -= losalt; buf[x] = (char)y; x++; salt++; } } else { WARN(("Unknown encryption: %i. Cannot decrypt\n", type)); DEBUG_RET(); return -1; } DEBUG_RET(); return 0; } uint64_t pst_getIntAt(pst_file *pf, char *buf) { uint64_t buf64; uint32_t buf32; if (pf->do_read64) { memcpy(&buf64, buf, sizeof(buf64)); LE64_CPU(buf64); return buf64; } else { memcpy(&buf32, buf, sizeof(buf32)); LE32_CPU(buf32); return buf32; } } uint64_t pst_getIntAtPos(pst_file *pf, int64_t pos ) { uint64_t buf64; uint32_t buf32; if (pf->do_read64) { (void)pst_getAtPos(pf, pos, &buf64, sizeof(buf64)); LE64_CPU(buf64); return buf64; } else { (void)pst_getAtPos(pf, pos, &buf32, sizeof(buf32)); LE32_CPU(buf32); return buf32; } } /** * Read part of the pst file. * * @param pf PST file structure * @param pos offset of the data in the pst file * @param buf buffer to contain the data * @param size size of the buffer and the amount of data to be read * @return actual read size, 0 if seek error */ size_t pst_getAtPos(pst_file *pf, int64_t pos, void* buf, size_t size) { size_t rc; DEBUG_ENT("pst_getAtPos"); // pst_block_recorder **t = &pf->block_head; // pst_block_recorder *p = pf->block_head; // while (p && ((p->offset+p->size) <= pos)) { // t = &p->next; // p = p->next; // } // if (p && (p->offset <= pos) && (pos < (p->offset+p->size))) { // // bump the count // p->readcount++; // } else { // // add a new block // pst_block_recorder *tail = *t; // p = (pst_block_recorder*)xmalloc(sizeof(*p)); // *t = p; // p->next = tail; // p->offset = pos; // p->size = size; // p->readcount = 1; // } // DEBUG_MAIN(("pst file old offset %#"PRIx64" old size %#x read count %i offset %#"PRIx64" size %#x\n", // p->offset, p->size, p->readcount, pos, size)); if (fseeko(pf->fp, pos, SEEK_SET) == -1) { DEBUG_RET(); return 0; } rc = fread(buf, (size_t)1, size, pf->fp); DEBUG_RET(); return rc; } /** * Get an ID block from file using _pst_ff_getIDblock and decrypt if necessary * * @param pf PST file structure * @param id ID of block to retrieve * @param buf Reference to pointer that will be set to new block. Any memory pointed to by buffer will be free()d beforehand * @return Size of block pointed to by *b */ size_t pst_ff_getIDblock_dec(pst_file *pf, uint64_t id, char **buf) { size_t r; int noenc = (int)(id & 2); // disable encryption DEBUG_ENT("pst_ff_getIDblock_dec"); DEBUG_INDEX(("for id %#"PRIi64"\n", id)); r = pst_ff_getIDblock(pf, id, buf); if ((pf->encryption) && !(noenc)) { (void)pst_decrypt(id, *buf, r, pf->encryption); } DEBUG_HEXDUMPC(*buf, r, 16); DEBUG_RET(); return r; } /** * Read a block of data from file into memory * @param pf PST file * @param id identifier of block to read * @param buf reference to pointer to buffer. If this pointer is non-NULL, it will first be free()d * @return size of block read into memory */ size_t pst_ff_getIDblock(pst_file *pf, uint64_t id, char** buf) { pst_index_ll *rec; size_t rsize; DEBUG_ENT("pst_ff_getIDblock"); rec = pst_getID(pf, id); if (!rec) { DEBUG_INDEX(("Cannot find ID %#"PRIx64"\n", id)); DEBUG_RET(); return 0; } DEBUG_INDEX(("id = %#"PRIx64", record size = %#x, offset = %#x\n", id, rec->size, rec->offset)); rsize = pst_read_block_size(pf, rec->offset, rec->size, buf); DEBUG_RET(); return rsize; } #define PST_PTR_BLOCK_SIZE 0x120 size_t pst_ff_getID2block(pst_file *pf, uint64_t id2, pst_id2_ll *id2_head, char** buf) { size_t ret; pst_id2_ll* ptr; pst_holder h = {buf, NULL, 0}; DEBUG_ENT("pst_ff_getID2block"); ptr = pst_getID2(id2_head, id2); if (!ptr) { DEBUG_INDEX(("Cannot find id2 value %#"PRIi64"\n", id2)); DEBUG_RET(); return 0; } ret = pst_ff_getID2data(pf, ptr->id, &h); DEBUG_RET(); return ret; } size_t pst_ff_getID2data(pst_file *pf, pst_index_ll *ptr, pst_holder *h) { size_t ret; char *b = NULL, *t; DEBUG_ENT("pst_ff_getID2data"); if (!(ptr->id & 0x02)) { ret = pst_ff_getIDblock_dec(pf, ptr->id, &b); if (h->buf) { *(h->buf) = b; } else if ((h->base64 == 1) && h->fp) { t = base64_encode(b, ret); if (t) { (void)pst_fwrite(t, (size_t)1, strlen(t), h->fp); free(t); // caught by valgrind } free(b); } else if (h->fp) { (void)pst_fwrite(b, (size_t)1, ret, h->fp); free(b); } else { // h-> does not specify any output } } else { // here we will assume it is a block that points to others DEBUG_READ(("Assuming it is a multi-block record because of it's id\n")); ret = pst_ff_compile_ID(pf, ptr->id, h, (size_t)0); } DEBUG_RET(); return ret; } size_t pst_ff_compile_ID(pst_file *pf, uint64_t id, pst_holder *h, size_t size) { size_t z, a; uint16_t count, y; char *buf3 = NULL, *buf2 = NULL, *t; char *b_ptr; int line_count = 0; char base64_extra_chars[3]; uint32_t base64_extra = 0; pst_block_hdr block_hdr; pst_table3_rec table3_rec; //for type 3 (0x0101) blocks DEBUG_ENT("pst_ff_compile_ID"); a = pst_ff_getIDblock(pf, id, &buf3); if (!a) { if (buf3) free(buf3); DEBUG_RET(); return 0; } DEBUG_HEXDUMPC(buf3, a, 0x10); memcpy(&block_hdr, buf3, sizeof(block_hdr)); LE16_CPU(block_hdr.index_offset); LE16_CPU(block_hdr.type); LE32_CPU(block_hdr.offset); DEBUG_EMAIL(("block header (index_offset=%#hx, type=%#hx, offset=%#x)\n", block_hdr.index_offset, block_hdr.type, block_hdr.offset)); if (block_hdr.index_offset != (uint16_t)0x0101) { //type 3 DEBUG_WARN(("WARNING: not a type 0x0101 buffer, Treating as normal buffer\n")); if (pf->encryption) (void)pst_decrypt(id, buf3, a, pf->encryption); if (h->buf) *(h->buf) = buf3; else if (h->base64 == 1 && h->fp) { t = base64_encode(buf3, a); if (t) { (void)pst_fwrite(t, (size_t)1, strlen(t), h->fp); free(t); // caught by valgrind } free(buf3); } else if (h->fp) { (void)pst_fwrite(buf3, (size_t)1, a, h->fp); free(buf3); } else { // h-> does not specify any output } DEBUG_RET(); return a; } count = block_hdr.type; b_ptr = buf3 + 8; line_count = 0; for (y=0; ybuf) { *(h->buf) = realloc(*(h->buf), size+z+1); DEBUG_READ(("appending read data of size %i onto main buffer from pos %i\n", z, size)); memcpy(&((*(h->buf))[size]), buf2, z); } else if ((h->base64 == 1) && h->fp) { if (base64_extra) { // include any bytes left over from the last encoding buf2 = (char*)realloc(buf2, z+base64_extra); memmove(buf2+base64_extra, buf2, z); memcpy(buf2, base64_extra_chars, base64_extra); z += base64_extra; } // find out how many bytes will be left over after this encoding and save them base64_extra = z % 3; if (base64_extra) { z -= base64_extra; memcpy(base64_extra_chars, buf2+z, base64_extra); } // encode this chunk t = base64_encode_multiple(buf2, z, &line_count); if (t) { DEBUG_READ(("writing %i bytes to file as base64 [%i]. Currently %i\n", z, strlen(t), size)); (void)pst_fwrite(t, (size_t)1, strlen(t), h->fp); free(t); // caught by valgrind } } else if (h->fp) { DEBUG_READ(("writing %i bytes to file. Currently %i\n", z, size)); (void)pst_fwrite(buf2, (size_t)1, z, h->fp); } else { // h-> does not specify any output } size += z; } if ((h->base64 == 1) && h->fp && base64_extra) { // need to encode any bytes left over t = base64_encode_multiple(base64_extra_chars, (size_t)base64_extra, &line_count); if (t) { (void)pst_fwrite(t, (size_t)1, strlen(t), h->fp); free(t); // caught by valgrind } } free(buf3); if (buf2) free(buf2); DEBUG_RET(); return size; } #ifdef _WIN32 char * fileTimeToAscii(const FILETIME* filetime) { time_t t; DEBUG_ENT("fileTimeToAscii"); t = fileTimeToUnixTime(filetime, 0); if (t == -1) DEBUG_WARN(("ERROR time_t varible that was produced, is -1\n")); DEBUG_RET(); return ctime(&t); } time_t fileTimeToUnixTime(const FILETIME* filetime, DWORD *x) { SYSTEMTIME s; struct tm t; DEBUG_ENT("fileTimeToUnixTime"); memset (&t, 0, sizeof(struct tm)); FileTimeToSystemTime(filetime, &s); t.tm_year = s.wYear-1900; // this is what is required t.tm_mon = s.wMonth-1; // also required! It made me a bit confused t.tm_mday = s.wDay; t.tm_hour = s.wHour; t.tm_min = s.wMinute; t.tm_sec = s.wSecond; DEBUG_RET(); return mktime(&t); } struct tm * fileTimeToStructTM (const FILETIME *filetime) { time_t t1; t1 = fileTimeToUnixTime(filetime, 0); return gmtime(&t1); } #endif //_WIN32 int pst_stricmp(char *a, char *b) { // compare strings case-insensitive. // returns -1 if a < b, 0 if a==b, 1 if a > b while(*a != '\0' && *b != '\0' && toupper(*a)==toupper(*b)) { a++; b++; } if (toupper(*a) == toupper(*b)) return 0; else if (toupper(*a) < toupper(*b)) return -1; else return 1; } int pst_strincmp(char *a, char *b, size_t x) { // compare upto x chars in string a and b case-insensitively // returns -1 if a < b, 0 if a==b, 1 if a > b size_t y = 0; while (*a != '\0' && *b != '\0' && y < x && toupper(*a)==toupper(*b)) { a++; b++; y++; } // if we have reached the end of either string, or a and b still match if (*a == '\0' || *b == '\0' || toupper(*a)==toupper(*b)) return 0; else if (toupper(*a) < toupper(*b)) return -1; else return 1; } size_t pst_fwrite(const void* ptr, size_t size, size_t nmemb, FILE *stream) { size_t r; DEBUG_ENT("pst_fwrite"); if (ptr) r = fwrite(ptr, size, nmemb, stream); else { r = 0; DEBUG_WARN(("An attempt to write a NULL Pointer was made\n")); } DEBUG_RET(); return r; } char * pst_wide_to_single(char *wt, size_t size) { // returns the first byte of each wide char. the size is the number of bytes in source char *x, *y; DEBUG_ENT("pst_wide_to_single"); x = xmalloc((size/2)+1); y = x; while (size != 0 && *wt != '\0') { *y = *wt; wt+=2; size -= 2; y++; } *y = '\0'; DEBUG_RET(); return x; } char *pst_rfc2426_escape(char *str) { static char* buf = NULL; static size_t buflen = 0; char *ret, *a, *b; size_t x = 0; int y, z; DEBUG_ENT("rfc2426_escape"); if (!str) ret = str; else { // calculate space required to escape all the following characters y = pst_chr_count(str, ',') + pst_chr_count(str, '\\') + pst_chr_count(str, ';') + pst_chr_count(str, '\n'); z = pst_chr_count(str, '\r'); if (y == 0 && z == 0) // there isn't any extra space required ret = str; else { x = strlen(str) + y - z + 1; // don't forget room for the NUL if (x > buflen) { buf = (char*) realloc(buf, x); buflen = x; } a = str; b = buf; while (*a != '\0') { switch (*a) { case ',' : case '\\': case ';' : *(b++) = '\\'; *b = *a; break; case '\n': // newlines are encoded as "\n" *(b++) = '\\'; *b = 'n'; break; case '\r': // skip cr b--; break; default: *b=*a; } b++; a++; } *b = '\0'; // NUL-terminate the string (buf) ret = buf; } } DEBUG_RET(); return ret; } int pst_chr_count(char *str, char x) { int r = 0; while (*str) { if (*str == x) r++; str++; } return r; } char *pst_rfc2425_datetime_format(FILETIME *ft) { static char buffer[30]; struct tm *stm = NULL; DEBUG_ENT("rfc2425_datetime_format"); stm = fileTimeToStructTM(ft); if (strftime(buffer, sizeof(buffer), "%Y-%m-%dT%H:%M:%SZ", stm)==0) { DEBUG_INFO(("Problem occured formatting date\n")); } DEBUG_RET(); return buffer; } char *pst_rfc2445_datetime_format(FILETIME *ft) { static char buffer[30]; struct tm *stm = NULL; DEBUG_ENT("rfc2445_datetime_format"); stm = fileTimeToStructTM(ft); if (strftime(buffer, sizeof(buffer), "%Y%m%dT%H%M%SZ", stm)==0) { DEBUG_INFO(("Problem occured formatting date\n")); } DEBUG_RET(); return buffer; } /** Convert a code page integer into a string suitable for iconv * * @param cp the code page integer used in the pst file * @return pointer to a static buffer holding the string representation of the * equivalent iconv character set */ const char* codepage(int cp) { static char buffer[20]; switch (cp) { case 932 : return "iso-2022-jp"; case 936 : return "gb2313"; case 950 : return "big5"; case 20127 : return "us-ascii"; case 20269 : return "iso-6937"; case 20865 : return "iso-8859-15"; case 20866 : return "koi8-r"; case 21866 : return "koi8-u"; case 28591 : return "iso-8859-1"; case 28592 : return "iso-8859-2"; case 28595 : return "iso-8859-5"; case 28596 : return "iso-8859-6"; case 28597 : return "iso-8859-7"; case 28598 : return "iso-8859-8"; case 28599 : return "iso-8859-9"; + case 28600 : return "iso-8859-10"; + case 28601 : return "iso-8859-11"; + case 28602 : return "iso-8859-12"; + case 28603 : return "iso-8859-13"; + case 28604 : return "iso-8859-14"; + case 28605 : return "iso-8859-15"; + case 28606 : return "iso-8859-16"; case 50220 : return "iso-2022-jp"; case 50221 : return "csiso2022jp"; case 51932 : return "euc-jp"; case 51949 : return "euc-kr"; case 65000 : return "utf-7"; case 65001 : return "utf-8"; default : snprintf(buffer, sizeof(buffer), "windows-%d", cp); return buffer; } return NULL; } /** get the default character set for this item * @param item pointer to the mapi item of interest * @return default character set */ const char* pst_default_charset(pst_item *item) { return (item->body_charset.str) ? item->body_charset.str : (item->message_codepage) ? codepage(item->message_codepage) : (item->internet_cpid) ? codepage(item->internet_cpid) : "utf-8"; } -/** Convert str to utf8 if possible. Null strings are preserved +/** Convert str to utf8 if possible; null strings are preserved. * * @param item pointer to the mapi item of interest - * ¶m str pointer to the mapi string of interest + * @param str pointer to the mapi string of interest */ void pst_convert_utf8_null(pst_item *item, pst_string *str) { if (!str->str) return; pst_convert_utf8(item, str); } -/** Convert str to utf8 if possible. Null strings are converted into empty strings. +/** Convert str to utf8 if possible; null strings are converted into empty strings. * * @param item pointer to the mapi item of interest - * ¶m str pointer to the mapi string of interest + * @param str pointer to the mapi string of interest */ void pst_convert_utf8(pst_item *item, pst_string *str) { if (str->is_utf8) return; if (!str->str) { str->str = strdup(""); return; } const char *charset = pst_default_charset(item); if (!strcasecmp("utf-8", charset)) return; // already utf8 DEBUG_ENT("pst_convert_utf8"); vbuf *newer = vballoc(2); size_t rc = vb_8bit2utf8(newer, str->str, strlen(str->str) + 1, charset); if (rc == (size_t)-1) { free(newer->b); DEBUG_EMAIL(("Failed to convert %s to utf-8 - %s\n", charset, str->str)); } else { free(str->str); str->str = newer->b; str->is_utf8 = 1; } free(newer); DEBUG_RET(); } diff --git a/src/libpst.h b/src/libpst.h index 169330c..c75a658 100644 --- a/src/libpst.h +++ b/src/libpst.h @@ -1,606 +1,606 @@ /*** * libpst.h * Part of LibPST project * Written by David Smith * dave.s@earthcorp.com */ // LibPST - Library for Accessing Outlook .pst files // Dave Smith - davesmith@users.sourceforge.net #ifndef LIBPST_H #define LIBPST_H #include "common.h" // switch to maximal packing for all structures in the libpst interface // this is reverted at the end of this file #ifdef _MSC_VER #pragma pack(push, 1) #endif #if defined(__GNUC__) || defined (__SUNPRO_C) || defined(__SUNPRO_CC) #pragma pack(1) #endif #define PST_TYPE_NOTE 1 #define PST_TYPE_APPOINTMENT 8 #define PST_TYPE_CONTACT 9 #define PST_TYPE_JOURNAL 10 #define PST_TYPE_STICKYNOTE 11 #define PST_TYPE_TASK 12 #define PST_TYPE_OTHER 13 #define PST_TYPE_REPORT 14 // defines whether decryption is done on this bit of data #define PST_NO_ENC 0 #define PST_ENC 1 // defines types of possible encryption #define PST_NO_ENCRYPT 0 #define PST_COMP_ENCRYPT 1 #define PST_ENCRYPT 2 // defines different types of mappings #define PST_MAP_ATTRIB (uint32_t)1 #define PST_MAP_HEADER (uint32_t)2 // define my custom email attributes. #define PST_ATTRIB_HEADER -1 // defines types of free/busy values for appointment->showas #define PST_FREEBUSY_FREE 0 #define PST_FREEBUSY_TENTATIVE 1 #define PST_FREEBUSY_BUSY 2 #define PST_FREEBUSY_OUT_OF_OFFICE 3 // defines labels for appointment->label #define PST_APP_LABEL_NONE 0 // None #define PST_APP_LABEL_IMPORTANT 1 // Important #define PST_APP_LABEL_BUSINESS 2 // Business #define PST_APP_LABEL_PERSONAL 3 // Personal #define PST_APP_LABEL_VACATION 4 // Vacation #define PST_APP_LABEL_MUST_ATTEND 5 // Must Attend #define PST_APP_LABEL_TRAVEL_REQ 6 // Travel Required #define PST_APP_LABEL_NEEDS_PREP 7 // Needs Preparation #define PST_APP_LABEL_BIRTHDAY 8 // Birthday #define PST_APP_LABEL_ANNIVERSARY 9 // Anniversary #define PST_APP_LABEL_PHONE_CALL 10// Phone Call // define type of reccuring event #define PST_APP_RECUR_NONE 0 #define PST_APP_RECUR_DAILY 1 #define PST_APP_RECUR_WEEKLY 2 #define PST_APP_RECUR_MONTHLY 3 #define PST_APP_RECUR_YEARLY 4 typedef struct pst_misc_6_struct { int32_t i1; int32_t i2; int32_t i3; int32_t i4; int32_t i5; int32_t i6; } pst_misc_6; typedef struct pst_entryid_struct { int32_t u1; char entryid[16]; uint32_t id; } pst_entryid; typedef struct pst_desc_struct32 { uint32_t d_id; uint32_t desc_id; uint32_t tree_id; uint32_t parent_d_id; } pst_desc32; typedef struct pst_desc_structn { uint64_t d_id; uint64_t desc_id; uint64_t tree_id; uint32_t parent_d_id; // not 64 bit ?? uint32_t u1; // padding } pst_descn; typedef struct pst_index_struct32 { uint32_t id; uint32_t offset; uint16_t size; int16_t u1; } pst_index32; typedef struct pst_index_struct { uint64_t id; uint64_t offset; uint16_t size; int16_t u0; int32_t u1; } pst_index; typedef struct pst_index_tree32 { uint32_t id; uint32_t offset; uint32_t size; int32_t u1; struct pst_index_tree * next; } pst_index_ll32; typedef struct pst_index_tree { uint64_t id; uint64_t offset; uint64_t size; int64_t u1; struct pst_index_tree *next; } pst_index_ll; typedef struct pst_id2_tree { uint64_t id2; pst_index_ll *id; struct pst_id2_tree *child; struct pst_id2_tree *next; } pst_id2_ll; typedef struct pst_desc_tree { uint64_t d_id; uint64_t parent_d_id; pst_index_ll *desc; pst_index_ll *assoc_tree; int32_t no_child; struct pst_desc_tree *prev; struct pst_desc_tree *next; struct pst_desc_tree *parent; struct pst_desc_tree *child; struct pst_desc_tree *child_tail; } pst_desc_ll; typedef struct pst_string { int is_utf8; // 1 = true, 0 = false char *str; // either utf8 or some sbcs } pst_string; typedef struct pst_item_email { FILETIME *arrival_date; int autoforward; // 1 = true, 0 = not set, -1 = false pst_string cc_address; pst_string bcc_address; int32_t conversation_index; int conversion_prohibited; // 1 = true, 0 = false int delete_after_submit; // 1 = true, 0 = false int delivery_report; // 1 = true, 0 = false char *encrypted_body; size_t encrypted_body_size; char *encrypted_htmlbody; size_t encrypted_htmlbody_size; int32_t flag; pst_string header; pst_string htmlbody; int32_t importance; pst_string in_reply_to; int message_cc_me; // 1 = true, 0 = false int message_recip_me; // 1 = true, 0 = false int message_to_me; // 1 = true, 0 = false pst_string messageid; int32_t orig_sensitivity; pst_string original_bcc; pst_string original_cc; pst_string original_to; pst_string outlook_recipient; pst_string outlook_recipient_name; pst_string outlook_recipient2; pst_string outlook_sender; pst_string outlook_sender_name; pst_string outlook_sender2; int32_t priority; pst_string processed_subject; int read_receipt; // 1 = true, 0 = false pst_string recip_access; pst_string recip_address; pst_string recip2_access; pst_string recip2_address; int reply_requested; // 1 = true, 0 = false pst_string reply_to; pst_string return_path_address; int32_t rtf_body_char_count; int32_t rtf_body_crc; pst_string rtf_body_tag; char *rtf_compressed; uint32_t rtf_compressed_size; int rtf_in_sync; // 1 = true, 0 = doesn't exist, -1 = false int32_t rtf_ws_prefix_count; int32_t rtf_ws_trailing_count; pst_string sender_access; pst_string sender_address; pst_string sender2_access; pst_string sender2_address; int32_t sensitivity; FILETIME *sent_date; pst_entryid *sentmail_folder; pst_string sentto_address; // delivery report fields pst_string report_text; FILETIME *report_time; int32_t ndr_reason_code; int32_t ndr_diag_code; pst_string supplementary_info; int32_t ndr_status_code; } pst_item_email; typedef struct pst_item_folder { int32_t email_count; int32_t unseen_email_count; int32_t assoc_count; int subfolder; // 1 = true, 0 = false } pst_item_folder; typedef struct pst_item_message_store { pst_entryid *top_of_personal_folder; // 0x35e0 pst_entryid *default_outbox_folder; // 0x35e2 pst_entryid *deleted_items_folder; // 0x35e3 pst_entryid *sent_items_folder; // 0x35e4 pst_entryid *user_views_folder; // 0x35e5 pst_entryid *common_view_folder; // 0x35e6 pst_entryid *search_root_folder; // 0x35e7 pst_entryid *top_of_folder; // 0x7c07 int32_t valid_mask; // 0x35df // what folders the message store contains int32_t pwd_chksum; // 0x76ff } pst_item_message_store; typedef struct pst_item_contact { pst_string access_method; pst_string account_name; pst_string address1; pst_string address1a; pst_string address1_desc; pst_string address1_transport; pst_string address2; pst_string address2a; pst_string address2_desc; pst_string address2_transport; pst_string address3; pst_string address3a; pst_string address3_desc; pst_string address3_transport; pst_string assistant_name; pst_string assistant_phone; pst_string billing_information; FILETIME *birthday; pst_string business_address; // 0x801b pst_string business_city; pst_string business_country; pst_string business_fax; pst_string business_homepage; pst_string business_phone; pst_string business_phone2; pst_string business_po_box; pst_string business_postal_code; pst_string business_state; pst_string business_street; pst_string callback_phone; pst_string car_phone; pst_string company_main_phone; pst_string company_name; pst_string computer_name; pst_string customer_id; pst_string def_postal_address; pst_string department; pst_string display_name_prefix; pst_string first_name; pst_string followup; pst_string free_busy_address; pst_string ftp_site; pst_string fullname; int16_t gender; pst_string gov_id; pst_string hobbies; pst_string home_address; // 0x801a pst_string home_city; pst_string home_country; pst_string home_fax; pst_string home_phone; pst_string home_phone2; pst_string home_po_box; pst_string home_postal_code; pst_string home_state; pst_string home_street; pst_string initials; pst_string isdn_phone; pst_string job_title; pst_string keyword; pst_string language; pst_string location; int mail_permission; // 1 = true, 0 = false pst_string manager_name; pst_string middle_name; pst_string mileage; pst_string mobile_phone; pst_string nickname; pst_string office_loc; pst_string common_name; pst_string org_id; pst_string other_address; // 0x801c pst_string other_city; pst_string other_country; pst_string other_phone; pst_string other_po_box; pst_string other_postal_code; pst_string other_state; pst_string other_street; pst_string pager_phone; pst_string personal_homepage; pst_string pref_name; pst_string primary_fax; pst_string primary_phone; pst_string profession; pst_string radio_phone; int rich_text; // 1 = true, 0 = false pst_string spouse_name; pst_string suffix; pst_string surname; pst_string telex; pst_string transmittable_display_name; pst_string ttytdd_phone; FILETIME *wedding_anniversary; pst_string work_address_street; // 0x8045 pst_string work_address_city; // 0x8046 pst_string work_address_state; // 0x8047 pst_string work_address_postalcode; // 0x8048 pst_string work_address_country; // 0x8049 pst_string work_address_postofficebox; // 0x804a } pst_item_contact; typedef struct pst_item_attach { pst_string filename1; pst_string filename2; pst_string mimetype; char *data; size_t size; uint64_t id2_val; uint64_t id_val; // calculated from id2_val during creation of record pst_id2_ll *id2_head; // deep copy from child int32_t method; int32_t position; int32_t sequence; struct pst_item_attach *next; } pst_item_attach; typedef struct pst_item_extra_field { char *field_name; char *value; struct pst_item_extra_field *next; } pst_item_extra_field; typedef struct pst_item_journal { FILETIME *end; FILETIME *start; pst_string type; pst_string description; } pst_item_journal; typedef struct pst_item_appointment { FILETIME *end; pst_string location; int alarm; // 1 = true, 0 = false FILETIME *reminder; int32_t alarm_minutes; pst_string alarm_filename; FILETIME *start; pst_string timezonestring; int32_t showas; int32_t label; int all_day; // 1 = true, 0 = false pst_string recurrence; int32_t recurrence_type; FILETIME *recurrence_start; FILETIME *recurrence_end; } pst_item_appointment; typedef struct pst_item { struct pst_item_email *email; // data referring to email struct pst_item_folder *folder; // data referring to folder struct pst_item_contact *contact; // data referring to contact struct pst_item_attach *attach; // linked list of attachments struct pst_item_message_store *message_store; // data referring to the message store struct pst_item_extra_field *extra_fields; // linked list of extra headers and such struct pst_item_journal *journal; // data referring to a journal entry struct pst_item_appointment *appointment; // data referring to a calendar entry int type; char *ascii_type; pst_string file_as; pst_string comment; pst_string body_charset; // null if not specified pst_string body; // email, journal pst_string subject; // email, journal int32_t internet_cpid; int32_t message_codepage; int32_t message_size; pst_string outlook_version; char *record_key; // probably 16 bytes long. size_t record_key_size; int response_requested; // 1 = true, 0 = false FILETIME *create_date; FILETIME *modify_date; int private_member; // 1 = true, 0 = false } pst_item; typedef struct pst_x_attrib_ll { uint32_t type; uint32_t mytype; uint32_t map; void *data; struct pst_x_attrib_ll *next; } pst_x_attrib_ll; typedef struct pst_block_recorder { struct pst_block_recorder *next; int64_t offset; size_t size; int readcount; } pst_block_recorder; typedef struct pst_file { pst_index_ll *i_head, *i_tail; pst_desc_ll *d_head, *d_tail; pst_x_attrib_ll *x_head; pst_block_recorder *block_head; int do_read64; // 0 is 32-bit pst file, pre Outlook 2003; // 1 is 64-bit pst file, Outlook 2003 and later uint64_t index1; uint64_t index1_back; uint64_t index2; uint64_t index2_back; FILE * fp; // file pointer to opened PST file uint64_t size; // pst file size unsigned char encryption; // pst encryption setting unsigned char ind_type; // pst index type } pst_file; typedef struct pst_block_offset { int16_t from; int16_t to; } pst_block_offset; typedef struct pst_block_offset_pointer { char *from; char *to; int needfree; } pst_block_offset_pointer; -typedef struct pst_num_item { - uint32_t id; // not an id1 or id2, this is actually some sort of type code +typedef struct pst_mapi_element { + uint32_t mapi_id; char *data; uint32_t type; size_t size; char *extra; -} pst_num_item; +} pst_mapi_element; -typedef struct pst_num_array { - int32_t count_item; - int32_t orig_count; - int32_t count_array; - struct pst_num_item ** items; - struct pst_num_array *next; -} pst_num_array; +typedef struct pst_mapi_object { + int32_t count_elements; // count of active elements + int32_t orig_count; // originally allocated elements + int32_t count_objects; // number of mapi objects in the list + struct pst_mapi_element **elements; + struct pst_mapi_object *next; +} pst_mapi_object; typedef struct pst_holder { char **buf; FILE *fp; int base64; } pst_holder; typedef struct pst_subblock { char *buf; size_t read_size; size_t i_offset; } pst_subblock; typedef struct pst_subblocks { size_t subblock_count; pst_subblock *subs; } pst_subblocks; // prototypes int pst_open(pst_file *pf, char *name); int pst_close(pst_file *pf); pst_desc_ll * pst_getTopOfFolders(pst_file *pf, pst_item *root); size_t pst_attach_to_mem(pst_file *pf, pst_item_attach *attach, char **b); size_t pst_attach_to_file(pst_file *pf, pst_item_attach *attach, FILE* fp); size_t pst_attach_to_file_base64(pst_file *pf, pst_item_attach *attach, FILE* fp); int pst_load_index (pst_file *pf); pst_desc_ll* pst_getNextDptr(pst_desc_ll* d); int pst_load_extended_attributes(pst_file *pf); int pst_build_id_ptr(pst_file *pf, int64_t offset, int32_t depth, uint64_t linku1, uint64_t start_val, uint64_t end_val); int pst_build_desc_ptr(pst_file *pf, int64_t offset, int32_t depth, uint64_t linku1, uint64_t start_val, uint64_t end_val); pst_item* pst_getItem(pst_file *pf, pst_desc_ll *d_ptr); pst_item* pst_parse_item (pst_file *pf, pst_desc_ll *d_ptr, pst_id2_ll *m_head); -pst_num_array* pst_parse_block(pst_file *pf, uint64_t block_id, pst_id2_ll *i2_head, pst_num_array *na_head); -int pst_process(pst_num_array *list, pst_item *item, pst_item_attach *attach); -void pst_free_list(pst_num_array *list); +pst_mapi_object* pst_parse_block(pst_file *pf, uint64_t block_id, pst_id2_ll *i2_head); +int pst_process(pst_mapi_object *list, pst_item *item, pst_item_attach *attach); +void pst_free_list(pst_mapi_object *list); void pst_freeItem(pst_item *item); void pst_free_id2(pst_id2_ll * head); void pst_free_id (pst_index_ll *head); void pst_free_desc (pst_desc_ll *head); void pst_free_xattrib(pst_x_attrib_ll *x); int pst_getBlockOffsetPointer(pst_file *pf, pst_id2_ll *i2_head, pst_subblocks *subblocks, uint32_t offset, pst_block_offset_pointer *p); int pst_getBlockOffset(char *buf, size_t read_size, uint32_t i_offset, uint32_t offset, pst_block_offset *p); pst_id2_ll* pst_build_id2(pst_file *pf, pst_index_ll* list); pst_index_ll* pst_getID(pst_file* pf, uint64_t id); pst_id2_ll* pst_getID2(pst_id2_ll * ptr, uint64_t id); pst_desc_ll* pst_getDptr(pst_file *pf, uint64_t id); size_t pst_read_block_size(pst_file *pf, int64_t offset, size_t size, char **buf); int pst_decrypt(uint64_t id, char *buf, size_t size, unsigned char type); uint64_t pst_getIntAt(pst_file *pf, char *buf); uint64_t pst_getIntAtPos(pst_file *pf, int64_t pos); size_t pst_getAtPos(pst_file *pf, int64_t pos, void* buf, size_t size); size_t pst_ff_getIDblock_dec(pst_file *pf, uint64_t id, char **b); size_t pst_ff_getIDblock(pst_file *pf, uint64_t id, char** b); size_t pst_ff_getID2block(pst_file *pf, uint64_t id2, pst_id2_ll *id2_head, char** buf); size_t pst_ff_getID2data(pst_file *pf, pst_index_ll *ptr, pst_holder *h); size_t pst_ff_compile_ID(pst_file *pf, uint64_t id, pst_holder *h, size_t size); int pst_strincmp(char *a, char *b, size_t x); int pst_stricmp(char *a, char *b); size_t pst_fwrite(const void*ptr, size_t size, size_t nmemb, FILE*stream); char * pst_wide_to_single(char *wt, size_t size); char * pst_rfc2426_escape(char *str); int pst_chr_count(char *str, char x); char * pst_rfc2425_datetime_format(FILETIME *ft); char * pst_rfc2445_datetime_format(FILETIME *ft); void pst_printDptr(pst_file *pf, pst_desc_ll *ptr); void pst_printIDptr(pst_file* pf); void pst_printID2ptr(pst_id2_ll *ptr); const char* pst_codepage(int cp); const char* pst_default_charset(pst_item *item); void pst_convert_utf8_null(pst_item *item, pst_string *str); void pst_convert_utf8(pst_item *item, pst_string *str); // switch from maximal packing back to default packing // undo the packing from the beginning of this file #ifdef _MSC_VER #pragma pack(pop) #endif #if defined(__GNUC__) || defined (__SUNPRO_C) || defined(__SUNPRO_CC) #pragma pack() #endif #endif // defined LIBPST_H diff --git a/xml/libpst.in b/xml/libpst.in index 4baf4ec..674c45b 100644 --- a/xml/libpst.in +++ b/xml/libpst.in @@ -1,2166 +1,2159 @@ @PACKAGE@ Utilities - Version @VERSION@ Packages The various source and binary packages are available at http://www.five-ten-sg.com/@PACKAGE@/packages/. The most recent documentation is available at http://www.five-ten-sg.com/@PACKAGE@/. A Mercurial source code repository for this project is available at http://hg.five-ten-sg.com/@PACKAGE@/. This version can now convert both 32 bit Outlook files (pre 2003), and the 64 bit Outlook 2003 pst files. Utilities are supplied to convert email messages to both mbox and MH mailbox formats, and to DII load file format for use with many of the CT Summation products. Contacts can be converted to a simple list, to vcard format, or to ldif format for import to an LDAP server. The libpff project has some excellent documentation of the pst file format. - 2009-02-28 + 2009-03-11 readpst 1 readpst @VERSION@ readpst convert PST (MS Outlook Personal Folders) files to mbox and other formats Synopsis readpst pstfile Description readpst is a program that can read an Outlook PST (Personal Folders) file and convert it into an mbox file, a format suitable for KMail, a recursive mbox structure, or separate emails. Options -C Decrypt the entire pst file and dump it to stdout. -D Include deleted items in the output. -M Output messages in MH 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. -S 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 increasing in intervals of 1 (ie 1, 2, 3, ...). Any attachments are saved alongside each email as XXXXXXXXX-attach1, XXXXXXXXX-attach2 and so on, or with the name of the attachment if one is present. -V Show program version and exit. -b Do not save the attachments for the RTF format of the email body. -c format Set the Contact output mode. Use -cv for vcard format or -cl for an email list. -d debug-file Specify name of debug log file. The log file is not an ascii file, it is a binary file readable by readpstlog. -h Show summary of options and exit. -k Changes the output format to KMail. -o output-directory Specifies the output directory. The directory must already exist, and is entered after the PST file is opened, but before any processing of files commences. -q Changes to silent mode. No feedback is printed to the screen, except for error messages. -r 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. -w Overwrite any previous output files. Beware: When used with the -S switch, this will remove all files from the target folder before writing. This is to keep the count of emails and attachments correct. See Also readpstlog 1 Author This manual page was originally written by Dave Smith <dave.s@earthcorp.com>, and updated by Joe Nahmias <joe@nahmias.net> for the Debian GNU/Linux system (but may be used by others). It was subsequently updated by Brad Hards <bradh@frogmouth.net>, and converted to xml format by Carl Byington <carl@five-ten-sg.com>. Copyright Copyright (C) 2002 by David Smith <dave.s@earthcorp.com>. XML version Copyright (C) 2008 by 510 Software Group <carl@five-ten-sg.com>. 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, or (at your option) any later version. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, please write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. Version @VERSION@ - 2009-02-28 + 2009-03-11 lspst 1 lspst @VERSION@ lspst list PST (MS Outlook Personal Folders) file data Synopsis lspst pstfile Options -V Show program version and exit. -d debug-file Specify name of debug log file. The log file is not an ascii file, it is a binary file readable by readpstlog. -h Show summary of options and exit. Description lspst is a program that can read an Outlook PST (Personal Folders) file and produce a simple listing of the data (contacts, email subjects, etc). See Also readpstlog 1 Author lspst was written by Joe Nahmias <joe@nahmias.net> based on readpst. This man page was written by 510 Software Group <carl@five-ten-sg.com>. Copyright Copyright (C) 2004 by Joe Nahmias <joe@nahmias.net>. 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, or (at your option) any later version. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, please write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. Version @VERSION@ - 2009-02-28 + 2009-03-11 readpstlog 1 readpstlog @VERSION@ readpstlog convert a readpst logfile to text format Synopsis readpstlog logfile Description readpstlog is a program that converts the binary logfile generated by readpst to a more desirable text format. Options -f format Sets the format of the text log output. Currently, the only valid output formats are T, for single line text, D for the default default multi line format, and I for an indented style with single line text. -t include-types Print only the specified types of log messages. Types are specified in a comma-delimited list (e.g. 3,10,5,6). -x exclude-types Exclude the specified types of log messages. Types are specified in a comma-delimited list (e.g. 3,10,5,6). Message Types readpstlog understands the following types of log messages: 1 File accesses 2 Index accesses 3 New email found 4 Warnings 5 Read accesses 6 Informational messages 7 Main function calls 8 Decrypting calls 9 Function entries 10 Function exits 11 HexDump calls Author This manual page was written by Joe Nahmias <joe@nahmias.net> for the Debian GNU/Linux system (but may be used by others). It was converted to xml format by Carl Byington <carl@five-ten-sg.com>. TODO The binary debug log file is generally much larger than the .pst file, so we need to switch to ftello/fseeko there also to handle files larger than 2GB. Copyright Copyright (C) 2002 by David Smith <dave.s@earthcorp.com>. XML version Copyright (C) 2008 by 510 Software Group <carl@five-ten-sg.com>. 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, or (at your option) any later version. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, please write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. Version @VERSION@ - 2009-02-28 + 2009-03-11 pst2ldif 1 pst2ldif @VERSION@ pst2ldif extract contacts from a MS Outlook .pst file in .ldif format Synopsis pst2ldif - pstfilename Options -V Show program version. Subsequent options are then ignored. -b ldap-base Sets the ldap base value used in the dn records. You probably want to use something like "o=organization, c=US". -c class Sets the objectClass values for the contact items. This class needs to be defined in the schema used by your LDAP server, and at a minimum it must contain the ldap attributes given below. This option may be specified multiple times to generate entries with multiple object classes. - - -C character-set - - Specify the name of the character set used in your pst file for contacts. - - -d debug-file Specify name of debug log file. The log file is not an ascii file, it is a binary file readable by readpstlog. -l extra-line Specify an extra line to be added to each ldap entry. This option may be specified multiple times to add multiple lines to each ldap entry. -o Use the old ldap schema, rather than the default new ldap schema. The old schema generates multiple postalAddress attributes for a single entry. The new schema generates a single postalAddress (and homePostalAddress when available) attribute with $ delimiters as specified in RFC4517. Using the old schema also generates two extra leading entries, one for "dn:ldap base", and one for "dn: cn=root, ldap base". -h Show summary of options. Subsequent options are then ignored. Description pst2ldif reads the contact information from a MS Outlook .pst file and produces a .ldif file that may be used to import those contacts into an LDAP database. The following ldap attributes are generated for the old ldap schema: cn givenName sn personalTitle company mail postalAddress l st postalCode c homePhone telephoneNumber facsimileTelephoneNumber mobile description The following attributes are generated for the new ldap schema: cn givenName sn title o mail postalAddress homePostalAddress l st postalCode c homePhone telephoneNumber facsimileTelephoneNumber mobile description labeledURI Copyright Copyright (C) 2008 by 510 Software Group <carl@five-ten-sg.com> 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, or (at your option) any later version. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, please write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. Version @VERSION@ - 2009-02-28 + 2009-03-11 pst2dii 1 pst2dii @VERSION@ pst2dii extract email messages from a MS Outlook .pst file in DII load format Synopsis pst2dii pstfilename Options -B bates-prefix Sets the bates prefix string. The bates sequence number is appended to this string, and printed on each page. -O dii-output-file Name of the output DII load file. -V Show program version. Subsequent options are then ignored. -b bates-number Starting bates sequence number. The default is zero. -c bates-color Font color for the bates stamp on each page, specified as 6 hex digits as rrggbb values. The default is ff0000 for bright red. -d debug-file Specify name of debug log file. The log file is not an ascii file, it is a binary file readable by readpstlog. -f ttf-font-file Specify name of a true type font file. This should be a fixed pitch font. -h Show summary of options. Subsequent options are then ignored. -o output-directory Specifies the output directory. The directory must already exist. Description pst2dii reads the email messages from a MS Outlook .pst file and produces a DII load file that may be used to import message summaries into a Summation DII system. The DII output file contains references to the image and attachment files in the output directory. Copyright Copyright (C) 2008 by 510 Software Group <carl@five-ten-sg.com> 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, or (at your option) any later version. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, please write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. Version @VERSION@ - 2009-02-28 + 2009-03-11 outlook.pst 5 outlook.pst format of MS Outlook .pst file Synopsis outlook.pst Overview Low level or primitive items in a .pst file are identified by an I_ID value. Higher level or composite items in a .pst file are identified by a D_ID value. There are two separate b-trees indexed by these I_ID and D_ID values. Starting with Outlook 2003, the file format changed from one with 32 bit pointers, to one with 64 bit pointers. We describe both formats here. 32 bit File Header The 32 bit file header is located at offset 0 in the .pst file. We only support index types 0x0e, 0x0f, 0x15, and 0x17, and encryption types 0x00, 0x01 and 0x02. Index type 0x0e is the older 32 bit Outlook format. Index type 0x0f seems to be rare, and so far the data seems to be identical to that in type 0x0e files. Index type 0x17 is the newer 64 bit Outlook format. Index type 0x15 seems to be rare, and according to the libpff project should have the same format as type 0x17 files. It was found in a 64-bit pst file created by Visual Recovery. It may be that index types less than 0x10 are 32 bit, and index types greater than or equal to 0x10 are 64 bit, and the low order four bits of the index type is some subtype or minor version number. Encryption type 0x00 is no encryption, type 0x01 is "compressible" encryption which is a simple substitution cipher, and type 0x02 is "strong" encryption, which is a simple three rotor Enigma cipher from WWII. offsetIndex1 is the file offset of the root of the index1 b-tree, which contains (I_ID, offset, size, unknown) tuples for each item in the file. backPointer1 is the value that should appear in the parent pointer of that root node. offsetIndex2 is the file offset of the root of the index2 b-tree, which contains (D_ID, DESC-I_ID, TREE-I_ID, PARENT-D_ID) tuples for each item in the file. backPointer2 is the value that should appear in the parent pointer of that root node. 64 bit File Header The 64 bit file header is located at offset 0 in the .pst file. 32 bit Index 1 Node The 32 bit index1 b-tree nodes are 512 byte blocks with the following format. The itemCount specifies the number of 12 byte records that are active. The nodeLevel is non-zero for this style of nodes. The leaf nodes have a different format. The backPointer must match the backPointer from the triple that pointed to this node. Each item in this node is a triple of (I_ID, backPointer, offset) where the offset points to the next deeper node in the tree, the backPointer value must match the backPointer in that deeper node, and I_ID is the lowest I_ID value in the subtree. 64 bit Index 1 Node The 64 bit index1 b-tree nodes are 512 byte blocks with the following format. The itemCount specifies the number of 24 byte records that are active. The nodeLevel is non-zero for this style of nodes. The leaf nodes have a different format. The backPointer must match the backPointer from the triple that pointed to this node. Each item in this node is a triple of (I_ID, backPointer, offset) where the offset points to the next deeper node in the tree, the backPointer value must match the backPointer in that deeper node, and I_ID is the lowest I_ID value in the subtree. 32 bit Index 1 Leaf Node The 32 bit index1 b-tree leaf nodes are 512 byte blocks with the following format. The itemCount specifies the number of 12 byte records that are active. The nodeLevel is zero for these leaf nodes. The backPointer must match the backPointer from the triple that pointed to this node. Each item in this node is a tuple of (I_ID, offset, size, unknown) The two low order bits of the I_ID value seem to be flags. I have never seen a case with bit zero set. Bit one indicates that the item is not encrypted. Note that references to these I_ID values elsewhere may have the low order bit set (and I don't know what that means), but when we do the search in this tree we need to clear that bit so that we can find the correct item. 64 bit Index 1 Leaf Node The 64 bit index1 b-tree leaf nodes are 512 byte blocks with the following format. The itemCount specifies the number of 24 byte records that are active. The nodeLevel is zero for these leaf nodes. The backPointer must match the backPointer from the triple that pointed to this node. Each item in this node is a tuple of (I_ID, offset, size, unknown) The two low order bits of the I_ID value seem to be flags. I have never seen a case with bit zero set. Bit one indicates that the item is not encrypted. Note that references to these I_ID values elsewhere may have the low order bit set (and I don't know what that means), but when we do the search in this tree we need to clear that bit so that we can find the correct item. 32 bit Index 2 Node The 32 bit index2 b-tree nodes are 512 byte blocks with the following format. The itemCount specifies the number of 12 byte records that are active. The nodeLevel is non-zero for this style of nodes. The leaf nodes have a different format. The backPointer must match the backPointer from the triple that pointed to this node. Each item in this node is a triple of (D_ID, backPointer, offset) where the offset points to the next deeper node in the tree, the backPointer value must match the backPointer in that deeper node, and D_ID is the lowest D_ID value in the subtree. 64 bit Index 2 Node The 64 bit index2 b-tree nodes are 512 byte blocks with the following format. The itemCount specifies the number of 24 byte records that are active. The nodeLevel is non-zero for this style of nodes. The leaf nodes have a different format. The backPointer must match the backPointer from the triple that pointed to this node. Each item in this node is a triple of (D_ID, backPointer, offset) where the offset points to the next deeper node in the tree, the backPointer value must match the backPointer in that deeper node, and D_ID is the lowest D_ID value in the subtree. 32 bit Index 2 Leaf Node The 32 bit index2 b-tree leaf nodes are 512 byte blocks with the following format. The itemCount specifies the number of 16 byte records that are active. The nodeLevel is zero for these leaf nodes. The backPointer must match the backPointer from the triple that pointed to this node. Each item in this node is a tuple of (D_ID, DESC-I_ID, TREE-I_ID, PARENT-D_ID) The DESC-I_ID points to the main data for this item (Associated Descriptor Items 0x7cec, 0xbcec, or 0x0101) via the index1 tree. The TREE-I_ID is zero or points to an Associated Tree Item 0x0002 via the index1 tree. The PARENT-D_ID points to the parent of this item in this index2 tree. 64 bit Index 2 Leaf Node The 64 bit index2 b-tree leaf nodes are 512 byte blocks with the following format. The itemCount specifies the number of 32 byte records that are active. The nodeLevel is zero for these leaf nodes. The backPointer must match the backPointer from the triple that pointed to this node. Each item in this node is a tuple of (D_ID, DESC-I_ID, TREE-I_ID, PARENT-D_ID) The DESC-I_ID points to the main data for this item (Associated Descriptor Items 0x7cec, 0xbcec, or 0x0101) via the index1 tree. The TREE-I_ID is zero or points to an Associated Tree Item 0x0002 via the index1 tree. The PARENT-D_ID points to the parent of this item in this index2 tree. 32 bit Associated Tree Item 0x0002 A D_ID value may point to an entry in the index2 tree with a non-zero TREE-I_ID which points to this descriptor block via the index1 tree. It maps local ID2 values (referenced in the main data for the original D_ID item) to I_ID values. This descriptor block contains triples of (ID2, I_ID, CHILD-I_ID) where the local ID2 data can be found via I_ID, and CHILD-I_ID is either zero or it points to another Associated Tree Item via the index1 tree. In the above 32 bit leaf node, we have a tuple of (0x61, 0x02a82c, 0x02a836, 0) 0x02a836 is the I_ID of the associated tree, and we can lookup that I_ID value in the index1 b-tree to find the (offset,size) of the data in the .pst file. 64 bit Associated Tree Item 0x0002 This descriptor block contains a tree that maps local ID2 values to I_ID entries, similar to the 32 bit version described above. Associated Descriptor Item 0xbcec Contains information about the item, which may be email, contact, or other outlook types. In the above leaf node, we have a tuple of (0x21, 0x00e638, 0, 0) 0x00e638 is the I_ID of the associated descriptor, and we can lookup that I_ID value in the index1 b-tree to find the (offset,size) of the data in the .pst file. This descriptor is eventually decoded to a list of MAPI elements. Note the signature of 0xbcec. There are other descriptor block formats with other signatures. Note the indexOffset of 0x013c - starting at that position in the descriptor block, we have an array of two byte integers. The first integer (0x000b) is a (count-1) of the number of overlapping pairs following the count. The first pair is (0, 0xc), the next pair is (0xc, 0x14) and the last (12th) pair is (0x123, 0x13b). These pairs are (start,end+1) offsets of items in this block. So we have count+2 integers following the count value. Note the b5offset of 0x0020, which is a type that I will call an index reference. Such index references have at least two different forms, and may point to data either in this block, or in some other block. External pointer references have the low order 4 bits all set, and are ID2 values that can be used to fetch data. This value of 0x0020 is an internal pointer reference, which needs to be right shifted by 4 bits to become 0x0002, which is then a byte offset to be added to the above indexOffset plus two (to skip the count), so it points to the (0xc, 0x14) pair. So far we have only described internal index references where the high order 16 bits are zero. That suffices for single descriptor blocks. But in the case of the type 0x0101 descriptor block, we have an array of subblocks. In this case, the high order 16 bits of an internal index reference are used to select the subblock. Each subblock starts with a 16 bit indexOffset which points to the count and array of 16 bit integer pairs which are offsets in the current subblock. Finally, we have the offset and size of the "b5" block located at offset 0xc with a size of 8 bytes in this descriptor block. The "b5" block has the following format: Note the descoffset of 0x0040, which again is an index reference. In this case, it is an internal pointer reference, which needs to be right shifted by 4 bits to become 0x0004, which is then a byte offset to be added to the above indexOffset plus two (to skip the count), so it points to the (0x14, 0x7c) pair. The datasize (6) plus the b5 code (02) gives the size of the entries, in this case 8 bytes. We now have the offset 0x14 of the descriptor array, composed of 8 byte entries that describe MAPI elements. Each descriptor entry has the following format: For some reference types (2, 3, 0xb) the value is used directly. Otherwise, the value is an index reference, which is either an ID2 value, or an offset, to be right shifted by 4 bits and used to fetch a pair from the index table to find the offset and size of the item in this descriptor block. The following reference types are known, but not all of these are implemented in the code yet. The following item types are known, but not all of these are implemented in the code yet. Associated Descriptor Item 0x7cec This style of descriptor block is similar to the 0xbcec format. This descriptor is also eventually decoded to a list of MAPI elements. Note the signature of 0x7cec. There are other descriptor block formats with other signatures. Note the indexOffset of 0x017a - starting at that position in the descriptor block, we have an array of two byte integers. The first integer (0x0006) is a (count-1) of the number of overlapping pairs following the count. The first pair is (0, 0xc), the next pair is (0xc, 0x14) and the last (7th) pair is (0x160, 0x179). These pairs are (start,end+1) offsets of items in this block. So we have count+2 integers following the count value. Note the 7coffset of 0x0040, which is an index reference. In this case, it is an internal reference pointer, which needs to be right shifted by 4 bits to become 0x0004, which is then a byte offset to be added to the above indexOffset plus two (to skip the count), so it points to the (0x14, 0xea) pair. We have the offset and size of the "7c" block located at offset 0x14 with a size of 214 bytes in this case. The "7c" block starts with a header with the following format: Note the b5Offset of 0x0020, which is an index reference. In this case, it is an internal reference pointer, which needs to be right shifted by 4 bits to become 0x0002, which is then a byte offset to be added to the above indexOffset plus two (to skip the count), so it points to the (0xc, 0x14) pair. Finally, we have the offset and size of the "b5" block located at offset 0xc with a size of 8 bytes in this descriptor block. The "b5" block has the following format: Note the descoffset of 0x0060, which again is an index reference. In this case, it is an internal pointer reference, which needs to be right shifted by 4 bits to become 0x0006, which is then a byte offset to be added to the above indexOffset plus two (to skip the count), so it points to the (0xea, 0xf0) pair. The datasize (2) plus the b5 code (04) gives the size of the entries, in this case 6 bytes. We now have the offset 0xea of an unused block of data in an unknown format, composed of 6 byte entries. That gives us (0xf0 - 0xea)/6 = 1, so we have a recordCount of one. We have seen cases where the descoffset in the b5 block is zero, and the index2Offset in the 7c block is zero. This has been seen for objects that seem to be attachments on messages that have been read. Before the message was read, it did not have any attachments. Note the index2Offset above of 0x0080, which again is an index reference. In this case, it is an internal pointer reference, which needs to be right shifted by 4 bits to become 0x0008, which is then a byte offset to be added to the above indexOffset plus two (to skip the count), so it points to the (0xf0, 0x155) pair. This is an array of tables of four byte integers. We will call these the IND2 tables. The size of each of these tables is specified by the recordSize field of the "7c" header. The number of these tables is the above recordCount value derived from the "b5" block. Now the remaining data in the "7c" block after the header starts at offset 0x2a. There should be itemCount 8 byte items here, with the following format: The ind2Offset is a byte offset into the current IND2 table of some value. If that is a four byte integer value, then once we fetch that, we have the same triple (item type, reference type, value) as we find in the 0xbcec style descriptor blocks. If not, then this value is used directly. These 8 byte descriptors are processed recordCount times, each time using the next IND2 table. The item and reference types are as described above for the 0xbcec format descriptor block. 32 bit Associated Descriptor Item 0x0101 This descriptor block contains a list of I_ID values. It is used when an I_ID (that would normally point to a type 0x7cec or 0xbcec descriptor block) contains more data than can fit in any single descriptor of those types. In this case, it points to a type 0x0101 block, which contains a list of I_ID values that themselves point to the actual descriptor blocks. The total length value in the 0x0101 header is the sum of the lengths of the blocks pointed to by the list of I_ID values. The result is an array of subblocks, that may contain index references where the high order 16 bits specify which descriptor subblock to use. Only the first descriptor subblock contains the signature (0xbcec or 0x7cec). 64 bit Associated Descriptor Item 0x0101 This descriptor block contains a list of I_ID values, similar to the 32 bit version described above.