libyal / libpff

Library and tools to access the Personal Folder File (PFF) and the Offline Folder File (OFF) format
GNU Lesser General Public License v3.0
291 stars 74 forks source link

How to handle the recipients structure #119

Open tt376 opened 1 year ago

tt376 commented 1 year ago

Thank you for developing many wonderful libraries.

I used the "libpff_message_get_recipients" function to get the recipients structure from the message. When I tried to get detailed information from recipients, all functions related to recipients were deprecated. I wrote the code below to enumerate the recipients, but is this redundant writing recommended? Why is the recipients function deprecated?

libpff_item_t* recipients = NULL;
libpff_message_get_recipients(sub_message, &recipients, NULL);
int number_of_recipient;
libpff_item_get_number_of_record_sets(recipients, &number_of_recipient, NULL);
for (int i = 0; i < number_of_recipient; i++)
{
    libpff_record_set_t* recipient_record_set = NULL;
    libpff_item_get_record_set_by_index(recipients, i, &recipient_record_set, NULL);

    libpff_record_entry_t* recipient_name_record_entry = NULL;
    libpff_record_set_get_entry_by_type(recipient_record_set, LIBPFF_ENTRY_TYPE_RECIPIENT_DISPLAY_NAME, 0, &recipient_name_record_entry,LIBPFF_ENTRY_VALUE_FLAG_MATCH_ANY_VALUE_TYPE, NULL);

    uint8_t recipient_name[128];
    libpff_record_entry_get_data_as_utf8_string(recipient_name_record_entry, recipient_name, 128, NULL);
    cout << DataConverter::utf8_to_multi_winapi(string(reinterpret_cast<char*>(recipient_name), 128)) << endl;
    (Omitted memory release)
}