diff --git a/src/insert_event.c b/src/insert_event.c index 7305e05..3eed188 100644 --- a/src/insert_event.c +++ b/src/insert_event.c @@ -1,6 +1,7 @@ +#include "date_time_handling.h" #include "insert_event.h" #include "string_handling.h" -#include "date_time_handling.h" +#include #include #include #include @@ -8,8 +9,17 @@ #include #include +// Prompts a user to insert data for one event and saves it in +// the iCalendar file at "file_name". +// Exits the program afterwards. void insert_event(char *file_name) { int myfd = open(file_name, O_RDWR); + if (myfd == -1) { + fprintf(stderr, "Error opening file \"%s\".\n", file_name); + fprintf(stderr, "%s.\n", strerror(errno)); + exit(1); + } + bool all_day_event = false; char summary_buf[256] = "SUMMARY:"; char *input_buffer = &summary_buf[8]; diff --git a/src/parse_ics.c b/src/parse_ics.c index 9c69a70..7ef91d8 100644 --- a/src/parse_ics.c +++ b/src/parse_ics.c @@ -4,6 +4,7 @@ #include "string_handling.h" #include #include +#include #include #include #include @@ -72,17 +73,18 @@ void unfolding_string(char *folded_string, char *unfolded_string) { } } -/* this function takes the head of an empty initialized event list - * and the path to the ics file - * it will "fill" the list - */ +// Takes the head of an empty initialized event list +// and the path to the ics file. +// "Fills" the linked list. +// Exits the program on error. void parse_ics_file(char *file_path, struct event **head) { char my_event[8192] = ""; char unfolded_event[8192] = ""; int myfd = open(file_path, O_RDONLY); if (myfd == -1) { - perror ("Error opening file"); + fprintf(stderr, "Error opening file \"%s\".\n", file_path); + fprintf(stderr, "%s.\n", strerror(errno)); exit(1); }