aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac2
-rw-r--r--src/daemon/Makefile.am1
-rw-r--r--src/daemon/daemon.c4
-rw-r--r--src/daemon/internal.h12
-rw-r--r--src/daemon/minimal_example.c2
-rw-r--r--src/daemon/plibc.h587
-rw-r--r--src/include/microhttpd.h4
7 files changed, 607 insertions, 5 deletions
diff --git a/configure.ac b/configure.ac
index e2d57e5e..eb6591a7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -83,7 +83,7 @@ netbsd*)
83*mingw*) 83*mingw*)
84 AC_DEFINE_UNQUOTED(MINGW,1,[This is a MinGW system]) 84 AC_DEFINE_UNQUOTED(MINGW,1,[This is a MinGW system])
85 AC_DEFINE_UNQUOTED(WINDOWS,1,[This is a Windows system]) 85 AC_DEFINE_UNQUOTED(WINDOWS,1,[This is a Windows system])
86 LDFLAGS="$LDFLAGS -no-undefined -Wl,--export-all-symbols -lws2_32" 86 LDFLAGS="$LDFLAGS -no-undefined -Wl,--export-all-symbols -lws2_32 -lplibc"
87 ;; 87 ;;
88*) 88*)
89 AC_MSG_RESULT(Unrecognised OS $host_os) 89 AC_MSG_RESULT(Unrecognised OS $host_os)
diff --git a/src/daemon/Makefile.am b/src/daemon/Makefile.am
index c86ed072..048c3176 100644
--- a/src/daemon/Makefile.am
+++ b/src/daemon/Makefile.am
@@ -12,6 +12,7 @@ libmicrohttpd_la_LDFLAGS = \
12libmicrohttpd_la_SOURCES = \ 12libmicrohttpd_la_SOURCES = \
13 daemon.c \ 13 daemon.c \
14 internal.c internal.h \ 14 internal.c internal.h \
15 plibc.h \
15 response.c response.h \ 16 response.c response.h \
16 session.c session.h 17 session.c session.h
17 18
diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c
index e00d1c45..9aad7593 100644
--- a/src/daemon/daemon.c
+++ b/src/daemon/daemon.c
@@ -561,6 +561,8 @@ MHD_stop_daemon(struct MHD_Daemon * daemon) {
561 free(daemon); 561 free(daemon);
562} 562}
563 563
564#ifndef WINDOWS
565
564static struct sigaction sig; 566static struct sigaction sig;
565 567
566static struct sigaction old; 568static struct sigaction old;
@@ -584,4 +586,6 @@ void __attribute__ ((destructor)) pthread_handlers_ltdl_fini() {
584 sigaction(SIGALRM, &old, &sig); 586 sigaction(SIGALRM, &old, &sig);
585} 587}
586 588
589#endif
590
587/* end of daemon.c */ 591/* end of daemon.c */
diff --git a/src/daemon/internal.h b/src/daemon/internal.h
index ee5e1f97..2022b77e 100644
--- a/src/daemon/internal.h
+++ b/src/daemon/internal.h
@@ -32,18 +32,22 @@
32 32
33#include <stdio.h> 33#include <stdio.h>
34#include <stdlib.h> 34#include <stdlib.h>
35#include <netdb.h>
36#include <string.h> 35#include <string.h>
37#include <unistd.h> 36#include <unistd.h>
38#include <stdarg.h> 37#include <stdarg.h>
39#include <errno.h> 38#include <errno.h>
40#include <fcntl.h> 39#include <fcntl.h>
41#include <signal.h> 40#include <signal.h>
42#include <pthread.h>
43#include <netinet/in.h>
44 41
45#include "microhttpd.h"
46#include "config.h" 42#include "config.h"
43#include "microhttpd.h"
44
45#ifndef MINGW
46#include <netdb.h>
47#include <netinet/in.h>
48#endif
49
50#include <pthread.h>
47 51
48#define MHD_MAX_BUF_SIZE 2048 52#define MHD_MAX_BUF_SIZE 2048
49 53
diff --git a/src/daemon/minimal_example.c b/src/daemon/minimal_example.c
index 009721d6..6dad8180 100644
--- a/src/daemon/minimal_example.c
+++ b/src/daemon/minimal_example.c
@@ -27,7 +27,9 @@
27#include "config.h" 27#include "config.h"
28#include <microhttpd.h> 28#include <microhttpd.h>
29#include <stdlib.h> 29#include <stdlib.h>
30#ifndef MINGW
30#include <unistd.h> 31#include <unistd.h>
32#endif
31#include <string.h> 33#include <string.h>
32#include <stdio.h> 34#include <stdio.h>
33 35
diff --git a/src/daemon/plibc.h b/src/daemon/plibc.h
new file mode 100644
index 00000000..65c431d5
--- /dev/null
+++ b/src/daemon/plibc.h
@@ -0,0 +1,587 @@
1/*
2 This file is part of PlibC.
3 (C) 2005, 2006, 2007 Nils Durner (and other contributing authors)
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18*/
19
20/**
21 * @file include/plibc.h
22 * @brief PlibC header
23 * @attention This file is usually not installed under Unix,
24 * so ship it with your application
25 * @version $Revision: 1.37 $
26 */
27
28#ifndef _PLIBC_H_
29#define _PLIBC_H_
30
31#ifndef SIGALRM
32 #define SIGALRM 14
33#endif
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
39#ifdef Q_OS_WIN32
40 #define WINDOWS 1
41#endif
42
43#ifdef WINDOWS
44
45#if ENABLE_NLS
46 #include "langinfo.h"
47#endif
48
49#include <windows.h>
50#include <Ws2tcpip.h>
51#include <time.h>
52#include <stdio.h>
53#include <sys/types.h>
54#include <sys/stat.h>
55#include <dirent.h>
56#include <errno.h>
57#include <stdarg.h>
58
59#define __BYTE_ORDER BYTE_ORDER
60#define __BIG_ENDIAN BIG_ENDIAN
61
62/* Conflicts with our definitions */
63#define __G_WIN32_H__
64
65/* Convert LARGE_INTEGER to double */
66#define Li2Double(x) ((double)((x).HighPart) * 4.294967296E9 + \
67 (double)((x).LowPart))
68
69#define socklen_t int
70#define ssize_t int
71#ifndef HAVE_FTRUNCATE
72#define ftruncate chsize
73#endif
74#define off_t int
75#define int64_t long long
76#define int32_t long
77
78struct stat64
79{
80 _dev_t st_dev;
81 _ino_t st_ino;
82 _mode_t st_mode;
83 short st_nlink;
84 short st_uid;
85 short st_gid;
86 _dev_t st_rdev;
87 __int64 st_size;
88 __time64_t st_atime;
89 __time64_t st_mtime;
90 __time64_t st_ctime;
91};
92
93#ifndef pid_t
94 #define pid_t int
95#endif
96
97#ifndef WEXITSTATUS
98 #define WEXITSTATUS(status) (((status) & 0xff00) >> 8)
99#endif
100
101/* Thanks to the Cygwin project */
102#define ENOCSI 43 /* No CSI structure available */
103#define EL2HLT 44 /* Level 2 halted */
104#ifndef EDEADLK
105 #define EDEADLK 45 /* Deadlock condition */
106#endif
107#ifndef ENOLCK
108 #define ENOLCK 46 /* No record locks available */
109#endif
110#define EBADE 50 /* Invalid exchange */
111#define EBADR 51 /* Invalid request descriptor */
112#define EXFULL 52 /* Exchange full */
113#define ENOANO 53 /* No anode */
114#define EBADRQC 54 /* Invalid request code */
115#define EBADSLT 55 /* Invalid slot */
116#ifndef EDEADLOCK
117 #define EDEADLOCK EDEADLK /* File locking deadlock error */
118#endif
119#define EBFONT 57 /* Bad font file fmt */
120#define ENOSTR 60 /* Device not a stream */
121#define ENODATA 61 /* No data (for no delay io) */
122#define ETIME 62 /* Timer expired */
123#define ENOSR 63 /* Out of streams resources */
124#define ENONET 64 /* Machine is not on the network */
125#define ENOPKG 65 /* Package not installed */
126#define EREMOTE 66 /* The object is remote */
127#define ENOLINK 67 /* The link has been severed */
128#define EADV 68 /* Advertise error */
129#define ESRMNT 69 /* Srmount error */
130#define ECOMM 70 /* Communication error on send */
131#define EPROTO 71 /* Protocol error */
132#define EMULTIHOP 74 /* Multihop attempted */
133#define ELBIN 75 /* Inode is remote (not really error) */
134#define EDOTDOT 76 /* Cross mount point (not really error) */
135#define EBADMSG 77 /* Trying to read unreadable message */
136#define ENOTUNIQ 80 /* Given log. name not unique */
137#define EBADFD 81 /* f.d. invalid for this operation */
138#define EREMCHG 82 /* Remote address changed */
139#define ELIBACC 83 /* Can't access a needed shared lib */
140#define ELIBBAD 84 /* Accessing a corrupted shared lib */
141#define ELIBSCN 85 /* .lib section in a.out corrupted */
142#define ELIBMAX 86 /* Attempting to link in too many libs */
143#define ELIBEXEC 87 /* Attempting to exec a shared library */
144#ifndef ENOSYS
145 #define ENOSYS 88 /* Function not implemented */
146#endif
147#define ENMFILE 89 /* No more files */
148#ifndef ENOTEMPTY
149 #define ENOTEMPTY 90 /* Directory not empty */
150#endif
151#ifndef ENAMETOOLONG
152 #define ENAMETOOLONG 91 /* File or path name too long */
153#endif
154#define ELOOP 92 /* Too many symbolic links */
155#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */
156#define EPFNOSUPPORT 96 /* Protocol family not supported */
157#define ECONNRESET 104 /* Connection reset by peer */
158#define ENOBUFS 105 /* No buffer space available */
159#define EAFNOSUPPORT 106 /* Address family not supported by protocol family */
160#define EPROTOTYPE 107 /* Protocol wrong type for socket */
161#define ENOTSOCK 108 /* Socket operation on non-socket */
162#define ENOPROTOOPT 109 /* Protocol not available */
163#define ESHUTDOWN 110 /* Can't send after socket shutdown */
164#define ECONNREFUSED 111 /* Connection refused */
165#define EADDRINUSE 112 /* Address already in use */
166#define ECONNABORTED 113 /* Connection aborted */
167#define ENETUNREACH 114 /* Network is unreachable */
168#define ENETDOWN 115 /* Network interface is not configured */
169#ifndef ETIMEDOUT
170 #define ETIMEDOUT 116 /* Connection timed out */
171#endif
172#define EHOSTDOWN 117 /* Host is down */
173#define EHOSTUNREACH 118 /* Host is unreachable */
174#define EINPROGRESS 119 /* Connection already in progress */
175#define EALREADY 120 /* Socket already connected */
176#define EDESTADDRREQ 121 /* Destination address required */
177#define EMSGSIZE 122 /* Message too long */
178#define EPROTONOSUPPORT 123 /* Unknown protocol */
179#define ESOCKTNOSUPPORT 124 /* Socket type not supported */
180#define EADDRNOTAVAIL 125 /* Address not available */
181#define ENETRESET 126 /* Connection aborted by network */
182#define EISCONN 127 /* Socket is already connected */
183#define ENOTCONN 128 /* Socket is not connected */
184#define ETOOMANYREFS 129 /* Too many references: cannot splice */
185#define EPROCLIM 130 /* Too many processes */
186#define EUSERS 131 /* Too many users */
187#define EDQUOT 132 /* Disk quota exceeded */
188#define ESTALE 133 /* Unknown error */
189#ifndef ENOTSUP
190 #define ENOTSUP 134 /* Not supported */
191#endif
192#define ENOMEDIUM 135 /* No medium (in tape drive) */
193#define ENOSHARE 136 /* No such host or network path */
194#define ECASECLASH 137 /* Filename exists with different case */
195#define EWOULDBLOCK EAGAIN /* Operation would block */
196#define EOVERFLOW 139 /* Value too large for defined data type */
197
198#undef HOST_NOT_FOUND
199#define HOST_NOT_FOUND 1
200#undef TRY_AGAIN
201#define TRY_AGAIN 2
202#undef NO_RECOVERY
203#define NO_RECOVERY 3
204#undef NO_ADDRESS
205#define NO_ADDRESS 4
206
207#define PROT_READ 0x1
208#define PROT_WRITE 0x2
209#define MAP_SHARED 0x1
210#define MAP_PRIVATE 0x2 /* unsupported */
211#define MAP_FIXED 0x10
212#define MAP_FAILED ((void *)-1)
213
214struct statfs
215{
216 long f_type; /* type of filesystem (see below) */
217 long f_bsize; /* optimal transfer block size */
218 long f_blocks; /* total data blocks in file system */
219 long f_bfree; /* free blocks in fs */
220 long f_bavail; /* free blocks avail to non-superuser */
221 long f_files; /* total file nodes in file system */
222 long f_ffree; /* free file nodes in fs */
223 long f_fsid; /* file system id */
224 long f_namelen; /* maximum length of filenames */
225 long f_spare[6]; /* spare for later */
226};
227
228/* Taken from the Wine project <http://www.winehq.org>
229 /wine/include/winternl.h */
230enum SYSTEM_INFORMATION_CLASS
231{
232 SystemBasicInformation = 0,
233 Unknown1,
234 SystemPerformanceInformation = 2,
235 SystemTimeOfDayInformation = 3, /* was SystemTimeInformation */
236 Unknown4,
237 SystemProcessInformation = 5,
238 Unknown6,
239 Unknown7,
240 SystemProcessorPerformanceInformation = 8,
241 Unknown9,
242 Unknown10,
243 SystemDriverInformation,
244 Unknown12,
245 Unknown13,
246 Unknown14,
247 Unknown15,
248 SystemHandleList,
249 Unknown17,
250 Unknown18,
251 Unknown19,
252 Unknown20,
253 SystemCacheInformation,
254 Unknown22,
255 SystemInterruptInformation = 23,
256 SystemExceptionInformation = 33,
257 SystemRegistryQuotaInformation = 37,
258 SystemLookasideInformation = 45
259};
260
261typedef struct
262{
263 LARGE_INTEGER IdleTime;
264 LARGE_INTEGER KernelTime;
265 LARGE_INTEGER UserTime;
266 LARGE_INTEGER Reserved1[2];
267 ULONG Reserved2;
268} SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION;
269
270#define sleep(secs) (Sleep(secs * 1000))
271
272/*********************** statfs *****************************/
273/* fake block size */
274#define FAKED_BLOCK_SIZE 512
275
276/* linux-compatible values for fs type */
277#define MSDOS_SUPER_MAGIC 0x4d44
278#define NTFS_SUPER_MAGIC 0x5346544E
279
280/*********************** End of statfs ***********************/
281
282#define SHUT_RDWR SD_BOTH
283
284/* Operations for flock() */
285#define LOCK_SH 1 /* shared lock */
286#define LOCK_EX 2 /* exclusive lock */
287#define LOCK_NB 4 /* or'd with one of the above to prevent
288 blocking */
289#define LOCK_UN 8 /* remove lock */
290
291/* Not supported under MinGW */
292#define S_IRGRP 0
293#define S_IWGRP 0
294#define S_IROTH 0
295#define S_IXGRP 0
296#define S_IWOTH 0
297#define S_IXOTH 0
298#define S_ISUID 0
299#define S_ISGID 0
300#define S_ISVTX 0
301#define S_IRWXG 0
302#define S_IRWXO 0
303
304#define SetErrnoFromWinError(e) _SetErrnoFromWinError(e, __FILE__, __LINE__)
305
306/**
307 * @brief index() - same as strchr()
308 */
309#define index(s, c) strchr(s, c)
310
311BOOL _plibc_CreateShortcut(const char *pszSrc, const char *pszDest);
312BOOL _plibc_DereferenceShortcut(char *pszShortcut);
313char *plibc_ChooseDir(char *pszTitle, unsigned long ulFlags);
314char *plibc_ChooseFile(char *pszTitle, unsigned long ulFlags);
315long QueryRegistry(HKEY hMainKey, char *pszKey, char *pszSubKey,
316 char *pszBuffer, long *pdLength);
317
318BOOL __win_IsHandleMarkedAsBlocking(SOCKET hHandle);
319void __win_SetHandleBlockingMode(SOCKET s, BOOL bBlocking);
320void __win_DiscardHandleBlockingMode(SOCKET s);
321int _win_isSocketValid(int s);
322int plibc_conv_to_win_path(const char *pszUnix, char *pszWindows);
323
324typedef void (*TPanicProc) (int, char *);
325void plibc_set_panic_proc(TPanicProc proc);
326
327int flock(int fd, int operation);
328int fsync(int fildes);
329int inet_pton(int af, const char *src, void *dst);
330int inet_pton4(const char *src, u_char *dst, int pton);
331#if USE_IPV6
332int inet_pton6(const char *src, u_char *dst);
333#endif
334int truncate(const char *fname, int distance);
335int statfs(const char *path, struct statfs *buf);
336const char *hstrerror(int err);
337void gettimeofday(struct timeval *tp, void *tzp);
338int mkstemp(char *tmplate);
339char *strptime (const char *buf, const char *format, struct tm *tm);
340char *ctime(const time_t *clock);
341char *ctime_r(const time_t *clock, char *buf);
342int plibc_init(char *pszOrg, char *pszApp);
343void plibc_shutdown();
344int plibc_initialized();
345int plibc_conv_to_win_path_ex(const char *pszUnix, char *pszWindows, int derefLinks);
346void _SetErrnoFromWinError(long lWinError, char *pszCaller, int iLine);
347void SetErrnoFromWinsockError(long lWinError);
348void SetHErrnoFromWinError(long lWinError);
349void SetErrnoFromHRESULT(HRESULT hRes);
350FILE *_win_fopen(const char *filename, const char *mode);
351DIR *_win_opendir(const char *dirname);
352int _win_open(const char *filename, int oflag, ...);
353#ifdef ENABLE_NLS
354char *_win_bindtextdomain(const char *domainname, const char *dirname);
355#endif
356int _win_chdir(const char *path);
357int _win_close(int fd);
358int _win_creat(const char *path, mode_t mode);
359int _win_fstat(int handle, struct stat *buffer);
360int _win_pipe(int *phandles);
361int _win_rmdir(const char *path);
362int _win_access( const char *path, int mode );
363int _win_chmod(const char *filename, int pmode);
364char *realpath(const char *file_name, char *resolved_name);
365long _win_random(void);
366int _win_remove(const char *path);
367int _win_rename(const char *oldname, const char *newname);
368int _win_stat(const char *path, struct stat *buffer);
369int _win_stat64(const char *path, struct stat64 *buffer);
370int _win_unlink(const char *filename);
371int _win_write(int fildes, const void *buf, size_t nbyte);
372int _win_read(int fildes, void *buf, size_t nbyte);
373size_t _win_fwrite(const void *buffer, size_t size, size_t count, FILE *stream);
374size_t _win_fread( void *buffer, size_t size, size_t count, FILE *stream );
375int _win_symlink(const char *path1, const char *path2);
376void *_win_mmap(void *start, size_t len, int access, int flags, int fd,
377 unsigned long long offset);
378int _win_munmap(void *start, size_t length);
379int _win_lstat(const char *path, struct stat *buf);
380int _win_lstat64(const char *path, struct stat64 *buf);
381int _win_readlink(const char *path, char *buf, size_t bufsize);
382int _win_accept(SOCKET s, struct sockaddr *addr, int *addrlen);
383int _win_printf(const char *format,...);
384int _win_fprintf(FILE *f,const char *format,...);
385int _win_vprintf(const char *format, va_list ap);
386int _win_vfprintf(FILE *stream, const char *format, va_list arg_ptr);
387int _win_vsprintf(char *dest,const char *format, va_list arg_ptr);
388int _win_vsnprintf(char* str, size_t size, const char *format, va_list arg_ptr);
389int _win_snprintf(char *str,size_t size,const char *format,...);
390int _win_sprintf(char *dest,const char *format,...);
391int _win_vsscanf(const char* str, const char* format, va_list arg_ptr);
392int _win_sscanf(const char *str, const char *format, ...);
393int _win_vfscanf(FILE *stream, const char *format, va_list arg_ptr);
394int _win_vscanf(const char *format, va_list arg_ptr);
395int _win_scanf(const char *format, ...);
396int _win_fscanf(FILE *stream, const char *format, ...);
397pid_t _win_waitpid(pid_t pid, int *stat_loc, int options);
398int _win_bind(SOCKET s, const struct sockaddr *name, int namelen);
399int _win_connect(SOCKET s,const struct sockaddr *name, int namelen);
400int _win_getpeername(SOCKET s, struct sockaddr *name,
401 int *namelen);
402int _win_getsockname(SOCKET s, struct sockaddr *name,
403 int *namelen);
404int _win_getsockopt(SOCKET s, int level, int optname, char *optval,
405 int *optlen);
406int _win_listen(SOCKET s, int backlog);
407int _win_recv(SOCKET s, char *buf, int len, int flags);
408int _win_recvfrom(SOCKET s, void *buf, int len, int flags,
409 struct sockaddr *from, int *fromlen);
410int _win_select(int max_fd, fd_set * rfds, fd_set * wfds, fd_set * efds,
411 const struct timeval *tv);
412int _win_send(SOCKET s, const char *buf, int len, int flags);
413int _win_sendto(SOCKET s, const char *buf, int len, int flags,
414 const struct sockaddr *to, int tolen);
415int _win_setsockopt(SOCKET s, int level, int optname, const void *optval,
416 int optlen);
417int _win_shutdown(SOCKET s, int how);
418SOCKET _win_socket(int af, int type, int protocol);
419struct hostent *_win_gethostbyaddr(const char *addr, int len, int type);
420struct hostent *_win_gethostbyname(const char *name);
421char *_win_strerror(int errnum);
422int IsWinNT();
423
424#if !HAVE_STRNDUP
425char *strndup (const char *s, size_t n);
426#endif
427#if !HAVE_STRNLEN
428size_t strnlen (const char *str, size_t maxlen);
429#endif
430
431#define strcasecmp(a, b) stricmp(a, b)
432#define strncasecmp(a, b, c) strnicmp(a, b, c)
433
434#endif /* WINDOWS */
435
436#ifndef WINDOWS
437 #define DIR_SEPARATOR '/'
438 #define DIR_SEPARATOR_STR "/"
439 #define PATH_SEPARATOR ';'
440 #define PATH_SEPARATOR_STR ";"
441 #define NEWLINE "\n"
442
443#ifdef ENABLE_NLS
444 #define BINDTEXTDOMAIN(d, n) bindtextdomain(d, n)
445#endif
446 #define CREAT(p, m) creat(p, m)
447 #undef FOPEN
448 #define FOPEN(f, m) fopen(f, m)
449 #define OPENDIR(d) opendir(d)
450 #define OPEN(f) open(f)
451 #define CHDIR(d) chdir(d)
452 #define CLOSE(f) close(f)
453 #define RMDIR(f) rmdir(f)
454 #define ACCESS(p, m) access(p, m)
455 #define CHMOD(f, p) chmod(f, p)
456 #define FSTAT(h, b) fstat(h, b)
457 #define PIPE(h) pipe(h)
458 #define REMOVE(p) remove(p)
459 #define RENAME(o, n) rename(o, n)
460 #define STAT(p, b) stat(p, b)
461 #define STAT64(p, b) stat64(p, b)
462 #define UNLINK(f) unlink(f)
463 #define WRITE(f, b, n) write(f, b, n)
464 #define READ(f, b, n) read(f, b, n)
465 #define GN_FREAD(b, s, c, f) fread(b, s, c, f)
466 #define GN_FWRITE(b, s, c, f) fwrite(b, s, c, f)
467 #define SYMLINK(a, b) symlink(a, b)
468 #define MMAP(s, l, p, f, d, o) mmap(s, l, p, f, d, o)
469 #define MUNMAP(s, l) munmap(s, l)
470 #define STRERROR(i) strerror(i)
471 #define RANDOM() random()
472 #define READLINK(p, b, s) readlink(p, b, s)
473 #define LSTAT(p, b) lstat(p, b)
474 #define LSTAT64(p, b) lstat64(p, b)
475 #define PRINTF printf
476 #define FPRINTF fprintf
477 #define VPRINTF(f, a) vprintf(f, a)
478 #define VFPRINTF(s, f, a) vfprintf(s, f, a)
479 #define VSPRINTF(d, f, a) vsprintf(d, f, a)
480 #define VSNPRINTF(str, size, fmt, a) vsnprintf(str, size, fmt, a)
481 #define _REAL_SNPRINTF snprintf
482 #define SPRINTF sprintf
483 #define VSSCANF(s, f, a) vsscanf(s, f, a)
484 #define SSCANF sscanf
485 #define VFSCANF(s, f, a) vfscanf(s, f, a)
486 #define VSCANF(f, a) vscanf(f, a)
487 #define SCANF scanf
488 #define FSCANF fscanf
489 #define WAITPID(p, s, o) waitpid(p, s, o)
490 #define ACCEPT(s, a, l) accept(s, a, l)
491 #define BIND(s, n, l) bind(s, n, l)
492 #define CONNECT(s, n, l) connect(s, n, l)
493 #define GETPEERNAME(s, n, l) getpeername(s, n, l)
494 #define GETSOCKNAME(s, n, l) getsockname(s, n, l)
495 #define GETSOCKOPT(s, l, o, v, p) getsockopt(s, l, o, v, p)
496 #define LISTEN(s, b) listen(s, b)
497 #define RECV(s, b, l, f) recv(s, b, l, f)
498 #define RECVFROM(s, b, l, f, r, o) recvfrom(s, b, l, f, r, o)
499 #define SELECT(n, r, w, e, t) select(n, r, w, e, t)
500 #define SEND(s, b, l, f) send(s, b, l, f)
501 #define SENDTO(s, b, l, f, o, n) sendto(s, b, l, f, o, n)
502 #define SETSOCKOPT(s, l, o, v, n) setsockopt(s, l, o, v, n)
503 #define SHUTDOWN(s, h) shutdown(s, h)
504 #define SOCKET(a, t, p) socket(a, t, p)
505 #define GETHOSTBYADDR(a, l, t) gethostbyname(a, l, t)
506 #define GETHOSTBYNAME(n) gethostbyname(n)
507#else
508 #define DIR_SEPARATOR '\\'
509 #define DIR_SEPARATOR_STR "\\"
510 #define PATH_SEPARATOR ':'
511 #define PATH_SEPARATOR_STR ":"
512 #define NEWLINE "\r\n"
513
514#ifdef ENABLE_NLS
515 #define BINDTEXTDOMAIN(d, n) _win_bindtextdomain(d, n)
516#endif
517 #define CREAT(p, m) _win_creat(p, m)
518 #define FOPEN(f, m) _win_fopen(f, m)
519 #define OPENDIR(d) _win_opendir(d)
520 #define OPEN(f) _win_open(f)
521 #define CHDIR(d) _win_chdir(d)
522 #define CLOSE(f) _win_close(f)
523 #define FSTAT(h, b) _win_fstat(h, b)
524 #define RMDIR(f) _win_rmdir(f)
525 #define ACCESS(p, m) _win_access(p, m)
526 #define CHMOD(f, p) _win_chmod(f, p)
527 #define PIPE(h) _win_pipe(h)
528 #define RANDOM() _win_random()
529 #define REMOVE(p) _win_remove(p)
530 #define RENAME(o, n) _win_rename(o, n)
531 #define STAT(p, b) _win_stat(p, b)
532 #define STAT64(p, b) _win_stat64(p, b)
533 #define UNLINK(f) _win_unlink(f)
534 #define WRITE(f, b, n) _win_write(f, b, n)
535 #define READ(f, b, n) _win_read(f, b, n)
536 #define GN_FREAD(b, s, c, f) _win_fread(b, s, c, f)
537 #define GN_FWRITE(b, s, c, f) _win_fwrite(b, s, c, f)
538 #define SYMLINK(a, b) _win_symlink(a, b)
539 #define MMAP(s, l, p, f, d, o) _win_mmap(s, l, p, f, d, o)
540 #define MUNMAP(s, l) _win_munmap(s, l)
541 #define STRERROR(i) _win_strerror(i)
542 #define READLINK(p, b, s) _win_readlink(p, b, s)
543 #define LSTAT(p, b) _win_lstat(p, b)
544 #define LSTAT64(p, b) _win_lstat64(p, b)
545 #define PRINTF(f, ...) _win_printf(f , __VA_ARGS__)
546 #define FPRINTF(fil, fmt, ...) _win_fprintf(fil, fmt, __VA_ARGS__)
547 #define VPRINTF(f, a) _win_vprintf(f, a)
548 #define VFPRINTF(s, f, a) _win_vfprintf(s, f, a)
549 #define VSPRINTF(d, f, a) _win_vsprintf(d, f, a)
550 #define VSNPRINTF(str, size, fmt, a) _win_vsnprintf(str, size, fmt, a)
551 #define _REAL_SNPRINTF(str, size, fmt, ...) _win_snprintf(str, size, fmt, __VA_ARGS__)
552 #define SPRINTF(d, f, ...) _win_sprintf(d, f, __VA_ARGS__)
553 #define VSSCANF(s, f, a) _win_vsscanf(s, f, a)
554 #define SSCANF(s, f, ...) _win_sscanf(s, f, __VA_ARGS__)
555 #define VFSCANF(s, f, a) _win_vfscanf(s, f, a)
556 #define VSCANF(f, a) _win_vscanf(f, a)
557 #define SCANF(f, ...) _win_scanf(f, __VA_ARGS__)
558 #define FSCANF(s, f, ...) _win_fscanf(s, f, __VA_ARGS__)
559 #define WAITPID(p, s, o) _win_waitpid(p, s, o)
560 #define ACCEPT(s, a, l) _win_accept(s, a, l)
561 #define BIND(s, n, l) _win_bind(s, n, l)
562 #define CONNECT(s, n, l) _win_connect(s, n, l)
563 #define GETPEERNAME(s, n, l) _win_getpeername(s, n, l)
564 #define GETSOCKNAME(s, n, l) _win_getsockname(s, n, l)
565 #define GETSOCKOPT(s, l, o, v, p) _win_getsockopt(s, l, o, v, p)
566 #define LISTEN(s, b) _win_listen(s, b)
567 #define RECV(s, b, l, f) _win_recv(s, b, l, f)
568 #define RECVFROM(s, b, l, f, r, o) _win_recvfrom(s, b, l, f, r, o)
569 #define SELECT(n, r, w, e, t) _win_select(n, r, w, e, t)
570 #define SEND(s, b, l, f) _win_send(s, b, l, f)
571 #define SENDTO(s, b, l, f, o, n) _win_sendto(s, b, l, f, o, n)
572 #define SETSOCKOPT(s, l, o, v, n) _win_setsockopt(s, l, o, v, n)
573 #define SHUTDOWN(s, h) _win_shutdown(s, h)
574 #define SOCKET(a, t, p) _win_socket(a, t, p)
575 #define GETHOSTBYADDR(a, l, t) _win_gethostbyname(a, l, t)
576 #define GETHOSTBYNAME(n) _win_gethostbyname(n)
577#endif
578
579
580#ifdef __cplusplus
581}
582#endif
583
584
585#endif //_PLIBC_H_
586
587/* end of plibc.h */
diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h
index d0b1b5dc..cca58347 100644
--- a/src/include/microhttpd.h
+++ b/src/include/microhttpd.h
@@ -47,8 +47,12 @@
47#define MHD_MICROHTTPD_H 47#define MHD_MICROHTTPD_H
48 48
49#include <sys/types.h> 49#include <sys/types.h>
50#ifndef MINGW
50#include <sys/select.h> 51#include <sys/select.h>
51#include <sys/socket.h> 52#include <sys/socket.h>
53#else
54#include "plibc.h"
55#endif
52 56
53#ifdef __cplusplus 57#ifdef __cplusplus
54extern "C" { 58extern "C" {