~ubuntu-branches/ubuntu/intrepid/gnunet/intrepid

« back to all changes in this revision

Viewing changes to src/include/plibc.h

  • Committer: Bazaar Package Importer
  • Author(s): Bhavani Shankar
  • Date: 2008-08-19 19:44:30 UTC
  • mfrom: (1.2.12 upstream) (3.1.2 lenny)
  • Revision ID: james.westby@ubuntu.com-20080819194430-x5gjv8wd7t7ldkp0
Tags: 0.8.0a-1ubuntu1
* Merge from debian unstable, remaining changes: (LP: #256576)
  - debian/rules:
   + Make use of code from cdbs' clean-la.mk file to clear the
      dependency_libs field in all .la files in the gnunet-dev 
      package.

Show diffs side-by-side

added added

removed removed

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