Debian Codegraph @

WWW/Library/Implementation/www_tcp.h

raw
1 /* System dependencies in the W3 library
2 * $LynxId: www_tcp.h,v 1.64 2025/07/25 19:57:16 tom Exp $
3 *
4 SYSTEM DEPENDENCIES
5
6 System-system differences for TCP include files and macros. This
7 file includes for each system the files necessary for network and
8 file I/O. It should be used in conjunction with HTUtils.h to help
9 ensure portability across as many platforms and flavors of platforms
10 as possible.
11
12 AUTHORS
13
14 TBL Tim Berners-Lee, W3 project, CERN, <[email protected]>
15 EvA Eelco van Asperen <[email protected]>
16 MA Marc Andreessen NCSA
17 AT Aleksandar Totic <[email protected]>
18 SCW Susan C. Weber <[email protected]>
19
20 HISTORY:
21 22 Feb 91 Written (TBL) as part of the WWW library.
22 16 Jan 92 PC code from EvA
23 22 Apr 93 Merged diffs bits from xmosaic release
24 29 Apr 93 Windows/NT code from SCW
25 20 May 94 A.Harper Add support for VMS CMU TCP/IP transport
26 3 Oct 94 A.Harper Add support for VMS SOCKETSHR/NETLIB
27 15 Jul 95 S. Bjorndahl Gnu C for VMS Globaldef/ref support
28
29 */
30
31 #ifndef TCP_H
32 #define TCP_H
33
34 /*
35
36 Default values
37
38 These values may be reset and altered by system-specific sections
39 later on. there are also a bunch of defaults at the end .
40
41 */
42 /* Default values of those: */
43 /* Routine to close a TCP-IP socket */
44 #define NETCLOSE close
45 /* Routine to read from a TCP-IP socket */
46 #define NETREAD(s,p,n) \
47 HTDoRead(s, p, (unsigned)(n))
48 /* Routine to write to a TCP-IP socket */
49 #define NETWRITE(s,p,n) write(s, p, (size_t)(n))
50 #define SOCKET_READ(s,b,l) read(s,b,(size_t)(l))
51 #define IOCTL(s,cmd,arg) ioctl(s,(long)(cmd),arg)
52 #define SOCKET_ERRNO errno /* normal socket errno */
53
54 /* Unless stated otherwise, */
55 #define SELECT /* Can handle >1 channel. */
56 #define GOT_SYSTEM /* Can call shell with string */
57
58 #ifdef UNIX
59 #define GOT_PIPE
60 #endif /* UNIX */
61
62 #define INVSOC (-1) /* Unix invalid socket */
63 /* NB: newer libwww has something different for Windows */
64
65 #ifndef VMS
66
67 #include <sys/types.h>
68
69 #if defined(__BORLANDC__)
70 #define DECL_ERRNO
71 #endif
72
73 #if defined(__DJGPP__) || defined(__BORLANDC__)
74 #undef HAVE_DIRENT_H
75 #define HAVE_DIRENT_H
76 #undef HAVE_SYS_FILIO_H
77 #endif /* DJGPP or __BORLANDC__ */
78
79 #if defined(_MSC_VER)
80 #undef HAVE_DIRENT_H
81 #define HAVE_DIRENT_H
82 #undef HAVE_SYS_FILIO_H
83 #endif /* _MSC_VER */
84
85 #ifdef HAVE_DIRENT_H
86 # include <dirent.h>
87 # define D_NAMLEN(dirent) strlen((dirent)->d_name)
88 # define STRUCT_DIRENT struct dirent
89 #else
90 # define D_NAMLEN(dirent) (dirent)->d_namlen
91 # define STRUCT_DIRENT struct direct
92 # ifdef HAVE_SYS_NDIR_H
93 # include <sys/ndir.h>
94 # endif
95 # ifdef HAVE_SYS_DIR_H
96 # include <sys/dir.h>
97 # endif
98 # ifdef HAVE_NDIR_H
99 # include <ndir.h>
100 # endif
101 #endif /* HAVE_DIRENT_H */
102
103 #ifdef HAVE_STRUCT_DIRENT64
104 # undef STRUCT_DIRENT
105 # define STRUCT_DIRENT struct dirent64
106 #endif
107
108 #if !(defined(DOSPATH) || defined(__EMX__) || defined(__CYGWIN__))
109 #define STRUCT_DIRENT__D_INO 1
110 #endif
111
112 #endif /* !VMS */
113
114 #ifdef TIME_WITH_SYS_TIME
115 # include <sys/time.h>
116 # include <time.h>
117 #else
118 # ifdef HAVE_SYS_TIME_H
119 # include <sys/time.h>
120 # else
121 # include <time.h>
122 # endif
123 #endif
124
125 #if defined(_AIX) && !defined(AIX)
126 #define AIX
127 #endif /* _AIX */
128
129 #ifndef __CYGWIN__
130 #ifdef WIN_EX
131 #define HAVE_FTIME 1
132 #define HAVE_SYS_TIMEB_H 1
133 #endif
134 #endif /* __CYGWIN__ */
135
136 #ifdef HAVE_FCNTL_H
137 #include <fcntl.h>
138 #else
139 #ifdef HAVE_SYS_FCNTL_H
140 #include <sys/fcntl.h>
141 #endif
142 #endif
143
144 #ifdef HAVE_STRING_H
145 #include <string.h> /* For bzero etc */
146 #endif /* HAVE_STRING_H */
147
148 /*
149
150 MACROS FOR CONVERTING CHARACTERS
151
152 */
153 #ifndef TOASCII
154 #ifdef EBCDIC /* S/390 -- gil -- 1327 */
155
156 extern const char un_IBM1047[];
157 extern const unsigned char IBM1047[];
158
159 /* For debugging
160 #include <assert.h>
161 #define TOASCII(c) (assert((c)>=0 && (c)<256), un_IBM1047[c])
162 */
163 /* for production */
164 #define TOASCII(c) (un_IBM1047[c])
165
166 #define FROMASCII(c) (IBM1047[c])
167
168 #else /* EBCDIC */
169
170 #if '0' != 48
171 error Host character set is not ASCII.
172 #endif
173
174 #define TOASCII(c) (c)
175 #define FROMASCII(c) (c)
176
177 #endif /* EBCDIC */
178 #endif /* !TOASCII */
179
180 /* convert a char to an unsigned, needed if we have signed characters for ctype.h */
181 #define UCH(ch) ((unsigned char)(ch))
182
183 /*
184 * These parameters were provided by Nigel Horne, using BeOS professional 5.0
185 */
186 #ifdef __BEOS__
187 #undef NETREAD
188 #undef NETWRITE
189 #undef NETCLOSE
190 #define NETREAD(s,b,l) recv((s),(b),(l),0)
191 #define NETWRITE(s,b,l) send((s),(b),(l),0)
192 #define NETCLOSE(s) closesocket(s)
193 #endif
194
195 /*
196 IBM-PC running Windows NT
197
198 These parameters provided by Susan C. Weber <[email protected]>.
199 */
200
201 #ifdef _WINDOWS
202
203 #ifndef _WINDOWS_NSL
204 #define _WINDOWS_NSL
205 #endif
206
207 #include <fcntl.h> /* For HTFile.c */
208 #include <sys/types.h> /* For HTFile.c */
209 #include <sys/stat.h> /* For HTFile.c */
210 #undef NETREAD
211 #undef NETWRITE
212 #undef NETCLOSE
213 #undef IOCTL
214 extern int ws_netread(int fd, char *buf, int len);
215
216 #define NETREAD(s,b,l) ws_netread((s),(b),(l)) /* 1997/11/06 (Thu) */
217 #define NETWRITE(s,b,l) send((s),(b),(l),0)
218 #define NETCLOSE(s) closesocket(s)
219 #define IOCTL(s,cmd,arg) ioctlsocket(s,cmd,arg)
220 #include <io.h>
221 #include <string.h>
222 #include <process.h>
223 #include <time.h>
224 #include <errno.h>
225 #include <direct.h>
226
227 #ifdef ENABLE_IPV6
228 #undef USE_WINSOCK2_H
229 #define USE_WINSOCK2_H
230
231 /* Avoid including <winsock*.h> in <windows.h> */
232 #ifndef WIN32_LEAN_AND_MEAN
233 #error Define "WIN32_LEAN_AND_MEAN" in your makefile
234 #endif
235
236 #ifdef _WINSOCKAPI_
237 #error windows.h included before winsock2.h
238 #endif
239
240 #if defined(_MSC_VER) && (!defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0501)
241 /*
242 * Needed to pull in the real getaddrinfo() and not the inline version
243 * in <wspiAPI.H> which doesn't support IPv6 (IPv4 only). <wspiAPI.H> is
244 * included from <ws2tcpip.h> for <= 0x0500 SDKs.
245 */
246 #undef _WIN32_WINNT
247 #define _WIN32_WINNT 0x0501
248 #endif
249 #endif /* ENABLE_IPV6 */
250
251 #ifdef USE_WINSOCK2_H
252 #include <winsock2.h> /* normally included in windows.h */
253
254 #ifdef ENABLE_IPV6
255 #include <ws2tcpip.h>
256 #endif
257
258 #undef EINPROGRESS
259 #undef EALREADY
260 #undef EISCONN
261 #undef EINTR
262 #undef EAGAIN
263 #undef ENOTCONN
264 #undef ECONNRESET
265 #undef ETIMEDOUT
266
267 #define EINPROGRESS WSAEINPROGRESS
268 #define EALREADY WSAEALREADY
269 #define EISCONN WSAEISCONN
270 #define EINTR WSAEINTR
271 /* fine EAGAIN WSAEAGAIN */
272 #define ENOTCONN WSAENOTCONN
273 #define ECONNRESET WSAECONNRESET
274 #define ETIMEDOUT WSAETIMEDOUT
275
276 #else /* USE_WINSOCK2_H */
277
278 #include <winsock.h>
279
280 #if defined(_MSC_VER) || defined(__MINGW32__)
281 #undef EINTR
282 #undef EAGAIN
283 #endif /* _MSC_VER */
284
285 #undef EINPROGRESS
286 #define EINPROGRESS (WSABASEERR+36)
287
288 #undef EALREADY
289 #define EALREADY (WSABASEERR+37)
290
291 #undef EISCONN
292 #define EISCONN (WSABASEERR+56)
293
294 #undef EINTR
295 #define EINTR (WSABASEERR+4)
296
297 #undef EAGAIN
298 #define EAGAIN (WSABASEERR+1002)
299
300 #undef ENOTCONN
301 #define ENOTCONN (WSABASEERR+57)
302
303 #undef ECONNRESET
304 #define ECONNRESET (WSABASEERR+54)
305
306 #undef ETIMEDOUT
307 #define ETIMEDOUT WSAETIMEDOUT
308
309 #endif /* USE_WINSOCK2_H */
310
311 #undef SOCKET_ERRNO
312 #define SOCKET_ERRNO WSAGetLastError()
313
314 #define INCLUDES_DONE
315 #define TCP_INCLUDES_DONE
316
317 #define LYNX_FD SOCKET /* WINSOCK uses an unsigned value for FD_SET, etc */
318
319 #else
320
321 #define LYNX_FD int /* POSIX says FD_SET descriptor is int */
322
323 #endif /* WINDOWS */
324
325 /*
326
327 VAX/VMS
328
329 Under VMS, there are many versions of TCP-IP. Define one if you do
330 not use Digital's UCX product:
331
332 UCX DEC's "Ultrix connection" (default)
333 CMU_TCP Available via FTP from sacusr.mp.usbr.gov
334 SOCKETSHR Eckhart Meyer's interface to NETLIB
335 WIN_TCP From Wollongong, now GEC software.
336 MULTINET From SRI, became TGV, then Cisco.
337 DECNET Cern's TCP socket emulation over DECnet
338 TCPIP_SERVICES TCP/IP Services (newer than UCX)
339
340 WIN_TCP, MULTINET and DECNET do not interfere with the
341 unix i/o library, and so they need special calls to read, write and
342 close sockets. In these cases the socket number is a VMS channel
343 number, so we make the @@@ HORRIBLE @@@ assumption that a channel
344 number will be greater than 10 but a unix file descriptor less than
345 10. It works.
346
347 */
348 #ifdef VMS
349
350 #ifdef UCX
351 #undef IOCTL
352 #define IOCTL(s,cmd,arg) HTioctl(s,cmd,arg)
353 #endif /* UCX */
354
355 #ifdef WIN_TCP
356 #undef SOCKET_READ
357 #undef NETWRITE
358 #undef NETCLOSE
359 #define SOCKET_READ(s,b,l) ((s)>10 ? netread((s),(b),(l)) : read((s),(b),(l)))
360 #define NETWRITE(s,b,l) ((s)>10 ? netwrite((s),(b),(l)) : write((s),(b),(l)))
361 #define NETCLOSE(s) ((s)>10 ? netclose(s) : close(s))
362 #undef IOCTL
363 #define IOCTL(a,b,c) -1 /* disables ioctl function */
364 #define NO_IOCTL /* flag to check if ioctl is disabled */
365 #endif /* WIN_TCP */
366
367 #ifdef CMU_TCP
368 #undef SOCKET_READ
369 #undef NETREAD
370 #undef NETWRITE
371 #undef NETCLOSE
372 #define SOCKET_READ(s,b,l) (cmu_get_sdc((s)) != 0 ? cmu_read((s),(b),(l)) : read((s),(b),(l)))
373 #define NETREAD(s,b,l) (cmu_get_sdc((s)) != 0 ? HTDoRead((s),(b),(l)) : read((s),(b),(l)))
374 #define NETWRITE(s,b,l) (cmu_get_sdc((s)) != 0 ? cmu_write((s),(b),(l)) : write((s),(b),(l)))
375 #define NETCLOSE(s) (cmu_get_sdc((s)) != 0 ? cmu_close((s)) : close((s)))
376 #endif /* CMU_TCP */
377
378 #ifdef MULTINET
379 #undef NETCLOSE
380 #undef SOCKET_READ
381 #undef NETWRITE
382 #undef IOCTL
383 #undef SOCKET_ERRNO
384 /*
385 * Delete these socket_foo() prototypes as MultiNet adds them
386 * to it's socket library headers. Compiler warnings due to
387 * the absence of arguments in the generic prototypes here will
388 * include the names of those which can be deleted. - FM
389 */
390 extern int socket_read();
391 extern int socket_write();
392 extern int socket_close();
393 extern int socket_ioctl();
394
395 #define SOCKET_READ(s,b,l) ((s)>10 ? socket_read((s),(b),(l)) : \
396 read((s),(b),(l)))
397 #define NETWRITE(s,b,l) ((s)>10 ? socket_write((s),(b),(l)) : \
398 write((s),(b),(l)))
399 #define NETCLOSE(s) ((s)>10 ? socket_close(s) : close(s))
400 #define IOCTL(s,cmd,arg) socket_ioctl(s,cmd,arg)
401 #define SOCKET_ERRNO socket_errno
402 #endif /* MULTINET */
403
404 #ifdef SOCKETSHR_TCP
405 #undef SOCKET_READ
406 #undef NETREAD
407 #undef NETWRITE
408 #undef NETCLOSE
409 #undef IOCTL
410 #define SOCKET_READ(s,b,l) (si_get_sdc((s)) != 0 ? si_read((s),(b),(l)) : \
411 read((s),(b),(l)))
412 #define NETREAD(s,b,l) (si_get_sdc((s)) != 0 ? HTDoRead((s),(b),(l)) : \
413 read((s),(b),(l)))
414 #define NETWRITE(s,b,l) (si_get_sdc((s)) != 0 ? si_write((s),(b),(l)) : \
415 write((s),(b),(l)))
416 #define NETCLOSE(s) (si_get_sdc((s)) != 0 ? si_close((s)) : close((s)))
417 #define IOCTL(s,cmd,arg) si_ioctl(s,cmd,arg)
418 #endif /* SOCKETSHR_TCP */
419
420 #ifdef TCPIP_SERVICES
421 /*
422 * TCPIP Services has all of the entrypoints including ioctl().
423 */
424 #undef NETWRITE
425 #define NETWRITE(s,b,l) send((s),(char *)(b),(l),0)
426
427 #define TYPE_FD_SET int
428
429 #if 0 /* this should be declared via time.h */
430 typedef TYPE_FD_SET fd_set;
431 #endif
432
433 #endif /* TCPIP_SERVICES */
434
435 #include <string.h>
436
437 #include <file.h>
438 #include <stat.h>
439 #include <unixio.h>
440 #include <unixlib.h>
441
442 #define INCLUDES_DONE
443
444 #ifdef MULTINET /* Include from standard Multinet directories */
445 /*
446 * Delete any of these multinet_foo() and associated prototypes
447 * as MultiNet adds them to its socket library headers. You'll
448 * get compiler warnings about them, due the absence of arguments
449 * in the generic prototyping here, and the warnings will include
450 * the names of the functions whose prototype entries can be
451 * deleted here. - FM
452 */
453 extern int multinet_accept();
454 extern int multinet_bind();
455 extern int multinet_connect();
456 extern int multinet_gethostname();
457 extern int multinet_getsockname();
458 extern unsigned short multinet_htons(unsigned short __val);
459 extern unsigned short multinet_ntohs(unsigned short __val);
460 extern int multinet_listen();
461 extern int multinet_select();
462 extern int multinet_socket();
463 extern char *vms_errno_string();
464
465 #ifndef __SOCKET_TYPEDEFS
466 #define __SOCKET_TYPEDEFS 1
467 #endif /* !__SOCKET_TYPEDEFS */
468
469 #include <time.h>
470 #include <types.h>
471 /*
472 * DEC C before version 5.2 added some typedefs to <types.h> which happen
473 * to be suppressed if the version-4 compatibility define is set. In
474 * particular, lynx uses "off_t". VAX-C used "unsigned", DEC-C uses "int".
475 */
476 #if defined(_DECC_V4_SOURCE) && !defined(____OFF_T)
477 #undef off_t
478 #define off_t int
479 #endif
480
481 #ifdef __TIME_T
482 #undef __TYPES
483 #define __TYPES 1
484 #define __TYPES_LOADED 1
485 #endif /* __TIME_T */
486
487 #ifdef __SOCKET_TYPEDEFS
488 #undef __SOCKET_TYPEDEFS
489 #endif /* __SOCKET_TYPEDEFS */
490
491 #include "multinet_root:[multinet.include.sys]types.h"
492
493 #ifndef __SOCKET_TYPEDEFS
494 #define __SOCKET_TYPEDEFS 1
495 #endif /* !__SOCKET_TYPEDEFS */
496
497 #include "multinet_root:[multinet.include]errno.h"
498
499 #ifdef __TYPES
500 #undef __TIME_T
501 #define __TIME_T 1
502 #endif /* __TYPE */
503
504 #ifdef __TIME_LOADED
505 #undef __TIME
506 #define __TIME 1 /* to avoid double definitions in in.h */
507 #endif /* __TIME_LOADED */
508
509 #include "multinet_root:[multinet.include.sys]time.h"
510
511 #define MULTINET_NO_PROTOTYPES /* DECC is compatible-but-different */
512 #include "multinet_root:[multinet.include.sys]socket.h"
513 #undef MULTINET_NO_PROTOTYPES
514 #include "multinet_root:[multinet.include.netinet]in.h"
515 #include "multinet_root:[multinet.include.arpa]inet.h"
516 #include "multinet_root:[multinet.include]netdb.h"
517 #include "multinet_root:[multinet.include.sys]ioctl.h"
518 #define TCP_INCLUDES_DONE
519 /*
520 * Uncomment this if you get compiler messages
521 * about struct timeval having no linkage. - FM
522 */
523 /*#define NO_TIMEVAL*/
524 #ifdef NO_TIMEVAL
525 struct timeval {
526 long tv_sec; /* seconds since Jan. 1, 1970 */
527 long tv_usec; /* microseconds */
528 };
529 #endif /* NO_TIMEVAL */
530 #endif /* MULTINET */
531
532 #ifdef DECNET
533 #include <types.h>
534 #include <errno.h>
535 #include <time.h>
536 #include <types.h> /* for socket.h */
537 #include <socket.h>
538 #include <dn>
539 #include <dnetdb>
540 /* #include "vms.h" */
541 #define TCP_INCLUDES_DONE
542 #endif /* DECNET */
543
544 #ifdef UCX
545 #include <types.h>
546 #include <errno.h>
547 #include <time.h>
548 #include <socket.h>
549 #include <in.h>
550 #include <inet.h>
551 #if defined(TCPWARE) && !defined(__DECC)
552 #include "tcpware_include:netdb.h"
553 #include "tcpware_include:ucx$inetdef.h"
554 #else
555 #include <netdb.h>
556 #ifdef MUCX
557 #include <multinet_root:[multinet.include.vms]ucx$inetdef.h>
558 #else
559 #include <ucx$inetdef.h>
560 #endif /* MUCX */
561 #endif /* TCPWARE */
562 #define TCP_INCLUDES_DONE
563 #endif /* UCX */
564
565 #ifdef CMU_TCP
566 #include <types.h>
567 #include <errno.h>
568 #include "cmuip_root:[syslib]time.h"
569 #include "cmuip_root:[syslib]socket.h"
570 #include <in.h>
571 #include <inet.h>
572 #include <netdb.h>
573 #include "cmuip_root:[syslib]ioctl.h"
574 #define TCP_INCLUDES_DONE
575 #endif /* CMU_TCP */
576
577 #ifdef SOCKETSHR_TCP
578 #include <types.h>
579 #include <errno.h>
580 #include <time.h>
581 #include <socket.h>
582 #include <in.h>
583 #include <inet.h>
584 #include <netdb.h>
585 #include "socketshr_library:socketshr.h"
586 #include "socketshr_library:ioctl.h"
587 #define TCP_INCLUDES_DONE
588 #endif /* SOCKETSHR_TCP */
589
590 #ifdef TCPIP_SERVICES
591 #include <types.h>
592 #include <errno.h>
593 #include <time.h>
594 #include <ioctl.h>
595 #include <socket.h>
596 #include <in.h>
597 #include <inet.h>
598 #include <netdb.h>
599 #define TCP_INCLUDES_DONE
600 #endif /* TCPIP_SERVICES */
601
602 #ifdef WIN_TCP
603 #include <types.h>
604 #include <errno.h>
605 #include <time.h>
606 #include <socket.h>
607 #include <in.h>
608 #include <inet.h>
609 #include <netdb.h>
610 #ifndef NO_IOCTL
611 #include <ioctl.h>
612 #endif /* !NO_IOCTL */
613 #define TCP_INCLUDES_DONE
614 #endif /* WIN_TCP */
615
616 #ifndef TCP_INCLUDES_DONE
617 #include <types.h>
618 #include <errno.h>
619 #include <time.h>
620 #ifdef VMS_SOCKET_HEADERS
621 /*
622 * Not all versions of VMS have the full set of headers
623 * for socket library functions, because the TCP/IP
624 * packages were layered products. If we want these
625 * specifically, instead of those for the above packages,
626 * the module should be compiled with VMS_SOCKET_HEADERS
627 * defined instead of layered product definitions, above.
628 * If the module is not using socket library functions,
629 * none of the definitions need be used, and we include
630 * only the above three headers. - FM
631 */
632 #include <socket.h>
633 #include <in.h>
634 #include <inet.h>
635 #include <netdb.h>
636 #include <ioctl.h>
637 #endif /* VMS_SOCKET_HEADERS */
638 #define TCP_INCLUDES_DONE
639 #endif /* !TCP_INCLUDES_DONE */
640
641 /*
642 * On VMS machines, the linker needs to be told to put global data sections
643 * into a data segment using these storage classes. (MarkDonszelmann)
644 */
645 #if defined(VAXC) && !defined(__DECC)
646 #define GLOBALDEF globaldef
647 #define GLOBALREF globalref
648 #else
649 #ifdef __GNUC__ /* this added by Sterling Bjorndahl */
650 #define GLOBALREF_IS_MACRO 1
651 #define GLOBALDEF_IS_MACRO 1
652 #include <gnu_hacks.h> /* defines GLOBALREF and GLOBALDEF for GNUC on VMS */
653 #endif /* __GNUC__ */
654 #endif /* VAXC && !DECC */
655
656 #include <perror.h>
657 #ifndef errno
658 extern int errno;
659 #endif /* !errno */
660
661 #endif /* VMS */
662
663 /*
664 * On non-VMS machines and for DECC on VMS, the GLOBALDEF and GLOBALREF
665 * storage types default to normal C storage types.
666 */
667 #ifndef GLOBALREF
668 #define GLOBALDEF
669 #define GLOBALREF extern
670 #endif /* !GLOBALREF */
671
672 #ifdef __DJGPP__
673 #undef SELECT
674 #define TCP_INCLUDES_DONE
675 #undef IOCTL
676 #define IOCTL(s,cmd,arg) ioctlsocket(s,cmd,(char*)(arg))
677 #define DECL_ERRNO
678 #include <errno.h>
679 #include <sys/types.h>
680 #include <io.h>
681 #include <sys/ioctl.h>
682 #include <sys/socket.h>
683 #include <arpa/inet.h>
684 #include <tcp.h>
685 #ifdef word
686 #undef word
687 #endif /* word */
688 #ifdef set_timeout
689 #undef set_timeout
690 #endif /* set_timeout */
691 #define select select_s
692
693 #undef NETWRITE
694 #define NETWRITE write_s
695 #undef NETREAD
696 #define NETREAD read_s
697 #undef NETCLOSE
698 #define NETCLOSE close_s
699 #ifdef UNIX
700 #undef UNIX
701 #endif /* UNIX */
702 #ifdef HAVE_GETTEXT
703 #define gettext gettext__
704 #endif
705 #if !defined(NCURSES) && !defined(USE_SLANG)
706 #define HAVE_CBREAK 1
707 #endif /* !NCURSES && !USE_SLANG */
708 #if defined(USE_SLANG) && !defined(NO_DJ_KEYHANDLER) && defined(HAVE_CONFIG_H)
709 #define DJGPP_KEYHANDLER
710 #endif /* USE_SLANG && !NO_DJ_KEYHANDLER && HAVE_CONFIG_H */
711 #endif /* DJGPP */
712
713 #ifdef HAVE_UNISTD_H
714 #include <unistd.h>
715 #endif /* HAVE_UNISTD_H */
716
717 #ifdef HAVE_SYS_FILIO_H
718 #include <sys/filio.h>
719 #endif /* HAVE_SYS_FILIO_H */
720
721 #if !defined(HAVE_LSTAT) && !defined(lstat)
722 #define lstat(path,block) stat(path,block)
723 #endif
724
725 #if defined(DECL_ERRNO) && !defined(errno)
726 extern int errno;
727 #endif /* DECL_ERRNO */
728
729 /*
730 Regular BSD unix versions
731 =========================
732 These are a default unix where not already defined specifically.
733 */
734 #ifndef INCLUDES_DONE
735 #include <sys/types.h>
736 #ifdef HAVE_STRING_H
737 #include <string.h>
738 #endif /* HAVE_STRING_H */
739 #include <errno.h> /* independent */
740 #ifdef __MVS__ /* S/390 -- gil -- 1361 */
741 #include <time.h>
742 #endif /* __MVS__ */
743 #ifdef SCO
744 #include <sys/timeb.h>
745 #include <time.h>
746 #endif /* SCO */
747 #if defined(AIX) || defined(SVR4)
748 #include <time.h>
749 #endif /* AIX || SVR4 */
750 #include <sys/time.h> /* independent */
751 #include <sys/stat.h>
752 #ifndef __MVS__ /* S/390 -- gil -- 1373 */
753 #include <sys/param.h>
754 #endif /* __MVS__ */
755 #include <sys/file.h> /* For open() etc */
756
757 #if defined(NeXT) || defined(sony_news)
758 #ifndef mode_t
759 typedef unsigned short mode_t;
760 #endif /* !mode_t */
761
762 #endif /* NeXT || sony_news */
763
764 #define INCLUDES_DONE
765 #endif /* Normal includes */
766
767 /* FIXME: this should be autoconf'd */
768 /* Interactive UNIX for i386 and i486 -- Thanks to [email protected] */
769 #ifdef ISC
770 #include <net/errno.h>
771 #include <sys/types.h>
772 #include <sys/tty.h>
773 #include <sys/sioctl.h>
774 #include <sys/bsdtypes.h>
775 #ifndef MERGE
776 #define MERGE
777 #include <sys/pty.h>
778 #undef MERGE
779 #else
780 #include <sys/pty.h>
781 #endif /* !MERGE */
782 #ifndef USE_DIRENT
783 #define USE_DIRENT /* sys V style directory open */
784 #endif /* USE_DIRENT */
785 #include <sys/dirent.h>
786 #endif /* ISC */
787
788 /* Directory reading stuff - BSD or SYS V
789 */
790 #ifdef HAVE_CONFIG_H
791
792 # ifdef HAVE_LIMITS_H
793 # include <limits.h>
794 # endif /* HAVE_LIMITS_H */
795 # if !defined(MAXINT) && defined(INT_MAX)
796 # define MAXINT INT_MAX
797 # endif /* !MAXINT && INT_MAX */
798
799 #else
800
801 #if !(defined(VM) || defined(VMS) || defined(THINK_C) || defined(PCNFS) || defined(_WINDOWS))
802 #define DECL_SYS_ERRLIST 1
803 #endif
804
805 #if defined(VMS)
806 #define socklen_t unsigned
807 #elif defined(_WINDOWS)
808 #define socklen_t int /* used for default LY_SOCKLEN definition */
809 #endif
810
811 #endif /* !HAVE_CONFIG_H */
812
813 #ifdef HAVE_LIBINTL_H
814 #include <libintl.h>
815 #endif
816
817 #define N_(s) s
818
819 #ifndef HAVE_GETTEXT
820 #define gettext(s) s
821 #endif
822
823 #ifndef NLS_TEXTDOMAIN
824 #define NLS_TEXTDOMAIN "lynx"
825 #endif
826
827 /*
828 Defaults
829 ========
830 INCLUDE FILES FOR TCP
831 */
832 #ifndef TCP_INCLUDES_DONE
833 #ifndef NO_IOCTL
834 #include <sys/ioctl.h> /* EJB */
835 #endif /* !NO_IOCTL */
836 #include <sys/socket.h>
837 #include <netinet/in.h>
838 #ifdef HAVE_ARPA_INET_H
839 #include <arpa/inet.h> /* Must be after netinet/in.h */
840 #endif
841 #include <netdb.h>
842 #endif /* TCP includes */
843
844 typedef unsigned short PortNumber;
845
846 #ifndef S_ISLNK
847 #define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
848 #endif /* S_ISLNK */
849
850 #ifndef S_ISDIR
851 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
852 #endif /* S_ISDIR */
853
854 #ifndef S_ISREG
855 #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
856 #endif /* S_ISREG */
857
858 #ifndef S_ISUID
859 #define S_ISUID 0004000
860 #endif
861 #ifndef S_ISGID
862 #define S_ISGID 0002000
863 #endif
864 #ifndef S_ISVTX
865 #define S_ISVTX 0001000
866 #endif
867
868 #ifndef S_IRWXU
869 #define S_IRWXU 00700
870 #endif
871
872 #ifndef S_IRUSR
873 #define S_IRUSR 00400
874 #endif
875 #ifndef S_IWUSR
876 #define S_IWUSR 00200
877 #endif
878 #ifndef S_IXUSR
879 #define S_IXUSR 00100
880 #endif
881
882 #ifndef S_IRWXG
883 #define S_IRWXG 00070
884 #endif
885
886 #ifndef S_IRGRP
887 #define S_IRGRP 00040
888 #endif
889 #ifndef S_IWGRP
890 #define S_IWGRP 00020
891 #endif
892 #ifndef S_IXGRP
893 #define S_IXGRP 00010
894 #endif
895
896 #ifndef S_IRWXO
897 #define S_IRWXO 00007
898 #endif
899
900 #ifndef S_IROTH
901 #define S_IROTH 00004
902 #endif
903 #ifndef S_IWOTH
904 #define S_IWOTH 00002
905 #endif
906 #ifndef S_IXOTH
907 #define S_IXOTH 00001
908 #endif
909
910 /*
911
912 ROUGH ESTIMATE OF MAX PATH LENGTH
913
914 */
915 #ifndef HT_MAX_PATH
916 #ifdef MAXPATHLEN
917 #define HT_MAX_PATH MAXPATHLEN
918 #else
919 #ifdef PATH_MAX
920 #define HT_MAX_PATH PATH_MAX
921 #else
922 #define HT_MAX_PATH 1024 /* Any better ideas? */
923 #endif
924 #endif
925 #endif /* HT_MAX_PATH */
926
927 #if HT_MAX_PATH < 256
928 #undef HT_MAX_PATH
929 #define HT_MAX_PATH 256
930 #endif
931
932 /*
933 MACROS FOR MANIPULATING MASKS FOR SELECT()
934 */
935 #ifdef SELECT
936 #ifndef FD_SET
937 #ifndef TYPE_FD_SET
938 #define TYPE_FD_SET unsigned
939 typedef TYPE_FD_SET fd_set;
940 #endif /* !TYPE_FD_SET */
941
942 #define FD_SET(fd,pmask) (*(pmask)) |= (1 << (fd))
943 #define FD_CLR(fd,pmask) (*(pmask)) &= ~(1 << (fd))
944 #define FD_ZERO(pmask) (*(pmask)) = 0
945 #define FD_ISSET(fd,pmask) (*(pmask) & (1 << (fd)))
946 #endif /* !FD_SET */
947 #endif /* SELECT */
948
949 /*
950 * Macro for setting errno - only define this if you really can do it.
951 */
952 #if defined(CAN_SET_ERRNO) || (!defined(errno) && (!defined(VMS) || defined(UCX)))
953 #define set_errno(value) errno = value
954 #else
955 #define set_errno(value) /* we do not know how */
956 #endif
957
958 /*
959 * IPv6 support
960 */
961 #if defined(HAVE_GETADDRINFO) && defined(ENABLE_IPV6)
962 #if defined(HAVE_GAI_STRERROR)
963 #define INET6
964 #elif defined(_WINDOWS)
965 #define INET6
966 #ifndef WIN_EX
967 #error Define "WIN_EX" in your makefile.
968 #endif
969 #ifndef _MSC_VER /* MSVC has this inlined in <ws2tcpip.h> */
970 #undef gai_strerror
971 #define gai_strerror(err) w32_strerror (err)
972 #endif
973 #endif
974 #endif /* HAVE_GETADDRINFO && ENABLE_IPV6 */
975
976 typedef union {
977 struct sockaddr_in soc_in;
978 struct sockaddr soc_address;
979 #ifdef INET6
980 struct sockaddr_storage soc_storage;
981 #endif
982 } LY_SOCKADDR;
983
984 #ifdef INET6
985 typedef struct sockaddr_storage SockA;
986
987 #define SOCKADDR_OF(param) (&((param).soc_address))
988
989 #ifndef SA_LEN
990 #ifdef SOCKADDR_LEN_INET
991 #define SA_LEN(x) (((x)->sa_family == AF_INET6) \
992 ? sizeof(struct sockaddr_in6) \
993 : sizeof(struct sockaddr_in))
994 #else
995 #define SA_LEN(x) (((x)->sa_family == AF_INET6) \
996 ? sizeof(struct sockaddr_in6) \
997 : (((x)->sa_family == AF_INET) \
998 ? sizeof(struct sockaddr_in) \
999 : sizeof(struct sockaddr))) /* AF_UNSPEC? */
1000 #endif
1001 #endif
1002
1003 #ifdef SIN6_LEN
1004 #define SOCKADDR_LEN(param) (SOCKADDR_OF(param)->sa_len)
1005 #else
1006 #define SOCKADDR_LEN(param) (socklen_t) SA_LEN(SOCKADDR_OF(param))
1007 #endif /* SIN6_LEN */
1008 #else
1009 typedef struct sockaddr_in SockA;
1010
1011 #define SOCKADDR_OF(param) ((struct sockaddr *)&(param))
1012 #define SOCKADDR_LEN(param) sizeof(param)
1013 #endif /* INET6 */
1014
1015 #ifndef MAXHOSTNAMELEN
1016 #define MAXHOSTNAMELEN 128 /* Max label is 63. Should handle 2 of those */
1017 #endif /* MAXHOSTNAMELEN */
1018
1019 #endif /* TCP_H */