1 /* System-system differences for TCP include files and macros tcp.h
2 ** ===========================================================
5 ** This file includes for each system, the files necessary for
6 ** network and file I/O
9 ** TBL Tim Berners-Lee, W3 project, CERN, <timbl@info.cern.ch>
10 ** EvA Eelco van Asperen <evas@cs.few.eur.nl>
13 ** 22 Feb 91 Written (TBL) as part of the WWW project.
14 ** 16 Jan 92 PC code from EvA
19 #define NETCLOSE close /* Routine to close a TCP-IP socket */
20 #define NETREAD read /* Routine to read from a TCP-IP socket */
21 #define NETWRITE write /* Routine to write to a TCP-IP socket */
24 /* Macintosh - Think-C
25 ** -------------------
27 ** Think-C is one development environment on the Mac.
29 ** We recommend that you compile with 4-byte ints to be compatible
30 ** with MPW C. We used Tom Milligan's s_socket library which was
31 ** written for 4 byte int, and the MacTCP library assumes 4-byte int.
34 #define DEBUG /* Can't put it on the CC command line */
35 #define NO_UNIX_IO /* getuid() missing */
36 #define NO_GETPID /* getpid() does not exist */
37 #define NO_GETWD /* getwd() does not exist */
39 #undef NETCLOSE /* Routine to close a TCP-IP socket */
40 #undef NETREAD /* Routine to read from a TCP-IP socket */
41 #undef NETWRITE /* Routine to write to a TCP-IP socket */
42 #define NETCLOSE s_close /* Routine to close a TCP-IP socket */
43 #define NETREAD s_read /* Routine to read from a TCP-IP socket */
44 #define NETWRITE s_write /* Routine to write to a TCP-IP socket */
46 #define bind s_bind /* Funny names presumably to prevent clashes */
47 #define connect s_connect
48 #define accept s_accept
49 #define listen s_listen
50 #define socket s_socket
51 #define getsockname s_getsockname
53 /* The function prototype checking is better than the include files
56 extern s_close(int s);
57 extern s_read(int s, char *buffer, int buflen);
58 extern s_write(int s, const char *buffer, int buflen);
60 extern bind(int s, struct sockaddr *name, int namelen);
61 extern accept(int s, struct sockaddr *addr, int *addrlen);
62 extern listen(int s, int qlen);
63 extern connect(int s, struct sockaddr *addr, int addrlen);
65 extern s_socket(int domain, int type, int protocol);
66 extern s_getsockname(int s, struct sockaddr *name, int *namelen);
67 extern struct hostent *gethostent(const char * name);
68 extern unsigned long inet_addr(const char * name);
73 /* On the NeXT, there's a little package of include files.
76 #include <libc.h> /* NeXT has all this packaged up */
79 #include <sys/errno.h> /* Get ECONNRESET etc */
80 #define SELECT /* Is supported ok */
90 /* On the IBM RS-6000, AIX is almost Unix.
91 ** But AIX must be defined in the makefile.
97 /* MVS is compiled as for VM. MVS has no unix-style I/O
98 ** The command line compile options seem to come across in
101 ** See aslo lots of VM stuff lower down.
112 #pragma linkage(newlib,OS) /* Enables recursive NEWLIB */
115 /* VM doesn't have a built-in predefined token, so we cheat: */
119 #include <string.h> /* For bzero etc - not NeXT or VM */
121 #define SELECT /* Handle >1 channel if we can. */
122 #endif /* Not NeXT */
125 /* Under VMS, there are many versions of TCP-IP. Define one if you
126 ** do not use Digital's UCX product:
128 ** UCX DEC's "Ultrix connection" (default)
129 ** WIN_TCP From Wollongong, now GEC software.
130 ** MULTINET From SRI, now from TGV Inv.
132 ** The second two do not interfere with the unix i/o library, and so they
133 ** need special calls to read, write and close sockets. In these cases the
134 ** socket number is a VMS channel number, so we make the HORRIBLE
135 ** assumption that a channel number will be greater than 10 but a
136 ** unix file descriptor less than 10.
143 #define NETREAD(s,b,l) ((s)>10 ? netread((s),(b),(l)) : read((s),(b),(l)))
144 #define NETWRITE(s,b,l) ((s)>10 ? netwrite((s),(b),(l)) : write((s),(b),(l)))
145 #define NETCLOSE(s) ((s)>10 ? netclose(s) : close(s))
152 #define NETREAD(s,b,l) ((s)>10 ? socket_read((s),(b),(l)) : read((s),(b),(l)))
153 #define NETWRITE(s,b,l) ((s)>10 ? socket_write((s),(b),(l)) : \
155 #define NETCLOSE(s) ((s)>10 ? socket_close(s) : close(s))
158 /* Certainly this works for UCX and Multinet; not tried for Wollongong
161 #include "multinet_root:[multinet.include.sys]types.h"
162 #include "multinet_root:[multinet.include]errno.h"
163 #include "multinet_root:[multinet.include.sys]time.h"
178 #define INCLUDES_DONE
180 #ifdef MULTINET /* Include from standard Multinet directories */
181 #include "multinet_root:[multinet.include.sys]socket.h"
182 #ifdef __TIME_LOADED /* defined by sys$library:time.h */
183 #define __TIME /* to avoid double definitions in next file */
185 #include "multinet_root:[multinet.include.netinet]in.h"
186 #include "multinet_root:[multinet.include.arpa]inet.h"
187 #include "multinet_root:[multinet.include]netdb.h"
194 #define TCP_INCLUDES_DONE
202 ** Note: All files must have lines <= 80 characters
203 ** All include file names must have 8 chars max (+".h")
205 ** Under VM, compile with "DEF=VM"
207 ** Under MVS, compile with "NOMAR DEF(MVS)" to get rid of 72 char margin
208 ** System include files TCPIP and COMMMAC neeed line number removal(!)
211 #ifdef VM /* or MVS -- see above. */
212 #define NOT_ASCII /* char type is not ASCII */
213 #define NO_UNIX_IO /* Unix I/O routines are not supported */
214 #define NO_GETPID /* getpid() does not exist */
215 #define NO_GETWD /* getwd() does not exist */
217 #define SHORT_NAMES /* 8 character uniqueness for globals */
219 #include <manifest.h>
220 #include <bsdtypes.h>
226 #include <errno.h> /* independent */
227 extern char asciitoebcdic[], ebcdictoascii[];
228 #define TOASCII(c) (c=='\n' ? 10 : ebcdictoascii[c])
229 #define FROMASCII(c) (c== 10 ? '\n' : asciitoebcdic[c])
233 #define INCLUDES_DONE
234 #define TCP_INCLUDES_DONE
238 /* IBM-PC running MS-DOS with SunNFS for TCP/IP
239 ** ---------------------
241 ** This code thanks to Eelco van Asperen <evas@cs.few.eur.nl>
245 #include <sys/types.h>
252 #include <errno.h> /* independent */
253 #include <sys/time.h> /* independent */
254 #include <sys/stat.h>
255 #include <fcntl.h> /* In place of sys/param and sys/file */
256 #define INCLUDES_DONE
258 #define FD_SET(fd,pmask) (*(unsigned*)(pmask)) |= (1<<(fd))
259 #define FD_CLR(fd,pmask) (*(unsigned*)(pmask)) &= ~(1<<(fd))
260 #define FD_ZERO(pmask) (*(unsigned*)(pmask))=0
261 #define FD_ISSET(fd,pmask) (*(unsigned*)(pmask) & (1<<(fd)))
265 /* Regular BSD unix versions: (default)
266 ** -------------------------
269 #ifndef INCLUDES_DONE
270 #include <sys/types.h>
271 /* #include <streams/streams.h> not ultrix */
278 #include <errno.h> /* independent */
279 #include <sys/time.h> /* independent */
280 #include <sys/stat.h>
281 #include <sys/param.h>
282 #include <sys/file.h> /* For open() etc */
283 #define INCLUDES_DONE
284 #endif /* Normal includes */
287 /* Default include files for TCP
289 #ifndef TCP_INCLUDES_DONE
290 #include <sys/socket.h>
291 #include <netinet/in.h>
292 #include <arpa/inet.h> /* Must be after netinet/in.h */
294 #endif /* TCP includes */
297 /* Default macros for manipulating masks for select()
300 typedef unsigned int fd_set;
301 #define FD_SET(fd,pmask) (*(pmask)) |= (1<<(fd))
302 #define FD_CLR(fd,pmask) (*(pmask)) &= ~(1<<(fd))
303 #define FD_ZERO(pmask) (*(pmask))=0
304 #define FD_ISSET(fd,pmask) (*(pmask) & (1<<(fd)))
308 /* Default macros for converting characters
312 #define TOASCII(c) (c)
313 #define FROMASCII(c) (c)
317 #ifdef pyr /* Pyramid can't uppercase non-alpha */
318 #define TOLOWER(c) (isupper(c) ? tolower(c) : (c))
319 #define TOUPPER(c) (islower(c) ? toupper(c) : (c))
321 #define TOLOWER(c) tolower(c)
322 #define TOUPPER(c) toupper(c)
324 #endif /* ndef TOUPPER */