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();
|
||||
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);
|
||||
|
||||
fflush(stderr);
|
||||
|
@ -10,94 +10,105 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#ifdef _WIN32
|
||||
# include <share.h>
|
||||
# ifndef _SH_SECURE
|
||||
# define _SH_SECURE 0x80
|
||||
# endif
|
||||
# include <share.h>
|
||||
# ifndef _SH_SECURE
|
||||
# define _SH_SECURE 0x80
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
# define OS_TYPE "Windows"
|
||||
/* Detect operating system type */
|
||||
#if defined(__MINGW32__)
|
||||
# define OS_TYPE_NAME "MinGW32"
|
||||
#elif defined(_WIN32)
|
||||
# define OS_TYPE_NAME "Windows"
|
||||
#elif defined(__CYGWIN__)
|
||||
# define OS_TYPE "Cygwin"
|
||||
# define OS_TYPE_NAME "Cygwin"
|
||||
#elif defined(__linux__)
|
||||
# define OS_TYPE "Linux"
|
||||
# define OS_TYPE_NAME "Linux"
|
||||
#elif defined(__FreeBSD__)
|
||||
# define OS_TYPE "FreeBSD"
|
||||
# define OS_TYPE_NAME "FreeBSD"
|
||||
#elif defined(__DragonFly__)
|
||||
# define OS_TYPE_NAME "DragonFly"
|
||||
#elif defined(__NetBSD__)
|
||||
# define OS_TYPE "NetBSD"
|
||||
# define OS_TYPE_NAME "NetBSD"
|
||||
#elif defined(__OpenBSD__)
|
||||
# define OS_TYPE "OpenBSD"
|
||||
#elif defined(__sun)
|
||||
# define OS_TYPE "Solaris"
|
||||
# define OS_TYPE_NAME "OpenBSD"
|
||||
#elif defined(__sun) && defined(__SVR4)
|
||||
# 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__)
|
||||
# define OS_TYPE "Unix"
|
||||
# define OS_TYPE_NAME "Unix"
|
||||
#else
|
||||
# error Unknown operating system!
|
||||
# error Unknown operating system!
|
||||
#endif
|
||||
|
||||
/* Detect CPU architecture */
|
||||
#if defined(__x86_64__) || defined(_M_X64)
|
||||
# define CPU_ARCH "x64"
|
||||
# define CPU_ARCH "x64"
|
||||
#elif defined(__i386__) || defined(_M_IX86)
|
||||
# define CPU_ARCH "x86"
|
||||
# define CPU_ARCH "x86"
|
||||
#elif defined(__aarch64__) || defined(_M_ARM64)
|
||||
# define CPU_ARCH "arm64"
|
||||
# define CPU_ARCH "arm64"
|
||||
#elif defined(__arm__) || defined(_M_ARM)
|
||||
# define CPU_ARCH "arm"
|
||||
# define CPU_ARCH "arm"
|
||||
#else
|
||||
# error Unknown CPU architecture!
|
||||
# error Unknown CPU architecture!
|
||||
#endif
|
||||
|
||||
/* Platform-specific quirks */
|
||||
#ifdef _WIN32
|
||||
# define MAIN wmain
|
||||
# define CHR wchar_t
|
||||
# define _T(X) L##X
|
||||
# define GETENV(X) _wgetenv((X))
|
||||
# define STRLEN(X) wcslen((X))
|
||||
# define STRICMP(X,Y) _wcsicmp((X),(Y))
|
||||
# define STRNICMP(X,Y,Z) _wcsnicmp((X),(Y),(Z))
|
||||
# define STRRCHR(X,Y) wcsrchr((X),(Y))
|
||||
# define STRTOUL(X) wcstoul((X), NULL, 0)
|
||||
# define STRDUP(X) _wcsdup((X))
|
||||
# define FPUTS(X,Y) fputws((X),(Y))
|
||||
# define FPRINTF(X,Y,...) fwprintf((X),(Y),__VA_ARGS__)
|
||||
# define REMOVE(X) _wremove((X))
|
||||
# define FOPEN(X,Y) _wfsopen((X),(Y),_SH_SECURE)
|
||||
# define STRERROR(X) _wcserror((X))
|
||||
# ifdef __USE_MINGW_ANSI_STDIO
|
||||
# define PRISTR "ls"
|
||||
# define PRIstr "hs"
|
||||
# define PRIwcs "ls"
|
||||
# else
|
||||
# define PRISTR "s"
|
||||
# define PRIstr "S"
|
||||
# define PRIwcs "s"
|
||||
# endif
|
||||
# define MAIN wmain
|
||||
# define CHR wchar_t
|
||||
# define _T(X) L##X
|
||||
# define GETENV(X) _wgetenv((X))
|
||||
# define STRLEN(X) wcslen((X))
|
||||
# define STRICMP(X,Y) _wcsicmp((X),(Y))
|
||||
# define STRNICMP(X,Y,Z) _wcsnicmp((X),(Y),(Z))
|
||||
# define STRRCHR(X,Y) wcsrchr((X),(Y))
|
||||
# define STRTOUL(X) wcstoul((X), NULL, 0)
|
||||
# define STRDUP(X) _wcsdup((X))
|
||||
# define FPUTS(X,Y) fputws((X),(Y))
|
||||
# define FPRINTF(X,Y,...) fwprintf((X),(Y),__VA_ARGS__)
|
||||
# define REMOVE(X) _wremove((X))
|
||||
# define FOPEN(X,Y) _wfsopen((X),(Y),_SH_SECURE)
|
||||
# define STRERROR(X) _wcserror((X))
|
||||
# ifdef __USE_MINGW_ANSI_STDIO
|
||||
# define PRISTR "ls"
|
||||
# define PRIstr "hs"
|
||||
# define PRIwcs "ls"
|
||||
# else
|
||||
# define PRISTR "s"
|
||||
# define PRIstr "S"
|
||||
# define PRIwcs "s"
|
||||
# endif
|
||||
#else
|
||||
# define MAIN main
|
||||
# define CHR char
|
||||
# define _T(X) X
|
||||
# define GETENV(X) getenv((X))
|
||||
# define STRLEN(X) strlen((X))
|
||||
# define STRICMP(X,Y) strcasecmp((X),(Y))
|
||||
# define STRNICMP(X,Y,Z) strncasecmp((X),(Y),(Z))
|
||||
# define STRRCHR(X,Y) strrchr((X),(Y))
|
||||
# define STRTOUL(X) strtoul((X), NULL, 0)
|
||||
# define STRDUP(X) strdup((X))
|
||||
# define FPUTS(X,Y) fputs((X),(Y))
|
||||
# define FPRINTF(X,Y,...) fprintf((X),(Y),__VA_ARGS__)
|
||||
# define REMOVE(X) remove((X))
|
||||
# define FOPEN(X,Y) fopen((X),(Y))
|
||||
# define STRERROR(X) strerror((X))
|
||||
# define PRISTR "s"
|
||||
# define PRIstr "s"
|
||||
# define PRIwcs "ls"
|
||||
# define MAIN main
|
||||
# define CHR char
|
||||
# define _T(X) X
|
||||
# define GETENV(X) getenv((X))
|
||||
# define STRLEN(X) strlen((X))
|
||||
# define STRICMP(X,Y) strcasecmp((X),(Y))
|
||||
# define STRNICMP(X,Y,Z) strncasecmp((X),(Y),(Z))
|
||||
# define STRRCHR(X,Y) strrchr((X),(Y))
|
||||
# define STRTOUL(X) strtoul((X), NULL, 0)
|
||||
# define STRDUP(X) strdup((X))
|
||||
# define FPUTS(X,Y) fputs((X),(Y))
|
||||
# define FPRINTF(X,Y,...) fprintf((X),(Y),__VA_ARGS__)
|
||||
# define REMOVE(X) remove((X))
|
||||
# define FOPEN(X,Y) fopen((X),(Y))
|
||||
# define STRERROR(X) strerror((X))
|
||||
# define PRISTR "s"
|
||||
# define PRIstr "s"
|
||||
# define PRIwcs "ls"
|
||||
#endif
|
||||
|
||||
#define T(X) _T(X)
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# define strdup(X) _strdup((X))
|
||||
# define strdup(X) _strdup((X))
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user