#ifndef IDADBG_LOCAL_H
#define IDADBG_LOCAL_H

#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <deque>
#include <map>

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <errno.h>
#include <assert.h>

#ifndef _WIN32
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#endif

#include <pin.H>
#include <portability.H>

#ifdef _WIN32

namespace WINDOWS
{
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <WinUser.h>
#include <Ws2tcpip.h>
};

#endif

#ifdef _WIN32

# if _MSC_VER
#   define snprintf _snprintf
#   define bzero(b,len) (memset((b), '\0', (len)), (void) 0)
#   define bcopy(b1,b2,len) (memmove((b2), (b1), (len)), (void) 0)
# endif

# ifdef  _WIN64
  typedef signed __int64 ssize_t;
# else
  typedef signed int ssize_t;
# endif

typedef WINDOWS::SOCKET PIN_SOCKET;

#define socket          WINDOWS::socket
#define pin_htons       WINDOWS::htons
#define pin_bind        WINDOWS::bind
#define pin_listen      WINDOWS::listen
#define pin_accept(s, addr, addrlen) WINDOWS::accept(s, (WINDOWS::sockaddr *)addr, addrlen)
#define pin_setsockopt(s, level, optname, optval, optlen) WINDOWS::setsockopt(s, level, optname, (const char*)optval, optlen)

#define pin_clilen      WINDOWS::clilen
#define pin_sockaddr    WINDOWS::sockaddr
#define pin_socklen_t   WINDOWS::socklen_t
#define pin_sockaddr_in WINDOWS::sockaddr_in

#else

#define PIN_SOCKET      int
#define pin_accept      accept
#define pin_setsockopt  setsockopt
#define pin_sockaddr_in sockaddr_in
#define pin_htons       htons
#define pin_bind        bind
#define pin_listen      listen
#define pin_clilen      clilen
#define pin_sockaddr    sockaddr
#define pin_socklen_t   socklen_t

#endif

#endif
