// main.c // Tammy Zhong // Program to test email management system functions // Modified by Angela Finlayson 1/11/2024 // (Provided) #include #include #include "email_management_system.h" int main(void) { // STAGE 1 printf("*****1. Creating Folder 1...*****\n"); struct folder *folder_1 = create_folder("Folder 1"); printf("\n*****2. Number of emails in Empty Folder 1:*****\n"); printf("%d\n", count_emails(folder_1)); printf("\n*****3. Printing Empty Folder 1...*****\n"); print_emails(folder_1); printf("\n*****4. Inserting emails in Empty Folder 1 *****\n"); insert_email_at_head(folder_1, "Jon", "AAA", 10.2, RECEIVED, HIGH_PRIORITY); insert_email_at_head(folder_1, "Tim", "BBB", 20.44, DRAFT, NORMAL_PRIORITY); insert_email_at_head(folder_1, "Brianna", "CCC", 150.0, SENT, LOW_PRIORITY); insert_email_at_head(folder_1, "Tammy", "DDD", 90.2, SENT, NORMAL_PRIORITY); insert_email_at_head(folder_1, "Tammy", "EEE", 90.0, DRAFT, LOW_PRIORITY); printf("\n*****5. Printing Folder 1...*****\n"); print_emails(folder_1); printf("\n*****6. Number of emails in Folder 1: *****\n"); printf("%d\n", count_emails(folder_1)); printf("\n*****7. Look for email with subject 'AAA'...*****\n"); struct email *email_found = search_email(folder_1, "AAA"); printf("\n*****8. Printing email found in Folder 1 ...*****\n"); print_single_email(email_found); printf("\n*****9. Look for email with subject 'DDD'...*****\n"); email_found = search_email(folder_1, "DDD"); printf("\n*****10. Printing email found in Folder 1 ...*****\n"); print_single_email(email_found); printf("\n*****11. Look for email with subject 'EEE'...*****\n"); email_found = search_email(folder_1, "EEE"); printf("\n*****12. Printing email found in Folder 1 ...*****\n"); print_single_email(email_found); printf("\n*****13. Look for email with subject 'Holiday'...*****\n"); email_found = search_email(folder_1, "Holiday"); printf("\n*****14. Printing email found in Folder 1 ...*****\n"); print_single_email(email_found); printf("\n*****15. Creating Folder 2... and inserting emails...*****\n"); struct folder *folder_2 = create_folder("Folder 2"); insert_email_at_head(folder_2, "Tammy", "E", 50.5, SENT, LOW_PRIORITY); insert_email_at_head(folder_2, "Chloe", "F", 5.97, RECEIVED, HIGH_PRIORITY); insert_email_at_head(folder_2, "Olivia", "G", 30.28, SENT, NORMAL_PRIORITY); insert_email_at_head(folder_2, "Andrew", "H", 5.5, RECEIVED, LOW_PRIORITY); insert_email_at_head(folder_2, "Grace", "I", 25.25, RECEIVED, LOW_PRIORITY); printf("\n*****16. Printing Folder 2...*****\n"); print_emails(folder_2); //STAGE 2 printf("\n*****17. Deleting LOW_PRIORITY emails from Folder 2...*****\n"); delete_email_of_priority(folder_2, LOW_PRIORITY); printf("\n*****18. Printing Folder 2...*****\n"); print_emails(folder_2); printf("\n*****19. Merging Folder 1 and Folder 2...*****\n"); struct folder *merged_folder = merge_folders("Merged Folder", folder_1, folder_2); printf("\n*****20. Printing merged folder...*****\n"); print_emails(merged_folder); printf("\n*****21. Split merged folder into inbox, sent, draft...*****\n"); struct folder *inbox = create_folder("inbox"); struct folder *sent = create_folder("sent"); struct folder *draft = create_folder("draft"); split_folder(merged_folder, inbox, sent, draft); printf("\n*****22. Printing inbox...*****\n"); print_emails(inbox); printf("\n*****23. Printing sent...*****\n"); print_emails(sent); printf("\n*****24. Printing draft...*****\n"); print_emails(draft); // EXTENSION //printf("\n*****25. Printing sorted inbox...*****\n"); //sort_emails(inbox); //print_emails(inbox); // STAGE 2 printf("\n*****Clearing inbox, sent, draft (freeing all memory)...*****\n"); clear_folder(inbox); clear_folder(sent); clear_folder(draft); return 0; }