summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2011-09-25 04:19:15 -0400
committerAdam <Adam@anope.org>2011-09-25 04:19:15 -0400
commit1f2399de364c09adcce4193895cd362d80ffdfc5 (patch)
tree5f40fc531f22c174b6e10bb7bc12842a4a21d30b /src
parent43201ead9575a74e350710bc191f4ac67366aca7 (diff)
Added a new database format and sqlite support. Also moved db-convert to a module.
Diffstat (limited to 'src')
-rw-r--r--src/access.cpp1
-rw-r--r--src/base.cpp16
-rw-r--r--src/bin/CMakeLists.txt2
-rwxr-xr-xsrc/bin/cp-recursive21
-rwxr-xr-xsrc/bin/langtool239
-rwxr-xr-xsrc/bin/mydbgen148
-rw-r--r--src/bots.cpp23
-rw-r--r--src/hostserv.cpp2
-rw-r--r--src/init.cpp4
-rw-r--r--src/main.cpp1
-rw-r--r--src/memoserv.cpp32
-rw-r--r--src/misc.cpp13
-rw-r--r--src/modes.cpp2
-rw-r--r--src/nickalias.cpp44
-rw-r--r--src/nickcore.cpp51
-rw-r--r--src/operserv.cpp41
-rw-r--r--src/regchannel.cpp221
-rw-r--r--src/tools/db-convert.cpp1032
-rw-r--r--src/tools/db-convert.h975
19 files changed, 438 insertions, 2430 deletions
diff --git a/src/access.cpp b/src/access.cpp
index 8a293a42d..d519abf39 100644
--- a/src/access.cpp
+++ b/src/access.cpp
@@ -11,7 +11,6 @@
#include "services.h"
#include "modules.h"
-#include "access.h"
enum
{
diff --git a/src/base.cpp b/src/base.cpp
index 0aec072a1..18450ef90 100644
--- a/src/base.cpp
+++ b/src/base.cpp
@@ -1,6 +1,22 @@
#include "services.h"
#include "modules.h"
+std::vector<SerializableBase *> serialized_types;
+std::list<SerializableBase *> serialized_items;
+
+void RegisterTypes()
+{
+ Serializable<NickCore>::Alloc.Register("NickCore");
+ Serializable<NickAlias>::Alloc.Register("NickAlias");
+ Serializable<BotInfo>::Alloc.Register("BotInfo");
+ Serializable<ChannelInfo>::Alloc.Register("ChannelInfo");
+ Serializable<LogSetting>::Alloc.Register("LogSetting");
+ Serializable<ModeLock>::Alloc.Register("ModeLock");
+ Serializable<AutoKick>::Alloc.Register("AutoKick");
+ Serializable<BadWord>::Alloc.Register("BadWord");
+ Serializable<Memo>::Alloc.Register("Memo");
+}
+
Base::Base()
{
}
diff --git a/src/bin/CMakeLists.txt b/src/bin/CMakeLists.txt
index 7c6fe514b..cb110edb5 100644
--- a/src/bin/CMakeLists.txt
+++ b/src/bin/CMakeLists.txt
@@ -1,7 +1,7 @@
# If not on Windows, generate anoperc and install it along with mydbgen
if(NOT WIN32)
configure_file(${Anope_SOURCE_DIR}/src/bin/anoperc.in ${Anope_BINARY_DIR}/src/bin/anoperc)
- install (PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/anoperc ${CMAKE_CURRENT_SOURCE_DIR}/mydbgen
+ install (PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/anoperc
DESTINATION bin
)
diff --git a/src/bin/cp-recursive b/src/bin/cp-recursive
deleted file mode 100755
index e51230db7..000000000
--- a/src/bin/cp-recursive
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/sh
-
-if [ $1 = "-t" ] ; then
- shift
-fi
-if [ ! "$2" ] ; then
- echo >&2 Usage: $0 '<sourcedir> <targetdir>'
- exit 1
-fi
-if [ -d "$1" ] ; then
- dir="$1"
-else
- dir="`echo $1 | sed 's#\(.*\)/.*#\1#'`"
-fi
-while [ "$2" ] ; do
- shift
-done
-if [ ! -d $1 ] ; then
- mkdir -p $1 || exit 1
-fi
-/bin/tar -Ccf $dir - . | /bin/tar -Cxf $1 -
diff --git a/src/bin/langtool b/src/bin/langtool
deleted file mode 100755
index c1072760c..000000000
--- a/src/bin/langtool
+++ /dev/null
@@ -1,239 +0,0 @@
-#!/usr/bin/perl
-#
-# Ribosome's all in one language tool
-# 1) Compares to check for missing lines
-# 2) Compares to check for equal lines
-# 3) Fixes (on request) missing lines
-# 4) Checks for errors in lines
-# 5) Checks for long lines (>60 characters)
-#
-
-# Check to see if we have received arguments
-if (!$ARGV[0]) {
-print "Usage: $0 [language file]\n";
-exit;
-}
-
-# If yes, set $sourcefile to the language filename
-$testagainst = $ARGV[0];
-
-# Set $sourcefile to en_us language file
-$sourcefile = "en_us.l";
-
-# Number of Keys in File, Number of Equal Lines, Number of Missing Lines
-# Fixed Lines (optional) and Number of Format Error Lines, Number of Long Lines
-my $numberlines = 0;
-my $equallines = 0;
-my $missinglines = 0;
-my $fixedlines = 0;
-my $errorline = 0;
-my $longlines = 0;
-
-# Array to hold the lines from the source file and explosion array for long line check
-
-my @sourcearray;
-my @explosion;
-
-# Create associative arrays which will contain keys and definitions
-# One for the control source and one for what is being tested against
-
-my %sourcehash= ();
-my %testhash= ();
-
-# Check if Files Exist
-
-if (! -f $sourcefile) {
-print "Critical Error: The source file does not exist or is unreadable.\nNote: This tool must be run from the language directory.\n";
-exit;
-}
-
-if (! -f $testagainst) {
-print "Critical Error: The language file does not exist or is unreadable\n";
-exit;
-}
-###########################################
-# Function to load sourcefile into memory #
-###########################################
-
-sub load_sourcefile {
-
- my $_key; # This variable will hold the key
- my $_def; # This variable will hold the definition
- my $line; # This variable will hold the current line
-
- open (SOURCEFILE, "< $sourcefile"); # Open the source file
- while (<SOURCEFILE>) { # For each line the source file
- $line = $_; # $line is set to the line in the source file
-
- # Skip comments
- if (/^#/) { # This checks for # which indicates comment
- next; # If detected, the next line is skipped to
- }
-
- # Start of a key
- if (/^[A-Z]/) { # Checks to see if the line is a key
- chomp($line); # Removes things that shouldn't be at the end
- push (@sourcearray, $line); # Puts the line into the source array
- # If a key is defined, load definition into the hash
- if ($_key ne undef) { # If the key is defined
- $sourcehash{$_key} = $_def; # Add the definition to the associative array
- }
- $_key=$line; # Set the key to the line
- $_def=""; # Reset the definition
- next; # Move onto the next line
- }
-
- if ($_key ne undef) { # If the key is set already
- $_def.=$line; # The definition is the current line
- }
-
- $sourcehash{$_key} = $_def; # Load the definition into the associative array
- } # End of while which reads lines
-
- close (SOURCEFILE); # Close the source file
-
-} # End of load_sourcefile function
-
-#################################################
-# Function to load testagainst file into memory #
-#################################################
-
-sub load_testagainst {
-
- my $_key; # This variable will hold the key
- my $_def; # This variable will hold the definition
- my $line; # This variable will hold the current line
-
- open (TESTAGAINSTFILE, "< $testagainst"); # Open the file containing the control lines
- while (<TESTAGAINSTFILE>) { # For each line in the file
- $line = $_; # $line is set to the lines value
-
-
- # Skip comments
- if (/^#/) { # This checks for # which indicates comment
- next; # If detected, the next line is skipped to
- }
-
- # Start of a key
- if (/^[A-Z]/) { # Checks to see if the line is a key
- chomp($line); # Removes things that shouldn't be at the end
-
-
- if ($_key ne undef) { # If the key is defined
- $testhash{$_key} = $_def; # Add the definition to the associative array
- }
- $_key=$line; # Set the key to the line
- $_def=""; # Reset the definition
- next; # Move onto the next line
- }
-
- if ($_key ne undef) { # If the key is set already
- $_def.=$line; # The definition is the current line
- }
-
- $testhash{$_key} = $_def; # Load the definition into the associative array
- } # End of while which reads lines
- close (TESTAGAINSTFILE); # Close the source file
-
-}
-
-
-sub get_format { # Function to get the formatting from a string
- my $fmt="";
- my $str=shift; # Get the input
-
- while ($str =~ m/%\w/g) {
- $fmt .= $&;
- }
-
- return $fmt; # Return the formatting
-}
-
-
-load_sourcefile; # Call function to load the source file
-load_testagainst; # Call function to load the test file
-
-if (!grep(/^LANG_NAME/,%testhash)) {
-print "Critical Error: $ARGV[0] is not a valid language file!\n";
-exit;
-}
-
-open (LOG,"> langcheck.log"); # Open logfile for writing
-
-foreach $sourcearray (@sourcearray) { # For each key stored in the source array
- my $_key=$_; # Store key from source array in $_key
-
- if ((get_format($sourcehash{$sourcearray})) ne (get_format($testhash{$sourcearray}))) {
- if ($sourcearray !~ STRFTIME ) {
- $errorline++;
- print LOG "FORMAT: $sourcearray - (expecting '".get_format($sourcehash{$sourcearray})."' and got '".get_format($testhash{$sourcearray})."')\n";
- } }
-
- if ($testhash{$sourcearray} eq $sourcehash{$sourcearray} ) {
- # If the definitions between the source and the test are equal
- $equallines++; # Number of equal lines increases
- print LOG "EQUAL: $sourcearray\n"; # Line is written to logfile
- }
-
- if (!grep(/^$sourcearray/,%testhash)) { # If the key is found in the testhash associative array
- $missinglines++; # Increase missing lines
- print LOG "MISSING: $sourcearray\n"; # Line is written to logfile
- }
-
- @explosion = split(/\n/, $testhash{$sourcearray});
- foreach $explosion (@explosion) {
- $explosion =~ s/\002//g;
- $explosion =~ s/\037//g;
- if (length($explosion) > 61) {
- print LOG "LONGLINE: $sourcearray (".substr($explosion,1,30)."...)\n";
- $longlines++;
- }
- }
-
-$numberlines++; # Increase the number of lines tested by 1
-}
-close (LOG); # Close the logfile
-
-
-#########################
-# Show the test results #
-#########################
-
-print "Calculation Results:\n";
-print "----------------------------------\n";
-print "[$numberlines] line(s) were compared\n";
-print "[$equallines] line(s) were found to equal their $sourcefile counterpart(s)\n";
-print "[$missinglines] line(s) were found to be missing\n";
-print "[$longlines] line(s) were found to be long (>60 chars)\n";
-print "[$errorline] line(s) were found to have formatting errors\n";
-print "The specific details of the test have been saved in langcheck.log\n";
-
-if ($missinglines) { # If missing lines exist
-print "----------------------------------\n";
-print "Missing line(s) have been detected in this test, would you like to fix the file?\n";
-print "This automatically inserts values from the control file ($sourcefile) for the missing values\n";
-print "y/N? (Default: No) ";
-
-my $input = <STDIN>; # Ask if the file should be fixed
-if ((substr($input,0,1) eq "y") || (substr($input,0,1) eq "Y")) { # If Yes...
-
-open (FIX, ">> $testagainst"); # Open the file and append changes
-
-foreach $sourcearray (@sourcearray) { # For each key stored in the source array
- my $_key=$_; # Store key from source array in $_key
-
- if (!grep(/^$sourcearray/,%testhash)) { # If the key is not found in the testhash associative array
- print FIX "$sourcearray\n$sourcehash{$sourcearray}"; # Add the line(s) to the language file
- $fixedlines++; # Increase the fixed line count
- }
-}
-
-close (FIX); # Close file after fixing
-
-print "Fixing Compete. [$fixedlines] line(s) fixed.\n";
-exit; # And Exit!
-}
- # Otherwise, quit without fixing
-print "Exiting. The language file has NOT been fixed.\n";
-
-}
diff --git a/src/bin/mydbgen b/src/bin/mydbgen
deleted file mode 100755
index 12bee8063..000000000
--- a/src/bin/mydbgen
+++ /dev/null
@@ -1,148 +0,0 @@
-#!/bin/sh
-#
-
-# Location of the .sql file with the schema
-DBSQL="tables.sql"
-
-# Schema Version
-SVER="2"
-
-# Local Version, defaults to 0
-LVER="0"
-
-TFILE="/tmp/.anopedb.$$"
-
-if [ "`eval echo -n 'a'`" = "-n a" ] ; then
- c="\c"
-else
- n="-n"
-fi
-
-DBFILE=../data/$DBSQL
-
-if [ ! -f "./$DBFILE" ] ; then
- echo "Error: Required file $DBSQL was not found!";
- exit
-fi
-
-echo ""
-echo "This script will guide you through the process of configuring your Anope"
-echo "installation to make use of MySQL support. This script must be used for both"
-echo "new installs as well as for upgrading for users who have a previous version"
-echo "of Anope installed"
-
-while [ -z "$SQLHOST" ] ; do
- echo ""
- echo "What is the hostname of your MySQL server?"
- echo $n "-> $c"
- read cc
- if [ ! -z "$cc" ] ; then
- SQLHOST=$cc
- fi
-done
-
-while [ -z "$SQLUSER" ] ; do
- echo ""
- echo "What is your MySQL username?"
- echo $n "-> $c"
- read cc
- if [ ! -z "$cc" ] ; then
- SQLUSER=$cc
- fi
-done
-
-OLD_TTY=`stty -g`
-
-echo ""
-echo "What is your MySQL password?"
-echo $n "-> $c"
-stty -echo echonl
-read cc
-SQLPASS_PREFIX=""
-if [ ! -z "$cc" ] ; then
- SQLPASS_PREFIX="-p"
- SQLPASS=$cc
-fi
-stty $OLD_TTY
-
-mysqlshow -h$SQLHOST -u$SQLUSER $SQLPASS_PREFIX$SQLPASS >/dev/null 2>&1
-if test "$?" = "1" ; then
- echo "Error: Unable to login, verify your login/password and hostname"
- exit
-fi
-
-while [ -z "$SQLDB" ] ; do
- echo ""
- echo "What is the name of the Anope SQL database?"
- echo $n "-> $c"
- read cc
- if [ ! -z "$cc" ] ; then
- SQLDB=$cc
- fi
-done
-
-MYSQLDUMP="mysqldump -h$SQLHOST -u$SQLUSER $SQLPASS_PREFIX$SQLPASS $SQLDB"
-MYSQLSHOW="mysqlshow -h$SQLHOST -u$SQLUSER $SQLPASS_PREFIX$SQLPASS $SQLDB"
-MYSQL="mysql -h$SQLHOST -u$SQLUSER $SQLPASS_PREFIX$SQLPASS $SQLDB"
-
-echo ""
-
-$MYSQLSHOW | grep -q $SQLDB
-if test "$?" = "1" ; then
- echo -n "Unable to find databse, creating... "
- mysql -h$SQLHOST -u$SQLUSER $SQLPASS_PREFIX$SQLPASS -Bs -e "create database $SQLDB" >/dev/null 2>&1
- if test "$?" = "0" ; then
- echo "done!"
- else
- echo "failed!"
- FAILED="$FAILED 'database creation'"
- fi
-fi
-
-$MYSQL -Bs -e "show tables like 'anope_os_core'" | grep -q anope_os_core
-if test "$?" = "1" ; then
- echo -n "Unable to find Anope schema, creating... "
- $MYSQL < $DBFILE
- if test "$?" = "0" ; then
- echo "done!"
- else
- echo "failed!"
- FAILED="$FAILED 'schema creation'"
- fi
-else
- echo "done!"
-fi
-
-echo ""
-
-if [ $LVER -ne $SVER ]; then
-echo -n "Inserting initial version number... "
-$MYSQL -Bs -e "delete from anope_info"
-echo "INSERT INTO anope_info (version, date) VALUES ($SVER, now())" > $TFILE
-$MYSQL < $TFILE >/dev/null 2>&1
-if test "$?" = "0" ; then
- echo "done!"
-else
- echo "failed!"
- FAILED="$FAILED 'version insert'"
-fi
-fi
-
-rm -f $TFILE
-if test "x$FAILED" = "x" ; then
- # Try to find out more about this installation
- SQLPORT="$(mysql_config --port 2> /dev/null)"
- if test "$SQLPORT" = "0" ; then
- SQLPORT=3306
- fi
- echo ""
- echo "Your MySQL setup is complete and your Anope schema is up to date. Make"
- echo "sure you configure MySQL on your services.conf file prior to launching"
- echo "Anope with MySQL support."
- echo ""
-else
- echo "The following operations failed:"
- echo "$FAILED"
-fi
-
-exit
diff --git a/src/bots.cpp b/src/bots.cpp
index 390fc6a69..928dcb2c1 100644
--- a/src/bots.cpp
+++ b/src/bots.cpp
@@ -64,6 +64,29 @@ BotInfo::~BotInfo()
BotListByUID.erase(this->uid);
}
+SerializableBase::serialized_data BotInfo::serialize()
+{
+ SerializableBase::serialized_data data;
+
+ data["nick"] << this->nick;
+ data["user"] << this->ident;
+ data["host"] << this->host;
+ data["realname"] << this->realname;
+ data["created"] << this->created;
+ data["chancount"] << this->chancount;
+
+ return data;
+}
+
+void BotInfo::unserialize(SerializableBase::serialized_data &data)
+{
+ BotInfo *bi = findbot(data["nick"].astr());
+ if (bi == NULL)
+ bi = new BotInfo(data["nick"].astr(), data["user"].astr(), data["host"].astr(), data["realname"].astr());
+ data["created"] >> bi->created;
+ data["chancount"] >> bi->chancount;
+}
+
void BotInfo::GenerateUID()
{
if (!this->uid.empty())
diff --git a/src/hostserv.cpp b/src/hostserv.cpp
index d3000d552..55cbaff29 100644
--- a/src/hostserv.cpp
+++ b/src/hostserv.cpp
@@ -72,7 +72,7 @@ const Anope::string &HostInfo::GetCreator() const
/** Retrieve when the vhost was crated
* @return the time it was created
*/
-const time_t HostInfo::GetTime() const
+time_t HostInfo::GetTime() const
{
return Time;
}
diff --git a/src/init.cpp b/src/init.cpp
index beb34aafb..c4cd62b07 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -241,6 +241,8 @@ void Init(int ac, char **av)
#endif
if (set_group() < 0)
throw FatalException("set_group() fail");
+
+ RegisterTypes();
/* Parse command line arguments */
ParseCommandLineArguments(ac, av);
@@ -442,8 +444,6 @@ void Init(int ac, char **av)
EventReturn MOD_RESULT;
FOREACH_RESULT(I_OnLoadDatabase, OnLoadDatabase());
Log() << "Databases loaded";
-
- FOREACH_MOD(I_OnPostLoadDatabases, OnPostLoadDatabases());
}
/*************************************************************************/
diff --git a/src/main.cpp b/src/main.cpp
index aab9edce5..5d3b5e3de 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -375,6 +375,7 @@ int main(int ac, char **av, char **envp)
ModuleManager::UnloadModule(m, NULL);
ModuleManager::CleanupRuntimeDirectory();
+ serialized_items.clear();
#ifdef _WIN32
OnShutdown();
diff --git a/src/memoserv.cpp b/src/memoserv.cpp
index 21940aca1..faaca180b 100644
--- a/src/memoserv.cpp
+++ b/src/memoserv.cpp
@@ -11,9 +11,41 @@
#include "services.h"
#include "modules.h"
+#include "memoserv.h"
Memo::Memo() : Flags<MemoFlag>(MemoFlagStrings) { }
+SerializableBase::serialized_data Memo::serialize()
+{
+ serialized_data data;
+
+ data["owner"] << this->owner;
+ data["time"] << this->time;
+ data["sender"] << this->sender;
+ data["text"] << this->text;
+
+ return data;
+}
+
+void Memo::unserialize(SerializableBase::serialized_data &data)
+{
+ if (!memoserv)
+ return;
+
+ bool ischan;
+ MemoInfo *mi = memoserv->GetMemoInfo(data["owner"].astr(), ischan);
+ if (!mi)
+ return;
+
+ Memo *m = new Memo();
+ data["owner"] >> m->owner;
+ data["time"] >> m->time;
+ data["sender"] >> m->sender;
+ data["text"] >> m->text;
+
+ mi->memos.push_back(m);
+}
+
unsigned MemoInfo::GetIndex(Memo *m) const
{
for (unsigned i = 0; i < this->memos.size(); ++i)
diff --git a/src/misc.cpp b/src/misc.cpp
index 5e41d42b7..0090dfa3b 100644
--- a/src/misc.cpp
+++ b/src/misc.cpp
@@ -14,6 +14,19 @@
#include "version.h"
#include "modules.h"
+ExtensibleItem::ExtensibleItem()
+{
+}
+
+ExtensibleItem::~ExtensibleItem()
+{
+}
+
+void ExtensibleItem::OnDelete()
+{
+ delete this;
+}
+
struct arc4_stream
{
uint8 i;
diff --git a/src/modes.cpp b/src/modes.cpp
index 4fc5d6483..e6f3a27a1 100644
--- a/src/modes.cpp
+++ b/src/modes.cpp
@@ -54,7 +54,7 @@ void SetDefaultMLock(ServerConfig *config)
if (cm->Type != MODE_LIST) // Only MODE_LIST can have duplicates
def_mode_locks.erase(cm->Name);
- def_mode_locks.insert(std::make_pair(cm->Name, ModeLock(adding == 1, cm->Name, param)));
+ def_mode_locks.insert(std::make_pair(cm->Name, ModeLock(NULL, adding == 1, cm->Name, param)));
}
}
}
diff --git a/src/nickalias.cpp b/src/nickalias.cpp
index f5269cc9f..7b07a4af3 100644
--- a/src/nickalias.cpp
+++ b/src/nickalias.cpp
@@ -102,3 +102,47 @@ void NickAlias::OnCancel(User *)
new NickServRelease(this, Config->NSReleaseTimeout);
}
}
+
+SerializableBase::serialized_data NickAlias::serialize()
+{
+ serialized_data data;
+
+ data["nick"].setKey().setMax(Config->NickLen) << this->nick;
+ data["last_quit"] << this->last_quit;
+ data["last_realname"] << this->last_realname;
+ data["last_usermask"] << this->last_usermask;
+ data["last_realhost"] << this->last_realhost;
+ data["time_registered"].setType(Serialize::DT_INT) << this->time_registered;
+ data["last_seen"].setType(Serialize::DT_INT) << this->last_seen;
+ data["nc"] << this->nc->display;
+
+ if (this->hostinfo.HasVhost())
+ {
+ data["vhost_ident"] << this->hostinfo.GetIdent();
+ data["vhost_host"] << this->hostinfo.GetHost();
+ data["vhost_creator"] << this->hostinfo.GetCreator();
+ data["vhost_time"] << this->hostinfo.GetTime();
+ }
+
+ return data;
+}
+
+void NickAlias::unserialize(SerializableBase::serialized_data &data)
+{
+ NickCore *core = findcore(data["nc"].astr());
+ if (core == NULL)
+ return;
+
+ NickAlias *na = new NickAlias(data["nick"].astr(), core);
+ data["last_quit"] >> na->last_quit;
+ data["last_realname"] >> na->last_realname;
+ data["last_usermask"] >> na->last_usermask;
+ data["last_realhost"] >> na->last_realhost;
+ data["time_registered"] >> na->time_registered;
+ data["last_seen"] >> na->last_seen;
+
+ time_t vhost_time;
+ data["vhost_time"] >> vhost_time;
+ na->hostinfo.SetVhost(data["vhost_ident"].astr(), data["vhost_host"].astr(), data["vhost_creator"].astr(), vhost_time);
+}
+
diff --git a/src/nickcore.cpp b/src/nickcore.cpp
index a33382f06..968e4d0e9 100644
--- a/src/nickcore.cpp
+++ b/src/nickcore.cpp
@@ -45,6 +45,57 @@ NickCore::~NickCore()
}
}
+SerializableBase::serialized_data NickCore::serialize()
+{
+ serialized_data data;
+
+ data["display"].setKey().setMax(Config->NickLen) << this->display;
+ data["pass"] << this->pass;
+ data["email"] << this->email;
+ data["greet"] << this->greet;
+ data["language"] << this->language;
+ for (unsigned i = 0; i < this->access.size(); ++i)
+ data["access"] << this->access[i] << " ";
+ for (unsigned i = 0; i < this->cert.size(); ++i)
+ data["cert"] << this->cert[i] << " ";
+ data["memomax"] << this->memos.memomax;
+ for (unsigned i = 0; i < this->memos.ignores.size(); ++i)
+ data["memoignores"] << this->memos.ignores[i] << " ";
+
+ return data;
+}
+
+void NickCore::unserialize(serialized_data &data)
+{
+ NickCore *nc = new NickCore(data["display"].astr());
+ data["pass"] >> nc->pass;
+ data["email"] >> nc->email;
+ data["greet"] >> nc->greet;
+ data["language"] >> nc->language;
+ {
+ Anope::string buf;
+ data["access"] >> buf;
+ spacesepstream sep(buf);
+ while (sep.GetToken(buf))
+ nc->access.push_back(buf);
+ }
+ {
+ Anope::string buf;
+ data["cert"] >> buf;
+ spacesepstream sep(buf);
+ while (sep.GetToken(buf))
+ nc->access.push_back(buf);
+ }
+ data["memomax"] >> nc->memos.memomax;
+ {
+ Anope::string buf;
+ data["memoignores"] >> buf;
+ spacesepstream sep(buf);
+ while (sep.GetToken(buf))
+ nc->memos.ignores.push_back(buf);
+ }
+}
+
bool NickCore::IsServicesOper() const
{
return this->o != NULL;
diff --git a/src/operserv.cpp b/src/operserv.cpp
index b17f9e0ad..b0db3aee1 100644
--- a/src/operserv.cpp
+++ b/src/operserv.cpp
@@ -16,6 +16,10 @@
/* List of XLine managers we check users against in XLineManager::CheckAll */
std::list<XLineManager *> XLineManager::XLineManagers;
+XLine::XLine()
+{
+}
+
XLine::XLine(const Anope::string &mask, const Anope::string &reason) : Mask(mask), Created(0), Expires(0), Reason(reason)
{
}
@@ -66,6 +70,37 @@ sockaddrs XLine::GetIP() const
return addr;
}
+SerializableBase::serialized_data XLine::serialize()
+{
+ serialized_data data;
+
+ data["mask"] << this->Mask;
+ data["by"] << this->By;
+ data["created"] << this->Created;
+ data["expires"] << this->Expires;
+ data["reason"] << this->Reason;
+ data["manager"] << this->Manager;
+
+ return data;
+}
+
+void XLine::unserialize(SerializableBase::serialized_data &data)
+{
+ service_reference<XLineManager> xlm(data["manager"].astr());
+ if (!xlm)
+ return;
+
+ XLine *xl = new XLine();
+
+ data["mask"] >> xl->Mask;
+ data["by"] >> xl->By;
+ data["created"] >> xl->Created;
+ data["expires"] >> xl->Expires;
+ data["reason"] >> xl->Reason;
+
+ xlm->AddXLine(xl);
+}
+
/** Constructor
*/
XLineManager::XLineManager(Module *creator, const Anope::string &xname, char t) : Service<XLineManager>(creator, xname), type(t)
@@ -159,6 +194,7 @@ const std::vector<XLine *> &XLineManager::GetList() const
*/
void XLineManager::AddXLine(XLine *x)
{
+ x->Manager = this->name;
this->XLines.push_back(x);
}
@@ -199,8 +235,9 @@ XLine *XLineManager::GetEntry(unsigned index)
*/
void XLineManager::Clear()
{
- while (!this->XLines.empty())
- this->DelXLine(this->XLines.front());
+ for (unsigned i = 0; i < this->XLines.size(); ++i)
+ delete this->XLines[i];
+ this->XLines.clear();
}
/** Add an entry to this XLine Manager
diff --git a/src/regchannel.cpp b/src/regchannel.cpp
index 7eceb5942..4c90fa458 100644
--- a/src/regchannel.cpp
+++ b/src/regchannel.cpp
@@ -12,6 +12,124 @@
#include "services.h"
#include "modules.h"
+SerializableBase::serialized_data BadWord::serialize()
+{
+ serialized_data data;
+
+ data["word"] << this->word;
+ data["type"].setType(Serialize::DT_INT) << this->type;
+
+ return data;
+}
+
+void BadWord::unserialize(SerializableBase::serialized_data &data)
+{
+ BadWord *bw = new BadWord();
+ data["word"] >> bw->word;
+ unsigned int n;
+ data["type"] >> n;
+ bw->type = static_cast<BadWordType>(n);
+}
+
+SerializableBase::serialized_data AutoKick::serialize()
+{
+ serialized_data data;
+
+ if (this->HasFlag(AK_ISNICK) && this->nc)
+ data["nc"] << this->nc->display;
+ else
+ data["mask"] << this->mask;
+ data["reason"] << this->reason;
+ data["creator"] << this->creator;
+ data["addtime"].setType(Serialize::DT_INT) << this->addtime;
+ data["last_used"].setType(Serialize::DT_INT) << this->last_used;
+
+ return data;
+}
+
+void AutoKick::unserialize(SerializableBase::serialized_data &data)
+{
+ AutoKick *ak = new AutoKick();
+
+ data["mask"] >> ak->mask;
+ ak->nc = findcore(data["nc"].astr());
+ data["reason"] >> ak->reason;
+ data["creator"] >> ak->creator;
+ data["addtime"] >> ak->addtime;
+ data["last_used"] >> ak->last_used;
+}
+
+SerializableBase::serialized_data ModeLock::serialize()
+{
+ serialized_data data;
+
+ if (this->ci == NULL)
+ return data;
+
+ data["ci"] << this->ci->name;
+ data["set"] << this->set;
+ data["name"] << ChannelModeNameStrings[this->name];
+ data["param"] << this->param;
+ data["setter"] << this->setter;
+ data["created"].setType(Serialize::DT_INT) << this->created;
+
+ return data;
+}
+
+void ModeLock::unserialize(SerializableBase::serialized_data &data)
+{
+ ChannelInfo *ci = cs_findchan(data["ci"].astr());
+ if (ci == NULL)
+ return;
+
+ ModeLock ml;
+
+ ml.ci = ci;
+
+ data["set"] >> ml.set;
+ Anope::string n;
+ data["name"] >> n;
+ for (unsigned i = 0; !ChannelModeNameStrings[i].empty(); ++i)
+ if (n == ChannelModeNameStrings[i])
+ {
+ ml.name = static_cast<ChannelModeName>(i);
+ break;
+ }
+ data["param"] >> ml.param;
+ data["setter"] >> ml.setter;
+ data["created"] >> ml.created;
+
+ ci->mode_locks.insert(std::make_pair(ml.name, ml));
+}
+
+SerializableBase::serialized_data LogSetting::serialize()
+{
+ serialized_data data;
+
+ data["service_name"] << service_name;
+ data["command_service"] << command_service;
+ data["command_name"] << command_name;
+ data["method"] << method;
+ data["extra"] << extra;
+ data["creator"] << creator;
+ data["created"].setType(Serialize::DT_INT) << created;
+
+ return data;
+}
+
+void LogSetting::unserialize(serialized_data &data)
+{
+ LogSetting ls;
+
+ data["service_name"] >> ls.service_name;
+ data["command_service"] >> ls.command_service;
+ data["command_name"] >> ls.command_name;
+ data["method"] >> ls.method;
+ data["extra"] >> ls.extra;
+