-
Notifications
You must be signed in to change notification settings - Fork 2
/
compat.h
61 lines (51 loc) · 1.28 KB
/
compat.h
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
// Copyright (c) 2017 J Cody Baker. All rights reserved.
// Use of this source code is governed by a MIT-style license that can be
// found in the LICENSE file.
#ifndef SNIP_COMPAT_H
#define SNIP_COMPAT_H
#ifndef MAX
#define MAX(a,b) (((a)>(b))?(a):(b))
#endif
#ifndef MIN
#define MIN(a,b) (((a)<(b))?(a):(b))
#endif
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifndef SNIP_BOOLEAN
#define SNIP_BOOLEAN int
#endif
// IPv6 addresses get [] around the literal ip when a port is specified. This keeps the port separate.
// INET6_ADDRSTRLEN is 46 bytes, [] 2, colon separator 1, 5 bytes for the port, and 1 for the null terminator
#define INET6_ADDRSTRLEN_WITH_PORT 54
#ifndef SHUT_RD
// Windows defines SD_RECEIVE instead of SHUT_RD, values are the same though.
#ifdef SD_RECEIVE
#define SHUT_RD SD_RECEIVE
#endif
#ifndef SHUT_RD
#define SHUT_RD 0
#endif
#endif
#ifndef SHUT_WR
// Windows defines SD_SEND instead of SHUT_WR, values are the same though.
#ifdef SD_SEND
#define SHUT_WR SD_SEND
#endif
#ifndef SHUT_WR
#define SHUT_WR 1
#endif
#endif
#ifndef SHUT_RDWR
// Windows defines SHUT_BOTH instead of SHUT_RDWR, values are the same though.
#ifdef SHUT_BOTH
#define SHUT_RDWR SHUT_BOTH
#endif
#ifndef SHUT_RDWR
#define SHUT_RDWR 2
#endif
#endif
#endif //SNIP_COMPAT_H