* Copyright 2009 Delft University of Technology. All rights reserved.
*
*/
-#ifndef P2TP_COMPAT_H
-#define P2TP_COMPAT_H
+#ifndef SWIFT_COMPAT_H
+#define SWIFT_COMPAT_H
#ifdef _MSC_VER
-#include "compat/stdint.h"
+typedef unsigned char uint8_t;
+typedef signed char int8_t;
+typedef unsigned short uint16_t;
+typedef short int16_t;
+typedef unsigned int uint32_t;
+typedef int int32_t;
+typedef __int64 int64_t;
+typedef unsigned __int64 uint64_t;
#else
#include <stdint.h>
#endif
+
#ifdef _WIN32
#include <winsock2.h>
#include <sys/stat.h>
#include <io.h>
#else
#include <sys/mman.h>
+#include <arpa/inet.h>
+#include <sys/select.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#endif
+
+#ifndef _WIN32
+typedef int SOCKET;
#endif
+
+#include <unistd.h>
#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
+#include <cstdio>
+#include <cstdlib>
+#include <string>
+
+#ifdef _MSC_VER
+#include "getopt_win.h"
+#else
+#include <getopt.h>
+#endif
#ifdef _WIN32
#define open(a,b,c) _open(a,b,c)
+#endif
+#ifndef S_IRUSR
#define S_IRUSR _S_IREAD
-#define S_IWUSR _S_IWRITE
+#endif
+#ifndef S_IWUSR
+#define S_IWUSR _S_IWRITE
+#endif
+#ifndef S_IRGRP
#define S_IRGRP _S_IREAD
+#endif
+#ifndef S_IROTH
#define S_IROTH _S_IREAD
#endif
-namespace p2tp {
+#ifdef _WIN32
+#define setsockoptptr_t (char*)
+#else
+#define setsockoptptr_t void*
+#endif
+
+
+namespace swift {
/** tint is the time integer type; microsecond-precise. */
typedef int64_t tint;
#define TINT_SEC ((tint)1000000)
#define TINT_MSEC ((tint)1000)
#define TINT_uSEC ((tint)1)
-#define TINT_NEVER ((tint)0x7fffffffffffffffLL)
+#define TINT_NEVER ((tint)0x3fffffffffffffffLL)
size_t file_size (int fd);
#endif
+std::string gettmpdir(void);
+
tint usec_time ();
+bool make_socket_nonblocking(SOCKET s);
+
+bool close_socket (SOCKET sock);
+
+
};
#endif