FreeBSD compile fix.

This commit is contained in:
LoRd_MuldeR 2020-10-14 17:57:40 +02:00
parent a3fd6360e1
commit 985dcfd6ee
Signed by: mulder
GPG Key ID: 2B5913365F57E03F
5 changed files with 35 additions and 35 deletions

View File

@ -148,7 +148,7 @@ static int encrypt(const char* const passphrase, const CHR* const input, const C
{
crc_actual = crc64_update(crc_actual, buffer, count);
bytes_read += count;
if (mcrypt_enc_process_inplace(ctx, buffer, count) != 0)
if (mcrypt_encrypt_inplace(ctx, buffer, count) != 0)
{
FPUTS(T("\n\nMCrypt error: Failed to encrypt data!\n\n"), stderr);
goto clean_up;
@ -270,7 +270,7 @@ static int decrypt(const char* const passphrase, const CHR* const input, const C
if (count > 0U)
{
bytes_read += count;
if (mcrypt_dec_process_inplace(ctx, buffer, count) != 0)
if (mcrypt_decrypt_inplace(ctx, buffer, count) != 0)
{
FPUTS(T("\n\nMCrypt error: Failed to decrypt data!\n\n"), stderr);
goto clean_up;
@ -351,7 +351,7 @@ static int self_test(void)
const size_t length = strlen(text_plain) + 1U;
int result = 1;
mcrypt_t ctx_enc = MCRYPT_NULL, ctx_dec = MCRYPT_NULL;
mcrypt_t ctx = MCRYPT_NULL;
FPUTS(T("Self-test is running, please be patient... "), stderr);
@ -369,14 +369,14 @@ static int self_test(void)
goto clean_up;
}
ctx_enc = mcrypt_alloc(seed, passphrase);
if (!ctx_enc)
ctx = mcrypt_alloc(seed, passphrase);
if (!ctx)
{
FPUTS(T("error!\n\nnWhoops: Failed to initialize encoder!\n\n"), stderr);
goto clean_up;
}
if (mcrypt_enc_process_inplace(ctx_enc, text_temp, length) != 0)
if (mcrypt_encrypt_inplace(ctx, (uint8_t*)text_temp, length) != 0)
{
FPUTS(T("error!\n\nWhoops: Failed to encrypt the message!\n\n"), stderr);
goto clean_up;
@ -388,14 +388,13 @@ static int self_test(void)
goto clean_up;
}
ctx_dec = mcrypt_alloc(seed, passphrase);
if (!ctx_dec)
if (mcrypt_reset(ctx, seed, passphrase) != 0)
{
FPUTS(T("error!\n\nWhoops: Failed to initialize decoder!\n\n"), stderr);
goto clean_up;
}
if (mcrypt_dec_process_inplace(ctx_dec, text_temp, length) != 0)
if (mcrypt_decrypt_inplace(ctx, (uint8_t*)text_temp, length) != 0)
{
FPUTS(T("error!\n\nWhoops: Failed to decrypt the message!\n\n"), stderr);
goto clean_up;
@ -412,14 +411,9 @@ static int self_test(void)
clean_up:
if (ctx_enc)
if (ctx)
{
mcrypt_free(ctx_enc);
}
if (ctx_dec)
{
mcrypt_free(ctx_dec);
mcrypt_free(ctx);
}
if (text_temp)

View File

@ -59,9 +59,6 @@
#define FPUTS(X,Y) fputws((X),(Y))
#define FPRINTF(X,Y,...) fwprintf((X),(Y),__VA_ARGS__)
#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
#ifdef __MINGW32__
#define PRISTR "ls"
#define PRIstr "hs"
@ -81,9 +78,6 @@
#define FPUTS(X,Y) fputs((X),(Y))
#define FPRINTF(X,Y,...) fprintf((X),(Y),__VA_ARGS__)
#define FOPEN(X,Y) fopen((X),(Y))
#define FILENO(X) fileno((X))
#define FSTAT64(X,Y) fstat64((X),(Y))
#define STAT64_T struct stat64
#define PRISTR "s"
#define PRIstr "s"
#define PRIwcs "ls"

View File

@ -7,7 +7,7 @@
#define WIN32_LEAN_AND_MEAN 1
#define _CRT_SECURE_NO_WARNINGS 1
#else
#define _LARGEFILE64_SOURCE 1
#define _GNU_SOURCE 1
#endif
#include "utils.h"
@ -18,9 +18,21 @@
#include <Windows.h>
#include <io.h>
#include <fcntl.h>
#define STAT_T struct _stati64
#define FSTAT(X,Y) _fstati64((X),(Y))
#define FILENO(X) _fileno((X))
#define S_IFMT _S_IFMT
#define S_IFDIR _S_IFDIR
#define S_IFIFO _S_IFIFO
#else
#if defined(__USE_LARGEFILE64) && (__USE_LARGEFILE64)
#define STAT_T struct stat64
#define FSTAT(X,Y) fstat64((X),(Y))
#else
#define STAT_T struct stat
#define FSTAT(X,Y) fstat((X),(Y))
#endif
#define FILENO(X) fileno((X))
#endif
void init_terminal(void)
@ -64,8 +76,8 @@ char* CHR_to_utf8(const CHR*const input)
uint64_t get_file_size(FILE* const file)
{
STAT64_T stat;
if (FSTAT64(FILENO(file), &stat) != 0)
STAT_T stat;
if (FSTAT(FILENO(file), &stat) != 0)
{
return UINT64_MAX;
}
@ -80,11 +92,11 @@ uint64_t get_file_size(FILE* const file)
const CHR* get_file_name(const CHR* path)
{
const CHR* ptr;
while (ptr = STRRCHR(path, T('/')))
while ((ptr = STRRCHR(path, T('/'))))
{
path = ptr + 1U;
}
while (ptr = STRRCHR(path, T('\\')))
while ((ptr = STRRCHR(path, T('\\'))))
{
path = ptr + 1U;
}

View File

@ -33,14 +33,14 @@ void mcrypt_free(const mcrypt_t context);
/*
* Encryption routines
*/
int mcrypt_enc_process(const mcrypt_t context, const uint8_t* const input, uint8_t* const output, size_t length);
int mcrypt_enc_process_inplace(const mcrypt_t context, uint8_t* const buffer, size_t length);
int mcrypt_encrypt(const mcrypt_t context, const uint8_t* const input, uint8_t* const output, size_t length);
int mcrypt_encrypt_inplace(const mcrypt_t context, uint8_t* const buffer, size_t length);
/*
* Decryption routines
*/
int mcrypt_dec_process(const mcrypt_t context, const uint8_t* const input, uint8_t* const output, size_t length);
int mcrypt_dec_process_inplace(const mcrypt_t context, uint8_t* const buffer, size_t length);
int mcrypt_decrypt(const mcrypt_t context, const uint8_t* const input, uint8_t* const output, size_t length);
int mcrypt_decrypt_inplace(const mcrypt_t context, uint8_t* const buffer, size_t length);
/*
* Auxiliary functions

View File

@ -209,7 +209,7 @@ int mcrypt_reset(const mcrypt_t context, const uint64_t salt, const char* const
return 0;
}
int mcrypt_enc_process(const mcrypt_t context, const uint8_t* const input, uint8_t* const output, size_t length)
int mcrypt_encrypt(const mcrypt_t context, const uint8_t* const input, uint8_t* const output, size_t length)
{
crypt_state_t* const state = (crypt_state_t*)context;
if (!state)
@ -223,7 +223,7 @@ int mcrypt_enc_process(const mcrypt_t context, const uint8_t* const input, uint8
return 0;
}
int mcrypt_enc_process_inplace(const mcrypt_t context, uint8_t* const buffer, size_t length)
int mcrypt_encrypt_inplace(const mcrypt_t context, uint8_t* const buffer, size_t length)
{
crypt_state_t* const state = (crypt_state_t*)context;
if (!state)
@ -238,7 +238,7 @@ int mcrypt_enc_process_inplace(const mcrypt_t context, uint8_t* const buffer, si
}
int mcrypt_dec_process(const mcrypt_t context, const uint8_t* const input, uint8_t* const output, size_t length)
int mcrypt_decrypt(const mcrypt_t context, const uint8_t* const input, uint8_t* const output, size_t length)
{
crypt_state_t* const state = (crypt_state_t*)context;
if (!state)
@ -252,7 +252,7 @@ int mcrypt_dec_process(const mcrypt_t context, const uint8_t* const input, uint8
return 0;
}
int mcrypt_dec_process_inplace(const mcrypt_t context, uint8_t* const buffer, size_t length)
int mcrypt_decrypt_inplace(const mcrypt_t context, uint8_t* const buffer, size_t length)
{
crypt_state_t* const state = (crypt_state_t*)context;
if (!state)