c84363a4fdea3ed173b15aaf988c1c84e5654282
[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 #include <fcntl.h>
32
33 #ifdef _POSIX
34 #include <sys/time.h>
35 #include <pthread.h>
36 #include <semaphore.h>
37 #include <dlfcn.h>
38 #include <pwd.h>
39
40 #ifdef LINUX
41 #include <termio.h>
42 #endif
43
44 #ifdef OSX
45 #include <termios.h>
46 #include <sys/ioctl.h>
47 #include <mach-o/dyld.h>
48 #endif
49
50 typedef void *OCL_LIB;
51
52 #ifdef HAVE_HWMON
53 typedef void *NV_LIB;
54 typedef void *AMD_LIB;
55 #ifdef OSX
56 #define __stdcall
57 #endif
58 #endif
59
60 #endif // _POSIX
61
62 #ifdef _WIN
63 #define WIN32_LEAN_AND_MEAN
64 #include <windows.h>
65 #include <process.h>
66 #include <conio.h>
67 #include <tchar.h>
68 #include <psapi.h>
69 #include <io.h>
70
71 typedef UINT8 uint8_t;
72 typedef UINT16 uint16_t;
73 typedef UINT32 uint32_t;
74 typedef UINT64 uint64_t;
75 typedef INT8 int8_t;
76 typedef INT16 int16_t;
77 typedef INT32 int32_t;
78 typedef INT64 int64_t;
79
80 typedef UINT32 uint;
81 typedef UINT64 uint64_t;
82
83 typedef HINSTANCE OCL_LIB;
84
85 #ifdef HAVE_HWMON
86 typedef HINSTANCE NV_LIB;
87 typedef HINSTANCE AMD_LIB;
88 #endif
89
90 #define mkdir(name,mode) mkdir (name)
91
92 #endif // _WIN
93
94 typedef uint8_t u8;
95 typedef uint16_t u16;
96 typedef uint32_t u32;
97 typedef uint64_t u64;
98
99 typedef uint32_t uint; // we need to get rid of this sooner or later, for consistency
100
101 #define SPEED_CACHE 128
102 #define SPEED_MAXAGE 4096
103
104 #undef BUFSIZ
105 #define BUFSIZ 8192
106
107 /**
108 * functions
109 */
110
111 void log_out_nn (FILE *fp, const char *fmt, ...);
112 void log_info_nn (const char *fmt, ...);
113 void log_error_nn (const char *fmt, ...);
114
115 void log_out (FILE *fp, const char *fmt, ...);
116 void log_info (const char *fmt, ...);
117 void log_error (const char *fmt, ...);
118
119 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
120 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
121
122 #endif // COMMON_H