Annotation of libwww/Library/src/wwwsys.html, revision 2.55

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

Webmaster