tcp.h
上传用户:zlh9724
上传日期:2007-01-04
资源大小:1991k
文件大小:30k
源码类别:

浏览器

开发平台:

Unix_Linux

  1. /*                                                      System dependencies in the W3 library
  2.                                    SYSTEM DEPENDENCIES
  3.                                              
  4.  */
  5. /*
  6. **      (c) COPYRIGHT MIT 1995.
  7. **      Please first read the full copyright statement in the file COPYRIGH.
  8. */
  9. /*
  10.    System-system differences for TCP include files and macros. This file includes for each
  11.    system the files necessary for network and file I/O.
  12.    
  13.    This module is a part of the W3C Reference Library.
  14.    
  15.   AUTHORS
  16.   
  17.   TBL                     Tim Berners-Lee, W3 project, CERN, <timbl@w3.org>
  18.                          
  19.   EvA                     Eelco van Asperen <evas@cs.few.eur.nl>
  20.                          
  21.   MA                      Marc Andreesen NCSA
  22.                          
  23.   MD                      Mark Donszelmann <duns@vxcern.cern.ch>
  24.                          
  25.   AT                      Aleksandar Totic <atotic@ncsa.uiuc.edu>
  26.                          
  27.   SCW                     Susan C. Weber <sweber@kyle.eitech.com>
  28.                          
  29.   HF                      Henrik Frystyk, <frystyk@w3.org>
  30.                          
  31.   CLB                     Charlie Brooks, <cbrooks@osf.org>
  32.                          
  33.   HISTORY:
  34.   
  35.   22 Feb 91               Written (TBL) as part of the WWW library.
  36.                          
  37.   16 Jan 92               PC code from (EvA)
  38.                          
  39.   22 Apr 93              Merged diffs bits from xmosaic release
  40.                          
  41.   29 Apr 93              Windows/NT code from (SCW)
  42.                          
  43.   29 Sep 93              Mar 96 CLB - changed SLEEP() macro for Windows/NT MSC compiler
  44.                          added BOOLEAN_DEFINED macro to avoid duplicate definitions in
  45.                          HUtils.h  changed netread() macros to support reading from
  46.                          stdin,etc. as well  as sockets. (Required for linemode browser to
  47.                          work).
  48.                          
  49.  */
  50. #ifndef TCP_H
  51. #define TCP_H
  52. /*
  53. Default values
  54.    These values may be reset and altered by system-specific sections later on. There is
  55.    also a bunch of defaults at the end and a section for ordinary BSD unix versions.
  56.    
  57.  */
  58. #define SELECT                  /* Can handle >1 channel */
  59. #define GOT_SYSTEM              /* Can call shell with string */
  60. #define GOT_PASSWD              /* Can we use getpass() command */
  61. #define TTY_IS_SELECTABLE       /* TTY can be passed to select() call */
  62. /*
  63.    If you want to use reentrant functions, for example gmtime_r then enable this flag
  64.    
  65.  */
  66. #if 0
  67. #define HT_REENTRANT
  68. #endif
  69. /*
  70.    
  71.    ___________________________________
  72.    
  73.                                  PLATFORM SPECIFIC STUFF
  74.                                              
  75.    Information below this line is specific for most platforms. See also General Stuff
  76.    
  77. Macintosh - Metrowerks Codewarrior 6
  78.    Metrowerks Codewarrior is one development environment on the Mac. We are using GUSI
  79.    (1.5.9) by Matthias Neeracher <neeri@iis.ee.ethz.ch> for our socket lib. You can find
  80.    more information about the GUSI Library at
  81.    http://err.ethz.ch/members/neeri/macintosh/gusiman/GUSI.html
  82.    
  83.        Compiles on PPC. Should compile on 68K.
  84.    
  85.        August 31, 1995 by Steven T. Roussey <sroussey@eng.uci.edu> (STR)
  86.    
  87.  */
  88. #ifdef __MWERKS__
  89. #include <gusi.h>
  90. #include <dirent.h>
  91. #include <errno.h>
  92. #include <sys/errno.h>
  93. #include <sioux.h>
  94. #define INCLUDES_DONE
  95. #define TCP_INCLUDES_DONE
  96. #define GUSI                    /* Identifies changes made for GUSI */
  97. #define NO_GETDOMAINNAME        /* STR */
  98. #define NO_PASSWD               /* STR */
  99. #define NO_GETWD
  100. #define HAS_GETCWD
  101. #define USE_DIRENT
  102. #define NO_GROUPS
  103. #define GOT_READ_DIR
  104. #define NO_TIMEZONE             /* STR */
  105. #define NO_GMTOFF
  106. #define HAVE_STRERROR
  107. #define STRUCT_DIRENT   struct dirent
  108. #define d_ino           d_fileno        /* backward compatibility */
  109. #define SLEEP(n)        GUSIDefaultSpin( SP_SLEEP, n/60)
  110. #define MKDIR(a,b)      mkdir(a)
  111. #endif
  112. /*
  113. Macintosh - MPW
  114.    MPW is one development environment on the Mac.
  115.    
  116.    This entry was created by Aleksandar Totic (atotic@ncsa.uiuc.edu) this file is
  117.    compatible with sockets package released by NCSA.  One major conflict is that this
  118.    library redefines write/read/etc as macros.  In some of HTML code these macros get
  119.    executed when they should not be. Such files should define NO_SOCKET_DEFS on top. This
  120.    is a temporary hack.
  121.    
  122.  */
  123. #ifdef applec                   /* MPW  */
  124. #undef GOT_SYSTEM
  125. #define DEBUG                   /* Can't put it on the CC command line */
  126. #define NO_UNIX_IO              /* getuid() missing */
  127. #define NO_GETPID               /* getpid() does not exist */
  128. #define NO_GETWD                /* getwd() does not exist */
  129. #define NETCLOSE s_close    /* Routine to close a TCP-IP socket */
  130. #define NETREAD  s_read     /* Routine to read from a TCP-IP socket */
  131. #define NETWRITE s_write    /* Routine to write to a TCP-IP socket */
  132. #define _ANSI_SOURCE
  133. #define GUI
  134. #define LINEFEED 10
  135. #define ANON_FTP_HOSTNAME
  136. #ifndef NO_SOCKET_DEFS
  137. #include <MacSockDefs.h>
  138. #endif /* NO_SOCKET_DEFS */
  139. #include <socket.ext.h>
  140. #include <string.h>
  141. #endif /* applec MPW */
  142. #ifdef __QNX__
  143. #define FD_SETSIZE 128 /* run-time specifiable limit */
  144. #include <sys/select.h>
  145. #endif
  146. /*
  147. Big Blue - the world of incompatibility
  148.   IBM RS6000
  149.   
  150.    On the IBM RS-6000, AIX is almost Unix.
  151.    
  152.  */
  153. #ifdef _AIX
  154. #define AIX
  155. #endif
  156. #ifdef AIX
  157. #define NO_ALTZONE
  158. #define RLOGIN_USER
  159. #define unix
  160. #endif
  161. /*    AIX 3.2
  162. **    -------
  163. */
  164. #ifdef _IBMR2
  165. #define USE_DIRENT              /* sys V style directory open */
  166. #endif
  167. /*
  168.   IBM VM-CMS, VM-XA MAINFRAMES
  169.   
  170.    MVS is compiled as for VM. MVS has no unix-style I/O.  The command line compile options
  171.    seem to come across in lower case.
  172.    
  173.  */
  174. #ifdef mvs
  175. #define MVS
  176. #endif
  177. #ifdef MVS
  178. #define VM
  179. #endif
  180. #ifdef NEWLIB
  181. #pragma linkage(newlib,OS)      /* Enables recursive NEWLIB */
  182. #endif
  183. /*      VM doesn't have a built-in predefined token, so we cheat: */
  184. #ifndef VM
  185. #include <string.h>             /* For bzero etc - not  VM */
  186. #endif
  187. /*      Note:   All include file names must have 8 chars max (+".h")
  188. **
  189. **      Under VM, compile with "(DEF=VM,SHORT_NAMES,DEBUG)"
  190. **
  191. **      Under MVS, compile with "NOMAR DEF(MVS)" to get rid of 72 char margin
  192. **        System include files TCPIP and COMMMAC neeed line number removal(!)
  193. */
  194. #ifdef VM                       /* or MVS -- see above. */
  195. #define GOT_PIPE                /* Of sorts */
  196. #define NOT_ASCII               /* char type is not ASCII */
  197. #define NO_UNIX_IO              /* Unix I/O routines are not supported */
  198. #define NO_GETPID               /* getpid() does not exist */
  199. #define NO_GETWD                /* getwd() does not exist */
  200. #ifndef SHORT_NAMES
  201. #define SHORT_NAMES             /* 8 character uniqueness for globals */
  202. #endif
  203. #include <manifest.h>
  204. #include <bsdtypes.h>
  205. #include <stdefs.h>
  206. #include <socket.h>
  207. #include <in.h>
  208. #include <inet.h>
  209. #include <netdb.h>
  210. #include <errno.h>          /* independent */
  211. extern char asciitoebcdic[], ebcdictoascii[];
  212. #define TOASCII(c)   (c=='n' ?  10  : ebcdictoascii[c])
  213. #define FROMASCII(c) (c== 10  ? 'n' : asciitoebcdic[c])
  214. #include <bsdtime.h>
  215. #include <time.h>
  216. #include <string.h>
  217. #define INCLUDES_DONE
  218. #define TCP_INCLUDES_DONE
  219. #define SIMPLE_TELNET
  220. #endif
  221. /*
  222. IBM-PC running MS-DOS with SunNFS for TCP/IP
  223.    This code thanks to Eelco van Asperen <evas@cs.few.eur.nl>
  224.    
  225.  */
  226. #ifdef PCNFS
  227. #include <sys/types.h>
  228. #include <string.h>
  229. #include <errno.h>          /* independent */
  230. #include <sys/time.h>       /* independent */
  231. #include <sys/stat.h>
  232. #include <fcntl.h>          /* In place of sys/param and sys/file */
  233. #define INCLUDES_DONE
  234. #define FD_SET(fd,pmask) (*(unsigned*)(pmask)) |=  (1<<(fd))
  235. #define FD_CLR(fd,pmask) (*(unsigned*)(pmask)) &= ~(1<<(fd))
  236. #define FD_ZERO(pmask)   (*(unsigned*)(pmask))=0
  237. #define FD_ISSET(fd,pmask) (*(unsigned*)(pmask) & (1<<(fd)))
  238. #define NO_GROUPS
  239. #endif  /* PCNFS */
  240. /*
  241. PC running Windows (16-bit)
  242.    Help provided by Eric Prud'hommeaux, Susan C. Weber <sweber@kyle.eitech.com>, Paul
  243.    Hounslow <P.M.Hounslow@reading.ac.uk>, and a lot of other PC people.
  244.    
  245.  */
  246. #if defined(_WINDOWS) || defined(_CONSOLE)
  247. #define WWW_MSWINDOWS
  248. #endif
  249. #if defined(_WINDOWS) && !defined (_CONSOLE)
  250. #define WWW_WIN_WINDOW
  251. #endif
  252. #if defined(_CONSOLE)
  253. #define WWW_WIN_CONSOLE
  254. #endif
  255. #ifdef WWW_MSWINDOWS
  256. #include <windows.h>
  257. #include <fcntl.h>
  258. #include <systypes.h>
  259. #include <sysstat.h>
  260. #define NETREAD(s,b,l)  recv((s),(b),(l),0)
  261. #define NETWRITE(s,b,l) send((s),(b),(l),0)
  262. #define NETCLOSE(s)     closesocket(s)
  263. #define IOCTL(s,c,a)    ioctlsocket(s,c, (long *) a)
  264. #define MKDIR(a,b)      mkdir((a))
  265. #define REMOVE(a)       remove((a))
  266. #define DEFAULT_SUFFIXES        "."
  267. #ifdef TTY_IS_SELECTABLE
  268. #undef TTY_IS_SELECTABLE
  269. #endif
  270. #include <io.h>
  271. #include <string.h>
  272. #include <process.h>
  273. #include <time.h>
  274. #include <direct.h>
  275. #include <stdio.h>
  276. #include <stdlib.h>
  277. #include <winsock.h>
  278. #ifndef _CONSOLE
  279. #define NO_STDIO
  280. #endif
  281. #define NO_PASSWD
  282. #define NO_ALTZONE
  283. #define NO_GETWD
  284. #define NO_FCNTL
  285. #define HAS_GETCWD
  286. #define NO_GETPASSWD
  287. #define NO_GETDOMAINNAME
  288. #define NO_RESOLV_CONF
  289. #define BOOLEAN_DEFINED
  290. #define INCLUDES_DONE
  291. #define TCP_INCLUDES_DONE
  292. #define SOCKET SOCKET                   /* WinSocks socket descriptor */
  293. #define INVSOC INVALID_SOCKET           /* WinSocks invalid socket */
  294. #define DESIRED_WINSOCK_VERSION 0x0101  /* we'd like winsock ver 1.1... */
  295. #define MINIMUM_WINSOCK_VERSION 0x0101  /* ...but we'll take ver 1.1 :) */
  296. /*
  297.   FILE AND DIRECTORY ACCESS
  298.   
  299.    These next defintions are because the UNIX stuff is not supplied with BC4 (Paul
  300.    Hounslow
  301.    
  302.  */
  303. #define NO_UNIX_IO
  304. typedef unsigned long mode_t;
  305. #define _IFMT           0170000 /* type of file */
  306. #define _IFDIR          0040000 /* directory */
  307. #define _IFCHR          0020000 /* character special */
  308. #define _IFBLK          0060000 /* block special */
  309. #define _IFREG          0100000 /* regular */
  310. #define _IFLNK          0120000 /* symbolic link */
  311. #define _IFSOCK         0140000 /* socket */
  312. #define _IFIFO          0010000 /* fifo */
  313. #define S_ISUID         0004000 /* set user id on execution */
  314. #define S_ISGID         0002000 /* set group id on execution */
  315. #define S_ISVTX         0001000 /* save swapped text even after use */
  316. #ifdef S_IREAD
  317. #undef S_IREAD
  318. #define S_IREAD         0000400 /* read permission, owner */
  319. #endif
  320. #ifdef S_IWRITE
  321. #undef S_IWRITE
  322. #define S_IWRITE        0000200 /* write permission, owner */
  323. #endif
  324. #ifdef S_IEXEC
  325. #undef S_IEXEC
  326. #define S_IEXEC         0000100 /* execute/search permission, owner */
  327. #endif
  328. #define S_ENFMT         0002000 /* enforcement-mode locking */
  329. #ifdef S_IFMT
  330. #undef S_IFMT
  331. #define S_IFMT          _IFMT
  332. #endif
  333. #ifdef S_IDIR
  334. #undef S_IDIR
  335. #define S_IFDIR         _IFDIR
  336. #endif
  337. #ifdef S_IFCHR
  338. #undef S_IFCHR
  339. #define S_IFCHR         _IFCHR
  340. #endif
  341. #ifdef S_IBLK
  342. #undef S_IBLK
  343. #define S_IFBLK         _IFBLK
  344. #endif
  345. #ifdef S_IREG
  346. #undef S_IREG
  347. #define S_IFREG         _IFREG
  348. #endif
  349. #define S_IFLNK         _IFLNK
  350. #ifdef S_IFIFO
  351. #undef S_IFIFO
  352. #define S_IFIFO         _IFIFO
  353. #endif
  354. #define S_IRWXU         0000700 /* rwx, owner */
  355. #define         S_IRUSR 0000400 /* read permission, owner */
  356. #define         S_IWUSR 0000200 /* write permission, owner */
  357. #define         S_IXUSR 0000100 /* execute/search permission, owner */
  358. #define S_IRWXG         0000070 /* rwx, group */
  359. #define         S_IRGRP 0000040 /* read permission, group */
  360. #define         S_IWGRP 0000020 /* write permission, grougroup */
  361. #define         S_IXGRP 0000010 /* execute/search permission, group */
  362. #define S_IRWXO         0000007 /* rwx, other */
  363. #define         S_IROTH 0000004 /* read permission, other */
  364. #define         S_IWOTH 0000002 /* write permission, other */
  365. #define         S_IXOTH 0000001 /* execute/search permission, other */
  366. #define S_ISREG(m)      (((m)&_IFMT) == _IFREG)
  367. /*
  368.   ERRNO AND RETURN CODES
  369.   
  370.    Winsock has its own errno codes and it returns them through WSAGetLastError(). However,
  371.    it does also support BSD error codes, so we make a compromise. WSA definitions moved
  372.    from _WIN32 ifdef by EGP
  373.    
  374.  */
  375. #define socerrno WSAGetLastError()
  376. #define ERRNO_DONE
  377. /*
  378.    Return code for socket functions. We can't use -1 as return value
  379.    
  380.  */
  381. #define EWOULDBLOCK     WSAEWOULDBLOCK
  382. #define EINPROGRESS     WSAEINPROGRESS
  383. #define ECONNREFUSED    WSAECONNREFUSED
  384. #define ETIMEDOUT       WSAETIMEDOUT
  385. #define ENETUNREACH     WSAENETUNREACH
  386. #define EHOSTUNREACH    WSAEHOSTUNREACH
  387. #define EHOSTDOWN       WSAEHOSTDOWN
  388. #define EISCONN         WSAEISCONN
  389. /* Some compilers do only define WIN32 and NOT _WINDOWS */
  390. #define NO_GROUPS
  391. #ifdef _WIN32
  392. #define MKDIR(a,b)      mkdir((a))     /* CLB NT has mkdir, but only one arg */
  393. #define SLEEP(n)        Sleep((n)*1000)
  394. #else
  395. #define MKDIR(a,b)      _mkdir((a))    /* CLB NT has mkdir, but only one arg */
  396. #endif /* WIN32 */
  397. #endif /* WWW_MSWINDOWS */
  398. /*
  399. VAX/VMS
  400.    Under VMS, there are many versions of TCP-IP. Define one if you do not use Digital's
  401.    UCX product:
  402.    
  403.   UCX                     DEC's "Ultrix connection" (default)
  404.                          
  405.   WIN_TCP                 From Wollongong, now GEC software.
  406.                          
  407.   MULTINET                From SRI, now from TGV Inv.
  408.                          
  409.   DECNET                  Cern's TCP socket emulation over DECnet
  410.                          
  411.    The last three do not interfere with the unix i/o library, and so they need special
  412.    calls to read, write and close sockets. In these cases the socket number is a VMS
  413.    channel number, so we make the @@@ HORRIBLE @@@ assumption that a channel number will
  414.    be greater than 10 but a unix file descriptor less than 10.  It works.
  415.    
  416.  */
  417. #ifdef VMS
  418. #include "HTVMSUtils.h"
  419. #define CACHE_FILE_PREFIX       "SYS$LOGIN:Z_"
  420. #define DEFAULT_SUFFIXES        "._"
  421. #ifdef WIN_TCP
  422. #define NETREAD(s,b,l)  ((s)>10 ? netread((s),(b),(l)) : read((s),(b),(l)))
  423. #define NETWRITE(s,b,l) ((s)>10 ? netwrite((s),(b),(l)) : write((s),(b),(l)))
  424. #define NETCLOSE(s)     ((s)>10 ? netclose(s) : close(s))
  425. #endif /* WIN_TCP */
  426. #ifdef MULTINET
  427. #undef NETCLOSE
  428. #undef NETREAD
  429. #undef NETWRITE
  430. #define NETREAD(s,b,l)  ((s)>10 ? socket_read((s),(b),(l)) : read((s),(b),(l)))
  431. #define NETWRITE(s,b,l) ((s)>10 ? socket_write((s),(b),(l)) : 
  432.                                 write((s),(b),(l)))
  433. #define NETCLOSE(s)     ((s)>10 ? socket_close(s) : close(s))
  434. #define IOCTL(s,c,a)    socket_ioctl(s,c,a);
  435. #endif /* MULTINET */
  436. #ifdef DECNET
  437. #define DNP_OBJ 80      /* This one doesn't look busy, but we must check */
  438.                         /* That one was for decnet */
  439. #undef SELECT           /* not supported */
  440. #define NETREAD(s,b,l)  ((s)>10 ? recv((s),(b),(l),0) : read((s),(b),(l)))
  441. #define NETWRITE(s,b,l) ((s)>10 ? send((s),(b),(l),0) : write((s),(b),(l)))
  442. #define NETCLOSE(s)     ((s)>10 ? socket_close(s) : close(s))
  443. #define NO_GETHOSTNAME                  /* Decnet doesn't have a name server */
  444. #endif /* Decnet */
  445. #define NO_RESOLV_CONF
  446. #define NO_GETDOMAINNAME
  447. /*      Certainly this works for UCX and Multinet; not tried for Wollongong
  448. */
  449. #ifdef MULTINET
  450. #include <time.h>
  451. #ifdef __TIME_T
  452. #define __TYPES
  453. #define __TYPES_LOADED
  454. #endif /* __TIME_T */
  455. #include <multinet_root:[multinet.include.sys]types.h>
  456. #include <multinet_root:[multinet.include]errno.h>
  457. #ifdef __TYPES
  458. #define __TIME_T
  459. #endif /* __TYPE */
  460. #ifdef __TIME_LOADED
  461. #define __TIME
  462. #endif /* __TIME_LOADED */
  463. #include <multinet_root:[multinet.include.sys]time.h>
  464. #else /* not MULTINET */
  465. #include <types.h>
  466. #include <errno.h>
  467. #include <time.h>
  468. #endif /* not MULTINET */
  469. #include string
  470. #ifndef STDIO_H
  471. #include <stdio>
  472. #define STDIO_H
  473. #endif
  474. #include file
  475. #ifndef DECNET  /* Why is it used at all ? Types conflict with "types.h> */
  476. #include unixio
  477. #endif
  478. #define INCLUDES_DONE
  479. #ifdef MULTINET  /* Include from standard Multinet directories */
  480. #include <multinet_root:[multinet.include.sys]socket.h>
  481. #ifdef __TIME_LOADED  /* defined by sys$library:time.h */
  482. #define __TIME  /* to avoid double definitions in next file */
  483. #endif
  484. #include <multinet_root:[multinet.include.netinet]in.h>
  485. #include <multinet_root:[multinet.include.arpa]inet.h>
  486. #include <multinet_root:[multinet.include]netdb.h>
  487. #include <multinet_root:[multinet.include.sys]ioctl.h>
  488. #else  /* not multinet */
  489. #ifdef DECNET
  490. #include <types.h>  /* for socket.h */
  491. #include <socket.h>
  492. #include <dn>
  493. #include <dnetdb>
  494. #else /* UCX or WIN */
  495. #ifdef CADDR_T
  496. #define __CADDR_T
  497. #endif /* problem with xlib.h inclusion */
  498. #include <socket.h>
  499. #include <in.h>
  500. #include <inet.h>
  501. #include <netdb.h>
  502. #include <ucx$inetdef.h>
  503. #endif  /* not DECNET */
  504. #endif  /* of Multinet or other TCP includes */
  505. #define TCP_INCLUDES_DONE
  506. #ifdef UCX
  507. #define SIMPLE_TELNET
  508. #endif
  509. /*
  510.    On VMS directory browsing is available through a separate copy of dirent.c. The
  511.    definition of R_OK seem to be missing from the system include files...
  512.    
  513.  */
  514. #define USE_DIRENT
  515. #define GOT_READ_DIR
  516. #include <dirent.h>
  517. #define STRUCT_DIRENT struct dirent
  518. #define R_OK 4
  519. /*
  520.    On VMS machines, the linker needs to be told to put global data sections into a data
  521.    segment using these storage classes. (MarkDonszelmann)
  522.    
  523.  */
  524. #ifdef VAXC
  525. #define GLOBALDEF globaldef
  526. #define GLOBALREF globalref
  527. #endif /*  VAXC */
  528. #endif  /* vms */
  529. /*
  530.    On non-VMS machines, the GLOBALDEF and GLOBALREF storage types default to normal C
  531.    storage types.
  532.    
  533.  */
  534. #ifndef GLOBALREF
  535. #define GLOBALDEF
  536. #define GLOBALREF extern
  537. #endif
  538. /*
  539.    On non-VMS machines STAT should be stat...On VMS machines STAT is a function that
  540.    converts directories and devices so that you can stat them.
  541.    
  542.  */
  543. #ifdef VMS
  544. typedef unsigned long mode_t;
  545. #define HT_STAT         HTStat
  546. #define HT_LSTAT        HTStat
  547. #else
  548. #define HT_STAT         stat
  549. #define HT_LSTAT        lstat
  550. #endif /* non VMS */
  551. /*
  552.   STRFTIME AND OTHER TIME STUFF
  553.   
  554.  */
  555. #ifdef VMS
  556. #ifndef DECC
  557. #define NO_STRFTIME
  558. #endif
  559. #define NO_MKTIME
  560. #define NO_TIMEGM
  561. #define NO_GMTOFF
  562. #define NO_TIMEZONE
  563. #endif
  564. /*
  565.   DEFINITION OF ERRNO
  566.   
  567.  */
  568. #ifdef VMS
  569. #ifndef __DECC
  570. extern int uerrno;      /* Deposit of error info (as per errno.h) */
  571. extern volatile noshare int socket_errno; /* socket VMS error info
  572.                                           (used for translation of vmserrno) */
  573. extern volatile noshare int vmserrno;   /* Deposit of VMS error info */
  574. extern volatile noshare int errno;  /* noshare to avoid PSECT conflict */
  575. #define ERRNO_DONE
  576. #endif /* not DECC */
  577. #endif /* VMS */
  578. /*
  579. SCO ODT unix version
  580.    (by Brian King)
  581.    
  582.  */
  583. #ifdef sco
  584. #include <grp.h>
  585. #include <unistd.h>
  586. #include <sys/fcntl.h>
  587. #include <time.h>
  588. #define USE_DIRENT
  589. #define NEED_INITGROUPS
  590. #define NO_GETDOMAINNAME
  591. #endif
  592. /*
  593. BSDi BSD/386 Unix
  594.    Specific stuff for BSDi BSD/386
  595.    
  596.  */
  597. #ifdef bsdi
  598. #define NO_GETDOMAINNAME
  599. #endif
  600. /*
  601. MIPS unix
  602.    Mips hack (bsd4.3/sysV mixture...)
  603.    
  604.  */
  605. #ifdef Mips     /* Bruker */
  606. typedef mode_t          int;
  607. #define S_ENFMT         S_ISGID         /* record locking enforcement flag */
  608. #define S_ISCHR(m)      ((m) & S_IFCHR)
  609. #define S_ISBLK(m)      ((m) & S_IFBLK)
  610. #define S_ISDIR(m)      (((m)& S_IFMT) == S_IFDIR)
  611. #define S_ISREG(m)      (((m)& S_IFMT) == S_IFREG)
  612. #define WEXITSTATUS(s)  (((s).w_status >> 8) & 0377)
  613. #define NO_STRFTIME
  614. /* Mips can't uppercase non-alpha */
  615. #define TOLOWER(c) (isupper(c) ? tolower(c) : (c))
  616. #define TOUPPER(c) (islower(c) ? toupper(c) : (c))
  617. /*
  618.   FILE PERMISSIONS
  619.   
  620.  */
  621. #ifndef S_IRWXU
  622. #define S_IRWXU 0000700
  623. #define S_IRWXG 0000070
  624. #define S_IRWXO 0000007
  625. #define S_IRUSR 0000400
  626. #define S_IWUSR 0000200
  627. #define S_IXUSR 0000100
  628. #define S_IRGRP 0000040
  629. #define S_IWGRP 0000020
  630. #define S_IXGRP 0000010
  631. #define S_IROTH 0000004
  632. #define S_IWOTH 0000002
  633. #define S_IXOTH 0000001
  634. #endif /* S_IRWXU */
  635. #endif /* Mips */
  636. /*
  637. Linux
  638.    Linux support (thanks to Rainer Klute)
  639.    
  640.  */
  641. #ifdef linux
  642. #include <unistd.h>
  643. #include <limits.h>
  644. #include <sys/fcntl.h>
  645. #define NO_ALTZONE
  646. #define NO_GETWD
  647. #define HAS_GETCWD
  648. #define FULL_TELNET
  649. #endif /* linux */
  650. /*
  651. Solaris
  652.    Solaris and other SVR4 based systems
  653.    
  654.  */
  655. #if defined(__svr4__) || defined(_POSIX_SOURCE) || defined(__hpux) || defined(__sgi)
  656. #if defined(__hpux)
  657. #define NO_ALTZONE
  658. #endif
  659. #ifdef UTS4                                   /* UTS wants sys/types.h first */
  660. #include <sys/types.h>
  661. #endif
  662. #include <unistd.h>
  663. #ifdef UTS4
  664. #include <sys/fcntl.h>
  665. #define POSIXWAIT
  666. #endif
  667. #ifdef AIX                                                     /* Apple Unix */
  668. #include <fcntl.h>
  669. #else
  670. #include <sys/fcntl.h>
  671. #endif
  672. /*
  673.    This is for NCR 3000 and Pyramid that also are SVR4 systems. Thanks to Alex Podlecki,
  674.    <a.podlecki@att.com>
  675.    
  676.  */
  677. #ifndef NGROUPS_MAX
  678. #include <limits.h>
  679. #endif
  680. /* Pyramid and Mips can't uppercase non-alpha */
  681. #ifdef pyramid
  682. #define TOLOWER(c) (isupper(c) ? tolower(c) : (c))
  683. #define TOUPPER(c) (islower(c) ? toupper(c) : (c))
  684. #endif
  685. /*
  686.    getwd() is BSD. System V has getcwd()
  687.    
  688.  */
  689. #define NO_GETWD
  690. #define HAS_GETCWD
  691. #endif /* Solaris and SVR4 */
  692. /*
  693. UTS 2.1 (BSD-like)
  694.  */
  695. #ifdef UTS2
  696. #include <time.h>
  697. #include <fcntl.h>
  698. #ifndef R_OK
  699. #define R_OK 4
  700. #endif
  701. #define NO_STRFTIME
  702. #define WEXITSTATUS(x)  ((int)((x).w_T.w_Retcode))
  703. #undef POSIXWAIT
  704. #endif /* UTS2 */
  705. /*
  706. OSF/1
  707.  */
  708. #ifdef __osf__
  709. #define USE_DIRENT
  710. #define NO_TIMEZONE                                      /* OSF/1 has gmtoff */
  711. #endif /* OSF1 AXP */
  712. /*
  713. Ultrix Decstation
  714.  */
  715. #ifdef decstation
  716. #include <unistd.h>
  717. #define NO_TIMEZONE                                     /* Ultrix has gmtoff */
  718. #define RLOGIN_USER
  719. #endif
  720. /*
  721. ISC 3.0
  722.    by Lauren Weinstein <lauren@vortex.com>.
  723.    
  724.  */
  725. #ifdef ISC3                     /* Lauren */
  726. #define USE_DIRENT
  727. #define GOT_READ_DIR
  728. #include <sys/ipc.h>
  729. #include <sys/dirent.h>
  730. #define direct dirent
  731. #include <sys/unistd.h>
  732. #define d_namlen d_reclen
  733. #include <sys/limits.h>
  734. typedef int mode_t;
  735. #define SIGSTP
  736. #define POSIXWAIT
  737. #define _POSIX_SOURCE
  738. #include <sys/types.h>
  739. #include <sys/wait.h>
  740. #include <net/errno.h>
  741. #define _SYSV3
  742. #include <time.h>
  743. #include <sys/fcntl.h>
  744. #define S_ISDIR(m)      (((m) & 0170000) == 0040000)
  745. #define S_ISCHR(m)      (((m) & 0170000) == 0020000)
  746. #define S_ISBLK(m)      (((m) & 0170000) == 0060000)
  747. #define S_ISREG(m)      (((m) & 0170000) == 0100000)
  748. #define S_ISFIFO(m)     (((m) & 0170000) == 0010000)
  749. #define S_ISLNK(m)      (((m) & 0170000) == 0120000)
  750. #endif  /* ISC 3.0 */
  751. /*
  752. NeXT
  753.    Next has a lot of strange changes in constants...
  754.    
  755.  */
  756. #ifdef NeXT
  757. #include <sys/types.h>
  758. #include <sys/stat.h>
  759. typedef unsigned short mode_t;
  760. #ifndef S_ISDIR
  761. #define S_ISDIR(m)     (m & S_IFDIR)
  762. #define S_ISREG(m)     (m & S_IFREG)
  763. #define S_ISCHR(m)     (m & S_IFCHR)
  764. #define S_ISBLK(m)     (m & S_IFBLK)
  765. #define S_ISLNK(m)     (m & S_IFLNK)
  766. #define S_ISSOCK(m)    (m & S_IFSOCK)
  767. #define S_ISFIFO(m)    (NO)
  768. #endif
  769. #ifndef WEXITSTATUS
  770. #define WEXITSTATUS(s) (((s).w_status >> 8) & 0377)
  771. #endif
  772. #ifndef O_NONBLOCK
  773. #define O_NONBLOCK      O_NDELAY
  774. #endif
  775. #define NO_TIMEZONE                                       /* next has gmtoff */
  776. /*
  777.   FILE PERMISSIONS FOR NEXT
  778.   
  779.  */
  780. #ifndef S_IRWXU
  781. #define S_IRWXU 0000700
  782. #define S_IRWXG 0000070
  783. #define S_IRWXO 0000007
  784. #define S_IRUSR 0000400
  785. #define S_IWUSR 0000200
  786. #define S_IXUSR 0000100
  787. #define S_IRGRP 0000040
  788. #define S_IWGRP 0000020
  789. #define S_IXGRP 0000010
  790. #define S_IROTH 0000004
  791. #define S_IWOTH 0000002
  792. #define S_IXOTH 0000001
  793. #endif /* S_IRWXU */
  794. #endif /* NeXT */
  795. /*
  796. A/UX Apple UNIX
  797.                  Kelly King, bhutab@apple.com and Jim Jagielski, jim@jagubox.gsfc.nasa.gov
  798.                                                                                           
  799.  */
  800. #ifdef _AUX
  801. #include <time.h>
  802. #define WEXITSTATUS(s) (((s).w_status >> 8) & 0377)
  803. #define NO_STRFTIME
  804. #endif
  805. /*
  806. Sony News
  807.    Thanks to Isao SEKI, seki@tama.prug.or.jp
  808.    
  809.  */
  810. #ifdef sony_news
  811. #include <sys/wait.h>
  812. #define WEXITSTATUS(s) (((s).w_status >> 8) & 0377)
  813. typedef int mode_t;
  814. #endif
  815. /*
  816. Regular BSD unix versions
  817.    These are a default unix where not already defined specifically.
  818.    
  819.  */
  820. #ifndef INCLUDES_DONE
  821. #include <sys/types.h>
  822. #include <string.h>
  823. #include <errno.h>          /* independent */
  824. #include <sys/time.h>       /* independent */
  825. #include <sys/stat.h>
  826. #include <sys/param.h>
  827. #include <sys/file.h>       /* For open() etc */
  828. #define INCLUDES_DONE
  829. #endif  /* Normal includes */
  830. #ifdef SUNOS
  831. #include <unistd.h>
  832. #define NO_TIMEZONE
  833. #define NO_MKTIME
  834. #undef HAVE_STRERROR
  835. #endif
  836. #ifdef NetBSD
  837. #define NO_TIMEZONE
  838. #define HAVE_STRERROR
  839. #endif
  840. #ifdef __FreeBSD__
  841. #define NO_TIMEZONE
  842. #define HAVE_STRERROR
  843. #define NO_GETWD
  844. #define HAS_GETCWD
  845. #define FULL_TELNET
  846. #endif
  847. /*
  848.   DIRECTORY READING STUFF - BSD OR SYS V
  849.   
  850.  */
  851. #if defined(unix) || defined(__unix__)   /* If UNIX (thanks to Rainer Klute) */
  852. #define GOT_PIPE                                        /* We do have a pipe */
  853. #define GOT_READ_DIR         /* if directory reading functions are available */
  854. #define GOT_OWNER                         /* If a file has owner permissions */
  855. #include <pwd.h>
  856. #include <grp.h>
  857. #include <stdio.h>
  858. #ifndef NeXT
  859. #define USE_DIRENT                /* Try this all the time, Henrik May 29 94 */
  860. #endif
  861. #ifdef USE_DIRENT                                           /* sys v version */
  862. #include <dirent.h>
  863. #define STRUCT_DIRENT struct dirent
  864. #else
  865. #include <sys/dir.h>
  866. #define STRUCT_DIRENT struct direct
  867. #endif
  868. #ifdef SOLARIS
  869. #include <sys/fcntl.h>
  870. #include <limits.h>
  871. #endif
  872. #ifndef FNDELAY
  873. #define FNDELAY         O_NDELAY
  874. #endif
  875. #endif /* unix */
  876. /*
  877.    
  878.    ___________________________________
  879.    
  880.                                       GENERAL STUFF
  881.                                              
  882.    Information below this line is general for most platforms.
  883.    
  884.    See also Platform Specific Stuff
  885.    
  886.   SLEEP SYSTEM CALL
  887.   
  888.    Some systems use milliseconds instead of seconds
  889.    
  890.  */
  891. #ifndef SLEEP
  892. #define SLEEP(n)        sleep(n)
  893. #endif
  894. /*
  895.   SOCKS
  896.   
  897.    SOCKS modifications by Ian Dunkin <imd1707@ggr.co.uk>.
  898.    
  899.  */
  900. #if defined(SOCKS) && !defined(RULE_FILE)
  901. #define connect Rconnect
  902. #define accept  Raccept
  903. #define getsockname Rgetsockname
  904. #define bind Rbind
  905. #define listen Rlisten
  906. #endif
  907. /*
  908.   NETWORK FAMILY
  909.   
  910.  */
  911. #ifdef DECNET
  912. typedef struct sockaddr_dn SockA;  /* See netdnet/dn.h or custom vms.h */
  913. #else /* Internet */
  914. typedef struct sockaddr_in SockA;  /* See netinet/in.h */
  915. #endif
  916. /*
  917.   DEFAULT VALUES OF NETWORK ACCESS
  918.   
  919.  */
  920. #ifndef NETCLOSE
  921. #define NETCLOSE close          /* Routine to close a TCP-IP socket */
  922. #endif
  923. #ifndef NETREAD
  924. #define NETREAD  read           /* Routine to read from a TCP-IP socket */
  925. #endif
  926. #ifndef NETWRITE
  927. #define NETWRITE write          /* Routine to write to a TCP-IP socket */
  928. #endif
  929. /*
  930.   INCLUDE FILES FOR TCP
  931.   
  932.  */
  933. #ifndef TCP_INCLUDES_DONE
  934. #include <sys/socket.h>
  935. #include <netinet/in.h>
  936. #include <arpa/inet.h>                 /* Must be after netinet/in.h */
  937. #include <netdb.h>
  938. #define TCP_INCLUDES_DONE
  939. #endif
  940. /*
  941.   DEFINITION OF ERRNO AND RETURN CODE
  942.   
  943.    This is the definition of error codes and the corresponding string constants.  If we do
  944.    not have the strerror function then try the error list table.
  945.    
  946.  */
  947. #ifndef ERRNO_DONE
  948. extern int errno;
  949. #define socerrno errno
  950. #endif
  951. #ifndef HAVE_STRERROR                             /* Otherwise use the table */
  952. extern char *sys_errlist[];
  953. extern int sys_nerr;
  954. #endif
  955. /*
  956.   DEFINITION OF SOCKET DESRCIPTORES
  957.   
  958.    This is necessary in order to support Windows NT...
  959.    
  960.  */
  961. #ifndef SOCKET
  962. #define SOCKET int              /* Unix like socket descriptor */
  963. #define INVSOC (-1)             /* Unix invalid socket */
  964. #endif
  965. #ifdef __svr4__
  966. #define HT_BACKLOG 32            /* Number of pending connect requests (TCP) */
  967. #else
  968. #define HT_BACKLOG 5             /* Number of pending connect requests (TCP) */
  969. #endif /* __svr4__ */
  970. /*
  971.   ADDITIONAL NETWORK VARIABLES FOR SOCKET, FILE ACCESS BITS
  972.   
  973.  */
  974. #ifndef _WINSOCKAPI_
  975. #define FD_READ         0x01
  976. #define FD_WRITE        0x02
  977. #define FD_OOB          0x04
  978. #define FD_ACCEPT       0x08
  979. #define FD_CONNECT      0x10
  980. #define FD_CLOSE        0x20
  981. #endif /* _WINSOCKAPI_ */
  982. /*
  983.   ROUGH ESTIMATE OF MAX PATH LENGTH
  984.   
  985.  */
  986. #ifndef HT_MAX_PATH
  987. #ifdef MAXPATHLEN
  988. #define HT_MAX_PATH MAXPATHLEN
  989. #else
  990. #ifdef PATH_MAX
  991. #define HT_MAX_PATH PATH_MAX
  992. #else
  993. #define HT_MAX_PATH 1024                        /* Any better ideas? */
  994. #endif
  995. #endif
  996. #endif /* HT_MAX_PATH */
  997. /*
  998.   DEFINITION OF NGROUPS
  999.   
  1000.  */
  1001. #ifdef NO_UNIX_IO
  1002. #define NO_GROUPS
  1003. #endif
  1004. #ifndef NO_GROUPS
  1005. #ifndef NGROUPS
  1006. #ifdef NGROUPS_MAX
  1007. #define NGROUPS NGROUPS_MAX
  1008. #else
  1009. #define NGROUPS 20                              /* Any better ideas? */
  1010. #endif
  1011. #endif
  1012. #endif
  1013. /*
  1014.   DEFINITION OF MAX DOMAIN NAME LENGTH
  1015.   
  1016.  */
  1017. #ifndef MAXHOSTNAMELEN
  1018. #define MAXHOSTNAMELEN 64                       /* Any better ideas? */
  1019. #endif
  1020. /*
  1021.   FILE/DIRECTORY MANAGEMENT
  1022.   
  1023.  */
  1024. #ifndef MKDIR
  1025. #define MKDIR(a,b)      mkdir((a), (b))
  1026. #endif
  1027. #ifndef RMDIR
  1028. #define RMDIR(a)        rmdir((a))
  1029. #endif
  1030. #ifndef REMOVE
  1031. #define REMOVE(a)       unlink((a))
  1032. #endif
  1033. #ifndef DEFAULT_SUFFIXES
  1034. #define DEFAULT_SUFFIXES        ".,_"
  1035. #endif
  1036. #ifndef FCNTL
  1037. #define FCNTL(r,s,t)    fcntl((r),(s),(t))
  1038. #endif
  1039. /*
  1040.   MACROS FOR MANIPULATING MASKS FOR SELECT()
  1041.   
  1042.  */
  1043. #ifdef SELECT
  1044. #ifndef FD_SET
  1045. typedef unsigned int fd_set;
  1046. #define FD_SET(fd,pmask) (*(pmask)) |=  (1<<(fd))
  1047. #define FD_CLR(fd,pmask) (*(pmask)) &= ~(1<<(fd))
  1048. #define FD_ZERO(pmask)   (*(pmask))=0
  1049. #define FD_ISSET(fd,pmask) (*(pmask) & (1<<(fd)))
  1050. #endif  /* FD_SET */
  1051. #endif  /* SELECT */
  1052. /*
  1053.   MACROS FOR CONVERTING CHARACTERS
  1054.   
  1055.  */
  1056. #ifndef TOASCII
  1057. #define TOASCII(c) (c)
  1058. #define FROMASCII(c) (c)
  1059. #endif
  1060. /*
  1061.   CACHE FILE PREFIX
  1062.   
  1063.    This is something onto which we tag something meaningful to make a cache file name.
  1064.    used in HTWSRC.c at least. If it is nor defined at all, caching is turned off.
  1065.    
  1066.  */
  1067. #ifndef CACHE_FILE_PREFIX
  1068. #if defined(unix) || defined(__unix__)
  1069. #define CACHE_FILE_PREFIX  "/usr/wsrc/"
  1070. #endif
  1071. #endif
  1072. /*
  1073.   THREAD SAFE SETUP
  1074.   
  1075.    These are some constants setting the size of buffers used by thread safe versions of
  1076.    some system calls.
  1077.    
  1078.  */
  1079. #ifdef HT_REENTRANT
  1080. #define HOSTENT_MAX     128
  1081. #define CTIME_MAX       26
  1082. #endif
  1083. /*
  1084.  */
  1085. #endif
  1086. /*
  1087.    End of system-specific file */