#ifndef _PROTO_DEFS
#define _PROTO_DEFS

#ifdef WIN32
#include <time.h>  // for mktime()
#include <basetsd.h>  // for UINT32/INT32 types
#include <winsock2.h>  // for struct timeval definition
const char PROTO_PATH_DELIMITER = '\\';
#else
#include <sys/types.h> // must include this first to make SGI's compiler happy
#include <limits.h>    // for PATH_MAX
const char PROTO_PATH_DELIMITER = '/';
#endif // UNIX

#ifdef SIMULATE
#ifdef NS2
#include "scheduler.h"
inline void ProtoSystemTime(struct timeval& theTime)
{
    double now = Scheduler::instance().clock();
    theTime.tv_sec = (unsigned long)(now);
    theTime.tv_usec = (unsigned long)((now - theTime.tv_sec) * 1.0e06);
}
#endif // NS2

#ifdef OPNET
#include "opnet.h"
inline void ProtoSystemTime(struct timeval& theTime)
{
    double current_time = op_sim_time();
    theTime.tv_sec = (unsigned long)(current_time);
    theTime.tv_usec = (unsigned long)((current_time - theTime.tv_sec) * 1.0e06);
}
#endif // OPNET

#else

#ifdef WIN32
inline void ProtoSystemTime(struct timeval& theTime)
{
    //epochTime = time for 00:00:0.00 1 Jan, 1970
    ULARGE_INTEGER epochTime;
    epochTime.HighPart = 27111902;
    epochTime.LowPart = 3577643008;
    FILETIME ft;
#ifdef _WIN32_WCE
    SYSTEMTIME st;
    GetSystemTime(&st);
    SystemTimeToFileTime(&st, &ft);
#else
    GetSystemTimeAsFileTime(&ft);
#endif // if/else _WIN32_WCE
    ULARGE_INTEGER usecTotal;
    usecTotal.HighPart = ft.dwHighDateTime;
    usecTotal.LowPart = ft.dwLowDateTime;
    usecTotal.QuadPart -= epochTime.QuadPart;
    usecTotal.QuadPart /= 10;  // convert to microseconds
    theTime.tv_sec = (long)(usecTotal.QuadPart / 1000000);
    theTime.tv_usec = (long)(usecTotal.QuadPart - theTime.tv_sec * 1000000);
}

#else

#include <sys/types.h> // must include this first to make SGI's compiler happy
#include <sys/time.h>  // for UNIX gettimeofday(), etc
inline void ProtoSystemTime(struct timeval& theTime)
{
    struct timezone tz;
    gettimeofday(&theTime, &tz);
}

#endif  // if/else WIN32/UNIX

#endif // if/else SIMULATE

#ifndef PATH_MAX
#ifdef WIN32
#define PATH_MAX MAX_PATH
#else
#define PATH_MAX _POSIX_PATH_MAX
#endif // if/else WIN32/UNIX
#endif // !PATH_MAX


#ifndef NULL
#define NULL 0
#endif // NULL

#ifndef WIN32
typedef long INT32;
typedef unsigned long UINT32;
#endif // !WIN32
typedef signed char INT8;
typedef unsigned char UINT8;
typedef short INT16;
typedef unsigned short UINT16;

#ifndef MAX
#define MAX(X,Y) ((X>Y)?(X):(Y))
#endif //!MAX
#ifndef MIN
#define MIN(X,Y) ((X<Y)?(X):(Y))
#endif //!MIN

#endif // _PROTO_DEFS
