# HG changeset patch # User Carl Byington # Date 1233687550 28800 # Node ID ab2a11e722506c3625169f5171081b30ca53fbc1 # Parent bdb38b434c0a93bf59837d3a1b10f511694e6456 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. diff -r bdb38b434c0a -r ab2a11e72250 ChangeLog --- a/ChangeLog Mon Feb 02 21:55:48 2009 -0800 +++ b/ChangeLog Tue Feb 03 10:59:10 2009 -0800 @@ -12,8 +12,15 @@ * 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. + LibPST 0.6.25 (2009-01-16) =============================== diff -r bdb38b434c0a -r ab2a11e72250 configure.in --- a/configure.in Mon Feb 02 21:55:48 2009 -0800 +++ b/configure.in Tue Feb 03 10:59:10 2009 -0800 @@ -2,10 +2,9 @@ AC_INIT(libpst,0.6.26,carl@five-ten-sg.com) AC_CONFIG_SRCDIR([config.h.in]) AC_CONFIG_HEADER([config.h]) +AM_INIT_AUTOMAKE($PACKAGE_NAME,$PACKAGE_VERSION) +AC_CANONICAL_HOST -AM_INIT_AUTOMAKE($PACKAGE_NAME,$PACKAGE_VERSION) - -AC_CANONICAL_HOST # Check for win32 which needs iconv library specified on the link line AC_MSG_CHECKING([for Win32]) @@ -20,6 +19,7 @@ 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 @@ -56,19 +56,30 @@ enable_dii=yes ) AC_MSG_RESULT([$enable_dii]) -if test "$enable_dii" = "yes"; then - AC_PATH_PROG(CONVERT, convert) - if test "x$CONVERT" = "x" ; then - AC_MSG_WARN([convert not found. pst2dii disabled]) +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 -if test "$enable_dii" = "yes"; then - AC_CHECK_HEADER([gd.h], , [ - enable_dii=no - AC_MSG_WARN([gd.h not found. pst2dii disabled]) - ]) -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"]) @@ -83,9 +94,12 @@ AC_PROG_MAKE_SET AC_PROG_RANLIB + +# make sure we get large file support AC_SYS_LARGEFILE AC_CHECK_SIZEOF(off_t) + # Checks for header files. AC_CHECK_HEADER([unistd.h], AM_CONDITIONAL(NEED_XGETOPT, [test yes = no]), @@ -93,7 +107,8 @@ ) AC_HEADER_DIRENT AC_HEADER_STDC -AC_CHECK_HEADERS([ctype.h dirent.h errno.h fcntl.h inttypes.h limits.h regex.h signal.h stdarg.h stdint.h stdio.h stdlib.h string.h sys/param.h sys/stat.h sys/types.h time.h unistd.h wchar.h]) +AC_CHECK_HEADERS([ctype.h dirent.h errno.h fcntl.h iconv.h inttypes.h limits.h regex.h signal.h stdarg.h stdint.h stdio.h stdlib.h string.h sys/param.h sys/stat.h sys/types.h time.h unistd.h wchar.h]) + # Checks for typedefs, structures, and compiler characteristics. AC_HEADER_STDBOOL @@ -102,6 +117,7 @@ AC_TYPE_SIZE_T AC_STRUCT_TM + # Checks for library functions. AC_FUNC_FSEEKO AC_FUNC_LSTAT @@ -115,6 +131,7 @@ AC_FUNC_VPRINTF AC_CHECK_FUNCS([memchr memmove memset strcasecmp strncasecmp strchr strdup strerror strpbrk strrchr strstr strtol]) + # iconv on mac is a library SAVELIBS="$LIBS" AC_SEARCH_LIBS([iconv_open], [iconv]) @@ -235,13 +252,6 @@ fi -AC_MSG_CHECKING([system enable shared]) -AC_MSG_RESULT([$enable_shared]) -AC_MSG_CHECKING([system enable static]) -AC_MSG_RESULT([$enable_static]) - - - AC_OUTPUT( \ Makefile \ debian/Makefile \ diff -r bdb38b434c0a -r ab2a11e72250 regression/regression-tests.bash --- a/regression/regression-tests.bash Mon Feb 02 21:55:48 2009 -0800 +++ b/regression/regression-tests.bash Tue Feb 03 10:59:10 2009 -0800 @@ -45,23 +45,23 @@ dodii 3 test.pst dodii 4 big_mail.pst else - dopst 1 ams.pst + #dopst 1 ams.pst dopst 2 sample_64.pst dopst 3 test.pst - dopst 4 big_mail.pst + #dopst 4 big_mail.pst dopst 5 mbmg.archive.pst dopst 6 Single2003-read.pst dopst 7 Single2003-unread.pst - dopst 8 ol2k3high.pst - dopst 9 ol97high.pst + #dopst 8 ol2k3high.pst + #dopst 9 ol97high.pst dopst 10 returned_message.pst - dopst 11 flow.pst + #dopst 11 flow.pst dopst 12 test-html.pst dopst 13 test-text.pst - dopst 14 joe.romanowski.pst - dopst 15 hourig1.pst - dopst 16 hourig2.pst - dopst 17 hourig3.pst + #dopst 14 joe.romanowski.pst + #dopst 15 hourig1.pst + #dopst 16 hourig2.pst + #dopst 17 hourig3.pst dopst 18 test-mac.pst fi diff -r bdb38b434c0a -r ab2a11e72250 src/XGetopt.c --- a/src/XGetopt.c Mon Feb 02 21:55:48 2009 -0800 +++ b/src/XGetopt.c Tue Feb 03 10:59:10 2009 -0800 @@ -20,9 +20,10 @@ #ifndef __MINGW32__ /* mingw has getopt() */ -#include -#include -#include "XGetopt.h" +#include "common.h" + +#include "define.h" + /////////////////////////////////////////////////////////////////////////////// // diff -r bdb38b434c0a -r ab2a11e72250 src/common.h --- a/src/common.h Mon Feb 02 21:55:48 2009 -0800 +++ b/src/common.h Tue Feb 03 10:59:10 2009 -0800 @@ -2,6 +2,12 @@ #ifndef __COMMON_H #define __COMMON_H + +#ifdef HAVE_CONFIG_H + #include "config.h" +#endif + + #include #include #include diff -r bdb38b434c0a -r ab2a11e72250 src/debug.c --- a/src/debug.c Mon Feb 02 21:55:48 2009 -0800 +++ b/src/debug.c Tue Feb 03 10:59:10 2009 -0800 @@ -251,19 +251,19 @@ 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; + uint64_t index_pos = ftello(debug_fp); + uint64_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_size = ((curr_items+2) * sizeof(uint64_t)); + uint64_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); + index = (uint64_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 @@ -335,9 +335,9 @@ 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; + int index_size = 3 * sizeof(uint64_t); + uint64_t index[3]; + uint64_t index_pos, file_pos; char zero = '\0'; unsigned int end; if (!debug_fp) return; // no file @@ -397,8 +397,8 @@ 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]; + int index_size = 3 * sizeof(uint64_t); + uint64_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 diff -r bdb38b434c0a -r ab2a11e72250 src/define.h --- a/src/define.h Mon Feb 02 21:55:48 2009 -0800 +++ b/src/define.h Tue Feb 03 10:59:10 2009 -0800 @@ -73,6 +73,18 @@ #include #endif +#ifdef HAVE_ICONV_H + #include +#endif + +#ifdef HAVE_REGEX_H + #include +#endif + +#ifdef HAVE_GD_H + #include +#endif + #define PERM_DIRS 0777 @@ -94,7 +106,6 @@ #error Only MSC and mingw supported for Windows #endif #ifndef __MINGW32__ - #define off_t __int64 #define size_t __int64 #endif #ifndef UINT64_MAX diff -r bdb38b434c0a -r ab2a11e72250 src/libpst.c --- a/src/libpst.c Mon Feb 02 21:55:48 2009 -0800 +++ b/src/libpst.c Tue Feb 03 10:59:10 2009 -0800 @@ -20,21 +20,21 @@ #define INDEX_TYPE32A 0x0F // unknown, but assumed to be similar for now #define INDEX_TYPE64 0x17 #define INDEX_TYPE64A 0x15 // http://sourceforge.net/projects/libpff/ -#define INDEX_TYPE_OFFSET (off_t)0x0A - -#define FILE_SIZE_POINTER32 (off_t)0xA8 -#define INDEX_POINTER32 (off_t)0xC4 -#define INDEX_BACK32 (off_t)0xC0 -#define SECOND_POINTER32 (off_t)0xBC -#define SECOND_BACK32 (off_t)0xB8 -#define ENC_TYPE32 (off_t)0x1CD - -#define FILE_SIZE_POINTER64 (off_t)0xB8 -#define INDEX_POINTER64 (off_t)0xF0 -#define INDEX_BACK64 (off_t)0xE8 -#define SECOND_POINTER64 (off_t)0xE0 -#define SECOND_BACK64 (off_t)0xD8 -#define ENC_TYPE64 (off_t)0x201 +#define INDEX_TYPE_OFFSET (uint64_t)0x0A + +#define FILE_SIZE_POINTER32 (uint64_t)0xA8 +#define INDEX_POINTER32 (uint64_t)0xC4 +#define INDEX_BACK32 (uint64_t)0xC0 +#define SECOND_POINTER32 (uint64_t)0xBC +#define SECOND_BACK32 (uint64_t)0xB8 +#define ENC_TYPE32 (uint64_t)0x1CD + +#define FILE_SIZE_POINTER64 (uint64_t)0xB8 +#define INDEX_POINTER64 (uint64_t)0xF0 +#define INDEX_BACK64 (uint64_t)0xE8 +#define SECOND_POINTER64 (uint64_t)0xE0 +#define SECOND_BACK64 (uint64_t)0xD8 +#define ENC_TYPE64 (uint64_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) @@ -813,7 +813,7 @@ } -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_id_ptr(pst_file *pf, uint64_t offset, int32_t depth, uint64_t linku1, uint64_t start_val, uint64_t end_val) { struct pst_table_ptr_structn table, table2; pst_index_ll *i_ptr=NULL; pst_index index; @@ -926,7 +926,7 @@ } -int pst_build_desc_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, uint64_t offset, int32_t depth, uint64_t linku1, uint64_t start_val, uint64_t end_val) { struct pst_table_ptr_structn table, table2; pst_descn desc_rec; int32_t item_count; @@ -4118,7 +4118,7 @@ is non-NULL, it will first be free()d * @return size of block read into memory */ -size_t pst_read_block_size(pst_file *pf, off_t offset, size_t size, char **buf) { +size_t pst_read_block_size(pst_file *pf, uint64_t offset, size_t size, char **buf) { size_t rsize; DEBUG_ENT("pst_read_block_size"); DEBUG_READ(("Reading block from %#"PRIx64", %x bytes\n", offset, size)); @@ -4210,7 +4210,7 @@ } -uint64_t pst_getIntAtPos(pst_file *pf, off_t pos ) { +uint64_t pst_getIntAtPos(pst_file *pf, uint64_t pos ) { uint64_t buf64; uint32_t buf32; if (pf->do_read64) { @@ -4235,7 +4235,7 @@ * @return actual read size, 0 if seek error */ -size_t pst_getAtPos(pst_file *pf, off_t pos, void* buf, size_t size) { +size_t pst_getAtPos(pst_file *pf, uint64_t pos, void* buf, size_t size) { size_t rc; DEBUG_ENT("pst_getAtPos"); // pst_block_recorder **t = &pf->block_head; diff -r bdb38b434c0a -r ab2a11e72250 src/libpst.h --- a/src/libpst.h Mon Feb 02 21:55:48 2009 -0800 +++ b/src/libpst.h Tue Feb 03 10:59:10 2009 -0800 @@ -460,7 +460,7 @@ typedef struct pst_block_recorder { struct pst_block_recorder *next; - off_t offset; + uint64_t offset; size_t size; int readcount; } pst_block_recorder; @@ -549,8 +549,8 @@ 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 start_val, uint64_t end_val); +int pst_build_id_ptr(pst_file *pf, uint64_t offset, int32_t depth, uint64_t linku1, uint64_t start_val, uint64_t end_val); +int pst_build_desc_ptr(pst_file *pf, uint64_t offset, int32_t depth, uint64_t linku1, uint64_t start_val, uint64_t end_val); pst_item* pst_getItem(pst_file *pf, pst_desc_ll *d_ptr); pst_item* pst_parse_item (pst_file *pf, pst_desc_ll *d_ptr); pst_num_array* pst_parse_block(pst_file *pf, uint64_t block_id, pst_index2_ll *i2_head, pst_num_array *na_head); @@ -567,11 +567,11 @@ 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); +size_t pst_read_block_size(pst_file *pf, uint64_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); +uint64_t pst_getIntAtPos(pst_file *pf, uint64_t pos); +size_t pst_getAtPos(pst_file *pf, uint64_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); diff -r bdb38b434c0a -r ab2a11e72250 src/libstrfunc.c --- a/src/libstrfunc.c Mon Feb 02 21:55:48 2009 -0800 +++ b/src/libstrfunc.c Tue Feb 03 10:59:10 2009 -0800 @@ -1,11 +1,11 @@ /* Taken from LibStrfunc v7.3 */ -#include -#include -#include +#include "common.h" #include "libstrfunc.h" +#include "define.h" + static char base64_code_chars[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=="; diff -r bdb38b434c0a -r ab2a11e72250 src/lzfu.c --- a/src/lzfu.c Mon Feb 02 21:55:48 2009 -0800 +++ b/src/lzfu.c Tue Feb 03 10:59:10 2009 -0800 @@ -15,10 +15,6 @@ #include "define.h" #include "lzfu.h" -#ifdef HAVE_SYS_TYPES_H - #include -#endif - #define LZFU_COMPRESSED 0x75465a4c #define LZFU_UNCOMPRESSED 0x414c454d diff -r bdb38b434c0a -r ab2a11e72250 src/nick2ldif.cpp --- a/src/nick2ldif.cpp Mon Feb 02 21:55:48 2009 -0800 +++ b/src/nick2ldif.cpp Tue Feb 03 10:59:10 2009 -0800 @@ -6,11 +6,10 @@ */ -#include #include -//#include -#include + extern "C" { + #include "common.h" #include "define.h" } diff -r bdb38b434c0a -r ab2a11e72250 src/pst2dii.cpp.in --- a/src/pst2dii.cpp.in Mon Feb 02 21:55:48 2009 -0800 +++ b/src/pst2dii.cpp.in Tue Feb 03 10:59:10 2009 -0800 @@ -7,22 +7,20 @@ Based on readpst.c by David Smith */ -#include -#include #include -#include #include #include using namespace std; extern "C" { - #include "define.h" #include "common.h" #include "libpst.h" #include "timeconv.h" + #include "libstrfunc.h" + + #include "define.h" #include "lzfu.h" - #include "libstrfunc.h" } struct file_ll { diff -r bdb38b434c0a -r ab2a11e72250 src/readpst.c --- a/src/readpst.c Mon Feb 02 21:55:48 2009 -0800 +++ b/src/readpst.c Tue Feb 03 10:59:10 2009 -0800 @@ -13,10 +13,6 @@ #include "define.h" #include "lzfu.h" -#ifdef HAVE_REGEX_H - #include -#endif - #define OUTPUT_TEMPLATE "%s" #define OUTPUT_KMAIL_DIR_TEMPLATE ".%s.directory" #define KMAIL_INDEX ".%s.index" @@ -242,7 +238,7 @@ srand((unsigned)now); if (regcomp(&meta_charset_pattern, "]*content=\"[^>]*charset=([^>\";]*)[\";]", REG_ICASE | REG_EXTENDED)) { - printf("cannot compile regex pattern\n"); + printf("cannot compile regex pattern to find content charset in html bodies\n"); exit(3); } diff -r bdb38b434c0a -r ab2a11e72250 src/readpstlog.c --- a/src/readpstlog.c Mon Feb 02 21:55:48 2009 -0800 +++ b/src/readpstlog.c Tue Feb 03 10:59:10 2009 -0800 @@ -68,13 +68,13 @@ buf = (char*) xmalloc(BUF_SIZE); while (!stop) { - off_t temp; - if (fread(&temp, sizeof(off_t), 1, fp)<=0) break; + uint64_t temp; + if (fread(&temp, sizeof(uint64_t), 1, fp)<=0) break; x = (int)temp; ptr = 0; if (x > 0) { - off_t i[x+1]; // plus 1 because we want to read the offset of the next index - if (get(i, sizeof(off_t), x+1, fp)==0) { + uint64_t i[x+1]; // plus 1 because we want to read the offset of the next index + if (get(i, sizeof(uint64_t), x+1, fp)==0) { // we have reached the end of the debug file printf("oh dear. we must now end\n"); break; diff -r bdb38b434c0a -r ab2a11e72250 src/testdebug.c --- a/src/testdebug.c Mon Feb 02 21:55:48 2009 -0800 +++ b/src/testdebug.c Tue Feb 03 10:59:10 2009 -0800 @@ -1,9 +1,9 @@ +#include "common.h" + #include "define.h" -#include -#include +#define BUF_SIZE 100000 -#define BUF_SIZE 100000 int main(int argc, const char** argv) { char *x = xmalloc(BUF_SIZE); // 10k memset(x, '.', BUF_SIZE-1); diff -r bdb38b434c0a -r ab2a11e72250 src/timeconv.c --- a/src/timeconv.c Mon Feb 02 21:55:48 2009 -0800 +++ b/src/timeconv.c Tue Feb 03 10:59:10 2009 -0800 @@ -13,8 +13,6 @@ #ifndef _WIN32 -#include - #include "common.h" #include "timeconv.h" diff -r bdb38b434c0a -r ab2a11e72250 src/vbuf.c --- a/src/vbuf.c Mon Feb 02 21:55:48 2009 -0800 +++ b/src/vbuf.c Tue Feb 03 10:59:10 2009 -0800 @@ -1,22 +1,10 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "common.h" +#include "vbuf.h" #include "define.h" -#include "vbuf.h" -#ifdef WITH_DMALLOC -#include -#endif -#define STUPID_CR "\r\n" #define ASSERT(x,...) { if( !(x) ) DIE(( __VA_ARGS__)); }