added end_date and function to print it accordingly
This commit is contained in:
23
src/main.c
23
src/main.c
@ -32,31 +32,42 @@ int main(int argc, char **argv) {
|
||||
get_date(current_date);
|
||||
printf ("Current date and time: ");
|
||||
pretty_print_date_time(current_date);
|
||||
printf ("\n");
|
||||
printf ("\n\n");
|
||||
|
||||
char date[256] = "";
|
||||
char start_date[256] = "";
|
||||
char end_date[256] = "";
|
||||
char summary[256] = "";
|
||||
|
||||
while(read_until_nl(myfd, my_line)) {
|
||||
if (strncmp(my_line, "BEGIN:VEVENT", 12) == 0) {
|
||||
memset(my_line, '\0', sizeof(my_line));
|
||||
// go to DTSTART, but dont write to a variable
|
||||
// put DTSTART into variable
|
||||
seek_string_a(myfd, "DTSTART");
|
||||
read_until_string(myfd, my_line, "DTEND");
|
||||
remove_whitespace(my_line);
|
||||
cut_string(my_line, ':', 1);
|
||||
strcpy(date, my_line);
|
||||
strcpy(start_date, my_line);
|
||||
|
||||
memset(my_line, '\0', sizeof(my_line));
|
||||
|
||||
// put DTEND into variable
|
||||
read_until_string(myfd, my_line, "SEQUENCE");
|
||||
remove_whitespace(my_line);
|
||||
cut_string(my_line, ':', 1);
|
||||
strcpy(end_date, my_line);
|
||||
|
||||
memset(my_line, '\0', sizeof(my_line));
|
||||
|
||||
// put summary into variable
|
||||
seek_string_a(myfd, "SUMMARY:");
|
||||
read_until_string(myfd, my_line, "TRANSP:");
|
||||
remove_nl_and_cr(my_line);
|
||||
strcpy(summary, my_line);
|
||||
memset(my_line, '\0', sizeof(my_line));
|
||||
|
||||
sorted_insert(&head, date, summary);
|
||||
memset(date, '\0', sizeof(date));
|
||||
sorted_insert(&head, start_date, end_date, summary);
|
||||
memset(start_date, '\0', sizeof(start_date));
|
||||
memset(end_date, '\0', sizeof(end_date));
|
||||
memset(summary, '\0', sizeof(summary));
|
||||
}
|
||||
memset(my_line, '\0', sizeof(my_line));
|
||||
|
Reference in New Issue
Block a user