home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Tools / lynx-2.4 / WWW / Library / Implementation / tcp.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-28  |  11.2 KB  |  462 lines

  1. /*                System dependencies in the W3 library
  2.                                    SYSTEM DEPENDENCIES
  3.                                              
  4.    System-system differences for TCP include files and macros. This
  5.    file includes for each system the files necessary for network and
  6.    file I/O.
  7.    
  8.   AUTHORS
  9.   
  10.   TBL                Tim Berners-Lee, W3 project, CERN, <timbl@info.cern.ch>
  11.   EvA                     Eelco van Asperen <evas@cs.few.eur.nl>
  12.   MA                      Marc Andreessen NCSA
  13.   AT                      Aleksandar Totic <atotic@ncsa.uiuc.edu>
  14.   SCW                     Susan C. Weber <sweber@kyle.eitech.com>
  15.                          
  16.   HISTORY:
  17.   22 Feb 91               Written (TBL) as part of the WWW library.
  18.   16 Jan 92               PC code from EvA
  19.   22 Apr 93               Merged diffs bits from xmosaic release
  20.   29 Apr 93               Windows/NT code from SCW
  21.   20 May 94          A.Harper Add support for VMS CMU TCP/IP transport
  22.    3 Oct 94          A.Harper Add support for VMS SOCKETSHR/NETLIB
  23.  
  24.   Much of the cross-system portability stuff has been intentionally
  25.   REMOVED from this version of the library by Marc A in order to
  26.   discourage attempts to make "easy" ports of Mosaic for X to non-Unix
  27.   platforms.  The library needs to be rewritten from the ground up; in
  28.   the meantime, Unix is *all* we support or intend to support with
  29.   this set of source code.
  30.  
  31. */
  32.  
  33. #ifndef TCP_H
  34. #define TCP_H
  35.  
  36. #ifndef HTUTILS_H
  37. #include "HTUtils.h"
  38. #endif
  39.  
  40. /*
  41.  
  42. Default values
  43.  
  44.    These values may be reset and altered by system-specific sections
  45.    later on.  there are also a bunch of defaults at the end .
  46.    
  47.  */
  48. /* Default values of those: */
  49. #define NETCLOSE close      /* Routine to close a TCP-IP socket         */
  50. #define NETREAD  HTDoRead       /* Routine to read from a TCP-IP socket     */
  51. #define NETWRITE write      /* Routine to write to a TCP-IP socket      */
  52. #define SOCKET_READ read    /* normal socket read routine */
  53. #define IOCTL ioctl        /* normal ioctl routine for sockets */
  54. #define SOCKET_ERRNO errno        /* normal socket errno */
  55.  
  56. /* Unless stated otherwise, */
  57. #define SELECT                  /* Can handle >1 channel.               */
  58. #define GOT_SYSTEM              /* Can call shell with string           */
  59.  
  60. #ifdef unix
  61. #define GOT_PIPE
  62. #endif
  63.  
  64. typedef struct sockaddr_in SockA;  /* See netinet/in.h */
  65.  
  66.  
  67. #ifndef STDIO_H
  68. #include <stdio.h>
  69. #define STDIO_H
  70. #endif
  71.  
  72. #ifdef _AIX
  73. #define AIX
  74. #endif
  75. #ifdef AIX
  76. #define unix
  77. #endif
  78.  
  79. #ifdef _IBMR2
  80. #define USE_DIRENT              /* sys V style directory open */
  81. #endif
  82.  
  83. /* Solaris. */
  84. #if defined(sun) && defined(__svr4__) && !defined(USE_DIRENT)
  85. #define USE_DIRENT              /* sys V style directory open */
  86. #endif
  87.  
  88. #if defined(__alpha)
  89. #define USE_DIRENT
  90. #endif
  91.  
  92. #ifndef USE_DIRENT
  93. #ifdef SVR4
  94. #define USE_DIRENT
  95. #endif
  96. #endif /* not USE_DIRENT */
  97.  
  98. #ifndef SOLARIS2
  99. #include <string.h>             /* For bzero etc */
  100. #endif /* SOLARIS2 */
  101.  
  102. /* Use builtin strdup when appropriate. */
  103. #if defined(ultrix) || defined(VMS) || defined(NeXT)
  104. extern char *strdup ();
  105. #endif
  106.  
  107. /*
  108.  
  109.   M ACROS FOR CONVERTING CHARACTERS
  110.  
  111.  */
  112. #ifndef TOASCII
  113. #define TOASCII(c) (c)
  114. #define FROMASCII(c) (c)
  115. #endif
  116.  
  117.  
  118. /*
  119.  
  120. VAX/VMS
  121.  
  122.    Under VMS, there are many versions of TCP-IP. Define one if you do
  123.    not use Digital's UCX product:
  124.    
  125.   UCX                     DEC's "Ultrix connection" (default)
  126.   CMU_TCP                 Available via FTP from sacusr.mp.usbr.gov
  127.   SOCKETSHR          Eckhart Meyer's interface to NETLIB
  128.   WIN_TCP                 From Wollongong, now GEC software.
  129.   MULTINET                From SRI, now from TGV Inv.
  130.   DECNET                  Cern's TCP socket emulation over DECnet
  131.                            
  132.    The last three do not interfere with the
  133.    unix i/o library, and so they need special calls to read, write and
  134.    close sockets. In these cases the socket number is a VMS channel
  135.    number, so we make the @@@ HORRIBLE @@@ assumption that a channel
  136.    number will be greater than 10 but a unix file descriptor less than
  137.    10.  It works.
  138.    
  139.  */
  140. #ifdef VMS 
  141.  
  142. #ifdef WIN_TCP
  143. #undef SOCKET_READ
  144. #undef NETWRITE
  145. #undef NETCLOSE
  146. #undef IOCTL
  147. #define SOCKET_READ(s,b,l)  ((s)>10 ? netread((s),(b),(l)) : read((s),(b),(l)))
  148. #define NETWRITE(s,b,l) ((s)>10 ? netwrite((s),(b),(l)) : write((s),(b),(l)))
  149. #define NETCLOSE(s)     ((s)>10 ? netclose(s) : close(s))
  150. #define IOCTL(a,b,c) -1 /* disables ioctl function          */
  151. #define NO_IOCTL    /* flag to check if ioctl is disabled */
  152. #endif /* WIN_TCP */
  153.  
  154. #ifdef CMU_TCP
  155. #undef SOCKET_READ
  156. #undef NETREAD
  157. #undef NETWRITE
  158. #undef NETCLOSE
  159. #define SOCKET_READ(s,b,l) (cmu_get_sdc((s)) != 0 ? cmu_read((s),(b),(l)) : read((s),(b),(l)))
  160. #define NETREAD(s,b,l) (cmu_get_sdc((s)) != 0 ? HTDoRead((s),(b),(l)) : read((s),(b),(l)))
  161. #define NETWRITE(s,b,l) (cmu_get_sdc((s)) != 0 ? cmu_write((s),(b),(l)) : write((s),(b),(l)))
  162. #define NETCLOSE(s) (cmu_get_sdc((s)) != 0 ? cmu_close((s)) : close((s)))
  163. #endif /* CMU_TCP */
  164.  
  165. #ifdef MULTINET
  166. #undef NETCLOSE
  167. #undef SOCKET_READ
  168. #undef NETWRITE
  169. #undef IOCTL
  170. #undef SOCKET_ERRNO
  171. #define SOCKET_READ(s,b,l)  ((s)>10 ? socket_read((s),(b),(l)) : \
  172.                 read((s),(b),(l)))
  173. #define NETWRITE(s,b,l) ((s)>10 ? socket_write((s),(b),(l)) : \
  174.                                 write((s),(b),(l)))
  175. #define NETCLOSE(s)     ((s)>10 ? socket_close(s) : close(s))
  176. #define IOCTL socket_ioctl
  177. #define SOCKET_ERRNO socket_errno
  178. #endif /* MULTINET */
  179.  
  180. #ifdef SOCKETSHR_TCP
  181. #undef SOCKET_READ
  182. #undef NETREAD
  183. #undef NETWRITE
  184. #undef NETCLOSE
  185. #undef IOCTL
  186. #define SOCKET_READ(s,b,l) (si_get_sdc((s)) != 0 ? si_read((s),(b),(l)) : \
  187.                                 read((s),(b),(l)))
  188. #define NETREAD(s,b,l) (si_get_sdc((s)) != 0 ? HTDoRead((s),(b),(l)) : \
  189.                                 read((s),(b),(l)))
  190. #define NETWRITE(s,b,l) (si_get_sdc((s)) != 0 ? si_write((s),(b),(l)) : \
  191.                                 write((s),(b),(l)))
  192. #define NETCLOSE(s) (si_get_sdc((s)) != 0 ? si_close((s)) : close((s)))
  193. #define IOCTL si_ioctl
  194. #endif /* SOCKETSHR_TCP */
  195.  
  196. #include <string.h>
  197.  
  198. #ifndef STDIO_H
  199. #include <stdio.h>
  200. #define STDIO_H
  201. #endif
  202.  
  203. #include <file.h>
  204. #include <stat.h>
  205. #include <unixio.h>
  206.  
  207. #define INCLUDES_DONE
  208.  
  209. #ifdef MULTINET  /* Include from standard Multinet directories */
  210. #include <time.h>
  211. #ifdef __TIME_T
  212. #define __TYPES 1
  213. #define __TYPES_LOADED 1
  214. #endif /* __TIME_T */
  215. #include "multinet_root:[multinet.include.sys]types.h"
  216. #include "multinet_root:[multinet.include]errno.h"
  217. #ifdef __TYPES
  218. #define __TIME_T 1
  219. #endif /* __TYPE */
  220. #ifdef __TIME_LOADED
  221. #define __TIME 1  /* to avoid double definitions in in.h */
  222. #endif /* __TIME_LOADED */
  223. #include "multinet_root:[multinet.include.sys]time.h"
  224. #include "multinet_root:[multinet.include.sys]socket.h"
  225. #include "multinet_root:[multinet.include.netinet]in.h"
  226. #include "multinet_root:[multinet.include.arpa]inet.h"
  227. #include "multinet_root:[multinet.include]netdb.h"
  228. #include "multinet_root:[multinet.include.sys]ioctl.h"
  229. #endif /* MULTINET */
  230.  
  231.  
  232. #ifdef DECNET
  233. #include <types.h>
  234. #include <errno.h>
  235. #include <time.h>
  236. #include "types.h"  /* for socket.h */
  237. #include "socket.h"
  238. #include "dn"
  239. #include "dnetdb"
  240. /* #include "vms.h" */
  241. #endif /* DECNET */
  242.  
  243.  
  244. #ifdef UCX
  245. #include <types.h>
  246. #include <errno.h>
  247. #include <time.h>
  248. #include <socket.h>
  249. #include <in.h>
  250. #include <inet.h>
  251. #ifdef TCPWARE
  252. #include "tcpware_include:netdb.h"
  253. #include "tcpware_include:ucx$inetdef.h"
  254. #else
  255. #include <netdb.h>
  256. #include <ucx$inetdef.h>
  257. #endif /* TCPWARE */
  258. #define bcopy(s, d, n) memcpy((d), (s), (n))
  259. #endif /* UCX */
  260.  
  261.  
  262. #ifdef CMU_TCP
  263. #include <types.h>
  264. #include <errno.h>
  265. #include "cmuip_root:[syslib]time.h"
  266. #include "cmuip_root:[syslib]socket.h"
  267. #include <in.h>
  268. #include <inet.h>
  269. #include <netdb.h>
  270. #include "cmuip_root:[syslib]ioctl.h"
  271. #define bcopy(s, d, n) memcpy((d), (s), (n))
  272. #endif /* CMU_TCP */
  273.  
  274.  
  275. #ifdef SOCKETSHR_TCP
  276. #include <types.h>
  277. #include <errno.h>
  278. #include <time.h>
  279. #include <socket.h>
  280. #include <in.h>
  281. #include <inet.h>
  282. #include <netdb.h>
  283. #include "socketshr_library:socketshr.h"
  284. #include "socketshr_library:ioctl.h"
  285. #define bcopy(s, d, n) memcpy((d), (s), (n))
  286. #endif /* SOCKETSHR_TCP */
  287.  
  288. #ifdef WIN_TCP
  289. #include <types.h>
  290. #include <errno.h>
  291. #include <time.h>
  292. #include <socket.h>
  293. #include <in.h>
  294. #include <inet.h>
  295. #include <netdb.h>
  296. #ifndef NO_IOCTL
  297. #include <ioctl.h>
  298. #endif /* !NO_IOCTL */
  299. #endif /* WIN_TCP */
  300.  
  301.  
  302. #define TCP_INCLUDES_DONE
  303.  
  304. /*
  305.  
  306.    On VMS machines, the linker needs to be told to put global data sections into
  307.  a data
  308.    segment using these storage classes. (MarkDonszelmann)
  309.   
  310.  */
  311. #if defined(VAXC) && !defined(__DECC)
  312. #define GLOBALDEF globaldef
  313. #define GLOBALREF globalref
  314. #endif /*  VAXC && !_DECC */
  315.  
  316. #endif  /* VMS */
  317.  
  318. /*
  319.  * On non-VMS machines, the GLOBALDEF and GLOBALREF storage types default 
  320.  * to normal C storage types.
  321.  */
  322. #ifndef GLOBALREF
  323. #define GLOBALDEF
  324. #define GLOBALREF extern
  325. #endif /* !GLOBALREF */
  326.  
  327.  
  328. /*
  329.  
  330. SCO ODT unix version
  331.  
  332.  */
  333. #ifdef SCO
  334. #define sco
  335. #endif
  336.  
  337. #ifdef sco
  338. #include <sys/fcntl.h>
  339. #define USE_DIRENT
  340. #endif
  341.  
  342. #if defined(SVR4) || defined(UNIXWARE)
  343. #include <sys/fcntl.h>
  344. #ifndef NO_FILIO_H    /* BSD Interactive doesn't have filio.h. */
  345. #include <sys/filio.h>
  346. #endif /* !NO_FILIO_H */
  347. #endif /* SVR4 || UNIXWARE */
  348.  
  349. /*
  350. SOLARIS 2
  351. */
  352.  
  353. #ifdef SOLARIS2
  354. #include <sys/filio.h>
  355. #endif
  356.  
  357. /*
  358.  
  359. MIPS unix
  360.  
  361.  */
  362. /* Mips hack (bsd4.3/sysV mixture...) */
  363.  
  364. #ifdef mips
  365. extern int errno;
  366. #endif
  367.  
  368.  
  369. /*
  370.  
  371. Regular BSD unix versions
  372.  
  373.    These are a default unix where not already defined specifically.
  374.    
  375.  */
  376. #ifndef INCLUDES_DONE
  377. #include <sys/types.h>
  378. /* #include <streams/streams.h>                 not ultrix */
  379. #ifndef SOLARIS2
  380. #include <string.h>
  381. #endif /* SOLARIS2 */
  382.  
  383. #include <errno.h>          /* independent */
  384. #include <sys/time.h>       /* independent */
  385. #include <sys/stat.h>
  386. #include <sys/param.h>
  387. #include <sys/file.h>       /* For open() etc */
  388. #define INCLUDES_DONE
  389. #endif  /* Normal includes */
  390.  
  391. /* Interactive UNIX for i386 and i486 -- Thanks to jeffrey@itm.itm.org */
  392. #ifdef ISC
  393. #include <net/errno.h>
  394. #include <sys/types.h>
  395. #include <sys/tty.h>
  396. #include <sys/sioctl.h>
  397. #include <sys/bsdtypes.h>
  398. #include <sys/fcntl.h>
  399. #include <sys/pty.h>
  400. #ifndef USE_DIRENT
  401. #define USE_DIRENT    /* sys V style directory open */
  402. #endif /* USE_DIRENT */
  403. #include <sys/dirent.h>
  404. #endif
  405.  
  406. /*                      Directory reading stuff - BSD or SYS V
  407. */
  408. #if defined(UNIX) && !defined(unix)
  409. #define unix
  410. #endif
  411.  
  412. #ifdef unix                    /* if this is to compile on a UNIX machine */
  413. #define GOT_READ_DIR 1    /* if directory reading functions are available */
  414. #ifdef USE_DIRENT             /* sys v version */
  415. #include <dirent.h>
  416. #define direct dirent
  417. #else
  418. #include <sys/dir.h>
  419. #endif
  420. #if defined(sun) && defined(__svr4__)
  421. #include <sys/fcntl.h>
  422. #include <limits.h>
  423. #endif
  424. #endif
  425.  
  426. /*
  427.  
  428. Defaults
  429.  
  430.   INCLUDE FILES FOR TCP
  431.   
  432.  */
  433. #ifndef TCP_INCLUDES_DONE
  434. #ifndef NO_IOCTL
  435. #include <sys/ioctl.h> /* EJB */
  436. #endif
  437. #include <sys/socket.h>
  438. #include <netinet/in.h>
  439. #ifndef __hpux /* this may or may not be good -marc */
  440. #include <arpa/inet.h>      /* Must be after netinet/in.h */
  441. #endif
  442. #include <netdb.h>
  443. #endif  /* TCP includes */
  444.  
  445.  
  446. /*
  447.  
  448.   MACROS FOR MANIPULATING MASKS FOR SELECT()
  449.   
  450.  */
  451. #ifdef SELECT
  452. #ifndef FD_SET
  453. typedef unsigned int fd_set;
  454. #define FD_SET(fd,pmask) (*(pmask)) |=  (1<<(fd))
  455. #define FD_CLR(fd,pmask) (*(pmask)) &= ~(1<<(fd))
  456. #define FD_ZERO(pmask)   (*(pmask))=0
  457. #define FD_ISSET(fd,pmask) (*(pmask) & (1<<(fd)))
  458. #endif  /* FD_SET */
  459. #endif  /* SELECT */
  460.  
  461. #endif /* TCP_H */
  462.