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