changeset 213:4a659f3138b7

fix pst2dii for shared library changes
author Carl Byington <carl@five-ten-sg.com>
date Mon, 08 Jun 2009 14:47:39 -0700
parents 8e17efed33c1
children 7fcff97ca5a9
files regression/regression-tests.bash src/pst2dii.cpp.in src/readpst.c
diffstat 3 files changed, 19 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/regression/regression-tests.bash	Mon Jun 08 13:51:24 2009 -0700
+++ b/regression/regression-tests.bash	Mon Jun 08 14:47:39 2009 -0700
@@ -20,10 +20,10 @@
 {
     n="$1"
     fn="$2"
+    echo $fn
     rm -rf output$n
     mkdir output$n
-    $val ../src/pst2dii -f /usr/share/fonts/bitstream-vera/VeraMono.ttf -B "bates-" -o output$n -O mydii$n -d dumper $fn >$fn.dii.err 2>&1
-         ../src/readpstlog -f I dumper >$fn.log
+    $val ../src/pst2dii -f /usr/share/fonts/bitstream-vera/VeraMono.ttf -B "bates-" -o output$n -O mydii$n -d $fn.log $fn >$fn.dii.err 2>&1
     rm -f dumper
 }
 
@@ -36,9 +36,7 @@
     ba=$(basename "$fn" .pst)
     rm -rf output$n
     mkdir output$n
-    #$val ../src/pst2ldif -d dumper -b 'o=ams-cc.com, c=US' -c 'newPerson' -o $fn >$ba.ldif.err 2>&1
-    $val ../src/pst2ldif -d dumper -b 'o=ams-cc.com, c=US' -c 'inetOrgPerson' $fn >$ba.ldif.err 2>&1
-         ../src/readpstlog -f I dumper >$ba.ldif.log
+    $val ../src/pst2ldif -d $ba.ldif.log -b 'o=ams-cc.com, c=US' -c 'inetOrgPerson' $fn >$ba.ldif.err 2>&1
     rm -f dumper
 }
 
@@ -101,6 +99,7 @@
     dopst   2 sample_64.pst
     dopst   3 test.pst
     dopst   4 big_mail.pst
+    exit
     dopst   5 mbmg.archive.pst
     dopst   6 Single2003-read.pst
     dopst   7 Single2003-unread.pst
--- a/src/pst2dii.cpp.in	Mon Jun 08 13:51:24 2009 -0700
+++ b/src/pst2dii.cpp.in	Mon Jun 08 14:47:39 2009 -0700
@@ -202,7 +202,7 @@
     }
     DEBUG_INFO(("Saving attachment to %s\n", temp));
     if (!(fp = fopen(temp, "wb"))) {
-        WARN(("write_separate_attachment: Cannot open attachment save file \"%s\"\n", temp));
+        DEBUG_WARN(("write_separate_attachment: Cannot open attachment save file \"%s\"\n", temp));
     } else {
         (void)pst_attach_to_file(pst, current_attach, fp);
         fclose(fp);
@@ -563,13 +563,15 @@
     fprintf(dii_file, "@EMAIL-END\n");
 
     int attach_num = 0;
-    for (pst_item_attach* current_attach = item->attach; current_attach; current_attach = current_attach->next) {
+    for (pst_item_attach* attach = item->attach; attach; attach = attach->next) {
+        pst_convert_utf8_null(item, &attach->filename1);
+        pst_convert_utf8_null(item, &attach->filename2);
+        pst_convert_utf8_null(item, &attach->mimetype);
         DEBUG_INFO(("Attempting Attachment encoding\n"));
-        if (!current_attach->data.data) {
-            DEBUG_WARN(("Data of attachment is NULL!. Size is supposed to be %i\n", current_attach->data.size));
+        if (attach->data.data || attach->i_id) {
+            string an = write_separate_attachment(f.name, attach, ++attach_num, pst);
+            fprintf(dii_file, "@EATTACH %s\n", an.c_str());
         }
-        string an = write_separate_attachment(f.name, current_attach, ++attach_num, pst);
-        fprintf(dii_file, "@EATTACH %s\n", an.c_str());
     }
     close_pdf();
     fprintf(dii_file, "@BATESBEG %d\n", bates);
@@ -581,8 +583,7 @@
 static void create_enter_dir(file_ll &f, file_ll *parent, pst_item *item);
 static void create_enter_dir(file_ll &f, file_ll *parent, pst_item *item)
 {
-    f.email_count  = 0;
-    f.skip_count   = 0;
+    pst_convert_utf8(item, &item->file_as);
     f.type         = item->type;
     f.stored_count = (item->folder) ? item->folder->item_count : 0;
     f.name         = ((parent) ? parent->name + "/" : "") + string(item->file_as.str);
@@ -602,30 +603,28 @@
     pst_item *item = NULL;
     DEBUG_ENT("process");
     create_enter_dir(ff, parent, outeritem);
-    while (d_ptr) {
+    for (; d_ptr; d_ptr = d_ptr->next) {
         if (d_ptr->desc) {
             item = pst_parse_item(&pstfile, d_ptr, NULL);
             DEBUG_INFO(("item pointer is %p\n", item));
             if (item) {
-                if (item->folder && d_ptr->child )  {
+                if (item->folder && item->file_as.str && d_ptr->child )  {
                     //if this is a non-empty folder, we want to recurse into it
                     fprintf(stderr, "entering folder %s\n", item->file_as.str);
                     process(item, &ff, d_ptr->child);
-                } else if (item->email && (item->type == PST_TYPE_NOTE || item->type == PST_TYPE_REPORT || item->type == PST_TYPE_OTHER)) {
+                } else if (item->email && (item->type == PST_TYPE_NOTE || item->type == PST_TYPE_SCHEDULE || item->type == PST_TYPE_REPORT)) {
                     ff.email_count++;
-                    DEBUG_INFO(("Processing Email\n"));
-                    if ((ff.type != PST_TYPE_NOTE) && (ff.type != PST_TYPE_REPORT) && (ff.type != PST_TYPE_OTHER)) {
-                        DEBUG_INFO(("I have an email, but the folder isn't an email folder. Processing anyway\n"));
-                    }
                     write_normal_email(ff, item, &pstfile);
                 }
+                else {
+                    ff.skip_count++;    // other mapi objects
+                }
                 pst_freeItem(item);
             } else {
                 ff.skip_count++;
                 DEBUG_INFO(("A NULL item was seen\n"));
             }
         }
-        d_ptr = d_ptr->next;
     }
     close_enter_dir(ff);
     DEBUG_RET();
--- a/src/readpst.c	Mon Jun 08 13:51:24 2009 -0700
+++ b/src/readpst.c	Mon Jun 08 14:47:39 2009 -0700
@@ -1808,8 +1808,6 @@
 void create_enter_dir(struct file_ll* f, pst_item *item)
 {
     pst_convert_utf8(item, &item->file_as);
-    f->item_count  = 0;
-    f->skip_count   = 0;
     f->type         = item->type;
     f->stored_count = (item->folder) ? item->folder->item_count : 0;