aboutsummaryrefslogtreecommitdiffstats
path: root/stdafx.h
blob: abc20ffcd587b383e83baabdfe6805fa50fba71a (plain)
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//

#ifndef __STDAFX
#define __STDAFX

#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#ifdef WINCE
	int errno;
	#define strerror(err) "strerror() Not Supported in Windows CE"
	#define abort() exit(1)
	#define EAGAIN 35
	#define EINTR   4
#else
	#include <sys/types.h>
	#include <errno.h>
#endif

#define USE_PHIDGET21_LOGGING

//use zeroconf
#ifdef NO_ZEROCONF
	#ifdef USE_ZEROCONF
	#undef USE_ZEROCONF
	#endif
#else
	#ifndef USE_ZEROCONF
	#define USE_ZEROCONF
	#endif
#endif

//iPhone, Android doesn't have libiconv
#if defined(_IPHONE) || defined(_ANDROID)
	#define USE_INTERNAL_UNICONV
#endif

#ifndef TRUE
#define TRUE 1
#endif

#ifndef FALSE
#define FALSE 0
#endif

#ifdef _WINDOWS
// Defines & Include for Windows only
	#ifndef AI_ADDRCONFIG
		#define AI_ADDRCONFIG   0x00000400  // Resolution only if global address configured
	#endif

	//On Windows (but not WinCE), compile in Labview functions
	#ifndef WINCE
		#ifndef COMPILE_PHIDGETS_LABVIEW
		#define COMPILE_PHIDGETS_LABVIEW
		#endif
	#endif

	//use runtime linking for zeroconf
	#ifndef ZEROCONF_RUNTIME_LINKING
	#define ZEROCONF_RUNTIME_LINKING
	#endif

	//On Windows (but not WinCE), compile in internal .local lookup (faster then letting Windows do it)
	#ifndef WINCE
		#ifndef ZEROCONF_LOOKUP
		#define ZEROCONF_LOOKUP
		#endif
	#endif

	// Modify the following defines if you have to target a platform prior to the ones specified below.
	// Refer to MSDN for the latest info on corresponding values for different platforms.
	#ifndef WINVER				// Allow use of features specific to Windows XP or later.
	#define WINVER 0x0500		// Change this to the appropriate value to target other versions of Windows.
	#endif

	#ifndef _WIN32_WINNT		// Allow use of features specific to Windows XP or later.                   
	#define _WIN32_WINNT 0x0500	// Change this to the appropriate value to target other versions of Windows.
	#endif						

	#ifndef _WIN32_WINDOWS		// Allow use of features specific to Windows 98 or later.
	#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
	#endif

	#ifndef _WIN32_IE			// Allow use of features specific to IE 6.0 or later.
	#define _WIN32_IE 0x0600	// Change this to the appropriate value to target other versions of IE.
	#endif

	#define WIN32_LEAN_AND_MEAN		// Exclude rarely-used stuff from Windows headers
	// Windows Header Files:
	#ifndef _CYGWIN
		#include <Winsock2.h>
		#include <ws2tcpip.h>
	#endif
	#if !defined(WINCE) && defined(_MSC_EXTENSIONS)
		#include <Wspiapi.h>
	#endif

	#include <windows.h>
	#include <winbase.h>
	#include <stdio.h>
	#include <stdlib.h>
	#include <time.h>
	#include <assert.h>
	#include <math.h>

	#ifdef USE_INTERNAL_UNICONV
		#include "cvtutf.h"
	#else
		#include <locale.h>
	#endif

	#ifdef _MSC_EXTENSIONS
		#include "snprintf.h"
	#endif
	#ifndef _CYGWIN
		#include "wincompat.h"
	#endif

	#define strdup _strdup
	#define snprintf _snprintf

	#define strtoll (__int64)_strtoi64
	#define strtoull (__int64)_strtoui64

	#define CCONV __stdcall
	#define CCONV_CDECL __cdecl
	#define SLEEP(dlay) Sleep(dlay);
	#define ZEROMEM(var,size) ZeroMemory(var, size);

	#ifdef PHIDGET21_EXPORTS
	#ifndef PHIDGET21_API
	#define PHIDGET21_API 
	#endif
	#else
	#ifndef PHIDGET21_API
	#define PHIDGET21_API __declspec(dllimport)
	#endif
	#endif
	
	typedef SYSTEMTIME TIME;
	typedef unsigned __int64 __uint64;

	typedef int ssize_t;

	#define C_IN 1
	#define NETDB_INTERNAL -1

	#ifndef DEPRECATE_WIN
	#define DEPRECATE_WIN(depmsg) __declspec(deprecated( depmsg ))
	#endif
	#ifndef DEPRECATE_GCC
	#define DEPRECATE_GCC
	#endif

#ifndef ECANCELED
#define ECANCELED 89
#endif
	
#else
// Defines & Include for both Mac and Linux
	#include <semaphore.h>
	#include <time.h>
	#include <stdio.h>
	#include <stdarg.h>
	#include <stdlib.h>
	#include <string.h>
	#include <pthread.h>
	#include <errno.h>
	#include <sys/types.h>
	#include <sys/socket.h>
	#include <netinet/in.h>
	#include <arpa/inet.h>
	#include <arpa/nameser.h>
	#include <netdb.h>
	#include <unistd.h>
	#include <sys/time.h>
	#include <ctype.h>
	#include <math.h>
	#ifdef USE_INTERNAL_UNICONV
		#include "cvtutf.h"
	#else
		#include <iconv.h>
	#endif

	#define CCONV
	#define CCONV_CDECL
	#define SLEEP(dlay) usleep(dlay*1000);
	#define ZEROMEM(var,size) memset(var, 0, size);
	#ifndef PHIDGET21_API
	#define PHIDGET21_API
	#endif
	typedef void *HANDLE;
	#define INFINITE 0xFFFFFFFF
	typedef long *LPDWORD;
	#define STILL_ACTIVE 0x00000103L
	#define WAIT_TIMEOUT 258L
	#define WAIT_ABANDONED 0x00000080
	#define WAIT_OBJECT_0 0x00000000L
	#define WAIT_FAILED 0xFFFFFFFF
	typedef int SOCKET;
	#define INVALID_SOCKET -1
	#ifndef SOCKET_ERROR
	#define SOCKET_ERROR -1
	#endif
	typedef void *OVERLAPPED;
	
	typedef struct timeval TIME;

	#ifndef DEPRECATE_GCC
	#define DEPRECATE_GCC __attribute__ ((deprecated))
	#endif
	#ifndef DEPRECATE_WIN
	#define DEPRECATE_WIN(depmsg)
	#endif
	
	#ifdef _MACOSX
// Defines & Include for Mac only
		#include <CoreFoundation/CoreFoundation.h>
		#include <mach/mach.h>

		#ifndef _IPHONE
			#include <IOKit/IOKitLib.h>
		#endif

		//For Zeroconf Lookup - use the internal version on Mac because otherwise SBC lookups are VERY slow!
		#define C_IN 1
		#ifndef ZEROCONF_LOOKUP
			#define ZEROCONF_LOOKUP
		#endif

	#elif _LINUX
		// Defines & Include for Linux Only
		#include <assert.h>
		#include <dlfcn.h>

		//use runtime linking for zeroconf
		#ifndef ZEROCONF_RUNTIME_LINKING
		#define ZEROCONF_RUNTIME_LINKING
		#endif
	#endif
#endif

#ifndef round
#define round(x) ((x)>=0?(int)((x)+0.5):(int)((x)-0.5))
#endif

#ifndef MSG_NOSIGNAL
#define MSG_NOSIGNAL 0
#endif

//#define round_double(x, decimals) (double)((double)round(x * (double)(pow(10, decimals))) / (double)(pow(10, decimals)))
double round_double(double x, int decimals);
int hexval(unsigned char c);

#include "clog.h"
#include "pdictclient.h"
#include "cphidget.h"

#ifdef DMALLOC
#include "dmalloc.h"
#endif

#endif