summaryrefslogtreecommitdiffstats
path: root/cpukit/shttpd/compat_win32.h
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/shttpd/compat_win32.h')
-rw-r--r--cpukit/shttpd/compat_win32.h93
1 files changed, 93 insertions, 0 deletions
diff --git a/cpukit/shttpd/compat_win32.h b/cpukit/shttpd/compat_win32.h
new file mode 100644
index 0000000000..b45b713048
--- /dev/null
+++ b/cpukit/shttpd/compat_win32.h
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2004-2007 Sergey Lyubka <valenok@gmail.com>
+ * All rights reserved
+ *
+ * "THE BEER-WARE LICENSE" (Revision 42):
+ * Sergey Lyubka wrote this file. As long as you retain this notice you
+ * can do whatever you want with this stuff. If we meet some day, and you think
+ * this stuff is worth it, you can buy me a beer in return.
+ */
+
+/* Tip from Justin Maximilian, suppress errors from winsock2.h */
+#define _WINSOCKAPI_
+
+#include <windows.h>
+#include <winsock2.h>
+#include <commctrl.h>
+#include <winnls.h>
+#include <shlobj.h>
+#include <shellapi.h>
+
+#ifndef _WIN32_WCE
+
+#ifdef _MSC_VER /* pragmas not valid on MinGW */
+#pragma comment(lib,"ws2_32")
+#pragma comment(lib,"user32")
+#pragma comment(lib,"comctl32")
+#pragma comment(lib,"comdlg32")
+#pragma comment(lib,"shell32")
+#ifdef NO_GUI
+#pragma comment(linker,"/subsystem:console")
+#else
+#pragma comment(linker,"/subsystem:windows")
+#endif /* NO_GUI */
+#endif /* _MSC_VER */
+#include <process.h>
+#include <direct.h>
+#include <io.h>
+
+#else /* _WIN32_WCE */
+
+/* Windows CE-specific definitions */
+#define NO_CGI /* WinCE has no pipes */
+#define NO_GUI /* temporarily until it is fixed */
+#pragma comment(lib,"ws2")
+/* WinCE has both Unicode and ANSI versions of GetProcAddress */
+#undef GetProcAddress
+#define GetProcAddress GetProcAddressA
+#include "compat_wince.h"
+
+#endif /* _WIN32_WCE */
+
+#define ERRNO GetLastError()
+#define NO_SOCKLEN_T
+#define SSL_LIB L"libssl32.dll"
+#define DIRSEP '\\'
+#define IS_DIRSEP_CHAR(c) ((c) == '/' || (c) == '\\')
+#define O_NONBLOCK 0
+#define EWOULDBLOCK WSAEWOULDBLOCK
+#define snprintf _snprintf
+#define vsnprintf _vsnprintf
+#define mkdir(x,y) _mkdir(x)
+#define dlopen(x,y) LoadLibraryW(x)
+#define dlsym(x,y) (void *) GetProcAddress(x,y)
+#define _POSIX_
+
+#ifdef __LCC__
+#include <stdint.h>
+#endif /* __LCC__ */
+
+#ifdef _MSC_VER /* MinGW already has these */
+typedef unsigned int uint32_t;
+typedef unsigned short uint16_t;
+typedef __int64 uint64_t;
+#define S_ISDIR(x) ((x) & _S_IFDIR)
+#endif /* _MSC_VER */
+
+/*
+ * POSIX dirent interface
+ */
+struct dirent {
+ char d_name[FILENAME_MAX];
+};
+
+typedef struct DIR {
+ HANDLE handle;
+ WIN32_FIND_DATAW info;
+ struct dirent result;
+ char *name;
+} DIR;
+
+extern DIR *opendir(const char *name);
+extern int closedir(DIR *dir);
+extern struct dirent *readdir(DIR *dir);