comparison dwcompat.h @ 1991:d83a86f5fe7f

OS/2: Move internal snprintf() into dw.h and dwcompat.h so it can be used anywhere that includes dw.h or dwcompat.h allowing continued use of VAC. Fix an issue where PIPENAME was erroneously defined in the Windows section, breaking any non-windows systems using domain sockets, like OS/2 with VAC.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 16 Sep 2019 19:12:39 +0000
parents b2cb0ef3ec3d
children 4bfcad4986ff
comparison
equal deleted inserted replaced
1990:433b7c772ff0 1991:d83a86f5fe7f
100 100
101 #ifndef API 101 #ifndef API
102 #define API 102 #define API
103 #endif 103 #endif
104 104
105 #include <stdio.h>
106
107 /* Mostly safe but slow snprintf() for compilers that don't have it...
108 * like VisualAge. So we can write safe code and still use VAC to test.
109 */
110 #if defined(__IBMC__) && !defined(snprintf)
111 #include <stdarg.h>
112 #include <string.h>
113 #include <stdlib.h>
114 static int _dw_snprintf(char *str, size_t size, const char *format, ...)
115 {
116 va_list args;
117 char *outbuf = calloc(1, size + strlen(format) + 1024);
118 int retval = -1;
119
120 if(outbuf)
121 {
122 va_start(args, format);
123 vsprintf(outbuf, format, args);
124 va_end(args);
125 retval = strlen(outbuf);
126 strncpy(str, outbuf, size);
127 free(outbuf);
128 }
129 return retval;
130 }
131 #define snprintf _dw_snprintf
132 #endif
133
134
105 #define msleep(a) DosSleep(a) 135 #define msleep(a) DosSleep(a)
106 136
107 #ifdef __EMX__ 137 #ifdef __EMX__
108 #include "platform/dirent.h" 138 #include "platform/dirent.h"
109 #include <sys/stat.h> 139 #include <sys/stat.h>
189 #include <afunix.h> 219 #include <afunix.h>
190 #define PIPEROOT getenv("TEMP") ? getenv("TEMP") : "C:\\Windows\\Temp\\" 220 #define PIPEROOT getenv("TEMP") ? getenv("TEMP") : "C:\\Windows\\Temp\\"
191 #else 221 #else
192 #define NO_DOMAIN_SOCKETS 222 #define NO_DOMAIN_SOCKETS
193 #endif 223 #endif
194
195 #ifndef PIPEROOT
196 #define PIPEROOT "/tmp/"
197 #endif
198
199 #define PIPENAME "%s" __TARGET__ "%d-%d"
200 224
201 #if defined(_P_NOWAIT) && !defined(P_NOWAIT) 225 #if defined(_P_NOWAIT) && !defined(P_NOWAIT)
202 #define P_NOWAIT _P_NOWAIT 226 #define P_NOWAIT _P_NOWAIT
203 #endif 227 #endif
204 228
276 #define FOPEN_APPEND_BINARY "ab" 300 #define FOPEN_APPEND_BINARY "ab"
277 301
278 #ifndef API 302 #ifndef API
279 #define API 303 #define API
280 #endif 304 #endif
305
306 #ifndef PIPEROOT
307 #define PIPEROOT "/tmp/"
308 #endif
309
310 #define PIPENAME "%s" __TARGET__ "%d-%d"
281 311
282 /* Compatibility layer for IBM C/Winsock 312 /* Compatibility layer for IBM C/Winsock
283 * Now using macros so we can allow cross 313 * Now using macros so we can allow cross
284 * compiler support. 314 * compiler support.
285 */ 315 */