implemented why2_strdup
hehe
This commit is contained in:
parent
0b4ca30ec9
commit
f8f53b4305
src
@ -65,9 +65,9 @@ why2_output_flags why2_decrypt_text(char *text, char *keyNew)
|
||||
char *textBuffer = why2_malloc(1);
|
||||
int textKeyChainLength;
|
||||
int *textKeyChain;
|
||||
char *key = strdup(keyNew); //COPY keyNew TO key
|
||||
char *key = why2_strdup(keyNew); //COPY keyNew TO key
|
||||
int *encryptedTextKeyChain;
|
||||
char *usedText = strdup(text); //COPY text TO usedText
|
||||
char *usedText = why2_strdup(text); //COPY text TO usedText
|
||||
|
||||
//GET LENGTH OF returningText AND textKeyChain
|
||||
for (int i = 0; i < (int) strlen(usedText); i++)
|
||||
|
@ -63,7 +63,7 @@ why2_output_flags why2_encrypt_text(char *text, char *keyNew)
|
||||
return why2_no_output(checkExitCode);
|
||||
}
|
||||
|
||||
key = strdup(keyNew);
|
||||
key = why2_strdup(keyNew);
|
||||
|
||||
//REDEFINE keyLength
|
||||
why2_set_key_length(strlen(key));
|
||||
|
@ -64,8 +64,8 @@ int main(void)
|
||||
//ENCRYPT
|
||||
why2_output_flags encrypted = why2_encrypt_text(WHY2_TEST_TEXT, NULL);
|
||||
|
||||
textBuffer = strdup(encrypted.outputText); //GET ENCRYPTED TEXT
|
||||
keyBuffer = strdup(encrypted.usedKey); //GET KEY
|
||||
textBuffer = why2_strdup(encrypted.outputText); //GET ENCRYPTED TEXT
|
||||
keyBuffer = why2_strdup(encrypted.usedKey); //GET KEY
|
||||
timeBuffer = encrypted.elapsedTime; //GET TIME 1
|
||||
|
||||
//DEALLOCATE BUFFER
|
||||
@ -79,11 +79,11 @@ int main(void)
|
||||
//COMPARE DIFFERENCE
|
||||
if (strcmp(encrypted.outputText, WHY2_TEST_TEXT) == 0 && encrypted.exitCode == 0) //WHY2_SUCCESS
|
||||
{
|
||||
statusBuffer = strdup("successful");
|
||||
statusBuffer = why2_strdup("successful");
|
||||
}
|
||||
else //FAILURE
|
||||
{
|
||||
statusBuffer = strdup("failed");
|
||||
statusBuffer = why2_strdup("failed");
|
||||
|
||||
outputBuffer = why2_realloc(outputBuffer, strlen(encrypted.outputText) + 6);
|
||||
sprintf(outputBuffer, "\t\t\"%s\"\n", encrypted.outputText);
|
||||
|
@ -79,7 +79,7 @@ why2_log_file why2_init_logger(char *directoryPath)
|
||||
//CREATE SYMLINK
|
||||
sprintf(latestBuffer, WHY2_LOG_LATEST_FORMATTING, WHY2_WRITE_DIR, WHY2_LOG_LATEST); //GENERATE LATEST.log PATH
|
||||
|
||||
latestFilePath = strdup(filePath);
|
||||
latestFilePath = why2_strdup(filePath);
|
||||
|
||||
if (access(latestBuffer, R_OK) == 0) { unlink(latestBuffer); } //REMOVE SYMLINK IF IT ALREADY EXISTS
|
||||
(void) (symlink(latestFilePath + (strlen(WHY2_WRITE_DIR) + 1), latestBuffer) + 1); //TODO: Try to create some function for processing exit value //CREATE
|
||||
@ -108,7 +108,7 @@ void why2_write_log(int loggerFile, char *logMessage)
|
||||
}
|
||||
|
||||
//COPY logMessage without '\n'
|
||||
char *logMessageUsed = strdup(logMessage);
|
||||
char *logMessageUsed = why2_strdup(logMessage);
|
||||
for (int i = 0; i < (int) strlen(logMessageUsed); i++)
|
||||
{
|
||||
if (logMessageUsed[i] == '\n') logMessageUsed[i] = '\0';
|
||||
@ -128,7 +128,7 @@ void why2_write_log(int loggerFile, char *logMessage)
|
||||
{
|
||||
why2_output_flags encrypted = why2_encrypt_text(logMessageUsed, flags.key); //ENCRYPT
|
||||
|
||||
message = strdup(encrypted.outputText); //COPY
|
||||
message = why2_strdup(encrypted.outputText); //COPY
|
||||
|
||||
//DEALLOCATION
|
||||
why2_deallocate_output(encrypted);
|
||||
|
@ -101,7 +101,7 @@ why2_decrypted_output why2_decrypt_logger(why2_log_file logger)
|
||||
{
|
||||
outputBuffer = why2_decrypt_text(content[i], why2_get_log_flags().key); //DECRYPT
|
||||
|
||||
contentDecrypted[i] = strdup(outputBuffer.outputText); //COPY
|
||||
contentDecrypted[i] = why2_strdup(outputBuffer.outputText); //COPY
|
||||
|
||||
why2_deallocate_output(outputBuffer); //DEALLOCATE outputBuffer
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user