Annotation of libwww/Library/src/wwwsys.html, revision 2.14
2.7 timbl 1: <HTML>
2: <HEAD>
2.2 timbl 3: <TITLE>System dependencies in the W3 library</TITLE>
2.9 timbl 4: <NEXTID N="z5">
2.7 timbl 5: </HEAD>
2.2 timbl 6: <BODY>
7: <H1>System Dependencies</H1>System-system differences for TCP
8: include files and macros. This file
9: includes for each system the files
10: necessary for network and file I/O.
2.9 timbl 11: Part of <A
12: NAME="z4" HREF="Overview.html">libwww</A>.
2.2 timbl 13: <H3>Authors</H3>
14: <DL>
15: <DT>TBL
16: <DD> Tim Berners-Lee, W3 project,
17: CERN, <timbl@info.cern.ch>
18: <DT>EvA
19: <DD> Eelco van Asperen <evas@cs.few.eur.nl>
20: <DT>MA
21: <DD> Marc Andreesen NCSA
2.7 timbl 22: <DT>MD
23: <DD> Mark Donszelmann <duns@vxcern.cern.ch>
2.2 timbl 24: <DT>AT
2.4 timbl 25: <DD> Aleksandar Totic <atotic@ncsa.uiuc.edu>
26: <DT>SCW
2.5 timbl 27: <DD> Susan C. Weber <sweber@kyle.eitech.com>
2.2 timbl 28: </DL>
29:
30: <H3>History:</H3>
31: <DL>
32: <DT>22 Feb 91
33: <DD> Written (TBL) as part of
34: the WWW library.
35: <DT>16 Jan 92
2.7 timbl 36: <DD> PC code from (EvA)
2.2 timbl 37: <DT>22 Apr 93
38: <DD> Merged diffs bits from
39: xmosaic release
2.4 timbl 40: <DT>29 Apr 93
2.7 timbl 41: <DD> Windows/NT code from (SCW)
42: <DT>29 Sep 93
43: <DD> VMS fixes (MD)
2.2 timbl 44: </DL>
45:
2.1 timbl 46: <PRE>
47: #ifndef TCP_H
48: #define TCP_H
49:
2.2 timbl 50: </PRE>
51: <H2>Default values</H2>These values may be reset and altered
52: by system-specific sections later
53: on. there are also a bunch of <A
2.7 timbl 54: NAME="z2" HREF="#z1">defaults
2.3 timbl 55: at the end</A> .
2.2 timbl 56: <PRE>/* Default values of those: */
2.1 timbl 57: #define NETCLOSE close /* Routine to close a TCP-IP socket */
58: #define NETREAD read /* Routine to read from a TCP-IP socket */
59: #define NETWRITE write /* Routine to write to a TCP-IP socket */
60:
61: /* Unless stated otherwise, */
2.2 timbl 62: #define SELECT /* Can handle >1 channel. */
2.1 timbl 63: #define GOT_SYSTEM /* Can call shell with string */
64:
65: #ifdef unix
66: #define GOT_PIPE
67: #endif
68: #ifdef VM
69: #define GOT_PIPE /* Of sorts */
70: #endif
71:
72: #ifdef DECNET
73: typedef struct sockaddr_dn SockA; /* See netdnet/dn.h or custom vms.h */
74: #else /* Internet */
75: typedef struct sockaddr_in SockA; /* See netinet/in.h */
76: #endif
77:
78:
2.2 timbl 79: </PRE>
80: <H2>Macintosh - Think-C</H2>Think-C is one development environment
81: on the Mac.<P>
82: We recommend that you compile with
83: 4-byte ints to be compatible with
84: MPW C. We used Tom Milligan's s_socket
85: library which was written for 4 byte
86: int, and the MacTCP library assumes
87: 4-byte int.
88: <PRE>#ifdef THINK_C
2.1 timbl 89: #undef GOT_SYSTEM
90: #define DEBUG /* Can't put it on the CC command line */
91: #define NO_UNIX_IO /* getuid() missing */
92: #define NO_GETPID /* getpid() does not exist */
93: #define NO_GETWD /* getwd() does not exist */
94:
95: #undef NETCLOSE /* Routine to close a TCP-IP socket */
96: #undef NETREAD /* Routine to read from a TCP-IP socket */
97: #undef NETWRITE /* Routine to write to a TCP-IP socket */
98: #define NETCLOSE s_close /* Routine to close a TCP-IP socket */
99: #define NETREAD s_read /* Routine to read from a TCP-IP socket */
100: #define NETWRITE s_write /* Routine to write to a TCP-IP socket */
101:
102: #define bind s_bind /* Funny names presumably to prevent clashes */
103: #define connect s_connect
104: #define accept s_accept
105: #define listen s_listen
106: #define socket s_socket
107: #define getsockname s_getsockname
108:
109: /* The function prototype checking is better than the include files
110: */
111:
112: extern s_close(int s);
113: extern s_read(int s, char *buffer, int buflen);
114: extern s_write(int s, const char *buffer, int buflen);
115:
116: extern bind(int s, struct sockaddr *name, int namelen);
117: extern accept(int s, struct sockaddr *addr, int *addrlen);
118: extern listen(int s, int qlen);
119: extern connect(int s, struct sockaddr *addr, int addrlen);
120:
121: extern s_socket(int domain, int type, int protocol);
122: extern s_getsockname(int s, struct sockaddr *name, int *namelen);
123: extern struct hostent *gethostent(const char * name);
124: extern unsigned long inet_addr(const char * name);
125:
126: #endif /* THINK_C */
127:
128:
2.2 timbl 129: </PRE>
130: <H2>Macintosh - MPW</H2>MPW is one development environment
131: on the Mac.<P>
132: This entry was created by Aleksandar
133: Totic (atotic@ncsa.uiuc.edu) this
134: file is compatible with sockets package
135: released by NCSA. One major conflict
136: is that this library redefines write/read/etc
137: as macros. In some of HTML code
138: these macros get executed when they
139: should not be. Such files should
140: define NO_SOCKET_DEFS on top. This
141: is a temporary hack.
142: <PRE>#ifdef applec /* MPW */
143: #undef GOT_SYSTEM
144: #define DEBUG /* Can't put it on the CC command line */
145: #define NO_UNIX_IO /* getuid() missing
146: */
147: #define NO_GETPID /* getpid() does not exist
148: */
149: #define NO_GETWD /* getwd() does not exist
150: */
151:
152: #undef NETCLOSE /* Routine to close a TCP-IP socket */
153: #undef NETREAD /* Routine to read from a TCP-IP socket */
154: #undef NETWRITE /* Routine to write to a TCP-IP socket */
155: #define NETCLOSE s_close /* Routine to close a TCP-IP socket */
156: #define NETREAD s_read /* Routine to read from a TCP-IP socket */
157: #define NETWRITE s_write /* Routine to write to a TCP-IP socket */
158: #define _ANSI_SOURCE
159: #define GUI
160: #define LINEFEED 10
161: #define ANON_FTP_HOSTNAME
162: #ifndef NO_SOCKET_DEFS
163: #include <MacSockDefs.h>
164: #endif
165:
166: #include <socket.ext.h>
167: #include <string.h>
168:
169: #endif /* MPW */
170:
171:
172:
2.1 timbl 173: #ifndef STDIO_H
2.2 timbl 174: #include <stdio.h>
2.1 timbl 175: #define STDIO_H
176: #endif
177:
2.2 timbl 178: </PRE>
2.6 timbl 179: <H2>Big Blue - the world of incompatibility</H2>
180: <H2>IBM RS600</H2>On the IBM RS-6000, AIX is almost
181: Unix.
182: <PRE>#ifdef _AIX
2.2 timbl 183: #define AIX
184: #endif
2.1 timbl 185: #ifdef AIX
186: #define unix
187: #endif
188:
2.2 timbl 189: /* AIX 3.2
190: ** -------
191: */
192:
193: #ifdef _IBMR2
2.6 timbl 194: #define USE_DIRENT /* sys V style directory open */
2.2 timbl 195: #endif
196:
197:
198: </PRE>
2.4 timbl 199: <H2>IBM VM-CMS, VM-XA Mainframes</H2>MVS is compiled as for VM. MVS has
200: no unix-style I/O. The command line
201: compile options seem to come across
202: in lower case.
203: <PRE>#ifdef mvs
2.1 timbl 204: #define MVS
205: #endif
206:
207: #ifdef MVS
208: #define VM
209: #endif
210:
211: #ifdef NEWLIB
212: #pragma linkage(newlib,OS) /* Enables recursive NEWLIB */
213: #endif
214:
215: /* VM doesn't have a built-in predefined token, so we cheat: */
216: #ifndef VM
2.2 timbl 217: #include <string.h> /* For bzero etc - not VM */
218: #endif
219:
220: /* Note: All include file names must have 8 chars max (+".h")
221: **
222: ** Under VM, compile with "(DEF=VM,SHORT_NAMES,DEBUG)"
223: **
224: ** Under MVS, compile with "NOMAR DEF(MVS)" to get rid of 72 char margin
225: ** System include files TCPIP and COMMMAC neeed line number removal(!)
226: */
227:
228: #ifdef VM /* or MVS -- see above. */
229: #define NOT_ASCII /* char type is not ASCII */
230: #define NO_UNIX_IO /* Unix I/O routines are not supported */
231: #define NO_GETPID /* getpid() does not exist */
232: #define NO_GETWD /* getwd() does not exist */
233: #ifndef SHORT_NAMES
234: #define SHORT_NAMES /* 8 character uniqueness for globals */
235: #endif
236: #include <manifest.h>
237: #include <bsdtypes.h>
238: #include <stdefs.h>
239: #include <socket.h>
240: #include <in.h>
241: #include <inet.h>
242: #include <netdb.h>
243: #include <errno.h> /* independent */
244: extern char asciitoebcdic[], ebcdictoascii[];
245: #define TOASCII(c) (c=='\n' ? 10 : ebcdictoascii[c])
246: #define FROMASCII(c) (c== 10 ? '\n' : asciitoebcdic[c])
247: #include <bsdtime.h>
248: #include <time.h>
249: #include <string.h>
250: #define INCLUDES_DONE
251: #define TCP_INCLUDES_DONE
2.1 timbl 252: #endif
253:
254:
2.2 timbl 255: </PRE>
256: <H2>IBM-PC running MS-DOS with SunNFS
257: for TCP/IP</H2>This code thanks to Eelco van Asperen
2.3 timbl 258: <evas@cs.few.eur.nl>
259: <PRE>#ifdef PCNFS
260: #include <sys/types.h>
2.2 timbl 261: #include <string.h>
262: #include <errno.h> /* independent */
263: #include <sys/time.h> /* independent */
264: #include <sys/stat.h>
265: #include <fcntl.h> /* In place of sys/param and sys/file */
266: #define INCLUDES_DONE
267: #define FD_SET(fd,pmask) (*(unsigned*)(pmask)) |= (1<<(fd))
268: #define FD_CLR(fd,pmask) (*(unsigned*)(pmask)) &= ~(1<<(fd))
269: #define FD_ZERO(pmask) (*(unsigned*)(pmask))=0
270: #define FD_ISSET(fd,pmask) (*(unsigned*)(pmask) & (1<<(fd)))
271: #endif /* PCNFS */
272:
2.4 timbl 273: </PRE>
274: <H2>IBM-PC running Windows NT</H2>These parameters providede by Susan
275: C. Weber <sweber@kyle.eitech.com>.
276: <PRE>#ifdef _WINDOWS
277: #include "fcntl.h" /* For HTFile.c */
278: #include "sys\types.h" /* For HTFile.c */
279: #include "sys\stat.h" /* For HTFile.c */
280:
281: #undef NETREAD
282: #undef NETWRITE
283: #undef NETCLOSE
284: #define NETREAD(s,b,l) ((s)>10 ? recv((s),(b),(l),0) : read((s),(b),(l)))
285: #define NETWRITE(s,b,l) ((s)>10 ? send((s),(b),(l),0) : write((s),(b),(l)))
286: #define NETCLOSE(s) ((s)>10 ? closesocket(s) : close(s))
287: #include <io.h>
288: #include <string.h>
289: #include <process.h>
290: #include <time.h>
291: #include <direct.h>
292: #include <stdio.h>
293: #include <winsock.h>
294: typedef struct sockaddr_in SockA; /* See netinet/in.h */
295: #define INCLUDES_DONE
296: #define TCP_INCLUDES_DONE
297: #endif /* WINDOWS */
298:
2.2 timbl 299:
300:
301: </PRE>
2.4 timbl 302: <H2>VAX/VMS</H2>Under VMS, there are many versions
303: of TCP-IP. Define one if you do not
304: use Digital's UCX product:
305: <DL>
306: <DT>UCX
2.5 timbl 307: <DD> DEC's "Ultrix connection" (default)
2.4 timbl 308: <DT>WIN_TCP
2.5 timbl 309: <DD> From Wollongong, now GEC
310: software.
2.4 timbl 311: <DT>MULTINET
2.5 timbl 312: <DD> From SRI, now from TGV Inv.
2.4 timbl 313: <DT>DECNET
2.5 timbl 314: <DD> Cern's TCP socket emulation
2.4 timbl 315: over DECnet
316: </DL>
317: The last three do not interfere with
318: the unix i/o library, and so they
319: need special calls to read, write
320: and close sockets. In these cases
321: the socket number is a VMS channel
322: number, so we make the @@@ HORRIBLE
323: @@@ assumption that a channel number
324: will be greater than 10 but a unix
325: file descriptor less than 10. It
326: works.
327: <PRE>#ifdef vms
2.7 timbl 328: #define CACHE_FILE_PREFIX "SYS$LOGIN:Z_"
329:
330: #ifdef WIN_TCP
2.1 timbl 331: #undef NETREAD
332: #undef NETWRITE
333: #undef NETCLOSE
2.2 timbl 334: #define NETREAD(s,b,l) ((s)>10 ? netread((s),(b),(l)) : read((s),(b),(l)))
335: #define NETWRITE(s,b,l) ((s)>10 ? netwrite((s),(b),(l)) : write((s),(b),(l)))
336: #define NETCLOSE(s) ((s)>10 ? netclose(s) : close(s))
2.1 timbl 337: #endif
338:
339: #ifdef MULTINET
340: #undef NETCLOSE
341: #undef NETREAD
342: #undef NETWRITE
2.2 timbl 343: #define NETREAD(s,b,l) ((s)>10 ? socket_read((s),(b),(l)) : read((s),(b),(l)))
344: #define NETWRITE(s,b,l) ((s)>10 ? socket_write((s),(b),(l)) : \
2.1 timbl 345: write((s),(b),(l)))
2.2 timbl 346: #define NETCLOSE(s) ((s)>10 ? socket_close(s) : close(s))
2.1 timbl 347: #endif
348:
349: #ifdef DECNET
350: #undef SELECT /* not supported */
351: #undef NETREAD
352: #undef NETWRITE
353: #undef NETCLOSE
2.2 timbl 354: #define NETREAD(s,b,l) ((s)>10 ? recv((s),(b),(l),0) : read((s),(b),(l)))
355: #define NETWRITE(s,b,l) ((s)>10 ? send((s),(b),(l),0) : write((s),(b),(l)))
356: #define NETCLOSE(s) ((s)>10 ? socket_close(s) : close(s))
2.1 timbl 357: #endif /* Decnet */
358:
359: /* Certainly this works for UCX and Multinet; not tried for Wollongong
360: */
361: #ifdef MULTINET
362: #include "multinet_root:[multinet.include.sys]types.h"
363: #include "multinet_root:[multinet.include]errno.h"
364: #include "multinet_root:[multinet.include.sys]time.h"
365: #else
366: #include types
367: #include errno
368: #include time
369: #endif /* multinet */
370:
371: #include string
372:
373: #ifndef STDIO_H
374: #include stdio
375: #define STDIO_H
376: #endif
377:
378: #include file
379:
380: #ifndef DECNET /* Why is it used at all ? Types conflict with "types.h" */
381: #include unixio
382: #endif
383:
384: #define INCLUDES_DONE
385:
386: #ifdef MULTINET /* Include from standard Multinet directories */
387: #include "multinet_root:[multinet.include.sys]socket.h"
388: #ifdef __TIME_LOADED /* defined by sys$library:time.h */
389: #define __TIME /* to avoid double definitions in next file */
390: #endif
391: #include "multinet_root:[multinet.include.netinet]in.h"
392: #include "multinet_root:[multinet.include.arpa]inet.h"
393: #include "multinet_root:[multinet.include]netdb.h"
394:
395: #else /* not multinet */
396: #ifdef DECNET
397: #include "types.h" /* for socket.h */
398: #include "socket.h"
399: #include "dn"
400: #include "dnetdb"
401: /* #include "vms.h" */
402:
403: #else /* UCX or WIN */
404: #include socket
405: #include in
406: #include inet
407: #include netdb
408:
409: #endif /* not DECNET */
410: #endif /* of Multinet or other TCP includes */
411:
412: #define TCP_INCLUDES_DONE
413:
2.7 timbl 414: </PRE>On VMS machines, the linker needs
415: to be told to put global data sections
416: into a data segment using these storage
417: classes. (MarkDonszelmann)
418: <PRE>#ifdef VAXC
419: #define GLOBALDEF globaldef
420: #define GLOBALREF globalref
421: #endif /* VAXC */
422:
2.1 timbl 423: #endif /* vms */
424:
2.7 timbl 425: </PRE>On non-VMS machines, the GLOBALDEF
426: and GLOBALREF storage types default
427: to normal C storage types.
428: <PRE>#ifndef GLOBALREF
429: #define GLOBALDEF
430: #define GLOBALREF extern
431: #endif
432:
2.1 timbl 433:
434:
2.2 timbl 435: </PRE>
436: <H2>SCO ODT unix version</H2>
437: <PRE>
438: #ifdef sco
439: #include <sys/fcntl.h>
440: #define USE_DIRENT
2.1 timbl 441: #endif
442:
2.2 timbl 443: </PRE>
444: <H2>MIPS unix</H2>
445: <PRE>/* Mips hack (bsd4.3/sysV mixture...) */
2.1 timbl 446:
447: #ifdef mips
448: extern int errno;
449: #endif
450:
2.8 timbl 451: </PRE>
2.10 luotonen 452: <H2>Solaris</H2>
2.14 ! luotonen 453: (And Linux, thanks to Rainer Klute)
2.10 luotonen 454: <PRE>
2.14 ! luotonen 455: #if defined(__svr4__) || defined(_POSIX_SOURCE)
2.11 luotonen 456: #include <unistd.h>
2.10 luotonen 457: #endif
458: </PRE>
2.8 timbl 459: <H2>OSF/1</H2>
460: <PRE>#ifdef __osf__
461: #define USE_DIRENT
462: #endif /* OSF1 AXP */
463:
2.2 timbl 464:
465: </PRE>
466: <H2>Regular BSD unix versions</H2>These are a default unix where not
467: already defined specifically.
468: <PRE>#ifndef INCLUDES_DONE
469: #include <sys/types.h>
470: /* #include <streams/streams.h> not ultrix */
471: #include <string.h>
472:
473: #include <errno.h> /* independent */
474: #include <sys/time.h> /* independent */
475: #include <sys/stat.h>
476: #include <sys/param.h>
477: #include <sys/file.h> /* For open() etc */
2.1 timbl 478: #define INCLUDES_DONE
479: #endif /* Normal includes */
480:
2.2 timbl 481: /* Directory reading stuff - BSD or SYS V
482: */
2.1 timbl 483: #ifdef unix /* if this is to compile on a UNIX machine */
484: #define GOT_READ_DIR 1 /* if directory reading functions are available */
2.2 timbl 485: #ifdef USE_DIRENT /* sys v version */
486: #include <dirent.h>
487: #define direct dirent
488: #else
489: #include <sys/dir.h>
2.1 timbl 490: #endif
2.2 timbl 491: #if defined(sun) && defined(__svr4__)
492: #include <sys/fcntl.h>
493: #include <limits.h>
494: #endif
495: #endif
2.1 timbl 496:
2.2 timbl 497: </PRE>
2.13 luotonen 498: <H2>NeXT</H2>
499: <PRE>
500: #ifdef NeXT
501: #include "sys/types.h"
502: #include "sys/stat.h"
503: #define S_ISDIR(m) (m & S_IFDIR)
504: #define S_ISREG(m) (m & S_IFREG)
505: #endif
506:
507: </PRE>
2.2 timbl 508: <H2><A
2.7 timbl 509: NAME="z1">Defaults</A></H2>
2.2 timbl 510: <H3>Include files for TCP</H3>
511: <PRE>#ifndef TCP_INCLUDES_DONE
512: #include <sys/socket.h>
513: #include <netinet/in.h>
514: #ifndef __hpux /* this may or may not be good -marc */
515: #include <arpa/inet.h> /* Must be after netinet/in.h */
516: #endif
517: #include <netdb.h>
2.1 timbl 518: #endif /* TCP includes */
519:
520:
2.2 timbl 521: </PRE>
522: <H3>Macros for manipulating masks for
523: select()</H3>
524: <PRE>#ifdef SELECT
2.1 timbl 525: #ifndef FD_SET
526: typedef unsigned int fd_set;
2.2 timbl 527: #define FD_SET(fd,pmask) (*(pmask)) |= (1<<(fd))
528: #define FD_CLR(fd,pmask) (*(pmask)) &= ~(1<<(fd))
2.1 timbl 529: #define FD_ZERO(pmask) (*(pmask))=0
2.2 timbl 530: #define FD_ISSET(fd,pmask) (*(pmask) & (1<<(fd)))
2.1 timbl 531: #endif /* FD_SET */
532: #endif /* SELECT */
533:
2.2 timbl 534: </PRE>
535: <H3><A
2.9 timbl 536: NAME="z0">M</A> acros for converting characters</H3>
2.2 timbl 537: <PRE>#ifndef TOASCII
2.1 timbl 538: #define TOASCII(c) (c)
539: #define FROMASCII(c) (c)
2.5 timbl 540: #endif
541:
542: </PRE>
543: <H3>Cache file prefix</H3>This is something onto which we tag
544: something meaningful to make a cache
545: file name. used in HTWSRC.c at least.
2.6 timbl 546: If it is nor defined at all, caching
2.5 timbl 547: is turned off.
548: <PRE>#ifndef CACHE_FILE_PREFIX
549: #ifdef unix
2.6 timbl 550: #define CACHE_FILE_PREFIX "/usr/wsrc/"
2.5 timbl 551: #endif
2.1 timbl 552: #endif
553:
2.2 timbl 554: #endif /* TCP_H */
555:
556:
2.1 timbl 557:
2.9 timbl 558: </PRE>end of system-specific file</A></BODY>
2.7 timbl 559: </HTML>
Webmaster