summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/Makefile2
-rw-r--r--include/account.h4
-rw-r--r--include/config.h3
-rw-r--r--include/configreader.h18
-rw-r--r--include/datafiles.h25
-rw-r--r--include/extern.h2
-rw-r--r--include/modules.h105
-rw-r--r--include/pseudo.h1
8 files changed, 106 insertions, 54 deletions
diff --git a/include/Makefile b/include/Makefile
index 13c5b8b2c..3d8067aa6 100644
--- a/include/Makefile
+++ b/include/Makefile
@@ -10,7 +10,7 @@ services.h: sysconf.h config.h extern.h
extern.h: slist.h
touch $@
-pseudo.h: commands.h timers.h datafiles.h slist.h
+pseudo.h: commands.h timers.h slist.h
touch $@
clean:
diff --git a/include/account.h b/include/account.h
index e20b70fe4..dc0d21c7d 100644
--- a/include/account.h
+++ b/include/account.h
@@ -58,8 +58,8 @@ enum NickCoreFlag
NI_SUSPENDED,
/* Autoop nickname in channels */
NI_AUTOOP,
- /* Nick won't expire */
- NI_NOEXPIRE,
+ /* This nickcore is forbidden, which means the nickalias for it is aswell */
+ NI_FORBIDDEN,
NI_END
};
diff --git a/include/config.h b/include/config.h
index f9d8f4370..a5151e071 100644
--- a/include/config.h
+++ b/include/config.h
@@ -25,6 +25,9 @@
/* Name of configuration file (in Services directory) */
#define SERVICES_CONF "services.conf"
+/* Name of anope datbase */
+#define DATABASE_FILE "anope.db"
+
/* Name of log file (in Services directory) */
#define LOG_FILENAME "services.log"
diff --git a/include/configreader.h b/include/configreader.h
index 97403b5fa..c9db6cb89 100644
--- a/include/configreader.h
+++ b/include/configreader.h
@@ -432,8 +432,6 @@ class ServerConfig
/* Global realname */
char *desc_GlobalNoticer;
- /* Name of the hostserv database */
- char *HostDBName;
/* HostServ Name */
char *s_HostServ;
/* HostServ realname */
@@ -443,18 +441,6 @@ class ServerConfig
char *PIDFilename;
/* MOTD filename */
char *MOTDFilename;
- /* NickServ DB name */
- char *NickDBName;
- /* DB name for nicks being registered */
- char *PreNickDBName;
- /* Channel DB name */
- char *ChanDBName;
- /* Botserv DB name */
- char *BotDBName;
- /* OperServ db name */
- char *OperDBName;
- /* News DB name */
- char *NewsDBName;
/* True if its ok to not be able to save backs */
bool NoBackupOkay;
@@ -695,8 +681,6 @@ class ServerConfig
unsigned MaxSessionLimit;
/* How long session akills should last */
time_t SessionAutoKillExpiry;
- /* DB name for exceptions */
- char *ExceptionDBName;
/* Reason to use for session kills */
char *SessionLimitExceeded;
/* Optional second reason */
@@ -708,6 +692,8 @@ class ServerConfig
std::list<std::string> ModulesAutoLoad;
/* Encryption modules */
std::list<std::string> EncModuleList;
+ /* Database modules */
+ std::list<std::string> DBModuleList;
/* HostServ Core Modules */
std::list<std::string> HostServCoreModules;
/* MemoServ Core Modules */
diff --git a/include/datafiles.h b/include/datafiles.h
deleted file mode 100644
index fe8cb3d12..000000000
--- a/include/datafiles.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Database file descriptor structure and file handling routine prototypes.
- *
- * (C) 2003-2009 Anope Team
- * Contact us at team@anope.org
- *
- * Please read COPYING and README for furhter details.
- *
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
- *
- * $Id$
- *
- */
-
-#ifndef DATAFILES_H
-#define DATAFILES_H
-
-#ifndef _WIN32
-#include <sys/param.h>
-#define DeleteFile unlink
-#endif
-
-
-
-#endif /* DATAFILES_H */
diff --git a/include/extern.h b/include/extern.h
index 10c4028b4..f570c39ff 100644
--- a/include/extern.h
+++ b/include/extern.h
@@ -393,8 +393,6 @@ E void SetDefaultMLock();
/**** modules.c ****/
E void modules_unload_all(bool unload_proto); /* Read warnings near function source */
-E void ModuleDatabaseBackup(const char *dbname);
-E void ModuleRemoveBackups(const char *dbname);
/**** nickserv.c ****/
diff --git a/include/modules.h b/include/modules.h
index f4d9700f3..129e2666d 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -186,7 +186,7 @@ enum CommandReturn
const char *ano_moderr();
#endif
-typedef enum { CORE,PROTOCOL,THIRD,SUPPORTED,QATESTED,ENCRYPTION } MODType;
+typedef enum { CORE,PROTOCOL,THIRD,SUPPORTED,QATESTED,ENCRYPTION,DATABASE } MODType;
typedef enum { MOD_OP_LOAD, MOD_OP_UNLOAD } ModuleOperation;
/*************************************************************************/
@@ -561,11 +561,15 @@ class CoreExport Module
*/
virtual void OnPostLoadDatabases() { }
- /** Called when anope saves databases.
- * NOTE: This event is deprecated pending new database handling.
- * XXX.
+ /** Called when the databases are saved
+ * @return EVENT_CONTINUE to let other modules continue saving, EVENT_STOP to stop
+ */
+ virtual EventReturn OnSaveDatabase() { return EVENT_CONTINUE; }
+
+ /** Called when the databases are loaded
+ * @return EVENT_CONTINUE to let other modules continue saving, EVENT_STOP to stop
*/
- virtual void OnSaveDatabase() MARK_DEPRECATED { }
+ virtual EventReturn OnLoadDatabase() { return EVENT_CONTINUE; }
/** Called when anope backs up databases.
* NOTE: This event is deprecated pending new database handling.
@@ -684,6 +688,73 @@ class CoreExport Module
*/
virtual void OnDatabaseExpire() MARK_DEPRECATED { }
+ /** Called when the flatfile dbs are being written
+ * @param Write A callback to the function used to insert a line into the database
+ */
+ virtual void OnDatabaseWrite(void (*Write)(const std::string &)) { }
+
+ /** Called when a line is read from the database
+ * @param params The params from the database
+ * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to stop processing
+ */
+ virtual EventReturn OnDatabaseRead(const std::vector<std::string> &params) { return EVENT_CONTINUE; }
+
+ /** Called when nickcore metadata is read from the database
+ * @param nc The nickcore
+ * @param key The metadata key
+ * @param params The params from the database
+ * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to stop processing
+ */
+ virtual EventReturn OnDatabaseReadMetadata(NickCore *nc, const std::string &key, const std::vector<std::string> &params) { return EVENT_CONTINUE; }
+
+ /** Called when nickcore metadata is read from the database
+ * @param na The nickalias
+ * @param key The metadata key
+ * @param params The params from the database
+ * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to stop processing
+ */
+ virtual EventReturn OnDatabaseReadMetadata(NickAlias *na, const std::string &key, const std::vector<std::string> &params) { return EVENT_CONTINUE; }
+
+ /** Called when botinfo metadata is read from the database
+ * @param bi The botinfo
+ * @param key The metadata key
+ * @param params The params from the database
+ * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to stop processing
+ */
+ virtual EventReturn OnDatabaseReadMetadata(BotInfo *bi, const std::string &key, const std::vector<std::string> &params) { return EVENT_CONTINUE; }
+
+ /** Called when chaninfo metadata is read from the database
+ * @param ci The chaninfo
+ * @param key The metadata key
+ * @param params The params from the database
+ * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to stop processing
+ */
+ virtual EventReturn OnDatabaseReadMetadata(ChannelInfo *ci, const std::string &key, const std::vector<std::string> &params) { return EVENT_CONTINUE; }
+
+ /** Called when we are writing metadata for a nickcore
+ * @param WriteMetata A callback function used to insert the metadata
+ * @param nc The nickcore
+ */
+ virtual void OnDatabaseWriteMetadata(void (*WriteMetadata)(const std::string &, const std::string &), NickCore *nc) { }
+
+ /** Called when we are wrting metadata for a nickalias
+ * @param WriteMetata A callback function used to insert the metadata
+ * @param na The nick alias
+ */
+ virtual void OnDatabaseWriteMetadata(void (*WriteMetadata)(const std::string &, const std::string &), NickAlias *na) { }
+
+ /** Called when we are writing metadata for a botinfo
+ * @param WriteMetata A callback function used to insert the metadata
+ * @param bi The botinfo
+ */
+ virtual void OnDatabaseWriteMetadata(void (*WriteMetadata)(const std::string &, const std::string &), BotInfo *bi) { }
+
+ /** Called when are are writing metadata for a channelinfo
+ * @param WriteMetata A callback function used to insert the metadata
+ * @param bi The channelinfo
+ */
+ virtual void OnDatabaseWriteMetadata(void (*WriteMetadata)(const std::string &, const std::string &), ChannelInfo *ci) { }
+
/** Called before services restart
*/
virtual void OnPreRestart() { }
@@ -983,6 +1054,18 @@ class CoreExport Module
*/
virtual EventReturn OnUnMLock(ChannelModeName Name) { return EVENT_CONTINUE; }
+ /** Called after a module is loaded
+ * @param u The user loading the module, can be NULL
+ * @param m The module
+ */
+ virtual void OnModuleLoad(User *u, Module *m) { }
+
+ /** Called before a module is unloaded
+ * @param u The user, can be NULL
+ * @param m The module
+ */
+ virtual void OnModuleUnload(User *u, Module *m) { }
+
};
@@ -1019,9 +1102,17 @@ enum Implementation
/* OperServ */
I_OnOperServHelp, I_OnDefconLevel,
+ /* Database */
+ I_OnPostLoadDatabases, I_OnSaveDatabase, I_OnLoadDatabase, I_OnBackupDatabase,
+ I_OnDatabaseExpire,
+ I_OnDatabaseWrite, I_OnDatabaseRead, I_OnDatabaseReadMetadata, I_OnDatabaseWriteMetadata,
+
+ /* Modules */
+ I_OnModuleLoad, I_OnModuleUnload,
+
/* Other */
- I_OnReload, I_OnPreServerConnect, I_OnNewServer, I_OnServerConnect, I_OnPreCommandRun, I_OnPreCommand, I_OnPostCommand, I_OnPostLoadDatabases, I_OnSaveDatabase, I_OnBackupDatabase,
- I_OnPreDatabaseExpire, I_OnDatabaseExpire, I_OnPreRestart, I_OnRestart, I_OnPreShutdown, I_OnShutdown, I_OnSignal,
+ I_OnReload, I_OnPreServerConnect, I_OnNewServer, I_OnServerConnect, I_OnPreCommandRun, I_OnPreCommand, I_OnPostCommand,
+ I_OnPreDatabaseExpire, I_OnPreRestart, I_OnRestart, I_OnPreShutdown, I_OnShutdown, I_OnSignal,
I_OnServerQuit, I_OnTopicUpdated,
I_OnEncrypt, I_OnEncryptInPlace, I_OnEncryptCheckLen, I_OnDecrypt, I_OnCheckPassword,
I_OnChannelModeSet, I_OnChannelModeUnset, I_OnUserModeSet, I_OnUserModeUnset, I_OnChannelModeAdd, I_OnUserModeAdd,
diff --git a/include/pseudo.h b/include/pseudo.h
index 65e5e81e7..d356aa953 100644
--- a/include/pseudo.h
+++ b/include/pseudo.h
@@ -15,5 +15,4 @@
#include "commands.h"
#include "language.h"
#include "timers.h"
-#include "datafiles.h"
#include "slist.h"