ThingWorx C SDK
twWindows.h
Go to the documentation of this file.
1 /***************************************
2  * Copyright 2017, PTC, Inc.
3  ***************************************/
4 
11 #ifndef TW_WINDOWS_H
12 #define TW_WINDOWS_H
13 
14 #include "winsock2.h"
15 #include "windows.h"
16 #include "conio.h"
17 #include "stdio.h"
18 
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
34 #ifndef TW_TLS_INCLUDE
35 #define TW_TLS_INCLUDE "twAxTls.h"
36 #endif
37 
40 #ifndef TW_LEAN_AND_MEAN
41 
44 #define TW_LOGGER_BUF_SIZE 4096
45 #define TW_LOG(level, fmt, ...) twLog(level, fmt, ##__VA_ARGS__)
46 #define TW_LOG_HEX(msg, preamble, length) twLogHexString(msg, preamble, length)
47 #define TW_LOG_MSG(msg, preamble) twLogMessage(msg, preamble)
48 
52 #define ENABLE_HTTP_PROXY_SUPPORT
53 #define USE_NTLM_PROXY
54 
55 #else /* LEAN AND MEAN */
56 
63 #define TW_LOGGER_BUF_SIZE 1
64 #define TW_LOG(level, fmt, ...)
65 #define TW_LOG_HEX(msg, preamble, length)
66 #define TW_LOG_MSG(msg, preamble)
67 
68 #undef OFFLINE_MSG_STORE
69 #define OFFLINE_MSG_STORE 0
70 #undef ENABLE_HTTP_PROXY_SUPPORT
71 #undef USE_NTLM_PROXY
72 #undef ENABLE_FILE_XFER
73 #undef ENABLE_TUNNELING
74 #endif
75 
79 #define rand_r(A) srand(*A)
80 
84 typedef DWORD64 DATETIME;
85 
88 #define TW_MUTEX LPHANDLE
89 
93 #define IPV4 AF_INET
94 #define IPV6 AF_INET6
95 #define TW_SOCKET_TYPE int
96 #define TW_ADDR_INFO struct addrinfo
97 
101 #define TICKS_PER_MSEC 1
102 
106 #define TW_MALLOC(a) malloc(a)
107 #define TW_CALLOC(a, b) calloc(a,b)
108 #define TW_REALLOC(a, b) realloc(a, b)
109 #define TW_FREE(a) free(a)
110 
114 #define TW_FILE_HANDLE FILE*
115 #define TW_FILE_DELIM '\\'
116 #define TW_FILE_DELIM_STR "\\"
117 #define TW_FILE_CASE_SENSITVE FALSE
118 #define TW_DIR HANDLE
119 
120 TW_FILE_HANDLE win_fopen(const char* name, const char* mode);
121 #define TW_FOPEN(a,b) win_fopen(a,b)
122 #define TW_FCLOSE(a) fclose(a)
123 #define TW_FREAD(a,b,c,d) fread(a,b,c,d)
124 #define TW_FWRITE(a,b,c,d) fwrite(a,b,c,d)
125 #define TW_FSEEK(a,b,c) _fseeki64(a,b,c)
126 #define TW_FTELL(a) _ftelli64(a)
127 #define TW_FERROR(a) ferror(a)
128 
132 #define TW_THREAD_ID HANDLE
133 
140 #define INLINE __forceinline
141 #if _MSC_VER < 1900
142 #define snprintf _snprintf
143 #endif
144 
145 
146 /* Thingworx integration - be64toh not defined on windows*/
147 # if BYTE_ORDER == LITTLE_ENDIAN
148 # define be64toh(x) ntohll(x)
149 # elif BYTE_ORDER == BIG_ENDIAN
150 # define be64toh(x) (x)
151 # else
152 # error byte order not supported
153 # endif
154 
155 #ifdef __cplusplus
156 }
157 #endif
158 #endif
DWORD64 DATETIME
Date/time definition.
Definition: twWindows.h:84