Mercurial > libpst
comparison src/libpst.c @ 125:23a36ac0514d
recover dropped pragma pack line, use int64_t rather than off_t to avoid forcing users of the shared library to enable large file support.
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Tue, 03 Feb 2009 15:01:47 -0800 |
parents | ab2a11e72250 |
children | 7f747c8c9d02 |
comparison
equal
deleted
inserted
replaced
124:cbf63dd3f109 | 125:23a36ac0514d |
---|---|
18 | 18 |
19 #define INDEX_TYPE32 0x0E | 19 #define INDEX_TYPE32 0x0E |
20 #define INDEX_TYPE32A 0x0F // unknown, but assumed to be similar for now | 20 #define INDEX_TYPE32A 0x0F // unknown, but assumed to be similar for now |
21 #define INDEX_TYPE64 0x17 | 21 #define INDEX_TYPE64 0x17 |
22 #define INDEX_TYPE64A 0x15 // http://sourceforge.net/projects/libpff/ | 22 #define INDEX_TYPE64A 0x15 // http://sourceforge.net/projects/libpff/ |
23 #define INDEX_TYPE_OFFSET (uint64_t)0x0A | 23 #define INDEX_TYPE_OFFSET (int64_t)0x0A |
24 | 24 |
25 #define FILE_SIZE_POINTER32 (uint64_t)0xA8 | 25 #define FILE_SIZE_POINTER32 (int64_t)0xA8 |
26 #define INDEX_POINTER32 (uint64_t)0xC4 | 26 #define INDEX_POINTER32 (int64_t)0xC4 |
27 #define INDEX_BACK32 (uint64_t)0xC0 | 27 #define INDEX_BACK32 (int64_t)0xC0 |
28 #define SECOND_POINTER32 (uint64_t)0xBC | 28 #define SECOND_POINTER32 (int64_t)0xBC |
29 #define SECOND_BACK32 (uint64_t)0xB8 | 29 #define SECOND_BACK32 (int64_t)0xB8 |
30 #define ENC_TYPE32 (uint64_t)0x1CD | 30 #define ENC_TYPE32 (int64_t)0x1CD |
31 | 31 |
32 #define FILE_SIZE_POINTER64 (uint64_t)0xB8 | 32 #define FILE_SIZE_POINTER64 (int64_t)0xB8 |
33 #define INDEX_POINTER64 (uint64_t)0xF0 | 33 #define INDEX_POINTER64 (int64_t)0xF0 |
34 #define INDEX_BACK64 (uint64_t)0xE8 | 34 #define INDEX_BACK64 (int64_t)0xE8 |
35 #define SECOND_POINTER64 (uint64_t)0xE0 | 35 #define SECOND_POINTER64 (int64_t)0xE0 |
36 #define SECOND_BACK64 (uint64_t)0xD8 | 36 #define SECOND_BACK64 (int64_t)0xD8 |
37 #define ENC_TYPE64 (uint64_t)0x201 | 37 #define ENC_TYPE64 (int64_t)0x201 |
38 | 38 |
39 #define FILE_SIZE_POINTER ((pf->do_read64) ? FILE_SIZE_POINTER64 : FILE_SIZE_POINTER32) | 39 #define FILE_SIZE_POINTER ((pf->do_read64) ? FILE_SIZE_POINTER64 : FILE_SIZE_POINTER32) |
40 #define INDEX_POINTER ((pf->do_read64) ? INDEX_POINTER64 : INDEX_POINTER32) | 40 #define INDEX_POINTER ((pf->do_read64) ? INDEX_POINTER64 : INDEX_POINTER32) |
41 #define INDEX_BACK ((pf->do_read64) ? INDEX_BACK64 : INDEX_BACK32) | 41 #define INDEX_BACK ((pf->do_read64) ? INDEX_BACK64 : INDEX_BACK32) |
42 #define SECOND_POINTER ((pf->do_read64) ? SECOND_POINTER64 : SECOND_POINTER32) | 42 #define SECOND_POINTER ((pf->do_read64) ? SECOND_POINTER64 : SECOND_POINTER32) |
811 } | 811 } |
812 return r; | 812 return r; |
813 } | 813 } |
814 | 814 |
815 | 815 |
816 int pst_build_id_ptr(pst_file *pf, uint64_t offset, int32_t depth, uint64_t linku1, uint64_t start_val, uint64_t end_val) { | 816 int pst_build_id_ptr(pst_file *pf, int64_t offset, int32_t depth, uint64_t linku1, uint64_t start_val, uint64_t end_val) { |
817 struct pst_table_ptr_structn table, table2; | 817 struct pst_table_ptr_structn table, table2; |
818 pst_index_ll *i_ptr=NULL; | 818 pst_index_ll *i_ptr=NULL; |
819 pst_index index; | 819 pst_index index; |
820 int32_t x, item_count; | 820 int32_t x, item_count; |
821 uint64_t old = start_val; | 821 uint64_t old = start_val; |
924 DEBUG_RET(); | 924 DEBUG_RET(); |
925 return 0; | 925 return 0; |
926 } | 926 } |
927 | 927 |
928 | 928 |
929 int pst_build_desc_ptr (pst_file *pf, uint64_t offset, int32_t depth, uint64_t linku1, uint64_t start_val, uint64_t end_val) { | 929 int pst_build_desc_ptr (pst_file *pf, int64_t offset, int32_t depth, uint64_t linku1, uint64_t start_val, uint64_t end_val) { |
930 struct pst_table_ptr_structn table, table2; | 930 struct pst_table_ptr_structn table, table2; |
931 pst_descn desc_rec; | 931 pst_descn desc_rec; |
932 int32_t item_count; | 932 int32_t item_count; |
933 uint64_t old = start_val; | 933 uint64_t old = start_val; |
934 int x; | 934 int x; |
1089 } | 1089 } |
1090 if (list) pst_free_list(list); | 1090 if (list) pst_free_list(list); |
1091 list = NULL; //pst_process will free the items in the list | 1091 list = NULL; //pst_process will free the items in the list |
1092 | 1092 |
1093 if ((id_ptr = pst_getID2(id2_head, (uint64_t)0x671))) { | 1093 if ((id_ptr = pst_getID2(id2_head, (uint64_t)0x671))) { |
1094 // attachments exist - so we will process them | 1094 // should not have any existing attachments anyway |
1095 while (item->attach) { | 1095 while (item->attach) { |
1096 DEBUG_EMAIL(("throw away existing attachment\n")); | |
1096 attach = item->attach->next; | 1097 attach = item->attach->next; |
1097 free(item->attach); | 1098 free(item->attach); |
1098 item->attach = attach; | 1099 item->attach = attach; |
1099 } | 1100 } |
1100 | 1101 |
1101 DEBUG_EMAIL(("ATTACHMENT processing attachment\n")); | 1102 DEBUG_EMAIL(("ATTACHMENT processing attachment\n")); |
1102 if ((list = pst_parse_block(pf, id_ptr->id, id2_head, NULL)) == NULL) { | 1103 if ((list = pst_parse_block(pf, id_ptr->id, id2_head, NULL)) == NULL) { |
1103 DEBUG_WARN(("ERROR error processing main attachment record\n")); | 1104 DEBUG_WARN(("ERROR error processing main attachment record\n")); |
1104 //if (item) pst_freeItem(item); | |
1105 if (id2_head) pst_free_id2(id2_head); | 1105 if (id2_head) pst_free_id2(id2_head); |
1106 DEBUG_RET(); | 1106 DEBUG_RET(); |
1107 //return NULL; | |
1108 return item; | 1107 return item; |
1109 } | 1108 } |
1110 else { | 1109 else { |
1111 for (x=0; x < list->count_array; x++) { | 1110 for (x=0; x < list->count_array; x++) { |
1112 attach = (pst_item_attach*) xmalloc(sizeof(pst_item_attach)); | 1111 attach = (pst_item_attach*) xmalloc(sizeof(pst_item_attach)); |
4116 * @param size size of the block to be read | 4115 * @param size size of the block to be read |
4117 * @param buf reference to pointer to buffer. If this pointer | 4116 * @param buf reference to pointer to buffer. If this pointer |
4118 is non-NULL, it will first be free()d | 4117 is non-NULL, it will first be free()d |
4119 * @return size of block read into memory | 4118 * @return size of block read into memory |
4120 */ | 4119 */ |
4121 size_t pst_read_block_size(pst_file *pf, uint64_t offset, size_t size, char **buf) { | 4120 size_t pst_read_block_size(pst_file *pf, int64_t offset, size_t size, char **buf) { |
4122 size_t rsize; | 4121 size_t rsize; |
4123 DEBUG_ENT("pst_read_block_size"); | 4122 DEBUG_ENT("pst_read_block_size"); |
4124 DEBUG_READ(("Reading block from %#"PRIx64", %x bytes\n", offset, size)); | 4123 DEBUG_READ(("Reading block from %#"PRIx64", %x bytes\n", offset, size)); |
4125 | 4124 |
4126 if (*buf) { | 4125 if (*buf) { |
4208 return buf32; | 4207 return buf32; |
4209 } | 4208 } |
4210 } | 4209 } |
4211 | 4210 |
4212 | 4211 |
4213 uint64_t pst_getIntAtPos(pst_file *pf, uint64_t pos ) { | 4212 uint64_t pst_getIntAtPos(pst_file *pf, int64_t pos ) { |
4214 uint64_t buf64; | 4213 uint64_t buf64; |
4215 uint32_t buf32; | 4214 uint32_t buf32; |
4216 if (pf->do_read64) { | 4215 if (pf->do_read64) { |
4217 (void)pst_getAtPos(pf, pos, &buf64, sizeof(buf64)); | 4216 (void)pst_getAtPos(pf, pos, &buf64, sizeof(buf64)); |
4218 LE64_CPU(buf64); | 4217 LE64_CPU(buf64); |
4233 * @param buf buffer to contain the data | 4232 * @param buf buffer to contain the data |
4234 * @param size size of the buffer and the amount of data to be read | 4233 * @param size size of the buffer and the amount of data to be read |
4235 * @return actual read size, 0 if seek error | 4234 * @return actual read size, 0 if seek error |
4236 */ | 4235 */ |
4237 | 4236 |
4238 size_t pst_getAtPos(pst_file *pf, uint64_t pos, void* buf, size_t size) { | 4237 size_t pst_getAtPos(pst_file *pf, int64_t pos, void* buf, size_t size) { |
4239 size_t rc; | 4238 size_t rc; |
4240 DEBUG_ENT("pst_getAtPos"); | 4239 DEBUG_ENT("pst_getAtPos"); |
4241 // pst_block_recorder **t = &pf->block_head; | 4240 // pst_block_recorder **t = &pf->block_head; |
4242 // pst_block_recorder *p = pf->block_head; | 4241 // pst_block_recorder *p = pf->block_head; |
4243 // while (p && ((p->offset+p->size) <= pos)) { | 4242 // while (p && ((p->offset+p->size) <= pos)) { |