#ifndef BIN_H
#define BIN_H
#include <assert.h>
-#ifdef _MSC_VER
+#ifdef _WIN32
// To avoid complaints about std::max. Appears to work in VS2008
#undef min
#undef max
#ifndef BIN64_H
#define BIN64_H
#include <assert.h>
-#ifdef _MSC_VER
+#ifdef _WIN32
#include "compat/stdint.h"
#else
#include <stdint.h>
#include <iostream>\r
#include "compat/hirestimeofday.h"\r
\r
-#ifndef _MSC_VER\r
+#ifndef _WIN32\r
#include <sys/time.h>\r
#endif\r
\r
}\r
\r
\r
-#ifdef _MSC_VER\r
+#ifdef _WIN32\r
#include <windows.h>\r
#include <sys/timeb.h>\r
\r
\r
// ARNOTODO: move to p2tp.cpp\r
\r
-#ifdef _MSC_VER\r
+#ifdef _WIN32\r
static WSADATA _WSAData;\r
#endif\r
\r
void LibraryInit(void)\r
{\r
-#ifdef _MSC_VER\r
+#ifdef _WIN32\r
// win32 requires you to initialize the Winsock DLL with the desired\r
// specification version\r
WORD wVersionRequested;\r
#ifndef HIRESTIMEOFDAY_H\r
#define HIRESTIMEOFDAY_H\r
\r
-#ifdef _MSC_VER\r
+#ifdef _WIN32\r
#include "compat/stdint.h"\r
#include <windows.h>\r
#else\r
static HiResTimeOfDay* Instance();\r
\r
private:\r
-#ifdef _MSC_VER\r
+#ifdef _WIN32\r
tint epochstart; // in usec\r
LARGE_INTEGER epochcounter;\r
LARGE_INTEGER last;\r
#include "util.h"\r
#include <vector>\r
\r
-#ifdef _MSC_VER\r
+#ifdef _WIN32\r
#include <windows.h>\r
#include <Tchar.h>\r
#endif\r
\r
std::string gettmpdir(void)\r
{\r
-#ifdef _MSC_VER\r
+#ifdef _WIN32\r
DWORD result = ::GetTempPath(0, _T(""));\r
if (result == 0)\r
throw std::runtime_error("Could not get system temp path");\r
*/
#include <iostream>
-#ifdef _MSC_VER
+#ifdef _WIN32
#include <winsock2.h>
typedef int socklen_t;
#else
length = recvfrom (sock, (char *)buf, MAXDGRAMSZ, 0,
(struct sockaddr*)&(addr), &addrlen);
if (length<0)
-#ifdef _MSC_VER
+#ifdef _WIN32
PLOG(ERROR)<<"on recv" << WSAGetLastError() << "\n";
#else
PLOG(ERROR)<<"on recv";
if (FD_ISSET(sockets[i],&bases))
return sockets[i];
} else if (sel<0)
-#ifdef _MSC_VER
+#ifdef _WIN32
PLOG(ERROR)<<"select fails" << WSAGetLastError() << "\n";
#else
PLOG(ERROR)<<"select fails";
PLOG(ERROR)<<"socket fails";
return -1;
}
-#ifdef _MSC_VER
+#ifdef _WIN32
u_long enable = 1;
ioctlsocket(fd, FIONBIO, &enable);
if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (const char *)&sndbuf, sizeof(int)) != 0 ) {
}
void Datagram::Close (int sock) { // remove from fd_set
-#ifdef _MSC_VER
+#ifdef _WIN32
if (closesocket(sock)!=0)
#else
if (::close(sock)!=0)
std::string sock2str (struct sockaddr_in addr) {
char ipch[32];
-#ifdef _MSC_VER
+#ifdef _WIN32
//Vista only: InetNtop(AF_INET,&(addr.sin_addr),ipch,32);
// IPv4 only:
struct in_addr inaddr;
#ifndef DATAGRAM_H
#define DATAGRAM_H
-#ifdef _MSC_VER
+#ifdef _WIN32
#include "compat/stdint.h"
#include <winsock2.h>
#include "compat/unixio.h"
namespace p2tp {
#define MAXDGRAMSZ 1400
-#ifndef _MSC_VER
+#ifndef _WIN32
#define INVALID_SOCKET -1
#endif
#include "hashtree.h"
#include <openssl/sha.h>
#include <string.h>
-#ifndef _MSC_VER
+#ifndef _WIN32
#include <sys/mman.h>
#endif
#include <sys/stat.h>
#ifndef P2TP_H
#define P2TP_H
-#ifdef _MSC_VER
+#ifdef _WIN32
#include "compat/stdint.h"
#else
#include <stdint.h>
PiecePicker* picker_;
/** File for keeping the Merkle hash tree. */
int hashfd_;
-#ifdef _MSC_VER
+#ifdef _WIN32
HANDLE hashmaphandle_;
#endif
/** Merkle hash tree: root */
* Copyright 2009 Delft University of Technology. All rights reserved.
*
*/
-#ifdef _MSC_VER
+#ifdef _WIN32
#include "compat/unixio.h"
#else
#include <sys/mman.h>
fstat(hashfd_, &hash_file_st);
if ( hash_file_st.st_size != expected_size_ )
ftruncate(hashfd_, expected_size_);
-#ifdef _MSC_VER
+#ifdef _WIN32
HANDLE hashhandle = (HANDLE)_get_osfhandle(hashfd_);
hashmaphandle_ = CreateFileMapping(hashhandle,
NULL,
FileTransfer::~FileTransfer ()
{
-#ifdef _MSC_VER
+#ifdef _WIN32
UnmapViewOfFile(hashes_);
CloseHandle(hashmaphandle_);
#else