ThingWorx C SDK
twIos.h
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 <CFNetwork/CFSocketStream.h>
19 
20 
24 #ifndef TW_LEAN_AND_MEAN
25 
28 #define TW_LOGGER_BUF_SIZE 4096
29 #define TW_LOG(level, fmt, ...) twLog(level, fmt, ##__VA_ARGS__)
30 #define TW_LOG_HEX(msg, preamble, length) twLogHexString(msg, preamble, length)
31 #define TW_LOG_MSG(msg, preamble) twLogMessage(msg, preamble)
32 
36 #ifndef ENABLE_HTTP_PROXY_SUPPORT
37 #define ENABLE_HTTP_PROXY_SUPPORT
38 #endif
39 #ifndef USE_NTLM_PROXY
40 #define USE_NTLM_PROXY
41 #endif
42 
43 #else /* LEAN AND MEAN */
44 
50 #define TW_LOGGER_BUF_SIZE 1
51 #define TW_LOG(level, fmt, ...)
52 #define TW_LOG_HEX(msg, preamble, length)
53 #define TW_LOG_MSG(msg, preamble)
54 
55 #undef OFFLINE_MSG_STORE
56 #define OFFLINE_MSG_STORE 0
57 #undef ENABLE_HTTP_PROXY_SUPPORT
58 #undef USE_NTLM_PROXY
59 #undef ENABLE_FILE_XFER
60 #undef ENABLE_TUNNELING
61 #endif
62 
66 typedef uint64_t DATETIME;
67 
71 #define TW_MUTEX pthread_mutex_t *
72 
73 /* Forward declaration */
74 struct twSocket;
75 
79 typedef struct iosStream {
80  struct twSocket * parent;
81  CFReadStreamRef readStream;
82  CFWriteStreamRef writeStream;
83  CFStreamClientContext ctx;
84 } iosStream;
85 
86 #define IPV4 AF_INET
87 #define IPV6 AF_INET6
88 #define TW_SOCKET_TYPE iosStream*
89 #define TW_ADDR_INFO struct addrinfo
90 
94 #define TICKS_PER_MSEC 1
95 
99 #define TW_MALLOC(a) malloc(a)
100 #define TW_CALLOC(a, b) calloc(a,b)
101 #define TW_REALLOC(a, b) realloc(a, b)
102 #define TW_FREE(a) free(a)
103 
107 #define TW_FOPEN(a,b) fopen(a,b)
108 #define TW_FCLOSE(a) fclose(a)
109 #define TW_FREAD(a,b,c,d) fread(a,b,c,d)
110 #define TW_FWRITE(a,b,c,d) fwrite(a,b,c,d)
111 #define TW_FSEEK(a,b,c) fseeko(a,b,c)
112 #define TW_FERROR(a) ferror(a)
113 #define TW_FTELL(a) ftell(a)
114 
115 #define TW_FILE_HANDLE FILE*
116 #define TW_FILE_DELIM '/'
117 #define TW_FILE_DELIM_STR "/"
118 #define TW_FILE_CASE_SENSITVE TRUE
119 #define TW_DIR DIR *
120 #define ERROR_NO_MORE_FILES 0
121 
125 #define TW_THREAD_ID pthread_t
126 
130 #define INLINE
131 #ifndef OS_IOS
132 
133 char getch();
134 
135 #endif
136 
137 
142 char * stringCopyInUTF8FromCFString(CFStringRef string);
143 CFStringRef cFStringFromUTF8String(char *string);
144 void clearLastStreamError();
145 void setLastErrorFromReadStream(CFReadStreamRef stream);
146 void setLastErrorFromWriteStream(CFWriteStreamRef stream);
147 
148 #endif
twSocket base type definition.
Definition: twOSPort.h:174
Definition: twIos.h:79
uint64_t DATETIME
Date/time type definition.
Definition: twLinux-openssl.h:76