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