00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #if defined(COMCTL32_V6)
00013 #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
00014 #endif
00015
00016 #if !defined(DSL_DLL) && !defined(DSL_STATIC)
00017 #pragma message( "Neither DSL_DLL or DSL_STATIC defined, defaulting to DSL_STATIC!" )
00018 #define DSL_STATIC
00019 #endif
00020
00021 #define PART1 ""
00022
00023 #if defined(DSL_STATIC)
00024 #define PART2 "-static"
00025 #else
00026 #define PART2 ""
00027 #endif
00028
00029 #if defined(DEBUG)
00030 #define LIBSUFFIX "_d"
00031 #else
00032 #define LIBSUFFIX ""
00033 #endif
00034
00035 #ifndef DSL_EXPORTS
00036 #define LIBNAME "dsl" PART1 "-core" PART2 LIBSUFFIX ".lib"
00037 #pragma message( "Will automatically link with " LIBNAME "" )
00038 #pragma comment(lib, LIBNAME)
00039 #endif
00040 #if defined(ENABLE_CURL) && !defined(DSL_CURL_EXPORTS)
00041 #define LIBNAMECURL "dsl" PART1 "-curl" PART2 LIBSUFFIX ".lib"
00042 #pragma message( "Will automatically link with " LIBNAMECURL "" )
00043 #pragma comment(lib, LIBNAMECURL)
00044 #endif
00045 #if defined(ENABLE_SQLITE) && !defined(DSL_SQLITE_EXPORTS)
00046 #define LIBNAMESQLITE "dsl" PART1 "-sqlite" PART2 LIBSUFFIX ".lib"
00047 #pragma message( "Will automatically link with " LIBNAMESQLITE "" )
00048 #pragma comment(lib, LIBNAMESQLITE)
00049 #endif
00050 #if defined(ENABLE_MYSQL) && !defined(DSL_MYSQL_EXPORTS)
00051 #define LIBNAMEMYSQL "dsl" PART1 "-mysql" PART2 LIBSUFFIX ".lib"
00052 #pragma message( "Will automatically link with " LIBNAMEMYSQL "" )
00053 #pragma comment(lib, LIBNAMEMYSQL)
00054 #endif
00055 #if defined(ENABLE_PHYSFS) && !defined(DSL_PHYSFS_EXPORTS)
00056 #define LIBNAMEPHYSFS "dsl" PART1 "-physfs" PART2 LIBSUFFIX ".lib"
00057 #pragma message( "Will automatically link with " LIBNAMEPHYSFS "" )
00058 #pragma comment(lib, LIBNAMEPHYSFS)
00059 #endif
00060 #if defined(ENABLE_OPENSSL) && !defined(DSL_OPENSSL_EXPORTS)
00061 #define LIBNAMEOPENSSL "dsl" PART1 "-openssl" PART2 LIBSUFFIX ".lib"
00062 #pragma message( "Will automatically link with " LIBNAMEOPENSSL "" )
00063 #pragma comment(lib, LIBNAMEOPENSSL)
00064 #endif
00065 #if defined(ENABLE_GNUTLS) && !defined(DSL_GNUTLS_EXPORTS)
00066 #define LIBNAMEGNUTLS "dsl" PART1 "-gnutls" PART2 LIBSUFFIX ".lib"
00067 #pragma message( "Will automatically link with " LIBNAMEGNUTLS "" )
00068 #pragma comment(lib, LIBNAMEGNUTLS)
00069 #endif
00070 #if defined(ENABLE_SODIUM) && !defined(DSL_SODIUM_EXPORTS)
00071 #define LIBNAMESODIUM "dsl" PART1 "-sodium" PART2 LIBSUFFIX ".lib"
00072 #pragma message( "Will automatically link with " LIBNAMESODIUM "" )
00073 #pragma comment(lib, LIBNAMESODIUM)
00074 #endif
00075
00076 #if defined(DSL_DLL)
00077 #if defined(DSL_EXPORTS)
00078 #define DSL_API extern "C" __declspec(dllexport)
00079 #define DSL_API_CLASS __declspec(dllexport)
00080 #else
00081 #define DSL_API extern "C" __declspec(dllimport)
00082 #define DSL_API_CLASS __declspec(dllimport)
00083 #endif
00084 #else
00085 #define DSL_API
00086 #define DSL_API_CLASS
00087 #endif
00088 #define DSL_DEPRECATE __declspec(deprecated)
00089
00090 #ifndef _CRT_SECURE_NO_DEPRECATE
00091 #define _CRT_SECURE_NO_DEPRECATE
00092 #endif
00093 #ifndef _CRT_NONSTDC_NO_DEPRECATE
00094 #define _CRT_NONSTDC_NO_DEPRECATE
00095 #endif
00096
00097
00098
00099 #ifndef _WINSOCK_DEPRECATED_NO_WARNINGS
00100 #define _WINSOCK_DEPRECATED_NO_WARNINGS
00101 #endif
00102
00103 #pragma warning(disable: 4251)
00104 #pragma warning(disable: 4800) //'int' : forcing value to bool 'true' or 'false' (performance warning)
00105 #pragma warning(disable: 4995)
00106
00107 #ifndef _WIN32_WINNT
00108 #define _WIN32_WINNT 0x0501
00109 #endif
00110
00111
00112
00113 #include <Ws2tcpip.h>
00114
00115 #include <Wspiapi.h>
00116 #include <windows.h>
00117 #include <commctrl.h>
00118
00119 #include <stdlib.h>
00120 #include <stdio.h>
00121 #include <string.h>
00122 #include <malloc.h>
00123 #include <sys/stat.h>
00124 #include <errno.h>
00125 #include <sys/types.h>
00126 #include <time.h>
00127
00128 #include <wchar.h>
00129 #include <tchar.h>
00130 #include <limits.h>
00131 #include <io.h>
00132 #include <fcntl.h>
00133 #include <direct.h>
00134 #include <shlobj.h>
00135
00136 #if defined(NTDDI_WIN10_RS4)
00137 #include <afunix.h>
00138 #else
00139 #define UNIX_PATH_MAX 108
00140
00141 typedef struct sockaddr_un
00142 {
00143 ADDRESS_FAMILY sun_family;
00144 char sun_path[UNIX_PATH_MAX];
00145 } SOCKADDR_UN, *PSOCKADDR_UN;
00146 #endif
00147
00148
00149 #pragma comment(lib, "ws2_32.lib")
00150 #pragma comment(lib, "comctl32.lib")
00151
00152 #if defined(ENABLE_GNUTLS)
00153 #pragma comment(lib, "libgnutls-30.lib")
00154 #endif
00155
00156 #if defined(ENABLE_OPENSSL)
00157 #if defined(DEBUG_SSL)
00158 #pragma comment(lib, "libssl32_d.lib")
00159 #pragma comment(lib, "libcrypto32_d.lib")
00160 #else
00161 #pragma comment(lib, "libssl32.lib")
00162 #pragma comment(lib, "libcrypto32.lib")
00163 #endif
00164 #endif
00165
00166 #if defined(ENABLE_MYSQL)
00167 #if defined(DEBUG_MYSQL)
00168 #pragma comment(lib, "libmariadb_d.lib")
00169 #else
00170 #pragma comment(lib, "libmariadb.lib")
00171 #endif
00172
00173 #endif
00174
00175 #if defined(ENABLE_SQLITE)
00176 #if defined(DEBUG)
00177 #pragma comment(lib, "sqlite3_d.lib")
00178 #else
00179 #pragma comment(lib, "sqlite3.lib")
00180 #endif
00181 #endif
00182
00183 #if defined(ENABLE_ZLIB)
00184 #if defined(DEBUG)
00185 #pragma comment(lib, "zlib-static_d.lib")
00186 #else
00187 #pragma comment(lib, "zlib-static.lib")
00188 #endif
00189 #endif
00190
00191 #if defined(ENABLE_CURL)
00192 #if defined(DEBUG)
00193 #pragma comment(lib, "libcurl_d.lib")
00194 #else
00195 #pragma comment(lib, "libcurl.lib")
00196 #endif
00197 #endif
00198
00199 #if defined(ENABLE_PHYSFS)
00200 #if defined(DEBUG)
00201 #pragma comment(lib, "physfs_d.lib")
00202 #else
00203 #pragma comment(lib, "physfs.lib")
00204 #endif
00205 #endif
00206
00207 #if defined(ENABLE_SODIUM)
00208 #pragma comment(lib, "libsodium.lib")
00209 #endif
00210
00211
00212 #if defined(_WIN64) || defined(WIN64)
00213 #if !defined(WIN64)
00214 #define WIN64
00215 #endif
00216 #define PLATFORM "Win64"
00217 #define CPU "x64"
00218
00219 #define DSL_CC
00220 #else
00221 #define PLATFORM "Win32"
00222 #define CPU "x86"
00223 #define DSL_CC __stdcall
00224 #endif
00225
00226 #include <drift/win32/poll.h>
00227
00228
00229 #define THREADTYPE unsigned __stdcall
00230 typedef unsigned (__stdcall *ThreadProto)(void *);
00231
00240 #if !defined(EWOULDBLOCK) || EWOULDBLOCK != WSAEWOULDBLOCK
00241 #undef EWOULDBLOCK
00242 #define EWOULDBLOCK WSAEWOULDBLOCK
00243 #endif
00244 #ifndef ENOTCONN
00245 #define ENOTCONN WSAENOTCONN
00246 #endif
00247 #ifndef EINPROGRESS
00248 #define EINPROGRESS WSAEINPROGRESS
00249 #endif
00250 #define R_OK 0x04
00251 #define W_OK 0x02
00252 #define F_OK 0x00
00253
00254
00255 #define snprintf _snprintf
00256 #define wfopen _wfopen
00257 #define getcwd _getcwd
00258 #define snwprintf _snwprintf
00259 #define vscprintf _vscprintf
00260 #define vscwprintf _vscwprintf
00261 #define wgetenv _wgetenv
00262 #define access _access
00263 #define stricmp _stricmp
00264 #define atoi64(x) _atoi64(x)
00265 #define atou64(x) _strtoui64(x, NULL, 10)
00266 #define atoul(x) strtoul(x, NULL, 10)
00267 #define S_ISDIR(x) (x & _S_IFDIR)
00268 #define S_ISREG(x) (x & _S_IFREG)
00269 #define S_ISEXEC(x) (x & _S_IEXEC)
00270 #define S_ISLNK(x) (0)
00271 #define stat64 _stati64
00272 #define lseek64 _lseeki64
00273 #define tell64 _telli64
00274 #define ftruncate _chsize_s
00275 #define dsl_mkdir(x,y) _mkdir(x)
00276
00277 #define tcslen _tcslen
00278 #define tcscpy _tcscpy
00279 #define tcsncpy _tcsncpy
00280 #define tcscat _tcscat
00281 #define tprintf _tprintf
00282 #define tsnprintf _sntprintf
00283 #define tcschr _tcschr
00284 #define tcsrchr _tcsrchr
00285 #define stprintf _stprintf
00286 #define tstoi _tstoi
00287 #define tcscmp tcscmp
00288 #define tcsicmp _tcsicmp
00289 #define tcsncmp _tcsncmp
00290 #define tcsnicmp _tcsnicmp
00291