Mercurial > dwindows
comparison dw.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 | 22e3e829be13 |
children | 77e43d71eaa7 |
comparison
equal
deleted
inserted
replaced
1990:433b7c772ff0 | 1991:d83a86f5fe7f |
---|---|
257 typedef unsigned long HSHM; | 257 typedef unsigned long HSHM; |
258 typedef unsigned long HICN; | 258 typedef unsigned long HICN; |
259 | 259 |
260 extern HAB dwhab; | 260 extern HAB dwhab; |
261 extern HMQ dwhmq; | 261 extern HMQ dwhmq; |
262 | |
263 #include <stdio.h> | |
264 | |
265 /* Mostly safe but slow snprintf() for compilers that don't have it... | |
266 * like VisualAge. So we can write safe code and still use VAC to test. | |
267 */ | |
268 #if defined(__IBMC__) && !defined(snprintf) | |
269 #include <stdarg.h> | |
270 #include <string.h> | |
271 #include <stdlib.h> | |
272 static int _dw_snprintf(char *str, size_t size, const char *format, ...) | |
273 { | |
274 va_list args; | |
275 char *outbuf = calloc(1, size + strlen(format) + 1024); | |
276 int retval = -1; | |
277 | |
278 if(outbuf) | |
279 { | |
280 va_start(args, format); | |
281 vsprintf(outbuf, format, args); | |
282 va_end(args); | |
283 retval = strlen(outbuf); | |
284 strncpy(str, outbuf, size); | |
285 free(outbuf); | |
286 } | |
287 return retval; | |
288 } | |
289 #define snprintf _dw_snprintf | |
290 #endif | |
291 | |
262 #endif | 292 #endif |
263 | 293 |
264 #if defined(__MAC__) | 294 #if defined(__MAC__) |
265 /* MacOS specific section */ | 295 /* MacOS specific section */ |
266 #include <pthread.h> | 296 #include <pthread.h> |