SlunkCrypt/frontend/src/platform.h

95 lines
2.1 KiB
C

/******************************************************************************/
/* MCrypt, by LoRd_MuldeR <MuldeR2@GMX.de> */
/* This work has been released under the CC0 1.0 Universal license! */
/******************************************************************************/
#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
#ifdef __linux__
#define OS_TYPE "Linux"
#else
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
#define OS_TYPE "BSD"
#else
#if defined(__APPLE__) && defined(__MACH__)
#define OS_TYPE "macOS"
#else
#error Unknown operating system!
#endif
#endif
#endif
#endif
#if defined(__x86_64__) || defined(_M_X64)
#define CPU_ARCH "x64"
#else
#if defined(__i386__) || defined(_M_IX86)
#define CPU_ARCH "x86"
#else
#if defined(__aarch64__) || defined(_M_ARM64)
#define CPU_ARCH "arm64"
#else
#if defined(__arm__) || defined(_M_ARM)
#define CPU_ARCH "arm"
#else
#error Unknown CPU architecture!
#endif
#endif
#endif
#endif
#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 STRRCHR(X,Y) wcsrchr((X),(Y))
#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)
#ifdef __MINGW32__
#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 STRRCHR(X,Y) strrchr((X),(Y))
#define FPUTS(X,Y) fputs((X),(Y))
#define FPRINTF(X,Y,...) fprintf((X),(Y),__VA_ARGS__)
#define FOPEN(X,Y) fopen((X),(Y))
#define PRISTR "s"
#define PRIstr "s"
#define PRIwcs "ls"
#endif
#define T(X) _T(X)
#ifdef _MSC_VER
#define strdup(X) _strdup((X))
#endif
#endif