Small improvement to platform detection.
This commit is contained in:
parent
70e9d2d3b5
commit
50955210ac
@ -157,7 +157,7 @@ int MAIN(const int argc, CHR *const argv[])
|
|||||||
init_terminal();
|
init_terminal();
|
||||||
setup_signal_handler(SIGINT, sigint_handler);
|
setup_signal_handler(SIGINT, sigint_handler);
|
||||||
|
|
||||||
FPRINTF(stderr, T("SlunkCrypt Utility (%") T(PRIstr) T("-%") T(PRIstr) T("), by LoRd_MuldeR <MuldeR2@GMX.de>\n"), OS_TYPE, CPU_ARCH);
|
FPRINTF(stderr, T("SlunkCrypt Utility (%") T(PRIstr) T("-%") T(PRIstr) T("), by LoRd_MuldeR <MuldeR2@GMX.de>\n"), OS_TYPE_NAME, CPU_ARCH);
|
||||||
FPRINTF(stderr, T("Using libSlunkCrypt v%u.%u.%u [%") T(PRIstr) T("]\n\n"), SLUNKCRYPT_VERSION_MAJOR, SLUNKCRYPT_VERSION_MINOR, SLUNKCRYPT_VERSION_PATCH, SLUNKCRYPT_BUILD);
|
FPRINTF(stderr, T("Using libSlunkCrypt v%u.%u.%u [%") T(PRIstr) T("]\n\n"), SLUNKCRYPT_VERSION_MAJOR, SLUNKCRYPT_VERSION_MINOR, SLUNKCRYPT_VERSION_PATCH, SLUNKCRYPT_BUILD);
|
||||||
|
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
|
@ -10,94 +10,105 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
# include <share.h>
|
# include <share.h>
|
||||||
# ifndef _SH_SECURE
|
# ifndef _SH_SECURE
|
||||||
# define _SH_SECURE 0x80
|
# define _SH_SECURE 0x80
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN32)
|
/* Detect operating system type */
|
||||||
# define OS_TYPE "Windows"
|
#if defined(__MINGW32__)
|
||||||
|
# define OS_TYPE_NAME "MinGW32"
|
||||||
|
#elif defined(_WIN32)
|
||||||
|
# define OS_TYPE_NAME "Windows"
|
||||||
#elif defined(__CYGWIN__)
|
#elif defined(__CYGWIN__)
|
||||||
# define OS_TYPE "Cygwin"
|
# define OS_TYPE_NAME "Cygwin"
|
||||||
#elif defined(__linux__)
|
#elif defined(__linux__)
|
||||||
# define OS_TYPE "Linux"
|
# define OS_TYPE_NAME "Linux"
|
||||||
#elif defined(__FreeBSD__)
|
#elif defined(__FreeBSD__)
|
||||||
# define OS_TYPE "FreeBSD"
|
# define OS_TYPE_NAME "FreeBSD"
|
||||||
|
#elif defined(__DragonFly__)
|
||||||
|
# define OS_TYPE_NAME "DragonFly"
|
||||||
#elif defined(__NetBSD__)
|
#elif defined(__NetBSD__)
|
||||||
# define OS_TYPE "NetBSD"
|
# define OS_TYPE_NAME "NetBSD"
|
||||||
#elif defined(__OpenBSD__)
|
#elif defined(__OpenBSD__)
|
||||||
# define OS_TYPE "OpenBSD"
|
# define OS_TYPE_NAME "OpenBSD"
|
||||||
#elif defined(__sun)
|
#elif defined(__sun) && defined(__SVR4)
|
||||||
# define OS_TYPE "Solaris"
|
# define OS_TYPE_NAME "Solaris"
|
||||||
|
#elif defined(__QNX__)
|
||||||
|
# define OS_TYPE_NAME "QNX"
|
||||||
|
#elif defined(__APPLE__) && defined(__MACH__)
|
||||||
|
# define OS_TYPE_NAME "macOS"
|
||||||
#elif defined(__unix__)
|
#elif defined(__unix__)
|
||||||
# define OS_TYPE "Unix"
|
# define OS_TYPE_NAME "Unix"
|
||||||
#else
|
#else
|
||||||
# error Unknown operating system!
|
# error Unknown operating system!
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Detect CPU architecture */
|
||||||
#if defined(__x86_64__) || defined(_M_X64)
|
#if defined(__x86_64__) || defined(_M_X64)
|
||||||
# define CPU_ARCH "x64"
|
# define CPU_ARCH "x64"
|
||||||
#elif defined(__i386__) || defined(_M_IX86)
|
#elif defined(__i386__) || defined(_M_IX86)
|
||||||
# define CPU_ARCH "x86"
|
# define CPU_ARCH "x86"
|
||||||
#elif defined(__aarch64__) || defined(_M_ARM64)
|
#elif defined(__aarch64__) || defined(_M_ARM64)
|
||||||
# define CPU_ARCH "arm64"
|
# define CPU_ARCH "arm64"
|
||||||
#elif defined(__arm__) || defined(_M_ARM)
|
#elif defined(__arm__) || defined(_M_ARM)
|
||||||
# define CPU_ARCH "arm"
|
# define CPU_ARCH "arm"
|
||||||
#else
|
#else
|
||||||
# error Unknown CPU architecture!
|
# error Unknown CPU architecture!
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Platform-specific quirks */
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
# define MAIN wmain
|
# define MAIN wmain
|
||||||
# define CHR wchar_t
|
# define CHR wchar_t
|
||||||
# define _T(X) L##X
|
# define _T(X) L##X
|
||||||
# define GETENV(X) _wgetenv((X))
|
# define GETENV(X) _wgetenv((X))
|
||||||
# define STRLEN(X) wcslen((X))
|
# define STRLEN(X) wcslen((X))
|
||||||
# define STRICMP(X,Y) _wcsicmp((X),(Y))
|
# define STRICMP(X,Y) _wcsicmp((X),(Y))
|
||||||
# define STRNICMP(X,Y,Z) _wcsnicmp((X),(Y),(Z))
|
# define STRNICMP(X,Y,Z) _wcsnicmp((X),(Y),(Z))
|
||||||
# define STRRCHR(X,Y) wcsrchr((X),(Y))
|
# define STRRCHR(X,Y) wcsrchr((X),(Y))
|
||||||
# define STRTOUL(X) wcstoul((X), NULL, 0)
|
# define STRTOUL(X) wcstoul((X), NULL, 0)
|
||||||
# define STRDUP(X) _wcsdup((X))
|
# define STRDUP(X) _wcsdup((X))
|
||||||
# define FPUTS(X,Y) fputws((X),(Y))
|
# define FPUTS(X,Y) fputws((X),(Y))
|
||||||
# define FPRINTF(X,Y,...) fwprintf((X),(Y),__VA_ARGS__)
|
# define FPRINTF(X,Y,...) fwprintf((X),(Y),__VA_ARGS__)
|
||||||
# define REMOVE(X) _wremove((X))
|
# define REMOVE(X) _wremove((X))
|
||||||
# define FOPEN(X,Y) _wfsopen((X),(Y),_SH_SECURE)
|
# define FOPEN(X,Y) _wfsopen((X),(Y),_SH_SECURE)
|
||||||
# define STRERROR(X) _wcserror((X))
|
# define STRERROR(X) _wcserror((X))
|
||||||
# ifdef __USE_MINGW_ANSI_STDIO
|
# ifdef __USE_MINGW_ANSI_STDIO
|
||||||
# define PRISTR "ls"
|
# define PRISTR "ls"
|
||||||
# define PRIstr "hs"
|
# define PRIstr "hs"
|
||||||
# define PRIwcs "ls"
|
# define PRIwcs "ls"
|
||||||
# else
|
# else
|
||||||
# define PRISTR "s"
|
# define PRISTR "s"
|
||||||
# define PRIstr "S"
|
# define PRIstr "S"
|
||||||
# define PRIwcs "s"
|
# define PRIwcs "s"
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
# define MAIN main
|
# define MAIN main
|
||||||
# define CHR char
|
# define CHR char
|
||||||
# define _T(X) X
|
# define _T(X) X
|
||||||
# define GETENV(X) getenv((X))
|
# define GETENV(X) getenv((X))
|
||||||
# define STRLEN(X) strlen((X))
|
# define STRLEN(X) strlen((X))
|
||||||
# define STRICMP(X,Y) strcasecmp((X),(Y))
|
# define STRICMP(X,Y) strcasecmp((X),(Y))
|
||||||
# define STRNICMP(X,Y,Z) strncasecmp((X),(Y),(Z))
|
# define STRNICMP(X,Y,Z) strncasecmp((X),(Y),(Z))
|
||||||
# define STRRCHR(X,Y) strrchr((X),(Y))
|
# define STRRCHR(X,Y) strrchr((X),(Y))
|
||||||
# define STRTOUL(X) strtoul((X), NULL, 0)
|
# define STRTOUL(X) strtoul((X), NULL, 0)
|
||||||
# define STRDUP(X) strdup((X))
|
# define STRDUP(X) strdup((X))
|
||||||
# define FPUTS(X,Y) fputs((X),(Y))
|
# define FPUTS(X,Y) fputs((X),(Y))
|
||||||
# define FPRINTF(X,Y,...) fprintf((X),(Y),__VA_ARGS__)
|
# define FPRINTF(X,Y,...) fprintf((X),(Y),__VA_ARGS__)
|
||||||
# define REMOVE(X) remove((X))
|
# define REMOVE(X) remove((X))
|
||||||
# define FOPEN(X,Y) fopen((X),(Y))
|
# define FOPEN(X,Y) fopen((X),(Y))
|
||||||
# define STRERROR(X) strerror((X))
|
# define STRERROR(X) strerror((X))
|
||||||
# define PRISTR "s"
|
# define PRISTR "s"
|
||||||
# define PRIstr "s"
|
# define PRIstr "s"
|
||||||
# define PRIwcs "ls"
|
# define PRIwcs "ls"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define T(X) _T(X)
|
#define T(X) _T(X)
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
# define strdup(X) _strdup((X))
|
# define strdup(X) _strdup((X))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user