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

📄 command.c

📁 打魔兽战网的都知道他是什么
💻 C
📖 第 1 页 / 共 5 页
字号:
/* * Copyright (C) 1998  Mark Baysinger (mbaysing@ucsd.edu) * Copyright (C) 1998,1999,2000,2001  Ross Combs (rocombs@cs.nmsu.edu) * Copyright (C) 1999  Gediminas (gediminas_lt@mailexcite.com) * Copyright (C) 1999  Rob Crittenden (rcrit@greyoak.com) * Copyright (C) 2000,2001  Marco Ziech (mmz@gmx.net) * Copyright (C) 2000  Dizzy * Copyright (C) 2000  Onlyer (onlyer@263.net) * Copyright (C) 2003,2004  Aaron * Copyright (C) 2004  Donny Redmond (dredmond@linuxmail.org) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. */#include "common/setup_before.h"#include <stdio.h>#ifdef HAVE_STDDEF_H# include <stddef.h>#else# ifndef NULL#  define NULL ((void *)0)# endif#endif#ifdef STDC_HEADERS# include <stdlib.h>#else# ifdef HAVE_MALLOC_H#  include <malloc.h># endif#endif#include "compat/strtoul.h"#ifdef HAVE_STRING_H# include <string.h>#else# ifdef HAVE_STRINGS_H#  include <strings.h># endif#endif#include "compat/strdup.h"#include "compat/strcasecmp.h"#include "compat/snprintf.h"#include <ctype.h>#include <errno.h>#include "compat/strerror.h"#ifdef TIME_WITH_SYS_TIME# include <sys/time.h># include <time.h>#else# ifdef HAVE_SYS_TIME_H#  include <sys/time.h># else#  include <time.h># endif#endif#ifdef HAVE_SYS_TYPES# include <sys/types.h>#endif#include "compat/strftime.h"#include "message.h"#include "common/tag.h"#include "connection.h"#include "channel.h"#include "game.h"#include "common/util.h"#include "common/version.h"#include "team.h"#include "account.h"#include "account_wrap.h"#include "server.h"#include "prefs.h"#include "common/eventlog.h"#include "ladder.h"#include "timer.h"#include "common/bnettime.h"#include "common/addr.h"#include "common/packet.h"#include "helpfile.h"#include "mail.h"#include "common/bnethash.h"#include "runprog.h"#include "common/list.h"#include "common/proginfo.h"#include "alias_command.h"#include "realm.h"#include "ipban.h"#include "command_groups.h"#include "common/queue.h"#include "common/bn_type.h"#include "common/xalloc.h"#include "command.h"#include "news.h"#include "common/trans.h"#include "common/lstr.h"// aaron#include "topic.h"#include "friends.h"#include "clan.h"#include "common/setup_after.h"static char const * bnclass_get_str(unsigned int class);static void do_whisper(t_connection * user_c, char const * dest, char const * text);static void do_whois(t_connection * c, char const * dest);static void user_timer_cb(t_connection * c, time_t now, t_timer_data str);char msgtemp[MAX_MESSAGE_LEN];char msgtemp2[MAX_MESSAGE_LEN];static char const * bnclass_get_str(unsigned int class){    switch (class)    {    case PLAYERINFO_DRTL_CLASS_WARRIOR:	return "warrior";    case PLAYERINFO_DRTL_CLASS_ROGUE:	return "rogue";    case PLAYERINFO_DRTL_CLASS_SORCERER:	return "sorcerer";    default:	return "unknown";    }}static void do_whisper(t_connection * user_c, char const * dest, char const * text){    t_connection * dest_c;    char const *   tname;    if (!(dest_c = connlist_find_connection_by_name(dest,conn_get_realm(user_c))))    {	message_send_text(user_c,message_type_error,user_c,"That user is not logged on.");	return;    }    if (conn_get_dndstr(dest_c))    {        sprintf(msgtemp,"%.64s is unavailable (%.128s)",conn_get_username(dest_c),conn_get_dndstr(dest_c));        message_send_text(user_c,message_type_info,user_c,msgtemp);        return;    }    message_send_text(user_c,message_type_whisperack,dest_c,text);    if (conn_get_awaystr(dest_c))    {        sprintf(msgtemp,"%.64s is away (%.128s)",conn_get_username(dest_c),conn_get_awaystr(dest_c));        message_send_text(user_c,message_type_info,user_c,msgtemp);    }    message_send_text(dest_c,message_type_whisper,user_c,text);    if ((tname = conn_get_username(user_c)))    {        char username[1+USER_NAME_MAX]; /* '*' + username (including NUL) */	if (strlen(tname)<USER_NAME_MAX)	{            sprintf(username,"*%s",tname);	    conn_set_lastsender(dest_c,username);	}    }}static void do_whois(t_connection * c, char const * dest){    t_connection *    dest_c;    char              namepart[136]; /* 64 + " (" + 64 + ")" + NUL */    char const *      verb;    t_game const *    game;    t_channel const * channel;    if ((!(dest_c = connlist_find_connection_by_accountname(dest))) &&        (!(dest_c = connlist_find_connection_by_name(dest,conn_get_realm(c)))))    {	t_account * dest_a;	t_bnettime btlogin;	time_t ulogin;	struct tm * tmlogin;	if (!(dest_a = accountlist_find_account(dest))) {	    message_send_text(c,message_type_error,c,"Unknown user.");	    return;	}	if (conn_get_class(c) == conn_class_bnet) {	    btlogin = time_to_bnettime((time_t)account_get_ll_time(dest_a),0);	    btlogin = bnettime_add_tzbias(btlogin, conn_get_tzbias(c));	    ulogin = bnettime_to_time(btlogin);	    if (!(tmlogin = gmtime(&ulogin)))		strcpy(msgtemp, "User was last seen on ?");	    else		strftime(msgtemp, sizeof(msgtemp), "User was last seen on : %a %b %d %H:%M:%S",tmlogin);	} else strcpy(msgtemp, "User is offline");	message_send_text(c, message_type_info, c, msgtemp);	return;    }    if (c==dest_c)    {	strcpy(namepart,"You");	verb = "are";    }    else    {	char const * tname;	sprintf(namepart,"%.64s",(tname = conn_get_chatcharname(dest_c,c)));	conn_unget_chatcharname(dest_c,tname);	verb = "is";    }    if ((game = conn_get_game(dest_c)))    {	sprintf(msgtemp,"%s %s using %s and %s currently in %s game \"%.64s\".",		namepart,		verb,		clienttag_get_title(conn_get_clienttag(dest_c)),		verb,		game_get_flag(game) == game_flag_private ? "private" : "",		game_get_name(game));    }    else if ((channel = conn_get_channel(dest_c)))    {        sprintf(msgtemp,"%s %s using %s and %s currently in channel \"%.64s\".",		namepart,		verb,		clienttag_get_title(conn_get_clienttag(dest_c)),		verb,		channel_get_name(channel));    }    else	sprintf(msgtemp,"%s %s using %s.",		namepart,		verb,		clienttag_get_title(conn_get_clienttag(dest_c)));    message_send_text(c,message_type_info,c,msgtemp);    if (conn_get_dndstr(dest_c))    {        sprintf(msgtemp,"%s %s refusing messages (%.128s)",		namepart,		verb,		conn_get_dndstr(dest_c));	message_send_text(c,message_type_info,c,msgtemp);    }    else        if (conn_get_awaystr(dest_c))        {            sprintf(msgtemp,"%s away (%.128s)",		    namepart,		    conn_get_awaystr(dest_c));	    message_send_text(c,message_type_info,c,msgtemp);        }}static void user_timer_cb(t_connection * c, time_t now, t_timer_data str){    if (!c)    {	eventlog(eventlog_level_error,__FUNCTION__,"got NULL connection");	return;    }    if (!str.p)    {	eventlog(eventlog_level_error,__FUNCTION__,"got NULL str");	return;    }    if (now!=(time_t)0) /* zero means user logged out before expiration */	message_send_text(c,message_type_info,c,str.p);    xfree(str.p);}typedef int (* t_command)(t_connection * c, char const * text);typedef struct {	const char * command_string;	t_command    command_handler;} t_command_table_row;static int command_set_flags(t_connection * c); // [Omega]// command handler prototypesstatic int _handle_clan_command(t_connection * c, char const * text);static int _handle_admin_command(t_connection * c, char const * text);static int _handle_aop_command(t_connection * c, char const * text);static int _handle_op_command(t_connection * c, char const * text);static int _handle_tmpop_command(t_connection * c, char const * text);static int _handle_deop_command(t_connection * c, char const * text);static int _handle_voice_command(t_connection * c, char const * text);static int _handle_devoice_command(t_connection * c, char const * text);static int _handle_vop_command(t_connection * c, char const * text);static int _handle_friends_command(t_connection * c, char const * text);static int _handle_me_command(t_connection * c, char const * text);static int _handle_whisper_command(t_connection * c, char const * text);static int _handle_status_command(t_connection * c, char const * text);static int _handle_who_command(t_connection * c, char const * text);static int _handle_whois_command(t_connection * c, char const * text);static int _handle_whoami_command(t_connection * c, char const * text);static int _handle_announce_command(t_connection * c, char const * text);static int _handle_beep_command(t_connection * c, char const * text);static int _handle_nobeep_command(t_connection * c, char const * text);static int _handle_version_command(t_connection * c, char const * text);static int _handle_copyright_command(t_connection * c, char const * text);static int _handle_uptime_command(t_connection * c, char const * text);static int _handle_stats_command(t_connection * c, char const * text);static int _handle_time_command(t_connection * c, char const * text);static int _handle_channel_command(t_connection * c, char const * text);static int _handle_rejoin_command(t_connection * c, char const * text);static int _handle_away_command(t_connection * c, char const * text);static int _handle_dnd_command(t_connection * c, char const * text);static int _handle_squelch_command(t_connection * c, char const * text);static int _handle_unsquelch_command(t_connection * c, char const * text);//static int _handle_designate_command(t_connection * c, char const * text); Obsolete function [Omega]//static int _handle_resign_command(t_connection * c, char const * text); Obsolete function [Omega]static int _handle_kick_command(t_connection * c, char const * text);static int _handle_ban_command(t_connection * c, char const * text);static int _handle_unban_command(t_connection * c, char const * text);static int _handle_reply_command(t_connection * c, char const * text);static int _handle_realmann_command(t_connection * c, char const * text);static int _handle_watch_command(t_connection * c, char const * text);static int _handle_unwatch_command(t_connection * c, char const * text);static int _handle_watchall_command(t_connection * c, char const * text);static int _handle_unwatchall_command(t_connection * c, char const * text);static int _handle_lusers_command(t_connection * c, char const * text);static int _handle_news_command(t_connection * c, char const * text);static int _handle_games_command(t_connection * c, char const * text);static int _handle_channels_command(t_connection * c, char const * text);static int _handle_addacct_command(t_connection * c, char const * text);static int _handle_chpass_command(t_connection * c, char const * text);static int _handle_connections_command(t_connection * c, char const * text);static int _handle_finger_command(t_connection * c, char const * text);static int _handle_operator_command(t_connection * c, char const * text);static int _handle_admins_command(t_connection * c, char const * text);static int _handle_quit_command(t_connection * c, char const * text);static int _handle_kill_command(t_connection * c, char const * text);static int _handle_killsession_command(t_connection * c, char const * text);static int _handle_gameinfo_command(t_connection * c, char const * text);static int _handle_ladderactivate_command(t_connection * c, char const * text);static int _handle_rehash_command(t_connection * c, char const * text);//static int _handle_rank_all_accounts_command(t_connection * c, char const * text);static int _handle_shutdown_command(t_connection * c, char const * text);static int _handle_ladderinfo_command(t_connection * c, char const * text);static int _handle_timer_command(t_connection * c, char const * text);static int _handle_serverban_command(t_connection * c, char const * text);static int _handle_netinfo_command(t_connection * c, char const * text);static int _handle_quota_command(t_connection * c, char const * text);static int _handle_lockacct_command(t_connection * c, char const * text);static int _handle_unlockacct_command(t_connection * c, char const * text);static int _handle_flag_command(t_connection * c, char const * text);static int _handle_tag_command(t_connection * c, char const * text);//static int _handle_ipban_command(t_connection * c, char const * text); Redirected to handle_ipban_command() in ipban.c [Omega]static int _handle_set_command(t_connection * c, char const * text);static int _handle_motd_command(t_connection * c, char const * text);static int _handle_ping_command(t_connection * c, char const * text);static int _handle_commandgroups_command(t_connection * c, char const * text);static int _handle_topic_command(t_connection * c, char const * text);static int _handle_moderate_command(t_connection * c, char const * text);static int _handle_clearstats_command(t_connection * c, char const * text);static int _handle_tos_command(t_connection * c, char const * text);static const t_command_table_row standard_command_table[] ={	{ "/clan"		, _handle_clan_command },	{ "/c"			, _handle_clan_command },	{ "/admin"		, _handle_admin_command },

⌨️ 快捷键说明

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