DEFINITIONS
This source file includes following functions.
1 #ifndef EXT_NT_H
2 #define EXT_NT_H
3
4
5
6
7
8
9
10
11
12 #undef EXTERN
13 #if defined(IMPORT)
14 #define EXTERN extern __declspec(dllimport)
15 #elif defined(EXPORT)
16 #define EXTERN extern __declspec(dllexport)
17 #endif
18
19
20
21
22
23
24
25
26
27
28
29
30 #if !defined(IN) && !defined(FLOAT)
31 #define OpenFile WINAPI_OpenFile
32 #include <windows.h>
33 #include <winsock.h>
34 #undef OpenFile
35 #endif
36
37
38
39
40 #undef try
41 #undef except
42 #undef finally
43 #undef leave
44
45 #if defined(__cplusplus)
46 extern "C++" {
47 #endif
48
49 #include <stdio.h>
50 #include <stdlib.h>
51 #include <string.h>
52 #include <direct.h>
53 #include <process.h>
54 #include <time.h>
55 #include <math.h>
56 #include <signal.h>
57 #include <sys/stat.h>
58 #include <sys/types.h>
59 #if !defined(__BORLANDC__)
60 # include <sys/utime.h>
61 #else
62 # include <utime.h>
63 #endif
64 #include <io.h>
65 #include <malloc.h>
66
67 #if defined(__cplusplus)
68 }
69 #endif
70
71 #define UIDTYPE int
72 #define GIDTYPE int
73 #define pid_t int
74 #define WNOHANG -1
75
76 #undef getc
77 #undef putc
78 #undef fgetc
79 #undef fputc
80 #undef getchar
81 #undef putchar
82 #undef fgetchar
83 #undef fputchar
84 #define getc(_stream) rb_w32_getc(_stream)
85 #define putc(_c, _stream) rb_w32_putc(_c, _stream)
86 #define fgetc(_stream) getc(_stream)
87 #define fputc(_c, _stream) putc(_c, _stream)
88 #define getchar() rb_w32_getc(stdin)
89 #define putchar(_c) rb_w32_putc(_c, stdout)
90 #define fgetchar(_stream) getchar()
91 #define fputchar(_c, _stream) putchar(_c)
92
93 #ifndef __BORLANDC__
94
95 #define access _access
96 #define chmod _chmod
97 #define chsize _chsize
98 #define dup _dup
99 #define dup2 _dup2
100 #define isatty _isatty
101 #define open _open
102 #define setmode _setmode
103 #define execl _execl
104 #define execle _execle
105 #define execlp _execlp
106 #define execlpe _execlpe
107 #define execv _execv
108 #define execve _execve
109 #define execvp _execvp
110 #define execvpe _execvpe
111 #define lseek _lseek
112 #define spawnl _spawnl
113 #define spawnle _spawnle
114 #define spawnlp _spawnlp
115 #define spawnlpe _spawnlpe
116 #define spawnv _spawnv
117 #define spawnve _spawnve
118 #define spawnvp _spawnvp
119 #define spawnvpe _spawnvpe
120 #if _MSC_VER < 800
121 #define fileno _fileno
122 #endif
123 #define strcasecmp _stricmp
124 #define strncasecmp _strnicmp
125 #else
126 #define strcasecmp stricmp
127 #define strncasecmp strnicmp
128 #define _open _sopen
129 #endif
130
131 #define close _close
132 #define creat _creat
133 #define eof _eof
134 #define filelength _filelength
135 #define locking _locking
136 #define mktemp _mktemp
137 #define perror _perror
138 #define read _read
139 #define sopen _sopen
140 #define tell _tell
141 #define umask _umask
142 #define unlink _unlink
143 #define write _write
144 #define getpid rb_w32_getpid
145 #define sleep(x) rb_w32_sleep((x)*1000)
146 #define utime _utime
147 #define vsnprintf _vsnprintf
148 #define snprintf _snprintf
149 #undef stat
150 #define stat(path,st) rb_w32_stat(path,st)
151
152 #ifdef __MINGW32__
153 struct timezone {
154 int tz_minuteswest;
155 int tz_dsttime;
156 };
157 #endif
158 extern int NtMakeCmdVector(char *, char ***, int);
159 extern void NtInitialize(int *, char ***);
160 extern char * NtGetLib(void);
161 extern char * NtGetBin(void);
162 extern pid_t pipe_exec(char *, int, FILE **, FILE **);
163 extern int flock(int fd, int oper);
164 extern int rb_w32_fddup(int);
165 extern void rb_w32_fdclose(FILE *);
166 extern SOCKET rb_w32_accept(SOCKET, struct sockaddr *, int *);
167 extern int rb_w32_bind(SOCKET, struct sockaddr *, int);
168 extern int rb_w32_connect(SOCKET, struct sockaddr *, int);
169 extern void rb_w32_fdset(int, fd_set*);
170 extern void rb_w32_fdclr(int, fd_set*);
171 extern int rb_w32_fdisset(int, fd_set*);
172 extern long rb_w32_select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
173 extern int rb_w32_getpeername(SOCKET, struct sockaddr *, int *);
174 extern int rb_w32_getsockname(SOCKET, struct sockaddr *, int *);
175 extern int rb_w32_getsockopt(SOCKET, int, int, char *, int *);
176 extern int rb_w32_ioctlsocket(SOCKET, long, u_long *);
177 extern int rb_w32_listen(SOCKET, int);
178 extern int rb_w32_recv(SOCKET, char *, int, int);
179 extern int rb_w32_recvfrom(SOCKET, char *, int, int, struct sockaddr *, int *);
180 extern int rb_w32_send(SOCKET, char *, int, int);
181 extern int rb_w32_sendto(SOCKET, char *, int, int, struct sockaddr *, int);
182 extern int rb_w32_setsockopt(SOCKET, int, int, char *, int);
183 extern int rb_w32_shutdown(SOCKET, int);
184 extern SOCKET rb_w32_socket(int, int, int);
185 extern SOCKET rb_w32_get_osfhandle(int);
186 extern struct hostent * rb_w32_gethostbyaddr(char *, int, int);
187 extern struct hostent * rb_w32_gethostbyname(char *);
188 extern int rb_w32_gethostname(char *, int);
189 extern struct protoent * rb_w32_getprotobyname(char *);
190 extern struct protoent * rb_w32_getprotobynumber(int);
191 extern struct servent * rb_w32_getservbyname(char *, char *);
192 extern struct servent * rb_w32_getservbyport(int, char *);
193 extern char * rb_w32_getenv(const char *);
194 extern int rb_w32_rename(const char *, const char *);
195 extern char **rb_w32_get_environ(void);
196 extern void rb_w32_free_environ(char **);
197
198 extern int chown(const char *, int, int);
199 extern int link(char *, char *);
200 extern int gettimeofday(struct timeval *, struct timezone *);
201 extern pid_t waitpid (pid_t, int *, int);
202 extern int do_spawn(char *);
203 extern int kill(int, int);
204 extern pid_t rb_w32_getpid(void);
205 #ifndef __BORLANDC__
206 extern int isinf(double);
207 extern int isnan(double);
208 #else
209 #include <float.h>
210 #ifndef isinf
211 #define isinf !_finite
212 #endif
213 #ifndef isnan
214 #define isnan _isnan
215 #endif
216
217 #ifdef S_ISDIR
218 #undef S_ISDIR
219 #endif
220
221 #ifdef S_ISFIFO
222 #undef S_ISFIFO
223 #endif
224
225 #ifdef S_ISBLK
226 #undef S_ISBLK
227 #endif
228
229 #ifdef S_ISCHR
230 #undef S_ISCHR
231 #endif
232
233 #ifdef S_ISREG
234 #undef S_ISREG
235 #endif
236
237 #define S_ISDIR(m) (((unsigned short)(m) & S_IFMT) == S_IFDIR)
238 #define S_ISFIFO(m) (((unsigned short)(m) & S_IFMT) == S_IFIFO)
239 #define S_ISBLK(m) (((unsigned short)(m) & S_IFMT) == S_IFBLK)
240 #define S_ISCHR(m) (((unsigned short)(m) & S_IFMT) == S_IFCHR)
241 #define S_ISREG(m) (((unsigned short)(m) & S_IFMT) == S_IFREG)
242 #endif
243
244 #if !defined S_IRUSR && !defined __MINGW32__
245 #define S_IRUSR 0400
246 #endif
247 #ifndef S_IRGRP
248 #define S_IRGRP 0040
249 #endif
250 #ifndef S_IROTH
251 #define S_IROTH 0004
252 #endif
253
254 #if !defined S_IWUSR && !defined __MINGW32__
255 #define S_IWUSR 0200
256 #endif
257 #ifndef S_IWGRP
258 #define S_IWGRP 0020
259 #endif
260 #ifndef S_IWOTH
261 #define S_IWOTH 0002
262 #endif
263
264 #if !defined S_IXUSR && !defined __MINGW32__
265 #define S_IXUSR 0100
266 #endif
267 #ifndef S_IXGRP
268 #define S_IXGRP 0010
269 #endif
270 #ifndef S_IXOTH
271 #define S_IXOTH 0001
272 #endif
273
274
275
276
277
278 #define SUFFIX
279
280
281
282
283 #if !defined(__BORLANDC__)
284 extern int ioctl (int, unsigned int, long);
285 #endif
286 extern UIDTYPE getuid (void);
287 extern UIDTYPE geteuid (void);
288 extern GIDTYPE getgid (void);
289 extern GIDTYPE getegid (void);
290 extern int setuid (int);
291 extern int setgid (int);
292
293 extern char *rb_w32_strerror(int);
294
295 #define strerror(e) rb_w32_strerror(e)
296
297 #define PIPE_BUF 1024
298
299 #define LOCK_SH 1
300 #define LOCK_EX 2
301 #define LOCK_NB 4
302 #define LOCK_UN 8
303 #ifndef EWOULDBLOCK
304 #define EWOULDBLOCK 10035
305 #endif
306
307
308 #ifndef SIGINT
309 #define SIGINT 2
310 #endif
311 #ifndef SIGKILL
312 #define SIGKILL 9
313 #endif
314
315
316
317
318
319 #ifdef accept
320 #undef accept
321 #endif
322 #define accept rb_w32_accept
323
324 #ifdef bind
325 #undef bind
326 #endif
327 #define bind rb_w32_bind
328
329 #ifdef connect
330 #undef connect
331 #endif
332 #define connect rb_w32_connect
333
334 #undef FD_SET
335 #define FD_SET rb_w32_fdset
336
337 #undef FD_CLR
338 #define FD_CLR rb_w32_fdclr
339
340 #undef FD_ISSET
341 #define FD_ISSET rb_w32_fdisset
342
343 #undef select
344 #define select rb_w32_select
345
346 #ifdef getpeername
347 #undef getpeername
348 #endif
349 #define getpeername rb_w32_getpeername
350
351 #ifdef getsockname
352 #undef getsockname
353 #endif
354 #define getsockname rb_w32_getsockname
355
356 #ifdef getsockopt
357 #undef getsockopt
358 #endif
359 #define getsockopt rb_w32_getsockopt
360
361 #ifdef ioctlsocket
362 #undef ioctlsocket
363 #endif
364 #define ioctlsocket rb_w32_ioctlsocket
365
366 #ifdef listen
367 #undef listen
368 #endif
369 #define listen rb_w32_listen
370
371 #ifdef recv
372 #undef recv
373 #endif
374 #define recv rb_w32_recv
375
376 #ifdef recvfrom
377 #undef recvfrom
378 #endif
379 #define recvfrom rb_w32_recvfrom
380
381 #ifdef send
382 #undef send
383 #endif
384 #define send rb_w32_send
385
386 #ifdef sendto
387 #undef sendto
388 #endif
389 #define sendto rb_w32_sendto
390
391 #ifdef setsockopt
392 #undef setsockopt
393 #endif
394 #define setsockopt rb_w32_setsockopt
395
396 #ifdef shutdown
397 #undef shutdown
398 #endif
399 #define shutdown rb_w32_shutdown
400
401 #ifdef socket
402 #undef socket
403 #endif
404 #define socket rb_w32_socket
405
406 #ifdef gethostbyaddr
407 #undef gethostbyaddr
408 #endif
409 #define gethostbyaddr rb_w32_gethostbyaddr
410
411 #ifdef gethostbyname
412 #undef gethostbyname
413 #endif
414 #define gethostbyname rb_w32_gethostbyname
415
416 #ifdef gethostname
417 #undef gethostname
418 #endif
419 #define gethostname rb_w32_gethostname
420
421 #ifdef getprotobyname
422 #undef getprotobyname
423 #endif
424 #define getprotobyname rb_w32_getprotobyname
425
426 #ifdef getprotobynumber
427 #undef getprotobynumber
428 #endif
429 #define getprotobynumber rb_w32_getprotobynumber
430
431 #ifdef getservbyname
432 #undef getservbyname
433 #endif
434 #define getservbyname rb_w32_getservbyname
435
436 #ifdef getservbyport
437 #undef getservbyport
438 #endif
439 #define getservbyport rb_w32_getservbyport
440
441 #ifdef get_osfhandle
442 #undef get_osfhandle
443 #endif
444 #define get_osfhandle rb_w32_get_osfhandle
445
446 #ifdef getcwd
447 #undef getcwd
448 #endif
449 #define getcwd rb_w32_getcwd
450
451 #ifdef getenv
452 #undef getenv
453 #endif
454 #define getenv rb_w32_getenv
455
456 #ifdef rename
457 #undef rename
458 #endif
459 #define rename rb_w32_rename
460
461 struct tms {
462 long tms_utime;
463 long tms_stime;
464 long tms_cutime;
465 long tms_cstime;
466 };
467
468 #ifdef times
469 #undef times
470 #endif
471 #define times rb_w32_times
472
473
474 HANDLE GetCurrentThreadHandle(void);
475 int rb_w32_main_context(int arg, void (*handler)(int));
476 int rb_w32_sleep(unsigned long msec);
477 void rb_w32_enter_critical(void);
478 void rb_w32_leave_critical(void);
479 int rb_w32_putc(int, FILE*);
480 int rb_w32_getc(FILE*);
481 #define Sleep(msec) (void)rb_w32_sleep(msec)
482
483
484
485
486
487
488
489
490 typedef DWORD (*asynchronous_func_t)(DWORD self, int argc, DWORD* argv);
491 DWORD rb_w32_asynchronize(asynchronous_func_t func, DWORD self, int argc, DWORD* argv, DWORD intrval);
492
493 #endif