Linux build fix.

This commit is contained in:
LoRd_MuldeR 2020-10-13 17:51:09 +02:00
parent 7a95a1a561
commit 3d5b480e70
Signed by: mulder
GPG Key ID: 2B5913365F57E03F
2 changed files with 20 additions and 9 deletions

View File

@ -49,10 +49,10 @@ static int weak_passphrase(const CHR *str)
while (*str)
{
const CHR c = *str++;
if (iswupper(c)) flags[0U] = 1;
else if (iswlower(c)) flags[1U] = 1;
else if (iswdigit(c)) flags[2U] = 1;
else if (iswgraph(c)) flags[3U] = 1;
if (ISUPPER(c)) flags[0U] = 1;
else if (ISLOWER(c)) flags[1U] = 1;
else if (ISDIGIT(c)) flags[2U] = 1;
else if (ISGRAPH(c)) flags[3U] = 1;
}
const int strong = flags[0U] && flags[1U] && flags[2U] && flags[3U];
return !strong;
@ -66,11 +66,11 @@ static int encrypt(const CHR* const passphrase, const CHR* const input, const CH
if (STRLEN(passphrase) < 8U)
{
FPUTS(L"Warning: Using a short passphrase. Eight characters or more are recommended!\n\n", stderr);
FPUTS(T("Warning: Using a short passphrase. Eight characters or more are recommended!\n\n"), stderr);
}
else if (weak_passphrase(passphrase))
{
FPUTS(L"Warning: Using a weak passphrase. A mix of upper-case characters, lower-case characters, digits and 'special' characters is recommended!\n\n", stderr);
FPUTS(T("Warning: Using a weak passphrase. A mix of upper-case characters, lower-case characters, digits and 'special' characters is recommended!\n\n"), stderr);
}
char *const passphrase_utf8 = utf16_to_bytes(passphrase, CP_UTF8);
@ -354,8 +354,8 @@ int MAIN(int argc, CHR* argv[])
FPUTS(T("Nothing to do!\n\n"), stderr);
}
FPUTS(T("Usage:\n"), stderr);
FPRINTF(stderr, T(" %") T(PRIwcs) T(" --encrypt <passphrase> <input.txt> <output.enc>\n"), argv[0U]);
FPRINTF(stderr, T(" %") T(PRIwcs) T(" --decrypt <passphrase> <input.enc> <output.txt>\n\n"), argv[0U]);
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;
}
@ -378,7 +378,7 @@ int MAIN(int argc, CHR* argv[])
}
else
{
FPRINTF(stderr, T("Error: Command \"%") T(PRIwcs) T("\" is unknown!\n\n"), argv[1U]);
FPRINTF(stderr, T("Error: Command \"%") T(PRISTR) T("\" is unknown!\n\n"), argv[1U]);
erase(argv[2U], STRLEN(argv[2U]) * sizeof(CHR));
return 1;
}

View File

@ -18,10 +18,16 @@
#define FILENO(X) _fileno((X))
#define FSTAT64(X,Y) _fstati64((X),(Y))
#define STAT64_T struct _stati64
#define ISUPPER(X) iswupper((X))
#define ISLOWER(X) iswlower((X))
#define ISDIGIT(X) iswdigit((X))
#define ISGRAPH(X) iswgraph((X))
#ifdef __MINGW32__
#define PRISTR "ls"
#define PRIstr "hs"
#define PRIwcs "ls"
#else
#define PRISTR "s"
#define PRIstr "S"
#define PRIwcs "s"
#endif
@ -37,6 +43,11 @@
#define FILENO(X) fileno((X))
#define FSTAT64(X,Y) fstat64((X),(Y))
#define STAT64_T struct stat64
#define ISUPPER(X) isupper((X))
#define ISLOWER(X) islower((X))
#define ISDIGIT(X) isdigit((X))
#define ISGRAPH(X) isgraph((X))
#define PRISTR "s"
#define PRIstr "s"
#define PRIwcs "ls"
#endif