# HG changeset patch # User Carl Byington # Date 1203029732 28800 # Node ID 7d5c637aaafba1f0a822dc615b0799faec07d888 # Parent a8b772313ff4065f08014001346a6840687052cf General cleanup and code fixes. Use autoscan to cleanup our autoconf system. Use autoconf to detect when we need to use our XGetopt files and other header files. Decode BCC field. Fix missing LE32_CPU byte swapping for FILETIME types. diff -r a8b772313ff4 -r 7d5c637aaafb ChangeLog --- a/ChangeLog Wed Feb 06 23:05:56 2008 -0800 +++ b/ChangeLog Thu Feb 14 14:55:32 2008 -0800 @@ -1,3 +1,11 @@ +LibPST 0.6.7 (2008-xx-xx) +=============================== + * 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) =============================== diff -r a8b772313ff4 -r 7d5c637aaafb README --- a/README Wed Feb 06 23:05:56 2008 -0800 +++ b/README Thu Feb 14 14:55:32 2008 -0800 @@ -1,8 +1,15 @@ - $Id$ - -Try this: +Starting with an unpacked tarball, try this: ./configure make su make install + + +Starting with a mercurial working directory, try this: + + make -f *cvs + ./configure >/dev/null + (cd xml; make; make distclean) + make distcheck + diff -r a8b772313ff4 -r 7d5c637aaafb configure.in --- a/configure.in Wed Feb 06 23:05:56 2008 -0800 +++ b/configure.in Thu Feb 14 14:55:32 2008 -0800 @@ -1,13 +1,46 @@ -AC_INIT(configure.in) +AC_PREREQ(2.59) +AC_INIT(libpst,0.6.6,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. +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 -AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(libpst,0.6.6) -AC_PATH_PROGS(BASH, bash) +# 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([limits.h malloc.h netinet/in.h stdint.h stdlib.h string.h sys/param.h wchar.h]) -AC_LANG_CPLUSPLUS -AC_PROG_CXX -AC_PROG_LIBTOOL -AC_SYS_LARGEFILE +# 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_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: # diff -r a8b772313ff4 -r 7d5c637aaafb package --- a/package Wed Feb 06 23:05:56 2008 -0800 +++ b/package Thu Feb 14 14:55:32 2008 -0800 @@ -1,12 +1,44 @@ #!/bin/bash -T=`grep AM_INIT_AUTOMAKE configure.in | cut -d'(' -f2` +find . -name '*~' | while read a; do rm -f "$a"; done + +# setup environment +T=`grep AC_INIT configure.in | cut -d'(' -f2` NAME=`echo $T | cut -d, -f1` -VER=`echo $T | cut -d, -f2 | cut -d')' -f1` +VER=`echo $T | cut -d, -f2` BALL=$NAME-$VER.tar.gz web=/home/httpd/html/510sg/$NAME distlog=/tmp/distcheck +repo=/usr/hg-repository/$NAME +exit +# check for uncommitted changes +a=$(hg status) +if [ -n "$a" ]; then + hg status + echo "fix those first with 'hg commit'" + exit 0 +fi + +# check for changesets pending push to global repository +hg outgoing $repo | grep 'no changes found' >/dev/null +if [ $? -ne 0 ]; then + hg outgoing $repo + echo "fix those first with 'hg push $repo'" + exit 0 +fi + +# get a new clean copy from source control +orig=$(pwd) +pack=$orig/../$NAME-package +[ -d "$pack" ] && rm -rf "$pack" +mkdir "$pack" +cd "$pack" +hg clone $repo +cd $NAME + +# build the package +mkdir -p $web chown --recursive root:root * make -f *cvs ./configure >/dev/null @@ -24,7 +56,6 @@ cd $NAME-$VER ./configure >/dev/null make >/dev/null - make install >/dev/null cd .. cd .. @@ -56,23 +87,8 @@ tail -10 $distlog fi chown --recursive carl:carl * -#args="--recursive -z -e ssh --times --perms --links --relative --owner --group --numeric-ids --delete" -#echo rsync $args $web ns1:/ -#rsync $args $web ns1:/ -# -#if [ -f /usr/local/bin/pst2ldif ]; then -# pushd /home/ldap -# pst=outlook.pst -# #rm -f pst2ldif.log my.log -# /usr/local/bin/pst2ldif -b 'o=ams-cc.com, c=US' -c 'newPerson' $pst >ams.ldif2 -# #./readpstlog pst2ldif.log | less >my.log -# #hexdump -C $pst >pst.dump -# -# grep '^dn:' ams.ldif2 | sort >aaa -# grep '^dn:' ams.ldif | sort >bbb -# echo 'differences from nightly ldap' -# diff aaa bbb -# echo 'end differences' -# rm -f aaa bbb -# popd -#fi + +# throw away the packaging directory +cd "$pack/.." +rm -rf $NAME-package +cd "$orig" diff -r a8b772313ff4 -r 7d5c637aaafb src/Makefile.am --- a/src/Makefile.am Wed Feb 06 23:05:56 2008 -0800 +++ b/src/Makefile.am Thu Feb 14 14:55:32 2008 -0800 @@ -11,6 +11,13 @@ dumpblocks_SOURCES = dumpblocks.c debug.c libpst.c libstrfunc.c timeconv.c vbuf.c generic.c getidblock_SOURCES = getidblock.c debug.c libpst.c libstrfunc.c timeconv.c vbuf.c generic.c +if NEED_XGETOPT + lspst_SOURCES += XGetopt.c + readpst_SOURCES += XGetopt.c + readpstlog_SOURCES += XGetopt.c + pst2ldif_SOURCES += XGetopt.c +endif + EXTRA_DIST = testdebug.c # set the include path found by configure @@ -22,8 +29,3 @@ readpstlog_LDFLAGS = $(all_libraries) pst2ldif_LDFLAGS = $(all_libraries) -# default compile flags -# lspst_CXXFLAGS = -# readpst_CXXFLAGS = -# readpstlog_CXXFLAGS = -# pst2ldif_CXXFLAGS = diff -r a8b772313ff4 -r 7d5c637aaafb src/common.h --- a/src/common.h Wed Feb 06 23:05:56 2008 -0800 +++ b/src/common.h Thu Feb 14 14:55:32 2008 -0800 @@ -17,6 +17,6 @@ unsigned int dwLowDateTime; unsigned int dwHighDateTime; } FILETIME; -# endif +# endif // FILETIME_DEFINED #endif // _WIN32 #endif // __COMMON_H diff -r a8b772313ff4 -r 7d5c637aaafb src/define.h --- a/src/define.h Wed Feb 06 23:05:56 2008 -0800 +++ b/src/define.h Thu Feb 14 14:55:32 2008 -0800 @@ -40,15 +40,43 @@ #define DEBUG_FUNCRET_NO 10 #define DEBUG_HEXDUMP_NO 11 -//variable number of arguments to this macro. will expand them into -// ## args, then exit with status of 1 #include #include #include +#include +#include +#include +#include +#include +#include +#include -#ifdef __LINUX__ -#include -#include +#ifdef HAVE_UNISTD_H + #include +#else + #include "XGetopt.h" + #ifdef HAVE_DIRECT_H + #include // win32 + #define chdir _chdir + #define int32_t __int32 + #endif + + #ifdef HAVE_WINDOWS_H + #include // win32 + #endif +#endif + +#ifdef HAVE_SYS_STAT_H +# include //mkdir +#endif + +// for reading of directory and clearing in function mk_seperate_dir +#ifdef HAVE_SYS_TYPES_H +# include +#endif + +#ifdef HAVE_DIRENT_H +# include #endif diff -r a8b772313ff4 -r 7d5c637aaafb src/dumpblocks.c --- a/src/dumpblocks.c Wed Feb 06 23:05:56 2008 -0800 +++ b/src/dumpblocks.c Thu Feb 14 14:55:32 2008 -0800 @@ -37,7 +37,7 @@ DEBUG_ENT("main"); printf("Opening file %s\n",file); - if (pst_open(&pstfile, file, "r")) { + if (pst_open(&pstfile, file)) { printf("Failed to open file %s\n", file); exit(1); } diff -r a8b772313ff4 -r 7d5c637aaafb src/getidblock.c --- a/src/getidblock.c Wed Feb 06 23:05:56 2008 -0800 +++ b/src/getidblock.c Thu Feb 14 14:55:32 2008 -0800 @@ -61,7 +61,7 @@ DEBUG_MAIN(("Opening file\n")); memset(&pstfile, 0, sizeof(pstfile)); - if (pst_open(&pstfile, fname, "r")!=0) { + if (pst_open(&pstfile, fname)) { DIE(("Error opening file\n")); } diff -r a8b772313ff4 -r 7d5c637aaafb src/libpst.c --- a/src/libpst.c Wed Feb 06 23:05:56 2008 -0800 +++ b/src/libpst.c Thu Feb 14 14:55:32 2008 -0800 @@ -5,31 +5,13 @@ * dave.s@earthcorp.com */ #include "define.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include // mkdir -#include // for Win32 definition of _O_BINARY #include "libstrfunc.h" #include "vbuf.h" +#include "libpst.h" +#include "timeconv.h" #define ASSERT(x) { if(!(x)) raise( SIGSEGV ); } -#ifdef _MSC_VER -# include -#else -# include -#endif //ifdef _MSC_VER - -#include "libpst.h" -#include "timeconv.h" #define INDEX_TYPE32 0x0E #define INDEX_TYPE64 0x17 @@ -151,7 +133,7 @@ 0xed, 0x9a, 0x64, 0x3f, 0xc1, 0x6c, 0xf9, 0xec}; /*0xff*/ -int pst_open(pst_file *pf, char *name, char *mode) { +int pst_open(pst_file *pf, char *name) { int32_t sig; unicode_init(); @@ -165,11 +147,7 @@ } memset(pf, 0, sizeof(*pf)); -#ifdef _MSC_VER - // set the default open mode for windows - _fmode = _O_BINARY; -#endif //_MSC_VER - if ((pf->fp = fopen(name, mode)) == NULL) { + if ((pf->fp = fopen(name, "rb")) == NULL) { WARN(("cannot open PST file. Error\n")); DEBUG_RET(); return -1; @@ -1758,6 +1736,13 @@ memcpy(targ, list->items[x]->data, list->items[x]->size); \ memset(((char*)targ)+list->items[x]->size, 0, (size_t)1); \ } +// malloc space and copy the item filetime +#define LIST_COPY_TIME(targ) { \ + targ = (FILETIME*) realloc(targ, sizeof(FILETIME)); \ + memcpy(targ, list->items[x]->data, list->items[x]->size); \ + LE32_CPU(targ->dwLowDateTime); \ + LE32_CPU(targ->dwHighDateTime); \ +} // malloc space and copy the current item's data and size #define LIST_COPY_SIZE(targ, type, mysize) { \ mysize = list->items[x]->size; \ @@ -1987,9 +1972,7 @@ case 0x0039: // PR_CLIENT_SUBMIT_TIME Date Email Sent/Created DEBUG_EMAIL(("Date sent - ")); MALLOC_EMAIL(item); - LIST_COPY(item->email->sent_date, (FILETIME*)); - LE32_CPU(item->email->sent_date->dwLowDateTime); - LE32_CPU(item->email->sent_date->dwHighDateTime); + LIST_COPY_TIME(item->email->sent_date); DEBUG_EMAIL(("%s", fileTimeToAscii(item->email->sent_date))); break; case 0x003B: // PR_SENT_REPRESENTING_SEARCH_KEY Sender address 1 @@ -2188,6 +2171,12 @@ item->email->delete_after_submit = 0; } break; + case 0x0E02: // PR_DISPLAY_BCC BCC Addresses + DEBUG_EMAIL(("Display BCC Addresses - ")); + MALLOC_EMAIL(item); + LIST_COPY(item->email->bcc_address, (char*)); + DEBUG_EMAIL(("%s\n", item->email->bcc_address)); + break; case 0x0E03: // PR_DISPLAY_CC CC Addresses DEBUG_EMAIL(("Display CC Addresses - ")); MALLOC_EMAIL(item); @@ -2203,7 +2192,7 @@ case 0x0E06: // PR_MESSAGE_DELIVERY_TIME Date 3 - Email Arrival Date DEBUG_EMAIL(("Date 3 (Delivery Time) - ")); MALLOC_EMAIL(item); - LIST_COPY(item->email->arrival_date, (FILETIME*)); + LIST_COPY_TIME(item->email->arrival_date); DEBUG_EMAIL(("%s", fileTimeToAscii(item->email->arrival_date))); break; case 0x0E07: // PR_MESSAGE_FLAGS Email Flag @@ -2371,12 +2360,12 @@ break; case 0x3007: // PR_CREATION_TIME Date 4 - Creation Date? DEBUG_EMAIL(("Date 4 (Item Creation Date) - ")); - LIST_COPY(item->create_date, (FILETIME*)); + LIST_COPY_TIME(item->create_date); DEBUG_EMAIL(("%s", fileTimeToAscii(item->create_date))); break; case 0x3008: // PR_LAST_MODIFICATION_TIME Date 5 - Modify Date DEBUG_EMAIL(("Date 5 (Modify Date) - ")); - LIST_COPY(item->modify_date, (FILETIME*)); + LIST_COPY_TIME(item->modify_date); DEBUG_EMAIL(("%s", fileTimeToAscii(item->modify_date))); break; case 0x300B: // PR_SEARCH_KEY Record Header 2 @@ -2872,13 +2861,13 @@ case 0x3A41: // PR_WEDDING_ANNIVERSARY DEBUG_EMAIL(("Wedding Anniversary - ")); MALLOC_CONTACT(item); - LIST_COPY(item->contact->wedding_anniversary, (FILETIME*)); + LIST_COPY_TIME(item->contact->wedding_anniversary); DEBUG_EMAIL(("%s\n", fileTimeToAscii(item->contact->wedding_anniversary))); break; case 0x3A42: // PR_BIRTHDAY DEBUG_EMAIL(("Birthday - ")); MALLOC_CONTACT(item); - LIST_COPY(item->contact->birthday, (FILETIME*)); + LIST_COPY_TIME(item->contact->birthday); DEBUG_EMAIL(("%s\n", fileTimeToAscii(item->contact->birthday))); break; case 0x3A43: // PR_HOBBIES @@ -3284,13 +3273,13 @@ case 0x820d: // Appointment start DEBUG_EMAIL(("Appointment Date Start - ")); MALLOC_APPOINTMENT(item); - LIST_COPY(item->appointment->start, (FILETIME*)); + LIST_COPY_TIME(item->appointment->start); DEBUG_EMAIL(("%s\n", fileTimeToAscii(item->appointment->start))); break; case 0x820e: // Appointment end DEBUG_EMAIL(("Appointment Date End - ")); MALLOC_APPOINTMENT(item); - LIST_COPY(item->appointment->end, (FILETIME*)); + LIST_COPY_TIME(item->appointment->end); DEBUG_EMAIL(("%s\n", fileTimeToAscii(item->appointment->end))); break; case 0x8214: // Label for an appointment @@ -3371,13 +3360,13 @@ case 0x8235: // Recurrence start date DEBUG_EMAIL(("Recurrence Start Date - ")); MALLOC_APPOINTMENT(item); - LIST_COPY(item->appointment->recurrence_start, (FILETIME*)); + LIST_COPY_TIME(item->appointment->recurrence_start); DEBUG_EMAIL(("%s\n", fileTimeToAscii(item->appointment->recurrence_start))); break; case 0x8236: // Recurrence end date DEBUG_EMAIL(("Recurrence End Date - ")); MALLOC_APPOINTMENT(item); - LIST_COPY(item->appointment->recurrence_end, (FILETIME*)); + LIST_COPY_TIME(item->appointment->recurrence_end); DEBUG_EMAIL(("%s\n", fileTimeToAscii(item->appointment->recurrence_end))); break; case 0x8501: // Reminder minutes before appointment start @@ -3438,7 +3427,7 @@ case 0x8560: // Appointment Reminder Time DEBUG_EMAIL(("Appointment Reminder Time - ")); MALLOC_APPOINTMENT(item); - LIST_COPY(item->appointment->reminder, (FILETIME*)); + LIST_COPY_TIME(item->appointment->reminder); DEBUG_EMAIL(("%s\n", fileTimeToAscii(item->appointment->reminder))); break; case 0x8700: // Journal Type @@ -3450,13 +3439,13 @@ case 0x8706: // Journal Start date/time DEBUG_EMAIL(("Start Timestamp - ")); MALLOC_JOURNAL(item); - LIST_COPY(item->journal->start, (FILETIME*)); + LIST_COPY_TIME(item->journal->start); DEBUG_EMAIL(("%s\n", fileTimeToAscii(item->journal->start))); break; case 0x8708: // Journal End date/time DEBUG_EMAIL(("End Timestamp - ")); MALLOC_JOURNAL(item); - LIST_COPY(item->journal->end, (FILETIME*)); + LIST_COPY_TIME(item->journal->end); DEBUG_EMAIL(("%s\n", fileTimeToAscii(item->journal->end))); break; case 0x8712: // Title? @@ -3757,6 +3746,7 @@ SAFE_FREE(item->email->arrival_date); SAFE_FREE(item->email->body); SAFE_FREE(item->email->cc_address); + SAFE_FREE(item->email->bcc_address); SAFE_FREE(item->email->common_name); SAFE_FREE(item->email->encrypted_body); SAFE_FREE(item->email->encrypted_htmlbody); diff -r a8b772313ff4 -r 7d5c637aaafb src/libpst.h --- a/src/libpst.h Wed Feb 06 23:05:56 2008 -0800 +++ b/src/libpst.h Thu Feb 14 14:55:32 2008 -0800 @@ -220,6 +220,7 @@ 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 @@ -563,7 +564,7 @@ // prototypes -int pst_open(pst_file *pf, char *name, char *mode); +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); diff -r a8b772313ff4 -r 7d5c637aaafb src/lspst.c --- a/src/lspst.c Wed Feb 06 23:05:56 2008 -0800 +++ b/src/lspst.c Thu Feb 14 14:55:32 2008 -0800 @@ -221,7 +221,7 @@ } // Open PST file - if (pst_open(&pstfile, argv[optind], "r")) DIE(("Error opening File\n")); + if (pst_open(&pstfile, argv[optind])) DIE(("Error opening File\n")); // Load PST index if (pst_load_index(&pstfile)) DIE(("Index Error\n")); diff -r a8b772313ff4 -r 7d5c637aaafb src/pst2ldif.cpp --- a/src/pst2ldif.cpp Wed Feb 06 23:05:56 2008 -0800 +++ b/src/pst2ldif.cpp Thu Feb 14 14:55:32 2008 -0800 @@ -10,42 +10,16 @@ using namespace std; -#include -#include -#include -#include -#include -#include -#include - -#ifndef _WIN32 -# include -# include //mkdir - -// for reading of directory and clearing in function mk_separate_dir -# include -# include -#else -# include -# define chdir _chdir -# define int32_t __int32 -#endif - -#ifndef __GNUC__ -# include "XGetopt.h" -#endif - // needed for std c++ collections #include extern "C" { - #include "libstrfunc.h" // for base64_encoding #include "define.h" + #include "libstrfunc.h" #include "libpst.h" #include "common.h" #include "timeconv.h" #include "lzfu.h" - #include "version.h" } int32_t usage(); @@ -425,7 +399,7 @@ DEBUG_INIT(d_log); DEBUG_REGISTER_CLOSE(); DEBUG_ENT("main"); - RET_DERROR(pst_open(&pstfile, fname, "r"), 1, ("Error opening File\n")); + RET_DERROR(pst_open(&pstfile, fname), 1, ("Error opening File\n")); RET_DERROR(pst_load_index(&pstfile), 2, ("Index Error\n")); pst_load_extended_attributes(&pstfile); diff -r a8b772313ff4 -r 7d5c637aaafb src/readpst.c --- a/src/readpst.c Wed Feb 06 23:05:56 2008 -0800 +++ b/src/readpst.c Thu Feb 14 14:55:32 2008 -0800 @@ -5,39 +5,13 @@ * dave.s@earthcorp.com */ #include "define.h" - -#include -#include -#include -#include -#include -#include -#include +#include "libstrfunc.h" #include "vbuf.h" - -#ifndef _WIN32 -# include -# include //mkdir - -// for reading of directory and clearing in function mk_seperate_dir -# include -# include -#else -# include -# define chdir _chdir -# define int32_t __int32 -#endif - -#ifndef __GNUC__ -# include "XGetopt.h" -#endif - -#include "libstrfunc.h" // for base64_encoding - #include "libpst.h" #include "common.h" #include "timeconv.h" #include "lzfu.h" + #define OUTPUT_TEMPLATE "%s" #define OUTPUT_KMAIL_DIR_TEMPLATE ".%s.directory" #define KMAIL_INDEX ".%s.index" @@ -53,6 +27,7 @@ #else #define D_MKDIR(x) mkdir(x) #endif + struct file_ll { char *name; char *dname; @@ -350,7 +325,7 @@ if (output_mode != OUTPUT_QUIET) printf("Opening PST file and indexes...\n"); - RET_DERROR(pst_open(&pstfile, fname, "r"), 1, ("Error opening File\n")); + RET_DERROR(pst_open(&pstfile, fname), 1, ("Error opening File\n")); RET_DERROR(pst_load_index(&pstfile), 2, ("Index Error\n")); pst_load_extended_attributes(&pstfile); diff -r a8b772313ff4 -r 7d5c637aaafb src/timeconv.c --- a/src/timeconv.c Wed Feb 06 23:05:56 2008 -0800 +++ b/src/timeconv.c Thu Feb 14 14:55:32 2008 -0800 @@ -5,7 +5,7 @@ */ /*** WARNING **** - * This file is not to be incluided in a Visual C++ Project + * This file is not to be included in a Visual C++ Project * It will make the whole project fail to compile * There are functions in libpst.c to handle the dates * Do not use this one