annotate dwcompat.h @ 2636:038f83009cdb

iOS/Android: With no autoconf #define HAVE_PIPE, Android and iOS should have it access to pipe(). iOS was failing to use the domain socket or loopback socket fallback, so make sure we are using pipe().
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 11 Aug 2021 20:32:13 +0000
parents 4d1bcfc617b2
children 45a6b33a003a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1909
cb5f9aa9aebb Added detection support for Windows 10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1864
diff changeset
1 /* $Id$ */
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2
1594
6baf177f335c Rename compat.c/h dwcompat.c/h and configure option to --with-dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1589
diff changeset
3 #ifndef _DWCOMPAT_H
6baf177f335c Rename compat.c/h dwcompat.c/h and configure option to --with-dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1589
diff changeset
4 #define _DWCOMPAT_H
174
75bf3051235f Fixes so you can mix compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 172
diff changeset
5
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6 /* This header includes and defines everything needed for a given OS/compiler */
2549
736282fddac5 Android: Get dwcompat building on Android. Had to disable the filesystem functions for now.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2385
diff changeset
7 #if defined(__UNIX__) || defined(__MAC__) || defined(__IOS__) || defined(__ANDROID__)
736282fddac5 Android: Get dwcompat building on Android. Had to disable the filesystem functions for now.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2385
diff changeset
8 /* iOS and Android currently don't use autoconf */
736282fddac5 Android: Get dwcompat building on Android. Had to disable the filesystem functions for now.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2385
diff changeset
9 #if !defined(__IOS__) && !defined(__ANDROID__)
2160
07f1366a724c Rename config.h(.in) to dwconfig.h and install it with dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1992
diff changeset
10 #include "dwconfig.h"
2634
4d1bcfc617b2 iOS/Android: Since these don't use autoconf, define HAVE_DIRENT_H.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2549
diff changeset
11 #else
4d1bcfc617b2 iOS/Android: Since these don't use autoconf, define HAVE_DIRENT_H.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2549
diff changeset
12 #define HAVE_DIRENT_H 1
2636
038f83009cdb iOS/Android: With no autoconf #define HAVE_PIPE, Android and iOS should have
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2634
diff changeset
13 #define HAVE_PIPE 1
2385
a126b04b9996 iOS: dwcompat now builds on iOS as well... Fixes for running dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2246
diff changeset
14 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
15
1589
9a21fbd6ae50 Don't rely on configure to add the 64bit file #defines on Unix and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1587
diff changeset
16 /* Attempt to include 64 bit file functions on various unix flavors */
9a21fbd6ae50 Don't rely on configure to add the 64bit file #defines on Unix and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1587
diff changeset
17 #ifndef _FILE_OFFSET_BITS
9a21fbd6ae50 Don't rely on configure to add the 64bit file #defines on Unix and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1587
diff changeset
18 #define _FILE_OFFSET_BITS 64
9a21fbd6ae50 Don't rely on configure to add the 64bit file #defines on Unix and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1587
diff changeset
19 #endif
9a21fbd6ae50 Don't rely on configure to add the 64bit file #defines on Unix and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1587
diff changeset
20 #ifndef _LARGEFILE_SOURCE
9a21fbd6ae50 Don't rely on configure to add the 64bit file #defines on Unix and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1587
diff changeset
21 #define _LARGEFILE_SOURCE 1
9a21fbd6ae50 Don't rely on configure to add the 64bit file #defines on Unix and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1587
diff changeset
22 #endif
9a21fbd6ae50 Don't rely on configure to add the 64bit file #defines on Unix and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1587
diff changeset
23 #ifndef _LARGEFILE64_SOURCE
9a21fbd6ae50 Don't rely on configure to add the 64bit file #defines on Unix and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1587
diff changeset
24 #define _LARGEFILE64_SOURCE 1
9a21fbd6ae50 Don't rely on configure to add the 64bit file #defines on Unix and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1587
diff changeset
25 #endif
9a21fbd6ae50 Don't rely on configure to add the 64bit file #defines on Unix and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1587
diff changeset
26 #ifndef _LARGE_FILES
9a21fbd6ae50 Don't rely on configure to add the 64bit file #defines on Unix and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1587
diff changeset
27 #define _LARGE_FILES 1
9a21fbd6ae50 Don't rely on configure to add the 64bit file #defines on Unix and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1587
diff changeset
28 #endif
9a21fbd6ae50 Don't rely on configure to add the 64bit file #defines on Unix and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1587
diff changeset
29 #ifndef _DARWIN_USE_64_BIT_INODE
9a21fbd6ae50 Don't rely on configure to add the 64bit file #defines on Unix and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1587
diff changeset
30 #define _DARWIN_USE_64_BIT_INODE 1
9a21fbd6ae50 Don't rely on configure to add the 64bit file #defines on Unix and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1587
diff changeset
31 #endif
9a21fbd6ae50 Don't rely on configure to add the 64bit file #defines on Unix and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1587
diff changeset
32
41
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
33 #include <sys/stat.h>
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
34 #include <unistd.h>
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
35 void msleep(long period);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
36 #endif /* Unix */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
37
41
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
38 #ifndef __TARGET__
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
39 #define __TARGET__ "dw"
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
40 #endif
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
41
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
42 #include <sys/types.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
43 #if HAVE_DIRENT_H
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
44 #include <dirent.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
45 #define NAMLEN(dirent) strlen((dirent)->d_name)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
46 #else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
47 #define dirent direct
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
48 #define NAMLEN(dirent) (dirent)->d_namlen
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
49 #if HAVE_SYS_NDIR_H
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
50 #include <sys/ndir.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
51 #endif /* HAVE_SYS_NDIR_H */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
52 #if HAVE_SYS_DIR_H
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
53 #include <sys/dir.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
54 #endif /* HAVE_SYS_DIR_H */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
55 #if HAVE_NDIR_H
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
56 #include <ndir.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
57 #endif /* HAVE_NDIR_H */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
58 #endif /* HAVE_DIRENT_H */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
59
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
60 #ifdef DIRSEP
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
61 #undef DIRSEP
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
62 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
63
1587
34d970f3ff23 Added 64bit stat and alloca functionality when building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1585
diff changeset
64 #ifdef __WATCOMC__
34d970f3ff23 Added 64bit stat and alloca functionality when building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1585
diff changeset
65 #include <alloca.h>
34d970f3ff23 Added 64bit stat and alloca functionality when building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1585
diff changeset
66 #include <sys/select.h>
34d970f3ff23 Added 64bit stat and alloca functionality when building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1585
diff changeset
67 #include <sys/stat.h>
34d970f3ff23 Added 64bit stat and alloca functionality when building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1585
diff changeset
68 # ifdef _stati64
34d970f3ff23 Added 64bit stat and alloca functionality when building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1585
diff changeset
69 # ifdef stat
34d970f3ff23 Added 64bit stat and alloca functionality when building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1585
diff changeset
70 # undef stat
34d970f3ff23 Added 64bit stat and alloca functionality when building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1585
diff changeset
71 # endif
34d970f3ff23 Added 64bit stat and alloca functionality when building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1585
diff changeset
72 # define stat(a, b) _stati64(a, b)
34d970f3ff23 Added 64bit stat and alloca functionality when building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1585
diff changeset
73 # define dwstat _stati64
34d970f3ff23 Added 64bit stat and alloca functionality when building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1585
diff changeset
74 # endif
34d970f3ff23 Added 64bit stat and alloca functionality when building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1585
diff changeset
75 #endif
34d970f3ff23 Added 64bit stat and alloca functionality when building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1585
diff changeset
76
172
0fc45e386376 Get Dynamic Windows building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 101
diff changeset
77 #if defined(__EMX__) || defined(__OS2__) || defined(__WIN32__) || defined(WINNT)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
78 #include <io.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
79 #include <process.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
80
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
81 #define DIRSEP "\\"
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
82 #define TYPDIR "."
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
83 #else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
84 #define DIRSEP "/"
41
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
85 #define TYPDIR "/usr/local/" __TARGET__
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
86 #endif
908
850b2e6cfeab Have INIDIR use the home directory on all platforms now, not just Unix and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 597
diff changeset
87 #define INIDIR "~/." __TARGET__
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
88
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
89 /* OS/2 */
172
0fc45e386376 Get Dynamic Windows building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 101
diff changeset
90 #if defined(__EMX__) || defined(__OS2__)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
91 #define INCL_WIN
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
92 #define INCL_GPI
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
93 #define INCL_VIO
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
94 #define INCL_NLS
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
95 #define INCL_DOS
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
96 #define INCL_DEV
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
97 #define INCL_DOSERRORS
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
98
1404
56f311dc23f6 Changes to get the library building with Watcom on OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1329
diff changeset
99 #ifdef __OS2__
56f311dc23f6 Changes to get the library building with Watcom on OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1329
diff changeset
100 # if (defined(__IBMC__) || defined(__WATCOMC__) || defined(_System)) && !defined(API)
56f311dc23f6 Changes to get the library building with Watcom on OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1329
diff changeset
101 # define API _System
56f311dc23f6 Changes to get the library building with Watcom on OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1329
diff changeset
102 # endif
174
75bf3051235f Fixes so you can mix compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 172
diff changeset
103 #endif
75bf3051235f Fixes so you can mix compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 172
diff changeset
104
543
8217ee5c254e Get EMX compiling again.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 527
diff changeset
105 #ifndef API
8217ee5c254e Get EMX compiling again.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 527
diff changeset
106 #define API
8217ee5c254e Get EMX compiling again.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 527
diff changeset
107 #endif
8217ee5c254e Get EMX compiling again.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 527
diff changeset
108
1991
d83a86f5fe7f OS/2: Move internal snprintf() into dw.h and dwcompat.h so it can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1975
diff changeset
109 #include <stdio.h>
d83a86f5fe7f OS/2: Move internal snprintf() into dw.h and dwcompat.h so it can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1975
diff changeset
110
d83a86f5fe7f OS/2: Move internal snprintf() into dw.h and dwcompat.h so it can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1975
diff changeset
111 /* Mostly safe but slow snprintf() for compilers that don't have it...
d83a86f5fe7f OS/2: Move internal snprintf() into dw.h and dwcompat.h so it can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1975
diff changeset
112 * like VisualAge. So we can write safe code and still use VAC to test.
d83a86f5fe7f OS/2: Move internal snprintf() into dw.h and dwcompat.h so it can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1975
diff changeset
113 */
d83a86f5fe7f OS/2: Move internal snprintf() into dw.h and dwcompat.h so it can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1975
diff changeset
114 #if defined(__IBMC__) && !defined(snprintf)
d83a86f5fe7f OS/2: Move internal snprintf() into dw.h and dwcompat.h so it can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1975
diff changeset
115 #include <stdarg.h>
d83a86f5fe7f OS/2: Move internal snprintf() into dw.h and dwcompat.h so it can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1975
diff changeset
116 #include <string.h>
d83a86f5fe7f OS/2: Move internal snprintf() into dw.h and dwcompat.h so it can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1975
diff changeset
117 #include <stdlib.h>
d83a86f5fe7f OS/2: Move internal snprintf() into dw.h and dwcompat.h so it can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1975
diff changeset
118 static int _dw_snprintf(char *str, size_t size, const char *format, ...)
d83a86f5fe7f OS/2: Move internal snprintf() into dw.h and dwcompat.h so it can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1975
diff changeset
119 {
d83a86f5fe7f OS/2: Move internal snprintf() into dw.h and dwcompat.h so it can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1975
diff changeset
120 va_list args;
d83a86f5fe7f OS/2: Move internal snprintf() into dw.h and dwcompat.h so it can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1975
diff changeset
121 char *outbuf = calloc(1, size + strlen(format) + 1024);
d83a86f5fe7f OS/2: Move internal snprintf() into dw.h and dwcompat.h so it can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1975
diff changeset
122 int retval = -1;
d83a86f5fe7f OS/2: Move internal snprintf() into dw.h and dwcompat.h so it can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1975
diff changeset
123
d83a86f5fe7f OS/2: Move internal snprintf() into dw.h and dwcompat.h so it can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1975
diff changeset
124 if(outbuf)
d83a86f5fe7f OS/2: Move internal snprintf() into dw.h and dwcompat.h so it can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1975
diff changeset
125 {
d83a86f5fe7f OS/2: Move internal snprintf() into dw.h and dwcompat.h so it can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1975
diff changeset
126 va_start(args, format);
d83a86f5fe7f OS/2: Move internal snprintf() into dw.h and dwcompat.h so it can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1975
diff changeset
127 vsprintf(outbuf, format, args);
d83a86f5fe7f OS/2: Move internal snprintf() into dw.h and dwcompat.h so it can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1975
diff changeset
128 va_end(args);
d83a86f5fe7f OS/2: Move internal snprintf() into dw.h and dwcompat.h so it can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1975
diff changeset
129 retval = strlen(outbuf);
d83a86f5fe7f OS/2: Move internal snprintf() into dw.h and dwcompat.h so it can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1975
diff changeset
130 strncpy(str, outbuf, size);
d83a86f5fe7f OS/2: Move internal snprintf() into dw.h and dwcompat.h so it can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1975
diff changeset
131 free(outbuf);
d83a86f5fe7f OS/2: Move internal snprintf() into dw.h and dwcompat.h so it can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1975
diff changeset
132 }
d83a86f5fe7f OS/2: Move internal snprintf() into dw.h and dwcompat.h so it can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1975
diff changeset
133 return retval;
d83a86f5fe7f OS/2: Move internal snprintf() into dw.h and dwcompat.h so it can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1975
diff changeset
134 }
d83a86f5fe7f OS/2: Move internal snprintf() into dw.h and dwcompat.h so it can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1975
diff changeset
135 #define snprintf _dw_snprintf
d83a86f5fe7f OS/2: Move internal snprintf() into dw.h and dwcompat.h so it can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1975
diff changeset
136 #endif
d83a86f5fe7f OS/2: Move internal snprintf() into dw.h and dwcompat.h so it can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1975
diff changeset
137
d83a86f5fe7f OS/2: Move internal snprintf() into dw.h and dwcompat.h so it can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1975
diff changeset
138
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
139 #define msleep(a) DosSleep(a)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
140
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
141 #ifdef __EMX__
525
2ff26b697877 Fixes for building with Innotek GCC. Will have to check for regressions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 433
diff changeset
142 #include "platform/dirent.h"
24
d9e87e8bcf1d Updated dynamic windows to build with EMX.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
143 #include <sys/stat.h>
d9e87e8bcf1d Updated dynamic windows to build with EMX.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
144 #ifdef FD_SETSIZE
d9e87e8bcf1d Updated dynamic windows to build with EMX.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
145 #undef FD_SETSIZE
d9e87e8bcf1d Updated dynamic windows to build with EMX.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
146 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
147 #define FD_SETSIZE 1024
172
0fc45e386376 Get Dynamic Windows building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 101
diff changeset
148 #endif /* __EMX__ */
0fc45e386376 Get Dynamic Windows building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 101
diff changeset
149
0fc45e386376 Get Dynamic Windows building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 101
diff changeset
150 #if defined(__EMX__) || defined(__WATCOMC__)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
151 #define strcasecmp stricmp
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
152 #define strncasecmp strnicmp
172
0fc45e386376 Get Dynamic Windows building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 101
diff changeset
153 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
154
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
155 #ifndef OS2
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
156 #define OS2
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
157 #endif /* OS2 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
158
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
159 #include <os2.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
160
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
161 #ifndef BKS_TABBEDDIALOG
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
162 #define BKS_TABBEDDIALOG 0x0800
571
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
163 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
164
2244
a1ac35abd5fd Make sure domain socket paths have a trailing DIRSEP... fixes an issue on Windows 10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2239
diff changeset
165 #define PIPEROOT "\\socket"
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
166 #endif /* __EMX__ || __IBMC__ */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
167
172
0fc45e386376 Get Dynamic Windows building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 101
diff changeset
168 #if defined(__OS2__) && (defined(__IBMC__) || defined(__WATCOMC__))
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
169 #define BSD_SELECT
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
170
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
171 #include <types.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
172 #include <time.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
173 #include <sys/stat.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
174 #include <sys/select.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
175 #include <sys/ioctl.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
176 #include <direct.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
177 #include <stdarg.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
178 /* For VAC we are using the Mozilla dirent.c */
172
0fc45e386376 Get Dynamic Windows building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 101
diff changeset
179 #ifndef __WATCOMC__
24
d9e87e8bcf1d Updated dynamic windows to build with EMX.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
180 #include "platform/dirent.h"
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
181 #endif
172
0fc45e386376 Get Dynamic Windows building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 101
diff changeset
182 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
183
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
184 /* Windows */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
185 #if defined(__WIN32__) || defined(WINNT)
527
e0ea29c3d1eb Fixed dw_window_pointer() so it works on Windows. Tried to fix the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 525
diff changeset
186
e0ea29c3d1eb Fixed dw_window_pointer() so it works on Windows. Tried to fix the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 525
diff changeset
187 #if defined(MSVC) && !defined(API)
1859
b02aa3947562 Missing dw_filesystem_set_column_title export from the MinGW definition
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1842
diff changeset
188 # if defined(__MINGW32__) && defined(BUILD_DLL)
b02aa3947562 Missing dw_filesystem_set_column_title export from the MinGW definition
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1842
diff changeset
189 # define API _cdecl __declspec(dllexport)
571
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
190 # else
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
191 # define API _cdecl
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
192 # endif
527
e0ea29c3d1eb Fixed dw_window_pointer() so it works on Windows. Tried to fix the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 525
diff changeset
193 #endif
e0ea29c3d1eb Fixed dw_window_pointer() so it works on Windows. Tried to fix the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 525
diff changeset
194
1960
22e3e829be13 Win: Switch to using winsock 2.x, this will remove support for ancient versions of Windows like 95 and NT 3.5 and older...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1909
diff changeset
195 #include <winsock2.h>
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
196 #include <windows.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
197 #include <time.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
198 #include <process.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
199 #include <sys/stat.h>
571
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
200
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
201 #ifdef MSVC
24
d9e87e8bcf1d Updated dynamic windows to build with EMX.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
202 #include "platform/dirent.h"
1842
123d1a900f54 More MINGW cleanups... eliminate a few more warnings and disable the unused-value warning due to unfixable warnings generated by the Win32 macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1839
diff changeset
203 #undef alloca
581
53639d920735 Fixes for Windows, alloca is _alloc in MSVC, added a macro in compat.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 580
diff changeset
204 #define alloca _alloca
1584
1fb62c442283 Added dwstat #define in compat.h which will be the 64bit stat struct if available on the given platform.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1404
diff changeset
205 #ifdef __stat64
1fb62c442283 Added dwstat #define in compat.h which will be the 64bit stat struct if available on the given platform.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1404
diff changeset
206 #undef stat
1fb62c442283 Added dwstat #define in compat.h which will be the 64bit stat struct if available on the given platform.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1404
diff changeset
207 #define stat(a, b) _stat64(a, b)
1fb62c442283 Added dwstat #define in compat.h which will be the 64bit stat struct if available on the given platform.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1404
diff changeset
208 #define dwstat __stat64
1fb62c442283 Added dwstat #define in compat.h which will be the 64bit stat struct if available on the given platform.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1404
diff changeset
209 #endif
1975
b2cb0ef3ec3d Win: Added partial or full dark mode support for containers, trees and toolbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1962
diff changeset
210 #include <direct.h>
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
211 #else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
212 #include <dir.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
213 #include <dirent.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
214 #endif
571
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
215
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
216 #include <stdarg.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
217
1960
22e3e829be13 Win: Switch to using winsock 2.x, this will remove support for ancient versions of Windows like 95 and NT 3.5 and older...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1909
diff changeset
218 /* Cygwin and Visual Studio 15.4 (SDK 10.0.16299.15) support domain sockets */
22e3e829be13 Win: Switch to using winsock 2.x, this will remove support for ancient versions of Windows like 95 and NT 3.5 and older...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1909
diff changeset
219 #if defined(__CYGWIN32__)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
220 #include <sys/un.h>
1960
22e3e829be13 Win: Switch to using winsock 2.x, this will remove support for ancient versions of Windows like 95 and NT 3.5 and older...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1909
diff changeset
221 #elif defined(_MSC_VER) && _MSC_VER >= 1912
22e3e829be13 Win: Switch to using winsock 2.x, this will remove support for ancient versions of Windows like 95 and NT 3.5 and older...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1909
diff changeset
222 #include <afunix.h>
2244
a1ac35abd5fd Make sure domain socket paths have a trailing DIRSEP... fixes an issue on Windows 10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2239
diff changeset
223 #define PIPEROOT getenv("TEMP") ? getenv("TEMP") : "C:\\Windows\\Temp"
1960
22e3e829be13 Win: Switch to using winsock 2.x, this will remove support for ancient versions of Windows like 95 and NT 3.5 and older...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1909
diff changeset
224 #else
22e3e829be13 Win: Switch to using winsock 2.x, this will remove support for ancient versions of Windows like 95 and NT 3.5 and older...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1909
diff changeset
225 #define NO_DOMAIN_SOCKETS
22e3e829be13 Win: Switch to using winsock 2.x, this will remove support for ancient versions of Windows like 95 and NT 3.5 and older...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1909
diff changeset
226 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
227
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
228 #if defined(_P_NOWAIT) && !defined(P_NOWAIT)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
229 #define P_NOWAIT _P_NOWAIT
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
230 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
231
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1594
diff changeset
232 #ifdef _MSC_VER
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1594
diff changeset
233 /* Handle deprecated functions in Visual C */
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1594
diff changeset
234 # if _MSC_VER >= 1400
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1594
diff changeset
235 # define strcasecmp(a, b) _stricmp(a, b)
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1594
diff changeset
236 # define strncasecmp(a, b, c) _strnicmp(a, b, c)
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1594
diff changeset
237 # define strdup(a) _strdup(a)
1710
b217cf9161c7 Move some more platform specific code into dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1695
diff changeset
238 # define snprintf _snprintf
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1594
diff changeset
239 # define unlink(a) _unlink(a)
2170
d871f636b46e Win: Add a few more forwarders for deprecated POSIX functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2160
diff changeset
240 # define rmdir(a) _rmdir(a)
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1594
diff changeset
241 # define close(a) _close(a)
2170
d871f636b46e Win: Add a few more forwarders for deprecated POSIX functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2160
diff changeset
242 # define open(a, b) _open(a, b)
d871f636b46e Win: Add a few more forwarders for deprecated POSIX functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2160
diff changeset
243 # define read(a, b, c) _read(a, b, c)
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1594
diff changeset
244 # define fdopen(a, b) _fdopen(a, b)
2170
d871f636b46e Win: Add a few more forwarders for deprecated POSIX functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2160
diff changeset
245 # define getcwd(a, b) _getcwd(a, b)
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1594
diff changeset
246 # define chdir(a) _chdir(a)
2170
d871f636b46e Win: Add a few more forwarders for deprecated POSIX functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2160
diff changeset
247 # define getpid() _getpid()
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1715
diff changeset
248 #ifndef _DW_INTERNAL
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1715
diff changeset
249 # define mkdir(a,b) _mkdir(a)
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1715
diff changeset
250 #endif
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1594
diff changeset
251 # else
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1594
diff changeset
252 # define strcasecmp(a, b) stricmp(a, b)
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1594
diff changeset
253 # define strncasecmp(a, b, c) strnicmp(a, b, c)
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1594
diff changeset
254 # endif
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1594
diff changeset
255 #endif
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1594
diff changeset
256 #define msleep(a) Sleep(a)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
257
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
258 #endif /* WIN32 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
259
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
260 /* Everything else ;) */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
261 #include <stdio.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
262 #ifdef HAVE_UNISTD_H
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
263 #include <unistd.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
264 #endif /* HAVE_UNISTD_H */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
265 #ifdef HAVE_SYS_STAT_H
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
266 #include <sys/stat.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
267 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
268 #include <stdlib.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
269 #include <stddef.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
270 #include <signal.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
271 #include <fcntl.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
272
2226
2de088fb5dd4 Added some missing APIs from the template, and changes so it builds dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2170
diff changeset
273 #if !defined(_MSC_VER)
1992
4bfcad4986ff OS/2: Fix compilation error with Watcom C on OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1991
diff changeset
274 #ifndef __WATCOMC__
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
275 #include <sys/time.h>
1992
4bfcad4986ff OS/2: Fix compilation error with Watcom C on OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1991
diff changeset
276 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
277 #include <sys/socket.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
278 #include <sys/un.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
279 #include <netinet/in.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
280 #include <netdb.h>
1324
032037c378ef Don't include arpa/inet.h on OS/2 with VisualAge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1323
diff changeset
281 #ifndef __IBMC__
1323
209d7f5137f2 Cleaned up the compatibility library header.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 908
diff changeset
282 #include <arpa/inet.h>
1324
032037c378ef Don't include arpa/inet.h on OS/2 with VisualAge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1323
diff changeset
283 #endif
172
0fc45e386376 Get Dynamic Windows building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 101
diff changeset
284 #if defined(__OS2__) && defined(RES_DEFAULT)
0fc45e386376 Get Dynamic Windows building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 101
diff changeset
285 #undef RES_DEFAULT
0fc45e386376 Get Dynamic Windows building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 101
diff changeset
286 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
287 #include <stdarg.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
288 #include <string.h>
2226
2de088fb5dd4 Added some missing APIs from the template, and changes so it builds dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2170
diff changeset
289 #endif /* !_MSC_VER */
41
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
290 #include <ctype.h>
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
291
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
292 #ifndef _MAX_PATH
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
293 #define _MAX_PATH 255
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
294 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
295
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
296 /* IBM C doesn't allow "t" in the mode parameter
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
297 * because it violates the ANSI standard.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
298 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
299 #ifdef __IBMC__
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
300 #define FOPEN_READ_TEXT "r"
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
301 #define FOPEN_WRITE_TEXT "w"
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
302 #define FOPEN_APPEND_TEXT "a"
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
303 #else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
304 #define FOPEN_READ_TEXT "rt"
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
305 #define FOPEN_WRITE_TEXT "wt"
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
306 #define FOPEN_APPEND_TEXT "at"
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
307 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
308 #define FOPEN_READ_BINARY "rb"
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
309 #define FOPEN_WRITE_BINARY "wb"
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
310 #define FOPEN_APPEND_BINARY "ab"
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
311
174
75bf3051235f Fixes so you can mix compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 172
diff changeset
312 #ifndef API
75bf3051235f Fixes so you can mix compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 172
diff changeset
313 #define API
75bf3051235f Fixes so you can mix compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 172
diff changeset
314 #endif
75bf3051235f Fixes so you can mix compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 172
diff changeset
315
1991
d83a86f5fe7f OS/2: Move internal snprintf() into dw.h and dwcompat.h so it can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1975
diff changeset
316 #ifndef PIPEROOT
2244
a1ac35abd5fd Make sure domain socket paths have a trailing DIRSEP... fixes an issue on Windows 10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2239
diff changeset
317 #define PIPEROOT "/tmp"
1991
d83a86f5fe7f OS/2: Move internal snprintf() into dw.h and dwcompat.h so it can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1975
diff changeset
318 #endif
d83a86f5fe7f OS/2: Move internal snprintf() into dw.h and dwcompat.h so it can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1975
diff changeset
319
2244
a1ac35abd5fd Make sure domain socket paths have a trailing DIRSEP... fixes an issue on Windows 10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2239
diff changeset
320 #define PIPENAME "%s%s" __TARGET__ "%d-%d"
1991
d83a86f5fe7f OS/2: Move internal snprintf() into dw.h and dwcompat.h so it can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1975
diff changeset
321
580
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
322 /* Compatibility layer for IBM C/Winsock
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
323 * Now using macros so we can allow cross
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
324 * compiler support.
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
325 */
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
326
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
327 #if defined(__IBMC__) || (defined(__WIN32__) && !defined(__CYGWIN32__))
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
328 #define sockread(a, b, c, d) recv(a, b, c, d)
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
329 #else
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
330 #define sockread(a, b, c, d) read(a, b, c)
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
331 #endif
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
332
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
333 #if defined(__IBMC__) || (defined(__WIN32__) && !defined(__CYGWIN32__))
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
334 #define sockwrite(a, b, c, d) send(a, b, c, d)
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
335 #else
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
336 #define sockwrite(a, b, c, d) write(a, b, c)
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
337 #endif
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
338
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
339 #ifdef __IBMC__
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
340 #define sockclose(a) soclose(a)
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
341 #elif defined(__WIN32__) && !defined(__CYGWIN32__)
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
342 #define sockclose(a) closesocket(a)
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
343 #else
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
344 #define sockclose(a) close(a)
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
345 #endif
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
346
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
347 #if defined(__OS2__) && !defined(__EMX__)
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
348 #define nonblock(a) { int _nonblock = 1; ioctl(a, FIONBIO, (char *)&_nonblock, sizeof(_nonblock)); }
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
349 #elif defined(__WIN32__) && !defined(__CYGWIN32__)
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
350 #define nonblock(a) { int _nonblock = 1; ioctlsocket(a, FIONBIO, (unsigned long *)&_nonblock); }
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
351 #else
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
352 #define nonblock(a) fcntl(a, F_SETFL, O_NONBLOCK)
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
353 #endif
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
354
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
355 #if defined(__OS2__) && !defined(__EMX__)
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
356 #define block(a) { int _block = 0; ioctl(a, FIONBIO, (char *)&_nonblock, sizeof(_block)); }
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
357 #elif defined(__WIN32__) && !defined(__CYGWIN32__)
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
358 #define block(a) { int _block = 0; ioctlsocket(a, FIONBIO, (unsigned long *)&_block); }
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
359 #else
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
360 #define block(a) fcntl(a, F_SETFL, 0)
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
361 #endif
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
362
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
363 #ifdef __IBMC__
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
364 #define sockinit() sock_init();
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
365 #elif defined(__WIN32__) || defined(WINNT)
1960
22e3e829be13 Win: Switch to using winsock 2.x, this will remove support for ancient versions of Windows like 95 and NT 3.5 and older...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1909
diff changeset
366 #define sockinit() { static WSADATA wsa; WSAStartup(MAKEWORD (2, 0), &wsa); }
580
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
367 #else /* !WIN32 */
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
368 #define sockinit()
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
369 #endif
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
370
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
371 #if defined(__WIN32__) || defined(WINNT)
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
372 #define sockshutdown() WSACleanup()
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
373 #else /* !WIN32 */
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
374 #define sockshutdown()
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
375 #endif
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
376
2239
95ad22a4da2d Bump version to 3.2 now that we are post 3.1 release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2226
diff changeset
377 #define oldsockpipe(pipes) { \
580
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
378 struct sockaddr_in server_addr; \
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
379 struct sockaddr_in listen_addr = { 0 }; \
581
53639d920735 Fixes for Windows, alloca is _alloc in MSVC, added a macro in compat.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 580
diff changeset
380 int tmpsock, len = sizeof(struct sockaddr_in); \
580
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
381 struct hostent *he = gethostbyname("localhost"); \
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
382 pipes[0] = pipes[1] = -1; \
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
383 if(he) \
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
384 { \
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
385 memset(&server_addr, 0, sizeof(server_addr)); \
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
386 server_addr.sin_family = AF_INET; \
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
387 server_addr.sin_port = 0; \
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
388 server_addr.sin_addr.s_addr = INADDR_ANY; \
581
53639d920735 Fixes for Windows, alloca is _alloc in MSVC, added a macro in compat.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 580
diff changeset
389 if ((tmpsock = socket(AF_INET, SOCK_STREAM, 0)) > -1 && bind(tmpsock, (struct sockaddr *)&server_addr, sizeof(server_addr)) > -1 && listen(tmpsock, 0) > -1) \
2239
95ad22a4da2d Bump version to 3.2 now that we are post 3.1 release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2226
diff changeset
390 { \
95ad22a4da2d Bump version to 3.2 now that we are post 3.1 release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2226
diff changeset
391 memset(&listen_addr, 0, sizeof(listen_addr)); \
95ad22a4da2d Bump version to 3.2 now that we are post 3.1 release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2226
diff changeset
392 getsockname(tmpsock, (struct sockaddr *)&listen_addr, &len); \
95ad22a4da2d Bump version to 3.2 now that we are post 3.1 release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2226
diff changeset
393 server_addr.sin_family = AF_INET; \
95ad22a4da2d Bump version to 3.2 now that we are post 3.1 release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2226
diff changeset
394 server_addr.sin_port = listen_addr.sin_port; \
95ad22a4da2d Bump version to 3.2 now that we are post 3.1 release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2226
diff changeset
395 server_addr.sin_addr.s_addr = *((unsigned long *)he->h_addr); \
95ad22a4da2d Bump version to 3.2 now that we are post 3.1 release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2226
diff changeset
396 if((pipes[1] = socket(AF_INET, SOCK_STREAM, 0)) > -1 && !connect(pipes[1], (struct sockaddr *)&server_addr, sizeof(server_addr))) \
95ad22a4da2d Bump version to 3.2 now that we are post 3.1 release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2226
diff changeset
397 pipes[0] = accept(tmpsock, 0, 0); \
95ad22a4da2d Bump version to 3.2 now that we are post 3.1 release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2226
diff changeset
398 } \
95ad22a4da2d Bump version to 3.2 now that we are post 3.1 release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2226
diff changeset
399 if(tmpsock > -1) \
95ad22a4da2d Bump version to 3.2 now that we are post 3.1 release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2226
diff changeset
400 sockclose(tmpsock); \
581
53639d920735 Fixes for Windows, alloca is _alloc in MSVC, added a macro in compat.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 580
diff changeset
401 } \
53639d920735 Fixes for Windows, alloca is _alloc in MSVC, added a macro in compat.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 580
diff changeset
402 }
2239
95ad22a4da2d Bump version to 3.2 now that we are post 3.1 release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2226
diff changeset
403
95ad22a4da2d Bump version to 3.2 now that we are post 3.1 release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2226
diff changeset
404 #ifdef HAVE_PIPE
95ad22a4da2d Bump version to 3.2 now that we are post 3.1 release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2226
diff changeset
405 #define sockpipe(pipes) { if(pipe(pipes) < 0) pipes[0] = pipes[1] = -1; }
95ad22a4da2d Bump version to 3.2 now that we are post 3.1 release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2226
diff changeset
406 #elif !defined(NO_DOMAIN_SOCKETS)
95ad22a4da2d Bump version to 3.2 now that we are post 3.1 release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2226
diff changeset
407 #define sockpipe(pipes) { \
95ad22a4da2d Bump version to 3.2 now that we are post 3.1 release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2226
diff changeset
408 struct sockaddr_un un; \
95ad22a4da2d Bump version to 3.2 now that we are post 3.1 release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2226
diff changeset
409 int tmpsock = socket(AF_UNIX, SOCK_STREAM, 0); \
95ad22a4da2d Bump version to 3.2 now that we are post 3.1 release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2226
diff changeset
410 pipes[0] = pipes[1] = -1; \
95ad22a4da2d Bump version to 3.2 now that we are post 3.1 release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2226
diff changeset
411 if(tmpsock > -1 && (pipes[1] = socket(AF_UNIX, SOCK_STREAM, 0)) > -1) \
95ad22a4da2d Bump version to 3.2 now that we are post 3.1 release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2226
diff changeset
412 { \
95ad22a4da2d Bump version to 3.2 now that we are post 3.1 release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2226
diff changeset
413 memset(&un, 0, sizeof(un)); \
95ad22a4da2d Bump version to 3.2 now that we are post 3.1 release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2226
diff changeset
414 un.sun_family=AF_UNIX; \
2244
a1ac35abd5fd Make sure domain socket paths have a trailing DIRSEP... fixes an issue on Windows 10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2239
diff changeset
415 sprintf(un.sun_path, PIPENAME, PIPEROOT, DIRSEP, (int)getpid(), pipes[1]); \
2239
95ad22a4da2d Bump version to 3.2 now that we are post 3.1 release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2226
diff changeset
416 unlink(un.sun_path); \
95ad22a4da2d Bump version to 3.2 now that we are post 3.1 release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2226
diff changeset
417 bind(tmpsock, (struct sockaddr *)&un, sizeof(un)); \
95ad22a4da2d Bump version to 3.2 now that we are post 3.1 release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2226
diff changeset
418 listen(tmpsock, 0); \
95ad22a4da2d Bump version to 3.2 now that we are post 3.1 release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2226
diff changeset
419 connect(pipes[1], (struct sockaddr *)&un, sizeof(un)); \
95ad22a4da2d Bump version to 3.2 now that we are post 3.1 release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2226
diff changeset
420 pipes[0] = accept(tmpsock, 0, 0); \
95ad22a4da2d Bump version to 3.2 now that we are post 3.1 release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2226
diff changeset
421 } else \
95ad22a4da2d Bump version to 3.2 now that we are post 3.1 release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2226
diff changeset
422 oldsockpipe(pipes); \
95ad22a4da2d Bump version to 3.2 now that we are post 3.1 release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2226
diff changeset
423 if(tmpsock > -1) \
95ad22a4da2d Bump version to 3.2 now that we are post 3.1 release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2226
diff changeset
424 sockclose(tmpsock); \
95ad22a4da2d Bump version to 3.2 now that we are post 3.1 release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2226
diff changeset
425 }
95ad22a4da2d Bump version to 3.2 now that we are post 3.1 release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2226
diff changeset
426 #else
95ad22a4da2d Bump version to 3.2 now that we are post 3.1 release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2226
diff changeset
427 #define sockpipe(pipes) oldsockpipe(pipes)
580
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
428 #endif
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
429
1329
19bfcdbab74e Hopefully the last socklen_t change... OS/2 needs it too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1328
diff changeset
430 /* Ok Windows and OS/2 both seem to be missing this */
19bfcdbab74e Hopefully the last socklen_t change... OS/2 needs it too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1328
diff changeset
431 #if defined(__WIN32__) || defined(__OS2__)
1326
03f0a57c9e87 Make sure socklen_t gets defined when building with Visual Studio.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1324
diff changeset
432 typedef int socklen_t;
03f0a57c9e87 Make sure socklen_t gets defined when building with Visual Studio.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1324
diff changeset
433 #endif
03f0a57c9e87 Make sure socklen_t gets defined when building with Visual Studio.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1324
diff changeset
434
1585
0576c5444587 Oops fallback dwstat didn't work quite right in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1584
diff changeset
435 /* If dwstat didn't otherwise get defined */
0576c5444587 Oops fallback dwstat didn't work quite right in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1584
diff changeset
436 #ifndef dwstat
0576c5444587 Oops fallback dwstat didn't work quite right in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1584
diff changeset
437 #define dwstat stat
0576c5444587 Oops fallback dwstat didn't work quite right in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1584
diff changeset
438 #endif
0576c5444587 Oops fallback dwstat didn't work quite right in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1584
diff changeset
439
1715
e6b139e0b64d Define O_BINARY as 0 in dwcompat.h for platforms which don't have it.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1710
diff changeset
440 /* Make sure O_BINARY is defined */
e6b139e0b64d Define O_BINARY as 0 in dwcompat.h for platforms which don't have it.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1710
diff changeset
441 #ifndef O_BINARY
e6b139e0b64d Define O_BINARY as 0 in dwcompat.h for platforms which don't have it.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1710
diff changeset
442 #define O_BINARY 0
e6b139e0b64d Define O_BINARY as 0 in dwcompat.h for platforms which don't have it.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1710
diff changeset
443 #endif
e6b139e0b64d Define O_BINARY as 0 in dwcompat.h for platforms which don't have it.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1710
diff changeset
444
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1715
diff changeset
445 #if defined(__IBMC__) || defined(__WATCOMC__) || (defined(_MSC_VER) && _MSC_VER < 1400) || defined(__MINGW32__) || defined(__MINGW64__)
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1715
diff changeset
446 #ifndef _DW_INTERNAL
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1715
diff changeset
447 # undef mkdir
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1715
diff changeset
448 # define mkdir(a,b) mkdir(a)
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1715
diff changeset
449 #endif
1710
b217cf9161c7 Move some more platform specific code into dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1695
diff changeset
450 #endif
b217cf9161c7 Move some more platform specific code into dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1695
diff changeset
451
580
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
452 #define socksprint(a, b) sockwrite(a, b, strlen(b), 0)
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
453
d7c338ac926a Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
454 char * API vargs(char *buf, int len, char *format, ...);
174
75bf3051235f Fixes so you can mix compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 172
diff changeset
455 int API makedir(char *path);
75bf3051235f Fixes so you can mix compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 172
diff changeset
456 void API setfileinfo(char *filename, char *url, char *logfile);
1860
02a23143334c Apparently Visual C's "long double" type is "double" for gcc...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1859
diff changeset
457 #ifdef __MINGW32__
02a23143334c Apparently Visual C's "long double" type is "double" for gcc...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1859
diff changeset
458 double API drivesize(int drive);
02a23143334c Apparently Visual C's "long double" type is "double" for gcc...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1859
diff changeset
459 double API drivefree(int drive);
02a23143334c Apparently Visual C's "long double" type is "double" for gcc...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1859
diff changeset
460 #else
174
75bf3051235f Fixes so you can mix compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 172
diff changeset
461 long double API drivesize(int drive);
75bf3051235f Fixes so you can mix compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 172
diff changeset
462 long double API drivefree(int drive);
1860
02a23143334c Apparently Visual C's "long double" type is "double" for gcc...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1859
diff changeset
463 #endif
174
75bf3051235f Fixes so you can mix compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 172
diff changeset
464 int API isdrive(int drive);
75bf3051235f Fixes so you can mix compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 172
diff changeset
465 void API getfsname(int drive, char *buf, int len);
75bf3051235f Fixes so you can mix compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 172
diff changeset
466 FILE * API fsopen(char *path, char *modes);
75bf3051235f Fixes so you can mix compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 172
diff changeset
467 int API fsclose(FILE *fp);
75bf3051235f Fixes so you can mix compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 172
diff changeset
468 char * API fsgets(char *str, int size, FILE *stream);
75bf3051235f Fixes so you can mix compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 172
diff changeset
469 int API fsseek(FILE *stream, long offset, int whence);
75bf3051235f Fixes so you can mix compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 172
diff changeset
470 int API locale_init(char *filename, int my_locale);
75bf3051235f Fixes so you can mix compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 172
diff changeset
471 char * API locale_string(char *default_text, int message);
557
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 543
diff changeset
472 void API nice_strformat(char *dest, long double val, int dec);
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 543
diff changeset
473 void API initdir(int argc, char *argv[]);
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 543
diff changeset
474 int API setpath(char *path);
571
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
475
174
75bf3051235f Fixes so you can mix compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 172
diff changeset
476 #endif