--------------------- PatchSet 3732 Date: 2002/03/16 09:27:35 Author: serassio Branch: nt-2_5 Tag: (none) Log: Imported Windows patches fron NT-2_3 and Cygwin-svc (second round) Members: include/squid-mswin.h:1.1->1.1.22.1 include/util.h:1.10.14.1->1.10.14.2 lib/win32lib.c:1.1->1.1.32.1 src/stat.c:1.13.10.1->1.13.10.2 --- /dev/null Wed Feb 14 00:55:47 2007 +++ squid/include/squid-mswin.h Wed Feb 14 00:57:27 2007 @@ -0,0 +1,336 @@ +/* + * $Id: squid-mswin.h,v 1.1.22.1 2002/03/16 09:27:35 serassio Exp $ + * + * AUTHOR: Guido Serassio & Andrey Shorin + * + * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ + * ---------------------------------------------------------- + * + * Squid is the result of efforts by numerous individuals from the + * Internet community. Development is led by Duane Wessels of the + * National Laboratory for Applied Network Research and funded by the + * National Science Foundation. Squid is Copyrighted (C) 1998 by + * the Regents of the University of California. Please see the + * COPYRIGHT file for full details. Squid incorporates software + * developed and/or copyrighted by other sources. Please see the + * CREDITS file for full details. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. + * + */ + +/* Some tricks for MS Compilers */ + +#define __STDC__ 1 + +#include "win32-autoconf.h" + +#pragma include_alias(, ) + +#define alloca _alloca +#define chdir _chdir +#define close _close +#define dup _dup +#define dup2 _dup2 +#define fdopen _fdopen +#define fileno _fileno +#define fstat _fstati64 +#define ftruncate WIN32_ftruncate +#define getcwd _getcwd +#define getpid _getpid +#define geteuid() 100 +#define getegid() 100 +#define getrusage WIN32_getrusage +#define ioctl ioctlsocket +#define is_interface_down WIN32_is_interface_down +#define lseek _lseeki64 +#define memccpy _memccpy +#define mkdir(p,m) _mkdir(p) +#define open _open +#define putenv _putenv +#define setgid(g) 100 +#define setmode _setmode +#define setuid(l) 100 +#define sleep(t) Sleep((t)*1000) +#define snprintf _snprintf +#define stat _stati64 +#define strcasecmp _stricmp +#define strdup _strdup +#define strncasecmp _strnicmp +#define tempnam _tempnam +#define truncate WIN32_truncate +#define umask _umask +#define unlink _unlink +#define vsnprintf _vsnprintf + +#define O_RDONLY _O_RDONLY +#define O_BINARY _O_BINARY +#define O_WRONLY _O_WRONLY +#define O_APPEND _O_APPEND +#define O_TRUNC _O_TRUNC +#define O_CREAT _O_CREAT +#define O_TEXT _O_TEXT +#define O_RDWR _O_RDWR + +#define S_IRWXO 007 +#define S_ISDIR(m) (((m) & _S_IFDIR) == _S_IFDIR) + +#define SIGHUP 1 /* hangup */ +#define SIGKILL 9 /* kill (cannot be caught or ignored) */ +#define SIGBUS 10 /* bus error */ +#define SIGPIPE 13 /* write on a pipe with no one to read it */ +#define SIGCHLD 20 /* to parent on child stop or exit */ +#define SIGUSR1 30 /* user defined signal 1 */ +#define SIGUSR2 31 /* user defined signal 2 */ + +#define ushort unsigned short int +#define uid_t int +#define gid_t int +#define mode_t int + +struct passwd { + uid_t pw_uid; + gid_t pw_gid; +}; + +struct group { + gid_t gr_gid; +}; + +struct statfs { + long f_type; /* type of filesystem (see below) */ + long f_bsize; /* optimal transfer block size */ + long f_blocks; /* total data blocks in file system */ + long f_bfree; /* free blocks in fs */ + long f_bavail; /* free blocks avail to non-superuser */ + long f_files; /* total file nodes in file system */ + long f_ffree; /* free file nodes in fs */ + long f_fsid; /* file system id */ + long f_namelen; /* maximum length of filenames */ + long f_spare[6]; /* spare for later */ +}; + +#define CHANGE_FD_SETSIZE 1 +#if CHANGE_FD_SETSIZE && SQUID_MAXFD > DEFAULT_FD_SETSIZE +#define FD_SETSIZE SQUID_MAXFD +#endif + +#include +#include +/* Hack to suppress compiler warnings on FD_SET() & FD_CLR() */ +#pragma warning (push) +#pragma warning (disable:4142) +typedef int SOCKET; +/* prevent inclusion of wingdi.h */ +#define NOGDI +#include +#pragma warning (pop) +#include "readdir.h" + +typedef char *caddr_t; + +#undef FD_CLOSE +#undef FD_OPEN +#undef FD_READ +#undef FD_WRITE +#define EISCONN WSAEISCONN +#define EINPROGRESS WSAEINPROGRESS +#define EWOULDBLOCK WSAEWOULDBLOCK +#define EALREADY WSAEALREADY +#define ETIMEDOUT WSAETIMEDOUT +#define ECONNREFUSED WSAECONNREFUSED +#define ECONNRESET WSAECONNRESET +#define ERESTART WSATRY_AGAIN + +/* internal to CTRLIB */ +#define FPIPE 0x08 /* file handle refers to a pipe */ +typedef struct { + long osfhnd; /* underlying OS file HANDLE */ + char osfile; /* attributes of file (e.g., open in text mode?) */ + char pipech; /* one char buffer for handles opened on pipes */ +#ifdef _MT + int lockinitflag; + CRITICAL_SECTION lock; +#endif /* _MT */ + } ioinfo; +extern _CRTIMP ioinfo * __pioinfo[]; +#define IOINFO_L2E 5 +#define IOINFO_ARRAY_ELTS (1 << IOINFO_L2E) +#define _pioinfo(i) ( __pioinfo[(i) >> IOINFO_L2E] + ((i) & (IOINFO_ARRAY_ELTS - 1)) ) +#define _osfile(i) ( _pioinfo(i)->osfile ) + +#undef h_errno +#define h_errno errno /* we'll set it ourselves */ + +#undef FD_CLR +#define FD_CLR(fd, set) do { \ + u_int __i; \ + SOCKET _sock = _get_osfhandle(fd); \ + for (__i = 0; __i < ((fd_set FAR *)(set))->fd_count ; __i++) { \ + if (((fd_set FAR *)(set))->fd_array[__i] == _sock) { \ + while (__i < ((fd_set FAR *)(set))->fd_count-1) { \ + ((fd_set FAR *)(set))->fd_array[__i] = \ + ((fd_set FAR *)(set))->fd_array[__i+1]; \ + __i++; \ + } \ + ((fd_set FAR *)(set))->fd_count--; \ + break; \ + } \ + } \ +} while(0) + +#undef FD_SET +#define FD_SET(fd, set) do { \ + u_int __i; \ + SOCKET _sock = _get_osfhandle(fd); \ + for (__i = 0; __i < ((fd_set FAR *)(set))->fd_count; __i++) { \ + if (((fd_set FAR *)(set))->fd_array[__i] == (_sock)) { \ + break; \ + } \ + } \ + if (__i == ((fd_set FAR *)(set))->fd_count) { \ + if (((fd_set FAR *)(set))->fd_count < FD_SETSIZE) { \ + ((fd_set FAR *)(set))->fd_array[__i] = (_sock); \ + ((fd_set FAR *)(set))->fd_count++; \ + } \ + } \ +} while(0) + +#undef FD_ISSET +#define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)_get_osfhandle(fd), (fd_set FAR *)(set)) + +extern __declspec(thread) int ws32_result; + +#if !defined(_etext) /* util.c actually */ +#define strerror(e) xbstrerror(e) +#else +#define NOT_NEEDED 1 +#endif + +/* internal to CRTLIB */ +/* used also in win32lib.c */ +extern void __cdecl _dosmaperr(unsigned long oserrno); + +#define socket(f,t,p) \ + (INVALID_SOCKET == ((SOCKET)ws32_result = socket(f,t,p)) ? \ + ((WSAEMFILE == (errno = WSAGetLastError()) ? errno = EMFILE : -1), -1) : \ + (SOCKET)_open_osfhandle(ws32_result,0)) +#define accept(s,a,l) \ + (INVALID_SOCKET == ((SOCKET)ws32_result = accept(_get_osfhandle(s),a,l)) ? \ + ((WSAEMFILE == (errno = WSAGetLastError()) ? errno = EMFILE : -1), -1) : \ + (SOCKET)_open_osfhandle(ws32_result,0)) +#define bind(s,n,l) \ + (SOCKET_ERROR == bind(_get_osfhandle(s),n,l) ? \ + (errno = WSAGetLastError()), -1 : 0) +#define connect(s,n,l) \ + (SOCKET_ERROR == connect(_get_osfhandle(s),n,l) ? \ + (WSAEMFILE == (errno = WSAGetLastError()) ? errno = EMFILE : -1, -1) : 0) +#define listen(s,b) \ + (SOCKET_ERROR == listen(_get_osfhandle(s),b) ? \ + (WSAEMFILE == (errno = WSAGetLastError()) ? errno = EMFILE : -1, -1) : 0) +#define shutdown(s,h) \ + (SOCKET_ERROR == shutdown(_get_osfhandle(s),h) ? \ + (errno = WSAGetLastError()), -1 : 0) +/* don't want to use it - cause an error */ +#define closesocket(s) \ + use_close_instead +#if defined(COMM_SELECT_C) +#define select(n,r,w,e,t) \ + (SOCKET_ERROR == (ws32_result = select(n,r,w,&errfds,t)) ? \ + ((errno = WSAGetLastError()), -1) : ws32_result) +#else +#define select(n,r,w,e,t) \ + (SOCKET_ERROR == (ws32_result = select(n,r,w,e,t)) ? \ + ((errno = WSAGetLastError()), -1) : ws32_result) +#endif +#define recv(s,b,l,f) \ + (SOCKET_ERROR == (ws32_result = recv(_get_osfhandle(s),b,l,f)) ? \ + ((errno = WSAGetLastError()), -1) : ws32_result) +#define recvfrom(s,b,l,f,fr,frl) \ + (SOCKET_ERROR == (ws32_result = recvfrom(_get_osfhandle(s),b,l,f,fr,frl)) ? \ + ((errno = WSAGetLastError()), -1) : ws32_result) +#define send(s,b,l,f) \ + (SOCKET_ERROR == (ws32_result = send(_get_osfhandle(s),b,l,f)) ? \ + ((errno = WSAGetLastError()), -1) : ws32_result) +#define sendto(s,b,l,f,t,tl) \ + (SOCKET_ERROR == (ws32_result = sendto(_get_osfhandle(s),b,l,f,t,tl)) ? \ + ((errno = WSAGetLastError()), -1) : ws32_result) +#define getsockname(s,n,l) \ + (SOCKET_ERROR == getsockname(_get_osfhandle(s),n,l) ? \ + (errno = WSAGetLastError()), -1 : 0) +#define getsockopt(s,l,o,v,n) \ + (Sleep(1), SOCKET_ERROR == getsockopt(_get_osfhandle(s),l,o,v,n) ? \ + (errno = WSAGetLastError()), -1 : 0) +#define setsockopt(s,l,o,v,n) \ + (SOCKET_ERROR == setsockopt(_get_osfhandle(s),l,o,v,n) ? \ + (errno = WSAGetLastError()), -1 : 0) +#define ioctlsocket(s,c,a) \ + (SOCKET_ERROR == ioctlsocket(_get_osfhandle(s),c,a) ? \ + (errno = WSAGetLastError()), -1 : 0) +#define gethostname(n,l) \ + (SOCKET_ERROR == gethostname(n,l) ? \ + (errno = WSAGetLastError()), -1 : 0) +#define gethostbyname(n) \ + (NULL == ((HOSTENT FAR*)ws32_result = gethostbyname(n)) ? \ + (errno = WSAGetLastError()), NULL : (HOSTENT FAR*)ws32_result) +#define getservbyname(n,p) \ + (NULL == ((SERVENT FAR*)ws32_result = getservbyname(n,p)) ? \ + (errno = WSAGetLastError()), NULL : (SERVENT FAR*)ws32_result) +#define gethostbyaddr(a,l,t) \ + (NULL == ((HOSTENT FAR*)ws32_result = gethostbyaddr(a,l,t)) ? \ + (errno = WSAGetLastError()), NULL : (HOSTENT FAR*)ws32_result) + +#if defined(STORE_IO_C) || defined(STORE_DIR_C) || defined(TOOLS_C) || defined(UTIL_C) +#define read _read +#define write _write +#else +extern __declspec(thread) int _so_err; +extern __declspec(thread) int _so_err_siz; +#define read(fd,buf,siz) \ + (_so_err_siz = sizeof(_so_err), \ + getsockopt((fd),SOL_SOCKET,SO_ERROR,(char*)&_so_err,&_so_err_siz) \ + == 0 ? recv((fd),(buf),(siz),0) : _read((fd),(buf),(siz))) +#define write(fd,buf,siz) \ + (_so_err_siz = sizeof(_so_err), \ + getsockopt((fd),SOL_SOCKET,SO_ERROR,(char*)&_so_err,&_so_err_siz) \ + == 0 ? send((fd),(buf),(siz),0) : _write((fd),(buf),(siz))) +#endif + +#if defined(COMM_C) || defined(TOOLS_C) +#undef close +#define close(s) closesocket(_get_osfhandle(s)) +#endif + +#define RUSAGE_SELF 0 /* calling process */ +#define RUSAGE_CHILDREN -1 /* terminated child processes */ + +struct rusage { + struct timeval ru_utime; /* user time used */ + struct timeval ru_stime; /* system time used */ + long ru_maxrss; /* integral max resident set size */ + long ru_ixrss; /* integral shared text memory size */ + long ru_idrss; /* integral unshared data size */ + long ru_isrss; /* integral unshared stack size */ + long ru_minflt; /* page reclaims */ + long ru_majflt; /* page faults */ + long ru_nswap; /* swaps */ + long ru_inblock; /* block input operations */ + long ru_oublock; /* block output operations */ + long ru_msgsnd; /* messages sent */ + long ru_msgrcv; /* messages received */ + long ru_nsignals; /* signals received */ + long ru_nvcsw; /* voluntary context switches */ + long ru_nivcsw; /* involuntary context switches */ +}; Index: squid/include/util.h =================================================================== RCS file: /cvsroot/squid-sf//squid/include/util.h,v retrieving revision 1.10.14.1 retrieving revision 1.10.14.2 diff -u -r1.10.14.1 -r1.10.14.2 --- squid/include/util.h 14 Mar 2002 20:23:41 -0000 1.10.14.1 +++ squid/include/util.h 16 Mar 2002 09:27:35 -0000 1.10.14.2 @@ -1,5 +1,5 @@ /* - * $Id: util.h,v 1.10.14.1 2002/03/14 20:23:41 serassio Exp $ + * $Id: util.h,v 1.10.14.2 2002/03/16 09:27:35 serassio Exp $ * * AUTHOR: Harvest Derived * @@ -44,13 +44,13 @@ #include #endif -#if !defined(SQUIDHOSTNAMELEN) -#ifndef _SQUID_MSWIN_ +#if !defined(SQUIDHOSTNAMELEN) +#ifndef _SQUID_MSWIN_ #include #ifndef _SQUID_NETDB_H_ /* need protection on NEXTSTEP */ #define _SQUID_NETDB_H_ #include -#endif +#endif #endif #if !defined(MAXHOSTNAMELEN) || (MAXHOSTNAMELEN < 128) #define SQUIDHOSTNAMELEN 128 @@ -133,19 +133,19 @@ * Returns the amount of known allocated memory */ int statMemoryAccounted(void); - -/* CygWin & Windows NT Port */ -/* win32lib.c */ -#ifdef _SQUID_MSWIN_ -extern int chroot (const char *); -extern int ftruncate(int, off_t); -extern int gettimeofday(struct timeval * ,void *); -extern int kill(pid_t, int); -extern int statfs(const char *, struct statfs *); -extern int truncate(const char *, off_t); -extern const char * wsastrerror(int); -extern struct passwd *getpwnam(char *); -extern struct group *getgrnam(char *); -#endif + +/* CygWin & Windows NT Port */ +/* win32lib.c */ +#ifdef _SQUID_MSWIN_ +extern int chroot (const char *); +extern int ftruncate(int, off_t); +extern int gettimeofday(struct timeval * ,void *); +extern int kill(pid_t, int); +extern int statfs(const char *, struct statfs *); +extern int truncate(const char *, off_t); +extern const char * wsastrerror(int); +extern struct passwd *getpwnam(char *); +extern struct group *getgrnam(char *); +#endif #endif /* SQUID_UTIL_H */ --- /dev/null Wed Feb 14 00:55:47 2007 +++ squid/lib/win32lib.c Wed Feb 14 00:57:27 2007 @@ -0,0 +1,361 @@ +/* + * $Id: win32lib.c,v 1.1.32.1 2002/03/16 09:27:35 serassio Exp $ + * + * * * * * * * * Legal stuff * * * * * * * + * + * (C) 2001 Guido Serassio , + * inspired by previous work by Romeo Anghelache & Eric Stern. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. + * + */ + +#include "squid.h" + +/* The following code section is part of an EXPERIMENTAL native */ +/* Windows NT/2000 Squid port - Compiles only on MS Visual C++ */ +#if defined(_SQUID_MSWIN_) +#undef assert +#include +#include +#include +#include +#include + +#define OPTERRCOLON (1) +#define OPTERRNF (2) +#define OPTERRARG (3) + +__declspec(thread) int ws32_result; +__declspec(thread) int _so_err; +__declspec(thread) int _so_err_siz; + +char *optarg; +int optreset = 0; +int optind = 1; +int opterr = 1; +int optopt; + +int chroot (const char *dirname) +{ + if (SetCurrentDirectory(dirname)) + return 0; + else + return GetLastError(); +} + +int kill(pid_t pid, int sig) +{ + HANDLE hProcess; + + if (sig == 0) { + if ((hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | + PROCESS_VM_READ, + FALSE, pid)) == NULL) + return -1; + else { + CloseHandle(hProcess); + return 0; + } + } + else return 0; +} + +int gettimeofday( struct timeval * pcur_time,void * tz){ + struct _timeb current; + _ftime(¤t); + pcur_time->tv_sec=current.time; + pcur_time->tv_usec=current.millitm * 1000; + return 0; +} + +int statfs(const char *path, struct statfs *sfs) +{ + char drive[4]; + DWORD spc, bps, freec, totalc; + DWORD vsn, maxlen, flags; + + if (!sfs) + { + errno=EINVAL; + return -1; + } + + strncpy(drive,path,2); + drive[2]='\0'; + strcat(drive,"\\"); + + if (!GetDiskFreeSpace(drive, &spc, &bps, &freec, &totalc)) { + errno=ENOENT; + return -1; + } + if (!GetVolumeInformation(drive, NULL, 0, &vsn, &maxlen, &flags, NULL, 0)) + { + errno=ENOENT; + return -1; + } + sfs->f_type = flags; + sfs->f_bsize = spc*bps; + sfs->f_blocks = totalc; + sfs->f_bfree = sfs->f_bavail = freec; + sfs->f_files = -1; + sfs->f_ffree = -1; + sfs->f_fsid = vsn; + sfs->f_namelen = maxlen; + return 0; +} + +int +WIN32_ftruncate (int fd, off_t size) +{ + HANDLE hfile; + unsigned int curpos; + + if (fd < 0) + return -1; + + hfile = (HANDLE) _get_osfhandle (fd); + curpos = SetFilePointer (hfile, 0, NULL, FILE_CURRENT); + if (curpos == 0xFFFFFFFF + || SetFilePointer (hfile, size, NULL, FILE_BEGIN) == 0xFFFFFFFF + || !SetEndOfFile (hfile)) + { + int error = GetLastError (); + + switch (error) + { + case ERROR_INVALID_HANDLE: + errno = EBADF; + break; + default: + errno = EIO; + break; + } + + return -1; + } + + return 0; +} + +int WIN32_truncate (const char *pathname, off_t length) +{ + int fd; + int res = -1; + + fd = open (pathname, O_RDWR); + + if (fd == -1) + errno=EBADF; + else + { + res = WIN32_ftruncate (fd, length); + close (fd); + } + + return res; +} + + +static int +optiserr(int argc, char * const *argv, int oint, const char *optstr, + int optchr, int err) +{ + if(opterr) + { + fprintf(stderr, "Error in argument %d, char %d: ", oint, optchr+1); + switch(err) + { + case OPTERRCOLON: + fprintf(stderr, ": in flags\n"); + break; + case OPTERRNF: + fprintf(stderr, "option not found %c\n", argv[oint][optchr]); + break; + case OPTERRARG: + fprintf(stderr, "no argument for option %c\n", argv[oint][optchr]); + break; + default: + fprintf(stderr, "unknown\n"); + break; + } + } + optopt = argv[oint][optchr]; + return('?'); +} + + +int +getopt(int argc, char* const *argv, const char *optstr) +{ + static int optchr = 0; + static int dash = 0; /* have already seen the - */ + + char *cp; + + if (optreset) + optreset = optchr = dash = 0; + if (optind >= argc) + return(EOF); + if (!dash && (argv[optind][0] != '-')) + return(EOF); + if (!dash && (argv[optind][0] == '-') && !argv[optind][1]) + { + /* + * use to specify stdin. Need to let pgm process this and + * the following args + */ + return(EOF); + } + if ((argv[optind][0] == '-') && (argv[optind][1] == '-')) + { + /* -- indicates end of args */ + optind++; + return(EOF); + } + if (!dash) + { + assert((argv[optind][0] == '-') && argv[optind][1]); + dash = 1; + optchr = 1; + } + + /* Check if the guy tries to do a -: kind of flag */ + assert(dash); + if(argv[optind][optchr] == ':') + { + dash = 0; + optind++; + return(optiserr(argc, argv, optind-1, optstr, optchr, OPTERRCOLON)); + } + if(!(cp = strchr(optstr, argv[optind][optchr]))) + { + int errind = optind; + int errchr = optchr; + + if(!argv[optind][optchr+1]) + { + dash = 0; + optind++; + } + else + optchr++; + return(optiserr(argc, argv, errind, optstr, errchr, OPTERRNF)); + } + if(cp[1] == ':') + { + dash = 0; + optind++; + if(optind == argc) + return(optiserr(argc, argv, optind-1, optstr, optchr, OPTERRARG)); + optarg = argv[optind++]; + return(*cp); + } + else + { + if(!argv[optind][optchr+1]) + { + dash = 0; + optind++; + } + else + optchr++; + return(*cp); + } + assert(0); + return(0); +} + +static struct _wsaerrtext { + int err; + const char *errconst; + const char *errdesc; +} _wsaerrtext[] = { +WSAEACCES,"WSAEACCES","Permission denied.", +WSAEADDRINUSE,"WSAEADDRINUSE","Address already in use.", +WSAEADDRNOTAVAIL,"WSAEADDRNOTAVAIL","Cannot assign requested address.", +WSAEAFNOSUPPORT,"WSAEAFNOSUPPORT","Address family not supported by protocol family.", +WSAEALREADY,"WSAEALREADY","Operation already in progress.", +WSAECONNABORTED,"WSAECONNABORTED","Software caused connection abort.", +WSAECONNREFUSED,"WSAECONNREFUSED","Connection refused.", +WSAECONNRESET,"WSAECONNRESET","Connection reset by peer.", +WSAEDESTADDRREQ,"WSAEDESTADDRREQ","Destination address required.", +WSAEFAULT,"WSAEFAULT","Bad address.", +WSAEHOSTDOWN,"WSAEHOSTDOWN","Host is down.", +WSAEHOSTUNREACH,"WSAEHOSTUNREACH","No route to host.", +WSAEINPROGRESS,"WSAEINPROGRESS","Operation now in progress.", +WSAEINTR,"WSAEINTR","Interrupted function call.", +WSAEINVAL,"WSAEINVAL","Invalid argument.", +WSAEISCONN,"WSAEISCONN","Socket is already connected.", +WSAEMFILE,"WSAEMFILE","Too many open files.", +WSAEMSGSIZE,"WSAEMSGSIZE","Message too long.", +WSAENETDOWN,"WSAENETDOWN","Network is down.", +WSAENETRESET,"WSAENETRESET","Network dropped connection on reset.", +WSAENETUNREACH,"WSAENETUNREACH","Network is unreachable.", +WSAENOBUFS,"WSAENOBUFS","No buffer space available.", +WSAENOPROTOOPT,"WSAENOPROTOOPT","Bad protocol option.", +WSAENOTCONN,"WSAENOTCONN","Socket is not connected.", +WSAENOTSOCK,"WSAENOTSOCK","Socket operation on nonsocket.", +WSAEOPNOTSUPP,"WSAEOPNOTSUPP","Operation not supported.", +WSAEPFNOSUPPORT,"WSAEPFNOSUPPORT","Protocol family not supported.", +WSAEPROCLIM,"WSAEPROCLIM","Too many processes.", +WSAEPROTONOSUPPORT,"WSAEPROTONOSUPPORT","Protocol not supported.", +WSAEPROTOTYPE,"WSAEPROTOTYPE","Protocol wrong type for socket.", +WSAESHUTDOWN,"WSAESHUTDOWN","Cannot send after socket shutdown.", +WSAESOCKTNOSUPPORT,"WSAESOCKTNOSUPPORT","Socket type not supported.", +WSAETIMEDOUT,"WSAETIMEDOUT","Connection timed out.", +WSAEWOULDBLOCK,"WSAEWOULDBLOCK","Resource temporarily unavailable.", +WSANOTINITIALISED,"WSANOTINITIALISED","Successful WSAStartup not yet performed.", +WSASYSNOTREADY,"WSASYSNOTREADY","Network subsystem is unavailable.", +WSAVERNOTSUPPORTED,"WSAVERNOTSUPPORTED","Winsock.dll version out of range.", +WSAEDISCON,"WSAEDISCON","Graceful shutdown in progress." +}; + +/* + * wsastrerror() - description of WSAGetLastError() + */ +const char * +wsastrerror(int err) +{ + static char xwsaerror_buf[BUFSIZ]; + int i, errind = -1; + + if ( err == 0 ) + return "(0) No error."; + for ( i = 0; i < sizeof(_wsaerrtext)/sizeof(struct _wsaerrtext); i++ ) { + if ( _wsaerrtext[i].err != err ) + continue; + errind = i; + break; + } + if (errind == -1) + snprintf(xwsaerror_buf, BUFSIZ, "(%d) Unknown", err); + else + snprintf(xwsaerror_buf, BUFSIZ, "(%d) %s, %s", err, _wsaerrtext[errind].errconst, _wsaerrtext[errind].errdesc); + return xwsaerror_buf; +} + +struct passwd *getpwnam(char * unused) +{ + static struct passwd pwd = {100}; + return &pwd; +} + +struct group *getgrnam(char * unused) +{ + static struct group grp = {100}; + return &grp; +} + +#endif Index: squid/src/stat.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/stat.c,v retrieving revision 1.13.10.1 retrieving revision 1.13.10.2 diff -u -r1.13.10.1 -r1.13.10.2 --- squid/src/stat.c 14 Mar 2002 20:23:45 -0000 1.13.10.1 +++ squid/src/stat.c 16 Mar 2002 09:27:36 -0000 1.13.10.2 @@ -1,6 +1,6 @@ /* - * $Id: stat.c,v 1.13.10.1 2002/03/14 20:23:45 serassio Exp $ + * $Id: stat.c,v 1.13.10.2 2002/03/16 09:27:36 serassio Exp $ * * DEBUG: section 18 Cache Manager Statistics * AUTHOR: Harvest Derived @@ -459,15 +459,15 @@ runtime = 1.0; storeAppendPrintf(sentry, "Squid Object Cache: Version %s\n", version_string); -#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) - if (WIN32_run_mode == _WIN_SQUID_RUN_MODE_SERVICE) { - storeAppendPrintf(sentry,"\nRunning as %s Windows System Service on %s\n", - WIN32_Service_name, WIN32_OS_string); - storeAppendPrintf(sentry,"Service command line is: %s\n", WIN32_Service_Command_Line); - } - else - storeAppendPrintf(sentry,"Running on %s\n",WIN32_OS_string); -#endif +#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) + if (WIN32_run_mode == _WIN_SQUID_RUN_MODE_SERVICE) { + storeAppendPrintf(sentry,"\nRunning as %s Windows System Service on %s\n", + WIN32_Service_name, WIN32_OS_string); + storeAppendPrintf(sentry,"Service command line is: %s\n", WIN32_Service_Command_Line); + } + else + storeAppendPrintf(sentry,"Running on %s\n",WIN32_OS_string); +#endif storeAppendPrintf(sentry, "Start Time:\t%s\n", mkrfc1123(squid_start.tv_sec)); storeAppendPrintf(sentry, "Current Time:\t%s\n",