#define __INSPIRCD_H__
#ifndef WIN32
-#define DllExport
-#define CoreExport
+#define DllExport
+#define CoreExport
#define printf_c printf
#else
#include "inspircd_win32wrapper.h"
#endif
// Required system headers.
-#include <time.h>
-#include <stdarg.h>
+#include <ctime>
+#include <cstdarg>
+#include <algorithm>
+#include <cmath>
+#include <cstring>
+#include <climits>
+
+#include <sstream>
+#include <string>
+#include <vector>
+#include <deque>
+#include <map>
+#include <bitset>
+#include <set>
+
+/** A list of failed port bindings, used for informational purposes on startup */
+typedef std::vector<std::pair<std::string, std::string> > FailedPortList;
+
+/** A cached text file stored with its contents as lines
+ */
+typedef std::deque< std::string > file_cache;
+
+/** A configuration key and value pair
+ */
+typedef std::pair< std::string, std::string > KeyVal;
+
+/** A list of related configuration keys and values
+ */
+typedef std::vector< KeyVal > KeyValList;
+
+/** An entire config file, built up of KeyValLists
+ */
+typedef std::multimap< std::string, KeyValList > ConfigDataHash;
#include "inspircd_config.h"
+#include "numerics.h"
#include "uid.h"
#include "users.h"
#include "channels.h"
#include "inspstring.h"
#include "protocol.h"
+#ifndef PATH_MAX
+#warning Potentially broken system, PATH_MAX undefined
+#define PATH_MAX 4096
+#endif
+
/**
* Used to define the maximum number of parameters a command may have.
*/
}
};
-/** A list of failed port bindings, used for informational purposes on startup */
-typedef std::vector<std::pair<std::string, long> > FailedPortList;
-
class InspIRCd;
DEFINE_HANDLER1(ProcessUserHandler, void, User*);
-DEFINE_HANDLER1(IsNickHandler, bool, const char*);
+DEFINE_HANDLER2(IsNickHandler, bool, const char*, size_t);
DEFINE_HANDLER1(IsIdentHandler, bool, const char*);
DEFINE_HANDLER1(FindDescriptorHandler, User*, int);
DEFINE_HANDLER1(FloodQuitUserHandler, void, User*);
-DEFINE_HANDLER1(IsChannelHandler, bool, const char*);
+DEFINE_HANDLER2(IsChannelHandler, bool, const char*, size_t);
DEFINE_HANDLER1(IsSIDHandler, bool, const std::string&);
DEFINE_HANDLER1(RehashHandler, void, const std::string&);
class XLineManager;
class BanCacheManager;
+/** The background thread for config reading, so that reading from executable includes
+ * does not block.
+ */
class CoreExport ConfigReaderThread : public Thread
{
InspIRCd* ServerInstance;
bool do_bail;
- User* TheUser;
+ std::string TheUserUID;
public:
- ConfigReaderThread(InspIRCd* Instance, bool bail, User* user) : Thread(), ServerInstance(Instance), do_bail(bail), TheUser(user)
+ ConfigReaderThread(InspIRCd* Instance, bool bail, const std::string &useruid) : Thread(), ServerInstance(Instance), do_bail(bail), TheUserUID(useruid)
{
}
* classbase. Amongst other things, it contains a ModeParser,
* a DNS object, a CommandParser object, and a list of active
* Module objects, and facilities for Module objects to
- * interact with the core system it implements. You should
- * NEVER attempt to instantiate a class of type InspIRCd
- * yourself. If you do, this is equivalent to spawning a second
- * IRC server, and could have catastrophic consequences for the
- * program in terms of ram usage (basically, you could create
- * an obese forkbomb built from recursively spawning irc servers!)
+ * interact with the core system it implements.
*/
class CoreExport InspIRCd : public classbase
{
*/
time_t OLDTIME;
- /** A 64k buffer used to read client lines into
+ /** A 64k buffer used to read socket data into
+ * NOTE: update ValidateNetBufferSize if you change this
*/
char ReadBuffer[65535];
*/
ThreadEngine* Threads;
+ /** Mutex engine, handles mutexes for threading where required
+ */
+ MutexFactory* Mutexes;
+
/** The thread/class used to read config files in REHASH and on startup
*/
ConfigReaderThread* ConfigThread;
/** LogManager handles logging.
*/
LogManager *Logs;
-
+
/** ModuleManager contains everything related to loading/unloading
* modules.
*/
* @param chname A channel name to verify
* @return True if the name is valid
*/
- caller1<bool, const char*> IsChannel;
+ caller2<bool, const char*, size_t> IsChannel;
/** Return true if str looks like a server ID
* @param string to check against
*/
void SignalHandler(int signal);
- /** Sets the signal recieved
+ /** Sets the signal recieved
* @param signal the signal recieved
*/
static void SetSignal(int signal);
* @param n A nickname to verify
* @return True if the nick is valid
*/
- caller1<bool, const char*> IsNick;
+ caller2<bool, const char*, size_t> IsNick;
/** Return true if an ident is valid
* @param An ident to verify
*/
void SendMode(const std::vector<std::string>& parameters, User *user);
- /** Match two strings using pattern matching.
- * This operates identically to the global function match(),
- * except for that it takes std::string arguments rather than
- * const char* ones.
- * @param sliteral The literal string to match against
- * @param spattern The pattern to match against. CIDR and globs are supported.
+ /** Match two strings using pattern matching, optionally, with a map
+ * to check case against (may be NULL). If map is null, match will be case insensitive.
+ * @param str The literal string to match against
+ * @param mask The glob pattern to match against.
*/
- bool MatchText(const std::string &sliteral, const std::string &spattern);
+ static bool Match(const std::string &str, const std::string &mask, unsigned const char *map = NULL);
+ static bool Match(const char *str, const char *mask, unsigned const char *map = NULL);
+
+ /** Match two strings using pattern matching, optionally, with a map
+ * to check case against (may be NULL). If map is null, match will be case insensitive.
+ * Supports CIDR patterns as well as globs.
+ * @param str The literal string to match against
+ * @param mask The glob or CIDR pattern to match against.
+ */
+ static bool MatchCIDR(const std::string &str, const std::string &mask, unsigned const char *map = NULL);
+ static bool MatchCIDR(const char *str, const char *mask, unsigned const char *map = NULL);
/** Call the handler for a given command.
* @param commandname The command whos handler you wish to call
*/
void BufferedSocketCull();
+ /** Adds an extban char to the 005 token.
+ */
+ void AddExtBanChar(char c);
+
char* GetReadBuffer()
{
return this->ReadBuffer;
}
};
+ENTRYPOINT;
+
#endif