www.pudn.com > RadiusSrv.rar > main.cpp, change:2004-03-24,size:1754b


#include <windows.h> 
#include "RadiusSrv.h" 
#include "stdio.h" 
#include "conio.h" 
#include "..\common\log.h" 
#include <time.h> 
 
#define VERSION_NUMBER   "1.1.000" 
 
BOOL CtrlHandler(DWORD fdwCtrlType)  
{  
	switch (fdwCtrlType)  
	{  
		// Handle the CTRL+C signal.  
		 
	case CTRL_C_EVENT:  
		 
		Beep(1000, 1000);  
		return TRUE;  
		 
		// CTRL+CLOSE: confirm that the user wants to exit.  
		 
	case CTRL_CLOSE_EVENT:  
		LOG(2) ("Begin to stop RadiusSrv...");  
		RadiusSrvDestroy(); 
		WSACleanup(); 
		return FALSE;  
		 
		// Pass other signals to the next handler.  
		 
	case CTRL_BREAK_EVENT:  
		 
	case CTRL_LOGOFF_EVENT:  
		 
	case CTRL_SHUTDOWN_EVENT:  
		 
	default:  
		 
		return FALSE;  
	}  
}  
 
int main(int argc, char *argv[]) 
{ 
#ifdef _DEMO 
	printf("                     VOIP验证系统服务器 v%s Demo\n", VERSION_NUMBER); 
 
#endif 
#ifndef _DEMO 
	printf("                     VOIP验证系统服务器 v%s\n", VERSION_NUMBER); 
#endif 
	time_t curTime; 
	time((time_t *) &curTime); 
 
	printf("                                     build at %s,%s\n", __DATE__, __TIME__); 
 
	printf("\n"); 
	printf(""); 
	printf(""); 
	printf(""); 
	printf(""); 
	WSADATA wsaData; 
	WORD version = MAKEWORD(2, 2); 
	if (WSAStartup(version, &wsaData) != 0) 
		return false; 
 
//	initArgs(argc, argv);	 
	if(RadiusSrvInit()) 
	{ 
		//set console hook 
		BOOL fSuccess; 
		fSuccess = SetConsoleCtrlHandler( 
			(PHANDLER_ROUTINE) CtrlHandler, // handler function  
			TRUE); // add to list  
		if (! fSuccess)  
			LOG(1) ("Could not set control handler\n");  
 
		RadiusSrvStart(); 
	} 
	RadiusSrvDestroy(); 
	WSACleanup(); 
	printf("there are some error when start the server!Press any key to exit..."); 
	getchar(); 
	return false; 
}