1 /* System dependencies in the W3 library 2 * $LynxId: www_tcp.h,v 1.54 2013/07/20 14:08:29 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, <timbl@info.cern.ch> 15 EvA Eelco van Asperen <evas@cs.few.eur.nl> 16 MA Marc Andreessen NCSA 17 AT Aleksandar Totic <atotic@ncsa.uiuc.edu> 18 SCW Susan C. Weber <sweber@kyle.eitech.com> 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 <sweber@kyle.eitech.com>. 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 #endif /* WINDOWS */ 317 318 /* 319 320 VAX/VMS 321 322 Under VMS, there are many versions of TCP-IP. Define one if you do 323 not use Digital's UCX product: 324 325 UCX DEC's "Ultrix connection" (default) 326 CMU_TCP Available via FTP from sacusr.mp.usbr.gov 327 SOCKETSHR Eckhart Meyer's interface to NETLIB 328 WIN_TCP From Wollongong, now GEC software. 329 MULTINET From SRI, became TGV, then Cisco. 330 DECNET Cern's TCP socket emulation over DECnet 331 TCPIP_SERVICES TCP/IP Services (newer than UCX) 332 333 WIN_TCP, MULTINET and DECNET do not interfere with the 334 unix i/o library, and so they need special calls to read, write and 335 close sockets. In these cases the socket number is a VMS channel 336 number, so we make the @@@ HORRIBLE @@@ assumption that a channel 337 number will be greater than 10 but a unix file descriptor less than 338 10. It works. 339 340 */ 341 #ifdef VMS 342 343 #ifdef UCX 344 #undef IOCTL 345 #define IOCTL(s,cmd,arg) HTioctl(s,cmd,arg) 346 #endif /* UCX */ 347 348 #ifdef WIN_TCP 349 #undef SOCKET_READ 350 #undef NETWRITE 351 #undef NETCLOSE 352 #define SOCKET_READ(s,b,l) ((s)>10 ? netread((s),(b),(l)) : read((s),(b),(l))) 353 #define NETWRITE(s,b,l) ((s)>10 ? netwrite((s),(b),(l)) : write((s),(b),(l))) 354 #define NETCLOSE(s) ((s)>10 ? netclose(s) : close(s)) 355 #undef IOCTL 356 #define IOCTL(a,b,c) -1 /* disables ioctl function */ 357 #define NO_IOCTL /* flag to check if ioctl is disabled */ 358 #endif /* WIN_TCP */ 359 360 #ifdef CMU_TCP 361 #undef SOCKET_READ 362 #undef NETREAD 363 #undef NETWRITE 364 #undef NETCLOSE 365 #define SOCKET_READ(s,b,l) (cmu_get_sdc((s)) != 0 ? cmu_read((s),(b),(l)) : read((s),(b),(l))) 366 #define NETREAD(s,b,l) (cmu_get_sdc((s)) != 0 ? HTDoRead((s),(b),(l)) : read((s),(b),(l))) 367 #define NETWRITE(s,b,l) (cmu_get_sdc((s)) != 0 ? cmu_write((s),(b),(l)) : write((s),(b),(l))) 368 #define NETCLOSE(s) (cmu_get_sdc((s)) != 0 ? cmu_close((s)) : close((s))) 369 #endif /* CMU_TCP */ 370 371 #ifdef MULTINET 372 #undef NETCLOSE 373 #undef SOCKET_READ 374 #undef NETWRITE 375 #undef IOCTL 376 #undef SOCKET_ERRNO 377 /* 378 * Delete these socket_foo() prototypes as MultiNet adds them 379 * to its socket library headers. Compiler warnings due to 380 * the absence of arguments in the generic prototypes here will 381 * include the names of those which can be deleted. - FM 382 */ 383 extern int socket_read(); 384 extern int socket_write(); 385 extern int socket_close(); 386 extern int socket_ioctl(); 387 388 #define SOCKET_READ(s,b,l) ((s)>10 ? socket_read((s),(b),(l)) : \ 389 read((s),(b),(l))) 390 #define NETWRITE(s,b,l) ((s)>10 ? socket_write((s),(b),(l)) : \ 391 write((s),(b),(l))) 392 #define NETCLOSE(s) ((s)>10 ? socket_close(s) : close(s)) 393 #define IOCTL(s,cmd,arg) socket_ioctl(s,cmd,arg) 394 #define SOCKET_ERRNO socket_errno 395 #endif /* MULTINET */ 396 397 #ifdef SOCKETSHR_TCP 398 #undef SOCKET_READ 399 #undef NETREAD 400 #undef NETWRITE 401 #undef NETCLOSE 402 #undef IOCTL 403 #define SOCKET_READ(s,b,l) (si_get_sdc((s)) != 0 ? si_read((s),(b),(l)) : \ 404 read((s),(b),(l))) 405 #define NETREAD(s,b,l) (si_get_sdc((s)) != 0 ? HTDoRead((s),(b),(l)) : \ 406 read((s),(b),(l))) 407 #define NETWRITE(s,b,l) (si_get_sdc((s)) != 0 ? si_write((s),(b),(l)) : \ 408 write((s),(b),(l))) 409 #define NETCLOSE(s) (si_get_sdc((s)) != 0 ? si_close((s)) : close((s))) 410 #define IOCTL(s,cmd,arg) si_ioctl(s,cmd,arg) 411 #endif /* SOCKETSHR_TCP */ 412 413 #ifdef TCPIP_SERVICES 414 /* 415 * TCPIP Services has all of the entrypoints including ioctl(). 416 */ 417 #undef NETWRITE 418 #define NETWRITE(s,b,l) send((s),(char *)(b),(l),0) 419 420 #define TYPE_FD_SET int 421 422 #if 0 /* this should be declared via time.h */ 423 typedef TYPE_FD_SET fd_set; 424 #endif 425 426 #endif /* TCPIP_SERVICES */ 427 428 #include <string.h> 429 430 #include <file.h> 431 #include <stat.h> 432 #include <unixio.h> 433 #include <unixlib.h> 434 435 #define INCLUDES_DONE 436 437 #ifdef MULTINET /* Include from standard Multinet directories */ 438 /* 439 * Delete any of these multinet_foo() and associated prototypes 440 * as MultiNet adds them to its socket library headers. You'll 441 * get compiler warnings about them, due the absence of arguments 442 * in the generic prototyping here, and the warnings will include 443 * the names of the functions whose prototype entries can be 444 * deleted here. - FM 445 */ 446 extern int multinet_accept(); 447 extern int multinet_bind(); 448 extern int multinet_connect(); 449 extern int multinet_gethostname(); 450 extern int multinet_getsockname(); 451 extern unsigned short multinet_htons(unsigned short __val); 452 extern unsigned short multinet_ntohs(unsigned short __val); 453 extern int multinet_listen(); 454 extern int multinet_select(); 455 extern int multinet_socket(); 456 extern char *vms_errno_string(); 457 458 #ifndef __SOCKET_TYPEDEFS 459 #define __SOCKET_TYPEDEFS 1 460 #endif /* !__SOCKET_TYPEDEFS */ 461 462 #include <time.h> 463 #include <types.h> 464 /* 465 * DEC C before version 5.2 added some typedefs to <types.h> which happen 466 * to be suppressed if the version-4 compatibility define is set. In 467 * particular, lynx uses "off_t". VAX-C used "unsigned", DEC-C uses "int". 468 */ 469 #if defined(_DECC_V4_SOURCE) && !defined(____OFF_T) 470 #undef off_t 471 #define off_t int 472 #endif 473 474 #ifdef __TIME_T 475 #undef __TYPES 476 #define __TYPES 1 477 #define __TYPES_LOADED 1 478 #endif /* __TIME_T */ 479 480 #ifdef __SOCKET_TYPEDEFS 481 #undef __SOCKET_TYPEDEFS 482 #endif /* __SOCKET_TYPEDEFS */ 483 484 #include "multinet_root:[multinet.include.sys]types.h" 485 486 #ifndef __SOCKET_TYPEDEFS 487 #define __SOCKET_TYPEDEFS 1 488 #endif /* !__SOCKET_TYPEDEFS */ 489 490 #include "multinet_root:[multinet.include]errno.h" 491 492 #ifdef __TYPES 493 #undef __TIME_T 494 #define __TIME_T 1 495 #endif /* __TYPE */ 496 497 #ifdef __TIME_LOADED 498 #undef __TIME 499 #define __TIME 1 /* to avoid double definitions in in.h */ 500 #endif /* __TIME_LOADED */ 501 502 #include "multinet_root:[multinet.include.sys]time.h" 503 504 #define MULTINET_NO_PROTOTYPES /* DECC is compatible-but-different */ 505 #include "multinet_root:[multinet.include.sys]socket.h" 506 #undef MULTINET_NO_PROTOTYPES 507 #include "multinet_root:[multinet.include.netinet]in.h" 508 #include "multinet_root:[multinet.include.arpa]inet.h" 509 #include "multinet_root:[multinet.include]netdb.h" 510 #include "multinet_root:[multinet.include.sys]ioctl.h" 511 #define TCP_INCLUDES_DONE 512 /* 513 * Uncomment this if you get compiler messages 514 * about struct timeval having no linkage. - FM 515 */ 516 /*#define NO_TIMEVAL*/ 517 #ifdef NO_TIMEVAL 518 struct timeval { 519 long tv_sec; /* seconds since Jan. 1, 1970 */ 520 long tv_usec; /* microseconds */ 521 }; 522 #endif /* NO_TIMEVAL */ 523 #endif /* MULTINET */ 524 525 #ifdef DECNET 526 #include <types.h> 527 #include <errno.h> 528 #include <time.h> 529 #include <types.h> /* for socket.h */ 530 #include <socket.h> 531 #include <dn> 532 #include <dnetdb> 533 /* #include "vms.h" */ 534 #define TCP_INCLUDES_DONE 535 #endif /* DECNET */ 536 537 #ifdef UCX 538 #include <types.h> 539 #include <errno.h> 540 #include <time.h> 541 #include <socket.h> 542 #include <in.h> 543 #include <inet.h> 544 #if defined(TCPWARE) && !defined(__DECC) 545 #include "tcpware_include:netdb.h" 546 #include "tcpware_include:ucx$inetdef.h" 547 #else 548 #include <netdb.h> 549 #ifdef MUCX 550 #include <multinet_root:[multinet.include.vms]ucx$inetdef.h> 551 #else 552 #include <ucx$inetdef.h> 553 #endif /* MUCX */ 554 #endif /* TCPWARE */ 555 #define TCP_INCLUDES_DONE 556 #endif /* UCX */ 557 558 #ifdef CMU_TCP 559 #include <types.h> 560 #include <errno.h> 561 #include "cmuip_root:[syslib]time.h" 562 #include "cmuip_root:[syslib]socket.h" 563 #include <in.h> 564 #include <inet.h> 565 #include <netdb.h> 566 #include "cmuip_root:[syslib]ioctl.h" 567 #define TCP_INCLUDES_DONE 568 #endif /* CMU_TCP */ 569 570 #ifdef SOCKETSHR_TCP 571 #include <types.h> 572 #include <errno.h> 573 #include <time.h> 574 #include <socket.h> 575 #include <in.h> 576 #include <inet.h> 577 #include <netdb.h> 578 #include "socketshr_library:socketshr.h" 579 #include "socketshr_library:ioctl.h" 580 #define TCP_INCLUDES_DONE 581 #endif /* SOCKETSHR_TCP */ 582 583 #ifdef TCPIP_SERVICES 584 #include <types.h> 585 #include <errno.h> 586 #include <time.h> 587 #include <ioctl.h> 588 #include <socket.h> 589 #include <in.h> 590 #include <inet.h> 591 #include <netdb.h> 592 #define TCP_INCLUDES_DONE 593 #endif /* TCPIP_SERVICES */ 594 595 #ifdef WIN_TCP 596 #include <types.h> 597 #include <errno.h> 598 #include <time.h> 599 #include <socket.h> 600 #include <in.h> 601 #include <inet.h> 602 #include <netdb.h> 603 #ifndef NO_IOCTL 604 #include <ioctl.h> 605 #endif /* !NO_IOCTL */ 606 #define TCP_INCLUDES_DONE 607 #endif /* WIN_TCP */ 608 609 #ifndef TCP_INCLUDES_DONE 610 #include <types.h> 611 #include <errno.h> 612 #include <time.h> 613 #ifdef VMS_SOCKET_HEADERS 614 /* 615 * Not all versions of VMS have the full set of headers 616 * for socket library functions, because the TCP/IP 617 * packages were layered products. If we want these 618 * specifically, instead of those for the above packages, 619 * the module should be compiled with VMS_SOCKET_HEADERS 620 * defined instead of layered product definitions, above. 621 * If the module is not using socket library functions, 622 * none of the definitions need be used, and we include 623 * only the above three headers. - FM 624 */ 625 #include <socket.h> 626 #include <in.h> 627 #include <inet.h> 628 #include <netdb.h> 629 #include <ioctl.h> 630 #endif /* VMS_SOCKET_HEADERS */ 631 #define TCP_INCLUDES_DONE 632 #endif /* !TCP_INCLUDES_DONE */ 633 634 /* 635 * On VMS machines, the linker needs to be told to put global data sections 636 * into a data segment using these storage classes. (MarkDonszelmann) 637 */ 638 #if defined(VAXC) && !defined(__DECC) 639 #define GLOBALDEF globaldef 640 #define GLOBALREF globalref 641 #else 642 #ifdef __GNUC__ /* this added by Sterling Bjorndahl */ 643 #define GLOBALREF_IS_MACRO 1 644 #define GLOBALDEF_IS_MACRO 1 645 #include <gnu_hacks.h> /* defines GLOBALREF and GLOBALDEF for GNUC on VMS */ 646 #endif /* __GNUC__ */ 647 #endif /* VAXC && !DECC */ 648 649 #include <perror.h> 650 #ifndef errno 651 extern int errno; 652 #endif /* !errno */ 653 654 #endif /* VMS */ 655 656 /* 657 * On non-VMS machines and for DECC on VMS, the GLOBALDEF and GLOBALREF 658 * storage types default to normal C storage types. 659 */ 660 #ifndef GLOBALREF 661 #define GLOBALDEF 662 #define GLOBALREF extern 663 #endif /* !GLOBALREF */ 664 665 #ifdef __DJGPP__ 666 #undef SELECT 667 #define TCP_INCLUDES_DONE 668 #undef IOCTL 669 #define IOCTL(s,cmd,arg) ioctlsocket(s,cmd,(char*)(arg)) 670 #define DECL_ERRNO 671 #include <errno.h> 672 #include <sys/types.h> 673 #include <io.h> 674 #include <sys/ioctl.h> 675 #include <sys/socket.h> 676 #include <arpa/inet.h> 677 #include <tcp.h> 678 #ifdef word 679 #undef word 680 #endif /* word */ 681 #ifdef set_timeout 682 #undef set_timeout 683 #endif /* set_timeout */ 684 #define select select_s 685 686 #undef NETWRITE 687 #define NETWRITE write_s 688 #undef NETREAD 689 #define NETREAD read_s 690 #undef NETCLOSE 691 #define NETCLOSE close_s 692 #ifdef UNIX 693 #undef UNIX 694 #endif /* UNIX */ 695 #ifdef HAVE_GETTEXT 696 #define gettext gettext__ 697 #endif 698 #if !defined(NCURSES) && !defined(USE_SLANG) 699 #define HAVE_CBREAK 1 700 #endif /* !NCURSES && !USE_SLANG */ 701 #if defined(USE_SLANG) && !defined(NO_DJ_KEYHANDLER) && defined(HAVE_CONFIG_H) 702 #define DJGPP_KEYHANDLER 703 #endif /* USE_SLANG && !NO_DJ_KEYHANDLER && HAVE_CONFIG_H */ 704 #endif /* DJGPP */ 705 706 #ifdef HAVE_UNISTD_H 707 #include <unistd.h> 708 #endif /* HAVE_UNISTD_H */ 709 710 #ifdef HAVE_SYS_FILIO_H 711 #include <sys/filio.h> 712 #endif /* HAVE_SYS_FILIO_H */ 713 714 #if !defined(HAVE_LSTAT) && !defined(lstat) 715 #define lstat(path,block) stat(path,block) 716 #endif 717 718 #if defined(DECL_ERRNO) && !defined(errno) 719 extern int errno; 720 #endif /* DECL_ERRNO */ 721 722 /* 723 Regular BSD unix versions 724 ========================= 725 These are a default unix where not already defined specifically. 726 */ 727 #ifndef INCLUDES_DONE 728 #include <sys/types.h> 729 #ifdef HAVE_STRING_H 730 #include <string.h> 731 #endif /* HAVE_STRING_H */ 732 #include <errno.h> /* independent */ 733 #ifdef __MVS__ /* S/390 -- gil -- 1361 */ 734 #include <time.h> 735 #endif /* __MVS__ */ 736 #ifdef SCO 737 #include <sys/timeb.h> 738 #include <time.h> 739 #endif /* SCO */ 740 #if defined(AIX) || defined(SVR4) 741 #include <time.h> 742 #endif /* AIX || SVR4 */ 743 #include <sys/time.h> /* independent */ 744 #include <sys/stat.h> 745 #ifndef __MVS__ /* S/390 -- gil -- 1373 */ 746 #include <sys/param.h> 747 #endif /* __MVS__ */ 748 #include <sys/file.h> /* For open() etc */ 749 750 #if defined(NeXT) || defined(sony_news) 751 #ifndef mode_t 752 typedef unsigned short mode_t; 753 #endif /* !mode_t */ 754 755 #endif /* NeXT || sony_news */ 756 757 #define INCLUDES_DONE 758 #endif /* Normal includes */ 759 760 /* FIXME: this should be autoconf'd */ 761 /* Interactive UNIX for i386 and i486 -- Thanks to jeffrey@itm.itm.org */ 762 #ifdef ISC 763 #include <net/errno.h> 764 #include <sys/types.h> 765 #include <sys/tty.h> 766 #include <sys/sioctl.h> 767 #include <sys/bsdtypes.h> 768 #ifndef MERGE 769 #define MERGE 770 #include <sys/pty.h> 771 #undef MERGE 772 #else 773 #include <sys/pty.h> 774 #endif /* !MERGE */ 775 #ifndef USE_DIRENT 776 #define USE_DIRENT /* sys V style directory open */ 777 #endif /* USE_DIRENT */ 778 #include <sys/dirent.h> 779 #endif /* ISC */ 780 781 /* Directory reading stuff - BSD or SYS V 782 */ 783 #ifdef HAVE_CONFIG_H 784 785 # ifdef HAVE_LIMITS_H 786 # include <limits.h> 787 # endif /* HAVE_LIMITS_H */ 788 # if !defined(MAXINT) && defined(INT_MAX) 789 # define MAXINT INT_MAX 790 # endif /* !MAXINT && INT_MAX */ 791 792 #else 793 794 #if !(defined(VM) || defined(VMS) || defined(THINK_C) || defined(PCNFS) || defined(_WINDOWS)) 795 #define DECL_SYS_ERRLIST 1 796 #endif 797 798 #if defined(VMS) 799 #define socklen_t unsigned 800 #else 801 #define socklen_t int /* used for default LY_SOCKLEN definition */ 802 #endif 803 804 #endif /* !HAVE_CONFIG_H */ 805 806 #ifdef HAVE_LIBINTL_H 807 #include <libintl.h> 808 #endif 809 810 #ifdef HAVE_LIBGETTEXT_H 811 #include <libgettext.h> 812 #endif 813 814 #define N_(s) s 815 816 #ifndef HAVE_GETTEXT 817 #define gettext(s) s 818 #endif 819 820 #ifndef NLS_TEXTDOMAIN 821 #define NLS_TEXTDOMAIN "lynx" 822 #endif 823 824 /* 825 Defaults 826 ======== 827 INCLUDE FILES FOR TCP 828 */ 829 #ifndef TCP_INCLUDES_DONE 830 #ifndef NO_IOCTL 831 #include <sys/ioctl.h> /* EJB */ 832 #endif /* !NO_IOCTL */ 833 #include <sys/socket.h> 834 #include <netinet/in.h> 835 #ifdef HAVE_ARPA_INET_H 836 #include <arpa/inet.h> /* Must be after netinet/in.h */ 837 #endif 838 #include <netdb.h> 839 #endif /* TCP includes */ 840 841 typedef unsigned short PortNumber; 842 843 #ifndef S_ISLNK 844 #define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) 845 #endif /* S_ISLNK */ 846 847 #ifndef S_ISDIR 848 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) 849 #endif /* S_ISDIR */ 850 851 #ifndef S_ISREG 852 #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) 853 #endif /* S_ISREG */ 854 855 #ifndef S_ISUID 856 #define S_ISUID 0004000 857 #endif 858 #ifndef S_ISGID 859 #define S_ISGID 0002000 860 #endif 861 #ifndef S_ISVTX 862 #define S_ISVTX 0001000 863 #endif 864 865 #ifndef S_IRWXU 866 #define S_IRWXU 00700 867 #endif 868 869 #ifndef S_IRUSR 870 #define S_IRUSR 00400 871 #endif 872 #ifndef S_IWUSR 873 #define S_IWUSR 00200 874 #endif 875 #ifndef S_IXUSR 876 #define S_IXUSR 00100 877 #endif 878 879 #ifndef S_IRWXG 880 #define S_IRWXG 00070 881 #endif 882 883 #ifndef S_IRGRP 884 #define S_IRGRP 00040 885 #endif 886 #ifndef S_IWGRP 887 #define S_IWGRP 00020 888 #endif 889 #ifndef S_IXGRP 890 #define S_IXGRP 00010 891 #endif 892 893 #ifndef S_IRWXO 894 #define S_IRWXO 00007 895 #endif 896 897 #ifndef S_IROTH 898 #define S_IROTH 00004 899 #endif 900 #ifndef S_IWOTH 901 #define S_IWOTH 00002 902 #endif 903 #ifndef S_IXOTH 904 #define S_IXOTH 00001 905 #endif 906 907 /* 908 909 ROUGH ESTIMATE OF MAX PATH LENGTH 910 911 */ 912 #ifndef HT_MAX_PATH 913 #ifdef MAXPATHLEN 914 #define HT_MAX_PATH MAXPATHLEN 915 #else 916 #ifdef PATH_MAX 917 #define HT_MAX_PATH PATH_MAX 918 #else 919 #define HT_MAX_PATH 1024 /* Any better ideas? */ 920 #endif 921 #endif 922 #endif /* HT_MAX_PATH */ 923 924 #if HT_MAX_PATH < 256 925 #undef HT_MAX_PATH 926 #define HT_MAX_PATH 256 927 #endif 928 929 /* 930 MACROS FOR MANIPULATING MASKS FOR SELECT() 931 */ 932 #ifdef SELECT 933 #ifndef FD_SET 934 #ifndef TYPE_FD_SET 935 #define TYPE_FD_SET unsigned 936 typedef TYPE_FD_SET fd_set; 937 #endif /* !TYPE_FD_SET */ 938 939 #define FD_SET(fd,pmask) (*(pmask)) |= (1 << (fd)) 940 #define FD_CLR(fd,pmask) (*(pmask)) &= ~(1 << (fd)) 941 #define FD_ZERO(pmask) (*(pmask)) = 0 942 #define FD_ISSET(fd,pmask) (*(pmask) & (1 << (fd))) 943 #endif /* !FD_SET */ 944 #endif /* SELECT */ 945 946 /* 947 * Macro for setting errno - only define this if you really can do it. 948 */ 949 #if defined(CAN_SET_ERRNO) || (!defined(errno) && (!defined(VMS) || defined(UCX))) 950 #define set_errno(value) errno = value 951 #else 952 #define set_errno(value) /* we do not know how */ 953 #endif 954 955 /* 956 * IPv6 support 957 */ 958 #if defined(HAVE_GETADDRINFO) && defined(ENABLE_IPV6) 959 #if defined(HAVE_GAI_STRERROR) 960 #define INET6 961 #elif defined(_WINDOWS) 962 #define INET6 963 #ifndef WIN_EX 964 #error Define "WIN_EX" in your makefile. 965 #endif 966 #ifndef _MSC_VER /* MSVC has this inlined in <ws2tcpip.h> */ 967 #undef gai_strerror 968 #define gai_strerror(err) w32_strerror (err) 969 #endif 970 #endif 971 #endif /* HAVE_GETADDRINFO && ENABLE_IPV6 */ 972 973 #ifdef INET6 974 typedef struct sockaddr_storage SockA; 975 976 #ifdef SIN6_LEN 977 #define SOCKADDR_LEN(soc_address) (((struct sockaddr *)&soc_address)->sa_len) 978 #else 979 #ifndef SA_LEN 980 #define SA_LEN(x) (((x)->sa_family == AF_INET6) \ 981 ? sizeof(struct sockaddr_in6) \ 982 : (((x)->sa_family == AF_INET) \ 983 ? sizeof(struct sockaddr_in) \ 984 : sizeof(struct sockaddr))) /* AF_UNSPEC? */ 985 #endif 986 #define SOCKADDR_LEN(soc_address) (socklen_t) (SA_LEN((struct sockaddr *)&soc_address)) 987 #endif /* SIN6_LEN */ 988 #else 989 typedef struct sockaddr_in SockA; 990 991 #define SOCKADDR_LEN(soc_address) sizeof(soc_address) 992 #endif /* INET6 */ 993 994 #ifndef MAXHOSTNAMELEN 995 #define MAXHOSTNAMELEN 128 /* Max label is 63. Should handle 2 of those */ 996 #endif /* MAXHOSTNAMELEN */ 997 998 #endif /* TCP_H */ 999