1 /*        W3C Sample Code Library libwww System Dependencies
2 */
3 /*
4  * **      (c) COPYRIGHT MIT 1995.
5  * **      Please first read the full copyright statement in the file COPYRIGH.
6  * */
7 /*
8  *
9  *  This file makes up for the differencies in the systems and platforms supported by
10  *  libwww. On Unix, it is a question of using autoconf to figure out what environment we
11  *  are in. This is done by running the configure script which creates a wwwconf.h file.
12  *  This configuration include file contains a large set of macro definitions telling what
13  *  features we have and don't have. On platforms not supported by autoconf (Windows, Mac,
14  *  VMS etc.) you will find the information normally contained in the wwwconf.h file
15  *  directly included below. The second part of this file uses all the information that we
16  *  either have from the wwwconf.h file or directly coded and actually does the includes
17  *  etc.
18  *
19  *  Unix
20  *
21  *  Microsoft Windows Win32 API
22  *
23  *  Macintosh
24  *
25  *  Vax VMS
26  *
27  *  This module is a part of the W3C Sample Code Library.
28  *
29  *  Tim Berners-Lee, W3 project, CERN, <timbl@w3.org>
30  *
31  *  EvA                    Eelco van Asperen <evas@cs.few.eur.nl>
32  *
33  *  MA                     Marc Andreesen NCSA
34  *
35  *  MD                     Mark Donszelmann <duns@vxcern.cern.ch>
36  *
37  *  AT                     Aleksandar Totic <atotic@ncsa.uiuc.edu>
38  *
39  *  SCW                    Susan C. Weber <sweber@kyle.eitech.com>
40  *
41  *  HF                     Henrik Frystyk, <frystyk@w3.org>
42  *
43  *  CLB                    Charlie Brooks, <cbrooks@osf.org>
44  *
45  *  Written (TBL) as part of the WWW library.
46  *
47  *  16 Jan 92              PC code from (EvA)
48  *
49  *  22 Apr 93              Merged diffs bits from xmosaic release
50  *
51  *  29 Apr 93              Windows/NT code from (SCW)
52  *
53  *  29 Sep 93              Mar 96 CLB - changed SLEEP() macro for Windows/NT MSC compiler
54  *                         added BOOLEAN_DEFINED macro to avoid duplicate definitions in
55  *                         HUtils.h changed netread() macros to support reading from
56  *                         stdin,etc. as well as sockets. (Required for linemode browser to
57  *                         work).
58  *
59  *  Henrik                 Changed to support autoconf for Unix
60  *
61  */
62 
63 #ifndef SYSDEP_H
64 #define SYSDEP_H
65 /*
66  *
67  * UNIX
68  *
69  *    We rely on autoconf to do the dirty job. If you have any changhes then please add them
70  *    to the configure script
71  *
72 */
73 /* 16.3.2007 Chris Kronberg
74  * Removed query include of wwwconf.h; not needed here.
75  *
76  *
77  * MICROSOFT WINDOWS WIN32 API
78  *
79  *    Help provided by Eric Prud'hommeaux, Susan C. Weber <sweber@kyle.eitech.com>, Paul
80  *       Hounslow <P.M.Hounslow@reading.ac.uk>, and a lot of other PC people.
81  *
82  *           */
83 #if defined(_WINDOWS) || defined(_CONSOLE)
84 #define WWW_MSWINDOWS
85 #endif
86 
87 #if defined(_WINDOWS) && !defined (_CONSOLE)
88 #define WWW_WIN_WINDOW
89 #endif
90 
91 #if defined(_CONSOLE)
92 #define WWW_WIN_CONSOLE
93 #endif
94 
95 #ifdef WWW_MSWINDOWS
96 
97 #include <windows.h>
98 #include <io.h>
99 #include <process.h>
100 #include <winsock.h>
101 
102 #include "windows/config.h"
103 
104 #define NETREAD(s,b,l)  recv((s),(b),(l),0)
105 #define NETWRITE(s,b,l) send((s),(b),(l),0)
106 #define NETCLOSE(s)     closesocket(s)
107 #define IOCTL(s,c,a)    ioctlsocket(s,c, (long *) a)
108 
109 #define MKDIR(a,b)      mkdir((a))
110 #define REMOVE(a)       remove((a))
111 #define DEFAULT_SUFFIXES        "."
112 
113 #ifndef _CONSOLE
114 #define NO_STDIO
115 #endif
116 
117 #define SOCKET SOCKET                   /* WinSocks socket descriptor */
118 #define INVSOC INVALID_SOCKET           /* WinSocks invalid socket */
119 
120 #define DESIRED_WINSOCK_VERSION 0x0101  /* we'd like winsock ver 1.1... */
121 #define MINIMUM_WINSOCK_VERSION 0x0101  /* ...but we'll take ver 1.1 :) */
122 /*
123  *
124  *    These next defintions are because the UNIX stuff is not supplied with BC4 (Paul
125  *       Hounslow <P.M.Hounslow@reading.ac.uk>)
126  *
127 */
128 #define NO_UNIX_IO
129 
130 #define _IFMT           0170000 /* type of file */
131 #define _IFDIR          0040000 /* directory */
132 #define _IFCHR          0020000 /* character special */
133 #define _IFBLK          0060000 /* block special */
134 #define _IFREG          0100000 /* regular */
135 #define _IFLNK          0120000 /* symbolic link */
136 #define _IFSOCK         0140000 /* socket */
137 #define _IFIFO          0010000 /* fifo */
138 
139 #define S_ISUID         0004000 /* set user id on execution */
140 #define S_ISGID         0002000 /* set group id on execution */
141 #define S_ISVTX         0001000 /* save swapped text even after use */
142 
143 #ifdef S_IREAD
144 #undef S_IREAD
145 #define S_IREAD         0000400 /* read permission, owner */
146 #endif
147 
148 #ifdef S_IWRITE
149 #undef S_IWRITE
150 #define S_IWRITE        0000200 /* write permission, owner */
151 #endif
152 
153 #ifdef S_IEXEC
154 #undef S_IEXEC
155 #define S_IEXEC         0000100 /* execute/search permission, owner */
156 #endif
157 
158 #define S_ENFMT         0002000 /* enforcement-mode locking */
159 
160 #ifdef S_IFMT
161 #undef S_IFMT
162 #define S_IFMT          _IFMT
163 #endif
164 
165 #ifdef S_IDIR
166 #undef S_IDIR
167 #define S_IFDIR         _IFDIR
168 #endif
169 
170 #ifdef S_IFCHR
171 #undef S_IFCHR
172 #define S_IFCHR         _IFCHR
173 #endif
174 
175 #ifdef S_IBLK
176 #undef S_IBLK
177 #define S_IFBLK         _IFBLK
178 #endif
179 
180 #ifdef S_IREG
181 #undef S_IREG
182 #define S_IFREG         _IFREG
183 #endif
184 
185 #define S_IFLNK         _IFLNK
186 
187 #ifdef S_IFIFO
188 #undef S_IFIFO
189 #define S_IFIFO         _IFIFO
190 #endif
191 
192 #define S_IRWXU         0000700 /* rwx, owner */
193 #define         S_IRUSR 0000400 /* read permission, owner */
194 #define         S_IWUSR 0000200 /* write permission, owner */
195 #define         S_IXUSR 0000100 /* execute/search permission, owner */
196 #define S_IRWXG         0000070 /* rwx, group */
197 #define         S_IRGRP 0000040 /* read permission, group */
198 #define         S_IWGRP 0000020 /* write permission, grougroup */
199 #define         S_IXGRP 0000010 /* execute/search permission, group */
200 #define S_IRWXO         0000007 /* rwx, other */
201 #define         S_IROTH 0000004 /* read permission, other */
202 #define         S_IWOTH 0000002 /* write permission, other */
203 #define         S_IXOTH 0000001 /* execute/search permission, other */
204 
205 #define S_ISREG(m)      (((m)&_IFMT) == _IFREG)
206 /*
207  *
208  *    Winsock has its own errno codes and it returns them through WSAGetLastError(). However,
209  *       it does also support BSD error codes, so we make a compromise. WSA definitions moved
210  *          from _WIN32 ifdef by EGP
211  *
212 */
213 #define socerrno WSAGetLastError()
214 #define ERRNO_DONE
215 /*
216  *
217  *    Return code for socket functions. We can't use -1 as return value
218  *
219 */
220 #define EWOULDBLOCK     WSAEWOULDBLOCK
221 #define EINPROGRESS     WSAEINPROGRESS
222 #define ECONNREFUSED    WSAECONNREFUSED
223 #define ETIMEDOUT       WSAETIMEDOUT
224 #define ENETUNREACH     WSAENETUNREACH
225 #define EHOSTUNREACH    WSAEHOSTUNREACH
226 #define EHOSTDOWN       WSAEHOSTDOWN
227 #define EISCONN         WSAEISCONN
228 #define EINVAL          WSAEINVAL
229 
230 /* Some compilers do only define WIN32 and NOT _WINDOWS */
231 
232 #define NO_GROUPS
233 
234 #ifdef _WIN32
235 #define MKDIR(a,b)      mkdir((a))     /* CLB NT has mkdir, but only one arg */
236 #define SLEEP(n)        Sleep((n)*1000)
237 #else
238 #define MKDIR(a,b)      _mkdir((a))    /* CLB NT has mkdir, but only one arg */
239 #endif /* WIN32 */
240 
241 #endif /* WWW_MSWINDOWS */
242 /*
243  *
244  * MACINTOSH
245  *
246  *    We have two environments on Macintosh: Codeworrior and MPV.
247  *
248  *    Metrowerks Codewarrior is one development environment on the Mac. We are using GUSI
249  *    (1.5.9) by Matthias Neeracher <neeri@iis.ee.ethz.ch> for our socket lib. You can find
250  *    more information about the GUSI Library from Switzerland.
251  *
252  *    Compiles on PPC. Should compile on 68K.
253  *
254  *    August 31, 1995 by Steven T. Roussey <sroussey@eng.uci.edu> (STR). and jeff@macalot.com
255  *                               (Jeff Dripps). Thanks a bunch!
256  *
257 */
258 #ifdef __MWERKS__
259 #include <gusi.h>
260 #include <dirent.h>
261 #include <errno.h>
262 #include <sys/errno.h>
263 #include <sioux.h>
264 
265 #define INCLUDES_DONE
266 #define TCP_INCLUDES_DONE
267 
268 #define GUSI                    /* Identifies changes made for GUSI */
269 
270 #undef  HAVE_GETDOMAINNAME      /* STR */
271 #undef  HAVE_GETPASS
272 #undef  HAVE_GETWD
273 
274 #define HAVE_GETCWD
275 #define USE_DIRENT
276 #define NO_GROUPS
277 #define GOT_READ_DIR
278 
279 #undef  HAVE_TIMEZONE           /* STR */
280 #define NO_GMTOFF
281 #define HAVE_STRERROR
282 #define HAVE_GETHOSTNAME
283 
284 #define d_ino           d_fileno        /* backward compatibility */
285 
286 #define SLEEP(n)        GUSIDefaultSpin( SP_SLEEP, n/60)
287 
288 #define MKDIR(a,b)      mkdir(a)
289 
290 #define HAVE_STRFTIME           // added JTD:5/1/96
291 #define HAVE_MKTIME             // added JTD:5/1/96
292 #define HAVE_STRCHR             // added JTD:5/1/96
293 #define STDC_HEADERS            // added JTD:5/1/96
294 #define HAVE_MEMCPY             // added JTD:5/1/96
295 #define TTY_IS_SELECTABLE       // added JTD:5/1/96
296 #define HAVE_READDIR            // added JTD:5/1/96
297 #define HAVE_DIRENT_INO         // added JTD:5/1/96
298 #define HAVE_DIRENT_H           // added JTD:5/1/96
299 
300 #endif
301 /*
302  *
303  *    MPW is one development environment on the Mac.
304  *
305  *    This entry was created by Aleksandar Totic (atotic@ncsa.uiuc.edu) this file is
306  *    compatible with sockets package released by NCSA. One major conflict is that this
307  *    library redefines write/read/etc as macros. In some of HTML code these macros get
308  *    executed when they should not be. Such files should define NO_SOCKET_DEFS on top. This
309  *    is a temporary hack.
310  *
311 */
312 #ifdef applec                   /* MPW  */
313 #undef HAVE_SYSTEM
314 #define DEBUG                   /* Can't put it on the CC command line */
315 
316 #define NO_UNIX_IO              /* getuid() missing */
317 #undef  HAVE_GETPID             /* getpid() does not exist */
318 #define NO_GETWD                /* getwd() does not exist */
319 
320 #define NETCLOSE s_close    /* Routine to close a TCP-IP socket */
321 #define NETREAD  s_read     /* Routine to read from a TCP-IP socket */
322 #define NETWRITE s_write    /* Routine to write to a TCP-IP socket */
323 
324 #define _ANSI_SOURCE
325 #define GUI
326 #define LINEFEED 10
327 #define ANON_FTP_HOSTNAME
328 #ifndef NO_SOCKET_DEFS
329 #include <MacSockDefs.h>
330 #endif /* NO_SOCKET_DEFS */
331 
332 #include <socket.ext.h>
333 #include <string.h>
334 
335 #endif /* applec MPW */
336 /*
337  *
338  * VAX/VMS
339  *
340  *    Under VMS, there are many versions of TCP-IP. Define one if you do not use Digital's
341  *    UCX product:
342  *
343  *    DEC's "Ultrix connection" (default)
344  *
345  *    WIN_TCP                From Wollongong, now GEC software.
346  *
347  *    MULTINET               From SRI, now from TGV Inv.
348  *
349  *    DECNET                 Cern's TCP socket emulation over DECnet
350  *
351  *    The last three do not interfere with the unix i/o library, and so they need special
352  *    calls to read, write and close sockets. In these cases the socket number is a VMS
353  *    channel number, so we make the @@@ HORRIBLE @@@ assumption that a channel number will
354  *    be greater than 10 but a unix file descriptor less than 10. It works.
355  *
356 */
357 #ifdef VMS
358 #include "HTVMSUtils.h"
359 #define CACHE_FILE_PREFIX       "SYS$LOGIN:Z_"
360 #define DEFAULT_SUFFIXES        "._"
361 
362 #define HAVE_CUSERID
363 
364 #ifdef WIN_TCP
365 #define NETREAD(s,b,l)  ((s)>10 ? netread((s),(b),(l)) : read((s),(b),(l)))
366 #define NETWRITE(s,b,l) ((s)>10 ? netwrite((s),(b),(l)) : write((s),(b),(l)))
367 #define NETCLOSE(s)     ((s)>10 ? netclose(s) : close(s))
368 #endif /* WIN_TCP */
369 
370 #ifdef MULTINET
371 #undef NETCLOSE
372 #undef NETREAD
373 #undef NETWRITE
374 #define NETREAD(s,b,l)  ((s)>10 ? socket_read((s),(b),(l)) : read((s),(b),(l)))
375 #define NETWRITE(s,b,l) ((s)>10 ? socket_write((s),(b),(l)) : \
376                                 write((s),(b),(l)))
377 #define NETCLOSE(s)     ((s)>10 ? socket_close(s) : close(s))
378 #define IOCTL(s,c,a)    socket_ioctl(s,c,a);
379 #endif /* MULTINET */
380 
381 #ifdef DECNET
382 #define DNP_OBJ 80      /* This one doesn't look busy, but we must check */
383                         /* That one was for decnet */
384 #undef SELECT           /* not supported */
385 #define NETREAD(s,b,l)  ((s)>10 ? recv((s),(b),(l),0) : read((s),(b),(l)))
386 #define NETWRITE(s,b,l) ((s)>10 ? send((s),(b),(l),0) : write((s),(b),(l)))
387 #define NETCLOSE(s)     ((s)>10 ? socket_close(s) : close(s))
388 
389 #undef HAVE_GETHOSTNAME                 /* Decnet doesn't have a name server */
390 #endif /* Decnet */
391 
392 #undef HAVE_GETDOMAINNAME
393 
394 /*      Certainly this works for UCX and Multinet; not tried for Wollongong
395 */
396 #ifdef MULTINET
397 #include <time.h>
398 #ifdef __TIME_T
399 #define __TYPES
400 #define __TYPES_LOADED
401 #endif /* __TIME_T */
402 #include <multinet_root:[multinet.include.sys]types.h>
403 #include <multinet_root:[multinet.include]errno.h>
404 #ifdef __TYPES
405 #define __TIME_T
406 #endif /* __TYPE */
407 #ifdef __TIME_LOADED
408 #define __TIME
409 #endif /* __TIME_LOADED */
410 #include <multinet_root:[multinet.include.sys]time.h>
411 #else /* not MULTINET */
412 #include <types.h>
413 #include <errno.h>
414 #include <time.h>
415 #endif /* not MULTINET */
416 
417 #include string
418 
419 #ifndef STDIO_H
420 #include <stdio>
421 #define STDIO_H
422 #endif
423 
424 #include file
425 
426 #ifndef DECNET  /* Why is it used at all ? Types conflict with "types.h> */
427 #include unixio
428 #endif
429 
430 #define INCLUDES_DONE
431 
432 #ifdef MULTINET  /* Include from standard Multinet directories */
433 #include <multinet_root:[multinet.include.sys]socket.h>
434 #ifdef __TIME_LOADED  /* defined by sys$library:time.h */
435 #define __TIME  /* to avoid double definitions in next file */
436 #endif
437 #include <multinet_root:[multinet.include.netinet]in.h>
438 #include <multinet_root:[multinet.include.arpa]inet.h>
439 #include <multinet_root:[multinet.include]netdb.h>
440 #include <multinet_root:[multinet.include.sys]ioctl.h>
441 
442 #else  /* not multinet */
443 #ifdef DECNET
444 #include <types.h>  /* for socket.h */
445 #include <socket.h>
446 #include <dn>
447 #include <dnetdb>
448 
449 #else /* UCX or WIN */
450 #ifdef CADDR_T
451 #define __CADDR_T
452 #endif /* problem with xlib.h inclusion */
453 #include <socket.h>
454 #include <in.h>
455 #include <inet.h>
456 #include <netdb.h>
457 #include <ucx$inetdef.h>
458 
459 #endif  /* not DECNET */
460 #endif  /* of Multinet or other TCP includes */
461 
462 #define TCP_INCLUDES_DONE
463 
464 #ifdef UCX
465 #define SIMPLE_TELNET
466 #endif
467 /*
468  *
469  *    On VMS directory browsing is available through a separate copy of dirent.c. The
470  *    definition of R_OK seem to be missing from the system include files...
471  *
472 */
473 #define USE_DIRENT
474 #define GOT_READ_DIR
475 #include <dirent.h>
476 #define DIR struct dirent
477 #define R_OK 4
478 /*
479  *
480  *    On VMS machines, the linker needs to be told to put global data sections into a data
481  *    segment using these storage classes. (MarkDonszelmann)
482  *
483 */
484 #ifdef VAXC
485 #define GLOBALDEF globaldef
486 #define GLOBALREF globalref
487 #endif /*  VAXC */
488 #endif  /* vms */
489 /*
490  *
491  *    On non-VMS machines, the GLOBALDEF and GLOBALREF storage types default to normal C
492  *    storage types.
493  *
494  *           */
495 #ifndef GLOBALREF
496 #define GLOBALDEF
497 #define GLOBALREF extern
498 #endif
499 /*
500  *
501  *    On non-VMS machines STAT should be stat...On VMS machines STAT is a function that
502  *    converts directories and devices so that you can stat them.
503  *
504 */
505 #ifdef VMS
506 typedef unsigned long mode_t;
507 #define HT_STAT         HTStat
508 #define HT_LSTAT        HTStat
509 #else
510 #define HT_STAT         stat
511 #define HT_LSTAT        lstat
512 #endif /* non VMS */
513 /*
514  *
515  *    Replace memory allocation and free C RTL functions with VAXC$xxx_OPT alternatives for
516  *    VAXC (but not DECC) on VMS. This makes a big performance difference. (Foteos Macrides).
517  *    Also have a look at the Dynamic Memory Module for how to handle malloc and calloc.
518  *
519 */
520 #ifdef VMS
521 #include <stdio.h>
522 #include <stdlib.h>
523 #include <unixlib.h>
524 #include <ctype.h>
525 #if defined(VAXC) && !defined(__DECC)
526 #define malloc  VAXC$MALLOC_OPT
527 #define calloc  VAXC$CALLOC_OPT
528 #define free    VAXC$FREE_OPT
529 #define cfree   VAXC$CFREE_OPT
530 #define realloc VAXC$REALLOC_OPT
531 #endif /* VAXC but not DECC */
532 #define unlink remove
533 #define gmtime localtime
534 #include <stat.h>
535 #define S_ISDIR(m)      (((m)&S_IFMT) == S_IFDIR)
536 #define S_ISREG(m)      (((m)&S_IFMT) == S_IFREG)
537 #define putenv HTVMS_putenv
538 #endif /* VMS */
539 /*
540  *
541 */
542 #ifdef VMS
543 #ifndef DECC
544 #undef  HAVE_STRFTIME
545 #endif
546 #undef  HAVE_MKTIME
547 #undef  HAVE_TIMEGM
548 #define NO_GMTOFF
549 #undef  HAVE_TIMEZONE
550 #endif
551 
552 /*
553  *
554 */
555 #ifdef VMS
556 #ifndef __DECC
557 extern int uerrno;      /* Deposit of error info (as per errno.h) */
558 extern volatile noshare int socket_errno; /* socket VMS error info
559                                           (used for translation of vmserrno) */
560 extern volatile noshare int vmserrno;   /* Deposit of VMS error info */
561 extern volatile noshare int errno;  /* noshare to avoid PSECT conflict */
562 #define ERRNO_DONE
563 #endif /* not DECC */
564 #endif /* VMS */
565 /*
566  *
567  *
568  *       ___________________________________
569  *
570  *       PLATFORM INDEPENDENT STUFF
571  *
572  *       Here we use all the knowledge we got above...
573  *
574  *       This file includes all system header files that are needed, iff they exist. Their
575  *       existance is discovered by configure.
576  *
577 */
578 /* stdio.h */
579 #ifdef HAVE_STDIO_H
580 #include <stdio.h>
581 #endif
582 
583 /* types.h */
584 #ifdef HAVE_SYS_TYPES_H
585 #include <sys/types.h>
586 #else
587 #ifdef HAVE_TYPES_H
588 #include <types.h>
589 #endif
590 #endif
591 
592 /* unistd.h */
593 #ifdef HAVE_UNISTD_H
594 #include <unistd.h>
595 #else
596 #ifdef HAVE_SYS_UNISTD_H
597 #include <sys/unistd.h>
598 #endif
599 #endif
600 
601 /* fcntl.h */
602 #ifdef HAVE_FCNTL_H
603 #include <fcntl.h>
604 #else
605 #ifdef HAVE_SYS_FCNTL_H
606 #include <sys/fcntl.h>
607 #endif
608 #endif
609 
610 /* sys/machine.h */
611 #ifdef HAVE_SYS_MACHINE_H
612 #include <sys/machine.h>
613 #endif
614 
615 /* limits.h */
616 #ifdef HAVE_SYS_LIMITS_H
617 #include <sys/limits.h>
618 #else
619 #ifdef HAVE_LIMITS_H
620 #include <limits.h>
621 #endif
622 #endif
623 
624 /* stat.h */
625 #ifdef HAVE_SYS_STAT_H
626 #include <sys/stat.h>
627 #else
628 #ifdef HAVE_STAT_H
629 #include <stat.h>
630 #endif
631 #endif
632 
633 /* Patch for problems in glibc6 */
634 #if defined(__GLIBC__)
635 #undef S_IFMT
636 #undef S_IFDIR
637 #define S_IFMT __S_IFMT
638 #define S_IFDIR __S_IFDIR
639 #endif
640 
641 /* in.h */
642 #ifdef HAVE_NETINET_IN_H
643 #include <netinet/in.h>
644 #else
645 #ifdef HAVE_IN_H
646 #include <in.h>
647 #endif
648 #endif
649 
650 /* tcp.h */
651 #ifdef HAVE_NETINET_TCP_H
652 #include <netinet/tcp.h>
653 #else
654 #ifdef HAVE_TCP_H
655 #include <tcp.h>
656 #endif
657 #endif
658 
659 /* file.h */
660 #ifdef HAVE_SYS_FILE_H
661 #include <sys/file.h>
662 #endif
663 
664 /* systeminfo.h */
665 #ifdef HAVE_SYS_SYSTEMINFO_H
666 #include <sys/systeminfo.h>
667 #endif
668 
669 /* ioctl.h */
670 #ifdef HAVE_SYS_IOCTL_H
671 #include <sys/ioctl.h>
672 #endif
673 
674 /* termios.h */
675 #ifdef HAVE_TERMIOS_H
676 #include <termios.h>
677 #endif
678 
679 /* time.h */
680 #ifdef TIME_WITH_SYS_TIME
681 #include <sys/time.h>
682 #include <time.h>
683 #else
684 #ifdef HAVE_SYS_TIME_H
685 #include <sys/time.h>
686 #else
687 #ifdef HAVE_TIME_H
688 #include <time.h>
689 #endif
690 #endif
691 #endif
692 
693 /* string{,s}.h */
694 #ifdef HAVE_STRING_H
695 #include <string.h>
696 #else
697 #ifdef HAVE_STRINGS_H
698 #include <strings.h>
699 #endif
700 #endif
701 
702 /* syslog.h */
703 #ifdef HAVE_SYSLOG_H
704 #include <syslog.h>
705 #endif
706 
707 /* socket.h */
708 #ifdef HAVE_SYS_SOCKET_H
709 #include <sys/socket.h>
710 #else
711 #ifdef HAVE_SOCKET_H
712 #include <socket.h>
713 #endif
714 #endif
715 
716 /* socket.ext.h */
717 #ifdef HAVE_SOCKET_EXT_H
718 #include <socket.ext.h>
719 #endif
720 
721 /* appkit.h */
722 #ifdef HAVE_APPKIT_APPKIT_H
723 #include <appkit/appkit.h>
724 #else
725 #ifdef HAVE_APPKIT_H
726 #include <appkit.h>
727 #endif
728 #endif
729 
730 /* dn.h */
731 #ifdef HAVE_DN_H
732 #include <dn.h>
733 #endif
734 
735 /* ipc.h */
736 #ifdef HAVE_SYS_IPC_H
737 #include <sys/ipc.h>
738 #endif
739 
740 /* errno.h */
741 #ifdef HAVE_ERRNO_H
742 #include <errno.h>
743 #else
744 #ifdef HAVE_SYS_ERRNO_H
745 #include <sys/errno.h>
746 #else
747 #ifdef HAVE_NET_ERRNO_H
748 #include <net/errno.h>
749 #endif
750 #endif
751 #endif
752 
753 /* pwd.h */
754 #ifdef HAVE_PWD_H
755 #include <pwd.h>
756 #endif
757 
758 /* grp.h */
759 #ifdef HAVE_GRP_H
760 #include <grp.h>
761 #endif
762 
763 /* inet.h */
764 #ifdef HAVE_ARPA_INET_H
765 #include <arpa/inet.h>
766 #else
767 #ifdef HAVE_INET_H
768 #include <inet.h>
769 #endif
770 #endif
771 
772 /* netdb.h */
773 #ifdef HAVE_NETDB_H
774 #include <netdb.h>
775 #endif
776 
777 /* manifest.h */
778 #ifdef HAVE_MANIFEST_H
779 #include <manifest.h>
780 #endif
781 
782 /* bsdtypes.h */
783 #ifdef HAVE_BSDTYPES_H
784 #include <bsdtypes.h>
785 #endif
786 
787 /* stdefs.h */
788 #ifdef HAVE_STDEFS_H
789 #include <stdefs.h>
790 #endif
791 
792 /* bsdtime.h */
793 #ifdef HAVE_BSDTIME_H
794 #include <bsdtime.h>
795 #endif
796 
797 /* select.h */
798 #ifdef HAVE_SYS_SELECT_H
799 #include <sys/select.h>
800 #else
801 #ifdef HAVE_SELECT_H
802 #include <select.h>
803 #endif
804 #endif
805 
806 /* dnetdb.h */
807 #ifdef HAVE_DNETDB_H
808 #include <dnetdb.h>
809 #endif
810 
811 /* ucx$inetdef.h */
812 #ifdef HAVE_UCX_INETDEF_H
813 #include <ucx$inetdef.h>
814 #endif
815 
816 /* libc.h */
817 #ifdef HAVE_LIBC_H
818 #include <libc.h>
819 #endif
820 
821 /* stdlib.h */
822 #ifdef HAVE_STDLIB_H
823 #include <stdlib.h>
824 #endif
825 
826 /* malloc.h */
827 #ifdef HAVE_MALLOC_H
828 #include <malloc.h>
829 #endif
830 
831 /* memory.h */
832 #ifdef HAVE_MEMORY_H
833 #include <memory.h>
834 #endif
835 
836 /* unixlib.h */
837 #ifdef HAVE_UNIXLIB_H
838 #include <unixlib.h>
839 #endif
840 
841 /* direct.h */
842 #ifdef HAVE_DIRECT_H
843 #include <direct.h>
844 #endif
845 
846 /* ctype.h */
847 #ifdef HAVE_CTYPE_H
848 #include <ctype.h>
849 #endif
850 
851 /* curses.h */
852 #ifdef CURSES
853 #ifdef HAVE_CURSESX_H
854 #include <cursesX.h>
855 #else
856 #ifdef HAVE_CURSES_H
857 #include <curses.h>
858 #endif
859 #endif
860 #endif
861 
862 /* resource.h (some wait.h's require it) */
863 #ifdef HAVE_SYS_RESOURCE_H
864 #include <sys/resource.h>
865 #else
866 #ifdef HAVE_RESOURCE_H
867 #include <resource.h>
868 #endif
869 #endif
870 
871 /* dirent.h / ndir.h / dir.h */
872 #ifdef HAVE_DIRENT_H
873 #include <dirent.h>
874 #define NAMLEN(dirent) strlen((dirent)->d_name)
875 #else
876 #define dirent direct
877 #define NAMLEN(dirent) (dirent)->d_namlen
878 #ifdef HAVE_SYS_NDIR_H
879 #include <sys/ndir.h>
880 #endif
881 #ifdef HAVE_SYS_DIR_H
882 #include <sys/dir.h>
883 #endif
884 #ifdef HAVE_DIR_H
885 #include <dir.h>
886 #endif
887 #ifdef HAVE_NDIR_H
888 #include <ndir.h>
889 #endif
890 #endif
891 
892 #if !defined(HAVE_STRCHR)
893 #define strchr index
894 #define strrchr rindex
895 #endif
896 #if !defined(HAVE_MEMCPY)
897 #define memcpy(d, s, n) bcopy((s), (d), (n))
898 #define memmove(d, s, n) bcopy((s), (d), (n))
899 #endif
900 
901 /* Definition of var args */
902 #if defined(STDC_HEADERS) || defined(__STDC__)
903 #include <stdarg.h>
904 #else
905 #ifndef WWW_MSWINDOWS
906 #include <varargs.h>
907 #endif
908 #endif
909 
910 /* wait.h */
911 #ifdef HAVE_SYS_WAIT_H
912 #include <sys/wait.h>
913 #endif
914 #ifndef WEXITSTATUS
915 #define WEXITSTATUS(stat_val) (((unsigned)(stat_val) >> 8) & 255)
916 #endif
917 #ifndef WIFEXITED
918 #define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
919 #endif
920 
921 #ifdef HT_POSIX_REGEX
922 #ifdef HAVE_RXPOSIX_H
923 #include <rxposix.h>
924 #else
925 #ifdef HAVE_REGEX_H
926 #include <regex.h>
927 #endif
928 #endif
929 #define W3C_DEFAULT_REGEX_FLAGS         (REG_EXTENDED | REG_NEWLINE)
930 #endif
931 /*
932  *
933  *  */
934 #ifndef BOOLEAN
935 typedef char    BOOLEAN;                                    /* Logical value */
936 #endif
937 
938 #ifndef CURSES
939 #ifndef TRUE
940 #define TRUE    (BOOLEAN)1
941 #define FALSE   (BOOLEAN)0
942 #endif
943 #endif   /*  CURSES  */
944 
945 #if !defined(BOOL) && !defined(WWW_MSWINDOWS)
946 #define BOOL BOOLEAN
947 #endif
948 
949 #ifndef YES
950 #define YES             (BOOL)1
951 #define NO              (BOOL)0
952 #endif
953 /*
954  *
955  *    If we don't have these (for some mysterious reason) then define them. This should (is?)
956  *    be handled by the configure script already.
957  *
958 */
959 #ifndef u_short
960 #define u_short unsigned short
961 #endif
962 
963 #ifndef u_long
964 #define u_long unsigned long
965 #endif
966 /*
967  *
968 */
969 #ifndef NULL
970 #define NULL ((void *)0)
971 #endif
972 /*
973  *
974  *    Some systems use milliseconds instead of seconds
975  *
976 */
977 #ifndef SLEEP
978 #define SLEEP(n)        sleep(n)
979 #endif
980 /*
981  *
982  *    SOCKS is a package for allowing socket connections to tunnel through firewalls in
983  *    carefully controlled situations. This package can be optionally compiled with SOCKS
984  *    support; these definitions replace the normal socket calls with the SOCKS ones. Initial
985  *    modification of the library is credited to Ian Dunkin <imd1707@ggr.co.uk>.
986  *
987 */
988 #ifdef SOCKS
989 #ifdef SOCKS4
990 #define connect         Rconnect
991 #define getsockname     Rgetsockname
992 #define getpeername     Rgetpeername
993 #define bind            Rbind
994 #define accept          Raccept
995 #define listen          Rlisten
996 #define select          Rselect
997 #define recvfrom        Rrecvfrom
998 #define sendto          Rsendto
999 #define recv            Rrecv
1000 #define send            Rsend
1001 #define read            Rread
1002 #define write           Rwrite
1003 #define rresvport       Rrresvport
1004 #define shutdown        Rshutdown
1005 #define listen          Rlisten
1006 #define close           Rclose
1007 #define dup             Rdup
1008 #define dup2            Rdup2
1009 #define fclose          Rfclose
1010 #define gethostbyname   Rgethostbyname
1011 #else
1012 #ifdef SOCKS5
1013 #define connect         SOCKSconnect
1014 #define getsockname     SOCKSgetsockname
1015 #define getpeername     SOCKSgetpeername
1016 #define bind            SOCKSbind
1017 #define accept          SOCKSaccept
1018 #define listen          SOCKSlisten
1019 #define select          SOCKSselect
1020 #define recvfrom        SOCKSrecvfrom
1021 #define sendto          SOCKSsendto
1022 #define recv            SOCKSrecv
1023 #define send            SOCKSsend
1024 #define read            SOCKSread
1025 #define write           SOCKSwrite
1026 #define rresvport       SOCKSrresvport
1027 #define shutdown        SOCKSshutdown
1028 #define listen          SOCKSlisten
1029 #define close           SOCKSclose
1030 #define dup             SOCKSdup
1031 #define dup2            SOCKSdup2
1032 #define fclose          SOCKSfclose
1033 #define gethostbyname   SOCKSgethostbyname
1034 #endif /* SOCKS5 */
1035 #endif /* SOCKS4 */
1036 #endif /* SOCKS */
1037 /*
1038  *
1039 */
1040 #ifdef DECNET
1041 typedef struct sockaddr_dn SockA;  /* See netdnet/dn.h or custom vms.h */
1042 #else /* Internet */
1043 typedef struct sockaddr_in SockA;  /* See netinet/in.h */
1044 #endif
1045 /*
1046  *
1047 */
1048 #ifndef NETCLOSE
1049 #define NETCLOSE close          /* Routine to close a TCP-IP socket */
1050 #endif
1051 
1052 #ifndef NETREAD
1053 #define NETREAD  read           /* Routine to read from a TCP-IP socket */
1054 #endif
1055 
1056 #ifndef NETWRITE
1057 #define NETWRITE write          /* Routine to write to a TCP-IP socket */
1058 #endif
1059 
1060 #ifndef NETWRITEV
1061 #define NETWRITEV writev
1062 #endif
1063 /*
1064  *
1065  *    This is the definition of error codes and the corresponding string constants. If we do
1066  *    not have the strerror function then try the error list table.
1067  *
1068 */
1069 #ifndef ERRNO_DONE
1070 extern int errno;
1071 #define socerrno errno
1072 #endif
1073 
1074 #ifndef HAVE_STRERROR                             /* Otherwise use the table */
1075 extern char *sys_errlist[];
1076 extern int sys_nerr;
1077 #endif
1078 /*
1079  *
1080  *    This is necessary in order to support Windows NT...
1081  *
1082 */
1083 #ifndef SOCKET
1084 #define SOCKET int              /* Unix like socket descriptor */
1085 #define INVSOC (-1)             /* Unix invalid socket */
1086 #endif
1087 
1088 #ifdef __svr4__
1089 #define HT_BACKLOG 32            /* Number of pending connect requests (TCP) */
1090 #else
1091 #define HT_BACKLOG 5             /* Number of pending connect requests (TCP) */
1092 #endif /* __svr4__ */
1093 /*
1094  *
1095 */
1096 #if 0
1097 #ifndef _WINSOCKAPI_
1098 #define FD_READ         0x01
1099 #define FD_WRITE        0x02
1100 #define FD_OOB          0x04
1101 #define FD_ACCEPT       0x08
1102 #define FD_CONNECT      0x10
1103 #define FD_CLOSE        0x20
1104 #endif /* _WINSOCKAPI_ */
1105 #endif
1106 /*
1107  *
1108 */
1109 #ifndef HT_MAX_PATH
1110 #ifdef MAXPATHLEN
1111 #define HT_MAX_PATH MAXPATHLEN
1112 #else
1113 #ifdef PATH_MAX
1114 #define HT_MAX_PATH PATH_MAX
1115 #else
1116 #define HT_MAX_PATH 1024                        /* Any better ideas? */
1117 #endif
1118 #endif
1119 #endif /* HT_MAX_PATH */
1120 
1121 #ifndef HT_MAX_TMPNAM
1122 #ifdef L_tmpnam
1123 #define HT_MAX_TMPNAM   L_tmpnam
1124 #else
1125 #define HT_MAX_TMPNAM   128
1126 #endif
1127 #endif
1128 /*
1129  *
1130 */
1131 #ifdef GETGROUPS_T
1132 #ifndef NGROUPS
1133 #ifdef NGROUPS_MAX
1134 #define NGROUPS         NGROUPS_MAX
1135 #else
1136 #define NGROUPS         20                      /* Any better ideas? */
1137 #endif
1138 #endif
1139 #endif
1140 /*
1141  *
1142 */
1143 #ifndef MAXHOSTNAMELEN
1144 #define MAXHOSTNAMELEN 64                       /* Any better ideas? */
1145 #endif
1146 /*
1147  *
1148 */
1149 #ifndef MKDIR
1150 #define MKDIR(a,b)      mkdir((a), (b))
1151 #endif
1152 
1153 #ifndef RMDIR
1154 #define RMDIR(a)        rmdir((a))
1155 #endif
1156 
1157 #ifndef REMOVE
1158 #define REMOVE(a)       unlink((a))
1159 #endif
1160 
1161 #ifndef DEFAULT_SUFFIXES
1162 #define DEFAULT_SUFFIXES        ".,_"
1163 #endif
1164 
1165 #ifndef F_OK
1166 #define R_OK    4
1167 #define W_OK    2
1168 #define X_OK    1
1169 #define F_OK    0
1170 #endif
1171 /*
1172  *
1173 */
1174 #ifndef FD_SET
1175 #define FD_SET(fd, m) (*(unsigned*)(m) |=  (1 << (fd)))
1176 #endif
1177 
1178 #ifndef FD_CLR
1179 #define FD_CLR(fd, m) (*(unsigned*)(m) &= ~(1 << (fd)))
1180 #endif
1181 
1182 #ifndef FD_ZERO
1183 #define FD_ZERO(m)    (*(unsigned*)(m)) = 0
1184 #endif
1185 
1186 #ifndef FD_ISSET
1187 #define FD_ISSET(fd, m) (*(unsigned*)(m) & (1 << (fd)))
1188 #endif
1189 /*
1190  *
1191 */
1192 #ifndef TOASCII
1193 #define TOASCII(c) (c)
1194 #define FROMASCII(c) (c)
1195 #endif
1196 /*
1197  *
1198  *    This is something onto which we tag something meaningful to make a cache file name.
1199  *    used in HTWSRC.c at least. If it is not defined at all, caching is turned off.
1200  *
1201 */
1202 #ifndef CACHE_FILE_PREFIX
1203 #ifdef unix
1204 #define CACHE_FILE_PREFIX  "/usr/wsrc/"
1205 #endif
1206 #endif
1207 /*
1208  *
1209  *    These are some constants setting the size of buffers used by thread safe versions of
1210  *    some system calls.
1211  *
1212 */
1213 #ifdef HT_REENTRANT
1214 #define HOSTENT_MAX     128
1215 #define CTIME_MAX       26
1216 #endif /* HT_REENTRANT */
1217 /*
1218  *
1219  *    We define some types here so we son't have to worry about it later
1220  *
1221 */
1222 typedef unsigned long ms_t;
1223 /*
1224  *
1225 */
1226 #endif
1227 /*
1228  *
1229  *
1230  *       ___________________________________
1231  *
1232 */
1233