#ifndef _MAIN_H
#define _MAIN_H


#include <stdio.h>
#include <stdlib.h>
#ifndef WIN32
#include <string.h>
#endif
//#include <wchar.h>

#ifndef NULL
#define NULL 0
#endif

#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif


typedef unsigned char BYTE, *PBYTE;
typedef char          *PSTR;
typedef const char    *PCSTR;
typedef void          *PVOID;

#define TL_SESSION	64
#define TL_FILENAME 4096
#define MAX_PATH	256

struct get_transfer_log{
	char	volumeid[32];
	char	sessionkey[TL_SESSION + 1];	/* null string is always error */
	time_t	startdate;					/* 0 is ignore date value */
	time_t	enddate;					/* 0 is ignore date value */
	char	is_delete;					/* Y,y is delete when get, Otherwise is not delete */
	char	direction;					/* U,u is upload, D,d is download, Otherwise both */
};

struct transfer_log_data {
	int total_message_number;
	int current_message_number;			/* start with 1 */
	char sessionid[TL_SESSION + 1];
	char filename[TL_FILENAME + 1];
	unsigned long long length;
	time_t startdate;
	time_t enddate;
	unsigned short respcode;			/* http response code */
	char direction;
};


#ifdef WIN32

#include <winsock2.h>

#else

#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <ctype.h>
#include <netdb.h>
#include <errno.h>

typedef int SOCKET;
typedef int __int32;
typedef long long __int64;
typedef char BOOL;
typedef struct sockaddr SOCKADDR;

#define INVALID_SOCKET  -1
#define SOCKET_ERROR    -1

#define closesocket(a) close(a)
#define GetLastError() errno

void SetLastError(int nErrCode);

#endif

time_t  get_time_from_sntp();

#endif
