summaryrefslogtreecommitdiff
path: root/replay.c
diff options
context:
space:
mode:
Diffstat (limited to 'replay.c')
-rw-r--r--replay.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/replay.c b/replay.c
index 410463b..7201082 100644
--- a/replay.c
+++ b/replay.c
@@ -154,6 +154,7 @@ int replaylines(int seconds, char *basedir) {
if (fp == NULL) {
printf("error: could not open replay log '%s'.\n", filename);
// Assume the file just doesn't exist yet - TODO - Interpret error codes to see what happened.
+ fclose(fp);
return 0;
}
@@ -198,8 +199,9 @@ int readreplayline(int seconds, int linenum, char *str, char *basedir) {
fp = fopen(filename, "r");
if (fp == NULL) {
- printf("error: could not open replay log '%s'.\n", filename);
- exit(1);
+ debugprint("error: could not open replay log '%s'.\n", filename);
+ fclose(fp);
+ return 0;
}
// Get the current time for comparison later
@@ -209,8 +211,9 @@ int readreplayline(int seconds, int linenum, char *str, char *basedir) {
// Read the timestamp from each line
int timestamp = gettimestamp(line);
if (timestamp < 1) {
- printf("Error reading timestamp from replay log file.\n");
- exit(1);
+ debugprint("Error reading timestamp from replay log file.\n");
+ fclose(fp);
+ return 0;
}
// If the line is within range of the requested time...
@@ -254,8 +257,9 @@ int writereplayline(char *str, char *basedir) {
fp = fopen(filename, "a");
if (fp == NULL) {
- printf("error: could not open replay log '%s' for writing.\n", filename);
- exit(1);
+ debugprint("error: could not open replay log '%s' for writing.\n", filename);
+ fclose(fp);
+ return 0;
}
// Get the current time and manipulate it into a C string
@@ -274,8 +278,9 @@ int writereplayline(char *str, char *basedir) {
// Write complete line to file
if ((bytes = fprintf(fp, "%s", line)) < 0) {
- printf("error: could not write to replay log file.\n");
- exit(1);
+ debugprint("error: could not write to replay log file.\n");
+ fclose(fp);
+ return 0;
}
fclose(fp);