Code clean-up.
This commit is contained in:
parent
2c42cf5f92
commit
698f4fa3c9
@ -101,7 +101,7 @@ static int encrypt(const char* const passphrase, const CHR* const input, const C
|
||||
goto clean_up;
|
||||
}
|
||||
|
||||
FPRINTF(stderr, T("Encrypting, please be patient... %5.1f%%"), 0.0);
|
||||
FPRINTF(stderr, T("Encrypting file contents, please be patient... %5.1f%%"), 0.0);
|
||||
|
||||
clock_t clk_now, clk_update = clock();
|
||||
uint64_t crc_actual = CRC_INITIALIZER, bytes_read = sizeof(uint64_t);
|
||||
@ -216,7 +216,7 @@ static int decrypt(const char* const passphrase, const CHR* const input, const C
|
||||
goto clean_up;
|
||||
}
|
||||
|
||||
FPRINTF(stderr, T("Decrypting, please be patient... %5.1f%%"), 0.0);
|
||||
FPRINTF(stderr, T("Decrypting file contents, please be patient... %5.1f%%"), 0.0);
|
||||
|
||||
clock_t clk_now, clk_update = clock();
|
||||
uint64_t crc_actual = CRC_INITIALIZER, bytes_read = sizeof(uint64_t);
|
||||
@ -309,7 +309,7 @@ int MAIN(int argc, CHR* argv[])
|
||||
{
|
||||
init_terminal();
|
||||
|
||||
FPRINTF(stderr, T("MCrypt Utility (%") T(PRIstr) T("-%") T(PRIstr) T("), by LoRd_MuldeR <mulder2@gmx.de>\n"), OS_TYPE, CPU_ARCH);
|
||||
FPRINTF(stderr, T("MCrypt Utility (%") T(PRIstr) T("-%") T(PRIstr) T("), by LoRd_MuldeR <MuldeR2@GMX.de>\n"), OS_TYPE, CPU_ARCH);
|
||||
FPRINTF(stderr, T("Using libMCrypt v%") T(PRIstr) T(" [%") T(PRIstr) T("]\n\n"), LIBMCRYPT_VERSION, LIBMCRYPT_BUILDNO);
|
||||
|
||||
const int help_requested = (argc > 1) && ((!STRICMP(argv[1U], T("/?"))) || (!STRICMP(argv[1U], T("--help"))) || (!STRICMP(argv[1U], T("--version"))));
|
||||
@ -326,7 +326,7 @@ int MAIN(int argc, CHR* argv[])
|
||||
FPUTS(T("Usage:\n"), stderr);
|
||||
FPRINTF(stderr, T(" %") T(PRISTR) T(" --encrypt <passphrase> <input.txt> <output.enc>\n"), argv[0U]);
|
||||
FPRINTF(stderr, T(" %") T(PRISTR) T(" --decrypt <passphrase> <input.enc> <output.txt>\n\n"), argv[0U]);
|
||||
return 1;
|
||||
return help_requested ? 0 : 1;
|
||||
}
|
||||
|
||||
const CHR *const command = argv[1U], *const passphrase = argv[2U], *const input_file = argv[3U], *const output_file = argv[4U];
|
||||
@ -385,6 +385,11 @@ int MAIN(int argc, CHR* argv[])
|
||||
|
||||
exiting:
|
||||
|
||||
free_utf8(passphrase_utf8);
|
||||
if (passphrase_utf8)
|
||||
{
|
||||
mcrypt_bzero(passphrase_utf8, strlen(passphrase_utf8));
|
||||
free(passphrase_utf8);
|
||||
}
|
||||
|
||||
mcrypt_bzero((CHR*)passphrase, STRLEN(passphrase) * sizeof(CHR));
|
||||
}
|
||||
|
@ -6,6 +6,13 @@
|
||||
#ifndef INC_PLATFORM_H
|
||||
#define INC_PLATFORM_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#ifdef _WIN32
|
||||
#include <share.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#define OS_TYPE "Win"
|
||||
#else
|
||||
@ -50,7 +57,7 @@
|
||||
#define STRICMP(X,Y) _wcsicmp((X),(Y))
|
||||
#define FPUTS(X,Y) fputws((X),(Y))
|
||||
#define FPRINTF(X,Y,...) fwprintf((X),(Y),__VA_ARGS__)
|
||||
#define FOPEN(X,Y) _wfopen((X),(Y))
|
||||
#define FOPEN(X,Y) _wfsopen((X),(Y),_SH_SECURE)
|
||||
#define FILENO(X) _fileno((X))
|
||||
#define FSTAT64(X,Y) _fstati64((X),(Y))
|
||||
#define STAT64_T struct _stati64
|
||||
|
@ -12,7 +12,6 @@
|
||||
|
||||
#include "utils.h"
|
||||
#include <mcrypt.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
@ -52,18 +51,7 @@ char* CHR_to_utf8(const CHR*const input)
|
||||
free(buffer);
|
||||
return NULL;
|
||||
#else
|
||||
return input; /*nothing to do*/
|
||||
#endif
|
||||
}
|
||||
|
||||
void free_utf8(char *const str_utf8)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (str_utf8)
|
||||
{
|
||||
mcrypt_bzero(str_utf8, strlen(str_utf8));
|
||||
free(str_utf8);
|
||||
}
|
||||
return strdup(input);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -6,13 +6,10 @@
|
||||
#ifndef INC_UTILS_H
|
||||
#define INC_UTILS_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include "platform.h"
|
||||
#include <stdint.h>
|
||||
|
||||
char* CHR_to_utf8(const CHR *const input);
|
||||
void free_utf8(char* const str_utf8);
|
||||
uint64_t get_file_size(FILE* const file);
|
||||
void init_terminal(void);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user