Mercurial > libpst
comparison src/libpst.c @ 164:ab384fed78c5
Compensate for iconv conversion to utf-7 that produces strings that are not null terminated.
Don't produce empty attachment files in separate mode.
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Mon, 16 Mar 2009 18:31:39 -0700 |
parents | 03fbb0269f3c |
children | 40e9de445038 |
comparison
equal
deleted
inserted
replaced
163:03fbb0269f3c | 164:ab384fed78c5 |
---|---|
407 size_t pst_attach_to_mem(pst_file *pf, pst_item_attach *attach, char **b){ | 407 size_t pst_attach_to_mem(pst_file *pf, pst_item_attach *attach, char **b){ |
408 size_t size=0; | 408 size_t size=0; |
409 pst_index_ll *ptr; | 409 pst_index_ll *ptr; |
410 pst_holder h = {b, NULL, 0}; | 410 pst_holder h = {b, NULL, 0}; |
411 DEBUG_ENT("pst_attach_to_mem"); | 411 DEBUG_ENT("pst_attach_to_mem"); |
412 if (attach->id_val != (uint64_t)-1) { | 412 if (attach->i_id != (uint64_t)-1) { |
413 ptr = pst_getID(pf, attach->id_val); | 413 ptr = pst_getID(pf, attach->i_id); |
414 if (ptr) { | 414 if (ptr) { |
415 size = pst_ff_getID2data(pf, ptr, &h); | 415 size = pst_ff_getID2data(pf, ptr, &h); |
416 } else { | 416 } else { |
417 DEBUG_WARN(("Couldn't find ID pointer. Cannot handle attachment\n")); | 417 DEBUG_WARN(("Couldn't find ID pointer. Cannot handle attachment\n")); |
418 size = 0; | 418 size = 0; |
429 size_t pst_attach_to_file(pst_file *pf, pst_item_attach *attach, FILE* fp) { | 429 size_t pst_attach_to_file(pst_file *pf, pst_item_attach *attach, FILE* fp) { |
430 pst_index_ll *ptr; | 430 pst_index_ll *ptr; |
431 pst_holder h = {NULL, fp, 0}; | 431 pst_holder h = {NULL, fp, 0}; |
432 size_t size = 0; | 432 size_t size = 0; |
433 DEBUG_ENT("pst_attach_to_file"); | 433 DEBUG_ENT("pst_attach_to_file"); |
434 if (attach->id_val != (uint64_t)-1) { | 434 if (attach->i_id != (uint64_t)-1) { |
435 ptr = pst_getID(pf, attach->id_val); | 435 ptr = pst_getID(pf, attach->i_id); |
436 if (ptr) { | 436 if (ptr) { |
437 size = pst_ff_getID2data(pf, ptr, &h); | 437 size = pst_ff_getID2data(pf, ptr, &h); |
438 } else { | 438 } else { |
439 DEBUG_WARN(("Couldn't find ID pointer. Cannot save attachment to file\n")); | 439 DEBUG_WARN(("Couldn't find ID pointer. Cannot save attachment to file\n")); |
440 } | 440 } |
452 size_t pst_attach_to_file_base64(pst_file *pf, pst_item_attach *attach, FILE* fp) { | 452 size_t pst_attach_to_file_base64(pst_file *pf, pst_item_attach *attach, FILE* fp) { |
453 pst_index_ll *ptr; | 453 pst_index_ll *ptr; |
454 pst_holder h = {NULL, fp, 1}; | 454 pst_holder h = {NULL, fp, 1}; |
455 size_t size = 0; | 455 size_t size = 0; |
456 DEBUG_ENT("pst_attach_to_file_base64"); | 456 DEBUG_ENT("pst_attach_to_file_base64"); |
457 if (attach->id_val != (uint64_t)-1) { | 457 if (attach->i_id != (uint64_t)-1) { |
458 ptr = pst_getID(pf, attach->id_val); | 458 ptr = pst_getID(pf, attach->i_id); |
459 if (ptr) { | 459 if (ptr) { |
460 size = pst_ff_getID2data(pf, ptr, &h); | 460 size = pst_ff_getID2data(pf, ptr, &h); |
461 } else { | 461 } else { |
462 DEBUG_WARN(("Couldn't find ID pointer. Cannot save attachment to Base64\n")); | 462 DEBUG_WARN(("Couldn't find ID pointer. Cannot save attachment to Base64\n")); |
463 } | 463 } |
548 pst_printID2ptr(id2_head); | 548 pst_printID2ptr(id2_head); |
549 } else { | 549 } else { |
550 DEBUG_WARN(("Have not been able to fetch any id2 values for item 0x61. Brace yourself!\n")); | 550 DEBUG_WARN(("Have not been able to fetch any id2 values for item 0x61. Brace yourself!\n")); |
551 } | 551 } |
552 | 552 |
553 na = pst_parse_block(pf, p->desc->id, id2_head); | 553 na = pst_parse_block(pf, p->desc->i_id, id2_head); |
554 if (!na) { | 554 if (!na) { |
555 DEBUG_WARN(("Cannot process desc block for item 0x61. Not loading extended Attributes\n")); | 555 DEBUG_WARN(("Cannot process desc block for item 0x61. Not loading extended Attributes\n")); |
556 pst_free_id2(id2_head); | 556 pst_free_id2(id2_head); |
557 DEBUG_RET(); | 557 DEBUG_RET(); |
558 return 0; | 558 return 0; |
892 DEBUG_RET(); | 892 DEBUG_RET(); |
893 return -1; | 893 return -1; |
894 } | 894 } |
895 } | 895 } |
896 i_ptr = (pst_index_ll*) xmalloc(sizeof(pst_index_ll)); | 896 i_ptr = (pst_index_ll*) xmalloc(sizeof(pst_index_ll)); |
897 i_ptr->id = index.id; | 897 i_ptr->i_id = index.id; |
898 i_ptr->offset = index.offset; | 898 i_ptr->offset = index.offset; |
899 i_ptr->u1 = index.u1; | 899 i_ptr->u1 = index.u1; |
900 i_ptr->size = index.size; | 900 i_ptr->size = index.size; |
901 i_ptr->next = NULL; | 901 i_ptr->next = NULL; |
902 if (pf->i_tail) pf->i_tail->next = i_ptr; | 902 if (pf->i_tail) pf->i_tail->next = i_ptr; |
1090 } | 1090 } |
1091 id2_head = pst_build_id2(pf, d_ptr->assoc_tree); | 1091 id2_head = pst_build_id2(pf, d_ptr->assoc_tree); |
1092 } | 1092 } |
1093 pst_printID2ptr(id2_head); | 1093 pst_printID2ptr(id2_head); |
1094 | 1094 |
1095 list = pst_parse_block(pf, d_ptr->desc->id, id2_head); | 1095 list = pst_parse_block(pf, d_ptr->desc->i_id, id2_head); |
1096 if (!list) { | 1096 if (!list) { |
1097 DEBUG_WARN(("pst_parse_block() returned an error for d_ptr->desc->id [%#"PRIx64"]\n", d_ptr->desc->id)); | 1097 DEBUG_WARN(("pst_parse_block() returned an error for d_ptr->desc->i_id [%#"PRIx64"]\n", d_ptr->desc->i_id)); |
1098 if (!m_head) pst_free_id2(id2_head); | 1098 if (!m_head) pst_free_id2(id2_head); |
1099 DEBUG_RET(); | 1099 DEBUG_RET(); |
1100 return NULL; | 1100 return NULL; |
1101 } | 1101 } |
1102 | 1102 |
1114 pst_free_list(list); | 1114 pst_free_list(list); |
1115 | 1115 |
1116 if ((id2_ptr = pst_getID2(id2_head, (uint64_t)0x692))) { | 1116 if ((id2_ptr = pst_getID2(id2_head, (uint64_t)0x692))) { |
1117 // DSN/MDN reports? | 1117 // DSN/MDN reports? |
1118 DEBUG_EMAIL(("DSN/MDN processing\n")); | 1118 DEBUG_EMAIL(("DSN/MDN processing\n")); |
1119 list = pst_parse_block(pf, id2_ptr->id->id, id2_head); | 1119 list = pst_parse_block(pf, id2_ptr->id->i_id, id2_head); |
1120 if (!list) { | 1120 if (!list) { |
1121 DEBUG_WARN(("ERROR error processing main DSN/MDN record\n")); | 1121 DEBUG_WARN(("ERROR error processing main DSN/MDN record\n")); |
1122 if (!m_head) pst_free_id2(id2_head); | 1122 if (!m_head) pst_free_id2(id2_head); |
1123 DEBUG_RET(); | 1123 DEBUG_RET(); |
1124 return item; | 1124 return item; |
1140 pst_free_list(list); | 1140 pst_free_list(list); |
1141 } | 1141 } |
1142 | 1142 |
1143 if ((id2_ptr = pst_getID2(id2_head, (uint64_t)0x671))) { | 1143 if ((id2_ptr = pst_getID2(id2_head, (uint64_t)0x671))) { |
1144 DEBUG_EMAIL(("ATTACHMENT processing attachment\n")); | 1144 DEBUG_EMAIL(("ATTACHMENT processing attachment\n")); |
1145 list = pst_parse_block(pf, id2_ptr->id->id, id2_head); | 1145 list = pst_parse_block(pf, id2_ptr->id->i_id, id2_head); |
1146 if (!list) { | 1146 if (!list) { |
1147 DEBUG_WARN(("ERROR error processing main attachment record\n")); | 1147 DEBUG_WARN(("ERROR error processing main attachment record\n")); |
1148 if (!m_head) pst_free_id2(id2_head); | 1148 if (!m_head) pst_free_id2(id2_head); |
1149 DEBUG_RET(); | 1149 DEBUG_RET(); |
1150 return item; | 1150 return item; |
1170 // each attachment | 1170 // each attachment |
1171 attach = item->attach; | 1171 attach = item->attach; |
1172 while (attach) { | 1172 while (attach) { |
1173 DEBUG_WARN(("initial attachment id2 %#"PRIx64"\n", attach->id2_val)); | 1173 DEBUG_WARN(("initial attachment id2 %#"PRIx64"\n", attach->id2_val)); |
1174 if ((id2_ptr = pst_getID2(id2_head, attach->id2_val))) { | 1174 if ((id2_ptr = pst_getID2(id2_head, attach->id2_val))) { |
1175 DEBUG_WARN(("initial attachment id2 found id %#"PRIx64"\n", id2_ptr->id->id)); | 1175 DEBUG_WARN(("initial attachment id2 found id %#"PRIx64"\n", id2_ptr->id->i_id)); |
1176 // id_ptr is a record describing the attachment | 1176 // id_ptr is a record describing the attachment |
1177 // we pass NULL instead of id2_head cause we don't want it to | 1177 // we pass NULL instead of id2_head cause we don't want it to |
1178 // load all the extra stuff here. | 1178 // load all the extra stuff here. |
1179 list = pst_parse_block(pf, id2_ptr->id->id, NULL); | 1179 list = pst_parse_block(pf, id2_ptr->id->i_id, NULL); |
1180 if (!list) { | 1180 if (!list) { |
1181 DEBUG_WARN(("ERROR error processing an attachment record\n")); | 1181 DEBUG_WARN(("ERROR error processing an attachment record\n")); |
1182 attach = attach->next; | 1182 attach = attach->next; |
1183 continue; | 1183 continue; |
1184 } | 1184 } |
1192 continue; | 1192 continue; |
1193 } | 1193 } |
1194 pst_free_list(list); | 1194 pst_free_list(list); |
1195 id2_ptr = pst_getID2(id2_head, attach->id2_val); | 1195 id2_ptr = pst_getID2(id2_head, attach->id2_val); |
1196 if (id2_ptr) { | 1196 if (id2_ptr) { |
1197 DEBUG_WARN(("second pass attachment updating id2 found id %#"PRIx64"\n", id2_ptr->id->id)); | 1197 DEBUG_WARN(("second pass attachment updating id2 found i_id %#"PRIx64"\n", id2_ptr->id->i_id)); |
1198 // id2_val has been updated to the ID2 value of the datablock containing the | 1198 // id2_val has been updated to the ID2 value of the datablock containing the |
1199 // attachment data | 1199 // attachment data |
1200 attach->id_val = id2_ptr->id->id; | 1200 attach->i_id = id2_ptr->id->i_id; |
1201 attach->id2_head = deep_copy(id2_ptr->child); | 1201 attach->id2_head = deep_copy(id2_ptr->child); |
1202 } else { | 1202 } else { |
1203 DEBUG_WARN(("have not located the correct value for the attachment [%#"PRIx64"]\n", attach->id2_val)); | 1203 DEBUG_WARN(("have not located the correct value for the attachment [%#"PRIx64"]\n", attach->id2_val)); |
1204 } | 1204 } |
1205 } else { | 1205 } else { |
1660 } | 1660 } |
1661 } | 1661 } |
1662 if (table_rec.ref_type == (uint16_t)0x1f) { | 1662 if (table_rec.ref_type == (uint16_t)0x1f) { |
1663 // there is more to do for the type 0x1f unicode strings | 1663 // there is more to do for the type 0x1f unicode strings |
1664 size_t rc; | 1664 size_t rc; |
1665 static vbuf *strbuf = NULL; | 1665 static vbuf *utf16buf = NULL; |
1666 static vbuf *unibuf = NULL; | 1666 static vbuf *utf8buf = NULL; |
1667 if (!strbuf) strbuf=vballoc((size_t)1024); | 1667 if (!utf16buf) utf16buf = vballoc((size_t)1024); |
1668 if (!unibuf) unibuf=vballoc((size_t)1024); | 1668 if (!utf8buf) utf8buf = vballoc((size_t)1024); |
1669 | 1669 |
1670 // splint barfed on the following lines | 1670 // splint barfed on the following lines |
1671 //VBUF_STATIC(strbuf, 1024); | 1671 //VBUF_STATIC(utf16buf, 1024); |
1672 //VBUF_STATIC(unibuf, 1024); | 1672 //VBUF_STATIC(utf8buf, 1024); |
1673 | 1673 |
1674 //need UTF-16 zero-termination | 1674 //need UTF-16 zero-termination |
1675 vbset(strbuf, mo_ptr->elements[x]->data, mo_ptr->elements[x]->size); | 1675 vbset(utf16buf, mo_ptr->elements[x]->data, mo_ptr->elements[x]->size); |
1676 vbappend(strbuf, "\0\0", (size_t)2); | 1676 vbappend(utf16buf, "\0\0", (size_t)2); |
1677 DEBUG_INDEX(("Iconv in:\n")); | 1677 DEBUG_INDEX(("Iconv in:\n")); |
1678 DEBUG_HEXDUMPC(strbuf->b, strbuf->dlen, 0x10); | 1678 DEBUG_HEXDUMPC(utf16buf->b, utf16buf->dlen, 0x10); |
1679 rc = vb_utf16to8(unibuf, strbuf->b, strbuf->dlen); | 1679 rc = vb_utf16to8(utf8buf, utf16buf->b, utf16buf->dlen); |
1680 if (rc == (size_t)-1) { | 1680 if (rc == (size_t)-1) { |
1681 free(unibuf->b); | |
1682 DEBUG_EMAIL(("Failed to convert utf-16 to utf-8\n")); | 1681 DEBUG_EMAIL(("Failed to convert utf-16 to utf-8\n")); |
1683 } | 1682 } |
1684 else { | 1683 else { |
1685 free(mo_ptr->elements[x]->data); | 1684 free(mo_ptr->elements[x]->data); |
1686 mo_ptr->elements[x]->size = unibuf->dlen; | 1685 mo_ptr->elements[x]->size = utf8buf->dlen; |
1687 mo_ptr->elements[x]->data = xmalloc(unibuf->dlen); | 1686 mo_ptr->elements[x]->data = xmalloc(utf8buf->dlen); |
1688 memcpy(mo_ptr->elements[x]->data, unibuf->b, unibuf->dlen); | 1687 memcpy(mo_ptr->elements[x]->data, utf8buf->b, utf8buf->dlen); |
1689 } | 1688 } |
1690 DEBUG_INDEX(("Iconv out:\n")); | 1689 DEBUG_INDEX(("Iconv out:\n")); |
1691 DEBUG_HEXDUMPC(mo_ptr->elements[x]->data, mo_ptr->elements[x]->size, 0x10); | 1690 DEBUG_HEXDUMPC(mo_ptr->elements[x]->data, mo_ptr->elements[x]->size, 0x10); |
1692 } | 1691 } |
1693 if (mo_ptr->elements[x]->type == 0) mo_ptr->elements[x]->type = table_rec.ref_type; | 1692 if (mo_ptr->elements[x]->type == 0) mo_ptr->elements[x]->type = table_rec.ref_type; |
3059 DEBUG_RET(); | 3058 DEBUG_RET(); |
3060 return NULL; | 3059 return NULL; |
3061 } | 3060 } |
3062 | 3061 |
3063 DEBUG_INDEX(("ID %#"PRIx64" is likely to be a description record. Count is %i (offset %#"PRIx64")\n", | 3062 DEBUG_INDEX(("ID %#"PRIx64" is likely to be a description record. Count is %i (offset %#"PRIx64")\n", |
3064 list->id, block_head.count, list->offset)); | 3063 list->i_id, block_head.count, list->offset)); |
3065 x = 0; | 3064 x = 0; |
3066 b_ptr = buf + ((pf->do_read64) ? 0x08 : 0x04); | 3065 b_ptr = buf + ((pf->do_read64) ? 0x08 : 0x04); |
3067 while (x < block_head.count) { | 3066 while (x < block_head.count) { |
3068 b_ptr += pst_decode_assoc(pf, &id2_rec, b_ptr); | 3067 b_ptr += pst_decode_assoc(pf, &id2_rec, b_ptr); |
3069 DEBUG_INDEX(("id2 = %#x, id = %#"PRIx64", child id = %#"PRIx64"\n", id2_rec.id2, id2_rec.id, id2_rec.child_id)); | 3068 DEBUG_INDEX(("id2 = %#x, id = %#"PRIx64", child id = %#"PRIx64"\n", id2_rec.id2, id2_rec.id, id2_rec.child_id)); |
3070 if ((i_ptr = pst_getID(pf, id2_rec.id)) == NULL) { | 3069 if ((i_ptr = pst_getID(pf, id2_rec.id)) == NULL) { |
3071 DEBUG_WARN(("%#"PRIx64" - Not Found\n", id2_rec.id)); | 3070 DEBUG_WARN(("%#"PRIx64" - Not Found\n", id2_rec.id)); |
3072 } else { | 3071 } else { |
3073 DEBUG_INDEX(("%#"PRIx64" - Offset %#"PRIx64", u1 %#"PRIx64", Size %"PRIi64"(%#"PRIx64")\n", | 3072 DEBUG_INDEX(("%#"PRIx64" - Offset %#"PRIx64", u1 %#"PRIx64", Size %"PRIi64"(%#"PRIx64")\n", |
3074 i_ptr->id, i_ptr->offset, i_ptr->u1, i_ptr->size, i_ptr->size)); | 3073 i_ptr->i_id, i_ptr->offset, i_ptr->u1, i_ptr->size, i_ptr->size)); |
3075 // add it to the tree | 3074 // add it to the tree |
3076 i2_ptr = (pst_id2_ll*) xmalloc(sizeof(pst_id2_ll)); | 3075 i2_ptr = (pst_id2_ll*) xmalloc(sizeof(pst_id2_ll)); |
3077 i2_ptr->id2 = id2_rec.id2; | 3076 i2_ptr->id2 = id2_rec.id2; |
3078 i2_ptr->id = i_ptr; | 3077 i2_ptr->id = i_ptr; |
3079 i2_ptr->child = NULL; | 3078 i2_ptr->child = NULL; |
3391 DEBUG_RET(); | 3390 DEBUG_RET(); |
3392 return 1; | 3391 return 1; |
3393 } | 3392 } |
3394 | 3393 |
3395 | 3394 |
3396 pst_index_ll* pst_getID(pst_file* pf, uint64_t id) { | 3395 pst_index_ll* pst_getID(pst_file* pf, uint64_t i_id) { |
3397 pst_index_ll *ptr; | 3396 pst_index_ll *ptr; |
3398 DEBUG_ENT("pst_getID"); | 3397 DEBUG_ENT("pst_getID"); |
3399 if (id == 0) { | 3398 if (i_id == 0) { |
3400 DEBUG_RET(); | 3399 DEBUG_RET(); |
3401 return NULL; | 3400 return NULL; |
3402 } | 3401 } |
3403 | 3402 |
3404 //if (id & 1) DEBUG_INDEX(("have odd id bit %#"PRIx64"\n", id)); | 3403 //if (i_id & 1) DEBUG_INDEX(("have odd id bit %#"PRIx64"\n", i_id)); |
3405 //if (id & 2) DEBUG_INDEX(("have two id bit %#"PRIx64"\n", id)); | 3404 //if (i_id & 2) DEBUG_INDEX(("have two id bit %#"PRIx64"\n", i_id)); |
3406 id -= (id & 1); | 3405 i_id -= (i_id & 1); |
3407 | 3406 |
3408 DEBUG_INDEX(("Trying to find %#"PRIx64"\n", id)); | 3407 DEBUG_INDEX(("Trying to find %#"PRIx64"\n", i_id)); |
3409 ptr = pf->i_head; | 3408 ptr = pf->i_head; |
3410 while (ptr && (ptr->id != id)) { | 3409 while (ptr && (ptr->i_id != i_id)) { |
3411 ptr = ptr->next; | 3410 ptr = ptr->next; |
3412 } | 3411 } |
3413 if (ptr) {DEBUG_INDEX(("Found Value %#"PRIx64"\n", id)); } | 3412 if (ptr) {DEBUG_INDEX(("Found Value %#"PRIx64"\n", i_id)); } |
3414 else {DEBUG_INDEX(("ERROR: Value %#"PRIx64" not found\n", id)); } | 3413 else {DEBUG_INDEX(("ERROR: Value %#"PRIx64" not found\n", i_id)); } |
3415 DEBUG_RET(); | 3414 DEBUG_RET(); |
3416 return ptr; | 3415 return ptr; |
3417 } | 3416 } |
3418 | 3417 |
3419 | 3418 |
3431 } | 3430 } |
3432 } | 3431 } |
3433 ptr = ptr->next; | 3432 ptr = ptr->next; |
3434 } | 3433 } |
3435 if (ptr && ptr->id) { | 3434 if (ptr && ptr->id) { |
3436 DEBUG_INDEX(("Found value %#"PRIx64"\n", ptr->id->id)); | 3435 DEBUG_INDEX(("Found value %#"PRIx64"\n", ptr->id->i_id)); |
3437 DEBUG_RET(); | 3436 DEBUG_RET(); |
3438 return ptr; | 3437 return ptr; |
3439 } | 3438 } |
3440 DEBUG_INDEX(("ERROR Not Found\n")); | 3439 DEBUG_INDEX(("ERROR Not Found\n")); |
3441 DEBUG_RET(); | 3440 DEBUG_RET(); |
3472 | 3471 |
3473 void pst_printDptr(pst_file *pf, pst_desc_ll *ptr) { | 3472 void pst_printDptr(pst_file *pf, pst_desc_ll *ptr) { |
3474 DEBUG_ENT("pst_printDptr"); | 3473 DEBUG_ENT("pst_printDptr"); |
3475 while (ptr) { | 3474 while (ptr) { |
3476 DEBUG_INDEX(("%#"PRIx64" [%i] desc=%#"PRIx64", assoc tree=%#"PRIx64"\n", ptr->d_id, ptr->no_child, | 3475 DEBUG_INDEX(("%#"PRIx64" [%i] desc=%#"PRIx64", assoc tree=%#"PRIx64"\n", ptr->d_id, ptr->no_child, |
3477 (ptr->desc ? ptr->desc->id : (uint64_t)0), | 3476 (ptr->desc ? ptr->desc->i_id : (uint64_t)0), |
3478 (ptr->assoc_tree ? ptr->assoc_tree->id : (uint64_t)0))); | 3477 (ptr->assoc_tree ? ptr->assoc_tree->i_id : (uint64_t)0))); |
3479 if (ptr->child) { | 3478 if (ptr->child) { |
3480 pst_printDptr(pf, ptr->child); | 3479 pst_printDptr(pf, ptr->child); |
3481 } | 3480 } |
3482 ptr = ptr->next; | 3481 ptr = ptr->next; |
3483 } | 3482 } |
3487 | 3486 |
3488 void pst_printIDptr(pst_file* pf) { | 3487 void pst_printIDptr(pst_file* pf) { |
3489 pst_index_ll *ptr = pf->i_head; | 3488 pst_index_ll *ptr = pf->i_head; |
3490 DEBUG_ENT("pst_printIDptr"); | 3489 DEBUG_ENT("pst_printIDptr"); |
3491 while (ptr) { | 3490 while (ptr) { |
3492 DEBUG_INDEX(("%#"PRIx64" offset=%#"PRIx64" size=%#"PRIx64"\n", ptr->id, ptr->offset, ptr->size)); | 3491 DEBUG_INDEX(("%#"PRIx64" offset=%#"PRIx64" size=%#"PRIx64"\n", ptr->i_id, ptr->offset, ptr->size)); |
3493 ptr = ptr->next; | 3492 ptr = ptr->next; |
3494 } | 3493 } |
3495 DEBUG_RET(); | 3494 DEBUG_RET(); |
3496 } | 3495 } |
3497 | 3496 |
3498 | 3497 |
3499 void pst_printID2ptr(pst_id2_ll *ptr) { | 3498 void pst_printID2ptr(pst_id2_ll *ptr) { |
3500 DEBUG_ENT("pst_printID2ptr"); | 3499 DEBUG_ENT("pst_printID2ptr"); |
3501 while (ptr) { | 3500 while (ptr) { |
3502 DEBUG_INDEX(("%#"PRIx64" id=%#"PRIx64"\n", ptr->id2, (ptr->id ? ptr->id->id : (uint64_t)0))); | 3501 DEBUG_INDEX(("%#"PRIx64" id=%#"PRIx64"\n", ptr->id2, (ptr->id ? ptr->id->i_id : (uint64_t)0))); |
3503 if (ptr->child) pst_printID2ptr(ptr->child); | 3502 if (ptr->child) pst_printID2ptr(ptr->child); |
3504 ptr = ptr->next; | 3503 ptr = ptr->next; |
3505 } | 3504 } |
3506 DEBUG_RET(); | 3505 DEBUG_RET(); |
3507 } | 3506 } |
3737 | 3736 |
3738 size_t pst_ff_getID2data(pst_file *pf, pst_index_ll *ptr, pst_holder *h) { | 3737 size_t pst_ff_getID2data(pst_file *pf, pst_index_ll *ptr, pst_holder *h) { |
3739 size_t ret; | 3738 size_t ret; |
3740 char *b = NULL, *t; | 3739 char *b = NULL, *t; |
3741 DEBUG_ENT("pst_ff_getID2data"); | 3740 DEBUG_ENT("pst_ff_getID2data"); |
3742 if (!(ptr->id & 0x02)) { | 3741 if (!(ptr->i_id & 0x02)) { |
3743 ret = pst_ff_getIDblock_dec(pf, ptr->id, &b); | 3742 ret = pst_ff_getIDblock_dec(pf, ptr->i_id, &b); |
3744 if (h->buf) { | 3743 if (h->buf) { |
3745 *(h->buf) = b; | 3744 *(h->buf) = b; |
3746 } else if ((h->base64 == 1) && h->fp) { | 3745 } else if ((h->base64 == 1) && h->fp) { |
3747 t = base64_encode(b, ret); | 3746 t = base64_encode(b, ret); |
3748 if (t) { | 3747 if (t) { |
3758 } | 3757 } |
3759 | 3758 |
3760 } else { | 3759 } else { |
3761 // here we will assume it is a block that points to others | 3760 // here we will assume it is a block that points to others |
3762 DEBUG_READ(("Assuming it is a multi-block record because of it's id\n")); | 3761 DEBUG_READ(("Assuming it is a multi-block record because of it's id\n")); |
3763 ret = pst_ff_compile_ID(pf, ptr->id, h, (size_t)0); | 3762 ret = pst_ff_compile_ID(pf, ptr->i_id, h, (size_t)0); |
3764 } | 3763 } |
3765 DEBUG_RET(); | 3764 DEBUG_RET(); |
3766 return ret; | 3765 return ret; |
3767 } | 3766 } |
3768 | 3767 |