1 /******************************************************************************/
2 /* SlunkCrypt, by LoRd_MuldeR <MuldeR2@GMX.de> */
3 /* This work has been released under the CC0 1.0 Universal license! */
4 /******************************************************************************/
15 # define _SH_SECURE 0x80
19 /* Detect operating system type */
20 #if defined(__MINGW32__)
21 # define OS_TYPE_NAME "MinGW32"
23 # define OS_TYPE_NAME "Windows"
24 #elif defined(__CYGWIN__)
25 # define OS_TYPE_NAME "Cygwin"
26 #elif defined(__linux__)
27 # define OS_TYPE_NAME "Linux"
28 #elif defined(__FreeBSD__)
29 # define OS_TYPE_NAME "FreeBSD"
30 #elif defined(__DragonFly__)
31 # define OS_TYPE_NAME "DragonFly"
32 #elif defined(__NetBSD__)
33 # define OS_TYPE_NAME "NetBSD"
34 #elif defined(__OpenBSD__)
35 # define OS_TYPE_NAME "OpenBSD"
36 #elif defined(__sun) && defined(__SVR4)
37 # define OS_TYPE_NAME "Solaris"
38 #elif defined(__QNX__)
39 # define OS_TYPE_NAME "QNX"
40 #elif defined(__APPLE__) && defined(__MACH__)
41 # define OS_TYPE_NAME "macOS"
42 #elif defined(__unix__)
43 # define OS_TYPE_NAME "Unix"
45 # error Unknown operating system!
48 /* Detect CPU architecture */
49 #if defined(__x86_64__) || defined(_M_X64)
50 # define CPU_ARCH "x64"
51 #elif defined(__i386__) || defined(_M_IX86)
52 # define CPU_ARCH "x86"
53 #elif defined(__aarch64__) || defined(_M_ARM64)
54 # define CPU_ARCH "arm64"
55 #elif defined(__arm__) || defined(_M_ARM)
56 # define CPU_ARCH "arm"
58 # error Unknown CPU architecture!
61 /* Platform-specific quirks */
66 # define GETENV(X) _wgetenv((X))
67 # define STRLEN(X) wcslen((X))
68 # define STRICMP(X,Y) _wcsicmp((X),(Y))
69 # define STRNICMP(X,Y,Z) _wcsnicmp((X),(Y),(Z))
70 # define STRRCHR(X,Y) wcsrchr((X),(Y))
71 # define STRTOUL(X) wcstoul((X), NULL, 0)
72 # define STRDUP(X) _wcsdup((X))
73 # define FPUTS(X,Y) fputws((X),(Y))
74 # define FPRINTF(X,Y,...) fwprintf((X),(Y),__VA_ARGS__)
75 # define REMOVE(X) _wremove((X))
76 # define FOPEN(X,Y) _wfsopen((X),(Y),_SH_SECURE)
77 # define STRERROR(X) _wcserror((X))
78 # ifdef __USE_MINGW_ANSI_STDIO
91 # define GETENV(X) getenv((X))
92 # define STRLEN(X) strlen((X))
93 # define STRICMP(X,Y) strcasecmp((X),(Y))
94 # define STRNICMP(X,Y,Z) strncasecmp((X),(Y),(Z))
95 # define STRRCHR(X,Y) strrchr((X),(Y))
96 # define STRTOUL(X) strtoul((X), NULL, 0)
97 # define STRDUP(X) strdup((X))
98 # define FPUTS(X,Y) fputs((X),(Y))
99 # define FPRINTF(X,Y,...) fprintf((X),(Y),__VA_ARGS__)
100 # define REMOVE(X) remove((X))
101 # define FOPEN(X,Y) fopen((X),(Y))
102 # define STRERROR(X) strerror((X))
111 # define strdup(X) _strdup((X))