Mercurial > dwindows
annotate dwcompat.h @ 1849:b5e1ccc76e58
Added code to set the foreground color on Mac buttons...
background color cannot be set, it is image based.
Also added defaultly disabled color test code to the testing application.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 01 Jan 2013 23:18:56 +0000 |
parents | 123d1a900f54 |
children | b02aa3947562 |
rev | line source |
---|---|
1839
22225eb286e5
Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1715
diff
changeset
|
1 /* $Id: dwcompat.h 1722 2012-05-08 17:14:40Z bsmith $ */ |
3 | 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 | 6 /* This header includes and defines everything needed for a given OS/compiler */ |
433
f225f16bebbd
Compile fixes for MacOS X.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
234
diff
changeset
|
7 #if defined(__UNIX__) || defined(__MAC__) |
1655
de4b88ee7ad8
Only include compat.h when building the dwcompat shared library.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1601
diff
changeset
|
8 #ifdef BUILD_DLL |
1695
90d02916b878
Strange for some reason we are including compat.h instead of config.h?
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1655
diff
changeset
|
9 #include "config.h" |
1655
de4b88ee7ad8
Only include compat.h when building the dwcompat shared library.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1601
diff
changeset
|
10 #endif |
3 | 11 |
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
|
12 /* 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
|
13 #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
|
14 #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
|
15 #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
|
16 #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
|
17 #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
|
18 #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
|
19 #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
|
20 #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
|
21 #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
|
22 #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
|
23 #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
|
24 #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
|
25 #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
|
26 #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
|
27 #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
|
28 |
41
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
29 #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
|
30 #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
|
31 void msleep(long period); |
3 | 32 #endif /* Unix */ |
33 | |
41
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
34 #ifndef __TARGET__ |
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
35 #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
|
36 #endif |
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
37 |
3 | 38 #include <sys/types.h> |
39 #if HAVE_DIRENT_H | |
40 #include <dirent.h> | |
41 #define NAMLEN(dirent) strlen((dirent)->d_name) | |
42 #else | |
43 #define dirent direct | |
44 #define NAMLEN(dirent) (dirent)->d_namlen | |
45 #if HAVE_SYS_NDIR_H | |
46 #include <sys/ndir.h> | |
47 #endif /* HAVE_SYS_NDIR_H */ | |
48 #if HAVE_SYS_DIR_H | |
49 #include <sys/dir.h> | |
50 #endif /* HAVE_SYS_DIR_H */ | |
51 #if HAVE_NDIR_H | |
52 #include <ndir.h> | |
53 #endif /* HAVE_NDIR_H */ | |
54 #endif /* HAVE_DIRENT_H */ | |
55 | |
56 #ifdef DIRSEP | |
57 #undef DIRSEP | |
58 #endif | |
59 | |
1587
34d970f3ff23
Added 64bit stat and alloca functionality when building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1585
diff
changeset
|
60 #ifdef __WATCOMC__ |
34d970f3ff23
Added 64bit stat and alloca functionality when building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1585
diff
changeset
|
61 #include <alloca.h> |
34d970f3ff23
Added 64bit stat and alloca functionality when building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1585
diff
changeset
|
62 #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
|
63 #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
|
64 # ifdef _stati64 |
34d970f3ff23
Added 64bit stat and alloca functionality when building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1585
diff
changeset
|
65 # ifdef stat |
34d970f3ff23
Added 64bit stat and alloca functionality when building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1585
diff
changeset
|
66 # undef stat |
34d970f3ff23
Added 64bit stat and alloca functionality when building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1585
diff
changeset
|
67 # endif |
34d970f3ff23
Added 64bit stat and alloca functionality when building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1585
diff
changeset
|
68 # 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
|
69 # define dwstat _stati64 |
34d970f3ff23
Added 64bit stat and alloca functionality when building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1585
diff
changeset
|
70 # endif |
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 |
172
0fc45e386376
Get Dynamic Windows building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
101
diff
changeset
|
73 #if defined(__EMX__) || defined(__OS2__) || defined(__WIN32__) || defined(WINNT) |
3 | 74 #include <io.h> |
75 #include <process.h> | |
76 | |
77 #define DIRSEP "\\" | |
78 #define TYPDIR "." | |
79 #else | |
80 #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
|
81 #define TYPDIR "/usr/local/" __TARGET__ |
3 | 82 #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
|
83 #define INIDIR "~/." __TARGET__ |
3 | 84 |
85 /* OS/2 */ | |
172
0fc45e386376
Get Dynamic Windows building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
101
diff
changeset
|
86 #if defined(__EMX__) || defined(__OS2__) |
3 | 87 #define INCL_WIN |
88 #define INCL_GPI | |
89 #define INCL_VIO | |
90 #define INCL_NLS | |
91 #define INCL_DOS | |
92 #define INCL_DEV | |
93 #define INCL_DOSERRORS | |
94 | |
1404
56f311dc23f6
Changes to get the library building with Watcom on OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1329
diff
changeset
|
95 #ifdef __OS2__ |
56f311dc23f6
Changes to get the library building with Watcom on OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1329
diff
changeset
|
96 # 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
|
97 # 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
|
98 # endif |
174
75bf3051235f
Fixes so you can mix compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
172
diff
changeset
|
99 #endif |
75bf3051235f
Fixes so you can mix compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
172
diff
changeset
|
100 |
543
8217ee5c254e
Get EMX compiling again.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
527
diff
changeset
|
101 #ifndef API |
8217ee5c254e
Get EMX compiling again.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
527
diff
changeset
|
102 #define API |
8217ee5c254e
Get EMX compiling again.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
527
diff
changeset
|
103 #endif |
8217ee5c254e
Get EMX compiling again.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
527
diff
changeset
|
104 |
3 | 105 #define msleep(a) DosSleep(a) |
106 | |
107 #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
|
108 #include "platform/dirent.h" |
24
d9e87e8bcf1d
Updated dynamic windows to build with EMX.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
109 #include <sys/stat.h> |
28
cd715f9036c0
Added HAVE_PIPE define for EMX.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
24
diff
changeset
|
110 #define HAVE_PIPE |
24
d9e87e8bcf1d
Updated dynamic windows to build with EMX.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
111 #ifdef FD_SETSIZE |
d9e87e8bcf1d
Updated dynamic windows to build with EMX.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
112 #undef FD_SETSIZE |
d9e87e8bcf1d
Updated dynamic windows to build with EMX.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
113 #endif |
3 | 114 #define FD_SETSIZE 1024 |
172
0fc45e386376
Get Dynamic Windows building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
101
diff
changeset
|
115 #endif /* __EMX__ */ |
0fc45e386376
Get Dynamic Windows building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
101
diff
changeset
|
116 |
0fc45e386376
Get Dynamic Windows building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
101
diff
changeset
|
117 #if defined(__EMX__) || defined(__WATCOMC__) |
3 | 118 #define strcasecmp stricmp |
119 #define strncasecmp strnicmp | |
172
0fc45e386376
Get Dynamic Windows building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
101
diff
changeset
|
120 #endif |
3 | 121 |
122 #ifndef OS2 | |
123 #define OS2 | |
124 #endif /* OS2 */ | |
125 | |
126 #include <os2.h> | |
127 | |
128 #ifndef BKS_TABBEDDIALOG | |
129 #define BKS_TABBEDDIALOG 0x0800 | |
571
828e6a66c5c5
Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
557
diff
changeset
|
130 #endif |
3 | 131 |
41
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
132 #define PIPENAME "\\socket\\" __TARGET__ "%d" |
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
133 #define TPIPENAME "\\socket\\" __TARGET__ "%d" |
3 | 134 #else |
41
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
135 #define PIPENAME "/tmp/" __TARGET__ "%d" |
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
136 #define TPIPENAME "/tmp/" __TARGET__ "%d" |
3 | 137 #endif /* __EMX__ || __IBMC__ */ |
138 | |
172
0fc45e386376
Get Dynamic Windows building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
101
diff
changeset
|
139 #if defined(__OS2__) && (defined(__IBMC__) || defined(__WATCOMC__)) |
3 | 140 #define BSD_SELECT |
141 | |
142 #include <types.h> | |
143 #include <time.h> | |
144 #include <sys/stat.h> | |
145 #include <sys/select.h> | |
146 #include <sys/ioctl.h> | |
147 #include <direct.h> | |
148 #include <stdarg.h> | |
149 /* 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
|
150 #ifndef __WATCOMC__ |
24
d9e87e8bcf1d
Updated dynamic windows to build with EMX.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
151 #include "platform/dirent.h" |
3 | 152 #endif |
172
0fc45e386376
Get Dynamic Windows building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
101
diff
changeset
|
153 #endif |
3 | 154 |
155 /* Windows */ | |
156 #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
|
157 |
e0ea29c3d1eb
Fixed dw_window_pointer() so it works on Windows. Tried to fix the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
525
diff
changeset
|
158 #if defined(MSVC) && !defined(API) |
571
828e6a66c5c5
Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
557
diff
changeset
|
159 # ifdef __MINGW32__ |
828e6a66c5c5
Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
557
diff
changeset
|
160 # ifdef BUILD_DLL |
828e6a66c5c5
Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
557
diff
changeset
|
161 # define API APIENTRY __declspec(dllexport) |
828e6a66c5c5
Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
557
diff
changeset
|
162 # else |
828e6a66c5c5
Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
557
diff
changeset
|
163 # define API APIENTRY __declspec(dllimport) |
828e6a66c5c5
Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
557
diff
changeset
|
164 # endif |
828e6a66c5c5
Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
557
diff
changeset
|
165 # else |
828e6a66c5c5
Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
557
diff
changeset
|
166 # define API _cdecl |
828e6a66c5c5
Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
557
diff
changeset
|
167 # 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
|
168 #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
|
169 |
3 | 170 #include <windows.h> |
171 #include <winsock.h> | |
172 #include <time.h> | |
173 #include <process.h> | |
174 #include <sys/stat.h> | |
571
828e6a66c5c5
Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
557
diff
changeset
|
175 |
3 | 176 #ifdef MSVC |
24
d9e87e8bcf1d
Updated dynamic windows to build with EMX.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
177 #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
|
178 #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
|
179 #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
|
180 #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
|
181 #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
|
182 #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
|
183 #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
|
184 #endif |
3 | 185 #else |
186 #include <dir.h> | |
187 #include <dirent.h> | |
188 #endif | |
571
828e6a66c5c5
Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
557
diff
changeset
|
189 |
3 | 190 #include <stdarg.h> |
191 | |
571
828e6a66c5c5
Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
557
diff
changeset
|
192 #if defined(__CYGWIN32__) /*|| defined(__MINGW32__)*/ |
3 | 193 #include <sys/un.h> |
194 #endif /* __CYGWIN32__ || __MINGW32__ */ | |
195 | |
196 #ifndef __CYGWIN32__ | |
197 #define NO_DOMAIN_SOCKETS | |
198 #endif /* __CYGWIN32__ */ | |
199 | |
200 #if defined(_P_NOWAIT) && !defined(P_NOWAIT) | |
201 #define P_NOWAIT _P_NOWAIT | |
202 #endif | |
203 | |
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
|
204 #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
|
205 /* 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
|
206 # 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
|
207 # 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
|
208 # 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
|
209 # 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
|
210 # 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
|
211 # define unlink(a) _unlink(a) |
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
|
212 # define close(a) _close(a) |
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
|
213 # define fdopen(a, b) _fdopen(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
|
214 # define chdir(a) _chdir(a) |
1839
22225eb286e5
Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1715
diff
changeset
|
215 #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
|
216 # 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
|
217 #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
|
218 # 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
|
219 # 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
|
220 # 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
|
221 # 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
|
222 #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
|
223 #define msleep(a) Sleep(a) |
3 | 224 |
225 #endif /* WIN32 */ | |
226 | |
227 /* Everything else ;) */ | |
228 #include <stdio.h> | |
229 #ifdef HAVE_UNISTD_H | |
230 #include <unistd.h> | |
231 #endif /* HAVE_UNISTD_H */ | |
232 #ifdef HAVE_SYS_STAT_H | |
233 #include <sys/stat.h> | |
234 #endif | |
235 #include <stdlib.h> | |
236 #include <stddef.h> | |
237 #include <signal.h> | |
238 #include <fcntl.h> | |
239 | |
240 #if !defined(__WIN32__) && !defined(WINNT) | |
241 #include <sys/time.h> | |
242 #include <sys/socket.h> | |
243 #include <sys/un.h> | |
244 #include <netinet/in.h> | |
245 #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
|
246 #ifndef __IBMC__ |
1323
209d7f5137f2
Cleaned up the compatibility library header.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
908
diff
changeset
|
247 #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
|
248 #endif |
172
0fc45e386376
Get Dynamic Windows building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
101
diff
changeset
|
249 #if defined(__OS2__) && defined(RES_DEFAULT) |
0fc45e386376
Get Dynamic Windows building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
101
diff
changeset
|
250 #undef RES_DEFAULT |
0fc45e386376
Get Dynamic Windows building with Watcom.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
101
diff
changeset
|
251 #endif |
3 | 252 #include <stdarg.h> |
253 #include <string.h> | |
254 #endif /* !WIN32 */ | |
41
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
255 #include <ctype.h> |
3 | 256 |
257 #ifndef _MAX_PATH | |
258 #define _MAX_PATH 255 | |
259 #endif | |
260 | |
261 /* IBM C doesn't allow "t" in the mode parameter | |
262 * because it violates the ANSI standard. | |
263 */ | |
264 #ifdef __IBMC__ | |
265 #define FOPEN_READ_TEXT "r" | |
266 #define FOPEN_WRITE_TEXT "w" | |
267 #define FOPEN_APPEND_TEXT "a" | |
268 #else | |
269 #define FOPEN_READ_TEXT "rt" | |
270 #define FOPEN_WRITE_TEXT "wt" | |
271 #define FOPEN_APPEND_TEXT "at" | |
272 #endif | |
273 #define FOPEN_READ_BINARY "rb" | |
274 #define FOPEN_WRITE_BINARY "wb" | |
275 #define FOPEN_APPEND_BINARY "ab" | |
276 | |
174
75bf3051235f
Fixes so you can mix compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
172
diff
changeset
|
277 #ifndef API |
75bf3051235f
Fixes so you can mix compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
172
diff
changeset
|
278 #define API |
75bf3051235f
Fixes so you can mix compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
172
diff
changeset
|
279 #endif |
75bf3051235f
Fixes so you can mix compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
172
diff
changeset
|
280 |
580
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
281 /* 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
|
282 * 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
|
283 * compiler support. |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
284 */ |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
285 |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
286 #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
|
287 #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
|
288 #else |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
289 #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
|
290 #endif |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
291 |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
292 #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
|
293 #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
|
294 #else |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
295 #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
|
296 #endif |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
297 |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
298 #ifdef __IBMC__ |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
299 #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
|
300 #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
|
301 #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
|
302 #else |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
303 #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
|
304 #endif |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
305 |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
306 #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
|
307 #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
|
308 #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
|
309 #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
|
310 #else |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
311 #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
|
312 #endif |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
313 |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
314 #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
|
315 #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
|
316 #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
|
317 #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
|
318 #else |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
319 #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
|
320 #endif |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
321 |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
322 #ifdef __IBMC__ |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
323 #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
|
324 #elif defined(__WIN32__) || defined(WINNT) |
582
ce08e7a56724
Minor change to the Windows sockinit() macro.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
581
diff
changeset
|
325 #define sockinit() { static WSADATA wsa; WSAStartup(MAKEWORD (1, 1), &wsa); } |
580
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
326 #else /* !WIN32 */ |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
327 #define sockinit() |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
328 #endif |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
329 |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
330 #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
|
331 #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
|
332 #else /* !WIN32 */ |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
333 #define sockshutdown() |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
334 #endif |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
335 |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
336 #ifdef HAVE_PIPE |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
337 #define sockpipe(pipes) { if(pipe(pipes) < 0) 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
|
338 #elif !defined(NO_DOMAIN_SOCKETS) |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
339 #define sockpipe(pipes) { \ |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
340 struct sockaddr_un un; \ |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
341 int tmpsock = socket(AF_UNIX, SOCK_STREAM, 0); \ |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
342 pipes[1] = socket(AF_UNIX, SOCK_STREAM, 0); \ |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
343 memset(&un, 0, sizeof(un)); \ |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
344 un.sun_family=AF_UNIX; \ |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
345 sprintf(un.sun_path, PIPENAME, pipes[1]); \ |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
346 bind(tmpsock, (struct sockaddr *)&un, sizeof(un)); \ |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
347 listen(tmpsock, 0); \ |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
348 connect(pipes[1], (struct sockaddr *)&un, sizeof(un)); \ |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
349 pipes[0] = accept(tmpsock, 0, 0); \ |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
350 sockclose(tmpsock); \ |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
351 } |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
352 #else |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
353 #define sockpipe(pipes) { \ |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
354 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
|
355 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
|
356 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
|
357 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
|
358 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
|
359 if(he) \ |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
360 { \ |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
361 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
|
362 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
|
363 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
|
364 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
|
365 if ((tmpsock = socket(AF_INET, SOCK_STREAM, 0)) > -1 && bind(tmpsock, (struct sockaddr *)&server_addr, sizeof(server_addr)) > -1 && listen(tmpsock, 0) > -1) \ |
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
|
366 { \ |
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
|
367 memset(&listen_addr, 0, sizeof(listen_addr)); \ |
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
|
368 getsockname(tmpsock, (struct sockaddr *)&listen_addr, &len); \ |
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
|
369 server_addr.sin_family = AF_INET; \ |
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
|
370 server_addr.sin_port = listen_addr.sin_port; \ |
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
|
371 server_addr.sin_addr.s_addr = *((unsigned long *)he->h_addr); \ |
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
|
372 if((pipes[1] = socket(AF_INET, SOCK_STREAM, 0)) > -1 && !connect(pipes[1], (struct sockaddr *)&server_addr, sizeof(server_addr))) \ |
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
|
373 pipes[0] = accept(tmpsock, 0, 0); \ |
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
|
374 } \ |
580
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
375 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
|
376 } \ |
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
|
377 } |
580
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
378 #endif |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
379 |
1329
19bfcdbab74e
Hopefully the last socklen_t change... OS/2 needs it too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1328
diff
changeset
|
380 /* 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
|
381 #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
|
382 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
|
383 #endif |
03f0a57c9e87
Make sure socklen_t gets defined when building with Visual Studio.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1324
diff
changeset
|
384 |
1585
0576c5444587
Oops fallback dwstat didn't work quite right in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1584
diff
changeset
|
385 /* 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
|
386 #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
|
387 #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
|
388 #endif |
0576c5444587
Oops fallback dwstat didn't work quite right in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1584
diff
changeset
|
389 |
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
|
390 /* 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
|
391 #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
|
392 #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
|
393 #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
|
394 |
1839
22225eb286e5
Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1715
diff
changeset
|
395 #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
|
396 #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
|
397 # undef mkdir |
22225eb286e5
Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1715
diff
changeset
|
398 # 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
|
399 #endif |
1710
b217cf9161c7
Move some more platform specific code into dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1695
diff
changeset
|
400 #endif |
b217cf9161c7
Move some more platform specific code into dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1695
diff
changeset
|
401 |
580
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
402 #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
|
403 |
d7c338ac926a
Sweeping changes to the compatibility module, moved all socket code out
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
571
diff
changeset
|
404 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
|
405 int API makedir(char *path); |
75bf3051235f
Fixes so you can mix compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
172
diff
changeset
|
406 void API setfileinfo(char *filename, char *url, char *logfile); |
75bf3051235f
Fixes so you can mix compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
172
diff
changeset
|
407 long double API drivesize(int drive); |
75bf3051235f
Fixes so you can mix compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
172
diff
changeset
|
408 long double API drivefree(int drive); |
75bf3051235f
Fixes so you can mix compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
172
diff
changeset
|
409 int API isdrive(int drive); |
75bf3051235f
Fixes so you can mix compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
172
diff
changeset
|
410 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
|
411 FILE * API fsopen(char *path, char *modes); |
75bf3051235f
Fixes so you can mix compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
172
diff
changeset
|
412 int API fsclose(FILE *fp); |
75bf3051235f
Fixes so you can mix compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
172
diff
changeset
|
413 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
|
414 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
|
415 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
|
416 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
|
417 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
|
418 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
|
419 int API setpath(char *path); |
571
828e6a66c5c5
Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
557
diff
changeset
|
420 |
828e6a66c5c5
Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
557
diff
changeset
|
421 #ifdef __MINGW32__ |
828e6a66c5c5
Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
557
diff
changeset
|
422 # undef API |
828e6a66c5c5
Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
557
diff
changeset
|
423 # define API APIENTRY |
174
75bf3051235f
Fixes so you can mix compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
172
diff
changeset
|
424 #endif |
571
828e6a66c5c5
Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
557
diff
changeset
|
425 |
828e6a66c5c5
Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
557
diff
changeset
|
426 #endif |