-
Notifications
You must be signed in to change notification settings - Fork 16
/
platform.h.in
153 lines (129 loc) · 3.07 KB
/
platform.h.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#ifndef __PLATFORM_H
#define __PLATFORM_H
#ifdef _WIN32
#include <winsock2.h>
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <io.h>
#include <fcntl.h>
#include <direct.h>
#include <Ws2tcpip.h>
#include <process.h>
#ifdef __cplusplus
extern "C" {
#endif
#include "gettimeofday.h"
#include "snprintf.h"
#include "net.h"
#include "w32_errno.h"
#include "w32_stat.h"
#include "random.h"
#include "utf8_util.h"
#ifdef __cplusplus
}
#else
typedef unsigned short mode_t;
#endif
#define strcasecmp lstrcmpi
#define strncasecmp strnicmp
#define mkdir(path, mode) mkdir(path)
#define sleep(sex) Sleep(1000 * (sex))
#define getuid() 0
#define getgid() 0
char *strptime(const char *s, const char *format, struct tm *tm);
#define srand w32_srand
#define rand w32_rand
#define socket w32_socket
#define getsockopt w32_getsockopt
#define setsockopt w32_setsockopt
#define bind w32_bind
#define listen w32_listen
#define accept w32_accept
#define connect w32_connect
#define shutdown w32_shutdown
#define send w32_send
#define recv w32_recv
#define closesocket w32_closesocket
#define getservbyname w32_getservbyname
#define getaddrinfo w32_getaddrinfo
#ifdef gai_strerror
#undef gai_strerror
#endif
#define gai_strerror w32_strerror
#define freeaddrinfo w32_freeaddrinfo
#define inet_ntop w32_inet_ntop
#define inet_ntoa w32_inet_ntoa
#define getpeername w32_getpeername
#define select w32_select
#define poll w32_poll
#define strerror w32_strerror
#define strerror_r w32_strerror_r
#define ftruncate _chsize
#define getpid GetCurrentProcessId
#define PATH_MAX 32767
#define WORDS_BIGENDIAN 0
#define EAI_SYSTEM 0
#else
#define closesocket(s) close(s)
#define cli_to_utf8_maybe_alloc(x) (x)
#define cli_strdup_to_utf8(x) strdup(x)
#endif
#ifndef O_BINARY
#define O_BINARY 0
#endif
#ifndef FALSE
#define FALSE (0)
#endif
#ifndef TRUE
#define TRUE (1)
#endif
#ifndef MIN
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#endif
#ifndef MAX
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef HAVE_IN_PORT_T
typedef unsigned short in_port_t;
#endif
#ifndef HAVE_IN_ADDR_T
typedef unsigned int in_addr_t;
#endif
#ifdef _WIN32
#define PATHSEP "\\"
#else
#define PATHSEP "/"
#endif
#ifndef _WIN32
#define CONFDIR_CLAMD CONFDIR PATHSEP "clamd.conf"
#define CONFDIR_FRESHCLAM CONFDIR PATHSEP "freshclam.conf"
#define CONFDIR_MILTER CONFDIR PATHSEP "clamav-milter.conf"
#endif
#ifndef WORDS_BIGENDIAN
#define WORDS_BIGENDIAN 0
#endif
#ifdef _WIN32
void w32_glob(int *argc_ptr, char ***argv_ptr);
#if !defined(THIS_IS_LIBCLAMAV) && defined(_MSC_VER)
#define LIBCLAMAV_EXPORT __declspec(dllimport)
#else
#define LIBCLAMAV_EXPORT
#endif
#undef HAVE_CONFIG_H
#ifdef OUT
#undef OUT
#endif
int real_main(int, char **);
#define main \
main(int argc, char **argv) \
{ \
_setmode(_fileno(stdin), _O_BINARY); \
w32_glob(&argc, &argv); \
return real_main(argc, argv); \
}; \
int real_main
#else
#define LIBCLAMAV_EXPORT
#endif
#endif /* __PLATFORM_H */