Mercurial > dwindows
comparison dwcompat.c @ 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 | 433b7c772ff0 |
children | 05dd5189099f |
comparison
equal
deleted
inserted
replaced
1990:433b7c772ff0 | 1991:d83a86f5fe7f |
---|---|
27 #include <sys/vfs.h> | 27 #include <sys/vfs.h> |
28 #endif | 28 #endif |
29 #endif | 29 #endif |
30 #include <time.h> | 30 #include <time.h> |
31 #include <errno.h> | 31 #include <errno.h> |
32 | |
33 /* Mostly safe but slow snprintf() for compilers that don't have it... | |
34 * like VisualAge. So we can write safe code and still use VAC to test. | |
35 */ | |
36 #if defined(__IBMC__) && !defined(snprintf) | |
37 static int snprintf(char *str, size_t size, const char *format, ...) | |
38 { | |
39 va_list args; | |
40 char *outbuf = calloc(1, size + strlen(format) + 1024); | |
41 int retval = -1; | |
42 | |
43 if(outbuf) | |
44 { | |
45 va_start(args, format); | |
46 vsprintf(outbuf, format, args); | |
47 va_end(args); | |
48 retval = strlen(outbuf); | |
49 strncpy(str, outbuf, size); | |
50 free(outbuf); | |
51 } | |
52 return retval; | |
53 } | |
54 #endif | |
55 | 32 |
56 #if defined(__UNIX__) || defined(__MAC__) | 33 #if defined(__UNIX__) || defined(__MAC__) |
57 void msleep(long period) | 34 void msleep(long period) |
58 { | 35 { |
59 #ifdef __sun__ | 36 #ifdef __sun__ |