Added support for build without ADL/NVML/NVAPI (issue #120)
[hashcat.git] / include / common.h
1 /**
2 * Author......: Jens Steube <jens.steube@gmail.com>
3 * License.....: MIT
4 */
5
6 #ifndef COMMON_H
7 #define COMMON_H
8
9 #define _POSIX_SOURCE
10 #define _GNU_SOURCE
11 #define _FILE_OFFSET_BITS 64
12 #define _CRT_SECURE_NO_WARNINGS
13
14 #include <stdarg.h>
15 #include <stdint.h>
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <stdbool.h>
19 #include <string.h>
20 #include <errno.h>
21 #include <getopt.h>
22 #include <math.h>
23 #include <ctype.h>
24 #include <dirent.h>
25 #include <time.h>
26 #include <unistd.h>
27 #include <signal.h>
28 #include <sys/stat.h>
29 #include <sys/types.h>
30 #include <search.h>
31
32 #ifdef _POSIX
33 #include <sys/time.h>
34 #include <pthread.h>
35 #include <semaphore.h>
36 #include <dlfcn.h>
37 #include <pwd.h>
38
39 #ifdef LINUX
40 #include <termio.h>
41 #endif
42
43 #ifdef OSX
44 #include <termios.h>
45 #include <sys/ioctl.h>
46 #include <mach-o/dyld.h>
47 #endif
48
49 #ifdef HAVE_HWMON
50 typedef void *HM_LIB;
51 #endif
52
53 #endif // _POSIX
54
55 #ifdef _WIN
56 #define WIN32_LEAN_AND_MEAN
57 #include <windows.h>
58 #include <process.h>
59 #include <conio.h>
60 #include <tchar.h>
61 #include <psapi.h>
62 #include <io.h>
63 #include <fcntl.h>
64
65 typedef UINT8 uint8_t;
66 typedef UINT16 uint16_t;
67 typedef UINT32 uint32_t;
68 typedef UINT64 uint64_t;
69 typedef INT8 int8_t;
70 typedef INT16 int16_t;
71 typedef INT32 int32_t;
72 typedef INT64 int64_t;
73
74 typedef UINT32 uint;
75 typedef UINT64 uint64_t;
76
77 #ifdef HAVE_HWMON
78 typedef HINSTANCE HM_LIB;
79 #endif
80
81 #define mkdir(name,mode) mkdir (name)
82
83 #endif // _WIN
84
85 typedef uint8_t u8;
86 typedef uint16_t u16;
87 typedef uint32_t u32;
88 typedef uint64_t u64;
89
90 typedef uint32_t uint; // we need to get rid of this sooner or later, for consistency
91
92 #define SPEED_CACHE 128
93 #define SPEED_MAXAGE 4096
94
95 #undef BUFSIZ
96 #define BUFSIZ 8192
97
98 /**
99 * functions
100 */
101
102 void log_out_nn (FILE *fp, const char *fmt, ...);
103 void log_info_nn (const char *fmt, ...);
104 void log_error_nn (const char *fmt, ...);
105
106 void log_out (FILE *fp, const char *fmt, ...);
107 void log_info (const char *fmt, ...);
108 void log_error (const char *fmt, ...);
109
110 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
111 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
112
113 #endif // COMMON_H