1 | /********** |
2 | This library is free software; you can redistribute it and/or modify it under |
3 | the terms of the GNU Lesser General Public License as published by the |
4 | Free Software Foundation; either version 3 of the License, or (at your |
5 | option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.) |
6 | |
7 | This library is distributed in the hope that it will be useful, but WITHOUT |
8 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
9 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
10 | more details. |
11 | |
12 | You should have received a copy of the GNU Lesser General Public License |
13 | along with this library; if not, write to the Free Software Foundation, Inc., |
14 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
15 | **********/ |
16 | /* "groupsock" interface |
17 | * Copyright (c) 1996-2020 Live Networks, Inc. All rights reserved. |
18 | * Common include files, typically used for networking |
19 | */ |
20 | |
21 | #ifndef _NET_COMMON_H |
22 | #define _NET_COMMON_H |
23 | |
24 | #if defined(__WIN32__) || defined(_WIN32) || defined(_WIN32_WCE) |
25 | /* Windows */ |
26 | #if defined(WINNT) || defined(_WINNT) || defined(__BORLANDC__) || defined(__MINGW32__) || defined(_WIN32_WCE) || defined (_MSC_VER) |
27 | #define _MSWSOCK_ |
28 | #include <winsock2.h> |
29 | #include <ws2tcpip.h> |
30 | #endif |
31 | #include <windows.h> |
32 | #include <errno.h> |
33 | #include <string.h> |
34 | |
35 | #define closeSocket closesocket |
36 | #ifdef EWOULDBLOCK |
37 | #undef EWOULDBLOCK |
38 | #endif |
39 | #ifdef EINPROGRESS |
40 | #undef EINPROGRESS |
41 | #endif |
42 | #ifdef EAGAIN |
43 | #undef EAGAIN |
44 | #endif |
45 | #ifdef EINTR |
46 | #undef EINTR |
47 | #endif |
48 | #define EWOULDBLOCK WSAEWOULDBLOCK |
49 | #define EINPROGRESS WSAEWOULDBLOCK |
50 | #define EAGAIN WSAEWOULDBLOCK |
51 | #define EINTR WSAEINTR |
52 | |
53 | #if defined(_WIN32_WCE) |
54 | #define NO_STRSTREAM 1 |
55 | #endif |
56 | |
57 | /* Definitions of size-specific types: */ |
58 | typedef __int64 int64_t; |
59 | typedef unsigned __int64 u_int64_t; |
60 | |
61 | typedef int int32_t; |
62 | typedef unsigned u_int32_t; |
63 | |
64 | typedef short int16_t; |
65 | typedef unsigned short u_int16_t; |
66 | |
67 | typedef unsigned char u_int8_t; |
68 | |
69 | // For "uintptr_t" and "intptr_t", we assume that if they're not already defined, then this must be |
70 | // an old, 32-bit version of Windows: |
71 | #if !defined(_MSC_STDINT_H_) && !defined(_UINTPTR_T_DEFINED) && !defined(_UINTPTR_T_DECLARED) && !defined(_UINTPTR_T) |
72 | typedef unsigned uintptr_t; |
73 | #endif |
74 | #if !defined(_MSC_STDINT_H_) && !defined(_INTPTR_T_DEFINED) && !defined(_INTPTR_T_DECLARED) && !defined(_INTPTR_T) |
75 | typedef int intptr_t; |
76 | #endif |
77 | |
78 | #elif defined(VXWORKS) |
79 | /* VxWorks */ |
80 | #include <time.h> |
81 | #include <timers.h> |
82 | #include <sys/times.h> |
83 | #include <sockLib.h> |
84 | #include <hostLib.h> |
85 | #include <resolvLib.h> |
86 | #include <ioLib.h> |
87 | |
88 | typedef unsigned int u_int32_t; |
89 | typedef unsigned short u_int16_t; |
90 | typedef unsigned char u_int8_t; |
91 | |
92 | #else |
93 | /* Unix */ |
94 | #include <sys/types.h> |
95 | #include <sys/socket.h> |
96 | #include <sys/time.h> |
97 | #include <netinet/in.h> |
98 | #include <arpa/inet.h> |
99 | #include <netdb.h> |
100 | #include <unistd.h> |
101 | #include <string.h> |
102 | #include <stdlib.h> |
103 | #include <errno.h> |
104 | #include <strings.h> |
105 | #include <ctype.h> |
106 | #include <stdint.h> |
107 | #if defined(_QNX4) |
108 | #include <sys/select.h> |
109 | #include <unix.h> |
110 | #endif |
111 | |
112 | #define closeSocket close |
113 | |
114 | #ifdef SOLARIS |
115 | #define u_int64_t uint64_t |
116 | #define u_int32_t uint32_t |
117 | #define u_int16_t uint16_t |
118 | #define u_int8_t uint8_t |
119 | #endif |
120 | #endif |
121 | |
122 | #ifndef SOCKLEN_T |
123 | #define SOCKLEN_T int |
124 | #endif |
125 | |
126 | #endif |
127 | |