www.pudn.com > BTSERVER.rar > bnbt.h


// 
// Copyright (C) 2003 Trevor Hogan 
// 
 
// Trinity Edition Modified Source File 
 
#ifndef RainbowBT_H 
 #define RainbowBT_H 
 
#include  
 
#ifdef WIN32 
 #define WIN32_LEAN_AND_MEAN 
#endif 
 
// 
// SOLARIS USERS - IF YOUR SYSTEM IS LITTLE ENDIAN, REMOVE THE NEXT 3 LINES 
//  see sha1.h 
// 
 
#if defined( __APPLE__ ) || defined( Solaris ) 
 #define RainbowBT_BIG_ENDIAN 
#endif 
 
#ifdef FreeBSD 
 #include  
#endif 
 
#include  
 
// large integers 
 
#ifdef WIN32 
 typedef __int64 int64; 
 typedef unsigned __int64 uint64; 
#else 
 typedef long long int64; 
 typedef unsigned long long uint64; 
#endif 
 
// stl 
 
#ifdef WIN32 
 #pragma warning( disable : 4786 ) 
#endif 
 
#include  
#include  
#include  
#include  
#include  
 
using namespace std; 
 
// path seperator 
 
#ifdef WIN32 
 #define PATH_SEP '\\' 
#else 
 #define PATH_SEP '/' 
#endif 
 
// this fixes MSVC loop scoping issues 
 
/* 
 
#ifdef WIN32 
 #define for if( 0 ) { } else for 
#endif 
 
*/ 
 
// time stuff 
 
unsigned long GetTime( ); 
 
#ifdef WIN32 
 #define MILLISLEEP( x ) Sleep( x ) 
#else 
 #define MILLISLEEP( x ) usleep( ( x ) * 1000 ) 
#endif 
 
// mutex 
 
#ifdef WIN32 
 #include  
 #include  
#else 
 #include  
#endif 
 
class CMutex 
{ 
public: 
#ifdef WIN32 
	void Initialize( ) { InitializeCriticalSection( &cs ); } 
	void Destroy( ) { DeleteCriticalSection( &cs ); } 
	void Claim( ) { EnterCriticalSection( &cs ); } 
	void Release( ) { LeaveCriticalSection( &cs ); } 
 
	CRITICAL_SECTION cs; 
#else 
	void Initialize( ) { pthread_mutex_init( &mtx, NULL ); } 
	void Destroy( ) { pthread_mutex_destroy( &mtx ); } 
	void Claim( ) { pthread_mutex_lock( &mtx ); } 
	void Release( ) { pthread_mutex_unlock( &mtx ); } 
 
	pthread_mutex_t mtx; 
#endif 
}; 
 
// network 
 
#ifdef WIN32 
 #include  
#else 
 #include  
 #include  
 #include  
 #include  
 #include  
 #include  
 #include  
 
 #include  
 
 #define SOCKET int 
 
 #define INVALID_SOCKET -1 
 #define SOCKET_ERROR -1 
 
 #define closesocket close 
 
 extern int GetLastError( ); 
#endif 
 
#ifdef __APPLE__ 
 typedef int socklen_t; 
 typedef int sockopt_len_t; 
#endif 
 
#ifdef FreeBSD 
 #include  
#endif 
 
#ifdef Solaris 
 #ifndef INADDR_NONE 
  #define INADDR_NONE -1 
 #endif 
#endif 
 
#ifndef MSG_NOSIGNAL 
 #define MSG_NOSIGNAL 0 
#endif 
 
class CAtom; 
class CAtomInt; 
class CAtomLong; 
class CAtomString; 
class CAtomList; 
class CAtomDicti; 
 
class CServer; 
class CTracker; 
class CClient; 
 
class CLink; 
class CLinkServer; 
 
struct request_t 
{ 
	struct sockaddr_in sin; 
	string strMethod; 
	string strURL; 
	map mapParams; 
	map mapHeaders; 
	map mapCookies; 
}; 
 
struct response_t 
{ 
	string strCode; 
	multimap mapHeaders; 
	string strContent; 
	bool bCompressOK; 
}; 
 
// current version 
 
#define RainbowBT_VER "1.0" 
 
#ifdef WIN32 
// The Trinity Edition - Modification Begins 
// Removes the NT Service Name Definition; Defined elsewhere 
/* Original Source Code: 
 #define RainbowBT_SERVICE_NAME "RainbowBT Service" 
*/ 
// ---------------------------------- End of Modification 
#endif 
 
extern CServer *gpServer; 
extern CLink *gpLink; 
extern CLinkServer *gpLinkServer; 
extern CMutex gmtxOutput; 
extern string gstrErrorLogDir; 
extern string gstrErrorLogFile; 
extern FILE *gpErrorLog; 
extern string gstrAccessLogDir; 
extern string gstrAccessLogFile; 
extern FILE *gpAccessLog; 
extern unsigned long giErrorLogCount; 
extern unsigned long giAccessLogCount; 
extern int giFlushInterval; 
extern bool gbDebug; 
extern int giMaxConns; 
extern string gstrStyle; 
extern string gstrCharSet; 
extern string gstrRealm; 
// The Trinity Edition - Addition Begins 
// Sets the NT Service Name variable as a global variable 
extern string gstrNTServiceName; 
// Sets the "RainbowBT_alt_signup_url" variable as a global variable 
extern string gstrAltSignupURL; 
// Sets the "RainbowBT_tracker_title" variable as a global variable 
extern string gstrTrackerTitle; 
// Sets the "RainbowBT_external_js" variable as a global variable 
extern string gstrExternalJavascript; 
// ----------------------------------- End of Addition 
 
// this is basically the old main( ), but it's here to make the NT Service code neater 
 
extern int RainbowBTmain( ); 
 
#endif