forked from webrtc-gateway/janus-gateway-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathos.h
157 lines (122 loc) · 3.92 KB
/
os.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
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
154
155
156
157
/*! \file os.h
* \author Marcin Sielski <[email protected]>
* \copyright GNU General Public License v3
* \brief OS comapatibility layer (headers)
* \details Implementation of OS specific incompatibilities.
* Should be included after all header files.
* \ingroup core
* \ref core
*/
#ifndef _JANUS_OS_H
#define _JANUS_OS_H
#ifdef _WIN32
#include <io.h>
#include <ws2tcpip.h>
#define IFF_RUNNING 0xFFFFFFFF
#define SO_REUSEPORT SO_REUSEADDR
#endif
#ifdef _WIN32
#ifdef SHARED
#define JANUS_API __declspec(dllexport)
#else
#define JANUS_API __declspec(dllimport)
#endif
#define JANUS_LOCAL JANUS_API
#else
#define JANUS_API
#define JANUS_LOCAL static
#endif
#ifndef __BIG_ENDIAN
#define __BIG_ENDIAN __ORDER_BIG_ENDIAN__
#endif
#ifndef __LITTLE_ENDIAN
#define __LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__
#endif
#ifndef __BYTE_ORDER
#define __BYTE_ORDER __BYTE_ORDER__
#endif
#ifndef LOCK_SH
#define LOCK_SH 1 // shared lock
#endif
#ifndef LOCK_EX
#define LOCK_EX 2 // exclusive lock
#endif
#ifndef LOCK_NB
#define LOCK_NB 4 // nonblocking request
#endif
#ifndef LOCK_UN
#define LOCK_UN 8 // remove an existing lock
#endif
#ifndef HAVE_UINT
typedef unsigned int uint;
#endif
#ifndef HAVE_NDFS_T
typedef unsigned long int nfds_t;
#endif
#ifndef HAVE_IN_ADDR_T
typedef u_long in_addr_t;
#endif
#ifndef HAVE_STRUCT_IFADDRS
// http://man7.org/linux/man-pages/man3/getifaddrs.3.html
struct ifaddrs {
struct ifaddrs *ifa_next; /* Next item in list */
char *ifa_name; /* Name of interface */
unsigned int ifa_flags; /* Flags from SIOCGIFFLAGS */
struct sockaddr *ifa_addr; /* Address of interface */
struct sockaddr *ifa_netmask; /* Netmask of interface */
union {
struct sockaddr *ifu_broadaddr;
/* Broadcast address of interface */
struct sockaddr *ifu_dstaddr;
/* Point-to-point destination address */
} ifa_ifu;
#define ifa_broadaddr ifa_ifu.ifu_broadaddr
#define ifa_dstaddr ifa_ifu.ifu_dstaddr
void *ifa_data; /* Address-specific data */
};
#endif
#ifndef HAVE_POLL
/*! \brief poll - wait for some event on a file descriptor
* @param fds set of file descriptors to be monitored
* @param nfds number of file descriptors
* @param timeout number of milliseconds that poll should block
* waiting for a file descriptor to become ready.
* @returns positive number in case of success, -1 otherwise */
JANUS_API int poll(struct pollfd *fds, nfds_t nfds, int timeout);
#endif
#ifndef HAVE_INET_ATON
/*! \brief inet_aton - converts the Internet host address from the IPv4
* numbers-and-dots notation into binary form
* @param cp Internet host address
* @param addr address binary structure
* @returns nonzero if the address is valid, a zero otherwise */
JANUS_API unsigned long inet_aton(register const char *cp, struct in_addr *addr);
#endif
#ifndef HAVE_GETIFADDRS
/*! \brief getifaddrs - get interface addresses
* @param ifpp list of interface addresses
* @returns zero in case of success, -1 otherwise */
JANUS_API int getifaddrs(struct ifaddrs **ifpp);
#endif
#ifndef HAVE_FREEIFADDRS
/*! \brief freeifaddrs - frees interface addresses
* @param ifp list of interface addresses */
JANUS_API void freeifaddrs(struct ifaddrs *ifp);
#endif
#ifndef HAVE_STRCASESTR
/*! \brief strcasestr - locate a substring in a string (case insensitive)
* @param heystak string
* @param needle substring to locaate
* @returns If needle is an empty string, heystack is returned; if needle occurs
* nowhere in heystack, NULL is returned; otherwise a pointer to the first
* character of the first occurrence of needle is returned */
JANUS_API char *strcasestr(const char *haystack, const char *needle);
#endif
#ifndef HAVE_FLOCK
/*! \brief flock - apply or remove an advisory lock on an open file
* @param fd file descriptor
* @param operation LOCK_SH, LOCK_EX, LOCK_UN, LOCK_NB
* @returns zero in case of susscess, -1 otherwise */
JANUS_API int flock (int fd, int operation);
#endif
#endif