X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=include%2Fmodules.h;h=95902536736de7ccee4b7f61a166a4ee6408b7d7;hb=ca4c4a67988419b9eb479ffcf82238dc1648b0ad;hp=accd9f03aef0b697b0f009cd6177e37649dcd340;hpb=0d95204c9848a56b02a1aca717ddca7f5e60e5a6;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/modules.h b/include/modules.h index accd9f03a..959025367 100644 --- a/include/modules.h +++ b/include/modules.h @@ -133,7 +133,7 @@ struct ModResult { } \ catch (CoreException& modexcept) \ { \ - ServerInstance->Logs->Log("MODULE",LOG_DEFAULT,"Exception caught: %s",modexcept.GetReason()); \ + ServerInstance->Logs->Log("MODULE", LOG_DEFAULT, "Exception caught: %s",modexcept.GetReason()); \ } \ _i = safei; \ } \ @@ -160,7 +160,7 @@ do { \ } \ catch (CoreException& except_ ## n) \ { \ - ServerInstance->Logs->Log("MODULE",LOG_DEFAULT,"Exception caught: %s", (except_ ## n).GetReason()); \ + ServerInstance->Logs->Log("MODULE", LOG_DEFAULT, "Exception caught: %s", (except_ ## n).GetReason()); \ (void) mod_ ## n; /* catch mismatched pairs */ \ } \ } \ @@ -361,7 +361,7 @@ enum Implementation I_OnSendSnotice, I_OnUserPreJoin, I_OnUserPreKick, I_OnUserKick, I_OnOper, I_OnInfo, I_OnWhois, I_OnUserPreInvite, I_OnUserInvite, I_OnUserPreMessage, I_OnUserPreNick, I_OnUserMessage, I_OnMode, I_OnGetServerDescription, I_OnSyncUser, - I_OnSyncChannel, I_OnDecodeMetaData, I_OnWallops, I_OnAcceptConnection, I_OnUserInit, + I_OnSyncChannel, I_OnDecodeMetaData, I_OnAcceptConnection, I_OnUserInit, I_OnChangeHost, I_OnChangeName, I_OnAddLine, I_OnDelLine, I_OnExpireLine, I_OnUserPostNick, I_OnPreMode, I_On005Numeric, I_OnKill, I_OnRemoteKill, I_OnLoadModule, I_OnUnloadModule, I_OnBackgroundTimer, I_OnPreCommand, I_OnCheckReady, I_OnCheckInvite, @@ -799,12 +799,6 @@ class CoreExport Module : public classbase, public usecountbase */ virtual void ProtoSendMetaData(void* opaque, Extensible* target, const std::string &extname, const std::string &extdata); - /** Called after every WALLOPS command. - * @param user The user sending the WALLOPS - * @param text The content of the WALLOPS message - */ - virtual void OnWallops(User* user, const std::string &text); - /** Called whenever a user's hostname is changed. * This event triggers after the host has been set. * @param user The user whos host is being changed @@ -1281,76 +1275,42 @@ class CoreExport Module : public classbase, public usecountbase virtual void OnSetUserIP(LocalUser* user); }; -/** Caches a text file into memory and can be used to retrieve lines from it. - * This class contains methods for read-only manipulation of a text file in memory. - * Either use the constructor type with one parameter to load a file into memory - * at construction, or use the LoadFile method to load a file. - */ +/** Provides an easy method of reading a text file into memory. */ class CoreExport FileReader : public classbase { - /** The file contents + /** The lines of text in the file. */ - std::vector fc; + std::vector lines; /** Content size in bytes */ - unsigned long contentsize; - - /** Calculate content size in bytes - */ - void CalcSize(); + unsigned long totalSize; public: - /** Default constructor. - * This method does not load any file into memory, you must use the LoadFile method - * after constructing the class this way. - */ - FileReader(); - - /** Secondary constructor. - * This method initialises the class with a file loaded into it ready for GetLine and - * and other methods to be called. If the file could not be loaded, FileReader::FileSize - * returns 0. - */ - FileReader(const std::string &filename); - - /** Default destructor. - * This deletes the memory allocated to the file. + /** Initializes a new file reader. */ - ~FileReader(); + FileReader() : totalSize(0) { } - /** Used to load a file. - * This method loads a file into the class ready for GetLine and - * and other methods to be called. If the file could not be loaded, FileReader::FileSize - * returns 0. + /** Initializes a new file reader and reads the specified file. + * @param file The file to read into memory. */ - void LoadFile(const std::string &filename); + FileReader(const std::string& filename); - /** Returns the whole content of the file as std::string + /** Loads a text file from disk. + * @param filename The file to read into memory. + * @throw CoreException The file can not be loaded. */ - std::string Contents(); + void Load(const std::string& filename); - /** Returns the entire size of the file as std::string + /** Retrieves the entire contents of the file cache as a single string. */ - unsigned long ContentSize(); + std::string GetString(); - /** Returns true if the file exists - * This function will return false if the file could not be opened. + /** Retrieves the entire contents of the file cache as a vector of strings. */ - bool Exists(); + const std::vector& GetVector() { return lines; } - /** Retrieve one line from the file. - * This method retrieves one line from the text file. If an empty non-NULL string is returned, - * the index was out of bounds, or the line had no data on it. - */ - std::string GetLine(int x); - - /** Returns the size of the file in lines. - * This method returns the number of lines in the read file. If it is 0, no lines have been - * read into memory, either because the file is empty or it does not exist, or cannot be - * opened due to permission problems. - */ - int FileSize(); + unsigned long TotalSize() { return totalSize; } }; /** A list of modules