+/*
+ * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
+ *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
+ */
+
/*
* 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.
- *
*/
+
#ifndef SQUID_OS_MSWINDOWS_H
#define SQUID_OS_MSWINDOWS_H
#if _SQUID_WINDOWS_
+/****************************************************************************
+ *--------------------------------------------------------------------------*
+ * DO *NOT* MAKE ANY CHANGES below here unless you know what you're doing...*
+ *--------------------------------------------------------------------------*
+ ****************************************************************************/
+
/* we target Windows XP and later - some API are missing otherwise */
#if _SQUID_MINGW_
#if WINVER < 0x0501
#endif
#endif /* _SQUID_MINGW_ */
+#if HAVE_DIRECT_H
+#include <direct.h>
+#endif
#if HAVE_FCNTL_H
#include <fcntl.h>
#endif /* HAVE_FCNTL_H */
#define fstat _fstati64
#define lseek _lseeki64
#define memccpy _memccpy
-#define mkdir(p,F) _mkdir((p))
#define mktemp _mktemp
#define snprintf _snprintf
#define stat _stati64
#define vsnprintf _vsnprintf
#endif
-/* CygWin and MinGW compilers need these. Microsoft C Compiler does not. */
-#if _SQUID_MINGW_ || _SQUID_CYGWIN_
-#define mkdir(p,F) mkdir((p))
-#endif
-
/* Microsoft C Compiler and CygWin need these. MinGW does not */
#if defined(_MSC_VER) || _SQUID_CYGWIN_
SQUIDCEXTERN int WIN32_ftruncate(int fd, off_t size);
#define ftruncate WIN32_ftruncate
SQUIDCEXTERN int WIN32_truncate(const char *pathname, off_t length);
#define truncate WIN32_truncate
+#define chdir _chdir
#endif
/* All three compiler systems need these: */
-#define chdir _chdir
#define dup _dup
#define dup2 _dup2
#define fdopen _fdopen
#define getcwd _getcwd
#define getpid _getpid
+#define mkdir(p,F) mkdir((p))
#define pclose _pclose
#define popen _popen
#define putenv _putenv
#define umask _umask
#define unlink _unlink
+#ifndef O_RDONLY
#define O_RDONLY _O_RDONLY
+#endif
+#ifndef O_WRONLY
#define O_WRONLY _O_WRONLY
+#endif
+#ifndef O_RDWR
#define O_RDWR _O_RDWR
+#endif
+#ifndef O_APPEND
#define O_APPEND _O_APPEND
-
+#endif
+#ifndef O_CREAT
#define O_CREAT _O_CREAT
+#endif
+#ifndef O_TRUNC
#define O_TRUNC _O_TRUNC
+#endif
+#ifndef O_EXCL
#define O_EXCL _O_EXCL
-
+#endif
+#ifndef O_TEXT
#define O_TEXT _O_TEXT
+#endif
+#ifndef O_BINARY
#define O_BINARY _O_BINARY
+#endif
+#ifndef O_RAW
#define O_RAW _O_BINARY
+#endif
+#ifndef O_TEMPORARY
#define O_TEMPORARY _O_TEMPORARY
+#endif
+#ifndef O_NOINHERIT
#define O_NOINHERIT _O_NOINHERIT
+#endif
+#ifndef O_SEQUENTIAL
#define O_SEQUENTIAL _O_SEQUENTIAL
+#endif
+#ifndef O_RANDOM
#define O_RANDOM _O_RANDOM
+#endif
+#ifndef O_NDELAY
#define O_NDELAY 0
+#endif
+#ifndef S_IFMT
#define S_IFMT _S_IFMT
+#endif
+#ifndef S_IFDIR
#define S_IFDIR _S_IFDIR
+#endif
+#ifndef S_IFCHR
#define S_IFCHR _S_IFCHR
+#endif
+#ifndef S_IFREG
#define S_IFREG _S_IFREG
+#endif
+#ifndef S_IREAD
#define S_IREAD _S_IREAD
+#endif
+#ifndef S_IWRITE
#define S_IWRITE _S_IWRITE
+#endif
+#ifndef S_IEXEC
#define S_IEXEC _S_IEXEC
-
+#endif
+#ifndef S_IRWXO
#define S_IRWXO 007
+#endif
#if defined(_MSC_VER)
#define S_ISDIR(m) (((m) & _S_IFDIR) == _S_IFDIR)
char **gr_mem; /* group members */
};
-#if !_SQUID_MINGW_
-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 */
-};
-#endif
-
#if !HAVE_GETTIMEOFDAY
struct timezone {
int tz_minuteswest; /* minutes west of Greenwich */
} else
return _open_osfhandle(result, 0);
}
-#define accept(s,a,l) Squid::accept(s,a,l)
+#define accept(s,a,l) Squid::accept(s,a,reinterpret_cast<socklen_t*>(l))
inline int
bind(int s, const struct sockaddr * n, socklen_t l)
} else
return 0;
}
-#define getsockname(s,a,l) Squid::getsockname(s,a,l)
+#define getsockname(s,a,l) Squid::getsockname(s,a,reinterpret_cast<socklen_t*>(l))
inline int
gethostname(char * n, size_t l)
} else
return result;
}
-#define recvfrom(s,b,l,f,r,n) Squid::recvfrom(s,b,l,f,r,n)
+#define recvfrom(s,b,l,f,r,n) Squid::recvfrom(s,b,l,f,r,reinterpret_cast<socklen_t*>(n))
inline int
select(int n, fd_set * r, fd_set * w, fd_set * e, struct timeval * t)
} else
return result;
}
-#define send(s,b,l,f) Squid::send(s,b,l,f)
+#define send(s,b,l,f) Squid::send(s,reinterpret_cast<const char*>(b),l,f)
inline ssize_t
sendto(int s, const void * b, size_t l, int f, const struct sockaddr * t, socklen_t tl)
SQUIDCEXTERN int chroot(const char *dirname);
SQUIDCEXTERN int kill(pid_t, int);
-#if !_SQUID_MINGW_
-SQUIDCEXTERN int statfs(const char *, struct statfs *);
-#endif
SQUIDCEXTERN struct passwd * getpwnam(char *unused);
SQUIDCEXTERN struct group * getgrnam(char *unused);