diff --git a/src/logger/lib/logger.c b/src/logger/lib/logger.c
index c2be6ef..57d10d0 100644
--- a/src/logger/lib/logger.c
+++ b/src/logger/lib/logger.c
@@ -29,7 +29,7 @@ along with this program. If not, see .
#include
-int initLogger(char *directoryPath)
+logFile initLogger(char *directoryPath)
{
//VARIABLES
struct stat st;
@@ -37,7 +37,7 @@ int initLogger(char *directoryPath)
time_t timeL = time(NULL);
struct tm tm = *localtime(&timeL);
int buffer = 1;
- int returning;
+ int file;
char *filePath = malloc(strlen(directoryPath) + 1 + strlen(LOG_FORMAT) + 1);
char *dateBuffer = malloc(strlen(LOG_FORMAT_START) + 1);
DIR *dir;
@@ -60,18 +60,29 @@ int initLogger(char *directoryPath)
}
}
- if (buffer > MAX_USAGE) return INVALID_FILE; //MAX_USAGE WAS REACHED
+ if (buffer > MAX_USAGE) //MAX_USAGE WAS REACHED
+ {
+ file = INVALID_FILE;
+
+ goto deallocation;
+ }
sprintf(filePath, LOG_FORMATTING, directoryPath, tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, buffer); //GENERATE LOG-NAME
- returning = open(filePath, O_WRONLY | O_APPEND | O_CREAT, 0644);
+ file = open(filePath, O_WRONLY | O_APPEND | O_CREAT, 0644);
+
+ deallocation:
//DEALLOCATION
free(filePath);
free(dateBuffer);
closedir(dir);
- return returning;
+ return (logFile)
+ {
+ file,
+ filePath
+ };
}
void writeLog(int loggerFile, char *logMessage)