summaryrefslogtreecommitdiffstats
path: root/cpukit/shttpd/compat_win32.h
blob: b45b7130481b312ee1b52bee770ca8544cc11db7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
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);