removing newline from logMessage

This commit is contained in:
Václav Šmejkal 2022-12-11 17:59:43 +01:00
parent ab9b46e75a
commit 596d6aff9a
No known key found for this signature in database
GPG Key ID: FD749A97DF2D5E19

View File

@ -108,9 +108,16 @@ void writeLog(int loggerFile, char *logMessage)
return; //TODO: Add some kind of error message return; //TODO: Add some kind of error message
} }
//COPY logMessage without '\n'
char *logMessageUsed = strdup(logMessage);
for (int i = 0; i < (int) strlen(logMessageUsed); i++)
{
if (logMessageUsed[i] == '\n') logMessageUsed[i] = '\0';
}
//VARIABLES //VARIABLES
char *buffer = NULL; char *buffer = NULL;
char *message = NULL; //COPY OF logMessage char *message = NULL; //FINAL MESSAGE
time_t timeL = time(NULL); time_t timeL = time(NULL);
struct tm tm = *localtime(&timeL); struct tm tm = *localtime(&timeL);
logFlags flags = getLogFlags(); logFlags flags = getLogFlags();
@ -120,15 +127,16 @@ void writeLog(int loggerFile, char *logMessage)
if (flags.key != NULL) //ENCRYPT TEXT IF KEY WAS CHANGED if (flags.key != NULL) //ENCRYPT TEXT IF KEY WAS CHANGED
{ {
outputFlags encrypted = encryptText(logMessage, flags.key); //ENCRYPT outputFlags encrypted = encryptText(logMessageUsed, flags.key); //ENCRYPT
message = strdup(encrypted.outputText); //COPY message = strdup(encrypted.outputText); //COPY
//DEALLOCATION //DEALLOCATION
deallocateOutput(encrypted); deallocateOutput(encrypted);
free(logMessageUsed); //I COULD DO THIS SMART SOMEHOW, BUT I AM TOO LAZY FOR THAT SHIT
} else //FUCK ENCRYPTION, LET'S DO IT; WHY WOULD WE EVEN USE WHY2-CORE? HUH? } else //FUCK ENCRYPTION, LET'S DO IT; WHY WOULD WE EVEN USE WHY2-CORE? HUH?
{ {
message = strdup(logMessage); //COPY message = logMessageUsed;
} }
buffer = malloc(strlen(WRITE_FORMAT) + strlen(message) + 3); //ALLOCATE buffer = malloc(strlen(WRITE_FORMAT) + strlen(message) + 3); //ALLOCATE