#ifndef donkey_h
#define donkey_h
#include <sys/stat.h>
// #include <stdint.h> // Use inet/arpa instead or other includes with "typedef unsigned char       uint8_t",..
#include <time.h>
#include "cygwin.h"

#ifdef _WIN32
	#define GLOBALCONFIGDIR	".\\"
#else // NOT _WIN32
	#define GLOBALCONFIGDIR	"/etc/"
#endif

#define GLOBALCONFIG	GLOBALCONFIGDIR "cdonkey.conf"

#define LOW_ID 		   0x1000000

#define db_cache_size		2*1024*1024

#define LOG_ZEILE	printf("%s %i\n", __FILE__, __LINE__); fflush(stdout);
// #define LOG_ZEILE ;

extern unsigned int     TCP_CLIENT_COUNT;
extern unsigned int     TCP_SERVER_COUNT;
extern unsigned int 	CLIENT_COUNT;

extern class cServer_udp *userver_listen;

extern char 		*incoming;
extern unsigned char 	 client_hash[16];
extern char 		*client_name;
extern char 		*bind_ip;
extern unsigned  	 my_version;
extern int  		 socket_udp;
extern char 		*control;
extern char 		*completed;
extern char 		*ctrl_pass;
extern char 		*ctrl_user;
extern char		 ZERO[16];
extern bool		 running;
extern int		 serverList_fd;
extern int		 source_fd;
extern double	 	 akt_rate_weight;
extern bool		 run_server;
extern bool		 tcp_search;
extern int       	 udp_search;
extern int 	 	 protocol_logLevel;
extern time_t	 	 currentTime;
extern class sServer    *tcp_server;
extern bool		 use_kademlia;
extern bool		 isTerm;
extern bool		 eMule;
extern bool		 res_server_sources;

struct sPorts {
	uint16_t	server;
	uint16_t	client;
	uint16_t	gui;
	uint16_t	clc;
	uint16_t	emule;
	uint16_t	kademlia;
	uint16_t	web;
	uint16_t	dummy;
	};

struct sPref {
	unsigned	verbose;
	unsigned	ip_trash;
	struct sPorts	ports;
	};

extern struct sPref	pref;

const class sFile *nextFile_search (void);
void	every_sec (void);
void log (unsigned level, const char *msg, ...);
#endif
