1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747
|
/*
* $Id: squid_mswin.h,v 1.2 2006/09/09 15:29:59 serassio Exp $
*
* AUTHOR: Andrey Shorin <tolsty@tushino.com>
* AUTHOR: Guido Serassio <serassio@squid-cache.org>
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
* ----------------------------------------------------------
*
* Squid is the result of efforts by numerous individuals from
* the Internet community; see the CONTRIBUTORS file for full
* details. Many organizations have provided support for Squid's
* development; see the SPONSORS file for full details. Squid is
* Copyrighted (C) 2001 by the Regents of the University of
* California; see the COPYRIGHT file for full details. Squid
* incorporates software developed and/or copyrighted by other
* sources; 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.
*
*/
#define ACL WindowsACL
#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
#if _MSC_VER == 1400
#define _CRT_SECURE_NO_DEPRECATE
#pragma warning( disable : 4290 )
#pragma warning( disable : 4996 )
#endif
#endif
#if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64
# define __USE_FILE_OFFSET64 1
#endif
#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef unsigned __int64 uint64_t;
typedef long pid_t;
#if defined __USE_FILE_OFFSET64
typedef int64_t off_t;
typedef uint64_t ino_t;
#else
typedef long off_t;
typedef unsigned long ino_t;
#endif
#define INT64_MAX _I64_MAX
#define INT64_MIN _I64_MIN
#define PRId64 "I64d"
#include "default_config_file.h"
/* Some tricks for MS Compilers */
#define __STDC__ 1
#pragma include_alias(<dirent.h>, <direct.h>)
#define THREADLOCAL __declspec(thread)
#elif defined(__GNUC__) /* gcc environment */
#define THREADLOCAL __attribute__((section(".tls")))
#endif
#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
#define alloca _alloca
#endif
#define chdir _chdir
#define dup _dup
#define dup2 _dup2
#define fdopen _fdopen
#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
#define fileno _fileno
#define fstat _fstati64
#endif
#define ftruncate WIN32_ftruncate
#define getcwd _getcwd
#define getpid _getpid
#define getrusage WIN32_getrusage
#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
#define lseek _lseeki64
#define memccpy _memccpy
#define mkdir(p) _mkdir(p)
#define mktemp _mktemp
#endif
#define pclose _pclose
#define pipe WIN32_pipe
#define popen _popen
#define putenv _putenv
#define setmode _setmode
#define sleep(t) Sleep((t)*1000)
#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
#define snprintf _snprintf
#define stat _stati64
#define strcasecmp _stricmp
#define strdup _strdup
#define strlwr _strlwr
#define strncasecmp _strnicmp
#define tempnam _tempnam
#endif
#define truncate WIN32_truncate
#define umask _umask
#define unlink _unlink
#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
#define vsnprintf _vsnprintf
#endif
#define O_RDONLY _O_RDONLY
#define O_WRONLY _O_WRONLY
#define O_RDWR _O_RDWR
#define O_APPEND _O_APPEND
#define O_CREAT _O_CREAT
#define O_TRUNC _O_TRUNC
#define O_EXCL _O_EXCL
#define O_TEXT _O_TEXT
#define O_BINARY _O_BINARY
#define O_RAW _O_BINARY
#define O_TEMPORARY _O_TEMPORARY
#define O_NOINHERIT _O_NOINHERIT
#define O_SEQUENTIAL _O_SEQUENTIAL
#define O_RANDOM _O_RANDOM
#define O_NDELAY 0
#define S_IFMT _S_IFMT
#define S_IFDIR _S_IFDIR
#define S_IFCHR _S_IFCHR
#define S_IFREG _S_IFREG
#define S_IREAD _S_IREAD
#define S_IWRITE _S_IWRITE
#define S_IEXEC _S_IEXEC
#define S_IRWXO 007
#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
#define S_ISDIR(m) (((m) & _S_IFDIR) == _S_IFDIR)
#endif
#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 */
typedef unsigned short int ushort;
typedef int uid_t;
typedef int gid_t;
struct passwd {
char *pw_name; /* user name */
char *pw_passwd; /* user password */
uid_t pw_uid; /* user id */
gid_t pw_gid; /* group id */
char *pw_gecos; /* real name */
char *pw_dir; /* home directory */
char *pw_shell; /* shell program */
};
struct group {
char *gr_name; /* group name */
char *gr_passwd; /* group password */
gid_t gr_gid; /* group id */
char **gr_mem; /* group members */
};
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 */
};
struct timezone
{
int tz_minuteswest; /* minutes west of Greenwich */
int tz_dsttime; /* type of dst correction */
};
#define CHANGE_FD_SETSIZE 1
#if CHANGE_FD_SETSIZE && SQUID_MAXFD > DEFAULT_FD_SETSIZE
#define FD_SETSIZE SQUID_MAXFD
#endif
#include <stddef.h>
#include <process.h>
#include <errno.h>
#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
/* Hack to suppress compiler warnings on FD_SET() & FD_CLR() */
#pragma warning (push)
#pragma warning (disable:4142)
#endif
/* prevent inclusion of wingdi.h */
#define NOGDI
#include <ws2spi.h>
#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
#pragma warning (pop)
#include "readdir.h"
#else
#include <io.h>
#include <stdlib.h>
#include <sys/types.h>
#endif
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 ENOTCONN WSAENOTCONN
#define ERESTART WSATRY_AGAIN
#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 = fd_table[fd].win32.handle; \
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 = fd_table[fd].win32.handle; \
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) Win32__WSAFDIsSet(fd, (fd_set FAR *)(set))
/* internal to Microsoft CRTLIB */
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;
#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 )
#define _osfhnd(i) ( _pioinfo(i)->osfhnd )
#define FOPEN 0x01 /* file handle open */
#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
SQUIDCEXTERN _CRTIMP ioinfo * __pioinfo[];
SQUIDCEXTERN int __cdecl _free_osfhnd(int);
#elif defined(__MINGW32__) /* MinGW environment */
__MINGW_IMPORT ioinfo * __pioinfo[];
SQUIDCEXTERN int _free_osfhnd(int);
#endif
SQUIDCEXTERN THREADLOCAL int ws32_result;
#define strerror(e) WIN32_strerror(e)
#ifdef __cplusplus
inline
int close(int fd)
{
char l_so_type[sizeof(int)];
int l_so_type_siz = sizeof(l_so_type);
SOCKET sock = _get_osfhandle(fd);
if (::getsockopt(sock, SOL_SOCKET, SO_TYPE, l_so_type, &l_so_type_siz) == 0){
int result = 0;
if (closesocket(sock) == SOCKET_ERROR) {
errno = WSAGetLastError();
result = 1;
}
_free_osfhnd(fd);
_osfile(fd) = 0;
return result;
}
else
return _close(fd);
}
#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
#ifndef _S_IREAD
#define _S_IREAD 0x0100
#endif
#ifndef _S_IWRITE
#define _S_IWRITE 0x0080
#endif
inline
int open(const char *filename, int oflag, int pmode = 0)
{
return _open(filename, oflag, pmode & (_S_IREAD | _S_IWRITE));
}
#endif
inline
int read(int fd, void * buf, size_t siz)
{
char l_so_type[sizeof(int)];
int l_so_type_siz = sizeof(l_so_type);
SOCKET sock = _get_osfhandle(fd);
if (::getsockopt(sock, SOL_SOCKET, SO_TYPE, l_so_type, &l_so_type_siz) == 0)
return ::recv(sock, (char FAR *) buf, (int)siz, 0);
else
return _read(fd, buf, (unsigned int)siz);
}
inline
int write(int fd, const void * buf, size_t siz)
{
char l_so_type[sizeof(int)];
int l_so_type_siz = sizeof(l_so_type);
SOCKET sock = _get_osfhandle(fd);
if (::getsockopt(sock, SOL_SOCKET, SO_TYPE, l_so_type, &l_so_type_siz) == 0)
return ::send(sock, (char FAR *) buf, siz, 0);
else
return _write(fd, buf, siz);
}
inline
char *index(const char *s, int c)
{
return (char *)strchr(s,c);
}
namespace Squid {
inline
int accept(int s, struct sockaddr * a, int * l)
{
SOCKET result;
if ((result = ::accept(_get_osfhandle(s), a, l)) == INVALID_SOCKET) {
if (WSAEMFILE == (errno = WSAGetLastError()))
errno = EMFILE;
return -1;
}
else
return _open_osfhandle(result, 0);
}
inline
int bind(int s, struct sockaddr * n, int l)
{
if (::bind(_get_osfhandle(s),n,l) == SOCKET_ERROR) {
errno = WSAGetLastError();
return -1;
}
else
return 0;
}
inline
int connect(int s, const struct sockaddr * n, int l)
{
if (::connect(_get_osfhandle(s),n,l) == SOCKET_ERROR) {
if (WSAEMFILE == (errno = WSAGetLastError()))
errno = EMFILE;
return -1;
}
else
return 0;
}
inline
struct hostent * gethostbyname (const char *n)
{
HOSTENT FAR * result;
if ((result = ::gethostbyname(n)) == NULL)
errno = WSAGetLastError();
return result;
}
#define gethostbyname(n) Squid::gethostbyname(n)
inline
SERVENT FAR* getservbyname (const char * n, const char * p)
{
SERVENT FAR * result;
if ((result = ::getservbyname(n, p)) == NULL)
errno = WSAGetLastError();
return result;
}
#define getservbyname(n,p) Squid::getservbyname(n,p)
inline
HOSTENT FAR * gethostbyaddr(const char * a, int l, int t)
{
HOSTENT FAR * result;
if ((result = ::gethostbyaddr(a, l, t)) == NULL)
errno = WSAGetLastError();
return result;
}
#define gethostbyaddr(a,l,t) Squid::gethostbyaddr(a,l,t)
inline
int getsockname(int s, struct sockaddr * n, int * l)
{
if ((::getsockname(_get_osfhandle(s), n, l)) == SOCKET_ERROR) {
errno = WSAGetLastError();
return -1;
}
else
return 0;
}
inline
int gethostname(char * n, size_t l)
{
if ((::gethostname(n, l)) == SOCKET_ERROR) {
errno = WSAGetLastError();
return -1;
}
else
return 0;
}
#define gethostname(n,l) Squid::gethostname(n,l)
inline
int getsockopt(int s, int l, int o, void * v, int * n)
{
Sleep(1);
if ((::getsockopt(_get_osfhandle(s), l, o,(char *) v, n)) == SOCKET_ERROR) {
errno = WSAGetLastError();
return -1;
}
else
return 0;
}
/* Simple ioctl() emulation */
inline
int ioctl(int s, int c, void * a)
{
if ((::ioctlsocket(_get_osfhandle(s), c, (u_long FAR *)a)) == SOCKET_ERROR) {
errno = WSAGetLastError();
return -1;
}
else
return 0;
}
inline
int ioctlsocket(int s, long c, u_long FAR * a)
{
if ((::ioctlsocket(_get_osfhandle(s), c, a)) == SOCKET_ERROR) {
errno = WSAGetLastError();
return -1;
}
else
return 0;
}
inline
int listen(int s, int b)
{
if (::listen(_get_osfhandle(s), b) == SOCKET_ERROR) {
if (WSAEMFILE == (errno = WSAGetLastError()))
errno = EMFILE;
return -1;
}
else
return 0;
}
#define listen(s,b) Squid::listen(s,b)
inline
int recv(int s, void * b, size_t l, int f)
{
int result;
if ((result = ::recv(_get_osfhandle(s), (char *)b, l, f)) == SOCKET_ERROR) {
errno = WSAGetLastError();
return -1;
}
else
return result;
}
inline
int recvfrom(int s, void * b, size_t l, int f, struct sockaddr * fr, int * fl)
{
int result;
if ((result = ::recvfrom(_get_osfhandle(s), (char *)b, l, f, fr, fl)) == SOCKET_ERROR) {
errno = WSAGetLastError();
return -1;
}
else
return result;
}
inline
int select(int n, fd_set * r, fd_set * w, fd_set * e, struct timeval * t)
{
int result;
if ((result = ::select(n,r,w,e,t)) == SOCKET_ERROR) {
errno = WSAGetLastError();
return -1;
}
else
return result;
}
#define select(n,r,w,e,t) Squid::select(n,r,w,e,t)
inline
int send(int s, const void * b, size_t l, int f)
{
int result;
if ((result = ::send(_get_osfhandle(s), (char *)b, l, f)) == SOCKET_ERROR) {
errno = WSAGetLastError();
return -1;
}
else
return result;
}
inline
int sendto(int s, const void * b, size_t l, int f, const struct sockaddr * t, int tl)
{
int result;
if ((result = ::sendto(_get_osfhandle(s), (char *)b, l, f, t, tl)) == SOCKET_ERROR) {
errno = WSAGetLastError();
return -1;
}
else
return result;
}
inline
int setsockopt(SOCKET s, int l, int o, const char * v, int n)
{
SOCKET socket;
socket = ((s == INVALID_SOCKET) ? s : (SOCKET)_get_osfhandle((int)s));
if (::setsockopt(socket, l, o, v, n) == SOCKET_ERROR) {
errno = WSAGetLastError();
return -1;
}
else
return 0;
}
#define setsockopt(s,l,o,v,n) Squid::setsockopt(s,l,o,v,n)
inline
int shutdown(int s, int h)
{
if (::shutdown(_get_osfhandle(s),h) == SOCKET_ERROR) {
errno = WSAGetLastError();
return -1;
}
else
return 0;
}
inline
int socket(int f, int t, int p)
{
SOCKET result;
if ((result = ::socket(f, t, p)) == INVALID_SOCKET) {
if (WSAEMFILE == (errno = WSAGetLastError()))
errno = EMFILE;
return -1;
}
else
return _open_osfhandle(result, 0);
}
#define socket(f,t,p) Squid::socket(f,t,p)
inline
int WSAAsyncSelect(int s, HWND h, unsigned int w, long e)
{
if (::WSAAsyncSelect(_get_osfhandle(s), h, w, e) == SOCKET_ERROR) {
errno = WSAGetLastError();
return -1;
}
else
return 0;
}
#undef WSADuplicateSocket
inline
int WSADuplicateSocket(int s, DWORD n, LPWSAPROTOCOL_INFO l)
{
#ifdef UNICODE
if (::WSADuplicateSocketW(_get_osfhandle(s), n, l) == SOCKET_ERROR) {
#else
if (::WSADuplicateSocketA(_get_osfhandle(s), n, l) == SOCKET_ERROR) {
#endif
errno = WSAGetLastError();
return -1;
}
else
return 0;
}
#undef WSASocket
inline
int WSASocket(int a, int t, int p, LPWSAPROTOCOL_INFO i, GROUP g, DWORD f)
{
SOCKET result;
#ifdef UNICODE
if ((result = ::WSASocketW(a, t, p, i, g, f)) == INVALID_SOCKET) {
#else
if ((result = ::WSASocketA(a, t, p, i, g, f)) == INVALID_SOCKET) {
#endif
if (WSAEMFILE == (errno = WSAGetLastError()))
errno = EMFILE;
return -1;
}
else
return _open_osfhandle(result, 0);
}
} /* namespace Squid */
#else /* #ifdef __cplusplus */
#define connect(s,n,l) \
(SOCKET_ERROR == connect(_get_osfhandle(s),n,l) ? \
(WSAEMFILE == (errno = WSAGetLastError()) ? errno = EMFILE : -1, -1) : 0)
#define gethostbyname(n) \
(NULL == ((HOSTENT FAR*)(ws32_result = (int)gethostbyname(n))) ? \
(errno = WSAGetLastError()), (HOSTENT FAR*)NULL : (HOSTENT FAR*)ws32_result)
#define gethostname(n,l) \
(SOCKET_ERROR == gethostname(n,l) ? \
(errno = WSAGetLastError()), -1 : 0)
#define recv(s,b,l,f) \
(SOCKET_ERROR == (ws32_result = recv(_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 select(n,r,w,e,t) \
(SOCKET_ERROR == (ws32_result = select(n,r,w,e,t)) ? \
(errno = WSAGetLastError()), -1 : ws32_result)
#define socket(f,t,p) \
(INVALID_SOCKET == ((SOCKET)(ws32_result = (int)socket(f,t,p))) ? \
((WSAEMFILE == (errno = WSAGetLastError()) ? errno = EMFILE : -1), -1) : \
(SOCKET)_open_osfhandle(ws32_result,0))
#define write _write /* Needed in util.c */
#define open _open /* Needed in win32lib.c */
#endif /* #ifdef __cplusplus */
#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 */
};
#undef ACL
SQUIDCEXTERN int chroot (const char *);
SQUIDCEXTERN int ftruncate(int, off_t);
SQUIDCEXTERN int gettimeofday(struct timeval * ,void *);
SQUIDCEXTERN int kill(pid_t, int);
SQUIDCEXTERN int statfs(const char *, struct statfs *);
SQUIDCEXTERN int truncate(const char *, off_t);
SQUIDCEXTERN const char * wsastrerror(int);
SQUIDCEXTERN struct passwd *getpwnam(char *);
SQUIDCEXTERN struct group *getgrnam(char *);
SQUIDCEXTERN uid_t geteuid(void);
SQUIDCEXTERN uid_t getuid(void);
SQUIDCEXTERN int setuid(uid_t);
SQUIDCEXTERN int seteuid(uid_t);
SQUIDCEXTERN gid_t getgid(void);
SQUIDCEXTERN gid_t getegid(void);
SQUIDCEXTERN int setgid(gid_t);
SQUIDCEXTERN int setegid(gid_t);
SQUIDCEXTERN const char *WIN32_strerror(int);
SQUIDCEXTERN void WIN32_maperror(unsigned long);
|