2
|
1 /*
|
|
2 * The contents of this file are subject to the Mozilla Public
|
|
3 * License Version 1.1 (the "License"); you may not use this file
|
|
4 * except in compliance with the License. You may obtain a copy of
|
|
5 * the License at http://www.mozilla.org/MPL/
|
|
6 *
|
|
7 * Software distributed under the License is distributed on an "AS
|
|
8 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
9 * implied. See the License for the specific language governing
|
|
10 * rights and limitations under the License.
|
|
11 *
|
|
12 * The Original Code is MPEG4IP.
|
|
13 *
|
|
14 * The Initial Developer of the Original Code is Cisco Systems Inc.
|
|
15 * Portions created by Cisco Systems Inc. are
|
|
16 * Copyright (C) Cisco Systems Inc. 2000, 2001. All Rights Reserved.
|
|
17 *
|
|
18 * Contributor(s):
|
|
19 * Dave Mackie dmackie@cisco.com
|
|
20 * Bill May wmay@cisco.com
|
|
21 */
|
|
22
|
|
23 #ifndef __SYSTEMS_H__
|
|
24 #define __SYSTEMS_H__
|
|
25
|
|
26 #ifdef WIN32
|
|
27 #define HAVE_IN_PORT_T
|
|
28 #define HAVE_SOCKLEN_T
|
|
29 #include <win32_ver.h>
|
|
30 #else
|
|
31 #include <config.h>
|
|
32 #endif
|
|
33
|
|
34
|
|
35
|
|
36
|
|
37 #ifdef WIN32
|
|
38
|
|
39 #define _WIN32_WINNT 0x0400
|
|
40 #include <windows.h>
|
|
41 #include <stdio.h>
|
|
42 #include <errno.h>
|
|
43 #include <stdlib.h>
|
|
44 #include <time.h>
|
|
45 #include <limits.h>
|
|
46
|
|
47 typedef unsigned __int64 uint64_t;
|
|
48 typedef unsigned __int32 uint32_t;
|
|
49 typedef unsigned __int16 uint16_t;
|
|
50 typedef unsigned __int8 uint8_t;
|
|
51 typedef unsigned __int64 u_int64_t;
|
|
52 typedef unsigned __int32 u_int32_t;
|
|
53 typedef unsigned __int16 u_int16_t;
|
|
54 typedef unsigned __int8 u_int8_t;
|
|
55 typedef __int64 int64_t;
|
|
56 typedef __int32 int32_t;
|
|
57 typedef __int16 int16_t;
|
|
58 typedef __int8 int8_t;
|
|
59 typedef unsigned short in_port_t;
|
|
60 typedef unsigned int socklen_t;
|
|
61 typedef int ssize_t;
|
|
62 #define snprintf _snprintf
|
|
63 #define strncasecmp _strnicmp
|
|
64 #define strcasecmp _stricmp
|
|
65
|
|
66 #include <io.h>
|
|
67 #include <fcntl.h>
|
|
68 #include <sys/types.h>
|
|
69 #include <sys/stat.h>
|
|
70 #define write _write
|
|
71 #define lseek _lseek
|
|
72 #define close _close
|
|
73 #define open _open
|
|
74 #define access _access
|
|
75 #define vsnprintf _vsnprintf
|
|
76 #define F_OK 0
|
|
77 #define OPEN_RDWR (_O_RDWR | _O_BINARY)
|
|
78 #define OPEN_CREAT (_O_CREAT | _O_BINARY)
|
|
79 #define OPEN_RDONLY (_O_RDONLY | _O_BINARY)
|
|
80 #define srandom srand
|
|
81 #define random rand
|
|
82
|
|
83 #define IOSBINARY ios::binary
|
|
84
|
|
85 #ifdef __cplusplus
|
|
86 extern "C" {
|
|
87 #endif
|
|
88 int gettimeofday(struct timeval *t, void *);
|
|
89 #ifdef __cplusplus
|
|
90 }
|
|
91 #endif
|
|
92
|
|
93 #define PATH_MAX MAX_PATH
|
|
94 #define MAX_UINT64 -1
|
|
95 #define LLD "%I64d"
|
|
96 #define LLU "%I64u"
|
|
97 #define LLX "%I64x"
|
|
98 #define M_LLU 1000i64
|
|
99 #define C_LLU 100i64
|
|
100 #define I_LLU 1i64
|
|
101
|
|
102 #define LOG_EMERG 0
|
|
103 #define LOG_ALERT 1
|
|
104 #define LOG_CRIT 2
|
|
105 #define LOG_ERR 3
|
|
106 #define LOG_WARNING 4
|
|
107 #define LOG_NOTICE 5
|
|
108 #define LOG_INFO 6
|
|
109 #define LOG_DEBUG 7
|
|
110
|
|
111 #if !__STDC__ && _INTEGRAL_MAX_BITS >= 64
|
|
112 #define VAR_TO_FPOS(fpos, var) (fpos) = (var)
|
|
113 #define FPOS_TO_VAR(fpos, typed, var) (var) = (typed)(_FPOSOFF(fpos))
|
|
114 #else
|
|
115 #define VAR_TO_FPOS(fpos, var) (fpos).lopart = ((var) & UINT_MAX); (fpos).hipart = ((var) >> 32)
|
|
116 #define FPOS_TO_VAR(fpos, typed, var) (var) = (typed)((uint64_t)((fpos).hipart ) << 32 | (fpos).lopart)
|
|
117 #endif
|
|
118
|
|
119 #define __STRING(expr) #expr
|
|
120
|
|
121 #define FOPEN_READ_BINARY "rb"
|
|
122 #define FOPEN_WRITE_BINARY "wb"
|
|
123
|
|
124 #else /* UNIX */
|
|
125
|
|
126 #include <stdio.h>
|
|
127 #include <errno.h>
|
|
128 #include <stdlib.h>
|
|
129
|
|
130 #ifdef HAVE_INTTYPES_H
|
|
131 #include <inttypes.h>
|
|
132 #else
|
|
133 #ifdef HAVE_STDINT_H
|
|
134 #include <stdint.h>
|
|
135 #else
|
|
136 #error "Don't have stdint.h or inttypes.h - no way to get uint8_t"
|
|
137 #endif
|
|
138 #endif
|
|
139
|
|
140 #include <unistd.h>
|
|
141 #include <fcntl.h>
|
|
142 #include <netinet/in.h>
|
|
143 #include <sys/types.h>
|
|
144 #include <sys/socket.h>
|
|
145 #include <netinet/in.h>
|
|
146 #include <arpa/inet.h>
|
|
147 #include <syslog.h>
|
|
148 #include <string.h>
|
|
149 #include <ctype.h>
|
|
150 #include <netdb.h>
|
|
151 #include <sys/stat.h>
|
|
152 #include <sys/time.h>
|
|
153 #include <sys/param.h>
|
|
154
|
|
155 #define OPEN_RDWR O_RDWR
|
|
156 #define OPEN_CREAT O_CREAT
|
|
157 #define OPEN_RDONLY O_RDONLY
|
|
158
|
|
159 #define closesocket close
|
|
160 #define IOSBINARY ios::bin
|
|
161 #define MAX_UINT64 -1LLU
|
|
162 #define LLD "%lld"
|
|
163 #define LLU "%llu"
|
|
164 #define LLX "%llx"
|
|
165 #define M_LLU 1000LLU
|
|
166 #define C_LLU 100LLU
|
|
167 #define I_LLU 1LLU
|
|
168 #ifdef HAVE_FPOS_T_POS
|
|
169 #define FPOS_TO_VAR(fpos, typed, var) (var) = (typed)((fpos).__pos)
|
|
170 #define VAR_TO_FPOS(fpos, var) (fpos).__pos = (var)
|
|
171 #else
|
|
172 #define FPOS_TO_VAR(fpos, typed, var) (var) = (typed)(fpos)
|
|
173 #define VAR_TO_FPOS(fpos, var) (fpos) = (var)
|
|
174 #endif
|
|
175
|
|
176 #define FOPEN_READ_BINARY "r"
|
|
177 #define FOPEN_WRITE_BINARY "w"
|
|
178 #endif /* define unix */
|
|
179
|
|
180 #include <stdarg.h>
|
|
181 typedef void (*error_msg_func_t)(int loglevel,
|
|
182 const char *lib,
|
|
183 const char *fmt,
|
|
184 va_list ap);
|
|
185 typedef void (*lib_message_func_t)(int loglevel,
|
|
186 const char *lib,
|
|
187 const char *fmt,
|
|
188 ...);
|
|
189 #ifndef HAVE_IN_PORT_T
|
|
190 typedef uint16_t in_port_t;
|
|
191 #endif
|
|
192
|
|
193 #ifndef HAVE_SOCKLEN_T
|
|
194 typedef unsigned int socklen_t;
|
|
195 #endif
|
|
196
|
|
197 #ifdef sun
|
|
198 #include <limits.h>
|
|
199 #define u_int8_t uint8_t
|
|
200 #define u_int16_t uint16_t
|
|
201 #define u_int32_t uint32_t
|
|
202 #define u_int64_t uint64_t
|
|
203 #define __STRING(expr) #expr
|
|
204 #endif
|
|
205
|
|
206 #ifndef HAVE_STRSEP
|
|
207 #ifdef __cplusplus
|
|
208 extern "C" {
|
|
209 #endif
|
|
210 char *strsep(char **strp, const char *delim);
|
|
211 #ifdef __cplusplus
|
|
212 }
|
|
213 #endif
|
|
214 #endif
|
|
215
|
|
216 #ifndef MIN
|
|
217 #define MIN(a,b) ((a) < (b) ? (a) : (b))
|
|
218 #endif
|
|
219
|
|
220 #ifndef MAX
|
|
221 #define MAX(a,b) ((a) > (b) ? (a) : (b))
|
|
222 #endif
|
|
223
|
|
224 #ifndef INADDR_NONE
|
|
225 #define INADDR_NONE (-1)
|
|
226 #endif
|
|
227
|
|
228 #define MALLOC_STRUCTURE(a) ((a *)malloc(sizeof(a)))
|
|
229
|
|
230 #define CHECK_AND_FREE(a) if ((a) != NULL) { free((a)); (a) = NULL;}
|
|
231
|
|
232 #ifndef TRUE
|
|
233 #define TRUE 1
|
|
234 #endif
|
|
235
|
|
236 #ifndef FALSE
|
|
237 #define FALSE 0
|
|
238 #endif
|
|
239
|
|
240 #endif /* __SYSTEMS_H__ */
|
|
241
|
|
242
|
|
243
|
|
244
|