📄 wwwsys.h
字号:
/* W3C Sample Code Library libwww System Dependencies! System Dependencies!*//*** (c) COPYRIGHT MIT 1995.** Please first read the full copyright statement in the file COPYRIGH.*//*This file makes up for the differencies in the systems and platforms supportedby libwww. On Unix, it is a question of usingautoconf to figure out what environment we are in. This is done by runningthe configure script which creates a wwwconf.h file. Thisconfiguration include file contains a large set of macro definitions tellingwhat features we have and don't have. On platforms not supported by autoconf(Windows, Mac, VMS etc.) you will find the information normally containedin the wwwconf.h file directly included below. Thesecond part of this file uses all the informationthat we either have from the wwwconf.h file or directly coded and actuallydoes the includes etc. o Unix o Microsoft Windows Win32 API o Macintosh o Vax VMS This module is a part of the W3C SampleCode Library.( Authors) TBL Tim Berners-Lee, W3 project, CERN, <timbl@w3.org> EvA Eelco van Asperen <evas@cs.few.eur.nl> MA Marc Andreesen NCSA MD Mark Donszelmann <duns@vxcern.cern.ch> AT Aleksandar Totic <atotic@ncsa.uiuc.edu> SCW Susan C. Weber <sweber@kyle.eitech.com> HF Henrik Frystyk, <frystyk@w3.org> CLB Charlie Brooks, <cbrooks@osf.org>( History:) 22 Feb 91 Written (TBL) as part of the WWW library. 16 Jan 92 PC code from (EvA) 22 Apr 93 Merged diffs bits from xmosaic release 29 Apr 93 Windows/NT code from (SCW) 29 Sep 93 Mar 96 CLB - changed SLEEP() macro for Windows/NT MSC compiler added BOOLEAN_DEFINED macro to avoid duplicate definitions in HUtils.h changed netread() macros to support reading from stdin,etc. as well as sockets. (Required for linemode browser to work). Henrik Changed to support autoconf for Unix*/#ifndef SYSDEP_H#define SYSDEP_H/*! Platform Specific Stuff!. Unix.We rely on autoconf to do the dirty job. If you have any changhesthen please add them to the configurescript*/#ifdef HAVE_CONFIG_H#include <wwwconf.h>#endif/*. Microsoft Windows Win32 API.Help provided by Eric Prud'hommeaux, Susan C. Weber<sweber@kyle.eitech.com>, Paul Hounslow<P.M.Hounslow@reading.ac.uk>, and a lot of other PC people.*/#if defined(_WINDOWS) || defined(_CONSOLE)#define WWW_MSWINDOWS#endif#if defined(_WINDOWS) && !defined (_CONSOLE)#define WWW_WIN_WINDOW#endif#if defined(_CONSOLE)#define WWW_WIN_CONSOLE#endif#ifdef WWW_MSWINDOWS#include <windows.h>#include <io.h>#include <process.h>#include <winsock.h>#include "windows/config.h"#define NETREAD(s,b,l) recv((s),(b),(l),0)#define NETWRITE(s,b,l) send((s),(b),(l),0)#define NETCLOSE(s) closesocket(s)#define IOCTL(s,c,a) ioctlsocket(s,c, (long *) a)#define MKDIR(a,b) mkdir((a))#define REMOVE(a) remove((a))#define DEFAULT_SUFFIXES "."#ifndef _CONSOLE#define NO_STDIO#endif#define SOCKET SOCKET /* WinSocks socket descriptor */#define INVSOC INVALID_SOCKET /* WinSocks invalid socket */#define DESIRED_WINSOCK_VERSION 0x0101 /* we'd like winsock ver 1.1... */#define MINIMUM_WINSOCK_VERSION 0x0101 /* ...but we'll take ver 1.1 :) *//*( File and Directory Access)These next defintions are because the UNIX stuff is not supplied with BC4(Paul Hounslow <P.M.Hounslow@reading.ac.uk>)*/#define NO_UNIX_IO#define _IFMT 0170000 /* type of file */#define _IFDIR 0040000 /* directory */#define _IFCHR 0020000 /* character special */#define _IFBLK 0060000 /* block special */#define _IFREG 0100000 /* regular */#define _IFLNK 0120000 /* symbolic link */#define _IFSOCK 0140000 /* socket */#define _IFIFO 0010000 /* fifo */#define S_ISUID 0004000 /* set user id on execution */#define S_ISGID 0002000 /* set group id on execution */#define S_ISVTX 0001000 /* save swapped text even after use */#ifdef S_IREAD#undef S_IREAD#define S_IREAD 0000400 /* read permission, owner */#endif#ifdef S_IWRITE#undef S_IWRITE#define S_IWRITE 0000200 /* write permission, owner */#endif#ifdef S_IEXEC#undef S_IEXEC#define S_IEXEC 0000100 /* execute/search permission, owner */#endif#define S_ENFMT 0002000 /* enforcement-mode locking */#ifdef S_IFMT#undef S_IFMT#define S_IFMT _IFMT#endif#ifdef S_IDIR#undef S_IDIR#define S_IFDIR _IFDIR#endif#ifdef S_IFCHR#undef S_IFCHR#define S_IFCHR _IFCHR#endif#ifdef S_IBLK#undef S_IBLK#define S_IFBLK _IFBLK#endif#ifdef S_IREG#undef S_IREG#define S_IFREG _IFREG#endif#define S_IFLNK _IFLNK#ifdef S_IFIFO#undef S_IFIFO#define S_IFIFO _IFIFO#endif#define S_IRWXU 0000700 /* rwx, owner */#define S_IRUSR 0000400 /* read permission, owner */#define S_IWUSR 0000200 /* write permission, owner */#define S_IXUSR 0000100 /* execute/search permission, owner */#define S_IRWXG 0000070 /* rwx, group */#define S_IRGRP 0000040 /* read permission, group */#define S_IWGRP 0000020 /* write permission, grougroup */#define S_IXGRP 0000010 /* execute/search permission, group */#define S_IRWXO 0000007 /* rwx, other */#define S_IROTH 0000004 /* read permission, other */#define S_IWOTH 0000002 /* write permission, other */#define S_IXOTH 0000001 /* execute/search permission, other */#define S_ISREG(m) (((m)&_IFMT) == _IFREG)#define DIR_SEPARATOR#define DIR_SEPARATOR_CHAR '\\'#define DIR_SEPARATOR_STR "\\"/*( Errno and Return Codes)Winsock has its own errno codes and it returns them through WSAGetLastError().However, it does also support BSD error codes, so we make a compromise. WSAdefinitions moved from _WIN32 ifdef by EGP*/#define socerrno WSAGetLastError()#define ERRNO_DONE/*Return code for socket functions. We can't use -1 as return value*/#define EWOULDBLOCK WSAEWOULDBLOCK#define EINPROGRESS WSAEINPROGRESS#define ECONNREFUSED WSAECONNREFUSED#define ETIMEDOUT WSAETIMEDOUT#define ENETUNREACH WSAENETUNREACH#define EHOSTUNREACH WSAEHOSTUNREACH#define EHOSTDOWN WSAEHOSTDOWN#define EISCONN WSAEISCONN//#define EINVAL WSAEINVAL#define ECONNRESET WSAECONNRESET#define ECONNABORTED WSAECONNABORTED#define ESHUTDOWN WSAESHUTDOWN/* Some compilers do only define WIN32 and NOT _WINDOWS */#define NO_GROUPS#ifdef _WIN32#define MKDIR(a,b) mkdir((a)) /* CLB NT has mkdir, but only one arg */#define SLEEP(n) Sleep((n)*1000)#else#define MKDIR(a,b) _mkdir((a)) /* CLB NT has mkdir, but only one arg */#endif /* WIN32 */#endif /* WWW_MSWINDOWS *//*. Macintosh.( mingw32 - Minimalist GNU for Windows)A bit like Cygwin, except it uses the native Windows API, which meansthe programs do not need the huge Cygwin DLL to run.Patch by Richard Atterer <richard@atterer.net>, October 2001*/#ifdef __MINGW32__#include <winsock2.h>#define WWW_MSWINDOWS/* #define WWW_WIN_CONSOLE */#define WWW_WIN_WINDOW/* #define WWW_WIN_ASYNC *//* #define WWW_WIN_DLL */#ifndef _WINSOCKAPI_#define _WINSOCKAPI_#endif#define NETREAD(s,b,l) recv((s),(b),(l),0)#define NETWRITE(s,b,l) send((s),(b),(l),0)#define NETCLOSE(s) closesocket(s)#define IOCTL(s,c,a) ioctlsocket(s,c, (long *) a)#define MKDIR(a,b) mkdir(a)#define REMOVE(a) remove((a))#define DEFAULT_SUFFIXES "."#define SOCKET SOCKET /* WinSocks socket descriptor */#define INVSOC INVALID_SOCKET /* WinSocks invalid socket */#define DESIRED_WINSOCK_VERSION 0x0101 /* we'd like winsock ver 1.1... */#define MINIMUM_WINSOCK_VERSION 0x0101 /* ...but we'll take ver 1.1 :) */#define DIR_SEPARATOR#define DIR_SEPARATOR_CHAR '\\'#define DIR_SEPARATOR_STR "\\"#define socerrno WSAGetLastError()#define ERRNO_DONE/* Taken from the WIN32 stuff above. */#define EWOULDBLOCK WSAEWOULDBLOCK#define EINPROGRESS WSAEINPROGRESS#define ECONNREFUSED WSAECONNREFUSED#define ETIMEDOUT WSAETIMEDOUT#define ENETUNREACH WSAENETUNREACH#define EHOSTUNREACH WSAEHOSTUNREACH#define EHOSTDOWN WSAEHOSTDOWN#define EISCONN WSAEISCONN/*#define EINVAL WSAEINVAL*/#define ECONNRESET WSAECONNRESET#define ECONNABORTED WSAECONNABORTED#define ESHUTDOWN WSAESHUTDOWN/* The configure.in script is wrong to default to #define GETGROUPS_T int */#ifdef GETGROUPS_T#undef GETGROUPS_T#endif#define HT_LSTAT stat#endif /* __MINGW32__ *//*. Macintosh.We have two environments on Macintosh: Codeworrior and MPV.( Metrowerks Codewarrior 6)Metrowerks Codewarrior is one development environment on the Mac. We areusing GUSI (1.5.9) by Matthias Neeracher <neeri@iis.ee.ethz.ch> forour socket lib. You can find more information about theGUSI Library fromSwitzerland.Compiles on PPC. Should compile on 68K.August 31, 1995 by Steven T. Roussey <sroussey@eng.uci.edu> (STR).and jeff@macalot.com (Jeff Dripps). Thanks a bunch!*/#ifdef __MWERKS__#include <gusi.h>#include <dirent.h>#include <errno.h>#include <sys/errno.h>#include <sioux.h>#define INCLUDES_DONE#define TCP_INCLUDES_DONE#define GUSI /* Identifies changes made for GUSI */#undef HAVE_GETDOMAINNAME /* STR */#undef HAVE_GETPASS#undef HAVE_GETWD#define HAVE_GETCWD#define USE_DIRENT#define NO_GROUPS#define GOT_READ_DIR#undef HAVE_TIMEZONE /* STR */#define NO_GMTOFF#define HAVE_STRERROR#define HAVE_GETHOSTNAME#define d_ino d_fileno /* backward compatibility */#define SLEEP(n) GUSIDefaultSpin( SP_SLEEP, n/60)#define MKDIR(a,b) mkdir(a)#define HAVE_STRFTIME // added JTD:5/1/96#define HAVE_MKTIME // added JTD:5/1/96#define HAVE_STRCHR // added JTD:5/1/96#define STDC_HEADERS // added JTD:5/1/96#define HAVE_MEMCPY // added JTD:5/1/96#define TTY_IS_SELECTABLE // added JTD:5/1/96#define HAVE_READDIR // added JTD:5/1/96#define HAVE_DIRENT_INO // added JTD:5/1/96#define HAVE_DIRENT_H // added JTD:5/1/96#endif/*( MPW)MPW is one development environment on the Mac.This entry was created by Aleksandar Totic (atotic@ncsa.uiuc.edu) this fileis compatible with sockets package released by NCSA. One major conflict isthat this library redefines write/read/etc as macros. In some of HTML codethese macros get executed when they should not be. Such files should defineNO_SOCKET_DEFS on top. This is a temporary hack.*/#ifdef applec /* MPW */#undef HAVE_SYSTEM#define DEBUG /* Can't put it on the CC command line */#define NO_UNIX_IO /* getuid() missing */#undef HAVE_GETPID /* getpid() does not exist */#define NO_GETWD /* getwd() does not exist */#define NETCLOSE s_close /* Routine to close a TCP-IP socket */#define NETREAD s_read /* Routine to read from a TCP-IP socket */#define NETWRITE s_write /* Routine to write to a TCP-IP socket */#define _ANSI_SOURCE#define GUI#define LINEFEED 10#define ANON_FTP_HOSTNAME#ifndef NO_SOCKET_DEFS#include <MacSockDefs.h>#endif /* NO_SOCKET_DEFS */#include <socket.ext.h>#include <string.h>#endif /* applec MPW *//*. VAX/VMS.Under VMS, there are many versions of TCP-IP. Define one if you do not useDigital's UCX product: UCX DEC's "Ultrix connection" (default) WIN_TCP From Wollongong, now GEC software. MULTINET From SRI, now from TGV Inv. DECNET Cern's TCP socket emulation over DECnetThe last three do not interfere with the unix i/o library, and so they needspecial calls to read, write and close sockets. In these cases the socketnumber is a VMS channel number, so we make the @@@ HORRIBLE @@@ assumptionthat a channel number will be greater than 10 but a unix file descriptor
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -