1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
17 #include "inspircd_config.h"
19 #include "configreader.h"
21 #include <sys/errno.h>
38 #include "inspstring.h"
39 #include "helperfuncs.h"
42 #include "socketengine.h"
45 #include "command_parse.h"
47 extern ServerConfig *Config;
48 extern InspIRCd* ServerInstance;
50 extern ModuleList modules;
51 extern FactoryList factory;
52 extern std::vector<InspSocket*> module_sockets;
53 extern std::vector<userrec*> local_users;
55 extern userrec* fd_ref_table[MAX_DESCRIPTORS];
56 extern user_hash clientlist;
57 extern chan_hash chanlist;
58 extern command_table cmdlist;
64 // version is a simple class for holding a modules version number
66 Version::Version(int major, int minor, int revision, int build, int flags) : Major(major), Minor(minor), Revision(revision), Build(build), Flags(flags) { };
68 // admin is a simple class for holding a server's administrative info
70 Admin::Admin(std::string name, std::string email, std::string nick) : Name(name), Email(email), Nick(nick) { };
72 Request::Request(char* anydata, Module* src, Module* dst) : data(anydata), source(src), dest(dst) { };
74 char* Request::GetData()
76 return (char*)this->data;
79 Module* Request::GetSource()
84 Module* Request::GetDest()
93 return dest->OnRequest(this);
101 Event::Event(char* anydata, Module* src, const std::string &eventid) : data(anydata), source(src), id(eventid) { };
103 char* Event::GetData()
105 return (char*)this->data;
108 Module* Event::GetSource()
115 FOREACH_MOD(I_OnEvent,OnEvent(this));
119 std::string Event::GetEventID()
125 // These declarations define the behavours of the base class Module (which does nothing at all)
127 Module::Module(Server* Me) { }
128 Module::~Module() { }
129 void Module::OnUserConnect(userrec* user) { }
130 void Module::OnUserQuit(userrec* user, const std::string& message) { }
131 void Module::OnUserDisconnect(userrec* user) { }
132 void Module::OnUserJoin(userrec* user, chanrec* channel) { }
133 void Module::OnUserPart(userrec* user, chanrec* channel, const std::string &partmessage) { }
134 void Module::OnRehash(const std::string ¶meter) { }
135 void Module::OnServerRaw(std::string &raw, bool inbound, userrec* user) { }
136 int Module::OnUserPreJoin(userrec* user, chanrec* chan, const char* cname) { return 0; }
137 void Module::OnMode(userrec* user, void* dest, int target_type, const std::string &text) { };
138 Version Module::GetVersion() { return Version(1,0,0,0,VF_VENDOR); }
139 void Module::OnOper(userrec* user, const std::string &opertype) { };
140 void Module::OnPostOper(userrec* user, const std::string &opertype) { };
141 void Module::OnInfo(userrec* user) { };
142 void Module::OnWhois(userrec* source, userrec* dest) { };
143 int Module::OnUserPreInvite(userrec* source,userrec* dest,chanrec* channel) { return 0; };
144 int Module::OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text,char status) { return 0; };
145 int Module::OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text,char status) { return 0; };
146 int Module::OnUserPreNick(userrec* user, const std::string &newnick) { return 0; };
147 void Module::OnUserPostNick(userrec* user, const std::string &oldnick) { };
148 int Module::OnAccessCheck(userrec* source,userrec* dest,chanrec* channel,int access_type) { return ACR_DEFAULT; };
149 void Module::On005Numeric(std::string &output) { };
150 int Module::OnKill(userrec* source, userrec* dest, const std::string &reason) { return 0; };
151 void Module::OnLoadModule(Module* mod,const std::string &name) { };
152 void Module::OnUnloadModule(Module* mod,const std::string &name) { };
153 void Module::OnBackgroundTimer(time_t curtime) { };
154 int Module::OnPreCommand(const std::string &command, char **parameters, int pcnt, userrec *user, bool validated) { return 0; };
155 bool Module::OnCheckReady(userrec* user) { return true; };
156 void Module::OnUserRegister(userrec* user) { };
157 int Module::OnUserPreKick(userrec* source, userrec* user, chanrec* chan, const std::string &reason) { return 0; };
158 void Module::OnUserKick(userrec* source, userrec* user, chanrec* chan, const std::string &reason) { };
159 int Module::OnRawMode(userrec* user, chanrec* chan, char mode, const std::string ¶m, bool adding, int pcnt) { return 0; };
160 int Module::OnCheckInvite(userrec* user, chanrec* chan) { return 0; };
161 int Module::OnCheckKey(userrec* user, chanrec* chan, const std::string &keygiven) { return 0; };
162 int Module::OnCheckLimit(userrec* user, chanrec* chan) { return 0; };
163 int Module::OnCheckBan(userrec* user, chanrec* chan) { return 0; };
164 int Module::OnStats(char symbol, userrec* user) { return 0; };
165 int Module::OnChangeLocalUserHost(userrec* user, const std::string &newhost) { return 0; };
166 int Module::OnChangeLocalUserGECOS(userrec* user, const std::string &newhost) { return 0; };
167 int Module::OnLocalTopicChange(userrec* user, chanrec* chan, const std::string &topic) { return 0; };
168 void Module::OnEvent(Event* event) { return; };
169 char* Module::OnRequest(Request* request) { return NULL; };
170 int Module::OnOperCompare(const std::string &password, const std::string &input) { return 0; };
171 void Module::OnGlobalOper(userrec* user) { };
172 void Module::OnGlobalConnect(userrec* user) { };
173 int Module::OnAddBan(userrec* source, chanrec* channel,const std::string &banmask) { return 0; };
174 int Module::OnDelBan(userrec* source, chanrec* channel,const std::string &banmask) { return 0; };
175 void Module::OnRawSocketAccept(int fd, const std::string &ip, int localport) { };
176 int Module::OnRawSocketWrite(int fd, char* buffer, int count) { return 0; };
177 void Module::OnRawSocketClose(int fd) { };
178 int Module::OnRawSocketRead(int fd, char* buffer, unsigned int count, int &readresult) { return 0; };
179 void Module::OnUserMessage(userrec* user, void* dest, int target_type, const std::string &text, char status) { };
180 void Module::OnUserNotice(userrec* user, void* dest, int target_type, const std::string &text, char status) { };
181 void Module::OnRemoteKill(userrec* source, userrec* dest, const std::string &reason) { };
182 void Module::OnUserInvite(userrec* source,userrec* dest,chanrec* channel) { };
183 void Module::OnPostLocalTopicChange(userrec* user, chanrec* chan, const std::string &topic) { };
184 void Module::OnGetServerDescription(const std::string &servername,std::string &description) { };
185 void Module::OnSyncUser(userrec* user, Module* proto, void* opaque) { };
186 void Module::OnSyncChannel(chanrec* chan, Module* proto, void* opaque) { };
187 void Module::ProtoSendMode(void* opaque, int target_type, void* target, const std::string &modeline) { };
188 void Module::OnSyncChannelMetaData(chanrec* chan, Module* proto,void* opaque, const std::string &extname) { };
189 void Module::OnSyncUserMetaData(userrec* user, Module* proto,void* opaque, const std::string &extname) { };
190 void Module::OnSyncOtherMetaData(Module* proto, void* opaque) { };
191 void Module::OnDecodeMetaData(int target_type, void* target, const std::string &extname, const std::string &extdata) { };
192 void Module::ProtoSendMetaData(void* opaque, int target_type, void* target, const std::string &extname, const std::string &extdata) { };
193 void Module::OnWallops(userrec* user, const std::string &text) { };
194 void Module::OnChangeHost(userrec* user, const std::string &newhost) { };
195 void Module::OnChangeName(userrec* user, const std::string &gecos) { };
196 void Module::OnAddGLine(long duration, userrec* source, const std::string &reason, const std::string &hostmask) { };
197 void Module::OnAddZLine(long duration, userrec* source, const std::string &reason, const std::string &ipmask) { };
198 void Module::OnAddKLine(long duration, userrec* source, const std::string &reason, const std::string &hostmask) { };
199 void Module::OnAddQLine(long duration, userrec* source, const std::string &reason, const std::string &nickmask) { };
200 void Module::OnAddELine(long duration, userrec* source, const std::string &reason, const std::string &hostmask) { };
201 void Module::OnDelGLine(userrec* source, const std::string &hostmask) { };
202 void Module::OnDelZLine(userrec* source, const std::string &ipmask) { };
203 void Module::OnDelKLine(userrec* source, const std::string &hostmask) { };
204 void Module::OnDelQLine(userrec* source, const std::string &nickmask) { };
205 void Module::OnDelELine(userrec* source, const std::string &hostmask) { };
206 void Module::OnCleanup(int target_type, void* item) { };
207 void Module::Implements(char* Implements) { for (int j = 0; j < 255; j++) Implements[j] = 0; };
208 void Module::OnChannelDelete(chanrec* chan) { };
209 Priority Module::Prioritize() { return PRIORITY_DONTCARE; }
210 void Module::OnSetAway(userrec* user) { };
211 void Module::OnCancelAway(userrec* user) { };
213 /* server is a wrapper class that provides methods to all of the C-style
214 * exports in the core
225 void Server::AddSocket(InspSocket* sock)
227 module_sockets.push_back(sock);
230 void Server::RemoveSocket(InspSocket* sock)
232 for (std::vector<InspSocket*>::iterator a = module_sockets.begin(); a < module_sockets.end(); a++)
234 InspSocket* s = (InspSocket*)*a;
240 long Server::PriorityAfter(const std::string &modulename)
242 for (unsigned int j = 0; j < Config->module_names.size(); j++)
244 if (Config->module_names[j] == modulename)
246 return ((j << 8) | PRIORITY_AFTER);
249 return PRIORITY_DONTCARE;
252 long Server::PriorityBefore(const std::string &modulename)
254 for (unsigned int j = 0; j < Config->module_names.size(); j++)
256 if (Config->module_names[j] == modulename)
258 return ((j << 8) | PRIORITY_BEFORE);
261 return PRIORITY_DONTCARE;
264 bool Server::PublishFeature(const std::string &FeatureName, Module* Mod)
266 if (Features.find(FeatureName) == Features.end())
268 Features[FeatureName] = Mod;
274 bool Server::UnpublishFeature(const std::string &FeatureName)
276 featurelist::iterator iter = Features.find(FeatureName);
278 if (iter == Features.end())
281 Features.erase(iter);
285 Module* Server::FindFeature(const std::string &FeatureName)
287 featurelist::iterator iter = Features.find(FeatureName);
289 if (iter == Features.end())
295 void Server::RehashServer()
297 WriteOpers("*** Rehashing config file");
298 Config->Read(false,NULL);
301 ServerConfig* Server::GetConfig()
306 std::string Server::GetVersion()
308 return ServerInstance->GetVersionString();
311 void Server::DelSocket(InspSocket* sock)
313 for (std::vector<InspSocket*>::iterator a = module_sockets.begin(); a < module_sockets.end(); a++)
317 module_sockets.erase(a);
323 long Server::GetChannelCount()
325 return (long)chanlist.size();
328 /* This is ugly, yes, but hash_map's arent designed to be
329 * addressed in this manner, and this is a bit of a kludge.
330 * Luckily its a specialist function and rarely used by
331 * many modules (in fact, it was specially created to make
332 * m_safelist possible, initially).
335 chanrec* Server::GetChannelIndex(long index)
338 for (chan_hash::iterator n = chanlist.begin(); n != chanlist.end(); n++, target++)
346 void Server::AddTimer(InspTimer* T)
351 void Server::SendOpers(const std::string &s)
353 WriteOpers("%s",s.c_str());
356 bool Server::MatchText(const std::string &sliteral, const std::string &spattern)
358 return match(sliteral.c_str(),spattern.c_str());
361 void Server::SendToModeMask(const std::string &modes, int flags, const std::string &text)
363 WriteMode(modes.c_str(),flags,"%s",text.c_str());
366 chanrec* Server::JoinUserToChannel(userrec* user, const std::string &cname, const std::string &key)
368 return add_channel(user,cname.c_str(),key.c_str(),false);
371 chanrec* Server::PartUserFromChannel(userrec* user, const std::string &cname, const std::string &reason)
373 return del_channel(user,cname.c_str(),reason.c_str(),false);
376 chanuserlist Server::GetUsers(chanrec* chan)
380 CUList *list = chan->GetUsers();
381 for (CUList::iterator i = list->begin(); i != list->end(); i++)
382 userl.push_back(i->second);
385 void Server::ChangeUserNick(userrec* user, const std::string &nickname)
387 force_nickchange(user,nickname.c_str());
390 void Server::KickUser(userrec* source, userrec* target, chanrec* chan, const std::string &reason)
394 kick_channel(source,target,chan,(char*)reason.c_str());
398 server_kick_channel(target,chan,(char*)reason.c_str(),true);
402 void Server::QuitUser(userrec* user, const std::string &reason)
404 kill_link(user,reason.c_str());
407 bool Server::IsUlined(const std::string &server)
409 return is_uline(server.c_str());
412 bool Server::CallCommandHandler(const std::string &commandname, char** parameters, int pcnt, userrec* user)
414 return ServerInstance->Parser->CallHandler(commandname,parameters,pcnt,user);
417 bool Server::IsValidModuleCommand(const std::string &commandname, int pcnt, userrec* user)
419 return ServerInstance->Parser->IsValidCommand(commandname, pcnt, user);
422 void Server::Log(int level, const std::string &s)
424 log(level,"%s",s.c_str());
427 void Server::AddCommand(command_t *f)
429 if (!ServerInstance->Parser->CreateCommand(f))
431 ModuleException err("Command "+std::string(f->command)+" already exists.");
436 void Server::SendMode(char **parameters, int pcnt, userrec *user)
438 //ServerInstance->ModeGrok->ServerMode(parameters,pcnt,user);
441 void Server::Send(int Socket, const std::string &s)
443 Write_NoFormat(Socket,s.c_str());
446 void Server::SendServ(int Socket, const std::string &s)
448 WriteServ_NoFormat(Socket,s.c_str());
451 void Server::SendFrom(int Socket, userrec* User, const std::string &s)
453 WriteFrom_NoFormat(Socket,User,s.c_str());
456 void Server::SendTo(userrec* Source, userrec* Dest, const std::string &s)
460 // if source is NULL, then the message originates from the local server
461 WriteServ_NoFormat(Dest->fd,s.c_str());
465 // otherwise it comes from the user specified
466 WriteTo_NoFormat(Source,Dest,s.c_str());
470 void Server::SendChannelServerNotice(const std::string &ServName, chanrec* Channel, const std::string &text)
472 WriteChannelWithServ_NoFormat((char*)ServName.c_str(), Channel, text.c_str());
475 void Server::SendChannel(userrec* User, chanrec* Channel, const std::string &s, bool IncludeSender)
479 WriteChannel_NoFormat(Channel,User,s.c_str());
483 ChanExceptSender_NoFormat(Channel,User,0,s.c_str());
487 bool Server::CommonChannels(userrec* u1, userrec* u2)
489 return (common_channels(u1,u2) != 0);
492 void Server::DumpText(userrec* User, const std::string &LinePrefix, stringstream &TextStream)
494 std::string CompleteLine = LinePrefix;
495 std::string Word = "";
496 while (TextStream >> Word)
498 if (CompleteLine.length() + Word.length() + 3 > 500)
500 WriteServ_NoFormat(User->fd,CompleteLine.c_str());
501 CompleteLine = LinePrefix;
503 CompleteLine = CompleteLine + Word + " ";
505 WriteServ_NoFormat(User->fd,CompleteLine.c_str());
508 void Server::SendCommon(userrec* User, const std::string &text, bool IncludeSender)
512 WriteCommon_NoFormat(User,text.c_str());
516 WriteCommonExcept_NoFormat(User,text.c_str());
520 void Server::SendWallops(userrec* User, const std::string &text)
522 WriteWallOps(User,false,"%s",text.c_str());
525 void Server::ChangeHost(userrec* user, const std::string &host)
527 ChangeDisplayedHost(user,host.c_str());
530 void Server::ChangeGECOS(userrec* user, const std::string &gecos)
532 ChangeName(user,gecos.c_str());
535 bool Server::IsNick(const std::string &nick)
537 return (isnick(nick.c_str()) != 0);
540 userrec* Server::FindNick(const std::string &nick)
545 userrec* Server::FindDescriptor(int socket)
547 return (socket < 65536 ? fd_ref_table[socket] : NULL);
550 chanrec* Server::FindChannel(const std::string &channel)
552 return FindChan(channel.c_str());
555 std::string Server::ChanMode(userrec* User, chanrec* Chan)
557 return cmode(User,Chan);
560 std::string Server::GetServerName()
562 return Config->ServerName;
565 std::string Server::GetNetworkName()
567 return Config->Network;
570 std::string Server::GetServerDescription()
572 return Config->ServerDesc;
575 Admin Server::GetAdmin()
577 return Admin(Config->AdminName,Config->AdminEmail,Config->AdminNick);
581 bool Server::AddMode(ModeHandler* mh, const unsigned char mode)
583 return ServerInstance->ModeGrok->AddMode(mh,mode);
586 int Server::CountUsers(chanrec* c)
591 bool Server::UserToPseudo(userrec* user, const std::string &message)
593 unsigned int old_fd = user->fd;
594 Write(old_fd,"ERROR :Closing link (%s@%s) [%s]",user->ident,user->host,message.c_str());
595 user->FlushWriteBuf();
597 user->fd = FD_MAGIC_NUMBER;
599 if (find(local_users.begin(),local_users.end(),user) != local_users.end())
601 local_users.erase(find(local_users.begin(),local_users.end(),user));
602 log(DEBUG,"Delete local user");
605 ServerInstance->SE->DelFd(old_fd);
611 bool Server::PseudoToUser(userrec* alive, userrec* zombie, const std::string &message)
613 log(DEBUG,"PseudoToUser");
614 zombie->fd = alive->fd;
615 FOREACH_MOD(I_OnUserQuit,OnUserQuit(alive,message));
616 alive->fd = FD_MAGIC_NUMBER;
617 alive->FlushWriteBuf();
618 alive->ClearBuffer();
619 // save these for later
620 std::string oldnick = alive->nick;
621 std::string oldhost = alive->host;
622 std::string oldident = alive->ident;
623 kill_link(alive,message.c_str());
624 if (find(local_users.begin(),local_users.end(),alive) != local_users.end())
626 local_users.erase(find(local_users.begin(),local_users.end(),alive));
627 log(DEBUG,"Delete local user");
629 // Fix by brain - cant write the user until their fd table entry is updated
630 fd_ref_table[zombie->fd] = zombie;
631 Write(zombie->fd,":%s!%s@%s NICK %s",oldnick.c_str(),oldident.c_str(),oldhost.c_str(),zombie->nick);
632 for (std::vector<ucrec*>::const_iterator i = zombie->chans.begin(); i != zombie->chans.end(); i++)
634 if (((ucrec*)(*i))->channel != NULL)
636 chanrec* Ptr = ((ucrec*)(*i))->channel;
637 WriteFrom(zombie->fd,zombie,"JOIN %s",Ptr->name);
640 WriteServ(zombie->fd,"332 %s %s :%s", zombie->nick, Ptr->name, Ptr->topic);
641 WriteServ(zombie->fd,"333 %s %s %s %d", zombie->nick, Ptr->name, Ptr->setby, Ptr->topicset);
643 userlist(zombie,Ptr);
644 WriteServ(zombie->fd,"366 %s %s :End of /NAMES list.", zombie->nick, Ptr->name);
647 if ((find(local_users.begin(),local_users.end(),zombie) == local_users.end()) && (zombie->fd != FD_MAGIC_NUMBER))
648 local_users.push_back(zombie);
653 void Server::AddGLine(long duration, const std::string &source, const std::string &reason, const std::string &hostmask)
655 add_gline(duration, source.c_str(), reason.c_str(), hostmask.c_str());
656 apply_lines(APPLY_GLINES);
659 void Server::AddQLine(long duration, const std::string &source, const std::string &reason, const std::string &nickname)
661 add_qline(duration, source.c_str(), reason.c_str(), nickname.c_str());
662 apply_lines(APPLY_QLINES);
665 void Server::AddZLine(long duration, const std::string &source, const std::string &reason, const std::string &ipaddr)
667 add_zline(duration, source.c_str(), reason.c_str(), ipaddr.c_str());
668 apply_lines(APPLY_ZLINES);
671 void Server::AddKLine(long duration, const std::string &source, const std::string &reason, const std::string &hostmask)
673 add_kline(duration, source.c_str(), reason.c_str(), hostmask.c_str());
674 apply_lines(APPLY_KLINES);
677 void Server::AddELine(long duration, const std::string &source, const std::string &reason, const std::string &hostmask)
679 add_eline(duration, source.c_str(), reason.c_str(), hostmask.c_str());
682 bool Server::DelGLine(const std::string &hostmask)
684 return del_gline(hostmask.c_str());
687 bool Server::DelQLine(const std::string &nickname)
689 return del_qline(nickname.c_str());
692 bool Server::DelZLine(const std::string &ipaddr)
694 return del_zline(ipaddr.c_str());
697 bool Server::DelKLine(const std::string &hostmask)
699 return del_kline(hostmask.c_str());
702 bool Server::DelELine(const std::string &hostmask)
704 return del_eline(hostmask.c_str());
707 long Server::CalcDuration(const std::string &delta)
709 return duration(delta.c_str());
713 * XXX why on *earth* is this in modules.cpp...? I think
714 * perhaps we need a server.cpp for Server:: stuff where possible. -- w00t
716 bool Server::IsValidMask(const std::string &mask)
718 char* dest = (char*)mask.c_str();
719 if (strchr(dest,'!')==0)
721 if (strchr(dest,'@')==0)
723 for (char* i = dest; *i; i++)
726 for (char* i = dest; *i; i++)
730 for (char* i = dest; *i; i++)
736 for (char* i = dest; *i; i++)
745 Module* Server::FindModule(const std::string &name)
747 for (int i = 0; i <= MODCOUNT; i++)
749 if (Config->module_names[i] == name)
757 ConfigReader::ConfigReader()
759 // Config->ClearStack();
761 /* Is there any reason to load the entire config file again here?
762 * it's needed if they specify another config file, but using the
763 * default one we can just use the global config data - pre-parsed!
765 //~ this->cache = new std::stringstream(std::stringstream::in | std::stringstream::out);
766 this->errorlog = new std::ostringstream(std::stringstream::in | std::stringstream::out);
768 //~ this->readerror = Config->LoadConf(CONFIG_FILE, this->cache,this->errorlog);
769 //~ if (!this->readerror)
770 //~ this->error = CONF_FILE_NOT_FOUND;
772 this->data = &Config->config_data;
773 this->privatehash = false;
777 ConfigReader::~ConfigReader()
780 //~ delete this->cache;
782 DELETE(this->errorlog);
783 if(this->privatehash)
788 ConfigReader::ConfigReader(const std::string &filename)
790 Config->ClearStack();
792 this->data = new ConfigDataHash;
793 this->privatehash = true;
794 this->errorlog = new std::ostringstream(std::stringstream::in | std::stringstream::out);
795 this->readerror = Config->LoadConf(*this->data, filename, *this->errorlog);
796 if (!this->readerror)
797 this->error = CONF_FILE_NOT_FOUND;
800 std::string ConfigReader::ReadValue(const std::string &tag, const std::string &name, int index)
802 /* Don't need to strlcpy() tag and name anymore, ReadConf() takes const char* */
805 if (!Config->ConfValue(*this->data, tag, name, index, result))
807 this->error = CONF_VALUE_NOT_FOUND;
814 bool ConfigReader::ReadFlag(const std::string &tag, const std::string &name, int index)
816 return Config->ConfValueBool(*this->data, tag, name, index);
819 long ConfigReader::ReadInteger(const std::string &tag, const std::string &name, int index, bool needs_unsigned)
823 if(!Config->ConfValueInteger(*this->data, tag, name, index, result))
825 this->error = CONF_VALUE_NOT_FOUND;
829 if ((needs_unsigned) && (result < 0))
831 this->error = CONF_NOT_UNSIGNED;
838 long ConfigReader::GetError()
840 long olderr = this->error;
845 void ConfigReader::DumpErrors(bool bail, userrec* user)
847 /* XXX - Duplicated code */
851 printf("There were errors in your configuration:\n%s", this->errorlog->str().c_str());
856 std::string errors = this->errorlog->str();
857 std::string::size_type start;
858 unsigned int prefixlen;
861 /* ":Config->ServerName NOTICE user->nick :" */
862 prefixlen = strlen(Config->ServerName) + strlen(user->nick) + 11;
866 WriteServ(user->fd,"NOTICE %s :There were errors in the configuration file:",user->nick);
868 while(start < errors.length())
870 WriteServ(user->fd, "NOTICE %s :%s",user->nick, errors.substr(start, 510 - prefixlen).c_str());
871 start += 510 - prefixlen;
876 WriteOpers("There were errors in the configuration file:");
878 while(start < errors.length())
880 WriteOpers(errors.substr(start, 360).c_str());
890 int ConfigReader::Enumerate(const std::string &tag)
892 return Config->ConfValueEnum(*this->data, tag);
895 int ConfigReader::EnumerateValues(const std::string &tag, int index)
897 return Config->ConfVarEnum(*this->data, tag, index);
900 bool ConfigReader::Verify()
902 return this->readerror;
906 FileReader::FileReader(const std::string &filename)
909 readfile(c,filename.c_str());
913 FileReader::FileReader()
917 void FileReader::LoadFile(const std::string &filename)
920 readfile(c,filename.c_str());
925 FileReader::~FileReader()
929 bool FileReader::Exists()
931 return (!(fc.size() == 0));
934 std::string FileReader::GetLine(int x)
936 if ((x<0) || ((unsigned)x>fc.size()))
941 int FileReader::FileSize()
947 std::vector<Module*> modules(255);
948 std::vector<ircd_module*> factory(255);