#ifndef __CONFIGURATION_AUTO__
#define __CONFIGURATION_AUTO__
+/* this is for windows support. */
+#define CoreExport /**/
+#define DllExport /**/
+
#define CONFIG_FILE "$config{CONFIG_DIR}/inspircd.conf"
#define MOD_PATH "$config{MODULE_DIR}"
#define VERSION "$version"
/** The base class for all inspircd classes
*/
-class classbase
+class CoreExport classbase
{
public:
/** Time that the object was instantiated (used for TS calculation etc)
* a flags variable, and each module defining bits within the flag as 'theirs' as it is less prone to conflict and
* supports arbitary data storage).
*/
-class Extensible : public classbase
+class CoreExport Extensible : public classbase
{
/** Private data store
*/
* Use BoolSet::Set and BoolSet::Get to set and get bools in the bitmask,
* and Unset and Invert for special operations upon them.
*/
-class BoolSet : public classbase
+class CoreExport BoolSet : public classbase
{
char bits;
* This class represents a channel, and contains its name, modes, time created, topic, topic set time,
* etc, and an instance of the BanList type.
*/
-class chanrec : public Extensible
+class CoreExport chanrec : public Extensible
{
private:
* call command handlers by name, and chop up comma seperated
* parameters into multiple calls.
*/
-class CommandParser : public classbase
+class CoreExport CommandParser : public classbase
{
private:
/** The creator of this class
#include "users.h"
#include "channels.h"
-void DoStats(InspIRCd* Instance, char statschar, userrec* user, string_list &results);
+DllExport void DoStats(InspIRCd* Instance, char statschar, userrec* user, string_list &results);
/** Handle /STATS
*/
#include "channels.h"
const char* Spacify(char* n);
-void do_whois(InspIRCd* Instance, userrec* user, userrec* dest,unsigned long signon, unsigned long idle, const char* nick);
+DllExport void do_whois(InspIRCd* Instance, userrec* user, userrec* dest,unsigned long signon, unsigned long idle, const char* nick);
/** Handle /WHOIS
*/
};
/* Forward ref for timer */
-class MaintainTimer;
+class WhoWasMaintainTimer;
/* Forward ref for typedefs */
class WhoWasGroup;
/** InspTimer that is used to maintain the whowas list, called once an hour
*/
-MaintainTimer* timer;
+extern WhoWasMaintainTimer* timer;
/** A group of users related by nickname
*/
~WhoWasGroup();
};
-class MaintainTimer : public InspTimer
+class WhoWasMaintainTimer : public InspTimer
{
private:
InspIRCd* ServerInstance;
public:
- MaintainTimer(InspIRCd* Instance, long interval)
+ WhoWasMaintainTimer(InspIRCd* Instance, long interval)
: InspTimer(interval, Instance->Time(), true), ServerInstance(Instance)
{
}
* and storage of the configuration data needed to run the ircd, such as
* the servername, connect classes, /ADMIN data, MOTDs and filenames etc.
*/
-class ServerConfig : public Extensible
+class CoreExport ServerConfig : public Extensible
{
private:
/** Creator/owner
};
-bool InitializeDisabledCommands(const char* data, InspIRCd* ServerInstance);
+CoreExport bool InitializeDisabledCommands(const char* data, InspIRCd* ServerInstance);
bool InitTypes(ServerConfig* conf, const char* tag);
bool InitClasses(ServerConfig* conf, const char* tag);
/** connection is the base class of userrec, and holds basic user properties.
* This can be extended for holding other user-like objects in the future.
*/
-class connection : public EventHandler
+class CoreExport connection : public EventHandler
{
public:
/** Hostname of connection.
/** A structure that defines a command. Every command available
* in InspIRCd must be defined as derived from command_t.
*/
-class command_t : public Extensible
+class CoreExport command_t : public Extensible
{
protected:
/** Owner/Creator object
* a list of users which are to be culled when a long
* operation (such as a netsplit) has completed.
*/
-class CullItem : public classbase
+class CoreExport CullItem : public classbase
{
private:
/** Holds a pointer to the user,
* you attempt to add the same user twice, then the second
* attempt will be ignored.
*/
-class CullList : public classbase
+class CoreExport CullList : public classbase
{
private:
/** Creator of this CullList
/**
* Result status, used internally
*/
-class DNSResult : public classbase
+class CoreExport DNSResult : public classbase
{
public:
/** Result ID
/** Cached item stored in the query cache.
*/
-class CachedQuery
+class CoreExport CachedQuery
{
public:
/** The cached result data, an IP or hostname
*/
int CalcTTLRemaining()
{
- int n = expires - time(NULL);
+ int n = (int)expires - (int)time(NULL);
return (n < 0 ? 0 : n);
}
};
/** DNS cache information. Holds IPs mapped to hostnames, and hostnames mapped to IPs.
*/
+#ifndef WIN32
typedef nspace::hash_map<irc::string, CachedQuery, nspace::hash<irc::string> > dnscache;
+#else
+typedef nspace::hash_map<irc::string, CachedQuery, nspace::hash_compare<irc::string> > dnscache;
+#endif
/**
* Error types that class Resolver can emit to its error method.
/**
* A DNS Resource Record (rr)
*/
-class ResourceRecord;
+struct ResourceRecord;
/**
* Query and resource record types
* can occur by calling virtual methods, one is a success situation, and the other
* an error situation.
*/
-class Resolver : public Extensible
+class CoreExport Resolver : public Extensible
{
protected:
/**
* back to Resolver objects, based upon the request ID. You
* should never use this class yourself.
*/
-class DNS : public EventHandler
+class CoreExport DNS : public EventHandler
{
private:
/** The DLLManager class is able to load a module file by filename,
* and locate its init_module symbol.
*/
-class DLLManager
+class CoreExport DLLManager
{
public:
/** This constructor loads the module using dlopen()
/** This class is a specialized form of DLLManager designed to load InspIRCd modules.
* It's job is to call the init_module function and receive a factory pointer.
*/
-class DLLFactoryBase : public DLLManager
+class CoreExport DLLFactoryBase : public DLLManager
{
public:
/** Default constructor.
* This template is a container for ModuleFactory itself, so that it may 'plug' into ModuleFactory
* and provide module loading capabilities transparently.
*/
-template <class T> class DLLFactory : public DLLFactoryBase
+template <class T> class CoreExport DLLFactory : public DLLFactoryBase
{
public:
/** Default constructor.
/** Array that maps exit codes (ExitStatus types) to
* human-readable strings to be shown on shutdown.
*/
-const char* ExitCodes[] =
-{
- "No error", /* 0 */
- "DIE command", /* 1 */
- "execv() failed", /* 2 */
- "Internal error", /* 3 */
- "Config file error", /* 4 */
- "Logfile error", /* 5 */
- "Fork failed", /* 6 */
- "Bad commandline parameters", /* 7 */
- "No ports could be bound", /* 8 */
- "Can't write PID file", /* 9 */
- "SocketEngine could not initialize", /* 10 */
- "Refusing to start up as root", /* 11 */
- "Found a <die> tag!", /* 12 */
- "Couldn't load module on startup", /* 13 */
- "", /* 14 */
- "Received SIGTERM", /* 15 */
-};
+extern const char * ExitCodes[];
#endif
#include "inspircd_config.h"
+#ifndef WIN32
#include <ext/hash_map>
#define nspace __gnu_cxx
+#else
+#include <hash_map>
+#define nspace stdext
+using stdext::hash_map;
+#endif
#endif
};
#endif
-/** Because of weirdness in g++, before 3.x this was namespace std. It's now __gnu_cxx.
- * This is a #define'd alias.
- */
-namespace nspace
-{
- /** Convert a string to lower case respecting RFC1459
- * @param n A string to lowercase
- */
- void strlower(char *n);
-
- /** Hashing function to hash std::string without respect to case
- */
- template<> struct hash<std::string>
- {
- /** Hash a std::string using RFC1459 case sensitivity rules
- * @param s A string to hash
- * @return The hash value
- */
- size_t operator()(const string &s) const;
- };
-}
-
/** The irc namespace contains a number of helper classes.
*/
namespace irc
* std::string, or a const char** array, using overloaded
* constructors.
*/
- class stringjoiner
+ class CoreExport stringjoiner
{
private:
/** Output string
* It can then reproduce this list, clamped to a maximum of MAXMODES
* values per line.
*/
- class modestacker
+ class CoreExport modestacker
{
private:
/** The mode sequence and its parameters
* list will be ":item". This is to allow for parsing 'source' fields
* from data.
*/
- class tokenstream
+ class CoreExport tokenstream
{
private:
/** Original string
* the next token, until none remain, at which point the method returns
* an empty string.
*/
- class sepstream : public classbase
+ class CoreExport sepstream : public classbase
{
private:
/** Original string
/** A derived form of sepstream, which seperates on commas
*/
- class commasepstream : public sepstream
+ class CoreExport commasepstream : public sepstream
{
public:
commasepstream(const std::string &source) : sepstream(source, ',')
/** A derived form of sepstream, which seperates on spaces
*/
- class spacesepstream : public sepstream
+ class CoreExport spacesepstream : public sepstream
{
public:
spacesepstream(const std::string &source) : sepstream(source, ' ')
* start or end < 0) then GetToken() will return the first element
* of the pair of numbers.
*/
- class portparser : public classbase
+ class CoreExport portparser : public classbase
{
private:
/** Used to split on commas
* };
* \endcode
*/
- class dynamicbitmask : public classbase
+ class CoreExport dynamicbitmask : public classbase
{
private:
/** Data bits. We start with four of these,
/** Compare two strings of size n
*/
- static int compare(const char* str1, const char* str2, size_t n);
+ static CoreExport int compare(const char* str1, const char* str2, size_t n);
/** Find a char within a string up to position n
*/
- static const char* find(const char* s1, int n, char c);
+ static CoreExport const char* find(const char* s1, int n, char c);
};
- std::string hex(const unsigned char *raw, size_t rawsz);
+ CoreExport std::string hex(const unsigned char *raw, size_t rawsz);
/** This typedef declares irc::string based upon irc_char_traits
*/
typedef basic_string<char, irc_char_traits, allocator<char> > string;
- const char* Spacify(const char* n);
+ CoreExport const char* Spacify(const char* n);
}
/* Define operators for using >> and << with irc::string to an ostream on an istream. */
/* This was endless fun. No. Really. */
/* It was also the first core change Ommeh made, if anyone cares */
-std::ostream& operator<<(std::ostream &os, const irc::string &str);
-std::istream& operator>>(std::istream &is, irc::string &str);
+inline std::ostream& operator<<(std::ostream &os, const irc::string &str) { return os << str.c_str(); }
+inline std::istream& operator>>(std::istream &is, irc::string &str)
+{
+ std::string tmp;
+ is >> tmp;
+ str = tmp.c_str();
+ return is;
+}
/* Define operators for + and == with irc::string to std::string for easy assignment
* and comparison - Brain
*/
-std::string operator+ (std::string& leftval, irc::string& rightval);
-irc::string operator+ (irc::string& leftval, std::string& rightval);
-bool operator== (const std::string& leftval, const irc::string& rightval);
-bool operator== (const irc::string& leftval, const std::string& rightval);
+inline std::string operator+ (std::string& leftval, irc::string& rightval)
+{
+ return leftval + std::string(rightval.c_str());
+}
+
+inline irc::string operator+ (irc::string& leftval, std::string& rightval)
+{
+ return leftval + irc::string(rightval.c_str());
+}
+
+inline bool operator== (const std::string& leftval, const irc::string& rightval)
+{
+ return (leftval.c_str() == rightval);
+}
+
+inline bool operator== (const irc::string& leftval, const std::string& rightval)
+{
+ return (leftval == rightval.c_str());
+}
+
+inline std::string assign(const irc::string &other) { return other.c_str(); }
+inline irc::string assign(const std::string &other) { return other.c_str(); }
+inline std::string& trim(std::string &str)
+{
+ std::string::size_type start = str.find_first_not_of(" ");
+ std::string::size_type end = str.find_last_not_of(" ");
+ if (start == std::string::npos || end == std::string::npos)
+ str = "";
+ else
+ str = str.substr(start, end-start+1);
+
+ return str;
+}
-std::string assign(const irc::string &other);
-irc::string assign(const std::string &other);
-std::string& trim(std::string &str);
+/* Hashing stuff is totally different on vc++'s hash_map implementation, so to save a buttload of #ifdefs we'll just
+ do it all at once - Burlex */
namespace nspace
{
/** Hashing function to hash irc::string
*/
+#ifdef WINDOWS
+ template<> class CoreExport hash_compare<irc::string, std::less<irc::string> >
+ {
+ public:
+ enum { bucket_size = 4, min_buckets = 8 }; // Got these numbers from the CRT source,
+ // if anyone wants to change them feel free.
+ bool operator()(const irc::string & s1, const irc::string & s2) const
+ {
+ if(s1.length() != s2.length()) return true;
+ return (irc::irc_char_traits::compare(s1.c_str(), s2.c_str(), s1.length()) < 0);
+ }
+
+ size_t operator()(const irc::string & s) const;
+ };
+
+ template<> class CoreExport hash_compare<std::string, std::less<std::string> >
+ {
+ public:
+ enum { bucket_size = 4, min_buckets = 8 };
+ bool operator()(const std::string & s1, const std::string & s2) const
+ {
+ if(s1.length() != s2.length()) return true;
+ return (irc::irc_char_traits::compare(s1.c_str(), s2.c_str(), s1.length()) < 0);
+ }
+
+ /** Hash a std::string using RFC1459 case sensitivity rules
+ * @param s A string to hash
+ * @return The hash value
+ */
+ size_t operator()(const std::string & s) const;
+ };
+#else
template<> struct hash<irc::string>
{
size_t operator()(const irc::string &s) const;
};
+
+ template<> struct hash<std::string>
+ {
+ /** Hash a std::string using RFC1459 case sensitivity rules
+ * @param s A string to hash
+ * @return The hash value
+ */
+ size_t operator()(const string &s) const;
+ };
+#endif
+
+ /** Convert a string to lower case respecting RFC1459
+ * @param n A string to lowercase
+ */
+ void strlower(char *n);
}
#endif
#ifndef __INSPIRCD_H__
#define __INSPIRCD_H__
+#ifndef WIN32
+#define DllExport
+#define CoreExport
+#define printf_c printf
+#else
+#include "inspircd_win32wrapper.h"
+#undef DELETE
+#undef ERROR
+#endif
+
#include <time.h>
#include <string>
#include <sstream>
* I/O (linux seems to, as does freebsd) this will default to
* blocking behaviour.
*/
-class FileLogger : public EventHandler
+class CoreExport FileLogger : public EventHandler
{
protected:
/** The creator/owner of this object
* program in terms of ram usage (basically, you could create
* an obese forkbomb built from recursively spawning irc servers!)
*/
-class InspIRCd : public classbase
+class CoreExport InspIRCd : public classbase
{
private:
/** Holds a string describing the last module error to occur
/** Used to time out socket connections
*/
-class SocketTimeout : public InspTimer
+class CoreExport SocketTimeout : public InspTimer
{
private:
InspSocket* sock;
* and use the InspSocket constructors to establish connections
* and bindings.
*/
-class InspSocket : public EventHandler
+class CoreExport InspSocket : public EventHandler
{
public:
#define __IN_INSPSTRING_H
#include "inspircd_config.h"
+#include <string.h>
#include <cstddef>
#ifndef HAS_STRLCPY
-size_t strlcpy(char *dst, const char *src, size_t siz);
-size_t strlcat(char *dst, const char *src, size_t siz);
+CoreExport size_t strlcpy(char *dst, const char *src, size_t siz);
+CoreExport size_t strlcat(char *dst, const char *src, size_t siz);
#endif
-int charlcat(char* x,char y,int z);
-bool charremove(char* mp, char remove);
+CoreExport int charlcat(char* x,char y,int z);
+CoreExport bool charremove(char* mp, char remove);
+inline char * strnewdup(const char * s1)
+{
+ size_t len = strlen(s1) + 1;
+ char * p = new char[len];
+ memcpy(p, s1, len);
+ return p;
+}
#endif
* mode is expected to have a parameter, then this is
* equivalent to returning MODEACTION_DENY.
*/
-class ModeHandler : public Extensible
+class CoreExport ModeHandler : public Extensible
{
protected:
InspIRCd* ServerInstance;
* and attach it to the mode using Server::AddModeWatcher and Server::DelModeWatcher.
* A ModeWatcher will be called both before and after the mode change.
*/
-class ModeWatcher : public Extensible
+class CoreExport ModeWatcher : public Extensible
{
protected:
InspIRCd* ServerInstance;
* parses client to server MODE strings for user and channel modes, and performs
* processing for the 004 mode list numeric, amongst other things.
*/
-class ModeParser : public classbase
+class CoreExport ModeParser : public classbase
{
private:
InspIRCd* ServerInstance;
#define FD_MAGIC_NUMBER -42
// useful macros
-
+#ifdef WINDOWS
+#define IS_LOCAL(x) ((x->GetFd() > -1))
+#else
#define IS_LOCAL(x) ((x->GetFd() > -1) && (x->GetFd() <= MAX_DESCRIPTORS))
+#endif
#define IS_REMOTE(x) (x->GetFd() < 0)
#define IS_MODULE_CREATED(x) (x->GetFd() == FD_MAGIC_NUMBER)
#define IS_OPER(x) (*x->oper)
* The four members (set by the constructor only) indicate details as to the version number
* of a module. A class of type Version is returned by the GetVersion method of the Module class.
*/
-class Version : public classbase
+class CoreExport Version : public classbase
{
public:
const int Major, Minor, Revision, Build, Flags, API;
* This class is used to represent a basic data structure which is passed
* between modules for safe inter-module communications.
*/
-class ModuleMessage : public Extensible
+class CoreExport ModuleMessage : public Extensible
{
public:
virtual ~ModuleMessage() {};
* using the Send() method, which will call the given module's OnRequest
* method with this class as its parameter.
*/
-class Request : public ModuleMessage
+class CoreExport Request : public ModuleMessage
{
protected:
/** This member holds a pointer to arbitary data set by the emitter of the message
* using the Send() method, which will trigger the OnEvent method in
* all modules passing the object as its parameter.
*/
-class Event : public ModuleMessage
+class CoreExport Event : public ModuleMessage
{
protected:
/** This member holds a pointer to arbitary data set by the emitter of the message
* be loaded. If this happens, the error message returned by ModuleException::GetReason will be displayed to the user
* attempting to load the module, or dumped to the console if the ircd is currently loading for the first time.
*/
-class CoreException : public std::exception
+class CoreExport CoreException : public std::exception
{
protected:
/** Holds the error message to be displayed
}
};
-class ModuleException : public CoreException
+class CoreExport ModuleException : public CoreException
{
public:
/** Default constructor, just uses the error mesage 'Module threw an exception'.
* its methods will be called when irc server events occur. class inherited from module must be
* instantiated by the ModuleFactory class (see relevent section) for the module to be initialised.
*/
-class Module : public Extensible
+class CoreExport Module : public Extensible
{
protected:
InspIRCd* ServerInstance;
* Constructing the class using one parameter allows you to specify a path to your own configuration
* file, otherwise, inspircd.conf is read.
*/
-class ConfigReader : public classbase
+class CoreExport ConfigReader : public classbase
{
protected:
InspIRCd* ServerInstance;
* 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.
*/
-class FileReader : public classbase
+class CoreExport FileReader : public classbase
{
InspIRCd* ServerInstance;
/** The file contents
* In most cases, the simple class shown in the example module m_foobar.so will suffice for most
* modules.
*/
-class ModuleFactory : public classbase
+class CoreExport ModuleFactory : public classbase
{
public:
/** The default constructor does nothing.
* Modules and the core can enable and disable snomask characters. If they do,
* then sending snomasks using these characters becomes possible.
*/
-class SnomaskManager : public Extensible
+class CoreExport SnomaskManager : public Extensible
{
private:
/** Creator/owner
#ifndef INSPIRCD_SOCKET_H
#define INSPIRCD_SOCKET_H
+#ifndef WIN32
+
#include <arpa/inet.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <unistd.h>
#include <fcntl.h>
#include <netdb.h>
+
+#else
+
+#include "inspircd_win32wrapper.h"
+
+#endif
+
#include <errno.h>
#include "inspircd_config.h"
#include "socketengine.h"
+/* Accept Define */
+#ifdef CONFIG_USE_IOCP
+#define _accept(s, addr, addrlen) __accept_socket(s, addr, addrlen, m_acceptEvent)
+#define _getsockname(fd, sockptr, socklen) __getsockname(fd, sockptr, socklen, m_acceptEvent)
+#else
+#define _accept accept
+#define _getsockname getsockname
+#endif
+
namespace irc
{
/** This namespace contains various protocol-independent helper classes.
* @returns True if the first mask_bits of address matches the first
* mask_bits of mask.
*/
- bool MatchCIDRBits(unsigned char* address, unsigned char* mask, unsigned int mask_bits);
+ CoreExport bool MatchCIDRBits(unsigned char* address, unsigned char* mask, unsigned int mask_bits);
/** Match CIDR, without matching username/nickname parts.
*
* @param cidr_mask The human readable mask, e.g. 1.2.0.0/16
* @return True if the mask matches the address
*/
- bool MatchCIDR(const char* address, const char* cidr_mask);
+ CoreExport bool MatchCIDR(const char* address, const char* cidr_mask);
/** Match CIDR, including an optional username/nickname part.
*
* @param cidr_mask The human readable mask, e.g. *\@1.2.0.0/16
* @return True if the mask matches the address
*/
- bool MatchCIDR(const char* address, const char* cidr_mask, bool match_with_username);
+ CoreExport bool MatchCIDR(const char* address, const char* cidr_mask, bool match_with_username);
/** Convert an insp_inaddr into human readable form.
*
* @return A human-readable address. IPV6 addresses
* will be shortened to remove fields which are 0.
*/
- const char* insp_ntoa(insp_inaddr n);
+ CoreExport const char* insp_ntoa(insp_inaddr n);
/** Convert a human-readable address into an insp_inaddr.
*
* or any other number upon failure.
*/
- int insp_aton(const char* a, insp_inaddr* n);
+ CoreExport int insp_aton(const char* a, insp_inaddr* n);
/** Make a socket file descriptor a blocking socket
* @param s A valid file descriptor
*/
- void Blocking(int s);
+ CoreExport void Blocking(int s);
/** Make a socket file descriptor into a nonblocking socket
* @param s A valid file descriptor
*/
- void NonBlocking(int s);
+ CoreExport void NonBlocking(int s);
/** Create a new valid file descriptor using socket()
* @return On return this function will return a value >= 0 for success,
* or a negative value upon failure (negative values are invalid file
* descriptors)
*/
- int OpenTCPSocket(char* addr, int socktype = SOCK_STREAM);
+ CoreExport int OpenTCPSocket(char* addr, int socktype = SOCK_STREAM);
};
};
* It will create a new userrec for every valid connection
* and assign it a file descriptor.
*/
-class ListenSocket : public EventHandler
+class CoreExport ListenSocket : public EventHandler
{
protected:
/** The creator/owner of this object
* must have a file descriptor. What this file descriptor
* is actually attached to is completely up to you.
*/
-class EventHandler : public Extensible
+class CoreExport EventHandler : public Extensible
{
protected:
/** File descriptor.
* and EVENT_WRITE for write events.
*/
virtual void HandleEvent(EventType et, int errornum = 0) = 0;
+
+#ifdef WINDOWS
+
+ /** "Fake" file descriptor. This is windows-specific.
+ */
+ int m_internalFd;
+
+ /** Pointer to read event. We delete this so the buffer can't be used
+ * after the socket is deleted, and so it doesn't leak memory
+ */
+ void * m_readEvent;
+ void * m_writeEvent;
+ void * m_acceptEvent;
+
+#endif
};
/** Provides basic file-descriptor-based I/O support.
* have to be aware of which SocketEngine derived
* class they are using.
*/
-class SocketEngine : public Extensible
+class CoreExport SocketEngine : public Extensible
{
protected:
/** Owner/Creator
* @param fd The event handler to look for
* @return True if this fd has an event handler
*/
- bool HasFd(int fd);
+ virtual bool HasFd(int fd);
/** Returns the EventHandler attached to a specific fd.
* If the fd isnt in the socketengine, returns NULL.
* @param fd The event handler to look for
* @return A pointer to the event handler, or NULL
*/
- EventHandler* GetRef(int fd);
+ virtual EventHandler* GetRef(int fd);
/** Waits for events and dispatches them to handlers.
* Please note that this doesnt wait long, only
* your object (which you should override) will be called
* at the given time.
*/
-class InspTimer : public Extensible
+class CoreExport InspTimer : public Extensible
{
private:
/** The triggering time
* This will ensure timers are not missed, as well as removing timers that have
* expired and allowing the addition of new ones.
*/
-class TimerManager : public Extensible
+class CoreExport TimerManager : public Extensible
{
protected:
/** A group of timers all set to trigger at the same time
#include "modules.h"
#include "globals.h"
+#ifndef WIN32
typedef nspace::hash_map<std::string, userrec*, nspace::hash<string>, irc::StrHashComp> user_hash;
typedef nspace::hash_map<std::string, chanrec*, nspace::hash<string>, irc::StrHashComp> chan_hash;
+#else
+typedef nspace::hash_map<std::string, userrec*, nspace::hash_compare<string, less<string> > > user_hash;
+typedef nspace::hash_map<std::string, chanrec*, nspace::hash_compare<string, less<string> > > chan_hash;
+#endif
-typedef std::vector<std::string> servernamelist;
+typedef std::vector<std::string*> servernamelist;
typedef std::deque<std::string> file_cache;
#endif
};
enum RegistrationState {
+
+#ifndef WIN32 // Burlex: This is already defined in win32, luckily it is still 0.
REG_NONE = 0, /* Has sent nothing */
+#endif
+
REG_USER = 1, /* Has sent USER */
REG_NICK = 2, /* Has sent NICK */
REG_NICKUSER = 3, /* Bitwise combination of REG_NICK and REG_USER */
/** Derived from Resolver, and performs user forward/reverse lookups.
*/
-class UserResolver : public Resolver
+class CoreExport UserResolver : public Resolver
{
private:
/** User this class is 'attached' to.
/** Holds information relevent to <connect allow> and <connect deny> tags in the config file.
*/
-class ConnectClass : public classbase
+class CoreExport ConnectClass : public classbase
{
private:
/** Type of line, either CC_ALLOW or CC_DENY
class userrec;
-class VisData
+class CoreExport VisData
{
public:
VisData();
* by nickname, or the FindDescriptor method of the InspIRCd class to find a specific user by their
* file descriptor value.
*/
-class userrec : public connection
+class CoreExport userrec : public connection
{
private:
/** Pointer to creator.
#include "inspircd_config.h"
-bool match(const char *str, const char *mask);
-bool match(const char *str, const char *mask, bool use_cidr_match);
-bool match(bool case_sensitive, const char *str, const char *mask);
-bool match(bool case_sensitive, const char *str, const char *mask, bool use_cidr_match);
+CoreExport bool match(const char *str, const char *mask);
+CoreExport bool match(const char *str, const char *mask, bool use_cidr_match);
+CoreExport bool match(bool case_sensitive, const char *str, const char *mask);
+CoreExport bool match(bool case_sensitive, const char *str, const char *mask, bool use_cidr_match);
/** XLine is the base class for ban lines such as G lines and K lines.
*/
-class XLine : public classbase
+class CoreExport XLine : public classbase
{
public:
/** KLine class
*/
-class KLine : public XLine
+class CoreExport KLine : public XLine
{
public:
/** Hostmask (ident@host) to match against
/** GLine class
*/
-class GLine : public XLine
+class CoreExport GLine : public XLine
{
public:
/** Hostmask (ident@host) to match against
/** ELine class
*/
-class ELine : public XLine
+class CoreExport ELine : public XLine
{
public:
/** Hostmask (ident@host) to match against
/** ZLine class
*/
-class ZLine : public XLine
+class CoreExport ZLine : public XLine
{
public:
/** IP Address (xx.yy.zz.aa) to match against
/** QLine class
*/
-class QLine : public XLine
+class CoreExport QLine : public XLine
{
public:
/** Nickname to match against.
/** XLineManager is a class used to manage glines, klines, elines, zlines and qlines.
*/
-class XLineManager
+class CoreExport XLineManager
{
protected:
/** The owner/creator of this class
#include "commands/cmd_admin.h"
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_admin(Instance);
}
#include "modules.h"
#include "commands/cmd_away.h"
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_away(Instance);
}
#include "users.h"
#include "commands/cmd_clearcache.h"
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_clearcache(Instance);
}
/** Handle /COMMANDS
*/
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_commands(Instance);
}
* This is handled by the server linking module, if necessary. Do not remove this stub.
*/
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_connect(Instance);
}
#include "commands/cmd_die.h"
#include "exitcodes.h"
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_die(Instance);
}
#include "xline.h"
#include "commands/cmd_eline.h"
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_eline(Instance);
}
#include "xline.h"
#include "commands/cmd_gline.h"
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_gline(Instance);
}
#include "modules.h"
#include "commands/cmd_info.h"
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_info(Instance);
}
user->WriteServ( "371 %s : typobox43 Jazza", user->nick);
user->WriteServ( "371 %s : jamie LeaChim", user->nick);
user->WriteServ( "371 %s : satmd nenolod", user->nick);
- user->WriteServ( "371 %s : HiroP", user->nick);
+ user->WriteServ( "371 %s : HiroP Burlex", user->nick);
user->WriteServ( "371 %s : ", user->nick);
user->WriteServ( "371 %s :\2Quality Assurance\2:", user->nick);
user->WriteServ( "371 %s : Bricker owine", user->nick);
#include "modules.h"
#include "commands/cmd_invite.h"
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_invite(Instance);
}
#include "inspircd.h"
#include "commands/cmd_ison.h"
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_ison(Instance);
}
#include "users.h"
#include "commands/cmd_join.h"
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_join(Instance);
}
#include "inspircd.h"
#include "commands/cmd_kick.h"
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_kick(Instance);
}
#include "wildcard.h"
#include "commands/cmd_kill.h"
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_kill(Instance);
}
#include "xline.h"
#include "commands/cmd_kline.h"
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_kline(Instance);
}
#include "modules.h"
#include "commands/cmd_links.h"
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_links(Instance);
}
/** Handle /LIST
*/
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_list(Instance);
}
#include "users.h"
#include "commands/cmd_loadmodule.h"
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_loadmodule(Instance);
}
#include "inspircd.h"
#include "commands/cmd_lusers.h"
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_lusers(Instance);
}
#include "users.h"
#include "commands/cmd_map.h"
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_map(Instance);
}
#include "users.h"
#include "commands/cmd_mode.h"
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_mode(Instance);
}
"OnPostCommand", "OnPostJoin", "OnWhoisLine", "OnBuildExemptList", "OnRawSocketConnect", "OnGarbageCollect", NULL
};
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_modules(Instance);
}
#include "users.h"
#include "commands/cmd_motd.h"
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_motd(Instance);
}
#include "users.h"
#include "commands/cmd_names.h"
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_names(Instance);
}
#include "xline.h"
#include "commands/cmd_nick.h"
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_nick(Instance);
}
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_notice(Instance);
}
return false;
}
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_oper(Instance);
}
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_part(Instance);
}
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_pass(Instance);
}
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_ping(Instance);
}
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_pong(Instance);
}
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_privmsg(Instance);
}
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_qline(Instance);
}
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_quit(Instance);
}
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_rehash(Instance);
}
#include "users.h"
#include "commands/cmd_reloadmodule.h"
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_reloadmodule(Instance);
}
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_restart(Instance);
}
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_rules(Instance);
}
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_server(Instance);
}
*/
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_squit(Instance);
}
#include "inspircd.h"
#include "configreader.h"
+#ifndef WIN32
#include <sys/resource.h>
+#endif
#include "users.h"
#include "modules.h"
#include "xline.h"
#include "commands/cmd_whowas.h"
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_stats(Instance);
}
return CMD_SUCCESS;
}
-void DoStats(InspIRCd* ServerInstance, char statschar, userrec* user, string_list &results)
+DllExport void DoStats(InspIRCd* ServerInstance, char statschar, userrec* user, string_list &results)
{
std::string sn = ServerInstance->Config->ServerName;
/* stats z (debug and memory info) */
case 'z':
{
- rusage R;
+#ifndef WIN32
+ rusage R;
results.push_back(sn+" 240 "+user->nick+" :InspIRCd(CLASS) "+ConvToStr(sizeof(InspIRCd))+" bytes");
results.push_back(sn+" 249 "+user->nick+" :Users(HASH_MAP) "+ConvToStr(ServerInstance->clientlist->size())+" ("+ConvToStr(ServerInstance->clientlist->size()*sizeof(userrec))+" bytes, "+ConvToStr(ServerInstance->clientlist->bucket_count())+" buckets)");
results.push_back(sn+" 249 "+user->nick+" :Channels(HASH_MAP) "+ConvToStr(ServerInstance->chanlist->size())+" ("+ConvToStr(ServerInstance->chanlist->size()*sizeof(chanrec))+" bytes, "+ConvToStr(ServerInstance->chanlist->bucket_count())+" buckets)");
results.push_back(sn+" 249 "+user->nick+" :Commands(VECTOR) "+ConvToStr(ServerInstance->Parser->cmdlist.size())+" ("+ConvToStr(ServerInstance->Parser->cmdlist.size()*sizeof(command_t))+" bytes)");
-
+#else
+ results.push_back(sn+" 240 "+user->nick+" :InspIRCd(CLASS) "+ConvToStr(sizeof(InspIRCd))+" bytes");
+ results.push_back(sn+" 249 "+user->nick+" :Users(HASH_MAP) "+ConvToStr(ServerInstance->clientlist->size())+" ("+ConvToStr(ServerInstance->clientlist->size()*sizeof(userrec))+" bytes)");
+ results.push_back(sn+" 249 "+user->nick+" :Channels(HASH_MAP) "+ConvToStr(ServerInstance->chanlist->size())+" ("+ConvToStr(ServerInstance->chanlist->size()*sizeof(chanrec))+" bytes)");
+ results.push_back(sn+" 249 "+user->nick+" :Commands(VECTOR) "+ConvToStr(ServerInstance->Parser->cmdlist.size())+" ("+ConvToStr(ServerInstance->Parser->cmdlist.size()*sizeof(command_t))+" bytes)");
+#endif
if (!ServerInstance->Config->WhoWasGroupSize == 0 && !ServerInstance->Config->WhoWasMaxGroups == 0)
{
command_t* whowas_command = ServerInstance->Parser->GetHandler("WHOWAS");
results.push_back(sn+" 249 "+user->nick+" :Modules(VECTOR) "+ConvToStr(ServerInstance->modules.size())+" ("+ConvToStr(ServerInstance->modules.size()*sizeof(Module))+" bytes)");
results.push_back(sn+" 249 "+user->nick+" :ClassFactories(VECTOR) "+ConvToStr(ServerInstance->factory.size())+" ("+ConvToStr(ServerInstance->factory.size()*sizeof(ircd_module))+" bytes)");
- if (!getrusage(0,&R)) /* RUSAGE_SELF */
+#ifndef WIN32
+ if (!getrusage(0,&R)) /* RUSAGE_SELF */
{
results.push_back(sn+" 249 "+user->nick+" :Total allocation: "+ConvToStr(R.ru_maxrss)+"K");
results.push_back(sn+" 249 "+user->nick+" :Signals: "+ConvToStr(R.ru_nsignals));
snprintf(percent, 30, "%03.5f%%", per);
results.push_back(sn+" 249 "+user->nick+" :CPU Usage: "+percent);
}
+#endif
}
break;
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_summon(Instance);
}
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_time(Instance);
}
#include "users.h"
#include "modules.h"
#include "commands/cmd_topic.h"
+#include "inspircd.h"
-
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_topic(Instance);
}
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_trace(Instance);
}
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_unloadmodule(Instance);
}
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_user(Instance);
}
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_userhost(Instance);
}
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_users(Instance);
}
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_version(Instance);
}
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_wallops(Instance);
}
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_who(Instance);
}
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_whois(Instance);
}
#include "users.h"
#include "commands/cmd_whowas.h"
-extern "C" command_t* init_command(InspIRCd* Instance)
+WhoWasMaintainTimer * timer;
+
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_whowas(Instance);
}
: command_t(Instance, "WHOWAS", 0, 1)
{
syntax = "<nick>{,<nick>}";
- timer = new MaintainTimer(Instance, 3600);
+ timer = new WhoWasMaintainTimer(Instance, 3600);
Instance->Timers->AddTimer(timer);
}
}
/* every hour, run this function which removes all entries older than Config->WhoWasMaxKeep */
-void MaintainTimer::Tick(time_t t)
+void WhoWasMaintainTimer::Tick(time_t t)
{
command_t* whowas_command = ServerInstance->Parser->GetHandler("WHOWAS");
if (whowas_command)
-extern "C" command_t* init_command(InspIRCd* Instance)
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
{
return new cmd_zline(Instance);
}
#include "inspircd.h"
#include "configreader.h"
#include <algorithm>
-#include <dirent.h>
-#include <dlfcn.h>
#include "users.h"
#include "modules.h"
#include "wildcard.h"
#include "socket.h"
#include "command_parse.h"
+/* Directory Searching for Unix-Only */
+#ifndef WIN32
+#include <dirent.h>
+#include <dlfcn.h>
+#endif
+
bool InspIRCd::ULine(const char* server)
{
if (!server)
bool ServerConfig::DirValid(const char* dirandfile)
{
+#ifdef WINDOWS
+ return true;
+#endif
+
char work[1024];
char buffer[1024];
char otherdir[1024];
if (strlen(otherdir) >= t)
{
otherdir[t] = '\0';
-
if (!strcmp(otherdir,work))
{
return true;
looks like this, walks like this or tastes like this.
*/
+#ifndef WIN32
#include <sys/types.h>
#include <sys/socket.h>
#include <errno.h>
#include <netinet/in.h>
#include <arpa/inet.h>
+#else
+#include "inspircd_win32wrapper.h"
+#endif
+
#include "dns.h"
#include "inspircd.h"
#include "socketengine.h"
memcpy(&addr.sin_addr.s_addr, &dnsobj->myserver4, sizeof(addr.sin_addr));
addr.sin_family = AF_INET;
addr.sin_port = htons(DNS::QUERY_PORT);
- if (sendto(dnsobj->GetFd(), payload, length + 12, 0, (sockaddr *) &addr, sizeof(addr)) != length+12)
+ if (sendto(dnsobj->GetFd(), (const char*)payload, length + 12, 0, (sockaddr *) &addr, sizeof(addr)) != length+12)
return -1;
#endif
const char* ipaddr_from;
unsigned short int port_from = 0;
- int length = recvfrom(this->GetFd(),buffer,sizeof(DNSHeader),0,from,&x);
+ int length = recvfrom(this->GetFd(),(char*)buffer,sizeof(DNSHeader),0,from,&x);
/* Did we get the whole header? */
if (length < 12)
/** Generate pseudo-random number */
unsigned long DNS::PRNG()
{
+#ifndef WIN32
unsigned long val = 0;
timeval n;
serverstats* s = ServerInstance->stats;
val = val + s->statsCollisions ^ s->statsDnsGood - s->statsDnsBad;
val += (s->statsConnects ^ (unsigned long)s->statsSent ^ (unsigned long)s->statsRecv) - ServerInstance->Config->ports.size();
return val;
+#else
+ unsigned long val = 0;
+ serverstats* s = ServerInstance->stats;
+ val = (time(NULL) ^ GetCurrentProcessId() ^ GetCurrentThreadId() ^ (this->currid++)) ^ s->statsAccept + time(NULL);
+ val = val + s->statsCollisions ^ s->statsDnsGood - s->statsDnsBad;
+ val += (s->statsConnects ^ (unsigned long)s->statsSent ^ (unsigned long)s->statsRecv);
+ return val;
+#endif
}
#include "configreader.h"
#include "dynamic.h"
+#ifndef WIN32
#include <dlfcn.h>
+#endif
+
#include "inspircd.h"
DLLManager::DLLManager(InspIRCd* ServerInstance, const char *fname)
#include "inspircd.h"
#include "hashcomp.h"
+#ifndef WIN32
#include <ext/hash_map>
#define nspace __gnu_cxx
+#else
+#include <hash_map>
+#define nspace stdext
+using stdext::hash_map;
+#endif
/******************************************************
*
}
}
+#ifndef WIN32
size_t nspace::hash<string>::operator()(const string &s) const
+#else
+size_t nspace::hash_compare<string, std::less<string> >::operator()(const string &s) const
+#endif
{
/* XXX: NO DATA COPIES! :)
* The hash function here is practically
return t;
}
+#ifndef WIN32
size_t nspace::hash<irc::string>::operator()(const irc::string &s) const
+#else
+size_t nspace::hash_compare<irc::string, std::less<irc::string> >::operator()(const irc::string &s) const
+#endif
{
register size_t t = 0;
for (irc::string::const_iterator x = s.begin(); x != s.end(); ++x) /* ++x not x++, as its faster */
return 0;
}
-std::string operator+ (std::string& leftval, irc::string& rightval)
-{
- return leftval + std::string(rightval.c_str());
-}
-
-irc::string operator+ (irc::string& leftval, std::string& rightval)
-{
- return leftval + irc::string(rightval.c_str());
-}
-
-bool operator== (const std::string& leftval, const irc::string& rightval)
-{
- return (leftval.c_str() == rightval);
-}
-
-bool operator== (const irc::string& leftval, const std::string& rightval)
-{
- return (leftval == rightval.c_str());
-}
-
const char* irc::irc_char_traits::find(const char* s1, int n, char c)
{
while(n-- > 0 && lowermap[(unsigned char)*s1] != lowermap[(unsigned char)c])
return s1;
}
-/* See hashcomp.h if you care about these... */
-std::ostream& operator<<(std::ostream &os, const irc::string &str)
-{
- return os << str.c_str();
-}
-
-std::istream& operator>>(std::istream &is, irc::string &str)
-{
- std::string tmp;
- is >> tmp;
- str = tmp.c_str();
- return is;
-}
-
irc::tokenstream::tokenstream(const std::string &source) : tokens(source), last_pushed(false)
{
/* Record starting position and current position */
/* EWW! This used to be using sprintf, which is WAY inefficient. -Special */
const char *hex = "0123456789abcdef";
-
- char buf[rawsz*2+1];
+
+ std::string buf;
+ buf.reserve(rawsz * 2 + 1);
size_t i, j;
for (i = 0, j = 0; j < rawsz; ++j)
return buf;
}
-const char* irc::Spacify(const char* n)
+CoreExport const char* irc::Spacify(const char* n)
{
static char x[MAXBUF];
strlcpy(x,n,MAXBUF);
return bits_size;
}
-std::string assign(const irc::string &other)
-{
- return other.c_str();
-}
-
-irc::string assign(const std::string &other)
-{
- return other.c_str();
-}
-
-std::string& trim(std::string &str)
-{
- std::string::size_type start = str.find_first_not_of(" ");
- std::string::size_type end = str.find_last_not_of(" ");
- if (start == std::string::npos || end == std::string::npos)
- str = "";
- else
- str = str.substr(start, end-start+1);
-
- return str;
-}
for (int count = 0; count < Config->ConfValueEnum(Config->config_data, "module"); count++)
{
Config->ConfValue(Config->config_data, "module", "name", count, configToken, MAXBUF);
- printf("[\033[1;32m*\033[0m] Loading module:\t\033[1;32m%s\033[0m\n",configToken);
+ printf_c("[\033[1;32m*\033[0m] Loading module:\t\033[1;32m%s\033[0m\n",configToken);
if (!this->LoadModule(configToken))
{
this->Log(DEFAULT,"There was an error loading the module '%s': %s", configToken, this->ModuleError());
- printf("\n[\033[1;31m*\033[0m] There was an error loading the module '%s': %s\n\n", configToken, this->ModuleError());
+ printf_c("\n[\033[1;31m*\033[0m] There was an error loading the module '%s': %s\n\n", configToken, this->ModuleError());
Exit(EXIT_STATUS_MODULE);
}
}
- printf("\nA total of \033[1;32m%d\033[0m module%s been loaded.\n", this->ModCount+1, this->ModCount+1 == 1 ? " has" : "s have");
+ printf_c("\nA total of \033[1;32m%d\033[0m module%s been loaded.\n", this->ModCount+1, this->ModCount+1 == 1 ? " has" : "s have");
this->Log(DEFAULT,"Total loaded modules: %d", this->ModCount+1);
}
#include "inspircd.h"
#include "configreader.h"
#include <signal.h>
+#ifndef WIN32
#include <dirent.h>
+#include <unistd.h>
+#endif
#include <exception>
#include <fstream>
-#include <unistd.h>
#include "modules.h"
#include "mode.h"
#include "xline.h"
#include "typedefs.h"
#include "command_parse.h"
#include "exitcodes.h"
+
+#ifndef WIN32
#include <dlfcn.h>
#include <getopt.h>
-
+#endif
using irc::sockets::NonBlocking;
using irc::sockets::Blocking;
InspIRCd* SI = NULL;
+/* Burlex: Moved from exitcodes.h -- due to duplicate symbols */
+const char* ExitCodes[] =
+{
+ "No error", /* 0 */
+ "DIE command", /* 1 */
+ "execv() failed", /* 2 */
+ "Internal error", /* 3 */
+ "Config file error", /* 4 */
+ "Logfile error", /* 5 */
+ "Fork failed", /* 6 */
+ "Bad commandline parameters", /* 7 */
+ "No ports could be bound", /* 8 */
+ "Can't write PID file", /* 9 */
+ "SocketEngine could not initialize", /* 10 */
+ "Refusing to start up as root", /* 11 */
+ "Found a <die> tag!", /* 12 */
+ "Couldn't load module on startup", /* 13 */
+ "", /* 14 */
+ "Received SIGTERM", /* 15 */
+};
+
void InspIRCd::AddServerName(const std::string &servername)
{
- if(find(servernames.begin(), servernames.end(), servername) == servernames.end())
- servernames.push_back(servername); /* Wasn't already there. */
+ servernamelist::iterator itr = servernames.begin();
+ for(; itr != servernames.end(); ++itr)
+ if(**itr == servername)
+ return;
+
+ string * ns = new string(servername);
+ servernames.push_back(ns);
}
const char* InspIRCd::FindServerNamePtr(const std::string &servername)
{
- servernamelist::iterator iter = find(servernames.begin(), servernames.end(), servername);
-
- if(iter == servernames.end())
- {
- AddServerName(servername);
- iter = --servernames.end();
- }
-
- return iter->c_str();
+ servernamelist::iterator itr = servernames.begin();
+ for(; itr != servernames.end(); ++itr)
+ if(**itr == servername)
+ return (*itr)->c_str();
+
+ servernames.push_back(new string(servername));
+ itr = --servernames.end();
+ return (*itr)->c_str();
}
bool InspIRCd::FindServerName(const std::string &servername)
{
- return (find(servernames.begin(), servernames.end(), servername) != servernames.end());
+ servernamelist::iterator itr = servernames.begin();
+ for(; itr != servernames.end(); ++itr)
+ if(**itr == servername)
+ return true;
+ return false;
}
void InspIRCd::Exit(int status)
{
+#ifdef WINDOWS
+ CloseIPC();
+#endif
if (SI)
{
SI->SendError("Exiting with status " + ConvToStr(status) + " (" + std::string(ExitCodes[status]) + ")");
/* Close logging */
this->Logger->Close();
+
+ /* Cleanup Server Names */
+ for(servernamelist::iterator itr = servernames.begin(); itr != servernames.end(); ++itr)
+ delete (*itr);
+
+#ifdef WINDOWS
+ /* WSACleanup */
+ WSACleanup();
+#endif
}
void InspIRCd::Restart(const std::string &reason)
this->Cleanup();
/* Figure out our filename (if theyve renamed it, we're boned) */
+#ifdef WINDOWS
+ std::string me = Config->MyDir + "inspircd.exe";
+#else
std::string me = Config->MyDir + "/inspircd";
+#endif
if (execv(me.c_str(), Config->argv) == -1)
{
void InspIRCd::Start()
{
- printf("\033[1;32mInspire Internet Relay Chat Server, compiled %s at %s\n",__DATE__,__TIME__);
- printf("(C) InspIRCd Development Team.\033[0m\n\n");
- printf("Developers:\t\t\033[1;32mBrain, FrostyCoolSlug, w00t, Om, Special, pippijn, peavey\033[0m\n");
- printf("Others:\t\t\t\033[1;32mSee /INFO Output\033[0m\n");
+ printf_c("\033[1;32mInspire Internet Relay Chat Server, compiled %s at %s\n",__DATE__,__TIME__);
+ printf_c("(C) InspIRCd Development Team.\033[0m\n\n");
+ printf_c("Developers:\t\t\033[1;32mBrain, FrostyCoolSlug, w00t, Om, Special, pippijn, peavey\033[0m\n");
+ printf_c("Others:\t\t\t\033[1;32mSee /INFO Output\033[0m\n");
}
void InspIRCd::Rehash(int status)
void InspIRCd::SetSignals()
{
+#ifndef WIN32
signal(SIGALRM, SIG_IGN);
signal(SIGHUP, InspIRCd::Rehash);
signal(SIGPIPE, SIG_IGN);
- signal(SIGTERM, InspIRCd::Exit);
signal(SIGCHLD, SIG_IGN);
+#endif
+ signal(SIGTERM, InspIRCd::Exit);
}
void InspIRCd::QuickExit(int status)
bool InspIRCd::DaemonSeed()
{
+#ifdef WINDOWS
+ // Create process, with argument --service
+ STARTUPINFO si;
+ PROCESS_INFORMATION pi;
+ memset(&si, 0, sizeof(si));
+ memset(&pi, 0, sizeof(pi));
+ SHELLEXECUTEINFO sh = {0};
+ sh.cbSize = sizeof(sh);
+ sh.fMask = SEE_MASK_NOCLOSEPROCESS;
+ sh.hwnd = 0;
+ sh.lpVerb = 0;
+ sh.lpDirectory = 0;
+ sh.hInstApp = 0;
+ sh.nShow = SW_SHOW;
+ sh.lpFile = "inspircd.exe";
+ sh.lpParameters = "--service";
+ if(!ShellExecuteEx(&sh))
+ return false;
+
+ CloseHandle(sh.hProcess);
+ exit(0);
+ return true;
+#else
signal(SIGTERM, InspIRCd::QuickExit);
int childpid;
}
return true;
+#endif
}
void InspIRCd::WritePID(const std::string &filename)
InspIRCd::InspIRCd(int argc, char** argv)
: ModCount(-1), duration_m(60), duration_h(60*60), duration_d(60*60*24), duration_w(60*60*24*7), duration_y(60*60*24*365), GlobalCulls(this)
{
+#ifdef WINDOWS
+ WSADATA wsadata;
+ WSAStartup(MAKEWORD(2,0), &wsadata);
+#endif
+
int found_ports = 0;
FailedPortList pl;
- int do_version = 0, do_nofork = 0, do_debug = 0, do_nolog = 0, do_root = 0; /* flag variables */
+ int do_version = 0, do_nofork = 0, do_debug = 0, do_nolog = 0, do_root = 0, is_service = 0; /* flag variables */
char c = 0;
modules.resize(255);
factory.resize(255);
+ memset(&server, 0, sizeof(server));
+ memset(&client, 0, sizeof(client));
this->unregistered_count = 0;
{ "nolog", no_argument, &do_nolog, 1 },
{ "runasroot", no_argument, &do_root, 1 },
{ "version", no_argument, &do_version, 1 },
+ { "service", no_argument, &is_service, 1 },
{ 0, 0, 0, 0 }
};
}
}
+#ifdef WINDOWS
+ if(is_service)
+ FreeConsole();
+#endif
+
if (do_version)
{
printf("\n%s r%s\n", VERSION, REVISION);
if (!Config->nofork)
{
- if (!this->DaemonSeed())
+ if (!is_service && !this->DaemonSeed())
{
printf("ERROR: could not go into daemon mode. Shutting down.\n");
Log(DEFAULT,"ERROR: could not go into daemon mode. Shutting down.");
printf("%d.\tIP: %s\tPort: %lu\n", j, i->first.empty() ? "<all>" : i->first.c_str(), (unsigned long)i->second);
}
}
-
+#ifndef WINDOWS
if (!Config->nofork)
{
if (kill(getppid(), SIGTERM) == -1)
Log(DEFAULT,"Keeping pseudo-tty open as we are running in the foreground.");
}
}
-
+#endif
printf("\nInspIRCd is now running!\n");
Log(DEFAULT,"Startup complete.");
this->WritePID(Config->PID);
+
+#ifdef WINDOWS
+ InitIPC();
+#endif
}
std::string InspIRCd::GetVersionString()
void InspIRCd::DoOneIteration(bool process_module_sockets)
{
- static rusage ru;
+#ifndef WIN32
+ static rusage ru;
+#endif
/* time() seems to be a pretty expensive syscall, so avoid calling it too much.
* Once per loop iteration is pleanty.
FOREACH_MOD_I(this,I_OnBackgroundTimer,OnBackgroundTimer(TIME));
Timers->TickMissedTimers(TIME);
}
-
+#ifndef WIN32
if (!getrusage(0, &ru))
{
gettimeofday(&this->stats->LastSampled, NULL);
this->stats->LastCPU = ru.ru_utime;
}
+#else
+ CheckIPC(this);
+#endif
}
/* Call the socket engine to wait on the active
if (log)
{
int written = fprintf(log,"%s",buffer.c_str());
+#ifdef WINDOWS
+ buffer = "";
+#else
if ((written >= 0) && (written < (int)buffer.length()))
{
buffer.erase(0, buffer.length());
/* Wrote the whole buffer, and no need for write callback */
buffer = "";
}
-
+#endif
if (writeops++ % 20)
{
fflush(log);
{
if (log)
{
- int flags = fcntl(fileno(log), F_GETFL, 0);
+ /* Burlex: Windows assumes nonblocking on FILE* pointers anyway, and also "file" fd's aren't the same
+ as socket fd's. */
+#ifndef WIN32
+ int flags = fcntl(fileno(log), F_GETFL, 0);
fcntl(fileno(log), F_SETFL, flags ^ O_NONBLOCK);
+#endif
if (buffer.size())
fprintf(log,"%s",buffer.c_str());
+#ifndef WINDOWS
ServerInstance->SE->DelFd(this);
+#endif
fflush(log);
fclose(log);
// attempt to increase socket sendq and recvq as high as its possible
int sendbuf = 32768;
int recvbuf = 32768;
- setsockopt(nfd,SOL_SOCKET,SO_SNDBUF,(const void *)&sendbuf,sizeof(sendbuf));
- setsockopt(nfd,SOL_SOCKET,SO_RCVBUF,(const void *)&recvbuf,sizeof(sendbuf));
+ setsockopt(nfd,SOL_SOCKET,SO_SNDBUF,(const char *)&sendbuf,sizeof(sendbuf));
+ setsockopt(nfd,SOL_SOCKET,SO_RCVBUF,(const char *)&recvbuf,sizeof(sendbuf));
}
/* Most irc servers require you to specify the ip you want to bind to.
((sockaddr_in*)addr)->sin_port = htons(this->port);
}
#endif
-
+#ifndef WIN32
int flags = fcntl(this->fd, F_GETFL, 0);
fcntl(this->fd, F_SETFL, flags | O_NONBLOCK);
-
+#else
+ unsigned long flags = 0;
+ ioctlsocket(this->fd, FIONBIO, &flags);
+#endif
if (connect(this->fd, (sockaddr*)addr, size) == -1)
{
if (errno != EINPROGRESS)
char* InspSocket::Read()
{
+#ifdef WINDOWS
+ if ((fd < 0) || (m_internalFd > MAX_DESCRIPTORS))
+#else
if ((fd < 0) || (fd > MAX_DESCRIPTORS))
+#endif
return NULL;
int n = 0;
while (outbuffer.size() && (errno != EAGAIN))
{
/* Send a line */
+#ifndef WIN32
int result = write(this->fd,outbuffer[0].c_str(),outbuffer[0].length());
+#else
+ int result = send(this->fd,outbuffer[0].c_str(),outbuffer[0].length(), 0);
+#endif
if (result > 0)
{
if ((unsigned int)result >= outbuffer[0].length())
bool InspSocket::Poll()
{
+#ifdef WINDOWS
+ if(Instance->SE->GetRef(this->fd) != this)
+ return false;
+ int incoming = -1;
+#else
if (this->Instance->SE->GetRef(this->fd) != this)
return false;
if ((fd < 0) || (fd > MAX_DESCRIPTORS))
return false;
-
+#endif
switch (this->state)
{
case I_CONNECTING:
/* Our socket was in write-state, so delete it and re-add it
* in read-state.
*/
+#ifndef WINDOWS
if (this->fd > -1)
{
this->Instance->SE->DelFd(this);
if (!this->Instance->SE->AddFd(this))
return false;
}
+#else
+ this->SetState(I_CONNECTED);
+#endif
if (Instance->Config->GetIOHook(this))
{
try
if ((!*this->host) || strchr(this->host, ':'))
length = sizeof(sockaddr_in6);
#endif
- incoming = accept (this->fd, client, &length);
+ incoming = _accept (this->fd, client, &length);
#ifdef IPV6
if ((!*this->host) || strchr(this->host, ':'))
{
*/
#include "inspstring.h"
-#include <string.h>
/*
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
*/
#ifndef HAS_STRLCPY
-size_t strlcat(char *dst, const char *src, size_t siz)
+CoreExport size_t strlcat(char *dst, const char *src, size_t siz)
{
char *d = dst;
const char *s = src;
return(dlen + (s - src)); /* count does not include NUL */
}
-size_t strlcpy(char *dst, const char *src, size_t siz)
+CoreExport size_t strlcpy(char *dst, const char *src, size_t siz)
{
char *d = dst;
const char *s = src;
}
#endif
-int charlcat(char* x,char y,int z)
+CoreExport int charlcat(char* x,char y,int z)
{
char* x__n = x;
int v = 0;
return v;
}
-bool charremove(char* mp, char remove)
+CoreExport bool charremove(char* mp, char remove)
{
char* mptr = mp;
bool shift_down = false;
bool InspIRCd::CallCommandHandler(const std::string &commandname, const char** parameters, int pcnt, userrec* user)
{
- return this->Parser->CallHandler(commandname,parameters,pcnt,user);
+ return (this->Parser->CallHandler(commandname,parameters,pcnt,user) != CMD_INVALID);
}
bool InspIRCd::IsValidModuleCommand(const std::string &commandname, int pcnt, userrec* user)
#include "transport.h"
+#ifdef WINDOWS
+#pragma comment(lib, "libgnutls-13.lib")
+#undef MAX_DESCRIPTORS
+#define MAX_DESCRIPTORS 10000
+#endif
+
/* $ModDesc: Provides SSL support for clients */
/* $CompileFlags: exec("libgnutls-config --cflags") */
/* $LinkerFlags: rpath("libgnutls-config --libs") exec("libgnutls-config --libs") */
public:
ModuleSSLGnuTLS(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
ServerInstance->PublishInterface("InspSocketHook", this);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleSSLGnuTLSFactory;
}
#include <openssl/ssl.h>
#include <openssl/err.h>
+#ifdef WINDOWS
+#include <openssl/applink.c>
+#endif
+
#include "inspircd_config.h"
#include "configreader.h"
#include "users.h"
#include "transport.h"
+#ifdef WINDOWS
+#pragma comment(lib, "libeay32MTd")
+#pragma comment(lib, "ssleay32MTd")
+#undef MAX_DESCRIPTORS
+#define MAX_DESCRIPTORS 10000
+#endif
+
/* $ModDesc: Provides SSL support for clients */
/* $CompileFlags: pkgconfversion("openssl","0.9.7") pkgconfincludes("openssl","/openssl/ssl.h","") */
/* $LinkerFlags: rpath("pkg-config --libs openssl") pkgconflibs("openssl","/libssl.so","-lssl -lcrypto -ldl") */
InspIRCd* PublicInstance;
ModuleSSLOpenSSL(InspIRCd* Me)
- : Module::Module(Me), PublicInstance(Me)
+ : Module(Me), PublicInstance(Me)
{
ServerInstance->PublishInterface("InspSocketHook", this);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleSSLOpenSSLFactory;
}
public:
ModuleAlias(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
ReadAliases();
pars.resize(127);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleAliasFactory;
}
cmd_alltime *mycommand;
public:
Modulealltime(InspIRCd *Me)
- : Module::Module(Me)
+ : Module(Me)
{
mycommand = new cmd_alltime(ServerInstance);
ServerInstance->AddCommand(mycommand);
};
-extern "C" void *init_module(void)
+extern "C" DllExport void *init_module(void)
{
return new ModulealltimeFactory;
}
private:
public:
- ModuleAntiBear(InspIRCd* Me) : Module::Module(Me)
+ ModuleAntiBear(InspIRCd* Me) : Module(Me)
{
}
// class for this library
//
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleAntiBearFactory;
}
{
public:
ModuleAntiBottler(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
}
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleAntiBottlerFactory;
}
CUList except_list;
public:
ModuleAuditorium(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
aum = new AuditoriumMode(ServerInstance);
if (!ServerInstance->AddMode(aum, 'u'))
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleAuditoriumFactory;
}
public:
ModuleBanException(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
be = new BanException(ServerInstance);
if (!ServerInstance->AddMode(be, 'e'))
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleBanExceptionFactory;
}
public:
ModuleBanRedirect(InspIRCd* Me)
- : Module::Module(Me), Srv(Me)
+ : Module(Me), Srv(Me)
{
re = new BanRedirect(Me);
nofollow = false;
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleBanRedirectFactory;
}
int ForgetDelay;
BlockAction action;
public:
- ModuleBlockAmsg(InspIRCd* Me) : Module::Module(Me)
+ ModuleBlockAmsg(InspIRCd* Me) : Module(Me)
{
this->OnRehash(NULL,"");
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleBlockAmsgFactory;
}
char capsmap[256];
public:
- ModuleBlockCAPS(InspIRCd* Me) : Module::Module(Me)
+ ModuleBlockCAPS(InspIRCd* Me) : Module(Me)
{
OnRehash(NULL,"");
bc = new BlockCaps(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleBlockCAPSFactory;
}
BlockColor *bc;
public:
- ModuleBlockColour(InspIRCd* Me) : Module::Module(Me)
+ ModuleBlockColour(InspIRCd* Me) : Module(Me)
{
bc = new BlockColor(ServerInstance);
if (!ServerInstance->AddMode(bc, 'c'))
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleBlockColourFactory;
}
BotMode* bm;
public:
ModuleBotMode(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
bm = new BotMode(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleBotModeFactory;
}
public:
- ModuleCBan(InspIRCd* Me) : Module::Module(Me)
+ ModuleCBan(InspIRCd* Me) : Module(Me)
{
mycommand = new cmd_cban(Me);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleCBanFactory;
}
public:
ModuleCensor(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
/* Read the configuration file on startup.
*/
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleCensorFactory;
}
#include <vector>
#include <string>
#include <stdlib.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
#include "users.h"
#include "modules.h"
#include "dns.h"
#include "inspircd.h"
+#ifndef WINDOWS
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#endif
/* $ModDesc: Change user's hosts connecting from known CGI:IRC hosts */
bool NotifyOpers;
CGIHostlist Hosts;
public:
- ModuleCgiIRC(InspIRCd* Me) : Module::Module(Me)
+ ModuleCgiIRC(InspIRCd* Me) : Module(Me)
{
OnRehash(NULL,"");
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleCgiIRCFactory;
}
private:
public:
ModuleChanCreate(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
ServerInstance->SNO->EnableSnomask('j', "CHANCREATE");
}
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleChanCreateFactory;
}
public:
ModuleChanFilter(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
cf = new ChanFilter(ServerInstance);
if (!ServerInstance->AddMode(cf, 'g'))
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleChanFilterFactory;
}
public:
ModuleChanProtect(InspIRCd* Me)
- : Module::Module(Me), FirstInGetsFounder(false), QAPrefixes(false), DeprivSelf(false), DeprivOthers(false), booting(true)
+ : Module(Me), FirstInGetsFounder(false), QAPrefixes(false), DeprivSelf(false), DeprivOthers(false), booting(true)
{
/* Load config stuff */
OnRehash(NULL,"");
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleChanProtectFactory;
}
private:
cmd_check *mycommand;
public:
- ModuleCheck(InspIRCd* Me) : Module::Module(Me)
+ ModuleCheck(InspIRCd* Me) : Module(Me)
{
mycommand = new cmd_check(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleCheckFactory;
}
char hostmap[256];
public:
ModuleChgHost(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
OnRehash(NULL,"");
mycommand = new cmd_chghost(ServerInstance, hostmap);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleChgHostFactory;
}
public:
- ModuleChgIdent(InspIRCd* Me) : Module::Module(Me)
+ ModuleChgIdent(InspIRCd* Me) : Module(Me)
{
mycommand = new cmd_chgident(ServerInstance);
ServerInstance->AddCommand(mycommand);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleChgIdentFactory;
}
public:
ModuleCloaking(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
ServerInstance->UseInterface("HashRequest");
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleCloakingFactory;
}
private:
cmd_clones *mycommand;
public:
- ModuleClones(InspIRCd* Me) : Module::Module(Me)
+ ModuleClones(InspIRCd* Me) : Module(Me)
{
mycommand = new cmd_clones(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleClonesFactory;
}
public:
ModuleConnJoin(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
OnRehash(NULL, "");
}
}
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleConnJoinFactory;
}
public:
ModuleModesOnConnect(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
Conf = new ConfigReader(ServerInstance);
tokens.push_back(buf);
int size = tokens.size() + 1;
- const char* modes[size];
+ const char** modes = new const char*[size];
modes[0] = user->nick;
modes[1] = tokens[0].c_str();
}
ServerInstance->Parser->CallHandler("MODE", modes, size, user);
+ delete [] modes;
}
break;
}
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleModesOnConnectFactory;
}
public:
ModuleWaitPong(InspIRCd* Me)
- : Module::Module(Me), Instance(Me), extenstr("waitpong_pingstr")
+ : Module(Me), Instance(Me), extenstr("waitpong_pingstr")
{
OnRehash(NULL,"");
}
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleWaitPongFactory;
}
public:
- ModuleConnFlood(InspIRCd* Me) : Module::Module(Me)
+ ModuleConnFlood(InspIRCd* Me) : Module(Me)
{
InitConf();
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleConnFloodFactory;
}
public:
ModuleDCCAllow(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
Conf = new ConfigReader(ServerInstance);
mycommand = new cmd_dccallow(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleDCCAllowFactory;
}
User_d* m1;
public:
ModuleDeaf(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
m1 = new User_d(ServerInstance);
if (!ServerInstance->AddMode(m1, 'd'))
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleDeafFactory;
}
ConfigReader *Conf;
public:
- ModuleDenyChannels(InspIRCd* Me) : Module::Module(Me)
+ ModuleDenyChannels(InspIRCd* Me) : Module(Me)
{
Conf = new ConfigReader(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleDenyChannelsFactory;
}
{
cmd_devoice *mycommand;
public:
- ModuleDeVoice(InspIRCd* Me) : Module::Module(Me)
+ ModuleDeVoice(InspIRCd* Me) : Module(Me)
{
mycommand = new cmd_devoice(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleDeVoiceFactory;
}
* ---------------------------------------------------
*/
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <stdint.h>
#include "inspircd.h"
#include "xline.h"
#include "dns.h"
#include "channels.h"
#include "modules.h"
+#ifndef WINDOWS
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <stdint.h>
+#endif
+
/* $ModDesc: Provides handling of DNS blacklists */
/* Class holding data for a single entry */
return DNSBLConfEntry::I_UNKNOWN;
}
public:
- ModuleDNSBL(InspIRCd *Me) : Module::Module(Me)
+ ModuleDNSBL(InspIRCd *Me) : Module(Me)
{
ReadConf();
}
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleDNSBLFactory;
}
public:
ModuleFilter(InspIRCd* Me)
- : FilterBase::FilterBase(Me, "m_filter.so")
+ : FilterBase(Me, "m_filter.so")
{
OnRehash(NULL,"");
}
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleFilterFactory;
}
}
};
-FilterBase::FilterBase(InspIRCd* Me, const std::string &source) : Module::Module(Me)
+FilterBase::FilterBase(InspIRCd* Me, const std::string &source) : Module(Me)
{
filtcommand = new cmd_filter(this, Me, source);
ServerInstance->AddCommand(filtcommand);
public:
ModuleFoobar(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
// The constructor just makes a copy of the server class
// class for this library
//
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleFoobarFactory;
}
cmd_greloadmodule *mycommand3;
public:
- ModuleGlobalLoad(InspIRCd* Me) : Module::Module(Me)
+ ModuleGlobalLoad(InspIRCd* Me) : Module(Me)
{
mycommand = new cmd_gloadmodule(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleGlobalLoadFactory;
}
cmd_globops* mycommand;
public:
ModuleGlobops(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
mycommand = new cmd_globops(ServerInstance);
ServerInstance->AddCommand(mycommand);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleGlobopsFactory;
}
public:
ModuleHelpop(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
ReadConfig();
ho = new Helpop(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleHelpopFactory;
}
HideChans* hm;
public:
ModuleHideChans(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
hm = new HideChans(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleHideChansFactory;
}
HideOper* hm;
public:
ModuleHideOper(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
hm = new HideOper(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleHideOperFactory;
}
public:
ModuleHostChange(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
Conf = new ConfigReader(ServerInstance);
OnRehash(NULL,"");
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleHostChangeFactory;
}
HTTPList sockets;
ModuleHTTPClient(InspIRCd *Me)
- : Module::Module(Me)
+ : Module(Me)
{
}
}
};
-extern "C" void *init_module(void)
+extern "C" DllExport void *init_module(void)
{
return new ModuleHTTPClientFactory;
}
}
}
- ModuleHttpServer(InspIRCd* Me) : Module::Module(Me)
+ ModuleHttpServer(InspIRCd* Me) : Module(Me)
{
ReadConfig();
}
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleHttpServerFactory;
}
this->stylesheet = c.ReadValue("httpstats", "stylesheet", 0);
}
- ModuleHttpStats(InspIRCd* Me) : Module::Module(Me)
+ ModuleHttpStats(InspIRCd* Me) : Module(Me)
{
ReadConfig();
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleHttpStatsFactory;
}
}
ModuleIdent(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
ReadSettings();
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleIdentFactory;
}
InvisibleDeOper* ido;
public:
ModuleInvisible(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
conf = new ConfigReader(ServerInstance);
qm = new InvisibleMode(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleInvisibleFactory;
}
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleInviteExceptionFactory;
}
public:
ModuleJoinFlood(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
jf = new JoinFlood(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleJoinFloodFactory;
}
cmd_jumpserver* js;
public:
ModuleJumpServer(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
js = new cmd_jumpserver(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleJumpServerFactory;
}
public:
ModuleKickNoRejoin(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
kr = new KickRejoin(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleKickNoRejoinFactory;
}
cmd_knock* mycommand;
Knock* kn;
public:
- ModuleKnock(InspIRCd* Me) : Module::Module(Me)
+ ModuleKnock(InspIRCd* Me) : Module(Me)
{
kn = new Knock(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleKnockFactory;
}
}
public:
- ModuleLockserv(InspIRCd* Me) : Module::Module(Me)
+ ModuleLockserv(InspIRCd* Me) : Module(Me)
{
ResetLocked();
lockcommand = new cmd_lockserv(ServerInstance, locked);
}
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleLockservFactory;
}
public:
ModuleMD5(InspIRCd* Me)
- : Module::Module(Me), key(NULL), chars(NULL)
+ : Module(Me), key(NULL), chars(NULL)
{
ServerInstance->PublishInterface("HashRequest", this);
}
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleMD5Factory;
}
public:
ModuleMsgFlood(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
mf = new MsgFlood(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleMsgFloodFactory;
}
public:
ModuleNamesX(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
}
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleNamesXFactory;
}
char* n;
public:
ModuleNickLock(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
cmd1 = new cmd_nicklock(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleNickLockFactory;
}
public:
ModuleNoCTCP(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
nc = new NoCTCP(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleNoCTCPFactory;
}
NoInvite *ni;
public:
- ModuleNoInvite(InspIRCd* Me) : Module::Module(Me)
+ ModuleNoInvite(InspIRCd* Me) : Module(Me)
{
ni = new NoInvite(ServerInstance);
if (!ServerInstance->AddMode(ni, 'V'))
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleNoInviteFactory;
}
public:
ModuleNoKicks(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
nk = new NoKicks(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleNoKicksFactory;
}
NoNicks* nn;
public:
ModuleNoNickChange(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
nn = new NoNicks(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleNoNickChangeFactory;
}
public:
ModuleNoNotice(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
nt = new NoNotice(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleNoNoticeFactory;
}
public:
ModuleOperHash(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
/* Read the config file first */
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleOperHashFactory;
}
OperChans* oc;
public:
ModuleOperChans(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
oc = new OperChans(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleOperChansFactory;
}
}
public:
- ModuleOperjoin(InspIRCd* Me) : Module::Module(Me)
+ ModuleOperjoin(InspIRCd* Me) : Module(Me)
{
OnRehash(NULL, "");
}
}
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleOperjoinFactory;
}
public:
ModuleOperLevels(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleOperLevelsFactory;
}
private:
public:
- ModuleOperLog(InspIRCd* Me) : Module::Module(Me)
+ ModuleOperLog(InspIRCd* Me) : Module(Me)
{
}
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleOperLogFactory;
}
public:
ModuleModesOnOper(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
Conf = new ConfigReader(ServerInstance);
tokens.push_back(buf);
int size = tokens.size() + 1;
- const char* modes[size];
+ char** modes = new char*[size];
modes[0] = user->nick;
modes[1] = (char*)tokens[0].c_str();
n.push_back(modes[j]);
}
rmode.Send(ServerInstance);
- ServerInstance->SendMode(modes, size, user);
+ ServerInstance->SendMode((const char**)modes, size, user);
+ delete [] modes;
}
break;
}
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleModesOnOperFactory;
}
}
ModuleOpermotd(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
opermotd = NULL;
mycommand = new cmd_opermotd(ServerInstance);
}
};
-extern "C" void* init_module(void)
+extern "C" DllExport void* init_module(void)
{
return new ModuleOpermotdFactory;
}
public:
ModuleOverride(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
// read our config options (main config file)
OnRehash(NULL,"");
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleOverrideFactory;
}
ConfigReader *conf;
public:
ModuleRandQuote(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
conf = new ConfigReader(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleRandQuoteFactory;
}
public:
ModuleRedirect(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
re = new Redirect(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleRedirectFactory;
}
{
public:
ModuleRegOnlyCreate(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
}
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleRegOnlyCreateFactory;
}
public:
ModuleRemove(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
mycommand = new cmd_remove(ServerInstance, supportnokicks);
mycommand2 = new cmd_fpart(ServerInstance, supportnokicks);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleRemoveFactory;
}
{
private:
public:
- ModuleRestrictBanned(InspIRCd* Me) : Module::Module(Me)
+ ModuleRestrictBanned(InspIRCd* Me) : Module(Me)
{
}
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleRestrictBannedFactory;
}
public:
ModuleRestrictChans(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
ReadConfig();
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleRestrictChansFactory;
}
public:
ModuleRestrictMsg(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
}
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleRestrictMsgFactory;
}
int global_listing;
int LimitList;
public:
- ModuleSafeList(InspIRCd* Me) : Module::Module(Me)
+ ModuleSafeList(InspIRCd* Me) : Module(Me)
{
OnRehash(NULL, "");
}
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleSafeListFactory;
}
cmd_sajoin* mycommand;
public:
ModuleSajoin(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
mycommand = new cmd_sajoin(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleSajoinFactory;
}
cmd_samode* mycommand;
public:
ModuleSaMode(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
mycommand = new cmd_samode(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleSaModeFactory;
}
cmd_sanick* mycommand;
public:
ModuleSanick(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
mycommand = new cmd_sanick(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleSanickFactory;
}
cmd_sapart* mycommand;
public:
ModuleSapart(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
mycommand = new cmd_sapart(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleSapartFactory;
}
cmd_saquit* mycommand;
public:
ModuleSaquit(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
mycommand = new cmd_saquit(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleSaquitFactory;
}
std::vector<std::string> allowlist;
time_t WaitTime;
public:
- ModuleSecureList(InspIRCd* Me) : Module::Module(Me)
+ ModuleSecureList(InspIRCd* Me) : Module(Me)
{
OnRehash(NULL,"");
}
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleSecureListFactory;
}
{
public:
ModuleSeeNicks(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
ServerInstance->SNO->EnableSnomask('n',"NICK");
ServerInstance->SNO->EnableSnomask('N',"REMOTENICK");
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleSeeNicksFactory;
}
User_R* m5;
public:
ModuleServices(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
m1 = new Channel_r(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleServicesFactory;
}
AChannel_M* m2;
AUser_R* m3;
public:
- ModuleServicesAccount(InspIRCd* Me) : Module::Module(Me)
+ ModuleServicesAccount(InspIRCd* Me) : Module(Me)
{
m1 = new AChannel_R(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleServicesAccountFactory;
}
char hostmap[256];
public:
ModuleSetHost(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
OnRehash(NULL,"");
mycommand = new cmd_sethost(ServerInstance, hostmap);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleSetHostFactory;
}
cmd_setident* mycommand;
public:
- ModuleSetIdent(InspIRCd* Me) : Module::Module(Me)
+ ModuleSetIdent(InspIRCd* Me) : Module(Me)
{
mycommand = new cmd_setident(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleSetIdentFactory;
}
cmd_setidle* mycommand;
public:
ModuleSetIdle(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
mycommand = new cmd_setidle(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleSetIdleFactory;
}
cmd_setname* mycommand;
public:
ModuleSetName(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
mycommand = new cmd_setname(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleSetNameFactory;
}
class ModuleSHA256 : public Module
{
- void SHA256Init(struct SHA256Context *ctx, const unsigned int* key)
+ void SHA256Init(SHA256Context *ctx, const unsigned int* key)
{
if (key)
{
ctx->tot_len = 0;
}
- void SHA256Transform(struct SHA256Context *ctx, unsigned char *message, unsigned int block_nb)
+ void SHA256Transform(SHA256Context *ctx, unsigned char *message, unsigned int block_nb)
{
uint32_t w[64];
uint32_t wv[8];
}
}
- void SHA256Update(struct SHA256Context *ctx, unsigned char *message, unsigned int len)
+ void SHA256Update(SHA256Context *ctx, unsigned char *message, unsigned int len)
{
unsigned int rem_len = SHA256_BLOCK_SIZE - ctx->len;
memcpy(&ctx->block[ctx->len], message, rem_len);
ctx->tot_len += (block_nb + 1) << 6;
}
- void SHA256Final(struct SHA256Context *ctx, unsigned char *digest)
+ void SHA256Final(SHA256Context *ctx, unsigned char *digest)
{
unsigned int block_nb = (1 + ((SHA256_BLOCK_SIZE - 9) < (ctx->len % SHA256_BLOCK_SIZE)));
unsigned int len_b = (ctx->tot_len + ctx->len) << 3;
{
// Generate the hash
unsigned char bytehash[SHA256_DIGEST_SIZE];
- struct SHA256Context ctx;
+ SHA256Context ctx;
SHA256Init(&ctx, key);
SHA256Update(&ctx, (unsigned char *)src, (unsigned int)len);
SHA256Final(&ctx, bytehash);
public:
- ModuleSHA256(InspIRCd* Me) : Module::Module(Me), key(NULL), chars(NULL)
+ ModuleSHA256(InspIRCd* Me) : Module(Me), key(NULL), chars(NULL)
{
ServerInstance->PublishInterface("HashRequest", this);
}
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleSHA256Factory;
}
public:
- ModuleShowwhois(InspIRCd* Me) : Module::Module(Me)
+ ModuleShowwhois(InspIRCd* Me) : Module(Me)
{
sw = new SeeWhois(ServerInstance);
};
-extern "C" void* init_module()
+extern "C" DllExport void* init_module()
{
return new ModuleShowwhoisFactory;
}
public:
ModuleSilence(InspIRCd* Me)
- : Module::Module(Me), maxsilence(32)
+ : Module(Me), maxsilence(32)
{
OnRehash(NULL, "");
mycommand = new cmd_silence(ServerInstance, maxsilence);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleSilenceFactory;
}
public:
ModuleSilence(InspIRCd* Me)
- : Module::Module(Me), maxsilence(32)
+ : Module(Me), maxsilence(32)
{
OnRehash(NULL, "");
mycommand = new cmd_silence(ServerInstance,maxsilence);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleSilenceFactory;
}
/* $ModDep: m_spanningtree/timesynctimer.h m_spanningtree/resolvers.h m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h m_spanningtree/rconnect.h */
ModuleSpanningTree::ModuleSpanningTree(InspIRCd* Me)
- : Module::Module(Me), max_local(0), max_global(0)
+ : Module(Me), max_local(0), max_global(0)
{
ServerInstance->UseInterface("InspSocketHook");
Utils = new SpanningTreeUtilities(Me, this);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleSpanningTreeFactory;
}
{
char* randombuf = new char[length+1];
std::string out;
+#ifdef WINDOWS
+ int fd = -1;
+#else
int fd = open("/dev/urandom", O_RDONLY, 0);
+#endif
if (fd >= 0)
{
+#ifndef WINDOWS
read(fd, randombuf, length);
close(fd);
+#endif
}
else
{
{
strparams[q] = params[q].c_str();
}
- switch (this->Instance->CallCommandHandler(command.c_str(), strparams, params.size(), who))
+ if(!this->Instance->CallCommandHandler(command.c_str(), strparams, params.size(), who))
{
- case CMD_INVALID:
- this->SendError("Unrecognised command '"+std::string(command.c_str())+"' -- possibly loaded mismatched modules");
- return false;
- break;
- case CMD_FAILURE:
- return true;
- break;
- default:
- /* CMD_SUCCESS and CMD_USER_DELETED fall through here */
- break;
+ this->SendError("Unrecognised command '"+std::string(command.c_str())+"' -- possibly loaded mismatched modules");
+ return false;
}
+ else
+ return true;
}
else
{
/* This hash_map holds the hash equivalent of the server
* tree, used for rapid linear lookups.
*/
+#ifdef WINDOWS
+typedef nspace::hash_map<std::string, TreeServer*, nspace::hash_compare<string, less<string> > > server_hash;
+#else
typedef nspace::hash_map<std::string, TreeServer*, nspace::hash<string>, irc::StrHashComp> server_hash;
+#endif
typedef std::map<TreeServer*,TreeServer*> TreeServerList;
cmd_spylist *mycommand;
cmd_spynames *mycommand2;
public:
- ModuleSpy(InspIRCd* Me) : Module::Module(Me)
+ ModuleSpy(InspIRCd* Me) : Module(Me)
{
mycommand = new cmd_spylist(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleSpyFactory;
}
char* dummy;
public:
- ModuleSSLDummy(InspIRCd* Me) : Module::Module(Me)
+ ModuleSSLDummy(InspIRCd* Me) : Module(Me)
{
}
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleSSLDummyFactory;
}
public:
ModuleSSLModes(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleSSLModesFactory;
}
UserStripColor *usc;
public:
- ModuleStripColor(InspIRCd* Me) : Module::Module(Me)
+ ModuleStripColor(InspIRCd* Me) : Module(Me)
{
usc = new UserStripColor(ServerInstance);
csc = new ChannelStripColor(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleStripColorFactory;
}
public:
- ModuleSVSHold(InspIRCd* Me) : Module::Module(Me)
+ ModuleSVSHold(InspIRCd* Me) : Module(Me)
{
mycommand = new cmd_svshold(Me);
ServerInstance->AddCommand(mycommand);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleSVSHoldFactory;
}
ConfigReader* Conf;
public:
- ModuleSWhois(InspIRCd* Me) : Module::Module(Me)
+ ModuleSWhois(InspIRCd* Me) : Module(Me)
{
Conf = new ConfigReader(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleSWhoisFactory;
}
bool claimed;
public:
ModuleTaxonomy(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
// Create a new command
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleTaxonomyFactory;
}
cmd_woot* newcommand;
public:
ModuleTestCommand(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
// Create a new command
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleTestCommandFactory;
}
cmd_tban* mycommand;
public:
ModuleTimedBans(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
mycommand = new cmd_tban(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleTimedBansFactory;
}
cmd_tline* newcommand;
public:
ModuleTLine(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
newcommand = new cmd_tline(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleTLineFactory;
}
public:
ModuleUHNames(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
}
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleUHNamesFactory;
}
public:
- ModuleUninvite(InspIRCd* Me) : Module::Module(Me)
+ ModuleUninvite(InspIRCd* Me) : Module(Me)
{
mycommand = new cmd_uninvite(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleUninviteFactory;
}
cmd_userip* mycommand;
public:
ModuleUserIP(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
mycommand = new cmd_userip(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleUserIPFactory;
}
cmd_vhost* mycommand;
public:
- ModuleVHost(InspIRCd* Me) : Module::Module(Me)
+ ModuleVHost(InspIRCd* Me) : Module(Me)
{
Conf = new ConfigReader(ServerInstance);
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleVHostFactory;
}
* of users using WATCH.
*/
+#ifdef WINDOWS
+typedef nspace::hash_map<irc::string, std::deque<userrec*>, nspace::hash_compare<irc::string, less<irc::string> > > watchentries;
+#else
typedef nspace::hash_map<irc::string, std::deque<userrec*>, nspace::hash<irc::string> > watchentries;
+#endif
typedef std::map<irc::string, std::string> watchlist;
/* Who's watching each nickname.
public:
Modulewatch(InspIRCd* Me)
- : Module::Module(Me), maxwatch(32)
+ : Module(Me), maxwatch(32)
{
OnRehash(NULL, "");
whos_watching_me = new watchentries();
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModulewatchFactory;
}
public:
ModuleXMLSocket(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
OnRehash(NULL,"");
}
return -1;
/* We want to alter the buffer, so we have to make a copy */
- char tmpbuffer[count+1];
+ char * tmpbuffer = new char[count + 1];
memcpy(tmpbuffer, buffer, count);
/* XXX: This will actually generate lines "looking\0\0like\0\0this"
tmpbuffer[n] = 0;
user->AddWriteBuf(std::string(tmpbuffer,count));
+ delete [] tmpbuffer;
return 1;
}
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleXMLSocketFactory;
}
* ((-1) << (8 - (mask % 8)))
* But imho, it sucks in comparison to a nice neat lookup table.
*/
-const char inverted_bits[8] = { 0x00, /* 00000000 - 0 bits - never actually used */
+const unsigned char inverted_bits[8] = { 0x00, /* 00000000 - 0 bits - never actually used */
0x80, /* 10000000 - 1 bits */
0xC0, /* 11000000 - 2 bits */
0xE0, /* 11100000 - 3 bits */
uslen = sizeof(sockaddr_in);
length = sizeof(sockaddr_in);
#endif
- incomingSockfd = accept (this->GetFd(), (sockaddr*)client, &length);
+ incomingSockfd = _accept (this->GetFd(), (sockaddr*)client, &length);
- if ((incomingSockfd > -1) && (!getsockname(incomingSockfd, sock_us, &uslen)))
+ if ((incomingSockfd > -1) && (!_getsockname(incomingSockfd, sock_us, &uslen)))
{
char buf[MAXBUF];
#ifdef IPV6
void irc::sockets::Blocking(int s)
{
- int flags = fcntl(s, F_GETFL, 0);
+#ifndef WIN32
+ int flags = fcntl(s, F_GETFL, 0);
fcntl(s, F_SETFL, flags ^ O_NONBLOCK);
+#else
+ unsigned long opt = 0;
+ ioctlsocket(s, FIONBIO, &opt);
+#endif
}
void irc::sockets::NonBlocking(int s)
{
- int flags = fcntl(s, F_GETFL, 0);
+#ifndef WIN32
+ int flags = fcntl(s, F_GETFL, 0);
fcntl(s, F_SETFL, flags | O_NONBLOCK);
+#else
+ unsigned long opt = 1;
+ ioctlsocket(s, FIONBIO, &opt);
+#endif
}
/** This will bind a socket to a port. It works for UDP/TCP.
}
else
{
- setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
+ setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (char*)&on, sizeof(on));
/* This is BSD compatible, setting l_onoff to 0 is *NOT* http://web.irc.org/mla/ircd-dev/msg02259.html */
linger.l_onoff = 1;
linger.l_linger = 1;
- setsockopt(sockfd, SOL_SOCKET, SO_LINGER, &linger,sizeof(linger));
+ setsockopt(sockfd, SOL_SOCKET, SO_LINGER, (char*)&linger,sizeof(linger));
return (sockfd);
}
}
EventHandler* SocketEngine::GetRef(int fd)
{
if ((fd < 0) || (fd > MAX_DESCRIPTORS))
- return false;
+ return 0;
return ref[fd];
}
const char* TypeName = values[0].GetString();
const char* Classes = values[1].GetString();
- conf->opertypes[TypeName] = strdup(Classes);
+ conf->opertypes[TypeName] = strnewdup(Classes);
return true;
}
const char* ClassName = values[0].GetString();
const char* CommandList = values[1].GetString();
- conf->operclass[ClassName] = strdup(CommandList);
+ conf->operclass[ClassName] = strnewdup(CommandList);
return true;
}
{
if (IS_LOCAL(this))
{
+#ifndef WIN32
return read(this->fd, buffer, size);
+#else
+ return recv(this->fd, (char*)buffer, size, 0);
+#endif
}
else
return 0;
if ((sendq.length()) && (this->fd != FD_MAGIC_NUMBER))
{
int old_sendq_length = sendq.length();
- int n_sent = write(this->fd, this->sendq.data(), this->sendq.length());
+#ifndef WIN32
+ int n_sent = write(this->fd, this->sendq.data(), this->sendq.length());
+#else
+ int n_sent = send(this->fd, (const char*)this->sendq.data(), this->sendq.length(), 0);
+#endif
if (n_sent == -1)
{
if (errno == EAGAIN)
* which for the time being is a physical impossibility (even the largest networks dont have more
* than about 10,000 users on ONE server!)
*/
+#ifndef WINDOWS
if ((unsigned int)socket >= MAX_DESCRIPTORS)
{
userrec::QuitUser(Instance, New, "Server is full");
return;
}
+#endif
New->exempt = (Instance->XLines->matches_exception(New) != NULL);
if (!New->exempt)
*/
void userrec::Write(std::string text)
{
+#ifdef WINDOWS
+ if ((this->fd < 0) || (this->m_internalFd > MAX_DESCRIPTORS))
+#else
if ((this->fd < 0) || (this->fd > MAX_DESCRIPTORS))
+#endif
return;
try
// (unattributed to any author) all over the 'net.
// For now, we'll just consider this public domain.
-bool csmatch(const char *str, const char *mask)
+CoreExport bool csmatch(const char *str, const char *mask)
{
unsigned char *cp = NULL, *mp = NULL;
unsigned char* string = (unsigned char*)str;
return !*wild;
}
-bool match(const char *str, const char *mask)
+CoreExport bool match(const char *str, const char *mask)
{
unsigned char *cp = NULL, *mp = NULL;
unsigned char* string = (unsigned char*)str;
}
/* Overloaded function that has the option of using cidr */
-bool match(const char *str, const char *mask, bool use_cidr_match)
+CoreExport bool match(const char *str, const char *mask, bool use_cidr_match)
{
if (use_cidr_match && MatchCIDR(str, mask, true))
return true;
return match(str, mask);
}
-bool match(bool case_sensitive, const char *str, const char *mask, bool use_cidr_match)
+CoreExport bool match(bool case_sensitive, const char *str, const char *mask, bool use_cidr_match)
{
if (use_cidr_match && MatchCIDR(str, mask, true))
return true;
return csmatch(str, mask);
}
-bool match(bool case_sensitive, const char *str, const char *mask)
+CoreExport bool match(bool case_sensitive, const char *str, const char *mask)
{
return case_sensitive ? csmatch(str, mask) : match(str, mask);
}