Mercurial > libpst
comparison src/libpst.c @ 51:06c0262ad689 stable-0-6-5
code cleanup
author | carl |
---|---|
date | Tue, 22 Jan 2008 14:39:02 -0800 |
parents | fb3818370dd6 |
children | 034641c26ab9 |
comparison
equal
deleted
inserted
replaced
50:fb3818370dd6 | 51:06c0262ad689 |
---|---|
360 | 360 |
361 y = 0; | 361 y = 0; |
362 x = pst_build_desc_ptr(pf, pf->index2, 0, pf->index2_back, &y, (uint64_t)0x21, UINT64_MAX); | 362 x = pst_build_desc_ptr(pf, pf->index2, 0, pf->index2_back, &y, (uint64_t)0x21, UINT64_MAX); |
363 DEBUG_INDEX(("build desc ptr returns %i\n", x)); | 363 DEBUG_INDEX(("build desc ptr returns %i\n", x)); |
364 | 364 |
365 DEBUG_CODE((void)pst_printDptr(pf);); | 365 DEBUG_CODE((void)pst_printDptr(pf, pf->d_head);); |
366 DEBUG_RET(); | 366 DEBUG_RET(); |
367 return 0; | 367 return 0; |
368 } | 368 } |
369 | 369 |
370 | 370 |
414 return 0; | 414 return 0; |
415 } | 415 } |
416 | 416 |
417 if (p->list_index) { | 417 if (p->list_index) { |
418 id2_head = pst_build_id2(pf, p->list_index, NULL); | 418 id2_head = pst_build_id2(pf, p->list_index, NULL); |
419 (void)pst_printID2ptr(id2_head); | 419 pst_printID2ptr(id2_head); |
420 } else { | 420 } else { |
421 DEBUG_WARN(("Have not been able to fetch any id2 values for item 0x61. Brace yourself!\n")); | 421 DEBUG_WARN(("Have not been able to fetch any id2 values for item 0x61. Brace yourself!\n")); |
422 } | 422 } |
423 | 423 |
424 na = pst_parse_block(pf, p->desc->id, id2_head, NULL); | 424 na = pst_parse_block(pf, p->desc->id, id2_head, NULL); |
717 DEBUG_WARN(("The end value is BEFORE the start value. This function will quit. Soz. [start:%#llx, end:%#llx]\n", start_val, end_val)); | 717 DEBUG_WARN(("The end value is BEFORE the start value. This function will quit. Soz. [start:%#llx, end:%#llx]\n", start_val, end_val)); |
718 DEBUG_RET(); | 718 DEBUG_RET(); |
719 return -1; | 719 return -1; |
720 } | 720 } |
721 DEBUG_INDEX(("Reading index block\n")); | 721 DEBUG_INDEX(("Reading index block\n")); |
722 if (pst_read_block_size(pf, offset, BLOCK_SIZE, &buf, 0, 0) < BLOCK_SIZE) { | 722 if (pst_read_block_size(pf, offset, BLOCK_SIZE, &buf) < BLOCK_SIZE) { |
723 DEBUG_WARN(("Failed to read %i bytes\n", BLOCK_SIZE)); | 723 DEBUG_WARN(("Failed to read %i bytes\n", BLOCK_SIZE)); |
724 if (buf) free(buf); | 724 if (buf) free(buf); |
725 DEBUG_RET(); | 725 DEBUG_RET(); |
726 return -1; | 726 return -1; |
727 } | 727 } |
942 DEBUG_WARN(("The end value is BEFORE the start value. This function will quit. Soz. [start:%#llx, end:%#llx]\n", start_val, end_val)); | 942 DEBUG_WARN(("The end value is BEFORE the start value. This function will quit. Soz. [start:%#llx, end:%#llx]\n", start_val, end_val)); |
943 DEBUG_RET(); | 943 DEBUG_RET(); |
944 return -1; | 944 return -1; |
945 } | 945 } |
946 DEBUG_INDEX(("Reading desc block\n")); | 946 DEBUG_INDEX(("Reading desc block\n")); |
947 if (pst_read_block_size(pf, offset, DESC_BLOCK_SIZE, &buf, 0, 0) < DESC_BLOCK_SIZE) { | 947 if (pst_read_block_size(pf, offset, DESC_BLOCK_SIZE, &buf) < DESC_BLOCK_SIZE) { |
948 DEBUG_WARN(("Failed to read %i bytes\n", DESC_BLOCK_SIZE)); | 948 DEBUG_WARN(("Failed to read %i bytes\n", DESC_BLOCK_SIZE)); |
949 if (buf) free(buf); | 949 if (buf) free(buf); |
950 DEBUG_RET(); | 950 DEBUG_RET(); |
951 return -1; | 951 return -1; |
952 } | 952 } |
1638 //contains 32 bits of data | 1638 //contains 32 bits of data |
1639 na_ptr->items[x]->size = sizeof(int32_t); | 1639 na_ptr->items[x]->size = sizeof(int32_t); |
1640 na_ptr->items[x]->type = table_rec.ref_type; | 1640 na_ptr->items[x]->type = table_rec.ref_type; |
1641 na_ptr->items[x]->data = xmalloc(sizeof(int32_t)); | 1641 na_ptr->items[x]->data = xmalloc(sizeof(int32_t)); |
1642 memcpy(na_ptr->items[x]->data, &(table_rec.value), sizeof(int32_t)); | 1642 memcpy(na_ptr->items[x]->data, &(table_rec.value), sizeof(int32_t)); |
1643 // are we missing an LE32_CPU() call here? table_rec.value is still | |
1644 // in the original order. | |
1643 | 1645 |
1644 } else if (table_rec.ref_type == (uint16_t)0x0005 || | 1646 } else if (table_rec.ref_type == (uint16_t)0x0005 || |
1645 table_rec.ref_type == (uint16_t)0x000d || | 1647 table_rec.ref_type == (uint16_t)0x000d || |
1646 table_rec.ref_type == (uint16_t)0x0014 || | 1648 table_rec.ref_type == (uint16_t)0x0014 || |
1647 table_rec.ref_type == (uint16_t)0x001e || | 1649 table_rec.ref_type == (uint16_t)0x001e || |
1738 freeall(&subblocks, &block_offset1, &block_offset2, &block_offset3, &block_offset4, &block_offset5, &block_offset6, &block_offset7); | 1740 freeall(&subblocks, &block_offset1, &block_offset2, &block_offset3, &block_offset4, &block_offset5, &block_offset6, &block_offset7); |
1739 DEBUG_RET(); | 1741 DEBUG_RET(); |
1740 return na_head; | 1742 return na_head; |
1741 } | 1743 } |
1742 | 1744 |
1745 | |
1743 // This version of free does NULL check first | 1746 // This version of free does NULL check first |
1744 #define SAFE_FREE(x) {if (x) free(x);} | 1747 #define SAFE_FREE(x) {if (x) free(x);} |
1745 | 1748 |
1746 | 1749 |
1747 // check if item->email is NULL, and init if so | 1750 // check if item->email is NULL, and init if so |
1825 break; | 1828 break; |
1826 case 0x0002: // PR_ALTERNATE_RECIPIENT_ALLOWED | 1829 case 0x0002: // PR_ALTERNATE_RECIPIENT_ALLOWED |
1827 // If set to true, the sender allows this email to be autoforwarded | 1830 // If set to true, the sender allows this email to be autoforwarded |
1828 DEBUG_EMAIL(("AutoForward allowed - ")); | 1831 DEBUG_EMAIL(("AutoForward allowed - ")); |
1829 MALLOC_EMAIL(item); | 1832 MALLOC_EMAIL(item); |
1830 if (*(int16_t*)list->items[x]->data != 0) { | 1833 if (*(int16_t*)list->items[x]->data) { |
1831 DEBUG_EMAIL(("True\n")); | 1834 DEBUG_EMAIL(("True\n")); |
1832 item->email->autoforward = 1; | 1835 item->email->autoforward = 1; |
1833 } else { | 1836 } else { |
1834 DEBUG_EMAIL(("False\n")); | 1837 DEBUG_EMAIL(("False\n")); |
1835 item->email->autoforward = -1; | 1838 item->email->autoforward = -1; |
1880 break; | 1883 break; |
1881 case 0x0023: // PR_ORIGINATOR_DELIVERY_REPORT_REQUESTED | 1884 case 0x0023: // PR_ORIGINATOR_DELIVERY_REPORT_REQUESTED |
1882 // set if the sender wants a delivery report from all recipients | 1885 // set if the sender wants a delivery report from all recipients |
1883 DEBUG_EMAIL(("Global Delivery Report - ")); | 1886 DEBUG_EMAIL(("Global Delivery Report - ")); |
1884 MALLOC_EMAIL(item); | 1887 MALLOC_EMAIL(item); |
1885 if (*(int16_t*)list->items[x]->data != 0) { | 1888 if (*(int16_t*)list->items[x]->data) { |
1886 DEBUG_EMAIL(("True\n")); | 1889 DEBUG_EMAIL(("True\n")); |
1887 item->email->delivery_report = 1; | 1890 item->email->delivery_report = 1; |
1888 } else { | 1891 } else { |
1889 DEBUG_EMAIL(("False\n")); | 1892 DEBUG_EMAIL(("False\n")); |
1890 item->email->delivery_report = 0; | 1893 item->email->delivery_report = 0; |
1900 memcpy(&(item->email->priority), list->items[x]->data, sizeof(item->email->priority)); | 1903 memcpy(&(item->email->priority), list->items[x]->data, sizeof(item->email->priority)); |
1901 LE32_CPU(item->email->priority); | 1904 LE32_CPU(item->email->priority); |
1902 t = item->email->priority; | 1905 t = item->email->priority; |
1903 DEBUG_EMAIL(("%s [%i]\n", (t<0?"NonUrgent":(t==0?"Normal":"Urgent")), t)); | 1906 DEBUG_EMAIL(("%s [%i]\n", (t<0?"NonUrgent":(t==0?"Normal":"Urgent")), t)); |
1904 break; | 1907 break; |
1905 case 0x0029:// PR_READ_RECEIPT_REQUESTED | 1908 case 0x0029: // PR_READ_RECEIPT_REQUESTED |
1906 DEBUG_EMAIL(("Read Receipt - ")); | 1909 DEBUG_EMAIL(("Read Receipt - ")); |
1907 MALLOC_EMAIL(item); | 1910 MALLOC_EMAIL(item); |
1908 if (*(int16_t*)list->items[x]->data != 0) { | 1911 if (*(int16_t*)list->items[x]->data) { |
1909 DEBUG_EMAIL(("True\n")); | 1912 DEBUG_EMAIL(("True\n")); |
1910 item->email->read_receipt = 1; | 1913 item->email->read_receipt = 1; |
1911 } else { | 1914 } else { |
1912 DEBUG_EMAIL(("False\n")); | 1915 DEBUG_EMAIL(("False\n")); |
1913 item->email->read_receipt = 0; | 1916 item->email->read_receipt = 0; |
1914 } | 1917 } |
1915 break; | 1918 break; |
1916 case 0x002B: // PR_RECIPIENT_REASSIGNMENT_PROHIBITED | 1919 case 0x002B: // PR_RECIPIENT_REASSIGNMENT_PROHIBITED |
1917 DEBUG_EMAIL(("Reassignment Prohibited (Private) - ")); | 1920 DEBUG_EMAIL(("Reassignment Prohibited (Private) - ")); |
1918 if (*(int16_t*)list->items[x]->data != 0) { | 1921 if (*(int16_t*)list->items[x]->data) { |
1919 DEBUG_EMAIL(("True\n")); | 1922 DEBUG_EMAIL(("True\n")); |
1920 item->private_member = 1; | 1923 item->private_member = 1; |
1921 } else { | 1924 } else { |
1922 DEBUG_EMAIL(("False\n")); | 1925 DEBUG_EMAIL(("False\n")); |
1923 item->private_member = 0; | 1926 item->private_member = 0; |
2041 break; | 2044 break; |
2042 case 0x0057: // PR_MESSAGE_TO_ME | 2045 case 0x0057: // PR_MESSAGE_TO_ME |
2043 // this user is listed explicitly in the TO address | 2046 // this user is listed explicitly in the TO address |
2044 DEBUG_EMAIL(("My address in TO field - ")); | 2047 DEBUG_EMAIL(("My address in TO field - ")); |
2045 MALLOC_EMAIL(item); | 2048 MALLOC_EMAIL(item); |
2046 if (*(int16_t*)list->items[x]->data != 0) { | 2049 if (*(int16_t*)list->items[x]->data) { |
2047 DEBUG_EMAIL(("True\n")); | 2050 DEBUG_EMAIL(("True\n")); |
2048 item->email->message_to_me = 1; | 2051 item->email->message_to_me = 1; |
2049 } else { | 2052 } else { |
2050 DEBUG_EMAIL(("False\n")); | 2053 DEBUG_EMAIL(("False\n")); |
2051 item->email->message_to_me = 0; | 2054 item->email->message_to_me = 0; |
2053 break; | 2056 break; |
2054 case 0x0058: // PR_MESSAGE_CC_ME | 2057 case 0x0058: // PR_MESSAGE_CC_ME |
2055 // this user is listed explicitly in the CC address | 2058 // this user is listed explicitly in the CC address |
2056 DEBUG_EMAIL(("My address in CC field - ")); | 2059 DEBUG_EMAIL(("My address in CC field - ")); |
2057 MALLOC_EMAIL(item); | 2060 MALLOC_EMAIL(item); |
2058 if (*(int16_t*)list->items[x]->data != 0) { | 2061 if (*(int16_t*)list->items[x]->data) { |
2059 DEBUG_EMAIL(("True\n")); | 2062 DEBUG_EMAIL(("True\n")); |
2060 item->email->message_cc_me = 1; | 2063 item->email->message_cc_me = 1; |
2061 } else { | 2064 } else { |
2062 DEBUG_EMAIL(("False\n")); | 2065 DEBUG_EMAIL(("False\n")); |
2063 item->email->message_cc_me = 0; | 2066 item->email->message_cc_me = 0; |
2064 } | 2067 } |
2065 break; | 2068 break; |
2066 case 0x0059: //PR_MESSAGE_RECIP_ME | 2069 case 0x0059: // PR_MESSAGE_RECIP_ME |
2067 // this user appears in TO, CC or BCC address list | 2070 // this user appears in TO, CC or BCC address list |
2068 DEBUG_EMAIL(("Message addressed to me - ")); | 2071 DEBUG_EMAIL(("Message addressed to me - ")); |
2069 MALLOC_EMAIL(item); | 2072 MALLOC_EMAIL(item); |
2070 if (*(int16_t*)list->items[x]->data != 0) { | 2073 if (*(int16_t*)list->items[x]->data) { |
2071 DEBUG_EMAIL(("True\n")); | 2074 DEBUG_EMAIL(("True\n")); |
2072 item->email->message_recip_me = 1; | 2075 item->email->message_recip_me = 1; |
2073 } else { | 2076 } else { |
2074 DEBUG_EMAIL(("False\n")); | 2077 DEBUG_EMAIL(("False\n")); |
2075 item->email->message_recip_me = 0; | 2078 item->email->message_recip_me = 0; |
2076 } | 2079 } |
2077 break; | 2080 break; |
2078 case 0x0063: // PR_RESPONSE_REQUESTED | 2081 case 0x0063: // PR_RESPONSE_REQUESTED |
2079 DEBUG_EMAIL(("Response requested - ")); | 2082 DEBUG_EMAIL(("Response requested - ")); |
2080 if (*(int16_t*)list->items[x]->data != 0) { | 2083 if (*(int16_t*)list->items[x]->data) { |
2081 DEBUG_EMAIL(("True\n")); | 2084 DEBUG_EMAIL(("True\n")); |
2082 item->response_requested = 1; | 2085 item->response_requested = 1; |
2083 } else { | 2086 } else { |
2084 DEBUG_EMAIL(("False\n")); | 2087 DEBUG_EMAIL(("False\n")); |
2085 item->response_requested = 0; | 2088 item->response_requested = 0; |
2141 DEBUG_EMAIL(("NOT PRINTED\n")); | 2144 DEBUG_EMAIL(("NOT PRINTED\n")); |
2142 break; | 2145 break; |
2143 case 0x0C17: // PR_REPLY_REQUESTED | 2146 case 0x0C17: // PR_REPLY_REQUESTED |
2144 DEBUG_EMAIL(("Reply Requested - ")); | 2147 DEBUG_EMAIL(("Reply Requested - ")); |
2145 MALLOC_EMAIL(item); | 2148 MALLOC_EMAIL(item); |
2146 if (*(int16_t*)list->items[x]->data != 0) { | 2149 if (*(int16_t*)list->items[x]->data) { |
2147 DEBUG_EMAIL(("True\n")); | 2150 DEBUG_EMAIL(("True\n")); |
2148 item->email->reply_requested = 1; | 2151 item->email->reply_requested = 1; |
2149 } else { | 2152 } else { |
2150 DEBUG_EMAIL(("False\n")); | 2153 DEBUG_EMAIL(("False\n")); |
2151 item->email->reply_requested = 0; | 2154 item->email->reply_requested = 0; |
2177 break; | 2180 break; |
2178 case 0x0E01: // PR_DELETE_AFTER_SUBMIT | 2181 case 0x0E01: // PR_DELETE_AFTER_SUBMIT |
2179 // I am not too sure how this works | 2182 // I am not too sure how this works |
2180 DEBUG_EMAIL(("Delete after submit - ")); | 2183 DEBUG_EMAIL(("Delete after submit - ")); |
2181 MALLOC_EMAIL(item); | 2184 MALLOC_EMAIL(item); |
2182 if (*(int16_t*)list->items[x]->data != 0) { | 2185 if (*(int16_t*)list->items[x]->data) { |
2183 DEBUG_EMAIL(("True\n")); | 2186 DEBUG_EMAIL(("True\n")); |
2184 item->email->delete_after_submit = 1; | 2187 item->email->delete_after_submit = 1; |
2185 } else { | 2188 } else { |
2186 DEBUG_EMAIL(("False\n")); | 2189 DEBUG_EMAIL(("False\n")); |
2187 item->email->delete_after_submit = 0; | 2190 item->email->delete_after_submit = 0; |
2241 // False means rtf version is more up-to-date than text body | 2244 // False means rtf version is more up-to-date than text body |
2242 // if this value doesn't exist, text body is more up-to-date than rtf and | 2245 // if this value doesn't exist, text body is more up-to-date than rtf and |
2243 // cannot update to the rtf | 2246 // cannot update to the rtf |
2244 DEBUG_EMAIL(("Compressed RTF in Sync - ")); | 2247 DEBUG_EMAIL(("Compressed RTF in Sync - ")); |
2245 MALLOC_EMAIL(item); | 2248 MALLOC_EMAIL(item); |
2246 if (*(int16_t*)list->items[x]->data != 0) { | 2249 if (*(int16_t*)list->items[x]->data) { |
2247 DEBUG_EMAIL(("True\n")); | 2250 DEBUG_EMAIL(("True\n")); |
2248 item->email->rtf_in_sync = 1; | 2251 item->email->rtf_in_sync = 1; |
2249 } else { | 2252 } else { |
2250 DEBUG_EMAIL(("False\n")); | 2253 DEBUG_EMAIL(("False\n")); |
2251 item->email->rtf_in_sync = 0; | 2254 item->email->rtf_in_sync = 0; |
2391 // FOLDER_VIEWS_VALID 0x20 | 2394 // FOLDER_VIEWS_VALID 0x20 |
2392 // FOLDER_COMMON_VIEWS_VALID 0x40 | 2395 // FOLDER_COMMON_VIEWS_VALID 0x40 |
2393 // FOLDER_FINDER_VALID 0x80 | 2396 // FOLDER_FINDER_VALID 0x80 |
2394 DEBUG_EMAIL(("Valid Folder Mask - ")); | 2397 DEBUG_EMAIL(("Valid Folder Mask - ")); |
2395 MALLOC_MESSAGESTORE(item); | 2398 MALLOC_MESSAGESTORE(item); |
2396 memcpy(&(item->message_store->valid_mask), list->items[x]->data, sizeof(int)); | 2399 memcpy(&(item->message_store->valid_mask), list->items[x]->data, sizeof(item->message_store->valid_mask)); |
2397 LE32_CPU(item->message_store->valid_mask); | 2400 LE32_CPU(item->message_store->valid_mask); |
2398 DEBUG_EMAIL(("%i\n", item->message_store->valid_mask)); | 2401 DEBUG_EMAIL(("%i\n", item->message_store->valid_mask)); |
2399 break; | 2402 break; |
2400 case 0x35E0: // PR_IPM_SUBTREE_ENTRYID Top of Personal Folder Record | 2403 case 0x35E0: // PR_IPM_SUBTREE_ENTRYID Top of Personal Folder Record |
2401 DEBUG_EMAIL(("Top of Personal Folder Record - ")); | 2404 DEBUG_EMAIL(("Top of Personal Folder Record - ")); |
2402 MALLOC_MESSAGESTORE(item); | 2405 MALLOC_MESSAGESTORE(item); |
2403 LIST_COPY(item->message_store->top_of_personal_folder, (pst_entryid*)); | 2406 LIST_COPY(item->message_store->top_of_personal_folder, (pst_entryid*)); |
2404 LE32_CPU(item->message_store->top_of_personal_folder->id); | 2407 LE32_CPU(item->message_store->top_of_personal_folder->id); |
2405 DEBUG_EMAIL(("[id = %#x]\n", item->message_store->top_of_personal_folder->id)); | 2408 DEBUG_EMAIL(("[id = %#x]\n", item->message_store->top_of_personal_folder->id)); |
2406 break; | 2409 break; |
2407 case 0x35E3: // PR_IPM_WASTEBASKET_ENTRYID Deleted Items Folder Record | 2410 case 0x35E2: // PR_IPM_OUTBOX_ENTRYID |
2411 DEBUG_EMAIL(("Default Outbox Folder record - ")); | |
2412 MALLOC_MESSAGESTORE(item); | |
2413 LIST_COPY(item->message_store->default_outbox_folder, (pst_entryid*)); | |
2414 LE32_CPU(item->message_store->default_outbox_folder->id); | |
2415 DEBUG_EMAIL(("[id = %#x]\n", item->message_store->default_outbox_folder->id)); | |
2416 break; | |
2417 case 0x35E3: // PR_IPM_WASTEBASKET_ENTRYID | |
2408 DEBUG_EMAIL(("Deleted Items Folder record - ")); | 2418 DEBUG_EMAIL(("Deleted Items Folder record - ")); |
2409 MALLOC_MESSAGESTORE(item); | 2419 MALLOC_MESSAGESTORE(item); |
2410 LIST_COPY(item->message_store->deleted_items_folder, (pst_entryid*)); | 2420 LIST_COPY(item->message_store->deleted_items_folder, (pst_entryid*)); |
2411 LE32_CPU(item->message_store->deleted_items_folder->id); | 2421 LE32_CPU(item->message_store->deleted_items_folder->id); |
2412 DEBUG_EMAIL(("[id = %#x]\n", item->message_store->deleted_items_folder->id)); | 2422 DEBUG_EMAIL(("[id = %#x]\n", item->message_store->deleted_items_folder->id)); |
2413 break; | 2423 break; |
2414 case 0x35E7: // PR_FINDER_ENTRYID Search Root Record | 2424 case 0x35E4: // PR_IPM_SENTMAIL_ENTRYID |
2415 DEBUG_EMAIL(("Search Root record - ")); | 2425 DEBUG_EMAIL(("Sent Items Folder record - ")); |
2426 MALLOC_MESSAGESTORE(item); | |
2427 LIST_COPY(item->message_store->sent_items_folder, (pst_entryid*)); | |
2428 LE32_CPU(item->message_store->sent_items_folder->id); | |
2429 DEBUG_EMAIL(("[id = %#x]\n", item->message_store->sent_items_folder->id)); | |
2430 break; | |
2431 case 0x35E5: // PR_VIEWS_ENTRYID | |
2432 DEBUG_EMAIL(("User Views Folder record - ")); | |
2433 MALLOC_MESSAGESTORE(item); | |
2434 LIST_COPY(item->message_store->user_views_folder, (pst_entryid*)); | |
2435 LE32_CPU(item->message_store->user_views_folder->id); | |
2436 DEBUG_EMAIL(("[id = %#x]\n", item->message_store->user_views_folder->id)); | |
2437 break; | |
2438 case 0x35E6: // PR_COMMON_VIEWS_ENTRYID | |
2439 DEBUG_EMAIL(("Common View Folder record - ")); | |
2440 MALLOC_MESSAGESTORE(item); | |
2441 LIST_COPY(item->message_store->common_view_folder, (pst_entryid*)); | |
2442 LE32_CPU(item->message_store->common_view_folder->id); | |
2443 DEBUG_EMAIL(("[id = %#x]\n", item->message_store->common_view_folder->id)); | |
2444 break; | |
2445 case 0x35E7: // PR_FINDER_ENTRYID | |
2446 DEBUG_EMAIL(("Search Root Folder record - ")); | |
2416 MALLOC_MESSAGESTORE(item); | 2447 MALLOC_MESSAGESTORE(item); |
2417 LIST_COPY(item->message_store->search_root_folder, (pst_entryid*)); | 2448 LIST_COPY(item->message_store->search_root_folder, (pst_entryid*)); |
2418 LE32_CPU(item->message_store->search_root_folder->id); | 2449 LE32_CPU(item->message_store->search_root_folder->id); |
2419 DEBUG_EMAIL(("[id = %#x]\n", item->message_store->search_root_folder->id)); | 2450 DEBUG_EMAIL(("[id = %#x]\n", item->message_store->search_root_folder->id)); |
2420 break; | 2451 break; |
2433 DEBUG_EMAIL(("%i\n", item->folder->unseen_email_count)); | 2464 DEBUG_EMAIL(("%i\n", item->folder->unseen_email_count)); |
2434 break; | 2465 break; |
2435 case 0x360A: // PR_SUBFOLDERS Has children | 2466 case 0x360A: // PR_SUBFOLDERS Has children |
2436 DEBUG_EMAIL(("Has Subfolders - ")); | 2467 DEBUG_EMAIL(("Has Subfolders - ")); |
2437 MALLOC_FOLDER(item); | 2468 MALLOC_FOLDER(item); |
2438 if (*(int32_t*)list->items[x]->data != 0) { | 2469 if (*(int16_t*)list->items[x]->data) { |
2439 DEBUG_EMAIL(("True\n")); | 2470 DEBUG_EMAIL(("True\n")); |
2440 item->folder->subfolder = 1; | 2471 item->folder->subfolder = 1; |
2441 } else { | 2472 } else { |
2442 DEBUG_EMAIL(("False\n")); | 2473 DEBUG_EMAIL(("False\n")); |
2443 item->folder->subfolder = 0; | 2474 item->folder->subfolder = 0; |
2562 DEBUG_EMAIL(("%s\n", item->contact->callback_phone)); | 2593 DEBUG_EMAIL(("%s\n", item->contact->callback_phone)); |
2563 break; | 2594 break; |
2564 case 0x3A03: // PR_CONVERSION_PROHIBITED | 2595 case 0x3A03: // PR_CONVERSION_PROHIBITED |
2565 DEBUG_EMAIL(("Message Conversion Prohibited - ")); | 2596 DEBUG_EMAIL(("Message Conversion Prohibited - ")); |
2566 MALLOC_EMAIL(item); | 2597 MALLOC_EMAIL(item); |
2567 if (*(int16_t*)list->items[x]->data != 0) { | 2598 if (*(int16_t*)list->items[x]->data) { |
2568 DEBUG_EMAIL(("True\n")); | 2599 DEBUG_EMAIL(("True\n")); |
2569 item->email->conversion_prohib = 1; | 2600 item->email->conversion_prohib = 1; |
2570 } else { | 2601 } else { |
2571 DEBUG_EMAIL(("False\n")); | 2602 DEBUG_EMAIL(("False\n")); |
2572 item->email->conversion_prohib = 0; | 2603 item->email->conversion_prohib = 0; |
2627 DEBUG_EMAIL(("%s\n", item->contact->location)); | 2658 DEBUG_EMAIL(("%s\n", item->contact->location)); |
2628 break; | 2659 break; |
2629 case 0x3A0E: // PR_MAIL_PERMISSION - Can the recipient receive and send email | 2660 case 0x3A0E: // PR_MAIL_PERMISSION - Can the recipient receive and send email |
2630 DEBUG_EMAIL(("Mail Permission - ")); | 2661 DEBUG_EMAIL(("Mail Permission - ")); |
2631 MALLOC_CONTACT(item); | 2662 MALLOC_CONTACT(item); |
2632 if (*(int16_t*)list->items[x]->data != 0) { | 2663 if (*(int16_t*)list->items[x]->data) { |
2633 DEBUG_EMAIL(("True\n")); | 2664 DEBUG_EMAIL(("True\n")); |
2634 item->contact->mail_permission = 1; | 2665 item->contact->mail_permission = 1; |
2635 } else { | 2666 } else { |
2636 DEBUG_EMAIL(("False\n")); | 2667 DEBUG_EMAIL(("False\n")); |
2637 item->contact->mail_permission = 0; | 2668 item->contact->mail_permission = 0; |
2830 DEBUG_EMAIL(("%s\n", item->contact->assistant_name)); | 2861 DEBUG_EMAIL(("%s\n", item->contact->assistant_name)); |
2831 break; | 2862 break; |
2832 case 0x3A40: // PR_SEND_RICH_INFO | 2863 case 0x3A40: // PR_SEND_RICH_INFO |
2833 DEBUG_EMAIL(("Can receive Rich Text - ")); | 2864 DEBUG_EMAIL(("Can receive Rich Text - ")); |
2834 MALLOC_CONTACT(item); | 2865 MALLOC_CONTACT(item); |
2835 if (*(int16_t*)list->items[x]->data != 0) { | 2866 if (*(int16_t*)list->items[x]->data) { |
2836 DEBUG_EMAIL(("True\n")); | 2867 DEBUG_EMAIL(("True\n")); |
2837 item->contact->rich_text = 1; | 2868 item->contact->rich_text = 1; |
2838 } else { | 2869 } else { |
2839 DEBUG_EMAIL(("False\n")); | 2870 DEBUG_EMAIL(("False\n")); |
2840 item->contact->rich_text = 0; | 2871 item->contact->rich_text = 0; |
2913 DEBUG_EMAIL(("%s\n", item->contact->ftp_site)); | 2944 DEBUG_EMAIL(("%s\n", item->contact->ftp_site)); |
2914 break; | 2945 break; |
2915 case 0x3A4D: // PR_GENDER | 2946 case 0x3A4D: // PR_GENDER |
2916 DEBUG_EMAIL(("Gender - ")); | 2947 DEBUG_EMAIL(("Gender - ")); |
2917 MALLOC_CONTACT(item); | 2948 MALLOC_CONTACT(item); |
2918 memcpy(&item->contact->gender, list->items[x]->data, sizeof(int16_t)); | 2949 memcpy(&item->contact->gender, list->items[x]->data, sizeof(item->contact->gender)); |
2919 LE16_CPU(item->contact->gender); | 2950 LE16_CPU(item->contact->gender); |
2920 switch(item->contact->gender) { | 2951 switch(item->contact->gender) { |
2921 case 0: | 2952 case 0: |
2922 DEBUG_EMAIL(("Unspecified\n")); | 2953 DEBUG_EMAIL(("Unspecified\n")); |
2923 break; | 2954 break; |
3058 } | 3089 } |
3059 break; | 3090 break; |
3060 case 0x67FF: // Extra Property Identifier (Password CheckSum) | 3091 case 0x67FF: // Extra Property Identifier (Password CheckSum) |
3061 DEBUG_EMAIL(("Password checksum [0x67FF] - ")); | 3092 DEBUG_EMAIL(("Password checksum [0x67FF] - ")); |
3062 MALLOC_MESSAGESTORE(item); | 3093 MALLOC_MESSAGESTORE(item); |
3063 memcpy(&(item->message_store->pwd_chksum), list->items[x]->data, | 3094 memcpy(&(item->message_store->pwd_chksum), list->items[x]->data, sizeof(item->message_store->pwd_chksum)); |
3064 sizeof(item->message_store->pwd_chksum)); | |
3065 DEBUG_EMAIL(("%#x\n", item->message_store->pwd_chksum)); | 3095 DEBUG_EMAIL(("%#x\n", item->message_store->pwd_chksum)); |
3066 break; | 3096 break; |
3067 case 0x6F02: // Secure HTML Body | 3097 case 0x6F02: // Secure HTML Body |
3068 DEBUG_EMAIL(("Secure HTML Body - ")); | 3098 DEBUG_EMAIL(("Secure HTML Body - ")); |
3069 MALLOC_EMAIL(item); | 3099 MALLOC_EMAIL(item); |
3108 case 0x801C: // Full Other Address | 3138 case 0x801C: // Full Other Address |
3109 DEBUG_EMAIL(("Other Address - ")); | 3139 DEBUG_EMAIL(("Other Address - ")); |
3110 MALLOC_CONTACT(item); | 3140 MALLOC_CONTACT(item); |
3111 LIST_COPY(item->contact->other_address, (char*)); | 3141 LIST_COPY(item->contact->other_address, (char*)); |
3112 DEBUG_EMAIL(("%s\n", item->contact->other_address)); | 3142 DEBUG_EMAIL(("%s\n", item->contact->other_address)); |
3143 break; | |
3144 case 0x8045: // Work address street | |
3145 DEBUG_EMAIL(("Work address street - ")); | |
3146 MALLOC_CONTACT(item); | |
3147 LIST_COPY(item->contact->work_address_street, (char*)); | |
3148 DEBUG_EMAIL(("%s\n", item->contact->work_address_street)); | |
3149 break; | |
3150 case 0x8046: // Work address city | |
3151 DEBUG_EMAIL(("Work address city - ")); | |
3152 MALLOC_CONTACT(item); | |
3153 LIST_COPY(item->contact->work_address_city, (char*)); | |
3154 DEBUG_EMAIL(("%s\n", item->contact->work_address_city)); | |
3155 break; | |
3156 case 0x8047: // Work address state | |
3157 DEBUG_EMAIL(("Work address state - ")); | |
3158 MALLOC_CONTACT(item); | |
3159 LIST_COPY(item->contact->work_address_state, (char*)); | |
3160 DEBUG_EMAIL(("%s\n", item->contact->work_address_state)); | |
3161 break; | |
3162 case 0x8048: // Work address postalcode | |
3163 DEBUG_EMAIL(("Work address postalcode - ")); | |
3164 MALLOC_CONTACT(item); | |
3165 LIST_COPY(item->contact->work_address_postalcode, (char*)); | |
3166 DEBUG_EMAIL(("%s\n", item->contact->work_address_postalcode)); | |
3167 break; | |
3168 case 0x8049: // Work address country | |
3169 DEBUG_EMAIL(("Work address country - ")); | |
3170 MALLOC_CONTACT(item); | |
3171 LIST_COPY(item->contact->work_address_country, (char*)); | |
3172 DEBUG_EMAIL(("%s\n", item->contact->work_address_country)); | |
3173 break; | |
3174 case 0x804A: // Work address postofficebox | |
3175 DEBUG_EMAIL(("Work address postofficebox - ")); | |
3176 MALLOC_CONTACT(item); | |
3177 LIST_COPY(item->contact->work_address_postofficebox, (char*)); | |
3178 DEBUG_EMAIL(("%s\n", item->contact->work_address_postofficebox)); | |
3113 break; | 3179 break; |
3114 case 0x8082: // Email Address 1 Transport | 3180 case 0x8082: // Email Address 1 Transport |
3115 DEBUG_EMAIL(("Email Address 1 Transport - ")); | 3181 DEBUG_EMAIL(("Email Address 1 Transport - ")); |
3116 MALLOC_CONTACT(item); | 3182 MALLOC_CONTACT(item); |
3117 LIST_COPY(item->contact->address1_transport, (char*)); | 3183 LIST_COPY(item->contact->address1_transport, (char*)); |
3260 } | 3326 } |
3261 break; | 3327 break; |
3262 case 0x8215: // All day appointment flag | 3328 case 0x8215: // All day appointment flag |
3263 DEBUG_EMAIL(("All day flag - ")); | 3329 DEBUG_EMAIL(("All day flag - ")); |
3264 MALLOC_APPOINTMENT(item); | 3330 MALLOC_APPOINTMENT(item); |
3265 if (*(int16_t*)list->items[x]->data != 0) { | 3331 if (*(int16_t*)list->items[x]->data) { |
3266 DEBUG_EMAIL(("True\n")); | 3332 DEBUG_EMAIL(("True\n")); |
3267 item->appointment->all_day = 1; | 3333 item->appointment->all_day = 1; |
3268 } else { | 3334 } else { |
3269 DEBUG_EMAIL(("False\n")); | 3335 DEBUG_EMAIL(("False\n")); |
3270 item->appointment->all_day = 0; | 3336 item->appointment->all_day = 0; |
3324 DEBUG_EMAIL(("%i\n", item->appointment->alarm_minutes)); | 3390 DEBUG_EMAIL(("%i\n", item->appointment->alarm_minutes)); |
3325 break; | 3391 break; |
3326 case 0x8503: // Reminder alarm | 3392 case 0x8503: // Reminder alarm |
3327 DEBUG_EMAIL(("Reminder alarm - ")); | 3393 DEBUG_EMAIL(("Reminder alarm - ")); |
3328 MALLOC_APPOINTMENT(item); | 3394 MALLOC_APPOINTMENT(item); |
3329 if (*(int16_t*)list->items[x]->data != 0) { | 3395 if (*(int16_t*)list->items[x]->data) { |
3330 DEBUG_EMAIL(("True\n")); | 3396 DEBUG_EMAIL(("True\n")); |
3331 item->appointment->alarm = 1; | 3397 item->appointment->alarm = 1; |
3332 } else { | 3398 } else { |
3333 DEBUG_EMAIL(("False\n")); | 3399 DEBUG_EMAIL(("False\n")); |
3334 item->appointment->alarm = 0; | 3400 item->appointment->alarm = 0; |
3335 } | 3401 } |
3336 break; | 3402 break; |
3337 case 0x8516: | 3403 case 0x8516: // Common start |
3338 DEBUG_EMAIL(("Appointment Start Date 3 - ")); | 3404 DEBUG_EMAIL(("Common Start Date - ")); |
3339 DEBUG_EMAIL(("%s\n", fileTimeToAscii((FILETIME*)list->items[x]->data))); | 3405 DEBUG_EMAIL(("%s\n", fileTimeToAscii((FILETIME*)list->items[x]->data))); |
3340 break; | 3406 break; |
3341 case 0x8517: | 3407 case 0x8517: // Common end |
3342 DEBUG_EMAIL(("Appointment End Date 3 - ")); | 3408 DEBUG_EMAIL(("Common End Date - ")); |
3343 DEBUG_EMAIL(("%s\n", fileTimeToAscii((FILETIME*)list->items[x]->data))); | 3409 DEBUG_EMAIL(("%s\n", fileTimeToAscii((FILETIME*)list->items[x]->data))); |
3344 break; | 3410 break; |
3345 case 0x851f: // Play reminder sound filename | 3411 case 0x851f: // Play reminder sound filename |
3346 DEBUG_EMAIL(("Appointment reminder sound filename - ")); | 3412 DEBUG_EMAIL(("Appointment reminder sound filename - ")); |
3347 MALLOC_APPOINTMENT(item); | 3413 MALLOC_APPOINTMENT(item); |
3400 MALLOC_JOURNAL(item); | 3466 MALLOC_JOURNAL(item); |
3401 LIST_COPY(item->journal->type, (char*)); | 3467 LIST_COPY(item->journal->type, (char*)); |
3402 DEBUG_EMAIL(("%s\n", item->journal->type)); | 3468 DEBUG_EMAIL(("%s\n", item->journal->type)); |
3403 break; | 3469 break; |
3404 default: | 3470 default: |
3405 DEBUG_EMAIL(("unknown type %#x\n", list->items[x]->id)); | 3471 if (list->items[x]->type == (uint32_t)0x0002) { |
3406 /* Reference Types | 3472 DEBUG_EMAIL(("Unknown type %#x 16bit int = %hi\n", list->items[x]->id, |
3407 | 3473 *(int16_t*)list->items[x]->data)); |
3408 2 - 0x0002 - Signed 16bit value | 3474 |
3409 3 - 0x0003 - Signed 32bit value | 3475 } else if (list->items[x]->type == (uint32_t)0x0003) { |
3410 11 - 0x000B - Boolean (non-zero = true) | 3476 DEBUG_EMAIL(("Unknown type %#x 32bit int = %i\n", list->items[x]->id, |
3411 13 - 0x000D - Embedded Object | 3477 *(int32_t*)list->items[x]->data)); |
3412 30 - 0x001E - Null terminated String | 3478 |
3413 31 - 0x001F - Unicode string | 3479 } else if (list->items[x]->type == (uint32_t)0x0004) { |
3414 64 - 0x0040 - Systime - Filetime structure | 3480 DEBUG_EMAIL(("Unknown type %#x 4-byte floating [size = %#x]\n", list->items[x]->id, |
3415 72 - 0x0048 - OLE Guid | 3481 list->items[x]->size)); |
3416 258 - 0x0102 - Binary data | |
3417 | |
3418 - 0x1003 - Array of 32bit values | |
3419 - 0x101E - Array of Strings | |
3420 - 0x1102 - Array of Binary data | |
3421 */ | |
3422 // DEBUG_EMAIL(("Unknown id [%#x, size=%#x]\n", list->items[x]->id, list->items[x]->size)); | |
3423 if (list->items[x]->type == (uint32_t)0x02) { | |
3424 DEBUG_EMAIL(("Unknown 16bit int = %hi\n", *(int16_t*)list->items[x]->data)); | |
3425 } else if (list->items[x]->type == (uint32_t)0x03) { | |
3426 DEBUG_EMAIL(("Unknown 32bit int = %i\n", *(int32_t*)list->items[x]->data)); | |
3427 } else if (list->items[x]->type == (uint32_t)0x0b) { | |
3428 DEBUG_EMAIL(("Unknown 16bit boolean = %s [%hi]\n", | |
3429 (*((int16_t*)list->items[x]->data)!=0?"True":"False"), | |
3430 *((int16_t*)list->items[x]->data))); | |
3431 } else if (list->items[x]->type == (uint32_t)0x1e) { | |
3432 DEBUG_EMAIL(("Unknown String Data = \"%s\" [%#x]\n", | |
3433 list->items[x]->data, list->items[x]->type)); | |
3434 } else if (list->items[x]->type == (uint32_t)0x40) { | |
3435 DEBUG_EMAIL(("Unknown Date = \"%s\" [%#x]\n", | |
3436 fileTimeToAscii((FILETIME*)list->items[x]->data), | |
3437 list->items[x]->type)); | |
3438 } else if (list->items[x]->type == (uint32_t)0x102) { | |
3439 DEBUG_EMAIL(("Unknown Binary Data [size = %#x]\n", | |
3440 list->items[x]->size)); | |
3441 DEBUG_HEXDUMP(list->items[x]->data, list->items[x]->size); | 3482 DEBUG_HEXDUMP(list->items[x]->data, list->items[x]->size); |
3483 | |
3484 } else if (list->items[x]->type == (uint32_t)0x0005) { | |
3485 DEBUG_EMAIL(("Unknown type %#x double floating [size = %#x]\n", list->items[x]->id, | |
3486 list->items[x]->size)); | |
3487 DEBUG_HEXDUMP(list->items[x]->data, list->items[x]->size); | |
3488 | |
3489 } else if (list->items[x]->type == (uint32_t)0x0006) { | |
3490 DEBUG_EMAIL(("Unknown type %#x signed 64bit int = %lli\n", list->items[x]->id, | |
3491 *(int64_t*)list->items[x]->data)); | |
3492 DEBUG_HEXDUMP(list->items[x]->data, list->items[x]->size); | |
3493 | |
3494 } else if (list->items[x]->type == (uint32_t)0x0007) { | |
3495 DEBUG_EMAIL(("Unknown type %#x application time [size = %#x]\n", list->items[x]->id, | |
3496 list->items[x]->size)); | |
3497 DEBUG_HEXDUMP(list->items[x]->data, list->items[x]->size); | |
3498 | |
3499 } else if (list->items[x]->type == (uint32_t)0x000a) { | |
3500 DEBUG_EMAIL(("Unknown type %#x 32bit error value = %i\n", list->items[x]->id, | |
3501 *(int32_t*)list->items[x]->data)); | |
3502 | |
3503 } else if (list->items[x]->type == (uint32_t)0x000b) { | |
3504 DEBUG_EMAIL(("Unknown type %#x 16bit boolean = %s [%hi]\n", list->items[x]->id, | |
3505 (*((int16_t*)list->items[x]->data)!=0?"True":"False"), | |
3506 *((int16_t*)list->items[x]->data))); | |
3507 | |
3508 } else if (list->items[x]->type == (uint32_t)0x000d) { | |
3509 DEBUG_EMAIL(("Unknown type %#x Embedded object [size = %#x]\n", list->items[x]->id, | |
3510 list->items[x]->size)); | |
3511 DEBUG_HEXDUMP(list->items[x]->data, list->items[x]->size); | |
3512 | |
3513 } else if (list->items[x]->type == (uint32_t)0x0014) { | |
3514 DEBUG_EMAIL(("Unknown type %#x signed 64bit int = %lli\n", list->items[x]->id, | |
3515 *(int64_t*)list->items[x]->data)); | |
3516 DEBUG_HEXDUMP(list->items[x]->data, list->items[x]->size); | |
3517 | |
3518 } else if (list->items[x]->type == (uint32_t)0x001e) { | |
3519 DEBUG_EMAIL(("Unknown type %#x String Data = \"%s\"\n", list->items[x]->id, | |
3520 list->items[x]->data)); | |
3521 | |
3522 } else if (list->items[x]->type == (uint32_t)0x001f) { | |
3523 DEBUG_EMAIL(("Unknown type %#x Unicode String Data [size = %#x]\n", list->items[x]->id, | |
3524 list->items[x]->size)); | |
3525 DEBUG_HEXDUMP(list->items[x]->data, list->items[x]->size); | |
3526 | |
3527 } else if (list->items[x]->type == (uint32_t)0x0040) { | |
3528 DEBUG_EMAIL(("Unknown type %#x Date = \"%s\"\n", list->items[x]->id, | |
3529 fileTimeToAscii((FILETIME*)list->items[x]->data))); | |
3530 | |
3531 } else if (list->items[x]->type == (uint32_t)0x0048) { | |
3532 DEBUG_EMAIL(("Unknown type %#x OLE GUID [size = %#x]\n", list->items[x]->id, | |
3533 list->items[x]->size)); | |
3534 DEBUG_HEXDUMP(list->items[x]->data, list->items[x]->size); | |
3535 | |
3536 } else if (list->items[x]->type == (uint32_t)0x0102) { | |
3537 DEBUG_EMAIL(("Unknown type %#x Binary Data [size = %#x]\n", list->items[x]->id, | |
3538 list->items[x]->size)); | |
3539 DEBUG_HEXDUMP(list->items[x]->data, list->items[x]->size); | |
3540 | |
3541 } else if (list->items[x]->type == (uint32_t)0x1003) { | |
3542 DEBUG_EMAIL(("Unknown type %#x Array of 32 bit values [size = %#x]\n", list->items[x]->id, | |
3543 list->items[x]->size)); | |
3544 DEBUG_HEXDUMP(list->items[x]->data, list->items[x]->size); | |
3545 | |
3546 } else if (list->items[x]->type == (uint32_t)0x1014) { | |
3547 DEBUG_EMAIL(("Unknown type %#x Array of 64 bit values [siize = %#x]\n", list->items[x]->id, | |
3548 list->items[x]->size)); | |
3549 DEBUG_HEXDUMP(list->items[x]->data, list->items[x]->size); | |
3550 | |
3442 } else if (list->items[x]->type == (uint32_t)0x101E) { | 3551 } else if (list->items[x]->type == (uint32_t)0x101E) { |
3443 DEBUG_EMAIL(("Unknown Array of Strings [%#x]\n", | 3552 DEBUG_EMAIL(("Unknown type %#x Array of Strings [size = %#x]\n", list->items[x]->id, |
3444 list->items[x]->type)); | 3553 list->items[x]->size)); |
3554 DEBUG_HEXDUMP(list->items[x]->data, list->items[x]->size); | |
3555 | |
3556 } else if (list->items[x]->type == (uint32_t)0x1102) { | |
3557 DEBUG_EMAIL(("Unknown type %#x Array of binary data blobs [size = %#x]\n", list->items[x]->id, | |
3558 list->items[x]->size)); | |
3559 DEBUG_HEXDUMP(list->items[x]->data, list->items[x]->size); | |
3560 | |
3445 } else { | 3561 } else { |
3446 DEBUG_EMAIL(("Unknown Not Printable [%#x]\n", | 3562 DEBUG_EMAIL(("Unknown type %#x Not Printable [%#x]\n", list->items[x]->id, |
3447 list->items[x]->type)); | 3563 list->items[x]->type)); |
3564 DEBUG_HEXDUMP(list->items[x]->data, list->items[x]->size); | |
3448 } | 3565 } |
3566 | |
3449 if (list->items[x]->data) { | 3567 if (list->items[x]->data) { |
3450 free(list->items[x]->data); | 3568 free(list->items[x]->data); |
3451 list->items[x]->data = NULL; | 3569 list->items[x]->data = NULL; |
3452 } | 3570 } |
3453 } | 3571 } |
3558 | 3676 |
3559 if (head_ptr) { | 3677 if (head_ptr) { |
3560 head = head_ptr; | 3678 head = head_ptr; |
3561 while (head_ptr) head_ptr = (tail = head_ptr)->next; | 3679 while (head_ptr) head_ptr = (tail = head_ptr)->next; |
3562 } | 3680 } |
3563 if (pst_read_block_size(pf, list->offset, list->size, &buf, PST_NO_ENC, 0) < list->size) { | 3681 if (pst_read_block_size(pf, list->offset, list->size, &buf) < list->size) { |
3564 //an error occured in block read | 3682 //an error occured in block read |
3565 WARN(("block read error occured. offset = %#llx, size = %#llx\n", list->offset, list->size)); | 3683 WARN(("block read error occured. offset = %#llx, size = %#llx\n", list->offset, list->size)); |
3566 if (buf) free(buf); | 3684 if (buf) free(buf); |
3567 DEBUG_RET(); | 3685 DEBUG_RET(); |
3568 return NULL; | 3686 return NULL; |
3676 } | 3794 } |
3677 if (item->folder) { | 3795 if (item->folder) { |
3678 free(item->folder); | 3796 free(item->folder); |
3679 } | 3797 } |
3680 if (item->message_store) { | 3798 if (item->message_store) { |
3799 SAFE_FREE(item->message_store->top_of_personal_folder); | |
3800 SAFE_FREE(item->message_store->default_outbox_folder); | |
3681 SAFE_FREE(item->message_store->deleted_items_folder); | 3801 SAFE_FREE(item->message_store->deleted_items_folder); |
3802 SAFE_FREE(item->message_store->sent_items_folder); | |
3803 SAFE_FREE(item->message_store->user_views_folder); | |
3804 SAFE_FREE(item->message_store->common_view_folder); | |
3682 SAFE_FREE(item->message_store->search_root_folder); | 3805 SAFE_FREE(item->message_store->search_root_folder); |
3683 SAFE_FREE(item->message_store->top_of_personal_folder); | |
3684 SAFE_FREE(item->message_store->top_of_folder); | 3806 SAFE_FREE(item->message_store->top_of_folder); |
3685 free(item->message_store); | 3807 free(item->message_store); |
3686 } | 3808 } |
3687 if (item->contact) { | 3809 if (item->contact) { |
3688 SAFE_FREE(item->contact->access_method); | 3810 SAFE_FREE(item->contact->access_method); |
3773 SAFE_FREE(item->contact->surname); | 3895 SAFE_FREE(item->contact->surname); |
3774 SAFE_FREE(item->contact->telex); | 3896 SAFE_FREE(item->contact->telex); |
3775 SAFE_FREE(item->contact->transmittable_display_name); | 3897 SAFE_FREE(item->contact->transmittable_display_name); |
3776 SAFE_FREE(item->contact->ttytdd_phone); | 3898 SAFE_FREE(item->contact->ttytdd_phone); |
3777 SAFE_FREE(item->contact->wedding_anniversary); | 3899 SAFE_FREE(item->contact->wedding_anniversary); |
3900 SAFE_FREE(item->contact->work_address_street); | |
3901 SAFE_FREE(item->contact->work_address_city); | |
3902 SAFE_FREE(item->contact->work_address_state); | |
3903 SAFE_FREE(item->contact->work_address_postalcode); | |
3904 SAFE_FREE(item->contact->work_address_country); | |
3905 SAFE_FREE(item->contact->work_address_postofficebox); | |
3778 free(item->contact); | 3906 free(item->contact); |
3779 } | 3907 } |
3780 while (item->attach) { | 3908 while (item->attach) { |
3781 SAFE_FREE(item->attach->filename1); | 3909 SAFE_FREE(item->attach->filename1); |
3782 SAFE_FREE(item->attach->filename2); | 3910 SAFE_FREE(item->attach->filename2); |
3967 DEBUG_RET(); | 4095 DEBUG_RET(); |
3968 return ptr; // will be NULL or record we are looking for | 4096 return ptr; // will be NULL or record we are looking for |
3969 } | 4097 } |
3970 | 4098 |
3971 | 4099 |
3972 int32_t pst_printDptr(pst_file *pf) { | 4100 void pst_printDptr(pst_file *pf, pst_desc_ll *ptr) { |
3973 pst_desc_ll *ptr = pf->d_head; | |
3974 int32_t depth = 0; | |
3975 char spaces[100]; | |
3976 DEBUG_ENT("pst_printDptr"); | 4101 DEBUG_ENT("pst_printDptr"); |
3977 memset(spaces, ' ', 99); | |
3978 spaces[99] = '\0'; | |
3979 while (ptr) { | 4102 while (ptr) { |
3980 DEBUG_INDEX(("%s%#x [%i] desc=%#x, list=%#x\n", &(spaces[(99-depth<0?0:99-depth)]), ptr->id, ptr->no_child, | 4103 DEBUG_INDEX(("%#x [%i] desc=%#x, list=%#x\n", ptr->id, ptr->no_child, |
3981 (ptr->desc==NULL?0:ptr->desc->id), | 4104 (ptr->desc==NULL?0:ptr->desc->id), |
3982 (ptr->list_index==NULL?0:ptr->list_index->id))); | 4105 (ptr->list_index==NULL?0:ptr->list_index->id))); |
3983 if (ptr->child) { | 4106 if (ptr->child) { |
3984 depth++; | 4107 pst_printDptr(pf, ptr->child); |
3985 ptr = ptr->child; | |
3986 continue; | |
3987 } | |
3988 while (!ptr->next && ptr->parent) { | |
3989 depth--; | |
3990 ptr = ptr->parent; | |
3991 } | 4108 } |
3992 ptr = ptr->next; | 4109 ptr = ptr->next; |
3993 } | 4110 } |
3994 DEBUG_RET(); | 4111 DEBUG_RET(); |
3995 return 0; | 4112 } |
3996 } | 4113 |
3997 | 4114 |
3998 | 4115 void pst_printIDptr(pst_file* pf) { |
3999 int32_t pst_printIDptr(pst_file* pf) { | |
4000 pst_index_ll *ptr = pf->i_head; | 4116 pst_index_ll *ptr = pf->i_head; |
4001 DEBUG_ENT("pst_printIDptr"); | 4117 DEBUG_ENT("pst_printIDptr"); |
4002 while (ptr) { | 4118 while (ptr) { |
4003 DEBUG_INDEX(("%#x offset=%#x size=%#x\n", ptr->id, ptr->offset, ptr->size)); | 4119 DEBUG_INDEX(("%#x offset=%#x size=%#x\n", ptr->id, ptr->offset, ptr->size)); |
4004 ptr = ptr->next; | 4120 ptr = ptr->next; |
4005 } | 4121 } |
4006 DEBUG_RET(); | 4122 DEBUG_RET(); |
4007 return 0; | 4123 } |
4008 } | 4124 |
4009 | 4125 |
4010 | 4126 void pst_printID2ptr(pst_index2_ll *ptr) { |
4011 int32_t pst_printID2ptr(pst_index2_ll *ptr) { | |
4012 DEBUG_ENT("pst_printID2ptr"); | 4127 DEBUG_ENT("pst_printID2ptr"); |
4013 while (ptr) { | 4128 while (ptr) { |
4014 DEBUG_INDEX(("%#x id=%#x\n", ptr->id2, (ptr->id!=NULL?ptr->id->id:0))); | 4129 DEBUG_INDEX(("%#x id=%#x\n", ptr->id2, (ptr->id!=NULL?ptr->id->id:0))); |
4015 ptr = ptr->next; | 4130 ptr = ptr->next; |
4016 } | 4131 } |
4017 DEBUG_RET(); | 4132 DEBUG_RET(); |
4018 return 0; | 4133 } |
4019 } | 4134 |
4020 | 4135 |
4021 | 4136 size_t pst_read_block_size(pst_file *pf, off_t offset, size_t size, char **buf) { |
4022 // when the first byte of the block being read is 01, then we can assume | |
4023 // that it is a list of further ids to read and we will follow those ids | |
4024 // recursively calling this function until we have all the data | |
4025 // we could do decryption of the encrypted PST files here | |
4026 size_t pst_read_block_size(pst_file *pf, off_t offset, size_t size, char **buf, int32_t do_enc, unsigned char is_index) { | |
4027 off_t fpos; | 4137 off_t fpos; |
4028 uint32_t x; | 4138 size_t rsize; |
4029 int16_t count, y; | |
4030 char *buf2 = NULL, *buf3 = NULL; | |
4031 unsigned char fdepth; | |
4032 pst_index_ll *ptr = NULL; | |
4033 size_t rsize, z; | |
4034 | 4139 |
4035 DEBUG_ENT("pst_read_block_size"); | 4140 DEBUG_ENT("pst_read_block_size"); |
4036 DEBUG_READ(("Reading block from %#x, %i bytes\n", offset, size)); | 4141 DEBUG_READ(("Reading block from %#x, %i bytes\n", offset, size)); |
4037 | 4142 |
4038 fpos = ftell(pf->fp); | 4143 fpos = ftell(pf->fp); |
4040 if (*buf) { | 4145 if (*buf) { |
4041 DEBUG_READ(("Freeing old memory\n")); | 4146 DEBUG_READ(("Freeing old memory\n")); |
4042 free(*buf); | 4147 free(*buf); |
4043 } | 4148 } |
4044 | 4149 |
4045 *buf = (void*) xmalloc(size+1); //plus one so that we can NUL terminate it later | 4150 *buf = (void*) xmalloc(size); |
4046 rsize = fread(*buf, (size_t)1, size, pf->fp); | 4151 rsize = fread(*buf, (size_t)1, size, pf->fp); |
4047 if (rsize != size) { | 4152 if (rsize != size) { |
4048 DEBUG_WARN(("Didn't read all that I could. fread returned less [%i instead of %i]\n", rsize, size)); | 4153 DEBUG_WARN(("Didn't read all that I could. fread returned less [%i instead of %i]\n", rsize, size)); |
4049 if (feof(pf->fp)) { | 4154 if (feof(pf->fp)) { |
4050 DEBUG_WARN(("We tried to read past the end of the file at [offset %#x, size %#x]\n", offset, size)); | 4155 DEBUG_WARN(("We tried to read past the end of the file at [offset %#x, size %#x]\n", offset, size)); |
4054 DEBUG_WARN(("I can't tell why it failed\n")); | 4159 DEBUG_WARN(("I can't tell why it failed\n")); |
4055 } | 4160 } |
4056 size = rsize; | 4161 size = rsize; |
4057 } | 4162 } |
4058 | 4163 |
4059 // DEBUG_HEXDUMP(*buf, size); | |
4060 | |
4061 /* if (is_index) { | |
4062 DEBUG_READ(("pst_read_block_size: ODD_BLOCK should be here\n")); | |
4063 DEBUG_READ(("\t: byte 0-1: %#x %#x\n", (*buf)[0], (*buf)[1])); | |
4064 }*/ | |
4065 | |
4066 if ((*buf)[0] == 0x01 && (*buf)[1] != 0x00 && is_index) { | |
4067 //don't do this recursion if we should be at a leaf node | |
4068 memcpy(&count, &((*buf)[2]), sizeof(int16_t)); | |
4069 LE16_CPU(count); | |
4070 memcpy(&fdepth, &((*buf)[1]), sizeof(fdepth)); | |
4071 DEBUG_READ(("Seen indexes to blocks. Depth is %i\n", fdepth)); | |
4072 // do fancy stuff! :) | |
4073 DEBUG_READ(("There are %i ids\n", count)); | |
4074 // if first 2 blocks are 01 01 then index to blocks | |
4075 size = 0; | |
4076 y = 0; | |
4077 while (y < count) { | |
4078 memcpy(&x, &(*buf)[0x08+(y*4)], sizeof(uint32_t)); | |
4079 LE32_CPU(x); | |
4080 if ((ptr = pst_getID(pf, x)) == NULL) { | |
4081 WARN(("Error. Cannot find ID [%#x] during multi-block read\n", x)); | |
4082 buf3 = (char*) realloc(buf3, size+1); | |
4083 buf3[size] = '\0'; | |
4084 *buf = buf3; | |
4085 (void)fseek(pf->fp, fpos, SEEK_SET); | |
4086 DEBUG_RET(); | |
4087 return size; | |
4088 } | |
4089 if ((z = pst_read_block_size(pf, ptr->offset, ptr->size, &buf2, do_enc, fdepth-1)) < ptr->size) { | |
4090 buf3 = (char*) realloc(buf3, size+1); | |
4091 buf3[size] = '\0'; | |
4092 *buf = buf3; | |
4093 (void)fseek(pf->fp, fpos, SEEK_SET); | |
4094 DEBUG_RET(); | |
4095 return size; | |
4096 } | |
4097 DEBUG_READ(("Melding newley retrieved block with bigger one. New size is %i\n", size+z)); | |
4098 buf3 = (char*) realloc(buf3, size+z+1); //plus one so that we can null terminate it later | |
4099 DEBUG_READ(("Doing copy. Start pos is %i, length is %i\n", size, z)); | |
4100 memcpy(&(buf3[size]), buf2, z); | |
4101 size += z; | |
4102 y++; | |
4103 } | |
4104 free(*buf); | |
4105 if (buf2) free(buf2); | |
4106 if (!buf3) { | |
4107 // this can happen if count == 0. We should create an empty buffer so we don't | |
4108 // confuse any clients | |
4109 buf3 = (char*) xmalloc((size_t)1); | |
4110 } | |
4111 *buf = buf3; | |
4112 } else if (do_enc && pf->encryption) { | |
4113 (void)pst_decrypt(*buf, size, pf->encryption); | |
4114 } else { | |
4115 // nothing to do | |
4116 } | |
4117 | |
4118 (*buf)[size] = '\0'; //should be byte after last one read | |
4119 (void)fseek(pf->fp, fpos, SEEK_SET); | 4164 (void)fseek(pf->fp, fpos, SEEK_SET); |
4120 DEBUG_RET(); | 4165 DEBUG_RET(); |
4121 return size; | 4166 return size; |
4122 } | 4167 } |
4123 | 4168 |
4188 return 1; | 4233 return 1; |
4189 } | 4234 } |
4190 if (fread(buf, (size_t)1, size, fp) < size) { | 4235 if (fread(buf, (size_t)1, size, fp) < size) { |
4191 DEBUG_RET(); | 4236 DEBUG_RET(); |
4192 return 2; | 4237 return 2; |
4193 } | |
4194 DEBUG_RET(); | |
4195 return 0; | |
4196 } | |
4197 | |
4198 | |
4199 int pst_get (FILE *fp, void *buf, size_t size) { | |
4200 DEBUG_ENT("pst_get"); | |
4201 if (fread(buf, (size_t)1, size, fp) < size) { | |
4202 DEBUG_RET(); | |
4203 return 1; | |
4204 } | 4238 } |
4205 DEBUG_RET(); | 4239 DEBUG_RET(); |
4206 return 0; | 4240 return 0; |
4207 } | 4241 } |
4208 | 4242 |
4323 return ret; | 4357 return ret; |
4324 } | 4358 } |
4325 | 4359 |
4326 | 4360 |
4327 size_t pst_ff_compile_ID(pst_file *pf, uint64_t id, pst_holder *h, size_t size) { | 4361 size_t pst_ff_compile_ID(pst_file *pf, uint64_t id, pst_holder *h, size_t size) { |
4328 size_t z, a; | 4362 size_t z, a, b; |
4329 uint16_t count, y; | 4363 uint16_t count, y; |
4330 uint32_t x, b; | |
4331 unsigned char * buf3 = NULL, *buf2 = NULL, *t; | 4364 unsigned char * buf3 = NULL, *buf2 = NULL, *t; |
4332 unsigned char fdepth; | |
4333 unsigned char *b_ptr; | 4365 unsigned char *b_ptr; |
4334 pst_block_hdr block_hdr; | 4366 pst_block_hdr block_hdr; |
4335 pst_table3_rec table3_rec; //for type 3 (0x0101) blocks | 4367 pst_table3_rec table3_rec; //for type 3 (0x0101) blocks |
4336 | 4368 |
4337 DEBUG_ENT("pst_ff_compile_ID"); | 4369 DEBUG_ENT("pst_ff_compile_ID"); |