comparison src/libpst.c @ 28:51d826f31329

more cleanup from Arne, document 7c block format
author carl
date Sat, 25 Feb 2006 16:03:45 -0800
parents f4643b609bdf
children b88ceb81dba2
comparison
equal deleted inserted replaced
27:99e6b70cdfb3 28:51d826f31329
1025 memset (attach, 0, sizeof(pst_item_attach)); 1025 memset (attach, 0, sizeof(pst_item_attach));
1026 attach->next = item->attach; 1026 attach->next = item->attach;
1027 item->attach = attach; 1027 item->attach = attach;
1028 x++; 1028 x++;
1029 } 1029 }
1030 item->current_attach = item->attach;
1031 1030
1032 if (_pst_process(list, item)) { 1031 if (_pst_process(list, item)) {
1033 DEBUG_WARN(("ERROR _pst_process() failed with attachments\n")); 1032 DEBUG_WARN(("ERROR _pst_process() failed with attachments\n"));
1034 _pst_free_list(list); 1033 _pst_free_list(list);
1035 DEBUG_RET(); 1034 DEBUG_RET();
1049 if ((list = _pst_parse_block(pf, id_ptr->id, NULL)) == NULL) { 1048 if ((list = _pst_parse_block(pf, id_ptr->id, NULL)) == NULL) {
1050 DEBUG_WARN(("ERROR error processing an attachment record\n")); 1049 DEBUG_WARN(("ERROR error processing an attachment record\n"));
1051 attach = attach->next; 1050 attach = attach->next;
1052 continue; 1051 continue;
1053 } 1052 }
1054 item->current_attach = attach;
1055 if (_pst_process(list, item)) { 1053 if (_pst_process(list, item)) {
1056 DEBUG_WARN(("ERROR _pst_process() failed with an attachment\n")); 1054 DEBUG_WARN(("ERROR _pst_process() failed with an attachment\n"));
1057 _pst_free_list(list); 1055 _pst_free_list(list);
1058 attach = attach->next; 1056 attach = attach->next;
1059 continue; 1057 continue;
1070 DEBUG_WARN(("ERROR cannot locate id2 value %#x\n", attach->id2_val)); 1068 DEBUG_WARN(("ERROR cannot locate id2 value %#x\n", attach->id2_val));
1071 } 1069 }
1072 attach = attach->next; 1070 attach = attach->next;
1073 } 1071 }
1074 } 1072 }
1075 item->current_attach = item->attach; //reset back to first
1076 } 1073 }
1077 1074
1078 _pst_free_id2(id2_head); 1075 _pst_free_id2(id2_head);
1079 DEBUG_RET(); 1076 DEBUG_RET();
1080 return item; 1077 return item;
1085 unsigned char *buf = NULL; 1082 unsigned char *buf = NULL;
1086 pst_num_array *na_ptr = NULL, *na_head = NULL; 1083 pst_num_array *na_ptr = NULL, *na_head = NULL;
1087 pst_block_offset block_offset; 1084 pst_block_offset block_offset;
1088 // pst_index_ll *rec = NULL; 1085 // pst_index_ll *rec = NULL;
1089 u_int32_t size = 0, t_ptr = 0, fr_ptr = 0, to_ptr = 0, ind_ptr = 0, x = 0; 1086 u_int32_t size = 0, t_ptr = 0, fr_ptr = 0, to_ptr = 0, ind_ptr = 0, x = 0;
1090 u_int32_t num_recs = 0, count_rec = 0, ind2_ptr = 0, list_start = 0, num_list = 0, cur_list = 0; 1087 u_int32_t num_recs = 0, count_rec = 0, ind2_ptr = 0, ind2_end = 0, list_start = 0, num_list = 0, cur_list = 0;
1091 int32_t block_type, rec_size; 1088 int32_t block_type, rec_size;
1092 size_t read_size=0; 1089 size_t read_size=0;
1093 pst_x_attrib_ll *mapptr; 1090 pst_x_attrib_ll *mapptr;
1094 1091
1095 struct { 1092 struct {
1162 DEBUG_RET(); 1159 DEBUG_RET();
1163 return NULL; 1160 return NULL;
1164 } 1161 }
1165 1162
1166 _pst_getBlockOffset(buf, read_size, ind_ptr, table_rec.value, &block_offset); 1163 _pst_getBlockOffset(buf, read_size, ind_ptr, table_rec.value, &block_offset);
1167 list_start = fr_ptr = block_offset.from; 1164 list_start = block_offset.from;
1168 to_ptr = block_offset.to; 1165 to_ptr = block_offset.to;
1169 num_list = (to_ptr - fr_ptr)/sizeof(table_rec); 1166 num_list = (to_ptr - list_start)/sizeof(table_rec);
1170 num_recs = 1; // only going to one object in these blocks 1167 num_recs = 1; // only going to one object in these blocks
1171 rec_size = 0; // doesn't matter cause there is only one object 1168 rec_size = 0; // doesn't matter cause there is only one object
1172 } 1169 }
1173 else if (block_hdr.type == 0x7CEC) { //type 2 1170 else if (block_hdr.type == 0x7CEC) { //type 2
1174 block_type = 2; 1171 block_type = 2;
1202 DEBUG_EMAIL(("b5 offset = %#x\n", seven_c_blk.b_five_offset)); 1199 DEBUG_EMAIL(("b5 offset = %#x\n", seven_c_blk.b_five_offset));
1203 1200
1204 _pst_getBlockOffset(buf, read_size, ind_ptr, seven_c_blk.b_five_offset, &block_offset); 1201 _pst_getBlockOffset(buf, read_size, ind_ptr, seven_c_blk.b_five_offset, &block_offset);
1205 fr_ptr = block_offset.from; 1202 fr_ptr = block_offset.from;
1206 memcpy(&table_rec, &(buf[fr_ptr]), sizeof(table_rec)); 1203 memcpy(&table_rec, &(buf[fr_ptr]), sizeof(table_rec));
1207 DEBUG_EMAIL(("before convert %#x\n", table_rec.type));
1208 LE16_CPU(table_rec.type); 1204 LE16_CPU(table_rec.type);
1209 DEBUG_EMAIL(("after convert %#x\n", table_rec.type));
1210 LE16_CPU(table_rec.ref_type); 1205 LE16_CPU(table_rec.ref_type);
1211 LE32_CPU(table_rec.value); 1206 LE32_CPU(table_rec.value);
1207 DEBUG_EMAIL(("after convert %#x\n", table_rec.type));
1212 1208
1213 if (table_rec.type != 0x04B5) { // different constant than a type 1 record 1209 if (table_rec.type != 0x04B5) { // different constant than a type 1 record
1214 WARN(("Unknown second block constant - %#X for id %#x\n", table_rec.type, block_id)); 1210 WARN(("Unknown second block constant - %#X for id %#x\n", table_rec.type, block_id));
1215 if (buf) free(buf); 1211 if (buf) free(buf);
1216 DEBUG_RET(); 1212 DEBUG_RET();
1227 _pst_getBlockOffset(buf, read_size, ind_ptr, table_rec.value, &block_offset); 1223 _pst_getBlockOffset(buf, read_size, ind_ptr, table_rec.value, &block_offset);
1228 num_recs = (block_offset.to - block_offset.from) / 6; // this will give the number of records in this block 1224 num_recs = (block_offset.to - block_offset.from) / 6; // this will give the number of records in this block
1229 1225
1230 _pst_getBlockOffset(buf, read_size, ind_ptr, seven_c_blk.ind2_offset, &block_offset); 1226 _pst_getBlockOffset(buf, read_size, ind_ptr, seven_c_blk.ind2_offset, &block_offset);
1231 ind2_ptr = block_offset.from; 1227 ind2_ptr = block_offset.from;
1228 ind2_end = block_offset.to;
1232 } else { 1229 } else {
1233 WARN(("ERROR: Unknown block constant - %#X for id %#x\n", block_hdr.type, block_id)); 1230 WARN(("ERROR: Unknown block constant - %#X for id %#x\n", block_hdr.type, block_id));
1234 DEBUG_HEXDUMPC(buf, read_size,0x10); 1231 DEBUG_HEXDUMPC(buf, read_size,0x10);
1235 if (buf) free(buf); 1232 if (buf) free(buf);
1236 DEBUG_RET(); 1233 DEBUG_RET();
1256 while (cur_list < num_list) { //we will increase fr_ptr as we progress through index 1253 while (cur_list < num_list) { //we will increase fr_ptr as we progress through index
1257 if (block_type == 1) { 1254 if (block_type == 1) {
1258 memcpy(&table_rec, &(buf[fr_ptr]), sizeof(table_rec)); 1255 memcpy(&table_rec, &(buf[fr_ptr]), sizeof(table_rec));
1259 LE16_CPU(table_rec.type); 1256 LE16_CPU(table_rec.type);
1260 LE16_CPU(table_rec.ref_type); 1257 LE16_CPU(table_rec.ref_type);
1258 //LE32_CPU(table_rec.value); // done later, some may be order invariant
1261 fr_ptr += sizeof(table_rec); 1259 fr_ptr += sizeof(table_rec);
1262 } else if (block_type == 2) { 1260 } else if (block_type == 2) {
1263 // we will copy the table2_rec values into a table_rec record so that we can keep the rest of the code 1261 // we will copy the table2_rec values into a table_rec record so that we can keep the rest of the code
1264 memcpy(&table2_rec, &(buf[fr_ptr]), sizeof(table2_rec)); 1262 memcpy(&table2_rec, &(buf[fr_ptr]), sizeof(table2_rec));
1265 LE16_CPU(table2_rec.ref_type); 1263 LE16_CPU(table2_rec.ref_type);
1268 LE16_CPU(table2_rec.u1); 1266 LE16_CPU(table2_rec.u1);
1269 1267
1270 // table_rec and table2_rec are arranged differently, so assign the values across 1268 // table_rec and table2_rec are arranged differently, so assign the values across
1271 table_rec.type = table2_rec.type; 1269 table_rec.type = table2_rec.type;
1272 table_rec.ref_type = table2_rec.ref_type; 1270 table_rec.ref_type = table2_rec.ref_type;
1273 if ((ind2_ptr+table2_rec.ind2_off > 0) && 1271 if (ind2_ptr+table2_rec.ind2_off <= ind2_end) {
1274 (ind2_ptr+table2_rec.ind2_off < read_size-sizeof(table_rec.value)))
1275 memcpy(&(table_rec.value), &(buf[ind2_ptr+table2_rec.ind2_off]), sizeof(table_rec.value)); 1272 memcpy(&(table_rec.value), &(buf[ind2_ptr+table2_rec.ind2_off]), sizeof(table_rec.value));
1273 //LE32_CPU(table_rec.value); // done later, some may be order invariant
1274 }
1276 else { 1275 else {
1277 DEBUG_WARN (("trying to read more than blocks size. Size=%#x, Req.=%#x," 1276 DEBUG_WARN (("trying to read more than blocks size. Size=%#x, Req.=%#x,"
1278 " Req Size=%#x\n", read_size, ind2_ptr+table2_rec.ind2_off, 1277 " Req Size=%#x\n", read_size, ind2_ptr+table2_rec.ind2_off,
1279 sizeof(table_rec.value))); 1278 sizeof(table_rec.value)));
1280 } 1279 }
1471 DEBUG_EMAIL(("item cannot be NULL.\n")); 1470 DEBUG_EMAIL(("item cannot be NULL.\n"));
1472 DEBUG_RET(); 1471 DEBUG_RET();
1473 return -1; 1472 return -1;
1474 } 1473 }
1475 1474
1476 attach = item->current_attach; // a working variable 1475 attach = item->attach; // a working variable
1477 1476
1478 while (list) { 1477 while (list) {
1479 x = 0; 1478 x = 0;
1480 while (x < list->count_item) { 1479 while (x < list->count_item) {
1481 // check here to see if the id is one that is mapped. 1480 // check here to see if the id is one that is mapped.