Merge pull request #156 from gm4tr1x/master
[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 typedef void *OCL_LIB;
50
51 #ifdef HAVE_HWMON
52 typedef void *HM_LIB;
53 #endif
54
55 #endif // _POSIX
56
57 #ifdef _WIN
58 #define WIN32_LEAN_AND_MEAN
59 #include <windows.h>
60 #include <process.h>
61 #include <conio.h>
62 #include <tchar.h>
63 #include <psapi.h>
64 #include <io.h>
65 #include <fcntl.h>
66
67 typedef UINT8 uint8_t;
68 typedef UINT16 uint16_t;
69 typedef UINT32 uint32_t;
70 typedef UINT64 uint64_t;
71 typedef INT8 int8_t;
72 typedef INT16 int16_t;
73 typedef INT32 int32_t;
74 typedef INT64 int64_t;
75
76 typedef UINT32 uint;
77 typedef UINT64 uint64_t;
78
79 #ifdef HAVE_HWMON
80 typedef HINSTANCE HM_LIB;
81 #endif
82
83 typedef HINSTANCE OCL_LIB;
84
85 #define mkdir(name,mode) mkdir (name)
86
87 #endif // _WIN
88
89 typedef uint8_t u8;
90 typedef uint16_t u16;
91 typedef uint32_t u32;
92 typedef uint64_t u64;
93
94 typedef uint32_t uint; // we need to get rid of this sooner or later, for consistency
95
96 #define SPEED_CACHE 128
97 #define SPEED_MAXAGE 4096
98
99 #undef BUFSIZ
100 #define BUFSIZ 8192
101
102 /**
103 * functions
104 */
105
106 void log_out_nn (FILE *fp, const char *fmt, ...);
107 void log_info_nn (const char *fmt, ...);
108 void log_error_nn (const char *fmt, ...);
109
110 void log_out (FILE *fp, const char *fmt, ...);
111 void log_info (const char *fmt, ...);
112 void log_error (const char *fmt, ...);
113
114 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
115 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
116
117 #endif // COMMON_H