#pragma once
-#define _FILE_OFFSET_BITS 64
-#ifndef _LARGEFILE_SOURCE
-#define _LARGEFILE_SOURCE
-#endif
-
-#ifndef _WIN32
-#define DllExport
-#define CoreExport
-#else
-#include "inspircd_win32wrapper.h"
-/** Windows defines these already */
-#undef ERROR
-#endif
-
-#ifdef __GNUC__
-#define CUSTOM_PRINTF(STRING, FIRST) __attribute__((format(printf, STRING, FIRST)))
-#else
-#define CUSTOM_PRINTF(STRING, FIRST)
-#endif
-
-#if defined __clang__ || defined __GNUC__
-# define DEPRECATED_METHOD(function) function __attribute__((deprecated))
-#elif defined _MSC_VER
-# define DEPRECATED_METHOD(function) __declspec(deprecated) function
-#else
-# pragma message ("Warning! DEPRECATED_METHOD() does not work on your compiler!")
-# define DEPRECATED_METHOD(function) function
-#endif
-
-// Required system headers.
-#include <ctime>
-#include <cstdarg>
-#include <algorithm>
-#include <cmath>
-#include <cstring>
#include <climits>
+#include <cmath>
+#include <csignal>
+#include <cstdarg>
#include <cstdio>
-#ifndef _WIN32
-#include <unistd.h>
-#endif
+#include <cstring>
+#include <ctime>
-#if defined _LIBCPP_VERSION || defined _WIN32
-# define TR1NS std
-# include <unordered_map>
-#else
-# define TR1NS std::tr1
-# include <tr1/unordered_map>
-#endif
-#include <sstream>
-#include <string>
-#include <vector>
-#include <list>
+#include <algorithm>
+#include <bitset>
#include <deque>
+#include <list>
#include <map>
-#include <bitset>
#include <set>
-#include <time.h>
-#include "config.h"
+#include <sstream>
+#include <string>
+#include <vector>
+
+#include "compat.h"
#include "typedefs.h"
-#include "consolecolors.h"
CoreExport extern InspIRCd* ServerInstance;
+#include "config.h"
+#include "consolecolors.h"
#include "caller.h"
#include "cull_list.h"
#include "extensible.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.
*/
void SendTo(LocalUser* user);
};
-DEFINE_HANDLER2(IsNickHandler, bool, const std::string&, size_t);
+DEFINE_HANDLER1(IsNickHandler, bool, const std::string&);
DEFINE_HANDLER2(GenRandomHandler, void, char*, size_t);
DEFINE_HANDLER1(IsIdentHandler, bool, const std::string&);
-DEFINE_HANDLER2(IsChannelHandler, bool, const std::string&, size_t);
+DEFINE_HANDLER1(IsChannelHandler, bool, const std::string&);
DEFINE_HANDLER1(RehashHandler, void, const std::string&);
DEFINE_HANDLER3(OnCheckExemptionHandler, ModResult, User*, Channel*, const std::string&);
*/
FakeUser* FakeClient;
- static const char LogHeader[];
-
/** Find a user in the UUID hash
* @param uid The UUID to find
* @return A pointer to the user, or NULL if the user does not exist
*/
SnomaskManager* SNO;
- /** DNS class, provides resolver facilities to the core and modules
- */
- DNS* Res;
-
/** Timer manager class, triggers Timer timer events
*/
TimerManager* Timers;
/** Set to the current signal recieved
*/
- int s_signal;
+ static sig_atomic_t s_signal;
/** Protocol interface, overridden by server protocol modules
*/
ProtocolInterface* PI;
- /** Holds extensible for user nickforced
- */
- LocalIntExt NICKForced;
-
/** Holds extensible for user operquit
*/
LocalStringExt OperQuit;
*/
void CheckRoot();
- /** Determine the right path for, and open, the logfile
- * @param argv The argv passed to main() initially, used to calculate program path
- * @param argc The argc passed to main() initially, used to calculate program path
- * @return True if the log could be opened, false if otherwise
- */
- bool OpenLog(char** argv, int argc);
-
/** Return true if a channel name is valid
* @param chname A channel name to verify
* @return True if the name is valid
*/
- caller2<bool, const std::string&, size_t> IsChannel;
+ caller1<bool, const std::string&> IsChannel;
/** Return true if str looks like a server ID
* @param string to check against
/** Causes the server to exit immediately with exit code 0.
* The status code is required for signal handlers, and ignored.
*/
+
+ /** Printf-wrapper.
+ * @param How you want it formatted
+ * @param ...
+ * @return The formatted string
+ */
+ static const char* Format(const char* formatString, ...);
+
static void QuickExit(int status);
/** Return a count of channels on the network
* @param n A nickname to verify
* @return True if the nick is valid
*/
- caller2<bool, const std::string&, size_t> IsNick;
+ caller1<bool, const std::string&> IsNick;
/** Return true if an ident is valid
* @param An ident to verify
*/
caller1<bool, const std::string&> IsIdent;
- /** Add a dns Resolver class to this server's active set
- * @param r The resolver to add
- * @param cached If this value is true, then the cache will
- * be searched for the DNS result, immediately. If the value is
- * false, then a request will be sent to the nameserver, and the
- * result will not be immediately available. You should usually
- * use the boolean value which you passed to the Resolver
- * constructor, which Resolver will set appropriately depending
- * on if cached results are available and haven't expired. It is
- * however safe to force this value to false, forcing a remote DNS
- * lookup, but not an update of the cache.
- * @return True if the operation completed successfully. Note that
- * if this method returns true, you should not attempt to access
- * the resolver class you pass it after this call, as depending upon
- * the request given, the object may be deleted!
- */
- bool AddResolver(Resolver* r, bool cached);
-
/** Add a command to this server's command parser
* @param f A Command command handler object to add
* @throw ModuleException Will throw ModuleExcption if the command already exists
* @param map The character map to use when matching.
*/
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);
+ 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.
* @param map The character map to use when matching.
*/
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);
+ static bool MatchCIDR(const char *str, const char *mask, unsigned const char *map = NULL);
+
+ /** Matches a hostname and IP against a space delimited list of hostmasks.
+ * @param masks The space delimited masks to match against.
+ * @param hostname The hostname to try and match.
+ * @param ipaddr The IP address to try and match.
+ */
+ static bool MatchMask(const std::string& masks, const std::string& hostname, const std::string& ipaddr);
/** Return true if the given parameter is a valid nick!user\@host mask
* @param mask A nick!user\@host masak to match against
/** Returns the full version string of this ircd
* @return The version string
*/
- std::string GetVersionString(bool rawversion = false);
+ std::string GetVersionString(bool getFullVersion = false);
/** Attempt to write the process id to a given file
* @param filename The PID file to attempt to write to