ThingWorx C SDK
twLinux.h
Go to the documentation of this file.
1 /***************************************
2  * Copyright 2017, PTC, Inc.
3  ***************************************/
4 
10 #ifndef TW_LINUX_H
11 #define TW_LINUX_H
12 
13 #include <sys/types.h>
14 #include <sys/socket.h>
15 #include <netdb.h>
16 #include <dirent.h>
17 #include <stdio.h>
18 #include <resolv.h>
19 #include <dlfcn.h>
20 
31 #ifndef TW_TLS_INCLUDE
32  #define TW_TLS_INCLUDE "twAxTls.h"
33 #endif
34 
38 #ifndef TW_LEAN_AND_MEAN
39 
42 #define TW_LOGGER_BUF_SIZE 4096
43 #define TW_LOG(level, fmt, ...) twLog(level, fmt, ##__VA_ARGS__)
44 #define TW_LOG_HEX(msg, preamble, length) twLogHexString(msg, preamble, length)
45 #define TW_LOG_MSG(msg, preamble) twLogMessage(msg, preamble)
46 
50 #ifndef ENABLE_HTTP_PROXY_SUPPORT
51 #define ENABLE_HTTP_PROXY_SUPPORT
52 #endif
53 #ifndef USE_NTLM_PROXY
54 #define USE_NTLM_PROXY
55 #endif
56 
57 #else /* LEAN AND MEAN */
58 
64 #define TW_LOGGER_BUF_SIZE 1
65 #define TW_LOG(level, fmt, ...)
66 #define TW_LOG_HEX(msg, preamble, length)
67 #define TW_LOG_MSG(msg, preamble)
68 
69 #undef OFFLINE_MSG_STORE
70 #define OFFLINE_MSG_STORE 0
71 #undef ENABLE_HTTP_PROXY_SUPPORT
72 #undef USE_NTLM_PROXY
73 #undef ENABLE_FILE_XFER
74 #undef ENABLE_TUNNELING
75 #endif
76 
80 typedef uint64_t DATETIME;
81 
85 #define TW_MUTEX pthread_mutex_t *
86 
90 #define IPV4 AF_INET
91 #define IPV6 AF_INET6
92 #define TW_SOCKET_TYPE int
93 #define TW_ADDR_INFO struct addrinfo
94 #ifndef TW_HINTS
95 #define TW_HINTS PF_UNSPEC
96 #endif
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_FOPEN(a,b) fopen(a,b)
115 #define TW_FCLOSE(a) fclose(a)
116 #define TW_FREAD(a,b,c,d) fread(a,b,c,d)
117 #define TW_FWRITE(a,b,c,d) fwrite(a,b,c,d)
118 #define TW_FSEEK(a,b,c) fseeko(a,b,c)
119 #define TW_FERROR(a) ferror(a)
120 #define TW_FTELL(a) ftell(a)
121 
122 #define TW_FILE_HANDLE FILE*
123 #define TW_FILE_DELIM '/'
124 #define TW_FILE_DELIM_STR "/"
125 #define TW_FILE_CASE_SENSITVE TRUE
126 #define TW_DIR DIR *
127 #define ERROR_NO_MORE_FILES 0
128 
132 #define TW_THREAD_ID pthread_t
133 
134 /* Thingworx integration - be64toh not defined on mac*/
135 #ifdef __MACH__
136 #define be64toh(x) OSSwapBigToHostInt64(x)
137 #endif
138 
142 #define INLINE
143 #ifndef OS_IOS
144 
145 char getch();
146 
147 #endif
148 
149 #if defined (__APPLE__) && (__MACH__)
150 #include <sys/syslimits.h>
151 #endif
152 
153 #endif
uint64_t DATETIME
Date/time type definition.
Definition: twLinux.h:80