⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 connection.c

📁 打魔兽战网的都知道他是什么
💻 C
📖 第 1 页 / 共 5 页
字号:
    }        return c->socket.real_local_port;}extern unsigned int conn_get_game_addr(t_connection const * c){    if (!c)    {        eventlog(eventlog_level_error,__FUNCTION__,"got NULL connection");        return 0;    }        return c->socket.udp_addr;}extern int conn_set_game_addr(t_connection * c, unsigned int game_addr){    if (!c)    {        eventlog(eventlog_level_error,__FUNCTION__,"got NULL connection");        return -1;    }        c->socket.udp_addr = game_addr;    return 0;}extern unsigned short conn_get_game_port(t_connection const * c){    if (!c)    {        eventlog(eventlog_level_error,__FUNCTION__,"got NULL connection");        return 0;    }        return c->socket.udp_port;}extern int conn_set_game_port(t_connection * c, unsigned short game_port){    if (!c)    {        eventlog(eventlog_level_error,__FUNCTION__,"got NULL connection");        return -1;    }        c->socket.udp_port = game_port;    return 0;}extern void conn_set_host(t_connection * c, char const * host){    if (!c)    {        eventlog(eventlog_level_error,__FUNCTION__,"got NULL connection");        return;    }    if (!host)    {        eventlog(eventlog_level_error,__FUNCTION__,"got NULL host");        return;    }        if (c->protocol.client.host)	xfree((void *)c->protocol.client.host); /* avoid warning */    c->protocol.client.host = xstrdup(host);}extern void conn_set_user(t_connection * c, char const * user){    if (!c)    {        eventlog(eventlog_level_error,__FUNCTION__,"got NULL connection");        return;    }    if (!user)    {        eventlog(eventlog_level_error,__FUNCTION__,"got NULL user");        return;    }    if (c->protocol.client.user)	xfree((void *)c->protocol.client.user); /* avoid warning */    c->protocol.client.user = xstrdup(user);}extern void conn_set_owner(t_connection * c, char const * owner){    if (!c)    {        eventlog(eventlog_level_error,__FUNCTION__,"got NULL connection");        return;    }    if (!owner)    {        eventlog(eventlog_level_error,__FUNCTION__,"got NULL owner");        return;    }        if (c->protocol.client.owner)	xfree((void *)c->protocol.client.owner); /* avoid warning */    c->protocol.client.owner = xstrdup(owner);}extern const char * conn_get_user(t_connection const * c){    if (!c) {	eventlog(eventlog_level_error,__FUNCTION__,"got NULL connection");	return NULL;    }    return c->protocol.client.user;}extern const char * conn_get_owner(t_connection const * c){    if (!c) {	eventlog(eventlog_level_error,__FUNCTION__,"got NULL connection");	return NULL;    }    return c->protocol.client.owner;}extern void conn_set_cdkey(t_connection * c, char const * cdkey){    if (!c)    {        eventlog(eventlog_level_error,__FUNCTION__,"got NULL connection");        return;    }    if (!cdkey)    {        eventlog(eventlog_level_error,__FUNCTION__,"got NULL cdkey");        return;    }    if (c->protocol.client.cdkey)	xfree((void *)c->protocol.client.cdkey); /* avoid warning */    c->protocol.client.cdkey = xstrdup(cdkey);}extern char const * conn_get_clientexe(t_connection const * c){    if (!c)    {        eventlog(eventlog_level_error,__FUNCTION__,"got NULL connection");        return NULL;    }    if (!c->protocol.client.clientexe)	return "";    return c->protocol.client.clientexe;}extern void conn_set_clientexe(t_connection * c, char const * clientexe){    char const * temp;        if (!c)    {        eventlog(eventlog_level_error,__FUNCTION__,"got NULL connection");        return;    }    if (!clientexe)    {        eventlog(eventlog_level_error,__FUNCTION__,"got NULL clientexe");        return;    }        temp = xstrdup(clientexe);    if (c->protocol.client.clientexe)	xfree((void *)c->protocol.client.clientexe); /* avoid warning */    c->protocol.client.clientexe = temp;}extern char const * conn_get_clientver(t_connection const * c){    if (!c)    {        eventlog(eventlog_level_error,__FUNCTION__,"got NULL connection");        return NULL;    }    if (!c->protocol.client.clientver)	return "";    return c->protocol.client.clientver;}extern void conn_set_clientver(t_connection * c, char const * clientver){    char const * temp;        if (!c)    {        eventlog(eventlog_level_error,__FUNCTION__,"got NULL connection");        return;    }    if (!clientver)    {        eventlog(eventlog_level_error,__FUNCTION__,"got NULL clientver");        return;    }        temp = xstrdup(clientver);    if (c->protocol.client.clientver)	xfree((void *)c->protocol.client.clientver); /* avoid warning */    c->protocol.client.clientver = temp;}extern t_tag conn_get_archtag(t_connection const * c){    if (!c) {        eventlog(eventlog_level_error,__FUNCTION__,"got NULL connection");        return 0; /* unknown */    }        return c->protocol.client.archtag;}extern void conn_set_archtag(t_connection * c, t_tag archtag){    char archtag_str[5];        if (!c) {        eventlog(eventlog_level_error,__FUNCTION__,"got NULL connection");        return;    }    if (!tag_check_arch(archtag)) {	eventlog(eventlog_level_error,__FUNCTION__,"got UNKNOWN archtag");	return;    }    if (c->protocol.client.archtag!=archtag)	eventlog(eventlog_level_info,__FUNCTION__,"[%d] setting client arch to \"%s\"",conn_get_socket(c),tag_uint_to_str(archtag_str,archtag));        c->protocol.client.archtag = archtag;}extern t_tag conn_get_gamelang(t_connection const * c){    if (!c)    {        eventlog(eventlog_level_error, __FUNCTION__,"got NULL connection");        return 0;    }        return c->protocol.client.gamelang;}extern void conn_set_gamelang(t_connection * c, t_tag gamelang){    char gamelang_str[5];        if (!c) {        eventlog(eventlog_level_error,__FUNCTION__,"got NULL connection");        return;    }    if (!gamelang)	return; /* only war3 & w3xp have gamelang */        if (!tag_check_gamelang(gamelang)) {	eventlog(eventlog_level_error,__FUNCTION__,"got UNKNOWN gamelang");	return;    }    if (c->protocol.client.gamelang!=gamelang)	eventlog(eventlog_level_info,__FUNCTION__,"[%d] setting client gamelang to \"%s\"",conn_get_socket(c),tag_uint_to_str(gamelang_str,gamelang));    c->protocol.client.gamelang = gamelang;}extern t_clienttag conn_get_clienttag(t_connection const * c){    if (!c)    {        eventlog(eventlog_level_error,__FUNCTION__,"got NULL connection");        return CLIENTTAG_UNKNOWN_UINT;    }        if (!c->protocol.client.clienttag)	return CLIENTTAG_UNKNOWN_UINT;    return c->protocol.client.clienttag;}extern t_clienttag conn_get_fake_clienttag(t_connection const * c){    char const * clienttag;    t_account *  account;        if (!c)    {        eventlog(eventlog_level_error,__FUNCTION__,"got NULL connection");        return 0; /* unknown */    }    account = conn_get_account(c);    if (account) /* BITS remote connections don't need to have an account */	if ((clienttag = account_get_strattr(account,"BNET\\fakeclienttag")))	    return tag_str_to_uint(clienttag);    return c->protocol.client.clienttag;}extern void conn_set_clienttag(t_connection * c, t_clienttag clienttag){    char clienttag_str[5];        if (!c) {        eventlog(eventlog_level_error,__FUNCTION__,"got NULL connection");        return;    }    if (!tag_check_client(clienttag)) {	eventlog(eventlog_level_error,__FUNCTION__,"got UNKNOWN clienttag \"%s\"",tag_uint_to_str(clienttag_str,clienttag));	return;    }    if (c->protocol.client.clienttag!=clienttag) {	eventlog(eventlog_level_info,__FUNCTION__,"[%d] setting client type to \"%s\"",conn_get_socket(c),tag_uint_to_str(clienttag_str,clienttag));        c->protocol.client.clienttag = clienttag;        if (c->protocol.chat.channel)	    channel_update_userflags(c);    }    }extern unsigned long conn_get_gameversion(t_connection const * c){    if (!c)    {	eventlog(eventlog_level_error, __FUNCTION__,"got NULL connection");	return 0;    }    return c->protocol.client.gameversion;}extern int conn_set_gameversion(t_connection * c, unsigned long gameversion){    if (!c)    {	eventlog(eventlog_level_error, __FUNCTION__,"got NULL connection");	return -1;    }        c->protocol.client.gameversion = gameversion;    return 0;}extern unsigned long conn_get_checksum(t_connection const * c){    if (!c)    {	eventlog(eventlog_level_error, __FUNCTION__,"got NULL connection");	return 0;    }    return c->protocol.client.checksum;}extern int conn_set_checksum(t_connection * c, unsigned long checksum){    if (!c)    {	eventlog(eventlog_level_error, __FUNCTION__,"got NULL connection");	return -1;    }        c->protocol.client.checksum = checksum;    return 0;}extern unsigned long conn_get_versionid(t_connection const * c){    if (!c)    {	eventlog(eventlog_level_error,__FUNCTION__,"got NULL connection");	return 0;    }    return c->protocol.client.versionid;}extern int conn_set_versionid(t_connection * c, unsigned long versionid){    if (!c)    {	eventlog(eventlog_level_error,__FUNCTION__,"got NULL connection");	return -1;    }    c->protocol.client.versionid = versionid;    return 0;}extern int conn_get_tzbias(t_connection const * c){    if (!c)    {        eventlog(eventlog_level_error,__FUNCTION__,"got NULL connection");        return 0;    }    return c->protocol.client.tzbias;}extern void conn_set_tzbias(t_connection * c, int tzbias){    if (!c)    {        eventlog(eventlog_level_error,__FUNCTION__,"got NULL connection");        return;    }        c->protocol.client.tzbias = tzbias;}static void conn_set_account(t_connection * c, t_account * account){    t_connection * other;    char const *   tname;        if (!c)    {        eventlog(eventlog_level_error,__FUNCTION__,"got NULL connection");        return;    }    if (!account)    {        eventlog(eventlog_level_error,__FUNCTION__,"got NULL account");        return;    }        if ((other = connlist_find_connection_by_accountname((tname = account_get_name(account)))))    {	eventlog(eventlog_level_info,__FUNCTION__,"[%d] forcing logout of previous login for \"%s\"",conn_get_socket(c),tname);	conn_set_state(other, conn_state_destroy);    }    c->protocol.account = account;    c->protocol.state = conn_state_loggedin;    account_set_conn(account,c);    {	char const * flagstr;		if ((flagstr = account_get_strattr(account,"BNET\\flags\\initial")))	    conn_add_flags(c,strtoul(flagstr,NULL,0));    }        account_set_ll_time(c->protocol.account,(unsigned int)now);    account_set_ll_owner(c->protocol.account,c->protocol.client.owner);    account_set_ll_clienttag(c->protocol.account,c->protocol.client.clienttag);    account_set_ll_ip(c->protocol.account,addr_num_to_ip_str(c->socket.tcp_addr));          if (c->protocol.client.host)    {	xfree((void *)c->protocol.client.host); /* avoid warning */	c->protocol.client.host = NULL;    }    if (c->protocol.client.user)    {	xfree((void *)c->protocol.client.user); /* avoid warning */	c->protocol.client.user = NULL;    }    if (c->protocol.client.clientexe)    {	xfree((void *)c->protocol.client.clientexe); /* avoid warning */	c->protocol.client.clientexe = NULL;    }    if (c->protocol.client.owner)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -