diff --git a/ChangeLog b/ChangeLog index cb2d81e..7cb6d7b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,940 +1,940 @@ LibPST 0.6.73 (2019-07-25) * Tim Dufrane - fix segfault in pst_close() LibPST 0.6.72 (2018-08-01) =============================== * Alfredo Esteban - add -l and -f options to lspst. * fix bydays recurring appointment, allow all 7 days - * update for fedora python packaging + * update for Fedora Python packaging LibPST 0.6.71 (2017-07-21) =============================== * Zachary Travis - Add support for the OST 2013 format, and Content-Disposition filename key fix for outlook compatibility LibPST 0.6.70 (2017-02-08) =============================== * Jeffrey Morlan - pst_getID2 must not recurse into children LibPST 0.6.69 (2016-10-29) =============================== * fix bugs in code allowing folders containing multiple item types LibPST 0.6.68 (2016-08-29) =============================== * allow folders containing multiple item types, e.g. email and calendar * better detection of valid internet headers LibPST 0.6.67 (2016-07-06) =============================== * Jeffrey Morlan - multiple bug fixes and an optimization see 'hg log -v' for details LibPST 0.6.66 (2015-12-21) =============================== * Igor Stroh - Added Content-ID header support LibPST 0.6.65 (2015-09-11) =============================== * Jeffrey Morlan - fix multiple Content-Type headers * Hans Liss - debug level output LibPST 0.6.64 (2015-03-09) =============================== * AJ Shankar fixes for attachment processing and body encodings that contain embedded null chars LibPST 0.6.63 (2013-12-27) =============================== * Daniel Gryniewicz found buffer overrun in LIST_COPY_TIME LibPST 0.6.62 (2013-09-22) =============================== * 983596 - Old dependency filter breaks file coloring LibPST 0.6.61 (2013-08-06) =============================== * move documentation to unversioned directory LibPST 0.6.60 (2013-06-12) =============================== * patch from Dominique Leuenberger to add AC_USE_SYSTEM_EXTENSIONS * add readpst -a option for attachment stripping LibPST 0.6.59 (2013-05-17) =============================== * add autoconf checking for libgsf LibPST 0.6.58 (2012-12-28) =============================== * fix From quoting on embedded rfc/822 messages LibPST 0.6.57 (2012-12-27) =============================== * remove useless dependencies LibPST 0.6.56 (2012-12-24) =============================== * merge -m .msg files code into main branch LibPST 0.6.55 (2012-05-08) =============================== * preserve bcc headers * document -C switch to set default character set * space after colon is not required in header fields LibPST 0.6.54 (2011-11-04) =============================== * embedded rfc822 messages might contain rtf encoded bodies LibPST 0.6.53 (2011-07-10) =============================== * add Status: header in output * allow fork for parallel processing of individual email folders in separate mode * proper handling of --with-boost-python option LibPST 0.6.52 (2011-05-22) =============================== * fix dangling freed pointer in embedded rfc822 message processing * allow broken outlook internet header field - it sometimes contains fragments of the message body rather than headers LibPST 0.6.51 (2011-04-17) =============================== * fix for buffer overrun; attachment size from the secondary list of mapi elements overwrote proper size from the primary list of mapi elements. - fedora bugzilla 696263 + Fedora bugzilla 696263 LibPST 0.6.50 (2010-12-24) =============================== * rfc2047 and rfc2231 encoding for non-ascii headers and attachment filenames LibPST 0.6.49 (2010-09-13) =============================== * fix to ignore embedded objects that are not email messages LibPST 0.6.48 (2010-09-02) =============================== * fix for broken internet headers from Outlook. * fix ax_python.m4 to look for python2.7 * Subpackage Licensing, add COPYING to -libs. * use mboxrd from quoting for output formats with multiple messages per file * use no from quoting for output formats with single message per file LibPST 0.6.47 (2010-05-07) =============================== * patches from Kenneth Berland for solaris. * fix output file name numbering to start at 1 rather than 2. LibPST 0.6.46 (2010-02-13) =============================== * prefer libpthread over librt for finding sem_init function. - * rebuild for fedora 13 change in implicit dso linking semantics. + * rebuild for Fedora 13 change in implicit dso linking semantics. LibPST 0.6.45 (2009-11-18) =============================== * patch from Hugo DesRosiers to export categories and notes into vcards. * extend that patch to export categories into vcalendar appointments also. LibPST 0.6.44 (2009-09-20) =============================== * fix --help usage; readpstlog is gone, debug files are now ascii text. * patch from Lee Ayres to add file name extensions in separate mode. * allow mixed items types in a folder in separate mode. LibPST 0.6.43 (2009-09-12) =============================== * patches from Justin Greer. add code pages 1200 and 1201 to the list for iconv add support for 0x0201 indirect blocks that point to 0x0101 blocks add readpst -t option to select output item types fix (remove) extra new line inside headers * cleanup base64 encoding to remove duplicate code. * patch from Chris White to avoid segfault with embedded appointments. * patch from Roberto Polli to add creation of some Thunderbird specific meta files. * patch from Justin Greer to ignore b5 tables at offset zero. * output type filtering can now be used to handle folders with multiple item types. * better decoding of rfc822 embedded message attachments. * better detection of dsn delivery reports LibPST 0.6.42 (2009-09-03) =============================== * patch from Fridrich Strba to build with DJGPP DOS cross-compiler. LibPST 0.6.41 (2009-06-23) =============================== * fix ax_python detection - should not use locate command - * checking for fedora versions is not needed + * checking for Fedora versions is not needed LibPST 0.6.40 (2009-06-23) =============================== - * fedora 11 has python2.6 + * Fedora 11 has python2.6 * remove pdf version of the man pages LibPST 0.6.39 (2009-06-21) =============================== - * fedora > 10 moved to boost-python-devel + * Fedora > 10 moved to boost-python-devel LibPST 0.6.38 (2009-06-21) =============================== - * add python module interface to the shared library for easy scripting. + * add Python module interface to the shared library for easy scripting. * the shared library must never write to stdout or stderr. * fix pst_attach_to_mem so the caller does not need to initialize the buffer pointer. * remove readpst -C switch, obsolete debugging code. * update version to 4:0:0 since we made many changes to the interface. * removed contact->access_method since we don't have a mapi element for it. * changed pst_attach_to_mem to return pst_binary structure. * decode more recurrence mapi elements. * readpst changes for parallel operation on multi processor machines. * remove readpstlog - the debug log files are now plain ascii. Add locking if needed so parallel jobs can produce debug logs. * more cleanup of the shared library interface, but still not fully thread safe. * make nested mime multipart/alternative to hold the text/html parts so the topmost level is almost always multipart/mixed. * the shared library interface should now be thread safe. * patch from Fridrich Strba to build on win32. * remove unreferenced code. LibPST 0.6.37 (2009-04-17) =============================== * add pst_attach_to_mem() back into the shared library interface. * improve developer documentation. * fix memory leak caught by valgrind. LibPST 0.6.36 (2009-04-14) =============================== * spec file cleanup with multiple sub packages. * add doxygen devel-doc documentation for the shared library. * switch back to fully versioned subpackage dependencies. * more cleanup on external names in the shared object file. LibPST 0.6.35 (2009-04-08) =============================== * fix bug where we failed to pickup the last extended attribute. * patch from Emmanuel Andry to fix potential security bug in pst2dii with printf(err). * properly add trailing mime boundary in all modes. * move version-info into main configure.in, and set it properly * prefix all external symbols in the shared library with pst_ to avoid symbol clashes with other shared libraries. - * new debianization from hggdh. + * new Debianization from hggdh. * build separate libpst, libpst-libs, libpst-devel rpms. * remove many functions from the interface by making them static. LibPST 0.6.34 (2009-03-19) =============================== * improve consistency checking when fetching items from the pst file. * avoid putting mixed item types into the same output folder. LibPST 0.6.33 (2009-03-17) =============================== - * fix fedora 11 type mismatch warning (actually an error in this case). - * fix large file support, some sytems require config.h to be included + * fix Fedora 11 type mismatch warning (actually an error in this case). + * fix large file support, some systems require config.h to be included earlier in the compilation. * compensate for iconv conversion to utf-7 that produces strings that are not null terminated. * don't produce empty attachment files in separate mode. LibPST 0.6.32 (2009-03-14) =============================== * fix ppc64 compile error. LibPST 0.6.31 (2009-03-14) =============================== - * bump version for fedora cvs tagging mistake. + * bump version for Fedora cvs tagging mistake. LibPST 0.6.30 (2009-03-14) =============================== * 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. * improve internal doxygen documentation. * avoid emitting bogus empty email messages into contacts and calendar files. 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 + * 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. + * 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 + * 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. + binary buffers. All pst file reads now go through 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 + * lspst - add usage message 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. + for uninitialized 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 + * 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. +Well, a lot 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 + * 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 +Cured a few problems with regard to emails with multiple embedded items. They are not fully re-created using Mime-types, but are -accessible with the -S switch (which saves everything as seperate +accessible with the -S switch (which saves everything as separate 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 +Another output method has been added which is called "Separate". 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, +All the emails are stored in separate 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 +When an email has an attachment, it is saved as a separate 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 +Anyway, this is what I would call a minor feature enhancement 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 +caesar 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 +encrypt the PST, it is merely stored there. This means that the readpst application is able to convert PST files without knowing the -password. Microsoft have some explaning to do! +password. Microsoft have some explaining 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/Doxyfile b/Doxyfile index 3e14516..42cf1f8 100644 --- a/Doxyfile +++ b/Doxyfile @@ -1,1519 +1,1519 @@ # Doxyfile 1.6.1 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project # # All text after a hash (#) is considered a comment and will be ignored # The format is: # TAG = value [value, ...] # For lists items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (" ") #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- # This tag specifies the encoding used for all characters in the config file # that follow. The default is UTF-8 which is also the encoding used for all # text before the first occurrence of this tag. Doxygen uses libiconv (or the # iconv built into libc) for the transcoding. See # http://www.gnu.org/software/libiconv for the list of possible encodings. DOXYFILE_ENCODING = UTF-8 # The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. PROJECT_NAME = 'LibPst' # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or # if some version control system is used. PROJECT_NUMBER = # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output # format and will distribute the generated files over these directories. # Enabling this option can be useful when feeding doxygen a huge amount of # source files, where putting all generated files in the same directory would # otherwise cause performance problems for the file system. CREATE_SUBDIRS = NO # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # The default language is English, other supported languages are: # Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, # Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, # Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English # messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, # Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, # Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. OUTPUT_LANGUAGE = English # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will # include brief member descriptions after the members that are listed in # the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend # the brief description of a member or function before the detailed description. # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES # This tag implements a quasi-intelligent brief description abbreviator # that is used to form the text in various listings. Each string # in this list, if found as the leading text of the brief description, will be # stripped from the text and the result after processing the whole list, is # used as the annotated text. Otherwise, the brief description is used as-is. # If left blank, the following values are used ("$name" is automatically # replaced with the name of the entity): "The $name class" "The $name widget" # "The $name file" "is" "provides" "specifies" "contains" # "represents" "a" "an" "the" ABBREVIATE_BRIEF = # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = NO # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all # inherited members of a class in the documentation of that class as if those # members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. INLINE_INHERITED_MEMB = NO # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full # path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = YES # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag # can be used to strip a user-defined part of the path. Stripping is # only done if one of the specified strings matches the left-hand part of # the path. The tag can be used to show relative paths in the file list. # If left blank the directory from which doxygen is run is used as the # path to strip. STRIP_FROM_PATH = # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of # the path mentioned in the documentation of a class, which tells # the reader which header file to include in order to use a class. # If left blank only the name of the header file containing the class # definition is used. Otherwise one should specify the include paths that # are normally passed to the compiler using the -I flag. STRIP_FROM_INC_PATH = . # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter # (but less readable) file names. This can be useful is your file systems # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen # will interpret the first line (until the first dot) of a JavaDoc-style # comment as the brief description. If set to NO, the JavaDoc # comments will behave just like regular Qt-style comments # (thus requiring an explicit @brief command for a brief description.) JAVADOC_AUTOBRIEF = YES # If the QT_AUTOBRIEF tag is set to YES then Doxygen will # interpret the first line (until the first dot) of a Qt-style # comment as the brief description. If set to NO, the comments # will behave just like regular Qt-style comments (thus requiring # an explicit \brief command for a brief description.) QT_AUTOBRIEF = NO # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen # treat a multi-line C++ special comment block (i.e. a block of //! or /// # comments) as a brief description. This used to be the default behaviour. # The new default is to treat a multi-line C++ comment block as a detailed # description. Set this tag to YES if you prefer the old behaviour instead. MULTILINE_CPP_IS_BRIEF = NO # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented # member inherits the documentation from any documented member that it # re-implements. INHERIT_DOCS = YES # If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce # a new page for each member. If set to NO, the documentation of a member will # be part of the file/class/namespace that contains it. SEPARATE_MEMBER_PAGES = NO # The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 4 # This tag can be used to specify a number of aliases that acts # as commands in the documentation. An alias has the form "name=value". # For example adding "sideeffect=\par Side Effects:\n" will allow you to # put the command \sideeffect (or @sideeffect) in the documentation, which # will result in a user-defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. ALIASES = # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C # sources only. Doxygen will then generate output that is more tailored for C. # For instance, some of the names that are used will be different. The list # of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = YES # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java # sources only. Doxygen will then generate output that is more tailored for # Java. For instance, namespaces will be presented as packages, qualified # scopes will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO # Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran # sources only. Doxygen will then generate output that is more tailored for # Fortran. OPTIMIZE_FOR_FORTRAN = NO # Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL # sources. Doxygen will then generate output that is tailored for # VHDL. OPTIMIZE_OUTPUT_VHDL = NO # Doxygen selects the parser to use depending on the extension of the files it parses. # With this tag you can assign which parser to use for a given extension. # Doxygen has a built-in mapping, but you can override or extend it using this tag. # The format is ext=language, where ext is a file extension, and language is one of # the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP, # Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat # .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran), # use: inc=Fortran f=C. Note that for custom extensions you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. EXTENSION_MAPPING = # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want # to include (a tag file for) the STL sources as input, then you should # set this tag to YES in order to let doxygen match functions declarations and # definitions whose arguments contain STL classes (e.g. func(std::string); v.s. # func(std::string) {}). This also make the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. BUILTIN_STL_SUPPORT = NO # If you use Microsoft's C++/CLI language, you should set this option to YES to # enable parsing support. CPP_CLI_SUPPORT = NO # Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. # Doxygen will parse them like normal C++ but will assume all classes use public # instead of private inheritance when no explicit protection keyword is present. SIP_SUPPORT = NO # For Microsoft's IDL there are propget and propput attributes to indicate getter # and setter methods for a property. Setting this option to YES (the default) # will make doxygen to replace the get and set methods by a property in the # documentation. This will only work if the methods are indeed getting or # setting a simple type. If this is not the case, or you want to show the # methods anyway, you should set this option to NO. IDL_PROPERTY_SUPPORT = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES, then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = NO # Set the SUBGROUPING tag to YES (the default) to allow class member groups of # the same type (for instance a group of public functions) to be put as a # subgroup of that type (e.g. under the Public Functions section). Set it to # NO to prevent subgrouping. Alternatively, this can be done per class using # the \nosubgrouping command. SUBGROUPING = YES # When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum # is documented as struct, union, or enum with the name of the typedef. So # typedef struct TypeS {} TypeT, will appear in the documentation as a struct # with name TypeT. When disabled the typedef will appear as a member of a file, # namespace, or class. And the struct will be named TypeS. This can typically # be useful for C code in case the coding convention dictates that all compound # types are typedef'ed and only the typedef is referenced, never the tag name. TYPEDEF_HIDES_STRUCT = NO # The SYMBOL_CACHE_SIZE determines the size of the internal cache use to # determine which symbols to keep in memory and which to flush to disk. # When the cache is full, less often used symbols will be written to disk. # For small to medium size projects (<1000 input files) the default value is # probably good enough. For larger projects a too small cache size can cause # doxygen to be busy swapping symbols to and from disk most of the time -# causing a significant performance penality. +# causing a significant performance penalty. # If the system has enough physical memory increasing the cache will improve the # performance by keeping more symbols in memory. Note that the value works on -# a logarithmic scale so increasing the size by one will rougly double the +# a logarithmic scale so increasing the size by one will roughly double the # memory usage. The cache size is given by this formula: # 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, # corresponding to a cache size of 2^16 = 65536 symbols SYMBOL_CACHE_SIZE = 0 #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in # documentation are documented, even if no documentation was available. # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES EXTRACT_ALL = YES # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = YES # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = YES # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) # defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = YES # This flag is only useful for Objective-C code. When set to YES local # methods, which are defined in the implementation section but not in # the interface are included in the documentation. # If set to NO (the default) only methods in the interface are included. EXTRACT_LOCAL_METHODS = NO # If this flag is set to YES, the members of anonymous namespaces will be # extracted and appear in the documentation as a namespace called # 'anonymous_namespace{file}', where file will be replaced with the base # name of the file that contains the anonymous namespace. By default # anonymous namespace are hidden. EXTRACT_ANON_NSPACES = NO # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all # undocumented members of documented classes, files or namespaces. # If set to NO (the default) these members will be included in the # various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. # If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all # friend (class|struct|union) declarations. # If set to NO (the default) these declarations will be included in the # documentation. HIDE_FRIEND_COMPOUNDS = NO # If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any # documentation blocks found inside the body of a function. # If set to NO (the default) these blocks will be appended to the # function's detailed documentation block. HIDE_IN_BODY_DOCS = NO # The INTERNAL_DOCS tag determines if documentation # that is typed after a \internal command is included. If the tag is set # to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = YES # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate # file names in lower-case letters. If set to YES upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. CASE_SENSE_NAMES = YES # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen # will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = NO # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen # will put a list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = YES # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen # will sort the (detailed) documentation of file and class members # alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = YES # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the # brief documentation of file, namespace and class members alphabetically # by member name. If set to NO (the default) the members will appear in # declaration order. SORT_BRIEF_DOCS = NO # If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the (brief and detailed) documentation of class members so that constructors and destructors are listed first. If set to NO (the default) the constructors will appear in the respective orders defined by SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. SORT_MEMBERS_CTORS_1ST = NO # If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the # hierarchy of group names into alphabetical order. If set to NO (the default) # the group names will appear in their defined order. SORT_GROUP_NAMES = NO # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be # sorted by fully-qualified names, including namespaces. If set to # NO (the default), the class list will be sorted only by class name, # not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. # Note: This option applies only to the class list, not to the # alphabetical list. SORT_BY_SCOPE_NAME = NO # The GENERATE_TODOLIST tag can be used to enable (YES) or # disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = YES # The GENERATE_TESTLIST tag can be used to enable (YES) or # disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = YES # The GENERATE_BUGLIST tag can be used to enable (YES) or # disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = YES # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or # disable (NO) the deprecated list. This list is created by putting # \deprecated commands in the documentation. GENERATE_DEPRECATEDLIST= YES # The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if sectionname ... \endif. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines # the initial value of a variable or define consists of for it to appear in # the documentation. If the initializer consists of more lines than specified # here it will be hidden. Use a value of 0 to hide initializers completely. # The appearance of the initializer of individual variables and defines in the # documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated # at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES # If the sources in your project are distributed over multiple directories # then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy # in the documentation. The default is NO. SHOW_DIRECTORIES = YES # Set the SHOW_FILES tag to NO to disable the generation of the Files page. # This will remove the Files entry from the Quick Index and from the # Folder Tree View (if specified). The default is YES. SHOW_FILES = YES # Set the SHOW_NAMESPACES tag to NO to disable the generation of the # Namespaces page. # This will remove the Namespaces entry from the Quick Index # and from the Folder Tree View (if specified). The default is YES. SHOW_NAMESPACES = YES # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from # the version control system). Doxygen will invoke the program by executing (via # popen()) the command , where is the value of # the FILE_VERSION_FILTER tag, and is the name of an input file # provided by doxygen. Whatever the program writes to standard output # is used as the file version. See the manual for examples. FILE_VERSION_FILTER = # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by # doxygen. The layout file controls the global structure of the generated output files # in an output format independent way. The create the layout file that represents # doxygen's defaults, run doxygen with the -l option. You can optionally specify a # file name after the option, if omitted DoxygenLayout.xml will be used as the name # of the layout file. LAYOUT_FILE = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are # generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings # for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = YES # If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some # parameters in a documented function, or documenting parameters that # don't exist or using markup commands wrongly. WARN_IF_DOC_ERROR = YES # This WARN_NO_PARAMDOC option can be abled to get warnings for # functions that are documented, but have no documentation for their parameters # or return value. If set to NO (the default) doxygen will only warn about # wrong or incomplete parameter documentation, but not about the absence of # documentation. WARN_NO_PARAMDOC = NO # The WARN_FORMAT tag determines the format of the warning messages that # doxygen can produce. The string should contain the $file, $line, and $text # tags, which will be replaced by the file and line number from which the # warning originated and the warning text. Optionally the format may contain # $version, which will be replaced by the version of the file (if it could # be obtained via FILE_VERSION_FILTER) WARN_FORMAT = "$file:$line: $text" # The WARN_LOGFILE tag can be used to specify a file to which warning # and error messages should be written. If left blank the output is written # to stderr. WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag can be used to specify the files and/or directories that contain # documented source files. You may enter file names like "myfile.cpp" or # directories like "/usr/src/myproject". Separate the files or directories # with spaces. INPUT = config.h src # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is # also the default input encoding. Doxygen uses libiconv (or the iconv built # into libc) for the transcoding. See http://www.gnu.org/software/libiconv for # the list of possible encodings. INPUT_ENCODING = UTF-8 # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank the following patterns are tested: # *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx # *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 FILE_PATTERNS = # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = YES # The EXCLUDE tag can be used to specify files and/or directories that should # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. EXCLUDE = # The EXCLUDE_SYMLINKS tag can be used select whether or not files or # directories that are symbolic links (a Unix filesystem feature) are excluded # from the input. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. Note that the wildcards are matched # against the file with absolute path, so to exclude all test directories # for example use the pattern */test/* EXCLUDE_PATTERNS = # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the # output. The symbol name can be a fully qualified name, a word, or if the # wildcard * is used, a substring. Examples: ANamespace, AClass, # AClass::ANamespace, ANamespace::*Test EXCLUDE_SYMBOLS = # The EXAMPLE_PATH tag can be used to specify one or more files or # directories that contain example code fragments that are included (see # the \include command). EXAMPLE_PATH = # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. EXAMPLE_PATTERNS = # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude # commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = NO # The IMAGE_PATH tag can be used to specify one or more files or # directories that contain image that are included in the documentation (see # the \image command). IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command , where # is the value of the INPUT_FILTER tag, and is the name of an # input file. Doxygen will then use the output that the filter program writes # to standard output. # If FILTER_PATTERNS is specified, this tag will be # ignored. INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. # Doxygen will compare the file name with each pattern and apply the # filter if there is a match. # The filters are a list of the form: # pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further # info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER # is applied to all files. FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will be used to filter the input files when producing source # files to browse (i.e. when SOURCE_BROWSER is set to YES). FILTER_SOURCE_FILES = NO #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will # be generated. Documented entities will be cross-referenced with these sources. # Note: To get rid of all source code in the generated output, make sure also # VERBATIM_HEADERS is set to NO. SOURCE_BROWSER = YES # Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = NO # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct # doxygen to hide any special comment blocks from generated source code # fragments. Normal C and C++ comments will always remain visible. STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES # then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = YES # If the REFERENCES_RELATION tag is set to YES # then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = YES # If the REFERENCES_LINK_SOURCE tag is set to YES (the default) # and SOURCE_BROWSER tag is set to YES, then the hyperlinks from # functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will # link to the source code. # Otherwise they will link to the documentation. REFERENCES_LINK_SOURCE = YES # If the USE_HTAGS tag is set to YES then the references to source code # will point to the HTML generated by the htags(1) tool instead of doxygen # built-in source browser. The htags tool is part of GNU's global source # tagging system (see http://www.gnu.org/software/global/global.html). You # will need version 4.8.6 or higher. USE_HTAGS = NO # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen # will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = YES #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index # of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = YES # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 5 # In case all classes in a project start with a common prefix, all # classes will be put under the same header in the alphabetical index. # The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = html.internal # The HTML_FILE_EXTENSION tag can be used to specify the file extension for # each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. HTML_FILE_EXTENSION = .html # The HTML_HEADER tag can be used to specify a personal HTML header for # each generated HTML page. If it is left blank doxygen will generate a # standard header. HTML_HEADER = # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. HTML_FOOTER = # If the HTML_TIMESTAMP tag is set to YES then the generated HTML # documentation will contain the timesstamp. HTML_TIMESTAMP = NO # The HTML_STYLESHEET tag can be used to specify a user-defined cascading # style sheet that is used by each HTML page. It can be used to # fine-tune the look of the HTML output. If the tag is left blank doxygen # will generate a default style sheet. Note that doxygen will try to copy # the style sheet file to the HTML output directory, so don't put your own # stylesheet in the HTML output directory as well, or it will be erased! HTML_STYLESHEET = # If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, # files or namespaces will be aligned in HTML using tables. If set to # NO a bullet list will be used. HTML_ALIGN_MEMBERS = YES # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the # page has loaded. For this to work a browser that supports # JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox # Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). HTML_DYNAMIC_SECTIONS = NO # If the GENERATE_DOCSET tag is set to YES, additional index files # will be generated that can be used as input for Apple's Xcode 3 # integrated development environment, introduced with OSX 10.5 (Leopard). # To create a documentation set, doxygen will generate a Makefile in the # HTML output directory. Running make will produce the docset in that # directory and running "make install" will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find # it at startup. # See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information. GENERATE_DOCSET = NO # When GENERATE_DOCSET tag is set to YES, this tag determines the name of the # feed. A documentation feed provides an umbrella under which multiple # documentation sets from a single provider (such as a company or product suite) # can be grouped. DOCSET_FEEDNAME = "Doxygen generated docs" # When GENERATE_DOCSET tag is set to YES, this tag specifies a string that # should uniquely identify the documentation set bundle. This should be a # reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen # will append .docset to the name. DOCSET_BUNDLE_ID = org.doxygen.Project # If the GENERATE_HTMLHELP tag is set to YES, additional index files # will be generated that can be used as input for tools like the # Microsoft HTML help workshop to generate a compiled HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can # be used to specify the file name of the resulting .chm file. You # can add a path in front of the file if the result should not be # written to the html output directory. CHM_FILE = # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can # be used to specify the location (absolute path including file name) of # the HTML help compiler (hhc.exe). If non-empty doxygen will try to run # the HTML help compiler on the generated index.hhp. HHC_LOCATION = # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag # controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING # is used to encode HtmlHelp index (hhk), content (hhc) and project file # content. CHM_INDEX_ENCODING = # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag # controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the HTML help documentation and to the tree view. TOC_EXPAND = NO # If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER # are set, an additional index file will be generated that can be used as input for # Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated # HTML documentation. GENERATE_QHP = NO # If the QHG_LOCATION tag is specified, the QCH_FILE tag can # be used to specify the file name of the resulting .qch file. # The path specified is relative to the HTML output folder. QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating # Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#namespace QHP_NAMESPACE = # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating # Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#virtual-folders QHP_VIRTUAL_FOLDER = doc # If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add. # For more information please see # http://doc.trolltech.com/qthelpproject.html#custom-filters QHP_CUST_FILTER_NAME = # The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see # Qt Help Project / Custom Filters. QHP_CUST_FILTER_ATTRS = # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's # filter section matches. # Qt Help Project / Filter Attributes. QHP_SECT_FILTER_ATTRS = # If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can # be used to specify the location of Qt's qhelpgenerator. # If non-empty doxygen will try to run qhelpgenerator on the generated # .qhp file. QHG_LOCATION = # The DISABLE_INDEX tag can be used to turn on/off the condensed index at # top of each HTML page. The value NO (the default) enables the index and # the value YES disables it. DISABLE_INDEX = NO # This tag can be used to set the number of enum values (range [1..20]) # that doxygen will group on one line in the generated HTML documentation. ENUM_VALUES_PER_LINE = 4 # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index # structure should be generated to display hierarchical information. # If the tag value is set to YES, a side panel will be generated # containing a tree-like index structure (just like the one that # is generated for HTML Help). For this to work a browser that supports # JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). # Windows users are probably better off using the HTML help feature. GENERATE_TREEVIEW = YES # By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, # and Class Hierarchy pages using a tree view instead of an ordered list. USE_INLINE_TREES = NO # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 # Use this tag to change the font size of Latex formulas included # as images in the HTML documentation. The default is 10. Note that # when you change the font size after a successful doxygen run you need # to manually remove any form_*.png images from the HTML output directory # to force them to be regenerated. FORMULA_FONTSIZE = 10 # When the SEARCHENGINE tag is enable doxygen will generate a search box for the HTML output. The underlying search engine uses javascript # and DHTML and should work on any modern browser. Note that when using HTML help (GENERATE_HTMLHELP) or Qt help (GENERATE_QHP) # there is already a search function so this one should typically # be disabled. SEARCHENGINE = NO #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = NO # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = latex # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. If left blank `latex' will be used as the default command name. LATEX_CMD_NAME = latex # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to # generate index for LaTeX. If left blank `makeindex' will be used as the # default command name. MAKEINDEX_CMD_NAME = makeindex # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact # LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = NO # The PAPER_TYPE tag can be used to set the paper type that is used # by the printer. Possible values are: a4, a4wide, letter, legal and # executive. If left blank a4wide will be used. PAPER_TYPE = a4wide # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. EXTRA_PACKAGES = # The LATEX_HEADER tag can be used to specify a personal LaTeX header for # the generated latex document. The header should contain everything until # the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! LATEX_HEADER = # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated # is prepared for conversion to pdf (using ps2pdf). The pdf file will # contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. PDF_HYPERLINKS = NO # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of # plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. USE_PDFLATEX = NO # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. # command to the generated LaTeX files. This will instruct LaTeX to keep # running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = NO # If LATEX_HIDE_INDICES is set to YES then doxygen will not # include the index chapters (such as File Index, Compound Index, etc.) # in the output. LATEX_HIDE_INDICES = NO # If LATEX_SOURCE_CODE is set to YES then doxygen will include source code with syntax highlighting in the LaTeX output. Note that which sources are shown also depends on other settings such as SOURCE_BROWSER. LATEX_SOURCE_CODE = NO #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output # The RTF output is optimized for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = NO # The RTF_OUTPUT tag is used to specify where the RTF docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = rtf # If the COMPACT_RTF tag is set to YES Doxygen generates more compact # RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated # will contain hyperlink fields. The RTF file will # contain links (just like the HTML output) instead of page references. # This makes the output suitable for online browsing using WORD or other # programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = YES # Load stylesheet definitions from file. Syntax is similar to doxygen's # config file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- # If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = NO # The MAN_OUTPUT tag is used to specify where the man pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = man # The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = .3 # If the MAN_LINKS tag is set to YES and Doxygen generates man output, # then it will generate one additional man file for each entity # documented in the real man page(s). These additional files # only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- # If the GENERATE_XML tag is set to YES Doxygen will # generate an XML file that captures the structure of # the code including all documentation. GENERATE_XML = NO # The XML_OUTPUT tag is used to specify where the XML pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `xml' will be used as the default path. XML_OUTPUT = xml # The XML_SCHEMA tag can be used to specify an XML schema, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_SCHEMA = # The XML_DTD tag can be used to specify an XML DTD, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_DTD = # If the XML_PROGRAMLISTING tag is set to YES Doxygen will # dump the program listings (including syntax highlighting # and cross-referencing information) to the XML output. Note that # enabling this will significantly increase the size of the XML output. XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will # generate an AutoGen Definitions (see autogen.sf.net) file # that captures the structure of the code including all # documentation. Note that this feature is still experimental # and incomplete at the moment. GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- # If the GENERATE_PERLMOD tag is set to YES Doxygen will # generate a Perl module file that captures the structure of # the code including all documentation. Note that this # feature is still experimental and incomplete at the # moment. GENERATE_PERLMOD = NO # If the PERLMOD_LATEX tag is set to YES Doxygen will generate # the necessary Makefile rules, Perl scripts and LaTeX code to be able # to generate PDF and DVI output from the Perl module output. PERLMOD_LATEX = NO # If the PERLMOD_PRETTY tag is set to YES the Perl module output will be # nicely formatted so it can be parsed by a human reader. # This is useful # if you want to understand what is going on. # On the other hand, if this # tag is set to NO the size of the Perl module output will be much smaller # and Perl will parse it just the same. PERLMOD_PRETTY = YES # The names of the make variables in the generated doxyrules.make file # are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. # This is useful so different doxyrules.make files included by the same # Makefile don't overwrite each other's variables. PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will # evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro # names in the source code. If set to NO (the default) only conditional # compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = YES # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES # then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_DEFINED tags. EXPAND_ONLY_PREDEF = NO # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # in the INCLUDE_PATH (see below) will be search if a #include is found. SEARCH_INCLUDES = YES # The INCLUDE_PATH tag can be used to specify one or more directories that # contain include files that are not input files but should be processed by # the preprocessor. INCLUDE_PATH = # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the # directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. INCLUDE_FILE_PATTERNS = # The PREDEFINED tag can be used to specify one or more macro names that # are defined before the preprocessor is started (similar to the -D option of # gcc). The argument of the tag is a list of macros of the form: name # or name=definition (no spaces). If the definition and the = are # omitted =1 is assumed. To prevent a macro definition from being # undefined via #undef or recursively expanded use the := operator # instead of the = operator. PREDEFINED = HAVE_CONFIG_H # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. # The macro definition that is found in the sources will be used. # Use the PREDEFINED tag if you want to use a different macro definition. EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then # doxygen's preprocessor will remove all function-like macros that are alone # on a line, have an all uppercase name, and do not end with a semicolon. Such # function macros are typically used for boiler-plate code, and will confuse # the parser if not removed. SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::additions related to external references #--------------------------------------------------------------------------- # The TAGFILES option can be used to specify one or more tagfiles. # Optionally an initial location of the external documentation # can be added for each tagfile. The format of a tag file without # this location is as follows: # # TAGFILES = file1 file2 ... # Adding location for the tag files is done as follows: # # TAGFILES = file1=loc1 "file2 = loc2" ... # where "loc1" and "loc2" can be relative or absolute paths or # URLs. If a location is present for each tag, the installdox tool # does not have to be run to correct the links. # Note that each tag file must have a unique name # (where the name does NOT include the path) # If a tag file is not located in the directory in which doxygen # is run, you must also specify the path to the tagfile here. TAGFILES = # When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. GENERATE_TAGFILE = # If the ALLEXTERNALS tag is set to YES all external classes will be listed # in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO # If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed # in the modules index. If set to NO, only the current project's groups will # be listed. EXTERNAL_GROUPS = YES # The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will # generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base # or super classes. Setting the tag to NO turns the diagrams off. Note that # this option is superseded by the HAVE_DOT option below. This is only a # fallback. It is recommended to install and use dot, since it yields more # powerful graphs. CLASS_DIAGRAMS = YES # You can define message sequence charts within doxygen comments using the \msc # command. Doxygen will then run the mscgen tool (see # http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the # documentation. The MSCGEN_PATH tag allows you to specify the directory where # the mscgen tool resides. If left empty the tool is assumed to be found in the # default search path. MSCGEN_PATH = # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = YES # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is # available from the path. This tool is part of Graphviz, a graph visualization # toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) HAVE_DOT = YES # By default doxygen will write a font called FreeSans.ttf to the output # directory and reference it in all dot files that doxygen generates. This # font does not include all possible unicode characters however, so when you need # these (or just want a differently looking font) you can specify the font name # using DOT_FONTNAME. You need need to make sure dot is able to find the font, # which can be done by putting it in a standard location or by setting the # DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory # containing the font. DOT_FONTNAME = FreeSans # The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. # The default size is 10pt. DOT_FONTSIZE = 10 # By default doxygen will tell dot to use the output directory to look for the # FreeSans.ttf font (which doxygen will put there itself). If you specify a # different font using DOT_FONTNAME you can set the path where dot # can find it using this tag. DOT_FONTPATH = # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect inheritance relations. Setting this tag to YES will force the # the CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = YES # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = YES # If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen # will generate a graph for groups, showing the direct groups dependencies GROUP_GRAPHS = YES # If the UML_LOOK tag is set to YES doxygen will generate inheritance and # collaboration diagrams in a style similar to the OMG's Unified Modeling # Language. UML_LOOK = NO # If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = NO # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT # tags are set to YES then doxygen will generate a graph for each documented # file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and # HAVE_DOT tags are set to YES then doxygen will generate a graph for each # documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES # If the CALL_GRAPH and HAVE_DOT options are set to YES then # doxygen will generate a call dependency graph for every global function # or class method. Note that enabling this option will significantly increase # the time of a run. So in most cases it will be better to enable call graphs # for selected functions only using the \callgraph command. CALL_GRAPH = YES # If the CALLER_GRAPH and HAVE_DOT tags are set to YES then # doxygen will generate a caller dependency graph for every global function # or class method. Note that enabling this option will significantly increase # the time of a run. So in most cases it will be better to enable caller # graphs for selected functions only using the \callergraph command. CALLER_GRAPH = NO # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = YES # If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES # then doxygen will show the dependencies a directory has on other directories # in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. DIRECTORY_GRAPH = YES # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. Possible values are png, jpg, or gif # If left blank png will be used. DOT_IMAGE_FORMAT = png # The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found in the path. DOT_PATH = # The DOTFILE_DIRS tag can be used to specify one or more directories that # contain dot files that are included in the documentation (see the # \dotfile command). DOTFILE_DIRS = # The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of # nodes that will be shown in the graph. If the number of nodes in a graph # becomes larger than this value, doxygen will truncate the graph, which is # visualized by representing a node as a red box. Note that doxygen if the # number of direct children of the root node in a graph is already larger than # DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note # that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. DOT_GRAPH_MAX_NODES = 50 # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the # graphs generated by dot. A depth value of 3 means that only nodes reachable # from the root by following a path via at most 3 edges will be shown. Nodes # that lay further from the root node will be omitted. Note that setting this # option to 1 or 2 may greatly reduce the computation time needed for large # code bases. Also note that the size of a graph can be further restricted by # DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. MAX_DOT_GRAPH_DEPTH = 0 # Set the DOT_TRANSPARENT tag to YES to generate images with a transparent # background. This is disabled by default, because dot on Windows does not # seem to support this out of the box. Warning: Depending on the platform used, # enabling this option may lead to badly anti-aliased labels on the edges of # a graph (i.e. they become hard to read). DOT_TRANSPARENT = NO # Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output # files in one run (i.e. multiple -o and -T options on the command line). This # makes dot run faster, but since only newer versions of dot (>1.8.10) # support this, this feature is disabled by default. DOT_MULTI_TARGETS = NO # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will # generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = YES # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will # remove the intermediate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES diff --git a/NEWS b/NEWS index d9a5b89..d561f9e 100644 --- a/NEWS +++ b/NEWS @@ -1,85 +1,85 @@ 0.6.73 2019-07-25 Tim Dufrane - fix segfault in pst_close() 0.6.72 2018-08-01 Alfredo Esteban - add -l and -f options to lspst. 0.6.71 2017-07-21 Zachary Travis - Add support for the OST 2013 format, and Content-Disposition filename key fix for outlook compatibility 0.6.70 2017-02-08 Jeffrey Morlan - pst_getID2 must not recurse into children 0.6.69 2016-10-29 fix bugs in code allowing folders containing multiple item types 0.6.68 2016-08-29 allow folders containing multiple item types; better detection of valid internet headers 0.6.67 2016-07-06 Jeffrey Morlan - multiple bug fixes and an optimization 0.6.66 2015-12-21 Igor Stroh - Added Content-ID header support 0.6.65 2015-09-11 Jeffrey Morlan - fix multiple Content-Type headers; Hans Liss - debug level output 0.6.64 2015-03-09 AJ Shankar fixes for attachment processing and body encodings that contain embedded null chars 0.6.63 2013-12-27 Daniel Gryniewicz found buffer overrun in LIST_COPY_TIME 0.6.62 2013-09-22 983596 - Old dependency filter breaks file coloring 0.6.61 2013-08-06 move documentation to unversioned directory 0.6.60 2013-06-12 add AC_USE_SYSTEM_EXTENSIONS, add readpst -a option for attachment stripping 0.6.59 2013-05-17 add autoconf checking for libgsf 0.6.58 2012-12-28 fix From quoting on embedded rfc/822 messages 0.6.57 2012-12-27 remove useless dependencies 0.6.56 2012-12-24 merge -m .msg files code into main branch 0.6.55 2012-05-08 preserve bcc headers, space after colon is not required in header fields 0.6.54 2011-11-04 embedded rfc822 messages might contain rtf encoded bodies 0.6.53 2011-07-10 allow fork for parallel processing of individual email folders in separate mode 0.6.52 2011-05-22 fix dangling freed pointer; allow broken outlook internet header field 0.6.51 2011-04-17 fix for buffer overrun; attachment size fetched twice 0.6.50 2010-12-24 rfc2047 and rfc2231 encoding for non-ascii headers and attachment filenames 0.6.49 2010-09-13 fix to ignore embedded objects that are not email messages 0.6.48 2010-09-02 fix for broken internet headers from Outlook, change to mboxrd quoting 0.6.47 2010-05-07 patches from Kenneth Berland for solaris 0.6.46 2010-02-13 fixes for fedora 13 change in implicit dso linking semantics 0.6.45 2009-11-18 patch from Hugo DesRosiers to export categories and notes into vcards 0.6.44 2009-09-20 patch from Lee Ayres to add file name extensions in separate mode 0.6.43 2009-09-12 patches from Justin Greer, Chris White, Roberto Polli; better rfc822 embedded message decoding 0.6.42 2009-09-03 patch from Fridrich Strba to build with DJGPP DOS cross-compiler 0.6.41 2009-06-23 fix ax_python detection - should not use locate command 0.6.40 2009-06-23 fedora 11 has python2.6, remove pdf version of the man pages 0.6.39 2009-06-21 fedora > 10 moved to boost-python-devel 0.6.39 2009-06-21 fedora > 10 moved to boost-python-devel 0.6.38 2009-06-21 many changes including shared library soname 0.6.37 2009-04-17 add pst_attach_to_mem() back into the shared library interface 0.6.36 2009-04-14 build separate -doc and -devel-doc subpackages 0.6.35 2009-04-08 properly add trailing mime boundary in all modes, build separate rpms with libpst.so shared. 0.6.34 2009-03-19 avoid putting mixed item types into the same output folder 0.6.33 2009-03-17 fix utf-7 conversions, don't produce empty attachment files in separate mode 0.6.32 2009-03-14 fix ppc64 compile error 0.6.31 2009-03-14 bump version for fedora cvs tagging mistake 0.6.30 2009-03-14 track character set individually for each mapi element, avoid emitting bogus empty email messages into contacts and calendar files. 0.6.29 2009-02-24 fix for 64bit on Fedora 11 0.6.28 2009-02-24 improve decoding of multipart/report and message/rfc822 mime types 0.6.27 2009-02-07 fix for const correctness on Fedora 11 0.6.26 2009-02-07 patch from Fridrich Strba for building on mingw, and autoconf cleanup, better mime headers 0.6.25 2009-01-16 improve handling of content-type charset values in mime parts 0.6.24 2008-12-11 patch from Chris Eagle to build on cygwin 0.6.23 2008-12-04 bump version to avoid cvs tagging mistake in fedora 0.6.22 2008-11-28 process emails with type PST_TYPE_OTHER, fix malloc error and possible segfault 0.6.21 2008-10-21 fix title bug with old schema in pst2ldif, also escape commas in distinguished names per rfc4514. 0.6.20 2008-10-09 add configure option --enable-dii=no, fixes from Robert Harris for pst2ldif. 0.6.19 2008-09-14 Initial work on a .so shared library from Bharath Acharya. 0.6.18 2008-08-28 Fixes for iconv on Mac from Justin Greer. 0.6.17 2008-08-05 More fixes for 32/64 bit portability on big endian ppc 0.6.16 2008-08-05 Use inttypes.h for portable printing of 64 bit items 0.6.15 2008-07-30 Fix file handle leak in error case, missing length on lz decompression 0.6.14 2008-06-15 Fix my mistake in debian packaging 0.6.13 2008-06-13 Patch from Robert Simpson for encryption type 2. 0.6.12 2008-06-10 Patch from Joachim Metz for debian packaging, and fix for incorrect length on lz decompression. 0.6.11 2008-06-03 Use ftello/fseeko to properly handle large files. 0.6.10 2008-05-29 Patch from Robert Simpson for doubly-linked list and arrays of unicode strings. 0.6.9 2008-05-16 Patch from Joachim Metz for 64 bit compile. 0.6.8 2008-03-05 Initial version of pst2dii to convert to Summation dii load file format. 0.6.7 2008-02-16 Ignore unknown attachments on some read messages; autoconf cleanup. 0.6.6 2008-01-31 Code cleanup, switch from cvs to mercurial source control. 0.6.5 2008-01-22 Code cleanup, rpm group Applications/Productivity. 0.6.4 2008-01-19 More fixes for 64 bit format, merge changes from svn Alioth. 0.6.3 2008-01-13 More type consistency issues found by splint. 0.6.2 2008-01-12 More fixes for 64 bit format, consistent types size_t, off_t, etc. 0.6.1 2008-01-06 Outlook 2003 64 bit format and fix for bogus contacts. 0.5.12 2007-10-02 security fix for possible buffer overruns in liv-zemple decoding -0.5.11 2007-08-24 fix for unitialized variable +0.5.11 2007-08-24 fix for uninitialized variable 0.5.10 2007-08-20 fix yet more valgrind errors, restructure readpst recursive walk, backwards overrun test 0.5.9 2007-08-12 fix more valgrind errors, pst2ldif wrote undefined data 0.5.8 2007-08-10 lzfu_decompress/base64_encode encoded random data into attachment 0.5.7 2007-08-09 fix valgrind errors, using uninitialized data 0.5.6 2007-07-15 handle small pst files, better decoding of 7c blocks 0.5.5 2007-07-10 merge changes from Joe Nahmias version 0.5.4 2006-02-25 add MH mode, generated filenames with no leading zeros 0.5.3 2006-02-20 switch to gnu autoconf/automake 0.5.2 2006-02-18 add pst2ldif, fix btree processing in libpst.c diff --git a/configure.ac b/configure.ac index f087039..04ffecf 100644 --- a/configure.ac +++ b/configure.ac @@ -1,396 +1,396 @@ AC_PREREQ(2.60) AC_INIT(libpst,0.6.73,carl@five-ten-sg.com) AC_CONFIG_SRCDIR([src/libpst.c]) AC_CONFIG_HEADER([config.h]) AC_CONFIG_MACRO_DIR([m4]) AM_INIT_AUTOMAKE AC_CANONICAL_HOST AC_USE_SYSTEM_EXTENSIONS # # 1. Remember that version-info is current:revision:age, and age <= current. # 2. If the source code has changed at all since the last public release, # then increment revision (`c:r:a' becomes `c:r+1:a'). # 3. If any interfaces have been added, removed, or changed since the last # update, increment current, and set revision to 0. # 4. If any interfaces have been added since the last public release, then # increment age, since we should be backward compatible with the previous # version. # 5. If any interfaces have been removed or changed since the last public # release, then set age to 0, since we are not backward compatible. # 6. libtool will build libpst.so.x.y.z where the SONAME is libpst.so.x # and x=current-age, y=age, z=revision libpst_version_info='5:15:1' AC_SUBST(LIBPST_VERSION_INFO, [$libpst_version_info]) libpst_so_major='4' AC_SUBST(LIBPST_SO_MAJOR, [$libpst_so_major]) # libpst # version soname so library name # 0.6.35 libpst.so.2 libpst.so.2.0.0 # 0.6.37 libpst.so.2 libpst.so.2.1.0 # 0.6.38 libpst.so.2 libpst.so.2.1.0 # 0.6.40 libpst.so.4 libpst.so.4.0.0 # 0.6.43 libpst.so.4 libpst.so.4.0.1 # 0.6.47 libpst.so.4 libpst.so.4.0.2 # 0.6.48 libpst.so.4 libpst.so.4.0.3 # 0.6.49 libpst.so.4 libpst.so.4.0.4 # 0.6.50 libpst.so.4 libpst.so.4.1.0 # 0.6.51 libpst.so.4 libpst.so.4.1.1 # 0.6.52 libpst.so.4 libpst.so.4.1.2 # 0.6.53 libpst.so.4 libpst.so.4.1.3 # 0.6.54 libpst.so.4 libpst.so.4.1.4 # 0.6.55 libpst.so.4 libpst.so.4.1.5 # 0.6.56 libpst.so.4 libpst.so.4.1.6 # 0.6.57 libpst.so.4 libpst.so.4.1.6 # 0.6.58 libpst.so.4 libpst.so.4.1.7 # 0.6.59 libpst.so.4 libpst.so.4.1.8 # 0.6.60 libpst.so.4 libpst.so.4.1.9 # 0.6.61 libpst.so.4 libpst.so.4.1.9 # 0.6.62 libpst.so.4 libpst.so.4.1.9 # 0.6.63 libpst.so.4 libpst.so.4.1.10 # 0.6.66 libpst.so.4 libpst.so.4.1.11 # 0.6.67 libpst.so.4 libpst.so.4.1.12 # 0.6.68 libpst.so.4 libpst.so.4.1.13 # 0.6.69 libpst.so.4 libpst.so.4.1.14 # 0.6.73 libpst.so.4 libpst.so.4.1.15 # Check for solaris AC_MSG_CHECKING([for Solaris]) case "$host" in *solaris*) os_solaris=yes ;; *) os_solaris=no ;; esac AC_MSG_RESULT($os_solaris) AM_CONDITIONAL(OS_SOLARIS, [test "$os_solaris" = "yes"]) # Check for win32 AC_MSG_CHECKING([for Win32]) case "$host" in *-mingw*) os_win32=yes ;; *) os_win32=no ;; esac AC_MSG_RESULT($os_win32) AM_CONDITIONAL(OS_WIN32, [test "$os_win32" = "yes"]) # Check for Win32 platform AC_MSG_CHECKING([for Win32 platform in general]) case "$host" in *-cygwin*) platform_win32=yes ;; *) platform_win32=$os_win32 ;; esac AC_MSG_RESULT($platform_win32) AM_CONDITIONAL(PLATFORM_WIN32, [test "$platform_win32" = "yes"]) # Checks for programs. # The following lines adds the --enable-dii option to configure: # # Give the user the choice to enter one of these: # --enable-dii # --enable-dii=yes # --enable-dii=no # AC_MSG_CHECKING([whether we are enabling dii utility]) AC_ARG_ENABLE(dii, AC_HELP_STRING([--enable-dii], [enable dii utility]), [ case "${enableval}" in yes) ;; no) ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-dii) ;; esac ], # default if not specified enable_dii=yes ) AC_MSG_RESULT([$enable_dii]) AC_PATH_PROG(CONVERT, convert) if test "x$CONVERT" = "x" ; then if test "$enable_dii" = "yes"; then enable_dii=no AC_MSG_WARN([convert program not found. pst2dii disabled]) fi else if test "x`$CONVERT --version 2>&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 # 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 inttypes.h limits.h regex.h semaphore.h signal.h stdarg.h stdint.h stdio.h stdlib.h string.h sys/param.h sys/shm.h sys/stat.h sys/types.h time.h unistd.h wchar.h]) AC_SEARCH_LIBS([sem_init],[pthread rt]) # Checks for typedefs, structures, and compiler characteristics. AC_HEADER_STDBOOL AC_HEADER_SYS_WAIT AC_C_CONST AC_C_INLINE AC_TYPE_OFF_T AC_TYPE_SIZE_T AC_TYPE_PID_T AC_STRUCT_TM # Checks for library functions. AC_FUNC_FORK AC_FUNC_FSEEKO AC_FUNC_STAT 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([chdir getcwd memchr memmove memset regcomp strcasecmp strncasecmp strchr strdup strerror strpbrk strrchr strstr strtol get_current_dir_name]) AM_GNU_GETTEXT AM_GNU_GETTEXT_VERSION([0.19.1]) AM_ICONV if test "$am_cv_func_iconv" != "yes"; then AC_MSG_ERROR([libpst requires iconv which is missing]) fi 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 --enable-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 # The following lines adds the --enable-python option to configure: # # Give the user the choice to enter one of these: # --enable-python # --enable-python=yes # --enable-python=no # AC_MSG_CHECKING([whether to build the libpst python interface]) AC_ARG_ENABLE([python], AC_HELP_STRING([--enable-python], [build libpst python interface]), [ case "${enableval}" in yes) ;; no) ;; *) AC_MSG_ERROR(bad value ${enableval} for --python) ;; esac ], [ enable_python=yes ]) AC_MSG_RESULT([$enable_python]) AM_CONDITIONAL(PYTHON_INTERFACE, [test "$enable_python" = "yes"]) if test "$enable_python" = "yes"; then enable_shared="yes" # get the version of installed python AX_PYTHON if test "$ax_python_bin" = "no"; then AC_MSG_ERROR(python binary not found) fi PYTHON_VERSION=`echo $ax_python_bin | cut -c7-` # find the flags for that version AX_PYTHON_DEVEL([>= '$PYTHON_VERSION']) - # do we have boost python? + # do we have Boost Python? AX_BOOST_PYTHON if test "$ac_cv_boost_python" = "no"; then - AC_MSG_ERROR(boost python not found) + AC_MSG_ERROR(Boost Python not found) fi AC_SUBST(PYTHON_VERSION, [$ax_python_bin]) fi # The following lines adds the --enable-profiling option to configure: # # Give the user the choice to enter one of these: # --enable-profiling # --enable-profiling=yes # --enable-profiling=no # AC_MSG_CHECKING([whether to link with gprof profiling]) AC_ARG_ENABLE([profiling], AC_HELP_STRING([--enable-profiling], [link with gprof profiling]), [ case "${enableval}" in yes) CFLAGS="$CFLAGS -pg" CPPFLAGS="$CPPFLAGS -pg" CXXFLAGS="$CXXFLAGS -pg" ;; no) ;; *) AC_MSG_ERROR(bad value ${enableval} for --profiling) ;; esac ], [ enable_profiling=no ]) AC_MSG_RESULT([$enable_profiling]) AM_CONDITIONAL(GPROF_PROFILING, [test "$enable_profiling" = "yes"]) gsf_flags="`pkg-config libgsf-1 --cflags`" gsf_libs="`pkg-config libgsf-1 --libs`" if test "$gsf_flags" = ""; then AC_MSG_ERROR(libgsf not found) fi AC_SUBST(GSF_FLAGS, [$gsf_flags]) AC_SUBST(GSF_LIBS, [$gsf_libs]) PKG_CHECK_MODULES([ZLIB], [zlib]) AC_OUTPUT( \ Makefile \ html/Makefile \ libpst.pc \ libpst.spec \ man/Makefile \ src/Makefile \ src/pst2dii.cpp \ python/Makefile \ xml/Makefile \ xml/libpst \ ) diff --git a/contrib/FILE-FORMAT b/contrib/FILE-FORMAT index 10a94b8..aa9f01c 100644 --- a/contrib/FILE-FORMAT +++ b/contrib/FILE-FORMAT @@ -1,170 +1,170 @@ File format for Outlook pst files ================================= Basically, we work on two indexes. One index associates an ID with each item, and the second index associates a second ID with the original ID. I see no real purpose for this yet. 0x00 - Signature [4 bytes] (0x4E444221) 0xA8 - File Size [4 bytes] 0xC4 - Pointer to Index of all Items in File, associating the first ID [4 bytes] 0xBC - Pointer to Index of controlling Items in File [4 bytes] -First All Items Index: - constists of a table of offsets pointing to the table of items. +First All Items Index: - consists of a table of offsets pointing to the table of items. ====================== repeating: 0x0 - First id in this table [4 bytes] 0x04 - Unknown [4 bytes] 0x08 - Offset of table [4 bytes] until "First id in this table" is zero Table Of Items: - Pointed to by above records. =============== repeating: 0x0 - Id1 of this item [4 bytes] 0x04 - Offset of this item [4 bytes] 0x08 - Size of data stored there [2 bytes] 0x0A - Unknown [2 bytes] until "Id1 of this item" is zero. When this is reached, you return to the above table and read the next record Second All Items Index: - Contains the descriptors for emails, and other items ======================= repeating: 0x0 - First id2 of this table [4 bytes] 0x04 - Unknown [4 bytes] 0x08 - Offset of table [4 bytes] until "First id2 of this table" is zero Second Table of Items: - Pointed to by above records ====================== repeats 0x1F times 0x0 - Id2 of this item [4 bytes] 0x04 - Id1 of the descriptor item [4 bytes] 0x08 - Id1 of the associated list [4 bytes] (this contains a list of id1 and id2 that are to with this controlling item) 0x0C - Id2 of parent [4 bytes] Associated List: - pointed to by the above record. Contains associations between id1 and id2 for the items controlled by the record ================ 0x0 - Constant [2 bytes] (0x0002) 0x02 - Count [2 bytes] (the number of items that are about to follow) repeating 0x0 - Id2 of record [4 bytes] 0x04 - Id of record [4 bytes] - This is an association between the two 0x08 - Unknown [4 bytes] until you have reached the "Count" Descriptor Item: - Referenced from "Second Table of Items" - contains information about the item (email, contact...) ================ 0x0 - Block Offset to Block Index [2 bytes] 0x02 - Constant [2 bytes] (0xBCEC) 0x04 - Index Pos of Section1 [4 bytes] NOTE: An index pos can be shifted left 4 times [ i_pos << 4 ] to get an index offset (ie, an offset from the start of the block index) Block Index: - contains offsets to points in the current block ============ 0x0 - Count of offsets minus one. [2 bytes] (In effect, each offset must be taken with the following one so that the start and end of the referenced item can be established. Therefore there is one extra to show the end of the last item.) repeating 0x0 - Block Offset [2 bytes] until you have one extra than the "Count" Section1: - Referenced from "Descriptor Item" - contains not much ========= 0x0 - Constant? [4 bytes] (0x0602B5) 0x04 - Index Pos of Descriptor fields [4 bytes] Descriptor Fields: - Contain the information needed to access the details of the email ================== repeats 0x0 - Item type [2 bytes] (subject, from, to ...) 0x02 - Reference type [2 bytes] (how to interpret the value) 0x04 - Value [4 bytes] -until the alloted size of the record has been read. (The following Block Offset from the Index has been reached) +until the allotted size of the record has been read. (The following Block Offset from the Index has been reached) Reference Types: - I don't know if I have interpreted this field correctly. It might have a completely different purpose =============== 0x0002 - 0x0003 - Value following is a value in it's own right 0x000B - 0x001E - (STRING) Value following is a Index Position (must be shifted left 4 times) 0x0040 - (DATE) " " " " " 0x0048 - 0x0102 - (STRUCTURE) " " " " " 0x1003 - 0x101E - (ARRAY OF STRING) 0x1102 - Value: ====== When the value is of type Index Position, you can left shift the value 4 times to get an offset into the Block Index. Some descriptor types can have Id2 values. This is recognised by using a bitwise AND with the number. ie val & 0x0000000F. if the result is 0xF, it is likely to be a Id2 reference. Descriptor Types: - Types that are in "Descriptor Fields" ================= All Values are Hex Note: it appears that some types can have a IPOS value or a ID2 value depending on the size of the field in question. It is safer to check every field than for me to say what the "usually" contain. Absolute values though, are generally going to be constant. Type Ref Type Value Desc ---- -------- ----- ---- 001A [REF] IPM Context. What type of message is this 0037 001E [REF] Email Subject. The referenced item is of type "Subject Type" 0039 [REF] Date. This is likely to be the arrival date 003B [REF] Outlook Address of Sender 003F [REF] Outlook structure describing the recipient 0040 [REF] Name of the Outlook recipient structure 0041 [REF] Outlook structure describing the sender 0042 [REF] Name of the Outlook sender structure 0043 [REF] Another structure describing the recipient 0044 [REF] Name of the second recipient structure 004F [REF] Reply-To Outlook Structure 0050 [REF] Name of the Reply-To structure 0051 [REF] Outlook Name of recipient 0052 [REF] Second Outlook name of recipient 0064 [REF] Sender's Address access method (SMTP, EX) 0065 [REF] Sender's Address 0070 [REF] Processed Subject (with Fwd:, Re, ... removed) 0071 [REF] Date. Another date 0075 [REF] Recipient Address Access Method (SMTP, EX) 0076 [REF] Recipient's Address 0077 [REF] Second Recipient Access Method (SMTP, EX) 0078 [REF] Second Recipient Address 007D 001E [REF] Email Header. This is the header that was attached to the email 0C19 [REF] Second sender struct 0C1A [REF] Name of second sender struct 0C1D [REF] Second outlook name of sender 0C1E [REF] Second sender access method (SMTP, EX) 0C1F [REF] Second Sender Address 0E03 [REF] CC Address? 0E04 [REF] SentTo Address 0E06 [REF] Date. 0E07 [REF] Flag - contains IsSeen value 0FF9 [REF] binary record header 1000 001E [REF] Plain Text Email Body. Does not exist if the email doesn't have a plain text version 1013 001E [REF] HTML Email Body. Does not exist if the email doesn't have a HTML version 1035 [REF] Message ID 1042 [REF] In-Reply-To or Parent's Message ID 1046 [REF] Return Path -3001 [REF] Folder Name? I have seen this value used for the contacts record aswell +3001 [REF] Folder Name? I have seen this value used for the contacts record as well 3007 [REF] Date. 3008 [REF] Date. 300B [REF] binary record header 35E0 [REF] binary record found in first item. Contains the reference to "Top of Personal Folder" item 35E3 [REF] binary record with a reference to "Deleted Items" item -35E7 [REF] binary record with a refernece to "Search Root" item +35E7 [REF] binary record with a reference to "Search Root" item 3602 [REF] the number of emails stored in a folder 3603 [REF] the number of unread emails in a folder 3613 [REF] the folder content description 8000- Contain extra bits of information that have been taken from the email's header. I call them extra lines Key: [REF] = Can be either Index Position, or an Id2 Reference diff --git a/contrib/FILE-FORMAT.html b/contrib/FILE-FORMAT.html index 10422d4..edce8c6 100644 --- a/contrib/FILE-FORMAT.html +++ b/contrib/FILE-FORMAT.html @@ -1,69 +1,69 @@ File Format for Outlook PST files

Header

         00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
 0x00    xx xx xx xx 00 00 00 00 00 00 00 00 00 00 00 00
 ...
 0xA0    00 00 00 00 00 00 00 00 xx xx xx xx 00 00 00 00
 0xB0    00 00 00 00 00 00 00 00 00 00 00 00 xx xx xx xx
 0xC0    00 00 00 00 xx xx xx xx 00 00 00 00 00 00 00 00
 
 

Signature in Header

The first 4 bytes of the PST file should be 0x21 0x42 0x44 0x4E, or as an int 0x4E444221. This is the only signature I have come across and will probably work in nearly all situations.

Size of current PST file

This is the size of the file. If I understand correctly, then Outlook would appear to have a 2GB, or 4GB file limit. Actually, I am not sure that the whole file format could take more than 1GB.

Pointer to Index of Controlling Items

-

This is what is reffered to as the second index, or Descriptive index. These records contain pointers to the item description and a table of extra ids. These records also contain the id2# of its parent.

+

This is what is referred to as the second index, or Descriptive index. These records contain pointers to the item description and a table of extra ids. These records also contain the id2# of its parent.

Table pointing to further tables

     00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
     xx xx xx xx 00 00 00 00 xx xx xx xx
 

Leaf node table (Actual Records)

     00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
     xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx
 

Pointer to index of ID Offsets

-

This is what is reffered to as an ID. These just basically point to offsets in the file. The do not describe what they point to. Each ID2 record that needs data not stored in it, will have an ID value that is a pointer to some data.

+

This is what is referred to as an ID. These just basically point to offsets in the file. The do not describe what they point to. Each ID2 record that needs data not stored in it, will have an ID value that is a pointer to some data.

Table pointing to further tables

     00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
     xx xx xx xx 00 00 00 00 xx xx xx xx
 

Leaf node table (Actual Records)

     00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
     xx xx xx xx xx xx xx xx xx xx 00 00 
 

Association Table

This is a simple record associating the ID records with the ID2 records. It is nearly always the case that an item record will refer to an ID2 value. This list, which should be pre-read, will allow the ID2 values to point to file offsets. We must keep a full list of ID values in memory so that we can lookup the file offsets when required.

     00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
     02 00 xx xx[xx xx xx xx xx xx xx xx 00 00 00 00]...
 

Description Record

This is a record that lists attributes of an item together with the attribute's data. It is the main place where data is stored. All data in a PST file is stored as items - from emails, to contacts, to the layout of a folder.

Block Header

     00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
     xx xx EC BC xx xx xx xx
 
OR
     00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
     xx xx EC 7C xx xx xx xx
 
\ No newline at end of file diff --git a/libpst.spec.in b/libpst.spec.in index bbd110a..d31e492 100644 --- a/libpst.spec.in +++ b/libpst.spec.in @@ -1,606 +1,606 @@ Summary: Utilities to convert Outlook .pst files to other formats Name: @PACKAGE@ Version: @VERSION@ Release: 1%{?dist} License: GPLv2+ Source: http://www.five-ten-sg.com/%{name}/packages/%{name}-%{version}.tar.gz URL: http://www.five-ten-sg.com/%{name}/ Requires: ImageMagick libgsf Requires: %{name}-libs = %{version}-%{release} BuildRequires: libtool gcc-c++ BuildRequires: ImageMagick gd-devel zlib-devel boost-devel libgsf-devel %if 0%{?fedora} > 27 BuildRequires: python3 python3-devel boost-python3 boost-python3-devel Requires: boost-python3 %else BuildRequires: python-devel %endif %{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")} %{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")} %description The Libpst utilities include readpst which can convert email messages to both mbox and MH mailbox formats, pst2ldif which can convert the contacts to .ldif format for import into ldap databases, and pst2dii which can convert email messages to the DII load file format used by Summation. %package libs Summary: Shared library used by the pst utilities %description libs The libpst-libs package contains the shared library used by the pst utilities. %if 0%{?fedora} > 27 %package -n python3-%{name} Requires: python3 Provides: %{name}-python = %{version}-%{release} %else %package python Requires: python %endif Summary: Python bindings for libpst Requires: %{name}-libs = %{version}-%{release} %if 0%{?fedora} >= 20 %global __provides_exclude_from %{?__provides_exclude_from:%__provides_exclude_from|}^%{python_sitearch}/_.*\.so$ %else %{?filter_setup: %filter_provides_in %{python_sitearch}/_.*\.so$ %filter_setup } %endif %if 0%{?fedora} > 27 %description -n python3-%{name} %else %description python %endif The libpst-python package allows you to use the libpst shared object -from python code. +from Python code. %package devel Summary: Library links and header files for libpst application development Requires: pkgconfig Requires: %{name}-libs = %{version}-%{release} %description devel The libpst-devel package contains the library links and header files you'll need to develop applications using the libpst shared library. You do not need to install it if you just want to use the libpst utilities. %package devel-doc Summary: Documentation for libpst.so for libpst application development Requires: %{name}-doc = %{version}-%{release} %description devel-doc The libpst-devel-doc package contains the doxygen generated documentation for the libpst.so shared library. %package doc Summary: Documentation for the pst utilities in html format %description doc The libpst-doc package contains the html documentation for the pst utilities. You do not need to install it if you just want to use the libpst utilities. %prep %setup -q %build autoreconf -v -f -i %configure --enable-libpst-shared %if 0%{?fedora} > 27 %make_build %else make %{?_smp_mflags} %endif %install %if 0%{?fedora} > 27 %make_install %else rm -rf $RPM_BUILD_ROOT make DESTDIR=$RPM_BUILD_ROOT install %endif rm $RPM_BUILD_ROOT%{_libdir}/libpst.la rm $RPM_BUILD_ROOT%{_libdir}/libpst.a mv $RPM_BUILD_ROOT%{_datadir}/doc/%{name}-%{version} $RPM_BUILD_ROOT%{_datadir}/doc/%{name} %ldconfig_scriptlets libs %files %defattr(-,root,root,-) %{_bindir}/* %{_mandir}/man1/* %{_mandir}/man5/* %files libs %defattr(-,root,root,-) %{_libdir}/libpst.so.* %doc COPYING %if 0%{?fedora} > 27 %files -n python3-%{name} %defattr(-,root,root,-) %{python3_sitearch}/_*.so %exclude %{python3_sitearch}/*.a %exclude %{python3_sitearch}/*.la %else %files python %defattr(-,root,root,-) %{python_sitearch}/_*.so %exclude %{python_sitearch}/*.a %exclude %{python_sitearch}/*.la %endif %files devel %defattr(-,root,root,-) %{_libdir}/libpst.so %{_includedir}/%{name}-@LIBPST_SO_MAJOR@/ %{_libdir}/pkgconfig/libpst.pc %files devel-doc %defattr(-,root,root,-) %{_datadir}/doc/%{name}/devel/ %files doc %defattr(-,root,root,-) %dir %{_datadir}/doc/%{name}/ %{_datadir}/doc/%{name}/*.html %{_datadir}/doc/%{name}/AUTHORS %{_datadir}/doc/%{name}/COPYING %{_datadir}/doc/%{name}/ChangeLog %{_datadir}/doc/%{name}/NEWS %{_datadir}/doc/%{name}/README %changelog * Thu Jul 25 2019 Carl Byington 0.6.73-1 - Tim Dufrane - fix segfault in pst_close() * Fri Jun 07 2019 Carl Byington 0.6.72-4 -- fixes for python3 +- fixes for Python 3 * Fri Feb 01 2019 Fedora Release Engineering - 0.6.72-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild * Wed Jan 30 2019 Jonathan Wakely - 0.6.72-2 - Rebuilt for Boost 1.69 * Wed Aug 01 2018 Carl Byington 0.6.72-1 - allow all 7 days in bydays recurring appointment -- update for fedora python packaging +- update for Fedora Python packaging - Alfredo Esteban - add -l and -f options to lspst * Fri Jul 13 2018 Fedora Release Engineering - 0.6.71-8 - Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild * Wed Feb 07 2018 Fedora Release Engineering - 0.6.71-7 - Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild * Sun Aug 20 2017 Zbigniew Jędrzejewski-Szmek - 0.6.71-6 - Add Provides for the old name without %%_isa * Sat Aug 19 2017 Zbigniew Jędrzejewski-Szmek - 0.6.71-5 - Python 2 binary package renamed to python2-libpst See https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3 * Sat Aug 19 2017 Zbigniew Jędrzejewski-Szmek - 0.6.71-4 - Python 2 binary package renamed to python2-libpst See https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3 * Thu Aug 03 2017 Fedora Release Engineering - 0.6.71-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild * Wed Jul 26 2017 Fedora Release Engineering - 0.6.71-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild * Fri Jul 21 2017 Carl Byington 0.6.71-1 -- fedora python naming scheme changes +- Fedora Python naming scheme changes - Zachary Travis - Add support for the OST 2013 format, and Content-Disposition filename key fix for outlook compatibility * Thu Jul 20 2017 Kalev Lember - 0.6.70-3 - Rebuilt for Boost 1.64 * Fri Jul 07 2017 Igor Gnatenko - 0.6.70-2 - Rebuild due to bug in RPM (RHBZ #1468476) * Wed Feb 08 2017 Carl Byington 0.6.70-1 - Jeffrey Morlan - pst_getID2 must not recurse into children * Fri Jan 27 2017 Jonathan Wakely - 0.6.69-2 - Rebuilt for Boost 1.63 * Sat Oct 29 2016 Carl Byington 0.6.69-1 - fix bugs in code allowing folders containing multiple item types * Mon Aug 29 2016 Carl Byington 0.6.68-1 - allow folders containing multiple item types, e.g. email and calendar - better detection of valid internet headers * Tue Jul 19 2016 Fedora Release Engineering - 0.6.67-2 - https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages * Wed Jul 06 2016 Carl Byington 0.6.67-1 - Jeffrey Morlan - multiple bug fixes and an optimization * Thu Feb 04 2016 Fedora Release Engineering - 0.6.66-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild * Fri Jan 15 2016 Jonathan Wakely - 0.6.66-2 - Rebuilt for Boost 1.60 * Mon Dec 21 2015 Carl Byington 0.6.66-1 - Igor Stroh - Added Content-ID header support * Fri Sep 11 2015 Carl Byington 0.6.65-1 - Jeffrey Morlan - fix multiple Content-Type headers - Hans Liss - debug level output * Thu Aug 27 2015 Jonathan Wakely - 0.6.64-6 - Rebuilt for Boost 1.59 * Wed Jul 29 2015 Fedora Release Engineering - 0.6.64-5 - Rebuilt for https://fedoraproject.org/wiki/Changes/F23Boost159 * Wed Jul 22 2015 David Tardon - 0.6.64-4 - rebuild for Boost 1.58 * Wed Jun 17 2015 Fedora Release Engineering - 0.6.64-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild * Sat May 02 2015 Kalev Lember - 0.6.64-2 - Rebuilt for GCC 5 C++11 ABI change * Mon Mar 09 2015 Carl Byington 0.6.64-1 -- fix line wrap on python provides_exclude_from +- fix line wrap on Python provides_exclude_from - fix unchecked errors found by cppcheck - AJ Shankar fixes for attachment processing and body encodings that contain embedded null chars. * Mon Jan 26 2015 Petr Machata - 0.6.63-5 - Rebuild for boost 1.57.0 * Sun Aug 17 2014 Fedora Release Engineering - 0.6.63-4 - Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild * Sat Jun 07 2014 Fedora Release Engineering - 0.6.63-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild * Fri May 23 2014 David Tardon - 0.6.63-2 - rebuild for boost 1.55.0 * Fri Dec 27 2013 Carl Byington 0.6.63-1 - Daniel Gryniewicz found buffer overrun in LIST_COPY_TIME * Sun Sep 22 2013 Carl Byington 0.6.62-1 - 983596 - Old dependency filter breaks file coloring * Tue Aug 06 2013 Carl Byington 0.6.61-1 - move documentation to unversioned directory * Sat Aug 03 2013 Fedora Release Engineering - 0.6.59-4 - Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild * Sat Jul 27 2013 pmachata@redhat.com - 0.6.59-3 - Rebuild for boost 1.54.0 * Wed Jun 12 2013 Carl Byington 0.6.60-1 - patch from Dominique Leuenberger to add AC_USE_SYSTEM_EXTENSIONS - add readpst -a option for attachment stripping * Tue Jun 11 2013 Remi Collet - 0.6.59-2 - rebuild for new GD 2.1.0 * Fri May 17 2013 Carl Byington 0.6.59-1 - add autoconf checking for libgsf * Fri Mar 29 2013 Carl Byington 0.6.58-4 - add autoreconf for aarch64 * Sun Feb 10 2013 Denis Arnaud - 0.6.58-3 - Rebuild for Boost-1.53.0 * Sat Feb 09 2013 Denis Arnaud - 0.6.58-2 - Rebuild for Boost-1.53.0 * Fri Dec 28 2012 Carl Byington - 0.6.58-1 - fix From quoting on embedded rfc/822 messages * Wed Dec 26 2012 Carl Byington - 0.6.57-1 - bugzilla 852414, remove unnecessary dependencies * Mon Dec 24 2012 Carl Byington - 0.6.56-1 - filter private provides from rpm - merge -m .msg files code into main branch * Thu Aug 09 2012 Carl Byington - 0.6.55-2 -- rebuild for python +- rebuild for Python * Thu Jul 19 2012 Fedora Release Engineering - 0.6.54-6 - Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild * Tue May 08 2012 Carl Byington - 0.6.55-1 - preserve bcc headers - document -C switch to set default character set - space after colon is not required in header fields * Tue Feb 28 2012 Fedora Release Engineering - 0.6.54-5 - Rebuilt for c++ ABI breakage * Fri Jan 13 2012 Fedora Release Engineering - 0.6.54-4 - Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild * Sat Dec 24 2011 Carl Byington - 0.6.54-3 -- bump versions and prep for fedora build +- bump versions and prep for Fedora build * Wed Nov 30 2011 Petr Pisar - 0.6.53-3 - Rebuild against boost-1.48 * Mon Nov 14 2011 Carl Byington - 0.6.54-2 - failed to bump version number * Fri Nov 04 2011 Carl Byington - 0.6.54-1 - embedded rfc822 messages might contain rtf encoded bodies * Fri Sep 02 2011 Petr Pisar - 0.6.53-2 - Rebuild against boost-1.47 * Sun Jul 10 2011 Carl Byington - 0.6.53-1 - add Status: header in output - allow fork for parallel processing of individual email folders in separate mode - proper handling of --with-boost-python option * Sun May 22 2011 Carl Byington - 0.6.52-1 - fix dangling freed pointer in embedded rfc822 message processing - allow broken outlook internet header field - it sometimes contains fragments of the message body rather than headers * Sun Apr 17 2011 Carl Byington - 0.6.51-1 - fix for buffer overrun; attachment size from the secondary list of mapi elements overwrote proper size from the primary list of mapi elements. - fedora bugzilla 696263 + Fedora bugzilla 696263 * Tue Feb 08 2011 Fedora Release Engineering - 0.6.49-4 - Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild * Mon Feb 07 2011 Thomas Spura - 0.6.49-3 - rebuild for new boost * Fri Dec 24 2010 Carl Byington - 0.6.50-1 - rfc2047 and rfc2231 encoding for non-ascii headers and attachment filenames. * Wed Sep 29 2010 jkeating - 0.6.49-2 - Rebuilt for gcc bug 634757 * Mon Sep 13 2010 Carl Byington - 0.6.49-1 - fix to ignore embedded objects that are not email messages - fedora bugzilla 633498 + Fedora bugzilla 633498 * Thu Sep 02 2010 Carl Byington - 0.6.48-1 - fix for broken internet headers from Outlook - fix ax_python.m4 to look for python2.7 - use mboxrd from quoting for output formats with multiple messages per file - use no from quoting for output formats with single message per file * Sat Jul 31 2010 Carl Byington - 0.6.47-6 -- rebuild for python dependencies +- rebuild for Python dependencies * Mon Jul 26 2010 David Malcolm - 0.6.47-4 -- hack up configure so that it looks for python 2.7 +- hack up configure so that it looks for Python 2.7 * Wed Jul 21 2010 David Malcolm - 0.6.47-3 - Rebuilt for https://fedoraproject.org/wiki/Features/Python_2.7/MassRebuild * Wed Jul 07 2010 Carl Byington - 0.6.47-2 - Subpackage Licensing, add COPYING to -libs. - patches from Kenneth Berland for solaris * Fri May 07 2010 Carl Byington - 0.6.47-1 - patches from Kenneth Berland for solaris * Thu Jan 21 2010 Carl Byington - 0.6.46-1 - prefer libpthread over librt for finding sem_init function. * Thu Jan 21 2010 Carl Byington - 0.6.45-2 - rebuild for new boost package * Wed Nov 18 2009 Carl Byington - 0.6.45-1 - patch from Hugo DesRosiers to export categories and notes into vcards. - extend that patch to export categories into vcalendar appointments also. * Sun Sep 20 2009 Carl Byington - 0.6.44-1 - patch from Lee Ayres to add file name extensions in separate mode. - allow mixed items types in a folder in separate mode. * Sat Sep 12 2009 Carl Byington - 0.6.43-1 - decode more of the pst format, some minor bug fixes - add support for code pages 1200 and 1201. - add readpst -t option to select output item types, which can now be used to process folders containing mixed item types. - fix segfault with embedded appointments - add readpst -u option for Thunderbird mode .size and .type files - better detection of embedded rfc822 message attachments * Thu Sep 03 2009 Carl Byington - 0.6.42-1 - patch from Fridrich Strba to build with DJGPP DOS cross-compiler. * Sat Jul 25 2009 Fedora Release Engineering - 0.6.41-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild * Tue Jun 23 2009 Carl Byington - 0.6.41-1 - fix ax_python detection - should not use locate command -- checking for fedora versions is not needed +- checking for Fedora versions is not needed * Tue Jun 23 2009 Carl Byington - 0.6.40-1 -- fedora 11 has python2.6 +- Fedora 11 has python2.6 - remove pdf version of the man pages * Sun Jun 21 2009 Carl Byington - 0.6.39-1 -- fedora > 10 moved to boost-python-devel +- Fedora > 10 moved to boost-python-devel * Sun Jun 21 2009 Carl Byington - 0.6.38-1 -- add python interface to the shared library. +- add Python interface to the shared library. - bump soname to version 4 for many changes to the interface. - better decoding of recurrence data in appointments. - remove readpstlog since debug log files are now plain text. - add readpst -j option for parallel jobs for each folder. - make nested mime multipart/alternative to hold the text/html parts. * Fri Apr 17 2009 Carl Byington - 0.6.37-1 - add pst_attach_to_mem() back into the shared library interface. - fix memory leak caught by valgrind. * Tue Apr 14 2009 Carl Byington - 0.6.36-1 - build separate -doc and -devel-doc subpackages. - other spec file cleanup * Wed Apr 08 2009 Carl Byington - 0.6.35-1 - properly add trailing mime boundary in all modes. - build separate libpst, libpst-libs, libpst-devel rpms. * Thu Mar 19 2009 Carl Byington - 0.6.34-1 - avoid putting mixed item types into the same output folder. * Tue Mar 17 2009 Carl Byington - 0.6.33-1 - compensate for iconv conversion to utf-7 that produces strings that are not null terminated. - don't produce empty attachment files in separate mode. * Sat Mar 14 2009 Carl Byington - 0.6.32-1 - fix ppc64 compile error * Sat Mar 14 2009 Carl Byington - 0.6.31-1 -- bump version for fedora cvs tagging mistake +- bump version for Fedora cvs tagging mistake * Sat Mar 14 2009 Carl Byington - 0.6.30-1 - track character set individually for each mapi element. - remove charset option from pst2ldif since we get that from each object now. - avoid emitting bogus empty email messages into contacts and calendar files. * Tue Feb 24 2009 Carl Byington - 0.6.29-1 - fix for 64bit on Fedora 11 * Tue Feb 24 2009 Carl Byington - 0.6.28-1 - improve decoding of multipart/report and message/rfc822 mime types. - improve character set handling. - fix embedded rfc822 messages with attachments. * Sat Feb 07 2009 Carl Byington - 0.6.27-1 - fix for const correctness on Fedora 11 * Sat Feb 07 2009 Carl Byington - 0.6.26-1 - patch from Fridrich Strba for building on mingw and general - cleanup of autoconf files. - add processing for pst files of type 0x0f. - strip and regenerate all MIME headers to avoid duplicates. - do a better job of making unique MIME boundaries. - only use base64 coding when strictly necessary. * Fri Jan 16 2009 Carl Byington - 0.6.25-1 - improve handling of content-type charset values in mime parts * Thu Dec 11 2008 Carl Byington - 0.6.24-1 - patch from Chris Eagle to build on cygwin * Thu Dec 04 2008 Carl Byington - 0.6.23-1 - bump version to avoid cvs tagging mistake in fedora * Fri Nov 28 2008 Carl Byington - 0.6.22-1 - 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 * Tue Oct 21 2008 Carl Byington - 0.6.21-1 - fix title bug with old schema in pst2ldif. - also escape commas in distinguished names per rfc4514. * Thu Oct 09 2008 Carl Byington - 0.6.20-1 - 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 * Sun Sep 14 2008 Carl Byington - 0.6.19-1 - Fix base64 encoding that could create long lines. - Initial work on a .so shared library from Bharath Acharya. * Thu Aug 28 2008 Carl Byington - 0.6.18-1 - Fixes for iconv on Mac from Justin Greer. * Tue Aug 05 2008 Carl Byington - 0.6.17-1 - More fixes for 32/64 bit portability on big endian ppc. * Tue Aug 05 2008 Carl Byington - 0.6.16-1 - Use inttypes.h for portable printing of 64 bit items. * Wed Jul 30 2008 Carl Byington - 0.6.15-1 - Patch from Robert Simpson for file handle leak in error case. - Fix for missing length on lz decompression, bug found by Chris White. * Sun Jun 15 2008 Carl Byington - 0.6.14-1 -- Fix my mistake in debian packaging. +- Fix my mistake in Debian packaging. * Fri Jun 13 2008 Carl Byington - 0.6.13-1 - Patch from Robert Simpson for encryption type 2. * Tue Jun 10 2008 Carl Byington - 0.6.12-1 -- Patch from Joachim Metz for debian packaging and +- Patch from Joachim Metz for Debian packaging and - fix for incorrect length on lz decompression * Tue Jun 03 2008 Carl Byington - 0.6.11-1 - 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. * Thu May 29 2008 Carl Byington - 0.6.10-1 - Patch from Robert Simpson for doubly-linked list code and arrays of unicode strings. * Fri May 16 2008 Carl Byington - 0.6.9 - Patch from Joachim Metz for 64 bit compile. - Fix pst format documentation for 8 byte backpointers. * Wed Mar 05 2008 Carl Byington - 0.6.8 - Initial version of pst2dii to convert to Summation dii load file format - changes for Fedora packaging guidelines (#434727) * Tue Jul 10 2007 Carl Byington - 0.5.5 - merge changes from Joe Nahmias version * Sun Feb 19 2006 Carl Byington - 0.5.3 - initial spec file using autoconf and http://www.fedora.us/docs/rpm-packaging-guidelines.html diff --git a/python/python-libpst.cpp b/python/python-libpst.cpp index eb88281..1832aa4 100644 --- a/python/python-libpst.cpp +++ b/python/python-libpst.cpp @@ -1,622 +1,622 @@ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include // #include // #include extern "C" { #include "libpst.h" #include "timeconv.h" #include "libstrfunc.h" #include "vbuf.h" #include "lzfu.h" } using namespace std; using namespace boost::python; -/** python version of pst_binary, where python is +/** Python version of pst_binary, where Python is responsible for freeing the underlying buffer */ struct ppst_binary : public pst_binary { }; class pst { public: pst(const string filename, const string charset); virtual ~pst(); pst_desc_tree* pst_getTopOfFolders(); ppst_binary pst_attach_to_mem(pst_item_attach *attach); size_t pst_attach_to_file(pst_item_attach *attach, FILE* fp); size_t pst_attach_to_file_base64(pst_item_attach *attach, FILE* fp); pst_desc_tree* pst_getNextDptr(pst_desc_tree* d); pst_item* pst_parse_item(pst_desc_tree *d_ptr, pst_id2_tree *m_head); void pst_freeItem(pst_item *item); pst_index_ll* pst_getID(uint64_t i_id); size_t pst_ff_getIDblock_dec(uint64_t i_id, char **buf); string pst_rfc2426_escape(char *str); string pst_rfc2425_datetime_format(const FILETIME *ft); string pst_rfc2445_datetime_format(const FILETIME *ft); string 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); pst_recurrence* pst_convert_recurrence(pst_item_appointment *appt); void pst_free_recurrence(pst_recurrence* r); - /** helper for python access to fopen() */ + /** helper for Python access to fopen() */ FILE* ppst_open_file(string filename, string mode); - /** helper for python access to fclose() */ + /** helper for Python access to fclose() */ int ppst_close_file(FILE* fp); private: bool is_open; pst_file pf; pst_item* root; pst_desc_tree* topf; }; pst::pst(const string filename, const string charset) { is_open = (::pst_open(&pf, filename.c_str(), charset.c_str()) == 0); root = NULL; topf = NULL; if (is_open) { ::pst_load_index(&pf); ::pst_load_extended_attributes(&pf); if (pf.d_head) root = ::pst_parse_item(&pf, pf.d_head, NULL); if (root) topf = ::pst_getTopOfFolders(&pf, root)->child; } } pst::~pst() { if (root) pst_freeItem(root); if (is_open) ::pst_close(&pf); } pst_desc_tree* pst::pst_getTopOfFolders() { return topf; } ppst_binary pst::pst_attach_to_mem(pst_item_attach *attach) { pst_binary r = ::pst_attach_to_mem(&pf, attach); ppst_binary rc; rc.size = r.size; rc.data = r.data; return rc; } size_t pst::pst_attach_to_file(pst_item_attach *attach, FILE* fp) { return ::pst_attach_to_file(&pf, attach, fp); } size_t pst::pst_attach_to_file_base64(pst_item_attach *attach, FILE* fp) { return ::pst_attach_to_file_base64(&pf, attach, fp); } pst_desc_tree* pst::pst_getNextDptr(pst_desc_tree* d) { return ::pst_getNextDptr(d); } pst_item* pst::pst_parse_item (pst_desc_tree *d_ptr, pst_id2_tree *m_head) { return ::pst_parse_item(&pf, d_ptr, m_head); } void pst::pst_freeItem(pst_item *item) { return ::pst_freeItem(item); } pst_index_ll* pst::pst_getID(uint64_t i_id) { return ::pst_getID(&pf, i_id); } size_t pst::pst_ff_getIDblock_dec(uint64_t i_id, char **buf) { return ::pst_ff_getIDblock_dec(&pf, i_id, buf); } string pst::pst_rfc2426_escape(char *str) { char *result = NULL; size_t resultlen = 0; char *rc = ::pst_rfc2426_escape(str, &result, &resultlen); string rrc(rc); if (result) free(result); return rrc; } string pst::pst_rfc2425_datetime_format(const FILETIME *ft) { char buf[30]; ::pst_rfc2425_datetime_format(ft, sizeof(buf), buf); return string(buf); } string pst::pst_rfc2445_datetime_format(const FILETIME *ft) { char buf[30]; ::pst_rfc2445_datetime_format(ft, sizeof(buf), buf); return string(buf); } string pst::pst_default_charset(pst_item *item) { char buf[30]; return string(::pst_default_charset(item, sizeof(buf), buf)); } void pst::pst_convert_utf8_null(pst_item *item, pst_string *str) { ::pst_convert_utf8_null(item, str); } void pst::pst_convert_utf8(pst_item *item, pst_string *str) { ::pst_convert_utf8(item, str); } pst_recurrence* pst::pst_convert_recurrence(pst_item_appointment *appt) { return ::pst_convert_recurrence(appt); } void pst::pst_free_recurrence(pst_recurrence* r) { ::pst_free_recurrence(r); } FILE* pst::ppst_open_file(string filename, string mode) { return ::fopen(filename.c_str(), mode.c_str()); } int pst::ppst_close_file(FILE* fp) { return ::fclose(fp); } struct make_python_string { /* we make no distinction between empty and null strings */ static PyObject* convert(char* const &s) { string ss; if (s) ss = string(s); return boost::python::incref(boost::python::object(ss).ptr()); } }; struct make_python_pst_binary { static PyObject* convert(pst_binary const &s) { if (s.data) { string ss; ss = string(s.data, s.size); return boost::python::incref(boost::python::object(ss).ptr()); } return boost::python::incref(boost::python::object().ptr()); } }; struct make_python_ppst_binary { static PyObject* convert(ppst_binary const &s) { if (s.data) { string ss; ss = string(s.data, s.size); free(s.data); return boost::python::incref(boost::python::object(ss).ptr()); } return boost::python::incref(boost::python::object().ptr()); } }; struct make_python_pst_item_email { static PyObject* convert(pst_item_email* const &s) { if (s) return to_python_indirect()(s); return boost::python::incref(boost::python::object().ptr()); } }; struct make_python_pst_item_attach { static PyObject* convert(pst_item_attach* const &s) { if (s) return to_python_indirect()(s); return boost::python::incref(boost::python::object().ptr()); } }; struct make_python_pst_desc_tree { static PyObject* convert(pst_desc_tree* const &s) { if (s) return to_python_indirect()(s); return boost::python::incref(boost::python::object().ptr()); } }; struct make_python_pst_index_ll { static PyObject* convert(pst_index_ll* const &s) { if (s) return to_python_indirect()(s); return boost::python::incref(boost::python::object().ptr()); } }; struct make_python_FILE { static PyObject* convert(FILE* const &s) { if (s) return to_python_indirect()(s); return boost::python::incref(boost::python::object().ptr()); } }; BOOST_PYTHON_MODULE(_libpst) { //boost::python::docstring_options doc_options(); to_python_converter(); to_python_converter(); to_python_converter(); to_python_converter(); to_python_converter(); to_python_converter(); to_python_converter(); to_python_converter(); class_("FILE") ; class_("FILETIME") .def_readwrite("dwLowDateTime", &FILETIME::dwLowDateTime) .def_readwrite("dwHighDateTime", &FILETIME::dwHighDateTime) ; class_("pst_entryid") .def_readonly("u1", &pst_entryid::u1) .def_readonly("entryid", &pst_entryid::entryid) .def_readonly("id", &pst_entryid::id) ; class_("pst_index_ll") .def_readonly("i_id", &pst_index_ll::i_id) .def_readonly("offset", &pst_index_ll::offset) .def_readonly("size", &pst_index_ll::size) .def_readonly("u1", &pst_index_ll::u1) ; class_("pst_id2_tree") .def_readonly("id2", &pst_id2_tree::id2) .add_property("id", make_getter(&pst_id2_tree::id, return_value_policy())) .add_property("child", make_getter(&pst_id2_tree::child, return_value_policy())) .add_property("next", make_getter(&pst_id2_tree::next, return_value_policy())) ; class_("pst_desc_tree") .def_readonly("d_id", &pst_desc_tree::d_id) .def_readonly("parent_d_id", &pst_desc_tree::parent_d_id) .add_property("desc", make_getter(&pst_desc_tree::desc, return_value_policy())) .add_property("assoc_tree", make_getter(&pst_desc_tree::assoc_tree, return_value_policy())) .def_readonly("no_child", &pst_desc_tree::no_child) .add_property("prev", make_getter(&pst_desc_tree::prev, return_value_policy())) .add_property("next", make_getter(&pst_desc_tree::next, return_value_policy())) .add_property("parent", make_getter(&pst_desc_tree::parent, return_value_policy())) .add_property("child", make_getter(&pst_desc_tree::child, return_value_policy())) .add_property("child_tail", make_getter(&pst_desc_tree::child_tail, return_value_policy())) ; class_("pst_string") .def_readonly("is_utf8", &pst_string::is_utf8) .def_readonly("str", &pst_string::str) ; class_("pst_item_email") .add_property("arrival_date", make_getter(&pst_item_email::arrival_date, return_value_policy())) .def_readonly("autoforward", &pst_item_email::autoforward) .def_readonly("cc_address", &pst_item_email::cc_address) .def_readonly("bcc_address", &pst_item_email::bcc_address) .add_property("conversation_index", make_getter(&pst_item_email::conversation_index, return_value_policy())) .def_readonly("conversion_prohibited", &pst_item_email::conversion_prohibited) .def_readonly("delete_after_submit", &pst_item_email::delete_after_submit) .def_readonly("delivery_report", &pst_item_email::delivery_report) .add_property("encrypted_body", make_getter(&pst_item_email::encrypted_body, return_value_policy())) .add_property("encrypted_htmlbody", make_getter(&pst_item_email::encrypted_htmlbody, return_value_policy())) .def_readonly("header", &pst_item_email::header) .def_readonly("htmlbody", &pst_item_email::htmlbody) .def_readonly("importance", &pst_item_email::importance) .def_readonly("in_reply_to", &pst_item_email::in_reply_to) .def_readonly("message_cc_me", &pst_item_email::message_cc_me) .def_readonly("message_recip_me", &pst_item_email::message_recip_me) .def_readonly("message_to_me", &pst_item_email::message_to_me) .def_readonly("messageid", &pst_item_email::messageid) .def_readonly("original_sensitivity", &pst_item_email::original_sensitivity) .def_readonly("original_bcc", &pst_item_email::original_bcc) .def_readonly("original_cc", &pst_item_email::original_cc) .def_readonly("original_to", &pst_item_email::original_to) .def_readonly("outlook_recipient", &pst_item_email::outlook_recipient) .def_readonly("outlook_recipient_name", &pst_item_email::outlook_recipient_name) .def_readonly("outlook_recipient2", &pst_item_email::outlook_recipient2) .def_readonly("outlook_sender", &pst_item_email::outlook_sender) .def_readonly("outlook_sender_name", &pst_item_email::outlook_sender_name) .def_readonly("outlook_sender2", &pst_item_email::outlook_sender2) .def_readonly("priority", &pst_item_email::priority) .def_readonly("processed_subject", &pst_item_email::processed_subject) .def_readonly("read_receipt", &pst_item_email::read_receipt) .def_readonly("recip_access", &pst_item_email::recip_access) .def_readonly("recip_address", &pst_item_email::recip_address) .def_readonly("recip2_access", &pst_item_email::recip2_access) .def_readonly("recip2_address", &pst_item_email::recip2_address) .def_readonly("reply_requested", &pst_item_email::reply_requested) .def_readonly("reply_to", &pst_item_email::reply_to) .def_readonly("return_path_address", &pst_item_email::return_path_address) .def_readonly("rtf_body_char_count", &pst_item_email::rtf_body_char_count) .def_readonly("rtf_body_crc", &pst_item_email::rtf_body_crc) .def_readonly("rtf_body_tag", &pst_item_email::rtf_body_tag) .add_property("rtf_compressed", make_getter(&pst_item_email::rtf_compressed, return_value_policy())) .def_readonly("rtf_in_sync", &pst_item_email::rtf_in_sync) .def_readonly("rtf_ws_prefix_count", &pst_item_email::rtf_ws_prefix_count) .def_readonly("rtf_ws_trailing_count", &pst_item_email::rtf_ws_trailing_count) .def_readonly("sender_access", &pst_item_email::sender_access) .def_readonly("sender_address", &pst_item_email::sender_address) .def_readonly("sender2_access", &pst_item_email::sender2_access) .def_readonly("sender2_address", &pst_item_email::sender2_address) .def_readonly("sensitivity", &pst_item_email::sensitivity) .add_property("sent_date", make_getter(&pst_item_email::sent_date, return_value_policy())) .add_property("sentmail_folder", make_getter(&pst_item_email::sentmail_folder, return_value_policy())) .def_readonly("sentto_address", &pst_item_email::sentto_address) .def_readonly("report_text", &pst_item_email::report_text) .add_property("report_time", make_getter(&pst_item_email::report_time, return_value_policy())) .def_readonly("ndr_reason_code", &pst_item_email::ndr_reason_code) .def_readonly("ndr_diag_code", &pst_item_email::ndr_diag_code) .def_readonly("supplementary_info", &pst_item_email::supplementary_info) .def_readonly("ndr_status_code", &pst_item_email::ndr_status_code) ; class_("pst_item_folder") .def_readonly("item_count", &pst_item_folder::item_count) .def_readonly("unseen_item_count", &pst_item_folder::unseen_item_count) .def_readonly("assoc_count", &pst_item_folder::assoc_count) .def_readonly("subfolder", &pst_item_folder::subfolder) ; class_("pst_item_message_store") .add_property("top_of_personal_folder", make_getter(&pst_item_message_store::top_of_personal_folder, return_value_policy())) .add_property("default_outbox_folder", make_getter(&pst_item_message_store::default_outbox_folder, return_value_policy())) .add_property("deleted_items_folder", make_getter(&pst_item_message_store::deleted_items_folder, return_value_policy())) .add_property("sent_items_folder", make_getter(&pst_item_message_store::sent_items_folder, return_value_policy())) .add_property("user_views_folder", make_getter(&pst_item_message_store::user_views_folder, return_value_policy())) .add_property("common_view_folder", make_getter(&pst_item_message_store::common_view_folder, return_value_policy())) .add_property("search_root_folder", make_getter(&pst_item_message_store::search_root_folder, return_value_policy())) .add_property("top_of_folder", make_getter(&pst_item_message_store::top_of_folder, return_value_policy())) .def_readonly("valid_mask", &pst_item_message_store::valid_mask) .def_readonly("pwd_chksum", &pst_item_message_store::pwd_chksum) ; class_("pst_item_contact") .def_readonly("account_name", &pst_item_contact::account_name) .def_readonly("address1", &pst_item_contact::address1) .def_readonly("address1a", &pst_item_contact::address1a) .def_readonly("address1_desc", &pst_item_contact::address1_desc) .def_readonly("address1_transport", &pst_item_contact::address1_transport) .def_readonly("address2", &pst_item_contact::address2) .def_readonly("address2a", &pst_item_contact::address2a) .def_readonly("address2_desc", &pst_item_contact::address2_desc) .def_readonly("address2_transport", &pst_item_contact::address2_transport) .def_readonly("address3", &pst_item_contact::address3) .def_readonly("address3a", &pst_item_contact::address3a) .def_readonly("address3_desc", &pst_item_contact::address3_desc) .def_readonly("address3_transport", &pst_item_contact::address3_transport) .def_readonly("assistant_name", &pst_item_contact::assistant_name) .def_readonly("assistant_phone", &pst_item_contact::assistant_phone) .def_readonly("billing_information", &pst_item_contact::billing_information) .add_property("birthday", make_getter(&pst_item_contact::birthday, return_value_policy())) .def_readonly("business_address", &pst_item_contact::business_address) .def_readonly("business_city", &pst_item_contact::business_city) .def_readonly("business_country", &pst_item_contact::business_country) .def_readonly("business_fax", &pst_item_contact::business_fax) .def_readonly("business_homepage", &pst_item_contact::business_homepage) .def_readonly("business_phone", &pst_item_contact::business_phone) .def_readonly("business_phone2", &pst_item_contact::business_phone2) .def_readonly("business_po_box", &pst_item_contact::business_po_box) .def_readonly("business_postal_code", &pst_item_contact::business_postal_code) .def_readonly("business_state", &pst_item_contact::business_state) .def_readonly("business_street", &pst_item_contact::business_street) .def_readonly("callback_phone", &pst_item_contact::callback_phone) .def_readonly("car_phone", &pst_item_contact::car_phone) .def_readonly("company_main_phone", &pst_item_contact::company_main_phone) .def_readonly("company_name", &pst_item_contact::company_name) .def_readonly("computer_name", &pst_item_contact::computer_name) .def_readonly("customer_id", &pst_item_contact::customer_id) .def_readonly("def_postal_address", &pst_item_contact::def_postal_address) .def_readonly("department", &pst_item_contact::department) .def_readonly("display_name_prefix", &pst_item_contact::display_name_prefix) .def_readonly("first_name", &pst_item_contact::first_name) .def_readonly("followup", &pst_item_contact::followup) .def_readonly("free_busy_address", &pst_item_contact::free_busy_address) .def_readonly("ftp_site", &pst_item_contact::ftp_site) .def_readonly("fullname", &pst_item_contact::fullname) .def_readonly("gender", &pst_item_contact::gender) .def_readonly("gov_id", &pst_item_contact::gov_id) .def_readonly("hobbies", &pst_item_contact::hobbies) .def_readonly("home_address", &pst_item_contact::home_address) .def_readonly("home_city", &pst_item_contact::home_city) .def_readonly("home_country", &pst_item_contact::home_country) .def_readonly("home_fax", &pst_item_contact::home_fax) .def_readonly("home_phone", &pst_item_contact::home_phone) .def_readonly("home_phone2", &pst_item_contact::home_phone2) .def_readonly("home_po_box", &pst_item_contact::home_po_box) .def_readonly("home_postal_code", &pst_item_contact::home_postal_code) .def_readonly("home_state", &pst_item_contact::home_state) .def_readonly("home_street", &pst_item_contact::home_street) .def_readonly("initials", &pst_item_contact::initials) .def_readonly("isdn_phone", &pst_item_contact::isdn_phone) .def_readonly("job_title", &pst_item_contact::job_title) .def_readonly("keyword", &pst_item_contact::keyword) .def_readonly("language", &pst_item_contact::language) .def_readonly("location", &pst_item_contact::location) .def_readonly("mail_permission", &pst_item_contact::mail_permission) .def_readonly("manager_name", &pst_item_contact::manager_name) .def_readonly("middle_name", &pst_item_contact::middle_name) .def_readonly("mileage", &pst_item_contact::mileage) .def_readonly("mobile_phone", &pst_item_contact::mobile_phone) .def_readonly("nickname", &pst_item_contact::nickname) .def_readonly("office_loc", &pst_item_contact::office_loc) .def_readonly("common_name", &pst_item_contact::common_name) .def_readonly("org_id", &pst_item_contact::org_id) .def_readonly("other_address", &pst_item_contact::other_address) .def_readonly("other_city", &pst_item_contact::other_city) .def_readonly("other_country", &pst_item_contact::other_country) .def_readonly("other_phone", &pst_item_contact::other_phone) .def_readonly("other_po_box", &pst_item_contact::other_po_box) .def_readonly("other_postal_code", &pst_item_contact::other_postal_code) .def_readonly("other_state", &pst_item_contact::other_state) .def_readonly("other_street", &pst_item_contact::other_street) .def_readonly("pager_phone", &pst_item_contact::pager_phone) .def_readonly("personal_homepage", &pst_item_contact::personal_homepage) .def_readonly("pref_name", &pst_item_contact::pref_name) .def_readonly("primary_fax", &pst_item_contact::primary_fax) .def_readonly("primary_phone", &pst_item_contact::primary_phone) .def_readonly("profession", &pst_item_contact::profession) .def_readonly("radio_phone", &pst_item_contact::radio_phone) .def_readonly("rich_text", &pst_item_contact::rich_text) .def_readonly("spouse_name", &pst_item_contact::spouse_name) .def_readonly("suffix", &pst_item_contact::suffix) .def_readonly("surname", &pst_item_contact::surname) .def_readonly("telex", &pst_item_contact::telex) .def_readonly("transmittable_display_name", &pst_item_contact::transmittable_display_name) .def_readonly("ttytdd_phone", &pst_item_contact::ttytdd_phone) .add_property("wedding_anniversary", make_getter(&pst_item_contact::wedding_anniversary, return_value_policy())) .def_readonly("work_address_street", &pst_item_contact::work_address_street) .def_readonly("work_address_city", &pst_item_contact::work_address_city) .def_readonly("work_address_state", &pst_item_contact::work_address_state) .def_readonly("work_address_postalcode", &pst_item_contact::work_address_postalcode) .def_readonly("work_address_country", &pst_item_contact::work_address_country) .def_readonly("work_address_postofficebox", &pst_item_contact::work_address_postofficebox) ; class_("pst_item_attach") .def_readonly("filename1", &pst_item_attach::filename1) .def_readonly("filename2", &pst_item_attach::filename2) .def_readonly("mimetype", &pst_item_attach::mimetype) .add_property("data", make_getter(&pst_item_attach::data, return_value_policy())) .def_readonly("id2_val", &pst_item_attach::id2_val) .def_readonly("i_id", &pst_item_attach::i_id) .add_property("id2_head", make_getter(&pst_item_attach::id2_head, return_value_policy())) .def_readonly("method", &pst_item_attach::method) .def_readonly("position", &pst_item_attach::position) .def_readonly("sequence", &pst_item_attach::sequence) .add_property("next", make_getter(&pst_item_attach::next, return_value_policy())) ; class_("pst_item_extra_field") .def_readonly("field_name", &pst_item_extra_field::field_name) .def_readonly("value", &pst_item_extra_field::value) .add_property("next", make_getter(&pst_item_extra_field::next, return_value_policy())) ; class_("pst_item_journal") .add_property("start", make_getter(&pst_item_journal::start, return_value_policy())) .add_property("end", make_getter(&pst_item_journal::end, return_value_policy())) .def_readonly("type", &pst_item_journal::type) .def_readonly("description", &pst_item_journal::description) ; class_("pst_recurrence") .def_readonly("signature", &pst_recurrence::signature) .def_readonly("type", &pst_recurrence::type) .def_readonly("sub_type", &pst_recurrence::sub_type) .def_readonly("parm1", &pst_recurrence::parm1) .def_readonly("parm2", &pst_recurrence::parm2) .def_readonly("parm3", &pst_recurrence::parm3) .def_readonly("parm4", &pst_recurrence::parm4) .def_readonly("parm5", &pst_recurrence::parm5) .def_readonly("termination", &pst_recurrence::termination) .def_readonly("interval", &pst_recurrence::interval) .def_readonly("bydaymask", &pst_recurrence::bydaymask) .def_readonly("dayofmonth", &pst_recurrence::dayofmonth) .def_readonly("monthofyear", &pst_recurrence::monthofyear) .def_readonly("position", &pst_recurrence::position) .def_readonly("count", &pst_recurrence::count) ; class_("pst_item_appointment") .add_property("start", make_getter(&pst_item_appointment::start, return_value_policy())) .add_property("end", make_getter(&pst_item_appointment::end, return_value_policy())) .def_readonly("location", &pst_item_appointment::location) .def_readonly("alarm", &pst_item_appointment::alarm) .add_property("reminder", make_getter(&pst_item_appointment::reminder, return_value_policy())) .def_readonly("alarm_minutes", &pst_item_appointment::alarm_minutes) .def_readonly("alarm_filename", &pst_item_appointment::alarm_filename) .def_readonly("timezonestring", &pst_item_appointment::timezonestring) .def_readonly("showas", &pst_item_appointment::showas) .def_readonly("label", &pst_item_appointment::label) .def_readonly("all_day", &pst_item_appointment::all_day) .def_readonly("is_recurring", &pst_item_appointment::is_recurring) .def_readonly("recurrence_type", &pst_item_appointment::recurrence_type) .def_readonly("recurrence_description", &pst_item_appointment::recurrence_description) .add_property("recurrence_data", make_getter(&pst_item_appointment::recurrence_data, return_value_policy())) .add_property("recurrence_start", make_getter(&pst_item_appointment::recurrence_start, return_value_policy())) .add_property("recurrence_end", make_getter(&pst_item_appointment::recurrence_end, return_value_policy())) ; class_("pst_item") .add_property("email", make_getter(&pst_item::email, return_value_policy())) .add_property("folder", make_getter(&pst_item::folder, return_value_policy())) .add_property("contact", make_getter(&pst_item::contact, return_value_policy())) .add_property("attach", make_getter(&pst_item::attach, return_value_policy())) .add_property("message_store", make_getter(&pst_item::message_store, return_value_policy())) .add_property("extra_fields", make_getter(&pst_item::extra_fields, return_value_policy())) .add_property("journal", make_getter(&pst_item::journal, return_value_policy())) .add_property("appointment", make_getter(&pst_item::appointment, return_value_policy())) .def_readonly("block_id", &pst_item::block_id) .def_readonly("type", &pst_item::type) .def_readonly("ascii_type", &pst_item::ascii_type) .def_readonly("flags", &pst_item::flags) .def_readonly("file_as", &pst_item::file_as) .def_readonly("comment", &pst_item::comment) .def_readonly("body_charset", &pst_item::body_charset) .def_readonly("body", &pst_item::body) .def_readonly("subject", &pst_item::subject) .def_readonly("internet_cpid", &pst_item::internet_cpid) .def_readonly("message_codepage", &pst_item::message_codepage) .def_readonly("message_size", &pst_item::message_size) .def_readonly("outlook_version", &pst_item::outlook_version) .add_property("record_key", make_getter(&pst_item::record_key, return_value_policy())) .add_property("predecessor_change", make_getter(&pst_item::predecessor_change, return_value_policy())) .def_readonly("response_requested", &pst_item::response_requested) .add_property("create_date", make_getter(&pst_item::create_date, return_value_policy())) .add_property("modify_date", make_getter(&pst_item::modify_date, return_value_policy())) .def_readonly("private_member", &pst_item::private_member) ; class_("pst_x_attrib_ll") .def_readonly("mytype", &pst_x_attrib_ll::mytype) .def_readonly("map", &pst_x_attrib_ll::map) .def_readonly("data", &pst_x_attrib_ll::data) .add_property("next", make_getter(&pst_x_attrib_ll::next, return_value_policy())) ; class_("pst_file") .def_readonly("cwd", &pst_file::cwd) .def_readonly("fname", &pst_file::fname) .add_property("d_head", make_getter(&pst_file::d_head, return_value_policy())) .add_property("d_tail", make_getter(&pst_file::d_tail, return_value_policy())) .add_property("x_head", make_getter(&pst_file::x_head, return_value_policy())) .def_readonly("do_read64", &pst_file::do_read64) .def_readonly("index1", &pst_file::index1) .def_readonly("index1_back", &pst_file::index1_back) .def_readonly("index2", &pst_file::index2) .def_readonly("index2_back", &pst_file::index2_back) .def_readonly("size", &pst_file::size) .def_readonly("encryption", &pst_file::encryption) .def_readonly("ind_type", &pst_file::ind_type) ; class_("pst", init()) .def("pst_getTopOfFolders", &pst::pst_getTopOfFolders, return_value_policy()) .def("pst_attach_to_mem", &pst::pst_attach_to_mem) .def("pst_attach_to_file", &pst::pst_attach_to_file) .def("pst_attach_to_file_base64", &pst::pst_attach_to_file_base64) .def("pst_getNextDptr", &pst::pst_getNextDptr, return_value_policy()) .def("pst_parse_item", &pst::pst_parse_item, return_value_policy()) .def("pst_freeItem", &pst::pst_freeItem) .def("pst_getID", &pst::pst_getID, return_value_policy()) .def("pst_ff_getIDblock_dec", &pst::pst_ff_getIDblock_dec) .def("pst_rfc2426_escape", &pst::pst_rfc2426_escape) .def("pst_rfc2425_datetime_format", &pst::pst_rfc2425_datetime_format) .def("pst_rfc2445_datetime_format", &pst::pst_rfc2445_datetime_format) .def("pst_default_charset", &pst::pst_default_charset) .def("pst_convert_utf8_null", &pst::pst_convert_utf8_null) .def("pst_convert_utf8", &pst::pst_convert_utf8) .def("ppst_open_file", &pst::ppst_open_file, return_value_policy()) .def("ppst_close_file", &pst::ppst_close_file) ; } diff --git a/src/getidblock.c b/src/getidblock.c index 10c3542..feb4e51 100644 --- a/src/getidblock.c +++ b/src/getidblock.c @@ -1,147 +1,147 @@ #include "define.h" int process = 0, binary = 0; pst_file pstfile; void usage(); void usage() { printf("usage: getidblock [options] filename id\n"); printf("\tfilename - name of the file to access\n"); printf("\tid - ID of the block to fetch (0 to fetch all) - can begin with 0x for hex\n"); printf("\toptions\n"); printf("\t\t-p\tProcess the block before finishing.\n"); printf("\t\t-b\tDump the blocks in binary to stdout.\n"); printf("\t\t\tView the debug log for information\n"); } void dumper(uint64_t i_id); void dumper(uint64_t i_id) { char *buf = NULL; size_t readSize; pst_desc_tree *ptr; DEBUG_INFO(("\n\n\nLooking at block index1 id %#"PRIx64"\n", i_id)); if ((readSize = pst_ff_getIDblock_dec(&pstfile, i_id, &buf)) <= 0 || buf == 0) { DIE(("Error loading block\n")); } DEBUG_INFO(("Printing block i_id %#"PRIx64", size %#"PRIx64"\n", i_id, (uint64_t)readSize)); if (binary) { if (fwrite(buf, 1, readSize, stdout) != 0) { - DIE(("Error occured during writing of buf to stdout\n")); + DIE(("Error occurred during writing of buf to stdout\n")); } } else { printf("Block id %#"PRIx64", size %#"PRIx64"\n", i_id, (uint64_t)readSize); pst_debug_hexdumper(stdout, buf, readSize, 0x10, 0); } if (buf) free(buf); if (process) { DEBUG_INFO(("Parsing block id %#"PRIx64"\n", i_id)); ptr = pstfile.d_head; while (ptr) { if (ptr->assoc_tree && ptr->assoc_tree->i_id == i_id) break; if (ptr->desc && ptr->desc->i_id == i_id) break; ptr = pst_getNextDptr(ptr); } if (!ptr) { ptr = (pst_desc_tree *) pst_malloc(sizeof(pst_desc_tree)); memset(ptr, 0, sizeof(pst_desc_tree)); ptr->desc = pst_getID(&pstfile, i_id); } pst_item *item = pst_parse_item(&pstfile, ptr, NULL); if (item) pst_freeItem(item); } } void dump_desc(pst_desc_tree *ptr, pst_desc_tree *parent); void dump_desc(pst_desc_tree *ptr, pst_desc_tree *parent) { while (ptr) { uint64_t parent_d_id = (parent) ? parent->d_id : 0; printf("Descriptor block d_id %#"PRIx64" parent d_id %#"PRIx64" children %i desc.i_id=%#"PRIx64", assoc tree.i_id=%#"PRIx64"\n", ptr->d_id, parent_d_id, ptr->no_child, (ptr->desc ? ptr->desc->i_id : (uint64_t)0), (ptr->assoc_tree ? ptr->assoc_tree->i_id : (uint64_t)0)); if (ptr->desc && ptr->desc->i_id) dumper(ptr->desc->i_id); if (ptr->assoc_tree && ptr->assoc_tree->i_id) dumper(ptr->assoc_tree->i_id); if (ptr->child) dump_desc(ptr->child, ptr); ptr = ptr->next; } } int main(int argc, char* const* argv) { // pass the id number to display on the command line char *fname, *sid; uint64_t i_id; int c; DEBUG_INIT("getidblock.log", NULL); DEBUG_ENT("main"); while ((c = getopt(argc, argv, "bp")) != -1) { switch (c) { case 'b': // enable binary output binary = 1; break; case 'p': - // enable procesing of block + // enable processing of block process = 1; break; default: usage(); exit(EXIT_FAILURE); } } if (optind + 1 >= argc) { // no more items on the cmd usage(); exit(EXIT_FAILURE); } fname = argv[optind]; sid = argv[optind + 1]; i_id = (uint64_t)strtoll(sid, NULL, 0); DEBUG_INFO(("Opening file\n")); memset(&pstfile, 0, sizeof(pstfile)); if (pst_open(&pstfile, fname, NULL)) { DIE(("Error opening file\n")); } DEBUG_INFO(("Loading Index\n")); if (pst_load_index(&pstfile) != 0) { DIE(("Error loading file index\n")); } if (i_id) { dumper(i_id); } else { size_t i; for (i = 0; i < pstfile.i_count; i++) { dumper(pstfile.i_table[i].i_id); } dump_desc(pstfile.d_head, NULL); } if (pst_close(&pstfile) != 0) { DIE(("pst_close failed\n")); } DEBUG_RET(); return 0; } diff --git a/src/libpst.c b/src/libpst.c index 84b9ed0..a1e3890 100644 --- a/src/libpst.c +++ b/src/libpst.c @@ -1,4664 +1,4664 @@ /*** * libpst.c * Part of the LibPST project * Written by David Smith * dave.s@earthcorp.com */ #include "define.h" #include "zlib.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_TYPE4K 0x24 #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 typedef struct pst_block_offset { uint16_t from; uint16_t to; } pst_block_offset; typedef struct pst_block_offset_pointer { char *from; char *to; int needfree; } pst_block_offset_pointer; typedef struct pst_holder { char **buf; FILE *fp; int base64; // bool, are we encoding into base64 int base64_line_count; // base64 bytes emitted on the current line size_t base64_extra; // count of bytes held in base64_extra_chars char base64_extra_chars[2]; // up to two pending unencoded bytes } 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; typedef struct pst_mapi_element { uint32_t mapi_id; char *data; uint32_t type; size_t size; char *extra; } pst_mapi_element; 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_desc32 { uint32_t d_id; uint32_t desc_id; uint32_t tree_id; uint32_t parent_d_id; } pst_desc32; typedef struct pst_index32 { uint32_t id; uint32_t offset; uint16_t size; int16_t u1; } pst_index32; struct pst_table_ptr_struct32{ uint32_t start; uint32_t u1; uint32_t offset; }; typedef struct pst_desc { 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_desc; typedef struct pst_index64 { uint64_t id; uint64_t offset; uint16_t size; int16_t u0; int32_t u1; } pst_index64; typedef struct pst_index { uint64_t id; uint64_t offset; uint16_t size; uint16_t inflated_size; int16_t u0; int32_t u1; } pst_index; struct pst_table_ptr_struct{ 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 }; static size_t pst_append_holder(pst_holder *h, size_t size, char **buf, size_t z); static 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); static pst_id2_tree* pst_build_id2(pst_file *pf, pst_index_ll* list); static 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); static int pst_chr_count(char *str, char x); static size_t pst_ff_compile_ID(pst_file *pf, uint64_t i_id, pst_holder *h, size_t size); static size_t pst_ff_getIDblock(pst_file *pf, uint64_t i_id, char** buf); static size_t pst_ff_getID2block(pst_file *pf, uint64_t id2, pst_id2_tree *id2_head, char** buf); static size_t pst_ff_getID2data(pst_file *pf, pst_index_ll *ptr, pst_holder *h); static size_t pst_finish_cleanup_holder(pst_holder *h, size_t size); static void pst_free_attach(pst_item_attach *attach); static void pst_free_desc (pst_desc_tree *head); static void pst_free_id2(pst_id2_tree * head); static void pst_free_list(pst_mapi_object *list); static void pst_free_xattrib(pst_x_attrib_ll *x); static size_t pst_getAtPos(pst_file *pf, int64_t pos, void* buf, size_t size); static int pst_getBlockOffsetPointer(pst_file *pf, pst_id2_tree *i2_head, pst_subblocks *subblocks, uint32_t offset, pst_block_offset_pointer *p); static int pst_getBlockOffset(char *buf, size_t read_size, uint32_t i_offset, uint32_t offset, pst_block_offset *p); static pst_id2_tree* pst_getID2(pst_id2_tree * ptr, uint64_t id); static pst_desc_tree* pst_getDptr(pst_file *pf, uint64_t d_id); static uint64_t pst_getIntAt(pst_file *pf, char *buf); static uint64_t pst_getIntAtPos(pst_file *pf, int64_t pos); static pst_mapi_object* pst_parse_block(pst_file *pf, uint64_t block_id, pst_id2_tree *i2_head); static void pst_printDptr(pst_file *pf, pst_desc_tree *ptr); static void pst_printID2ptr(pst_id2_tree *ptr); static int pst_process(uint64_t block_id, pst_mapi_object *list, pst_item *item, pst_item_attach *attach); static size_t pst_read_block_size(pst_file *pf, int64_t offset, size_t size, size_t inflated_size, char **buf); static size_t pst_read_raw_block_size(pst_file *pf, int64_t offset, size_t size, char **buf); static int pst_decrypt(uint64_t i_id, char *buf, size_t size, unsigned char type); static int pst_strincmp(char *a, char *b, size_t x); static char* pst_wide_to_single(char *wt, size_t size); static char *pst_getcwd(void) { char *cwd; #ifdef HAVE_GET_CURRENT_DIR_NAME cwd = get_current_dir_name(); #else cwd = pst_malloc(PATH_MAX+1); getcwd(cwd, PATH_MAX+1); #endif return cwd; } int pst_open(pst_file *pf, const char *name, const char *charset) { int32_t sig; pst_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)); pf->charset = charset; if ((pf->fp = fopen(name, "rb")) == NULL) { 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); DEBUG_WARN(("cannot read signature from PST file. Closing with 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); DEBUG_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; case INDEX_TYPE4K : pf->do_read64 = 2; break; default: (void)fclose(pf->fp); DEBUG_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(); pf->cwd = pst_getcwd(); pf->fname = strdup(name); return 0; } int pst_reopen(pst_file *pf) { char *cwd; cwd = pst_getcwd(); if (cwd == NULL) return -1; if (chdir(pf->cwd)) goto err; if (!freopen(pf->fname, "rb", pf->fp)) goto err; if (chdir(cwd)) goto err; free(cwd); return 0; err: free(cwd); return -1; } int pst_close(pst_file *pf) { DEBUG_ENT("pst_close"); if (!pf) { DEBUG_RET(); return 0; } if (!pf->fp) { DEBUG_RET(); return 0; } if (fclose(pf->fp)) { DEBUG_WARN(("fclose returned non-zero value\n")); } // free the paths free(pf->cwd); free(pf->fname); // we must free the id array and the desc tree free(pf->i_table); 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_tree *node, pst_desc_tree **head, pst_desc_tree **tail); static void add_descriptor_to_list(pst_desc_tree *node, pst_desc_tree **head, pst_desc_tree **tail) { DEBUG_ENT("add_descriptor_to_list"); //DEBUG_INFO(("Added node %#"PRIx64" parent %#"PRIx64" real parent %#"PRIx64" prev %#"PRIx64" next %#"PRIx64"\n", // node->id, node->parent_d_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_tree *node); static void record_descriptor(pst_file *pf, pst_desc_tree *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_tree *n = pf->d_head; while (n) { if (n->parent_d_id == node->d_id) { // found a child of this node DEBUG_INFO(("Found orphan child %#"PRIx64" of parent %#"PRIx64"\n", n->d_id, node->d_id)); pst_desc_tree *nn = n->next; pst_desc_tree *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_INFO(("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_INFO(("%#"PRIx64" is its own parent. What is this world coming to?\n", node->d_id)); add_descriptor_to_list(node, &pf->d_head, &pf->d_tail); } else { //DEBUG_INFO(("Searching for parent %#"PRIx64" of %#"PRIx64"\n", node->parent_d_id, node->d_id)); pst_desc_tree *parent = pst_getDptr(pf, node->parent_d_id); if (parent) { //DEBUG_INFO(("Found parent %#"PRIx64"\n", node->parent_d_id)); parent->no_child++; node->parent = parent; add_descriptor_to_list(node, &parent->child, &parent->child_tail); } else { DEBUG_INFO(("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_tree* deep_copy(pst_id2_tree *head); static pst_id2_tree* deep_copy(pst_id2_tree *head) { if (!head) return NULL; pst_id2_tree* me = (pst_id2_tree*) pst_malloc(sizeof(pst_id2_tree)); me->id2 = head->id2; me->id = head->id; me->child = deep_copy(head->child); me->next = deep_copy(head->next); return me; } pst_desc_tree* pst_getTopOfFolders(pst_file *pf, const pst_item *root) { pst_desc_tree *topnode; uint32_t topid; DEBUG_ENT("pst_getTopOfFolders"); if (!root || !root->message_store) { DEBUG_INFO(("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_INFO(("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_tree*) pst_malloc(sizeof(pst_desc_tree)); 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; } pst_binary pst_attach_to_mem(pst_file *pf, pst_item_attach *attach) { pst_index_ll *ptr; pst_binary rc; pst_holder h = {&rc.data, NULL, 0, 0, 0}; rc.size = 0; rc.data = NULL; DEBUG_ENT("pst_attach_to_mem"); if ((!attach->data.data) && (attach->i_id != (uint64_t)-1)) { ptr = pst_getID(pf, attach->i_id); if (ptr) { rc.size = pst_ff_getID2data(pf, ptr, &h); } else { DEBUG_WARN(("Couldn't find ID pointer. Cannot handle attachment\n")); } } else { rc = attach->data; attach->data.data = NULL; // prevent pst_free_item() from trying to free this attach->data.size = 0; // since we have given that buffer to the caller } DEBUG_RET(); return rc; } 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, 0, 0}; size_t size = 0; DEBUG_ENT("pst_attach_to_file"); if ((!attach->data.data) && (attach->i_id != (uint64_t)-1)) { ptr = pst_getID(pf, attach->i_id); if (ptr) { size = pst_ff_getID2data(pf, ptr, &h); } else { DEBUG_WARN(("Couldn't find ID pointer. Cannot save attachment to file\n")); } } else { size = attach->data.size; if (attach->data.data && size) { // save the attachment to the file (void)pst_fwrite(attach->data.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, 0, 0}; size_t size = 0; DEBUG_ENT("pst_attach_to_file_base64"); if ((!attach->data.data) && (attach->i_id != (uint64_t)-1)) { ptr = pst_getID(pf, attach->i_id); if (ptr) { size = pst_ff_getID2data(pf, ptr, &h); } else { DEBUG_WARN(("Couldn't find ID pointer. Cannot save attachment to Base64\n")); } } else { size = attach->data.size; if (attach->data.data && size) { // encode the attachment to the file char *c = pst_base64_encode(attach->data.data, size); if (c) { (void)pst_fwrite(c, (size_t)1, strlen(c), fp); free(c); // caught by valgrind } } } DEBUG_RET(); return size; } int pst_load_index (pst_file *pf) { int x; DEBUG_ENT("pst_load_index"); if (!pf) { DEBUG_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_INFO(("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_INFO(("build desc ptr returns %i\n", x)); pst_printDptr(pf, pf->d_head); DEBUG_RET(); return 0; } pst_desc_tree* pst_getNextDptr(pst_desc_tree* d) { pst_desc_tree* 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; /** Try to load the extended attributes from the pst file. @return true(1) or false(0) to indicate whether the extended attributes have been loaded */ int pst_load_extended_attributes(pst_file *pf) { // for PST files this will load up d_id 0x61 and check it's "assoc_tree" attribute. pst_desc_tree *p; pst_mapi_object *list; pst_id2_tree *id2_head = NULL; char *buffer=NULL, *headerbuffer=NULL; size_t bsize=0, hsize=0, bptr=0; pst_x_attrib xattrib; int32_t tint, x; pst_x_attrib_ll *ptr, *p_head=NULL; DEBUG_ENT("pst_loadExtendedAttributes"); p = pst_getDptr(pf, (uint64_t)0x61); if (!p) { DEBUG_WARN(("Cannot find d_id 0x61 for loading the Extended Attributes\n")); DEBUG_RET(); return 0; } if (!p->desc) { DEBUG_WARN(("descriptor is NULL for d_id 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 d_id 0x61. Brace yourself!\n")); } list = pst_parse_block(pf, p->desc->i_id, id2_head); if (!list) { DEBUG_WARN(("Cannot process desc block for item 0x61. Not loading extended Attributes\n")); pst_free_id2(id2_head); DEBUG_RET(); return 0; } - DEBUG_INFO(("look thru d_id 0x61 list of mapi objects\n")); + DEBUG_INFO(("look through d_id 0x61 list of mapi objects\n")); for (x=0; x < list->count_elements; x++) { DEBUG_INFO(("#%d - mapi-id: %#x type: %#x length: %#x\n", x, list->elements[x]->mapi_id, list->elements[x]->type, list->elements[x]->size)); if (list->elements[x]->data) { DEBUG_HEXDUMPC(list->elements[x]->data, list->elements[x]->size, 0x10); } if (list->elements[x]->mapi_id == (uint32_t)0x0003) { buffer = list->elements[x]->data; bsize = list->elements[x]->size; } else if (list->elements[x]->mapi_id == (uint32_t)0x0004) { headerbuffer = list->elements[x]->data; hsize = list->elements[x]->size; } else { // leave them null } } if (!buffer) { pst_free_list(list); DEBUG_WARN(("No extended attributes buffer found. Not processing\n")); DEBUG_RET(); return 0; } while (bptr < bsize) { int err = 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; ptr = (pst_x_attrib_ll*) pst_malloc(sizeof(*ptr)); memset(ptr, 0, sizeof(*ptr)); ptr->map = xattrib.map+0x8000; ptr->next = NULL; DEBUG_INFO(("xattrib: ext = %#"PRIx32", type = %#"PRIx16", map = %#"PRIx16"\n", xattrib.extended, xattrib.type, xattrib.map)); 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*) pst_malloc((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_INFO(("Mapped attribute %#"PRIx32" to %s\n", ptr->map, ptr->data)); } else { DEBUG_INFO(("Cannot read outside of buffer [%i !< %i]\n", xattrib.extended, hsize)); err = 1; } ptr->mytype = PST_MAP_HEADER; } else { // contains the attribute code to map to. ptr->data = (uint32_t*)pst_malloc(sizeof(uint32_t)); memset(ptr->data, 0, sizeof(uint32_t)); *((uint32_t*)ptr->data) = xattrib.extended; ptr->mytype = PST_MAP_ATTRIB; DEBUG_INFO(("Mapped attribute %#"PRIx32" to %#"PRIx32"\n", ptr->map, *((uint32_t*)ptr->data))); } if (!err) { // add it to the list pst_x_attrib_ll *p_sh = p_head; pst_x_attrib_ll *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); } } pst_free_id2(id2_head); pst_free_list(list); pf->x_head = p_head; DEBUG_RET(); return 1; } #define ITEM_COUNT_OFFSET32 0x1f0 // count byte #define MAX_COUNT_OFFSET32 0x1f1 #define ENTRY_SIZE_OFFSET32 0x1f2 #define LEVEL_INDICATOR_OFFSET32 0x1f3 // node or leaf #define BACKLINK_OFFSET32 0x1f8 // backlink u1 value #define ITEM_COUNT_OFFSET64 0x1e8 // count byte #define MAX_COUNT_OFFSET64 0x1e9 #define ENTRY_SIZE_OFFSET64 0x1ea // node or leaf #define LEVEL_INDICATOR_OFFSET64 0x1eb // node or leaf #define BACKLINK_OFFSET64 0x1f8 // backlink u1 value #define ITEM_COUNT_OFFSET4K 0xfd8 #define MAX_COUNT_OFFSET4K 0xfda #define ENTRY_SIZE_OFFSET4K 0xfdc #define LEVEL_INDICATOR_OFFSET4K 0xfdd #define BACKLINK_OFFSET4K 0xff0 #define BLOCK_SIZE (size_t)((pf->do_read64 == 2) ? 4096 : 512) // index blocks #define DESC_BLOCK_SIZE (size_t)((pf->do_read64 == 2) ? 4096 : 512) // descriptor blocks #define ITEM_COUNT_OFFSET (size_t)((pf->do_read64) ? (pf->do_read64 == 2 ? ITEM_COUNT_OFFSET4K : ITEM_COUNT_OFFSET64) : ITEM_COUNT_OFFSET32) #define LEVEL_INDICATOR_OFFSET (size_t)((pf->do_read64) ? (pf->do_read64 == 2 ? LEVEL_INDICATOR_OFFSET4K : LEVEL_INDICATOR_OFFSET64) : LEVEL_INDICATOR_OFFSET32) #define BACKLINK_OFFSET (size_t)((pf->do_read64) ? (pf->do_read64 == 2 ? BACKLINK_OFFSET4K : BACKLINK_OFFSET64) : BACKLINK_OFFSET32) #define ENTRY_SIZE_OFFSET (size_t)((pf->do_read64) ? (pf->do_read64 == 2 ? ENTRY_SIZE_OFFSET4K : ENTRY_SIZE_OFFSET64) : ENTRY_SIZE_OFFSET32) #define MAX_COUNT_OFFSET (size_t)((pf->do_read64) ? (pf->do_read64 == 2 ? MAX_COUNT_OFFSET4K : MAX_COUNT_OFFSET64) : MAX_COUNT_OFFSET32) #define read_twobyte(BUF, OFF) (int32_t) ((((unsigned)BUF[OFF + 1] & 0xFF)) << 8) | ((unsigned)BUF[OFF] & 0xFF); static size_t pst_decode_desc(pst_file *pf, pst_desc *desc, char *buf); static size_t pst_decode_desc(pst_file *pf, pst_desc *desc, char *buf) { size_t r; if (pf->do_read64) { DEBUG_INFO(("Decoding desc64\n")); DEBUG_HEXDUMPC(buf, sizeof(pst_desc), 0x10); memcpy(desc, buf, sizeof(pst_desc)); LE64_CPU(desc->d_id); LE64_CPU(desc->desc_id); LE64_CPU(desc->tree_id); LE32_CPU(desc->parent_d_id); LE32_CPU(desc->u1); r = sizeof(pst_desc); } else { pst_desc32 d32; DEBUG_INFO(("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_struct *table, char *buf); static size_t pst_decode_table(pst_file *pf, struct pst_table_ptr_struct *table, char *buf) { size_t r; if (pf->do_read64) { DEBUG_INFO(("Decoding table64\n")); DEBUG_HEXDUMPC(buf, sizeof(struct pst_table_ptr_struct), 0x10); memcpy(table, buf, sizeof(struct pst_table_ptr_struct)); LE64_CPU(table->start); LE64_CPU(table->u1); LE64_CPU(table->offset); r =sizeof(struct pst_table_ptr_struct); } else { struct pst_table_ptr_struct32 t32; DEBUG_INFO(("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 == 2) { DEBUG_INFO(("Decoding index4k\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->inflated_size); LE16_CPU(index->u0); LE32_CPU(index->u1); r = sizeof(pst_index); } else if (pf->do_read64 == 1) { pst_index64 index64; DEBUG_INFO(("Decoding index64\n")); DEBUG_HEXDUMPC(buf, sizeof(pst_index64), 0x10); memcpy(&index64, buf, sizeof(pst_index64)); LE64_CPU(index64.id); LE64_CPU(index64.offset); LE16_CPU(index64.size); LE16_CPU(index64.u0); LE32_CPU(index64.u1); index->id = index64.id; index->offset = index64.offset; index->size = index64.size; index->inflated_size = index64.size; index->u0 = index64.u0; index->u1 = index64.u1; r = sizeof(pst_index64); } else { pst_index32 index32; DEBUG_INFO(("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->inflated_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_INFO(("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_INFO(("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.child_id); 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; DEBUG_ENT("pst_decode_type3"); if (pf->do_read64) { DEBUG_INFO(("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_INFO(("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); } DEBUG_RET(); 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. */ static 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_struct table, table2; pst_index_ll *i_ptr=NULL; pst_index index; int32_t x, item_count, count_max; uint64_t old = start_val; char *buf = NULL, *bptr; DEBUG_ENT("pst_build_id_ptr"); DEBUG_INFO(("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_INFO(("Reading index block\n")); if (pst_read_block_size(pf, offset, BLOCK_SIZE, 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, 0x10); if (pf->do_read64 == 2) { item_count = read_twobyte(buf, ITEM_COUNT_OFFSET); count_max = read_twobyte(buf, MAX_COUNT_OFFSET); } else { item_count = (int32_t)(unsigned)(buf[ITEM_COUNT_OFFSET]); count_max = (int32_t)(unsigned)(buf[MAX_COUNT_OFFSET]); } if (item_count > count_max) { DEBUG_WARN(("Item count %i too large, max is %i\n", item_count, 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; } int entry_size = (int32_t)(unsigned)(buf[ENTRY_SIZE_OFFSET]); DEBUG_INFO(("count %#"PRIx64" max %#"PRIx64" size %#"PRIx64"\n", item_count, count_max, entry_size)); if (buf[LEVEL_INDICATOR_OFFSET] == '\0') { // this node contains leaf pointers x = 0; while (x < item_count) { pst_decode_index(pf, &index, bptr); bptr += entry_size; x++; if (index.id == 0) break; DEBUG_INFO(("[%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_INFO(("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 (pf->i_count == pf->i_capacity) { pf->i_capacity += (pf->i_capacity >> 1) + 16; // arbitrary growth rate pf->i_table = pst_realloc(pf->i_table, pf->i_capacity * sizeof(pst_index_ll)); } i_ptr = &pf->i_table[pf->i_count++]; i_ptr->i_id = index.id; i_ptr->offset = index.offset; i_ptr->u1 = index.u1; i_ptr->size = index.size; i_ptr->inflated_size = index.inflated_size; } } else { // this node contains node pointers x = 0; while (x < item_count) { pst_decode_table(pf, &table, bptr); bptr += entry_size; x++; if (table.start == 0) break; if (x < item_count) { (void)pst_decode_table(pf, &table2, bptr); } else { table2.start = end_val; } DEBUG_INFO(("[%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; (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. */ static 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_struct table, table2; pst_desc desc_rec; int32_t item_count, count_max; uint64_t old = start_val; int x; char *buf = NULL, *bptr; DEBUG_ENT("pst_build_desc_ptr"); DEBUG_INFO(("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_INFO(("Reading desc block\n")); if (pst_read_block_size(pf, offset, DESC_BLOCK_SIZE, 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; if (pf->do_read64 == 2) { item_count = read_twobyte(buf, ITEM_COUNT_OFFSET); count_max = read_twobyte(buf, MAX_COUNT_OFFSET); } else { item_count = (int32_t)(unsigned)(buf[ITEM_COUNT_OFFSET]); count_max = (int32_t)(unsigned)(buf[MAX_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; } int32_t entry_size = (int32_t)(unsigned)(buf[ENTRY_SIZE_OFFSET]); if (buf[LEVEL_INDICATOR_OFFSET] == '\0') { // this node contains leaf pointers DEBUG_HEXDUMPC(buf, DESC_BLOCK_SIZE, entry_size); if (item_count > count_max) { DEBUG_WARN(("Item count %i too large, max is %i\n", item_count, 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; DEBUG_INFO(("New Record %#"PRIx64" with parent %#x\n", desc_rec.d_id, desc_rec.parent_d_id)); { pst_desc_tree *d_ptr = (pst_desc_tree*) pst_malloc(sizeof(pst_desc_tree)); 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, entry_size); if (item_count > count_max) { DEBUG_WARN(("Item count %i too large, max is %i\n", item_count, 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; (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_tree *d_ptr, pst_id2_tree *m_head) { pst_mapi_object * list; pst_id2_tree *id2_head = m_head; pst_id2_tree *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\n")); 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->i_id, id2_head); if (!list) { DEBUG_WARN(("pst_parse_block() returned an error for d_ptr->desc->i_id [%#"PRIx64"]\n", d_ptr->desc->i_id)); if (!m_head) pst_free_id2(id2_head); DEBUG_RET(); return NULL; } item = (pst_item*) pst_malloc(sizeof(pst_item)); memset(item, 0, sizeof(pst_item)); item->pf = pf; if (pst_process(d_ptr->desc->i_id, list, item, NULL)) { DEBUG_WARN(("pst_process() returned non-zero value. That is an error\n")); pst_freeItem(item); pst_free_list(list); 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_INFO(("DSN/MDN processing\n")); list = pst_parse_block(pf, id2_ptr->id->i_id, id2_ptr->child); if (list) { for (x=0; x < list->count_objects; x++) { attach = (pst_item_attach*) pst_malloc(sizeof(pst_item_attach)); memset(attach, 0, sizeof(pst_item_attach)); attach->next = item->attach; item->attach = attach; } if (pst_process(id2_ptr->id->i_id, list, item, item->attach)) { DEBUG_WARN(("ERROR pst_process() failed with DSN/MDN attachments\n")); pst_freeItem(item); pst_free_list(list); if (!m_head) pst_free_id2(id2_head); DEBUG_RET(); return NULL; } pst_free_list(list); } else { DEBUG_WARN(("ERROR error processing main DSN/MDN record\n")); // if (!m_head) pst_free_id2(id2_head); // DEBUG_RET(); // return item; } } if ((id2_ptr = pst_getID2(id2_head, (uint64_t)0x671))) { DEBUG_INFO(("ATTACHMENT processing attachment\n")); list = pst_parse_block(pf, id2_ptr->id->i_id, id2_ptr->child); if (!list) { if (item->flags & PST_FLAG_HAS_ATTACHMENT) { // Only report an error if we expected to see an attachment table and didn't. 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_objects; x++) { attach = (pst_item_attach*) pst_malloc(sizeof(pst_item_attach)); memset(attach, 0, sizeof(pst_item_attach)); attach->next = item->attach; item->attach = attach; } if (pst_process(id2_ptr->id->i_id, list, item, item->attach)) { DEBUG_WARN(("ERROR pst_process() failed with attachments\n")); pst_freeItem(item); pst_free_list(list); 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 for (attach = item->attach; attach; attach = attach->next) { 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->i_id)); // id2_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->i_id, NULL); if (!list) { DEBUG_WARN(("ERROR error processing an attachment record\n")); continue; } if (list->count_objects > 1) { DEBUG_WARN(("ERROR probably fatal, list count array will overrun attach structure.\n")); } // reprocess the same attachment list against new data // this might update attach->id2_val if (pst_process(id2_ptr->id->i_id, list, item, attach)) { DEBUG_WARN(("ERROR pst_process() failed with an attachment\n")); pst_free_list(list); continue; } pst_free_list(list); // As per 2.4.6.2 in the spec, the attachment data is stored as a child of the // attachment object, so we pass in id2_ptr as the head to search from. id2_ptr = pst_getID2(id2_ptr->child, attach->id2_val); if (id2_ptr) { DEBUG_WARN(("second pass attachment updating id2 %#"PRIx64" found i_id %#"PRIx64"\n", attach->id2_val, id2_ptr->id->i_id)); // i_id has been updated to the datablock containing the attachment data attach->i_id = id2_ptr->id->i_id; attach->id2_head = deep_copy(id2_ptr->child); } else { 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 } } } 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 MAPI objects, each of which contains a list of MAPI elements. * * @return list of MAPI objects */ static pst_mapi_object* pst_parse_block(pst_file *pf, uint64_t block_id, pst_id2_tree *i2_head) { pst_mapi_object *mo_head = NULL; char *buf = NULL; size_t read_size = 0; pst_subblocks subblocks; 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; int32_t num_mapi_objects; int32_t count_mapi_objects; int32_t num_mapi_elements; int32_t count_mapi_elements; 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; char* ind2_block_start = NULL; size_t ind2_max_block_size = pf->do_read64 ? 0x1FF0 : 0x1FF4; 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) { DEBUG_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_INFO(("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; i 0) { if (pst_getBlockOffsetPointer(pf, i2_head, &subblocks, table_rec.value, &block_offset5)) { DEBUG_WARN(("internal error (7c.b5.desc offset %#x) in reading block id %#"PRIx64"\n", table_rec.value, block_id)); freeall(&subblocks, &block_offset1, &block_offset2, &block_offset3, &block_offset4, &block_offset5, &block_offset6, &block_offset7); DEBUG_RET(); return NULL; } // this will give the number of records in this block num_mapi_objects = (block_offset5.to - block_offset5.from) / (4 + table_rec.ref_type); if (pst_getBlockOffsetPointer(pf, i2_head, &subblocks, seven_c_blk.ind2_offset, &block_offset6)) { DEBUG_WARN(("internal error (7c.ind2 offset %#x) in reading block id %#"PRIx64"\n", seven_c_blk.ind2_offset, block_id)); freeall(&subblocks, &block_offset1, &block_offset2, &block_offset3, &block_offset4, &block_offset5, &block_offset6, &block_offset7); DEBUG_RET(); return NULL; } ind2_ptr = block_offset6.from; ind2_block_start = ind2_ptr; ind2_end = block_offset6.to; } else { num_mapi_objects = 0; } DEBUG_INFO(("7cec block index2 pointer %#x and end %#x\n", ind2_ptr, ind2_end)); } else { DEBUG_WARN(("ERROR: Unknown block constant - %#hx for id %#"PRIx64"\n", block_hdr.type, block_id)); freeall(&subblocks, &block_offset1, &block_offset2, &block_offset3, &block_offset4, &block_offset5, &block_offset6, &block_offset7); DEBUG_RET(); return NULL; } DEBUG_INFO(("found %i mapi objects each with %i mapi elements\n", num_mapi_objects, num_mapi_elements)); for (count_mapi_objects=0; count_mapi_objectsnext = mo_head; mo_head = mo_ptr; // allocate the array of mapi elements mo_ptr->elements = (pst_mapi_element**) pst_malloc(sizeof(pst_mapi_element)*num_mapi_elements); mo_ptr->count_elements = num_mapi_elements; mo_ptr->orig_count = num_mapi_elements; mo_ptr->count_objects = (int32_t)num_mapi_objects; // each record will have a record of the total number of records for (x=0; xelements[x] = NULL; DEBUG_INFO(("going to read %i mapi elements for mapi object %i\n", num_mapi_elements, count_mapi_objects)); fr_ptr = list_start; // initialize fr_ptr to the start of the list. x = 0; // x almost tracks count_mapi_elements, but see 'continue' statement below for (count_mapi_elements=0; count_mapi_elements= (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 { DEBUG_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(mo_head); DEBUG_RET(); return NULL; } DEBUG_INFO(("reading element %i (type=%#x, ref_type=%#x, value=%#x)\n", x, table_rec.type, table_rec.ref_type, table_rec.value)); if (!mo_ptr->elements[x]) { mo_ptr->elements[x] = (pst_mapi_element*) pst_malloc(sizeof(pst_mapi_element)); } 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) { mo_ptr->elements[x]->mapi_id = *((uint32_t*)mapptr->data); DEBUG_INFO(("Mapped attrib %#x to %#x\n", table_rec.type, mo_ptr->elements[x]->mapi_id)); } else if (mapptr->mytype == PST_MAP_HEADER) { DEBUG_INFO(("Internet Header mapping found %#"PRIx32" to %s\n", table_rec.type, 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 { mo_ptr->elements[x]->mapi_id = table_rec.type; } 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 mo_ptr->elements[x]->size = sizeof(int32_t); mo_ptr->elements[x]->type = table_rec.ref_type; mo_ptr->elements[x]->data = pst_malloc(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. mo_ptr->elements[x]->size = value_size; mo_ptr->elements[x]->type = table_rec.ref_type; mo_ptr->elements[x]->data = pst_malloc(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)); 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)); } mo_ptr->count_elements --; //we will be skipping a row continue; } } else { value_size = (size_t)(block_offset7.to - block_offset7.from); mo_ptr->elements[x]->size = value_size; mo_ptr->elements[x]->type = table_rec.ref_type; mo_ptr->elements[x]->data = pst_malloc(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*) mo_ptr->elements[x]->data; LE32_CPU(type_d_rec->id); 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)); 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 pst_vbuf *utf16buf = NULL; static pst_vbuf *utf8buf = NULL; if (!utf16buf) utf16buf = pst_vballoc((size_t)1024); if (!utf8buf) utf8buf = pst_vballoc((size_t)1024); //need UTF-16 zero-termination pst_vbset(utf16buf, mo_ptr->elements[x]->data, mo_ptr->elements[x]->size); pst_vbappend(utf16buf, "\0\0", (size_t)2); DEBUG_INFO(("Iconv in:\n")); DEBUG_HEXDUMPC(utf16buf->b, utf16buf->dlen, 0x10); rc = pst_vb_utf16to8(utf8buf, utf16buf->b, utf16buf->dlen); if (rc == (size_t)-1) { DEBUG_WARN(("Failed to convert utf-16 to utf-8\n")); } else { free(mo_ptr->elements[x]->data); mo_ptr->elements[x]->size = utf8buf->dlen; mo_ptr->elements[x]->data = pst_malloc(utf8buf->dlen); memcpy(mo_ptr->elements[x]->data, utf8buf->b, utf8buf->dlen); } DEBUG_INFO(("Iconv out:\n")); DEBUG_HEXDUMPC(mo_ptr->elements[x]->data, mo_ptr->elements[x]->size, 0x10); } if (mo_ptr->elements[x]->type == 0) mo_ptr->elements[x]->type = table_rec.ref_type; } else { DEBUG_WARN(("ERROR Unknown ref_type %#hx\n", table_rec.ref_type)); } x++; } DEBUG_INFO(("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; // ind2 rows do not get split between blocks. See PST spec, 2.3.4.4 "Row Matrix". if (ind2_ptr + rec_size > ind2_block_start + ind2_max_block_size) { ind2_block_start += ind2_max_block_size; DEBUG_INFO(("advancing ind2_ptr to next block. Was %#x, Now %#x\n", ind2_ptr, ind2_block_start)); ind2_ptr = ind2_block_start; } } freeall(&subblocks, &block_offset1, &block_offset2, &block_offset3, &block_offset4, &block_offset5, &block_offset6, &block_offset7); DEBUG_RET(); 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) #define SAFE_FREE_BIN(x) SAFE_FREE(x.data) // check if item->email is NULL, and init if so #define MALLOC_EMAIL(x) { if (!x->email) { x->email = (pst_item_email*) pst_malloc(sizeof(pst_item_email)); memset(x->email, 0, sizeof(pst_item_email) );} } #define MALLOC_FOLDER(x) { if (!x->folder) { x->folder = (pst_item_folder*) pst_malloc(sizeof(pst_item_folder)); memset(x->folder, 0, sizeof(pst_item_folder) );} } #define MALLOC_CONTACT(x) { if (!x->contact) { x->contact = (pst_item_contact*) pst_malloc(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*) pst_malloc(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*) pst_malloc(sizeof(pst_item_journal)); memset(x->journal, 0, sizeof(pst_item_journal) );} } #define MALLOC_APPOINTMENT(x) { if (!x->appointment) { x->appointment = (pst_item_appointment*) pst_malloc(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 pst_realloc(targ, list->elements[x]->size+1); \ memcpy(targ, list->elements[x]->data, list->elements[x]->size);\ memset(((char*)targ)+list->elements[x]->size, 0, (size_t)1); \ } #define LIST_COPY_CSTR(targ) { \ if ((list->elements[x]->type == 0x1f) || \ (list->elements[x]->type == 0x1e) || \ (list->elements[x]->type == 0x102)) { \ LIST_COPY(targ, (char*)) \ } \ else { \ DEBUG_WARN(("src not 0x1e or 0x1f or 0x102 for string dst\n")); \ DEBUG_HEXDUMP(list->elements[x]->data, list->elements[x]->size); \ SAFE_FREE(targ); \ targ = NULL; \ } \ } #define LIST_COPY_BOOL(label, targ) { \ if (list->elements[x]->type != 0x0b) { \ DEBUG_WARN(("src not 0x0b for boolean dst\n")); \ DEBUG_HEXDUMP(list->elements[x]->data, list->elements[x]->size); \ } \ if (*(int16_t*)list->elements[x]->data) { \ DEBUG_INFO((label" - True\n")); \ targ = 1; \ } else { \ DEBUG_INFO((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(targ) { \ if (list->elements[x]->type != 0x02) { \ DEBUG_WARN(("src not 0x02 for int16 dst\n")); \ DEBUG_HEXDUMP(list->elements[x]->data, list->elements[x]->size); \ } \ memcpy(&(targ), list->elements[x]->data, sizeof(targ)); \ LE16_CPU(targ); \ } #define LIST_COPY_INT16(label, targ) { \ LIST_COPY_INT16_N(targ); \ DEBUG_INFO((label" - %i %#x\n", (int)targ, (int)targ)); \ } #define LIST_COPY_INT32_N(targ) { \ if (list->elements[x]->type != 0x03) { \ DEBUG_WARN(("src not 0x03 for int32 dst\n")); \ DEBUG_HEXDUMP(list->elements[x]->data, list->elements[x]->size); \ } \ memcpy(&(targ), list->elements[x]->data, sizeof(targ)); \ LE32_CPU(targ); \ } #define LIST_COPY_INT32(label, targ) { \ LIST_COPY_INT32_N(targ); \ DEBUG_INFO((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(targ); \ targ += delta; \ DEBUG_INFO((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(targ); \ targ += delta; \ DEBUG_INFO((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) { \ LIST_COPY(targ, (pst_entryid*)); \ LE32_CPU(targ->u1); \ LE32_CPU(targ->id); \ DEBUG_INFO((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_CSTR(targ.str); \ targ.is_utf8 = (list->elements[x]->type == 0x1f) ? 1 : 0; \ DEBUG_INFO((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) { \ if ((list->elements[x]->type != 0x40) || \ (list->elements[x]->size != sizeof(FILETIME))) { \ DEBUG_WARN(("src not 0x40 or wrong length for filetime dst\n")); \ DEBUG_HEXDUMP(list->elements[x]->data, list->elements[x]->size); \ } \ else { \ targ = (FILETIME*) pst_realloc(targ, sizeof(FILETIME)); \ memcpy(targ, list->elements[x]->data, sizeof(FILETIME)); \ LE32_CPU(targ->dwLowDateTime); \ LE32_CPU(targ->dwHighDateTime); \ DEBUG_INFO((label" - %s", pst_fileTimeToAscii(targ, time_buffer))); \ } \ } #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_BIN(targ) { \ targ.size = list->elements[x]->size; \ if (targ.size) { \ targ.data = (char*)pst_realloc(targ.data, targ.size); \ memcpy(targ.data, list->elements[x]->data, targ.size); \ } \ else { \ SAFE_FREE_BIN(targ); \ targ.data = NULL; \ } \ } #define LIST_COPY_EMAIL_BIN(label, targ) { \ MALLOC_EMAIL(item); \ LIST_COPY_BIN(targ); \ DEBUG_INFO((label"\n")); \ } #define LIST_COPY_APPT_BIN(label, targ) { \ MALLOC_APPOINTMENT(item); \ LIST_COPY_BIN(targ); \ DEBUG_INFO((label"\n")); \ DEBUG_HEXDUMP(targ.data, targ.size); \ } #define NULL_CHECK(x) { if (!x) { DEBUG_WARN(("NULL_CHECK: Null Found\n")); break;} } /** * process the list of MAPI objects produced from parse_block() * * @param block_id block number used by parse_block() to produce these MAPI objects * @param list pointer to the list of MAPI objects from parse_block() * @param item pointer to the high level item to be updated from the list. * this item may be an email, contact or other sort of item. * 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 MAPI objects list. * * @return 0 for ok, -1 for error. */ static int pst_process(uint64_t block_id, pst_mapi_object *list, pst_item *item, pst_item_attach *attach) { DEBUG_ENT("pst_process"); if (!item) { DEBUG_WARN(("item cannot be NULL.\n")); DEBUG_RET(); return -1; } item->block_id = block_id; while (list) { int32_t x; char time_buffer[30]; for (x=0; xcount_elements; x++) { int32_t t; uint32_t ut; DEBUG_INFO(("#%d - mapi-id: %#x type: %#x length: %#x\n", x, list->elements[x]->mapi_id, list->elements[x]->type, list->elements[x]->size)); switch (list->elements[x]->mapi_id) { case PST_ATTRIB_HEADER: // CUSTOM attribute for saying the Extra Headers if (list->elements[x]->extra) { if (list->elements[x]->type == 0x0101e) { // an array of strings, rather than a single string int32_t string_length, i, offset, next_offset; int32_t p = 0; int32_t array_element_count = PST_LE_GET_INT32(list->elements[x]->data); p+=4; for (i = 1; i <= array_element_count; i++) { pst_item_extra_field *ef = (pst_item_extra_field*) pst_malloc(sizeof(pst_item_extra_field)); memset(ef, 0, sizeof(pst_item_extra_field)); offset = PST_LE_GET_INT32(list->elements[x]->data + p); p+=4; next_offset = (i == array_element_count) ? list->elements[x]->size : PST_LE_GET_INT32(list->elements[x]->data + p);; string_length = next_offset - offset; ef->value = pst_malloc(string_length + 1); memcpy(ef->value, list->elements[x]->data + offset, string_length); ef->value[string_length] = '\0'; ef->field_name = strdup(list->elements[x]->extra); ef->next = item->extra_fields; item->extra_fields = ef; DEBUG_INFO(("Extra Field - \"%s\" = \"%s\"\n", ef->field_name, ef->value)); } } else { // should be a single string pst_item_extra_field *ef = (pst_item_extra_field*) pst_malloc(sizeof(pst_item_extra_field)); memset(ef, 0, sizeof(pst_item_extra_field)); LIST_COPY_CSTR(ef->value); if (ef->value) { ef->field_name = strdup(list->elements[x]->extra); ef->next = item->extra_fields; item->extra_fields = ef; DEBUG_INFO(("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_INFO(("body charset %s from content-type extra field\n", set)); } } } } else { DEBUG_WARN(("What does this mean? Internet header %s value\n", list->elements[x]->extra)); DEBUG_HEXDUMP(list->elements[x]->data, list->elements[x]->size); free(ef); // caught by valgrind } } } break; case 0x0002: // PR_ALTERNATE_RECIPIENT_ALLOWED if (list->elements[x]->type == 0x0b) { // 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; } else { DEBUG_WARN(("What does this mean?\n")); DEBUG_HEXDUMP(list->elements[x]->data, list->elements[x]->size); } break; case 0x0003: // Extended Attributes table DEBUG_INFO(("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 IPM.x if ((list->elements[x]->type == 0x1e) || (list->elements[x]->type == 0x1f)) { LIST_COPY_CSTR(item->ascii_type); if (!item->ascii_type) item->ascii_type = strdup("unknown"); if (pst_strincmp("IPM.Note", item->ascii_type, 8) == 0) item->type = PST_TYPE_NOTE; else if (pst_stricmp("IPM", item->ascii_type) == 0) item->type = PST_TYPE_NOTE; else if (pst_strincmp("IPM.Contact", item->ascii_type, 11) == 0) item->type = PST_TYPE_CONTACT; else if (pst_strincmp("REPORT.IPM.Note", item->ascii_type, 15) == 0) 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.Schedule.Meeting", item->ascii_type, 20) == 0) item->type = PST_TYPE_SCHEDULE; // meeting requests and responses transported over email else if (pst_strincmp("IPM.StickyNote", item->ascii_type, 14) == 0) item->type = PST_TYPE_STICKYNOTE; else if (pst_strincmp("IPM.Task", item->ascii_type, 8) == 0) item->type = PST_TYPE_TASK; else item->type = PST_TYPE_OTHER; DEBUG_INFO(("Message class %s [%"PRIi32"] \n", item->ascii_type, item->type)); } else { DEBUG_WARN(("What does this mean?\n")); DEBUG_HEXDUMP(list->elements[x]->data, list->elements[x]->size); } break; case 0x0023: // PR_ORIGINATOR_DELIVERY_REPORT_REQUESTED if (list->elements[x]->type == 0x0b) { // set if the sender wants a delivery report from all recipients LIST_COPY_EMAIL_BOOL("Global Delivery Report", item->email->delivery_report); } else { DEBUG_WARN(("What does this mean?\n")); DEBUG_HEXDUMP(list->elements[x]->data, list->elements[x]->size); } break; case 0x0026: // PR_PRIORITY 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->original_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->elements[x]->size > 2) && (((uint8_t)list->elements[x]->data[0]) < 0x20)) { off = 2; } list->elements[x]->data += off; list->elements[x]->size -= off; LIST_COPY_STR("Raw Subject", item->subject); 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_INFO(("Recipient Structure 1 -- NOT PROCESSED\n")); break; case 0x0040: // PR_RECEIVED_BY_NAME Name of Recipient Structure LIST_COPY_EMAIL_STR("Received By Name 1", item->email->outlook_received_name1); break; case 0x0041: // PR_SENT_REPRESENTING_ENTRYID Structure containing Sender DEBUG_INFO(("Sent on behalf of Structure 1 -- NOT PROCESSED\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_INFO(("Received on behalf of Structure -- NOT PROCESSED\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_INFO(("Reply-To Structure -- NOT PROCESSED\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_BIN("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_INFO(("Non-Receipt Notification Requested -- NOT PROCESSED\n")); 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_INFO(("Sender Structure 2 -- NOT PROCESSED\n")); break; case 0x0C1A: // PR_SENDER_NAME Name of Sender Structure 2 LIST_COPY_EMAIL_STR("Name of Sender Structure 2", item->email->outlook_sender_name2); 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 LIST_COPY_EMAIL_INT32("Message Flags", item->flags); break; case 0x0E08: // PR_MESSAGE_SIZE Total size of a message object 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 0x0E1D: // PR_NORMALIZED_SUBJECT LIST_COPY_EMAIL_STR("Normalized subject", item->email->outlook_normalized_subject); 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 NULL_CHECK(attach); LIST_COPY_INT32("Attachment Size", t); // ignore this. we either get data and size from 0x3701 // or id codes from 0x3701 or 0x67f2 break; case 0x0FF9: // PR_RECORD_KEY Record Header 1 LIST_COPY_BIN(item->record_key); DEBUG_INFO(("Record Key\n")); DEBUG_HEXDUMP(item->record_key.data, item->record_key.size); break; case 0x1000: // PR_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 + // a count of the *significant* characters 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_BIN("RTF Compressed body", item->email->rtf_compressed); 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_TIME("Date 4 (Item Creation Date)", item->create_date); break; case 0x3008: // PR_LAST_MODIFICATION_TIME Date 5 - Modify Date LIST_COPY_TIME("Date 5 (Modify Date)", item->modify_date); break; case 0x300B: // PR_SEARCH_KEY Record Header 2 LIST_COPY_EMAIL_STR("Record Search 2", item->email->outlook_search_key); break; case 0x35DF: // PR_VALID_FOLDER_MASK 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->item_count); break; case 0x3603: // PR_CONTENT_UNREAD Number of unread emails LIST_COPY_FOLDER_INT32("Unread Email Count", item->folder->unseen_item_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 LIST_COPY_CSTR(item->ascii_type); if (pst_strincmp("IPF.Note", item->ascii_type, 8) == 0) item->type = PST_TYPE_NOTE; else if (pst_strincmp("IPF.Imap", item->ascii_type, 8) == 0) item->type = PST_TYPE_NOTE; else if (pst_stricmp("IPF", item->ascii_type) == 0) item->type = PST_TYPE_NOTE; else if (pst_strincmp("IPF.Contact", item->ascii_type, 11) == 0) item->type = PST_TYPE_CONTACT; else if (pst_strincmp("IPF.Journal", item->ascii_type, 11) == 0) item->type = PST_TYPE_JOURNAL; else if (pst_strincmp("IPF.Appointment", item->ascii_type, 15) == 0) item->type = PST_TYPE_APPOINTMENT; else if (pst_strincmp("IPF.StickyNote", item->ascii_type, 14) == 0) item->type = PST_TYPE_STICKYNOTE; else if (pst_strincmp("IPF.Task", item->ascii_type, 8) == 0) item->type = PST_TYPE_TASK; else item->type = PST_TYPE_OTHER; DEBUG_INFO(("Container class %s [%"PRIi32"]\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("Associated Content count", item->folder->assoc_count); break; case 0x3701: // PR_ATTACH_DATA_OBJ binary data of attachment DEBUG_INFO(("Binary Data [Size %i]\n", list->elements[x]->size)); NULL_CHECK(attach); if (!list->elements[x]->data) { //special case attach->id2_val = list->elements[x]->type; DEBUG_INFO(("Seen a Reference. The data hasn't been loaded yet. [%#"PRIx64"]\n", attach->id2_val)); } else { LIST_COPY_BIN(attach->data); } 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 0x3712: // PR_ATTACH_CONTENT_ID // content identification header (Content-ID) NULL_CHECK(attach); LIST_COPY_STR("Content ID", attach->content_id); break; case 0x3A00: // PR_ACCOUNT LIST_COPY_CONTACT_STR("Contact's Account name", item->contact->account_name); break; case 0x3A01: // PR_ALTERNATE_RECIPIENT DEBUG_INFO(("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_INFO(("Original Entry ID - NOT PROCESSED\n")); break; case 0x3A13: // PR_ORIGINAL_DISPLAY_NAME DEBUG_INFO(("Original Display Name - NOT PROCESSED\n")); break; case 0x3A14: // PR_ORIGINAL_SEARCH_KEY DEBUG_INFO(("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_INFO(("User Certificate - NOT PROCESSED\n")); 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_INFO(("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: // PR_PREDECESSOR_CHANGE_LIST LIST_COPY_BIN(item->predecessor_change); DEBUG_INFO(("Predecessor Change\n")); DEBUG_HEXDUMP(item->predecessor_change.data, item->predecessor_change.size); break; case 0x67F2: // ID2 value of the attachment NULL_CHECK(attach); LIST_COPY_INT32("Attachment ID2 value", ut); attach->id2_val = ut; break; case 0x67FF: // Extra Property Identifier (Password CheckSum) LIST_COPY_STORE_INT32("Password checksum", item->message_store->pwd_chksum); break; case 0x6F02: // Secure HTML Body LIST_COPY_EMAIL_BIN("Secure HTML Body", item->email->encrypted_htmlbody); break; case 0x6F04: // Secure Text Body LIST_COPY_EMAIL_BIN("Secure Text Body", item->email->encrypted_body); break; case 0x7C07: // top of folders ENTRYID LIST_COPY_STORE_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: // PR_OUTLOOK_EVENT_SHOW_TIME_AS LIST_COPY_APPT_ENUM("Appointment shows as", item->appointment->showas, 0, 4, "Free", "Tentative", "Busy", "Out Of Office"); break; case 0x8208: // PR_OUTLOOK_EVENT_LOCATION LIST_COPY_APPT_STR("Appointment Location", item->appointment->location); break; case 0x820d: // PR_OUTLOOK_EVENT_START_DATE LIST_COPY_APPT_TIME("Appointment Date Start", item->appointment->start); break; case 0x820e: // PR_OUTLOOK_EVENT_START_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: // PR_OUTLOOK_EVENT_ALL_DAY LIST_COPY_APPT_BOOL("All day flag", item->appointment->all_day); break; case 0x8216: // PR_OUTLOOK_EVENT_RECURRENCE_DATA LIST_COPY_APPT_BIN("Appointment recurrence data", item->appointment->recurrence_data); break; case 0x8223: // PR_OUTLOOK_EVENT_IS_RECURRING LIST_COPY_APPT_BOOL("Is recurring", item->appointment->is_recurring); break; case 0x8231: // Recurrence type LIST_COPY_APPT_ENUM("Appointment recurrence type ", 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_description); break; case 0x8234: // TimeZone as String LIST_COPY_APPT_STR("TimeZone of times", item->appointment->timezonestring); break; case 0x8235: // PR_OUTLOOK_EVENT_RECURRENCE_START LIST_COPY_APPT_TIME("Recurrence Start Date", item->appointment->recurrence_start); break; case 0x8236: // PR_OUTLOOK_EVENT_RECURRENCE_END LIST_COPY_APPT_TIME("Recurrence End Date", item->appointment->recurrence_end); break; case 0x8501: // PR_OUTLOOK_COMMON_REMINDER_MINUTES_BEFORE LIST_COPY_APPT_INT32("Alarm minutes", item->appointment->alarm_minutes); break; case 0x8503: // PR_OUTLOOK_COMMON_REMINDER_SET LIST_COPY_APPT_BOOL("Reminder alarm", item->appointment->alarm); break; case 0x8516: // Common start DEBUG_INFO(("Common Start Date - %s\n", pst_fileTimeToAscii((FILETIME*)list->elements[x]->data, time_buffer))); break; case 0x8517: // Common end DEBUG_INFO(("Common End Date - %s\n", pst_fileTimeToAscii((FILETIME*)list->elements[x]->data, time_buffer))); 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: // PR_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->elements[x]->type == (uint32_t)0x0002) { DEBUG_WARN(("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_WARN(("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_WARN(("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_WARN(("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_WARN(("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_WARN(("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_WARN(("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_WARN(("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_WARN(("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_WARN(("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_WARN(("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_WARN(("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_WARN(("Unknown type %#x Date = \"%s\"\n", list->elements[x]->mapi_id, pst_fileTimeToAscii((FILETIME*)list->elements[x]->data, time_buffer))); } else if (list->elements[x]->type == (uint32_t)0x0048) { DEBUG_WARN(("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_WARN(("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_WARN(("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_WARN(("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_WARN(("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_WARN(("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_WARN(("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_WARN(("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->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; } static void pst_free_list(pst_mapi_object *list) { pst_mapi_object *l; DEBUG_ENT("pst_free_list"); while (list) { if (list->elements) { int32_t x; for (x=0; x < list->orig_count; x++) { if (list->elements[x]) { if (list->elements[x]->data) free(list->elements[x]->data); free(list->elements[x]); } } free(list->elements); } l = list->next; free (list); list = l; } DEBUG_RET(); } static void pst_free_id2(pst_id2_tree * head) { pst_id2_tree *t; DEBUG_ENT("pst_free_id2"); while (head) { pst_free_id2(head->child); t = head->next; free(head); head = t; } DEBUG_RET(); } static void pst_free_desc (pst_desc_tree *head) { pst_desc_tree *t; DEBUG_ENT("pst_free_desc"); while (head) { pst_free_desc(head->child); t = head->next; free(head); head = t; } DEBUG_RET(); } static 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(); } static pst_id2_tree * pst_build_id2(pst_file *pf, pst_index_ll* list) { pst_block_header block_head; pst_id2_tree *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_tree *i2_ptr = NULL; DEBUG_ENT("pst_build_id2"); if (pst_read_block_size(pf, list->offset, list->size, list->inflated_size, &buf) < list->size) { - //an error occured in block read - DEBUG_WARN(("block read error occured. offset = %#"PRIx64", size = %#"PRIx64"\n", list->offset, list->size)); + //an error occurred in block read + DEBUG_WARN(("block read error occurred. 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? DEBUG_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_INFO(("ID %#"PRIx64" is likely to be a description record. Count is %i (offset %#"PRIx64")\n", list->i_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_INFO(("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_INFO(("%#"PRIx64" - Offset %#"PRIx64", u1 %#"PRIx64", Size %"PRIi64"(%#"PRIx64")\n", i_ptr->i_id, i_ptr->offset, i_ptr->u1, i_ptr->size, i_ptr->inflated_size)); // add it to the tree i2_ptr = (pst_id2_tree*) pst_malloc(sizeof(pst_id2_tree)); 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 [%#"PRIx64"] 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; } static 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_STR(attach->content_id); SAFE_FREE_BIN(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_BIN(item->email->conversation_index); SAFE_FREE_BIN(item->email->encrypted_body); SAFE_FREE_BIN(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_BIN(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); SAFE_FREE_STR(item->email->outlook_received_name1); SAFE_FREE_STR(item->email->outlook_sender_name2); SAFE_FREE_STR(item->email->outlook_normalized_subject); SAFE_FREE_STR(item->email->outlook_search_key); 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->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->start); SAFE_FREE(item->journal->end); SAFE_FREE_STR(item->journal->type); free(item->journal); } if (item->appointment) { SAFE_FREE(item->appointment->start); SAFE_FREE(item->appointment->end); SAFE_FREE_STR(item->appointment->location); SAFE_FREE(item->appointment->reminder); SAFE_FREE_STR(item->appointment->alarm_filename); SAFE_FREE_STR(item->appointment->timezonestring); SAFE_FREE_STR(item->appointment->recurrence_description); SAFE_FREE_BIN(item->appointment->recurrence_data); 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_BIN(item->record_key); SAFE_FREE_BIN(item->predecessor_change); 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. */ static int pst_getBlockOffsetPointer(pst_file *pf, pst_id2_tree *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 { DEBUG_WARN(("Found internal %#x value.\n", offset)); // internal index reference size_t subindex = offset >> 16; if (pf->do_read64 == 2) { // Shift over 3 more bits for new flags. subindex = subindex >> 3; } 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; } /** */ static 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 || p->to > read_size) { DEBUG_WARN(("get block offset bad range\n")); DEBUG_RET(); return 0; } DEBUG_RET(); return 1; } static int pst_getID_compare(const void *key, const void *entry) { uint64_t key_id = *(const uint64_t*)key; uint64_t entry_id = ((const pst_index_ll*)entry)->i_id; return (key_id > entry_id) - (key_id < entry_id); } /** */ pst_index_ll* pst_getID(pst_file* pf, uint64_t i_id) { pst_index_ll *ptr; DEBUG_ENT("pst_getID"); if (i_id == 0) { DEBUG_RET(); return NULL; } //if (i_id & 1) DEBUG_INFO(("have odd id bit %#"PRIx64"\n", i_id)); //if (i_id & 2) DEBUG_INFO(("have two id bit %#"PRIx64"\n", i_id)); i_id -= (i_id & 1); DEBUG_INFO(("Trying to find %#"PRIx64"\n", i_id)); ptr = bsearch(&i_id, pf->i_table, pf->i_count, sizeof *pf->i_table, pst_getID_compare); if (ptr) {DEBUG_INFO(("Found Value %#"PRIx64"\n", i_id)); } else {DEBUG_INFO(("ERROR: Value %#"PRIx64" not found\n", i_id)); } DEBUG_RET(); return ptr; } static pst_id2_tree *pst_getID2(pst_id2_tree *head, uint64_t id2) { // the id2 values are only unique among siblings. // we must not recurse into children // the caller must supply the correct parent DEBUG_ENT("pst_getID2"); DEBUG_INFO(("looking for id2 = %#"PRIx64"\n", id2)); pst_id2_tree *ptr = head; while (ptr) { if (ptr->id2 == id2) break; ptr = ptr->next; } if (ptr && ptr->id) { DEBUG_INFO(("Found value %#"PRIx64"\n", ptr->id->i_id)); DEBUG_RET(); return ptr; } DEBUG_INFO(("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_tree node in the descriptor tree */ static pst_desc_tree* pst_getDptr(pst_file *pf, uint64_t d_id) { pst_desc_tree *ptr = pf->d_head; DEBUG_ENT("pst_getDptr"); while (ptr && (ptr->d_id != d_id)) { //DEBUG_INFO(("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 } static void pst_printDptr(pst_file *pf, pst_desc_tree *ptr) { DEBUG_ENT("pst_printDptr"); while (ptr) { DEBUG_INFO(("%#"PRIx64" [%i] desc=%#"PRIx64", assoc tree=%#"PRIx64"\n", ptr->d_id, ptr->no_child, (ptr->desc ? ptr->desc->i_id : (uint64_t)0), (ptr->assoc_tree ? ptr->assoc_tree->i_id : (uint64_t)0))); if (ptr->child) { pst_printDptr(pf, ptr->child); } ptr = ptr->next; } DEBUG_RET(); } static void pst_printID2ptr(pst_id2_tree *ptr) { DEBUG_ENT("pst_printID2ptr"); while (ptr) { DEBUG_INFO(("%#"PRIx64" id=%#"PRIx64"\n", ptr->id2, (ptr->id ? ptr->id->i_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 */ static size_t pst_read_raw_block_size(pst_file *pf, int64_t offset, size_t size, char **buf) { size_t rsize; DEBUG_ENT("pst_read_raw_block_size"); DEBUG_INFO(("Reading raw block from %#"PRIx64", %x bytes\n", offset, size)); if (*buf) { DEBUG_INFO(("Freeing old memory\n")); free(*buf); } *buf = (char*) pst_malloc(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; } static size_t pst_read_block_size(pst_file *pf, int64_t offset, size_t size, size_t inflated_size, char **buf) { DEBUG_ENT("pst_read_block_size"); DEBUG_INFO(("Reading block from %#"PRIx64", %x bytes, %x inflated\n", offset, size, inflated_size)); if (inflated_size <= size) { // Not deflated. size_t ret = pst_read_raw_block_size(pf, offset, size, buf); DEBUG_RET(); return ret; } // We need to read the raw block and inflate it. char *zbuf = NULL; if (pst_read_raw_block_size(pf, offset, size, &zbuf) != size) { DEBUG_WARN(("Failed to read %i bytes\n", size)); if (zbuf) free(zbuf); DEBUG_RET(); return -1; } *buf = (char *) pst_malloc(inflated_size); size_t result_size = inflated_size; if (uncompress((Bytef *) *buf, &result_size, (Bytef *) zbuf, size) != Z_OK || result_size != inflated_size) { DEBUG_WARN(("Failed to uncompress %i bytes to %i bytes, got %i\n", size, inflated_size, result_size)); if (zbuf) free(zbuf); DEBUG_RET(); return -1; } DEBUG_RET(); return inflated_size; } /** Decrypt a block of data from the pst file. * @param i_id identifier of this block, needed as part of the key for the enigma cipher * @param buf pointer to the buffer to be decrypted in place * @param size size of the buffer * @param type @li 0 PST_NO_ENCRYPT, none @li 1 PST_COMP_ENCRYPT, simple byte substitution cipher with fixed key - @li 2 PST_ENCRYPT, german enigma 3 rotor cipher with fixed key + @li 2 PST_ENCRYPT, German enigma 3 rotor cipher with fixed key * @return 0 if ok, -1 if error (NULL buffer or unknown encryption type) */ static int pst_decrypt(uint64_t i_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) (((i_id & 0x00000000ffff0000) >> 16) ^ (i_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 { DEBUG_WARN(("Unknown encryption: %i. Cannot decrypt\n", type)); DEBUG_RET(); return -1; } DEBUG_RET(); return 0; } static 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; } } static 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 */ static 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*)pst_malloc(sizeof(*p)); // *t = p; // p->next = tail; // p->offset = pos; // p->size = size; // p->readcount = 1; // } // DEBUG_INFO(("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 i_id ID of block to retrieve * @param buf reference to pointer to buffer that will contain the data block. * If this pointer is non-NULL, it will first be free()d. * @return Size of block read into memory */ size_t pst_ff_getIDblock_dec(pst_file *pf, uint64_t i_id, char **buf) { size_t r; int noenc = (int)(i_id & 2); // disable encryption DEBUG_ENT("pst_ff_getIDblock_dec"); DEBUG_INFO(("for id %#"PRIx64"\n", i_id)); r = pst_ff_getIDblock(pf, i_id, buf); if ((pf->encryption) && !(noenc)) { (void)pst_decrypt(i_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 structure * @param i_id ID of block to read * @param buf reference to pointer to buffer that will contain the data block. * If this pointer is non-NULL, it will first be free()d. * @return size of block read into memory */ static size_t pst_ff_getIDblock(pst_file *pf, uint64_t i_id, char** buf) { pst_index_ll *rec; size_t rsize; DEBUG_ENT("pst_ff_getIDblock"); rec = pst_getID(pf, i_id); if (!rec) { DEBUG_INFO(("Cannot find ID %#"PRIx64"\n", i_id)); DEBUG_RET(); return 0; } DEBUG_INFO(("id = %#"PRIx64", record size = %#x, offset = %#x\n", i_id, rec->size, rec->offset)); rsize = pst_read_block_size(pf, rec->offset, rec->size, rec->inflated_size, buf); DEBUG_RET(); return rsize; } static size_t pst_ff_getID2block(pst_file *pf, uint64_t id2, pst_id2_tree *id2_head, char** buf) { size_t ret; pst_id2_tree* ptr; pst_holder h = {buf, NULL, 0, 0, 0}; DEBUG_ENT("pst_ff_getID2block"); ptr = pst_getID2(id2_head, id2); if (!ptr) { DEBUG_WARN(("Cannot find id2 value %#"PRIx64"\n", id2)); DEBUG_RET(); return 0; } ret = pst_ff_getID2data(pf, ptr->id, &h); DEBUG_RET(); return ret; } /** find the actual data from an i_id and send it to the destination * specified by the pst_holder h. h must be a new empty destination. * * @param pf PST file structure * @param ptr * @param h specifies the output destination (buffer, file, encoding) * @return updated size of the output */ static size_t pst_ff_getID2data(pst_file *pf, pst_index_ll *ptr, pst_holder *h) { size_t ret; char *b = NULL; DEBUG_ENT("pst_ff_getID2data"); if (!(ptr->i_id & 0x02)) { ret = pst_ff_getIDblock_dec(pf, ptr->i_id, &b); ret = pst_append_holder(h, (size_t)0, &b, ret); free(b); } else { // here we will assume it is an indirection block that points to others DEBUG_INFO(("Assuming it is a multi-block record because of it's id %#"PRIx64"\n", ptr->i_id)); ret = pst_ff_compile_ID(pf, ptr->i_id, h, (size_t)0); } ret = pst_finish_cleanup_holder(h, ret); DEBUG_RET(); return ret; } /** find the actual data from an indirection i_id and send it to the destination * specified by the pst_holder. * * @param pf PST file structure * @param i_id ID of the block to read * @param h specifies the output destination (buffer, file, encoding) * @param size number of bytes of data already sent to h * @return updated size of the output */ static size_t pst_ff_compile_ID(pst_file *pf, uint64_t i_id, pst_holder *h, size_t size) { size_t z, a; uint16_t count, y; char *buf3 = NULL; char *buf2 = NULL; char *b_ptr; 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, i_id, &buf3); if (!a) { if (buf3) free(buf3); DEBUG_RET(); return 0; } DEBUG_HEXDUMPC(buf3, a, 16); memcpy(&block_hdr, buf3, sizeof(block_hdr)); LE16_CPU(block_hdr.index_offset); LE16_CPU(block_hdr.type); LE32_CPU(block_hdr.offset); DEBUG_INFO(("block header (index_offset=%#hx, type=%#hx, offset=%#x)\n", block_hdr.index_offset, block_hdr.type, block_hdr.offset)); count = block_hdr.type; b_ptr = buf3 + 8; // For indirect lookups through a table of i_ids, just recurse back into this // function, letting it concatenate all the data together, and then return the // total size of the data. if (block_hdr.index_offset == (uint16_t)0x0201) { // Indirect lookup (depth 2). for (y=0; yencryption) (void)pst_decrypt(i_id, buf3, a, pf->encryption); size = pst_append_holder(h, size, &buf3, a); free(buf3); DEBUG_RET(); return size; } for (y=0; ybuf) { *(h->buf) = pst_realloc(*(h->buf), size+z+1); DEBUG_INFO(("appending read data of size %i onto main buffer from pos %i\n", z, size)); memcpy(*(h->buf)+size, *buf, z); // base64 encoding to a file } else if ((h->base64 == 1) && h->fp) { // if (h->base64_extra) { // include any bytes left over from the last encoding *buf = (char*)pst_realloc(*buf, z+h->base64_extra); memmove(*buf+h->base64_extra, *buf, z); memcpy(*buf, h->base64_extra_chars, h->base64_extra); z += h->base64_extra; } // find out how many bytes will be left over after this encoding and save them h->base64_extra = z % 3; if (h->base64_extra) { z -= h->base64_extra; memcpy(h->base64_extra_chars, *buf+z, h->base64_extra); } // encode this chunk t = pst_base64_encode_multiple(*buf, z, &h->base64_line_count); if (t) { DEBUG_INFO(("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 } // raw append to a file } else if (h->fp) { DEBUG_INFO(("writing %i bytes to file. Currently %i\n", z, size)); (void)pst_fwrite(*buf, (size_t)1, z, h->fp); // null output } else { // h-> does not specify any output } DEBUG_RET(); return size+z; } /** finish cleanup for base64 encoding to a file with extra bytes left over * * @param h specifies the output destination (buffer, file, encoding) * @param size number of bytes of data already sent to h * @return updated size of the output */ static size_t pst_finish_cleanup_holder(pst_holder *h, size_t size) { char *t; DEBUG_ENT("pst_finish_cleanup_holder"); if ((h->base64 == 1) && h->fp && h->base64_extra) { // need to encode any bytes left over t = pst_base64_encode_multiple(h->base64_extra_chars, h->base64_extra, &h->base64_line_count); if (t) { (void)pst_fwrite(t, (size_t)1, strlen(t), h->fp); free(t); // caught by valgrind } size += h->base64_extra; } DEBUG_RET(); return size; } /** compare strings case-insensitive. * @return -1 if a < b, 0 if a==b, 1 if a > b */ int pst_stricmp(char *a, char *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; } static int pst_strincmp(char *a, char *b, size_t x) { - // compare upto x chars in string a and b case-insensitively + // compare up to 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; if (ptr) r = fwrite(ptr, size, nmemb, stream); else { r = 0; DEBUG_ENT("pst_fwrite"); DEBUG_WARN(("An attempt to write a NULL Pointer was made\n")); DEBUG_RET(); } return r; } static 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 = pst_malloc((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, char **buf, size_t* buflen) { //static char* buf = NULL; //static size_t buflen = 0; char *ret, *a, *b; size_t x = 0; int y, z; if (!str) return NULL; DEBUG_ENT("rfc2426_escape"); // 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*)pst_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; } static 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(const FILETIME* ft, int buflen, char* result) { struct tm stm; DEBUG_ENT("rfc2425_datetime_format"); pst_fileTimeToStructTM(ft, &stm); if (strftime(result, buflen, "%Y-%m-%dT%H:%M:%SZ", &stm)==0) { - DEBUG_INFO(("Problem occured formatting date\n")); + DEBUG_INFO(("Problem occurred formatting date\n")); } DEBUG_RET(); return result; } char* pst_rfc2445_datetime_format(const FILETIME* ft, int buflen, char* result) { struct tm stm; DEBUG_ENT("rfc2445_datetime_format"); pst_fileTimeToStructTM(ft, &stm); if (strftime(result, buflen, "%Y%m%dT%H%M%SZ", &stm)==0) { - DEBUG_INFO(("Problem occured formatting date\n")); + DEBUG_INFO(("Problem occurred formatting date\n")); } DEBUG_RET(); return result; } char* pst_rfc2445_datetime_format_now(int buflen, char* result) { struct tm stm; time_t t = time(NULL); DEBUG_ENT("rfc2445_datetime_format_now"); gmtime_r(&t, &stm); if (strftime(result, buflen, "%Y%m%dT%H%M%SZ", &stm)==0) { - DEBUG_INFO(("Problem occured formatting date\n")); + DEBUG_INFO(("Problem occurred formatting date\n")); } DEBUG_RET(); return result; } /** Convert a code page integer into a string suitable for iconv() * * @param cp the code page integer used in the pst file * @param[in] buflen length of the output buffer * @param[out] result pointer to output buffer, must be at least 30 bytes * @return pointer to a static buffer holding the string representation of the * equivalent iconv character set */ static const char* codepage(int cp, int buflen, char* result); static const char* codepage(int cp, int buflen, char* result) { switch (cp) { case 932 : return "iso-2022-jp"; case 936 : return "gb2313"; case 950 : return "big5"; case 1200 : return "ucs-2le"; case 1201 : return "ucs-2be"; 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(result, buflen, "windows-%d", cp); return result; } return NULL; } /** Get the default character set for this item. This is used to find * the charset for pst_string elements that are not already in utf8 encoding. * * @param item pointer to the mapi item of interest * @param[in] buflen length of the output buffer * @param[out] result pointer to output buffer, must be at least 30 bytes - * @return default character set as a string useable by iconv() + * @return default character set as a string usable by iconv() */ const char* pst_default_charset(pst_item *item, int buflen, char* result) { return (item->body_charset.str) ? item->body_charset.str : (item->message_codepage) ? codepage(item->message_codepage, buflen, result) : (item->internet_cpid) ? codepage(item->internet_cpid, buflen, result) : (item->pf && item->pf->charset) ? item->pf->charset : "iso-8859-1"; } /** Convert str to rfc2231 encoding of str * * @param str pointer to the mapi string of interest */ void pst_rfc2231(pst_string *str) { int needs = 0; const int8_t *x = (int8_t *)str->str; while (*x) { if (*x <= 32) needs++; x++; } int n = strlen(str->str) + 2*needs + 15; char *buffer = pst_malloc(n); strcpy(buffer, "utf-8''"); x = (int8_t *)str->str; const uint8_t *y = (uint8_t *)str->str; uint8_t *z = (uint8_t *)buffer; z += strlen(buffer); // skip the utf8 prefix while (*y) { if (*x <= 32) { *(z++) = (uint8_t)'%'; snprintf(z, 3, "%2x", *y); z += 2; } else { *(z++) = *y; } x++; y++; } *z = '\0'; free(str->str); str->str = buffer; } /** Convert str to rfc2047 encoding of str, possibly enclosed in quotes if it contains spaces * * @param item pointer to the containing mapi item * @param str pointer to the mapi string of interest * @param needs_quote true if strings containing spaces should be wrapped in quotes */ void pst_rfc2047(pst_item *item, pst_string *str, int needs_quote) { int has_space = 0; int needs_coding = 0; pst_convert_utf8(item, str); const int8_t *x = (int8_t *)str->str; while (*x) { if (*x == 32) has_space = 1; if (*x < 32) needs_coding = 1; x++; } if (needs_coding) { char *enc = pst_base64_encode_single(str->str, strlen(str->str)); free(str->str); int n = strlen(enc) + 20; str->str = pst_malloc(n); snprintf(str->str, n, "=?utf-8?B?%s?=", enc); free(enc); } else if (has_space && needs_quote) { int n = strlen(str->str) + 10; char *buffer = pst_malloc(n); snprintf(buffer, n, "\"%s\"", str->str); free(str->str); str->str = buffer; } } /** Convert str to utf8 if possible; null strings are preserved. * * @param item pointer to the containing mapi item * @param str pointer to the mapi string of interest */ 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. * * @param item pointer to the containing mapi item * @param str pointer to the mapi string of interest */ void pst_convert_utf8(pst_item *item, pst_string *str) { DEBUG_ENT("pst_convert_utf8"); char buffer[30]; if (str->is_utf8) { DEBUG_WARN(("Already utf8\n")); DEBUG_RET(); return; } if (!str->str) { str->str = strdup(""); DEBUG_WARN(("null to empty string\n")); DEBUG_RET(); return; } const char *charset = pst_default_charset(item, sizeof(buffer), buffer); DEBUG_WARN(("default charset is %s\n", charset)); if (!strcasecmp("utf-8", charset)) { DEBUG_RET(); return; } pst_vbuf *newer = pst_vballoc(2); size_t rc = pst_vb_8bit2utf8(newer, str->str, strlen(str->str) + 1, charset); if (rc == (size_t)-1) { free(newer->b); DEBUG_WARN(("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(); } /** Decode raw recurrence data into a better structure. * @param appt pointer to appointment structure * @return pointer to decoded recurrence structure that must be free'd by the caller. */ pst_recurrence* pst_convert_recurrence(pst_item_appointment* appt) { const int bias = 30 * 24 * 60; // minutes in 30 days int m[4] = {3,4,4,5}; pst_recurrence *r = pst_malloc(sizeof(pst_recurrence)); memset(r, 0, sizeof(pst_recurrence)); size_t s = appt->recurrence_data.size; size_t i = 0; char* p = appt->recurrence_data.data; if (p) { if (i+4 <= s) { r->signature = PST_LE_GET_UINT32(p+i); i += 4; } if (i <= s) { r->type = PST_LE_GET_UINT8(p+i) - 0x0a; i += 2; } if (i+4 <= s) { r->sub_type = PST_LE_GET_UINT32(p+i); i += 4; } if (r->sub_type <= 3) { int n = m[r->sub_type]; // number of parms for this sub_type int j = 0; for (j=0; jparm1 + j) = PST_LE_GET_UINT32(p+i); i += 4; } } } if (i <= s) { r->termination = PST_LE_GET_UINT8(p+i) - 0x21; i += 4; } if (i+4 <= s) { r->count = PST_LE_GET_UINT32(p+i); i += 4; } if (r->termination == 2) r->count = 0; switch (r->type) { case 0: // daily if (r->sub_type == 0) { // simple daily r->interval = r->parm2 / (24 * 60); // was minutes between recurrences } else { // daily every weekday, subset of weekly r->interval = 1; r->bydaymask = r->parm4; } break; case 1: // weekly r->interval = r->parm2; r->bydaymask = r->parm4; break; case 2: // monthly r->interval = r->parm2; if (r->sub_type == 2) { // monthly on day d r->dayofmonth = r->parm4; } else { // monthly on 2nd tuesday r->bydaymask = r->parm4; r->position = r->parm5; } break; case 3: // yearly r->interval = 1; r->monthofyear = ((r->parm1 + bias/2) / bias) + 1; if (r->sub_type == 2) { // yearly on day d of month m r->dayofmonth = r->parm4; } else { // yearly on 2nd tuesday of month m r->bydaymask = r->parm4; r->position = r->parm5; } break; default: break; } } return r; } /** Free a recurrence structure. * @param r input pointer to be freed */ void pst_free_recurrence(pst_recurrence* r) { if (r) free(r); } diff --git a/src/libpst.h b/src/libpst.h index a5ba83c..b521d31 100644 --- a/src/libpst.h +++ b/src/libpst.h @@ -1,1177 +1,1177 @@ /*** * 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 __PST_LIBPST_H #define __PST_LIBPST_H #include "common.h" #ifdef __cplusplus extern "C" { #endif // 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_SCHEDULE 2 #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 #define PST_TYPE_MAX 15 // 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 #define PST_APP_LABEL_IMPORTANT 1 #define PST_APP_LABEL_BUSINESS 2 #define PST_APP_LABEL_PERSONAL 3 #define PST_APP_LABEL_VACATION 4 #define PST_APP_LABEL_MUST_ATTEND 5 #define PST_APP_LABEL_TRAVEL_REQ 6 #define PST_APP_LABEL_NEEDS_PREP 7 #define PST_APP_LABEL_BIRTHDAY 8 #define PST_APP_LABEL_ANNIVERSARY 9 #define PST_APP_LABEL_PHONE_CALL 10 -// define type of recuring event +// define type of recurring 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 // define attachment types #define PST_ATTACH_NONE 0 #define PST_ATTACH_BY_VALUE 1 #define PST_ATTACH_BY_REF 2 #define PST_ATTACH_BY_REF_RESOLV 3 #define PST_ATTACH_BY_REF_ONLY 4 #define PST_ATTACH_EMBEDDED 5 #define PST_ATTACH_OLE 6 // define flags #define PST_FLAG_READ 0x01 #define PST_FLAG_UNMODIFIED 0x02 #define PST_FLAG_SUBMIT 0x04 #define PST_FLAG_UNSENT 0x08 #define PST_FLAG_HAS_ATTACHMENT 0x10 #define PST_FLAG_FROM_ME 0x20 #define PST_FLAG_ASSOCIATED 0x40 #define PST_FLAG_RESEND 0x80 #define PST_FLAG_RN_PENDING 0x100 #define PST_FLAG_NRN_PENDING 0x200 typedef struct pst_entryid { int32_t u1; char entryid[16]; uint32_t id; } pst_entryid; typedef struct pst_index_ll { uint64_t i_id; uint64_t offset; uint64_t size; uint64_t inflated_size; int64_t u1; } 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_tree; 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_tree; /** The string is either utf8 encoded, or it is in the code page * specified by the containing mapi object. It can be forced into * utf8 by calling pst_convert_utf8() or pst_convert_utf8_null(). */ typedef struct pst_string { /** @li 1 true * @li 0 false */ int is_utf8; char *str; } pst_string; /** a simple wrapper for binary blobs */ typedef struct pst_binary { size_t size; char *data; } pst_binary; /** This contains the email related mapi elements */ typedef struct pst_item_email { /** mapi element 0x0e06 PR_MESSAGE_DELIVERY_TIME */ FILETIME *arrival_date; /** mapi element 0x0002 PR_ALTERNATE_RECIPIENT_ALLOWED * @li 1 true * @li 0 not set * @li -1 false */ int autoforward; /** mapi element 0x0e03 PR_DISPLAY_CC */ pst_string cc_address; /** mapi element 0x0e02 PR_DISPLAY_BCC */ pst_string bcc_address; /** mapi element 0x0071 PR_CONVERSATION_INDEX */ pst_binary conversation_index; /** mapi element 0x3a03 PR_CONVERSION_PROHIBITED * @li 1 true * @li 0 false */ int conversion_prohibited; /** mapi element 0x0e01 PR_DELETE_AFTER_SUBMIT * @li 1 true * @li 0 false */ int delete_after_submit; /** mapi element 0x0023 PR_ORIGINATOR_DELIVERY_REPORT_REQUESTED * @li 1 true * @li 0 false */ int delivery_report; /** mapi element 0x6f04 */ pst_binary encrypted_body; /** mapi element 0x6f02 */ pst_binary encrypted_htmlbody; /** mapi element 0x007d PR_TRANSPORT_MESSAGE_HEADERS */ pst_string header; /** mapi element 0x1013 */ pst_string htmlbody; /** mapi element 0x0017 PR_IMPORTANCE * @li 0 low * @li 1 normal * @li 2 high */ int32_t importance; /** mapi element 0x1042 */ pst_string in_reply_to; /** mapi element 0x0058 PR_MESSAGE_CC_ME, this user is listed explicitly in the CC address * @li 1 true * @li 0 false */ int message_cc_me; /** mapi element 0x0059 PR_MESSAGE_RECIP_ME, this user appears in TO, CC or BCC address list * @li 1 true * @li 0 false */ int message_recip_me; /** mapi element 0x0057 PR_MESSAGE_TO_ME, this user is listed explicitly in the TO address * @li 1 true * @li 0 false */ int message_to_me; /** mapi element 0x1035 */ pst_string messageid; /** mapi element 0x002e PR_ORIGINAL_SENSITIVITY * @li 0=none * @li 1=personal * @li 2=private * @li 3=company confidential */ int32_t original_sensitivity; /** mapi element 0x0072 PR_ORIGINAL_DISPLAY_BCC */ pst_string original_bcc; /** mapi element 0x0073 PR_ORIGINAL_DISPLAY_CC */ pst_string original_cc; /** mapi element 0x0074 PR_ORIGINAL_DISPLAY_TO */ pst_string original_to; /** mapi element 0x0051 PR_RECEIVED_BY_SEARCH_KEY */ pst_string outlook_recipient; /** mapi element 0x0044 PR_RCVD_REPRESENTING_NAME */ pst_string outlook_recipient_name; /** mapi element 0x0052 PR_RCVD_REPRESENTING_SEARCH_KEY */ pst_string outlook_recipient2; /** mapi element 0x003b PR_SENT_REPRESENTING_SEARCH_KEY */ pst_string outlook_sender; /** mapi element 0x0042 PR_SENT_REPRESENTING_NAME */ pst_string outlook_sender_name; /** mapi element 0x0c1d PR_SENDER_SEARCH_KEY */ pst_string outlook_sender2; /** mapi element 0x0026 PR_PRIORITY * @li 0 nonurgent * @li 1 normal * @li 2 urgent */ /** mapi element */ int32_t priority; /** mapi element 0x0070 PR_CONVERSATION_TOPIC */ pst_string processed_subject; /** mapi element 0x0029 PR_READ_RECEIPT_REQUESTED * @li 1 true * @li 0 false */ int read_receipt; /** mapi element 0x0075 PR_RECEIVED_BY_ADDRTYPE */ pst_string recip_access; /** mapi element 0x0076 PR_RECEIVED_BY_EMAIL_ADDRESS */ pst_string recip_address; /** mapi element 0x0077 PR_RCVD_REPRESENTING_ADDRTYPE */ pst_string recip2_access; /** mapi element 0x0078 PR_RCVD_REPRESENTING_EMAIL_ADDRESS */ pst_string recip2_address; /** mapi element 0x0c17 PR_REPLY_REQUESTED * @li 1 true * @li 0 false */ int reply_requested; /** mapi element 0x0050 PR_REPLY_RECIPIENT_NAMES */ pst_string reply_to; /** mapi element 0x1046, this seems to be the message-id of the rfc822 mail that is being returned */ pst_string return_path_address; /** mapi element 0x1007 PR_RTF_SYNC_BODY_COUNT, - * a count of the *significant* charcters in the rtf body. Doesn't count + * a count of the *significant* characters in the rtf body. Doesn't count * whitespace and other ignorable characters. */ int32_t rtf_body_char_count; /** mapi element 0x1006 PR_RTF_SYNC_BODY_CRC */ int32_t rtf_body_crc; /** mapi element 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. */ pst_string rtf_body_tag; /** mapi element 0x1009 PR_RTF_COMPRESSED, * the compressed rtf body data. * Use pst_lzfu_decompress() to retrieve the actual rtf body data. */ pst_binary rtf_compressed; /** mapi element 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. * @li 1 true * @li 0 false */ int rtf_in_sync; /** mapi element 0x1010 PR_RTF_SYNC_PREFIX_COUNT, * a count of the ignored characters before the first significant character */ int32_t rtf_ws_prefix_count; /** mapi element 0x1011 PR_RTF_SYNC_TRAILING_COUNT, * a count of the ignored characters after the last significant character */ int32_t rtf_ws_trailing_count; /** mapi element 0x0064 PR_SENT_REPRESENTING_ADDRTYPE */ pst_string sender_access; /** mapi element 0x0065 PR_SENT_REPRESENTING_EMAIL_ADDRESS */ pst_string sender_address; /** mapi element 0x0c1e PR_SENDER_ADDRTYPE */ pst_string sender2_access; /** mapi element 0x0c1f PR_SENDER_EMAIL_ADDRESS */ pst_string sender2_address; /** mapi element 0x0036 PR_SENSITIVITY * @li 0=none * @li 1=personal * @li 2=private * @li 3=company confidential */ int32_t sensitivity; /** mapi element 0x0039 PR_CLIENT_SUBMIT_TIME */ FILETIME *sent_date; /** mapi element 0x0e0a PR_SENTMAIL_ENTRYID */ pst_entryid *sentmail_folder; /** mapi element 0x0e04 PR_DISPLAY_TO */ pst_string sentto_address; /** mapi element 0x1001 PR_REPORT_TEXT, delivery report dsn body */ pst_string report_text; /** mapi element 0x0032 PR_REPORT_TIME, delivery report time */ FILETIME *report_time; /** mapi element 0x0c04 PR_NDR_REASON_CODE */ int32_t ndr_reason_code; /** mapi element 0x0c05 PR_NDR_DIAG_CODE */ int32_t ndr_diag_code; /** mapi element 0x0c1b PR_SUPPLEMENTARY_INFO */ pst_string supplementary_info; /** mapi element 0x0c20 PR_NDR_STATUS_CODE */ int32_t ndr_status_code; // elements added for .msg processing /** mapi element 0x0040 PR_RECEIVED_BY_NAME */ pst_string outlook_received_name1; /** mapi element 0x0c1a PR_SENDER_NAME */ pst_string outlook_sender_name2; /** mapi element 0x0e1d PR_NORMALIZED_SUBJECT */ pst_string outlook_normalized_subject; /** mapi element 0x300b PR_SEARCH_KEY */ pst_string outlook_search_key; } pst_item_email; /** This contains the folder related mapi elements */ typedef struct pst_item_folder { /** mapi element 0x3602 PR_CONTENT_COUNT */ int32_t item_count; /** mapi element 0x3603 PR_CONTENT_UNREAD */ int32_t unseen_item_count; /** mapi element 0x3617 PR_ASSOC_CONTENT_COUNT Associated content are items that are attached to this folder, but are hidden from users. */ int32_t assoc_count; /** mapi element 0x360a PR_SUBFOLDERS * @li 1 true * @li 0 false */ /** mapi element */ int subfolder; } pst_item_folder; /** This contains the message store related mapi elements */ typedef struct pst_item_message_store { /** mapi element 0x35e0 */ pst_entryid *top_of_personal_folder; /** mapi element 0x35e2 */ pst_entryid *default_outbox_folder; /** mapi element 0x35e3 */ pst_entryid *deleted_items_folder; /** mapi element 0x35e4 */ pst_entryid *sent_items_folder; /** mapi element 0x35e5 */ pst_entryid *user_views_folder; /** mapi element 0x35e6 */ pst_entryid *common_view_folder; /** mapi element 0x35e7 */ pst_entryid *search_root_folder; /** mapi element 0x7c07 */ pst_entryid *top_of_folder; /** mapi element 0x35df, * bit mask of folders in this message store * @li 0x1 FOLDER_IPM_SUBTREE_VALID * @li 0x2 FOLDER_IPM_INBOX_VALID * @li 0x4 FOLDER_IPM_OUTBOX_VALID * @li 0x8 FOLDER_IPM_WASTEBOX_VALID * @li 0x10 FOLDER_IPM_SENTMAIL_VALID * @li 0x20 FOLDER_VIEWS_VALID * @li 0x40 FOLDER_COMMON_VIEWS_VALID * @li 0x80 FOLDER_FINDER_VALID */ int32_t valid_mask; /** mapi element 0x76ff */ int32_t pwd_chksum; } pst_item_message_store; /** This contains the contact related mapi elements */ typedef struct pst_item_contact { /** mapi element 0x3a00 PR_ACCOUNT */ pst_string account_name; /** mapi element 0x3003 PR_EMAIL_ADDRESS, or 0x8083 */ pst_string address1; /** mapi element 0x8085 */ pst_string address1a; /** mapi element 0x8084 */ pst_string address1_desc; /** mapi element 0x3002 PR_ADDRTYPE, or 0x8082 */ pst_string address1_transport; /** mapi element 0x8093 */ pst_string address2; /** mapi element 0x8095 */ pst_string address2a; /** mapi element 0x8094 */ pst_string address2_desc; /** mapi element 0x8092 */ pst_string address2_transport; /** mapi element 0x80a3 */ pst_string address3; /** mapi element 0x80a5 */ pst_string address3a; /** mapi element 0x80a4 */ pst_string address3_desc; /** mapi element 0x80a2 */ pst_string address3_transport; /** mapi element 0x3a30 PR_ASSISTANT */ pst_string assistant_name; /** mapi element 0x3a2e PR_ASSISTANT_TELEPHONE_NUMBER */ pst_string assistant_phone; /** mapi element 0x8535 */ pst_string billing_information; /** mapi element 0x3a42 PR_BIRTHDAY */ FILETIME *birthday; /** mapi element 0x801b */ pst_string business_address; /** mapi element 0x3a27 PR_BUSINESS_ADDRESS_CITY */ pst_string business_city; /** mapi element 0x3a26 PR_BUSINESS_ADDRESS_COUNTRY */ pst_string business_country; /** mapi element 0x3a24 PR_BUSINESS_FAX_NUMBER */ pst_string business_fax; /** mapi element 0x3a51 PR_BUSINESS_HOME_PAGE */ pst_string business_homepage; /** mapi element 0x3a08 PR_BUSINESS_TELEPHONE_NUMBER */ pst_string business_phone; /** mapi element 0x3a1b PR_BUSINESS2_TELEPHONE_NUMBER */ pst_string business_phone2; /** mapi element 0x3a2b PR_BUSINESS_PO_BOX */ pst_string business_po_box; /** mapi element 0x3a2a PR_BUSINESS_POSTAL_CODE */ pst_string business_postal_code; /** mapi element 0x3a28 PR_BUSINESS_ADDRESS_STATE_OR_PROVINCE */ pst_string business_state; /** mapi element 0x3a29 PR_BUSINESS_ADDRESS_STREET */ pst_string business_street; /** mapi element 0x3a02 PR_CALLBACK_TELEPHONE_NUMBER */ pst_string callback_phone; /** mapi element 0x3a1e PR_CAR_TELEPHONE_NUMBER */ pst_string car_phone; /** mapi element 0x3a57 PR_COMPANY_MAIN_PHONE_NUMBER */ pst_string company_main_phone; /** mapi element 0x3a16 PR_COMPANY_NAME */ pst_string company_name; /** mapi element 0x3a49 PR_COMPUTER_NETWORK_NAME */ pst_string computer_name; /** mapi element 0x3a4a PR_CUSTOMER_ID */ pst_string customer_id; /** mapi element 0x3a15 PR_POSTAL_ADDRESS */ pst_string def_postal_address; /** mapi element 0x3a18 PR_DEPARTMENT_NAME */ pst_string department; /** mapi element 0x3a45 PR_DISPLAY_NAME_PREFIX */ pst_string display_name_prefix; /** mapi element 0x3a06 PR_GIVEN_NAME */ pst_string first_name; /** mapi element 0x8530 */ pst_string followup; /** mapi element 0x80d8 */ pst_string free_busy_address; /** mapi element 0x3a4c PR_FTP_SITE */ pst_string ftp_site; /** mapi element 0x8005 */ pst_string fullname; /** mapi element 0x3a4d PR_GENDER * @li 0 unspecified * @li 1 female * @li 2 male */ int16_t gender; /** mapi element 0x3a07 PR_GOVERNMENT_ID_NUMBER */ pst_string gov_id; /** mapi element 0x3a43 PR_HOBBIES */ pst_string hobbies; /** mapi element 0x801a */ pst_string home_address; /** mapi element 0x3a59 PR_HOME_ADDRESS_CITY */ pst_string home_city; /** mapi element 0x3a5a PR_HOME_ADDRESS_COUNTRY */ pst_string home_country; /** mapi element 0x3a25 PR_HOME_FAX_NUMBER */ pst_string home_fax; /** mapi element 0x3a09 PR_HOME_TELEPHONE_NUMBER */ pst_string home_phone; /** mapi element 0x3a2f PR_HOME2_TELEPHONE_NUMBER */ pst_string home_phone2; /** mapi element 0x3a5e PR_HOME_ADDRESS_POST_OFFICE_BOX */ pst_string home_po_box; /** mapi element 0x3a5b PR_HOME_ADDRESS_POSTAL_CODE */ pst_string home_postal_code; /** mapi element 0x3a5c PR_HOME_ADDRESS_STATE_OR_PROVINCE */ pst_string home_state; /** mapi element 0x3a5d PR_HOME_ADDRESS_STREET */ pst_string home_street; /** mapi element 0x3a0a PR_INITIALS */ pst_string initials; /** mapi element 0x3a2d PR_ISDN_NUMBER */ pst_string isdn_phone; /** mapi element 0x3a17 PR_TITLE */ pst_string job_title; /** mapi element 0x3a0b PR_KEYWORD */ pst_string keyword; /** mapi element 0x3a0c PR_LANGUAGE */ pst_string language; /** mapi element 0x3a0d PR_LOCATION */ pst_string location; /** mapi element 0x3a0e PR_MAIL_PERMISSION * @li 1 true * @li 0 false */ int mail_permission; /** mapi element 0x3a4e PR_MANAGER_NAME */ pst_string manager_name; /** mapi element 0x3a44 PR_MIDDLE_NAME */ pst_string middle_name; /** mapi element 0x8534 */ pst_string mileage; /** mapi element 0x3a1c PR_MOBILE_TELEPHONE_NUMBER */ pst_string mobile_phone; /** mapi element 0x3a4f PR_NICKNAME */ pst_string nickname; /** mapi element 0x3a19 PR_OFFICE_LOCATION */ pst_string office_loc; /** mapi element 0x3a0f PR_MHS_COMMON_NAME */ pst_string common_name; /** mapi element 0x3a10 PR_ORGANIZATIONAL_ID_NUMBER */ pst_string org_id; /** mapi element 0x801c */ pst_string other_address; /** mapi element 0x3a5f PR_OTHER_ADDRESS_CITY */ pst_string other_city; /** mapi element 0x3a60 PR_OTHER_ADDRESS_COUNTRY */ pst_string other_country; /** mapi element 0x3a1f PR_OTHER_TELEPHONE_NUMBER */ pst_string other_phone; /** mapi element 0x3a64 PR_OTHER_ADDRESS_POST_OFFICE_BOX */ pst_string other_po_box; /** mapi element 0x3a61 PR_OTHER_ADDRESS_POSTAL_CODE */ pst_string other_postal_code; /** mapi element 0x3a62 PR_OTHER_ADDRESS_STATE_OR_PROVINCE */ pst_string other_state; /** mapi element 0x3a63 PR_OTHER_ADDRESS_STREET */ pst_string other_street; /** mapi element 0x3a21 PR_PAGER_TELEPHONE_NUMBER */ pst_string pager_phone; /** mapi element 0x3a50 PR_PERSONAL_HOME_PAGE */ pst_string personal_homepage; /** mapi element 0x3a47 PR_PREFERRED_BY_NAME */ pst_string pref_name; /** mapi element 0x3a23 PR_PRIMARY_FAX_NUMBER */ pst_string primary_fax; /** mapi element 0x3a1a PR_PRIMARY_TELEPHONE_NUMBER */ pst_string primary_phone; /** mapi element 0x3a46 PR_PROFESSION */ pst_string profession; /** mapi element 0x3a1d PR_RADIO_TELEPHONE_NUMBER */ pst_string radio_phone; /** mapi element 0x3a40 PR_SEND_RICH_INFO * @li 1 true * @li 0 false */ int rich_text; /** mapi element 0x3a48 PR_SPOUSE_NAME */ pst_string spouse_name; /** mapi element 0x3a05 PR_GENERATION (Jr., Sr., III, etc) */ pst_string suffix; /** mapi element 0x3a11 PR_SURNAME */ pst_string surname; /** mapi element 0x3a2c PR_TELEX_NUMBER */ pst_string telex; /** mapi element 0x3a20 PR_TRANSMITTABLE_DISPLAY_NAME */ pst_string transmittable_display_name; /** mapi element 0x3a4b PR_TTYTDD_PHONE_NUMBER */ pst_string ttytdd_phone; /** mapi element 0x3a41 PR_WEDDING_ANNIVERSARY */ FILETIME *wedding_anniversary; /** mapi element 0x8045 */ pst_string work_address_street; /** mapi element 0x8046 */ pst_string work_address_city; /** mapi element 0x8047 */ pst_string work_address_state; /** mapi element 0x8048 */ pst_string work_address_postalcode; /** mapi element 0x8049 */ pst_string work_address_country; /** mapi element 0x804a */ pst_string work_address_postofficebox; } pst_item_contact; /** This contains the attachment related mapi elements */ typedef struct pst_item_attach { /** mapi element 0x3704 PR_ATTACH_FILENAME */ pst_string filename1; /** mapi element 0x3707 PR_ATTACH_LONG_FILENAME */ pst_string filename2; /** mapi element 0x370e PR_ATTACH_MIME_TAG */ pst_string mimetype; /** mapi element 0x3712 PR_ATTACH_CONTENT_ID */ pst_string content_id; /** mapi element 0x3701 PR_ATTACH_DATA_OBJ */ pst_binary data; /** only used if the attachment is by reference, in which case this is the id2 reference */ uint64_t id2_val; /** calculated from id2_val during creation of record */ uint64_t i_id; /** id2 tree needed to resolve attachments by reference */ pst_id2_tree *id2_head; /** mapi element 0x3705 PR_ATTACH_METHOD * @li 0 no attachment * @li 1 attach by value * @li 2 attach by reference * @li 3 attach by reference resolve * @li 4 attach by reference only * @li 5 embedded message * @li 6 OLE */ int32_t method; /** mapi element 0x370b PR_RENDERING_POSITION */ int32_t position; /** mapi element 0x3710 PR_ATTACH_MIME_SEQUENCE */ int32_t sequence; struct pst_item_attach *next; } pst_item_attach; /** linked list of extra header fields */ typedef struct pst_item_extra_field { char *field_name; char *value; struct pst_item_extra_field *next; } pst_item_extra_field; /** This contains the journal related mapi elements */ typedef struct pst_item_journal { /** mapi element 0x8706 */ FILETIME *start; /** mapi element 0x8708 */ FILETIME *end; /** mapi element 0x8700 */ pst_string type; /** mapi element 0x8712 */ pst_string description; } pst_item_journal; /** This contains the recurrence data separated into fields. http://www.geocities.com/cainrandom/dev/MAPIRecurrence.html */ typedef struct pst_recurrence { /** 0x30043004 */ uint32_t signature; /** @li 0 daily * @li 1 weekly * @li 2 monthly * @li 3 yearly */ uint32_t type; /** implies number of recurrence parameters * @li 0 has 3 parameters * @li 1 has 4 parameters * @li 2 has 4 parameters * @li 3 has 5 parameters */ uint32_t sub_type; - /** must be contiguous, not an array to make python interface easier */ + /** must be contiguous, not an array to make Python interface easier */ uint32_t parm1; uint32_t parm2; uint32_t parm3; uint32_t parm4; uint32_t parm5; /** type of termination of the recurrence @li 0 terminates on a date @li 1 terminates based on integer number of occurrences @li 2 never terminates */ uint32_t termination; /** recurrence interval in terms of the recurrence type */ uint32_t interval; /** bit mask of days of the week */ uint32_t bydaymask; /** day of month for monthly and yearly recurrences */ uint32_t dayofmonth; /** month of year for yearly recurrences */ uint32_t monthofyear; - /** occurence of day for 2nd Tuesday of month, in which case position is 2 */ + /** occurrence of day for 2nd Tuesday of month, in which case position is 2 */ uint32_t position; /** number of occurrences, even if recurrence terminates based on date */ uint32_t count; // there is more data, including the termination date, // but we can get that from other mapi elements. } pst_recurrence; /** This contains the appointment related mapi elements */ typedef struct pst_item_appointment { /** mapi element 0x820d PR_OUTLOOK_EVENT_START_DATE */ FILETIME *start; /** mapi element 0x820e PR_OUTLOOK_EVENT_START_END */ FILETIME *end; /** mapi element 0x8208 PR_OUTLOOK_EVENT_LOCATION */ pst_string location; /** mapi element 0x8503 PR_OUTLOOK_COMMON_REMINDER_SET * @li 1 true * @li 0 false */ int alarm; /** mapi element 0x8560 */ FILETIME *reminder; /** mapi element 0x8501 PR_OUTLOOK_COMMON_REMINDER_MINUTES_BEFORE */ int32_t alarm_minutes; /** mapi element 0x851f */ pst_string alarm_filename; /** mapi element 0x8234 */ pst_string timezonestring; /** mapi element 0x8205 PR_OUTLOOK_EVENT_SHOW_TIME_AS * @li 0 free * @li 1 tentative * @li 2 busy * @li 3 out of office*/ int32_t showas; /** mapi element 0x8214 * @li 0 None * @li 1 Important * @li 2 Business * @li 3 Personal * @li 4 Vacation * @li 5 Must Attend * @li 6 Travel Required * @li 7 Needs Preparation * @li 8 Birthday * @li 9 Anniversary * @li 10 Phone Call */ int32_t label; /** mapi element 0x8215 PR_OUTLOOK_EVENT_ALL_DAY * @li 1 true * @li 0 false */ int all_day; /** mapi element 0x8223 PR_OUTLOOK_EVENT_IS_RECURRING * @li 1 true * @li 0 false */ int is_recurring; /** mapi element 0x8231 * @li 0 none * @li 1 daily * @li 2 weekly * @li 3 monthly * @li 4 yearly */ int32_t recurrence_type; /** mapi element 0x8232 recurrence description */ pst_string recurrence_description; /** mapi element 0x8216 recurrence data */ pst_binary recurrence_data; /** mapi element 0x8235 PR_OUTLOOK_EVENT_RECURRENCE_START */ FILETIME *recurrence_start; /** mapi element 0x8236 PR_OUTLOOK_EVENT_RECURRENCE_END */ FILETIME *recurrence_end; } pst_item_appointment; /** This contains the common mapi elements, and pointers to structures for * each major mapi item type. It represents a complete mapi object. */ typedef struct pst_item { /** pointer to the pst_file */ struct pst_file *pf; /** block id that can be used to generate uid */ uint64_t block_id; /** email mapi elements */ pst_item_email *email; /** folder mapi elements */ pst_item_folder *folder; /** contact mapi elements */ pst_item_contact *contact; /** linked list of attachments */ pst_item_attach *attach; /** message store mapi elements */ pst_item_message_store *message_store; /** linked list of extra headers and such */ pst_item_extra_field *extra_fields; /** journal mapi elements */ pst_item_journal *journal; /** calendar mapi elements */ pst_item_appointment *appointment; /** derived from mapi elements 0x001a PR_MESSAGE_CLASS or 0x3613 PR_CONTAINER_CLASS * @li 1 PST_TYPE_NOTE * @li 2 PST_TYPE_SCHEDULE * @li 8 PST_TYPE_APPOINTMENT * @li 9 PST_TYPE_CONTACT * @li 10 PST_TYPE_JOURNAL * @li 11 PST_TYPE_STICKYNOTE * @li 12 PST_TYPE_TASK * @li 13 PST_TYPE_OTHER * @li 14 PST_TYPE_REPORT */ int type; /** mapi element 0x001a PR_MESSAGE_CLASS or 0x3613 PR_CONTAINER_CLASS */ char *ascii_type; /** mapi element 0x0e07 PR_MESSAGE_FLAGS * @li 0x01 Read * @li 0x02 Unmodified * @li 0x04 Submit * @li 0x08 Unsent * @li 0x10 Has Attachments * @li 0x20 From Me * @li 0x40 Associated * @li 0x80 Resend * @li 0x100 RN Pending * @li 0x200 NRN Pending */ int32_t flags; /** mapi element 0x3001 PR_DISPLAY_NAME */ pst_string file_as; /** mapi element 0x3004 PR_COMMENT */ pst_string comment; /** derived from extra_fields["content-type"] if it contains a charset= subfield */ pst_string body_charset; /** mapi element 0x1000 PR_BODY */ pst_string body; /** mapi element 0x0037 PR_SUBJECT */ pst_string subject; /** mapi element 0x3fde PR_INTERNET_CPID */ int32_t internet_cpid; /** mapi element 0x3ffd PR_MESSAGE_CODEPAGE */ int32_t message_codepage; /** mapi element 0x0e08 PR_MESSAGE_SIZE */ int32_t message_size; /** mapi element 0x8554 PR_OUTLOOK_VERSION */ pst_string outlook_version; /** mapi element 0x0ff9 PR_RECORD_KEY */ pst_binary record_key; /** mapi element 0x65e3 PR_PREDECESSOR_CHANGE_LIST */ pst_binary predecessor_change; /** mapi element 0x0063 PR_RESPONSE_REQUESTED * @li 1 true * @li 0 false */ int response_requested; /** mapi element 0x3007 PR_CREATION_TIME */ FILETIME *create_date; /** mapi element 0x3008 PR_LAST_MODIFICATION_TIME */ FILETIME *modify_date; /** mapi element 0x002b PR_RECIPIENT_REASSIGNMENT_PROHIBITED * @li 1 true * @li 0 false */ int private_member; } pst_item; /** Linked list of extended attributes. * This is used to convert mapi_id values in the pst file into - * cannonical mapi_id values to be used in this code. This list + * canonical mapi_id values to be used in this code. This list * is kept in sorted order, where the key is the 'map' field. - * Some mapi_id values are converted to cannonical mapi_id values + * Some mapi_id values are converted to canonical mapi_id values * (PST_MAP_ATTRIB), and others are converted to a string * (PST_ATTRIB_HEADER). */ typedef struct pst_x_attrib_ll { /** @li 1 PST_MAP_ATTRIB map->int attribute @li 2 PST_MAP_HEADER map->string header */ uint32_t mytype; /** key for the mapping */ uint32_t map; /** data target of the mapping, either uint32_t or string */ void *data; /** link to next item in the list */ struct pst_x_attrib_ll *next; } pst_x_attrib_ll; /** this is only used for internal debugging */ 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 { /** file pointer to opened PST file */ FILE* fp; /** original cwd when the file was opened */ char* cwd; /** original file name when the file was opened */ char* fname; /** default character set for items without one */ const char* charset; /** the array of index structures */ pst_index_ll *i_table; size_t i_count, i_capacity; /** the head and tail of the top level of the descriptor tree */ pst_desc_tree *d_head, *d_tail; /** the head of the extended attributes linked list */ pst_x_attrib_ll *x_head; /** the head of the block recorder, a debug artifact * used to detect cases where we might read the same * block multiple times while processing a pst file. */ pst_block_recorder *block_head; /** @li 0 is 32-bit pst file, pre Outlook 2003; * @li 1 is 64-bit pst file, Outlook 2003 or later; * @li 2 is 64-bit OST file, Outlook 2013 or later */ int do_read64; /** file offset of the first b-tree node in the index tree */ uint64_t index1; /** back pointer value in the first b-tree node in the index tree */ uint64_t index1_back; /** file offset of the first b-tree node in the descriptor tree*/ uint64_t index2; /** back pointer value in the first b-tree node in the descriptor tree */ uint64_t index2_back; /** size of the pst file */ uint64_t size; /** @li 0 PST_NO_ENCRYPT, none * @li 1 PST_COMP_ENCRYPT, simple byte substitution cipher with fixed key - * @li 2 PST_ENCRYPT, german enigma 3 rotor cipher with fixed key */ + * @li 2 PST_ENCRYPT, German enigma 3 rotor cipher with fixed key */ unsigned char encryption; /** index type or file type * @li 0x0e 32 bit pre Outlook 2003 * @li 0x0f 32 bit pre Outlook 2003 * @li 0x15 64 bit Outlook 2003 or later * @li 0x17 64 bit Outlook 2003 or later */ unsigned char ind_type; } pst_file; /** Open a pst file. * @param pf pointer to uninitialized pst_file structure. This structure * will be filled in by this function. * @param name name of the file, suitable for fopen(). * @param charset default charset for item with unspecified character sets * @return 0 if ok, -1 if error */ int pst_open(pst_file *pf, const char *name, const char *charset); /** Reopen the pst file after a fork * @param pf pointer to the pst_file structure setup by pst_open(). * @return 0 if ok, -1 if error */ int pst_reopen(pst_file *pf); /** Load the index entries from the pst file. This loads both the * i_id linked list, and the d_id tree, and should normally be the * first call after pst_open(). * @param pf pointer to the pst_file structure setup by pst_open(). */ int pst_load_index (pst_file *pf); /** Load the extended attribute mapping table from the pst file. This * should normally be the second call after pst_open(). * @param pf pointer to the pst_file structure setup by pst_open(). */ int pst_load_extended_attributes(pst_file *pf); /** Close a pst file. * @param pf pointer to the pst_file structure setup by pst_open(). */ int pst_close(pst_file *pf); /** Get the top of folders descriptor tree. This is the main descriptor tree * that needs to be walked to look at every item in the pst file. * @param pf pointer to the pst_file structure setup by pst_open(). * @param root root item, which can be obtained by pst_parse_item(pf, pf->d_head, NULL). */ pst_desc_tree* pst_getTopOfFolders(pst_file *pf, const pst_item *root); /** Assemble the binary attachment into a single buffer. * @param pf pointer to the pst_file structure setup by pst_open(). * @param attach pointer to the attachment record * @return structure containing size of and pointer to the buffer. * the caller must free this buffer. */ pst_binary pst_attach_to_mem(pst_file *pf, pst_item_attach *attach); /** Write a binary attachment to a file. * @param pf pointer to the pst_file structure setup by pst_open(). * @param attach pointer to the attachment record * @param fp pointer to an open FILE. */ size_t pst_attach_to_file(pst_file *pf, pst_item_attach *attach, FILE* fp); /** Write a binary attachment base64 encoded to a file. * @param pf pointer to the pst_file structure setup by pst_open(). * @param attach pointer to the attachment record * @param fp pointer to an open FILE. */ size_t pst_attach_to_file_base64(pst_file *pf, pst_item_attach *attach, FILE* fp); /** Walk the descriptor tree. * @param d pointer to the current item in the descriptor tree. * @return pointer to the next item in the descriptor tree. */ pst_desc_tree* pst_getNextDptr(pst_desc_tree* d); /** Assemble a mapi object from a descriptor pointer. * @param pf pointer to the pst_file structure setup by pst_open(). * @param d_ptr pointer to an item in the descriptor tree. * @param m_head normally NULL. This is only used when processing embedded * attached rfc822 messages, in which case it is attach->id2_head. * @return pointer to the mapi object. Must be free'd by pst_freeItem(). */ pst_item* pst_parse_item (pst_file *pf, pst_desc_tree *d_ptr, pst_id2_tree *m_head); /** Free the item returned by pst_parse_item(). * @param item pointer to item returned from pst_parse_item(). */ void pst_freeItem(pst_item *item); /** Lookup the i_id in the index linked list, and return a pointer to the element. * @param pf pointer to the pst_file structure setup by pst_open(). * @param i_id key for the index linked list * @return pointer to the element, or NULL if not found. */ pst_index_ll* pst_getID(pst_file* pf, uint64_t i_id); /** Get an ID block from the file using pst_ff_getIDblock() and decrypt if necessary. * @param pf pointer to the pst_file structure setup by pst_open(). * @param i_id ID of block to retrieve * @param buf reference to pointer to buffer that will contain the data block. * If this pointer is non-NULL, it will first be free()d. * @return Size of block read into memory */ size_t pst_ff_getIDblock_dec(pst_file *pf, uint64_t i_id, char **buf); /** compare strings case-insensitive. * @return -1 if a < b, 0 if a==b, 1 if a > b */ int pst_stricmp(char *a, char *b); /** fwrite with checking for null pointer. * @param ptr pointer to the buffer * @param size size of each item * @param nmemb number of items * @param stream output file * @return number of bytes written, zero if ptr==NULL */ size_t pst_fwrite(const void* ptr, size_t size, size_t nmemb, FILE* stream); /** Add any necessary escape characters for rfc2426 vcard format * @param[in] str pointer to input string * @param[in,out] result pointer to a char* pointer that may be realloc'ed if needed * @param[in,out] resultlen size of the result buffer * @return pointer to output string, either the input pointer if * there are no characters that need escapes, or a pointer * to a possibly realloc'ed result buffer. */ char* pst_rfc2426_escape(char* str, char** result, size_t* resultlen); /** Convert a FILETIME into rfc2425 date/time format 1953-10-15T23:10:00Z * which is the same as one of the forms in the ISO3601 standard * @param[in] ft time to be converted * @param[in] buflen length of the output buffer * @param[out] result pointer to output buffer, must be at least 30 bytes * @return time in rfc2425 format */ char* pst_rfc2425_datetime_format(const FILETIME* ft, int buflen, char* result); /** Convert a FILETIME into rfc2445 date/time format 19531015T231000Z * @param[in] ft time to be converted * @param[in] buflen length of the output buffer * @param[out] result pointer to output buffer, must be at least 30 bytes * @return time in rfc2445 format */ char* pst_rfc2445_datetime_format(const FILETIME* ft, int buflen, char* result); /** Convert the current time rfc2445 date/time format 19531015T231000Z * @param[in] buflen length of the output buffer * @param[out] result pointer to output buffer, must be at least 30 bytes * @return time in rfc2445 format */ char* pst_rfc2445_datetime_format_now(int buflen, char* result); /** Get the default character set for this item. This is used to find * the charset for pst_string elements that are not already in utf8 encoding. * @param item pointer to the mapi item of interest * @param[in] buflen length of the output buffer * @param[out] result pointer to output buffer, must be at least 30 bytes - * @return default character set as a string useable by iconv() + * @return default character set as a string usable by iconv() */ const char* pst_default_charset(pst_item *item, int buflen, char* result); /** Convert str to rfc2231 encoding of str * @param str pointer to the mapi string of interest */ void pst_rfc2231(pst_string *str); /** Convert str to rfc2047 encoding of str, possibly enclosed in quotes if it contains spaces * @param item pointer to the containing mapi item * @param str pointer to the mapi string of interest * @param needs_quote true if strings containing spaces should be wrapped in quotes */ void pst_rfc2047(pst_item *item, pst_string *str, int needs_quote); /** Convert str to utf8 if possible; null strings are preserved. * @param item pointer to the containing mapi item * @param str pointer to the mapi string of interest */ void pst_convert_utf8_null(pst_item *item, pst_string *str); /** Convert str to utf8 if possible; null strings are converted into empty strings. * @param item pointer to the containing mapi item * @param str pointer to the mapi string of interest */ void pst_convert_utf8(pst_item *item, pst_string *str); /** Decode raw recurrence data into a better structure. * @param appt pointer to appointment structure * @return pointer to decoded recurrence structure that must be free'd by the caller. */ pst_recurrence* pst_convert_recurrence(pst_item_appointment* appt); /** Free a recurrence structure. * @param r input pointer to be freed */ void pst_free_recurrence(pst_recurrence* r); // 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 #ifdef __cplusplus } #endif #endif diff --git a/src/lspst.c b/src/lspst.c index f2886de..5175595 100644 --- a/src/lspst.c +++ b/src/lspst.c @@ -1,312 +1,312 @@ /*** * lspst.c * Part of the LibPST project * Author: Joe Nahmias - * Based on readpst.c by by David Smith + * Based on readpst.c by David Smith * */ #include "define.h" struct file_ll { char *dname; int32_t stored_count; int32_t item_count; int32_t skip_count; int32_t type; }; struct options { int long_format; char *date_format; }; void canonicalize_filename(char *fname); void debug_print(char *fmt, ...); void usage(char *prog_name); void version(); // global settings pst_file pstfile; void create_enter_dir(struct file_ll* f, pst_item *item) { pst_convert_utf8(item, &item->file_as); f->item_count = 0; f->skip_count = 0; f->type = item->type; f->stored_count = (item->folder) ? item->folder->item_count : 0; f->dname = strdup(item->file_as.str); } void close_enter_dir(struct file_ll *f) { free(f->dname); } void process(pst_item *outeritem, pst_desc_tree *d_ptr, struct options o) { struct file_ll ff; pst_item *item = NULL; char *result = NULL; size_t resultlen = 0; size_t dateresultlen; DEBUG_ENT("process"); memset(&ff, 0, sizeof(ff)); create_enter_dir(&ff, outeritem); while (d_ptr) { if (!d_ptr->desc) { DEBUG_WARN(("ERROR item's desc record is NULL\n")); ff.skip_count++; } else { DEBUG_INFO(("Desc Email ID %"PRIx64" [d_ptr->d_id = %"PRIx64"]\n", d_ptr->desc->i_id, d_ptr->d_id)); item = pst_parse_item(&pstfile, d_ptr, NULL); DEBUG_INFO(("About to process item @ %p.\n", item)); if (item) { if (item->message_store) { // there should only be one message_store, and we have already done it DIE(("A second message_store has been found. Sorry, this must be an error.\n")); } if (item->folder && d_ptr->child) { // if this is a folder, we want to recurse into it pst_convert_utf8(item, &item->file_as); printf("Folder \"%s\"\n", item->file_as.str); process(item, d_ptr->child, o); } else if (item->contact && (item->type == PST_TYPE_CONTACT)) { if (!ff.type) ff.type = item->type; // Process Contact item if (ff.type != PST_TYPE_CONTACT) { DEBUG_INFO(("I have a contact, but the folder isn't a contacts folder. Processing anyway\n")); } printf("Contact"); if (item->contact->fullname.str) printf("\t%s", pst_rfc2426_escape(item->contact->fullname.str, &result, &resultlen)); printf("\n"); } else if (item->email && ((item->type == PST_TYPE_NOTE) || (item->type == PST_TYPE_SCHEDULE) || (item->type == PST_TYPE_REPORT))) { if (!ff.type) ff.type = item->type; // Process Email item if ((ff.type != PST_TYPE_NOTE) && (ff.type != PST_TYPE_SCHEDULE) && (ff.type != PST_TYPE_REPORT)) { DEBUG_INFO(("I have an email, but the folder isn't an email folder. Processing anyway\n")); } printf("Email"); if (o.long_format == 1) { if (item->email->arrival_date) { char time_buffer[MAXDATEFMTLEN]; dateresultlen = pst_fileTimeToString(item->email->arrival_date, o.date_format, time_buffer); if (dateresultlen < 1) DIE(("Date format error in -f option.\n")); printf("\tDate: %s", time_buffer); } else printf("\t"); } if (item->email->outlook_sender_name.str) printf("\tFrom: %s", item->email->outlook_sender_name.str); else printf("\t"); if (o.long_format == 1) { if (item->email->outlook_recipient_name.str) printf("\tTo: %s", item->email->outlook_recipient_name.str); else printf("\t"); if (item->email->cc_address.str) printf("\tCC: %s", item->email->cc_address.str); else printf("\t"); if (item->email->bcc_address.str) printf("\tBCC: %s", item->email->bcc_address.str); else printf("\t"); } if (item->subject.str) printf("\tSubject: %s", item->subject.str); else printf("\t"); printf("\n"); } else if (item->journal && (item->type == PST_TYPE_JOURNAL)) { if (!ff.type) ff.type = item->type; // Process Journal item if (ff.type != PST_TYPE_JOURNAL) { DEBUG_INFO(("I have a journal entry, but folder isn't specified as a journal type. Processing...\n")); } if (item->subject.str) printf("Journal\t%s\n", pst_rfc2426_escape(item->subject.str, &result, &resultlen)); } else if (item->appointment && (item->type == PST_TYPE_APPOINTMENT)) { char time_buffer[30]; if (!ff.type) ff.type = item->type; // Process Calendar Appointment item DEBUG_INFO(("Processing Appointment Entry\n")); if (ff.type != PST_TYPE_APPOINTMENT) { DEBUG_INFO(("I have an appointment, but folder isn't specified as an appointment type. Processing...\n")); } printf("Appointment"); if (item->subject.str) printf("\tSUMMARY: %s", pst_rfc2426_escape(item->subject.str, &result, &resultlen)); if (item->appointment->start) printf("\tSTART: %s", pst_rfc2445_datetime_format(item->appointment->start, sizeof(time_buffer), time_buffer)); if (item->appointment->end) printf("\tEND: %s", pst_rfc2445_datetime_format(item->appointment->end, sizeof(time_buffer), time_buffer)); printf("\tALL DAY: %s", (item->appointment->all_day==1 ? "Yes" : "No")); printf("\n"); } else { ff.skip_count++; DEBUG_INFO(("Unknown item type. %i. Ascii1=\"%s\"\n", item->type, item->ascii_type)); } pst_freeItem(item); } else { ff.skip_count++; DEBUG_INFO(("A NULL item was seen\n")); } } d_ptr = d_ptr->next; } close_enter_dir(&ff); if (result) free(result); DEBUG_RET(); } void usage(char *prog_name) { DEBUG_ENT("usage"); version(); printf("Usage: %s [OPTIONS] {PST FILENAME}\n", prog_name); printf("OPTIONS:\n"); printf("\t-d \t- Debug to file. This is a binary log. Use readlog to print it\n"); printf("\t-l\t- Print the date, CC and BCC fields of emails too (by default only the From and Subject)\n"); printf("\t-f \t- Select the date format in ctime format (by default \"%%F %%T\")\n"); printf("\t-h\t- Help. This screen\n"); printf("\t-V\t- Version. Display program version\n"); DEBUG_RET(); } void version() { DEBUG_ENT("version"); printf("lspst / LibPST v%s\n", VERSION); #if BYTE_ORDER == BIG_ENDIAN printf("Big Endian implementation being used.\n"); #elif BYTE_ORDER == LITTLE_ENDIAN printf("Little Endian implementation being used.\n"); #else # error "Byte order not supported by this library" #endif DEBUG_RET(); } int main(int argc, char* const* argv) { pst_item *item = NULL; pst_desc_tree *d_ptr; char *temp = NULL; //temporary char pointer int c; char *d_log = NULL; struct options o; o.long_format = 0; char *defaultfmtdate = "%F %T"; o.date_format = defaultfmtdate; while ((c = getopt(argc, argv, "d:f:lhV"))!= -1) { switch (c) { case 'd': d_log = optarg; break; case 'f': o.date_format = optarg; break; case 'l': o.long_format = 1; break; case 'h': usage(argv[0]); exit(0); break; case 'V': version(); exit(0); break; default: usage(argv[0]); exit(1); break; } } #ifdef DEBUG_ALL // force a log file if (!d_log) d_log = "lspst.log"; #endif // defined DEBUG_ALL DEBUG_INIT(d_log, NULL); DEBUG_ENT("main"); if (argc <= optind) { usage(argv[0]); exit(2); } // Open PST file if (pst_open(&pstfile, argv[optind], NULL)) DIE(("Error opening File\n")); // Load PST index if (pst_load_index(&pstfile)) DIE(("Index Error\n")); pst_load_extended_attributes(&pstfile); d_ptr = pstfile.d_head; // first record is main record item = pst_parse_item(&pstfile, d_ptr, NULL); if (!item || !item->message_store) { DEBUG_RET(); DIE(("Could not get root record\n")); } // default the file_as to the same as the main filename if it doesn't exist if (!item->file_as.str) { if (!(temp = strrchr(argv[1], '/'))) if (!(temp = strrchr(argv[1], '\\'))) temp = argv[1]; else temp++; // get past the "\\" else temp++; // get past the "/" item->file_as.str = strdup(temp); item->file_as.is_utf8 = 1; } d_ptr = pst_getTopOfFolders(&pstfile, item); if (!d_ptr) DIE(("Top of folders record not found. Cannot continue\n")); process(item, d_ptr->child, o); // do the childred of TOPF pst_freeItem(item); pst_close(&pstfile); DEBUG_RET(); return 0; } -// This function will make sure that a filename is in cannonical form. That +// This function will make sure that a filename is in canonical form. That // is, it will replace any slashes, backslashes, or colons with underscores. void canonicalize_filename(char *fname) { DEBUG_ENT("canonicalize_filename"); if (fname == NULL) { DEBUG_RET(); return; } while ((fname = strpbrk(fname, "/\\:"))) *fname = '_'; DEBUG_RET(); } diff --git a/src/lzfu.c b/src/lzfu.c index cda45f8..da6f40a 100644 --- a/src/lzfu.c +++ b/src/lzfu.c @@ -1,120 +1,120 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #include "define.h" #include "lzfu.h" #define LZFU_COMPRESSED 0x75465a4c #define LZFU_UNCOMPRESSED 0x414c454d // initital dictionary #define LZFU_INITDICT "{\\rtf1\\ansi\\mac\\deff0\\deftab720{\\fonttbl;}" \ "{\\f0\\fnil \\froman \\fswiss \\fmodern \\fscrip" \ "t \\fdecor MS Sans SerifSymbolArialTimes Ne" \ "w RomanCourier{\\colortbl\\red0\\green0\\blue0" \ "\r\n\\par \\pard\\plain\\f0\\fs20\\b\\i\\u\\tab" \ "\\tx" // initial length of dictionary #define LZFU_INITLENGTH 207 // header for compressed rtf typedef struct _lzfuheader { uint32_t cbSize; uint32_t cbRawSize; uint32_t dwMagic; uint32_t dwCRC; } lzfuheader; char* pst_lzfu_decompress(char* rtfcomp, uint32_t compsize, size_t *size) { unsigned char dict[4096]; // the dictionary buffer unsigned int dict_length = 0; // the dictionary pointer lzfuheader lzfuhdr; // the header of the lzfu block unsigned char flags; // 8 bits of flags (1=2byte block pointer into the dict, 0=1 byte literal) - unsigned char flag_mask; // look at one flag bit each time thru the loop + unsigned char flag_mask; // look at one flag bit each time through the loop uint32_t i; char *out_buf; uint32_t out_ptr = 0; uint32_t out_size; uint32_t in_ptr; uint32_t in_size; memcpy(dict, LZFU_INITDICT, LZFU_INITLENGTH); memset(dict + LZFU_INITLENGTH, 0, sizeof(dict) - LZFU_INITLENGTH); dict_length = LZFU_INITLENGTH; memcpy(&lzfuhdr, rtfcomp, sizeof(lzfuhdr)); LE32_CPU(lzfuhdr.cbSize); LE32_CPU(lzfuhdr.cbRawSize); LE32_CPU(lzfuhdr.dwMagic); LE32_CPU(lzfuhdr.dwCRC); //printf("total size: %d\n", lzfuhdr.cbSize+4); //printf("raw size : %d\n", lzfuhdr.cbRawSize); //printf("compressed: %s\n", (lzfuhdr.dwMagic == LZFU_COMPRESSED ? "yes" : "no")); //printf("CRC : %#x\n", lzfuhdr.dwCRC); //printf("\n"); out_size = lzfuhdr.cbRawSize; out_buf = (char*)pst_malloc(out_size); in_ptr = sizeof(lzfuhdr); // Make sure to correct lzfuhdr.cbSize with 4 bytes before comparing // to compsize in_size = (lzfuhdr.cbSize + 4 < compsize) ? lzfuhdr.cbSize + 4 : compsize; while (in_ptr < in_size) { flags = (unsigned char)(rtfcomp[in_ptr++]); flag_mask = 1; while (flag_mask) { if (flag_mask & flags) { // two bytes available? if (in_ptr+1 < in_size) { // read 2 bytes from input uint16_t blkhdr, offset, length; memcpy(&blkhdr, rtfcomp+in_ptr, 2); LE16_CPU(blkhdr); in_ptr += 2; /* swap the upper and lower bytes of blkhdr */ blkhdr = (((blkhdr&0xFF00)>>8)+ ((blkhdr&0x00FF)<<8)); /* the offset is the first 12 bits of the 16 bit value */ offset = (blkhdr&0xFFF0)>>4; /* the length of the dict entry are the last 4 bits */ length = (blkhdr&0x000F)+2; // add the value we are about to print to the dictionary for (i=0; i < length; i++) { unsigned char c1; c1 = dict[(offset+i)%4096]; dict[dict_length] = c1; dict_length = (dict_length+1) % 4096; if (out_ptr < out_size) out_buf[out_ptr++] = (char)c1; // required for dictionary wrap around // otherwise 0 byte values are referenced incorrectly dict[dict_length] = 0; } } } else { // one byte available? if (in_ptr < in_size) { // uncompressed chunk (single byte) char c1 = rtfcomp[in_ptr++]; dict[dict_length] = c1; dict_length = (dict_length+1)%4096; if (out_ptr < out_size) out_buf[out_ptr++] = (char)c1; // required for dictionary wrap around // otherwise 0 byte values are referenced incorrect dict[dict_length] = 0; } } flag_mask <<= 1; } } *size = out_ptr; return out_buf; } diff --git a/src/readpst.c b/src/readpst.c index bc5ee24..b6990af 100644 --- a/src/readpst.c +++ b/src/readpst.c @@ -1,2334 +1,2334 @@ /*** * readpst.c * Part of the LibPST project * Written by David Smith * dave.s@earthcorp.com */ #include "define.h" #include "lzfu.h" #include "msg.h" #define OUTPUT_TEMPLATE "%s.%s" #define OUTPUT_KMAIL_DIR_TEMPLATE ".%s.directory" #define KMAIL_INDEX "../.%s.index" #define SEP_MAIL_FILE_TEMPLATE "%i%s" // max size of the c_time char*. It will store the date of the email #define C_TIME_SIZE 500 struct file_ll { char *name[PST_TYPE_MAX]; char *dname; FILE * output[PST_TYPE_MAX]; int32_t stored_count; int32_t item_count; int32_t skip_count; }; int grim_reaper(); pid_t try_fork(char* folder); void process(pst_item *outeritem, pst_desc_tree *d_ptr); void write_email_body(FILE *f, char *body); void removeCR(char *c); void usage(); void version(); void mk_kmail_dir(char* fname); int close_kmail_dir(); void mk_recurse_dir(char* dir); int close_recurse_dir(); void mk_separate_dir(char *dir); int close_separate_dir(); void mk_separate_file(struct file_ll *f, int32_t t, char *extension, int openit); void close_separate_file(struct file_ll *f); char* my_stristr(char *haystack, char *needle); void check_filename(char *fname); int acceptable_ext(pst_item_attach* attach); void write_separate_attachment(char f_name[], pst_item_attach* attach, int attach_num, pst_file* pst); void write_embedded_message(FILE* f_output, pst_item_attach* attach, char *boundary, pst_file* pf, int save_rtf, char** extra_mime_headers); void write_inline_attachment(FILE* f_output, pst_item_attach* attach, char *boundary, pst_file* pst); int valid_headers(char *header); void header_has_field(char *header, char *field, int *flag); void header_get_subfield(char *field, const char *subfield, char *body_subfield, size_t size_subfield); char* header_get_field(char *header, char *field); char* header_end_field(char *field); void header_strip_field(char *header, char *field); int test_base64(char *body, size_t len); void find_html_charset(char *html, char *charset, size_t charsetlen); void find_rfc822_headers(char** extra_mime_headers); void write_body_part(FILE* f_output, pst_string *body, char *mime, char *charset, char *boundary, pst_file* pst); void write_schedule_part_data(FILE* f_output, pst_item* item, const char* sender, const char* method); void write_schedule_part(FILE* f_output, pst_item* item, const char* sender, const char* boundary); void write_normal_email(FILE* f_output, char f_name[], pst_item* item, int mode, int mode_MH, pst_file* pst, int save_rtf, int embedding, char** extra_mime_headers); void write_vcard(FILE* f_output, pst_item *item, pst_item_contact* contact, char comment[]); int write_extra_categories(FILE* f_output, pst_item* item); void write_journal(FILE* f_output, pst_item* item); void write_appointment(FILE* f_output, pst_item *item); void create_enter_dir(struct file_ll* f, pst_item *item); void close_enter_dir(struct file_ll *f); char* quote_string(char *inp); const char* prog_name; char* output_dir = "."; // Normal mode just creates mbox format files in the current directory. Each file is named // the same as the folder's name that it represents #define MODE_NORMAL 0 // KMail mode creates a directory structure suitable for being used directly // by the KMail application #define MODE_KMAIL 1 // recurse mode creates a directory structure like the PST file. Each directory // contains only one file which stores the emails in mboxrd format. #define MODE_RECURSE 2 // separate mode creates the same directory structure as recurse. The emails are stored in // separate files, numbering from 1 upward. Attachments belonging to the emails are // saved as email_no-filename (e.g. 1-samplefile.doc or 1-Attachment2.zip) #define MODE_SEPARATE 3 // Output Normal just prints the standard information about what is going on #define OUTPUT_NORMAL 0 // Output Quiet is provided so that only errors are printed #define OUTPUT_QUIET 1 // default mime-type for attachments that have a null mime-type #define MIME_TYPE_DEFAULT "application/octet-stream" #define RFC822 "message/rfc822" // output mode for contacts #define CMODE_VCARD 0 #define CMODE_LIST 1 // output mode for deleted items #define DMODE_EXCLUDE 0 #define DMODE_INCLUDE 1 // Output type mode flags #define OTMODE_EMAIL 1 #define OTMODE_APPOINTMENT 2 #define OTMODE_JOURNAL 4 #define OTMODE_CONTACT 8 // output settings for RTF bodies // filename for the attachment #define RTF_ATTACH_NAME "rtf-body.rtf" // mime type for the attachment #define RTF_ATTACH_TYPE "application/rtf" // global settings int mode = MODE_NORMAL; int mode_MH = 0; // a submode of MODE_SEPARATE int mode_EX = 0; // a submode of MODE_SEPARATE int mode_MSG = 0; // a submode of MODE_SEPARATE int mode_thunder = 0; // a submode of MODE_RECURSE int output_mode = OUTPUT_NORMAL; int contact_mode = CMODE_VCARD; int deleted_mode = DMODE_EXCLUDE; int output_type_mode = 0xff; // Default to all. int contact_mode_specified = 0; int overwrite = 0; int prefer_utf8 = 0; int save_rtf_body = 1; int file_name_len = 10; // enough room for MODE_SPEARATE file name pst_file pstfile; regex_t meta_charset_pattern; char* default_charset = NULL; char* acceptable_extensions = NULL; int number_processors = 1; // number of cpus we have int max_children = 0; // based on number of cpus and command line args int max_child_specified = 0;// have command line arg -j int active_children; // number of children of this process, cannot be larger than max_children pid_t* child_processes; // setup by main(), and at the start of new child process #ifdef HAVE_SEMAPHORE_H int shared_memory_id; sem_t* global_children = NULL; sem_t* output_mutex = NULL; #endif int grim_reaper(int waitall) { int available = 0; #ifdef HAVE_FORK #ifdef HAVE_SEMAPHORE_H if (global_children) { //sem_getvalue(global_children, &available); //printf("grim reaper %s for pid %d (parent %d) with %d children, %d available\n", (waitall) ? "all" : "", getpid(), getppid(), active_children, available); //fflush(stdout); int i,j; for (i=0; i 0 but active_children == max_children if (available && active_children < max_children) { sem_wait(global_children); pid_t child = fork(); if (child < 0) { // fork failed, pretend it worked and we are the child return 0; } else if (child == 0) { // fork worked, and we are the child, reinitialize *our* list of children active_children = 0; memset(child_processes, 0, sizeof(pid_t) * max_children); pst_reopen(&pstfile); // close and reopen the pst file to get an independent file position pointer } else { // fork worked, and we are the parent, record this child that we need to wait for //pid_t me = getpid(); //printf("parent %d forked child pid %d to process folder %s\n", me, child, folder); //fflush(stdout); child_processes[active_children++] = child; } return child; } else { return 0; // pretend to have forked and we are the child } #endif #endif return 0; } void process(pst_item *outeritem, pst_desc_tree *d_ptr) { struct file_ll ff; pst_item *item = NULL; DEBUG_ENT("process"); create_enter_dir(&ff, outeritem); for (; d_ptr; d_ptr = d_ptr->next) { DEBUG_INFO(("New item record\n")); if (!d_ptr->desc) { ff.skip_count++; DEBUG_WARN(("ERROR item's desc record is NULL\n")); continue; } DEBUG_INFO(("Desc Email ID %#"PRIx64" [d_ptr->d_id = %#"PRIx64"]\n", d_ptr->desc->i_id, d_ptr->d_id)); item = pst_parse_item(&pstfile, d_ptr, NULL); DEBUG_INFO(("About to process item\n")); if (!item) { ff.skip_count++; DEBUG_INFO(("A NULL item was seen\n")); continue; } if (item->subject.str) { DEBUG_INFO(("item->subject = %s\n", item->subject.str)); } if (item->folder && item->file_as.str) { DEBUG_INFO(("Processing Folder \"%s\"\n", item->file_as.str)); if (output_mode != OUTPUT_QUIET) { pst_debug_lock(); printf("Processing Folder \"%s\"\n", item->file_as.str); fflush(stdout); pst_debug_unlock(); } ff.item_count++; if (d_ptr->child && (deleted_mode == DMODE_INCLUDE || strcasecmp(item->file_as.str, "Deleted Items"))) { //if this is a non-empty folder other than deleted items, we want to recurse into it pid_t parent = getpid(); pid_t child = try_fork(item->file_as.str); if (child == 0) { // we are the child process, or the original parent if no children were available pid_t me = getpid(); process(item, d_ptr->child); #ifdef HAVE_FORK #ifdef HAVE_SEMAPHORE_H if (me != parent) { // we really were a child, forked for the sole purpose of processing this folder // free my child count slot before really exiting, since // all I am doing here is waiting for my children to exit sem_post(global_children); grim_reaper(1); // wait for all my child processes to exit exit(0); // really exit } #endif #endif } } } else if (item->contact && (item->type == PST_TYPE_CONTACT)) { DEBUG_INFO(("Processing Contact\n")); if (!(output_type_mode & OTMODE_CONTACT)) { ff.skip_count++; DEBUG_INFO(("skipping contact: not in output type list\n")); } else { ff.item_count++; if (mode == MODE_SEPARATE) mk_separate_file(&ff, PST_TYPE_CONTACT, (mode_EX) ? ".vcf" : "", 1); if (contact_mode == CMODE_VCARD) { pst_convert_utf8_null(item, &item->comment); write_vcard(ff.output[PST_TYPE_CONTACT], item, item->contact, item->comment.str); } else { pst_convert_utf8(item, &item->contact->fullname); pst_convert_utf8(item, &item->contact->address1); fprintf(ff.output[PST_TYPE_CONTACT], "%s <%s>\n", item->contact->fullname.str, item->contact->address1.str); } if (mode == MODE_SEPARATE) close_separate_file(&ff); } } else if (item->email && ((item->type == PST_TYPE_NOTE) || (item->type == PST_TYPE_SCHEDULE) || (item->type == PST_TYPE_REPORT))) { DEBUG_INFO(("Processing Email\n")); if (!(output_type_mode & OTMODE_EMAIL)) { ff.skip_count++; DEBUG_INFO(("skipping email: not in output type list\n")); } else { char *extra_mime_headers = NULL; ff.item_count++; if (mode == MODE_SEPARATE) { // process this single email message, possibly forking pid_t parent = getpid(); pid_t child = try_fork(item->file_as.str); if (child == 0) { // we are the child process, or the original parent if no children were available pid_t me = getpid(); mk_separate_file(&ff, PST_TYPE_NOTE, (mode_EX) ? ".eml" : "", 1); write_normal_email(ff.output[PST_TYPE_NOTE], ff.name[PST_TYPE_NOTE], item, mode, mode_MH, &pstfile, save_rtf_body, PST_TYPE_NOTE, &extra_mime_headers); close_separate_file(&ff); if (mode_MSG) { mk_separate_file(&ff, PST_TYPE_NOTE, ".msg", 0); write_msg_email(ff.name[PST_TYPE_NOTE], item, &pstfile); } #ifdef HAVE_FORK #ifdef HAVE_SEMAPHORE_H if (me != parent) { // we really were a child, forked for the sole purpose of processing this message // free my child count slot before really exiting, since // all I am doing here is waiting for my children to exit sem_post(global_children); grim_reaper(1); // wait for all my child processes to exit - there should not be any exit(0); // really exit } #endif #endif } } else { // process this single email message, cannot fork since not separate mode write_normal_email(ff.output[PST_TYPE_NOTE], ff.name[PST_TYPE_NOTE], item, mode, mode_MH, &pstfile, save_rtf_body, 0, &extra_mime_headers); } } } else if (item->journal && (item->type == PST_TYPE_JOURNAL)) { DEBUG_INFO(("Processing Journal Entry\n")); if (!(output_type_mode & OTMODE_JOURNAL)) { ff.skip_count++; DEBUG_INFO(("skipping journal entry: not in output type list\n")); } else { ff.item_count++; if (mode == MODE_SEPARATE) mk_separate_file(&ff, PST_TYPE_JOURNAL, (mode_EX) ? ".ics" : "", 1); write_journal(ff.output[PST_TYPE_JOURNAL], item); fprintf(ff.output[PST_TYPE_JOURNAL], "\n"); if (mode == MODE_SEPARATE) close_separate_file(&ff); } } else if (item->appointment && (item->type == PST_TYPE_APPOINTMENT)) { DEBUG_INFO(("Processing Appointment Entry\n")); if (!(output_type_mode & OTMODE_APPOINTMENT)) { ff.skip_count++; DEBUG_INFO(("skipping appointment: not in output type list\n")); } else { ff.item_count++; if (mode == MODE_SEPARATE) mk_separate_file(&ff, PST_TYPE_APPOINTMENT, (mode_EX) ? ".ics" : "", 1); write_schedule_part_data(ff.output[PST_TYPE_APPOINTMENT], item, NULL, NULL); fprintf(ff.output[PST_TYPE_APPOINTMENT], "\n"); if (mode == MODE_SEPARATE) close_separate_file(&ff); } } else if (item->message_store) { // there should only be one message_store, and we have already done it ff.skip_count++; DEBUG_WARN(("item with message store content, type %i %s, skipping it\n", item->type, item->ascii_type)); } else { ff.skip_count++; DEBUG_WARN(("Unknown item type %i (%s) name (%s)\n", item->type, item->ascii_type, item->file_as.str)); } pst_freeItem(item); } close_enter_dir(&ff); DEBUG_RET(); } int main(int argc, char* const* argv) { pst_item *item = NULL; pst_desc_tree *d_ptr; char * fname = NULL; char *d_log = NULL; int c,x; char *temp = NULL; //temporary char pointer prog_name = argv[0]; time_t now = time(NULL); srand((unsigned)now); if (regcomp(&meta_charset_pattern, "]*content=\"[^>]*charset=([^>\";]*)[\";]", REG_ICASE | REG_EXTENDED)) { printf("cannot compile regex pattern to find content charset in html bodies\n"); exit(3); } // command-line option handling while ((c = getopt(argc, argv, "a:bC:c:Dd:emhj:kMo:qrSt:uVwL:8"))!= -1) { switch (c) { case 'a': if (optarg) { int n = strlen(optarg); acceptable_extensions = (char*)pst_malloc(n+2); strcpy(acceptable_extensions, optarg); acceptable_extensions[n+1] = '\0'; // double null terminates array of non-empty null terminated strings. char *p = acceptable_extensions; while (*p) { if (*p == ',') *p = '\0'; p++; } } break; case 'b': save_rtf_body = 0; break; case 'C': if (optarg) { default_charset = optarg; } else { usage(); exit(0); } break; case 'c': if (optarg && optarg[0]=='v') { contact_mode=CMODE_VCARD; contact_mode_specified = 1; } else if (optarg && optarg[0]=='l') { contact_mode=CMODE_LIST; contact_mode_specified = 1; } else { usage(); exit(0); } break; case 'D': deleted_mode = DMODE_INCLUDE; break; case 'd': d_log = optarg; break; case 'h': usage(); exit(0); break; case 'j': max_children = atoi(optarg); max_child_specified = 1; break; case 'k': mode = MODE_KMAIL; break; case 'M': mode = MODE_SEPARATE; mode_MH = 1; mode_EX = 0; mode_MSG = 0; break; case 'e': mode = MODE_SEPARATE; mode_MH = 1; mode_EX = 1; mode_MSG = 0; file_name_len = 14; break; case 'L': pst_debug_setlevel(atoi(optarg)); break; case 'm': mode = MODE_SEPARATE; mode_MH = 1; mode_EX = 1; mode_MSG = 1; file_name_len = 14; break; case 'o': output_dir = optarg; break; case 'q': output_mode = OUTPUT_QUIET; break; case 'r': mode = MODE_RECURSE; mode_thunder = 0; break; case 'S': mode = MODE_SEPARATE; mode_MH = 0; mode_EX = 0; mode_MSG = 0; break; case 't': // email, appointment, contact, other if (!optarg) { usage(); exit(0); } temp = optarg; output_type_mode = 0; while (*temp > 0) { switch (temp[0]) { case 'e': output_type_mode |= OTMODE_EMAIL; break; case 'a': output_type_mode |= OTMODE_APPOINTMENT; break; case 'j': output_type_mode |= OTMODE_JOURNAL; break; case 'c': output_type_mode |= OTMODE_CONTACT; break; default: usage(); exit(0); break; } temp++; } break; case 'u': mode = MODE_RECURSE; mode_thunder = 1; break; case 'V': version(); exit(0); break; case 'w': overwrite = 1; break; case '8': prefer_utf8 = 1; break; default: usage(); exit(1); break; } } if (argc > optind) { fname = argv[optind]; } else { usage(); exit(2); } #ifdef _SC_NPROCESSORS_ONLN number_processors = sysconf(_SC_NPROCESSORS_ONLN); #endif max_children = (max_child_specified) ? max_children : number_processors * 4; active_children = 0; child_processes = (pid_t *)pst_malloc(sizeof(pid_t) * max_children); memset(child_processes, 0, sizeof(pid_t) * max_children); #ifdef HAVE_SEMAPHORE_H if (max_children) { shared_memory_id = shmget(IPC_PRIVATE, sizeof(sem_t)*2, 0777); if (shared_memory_id >= 0) { global_children = (sem_t *)shmat(shared_memory_id, NULL, 0); if (global_children == (sem_t *)-1) global_children = NULL; if (global_children) { output_mutex = &(global_children[1]); sem_init(global_children, 1, max_children); sem_init(output_mutex, 1, 1); } shmctl(shared_memory_id, IPC_RMID, NULL); } } #endif #ifdef DEBUG_ALL // force a log file if (!d_log) d_log = "readpst.log"; #endif // defined DEBUG_ALL #ifdef HAVE_SEMAPHORE_H DEBUG_INIT(d_log, output_mutex); #else DEBUG_INIT(d_log, NULL); #endif DEBUG_ENT("main"); if (output_mode != OUTPUT_QUIET) printf("Opening PST file and indexes...\n"); RET_DERROR(pst_open(&pstfile, fname, default_charset), 1, ("Error opening File\n")); RET_DERROR(pst_load_index(&pstfile), 2, ("Index Error\n")); pst_load_extended_attributes(&pstfile); if (chdir(output_dir)) { x = errno; pst_close(&pstfile); DEBUG_RET(); DIE(("Cannot change to output dir %s: %s\n", output_dir, strerror(x))); } d_ptr = pstfile.d_head; // first record is main record item = pst_parse_item(&pstfile, d_ptr, NULL); if (!item || !item->message_store) { DEBUG_RET(); DIE(("Could not get root record\n")); } // default the file_as to the same as the main filename if it doesn't exist if (!item->file_as.str) { if (!(temp = strrchr(fname, '/'))) if (!(temp = strrchr(fname, '\\'))) temp = fname; else temp++; // get past the "\\" else temp++; // get past the "/" item->file_as.str = (char*)pst_malloc(strlen(temp)+1); strcpy(item->file_as.str, temp); item->file_as.is_utf8 = 1; DEBUG_INFO(("file_as was blank, so am using %s\n", item->file_as.str)); } DEBUG_INFO(("Root Folder Name: %s\n", item->file_as.str)); d_ptr = pst_getTopOfFolders(&pstfile, item); if (!d_ptr) { DEBUG_RET(); DIE(("Top of folders record not found. Cannot continue\n")); } process(item, d_ptr->child); // do the children of TOPF grim_reaper(1); // wait for all child processes pst_freeItem(item); pst_close(&pstfile); DEBUG_RET(); #ifdef HAVE_SEMAPHORE_H if (global_children) { sem_destroy(global_children); sem_destroy(output_mutex); shmdt(global_children); } #endif regfree(&meta_charset_pattern); return 0; } void write_email_body(FILE *f, char *body) { char *n = body; DEBUG_ENT("write_email_body"); if (mode != MODE_SEPARATE) { while (n) { char *p = body; while (*p == '>') p++; if (strncmp(p, "From ", 5) == 0) fprintf(f, ">"); if ((n = strchr(body, '\n'))) { n++; pst_fwrite(body, n-body, 1, f); //write just a line body = n; } } } pst_fwrite(body, strlen(body), 1, f); DEBUG_RET(); } void removeCR (char *c) { // converts \r\n to \n char *a, *b; DEBUG_ENT("removeCR"); a = b = c; while (*a != '\0') { *b = *a; if (*a != '\r') b++; a++; } *b = '\0'; DEBUG_RET(); } void usage() { DEBUG_ENT("usage"); version(); printf("Usage: %s [OPTIONS] {PST FILENAME}\n", prog_name); printf("OPTIONS:\n"); printf("\t-V\t- Version. Display program version\n"); printf("\t-C charset\t- character set for items with an unspecified character set\n"); printf("\t-D\t- Include deleted items in output\n"); printf("\t-L \t- Set debug level; 1=debug,2=info,3=warn.\n"); printf("\t-M\t- Write emails in the MH (rfc822) format\n"); printf("\t-S\t- Separate. Write emails in the separate format\n"); printf("\t-a \t- Discard any attachment without an extension on the list\n"); printf("\t-b\t- Don't save RTF-Body attachments\n"); printf("\t-c[v|l]\t- Set the Contact output mode. -cv = VCard, -cl = EMail list\n"); printf("\t-d \t- Debug to file.\n"); printf("\t-e\t- As with -M, but include extensions on output files\n"); printf("\t-h\t- Help. This screen\n"); printf("\t-j \t- Number of parallel jobs to run\n"); printf("\t-k\t- KMail. Output in kmail format\n"); printf("\t-m\t- As with -e, but write .msg files also\n"); printf("\t-o \t- Output directory to write files to. CWD is changed *after* opening pst file\n"); printf("\t-q\t- Quiet. Only print error messages\n"); printf("\t-r\t- Recursive. Output in a recursive format\n"); printf("\t-t[eajc]\t- Set the output type list. e = email, a = attachment, j = journal, c = contact\n"); printf("\t-u\t- Thunderbird mode. Write two extra .size and .type files\n"); printf("\t-w\t- Overwrite any output mbox files\n"); printf("\t-8\t- Output bodies in UTF-8, rather than original encoding, if UTF-8 version is available\n"); printf("\n"); printf("Only one of -M -S -e -k -m -r should be specified\n"); DEBUG_RET(); } void version() { DEBUG_ENT("version"); printf("ReadPST / LibPST v%s\n", VERSION); #if BYTE_ORDER == BIG_ENDIAN printf("Big Endian implementation being used.\n"); #elif BYTE_ORDER == LITTLE_ENDIAN printf("Little Endian implementation being used.\n"); #else # error "Byte order not supported by this library" #endif DEBUG_RET(); } void mk_kmail_dir(char *fname) { //make a directory based on OUTPUT_KMAIL_DIR_TEMPLATE //change to that directory char *dir, *index; int x; DEBUG_ENT("mk_kmail_dir"); dir = pst_malloc(strlen(fname)+strlen(OUTPUT_KMAIL_DIR_TEMPLATE)+1); sprintf(dir, OUTPUT_KMAIL_DIR_TEMPLATE, fname); check_filename(dir); if (D_MKDIR(dir)) { if (errno != EEXIST) { // not an error because it exists x = errno; DIE(("mk_kmail_dir: Cannot create directory %s: %s\n", dir, strerror(x))); } } if (chdir(dir)) { x = errno; DIE(("mk_kmail_dir: Cannot change to directory %s: %s\n", dir, strerror(x))); } free (dir); //we should remove any existing indexes created by KMail, cause they might be different now index = pst_malloc(strlen(fname)+strlen(KMAIL_INDEX)+1); sprintf(index, KMAIL_INDEX, fname); unlink(index); free(index); DEBUG_RET(); } int close_kmail_dir() { int x; DEBUG_ENT("close_kmail_dir"); if (chdir("..")) { x = errno; DIE(("close_kmail_dir: Cannot move up dir (..): %s\n", strerror(x))); } DEBUG_RET(); return 0; } char *item_type_to_name(int32_t item_type) { char *name; switch (item_type) { case PST_TYPE_APPOINTMENT: name = "calendar"; break; case PST_TYPE_CONTACT: name = "contacts"; break; case PST_TYPE_JOURNAL: name = "journal"; break; case PST_TYPE_STICKYNOTE: case PST_TYPE_TASK: case PST_TYPE_NOTE: case PST_TYPE_OTHER: case PST_TYPE_REPORT: default: name = "mbox"; break; } return name; } int32_t reduced_item_type(int32_t item_type) { int32_t reduced; switch (item_type) { case PST_TYPE_APPOINTMENT: case PST_TYPE_CONTACT: case PST_TYPE_JOURNAL: reduced = item_type; break; case PST_TYPE_STICKYNOTE: case PST_TYPE_TASK: case PST_TYPE_NOTE: case PST_TYPE_OTHER: case PST_TYPE_REPORT: default: reduced = PST_TYPE_NOTE; break; } return reduced; } // this will create a directory by that name void mk_recurse_dir(char *dir) { int x; DEBUG_ENT("mk_recurse_dir"); check_filename(dir); if (D_MKDIR (dir)) { if (errno != EEXIST) { // not an error because it exists x = errno; DIE(("mk_recurse_dir: Cannot create directory %s: %s\n", dir, strerror(x))); } } if (chdir(dir)) { x = errno; DIE(("mk_recurse_dir: Cannot change to directory %s: %s\n", dir, strerror(x))); } DEBUG_RET(); } int close_recurse_dir() { int x; DEBUG_ENT("close_recurse_dir"); if (chdir("..")) { x = errno; DIE(("close_recurse_dir: Cannot go up dir (..): %s\n", strerror(x))); } DEBUG_RET(); return 0; } void mk_separate_dir(char *dir) { size_t dirsize = strlen(dir) + 10; char dir_name[dirsize]; int x = 0, y = 0; DEBUG_ENT("mk_separate_dir"); do { if (y == 0) snprintf(dir_name, dirsize, "%s", dir); else snprintf(dir_name, dirsize, "%s" SEP_MAIL_FILE_TEMPLATE, dir, y, ""); // enough for 9 digits allocated above check_filename(dir_name); DEBUG_INFO(("about to try creating %s\n", dir_name)); if (D_MKDIR(dir_name)) { if (errno != EEXIST) { // if there is an error, and it doesn't already exist x = errno; DIE(("mk_separate_dir: Cannot create directory %s: %s\n", dir, strerror(x))); } } else { break; } y++; } while (overwrite == 0); if (chdir(dir_name)) { x = errno; DIE(("mk_separate_dir: Cannot change to directory %s: %s\n", dir, strerror(x))); } if (overwrite) { // we should probably delete all files from this directory #if !defined(WIN32) && !defined(__CYGWIN__) DIR * sdir = NULL; struct dirent *dirent = NULL; struct stat filestat; if (!(sdir = opendir("./"))) { DEBUG_WARN(("mk_separate_dir: Cannot open dir \"%s\" for deletion of old contents\n", "./")); } else { while ((dirent = readdir(sdir))) { if (lstat(dirent->d_name, &filestat) != -1) if (S_ISREG(filestat.st_mode)) { if (unlink(dirent->d_name)) { y = errno; DIE(("mk_separate_dir: unlink returned error on file %s: %s\n", dirent->d_name, strerror(y))); } } } closedir(sdir); // cppcheck detected leak } #endif } DEBUG_RET(); } int close_separate_dir() { int x; DEBUG_ENT("close_separate_dir"); if (chdir("..")) { x = errno; DIE(("close_separate_dir: Cannot go up dir (..): %s\n", strerror(x))); } DEBUG_RET(); return 0; } void mk_separate_file(struct file_ll *f, int32_t t, char *extension, int openit) { DEBUG_ENT("mk_separate_file"); DEBUG_INFO(("opening next file to save email type %s\n", item_type_to_name(t))); if (f->item_count > 999999999) { // bigger than nine 9's DIE(("mk_separate_file: The number of emails in this folder has become too high to handle\n")); } sprintf(f->name[t], SEP_MAIL_FILE_TEMPLATE, f->item_count, extension); check_filename(f->name[t]); if (openit) { if (!(f->output[t] = fopen(f->name[t], "w"))) { DIE(("mk_separate_file: Cannot open file to save email \"%s\"\n", f->name[t])); } } DEBUG_RET(); } void close_separate_file(struct file_ll *f) { int32_t t; DEBUG_ENT("close_separate_file"); for (t=0; toutput[t]) { struct stat st; fclose(f->output[t]); stat(f->name[t], &st); if (!st.st_size) { DEBUG_WARN(("removing empty output file %s\n", f->name[t])); remove(f->name[t]); } f->output[t] = NULL; } } DEBUG_RET(); } char *my_stristr(char *haystack, char *needle) { // my_stristr varies from strstr in that its searches are case-insensitive char *x=haystack, *y=needle, *z = NULL; if (!haystack || !needle) { return NULL; } while (*y != '\0' && *x != '\0') { if (tolower(*y) == tolower(*x)) { // move y on one y++; if (!z) { z = x; // store first position in haystack where a match is made } } else { y = needle; // reset y to the beginning of the needle z = NULL; // reset the haystack storage point } x++; // advance the search in the haystack } // If the haystack ended before our search finished, it's not a match. if (*y != '\0') return NULL; return z; } void check_filename(char *fname) { char *t = fname; DEBUG_ENT("check_filename"); if (!t) { DEBUG_RET(); return; } while ((t = strpbrk(t, "/\\:"))) { // while there are characters in the second string that we don't want *t = '_'; //replace them with an underscore } DEBUG_RET(); } /** * check if the file name extension is acceptable. If not, the attachment * will be discarded * @param attach pst attachment object * @return true if the attachment filename contains an extension that we want. */ int acceptable_ext(pst_item_attach* attach) { if (!acceptable_extensions || *acceptable_extensions == '\0') return 1; // acceptable list missing or empty char *attach_filename = (attach->filename2.str) ? attach->filename2.str : attach->filename1.str; if (!attach_filename) return 1; // attachment with no name is always acceptable char *e = strrchr(attach_filename, '.'); if (!e) return 1; // attachment with no extension is always acceptable. DEBUG_ENT("acceptable_ext"); DEBUG_INFO(("attachment extension %s\n", e)); int rc = 0; char *a = acceptable_extensions; while (*a) { if (pst_stricmp(a, e) == 0) { rc = 1; break; } a += strlen(a) + 1; } DEBUG_INFO(("attachment acceptable returns %d\n", rc)); DEBUG_RET(); return rc; } void write_separate_attachment(char f_name[], pst_item_attach* attach, int attach_num, pst_file* pst) { FILE *fp = NULL; int x = 0; char *temp = NULL; // If there is a long filename (filename2) use that, otherwise // use the 8.3 filename (filename1) char *attach_filename = (attach->filename2.str) ? attach->filename2.str : attach->filename1.str; DEBUG_ENT("write_separate_attachment"); DEBUG_INFO(("Attachment %s Size is %#"PRIx64", data = %#"PRIxPTR", id %#"PRIx64"\n", attach_filename, (uint64_t)attach->data.size, attach->data.data, attach->i_id)); if (!attach->data.data) { // make sure we can fetch data from the id pst_index_ll *ptr = pst_getID(pst, attach->i_id); if (!ptr) { DEBUG_WARN(("Couldn't find i_id %#"PRIx64". Cannot save attachment to file\n", attach->i_id)); DEBUG_RET(); return; } } check_filename(f_name); if (!attach_filename) { - // generate our own (dummy) filename for the attachement + // generate our own (dummy) filename for the attachment temp = pst_malloc(strlen(f_name)+15); sprintf(temp, "%s-attach%i", f_name, attach_num); } else { // have an attachment name, make sure it's unique temp = pst_malloc(strlen(f_name)+strlen(attach_filename)+15); do { if (fp) fclose(fp); if (x == 0) sprintf(temp, "%s-%s", f_name, attach_filename); else sprintf(temp, "%s-%s-%i", f_name, attach_filename, x); } while ((fp = fopen(temp, "r")) && ++x < 99999999); if (x > 99999999) { DIE(("error finding attachment name. exhausted possibilities to %s\n", temp)); } } DEBUG_INFO(("Saving attachment to %s\n", temp)); if (!(fp = fopen(temp, "w"))) { DEBUG_WARN(("write_separate_attachment: Cannot open attachment save file \"%s\"\n", temp)); } else { (void)pst_attach_to_file(pst, attach, fp); fclose(fp); } if (temp) free(temp); DEBUG_RET(); } void write_embedded_message(FILE* f_output, pst_item_attach* attach, char *boundary, pst_file* pf, int save_rtf, char** extra_mime_headers) { pst_index_ll *ptr; DEBUG_ENT("write_embedded_message"); ptr = pst_getID(pf, attach->i_id); pst_desc_tree d_ptr; d_ptr.d_id = 0; d_ptr.parent_d_id = 0; d_ptr.assoc_tree = NULL; d_ptr.desc = ptr; d_ptr.no_child = 0; d_ptr.prev = NULL; d_ptr.next = NULL; d_ptr.parent = NULL; d_ptr.child = NULL; d_ptr.child_tail = NULL; pst_item *item = pst_parse_item(pf, &d_ptr, attach->id2_head); // It appears that if the embedded message contains an appointment/ // calendar item, pst_parse_item returns NULL due to the presence of // an unexpected reference type of 0x1048, which seems to represent // an array of GUIDs representing a CLSID. It's likely that this is // a reference to an internal Outlook COM class. // Log the skipped item and continue on. if (!item) { DEBUG_WARN(("write_embedded_message: pst_parse_item was unable to parse the embedded message in attachment ID %llu", attach->i_id)); } else { if (!item->email) { DEBUG_WARN(("write_embedded_message: pst_parse_item returned type %d, not an email message", item->type)); } else { fprintf(f_output, "\n--%s\n", boundary); fprintf(f_output, "Content-Type: %s\n\n", attach->mimetype.str); write_normal_email(f_output, "", item, MODE_NORMAL, 0, pf, save_rtf, 1, extra_mime_headers); } pst_freeItem(item); } DEBUG_RET(); } /** * Backslash-escape quotes and backslashes in the given string. */ char *quote_string(char *inp) { int i = 0; int count = 0; char *curr = inp; while (*curr) { if (*curr == '\"' || *curr == '\\') { count++; } curr++; i++; } char *res = malloc(i + count + 1); char *curr_in = inp; char *curr_out = res; while (*curr_in) { if (*curr_in == '\"' || *curr_in == '\\') { *curr_out++ = '\\'; } *curr_out++ = *curr_in++; } *curr_out = '\0'; return res; } void write_inline_attachment(FILE* f_output, pst_item_attach* attach, char *boundary, pst_file* pst) { DEBUG_ENT("write_inline_attachment"); DEBUG_INFO(("Attachment Size is %#"PRIx64", data = %#"PRIxPTR", id %#"PRIx64"\n", (uint64_t)attach->data.size, attach->data.data, attach->i_id)); if (!attach->data.data) { // make sure we can fetch data from the id pst_index_ll *ptr = pst_getID(pst, attach->i_id); if (!ptr) { DEBUG_WARN(("Couldn't find ID pointer. Cannot save attachment to file\n")); DEBUG_RET(); return; } } fprintf(f_output, "\n--%s\n", boundary); if (!attach->mimetype.str) { fprintf(f_output, "Content-Type: %s\n", MIME_TYPE_DEFAULT); } else { fprintf(f_output, "Content-Type: %s\n", attach->mimetype.str); } fprintf(f_output, "Content-Transfer-Encoding: base64\n"); if (attach->content_id.str) { fprintf(f_output, "Content-ID: <%s>\n", attach->content_id.str); } if (attach->filename2.str) { // use the long filename, converted to proper encoding if needed. // it is already utf8 char *escaped = quote_string(attach->filename2.str); pst_rfc2231(&attach->filename2); fprintf(f_output, "Content-Disposition: attachment; \n filename*=%s;\n", attach->filename2.str); // Also include the (escaped) utf8 filename in the 'filename' header directly - this is not strictly valid // (since this header should be ASCII) but is almost always handled correctly (and in fact this is the only // way to get MS Outlook to correctly read a UTF8 filename, AFAICT, which is why we're doing it). fprintf(f_output, " filename=\"%s\"\n\n", escaped); free(escaped); } else if (attach->filename1.str) { // short filename never needs encoding fprintf(f_output, "Content-Disposition: attachment; filename=\"%s\"\n\n", attach->filename1.str); } else { // no filename is inline fprintf(f_output, "Content-Disposition: inline\n\n"); } (void)pst_attach_to_file_base64(pst, attach, f_output); fprintf(f_output, "\n\n"); DEBUG_RET(); } int header_match(char *header, char*field) { int n = strlen(field); if (strncasecmp(header, field, n) == 0) return 1; // tag:{space} if ((field[n-1] == ' ') && (strncasecmp(header, field, n-1) == 0)) { char *crlftab = "\r\n\t"; DEBUG_INFO(("Possible wrapped header = %s\n", header)); if (strncasecmp(header+n-1, crlftab, 3) == 0) return 1; // tag:{cr}{lf}{tab} } return 0; } int valid_headers(char *header) { // headers are sometimes really bogus - they seem to be fragments of the // message body, so we only use them if they seem to be real rfc822 headers. // this list is composed of ones that we have seen in real pst files. // there are surely others. the problem is - given an arbitrary character // string, is it a valid (or even reasonable) set of rfc822 headers? if (header) { if (header_match(header, "Content-Type: " )) return 1; if (header_match(header, "Date: " )) return 1; if (header_match(header, "From: " )) return 1; if (header_match(header, "MIME-Version: " )) return 1; if (header_match(header, "Microsoft Mail Internet Headers")) return 1; if (header_match(header, "Received: " )) return 1; if (header_match(header, "Return-Path: " )) return 1; if (header_match(header, "Subject: " )) return 1; if (header_match(header, "To: " )) return 1; if (header_match(header, "X-ASG-Debug-ID: " )) return 1; if (header_match(header, "X-Barracuda-URL: " )) return 1; if (header_match(header, "X-x: " )) return 1; if (strlen(header) > 2) { DEBUG_INFO(("Ignore bogus headers = %s\n", header)); } return 0; } else return 0; } void header_has_field(char *header, char *field, int *flag) { DEBUG_ENT("header_has_field"); if (my_stristr(header, field) || (strncasecmp(header, field+1, strlen(field)-1) == 0)) { DEBUG_INFO(("header block has %s header\n", field+1)); *flag = 1; } DEBUG_RET(); } void header_get_subfield(char *field, const char *subfield, char *body_subfield, size_t size_subfield) { if (!field) return; DEBUG_ENT("header_get_subfield"); char search[60]; snprintf(search, sizeof(search), " %s=", subfield); field++; char *n = header_end_field(field); char *s = my_stristr(field, search); if (n && s && (s < n)) { char *e, *f, save; s += strlen(search); // skip over subfield= if (*s == '"') { s++; e = strchr(s, '"'); } else { e = strchr(s, ';'); f = strchr(s, '\n'); if (e && f && (f < e)) e = f; } if (!e || (e > n)) e = n; // use the trailing lf as terminator if nothing better save = *e; *e = '\0'; snprintf(body_subfield, size_subfield, "%s", s); // copy the subfield to our buffer *e = save; DEBUG_INFO(("body %s %s from headers\n", subfield, body_subfield)); } DEBUG_RET(); } char* header_get_field(char *header, char *field) { char *t = my_stristr(header, field); if (!t && (strncasecmp(header, field+1, strlen(field)-1) == 0)) t = header; return t; } // return pointer to \n at the end of this header field, // or NULL if this field goes to the end of the string. char *header_end_field(char *field) { char *e = strchr(field+1, '\n'); while (e && ((e[1] == ' ') || (e[1] == '\t'))) { e = strchr(e+1, '\n'); } return e; } void header_strip_field(char *header, char *field) { char *t; while ((t = header_get_field(header, field))) { char *e = header_end_field(t); if (e) { if (t == header) e++; // if *t is not \n, we don't want to keep the \n at *e either. while (*e != '\0') { *t = *e; t++; e++; } *t = '\0'; } else { // this was the last header field, truncate the headers *t = '\0'; } } } int test_base64(char *body, size_t len) { int b64 = 0; uint8_t *b = (uint8_t *)body; DEBUG_ENT("test_base64"); while (len--) { if ((*b < 32) && (*b != 9) && (*b != 10)) { DEBUG_INFO(("found base64 byte %d\n", (int)*b)); DEBUG_HEXDUMPC(body, strlen(body), 0x10); b64 = 1; break; } b++; } DEBUG_RET(); return b64; } void find_html_charset(char *html, char *charset, size_t charsetlen) { const int index = 1; const int nmatch = index+1; regmatch_t match[nmatch]; DEBUG_ENT("find_html_charset"); int rc = regexec(&meta_charset_pattern, html, nmatch, match, 0); if (rc == 0) { int s = match[index].rm_so; int e = match[index].rm_eo; if (s != -1) { char save = html[e]; html[e] = '\0'; snprintf(charset, charsetlen, "%s", html+s); // copy the html charset html[e] = save; DEBUG_INFO(("charset %s from html text\n", charset)); } else { DEBUG_INFO(("matching %d %d %d %d\n", match[0].rm_so, match[0].rm_eo, match[1].rm_so, match[1].rm_eo)); DEBUG_HEXDUMPC(html, strlen(html), 0x10); } } else { DEBUG_INFO(("regexec returns %d\n", rc)); } DEBUG_RET(); } void find_rfc822_headers(char** extra_mime_headers) { DEBUG_ENT("find_rfc822_headers"); char *headers = *extra_mime_headers; if (headers) { char *temp, *t; while ((temp = strstr(headers, "\n\n"))) { temp[1] = '\0'; t = header_get_field(headers, "\nContent-Type:"); if (t) { t++; DEBUG_INFO(("found content type header\n")); char *n = strchr(t, '\n'); char *s = strstr(t, ": "); char *e = strchr(t, ';'); if (!e || (e > n)) e = n; if (s && (s < e)) { s += 2; if (!strncasecmp(s, RFC822, e-s)) { headers = temp+2; // found rfc822 header DEBUG_INFO(("found 822 headers\n%s\n", headers)); break; } } } //DEBUG_INFO(("skipping to next block after\n%s\n", headers)); headers = temp+2; // skip to next chunk of headers } *extra_mime_headers = headers; } DEBUG_RET(); } void write_body_part(FILE* f_output, pst_string *body, char *mime, char *charset, char *boundary, pst_file* pst) { DEBUG_ENT("write_body_part"); removeCR(body->str); size_t body_len = strlen(body->str); if (body->is_utf8 && (strcasecmp("utf-8", charset))) { if (prefer_utf8) { charset = "utf-8"; } else { // try to convert to the specified charset since the target // is not utf-8, and the data came from a unicode (utf16) field // and is now in utf-8. size_t rc; DEBUG_INFO(("Convert %s utf-8 to %s\n", mime, charset)); pst_vbuf *newer = pst_vballoc(2); rc = pst_vb_utf8to8bit(newer, body->str, body_len, charset); if (rc == (size_t)-1) { // unable to convert, change the charset to utf8 free(newer->b); DEBUG_INFO(("Failed to convert %s utf-8 to %s\n", mime, charset)); charset = "utf-8"; } else { // null terminate the output string pst_vbgrow(newer, 1); newer->b[newer->dlen] = '\0'; free(body->str); body->str = newer->b; body_len = newer->dlen; } free(newer); } } int base64 = test_base64(body->str, body_len); fprintf(f_output, "\n--%s\n", boundary); fprintf(f_output, "Content-Type: %s; charset=\"%s\"\n", mime, charset); if (base64) fprintf(f_output, "Content-Transfer-Encoding: base64\n"); fprintf(f_output, "\n"); // Any body that uses an encoding with NULLs, e.g. UTF16, will be base64-encoded here. if (base64) { char *enc = pst_base64_encode(body->str, body_len); if (enc) { write_email_body(f_output, enc); fprintf(f_output, "\n"); free(enc); } } else { write_email_body(f_output, body->str); } DEBUG_RET(); } void write_schedule_part_data(FILE* f_output, pst_item* item, const char* sender, const char* method) { fprintf(f_output, "BEGIN:VCALENDAR\n"); fprintf(f_output, "VERSION:2.0\n"); fprintf(f_output, "PRODID:LibPST v%s\n", VERSION); if (method) fprintf(f_output, "METHOD:%s\n", method); fprintf(f_output, "BEGIN:VEVENT\n"); if (sender) { if (item->email->outlook_sender_name.str) { fprintf(f_output, "ORGANIZER;CN=\"%s\":MAILTO:%s\n", item->email->outlook_sender_name.str, sender); } else { fprintf(f_output, "ORGANIZER;CN=\"\":MAILTO:%s\n", sender); } } write_appointment(f_output, item); fprintf(f_output, "END:VCALENDAR\n"); } void write_schedule_part(FILE* f_output, pst_item* item, const char* sender, const char* boundary) { const char* method = "REQUEST"; const char* charset = "utf-8"; char fname[30]; if (!item->appointment) return; // inline appointment request fprintf(f_output, "\n--%s\n", boundary); fprintf(f_output, "Content-Type: %s; method=\"%s\"; charset=\"%s\"\n\n", "text/calendar", method, charset); write_schedule_part_data(f_output, item, sender, method); fprintf(f_output, "\n"); // attachment appointment request snprintf(fname, sizeof(fname), "i%i.ics", rand()); fprintf(f_output, "\n--%s\n", boundary); fprintf(f_output, "Content-Type: %s; charset=\"%s\"; name=\"%s\"\n", "text/calendar", "utf-8", fname); fprintf(f_output, "Content-Disposition: attachment; filename=\"%s\"\n\n", fname); write_schedule_part_data(f_output, item, sender, method); fprintf(f_output, "\n"); } void write_normal_email(FILE* f_output, char f_name[], pst_item* item, int mode, int mode_MH, pst_file* pst, int save_rtf, int embedding, char** extra_mime_headers) { char boundary[60]; char altboundary[66]; char *altboundaryp = NULL; char body_charset[30]; char buffer_charset[30]; char body_report[60]; char sender[60]; int sender_known = 0; char *temp = NULL; time_t em_time; char *c_time; char *headers = NULL; int has_from, has_subject, has_to, has_cc, has_date, has_msgid; has_from = has_subject = has_to = has_cc = has_date = has_msgid = 0; DEBUG_ENT("write_normal_email"); pst_convert_utf8_null(item, &item->email->header); headers = valid_headers(item->email->header.str) ? item->email->header.str : valid_headers(*extra_mime_headers) ? *extra_mime_headers : NULL; // setup default body character set and report type strncpy(body_charset, pst_default_charset(item, sizeof(buffer_charset), buffer_charset), sizeof(body_charset)); body_charset[sizeof(body_charset)-1] = '\0'; strncpy(body_report, "delivery-status", sizeof(body_report)); body_report[sizeof(body_report)-1] = '\0'; // setup default sender pst_convert_utf8(item, &item->email->sender_address); if (item->email->sender_address.str && strchr(item->email->sender_address.str, '@')) { temp = item->email->sender_address.str; sender_known = 1; } else { temp = "MAILER-DAEMON"; } strncpy(sender, temp, sizeof(sender)); sender[sizeof(sender)-1] = '\0'; // convert the sent date if it exists, or set it to a fixed date if (item->email->sent_date) { em_time = pst_fileTimeToUnixTime(item->email->sent_date); c_time = ctime(&em_time); if (c_time) c_time[strlen(c_time)-1] = '\0'; //remove end \n else c_time = "Thu Jan 1 00:00:00 1970"; } else c_time = "Thu Jan 1 00:00:00 1970"; // create our MIME boundaries here. snprintf(boundary, sizeof(boundary), "--boundary-LibPST-iamunique-%i_-_-", rand()); snprintf(altboundary, sizeof(altboundary), "alt-%s", boundary); // we will always look at the headers to discover some stuff if (headers ) { char *t; removeCR(headers); temp = strstr(headers, "\n\n"); if (temp) { // cut off our real rfc822 headers here temp[1] = '\0'; // pointer to all the embedded MIME headers. // we use these to find the actual rfc822 headers for embedded message/rfc822 mime parts // but only for the outermost message if (!*extra_mime_headers) *extra_mime_headers = temp+2; DEBUG_INFO(("Found extra mime headers\n%s\n", temp+2)); } // Check if the headers have all the necessary fields header_has_field(headers, "\nFrom:", &has_from); header_has_field(headers, "\nTo:", &has_to); header_has_field(headers, "\nSubject:", &has_subject); header_has_field(headers, "\nDate:", &has_date); header_has_field(headers, "\nCC:", &has_cc); header_has_field(headers, "\nMessage-Id:", &has_msgid); // look for charset and report-type in Content-Type header t = header_get_field(headers, "\nContent-Type:"); header_get_subfield(t, "charset", body_charset, sizeof(body_charset)); header_get_subfield(t, "report-type", body_report, sizeof(body_report)); // derive a proper sender email address if (!sender_known) { t = header_get_field(headers, "\nFrom:"); if (t) { // assume address is on the first line, rather than on a continuation line t++; char *n = strchr(t, '\n'); char *s = strchr(t, '<'); char *e = strchr(t, '>'); if (s && e && n && (s < e) && (e < n)) { char save = *e; *e = '\0'; snprintf(sender, sizeof(sender), "%s", s+1); *e = save; } } } // Strip out the mime headers and some others that we don't want to emit header_strip_field(headers, "\nMicrosoft Mail Internet Headers"); header_strip_field(headers, "\nMIME-Version:"); header_strip_field(headers, "\nContent-Type:"); header_strip_field(headers, "\nContent-Transfer-Encoding:"); header_strip_field(headers, "\nContent-class:"); header_strip_field(headers, "\nX-MimeOLE:"); header_strip_field(headers, "\nX-From_:"); } DEBUG_INFO(("About to print Header\n")); if (item && item->subject.str) { pst_convert_utf8(item, &item->subject); DEBUG_INFO(("item->subject = %s\n", item->subject.str)); } if (mode != MODE_SEPARATE) { // most modes need this separator line. // procmail produces this separator without the quotes around the // sender email address, but apparently some Mac email client needs // those quotes, and they don't seem to cause problems for anyone else. char *quo = (embedding) ? ">" : ""; fprintf(f_output, "%sFrom \"%s\" %s\n", quo, sender, c_time); } // print the supplied email headers if (headers) { int len = strlen(headers); if (len > 0) { fprintf(f_output, "%s", headers); // make sure the headers end with a \n if (headers[len-1] != '\n') fprintf(f_output, "\n"); //char *h = headers; //while (*h) { // char *e = strchr(h, '\n'); // int d = 1; // normally e points to trailing \n // if (!e) { // e = h + strlen(h); // e points to trailing null // d = 0; // } // // we could do rfc2047 encoding here if needed // fprintf(f_output, "%.*s\n", (int)(e-h), h); // h = e + d; //} } } // record read status if ((item->flags & PST_FLAG_READ) == PST_FLAG_READ) { fprintf(f_output, "Status: RO\n"); } // create required header fields that are not already written if (!has_from) { if (item->email->outlook_sender_name.str){ pst_rfc2047(item, &item->email->outlook_sender_name, 1); fprintf(f_output, "From: %s <%s>\n", item->email->outlook_sender_name.str, sender); } else { fprintf(f_output, "From: <%s>\n", sender); } } if (!has_subject) { if (item->subject.str) { pst_rfc2047(item, &item->subject, 0); fprintf(f_output, "Subject: %s\n", item->subject.str); } else { fprintf(f_output, "Subject: \n"); } } if (!has_to && item->email->sentto_address.str) { pst_rfc2047(item, &item->email->sentto_address, 0); fprintf(f_output, "To: %s\n", item->email->sentto_address.str); } if (!has_cc && item->email->cc_address.str) { pst_rfc2047(item, &item->email->cc_address, 0); fprintf(f_output, "Cc: %s\n", item->email->cc_address.str); } if (!has_date && item->email->sent_date) { char c_time[C_TIME_SIZE]; struct tm stm; gmtime_r(&em_time, &stm); strftime(c_time, C_TIME_SIZE, "%a, %d %b %Y %H:%M:%S %z", &stm); fprintf(f_output, "Date: %s\n", c_time); } if (!has_msgid && item->email->messageid.str) { pst_convert_utf8(item, &item->email->messageid); fprintf(f_output, "Message-Id: %s\n", item->email->messageid.str); } // add forensic headers to capture some .pst stuff that is not really // needed or used by mail clients pst_convert_utf8_null(item, &item->email->sender_address); if (item->email->sender_address.str && !strchr(item->email->sender_address.str, '@') && strcmp(item->email->sender_address.str, ".") && (strlen(item->email->sender_address.str) > 0)) { fprintf(f_output, "X-libpst-forensic-sender: %s\n", item->email->sender_address.str); } if (item->email->bcc_address.str) { pst_convert_utf8(item, &item->email->bcc_address); fprintf(f_output, "X-libpst-forensic-bcc: %s\n", item->email->bcc_address.str); } // add our own mime headers fprintf(f_output, "MIME-Version: 1.0\n"); if (item->type == PST_TYPE_REPORT) { // multipart/report for DSN/MDN reports fprintf(f_output, "Content-Type: multipart/report; report-type=%s;\n\tboundary=\"%s\"\n", body_report, boundary); } else { fprintf(f_output, "Content-Type: multipart/mixed;\n\tboundary=\"%s\"\n", boundary); } fprintf(f_output, "\n"); // end of headers, start of body // now dump the body parts if ((item->type == PST_TYPE_REPORT) && (item->email->report_text.str)) { write_body_part(f_output, &item->email->report_text, "text/plain", body_charset, boundary, pst); fprintf(f_output, "\n"); } if (item->body.str && item->email->htmlbody.str) { // start the nested alternative part fprintf(f_output, "\n--%s\n", boundary); fprintf(f_output, "Content-Type: multipart/alternative;\n\tboundary=\"%s\"\n", altboundary); altboundaryp = altboundary; } else { altboundaryp = boundary; } if (item->body.str) { write_body_part(f_output, &item->body, "text/plain", body_charset, altboundaryp, pst); } if (item->email->htmlbody.str) { find_html_charset(item->email->htmlbody.str, body_charset, sizeof(body_charset)); write_body_part(f_output, &item->email->htmlbody, "text/html", body_charset, altboundaryp, pst); } if (item->body.str && item->email->htmlbody.str) { // end the nested alternative part fprintf(f_output, "\n--%s--\n", altboundary); } if (item->email->rtf_compressed.data && save_rtf) { pst_item_attach* attach = (pst_item_attach*)pst_malloc(sizeof(pst_item_attach)); DEBUG_INFO(("Adding RTF body as attachment\n")); memset(attach, 0, sizeof(pst_item_attach)); attach->next = item->attach; item->attach = attach; attach->data.data = pst_lzfu_decompress(item->email->rtf_compressed.data, item->email->rtf_compressed.size, &attach->data.size); attach->filename2.str = strdup(RTF_ATTACH_NAME); attach->filename2.is_utf8 = 1; attach->mimetype.str = strdup(RTF_ATTACH_TYPE); attach->mimetype.is_utf8 = 1; } if (item->email->encrypted_body.data) { pst_item_attach* attach = (pst_item_attach*)pst_malloc(sizeof(pst_item_attach)); DEBUG_INFO(("Adding encrypted text body as attachment\n")); memset(attach, 0, sizeof(pst_item_attach)); attach->next = item->attach; item->attach = attach; attach->data.data = item->email->encrypted_body.data; attach->data.size = item->email->encrypted_body.size; item->email->encrypted_body.data = NULL; } if (item->email->encrypted_htmlbody.data) { pst_item_attach* attach = (pst_item_attach*)pst_malloc(sizeof(pst_item_attach)); DEBUG_INFO(("Adding encrypted HTML body as attachment\n")); memset(attach, 0, sizeof(pst_item_attach)); attach->next = item->attach; item->attach = attach; attach->data.data = item->email->encrypted_htmlbody.data; attach->data.size = item->email->encrypted_htmlbody.size; item->email->encrypted_htmlbody.data = NULL; } if (item->type == PST_TYPE_SCHEDULE) { write_schedule_part(f_output, item, sender, boundary); } // other attachments { pst_item_attach* attach; int attach_num = 0; for (attach = item->attach; attach; attach = attach->next) { pst_convert_utf8_null(item, &attach->filename1); pst_convert_utf8_null(item, &attach->filename2); pst_convert_utf8_null(item, &attach->mimetype); DEBUG_INFO(("Attempting Attachment encoding\n")); if (attach->method == PST_ATTACH_EMBEDDED) { DEBUG_INFO(("have an embedded rfc822 message attachment\n")); if (attach->mimetype.str) { DEBUG_INFO(("which already has a mime-type of %s\n", attach->mimetype.str)); free(attach->mimetype.str); } attach->mimetype.str = strdup(RFC822); attach->mimetype.is_utf8 = 1; find_rfc822_headers(extra_mime_headers); write_embedded_message(f_output, attach, boundary, pst, save_rtf, extra_mime_headers); } else if (attach->data.data || attach->i_id) { if (acceptable_ext(attach)) { if (mode == MODE_SEPARATE && !mode_MH) write_separate_attachment(f_name, attach, ++attach_num, pst); else write_inline_attachment(f_output, attach, boundary, pst); } } } } fprintf(f_output, "\n--%s--\n\n", boundary); DEBUG_RET(); } void write_vcard(FILE* f_output, pst_item* item, pst_item_contact* contact, char comment[]) { char* result = NULL; size_t resultlen = 0; char time_buffer[30]; // We can only call rfc escape once per printf, since the second call // may free the buffer returned by the first call. // I had tried to place those into a single printf - Carl. DEBUG_ENT("write_vcard"); // make everything utf8 pst_convert_utf8_null(item, &contact->fullname); pst_convert_utf8_null(item, &contact->surname); pst_convert_utf8_null(item, &contact->first_name); pst_convert_utf8_null(item, &contact->middle_name); pst_convert_utf8_null(item, &contact->display_name_prefix); pst_convert_utf8_null(item, &contact->suffix); pst_convert_utf8_null(item, &contact->nickname); pst_convert_utf8_null(item, &contact->address1); pst_convert_utf8_null(item, &contact->address2); pst_convert_utf8_null(item, &contact->address3); pst_convert_utf8_null(item, &contact->home_po_box); pst_convert_utf8_null(item, &contact->home_street); pst_convert_utf8_null(item, &contact->home_city); pst_convert_utf8_null(item, &contact->home_state); pst_convert_utf8_null(item, &contact->home_postal_code); pst_convert_utf8_null(item, &contact->home_country); pst_convert_utf8_null(item, &contact->home_address); pst_convert_utf8_null(item, &contact->business_po_box); pst_convert_utf8_null(item, &contact->business_street); pst_convert_utf8_null(item, &contact->business_city); pst_convert_utf8_null(item, &contact->business_state); pst_convert_utf8_null(item, &contact->business_postal_code); pst_convert_utf8_null(item, &contact->business_country); pst_convert_utf8_null(item, &contact->business_address); pst_convert_utf8_null(item, &contact->other_po_box); pst_convert_utf8_null(item, &contact->other_street); pst_convert_utf8_null(item, &contact->other_city); pst_convert_utf8_null(item, &contact->other_state); pst_convert_utf8_null(item, &contact->other_postal_code); pst_convert_utf8_null(item, &contact->other_country); pst_convert_utf8_null(item, &contact->other_address); pst_convert_utf8_null(item, &contact->business_fax); pst_convert_utf8_null(item, &contact->business_phone); pst_convert_utf8_null(item, &contact->business_phone2); pst_convert_utf8_null(item, &contact->car_phone); pst_convert_utf8_null(item, &contact->home_fax); pst_convert_utf8_null(item, &contact->home_phone); pst_convert_utf8_null(item, &contact->home_phone2); pst_convert_utf8_null(item, &contact->isdn_phone); pst_convert_utf8_null(item, &contact->mobile_phone); pst_convert_utf8_null(item, &contact->other_phone); pst_convert_utf8_null(item, &contact->pager_phone); pst_convert_utf8_null(item, &contact->primary_fax); pst_convert_utf8_null(item, &contact->primary_phone); pst_convert_utf8_null(item, &contact->radio_phone); pst_convert_utf8_null(item, &contact->telex); pst_convert_utf8_null(item, &contact->job_title); pst_convert_utf8_null(item, &contact->profession); pst_convert_utf8_null(item, &contact->assistant_name); pst_convert_utf8_null(item, &contact->assistant_phone); pst_convert_utf8_null(item, &contact->company_name); pst_convert_utf8_null(item, &item->body); // the specification I am following is (hopefully) RFC2426 vCard Mime Directory Profile fprintf(f_output, "BEGIN:VCARD\n"); fprintf(f_output, "FN:%s\n", pst_rfc2426_escape(contact->fullname.str, &result, &resultlen)); //fprintf(f_output, "N:%s;%s;%s;%s;%s\n", fprintf(f_output, "N:%s;", (!contact->surname.str) ? "" : pst_rfc2426_escape(contact->surname.str, &result, &resultlen)); fprintf(f_output, "%s;", (!contact->first_name.str) ? "" : pst_rfc2426_escape(contact->first_name.str, &result, &resultlen)); fprintf(f_output, "%s;", (!contact->middle_name.str) ? "" : pst_rfc2426_escape(contact->middle_name.str, &result, &resultlen)); fprintf(f_output, "%s;", (!contact->display_name_prefix.str) ? "" : pst_rfc2426_escape(contact->display_name_prefix.str, &result, &resultlen)); fprintf(f_output, "%s\n", (!contact->suffix.str) ? "" : pst_rfc2426_escape(contact->suffix.str, &result, &resultlen)); if (contact->nickname.str) fprintf(f_output, "NICKNAME:%s\n", pst_rfc2426_escape(contact->nickname.str, &result, &resultlen)); if (contact->address1.str) fprintf(f_output, "EMAIL:%s\n", pst_rfc2426_escape(contact->address1.str, &result, &resultlen)); if (contact->address2.str) fprintf(f_output, "EMAIL:%s\n", pst_rfc2426_escape(contact->address2.str, &result, &resultlen)); if (contact->address3.str) fprintf(f_output, "EMAIL:%s\n", pst_rfc2426_escape(contact->address3.str, &result, &resultlen)); if (contact->birthday) fprintf(f_output, "BDAY:%s\n", pst_rfc2425_datetime_format(contact->birthday, sizeof(time_buffer), time_buffer)); if (contact->home_address.str) { //fprintf(f_output, "ADR;TYPE=home:%s;%s;%s;%s;%s;%s;%s\n", fprintf(f_output, "ADR;TYPE=home:%s;", (!contact->home_po_box.str) ? "" : pst_rfc2426_escape(contact->home_po_box.str, &result, &resultlen)); fprintf(f_output, "%s;", ""); // extended Address fprintf(f_output, "%s;", (!contact->home_street.str) ? "" : pst_rfc2426_escape(contact->home_street.str, &result, &resultlen)); fprintf(f_output, "%s;", (!contact->home_city.str) ? "" : pst_rfc2426_escape(contact->home_city.str, &result, &resultlen)); fprintf(f_output, "%s;", (!contact->home_state.str) ? "" : pst_rfc2426_escape(contact->home_state.str, &result, &resultlen)); fprintf(f_output, "%s;", (!contact->home_postal_code.str) ? "" : pst_rfc2426_escape(contact->home_postal_code.str, &result, &resultlen)); fprintf(f_output, "%s\n", (!contact->home_country.str) ? "" : pst_rfc2426_escape(contact->home_country.str, &result, &resultlen)); fprintf(f_output, "LABEL;TYPE=home:%s\n", pst_rfc2426_escape(contact->home_address.str, &result, &resultlen)); } if (contact->business_address.str) { //fprintf(f_output, "ADR;TYPE=work:%s;%s;%s;%s;%s;%s;%s\n", fprintf(f_output, "ADR;TYPE=work:%s;", (!contact->business_po_box.str) ? "" : pst_rfc2426_escape(contact->business_po_box.str, &result, &resultlen)); fprintf(f_output, "%s;", ""); // extended Address fprintf(f_output, "%s;", (!contact->business_street.str) ? "" : pst_rfc2426_escape(contact->business_street.str, &result, &resultlen)); fprintf(f_output, "%s;", (!contact->business_city.str) ? "" : pst_rfc2426_escape(contact->business_city.str, &result, &resultlen)); fprintf(f_output, "%s;", (!contact->business_state.str) ? "" : pst_rfc2426_escape(contact->business_state.str, &result, &resultlen)); fprintf(f_output, "%s;", (!contact->business_postal_code.str) ? "" : pst_rfc2426_escape(contact->business_postal_code.str, &result, &resultlen)); fprintf(f_output, "%s\n", (!contact->business_country.str) ? "" : pst_rfc2426_escape(contact->business_country.str, &result, &resultlen)); fprintf(f_output, "LABEL;TYPE=work:%s\n", pst_rfc2426_escape(contact->business_address.str, &result, &resultlen)); } if (contact->other_address.str) { //fprintf(f_output, "ADR;TYPE=postal:%s;%s;%s;%s;%s;%s;%s\n", fprintf(f_output, "ADR;TYPE=postal:%s;",(!contact->other_po_box.str) ? "" : pst_rfc2426_escape(contact->other_po_box.str, &result, &resultlen)); fprintf(f_output, "%s;", ""); // extended Address fprintf(f_output, "%s;", (!contact->other_street.str) ? "" : pst_rfc2426_escape(contact->other_street.str, &result, &resultlen)); fprintf(f_output, "%s;", (!contact->other_city.str) ? "" : pst_rfc2426_escape(contact->other_city.str, &result, &resultlen)); fprintf(f_output, "%s;", (!contact->other_state.str) ? "" : pst_rfc2426_escape(contact->other_state.str, &result, &resultlen)); fprintf(f_output, "%s;", (!contact->other_postal_code.str) ? "" : pst_rfc2426_escape(contact->other_postal_code.str, &result, &resultlen)); fprintf(f_output, "%s\n", (!contact->other_country.str) ? "" : pst_rfc2426_escape(contact->other_country.str, &result, &resultlen)); fprintf(f_output, "LABEL;TYPE=postal:%s\n", pst_rfc2426_escape(contact->other_address.str, &result, &resultlen)); } if (contact->business_fax.str) fprintf(f_output, "TEL;TYPE=work,fax:%s\n", pst_rfc2426_escape(contact->business_fax.str, &result, &resultlen)); if (contact->business_phone.str) fprintf(f_output, "TEL;TYPE=work,voice:%s\n", pst_rfc2426_escape(contact->business_phone.str, &result, &resultlen)); if (contact->business_phone2.str) fprintf(f_output, "TEL;TYPE=work,voice:%s\n", pst_rfc2426_escape(contact->business_phone2.str, &result, &resultlen)); if (contact->car_phone.str) fprintf(f_output, "TEL;TYPE=car,voice:%s\n", pst_rfc2426_escape(contact->car_phone.str, &result, &resultlen)); if (contact->home_fax.str) fprintf(f_output, "TEL;TYPE=home,fax:%s\n", pst_rfc2426_escape(contact->home_fax.str, &result, &resultlen)); if (contact->home_phone.str) fprintf(f_output, "TEL;TYPE=home,voice:%s\n", pst_rfc2426_escape(contact->home_phone.str, &result, &resultlen)); if (contact->home_phone2.str) fprintf(f_output, "TEL;TYPE=home,voice:%s\n", pst_rfc2426_escape(contact->home_phone2.str, &result, &resultlen)); if (contact->isdn_phone.str) fprintf(f_output, "TEL;TYPE=isdn:%s\n", pst_rfc2426_escape(contact->isdn_phone.str, &result, &resultlen)); if (contact->mobile_phone.str) fprintf(f_output, "TEL;TYPE=cell,voice:%s\n", pst_rfc2426_escape(contact->mobile_phone.str, &result, &resultlen)); if (contact->other_phone.str) fprintf(f_output, "TEL;TYPE=msg:%s\n", pst_rfc2426_escape(contact->other_phone.str, &result, &resultlen)); if (contact->pager_phone.str) fprintf(f_output, "TEL;TYPE=pager:%s\n", pst_rfc2426_escape(contact->pager_phone.str, &result, &resultlen)); if (contact->primary_fax.str) fprintf(f_output, "TEL;TYPE=fax,pref:%s\n", pst_rfc2426_escape(contact->primary_fax.str, &result, &resultlen)); if (contact->primary_phone.str) fprintf(f_output, "TEL;TYPE=phone,pref:%s\n", pst_rfc2426_escape(contact->primary_phone.str, &result, &resultlen)); if (contact->radio_phone.str) fprintf(f_output, "TEL;TYPE=pcs:%s\n", pst_rfc2426_escape(contact->radio_phone.str, &result, &resultlen)); if (contact->telex.str) fprintf(f_output, "TEL;TYPE=bbs:%s\n", pst_rfc2426_escape(contact->telex.str, &result, &resultlen)); if (contact->job_title.str) fprintf(f_output, "TITLE:%s\n", pst_rfc2426_escape(contact->job_title.str, &result, &resultlen)); if (contact->profession.str) fprintf(f_output, "ROLE:%s\n", pst_rfc2426_escape(contact->profession.str, &result, &resultlen)); if (contact->assistant_name.str || contact->assistant_phone.str) { fprintf(f_output, "AGENT:BEGIN:VCARD\n"); if (contact->assistant_name.str) fprintf(f_output, "FN:%s\n", pst_rfc2426_escape(contact->assistant_name.str, &result, &resultlen)); if (contact->assistant_phone.str) fprintf(f_output, "TEL:%s\n", pst_rfc2426_escape(contact->assistant_phone.str, &result, &resultlen)); } if (contact->company_name.str) fprintf(f_output, "ORG:%s\n", pst_rfc2426_escape(contact->company_name.str, &result, &resultlen)); if (comment) fprintf(f_output, "NOTE:%s\n", pst_rfc2426_escape(comment, &result, &resultlen)); if (item->body.str) fprintf(f_output, "NOTE:%s\n", pst_rfc2426_escape(item->body.str, &result, &resultlen)); write_extra_categories(f_output, item); fprintf(f_output, "VERSION: 3.0\n"); fprintf(f_output, "END:VCARD\n\n"); if (result) free(result); DEBUG_RET(); } /** * write extra vcard or vcalendar categories from the extra keywords fields * * @param f_output open file pointer * @param item pst item containing the keywords * @return true if we write a categories line */ int write_extra_categories(FILE* f_output, pst_item* item) { char* result = NULL; size_t resultlen = 0; pst_item_extra_field *ef = item->extra_fields; const char *fmt = "CATEGORIES:%s"; int category_started = 0; while (ef) { if (strcmp(ef->field_name, "Keywords") == 0) { fprintf(f_output, fmt, pst_rfc2426_escape(ef->value, &result, &resultlen)); fmt = ", %s"; category_started = 1; } ef = ef->next; } if (category_started) fprintf(f_output, "\n"); if (result) free(result); return category_started; } void write_journal(FILE* f_output, pst_item* item) { char* result = NULL; size_t resultlen = 0; char time_buffer[30]; pst_item_journal* journal = item->journal; // make everything utf8 pst_convert_utf8_null(item, &item->subject); pst_convert_utf8_null(item, &item->body); fprintf(f_output, "BEGIN:VJOURNAL\n"); fprintf(f_output, "DTSTAMP:%s\n", pst_rfc2445_datetime_format_now(sizeof(time_buffer), time_buffer)); if (item->create_date) fprintf(f_output, "CREATED:%s\n", pst_rfc2445_datetime_format(item->create_date, sizeof(time_buffer), time_buffer)); if (item->modify_date) fprintf(f_output, "LAST-MOD:%s\n", pst_rfc2445_datetime_format(item->modify_date, sizeof(time_buffer), time_buffer)); if (item->subject.str) fprintf(f_output, "SUMMARY:%s\n", pst_rfc2426_escape(item->subject.str, &result, &resultlen)); if (item->body.str) fprintf(f_output, "DESCRIPTION:%s\n", pst_rfc2426_escape(item->body.str, &result, &resultlen)); if (journal && journal->start) fprintf(f_output, "DTSTART;VALUE=DATE-TIME:%s\n", pst_rfc2445_datetime_format(journal->start, sizeof(time_buffer), time_buffer)); fprintf(f_output, "END:VJOURNAL\n"); if (result) free(result); } void write_appointment(FILE* f_output, pst_item* item) { char* result = NULL; size_t resultlen = 0; char time_buffer[30]; pst_item_appointment* appointment = item->appointment; // make everything utf8 pst_convert_utf8_null(item, &item->subject); pst_convert_utf8_null(item, &item->body); pst_convert_utf8_null(item, &appointment->location); fprintf(f_output, "UID:%#"PRIx64"\n", item->block_id); fprintf(f_output, "DTSTAMP:%s\n", pst_rfc2445_datetime_format_now(sizeof(time_buffer), time_buffer)); if (item->create_date) fprintf(f_output, "CREATED:%s\n", pst_rfc2445_datetime_format(item->create_date, sizeof(time_buffer), time_buffer)); if (item->modify_date) fprintf(f_output, "LAST-MOD:%s\n", pst_rfc2445_datetime_format(item->modify_date, sizeof(time_buffer), time_buffer)); if (item->subject.str) fprintf(f_output, "SUMMARY:%s\n", pst_rfc2426_escape(item->subject.str, &result, &resultlen)); if (item->body.str) fprintf(f_output, "DESCRIPTION:%s\n", pst_rfc2426_escape(item->body.str, &result, &resultlen)); if (appointment && appointment->start) fprintf(f_output, "DTSTART;VALUE=DATE-TIME:%s\n", pst_rfc2445_datetime_format(appointment->start, sizeof(time_buffer), time_buffer)); if (appointment && appointment->end) fprintf(f_output, "DTEND;VALUE=DATE-TIME:%s\n", pst_rfc2445_datetime_format(appointment->end, sizeof(time_buffer), time_buffer)); if (appointment && appointment->location.str) fprintf(f_output, "LOCATION:%s\n", pst_rfc2426_escape(appointment->location.str, &result, &resultlen)); if (appointment) { switch (appointment->showas) { case PST_FREEBUSY_TENTATIVE: fprintf(f_output, "STATUS:TENTATIVE\n"); break; case PST_FREEBUSY_FREE: // mark as transparent and as confirmed fprintf(f_output, "TRANSP:TRANSPARENT\n"); case PST_FREEBUSY_BUSY: case PST_FREEBUSY_OUT_OF_OFFICE: fprintf(f_output, "STATUS:CONFIRMED\n"); break; } if (appointment->is_recurring) { const char* rules[] = {"DAILY", "WEEKLY", "MONTHLY", "YEARLY"}; const char* days[] = {"SU", "MO", "TU", "WE", "TH", "FR", "SA"}; pst_recurrence *rdata = pst_convert_recurrence(appointment); fprintf(f_output, "RRULE:FREQ=%s", rules[rdata->type]); if (rdata->count) fprintf(f_output, ";COUNT=%u", rdata->count); if ((rdata->interval != 1) && (rdata->interval)) fprintf(f_output, ";INTERVAL=%u", rdata->interval); if (rdata->dayofmonth) fprintf(f_output, ";BYMONTHDAY=%d", rdata->dayofmonth); if (rdata->monthofyear) fprintf(f_output, ";BYMONTH=%d", rdata->monthofyear); if (rdata->position) fprintf(f_output, ";BYSETPOS=%d", rdata->position); if (rdata->bydaymask) { char byday[40]; int empty = 1; int i=0; memset(byday, 0, sizeof(byday)); for (i=0; i<7; i++) { int bit = 1 << i; if (bit & rdata->bydaymask) { char temp[40]; snprintf(temp, sizeof(temp), "%s%s%s", byday, (empty) ? ";BYDAY=" : ";", days[i]); strcpy(byday, temp); empty = 0; } } fprintf(f_output, "%s", byday); } fprintf(f_output, "\n"); pst_free_recurrence(rdata); } switch (appointment->label) { case PST_APP_LABEL_NONE: if (!write_extra_categories(f_output, item)) fprintf(f_output, "CATEGORIES:NONE\n"); break; case PST_APP_LABEL_IMPORTANT: fprintf(f_output, "CATEGORIES:IMPORTANT\n"); break; case PST_APP_LABEL_BUSINESS: fprintf(f_output, "CATEGORIES:BUSINESS\n"); break; case PST_APP_LABEL_PERSONAL: fprintf(f_output, "CATEGORIES:PERSONAL\n"); break; case PST_APP_LABEL_VACATION: fprintf(f_output, "CATEGORIES:VACATION\n"); break; case PST_APP_LABEL_MUST_ATTEND: fprintf(f_output, "CATEGORIES:MUST-ATTEND\n"); break; case PST_APP_LABEL_TRAVEL_REQ: fprintf(f_output, "CATEGORIES:TRAVEL-REQUIRED\n"); break; case PST_APP_LABEL_NEEDS_PREP: fprintf(f_output, "CATEGORIES:NEEDS-PREPARATION\n"); break; case PST_APP_LABEL_BIRTHDAY: fprintf(f_output, "CATEGORIES:BIRTHDAY\n"); break; case PST_APP_LABEL_ANNIVERSARY: fprintf(f_output, "CATEGORIES:ANNIVERSARY\n"); break; case PST_APP_LABEL_PHONE_CALL: fprintf(f_output, "CATEGORIES:PHONE-CALL\n"); break; } // ignore bogus alarms if (appointment->alarm && (appointment->alarm_minutes >= 0) && (appointment->alarm_minutes < 1440)) { fprintf(f_output, "BEGIN:VALARM\n"); fprintf(f_output, "TRIGGER:-PT%dM\n", appointment->alarm_minutes); fprintf(f_output, "ACTION:DISPLAY\n"); fprintf(f_output, "DESCRIPTION:Reminder\n"); fprintf(f_output, "END:VALARM\n"); } } fprintf(f_output, "END:VEVENT\n"); if (result) free(result); } void create_enter_dir(struct file_ll* f, pst_item *item) { memset(f, 0, sizeof(*f)); f->stored_count = (item->folder) ? item->folder->item_count : 0; pst_convert_utf8(item, &item->file_as); f->dname = (char*) pst_malloc(strlen(item->file_as.str)+1); strcpy(f->dname, item->file_as.str); DEBUG_ENT("create_enter_dir"); if (mode == MODE_KMAIL) { int32_t t; mk_kmail_dir(item->file_as.str); for (t=0; tname[t] = (char*) pst_malloc(strlen(item->file_as.str)+strlen(OUTPUT_TEMPLATE)+30); sprintf(f->name[t], OUTPUT_TEMPLATE, item->file_as.str, item_type_to_name(t)); } } } else if (mode == MODE_RECURSE) { int32_t t; mk_recurse_dir(item->file_as.str); for (t=0; tname[t] = strdup(item_type_to_name(t)); } } if (mode_thunder) { FILE *type_file = fopen(".type", "w"); fprintf(type_file, "%d\n", item->type); fclose(type_file); } } else if (mode == MODE_SEPARATE) { // do similar stuff to recurse here. int32_t t; mk_separate_dir(item->file_as.str); for (t=0; tname[t] = (char*) pst_malloc(file_name_len); memset(f->name[t], 0, file_name_len); } } } else { // MODE_NORMAL int32_t t; for (t=0; tname[t] = (char*) pst_malloc(strlen(item->file_as.str)+strlen(OUTPUT_TEMPLATE)+30); sprintf(f->name[t], OUTPUT_TEMPLATE, item->file_as.str, item_type_to_name(t)); } } } if (mode != MODE_SEPARATE) { int32_t t; for (t=0; tname[t]) { if (!overwrite) { int x = 0; char *temp = (char*) pst_malloc (strlen(f->name[t])+10); //enough room for 10 digits sprintf(temp, "%s", f->name[t]); check_filename(temp); while ((f->output[t] = fopen(temp, "r"))) { DEBUG_INFO(("need to increase filename because one already exists with that name\n")); x++; sprintf(temp, "%s%08d", f->name[t], x); DEBUG_INFO(("- bump file name and try \"%s\"\n", temp)); if (x == 99999999) { DIE(("create_enter_dir: Why can I not create a folder %s? I have tried %i extensions...\n", f->name[t], x)); } fclose(f->output[t]); } if (x > 0) { //then the f->name should change free (f->name[t]); f->name[t] = temp; } else { free(temp); } } check_filename(f->name[t]); if (!(f->output[t] = fopen(f->name[t], "w"))) { DIE(("create_enter_dir: Could not open file \"%s\" for write\n", f->name[t])); } DEBUG_INFO(("f->name = %s\nitem->folder_name = %s\n", f->name[t], item->file_as.str)); } } } DEBUG_RET(); } void close_enter_dir(struct file_ll *f) { int32_t t; DEBUG_INFO(("processed item count for folder %s is %i, skipped %i, total %i \n", f->dname, f->item_count, f->skip_count, f->stored_count)); if (output_mode != OUTPUT_QUIET) { pst_debug_lock(); printf("\t\"%s\" - %i items done, %i items skipped.\n", f->dname, f->item_count, f->skip_count); fflush(stdout); pst_debug_unlock(); } for (t=0; toutput[t]) { if (mode == MODE_SEPARATE) DEBUG_WARN(("close_enter_dir finds open separate file\n")); fclose(f->output[t]); f->output[t] = NULL; } if (f->name[t]) { struct stat st; stat(f->name[t], &st); if (!st.st_size) { DEBUG_WARN(("removing empty output file %s\n", f->name[t])); remove(f->name[t]); } free(f->name[t]); f->name[t] = NULL; } } free(f->dname); if (mode == MODE_KMAIL) close_kmail_dir(); else if (mode == MODE_RECURSE) { if (mode_thunder) { FILE *type_file = fopen(".size", "w"); fprintf(type_file, "%i %i\n", f->item_count, f->stored_count); fclose(type_file); } close_recurse_dir(); } else if (mode == MODE_SEPARATE) close_separate_dir(); } diff --git a/xml/libpst.in b/xml/libpst.in index c5787ee..4180fb3 100644 --- a/xml/libpst.in +++ b/xml/libpst.in @@ -1,2055 +1,2055 @@ @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@/. The most recent developer documentation for the shared library is available at http://www.five-ten-sg.com/@PACKAGE@/devel/. 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. 2017-12-07 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 default-charset Set the character set to be used for items with an unspecified character set. -D Include deleted items in the output. -M Output messages in MH (rfc822) format as separate files. This will create folders as named in the PST file, and will put each email together with any attachments into its own file. These files will be numbered from 1 to n with no leading zeros. This format has no from quoting. -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 to n with no leading zeros. Attachments will also be saved in the same folder as the email message. The attachments for message $m are saved as $m-$name where $name is (the original name of the attachment, or 'attach$n' if the attachment had no name), where $n is another sequential index with no leading zeros. This format has no from quoting. -V Show program version and exit. -a attachment-extension-list Set the list of acceptable attachment extensions. Any attachment that does not have an extension on this list will be discarded. All attachments are acceptable if the list is empty, or this option is not specified. -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 now an ascii file, instead of the binary file used in previous versions. -e Same as the M option, but each output file will include an extension from (.eml, .ics, .vcf). This format has no from quoting. -h Show summary of options and exit. -j jobs Specifies the maximum number of parallel jobs. Specify 0 to suppress running parallel jobs. Folders may be processed in parallel. Output formats that place each mail message in a separate file (-M, -S, -e) may process the contents of individual folders in parallel. -k Changes the output format to KMail. This format uses mboxrd from quoting. -m Same as the e option, but write .msg files also -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. Appointments go into a file called "calendar", address book entries go into a file called "contacts", and journal entries go into a file called "journal". These files are then compatible with all mbox-compatible email clients. This format uses mboxrd from quoting. -t output-type-codes Specifies the item types that are processed. The argument is a sequence of single letters from (e,a,j,c) for (email, appointment, journal, contact) types. The default is to process all item types. -u Sets Thunderbird mode, a submode of recursive mode. This causes two extra .type and .size meta files to be created. This format uses mboxrd from quoting. -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. -8 Output bodies in UTF-8, rather than original encoding, if a UTF-8 version is available. From Quoting Output formats that place each mail message in a separate file (-M, -S, -e, -m) don't do any from quoting. Output formats that place multiple email messages in a single file (-k, -r, -u) now use mboxrd from quoting rules. If none of those switches are specified, the default output format uses mboxrd from quoting rules, since it produces multiple email messages in a single file. Earlier versions used mboxo from quoting rules for all output formats. 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@ 2016-08-29 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 now an ascii file, instead of the binary file used in previous versions. -f date-format Select the date format for long format listing. Defaults to "%F %T". -l Use long format listing to show the Date, CC and BCC headers. -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). 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@ 2017-12-07 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. -d debug-file Specify name of debug log file. The log file is now an ascii file, instead of the binary file used in previous versions. -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@ 2017-12-07 pst2dii 1 pst2dii @VERSION@ pst2dii extract email messages from a MS Outlook .pst file in DII load format Synopsis pst2dii -f ttf-font-file 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 now an ascii file, instead of the binary file used in previous versions. -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@ 2017-12-07 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.