X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_sethost.cpp;h=2ef0c054865a6fcf9a19ee5b1631f6324e0c4938;hb=64faca29b377185c4615c8f2e4eecedc7ad045d1;hp=8e397c0e13589946eedd17bb72b70f571d7a2da3;hpb=1c1c5fc3f01c42a09d34594989679bbc8fb21c0d;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_sethost.cpp b/src/modules/m_sethost.cpp index 8e397c0e1..2ef0c0548 100644 --- a/src/modules/m_sethost.cpp +++ b/src/modules/m_sethost.cpp @@ -1,16 +1,24 @@ -/* +------------------------------------+ - * | Inspire Internet Relay Chat Daemon | - * +------------------------------------+ +/* + * InspIRCd -- Internet Relay Chat Daemon * - * InspIRCd: (C) 2002-2009 InspIRCd Development Team - * See: http://wiki.inspircd.org/Credits + * Copyright (C) 2007 Dennis Friis + * Copyright (C) 2007 Robin Burchell + * Copyright (C) 2004-2006 Craig Edwards * - * This program is free but copyrighted software; see - * the file COPYING for details. + * This file is part of InspIRCd. InspIRCd 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, version 2. * - * --------------------------------------------------- + * 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, see . */ + #include "inspircd.h" /* $ModDesc: Provides support for the SETHOST command */ @@ -22,9 +30,10 @@ class CommandSethost : public Command private: char* hostmap; public: - CommandSethost (InspIRCd* Instance, Module* Creator, char* hmap) : Command(Instance,Creator,"SETHOST","o",1), hostmap(hmap) + CommandSethost(Module* Creator, char* hmap) : Command(Creator,"SETHOST", 1), hostmap(hmap) { - syntax = ""; + allow_empty_last_param = false; + flags_needed = 'o'; syntax = ""; TRANSLATE2(TR_TEXT, TR_END); } @@ -35,15 +44,11 @@ class CommandSethost : public Command { if (!hostmap[(const unsigned char)*x]) { - user->WriteServ("NOTICE "+std::string(user->nick)+" :*** SETHOST: Invalid characters in hostname"); + user->WriteServ("NOTICE "+user->nick+" :*** SETHOST: Invalid characters in hostname"); return CMD_FAILURE; } } - if (len == 0) - { - user->WriteServ("NOTICE %s :*** SETHOST: Host must be specified", user->nick.c_str()); - return CMD_FAILURE; - } + if (len > 64) { user->WriteServ("NOTICE %s :*** SETHOST: Host too long",user->nick.c_str()); @@ -52,7 +57,7 @@ class CommandSethost : public Command if (user->ChangeDisplayedHost(parameters[0].c_str())) { - ServerInstance->SNO->WriteGlobalSno('a', std::string(user->nick)+" used SETHOST to change their displayed host to "+user->dhost); + ServerInstance->SNO->WriteGlobalSno('a', user->nick+" used SETHOST to change their displayed host to "+user->dhost); return CMD_SUCCESS; } @@ -66,23 +71,22 @@ class ModuleSetHost : public Module CommandSethost cmd; char hostmap[256]; public: - ModuleSetHost(InspIRCd* Me) - : Module(Me), cmd(Me, this, hostmap) + ModuleSetHost() + : cmd(this, hostmap) + { + } + + void init() { OnRehash(NULL); - ServerInstance->AddCommand(&cmd); + ServerInstance->Modules->AddService(cmd); Implementation eventlist[] = { I_OnRehash }; - ServerInstance->Modules->Attach(eventlist, this, 1); + ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); } - void OnRehash(User* user) { - ConfigReader Conf(ServerInstance); - std::string hmap = Conf.ReadValue("hostname", "charmap", 0); - - if (hmap.empty()) - hmap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_/0123456789"; + std::string hmap = ServerInstance->Config->ConfValue("hostname")->getString("charmap", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_/0123456789"); memset(hostmap, 0, sizeof(hostmap)); for (std::string::iterator n = hmap.begin(); n != hmap.end(); n++) @@ -95,7 +99,7 @@ class ModuleSetHost : public Module virtual Version GetVersion() { - return Version("$Id$", VF_VENDOR, API_VERSION); + return Version("Provides support for the SETHOST command", VF_VENDOR); } };