summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2010-08-15 01:45:38 -0400
committerAdam <Adam@anope.org>2010-08-15 01:45:38 -0400
commita950ed8cabfeca55c909f02412b1788bd386dcff (patch)
treecfa9a16c2385176490ea849f6a4041ee9456c8eb
parent4d0a1aaabd861bb7cd1e378bd1e600af1d34d5d2 (diff)
Rewrote the MySQL API to use threads. This acts similar to before, but is faster. Removed db_mysql_execute for now.
-rw-r--r--CMakeLists.txt1
-rw-r--r--data/CMakeLists.txt2
-rw-r--r--data/example.conf4
-rw-r--r--data/mysql/tables.sql354
-rw-r--r--data/tables.sql386
-rw-r--r--docs/MYSQL27
-rw-r--r--include/modules.h119
-rw-r--r--include/services.h1
-rw-r--r--include/sockets.h24
-rw-r--r--modules/CMakeLists.txt1
-rw-r--r--modules/extra/db_mysql.cpp1550
-rw-r--r--modules/extra/m_mysql.cpp414
-rw-r--r--modules/extra/mysql/db_mysql.h212
-rw-r--r--modules/extra/mysql/db_mysql_execute.cpp159
-rw-r--r--modules/extra/mysql/db_mysql_read.cpp618
-rw-r--r--modules/extra/mysql/db_mysql_write.cpp1040
-rw-r--r--modules/extra/sql.h82
-rw-r--r--modules/socketengines/m_socketengine_epoll.cpp8
-rw-r--r--modules/socketengines/m_socketengine_select.cpp2
-rw-r--r--src/CMakeLists.txt14
-rwxr-xr-xsrc/bin/mydbgen5
-rw-r--r--src/module.cpp11
-rw-r--r--src/modulemanager.cpp34
-rw-r--r--src/modules.cpp16
-rw-r--r--src/socketengines/socketengine_eventfd.cpp47
-rw-r--r--src/socketengines/socketengine_pipe.cpp50
-rw-r--r--src/socketengines/socketengine_win32.cpp76
-rw-r--r--src/sockets.cpp7
28 files changed, 2805 insertions, 2459 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 64d533dcf..30810405b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -330,6 +330,7 @@ check_function_exists(strlcat HAVE_STRLCAT)
check_function_exists(strlcpy HAVE_STRLCPY)
check_function_exists(umask HAVE_UMASK)
check_function_exists(backtrace HAVE_BACKTRACE)
+check_function_exists(eventfd HAVE_EVENTFD)
# Check for the existance of the following types
check_type_size(uint8_t UINT8_T)
diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt
index 63d55d4cd..461ea287a 100644
--- a/data/CMakeLists.txt
+++ b/data/CMakeLists.txt
@@ -1,6 +1,6 @@
# Only install example.chk and example.conf from this directory
# NOTE: I would've had this just find all files in the directory, but that would include files not needed (like this file)
-set(DATA example.chk example.conf tables.sql)
+set(DATA example.chk example.conf mysql/tables.sql)
install(FILES ${DATA}
DESTINATION data
)
diff --git a/data/example.conf b/data/example.conf
index 1a9ee7ff3..c580399fb 100644
--- a/data/example.conf
+++ b/data/example.conf
@@ -292,9 +292,7 @@ options
*
* Supported:
* - db_plain
- * - db_mysql_write
- * - db_mysql_read
- * - db_mysql_execute
+ * - db_mysql
*/
database = "db_plain"
diff --git a/data/mysql/tables.sql b/data/mysql/tables.sql
new file mode 100644
index 000000000..6b9c41b89
--- /dev/null
+++ b/data/mysql/tables.sql
@@ -0,0 +1,354 @@
+SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
+
+--
+-- Table structure for table `anope_bs_badwords`
+--
+
+DROP TABLE IF EXISTS `anope_bs_badwords`;
+CREATE TABLE IF NOT EXISTS `anope_bs_badwords` (
+ `channel` varchar(255) NOT NULL default '',
+ `word` varchar(255) NOT NULL,
+ `type` varchar(50) NOT NULL,
+ UNIQUE KEY `channel` (`channel`,`word`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `anope_bs_core`
+--
+
+DROP TABLE IF EXISTS `anope_bs_core`;
+CREATE TABLE IF NOT EXISTS `anope_bs_core` (
+ `nick` varchar(255) NOT NULL default '',
+ `user` varchar(255) NOT NULL default '',
+ `host` text NOT NULL,
+ `rname` text NOT NULL,
+ `flags` text NOT NULL,
+ `created` int(10) unsigned NOT NULL default '0',
+ `chancount` int(11) NOT NULL default '0',
+ PRIMARY KEY (`nick`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `anope_bs_info_metadata`
+--
+
+DROP TABLE IF EXISTS `anope_bs_info_metadata`;
+CREATE TABLE IF NOT EXISTS `anope_bs_info_metadata` (
+ `botname` varchar(255) NOT NULL default '',
+ `name` varchar(255) NOT NULL default '',
+ `value` text NOT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `anope_cs_access`
+--
+
+DROP TABLE IF EXISTS `anope_cs_access`;
+CREATE TABLE IF NOT EXISTS `anope_cs_access` (
+ `level` int(11) NOT NULL default '0',
+ `display` varchar(255) NOT NULL default '',
+ `channel` varchar(255) NOT NULL default '',
+ `last_seen` int(10) unsigned NOT NULL default '0',
+ `creator` varchar(255) NOT NULL default '',
+ UNIQUE KEY `channel` (`channel`,`display`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `anope_cs_akick`
+--
+
+DROP TABLE IF EXISTS `anope_cs_akick`;
+CREATE TABLE IF NOT EXISTS `anope_cs_akick` (
+ `channel` varchar(255) NOT NULL default '',
+ `flags` varchar(255) NOT NULL default '',
+ `mask` varchar(255) NOT NULL default '',
+ `reason` text NOT NULL,
+ `creator` varchar(255) NOT NULL default '',
+ `created` int(10) unsigned NOT NULL default '0',
+ `last_used` int(10) unsigned NOT NULL default '0',
+ UNIQUE KEY `channel` (`channel`,`mask`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `anope_cs_info`
+--
+
+DROP TABLE IF EXISTS `anope_cs_info`;
+CREATE TABLE IF NOT EXISTS `anope_cs_info` (
+ `name` varchar(255) NOT NULL default '',
+ `founder` text NOT NULL,
+ `successor` text NOT NULL,
+ `descr` text NOT NULL,
+ `time_registered` int(10) unsigned NOT NULL default '0',
+ `last_used` int(10) unsigned NOT NULL default '0',
+ `last_topic` text NOT NULL,
+ `last_topic_setter` text NOT NULL,
+ `last_topic_time` int(10) unsigned NOT NULL default '0',
+ `flags` text NOT NULL,
+ `forbidby` text NOT NULL,
+ `forbidreason` text NOT NULL,
+ `bantype` smallint(6) NOT NULL default '0',
+ `mlock_on` text NOT NULL,
+ `mlock_off` text NOT NULL,
+ `mlock_params` text NOT NULL,
+ `entry_message` text NOT NULL,
+ `memomax` smallint(5) unsigned NOT NULL default '0',
+ `botnick` varchar(255) NOT NULL default '',
+ `botflags` text NOT NULL,
+ `capsmin` smallint(6) NOT NULL default '0',
+ `capspercent` smallint(6) NOT NULL default '0',
+ `floodlines` smallint(6) NOT NULL default '0',
+ `floodsecs` smallint(6) NOT NULL default '0',
+ `repeattimes` smallint(6) NOT NULL default '0',
+ PRIMARY KEY (`name`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `anope_cs_info_metadata`
+--
+
+DROP TABLE IF EXISTS `anope_cs_info_metadata`;
+CREATE TABLE IF NOT EXISTS `anope_cs_info_metadata` (
+ `channel` varchar(255) NOT NULL default '',
+ `name` varchar(255) NOT NULL default '',
+ `value` text NOT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `anope_cs_levels`
+--
+
+DROP TABLE IF EXISTS `anope_cs_levels`;
+CREATE TABLE IF NOT EXISTS `anope_cs_levels` (
+ `channel` varchar(255) NOT NULL default '',
+ `position` int(11) NOT NULL default '0',
+ `level` int(11) NOT NULL default '0',
+ UNIQUE KEY `channel` (`channel`,`position`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `anope_cs_ttb`
+--
+
+DROP TABLE IF EXISTS `anope_cs_ttb`;
+CREATE TABLE IF NOT EXISTS `anope_cs_ttb` (
+ `channel` varchar(255) NOT NULL default '',
+ `ttb_id` int(11) NOT NULL default '0',
+ `value` int(11) NOT NULL default '0',
+ UNIQUE KEY `channel` (`channel`,`ttb_id`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `anope_extra`
+--
+
+DROP TABLE IF EXISTS `anope_extra`;
+CREATE TABLE IF NOT EXISTS `anope_extra` (
+ `data` text NOT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `anope_info`
+--
+
+DROP TABLE IF EXISTS `anope_info`;
+CREATE TABLE IF NOT EXISTS `anope_info` (
+ `version` int(11) default NULL,
+ `date` datetime default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `anope_ms_info`
+--
+
+DROP TABLE IF EXISTS `anope_ms_info`;
+CREATE TABLE IF NOT EXISTS `anope_ms_info` (
+ `receiver` varchar(255) NOT NULL,
+ `number` int(11) NOT NULL default '0',
+ `flags` int(11) NOT NULL default '0',
+ `time` int(10) unsigned NOT NULL default '0',
+ `sender` text NOT NULL,
+ `text` blob NOT NULL,
+ `serv` enum('NICK','CHAN') NOT NULL default 'NICK'
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `anope_ns_access`
+--
+
+DROP TABLE IF EXISTS `anope_ns_access`;
+CREATE TABLE IF NOT EXISTS `anope_ns_access` (
+ `display` varchar(255) NOT NULL default '',
+ `access` varchar(160) NOT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `anope_ns_alias`
+--
+
+DROP TABLE IF EXISTS `anope_ns_alias`;
+CREATE TABLE IF NOT EXISTS `anope_ns_alias` (
+ `nick` varchar(255) NOT NULL default '',
+ `last_quit` text NOT NULL,
+ `last_realname` text NOT NULL,
+ `last_usermask` text NOT NULL,
+ `time_registered` int(10) unsigned NOT NULL default '0',
+ `last_seen` int(10) unsigned NOT NULL default '0',
+ `flags` text NOT NULL,
+ `display` varchar(255) NOT NULL default '',
+ PRIMARY KEY (`nick`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `anope_ns_alias_metadata`
+--
+
+DROP TABLE IF EXISTS `anope_ns_alias_metadata`;
+CREATE TABLE IF NOT EXISTS `anope_ns_alias_metadata` (
+ `nick` varchar(255) NOT NULL default '',
+ `name` varchar(255) NOT NULL default '',
+ `value` text NOT NULL,
+ PRIMARY KEY (`name`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `anope_ns_core`
+--
+
+DROP TABLE IF EXISTS `anope_ns_core`;
+CREATE TABLE IF NOT EXISTS `anope_ns_core` (
+ `display` varchar(255) NOT NULL default '',
+ `pass` text NOT NULL,
+ `email` text NOT NULL,
+ `greet` text NOT NULL,
+ `flags` text NOT NULL,
+ `language` smallint(5) unsigned NOT NULL default '0',
+ `channelcount` smallint(5) unsigned NOT NULL default '0',
+ `memomax` smallint(5) unsigned NOT NULL default '0',
+ PRIMARY KEY (`display`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `anope_ns_core_metadata`
+--
+
+DROP TABLE IF EXISTS `anope_ns_core_metadata`;
+CREATE TABLE IF NOT EXISTS `anope_ns_core_metadata` (
+ `nick` varchar(255) NOT NULL default '',
+ `name` varchar(255) NOT NULL default '',
+ `value` text NOT NULL,
+ PRIMARY KEY (`name`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `anope_ns_request`
+--
+
+DROP TABLE IF EXISTS `anope_ns_request`;
+CREATE TABLE IF NOT EXISTS `anope_ns_request` (
+ `nick` varchar(255) NOT NULL default '',
+ `passcode` text NOT NULL,
+ `password` text NOT NULL,
+ `email` text NOT NULL,
+ `requested` int(10) unsigned NOT NULL default '0',
+ PRIMARY KEY (`nick`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `anope_os_akills`
+--
+
+DROP TABLE IF EXISTS `anope_os_akills`;
+CREATE TABLE IF NOT EXISTS `anope_os_akills` (
+ `user` varchar(255) NOT NULL,
+ `host` varchar(255) NOT NULL,
+ `xby` text NOT NULL,
+ `reason` text NOT NULL,
+ `seton` int(10) unsigned NOT NULL default '0',
+ `expire` int(10) unsigned NOT NULL default '0'
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `anope_os_core`
+--
+
+DROP TABLE IF EXISTS `anope_os_core`;
+CREATE TABLE IF NOT EXISTS `anope_os_core` (
+ `maxusercnt` int(11) NOT NULL default '0',
+ `maxusertime` int(10) unsigned NOT NULL default '0',
+ `akills_count` int(11) NOT NULL default '0',
+ `snlines_count` int(11) NOT NULL default '0',
+ `sqlines_count` int(11) NOT NULL default '0',
+ `szlines_count` int(11) NOT NULL default '0'
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `anope_os_exceptions`
+--
+
+DROP TABLE IF EXISTS `anope_os_exceptions`;
+CREATE TABLE IF NOT EXISTS `anope_os_exceptions` (
+ `mask` varchar(255) NOT NULL,
+ `slimit` int(11) NOT NULL default '0',
+ `who` text NOT NULL,
+ `reason` text NOT NULL,
+ `time` int(10) unsigned NOT NULL default '0',
+ `expires` int(10) unsigned NOT NULL default '0'
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `anope_os_xlines`
+--
+
+DROP TABLE IF EXISTS `anope_os_xlines`;
+CREATE TABLE IF NOT EXISTS `anope_os_xlines` (
+ `type` varchar(20) NOT NULL,
+ `mask` varchar(255) NOT NULL,
+ `xby` text NOT NULL,
+ `reason` text NOT NULL,
+ `seton` int(10) unsigned NOT NULL default '0',
+ `expire` int(10) unsigned NOT NULL default '0'
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
diff --git a/data/tables.sql b/data/tables.sql
deleted file mode 100644
index deeef41cc..000000000
--- a/data/tables.sql
+++ /dev/null
@@ -1,386 +0,0 @@
-
--- If you need to create your db, uncomment the following lines.
---
--- CREATE DATABASE anope;
--- USE anope;
-
-
--- --------------------------------------------------------
-
---
--- Table structure for table 'anope_extra'
---
-
-DROP TABLE IF EXISTS anope_extra;
-CREATE TABLE anope_extra (
- data text NOT NULL default ''
-) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
--- --------------------------------------------------------
-
---
--- Table structure for table 'anope_commands'
---
-
-DROP TABLE IF EXISTS anope_commands;
-CREATE TABLE anope_commands (
- nick varchar(255) NOT NULL default '',
- service varchar(255) NOT NULL default '',
- command text NOT NULL default ''
-) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
--- --------------------------------------------------------
-
---
--- Table structure for table 'anope_ns_core'
---
-
-DROP TABLE IF EXISTS anope_ns_core;
-CREATE TABLE anope_ns_core (
- display varchar(255) NOT NULL default '',
- pass text NOT NULL,
- email text NOT NULL default '',
- greet text NOT NULL default '',
- icq int(10) unsigned NOT NULL default '0',
- url text NOT NULL default '',
- flags text NOT NULL default '',
- language smallint(5) unsigned NOT NULL default '0',
- channelcount smallint(5) unsigned NOT NULL default '0',
- memomax smallint(5) unsigned NOT NULL default '0',
- PRIMARY KEY (display)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
---
--- Table structure for table 'anope_ns_core_metadata'
---
-
-DROP TABLE IF EXISTS anope_ns_core_metadata;
-CREATE TABLE anope_ns_core_metadata (
- nick varchar(255) NOT NULL default '',
- name varchar(255) NOT NULL default '',
- value text NOT NULL default '',
- PRIMARY KEY (name)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
--- ---------------------------------------------------------
---
--- Table structure for table 'anope_ns_alias'
---
-
-DROP TABLE IF EXISTS anope_ns_alias;
-CREATE TABLE anope_ns_alias (
- nick varchar(255) NOT NULL default '',
- last_quit text NOT NULL,
- last_realname text NOT NULL,
- last_usermask text NOT NULL,
- time_registered int(10) unsigned NOT NULL default '0',
- last_seen int(10) unsigned NOT NULL default '0',
- flags text NOT NULL default '',
- display varchar(255) NOT NULL default '',
- PRIMARY KEY (nick)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
---
--- Table structure for table 'anope_ns_alias_metadata'
---
-
-DROP TABLE IF EXISTS anope_ns_alias_metadata;
-CREATE TABLE anope_ns_alias_metadata (
- nick varchar(255) NOT NULL default '',
- name varchar(255) NOT NULL default '',
- value text NOT NULL default '',
- PRIMARY KEY (name)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
--- --------------------------------------------------------
-
---
--- Table structure for table 'anope_ns_access'
---
-
-DROP TABLE IF EXISTS anope_ns_access;
-CREATE TABLE anope_ns_access (
- display varchar(255) NOT NULL default '',
- access varchar(160) NOT NULL
-) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
--- ---------------------------------------------------------
-
---
--- Table structure for table 'anope_ns_request'
---
-
-DROP TABLE IF EXISTS anope_ns_request;
-CREATE TABLE anope_ns_request (
- nick varchar(255) NOT NULL default '',
- passcode text NOT NULL,
- password text NOT NULL,
- email text NOT NULL,
- requested int(10) unsigned NOT NULL default '0',
- PRIMARY KEY (nick)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
--- --------------------------------------------------------
-
---
--- Table structure for table 'anope_cs_access'
---
-
-DROP TABLE IF EXISTS anope_cs_access;
-CREATE TABLE anope_cs_access (
- level int(11) NOT NULL default '0',
- display varchar(255) NOT NULL default '',
- channel varchar(255) NOT NULL default '',
- last_seen int(10) unsigned NOT NULL default '0',
- creator varchar(255) NOT NULL default '',
- UNIQUE KEY (channel,display)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
--- --------------------------------------------------------
-
---
--- Table structure for table 'anope_cs_akick'
---
-
-DROP TABLE IF EXISTS anope_cs_akick;
-CREATE TABLE anope_cs_akick (
- channel varchar(255) NOT NULL default '',
- flags varchar(255) NOT NULL default '',
- mask varchar(255) NOT NULL default '',
- reason text NOT NULL default '',
- creator varchar(255) NOT NULL default '',
- created int(10) unsigned NOT NULL default '0',
- last_used int(10) unsigned NOT NULL default '0',
- UNIQUE KEY channel (channel, mask)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
--- --------------------------------------------------------
-
---
--- Table structure for table 'anope_bs_badwords'
---
-
-DROP TABLE IF EXISTS anope_bs_badwords;
-CREATE TABLE anope_bs_badwords (
- channel varchar(255) NOT NULL default '',
- word varchar(255) NOT NULL,
- type varchar(50) NOT NULL,
- UNIQUE KEY channel (channel,word)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
--- --------------------------------------------------------
-
---
--- Table structure for table 'anope_cs_info'
---
-
-DROP TABLE IF EXISTS anope_cs_info;
-CREATE TABLE anope_cs_info (
- name varchar(255) NOT NULL default '',
- founder text NOT NULL,
- successor text NOT NULL,
- descr text NOT NULL,
- url text NOT NULL,
- email text NOT NULL,
- time_registered int(10) unsigned NOT NULL default '0',
- last_used int(10) unsigned NOT NULL default '0',
- last_topic text NOT NULL,
- last_topic_setter text NOT NULL,
- last_topic_time int(10) unsigned NOT NULL default '0',
- flags text NOT NULL default '',
- forbidby text NOT NULL,
- forbidreason text NOT NULL,
- bantype smallint(6) NOT NULL default '0',
- mlock_on text NOT NULL default '',
- mlock_off text NOT NULL default '',
- mlock_params text NOT NULL default '',
- entry_message text NOT NULL,
- memomax smallint(5) unsigned NOT NULL default '0',
- botnick varchar(255) NOT NULL default '',
- botflags text NOT NULL default '',
- capsmin smallint(6) NOT NULL default '0',
- capspercent smallint(6) NOT NULL default '0',
- floodlines smallint(6) NOT NULL default '0',
- floodsecs smallint(6) NOT NULL default '0',
- repeattimes smallint(6) NOT NULL default '0',
- PRIMARY KEY (name)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
--- --------------------------------------------------------
-
---
--- Table structure for table 'anope_cs_info_metadata'
---
-
-DROP TABLE IF EXISTS anope_cs_info_metadata;
-CREATE TABLE anope_cs_info_metadata (
- channel varchar(255) NOT NULL default '',
- name varchar(255) NOT NULL default '',
- value text NOT NULL default ''
-) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
--- --------------------------------------------------------
-
---
--- Table structure for table 'anope_cs_levels'
---
-
-DROP TABLE IF EXISTS anope_cs_levels;
-CREATE TABLE anope_cs_levels (
- channel varchar(255) NOT NULL default '',
- position int(11) NOT NULL default '0',
- level int(11) NOT NULL default '0',
- UNIQUE KEY channel (channel,position)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
--- --------------------------------------------------------
-
---
--- Table structure for table 'anope_cs_ttb'
---
-
-DROP TABLE IF EXISTS anope_cs_ttb;
-CREATE TABLE anope_cs_ttb (
- channel varchar(255) NOT NULL default '',
- ttb_id int(11) NOT NULL default '0',
- value int(11) NOT NULL default '0',
- UNIQUE KEY channel (channel,ttb_id)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
--- --------------------------------------------------------
-
---
--- Table structure for table 'anope_bs_core'
---
-
-DROP TABLE IF EXISTS anope_bs_core;
-CREATE TABLE anope_bs_core (
- nick varchar(255) NOT NULL default '',
- user varchar(255) NOT NULL default '',
- host text NOT NULL default '',
- rname text NOT NULL default '',
- flags text NOT NULL default '',
- created int(10) unsigned NOT NULL default '0',
- chancount int(11) NOT NULL default '0',
- PRIMARY KEY (nick)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
--- --------------------------------------------------------
-
---
--- Table structure for table 'anope_bs_info_metadata'
---
-
-DROP TABLE IF EXISTS anope_bs_info_metadata;
-CREATE TABLE anope_bs_info_metadata (
- botname varchar(255) NOT NULL default '',
- name varchar(255) NOT NULL default '',
- value text NOT NULL default ''
-) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
--- --------------------------------------------------------
-
---
--- Table structure for table 'anope_ms_info'
---
-
-DROP TABLE IF EXISTS anope_ms_info;
-CREATE TABLE anope_ms_info (
- receiver varchar(255) NOT NULL,
- number int(11) NOT NULL default '0',
- flags int(11) NOT NULL default '0',
- time int(10) unsigned NOT NULL default '0',
- sender text NOT NULL,
- text blob NOT NULL,
- serv enum('NICK','CHAN') NOT NULL default 'NICK'
-) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
--- --------------------------------------------------------
-
---
--- Table structure for table 'anope_os_akills'
---
-
-DROP TABLE IF EXISTS anope_os_akills;
-CREATE TABLE anope_os_akills (
- user varchar(255) NOT NULL,
- host varchar(255) NOT NULL,
- xby text NOT NULL,
- reason text NOT NULL,
- seton int(10) unsigned NOT NULL default '0',
- expire int(10) unsigned NOT NULL default '0'
-) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
--- --------------------------------------------------------
-
---
--- Table structure for table 'anope_os_core'
---
-
-DROP TABLE IF EXISTS anope_os_core;
-CREATE TABLE anope_os_core (
- maxusercnt int(11) NOT NULL default '0',
- maxusertime int(10) unsigned NOT NULL default '0',
- akills_count int(11) NOT NULL default '0',
- snlines_count int(11) NOT NULL default '0',
- sqlines_count int(11) NOT NULL default '0',
- szlines_count int(11) NOT NULL default '0'
-) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
--- --------------------------------------------------------
-
---
--- Table structure for table 'anope_os_exceptions'
---
-
-DROP TABLE IF EXISTS anope_os_exceptions;
-CREATE TABLE anope_os_exceptions (
- mask varchar(255) NOT NULL,
- slimit int(11) NOT NULL default '0',
- who text NOT NULL,
- reason text NOT NULL,
- time int(10) unsigned NOT NULL default '0',
- expires int(10) unsigned NOT NULL default '0'
-) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
--- --------------------------------------------------------
-
---
--- Table structure for table 'anope_os_xlines'
---
-
-DROP TABLE IF EXISTS anope_os_xlines;
-CREATE TABLE anope_os_xlines (
- type varchar(20) NOT NULL,
- mask varchar(255) NOT NULL,
- xby text NOT NULL,
- reason text NOT NULL,
- seton int(10) unsigned NOT NULL default '0',
- expire int(10) unsigned NOT NULL default '0'
-) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
--- --------------------------------------------------------
-
---
--- Table structure for table 'anope_metadata'
---
-
-DROP TABLE IF EXISTS anope_metadata;
-CREATE TABLE anope_metadata (
- name varchar(255) NOT NULL default '',
- value text NOT NULL default '',
- PRIMARY KEY (name)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
--- --------------------------------------------------------
-
---
--- Table structure for table 'anope_info'
---
-
-DROP TABLE IF EXISTS anope_info;
-CREATE TABLE anope_info (
- version int(11) default NULL,
- date datetime default NULL
-) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
diff --git a/docs/MYSQL b/docs/MYSQL
deleted file mode 100644
index a72482107..000000000
--- a/docs/MYSQL
+++ /dev/null
@@ -1,27 +0,0 @@
-Anope MySQL Support
--------------------
-
-MySQL support was readded in version 1.9.2 In the form of three modules.
-
-db_mysql_read - Allows you to load your databases from MySQL.
-db_mysql_write - Allows live updating of SQL tables whenever something is executed in Anope.
-db_mysql_execute - Allows executing of Anope commands via SQL.
-
-To execute commands via SQL, you must insert the command into the anope_commands table, an example is as follows:
-
-INSERT INTO `anope_commands` (nick, service, command) VALUES('Adam', 'NickServ', 'REGISTER qwerty Adam@anope.org');
-
-By default, every 60 seconds Anope checks this table for commands to execute. When Anope sees a new command to execute, it checks the following.
-
-If the nick given is -SQLUser, then the command gets executed by a special fake user within Anope called -SQLUser. -SQLUser has every permission and command available, there are no permission checks at all for this user, it can do anything.
-
-If the nick is not -SQLUser, it checks to see if it is a registered nick. If it is, it sees if there are any users online using the NickCore of that nick.
- If there is a user online with that core the command gets executed as if that user executed it, and the reply goes to that user.
- If there isn't a user online with the core, it creates a fake user as the nick given to it, and gives to it the permissions the user would have if they were online and identified.
-If the nick is not registered, it checks to see if there is a user currently on that nick. If there is, it executes the command as that user, and the reply goes to that user.
- If the nick is not registered and no one is using the nick, it creates a fake user of the nick given to it, and gives it regular nonidentified user access.
-
-Currently there is no way to check to see if a command was executed successfully within Anope from SQL (even if there was, the possibly update delay would be a problem).
-
-IMPORTANT: When using db_mysql_write when you already have a database, you need to do an initial import of the data to SQL (as db_mysql_write only updates it when it is changed, it never actually mass-dumps all of your data into SQL). To do this, start Anope and execute /OperServ SQLSYNC.
-
diff --git a/include/modules.h b/include/modules.h
index 627e04383..307c83d87 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -160,9 +160,6 @@ extern CoreExport message_map MessageMap;
class Module;
extern CoreExport std::list<Module *> Modules;
-/*************************************************************************/
-/* Structure for information about a *Serv command. */
-
class Version
{
private:
@@ -1109,11 +1106,16 @@ enum Implementation
I_END
};
+class Service;
/** Used to manage modules.
*/
class CoreExport ModuleManager
{
+ private:
+ /** A map of service providers
+ */
+ static std::map<Anope::string, Service *> ServiceProviders;
public:
/** Event handler hooks.
* This needs to be public to be used by FOREACH_MOD and friends.
@@ -1202,6 +1204,24 @@ class CoreExport ModuleManager
*/
static void UnloadAll(bool unload_proto);
+ /** Register a service
+ * @param s The service
+ * @return true if it was successfully registeed, else false (service name colision)
+ */
+ static bool RegisterService(Service *s);
+
+ /** Unregister a service
+ * @param s The service
+ * @return true if it was unregistered successfully
+ */
+ static bool UnregisterService(Service *s);
+
+ /** Get a service
+ * @param name The service name
+ * @return The services, or NULL
+ */
+ static Service *GetService(const Anope::string &name);
+
private:
/** Call the module_delete function to safely delete the module
* @param m the module to delete
@@ -1229,6 +1249,99 @@ class CallBack : public Timer
}
};
+class Service
+{
+ public:
+ Module *owner;
+ Anope::string name;
+
+ Service(Module *o, const Anope::string &n);
+
+ virtual ~Service();
+};