00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00028 #ifndef _PLIBC_H_
00029 #define _PLIBC_H_
00030
00031 #ifndef SIGALRM
00032 #define SIGALRM 14
00033 #endif
00034
00035 #ifdef __cplusplus
00036 extern "C"
00037 {
00038 #endif
00039
00040 #include <stddef.h>
00041
00042 #ifdef Q_OS_WIN32
00043 #define WINDOWS 1
00044 #endif
00045
00046 #define HAVE_PLIBC_FD 0
00047
00048 #ifdef WINDOWS
00049
00050 #if ENABLE_NLS
00051 #include "langinfo.h"
00052 #endif
00053
00054 #include <windows.h>
00055 #include <Ws2tcpip.h>
00056 #include <time.h>
00057 #include <stdio.h>
00058 #include <sys/types.h>
00059 #include <sys/stat.h>
00060 #include <dirent.h>
00061 #include <errno.h>
00062 #include <stdarg.h>
00063
00064 #define __BYTE_ORDER BYTE_ORDER
00065 #define __BIG_ENDIAN BIG_ENDIAN
00066
00067
00068 #define __G_WIN32_H__
00069
00070
00071 #define Li2Double(x) ((double)((x).HighPart) * 4.294967296E9 + \
00072 (double)((x).LowPart))
00073
00074 #define socklen_t int
00075 #define ssize_t int
00076 #define off_t int
00077 #define int64_t long long
00078 #define int32_t long
00079
00080 struct stat64
00081 {
00082 _dev_t st_dev;
00083 _ino_t st_ino;
00084 _mode_t st_mode;
00085 short st_nlink;
00086 short st_uid;
00087 short st_gid;
00088 _dev_t st_rdev;
00089 __int64 st_size;
00090 __time64_t st_atime;
00091 __time64_t st_mtime;
00092 __time64_t st_ctime;
00093 };
00094
00095 #ifndef pid_t
00096 #define pid_t int
00097 #endif
00098
00099 #ifndef WEXITSTATUS
00100 #define WEXITSTATUS(status) (((status) & 0xff00) >> 8)
00101 #endif
00102
00103 #ifndef MSG_DONTWAIT
00104 #define MSG_DONTWAIT 0
00105 #endif
00106
00107
00108 #define ENOCSI 43
00109 #define EL2HLT 44
00110 #ifndef EDEADLK
00111 #define EDEADLK 45
00112 #endif
00113 #ifndef ENOLCK
00114 #define ENOLCK 46
00115 #endif
00116 #define EBADE 50
00117 #define EBADR 51
00118 #define EXFULL 52
00119 #define ENOANO 53
00120 #define EBADRQC 54
00121 #define EBADSLT 55
00122 #ifndef EDEADLOCK
00123 #define EDEADLOCK EDEADLK
00124 #endif
00125 #define EBFONT 57
00126 #define ENOSTR 60
00127 #define ENODATA 61
00128 #define ETIME 62
00129 #define ENOSR 63
00130 #define ENONET 64
00131 #define ENOPKG 65
00132 #define EREMOTE 66
00133 #define ENOLINK 67
00134 #define EADV 68
00135 #define ESRMNT 69
00136 #define ECOMM 70
00137 #define EPROTO 71
00138 #define EMULTIHOP 74
00139 #define ELBIN 75
00140 #define EDOTDOT 76
00141 #define EBADMSG 77
00142 #define ENOTUNIQ 80
00143 #define EBADFD 81
00144 #define EREMCHG 82
00145 #define ELIBACC 83
00146 #define ELIBBAD 84
00147 #define ELIBSCN 85
00148 #define ELIBMAX 86
00149 #define ELIBEXEC 87
00150 #ifndef ENOSYS
00151 #define ENOSYS 88
00152 #endif
00153 #define ENMFILE 89
00154 #ifndef ENOTEMPTY
00155 #define ENOTEMPTY 90
00156 #endif
00157 #ifndef ENAMETOOLONG
00158 #define ENAMETOOLONG 91
00159 #endif
00160 #define ELOOP 92
00161 #define EOPNOTSUPP 95
00162 #define EPFNOSUPPORT 96
00163 #define ECONNRESET 104
00164 #define ENOBUFS 105
00165 #define EAFNOSUPPORT 106
00166 #define EPROTOTYPE 107
00167 #define ENOTSOCK 108
00168 #define ENOPROTOOPT 109
00169 #define ESHUTDOWN 110
00170 #define ECONNREFUSED 111
00171 #define EADDRINUSE 112
00172 #define ECONNABORTED 113
00173 #define ENETUNREACH 114
00174 #define ENETDOWN 115
00175 #ifndef ETIMEDOUT
00176 #define ETIMEDOUT 116
00177 #endif
00178 #define EHOSTDOWN 117
00179 #define EHOSTUNREACH 118
00180 #define EINPROGRESS 119
00181 #define EALREADY 120
00182 #define EDESTADDRREQ 121
00183 #define EMSGSIZE 122
00184 #define EPROTONOSUPPORT 123
00185 #define ESOCKTNOSUPPORT 124
00186 #define EADDRNOTAVAIL 125
00187 #define ENETRESET 126
00188 #define EISCONN 127
00189 #define ENOTCONN 128
00190 #define ETOOMANYREFS 129
00191 #define EPROCLIM 130
00192 #define EUSERS 131
00193 #define EDQUOT 132
00194 #define ESTALE 133
00195 #ifndef ENOTSUP
00196 #define ENOTSUP 134
00197 #endif
00198 #define ENOMEDIUM 135
00199 #define ENOSHARE 136
00200 #define ECASECLASH 137
00201 #define EWOULDBLOCK EAGAIN
00202 #define EOVERFLOW 139
00203
00204 #undef HOST_NOT_FOUND
00205 #define HOST_NOT_FOUND 1
00206 #undef TRY_AGAIN
00207 #define TRY_AGAIN 2
00208 #undef NO_RECOVERY
00209 #define NO_RECOVERY 3
00210 #undef NO_ADDRESS
00211 #define NO_ADDRESS 4
00212
00213 #define PROT_READ 0x1
00214 #define PROT_WRITE 0x2
00215 #define MAP_SHARED 0x1
00216 #define MAP_PRIVATE 0x2
00217 #define MAP_FIXED 0x10
00218 #define MAP_FAILED ((void *)-1)
00219
00220 struct statfs
00221 {
00222 long f_type;
00223 long f_bsize;
00224 long f_blocks;
00225 long f_bfree;
00226 long f_bavail;
00227 long f_files;
00228 long f_ffree;
00229 long f_fsid;
00230 long f_namelen;
00231 long f_spare[6];
00232 };
00233
00234 extern const struct in6_addr in6addr_any;
00235 extern const struct in6_addr in6addr_loopback;
00236
00237
00238
00239 enum SYSTEM_INFORMATION_CLASS
00240 {
00241 SystemBasicInformation = 0,
00242 Unknown1,
00243 SystemPerformanceInformation = 2,
00244 SystemTimeOfDayInformation = 3,
00245 Unknown4,
00246 SystemProcessInformation = 5,
00247 Unknown6,
00248 Unknown7,
00249 SystemProcessorPerformanceInformation = 8,
00250 Unknown9,
00251 Unknown10,
00252 SystemDriverInformation,
00253 Unknown12,
00254 Unknown13,
00255 Unknown14,
00256 Unknown15,
00257 SystemHandleList,
00258 Unknown17,
00259 Unknown18,
00260 Unknown19,
00261 Unknown20,
00262 SystemCacheInformation,
00263 Unknown22,
00264 SystemInterruptInformation = 23,
00265 SystemExceptionInformation = 33,
00266 SystemRegistryQuotaInformation = 37,
00267 SystemLookasideInformation = 45
00268 };
00269
00270 typedef struct
00271 {
00272 LARGE_INTEGER IdleTime;
00273 LARGE_INTEGER KernelTime;
00274 LARGE_INTEGER UserTime;
00275 LARGE_INTEGER Reserved1[2];
00276 ULONG Reserved2;
00277 } SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION;
00278
00279 #define sleep(secs) (Sleep(secs * 1000))
00280
00281
00282
00283 #define FAKED_BLOCK_SIZE 512
00284
00285
00286 #define MSDOS_SUPER_MAGIC 0x4d44
00287 #define NTFS_SUPER_MAGIC 0x5346544E
00288
00289
00290
00291 #define SHUT_RDWR SD_BOTH
00292
00293
00294 #define LOCK_SH 1
00295 #define LOCK_EX 2
00296 #define LOCK_NB 4
00297
00298 #define LOCK_UN 8
00299
00300
00301 #define S_IRGRP 0
00302 #define S_IWGRP 0
00303 #define S_IROTH 0
00304 #define S_IXGRP 0
00305 #define S_IWOTH 0
00306 #define S_IXOTH 0
00307 #define S_ISUID 0
00308 #define S_ISGID 0
00309 #define S_ISVTX 0
00310 #define S_IRWXG 0
00311 #define S_IRWXO 0
00312
00313 #define SHUT_WR SD_SEND
00314 #define SHUT_RD SD_RECEIVE
00315 #define SHUT_RDWR SD_BOTH
00316
00317 #define SIGKILL 9
00318 #define SIGTERM 15
00319
00320 #define SetErrnoFromWinError(e) _SetErrnoFromWinError(e, __FILE__, __LINE__)
00321
00322 BOOL _plibc_CreateShortcut (const char *pszSrc, const char *pszDest);
00323 BOOL _plibc_DereferenceShortcut (char *pszShortcut);
00324 char *plibc_ChooseDir (char *pszTitle, unsigned long ulFlags);
00325 char *plibc_ChooseFile (char *pszTitle, unsigned long ulFlags);
00326 long QueryRegistry (HKEY hMainKey, char *pszKey, char *pszSubKey,
00327 char *pszBuffer, long *pdLength);
00328
00329 BOOL __win_IsHandleMarkedAsBlocking (SOCKET hHandle);
00330 void __win_SetHandleBlockingMode (SOCKET s, BOOL bBlocking);
00331 void __win_DiscardHandleBlockingMode (SOCKET s);
00332 int _win_isSocketValid (int s);
00333 int plibc_conv_to_win_path (const char *pszUnix, char *pszWindows);
00334 unsigned plibc_get_handle_count ();
00335
00336 typedef void (*TPanicProc) (int, char *);
00337 void plibc_set_panic_proc (TPanicProc proc);
00338
00339 int flock (int fd, int operation);
00340 int fsync (int fildes);
00341 int inet_pton (int af, const char *src, void *dst);
00342 int inet_pton4 (const char *src, u_char * dst, int pton);
00343 #if USE_IPV6
00344 int inet_pton6 (const char *src, u_char * dst);
00345 #endif
00346 int truncate (const char *fname, int distance);
00347 int statfs (const char *path, struct statfs *buf);
00348 const char *hstrerror (int err);
00349 int mkstemp (char *tmplate);
00350 char *strptime (const char *buf, const char *format, struct tm *tm);
00351 const char *inet_ntop (int af, const void *src, char *dst, size_t size);
00352
00353 int plibc_init (char *pszOrg, char *pszApp);
00354 void plibc_shutdown ();
00355 int plibc_initialized ();
00356 int plibc_conv_to_win_path_ex (const char *pszUnix, char *pszWindows,
00357 int derefLinks);
00358 void _SetErrnoFromWinError (long lWinError, char *pszCaller, int iLine);
00359 void SetErrnoFromWinsockError (long lWinError);
00360 void SetHErrnoFromWinError (long lWinError);
00361 void SetErrnoFromHRESULT (HRESULT hRes);
00362 int GetErrnoFromWinsockError (long lWinError);
00363 FILE *_win_fopen (const char *filename, const char *mode);
00364 DIR *_win_opendir (const char *dirname);
00365 int _win_open (const char *filename, int oflag, ...);
00366 #ifdef ENABLE_NLS
00367 char *_win_bindtextdomain (const char *domainname, const char *dirname);
00368 #endif
00369 int _win_chdir (const char *path);
00370 int _win_close (int fd);
00371 int _win_creat (const char *path, mode_t mode);
00372 char *_win_ctime (const time_t * clock);
00373 char *_win_ctime_r (const time_t * clock, char *buf);
00374 int _win_fstat (int handle, struct stat *buffer);
00375 int _win_ftruncate (int fildes, off_t length);
00376 void _win_gettimeofday (struct timeval *tp, void *tzp);
00377 int _win_kill (pid_t pid, int sig);
00378 int _win_pipe (int *phandles);
00379 int _win_rmdir (const char *path);
00380 int _win_access (const char *path, int mode);
00381 int _win_chmod (const char *filename, int pmode);
00382 char *realpath (const char *file_name, char *resolved_name);
00383 long _win_random (void);
00384 int _win_remove (const char *path);
00385 int _win_rename (const char *oldname, const char *newname);
00386 int _win_stat (const char *path, struct stat *buffer);
00387 int _win_stat64 (const char *path, struct stat64 *buffer);
00388 int _win_unlink (const char *filename);
00389 int _win_write (int fildes, const void *buf, size_t nbyte);
00390 int _win_read (int fildes, void *buf, size_t nbyte);
00391 size_t _win_fwrite (const void *buffer, size_t size, size_t count,
00392 FILE * stream);
00393 size_t _win_fread (void *buffer, size_t size, size_t count, FILE * stream);
00394 int _win_symlink (const char *path1, const char *path2);
00395 void *_win_mmap (void *start, size_t len, int access, int flags, int fd,
00396 unsigned long long offset);
00397 int _win_munmap (void *start, size_t length);
00398 int _win_lstat (const char *path, struct stat *buf);
00399 int _win_lstat64 (const char *path, struct stat64 *buf);
00400 int _win_readlink (const char *path, char *buf, size_t bufsize);
00401 int _win_accept (SOCKET s, struct sockaddr *addr, int *addrlen);
00402 int _win_printf (const char *format, ...);
00403 int _win_fprintf (FILE * f, const char *format, ...);
00404 int _win_vprintf (const char *format, va_list ap);
00405 int _win_vfprintf (FILE * stream, const char *format, va_list arg_ptr);
00406 int _win_vsprintf (char *dest, const char *format, va_list arg_ptr);
00407 int _win_vsnprintf (char *str, size_t size, const char *format,
00408 va_list arg_ptr);
00409 int _win_snprintf (char *str, size_t size, const char *format, ...);
00410 int _win_sprintf (char *dest, const char *format, ...);
00411 int _win_vsscanf (const char *str, const char *format, va_list arg_ptr);
00412 int _win_sscanf (const char *str, const char *format, ...);
00413 int _win_vfscanf (FILE * stream, const char *format, va_list arg_ptr);
00414 int _win_vscanf (const char *format, va_list arg_ptr);
00415 int _win_scanf (const char *format, ...);
00416 int _win_fscanf (FILE * stream, const char *format, ...);
00417 pid_t _win_waitpid (pid_t pid, int *stat_loc, int options);
00418 int _win_bind (SOCKET s, const struct sockaddr *name, int namelen);
00419 int _win_connect (SOCKET s, const struct sockaddr *name, int namelen);
00420 int _win_getpeername (SOCKET s, struct sockaddr *name, int *namelen);
00421 int _win_getsockname (SOCKET s, struct sockaddr *name, int *namelen);
00422 int _win_getsockopt (SOCKET s, int level, int optname, char *optval,
00423 int *optlen);
00424 int _win_listen (SOCKET s, int backlog);
00425 int _win_recv (SOCKET s, char *buf, int len, int flags);
00426 int _win_recvfrom (SOCKET s, void *buf, int len, int flags,
00427 struct sockaddr *from, int *fromlen);
00428 int _win_select (int max_fd, fd_set * rfds, fd_set * wfds, fd_set * efds,
00429 const struct timeval *tv);
00430 int _win_send (SOCKET s, const char *buf, int len, int flags);
00431 int _win_sendto (SOCKET s, const char *buf, int len, int flags,
00432 const struct sockaddr *to, int tolen);
00433 int _win_setsockopt (SOCKET s, int level, int optname, const void *optval,
00434 int optlen);
00435 int _win_shutdown (SOCKET s, int how);
00436 SOCKET _win_socket (int af, int type, int protocol);
00437 struct hostent *_win_gethostbyaddr (const char *addr, int len, int type);
00438 struct hostent *_win_gethostbyname (const char *name);
00439 struct hostent *gethostbyname2 (const char *name, int af);
00440 char *_win_strerror (int errnum);
00441 int IsWinNT ();
00442 char *index (const char *s, int c);
00443
00444 #if !HAVE_STRNDUP
00445 char *strndup (const char *s, size_t n);
00446 #endif
00447 #if !HAVE_STRNLEN
00448 size_t strnlen (const char *str, size_t maxlen);
00449 #endif
00450
00451 #define strcasecmp(a, b) stricmp(a, b)
00452 #define strncasecmp(a, b, c) strnicmp(a, b, c)
00453
00454 #endif
00455
00456 #ifndef WINDOWS
00457 #define DIR_SEPARATOR '/'
00458 #define DIR_SEPARATOR_STR "/"
00459 #define PATH_SEPARATOR ';'
00460 #define PATH_SEPARATOR_STR ";"
00461 #define NEWLINE "\n"
00462
00463 #ifdef ENABLE_NLS
00464 #define BINDTEXTDOMAIN(d, n) bindtextdomain(d, n)
00465 #endif
00466 #define CREAT(p, m) creat(p, m)
00467 #define PLIBC_CTIME(c) ctime(c)
00468 #define CTIME_R(c, b) ctime_r(c, b)
00469 #undef FOPEN
00470 #define FOPEN(f, m) fopen(f, m)
00471 #define FTRUNCATE(f, l) ftruncate(f, l)
00472 #define OPENDIR(d) opendir(d)
00473 #define OPEN open
00474 #define CHDIR(d) chdir(d)
00475 #define CLOSE(f) close(f)
00476 #define LSEEK(f, o, w) lseek(f, o, w)
00477 #define RMDIR(f) rmdir(f)
00478 #define ACCESS(p, m) access(p, m)
00479 #define CHMOD(f, p) chmod(f, p)
00480 #define FSTAT(h, b) fstat(h, b)
00481 #define PLIBC_KILL(p, s) kill(p, s)
00482 #define PIPE(h) pipe(h)
00483 #define REMOVE(p) remove(p)
00484 #define RENAME(o, n) rename(o, n)
00485 #define STAT(p, b) stat(p, b)
00486 #define STAT64(p, b) stat64(p, b)
00487 #define UNLINK(f) unlink(f)
00488 #define WRITE(f, b, n) write(f, b, n)
00489 #define READ(f, b, n) read(f, b, n)
00490 #define GN_FREAD(b, s, c, f) fread(b, s, c, f)
00491 #define GN_FWRITE(b, s, c, f) fwrite(b, s, c, f)
00492 #define SYMLINK(a, b) symlink(a, b)
00493 #define MMAP(s, l, p, f, d, o) mmap(s, l, p, f, d, o)
00494 #define MUNMAP(s, l) munmap(s, l)
00495 #define STRERROR(i) strerror(i)
00496 #define RANDOM() random()
00497 #define READLINK(p, b, s) readlink(p, b, s)
00498 #define LSTAT(p, b) lstat(p, b)
00499 #define LSTAT64(p, b) lstat64(p, b)
00500 #define PRINTF printf
00501 #define FPRINTF fprintf
00502 #define VPRINTF(f, a) vprintf(f, a)
00503 #define VFPRINTF(s, f, a) vfprintf(s, f, a)
00504 #define VSPRINTF(d, f, a) vsprintf(d, f, a)
00505 #define VSNPRINTF(str, size, fmt, a) vsnprintf(str, size, fmt, a)
00506 #define _REAL_SNPRINTF snprintf
00507 #define SPRINTF sprintf
00508 #define VSSCANF(s, f, a) vsscanf(s, f, a)
00509 #define SSCANF sscanf
00510 #define VFSCANF(s, f, a) vfscanf(s, f, a)
00511 #define VSCANF(f, a) vscanf(f, a)
00512 #define SCANF scanf
00513 #define FSCANF fscanf
00514 #define WAITPID(p, s, o) waitpid(p, s, o)
00515 #define ACCEPT(s, a, l) accept(s, a, l)
00516 #define BIND(s, n, l) bind(s, n, l)
00517 #define CONNECT(s, n, l) connect(s, n, l)
00518 #define GETPEERNAME(s, n, l) getpeername(s, n, l)
00519 #define GETSOCKNAME(s, n, l) getsockname(s, n, l)
00520 #define GETSOCKOPT(s, l, o, v, p) getsockopt(s, l, o, v, p)
00521 #define LISTEN(s, b) listen(s, b)
00522 #define RECV(s, b, l, f) recv(s, b, l, f)
00523 #define RECVFROM(s, b, l, f, r, o) recvfrom(s, b, l, f, r, o)
00524 #define SELECT(n, r, w, e, t) select(n, r, w, e, t)
00525 #define SEND(s, b, l, f) send(s, b, l, f)
00526 #define SENDTO(s, b, l, f, o, n) sendto(s, b, l, f, o, n)
00527 #define SETSOCKOPT(s, l, o, v, n) setsockopt(s, l, o, v, n)
00528 #define SHUTDOWN(s, h) shutdown(s, h)
00529 #define SOCKET(a, t, p) socket(a, t, p)
00530 #define GETHOSTBYADDR(a, l, t) gethostbyname(a, l, t)
00531 #define GETHOSTBYNAME(n) gethostbyname(n)
00532 #define GETTIMEOFDAY(t, n) gettimeofday(t, n)
00533 #define INSQUE(e, p) insque(e, p)
00534 #define REMQUE(e) remque(e)
00535
00536 #ifndef __SYMBIAN32__
00537 #define HSEARCH(i, a) hsearch(i, a)
00538 #define HCREATE(n) hcreate(n)
00539 #define HDESTROY() hdestroy()
00540 #define HSEARCH_R(i, a, r, h) hsearch_r(i, a, r, h)
00541 #define HCREATE_R(n, h) hcreate_r(n, h)
00542 #define HDESTROY_R(h) hdestroy_r(h)
00543 #define TSEARCH(k, r, c) tsearch(k, r, c)
00544 #define TFIND(k, r, c) tfind(k, r, c)
00545 #define TDELETE(k, r, c) tdelete(k, r, c)
00546 #define TWALK(r, a) twalk(r, a)
00547 #define TDESTROY(r, f) tdestroy(r, f)
00548 #define LFIND(k, b, n, s, c) lfind(k, b, n, s, c)
00549 #define LSEARCH(k, b, n, s, c) lsearch(k, b, n, s, c)
00550 #else // __SYMBIAN32__
00551 #define HSEARCH(i, a) _win_hsearch(i, a)
00552 #define HCREATE(n) _win_hcreate(n)
00553 #define HDESTROY() _win_hdestroy()
00554 #define HSEARCH_R(i, a, r, h) _win_hsearch_r(i, a, r, h)
00555 #define HCREATE_R(n, h) _win_hcreate_r(n, h)
00556 #define HDESTROY_R(h) _win_hdestroy_r(h)
00557 #define TSEARCH(k, r, c) _win_tsearch(k, r, c)
00558 #define TFIND(k, r, c) _win_tfind(k, r, c)
00559 #define TDELETE(k, r, c) _win_tdelete(k, r, c)
00560 #define TWALK(r, a) _win_twalk(r, a)
00561 #define TDESTROY(r, f) _win_tdestroy(r, f)
00562 #define LFIND(k, b, n, s, c) _win_lfind(k, b, n, s, c)
00563 #define LSEARCH(k, b, n, s, c) _win_lsearch(k, b, n, s, c)
00564 #endif // !__SYMBIAN32__
00565
00566 #else
00567 #define DIR_SEPARATOR '\\'
00568 #define DIR_SEPARATOR_STR "\\"
00569 #define PATH_SEPARATOR ':'
00570 #define PATH_SEPARATOR_STR ":"
00571 #define NEWLINE "\r\n"
00572
00573 #ifdef ENABLE_NLS
00574 #define BINDTEXTDOMAIN(d, n) _win_bindtextdomain(d, n)
00575 #endif
00576 #define CREAT(p, m) _win_creat(p, m)
00577 #define PLIBC_CTIME(c) _win_ctime(c)
00578 #define CTIME_R(c, b) _win_ctime_r(c, b)
00579 #define FOPEN(f, m) _win_fopen(f, m)
00580 #define FTRUNCATE(f, l) _win_ftruncate(f, l)
00581 #define OPENDIR(d) _win_opendir(d)
00582 #define OPEN _win_open
00583 #define CHDIR(d) _win_chdir(d)
00584 #define CLOSE(f) _win_close(f)
00585 #define PLIBC_KILL(p, s) _win_kill(p, s)
00586 #define LSEEK(f, o, w) _win_lseek(f, o, w)
00587 #define FSTAT(h, b) _win_fstat(h, b)
00588 #define RMDIR(f) _win_rmdir(f)
00589 #define ACCESS(p, m) _win_access(p, m)
00590 #define CHMOD(f, p) _win_chmod(f, p)
00591 #define PIPE(h) _win_pipe(h)
00592 #define RANDOM() _win_random()
00593 #define REMOVE(p) _win_remove(p)
00594 #define RENAME(o, n) _win_rename(o, n)
00595 #define STAT(p, b) _win_stat(p, b)
00596 #define STAT64(p, b) _win_stat64(p, b)
00597 #define UNLINK(f) _win_unlink(f)
00598 #define WRITE(f, b, n) _win_write(f, b, n)
00599 #define READ(f, b, n) _win_read(f, b, n)
00600 #define GN_FREAD(b, s, c, f) _win_fread(b, s, c, f)
00601 #define GN_FWRITE(b, s, c, f) _win_fwrite(b, s, c, f)
00602 #define SYMLINK(a, b) _win_symlink(a, b)
00603 #define MMAP(s, l, p, f, d, o) _win_mmap(s, l, p, f, d, o)
00604 #define MUNMAP(s, l) _win_munmap(s, l)
00605 #define STRERROR(i) _win_strerror(i)
00606 #define READLINK(p, b, s) _win_readlink(p, b, s)
00607 #define LSTAT(p, b) _win_lstat(p, b)
00608 #define LSTAT64(p, b) _win_lstat64(p, b)
00609 #define PRINTF(f, ...) _win_printf(f , __VA_ARGS__)
00610 #define FPRINTF(fil, fmt, ...) _win_fprintf(fil, fmt, __VA_ARGS__)
00611 #define VPRINTF(f, a) _win_vprintf(f, a)
00612 #define VFPRINTF(s, f, a) _win_vfprintf(s, f, a)
00613 #define VSPRINTF(d, f, a) _win_vsprintf(d, f, a)
00614 #define VSNPRINTF(str, size, fmt, a) _win_vsnprintf(str, size, fmt, a)
00615 #define _REAL_SNPRINTF(str, size, fmt, ...) _win_snprintf(str, size, fmt, __VA_ARGS__)
00616 #define SPRINTF(d, f, ...) _win_sprintf(d, f, __VA_ARGS__)
00617 #define VSSCANF(s, f, a) _win_vsscanf(s, f, a)
00618 #define SSCANF(s, f, ...) _win_sscanf(s, f, __VA_ARGS__)
00619 #define VFSCANF(s, f, a) _win_vfscanf(s, f, a)
00620 #define VSCANF(f, a) _win_vscanf(f, a)
00621 #define SCANF(f, ...) _win_scanf(f, __VA_ARGS__)
00622 #define FSCANF(s, f, ...) _win_fscanf(s, f, __VA_ARGS__)
00623 #define WAITPID(p, s, o) _win_waitpid(p, s, o)
00624 #define ACCEPT(s, a, l) _win_accept(s, a, l)
00625 #define BIND(s, n, l) _win_bind(s, n, l)
00626 #define CONNECT(s, n, l) _win_connect(s, n, l)
00627 #define GETPEERNAME(s, n, l) _win_getpeername(s, n, l)
00628 #define GETSOCKNAME(s, n, l) _win_getsockname(s, n, l)
00629 #define GETSOCKOPT(s, l, o, v, p) _win_getsockopt(s, l, o, v, p)
00630 #define LISTEN(s, b) _win_listen(s, b)
00631 #define RECV(s, b, l, f) _win_recv(s, b, l, f)
00632 #define RECVFROM(s, b, l, f, r, o) _win_recvfrom(s, b, l, f, r, o)
00633 #define SELECT(n, r, w, e, t) _win_select(n, r, w, e, t)
00634 #define SEND(s, b, l, f) _win_send(s, b, l, f)
00635 #define SENDTO(s, b, l, f, o, n) _win_sendto(s, b, l, f, o, n)
00636 #define SETSOCKOPT(s, l, o, v, n) _win_setsockopt(s, l, o, v, n)
00637 #define SHUTDOWN(s, h) _win_shutdown(s, h)
00638 #define SOCKET(a, t, p) _win_socket(a, t, p)
00639 #define GETHOSTBYADDR(a, l, t) _win_gethostbyname(a, l, t)
00640 #define GETHOSTBYNAME(n) _win_gethostbyname(n)
00641 #define GETTIMEOFDAY(t, n) _win_gettimeofday(t, n)
00642 #define INSQUE(e, p) _win_insque(e, p)
00643 #define REMQUE(e) _win_remque(e)
00644 #define HSEARCH(i, a) _win_hsearch(i, a)
00645 #define HCREATE(n) _win_hcreate(n)
00646 #define HDESTROY() _win_hdestroy()
00647 #define HSEARCH_R(i, a, r, h) _win_hsearch_r(i, a, r, h)
00648 #define HCREATE_R(n, h) _win_hcreate_r(n, h)
00649 #define HDESTROY_R(h) _win_hdestroy_r(h)
00650 #define TSEARCH(k, r, c) _win_tsearch(k, r, c)
00651 #define TFIND(k, r, c) _win_tfind(k, r, c)
00652 #define TDELETE(k, r, c) _win_tdelete(k, r, c)
00653 #define TWALK(r, a) _win_twalk(r, a)
00654 #define TDESTROY(r, f) _win_tdestroy(r, f)
00655 #define LFIND(k, b, n, s, c) _win_lfind(k, b, n, s, c)
00656 #define LSEARCH(k, b, n, s, c) _win_lsearch(k, b, n, s, c)
00657 #endif
00658
00659
00660
00661
00662
00663
00664 struct PLIBC_SEARCH_QELEM
00665 {
00666 struct qelem *q_forw;
00667 struct qelem *q_back;
00668 char q_data[1];
00669 };
00670
00671
00672
00673 void _win_insque (void *__elem, void *__prev);
00674
00675
00676 void _win_remque (void *__elem);
00677
00678
00679
00680 typedef int (*PLIBC_SEARCH__compar_fn_t) (__const void *, __const void *);
00681
00682 typedef PLIBC_SEARCH__compar_fn_t _win_comparison_fn_t;
00683
00684
00685 typedef enum
00686 {
00687 PLIBC_SEARCH_FIND,
00688 PLIBC_SEARCH_ENTER
00689 }
00690 PLIBC_SEARCH_ACTION;
00691
00692 typedef struct PLIBC_SEARCH_entry
00693 {
00694 char *key;
00695 void *data;
00696 }
00697 PLIBC_SEARCH_ENTRY;
00698
00699
00700
00701
00702 typedef struct _PLIBC_SEARCH_ENTRY
00703 {
00704 unsigned int used;
00705 PLIBC_SEARCH_ENTRY entry;
00706 }
00707 _PLIBC_SEARCH_ENTRY;
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718 PLIBC_SEARCH_ENTRY *_win_hsearch (PLIBC_SEARCH_ENTRY __item,
00719 PLIBC_SEARCH_ACTION __action);
00720
00721
00722 int _win_hcreate (size_t __nel);
00723
00724
00725 void _win_hdestroy (void);
00726
00727
00728 struct PLIBC_SEARCH_hsearch_data
00729 {
00730 struct _PLIBC_SEARCH_ENTRY *table;
00731 unsigned int size;
00732 unsigned int filled;
00733 };
00734
00735
00736
00737 int _win_hsearch_r (PLIBC_SEARCH_ENTRY __item, PLIBC_SEARCH_ACTION __action,
00738 PLIBC_SEARCH_ENTRY ** __retval,
00739 struct PLIBC_SEARCH_hsearch_data *__htab);
00740 int _win_hcreate_r (size_t __nel, struct PLIBC_SEARCH_hsearch_data *__htab);
00741 void _win_hdestroy_r (struct PLIBC_SEARCH_hsearch_data *__htab);
00742
00743
00744
00745
00746
00747
00748
00749 typedef enum
00750 {
00751 PLIBC_SEARCH_preorder,
00752 PLIBC_SEARCH_postorder,
00753 PLIBC_SEARCH_endorder,
00754 PLIBC_SEARCH_leaf
00755 }
00756 PLIBC_SEARCH_VISIT;
00757
00758
00759
00760 void *_win_tsearch (__const void *__key, void **__rootp,
00761 PLIBC_SEARCH__compar_fn_t __compar);
00762
00763
00764
00765 void *_win_tfind (__const void *__key, void *__const * __rootp,
00766 PLIBC_SEARCH__compar_fn_t __compar);
00767
00768
00769 void *_win_tdelete (__const void *__restrict __key,
00770 void **__restrict __rootp,
00771 PLIBC_SEARCH__compar_fn_t __compar);
00772
00773 typedef void (*PLIBC_SEARCH__action_fn_t) (__const void *__nodep,
00774 PLIBC_SEARCH_VISIT __value,
00775 int __level);
00776
00777
00778
00779 void _win_twalk (__const void *__root, PLIBC_SEARCH__action_fn_t __action);
00780
00781
00782
00783 typedef void (*PLIBC_SEARCH__free_fn_t) (void *__nodep);
00784
00785
00786 void _win_tdestroy (void *__root, PLIBC_SEARCH__free_fn_t __freefct);
00787
00788
00789
00790
00791 void *_win_lfind (__const void *__key, __const void *__base,
00792 size_t * __nmemb, size_t __size,
00793 PLIBC_SEARCH__compar_fn_t __compar);
00794
00795
00796
00797 void *_win_lsearch (__const void *__key, void *__base,
00798 size_t * __nmemb, size_t __size,
00799 PLIBC_SEARCH__compar_fn_t __compar);
00800
00801
00802 #ifdef __cplusplus
00803 }
00804 #endif
00805
00806
00807 #endif //_PLIBC_H_
00808
00809