diff --git a/ChangeLog b/ChangeLog index 46b744a..cef14a1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,599 +1,603 @@ +LibPST 0.6.17 (2008-08-05) +=============================== + * More fixes for 32/64 bit portability on big endian ppc. + LibPST 0.6.16 (2008-08-05) =============================== * Use inttypes.h for portable printing of 64 bit items. LibPST 0.6.15 (2008-07-30) =============================== * Patch from Robert Simpson for file handle leak in error case. * Fix for missing length on lz decompression, bug found by Chris White. LibPST 0.6.14 (2008-06-15) =============================== * Fix my mistake in debian packaging. LibPST 0.6.13 (2008-06-13) =============================== * Patch from Robert Simpson for encryption type 2. * Fix the order of testing item types to avoid claiming there are multiple message stores. LibPST 0.6.12 (2008-06-10) =============================== * Patch from Joachim Metz for debian packaging, and fix for incorrect length on lz decompression. LibPST 0.6.11 (2008-06-03) =============================== * Use ftello/fseeko to properly handle large files. * Document and properly use datasize field in b5 blocks. * Fix some MSVC compile issues and collect MSVC dependencies into one place. LibPST 0.6.10 (2008-05-29) =============================== * Patch from Robert Simpson fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them). * More changes for Fedora packaging (#434727) * Fixes for const correctness. LibPST 0.6.9 (2008-05-16) =============================== * Patch from Joachim Metz for 64 bit compile. * Signed/unsigned cleanup from 'CFLAGS=-Wextra ./configure'. * Reindent vbuf.c to make it readable. * Fix pst format documentation for 8 byte backpointers. LibPST 0.6.8 (2008-03-05) =============================== * Initial version of pst2dii to convert to Summation dii load file format. * Changes for Fedora packaging (#434727) LibPST 0.6.7 (2008-02-16) =============================== * Work around bogus 7c.b5 blocks in some messages that have been read. They appear to have attachments, but of some unknown format. Before the message was read, it did not have any attachments. * Use autoscan to cleanup our autoconf system. * Use autoconf to detect when we need to use our XGetopt files and other header files. * More fields, including BCC. * Fix missing LE32_CPU byte swapping for FILETIME types. LibPST 0.6.6 (2008-01-31) =============================== * More code cleanup, removing unnecessary null terminations on binary buffers. All pst file reads now go thru one function. Logging all pst reads to detect cases where we read the same data multiple times - discovers node sizes are actually 512 bytes. * Switch from cvs to mercurial source control. LibPST 0.6.5 (2008-01-22) =============================== * More code cleanup, removing obsolete code. All the boolean flags of type 0xb have length 4, so these are all 32 bits in the file. Libpst treats them all as 16 bits, but at least we are consistent. * More fields decoded - for example, see We should be able to use that data for much more complete decoding. * Move the rpm group to Applications/Productivity consistent with Evolution. LibPST 0.6.4 (2008-01-19) =============================== * More fixes for Outlook 2003 64 bit parsing. We observed cases of compressed RTF bodies (type 0x1009) with zero length. * Document type 0x0101 descriptor blocks and process them. * Fix large file support - we need to include config.h before any standard headers. * Merge following changes from svn snapshot from Alioth: * Add new fields to appointment for recurring events (SourceForge #304198) * Map IPM.Task items to PST_TYPE_TASK. * Applied patch to remove compiler warnings, thanks! (SourceForge #304314) * Fix crash with unknown reference type * Fix more memory issues detected by valgrind * lspst - add usage mesage and option parsing using getopt (SourceForge #304199) * Fix crash caused by invalid free calls * Fix crash when email subject is empty * Fix memory and information leak in hex debug dump LibPST 0.6.3 (2008-01-13) =============================== * More type consistency issues found by splint. LibPST 0.6.2 (2008-01-12) =============================== * More fixes for Outlook 2003 64 bit parsing. * All buffer sizes changed to size_t, all file offsets changed to off_t, all function names start with pst_, many other type consistency issues found by splint. Many changes to #llx in debug printing for 64 bit items. All id values are now uint64_t. LibPST 0.6.1 (2008-01-06) =============================== * Outlook 2003 64 bit parsing. Some documentation from Alexander Grau and patches from Sean Loaring . * fix from Antonio Palama for email items that happen to have item->contact non null, and were being processed as contacts. * Add large file support so we can read .pst files larger than 2gb. * Change lspst to be similar to readpst, properly using recursion to walk the tree, and testing item types. Add a man page for lspst. LibPST 0.5.12 (2007-10-02) =============================== * security fix from Brad Hards for buffer overruns in liv-zemple decoding for corrupted or malicious pst files. LibPST 0.5.11 (2007-08-24) =============================== * fix from Stevens Miller for unitialized variable. LibPST 0.5.10 (2007-08-20) =============================== * fix yet more valgrind errors - finally have a clean memory check. * restructure readpst.c for proper recursive tree walk. * buffer overrun test was backwards, introduced at 0.5.6 * fix broken email attachments, introduced at 0.5.6 LibPST 0.5.9 (2007-08-12) =============================== * fix more valgrind errors. LibPST 0.5.8 (2007-08-10) =============================== * fix more valgrind errors. lzfu_decompress needs to return the actual buffer size, since the lz header overestimates the size. This caused base64_encode to encode undefined bytes into the email attachment. LibPST 0.5.7 (2007-08-09) =============================== * fix valgrind errors, using uninitialized data. * improve debug logging and readpstlog for indented listings. * cleanup documentation. LibPST 0.5.6 (2007-07-15) =============================== * Fix to allow very small pst files with only one node in the tree. We were mixing signed/unsigned types in comparisons. * More progress decoding the basic structure 7c blocks. Many four byte values may be ID2 indices with data outside the buffer. * Start using doxygen to generate internal documentation. LibPST 0.5.5 (2007-07-10) =============================== * merge the following changes from Joe Nahmias version: * Lots of memory fixes. Thanks to Nigel Horne for his assistance tracking these down! * Fixed creation of vCards from contacts, thanks to Nigel Horne for his help with this! * fix for MIME multipart/alternative attachments. * added -c options to readpst manpage. * use 8.3 attachment filename if long filename isn't available. * new -b option to skip rtf-body.rtf attachments. * fix format of From header lines in mbox files. * Add more appointment fields, thanks to Chris Halls for tracking them down! LibPST 0.5.4 (2006-02-25) =============================== * patches from Arne, adding MH mode, remove leading zeros from the generated numbered filenames starting with one rather than zero. Miscellaneous code cleanup. * document the "7c" descriptor block format. LibPST 0.5.3 (2006-02-20) =============================== * switch to gnu autoconf/automake. This breaks the MS VC++ projects since the source code is now in the src subdirectory. * documentation switched to xml, building man pages and html from the master xml copy. * include rpm .spec file for building src and binary rpms. LibPST 0.5.2 (2006-02-18) =============================== * Added pst2ldif to convert the contacts to ldif format for import into ldap databases. * Major changes to libpst.c to properly use the node depth values from the b-tree nodes. We also use the item count values in the nodes rather than trying to guess how many items are active. * Cleanup whitespace - using tabs for every four columns. LibPST 0.5.1 (17 November 2004) =============================== Well, alot has happened since the last release of libpst. Release / Management: * The project has forked! The new maintainer is Joseph Nahmias. * We have changed hosting sites, thanks to sourceforge for hosting to this point. From this point forward we will be using alioth.debian.org. * The project is now using SubVersioN for source control. You can get the latest code by running: svn co svn://svn.debian.org/svn/libpst/trunk . * See for more information. Code Changes: * Added lspst program to list items in a PST. Still incomplete. * Added vim folding markers to readpst.c * avoid the pseudo-prologue that MS prepends to the email headers * fix build on msvc, since it doesn't have sys/param.h * Re-vamped Makefile: * Only define CFLAGS in Makefileif missing * fixed {un,}install targets in Makefile * Fixed up build process in Makefile * Added mozilla conversion script from David Binard * Fixed bogus creation of readpst.log on every invocation * escaped dashes and apostrophe in manpages * Updated TODO * added manpages from debian pkg * fix escaped-string length count to consider '\n', thanks to Paul Bakker . * ensure there's a blank line between header and body patch from (SourceForge #890745). * Apply accumulated endian-related patches * Removed unused files, upstream's debian/ dir -- Joe Nahmias LibPST v0.5 =========== It is with GREAT relief that I bring you version 0.5 of the LibPST tools! Through great difficulties, this tool has survived and expanded to become even better. The changes are as follows: * RTF support. We can now decompress RTF bodies in emails, and are saved as attachments * Better support in reading the indexes. Fixed many bugs with them * Improved reliability. "Now we are getting somewhere!" * Improved compiling. Hopefully we won't be hitting too many compile errors now. * vCard handling. Contacts are now exported as vCard entries. * vEvent handling. Support has begun on exporting Calendar entries as events * Support for Journal entries has also begun If you have any problems with this release, don't hesitate to contact me. These changes come to you, as always, free under the GPL license!! What a wonderful thing it is. It does mean that you can write your own program off of this library and distribute it also for free. However, anyone with commercial interests for developing applications they will be charging for are encouraged to get in touch with me, as I am sure we can come to some arrangement. Dave Smith LibPST v0.4.3 ============= Bug fix release. No extra functionality Dave Smith LibPST v0.4.2 ============= The debug system has had an overhaul. The debug messages are no longer printed to the screen when they are enabled. They are dumped to a binary file. There is another utility called "readlog" that I have written to handle these log files. It should make it easier to selectively view bits of a log file. It also shows the position that the log message was printed from. There is a new switch in readpst. It is -d. It enables the user to specify the log file which the binary log is written to. If the switch isn't used, the default file of "readpst.log" is used. The code is now Visual C++ compatible. It has compiled on Visual C++ .net Standard edition, and produces the readpst.exe file. Use the project file included in this distribution. There have been minor improvements elsewhere too. LibPST v0.4.1 ============= Fixed a couple more bugs. Is it me or do bugs just insert themselves in random, hard to find places! Cured a few problems with regard to emails with multiple embeded items. They are not fully re-created using Mime-types, but are accessible with the -S switch (which saves everything as seperate items) Fixed a problem reading the first index. Back sliders are now detected. (ie when the value following the current one is smaller, not bigger!) Added some error messages when we try and read outside of the PST file, this was causing a few problems before, cause the return value wasn't always checked, so it was possible to be reading random data, and trying to make sense of it! Anyway, if you find any problems, don't hesitate to mail me Dave Smith LibPST v0.4 =========== Fixed a nasty bug that occasionally corrupted attachments. Another bug with regard to reading of indexes (also occasional). Another output method has been added which is called "Seperate". It is activated with the -S switch. It operates in the following manor: |--Inbox-->000000 | 000001 | 000002 |--Sentmail-->0000000 | 0000001 | 0000002 All the emails are stored in seperate files counting from 0 upwards, in a folder named as the PST folder. When an email has an attachment, it is saved as a seperate file. The filename for the attachment is made up of 2 parts, the first is the email number to which it belongs, the second is its filename. The should now be runnable on big-endian machines, if the define.h file is first modified. The #define LITTLE_ENDIAN must be commented out, and the #define BIG_ENDIAN must be uncommented. More verbose error messages have been added. Apparently people got confused when the program stopped for no visible reason. This has now been resolved. Thanks for the continued support of all people involved. Dave Smith Libpst v0.3.4 ============= Several more fixes. An Infinite loop and incorrect interpreting of item index attributes. Work has started on making the code executable on big endian CPUs. At present it should work with Linux on these CPUs, but I would appreciate it if you could provide feedback with regard to it's performance. I am also working with some other people at make it operate on Solaris. A whole load more items are now recognized by the Item records. With more items in Emails and Folders. I haven't got to the Contacts yet. Anyway, this is what I would call a minor feature enhancment and bugfix release. Dave Smith LibPST v0.3.3 ============= Fixed several items. Mainly memory leaks. Loads of them! oops.. I have added a new program, mainly of debugging, which when passed an ID value and a pst file, will extract and decrypt that ID from the pst file. I don't see it being a huge attraction, or of much use to most people, but it is another example of writing an application to use the libpst interface. Another fix was in the reading of the item index. This has hopefully now been corrected. The result of this bug was that not all the emails in a folder were converted. Hopefully you should have more luck now. Dave Smith LibPST v0.3.2 ============= Quick bugfix release. There was a bug in the decryption of the basic encryption that outlook uses. One byte, 0x6c, was incorrectly decrypted to 0x6c instead of 0xcd. This release fixes this bug. Sorry... LibPST v0.3.1 ============= Minor improvements. Fixed bug when linking multiple blocks together, so now the linking blocks are not "encrypted" when trying to read them. LibPST v0.3 =========== A lot of bug fixing has been done for this release. Testing has been done on the creation of the files by readpst. Better handling of large binaries being extracted from the PST file has been implemented. Quite a few reports have come in about not being able to compile on Darwin. This could be down to using macros with variable parameter lists. This has now been changed to use C functions with variable parameters. I hope this fixes a lot of problems. Added support for recreating the folder structure into normal directories. For Instance: Personal Folders |-Inbox | |-Jokes | |-Meetings |-Send Items each folder containing an mbox file with the correct emails for that folder. Dave Smith LibPST v0.3 beta1 ================= Again, a shed load of enhancements. More work has been done on the mime creation. A bug has been fixed that was letting part of the attachments that were created disappear. A major enhancement is that "compressible encryption" support has been added. This was an incredibly simple method to use. It is basically a ceasar cipher. It has been noted by several users already that the PST password that Outlook uses, serves *no purpose*. It is not used to encrypt the PST, it is mearly stored there. This means that the readpst application is able to convert PST files without knowing the password. Microsoft have some explaning to do! Output files are now not overwritten if they already exist. This means that if you have two folders in your PST file named "fred", the first one encountered will be named "fred" and the second one will be named "fred00000001". As you can see, there is enough room there for many duplicate names! Output filenames are now restricted. Any "/" or "\" characters in the name are replaced with "_". If you find that there are any other characters that need to be changed, could you please make me aware! Thanks to Berry Wizard for help with supporting the encryption. Thanks to Auke Kok, Carolus Walraven and Yogesh Kumar Guatam for providing debugging information and testing. Dave Smith LibPST v0.2 beta1 ================= Hello once more... Attachments are now re-created in mime format. The method is very crude and could be prone to over generalisation. Please test this version, and if attachments are not recreated correctly, please send me the email (complete message source) of the original and converted. Cheers. I hope this will work for everyone who uses this program, but reality can be very different! Let us see how it goes... Dave Smith LibPST v0.2 alpha1 =========== Hello! Some improvements. The internal code has been changed so that attachments are now processed and loaded into the structures. The readpst program is not finished yet. It needs to convert these binary structs into mime data. At present it just saves them to the current directory, overwriting any previous files with the attachment name. Improvements over previous version: * KMail output is supported - if the "-k" flag is specified, all the directory hierarchy is created using the KMail standard * Lots of bugs and memory leaks fixed Usage: ReadPST v0.2alpha1 implementing LibPST v0.2alpha1 Usage: ./readpst [OPTIONS] {PST FILENAME} OPTIONS: -h - Help. This screen -k - KMail. Output in kmail format -o - Output Dir. Directory to write files to. CWD is changed *after* opening pst file -V - Version. Display program version If you want to view lots of debug output, modify a line in "define.h" from "//#define DEBUG_ALL" to "#define DEBUG_ALL". It would then be advisable to pipe all output to a log file: ./readpst -o out pst_file &> logfile Dave Smith LibPST v0.1 =========== Hi Folks! This has been a long, hard slog, but I now feel that I have got somewhere useful. The included program "main" is able to read an Outlook PST file and dump the emails into mbox files, separating each folder into a different mbox file. All the mbox files are stored in the current directory and no attempt is yet made to organise these files into a directory hierarchy. This would not be too difficult to achieve though. Email attachments are not yet handled, neither are Contacts. There is no pretty interface yet, but you can convert a PST file in the following manner ./main {path to PST file} This is very much a work in progress, but I thought I should release this code so that people can lose their conception that outlook files will never be converted to Linux. I am intending that the code I am writing will be developed into greater applications to provide USEFUL tools for accessing and converting PST files into a variety of formats. One point I feel I should make is that Outlook, by default, creates "Compressible Encryption" PST files. I have not, as yet, attempted to write any decryption routines, so you will not be able to convert these files. However, if you create a new PST file and choose not to make an encrypted one, you can copy all your emails into this new one and then convert the unencrypted one. I hope you enjoy, Dave Smith diff --git a/NEWS b/NEWS index dc29c25..987d9a5 100644 --- a/NEWS +++ b/NEWS @@ -1,27 +1,28 @@ +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.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.in b/configure.in index 2f9ab28..841d1c9 100644 --- a/configure.in +++ b/configure.in @@ -1,93 +1,93 @@ AC_PREREQ(2.59) -AC_INIT(libpst,0.6.16,carl@five-ten-sg.com) +AC_INIT(libpst,0.6.17,carl@five-ten-sg.com) AC_CONFIG_SRCDIR([config.h.in]) AC_CONFIG_HEADER([config.h]) AM_INIT_AUTOMAKE($PACKAGE_NAME,$PACKAGE_VERSION) # Checks for programs. my_build_dii=yes AC_PATH_PROG(CONVERT, convert) if test "x$CONVERT" = "x" ; then AC_MSG_WARN([convert not found. pst2dii disabled]) my_build_dii=no fi AM_CONDITIONAL(BUILD_DII, test $my_build_dii = yes) # Checks for programs. AC_PROG_CXX AC_PROG_CC AC_PROG_CPP AC_PROG_INSTALL AC_PROG_LN_S AC_PROG_MAKE_SET AC_PROG_RANLIB 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([fcntl.h limits.h malloc.h netinet/in.h stdint.h stdlib.h string.h sys/param.h wchar.h]) if test "$my_build_dii" = "yes"; then AC_CHECK_HEADERS([gd.h]) fi # Checks for typedefs, structures, and compiler characteristics. AC_HEADER_STDBOOL AC_C_CONST AC_TYPE_OFF_T AC_TYPE_SIZE_T AC_STRUCT_TM # Checks for library functions. AC_FUNC_FSEEKO AC_FUNC_LSTAT AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK AC_FUNC_MALLOC AC_FUNC_MKTIME AC_FUNC_REALLOC AC_FUNC_STRFTIME AC_FUNC_VPRINTF AC_CHECK_FUNCS([memchr memmove memset strcasecmp strchr strdup strerror strpbrk strrchr strstr strtol]) # 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]), [if test "${enable_pst_debug}" = "no" ; then AC_MSG_RESULT([no]) else AC_DEFINE(DEBUG_ALL, 1, Define to 1 to force debug dump file creation) AC_MSG_RESULT([yes]) fi], # Default value for configure AC_MSG_RESULT([no]) ) AC_OUTPUT( \ Makefile \ debian/changelog \ debian/Makefile \ libpst.spec \ html/Makefile \ info/Makefile \ man/Makefile \ src/Makefile \ src/version.h \ src/pst2dii.cpp \ xml/Makefile \ xml/libpst \ ) diff --git a/libpst.spec.in b/libpst.spec.in index d925c8b..89553da 100644 --- a/libpst.spec.in +++ b/libpst.spec.in @@ -1,88 +1,91 @@ Summary: Utilities to convert Outlook .pst files to other formats Name: @PACKAGE@ Version: @VERSION@ Release: 1%{?dist} License: GPLv2+ Group: Applications/Productivity Source: http://www.five-ten-sg.com/%{name}/packages/%{name}-%{version}.tar.gz BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) URL: http://www.five-ten-sg.com/%{name}/ Requires: ImageMagick BuildRequires: ImageMagick freetype-devel gd-devel libjpeg-devel zlib-devel %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. %prep %setup -q %build %configure make %{?_smp_mflags} %install rm -rf $RPM_BUILD_ROOT make DESTDIR=$RPM_BUILD_ROOT install %clean rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root,-) %{_bindir}/* %{_mandir}/man1/* %{_mandir}/man5/* %docdir %{_datadir}/doc/%{name}-%{version} %{_datadir}/doc/%{name}-%{version} %changelog +* 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. * 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 - 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/src/debug.c b/src/debug.c index ea65921..4056836 100644 --- a/src/debug.c +++ b/src/debug.c @@ -1,451 +1,451 @@ #include "define.h" #include #include #include #include #include #include struct pst_debug_item { int type; char * function; unsigned int line; char * file; char * text; struct pst_debug_item *next; } *item_head=NULL, *item_tail=NULL, *item_ptr=NULL, *info_ptr=NULL, *temp_list=NULL; struct pst_debug_func { char * name; struct pst_debug_func *next; } *func_head=NULL, *func_ptr=NULL; void pst_debug_write_msg(struct pst_debug_item *item, const char *fmt, va_list *ap, int size); void pst_debug_write_hex(struct pst_debug_item *item, char *buf, size_t size, int col); void * xmalloc(size_t size); size_t pst_debug_fwrite(const void *ptr, size_t size, size_t nitems, FILE *stream) { return fwrite(ptr, size, nitems, stream); } // the largest text size we will store in memory. Otherwise we // will do a debug_write, then create a new record, and write the // text body directly to the file #define MAX_MESSAGE_SIZE 4096 void pst_debug(const char *fmt, ...) { va_list ap; va_start(ap,fmt); vfprintf(stderr, fmt, ap); va_end(ap); } #define NUM_COL 30 void pst_debug_hexdumper(FILE *out, char *buf, size_t size, int col, int delta) { size_t off = 0, toff; int count = 0; if (!out) return; // no file if (col == -1) col = NUM_COL; fprintf(out, "\n"); while (off < size) { - fprintf(out, "%06X\t:", off+delta); + fprintf(out, "%06"PRIx64"\t:", (uint64_t)(off+delta)); toff = off; while (count < col && off < size) { fprintf(out, "%02hhx ", (unsigned char)buf[off]); off++; count++; } off = toff; while (count < col) { // only happens at end of block to pad the text over to the text column fprintf(out, " "); count++; } count = 0; fprintf(out, ":"); while (count < col && off < size) { fprintf(out, "%c", isgraph(buf[off])?buf[off]:'.'); off++; count ++; } fprintf(out, "\n"); count=0; } fprintf(out, "\n"); } FILE *debug_fp = NULL; unsigned int max_items=DEBUG_MAX_ITEMS, curr_items=0; void pst_debug_init(const char* fname) { unsigned char version = DEBUG_VERSION; item_head = item_tail = NULL; curr_items = 0; if (debug_fp) pst_debug_close(); if (!fname) return; if ((debug_fp = fopen(fname, "wb")) == NULL) { fprintf(stderr, "Opening of file %s failed\n", fname); exit(1); } pst_debug_fwrite(&version, 1, sizeof(char), debug_fp); } // function must be called before pst_debug_msg. It sets up the // structure for the function that follows void pst_debug_msg_info(int line, const char* file, int type) { char *x; if (!debug_fp) return; // no file info_ptr = (struct pst_debug_item*) xmalloc(sizeof(struct pst_debug_item)); info_ptr->type = type; info_ptr->line = line; x = (func_head==NULL?"No Function":func_head->name); info_ptr->function = (char*) xmalloc(strlen(x)+1); strcpy(info_ptr->function, x); info_ptr->file = (char*) xmalloc(strlen(file)+1); strcpy(info_ptr->file, file); //put the current record on a temp linked list info_ptr->next = temp_list; temp_list = info_ptr; } void pst_debug_msg_text(const char* fmt, ...) { va_list ap; int f, g; char x[2]; #ifdef _WIN32 char *buf = NULL; #endif struct pst_debug_item *temp; if (!debug_fp) return; // no file // get the record off of the temp_list info_ptr = temp_list; if (info_ptr) temp_list = info_ptr->next; else { fprintf(stderr, "NULL info_ptr. ERROR!!\n"); exit(-2); } #ifdef _WIN32 // vsnprintf trick doesn't work on msvc. g = 2000; f = -1; while (f < 0) { buf = realloc(buf, g+1); va_start(ap, fmt); f = vsnprintf(buf, g, fmt, ap); va_end(ap); g += g/2; } free(buf); #else // according to glibc 2.1, this should return the req. number of bytes for // the string va_start(ap, fmt); f = vsnprintf(x, 1, fmt, ap); va_end(ap); #endif if (f > 0 && f < MAX_MESSAGE_SIZE) { info_ptr->text = (char*) xmalloc(f+1); va_start(ap, fmt); if ((g = vsnprintf(info_ptr->text, f, fmt, ap)) == -1) { fprintf(stderr, "_debug_msg: Dying! vsnprintf returned -1 for format \"%s\"\n", fmt); exit(-2); } va_end(ap); info_ptr->text[g] = '\0'; if (f != g) { fprintf(stderr, "_debug_msg: f != g\n"); } } else if (f > 0) { // it is over the max_message_size then f += strlen(info_ptr->file)+strlen(info_ptr->function); temp = info_ptr; pst_debug_write(); // dump the current messages info_ptr = temp; va_start(ap, fmt); pst_debug_write_msg(info_ptr, fmt, &ap, f); va_end(ap); free(info_ptr->function); free(info_ptr->file); free(info_ptr); info_ptr = NULL; return; } else { fprintf(stderr, "_debug_msg: error getting requested size of debug message\n"); info_ptr->text = "ERROR Saving\n"; } if (!item_head) item_head = info_ptr; info_ptr->next = NULL; if (item_tail) item_tail->next = info_ptr; item_tail = info_ptr; if (++curr_items == max_items) { // here we will jump off and save the contents pst_debug_write(); info_ptr = NULL; } } void pst_debug_hexdump(char *x, size_t y, int cols, int delta) { struct pst_debug_item *temp; if (!debug_fp) return; // no file info_ptr = temp_list; if (info_ptr) temp_list = info_ptr->next; temp = info_ptr; pst_debug_write(); info_ptr = temp; pst_debug_write_hex(info_ptr, x, y, cols); free(info_ptr->function); free(info_ptr->file); free(info_ptr); info_ptr = NULL; } void pst_debug_func(const char *function) { func_ptr = xmalloc (sizeof(struct pst_debug_func)); func_ptr->name = xmalloc(strlen(function)+1); strcpy(func_ptr->name, function); func_ptr->next = func_head; func_head = func_ptr; } void pst_debug_func_ret() { //remove the head item func_ptr = func_head; if (func_head) { func_head = func_head->next; free(func_ptr->name); free(func_ptr); } else { DIE(("function list is empty!\n")); } } void pst_debug_close(void) { pst_debug_write(); while (func_head) { func_ptr = func_head; func_head = func_head->next; free(func_ptr->name); free(func_ptr); } if (debug_fp) fclose(debug_fp); debug_fp = NULL; } void pst_debug_write() { size_t size, ptr, funcname, filename, text, end; char *buf = NULL, rec_type; if (!debug_fp) return; // no file off_t index_pos = ftello(debug_fp); off_t file_pos = index_pos; // add 2. One for the pointer to the next index, // one for the count of this index int index_size = ((curr_items+2) * sizeof(off_t)); off_t *index; int index_ptr = 0; struct pst_debug_file_rec_m mfile_rec; struct pst_debug_file_rec_l lfile_rec; if (curr_items == 0) return; // no items to write. index = (off_t*)xmalloc(index_size); memset(index, 0, index_size); // valgrind, avoid writing uninitialized data file_pos += index_size; // write the index first, we will re-write it later, but // we want to allocate the space pst_debug_fwrite(index, index_size, 1, debug_fp); index[index_ptr++] = curr_items; item_ptr = item_head; while (item_ptr) { file_pos = ftello(debug_fp); index[index_ptr++] = file_pos; size = strlen(item_ptr->function) + strlen(item_ptr->file) + strlen(item_ptr->text) + 3; //for the three \0s if (buf) free(buf); buf = xmalloc(size+1); ptr = 0; funcname=ptr; ptr += sprintf(&(buf[ptr]), "%s", item_ptr->function)+1; filename=ptr; ptr += sprintf(&(buf[ptr]), "%s", item_ptr->file)+1; text=ptr; ptr += sprintf(&(buf[ptr]), "%s", item_ptr->text)+1; end=ptr; if (end > USHRT_MAX) { // bigger than can be stored in a short rec_type = 'L'; pst_debug_fwrite(&rec_type, 1, sizeof(char), debug_fp); lfile_rec.type = item_ptr->type; lfile_rec.line = item_ptr->line; lfile_rec.funcname = funcname; lfile_rec.filename = filename; lfile_rec.text = text; lfile_rec.end = end; pst_debug_fwrite(&lfile_rec, sizeof(lfile_rec), 1, debug_fp); } else { rec_type = 'M'; pst_debug_fwrite(&rec_type, 1, sizeof(char), debug_fp); mfile_rec.type = item_ptr->type; mfile_rec.line = item_ptr->line; mfile_rec.funcname = funcname; mfile_rec.filename = filename; mfile_rec.text = text; mfile_rec.end = end; pst_debug_fwrite(&mfile_rec, sizeof(mfile_rec), 1, debug_fp); } pst_debug_fwrite(buf, 1, ptr, debug_fp); if (buf) free(buf); buf = NULL; item_head = item_ptr->next; free(item_ptr->function); free(item_ptr->file); free(item_ptr->text); free(item_ptr); item_ptr = item_head; } curr_items = 0; index[index_ptr] = ftello(debug_fp); // we should now have a complete index fseeko(debug_fp, index_pos, SEEK_SET); pst_debug_fwrite(index, index_size, 1, debug_fp); fseeko(debug_fp, 0, SEEK_END); item_ptr = item_head = item_tail = NULL; free(index); if (buf) free(buf); } void pst_debug_write_msg(struct pst_debug_item *item, const char *fmt, va_list *ap, int size) { struct pst_debug_file_rec_l lfile_rec; struct pst_debug_file_rec_m mfile_rec; unsigned char rec_type; int index_size = 3 * sizeof(off_t); off_t index[3]; off_t index_pos, file_pos; char zero='\0'; unsigned int end; if (!debug_fp) return; // no file index[0] = 1; //only one item in this index index_pos = ftello(debug_fp); pst_debug_fwrite(index, index_size, 1, debug_fp); index[1] = ftello(debug_fp); if (size > USHRT_MAX) { // bigger than can be stored in a short rec_type = 'L'; pst_debug_fwrite(&rec_type, 1, sizeof(char), debug_fp); lfile_rec.type = item->type; lfile_rec.line = item->line; lfile_rec.funcname = 0; lfile_rec.filename = strlen(item->function)+1; lfile_rec.text = lfile_rec.filename+strlen(item->file)+1; pst_debug_fwrite(&lfile_rec, sizeof(lfile_rec), 1, debug_fp); } else { rec_type = 'M'; pst_debug_fwrite(&rec_type, 1, sizeof(char), debug_fp); mfile_rec.type = item->type; mfile_rec.line = item->line; mfile_rec.funcname = 0; mfile_rec.filename = strlen(item->function)+1; mfile_rec.text = mfile_rec.filename+strlen(item->file)+1; pst_debug_fwrite(&mfile_rec, sizeof(mfile_rec), 1, debug_fp); } file_pos = ftello(debug_fp); pst_debug_fwrite(item->function, strlen(item->function)+1, 1, debug_fp); pst_debug_fwrite(item->file, strlen(item->file)+1, 1, debug_fp); vfprintf(debug_fp, fmt, *ap); pst_debug_fwrite(&zero, 1, 1, debug_fp); end = (unsigned int) (ftello(debug_fp) - file_pos); index[2] = ftello(debug_fp); fseeko(debug_fp, index_pos, SEEK_SET); pst_debug_fwrite(index, index_size, 1, debug_fp); if (size > USHRT_MAX) { pst_debug_fwrite(&rec_type, 1, sizeof(char), debug_fp); lfile_rec.end = end; pst_debug_fwrite(&lfile_rec, sizeof(lfile_rec), 1, debug_fp); } else { pst_debug_fwrite(&rec_type, 1, sizeof(char), debug_fp); mfile_rec.end = end; pst_debug_fwrite(&mfile_rec, sizeof(mfile_rec), 1, debug_fp); } fseeko(debug_fp, 0, SEEK_END); } void pst_debug_write_hex(struct pst_debug_item *item, char *buf, size_t size, int col) { struct pst_debug_file_rec_l lfile_rec; unsigned char rec_type; int index_size = 3 * sizeof(off_t); off_t index_pos, file_pos, index[3]; char zero='\0'; if (!debug_fp) return; // no file index[0] = 1; // only one item in this index run index[1] = 0; // valgrind, avoid writing uninitialized data index[2] = 0; // "" index_pos = ftello(debug_fp); pst_debug_fwrite(index, index_size, 1, debug_fp); index[1] = ftello(debug_fp); // always use the long rec_type = 'L'; pst_debug_fwrite(&rec_type, 1, sizeof(char), debug_fp); lfile_rec.funcname = 0; lfile_rec.filename = strlen(item->function)+1; lfile_rec.text = lfile_rec.filename+strlen(item->file)+1; lfile_rec.end = 0; // valgrind, avoid writing uninitialized data lfile_rec.line = item->line; lfile_rec.type = item->type; pst_debug_fwrite(&lfile_rec, sizeof(lfile_rec), 1, debug_fp); file_pos = ftello(debug_fp); pst_debug_fwrite(item->function, strlen(item->function)+1, 1, debug_fp); pst_debug_fwrite(item->file, strlen(item->file)+1, 1, debug_fp); pst_debug_hexdumper(debug_fp, buf, size, col, 0); pst_debug_fwrite(&zero, 1, 1, debug_fp); lfile_rec.end = ftello(debug_fp) - file_pos; index[2] = ftello(debug_fp); fseeko(debug_fp, index_pos, SEEK_SET); pst_debug_fwrite(index, index_size, 1, debug_fp); pst_debug_fwrite(&rec_type, 1, sizeof(char), debug_fp); pst_debug_fwrite(&lfile_rec, sizeof(lfile_rec), 1, debug_fp); fseeko(debug_fp, 0, SEEK_END); } void *xmalloc(size_t size) { void *mem = malloc(size); if (!mem) { fprintf(stderr, "xMalloc: Out Of memory [req: %ld]\n", (long)size); exit(1); } return mem; } diff --git a/src/libpst.h b/src/libpst.h index 9095e20..3b86da1 100644 --- a/src/libpst.h +++ b/src/libpst.h @@ -1,615 +1,615 @@ /*** * libpst.h * Part of LibPST project * Written by David Smith * dave.s@earthcorp.com */ // LibPST - Library for Accessing Outlook .pst files // Dave Smith - davesmith@users.sourceforge.net #ifndef LIBPST_H #define LIBPST_H #ifndef _MSC_VER #include #include #ifndef FILETIME_DEFINED #define FILETIME_DEFINED //Win32 Filetime struct - copied from WINE typedef struct { uint32_t dwLowDateTime; uint32_t dwHighDateTime; } FILETIME; #endif #endif // According to Jan Wolter, sys/param.h is the most portable source of endian // information on UNIX systems. see http://www.unixpapa.com/incnote/byteorder.html #ifdef _MSC_VER #define BYTE_ORDER LITTLE_ENDIAN #else #include #endif // defined _MSC_VER #if BYTE_ORDER == BIG_ENDIAN # define LE64_CPU(x) \ - x = ((((x) & 0xff00000000000000) >> 56) | \ - (((x) & 0x00ff000000000000) >> 40) | \ - (((x) & 0x0000ff0000000000) >> 24) | \ - (((x) & 0x000000ff00000000) >> 8 ) | \ - (((x) & 0x00000000ff000000) << 8 ) | \ - (((x) & 0x0000000000ff0000) << 24) | \ - (((x) & 0x000000000000ff00) << 40) | \ - (((x) & 0x00000000000000ff) << 56)); + x = ((((x) & UINT64_C(0xff00000000000000)) >> 56) | \ + (((x) & UINT64_C(0x00ff000000000000)) >> 40) | \ + (((x) & UINT64_C(0x0000ff0000000000)) >> 24) | \ + (((x) & UINT64_C(0x000000ff00000000)) >> 8 ) | \ + (((x) & UINT64_C(0x00000000ff000000)) << 8 ) | \ + (((x) & UINT64_C(0x0000000000ff0000)) << 24) | \ + (((x) & UINT64_C(0x000000000000ff00)) << 40) | \ + (((x) & UINT64_C(0x00000000000000ff)) << 56)); # define LE32_CPU(x) \ x = ((((x) & 0xff000000) >> 24) | \ (((x) & 0x00ff0000) >> 8 ) | \ (((x) & 0x0000ff00) << 8 ) | \ (((x) & 0x000000ff) << 24)); # define LE16_CPU(x) \ x = ((((x) & 0xff00) >> 8) | \ (((x) & 0x00ff) << 8)); #elif BYTE_ORDER == LITTLE_ENDIAN # define LE64_CPU(x) {} # define LE32_CPU(x) {} # define LE16_CPU(x) {} #else # error "Byte order not supported by this library" #endif // BYTE_ORDER #define PST_TYPE_NOTE 1 #define PST_TYPE_APPOINTMENT 8 #define PST_TYPE_CONTACT 9 #define PST_TYPE_JOURNAL 10 #define PST_TYPE_STICKYNOTE 11 #define PST_TYPE_TASK 12 #define PST_TYPE_OTHER 13 #define PST_TYPE_REPORT 14 // defines whether decryption is done on this bit of data #define PST_NO_ENC 0 #define PST_ENC 1 // defines types of possible encryption #define PST_NO_ENCRYPT 0 #define PST_COMP_ENCRYPT 1 #define PST_ENCRYPT 2 // defines different types of mappings #define PST_MAP_ATTRIB (uint32_t)1 #define PST_MAP_HEADER (uint32_t)2 // define my custom email attributes. #define PST_ATTRIB_HEADER -1 // defines types of free/busy values for appointment->showas #define PST_FREEBUSY_FREE 0 #define PST_FREEBUSY_TENTATIVE 1 #define PST_FREEBUSY_BUSY 2 #define PST_FREEBUSY_OUT_OF_OFFICE 3 // defines labels for appointment->label #define PST_APP_LABEL_NONE 0 // None #define PST_APP_LABEL_IMPORTANT 1 // Important #define PST_APP_LABEL_BUSINESS 2 // Business #define PST_APP_LABEL_PERSONAL 3 // Personal #define PST_APP_LABEL_VACATION 4 // Vacation #define PST_APP_LABEL_MUST_ATTEND 5 // Must Attend #define PST_APP_LABEL_TRAVEL_REQ 6 // Travel Required #define PST_APP_LABEL_NEEDS_PREP 7 // Needs Preparation #define PST_APP_LABEL_BIRTHDAY 8 // Birthday #define PST_APP_LABEL_ANNIVERSARY 9 // Anniversary #define PST_APP_LABEL_PHONE_CALL 10// Phone Call // define type of reccuring event #define PST_APP_RECUR_NONE 0 #define PST_APP_RECUR_DAILY 1 #define PST_APP_RECUR_WEEKLY 2 #define PST_APP_RECUR_MONTHLY 3 #define PST_APP_RECUR_YEARLY 4 typedef struct pst_misc_6_struct { int32_t i1; int32_t i2; int32_t i3; int32_t i4; int32_t i5; int32_t i6; } pst_misc_6; typedef struct pst_entryid_struct { int32_t u1; char entryid[16]; uint32_t id; } pst_entryid; typedef struct pst_desc_struct32 { uint32_t d_id; uint32_t desc_id; uint32_t list_id; uint32_t parent_id; } pst_desc32; typedef struct pst_desc_structn { uint64_t d_id; uint64_t desc_id; uint64_t list_id; uint32_t parent_id; // not 64 bit ?? uint32_t u1; // padding } pst_descn; typedef struct pst_index_struct32 { uint32_t id; uint32_t offset; uint16_t size; int16_t u1; } pst_index32; typedef struct pst_index_struct { uint64_t id; uint64_t offset; uint16_t size; int16_t u0; int32_t u1; } pst_index; typedef struct pst_index_tree32 { uint32_t id; uint32_t offset; uint32_t size; int32_t u1; struct pst_index_tree * next; } pst_index_ll32; typedef struct pst_index_tree { uint64_t id; uint64_t offset; uint64_t size; int64_t u1; struct pst_index_tree * next; } pst_index_ll; typedef struct pst_index2_tree { uint64_t id2; pst_index_ll *id; struct pst_index2_tree * next; } pst_index2_ll; typedef struct pst_desc_tree { uint64_t id; pst_index_ll * list_index; pst_index_ll * desc; int32_t no_child; struct pst_desc_tree * prev; struct pst_desc_tree * next; struct pst_desc_tree * parent; struct pst_desc_tree * child; struct pst_desc_tree * child_tail; } pst_desc_ll; typedef struct pst_item_email_subject { int off1; int off2; char *subj; } pst_item_email_subject; typedef struct pst_item_email { FILETIME *arrival_date; int autoforward; // 1 = true, 0 = not set, -1 = false char *body; char *cc_address; char *bcc_address; char *common_name; int32_t conv_index; int conversion_prohib; // 1 = true, 0 = false int delete_after_submit; // 1 = true, 0 = false int delivery_report; // 1 = true, 0 = false char *encrypted_body; size_t encrypted_body_size; char *encrypted_htmlbody; size_t encrypted_htmlbody_size; int32_t flag; char *header; char *htmlbody; int32_t importance; char *in_reply_to; int message_cc_me; // 1 = true, 0 = false int message_recip_me; // 1 = true, 0 = false int message_to_me; // 1 = true, 0 = false char *messageid; int32_t orig_sensitivity; char *original_bcc; char *original_cc; char *original_to; char *outlook_recipient; char *outlook_recipient_name; char *outlook_recipient2; char *outlook_sender; char *outlook_sender_name; char *outlook_sender2; int32_t priority; char *proc_subject; int read_receipt; // 1 = true, 0 = false char *recip_access; char *recip_address; char *recip2_access; char *recip2_address; int reply_requested; // 1 = true, 0 = false char *reply_to; char *return_path_address; int32_t rtf_body_char_count; int32_t rtf_body_crc; char *rtf_body_tag; char *rtf_compressed; uint32_t rtf_compressed_size; int rtf_in_sync; // 1 = true, 0 = doesn't exist, -1 = false int32_t rtf_ws_prefix_count; int32_t rtf_ws_trailing_count; char *sender_access; char *sender_address; char *sender2_access; char *sender2_address; int32_t sensitivity; FILETIME *sent_date; pst_entryid *sentmail_folder; char *sentto_address; pst_item_email_subject *subject; } pst_item_email; typedef struct pst_item_folder { int32_t email_count; int32_t unseen_email_count; int32_t assoc_count; int subfolder; // 1 = true, 0 = false } pst_item_folder; typedef struct pst_item_message_store { pst_entryid *top_of_personal_folder; // 0x35e0 pst_entryid *default_outbox_folder; // 0x35e2 pst_entryid *deleted_items_folder; // 0x35e3 pst_entryid *sent_items_folder; // 0x35e4 pst_entryid *user_views_folder; // 0x35e5 pst_entryid *common_view_folder; // 0x35e6 pst_entryid *search_root_folder; // 0x35e7 pst_entryid *top_of_folder; // 0x7c07 int32_t valid_mask; // 0x35df // what folders the message store contains int32_t pwd_chksum; // 0x76ff } pst_item_message_store; typedef struct pst_item_contact { char *access_method; char *account_name; char *address1; char *address1a; char *address1_desc; char *address1_transport; char *address2; char *address2a; char *address2_desc; char *address2_transport; char *address3; char *address3a; char *address3_desc; char *address3_transport; char *assistant_name; char *assistant_phone; char *billing_information; FILETIME *birthday; char *business_address; // 0x801b char *business_city; char *business_country; char *business_fax; char *business_homepage; char *business_phone; char *business_phone2; char *business_po_box; char *business_postal_code; char *business_state; char *business_street; char *callback_phone; char *car_phone; char *company_main_phone; char *company_name; char *computer_name; char *customer_id; char *def_postal_address; char *department; char *display_name_prefix; char *first_name; char *followup; char *free_busy_address; char *ftp_site; char *fullname; int16_t gender; char *gov_id; char *hobbies; char *home_address; // 0x801a char *home_city; char *home_country; char *home_fax; char *home_phone; char *home_phone2; char *home_po_box; char *home_postal_code; char *home_state; char *home_street; char *initials; char *isdn_phone; char *job_title; char *keyword; char *language; char *location; int mail_permission; // 1 = true, 0 = false char *manager_name; char *middle_name; char *mileage; char *mobile_phone; char *nickname; char *office_loc; char *org_id; char *other_address; // 0x801c char *other_city; char *other_country; char *other_phone; char *other_po_box; char *other_postal_code; char *other_state; char *other_street; char *pager_phone; char *personal_homepage; char *pref_name; char *primary_fax; char *primary_phone; char *profession; char *radio_phone; int rich_text; // 1 = true, 0 = false char *spouse_name; char *suffix; char *surname; char *telex; char *transmittable_display_name; char *ttytdd_phone; FILETIME *wedding_anniversary; char *work_address_street; // 0x8045 char *work_address_city; // 0x8046 char *work_address_state; // 0x8047 char *work_address_postalcode; // 0x8048 char *work_address_country; // 0x8049 char *work_address_postofficebox; // 0x804a } pst_item_contact; typedef struct pst_item_attach { char *filename1; char *filename2; char *mimetype; char *data; size_t size; uint64_t id2_val; uint64_t id_val; // calculated from id2_val during creation of record int32_t method; int32_t position; int32_t sequence; struct pst_item_attach *next; } pst_item_attach; typedef struct pst_item_extra_field { char *field_name; char *value; struct pst_item_extra_field *next; } pst_item_extra_field; typedef struct pst_item_journal { FILETIME *end; FILETIME *start; char *type; } pst_item_journal; typedef struct pst_item_appointment { FILETIME *end; char *location; int alarm; // 1 = true, 0 = false FILETIME *reminder; int32_t alarm_minutes; char *alarm_filename; FILETIME *start; char *timezonestring; int32_t showas; int32_t label; int all_day; // 1 = true, 0 = false char *recurrence; int32_t recurrence_type; FILETIME *recurrence_start; FILETIME *recurrence_end; } pst_item_appointment; typedef struct pst_item { struct pst_item_email *email; // data reffering to email struct pst_item_folder *folder; // data reffering to folder struct pst_item_contact *contact; // data reffering to contact struct pst_item_attach *attach; // linked list of attachments struct pst_item_message_store *message_store; // data referring to the message store struct pst_item_extra_field *extra_fields; // linked list of extra headers and such struct pst_item_journal *journal; // data reffering to a journal entry struct pst_item_appointment *appointment; // data reffering to a calendar entry int type; char *ascii_type; char *file_as; char *comment; int32_t message_size; char *outlook_version; char *record_key; // probably 16 bytes long. size_t record_key_size; int response_requested; // 1 = true, 0 = false FILETIME *create_date; FILETIME *modify_date; int private_member; // 1 = true, 0 = false } pst_item; typedef struct pst_x_attrib_ll { uint32_t type; uint32_t mytype; uint32_t map; void *data; struct pst_x_attrib_ll *next; } pst_x_attrib_ll; typedef struct pst_block_recorder { struct pst_block_recorder *next; off_t offset; size_t size; int readcount; } pst_block_recorder; typedef struct pst_file { pst_index_ll *i_head, *i_tail; pst_desc_ll *d_head, *d_tail; pst_x_attrib_ll *x_head; pst_block_recorder *block_head; //set this to 0 to read 32-bit pst files (pre Outlook 2003) //set this to 1 to read 64-bit pst files (Outlook 2003 and later) int do_read64; uint64_t index1; uint64_t index1_back; uint64_t index2; uint64_t index2_back; FILE * fp; // file pointer to opened PST file uint64_t size; // pst file size unsigned char encryption; // pst encryption setting unsigned char ind_type; // pst index type } pst_file; typedef struct pst_block_offset { int16_t from; int16_t to; } pst_block_offset; typedef struct pst_block_offset_pointer { char *from; char *to; int needfree; } pst_block_offset_pointer; typedef struct pst_num_item { uint32_t id; // not an id1 or id2, this is actually some sort of type code char *data; uint32_t type; size_t size; char *extra; } pst_num_item; typedef struct pst_num_array { int32_t count_item; int32_t orig_count; int32_t count_array; struct pst_num_item ** items; struct pst_num_array *next; } pst_num_array; typedef struct pst_holder { char **buf; FILE * fp; int base64; char base64_extra_chars[3]; uint32_t base64_extra; } pst_holder; typedef struct pst_subblock { char *buf; size_t read_size; size_t i_offset; } pst_subblock; typedef struct pst_subblocks { size_t subblock_count; pst_subblock *subs; } pst_subblocks; // prototypes int pst_open(pst_file *pf, char *name); int pst_close(pst_file *pf); pst_desc_ll * pst_getTopOfFolders(pst_file *pf, pst_item *root); size_t pst_attach_to_mem(pst_file *pf, pst_item_attach *attach, char **b); size_t pst_attach_to_file(pst_file *pf, pst_item_attach *attach, FILE* fp); size_t pst_attach_to_file_base64(pst_file *pf, pst_item_attach *attach, FILE* fp); int pst_load_index (pst_file *pf); pst_desc_ll* pst_getNextDptr(pst_desc_ll* d); int pst_load_extended_attributes(pst_file *pf); int pst_build_id_ptr(pst_file *pf, off_t offset, int32_t depth, uint64_t linku1, uint64_t start_val, uint64_t end_val); int pst_build_desc_ptr(pst_file *pf, off_t offset, int32_t depth, uint64_t linku1, uint64_t *high_id, uint64_t start_val, uint64_t end_val); pst_item* pst_getItem(pst_file *pf, pst_desc_ll *d_ptr); pst_item* pst_parse_item (pst_file *pf, pst_desc_ll *d_ptr); pst_num_array* pst_parse_block(pst_file *pf, uint64_t block_id, pst_index2_ll *i2_head, pst_num_array *na_head); int pst_process(pst_num_array *list, pst_item *item, pst_item_attach *attach); void pst_free_list(pst_num_array *list); void pst_freeItem(pst_item *item); void pst_free_id2(pst_index2_ll * head); void pst_free_id (pst_index_ll *head); void pst_free_desc (pst_desc_ll *head); void pst_free_xattrib(pst_x_attrib_ll *x); int pst_getBlockOffsetPointer(pst_file *pf, pst_index2_ll *i2_head, pst_subblocks *subblocks, uint32_t offset, pst_block_offset_pointer *p); int pst_getBlockOffset(char *buf, size_t read_size, uint32_t i_offset, uint32_t offset, pst_block_offset *p); pst_index2_ll* pst_build_id2(pst_file *pf, pst_index_ll* list, pst_index2_ll* head_ptr); pst_index_ll* pst_getID(pst_file* pf, uint64_t id); pst_index_ll* pst_getID2(pst_index2_ll * ptr, uint64_t id); pst_desc_ll* pst_getDptr(pst_file *pf, uint64_t id); size_t pst_read_block_size(pst_file *pf, off_t offset, size_t size, char **buf); int pst_decrypt(uint64_t id, char *buf, size_t size, unsigned char type); uint64_t pst_getIntAt(pst_file *pf, char *buf); uint64_t pst_getIntAtPos(pst_file *pf, off_t pos); size_t pst_getAtPos(pst_file *pf, off_t pos, void* buf, size_t size); size_t pst_ff_getIDblock_dec(pst_file *pf, uint64_t id, char **b); size_t pst_ff_getIDblock(pst_file *pf, uint64_t id, char** b); size_t pst_ff_getID2block(pst_file *pf, uint64_t id2, pst_index2_ll *id2_head, char** buf); size_t pst_ff_getID2data(pst_file *pf, pst_index_ll *ptr, pst_holder *h); size_t pst_ff_compile_ID(pst_file *pf, uint64_t id, pst_holder *h, size_t size); int pst_strincmp(char *a, char *b, size_t x); int pst_stricmp(char *a, char *b); size_t pst_fwrite(const void*ptr, size_t size, size_t nmemb, FILE*stream); char * pst_wide_to_single(char *wt, size_t size); char * pst_rfc2426_escape(char *str); int pst_chr_count(char *str, char x); char * pst_rfc2425_datetime_format(FILETIME *ft); char * pst_rfc2445_datetime_format(FILETIME *ft); void pst_printDptr(pst_file *pf, pst_desc_ll *ptr); void pst_printIDptr(pst_file* pf); void pst_printID2ptr(pst_index2_ll *ptr); #endif // defined LIBPST_H