comparison src/libpst.c @ 141:fd4297884319

improve decoding of multipart/report and message/rfc822 mime types
author Carl Byington <carl@five-ten-sg.com>
date Sat, 14 Feb 2009 11:02:37 -0800
parents e35fd42bac05
children 2189a6b8134e
comparison
equal deleted inserted replaced
140:fc6c54c453e5 141:fd4297884319
390 size = pst_ff_getID2data(pf, ptr, &h); 390 size = pst_ff_getID2data(pf, ptr, &h);
391 } else { 391 } else {
392 DEBUG_WARN(("Couldn't find ID pointer. Cannot handle attachment\n")); 392 DEBUG_WARN(("Couldn't find ID pointer. Cannot handle attachment\n"));
393 size = 0; 393 size = 0;
394 } 394 }
395 attach->size = size; // may as well update it to what is correct for this instance 395 attach->size = size;
396 } else { 396 } else {
397 size = attach->size; 397 size = attach->size;
398 } 398 }
399 DEBUG_RET(); 399 DEBUG_RET();
400 return size; 400 return size;
407 size_t size = 0; 407 size_t size = 0;
408 DEBUG_ENT("pst_attach_to_file"); 408 DEBUG_ENT("pst_attach_to_file");
409 if (attach->id_val != (uint64_t)-1) { 409 if (attach->id_val != (uint64_t)-1) {
410 ptr = pst_getID(pf, attach->id_val); 410 ptr = pst_getID(pf, attach->id_val);
411 if (ptr) { 411 if (ptr) {
412 // pst_num_array *list = pst_parse_block(pf, ptr->id, NULL, NULL);
413 // DEBUG_WARN(("writing file data attachment\n"));
414 // for (int32_t x=0; x<list->count_item; x++) {
415 // DEBUG_HEXDUMPC(list->items[x]->data, list->items[x]->size, 0x10);
416 // (void)pst_fwrite(list->items[x]->data, (size_t)1, list->items[x]->size, fp);
417 // }
418 size = pst_ff_getID2data(pf, ptr, &h); 412 size = pst_ff_getID2data(pf, ptr, &h);
419 } else { 413 } else {
420 DEBUG_WARN(("Couldn't find ID pointer. Cannot save attachment to file\n")); 414 DEBUG_WARN(("Couldn't find ID pointer. Cannot save attachment to file\n"));
421 } 415 }
422 attach->size = size; 416 attach->size = size;
423 } else { 417 } else {
424 // save the attachment to file 418 // save the attachment to the file
425 size = attach->size; 419 size = attach->size;
426 (void)pst_fwrite(attach->data, (size_t)1, size, fp); 420 (void)pst_fwrite(attach->data, (size_t)1, size, fp);
427 } 421 }
428 DEBUG_RET(); 422 DEBUG_RET();
429 return size; 423 return size;
432 426
433 size_t pst_attach_to_file_base64(pst_file *pf, pst_item_attach *attach, FILE* fp) { 427 size_t pst_attach_to_file_base64(pst_file *pf, pst_item_attach *attach, FILE* fp) {
434 pst_index_ll *ptr; 428 pst_index_ll *ptr;
435 pst_holder h = {NULL, fp, 1}; 429 pst_holder h = {NULL, fp, 1};
436 size_t size = 0; 430 size_t size = 0;
437 char *c;
438 DEBUG_ENT("pst_attach_to_file_base64"); 431 DEBUG_ENT("pst_attach_to_file_base64");
439 if (attach->id_val != (uint64_t)-1) { 432 if (attach->id_val != (uint64_t)-1) {
440 ptr = pst_getID(pf, attach->id_val); 433 ptr = pst_getID(pf, attach->id_val);
441 if (ptr) { 434 if (ptr) {
442 // pst_num_array *list = pst_parse_block(pf, ptr->id, NULL, NULL);
443 // DEBUG_WARN(("writing base64 data attachment\n"));
444 // for (int32_t x=0; x<list->count_item; x++) {
445 // DEBUG_HEXDUMPC(list->items[x]->data, list->items[x]->size, 0x10);
446 // c = base64_encode(list->items[x]->data, list->items[x]->size);
447 // if (c) {
448 // (void)pst_fwrite(c, (size_t)1, strlen(c), fp);
449 // free(c); // caught by valgrind
450 // }
451 // }
452 size = pst_ff_getID2data(pf, ptr, &h); 435 size = pst_ff_getID2data(pf, ptr, &h);
453 } else { 436 } else {
454 DEBUG_WARN(("Couldn't find ID pointer. Cannot save attachment to Base64\n")); 437 DEBUG_WARN(("Couldn't find ID pointer. Cannot save attachment to Base64\n"));
455 } 438 }
456 attach->size = size; 439 attach->size = size;
457 } else { 440 } else {
458 // encode the attachment to the file 441 // encode the attachment to the file
459 c = base64_encode(attach->data, attach->size); 442 char *c = base64_encode(attach->data, attach->size);
460 if (c) { 443 if (c) {
461 (void)pst_fwrite(c, (size_t)1, strlen(c), fp); 444 (void)pst_fwrite(c, (size_t)1, strlen(c), fp);
462 free(c); // caught by valgrind 445 free(c); // caught by valgrind
463 } 446 }
464 size = attach->size; 447 size = attach->size;
2303 DEBUG_EMAIL(("In-Reply-To - ")); 2286 DEBUG_EMAIL(("In-Reply-To - "));
2304 MALLOC_EMAIL(item); 2287 MALLOC_EMAIL(item);
2305 LIST_COPY(item->email->in_reply_to, (char*)); 2288 LIST_COPY(item->email->in_reply_to, (char*));
2306 DEBUG_EMAIL(("%s\n", item->email->in_reply_to)); 2289 DEBUG_EMAIL(("%s\n", item->email->in_reply_to));
2307 break; 2290 break;
2308 case 0x1046: // Return Path 2291 case 0x1046: // Return Path - this seems to be the message-id of the rfc822 mail that is being returned
2309 DEBUG_EMAIL(("Return Path - ")); 2292 DEBUG_EMAIL(("Return Path - "));
2310 MALLOC_EMAIL(item); 2293 MALLOC_EMAIL(item);
2311 LIST_COPY(item->email->return_path_address, (char*)); 2294 LIST_COPY(item->email->return_path_address, (char*));
2312 DEBUG_EMAIL(("%s\n", item->email->return_path_address)); 2295 DEBUG_EMAIL(("%s\n", item->email->return_path_address));
2313 break; 2296 break;