#include "list_handling.h" #include "parse_ics.h" #include "cli_arg_parsing.h" #include "date_time_handling.h" #include "string_handling.h" #include "read_until_nl.h" #include "read_until_string.h" #include "seek_string_a.h" #include #include #include #include #include #include int main(int argc, char **argv) { char *ics_path = ""; int show_all_events = 0; get_cli_args(argc, argv, &ics_path, &show_all_events); char my_event[8192] = ""; char unfolded_event[8192] = ""; int myfd = open(ics_path, O_RDONLY); if (myfd == -1) { perror ("Error opening file"); return 1; } // initialize linked list struct event *head = NULL; static char current_date[] = "xxxxxxxxTxxxxxx"; get_date(current_date); printf ("Current date and time: "); pretty_print_date_time(current_date); printf ("\n\n"); while(read_until_nl(myfd, my_event)) { if (strncmp(my_event, "BEGIN:VEVENT", 12) == 0) { // include the BEGIN:EVENT to not loose the new line of first field lseek(myfd, -1, SEEK_CUR); memset(my_event, '\0', sizeof(my_event)); read_until_string(myfd, my_event, "END:VEVENT"); unfolding_string(my_event, unfolded_event); parse_event(unfolded_event, &head); } memset(my_event, '\0', sizeof(my_event)); } print_upcoming(head, current_date, show_all_events); free_list(head); return 0; }