aboutsummaryrefslogtreecommitdiff
path: root/src/include/plibc.h
diff options
context:
space:
mode:
authorNils Durner <durner@gnunet.org>2009-06-10 22:24:54 +0000
committerNils Durner <durner@gnunet.org>2009-06-10 22:24:54 +0000
commit9cf5b99404c1f3694417b2e4900771398022fd23 (patch)
treee6e8f99d21a6ae94894c774b7505b95ae370ccff /src/include/plibc.h
parent812138f1d6cbd39d2ec623f2201bb034ab4ac3d2 (diff)
downloadgnunet-9cf5b99404c1f3694417b2e4900771398022fd23.tar.gz
gnunet-9cf5b99404c1f3694417b2e4900771398022fd23.zip
MinGW
Diffstat (limited to 'src/include/plibc.h')
-rw-r--r--src/include/plibc.h1026
1 files changed, 614 insertions, 412 deletions
diff --git a/src/include/plibc.h b/src/include/plibc.h
index 93ca012e1..51d78fc7e 100644
--- a/src/include/plibc.h
+++ b/src/include/plibc.h
@@ -1,17 +1,17 @@
1/* 1/*
2 This file is part of PlibC. 2 This file is part of PlibC.
3 (C) 2005, 2006, 2007, 2008 Nils Durner (and other contributing authors) 3 (C) 2005, 2006, 2007, 2008, 2009 Nils Durner (and other contributing authors)
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public 6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version. 8 version 2.1 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details. 13 Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU Lesser General Public 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 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 17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -22,33 +22,33 @@
22 * @brief PlibC header 22 * @brief PlibC header
23 * @attention This file is usually not installed under Unix, 23 * @attention This file is usually not installed under Unix,
24 * so ship it with your application 24 * so ship it with your application
25 * @version $Revision: 1.46 $ 25 * @version $Revision: 39 $
26 */ 26 */
27 27
28#ifndef _PLIBC_H_ 28#ifndef _PLIBC_H_
29#define _PLIBC_H_ 29#define _PLIBC_H_
30 30
31#ifndef SIGALRM 31#ifndef SIGALRM
32#define SIGALRM 14 32 #define SIGALRM 14
33#endif /* */ 33#endif
34 34
35#ifdef __cplusplus 35#ifdef __cplusplus
36extern "C" 36extern "C" {
37{ 37#endif
38 38
39#endif /* */ 39#include <stddef.h>
40 40
41#ifdef Q_OS_WIN32 41#ifdef Q_OS_WIN32
42#define WINDOWS 1 42 #define WINDOWS 1
43#endif /* */ 43#endif
44 44
45#define HAVE_PLIBC_FD 0 45#define HAVE_PLIBC_FD 0
46 46
47#ifdef WINDOWS 47#ifdef WINDOWS
48 48
49#if ENABLE_NLS 49#if ENABLE_NLS
50#include "langinfo.h" 50 #include "langinfo.h"
51#endif /* */ 51#endif
52 52
53#include <windows.h> 53#include <windows.h>
54#include <Ws2tcpip.h> 54#include <Ws2tcpip.h>
@@ -68,14 +68,16 @@ extern "C"
68 68
69/* Convert LARGE_INTEGER to double */ 69/* Convert LARGE_INTEGER to double */
70#define Li2Double(x) ((double)((x).HighPart) * 4.294967296E9 + \ 70#define Li2Double(x) ((double)((x).HighPart) * 4.294967296E9 + \
71 (double) ((x).LowPart)) 71 (double)((x).LowPart))
72
72#define socklen_t int 73#define socklen_t int
73#define ssize_t int 74#define ssize_t int
74#define off_t int 75#define off_t int
75#define int64_t long long 76#define int64_t long long
76#define int32_t long 77#define int32_t long
77 struct stat64 78
78 { 79struct stat64
80{
79 _dev_t st_dev; 81 _dev_t st_dev;
80 _ino_t st_ino; 82 _ino_t st_ino;
81 _mode_t st_mode; 83 _mode_t st_mode;
@@ -87,112 +89,116 @@ extern "C"
87 __time64_t st_atime; 89 __time64_t st_atime;
88 __time64_t st_mtime; 90 __time64_t st_mtime;
89 __time64_t st_ctime; 91 __time64_t st_ctime;
90 }; 92};
91 93
92#ifndef pid_t 94#ifndef pid_t
93#define pid_t int 95 #define pid_t int
94#endif /* */ 96#endif
95 97
96#ifndef WEXITSTATUS 98#ifndef WEXITSTATUS
97#define WEXITSTATUS(status) (((status) & 0xff00) >> 8) 99 #define WEXITSTATUS(status) (((status) & 0xff00) >> 8)
98#endif /* */ 100#endif
101
102#ifndef MSG_DONTWAIT
103 #define MSG_DONTWAIT 0
104#endif
99 105
100/* Thanks to the Cygwin project */ 106/* Thanks to the Cygwin project */
101#define ENOCSI 43 /* No CSI structure available */ 107#define ENOCSI 43 /* No CSI structure available */
102#define EL2HLT 44 /* Level 2 halted */ 108#define EL2HLT 44 /* Level 2 halted */
103#ifndef EDEADLK 109#ifndef EDEADLK
104#define EDEADLK 45 /* Deadlock condition */ 110 #define EDEADLK 45 /* Deadlock condition */
105#endif /* */ 111#endif
106#ifndef ENOLCK 112#ifndef ENOLCK
107#define ENOLCK 46 /* No record locks available */ 113 #define ENOLCK 46 /* No record locks available */
108#endif /* */ 114#endif
109#define EBADE 50 /* Invalid exchange */ 115#define EBADE 50 /* Invalid exchange */
110#define EBADR 51 /* Invalid request descriptor */ 116#define EBADR 51 /* Invalid request descriptor */
111#define EXFULL 52 /* Exchange full */ 117#define EXFULL 52 /* Exchange full */
112#define ENOANO 53 /* No anode */ 118#define ENOANO 53 /* No anode */
113#define EBADRQC 54 /* Invalid request code */ 119#define EBADRQC 54 /* Invalid request code */
114#define EBADSLT 55 /* Invalid slot */ 120#define EBADSLT 55 /* Invalid slot */
115#ifndef EDEADLOCK 121#ifndef EDEADLOCK
116#define EDEADLOCK EDEADLK /* File locking deadlock error */ 122 #define EDEADLOCK EDEADLK /* File locking deadlock error */
117#endif /* */ 123#endif
118#define EBFONT 57 /* Bad font file fmt */ 124#define EBFONT 57 /* Bad font file fmt */
119#define ENOSTR 60 /* Device not a stream */ 125#define ENOSTR 60 /* Device not a stream */
120#define ENODATA 61 /* No data (for no delay io) */ 126#define ENODATA 61 /* No data (for no delay io) */
121#define ETIME 62 /* Timer expired */ 127#define ETIME 62 /* Timer expired */
122#define ENOSR 63 /* Out of streams resources */ 128#define ENOSR 63 /* Out of streams resources */
123#define ENONET 64 /* Machine is not on the network */ 129#define ENONET 64 /* Machine is not on the network */
124#define ENOPKG 65 /* Package not installed */ 130#define ENOPKG 65 /* Package not installed */
125#define EREMOTE 66 /* The object is remote */ 131#define EREMOTE 66 /* The object is remote */
126#define ENOLINK 67 /* The link has been severed */ 132#define ENOLINK 67 /* The link has been severed */
127#define EADV 68 /* Advertise error */ 133#define EADV 68 /* Advertise error */
128#define ESRMNT 69 /* Srmount error */ 134#define ESRMNT 69 /* Srmount error */
129#define ECOMM 70 /* Communication error on send */ 135#define ECOMM 70 /* Communication error on send */
130#define EPROTO 71 /* Protocol error */ 136#define EPROTO 71 /* Protocol error */
131#define EMULTIHOP 74 /* Multihop attempted */ 137#define EMULTIHOP 74 /* Multihop attempted */
132#define ELBIN 75 /* Inode is remote (not really error) */ 138#define ELBIN 75 /* Inode is remote (not really error) */
133#define EDOTDOT 76 /* Cross mount point (not really error) */ 139#define EDOTDOT 76 /* Cross mount point (not really error) */
134#define EBADMSG 77 /* Trying to read unreadable message */ 140#define EBADMSG 77 /* Trying to read unreadable message */
135#define ENOTUNIQ 80 /* Given log. name not unique */ 141#define ENOTUNIQ 80 /* Given log. name not unique */
136#define EBADFD 81 /* f.d. invalid for this operation */ 142#define EBADFD 81 /* f.d. invalid for this operation */
137#define EREMCHG 82 /* Remote address changed */ 143#define EREMCHG 82 /* Remote address changed */
138#define ELIBACC 83 /* Can't access a needed shared lib */ 144#define ELIBACC 83 /* Can't access a needed shared lib */
139#define ELIBBAD 84 /* Accessing a corrupted shared lib */ 145#define ELIBBAD 84 /* Accessing a corrupted shared lib */
140#define ELIBSCN 85 /* .lib section in a.out corrupted */ 146#define ELIBSCN 85 /* .lib section in a.out corrupted */
141#define ELIBMAX 86 /* Attempting to link in too many libs */ 147#define ELIBMAX 86 /* Attempting to link in too many libs */
142#define ELIBEXEC 87 /* Attempting to exec a shared library */ 148#define ELIBEXEC 87 /* Attempting to exec a shared library */
143#ifndef ENOSYS 149#ifndef ENOSYS
144#define ENOSYS 88 /* Function not implemented */ 150 #define ENOSYS 88 /* Function not implemented */
145#endif /* */ 151#endif
146#define ENMFILE 89 /* No more files */ 152#define ENMFILE 89 /* No more files */
147#ifndef ENOTEMPTY 153#ifndef ENOTEMPTY
148#define ENOTEMPTY 90 /* Directory not empty */ 154 #define ENOTEMPTY 90 /* Directory not empty */
149#endif /* */ 155#endif
150#ifndef ENAMETOOLONG 156#ifndef ENAMETOOLONG
151#define ENAMETOOLONG 91 /* File or path name too long */ 157 #define ENAMETOOLONG 91 /* File or path name too long */
152#endif /* */ 158#endif
153#define ELOOP 92 /* Too many symbolic links */ 159#define ELOOP 92 /* Too many symbolic links */
154#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ 160#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */
155#define EPFNOSUPPORT 96 /* Protocol family not supported */ 161#define EPFNOSUPPORT 96 /* Protocol family not supported */
156#define ECONNRESET 104 /* Connection reset by peer */ 162#define ECONNRESET 104 /* Connection reset by peer */
157#define ENOBUFS 105 /* No buffer space available */ 163#define ENOBUFS 105 /* No buffer space available */
158#define EAFNOSUPPORT 106 /* Address family not supported by protocol family */ 164#define EAFNOSUPPORT 106 /* Address family not supported by protocol family */
159#define EPROTOTYPE 107 /* Protocol wrong type for socket */ 165#define EPROTOTYPE 107 /* Protocol wrong type for socket */
160#define ENOTSOCK 108 /* Socket operation on non-socket */ 166#define ENOTSOCK 108 /* Socket operation on non-socket */
161#define ENOPROTOOPT 109 /* Protocol not available */ 167#define ENOPROTOOPT 109 /* Protocol not available */
162#define ESHUTDOWN 110 /* Can't send after socket shutdown */ 168#define ESHUTDOWN 110 /* Can't send after socket shutdown */
163#define ECONNREFUSED 111 /* Connection refused */ 169#define ECONNREFUSED 111 /* Connection refused */
164#define EADDRINUSE 112 /* Address already in use */ 170#define EADDRINUSE 112 /* Address already in use */
165#define ECONNABORTED 113 /* Connection aborted */ 171#define ECONNABORTED 113 /* Connection aborted */
166#define ENETUNREACH 114 /* Network is unreachable */ 172#define ENETUNREACH 114 /* Network is unreachable */
167#define ENETDOWN 115 /* Network interface is not configured */ 173#define ENETDOWN 115 /* Network interface is not configured */
168#ifndef ETIMEDOUT 174#ifndef ETIMEDOUT
169#define ETIMEDOUT 116 /* Connection timed out */ 175 #define ETIMEDOUT 116 /* Connection timed out */
170#endif /* */ 176#endif
171#define EHOSTDOWN 117 /* Host is down */ 177#define EHOSTDOWN 117 /* Host is down */
172#define EHOSTUNREACH 118 /* Host is unreachable */ 178#define EHOSTUNREACH 118 /* Host is unreachable */
173#define EINPROGRESS 119 /* Connection already in progress */ 179#define EINPROGRESS 119 /* Connection already in progress */
174#define EALREADY 120 /* Socket already connected */ 180#define EALREADY 120 /* Socket already connected */
175#define EDESTADDRREQ 121 /* Destination address required */ 181#define EDESTADDRREQ 121 /* Destination address required */
176#define EMSGSIZE 122 /* Message too long */ 182#define EMSGSIZE 122 /* Message too long */
177#define EPROTONOSUPPORT 123 /* Unknown protocol */ 183#define EPROTONOSUPPORT 123 /* Unknown protocol */
178#define ESOCKTNOSUPPORT 124 /* Socket type not supported */ 184#define ESOCKTNOSUPPORT 124 /* Socket type not supported */
179#define EADDRNOTAVAIL 125 /* Address not available */ 185#define EADDRNOTAVAIL 125 /* Address not available */
180#define ENETRESET 126 /* Connection aborted by network */ 186#define ENETRESET 126 /* Connection aborted by network */
181#define EISCONN 127 /* Socket is already connected */ 187#define EISCONN 127 /* Socket is already connected */
182#define ENOTCONN 128 /* Socket is not connected */ 188#define ENOTCONN 128 /* Socket is not connected */
183#define ETOOMANYREFS 129 /* Too many references: cannot splice */ 189#define ETOOMANYREFS 129 /* Too many references: cannot splice */
184#define EPROCLIM 130 /* Too many processes */ 190#define EPROCLIM 130 /* Too many processes */
185#define EUSERS 131 /* Too many users */ 191#define EUSERS 131 /* Too many users */
186#define EDQUOT 132 /* Disk quota exceeded */ 192#define EDQUOT 132 /* Disk quota exceeded */
187#define ESTALE 133 /* Unknown error */ 193#define ESTALE 133 /* Unknown error */
188#ifndef ENOTSUP 194#ifndef ENOTSUP
189#define ENOTSUP 134 /* Not supported */ 195 #define ENOTSUP 134 /* Not supported */
190#endif /* */ 196#endif
191#define ENOMEDIUM 135 /* No medium (in tape drive) */ 197#define ENOMEDIUM 135 /* No medium (in tape drive) */
192#define ENOSHARE 136 /* No such host or network path */ 198#define ENOSHARE 136 /* No such host or network path */
193#define ECASECLASH 137 /* Filename exists with different case */ 199#define ECASECLASH 137 /* Filename exists with different case */
194#define EWOULDBLOCK EAGAIN /* Operation would block */ 200#define EWOULDBLOCK EAGAIN /* Operation would block */
195#define EOVERFLOW 139 /* Value too large for defined data type */ 201#define EOVERFLOW 139 /* Value too large for defined data type */
196 202
197#undef HOST_NOT_FOUND 203#undef HOST_NOT_FOUND
198#define HOST_NOT_FOUND 1 204#define HOST_NOT_FOUND 1
@@ -206,46 +212,68 @@ extern "C"
206#define PROT_READ 0x1 212#define PROT_READ 0x1
207#define PROT_WRITE 0x2 213#define PROT_WRITE 0x2
208#define MAP_SHARED 0x1 214#define MAP_SHARED 0x1
209#define MAP_PRIVATE 0x2 /* unsupported */ 215#define MAP_PRIVATE 0x2 /* unsupported */
210#define MAP_FIXED 0x10 216#define MAP_FIXED 0x10
211#define MAP_FAILED ((void *)-1) 217#define MAP_FAILED ((void *)-1)
212 struct statfs 218
213 { 219struct statfs
214 long f_type; /* type of filesystem (see below) */ 220{
215 long f_bsize; /* optimal transfer block size */ 221 long f_type; /* type of filesystem (see below) */
216 long f_blocks; /* total data blocks in file system */ 222 long f_bsize; /* optimal transfer block size */
217 long f_bfree; /* free blocks in fs */ 223 long f_blocks; /* total data blocks in file system */
218 long f_bavail; /* free blocks avail to non-superuser */ 224 long f_bfree; /* free blocks in fs */
219 long f_files; /* total file nodes in file system */ 225 long f_bavail; /* free blocks avail to non-superuser */
220 long f_ffree; /* free file nodes in fs */ 226 long f_files; /* total file nodes in file system */
221 long f_fsid; /* file system id */ 227 long f_ffree; /* free file nodes in fs */
222 long f_namelen; /* maximum length of filenames */ 228 long f_fsid; /* file system id */
223 long f_spare[6]; /* spare for later */ 229 long f_namelen; /* maximum length of filenames */
224 }; 230 long f_spare[6]; /* spare for later */
225 extern const struct in6_addr in6addr_any; /* :: */ 231};
226 extern const struct in6_addr in6addr_loopback; /* ::1 */ 232
233extern const struct in6_addr in6addr_any; /* :: */
234extern const struct in6_addr in6addr_loopback; /* ::1 */
227 235
228/* Taken from the Wine project <http://www.winehq.org> 236/* Taken from the Wine project <http://www.winehq.org>
229 /wine/include/winternl.h */ 237 /wine/include/winternl.h */
230 enum SYSTEM_INFORMATION_CLASS 238enum SYSTEM_INFORMATION_CLASS
231 { SystemBasicInformation = 0, Unknown1, SystemPerformanceInformation = 2, SystemTimeOfDayInformation = 3, /* was SystemTimeInformation */ 239{
232 Unknown4, SystemProcessInformation = 240 SystemBasicInformation = 0,
233 5, Unknown6, Unknown7, SystemProcessorPerformanceInformation = 241 Unknown1,
234 8, Unknown9, Unknown10, SystemDriverInformation, Unknown12, 242 SystemPerformanceInformation = 2,
235 Unknown13, Unknown14, Unknown15, SystemHandleList, Unknown17, 243 SystemTimeOfDayInformation = 3, /* was SystemTimeInformation */
236 Unknown18, Unknown19, Unknown20, SystemCacheInformation, 244 Unknown4,
237 Unknown22, SystemInterruptInformation = 245 SystemProcessInformation = 5,
238 23, SystemExceptionInformation = 246 Unknown6,
239 33, SystemRegistryQuotaInformation = 37, SystemLookasideInformation = 45 247 Unknown7,
240 }; 248 SystemProcessorPerformanceInformation = 8,
241 typedef struct 249 Unknown9,
242 { 250 Unknown10,
251 SystemDriverInformation,
252 Unknown12,
253 Unknown13,
254 Unknown14,
255 Unknown15,
256 SystemHandleList,
257 Unknown17,
258 Unknown18,
259 Unknown19,
260 Unknown20,
261 SystemCacheInformation,
262 Unknown22,
263 SystemInterruptInformation = 23,
264 SystemExceptionInformation = 33,
265 SystemRegistryQuotaInformation = 37,
266 SystemLookasideInformation = 45
267};
268
269typedef struct
270{
243 LARGE_INTEGER IdleTime; 271 LARGE_INTEGER IdleTime;
244 LARGE_INTEGER KernelTime; 272 LARGE_INTEGER KernelTime;
245 LARGE_INTEGER UserTime; 273 LARGE_INTEGER UserTime;
246 LARGE_INTEGER Reserved1[2]; 274 LARGE_INTEGER Reserved1[2];
247 ULONG Reserved2; 275 ULONG Reserved2;
248 } SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION; 276} SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION;
249 277
250#define sleep(secs) (Sleep(secs * 1000)) 278#define sleep(secs) (Sleep(secs * 1000))
251 279
@@ -262,11 +290,11 @@ extern "C"
262#define SHUT_RDWR SD_BOTH 290#define SHUT_RDWR SD_BOTH
263 291
264/* Operations for flock() */ 292/* Operations for flock() */
265#define LOCK_SH 1 /* shared lock */ 293#define LOCK_SH 1 /* shared lock */
266#define LOCK_EX 2 /* exclusive lock */ 294#define LOCK_EX 2 /* exclusive lock */
267#define LOCK_NB 4 /* or'd with one of the above to prevent 295#define LOCK_NB 4 /* or'd with one of the above to prevent
268 blocking */ 296 blocking */
269#define LOCK_UN 8 /* remove lock */ 297#define LOCK_UN 8 /* remove lock */
270 298
271/* Not supported under MinGW */ 299/* Not supported under MinGW */
272#define S_IRGRP 0 300#define S_IRGRP 0
@@ -289,294 +317,468 @@ extern "C"
289#define SIGTERM 15 317#define SIGTERM 15
290 318
291#define SetErrnoFromWinError(e) _SetErrnoFromWinError(e, __FILE__, __LINE__) 319#define SetErrnoFromWinError(e) _SetErrnoFromWinError(e, __FILE__, __LINE__)
292 BOOL _plibc_CreateShortcut (const char *pszSrc, const char *pszDest);
293 BOOL _plibc_DereferenceShortcut (char *pszShortcut);
294 char *plibc_ChooseDir (char *pszTitle, unsigned long ulFlags);
295 char *plibc_ChooseFile (char *pszTitle, unsigned long ulFlags);
296 long QueryRegistry (HKEY hMainKey, char *pszKey, char *pszSubKey,
297 char *pszBuffer, long *pdLength);
298 BOOL __win_IsHandleMarkedAsBlocking (SOCKET hHandle);
299 void __win_SetHandleBlockingMode (SOCKET s, BOOL bBlocking);
300 void __win_DiscardHandleBlockingMode (SOCKET s);
301 int _win_isSocketValid (int s);
302 int plibc_conv_to_win_path (const char *pszUnix, char *pszWindows);
303 unsigned plibc_get_handle_count ();
304 typedef void (*TPanicProc) (int, char *);
305 void plibc_set_panic_proc (TPanicProc proc);
306 int flock (int fd, int operation);
307 int fsync (int fildes);
308 int inet_pton (int af, const char *src, void *dst);
309 int inet_pton4 (const char *src, u_char * dst, int pton);
310 320
321BOOL _plibc_CreateShortcut(const char *pszSrc, const char *pszDest);
322BOOL _plibc_DereferenceShortcut(char *pszShortcut);
323char *plibc_ChooseDir(char *pszTitle, unsigned long ulFlags);
324char *plibc_ChooseFile(char *pszTitle, unsigned long ulFlags);
325long QueryRegistry(HKEY hMainKey, char *pszKey, char *pszSubKey,
326 char *pszBuffer, long *pdLength);
327
328BOOL __win_IsHandleMarkedAsBlocking(SOCKET hHandle);
329void __win_SetHandleBlockingMode(SOCKET s, BOOL bBlocking);
330void __win_DiscardHandleBlockingMode(SOCKET s);
331int _win_isSocketValid(int s);
332int plibc_conv_to_win_path(const char *pszUnix, char *pszWindows);
333unsigned plibc_get_handle_count();
334
335typedef void (*TPanicProc) (int, char *);
336void plibc_set_panic_proc(TPanicProc proc);
337
338int flock(int fd, int operation);
339int fsync(int fildes);
340int inet_pton(int af, const char *src, void *dst);
341int inet_pton4(const char *src, u_char *dst, int pton);
311#if USE_IPV6 342#if USE_IPV6
312 int inet_pton6 (const char *src, u_char * dst); 343int inet_pton6(const char *src, u_char *dst);
313 344#endif
314#endif /* */ 345int truncate(const char *fname, int distance);
315 int truncate (const char *fname, int distance); 346int statfs(const char *path, struct statfs *buf);
316 int statfs (const char *path, struct statfs *buf); 347const char *hstrerror(int err);
317 const char *hstrerror (int err); 348int mkstemp(char *tmplate);
318 void gettimeofday (struct timeval *tp, void *tzp); 349char *strptime (const char *buf, const char *format, struct tm *tm);
319 int mkstemp (char *tmplate); 350const char *inet_ntop(int af, const void *src, char *dst, size_t size);
320 char *strptime (const char *buf, const char *format, struct tm *tm); 351
321 char *ctime (const time_t * clock); 352int plibc_init(char *pszOrg, char *pszApp);
322 char *ctime_r (const time_t * clock, char *buf); 353void plibc_shutdown();
323 const char *inet_ntop (int af, const void *src, char *dst, size_t size); 354int plibc_initialized();
324 int plibc_init (char *pszOrg, char *pszApp); 355int plibc_conv_to_win_path_ex(const char *pszUnix, char *pszWindows, int derefLinks);
325 void plibc_shutdown (); 356void _SetErrnoFromWinError(long lWinError, char *pszCaller, int iLine);
326 int plibc_initialized (); 357void SetErrnoFromWinsockError(long lWinError);
327 int plibc_conv_to_win_path_ex (const char *pszUnix, char *pszWindows, 358void SetHErrnoFromWinError(long lWinError);
328 int derefLinks); 359void SetErrnoFromHRESULT(HRESULT hRes);
329 void _SetErrnoFromWinError (long lWinError, char *pszCaller, int iLine); 360int GetErrnoFromWinsockError(long lWinError);
330 void SetErrnoFromWinsockError (long lWinError); 361FILE *_win_fopen(const char *filename, const char *mode);
331 void SetHErrnoFromWinError (long lWinError); 362DIR *_win_opendir(const char *dirname);
332 void SetErrnoFromHRESULT (HRESULT hRes); 363int _win_open(const char *filename, int oflag, ...);
333 FILE *_win_fopen (const char *filename, const char *mode);
334 DIR *_win_opendir (const char *dirname);
335 int _win_open (const char *filename, int oflag, ...);
336
337#ifdef ENABLE_NLS 364#ifdef ENABLE_NLS
338 char *_win_bindtextdomain (const char *domainname, const char *dirname); 365char *_win_bindtextdomain(const char *domainname, const char *dirname);
339 366#endif
340#endif /* */ 367int _win_chdir(const char *path);
341 int _win_chdir (const char *path); 368int _win_close(int fd);
342 int _win_close (int fd); 369int _win_creat(const char *path, mode_t mode);
343 int _win_creat (const char *path, mode_t mode); 370char *_win_ctime(const time_t *clock);
344 int _win_fstat (int handle, struct stat *buffer); 371char *_win_ctime_r(const time_t *clock, char *buf);
345 int _win_ftruncate (int fildes, off_t length); 372int _win_fstat(int handle, struct stat *buffer);
346 int _win_kill (pid_t pid, int sig); 373int _win_ftruncate(int fildes, off_t length);
347 int _win_pipe (int *phandles); 374void _win_gettimeofday(struct timeval *tp, void *tzp);
348 int _win_rmdir (const char *path); 375int _win_kill(pid_t pid, int sig);
349 int _win_access (const char *path, int mode); 376int _win_pipe(int *phandles);
350 int _win_chmod (const char *filename, int pmode); 377int _win_rmdir(const char *path);
351 char *realpath (const char *file_name, char *resolved_name); 378int _win_access( const char *path, int mode );
352 long _win_random (void); 379int _win_chmod(const char *filename, int pmode);
353 int _win_remove (const char *path); 380char *realpath(const char *file_name, char *resolved_name);
354 int _win_rename (const char *oldname, const char *newname); 381long _win_random(void);
355 int _win_stat (const char *path, struct stat *buffer); 382int _win_remove(const char *path);
356 int _win_stat64 (const char *path, struct stat64 *buffer); 383int _win_rename(const char *oldname, const char *newname);
357 int _win_unlink (const char *filename); 384int _win_stat(const char *path, struct stat *buffer);
358 int _win_write (int fildes, const void *buf, size_t nbyte); 385int _win_stat64(const char *path, struct stat64 *buffer);
359 int _win_read (int fildes, void *buf, size_t nbyte); 386int _win_unlink(const char *filename);
360 size_t _win_fwrite (const void *buffer, size_t size, size_t count, 387int _win_write(int fildes, const void *buf, size_t nbyte);
361 FILE * stream); 388int _win_read(int fildes, void *buf, size_t nbyte);
362 size_t _win_fread (void *buffer, size_t size, size_t count, FILE * stream); 389size_t _win_fwrite(const void *buffer, size_t size, size_t count, FILE *stream);
363 int _win_symlink (const char *path1, const char *path2); 390size_t _win_fread( void *buffer, size_t size, size_t count, FILE *stream );
364 void *_win_mmap (void *start, size_t len, int access, int flags, int fd, 391int _win_symlink(const char *path1, const char *path2);
365 unsigned long long offset); 392void *_win_mmap(void *start, size_t len, int access, int flags, int fd,
366 int _win_munmap (void *start, size_t length); 393 unsigned long long offset);
367 int _win_lstat (const char *path, struct stat *buf); 394int _win_munmap(void *start, size_t length);
368 int _win_lstat64 (const char *path, struct stat64 *buf); 395int _win_lstat(const char *path, struct stat *buf);
369 int _win_readlink (const char *path, char *buf, size_t bufsize); 396int _win_lstat64(const char *path, struct stat64 *buf);
370 int _win_accept (SOCKET s, struct sockaddr *addr, int *addrlen); 397int _win_readlink(const char *path, char *buf, size_t bufsize);
371 int _win_printf (const char *format, ...); 398int _win_accept(SOCKET s, struct sockaddr *addr, int *addrlen);
372 int _win_fprintf (FILE * f, const char *format, ...); 399int _win_printf(const char *format,...);
373 int _win_vprintf (const char *format, va_list ap); 400int _win_fprintf(FILE *f,const char *format,...);
374 int _win_vfprintf (FILE * stream, const char *format, va_list arg_ptr); 401int _win_vprintf(const char *format, va_list ap);
375 int _win_vsprintf (char *dest, const char *format, va_list arg_ptr); 402int _win_vfprintf(FILE *stream, const char *format, va_list arg_ptr);
376 int _win_vsnprintf (char *str, size_t size, const char *format, 403int _win_vsprintf(char *dest,const char *format, va_list arg_ptr);
377 va_list arg_ptr); 404int _win_vsnprintf(char* str, size_t size, const char *format, va_list arg_ptr);
378 int _win_snprintf (char *str, size_t size, const char *format, ...); 405int _win_snprintf(char *str,size_t size,const char *format,...);
379 int _win_sprintf (char *dest, const char *format, ...); 406int _win_sprintf(char *dest,const char *format,...);
380 int _win_vsscanf (const char *str, const char *format, va_list arg_ptr); 407int _win_vsscanf(const char* str, const char* format, va_list arg_ptr);
381 int _win_sscanf (const char *str, const char *format, ...); 408int _win_sscanf(const char *str, const char *format, ...);
382 int _win_vfscanf (FILE * stream, const char *format, va_list arg_ptr); 409int _win_vfscanf(FILE *stream, const char *format, va_list arg_ptr);
383 int _win_vscanf (const char *format, va_list arg_ptr); 410int _win_vscanf(const char *format, va_list arg_ptr);
384 int _win_scanf (const char *format, ...); 411int _win_scanf(const char *format, ...);
385 int _win_fscanf (FILE * stream, const char *format, ...); 412int _win_fscanf(FILE *stream, const char *format, ...);
386 pid_t _win_waitpid (pid_t pid, int *stat_loc, int options); 413pid_t _win_waitpid(pid_t pid, int *stat_loc, int options);
387 int _win_bind (SOCKET s, const struct sockaddr *name, int namelen); 414int _win_bind(SOCKET s, const struct sockaddr *name, int namelen);
388 int _win_connect (SOCKET s, const struct sockaddr *name, int namelen); 415int _win_connect(SOCKET s,const struct sockaddr *name, int namelen);
389 int _win_getpeername (SOCKET s, struct sockaddr *name, int *namelen); 416int _win_getpeername(SOCKET s, struct sockaddr *name,
390 int _win_getsockname (SOCKET s, struct sockaddr *name, int *namelen); 417 int *namelen);
391 int _win_getsockopt (SOCKET s, int level, int optname, char *optval, 418int _win_getsockname(SOCKET s, struct sockaddr *name,
392 int *optlen); 419 int *namelen);
393 int _win_listen (SOCKET s, int backlog); 420int _win_getsockopt(SOCKET s, int level, int optname, char *optval,
394 int _win_recv (SOCKET s, char *buf, int len, int flags); 421 int *optlen);
395 int _win_recvfrom (SOCKET s, void *buf, int len, int flags, 422int _win_listen(SOCKET s, int backlog);
396 struct sockaddr *from, int *fromlen); 423int _win_recv(SOCKET s, char *buf, int len, int flags);
397 int _win_select (int max_fd, fd_set * rfds, fd_set * wfds, fd_set * efds, 424int _win_recvfrom(SOCKET s, void *buf, int len, int flags,
398 const struct timeval *tv); 425 struct sockaddr *from, int *fromlen);
399 int _win_send (SOCKET s, const char *buf, int len, int flags); 426int _win_select(int max_fd, fd_set * rfds, fd_set * wfds, fd_set * efds,
400 int _win_sendto (SOCKET s, const char *buf, int len, int flags, 427 const struct timeval *tv);
401 const struct sockaddr *to, int tolen); 428int _win_send(SOCKET s, const char *buf, int len, int flags);
402 int _win_setsockopt (SOCKET s, int level, int optname, const void *optval, 429int _win_sendto(SOCKET s, const char *buf, int len, int flags,
403 int optlen); 430 const struct sockaddr *to, int tolen);
404 int _win_shutdown (SOCKET s, int how); 431int _win_setsockopt(SOCKET s, int level, int optname, const void *optval,
405 SOCKET _win_socket (int af, int type, int protocol); 432 int optlen);
406 struct hostent *_win_gethostbyaddr (const char *addr, int len, int type); 433int _win_shutdown(SOCKET s, int how);
407 struct hostent *_win_gethostbyname (const char *name); 434SOCKET _win_socket(int af, int type, int protocol);
408 struct hostent *gethostbyname2 (const char *name, int af); 435struct hostent *_win_gethostbyaddr(const char *addr, int len, int type);
409 char *_win_strerror (int errnum); 436struct hostent *_win_gethostbyname(const char *name);
410 int IsWinNT (); 437struct hostent *gethostbyname2(const char *name, int af);
411 char *index (const char *s, int c); 438char *_win_strerror(int errnum);
439int IsWinNT();
440char *index(const char *s, int c);
412 441
413#if !HAVE_STRNDUP 442#if !HAVE_STRNDUP
414 char *strndup (const char *s, size_t n); 443char *strndup (const char *s, size_t n);
415 444#endif
416#endif /* */
417#if !HAVE_STRNLEN 445#if !HAVE_STRNLEN
418 size_t strnlen (const char *str, size_t maxlen); 446size_t strnlen (const char *str, size_t maxlen);
419 447#endif
420#endif /* */
421 448
422#define strcasecmp(a, b) stricmp(a, b) 449#define strcasecmp(a, b) stricmp(a, b)
423#define strncasecmp(a, b, c) strnicmp(a, b, c) 450#define strncasecmp(a, b, c) strnicmp(a, b, c)
424 451
425#endif /* WINDOWS */ 452#endif /* WINDOWS */
426 453
427#ifndef WINDOWS 454#ifndef WINDOWS
428#define DIR_SEPARATOR '/' 455 #define DIR_SEPARATOR '/'
429#define DIR_SEPARATOR_STR "/" 456 #define DIR_SEPARATOR_STR "/"
430#define PATH_SEPARATOR ';' 457 #define PATH_SEPARATOR ';'
431#define PATH_SEPARATOR_STR ";" 458 #define PATH_SEPARATOR_STR ";"
432#define NEWLINE "\n" 459 #define NEWLINE "\n"
433 460
434#ifdef ENABLE_NLS 461#ifdef ENABLE_NLS
435#define BINDTEXTDOMAIN(d, n) bindtextdomain(d, n) 462 #define BINDTEXTDOMAIN(d, n) bindtextdomain(d, n)
436#endif /* */ 463#endif
437#define CREAT(p, m) creat(p, m) 464 #define CREAT(p, m) creat(p, m)
438#undef FOPEN 465 #define PLIBC_CTIME(c) ctime(c)
439#define FOPEN(f, m) fopen(f, m) 466 #define CTIME_R(c, b) ctime_r(c, b)
440#define FTRUNCATE(f, l) ftruncate(f, l) 467 #undef FOPEN
441#define OPENDIR(d) opendir(d) 468 #define FOPEN(f, m) fopen(f, m)
442#define OPEN open 469 #define FTRUNCATE(f, l) ftruncate(f, l)
443#define CHDIR(d) chdir(d) 470 #define OPENDIR(d) opendir(d)
444#define CLOSE(f) close(f) 471 #define OPEN open
445#define LSEEK(f, o, w) lseek(f, o, w) 472 #define CHDIR(d) chdir(d)
446#define RMDIR(f) rmdir(f) 473 #define CLOSE(f) close(f)
447#define ACCESS(p, m) access(p, m) 474 #define LSEEK(f, o, w) lseek(f, o, w)
448#define CHMOD(f, p) chmod(f, p) 475 #define RMDIR(f) rmdir(f)
449#define FSTAT(h, b) fstat(h, b) 476 #define ACCESS(p, m) access(p, m)
450#define PLIBC_KILL(p, s) kill(p, s) 477 #define CHMOD(f, p) chmod(f, p)
451#define PIPE(h) pipe(h) 478 #define FSTAT(h, b) fstat(h, b)
452#define REMOVE(p) remove(p) 479 #define PLIBC_KILL(p, s) kill(p, s)
453#define RENAME(o, n) rename(o, n) 480 #define PIPE(h) pipe(h)
454#define STAT(p, b) stat(p, b) 481 #define REMOVE(p) remove(p)
455#define STAT64(p, b) stat64(p, b) 482 #define RENAME(o, n) rename(o, n)
456#define UNLINK(f) unlink(f) 483 #define STAT(p, b) stat(p, b)
457#define WRITE(f, b, n) write(f, b, n) 484 #define STAT64(p, b) stat64(p, b)
458#define READ(f, b, n) read(f, b, n) 485 #define UNLINK(f) unlink(f)
459#define GN_FREAD(b, s, c, f) fread(b, s, c, f) 486 #define WRITE(f, b, n) write(f, b, n)
460#define GN_FWRITE(b, s, c, f) fwrite(b, s, c, f) 487 #define READ(f, b, n) read(f, b, n)
461#define SYMLINK(a, b) symlink(a, b) 488 #define GN_FREAD(b, s, c, f) fread(b, s, c, f)
462#define MMAP(s, l, p, f, d, o) mmap(s, l, p, f, d, o) 489 #define GN_FWRITE(b, s, c, f) fwrite(b, s, c, f)
463#define MUNMAP(s, l) munmap(s, l) 490 #define SYMLINK(a, b) symlink(a, b)
464#define STRERROR(i) strerror(i) 491 #define MMAP(s, l, p, f, d, o) mmap(s, l, p, f, d, o)
465#define RANDOM() random() 492 #define MUNMAP(s, l) munmap(s, l)
466#define READLINK(p, b, s) readlink(p, b, s) 493 #define STRERROR(i) strerror(i)
467#define LSTAT(p, b) lstat(p, b) 494 #define RANDOM() random()
468#define LSTAT64(p, b) lstat64(p, b) 495 #define READLINK(p, b, s) readlink(p, b, s)
469#define PRINTF printf 496 #define LSTAT(p, b) lstat(p, b)
470#define FPRINTF fprintf 497 #define LSTAT64(p, b) lstat64(p, b)
471#define VPRINTF(f, a) vprintf(f, a) 498 #define PRINTF printf
472#define VFPRINTF(s, f, a) vfprintf(s, f, a) 499 #define FPRINTF fprintf
473#define VSPRINTF(d, f, a) vsprintf(d, f, a) 500 #define VPRINTF(f, a) vprintf(f, a)
474#define VSNPRINTF(str, size, fmt, a) vsnprintf(str, size, fmt, a) 501 #define VFPRINTF(s, f, a) vfprintf(s, f, a)
475#define _REAL_SNPRINTF snprintf 502 #define VSPRINTF(d, f, a) vsprintf(d, f, a)
476#define SPRINTF sprintf 503 #define VSNPRINTF(str, size, fmt, a) vsnprintf(str, size, fmt, a)
477#define VSSCANF(s, f, a) vsscanf(s, f, a) 504 #define _REAL_SNPRINTF snprintf
478#define SSCANF sscanf 505 #define SPRINTF sprintf
479#define VFSCANF(s, f, a) vfscanf(s, f, a) 506 #define VSSCANF(s, f, a) vsscanf(s, f, a)
480#define VSCANF(f, a) vscanf(f, a) 507 #define SSCANF sscanf
481#define SCANF scanf 508 #define VFSCANF(s, f, a) vfscanf(s, f, a)
482#define FSCANF fscanf 509 #define VSCANF(f, a) vscanf(f, a)
483#define WAITPID(p, s, o) waitpid(p, s, o) 510 #define SCANF scanf
484#define ACCEPT(s, a, l) accept(s, a, l) 511 #define FSCANF fscanf
485#define BIND(s, n, l) bind(s, n, l) 512 #define WAITPID(p, s, o) waitpid(p, s, o)
486#define CONNECT(s, n, l) connect(s, n, l) 513 #define ACCEPT(s, a, l) accept(s, a, l)
487#define GETPEERNAME(s, n, l) getpeername(s, n, l) 514 #define BIND(s, n, l) bind(s, n, l)
488#define GETSOCKNAME(s, n, l) getsockname(s, n, l) 515 #define CONNECT(s, n, l) connect(s, n, l)
489#define GETSOCKOPT(s, l, o, v, p) getsockopt(s, l, o, v, p) 516 #define GETPEERNAME(s, n, l) getpeername(s, n, l)
490#define LISTEN(s, b) listen(s, b) 517 #define GETSOCKNAME(s, n, l) getsockname(s, n, l)
491#define RECV(s, b, l, f) recv(s, b, l, f) 518 #define GETSOCKOPT(s, l, o, v, p) getsockopt(s, l, o, v, p)
492#define RECVFROM(s, b, l, f, r, o) recvfrom(s, b, l, f, r, o) 519 #define LISTEN(s, b) listen(s, b)
493#define SELECT(n, r, w, e, t) select(n, r, w, e, t) 520 #define RECV(s, b, l, f) recv(s, b, l, f)
494#define SEND(s, b, l, f) send(s, b, l, f) 521 #define RECVFROM(s, b, l, f, r, o) recvfrom(s, b, l, f, r, o)
495#define SENDTO(s, b, l, f, o, n) sendto(s, b, l, f, o, n) 522 #define SELECT(n, r, w, e, t) select(n, r, w, e, t)
496#define SETSOCKOPT(s, l, o, v, n) setsockopt(s, l, o, v, n) 523 #define SEND(s, b, l, f) send(s, b, l, f)
497#define SHUTDOWN(s, h) shutdown(s, h) 524 #define SENDTO(s, b, l, f, o, n) sendto(s, b, l, f, o, n)
498#define SOCKET(a, t, p) socket(a, t, p) 525 #define SETSOCKOPT(s, l, o, v, n) setsockopt(s, l, o, v, n)
499#define GETHOSTBYADDR(a, l, t) gethostbyname(a, l, t) 526 #define SHUTDOWN(s, h) shutdown(s, h)
500#define GETHOSTBYNAME(n) gethostbyname(n) 527 #define SOCKET(a, t, p) socket(a, t, p)
501#else /* */ 528 #define GETHOSTBYADDR(a, l, t) gethostbyname(a, l, t)
502#define DIR_SEPARATOR '\\' 529 #define GETHOSTBYNAME(n) gethostbyname(n)
503#define DIR_SEPARATOR_STR "\\" 530 #define GETTIMEOFDAY(t, n) gettimeofday(t, n)
504#define PATH_SEPARATOR ':' 531 #define INSQUE(e, p) insque(e, p)
505#define PATH_SEPARATOR_STR ":" 532 #define REMQUE(e) remque(e)
506#define NEWLINE "\r\n" 533 #define HSEARCH(i, a) hsearch(i, a)
534 #define HCREATE(n) hcreate(n)
535 #define HDESTROY() hdestroy()
536 #define HSEARCH_R(i, a, r, h) hsearch_r(i, a, r, h)
537 #define HCREATE_R(n, h) hcreate_r(n, h)
538 #define HDESTROY_R(h) hdestroy_r(h)
539 #define TSEARCH(k, r, c) tsearch(k, r, c)
540 #define TFIND(k, r, c) tfind(k, r, c)
541 #define TDELETE(k, r, c) tdelete(k, r, c)
542 #define TWALK(r, a) twalk(r, a)
543 #define TDESTROY(r, f) tdestroy(r, f)
544 #define LFIND(k, b, n, s, c) lfind(k, b, n, s, c)
545 #define LSEARCH(k, b, n, s, c) lsearch(k, b, n, s, c)
546#else
547 #define DIR_SEPARATOR '\\'
548 #define DIR_SEPARATOR_STR "\\"
549 #define PATH_SEPARATOR ':'
550 #define PATH_SEPARATOR_STR ":"
551 #define NEWLINE "\r\n"
507 552
508#ifdef ENABLE_NLS 553#ifdef ENABLE_NLS
509#define BINDTEXTDOMAIN(d, n) _win_bindtextdomain(d, n) 554 #define BINDTEXTDOMAIN(d, n) _win_bindtextdomain(d, n)
510#endif /* */ 555#endif
511#define CREAT(p, m) _win_creat(p, m) 556 #define CREAT(p, m) _win_creat(p, m)
512#define FOPEN(f, m) _win_fopen(f, m) 557 #define PLIBC_CTIME(c) _win_ctime(c)
513#define FTRUNCATE(f, l) _win_ftruncate(f, l) 558 #define CTIME_R(c, b) _win_ctime_r(c, b)
514#define OPENDIR(d) _win_opendir(d) 559 #define FOPEN(f, m) _win_fopen(f, m)
515#define OPEN _win_open 560 #define FTRUNCATE(f, l) _win_ftruncate(f, l)
516#define CHDIR(d) _win_chdir(d) 561 #define OPENDIR(d) _win_opendir(d)
517#define CLOSE(f) _win_close(f) 562 #define OPEN _win_open
518#define PLIBC_KILL(p, s) _win_kill(p, s) 563 #define CHDIR(d) _win_chdir(d)
519#define LSEEK(f, o, w) _win_lseek(f, o, w) 564 #define CLOSE(f) _win_close(f)
520#define FSTAT(h, b) _win_fstat(h, b) 565 #define PLIBC_KILL(p, s) _win_kill(p, s)
521#define RMDIR(f) _win_rmdir(f) 566 #define LSEEK(f, o, w) _win_lseek(f, o, w)
522#define ACCESS(p, m) _win_access(p, m) 567 #define FSTAT(h, b) _win_fstat(h, b)
523#define CHMOD(f, p) _win_chmod(f, p) 568 #define RMDIR(f) _win_rmdir(f)
524#define PIPE(h) _win_pipe(h) 569 #define ACCESS(p, m) _win_access(p, m)
525#define RANDOM() _win_random() 570 #define CHMOD(f, p) _win_chmod(f, p)
526#define REMOVE(p) _win_remove(p) 571 #define PIPE(h) _win_pipe(h)
527#define RENAME(o, n) _win_rename(o, n) 572 #define RANDOM() _win_random()
528#define STAT(p, b) _win_stat(p, b) 573 #define REMOVE(p) _win_remove(p)
529#define STAT64(p, b) _win_stat64(p, b) 574 #define RENAME(o, n) _win_rename(o, n)
530#define UNLINK(f) _win_unlink(f) 575 #define STAT(p, b) _win_stat(p, b)
531#define WRITE(f, b, n) _win_write(f, b, n) 576 #define STAT64(p, b) _win_stat64(p, b)
532#define READ(f, b, n) _win_read(f, b, n) 577 #define UNLINK(f) _win_unlink(f)
533#define GN_FREAD(b, s, c, f) _win_fread(b, s, c, f) 578 #define WRITE(f, b, n) _win_write(f, b, n)
534#define GN_FWRITE(b, s, c, f) _win_fwrite(b, s, c, f) 579 #define READ(f, b, n) _win_read(f, b, n)
535#define SYMLINK(a, b) _win_symlink(a, b) 580 #define GN_FREAD(b, s, c, f) _win_fread(b, s, c, f)
536#define MMAP(s, l, p, f, d, o) _win_mmap(s, l, p, f, d, o) 581 #define GN_FWRITE(b, s, c, f) _win_fwrite(b, s, c, f)
537#define MUNMAP(s, l) _win_munmap(s, l) 582 #define SYMLINK(a, b) _win_symlink(a, b)
538#define STRERROR(i) _win_strerror(i) 583 #define MMAP(s, l, p, f, d, o) _win_mmap(s, l, p, f, d, o)
539#define READLINK(p, b, s) _win_readlink(p, b, s) 584 #define MUNMAP(s, l) _win_munmap(s, l)
540#define LSTAT(p, b) _win_lstat(p, b) 585 #define STRERROR(i) _win_strerror(i)
541#define LSTAT64(p, b) _win_lstat64(p, b) 586 #define READLINK(p, b, s) _win_readlink(p, b, s)
542#define PRINTF(f, ...) _win_printf(f , __VA_ARGS__) 587 #define LSTAT(p, b) _win_lstat(p, b)
543#define FPRINTF(fil, fmt, ...) _win_fprintf(fil, fmt, __VA_ARGS__) 588 #define LSTAT64(p, b) _win_lstat64(p, b)
544#define VPRINTF(f, a) _win_vprintf(f, a) 589 #define PRINTF(f, ...) _win_printf(f , __VA_ARGS__)
545#define VFPRINTF(s, f, a) _win_vfprintf(s, f, a) 590 #define FPRINTF(fil, fmt, ...) _win_fprintf(fil, fmt, __VA_ARGS__)
546#define VSPRINTF(d, f, a) _win_vsprintf(d, f, a) 591 #define VPRINTF(f, a) _win_vprintf(f, a)
547#define VSNPRINTF(str, size, fmt, a) _win_vsnprintf(str, size, fmt, a) 592 #define VFPRINTF(s, f, a) _win_vfprintf(s, f, a)
548#define _REAL_SNPRINTF(str, size, fmt, ...) _win_snprintf(str, size, fmt, __VA_ARGS__) 593 #define VSPRINTF(d, f, a) _win_vsprintf(d, f, a)
549#define SPRINTF(d, f, ...) _win_sprintf(d, f, __VA_ARGS__) 594 #define VSNPRINTF(str, size, fmt, a) _win_vsnprintf(str, size, fmt, a)
550#define VSSCANF(s, f, a) _win_vsscanf(s, f, a) 595 #define _REAL_SNPRINTF(str, size, fmt, ...) _win_snprintf(str, size, fmt, __VA_ARGS__)
551#define SSCANF(s, f, ...) _win_sscanf(s, f, __VA_ARGS__) 596 #define SPRINTF(d, f, ...) _win_sprintf(d, f, __VA_ARGS__)
552#define VFSCANF(s, f, a) _win_vfscanf(s, f, a) 597 #define VSSCANF(s, f, a) _win_vsscanf(s, f, a)
553#define VSCANF(f, a) _win_vscanf(f, a) 598 #define SSCANF(s, f, ...) _win_sscanf(s, f, __VA_ARGS__)
554#define SCANF(f, ...) _win_scanf(f, __VA_ARGS__) 599 #define VFSCANF(s, f, a) _win_vfscanf(s, f, a)
555#define FSCANF(s, f, ...) _win_fscanf(s, f, __VA_ARGS__) 600 #define VSCANF(f, a) _win_vscanf(f, a)
556#define WAITPID(p, s, o) _win_waitpid(p, s, o) 601 #define SCANF(f, ...) _win_scanf(f, __VA_ARGS__)
557#define ACCEPT(s, a, l) _win_accept(s, a, l) 602 #define FSCANF(s, f, ...) _win_fscanf(s, f, __VA_ARGS__)
558#define BIND(s, n, l) _win_bind(s, n, l) 603 #define WAITPID(p, s, o) _win_waitpid(p, s, o)
559#define CONNECT(s, n, l) _win_connect(s, n, l) 604 #define ACCEPT(s, a, l) _win_accept(s, a, l)
560#define GETPEERNAME(s, n, l) _win_getpeername(s, n, l) 605 #define BIND(s, n, l) _win_bind(s, n, l)
561#define GETSOCKNAME(s, n, l) _win_getsockname(s, n, l) 606 #define CONNECT(s, n, l) _win_connect(s, n, l)
562#define GETSOCKOPT(s, l, o, v, p) _win_getsockopt(s, l, o, v, p) 607 #define GETPEERNAME(s, n, l) _win_getpeername(s, n, l)
563#define LISTEN(s, b) _win_listen(s, b) 608 #define GETSOCKNAME(s, n, l) _win_getsockname(s, n, l)
564#define RECV(s, b, l, f) _win_recv(s, b, l, f) 609 #define GETSOCKOPT(s, l, o, v, p) _win_getsockopt(s, l, o, v, p)
565#define RECVFROM(s, b, l, f, r, o) _win_recvfrom(s, b, l, f, r, o) 610 #define LISTEN(s, b) _win_listen(s, b)
566#define SELECT(n, r, w, e, t) _win_select(n, r, w, e, t) 611 #define RECV(s, b, l, f) _win_recv(s, b, l, f)
567#define SEND(s, b, l, f) _win_send(s, b, l, f) 612 #define RECVFROM(s, b, l, f, r, o) _win_recvfrom(s, b, l, f, r, o)
568#define SENDTO(s, b, l, f, o, n) _win_sendto(s, b, l, f, o, n) 613 #define SELECT(n, r, w, e, t) _win_select(n, r, w, e, t)
569#define SETSOCKOPT(s, l, o, v, n) _win_setsockopt(s, l, o, v, n) 614 #define SEND(s, b, l, f) _win_send(s, b, l, f)
570#define SHUTDOWN(s, h) _win_shutdown(s, h) 615 #define SENDTO(s, b, l, f, o, n) _win_sendto(s, b, l, f, o, n)
571#define SOCKET(a, t, p) _win_socket(a, t, p) 616 #define SETSOCKOPT(s, l, o, v, n) _win_setsockopt(s, l, o, v, n)
572#define GETHOSTBYADDR(a, l, t) _win_gethostbyname(a, l, t) 617 #define SHUTDOWN(s, h) _win_shutdown(s, h)
573#define GETHOSTBYNAME(n) _win_gethostbyname(n) 618 #define SOCKET(a, t, p) _win_socket(a, t, p)
574#endif /* */ 619 #define GETHOSTBYADDR(a, l, t) _win_gethostbyname(a, l, t)
620 #define GETHOSTBYNAME(n) _win_gethostbyname(n)
621 #define GETTIMEOFDAY(t, n) _win_gettimeofday(t, n)
622 #define INSQUE(e, p) _win_insque(e, p)
623 #define REMQUE(e) _win_remque(e)
624 #define HSEARCH(i, a) _win_hsearch(i, a)
625 #define HCREATE(n) _win_hcreate(n)
626 #define HDESTROY() _win_hdestroy()
627 #define HSEARCH_R(i, a, r, h) _win_hsearch_r(i, a, r, h)
628 #define HCREATE_R(n, h) _win_hcreate_r(n, h)
629 #define HDESTROY_R(h) _win_hdestroy_r(h)
630 #define TSEARCH(k, r, c) _win_tsearch(k, r, c)
631 #define TFIND(k, r, c) _win_tfind(k, r, c)
632 #define TDELETE(k, r, c) _win_tdelete(k, r, c)
633 #define TWALK(r, a) _win_twalk(r, a)
634 #define TDESTROY(r, f) _win_tdestroy(r, f)
635 #define LFIND(k, b, n, s, c) _win_lfind(k, b, n, s, c)
636 #define LSEARCH(k, b, n, s, c) _win_lsearch(k, b, n, s, c)
637#endif
638
639/* search.h */
640
641/* Prototype structure for a linked-list data structure.
642 This is the type used by the `insque' and `remque' functions. */
643
644struct PLIBC_SEARCH_QELEM
645 {
646 struct qelem *q_forw;
647 struct qelem *q_back;
648 char q_data[1];
649 };
650
651
652/* Insert ELEM into a doubly-linked list, after PREV. */
653void _win_insque (void *__elem, void *__prev);
654
655/* Unlink ELEM from the doubly-linked list that it is in. */
656void _win_remque (void *__elem);
657
658
659/* For use with hsearch(3). */
660typedef int (*PLIBC_SEARCH__compar_fn_t) (__const void *, __const void *);
661
662typedef PLIBC_SEARCH__compar_fn_t _win_comparison_fn_t;
663
664/* Action which shall be performed in the call the hsearch. */
665typedef enum
666 {
667 PLIBC_SEARCH_FIND,
668 PLIBC_SEARCH_ENTER
669 }
670PLIBC_SEARCH_ACTION;
671
672typedef struct PLIBC_SEARCH_entry
673 {
674 char *key;
675 void *data;
676 }
677PLIBC_SEARCH_ENTRY;
678
679/* The reentrant version has no static variables to maintain the state.
680 Instead the interface of all functions is extended to take an argument
681 which describes the current status. */
682typedef struct _PLIBC_SEARCH_ENTRY
683{
684 unsigned int used;
685 PLIBC_SEARCH_ENTRY entry;
686}
687_PLIBC_SEARCH_ENTRY;
688
689
690/* Family of hash table handling functions. The functions also
691 have reentrant counterparts ending with _r. The non-reentrant
692 functions all work on a signle internal hashing table. */
693
694/* Search for entry matching ITEM.key in internal hash table. If
695 ACTION is `FIND' return found entry or signal error by returning
696 NULL. If ACTION is `ENTER' replace existing data (if any) with
697 ITEM.data. */
698PLIBC_SEARCH_ENTRY *_win_hsearch (PLIBC_SEARCH_ENTRY __item, PLIBC_SEARCH_ACTION __action);
699
700/* Create a new hashing table which will at most contain NEL elements. */
701int _win_hcreate (size_t __nel);
702
703/* Destroy current internal hashing table. */
704void _win_hdestroy (void);
705
706/* Data type for reentrant functions. */
707struct PLIBC_SEARCH_hsearch_data
708 {
709 struct _PLIBC_SEARCH_ENTRY *table;
710 unsigned int size;
711 unsigned int filled;
712 };
713
714/* Reentrant versions which can handle multiple hashing tables at the
715 same time. */
716int _win_hsearch_r (PLIBC_SEARCH_ENTRY __item, PLIBC_SEARCH_ACTION __action, PLIBC_SEARCH_ENTRY **__retval,
717 struct PLIBC_SEARCH_hsearch_data *__htab);
718int _win_hcreate_r (size_t __nel, struct PLIBC_SEARCH_hsearch_data *__htab);
719void _win_hdestroy_r (struct PLIBC_SEARCH_hsearch_data *__htab);
720
721
722/* The tsearch routines are very interesting. They make many
723 assumptions about the compiler. It assumes that the first field
724 in node must be the "key" field, which points to the datum.
725 Everything depends on that. */
726/* For tsearch */
727typedef enum
728{
729 PLIBC_SEARCH_preorder,
730 PLIBC_SEARCH_postorder,
731 PLIBC_SEARCH_endorder,
732 PLIBC_SEARCH_leaf
733}
734PLIBC_SEARCH_VISIT;
735
736/* Search for an entry matching the given KEY in the tree pointed to
737 by *ROOTP and insert a new element if not found. */
738void *_win_tsearch (__const void *__key, void **__rootp,
739 PLIBC_SEARCH__compar_fn_t __compar);
740
741/* Search for an entry matching the given KEY in the tree pointed to
742 by *ROOTP. If no matching entry is available return NULL. */
743void *_win_tfind (__const void *__key, void *__const *__rootp,
744 PLIBC_SEARCH__compar_fn_t __compar);
745
746/* Remove the element matching KEY from the tree pointed to by *ROOTP. */
747void *_win_tdelete (__const void *__restrict __key,
748 void **__restrict __rootp,
749 PLIBC_SEARCH__compar_fn_t __compar);
750
751typedef void (*PLIBC_SEARCH__action_fn_t) (__const void *__nodep, PLIBC_SEARCH_VISIT __value,
752 int __level);
753
754/* Walk through the whole tree and call the ACTION callback for every node
755 or leaf. */
756void _win_twalk (__const void *__root, PLIBC_SEARCH__action_fn_t __action);
757
758/* Callback type for function to free a tree node. If the keys are atomic
759 data this function should do nothing. */
760typedef void (*PLIBC_SEARCH__free_fn_t) (void *__nodep);
761
762/* Destroy the whole tree, call FREEFCT for each node or leaf. */
763void _win_tdestroy (void *__root, PLIBC_SEARCH__free_fn_t __freefct);
764
765
766/* Perform linear search for KEY by comparing by COMPAR in an array
767 [BASE,BASE+NMEMB*SIZE). */
768void *_win_lfind (__const void *__key, __const void *__base,
769 size_t *__nmemb, size_t __size, PLIBC_SEARCH__compar_fn_t __compar);
770
771/* Perform linear search for KEY by comparing by COMPAR function in
772 array [BASE,BASE+NMEMB*SIZE) and insert entry if not found. */
773void *_win_lsearch (__const void *__key, void *__base,
774 size_t *__nmemb, size_t __size, PLIBC_SEARCH__compar_fn_t __compar);
775
575 776
576#ifdef __cplusplus 777#ifdef __cplusplus
577} 778}
578#endif /* */ 779#endif
780
579 781
580#endif //_PLIBC_H_ 782#endif //_PLIBC_H_
581 783
582/* end of plibc.h */ 784/* end of plibc.h */