summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2015-10-27 18:57:37 -0400
committerAdam <Adam@anope.org>2015-10-27 18:58:48 -0400
commit64dac60071fab652745a6e7a06cf6b7bdbbd3625 (patch)
treef8f30161150451672b381f6370a8fdcab654bbb8 /include
parent162fdbe5815bbdf187f549fefac94ff476d72e62 (diff)
parent830361e97d03c74e54cb1cf1bbf329dffdeb66f7 (diff)
Merge branch '2.0' into 2.1
Diffstat (limited to 'include')
-rw-r--r--include/CMakeLists.txt3
-rw-r--r--include/anope.h6
-rw-r--r--include/channels.h6
-rw-r--r--include/config.h2
-rw-r--r--include/event.h3
-rw-r--r--include/hashcomp.h2
-rw-r--r--include/modes.h6
-rw-r--r--include/modules.h33
-rw-r--r--include/modules/chanserv.h4
-rw-r--r--include/modules/cs_mode.h2
-rw-r--r--include/modules/ldap.h42
-rw-r--r--include/sockets.h2
-rw-r--r--include/users.h4
-rw-r--r--include/version.cpp122
14 files changed, 155 insertions, 82 deletions
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
index 7476edfe7..72bfdfba1 100644
--- a/include/CMakeLists.txt
+++ b/include/CMakeLists.txt
@@ -7,7 +7,7 @@ get_target_property(version_BINARY version LOCATION)
# Modify version.h from the above executable, with dependencies to version.cpp
# and all of the source files in the main build
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/version_build
- COMMAND ${version_BINARY} ${Anope_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/version.h
+ COMMAND ${version_BINARY} ${Anope_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/version.h ${CMAKE_CURRENT_BINARY_DIR}/build.h
DEPENDS version ${SRC_SRCS}
)
# Add version to list of files for CPack to ignore
@@ -15,6 +15,7 @@ get_filename_component(version_BINARY ${version_BINARY} NAME)
add_to_cpack_ignored_files("${version_BINARY}$" TRUE)
if(NOT WIN32)
add_to_cpack_ignored_files("version.h$" TRUE)
+ add_to_cpack_ignored_files("build.h$" TRUE)
endif(NOT WIN32)
# Add a custom target to the above file
diff --git a/include/anope.h b/include/anope.h
index 218e75d47..f6e864300 100644
--- a/include/anope.h
+++ b/include/anope.h
@@ -542,7 +542,7 @@ namespace Anope
extern CoreExport Anope::string Random(size_t len);
}
-/** sepstream allows for splitting token seperated lists.
+/** sepstream allows for splitting token separated lists.
* Each successive call to sepstream::GetToken() returns
* the next token, until none remain, at which point the method returns
* an empty string.
@@ -614,7 +614,7 @@ class CoreExport sepstream
bool StreamEnd();
};
-/** A derived form of sepstream, which seperates on commas
+/** A derived form of sepstream, which separates on commas
*/
class commasepstream : public sepstream
{
@@ -624,7 +624,7 @@ class commasepstream : public sepstream
commasepstream(const Anope::string &source, bool allowempty = false) : sepstream(source, ',', allowempty) { }
};
-/** A derived form of sepstream, which seperates on spaces
+/** A derived form of sepstream, which separates on spaces
*/
class spacesepstream : public sepstream
{
diff --git a/include/channels.h b/include/channels.h
index f2dc9e182..4b814c8bd 100644
--- a/include/channels.h
+++ b/include/channels.h
@@ -31,6 +31,8 @@ struct ChanUserContainer : public Extensible
class CoreExport Channel : public Base, public Extensible
{
+ static std::vector<Channel *> deleting;
+
public:
typedef std::multimap<Anope::string, Anope::string> ModeList;
private:
@@ -258,7 +260,7 @@ class CoreExport Channel : public Base, public Extensible
* @param newtopic The new topic
* @param ts The time the new topic is being set
*/
- void ChangeTopicInternal(const Anope::string &user, const Anope::string &newtopic, time_t ts = Anope::CurTime);
+ void ChangeTopicInternal(User *u, const Anope::string &user, const Anope::string &newtopic, time_t ts = Anope::CurTime);
/** Update the topic of the channel, and reset it if topiclock etc says to
* @param user The user setting the topic
@@ -300,5 +302,7 @@ class CoreExport Channel : public Base, public Extensible
* @param ts The time the channel was created
*/
static Channel *FindOrCreate(const Anope::string &name, bool &created, time_t ts = Anope::CurTime);
+
+ static void DeleteChannels();
};
diff --git a/include/config.h b/include/config.h
index 65a8bf55d..4fe5a94d5 100644
--- a/include/config.h
+++ b/include/config.h
@@ -104,6 +104,8 @@ namespace Configuration
bool UseStrictPrivmsg;
/* flag for options:regexengine */
std::regex::flag_type regex_flags;
+ /* networkinfo:nickchars */
+ Anope::string NickChars;
/* either "/msg " or "/" */
Anope::string StrictPrivmsg;
diff --git a/include/event.h b/include/event.h
index 1cc39a67e..f7934b84a 100644
--- a/include/event.h
+++ b/include/event.h
@@ -358,11 +358,12 @@ namespace Event
struct CoreExport TopicUpdated : Events
{
/** Called when a new topic is set
+ * @param source
* @param c The channel
* @param setter The user who set the new topic
* @param topic The new topic
*/
- virtual void OnTopicUpdated(Channel *c, const Anope::string &user, const Anope::string &topic) anope_abstract;
+ virtual void OnTopicUpdated(User *source, Channel *c, const Anope::string &user, const Anope::string &topic) anope_abstract;
};
extern CoreExport EventHandlers<TopicUpdated> OnTopicUpdated;
diff --git a/include/hashcomp.h b/include/hashcomp.h
index a9a1105ee..43440453c 100644
--- a/include/hashcomp.h
+++ b/include/hashcomp.h
@@ -67,7 +67,7 @@ namespace ci
* @param s1 String to find in
* @param n Position to search up to
* @param c Character to search for
- * @return Pointer to the first occurance of c in s1
+ * @return Pointer to the first occurrence of c in s1
*/
static const char *find(const char *s1, int n, char c);
};
diff --git a/include/modes.h b/include/modes.h
index c010700ca..bc69f77d0 100644
--- a/include/modes.h
+++ b/include/modes.h
@@ -112,6 +112,8 @@ class CoreExport ChannelMode : public Mode
bool CanSet(User *u) const override;
+ virtual void Check() { }
+
/** 'wrap' this channel mode and param to the underlying mode and param
*/
virtual ChannelMode *Wrap(Anope::string &param);
@@ -210,9 +212,11 @@ class CoreExport ChannelModeVirtual : public T
~ChannelModeVirtual();
+ void Check() override;
+
ChannelMode *Wrap(Anope::string &param) override;
- ChannelMode *Unwrap(ChannelMode *cm, Anope::string &param) = 0;
+ ChannelMode *Unwrap(ChannelMode *cm, Anope::string &param) anope_abstract;
};
/* The status a user has on a channel (+v, +h, +o) etc */
diff --git a/include/modules.h b/include/modules.h
index 87051704b..e885a800e 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -18,13 +18,22 @@
#include "timers.h"
#include "logger.h"
#include "extensible.h"
+#include "version.h"
class ModuleDef;
+struct ModuleVersionC;
+
+enum
+{
+ ANOPE_MODAPI_VER = 1
+};
struct AnopeModule
{
+ unsigned int api_version;
ModuleDef* (*init)();
void (*fini)(ModuleDef *);
+ ModuleVersionC (*version)();
};
class ModuleDef
@@ -70,10 +79,20 @@ template<class ModuleClass> void ModuleInfo(ModuleDef *moddef) { }
{ \
delete def; \
} \
+ static ModuleVersionC ModuleVersion() \
+ { \
+ ModuleVersionC ver; \
+ ver.version_major = VERSION_MAJOR; \
+ ver.version_minor = VERSION_MINOR; \
+ ver.version_patch = VERSION_PATCH; \
+ return ver; \
+ } \
extern "C" DllExport struct AnopeModule AnopeMod = \
{ \
+ ANOPE_MODAPI_VER, \
CreateModuleDef, \
- DeleteModuleDef \
+ DeleteModuleDef, \
+ ModuleVersion \
};
enum ModuleReturn
@@ -113,6 +132,11 @@ enum
};
typedef unsigned short ModType;
+struct ModuleVersionC
+{
+ int version_major, version_minor, version_patch;
+};
+
/** Returned by Module::GetVersion, used to see what version of Anope
* a module is compiled against.
*/
@@ -124,12 +148,7 @@ class ModuleVersion
int version_patch;
public:
- /** Constructor
- * @param major The major version number
- * @param minor The minor version number
- * @param patch The patch version number
- */
- ModuleVersion(int major, int minor, int patch);
+ ModuleVersion(const ModuleVersionC &);
/** Get the major version of Anope this was built against
* @return The major version
diff --git a/include/modules/chanserv.h b/include/modules/chanserv.h
index f0c396d39..35fc3c332 100644
--- a/include/modules/chanserv.h
+++ b/include/modules/chanserv.h
@@ -266,8 +266,8 @@ namespace ChanServ
/** Retrieve the access for a user or group in the form of a vector of access entries
* (as multiple entries can affect a single user).
*/
- virtual AccessGroup AccessFor(const User *u) anope_abstract;
- virtual AccessGroup AccessFor(NickServ::Account *nc) anope_abstract;
+ virtual AccessGroup AccessFor(const User *u, bool updateLastUsed = true) anope_abstract;
+ virtual AccessGroup AccessFor(NickServ::Account *nc, bool updateLastUsed = true) anope_abstract;
/** Get the size of the accss vector for this channel
* @return The access vector size
diff --git a/include/modules/cs_mode.h b/include/modules/cs_mode.h
index 4d5f9dd2f..4c7965e2a 100644
--- a/include/modules/cs_mode.h
+++ b/include/modules/cs_mode.h
@@ -92,7 +92,7 @@ class ModeLocks : public Service
virtual ModeLock *GetMLock(ChanServ::Channel *, const Anope::string &mname, const Anope::string &param = "") anope_abstract;
/** Get the current mode locks as a string
- * @param complete True to show mlock parameters aswell
+ * @param complete True to show mlock parameters as well
* @return A string of mode locks, eg: +nrt
*/
virtual Anope::string GetMLockAsString(ChanServ::Channel *, bool complete) const anope_abstract;
diff --git a/include/modules/ldap.h b/include/modules/ldap.h
index e3897b8cc..51ef842c8 100644
--- a/include/modules/ldap.h
+++ b/include/modules/ldap.h
@@ -1,8 +1,6 @@
#ifndef ANOPE_LDAP_H
#define ANOPE_LDAP_H
-typedef int LDAPQuery;
-
class LDAPException : public ModuleException
{
public:
@@ -59,28 +57,26 @@ struct LDAPAttributes : public std::map<Anope::string, std::vector<Anope::string
}
};
+enum QueryType
+{
+ QUERY_UNKNOWN,
+ QUERY_BIND,
+ QUERY_SEARCH,
+ QUERY_ADD,
+ QUERY_DELETE,
+ QUERY_MODIFY
+};
+
struct LDAPResult
{
std::vector<LDAPAttributes> messages;
Anope::string error;
- enum QueryType
- {
- QUERY_UNKNOWN,
- QUERY_BIND,
- QUERY_SEARCH,
- QUERY_ADD,
- QUERY_DELETE,
- QUERY_MODIFY
- };
-
QueryType type;
- LDAPQuery id;
LDAPResult()
{
this->type = QUERY_UNKNOWN;
- this->id = -1;
}
size_t size() const
@@ -126,48 +122,42 @@ class LDAPProvider : public Service
/** Attempt to bind to the LDAP server as an admin
* @param i The LDAPInterface the result is sent to
- * @return The query ID
*/
- virtual LDAPQuery BindAsAdmin(LDAPInterface *i) anope_abstract;
+ virtual void BindAsAdmin(LDAPInterface *i) anope_abstract;
/** Bind to LDAP
* @param i The LDAPInterface the result is sent to
* @param who The binddn
* @param pass The password
- * @return The query ID
*/
- virtual LDAPQuery Bind(LDAPInterface *i, const Anope::string &who, const Anope::string &pass) anope_abstract;
+ virtual void Bind(LDAPInterface *i, const Anope::string &who, const Anope::string &pass) anope_abstract;
/** Search ldap for the specified filter
* @param i The LDAPInterface the result is sent to
* @param base The base DN to search
* @param filter The filter to apply
- * @return The query ID
*/
- virtual LDAPQuery Search(LDAPInterface *i, const Anope::string &base, const Anope::string &filter) anope_abstract;
+ virtual void Search(LDAPInterface *i, const Anope::string &base, const Anope::string &filter) anope_abstract;
/** Add an entry to LDAP
* @param i The LDAPInterface the result is sent to
* @param dn The dn of the entry to add
* @param attributes The attributes
- * @return The query ID
*/
- virtual LDAPQuery Add(LDAPInterface *i, const Anope::string &dn, LDAPMods &attributes) anope_abstract;
+ virtual void Add(LDAPInterface *i, const Anope::string &dn, LDAPMods &attributes) anope_abstract;
/** Delete an entry from LDAP
* @param i The LDAPInterface the result is sent to
* @param dn The dn of the entry to delete
- * @return The query ID
*/
- virtual LDAPQuery Del(LDAPInterface *i, const Anope::string &dn) anope_abstract;
+ virtual void Del(LDAPInterface *i, const Anope::string &dn) anope_abstract;
/** Modify an existing entry in LDAP
* @param i The LDAPInterface the result is sent to
* @param base The base DN to modify
* @param attributes The attributes to modify
- * @return The query ID
*/
- virtual LDAPQuery Modify(LDAPInterface *i, const Anope::string &base, LDAPMods &attributes) anope_abstract;
+ virtual void Modify(LDAPInterface *i, const Anope::string &base, LDAPMods &attributes) anope_abstract;
};
#endif // ANOPE_LDAP_H
diff --git a/include/sockets.h b/include/sockets.h
index a0e310885..49e9d1fcd 100644
--- a/include/sockets.h
+++ b/include/sockets.h
@@ -371,7 +371,7 @@ class CoreExport ListenSocket : public virtual Socket
virtual ~ListenSocket();
/** Process what has come in from the connection
- * @return false to destory this socket
+ * @return false to destroy this socket
*/
bool ProcessRead();
diff --git a/include/users.h b/include/users.h
index 2942c91a8..656ab667c 100644
--- a/include/users.h
+++ b/include/users.h
@@ -49,7 +49,7 @@ class CoreExport User : public virtual Base, public virtual Extensible, public C
Anope::string vident;
Anope::string ident;
Anope::string uid;
- /* If the user is on the access list of the nick theyre on */
+ /* If the user is on the access list of the nick they're on */
bool on_access;
/* Map of user modes and the params this user has (if any) */
ModeList modes;
@@ -110,7 +110,7 @@ class CoreExport User : public virtual Base, public virtual Extensible, public C
* @param svhost The vhost of the user
* @param sip The ip of the user
* @param sserver The server of the user
- * @param srealname The realname/gecos of teh user
+ * @param srealname The realname/gecos of the user
* @param ts User's timestamp
* @param smodes User's modes
* @param suid The unique identifier of the user.
diff --git a/include/version.cpp b/include/version.cpp
index 5432188fe..c688c07e8 100644
--- a/include/version.cpp
+++ b/include/version.cpp
@@ -13,7 +13,7 @@
#include <iostream>
#include <fstream>
#include <sstream>
-#include <list>
+#include <map>
static std::string get_git_hash(const std::string &git_dir)
{
@@ -45,29 +45,16 @@ static std::string get_git_hash(const std::string &git_dir)
return "g" + filebuf.substr(0, 7);
}
-int main(int argc, char *argv[])
+static bool read_version_sh(const std::string &version_sh, std::map<std::string, std::string> &versions)
{
- if (argc < 3)
- {
- std::cerr << "Syntax: " << argv[0] << " <base> <version.h>" << std::endl;
- return 1;
- }
-
- std::string version_sh = std::string(argv[1]) + "/src/version.sh";
- std::string git_dir = std::string(argv[1]) + "/.git";
-
- std::fstream fd;
-
- fd.clear();
- fd.open(version_sh.c_str(), std::ios::in);
+ std::fstream fd(version_sh.c_str(), std::ios::in);
if (!fd.is_open())
{
std::cerr << "Error: Unable to open src/version.sh for reading: " << version_sh << std::endl;
- return 1;
+ return false;
}
std::string filebuf;
- std::list<std::pair<std::string, std::string> > versions;
while (getline(fd, filebuf))
{
if (!filebuf.find("VERSION_"))
@@ -75,24 +62,25 @@ int main(int argc, char *argv[])
size_t eq = filebuf.find('=');
std::string type = filebuf.substr(0, eq);
- std::string value = filebuf.substr(eq + 2, filebuf.length() - eq - 3);
- versions.push_back(std::make_pair(type, value));
+ std::string value = filebuf.substr(eq + 1);
+
+ versions[type] = value;
}
}
fd.close();
- std::string git_version = get_git_hash(git_dir);
- if (!git_version.empty())
- versions.push_back(std::make_pair("VERSION_GIT", git_version));
+ return true;
+}
- fd.clear();
- fd.open(argv[2], std::ios::in);
+static bool write_build_h(const std::string &buildh, const std::string &git_version)
+{
+ std::fstream fd(buildh.c_str(), std::ios::in);
std::string build = "#define BUILD 1";
if (fd.is_open())
{
- while (getline(fd, filebuf))
+ for (std::string filebuf; getline(fd, filebuf);)
{
if (!filebuf.find("#define BUILD"))
{
@@ -110,27 +98,91 @@ int main(int argc, char *argv[])
}
fd.clear();
- fd.open(argv[2], std::ios::out);
-
+ fd.open(buildh.c_str(), std::ios::out);
if (!fd.is_open())
{
- std::cerr << "Error: Unable to include/version.h for writing: " << argv[2] << std::endl;
- return 1;
+ std::cerr << "Error: Unable to open build.h for writing: " << buildh << std::endl;
+ return false;
}
fd << "/* This file is automatically generated by version.cpp - do not edit it! */" << std::endl;
+ fd << build << std::endl;
+ if (!git_version.empty())
+ fd << "#define VERSION_GIT \"" << git_version << "\"" << std::endl;
+ fd.close();
- for (std::list<std::pair<std::string, std::string> >::iterator it = versions.begin(), it_end = versions.end(); it != it_end; ++it)
+ return true;
+}
+
+static void read_version_h(const std::string &versionh, std::map<std::string, std::string> &versions)
+{
+ std::fstream fd(versionh.c_str(), std::ios::in);
+
+ if (!fd.is_open())
+ return;
+
+ for (std::string filebuf; getline(fd, filebuf);)
{
- if (it->first == "VERSION_EXTRA" || it->first == "VERSION_GIT")
- fd << "#define " << it->first << " \"" << it->second << "\"" << std::endl;
- else
- fd << "#define " << it->first << " " << it->second << std::endl;
+ if (!filebuf.find("#define VERSION_"))
+ {
+ size_t space = filebuf.substr(8).find(' ');
+
+ std::string name = filebuf.substr(8).substr(0, space),
+ version = filebuf.substr(8).substr(space + 1);
+
+ versions[name] = version;
+ }
}
- fd << build << std::endl;
+ fd.close();
+}
+
+static bool write_version_h(const std::string &versionh, const std::map<std::string, std::string> &versions)
+{
+ std::fstream fd(versionh.c_str(), std::ios::out);
+
+ if (!fd.is_open())
+ return false;
+
+ for (std::map<std::string, std::string>::const_iterator it = versions.begin(); it != versions.end(); ++it)
+ {
+ fd << "#define " << it->first << " " << it->second << std::endl;
+ }
fd.close();
+ return true;
+}
+
+int main(int argc, char *argv[])
+{
+ if (argc < 4)
+ {
+ std::cerr << "Syntax: " << argv[0] << " <base> <version.h> <build.h>" << std::endl;
+ return 1;
+ }
+
+ std::string version_sh = std::string(argv[1]) + "/src/version.sh";
+ std::string git_dir = std::string(argv[1]) + "/.git";
+ std::string versionh = argv[2];
+ std::string buildh = argv[3];
+
+ std::map<std::string, std::string> versions, old_versions;
+
+ if (!read_version_sh(version_sh, versions))
+ return -1;
+
+ std::string git_version = get_git_hash(git_dir);
+ if (!write_build_h(buildh, git_version))
+ return -1;
+
+ read_version_h(versionh, old_versions);
+
+ if (versions == old_versions)
+ return 0;
+
+ if (!write_version_h(versionh, versions))
+ return -1;
+
return 0;
}