]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules.cpp
Allow static build of inspircd without module support
[user/henk/code/inspircd.git] / src / modules.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
6  * See: http://wiki.inspircd.org/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #include "inspircd.h"
15 #include "xline.h"
16 #include "socket.h"
17 #include "socketengine.h"
18 #include "command_parse.h"
19 #include "dns.h"
20 #include "exitcodes.h"
21
22 #ifndef WIN32
23         #include <dirent.h>
24 #endif
25
26
27 // Version is a simple class for holding a modules version number
28 template<>
29 VersionBase<API_VERSION>::VersionBase(const std::string &modv, int flags, const std::string& rev)
30 : description(modv), version(rev), Flags(flags)
31 {
32 }
33
34 Request::Request(Module* src, Module* dst, const char* idstr)
35 : id(idstr), source(src), dest(dst)
36 {
37 }
38
39 void Request::Send()
40 {
41         if (dest)
42                 dest->OnRequest(*this);
43 }
44
45 Event::Event(Module* src, const std::string &eventid) : source(src), id(eventid) { }
46
47 void Event::Send()
48 {
49         FOREACH_MOD(I_OnEvent,OnEvent(*this));
50 }
51
52 // These declarations define the behavours of the base class Module (which does nothing at all)
53
54 Module::Module() { }
55 CullResult Module::cull()
56 {
57         return classbase::cull();
58 }
59 Module::~Module()
60 {
61 }
62
63 ModResult       Module::OnSendSnotice(char &snomask, std::string &type, const std::string &message) { return MOD_RES_PASSTHRU; }
64 void            Module::OnUserConnect(LocalUser*) { }
65 void            Module::OnUserQuit(User*, const std::string&, const std::string&) { }
66 void            Module::OnUserDisconnect(LocalUser*) { }
67 void            Module::OnUserJoin(Membership*, bool, bool, CUList&) { }
68 void            Module::OnPostJoin(Membership*) { }
69 void            Module::OnUserPart(Membership*, std::string&, CUList&) { }
70 void            Module::OnPreRehash(User*, const std::string&) { }
71 void            Module::OnModuleRehash(User*, const std::string&) { }
72 void            Module::OnRehash(User*) { }
73 ModResult       Module::OnUserPreJoin(User*, Channel*, const char*, std::string&, const std::string&) { return MOD_RES_PASSTHRU; }
74 void            Module::OnMode(User*, void*, int, const std::vector<std::string>&, const std::vector<TranslateType>&) { }
75 void            Module::OnOper(User*, const std::string&) { }
76 void            Module::OnPostOper(User*, const std::string&, const std::string &) { }
77 void            Module::OnInfo(User*) { }
78 void            Module::OnWhois(User*, User*) { }
79 ModResult       Module::OnUserPreInvite(User*, User*, Channel*, time_t) { return MOD_RES_PASSTHRU; }
80 ModResult       Module::OnUserPreMessage(User*, void*, int, std::string&, char, CUList&) { return MOD_RES_PASSTHRU; }
81 ModResult       Module::OnUserPreNotice(User*, void*, int, std::string&, char, CUList&) { return MOD_RES_PASSTHRU; }
82 ModResult       Module::OnUserPreNick(User*, const std::string&) { return MOD_RES_PASSTHRU; }
83 void            Module::OnUserPostNick(User*, const std::string&) { }
84 ModResult       Module::OnPreMode(User*, User*, Channel*, const std::vector<std::string>&) { return MOD_RES_PASSTHRU; }
85 void            Module::On005Numeric(std::string&) { }
86 ModResult       Module::OnKill(User*, User*, const std::string&) { return MOD_RES_PASSTHRU; }
87 void            Module::OnLoadModule(Module*) { }
88 void            Module::OnUnloadModule(Module*) { }
89 void            Module::OnBackgroundTimer(time_t) { }
90 ModResult       Module::OnPreCommand(std::string&, std::vector<std::string>&, User *, bool, const std::string&) { return MOD_RES_PASSTHRU; }
91 void            Module::OnPostCommand(const std::string&, const std::vector<std::string>&, User *, CmdResult, const std::string&) { }
92 ModResult       Module::OnCheckReady(LocalUser*) { return MOD_RES_PASSTHRU; }
93 ModResult       Module::OnUserRegister(LocalUser*) { return MOD_RES_PASSTHRU; }
94 ModResult       Module::OnUserPreKick(User*, Membership*, const std::string&) { return MOD_RES_PASSTHRU; }
95 void            Module::OnUserKick(User*, Membership*, const std::string&, CUList&) { }
96 ModResult       Module::OnRawMode(User*, Channel*, const char, const std::string &, bool, int) { return MOD_RES_PASSTHRU; }
97 ModResult       Module::OnCheckInvite(User*, Channel*) { return MOD_RES_PASSTHRU; }
98 ModResult       Module::OnCheckKey(User*, Channel*, const std::string&) { return MOD_RES_PASSTHRU; }
99 ModResult       Module::OnCheckLimit(User*, Channel*) { return MOD_RES_PASSTHRU; }
100 ModResult       Module::OnCheckChannelBan(User*, Channel*) { return MOD_RES_PASSTHRU; }
101 ModResult       Module::OnCheckBan(User*, Channel*, const std::string&) { return MOD_RES_PASSTHRU; }
102 ModResult       Module::OnExtBanCheck(User*, Channel*, char) { return MOD_RES_PASSTHRU; }
103 ModResult       Module::OnStats(char, User*, string_list&) { return MOD_RES_PASSTHRU; }
104 ModResult       Module::OnChangeLocalUserHost(LocalUser*, const std::string&) { return MOD_RES_PASSTHRU; }
105 ModResult       Module::OnChangeLocalUserGECOS(LocalUser*, const std::string&) { return MOD_RES_PASSTHRU; }
106 ModResult       Module::OnPreTopicChange(User*, Channel*, const std::string&) { return MOD_RES_PASSTHRU; }
107 void            Module::OnEvent(Event&) { }
108 void            Module::OnRequest(Request&) { }
109 ModResult       Module::OnPassCompare(Extensible* ex, const std::string &password, const std::string &input, const std::string& hashtype) { return MOD_RES_PASSTHRU; }
110 void            Module::OnGlobalOper(User*) { }
111 void            Module::OnPostConnect(User*) { }
112 ModResult       Module::OnAddBan(User*, Channel*, const std::string &) { return MOD_RES_PASSTHRU; }
113 ModResult       Module::OnDelBan(User*, Channel*, const std::string &) { return MOD_RES_PASSTHRU; }
114 void            Module::OnStreamSocketAccept(StreamSocket*, irc::sockets::sockaddrs*, irc::sockets::sockaddrs*) { }
115 int             Module::OnStreamSocketWrite(StreamSocket*, std::string&) { return -1; }
116 void            Module::OnStreamSocketClose(StreamSocket*) { }
117 void            Module::OnStreamSocketConnect(StreamSocket*) { }
118 int             Module::OnStreamSocketRead(StreamSocket*, std::string&) { return -1; }
119 void            Module::OnUserMessage(User*, void*, int, const std::string&, char, const CUList&) { }
120 void            Module::OnUserNotice(User*, void*, int, const std::string&, char, const CUList&) { }
121 void            Module::OnRemoteKill(User*, User*, const std::string&, const std::string&) { }
122 void            Module::OnUserInvite(User*, User*, Channel*, time_t) { }
123 void            Module::OnPostTopicChange(User*, Channel*, const std::string&) { }
124 void            Module::OnGetServerDescription(const std::string&, std::string&) { }
125 void            Module::OnSyncUser(User*, Module*, void*) { }
126 void            Module::OnSyncChannel(Channel*, Module*, void*) { }
127 void            Module::OnSyncNetwork(Module*, void*) { }
128 void            Module::ProtoSendMode(void*, TargetTypeFlags, void*, const std::vector<std::string>&, const std::vector<TranslateType>&) { }
129 void            Module::OnDecodeMetaData(Extensible*, const std::string&, const std::string&) { }
130 void            Module::ProtoSendMetaData(void*, Extensible*, const std::string&, const std::string&) { }
131 void            Module::OnWallops(User*, const std::string&) { }
132 void            Module::OnChangeHost(User*, const std::string&) { }
133 void            Module::OnChangeName(User*, const std::string&) { }
134 void            Module::OnChangeIdent(User*, const std::string&) { }
135 void            Module::OnAddLine(User*, XLine*) { }
136 void            Module::OnDelLine(User*, XLine*) { }
137 void            Module::OnExpireLine(XLine*) { }
138 void            Module::OnCleanup(int, void*) { }
139 ModResult       Module::OnChannelPreDelete(Channel*) { return MOD_RES_PASSTHRU; }
140 void            Module::OnChannelDelete(Channel*) { }
141 ModResult       Module::OnSetAway(User*, const std::string &) { return MOD_RES_PASSTHRU; }
142 ModResult       Module::OnUserList(User*, Channel*) { return MOD_RES_PASSTHRU; }
143 ModResult       Module::OnWhoisLine(User*, User*, int&, std::string&) { return MOD_RES_PASSTHRU; }
144 void            Module::OnBuildNeighborList(User*, UserChanList&, std::map<User*,bool>&) { }
145 void            Module::OnGarbageCollect() { }
146 void            Module::OnText(User*, void*, int, const std::string&, char, CUList&) { }
147 void            Module::OnRunTestSuite() { }
148 void            Module::OnNamesListItem(User*, Membership*, std::string&, std::string&) { }
149 ModResult       Module::OnNumeric(User*, unsigned int, const std::string&) { return MOD_RES_PASSTHRU; }
150 void            Module::OnHookIO(StreamSocket*, ListenSocket*) { }
151 ModResult   Module::OnAcceptConnection(int, ListenSocket*, irc::sockets::sockaddrs*, irc::sockets::sockaddrs*) { return MOD_RES_PASSTHRU; }
152 void            Module::OnSendWhoLine(User*, User*, Channel*, std::string&) { }
153 ModResult       Module::OnChannelRestrictionApply(User*, Channel*, const char*) { return MOD_RES_PASSTHRU; }
154
155 ModuleManager::ModuleManager() : ModCount(0)
156 {
157 }
158
159 ModuleManager::~ModuleManager()
160 {
161 }
162
163 bool ModuleManager::Attach(Implementation i, Module* mod)
164 {
165         if (std::find(EventHandlers[i].begin(), EventHandlers[i].end(), mod) != EventHandlers[i].end())
166                 return false;
167
168         EventHandlers[i].push_back(mod);
169         return true;
170 }
171
172 bool ModuleManager::Detach(Implementation i, Module* mod)
173 {
174         EventHandlerIter x = std::find(EventHandlers[i].begin(), EventHandlers[i].end(), mod);
175
176         if (x == EventHandlers[i].end())
177                 return false;
178
179         EventHandlers[i].erase(x);
180         return true;
181 }
182
183 void ModuleManager::Attach(Implementation* i, Module* mod, size_t sz)
184 {
185         for (size_t n = 0; n < sz; ++n)
186                 Attach(i[n], mod);
187 }
188
189 void ModuleManager::DetachAll(Module* mod)
190 {
191         for (size_t n = I_BEGIN + 1; n != I_END; ++n)
192                 Detach((Implementation)n, mod);
193 }
194
195 bool ModuleManager::SetPriority(Module* mod, Priority s)
196 {
197         for (size_t n = I_BEGIN + 1; n != I_END; ++n)
198                 SetPriority(mod, (Implementation)n, s);
199
200         return true;
201 }
202
203 bool ModuleManager::SetPriority(Module* mod, Implementation i, Priority s, Module** modules, size_t sz)
204 {
205         /** To change the priority of a module, we first find its position in the vector,
206          * then we find the position of the other modules in the vector that this module
207          * wants to be before/after. We pick off either the first or last of these depending
208          * on which they want, and we make sure our module is *at least* before or after
209          * the first or last of this subset, depending again on the type of priority.
210          */
211         size_t swap_pos = 0;
212         size_t source = 0;
213         bool swap = true;
214         bool found = false;
215
216         /* Locate our module. This is O(n) but it only occurs on module load so we're
217          * not too bothered about it
218          */
219         for (size_t x = 0; x != EventHandlers[i].size(); ++x)
220         {
221                 if (EventHandlers[i][x] == mod)
222                 {
223                         source = x;
224                         found = true;
225                         break;
226                 }
227         }
228
229         /* Eh? this module doesnt exist, probably trying to set priority on an event
230          * theyre not attached to.
231          */
232         if (!found)
233                 return false;
234
235         switch (s)
236         {
237                 /* Dummy value */
238                 case PRIORITY_DONTCARE:
239                         swap = false;
240                 break;
241                 /* Module wants to be first, sod everything else */
242                 case PRIORITY_FIRST:
243                         if (prioritizationState != PRIO_STATE_FIRST)
244                                 swap = false;
245                         else
246                                 swap_pos = 0;
247                 break;
248                 /* Module wants to be last. */
249                 case PRIORITY_LAST:
250                         if (prioritizationState != PRIO_STATE_FIRST)
251                                 swap = false;
252                         else if (EventHandlers[i].empty())
253                                 swap_pos = 0;
254                         else
255                                 swap_pos = EventHandlers[i].size() - 1;
256                 break;
257                 /* Place this module after a set of other modules */
258                 case PRIORITY_AFTER:
259                 {
260                         /* Find the latest possible position */
261                         swap_pos = 0;
262                         swap = false;
263                         for (size_t x = 0; x != EventHandlers[i].size(); ++x)
264                         {
265                                 for (size_t n = 0; n < sz; ++n)
266                                 {
267                                         if ((modules[n]) && (EventHandlers[i][x] == modules[n]) && (x >= swap_pos) && (source <= swap_pos))
268                                         {
269                                                 swap_pos = x;
270                                                 swap = true;
271                                         }
272                                 }
273                         }
274                 }
275                 break;
276                 /* Place this module before a set of other modules */
277                 case PRIORITY_BEFORE:
278                 {
279                         swap_pos = EventHandlers[i].size() - 1;
280                         swap = false;
281                         for (size_t x = 0; x != EventHandlers[i].size(); ++x)
282                         {
283                                 for (size_t n = 0; n < sz; ++n)
284                                 {
285                                         if ((modules[n]) && (EventHandlers[i][x] == modules[n]) && (x <= swap_pos) && (source >= swap_pos))
286                                         {
287                                                 swap = true;
288                                                 swap_pos = x;
289                                         }
290                                 }
291                         }
292                 }
293                 break;
294         }
295
296         /* Do we need to swap? */
297         if (swap && (swap_pos != source))
298         {
299                 // We are going to change positions; we'll need to run again to verify all requirements
300                 if (prioritizationState == PRIO_STATE_LAST)
301                         prioritizationState = PRIO_STATE_AGAIN;
302                 /* Suggestion from Phoenix, "shuffle" the modules to better retain call order */
303                 int incrmnt = 1;
304
305                 if (source > swap_pos)
306                         incrmnt = -1;
307
308                 for (unsigned int j = source; j != swap_pos; j += incrmnt)
309                 {
310                         if (( j + incrmnt > EventHandlers[i].size() - 1) || (j + incrmnt < 0))
311                                 continue;
312
313                         std::swap(EventHandlers[i][j], EventHandlers[i][j+incrmnt]);
314                 }
315         }
316
317         return true;
318 }
319
320 std::string& ModuleManager::LastError()
321 {
322         return LastModuleError;
323 }
324
325 bool ModuleManager::PublishFeature(const std::string &FeatureName, Module* Mod)
326 {
327         if (Features.find(FeatureName) == Features.end())
328         {
329                 Features[FeatureName] = Mod;
330                 return true;
331         }
332         return false;
333 }
334
335 bool ModuleManager::UnpublishFeature(const std::string &FeatureName)
336 {
337         featurelist::iterator iter = Features.find(FeatureName);
338
339         if (iter == Features.end())
340                 return false;
341
342         Features.erase(iter);
343         return true;
344 }
345
346 Module* ModuleManager::FindFeature(const std::string &FeatureName)
347 {
348         featurelist::iterator iter = Features.find(FeatureName);
349
350         if (iter == Features.end())
351                 return NULL;
352
353         return iter->second;
354 }
355
356 bool ModuleManager::PublishInterface(const std::string &InterfaceName, Module* Mod)
357 {
358         interfacelist::iterator iter = Interfaces.find(InterfaceName);
359
360         if (iter == Interfaces.end())
361         {
362                 modulelist ml;
363                 ml.push_back(Mod);
364                 Interfaces[InterfaceName] = std::make_pair(0, ml);
365         }
366         else
367         {
368                 iter->second.second.push_back(Mod);
369         }
370         return true;
371 }
372
373 bool ModuleManager::UnpublishInterface(const std::string &InterfaceName, Module* Mod)
374 {
375         interfacelist::iterator iter = Interfaces.find(InterfaceName);
376
377         if (iter == Interfaces.end())
378                 return false;
379
380         for (modulelist::iterator x = iter->second.second.begin(); x != iter->second.second.end(); x++)
381         {
382                 if (*x == Mod)
383                 {
384                         iter->second.second.erase(x);
385                         if (iter->second.second.empty())
386                                 Interfaces.erase(InterfaceName);
387                         return true;
388                 }
389         }
390         return false;
391 }
392
393 modulelist* ModuleManager::FindInterface(const std::string &InterfaceName)
394 {
395         interfacelist::iterator iter = Interfaces.find(InterfaceName);
396         if (iter == Interfaces.end())
397                 return NULL;
398         else
399                 return &(iter->second.second);
400 }
401
402 bool ModuleManager::ModuleHasInterface(Module* mod, const std::string& InterfaceName)
403 {
404         interfacelist::iterator iter = Interfaces.find(InterfaceName);
405         if (iter == Interfaces.end())
406                 return false;
407         else
408         {
409                 modulelist& ml = iter->second.second;
410                 modulelist::iterator mi = std::find(ml.begin(), ml.end(), mod);
411                 return (mi != ml.end());
412         }
413 }
414
415 void ModuleManager::UseInterface(const std::string &InterfaceName)
416 {
417         interfacelist::iterator iter = Interfaces.find(InterfaceName);
418         if (iter != Interfaces.end())
419                 iter->second.first++;
420
421 }
422
423 void ModuleManager::DoneWithInterface(const std::string &InterfaceName)
424 {
425         interfacelist::iterator iter = Interfaces.find(InterfaceName);
426         if (iter != Interfaces.end())
427                 iter->second.first--;
428 }
429
430 std::pair<int,std::string> ModuleManager::GetInterfaceInstanceCount(Module* m)
431 {
432         for (interfacelist::iterator iter = Interfaces.begin(); iter != Interfaces.end(); iter++)
433         {
434                 for (modulelist::iterator x = iter->second.second.begin(); x != iter->second.second.end(); x++)
435                 {
436                         if (*x == m)
437                         {
438                                 return std::make_pair(iter->second.first, iter->first);
439                         }
440                 }
441         }
442         return std::make_pair(0, "");
443 }
444
445 const std::string& ModuleManager::GetModuleName(Module* m)
446 {
447         static std::string nothing;
448
449         for (std::map<std::string, Module*>::iterator n = Modules.begin(); n != Modules.end(); ++n)
450         {
451                 if (n->second == m)
452                         return n->first;
453         }
454
455         return nothing;
456 }
457
458 CmdResult InspIRCd::CallCommandHandler(const std::string &commandname, const std::vector<std::string>& parameters, User* user)
459 {
460         return this->Parser->CallHandler(commandname, parameters, user);
461 }
462
463 bool InspIRCd::IsValidModuleCommand(const std::string &commandname, int pcnt, User* user)
464 {
465         return this->Parser->IsValidCommand(commandname, pcnt, user);
466 }
467
468 void InspIRCd::AddCommand(Command *f)
469 {
470         if (!this->Parser->AddCommand(f))
471         {
472                 throw ModuleException("Command "+std::string(f->command)+" already exists.");
473         }
474 }
475
476 void InspIRCd::SendMode(const std::vector<std::string>& parameters, User *user)
477 {
478         this->Modes->Process(parameters, user);
479 }
480
481 bool InspIRCd::AddResolver(Resolver* r, bool cached)
482 {
483         if (!cached)
484                 return this->Res->AddResolverClass(r);
485         else
486         {
487                 r->TriggerCachedResult();
488                 delete r;
489                 return true;
490         }
491 }
492
493 Module* ModuleManager::Find(const std::string &name)
494 {
495         std::map<std::string, Module*>::iterator modfind = Modules.find(name);
496
497         if (modfind == Modules.end())
498                 return NULL;
499         else
500                 return modfind->second;
501 }
502
503 const std::vector<std::string> ModuleManager::GetAllModuleNames(int filter)
504 {
505         std::vector<std::string> retval;
506         for (std::map<std::string, Module*>::iterator x = Modules.begin(); x != Modules.end(); ++x)
507                 if (!filter || (x->second->GetVersion().Flags & filter))
508                         retval.push_back(x->first);
509         return retval;
510 }
511
512 ConfigReader::ConfigReader()
513 {
514         this->error = 0;
515 }
516
517
518 ConfigReader::~ConfigReader()
519 {
520 }
521
522 static ConfigTag* SlowGetTag(const std::string &tag, int index)
523 {
524         ConfigTagList tags = ServerInstance->Config->ConfTags(tag);
525         while (tags.first != tags.second)
526         {
527                 if (!index)
528                         return tags.first->second;
529                 tags.first++;
530                 index--;
531         }
532         return NULL;
533 }
534
535 std::string ConfigReader::ReadValue(const std::string &tag, const std::string &name, const std::string &default_value, int index, bool allow_linefeeds)
536 {
537         std::string result = default_value;
538         if (!SlowGetTag(tag, index)->readString(name, result, allow_linefeeds))
539         {
540                 this->error = CONF_VALUE_NOT_FOUND;
541         }
542         return result;
543 }
544
545 std::string ConfigReader::ReadValue(const std::string &tag, const std::string &name, int index, bool allow_linefeeds)
546 {
547         return ReadValue(tag, name, "", index, allow_linefeeds);
548 }
549
550 bool ConfigReader::ReadFlag(const std::string &tag, const std::string &name, const std::string &default_value, int index)
551 {
552         bool def = (default_value == "yes");
553         return SlowGetTag(tag, index)->getBool(name, def);
554 }
555
556 bool ConfigReader::ReadFlag(const std::string &tag, const std::string &name, int index)
557 {
558         return ReadFlag(tag, name, "", index);
559 }
560
561
562 int ConfigReader::ReadInteger(const std::string &tag, const std::string &name, const std::string &default_value, int index, bool need_positive)
563 {
564         int v = atoi(default_value.c_str());
565         int result = SlowGetTag(tag, index)->getInt(name, v);
566
567         if ((need_positive) && (result < 0))
568         {
569                 this->error = CONF_INT_NEGATIVE;
570                 return 0;
571         }
572
573         return result;
574 }
575
576 int ConfigReader::ReadInteger(const std::string &tag, const std::string &name, int index, bool need_positive)
577 {
578         return ReadInteger(tag, name, "", index, need_positive);
579 }
580
581 long ConfigReader::GetError()
582 {
583         long olderr = this->error;
584         this->error = 0;
585         return olderr;
586 }
587
588 int ConfigReader::Enumerate(const std::string &tag)
589 {
590         ServerInstance->Logs->Log("MODULE", DEBUG, "Module is using ConfigReader::Enumerate on %s; this is slow!",
591                 tag.c_str());
592         int i=0;
593         while (SlowGetTag(tag, i)) i++;
594         return i;
595 }
596
597 FileReader::FileReader(const std::string &filename)
598 {
599         LoadFile(filename);
600 }
601
602 FileReader::FileReader()
603 {
604 }
605
606 std::string FileReader::Contents()
607 {
608         std::string x;
609         for (file_cache::iterator a = this->fc.begin(); a != this->fc.end(); a++)
610         {
611                 x.append(*a);
612                 x.append("\r\n");
613         }
614         return x;
615 }
616
617 unsigned long FileReader::ContentSize()
618 {
619         return this->contentsize;
620 }
621
622 void FileReader::CalcSize()
623 {
624         unsigned long n = 0;
625         for (file_cache::iterator a = this->fc.begin(); a != this->fc.end(); a++)
626                 n += (a->length() + 2);
627         this->contentsize = n;
628 }
629
630 void FileReader::LoadFile(const std::string &filename)
631 {
632         file_cache c;
633         c.clear();
634         if (ServerInstance->Config->ReadFile(c,filename.c_str()))
635         {
636                 this->fc = c;
637                 this->CalcSize();
638         }
639 }
640
641
642 FileReader::~FileReader()
643 {
644 }
645
646 bool FileReader::Exists()
647 {
648         return (!(fc.size() == 0));
649 }
650
651 std::string FileReader::GetLine(int x)
652 {
653         if ((x<0) || ((unsigned)x>fc.size()))
654                 return "";
655         return fc[x];
656 }
657
658 int FileReader::FileSize()
659 {
660         return fc.size();
661 }