Exemplo n.º 1
0
int main(int argc, char* argv[])
{
	if(argc!=3) { print_usage(); exit(0); }
	if(sock_str2addr(argv[2], &sa)==NULL) { print_usage(); exit(0); }

	if(strcmp(argv[1], "client")!=0 && strcmp(argv[1], "server")!=0) { print_usage(); exit(0); }

	sock_init();
	fdwatch_init();
	mempool_init();
	threadpool_init(1);
	network_init(20000);

	if(strcmp(argv[1], "client")==0) {
		client_do();
	} else {
		server_do();
	}

	network_final();
	threadpool_final();
	mempool_final();
	fdwatch_final();
	sock_final();

	return 0;
}
Exemplo n.º 2
0
irc_session_t * irc_create_session(irc_callbacks_t * callbacks) {
    irc_session_t * session = calloc(1, sizeof (irc_session_t));

    if (!session)
        return 0;

    session->sock = -1;

    if (libirc_mutex_init(&session->mutex_session)
            || libirc_mutex_init(&session->mutex_dcc)) {
        free(session);
        return 0;
    }

    session->dcc_last_id = 1;
    session->dcc_timeout = 60;

    memcpy(&session->callbacks, callbacks, sizeof (irc_callbacks_t));

    if (!session->callbacks.event_ctcp_req)
        session->callbacks.event_ctcp_req = libirc_event_ctcp_internal;

    fdwatch_init();   
    session->line_parser = create_line_parser();
    line_parser_set_session(session->line_parser, session);

    memset(session->incoming_buf, 0, LIBIRC_BUFFER_SIZE);
    memset(session->outgoing_buf, 0, LIBIRC_BUFFER_SIZE);

    return session;
}
Exemplo n.º 3
0
int csmng_init()
{
	sock_init();
	fdwatch_init();

	if(!sock_str2addr(appbox_args_get("listen", "0.0.0.0:1980"), &listen_ep))
		return ERR_INVALID_PARAMETER;

	strcpy(mapfile, appbox_args_get("map", "csmng.map"));
	strcpy(histroyfile, appbox_args_get("histroy", "file://[email protected]"));
	console_log = log_open(histroyfile);
	if(console_log==NULL) {
		printf("can't open histroy file");
	}

	return ERR_NOERROR;
}
Exemplo n.º 4
0
int pre_server_startup(void)
{
    pvpgn_greeting();
    if (oom_setup() < 0) {
	eventlog(eventlog_level_error, __FUNCTION__, "OOM init failed");
	return STATUS_OOM_FAILURE;
    }
    if (storage_init(prefs_get_storage_path()) < 0) {
	eventlog(eventlog_level_error, "pre_server_startup", "storage init failed");
	return STATUS_STORAGE_FAILURE;
    }
    if (psock_init() < 0) {
	eventlog(eventlog_level_error, __FUNCTION__, "could not initialize socket functions");
	return STATUS_PSOCK_FAILURE;
    }
    if (support_check_files(prefs_get_supportfile()) < 0) {
        eventlog(eventlog_level_error, "pre_server_startup","some needed files are missing");
	eventlog(eventlog_level_error, "pre_server_startup","please make sure you installed the supportfiles in %s",prefs_get_filedir());
	return STATUS_SUPPORT_FAILURE;
    }
    if (anongame_maplists_create() < 0) {
	eventlog(eventlog_level_error, "pre_server_startup", "could not load maps");
	return STATUS_MAPLISTS_FAILURE;
    }
    if (anongame_matchlists_create() < 0) {
	eventlog(eventlog_level_error, "pre_server_startup", "could not create matchlists");
	return STATUS_MATCHLISTS_FAILURE;
    }
    if (fdwatch_init(prefs_get_max_connections())) {
	eventlog(eventlog_level_error, __FUNCTION__, "error initilizing fdwatch");
	return STATUS_FDWATCH_FAILURE;
    }
    connlist_create();
    gamelist_create();
    timerlist_create();
    server_set_hostname();
    channellist_create();
    if (helpfile_init(prefs_get_helpfile())<0)
	eventlog(eventlog_level_error,__FUNCTION__,"could not load helpfile");
    ipbanlist_create();
    if (ipbanlist_load(prefs_get_ipbanfile())<0)
	eventlog(eventlog_level_error,__FUNCTION__,"could not load IP ban list");
    if (adbannerlist_create(prefs_get_adfile())<0)
	eventlog(eventlog_level_error,__FUNCTION__,"could not load adbanner list");
    if (autoupdate_load(prefs_get_mpqfile())<0)
	eventlog(eventlog_level_error,__FUNCTION__,"could not load autoupdate list");
    if (versioncheck_load(prefs_get_versioncheck_file())<0)
	eventlog(eventlog_level_error,__FUNCTION__,"could not load versioncheck list");
   if (news_load(prefs_get_newsfile())<0)
	eventlog(eventlog_level_error,__FUNCTION__,"could not load news list");
    watchlist_create();
    output_init();
    attrlayer_init();
    accountlist_create();
    if (ladder_createxptable(prefs_get_xplevel_file(),prefs_get_xpcalc_file())<0) {
        eventlog(eventlog_level_error, "pre_server_startup", "could not load WAR3 xp calc tables");
        return STATUS_WAR3XPTABLES_FAILURE;
    }
    ladders_init();
    ladders_load_accounts_to_ladderlists();
    ladder_update_all_accounts();
    if (characterlist_create("")<0)
	eventlog(eventlog_level_error,__FUNCTION__,"could not load character list");
    if (prefs_get_track()) /* setup the tracking mechanism */
        tracker_set_servers(prefs_get_trackserv_addrs());
    if (command_groups_load(prefs_get_command_groups_file())<0)
	eventlog(eventlog_level_error,__FUNCTION__,"could not load command_groups list");
    aliasfile_load(prefs_get_aliasfile());
    if (trans_load(prefs_get_transfile(),TRANS_BNETD)<0)
	eventlog(eventlog_level_error,__FUNCTION__,"could not load trans list");
    tournament_init(prefs_get_tournament_file());
    anongame_infos_load(prefs_get_anongame_infos_file());
    clanlist_load();
    teamlist_load();
    if (realmlist_create(prefs_get_realmfile())<0)
	eventlog(eventlog_level_error,__FUNCTION__,"could not load realm list");
    topiclist_load(prefs_get_topicfile());
    return 0;
}