示例#1
0
文件: main.c 项目: larsivsi/cbot
void terminate()
{

	log_terminate();
	irc_terminate();
	markov_terminate();
	free_config();

	curl_global_cleanup();
}
示例#2
0
文件: winmain.c 项目: aosm/bind
int     main(int ac, char *av[])
{
    WORD    version = MAKEWORD(2, 0) ;
    WSADATA wsaData ;

    /*
     * check 1st option
     */

    if (ac >= 2) {
        if (strcmp(av[1], "-service") == 0) {
	    serviceRun(ac, av) ;
	    return 0 ;
	}
	if (strcmp(av[1], "-install") == 0) {
	    serviceInstall(ac, av) ;
	    return 0 ;
	}
	if (strcmp(av[1], "-remove") == 0) {
	    serviceRemove(ac, av) ;
	    return 0 ;
	}
    }
    
    /*
     * otherwise run as normal application
     */
     
    if (config_load(ac, av) != TRUE) {
        printf("cannot load configration\n") ;
	return 1 ;
    }
    log_configure(ac, av) ;
    
    if (WSAStartup(version, &wsaData) != 0) {
        printf("cannot startup WinSock\n") ;
	return FALSE ;
    }
    if (server_init(ac, av) != TRUE) {
        printf("cannot initialize server\n") ;
	WSACleanup() ;
	return 1 ;
    }
    
    signal(SIGINT, handler)   ;
    signal(SIGTERM, handler)  ;
    signal(SIGBREAK, handler) ;
    
    printf("Service  Started\n") ;
    
    server_loop() ;
    
    printf("Service Termiating...\n") ;

    server_done() ;

    printf("Service Terminated\n") ;
    
    WSACleanup() ;

    log_terminate() ;
    
    return 0 ;
}