Mercurial > libpst
comparison src/libpst.c @ 202:2f38c4ce606f
remove readpstlog, switch to plain ascii debug log files
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Mon, 18 May 2009 15:55:05 -0700 |
parents | 3850a3b11745 |
children | 9fb600ef4e03 |
comparison
equal
deleted
inserted
replaced
201:3850a3b11745 | 202:2f38c4ce606f |
---|---|
401 */ | 401 */ |
402 static void add_descriptor_to_list(pst_desc_tree *node, pst_desc_tree **head, pst_desc_tree **tail); | 402 static void add_descriptor_to_list(pst_desc_tree *node, pst_desc_tree **head, pst_desc_tree **tail); |
403 static void add_descriptor_to_list(pst_desc_tree *node, pst_desc_tree **head, pst_desc_tree **tail) | 403 static void add_descriptor_to_list(pst_desc_tree *node, pst_desc_tree **head, pst_desc_tree **tail) |
404 { | 404 { |
405 DEBUG_ENT("add_descriptor_to_list"); | 405 DEBUG_ENT("add_descriptor_to_list"); |
406 //DEBUG_INDEX(("Added node %#"PRIx64" parent %#"PRIx64" real parent %#"PRIx64" prev %#"PRIx64" next %#"PRIx64"\n", | 406 //DEBUG_INFO(("Added node %#"PRIx64" parent %#"PRIx64" real parent %#"PRIx64" prev %#"PRIx64" next %#"PRIx64"\n", |
407 // node->id, node->parent_d_id, | 407 // node->id, node->parent_d_id, |
408 // (node->parent ? node->parent->id : (uint64_t)0), | 408 // (node->parent ? node->parent->id : (uint64_t)0), |
409 // (node->prev ? node->prev->id : (uint64_t)0), | 409 // (node->prev ? node->prev->id : (uint64_t)0), |
410 // (node->next ? node->next->id : (uint64_t)0))); | 410 // (node->next ? node->next->id : (uint64_t)0))); |
411 if (*tail) (*tail)->next = node; | 411 if (*tail) (*tail)->next = node; |
436 // find any orphan children of this node, and collect them | 436 // find any orphan children of this node, and collect them |
437 pst_desc_tree *n = pf->d_head; | 437 pst_desc_tree *n = pf->d_head; |
438 while (n) { | 438 while (n) { |
439 if (n->parent_d_id == node->d_id) { | 439 if (n->parent_d_id == node->d_id) { |
440 // found a child of this node | 440 // found a child of this node |
441 DEBUG_INDEX(("Found orphan child %#"PRIx64" of parent %#"PRIx64"\n", n->d_id, node->d_id)); | 441 DEBUG_INFO(("Found orphan child %#"PRIx64" of parent %#"PRIx64"\n", n->d_id, node->d_id)); |
442 pst_desc_tree *nn = n->next; | 442 pst_desc_tree *nn = n->next; |
443 pst_desc_tree *pp = n->prev; | 443 pst_desc_tree *pp = n->prev; |
444 node->no_child++; | 444 node->no_child++; |
445 n->parent = node; | 445 n->parent = node; |
446 add_descriptor_to_list(n, &node->child, &node->child_tail); | 446 add_descriptor_to_list(n, &node->child, &node->child_tail); |
454 } | 454 } |
455 | 455 |
456 // now hook this node into the global tree | 456 // now hook this node into the global tree |
457 if (node->parent_d_id == 0) { | 457 if (node->parent_d_id == 0) { |
458 // add top level node to the descriptor tree | 458 // add top level node to the descriptor tree |
459 //DEBUG_INDEX(("Null parent\n")); | 459 //DEBUG_INFO(("Null parent\n")); |
460 add_descriptor_to_list(node, &pf->d_head, &pf->d_tail); | 460 add_descriptor_to_list(node, &pf->d_head, &pf->d_tail); |
461 } | 461 } |
462 else if (node->parent_d_id == node->d_id) { | 462 else if (node->parent_d_id == node->d_id) { |
463 // add top level node to the descriptor tree | 463 // add top level node to the descriptor tree |
464 DEBUG_INDEX(("%#"PRIx64" is its own parent. What is this world coming to?\n", node->d_id)); | 464 DEBUG_INFO(("%#"PRIx64" is its own parent. What is this world coming to?\n", node->d_id)); |
465 add_descriptor_to_list(node, &pf->d_head, &pf->d_tail); | 465 add_descriptor_to_list(node, &pf->d_head, &pf->d_tail); |
466 } else { | 466 } else { |
467 //DEBUG_INDEX(("Searching for parent %#"PRIx64" of %#"PRIx64"\n", node->parent_d_id, node->d_id)); | 467 //DEBUG_INFO(("Searching for parent %#"PRIx64" of %#"PRIx64"\n", node->parent_d_id, node->d_id)); |
468 pst_desc_tree *parent = pst_getDptr(pf, node->parent_d_id); | 468 pst_desc_tree *parent = pst_getDptr(pf, node->parent_d_id); |
469 if (parent) { | 469 if (parent) { |
470 //DEBUG_INDEX(("Found parent %#"PRIx64"\n", node->parent_d_id)); | 470 //DEBUG_INFO(("Found parent %#"PRIx64"\n", node->parent_d_id)); |
471 parent->no_child++; | 471 parent->no_child++; |
472 node->parent = parent; | 472 node->parent = parent; |
473 add_descriptor_to_list(node, &parent->child, &parent->child_tail); | 473 add_descriptor_to_list(node, &parent->child, &parent->child_tail); |
474 } | 474 } |
475 else { | 475 else { |
476 DEBUG_INDEX(("No parent %#"PRIx64", have an orphan child %#"PRIx64"\n", node->parent_d_id, node->d_id)); | 476 DEBUG_INFO(("No parent %#"PRIx64", have an orphan child %#"PRIx64"\n", node->parent_d_id, node->d_id)); |
477 add_descriptor_to_list(node, &pf->d_head, &pf->d_tail); | 477 add_descriptor_to_list(node, &pf->d_head, &pf->d_tail); |
478 } | 478 } |
479 } | 479 } |
480 DEBUG_RET(); | 480 DEBUG_RET(); |
481 } | 481 } |
504 pst_desc_tree* pst_getTopOfFolders(pst_file *pf, const pst_item *root) { | 504 pst_desc_tree* pst_getTopOfFolders(pst_file *pf, const pst_item *root) { |
505 pst_desc_tree *topnode; | 505 pst_desc_tree *topnode; |
506 uint32_t topid; | 506 uint32_t topid; |
507 DEBUG_ENT("pst_getTopOfFolders"); | 507 DEBUG_ENT("pst_getTopOfFolders"); |
508 if (!root || !root->message_store) { | 508 if (!root || !root->message_store) { |
509 DEBUG_INDEX(("There isn't a top of folder record here.\n")); | 509 DEBUG_INFO(("There isn't a top of folder record here.\n")); |
510 DEBUG_RET(); | 510 DEBUG_RET(); |
511 return NULL; | 511 return NULL; |
512 } | 512 } |
513 if (!root->message_store->top_of_personal_folder) { | 513 if (!root->message_store->top_of_personal_folder) { |
514 // this is the OST way | 514 // this is the OST way |
515 // ASSUMPTION: Top Of Folders record in PST files is *always* descid 0x2142 | 515 // ASSUMPTION: Top Of Folders record in PST files is *always* descid 0x2142 |
516 topid = 0x2142; | 516 topid = 0x2142; |
517 } else { | 517 } else { |
518 topid = root->message_store->top_of_personal_folder->id; | 518 topid = root->message_store->top_of_personal_folder->id; |
519 } | 519 } |
520 DEBUG_INDEX(("looking for top of folder descriptor %#"PRIx32"\n", topid)); | 520 DEBUG_INFO(("looking for top of folder descriptor %#"PRIx32"\n", topid)); |
521 topnode = pst_getDptr(pf, (uint64_t)topid); | 521 topnode = pst_getDptr(pf, (uint64_t)topid); |
522 if (!topnode) { | 522 if (!topnode) { |
523 // add dummy top record to pickup orphan children | 523 // add dummy top record to pickup orphan children |
524 topnode = (pst_desc_tree*) pst_malloc(sizeof(pst_desc_tree)); | 524 topnode = (pst_desc_tree*) pst_malloc(sizeof(pst_desc_tree)); |
525 topnode->d_id = topid; | 525 topnode->d_id = topid; |
617 DEBUG_RET(); | 617 DEBUG_RET(); |
618 return -1; | 618 return -1; |
619 } | 619 } |
620 | 620 |
621 x = pst_build_id_ptr(pf, pf->index1, 0, pf->index1_back, 0, UINT64_MAX); | 621 x = pst_build_id_ptr(pf, pf->index1, 0, pf->index1_back, 0, UINT64_MAX); |
622 DEBUG_INDEX(("build id ptr returns %i\n", x)); | 622 DEBUG_INFO(("build id ptr returns %i\n", x)); |
623 | 623 |
624 x = pst_build_desc_ptr(pf, pf->index2, 0, pf->index2_back, (uint64_t)0x21, UINT64_MAX); | 624 x = pst_build_desc_ptr(pf, pf->index2, 0, pf->index2_back, (uint64_t)0x21, UINT64_MAX); |
625 DEBUG_INDEX(("build desc ptr returns %i\n", x)); | 625 DEBUG_INFO(("build desc ptr returns %i\n", x)); |
626 | 626 |
627 DEBUG_CODE((void)pst_printDptr(pf, pf->d_head);); | 627 pst_printDptr(pf, pf->d_head); |
628 | |
628 DEBUG_RET(); | 629 DEBUG_RET(); |
629 return 0; | 630 return 0; |
630 } | 631 } |
631 | 632 |
632 | 633 |
692 pst_free_id2(id2_head); | 693 pst_free_id2(id2_head); |
693 DEBUG_RET(); | 694 DEBUG_RET(); |
694 return 0; | 695 return 0; |
695 } | 696 } |
696 | 697 |
697 DEBUG_EMAIL(("look thru d_id 0x61 list of mapi objects\n")); | 698 DEBUG_INFO(("look thru d_id 0x61 list of mapi objects\n")); |
698 for (x=0; x < list->count_elements; x++) { | 699 for (x=0; x < list->count_elements; x++) { |
699 DEBUG_EMAIL(("#%d - mapi-id: %#x type: %#x length: %#x\n", x, list->elements[x]->mapi_id, list->elements[x]->type, list->elements[x]->size)); | 700 DEBUG_INFO(("#%d - mapi-id: %#x type: %#x length: %#x\n", x, list->elements[x]->mapi_id, list->elements[x]->type, list->elements[x]->size)); |
700 if (list->elements[x]->data) { | 701 if (list->elements[x]->data) { |
701 DEBUG_HEXDUMPC(list->elements[x]->data, list->elements[x]->size, 0x10); | 702 DEBUG_HEXDUMPC(list->elements[x]->data, list->elements[x]->size, 0x10); |
702 } | 703 } |
703 if (list->elements[x]->mapi_id == (uint32_t)0x0003) { | 704 if (list->elements[x]->mapi_id == (uint32_t)0x0003) { |
704 buffer = list->elements[x]->data; | 705 buffer = list->elements[x]->data; |
725 xattrib.map = PST_LE_GET_UINT16(buffer+bptr), bptr += 2; | 726 xattrib.map = PST_LE_GET_UINT16(buffer+bptr), bptr += 2; |
726 ptr = (pst_x_attrib_ll*) pst_malloc(sizeof(*ptr)); | 727 ptr = (pst_x_attrib_ll*) pst_malloc(sizeof(*ptr)); |
727 memset(ptr, 0, sizeof(*ptr)); | 728 memset(ptr, 0, sizeof(*ptr)); |
728 ptr->map = xattrib.map+0x8000; | 729 ptr->map = xattrib.map+0x8000; |
729 ptr->next = NULL; | 730 ptr->next = NULL; |
730 DEBUG_INDEX(("xattrib: ext = %#"PRIx32", type = %#"PRIx16", map = %#"PRIx16"\n", | 731 DEBUG_INFO(("xattrib: ext = %#"PRIx32", type = %#"PRIx16", map = %#"PRIx16"\n", |
731 xattrib.extended, xattrib.type, xattrib.map)); | 732 xattrib.extended, xattrib.type, xattrib.map)); |
732 if (xattrib.type & 0x0001) { // if the Bit 1 is set | 733 if (xattrib.type & 0x0001) { // if the Bit 1 is set |
733 // pointer to Unicode field in buffer | 734 // pointer to Unicode field in buffer |
734 if (xattrib.extended < hsize) { | 735 if (xattrib.extended < hsize) { |
735 char *wt; | 736 char *wt; |
739 wt = (char*) pst_malloc((size_t)(tint+2)); // plus 2 for a uni-code zero | 740 wt = (char*) pst_malloc((size_t)(tint+2)); // plus 2 for a uni-code zero |
740 memset(wt, 0, (size_t)(tint+2)); | 741 memset(wt, 0, (size_t)(tint+2)); |
741 memcpy(wt, &(headerbuffer[xattrib.extended+sizeof(tint)]), (size_t)tint); | 742 memcpy(wt, &(headerbuffer[xattrib.extended+sizeof(tint)]), (size_t)tint); |
742 ptr->data = pst_wide_to_single(wt, (size_t)tint); | 743 ptr->data = pst_wide_to_single(wt, (size_t)tint); |
743 free(wt); | 744 free(wt); |
744 DEBUG_INDEX(("Mapped attribute %#"PRIx32" to %s\n", ptr->map, ptr->data)); | 745 DEBUG_INFO(("Mapped attribute %#"PRIx32" to %s\n", ptr->map, ptr->data)); |
745 } else { | 746 } else { |
746 DEBUG_INDEX(("Cannot read outside of buffer [%i !< %i]\n", xattrib.extended, hsize)); | 747 DEBUG_INFO(("Cannot read outside of buffer [%i !< %i]\n", xattrib.extended, hsize)); |
747 err = 1; | 748 err = 1; |
748 } | 749 } |
749 ptr->mytype = PST_MAP_HEADER; | 750 ptr->mytype = PST_MAP_HEADER; |
750 } else { | 751 } else { |
751 // contains the attribute code to map to. | 752 // contains the attribute code to map to. |
752 ptr->data = (uint32_t*)pst_malloc(sizeof(uint32_t)); | 753 ptr->data = (uint32_t*)pst_malloc(sizeof(uint32_t)); |
753 memset(ptr->data, 0, sizeof(uint32_t)); | 754 memset(ptr->data, 0, sizeof(uint32_t)); |
754 *((uint32_t*)ptr->data) = xattrib.extended; | 755 *((uint32_t*)ptr->data) = xattrib.extended; |
755 ptr->mytype = PST_MAP_ATTRIB; | 756 ptr->mytype = PST_MAP_ATTRIB; |
756 DEBUG_INDEX(("Mapped attribute %#"PRIx32" to %#"PRIx32"\n", ptr->map, *((uint32_t*)ptr->data))); | 757 DEBUG_INFO(("Mapped attribute %#"PRIx32" to %#"PRIx32"\n", ptr->map, *((uint32_t*)ptr->data))); |
757 } | 758 } |
758 | 759 |
759 if (!err) { | 760 if (!err) { |
760 // add it to the list | 761 // add it to the list |
761 pst_x_attrib_ll *p_sh = p_head; | 762 pst_x_attrib_ll *p_sh = p_head; |
814 | 815 |
815 static size_t pst_decode_desc(pst_file *pf, pst_desc *desc, char *buf); | 816 static size_t pst_decode_desc(pst_file *pf, pst_desc *desc, char *buf); |
816 static size_t pst_decode_desc(pst_file *pf, pst_desc *desc, char *buf) { | 817 static size_t pst_decode_desc(pst_file *pf, pst_desc *desc, char *buf) { |
817 size_t r; | 818 size_t r; |
818 if (pf->do_read64) { | 819 if (pf->do_read64) { |
819 DEBUG_INDEX(("Decoding desc64\n")); | 820 DEBUG_INFO(("Decoding desc64\n")); |
820 DEBUG_HEXDUMPC(buf, sizeof(pst_desc), 0x10); | 821 DEBUG_HEXDUMPC(buf, sizeof(pst_desc), 0x10); |
821 memcpy(desc, buf, sizeof(pst_desc)); | 822 memcpy(desc, buf, sizeof(pst_desc)); |
822 LE64_CPU(desc->d_id); | 823 LE64_CPU(desc->d_id); |
823 LE64_CPU(desc->desc_id); | 824 LE64_CPU(desc->desc_id); |
824 LE64_CPU(desc->tree_id); | 825 LE64_CPU(desc->tree_id); |
826 LE32_CPU(desc->u1); | 827 LE32_CPU(desc->u1); |
827 r = sizeof(pst_desc); | 828 r = sizeof(pst_desc); |
828 } | 829 } |
829 else { | 830 else { |
830 pst_desc32 d32; | 831 pst_desc32 d32; |
831 DEBUG_INDEX(("Decoding desc32\n")); | 832 DEBUG_INFO(("Decoding desc32\n")); |
832 DEBUG_HEXDUMPC(buf, sizeof(pst_desc32), 0x10); | 833 DEBUG_HEXDUMPC(buf, sizeof(pst_desc32), 0x10); |
833 memcpy(&d32, buf, sizeof(pst_desc32)); | 834 memcpy(&d32, buf, sizeof(pst_desc32)); |
834 LE32_CPU(d32.d_id); | 835 LE32_CPU(d32.d_id); |
835 LE32_CPU(d32.desc_id); | 836 LE32_CPU(d32.desc_id); |
836 LE32_CPU(d32.tree_id); | 837 LE32_CPU(d32.tree_id); |
848 | 849 |
849 static size_t pst_decode_table(pst_file *pf, struct pst_table_ptr_struct *table, char *buf); | 850 static size_t pst_decode_table(pst_file *pf, struct pst_table_ptr_struct *table, char *buf); |
850 static size_t pst_decode_table(pst_file *pf, struct pst_table_ptr_struct *table, char *buf) { | 851 static size_t pst_decode_table(pst_file *pf, struct pst_table_ptr_struct *table, char *buf) { |
851 size_t r; | 852 size_t r; |
852 if (pf->do_read64) { | 853 if (pf->do_read64) { |
853 DEBUG_INDEX(("Decoding table64\n")); | 854 DEBUG_INFO(("Decoding table64\n")); |
854 DEBUG_HEXDUMPC(buf, sizeof(struct pst_table_ptr_struct), 0x10); | 855 DEBUG_HEXDUMPC(buf, sizeof(struct pst_table_ptr_struct), 0x10); |
855 memcpy(table, buf, sizeof(struct pst_table_ptr_struct)); | 856 memcpy(table, buf, sizeof(struct pst_table_ptr_struct)); |
856 LE64_CPU(table->start); | 857 LE64_CPU(table->start); |
857 LE64_CPU(table->u1); | 858 LE64_CPU(table->u1); |
858 LE64_CPU(table->offset); | 859 LE64_CPU(table->offset); |
859 r =sizeof(struct pst_table_ptr_struct); | 860 r =sizeof(struct pst_table_ptr_struct); |
860 } | 861 } |
861 else { | 862 else { |
862 struct pst_table_ptr_struct32 t32; | 863 struct pst_table_ptr_struct32 t32; |
863 DEBUG_INDEX(("Decoding table32\n")); | 864 DEBUG_INFO(("Decoding table32\n")); |
864 DEBUG_HEXDUMPC(buf, sizeof( struct pst_table_ptr_struct32), 0x10); | 865 DEBUG_HEXDUMPC(buf, sizeof( struct pst_table_ptr_struct32), 0x10); |
865 memcpy(&t32, buf, sizeof(struct pst_table_ptr_struct32)); | 866 memcpy(&t32, buf, sizeof(struct pst_table_ptr_struct32)); |
866 LE32_CPU(t32.start); | 867 LE32_CPU(t32.start); |
867 LE32_CPU(t32.u1); | 868 LE32_CPU(t32.u1); |
868 LE32_CPU(t32.offset); | 869 LE32_CPU(t32.offset); |
877 | 878 |
878 static size_t pst_decode_index(pst_file *pf, pst_index *index, char *buf); | 879 static size_t pst_decode_index(pst_file *pf, pst_index *index, char *buf); |
879 static size_t pst_decode_index(pst_file *pf, pst_index *index, char *buf) { | 880 static size_t pst_decode_index(pst_file *pf, pst_index *index, char *buf) { |
880 size_t r; | 881 size_t r; |
881 if (pf->do_read64) { | 882 if (pf->do_read64) { |
882 DEBUG_INDEX(("Decoding index64\n")); | 883 DEBUG_INFO(("Decoding index64\n")); |
883 DEBUG_HEXDUMPC(buf, sizeof(pst_index), 0x10); | 884 DEBUG_HEXDUMPC(buf, sizeof(pst_index), 0x10); |
884 memcpy(index, buf, sizeof(pst_index)); | 885 memcpy(index, buf, sizeof(pst_index)); |
885 LE64_CPU(index->id); | 886 LE64_CPU(index->id); |
886 LE64_CPU(index->offset); | 887 LE64_CPU(index->offset); |
887 LE16_CPU(index->size); | 888 LE16_CPU(index->size); |
888 LE16_CPU(index->u0); | 889 LE16_CPU(index->u0); |
889 LE32_CPU(index->u1); | 890 LE32_CPU(index->u1); |
890 r = sizeof(pst_index); | 891 r = sizeof(pst_index); |
891 } else { | 892 } else { |
892 pst_index32 index32; | 893 pst_index32 index32; |
893 DEBUG_INDEX(("Decoding index32\n")); | 894 DEBUG_INFO(("Decoding index32\n")); |
894 DEBUG_HEXDUMPC(buf, sizeof(pst_index32), 0x10); | 895 DEBUG_HEXDUMPC(buf, sizeof(pst_index32), 0x10); |
895 memcpy(&index32, buf, sizeof(pst_index32)); | 896 memcpy(&index32, buf, sizeof(pst_index32)); |
896 LE32_CPU(index32.id); | 897 LE32_CPU(index32.id); |
897 LE32_CPU(index32.offset); | 898 LE32_CPU(index32.offset); |
898 LE16_CPU(index32.size); | 899 LE16_CPU(index32.size); |
910 | 911 |
911 static size_t pst_decode_assoc(pst_file *pf, pst_id2_assoc *assoc, char *buf); | 912 static size_t pst_decode_assoc(pst_file *pf, pst_id2_assoc *assoc, char *buf); |
912 static size_t pst_decode_assoc(pst_file *pf, pst_id2_assoc *assoc, char *buf) { | 913 static size_t pst_decode_assoc(pst_file *pf, pst_id2_assoc *assoc, char *buf) { |
913 size_t r; | 914 size_t r; |
914 if (pf->do_read64) { | 915 if (pf->do_read64) { |
915 DEBUG_INDEX(("Decoding assoc64\n")); | 916 DEBUG_INFO(("Decoding assoc64\n")); |
916 DEBUG_HEXDUMPC(buf, sizeof(pst_id2_assoc), 0x10); | 917 DEBUG_HEXDUMPC(buf, sizeof(pst_id2_assoc), 0x10); |
917 memcpy(assoc, buf, sizeof(pst_id2_assoc)); | 918 memcpy(assoc, buf, sizeof(pst_id2_assoc)); |
918 LE32_CPU(assoc->id2); | 919 LE32_CPU(assoc->id2); |
919 LE64_CPU(assoc->id); | 920 LE64_CPU(assoc->id); |
920 LE64_CPU(assoc->child_id); | 921 LE64_CPU(assoc->child_id); |
921 r = sizeof(pst_id2_assoc); | 922 r = sizeof(pst_id2_assoc); |
922 } else { | 923 } else { |
923 pst_id2_assoc32 assoc32; | 924 pst_id2_assoc32 assoc32; |
924 DEBUG_INDEX(("Decoding assoc32\n")); | 925 DEBUG_INFO(("Decoding assoc32\n")); |
925 DEBUG_HEXDUMPC(buf, sizeof(pst_id2_assoc32), 0x10); | 926 DEBUG_HEXDUMPC(buf, sizeof(pst_id2_assoc32), 0x10); |
926 memcpy(&assoc32, buf, sizeof(pst_id2_assoc32)); | 927 memcpy(&assoc32, buf, sizeof(pst_id2_assoc32)); |
927 LE32_CPU(assoc32.id2); | 928 LE32_CPU(assoc32.id2); |
928 LE32_CPU(assoc32.id); | 929 LE32_CPU(assoc32.id); |
929 LE32_CPU(assoc32.child_id); | 930 LE32_CPU(assoc32.child_id); |
938 | 939 |
939 static size_t pst_decode_type3(pst_file *pf, pst_table3_rec *table3_rec, char *buf); | 940 static size_t pst_decode_type3(pst_file *pf, pst_table3_rec *table3_rec, char *buf); |
940 static size_t pst_decode_type3(pst_file *pf, pst_table3_rec *table3_rec, char *buf) { | 941 static size_t pst_decode_type3(pst_file *pf, pst_table3_rec *table3_rec, char *buf) { |
941 size_t r; | 942 size_t r; |
942 if (pf->do_read64) { | 943 if (pf->do_read64) { |
943 DEBUG_INDEX(("Decoding table3 64\n")); | 944 DEBUG_INFO(("Decoding table3 64\n")); |
944 DEBUG_HEXDUMPC(buf, sizeof(pst_table3_rec), 0x10); | 945 DEBUG_HEXDUMPC(buf, sizeof(pst_table3_rec), 0x10); |
945 memcpy(table3_rec, buf, sizeof(pst_table3_rec)); | 946 memcpy(table3_rec, buf, sizeof(pst_table3_rec)); |
946 LE64_CPU(table3_rec->id); | 947 LE64_CPU(table3_rec->id); |
947 r = sizeof(pst_table3_rec); | 948 r = sizeof(pst_table3_rec); |
948 } else { | 949 } else { |
949 pst_table3_rec32 table3_rec32; | 950 pst_table3_rec32 table3_rec32; |
950 DEBUG_INDEX(("Decoding table3 32\n")); | 951 DEBUG_INFO(("Decoding table3 32\n")); |
951 DEBUG_HEXDUMPC(buf, sizeof(pst_table3_rec32), 0x10); | 952 DEBUG_HEXDUMPC(buf, sizeof(pst_table3_rec32), 0x10); |
952 memcpy(&table3_rec32, buf, sizeof(pst_table3_rec32)); | 953 memcpy(&table3_rec32, buf, sizeof(pst_table3_rec32)); |
953 LE32_CPU(table3_rec32.id); | 954 LE32_CPU(table3_rec32.id); |
954 table3_rec->id = table3_rec32.id; | 955 table3_rec->id = table3_rec32.id; |
955 r = sizeof(pst_table3_rec32); | 956 r = sizeof(pst_table3_rec32); |
970 int32_t x, item_count; | 971 int32_t x, item_count; |
971 uint64_t old = start_val; | 972 uint64_t old = start_val; |
972 char *buf = NULL, *bptr; | 973 char *buf = NULL, *bptr; |
973 | 974 |
974 DEBUG_ENT("pst_build_id_ptr"); | 975 DEBUG_ENT("pst_build_id_ptr"); |
975 DEBUG_INDEX(("offset %#"PRIx64" depth %i linku1 %#"PRIx64" start %#"PRIx64" end %#"PRIx64"\n", offset, depth, linku1, start_val, end_val)); | 976 DEBUG_INFO(("offset %#"PRIx64" depth %i linku1 %#"PRIx64" start %#"PRIx64" end %#"PRIx64"\n", offset, depth, linku1, start_val, end_val)); |
976 if (end_val <= start_val) { | 977 if (end_val <= start_val) { |
977 DEBUG_WARN(("The end value is BEFORE the start value. This function will quit. Soz. [start:%#"PRIx64", end:%#"PRIx64"]\n", start_val, end_val)); | 978 DEBUG_WARN(("The end value is BEFORE the start value. This function will quit. Soz. [start:%#"PRIx64", end:%#"PRIx64"]\n", start_val, end_val)); |
978 DEBUG_RET(); | 979 DEBUG_RET(); |
979 return -1; | 980 return -1; |
980 } | 981 } |
981 DEBUG_INDEX(("Reading index block\n")); | 982 DEBUG_INFO(("Reading index block\n")); |
982 if (pst_read_block_size(pf, offset, BLOCK_SIZE, &buf) < BLOCK_SIZE) { | 983 if (pst_read_block_size(pf, offset, BLOCK_SIZE, &buf) < BLOCK_SIZE) { |
983 DEBUG_WARN(("Failed to read %i bytes\n", BLOCK_SIZE)); | 984 DEBUG_WARN(("Failed to read %i bytes\n", BLOCK_SIZE)); |
984 if (buf) free(buf); | 985 if (buf) free(buf); |
985 DEBUG_RET(); | 986 DEBUG_RET(); |
986 return -1; | 987 return -1; |
1007 x = 0; | 1008 x = 0; |
1008 while (x < item_count) { | 1009 while (x < item_count) { |
1009 bptr += pst_decode_index(pf, &index, bptr); | 1010 bptr += pst_decode_index(pf, &index, bptr); |
1010 x++; | 1011 x++; |
1011 if (index.id == 0) break; | 1012 if (index.id == 0) break; |
1012 DEBUG_INDEX(("[%i]%i Item [id = %#"PRIx64", offset = %#"PRIx64", u1 = %#x, size = %i(%#x)]\n", | 1013 DEBUG_INFO(("[%i]%i Item [id = %#"PRIx64", offset = %#"PRIx64", u1 = %#x, size = %i(%#x)]\n", |
1013 depth, x, index.id, index.offset, index.u1, index.size, index.size)); | 1014 depth, x, index.id, index.offset, index.u1, index.size, index.size)); |
1014 // if (index.id & 0x02) DEBUG_INDEX(("two-bit set!!\n")); | 1015 // if (index.id & 0x02) DEBUG_INFO(("two-bit set!!\n")); |
1015 if ((index.id >= end_val) || (index.id < old)) { | 1016 if ((index.id >= end_val) || (index.id < old)) { |
1016 DEBUG_WARN(("This item isn't right. Must be corruption, or I got it wrong!\n")); | 1017 DEBUG_WARN(("This item isn't right. Must be corruption, or I got it wrong!\n")); |
1017 if (buf) free(buf); | 1018 if (buf) free(buf); |
1018 DEBUG_RET(); | 1019 DEBUG_RET(); |
1019 return -1; | 1020 return -1; |
1048 (void)pst_decode_table(pf, &table2, bptr); | 1049 (void)pst_decode_table(pf, &table2, bptr); |
1049 } | 1050 } |
1050 else { | 1051 else { |
1051 table2.start = end_val; | 1052 table2.start = end_val; |
1052 } | 1053 } |
1053 DEBUG_INDEX(("[%i] %i Index Table [start id = %#"PRIx64", u1 = %#"PRIx64", offset = %#"PRIx64", end id = %#"PRIx64"]\n", | 1054 DEBUG_INFO(("[%i] %i Index Table [start id = %#"PRIx64", u1 = %#"PRIx64", offset = %#"PRIx64", end id = %#"PRIx64"]\n", |
1054 depth, x, table.start, table.u1, table.offset, table2.start)); | 1055 depth, x, table.start, table.u1, table.offset, table2.start)); |
1055 if ((table.start >= end_val) || (table.start < old)) { | 1056 if ((table.start >= end_val) || (table.start < old)) { |
1056 DEBUG_WARN(("This table isn't right. Must be corruption, or I got it wrong!\n")); | 1057 DEBUG_WARN(("This table isn't right. Must be corruption, or I got it wrong!\n")); |
1057 if (buf) free(buf); | 1058 if (buf) free(buf); |
1058 DEBUG_RET(); | 1059 DEBUG_RET(); |
1087 uint64_t old = start_val; | 1088 uint64_t old = start_val; |
1088 int x; | 1089 int x; |
1089 char *buf = NULL, *bptr; | 1090 char *buf = NULL, *bptr; |
1090 | 1091 |
1091 DEBUG_ENT("pst_build_desc_ptr"); | 1092 DEBUG_ENT("pst_build_desc_ptr"); |
1092 DEBUG_INDEX(("offset %#"PRIx64" depth %i linku1 %#"PRIx64" start %#"PRIx64" end %#"PRIx64"\n", offset, depth, linku1, start_val, end_val)); | 1093 DEBUG_INFO(("offset %#"PRIx64" depth %i linku1 %#"PRIx64" start %#"PRIx64" end %#"PRIx64"\n", offset, depth, linku1, start_val, end_val)); |
1093 if (end_val <= start_val) { | 1094 if (end_val <= start_val) { |
1094 DEBUG_WARN(("The end value is BEFORE the start value. This function will quit. Soz. [start:%#"PRIx64", end:%#"PRIx64"]\n", start_val, end_val)); | 1095 DEBUG_WARN(("The end value is BEFORE the start value. This function will quit. Soz. [start:%#"PRIx64", end:%#"PRIx64"]\n", start_val, end_val)); |
1095 DEBUG_RET(); | 1096 DEBUG_RET(); |
1096 return -1; | 1097 return -1; |
1097 } | 1098 } |
1098 DEBUG_INDEX(("Reading desc block\n")); | 1099 DEBUG_INFO(("Reading desc block\n")); |
1099 if (pst_read_block_size(pf, offset, DESC_BLOCK_SIZE, &buf) < DESC_BLOCK_SIZE) { | 1100 if (pst_read_block_size(pf, offset, DESC_BLOCK_SIZE, &buf) < DESC_BLOCK_SIZE) { |
1100 DEBUG_WARN(("Failed to read %i bytes\n", DESC_BLOCK_SIZE)); | 1101 DEBUG_WARN(("Failed to read %i bytes\n", DESC_BLOCK_SIZE)); |
1101 if (buf) free(buf); | 1102 if (buf) free(buf); |
1102 DEBUG_RET(); | 1103 DEBUG_RET(); |
1103 return -1; | 1104 return -1; |
1121 DEBUG_RET(); | 1122 DEBUG_RET(); |
1122 return -1; | 1123 return -1; |
1123 } | 1124 } |
1124 for (x=0; x<item_count; x++) { | 1125 for (x=0; x<item_count; x++) { |
1125 bptr += pst_decode_desc(pf, &desc_rec, bptr); | 1126 bptr += pst_decode_desc(pf, &desc_rec, bptr); |
1126 DEBUG_INDEX(("[%i] Item(%#x) = [d_id = %#"PRIx64", desc_id = %#"PRIx64", tree_id = %#"PRIx64", parent_d_id = %#x]\n", | 1127 DEBUG_INFO(("[%i] Item(%#x) = [d_id = %#"PRIx64", desc_id = %#"PRIx64", tree_id = %#"PRIx64", parent_d_id = %#x]\n", |
1127 depth, x, desc_rec.d_id, desc_rec.desc_id, desc_rec.tree_id, desc_rec.parent_d_id)); | 1128 depth, x, desc_rec.d_id, desc_rec.desc_id, desc_rec.tree_id, desc_rec.parent_d_id)); |
1128 if ((desc_rec.d_id >= end_val) || (desc_rec.d_id < old)) { | 1129 if ((desc_rec.d_id >= end_val) || (desc_rec.d_id < old)) { |
1129 DEBUG_WARN(("This item isn't right. Must be corruption, or I got it wrong!\n")); | 1130 DEBUG_WARN(("This item isn't right. Must be corruption, or I got it wrong!\n")); |
1130 DEBUG_HEXDUMPC(buf, DESC_BLOCK_SIZE, 16); | 1131 DEBUG_HEXDUMPC(buf, DESC_BLOCK_SIZE, 16); |
1131 if (buf) free(buf); | 1132 if (buf) free(buf); |
1139 if (buf) free(buf); | 1140 if (buf) free(buf); |
1140 DEBUG_RET(); | 1141 DEBUG_RET(); |
1141 return -1; | 1142 return -1; |
1142 } | 1143 } |
1143 } | 1144 } |
1144 DEBUG_INDEX(("New Record %#"PRIx64" with parent %#x\n", desc_rec.d_id, desc_rec.parent_d_id)); | 1145 DEBUG_INFO(("New Record %#"PRIx64" with parent %#x\n", desc_rec.d_id, desc_rec.parent_d_id)); |
1145 { | 1146 { |
1146 pst_desc_tree *d_ptr = (pst_desc_tree*) pst_malloc(sizeof(pst_desc_tree)); | 1147 pst_desc_tree *d_ptr = (pst_desc_tree*) pst_malloc(sizeof(pst_desc_tree)); |
1147 d_ptr->d_id = desc_rec.d_id; | 1148 d_ptr->d_id = desc_rec.d_id; |
1148 d_ptr->parent_d_id = desc_rec.parent_d_id; | 1149 d_ptr->parent_d_id = desc_rec.parent_d_id; |
1149 d_ptr->assoc_tree = pst_getID(pf, desc_rec.tree_id); | 1150 d_ptr->assoc_tree = pst_getID(pf, desc_rec.tree_id); |
1167 (void)pst_decode_table(pf, &table2, bptr); | 1168 (void)pst_decode_table(pf, &table2, bptr); |
1168 } | 1169 } |
1169 else { | 1170 else { |
1170 table2.start = end_val; | 1171 table2.start = end_val; |
1171 } | 1172 } |
1172 DEBUG_INDEX(("[%i] %i Descriptor Table [start id = %#"PRIx64", u1 = %#"PRIx64", offset = %#"PRIx64", end id = %#"PRIx64"]\n", | 1173 DEBUG_INFO(("[%i] %i Descriptor Table [start id = %#"PRIx64", u1 = %#"PRIx64", offset = %#"PRIx64", end id = %#"PRIx64"]\n", |
1173 depth, x, table.start, table.u1, table.offset, table2.start)); | 1174 depth, x, table.start, table.u1, table.offset, table2.start)); |
1174 if ((table.start >= end_val) || (table.start < old)) { | 1175 if ((table.start >= end_val) || (table.start < old)) { |
1175 DEBUG_WARN(("This table isn't right. Must be corruption, or I got it wrong!\n")); | 1176 DEBUG_WARN(("This table isn't right. Must be corruption, or I got it wrong!\n")); |
1176 if (buf) free(buf); | 1177 if (buf) free(buf); |
1177 DEBUG_RET(); | 1178 DEBUG_RET(); |
1247 } | 1248 } |
1248 pst_free_list(list); | 1249 pst_free_list(list); |
1249 | 1250 |
1250 if ((id2_ptr = pst_getID2(id2_head, (uint64_t)0x692))) { | 1251 if ((id2_ptr = pst_getID2(id2_head, (uint64_t)0x692))) { |
1251 // DSN/MDN reports? | 1252 // DSN/MDN reports? |
1252 DEBUG_EMAIL(("DSN/MDN processing\n")); | 1253 DEBUG_INFO(("DSN/MDN processing\n")); |
1253 list = pst_parse_block(pf, id2_ptr->id->i_id, id2_head); | 1254 list = pst_parse_block(pf, id2_ptr->id->i_id, id2_head); |
1254 if (!list) { | 1255 if (!list) { |
1255 DEBUG_WARN(("ERROR error processing main DSN/MDN record\n")); | 1256 DEBUG_WARN(("ERROR error processing main DSN/MDN record\n")); |
1256 if (!m_head) pst_free_id2(id2_head); | 1257 if (!m_head) pst_free_id2(id2_head); |
1257 DEBUG_RET(); | 1258 DEBUG_RET(); |
1273 } | 1274 } |
1274 pst_free_list(list); | 1275 pst_free_list(list); |
1275 } | 1276 } |
1276 | 1277 |
1277 if ((id2_ptr = pst_getID2(id2_head, (uint64_t)0x671))) { | 1278 if ((id2_ptr = pst_getID2(id2_head, (uint64_t)0x671))) { |
1278 DEBUG_EMAIL(("ATTACHMENT processing attachment\n")); | 1279 DEBUG_INFO(("ATTACHMENT processing attachment\n")); |
1279 list = pst_parse_block(pf, id2_ptr->id->i_id, id2_head); | 1280 list = pst_parse_block(pf, id2_ptr->id->i_id, id2_head); |
1280 if (!list) { | 1281 if (!list) { |
1281 DEBUG_WARN(("ERROR error processing main attachment record\n")); | 1282 DEBUG_WARN(("ERROR error processing main attachment record\n")); |
1282 if (!m_head) pst_free_id2(id2_head); | 1283 if (!m_head) pst_free_id2(id2_head); |
1283 DEBUG_RET(); | 1284 DEBUG_RET(); |
1459 | 1460 |
1460 memcpy(&block_hdr, buf, sizeof(block_hdr)); | 1461 memcpy(&block_hdr, buf, sizeof(block_hdr)); |
1461 LE16_CPU(block_hdr.index_offset); | 1462 LE16_CPU(block_hdr.index_offset); |
1462 LE16_CPU(block_hdr.type); | 1463 LE16_CPU(block_hdr.type); |
1463 LE32_CPU(block_hdr.offset); | 1464 LE32_CPU(block_hdr.offset); |
1464 DEBUG_EMAIL(("block header (index_offset=%#hx, type=%#hx, offset=%#hx)\n", block_hdr.index_offset, block_hdr.type, block_hdr.offset)); | 1465 DEBUG_INFO(("block header (index_offset=%#hx, type=%#hx, offset=%#hx)\n", block_hdr.index_offset, block_hdr.type, block_hdr.offset)); |
1465 | 1466 |
1466 if (block_hdr.index_offset == (uint16_t)0x0101) { //type 3 | 1467 if (block_hdr.index_offset == (uint16_t)0x0101) { //type 3 |
1467 size_t i; | 1468 size_t i; |
1468 char *b_ptr = buf + 8; | 1469 char *b_ptr = buf + 8; |
1469 subblocks.subblock_count = block_hdr.type; | 1470 subblocks.subblock_count = block_hdr.type; |
1485 free(buf); | 1486 free(buf); |
1486 memcpy(&block_hdr, subblocks.subs[0].buf, sizeof(block_hdr)); | 1487 memcpy(&block_hdr, subblocks.subs[0].buf, sizeof(block_hdr)); |
1487 LE16_CPU(block_hdr.index_offset); | 1488 LE16_CPU(block_hdr.index_offset); |
1488 LE16_CPU(block_hdr.type); | 1489 LE16_CPU(block_hdr.type); |
1489 LE32_CPU(block_hdr.offset); | 1490 LE32_CPU(block_hdr.offset); |
1490 DEBUG_EMAIL(("block header (index_offset=%#hx, type=%#hx, offset=%#hx)\n", block_hdr.index_offset, block_hdr.type, block_hdr.offset)); | 1491 DEBUG_INFO(("block header (index_offset=%#hx, type=%#hx, offset=%#hx)\n", block_hdr.index_offset, block_hdr.type, block_hdr.offset)); |
1491 } | 1492 } |
1492 else { | 1493 else { |
1493 // setup the subblock descriptors, but we only have one block | 1494 // setup the subblock descriptors, but we only have one block |
1494 subblocks.subblock_count = (size_t)1; | 1495 subblocks.subblock_count = (size_t)1; |
1495 subblocks.subs = malloc(sizeof(pst_subblock)); | 1496 subblocks.subs = malloc(sizeof(pst_subblock)); |
1509 } | 1510 } |
1510 memcpy(&table_rec, block_offset1.from, sizeof(table_rec)); | 1511 memcpy(&table_rec, block_offset1.from, sizeof(table_rec)); |
1511 LE16_CPU(table_rec.type); | 1512 LE16_CPU(table_rec.type); |
1512 LE16_CPU(table_rec.ref_type); | 1513 LE16_CPU(table_rec.ref_type); |
1513 LE32_CPU(table_rec.value); | 1514 LE32_CPU(table_rec.value); |
1514 DEBUG_EMAIL(("table_rec (type=%#hx, ref_type=%#hx, value=%#x)\n", table_rec.type, table_rec.ref_type, table_rec.value)); | 1515 DEBUG_INFO(("table_rec (type=%#hx, ref_type=%#hx, value=%#x)\n", table_rec.type, table_rec.ref_type, table_rec.value)); |
1515 | 1516 |
1516 if ((table_rec.type != (uint16_t)0x02B5) || (table_rec.ref_type != 6)) { | 1517 if ((table_rec.type != (uint16_t)0x02B5) || (table_rec.ref_type != 6)) { |
1517 DEBUG_WARN(("Unknown second block constant - %#hx %#hx for id %#"PRIx64"\n", table_rec.type, table_rec.ref_type, block_id)); | 1518 DEBUG_WARN(("Unknown second block constant - %#hx %#hx for id %#"PRIx64"\n", table_rec.type, table_rec.ref_type, block_id)); |
1518 freeall(&subblocks, &block_offset1, &block_offset2, &block_offset3, &block_offset4, &block_offset5, &block_offset6, &block_offset7); | 1519 freeall(&subblocks, &block_offset1, &block_offset2, &block_offset3, &block_offset4, &block_offset5, &block_offset6, &block_offset7); |
1519 DEBUG_RET(); | 1520 DEBUG_RET(); |
1572 } | 1573 } |
1573 memcpy(&table_rec, block_offset4.from, sizeof(table_rec)); | 1574 memcpy(&table_rec, block_offset4.from, sizeof(table_rec)); |
1574 LE16_CPU(table_rec.type); | 1575 LE16_CPU(table_rec.type); |
1575 LE16_CPU(table_rec.ref_type); | 1576 LE16_CPU(table_rec.ref_type); |
1576 LE32_CPU(table_rec.value); | 1577 LE32_CPU(table_rec.value); |
1577 DEBUG_EMAIL(("table_rec (type=%#hx, ref_type=%#hx, value=%#x)\n", table_rec.type, table_rec.ref_type, table_rec.value)); | 1578 DEBUG_INFO(("table_rec (type=%#hx, ref_type=%#hx, value=%#x)\n", table_rec.type, table_rec.ref_type, table_rec.value)); |
1578 | 1579 |
1579 if (table_rec.type != (uint16_t)0x04B5) { // different constant than a type 1 record | 1580 if (table_rec.type != (uint16_t)0x04B5) { // different constant than a type 1 record |
1580 DEBUG_WARN(("Unknown second block constant - %#hx for id %#"PRIx64"\n", table_rec.type, block_id)); | 1581 DEBUG_WARN(("Unknown second block constant - %#hx for id %#"PRIx64"\n", table_rec.type, block_id)); |
1581 freeall(&subblocks, &block_offset1, &block_offset2, &block_offset3, &block_offset4, &block_offset5, &block_offset6, &block_offset7); | 1582 freeall(&subblocks, &block_offset1, &block_offset2, &block_offset3, &block_offset4, &block_offset5, &block_offset6, &block_offset7); |
1582 DEBUG_RET(); | 1583 DEBUG_RET(); |
1607 freeall(&subblocks, &block_offset1, &block_offset2, &block_offset3, &block_offset4, &block_offset5, &block_offset6, &block_offset7); | 1608 freeall(&subblocks, &block_offset1, &block_offset2, &block_offset3, &block_offset4, &block_offset5, &block_offset6, &block_offset7); |
1608 DEBUG_RET(); | 1609 DEBUG_RET(); |
1609 return NULL; | 1610 return NULL; |
1610 } | 1611 } |
1611 | 1612 |
1612 DEBUG_EMAIL(("Mallocing number of records %i\n", num_recs)); | 1613 DEBUG_INFO(("Mallocing number of records %i\n", num_recs)); |
1613 for (count_rec=0; count_rec<num_recs; count_rec++) { | 1614 for (count_rec=0; count_rec<num_recs; count_rec++) { |
1614 mo_ptr = (pst_mapi_object*) pst_malloc(sizeof(pst_mapi_object)); | 1615 mo_ptr = (pst_mapi_object*) pst_malloc(sizeof(pst_mapi_object)); |
1615 memset(mo_ptr, 0, sizeof(pst_mapi_object)); | 1616 memset(mo_ptr, 0, sizeof(pst_mapi_object)); |
1616 mo_ptr->next = mo_head; | 1617 mo_ptr->next = mo_head; |
1617 mo_head = mo_ptr; | 1618 mo_head = mo_ptr; |
1621 mo_ptr->orig_count = num_list; | 1622 mo_ptr->orig_count = num_list; |
1622 mo_ptr->count_objects = (int32_t)num_recs; // each record will have a record of the total number of records | 1623 mo_ptr->count_objects = (int32_t)num_recs; // each record will have a record of the total number of records |
1623 for (x=0; x<num_list; x++) mo_ptr->elements[x] = NULL; | 1624 for (x=0; x<num_list; x++) mo_ptr->elements[x] = NULL; |
1624 x = 0; | 1625 x = 0; |
1625 | 1626 |
1626 DEBUG_EMAIL(("going to read %i (%#x) items\n", mo_ptr->count_elements, mo_ptr->count_elements)); | 1627 DEBUG_INFO(("going to read %i (%#x) items\n", mo_ptr->count_elements, mo_ptr->count_elements)); |
1627 | 1628 |
1628 fr_ptr = list_start; // initialize fr_ptr to the start of the list. | 1629 fr_ptr = list_start; // initialize fr_ptr to the start of the list. |
1629 for (cur_list=0; cur_list<num_list; cur_list++) { //we will increase fr_ptr as we progress through index | 1630 for (cur_list=0; cur_list<num_list; cur_list++) { //we will increase fr_ptr as we progress through index |
1630 char* value_pointer = NULL; // needed for block type 2 with values larger than 4 bytes | 1631 char* value_pointer = NULL; // needed for block type 2 with values larger than 4 bytes |
1631 size_t value_size = 0; | 1632 size_t value_size = 0; |
1668 freeall(&subblocks, &block_offset1, &block_offset2, &block_offset3, &block_offset4, &block_offset5, &block_offset6, &block_offset7); | 1669 freeall(&subblocks, &block_offset1, &block_offset2, &block_offset3, &block_offset4, &block_offset5, &block_offset6, &block_offset7); |
1669 pst_free_list(mo_head); | 1670 pst_free_list(mo_head); |
1670 DEBUG_RET(); | 1671 DEBUG_RET(); |
1671 return NULL; | 1672 return NULL; |
1672 } | 1673 } |
1673 DEBUG_EMAIL(("reading block %i (type=%#x, ref_type=%#x, value=%#x)\n", | 1674 DEBUG_INFO(("reading block %i (type=%#x, ref_type=%#x, value=%#x)\n", |
1674 x, table_rec.type, table_rec.ref_type, table_rec.value)); | 1675 x, table_rec.type, table_rec.ref_type, table_rec.value)); |
1675 | 1676 |
1676 if (!mo_ptr->elements[x]) { | 1677 if (!mo_ptr->elements[x]) { |
1677 mo_ptr->elements[x] = (pst_mapi_element*) pst_malloc(sizeof(pst_mapi_element)); | 1678 mo_ptr->elements[x] = (pst_mapi_element*) pst_malloc(sizeof(pst_mapi_element)); |
1678 } | 1679 } |
1682 mapptr = pf->x_head; | 1683 mapptr = pf->x_head; |
1683 while (mapptr && (mapptr->map < table_rec.type)) mapptr = mapptr->next; | 1684 while (mapptr && (mapptr->map < table_rec.type)) mapptr = mapptr->next; |
1684 if (mapptr && (mapptr->map == table_rec.type)) { | 1685 if (mapptr && (mapptr->map == table_rec.type)) { |
1685 if (mapptr->mytype == PST_MAP_ATTRIB) { | 1686 if (mapptr->mytype == PST_MAP_ATTRIB) { |
1686 mo_ptr->elements[x]->mapi_id = *((uint32_t*)mapptr->data); | 1687 mo_ptr->elements[x]->mapi_id = *((uint32_t*)mapptr->data); |
1687 DEBUG_EMAIL(("Mapped attrib %#x to %#x\n", table_rec.type, mo_ptr->elements[x]->mapi_id)); | 1688 DEBUG_INFO(("Mapped attrib %#x to %#x\n", table_rec.type, mo_ptr->elements[x]->mapi_id)); |
1688 } else if (mapptr->mytype == PST_MAP_HEADER) { | 1689 } else if (mapptr->mytype == PST_MAP_HEADER) { |
1689 DEBUG_EMAIL(("Internet Header mapping found %#"PRIx32" to %s\n", table_rec.type, mapptr->data)); | 1690 DEBUG_INFO(("Internet Header mapping found %#"PRIx32" to %s\n", table_rec.type, mapptr->data)); |
1690 mo_ptr->elements[x]->mapi_id = (uint32_t)PST_ATTRIB_HEADER; | 1691 mo_ptr->elements[x]->mapi_id = (uint32_t)PST_ATTRIB_HEADER; |
1691 mo_ptr->elements[x]->extra = mapptr->data; | 1692 mo_ptr->elements[x]->extra = mapptr->data; |
1692 } | 1693 } |
1693 else { | 1694 else { |
1694 DEBUG_WARN(("Missing assertion failure\n")); | 1695 DEBUG_WARN(("Missing assertion failure\n")); |
1798 if (!utf8buf) utf8buf = pst_vballoc((size_t)1024); | 1799 if (!utf8buf) utf8buf = pst_vballoc((size_t)1024); |
1799 | 1800 |
1800 //need UTF-16 zero-termination | 1801 //need UTF-16 zero-termination |
1801 pst_vbset(utf16buf, mo_ptr->elements[x]->data, mo_ptr->elements[x]->size); | 1802 pst_vbset(utf16buf, mo_ptr->elements[x]->data, mo_ptr->elements[x]->size); |
1802 pst_vbappend(utf16buf, "\0\0", (size_t)2); | 1803 pst_vbappend(utf16buf, "\0\0", (size_t)2); |
1803 DEBUG_INDEX(("Iconv in:\n")); | 1804 DEBUG_INFO(("Iconv in:\n")); |
1804 DEBUG_HEXDUMPC(utf16buf->b, utf16buf->dlen, 0x10); | 1805 DEBUG_HEXDUMPC(utf16buf->b, utf16buf->dlen, 0x10); |
1805 rc = pst_vb_utf16to8(utf8buf, utf16buf->b, utf16buf->dlen); | 1806 rc = pst_vb_utf16to8(utf8buf, utf16buf->b, utf16buf->dlen); |
1806 if (rc == (size_t)-1) { | 1807 if (rc == (size_t)-1) { |
1807 DEBUG_WARN(("Failed to convert utf-16 to utf-8\n")); | 1808 DEBUG_WARN(("Failed to convert utf-16 to utf-8\n")); |
1808 } | 1809 } |
1810 free(mo_ptr->elements[x]->data); | 1811 free(mo_ptr->elements[x]->data); |
1811 mo_ptr->elements[x]->size = utf8buf->dlen; | 1812 mo_ptr->elements[x]->size = utf8buf->dlen; |
1812 mo_ptr->elements[x]->data = pst_malloc(utf8buf->dlen); | 1813 mo_ptr->elements[x]->data = pst_malloc(utf8buf->dlen); |
1813 memcpy(mo_ptr->elements[x]->data, utf8buf->b, utf8buf->dlen); | 1814 memcpy(mo_ptr->elements[x]->data, utf8buf->b, utf8buf->dlen); |
1814 } | 1815 } |
1815 DEBUG_INDEX(("Iconv out:\n")); | 1816 DEBUG_INFO(("Iconv out:\n")); |
1816 DEBUG_HEXDUMPC(mo_ptr->elements[x]->data, mo_ptr->elements[x]->size, 0x10); | 1817 DEBUG_HEXDUMPC(mo_ptr->elements[x]->data, mo_ptr->elements[x]->size, 0x10); |
1817 } | 1818 } |
1818 if (mo_ptr->elements[x]->type == 0) mo_ptr->elements[x]->type = table_rec.ref_type; | 1819 if (mo_ptr->elements[x]->type == 0) mo_ptr->elements[x]->type = table_rec.ref_type; |
1819 } else { | 1820 } else { |
1820 DEBUG_WARN(("ERROR Unknown ref_type %#hx\n", table_rec.ref_type)); | 1821 DEBUG_WARN(("ERROR Unknown ref_type %#hx\n", table_rec.ref_type)); |
1823 DEBUG_RET(); | 1824 DEBUG_RET(); |
1824 return NULL; | 1825 return NULL; |
1825 } | 1826 } |
1826 x++; | 1827 x++; |
1827 } | 1828 } |
1828 DEBUG_EMAIL(("increasing ind2_ptr by %i [%#x] bytes. Was %#x, Now %#x\n", rec_size, rec_size, ind2_ptr, ind2_ptr+rec_size)); | 1829 DEBUG_INFO(("increasing ind2_ptr by %i [%#x] bytes. Was %#x, Now %#x\n", rec_size, rec_size, ind2_ptr, ind2_ptr+rec_size)); |
1829 ind2_ptr += rec_size; | 1830 ind2_ptr += rec_size; |
1830 } | 1831 } |
1831 freeall(&subblocks, &block_offset1, &block_offset2, &block_offset3, &block_offset4, &block_offset5, &block_offset6, &block_offset7); | 1832 freeall(&subblocks, &block_offset1, &block_offset2, &block_offset3, &block_offset4, &block_offset5, &block_offset6, &block_offset7); |
1832 DEBUG_RET(); | 1833 DEBUG_RET(); |
1833 return mo_head; | 1834 return mo_head; |
1872 if (list->elements[x]->type != 0x0b) { \ | 1873 if (list->elements[x]->type != 0x0b) { \ |
1873 DEBUG_WARN(("src not 0x0b for boolean dst\n")); \ | 1874 DEBUG_WARN(("src not 0x0b for boolean dst\n")); \ |
1874 DEBUG_HEXDUMP(list->elements[x]->data, list->elements[x]->size); \ | 1875 DEBUG_HEXDUMP(list->elements[x]->data, list->elements[x]->size); \ |
1875 } \ | 1876 } \ |
1876 if (*(int16_t*)list->elements[x]->data) { \ | 1877 if (*(int16_t*)list->elements[x]->data) { \ |
1877 DEBUG_EMAIL((label" - True\n")); \ | 1878 DEBUG_INFO((label" - True\n")); \ |
1878 targ = 1; \ | 1879 targ = 1; \ |
1879 } else { \ | 1880 } else { \ |
1880 DEBUG_EMAIL((label" - False\n")); \ | 1881 DEBUG_INFO((label" - False\n")); \ |
1881 targ = 0; \ | 1882 targ = 0; \ |
1882 } \ | 1883 } \ |
1883 } | 1884 } |
1884 | 1885 |
1885 #define LIST_COPY_EMAIL_BOOL(label, targ) { \ | 1886 #define LIST_COPY_EMAIL_BOOL(label, targ) { \ |
1906 LE16_CPU(targ); \ | 1907 LE16_CPU(targ); \ |
1907 } | 1908 } |
1908 | 1909 |
1909 #define LIST_COPY_INT16(label, targ) { \ | 1910 #define LIST_COPY_INT16(label, targ) { \ |
1910 LIST_COPY_INT16_N(targ); \ | 1911 LIST_COPY_INT16_N(targ); \ |
1911 DEBUG_EMAIL((label" - %i %#x\n", (int)targ, (int)targ)); \ | 1912 DEBUG_INFO((label" - %i %#x\n", (int)targ, (int)targ)); \ |
1912 } | 1913 } |
1913 | 1914 |
1914 #define LIST_COPY_INT32_N(targ) { \ | 1915 #define LIST_COPY_INT32_N(targ) { \ |
1915 if (list->elements[x]->type != 0x03) { \ | 1916 if (list->elements[x]->type != 0x03) { \ |
1916 DEBUG_WARN(("src not 0x03 for int32 dst\n")); \ | 1917 DEBUG_WARN(("src not 0x03 for int32 dst\n")); \ |
1920 LE32_CPU(targ); \ | 1921 LE32_CPU(targ); \ |
1921 } | 1922 } |
1922 | 1923 |
1923 #define LIST_COPY_INT32(label, targ) { \ | 1924 #define LIST_COPY_INT32(label, targ) { \ |
1924 LIST_COPY_INT32_N(targ); \ | 1925 LIST_COPY_INT32_N(targ); \ |
1925 DEBUG_EMAIL((label" - %i %#x\n", (int)targ, (int)targ)); \ | 1926 DEBUG_INFO((label" - %i %#x\n", (int)targ, (int)targ)); \ |
1926 } | 1927 } |
1927 | 1928 |
1928 #define LIST_COPY_EMAIL_INT32(label, targ) { \ | 1929 #define LIST_COPY_EMAIL_INT32(label, targ) { \ |
1929 MALLOC_EMAIL(item); \ | 1930 MALLOC_EMAIL(item); \ |
1930 LIST_COPY_INT32(label, targ); \ | 1931 LIST_COPY_INT32(label, targ); \ |
1947 | 1948 |
1948 #define LIST_COPY_ENUM(label, targ, delta, count, ...) { \ | 1949 #define LIST_COPY_ENUM(label, targ, delta, count, ...) { \ |
1949 char *tlabels[] = {__VA_ARGS__}; \ | 1950 char *tlabels[] = {__VA_ARGS__}; \ |
1950 LIST_COPY_INT32_N(targ); \ | 1951 LIST_COPY_INT32_N(targ); \ |
1951 targ += delta; \ | 1952 targ += delta; \ |
1952 DEBUG_EMAIL((label" - %s [%i]\n", \ | 1953 DEBUG_INFO((label" - %s [%i]\n", \ |
1953 (((int)targ < 0) || ((int)targ >= count)) \ | 1954 (((int)targ < 0) || ((int)targ >= count)) \ |
1954 ? "**invalid" \ | 1955 ? "**invalid" \ |
1955 : tlabels[(int)targ], (int)targ)); \ | 1956 : tlabels[(int)targ], (int)targ)); \ |
1956 } | 1957 } |
1957 | 1958 |
1967 | 1968 |
1968 #define LIST_COPY_ENUM16(label, targ, delta, count, ...) { \ | 1969 #define LIST_COPY_ENUM16(label, targ, delta, count, ...) { \ |
1969 char *tlabels[] = {__VA_ARGS__}; \ | 1970 char *tlabels[] = {__VA_ARGS__}; \ |
1970 LIST_COPY_INT16_N(targ); \ | 1971 LIST_COPY_INT16_N(targ); \ |
1971 targ += delta; \ | 1972 targ += delta; \ |
1972 DEBUG_EMAIL((label" - %s [%i]\n", \ | 1973 DEBUG_INFO((label" - %s [%i]\n", \ |
1973 (((int)targ < 0) || ((int)targ >= count)) \ | 1974 (((int)targ < 0) || ((int)targ >= count)) \ |
1974 ? "**invalid" \ | 1975 ? "**invalid" \ |
1975 : tlabels[(int)targ], (int)targ)); \ | 1976 : tlabels[(int)targ], (int)targ)); \ |
1976 } | 1977 } |
1977 | 1978 |
1982 | 1983 |
1983 #define LIST_COPY_ENTRYID(label, targ) { \ | 1984 #define LIST_COPY_ENTRYID(label, targ) { \ |
1984 LIST_COPY(targ, (pst_entryid*)); \ | 1985 LIST_COPY(targ, (pst_entryid*)); \ |
1985 LE32_CPU(targ->u1); \ | 1986 LE32_CPU(targ->u1); \ |
1986 LE32_CPU(targ->id); \ | 1987 LE32_CPU(targ->id); \ |
1987 DEBUG_EMAIL((label" u1=%#x, id=%#x\n", targ->u1, targ->id));\ | 1988 DEBUG_INFO((label" u1=%#x, id=%#x\n", targ->u1, targ->id));\ |
1988 } | 1989 } |
1989 | 1990 |
1990 #define LIST_COPY_EMAIL_ENTRYID(label, targ) { \ | 1991 #define LIST_COPY_EMAIL_ENTRYID(label, targ) { \ |
1991 MALLOC_EMAIL(item); \ | 1992 MALLOC_EMAIL(item); \ |
1992 LIST_COPY_ENTRYID(label, targ); \ | 1993 LIST_COPY_ENTRYID(label, targ); \ |
2001 // malloc space and copy the current item's data null terminated | 2002 // malloc space and copy the current item's data null terminated |
2002 // including the utf8 flag | 2003 // including the utf8 flag |
2003 #define LIST_COPY_STR(label, targ) { \ | 2004 #define LIST_COPY_STR(label, targ) { \ |
2004 LIST_COPY_CSTR(targ.str); \ | 2005 LIST_COPY_CSTR(targ.str); \ |
2005 targ.is_utf8 = (list->elements[x]->type == 0x1f) ? 1 : 0; \ | 2006 targ.is_utf8 = (list->elements[x]->type == 0x1f) ? 1 : 0; \ |
2006 DEBUG_EMAIL((label" - unicode %d - %s\n", targ.is_utf8, targ.str)); \ | 2007 DEBUG_INFO((label" - unicode %d - %s\n", targ.is_utf8, targ.str)); \ |
2007 } | 2008 } |
2008 | 2009 |
2009 #define LIST_COPY_EMAIL_STR(label, targ) { \ | 2010 #define LIST_COPY_EMAIL_STR(label, targ) { \ |
2010 MALLOC_EMAIL(item); \ | 2011 MALLOC_EMAIL(item); \ |
2011 LIST_COPY_STR(label, targ); \ | 2012 LIST_COPY_STR(label, targ); \ |
2034 } \ | 2035 } \ |
2035 targ = (FILETIME*) realloc(targ, sizeof(FILETIME)); \ | 2036 targ = (FILETIME*) realloc(targ, sizeof(FILETIME)); \ |
2036 memcpy(targ, list->elements[x]->data, list->elements[x]->size); \ | 2037 memcpy(targ, list->elements[x]->data, list->elements[x]->size); \ |
2037 LE32_CPU(targ->dwLowDateTime); \ | 2038 LE32_CPU(targ->dwLowDateTime); \ |
2038 LE32_CPU(targ->dwHighDateTime); \ | 2039 LE32_CPU(targ->dwHighDateTime); \ |
2039 DEBUG_EMAIL((label" - %s", pst_fileTimeToAscii(targ, time_buffer))); \ | 2040 DEBUG_INFO((label" - %s", pst_fileTimeToAscii(targ, time_buffer))); \ |
2040 } | 2041 } |
2041 | 2042 |
2042 #define LIST_COPY_EMAIL_TIME(label, targ) { \ | 2043 #define LIST_COPY_EMAIL_TIME(label, targ) { \ |
2043 MALLOC_EMAIL(item); \ | 2044 MALLOC_EMAIL(item); \ |
2044 LIST_COPY_TIME(label, targ); \ | 2045 LIST_COPY_TIME(label, targ); \ |
2073 } | 2074 } |
2074 | 2075 |
2075 #define LIST_COPY_EMAIL_BIN(label, targ) { \ | 2076 #define LIST_COPY_EMAIL_BIN(label, targ) { \ |
2076 MALLOC_EMAIL(item); \ | 2077 MALLOC_EMAIL(item); \ |
2077 LIST_COPY_BIN(targ); \ | 2078 LIST_COPY_BIN(targ); \ |
2078 DEBUG_EMAIL((label"\n")); \ | 2079 DEBUG_INFO((label"\n")); \ |
2079 } | 2080 } |
2080 #define LIST_COPY_APPT_BIN(label, targ) { \ | 2081 #define LIST_COPY_APPT_BIN(label, targ) { \ |
2081 MALLOC_APPOINTMENT(item); \ | 2082 MALLOC_APPOINTMENT(item); \ |
2082 LIST_COPY_BIN(targ); \ | 2083 LIST_COPY_BIN(targ); \ |
2083 DEBUG_EMAIL((label"\n")); \ | 2084 DEBUG_INFO((label"\n")); \ |
2084 DEBUG_EMAIL_HEXPRINT(targ.data, targ.size); \ | 2085 DEBUG_HEXDUMP(targ.data, targ.size); \ |
2085 } | 2086 } |
2086 | 2087 |
2087 #define NULL_CHECK(x) { if (!x) { DEBUG_WARN(("NULL_CHECK: Null Found\n")); break;} } | 2088 #define NULL_CHECK(x) { if (!x) { DEBUG_WARN(("NULL_CHECK: Null Found\n")); break;} } |
2088 | 2089 |
2089 | 2090 |
2102 * @return 0 for ok, -1 for error. | 2103 * @return 0 for ok, -1 for error. |
2103 */ | 2104 */ |
2104 static int pst_process(pst_mapi_object *list, pst_item *item, pst_item_attach *attach) { | 2105 static int pst_process(pst_mapi_object *list, pst_item *item, pst_item_attach *attach) { |
2105 DEBUG_ENT("pst_process"); | 2106 DEBUG_ENT("pst_process"); |
2106 if (!item) { | 2107 if (!item) { |
2107 DEBUG_EMAIL(("item cannot be NULL.\n")); | 2108 DEBUG_WARN(("item cannot be NULL.\n")); |
2108 DEBUG_RET(); | 2109 DEBUG_RET(); |
2109 return -1; | 2110 return -1; |
2110 } | 2111 } |
2111 | 2112 |
2112 while (list) { | 2113 while (list) { |
2113 int32_t x; | 2114 int32_t x; |
2114 char time_buffer[30]; | 2115 char time_buffer[30]; |
2115 for (x=0; x<list->count_elements; x++) { | 2116 for (x=0; x<list->count_elements; x++) { |
2116 int32_t t; | 2117 int32_t t; |
2117 DEBUG_EMAIL(("#%d - mapi-id: %#x type: %#x length: %#x\n", x, list->elements[x]->mapi_id, list->elements[x]->type, list->elements[x]->size)); | 2118 DEBUG_INFO(("#%d - mapi-id: %#x type: %#x length: %#x\n", x, list->elements[x]->mapi_id, list->elements[x]->type, list->elements[x]->size)); |
2118 | 2119 |
2119 switch (list->elements[x]->mapi_id) { | 2120 switch (list->elements[x]->mapi_id) { |
2120 case PST_ATTRIB_HEADER: // CUSTOM attribute for saying the Extra Headers | 2121 case PST_ATTRIB_HEADER: // CUSTOM attribute for saying the Extra Headers |
2121 if (list->elements[x]->extra) { | 2122 if (list->elements[x]->extra) { |
2122 pst_item_extra_field *ef = (pst_item_extra_field*) pst_malloc(sizeof(pst_item_extra_field)); | 2123 pst_item_extra_field *ef = (pst_item_extra_field*) pst_malloc(sizeof(pst_item_extra_field)); |
2124 LIST_COPY_CSTR(ef->value); | 2125 LIST_COPY_CSTR(ef->value); |
2125 if (ef->value) { | 2126 if (ef->value) { |
2126 ef->field_name = strdup(list->elements[x]->extra); | 2127 ef->field_name = strdup(list->elements[x]->extra); |
2127 ef->next = item->extra_fields; | 2128 ef->next = item->extra_fields; |
2128 item->extra_fields = ef; | 2129 item->extra_fields = ef; |
2129 DEBUG_EMAIL(("Extra Field - \"%s\" = \"%s\"\n", ef->field_name, ef->value)); | 2130 DEBUG_INFO(("Extra Field - \"%s\" = \"%s\"\n", ef->field_name, ef->value)); |
2130 if (strcmp(ef->field_name, "content-type") == 0) { | 2131 if (strcmp(ef->field_name, "content-type") == 0) { |
2131 char *p = strstr(ef->value, "charset=\""); | 2132 char *p = strstr(ef->value, "charset=\""); |
2132 if (p) { | 2133 if (p) { |
2133 p += 9; // skip over charset=" | 2134 p += 9; // skip over charset=" |
2134 char *pp = strchr(p, '"'); | 2135 char *pp = strchr(p, '"'); |
2137 char *set = strdup(p); | 2138 char *set = strdup(p); |
2138 *pp = '"'; | 2139 *pp = '"'; |
2139 if (item->body_charset.str) free(item->body_charset.str); | 2140 if (item->body_charset.str) free(item->body_charset.str); |
2140 item->body_charset.str = set; | 2141 item->body_charset.str = set; |
2141 item->body_charset.is_utf8 = 1; | 2142 item->body_charset.is_utf8 = 1; |
2142 DEBUG_EMAIL(("body charset %s from content-type extra field\n", set)); | 2143 DEBUG_INFO(("body charset %s from content-type extra field\n", set)); |
2143 } | 2144 } |
2144 } | 2145 } |
2145 } | 2146 } |
2146 } | 2147 } |
2147 else { | 2148 else { |
2160 DEBUG_WARN(("What does this mean?\n")); | 2161 DEBUG_WARN(("What does this mean?\n")); |
2161 DEBUG_HEXDUMP(list->elements[x]->data, list->elements[x]->size); | 2162 DEBUG_HEXDUMP(list->elements[x]->data, list->elements[x]->size); |
2162 } | 2163 } |
2163 break; | 2164 break; |
2164 case 0x0003: // Extended Attributes table | 2165 case 0x0003: // Extended Attributes table |
2165 DEBUG_EMAIL(("Extended Attributes Table - NOT PROCESSED\n")); | 2166 DEBUG_INFO(("Extended Attributes Table - NOT PROCESSED\n")); |
2166 break; | 2167 break; |
2167 case 0x0017: // PR_IMPORTANCE - How important the sender deems it to be | 2168 case 0x0017: // PR_IMPORTANCE - How important the sender deems it to be |
2168 LIST_COPY_EMAIL_ENUM("Importance Level", item->email->importance, 0, 3, "Low", "Normal", "High"); | 2169 LIST_COPY_EMAIL_ENUM("Importance Level", item->email->importance, 0, 3, "Low", "Normal", "High"); |
2169 break; | 2170 break; |
2170 case 0x001A: // PR_MESSAGE_CLASS IPM.x | 2171 case 0x001A: // PR_MESSAGE_CLASS IPM.x |
2190 item->type = PST_TYPE_STICKYNOTE; | 2191 item->type = PST_TYPE_STICKYNOTE; |
2191 else if (pst_strincmp("IPM.Task", item->ascii_type, 8) == 0) | 2192 else if (pst_strincmp("IPM.Task", item->ascii_type, 8) == 0) |
2192 item->type = PST_TYPE_TASK; | 2193 item->type = PST_TYPE_TASK; |
2193 else | 2194 else |
2194 item->type = PST_TYPE_OTHER; | 2195 item->type = PST_TYPE_OTHER; |
2195 DEBUG_EMAIL(("Message class %s [%"PRIi32"] \n", item->ascii_type, item->type)); | 2196 DEBUG_INFO(("Message class %s [%"PRIi32"] \n", item->ascii_type, item->type)); |
2196 } | 2197 } |
2197 else { | 2198 else { |
2198 DEBUG_WARN(("What does this mean?\n")); | 2199 DEBUG_WARN(("What does this mean?\n")); |
2199 DEBUG_HEXDUMP(list->elements[x]->data, list->elements[x]->size); | 2200 DEBUG_HEXDUMP(list->elements[x]->data, list->elements[x]->size); |
2200 } | 2201 } |
2247 break; | 2248 break; |
2248 case 0x003B: // PR_SENT_REPRESENTING_SEARCH_KEY Sender address 1 | 2249 case 0x003B: // PR_SENT_REPRESENTING_SEARCH_KEY Sender address 1 |
2249 LIST_COPY_EMAIL_STR("Sent on behalf of address 1", item->email->outlook_sender); | 2250 LIST_COPY_EMAIL_STR("Sent on behalf of address 1", item->email->outlook_sender); |
2250 break; | 2251 break; |
2251 case 0x003F: // PR_RECEIVED_BY_ENTRYID Structure containing Recipient | 2252 case 0x003F: // PR_RECEIVED_BY_ENTRYID Structure containing Recipient |
2252 DEBUG_EMAIL(("Recipient Structure 1 -- NOT PROCESSED\n")); | 2253 DEBUG_INFO(("Recipient Structure 1 -- NOT PROCESSED\n")); |
2253 break; | 2254 break; |
2254 case 0x0040: // PR_RECEIVED_BY_NAME Name of Recipient Structure | 2255 case 0x0040: // PR_RECEIVED_BY_NAME Name of Recipient Structure |
2255 DEBUG_EMAIL(("Received By Name 1 -- NOT PROCESSED\n")); | 2256 DEBUG_INFO(("Received By Name 1 -- NOT PROCESSED\n")); |
2256 break; | 2257 break; |
2257 case 0x0041: // PR_SENT_REPRESENTING_ENTRYID Structure containing Sender | 2258 case 0x0041: // PR_SENT_REPRESENTING_ENTRYID Structure containing Sender |
2258 DEBUG_EMAIL(("Sent on behalf of Structure 1 -- NOT PROCESSED\n")); | 2259 DEBUG_INFO(("Sent on behalf of Structure 1 -- NOT PROCESSED\n")); |
2259 break; | 2260 break; |
2260 case 0x0042: // PR_SENT_REPRESENTING_NAME | 2261 case 0x0042: // PR_SENT_REPRESENTING_NAME |
2261 LIST_COPY_EMAIL_STR("Sent on behalf of", item->email->outlook_sender_name); | 2262 LIST_COPY_EMAIL_STR("Sent on behalf of", item->email->outlook_sender_name); |
2262 break; | 2263 break; |
2263 case 0x0043: // PR_RCVD_REPRESENTING_ENTRYID Recipient Structure 2 | 2264 case 0x0043: // PR_RCVD_REPRESENTING_ENTRYID Recipient Structure 2 |
2264 DEBUG_EMAIL(("Received on behalf of Structure -- NOT PROCESSED\n")); | 2265 DEBUG_INFO(("Received on behalf of Structure -- NOT PROCESSED\n")); |
2265 break; | 2266 break; |
2266 case 0x0044: // PR_RCVD_REPRESENTING_NAME | 2267 case 0x0044: // PR_RCVD_REPRESENTING_NAME |
2267 LIST_COPY_EMAIL_STR("Received on behalf of", item->email->outlook_recipient_name); | 2268 LIST_COPY_EMAIL_STR("Received on behalf of", item->email->outlook_recipient_name); |
2268 break; | 2269 break; |
2269 case 0x004F: // PR_REPLY_RECIPIENT_ENTRIES Reply-To Structure | 2270 case 0x004F: // PR_REPLY_RECIPIENT_ENTRIES Reply-To Structure |
2270 DEBUG_EMAIL(("Reply-To Structure -- NOT PROCESSED\n")); | 2271 DEBUG_INFO(("Reply-To Structure -- NOT PROCESSED\n")); |
2271 break; | 2272 break; |
2272 case 0x0050: // PR_REPLY_RECIPIENT_NAMES Name of Reply-To Structure | 2273 case 0x0050: // PR_REPLY_RECIPIENT_NAMES Name of Reply-To Structure |
2273 LIST_COPY_EMAIL_STR("Reply-To", item->email->reply_to); | 2274 LIST_COPY_EMAIL_STR("Reply-To", item->email->reply_to); |
2274 break; | 2275 break; |
2275 case 0x0051: // PR_RECEIVED_BY_SEARCH_KEY Recipient Address 1 | 2276 case 0x0051: // PR_RECEIVED_BY_SEARCH_KEY Recipient Address 1 |
2334 break; | 2335 break; |
2335 case 0x0C05: // PR_NDR_DIAG_CODE | 2336 case 0x0C05: // PR_NDR_DIAG_CODE |
2336 LIST_COPY_EMAIL_INT32("NDR diag code", item->email->ndr_diag_code); | 2337 LIST_COPY_EMAIL_INT32("NDR diag code", item->email->ndr_diag_code); |
2337 break; | 2338 break; |
2338 case 0x0C06: // PR_NON_RECEIPT_NOTIFICATION_REQUESTED | 2339 case 0x0C06: // PR_NON_RECEIPT_NOTIFICATION_REQUESTED |
2339 DEBUG_EMAIL(("Non-Receipt Notification Requested -- NOT PROCESSED\n")); | 2340 DEBUG_INFO(("Non-Receipt Notification Requested -- NOT PROCESSED\n")); |
2340 break; | 2341 break; |
2341 case 0x0C17: // PR_REPLY_REQUESTED | 2342 case 0x0C17: // PR_REPLY_REQUESTED |
2342 LIST_COPY_EMAIL_BOOL("Reply Requested", item->email->reply_requested); | 2343 LIST_COPY_EMAIL_BOOL("Reply Requested", item->email->reply_requested); |
2343 break; | 2344 break; |
2344 case 0x0C19: // PR_SENDER_ENTRYID Sender Structure 2 | 2345 case 0x0C19: // PR_SENDER_ENTRYID Sender Structure 2 |
2345 DEBUG_EMAIL(("Sender Structure 2 -- NOT PROCESSED\n")); | 2346 DEBUG_INFO(("Sender Structure 2 -- NOT PROCESSED\n")); |
2346 break; | 2347 break; |
2347 case 0x0C1A: // PR_SENDER_NAME Name of Sender Structure 2 | 2348 case 0x0C1A: // PR_SENDER_NAME Name of Sender Structure 2 |
2348 DEBUG_EMAIL(("Name of Sender Structure 2 -- NOT PROCESSED\n")); | 2349 DEBUG_INFO(("Name of Sender Structure 2 -- NOT PROCESSED\n")); |
2349 break; | 2350 break; |
2350 case 0x0C1B: // PR_SUPPLEMENTARY_INFO | 2351 case 0x0C1B: // PR_SUPPLEMENTARY_INFO |
2351 LIST_COPY_EMAIL_STR("Supplementary info", item->email->supplementary_info); | 2352 LIST_COPY_EMAIL_STR("Supplementary info", item->email->supplementary_info); |
2352 break; | 2353 break; |
2353 case 0x0C1D: // PR_SENDER_SEARCH_KEY Name of Sender Address 2 | 2354 case 0x0C1D: // PR_SENDER_SEARCH_KEY Name of Sender Address 2 |
2399 LIST_COPY_INT32("Attachment Size", t); | 2400 LIST_COPY_INT32("Attachment Size", t); |
2400 attach->data.size = (size_t)t; | 2401 attach->data.size = (size_t)t; |
2401 break; | 2402 break; |
2402 case 0x0FF9: // PR_RECORD_KEY Record Header 1 | 2403 case 0x0FF9: // PR_RECORD_KEY Record Header 1 |
2403 LIST_COPY_BIN(item->record_key); | 2404 LIST_COPY_BIN(item->record_key); |
2404 DEBUG_EMAIL(("Record Key\n")); | 2405 DEBUG_INFO(("Record Key\n")); |
2405 DEBUG_EMAIL_HEXPRINT(item->record_key.data, item->record_key.size); | 2406 DEBUG_HEXDUMP(item->record_key.data, item->record_key.size); |
2406 break; | 2407 break; |
2407 case 0x1000: // PR_BODY | 2408 case 0x1000: // PR_BODY |
2408 LIST_COPY_STR("Plain Text body", item->body); | 2409 LIST_COPY_STR("Plain Text body", item->body); |
2409 break; | 2410 break; |
2410 case 0x1001: // PR_REPORT_TEXT | 2411 case 0x1001: // PR_REPORT_TEXT |
2463 break; | 2464 break; |
2464 case 0x3008: // PR_LAST_MODIFICATION_TIME Date 5 - Modify Date | 2465 case 0x3008: // PR_LAST_MODIFICATION_TIME Date 5 - Modify Date |
2465 LIST_COPY_TIME("Date 5 (Modify Date)", item->modify_date); | 2466 LIST_COPY_TIME("Date 5 (Modify Date)", item->modify_date); |
2466 break; | 2467 break; |
2467 case 0x300B: // PR_SEARCH_KEY Record Header 2 | 2468 case 0x300B: // PR_SEARCH_KEY Record Header 2 |
2468 DEBUG_EMAIL(("Record Search 2 -- NOT PROCESSED\n")); | 2469 DEBUG_INFO(("Record Search 2 -- NOT PROCESSED\n")); |
2469 break; | 2470 break; |
2470 case 0x35DF: // PR_VALID_FOLDER_MASK | 2471 case 0x35DF: // PR_VALID_FOLDER_MASK |
2471 LIST_COPY_STORE_INT32("Valid Folder Mask", item->message_store->valid_mask); | 2472 LIST_COPY_STORE_INT32("Valid Folder Mask", item->message_store->valid_mask); |
2472 break; | 2473 break; |
2473 case 0x35E0: // PR_IPM_SUBTREE_ENTRYID Top of Personal Folder Record | 2474 case 0x35E0: // PR_IPM_SUBTREE_ENTRYID Top of Personal Folder Record |
2503 break; | 2504 break; |
2504 case 0x3613: // PR_CONTAINER_CLASS IPF.x | 2505 case 0x3613: // PR_CONTAINER_CLASS IPF.x |
2505 LIST_COPY_CSTR(item->ascii_type); | 2506 LIST_COPY_CSTR(item->ascii_type); |
2506 if (pst_strincmp("IPF.Note", item->ascii_type, 8) == 0) | 2507 if (pst_strincmp("IPF.Note", item->ascii_type, 8) == 0) |
2507 item->type = PST_TYPE_NOTE; | 2508 item->type = PST_TYPE_NOTE; |
2508 if (pst_strincmp("IPF.Imap", item->ascii_type, 8) == 0) | 2509 else if (pst_strincmp("IPF.Imap", item->ascii_type, 8) == 0) |
2509 item->type = PST_TYPE_NOTE; | 2510 item->type = PST_TYPE_NOTE; |
2510 else if (pst_stricmp("IPF", item->ascii_type) == 0) | 2511 else if (pst_stricmp("IPF", item->ascii_type) == 0) |
2511 item->type = PST_TYPE_NOTE; | 2512 item->type = PST_TYPE_NOTE; |
2512 else if (pst_strincmp("IPF.Contact", item->ascii_type, 11) == 0) | 2513 else if (pst_strincmp("IPF.Contact", item->ascii_type, 11) == 0) |
2513 item->type = PST_TYPE_CONTACT; | 2514 item->type = PST_TYPE_CONTACT; |
2520 else if (pst_strincmp("IPF.Task", item->ascii_type, 8) == 0) | 2521 else if (pst_strincmp("IPF.Task", item->ascii_type, 8) == 0) |
2521 item->type = PST_TYPE_TASK; | 2522 item->type = PST_TYPE_TASK; |
2522 else | 2523 else |
2523 item->type = PST_TYPE_OTHER; | 2524 item->type = PST_TYPE_OTHER; |
2524 | 2525 |
2525 DEBUG_EMAIL(("Container class %s [%"PRIi32"]\n", item->ascii_type, item->type)); | 2526 DEBUG_INFO(("Container class %s [%"PRIi32"]\n", item->ascii_type, item->type)); |
2526 break; | 2527 break; |
2527 case 0x3617: // PR_ASSOC_CONTENT_COUNT | 2528 case 0x3617: // PR_ASSOC_CONTENT_COUNT |
2528 // associated content are items that are attached to this folder | 2529 // associated content are items that are attached to this folder |
2529 // but are hidden from users | 2530 // but are hidden from users |
2530 LIST_COPY_FOLDER_INT32("Associated Content count", item->folder->assoc_count); | 2531 LIST_COPY_FOLDER_INT32("Associated Content count", item->folder->assoc_count); |
2531 break; | 2532 break; |
2532 case 0x3701: // PR_ATTACH_DATA_OBJ binary data of attachment | 2533 case 0x3701: // PR_ATTACH_DATA_OBJ binary data of attachment |
2533 DEBUG_EMAIL(("Binary Data [Size %i] - ", list->elements[x]->size)); | 2534 DEBUG_INFO(("Binary Data [Size %i] - ", list->elements[x]->size)); |
2534 NULL_CHECK(attach); | 2535 NULL_CHECK(attach); |
2535 if (!list->elements[x]->data) { //special case | 2536 if (!list->elements[x]->data) { //special case |
2536 attach->id2_val = list->elements[x]->type; | 2537 attach->id2_val = list->elements[x]->type; |
2537 DEBUG_EMAIL(("Seen a Reference. The data hasn't been loaded yet. [%#"PRIx64"]\n", attach->id2_val)); | 2538 DEBUG_INFO(("Seen a Reference. The data hasn't been loaded yet. [%#"PRIx64"]\n", attach->id2_val)); |
2538 } else { | 2539 } else { |
2539 LIST_COPY_BIN(attach->data); | 2540 LIST_COPY_BIN(attach->data); |
2540 } | 2541 } |
2541 break; | 2542 break; |
2542 case 0x3704: // PR_ATTACH_FILENAME Attachment filename (8.3) | 2543 case 0x3704: // PR_ATTACH_FILENAME Attachment filename (8.3) |
2574 break; | 2575 break; |
2575 case 0x3A00: // PR_ACCOUNT | 2576 case 0x3A00: // PR_ACCOUNT |
2576 LIST_COPY_CONTACT_STR("Contact's Account name", item->contact->account_name); | 2577 LIST_COPY_CONTACT_STR("Contact's Account name", item->contact->account_name); |
2577 break; | 2578 break; |
2578 case 0x3A01: // PR_ALTERNATE_RECIPIENT | 2579 case 0x3A01: // PR_ALTERNATE_RECIPIENT |
2579 DEBUG_EMAIL(("Contact Alternate Recipient - NOT PROCESSED\n")); | 2580 DEBUG_INFO(("Contact Alternate Recipient - NOT PROCESSED\n")); |
2580 break; | 2581 break; |
2581 case 0x3A02: // PR_CALLBACK_TELEPHONE_NUMBER | 2582 case 0x3A02: // PR_CALLBACK_TELEPHONE_NUMBER |
2582 LIST_COPY_CONTACT_STR("Callback telephone number", item->contact->callback_phone); | 2583 LIST_COPY_CONTACT_STR("Callback telephone number", item->contact->callback_phone); |
2583 break; | 2584 break; |
2584 case 0x3A03: // PR_CONVERSION_PROHIBITED | 2585 case 0x3A03: // PR_CONVERSION_PROHIBITED |
2622 break; | 2623 break; |
2623 case 0x3A11: // PR_SURNAME Contact's Surname | 2624 case 0x3A11: // PR_SURNAME Contact's Surname |
2624 LIST_COPY_CONTACT_STR("Contacts Surname", item->contact->surname); | 2625 LIST_COPY_CONTACT_STR("Contacts Surname", item->contact->surname); |
2625 break; | 2626 break; |
2626 case 0x3A12: // PR_ORIGINAL_ENTRY_ID | 2627 case 0x3A12: // PR_ORIGINAL_ENTRY_ID |
2627 DEBUG_EMAIL(("Original Entry ID - NOT PROCESSED\n")); | 2628 DEBUG_INFO(("Original Entry ID - NOT PROCESSED\n")); |
2628 break; | 2629 break; |
2629 case 0x3A13: // PR_ORIGINAL_DISPLAY_NAME | 2630 case 0x3A13: // PR_ORIGINAL_DISPLAY_NAME |
2630 DEBUG_EMAIL(("Original Display Name - NOT PROCESSED\n")); | 2631 DEBUG_INFO(("Original Display Name - NOT PROCESSED\n")); |
2631 break; | 2632 break; |
2632 case 0x3A14: // PR_ORIGINAL_SEARCH_KEY | 2633 case 0x3A14: // PR_ORIGINAL_SEARCH_KEY |
2633 DEBUG_EMAIL(("Original Search Key - NOT PROCESSED\n")); | 2634 DEBUG_INFO(("Original Search Key - NOT PROCESSED\n")); |
2634 break; | 2635 break; |
2635 case 0x3A15: // PR_POSTAL_ADDRESS | 2636 case 0x3A15: // PR_POSTAL_ADDRESS |
2636 LIST_COPY_CONTACT_STR("Default Postal Address", item->contact->def_postal_address); | 2637 LIST_COPY_CONTACT_STR("Default Postal Address", item->contact->def_postal_address); |
2637 break; | 2638 break; |
2638 case 0x3A16: // PR_COMPANY_NAME | 2639 case 0x3A16: // PR_COMPANY_NAME |
2670 break; | 2671 break; |
2671 case 0x3A21: // PR_PAGER_TELEPHONE_NUMBER | 2672 case 0x3A21: // PR_PAGER_TELEPHONE_NUMBER |
2672 LIST_COPY_CONTACT_STR("Pager Phone Number", item->contact->pager_phone); | 2673 LIST_COPY_CONTACT_STR("Pager Phone Number", item->contact->pager_phone); |
2673 break; | 2674 break; |
2674 case 0x3A22: // PR_USER_CERTIFICATE | 2675 case 0x3A22: // PR_USER_CERTIFICATE |
2675 DEBUG_EMAIL(("User Certificate - NOT PROCESSED\n")); | 2676 DEBUG_INFO(("User Certificate - NOT PROCESSED\n")); |
2676 break; | 2677 break; |
2677 case 0x3A23: // PR_PRIMARY_FAX_NUMBER | 2678 case 0x3A23: // PR_PRIMARY_FAX_NUMBER |
2678 LIST_COPY_CONTACT_STR("Primary Fax Number", item->contact->primary_fax); | 2679 LIST_COPY_CONTACT_STR("Primary Fax Number", item->contact->primary_fax); |
2679 break; | 2680 break; |
2680 case 0x3A24: // PR_BUSINESS_FAX_NUMBER | 2681 case 0x3A24: // PR_BUSINESS_FAX_NUMBER |
2772 break; | 2773 break; |
2773 case 0x3A57: // PR_COMPANY_MAIN_PHONE_NUMBER | 2774 case 0x3A57: // PR_COMPANY_MAIN_PHONE_NUMBER |
2774 LIST_COPY_CONTACT_STR("Company Main Phone", item->contact->company_main_phone); | 2775 LIST_COPY_CONTACT_STR("Company Main Phone", item->contact->company_main_phone); |
2775 break; | 2776 break; |
2776 case 0x3A58: // PR_CHILDRENS_NAMES | 2777 case 0x3A58: // PR_CHILDRENS_NAMES |
2777 DEBUG_EMAIL(("Children's Names - NOT PROCESSED\n")); | 2778 DEBUG_INFO(("Children's Names - NOT PROCESSED\n")); |
2778 break; | 2779 break; |
2779 case 0x3A59: // PR_HOME_ADDRESS_CITY | 2780 case 0x3A59: // PR_HOME_ADDRESS_CITY |
2780 LIST_COPY_CONTACT_STR("Home Address City", item->contact->home_city); | 2781 LIST_COPY_CONTACT_STR("Home Address City", item->contact->home_city); |
2781 break; | 2782 break; |
2782 case 0x3A5A: // PR_HOME_ADDRESS_COUNTRY | 2783 case 0x3A5A: // PR_HOME_ADDRESS_COUNTRY |
2818 case 0x3FFD: // PR_MESSAGE_CODEPAGE | 2819 case 0x3FFD: // PR_MESSAGE_CODEPAGE |
2819 LIST_COPY_INT32("Message code page", item->message_codepage); | 2820 LIST_COPY_INT32("Message code page", item->message_codepage); |
2820 break; | 2821 break; |
2821 case 0x65E3: // PR_PREDECESSOR_CHANGE_LIST | 2822 case 0x65E3: // PR_PREDECESSOR_CHANGE_LIST |
2822 LIST_COPY_BIN(item->predecessor_change); | 2823 LIST_COPY_BIN(item->predecessor_change); |
2823 DEBUG_EMAIL(("Predecessor Change\n")); | 2824 DEBUG_INFO(("Predecessor Change\n")); |
2824 DEBUG_EMAIL_HEXPRINT(item->predecessor_change.data, item->predecessor_change.size); | 2825 DEBUG_HEXDUMP(item->predecessor_change.data, item->predecessor_change.size); |
2825 break; | 2826 break; |
2826 case 0x67F2: // ID2 value of the attachments proper record | 2827 case 0x67F2: // ID2 value of the attachments proper record |
2827 DEBUG_EMAIL(("Attachment ID2 value - ")); | 2828 DEBUG_INFO(("Attachment ID2 value - ")); |
2828 if (attach) { | 2829 if (attach) { |
2829 uint32_t tempid; | 2830 uint32_t tempid; |
2830 memcpy(&(tempid), list->elements[x]->data, sizeof(tempid)); | 2831 memcpy(&(tempid), list->elements[x]->data, sizeof(tempid)); |
2831 LE32_CPU(tempid); | 2832 LE32_CPU(tempid); |
2832 attach->id2_val = tempid; | 2833 attach->id2_val = tempid; |
2833 DEBUG_EMAIL(("%#"PRIx64"\n", attach->id2_val)); | 2834 DEBUG_INFO(("%#"PRIx64"\n", attach->id2_val)); |
2834 } else { | 2835 } else { |
2835 DEBUG_WARN(("NOT AN ATTACHMENT: %#x\n", list->elements[x]->mapi_id)); | 2836 DEBUG_WARN(("NOT AN ATTACHMENT: %#x\n", list->elements[x]->mapi_id)); |
2836 } | 2837 } |
2837 break; | 2838 break; |
2838 case 0x67FF: // Extra Property Identifier (Password CheckSum) | 2839 case 0x67FF: // Extra Property Identifier (Password CheckSum) |
2977 break; | 2978 break; |
2978 case 0x8503: // PR_OUTLOOK_COMMON_REMINDER_SET | 2979 case 0x8503: // PR_OUTLOOK_COMMON_REMINDER_SET |
2979 LIST_COPY_APPT_BOOL("Reminder alarm", item->appointment->alarm); | 2980 LIST_COPY_APPT_BOOL("Reminder alarm", item->appointment->alarm); |
2980 break; | 2981 break; |
2981 case 0x8516: // Common start | 2982 case 0x8516: // Common start |
2982 DEBUG_EMAIL(("Common Start Date - %s\n", pst_fileTimeToAscii((FILETIME*)list->elements[x]->data, time_buffer))); | 2983 DEBUG_INFO(("Common Start Date - %s\n", pst_fileTimeToAscii((FILETIME*)list->elements[x]->data, time_buffer))); |
2983 break; | 2984 break; |
2984 case 0x8517: // Common end | 2985 case 0x8517: // Common end |
2985 DEBUG_EMAIL(("Common End Date - %s\n", pst_fileTimeToAscii((FILETIME*)list->elements[x]->data, time_buffer))); | 2986 DEBUG_INFO(("Common End Date - %s\n", pst_fileTimeToAscii((FILETIME*)list->elements[x]->data, time_buffer))); |
2986 break; | 2987 break; |
2987 case 0x851f: // Play reminder sound filename | 2988 case 0x851f: // Play reminder sound filename |
2988 LIST_COPY_APPT_STR("Appointment reminder sound filename", item->appointment->alarm_filename); | 2989 LIST_COPY_APPT_STR("Appointment reminder sound filename", item->appointment->alarm_filename); |
2989 break; | 2990 break; |
2990 case 0x8530: // Followup | 2991 case 0x8530: // Followup |
3243 if (buf) free(buf); | 3244 if (buf) free(buf); |
3244 DEBUG_RET(); | 3245 DEBUG_RET(); |
3245 return NULL; | 3246 return NULL; |
3246 } | 3247 } |
3247 | 3248 |
3248 DEBUG_INDEX(("ID %#"PRIx64" is likely to be a description record. Count is %i (offset %#"PRIx64")\n", | 3249 DEBUG_INFO(("ID %#"PRIx64" is likely to be a description record. Count is %i (offset %#"PRIx64")\n", |
3249 list->i_id, block_head.count, list->offset)); | 3250 list->i_id, block_head.count, list->offset)); |
3250 x = 0; | 3251 x = 0; |
3251 b_ptr = buf + ((pf->do_read64) ? 0x08 : 0x04); | 3252 b_ptr = buf + ((pf->do_read64) ? 0x08 : 0x04); |
3252 while (x < block_head.count) { | 3253 while (x < block_head.count) { |
3253 b_ptr += pst_decode_assoc(pf, &id2_rec, b_ptr); | 3254 b_ptr += pst_decode_assoc(pf, &id2_rec, b_ptr); |
3254 DEBUG_INDEX(("id2 = %#x, id = %#"PRIx64", child id = %#"PRIx64"\n", id2_rec.id2, id2_rec.id, id2_rec.child_id)); | 3255 DEBUG_INFO(("id2 = %#x, id = %#"PRIx64", child id = %#"PRIx64"\n", id2_rec.id2, id2_rec.id, id2_rec.child_id)); |
3255 if ((i_ptr = pst_getID(pf, id2_rec.id)) == NULL) { | 3256 if ((i_ptr = pst_getID(pf, id2_rec.id)) == NULL) { |
3256 DEBUG_WARN(("%#"PRIx64" - Not Found\n", id2_rec.id)); | 3257 DEBUG_WARN(("%#"PRIx64" - Not Found\n", id2_rec.id)); |
3257 } else { | 3258 } else { |
3258 DEBUG_INDEX(("%#"PRIx64" - Offset %#"PRIx64", u1 %#"PRIx64", Size %"PRIi64"(%#"PRIx64")\n", | 3259 DEBUG_INFO(("%#"PRIx64" - Offset %#"PRIx64", u1 %#"PRIx64", Size %"PRIi64"(%#"PRIx64")\n", |
3259 i_ptr->i_id, i_ptr->offset, i_ptr->u1, i_ptr->size, i_ptr->size)); | 3260 i_ptr->i_id, i_ptr->offset, i_ptr->u1, i_ptr->size, i_ptr->size)); |
3260 // add it to the tree | 3261 // add it to the tree |
3261 i2_ptr = (pst_id2_tree*) pst_malloc(sizeof(pst_id2_tree)); | 3262 i2_ptr = (pst_id2_tree*) pst_malloc(sizeof(pst_id2_tree)); |
3262 i2_ptr->id2 = id2_rec.id2; | 3263 i2_ptr->id2 = id2_rec.id2; |
3263 i2_ptr->id = i_ptr; | 3264 i2_ptr->id = i_ptr; |
3586 if (i_id == 0) { | 3587 if (i_id == 0) { |
3587 DEBUG_RET(); | 3588 DEBUG_RET(); |
3588 return NULL; | 3589 return NULL; |
3589 } | 3590 } |
3590 | 3591 |
3591 //if (i_id & 1) DEBUG_INDEX(("have odd id bit %#"PRIx64"\n", i_id)); | 3592 //if (i_id & 1) DEBUG_INFO(("have odd id bit %#"PRIx64"\n", i_id)); |
3592 //if (i_id & 2) DEBUG_INDEX(("have two id bit %#"PRIx64"\n", i_id)); | 3593 //if (i_id & 2) DEBUG_INFO(("have two id bit %#"PRIx64"\n", i_id)); |
3593 i_id -= (i_id & 1); | 3594 i_id -= (i_id & 1); |
3594 | 3595 |
3595 DEBUG_INDEX(("Trying to find %#"PRIx64"\n", i_id)); | 3596 DEBUG_INFO(("Trying to find %#"PRIx64"\n", i_id)); |
3596 ptr = pf->i_head; | 3597 ptr = pf->i_head; |
3597 while (ptr && (ptr->i_id != i_id)) { | 3598 while (ptr && (ptr->i_id != i_id)) { |
3598 ptr = ptr->next; | 3599 ptr = ptr->next; |
3599 } | 3600 } |
3600 if (ptr) {DEBUG_INDEX(("Found Value %#"PRIx64"\n", i_id)); } | 3601 if (ptr) {DEBUG_INFO(("Found Value %#"PRIx64"\n", i_id)); } |
3601 else {DEBUG_INDEX(("ERROR: Value %#"PRIx64" not found\n", i_id)); } | 3602 else {DEBUG_INFO(("ERROR: Value %#"PRIx64" not found\n", i_id)); } |
3602 DEBUG_RET(); | 3603 DEBUG_RET(); |
3603 return ptr; | 3604 return ptr; |
3604 } | 3605 } |
3605 | 3606 |
3606 | 3607 |
3607 static pst_id2_tree *pst_getID2(pst_id2_tree *head, uint64_t id2) { | 3608 static pst_id2_tree *pst_getID2(pst_id2_tree *head, uint64_t id2) { |
3608 DEBUG_ENT("pst_getID2"); | 3609 DEBUG_ENT("pst_getID2"); |
3609 DEBUG_INDEX(("looking for id2 = %#"PRIx64"\n", id2)); | 3610 DEBUG_INFO(("looking for id2 = %#"PRIx64"\n", id2)); |
3610 pst_id2_tree *ptr = head; | 3611 pst_id2_tree *ptr = head; |
3611 while (ptr) { | 3612 while (ptr) { |
3612 if (ptr->id2 == id2) break; | 3613 if (ptr->id2 == id2) break; |
3613 if (ptr->child) { | 3614 if (ptr->child) { |
3614 pst_id2_tree *rc = pst_getID2(ptr->child, id2); | 3615 pst_id2_tree *rc = pst_getID2(ptr->child, id2); |
3618 } | 3619 } |
3619 } | 3620 } |
3620 ptr = ptr->next; | 3621 ptr = ptr->next; |
3621 } | 3622 } |
3622 if (ptr && ptr->id) { | 3623 if (ptr && ptr->id) { |
3623 DEBUG_INDEX(("Found value %#"PRIx64"\n", ptr->id->i_id)); | 3624 DEBUG_INFO(("Found value %#"PRIx64"\n", ptr->id->i_id)); |
3624 DEBUG_RET(); | 3625 DEBUG_RET(); |
3625 return ptr; | 3626 return ptr; |
3626 } | 3627 } |
3627 DEBUG_INDEX(("ERROR Not Found\n")); | 3628 DEBUG_INFO(("ERROR Not Found\n")); |
3628 DEBUG_RET(); | 3629 DEBUG_RET(); |
3629 return NULL; | 3630 return NULL; |
3630 } | 3631 } |
3631 | 3632 |
3632 | 3633 |
3640 */ | 3641 */ |
3641 static pst_desc_tree* pst_getDptr(pst_file *pf, uint64_t d_id) { | 3642 static pst_desc_tree* pst_getDptr(pst_file *pf, uint64_t d_id) { |
3642 pst_desc_tree *ptr = pf->d_head; | 3643 pst_desc_tree *ptr = pf->d_head; |
3643 DEBUG_ENT("pst_getDptr"); | 3644 DEBUG_ENT("pst_getDptr"); |
3644 while (ptr && (ptr->d_id != d_id)) { | 3645 while (ptr && (ptr->d_id != d_id)) { |
3645 //DEBUG_INDEX(("Looking for %#"PRIx64" at node %#"PRIx64" with parent %#"PRIx64"\n", id, ptr->d_id, ptr->parent_d_id)); | 3646 //DEBUG_INFO(("Looking for %#"PRIx64" at node %#"PRIx64" with parent %#"PRIx64"\n", id, ptr->d_id, ptr->parent_d_id)); |
3646 if (ptr->child) { | 3647 if (ptr->child) { |
3647 ptr = ptr->child; | 3648 ptr = ptr->child; |
3648 continue; | 3649 continue; |
3649 } | 3650 } |
3650 while (!ptr->next && ptr->parent) { | 3651 while (!ptr->next && ptr->parent) { |
3658 | 3659 |
3659 | 3660 |
3660 static void pst_printDptr(pst_file *pf, pst_desc_tree *ptr) { | 3661 static void pst_printDptr(pst_file *pf, pst_desc_tree *ptr) { |
3661 DEBUG_ENT("pst_printDptr"); | 3662 DEBUG_ENT("pst_printDptr"); |
3662 while (ptr) { | 3663 while (ptr) { |
3663 DEBUG_INDEX(("%#"PRIx64" [%i] desc=%#"PRIx64", assoc tree=%#"PRIx64"\n", ptr->d_id, ptr->no_child, | 3664 DEBUG_INFO(("%#"PRIx64" [%i] desc=%#"PRIx64", assoc tree=%#"PRIx64"\n", ptr->d_id, ptr->no_child, |
3664 (ptr->desc ? ptr->desc->i_id : (uint64_t)0), | 3665 (ptr->desc ? ptr->desc->i_id : (uint64_t)0), |
3665 (ptr->assoc_tree ? ptr->assoc_tree->i_id : (uint64_t)0))); | 3666 (ptr->assoc_tree ? ptr->assoc_tree->i_id : (uint64_t)0))); |
3666 if (ptr->child) { | 3667 if (ptr->child) { |
3667 pst_printDptr(pf, ptr->child); | 3668 pst_printDptr(pf, ptr->child); |
3668 } | 3669 } |
3674 | 3675 |
3675 static void pst_printIDptr(pst_file* pf) { | 3676 static void pst_printIDptr(pst_file* pf) { |
3676 pst_index_ll *ptr = pf->i_head; | 3677 pst_index_ll *ptr = pf->i_head; |
3677 DEBUG_ENT("pst_printIDptr"); | 3678 DEBUG_ENT("pst_printIDptr"); |
3678 while (ptr) { | 3679 while (ptr) { |
3679 DEBUG_INDEX(("%#"PRIx64" offset=%#"PRIx64" size=%#"PRIx64"\n", ptr->i_id, ptr->offset, ptr->size)); | 3680 DEBUG_INFO(("%#"PRIx64" offset=%#"PRIx64" size=%#"PRIx64"\n", ptr->i_id, ptr->offset, ptr->size)); |
3680 ptr = ptr->next; | 3681 ptr = ptr->next; |
3681 } | 3682 } |
3682 DEBUG_RET(); | 3683 DEBUG_RET(); |
3683 } | 3684 } |
3684 | 3685 |
3685 | 3686 |
3686 static void pst_printID2ptr(pst_id2_tree *ptr) { | 3687 static void pst_printID2ptr(pst_id2_tree *ptr) { |
3687 DEBUG_ENT("pst_printID2ptr"); | 3688 DEBUG_ENT("pst_printID2ptr"); |
3688 while (ptr) { | 3689 while (ptr) { |
3689 DEBUG_INDEX(("%#"PRIx64" id=%#"PRIx64"\n", ptr->id2, (ptr->id ? ptr->id->i_id : (uint64_t)0))); | 3690 DEBUG_INFO(("%#"PRIx64" id=%#"PRIx64"\n", ptr->id2, (ptr->id ? ptr->id->i_id : (uint64_t)0))); |
3690 if (ptr->child) pst_printID2ptr(ptr->child); | 3691 if (ptr->child) pst_printID2ptr(ptr->child); |
3691 ptr = ptr->next; | 3692 ptr = ptr->next; |
3692 } | 3693 } |
3693 DEBUG_RET(); | 3694 DEBUG_RET(); |
3694 } | 3695 } |
3704 * @return size of block read into memory | 3705 * @return size of block read into memory |
3705 */ | 3706 */ |
3706 static size_t pst_read_block_size(pst_file *pf, int64_t offset, size_t size, char **buf) { | 3707 static size_t pst_read_block_size(pst_file *pf, int64_t offset, size_t size, char **buf) { |
3707 size_t rsize; | 3708 size_t rsize; |
3708 DEBUG_ENT("pst_read_block_size"); | 3709 DEBUG_ENT("pst_read_block_size"); |
3709 DEBUG_READ(("Reading block from %#"PRIx64", %x bytes\n", offset, size)); | 3710 DEBUG_INFO(("Reading block from %#"PRIx64", %x bytes\n", offset, size)); |
3710 | 3711 |
3711 if (*buf) { | 3712 if (*buf) { |
3712 DEBUG_READ(("Freeing old memory\n")); | 3713 DEBUG_INFO(("Freeing old memory\n")); |
3713 free(*buf); | 3714 free(*buf); |
3714 } | 3715 } |
3715 *buf = (char*) pst_malloc(size); | 3716 *buf = (char*) pst_malloc(size); |
3716 | 3717 |
3717 rsize = pst_getAtPos(pf, offset, *buf, size); | 3718 rsize = pst_getAtPos(pf, offset, *buf, size); |
3839 // p->next = tail; | 3840 // p->next = tail; |
3840 // p->offset = pos; | 3841 // p->offset = pos; |
3841 // p->size = size; | 3842 // p->size = size; |
3842 // p->readcount = 1; | 3843 // p->readcount = 1; |
3843 // } | 3844 // } |
3844 // DEBUG_MAIN(("pst file old offset %#"PRIx64" old size %#x read count %i offset %#"PRIx64" size %#x\n", | 3845 // DEBUG_INFO(("pst file old offset %#"PRIx64" old size %#x read count %i offset %#"PRIx64" size %#x\n", |
3845 // p->offset, p->size, p->readcount, pos, size)); | 3846 // p->offset, p->size, p->readcount, pos, size)); |
3846 | 3847 |
3847 if (fseeko(pf->fp, pos, SEEK_SET) == -1) { | 3848 if (fseeko(pf->fp, pos, SEEK_SET) == -1) { |
3848 DEBUG_RET(); | 3849 DEBUG_RET(); |
3849 return 0; | 3850 return 0; |
3864 */ | 3865 */ |
3865 size_t pst_ff_getIDblock_dec(pst_file *pf, uint64_t i_id, char **buf) { | 3866 size_t pst_ff_getIDblock_dec(pst_file *pf, uint64_t i_id, char **buf) { |
3866 size_t r; | 3867 size_t r; |
3867 int noenc = (int)(i_id & 2); // disable encryption | 3868 int noenc = (int)(i_id & 2); // disable encryption |
3868 DEBUG_ENT("pst_ff_getIDblock_dec"); | 3869 DEBUG_ENT("pst_ff_getIDblock_dec"); |
3869 DEBUG_INDEX(("for id %#"PRIi64"\n", i_id)); | 3870 DEBUG_INFO(("for id %#"PRIi64"\n", i_id)); |
3870 r = pst_ff_getIDblock(pf, i_id, buf); | 3871 r = pst_ff_getIDblock(pf, i_id, buf); |
3871 if ((pf->encryption) && !(noenc)) { | 3872 if ((pf->encryption) && !(noenc)) { |
3872 (void)pst_decrypt(i_id, *buf, r, pf->encryption); | 3873 (void)pst_decrypt(i_id, *buf, r, pf->encryption); |
3873 } | 3874 } |
3874 DEBUG_HEXDUMPC(*buf, r, 16); | 3875 DEBUG_HEXDUMPC(*buf, r, 16); |
3889 pst_index_ll *rec; | 3890 pst_index_ll *rec; |
3890 size_t rsize; | 3891 size_t rsize; |
3891 DEBUG_ENT("pst_ff_getIDblock"); | 3892 DEBUG_ENT("pst_ff_getIDblock"); |
3892 rec = pst_getID(pf, i_id); | 3893 rec = pst_getID(pf, i_id); |
3893 if (!rec) { | 3894 if (!rec) { |
3894 DEBUG_INDEX(("Cannot find ID %#"PRIx64"\n", i_id)); | 3895 DEBUG_INFO(("Cannot find ID %#"PRIx64"\n", i_id)); |
3895 DEBUG_RET(); | 3896 DEBUG_RET(); |
3896 return 0; | 3897 return 0; |
3897 } | 3898 } |
3898 DEBUG_INDEX(("id = %#"PRIx64", record size = %#x, offset = %#x\n", i_id, rec->size, rec->offset)); | 3899 DEBUG_INFO(("id = %#"PRIx64", record size = %#x, offset = %#x\n", i_id, rec->size, rec->offset)); |
3899 rsize = pst_read_block_size(pf, rec->offset, rec->size, buf); | 3900 rsize = pst_read_block_size(pf, rec->offset, rec->size, buf); |
3900 DEBUG_RET(); | 3901 DEBUG_RET(); |
3901 return rsize; | 3902 return rsize; |
3902 } | 3903 } |
3903 | 3904 |
3908 pst_holder h = {buf, NULL, 0}; | 3909 pst_holder h = {buf, NULL, 0}; |
3909 DEBUG_ENT("pst_ff_getID2block"); | 3910 DEBUG_ENT("pst_ff_getID2block"); |
3910 ptr = pst_getID2(id2_head, id2); | 3911 ptr = pst_getID2(id2_head, id2); |
3911 | 3912 |
3912 if (!ptr) { | 3913 if (!ptr) { |
3913 DEBUG_INDEX(("Cannot find id2 value %#"PRIi64"\n", id2)); | 3914 DEBUG_WARN(("Cannot find id2 value %#"PRIi64"\n", id2)); |
3914 DEBUG_RET(); | 3915 DEBUG_RET(); |
3915 return 0; | 3916 return 0; |
3916 } | 3917 } |
3917 ret = pst_ff_getID2data(pf, ptr->id, &h); | 3918 ret = pst_ff_getID2data(pf, ptr->id, &h); |
3918 DEBUG_RET(); | 3919 DEBUG_RET(); |
3942 // h-> does not specify any output | 3943 // h-> does not specify any output |
3943 } | 3944 } |
3944 | 3945 |
3945 } else { | 3946 } else { |
3946 // here we will assume it is a block that points to others | 3947 // here we will assume it is a block that points to others |
3947 DEBUG_READ(("Assuming it is a multi-block record because of it's id\n")); | 3948 DEBUG_INFO(("Assuming it is a multi-block record because of it's id\n")); |
3948 ret = pst_ff_compile_ID(pf, ptr->i_id, h, (size_t)0); | 3949 ret = pst_ff_compile_ID(pf, ptr->i_id, h, (size_t)0); |
3949 } | 3950 } |
3950 DEBUG_RET(); | 3951 DEBUG_RET(); |
3951 return ret; | 3952 return ret; |
3952 } | 3953 } |
3973 DEBUG_HEXDUMPC(buf3, a, 16); | 3974 DEBUG_HEXDUMPC(buf3, a, 16); |
3974 memcpy(&block_hdr, buf3, sizeof(block_hdr)); | 3975 memcpy(&block_hdr, buf3, sizeof(block_hdr)); |
3975 LE16_CPU(block_hdr.index_offset); | 3976 LE16_CPU(block_hdr.index_offset); |
3976 LE16_CPU(block_hdr.type); | 3977 LE16_CPU(block_hdr.type); |
3977 LE32_CPU(block_hdr.offset); | 3978 LE32_CPU(block_hdr.offset); |
3978 DEBUG_EMAIL(("block header (index_offset=%#hx, type=%#hx, offset=%#x)\n", block_hdr.index_offset, block_hdr.type, block_hdr.offset)); | 3979 DEBUG_INFO(("block header (index_offset=%#hx, type=%#hx, offset=%#x)\n", block_hdr.index_offset, block_hdr.type, block_hdr.offset)); |
3979 | 3980 |
3980 if (block_hdr.index_offset != (uint16_t)0x0101) { //type 3 | 3981 if (block_hdr.index_offset != (uint16_t)0x0101) { //type 3 |
3981 DEBUG_WARN(("WARNING: not a type 0x0101 buffer, Treating as normal buffer\n")); | 3982 DEBUG_WARN(("WARNING: not a type 0x0101 buffer, Treating as normal buffer\n")); |
3982 if (pf->encryption) (void)pst_decrypt(i_id, buf3, a, pf->encryption); | 3983 if (pf->encryption) (void)pst_decrypt(i_id, buf3, a, pf->encryption); |
3983 if (h->buf) | 3984 if (h->buf) |
4011 DEBUG_RET(); | 4012 DEBUG_RET(); |
4012 return z; | 4013 return z; |
4013 } | 4014 } |
4014 if (h->buf) { | 4015 if (h->buf) { |
4015 *(h->buf) = realloc(*(h->buf), size+z+1); | 4016 *(h->buf) = realloc(*(h->buf), size+z+1); |
4016 DEBUG_READ(("appending read data of size %i onto main buffer from pos %i\n", z, size)); | 4017 DEBUG_INFO(("appending read data of size %i onto main buffer from pos %i\n", z, size)); |
4017 memcpy(&((*(h->buf))[size]), buf2, z); | 4018 memcpy(&((*(h->buf))[size]), buf2, z); |
4018 } else if ((h->base64 == 1) && h->fp) { | 4019 } else if ((h->base64 == 1) && h->fp) { |
4019 if (base64_extra) { | 4020 if (base64_extra) { |
4020 // include any bytes left over from the last encoding | 4021 // include any bytes left over from the last encoding |
4021 buf2 = (char*)realloc(buf2, z+base64_extra); | 4022 buf2 = (char*)realloc(buf2, z+base64_extra); |
4032 } | 4033 } |
4033 | 4034 |
4034 // encode this chunk | 4035 // encode this chunk |
4035 t = pst_base64_encode_multiple(buf2, z, &line_count); | 4036 t = pst_base64_encode_multiple(buf2, z, &line_count); |
4036 if (t) { | 4037 if (t) { |
4037 DEBUG_READ(("writing %i bytes to file as base64 [%i]. Currently %i\n", z, strlen(t), size)); | 4038 DEBUG_INFO(("writing %i bytes to file as base64 [%i]. Currently %i\n", z, strlen(t), size)); |
4038 (void)pst_fwrite(t, (size_t)1, strlen(t), h->fp); | 4039 (void)pst_fwrite(t, (size_t)1, strlen(t), h->fp); |
4039 free(t); // caught by valgrind | 4040 free(t); // caught by valgrind |
4040 } | 4041 } |
4041 } else if (h->fp) { | 4042 } else if (h->fp) { |
4042 DEBUG_READ(("writing %i bytes to file. Currently %i\n", z, size)); | 4043 DEBUG_INFO(("writing %i bytes to file. Currently %i\n", z, size)); |
4043 (void)pst_fwrite(buf2, (size_t)1, z, h->fp); | 4044 (void)pst_fwrite(buf2, (size_t)1, z, h->fp); |
4044 } else { | 4045 } else { |
4045 // h-> does not specify any output | 4046 // h-> does not specify any output |
4046 } | 4047 } |
4047 size += z; | 4048 size += z; |
4093 } | 4094 } |
4094 | 4095 |
4095 | 4096 |
4096 size_t pst_fwrite(const void* ptr, size_t size, size_t nmemb, FILE *stream) { | 4097 size_t pst_fwrite(const void* ptr, size_t size, size_t nmemb, FILE *stream) { |
4097 size_t r; | 4098 size_t r; |
4098 DEBUG_ENT("pst_fwrite"); | |
4099 if (ptr) | 4099 if (ptr) |
4100 r = fwrite(ptr, size, nmemb, stream); | 4100 r = fwrite(ptr, size, nmemb, stream); |
4101 else { | 4101 else { |
4102 r = 0; | 4102 r = 0; |
4103 DEBUG_ENT("pst_fwrite"); | |
4103 DEBUG_WARN(("An attempt to write a NULL Pointer was made\n")); | 4104 DEBUG_WARN(("An attempt to write a NULL Pointer was made\n")); |
4104 } | 4105 DEBUG_RET(); |
4105 DEBUG_RET(); | 4106 } |
4106 return r; | 4107 return r; |
4107 } | 4108 } |
4108 | 4109 |
4109 | 4110 |
4110 static char* pst_wide_to_single(char *wt, size_t size) { | 4111 static char* pst_wide_to_single(char *wt, size_t size) { |