comparison src/libpst.c @ 201:3850a3b11745

fixes for parallel readpst
author Carl Byington <carl@five-ten-sg.com>
date Sat, 16 May 2009 10:32:26 -0700
parents e3a46f66332b
children 2f38c4ce606f
comparison
equal deleted inserted replaced
200:d360f96f71f6 201:3850a3b11745
251 0xf1, 0x5a, 0xef, 0xcf, 0x90, 0xb6, 0x8b, 0xb5, 0xbd, 0xc0, 0xbf, 0x08, 0x97, 0x1e, 0x6c, 0xe2, 251 0xf1, 0x5a, 0xef, 0xcf, 0x90, 0xb6, 0x8b, 0xb5, 0xbd, 0xc0, 0xbf, 0x08, 0x97, 0x1e, 0x6c, 0xe2,
252 0x61, 0xe0, 0xc6, 0xc1, 0x59, 0xab, 0xbb, 0x58, 0xde, 0x5f, 0xdf, 0x60, 0x79, 0x7e, 0xb2, 0x8a 252 0x61, 0xe0, 0xc6, 0xc1, 0x59, 0xab, 0xbb, 0x58, 0xde, 0x5f, 0xdf, 0x60, 0x79, 0x7e, 0xb2, 0x8a
253 }; 253 };
254 254
255 static 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); 255 static 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);
256 static pst_id2_tree* pst_build_id2(pst_file *pf, pst_index_ll* list); 256 static pst_id2_tree* pst_build_id2(pst_file *pf, pst_index_ll* list);
257 static 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); 257 static 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);
258 static int pst_chr_count(char *str, char x); 258 static int pst_chr_count(char *str, char x);
259 static size_t pst_ff_compile_ID(pst_file *pf, uint64_t i_id, pst_holder *h, size_t size); 259 static size_t pst_ff_compile_ID(pst_file *pf, uint64_t i_id, pst_holder *h, size_t size);
260 static size_t pst_ff_getID2block(pst_file *pf, uint64_t id2, pst_id2_tree *id2_head, char** buf); 260 static size_t pst_ff_getID2block(pst_file *pf, uint64_t id2, pst_id2_tree *id2_head, char** buf);
261 static size_t pst_ff_getID2data(pst_file *pf, pst_index_ll *ptr, pst_holder *h); 261 static size_t pst_ff_getID2data(pst_file *pf, pst_index_ll *ptr, pst_holder *h);
266 static void pst_free_list(pst_mapi_object *list); 266 static void pst_free_list(pst_mapi_object *list);
267 static void pst_free_xattrib(pst_x_attrib_ll *x); 267 static void pst_free_xattrib(pst_x_attrib_ll *x);
268 static size_t pst_getAtPos(pst_file *pf, int64_t pos, void* buf, size_t size); 268 static size_t pst_getAtPos(pst_file *pf, int64_t pos, void* buf, size_t size);
269 static int pst_getBlockOffsetPointer(pst_file *pf, pst_id2_tree *i2_head, pst_subblocks *subblocks, uint32_t offset, pst_block_offset_pointer *p); 269 static int pst_getBlockOffsetPointer(pst_file *pf, pst_id2_tree *i2_head, pst_subblocks *subblocks, uint32_t offset, pst_block_offset_pointer *p);
270 static int pst_getBlockOffset(char *buf, size_t read_size, uint32_t i_offset, uint32_t offset, pst_block_offset *p); 270 static int pst_getBlockOffset(char *buf, size_t read_size, uint32_t i_offset, uint32_t offset, pst_block_offset *p);
271 static pst_id2_tree* pst_getID2(pst_id2_tree * ptr, uint64_t id); 271 static pst_id2_tree* pst_getID2(pst_id2_tree * ptr, uint64_t id);
272 static pst_desc_tree* pst_getDptr(pst_file *pf, uint64_t d_id); 272 static pst_desc_tree* pst_getDptr(pst_file *pf, uint64_t d_id);
273 static uint64_t pst_getIntAt(pst_file *pf, char *buf); 273 static uint64_t pst_getIntAt(pst_file *pf, char *buf);
274 static uint64_t pst_getIntAtPos(pst_file *pf, int64_t pos); 274 static uint64_t pst_getIntAtPos(pst_file *pf, int64_t pos);
275 static pst_mapi_object* pst_parse_block(pst_file *pf, uint64_t block_id, pst_id2_tree *i2_head); 275 static pst_mapi_object* pst_parse_block(pst_file *pf, uint64_t block_id, pst_id2_tree *i2_head);
276 static void pst_printDptr(pst_file *pf, pst_desc_tree *ptr); 276 static void pst_printDptr(pst_file *pf, pst_desc_tree *ptr);
277 static void pst_printIDptr(pst_file* pf); 277 static void pst_printIDptr(pst_file* pf);
351 pf->index1_back = pst_getIntAtPos(pf, INDEX_BACK); 351 pf->index1_back = pst_getIntAtPos(pf, INDEX_BACK);
352 pf->index1 = pst_getIntAtPos(pf, INDEX_POINTER); 352 pf->index1 = pst_getIntAtPos(pf, INDEX_POINTER);
353 DEBUG_INFO(("Pointer1 is %#"PRIx64", back pointer2 is %#"PRIx64"\n", pf->index1, pf->index1_back)); 353 DEBUG_INFO(("Pointer1 is %#"PRIx64", back pointer2 is %#"PRIx64"\n", pf->index1, pf->index1_back));
354 354
355 DEBUG_RET(); 355 DEBUG_RET();
356
357 pf->cwd = pst_malloc(PATH_MAX+1);
358 getcwd(pf->cwd, PATH_MAX+1);
359 pf->fname = strdup(name);
360 return 0;
361 }
362
363
364 int pst_reopen(pst_file *pf) {
365 char cwd[PATH_MAX];
366 if (!getcwd(cwd, PATH_MAX)) return -1;
367 if (chdir(pf->cwd)) return -1;
368 if (!freopen(pf->fname, "rb", pf->fp)) return -1;
369 if (chdir(cwd)) return -1;
356 return 0; 370 return 0;
357 } 371 }
358 372
359 373
360 int pst_close(pst_file *pf) { 374 int pst_close(pst_file *pf) {
363 DEBUG_RET(); 377 DEBUG_RET();
364 return 0; 378 return 0;
365 } 379 }
366 if (fclose(pf->fp)) { 380 if (fclose(pf->fp)) {
367 DEBUG_WARN(("fclose returned non-zero value\n")); 381 DEBUG_WARN(("fclose returned non-zero value\n"));
368 DEBUG_RET(); 382 }
369 return -1; 383 // free the paths
370 } 384 free(pf->cwd);
385 free(pf->fname);
371 // we must free the id linklist and the desc tree 386 // we must free the id linklist and the desc tree
372 pst_free_id (pf->i_head); 387 pst_free_id(pf->i_head);
373 pst_free_desc (pf->d_head); 388 pst_free_desc(pf->d_head);
374 pst_free_xattrib (pf->x_head); 389 pst_free_xattrib(pf->x_head);
375 DEBUG_RET(); 390 DEBUG_RET();
376 return 0; 391 return 0;
377 } 392 }
378 393
379 394
2487 LIST_COPY_BOOL("Has Subfolders", item->folder->subfolder); 2502 LIST_COPY_BOOL("Has Subfolders", item->folder->subfolder);
2488 break; 2503 break;
2489 case 0x3613: // PR_CONTAINER_CLASS IPF.x 2504 case 0x3613: // PR_CONTAINER_CLASS IPF.x
2490 LIST_COPY_CSTR(item->ascii_type); 2505 LIST_COPY_CSTR(item->ascii_type);
2491 if (pst_strincmp("IPF.Note", item->ascii_type, 8) == 0) 2506 if (pst_strincmp("IPF.Note", item->ascii_type, 8) == 0)
2507 item->type = PST_TYPE_NOTE;
2508 if (pst_strincmp("IPF.Imap", item->ascii_type, 8) == 0)
2492 item->type = PST_TYPE_NOTE; 2509 item->type = PST_TYPE_NOTE;
2493 else if (pst_stricmp("IPF", item->ascii_type) == 0) 2510 else if (pst_stricmp("IPF", item->ascii_type) == 0)
2494 item->type = PST_TYPE_NOTE; 2511 item->type = PST_TYPE_NOTE;
2495 else if (pst_strincmp("IPF.Contact", item->ascii_type, 11) == 0) 2512 else if (pst_strincmp("IPF.Contact", item->ascii_type, 11) == 0)
2496 item->type = PST_TYPE_CONTACT; 2513 item->type = PST_TYPE_CONTACT;
4333 if (i+4 <= s) { *(&r->parm1 + j) = PST_LE_GET_UINT32(p+i); i += 4; } 4350 if (i+4 <= s) { *(&r->parm1 + j) = PST_LE_GET_UINT32(p+i); i += 4; }
4334 } 4351 }
4335 } 4352 }
4336 if (i <= s) { r->termination = PST_LE_GET_UINT8(p+i) - 0x21; i += 4; } 4353 if (i <= s) { r->termination = PST_LE_GET_UINT8(p+i) - 0x21; i += 4; }
4337 if (i+4 <= s) { r->count = PST_LE_GET_UINT32(p+i); i += 4; } 4354 if (i+4 <= s) { r->count = PST_LE_GET_UINT32(p+i); i += 4; }
4355 if (r->termination == 2) r->count = 0;
4338 switch (r->type) { 4356 switch (r->type) {
4339 case 0: // daily 4357 case 0: // daily
4340 if (r->sub_type == 0) { 4358 if (r->sub_type == 0) {
4341 // simple daily 4359 // simple daily
4342 r->interval = r->parm2 / (24 * 60); // was minutes between recurrences 4360 r->interval = r->parm2 / (24 * 60); // was minutes between recurrences