changeset 93:cb14583c119a

iconv changes for Mac
author Carl Byington <carl@five-ten-sg.com>
date Thu, 28 Aug 2008 15:25:53 -0700
parents 93ce964a3f92
children 997cf1373f9e
files AUTHORS ChangeLog NEWS configure.in libpst.spec.in regression/regression-tests.bash src/libpst.c src/vbuf.c
diffstat 8 files changed, 53 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/AUTHORS	Tue Aug 05 12:09:19 2008 -0700
+++ b/AUTHORS	Thu Aug 28 15:25:53 2008 -0700
@@ -19,3 +19,4 @@
     James Woodcock
     Joachim Metz <joachim.metz@gmail.com>
     Robert Simpson <rsimpson@idiscoverglobal.com>
+    Justin Greer <jgreer@nextpoint.com>
--- a/ChangeLog	Tue Aug 05 12:09:19 2008 -0700
+++ b/ChangeLog	Thu Aug 28 15:25:53 2008 -0700
@@ -1,3 +1,7 @@
+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.
--- a/NEWS	Tue Aug 05 12:09:19 2008 -0700
+++ b/NEWS	Thu Aug 28 15:25:53 2008 -0700
@@ -1,3 +1,4 @@
+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.
--- a/configure.in	Tue Aug 05 12:09:19 2008 -0700
+++ b/configure.in	Thu Aug 28 15:25:53 2008 -0700
@@ -1,5 +1,5 @@
 AC_PREREQ(2.59)
-AC_INIT(libpst,0.6.17,carl@five-ten-sg.com)
+AC_INIT(libpst,0.6.18,carl@five-ten-sg.com)
 AC_CONFIG_SRCDIR([config.h.in])
 AC_CONFIG_HEADER([config.h])
 
@@ -56,6 +56,9 @@
 AC_FUNC_VPRINTF
 AC_CHECK_FUNCS([memchr memmove memset strcasecmp strchr strdup strerror strpbrk strrchr strstr strtol])
 
+# iconv on mac is a library
+AC_SEARCH_LIBS([iconv_open], [iconv])
+
 # The following lines adds the --enable-pst-debug option to configure:
 #
 # Give the user the choice to enter one of these:
--- a/libpst.spec.in	Tue Aug 05 12:09:19 2008 -0700
+++ b/libpst.spec.in	Thu Aug 28 15:25:53 2008 -0700
@@ -47,6 +47,9 @@
 
 
 %changelog
+* Thu Aug 28 2008 Carl Byington <carl@five-ten-sg.com> - 0.6.18-1
+- Fixes for iconv on Mac from Justin Greer.
+
 * Tue Aug 05 2008 Carl Byington <carl@five-ten-sg.com> - 0.6.17-1
 - More fixes for 32/64 bit portability on big endian ppc.
 
--- a/regression/regression-tests.bash	Tue Aug 05 12:09:19 2008 -0700
+++ b/regression/regression-tests.bash	Thu Aug 28 15:25:53 2008 -0700
@@ -3,7 +3,11 @@
 val="valgrind --leak-check=full"
 val=''
 
-for i in {1..12}; do
+pushd ..
+make || exit
+popd
+
+for i in {1..13}; do
     rm -rf output$i
     mkdir output$i
 done
@@ -27,7 +31,8 @@
 $val  ../src/readpst -cv    -o output1 ams.pst                       >out1.err 2>&1
 $val  ../src/readpst -cl -r -o output2 ams.pst                       >out2.err 2>&1
 $val  ../src/readpst -S     -o output3 ams.pst                       >out3.err 2>&1
-$val  ../src/readpst -M     -o output4 ams.pst                       >out4.err 2>&1
+$val  ../src/readpst -M     -o output4 -d dumper ams.pst              >out4.err 2>&1
+      ../src/readpstlog -f I dumper >ams.log
 
 $val  ../src/readpst        -o output5 -d dumper mbmg.archive.pst    >out5.err 2>&1
       ../src/readpstlog -f I dumper >mbmg.archive.log
@@ -53,7 +58,10 @@
 $val  ../src/readpst -cv    -o output12 -d dumper ol97high.pst       >out12.err 2>&1
       ../src/readpstlog -f I dumper >ol97high.log
 
-$val  ../src/lspst -d dumper ams.pst                                 >out13.err 2>&1
+$val  ../src/readpst -cv    -o output13 -d dumper returned_message.pst >out13.err 2>&1
+      ../src/readpstlog -f I dumper >returned_message.log
+
+$val  ../src/lspst -d dumper ams.pst                                 >out14.err 2>&1
       ../src/readpstlog -f I dumper >ams.log
 
 rm -f dumper
--- a/src/libpst.c	Tue Aug 05 12:09:19 2008 -0700
+++ b/src/libpst.c	Thu Aug 28 15:25:53 2008 -0700
@@ -290,15 +290,21 @@
 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};
-    size_t size;
+    size_t size = 0;
+    int32_t x;
     DEBUG_ENT("pst_attach_to_file");
     if (attach->id_val != (uint64_t)-1) {
         ptr = pst_getID(pf, attach->id_val);
         if (ptr) {
+            // pst_num_array *list = pst_parse_block(pf, ptr->id, NULL, NULL);
+            // DEBUG_WARN(("writing file data attachment\n"));
+            // for (x=0; x<list->count_item; x++) {
+            //     DEBUG_HEXDUMPC(list->items[x]->data, list->items[x]->size, 0x10);
+            //     (void)pst_fwrite(list->items[x]->data, (size_t)1, list->items[x]->size, fp);
+            // }
             size = pst_ff_getID2data(pf, ptr, &h);
         } else {
             DEBUG_WARN(("Couldn't find ID pointer. Cannot save attachment to file\n"));
-            size = 0;
         }
         attach->size = size;
     } else {
@@ -314,12 +320,23 @@
 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};
-    size_t size;
+    size_t size = 0;
+    int32_t x;
     char *c;
     DEBUG_ENT("pst_attach_to_file_base64");
     if (attach->id_val != (uint64_t)-1) {
         ptr = pst_getID(pf, attach->id_val);
         if (ptr) {
+            // pst_num_array *list = pst_parse_block(pf, ptr->id, NULL, NULL);
+            // DEBUG_WARN(("writing base64 data attachment\n"));
+            // for (x=0; x<list->count_item; x++) {
+            //     DEBUG_HEXDUMPC(list->items[x]->data, list->items[x]->size, 0x10);
+            //     c = base64_encode(list->items[x]->data, list->items[x]->size);
+            //     if (c) {
+            //         (void)pst_fwrite(c, (size_t)1, strlen(c), fp);
+            //         free(c);    // caught by valgrind
+            //     }
+            // }
             size = pst_ff_getID2data(pf, ptr, &h);
             // will need to encode any bytes left over
             c = base64_encode(h.base64_extra_chars, (size_t)h.base64_extra);
@@ -328,8 +345,7 @@
                 free(c);    // caught by valgrind
             }
         } else {
-            DEBUG_WARN (("Couldn't find ID pointer. Cannot save attachment to Base64\n"));
-            size = 0;
+            DEBUG_WARN(("Couldn't find ID pointer. Cannot save attachment to Base64\n"));
         }
         attach->size = size;
     } else {
@@ -431,8 +447,7 @@
         return 0;
     }
 
-    x = 0;
-    while (x < na->count_item) {
+    for (x=0; x < na->count_item; x++) {
         if (na->items[x]->id == (uint32_t)0x0003) {
             buffer = na->items[x]->data;
             bsize = na->items[x]->size;
@@ -442,7 +457,6 @@
         } else {
             // leave them null
         }
-        x++;
     }
 
     if (!buffer) {
@@ -1204,13 +1218,11 @@
             return item;
         }
         else {
-            x = 0;
-            while (x < list->count_array) {
-                attach = (pst_item_attach*) xmalloc (sizeof(pst_item_attach));
-                memset (attach, 0, sizeof(pst_item_attach));
+            for (x=0; x < list->count_array; x++) {
+                attach = (pst_item_attach*) xmalloc(sizeof(pst_item_attach));
+                memset(attach, 0, sizeof(pst_item_attach));
                 attach->next = item->attach;
                 item->attach = attach;
-                x++;
             }
 
             if (pst_process(list, item, item->attach)) {
@@ -4436,8 +4448,6 @@
         DEBUG_READ(("Assuming it is a multi-block record because of it's id\n"));
         ret = pst_ff_compile_ID(pf, ptr->id, h, (size_t)0);
     }
-    // bogus null termination off the end of the buffer!!
-    //if (h->buf && *h->buf) (*(h->buf))[ret]='\0';
     DEBUG_RET();
     return ret;
 }
--- a/src/vbuf.c	Tue Aug 05 12:09:19 2008 -0700
+++ b/src/vbuf.c	Thu Aug 28 15:25:53 2008 -0700
@@ -3,7 +3,6 @@
 #include <errno.h>
 #include <iconv.h>
 #include <limits.h>
-#include <malloc.h>
 #include <signal.h>
 #include <stdarg.h>
 #include <stdio.h>
@@ -71,13 +70,13 @@
     if (unicode_up)
         unicode_close();
 
-    if ((iconv_t) - 1 == (i16to8 = iconv_open("UTF-8", "UTF-16"))) {
-        fprintf(stderr, "doexport(): Couldn't open iconv descriptor for UTF-16 to UTF-8.\n");
+    if ((iconv_t) - 1 == (i16to8 = iconv_open("UTF-8", "UTF-16LE"))) {
+        fprintf(stderr, "doexport(): Couldn't open iconv descriptor for UTF-16LE to UTF-8.\n");
         exit(1);
     }
 
-    if ((iconv_t) - 1 == (i8to16 = iconv_open("UTF-16", "UTF-8"))) {
-        fprintf(stderr, "doexport(): Couldn't open iconv descriptor for UTF-8 to UTF-16.\n");
+    if ((iconv_t) - 1 == (i8to16 = iconv_open("UTF-16LE", "UTF-8"))) {
+        fprintf(stderr, "doexport(): Couldn't open iconv descriptor for UTF-8 to UTF-16LE.\n");
         exit(2);
     }
     //iconv will prefix output with an FF FE (utf-16 start seq), the following dumps that.