#ifndef _COMMDEF_H_
#define _COMMDEF_H_

#if !defined(__solaris__) && defined(__sun__)
#define __solaris__
#endif


#ifdef _WIN32
#ifdef ARCLIB_EXPORTS
#define ARCLIB_API
#else
#define ARCLIB_API
#endif

#ifndef NULL
#define NULL	0
#endif


#ifndef int8_t
typedef signed char		int8_t;
#endif
#ifndef u_int8_t
typedef unsigned char	u_int8_t;
#endif
#ifndef int16_t
typedef signed short	int16_t;
#endif
#ifndef u_int16_t
typedef unsigned short	u_int16_t;
#endif
#ifndef int32_t
typedef signed int		int32_t;
#endif
#ifndef u_int32_t
typedef unsigned int	u_int32_t;
#endif
#ifndef int64_t
typedef long long		int64_t;
#endif
#ifndef u_int64_t
typedef unsigned long long	u_int64_t;
#endif
#endif	// end of _WIN32

#if defined(__linux__) || defined(__FreeBSD__) || defined(__sun__) || defined(__APPLE__)
#define	__unix_like__			1
#include <stdio.h>   //Standard input/output definitions
#include <string.h>  //String function definitions
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/wait.h> //waitpid() and wait()
#ifdef __linux__
	#include <linux/serial.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
#include <fcntl.h>   // File control definitions
#include <errno.h>   // Error number definitions
#include <termios.h> // POSIX terminal control definitions
#include <unistd.h>  // fork()
#include <netinet/in.h>
#include <arpa/inet.h>	// inet_addr(...)
#include <netdb.h>
#include <strings.h>
#include <syslog.h>
#endif	// end of defined(__linux__) || defined(__FreeBSD__) || defined(__sun__) || defined(__APPLE__)

#ifdef __solaris__
typedef unsigned char	u_int8_t;
typedef unsigned short	u_int16_t;
typedef unsigned long	u_int32_t;
typedef unsigned long long	u_int64_t;
#endif



#ifdef _DOS
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <memory.h>
#include <io.h>
#include <fcntl.h>
#include <time.h>
#ifndef int8_t
typedef signed char		int8_t;
#endif
#ifndef u_int8_t
typedef unsigned char	u_int8_t;
#endif
#ifndef int16_t
typedef signed int		int16_t;
#endif
#ifndef u_int16_t
typedef unsigned int	u_int16_t;
#endif
#ifndef int32_t
typedef signed long		int32_t;
#endif
#ifndef u_int32_t
typedef unsigned long	u_int32_t;
#endif
#endif // end of _DOS

#ifndef _WIN32
#ifndef IN
#define IN
#endif
#ifndef OUT
#define OUT
#endif
#ifndef TRUE
#define TRUE		1
#endif
#ifndef FALSE
#define FALSE		0
#endif
#ifndef BOOL
#define BOOL		int8_t
#endif
#ifndef CHAR
#define CHAR		int8_t
#endif
#ifndef UCHAR
#define UCHAR		u_int8_t
#endif
#ifndef BYTE
#define BYTE		u_int8_t
#endif
#ifndef PBYTE
#define PBYTE		u_int8_t *
#endif
#ifndef WORD
#define WORD		u_int16_t
#endif
#ifndef DWORD
#define DWORD		u_int32_t
#endif
#ifndef LONG
#define LONG		int32_t
#endif
#ifndef ULONG
#define ULONG		uint32_t
#endif
#ifndef LVOID
#define LVOID		void *
#endif
#ifndef LPVOID
#define LPVOID		void *
#endif
#ifndef HANDLE
#define HANDLE		int
#endif
#ifndef SOCKET
#define SOCKET		int
#endif
#ifndef SOCKET_ERROR
#define SOCKET_ERROR	-1
#endif
#ifndef INVALID_SOCKET
#define INVALID_SOCKET	-1
#endif
#endif	// end of _WIN32
#endif	//end of _COMMDEF_H_
