Mercurial > libpst
comparison src/libpst.c @ 203:9fb600ef4e03
cleanup debug logging
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Tue, 19 May 2009 10:20:33 -0700 |
parents | 2f38c4ce606f |
children | 268458c79e9b |
comparison
equal
deleted
inserted
replaced
202:2f38c4ce606f | 203:9fb600ef4e03 |
---|---|
1218 return NULL; | 1218 return NULL; |
1219 } | 1219 } |
1220 | 1220 |
1221 if (d_ptr->assoc_tree) { | 1221 if (d_ptr->assoc_tree) { |
1222 if (m_head) { | 1222 if (m_head) { |
1223 DEBUG_WARN(("supplied master head, but have a list that is building a new id2_head")); | 1223 DEBUG_WARN(("supplied master head, but have a list that is building a new id2_head\n")); |
1224 m_head = NULL; | 1224 m_head = NULL; |
1225 } | 1225 } |
1226 id2_head = pst_build_id2(pf, d_ptr->assoc_tree); | 1226 id2_head = pst_build_id2(pf, d_ptr->assoc_tree); |
1227 } | 1227 } |
1228 pst_printID2ptr(id2_head); | 1228 pst_printID2ptr(id2_head); |
1393 pst_block_offset_pointer block_offset4; | 1393 pst_block_offset_pointer block_offset4; |
1394 pst_block_offset_pointer block_offset5; | 1394 pst_block_offset_pointer block_offset5; |
1395 pst_block_offset_pointer block_offset6; | 1395 pst_block_offset_pointer block_offset6; |
1396 pst_block_offset_pointer block_offset7; | 1396 pst_block_offset_pointer block_offset7; |
1397 int32_t x; | 1397 int32_t x; |
1398 int num_recs; | 1398 int32_t num_mapi_objects; |
1399 int count_rec; | 1399 int32_t count_mapi_objects; |
1400 int32_t num_list; | 1400 int32_t num_mapi_elements; |
1401 int32_t cur_list; | 1401 int32_t count_mapi_elements; |
1402 int block_type; | 1402 int block_type; |
1403 uint32_t rec_size = 0; | 1403 uint32_t rec_size = 0; |
1404 char* list_start; | 1404 char* list_start; |
1405 char* fr_ptr; | 1405 char* fr_ptr; |
1406 char* to_ptr; | 1406 char* to_ptr; |
1527 DEBUG_RET(); | 1527 DEBUG_RET(); |
1528 return NULL; | 1528 return NULL; |
1529 } | 1529 } |
1530 list_start = block_offset2.from; | 1530 list_start = block_offset2.from; |
1531 to_ptr = block_offset2.to; | 1531 to_ptr = block_offset2.to; |
1532 num_list = (to_ptr - list_start)/sizeof(table_rec); | 1532 num_mapi_elements = (to_ptr - list_start)/sizeof(table_rec); |
1533 num_recs = 1; // only going to be one object in these blocks | 1533 num_mapi_objects = 1; // only going to be one object in these blocks |
1534 } | 1534 } |
1535 else if (block_hdr.type == (uint16_t)0x7CEC) { //type 2 | 1535 else if (block_hdr.type == (uint16_t)0x7CEC) { //type 2 |
1536 block_type = 2; | 1536 block_type = 2; |
1537 | 1537 |
1538 if (pst_getBlockOffsetPointer(pf, i2_head, &subblocks, block_hdr.offset, &block_offset3)) { | 1538 if (pst_getBlockOffsetPointer(pf, i2_head, &subblocks, block_hdr.offset, &block_offset3)) { |
1561 DEBUG_RET(); | 1561 DEBUG_RET(); |
1562 return NULL; | 1562 return NULL; |
1563 } | 1563 } |
1564 | 1564 |
1565 rec_size = seven_c_blk.rec_size; | 1565 rec_size = seven_c_blk.rec_size; |
1566 num_list = (int32_t)(unsigned)seven_c_blk.item_count; | 1566 num_mapi_elements = (int32_t)(unsigned)seven_c_blk.item_count; |
1567 | 1567 |
1568 if (pst_getBlockOffsetPointer(pf, i2_head, &subblocks, seven_c_blk.b_five_offset, &block_offset4)) { | 1568 if (pst_getBlockOffsetPointer(pf, i2_head, &subblocks, seven_c_blk.b_five_offset, &block_offset4)) { |
1569 DEBUG_WARN(("internal error (7c.b5 offset %#x) in reading block id %#"PRIx64"\n", seven_c_blk.b_five_offset, block_id)); | 1569 DEBUG_WARN(("internal error (7c.b5 offset %#x) in reading block id %#"PRIx64"\n", seven_c_blk.b_five_offset, block_id)); |
1570 freeall(&subblocks, &block_offset1, &block_offset2, &block_offset3, &block_offset4, &block_offset5, &block_offset6, &block_offset7); | 1570 freeall(&subblocks, &block_offset1, &block_offset2, &block_offset3, &block_offset4, &block_offset5, &block_offset6, &block_offset7); |
1571 DEBUG_RET(); | 1571 DEBUG_RET(); |
1590 DEBUG_RET(); | 1590 DEBUG_RET(); |
1591 return NULL; | 1591 return NULL; |
1592 } | 1592 } |
1593 | 1593 |
1594 // this will give the number of records in this block | 1594 // this will give the number of records in this block |
1595 num_recs = (block_offset5.to - block_offset5.from) / (4 + table_rec.ref_type); | 1595 num_mapi_objects = (block_offset5.to - block_offset5.from) / (4 + table_rec.ref_type); |
1596 | 1596 |
1597 if (pst_getBlockOffsetPointer(pf, i2_head, &subblocks, seven_c_blk.ind2_offset, &block_offset6)) { | 1597 if (pst_getBlockOffsetPointer(pf, i2_head, &subblocks, seven_c_blk.ind2_offset, &block_offset6)) { |
1598 DEBUG_WARN(("internal error (7c.ind2 offset %#x) in reading block id %#"PRIx64"\n", seven_c_blk.ind2_offset, block_id)); | 1598 DEBUG_WARN(("internal error (7c.ind2 offset %#x) in reading block id %#"PRIx64"\n", seven_c_blk.ind2_offset, block_id)); |
1599 freeall(&subblocks, &block_offset1, &block_offset2, &block_offset3, &block_offset4, &block_offset5, &block_offset6, &block_offset7); | 1599 freeall(&subblocks, &block_offset1, &block_offset2, &block_offset3, &block_offset4, &block_offset5, &block_offset6, &block_offset7); |
1600 DEBUG_RET(); | 1600 DEBUG_RET(); |
1601 return NULL; | 1601 return NULL; |
1602 } | 1602 } |
1603 ind2_ptr = block_offset6.from; | 1603 ind2_ptr = block_offset6.from; |
1604 ind2_end = block_offset6.to; | 1604 ind2_end = block_offset6.to; |
1605 DEBUG_INFO(("7cec block index2 pointer %#x and end %#x\n", ind2_ptr, ind2_end)); | |
1605 } | 1606 } |
1606 else { | 1607 else { |
1607 DEBUG_WARN(("ERROR: Unknown block constant - %#hx for id %#"PRIx64"\n", block_hdr.type, block_id)); | 1608 DEBUG_WARN(("ERROR: Unknown block constant - %#hx for id %#"PRIx64"\n", block_hdr.type, block_id)); |
1608 freeall(&subblocks, &block_offset1, &block_offset2, &block_offset3, &block_offset4, &block_offset5, &block_offset6, &block_offset7); | 1609 freeall(&subblocks, &block_offset1, &block_offset2, &block_offset3, &block_offset4, &block_offset5, &block_offset6, &block_offset7); |
1609 DEBUG_RET(); | 1610 DEBUG_RET(); |
1610 return NULL; | 1611 return NULL; |
1611 } | 1612 } |
1612 | 1613 |
1613 DEBUG_INFO(("Mallocing number of records %i\n", num_recs)); | 1614 DEBUG_INFO(("found %i mapi objects each with %i mapi elements\n", num_mapi_objects, num_mapi_elements)); |
1614 for (count_rec=0; count_rec<num_recs; count_rec++) { | 1615 for (count_mapi_objects=0; count_mapi_objects<num_mapi_objects; count_mapi_objects++) { |
1616 // put another mapi object on the linked list | |
1615 mo_ptr = (pst_mapi_object*) pst_malloc(sizeof(pst_mapi_object)); | 1617 mo_ptr = (pst_mapi_object*) pst_malloc(sizeof(pst_mapi_object)); |
1616 memset(mo_ptr, 0, sizeof(pst_mapi_object)); | 1618 memset(mo_ptr, 0, sizeof(pst_mapi_object)); |
1617 mo_ptr->next = mo_head; | 1619 mo_ptr->next = mo_head; |
1618 mo_head = mo_ptr; | 1620 mo_head = mo_ptr; |
1619 // allocate an array of count num_recs to contain sizeof(pst_mapi_element) | 1621 // allocate the array of mapi elements |
1620 mo_ptr->elements = (pst_mapi_element**) pst_malloc(sizeof(pst_mapi_element)*num_list); | 1622 mo_ptr->elements = (pst_mapi_element**) pst_malloc(sizeof(pst_mapi_element)*num_mapi_elements); |
1621 mo_ptr->count_elements = num_list; | 1623 mo_ptr->count_elements = num_mapi_elements; |
1622 mo_ptr->orig_count = num_list; | 1624 mo_ptr->orig_count = num_mapi_elements; |
1623 mo_ptr->count_objects = (int32_t)num_recs; // each record will have a record of the total number of records | 1625 mo_ptr->count_objects = (int32_t)num_mapi_objects; // each record will have a record of the total number of records |
1624 for (x=0; x<num_list; x++) mo_ptr->elements[x] = NULL; | 1626 for (x=0; x<num_mapi_elements; x++) mo_ptr->elements[x] = NULL; |
1625 x = 0; | 1627 |
1626 | 1628 DEBUG_INFO(("going to read %i mapi elements for mapi object %i\n", num_mapi_elements, count_mapi_objects)); |
1627 DEBUG_INFO(("going to read %i (%#x) items\n", mo_ptr->count_elements, mo_ptr->count_elements)); | 1629 |
1628 | 1630 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. | 1631 x = 0; // x almost tracks count_mapi_elements, but see 'continue' statement below |
1630 for (cur_list=0; cur_list<num_list; cur_list++) { //we will increase fr_ptr as we progress through index | 1632 for (count_mapi_elements=0; count_mapi_elements<num_mapi_elements; count_mapi_elements++) { //we will increase fr_ptr as we progress through index |
1631 char* value_pointer = NULL; // needed for block type 2 with values larger than 4 bytes | 1633 char* value_pointer = NULL; // needed for block type 2 with values larger than 4 bytes |
1632 size_t value_size = 0; | 1634 size_t value_size = 0; |
1633 if (block_type == 1) { | 1635 if (block_type == 1) { |
1634 memcpy(&table_rec, fr_ptr, sizeof(table_rec)); | 1636 memcpy(&table_rec, fr_ptr, sizeof(table_rec)); |
1635 LE16_CPU(table_rec.type); | 1637 LE16_CPU(table_rec.type); |
1640 // we will copy the table2_rec values into a table_rec record so that we can keep the rest of the code | 1642 // we will copy the table2_rec values into a table_rec record so that we can keep the rest of the code |
1641 memcpy(&table2_rec, fr_ptr, sizeof(table2_rec)); | 1643 memcpy(&table2_rec, fr_ptr, sizeof(table2_rec)); |
1642 LE16_CPU(table2_rec.ref_type); | 1644 LE16_CPU(table2_rec.ref_type); |
1643 LE16_CPU(table2_rec.type); | 1645 LE16_CPU(table2_rec.type); |
1644 LE16_CPU(table2_rec.ind2_off); | 1646 LE16_CPU(table2_rec.ind2_off); |
1647 DEBUG_INFO(("reading element %i (type=%#x, ref_type=%#x, offset=%#x, size=%#x)\n", | |
1648 x, table2_rec.type, table2_rec.ref_type, table2_rec.ind2_off, table2_rec.size)); | |
1645 | 1649 |
1646 // table_rec and table2_rec are arranged differently, so assign the values across | 1650 // table_rec and table2_rec are arranged differently, so assign the values across |
1647 table_rec.type = table2_rec.type; | 1651 table_rec.type = table2_rec.type; |
1648 table_rec.ref_type = table2_rec.ref_type; | 1652 table_rec.ref_type = table2_rec.ref_type; |
1649 table_rec.value = 0; | 1653 table_rec.value = 0; |
1669 freeall(&subblocks, &block_offset1, &block_offset2, &block_offset3, &block_offset4, &block_offset5, &block_offset6, &block_offset7); | 1673 freeall(&subblocks, &block_offset1, &block_offset2, &block_offset3, &block_offset4, &block_offset5, &block_offset6, &block_offset7); |
1670 pst_free_list(mo_head); | 1674 pst_free_list(mo_head); |
1671 DEBUG_RET(); | 1675 DEBUG_RET(); |
1672 return NULL; | 1676 return NULL; |
1673 } | 1677 } |
1674 DEBUG_INFO(("reading block %i (type=%#x, ref_type=%#x, value=%#x)\n", | 1678 DEBUG_INFO(("reading element %i (type=%#x, ref_type=%#x, value=%#x)\n", |
1675 x, table_rec.type, table_rec.ref_type, table_rec.value)); | 1679 x, table_rec.type, table_rec.ref_type, table_rec.value)); |
1676 | 1680 |
1677 if (!mo_ptr->elements[x]) { | 1681 if (!mo_ptr->elements[x]) { |
1678 mo_ptr->elements[x] = (pst_mapi_element*) pst_malloc(sizeof(pst_mapi_element)); | 1682 mo_ptr->elements[x] = (pst_mapi_element*) pst_malloc(sizeof(pst_mapi_element)); |
1679 } | 1683 } |
2529 // associated content are items that are attached to this folder | 2533 // associated content are items that are attached to this folder |
2530 // but are hidden from users | 2534 // but are hidden from users |
2531 LIST_COPY_FOLDER_INT32("Associated Content count", item->folder->assoc_count); | 2535 LIST_COPY_FOLDER_INT32("Associated Content count", item->folder->assoc_count); |
2532 break; | 2536 break; |
2533 case 0x3701: // PR_ATTACH_DATA_OBJ binary data of attachment | 2537 case 0x3701: // PR_ATTACH_DATA_OBJ binary data of attachment |
2534 DEBUG_INFO(("Binary Data [Size %i] - ", list->elements[x]->size)); | 2538 DEBUG_INFO(("Binary Data [Size %i]\n", list->elements[x]->size)); |
2535 NULL_CHECK(attach); | 2539 NULL_CHECK(attach); |
2536 if (!list->elements[x]->data) { //special case | 2540 if (!list->elements[x]->data) { //special case |
2537 attach->id2_val = list->elements[x]->type; | 2541 attach->id2_val = list->elements[x]->type; |
2538 DEBUG_INFO(("Seen a Reference. The data hasn't been loaded yet. [%#"PRIx64"]\n", attach->id2_val)); | 2542 DEBUG_INFO(("Seen a Reference. The data hasn't been loaded yet. [%#"PRIx64"]\n", attach->id2_val)); |
2539 } else { | 2543 } else { |
2823 LIST_COPY_BIN(item->predecessor_change); | 2827 LIST_COPY_BIN(item->predecessor_change); |
2824 DEBUG_INFO(("Predecessor Change\n")); | 2828 DEBUG_INFO(("Predecessor Change\n")); |
2825 DEBUG_HEXDUMP(item->predecessor_change.data, item->predecessor_change.size); | 2829 DEBUG_HEXDUMP(item->predecessor_change.data, item->predecessor_change.size); |
2826 break; | 2830 break; |
2827 case 0x67F2: // ID2 value of the attachments proper record | 2831 case 0x67F2: // ID2 value of the attachments proper record |
2828 DEBUG_INFO(("Attachment ID2 value - ")); | |
2829 if (attach) { | 2832 if (attach) { |
2830 uint32_t tempid; | 2833 uint32_t tempid; |
2831 memcpy(&(tempid), list->elements[x]->data, sizeof(tempid)); | 2834 memcpy(&(tempid), list->elements[x]->data, sizeof(tempid)); |
2832 LE32_CPU(tempid); | 2835 LE32_CPU(tempid); |
2833 attach->id2_val = tempid; | 2836 attach->id2_val = tempid; |
2834 DEBUG_INFO(("%#"PRIx64"\n", attach->id2_val)); | 2837 DEBUG_INFO(("Attachment ID2 value - %#"PRIx64"\n", attach->id2_val)); |
2835 } else { | 2838 } else { |
2836 DEBUG_WARN(("NOT AN ATTACHMENT: %#x\n", list->elements[x]->mapi_id)); | 2839 DEBUG_WARN(("NOT AN ATTACHMENT: %#x\n", list->elements[x]->mapi_id)); |
2837 } | 2840 } |
2838 break; | 2841 break; |
2839 case 0x67FF: // Extra Property Identifier (Password CheckSum) | 2842 case 0x67FF: // Extra Property Identifier (Password CheckSum) |
3570 memcpy(&(p->to), &(buf[(i_offset+2)+of1+sizeof(p->from)]), sizeof(p->to)); | 3573 memcpy(&(p->to), &(buf[(i_offset+2)+of1+sizeof(p->from)]), sizeof(p->to)); |
3571 LE16_CPU(p->from); | 3574 LE16_CPU(p->from); |
3572 LE16_CPU(p->to); | 3575 LE16_CPU(p->to); |
3573 DEBUG_WARN(("get block offset finds from=%i(%#x), to=%i(%#x)\n", p->from, p->from, p->to, p->to)); | 3576 DEBUG_WARN(("get block offset finds from=%i(%#x), to=%i(%#x)\n", p->from, p->from, p->to, p->to)); |
3574 if (p->from > p->to) { | 3577 if (p->from > p->to) { |
3575 DEBUG_WARN(("get block offset from > to")); | 3578 DEBUG_WARN(("get block offset from > to\n")); |
3576 DEBUG_RET(); | 3579 DEBUG_RET(); |
3577 return 0; | 3580 return 0; |
3578 } | 3581 } |
3579 DEBUG_RET(); | 3582 DEBUG_RET(); |
3580 return 1; | 3583 return 1; |