summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.BANNER4
-rw-r--r--.github/workflows/ci-linux.yml13
-rw-r--r--.github/workflows/ci-windows.yml34
-rw-r--r--CMakeLists.txt335
-rwxr-xr-xConfig62
-rw-r--r--README.md14
-rw-r--r--cmake/Anope.cmake513
-rw-r--r--cmake/FindGettext.cmake26
-rw-r--r--cmake/ReadFile.cmake5
-rw-r--r--data/CMakeLists.txt4
-rw-r--r--data/anope.example.conf (renamed from data/example.conf)157
-rw-r--r--data/chanserv.example.conf4
-rw-r--r--data/example.chk8
-rw-r--r--data/global.example.conf6
-rw-r--r--data/hostserv.example.conf8
-rw-r--r--data/modules.example.conf14
-rw-r--r--data/nickserv.example.conf58
-rw-r--r--data/operserv.example.conf35
-rw-r--r--data/stats.standalone.example.conf77
-rw-r--r--docs/CMakeLists.txt4
-rw-r--r--docs/Changes.conf11
-rw-r--r--docs/DEFCON6
-rw-r--r--docs/EVENTS7
-rw-r--r--docs/INSTALL22
-rw-r--r--docs/INSTALL.fr24
-rw-r--r--docs/LANGUAGE2
-rw-r--r--docs/MODULES4
-rw-r--r--docs/README10
-rw-r--r--docs/REDIS4
-rw-r--r--docs/TOOLS25
-rw-r--r--docs/WIN32.txt4
-rw-r--r--include/CMakeLists.txt48
-rw-r--r--include/access.h8
-rw-r--r--include/account.h15
-rw-r--r--include/anope.h41
-rw-r--r--include/base.h20
-rw-r--r--include/bots.h5
-rw-r--r--include/channels.h5
-rw-r--r--include/commands.h15
-rw-r--r--include/config.h17
-rw-r--r--include/defs.h2
-rw-r--r--include/extensible.h21
-rw-r--r--include/hashcomp.h26
-rw-r--r--include/language.h13
-rw-r--r--include/lists.h11
-rw-r--r--include/logger.h27
-rw-r--r--include/mail.h9
-rw-r--r--include/memo.h9
-rw-r--r--include/messages.h42
-rw-r--r--include/modes.h31
-rw-r--r--include/module.h5
-rw-r--r--include/modules.h38
-rw-r--r--include/modules/bs_badwords.h8
-rw-r--r--include/modules/bs_kick.h6
-rw-r--r--include/modules/cs_entrymsg.h6
-rw-r--r--include/modules/cs_log.h8
-rw-r--r--include/modules/cs_mode.h8
-rw-r--r--include/modules/dns.h25
-rw-r--r--include/modules/encryption.h6
-rw-r--r--include/modules/httpd.h32
-rw-r--r--include/modules/ldap.h13
-rw-r--r--include/modules/ns_cert.h6
-rw-r--r--include/modules/os_forbid.h13
-rw-r--r--include/modules/os_ignore.h8
-rw-r--r--include/modules/os_news.h5
-rw-r--r--include/modules/os_session.h15
-rw-r--r--include/modules/pseudoclients/chanserv.h5
-rw-r--r--include/modules/pseudoclients/global.h5
-rw-r--r--include/modules/pseudoclients/memoserv.h5
-rw-r--r--include/modules/pseudoclients/nickserv.h5
-rw-r--r--include/modules/redis.h8
-rw-r--r--include/modules/sasl.h6
-rw-r--r--include/modules/set_misc.h7
-rw-r--r--include/modules/sql.h40
-rw-r--r--include/modules/ssl.h2
-rw-r--r--include/modules/suspend.h6
-rw-r--r--include/modules/xmlrpc.h6
-rw-r--r--include/opertype.h7
-rw-r--r--include/protocol.h24
-rw-r--r--include/pstdint.h800
-rw-r--r--include/regchannel.h10
-rw-r--r--include/regexpr.h9
-rw-r--r--include/serialize.h27
-rw-r--r--include/servers.h7
-rw-r--r--include/service.h11
-rw-r--r--include/services.h25
-rw-r--r--include/socketengine.h5
-rw-r--r--include/sockets.h66
-rw-r--r--include/sysconf.h.cmake56
-rw-r--r--include/threadengine.h13
-rw-r--r--include/timers.h5
-rw-r--r--include/uplink.h11
-rw-r--r--include/users.h12
-rw-r--r--include/version.cpp10
-rw-r--r--include/xline.h11
-rw-r--r--language/CMakeLists.txt10
-rw-r--r--language/anope.ca_ES.po6
-rw-r--r--language/anope.de_DE.po6
-rw-r--r--language/anope.el_GR.po6
-rw-r--r--language/anope.hu_HU.po6
-rw-r--r--language/anope.pt_PT.po6
-rw-r--r--language/anope.ru_RU.po6
-rw-r--r--language/anope.tr_TR.po6
-rw-r--r--modules/CMakeLists.txt215
-rw-r--r--modules/bs_autoassign.cpp2
-rw-r--r--modules/commands/bs_assign.cpp16
-rw-r--r--modules/commands/bs_badwords.cpp38
-rw-r--r--modules/commands/bs_bot.cpp4
-rw-r--r--modules/commands/bs_botlist.cpp12
-rw-r--r--modules/commands/bs_control.cpp8
-rw-r--r--modules/commands/bs_info.cpp22
-rw-r--r--modules/commands/bs_kick.cpp97
-rw-r--r--modules/commands/bs_set.cpp22
-rw-r--r--modules/commands/cs_access.cpp90
-rw-r--r--modules/commands/cs_akick.cpp33
-rw-r--r--modules/commands/cs_ban.cpp6
-rw-r--r--modules/commands/cs_clone.cpp15
-rw-r--r--modules/commands/cs_drop.cpp4
-rw-r--r--modules/commands/cs_enforce.cpp43
-rw-r--r--modules/commands/cs_entrymsg.cpp20
-rw-r--r--modules/commands/cs_flags.cpp68
-rw-r--r--modules/commands/cs_getkey.cpp4
-rw-r--r--modules/commands/cs_info.cpp8
-rw-r--r--modules/commands/cs_invite.cpp4
-rw-r--r--modules/commands/cs_kick.cpp4
-rw-r--r--modules/commands/cs_list.cpp22
-rw-r--r--modules/commands/cs_log.cpp42
-rw-r--r--modules/commands/cs_mode.cpp139
-rw-r--r--modules/commands/cs_register.cpp4
-rw-r--r--modules/commands/cs_seen.cpp47
-rw-r--r--modules/commands/cs_set.cpp110
-rw-r--r--modules/commands/cs_set_misc.cpp21
-rw-r--r--modules/commands/cs_status.cpp10
-rw-r--r--modules/commands/cs_suspend.cpp25
-rw-r--r--modules/commands/cs_sync.cpp8
-rw-r--r--modules/commands/cs_topic.cpp14
-rw-r--r--modules/commands/cs_unban.cpp18
-rw-r--r--modules/commands/cs_updown.cpp11
-rw-r--r--modules/commands/cs_xop.cpp69
-rw-r--r--modules/commands/gl_global.cpp4
-rw-r--r--modules/commands/greet.cpp18
-rw-r--r--modules/commands/help.cpp20
-rw-r--r--modules/commands/hs_del.cpp12
-rw-r--r--modules/commands/hs_group.cpp17
-rw-r--r--modules/commands/hs_list.cpp12
-rw-r--r--modules/commands/hs_off.cpp4
-rw-r--r--modules/commands/hs_on.cpp4
-rw-r--r--modules/commands/hs_request.cpp41
-rw-r--r--modules/commands/hs_set.cpp11
-rw-r--r--modules/commands/ms_cancel.cpp4
-rw-r--r--modules/commands/ms_check.cpp4
-rw-r--r--modules/commands/ms_del.cpp6
-rw-r--r--modules/commands/ms_ignore.cpp14
-rw-r--r--modules/commands/ms_info.cpp4
-rw-r--r--modules/commands/ms_list.cpp10
-rw-r--r--modules/commands/ms_read.cpp8
-rw-r--r--modules/commands/ms_rsend.cpp4
-rw-r--r--modules/commands/ms_send.cpp4
-rw-r--r--modules/commands/ms_sendall.cpp8
-rw-r--r--modules/commands/ms_set.cpp4
-rw-r--r--modules/commands/ms_staff.cpp8
-rw-r--r--modules/commands/ns_access.cpp6
-rw-r--r--modules/commands/ns_ajoin.cpp23
-rw-r--r--modules/commands/ns_alist.cpp15
-rw-r--r--modules/commands/ns_cert.cpp38
-rw-r--r--modules/commands/ns_drop.cpp4
-rw-r--r--modules/commands/ns_getemail.cpp8
-rw-r--r--modules/commands/ns_getpass.cpp74
-rw-r--r--modules/commands/ns_group.cpp32
-rw-r--r--modules/commands/ns_identify.cpp8
-rw-r--r--modules/commands/ns_info.cpp16
-rw-r--r--modules/commands/ns_list.cpp26
-rw-r--r--modules/commands/ns_logout.cpp6
-rw-r--r--modules/commands/ns_recover.cpp20
-rw-r--r--modules/commands/ns_register.cpp39
-rw-r--r--modules/commands/ns_resetpass.cpp8
-rw-r--r--modules/commands/ns_set.cpp202
-rw-r--r--modules/commands/ns_set_misc.cpp23
-rw-r--r--modules/commands/ns_status.cpp4
-rw-r--r--modules/commands/ns_suspend.cpp22
-rw-r--r--modules/commands/ns_update.cpp4
-rw-r--r--modules/commands/os_akill.cpp22
-rw-r--r--modules/commands/os_chankill.cpp8
-rw-r--r--modules/commands/os_config.cpp33
-rw-r--r--modules/commands/os_defcon.cpp45
-rw-r--r--modules/commands/os_dns.cpp146
-rw-r--r--modules/commands/os_forbid.cpp63
-rw-r--r--modules/commands/os_ignore.cpp32
-rw-r--r--modules/commands/os_info.cpp23
-rw-r--r--modules/commands/os_jupe.cpp8
-rw-r--r--modules/commands/os_kick.cpp4
-rw-r--r--modules/commands/os_kill.cpp4
-rw-r--r--modules/commands/os_list.cpp68
-rw-r--r--modules/commands/os_login.cpp14
-rw-r--r--modules/commands/os_logsearch.cpp10
-rw-r--r--modules/commands/os_mode.cpp17
-rw-r--r--modules/commands/os_modinfo.cpp24
-rw-r--r--modules/commands/os_module.cpp12
-rw-r--r--modules/commands/os_news.cpp54
-rw-r--r--modules/commands/os_noop.cpp10
-rw-r--r--modules/commands/os_oline.cpp78
-rw-r--r--modules/commands/os_oper.cpp48
-rw-r--r--modules/commands/os_reload.cpp10
-rw-r--r--modules/commands/os_session.cpp65
-rw-r--r--modules/commands/os_set.cpp14
-rw-r--r--modules/commands/os_shutdown.cpp20
-rw-r--r--modules/commands/os_stats.cpp24
-rw-r--r--modules/commands/os_svs.cpp12
-rw-r--r--modules/commands/os_sxline.cpp63
-rw-r--r--modules/commands/os_update.cpp8
-rw-r--r--modules/cs_statusupdate.cpp24
-rw-r--r--modules/database/db_flatfile.cpp99
-rw-r--r--modules/database/db_old.cpp30
-rw-r--r--modules/database/db_redis.cpp125
-rw-r--r--modules/database/db_sql.cpp58
-rw-r--r--modules/database/db_sql_live.cpp30
-rw-r--r--modules/encryption/enc_bcrypt.cpp843
-rw-r--r--modules/encryption/enc_md5.cpp17
-rw-r--r--modules/encryption/enc_none.cpp17
-rw-r--r--modules/encryption/enc_old.cpp10
-rw-r--r--modules/encryption/enc_sha1.cpp17
-rw-r--r--modules/encryption/enc_sha256.cpp18
-rw-r--r--modules/extra/m_ldap.cpp59
-rw-r--r--modules/extra/m_ldap_authentication.cpp32
-rw-r--r--modules/extra/m_ldap_oper.cpp16
-rw-r--r--modules/extra/m_mysql.cpp88
-rw-r--r--modules/extra/m_regex_pcre.cpp11
-rw-r--r--modules/extra/m_regex_pcre2.cpp11
-rw-r--r--modules/extra/m_regex_posix.cpp11
-rw-r--r--modules/extra/m_regex_tre.cpp11
-rw-r--r--modules/extra/m_sql_authentication.cpp10
-rw-r--r--modules/extra/m_sql_log.cpp7
-rw-r--r--modules/extra/m_sql_oper.cpp12
-rw-r--r--modules/extra/m_sqlite.cpp67
-rw-r--r--modules/extra/m_ssl_gnutls.cpp38
-rw-r--r--modules/extra/m_ssl_openssl.cpp22
-rw-r--r--modules/extra/stats/cs_fantasy_stats.cpp6
-rw-r--r--modules/extra/stats/cs_fantasy_top.cpp6
-rw-r--r--modules/extra/stats/irc2sql/irc2sql.cpp15
-rw-r--r--modules/extra/stats/irc2sql/irc2sql.h50
-rw-r--r--modules/extra/stats/m_chanstats.cpp42
-rw-r--r--modules/fantasy.cpp8
-rw-r--r--modules/m_dns.cpp104
-rw-r--r--modules/m_dnsbl.cpp30
-rw-r--r--modules/m_helpchan.cpp2
-rw-r--r--modules/m_httpd.cpp65
-rw-r--r--modules/m_proxyscan.cpp48
-rw-r--r--modules/m_redis.cpp98
-rw-r--r--modules/m_rewrite.cpp16
-rw-r--r--modules/m_sasl.cpp50
-rw-r--r--modules/m_xmlrpc.cpp22
-rw-r--r--modules/m_xmlrpc_main.cpp44
-rw-r--r--modules/ns_maxemail.cpp11
-rw-r--r--modules/protocol/bahamut.cpp78
-rw-r--r--modules/protocol/hybrid.cpp126
-rw-r--r--modules/protocol/inspircd.cpp (renamed from modules/protocol/inspircd3.cpp)244
-rw-r--r--modules/protocol/inspircd12.cpp1408
-rw-r--r--modules/protocol/inspircd20.cpp1106
-rw-r--r--modules/protocol/ngircd.cpp72
-rw-r--r--modules/protocol/plexus.cpp76
-rw-r--r--modules/protocol/ratbox.cpp66
-rw-r--r--modules/protocol/solanum.cpp (renamed from modules/protocol/charybdis.cpp)193
-rw-r--r--modules/protocol/unreal.cpp1340
-rw-r--r--modules/protocol/unrealircd.cpp (renamed from modules/protocol/unreal4.cpp)265
-rw-r--r--modules/pseudoclients/botserv.cpp32
-rw-r--r--modules/pseudoclients/chanserv.cpp77
-rw-r--r--modules/pseudoclients/global.cpp18
-rw-r--r--modules/pseudoclients/hostserv.cpp14
-rw-r--r--modules/pseudoclients/memoserv.cpp33
-rw-r--r--modules/pseudoclients/nickserv.cpp98
-rw-r--r--modules/pseudoclients/operserv.cpp56
-rw-r--r--modules/third/language/CMakeLists.txt10
-rw-r--r--modules/webcpanel/pages/chanserv/access.cpp8
-rw-r--r--modules/webcpanel/pages/chanserv/access.h6
-rw-r--r--modules/webcpanel/pages/chanserv/akick.cpp4
-rw-r--r--modules/webcpanel/pages/chanserv/akick.h6
-rw-r--r--modules/webcpanel/pages/chanserv/drop.cpp3
-rw-r--r--modules/webcpanel/pages/chanserv/drop.h4
-rw-r--r--modules/webcpanel/pages/chanserv/info.h4
-rw-r--r--modules/webcpanel/pages/chanserv/modes.cpp13
-rw-r--r--modules/webcpanel/pages/chanserv/modes.h6
-rw-r--r--modules/webcpanel/pages/chanserv/set.h6
-rw-r--r--modules/webcpanel/pages/chanserv/utils.cpp4
-rw-r--r--modules/webcpanel/pages/chanserv/utils.h2
-rw-r--r--modules/webcpanel/pages/confirm.h4
-rw-r--r--modules/webcpanel/pages/hostserv/request.h4
-rw-r--r--modules/webcpanel/pages/index.cpp12
-rw-r--r--modules/webcpanel/pages/index.h8
-rw-r--r--modules/webcpanel/pages/logout.h4
-rw-r--r--modules/webcpanel/pages/memoserv/memos.cpp4
-rw-r--r--modules/webcpanel/pages/memoserv/memos.h4
-rw-r--r--modules/webcpanel/pages/nickserv/access.cpp8
-rw-r--r--modules/webcpanel/pages/nickserv/access.h4
-rw-r--r--modules/webcpanel/pages/nickserv/alist.cpp4
-rw-r--r--modules/webcpanel/pages/nickserv/alist.h4
-rw-r--r--modules/webcpanel/pages/nickserv/cert.cpp4
-rw-r--r--modules/webcpanel/pages/nickserv/cert.h4
-rw-r--r--modules/webcpanel/pages/nickserv/confirm.h2
-rw-r--r--modules/webcpanel/pages/nickserv/info.h4
-rw-r--r--modules/webcpanel/pages/operserv/akill.cpp6
-rw-r--r--modules/webcpanel/pages/operserv/akill.h4
-rw-r--r--modules/webcpanel/pages/register.h4
-rw-r--r--modules/webcpanel/static_fileserver.cpp2
-rw-r--r--modules/webcpanel/static_fileserver.h4
-rw-r--r--modules/webcpanel/template_fileserver.cpp22
-rw-r--r--modules/webcpanel/template_fileserver.h4
-rw-r--r--modules/webcpanel/webcpanel.cpp6
-rw-r--r--modules/webcpanel/webcpanel.h18
-rw-r--r--src/CMakeLists.txt93
-rw-r--r--src/access.cpp35
-rw-r--r--src/account.cpp2
-rw-r--r--src/base.cpp8
-rw-r--r--src/bots.cpp4
-rw-r--r--src/channels.cpp47
-rw-r--r--src/command.cpp13
-rw-r--r--src/config.cpp137
-rw-r--r--src/extensible.cpp5
-rw-r--r--src/hashcomp.cpp2
-rw-r--r--src/init.cpp38
-rw-r--r--src/language.cpp6
-rw-r--r--src/logger.cpp63
-rw-r--r--src/mail.cpp20
-rw-r--r--src/main.cpp8
-rw-r--r--src/memos.cpp8
-rw-r--r--src/messages.cpp58
-rw-r--r--src/misc.cpp87
-rw-r--r--src/modes.cpp63
-rw-r--r--src/module.cpp10
-rw-r--r--src/modulemanager.cpp50
-rw-r--r--src/nickcore.cpp26
-rw-r--r--src/opertype.cpp50
-rw-r--r--src/process.cpp1
-rw-r--r--src/protocol.cpp25
-rw-r--r--src/regchannel.cpp20
-rw-r--r--src/serialize.cpp15
-rw-r--r--src/servers.cpp69
-rw-r--r--src/siphash.cpp10
-rw-r--r--src/socket_clients.cpp2
-rw-r--r--src/socket_transport.cpp16
-rw-r--r--src/socketengines/socketengine_epoll.cpp4
-rw-r--r--src/sockets.cpp84
-rw-r--r--src/threadengine.cpp8
-rw-r--r--src/timers.cpp2
-rw-r--r--src/tools/CMakeLists.txt21
-rw-r--r--src/tools/anoperc.in6
-rw-r--r--src/tools/anopesmtp.cpp535
-rw-r--r--src/uplink.cpp10
-rw-r--r--src/users.cpp32
-rw-r--r--src/version.sh4
-rw-r--r--src/win32/anope_windows.h5
-rw-r--r--src/win32/dir/dir.cpp48
-rw-r--r--src/win32/dir/dir.h27
-rw-r--r--src/win32/socket.cpp81
-rw-r--r--src/win32/socket.h4
-rw-r--r--src/xline.cpp15
-rw-r--r--vendor/README.md13
-rw-r--r--vendor/bcrypt/crypt_blowfish.c907
-rw-r--r--vendor/bcrypt/crypt_blowfish.h27
-rwxr-xr-xvendor/update111
-rw-r--r--vendor/update.toml8
360 files changed, 5334 insertions, 11767 deletions
diff --git a/.BANNER b/.BANNER
index bae644cd0..cd113fc66 100644
--- a/.BANNER
+++ b/.BANNER
@@ -7,11 +7,11 @@
| |
|_| IRC Services
CURVER
-This program will help you to compile your Services, and ask you
+This program will help you to compile your services, and ask you
questions regarding the compile-time settings of it during the
process. For more options type SOURCE_DIR/Config --help
-Anope is a set of Services for IRC networks that allows users to
+Anope is a set of services for IRC networks that allows users to
manage their nicks and channels in a secure and efficient way,
and administrators to manage their network with powerful tools.
diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml
index 1f069fda6..1794ededf 100644
--- a/.github/workflows/ci-linux.yml
+++ b/.github/workflows/ci-linux.yml
@@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-20.04
env:
CXX: ${{ matrix.compiler }}
- CXXFLAGS: -std=${{ matrix.standard }}
+ CXXFLAGS: -Werror
steps:
- uses: actions/checkout@v4
- name: Install dependencies
@@ -17,8 +17,6 @@ jobs:
clang \
g++ \
git \
- libc++-dev \
- libc++abi-dev \
libgnutls28-dev \
libldap2-dev \
libmysqlclient-dev \
@@ -27,7 +25,7 @@ jobs:
libsqlite3-dev \
libssl-dev \
libtre-dev \
- make
+ ninja-build
- name: Enable extras
run: |
for MODULE in m_ldap.cpp m_ldap_authentication.cpp m_ldap_oper.cpp m_mysql.cpp m_regex_pcre.cpp m_regex_pcre2.cpp m_regex_posix.cpp m_regex_tre.cpp m_sql_authentication.cpp m_sql_log.cpp m_sql_oper.cpp m_sqlite.cpp m_ssl_gnutls.cpp m_ssl_openssl.cpp stats
@@ -37,16 +35,13 @@ jobs:
- name: Run CMake
run: |
mkdir build && cd build
- cmake -DCMAKE_BUILD_TYPE:STRING=DEBUG -DINSTDIR:STRING=${{ github.workspace }}/run ..
+ cmake -GNinja -DCMAKE_BUILD_TYPE:STRING=DEBUG -DINSTDIR:STRING=${{ github.workspace }}/run ..
- name: Build Anope
run: |
- make --directory ${{ github.workspace }}/build --jobs $(nproc) --no-print-directory install
+ ninja -C ${{ github.workspace }}/build install
strategy:
fail-fast: false
matrix:
compiler:
- clang++
- g++
- standard:
- - c++98
- - c++17
diff --git a/.github/workflows/ci-windows.yml b/.github/workflows/ci-windows.yml
new file mode 100644
index 000000000..66754ada0
--- /dev/null
+++ b/.github/workflows/ci-windows.yml
@@ -0,0 +1,34 @@
+name: Windows CI
+on:
+ pull_request:
+ push:
+ schedule:
+ - cron: '0 0 * * 0'
+jobs:
+ build:
+ runs-on: windows-2019
+ steps:
+ - uses: actions/checkout@v3
+
+ - name: Setup MSBuild
+ uses: microsoft/setup-msbuild@v1.3
+
+ - name: Setup Conan
+ uses: turtlebrowser/get-conan@v1.2
+ with:
+ version: 1.59.0
+
+ - name: Install libraries
+ run: |
+ conan install ${{ github.workspace }}\src\win32 --build=missing
+
+ - name: Run CMake
+ run: |
+ mkdir ${{ github.workspace }}\build
+ cd ${{ github.workspace }}\build
+ cmake -A "x64" -G "Visual Studio 16 2019" ..
+
+ - name: Build Anope
+ working-directory: ${{ github.workspace }}\build
+ run: |
+ msbuild PACKAGE.vcxproj /M:3 /P:Configuration=Release /P:Platform=x64 /VERBOSITY:MINIMAL
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 822f6f39d..868880669 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,73 +1,10 @@
-# This usage of CMake requires at least version 2.4 (checks are made to determine what to use when certain versions lack functions)
-cmake_minimum_required(VERSION 2.4 FATAL_ERROR)
-if(COMMAND cmake_policy)
- cmake_policy(SET CMP0003 NEW)
- if(POLICY CMP0026)
- cmake_policy(SET CMP0026 OLD)
- endif(POLICY CMP0026)
- if(POLICY CMP0007)
- cmake_policy(SET CMP0007 OLD)
- endif(POLICY CMP0007)
-endif(COMMAND cmake_policy)
+# This usage of CMake requires at least version 3.8
+cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
# Set the project as C++ primarily, but have C enabled for the checks required later
project(Anope CXX)
enable_language(C)
-# Detect the version of CMake for the later conditional checks
-execute_process(COMMAND ${CMAKE_COMMAND} --version OUTPUT_VARIABLE VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
-string(REGEX REPLACE "cmake version 2\\.(.*)" "\\1" ONLY_VERSION "${VERSION}")
-string(REGEX MATCH "-patch .*$" HAS_PATCH "${ONLY_VERSION}")
-if(HAS_PATCH)
- string(REGEX REPLACE "(.*)-patch .*" "\\1" MINOR_VERSION "${ONLY_VERSION}")
- string(REGEX REPLACE ".*-patch (.*)" "\\1" PATCH_VERSION "${ONLY_VERSION}")
-else(HAS_PATCH)
- string(REGEX MATCH "\\." HAS_DOT "${ONLY_VERSION}")
- if(HAS_DOT)
- string(REGEX REPLACE "(.*)\\..*" "\\1" MINOR_VERSION "${ONLY_VERSION}")
- string(REGEX REPLACE ".*\\.(.*)" "\\1" PATCH_VERSION "${ONLY_VERSION}")
- else(HAS_DOT)
- string(REGEX REPLACE "(.*)-beta" "\\1" MINOR_VERSION "${ONLY_VERSION}")
- if(MINOR_VERSION STREQUAL "4-1\n")
- set(PATCH_VERSION 1)
- else(MINOR_VERSION STREQUAL "4-1\n")
- set(PATCH_VERSION 0)
- endif(MINOR_VERSION STREQUAL "4-1\n")
- set(MINOR_VERSION 4)
- endif(HAS_DOT)
-endif(HAS_PATCH)
-
-# Detect is we are using CMake 2.6 or better, these versions include functions that require less work than CMake 2.4 does
-if(MINOR_VERSION GREATER 5)
- set(CMAKE26_OR_BETTER TRUE)
- set(CMAKE248_OR_BETTER TRUE)
- set(CMAKE244_OR_BETTER TRUE)
- set(CMAKE242_OR_BETTER TRUE)
-else(MINOR_VERSION GREATER 5)
- set(CMAKE26_OR_BETTER FALSE)
- # Also detect if we are using CMake 2.4.8 or better, the FIND sub-command of list() is nonexistent in earlier versions
- if(PATCH_VERSION GREATER 7)
- set(CMAKE248_OR_BETTER TRUE)
- set(CMAKE244_OR_BETTER TRUE)
- set(CMAKE242_OR_BETTER TRUE)
- else(PATCH_VERSION GREATER 7)
- set(CMAKE248_OR_BETTER FALSE)
- # Also detect if we are using CMake 2.4.4 or better, the CheckCXXCompilerFlag module and SORT sub-command of list() are nonexistent in earlier versions
- if(PATCH_VERSION GREATER 3)
- set(CMAKE244_OR_BETTER TRUE)
- set(CMAKE242_OR_BETTER TRUE)
- else(PATCH_VERSION GREATER 3)
- set(CMAKE244_OR_BETTER FALSE)
- # ALSO detect if we are using CMake 2.4.2 or better, the APPEND sub-command of list() is nonexistent in earlier versions
- if(PATCH_VERSION GREATER 1)
- set(CMAKE242_OR_BETTER TRUE)
- else(PATCH_VERSION GREATER 1)
- set(CMAKE242_OR_BETTER FALSE)
- endif(PATCH_VERSION GREATER 1)
- endif(PATCH_VERSION GREATER 3)
- endif(PATCH_VERSION GREATER 7)
-endif(MINOR_VERSION GREATER 5)
-
# Override the module include path to include our directory, for our Anope.cmake, as well as we are using our own version of the NSIS template
set(CMAKE_MODULE_PATH ${Anope_SOURCE_DIR}/cmake)
@@ -80,14 +17,10 @@ set(ENV{LC_ALL} C)
set(DEFAULT_LIBRARY_DIRS)
set(DEFAULT_INCLUDE_DIRS)
-# Check that we aren't running on an ancient broken GCC
-if(CMAKE_COMPILER_IS_GNUCXX)
- execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_FULL_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
- string(REGEX REPLACE "^(\\d+\\.\\d+)" "\\1" GCC_VERSION ${GCC_FULL_VERSION})
- if(GCC_VERSION LESS 4.2)
- message(FATAL_ERROR "Your compiler is too old to build Anope. Upgrade to GCC 4.2 or newer!")
- endif(GCC_VERSION LESS 4.2)
-endif(CMAKE_COMPILER_IS_GNUCXX)
+# We require C++17 to build
+set(CMAKE_CXX_EXTENSIONS OFF)
+set(CMAKE_CXX_STANDARD 17)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
# If we are using a GNU compiler (have to use CXX because it seems to fail on C), we will be able to determine it's default paths for libraries and includes
if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang$")
@@ -98,9 +31,9 @@ if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang$")
# Replace the colons in the list with semicolons (only when not on MinGW, which uses semicolons already), and if on MinGW, just copy the line
if(NOT MINGW)
string(REGEX REPLACE ":" ";" LIBRARIES ${LINE})
- else(NOT MINGW)
+ else()
set(LIBRARIES "${LINE}")
- endif(NOT MINGW)
+ endif()
# Iterate through the libraries
foreach(LIBRARY ${LIBRARIES})
# Check if the first character is an equal sign, and skip that library directory as it is (I believe) the primary default and shows up later in the list anyways
@@ -108,13 +41,13 @@ if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang$")
if(NOT FIRST_CHAR STREQUAL "=")
# If the directory had no = in front of it, make sure it's absolute and add it to the list of default library directories
get_filename_component(LIBRARY ${LIBRARY} ABSOLUTE)
- append_to_list(DEFAULT_LIBRARY_DIRS ${LIBRARY})
- endif(NOT FIRST_CHAR STREQUAL "=")
- endforeach(LIBRARY)
+ list(APPEND DEFAULT_LIBRARY_DIRS ${LIBRARY})
+ endif()
+ endforeach()
# Remove duplicate entries from the list
if(DEFAULT_LIBRARY_DIRS)
- remove_list_duplicates(DEFAULT_LIBRARY_DIRS)
- endif(DEFAULT_LIBRARY_DIRS)
+ list(REMOVE_DUPLICATES DEFAULT_LIBRARY_DIRS)
+ endif()
# Create a temporary file to test for the default include directories
FILE(WRITE empty.cpp "")
# Next, we look for the compiler's default include directories
@@ -131,11 +64,11 @@ if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang$")
# If the line has the following on it, the next lines will contain directory names
if(LINE STREQUAL "#include <...> search starts here:")
set(IN_SEARCH TRUE)
- else(LINE STREQUAL "#include <...> search starts here:")
+ else()
# If the line has the following on it, we hit the end of the list
if(LINE STREQUAL "End of search list.")
set(IN_SEARCH FALSE)
- else(LINE STREQUAL "End of search list.")
+ else()
# If we are within the block between the above two lines...
if(IN_SEARCH)
# Get everything but the first character of the line
@@ -147,47 +80,16 @@ if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang$")
# Convert the path to an absolute one, just in case it wasn't
get_filename_component(INCLUDE ${INCLUDE} ABSOLUTE)
# Add that directory to the list of default include directories
- append_to_list(DEFAULT_INCLUDE_DIRS ${INCLUDE})
- endif(IN_SEARCH)
- endif(LINE STREQUAL "End of search list.")
- endif(LINE STREQUAL "#include <...> search starts here:")
- endforeach(LINE)
+ list(APPEND DEFAULT_INCLUDE_DIRS ${INCLUDE})
+ endif()
+ endif()
+ endif()
+ endforeach()
# Remove duplicate entries from the list
if(DEFAULT_INCLUDE_DIRS)
- remove_list_duplicates(DEFAULT_INCLUDE_DIRS)
- endif(DEFAULT_INCLUDE_DIRS)
-endif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang$")
-
-# If we are using Visual Studio, locate the path of the Windows Server 2008 SDK or Windows Server 2003 Platform SDK, depending on which is installed
-if(MSVC)
- # If the path comes up as "/registry" from any of these, the path wasn't found, otherwise, we'll set WSDK_PATH to the corresponding path
- # Look for the 2008 SDK under HKLM first
- get_filename_component(WSDK2008_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows;CurrentInstallFolder]" ABSOLUTE CACHE)
- if(WSDK2008_PATH STREQUAL "/registry")
- # If not found, look for the 2003 SDK under HKLM
- get_filename_component(WSDK2003_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MicrosoftSDK\\InstalledSDKs\\D2FF9F89-8AA2-4373-8A31-C838BF4DBBE1;Install Dir]" ABSOLUTE CACHE)
- if(WSDK2003_PATH STREQUAL "/registry")
- # If not found, look for the 2008 SDK under HKCU
- get_filename_component(WSDK2008_PATH "[HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows;CurrentInstallFolder]" ABSOLUTE CACHE)
- if(WSDK2008_PATH STREQUAL "/registry")
- # If not found, look for the 2003 SDK under HKCU
- get_filename_component(WSDK2003_PATH "[HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\MicrosoftSDK\\InstalledSDKs\\D2FF9F89-8AA2-4373-8A31-C838BF4DBBE1;Install Dir]" ABSOLUTE CACHE)
- if(WSDK2003_PATH STREQUAL "/registry")
- # The SDK was never found, set the path to nothing
- set(WSDK_PATH "")
- else(WSDK2003_PATH STREQUAL "/registry")
- set(WSDK_PATH "${WSDK2003_PATH}")
- endif(WSDK2003_PATH STREQUAL "/registry")
- else(WSDK2008_PATH STREQUAL "/registry")
- set(WSDK_PATH "${WSDK2008_PATH}")
- endif(WSDK2008_PATH STREQUAL "/registry")
- else(WSDK2003_PATH STREQUAL "/registry")
- set(WSDK_PATH "${WSDK2003_PATH}")
- endif(WSDK2003_PATH STREQUAL "/registry")
- else(WSDK2008_PATH STREQUAL "/registry")
- set(WSDK_PATH "${WSDK2008_PATH}")
- endif(WSDK2008_PATH STREQUAL "/registry")
-endif(MSVC)
+ list(REMOVE_DUPLICATES DEFAULT_INCLUDE_DIRS)
+ endif()
+endif()
# If the user specifies -DCMAKE_BUILD_TYPE on the command line, take their definition
# and dump it in the cache along with proper documentation, otherwise set CMAKE_BUILD_TYPE
@@ -196,38 +98,33 @@ endif(MSVC)
if(NOT MSVC)
if(CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.")
- else(CMAKE_BUILD_TYPE)
+ else()
set(CMAKE_BUILD_TYPE DEBUG CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.")
- endif(CMAKE_BUILD_TYPE)
-endif(NOT MSVC)
+ endif()
+endif()
# If running under MinGW, we have to force the resource compiler settings (hopefully this will be fixed in a later version of CMake)
if(MINGW)
set(CMAKE_RC_COMPILER_INIT windres)
enable_language(RC)
set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <FLAGS> <DEFINES> -o <OBJECT> <SOURCE>")
-endif(MINGW)
+endif()
# Include the checking functions used later in this CMakeLists.txt
include(CheckFunctionExists)
-include(CheckIncludeFile)
include(CheckTypeSize)
include(CheckLibraryExists)
-if(CMAKE244_OR_BETTER)
- include(CheckCXXCompilerFlag)
-else(CMAKE244_OR_BETTER)
- include(TestCXXAcceptsFlag)
-endif(CMAKE244_OR_BETTER)
+include(CheckCXXCompilerFlag)
# If extra include directories were specified, tell cmake about them.
if(EXTRA_INCLUDE)
include_directories(${EXTRA_INCLUDE})
-endif(EXTRA_INCLUDE)
+endif()
# If extra library directories were specified, tell cmake about them.
if(EXTRA_LIBS)
link_directories(${EXTRA_LIBS})
-endif(EXTRA_LIBS)
+endif()
# setup conan
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/conanbuildinfo.cmake")
@@ -237,25 +134,31 @@ endif()
# Find gettext
find_package(Gettext)
-
-option(USE_PCH "Use precompiled headers" OFF)
+find_package(Intl)
+if(GETTEXT_FOUND AND Intl_FOUND)
+ set(HAVE_LOCALIZATION ON)
+ include_directories(${Intl_INCLUDE_DIRS})
+else()
+ message("Unable to find gettext and libintl; disabling localization")
+ set(HAVE_LOCALIZATION OFF)
+endif()
# Use the following directories as includes
-# Note that it is important the binary include directory comes before the
-# source include directory so the precompiled headers work correctly.
-include_directories(${Anope_BINARY_DIR}/include ${Anope_SOURCE_DIR}/include ${Anope_BINARY_DIR}/language ${Anope_SOURCE_DIR}/modules/pseudoclients)
+include_directories(
+ ${Anope_BINARY_DIR}/include
+ ${Anope_SOURCE_DIR}/include
+ ${Anope_SOURCE_DIR}/vendor
+)
# Pass on REPRODUCIBLE_BUILD
if(REPRODUCIBLE_BUILD)
add_definitions(-DREPRODUCIBLE_BUILD)
-endif(REPRODUCIBLE_BUILD)
+endif()
-# If using Windows, always add the _WIN32 define
if(WIN32)
- add_definitions(-D_WIN32)
- # And include the windows specific folder for our anope_windows.h
+ # If using Windows, include the windows specific folder for anope_windows.h
include_directories(${Anope_SOURCE_DIR}/src/win32)
-endif(WIN32)
+endif()
# If using Visual Studio, set the C++ flags accordingly
if(MSVC)
@@ -265,107 +168,76 @@ if(MSVC)
string(REPLACE "/W3 " "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
# Set the compile flags to have warnings on the max setting (but disable a few annoying ones), exception handling turned on, the proper defines
set(CXXFLAGS "${CXXFLAGS} /W4 /wd4100 /wd4127 /wd4250 /wd4251 /wd4355 /wd4706 /wd4800 /wd4996 /EHs")
- add_definitions(-DMSVCPP -D_CRT_SECURE_NO_WARNINGS)
+ add_definitions(-D_CRT_SECURE_NO_WARNINGS)
# Otherwise, we're not using Visual Studio
-else(MSVC)
+else()
# Set the compile flags to have all warnings on (including shadowed variables)
- set(CXXFLAGS "${CXXFLAGS} -Wall -Wshadow")
- # If on a *nix system, also set the compile flags to remove GNU extensions (favor ISO C++) as well as reject non-ISO C++ code, also remove all leading underscores in exported symbols (only on GNU compiler)
- if(UNIX)
- set(CXXFLAGS "${CXXFLAGS} -ansi -pedantic ${CMAKE_CXX_FLAGS}")
- if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
- set(CXXFLAGS "${CXXFLAGS} -Wno-long-long -fno-leading-underscore")
- endif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
- # If we aren't on a *nix system, we are using MinGW
- else(UNIX)
- # Also, if we are building under MinGW, add another define for MinGW
- if(MINGW)
- add_definitions(-DMINGW)
- endif(MINGW)
- endif(UNIX)
-endif(MSVC)
+ set(CXXFLAGS "${CXXFLAGS} -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Wextra -Wpedantic -Wno-unused-parameter ${CMAKE_CXX_FLAGS}")
+endif()
# If CMake has found that the given system requires a special library for dl* calls, include it with the linker flags
if(CMAKE_DL_LIBS)
- append_to_list(LINK_LIBS ${CMAKE_DL_LIBS})
-endif(CMAKE_DL_LIBS)
+ list(APPEND LINK_LIBS ${CMAKE_DL_LIBS})
+endif()
# Under MinGW, the -shared flag isn't properly set in the module-specific linker flags, add it from the C flags for shared libraries
if(MINGW)
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS}")
-endif(MINGW)
+endif()
if(NOT PROGRAM_NAME)
- # Under Windows, we set the executable name for Anope to be anope
- if(WIN32)
- set(PROGRAM_NAME anope)
- # Under *nix, we set the executable name for Anope to be services
- else(WIN32)
- set(PROGRAM_NAME services)
- endif(WIN32)
-endif(NOT PROGRAM_NAME)
+ set(PROGRAM_NAME anope)
+endif()
# If we are not using Visual Studio, we'll run the following checks
if(NOT MSVC)
# Check if the C++ compiler can accept the -pipe flag, and add it to the compile flags if it works
- if(CMAKE244_OR_BETTER)
- # If using CMake 2.4.4 or better, we can use check_cxx_compiler_flag
- check_cxx_compiler_flag(-pipe HAVE_PIPE_FLAG)
- else(CMAKE244_OR_BETTER)
- # If using CMake 2.4.3 or older, we will use check_cxx_accepts_flags instead
- check_cxx_accepts_flag(-pipe HAVE_PIPE_FLAG)
- endif(CMAKE244_OR_BETTER)
+ check_cxx_compiler_flag(-pipe HAVE_PIPE_FLAG)
# If the flag was accepted, add it to the list of flags
if(HAVE_PIPE_FLAG)
set(CXXFLAGS "${CXXFLAGS} -pipe")
- endif(HAVE_PIPE_FLAG)
+ endif()
# The following are additional library checks, they are not required for Windows
if(NOT WIN32)
# Check if socket is within the socket library (if the library exists), and add it to the linker flags if needed
check_library_exists(socket socket "" HAVE_SOCKET_LIB)
if(HAVE_SOCKET_LIB)
- append_to_list(LINK_LIBS socket)
- endif(HAVE_SOCKET_LIB)
+ list(APPEND LINK_LIBS socket)
+ endif()
# Check if inet_addr is within the nsl library (if the library exists), and add it to the linker flags if needed
check_library_exists(nsl inet_addr "" HAVE_NSL_LIB)
if(HAVE_NSL_LIB)
- append_to_list(LINK_LIBS nsl)
- endif(HAVE_NSL_LIB)
+ list(APPEND LINK_LIBS nsl)
+ endif()
# Check if pthread_create is within the pthread library (if the library exists), and add it to the linker flags if needed
check_library_exists(pthread pthread_create "" HAVE_PTHREAD)
if(HAVE_PTHREAD)
if(NOT APPLE)
set(LDFLAGS "${LDFLAGS} -pthread")
- endif(NOT APPLE)
- else(HAVE_PTHREAD)
+ endif()
+ else()
message(FATAL_ERROR "The pthread library is required to build Anope")
- endif(HAVE_PTHREAD)
- endif(NOT WIN32)
-endif(NOT MSVC)
+ endif()
+ endif()
+endif()
# If DEFUMASK wasn't passed to CMake, set a default depending on if RUNGROUP was passed in or not
if(NOT DEFUMASK)
if(RUNGROUP)
set(DEFUMASK "007")
- else(RUNGROUP)
+ else()
set(DEFUMASK "077")
- endif(RUNGROUP)
-endif(NOT DEFUMASK)
+ endif()
+endif()
# Set the DEBUG_BUILD for sysconf.h
if(CMAKE_BUILD_TYPE STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO")
+ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(DEBUG_BUILD TRUE)
-endif(CMAKE_BUILD_TYPE STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO")
-
-# Check for the existence of the following include files
-check_include_file(cstdint HAVE_CSTDINT)
-check_include_file(stdint.h HAVE_STDINT_H)
-check_include_file(strings.h HAVE_STRINGS_H)
+endif()
# Check for the existence of the following functions
-check_function_exists(strcasecmp HAVE_STRCASECMP)
-check_function_exists(stricmp HAVE_STRICMP)
check_function_exists(umask HAVE_UMASK)
check_function_exists(epoll_wait HAVE_EPOLL)
check_function_exists(poll HAVE_POLL)
@@ -373,63 +245,60 @@ check_function_exists(kqueue HAVE_KQUEUE)
# Strip the leading and trailing spaces from the compile flags
if(CXXFLAGS)
- strip_string(${CXXFLAGS} CXXFLAGS)
-endif(CXXFLAGS)
+ string(STRIP ${CXXFLAGS} CXXFLAGS)
+endif()
# Strip the leading and trailing spaces from the linker flags
if(LDFLAGS)
- strip_string(${LDFLAGS} LDFLAGS)
-endif(LDFLAGS)
+ string(STRIP ${LDFLAGS} LDFLAGS)
+endif()
# Search for the following programs
-find_program(GREP grep)
-find_program(SH sh)
-find_program(CHGRP chgrp)
-find_program(CHMOD chmod)
+find_program(CHGRP "chgrp" REQUIRED)
+find_program(CHMOD "chmod" REQUIRED)
-# If a INSTDIR was passed in to CMake, use it as the install prefix, otherwise set the default install prefix to the services directory under the user's home directory
+# If a INSTDIR was passed in to CMake, use it as the install prefix, otherwise set the default install prefix to the anope directory under the user's home directory
if(INSTDIR)
set(CMAKE_INSTALL_PREFIX "${INSTDIR}")
elseif(NOT CMAKE_INSTALL_PREFIX)
- set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/services")
-endif(INSTDIR)
+ set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/anope")
+endif()
# Set default paths for various directories if not already defined
if(NOT BIN_DIR)
set(BIN_DIR "bin")
-endif(NOT BIN_DIR)
+endif()
if(NOT DB_DIR)
set(DB_DIR "data")
-endif(NOT DB_DIR)
+endif()
if(NOT DOC_DIR)
set(DOC_DIR "doc")
-endif(NOT DOC_DIR)
+endif()
if(NOT CONF_DIR)
set(CONF_DIR "conf")
-endif(NOT CONF_DIR)
+endif()
if(NOT LIB_DIR)
set(LIB_DIR "lib")
-endif(NOT LIB_DIR)
+endif()
if(NOT LOCALE_DIR)
set(LOCALE_DIR "locale")
-endif(NOT LOCALE_DIR)
+endif()
if(NOT LOGS_DIR)
set(LOGS_DIR "logs")
-endif(NOT LOGS_DIR)
+endif()
# Version number processing
# Find all lines in src/version.sh that start with VERSION_
-read_from_file(${Anope_SOURCE_DIR}/src/version.sh "^VERSION_" VERSIONS)
+file(STRINGS ${Anope_SOURCE_DIR}/src/version.sh VERSIONS REGEX "^VERSION_")
# Iterate through the strings found
foreach(VERSION_STR ${VERSIONS})
string(REGEX REPLACE "^VERSION_([A-Z]+)=\"?([^\"]*)\"?$" "\\1;\\2" VERSION_OUT ${VERSION_STR})
- # Depends on CMP0007 OLD
list(LENGTH VERSION_OUT VERSION_LEN)
list(GET VERSION_OUT 0 VERSION_TYPE)
if(${VERSION_LEN} GREATER 1)
list(GET VERSION_OUT 1 VERSION_DATA)
set(VERSION_${VERSION_TYPE} ${VERSION_DATA})
- endif(${VERSION_LEN} GREATER 1)
-endforeach(VERSION_STR ${VERSIONS})
+ endif()
+endforeach()
# Default build version to 0
set(VERSION_BUILD 0)
@@ -437,7 +306,7 @@ set(VERSION_BUILD 0)
# Only change the build number if version.h exists
if(EXISTS "${Anope_SOURCE_DIR}/include/version.h")
# Attempt to read the build number from include/version.h
- read_from_file(${Anope_SOURCE_DIR}/include/version.h "^#define VERSION_BUILD" VERSIONS)
+ file(STRINGS ${Anope_SOURCE_DIR}/src/version.sh VERSIONS REGEX "^#define VERSION_BUILD")
foreach(VERSION_STR ${VERSIONS})
# Get the length of the string
string(LENGTH ${VERSION_STR} VERSION_LEN)
@@ -447,8 +316,8 @@ if(EXISTS "${Anope_SOURCE_DIR}/include/version.h")
string(SUBSTRING ${VERSION_STR} 22 ${VERSION_NUM_LEN} VERSION)
# Set VERSION_BUILD correctly
set(VERSION_BUILD ${VERSION})
- endforeach(VERSION_STR ${VERSIONS})
-endif(EXISTS "${Anope_SOURCE_DIR}/include/version.h")
+ endforeach()
+endif()
# Set the version variables based on what was found above
set(VERSION_COMMA "${VERSION_MAJOR},${VERSION_MINOR},${VERSION_PATCH},${VERSION_BUILD}")
@@ -461,7 +330,7 @@ set(VERSION_FULL_NOBUILD "${VERSION_DOTTED_NOBUILD}${VERSION_EXTRA}")
if(WIN32)
# Generate the win32.rc file using the above variables
configure_file(${Anope_SOURCE_DIR}/src/win32/win32.rc.cmake ${Anope_BINARY_DIR}/src/win32/win32.rc)
-endif(WIN32)
+endif()
# Add the initial files to ignore which will be ignored regardless of if you are building in-source or out-of-source
add_to_cpack_ignored_files(".git\;config.cache\;CMakeFiles\;sysconf.h$\;build" TRUE)
@@ -476,8 +345,8 @@ if(${Anope_SOURCE_DIR} STREQUAL ${Anope_BINARY_DIR})
# If using Visual Studio, add these files as well
if(MSVC)
add_to_cpack_ignored_files(".vcproj$\;.sln$\;.ncb$\;.suo$\;.dir$\;.ilk$\;.exp$\;.pdb$\;.lib$\;/debug$;/release$;/relwithdebinfo$;/minsizerel$" TRUE)
- endif(MSVC)
-endif(${Anope_SOURCE_DIR} STREQUAL ${Anope_BINARY_DIR})
+ endif()
+endif()
# Go into the following directories and run their CMakeLists.txt as well
add_subdirectory(data)
@@ -488,7 +357,7 @@ add_subdirectory(modules)
add_subdirectory(include)
# Get the filename of the Anope binary, to use later
-get_target_property(SERVICES_BINARY ${PROGRAM_NAME} LOCATION)
+set(SERVICES_BINARY "$<TARGET_FILE:${PROGRAM_NAME}>")
get_filename_component(SERVICES_BINARY ${SERVICES_BINARY} NAME)
# At install time, create the following additional directories
@@ -496,19 +365,19 @@ install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${DB_
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${LOGS_DIR}\")")
if(WIN32)
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${DB_DIR}/runtime\")")
-endif(WIN32)
+endif()
# On non-Windows platforms, if RUNGROUP is set, change the permissions of the below directories, as well as the group of the data directory
if(NOT WIN32 AND RUNGROUP)
install(CODE "execute_process(COMMAND ${CHMOD} 2775 \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/\${DB_DIR}/backups\")")
install(CODE "execute_process(COMMAND ${CHMOD} 2775 \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/\${LOGS_DIR}\")")
install(CODE "execute_process(COMMAND ${CHGRP} -R ${RUNGROUP} \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}\")")
-endif(NOT WIN32 AND RUNGROUP)
+endif()
# On Windows platforms, install extra files
if(WIN32)
install(FILES ${Anope_SOURCE_DIR}/src/win32/anope.bat
DESTINATION ${BIN_DIR}
)
-endif(WIN32)
+endif()
install(CODE "file(REMOVE_RECURSE \"$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${LIB_DIR}/modules\")")
@@ -549,10 +418,10 @@ if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
set(CPACK_NSIS_INSTALLED_ICON_NAME "${SERVICES_BINARY}")
set(CPACK_NSIS_URL_INFO_ABOUT "https://www.anope.org/")
set(CPACK_NSIS_COMPRESSOR "/SOLID lzma")
- endif(WIN32)
+ endif()
set(CPACK_SOURCE_PACKAGE_FILE_NAME "anope-${VERSION_FULL_NOBUILD}-source")
set(CPACK_SOURCE_GENERATOR "TGZ")
set(CPACK_SOURCE_IGNORE_FILES "$ENV{CPACK_IGNORED_FILES}")
set(CPACK_MONOLITHIC_INSTALL TRUE)
include(CPack)
-endif(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
+endif()
diff --git a/Config b/Config
index 089272c10..235ded71c 100755
--- a/Config
+++ b/Config
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# Configuration script for Services.
+# Configuration script for Anope.
#
# Anope (C) 2003-2023 Anope Team
# Contact us at team@anope.org
@@ -62,12 +62,6 @@ Run_Build_System () {
BUILD_TYPE="-DCMAKE_BUILD_TYPE:STRING=RELEASE"
fi
- if [ "$USE_PCH" = "yes" ] ; then
- PCH="-DUSE_PCH:BOOLEAN=ON"
- else
- PCH="-DUSE_PCH:BOOLEAN=OFF"
- fi
-
if [ "$EXTRA_INCLUDE_DIRS" != "" ] ; then
EXTRA_INCLUDE="-DEXTRA_INCLUDE:STRING=$EXTRA_INCLUDE_DIRS"
fi
@@ -76,12 +70,6 @@ Run_Build_System () {
EXTRA_LIBS="-DEXTRA_LIBS:STRING=$EXTRA_LIB_DIRS"
fi
- case `uname -s` in
- MINGW*)
- GEN_TYPE="-G\"MSYS Makefiles\""
- ;;
- esac
-
if [ "$SOURCE_DIR" = "." ] ; then
pwdsave=`pwd`
test -d build || mkdir build
@@ -91,9 +79,9 @@ Run_Build_System () {
REAL_SOURCE_DIR="$SOURCE_DIR"
fi
- echo "cmake $GEN_TYPE $WITH_INST $WITH_RUN $WITH_PERM $BUILD_TYPE $PCH $EXTRA_INCLUDE $EXTRA_LIBS $EXTRA_CONFIG_ARGS $REAL_SOURCE_DIR"
+ echo "cmake $GEN_TYPE $WITH_INST $WITH_RUN $WITH_PERM $BUILD_TYPE $EXTRA_INCLUDE $EXTRA_LIBS $EXTRA_CONFIG_ARGS $REAL_SOURCE_DIR"
- cmake $GEN_TYPE $WITH_INST $WITH_RUN $WITH_PERM $BUILD_TYPE $PCH $EXTRA_INCLUDE $EXTRA_LIBS $EXTRA_CONFIG_ARGS $REAL_SOURCE_DIR
+ cmake $GEN_TYPE $WITH_INST $WITH_RUN $WITH_PERM $BUILD_TYPE $EXTRA_INCLUDE $EXTRA_LIBS $EXTRA_CONFIG_ARGS $REAL_SOURCE_DIR
if [ $? -ne 0 ]; then
echo "You should fix these issues and then run ./Config -quick to rerun CMake."
exit 1
@@ -125,11 +113,10 @@ export ECHO2 ECHO2SUF
# Init values
###########################################################################
-INSTDIR=$HOME/services
+INSTDIR=$HOME/anope
RUNGROUP=
UMASK=
DEBUG="no"
-USE_PCH="no"
EXTRA_INCLUDE_DIRS=
EXTRA_LIB_DIRS=
EXTRA_CONFIG_ARGS=
@@ -176,7 +163,7 @@ done
cmake --version 2>&1 > /dev/null
if [ $? -ne 0 ] ; then
clear
- echo "Anope requires CMake 2.4 or newer, which can be downloaded at https://cmake.org/ or through your system's package manager."
+ echo "Anope requires CMake 3.8 or newer, which can be downloaded at https://cmake.org/ or through your system's package manager."
echo "If you have installed CMake already, ensure it is in your PATH environment variable."
exit 0
fi
@@ -184,24 +171,15 @@ fi
###########################################################################
if [ ! "$NO_INTRO" ] ; then
- case `uname -s` in
- MINGW*)
- PAGER=less
- ;;
- *)
- PAGER=more
- clear
- ;;
- esac
export MORE='-e'
. $SOURCE_DIR/src/version.sh
- cat $SOURCE_DIR/.BANNER | sed "s/CURVER/$VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH$VERSION_EXTRA/" | sed "s@SOURCE_DIR@$SOURCE_DIR@" | $PAGER
+ cat $SOURCE_DIR/.BANNER | sed "s/CURVER/$VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH$VERSION_EXTRA/" | sed "s@SOURCE_DIR@$SOURCE_DIR@" | more
echo ""
else
echo ""
fi
-echo "Beginning Services configuration."
+echo "Beginning Anope configuration."
echo ""
###########################################################################
@@ -240,7 +218,7 @@ while [ $ok -eq 0 ] ; do
fi
fi
elif exists "$INPUT/include/services.h" ; then
- echo "You cannot use the Services source directory as a target directory."
+ echo "You cannot use the Anope source directory as a target directory."
else
ok=1
fi
@@ -252,11 +230,11 @@ echo ""
OLD_RUNGROUP="$RUNGROUP"
if [ "$RUNGROUP" ] ; then
- echo "Which group should all Services data files be owned by? (If Services"
+ echo "Which group should all Anope data files be owned by? (If Anope"
echo "should not force files to be owned by a particular group, type \"none\""
echo "(without the quotes) and press Return.)"
else
- echo "Which group should all Services data files be owned by? (If Services"
+ echo "Which group should all Anope data files be owned by? (If Anope"
echo "should not force files to be owned by a particular group, just press"
echo "Return.)"
fi
@@ -322,25 +300,6 @@ echo ""
####
-TEMP_YN="n"
-if [ "$USE_PCH" = "yes" ] ; then
- TEMP_YN="y"
-fi
-echo "Do you want to build using precompiled headers? This can speed up"
-echo "the build, but uses more disk space."
-echo2 "[$TEMP_YN] "
-read YN
-if [ "$YN" ] ; then
- if [ "$YN" = "y" ] ; then
- USE_PCH="yes"
- else
- USE_PCH="no"
- fi
-fi
-echo ""
-
-####
-
echo "Are there any extra include directories you wish to use?"
echo "You may only need to do this if CMake is unable to locate"
echo "missing dependencies without hints."
@@ -403,7 +362,6 @@ INSTDIR="$INSTDIR"
RUNGROUP="$RUNGROUP"
UMASK=$UMASK
DEBUG="$DEBUG"
-USE_PCH="$USE_PCH"
EXTRA_INCLUDE_DIRS="$EXTRA_INCLUDE_DIRS"
EXTRA_LIB_DIRS="$EXTRA_LIB_DIRS"
EXTRA_CONFIG_ARGS="$EXTRA_CONFIG_ARGS"
diff --git a/README.md b/README.md
index 9d4b62350..9a6886519 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
## About
-Anope is an open source set of IRC Services. It is highly modular, with a vast number of configurable parameters, and is the most used IRC services package. There are also many modules on the [modsite](https://modules.anope.org) to add additional features. It runs on Linux, BSD, and Windows, and supports many modern IRCds, including InspIRCd, UnrealIRCd, and ircd-hybrid. For more details, credits, command line options, and contact information see [docs/README](https://github.com/anope/anope/blob/2.0/docs/README).
+Anope is an open source set of IRC services. It is highly modular, with a vast number of configurable parameters, and is the most used IRC services package. There are also many modules on the [modsite](https://modules.anope.org) to add additional features. It runs on Linux, BSD, and Windows, and supports many modern IRCds, including InspIRCd, UnrealIRCd, and ircd-hybrid. For more details, credits, command line options, and contact information see [docs/README](https://github.com/anope/anope/blob/2.0/docs/README).
* [Website](https://anope.org)
* [GitHub](https://github.com/anope)
@@ -19,7 +19,7 @@ $ make
$ make install
```
-Now change to the directory where you installed Anope to, e.g. `$ cd ~/services/`
+Now change to the directory where you installed Anope to, e.g. `$ cd ~/anope/`
### Windows
Download the latest release off of the [releases page](https://github.com/anope/anope/releases) and run the installer.
@@ -27,19 +27,19 @@ Download the latest release off of the [releases page](https://github.com/anope/
## Configuration
-Copy conf/example.conf to conf/services.conf
+Copy conf/anope.example.conf to conf/anope.conf
```
-$ cp conf/example.conf conf/services.conf
+$ cp conf/anope.example.conf conf/anope.conf
```
-Edit services.conf, configuring the uplink, serverinfo, and protocol module configurations. Example link blocks for popular IRCds are included in the the example.conf documentation. The [Anope wiki](https://wiki.anope.org) is also a good source of information. Our support channel is located at #anope on [irc.anope.org](irc://irc.anope.org/#anope).
+Edit anope.conf, configuring the uplink, serverinfo, and protocol module configurations. Example link blocks for popular IRCds are included in the anope.example.conf documentation. The [Anope wiki](https://wiki.anope.org) is also a good source of information. Our support channel is located at #anope on [irc.anope.org](irc://irc.anope.org/#anope).
-Note that the example configuration file includes other example configuration files. If you want to modify the other example configuration files, copy them (e.g. `modules.example.conf` to `modules.conf`) and modify the `include` directive in `services.conf` to include the new file.
+Note that the example configuration file includes other example configuration files. If you want to modify the other example configuration files, copy them (e.g. `modules.example.conf` to `modules.conf`) and modify the `include` directive in `anope.conf` to include the new file.
## Running
-Run `$ ./bin/services` to start Anope. If asked to provide logs for support, use the `--support` flag, e.g.: `$ ./bin/services --support`
+Run `$ ./bin/anope` to start Anope. If asked to provide logs for support, use the `--support` flag, e.g.: `$ ./bin/anope --support`
## Installing extra modules
diff --git a/cmake/Anope.cmake b/cmake/Anope.cmake
index 1b924bc5d..818e548a6 100644
--- a/cmake/Anope.cmake
+++ b/cmake/Anope.cmake
@@ -1,422 +1,4 @@
###############################################################################
-# strip_string(<input string> <output string>)
-#
-# A macro to handle stripping the leading and trailing spaces from a string,
-# uses string(STRIP) if using CMake 2.6.x or better, otherwise uses
-# string(REGEX REPLACE).
-###############################################################################
-macro(strip_string INPUT_STRING OUTPUT_STRING)
- if(CMAKE26_OR_BETTER)
- # For CMake 2.6.x or better, we can just use the STRIP sub-command of string()
- string(STRIP ${INPUT_STRING} ${OUTPUT_STRING})
- else(CMAKE26_OR_BETTER)
- # For CMake 2.4.x, we will have to use the REGEX REPLACE sub-command of string() instead
- # First check if the input string is empty or not
- if (${INPUT_STRING} STREQUAL "")
- set(${OUTPUT_STRING} "")
- else(${INPUT_STRING} STREQUAL "")
- # Determine if the string is entirely empty or not
- string(REGEX MATCH "^[ \t]*$" EMPTY_STRING "${INPUT_STRING}")
- if(EMPTY_STRING)
- set(${OUTPUT_STRING} "")
- else(EMPTY_STRING)
- # We detect if there is any leading whitespace and remove any if there is
- string(SUBSTRING "${INPUT_STRING}" 0 1 FIRST_CHAR)
- if(FIRST_CHAR STREQUAL " " OR FIRST_CHAR STREQUAL "\t")
- string(REGEX REPLACE "^[ \t]+" "" TEMP_STRING "${INPUT_STRING}")
- else(FIRST_CHAR STREQUAL " " OR FIRST_CHAR STREQUAL "\t")
- set(TEMP_STRING "${INPUT_STRING}")
- endif(FIRST_CHAR STREQUAL " " OR FIRST_CHAR STREQUAL "\t")
- # Next we detect if there is any trailing whitespace and remove any if there is
- string(LENGTH "${TEMP_STRING}" STRING_LEN)
- math(EXPR STRING_LEN "${STRING_LEN} - 1")
- string(SUBSTRING "${TEMP_STRING}" ${STRING_LEN} 1 LAST_CHAR)
- if(LAST_CHAR STREQUAL " " OR LAST_CHAR STREQUAL "\t")
- string(REGEX REPLACE "[ \t]+$" "" ${OUTPUT_STRING} "${TEMP_STRING}")
- else(LAST_CHAR STREQUAL " " OR LAST_CHAR STREQUAL "\t")
- set(${OUTPUT_STRING} "${TEMP_STRING}")
- endif(LAST_CHAR STREQUAL " " OR LAST_CHAR STREQUAL "\t")
- endif(EMPTY_STRING)
- endif(${INPUT_STRING} STREQUAL "")
- endif(CMAKE26_OR_BETTER)
-endmacro(strip_string)
-
-###############################################################################
-# append_to_list(<list> <args>...)
-#
-# A macro to handle appending to lists, uses list(APPEND) if using CMake 2.4.2
-# or better, otherwise uses set() instead.
-###############################################################################
-macro(append_to_list LIST)
- if(CMAKE242_OR_BETTER)
- # For CMake 2.4.2 or better, we can just use the APPEND sub-command of list()
- list(APPEND ${LIST} ${ARGN})
- else(CMAKE242_OR_BETTER)
- # For CMake 2.4.x before 2.4.2, we have to do this manually use set() instead
- set(${LIST} ${${LIST}} ${ARGN})
- endif(CMAKE242_OR_BETTER)
-endmacro(append_to_list)
-
-###############################################################################
-# find_in_list(<list> <value> <output variable>)
-#
-# A macro to handle searching within a list, will store the result in the
-# given <output variable>, uses list(FIND) if using CMake 2.6.x or better
-# (or CMake 2.4.8 or better), otherwise it iterates through the list to find
-# the item.
-###############################################################################
-macro(find_in_list LIST ITEM_TO_FIND FOUND)
- if(CMAKE248_OR_BETTER)
- # For CMake 2.4.8 or better, we can use the FIND sub-command of list()
- list(FIND ${LIST} ${ITEM_TO_FIND} ITEM_FOUND)
- else(CMAKE248_OR_BETTER)
- # For CMake 2.4.x before 2.4.8, we have to do this ourselves (NOTE: This is very slow due to a lack of break() as well)
- # Firstly we set the position to -1 indicating nothing found, we also use a temporary position
- set(ITEM_FOUND -1)
- set(POS 0)
- # Iterate through the list
- foreach(ITEM ${${LIST}})
- # If the item we are looking at is the item we are trying to find, set that we've found the item
- if(${ITEM} STREQUAL ${ITEM_TO_FIND})
- set(ITEM_FOUND ${POS})
- endif(${ITEM} STREQUAL ${ITEM_TO_FIND})
- # Increase the position value by 1
- math(EXPR POS "${POS} + 1")
- endforeach(ITEM)
- endif(CMAKE248_OR_BETTER)
- # Set the given FOUND variable to the result
- set(${FOUND} ${ITEM_FOUND})
-endmacro(find_in_list)
-
-###############################################################################
-# remove_list_duplicates(<list>)
-#
-# A macro to handle removing duplicates from a list, uses
-# list(REMOVE_DUPLICATES) if using CMake 2.6.x or better, otherwise it uses
-# a slower method of creating a temporary list and only adding to it when
-# a duplicate item hasn't been found.
-###############################################################################
-macro(remove_list_duplicates LIST)
- if(CMAKE26_OR_BETTER)
- # For CMake 2.6.x or better, this can be done automatically
- list(REMOVE_DUPLICATES ${LIST})
- else(CMAKE26_OR_BETTER)
- # For CMake 2.4.x, we have to do this ourselves, firstly we'll clear a temporary list
- set(NEW_LIST)
- # Iterate through the old list
- foreach(ITEM ${${LIST}})
- # Check if the item is in the new list
- find_in_list(NEW_LIST ${ITEM} FOUND_ITEM)
- if(FOUND_ITEM EQUAL -1)
- # If the item was not found, append it to the list
- append_to_list(NEW_LIST ${ITEM})
- endif(FOUND_ITEM EQUAL -1)
- endforeach(ITEM)
- # Replace the old list with the new list
- set(${LIST} ${NEW_LIST})
- endif(CMAKE26_OR_BETTER)
-endmacro(remove_list_duplicates)
-
-###############################################################################
-# remove_item_from_list(<list> <value>)
-#
-# A macro to handle removing a value from a list, uses list(REMOVE_ITEM) in
-# both cases, but can remove the value itself using CMake 2.4.2 or better,
-# while older versions use a slower method of iterating the list to find the
-# index of the value to remove.
-###############################################################################
-macro(remove_item_from_list LIST VALUE)
- if(CMAKE242_OR_BETTER)
- # For CMake 2.4.2 or better, this can be done automatically
- list(REMOVE_ITEM ${LIST} ${VALUE})
- else(CMAKE242_OR_BETTER)
- # For CMake 2.4.x before 2.4.2, we have to do this ourselves, firstly we set the index and a variable to indicate if the item was found
- set(INDEX 0)
- set(FOUND FALSE)
- # Iterate through the old list
- foreach(ITEM ${${LIST}})
- # If the item hasn't been found yet, but the current item is the same, remove it
- if(NOT FOUND)
- if(ITEM STREQUAL ${VALUE})
- set(FOUND TRUE)
- list(REMOVE_ITEM ${LIST} ${INDEX})
- endif(ITEM STREQUAL ${VALUE})
- endif(NOT FOUND)
- # Increase the index value by 1
- math(EXPR INDEX "${INDEX} + 1")
- endforeach(ITEM)
- endif(CMAKE242_OR_BETTER)
-endmacro(remove_item_from_list)
-
-###############################################################################
-# sort_list(<list>)
-#
-# A macro to handle sorting a list, uses list(SORT) if using CMake 2.4.4 or
-# better, otherwise it uses a slower method of creating a temporary list and
-# adding elements in alphabetical order.
-###############################################################################
-macro(sort_list LIST)
- if(CMAKE244_OR_BETTER)
- # For CMake 2.4.4 or better, this can be done automatically
- list(SORT ${LIST})
- else(CMAKE244_OR_BETTER)
- # For CMake 2.4.x before 2.4.4, we have to do this ourselves, firstly we'll create a temporary list
- set(NEW_LIST)
- # Iterate through the old list
- foreach(ITEM ${${LIST}})
- # Temporary index position for the new list, as well as temporary value to store if the item was ever found
- set(INDEX 0)
- set(FOUND FALSE)
- # Iterate through the new list
- foreach(NEW_ITEM ${NEW_LIST})
- # Compare the items, only if nothing was found before
- if(NOT FOUND)
- if(NEW_ITEM STRGREATER "${ITEM}")
- set(FOUND TRUE)
- list(INSERT NEW_LIST ${INDEX} ${ITEM})
- endif(NEW_ITEM STRGREATER "${ITEM}")
- endif(NOT FOUND)
- # Increase the index value by 1
- math(EXPR INDEX "${INDEX} + 1")
- endforeach(NEW_ITEM)
- # If the item was never found, just append it to the end
- if(NOT FOUND)
- append_to_list(NEW_LIST ${ITEM})
- endif(NOT FOUND)
- endforeach(ITEM)
- # Replace the old list with the new list
- set(${LIST} ${NEW_LIST})
- endif(CMAKE244_OR_BETTER)
-endmacro(sort_list)
-
-###############################################################################
-# read_from_file(<filename> <regex> <output variable>)
-#
-# A macro to handle reading specific lines from a file, uses file(STRINGS) if
-# using CMake 2.6.x or better, otherwise we read in the entire file and
-# perform a string(REGEX MATCH) on each line of the file instead. This
-# macro can also be used to read in all the lines of a file if REGEX is set
-# to "".
-###############################################################################
-macro(read_from_file FILE REGEX STRINGS)
- if(CMAKE26_OR_BETTER)
- # For CMake 2.6.x or better, we can just use the STRINGS sub-command to get the lines that match the given regular expression (if one is given, otherwise get all lines)
- if(REGEX STREQUAL "")
- file(STRINGS ${FILE} RESULT)
- else(REGEX STREQUAL "")
- file(STRINGS ${FILE} RESULT REGEX ${REGEX})
- endif(REGEX STREQUAL "")
- else(CMAKE26_OR_BETTER)
- # For CMake 2.4.x, we need to do this manually, firstly we read the file in
- execute_process(COMMAND ${CMAKE_COMMAND} -DFILE:STRING=${FILE} -P ${Anope_SOURCE_DIR}/cmake/ReadFile.cmake ERROR_VARIABLE ALL_STRINGS)
- # Next we replace all newlines with semicolons
- string(REGEX REPLACE "\n" ";" ALL_STRINGS ${ALL_STRINGS})
- if(REGEX STREQUAL "")
- # For no regular expression, just set the result to all the lines
- set(RESULT ${ALL_STRINGS})
- else(REGEX STREQUAL "")
- # Clear the result list
- set(RESULT)
- # Iterate through all the lines of the file
- foreach(STRING ${ALL_STRINGS})
- # Check for a match against the given regular expression
- string(REGEX MATCH ${REGEX} STRING_MATCH ${STRING})
- # If we had a match, append the match to the list
- if(STRING_MATCH)
- append_to_list(RESULT ${STRING})
- endif(STRING_MATCH)
- endforeach(STRING)
- endif(REGEX STREQUAL "")
- endif(CMAKE26_OR_BETTER)
- # Set the given STRINGS variable to the result
- set(${STRINGS} ${RESULT})
-endmacro(read_from_file)
-
-###############################################################################
-# extract_include_filename(<line> <output variable> [<optional output variable of quote type>])
-#
-# This macro will take a #include line and extract the filename.
-###############################################################################
-macro(extract_include_filename INCLUDE FILENAME)
- # Strip the leading and trailing spaces from the include line
- strip_string(${INCLUDE} INCLUDE_STRIPPED)
- # Make sure to only do the following if there is a string
- if(INCLUDE_STRIPPED STREQUAL "")
- set(FILE "")
- else(INCLUDE_STRIPPED STREQUAL "")
- # Extract the filename including the quotes or angle brackets
- string(REGEX REPLACE "^.*([\"<].*[\">]).*$" "\\1" FILE "${INCLUDE_STRIPPED}")
- # If an optional 3rd argument is given, we'll store if the quote style was quoted or angle bracketed
- if(${ARGC} GREATER 2)
- string(SUBSTRING ${FILE} 0 1 QUOTE)
- if(QUOTE STREQUAL "<")
- set(${ARGV2} "angle brackets")
- else(QUOTE STREQUAL "<")
- set(${ARGV2} "quotes")
- endif(QUOTE STREQUAL "<")
- endif(${ARGC} GREATER 2)
- # Now remove the quotes or angle brackets
- string(REGEX REPLACE "^[\"<](.*)[\">]$" "\\1" FILE "${FILE}")
- endif(INCLUDE_STRIPPED STREQUAL "")
- # Set the filename to the the given variable
- set(${FILENAME} "${FILE}")
-endmacro(extract_include_filename)
-
-###############################################################################
-# find_includes(<source filename> <output variable>)
-#
-# This macro will search through a file for #include lines, regardless of
-# whitespace, but only returns the lines that are valid for the current
-# platform CMake is running on.
-###############################################################################
-macro(find_includes SRC INCLUDES)
- # Read all lines from the file that start with #, regardless of whitespace before the #
- read_from_file(${SRC} "^[ \t]*#.*$" LINES)
- # Set that any #include lines found are valid, and create temporary variables for the last found #ifdef/#ifndef
- set(VALID_LINE TRUE)
- set(LAST_DEF)
- set(LAST_CHECK)
- # Create an empty include list
- set(INCLUDES_LIST)
- # Iterate through all the # lines
- foreach(LINE ${LINES})
- # Search for #ifdef, #ifndef, #else, #endif, and #include
- string(REGEX MATCH "^[ \t]*#[ \t]*ifdef[ \t]*.*$" FOUND_IFDEF ${LINE})
- string(REGEX MATCH "^[ \t]*#[ \t]*ifndef[ \t]*.*$" FOUND_IFNDEF ${LINE})
- string(REGEX MATCH "^[ \t]*#[ \t]*else.*$" FOUND_ELSE ${LINE})
- string(REGEX MATCH "^[ \t]*#[ \t]*endif.*$" FOUND_ENDIF ${LINE})
- string(REGEX MATCH "^[ \t]*#[ \t]*include[ \t]*[\"<].*[\">][\ t]*.*$" FOUND_INCLUDE ${LINE})
- # If we found a #ifdef on the line, extract the data after the #ifdef and set if the lines after it are valid based on the variables in CMake
- if(FOUND_IFDEF)
- # Extract the define
- string(REGEX REPLACE "^[ \t]*#[ \t]*ifdef[ \t]*(.*)$" "\\1" DEFINE ${LINE})
- # Replace _WIN32 with WIN32, so we can check if the WIN32 variable of CMake is set instead of _WIN32
- if(DEFINE STREQUAL "_WIN32")
- set(DEFINE WIN32)
- endif(DEFINE STREQUAL "_WIN32")
- # Set the last define to this one, and set the last check to true, so when #else is encountered, we can do an opposing check
- set(LAST_DEF ${DEFINE})
- set(LAST_CHECK TRUE)
- # If the define is true (it either exists or is a non-false result), the lines following will be checked, otherwise they will be skipped
- if(${DEFINE})
- set(VALID_LINE TRUE)
- else(${DEFINE})
- set(VALID_LINE FALSE)
- endif(${DEFINE})
- else(FOUND_IFDEF)
- # If we found a #ifndef on the line, the same thing as #ifdef is done, except with the checks in the opposite direction
- if(FOUND_IFNDEF)
- # Extract the define
- string(REGEX REPLACE "^[ \t]*#[ \t]*ifndef[ \t]*(.*)$" "\\1" DEFINE ${LINE})
- # Replace _WIN32 with WIN32, so we can check if the WIN32 variable of CMake is set instead of _WIN32
- if(DEFINE STREQUAL "_WIN32")
- set(DEFINE WIN32)
- endif(DEFINE STREQUAL "_WIN32")
- # Set the last define to this one, and set the last check to false, so when #else is encountered, we can do an opposing check
- set(LAST_DEF ${DEFINE})
- set(LAST_CHECK FALSE)
- # If the define is not true (it either doesn't exists or is a false result), the lines following will be checked, otherwise they will be skipped
- if(${DEFINE})
- set(VALID_LINE FALSE)
- else(${DEFINE})
- set(VALUE_LINE TRUE)
- endif(${DEFINE})
- else(FOUND_IFNDEF)
- # If we found a #else on the line, we check the last define in the opposite direction
- if(FOUND_ELSE)
- # When LAST_CHECK is true, we were inside a #ifdef, now act as if we are entering a #ifndef section by doing an opposing check
- if(LAST_CHECK)
- if(${LAST_DEF})
- set(VALID_LINE FALSE)
- else(${LAST_DEF})
- set(VALID_LINE TRUE)
- endif(${LAST_DEF})
- # When LAST_CHECK is false, we were inside a #ifndef, now act as if we are entering a #ifdef section by doing an opposing check
- else(LAST_CHECK)
- if(${LAST_DEF})
- set(VALID_LINE TRUE)
- else(${LAST_DEF})
- set(VALID_LINE FALSE)
- endif(${LAST_DEF})
- endif(LAST_CHECK)
- else(FOUND_ELSE)
- # If we found a #endif on the line, we'll assume everything following the line is valid until we meet another one of the above lines
- if(FOUND_ENDIF)
- set(VALID_LINE TRUE)
- else(FOUND_ENDIF)
- # If we found a #include on the line, add the entire line to the list of includes unless the line isn't valid
- if(FOUND_INCLUDE)
- if(VALID_LINE)
- append_to_list(INCLUDES_LIST "${LINE}")
- endif(VALID_LINE)
- endif(FOUND_INCLUDE)
- endif(FOUND_ENDIF)
- endif(FOUND_ELSE)
- endif(FOUND_IFNDEF)
- endif(FOUND_IFDEF)
- endforeach(LINE)
- set(${INCLUDES} ${INCLUDES_LIST})
-endmacro(find_includes)
-
-###############################################################################
-# calculate_depends(<source filename> [<optional output variable for includes>])
-#
-# This macro is used in most of the src (sub)directories to calculate the
-# header file dependencies for the given source file.
-###############################################################################
-macro(calculate_depends SRC)
- # Temporarily set that we didn't get a 3rd argument before we actually check if we did get one or not
- set(CHECK_ANGLE_INCLUDES FALSE)
- # Check for a third argument
- if(${ARGC} GREATER 1)
- set(CHECK_ANGLE_INCLUDES TRUE)
- endif(${ARGC} GREATER 1)
- # Find all the lines in the given source file that have any form of #include on them, regardless of whitespace, but only if they are valid for the platform we are on
- find_includes(${SRC} INCLUDES)
- # Reset the list of headers to empty
- set(HEADERS)
- # Iterate through the strings containing #include (if any)
- foreach(INCLUDE ${INCLUDES})
- # Extract the filename from the #include line
- extract_include_filename(${INCLUDE} FILENAME QUOTE_TYPE)
- if(QUOTE_TYPE STREQUAL "angle brackets")
- # The following checks will only be done if there was a request for angle includes to be checked
- if(CHECK_ANGLE_INCLUDES)
- # Find the path of the include file
- if(DEFAULT_INCLUDE_DIRS OR WSDK_PATH OR DEFINED $ENV{VCINSTALLDIR})
- find_path(FOUND_${FILENAME}_INCLUDE NAMES ${FILENAME} PATHS ${DEFAULT_INCLUDE_DIRS} ${WSDK_PATH}/include $ENV{VCINSTALLDIR}/include ${EXTRA_INCLUDE})
- else(DEFAULT_INCLUDE_DIRS OR WSDK_PATH OR DEFINED $ENV{VCINSTALLDIR})
- find_path(FOUND_${FILENAME}_INCLUDE NAMES ${FILENAME} ${EXTRA_INCLUDE})
- endif(DEFAULT_INCLUDE_DIRS OR WSDK_PATH OR DEFINED $ENV{VCINSTALLDIR})
- # If the include file was found, add it's path to the list of include paths, but only if it doesn't already exist and isn't in the defaults for the compiler
- if(FOUND_${FILENAME}_INCLUDE)
- # This used to be find_in_list, but it was changed to this loop to do a find on each default include directory, this fixes Mac OS X trying to get it's framework directories in here
- set(FOUND_IN_DEFAULTS -1)
- foreach(DEFAULT_INCLUDE_DIR ${DEFAULT_INCLUDE_DIRS})
- string(REGEX REPLACE "\\+" "\\\\+" DEFAULT_INCLUDE_DIR ${DEFAULT_INCLUDE_DIR})
- string(REGEX MATCH ${DEFAULT_INCLUDE_DIR} FOUND_DEFAULT ${FOUND_${FILENAME}_INCLUDE})
- if(FOUND_DEFAULT)
- set(FOUND_IN_DEFAULTS 0)
- endif(FOUND_DEFAULT)
- endforeach(DEFAULT_INCLUDE_DIR)
- if(FOUND_IN_DEFAULTS EQUAL -1)
- find_in_list(${ARGV1} "${FOUND_${FILENAME}_INCLUDE}" FOUND_IN_INCLUDES)
- if(FOUND_IN_INCLUDES EQUAL -1)
- append_to_list(${ARGV1} "${FOUND_${FILENAME}_INCLUDE}")
- endif(FOUND_IN_INCLUDES EQUAL -1)
- endif(FOUND_IN_DEFAULTS EQUAL -1)
- else(FOUND_${FILENAME}_INCLUDE)
- # XXX
- if(NOT ${FILENAME} STREQUAL "libintl.h")
- message(FATAL_ERROR "${SRC} needs header file ${FILENAME} but we were unable to locate that header file! Check that the header file is within the search path of your OS.")
- endif(NOT ${FILENAME} STREQUAL "libintl.h")
- endif(FOUND_${FILENAME}_INCLUDE)
- endif(CHECK_ANGLE_INCLUDES)
- endif(QUOTE_TYPE STREQUAL "angle brackets")
- endforeach(INCLUDE)
-endmacro(calculate_depends)
-
-###############################################################################
# calculate_libraries(<source filename> <output variable for linker flags> <output variable for extra depends>)
#
# This macro is used in most of the module (sub)directories to calculate the
@@ -433,10 +15,10 @@ macro(calculate_libraries SRC SRC_LDFLAGS EXTRA_DEPENDS)
set(LIBRARIES)
# Check to see if there are any lines matching: /* RequiredLibraries: [something] */
if(WIN32)
- read_from_file(${SRC} "/\\\\*[ \t]*RequiredWindowsLibraries:[ \t]*.*[ \t]*\\\\*/" REQUIRED_LIBRARIES)
- else(WIN32)
- read_from_file(${SRC} "/\\\\*[ \t]*RequiredLibraries:[ \t]*.*[ \t]*\\\\*/" REQUIRED_LIBRARIES)
- endif(WIN32)
+ file(STRINGS ${SRC} REQUIRED_LIBRARIES REGEX "/\\*[ \t]*RequiredWindowsLibraries:[ \t]*.*[ \t]*\\*/")
+ else()
+ file(STRINGS ${SRC} REQUIRED_LIBRARIES REGEX "/\\*[ \t]*RequiredLibraries:[ \t]*.*[ \t]*\\*/")
+ endif()
# Iterate through those lines
foreach(REQUIRED_LIBRARY ${REQUIRED_LIBRARIES})
# Strip off the /* RequiredLibraries: and */ from the line
@@ -450,86 +32,55 @@ macro(calculate_libraries SRC SRC_LDFLAGS EXTRA_DEPENDS)
if (${LIBRARY} MATCHES "^.+\\|.+$")
string(REGEX REPLACE ".+\\|(.*)" "\\1" LIBRARY_ALT ${LIBRARY})
string(REGEX REPLACE "(.+)\\|.*" "\\1" LIBRARY ${LIBRARY})
- endif(${LIBRARY} MATCHES "^.+\\|.+$")
+ endif()
# Locate the library to see if it exists
- if(DEFAULT_LIBRARY_DIRS OR WSDK_PATH OR DEFINED $ENV{VCINSTALLDIR})
- find_library(FOUND_${LIBRARY}_LIBRARY NAMES ${LIBRARY} ${LIBRARY_ALT} PATHS ${DEFAULT_LIBRARY_DIRS} ${WSDK_PATH}/lib $ENV{VCINSTALLDIR}/lib ${EXTRA_INCLUDE} ${EXTRA_LIBS})
- else(DEFAULT_LIBRARY_DIRS OR WSDK_PATH OR DEFINED $ENV{VCINSTALLDIR})
+ if(DEFAULT_LIBRARY_DIRS OR DEFINED $ENV{VCINSTALLDIR})
+ find_library(FOUND_${LIBRARY}_LIBRARY NAMES ${LIBRARY} ${LIBRARY_ALT} PATHS ${DEFAULT_LIBRARY_DIRS} $ENV{VCINSTALLDIR}/lib ${EXTRA_INCLUDE} ${EXTRA_LIBS})
+ else()
find_library(FOUND_${LIBRARY}_LIBRARY NAMES ${LIBRARY} ${LIBRARY_ALT} PATHS ${EXTRA_INCLUDE} ${EXTRA_LIBS} NO_DEFAULT_PATH)
find_library(FOUND_${LIBRARY}_LIBRARY NAMES ${LIBRARY} ${LIBRARY_ALT} PATHS ${EXTRA_INCLUDE} ${EXTRA_LIBS})
- endif(DEFAULT_LIBRARY_DIRS OR WSDK_PATH OR DEFINED $ENV{VCINSTALLDIR})
+ endif()
# If the library was found, we will add it to the linker flags
if(FOUND_${LIBRARY}_LIBRARY)
if(MSVC)
# For Visual Studio, instead of editing the linker flags, we'll add the library to a separate list of extra dependencies
- append_to_list(EXTRA_DEPENDENCIES "${FOUND_${LIBRARY}_LIBRARY}")
- else(MSVC)
+ list(APPEND EXTRA_DEPENDENCIES "${FOUND_${LIBRARY}_LIBRARY}")
+ else()
# Get the path only of the library, to add it to library paths.
get_filename_component(LIBRARY_PATH ${FOUND_${LIBRARY}_LIBRARY} PATH)
- append_to_list(LIBRARY_PATHS "${LIBRARY_PATH}")
+ list(APPEND LIBRARY_PATHS "${LIBRARY_PATH}")
# Extract the library short name, add it to the library path
get_filename_component(LIBRARY_NAME ${FOUND_${LIBRARY}_LIBRARY} NAME_WE)
string(REGEX REPLACE "^lib" "" LIBRARY_NAME ${LIBRARY_NAME})
- append_to_list(LIBRARIES ${LIBRARY_NAME})
- endif(MSVC)
- else(FOUND_${LIBRARY}_LIBRARY)
+ list(APPEND LIBRARIES ${LIBRARY_NAME})
+ endif()
+ else()
# In the case of the library not being found, we fatally error so CMake stops trying to generate
message(FATAL_ERROR "${SRC} needs library ${LIBRARY} but we were unable to locate that library! Check that the library is within the search path of your OS.")
- endif(FOUND_${LIBRARY}_LIBRARY)
- endforeach(LIBRARY)
- endforeach(REQUIRED_LIBRARY)
+ endif()
+ endforeach()
+ endforeach()
# Remove duplicates from the library paths
if(LIBRARY_PATHS)
- remove_list_duplicates(LIBRARY_PATHS)
- endif(LIBRARY_PATHS)
+ list(REMOVE_DUPLICATES LIBRARY_PATHS)
+ endif()
# Remove diplicates from the libraries
if(LIBRARIES)
- remove_list_duplicates(LIBRARIES)
- endif(LIBRARIES)
+ list(REMOVE_DUPLICATES LIBRARIES)
+ endif()
# Iterate through library paths and add them to the linker flags
foreach(LIBRARY_PATH ${LIBRARY_PATHS})
- find_in_list(DEFAULT_LIBRARY_DIRS "${LIBRARY_PATH}" FOUND_IN_DEFAULTS)
- if(FOUND_IN_DEFAULTS EQUAL -1)
+ if(NOT "${LIBRARY_PATH}" IN_LIST DEFAULT_LIBRARY_DIRS)
set(THIS_LDFLAGS "${THIS_LDFLAGS} -L${LIBRARY_PATH}")
- endif(FOUND_IN_DEFAULTS EQUAL -1)
- endforeach(LIBRARY_PATH)
+ endif()
+ endforeach()
# Iterate through libraries and add them to the linker flags
foreach(LIBRARY ${LIBRARIES})
- append_to_list(EXTRA_DEPENDENCIES "${LIBRARY}")
- endforeach(LIBRARY)
+ list(APPEND EXTRA_DEPENDENCIES "${LIBRARY}")
+ endforeach()
set(${SRC_LDFLAGS} "${THIS_LDFLAGS}")
set(${EXTRA_DEPENDS} "${EXTRA_DEPENDENCIES}")
-endmacro(calculate_libraries)
-
-###############################################################################
-# check_functions(<source filename> <output variable set to TRUE on success>)
-#
-# This macro is used in most of the module (sub)directories to calculate the
-# function dependencies for the given source file.
-###############################################################################
-macro(check_functions SRC SUCCESS)
- # Default to true
- set(${SUCCESS} TRUE)
- # Check to see if there are any lines matching: /* RequiredFunctions: [something] */
- read_from_file(${SRC} "/\\\\*[ \t]*RequiredFunctions:[ \t]*.*[ \t]*\\\\*/" REQUIRED_FUNCTIONS)
- # Iterate through those lines
- foreach(REQUIRED_FUNCTION ${REQUIRED_FUNCTIONS})
- # Strip off the /* RequiredFunctions: and */ from the line
- string(REGEX REPLACE "/\\*[ \t]*RequiredFunctions:[ \t]*([^ \t]*)[ \t]*\\*/" "\\1" REQUIRED_FUNCTION ${REQUIRED_FUNCTION})
- # Replace all commas with semicolons
- string(REGEX REPLACE "," ";" REQUIRED_FUNCTION ${REQUIRED_FUNCTION})
- # Iterate through the functions given
- foreach(FUNCTION ${REQUIRED_FUNCTION})
- # Check if the function exists
- check_function_exists(${REQUIRED_FUNCTION} HAVE_${REQUIRED_FUNCTION})
- # If we don't have the function warn the user and set SUCCESS to FALSE
- if(NOT HAVE_${REQUIRED_FUNCTION})
- message("${SRC} needs function ${REQUIRED_FUNCTION} but we were unable to locate that function!")
- set(${SUCCESS} FALSE)
- endif(NOT HAVE_${REQUIRED_FUNCTION})
- endforeach(FUNCTION)
- endforeach(REQUIRED_FUNCTION)
-endmacro(check_functions)
+endmacro()
###############################################################################
# add_to_cpack_ignored_files(<item> [TRUE])
@@ -544,12 +95,12 @@ macro(add_to_cpack_ignored_files ITEM)
# If we have 2+ arguments, assume that the second one was something like TRUE (doesn't matter really) and convert periods so they will be \\. for CPack
if(${ARGC} GREATER 1)
string(REPLACE "." "\\\\." REAL_ITEM ${REAL_ITEM})
- endif(${ARGC} GREATER 1)
+ endif()
# If the environment variable is already defined, just tack the item to the end
if(DEFINED ENV{CPACK_IGNORED_FILES})
set(ENV{CPACK_IGNORED_FILES} "$ENV{CPACK_IGNORED_FILES};${REAL_ITEM}")
# Otherwise set the environment variable to the item
- else(DEFINED ENV{CPACK_IGNORED_FILES})
+ else()
set(ENV{CPACK_IGNORED_FILES} "${REAL_ITEM}")
- endif(DEFINED ENV{CPACK_IGNORED_FILES})
-endmacro(add_to_cpack_ignored_files)
+ endif()
+endmacro()
diff --git a/cmake/FindGettext.cmake b/cmake/FindGettext.cmake
deleted file mode 100644
index 0f5502874..000000000
--- a/cmake/FindGettext.cmake
+++ /dev/null
@@ -1,26 +0,0 @@
-# Find the header files, libs, and executables for gettext
-if(NOT WIN32)
- find_path(GETTEXT_INCLUDE libintl.h /usr/include /usr/local/include ${EXTRA_INCLUDE})
- find_library(GETTEXT_LIBRARY intl PATHS /usr/lib /usr/lib64 ${EXTRA_LIBS})
- find_program(GETTEXT_MSGFMT msgfmt PATHS /usr/bin/ /usr/local/bin ${EXTRA_INCLUDE})
- if(GETTEXT_INCLUDE AND GETTEXT_MSGFMT)
- set(GETTEXT_FOUND TRUE)
- if(GETTEXT_LIBRARY)
- set(GETTEXT_LIBRARIES ${GETTEXT_LIBRARY})
- endif(GETTEXT_LIBRARY)
- endif(GETTEXT_INCLUDE AND GETTEXT_MSGFMT)
-else(NOT WIN32)
- find_path(GETTEXT_INCLUDE libintl.h)
- find_library(GETTEXT_LIBRARY gnuintl)
- find_program(GETTEXT_MSGFMT msgfmt)
- if(GETTEXT_INCLUDE AND GETTEXT_LIBRARY AND GETTEXT_MSGFMT)
- set(GETTEXT_FOUND TRUE)
- set(GETTEXT_LIBRARIES ${GETTEXT_LIBRARY})
- endif(GETTEXT_INCLUDE AND GETTEXT_LIBRARY AND GETTEXT_MSGFMT)
-endif(NOT WIN32)
-
-# If we found everything we need set variables correctly for lang/CMakeLists.txt to use
-if(GETTEXT_FOUND)
- include_directories("${GETTEXT_INCLUDE}")
- set(GETTEXT_MSGFMT_EXECUTABLE ${GETTEXT_MSGFMT})
-endif(GETTEXT_FOUND)
diff --git a/cmake/ReadFile.cmake b/cmake/ReadFile.cmake
deleted file mode 100644
index be60f1fa7..000000000
--- a/cmake/ReadFile.cmake
+++ /dev/null
@@ -1,5 +0,0 @@
-# This file is external to the read_from_file macro in Anope.cmake in order to
-# get around a possible memory leak in older versions of CMake.
-
-file(READ "${FILE}" RESULT)
-message("${RESULT}")
diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt
index 8bb635dcf..fca99879e 100644
--- a/data/CMakeLists.txt
+++ b/data/CMakeLists.txt
@@ -1,6 +1,6 @@
-# Only install example.chk and example.conf from this directory
+# Only install example.chk and anope.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 botserv.example.conf example.conf hostserv.example.conf modules.example.conf operserv.example.conf chanserv.example.conf global.example.conf memoserv.example.conf nickserv.example.conf chanstats.example.conf irc2sql.example.conf stats.standalone.example.conf)
+set(DATA example.chk anope.example.conf botserv.example.conf hostserv.example.conf modules.example.conf operserv.example.conf chanserv.example.conf global.example.conf memoserv.example.conf nickserv.example.conf chanstats.example.conf irc2sql.example.conf stats.standalone.example.conf)
install(FILES ${DATA}
DESTINATION ${CONF_DIR}
)
diff --git a/data/example.conf b/data/anope.example.conf
index 1ccadcd31..f2fe66837 100644
--- a/data/example.conf
+++ b/data/anope.example.conf
@@ -1,8 +1,8 @@
/*
- * Example configuration file for Services. After making the appropriate
- * changes to this file, place it in the Services conf directory (as
- * specified in the "configure" script, default /home/username/services/conf)
- * under the name "services.conf".
+ * Example configuration file for Anope. After making the appropriate
+ * changes to this file, place it in the Anope conf directory (as
+ * specified in the "Config" script, default /home/username/anope/conf)
+ * under the name "anope.conf".
*
* The format of this file is fairly simple: three types of comments are supported:
* - All text after a '#' on a line is ignored, as in shell scripting
@@ -53,7 +53,7 @@
* included to indicate whether an option is required:
*
* [REQUIRED]
- * Indicates a directive which must be given. Without it, Services will
+ * Indicates a directive which must be given. Without it, Anope will
* not start.
*
* [RECOMMENDED]
@@ -71,7 +71,7 @@
*
* [DEPRECATED]
* Indicates a directive which will disappear in a future version of
- * Services, usually because its functionality has been either
+ * Anope, usually because its functionality has been either
* superseded by that of other directives or incorporated into the main
* program.
*/
@@ -110,7 +110,7 @@ define
#include
{
type = "executable"
- name = "/usr/bin/wget -q -O - https://some.misconfigured.network.com/services.conf"
+ name = "/usr/bin/wget -q -O - https://some.misconfigured.network.com/anope.conf"
}
/*
@@ -120,7 +120,7 @@ define
* This section can be included multiple times, and Anope will attempt to
* connect to each server until it finally connects.
*
- * Each uplink IRCd should have a corresponding configuration to allow Services
+ * Each uplink IRCd should have a corresponding configuration to allow Anope
* to link to it.
*
* An example configuration for InspIRCd that is compatible with the below uplink
@@ -161,20 +161,22 @@ define
uplink
{
/*
- * The IP or hostname of the IRC server you wish to connect Services to.
- * Usually, you will want to connect Services over 127.0.0.1 (aka localhost).
+ * The IP address, hostname, or UNIX socket path of the IRC server you wish
+ * to connect Anope to.
+ * Usually, you will want to connect over 127.0.0.1 (aka localhost).
*
* NOTE: On some shell providers, this will not be an option.
*/
host = "127.0.0.1"
/*
- * Enable if Services should connect using IPv6.
+ * The protocol that Anope should use when connecting to the uplink. Can
+ * be set to "ipv4" (the default), "ipv6", or "unix".
*/
- ipv6 = no
+ protocol = "ipv4"
/*
- * Enable if Services should connect using SSL.
+ * Enable if Anope should connect using SSL.
* You must have an SSL module loaded for this to work.
*/
ssl = no
@@ -200,12 +202,12 @@ uplink
/*
* [REQUIRED] Server Information
*
- * This section contains information about the Services server.
+ * This section contains information about the services server.
*/
serverinfo
{
/*
- * The hostname that Services will be seen as, it must have no conflicts with any
+ * The hostname that Anope will be seen as, it must have no conflicts with any
* other server names on the rest of your IRC network. Note that it does not have
* to be an existing hostname, just one that isn't on your network already.
*/
@@ -215,11 +217,11 @@ serverinfo
* The text which should appear as the server's information in /WHOIS and similar
* queries.
*/
- description = "Services for IRC Networks"
+ description = "Anope IRC Services"
/*
- * The local address that Services will bind to before connecting to the remote
- * server. This may be useful for multihomed hosts. If omitted, Services will let
+ * The local address that Anope will bind to before connecting to the remote
+ * server. This may be useful for multihomed hosts. If omitted, Anope will let
* the Operating System choose the local address. This directive is optional.
*
* If you don't know what this means or don't need to use it, just leave this
@@ -235,16 +237,16 @@ serverinfo
#id = "00A"
/*
- * The filename containing the Services process ID. The path is relative to the
+ * The filename containing the Anope process ID. The path is relative to the
* services root directory.
*/
- pid = "data/services.pid"
+ pid = "data/anope.pid"
/*
* The filename containing the Message of the Day. The path is relative to the
* services root directory.
*/
- motd = "conf/services.motd"
+ motd = "conf/motd.txt"
}
/*
@@ -255,20 +257,17 @@ serverinfo
*
* Supported:
* - bahamut
- * - charybdis
* - hybrid
- * - inspircd12
- * - inspircd20
- * - inspircd3
+ * - inspircd
* - ngircd
* - plexus
* - ratbox
- * - unreal (for 3.2.x)
- * - unreal4 (for 4.x or later)
+ * - solanum
+ * - unrealircd
*/
module
{
- name = "inspircd3"
+ name = "inspircd"
/*
* Some protocol modules can enforce mode locks server-side. This reduces the spam caused by
@@ -290,32 +289,32 @@ module
/*
* [REQUIRED] Network Information
*
- * This section contains information about the IRC network that Services will be
+ * This section contains information about the IRC network that Anope will be
* connecting to.
*/
networkinfo
{
/*
- * This is the name of the network that Services will be running on.
+ * This is the name of the network that Anope will be running on.
*/
networkname = "LocalNet"
/*
* Set this to the maximum allowed nick length on your network.
* Be sure to set this correctly, as setting this wrong can result in
- * Services being disconnected from the network.
+ * Anope being disconnected from the network.
*/
nicklen = 31
/* Set this to the maximum allowed ident length on your network.
* Be sure to set this correctly, as setting this wrong can result in
- * Services being disconnected from the network.
+ * Anope being disconnected from the network.
*/
userlen = 10
/* Set this to the maximum allowed hostname length on your network.
* Be sure to set this correctly, as setting this wrong can result in
- * Services being disconnected from the network.
+ * Anope being disconnected from the network.
*/
hostlen = 64
@@ -331,7 +330,7 @@ networkinfo
/*
* Characters allowed in nicknames. This always includes the characters described
* in RFC1459, and so does not need to be set for normal behavior. Changing this to
- * include characters your IRCd doesn't support will cause your IRCd and/or Services
+ * include characters your IRCd doesn't support will cause your IRCd and/or Anope
* to break. Multibyte characters are not supported, nor are escape sequences.
*
* It is recommended you DON'T change this.
@@ -343,7 +342,7 @@ networkinfo
* to services, such as BotServ bot hostnames and user vhosts. Changing this is not
* recommended unless you know for sure your IRCd supports whatever characters you are
* wanting to use. Telling services to set a vHost containing characters your IRCd
- * disallows could potentially break the IRCd and/or Services.
+ * disallows could potentially break the IRCd and/or Anope.
*
* It is recommended you DON'T change this.
*/
@@ -368,22 +367,22 @@ networkinfo
}
/*
- * [REQUIRED] Services Options
+ * [REQUIRED] Anope Options
*
- * This section contains various options which determine how Services will operate.
+ * This section contains various options which determine how Anope will operate.
*/
options
{
/*
* On Linux/UNIX systems Anope can setuid and setgid to this user and group
- * after starting up. This is useful if Anope has to bind to privileged ports
+ * after starting up. This is useful if Anope has to bind to privileged ports.
*/
#user = "anope"
#group = "anope"
/*
* The case mapping used by services. This must be set to a valid locale name
- * installed on your machine. Services use this case map to compare, with
+ * installed on your machine. Anope uses this case map to compare, with
* case insensitivity, things such as nick names, channel names, etc.
*
* We provide two special casemaps shipped with Anope, ascii and rfc1459.
@@ -409,23 +408,11 @@ options
#seed = 9866235
/*
- * If set, Services will perform more stringent checks on passwords. If this
- * isn't set, Services will only disallow a password if it is the same as the
- * entity (nickname name) with which it is associated. When set, however,
- * Services will also check that the password is at least five
- * characters long, and in the future will probably check other things
- * as well.
- *
- * This directive is optional, but recommended.
- */
- strictpasswords = yes
-
- /*
- * Sets the number of invalid password tries before Services removes a user
+ * Sets the number of invalid password tries before services removes a user
* from the network. If a user enters a number of invalid passwords equal to
- * the given amount for any Services function or combination of functions
- * during a single IRC session (subject to badpasstimeout, below), Services
- * will issues a /KILL for the user. If not given, Services will ignore
+ * the given amount for any services function or combination of functions
+ * during a single IRC session (subject to badpasstimeout, below), services
+ * will issues a /KILL for the user. If not given, services will ignore
* failed password attempts (though they will be logged in any case).
*
* This directive is optional, but recommended.
@@ -467,7 +454,7 @@ options
/*
* Sets the (maximum) frequency at which the timeout list is checked. This,
* combined with readtimeout above, determines how accurately timed events,
- * such as nick kills, occur; it also determines how much CPU time Services
+ * such as nick kills, occur; it also determines how much CPU time services
* will use doing this. Higher values will cause less accurate timing but
* less CPU usage.
*
@@ -480,7 +467,7 @@ options
timeoutcheck = 3s
/*
- * If set, this will allow users to let Services send PRIVMSGs to them
+ * If set, this will allow users to let services send PRIVMSGs to them
* instead of NOTICEs. Also see the "msg" option of nickserv:defaults,
* which also toggles the default communication (PRIVMSG or NOTICE) to
* use for unregistered users.
@@ -493,7 +480,7 @@ options
#useprivmsg = yes
/*
- * If set, will force Services to only respond to PRIVMSGs addresses to
+ * If set, will force services to only respond to PRIVMSGs addresses to
* Nick@ServerName - e.g. NickServ@example.com. This should be used in
* conjunction with IRCd aliases. This directive is optional.
*
@@ -502,14 +489,14 @@ options
#usestrictprivmsg = yes
/*
- * If set, Services will only show /stats o to IRC Operators. This directive
+ * If set, Anope will only show /stats o to IRC Operators. This directive
* is optional.
*/
#hidestatso = yes
/*
* A space-separated list of U-lined servers on your network, it is assumed that
- * the servers in this list are allowed to set channel modes and Services will
+ * the servers in this list are allowed to set channel modes and Anope will
* not attempt to reverse their mode changes.
*
* WARNING: Do NOT put your normal IRC user servers in this directive.
@@ -524,13 +511,13 @@ options
retrywait = 60s
/*
- * If set, Services will hide commands that users don't have the privilege to execute
+ * If set, services will hide commands that users don't have the privilege to execute
* from HELP output.
*/
hideprivilegedcommands = yes
/*
- * If set, Services will hide commands that users can't execute because they are not
+ * If set, services will hide commands that users can't execute because they are not
* logged in from HELP output.
*/
hideregisteredcommands = yes
@@ -748,7 +735,7 @@ log
{
bot = "Global"
target = "globops"
- admin = "global/* operserv/chankill operserv/mode operserv/kick operserv/akill operserv/s*line operserv/noop operserv/jupe operserv/oline operserv/set operserv/svsnick operserv/svsjoin operserv/svspart nickserv/getpass */drop"
+ admin = "global/* operserv/chankill operserv/mode operserv/kick operserv/akill operserv/s*line operserv/noop operserv/jupe operserv/set operserv/svsnick operserv/svsjoin operserv/svspart nickserv/getpass */drop"
servers = "squit"
users = "oper"
other = "expire/* bados akill/*"
@@ -787,7 +774,7 @@ log
* nickserv/recover - Can recover other users nicks
* operserv/config - Can modify services's configuration
* operserv/oper/modify - Can add and remove operators with at most the same privileges
- * protected - Can not be kicked from channels by Services
+ * protected - Can not be kicked from channels by services
*
* Available commands:
* botserv/bot/del botserv/bot/add botserv/bot/change botserv/set/private
@@ -800,8 +787,7 @@ log
*
* memoserv/sendall memoserv/staff
*
- * nickserv/getpass nickserv/getemail nickserv/suspend nickserv/ajoin
- * nickserv/list
+ * nickserv/getemail nickserv/suspend nickserv/ajoin nickserv/list
*
* nickserv/saset/autoop nickserv/saset/email nickserv/saset/greet nickserv/saset/password
* nickserv/saset/display nickserv/saset/kill nickserv/saset/language nickserv/saset/message
@@ -818,7 +804,7 @@ log
* operserv/oper operserv/config operserv/umode operserv/logsearch
* operserv/modload operserv/jupe operserv/set operserv/noop
* operserv/quit operserv/update operserv/reload operserv/restart
- * operserv/shutdown operserv/svs operserv/oline operserv/kill
+ * operserv/shutdown operserv/svs operserv/kill
*
* Firstly, we define 'opertypes' which are named whatever we want ('Network Administrator', etc).
* These can contain commands for oper-only strings (see above) which grants access to that specific command,
@@ -872,7 +858,7 @@ opertype
inherits = "Services Operator"
- commands = "botserv/* chanserv/access/list chanserv/drop chanserv/getkey chanserv/saset/noexpire memoserv/sendall nickserv/saset/* nickserv/getemail operserv/news operserv/jupe operserv/svs operserv/stats operserv/oline operserv/noop operserv/forbid global/*"
+ commands = "botserv/* chanserv/access/list chanserv/drop chanserv/getkey chanserv/saset/noexpire memoserv/sendall nickserv/saset/* nickserv/getemail operserv/news operserv/jupe operserv/svs operserv/stats operserv/noop operserv/forbid global/*"
privs = "*"
}
@@ -890,10 +876,10 @@ opertype
* After defining different types of operators in the above opertype section, we now define who is in these groups
* through 'oper' blocks, similar to ircd access.
*
- * The default is to comment these out (so NOBODY will have Services access).
+ * The default is to comment these out (so NOBODY will have access).
* You probably want to add yourself and a few other people at minimum.
*
- * As with all permissions, make sure to only give trustworthy people access to Services.
+ * As with all permissions, make sure to only give trustworthy people access.
*/
#oper
@@ -904,7 +890,7 @@ opertype
/* The opertype this person will have */
type = "Services Root"
- /* If set, the user must be an oper on the IRCd to gain their Services
+ /* If set, the user must be an oper on the IRCd to gain their
* oper privileges.
*/
require_oper = yes
@@ -939,7 +925,7 @@ opertype
/*
* [OPTIONAL] Mail Config
*
- * This section contains settings related to the use of e-mail from Services.
+ * This section contains settings related to the use of e-mail from services.
* If the usemail directive is set to yes, unless specified otherwise, all other
* directives are required.
*
@@ -950,7 +936,7 @@ opertype
mail
{
/*
- * If set, this option enables the mail commands in Services. You may choose
+ * If set, this option enables the mail commands in Anope. You may choose
* to disable it if you have no Sendmail-compatible mailer installed. Whilst
* this directive (and entire block) is optional, it is required if
* nickserv:registration is set to yes.
@@ -981,7 +967,7 @@ mail
* another e-mail after they have sent one. It also controls the minimum time
* a user must wait before they can receive another e-mail.
*
- * This feature prevents users from being mail bombed using Services and
+ * This feature prevents users from being mail bombed using services and
* it is highly recommended that it be used.
*
* This directive is optional, but highly recommended.
@@ -989,7 +975,7 @@ mail
delay = 5m
/*
- * If set, Services will not attempt to put quotes around the TO: fields
+ * If set, Anope will not put quotes around the TO: fields
* in e-mails.
*
* This directive is optional, and as far as we know, it's only needed
@@ -1126,18 +1112,18 @@ module
/*
* Sets the number of days backups of databases are kept. If you don't give it,
- * or if you set it to 0, Services won't backup the databases.
+ * or if you set it to 0, Anope won't backup the databases.
*
- * NOTE: Services must run 24 hours a day for this feature to work.
+ * NOTE: Anope must run 24 hours a day for this feature to work.
*
* This directive is optional, but recommended.
*/
keepbackups = 3
/*
- * Allows Services to continue file write operations (i.e. database saving)
+ * Allows Anope to continue file write operations (i.e. database saving)
* even if the original file cannot be backed up. Enabling this option may
- * allow Services to continue operation under conditions where it might
+ * allow Anope to continue operation under conditions where it might
* otherwise fail, such as a nearly-full disk.
*
* NOTE: Enabling this option can cause irrecoverable data loss under some
@@ -1257,14 +1243,13 @@ module
#module { name = "enc_bcrypt" }
module { name = "enc_sha256" }
-/*
- * When using enc_none, passwords will be stored without encryption. This isn't secure
- * therefore it is not recommended.
- */
-#module { name = "enc_none" }
-
-/* Deprecated encryption modules */
+ /*
+ * [DEPRECATED] Deprecated encryption modules. You can only use these for compatibility with
+ * old databases and will need to load one of the above modules as your primary encryption
+ * module.
+ */
#module { name = "enc_md5" }
+#module { name = "enc_none" }
#module { name = "enc_sha1" }
/*
diff --git a/data/chanserv.example.conf b/data/chanserv.example.conf
index cce4456ac..e5d623223 100644
--- a/data/chanserv.example.conf
+++ b/data/chanserv.example.conf
@@ -110,9 +110,9 @@ module
* The length of time before a channel registration expires.
*
* This directive is optional, but recommended.
- * If not set, the default is 14 days.
+ * If not set, the default is 30 days.
*/
- expire = 14d
+ expire = 30d
/*
* The maximum number of entries on a channel's access list.
diff --git a/data/example.chk b/data/example.chk
index 119b1ca99..e71928f1c 100644
--- a/data/example.chk
+++ b/data/example.chk
@@ -9,16 +9,16 @@
###############################################################
# Anope binary directory
-ANOPATH=/home/ircd/services/bin
+ANOPATH=/home/ircd/anope/bin
# Anope data directory
-ANODATA=/home/ircd/services/data
+ANODATA=/home/ircd/anope/data
# Name of the pid file
-ANOPIDF=services.pid
+ANOPIDF=anope.pid
# Name of the executable
-ANOPROG=services
+ANOPROG=anope
# Parameters to pass to the executable
ANOARGS=""
diff --git a/data/global.example.conf b/data/global.example.conf
index 90ec350ce..d48fe0581 100644
--- a/data/global.example.conf
+++ b/data/global.example.conf
@@ -66,7 +66,7 @@ module
client = "Global"
/*
- * This is the global message that will be sent when Services are being
+ * This is the global message that will be sent when Anope is being
* shutdown/restarted.
*
* This directive is optional.
@@ -74,7 +74,7 @@ module
#globaloncycledown = "Services are restarting, they will be back shortly - please be good while they're gone"
/*
- * This is the global message that will be sent when Services (re)join the
+ * This is the global message that will be sent when Anope (re)joins the
* network.
*
* This directive is optional.
@@ -82,7 +82,7 @@ module
#globaloncycleup = "Services are now back online - have a nice day"
/*
- * If set, Services will hide the IRC Operator's nick in a global
+ * If set, Anope will hide the IRC Operator's nick in a global
* message/notice.
*
* This directive is optional.
diff --git a/data/hostserv.example.conf b/data/hostserv.example.conf
index e13e8fdd1..0f74ba467 100644
--- a/data/hostserv.example.conf
+++ b/data/hostserv.example.conf
@@ -110,12 +110,12 @@ module
/*
* Upon nickserv/group, this option syncs the nick's main vHost to the grouped nick.
*/
- syncongroup = false
+ syncongroup = true
/*
* This makes vhosts act as if they are per account.
*/
- synconset = false
+ synconset = true
}
command { service = "HostServ"; name = "GROUP"; command = "hostserv/group"; }
@@ -161,13 +161,13 @@ module
name = "hs_request"
/*
- * If set, Services will send a memo to the user requesting a vHost when it's been
+ * If set, Anope will send a memo to the user requesting a vHost when it's been
* approved or rejected.
*/
#memouser = yes
/*
- * If set, Services will send a memo to all Services staff when a new vHost is requested.
+ * If set, Anope will send a memo to all services staff when a new vHost is requested.
*/
#memooper = yes
}
diff --git a/data/modules.example.conf b/data/modules.example.conf
index eba8f777f..f06789e41 100644
--- a/data/modules.example.conf
+++ b/data/modules.example.conf
@@ -3,7 +3,7 @@
*
* The following blocks are used to load all non-core modules, including 3rd-party modules.
* Modules can be prevented from loading by commenting out the line, other modules can be added by
- * adding a module block. These modules will be loaded prior to Services connecting to your network.
+ * adding a module block. These modules will be loaded prior to Anope connecting to your network.
*
* Note that some of these modules are labeled EXTRA, and must be enabled prior to compiling by
* running the 'extras' script on Linux and UNIX.
@@ -91,14 +91,14 @@ module { name = "help" }
name = "m_dnsbl"
/*
- * If set, Services will check clients against the DNSBLs when services connect to its uplink.
+ * If set, Anope will check clients against the DNSBLs when services connect to its uplink.
* This is not recommended, and on large networks will open a very large amount of DNS queries.
* Whilst services are not drastically affected by this, your nameserver/DNSBL might care.
*/
check_on_connect = no
/*
- * If set, Services will check clients when coming back from a netsplit. This can cause a large number
+ * If set, Anope will check clients when coming back from a netsplit. This can cause a large number
* of DNS queries open at once. Whilst services are not drastically affected by this, your nameserver/DNSBL
* might care.
*/
@@ -319,7 +319,7 @@ module { name = "help" }
* This module dynamically ties users to Anope opertypes when they identify
* via LDAP group membership. Requires m_ldap.
*
- * Note that this doesn't give the user privileges on the IRCd, only in Services.
+ * Note that this doesn't give the user privileges on the IRCd, only in Anope.
*/
#module
{
@@ -545,8 +545,8 @@ module { name = "help" }
/*
* m_sasl
*
- * Some IRCds allow "SASL" authentication to let users identify to Services
- * during the IRCd user registration process. If this module is loaded, Services will allow
+ * Some IRCds allow "SASL" authentication to let users identify to services
+ * during the IRCd user registration process. If this module is loaded, Anope will allow
* authenticating users through this mechanism. Supported mechanisms are:
* PLAIN, EXTERNAL.
*/
@@ -709,7 +709,7 @@ module { name = "m_sasl" }
/* Query to execute to determine if a user should have operator privileges.
* A field named opertype must be returned in order to link the user to their oper type.
- * The oper types must be configured earlier in services.conf.
+ * The oper types must be configured earlier in anope.conf.
*
* If a field named modes is returned from this query then those modes are set on the user.
* Without this, only a simple +o is sent.
diff --git a/data/nickserv.example.conf b/data/nickserv.example.conf
index f835a9327..69f2fa07e 100644
--- a/data/nickserv.example.conf
+++ b/data/nickserv.example.conf
@@ -107,8 +107,8 @@ module
* - memo_receive: Notify user if they have a new memo as soon as it's received
* - memo_mail: Notify user if they have a new memo by mail
* - autoop: User will be automatically opped in channels they enter and have access to
- * - msg: Services messages will be sent as PRIVMSGs instead of NOTICEs, requires
- * options:useprivmsg to be enabled as well
+ * - msg: Messages will be sent as PRIVMSGs instead of NOTICEs, requires options:useprivmsg
+ * to be enabled as well
* - ns_keep_modes: Enables keepmodes, which retains user modes across sessions
* - ns_no_expire: Enables no expire. Unconfirmed expire overrules this.
*
@@ -126,20 +126,20 @@ module
/*
* The length of time before a nick's registration expires.
*
- * This directive is optional, but recommended. If not set, the default is 21 days.
+ * This directive is optional, but recommended. If not set, the default is 90 days.
*/
- expire = 21d
+ expire = 90d
/*
- * Prevents the use of the ACCESS and CERT (excluding their LIST subcommand), DROP, FORBID, SUSPEND,
- * GETPASS and SET PASSWORD commands by services operators on other services operators.
+ * Prevents the use of the ACCESS and CERT (excluding their LIST subcommand), DROP, FORBID, SUSPEND
+ * and SET PASSWORD commands by services operators on other services operators.
*
* This directive is optional, but recommended.
*/
secureadmins = yes
/*
- * If set, Services will set the channel modes a user has access to upon identifying, assuming
+ * If set, Anope will set the channel modes a user has access to upon identifying, assuming
* they are not already set.
*
* This directive is optional.
@@ -147,14 +147,14 @@ module
modeonid = yes
/*
- * If set, Services will set these user modes on any user who identifies.
+ * If set, Anope will set these user modes on any user who identifies.
*
* This directive is optional.
*/
#modesonid = "+R"
/*
- * If set, Services will not show netsplits in the last quit message field
+ * If set, Anope will not show netsplits in the last quit message field
* of NickServ's INFO command.
*/
hidenetsplitquit = no
@@ -168,7 +168,7 @@ module
/*
* If set, forbids the registration of nicks that contain an existing
- * nick with Services access. For example, if Tester is a Services Oper,
+ * nick with services access. For example, if Tester is a Services Oper,
* you can't register NewTester or Tester123 unless you are an IRC
* Operator.
*
@@ -181,14 +181,14 @@ module
#restrictopernicks = yes
/*
- * The username, and possibly hostname, used for fake users created when Services needs to
+ * The username, and possibly hostname, used for fake users created when Anope needs to
* hold a nickname.
*/
enforceruser = "enforcer"
enforcerhost = "services.host"
/*
- * The length of time Services hold nicknames.
+ * The length of time Anope should hold nicknames for.
*
* This directive is optional, but recommended. If not set it defaults to 1 minute.
*/
@@ -204,16 +204,23 @@ module
guestnickprefix = "Guest"
/*
- * If set, Services do not allow ownership of nick names, only ownership of accounts.
+ * If set, Anope does not allow ownership of nick names, only ownership of accounts.
*/
nonicknameownership = no
/*
+ * The minimum length of passwords
+ *
+ * This directive is optional. If not set it defaults to 8.
+ */
+ minpasslen = 8
+
+ /*
* The maximum length of passwords
*
* This directive is optional. If not set it defaults to 32.
*/
- passlen = 32
+ maxpasslen = 32
}
/*
@@ -259,7 +266,7 @@ module
accessmax = 32
/*
- * If set, Services will add the usermask of registering users to the access list of their
+ * If set, Anope will add the usermask of registering users to the access list of their
* newly created account. If not set, users will always have to identify to NickServ before
* being recognized, unless they manually add an address to the access list of their account.
* This directive is optional.
@@ -336,18 +343,6 @@ module { name = "ns_getemail" }
command { service = "NickServ"; name = "GETEMAIL"; command = "nickserv/getemail"; permission = "nickserv/getemail"; group = "nickserv/admin"; }
/*
- * ns_getpass
- *
- * Provides the command nickserv/getpass.
- *
- * Used for getting users passwords.
- *
- * Requires no encryption is being used.
- */
-#module { name = "ns_getpass" }
-#command { service = "NickServ"; name = "GETPASS"; command = "nickserv/getpass"; permission = "nickserv/getpass"; }
-
-/*
* ns_group
*
* Provides the commands nickserv/group, nickserv/glist, and nickserv/ungroup.
@@ -457,7 +452,7 @@ module
name = "ns_recover"
/*
- * If set, Services will svsnick and svsjoin users who use the recover
+ * If set, Anope will svsnick and svsjoin users who use the recover
* command on an identified user to the nick and channels of the recovered user.
*
* This directive is optional.
@@ -465,9 +460,10 @@ module
restoreonrecover = yes
}
command { service = "NickServ"; name = "RECOVER"; command = "nickserv/recover"; }
-# Uncomment below to emulate 1.8's behavior of ghost and release.
-#command { service = "NickServ"; name = "GHOST"; command = "nickserv/recover"; }
-#command { service = "NickServ"; name = "RELEASE"; command = "nickserv/recover"; }
+
+# For compatibility with Anope 1.8 and Atheme.
+command { service = "NickServ"; name = "GHOST"; command = "nickserv/recover"; hide = true; }
+command { service = "NickServ"; name = "RELEASE"; command = "nickserv/recover"; hide = true; }
/*
* ns_register
diff --git a/data/operserv.example.conf b/data/operserv.example.conf
index 9856d5b2d..d4cfeda0b 100644
--- a/data/operserv.example.conf
+++ b/data/operserv.example.conf
@@ -75,7 +75,7 @@ module
sqlineexpiry = 30d
/*
- * If set, this option will make Services send an AKILL command immediately after it has been
+ * If set, this option will make Anope send an AKILL command immediately after it has been
* added with AKILL ADD. This eliminates the need for killing the user after the AKILL has
* been added.
*
@@ -84,7 +84,7 @@ module
akillonadd = yes
/*
- * If set, this option will make Services send an (SVS)KILL command immediately after SNLINE ADD.
+ * If set, this option will make Anope send an (SVS)KILL command immediately after SNLINE ADD.
* This eliminates the need for killing the user after the SNLINE has been added.
*
* This directive is optional.
@@ -92,7 +92,7 @@ module
killonsnline = yes
/*
- * If set, this option will make Services send an (SVS)KILL command immediately after SQLINE ADD.
+ * If set, this option will make Anope send an (SVS)KILL command immediately after SQLINE ADD.
* This eliminates the need for killing the user after the SQLINE has been added.
*
* This directive is optional.
@@ -167,7 +167,7 @@ command { service = "OperServ"; name = "CHANKILL"; command = "operserv/chankill"
name = "os_defcon"
/*
- * Default DefCon level (1-5) to use when starting Services up. Level 5 constitutes normal operation
+ * Default DefCon level (1-5) to use when starting Anope up. Level 5 constitutes normal operation
* while level 1 constitutes the most restrictive operation. If this setting is left out or set to
* 0, DefCon will be disabled and the rest of this block will be ignored.
*/
@@ -184,8 +184,8 @@ command { service = "OperServ"; name = "CHANKILL"; command = "operserv/chankill"
* - forcechanmodes: Forces all channels to have the modes given in the later chanmodes directive
* - reducedsessions: Reduces the session limit to the value given in the later sessionlimit directive
* - nonewclients: KILL any new clients trying to connect
- * - operonly: Services will ignore all non-IRCops
- * - silentoperonly: Services will silently ignore all non-IRCops
+ * - operonly: Ignore all non-IRCops
+ * - silentoperonly: Silently ignore all non-IRCops
* - akillnewclients: AKILL any new clients trying to connect
* - nonewmemos: No new memos will be sent to block MemoServ attacks
*/
@@ -209,7 +209,7 @@ command { service = "OperServ"; name = "CHANKILL"; command = "operserv/chankill"
* The channel modes to set on all channels when the DefCon channel mode system is in use.
*
* Note 1: Choose these modes carefully, because when DefCon switches to a level which does NOT have
- * the mode setting selected, Services will set the reverse on all channels, e.g. if this setting
+ * the mode setting selected, Anope will set the reverse on all channels, e.g. if this setting
* is +RN when DefCon is used, all channels will be set to +RN, when DefCon is removed, all
* channels will be set to -RN. You don't want to set this to +k for example, because when DefCon
* is removed, all channels are set -k, removing the key from previously keyed channels.
@@ -227,14 +227,14 @@ command { service = "OperServ"; name = "CHANKILL"; command = "operserv/chankill"
#timeout = 15m
/*
- * If set, Services will send a global message on DefCon level changes.
+ * If set, Anope will send a global message on DefCon level changes.
*
* This directive is optional.
*/
#globalondefcon = yes
/*
- * If set, Services will send the global message defined in the message directive on DefCon level
+ * If set, Anope will send the global message defined in the message directive on DefCon level
* changes.
*
* This directive is optional.
@@ -348,7 +348,7 @@ command { service = "OperServ"; name = "FORBID"; command = "operserv/forbid"; pe
*
* Provides the command operserv/ignore.
*
- * Used to make Services ignore users.
+ * Used to make Anope ignore users.
*/
module { name = "os_ignore" }
command { service = "OperServ"; name = "IGNORE"; command = "operserv/ignore"; permission = "operserv/ignore"; }
@@ -507,17 +507,6 @@ module { name = "os_noop" }
command { service = "OperServ"; name = "NOOP"; command = "operserv/noop"; permission = "operserv/noop"; }
/*
- * os_oline
- *
- * Provides the command operserv/oline.
- *
- * Used to set oper flags on users, and is specific to UnrealIRCd 3.2.
- * See /helpop ?svso on your IRCd for more information.
- */
-#module { name = "os_oline" }
-#command { service = "OperServ"; name = "OLINE"; command = "operserv/oline"; permission = "operserv/oline"; }
-
-/*
* os_oper
*
* Provides the command operserv/oper.
@@ -532,7 +521,7 @@ command { service = "OperServ"; name = "OPER"; command = "operserv/oper"; permis
*
* Provides the command operserv/reload.
*
- * Used to reload the services.conf configuration file.
+ * Used to reload the anope.conf configuration file.
*/
module { name = "os_reload" }
command { service = "OperServ"; name = "RELOAD"; command = "operserv/reload"; permission = "operserv/reload"; }
@@ -595,7 +584,7 @@ module
#sessionlimitdetailsloc = "Please visit https://your.website.url/ for more information about session limits."
/*
- * If set and is not 0, this directive tells Services to add an AKILL if the number of subsequent kills
+ * If set and is not 0, this directive tells Anope to add an AKILL if the number of subsequent kills
* for the same host exceeds this value, preventing the network from experiencing KILL floods.
*
* This directive is optional.
diff --git a/data/stats.standalone.example.conf b/data/stats.standalone.example.conf
index 5aea3a6e2..bd40723e8 100644
--- a/data/stats.standalone.example.conf
+++ b/data/stats.standalone.example.conf
@@ -1,8 +1,8 @@
/*
- * Example configuration file for Services. After making the appropriate
- * changes to this file, place it in the Services conf directory (as
- * specified in the "configure" script, default /home/username/services/conf)
- * under the name "services.conf".
+ * Example configuration file for Anope. After making the appropriate
+ * changes to this file, place it in the Anope conf directory (as
+ * specified in the "Config" script, default /home/username/anope/conf)
+ * under the name "anope.conf".
*
* The format of this file is fairly simple: three types of comments are supported:
* - All text after a '#' on a line is ignored, as in shell scripting
@@ -53,7 +53,7 @@
* included to indicate whether an option is required:
*
* [REQUIRED]
- * Indicates a directive which must be given. Without it, Services will
+ * Indicates a directive which must be given. Without it, Anope will
* not start.
*
* [RECOMMENDED]
@@ -71,7 +71,7 @@
*
* [DEPRECATED]
* Indicates a directive which will disappear in a future version of
- * Services, usually because its functionality has been either
+ * Anope, usually because its functionality has been either
* superseded by that of other directives or incorporated into the main
* program.
*/
@@ -120,7 +120,7 @@ define
* This section can be included multiple times, and Anope will attempt to
* connect to each server until it finally connects.
*
- * Each uplink IRCd should have a corresponding configuration to allow Services
+ * Each uplink IRCd should have a corresponding configuration to allow Anope
* to link to it.
*
* An example configuration for InspIRCd that is compatible with the below uplink
@@ -158,20 +158,22 @@ define
uplink
{
/*
- * The IP or hostname of the IRC server you wish to connect Services to.
- * Usually, you will want to connect Services over 127.0.0.1 (aka localhost).
+ * The IP address, hostname, or UNIX socket path of the IRC server you wish
+ * to connect Anope to.
+ * Usually, you will want to connect over 127.0.0.1 (aka localhost).
*
* NOTE: On some shell providers, this will not be an option.
*/
host = "127.0.0.1"
/*
- * Enable if Services should connect using IPv6.
+ * The protocol that Anope should use when connecting to the uplink. Can
+ * be set to "ipv4" (the default), "ipv6", or "unix".
*/
- ipv6 = no
+ protocol = "ipv4"
/*
- * Enable if Services should connect using SSL.
+ * Enable if Anope should connect using SSL.
* You must have an SSL module loaded for this to work.
*/
ssl = no
@@ -197,12 +199,12 @@ uplink
/*
* [REQUIRED] Server Information
*
- * This section contains information about the Services server.
+ * This section contains information about the services server.
*/
serverinfo
{
/*
- * The hostname that Services will be seen as, it must have no conflicts with any
+ * The hostname that Anope will be seen as, it must have no conflicts with any
* other server names on the rest of your IRC network. Note that it does not have
* to be an existing hostname, just one that isn't on your network already.
*/
@@ -212,11 +214,11 @@ serverinfo
* The text which should appear as the server's information in /WHOIS and similar
* queries.
*/
- description = "Stats for IRC Networks"
+ description = "Anope IRC Statistics"
/*
- * The local address that Services will bind to before connecting to the remote
- * server. This may be useful for multihomed hosts. If omitted, Services will let
+ * The local address that Anope will bind to before connecting to the remote
+ * server. This may be useful for multihomed hosts. If omitted, Anope will let
* the Operating System choose the local address. This directive is optional.
*
* If you don't know what this means or don't need to use it, just leave this
@@ -232,16 +234,16 @@ serverinfo
#id = "00A"
/*
- * The filename containing the Services process ID. The path is relative to the
+ * The filename containing the Anope process ID. The path is relative to the
* services root directory.
*/
- pid = "data/stats.pid"
+ pid = "data/anope.pid"
/*
* The filename containing the Message of the Day. The path is relative to the
* services root directory.
*/
- motd = "conf/stats.motd"
+ motd = "conf/motd.txt"
}
/*
@@ -252,51 +254,48 @@ serverinfo
*
* Supported:
* - bahamut
- * - charybdis
* - hybrid
- * - inspircd12
- * - inspircd20
- * - inspircd3
+ * - inspircd
* - ngircd
* - plexus
* - ratbox
- * - unreal (for 3.2.x)
- * - unreal4 (for 4.x or later)
+ * - solanum
+ * - unrealircd
*/
module
{
- name = "inspircd3"
+ name = "inspircd"
}
/*
* [REQUIRED] Network Information
*
- * This section contains information about the IRC network that Services will be
+ * This section contains information about the IRC network that Anope will be
* connecting to.
*/
networkinfo
{
/*
- * This is the name of the network that Services will be running on.
+ * This is the name of the network that Anope will be running on.
*/
networkname = "LocalNet"
/*
* Set this to the maximum allowed nick length on your network.
* Be sure to set this correctly, as setting this wrong can result in
- * Services being disconnected from the network.
+ * Anope being disconnected from the network.
*/
nicklen = 31
/* Set this to the maximum allowed ident length on your network.
* Be sure to set this correctly, as setting this wrong can result in
- * Services being disconnected from the network.
+ * Anope being disconnected from the network.
*/
userlen = 10
/* Set this to the maximum allowed hostname length on your network.
* Be sure to set this correctly, as setting this wrong can result in
- * Services being disconnected from the network.
+ * Anope being disconnected from the network.
*/
hostlen = 64
@@ -314,7 +313,7 @@ networkinfo
* to services, such as BotServ bot hostnames and user vhosts. Changing this is not
* recommended unless you know for sure your IRCd supports whatever characters you are
* wanting to use. Telling services to set a vHost containing characters your IRCd
- * disallows could potentially break the IRCd and/or Services.
+ * disallows could potentially break the IRCd and/or Anope.
*
* It is recommended you DON'T change this.
*/
@@ -339,22 +338,22 @@ networkinfo
}
/*
- * [REQUIRED] Services Options
+ * [REQUIRED] Anope Options
*
- * This section contains various options which determine how Services will operate.
+ * This section contains various options which determine how Anope will operate.
*/
options
{
/*
* On Linux/UNIX systems Anope can setuid and setgid to this user and group
- * after starting up. This is useful if Anope has to bind to privileged ports
+ * after starting up. This is useful if Anope has to bind to privileged ports.
*/
#user = "anope"
#group = "anope"
/*
* The case mapping used by services. This must be set to a valid locale name
- * installed on your machine. Services use this case map to compare, with
+ * installed on your machine. Anope uses this case map to compare, with
* case insensitivity, things such as nick names, channel names, etc.
*
* We provide two special casemaps shipped with Anope, ascii and rfc1459.
@@ -378,14 +377,14 @@ options
warningtimeout = 4h
/*
- * If set, Services will only show /stats o to IRC Operators. This directive
+ * If set, Anope will only show /stats o to IRC Operators. This directive
* is optional.
*/
#hidestatso = yes
/*
* A space-separated list of U-lined servers on your network, it is assumed that
- * the servers in this list are allowed to set channel modes and Services will
+ * the servers in this list are allowed to set channel modes and Anope will
* not attempt to reverse their mode changes.
*
* WARNING: Do NOT put your normal IRC user servers in this directive.
diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt
index 082b1da0e..fd93e81c0 100644
--- a/docs/CMakeLists.txt
+++ b/docs/CMakeLists.txt
@@ -6,10 +6,10 @@ if(WIN32)
if(IN_SOURCE)
# Add README.txt to list of files for CPack to ignore
add_to_cpack_ignored_files("README.txt$" TRUE)
- endif(IN_SOURCE)
+ endif()
set(DOCS Changes Changes.conf DEFCON FAQ INSTALL LANGUAGE MODULES NEWS ${CMAKE_CURRENT_BINARY_DIR}/README.txt WIN32.txt)
install(FILES ${DOCS}
DESTINATION ${DOC_DIR}
)
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${CMAKE_CURRENT_BINARY_DIR}/README.txt")
-endif(WIN32)
+endif()
diff --git a/docs/Changes.conf b/docs/Changes.conf
index a756ef89b..cae02ea86 100644
--- a/docs/Changes.conf
+++ b/docs/Changes.conf
@@ -1,3 +1,14 @@
+Anope Version 2.1.0-git
+-----------------------
+Added nickserv:minpasslen for configuring the minimum password length.
+Removed nickserv:strictpasswords as it is obsolete now nickserv:minpasslen exists.
+Removed the inspircd12 and inspircd20 modules (use inspircd instead).
+Removed the unreal module (use unrealircd instead)
+Renamed nickserv:passlen to nickserv:maxpasslen.
+Renamed the inspircd3 module to inspircd.
+Renamed the unreal4 module to unrealircd.
+Replaced uplink:ipv6 with uplink:protocol.
+
Anope Version 2.0.15-git
------------------------
No significant changes.
diff --git a/docs/DEFCON b/docs/DEFCON
index dbc981df9..2eaaa3dfe 100644
--- a/docs/DEFCON
+++ b/docs/DEFCON
@@ -23,7 +23,7 @@ Anope DefCon
These are configurable levels that mandates what actions Anope should
take in case of emergency and change in readiness status.
- It is used to prevent abuse to both Services, and the ircd on which they
+ It is used to prevent abuse to both Anope, and the IRCd on which they
are running. Also to protect the users, primarily in the event of Clones
and/or FloodBOT attacks.
@@ -50,8 +50,8 @@ Anope DefCon
Force Chan Mode
Use Reduced Session Limit
KILL any new clients trying to connect
- Services will ignore everyone but opers
- Services will silently ignore everyone but opers
+ Ignore everyone but opers
+ Silently ignore everyone but opers
AKILL all new clients trying to connect
No new memos sent to block MemoServ attacks
diff --git a/docs/EVENTS b/docs/EVENTS
index 54e9c87a5..ba570289b 100644
--- a/docs/EVENTS
+++ b/docs/EVENTS
@@ -22,13 +22,10 @@ Anope Internal Events
The full list of functions and parameters are in modules.h. In this
case, you would be overriding OnJoinChannel() and OnPartChannel() like so:
- void OnJoinChannel(User *u, Channel *c) anope_override { }
- void OnPartChannel(User *u, Channel *c) anope_override { }
+ void OnJoinChannel(User *u, Channel *c) override { }
+ void OnPartChannel(User *u, Channel *c) override { }
Some of these event overrides can be used to prevent or allow things to
happen that would normally not be allowed or denied. You can also use
ModuleManager (not explained here) to set control which order the modules
are queried (when multiple modules hook to the same event).
-
- The "anope_override" identifier is for compatibility with C++11.
- Its usage is highly recommended.
diff --git a/docs/INSTALL b/docs/INSTALL
index 91814358b..cbd170804 100644
--- a/docs/INSTALL
+++ b/docs/INSTALL
@@ -52,8 +52,8 @@ Note: You should also read the README and FAQ files!
cause trouble on your network if passwords are not encrypted, or read
the memos of any user.
- Now go into the conf directory (by default, ~/services/conf). Copy the example
- configuration file (example.conf) to services.conf, and open the latter
+ Now go into the conf directory (by default, ~/anope/conf). Copy the example
+ configuration file (anope.example.conf) to anope.conf, and open the latter
with your favorite text editor. It contains all the configuration
directives Anope will use at startup. Read the instructions contained in
the file carefully. Using the default values is NOT a good idea, and will
@@ -71,11 +71,11 @@ Note: You should also read the README and FAQ files!
* IMPORTANT: Back up your old databases!
* If you are upgrading to a new major release, ALWAYS restart a
- fresh configuration file from example.conf.
+ fresh configuration file from anope.example.conf.
3) Setting up the IRCd
- Services acts as an IRC server with pseudo-clients on it. To link them to
+ Anope acts as an IRC server with pseudo-clients on it. To link them to
your network, you'll need to configure your IRCd to allow services to link.
The configuration varies depending on the IRCd, but you will probably need
@@ -83,7 +83,7 @@ Note: You should also read the README and FAQ files!
a shared block), and be sure that the IRCd is listening on the given port
in the link block.
- Example link configurations can be found in example.conf for some of the
+ Example link configurations can be found in anope.example.conf for some of the
popular IRCds.
Don't forget to /rehash your IRCd to apply changes.
@@ -91,16 +91,16 @@ Note: You should also read the README and FAQ files!
4) Starting Anope
Go into the directory where binaries were installed (by default, this is
- ~/services/bin). Type ./services to launch Anope.
+ ~/anope/bin). Type ./anope to launch Anope.
If there are syntax errors in the configuration file they will be
displayed on the screen. Correct them until there are no errors anymore.
A successful startup won't generate any message.
- Give Services at least one minute to link to your network, as certain
+ Give Anope at least one minute to link to your network, as certain
IRCds on some OSes may be really slow for the link process. If nothing
happens after about a minute, it is probably a configuration problem. Try
- to launch Anope with ./services -debug -nofork to see any errors that it
+ to launch Anope with ./anope -debug -nofork to see any errors that it
encounters, and try to correct them.
If you need help to solve errors, feel free to subscribe to the Anope
@@ -112,16 +112,16 @@ Note: You should also read the README and FAQ files!
still running, and restart it if not.
First rename the example.chk script that is in Anope path (by default,
- this is ~/services/conf) to services.chk and edit it. You'll need to
+ this is ~/anope/conf) to anope.chk and edit it. You'll need to
modify the CONFIGURATION part of the file. Then ensure that the file is
- marked as executable by typing chmod +x services.chk, and try to launch the
+ marked as executable by typing chmod +x anope.chk, and try to launch the
script to see if it works (Anope must not be running when you do this ;))
When this is done, you'll have to add the crontab entry. Type crontab -e.
This will open the default text editor with the crontab file. Enter the
following (with correct path):
- */5 * * * * /home/ircd/services/conf/services.chk >/dev/null 2>&1
+ */5 * * * * /home/ircd/anope/conf/anope.chk >/dev/null 2>&1
The */5 at the beginning means "check every 5 minutes". You may replace
the 5 with other another number if you want (but less than 60). Consult
diff --git a/docs/INSTALL.fr b/docs/INSTALL.fr
index 994f2f02f..f80aeb9d6 100644
--- a/docs/INSTALL.fr
+++ b/docs/INSTALL.fr
@@ -49,15 +49,15 @@ Note : Vous devrez également lire les fichiers README et FAQ !
Allez dans le dossier build (cd build) et tapez make et make install.
Ceci va installer tous les fichiers nécessaires dans les dossiers que
vous avez indiqués avec le script Config et régler les permissions des
- fichiers. Vous devez vous assurer que le répertoire data n'est pas
+ fichiers. Vous devez vous assurer que le répertoire data n'est pas
accessible par les autres utilisateurs, car des utilisateurs
malveillants pourraient causer des problèmes sur votre réseau, si les
mots de passe ne sont pas chiffrés, ou lire les mémos de tous les
utilisateurs.
- Allez maintenant dans le répertoire conf (par défaut, ~/services/conf).
- Copiez l'exemple de fichier de configuration (example.conf) en
- services.conf et ouvrez ce dernier avec votre éditeur de texte favori.
+ Allez maintenant dans le répertoire conf (par défaut, ~/anope/conf).
+ Copiez l'exemple de fichier de configuration (anope.example.conf) en
+ anope.conf et ouvrez ce dernier avec votre éditeur de texte favori.
Il contient toutes les directives de configuration qu'Anope va utiliser
en démarrant. Lisez attentivement les instructions contenues dans le
fichier. L'utilisation des valeurs par défaut n'est pas toujours
@@ -78,11 +78,11 @@ Note : Vous devrez également lire les fichiers README et FAQ !
* IMPORTANT : Sauvegardez vos anciennes bases de données !
* Si vous mettez à jour vers une nouvelle version majeure,
recommencez *toujours* toute votre configuration à partir du
- fichier example.conf.
+ fichier anope.example.conf.
3) Configuration de l'IRCd
- Les Services agissent comme un serveur IRC avec des pseudo-clients.
+ Anope agit comme un serveur IRC avec des pseudo-clients.
Pour les relier à votre réseau, vous aurez besoin de configurer votre
IRCd pour permettre aux services de se connecter.
@@ -92,14 +92,14 @@ Note : Vous devrez également lire les fichiers README et FAQ !
sur le port donné dans le bloc link.
Des exemples de configurations de bloc link peuvent être trouvés dans
- le fichier example.conf pour certains des IRCd les plus populaires.
+ le fichier anope.example.conf pour certains des IRCd les plus populaires.
Souvenez-vous de /rehash votre IRCd pour appliquer les changements.
4) Mettre en route Anope
Allez dans le répertoire où les fichiers binaires ont été installés
- (par défaut, ~/services/bin). Tapez ./services pour lancer Anope.
+ (par défaut, ~/anope/bin). Tapez ./anope pour lancer Anope.
S'il y a des erreurs de syntaxe dans le fichier de configuration, elles
seront affichées à l'écran. Corrigez-les jusqu'à ce qu'il n'y en ait
@@ -109,7 +109,7 @@ Note : Vous devrez également lire les fichiers README et FAQ !
réseau, car certains IRCds sur certains systèmes peuvent être très
lents pour le processus de liaison. Si rien ne se passe après environ
une minute, il y a probablement un problème de configuration. Essayez
- de lancer Anope en mode debug avec ./services -debug -nofork pour voir
+ de lancer Anope en mode debug avec ./anope -debug -nofork pour voir
toutes les erreurs rencontrées et essayez de les corriger.
Si vous avez besoin d'aide pour résoudre des erreurs, n'hésitez pas à
@@ -122,10 +122,10 @@ Note : Vous devrez également lire les fichiers README et FAQ !
est toujours en cours d'exécution et de le redémarrer s'il n'est pas.
D'abord renommez le script example.chk qui est dans les dossiers
- d'Anope (par défaut, ~/services/conf) en services.chk et modifiez-le.
+ d'Anope (par défaut, ~/anope/conf) en anope.chk et modifiez-le.
Vous aurez besoin de modifier la partie CONFIGURATION du fichier.
Assurez-vous ensuite que le fichier est marqué comme exécutable en
- tapant chmod +x services.chk et essayez de lancer le script pour voir
+ tapant chmod +x anope.chk et essayez de lancer le script pour voir
si cela fonctionne (Anope ne doit pas être en marche lorsque vous
testez cela ;))
@@ -133,7 +133,7 @@ Note : Vous devrez également lire les fichiers README et FAQ !
crontab -e. Cela va ouvrir l'éditeur de texte par défaut avec le
fichier crontab. Entrez la ligne suivante (avec le chemin correct) :
- */5 * * * * /home/ircd/services/conf/services.chk > /dev/null 2>&1
+ */5 * * * * /home/ircd/anope/conf/anope.chk > /dev/null 2>&1
Le */5 au début signifie "vérifier toutes les 5 minutes". Vous pouvez
remplacer le 5 par un autre numéro si vous voulez (mais moins de 60).
diff --git a/docs/LANGUAGE b/docs/LANGUAGE
index 061d611f6..6788b41fe 100644
--- a/docs/LANGUAGE
+++ b/docs/LANGUAGE
@@ -26,7 +26,7 @@ Anope Multi Language Support
Anope uses gettext (https://www.gnu.org/software/gettext/) to translate messages for users. To add a new language
install gettext and run `msginit -l language -o anope.language.po -i anope.pot`. For example if I was translating to
Spanish I could run `msginit -l es_ES -o anope.es_ES.po -i anope.pot`. Open the newly generating .po file and start
- translating. Once you are done simply rerun ./Config; make && make install and add the language to your services.conf.
+ translating. Once you are done simply rerun ./Config; make && make install and add the language to your anope.conf.
Note that on Windows it is not quite this simple, windows.cpp must be edited and Anope recompiled and restarted.
Poedit (https://poedit.net/) is a popular po file editor, and we recommend using it or another editor designed to edit
diff --git a/docs/MODULES b/docs/MODULES
index 52cb3b25c..d74f4f35a 100644
--- a/docs/MODULES
+++ b/docs/MODULES
@@ -22,7 +22,7 @@ Anope Modules
1. If modules are supported by your system, they will be configured
automatically when you run ./Config. The modules will be installed
to the modules directory in your data path (by default this will
- be ~/services/data/modules).
+ be ~/anope/data/modules).
2. Compile Anope as usual using ./Config. The "make" process will now
compile module support into Anope, and compile the default sample
@@ -98,7 +98,7 @@ Anope Modules
1. Make sure you're in the main source directory. (usually anope-1.X.XX/)
2. Run ./Config to find and configure modules, then `cd build`.
3. Run `make` to compile Anope, and any modules.
- 4. Run `make install` to copy the compiled binaries to the ~/services/
+ 4. Run `make install` to copy the compiled binaries to the ~/anope/
directory.
You can now use /msg OperServ MODLOAD to load the new modules.
diff --git a/docs/README b/docs/README
index 7073d8476..da9c5a010 100644
--- a/docs/README
+++ b/docs/README
@@ -120,7 +120,7 @@ Table of Contents
2) Presentation
- Anope is a set of Services for IRC networks that allows users to manage
+ Anope is a set of services for IRC networks that allows users to manage
their nicks and channels in a secure and efficient way, and administrators
to manage their network with powerful tools.
@@ -167,13 +167,13 @@ Table of Contents
Anope currently works with:
* Bahamut 1.4.27 or later (including 1.8)
- * Charybdis 3.4 or later
* ircd-hybrid 8.2.23 or later
- * InspIRCd 1.2 or later
+ * InspIRCd 3 or later
* ngIRCd 19.2 or later
* Plexus 3 or later
* Ratbox 2.0.6 or later
- * UnrealIRCd 3.2 or later
+ * Solanum (all versions)
+ * UnrealIRCd 4 or later
Anope could also work with some of the daemons derived by the ones listed
above, but there's no support for them if they work or don't work.
@@ -225,7 +225,7 @@ Table of Contents
the log file; if you send a bug report, PLEASE include an excerpt from
the log file WITH DEBUGGING ACTIVE; we cannot emphasize enough how
important this is to tracking down problems. (You can also enable
- debugging while Services is running using OperServ's SET DEBUG command.)
+ debugging while Anope is running using OperServ's SET DEBUG command.)
If you repeat use --debug=<level>, the debugging level will be increased,
which provides more detailed information but may also slow Anope down
considerably and make the log file grow dramatically faster. In general,
diff --git a/docs/REDIS b/docs/REDIS
index 8f7a076fd..761d6de9e 100644
--- a/docs/REDIS
+++ b/docs/REDIS
@@ -149,12 +149,12 @@ Table of Contents
Which returns a new object ID for me, in this example it will be "8".
Now I can create the object:
- HMSET hash:BotInfo:8 nick redis user redis host services.anope.org realname "Services for IRC Networks"
+ HMSET hash:BotInfo:8 nick redis user redis host services.anope.org realname "Anope IRC Services"
Note if you are using HSET instead of HMSET you will need to use a transaction, as shown in the above example.
If you are watching your services logs you will immediately see:
- USERS: redis!redis@services.anope.org (Services for IRC Networks) connected to the network (services.anope.org)
+ USERS: redis!redis@services.anope.org (Anope IRC Services) connected to the network (services.anope.org)
And the bot redis will be in BotServ's bot list.
Notice how ids:BotInfo and the value keys are updated automatically.
diff --git a/docs/TOOLS b/docs/TOOLS
deleted file mode 100644
index 5e8f139cb..000000000
--- a/docs/TOOLS
+++ /dev/null
@@ -1,25 +0,0 @@
-Anope Bundled Tools
--------------------
-
-1) Anope SMTP Client
-
- Provided with Anope is a simple SMTP client which can be used instead of
- programs like SendMail in some cases.
-
- The SMTP client can be used instead of sendmail for use with Anope's mail
- options. To use the SMTP client instead of sendmail, find the line in your
- services configuration file (services.conf) that defines sendmailpath. On
- that line, change the path to your services installation directory, then
- followed by "bin/anopesmtp" and the IP address of a valid SMTP server. It
- should look like this:
-
- sendmailpath = "/home/anope/services/bin/anopesmtp 127.0.0.1"
-
- If the SMTP client doesn't send mail, or if there's an other problem with
- it, you can enable debug mode by passing the --debug flag after the server
- address. This should generate a log file of what happened when it tried
- to connect to the SMTP server.
-
- Credits:
- Originally written by Dominick Meglio <codemastr@unrealircd.com>
- Ported to *nix by Trystan Scott Lee <trystan@nomadirc.net>
diff --git a/docs/WIN32.txt b/docs/WIN32.txt
index 2880cb0e0..104ef7441 100644
--- a/docs/WIN32.txt
+++ b/docs/WIN32.txt
@@ -103,7 +103,7 @@ Anope for Windows
INSTALL within the Solution Explorer. Right-click on INSTALL and choose Build.
When you have done this, all the files will be installed to where they belong.
- The only thing you need to do is rename "data/example.conf" to be "data/services.conf",
+ The only thing you need to do is rename "data/anope.example.conf" to be "data/anope.conf",
and then follow the steps to set up Anope.
You have now completed the building phase of Anope for Windows. You can
@@ -120,7 +120,7 @@ Anope for Windows
Notepad will cause strange characters to appear, and you may not be able to
edit the file correctly.
- Open services.conf, and read through it carefully and adjust the settings
+ Open anope.conf, and read through it carefully and adjust the settings
you think you need to adjust.
If you are unsure of the settings, you can go to the dos command prompt
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
index a434be6e1..763826344 100644
--- a/include/CMakeLists.txt
+++ b/include/CMakeLists.txt
@@ -3,7 +3,7 @@ set_source_files_properties(version.cpp PROPERTIES LANGUAGE CXX COMPILE_FLAGS "$
# Generate version-bin executable to modify version.h, setting it's linker flags as well
add_executable(version-bin version.cpp)
set_target_properties(version-bin PROPERTIES LINKER_LANGUAGE CXX LINK_FLAGS "${LDFLAGS}")
-get_target_property(version_BINARY version-bin LOCATION)
+set(version_BINARY "$<TARGET_FILE:version-bin>")
# 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.h ${CMAKE_CURRENT_BINARY_DIR}/build.h
@@ -16,49 +16,7 @@ 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)
-
-set(PCH_SOURCES_GCH "")
-if(USE_PCH AND CMAKE_COMPILER_IS_GNUCXX)
- string(REPLACE " " ";" PCH_CXXFLAGS "${CXXFLAGS} ${CMAKE_CXX_FLAGS}")
-
- file(GLOB PCH_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.h")
- sort_list(PCH_SOURCES)
-
- foreach(PCH_SOURCE ${PCH_SOURCES})
- find_includes(${PCH_SOURCE} INCLUDES)
- set(INCLUDES_LIST)
- append_to_list(INCLUDES_LIST ${PCH_SOURCE})
- foreach(INCLUDE ${INCLUDES})
- # Extract the filename from the #include line
- extract_include_filename(${INCLUDE} FILENAME QUOTE_TYPE)
- if(QUOTE_TYPE STREQUAL "quotes")
- find_in_list(PCH_SOURCES "${FILENAME}" FOUND)
- if(NOT FOUND EQUAL -1)
- append_to_list(INCLUDES_LIST ${FILENAME})
- endif(NOT FOUND EQUAL -1)
- endif(QUOTE_TYPE STREQUAL "quotes")
- endforeach(INCLUDE)
-
- set(PCH_EXTRAFLAGS "")
- if(DEBUG_BUILD)
- set(PCH_EXTRAFLAGS "-g")
- endif(DEBUG_BUILD)
- if(PCH_SOURCE STREQUAL "module.h")
- set(PCH_EXTRAFLAGS ${PCH_EXTRAFLAGS} -fPIC)
- endif(PCH_SOURCE STREQUAL "module.h")
- if(GETTEXT_INCLUDE)
- set(PCH_GETTEXT_INCLUDE "-I${GETTEXT_INCLUDE}")
- endif(GETTEXT_INCLUDE)
-
- set(PCH_SOURCES_GCH "${PCH_SOURCES_GCH};${CMAKE_CURRENT_BINARY_DIR}/${PCH_SOURCE}.gch")
- add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${PCH_SOURCE}.gch
- COMMAND ${CMAKE_CXX_COMPILER} ARGS ${PCH_CXXFLAGS} ${PCH_EXTRAFLAGS}
- ${PCH_GETTEXT_INCLUDE} -I${CMAKE_CURRENT_BINARY_DIR} -I${Anope_SOURCE_DIR}/modules/pseudoclients ${CMAKE_CURRENT_SOURCE_DIR}/${PCH_SOURCE} -o ${CMAKE_CURRENT_BINARY_DIR}/${PCH_SOURCE}.gch
- DEPENDS ${INCLUDES_LIST} VERBATIM
- )
- endforeach(PCH_SOURCE ${PCH_SOURCES})
-endif(USE_PCH AND CMAKE_COMPILER_IS_GNUCXX)
+endif()
# Add a custom target to the above file
-add_custom_target(headers DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/version.h ${CMAKE_CURRENT_BINARY_DIR}/build.h ${PCH_SOURCES_GCH})
+add_custom_target(headers DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/version.h ${CMAKE_CURRENT_BINARY_DIR}/build.h)
diff --git a/include/access.h b/include/access.h
index c668c6c38..f22e098bf 100644
--- a/include/access.h
+++ b/include/access.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef ACCESS_H
-#define ACCESS_H
+#pragma once
#include "services.h"
#include "anope.h"
@@ -85,6 +84,7 @@ class CoreExport ChanAccess : public Serializable
/* Channel this access entry is on */
Serialize::Reference<ChannelInfo> ci;
Anope::string creator;
+ Anope::string description;
time_t last_seen;
time_t created;
@@ -95,7 +95,7 @@ class CoreExport ChanAccess : public Serializable
const Anope::string &Mask() const;
NickCore *GetAccount() const;
- void Serialize(Serialize::Data &data) const anope_override;
+ void Serialize(Serialize::Data &data) const override;
static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
static const unsigned int MAX_DEPTH = 4;
@@ -170,5 +170,3 @@ class CoreExport AccessGroup
inline bool empty() const { return paths.empty(); }
};
-
-#endif
diff --git a/include/account.h b/include/account.h
index 16fe19646..d48b25872 100644
--- a/include/account.h
+++ b/include/account.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef ACCOUNT_H
-#define ACCOUNT_H
+#pragma once
#include "extensible.h"
#include "serialize.h"
@@ -20,7 +19,7 @@
typedef Anope::hash_map<NickAlias *> nickalias_map;
typedef Anope::hash_map<NickCore *> nickcore_map;
-typedef TR1NS::unordered_map<uint64_t, NickCore *> nickcoreid_map;
+typedef std::unordered_map<uint64_t, NickCore *> nickcoreid_map;
extern CoreExport Serialize::Checker<nickalias_map> NickAliasList;
extern CoreExport Serialize::Checker<nickcore_map> NickCoreList;
@@ -54,7 +53,7 @@ class CoreExport NickAlias : public Serializable, public Extensible
NickAlias(const Anope::string &nickname, NickCore *nickcore);
~NickAlias();
- void Serialize(Serialize::Data &data) const anope_override;
+ void Serialize(Serialize::Data &data) const override;
static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
/** Set a vhost for the user
@@ -149,7 +148,7 @@ class CoreExport NickCore : public Serializable, public Extensible
NickCore(const Anope::string &nickdisplay, uint64_t nickid = 0);
~NickCore();
- void Serialize(Serialize::Data &data) const anope_override;
+ void Serialize(Serialize::Data &data) const override;
static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
/** Changes the display for this account
@@ -240,8 +239,8 @@ class CoreExport IdentifyRequest
Anope::string password;
std::set<Module *> holds;
- bool dispatched;
- bool success;
+ bool dispatched = false;
+ bool success = false;
static std::set<IdentifyRequest *> Requests;
@@ -286,5 +285,3 @@ class CoreExport IdentifyRequest
static void ModuleUnload(Module *m);
};
-
-#endif // ACCOUNT_H
diff --git a/include/anope.h b/include/anope.h
index ed894c4ce..22094cf1d 100644
--- a/include/anope.h
+++ b/include/anope.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef ANOPE_H
-#define ANOPE_H
+#pragma once
#include <signal.h>
@@ -54,9 +53,7 @@ namespace Anope
string(const ci::string &_str) : _string(_str.c_str()) { }
string(const string &_str, size_type pos, size_type n = npos) : _string(_str._string, pos, n) { }
template <class InputIterator> string(InputIterator first, InputIterator last) : _string(first, last) { }
-#if __cplusplus >= 201103L
string(const string &) = default;
-#endif
/**
* Assignment operators, so any type of string can be assigned to this class.
@@ -257,8 +254,8 @@ namespace Anope
inline string lower() const
{
Anope::string new_string = *this;
- for (size_type i = 0; i < new_string.length(); ++i)
- new_string[i] = Anope::tolower(new_string[i]);
+ for (auto &chr : new_string)
+ chr = Anope::tolower(chr);
return new_string;
}
@@ -268,8 +265,8 @@ namespace Anope
inline string upper() const
{
Anope::string new_string = *this;
- for (size_type i = 0; i < new_string.length(); ++i)
- new_string[i] = Anope::toupper(new_string[i]);
+ for (auto &chr : new_string)
+ chr = Anope::toupper(chr);
return new_string;
}
@@ -315,7 +312,7 @@ namespace Anope
{
inline size_t operator()(const string &s) const
{
- return TR1NS::hash<std::string>()(s.lower().str());
+ return std::hash<std::string>()(s.lower().str());
}
};
@@ -323,7 +320,7 @@ namespace Anope
{
inline size_t operator()(const string &s) const
{
- return TR1NS::hash<std::string>()(s.str());
+ return std::hash<std::string>()(s.str());
}
};
@@ -337,7 +334,7 @@ namespace Anope
template<typename T> class map : public std::map<string, T, ci::less> { };
template<typename T> class multimap : public std::multimap<string, T, ci::less> { };
- template<typename T> class hash_map : public TR1NS::unordered_map<string, T, hash_ci, compare> { };
+ template<typename T> class hash_map : public std::unordered_map<string, T, hash_ci, compare> { };
#ifndef REPRODUCIBLE_BUILD
static const char *const compiled = __TIME__ " " __DATE__;
@@ -369,11 +366,11 @@ namespace Anope
*/
extern CoreExport bool ReadOnly, NoFork, NoThird, NoExpire, ProtocolDebug;
- /** The root of the services installation. Usually ~/services
+ /** The root of the Anope installation. Usually ~/anope
*/
extern CoreExport Anope::string ServicesDir;
- /** Services binary name (eg services)
+ /** Anope binary name (eg anope)
*/
extern CoreExport Anope::string ServicesBin;
@@ -465,14 +462,6 @@ namespace Anope
*/
extern CoreExport void Encrypt(const Anope::string &src, Anope::string &dest);
- /** Decrypts what is in 'src' to 'dest'.
- * @param src The source string to decrypt
- * @param dest The destination where the decrypted string is placed
- * @return true if decryption was successful. This is usually not the case
- * as most encryption methods we use are one way.
- */
- extern CoreExport bool Decrypt(const Anope::string &src, Anope::string &dest);
-
/** Hashes a buffer with SipHash-2-4
* @param src The start of the buffer to hash
* @param src_sz The total number of bytes in the buffer
@@ -577,7 +566,7 @@ class CoreExport sepstream
char sep;
/** Current string position
*/
- size_t pos;
+ size_t pos = 0;
/** If set then GetToken() can return an empty string
*/
bool allow_empty;
@@ -683,7 +672,7 @@ class CoreException : public std::exception
* Actually no, it does nothing. Never mind.
* @throws Nothing!
*/
- virtual ~CoreException() throw() { }
+ virtual ~CoreException() noexcept = default;
/** Returns the reason for the exception.
* The module should probably put something informative here as the user will see this upon failure.
*/
@@ -712,7 +701,7 @@ class ModuleException : public CoreException
* Actually no, it does nothing. Never mind.
* @throws Nothing!
*/
- virtual ~ModuleException() throw() { }
+ virtual ~ModuleException() noexcept = default;
};
class ConvertException : public CoreException
@@ -720,7 +709,7 @@ class ConvertException : public CoreException
public:
ConvertException(const Anope::string &reason = "") : CoreException(reason) { }
- virtual ~ConvertException() throw() { }
+ virtual ~ConvertException() noexcept = default;
};
/** Convert something to a string
@@ -794,5 +783,3 @@ template<typename T, typename O> inline T anope_dynamic_static_cast(O ptr)
return static_cast<T>(ptr);
}
#endif
-
-#endif // ANOPE_H
diff --git a/include/base.h b/include/base.h
index 819d3c116..a88877bc5 100644
--- a/include/base.h
+++ b/include/base.h
@@ -6,8 +6,7 @@
* Please read COPYING and README for further details.
*/
-#ifndef BASE_H
-#define BASE_H
+#pragma once
#include "services.h"
@@ -16,9 +15,8 @@
class CoreExport Base
{
/* References to this base class */
- std::set<ReferenceBase *> *references;
+ std::set<ReferenceBase *> *references = nullptr;
public:
- Base();
virtual ~Base();
/** Adds a reference to this object. Eg, when a Reference
@@ -33,11 +31,11 @@ class CoreExport Base
class ReferenceBase
{
protected:
- bool invalid;
+ bool invalid = false;
public:
- ReferenceBase() : invalid(false) { }
+ ReferenceBase() = default;
ReferenceBase(const ReferenceBase &other) : invalid(other.invalid) { }
- virtual ~ReferenceBase() { }
+ virtual ~ReferenceBase() = default;
inline void Invalidate() { this->invalid = true; }
};
@@ -48,11 +46,9 @@ template<typename T>
class Reference : public ReferenceBase
{
protected:
- T *ref;
+ T *ref = nullptr;
public:
- Reference() : ref(NULL)
- {
- }
+ Reference() = default;
Reference(T *obj) : ref(obj)
{
@@ -139,5 +135,3 @@ class Reference : public ReferenceBase
return false;
}
};
-
-#endif // BASE_H
diff --git a/include/bots.h b/include/bots.h
index 8c4aa2e7e..4b2f40ddf 100644
--- a/include/bots.h
+++ b/include/bots.h
@@ -6,8 +6,7 @@
* Please read COPYING and README for further details.
*/
-#ifndef BOTS_H
-#define BOTS_H
+#pragma once
#include "users.h"
#include "anope.h"
@@ -131,5 +130,3 @@ class CoreExport BotInfo : public User, public Serializable
*/
static BotInfo* Find(const Anope::string &nick, bool nick_only = false);
};
-
-#endif // BOTS_H
diff --git a/include/channels.h b/include/channels.h
index e3ce9acf1..da4ab33a4 100644
--- a/include/channels.h
+++ b/include/channels.h
@@ -6,8 +6,7 @@
* Please read COPYING and README for further details.
*/
-#ifndef CHANNELS_H
-#define CHANNELS_H
+#pragma once
#include "anope.h"
#include "extensible.h"
@@ -311,5 +310,3 @@ class CoreExport Channel : public Base, public Extensible
static void DeleteChannels();
};
-
-#endif // CHANNELS_H
diff --git a/include/commands.h b/include/commands.h
index b1fb4a4ae..451727500 100644
--- a/include/commands.h
+++ b/include/commands.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef COMMAND_H
-#define COMMAND_H
+#pragma once
#include "service.h"
#include "anope.h"
@@ -26,8 +25,6 @@ struct CommandInfo
{
typedef Anope::map<CommandInfo> map;
- CommandInfo() : hide(false), prepend_channel(false) { }
-
/* Service name of the command */
Anope::string name;
/* Permission required to execute the command */
@@ -35,9 +32,9 @@ struct CommandInfo
/* Group this command is in */
Anope::string group;
/* whether or not to hide this command in help output */
- bool hide;
+ bool hide = false;
/* Only used with fantasy */
- bool prepend_channel;
+ bool prepend_channel = false;
};
/* Where the replies from commands go to. User inherits from this and is the normal
@@ -45,7 +42,7 @@ struct CommandInfo
*/
struct CoreExport CommandReply
{
- virtual ~CommandReply() { }
+ virtual ~CommandReply() = default;
virtual void SendMessage(BotInfo *source, const Anope::string &msg) = 0;
};
@@ -120,7 +117,7 @@ class CoreExport Command : public Service
Command(Module *owner, const Anope::string &sname, size_t min_params, size_t max_params = 0);
public:
- virtual ~Command();
+ virtual ~Command() = default;
protected:
void SetDesc(const Anope::string &d);
@@ -183,5 +180,3 @@ class CoreExport Command : public Service
*/
static bool FindCommandFromService(const Anope::string &command_service, BotInfo* &bi, Anope::string &name);
};
-
-#endif // COMMANDS_H
diff --git a/include/config.h b/include/config.h
index f3e5d8816..bcd792adb 100644
--- a/include/config.h
+++ b/include/config.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef CONFIG_H
-#define CONFIG_H
+#pragma once
#include "account.h"
#include "regchannel.h"
@@ -66,7 +65,7 @@ namespace Configuration
}
bool Set(const Anope::string &tag, const Anope::string &value);
- const item_map* GetItems() const;
+ const item_map &GetItems() const;
};
template<> CoreExport const Anope::string Block::Get(const Anope::string &tag, const Anope::string& def) const;
@@ -83,7 +82,7 @@ namespace Configuration
{
Anope::string name;
bool executable;
- FILE *fp;
+ FILE *fp = nullptr;
public:
File(const Anope::string &, bool);
~File();
@@ -158,10 +157,10 @@ namespace Configuration
Anope::string host;
unsigned port;
Anope::string password;
- bool ipv6;
+ int protocol;
- Uplink(const Anope::string &_host, int _port, const Anope::string &_password, bool _ipv6) : host(_host), port(_port), password(_password), ipv6(_ipv6) { }
- inline bool operator==(const Uplink &other) const { return host == other.host && port == other.port && password == other.password && ipv6 == other.ipv6; }
+ Uplink(const Anope::string &_host, int _port, const Anope::string &_password, int _protocol) : host(_host), port(_port), password(_password), protocol(_protocol) { }
+ inline bool operator==(const Uplink &other) const { return host == other.host && port == other.port && password == other.password && protocol == other.protocol; }
inline bool operator!=(const Uplink &other) const { return !(*this == other); }
};
}
@@ -185,10 +184,8 @@ class ConfigException : public CoreException
* Actually no, it does nothing. Never mind.
* @throws Nothing!
*/
- virtual ~ConfigException() throw() { }
+ virtual ~ConfigException() noexcept = default;
};
extern Configuration::File ServicesConf;
extern CoreExport Configuration::Conf *Config;
-
-#endif // CONFIG_H
diff --git a/include/defs.h b/include/defs.h
index 2ce36f6e3..83ec924d9 100644
--- a/include/defs.h
+++ b/include/defs.h
@@ -9,6 +9,8 @@
* Based on the original code of Services by Andy Church.
*/
+#pragma once
+
class AccessGroup;
class AutoKick;
class BotInfo;
diff --git a/include/extensible.h b/include/extensible.h
index fee168bcc..317ea9f64 100644
--- a/include/extensible.h
+++ b/include/extensible.h
@@ -6,8 +6,7 @@
* Please read COPYING and README for further details.
*/
-#ifndef EXTENSIBLE_H
-#define EXTENSIBLE_H
+#pragma once
#include "anope.h"
#include "serialize.h"
@@ -93,7 +92,7 @@ class BaseExtensibleItem : public ExtensibleBase
return t;
}
- void Unset(Extensible *obj) anope_override
+ void Unset(Extensible *obj) override
{
T *value = Get(obj);
items.erase(obj);
@@ -128,7 +127,7 @@ template<typename T>
class ExtensibleItem : public BaseExtensibleItem<T>
{
protected:
- T* Create(Extensible *obj) anope_override
+ T* Create(Extensible *obj) override
{
return new T(obj);
}
@@ -140,7 +139,7 @@ template<typename T>
class PrimitiveExtensibleItem : public BaseExtensibleItem<T>
{
protected:
- T* Create(Extensible *obj) anope_override
+ T* Create(Extensible *obj) override
{
return new T();
}
@@ -152,7 +151,7 @@ template<>
class PrimitiveExtensibleItem<bool> : public BaseExtensibleItem<bool>
{
protected:
- bool* Create(Extensible *) anope_override
+ bool* Create(Extensible *) override
{
return NULL;
}
@@ -166,13 +165,13 @@ class SerializableExtensibleItem : public PrimitiveExtensibleItem<T>
public:
SerializableExtensibleItem(Module *m, const Anope::string &n) : PrimitiveExtensibleItem<T>(m, n) { }
- void ExtensibleSerialize(const Extensible *e, const Serializable *s, Serialize::Data &data) const anope_override
+ void ExtensibleSerialize(const Extensible *e, const Serializable *s, Serialize::Data &data) const override
{
T* t = this->Get(e);
data[this->name] << *t;
}
- void ExtensibleUnserialize(Extensible *e, Serializable *s, Serialize::Data &data) anope_override
+ void ExtensibleUnserialize(Extensible *e, Serializable *s, Serialize::Data &data) override
{
T t;
if (data[this->name] >> t)
@@ -188,12 +187,12 @@ class SerializableExtensibleItem<bool> : public PrimitiveExtensibleItem<bool>
public:
SerializableExtensibleItem(Module *m, const Anope::string &n) : PrimitiveExtensibleItem<bool>(m, n) { }
- void ExtensibleSerialize(const Extensible *e, const Serializable *s, Serialize::Data &data) const anope_override
+ void ExtensibleSerialize(const Extensible *e, const Serializable *s, Serialize::Data &data) const override
{
data[this->name] << true;
}
- void ExtensibleUnserialize(Extensible *e, Serializable *s, Serialize::Data &data) anope_override
+ void ExtensibleUnserialize(Extensible *e, Serializable *s, Serialize::Data &data) override
{
bool b = false;
data[this->name] >> b;
@@ -259,5 +258,3 @@ void Extensible::Shrink(const Anope::string &name)
else
Log(LOG_DEBUG) << "Shrink for nonexistent type " << name << " on " << static_cast<void *>(this);
}
-
-#endif // EXTENSIBLE_H
diff --git a/include/hashcomp.h b/include/hashcomp.h
index bc6c8a9b9..930717444 100644
--- a/include/hashcomp.h
+++ b/include/hashcomp.h
@@ -6,19 +6,11 @@
* Please read COPYING and README for further details.
*/
-#ifndef HASHCOMP_H
-#define HASHCOMP_H
+#pragma once
#include <string>
#include <locale>
-
-#if defined _LIBCPP_VERSION || defined _WIN32
#include <unordered_map>
-#define TR1NS std
-#else
-#include <tr1/unordered_map>
-#define TR1NS std::tr1
-#endif
#include "services.h"
@@ -29,16 +21,16 @@ namespace Anope
/* Casemap in use by Anope. ci::string's comparison functions use this (and thus Anope::string) */
extern std::locale casemap;
- extern void CaseMapRebuild();
- extern unsigned char tolower(unsigned char);
- extern unsigned char toupper(unsigned char);
+ extern CoreExport void CaseMapRebuild();
+ extern CoreExport unsigned char tolower(unsigned char);
+ extern CoreExport unsigned char toupper(unsigned char);
/* ASCII case insensitive ctype. */
template<typename char_type>
class ascii_ctype : public std::ctype<char_type>
{
public:
- char_type do_toupper(char_type c) const anope_override
+ char_type do_toupper(char_type c) const override
{
if (c >= 'a' && c <= 'z')
return c - 32;
@@ -46,7 +38,7 @@ namespace Anope
return c;
}
- char_type do_tolower(char_type c) const anope_override
+ char_type do_tolower(char_type c) const override
{
if (c >= 'A' && c <= 'Z')
return c + 32;
@@ -60,7 +52,7 @@ namespace Anope
class rfc1459_ctype : public ascii_ctype<char_type>
{
public:
- char_type do_toupper(char_type c) const anope_override
+ char_type do_toupper(char_type c) const override
{
if (c == '{' || c == '}' || c == '|')
return c - 32;
@@ -68,7 +60,7 @@ namespace Anope
return ascii_ctype<char_type>::do_toupper(c);
}
- char_type do_tolower(char_type c) const anope_override
+ char_type do_tolower(char_type c) const override
{
if (c == '[' || c == ']' || c == '\\')
return c + 32;
@@ -195,5 +187,3 @@ inline bool operator!=(const std::string &leftval, const ci::string &rightval)
{
return !(leftval.c_str() == rightval);
}
-
-#endif // HASHCOMP_H
diff --git a/include/language.h b/include/language.h
index 0ac0ef0c9..ef568ad94 100644
--- a/include/language.h
+++ b/include/language.h
@@ -6,12 +6,14 @@
* Please read COPYING and README for further details.
*/
+#pragma once
+
#include "anope.h"
namespace Language
{
- /* Languages we support as configured in services.conf. They are
+ /* Languages we support as configured in anope.conf. They are
* added to this list if we detect a language exists in the correct
* location for each language.
*/
@@ -70,10 +72,11 @@ namespace Language
#define READ_ONLY_MODE _("Services are in read-only mode!")
#define PASSWORD_INCORRECT _("Password incorrect.")
#define ACCESS_DENIED _("Access denied.")
-#define MORE_OBSCURE_PASSWORD _("Please try again with a more obscure password. Passwords should be at least\n" \
- "five characters long, should not be something easily guessed\n" \
- "(e.g. your real name or your nick), and cannot contain the space or tab characters.")
-#define PASSWORD_TOO_LONG _("Your password is too long. It must not exceed %u characters.")
+#define MORE_OBSCURE_PASSWORD _("Please try again with a more obscure password. Passwords should not be\n" \
+ "something that could be easily guessed (e.g. your real name or your nick) and\n" \
+ "cannot contain the space or tab characters.\n")
+#define PASSWORD_TOO_SHORT _("Your password is too short. It must must be longer than %u characters.")
+#define PASSWORD_TOO_LONG _("Your password is too long. It must be shorter than %u characters.")
#define NICK_NOT_REGISTERED _("Your nick isn't registered.")
#define NICK_X_NOT_REGISTERED _("Nick \002%s\002 isn't registered.")
#define NICK_X_NOT_IN_USE _("Nick \002%s\002 isn't currently in use.")
diff --git a/include/lists.h b/include/lists.h
index 5f4605bc7..6e134d7ca 100644
--- a/include/lists.h
+++ b/include/lists.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef LISTS_H
-#define LISTS_H
+#pragma once
#include "services.h"
#include "anope.h"
@@ -25,7 +24,7 @@
class CoreExport NumberList
{
private:
- bool is_valid;
+ bool is_valid = true;
std::set<unsigned> numbers;
@@ -39,7 +38,7 @@ class CoreExport NumberList
/** Destructor, does nothing
*/
- virtual ~NumberList();
+ virtual ~NumberList() = default;
/** Should be called after the constructors are done running. This calls the callbacks.
*/
@@ -83,12 +82,10 @@ class CoreExport InfoFormatter
{
NickCore *nc;
std::vector<std::pair<Anope::string, Anope::string> > replies;
- unsigned longest;
+ unsigned longest = 0;
public:
InfoFormatter(NickCore *nc);
void Process(std::vector<Anope::string> &);
Anope::string &operator[](const Anope::string &key);
void AddOption(const Anope::string &opt);
};
-
-#endif // LISTS_H
diff --git a/include/logger.h b/include/logger.h
index e82bca52d..c23b00666 100644
--- a/include/logger.h
+++ b/include/logger.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef LOGGER_H
-#define LOGGER_H
+#pragma once
#include "anope.h"
#include "defs.h"
@@ -53,23 +52,23 @@ class CoreExport Log
{
public:
/* Bot that should log this message */
- BotInfo *bi;
+ BotInfo *bi = nullptr;
/* For commands, the user executing the command, but might not always exist */
- User *u;
+ User *u = nullptr;
/* For commands, the account executing the command, but will not always exist */
- NickCore *nc;
+ NickCore *nc = nullptr;
/* For commands, the command being executed */
- Command *c;
+ Command *c = nullptr;
/* For commands, the command source */
- CommandSource *source;
+ CommandSource *source = nullptr;
/* Used for LOG_CHANNEL */
- Channel *chan;
+ Channel *chan = nullptr;
/* For commands, the channel the command was executed on, will not always exist */
- const ChannelInfo *ci;
+ const ChannelInfo *ci = nullptr;
/* For LOG_SERVER */
- Server *s;
+ Server *s = nullptr;
/* For LOG_MODULE */
- Module *m;
+ Module *m = nullptr;
LogType type;
Anope::string category;
@@ -113,10 +112,10 @@ class CoreExport Log
class CoreExport LogInfo
{
public:
- BotInfo *bot;
+ BotInfo *bot = nullptr;
std::vector<Anope::string> targets;
std::vector<LogFile *> logfiles;
- int last_day;
+ int last_day = 0;
std::vector<Anope::string> sources;
int log_age;
std::vector<Anope::string> admin;
@@ -140,5 +139,3 @@ class CoreExport LogInfo
/* Logs the message l if configured to */
void ProcessMessage(const Log *l);
};
-
-#endif // LOGGER_H
diff --git a/include/mail.h b/include/mail.h
index 1e24183fe..e06357825 100644
--- a/include/mail.h
+++ b/include/mail.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef MAIL_H
-#define MAIL_H
+#pragma once
#include "anope.h"
#include "threadengine.h"
@@ -35,7 +34,7 @@ namespace Mail
Anope::string content_type;
bool dont_quote_addresses;
- bool success;
+ bool success = false;
public:
/** Construct this message. Once constructed call Thread::Start to launch the mail sending.
* @param sf Config->SendFrom
@@ -49,9 +48,7 @@ namespace Mail
~Message();
/* Called from within the thread to actually send the mail */
- void Run() anope_override;
+ void Run() override;
};
} // namespace Mail
-
-#endif // MAIL_H
diff --git a/include/memo.h b/include/memo.h
index c6a1ec2d9..e97cc9da0 100644
--- a/include/memo.h
+++ b/include/memo.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef MEMO_H
-#define MEMO_H
+#pragma once
#include "anope.h"
#include "serialize.h"
@@ -24,7 +23,7 @@ class CoreExport Memo : public Serializable
Memo();
~Memo();
- void Serialize(Serialize::Data &data) const anope_override;
+ void Serialize(Serialize::Data &data) const override;
static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
Anope::string owner;
@@ -39,7 +38,7 @@ class CoreExport Memo : public Serializable
*/
struct CoreExport MemoInfo
{
- int16_t memomax;
+ int16_t memomax = 0;
Serialize::Checker<std::vector<Memo *> > memos;
std::vector<Anope::string> ignores;
@@ -51,5 +50,3 @@ struct CoreExport MemoInfo
static MemoInfo *GetMemoInfo(const Anope::string &targ, bool &is_chan);
};
-
-#endif // MEMO_H
diff --git a/include/messages.h b/include/messages.h
index 4efb74acb..85ce8effa 100644
--- a/include/messages.h
+++ b/include/messages.h
@@ -9,6 +9,8 @@
* Based on the original code of Services by Andy Church.
*/
+#pragma once
+
#include "protocol.h"
/* Common IRCD messages.
@@ -23,35 +25,35 @@ namespace Message
{
Away(Module *creator, const Anope::string &mname = "AWAY") : IRCDMessage(creator, mname, 0) { SetFlag(IRCDMESSAGE_REQUIRE_USER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override;
};
struct CoreExport Capab : IRCDMessage
{
Capab(Module *creator, const Anope::string &mname = "CAPAB") : IRCDMessage(creator, mname, 1) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override;
};
struct CoreExport Error : IRCDMessage
{
Error(Module *creator, const Anope::string &mname = "ERROR") : IRCDMessage(creator, mname, 1) { }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override;
};
struct CoreExport Invite : IRCDMessage
{
Invite(Module *creator, const Anope::string &mname = "INVITE") : IRCDMessage(creator, mname, 2) { SetFlag(IRCDMESSAGE_REQUIRE_USER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override;
};
struct CoreExport Join : IRCDMessage
{
Join(Module *creator, const Anope::string &mname = "JOIN") : IRCDMessage(creator, mname, 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override;
typedef std::pair<ChannelStatus, User *> SJoinUser;
@@ -69,105 +71,105 @@ namespace Message
{
Kick(Module *creator, const Anope::string &mname = "KICK") : IRCDMessage(creator, mname, 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override;
};
struct CoreExport Kill : IRCDMessage
{
Kill(Module *creator, const Anope::string &mname = "KILL") : IRCDMessage(creator, mname, 2) { }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override;
};
struct CoreExport Mode : IRCDMessage
{
Mode(Module *creator, const Anope::string &mname = "MODE") : IRCDMessage(creator, mname, 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override;
};
struct CoreExport MOTD : IRCDMessage
{
MOTD(Module *creator, const Anope::string &mname = "MOTD") : IRCDMessage(creator, mname, 1) { }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override;
};
struct CoreExport Notice : IRCDMessage
{
Notice(Module *creator, const Anope::string &mname = "NOTICE") : IRCDMessage(creator, mname, 2) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override;
};
struct CoreExport Part : IRCDMessage
{
Part(Module *creator, const Anope::string &mname = "PART") : IRCDMessage(creator, mname, 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override;
};
struct CoreExport Ping : IRCDMessage
{
Ping(Module *creator, const Anope::string &mname = "PING") : IRCDMessage(creator, mname, 1) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override;
};
struct CoreExport Privmsg : IRCDMessage
{
Privmsg(Module *creator, const Anope::string &mname = "PRIVMSG") : IRCDMessage(creator, mname, 2) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override;
};
struct CoreExport Quit : IRCDMessage
{
Quit(Module *creator, const Anope::string &mname = "QUIT") : IRCDMessage(creator, mname, 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override;
};
struct CoreExport SQuit : IRCDMessage
{
SQuit(Module *creator, const Anope::string &mname = "SQUIT") : IRCDMessage(creator, mname, 2) { }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override;
};
struct CoreExport Stats : IRCDMessage
{
Stats(Module *creator, const Anope::string &mname = "STATS") : IRCDMessage(creator, mname, 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override;
};
struct CoreExport Time : IRCDMessage
{
Time(Module *creator, const Anope::string &mname = "TIME") : IRCDMessage(creator, mname, 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override;
};
struct CoreExport Topic : IRCDMessage
{
Topic(Module *creator, const Anope::string &mname = "TOPIC") : IRCDMessage(creator, mname, 2) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override;
};
struct CoreExport Version : IRCDMessage
{
Version(Module *creator, const Anope::string &mname = "VERSION") : IRCDMessage(creator, mname, 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override;
};
struct CoreExport Whois : IRCDMessage
{
Whois(Module *creator, const Anope::string &mname = "WHOIS") : IRCDMessage(creator, mname, 1) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override;
};
} // namespace Message
diff --git a/include/modes.h b/include/modes.h
index 134fb04b2..3c34a6b31 100644
--- a/include/modes.h
+++ b/include/modes.h
@@ -6,8 +6,7 @@
* Please read COPYING and README for further details.
*/
-#ifndef MODES_H
-#define MODES_H
+#pragma once
#include "anope.h"
#include "base.h"
@@ -55,7 +54,7 @@ class CoreExport Mode : public Base
* @param type The mode type
*/
Mode(const Anope::string &mname, ModeClass mclass, char mc, ModeType type);
- virtual ~Mode();
+ virtual ~Mode() = default;
/** Can a user set this mode, used for mlock
* @param u The user
@@ -105,7 +104,7 @@ class CoreExport ChannelMode : public Mode
*/
ChannelMode(const Anope::string &name, char mc);
- bool CanSet(User *u) const anope_override;
+ bool CanSet(User *u) const override;
virtual void Check() { }
@@ -217,11 +216,11 @@ class CoreExport ChannelModeVirtual : public T
~ChannelModeVirtual();
- void Check() anope_override;
+ void Check() override;
- ChannelMode *Wrap(Anope::string &param) anope_override;
+ ChannelMode *Wrap(Anope::string &param) override;
- ChannelMode *Unwrap(ChannelMode *cm, Anope::string &param) anope_override = 0;
+ ChannelMode *Unwrap(ChannelMode *cm, Anope::string &param) override = 0;
};
/* The status a user has on a channel (+v, +h, +o) etc */
@@ -229,7 +228,7 @@ class CoreExport ChannelStatus
{
Anope::string modes;
public:
- ChannelStatus();
+ ChannelStatus() = default;
ChannelStatus(const Anope::string &modes);
void AddMode(char c);
void DelMode(char c);
@@ -245,7 +244,7 @@ class CoreExport UserModeOperOnly : public UserMode
public:
UserModeOperOnly(const Anope::string &mname, char um) : UserMode(mname, um) { }
- bool CanSet(User *u) const anope_override;
+ bool CanSet(User *u) const override;
};
class CoreExport UserModeNoone : public UserMode
@@ -253,7 +252,7 @@ class CoreExport UserModeNoone : public UserMode
public:
UserModeNoone(const Anope::string &mname, char um) : UserMode(mname, um) { }
- bool CanSet(User *u) const anope_override;
+ bool CanSet(User *u) const override;
};
/** Channel mode +k (key)
@@ -263,7 +262,7 @@ class CoreExport ChannelModeKey : public ChannelModeParam
public:
ChannelModeKey(char mc) : ChannelModeParam("KEY", mc) { }
- bool IsValid(Anope::string &value) const anope_override;
+ bool IsValid(Anope::string &value) const override;
};
/** This class is used for oper only channel modes
@@ -274,7 +273,7 @@ class CoreExport ChannelModeOperOnly : public ChannelMode
ChannelModeOperOnly(const Anope::string &mname, char mc) : ChannelMode(mname, mc) { }
/* Opers only */
- bool CanSet(User *u) const anope_override;
+ bool CanSet(User *u) const override;
};
/** This class is used for channel modes only servers may set
@@ -284,7 +283,7 @@ class CoreExport ChannelModeNoone : public ChannelMode
public:
ChannelModeNoone(const Anope::string &mname, char mc) : ChannelMode(mname, mc) { }
- bool CanSet(User *u) const anope_override;
+ bool CanSet(User *u) const override;
};
/** This is the mode manager
@@ -394,8 +393,8 @@ class CoreExport Entry
Anope::string name;
Anope::string mask;
public:
- unsigned short cidr_len;
- int family;
+ unsigned short cidr_len = 0;
+ int family = 0;
Anope::string nick, user, host, real;
/** Constructor
@@ -418,5 +417,3 @@ class CoreExport Entry
*/
bool Matches(User *u, bool full = false) const;
};
-
-#endif // MODES_H
diff --git a/include/module.h b/include/module.h
index b9a1e6a2f..d1c68cb7c 100644
--- a/include/module.h
+++ b/include/module.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef MODULE_H
-#define MODULE_H
+#pragma once
#include "access.h"
#include "account.h"
@@ -50,5 +49,3 @@
#include "modules/pseudoclients/global.h"
#include "modules/pseudoclients/memoserv.h"
#include "modules/pseudoclients/nickserv.h"
-
-#endif // MODULE_H
diff --git a/include/modules.h b/include/modules.h
index 659804b1d..13030bca2 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -9,11 +9,10 @@
* Based on the original code of Services by Andy Church.
*/
-#include "serialize.h"
-#ifndef MODULES_H
-#define MODULES_H
+#pragma once
+#include "serialize.h"
#include "base.h"
#include "modes.h"
#include "timers.h"
@@ -25,32 +24,7 @@
* and functions needed to make a module loadable by the OS.
* It defines the class factory and external AnopeInit and AnopeFini functions.
*/
-#ifdef _WIN32
-# define MODULE_INIT(x) \
- extern "C" DllExport Module *AnopeInit(const Anope::string &, const Anope::string &); \
- extern "C" Module *AnopeInit(const Anope::string &modname, const Anope::string &creator) \
- { \
- return new x(modname, creator); \
- } \
- BOOLEAN WINAPI DllMain(HINSTANCE, DWORD, LPVOID) \
- { \
- return TRUE; \
- } \
- extern "C" DllExport void AnopeFini(x *); \
- extern "C" void AnopeFini(x *m) \
- { \
- delete m; \
- } \
- extern "C" DllExport ModuleVersionC AnopeVersion() \
- { \
- ModuleVersionC ver; \
- ver.version_major = VERSION_MAJOR; \
- ver.version_minor = VERSION_MINOR; \
- ver.version_patch = VERSION_PATCH; \
- return ver; \
- }
-#else
-# define MODULE_INIT(x) \
+#define MODULE_INIT(x) \
extern "C" DllExport Module *AnopeInit(const Anope::string &modname, const Anope::string &creator) \
{ \
return new x(modname, creator); \
@@ -67,7 +41,6 @@
ver.version_patch = VERSION_PATCH; \
return ver; \
}
-#endif
/**
* This #define allows us to call a method in all
@@ -322,7 +295,7 @@ class CoreExport Module : public Extensible
*/
virtual void OnUserKicked(const MessageSource &source, User *target, const Anope::string &channel, ChannelStatus &status, const Anope::string &kickmsg) { throw NotImplementedException(); }
- /** Called when Services' configuration is being (re)loaded.
+ /** Called when the configuration is being (re)loaded.
* @param conf The config that is being built now and will replace the global Config object
* @throws A ConfigException to abort the config (re)loading process.
*/
@@ -405,7 +378,6 @@ class CoreExport Module : public Extensible
* see src/encrypt.c for detailed informations
*/
virtual EventReturn OnEncrypt(const Anope::string &src, Anope::string &dest) { throw NotImplementedException(); }
- virtual EventReturn OnDecrypt(const Anope::string &hashm, const Anope::string &src, Anope::string &dest) { throw NotImplementedException(); }
/** Called on fantasy command
* @param source The source of the command
@@ -1235,5 +1207,3 @@ class CoreExport ModuleManager
*/
static ModuleVersion GetVersion(void *handle);
};
-
-#endif // MODULES_H
diff --git a/include/modules/bs_badwords.h b/include/modules/bs_badwords.h
index 9f9f017e1..ef773269f 100644
--- a/include/modules/bs_badwords.h
+++ b/include/modules/bs_badwords.h
@@ -9,6 +9,8 @@
* Based on the original code of Services by Andy Church.
*/
+#pragma once
+
/** Flags for badwords
*/
enum BadWordType
@@ -30,14 +32,14 @@ struct BadWord
Anope::string word;
BadWordType type;
- virtual ~BadWord() { }
+ virtual ~BadWord() = default;
protected:
- BadWord() { }
+ BadWord() = default;
};
struct BadWords
{
- virtual ~BadWords() { }
+ virtual ~BadWords() = default;
/** Add a badword to the badword list
* @param word The badword
diff --git a/include/modules/bs_kick.h b/include/modules/bs_kick.h
index 4108b0603..c296e9221 100644
--- a/include/modules/bs_kick.h
+++ b/include/modules/bs_kick.h
@@ -9,6 +9,8 @@
* Based on the original code of Services by Andy Church.
*/
+#pragma once
+
/* Indices for TTB (Times To Ban) */
enum
{
@@ -36,9 +38,9 @@ struct KickerData
bool dontkickops, dontkickvoices;
protected:
- KickerData() { }
+ KickerData() = default;
public:
- virtual ~KickerData() { }
+ virtual ~KickerData() = default;
virtual void Check(ChannelInfo *ci) = 0;
};
diff --git a/include/modules/cs_entrymsg.h b/include/modules/cs_entrymsg.h
index 89ffe39ff..e3586d5e9 100644
--- a/include/modules/cs_entrymsg.h
+++ b/include/modules/cs_entrymsg.h
@@ -6,6 +6,8 @@
* Please read COPYING and README for further details.
*/
+#pragma once
+
struct EntryMsg
{
Anope::string chan;
@@ -13,9 +15,9 @@ struct EntryMsg
Anope::string message;
time_t when;
- virtual ~EntryMsg() { }
+ virtual ~EntryMsg() = default;
protected:
- EntryMsg() { }
+ EntryMsg() = default;
};
struct EntryMessageList : Serialize::Checker<std::vector<EntryMsg *> >
diff --git a/include/modules/cs_log.h b/include/modules/cs_log.h
index ba2953e60..e283beabb 100644
--- a/include/modules/cs_log.h
+++ b/include/modules/cs_log.h
@@ -9,6 +9,8 @@
* Based on the original code of Services by Andy Church.
*/
+#pragma once
+
struct LogSetting
{
Anope::string chan;
@@ -22,9 +24,9 @@ struct LogSetting
Anope::string creator;
time_t created;
- virtual ~LogSetting() { }
+ virtual ~LogSetting() = default;
protected:
- LogSetting() { }
+ LogSetting() = default;
};
struct LogSettings : Serialize::Checker<std::vector<LogSetting *> >
@@ -37,6 +39,6 @@ struct LogSettings : Serialize::Checker<std::vector<LogSetting *> >
}
public:
- virtual ~LogSettings() { }
+ virtual ~LogSettings() = default;
virtual LogSetting *Create() = 0;
};
diff --git a/include/modules/cs_mode.h b/include/modules/cs_mode.h
index 3904d2f4d..e62042d04 100644
--- a/include/modules/cs_mode.h
+++ b/include/modules/cs_mode.h
@@ -9,6 +9,8 @@
* Based on the original code of Services by Andy Church.
*/
+#pragma once
+
struct ModeLock
{
Anope::string ci;
@@ -18,16 +20,16 @@ struct ModeLock
Anope::string setter;
time_t created;
- virtual ~ModeLock() { }
+ virtual ~ModeLock() = default;
protected:
- ModeLock() { }
+ ModeLock() = default;
};
struct ModeLocks
{
typedef std::vector<ModeLock *> ModeList;
- virtual ~ModeLocks() { }
+ virtual ~ModeLocks() = default;
/** Check if a mode is mlocked
* @param mode The mode
diff --git a/include/modules/dns.h b/include/modules/dns.h
index 5139f7e16..1c5941588 100644
--- a/include/modules/dns.h
+++ b/include/modules/dns.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef DNS_H
-#define DNS_H
+#pragma once
namespace DNS
{
@@ -73,10 +72,10 @@ namespace DNS
struct Question
{
Anope::string name;
- QueryType type;
- unsigned short qclass;
+ QueryType type = QUERY_NONE;
+ unsigned short qclass = 0;
- Question() : type(QUERY_NONE), qclass(0) { }
+ Question() = default;
Question(const Anope::string &n, QueryType t, unsigned short c = 1) : name(n), type(t), qclass(c) { }
inline bool operator==(const Question & other) const { return name == other.name && type == other.type && qclass == other.qclass; }
@@ -91,12 +90,12 @@ namespace DNS
struct ResourceRecord : Question
{
- unsigned int ttl;
+ unsigned int ttl = 0;
Anope::string rdata;
time_t created;
- ResourceRecord(const Anope::string &n, QueryType t, unsigned short c = 1) : Question(n, t, c), ttl(0), created(Anope::CurTime) { }
- ResourceRecord(const Question &q) : Question(q), ttl(0), created(Anope::CurTime) { }
+ ResourceRecord(const Anope::string &n, QueryType t, unsigned short c = 1) : Question(n, t, c), created(Anope::CurTime) { }
+ ResourceRecord(const Question &q) : Question(q), created(Anope::CurTime) { }
};
struct Query
@@ -118,7 +117,7 @@ namespace DNS
{
public:
Manager(Module *creator) : Service(creator, "DNS::Manager", "dns/manager") { }
- virtual ~Manager() { }
+ virtual ~Manager() = default;
virtual void Process(Request *req) = 0;
virtual void RemoveRequest(Request *req) = 0;
@@ -139,12 +138,12 @@ namespace DNS
/* Use result cache if available */
bool use_cache;
/* Request id */
- unsigned short id;
+ unsigned short id = 0;
/* Creator of this request */
Module *creator;
Request(Manager *mgr, Module *c, const Anope::string &addr, QueryType qt, bool cache = false) : Timer(0), Question(addr, qt), manager(mgr),
- use_cache(cache), id(0), creator(c) { }
+ use_cache(cache), creator(c) { }
virtual ~Request()
{
@@ -164,7 +163,7 @@ namespace DNS
/** Used to time out the query, xalls OnError and lets the TimerManager
* delete this request.
*/
- void Tick(time_t) anope_override
+ void Tick(time_t) override
{
Log(LOG_DEBUG_2) << "Resolver: timeout for query " << this->name;
Query rr(*this);
@@ -174,5 +173,3 @@ namespace DNS
};
} // namespace DNS
-
-#endif // DNS_H
diff --git a/include/modules/encryption.h b/include/modules/encryption.h
index 68f92ce12..70bf6fb08 100644
--- a/include/modules/encryption.h
+++ b/include/modules/encryption.h
@@ -9,6 +9,8 @@
* Based on the original code of Services by Andy Church.
*/
+#pragma once
+
namespace Encryption
{
typedef std::pair<const unsigned char *, size_t> Hash;
@@ -17,7 +19,7 @@ namespace Encryption
class Context
{
public:
- virtual ~Context() { }
+ virtual ~Context() = default;
virtual void Update(const unsigned char *data, size_t len) = 0;
virtual void Finalize() = 0;
virtual Hash GetFinalizedHash() = 0;
@@ -27,7 +29,7 @@ namespace Encryption
{
public:
Provider(Module *creator, const Anope::string &sname) : Service(creator, "Encryption::Provider", sname) { }
- virtual ~Provider() { }
+ virtual ~Provider() = default;
virtual Context *CreateContext(IV * = NULL) = 0;
virtual IV GetDefaultIV() = 0;
diff --git a/include/modules/httpd.h b/include/modules/httpd.h
index 1637f9961..207499d3b 100644
--- a/include/modules/httpd.h
+++ b/include/modules/httpd.h
@@ -6,8 +6,7 @@
* Please read COPYING and README for further details.
*/
-#ifndef ANOPE_HTTPD_H
-#define ANOPE_HTTPD_H
+#pragma once
enum HTTPError
{
@@ -21,13 +20,14 @@ enum HTTPError
/* A message to someone */
struct HTTPReply
{
- HTTPError error;
+ HTTPError error = HTTP_ERROR_OK;
Anope::string content_type;
std::map<Anope::string, Anope::string, ci::less> headers;
typedef std::list<std::pair<Anope::string, Anope::string> > cookie;
std::vector<cookie> cookies;
- HTTPReply() : error(HTTP_ERROR_OK), length(0) { }
+ HTTPReply() = default;
+ HTTPReply& operator=(const HTTPReply &) = default;
HTTPReply(const HTTPReply& other) : error(other.error), length(other.length)
{
@@ -35,14 +35,14 @@ struct HTTPReply
headers = other.headers;
cookies = other.cookies;
- for (unsigned i = 0; i < other.out.size(); ++i)
- out.push_back(new Data(other.out[i]->buf, other.out[i]->len));
+ for (const auto &datum : other.out)
+ out.push_back(new Data(datum->buf, datum->len));
}
~HTTPReply()
{
- for (unsigned i = 0; i < out.size(); ++i)
- delete out[i];
+ for (const auto *datum : out)
+ delete datum;
out.clear();
}
@@ -65,7 +65,7 @@ struct HTTPReply
};
std::deque<Data *> out;
- size_t length;
+ size_t length = 0;
void Write(const Anope::string &message)
{
@@ -93,7 +93,7 @@ struct HTTPMessage
class HTTPClient;
class HTTPProvider;
-class HTTPPage : public Base
+class HTTPPage : public virtual Base
{
Anope::string url;
Anope::string content_type;
@@ -196,10 +196,8 @@ namespace HTTPUtils
{
Anope::string encoded;
- for (unsigned i = 0; i < url.length(); ++i)
+ for (const auto c : url)
{
- const char& c = url[i];
-
if (isalnum(c) || c == '.' || c == '-' || c == '*' || c == '_')
encoded += c;
else if (c == ' ')
@@ -215,9 +213,9 @@ namespace HTTPUtils
{
Anope::string dst;
- for (unsigned i = 0; i < src.length(); ++i)
+ for (const auto c : src)
{
- switch (src[i])
+ switch (c)
{
case '<':
dst += "&lt;";
@@ -232,12 +230,10 @@ namespace HTTPUtils
dst += "&amp;";
break;
default:
- dst += src[i];
+ dst += c;
}
}
return dst;
}
}
-
-#endif // ANOPE_HTTPD_H
diff --git a/include/modules/ldap.h b/include/modules/ldap.h
index 2f5382a0b..34f73f65b 100644
--- a/include/modules/ldap.h
+++ b/include/modules/ldap.h
@@ -6,15 +6,14 @@
* Please read COPYING and README for further details.
*/
-#ifndef ANOPE_LDAP_H
-#define ANOPE_LDAP_H
+#pragma once
class LDAPException : public ModuleException
{
public:
LDAPException(const Anope::string &reason) : ModuleException(reason) { }
- virtual ~LDAPException() throw() { }
+ virtual ~LDAPException() noexcept = default;
};
struct LDAPModification
@@ -43,8 +42,8 @@ struct LDAPAttributes : public std::map<Anope::string, std::vector<Anope::string
const std::vector<Anope::string> keys() const
{
std::vector<Anope::string> k;
- for (const_iterator it = this->begin(), it_end = this->end(); it != it_end; ++it)
- k.push_back(it->first);
+ for (const auto &[key, _] : *this)
+ k.push_back(key);
return k;
}
@@ -116,7 +115,7 @@ class LDAPInterface
Module *owner;
LDAPInterface(Module *m) : owner(m) { }
- virtual ~LDAPInterface() { }
+ virtual ~LDAPInterface() = default;
virtual void OnResult(const LDAPResult &r) = 0;
virtual void OnError(const LDAPResult &err) = 0;
@@ -167,5 +166,3 @@ class LDAPProvider : public Service
*/
virtual void Modify(LDAPInterface *i, const Anope::string &base, LDAPMods &attributes) = 0;
};
-
-#endif // ANOPE_LDAP_H
diff --git a/include/modules/ns_cert.h b/include/modules/ns_cert.h
index 946467520..824964ba8 100644
--- a/include/modules/ns_cert.h
+++ b/include/modules/ns_cert.h
@@ -9,12 +9,14 @@
* Based on the original code of Services by Andy Church.
*/
+#pragma once
+
struct NSCertList
{
protected:
- NSCertList() { }
+ NSCertList() = default;
public:
- virtual ~NSCertList() { }
+ virtual ~NSCertList() = default;
/** Add an entry to the nick's certificate list
*
diff --git a/include/modules/os_forbid.h b/include/modules/os_forbid.h
index eacf3425c..35dfc5c7f 100644
--- a/include/modules/os_forbid.h
+++ b/include/modules/os_forbid.h
@@ -6,8 +6,7 @@
* Please read COPYING and README for further details.
*/
-#ifndef OS_FORBID_H
-#define OS_FORBID_H
+#pragma once
enum ForbidType
{
@@ -23,13 +22,13 @@ struct ForbidData
Anope::string mask;
Anope::string creator;
Anope::string reason;
- time_t created;
- time_t expires;
+ time_t created = 0;
+ time_t expires = 0;
ForbidType type;
- virtual ~ForbidData() { }
+ virtual ~ForbidData() = default;
protected:
- ForbidData() : created(0), expires(0) { }
+ ForbidData() = default;
};
class ForbidService : public Service
@@ -51,5 +50,3 @@ class ForbidService : public Service
};
static ServiceReference<ForbidService> forbid_service("ForbidService", "forbid");
-
-#endif
diff --git a/include/modules/os_ignore.h b/include/modules/os_ignore.h
index 0d7ebc04d..14b71f9ac 100644
--- a/include/modules/os_ignore.h
+++ b/include/modules/os_ignore.h
@@ -9,16 +9,18 @@
* Based on the original code of Services by Andy Church.
*/
+#pragma once
+
struct IgnoreData
{
Anope::string mask;
Anope::string creator;
Anope::string reason;
- time_t time; /* When do we stop ignoring them? */
+ time_t time = 0; /* When do we stop ignoring them? */
- virtual ~IgnoreData() { }
+ virtual ~IgnoreData() = default;
protected:
- IgnoreData() : time(0) { }
+ IgnoreData() = default;
};
class IgnoreService : public Service
diff --git a/include/modules/os_news.h b/include/modules/os_news.h
index 06703939b..10228e82a 100644
--- a/include/modules/os_news.h
+++ b/include/modules/os_news.h
@@ -6,8 +6,7 @@
* Please read COPYING and README for further details.
*/
-#ifndef OS_NEWS
-#define OS_NEWS
+#pragma once
enum NewsType
{
@@ -48,5 +47,3 @@ class NewsService : public Service
};
static ServiceReference<NewsService> news_service("NewsService", "news");
-
-#endif // OS_NEWS
diff --git a/include/modules/os_session.h b/include/modules/os_session.h
index ce12f7758..eb8c2aaca 100644
--- a/include/modules/os_session.h
+++ b/include/modules/os_session.h
@@ -6,16 +6,15 @@
* Please read COPYING and README for further details.
*/
-#ifndef OS_SESSION_H
-#define OS_SESSION_H
+#pragma once
struct Session
{
cidr addr; /* A cidr (sockaddrs + len) representing this session */
- unsigned count; /* Number of clients with this host */
- unsigned hits; /* Number of subsequent kills for a host */
+ unsigned count = 1; /* Number of clients with this host */
+ unsigned hits = 0; /* Number of subsequent kills for a host */
- Session(const sockaddrs &ip, int len) : addr(ip, len), count(1), hits(0) { }
+ Session(const sockaddrs &ip, int len) : addr(ip, len) { }
};
struct Exception : Serializable
@@ -28,14 +27,14 @@ struct Exception : Serializable
time_t expires; /* Time when it expires. 0 == no expiry */
Exception() : Serializable("Exception") { }
- void Serialize(Serialize::Data &data) const anope_override;
+ void Serialize(Serialize::Data &data) const override;
static Serializable* Unserialize(Serializable *obj, Serialize::Data &data);
};
class SessionService : public Service
{
public:
- typedef TR1NS::unordered_map<cidr, Session *, cidr::hash> SessionMap;
+ typedef std::unordered_map<cidr, Session *, cidr::hash> SessionMap;
typedef std::vector<Exception *> ExceptionVector;
SessionService(Module *m) : Service(m, "SessionService", "session") { }
@@ -90,5 +89,3 @@ Serializable* Exception::Unserialize(Serializable *obj, Serialize::Data &data)
session_service->AddException(ex);
return ex;
}
-
-#endif
diff --git a/include/modules/pseudoclients/chanserv.h b/include/modules/pseudoclients/chanserv.h
index befd42fd8..013596ed9 100644
--- a/include/modules/pseudoclients/chanserv.h
+++ b/include/modules/pseudoclients/chanserv.h
@@ -6,8 +6,7 @@
* Please read COPYING and README for further details.
*/
-#ifndef CHANSERV_H
-#define CHANSERV_H
+#pragma once
class ChanServService : public Service
{
@@ -21,5 +20,3 @@ class ChanServService : public Service
*/
virtual void Hold(Channel *c) = 0;
};
-
-#endif // CHANSERV_H
diff --git a/include/modules/pseudoclients/global.h b/include/modules/pseudoclients/global.h
index 030f73f80..b27ad3562 100644
--- a/include/modules/pseudoclients/global.h
+++ b/include/modules/pseudoclients/global.h
@@ -6,8 +6,7 @@
* Please read COPYING and README for further details.
*/
-#ifndef GLOBAL_H
-#define GLOBAL_H
+#pragma once
class GlobalService : public Service
{
@@ -26,5 +25,3 @@ class GlobalService : public Service
*/
virtual void SendGlobal(BotInfo *sender, const Anope::string &source, const Anope::string &message) = 0;
};
-
-#endif // GLOBAL_H
diff --git a/include/modules/pseudoclients/memoserv.h b/include/modules/pseudoclients/memoserv.h
index 77c47692d..ea3fc964e 100644
--- a/include/modules/pseudoclients/memoserv.h
+++ b/include/modules/pseudoclients/memoserv.h
@@ -6,8 +6,7 @@
* Please read COPYING and README for further details.
*/
-#ifndef MEMOSERV_H
-#define MEMOSERV_H
+#pragma once
class MemoServService : public Service
{
@@ -37,5 +36,3 @@ class MemoServService : public Service
*/
virtual void Check(User *u) = 0;
};
-
-#endif // MEMOSERV_H
diff --git a/include/modules/pseudoclients/nickserv.h b/include/modules/pseudoclients/nickserv.h
index 9310cff1f..5207d7021 100644
--- a/include/modules/pseudoclients/nickserv.h
+++ b/include/modules/pseudoclients/nickserv.h
@@ -6,8 +6,7 @@
* Please read COPYING and README for further details.
*/
-#ifndef NICKSERV_H
-#define NICKSERV_H
+#pragma once
class NickServService : public Service
{
@@ -20,5 +19,3 @@ class NickServService : public Service
virtual void Collide(User *u, NickAlias *na) = 0;
virtual void Release(NickAlias *na) = 0;
};
-
-#endif // NICKSERV_H
diff --git a/include/modules/redis.h b/include/modules/redis.h
index 82ce5c0ad..f30311f34 100644
--- a/include/modules/redis.h
+++ b/include/modules/redis.h
@@ -6,6 +6,8 @@
* Please read COPYING and README for further details.
*/
+#pragma once
+
namespace Redis
{
struct Reply
@@ -30,8 +32,8 @@ namespace Redis
i = 0;
bulk.clear();
multi_bulk_size = 0;
- for (unsigned j = 0; j < multi_bulk.size(); ++j)
- delete multi_bulk[j];
+ for (const auto *reply : multi_bulk)
+ delete reply;
multi_bulk.clear();
}
@@ -47,7 +49,7 @@ namespace Redis
Module *owner;
Interface(Module *m) : owner(m) { }
- virtual ~Interface() { }
+ virtual ~Interface() = default;
virtual void OnResult(const Reply &r) = 0;
virtual void OnError(const Anope::string &error) { Log(owner) << error; }
diff --git a/include/modules/sasl.h b/include/modules/sasl.h
index c1d319f4c..f5482d31b 100644
--- a/include/modules/sasl.h
+++ b/include/modules/sasl.h
@@ -6,6 +6,8 @@
* Please read COPYING and README for further details.
*/
+#pragma once
+
namespace SASL
{
struct Message
@@ -82,7 +84,7 @@ namespace SASL
public:
IdentifyRequest(Module *m, const Anope::string &id, const Anope::string &acc, const Anope::string &pass, const Anope::string &h, const Anope::string &i) : ::IdentifyRequest(m, acc, pass), uid(id), hostname(h), ip(i) { }
- void OnSuccess() anope_override
+ void OnSuccess() override
{
if (!sasl)
return;
@@ -108,7 +110,7 @@ namespace SASL
}
}
- void OnFail() anope_override
+ void OnFail() override
{
if (!sasl)
return;
diff --git a/include/modules/set_misc.h b/include/modules/set_misc.h
index 453c77f02..892972d6d 100644
--- a/include/modules/set_misc.h
+++ b/include/modules/set_misc.h
@@ -6,12 +6,15 @@
* Please read COPYING and README for further details.
*/
+#pragma once
+
struct MiscData
{
Anope::string object;
Anope::string name;
Anope::string data;
- MiscData() { }
- virtual ~MiscData() { }
+ virtual ~MiscData() = default;
+ protected:
+ MiscData() = default;
};
diff --git a/include/modules/sql.h b/include/modules/sql.h
index 091e662cf..607f8bcd9 100644
--- a/include/modules/sql.h
+++ b/include/modules/sql.h
@@ -6,6 +6,8 @@
* Please read COPYING and README for further details.
*/
+#pragma once
+
namespace SQL
{
@@ -21,7 +23,7 @@ namespace SQL
Clear();
}
- std::iostream& operator[](const Anope::string &key) anope_override
+ std::iostream& operator[](const Anope::string &key) override
{
std::stringstream *&ss = data[key];
if (!ss)
@@ -29,44 +31,46 @@ namespace SQL
return *ss;
}
- std::set<Anope::string> KeySet() const anope_override
+ std::set<Anope::string> KeySet() const override
{
std::set<Anope::string> keys;
- for (Map::const_iterator it = this->data.begin(), it_end = this->data.end(); it != it_end; ++it)
- keys.insert(it->first);
+ for (const auto &[key, _] : this->data)
+ keys.insert(key);
return keys;
}
- size_t Hash() const anope_override
+ size_t Hash() const override
{
size_t hash = 0;
- for (Map::const_iterator it = this->data.begin(), it_end = this->data.end(); it != it_end; ++it)
- if (!it->second->str().empty())
- hash ^= Anope::hash_cs()(it->second->str());
+ for (const auto &[_, value] : this->data)
+ {
+ if (!value->str().empty())
+ hash ^= Anope::hash_cs()(value->str());
+ }
return hash;
}
std::map<Anope::string, std::iostream *> GetData() const
{
std::map<Anope::string, std::iostream *> d;
- for (Map::const_iterator it = this->data.begin(), it_end = this->data.end(); it != it_end; ++it)
- d[it->first] = it->second;
+ for (const auto &[key, value] : this->data)
+ d[key] = value;
return d;
}
void Clear()
{
- for (Map::const_iterator it = this->data.begin(), it_end = this->data.end(); it != it_end; ++it)
- delete it->second;
+ for (const auto &[_, value] : this->data)
+ delete value;
this->data.clear();
}
- void SetType(const Anope::string &key, Type t) anope_override
+ void SetType(const Anope::string &key, Type t) override
{
this->types[key] = t;
}
- Type GetType(const Anope::string &key) const anope_override
+ Type GetType(const Anope::string &key) const override
{
std::map<Anope::string, Type>::const_iterator it = this->types.find(key);
if (it != this->types.end())
@@ -82,7 +86,7 @@ namespace SQL
public:
Exception(const Anope::string &reason) : ModuleException(reason) { }
- virtual ~Exception() throw() { }
+ virtual ~Exception() noexcept = default;
};
/** A SQL query
@@ -141,10 +145,10 @@ namespace SQL
Query query;
Anope::string error;
public:
- unsigned int id;
+ unsigned int id = 0;
Anope::string finished_query;
- Result() : id(0) { }
+ Result() = default;
Result(unsigned int i, const Query &q, const Anope::string &fq, const Anope::string &err = "") : query(q), error(err), id(i), finished_query(fq) { }
inline operator bool() const { return this->error.empty(); }
@@ -187,7 +191,7 @@ namespace SQL
Module *owner;
Interface(Module *m) : owner(m) { }
- virtual ~Interface() { }
+ virtual ~Interface() = default;
virtual void OnResult(const Result &r) = 0;
virtual void OnError(const Result &r) = 0;
diff --git a/include/modules/ssl.h b/include/modules/ssl.h
index abbb867f7..4d1fa63e4 100644
--- a/include/modules/ssl.h
+++ b/include/modules/ssl.h
@@ -6,6 +6,8 @@
* Please read COPYING and README for further details.
*/
+#pragma once
+
class SSLService : public Service
{
public:
diff --git a/include/modules/suspend.h b/include/modules/suspend.h
index df44f56c7..a085e23e6 100644
--- a/include/modules/suspend.h
+++ b/include/modules/suspend.h
@@ -9,11 +9,13 @@
* Based on the original code of Services by Andy Church.
*/
+#pragma once
+
struct SuspendInfo
{
Anope::string what, by, reason;
time_t when, expires;
- SuspendInfo() { }
- virtual ~SuspendInfo() { }
+ SuspendInfo() = default;
+ virtual ~SuspendInfo() = default;
};
diff --git a/include/modules/xmlrpc.h b/include/modules/xmlrpc.h
index 1c324deab..81d8b3f7e 100644
--- a/include/modules/xmlrpc.h
+++ b/include/modules/xmlrpc.h
@@ -6,6 +6,8 @@
* Please read COPYING and README for further details.
*/
+#pragma once
+
#include "httpd.h"
class XMLRPCRequest
@@ -19,7 +21,7 @@ class XMLRPCRequest
HTTPReply& r;
XMLRPCRequest(HTTPReply &_r) : r(_r) { }
- inline void reply(const Anope::string &dname, const Anope::string &ddata) { this->replies.insert(std::make_pair(dname, ddata)); }
+ inline void reply(const Anope::string &dname, const Anope::string &ddata) { this->replies.emplace(dname, ddata); }
inline const std::map<Anope::string, Anope::string> &get_replies() { return this->replies; }
};
@@ -28,7 +30,7 @@ class XMLRPCServiceInterface;
class XMLRPCEvent
{
public:
- virtual ~XMLRPCEvent() { }
+ virtual ~XMLRPCEvent() = default;
virtual bool Run(XMLRPCServiceInterface *iface, HTTPClient *client, XMLRPCRequest &request) = 0;
};
diff --git a/include/opertype.h b/include/opertype.h
index 937915cb9..628180cbb 100644
--- a/include/opertype.h
+++ b/include/opertype.h
@@ -6,8 +6,7 @@
* Please read COPYING and README for further details.
*/
-#ifndef OPERTYPE_H
-#define OPERTYPE_H
+#pragma once
#include "services.h"
#include "account.h"
@@ -22,7 +21,7 @@ struct CoreExport Oper
/* The type of operator this operator is */
OperType *ot;
/* Whether the user must be an IRC operator (umode +o) to be considered a services operator */
- bool require_oper;
+ bool require_oper = true;
Anope::string password;
Anope::string certfp;
/* Hosts allowed to use this operator block */
@@ -123,5 +122,3 @@ class CoreExport OperType
*/
const std::list<Anope::string> GetPrivs() const;
};
-
-#endif // OPERTYPE_H
diff --git a/include/protocol.h b/include/protocol.h
index 874a5ff34..4f7990b51 100644
--- a/include/protocol.h
+++ b/include/protocol.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef PROTOCOL_H
-#define PROTOCOL_H
+#pragma once
#include "services.h"
#include "anope.h"
@@ -61,10 +60,10 @@ class CoreExport IRCDProto : public Service
bool CanSZLine;
/* Can we place temporary holds on specific nicknames? */
bool CanSVSHold;
- /* See os_oline */
- bool CanSVSO;
/* See ns_cert */
bool CanCertFP;
+ /* Can we send arbitrary message tags? */
+ bool CanSendTags;
/* Whether this IRCd requires unique IDs for each user or server. See TS6/P10. */
bool RequiresID;
/* If this IRCd has unique ids, whether the IDs and nicknames are ambiguous */
@@ -180,10 +179,6 @@ class CoreExport IRCDProto : public Service
virtual void SendInvite(const MessageSource &source, const Channel *c, User *u);
virtual void SendGlobops(const MessageSource &source, const char *fmt, ...);
- /** Sets oper flags on a user, currently only supported by Unreal
- */
- virtual void SendSVSO(BotInfo *, const Anope::string &, const Anope::string &) { }
-
/** Sends a nick change of one of our clients.
*/
virtual void SendNickChange(User *u, const Anope::string &newnick);
@@ -230,7 +225,7 @@ class CoreExport IRCDProto : public Service
virtual void SendSASLMechanisms(std::vector<Anope::string> &) { }
virtual void SendSASLMessage(const SASL::Message &) { }
- virtual void SendSVSLogin(const Anope::string &uid, const Anope::string &acc, const Anope::string &vident, const Anope::string &vhost) { }
+ virtual void SendSVSLogin(const Anope::string &uid, NickAlias *na) { }
virtual bool IsNickValid(const Anope::string &);
virtual bool IsChannelValid(const Anope::string &);
@@ -250,8 +245,8 @@ class CoreExport IRCDProto : public Service
class CoreExport MessageSource
{
Anope::string source;
- User *u;
- Server *s;
+ User *u = nullptr;
+ Server *s = nullptr;
public:
MessageSource(const Anope::string &);
@@ -279,8 +274,7 @@ class CoreExport IRCDMessage : public Service
public:
IRCDMessage(Module *owner, const Anope::string &n, unsigned p = 0);
unsigned GetParamCount() const;
- virtual void Run(MessageSource &, const std::vector<Anope::string> &params) = 0;
- virtual void Run(MessageSource &, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags);
+ virtual void Run(MessageSource &, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) = 0;
void SetFlag(IRCDMessageFlag f) { flags.insert(f); }
bool HasFlag(IRCDMessageFlag f) const { return flags.count(f); }
@@ -294,7 +288,7 @@ private:
Anope::string message;
/** The current position within the message. */
- Anope::string::size_type position;
+ Anope::string::size_type position = 0;
public:
/** Create a tokenstream and fill it with the provided data. */
@@ -314,5 +308,3 @@ private:
};
extern CoreExport IRCDProto *IRCD;
-
-#endif // PROTOCOL_H
diff --git a/include/pstdint.h b/include/pstdint.h
deleted file mode 100644
index b034ae086..000000000
--- a/include/pstdint.h
+++ /dev/null
@@ -1,800 +0,0 @@
-/* A portable stdint.h
- ****************************************************************************
- * BSD License:
- ****************************************************************************
- *
- * Copyright (c) 2005-2011 Paul Hsieh
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ****************************************************************************
- *
- * Version 0.1.12
- *
- * The ANSI C standard committee, for the C99 standard, specified the
- * inclusion of a new standard include file called stdint.h. This is
- * a very useful and long desired include file which contains several
- * very precise definitions for integer scalar types that is
- * critically important for making portable several classes of
- * applications including cryptography, hashing, variable length
- * integer libraries and so on. But for most developers its likely
- * useful just for programming sanity.
- *
- * The problem is that most compiler vendors have decided not to
- * implement the C99 standard, and the next C++ language standard
- * (which has a lot more mindshare these days) will be a long time in
- * coming and its unknown whether or not it will include stdint.h or
- * how much adoption it will have. Either way, it will be a long time
- * before all compilers come with a stdint.h and it also does nothing
- * for the extremely large number of compilers available today which
- * do not include this file, or anything comparable to it.
- *
- * So that's what this file is all about. Its an attempt to build a
- * single universal include file that works on as many platforms as
- * possible to deliver what stdint.h is supposed to. A few things
- * that should be noted about this file:
- *
- * 1) It is not guaranteed to be portable and/or present an identical
- * interface on all platforms. The extreme variability of the
- * ANSI C standard makes this an impossibility right from the
- * very get go. Its really only meant to be useful for the vast
- * majority of platforms that possess the capability of
- * implementing usefully and precisely defined, standard sized
- * integer scalars. Systems which are not intrinsically 2s
- * complement may produce invalid constants.
- *
- * 2) There is an unavoidable use of non-reserved symbols.
- *
- * 3) Other standard include files are invoked.
- *
- * 4) This file may come in conflict with future platforms that do
- * include stdint.h. The hope is that one or the other can be
- * used with no real difference.
- *
- * 5) In the current version, if your platform can't represent
- * int32_t, int16_t and int8_t, it just dumps out with a compiler
- * error.
- *
- * 6) 64 bit integers may or may not be defined. Test for their
- * presence with the test: #ifdef INT64_MAX or #ifdef UINT64_MAX.
- * Note that this is different from the C99 specification which
- * requires the existence of 64 bit support in the compiler. If
- * this is not defined for your platform, yet it is capable of
- * dealing with 64 bits then it is because this file has not yet
- * been extended to cover all of your system's capabilities.
- *
- * 7) (u)intptr_t may or may not be defined. Test for its presence
- * with the test: #ifdef PTRDIFF_MAX. If this is not defined
- * for your platform, then it is because this file has not yet
- * been extended to cover all of your system's capabilities, not
- * because its optional.
- *
- * 8) The following might not been defined even if your platform is
- * capable of defining it:
- *
- * WCHAR_MIN
- * WCHAR_MAX
- * (u)int64_t
- * PTRDIFF_MIN
- * PTRDIFF_MAX
- * (u)intptr_t
- *
- * 9) The following have not been defined:
- *
- * WINT_MIN
- * WINT_MAX
- *
- * 10) The criteria for defining (u)int_least(*)_t isn't clear,
- * except for systems which don't have a type that precisely
- * defined 8, 16, or 32 bit types (which this include file does
- * not support anyways). Default definitions have been given.
- *
- * 11) The criteria for defining (u)int_fast(*)_t isn't something I
- * would trust to any particular compiler vendor or the ANSI C
- * committee. It is well known that "compatible systems" are
- * commonly created that have very different performance
- * characteristics from the systems they are compatible with,
- * especially those whose vendors make both the compiler and the
- * system. Default definitions have been given, but its strongly
- * recommended that users never use these definitions for any
- * reason (they do *NOT* deliver any serious guarantee of
- * improved performance -- not in this file, nor any vendor's
- * stdint.h).
- *
- * 12) The following macros:
- *
- * PRINTF_INTMAX_MODIFIER
- * PRINTF_INT64_MODIFIER
- * PRINTF_INT32_MODIFIER
- * PRINTF_INT16_MODIFIER
- * PRINTF_LEAST64_MODIFIER
- * PRINTF_LEAST32_MODIFIER
- * PRINTF_LEAST16_MODIFIER
- * PRINTF_INTPTR_MODIFIER
- *
- * are strings which have been defined as the modifiers required
- * for the "d", "u" and "x" printf formats to correctly output
- * (u)intmax_t, (u)int64_t, (u)int32_t, (u)int16_t, (u)least64_t,
- * (u)least32_t, (u)least16_t and (u)intptr_t types respectively.
- * PRINTF_INTPTR_MODIFIER is not defined for some systems which
- * provide their own stdint.h. PRINTF_INT64_MODIFIER is not
- * defined if INT64_MAX is not defined. These are an extension
- * beyond what C99 specifies must be in stdint.h.
- *
- * In addition, the following macros are defined:
- *
- * PRINTF_INTMAX_HEX_WIDTH
- * PRINTF_INT64_HEX_WIDTH
- * PRINTF_INT32_HEX_WIDTH
- * PRINTF_INT16_HEX_WIDTH
- * PRINTF_INT8_HEX_WIDTH
- * PRINTF_INTMAX_DEC_WIDTH
- * PRINTF_INT64_DEC_WIDTH
- * PRINTF_INT32_DEC_WIDTH
- * PRINTF_INT16_DEC_WIDTH
- * PRINTF_INT8_DEC_WIDTH
- *
- * Which specifies the maximum number of characters required to
- * print the number of that type in either hexadecimal or decimal.
- * These are an extension beyond what C99 specifies must be in
- * stdint.h.
- *
- * Compilers tested (all with 0 warnings at their highest respective
- * settings): Borland Turbo C 2.0, WATCOM C/C++ 11.0 (16 bits and 32
- * bits), Microsoft Visual C++ 6.0 (32 bit), Microsoft Visual Studio
- * .net (VC7), Intel C++ 4.0, GNU gcc v3.3.3
- *
- * This file should be considered a work in progress. Suggestions for
- * improvements, especially those which increase coverage are strongly
- * encouraged.
- *
- * Acknowledgements
- *
- * The following people have made significant contributions to the
- * development and testing of this file:
- *
- * Chris Howie
- * John Steele Scott
- * Dave Thorup
- * John Dill
- *
- */
-
-#include <stddef.h>
-#include <limits.h>
-#include <signal.h>
-
-/*
- * For gcc with _STDINT_H, fill in the PRINTF_INT*_MODIFIER macros, and
- * do nothing else. On the Mac OS X version of gcc this is _STDINT_H_.
- */
-
-#if ((defined(__STDC__) && __STDC__ && __STDC_VERSION__ >= 199901L) || (defined (__WATCOMC__) && (defined (_STDINT_H_INCLUDED) || __WATCOMC__ >= 1250)) || (defined(__GNUC__) && (defined(_STDINT_H) || defined(_STDINT_H_) || defined (__UINT_FAST64_TYPE__)) )) && !defined (_PSTDINT_H_INCLUDED)
-#include <stdint.h>
-#define _PSTDINT_H_INCLUDED
-# ifndef PRINTF_INT64_MODIFIER
-# define PRINTF_INT64_MODIFIER "ll"
-# endif
-# ifndef PRINTF_INT32_MODIFIER
-# define PRINTF_INT32_MODIFIER "l"
-# endif
-# ifndef PRINTF_INT16_MODIFIER
-# define PRINTF_INT16_MODIFIER "h"
-# endif
-# ifndef PRINTF_INTMAX_MODIFIER
-# define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER
-# endif
-# ifndef PRINTF_INT64_HEX_WIDTH
-# define PRINTF_INT64_HEX_WIDTH "16"
-# endif
-# ifndef PRINTF_INT32_HEX_WIDTH
-# define PRINTF_INT32_HEX_WIDTH "8"
-# endif
-# ifndef PRINTF_INT16_HEX_WIDTH
-# define PRINTF_INT16_HEX_WIDTH "4"
-# endif
-# ifndef PRINTF_INT8_HEX_WIDTH
-# define PRINTF_INT8_HEX_WIDTH "2"
-# endif
-# ifndef PRINTF_INT64_DEC_WIDTH
-# define PRINTF_INT64_DEC_WIDTH "20"
-# endif
-# ifndef PRINTF_INT32_DEC_WIDTH
-# define PRINTF_INT32_DEC_WIDTH "10"
-# endif
-# ifndef PRINTF_INT16_DEC_WIDTH
-# define PRINTF_INT16_DEC_WIDTH "5"
-# endif
-# ifndef PRINTF_INT8_DEC_WIDTH
-# define PRINTF_INT8_DEC_WIDTH "3"
-# endif
-# ifndef PRINTF_INTMAX_HEX_WIDTH
-# define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH
-# endif
-# ifndef PRINTF_INTMAX_DEC_WIDTH
-# define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH
-# endif
-
-/*
- * Something really weird is going on with Open Watcom. Just pull some of
- * these duplicated definitions from Open Watcom's stdint.h file for now.
- */
-
-# if defined (__WATCOMC__) && __WATCOMC__ >= 1250
-# if !defined (INT64_C)
-# define INT64_C(x) (x + (INT64_MAX - INT64_MAX))
-# endif
-# if !defined (UINT64_C)
-# define UINT64_C(x) (x + (UINT64_MAX - UINT64_MAX))
-# endif
-# if !defined (INT32_C)
-# define INT32_C(x) (x + (INT32_MAX - INT32_MAX))
-# endif
-# if !defined (UINT32_C)
-# define UINT32_C(x) (x + (UINT32_MAX - UINT32_MAX))
-# endif
-# if !defined (INT16_C)
-# define INT16_C(x) (x)
-# endif
-# if !defined (UINT16_C)
-# define UINT16_C(x) (x)
-# endif
-# if !defined (INT8_C)
-# define INT8_C(x) (x)
-# endif
-# if !defined (UINT8_C)
-# define UINT8_C(x) (x)
-# endif
-# if !defined (UINT64_MAX)
-# define UINT64_MAX 18446744073709551615ULL
-# endif
-# if !defined (INT64_MAX)
-# define INT64_MAX 9223372036854775807LL
-# endif
-# if !defined (UINT32_MAX)
-# define UINT32_MAX 4294967295UL
-# endif
-# if !defined (INT32_MAX)
-# define INT32_MAX 2147483647L
-# endif
-# if !defined (INTMAX_MAX)
-# define INTMAX_MAX INT64_MAX
-# endif
-# if !defined (INTMAX_MIN)
-# define INTMAX_MIN INT64_MIN
-# endif
-# endif
-#endif
-
-#ifndef _PSTDINT_H_INCLUDED
-#define _PSTDINT_H_INCLUDED
-
-#ifndef SIZE_MAX
-# define SIZE_MAX (~(size_t)0)
-#endif
-
-/*
- * Deduce the type assignments from limits.h under the assumption that
- * integer sizes in bits are powers of 2, and follow the ANSI
- * definitions.
- */
-
-#ifndef UINT8_MAX
-# define UINT8_MAX 0xff
-#endif
-#ifndef uint8_t
-# if (UCHAR_MAX == UINT8_MAX) || defined (S_SPLINT_S)
- typedef unsigned char uint8_t;
-# define UINT8_C(v) ((uint8_t) v)
-# else
-# error "Platform not supported"
-# endif
-#endif
-
-#ifndef INT8_MAX
-# define INT8_MAX 0x7f
-#endif
-#ifndef INT8_MIN
-# define INT8_MIN INT8_C(0x80)
-#endif
-#ifndef int8_t
-# if (SCHAR_MAX == INT8_MAX) || defined (S_SPLINT_S)
- typedef signed char int8_t;
-# define INT8_C(v) ((int8_t) v)
-# else
-# error "Platform not supported"
-# endif
-#endif
-
-#ifndef UINT16_MAX
-# define UINT16_MAX 0xffff
-#endif
-#ifndef uint16_t
-#if (UINT_MAX == UINT16_MAX) || defined (S_SPLINT_S)
- typedef unsigned int uint16_t;
-# ifndef PRINTF_INT16_MODIFIER
-# define PRINTF_INT16_MODIFIER ""
-# endif
-# define UINT16_C(v) ((uint16_t) (v))
-#elif (USHRT_MAX == UINT16_MAX)
- typedef unsigned short uint16_t;
-# define UINT16_C(v) ((uint16_t) (v))
-# ifndef PRINTF_INT16_MODIFIER
-# define PRINTF_INT16_MODIFIER "h"
-# endif
-#else
-#error "Platform not supported"
-#endif
-#endif
-
-#ifndef INT16_MAX
-# define INT16_MAX 0x7fff
-#endif
-#ifndef INT16_MIN
-# define INT16_MIN INT16_C(0x8000)
-#endif
-#ifndef int16_t
-#if (INT_MAX == INT16_MAX) || defined (S_SPLINT_S)
- typedef signed int int16_t;
-# define INT16_C(v) ((int16_t) (v))
-# ifndef PRINTF_INT16_MODIFIER
-# define PRINTF_INT16_MODIFIER ""
-# endif
-#elif (SHRT_MAX == INT16_MAX)
- typedef signed short int16_t;
-# define INT16_C(v) ((int16_t) (v))
-# ifndef PRINTF_INT16_MODIFIER
-# define PRINTF_INT16_MODIFIER "h"
-# endif
-#else
-#error "Platform not supported"
-#endif
-#endif
-
-#ifndef UINT32_MAX
-# define UINT32_MAX (0xffffffffUL)
-#endif
-#ifndef uint32_t
-#if (ULONG_MAX == UINT32_MAX) || defined (S_SPLINT_S)
- typedef unsigned long uint32_t;
-# define UINT32_C(v) v ## UL
-# ifndef PRINTF_INT32_MODIFIER
-# define PRINTF_INT32_MODIFIER "l"
-# endif
-#elif (UINT_MAX == UINT32_MAX)
- typedef unsigned int uint32_t;
-# ifndef PRINTF_INT32_MODIFIER
-# define PRINTF_INT32_MODIFIER ""
-# endif
-# define UINT32_C(v) v ## U
-#elif (USHRT_MAX == UINT32_MAX)
- typedef unsigned short uint32_t;
-# define UINT32_C(v) ((unsigned short) (v))
-# ifndef PRINTF_INT32_MODIFIER
-# define PRINTF_INT32_MODIFIER ""
-# endif
-#else
-#error "Platform not supported"
-#endif
-#endif
-
-#ifndef INT32_MAX
-# define INT32_MAX (0x7fffffffL)
-#endif
-#ifndef INT32_MIN
-# define INT32_MIN INT32_C(0x80000000)
-#endif
-#ifndef int32_t
-#if (LONG_MAX == INT32_MAX) || defined (S_SPLINT_S)
- typedef signed long int32_t;
-# define INT32_C(v) v ## L
-# ifndef PRINTF_INT32_MODIFIER
-# define PRINTF_INT32_MODIFIER "l"
-# endif
-#elif (INT_MAX == INT32_MAX)
- typedef signed int int32_t;
-# define INT32_C(v) v
-# ifndef PRINTF_INT32_MODIFIER
-# define PRINTF_INT32_MODIFIER ""
-# endif
-#elif (SHRT_MAX == INT32_MAX)
- typedef signed short int32_t;
-# define INT32_C(v) ((short) (v))
-# ifndef PRINTF_INT32_MODIFIER
-# define PRINTF_INT32_MODIFIER ""
-# endif
-#else
-#error "Platform not supported"
-#endif
-#endif
-
-/*
- * The macro stdint_int64_defined is temporarily used to record
- * whether or not 64 integer support is available. It must be
- * defined for any 64 integer extensions for new platforms that are
- * added.
- */
-
-#undef stdint_int64_defined
-#if (defined(__STDC__) && defined(__STDC_VERSION__)) || defined (S_SPLINT_S)
-# if (__STDC__ && __STDC_VERSION__ >= 199901L) || defined (S_SPLINT_S)
-# define stdint_int64_defined
- typedef long long int64_t;
- typedef unsigned long long uint64_t;
-# define UINT64_C(v) v ## ULL
-# define INT64_C(v) v ## LL
-# ifndef PRINTF_INT64_MODIFIER
-# define PRINTF_INT64_MODIFIER "ll"
-# endif
-# endif
-#endif
-
-#if !defined (stdint_int64_defined)
-# if defined(__GNUC__)
-# define stdint_int64_defined
- __extension__ typedef long long int64_t;
- __extension__ typedef unsigned long long uint64_t;
-# define UINT64_C(v) v ## ULL
-# define INT64_C(v) v ## LL
-# ifndef PRINTF_INT64_MODIFIER
-# define PRINTF_INT64_MODIFIER "ll"
-# endif
-# elif defined(__MWERKS__) || defined (__SUNPRO_C) || defined (__SUNPRO_CC) || defined (__APPLE_CC__) || defined (_LONG_LONG) || defined (_CRAYC) || defined (S_SPLINT_S)
-# define stdint_int64_defined
- typedef long long int64_t;
- typedef unsigned long long uint64_t;
-# define UINT64_C(v) v ## ULL
-# define INT64_C(v) v ## LL
-# ifndef PRINTF_INT64_MODIFIER
-# define PRINTF_INT64_MODIFIER "ll"
-# endif
-# elif (defined(__WATCOMC__) && defined(__WATCOM_INT64__)) || (defined(_MSC_VER) && _INTEGRAL_MAX_BITS >= 64) || (defined (__BORLANDC__) && __BORLANDC__ > 0x460) || defined (__alpha) || defined (__DECC)
-# define stdint_int64_defined
- typedef __int64 int64_t;
- typedef unsigned __int64 uint64_t;
-# define UINT64_C(v) v ## UI64
-# define INT64_C(v) v ## I64
-# ifndef PRINTF_INT64_MODIFIER
-# define PRINTF_INT64_MODIFIER "I64"
-# endif
-# endif
-#endif
-
-#if !defined (LONG_LONG_MAX) && defined (INT64_C)
-# define LONG_LONG_MAX INT64_C (9223372036854775807)
-#endif
-#ifndef ULONG_LONG_MAX
-# define ULONG_LONG_MAX UINT64_C (18446744073709551615)
-#endif
-
-#if !defined (INT64_MAX) && defined (INT64_C)
-# define INT64_MAX INT64_C (9223372036854775807)
-#endif
-#if !defined (INT64_MIN) && defined (INT64_C)
-# define INT64_MIN INT64_C (-9223372036854775808)
-#endif
-#if !defined (UINT64_MAX) && defined (INT64_C)
-# define UINT64_MAX UINT64_C (18446744073709551615)
-#endif
-
-/*
- * Width of hexadecimal for number field.
- */
-
-#ifndef PRINTF_INT64_HEX_WIDTH
-# define PRINTF_INT64_HEX_WIDTH "16"
-#endif
-#ifndef PRINTF_INT32_HEX_WIDTH
-# define PRINTF_INT32_HEX_WIDTH "8"
-#endif
-#ifndef PRINTF_INT16_HEX_WIDTH
-# define PRINTF_INT16_HEX_WIDTH "4"
-#endif
-#ifndef PRINTF_INT8_HEX_WIDTH
-# define PRINTF_INT8_HEX_WIDTH "2"
-#endif
-
-#ifndef PRINTF_INT64_DEC_WIDTH
-# define PRINTF_INT64_DEC_WIDTH "20"
-#endif
-#ifndef PRINTF_INT32_DEC_WIDTH
-# define PRINTF_INT32_DEC_WIDTH "10"
-#endif
-#ifndef PRINTF_INT16_DEC_WIDTH
-# define PRINTF_INT16_DEC_WIDTH "5"
-#endif
-#ifndef PRINTF_INT8_DEC_WIDTH
-# define PRINTF_INT8_DEC_WIDTH "3"
-#endif
-
-/*
- * Ok, lets not worry about 128 bit integers for now. Moore's law says
- * we don't need to worry about that until about 2040 at which point
- * we'll have bigger things to worry about.
- */
-
-#ifdef stdint_int64_defined
- typedef int64_t intmax_t;
- typedef uint64_t uintmax_t;
-# define INTMAX_MAX INT64_MAX
-# define INTMAX_MIN INT64_MIN
-# define UINTMAX_MAX UINT64_MAX
-# define UINTMAX_C(v) UINT64_C(v)
-# define INTMAX_C(v) INT64_C(v)
-# ifndef PRINTF_INTMAX_MODIFIER
-# define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER
-# endif
-# ifndef PRINTF_INTMAX_HEX_WIDTH
-# define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH
-# endif
-# ifndef PRINTF_INTMAX_DEC_WIDTH
-# define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH
-# endif
-#else
- typedef int32_t intmax_t;
- typedef uint32_t uintmax_t;
-# define INTMAX_MAX INT32_MAX
-# define UINTMAX_MAX UINT32_MAX
-# define UINTMAX_C(v) UINT32_C(v)
-# define INTMAX_C(v) INT32_C(v)
-# ifndef PRINTF_INTMAX_MODIFIER
-# define PRINTF_INTMAX_MODIFIER PRINTF_INT32_MODIFIER
-# endif
-# ifndef PRINTF_INTMAX_HEX_WIDTH
-# define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT32_HEX_WIDTH
-# endif
-# ifndef PRINTF_INTMAX_DEC_WIDTH
-# define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT32_DEC_WIDTH
-# endif
-#endif
-
-/*
- * Because this file currently only supports platforms which have
- * precise powers of 2 as bit sizes for the default integers, the
- * least definitions are all trivial. Its possible that a future
- * version of this file could have different definitions.
- */
-
-#ifndef stdint_least_defined
- typedef int8_t int_least8_t;
- typedef uint8_t uint_least8_t;
- typedef int16_t int_least16_t;
- typedef uint16_t uint_least16_t;
- typedef int32_t int_least32_t;
- typedef uint32_t uint_least32_t;
-# define PRINTF_LEAST32_MODIFIER PRINTF_INT32_MODIFIER
-# define PRINTF_LEAST16_MODIFIER PRINTF_INT16_MODIFIER
-# define UINT_LEAST8_MAX UINT8_MAX
-# define INT_LEAST8_MAX INT8_MAX
-# define UINT_LEAST16_MAX UINT16_MAX
-# define INT_LEAST16_MAX INT16_MAX
-# define UINT_LEAST32_MAX UINT32_MAX
-# define INT_LEAST32_MAX INT32_MAX
-# define INT_LEAST8_MIN INT8_MIN
-# define INT_LEAST16_MIN INT16_MIN
-# define INT_LEAST32_MIN INT32_MIN
-# ifdef stdint_int64_defined
- typedef int64_t int_least64_t;
- typedef uint64_t uint_least64_t;
-# define PRINTF_LEAST64_MODIFIER PRINTF_INT64_MODIFIER
-# define UINT_LEAST64_MAX UINT64_MAX
-# define INT_LEAST64_MAX INT64_MAX
-# define INT_LEAST64_MIN INT64_MIN
-# endif
-#endif
-#undef stdint_least_defined
-
-/*
- * The ANSI C committee pretending to know or specify anything about
- * performance is the epitome of misguided arrogance. The mandate of
- * this file is to *ONLY* ever support that absolute minimum
- * definition of the fast integer types, for compatibility purposes.
- * No extensions, and no attempt to suggest what may or may not be a
- * faster integer type will ever be made in this file. Developers are
- * warned to stay away from these types when using this or any other
- * stdint.h.
- */
-
-typedef int_least8_t int_fast8_t;
-typedef uint_least8_t uint_fast8_t;
-typedef int_least16_t int_fast16_t;
-typedef uint_least16_t uint_fast16_t;
-typedef int_least32_t int_fast32_t;
-typedef uint_least32_t uint_fast32_t;
-#define UINT_FAST8_MAX UINT_LEAST8_MAX
-#define INT_FAST8_MAX INT_LEAST8_MAX
-#define UINT_FAST16_MAX UINT_LEAST16_MAX
-#define INT_FAST16_MAX INT_LEAST16_MAX
-#define UINT_FAST32_MAX UINT_LEAST32_MAX
-#define INT_FAST32_MAX INT_LEAST32_MAX
-#define INT_FAST8_MIN INT_LEAST8_MIN
-#define INT_FAST16_MIN INT_LEAST16_MIN
-#define INT_FAST32_MIN INT_LEAST32_MIN
-#ifdef stdint_int64_defined
- typedef int_least64_t int_fast64_t;
- typedef uint_least64_t uint_fast64_t;
-# define UINT_FAST64_MAX UINT_LEAST64_MAX
-# define INT_FAST64_MAX INT_LEAST64_MAX
-# define INT_FAST64_MIN INT_LEAST64_MIN
-#endif
-
-#undef stdint_int64_defined
-
-/*
- * Whatever piecemeal, per compiler thing we can do about the wchar_t
- * type limits.
- */
-
-#if defined(__WATCOMC__) || defined(_MSC_VER) || defined (__GNUC__)
-# include <wchar.h>
-# ifndef WCHAR_MIN
-# define WCHAR_MIN 0
-# endif
-# ifndef WCHAR_MAX
-# define WCHAR_MAX ((wchar_t)-1)
-# endif
-#endif
-
-/*
- * Whatever piecemeal, per compiler/platform thing we can do about the
- * (u)intptr_t types and limits.
- */
-
-#if defined (_MSC_VER) && defined (_UINTPTR_T_DEFINED)
-# define STDINT_H_UINTPTR_T_DEFINED
-#endif
-
-#ifndef STDINT_H_UINTPTR_T_DEFINED
-# if defined (__alpha__) || defined (__ia64__) || defined (__x86_64__) || defined (_WIN64)
-# define stdint_intptr_bits 64
-# elif defined (__WATCOMC__) || defined (__TURBOC__)
-# if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__)
-# define stdint_intptr_bits 16
-# else
-# define stdint_intptr_bits 32
-# endif
-# elif defined (__i386__) || defined (_WIN32) || defined (WIN32)
-# define stdint_intptr_bits 32
-# elif defined (__INTEL_COMPILER)
-/* TODO -- what did Intel do about x86-64? */
-# endif
-
-# ifdef stdint_intptr_bits
-# define stdint_intptr_glue3_i(a,b,c) a##b##c
-# define stdint_intptr_glue3(a,b,c) stdint_intptr_glue3_i(a,b,c)
-# ifndef PRINTF_INTPTR_MODIFIER
-# define PRINTF_INTPTR_MODIFIER stdint_intptr_glue3(PRINTF_INT,stdint_intptr_bits,_MODIFIER)
-# endif
-# ifndef PTRDIFF_MAX
-# define PTRDIFF_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX)
-# endif
-# ifndef PTRDIFF_MIN
-# define PTRDIFF_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN)
-# endif
-# ifndef UINTPTR_MAX
-# define UINTPTR_MAX stdint_intptr_glue3(UINT,stdint_intptr_bits,_MAX)
-# endif
-# ifndef INTPTR_MAX
-# define INTPTR_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX)
-# endif
-# ifndef INTPTR_MIN
-# define INTPTR_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN)
-# endif
-# ifndef INTPTR_C
-# define INTPTR_C(x) stdint_intptr_glue3(INT,stdint_intptr_bits,_C)(x)
-# endif
-# ifndef UINTPTR_C
-# define UINTPTR_C(x) stdint_intptr_glue3(UINT,stdint_intptr_bits,_C)(x)
-# endif
- typedef stdint_intptr_glue3(uint,stdint_intptr_bits,_t) uintptr_t;
- typedef stdint_intptr_glue3( int,stdint_intptr_bits,_t) intptr_t;
-# else
-/* TODO -- This following is likely wrong for some platforms, and does
- nothing for the definition of uintptr_t. */
- typedef ptrdiff_t intptr_t;
-# endif
-# define STDINT_H_UINTPTR_T_DEFINED
-#endif
-
-/*
- * Assumes sig_atomic_t is signed and we have a 2s complement machine.
- */
-
-#ifndef SIG_ATOMIC_MAX
-# define SIG_ATOMIC_MAX ((((sig_atomic_t) 1) << (sizeof (sig_atomic_t)*CHAR_BIT-1)) - 1)
-#endif
-
-#endif
-
-#if defined (__TEST_PSTDINT_FOR_CORRECTNESS)
-
-/*
- * Please compile with the maximum warning settings to make sure macros are not
- * defined more than once.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#define glue3_aux(x,y,z) x ## y ## z
-#define glue3(x,y,z) glue3_aux(x,y,z)
-
-#define DECLU(bits) glue3(uint,bits,_t) glue3(u,bits,=) glue3(UINT,bits,_C) (0);
-#define DECLI(bits) glue3(int,bits,_t) glue3(i,bits,=) glue3(INT,bits,_C) (0);
-
-#define DECL(us,bits) glue3(DECL,us,) (bits)
-
-#define TESTUMAX(bits) glue3(u,bits,=) glue3(~,u,bits); if (glue3(UINT,bits,_MAX) glue3(!=,u,bits)) printf ("Something wrong with UINT%d_MAX\n", bits)
-
-int main () {
- DECL(I,8)
- DECL(U,8)
- DECL(I,16)
- DECL(U,16)
- DECL(I,32)
- DECL(U,32)
-#ifdef INT64_MAX
- DECL(I,64)
- DECL(U,64)
-#endif
- intmax_t imax = INTMAX_C(0);
- uintmax_t umax = UINTMAX_C(0);
- char str0[256], str1[256];
-
- sprintf (str0, "%d %x\n", 0, ~0);
-
- sprintf (str1, "%d %x\n", i8, ~0);
- if (0 != strcmp (str0, str1)) printf ("Something wrong with i8 : %s\n", str1);
- sprintf (str1, "%u %x\n", u8, ~0);
- if (0 != strcmp (str0, str1)) printf ("Something wrong with u8 : %s\n", str1);
- sprintf (str1, "%d %x\n", i16, ~0);
- if (0 != strcmp (str0, str1)) printf ("Something wrong with i16 : %s\n", str1);
- sprintf (str1, "%u %x\n", u16, ~0);
- if (0 != strcmp (str0, str1)) printf ("Something wrong with u16 : %s\n", str1);
- sprintf (str1, "%" PRINTF_INT32_MODIFIER "d %x\n", i32, ~0);
- if (0 != strcmp (str0, str1)) printf ("Something wrong with i32 : %s\n", str1);
- sprintf (str1, "%" PRINTF_INT32_MODIFIER "u %x\n", u32, ~0);
- if (0 != strcmp (str0, str1)) printf ("Something wrong with u32 : %s\n", str1);
-#ifdef INT64_MAX
- sprintf (str1, "%" PRINTF_INT64_MODIFIER "d %x\n", i64, ~0);
- if (0 != strcmp (str0, str1)) printf ("Something wrong with i64 : %s\n", str1);
-#endif
- sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "d %x\n", imax, ~0);
- if (0 != strcmp (str0, str1)) printf ("Something wrong with imax : %s\n", str1);
- sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "u %x\n", umax, ~0);
- if (0 != strcmp (str0, str1)) printf ("Something wrong with umax : %s\n", str1);
-
- TESTUMAX(8);
- TESTUMAX(16);
- TESTUMAX(32);
-#ifdef INT64_MAX
- TESTUMAX(64);
-#endif
-
- return EXIT_SUCCESS;
-}
-
-#endif
diff --git a/include/regchannel.h b/include/regchannel.h
index d05d8c376..ef49d0913 100644
--- a/include/regchannel.h
+++ b/include/regchannel.h
@@ -6,8 +6,7 @@
* Please read COPYING and README for further details.
*/
-#ifndef REGCHANNEL_H
-#define REGCHANNEL_H
+#pragma once
#include "memo.h"
#include "modes.h"
@@ -38,7 +37,7 @@ class CoreExport AutoKick : public Serializable
AutoKick();
~AutoKick();
- void Serialize(Serialize::Data &data) const anope_override;
+ void Serialize(Serialize::Data &data) const override;
static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
};
@@ -93,8 +92,9 @@ class CoreExport ChannelInfo : public Serializable, public Extensible
ChannelInfo(const ChannelInfo &ci);
~ChannelInfo();
+ ChannelInfo& operator=(const ChannelInfo &) = default;
- void Serialize(Serialize::Data &data) const anope_override;
+ void Serialize(Serialize::Data &data) const override;
static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
/** Change the founder of the channel
@@ -248,5 +248,3 @@ class CoreExport ChannelInfo : public Serializable, public Extensible
* @return true or false
*/
extern CoreExport bool IsFounder(const User *user, const ChannelInfo *ci);
-
-#endif // REGCHANNEL_H
diff --git a/include/regexpr.h b/include/regexpr.h
index b42094597..7ddfa9a55 100644
--- a/include/regexpr.h
+++ b/include/regexpr.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef REGEXPR_H
-#define REGEXPR_H
+#pragma once
#include "services.h"
#include "anope.h"
@@ -21,7 +20,7 @@ class RegexException : public CoreException
public:
RegexException(const Anope::string &reason = "") : CoreException(reason) { }
- virtual ~RegexException() throw() { }
+ virtual ~RegexException() noexcept = default;
};
class CoreExport Regex
@@ -30,7 +29,7 @@ class CoreExport Regex
protected:
Regex(const Anope::string &expr) : expression(expr) { }
public:
- virtual ~Regex() { }
+ virtual ~Regex() = default;
const Anope::string &GetExpression() { return expression; }
virtual bool Matches(const Anope::string &str) = 0;
};
@@ -41,5 +40,3 @@ class CoreExport RegexProvider : public Service
RegexProvider(Module *o, const Anope::string &n) : Service(o, "Regex", n) { }
virtual Regex *Compile(const Anope::string &) = 0;
};
-
-#endif // REGEXPR_H
diff --git a/include/serialize.h b/include/serialize.h
index ca095541c..1cb4bdce5 100644
--- a/include/serialize.h
+++ b/include/serialize.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef SERIALIZE_H
-#define SERIALIZE_H
+#pragma once
#include <sstream>
@@ -28,7 +27,7 @@ namespace Serialize
DT_INT
};
- virtual ~Data() { }
+ virtual ~Data() = default;
virtual std::iostream& operator[](const Anope::string &key) = 0;
virtual std::set<Anope::string> KeySet() const { throw CoreException("Not supported"); }
@@ -65,9 +64,9 @@ class CoreExport Serializable : public virtual Base
/* Iterator into serializable_items */
std::list<Serializable *>::iterator s_iter;
/* The hash of the last serialized form of this object committed to the database */
- size_t last_commit;
+ size_t last_commit = 0;
/* The last time this object was committed to the database */
- time_t last_commit_time;
+ time_t last_commit_time = 0;
protected:
Serializable(const Anope::string &serialize_type);
@@ -79,10 +78,10 @@ class CoreExport Serializable : public virtual Base
virtual ~Serializable();
/* Unique ID (per type, not globally) for this object */
- uint64_t id;
+ uint64_t id = 0;
/* Only used by redis, to ignore updates */
- unsigned short redis_ignore;
+ unsigned short redis_ignore = 0;
/** Marks the object as potentially being updated "soon".
*/
@@ -127,7 +126,7 @@ class CoreExport Serialize::Type : public Base
* this timestamp. if curtime == timestamp then we have the most up to date
* version of every object of this type.
*/
- time_t timestamp;
+ time_t timestamp = 0;
public:
/* Map of Serializable::id to Serializable objects */
@@ -187,7 +186,7 @@ class Serialize::Checker
{
Anope::string name;
T obj;
- mutable ::Reference<Serialize::Type> type;
+ mutable ::Reference<Serialize::Type> type = nullptr;
inline void Check() const
{
@@ -198,7 +197,7 @@ class Serialize::Checker
}
public:
- Checker(const Anope::string &n) : name(n), type(NULL) { }
+ Checker(const Anope::string &n) : name(n) { }
inline const T* operator->() const
{
@@ -244,12 +243,10 @@ template<typename T>
class Serialize::Reference : public ReferenceBase
{
protected:
- T *ref;
+ T *ref = nullptr;
public:
- Reference() : ref(NULL)
- {
- }
+ Reference() = default;
Reference(T *obj) : ref(obj)
{
@@ -331,5 +328,3 @@ class Serialize::Reference : public ReferenceBase
return NULL;
}
};
-
-#endif // SERIALIZE_H
diff --git a/include/servers.h b/include/servers.h
index 937e31163..442b54f25 100644
--- a/include/servers.h
+++ b/include/servers.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef SERVERS_H
-#define SERVERS_H
+#pragma once
#include "services.h"
#include "anope.h"
@@ -80,7 +79,7 @@ class CoreExport Server : public Extensible
public:
/* Number of users on the server */
- unsigned users;
+ unsigned users = 0;
/** Delete this server with a reason
* @param reason The reason
@@ -183,5 +182,3 @@ class CoreExport Server : public Extensible
*/
static Server *Find(const Anope::string &name, bool name_only = false);
};
-
-#endif // SERVERS_H
diff --git a/include/service.h b/include/service.h
index c5c5a5881..fd4163675 100644
--- a/include/service.h
+++ b/include/service.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef SERVICE_H
-#define SERVICE_H
+#pragma once
#include "services.h"
#include "anope.h"
@@ -113,7 +112,7 @@ class CoreExport Service : public virtual Base
}
};
-/** Like Reference, but used to refer to Services.
+/** Like Reference, but used to refer to a Service.
*/
template<typename T>
class ServiceReference : public Reference<T>
@@ -122,7 +121,7 @@ class ServiceReference : public Reference<T>
Anope::string name;
public:
- ServiceReference() { }
+ ServiceReference() = default;
ServiceReference(const Anope::string &t, const Anope::string &n) : type(t), name(n)
{
@@ -138,7 +137,7 @@ class ServiceReference : public Reference<T>
this->invalid = true;
}
- operator bool() anope_override
+ operator bool() override
{
if (this->invalid)
{
@@ -173,5 +172,3 @@ class ServiceAlias
Service::DelAlias(t, f);
}
};
-
-#endif // SERVICE_H
diff --git a/include/services.h b/include/services.h
index 7e3fb2124..1af714563 100644
--- a/include/services.h
+++ b/include/services.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef SERVICES_H
-#define SERVICES_H
+#pragma once
#include "sysconf.h"
@@ -21,16 +20,15 @@
#include <cstdarg>
#include <stdexcept>
-#include <string.h>
-#if HAVE_STRINGS_H
-# include <strings.h>
-#endif
+#include <cstring>
#ifndef _WIN32
#include <unistd.h>
#endif
/* Pull in the various bits of STL */
+#include <cstdint>
+#include <cstddef>
#include <iostream>
#include <fstream>
#include <sstream>
@@ -48,21 +46,10 @@
#define _(x) x
-#if defined __GXX_EXPERIMENTAL_CXX0X__ || __cplusplus >= 201103L
-# define anope_override override
-# define anope_final final
-#else
-# define anope_override
-# define anope_final
-#endif
-
#ifndef _WIN32
-# define DllExport
-# define CoreExport
-# define MARK_DEPRECATED __attribute((deprecated))
+# define DllExport __attribute__ ((visibility ("default")))
+# define CoreExport __attribute__ ((visibility ("default")))
# define anope_close close
#else
# include "anope_windows.h"
#endif
-
-#endif // SERVICES_H
diff --git a/include/socketengine.h b/include/socketengine.h
index 670115e36..6084aa522 100644
--- a/include/socketengine.h
+++ b/include/socketengine.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef SOCKETENGINE_H
-#define SOCKETENGINE_H
+#pragma once
#include "services.h"
#include "sockets.h"
@@ -46,5 +45,3 @@ class CoreExport SocketEngine
static bool IgnoreErrno();
};
-
-#endif // SOCKETENGINE_H
diff --git a/include/sockets.h b/include/sockets.h
index d2b0f26f0..63df8c7b3 100644
--- a/include/sockets.h
+++ b/include/sockets.h
@@ -9,17 +9,22 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef SOCKETS_H
-#define SOCKETS_H
+#pragma once
#ifndef _WIN32
#include <netinet/in.h>
#include <sys/types.h>
#include <sys/socket.h>
+#include <sys/un.h>
#endif
#include "anope.h"
+// This has to be after anope.h
+#ifdef _WIN32
+# include <afunix.h>
+#endif
+
#define NET_BUFSIZE 65535
/** A sockaddr union used to combine IPv4 and IPv6 sockaddrs
@@ -29,6 +34,7 @@ union CoreExport sockaddrs
sockaddr sa;
sockaddr_in sa4;
sockaddr_in6 sa6;
+ sockaddr_un saun;
/** Construct the object, sets everything to 0
*/
@@ -57,6 +63,11 @@ union CoreExport sockaddrs
*/
Anope::string addr() const;
+ /** Gets the endpoint represented by this addr.
+ * @return The endpoint.
+ */
+ Anope::string str() const;
+
/** Get the reverse address represented by this addr
* @return The reverse address
*/
@@ -126,7 +137,7 @@ class SocketException : public CoreException
/** Destructor
* @throws Nothing
*/
- virtual ~SocketException() throw() { }
+ virtual ~SocketException() noexcept = default;
};
enum SocketFlag
@@ -144,7 +155,7 @@ enum SocketFlag
class CoreExport SocketIO
{
public:
- virtual ~SocketIO() { }
+ virtual ~SocketIO() = default;
/** Receive something from the buffer
* @param s The socket
@@ -204,8 +215,9 @@ class CoreExport Socket
protected:
/* Socket FD */
int sock;
- /* Is this an IPv6 socket? */
- bool ipv6;
+
+ /* The family of this socket FD */
+ int family;
public:
std::bitset<SF_SIZE> flags;
@@ -222,25 +234,25 @@ class CoreExport Socket
/** Constructor, possibly creates the socket and adds it to the engine
* @param sock The socket to use, -1 if we need to create our own
- * @param ipv6 true if using ipv6
+ * @param family The family of the socket
* @param type The socket type, defaults to SOCK_STREAM
*/
- Socket(int sock, bool ipv6 = false, int type = SOCK_STREAM);
+ Socket(int sock, int family = AF_INET, int type = SOCK_STREAM);
/** Destructor, closes the socket and removes it from the engine
*/
virtual ~Socket();
+ /** Get the socket family for this socket
+ * @return the family
+ */
+ int GetFamily() const;
+
/** Get the socket FD for this socket
* @return the fd
*/
int GetFD() const;
- /** Check if this socket is IPv6
- * @return true or false
- */
- bool IsIPv6() const;
-
/** Mark a socket as (non)blocking
* @param state true to enable blocking, false to disable blocking
* @return true if the socket is now blocking
@@ -285,18 +297,17 @@ class CoreExport BufferedSocket : public virtual Socket
int recv_len;
public:
- BufferedSocket();
- virtual ~BufferedSocket();
+ virtual ~BufferedSocket() = default;
/** Called when there is something to be received for this socket
* @return true on success, false to drop this socket
*/
- bool ProcessRead() anope_override;
+ bool ProcessRead() override;
/** Called when the socket is ready to be written to
* @return true on success, false to drop this socket
*/
- bool ProcessWrite() anope_override;
+ bool ProcessWrite() override;
/** Gets the new line from the input buffer, if any
*/
@@ -339,18 +350,17 @@ class CoreExport BinarySocket : public virtual Socket
std::deque<DataBlock *> write_buffer;
public:
- BinarySocket();
- virtual ~BinarySocket();
+ virtual ~BinarySocket() = default;
/** Called when there is something to be received for this socket
* @return true on success, false to drop this socket
*/
- bool ProcessRead() anope_override;
+ bool ProcessRead() override;
/** Called when the socket is ready to be written to
* @return true on success, false to drop this socket
*/
- bool ProcessWrite() anope_override;
+ bool ProcessWrite() override;
/** Write data to the socket
* @param buffer The data to write
@@ -377,7 +387,7 @@ class CoreExport ListenSocket : public virtual Socket
* @param ipv6 true for ipv6
*/
ListenSocket(const Anope::string &bindip, int port, bool ipv6);
- virtual ~ListenSocket();
+ virtual ~ListenSocket() = default;
/** Process what has come in from the connection
* @return false to destroy this socket
@@ -408,12 +418,12 @@ class CoreExport ConnectionSocket : public virtual Socket
* Used to determine whether or not this socket is connected yet.
* @return true to continue to call ProcessRead/ProcessWrite, false to not continue
*/
- bool Process() anope_override;
+ bool Process() override;
/** Called when there is an error for this socket
* @return true on success, false to drop this socket
*/
- void ProcessError() anope_override;
+ void ProcessError() override;
/** Called on a successful connect
*/
@@ -443,12 +453,12 @@ class CoreExport ClientSocket : public virtual Socket
* Used to determine whether or not this socket is connected yet.
* @return true to continue to call ProcessRead/ProcessWrite, false to not continue
*/
- bool Process() anope_override;
+ bool Process() override;
/** Called when there is an error for this socket
* @return true on success, false to drop this socket
*/
- void ProcessError() anope_override;
+ void ProcessError() override;
/** Called when a client has been accepted() successfully.
*/
@@ -472,7 +482,7 @@ class CoreExport Pipe : public Socket
/** Called when data is to be read, reads the data then calls OnNotify
*/
- bool ProcessRead() anope_override;
+ bool ProcessRead() override;
/** Write data to this pipe
* @param data The data to write
@@ -507,5 +517,3 @@ class CoreExport Pipe : public Socket
extern CoreExport uint32_t TotalRead;
extern CoreExport uint32_t TotalWritten;
extern CoreExport SocketIO NormalSocketIO;
-
-#endif // SOCKET_H
diff --git a/include/sysconf.h.cmake b/include/sysconf.h.cmake
index 5f0e275c3..72bc5526e 100644
--- a/include/sysconf.h.cmake
+++ b/include/sysconf.h.cmake
@@ -1,47 +1,33 @@
-#ifndef _SYSCONF_H_
-#define _SYSCONF_H_
+/*
+ *
+ * (C) 2003-2023 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ */
-#cmakedefine DEBUG_BUILD
+#pragma once
+// The default umask to use for files.
#cmakedefine DEFUMASK @DEFUMASK@
-#cmakedefine HAVE_CSTDINT 1
-#cmakedefine HAVE_STDINT_H 1
-#cmakedefine HAVE_STDDEF_H 1
-#cmakedefine HAVE_STRCASECMP 1
-#cmakedefine HAVE_STRICMP 1
-#cmakedefine HAVE_STRINGS_H 1
-#cmakedefine HAVE_UMASK 1
-#cmakedefine HAVE_EVENTFD 1
-#cmakedefine HAVE_EPOLL 1
-#cmakedefine HAVE_POLL 1
-#cmakedefine GETTEXT_FOUND 1
-#ifdef HAVE_CSTDINT
-# include <cstdint>
-#else
-# ifdef HAVE_STDINT_H
-# include <stdint.h>
-# else
-# include "pstdint.h"
-# endif
-#endif
-#ifdef HAVE_STDDEF_H
-# include <stddef.h>
-#endif
+// Whether Anope was built in debug mode.
+#cmakedefine01 DEBUG_BUILD
+
+// Whether Anope was built with localization support.
+#cmakedefine01 HAVE_LOCALIZATION
+
+// Whether the umask() function is available.
+#cmakedefine01 HAVE_UMASK
#ifdef _WIN32
# define popen _popen
# define pclose _pclose
-# define ftruncate _chsize
-# ifdef MSVCPP
+# ifdef _MSC_VER
# define PATH_MAX MAX_PATH
# endif
-# define MAXPATHLEN MAX_PATH
-# define bzero(buf, size) memset(buf, 0, size)
-# ifdef MSVCPP
-# define strcasecmp stricmp
-# endif
# define sleep(x) Sleep(x * 1000)
#endif
-
-#endif
diff --git a/include/threadengine.h b/include/threadengine.h
index 19fa53b09..7d7c2dc70 100644
--- a/include/threadengine.h
+++ b/include/threadengine.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef THREADENGINE_H
-#define THREADENGINE_H
+#pragma once
#include "sockets.h"
#include "extensible.h"
@@ -19,19 +18,15 @@ class CoreExport Thread : public Pipe, public Extensible
{
private:
/* Set to true to tell the thread to finish and we are waiting for it */
- bool exit;
+ bool exit = false;
public:
/* Handle for this thread */
pthread_t handle;
- /** Threads constructor
- */
- Thread();
-
/** Threads destructor
*/
- virtual ~Thread();
+ virtual ~Thread() = default;
/** Join to the thread, sets the exit state to true
*/
@@ -116,5 +111,3 @@ class CoreExport Condition : public Mutex
*/
void Wait();
};
-
-#endif // THREADENGINE_H
diff --git a/include/timers.h b/include/timers.h
index 6ba33ca7c..d3a5b9532 100644
--- a/include/timers.h
+++ b/include/timers.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef TIMERS_H
-#define TIMERS_H
+#pragma once
#include "anope.h"
@@ -127,5 +126,3 @@ class CoreExport TimerManager
*/
static void DeleteTimersFor(Module *m);
};
-
-#endif // TIMERS_H
diff --git a/include/uplink.h b/include/uplink.h
index b0fe4b0f8..c14c5fda8 100644
--- a/include/uplink.h
+++ b/include/uplink.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef UPLINK_H
-#define UPLINK_H
+#pragma once
#include "sockets.h"
#include "protocol.h"
@@ -27,9 +26,9 @@ class UplinkSocket : public ConnectionSocket, public BufferedSocket
bool error;
UplinkSocket();
~UplinkSocket();
- bool ProcessRead() anope_override;
- void OnConnect() anope_override;
- void OnError(const Anope::string &) anope_override;
+ bool ProcessRead() override;
+ void OnConnect() override;
+ void OnError(const Anope::string &) override;
/* A message sent over the uplink socket */
class CoreExport Message
@@ -49,5 +48,3 @@ class UplinkSocket : public ConnectionSocket, public BufferedSocket
};
};
extern CoreExport UplinkSocket *UplinkSock;
-
-#endif // UPLINK_H
diff --git a/include/users.h b/include/users.h
index 31f5cf97c..6e94e24f0 100644
--- a/include/users.h
+++ b/include/users.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef USERS_H
-#define USERS_H
+#pragma once
#include "anope.h"
#include "modes.h"
@@ -190,7 +189,7 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe
* @param ... any number of parameters
*/
void SendMessage(BotInfo *source, const char *fmt, ...);
- void SendMessage(BotInfo *source, const Anope::string &msg) anope_override;
+ void SendMessage(BotInfo *source, const Anope::string &msg) override;
/** Identify the user to a nick.
* updates last_seen, logs the user in,
@@ -226,6 +225,11 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe
*/
bool IsRecognized(bool check_secure = true) const;
+ /** Check if the user is connected securely.
+ * @return True if the user is connected securely; otherwise, false.
+ */
+ bool IsSecurelyConnected() const;
+
/** Check if the user is a services oper
* @return true if they are an oper
*/
@@ -370,5 +374,3 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe
*/
static void QuitUsers();
};
-
-#endif // USERS_H
diff --git a/include/version.cpp b/include/version.cpp
index af7993a36..9cb16d78e 100644
--- a/include/version.cpp
+++ b/include/version.cpp
@@ -105,8 +105,9 @@ static bool write_build_h(const std::string &buildh, const std::string &git_vers
return false;
}
- fd << "/* This file is automatically generated by version.cpp - do not edit it! */" << std::endl;
- fd << build << std::endl;
+ fd << "/* This file is automatically generated by version.cpp - do not edit it! */" << std::endl
+ << "#pragma once" << std::endl
+ << build << std::endl;
if (!git_version.empty())
fd << "#define VERSION_GIT \"" << git_version << "\"" << std::endl;
fd.close();
@@ -144,9 +145,10 @@ static bool write_version_h(const std::string &versionh, const std::map<std::str
if (!fd.is_open())
return false;
- for (std::map<std::string, std::string>::const_iterator it = versions.begin(); it != versions.end(); ++it)
+ fd << "#pragma once" << std::endl;
+ for (const auto &[key, value] : versions)
{
- fd << "#define " << it->first << " " << it->second << std::endl;
+ fd << "#define " << key << " " << value << std::endl;
}
fd.close();
diff --git a/include/xline.h b/include/xline.h
index b9cd8b791..951f74563 100644
--- a/include/xline.h
+++ b/include/xline.h
@@ -6,8 +6,7 @@
* Please read COPYING and README for further details.
*/
-#ifndef XLINE_H
-#define XLINE_H
+#pragma once
#include "serialize.h"
#include "service.h"
@@ -23,8 +22,8 @@ class CoreExport XLine : public Serializable
Anope::string mask;
Regex *regex;
Anope::string by;
- time_t created;
- time_t expires;
+ time_t created = 0;
+ time_t expires = 0;
Anope::string reason;
XLineManager *manager;
Anope::string id;
@@ -44,7 +43,7 @@ class CoreExport XLine : public Serializable
bool HasNickOrReal() const;
bool IsRegex() const;
- void Serialize(Serialize::Data &data) const anope_override;
+ void Serialize(Serialize::Data &data) const override;
static Serializable* Unserialize(Serializable *obj, Serialize::Data &data);
};
@@ -180,5 +179,3 @@ class CoreExport XLineManager : public Service
*/
virtual void SendDel(XLine *x) = 0;
};
-
-#endif // XLINE_H
diff --git a/language/CMakeLists.txt b/language/CMakeLists.txt
index 577e132a3..3c98d266a 100644
--- a/language/CMakeLists.txt
+++ b/language/CMakeLists.txt
@@ -1,8 +1,8 @@
# Only do this if gettext is installed
-if(GETTEXT_FOUND)
+if(HAVE_LOCALIZATION)
# Get all of the .po files
file(GLOB LANG_SRCS_PO RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.*.po")
- sort_list(LANG_SRCS_PO)
+ list(SORT LANG_SRCS_PO)
foreach(LANG_PO ${LANG_SRCS_PO})
# Get the domain for this language file
@@ -26,12 +26,12 @@ if(GETTEXT_FOUND)
# Add to cpack ignored files if not on Windows.
if(NOT WIN32)
add_to_cpack_ignored_files("${LANG_MO}")
- endif(NOT WIN32)
+ endif()
# Install the new language file
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${LANG_MO} DESTINATION ${LOCALE_DIR}/${LANG_LANG}/LC_MESSAGES RENAME ${LANG_DOMAIN}.mo PERMISSIONS ${PERMS})
- endforeach(LANG_PO)
+ endforeach()
# Generate languages, depends on the mo files
add_custom_target(language DEPENDS ${LANG_SRCS_MO})
-endif(GETTEXT_FOUND)
+endif()
diff --git a/language/anope.ca_ES.po b/language/anope.ca_ES.po
index 6d26ce336..99b8204fb 100644
--- a/language/anope.ca_ES.po
+++ b/language/anope.ca_ES.po
@@ -4097,7 +4097,7 @@ msgstr ""
"to them. (However, no more than %d messages will be\n"
"sent in order to avoid flooding the user. If there are\n"
"more news messages, only the most recent will be sent.)\n"
-"NewsCount can be configured in services.conf.\n"
+"NewsCount can be configured in anope.conf.\n"
"\n"
"LOGONNEWS may only be used by Services Operators."
@@ -4118,7 +4118,7 @@ msgstr ""
"be sent to them. (However, no more than %d messages will\n"
"be sent in order to avoid flooding the user. If there are\n"
"more news messages, only the most recent will be sent.)\n"
-"NewsCount can be configured in services.conf.\n"
+"NewsCount can be configured in anope.conf.\n"
"\n"
"OPERNEWS may only be used by Services Operators."
@@ -7671,7 +7671,7 @@ msgstr "Sucessor de %s desabilitat."
#, fuzzy
msgid ""
"Super admin can not be set because it is not enabled in the configuration."
-msgstr "SuperAdmin setting not enabled in services.conf"
+msgstr "SuperAdmin setting not enabled in anope.conf"
#, fuzzy
msgid "Suspend a given nick"
diff --git a/language/anope.de_DE.po b/language/anope.de_DE.po
index 5660f24e2..ec0280e3e 100644
--- a/language/anope.de_DE.po
+++ b/language/anope.de_DE.po
@@ -3778,7 +3778,7 @@ msgstr ""
"angezeigt. (Es werden jedoch nur max. %d angezeigt, um ein\n"
"Flooding des Users zu verhindern. Wenn mehr News\n"
"existieren, werden nur die neuesten angezeigt.)\n"
-"NewsCount kann in der services.conf eingestellt werden.\n"
+"NewsCount kann in der anope.conf eingestellt werden.\n"
"\n"
"Diese Funktion ist beschränkt auf Services Operatoren."
@@ -3796,7 +3796,7 @@ msgstr ""
"(Es werden jedoch nur max. %d Nachrichten angezeigt, um ein\n"
"Flooding des Users zu verhindern. Wenn mehr News\n"
"existieren, werden nur die neüsten angezeigt.)\n"
-"NewsCount can be configured in services.conf.\n"
+"NewsCount can be configured in anope.conf.\n"
"\n"
"Diese Funktion ist beschränkt auf Services Operatoren."
@@ -7365,7 +7365,7 @@ msgstr "Der Eintrag des Vertreters für %s wurde entfernt."
#, fuzzy
msgid "Super admin can not be set because it is not enabled in the configuration."
-msgstr "SuperAdmin muss in der services.conf eingeschaltet werden."
+msgstr "SuperAdmin muss in der anope.conf eingeschaltet werden."
#, fuzzy
msgid "Suspend a given nick"
diff --git a/language/anope.el_GR.po b/language/anope.el_GR.po
index d99dcaf63..8d4fdc404 100644
--- a/language/anope.el_GR.po
+++ b/language/anope.el_GR.po
@@ -4012,7 +4012,7 @@ msgstr ""
"(Παρόλα αυτά, δεν θα του στέλνονται παραπάνω από #%d# μηνύματα\n"
"για να αποφευχθεί το flood του χρήστη. Αν υπάρχουν\n"
"περισσότερα μηνύματα, θα φαίνονται τα πιο πρόσφατα.)\n"
-"Το NewsCount μπορεί να ρυθμιστεί στο services.conf.\n"
+"Το NewsCount μπορεί να ρυθμιστεί στο anope.conf.\n"
"\n"
"Η εντολή LOGONNEWS μπορεί να χρησιμοποιηθεί μόνο από IRC Operators."
@@ -4034,7 +4034,7 @@ msgstr ""
"μηνύματα\n"
"για να αποφευχθεί flood στον χρήστη. Αν υπάρχουν \n"
"περισσότερα μηνύματα, θα φαίνονται τα πιο πρόσφατα.)\n"
-"Το NewsCount μπορεί να ρυθμιστεί στο services.conf.\n"
+"Το NewsCount μπορεί να ρυθμιστεί στο anope.conf.\n"
" \n"
"Το OPERNEWS μπορεί να χρησιμοποιηθεί μόνο από Services Operators."
@@ -7580,7 +7580,7 @@ msgstr "Ο Successor του #%s# δεν έχει οριστεί."
#, fuzzy
msgid ""
"Super admin can not be set because it is not enabled in the configuration."
-msgstr "H ρύθμιση SuperAdmin δεν έχει ενεργοποιηθεί στο services.conf"
+msgstr "H ρύθμιση SuperAdmin δεν έχει ενεργοποιηθεί στο anope.conf"
#
msgid "Suspend a given nick"
diff --git a/language/anope.hu_HU.po b/language/anope.hu_HU.po
index 709c8e810..56f21a2e8 100644
--- a/language/anope.hu_HU.po
+++ b/language/anope.hu_HU.po
@@ -4056,7 +4056,7 @@ msgstr ""
"to them. (However, no more than %d messages will be\n"
"sent in order to avoid flooding the user. If there are\n"
"more news messages, only the most recent will be sent.)\n"
-"NewsCount can be configured in services.conf.\n"
+"NewsCount can be configured in anope.conf.\n"
"\n"
"LOGONNEWS may only be used by Services Operators."
@@ -4077,7 +4077,7 @@ msgstr ""
"be sent to them. (However, no more than %d messages will\n"
"be sent in order to avoid flooding the user. If there are\n"
"more news messages, only the most recent will be sent.)\n"
-"NewsCount can be configured in services.conf.\n"
+"NewsCount can be configured in anope.conf.\n"
"\n"
"OPERNEWS may only be used by Services Operators."
@@ -7581,7 +7581,7 @@ msgstr "A megadott csatorna %s successora törölve."
#, fuzzy
msgid ""
"Super admin can not be set because it is not enabled in the configuration."
-msgstr "SuperAdmin setting not enabled in services.conf"
+msgstr "SuperAdmin setting not enabled in anope.conf"
#, fuzzy
msgid "Suspend a given nick"
diff --git a/language/anope.pt_PT.po b/language/anope.pt_PT.po
index 2173ebd7b..e74d75553 100644
--- a/language/anope.pt_PT.po
+++ b/language/anope.pt_PT.po
@@ -4022,7 +4022,7 @@ msgstr ""
"to them. (However, no more than %s messages will be\n"
"sent in order to avoid flooding the user. If there are\n"
"more news messages, only the most recent will be sent.)\n"
-"NewsCount can be configured in services.conf.\n"
+"NewsCount can be configured in anope.conf.\n"
"\n"
"LOGONNEWS may only be used by Services Operators."
@@ -4043,7 +4043,7 @@ msgstr ""
"be sent to them. (However, no more than %s messages will\n"
"be sent in order to avoid flooding the user. If there are\n"
"more news messages, only the most recent will be sent.)\n"
-"NewsCount can be configured in services.conf.\n"
+"NewsCount can be configured in anope.conf.\n"
"\n"
"OPERNEWS may only be used by Services Operators."
@@ -7540,7 +7540,7 @@ msgstr "Successor do canal %s removido."
#, fuzzy
msgid ""
"Super admin can not be set because it is not enabled in the configuration."
-msgstr "Opção SuperAdmin não habilitada no arquivo services.conf"
+msgstr "Opção SuperAdmin não habilitada no arquivo anope.conf"
#, fuzzy
msgid "Suspend a given nick"
diff --git a/language/anope.ru_RU.po b/language/anope.ru_RU.po
index d9171ee19..be356a9c9 100644
--- a/language/anope.ru_RU.po
+++ b/language/anope.ru_RU.po
@@ -3223,7 +3223,7 @@ msgid ""
msgstr ""
"Синтаксис: RELOAD\n"
"\n"
-"Заставляет сервисы перечитать конфигурационный файл services.conf.\n"
+"Заставляет сервисы перечитать конфигурационный файл anope.conf.\n"
"Примечание: активация некоторых новых/измененных директив конфига\n"
"требует полного перезапуска сервисов (например: изменение ников\n"
"сервисов, активация лимитирования сессий, и т.д.)"
@@ -4135,7 +4135,7 @@ msgstr ""
"Стоит заметить, что во избежание флуда пользователь получит только\n"
"%d новость(и), так что если у вас в списке их больше - показаны\n"
"будут только последние из них. Значение NewsCount, отвечающее за\n"
-"одновременно посылаемое кол-во новостей, указывается в services.conf\n"
+"одновременно посылаемое кол-во новостей, указывается в anope.conf\n"
"\n"
"Команда LOGONNEWS ADD позволяет добавить новость в список.\n"
"\n"
@@ -4163,7 +4163,7 @@ msgstr ""
"Стоит заметить, что во избежание флуда пользователь получит только\n"
"%d новость(и), так что если у вас в списке их больше - показаны\n"
"будут только последние из них. Значение NewsCount, отвечающее за\n"
-"одновременно посылаемое кол-во новостей, указывается в services.conf\n"
+"одновременно посылаемое кол-во новостей, указывается в anope.conf\n"
"\n"
"Команда OPERNEWS ADD позволяет добавить новость в список.\n"
"\n"
diff --git a/language/anope.tr_TR.po b/language/anope.tr_TR.po
index 8f52cccd9..988f8e1cb 100644
--- a/language/anope.tr_TR.po
+++ b/language/anope.tr_TR.po
@@ -4012,7 +4012,7 @@ msgstr ""
"to them. (However, no more than %d messages will be\n"
"sent in order to avoid flooding the user. If there are\n"
"more news messages, only the most recent will be sent.)\n"
-"NewsCount can be configured in services.conf.\n"
+"NewsCount can be configured in anope.conf.\n"
"\n"
"LOGONNEWS may only be used by Services Operators."
@@ -4033,7 +4033,7 @@ msgstr ""
"be sent to them. (However, no more than %d messages will\n"
"be sent in order to avoid flooding the user. If there are\n"
"more news messages, only the most recent will be sent.)\n"
-"NewsCount can be configured in services.conf.\n"
+"NewsCount can be configured in anope.conf.\n"
"\n"
"OPERNEWS may only be used by Services Operators."
@@ -7532,7 +7532,7 @@ msgstr "%s için successor kaldırıldı."
#, fuzzy
msgid ""
"Super admin can not be set because it is not enabled in the configuration."
-msgstr "SuperAdmin setting not enabled in services.conf"
+msgstr "SuperAdmin setting not enabled in anope.conf"
#, fuzzy
msgid "Suspend a given nick"
diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt
index 460c7b18a..311e9964b 100644
--- a/modules/CMakeLists.txt
+++ b/modules/CMakeLists.txt
@@ -1,7 +1,7 @@
# If using Windows, add the MODULE_COMPILE define
if(WIN32)
add_definitions(-DMODULE_COMPILE)
-endif(WIN32)
+endif()
# enable extra modules if conan is used
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../conanbuildinfo.cmake")
@@ -40,16 +40,16 @@ endif()
macro(build_modules SRC)
if(NOT ${SRC} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR} AND EXISTS "${SRC}/CMakeLists.txt")
add_subdirectory("${SRC}")
- else(NOT ${SRC} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR} AND EXISTS "${SRC}/CMakeLists.txt")
+ else()
file(GLOB MODULES_SRCS "${SRC}/*")
foreach(MODULE_SRC ${MODULES_SRCS})
if(IS_DIRECTORY "${MODULE_SRC}")
build_modules("${MODULE_SRC}")
- else(IS_DIRECTORY "${MODULE_SRC}")
+ else()
string(REGEX MATCH "\\.c$" ANOPE18MODULE ${MODULE_SRC})
if(ANOPE18MODULE)
message(FATAL_ERROR "Anope 1 modules are not compatible with Anope 2!\nOffending module: ${MODULE_SRC}")
- endif(ANOPE18MODULE)
+ endif()
string(REGEX MATCH "\\.cpp$" CPP ${MODULE_SRC})
if(CPP)
set_source_files_properties(${MODULE_SRC} PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${CXXFLAGS}")
@@ -57,68 +57,50 @@ macro(build_modules SRC)
file(RELATIVE_PATH FNAME ${SRC} ${MODULE_SRC})
# Convert the real source file extension to have a .so extension
string(REGEX REPLACE "\\.cpp$" ".so" SO ${FNAME})
- # Temporary variable for the current source's include directories
- set(TEMP_INCLUDES)
- # Calculate the header file dependencies for the given source file
- calculate_depends(${MODULE_SRC} TEMP_INCLUDES)
- # If there were some extra include directories, add them to the list
- if(TEMP_INCLUDES)
- append_to_list(EXTRA_INCLUDES ${TEMP_INCLUDES})
- endif(TEMP_INCLUDES)
-
# Reset linker flags
set(TEMP_LDFLAGS)
# Reset extra dependencies
set(TEMP_DEPENDENCIES)
# Calculate the library dependencies for the given source file
calculate_libraries(${MODULE_SRC} TEMP_LDFLAGS TEMP_DEPENDENCIES)
- # Reset has_function
- set(HAS_FUNCTION)
- # Check the function dependencies for the given source file
- check_functions(${MODULE_SRC} HAS_FUNCTION)
- # Only continue if this module has all of the required functions
- if(HAS_FUNCTION)
- # For Visual Studio only, include win32_memory static library, required to override Visual Studio's overrides of the new/delete operators
- if(MSVC)
- set(WIN32_MEMORY win32_memory)
- else(MSVC)
- set(WIN32_MEMORY)
- endif(MSVC)
- # Generate the module and set its linker flags, also set it to depend on the main Anope executable to be built beforehand
- add_library(${SO} MODULE ${MODULE_SRC})
- # Windows requires this because it's weird
- if(WIN32)
- set(WIN32_NO_LIBS "/nodefaultlib:\"libcmt.lib\" /OPT:NOREF")
- else(WIN32)
- set(WIN32_NO_LIBS)
- endif(WIN32)
- set_target_properties(${SO} PROPERTIES LINKER_LANGUAGE CXX PREFIX "" SUFFIX "" LINK_FLAGS "${TEMP_LDFLAGS} ${WIN32_NO_LIBS}" INSTALL_RPATH_USE_LINK_PATH ON BUILD_WITH_INSTALL_RPATH ON)
- add_dependencies(${SO} ${PROGRAM_NAME})
- if(GETTEXT_FOUND)
- add_dependencies(${SO} module_language)
- endif(GETTEXT_FOUND)
- target_link_libraries(${SO} ${TEMP_DEPENDENCIES})
- # For Windows only, have the module link to the export library of Anope as well as wsock32 and Ws2_32 libraries (most of the modules probably don't need this, but this is to be on the safe side), also set its version
- if(WIN32)
- target_link_libraries(${SO} ${PROGRAM_NAME} wsock32 Ws2_32 ${WIN32_MEMORY})
- set_target_properties(${PROGRAM_NAME} PROPERTIES VERSION "${VERSION_DOTTED}")
- else(WIN32)
- if(APPLE)
- target_link_libraries(${SO} ${PROGRAM_NAME})
- endif(APPLE)
- endif(WIN32)
- # Set the module to be installed to the module directory under the data directory
- install(TARGETS ${SO} DESTINATION ${LIB_DIR}/modules)
- endif(HAS_FUNCTION)
- endif(CPP)
- endif(IS_DIRECTORY "${MODULE_SRC}")
- endforeach(MODULE_SRC ${MODULES_SRCS})
- endif(NOT ${SRC} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR} AND EXISTS "${SRC}/CMakeLists.txt")
-endmacro(build_modules)
+ # For Visual Studio only, include win32_memory static library, required to override Visual Studio's overrides of the new/delete operators
+ if(MSVC)
+ set(WIN32_MEMORY win32_memory)
+ else()
+ set(WIN32_MEMORY)
+ endif()
+ # Generate the module and set its linker flags, also set it to depend on the main Anope executable to be built beforehand
+ add_library(${SO} MODULE ${MODULE_SRC})
+ # Windows requires this because it's weird
+ if(WIN32)
+ set(WIN32_NO_LIBS "/nodefaultlib:\"libcmt.lib\" /OPT:NOREF")
+ else()
+ set(WIN32_NO_LIBS)
+ endif()
+ set_target_properties(${SO} PROPERTIES LINKER_LANGUAGE CXX PREFIX "" SUFFIX "" LINK_FLAGS "${TEMP_LDFLAGS} ${WIN32_NO_LIBS}" INSTALL_RPATH_USE_LINK_PATH ON BUILD_WITH_INSTALL_RPATH ON)
+ add_dependencies(${SO} ${PROGRAM_NAME})
+ if(HAVE_LOCALIZATION)
+ add_dependencies(${SO} module_language)
+ endif()
+ target_link_libraries(${SO} ${TEMP_DEPENDENCIES})
+ # For Windows only, have the module link to the export library of Anope as well as wsock32 and Ws2_32 libraries (most of the modules probably don't need this, but this is to be on the safe side), also set its version
+ if(WIN32)
+ target_link_libraries(${SO} ${PROGRAM_NAME} wsock32 Ws2_32 ${WIN32_MEMORY})
+ set_target_properties(${PROGRAM_NAME} PROPERTIES VERSION "${VERSION_DOTTED}")
+ elseif(APPLE)
+ target_link_libraries(${SO} ${PROGRAM_NAME})
+ endif()
+ # Set the module to be installed to the module directory under the data directory
+ install(TARGETS ${SO} DESTINATION ${LIB_DIR}/modules)
+ endif()
+ endif()
+ endforeach()
+ endif()
+endmacro()
macro(build_subdir)
file(GLOB_RECURSE MODULES_SUBDIR_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cpp")
- sort_list(MODULES_SUBDIR_SRCS)
+ list(SORT MODULES_SUBDIR_SRCS)
GET_FILENAME_COMPONENT(FOLDER_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)
set(SO "${FOLDER_NAME}.so")
@@ -126,78 +108,57 @@ macro(build_subdir)
# Set all the files to use C++ as well as set their compile flags (use the module-specific compile flags, though)
set_source_files_properties(${MODULES_SUBDIR_SRCS} PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${CXXFLAGS}")
- set(HAS_FUNCTION TRUE)
-
# Iterate through the source files in the subdirectory
foreach(SRC ${MODULES_SUBDIR_SRCS})
- if(HAS_FUNCTION)
- # Temporary variable for the current source's include directories
- set(TEMP_INCLUDES)
- # Calculate the header file dependencies for the given source file
- calculate_depends(${SRC} TEMP_INCLUDES)
- # If there were some extra include directories, add them to the list
- if(TEMP_INCLUDES)
- include_directories(${TEMP_INCLUDES})
- endif(TEMP_INCLUDES)
-
- # Reset linker flags
- set(TEMP_LDFLAGS)
- # Reset extra dependencies
- set(TEMP_DEPENDENCIES)
- # Calculate the library dependencies for the given source file
- calculate_libraries(${SRC} SKIP_LIBRARIES MODULE TEMP_LDFLAGS TEMP_DEPENDENCIES)
- # Check the function dependencies for the given source file
- check_functions(${SRC} HAS_FUNCTION)
-
- # Append this source file's linker flags to the subdirectoy's linker flags, if there are any to append
- if(TEMP_DEPENDENCIES)
- append_to_list(SUBDIR_EXTRA_DEPENDS ${TEMP_DEPENDENCIES})
- endif(TEMP_DEPENDENCIES)
- endif(HAS_FUNCTION)
- endforeach(SRC ${MODULES_SUBDIR_SRCS})
-
- # Continue if library and function requirements are met
- if(HAS_FUNCTION)
- # Remove duplicates from the linker flags
- if(SUBDIR_LDFLAGS)
- remove_list_duplicates(SUBDIR_LDFLAGS)
- endif(SUBDIR_LDFLAGS)
-
- # Remove duplicates from the extra dependencies
- if(SUBDIR_EXTRA_DEPENDS)
- remove_list_duplicates(SUBDIR_EXTRA_DEPENDS)
- endif(SUBDIR_EXTRA_DEPENDS)
-
- # For Visual Studio only, include win32_memory static library, required to override Visual Studio's overrides of the new/delete operators
- if(MSVC)
- set(WIN32_MEMORY win32_memory)
- else(MSVC)
- set(WIN32_MEMORY)
- endif(MSVC)
-
- # Generate the module and set it's linker flags, also set it to depend on the main Anope executable to be built beforehand
- add_library(${SO} MODULE ${MODULES_SUBDIR_SRCS})
- set_target_properties(${SO} PROPERTIES LINKER_LANGUAGE CXX PREFIX "" SUFFIX "" LINK_FLAGS "${SUBDIR_LDFLAGS}" INSTALL_RPATH_USE_LINK_PATH ON BUILD_WITH_INSTALL_RPATH ON)
- add_dependencies(${SO} ${PROGRAM_NAME})
- if(GETTEXT_FOUND)
- add_dependencies(${SO} module_language)
- endif(GETTEXT_FOUND)
- target_link_libraries(${SO} ${SUBDIR_EXTRA_DEPENDS})
- # For Windows only, have the module link to the export library of Anope as well as wsock32 and Ws2_32 libraries (most of the modules probably don't need this, but this is to be on the safe side), also set it's version
- if(WIN32)
- target_link_libraries(${SO} ${PROGRAM_NAME} wsock32 Ws2_32 ${WIN32_MEMORY})
- set_target_properties(${PROGRAM_NAME} PROPERTIES VERSION "${VERSION_DOTTED}")
- else(WIN32)
- if(APPLE)
- target_link_libraries(${SO} ${PROGRAM_NAME})
- endif(APPLE)
- endif(WIN32)
-
- # Set the module to be installed to the module directory under the data directory
- install(TARGETS ${SO} DESTINATION ${LIB_DIR}/modules)
-
- endif(HAS_FUNCTION)
-endmacro(build_subdir)
+ # Reset linker flags
+ set(TEMP_LDFLAGS)
+ # Reset extra dependencies
+ set(TEMP_DEPENDENCIES)
+ # Calculate the library dependencies for the given source file
+ calculate_libraries(${SRC} SKIP_LIBRARIES MODULE TEMP_LDFLAGS TEMP_DEPENDENCIES)
+
+ # Append this source file's linker flags to the subdirectoy's linker flags, if there are any to append
+ if(TEMP_DEPENDENCIES)
+ list(APPEND SUBDIR_EXTRA_DEPENDS ${TEMP_DEPENDENCIES})
+ endif()
+ endforeach()
+
+ # Remove duplicates from the linker flags
+ if(SUBDIR_LDFLAGS)
+ list(REMOVE_DUPLICATES SUBDIR_LDFLAGS)
+ endif()
+
+ # Remove duplicates from the extra dependencies
+ if(SUBDIR_EXTRA_DEPENDS)
+ list(REMOVE_DUPLICATES SUBDIR_EXTRA_DEPENDS)
+ endif()
+
+ # For Visual Studio only, include win32_memory static library, required to override Visual Studio's overrides of the new/delete operators
+ if(MSVC)
+ set(WIN32_MEMORY win32_memory)
+ else()
+ set(WIN32_MEMORY)
+ endif()
+
+ # Generate the module and set it's linker flags, also set it to depend on the main Anope executable to be built beforehand
+ add_library(${SO} MODULE ${MODULES_SUBDIR_SRCS})
+ set_target_properties(${SO} PROPERTIES LINKER_LANGUAGE CXX PREFIX "" SUFFIX "" LINK_FLAGS "${SUBDIR_LDFLAGS}" INSTALL_RPATH_USE_LINK_PATH ON BUILD_WITH_INSTALL_RPATH ON)
+ add_dependencies(${SO} ${PROGRAM_NAME})
+ if(HAVE_LOCALIZATION)
+ add_dependencies(${SO} module_language)
+ endif()
+ target_link_libraries(${SO} ${SUBDIR_EXTRA_DEPENDS})
+ # For Windows only, have the module link to the export library of Anope as well as wsock32 and Ws2_32 libraries (most of the modules probably don't need this, but this is to be on the safe side), also set it's version
+ if(WIN32)
+ target_link_libraries(${SO} ${PROGRAM_NAME} wsock32 Ws2_32 ${WIN32_MEMORY})
+ set_target_properties(${PROGRAM_NAME} PROPERTIES VERSION "${VERSION_DOTTED}")
+ elseif(APPLE)
+ target_link_libraries(${SO} ${PROGRAM_NAME})
+ endif()
+
+ # Set the module to be installed to the module directory under the data directory
+ install(TARGETS ${SO} DESTINATION ${LIB_DIR}/modules)
+endmacro()
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
build_modules(${CMAKE_CURRENT_SOURCE_DIR})
diff --git a/modules/bs_autoassign.cpp b/modules/bs_autoassign.cpp
index 31543c05d..27215e56b 100644
--- a/modules/bs_autoassign.cpp
+++ b/modules/bs_autoassign.cpp
@@ -16,7 +16,7 @@ class BSAutoAssign : public Module
{
}
- void OnChanRegistered(ChannelInfo *ci) anope_override
+ void OnChanRegistered(ChannelInfo *ci) override
{
const Anope::string &bot = Config->GetModule(this)->Get<const Anope::string>("bot");
if (bot.empty())
diff --git a/modules/commands/bs_assign.cpp b/modules/commands/bs_assign.cpp
index edfff1c59..53d616e33 100644
--- a/modules/commands/bs_assign.cpp
+++ b/modules/commands/bs_assign.cpp
@@ -20,7 +20,7 @@ class CommandBSAssign : public Command
this->SetSyntax(_("\037channel\037 \037nick\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &chan = params[0];
const Anope::string &nick = params[1];
@@ -71,7 +71,7 @@ class CommandBSAssign : public Command
source.Reply(_("Bot \002%s\002 has been assigned to %s."), bi->nick.c_str(), ci->name.c_str());
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -91,7 +91,7 @@ class CommandBSUnassign : public Command
this->SetSyntax(_("\037channel\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (Anope::ReadOnly)
{
@@ -132,7 +132,7 @@ class CommandBSUnassign : public Command
source.Reply(_("There is no bot assigned to %s anymore."), ci->name.c_str());
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -154,7 +154,7 @@ class CommandBSSetNoBot : public Command
this->SetSyntax(_("\037channel\037 {\037ON|OFF\037}"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
ChannelInfo *ci = ChannelInfo::Find(params[0]);
const Anope::string &value = params[1];
@@ -191,7 +191,7 @@ class CommandBSSetNoBot : public Command
this->OnSyntaxError(source, source.command);
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(_(" \n"
@@ -217,7 +217,7 @@ class BSAssign : public Module
{
}
- void OnInvite(User *source, Channel *c, User *targ) anope_override
+ void OnInvite(User *source, Channel *c, User *targ) override
{
BotInfo *bi;
if (Anope::ReadOnly || !c->ci || targ->server != Me || !(bi = dynamic_cast<BotInfo *>(targ)))
@@ -246,7 +246,7 @@ class BSAssign : public Module
targ->SendMessage(bi, _("Bot \002%s\002 has been assigned to %s."), bi->nick.c_str(), c->name.c_str());
}
- void OnBotInfo(CommandSource &source, BotInfo *bi, ChannelInfo *ci, InfoFormatter &info) anope_override
+ void OnBotInfo(CommandSource &source, BotInfo *bi, ChannelInfo *ci, InfoFormatter &info) override
{
if (nobot.HasExt(ci))
info.AddOption(_("No bot"));
diff --git a/modules/commands/bs_badwords.cpp b/modules/commands/bs_badwords.cpp
index 5ceba9fb3..72e8c60f3 100644
--- a/modules/commands/bs_badwords.cpp
+++ b/modules/commands/bs_badwords.cpp
@@ -15,9 +15,9 @@
struct BadWordImpl : BadWord, Serializable
{
BadWordImpl() : Serializable("BadWord") { }
- ~BadWordImpl();
+ ~BadWordImpl() override;
- void Serialize(Serialize::Data &data) const anope_override
+ void Serialize(Serialize::Data &data) const override
{
data["ci"] << this->chan;
data["word"] << this->word;
@@ -35,9 +35,9 @@ struct BadWordsImpl : BadWords
BadWordsImpl(Extensible *obj) : ci(anope_dynamic_static_cast<ChannelInfo *>(obj)), badwords("BadWord") { }
- ~BadWordsImpl();
+ ~BadWordsImpl() override;
- BadWord* AddBadWord(const Anope::string &word, BadWordType type) anope_override
+ BadWord* AddBadWord(const Anope::string &word, BadWordType type) override
{
BadWordImpl *bw = new BadWordImpl();
bw->chan = ci->name;
@@ -51,7 +51,7 @@ struct BadWordsImpl : BadWords
return bw;
}
- BadWord* GetBadWord(unsigned index) const anope_override
+ BadWord* GetBadWord(unsigned index) const override
{
if (this->badwords->empty() || index >= this->badwords->size())
return NULL;
@@ -61,12 +61,12 @@ struct BadWordsImpl : BadWords
return bw;
}
- unsigned GetBadWordCount() const anope_override
+ unsigned GetBadWordCount() const override
{
return this->badwords->size();
}
- void EraseBadWord(unsigned index) anope_override
+ void EraseBadWord(unsigned index) override
{
if (this->badwords->empty() || index >= this->badwords->size())
return;
@@ -76,13 +76,13 @@ struct BadWordsImpl : BadWords
delete this->badwords->at(index);
}
- void ClearBadWords() anope_override
+ void ClearBadWords() override
{
while (!this->badwords->empty())
delete this->badwords->back();
}
- void Check() anope_override
+ void Check() override
{
if (this->badwords->empty())
ci->Shrink<BadWords>("badwords");
@@ -150,17 +150,17 @@ class BadwordsDelCallback : public NumberList
ChannelInfo *ci;
BadWords *bw;
Command *c;
- unsigned deleted;
- bool override;
+ unsigned deleted = 0;
+ bool override = false;
public:
- BadwordsDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, const Anope::string &list) : NumberList(list, true), source(_source), ci(_ci), c(_c), deleted(0), override(false)
+ BadwordsDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, const Anope::string &list) : NumberList(list, true), source(_source), ci(_ci), c(_c)
{
if (!source.AccessFor(ci).HasPriv("BADWORDS") && source.HasPriv("botserv/administration"))
this->override = true;
bw = ci->Require<BadWords>("badwords");
}
- ~BadwordsDelCallback()
+ ~BadwordsDelCallback() override
{
if (!deleted)
source.Reply(_("No matching entries on %s bad words list."), ci->name.c_str());
@@ -170,7 +170,7 @@ class BadwordsDelCallback : public NumberList
source.Reply(_("Deleted %d entries from %s bad words list."), deleted, ci->name.c_str());
}
- void HandleNumber(unsigned Number) anope_override
+ void HandleNumber(unsigned Number) override
{
if (!bw || !Number || Number > bw->GetBadWordCount())
return;
@@ -209,7 +209,7 @@ class CommandBSBadwords : public Command
{
}
- void HandleNumber(unsigned Number) anope_override
+ void HandleNumber(unsigned Number) override
{
if (!Number || Number > bw->GetBadWordCount())
return;
@@ -251,8 +251,8 @@ class CommandBSBadwords : public Command
source.Reply(_("Bad words list for %s:"), ci->name.c_str());
- for (unsigned i = 0; i < replies.size(); ++i)
- source.Reply(replies[i]);
+ for (const auto &reply : replies)
+ source.Reply(reply);
source.Reply(_("End of bad words list."));
}
@@ -374,7 +374,7 @@ class CommandBSBadwords : public Command
this->SetSyntax(_("\037channel\037 CLEAR"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &cmd = params[1];
const Anope::string &word = params.size() > 2 ? params[2] : "";
@@ -417,7 +417,7 @@ class CommandBSBadwords : public Command
this->OnSyntaxError(source, "");
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/bs_bot.cpp b/modules/commands/bs_bot.cpp
index 547dca06e..ee44437dd 100644
--- a/modules/commands/bs_bot.cpp
+++ b/modules/commands/bs_bot.cpp
@@ -272,7 +272,7 @@ class CommandBSBot : public Command
this->SetSyntax(_("\002DEL \037nick\037\002"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &cmd = params[0];
@@ -345,7 +345,7 @@ class CommandBSBot : public Command
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/bs_botlist.cpp b/modules/commands/bs_botlist.cpp
index 71d8ee3ee..b124aa2ce 100644
--- a/modules/commands/bs_botlist.cpp
+++ b/modules/commands/bs_botlist.cpp
@@ -19,17 +19,15 @@ class CommandBSBotList : public Command
this->SetDesc(_("Lists available bots"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
unsigned count = 0;
ListFormatter list(source.GetAccount());
list.AddColumn(_("Nick")).AddColumn(_("Mask"));
- for (botinfo_map::const_iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it)
+ for (const auto &[_, bi] : *BotListByNick)
{
- BotInfo *bi = it->second;
-
if (source.HasPriv("botserv/administration") || !bi->oper_only)
{
++count;
@@ -50,14 +48,14 @@ class CommandBSBotList : public Command
{
source.Reply(_("Bot list:"));
- for (unsigned i = 0; i < replies.size(); ++i)
- source.Reply(replies[i]);
+ for (const auto &reply : replies)
+ source.Reply(reply);
source.Reply(_("%d bots available."), count);
}
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/bs_control.cpp b/modules/commands/bs_control.cpp
index 7cbcd9d0a..8bb93327b 100644
--- a/modules/commands/bs_control.cpp
+++ b/modules/commands/bs_control.cpp
@@ -20,7 +20,7 @@ class CommandBSSay : public Command
this->SetSyntax(_("\037channel\037 \037text\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &text = params[1];
@@ -62,7 +62,7 @@ class CommandBSSay : public Command
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to say: " << text;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -80,7 +80,7 @@ class CommandBSAct : public Command
this->SetSyntax(_("\037channel\037 \037text\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
Anope::string message = params[1];
@@ -120,7 +120,7 @@ class CommandBSAct : public Command
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to say: " << message;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/bs_info.cpp b/modules/commands/bs_info.cpp
index 22ae3d31b..d9b3afe1d 100644
--- a/modules/commands/bs_info.cpp
+++ b/modules/commands/bs_info.cpp
@@ -17,10 +17,8 @@ class CommandBSInfo : public Command
void send_bot_channels(std::vector<Anope::string> &buffers, const BotInfo *bi)
{
Anope::string buf;
- for (registered_channel_map::const_iterator it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; ++it)
+ for (const auto &[_, ci] : *RegisteredChannelList)
{
- const ChannelInfo *ci = it->second;
-
if (ci->bi == bi)
{
buf += " " + ci->name + " ";
@@ -41,7 +39,7 @@ class CommandBSInfo : public Command
this->SetSyntax(_("{\037channel\037 | \037nickname\037}"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &query = params[0];
@@ -63,15 +61,15 @@ class CommandBSInfo : public Command
std::vector<Anope::string> replies;
info.Process(replies);
- for (unsigned i = 0; i < replies.size(); ++i)
- source.Reply(replies[i]);
+ for (const auto &reply : replies)
+ source.Reply(reply);
if (source.HasPriv("botserv/administration"))
{
std::vector<Anope::string> buf;
this->send_bot_channels(buf, bi);
- for (unsigned i = 0; i < buf.size(); ++i)
- source.Reply(buf[i]);
+ for (const auto &line : buf)
+ source.Reply(line);
}
}
@@ -94,14 +92,14 @@ class CommandBSInfo : public Command
std::vector<Anope::string> replies;
info.Process(replies);
- for (unsigned i = 0; i < replies.size(); ++i)
- source.Reply(replies[i]);
+ for (const auto &reply : replies)
+ source.Reply(reply);
}
else
source.Reply(_("\002%s\002 is not a valid bot or registered channel."), query.c_str());
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -113,7 +111,7 @@ class CommandBSInfo : public Command
return true;
}
- const Anope::string GetDesc(CommandSource &source) const anope_override
+ const Anope::string GetDesc(CommandSource &source) const override
{
return Anope::printf(Language::Translate(source.GetAccount(), _("Allows you to see %s information about a channel or a bot")), source.service->nick.c_str());
}
diff --git a/modules/commands/bs_kick.cpp b/modules/commands/bs_kick.cpp
index eeeaf4b22..051400d16 100644
--- a/modules/commands/bs_kick.cpp
+++ b/modules/commands/bs_kick.cpp
@@ -20,8 +20,8 @@ struct KickerDataImpl : KickerData
KickerDataImpl(Extensible *obj)
{
amsgs = badwords = bolds = caps = colors = flood = italics = repeat = reverses = underlines = false;
- for (int16_t i = 0; i < TTB_SIZE; ++i)
- ttb[i] = 0;
+ for (auto &ttbtype : ttb)
+ ttbtype = 0;
capsmin = capspercent = 0;
floodlines = floodsecs = 0;
repeattimes = 0;
@@ -29,7 +29,7 @@ struct KickerDataImpl : KickerData
dontkickops = dontkickvoices = false;
}
- void Check(ChannelInfo *ci) anope_override
+ void Check(ChannelInfo *ci) override
{
if (amsgs || badwords || bolds || caps || colors || flood || italics || repeat || reverses || underlines || dontkickops || dontkickvoices)
return;
@@ -41,7 +41,7 @@ struct KickerDataImpl : KickerData
{
ExtensibleItem(Module *m, const Anope::string &ename) : ::ExtensibleItem<KickerDataImpl>(m, ename) { }
- void ExtensibleSerialize(const Extensible *e, const Serializable *s, Serialize::Data &data) const anope_override
+ void ExtensibleSerialize(const Extensible *e, const Serializable *s, Serialize::Data &data) const override
{
if (s->GetSerializableType()->GetName() != "ChannelInfo")
return;
@@ -69,11 +69,11 @@ struct KickerDataImpl : KickerData
data.SetType("repeattimes", Serialize::Data::DT_INT); data["repeattimes"] << kd->repeattimes;
data.SetType("dontkickops", Serialize::Data::DT_INT); data["dontkickops"] << kd->dontkickops;
data.SetType("dontkickvoices", Serialize::Data::DT_INT); data["dontkickvoices"] << kd->dontkickvoices;
- for (int16_t i = 0; i < TTB_SIZE; ++i)
- data["ttb"] << kd->ttb[i] << " ";
+ for (auto ttbtype : kd->ttb)
+ data["ttb"] << ttbtype << " ";
}
- void ExtensibleUnserialize(Extensible *e, Serializable *s, Serialize::Data &data) anope_override
+ void ExtensibleUnserialize(Extensible *e, Serializable *s, Serialize::Data &data) override
{
if (s->GetSerializableType()->GetName() != "ChannelInfo")
return;
@@ -124,23 +124,20 @@ class CommandBSKick : public Command
this->SetSyntax(_("\037option\037 \037channel\037 {\037ON|OFF\037} [\037settings\037]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
this->OnSyntaxError(source, "");
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
source.Reply(_("Configures bot kickers. \037option\037 can be one of:"));
Anope::string this_name = source.command;
- for (CommandInfo::map::const_iterator it = source.service->commands.begin(), it_end = source.service->commands.end(); it != it_end; ++it)
+ for (const auto &[c_name, info] : source.service->commands)
{
- const Anope::string &c_name = it->first;
- const CommandInfo &info = it->second;
-
if (c_name.find_ci(this_name + " ") == 0)
{
ServiceReference<Command> command("Command", info.name);
@@ -169,9 +166,9 @@ class CommandBSKickBase : public Command
{
}
- virtual void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override = 0;
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override = 0;
- virtual bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override = 0;
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override = 0;
protected:
bool CheckArguments(CommandSource &source, const std::vector<Anope::string> &params, ChannelInfo* &ci)
@@ -256,7 +253,7 @@ class CommandBSKickAMSG : public CommandBSKickBase
this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
ChannelInfo *ci;
if (CheckArguments(source, params, ci))
@@ -267,7 +264,7 @@ class CommandBSKickAMSG : public CommandBSKickBase
}
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -292,7 +289,7 @@ class CommandBSKickBadwords : public CommandBSKickBase
this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
ChannelInfo *ci;
if (CheckArguments(source, params, ci))
@@ -304,7 +301,7 @@ class CommandBSKickBadwords : public CommandBSKickBase
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -331,7 +328,7 @@ class CommandBSKickBolds : public CommandBSKickBase
this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
ChannelInfo *ci;
if (CheckArguments(source, params, ci))
@@ -342,7 +339,7 @@ class CommandBSKickBolds : public CommandBSKickBase
}
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -365,7 +362,7 @@ class CommandBSKickCaps : public CommandBSKickBase
this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037 [\037min\037 [\037percent\037]]]\002"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
ChannelInfo *ci;
if (!CheckArguments(source, params, ci))
@@ -433,7 +430,7 @@ class CommandBSKickCaps : public CommandBSKickBase
kd->Check(ci);
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -461,7 +458,7 @@ class CommandBSKickColors : public CommandBSKickBase
this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
ChannelInfo *ci;
if (CheckArguments(source, params, ci))
@@ -472,7 +469,7 @@ class CommandBSKickColors : public CommandBSKickBase
}
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -495,7 +492,7 @@ class CommandBSKickFlood : public CommandBSKickBase
this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037 [\037ln\037 [\037secs\037]]]\002"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
ChannelInfo *ci;
if (!CheckArguments(source, params, ci))
@@ -568,7 +565,7 @@ class CommandBSKickFlood : public CommandBSKickBase
kd->Check(ci);
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -593,7 +590,7 @@ class CommandBSKickItalics : public CommandBSKickBase
this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
ChannelInfo *ci;
if (CheckArguments(source, params, ci))
@@ -604,7 +601,7 @@ class CommandBSKickItalics : public CommandBSKickBase
}
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -627,7 +624,7 @@ class CommandBSKickRepeat : public CommandBSKickBase
this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037 [\037num\037]]\002"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
ChannelInfo *ci;
if (!CheckArguments(source, params, ci))
@@ -703,7 +700,7 @@ class CommandBSKickRepeat : public CommandBSKickBase
kd->Check(ci);
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -728,7 +725,7 @@ class CommandBSKickReverses : public CommandBSKickBase
this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
ChannelInfo *ci;
if (CheckArguments(source, params, ci))
@@ -739,7 +736,7 @@ class CommandBSKickReverses : public CommandBSKickBase
}
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -762,7 +759,7 @@ class CommandBSKickUnderlines : public CommandBSKickBase
this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
ChannelInfo *ci;
if (CheckArguments(source, params, ci))
@@ -773,7 +770,7 @@ class CommandBSKickUnderlines : public CommandBSKickBase
}
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -796,7 +793,7 @@ class CommandBSSetDontKickOps : public Command
this->SetSyntax(_("\037channel\037 {ON | OFF}"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL)
@@ -841,7 +838,7 @@ class CommandBSSetDontKickOps : public Command
kd->Check(ci);
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(_(" \n"
@@ -861,7 +858,7 @@ class CommandBSSetDontKickVoices : public Command
this->SetSyntax(_("\037channel\037 {ON | OFF}"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL)
@@ -906,7 +903,7 @@ class CommandBSSetDontKickVoices : public Command
kd->Check(ci);
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(_(" \n"
@@ -928,8 +925,8 @@ struct BanData
Data()
{
last_use = 0;
- for (int i = 0; i < TTB_SIZE; ++i)
- this->ttb[i] = 0;
+ for (auto &ttbtype : this->ttb)
+ ttbtype = 0;
}
};
@@ -993,14 +990,12 @@ class BanDataPurger : public Timer
public:
BanDataPurger(Module *o) : Timer(o, 300, Anope::CurTime, true) { }
- void Tick(time_t) anope_override
+ void Tick(time_t) override
{
Log(LOG_DEBUG) << "bs_main: Running bandata purger";
- for (channel_map::iterator it = ChannelList.begin(), it_end = ChannelList.end(); it != it_end; ++it)
+ for (auto &[_, c] : ChannelList)
{
- Channel *c = it->second;
-
BanData *bd = c->GetExt<BanData>("bandata");
if (bd != NULL)
{
@@ -1049,7 +1044,7 @@ class BSKick : public Module
UserData *ud = userdata.Require(uc);
return ud;
- }
+ }
void check_ban(ChannelInfo *ci, User *u, KickerData *kd, int ttbtype)
{
@@ -1110,7 +1105,7 @@ class BSKick : public Module
}
- void OnBotInfo(CommandSource &source, BotInfo *bi, ChannelInfo *ci, InfoFormatter &info) anope_override
+ void OnBotInfo(CommandSource &source, BotInfo *bi, ChannelInfo *ci, InfoFormatter &info) override
{
if (!ci)
return;
@@ -1225,7 +1220,7 @@ class BSKick : public Module
info.AddOption(_("Voices protection"));
}
- void OnPrivmsg(User *u, Channel *c, Anope::string &msg) anope_override
+ void OnPrivmsg(User *u, Channel *c, Anope::string &msg) override
{
/* Now we can make kicker stuff. We try to order the checks
* from the fastest one to the slowest one, since there's
@@ -1308,11 +1303,11 @@ class BSKick : public Module
{
int i = 0, l = 0;
- for (unsigned j = 0, end = realbuf.length(); j < end; ++j)
+ for (auto chr : realbuf)
{
- if (isupper(realbuf[j]))
+ if (isupper(chr))
++i;
- else if (islower(realbuf[j]))
+ else if (islower(chr))
++l;
}
diff --git a/modules/commands/bs_set.cpp b/modules/commands/bs_set.cpp
index 74e614075..0670b537f 100644
--- a/modules/commands/bs_set.cpp
+++ b/modules/commands/bs_set.cpp
@@ -20,12 +20,12 @@ class CommandBSSet : public Command
this->SetSyntax(_("\037option\037 \037(channel | bot)\037 \037settings\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
this->OnSyntaxError(source, "");
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -35,10 +35,8 @@ class CommandBSSet : public Command
bool hide_privileged_commands = Config->GetBlock("options")->Get<bool>("hideprivilegedcommands"),
hide_registered_commands = Config->GetBlock("options")->Get<bool>("hideregisteredcommands");
Anope::string this_name = source.command;
- for (CommandInfo::map::const_iterator it = source.service->commands.begin(), it_end = source.service->commands.end(); it != it_end; ++it)
+ for (const auto &[c_name, info] : source.service->commands)
{
- const Anope::string &c_name = it->first;
- const CommandInfo &info = it->second;
if (c_name.find_ci(this_name + " ") == 0)
{
if (info.hide)
@@ -54,7 +52,7 @@ class CommandBSSet : public Command
if (hide_privileged_commands && !info.permission.empty() && !source.HasCommand(info.permission))
continue;
- source.command = it->first;
+ source.command = c_name;
command->OnServHelp(source);
}
}
@@ -77,7 +75,7 @@ class CommandBSSetBanExpire : public Command
public:
UnbanTimer(Module *creator, const Anope::string &ch, const Anope::string &bmask, time_t t) : Timer(creator, t), chname(ch), mask(bmask) { }
- void Tick(time_t) anope_override
+ void Tick(time_t) override
{
Channel *c = Channel::Find(chname);
if (c)
@@ -91,7 +89,7 @@ class CommandBSSetBanExpire : public Command
this->SetSyntax(_("\037channel\037 \037time\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &chan = params[0];
const Anope::string &arg = params[1];
@@ -141,7 +139,7 @@ class CommandBSSetBanExpire : public Command
source.Reply(_("Bot bans will automatically expire after %s."), Anope::Duration(ci->banexpire, source.GetAccount()).c_str());
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(_(" \n"
@@ -162,7 +160,7 @@ class CommandBSSetPrivate : public Command
this->SetSyntax(_("\037botname\037 {\037ON|OFF\037}"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
BotInfo *bi = BotInfo::Find(params[0], true);
const Anope::string &value = params[1];
@@ -193,7 +191,7 @@ class CommandBSSetPrivate : public Command
this->OnSyntaxError(source, source.command);
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(_(" \n"
@@ -216,7 +214,7 @@ class BSSet : public Module
{
}
- void OnBotBan(User *u, ChannelInfo *ci, const Anope::string &mask) anope_override
+ void OnBotBan(User *u, ChannelInfo *ci, const Anope::string &mask) override
{
if (!ci->banexpire)
return;
diff --git a/modules/commands/cs_access.cpp b/modules/commands/cs_access.cpp
index 1a6c93514..f1d132963 100644
--- a/modules/commands/cs_access.cpp
+++ b/modules/commands/cs_access.cpp
@@ -16,30 +16,30 @@ static std::map<Anope::string, int16_t, ci::less> defaultLevels;
static inline void reset_levels(ChannelInfo *ci)
{
ci->ClearLevels();
- for (std::map<Anope::string, int16_t, ci::less>::iterator it = defaultLevels.begin(), it_end = defaultLevels.end(); it != it_end; ++it)
- ci->SetLevel(it->first, it->second);
+ for (auto &[priv, level] : defaultLevels)
+ ci->SetLevel(priv, level);
}
class AccessChanAccess : public ChanAccess
{
public:
- int level;
+ int level = 0;
- AccessChanAccess(AccessProvider *p) : ChanAccess(p), level(0)
+ AccessChanAccess(AccessProvider *p) : ChanAccess(p)
{
}
- bool HasPriv(const Anope::string &name) const anope_override
+ bool HasPriv(const Anope::string &name) const override
{
return this->ci->GetLevel(name) != ACCESS_INVALID && this->level >= this->ci->GetLevel(name);
}
- Anope::string AccessSerialize() const anope_override
+ Anope::string AccessSerialize() const override
{
return stringify(this->level);
}
- void AccessUnserialize(const Anope::string &data) anope_override
+ void AccessUnserialize(const Anope::string &data) override
{
try
{
@@ -50,7 +50,7 @@ class AccessChanAccess : public ChanAccess
}
}
- bool operator>(const ChanAccess &other) const anope_override
+ bool operator>(const ChanAccess &other) const override
{
if (this->provider != other.provider)
return ChanAccess::operator>(other);
@@ -58,7 +58,7 @@ class AccessChanAccess : public ChanAccess
return this->level > anope_dynamic_static_cast<const AccessChanAccess *>(&other)->level;
}
- bool operator<(const ChanAccess &other) const anope_override
+ bool operator<(const ChanAccess &other) const override
{
if (this->provider != other.provider)
return ChanAccess::operator<(other);
@@ -77,7 +77,7 @@ class AccessAccessProvider : public AccessProvider
me = this;
}
- ChanAccess *Create() anope_override
+ ChanAccess *Create() override
{
return new AccessChanAccess(this);
}
@@ -214,6 +214,7 @@ class CommandCSAccess : public Command
access->level = level;
access->last_seen = 0;
access->created = Anope::CurTime;
+ access->description = params.size() > 4 ? params[4] : "";
ci->AddAccess(access);
FOREACH_MOD(OnAccessAdd, (ci, source, access));
@@ -250,18 +251,18 @@ class CommandCSAccess : public Command
CommandSource &source;
ChannelInfo *ci;
Command *c;
- unsigned deleted;
+ unsigned deleted = 0;
Anope::string Nicks;
- bool denied;
- bool override;
+ bool denied = false;
+ bool override = false;
public:
- AccessDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, const Anope::string &numlist) : NumberList(numlist, true), source(_source), ci(_ci), c(_c), deleted(0), denied(false), override(false)
+ AccessDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, const Anope::string &numlist) : NumberList(numlist, true), source(_source), ci(_ci), c(_c)
{
if (!source.AccessFor(ci).HasPriv("ACCESS_CHANGE") && source.HasPriv("chanserv/access/modify"))
this->override = true;
}
- ~AccessDelCallback()
+ ~AccessDelCallback() override
{
if (denied && !deleted)
source.Reply(ACCESS_DENIED);
@@ -278,7 +279,7 @@ class CommandCSAccess : public Command
}
}
- void HandleNumber(unsigned Number) anope_override
+ void HandleNumber(unsigned Number) override
{
if (!Number || Number > ci->GetAccessCount())
return;
@@ -359,7 +360,7 @@ class CommandCSAccess : public Command
{
}
- void HandleNumber(unsigned number) anope_override
+ void HandleNumber(unsigned number) override
{
if (!number || number > ci->GetAccessCount())
return;
@@ -368,12 +369,14 @@ class CommandCSAccess : public Command
Anope::string timebuf;
if (ci->c)
- for (Channel::ChanUserList::const_iterator cit = ci->c->users.begin(), cit_end = ci->c->users.end(); cit != cit_end; ++cit)
+ {
+ for (const auto &[_, cuc] : ci->c->users)
{
ChannelInfo *p;
- if (access->Matches(cit->second->user, cit->second->user->Account(), p))
+ if (access->Matches(cuc->user, cuc->user->Account(), p))
timebuf = "Now";
}
+ }
if (timebuf.empty())
{
if (access->last_seen == 0)
@@ -388,6 +391,7 @@ class CommandCSAccess : public Command
entry["Mask"] = access->Mask();
entry["By"] = access->creator;
entry["Last seen"] = timebuf;
+ entry["Description"] = access->description;
this->list.AddEntry(entry);
}
}
@@ -405,12 +409,14 @@ class CommandCSAccess : public Command
Anope::string timebuf;
if (ci->c)
- for (Channel::ChanUserList::const_iterator cit = ci->c->users.begin(), cit_end = ci->c->users.end(); cit != cit_end; ++cit)
+ {
+ for (auto &[_, cuc] : ci->c->users)
{
ChannelInfo *p;
- if (access->Matches(cit->second->user, cit->second->user->Account(), p))
+ if (access->Matches(cuc->user, cuc->user->Account(), p))
timebuf = "Now";
}
+ }
if (timebuf.empty())
{
if (access->last_seen == 0)
@@ -425,6 +431,7 @@ class CommandCSAccess : public Command
entry["Mask"] = access->Mask();
entry["By"] = access->creator;
entry["Last seen"] = timebuf;
+ entry["Description"] = access->description;
list.AddEntry(entry);
}
}
@@ -438,8 +445,8 @@ class CommandCSAccess : public Command
source.Reply(_("Access list for %s:"), ci->name.c_str());
- for (unsigned i = 0; i < replies.size(); ++i)
- source.Reply(replies[i]);
+ for (const auto &reply : replies)
+ source.Reply(reply);
source.Reply(_("End of access list"));
}
@@ -456,7 +463,7 @@ class CommandCSAccess : public Command
}
ListFormatter list(source.GetAccount());
- list.AddColumn(_("Number")).AddColumn(_("Level")).AddColumn(_("Mask"));
+ list.AddColumn(_("Number")).AddColumn(_("Level")).AddColumn(_("Mask")).AddColumn(_("Description"));
this->ProcessList(source, ci, params, list);
}
@@ -469,7 +476,7 @@ class CommandCSAccess : public Command
}
ListFormatter list(source.GetAccount());
- list.AddColumn(_("Number")).AddColumn(_("Level")).AddColumn(_("Mask")).AddColumn(_("By")).AddColumn(_("Last seen"));
+ list.AddColumn(_("Number")).AddColumn(_("Level")).AddColumn(_("Mask")).AddColumn(_("By")).AddColumn(_("Last seen")).AddColumn(_("Description"));
this->ProcessList(source, ci, params, list);
}
@@ -493,17 +500,17 @@ class CommandCSAccess : public Command
}
public:
- CommandCSAccess(Module *creator) : Command(creator, "chanserv/access", 2, 4)
+ CommandCSAccess(Module *creator) : Command(creator, "chanserv/access", 2, 5)
{
this->SetDesc(_("Modify the list of privileged users"));
- this->SetSyntax(_("\037channel\037 ADD \037mask\037 \037level\037"));
+ this->SetSyntax(_("\037channel\037 ADD \037mask\037 \037level\037 [\037description\037]"));
this->SetSyntax(_("\037channel\037 DEL {\037mask\037 | \037entry-num\037 | \037list\037}"));
this->SetSyntax(_("\037channel\037 LIST [\037mask\037 | \037list\037]"));
this->SetSyntax(_("\037channel\037 VIEW [\037mask\037 | \037list\037]"));
this->SetSyntax(_("\037channel\037 CLEAR"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &cmd = params[1];
const Anope::string &nick = params.size() > 2 ? params[2] : "";
@@ -561,7 +568,7 @@ class CommandCSAccess : public Command
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -698,9 +705,8 @@ class CommandCSLevels : public Command
const std::vector<Privilege> &privs = PrivilegeManager::GetPrivileges();
- for (unsigned i = 0; i < privs.size(); ++i)
+ for (const auto &p : privs)
{
- const Privilege &p = privs[i];
int16_t j = ci->GetLevel(p.name);
ListFormatter::ListEntry entry;
@@ -719,8 +725,8 @@ class CommandCSLevels : public Command
std::vector<Anope::string> replies;
list.Process(replies);
- for (unsigned i = 0; i < replies.size(); ++i)
- source.Reply(replies[i]);
+ for (const auto &reply : replies)
+ source.Reply(reply);
}
void DoReset(CommandSource &source, ChannelInfo *ci)
@@ -745,7 +751,7 @@ class CommandCSLevels : public Command
this->SetSyntax(_("\037channel\037 RESET"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &cmd = params[1];
const Anope::string &what = params.size() > 2 ? params[2] : "";
@@ -789,7 +795,7 @@ class CommandCSLevels : public Command
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
if (subcommand.equals_ci("DESC"))
{
@@ -798,10 +804,8 @@ class CommandCSLevels : public Command
ListFormatter list(source.GetAccount());
list.AddColumn(_("Name")).AddColumn(_("Description"));
- const std::vector<Privilege> &privs = PrivilegeManager::GetPrivileges();
- for (unsigned i = 0; i < privs.size(); ++i)
+ for (const auto &p : PrivilegeManager::GetPrivileges())
{
- const Privilege &p = privs[i];
ListFormatter::ListEntry entry;
entry["Name"] = p.name;
entry["Description"] = Language::Translate(source.nc, p.desc.c_str());
@@ -811,8 +815,8 @@ class CommandCSLevels : public Command
std::vector<Anope::string> replies;
list.Process(replies);
- for (unsigned i = 0; i < replies.size(); ++i)
- source.Reply(replies[i]);
+ for (const auto &reply : replies)
+ source.Reply(reply);
}
else
{
@@ -856,7 +860,7 @@ class CSAccess : public Module
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
defaultLevels.clear();
@@ -882,12 +886,12 @@ class CSAccess : public Module
}
}
- void OnCreateChan(ChannelInfo *ci) anope_override
+ void OnCreateChan(ChannelInfo *ci) override
{
reset_levels(ci);
}
- EventReturn OnGroupCheckPriv(const AccessGroup *group, const Anope::string &priv) anope_override
+ EventReturn OnGroupCheckPriv(const AccessGroup *group, const Anope::string &priv) override
{
if (group->ci == NULL)
return EVENT_CONTINUE;
diff --git a/modules/commands/cs_akick.cpp b/modules/commands/cs_akick.cpp
index 4ccf2a3b4..78215dacd 100644
--- a/modules/commands/cs_akick.cpp
+++ b/modules/commands/cs_akick.cpp
@@ -96,10 +96,9 @@ class CommandCSAKick : public Command
/* Check excepts BEFORE we get this far */
if (ci->c)
{
- std::vector<Anope::string> modes = ci->c->GetModeList("EXCEPT");
- for (unsigned int i = 0; i < modes.size(); ++i)
+ for (const auto &mode : ci->c->GetModeList("EXCEPT"))
{
- if (Anope::Match(modes[i], mask))
+ if (Anope::Match(mode, mask))
{
source.Reply(CHAN_EXCEPTED, mask.c_str(), ci->name.c_str());
return;
@@ -129,10 +128,8 @@ class CommandCSAKick : public Command
{
/* Match against all currently online users with equal or
* higher access. - Viper */
- for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
+ for (const auto &[_, u2] : UserListByNick)
{
- User *u2 = it->second;
-
AccessGroup nc_access = ci->AccessFor(nc), u_access = source.AccessFor(ci);
Entry entry_mask("", mask);
@@ -145,9 +142,9 @@ class CommandCSAKick : public Command
/* Match against the lastusermask of all nickalias's with equal
* or higher access. - Viper */
- for (nickalias_map::const_iterator it = NickAliasList->begin(), it_end = NickAliasList->end(); it != it_end; ++it)
+ for (const auto &[_, na2] : *NickAliasList)
{
- na = it->second;
+ na = na2;
AccessGroup nc_access = ci->AccessFor(na->nc), u_access = source.AccessFor(ci);
if (na->nc && (na->nc == ci->GetFounder() || nc_access >= u_access))
@@ -211,14 +208,14 @@ class CommandCSAKick : public Command
CommandSource &source;
ChannelInfo *ci;
Command *c;
- unsigned deleted;
+ unsigned deleted = 0;
AccessGroup ag;
public:
- AkickDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, const Anope::string &list) : NumberList(list, true), source(_source), ci(_ci), c(_c), deleted(0), ag(source.AccessFor(ci))
+ AkickDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, const Anope::string &list) : NumberList(list, true), source(_source), ci(_ci), c(_c), ag(source.AccessFor(ci))
{
}
- ~AkickDelCallback()
+ ~AkickDelCallback() override
{
if (!deleted)
source.Reply(_("No matching entries on %s autokick list."), ci->name.c_str());
@@ -228,7 +225,7 @@ class CommandCSAKick : public Command
source.Reply(_("Deleted %d entries from %s autokick list."), deleted, ci->name.c_str());
}
- void HandleNumber(unsigned number) anope_override
+ void HandleNumber(unsigned number) override
{
if (!number || number > ci->GetAkickCount())
return;
@@ -293,7 +290,7 @@ class CommandCSAKick : public Command
{
}
- void HandleNumber(unsigned number) anope_override
+ void HandleNumber(unsigned number) override
{
if (!number || number > ci->GetAkickCount())
return;
@@ -373,8 +370,8 @@ class CommandCSAKick : public Command
source.Reply(_("Autokick list for %s:"), ci->name.c_str());
- for (unsigned i = 0; i < replies.size(); ++i)
- source.Reply(replies[i]);
+ for (const auto &reply : replies)
+ source.Reply(reply);
source.Reply(_("End of autokick list"));
}
@@ -440,7 +437,7 @@ class CommandCSAKick : public Command
this->SetSyntax(_("\037channel\037 CLEAR"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
Anope::string chan = params[0];
Anope::string cmd = params[1];
@@ -485,7 +482,7 @@ class CommandCSAKick : public Command
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
BotInfo *bi = Config->GetClient("NickServ");
this->SendSyntax(source);
@@ -538,7 +535,7 @@ class CSAKick : public Module
{
}
- EventReturn OnCheckKick(User *u, Channel *c, Anope::string &mask, Anope::string &reason) anope_override
+ EventReturn OnCheckKick(User *u, Channel *c, Anope::string &mask, Anope::string &reason) override
{
if (!c->ci || c->MatchesList(u, "EXCEPT"))
return EVENT_CONTINUE;
diff --git a/modules/commands/cs_ban.cpp b/modules/commands/cs_ban.cpp
index 88b0c5168..51e124948 100644
--- a/modules/commands/cs_ban.cpp
+++ b/modules/commands/cs_ban.cpp
@@ -23,7 +23,7 @@ class TempBan : public Timer
public:
TempBan(time_t seconds, Channel *c, const Anope::string &banmask, const Anope::string &mod) : Timer(me, seconds), channel(c->name), mask(banmask), mode(mod) { }
- void Tick(time_t ctime) anope_override
+ void Tick(time_t ctime) override
{
Channel *c = Channel::Find(this->channel);
if (c)
@@ -40,7 +40,7 @@ class CommandCSBan : public Command
this->SetSyntax(_("\037channel\037 [+\037expiry\037] {\037nick\037 | \037mask\037} [\037reason\037]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
Configuration::Block *block = Config->GetCommand(source);
const Anope::string &mode = block->Get<Anope::string>("mode", "BAN");
@@ -223,7 +223,7 @@ class CommandCSBan : public Command
}
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/cs_clone.cpp b/modules/commands/cs_clone.cpp
index 3074d13ec..c287f6a0b 100644
--- a/modules/commands/cs_clone.cpp
+++ b/modules/commands/cs_clone.cpp
@@ -44,6 +44,7 @@ class CommandCSClone : public Command
ChanAccess *newaccess = provider->Create();
newaccess->SetMask(taccess->Mask(), target_ci);
newaccess->creator = taccess->creator;
+ newaccess->description = taccess->description;
newaccess->last_seen = taccess->last_seen;
newaccess->created = taccess->created;
newaccess->AccessUnserialize(taccess->AccessSerialize());
@@ -98,11 +99,9 @@ class CommandCSClone : public Command
void CopyLevels(CommandSource &source, ChannelInfo *ci, ChannelInfo *target_ci)
{
- const Anope::map<int16_t> &cilevels = ci->GetLevelEntries();
-
- for (Anope::map<int16_t>::const_iterator it = cilevels.begin(); it != cilevels.end(); ++it)
+ for (const auto &[priv, level] : ci->GetLevelEntries())
{
- target_ci->SetLevel(it->first, it->second);
+ target_ci->SetLevel(priv, level);
}
source.Reply(_("All level entries from \002%s\002 have been cloned into \002%s\002."), ci->name.c_str(), target_ci->name.c_str());
@@ -115,7 +114,7 @@ public:
this->SetSyntax(_("\037channel\037 \037target\037 [\037what\037]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &channel = params[0];
const Anope::string &target = params[1];
@@ -198,8 +197,8 @@ public:
const Anope::string settings[] = { "NOAUTOOP", "CS_KEEP_MODES", "PEACE", "PERSIST", "RESTRICTED",
"CS_SECURE", "SECUREFOUNDER", "SECUREOPS", "SIGNKICK", "SIGNKICK_LEVEL", "CS_NO_EXPIRE" };
- for (unsigned int i = 0; i < sizeof(settings) / sizeof(Anope::string); ++i)
- CopySetting(ci, target_ci, settings[i]);
+ for (const auto &setting : settings)
+ CopySetting(ci, target_ci, setting);
CopyAccess(source, ci, target_ci);
CopyAkick(source, ci, target_ci);
@@ -235,7 +234,7 @@ public:
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to clone " << (what.empty() ? "everything from it" : what) << " to " << target_ci->name;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/cs_drop.cpp b/modules/commands/cs_drop.cpp
index a0e3311a4..86fd3256a 100644
--- a/modules/commands/cs_drop.cpp
+++ b/modules/commands/cs_drop.cpp
@@ -20,7 +20,7 @@ class CommandCSDrop : public Command
this->SetSyntax(_("\037channel\037 \037channel\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &chan = params[0];
@@ -66,7 +66,7 @@ class CommandCSDrop : public Command
c->CheckModes();
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/cs_enforce.cpp b/modules/commands/cs_enforce.cpp
index 2a8c43478..eca2d0651 100644
--- a/modules/commands/cs_enforce.cpp
+++ b/modules/commands/cs_enforce.cpp
@@ -29,10 +29,8 @@ class CommandCSEnforce : public Command
bool hadsecureops = ci->HasExt("SECUREOPS");
ci->Extend<bool>("SECUREOPS");
- for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
+ for (const auto &[_, uc] : ci->c->users)
{
- ChanUserContainer *uc = it->second;
-
ci->c->SetCorrectModes(uc->user, false);
}
@@ -48,9 +46,9 @@ class CommandCSEnforce : public Command
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enforce restricted";
std::vector<User *> users;
- for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
+
+ for (const auto &[_, uc] : ci->c->users)
{
- ChanUserContainer *uc = it->second;
User *user = uc->user;
if (user->IsProtected())
@@ -60,10 +58,8 @@ class CommandCSEnforce : public Command
users.push_back(user);
}
- for (unsigned i = 0; i < users.size(); ++i)
+ for (auto *user : users)
{
- User *user = users[i];
-
Anope::string mask = ci->GetIdealBan(user);
Anope::string reason = Language::Translate(user, _("RESTRICTED enforced by ")) + source.GetNick();
ci->c->SetMode(NULL, "BAN", mask);
@@ -79,9 +75,8 @@ class CommandCSEnforce : public Command
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enforce registered only";
std::vector<User *> users;
- for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
+ for (const auto &[_, uc] : ci->c->users)
{
- ChanUserContainer *uc = it->second;
User *user = uc->user;
if (user->IsProtected())
@@ -91,10 +86,8 @@ class CommandCSEnforce : public Command
users.push_back(user);
}
- for (unsigned i = 0; i < users.size(); ++i)
+ for (auto *user : users)
{
- User *user = users[i];
-
Anope::string mask = ci->GetIdealBan(user);
Anope::string reason = Language::Translate(user, _("REGONLY enforced by ")) + source.GetNick();
if (!ci->c->HasMode("REGISTEREDONLY"))
@@ -111,22 +104,19 @@ class CommandCSEnforce : public Command
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enforce SSL only";
std::vector<User *> users;
- for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
+ for (auto &[_, uc] : ci->c->users)
{
- ChanUserContainer *uc = it->second;
User *user = uc->user;
if (user->IsProtected())
continue;
- if (!user->HasMode("SSL") && !user->HasExt("ssl"))
+ if (!user->IsSecurelyConnected())
users.push_back(user);
}
- for (unsigned i = 0; i < users.size(); ++i)
+ for (auto *user : users)
{
- User *user = users[i];
-
Anope::string mask = ci->GetIdealBan(user);
Anope::string reason = Language::Translate(user, _("SSLONLY enforced by ")) + source.GetNick();
if (!ci->c->HasMode("SSL"))
@@ -143,9 +133,8 @@ class CommandCSEnforce : public Command
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enforce bans";
std::vector<User *> users;
- for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
+ for (const auto &[_, uc] : ci->c->users)
{
- ChanUserContainer *uc = it->second;
User *user = uc->user;
if (user->IsProtected())
@@ -155,10 +144,8 @@ class CommandCSEnforce : public Command
users.push_back(user);
}
- for (unsigned i = 0; i < users.size(); ++i)
+ for (auto *user : users)
{
- User *user = users[i];
-
Anope::string reason = Language::Translate(user, _("BANS enforced by ")) + source.GetNick();
ci->c->Kick(NULL, user, "%s", reason.c_str());
}
@@ -210,10 +197,8 @@ class CommandCSEnforce : public Command
users.push_back(user);
}
- for (unsigned i = 0; i < users.size(); ++i)
+ for (auto *user : users)
{
- User *user = users[i];
-
Anope::string reason = Language::Translate(user, _("LIMIT enforced by ")) + source.GetNick();
ci->c->Kick(NULL, user, "%s", reason.c_str());
}
@@ -228,7 +213,7 @@ class CommandCSEnforce : public Command
this->SetSyntax(_("\037channel\037 \037what\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &what = params.size() > 1 ? params[1] : "";
@@ -256,7 +241,7 @@ class CommandCSEnforce : public Command
this->OnSyntaxError(source, "");
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/cs_entrymsg.cpp b/modules/commands/cs_entrymsg.cpp
index 1817b9c44..0b6fdcbfe 100644
--- a/modules/commands/cs_entrymsg.cpp
+++ b/modules/commands/cs_entrymsg.cpp
@@ -26,9 +26,9 @@ struct EntryMsgImpl : EntryMsg, Serializable
this->when = ct;
}
- ~EntryMsgImpl();
+ ~EntryMsgImpl() override;
- void Serialize(Serialize::Data &data) const anope_override
+ void Serialize(Serialize::Data &data) const override
{
data["ci"] << this->chan;
data["creator"] << this->creator;
@@ -43,7 +43,7 @@ struct EntryMessageListImpl : EntryMessageList
{
EntryMessageListImpl(Extensible *) { }
- EntryMsg* Create() anope_override
+ EntryMsg* Create() override
{
return new EntryMsgImpl();
}
@@ -128,8 +128,8 @@ class CommandEntryMessage : public Command
std::vector<Anope::string> replies;
list.Process(replies);
- for (unsigned i = 0; i < replies.size(); ++i)
- source.Reply(replies[i]);
+ for (const auto &reply : replies)
+ source.Reply(reply);
source.Reply(_("End of entry message list."));
}
@@ -197,7 +197,7 @@ class CommandEntryMessage : public Command
this->SetSyntax(_("\037channel\037 CLEAR"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL)
@@ -232,7 +232,7 @@ class CommandEntryMessage : public Command
this->OnSyntaxError(source, "");
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -273,15 +273,15 @@ class CSEntryMessage : public Module
{
}
- void OnJoinChannel(User *u, Channel *c) anope_override
+ void OnJoinChannel(User *u, Channel *c) override
{
if (u && c && c->ci && u->server->IsSynced())
{
EntryMessageList *messages = c->ci->GetExt<EntryMessageList>("entrymsg");
if (messages != NULL)
- for (unsigned i = 0; i < (*messages)->size(); ++i)
- u->SendMessage(c->ci->WhoSends(), "[%s] %s", c->ci->name.c_str(), (*messages)->at(i)->message.c_str());
+ for (const auto &message : *(*messages))
+ u->SendMessage(c->ci->WhoSends(), "[%s] %s", c->ci->name.c_str(), message->message.c_str());
}
}
};
diff --git a/modules/commands/cs_flags.cpp b/modules/commands/cs_flags.cpp
index 47a18242e..54a99d7b6 100644
--- a/modules/commands/cs_flags.cpp
+++ b/modules/commands/cs_flags.cpp
@@ -22,7 +22,7 @@ class FlagsChanAccess : public ChanAccess
{
}
- bool HasPriv(const Anope::string &priv) const anope_override
+ bool HasPriv(const Anope::string &priv) const override
{
std::map<Anope::string, char>::iterator it = defaultFlags.find(priv);
if (it != defaultFlags.end() && this->flags.count(it->second) > 0)
@@ -30,12 +30,12 @@ class FlagsChanAccess : public ChanAccess
return false;
}
- Anope::string AccessSerialize() const anope_override
+ Anope::string AccessSerialize() const override
{
return Anope::string(this->flags.begin(), this->flags.end());
}
- void AccessUnserialize(const Anope::string &data) anope_override
+ void AccessUnserialize(const Anope::string &data) override
{
for (unsigned i = data.length(); i > 0; --i)
this->flags.insert(data[i - 1]);
@@ -48,9 +48,9 @@ class FlagsChanAccess : public ChanAccess
std::set<char> buffer;
- for (std::map<Anope::string, char>::iterator it = defaultFlags.begin(), it_end = defaultFlags.end(); it != it_end; ++it)
- if (access->HasPriv(it->first))
- buffer.insert(it->second);
+ for (auto &[priv, flag] : defaultFlags)
+ if (access->HasPriv(priv))
+ buffer.insert(flag);
if (buffer.empty())
return "(none)";
@@ -69,7 +69,7 @@ class FlagsAccessProvider : public AccessProvider
ap = this;
}
- ChanAccess *Create() anope_override
+ ChanAccess *Create() override
{
return new FlagsChanAccess(this);
}
@@ -78,7 +78,7 @@ FlagsAccessProvider* FlagsAccessProvider::ap;
class CommandCSFlags : public Command
{
- void DoModify(CommandSource &source, ChannelInfo *ci, Anope::string mask, const Anope::string &flags)
+ void DoModify(CommandSource &source, ChannelInfo *ci, Anope::string mask, const Anope::string &flags, const Anope::string &description)
{
if (flags.empty())
{
@@ -189,14 +189,14 @@ class CommandCSFlags : public Command
add = false;
break;
case '*':
- for (std::map<Anope::string, char>::iterator it = defaultFlags.begin(), it_end = defaultFlags.end(); it != it_end; ++it)
+ for (const auto &[priv, flag] : defaultFlags)
{
- bool has = current_flags.count(it->second);
+ bool has = current_flags.count(flag);
// If we are adding a flag they already have or removing one they don't have, don't bother
if (add == has)
continue;
- if (!u_access.HasPriv(it->first) && !u_access.founder)
+ if (!u_access.HasPriv(priv) && !u_access.founder)
{
if (source.HasPriv("chanserv/access/modify"))
override = true;
@@ -205,9 +205,9 @@ class CommandCSFlags : public Command
}
if (add)
- current_flags.insert(it->second);
+ current_flags.insert(flag);
else
- current_flags.erase(it->second);
+ current_flags.erase(flag);
}
break;
default:
@@ -218,11 +218,11 @@ class CommandCSFlags : public Command
i = flags.length();
}
- for (std::map<Anope::string, char>::iterator it = defaultFlags.begin(), it_end = defaultFlags.end(); it != it_end; ++it)
+ for (const auto &[priv, flag] : defaultFlags)
{
- if (f != it->second)
+ if (f != flag)
continue;
- else if (!u_access.HasPriv(it->first) && !u_access.founder)
+ else if (!u_access.HasPriv(priv) && !u_access.founder)
{
if (source.HasPriv("chanserv/access/modify"))
override = true;
@@ -262,7 +262,8 @@ class CommandCSFlags : public Command
return;
FlagsChanAccess *access = anope_dynamic_static_cast<FlagsChanAccess *>(provider->Create());
access->SetMask(mask, ci);
- access->creator = source.GetNick();
+ access->creator = source.GetNick();
+ access->description = current ? current->description : description;
access->last_seen = current ? current->last_seen : 0;
access->created = Anope::CurTime;
access->flags = current_flags;
@@ -298,7 +299,7 @@ class CommandCSFlags : public Command
ListFormatter list(source.GetAccount());
- list.AddColumn(_("Number")).AddColumn(_("Mask")).AddColumn(_("Flags")).AddColumn(_("Creator")).AddColumn(_("Created"));
+ list.AddColumn(_("Number")).AddColumn(_("Mask")).AddColumn(_("Flags")).AddColumn(_("Creator")).AddColumn(_("Created")).AddColumn(_("Description"));
unsigned count = 0;
for (unsigned i = 0, end = ci->GetAccessCount(); i < end; ++i)
@@ -328,6 +329,7 @@ class CommandCSFlags : public Command
entry["Flags"] = flags;
entry["Creator"] = access->creator;
entry["Created"] = Anope::strftime(access->created, source.nc, true);
+ entry["Description"] = access->description;
list.AddEntry(entry);
}
@@ -339,8 +341,8 @@ class CommandCSFlags : public Command
list.Process(replies);
source.Reply(_("Flags list for %s"), ci->name.c_str());
- for (unsigned i = 0; i < replies.size(); ++i)
- source.Reply(replies[i]);
+ for (const auto &reply : replies)
+ source.Reply(reply);
if (count == ci->GetAccessCount())
source.Reply(_("End of access list."));
else
@@ -368,15 +370,15 @@ class CommandCSFlags : public Command
}
public:
- CommandCSFlags(Module *creator) : Command(creator, "chanserv/flags", 1, 4)
+ CommandCSFlags(Module *creator) : Command(creator, "chanserv/flags", 1, 5)
{
this->SetDesc(_("Modify the list of privileged users"));
- this->SetSyntax(_("\037channel\037 [MODIFY] \037mask\037 \037changes\037"));
+ this->SetSyntax(_("\037channel\037 [MODIFY] \037mask\037 \037changes\037 [\037description\037]"));
this->SetSyntax(_("\037channel\037 LIST [\037mask\037 | +\037flags\037]"));
this->SetSyntax(_("\037channel\037 CLEAR"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &chan = params[0];
const Anope::string &cmd = params.size() > 1 ? params[1] : "";
@@ -409,23 +411,25 @@ class CommandCSFlags : public Command
this->DoClear(source, ci);
else
{
- Anope::string mask, flags;
+ Anope::string mask, flags, description;
if (cmd.equals_ci("MODIFY"))
{
mask = params.size() > 2 ? params[2] : "";
flags = params.size() > 3 ? params[3] : "";
+ description = params.size() > 4 ? params[4] : "";
}
else
{
mask = cmd;
flags = params.size() > 2 ? params[2] : "";
+ description = params.size() > 3 ? params[3] : "";
}
- this->DoModify(source, ci, mask, flags);
+ this->DoModify(source, ci, mask, flags, description);
}
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -450,15 +454,15 @@ class CommandCSFlags : public Command
typedef std::multimap<char, Anope::string, ci::less> reverse_map;
reverse_map reverse;
- for (std::map<Anope::string, char>::iterator it = defaultFlags.begin(), it_end = defaultFlags.end(); it != it_end; ++it)
- reverse.insert(std::make_pair(it->second, it->first));
+ for (auto &[priv, flag] : defaultFlags)
+ reverse.emplace(flag, priv);
- for (reverse_map::iterator it = reverse.begin(), it_end = reverse.end(); it != it_end; ++it)
+ for (auto &[flag, priv] : reverse)
{
- Privilege *p = PrivilegeManager::FindPrivilege(it->second);
+ Privilege *p = PrivilegeManager::FindPrivilege(priv);
if (p == NULL)
continue;
- source.Reply(" %c - %s", it->first, Language::Translate(source.nc, p->desc.c_str()));
+ source.Reply(" %c - %s", flag, Language::Translate(source.nc, p->desc.c_str()));
}
return true;
@@ -478,7 +482,7 @@ class CSFlags : public Module
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
defaultFlags.clear();
diff --git a/modules/commands/cs_getkey.cpp b/modules/commands/cs_getkey.cpp
index 678bf41d6..c184ecac2 100644
--- a/modules/commands/cs_getkey.cpp
+++ b/modules/commands/cs_getkey.cpp
@@ -20,7 +20,7 @@ class CommandCSGetKey : public Command
this->SetSyntax(_("\037channel\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &chan = params[0];
@@ -50,7 +50,7 @@ class CommandCSGetKey : public Command
source.Reply(_("Key for channel \002%s\002 is \002%s\002."), chan.c_str(), key.c_str());
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/cs_info.cpp b/modules/commands/cs_info.cpp
index f9d565bc9..d47f9f8c1 100644
--- a/modules/commands/cs_info.cpp
+++ b/modules/commands/cs_info.cpp
@@ -21,7 +21,7 @@ class CommandCSInfo : public Command
this->AllowUnregistered(true);
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &chan = params[0];
@@ -65,11 +65,11 @@ class CommandCSInfo : public Command
std::vector<Anope::string> replies;
info.Process(replies);
- for (unsigned i = 0; i < replies.size(); ++i)
- source.Reply(replies[i]);
+ for (const auto &reply : replies)
+ source.Reply(reply);
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/cs_invite.cpp b/modules/commands/cs_invite.cpp
index d95c954a1..91c98673f 100644
--- a/modules/commands/cs_invite.cpp
+++ b/modules/commands/cs_invite.cpp
@@ -20,7 +20,7 @@ class CommandCSInvite : public Command
this->SetSyntax(_("\037channel\037 [\037nick\037]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &chan = params[0];
@@ -84,7 +84,7 @@ class CommandCSInvite : public Command
}
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/cs_kick.cpp b/modules/commands/cs_kick.cpp
index a3c84ee87..5d2bce871 100644
--- a/modules/commands/cs_kick.cpp
+++ b/modules/commands/cs_kick.cpp
@@ -21,7 +21,7 @@ class CommandCSKick : public Command
this->SetSyntax(_("\037channel\037 \037mask\037 [\037reason\037]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &chan = params[0];
const Anope::string &target = params[1];
@@ -121,7 +121,7 @@ class CommandCSKick : public Command
source.Reply(NICK_X_NOT_IN_USE, target.c_str());
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/cs_list.cpp b/modules/commands/cs_list.cpp
index a3892090c..8323b6adb 100644
--- a/modules/commands/cs_list.cpp
+++ b/modules/commands/cs_list.cpp
@@ -21,7 +21,7 @@ class CommandCSList : public Command
this->SetSyntax(_("\037pattern\037 [SUSPENDED] [NOEXPIRE]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
Anope::string pattern = params[0];
unsigned nchans;
@@ -75,13 +75,11 @@ class CommandCSList : public Command
list.AddColumn(_("Name")).AddColumn(_("Description"));
Anope::map<ChannelInfo *> ordered_map;
- for (registered_channel_map::const_iterator it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; ++it)
- ordered_map[it->first] = it->second;
+ for (const auto &[cname, ci] : *RegisteredChannelList)
+ ordered_map[cname] = ci;
- for (Anope::map<ChannelInfo *>::const_iterator it = ordered_map.begin(), it_end = ordered_map.end(); it != it_end; ++it)
+ for (const auto &[_, ci] : ordered_map)
{
- const ChannelInfo *ci = it->second;
-
if (!is_servadmin)
{
if (ci->HasExt("CS_PRIVATE") || ci->HasExt("CS_SUSPENDED"))
@@ -124,13 +122,13 @@ class CommandCSList : public Command
std::vector<Anope::string> replies;
list.Process(replies);
- for (unsigned i = 0; i < replies.size(); ++i)
- source.Reply(replies[i]);
+ for (const auto &reply : replies)
+ source.Reply(reply);
source.Reply(_("End of list - %d/%d matches shown."), nchans > listmax ? listmax : nchans, nchans);
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -181,7 +179,7 @@ class CommandCSSetPrivate : public Command
this->SetSyntax(_("\037channel\037 {ON | OFF}"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (Anope::ReadOnly)
{
@@ -225,7 +223,7 @@ class CommandCSSetPrivate : public Command
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -253,7 +251,7 @@ class CSList : public Module
{
}
- void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_all) anope_override
+ void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_all) override
{
if (!show_all)
return;
diff --git a/modules/commands/cs_log.cpp b/modules/commands/cs_log.cpp
index 67d08e4e6..2a6f2d0ec 100644
--- a/modules/commands/cs_log.cpp
+++ b/modules/commands/cs_log.cpp
@@ -18,7 +18,7 @@ struct LogSettingImpl : LogSetting, Serializable
{
}
- ~LogSettingImpl()
+ ~LogSettingImpl() override
{
ChannelInfo *ci = ChannelInfo::Find(chan);
if (ci)
@@ -33,7 +33,7 @@ struct LogSettingImpl : LogSetting, Serializable
}
}
- void Serialize(Serialize::Data &data) const anope_override
+ void Serialize(Serialize::Data &data) const override
{
data["ci"] << chan;
data["service_name"] << service_name;
@@ -81,7 +81,7 @@ struct LogSettingsImpl : LogSettings
{
LogSettingsImpl(Extensible *) { }
- ~LogSettingsImpl()
+ ~LogSettingsImpl() override
{
for (iterator it = (*this)->begin(); it != (*this)->end();)
{
@@ -91,7 +91,7 @@ struct LogSettingsImpl : LogSettings
}
}
- LogSetting *Create() anope_override
+ LogSetting *Create() override
{
return new LogSettingImpl();
}
@@ -107,7 +107,7 @@ public:
this->SetSyntax(_("\037channel\037 \037command\037 \037method\037 [\037status\037]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &channel = params[0];
@@ -144,8 +144,8 @@ public:
std::vector<Anope::string> replies;
list.Process(replies);
- for (unsigned i = 0; i < replies.size(); ++i)
- source.Reply(replies[i]);
+ for (const auto &reply : replies)
+ source.Reply(reply);
}
}
else if (params.size() > 2)
@@ -199,12 +199,14 @@ public:
return;
}
- for (unsigned i = 0; i < extra.length(); ++i)
- if (ModeManager::GetStatusChar(extra[i]) == 0)
+ for (auto chr : extra)
+ {
+ if (ModeManager::GetStatusChar(chr) == 0)
{
- source.Reply(_("%c is an unknown status mode."), extra[i]);
+ source.Reply(_("%c is an unknown status mode."), chr);
return;
}
+ }
bool override = !source.AccessFor(ci).HasPriv("SET");
@@ -251,7 +253,7 @@ public:
this->OnSyntaxError(source, "");
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -301,7 +303,7 @@ class CSLog : public Module
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
Configuration::Block *block = conf->GetModule(this);
defaults.clear();
@@ -320,16 +322,14 @@ class CSLog : public Module
}
}
- void OnChanRegistered(ChannelInfo *ci) anope_override
+ void OnChanRegistered(ChannelInfo *ci) override
{
if (defaults.empty())
return;
LogSettings *ls = logsettings.Require(ci);
- for (unsigned i = 0; i < defaults.size(); ++i)
+ for (auto &d : defaults)
{
- LogDefault &d = defaults[i];
-
LogSetting *log = new LogSettingImpl();
log->chan = ci->name;
@@ -353,18 +353,17 @@ class CSLog : public Module
}
}
- void OnLog(Log *l) anope_override
+ void OnLog(Log *l) override
{
if (l->type != LOG_COMMAND || l->u == NULL || l->c == NULL || l->ci == NULL || !Me || !Me->IsSynced())
return;
LogSettings *ls = logsettings.Get(l->ci);
if (ls)
- for (unsigned i = 0; i < (*ls)->size(); ++i)
+ {
+ for (auto *log : *(*ls))
{
- const LogSetting *log = (*ls)->at(i);
-
- /* wrong command */
+ /* wrong command */
if (log->service_name != l->c->name)
continue;
@@ -393,6 +392,7 @@ class CSLog : public Module
else if (log->method.equals_ci("NOTICE") && l->ci->c)
IRCD->SendNotice(l->ci->WhoSends(), log->extra + l->ci->c->name, "%s", buffer.c_str());
}
+ }
}
};
diff --git a/modules/commands/cs_mode.cpp b/modules/commands/cs_mode.cpp
index 313dfe636..69e2247ba 100644
--- a/modules/commands/cs_mode.cpp
+++ b/modules/commands/cs_mode.cpp
@@ -18,7 +18,7 @@ struct ModeLockImpl : ModeLock, Serializable
{
}
- ~ModeLockImpl()
+ ~ModeLockImpl() override
{
ChannelInfo *chan = ChannelInfo::Find(ci);
if (chan)
@@ -29,7 +29,7 @@ struct ModeLockImpl : ModeLock, Serializable
}
}
- void Serialize(Serialize::Data &data) const anope_override;
+ void Serialize(Serialize::Data &data) const override;
static Serializable* Unserialize(Serializable *obj, Serialize::Data &data);
};
@@ -42,26 +42,23 @@ struct ModeLocksImpl : ModeLocks
{
}
- ~ModeLocksImpl()
+ ~ModeLocksImpl() override
{
ModeList modelist;
mlocks->swap(modelist);
- for (ModeList::iterator it = modelist.begin(); it != modelist.end(); ++it)
+ for (auto *ml : modelist)
{
- ModeLock *ml = *it;
delete ml;
}
}
- bool HasMLock(ChannelMode *mode, const Anope::string &param, bool status) const anope_override
+ bool HasMLock(ChannelMode *mode, const Anope::string &param, bool status) const override
{
if (!mode)
return false;
- for (ModeList::const_iterator it = this->mlocks->begin(); it != this->mlocks->end(); ++it)
+ for (auto *ml : *this->mlocks)
{
- const ModeLock *ml = *it;
-
if (ml->name == mode->name && ml->set == status && ml->param == param)
return true;
}
@@ -69,7 +66,7 @@ struct ModeLocksImpl : ModeLocks
return false;
}
- bool SetMLock(ChannelMode *mode, bool status, const Anope::string &param, Anope::string setter, time_t created = Anope::CurTime) anope_override
+ bool SetMLock(ChannelMode *mode, bool status, const Anope::string &param, Anope::string setter, time_t created = Anope::CurTime) override
{
if (!mode)
return false;
@@ -99,15 +96,13 @@ struct ModeLocksImpl : ModeLocks
return true;
}
- bool RemoveMLock(ChannelMode *mode, bool status, const Anope::string &param = "") anope_override
+ bool RemoveMLock(ChannelMode *mode, bool status, const Anope::string &param = "") override
{
if (!mode)
return false;
- for (ModeList::iterator it = this->mlocks->begin(); it != this->mlocks->end(); ++it)
+ for (auto *m : *this->mlocks)
{
- ModeLock *m = *it;
-
if (m->name == mode->name)
{
// For list or status modes, we must check the parameter
@@ -128,44 +123,41 @@ struct ModeLocksImpl : ModeLocks
return false;
}
- void RemoveMLock(ModeLock *mlock) anope_override
+ void RemoveMLock(ModeLock *mlock) override
{
ModeList::iterator it = std::find(this->mlocks->begin(), this->mlocks->end(), mlock);
if (it != this->mlocks->end())
this->mlocks->erase(it);
}
- void ClearMLock() anope_override
+ void ClearMLock() override
{
ModeList ml;
this->mlocks->swap(ml);
- for (unsigned i = 0; i < ml.size(); ++i)
- delete ml[i];
+ for (const auto *lock : ml)
+ delete lock;
}
- const ModeList &GetMLock() const anope_override
+ const ModeList &GetMLock() const override
{
return this->mlocks;
}
- std::list<ModeLock *> GetModeLockList(const Anope::string &name) anope_override
+ std::list<ModeLock *> GetModeLockList(const Anope::string &name) override
{
std::list<ModeLock *> mlist;
- for (ModeList::const_iterator it = this->mlocks->begin(); it != this->mlocks->end(); ++it)
+ for (auto *m : *this->mlocks)
{
- ModeLock *m = *it;
- if (m->name == name)
+ if (m->name == name)
mlist.push_back(m);
}
return mlist;
}
- const ModeLock *GetMLock(const Anope::string &mname, const Anope::string &param = "") anope_override
+ const ModeLock *GetMLock(const Anope::string &mname, const Anope::string &param = "") override
{
- for (ModeList::const_iterator it = this->mlocks->begin(); it != this->mlocks->end(); ++it)
+ for (auto *m : *this->mlocks)
{
- ModeLock *m = *it;
-
if (m->name == mname && m->param == param)
return m;
}
@@ -173,13 +165,12 @@ struct ModeLocksImpl : ModeLocks
return NULL;
}
- Anope::string GetMLockAsString(bool complete) const anope_override
+ Anope::string GetMLockAsString(bool complete) const override
{
Anope::string pos = "+", neg = "-", params;
- for (ModeList::const_iterator it = this->mlocks->begin(); it != this->mlocks->end(); ++it)
+ for (auto *ml : *this->mlocks)
{
- const ModeLock *ml = *it;
ChannelMode *cm = ModeManager::FindChannelModeByName(ml->name);
if (!cm || cm->type == MODE_LIST || cm->type == MODE_STATUS)
@@ -202,7 +193,7 @@ struct ModeLocksImpl : ModeLocks
return pos + neg + params;
}
- void Check() anope_override
+ void Check() override
{
if (this->mlocks->empty())
ci->Shrink<ModeLocks>("modelocks");
@@ -281,9 +272,8 @@ class CommandCSMode : public Command
if (subcommand.equals_ci("SET"))
{
const ModeLocks::ModeList mlocks = modelocks->GetMLock();
- for (ModeLocks::ModeList::const_iterator it = mlocks.begin(); it != mlocks.end(); ++it)
+ for (auto *ml : mlocks)
{
- const ModeLock *ml = *it;
ChannelMode *cm = ModeManager::FindChannelModeByName(ml->name);
if (cm && cm->CanSet(source.GetUser()))
modelocks->RemoveMLock(cm, ml->set, ml->param);
@@ -299,9 +289,9 @@ class CommandCSMode : public Command
int adding = 1;
bool needreply = true;
- for (size_t i = 0; i < modes.length(); ++i)
+ for (auto mode : modes)
{
- switch (modes[i])
+ switch (mode)
{
case '+':
adding = 1;
@@ -311,15 +301,15 @@ class CommandCSMode : public Command
break;
default:
needreply = false;
- ChannelMode *cm = ModeManager::FindChannelModeByChar(modes[i]);
+ ChannelMode *cm = ModeManager::FindChannelModeByChar(mode);
if (!cm)
{
- source.Reply(_("Unknown mode character %c ignored."), modes[i]);
+ source.Reply(_("Unknown mode character %c ignored."), mode);
break;
}
else if (u && !cm->CanSet(u))
{
- source.Reply(_("You may not (un)lock mode %c."), modes[i]);
+ source.Reply(_("You may not (un)lock mode %c."), mode);
break;
}
@@ -391,9 +381,9 @@ class CommandCSMode : public Command
int adding = 1;
bool needreply = true;
- for (size_t i = 0; i < modes.length(); ++i)
+ for (auto mode : modes)
{
- switch (modes[i])
+ switch (mode)
{
case '+':
adding = 1;
@@ -403,15 +393,15 @@ class CommandCSMode : public Command
break;
default:
needreply = false;
- ChannelMode *cm = ModeManager::FindChannelModeByChar(modes[i]);
+ ChannelMode *cm = ModeManager::FindChannelModeByChar(mode);
if (!cm)
{
- source.Reply(_("Unknown mode character %c ignored."), modes[i]);
+ source.Reply(_("Unknown mode character %c ignored."), mode);
break;
}
else if (u && !cm->CanSet(u))
{
- source.Reply(_("You may not (un)lock mode %c."), modes[i]);
+ source.Reply(_("You may not (un)lock mode %c."), mode);
break;
}
@@ -448,9 +438,8 @@ class CommandCSMode : public Command
ListFormatter list(source.GetAccount());
list.AddColumn(_("Mode")).AddColumn(_("Param")).AddColumn(_("Creator")).AddColumn(_("Created"));
- for (ModeLocks::ModeList::const_iterator it = mlocks.begin(), it_end = mlocks.end(); it != it_end; ++it)
+ for (auto *ml : mlocks)
{
- const ModeLock *ml = *it;
ChannelMode *cm = ModeManager::FindChannelModeByName(ml->name);
if (!cm)
continue;
@@ -468,8 +457,8 @@ class CommandCSMode : public Command
std::vector<Anope::string> replies;
list.Process(replies);
- for (unsigned i = 0; i < replies.size(); ++i)
- source.Reply(replies[i]);
+ for (const auto &reply : replies)
+ source.Reply(reply);
}
}
else
@@ -489,9 +478,9 @@ class CommandCSMode : public Command
bool override = !source.AccessFor(ci).HasPriv("MODE") && source.HasPriv("chanserv/administration");
int adding = -1;
- for (size_t i = 0; i < modes.length(); ++i)
+ for (auto mode : modes)
{
- switch (modes[i])
+ switch (mode)
{
case '+':
adding = 1;
@@ -521,7 +510,7 @@ class CommandCSMode : public Command
default:
if (adding == -1)
break;
- ChannelMode *cm = ModeManager::FindChannelModeByChar(modes[i]);
+ ChannelMode *cm = ModeManager::FindChannelModeByChar(mode);
if (!cm || (u && !cm->CanSet(u) && !can_override))
continue;
switch (cm->type)
@@ -665,10 +654,11 @@ class CommandCSMode : public Command
}
else
{
- std::vector<Anope::string> v = ci->c->GetModeList(cm->name);
- for (unsigned j = 0; j < v.size(); ++j)
- if (Anope::Match(v[j], param))
- ci->c->RemoveMode(NULL, cm, v[j]);
+ for (const auto &mode : ci->c->GetModeList(cm->name))
+ {
+ if (Anope::Match(mode, param))
+ ci->c->RemoveMode(NULL, cm, mode);
+ }
}
}
} // switch
@@ -685,8 +675,8 @@ class CommandCSMode : public Command
{
std::vector<Anope::string> new_params;
new_params.push_back(params[0]);
- new_params.push_back("SET");
- new_params.push_back("-*");
+ new_params.emplace_back("SET");
+ new_params.emplace_back("-*");
this->DoSet(source, ci, new_params);
return;
}
@@ -721,9 +711,9 @@ class CommandCSMode : public Command
std::vector<Anope::string> new_params;
new_params.push_back(params[0]);
- new_params.push_back("SET");
+ new_params.emplace_back("SET");
new_params.push_back("-" + stringify(cm->mchar));
- new_params.push_back("*");
+ new_params.emplace_back("*");
this->DoSet(source, ci, new_params);
}
@@ -736,7 +726,7 @@ class CommandCSMode : public Command
this->SetSyntax(_("\037channel\037 CLEAR [\037what\037]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &subcommand = params[1];
@@ -766,7 +756,7 @@ class CommandCSMode : public Command
this->OnSyntaxError(source, "");
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -807,7 +797,7 @@ class CommandCSModes : public Command
this->SetSyntax(_("\037channel\037 [\037user\037]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
User *u = source.GetUser(),
*targ = params.size() > 1 ? User::Find(params[1], true) : u;
@@ -879,7 +869,7 @@ class CommandCSModes : public Command
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "on " << targ->nick;
}
- const Anope::string GetDesc(CommandSource &source) const anope_override
+ const Anope::string GetDesc(CommandSource &source) const override
{
const std::pair<bool, Anope::string> &m = modes[source.command];
if (!m.second.empty())
@@ -893,7 +883,7 @@ class CommandCSModes : public Command
return "";
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
const std::pair<bool, Anope::string> &m = modes[source.command];
if (m.second.empty())
@@ -932,7 +922,7 @@ class CSMode : public Module
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
modes.clear();
@@ -956,17 +946,17 @@ class CSMode : public Module
}
}
- void OnCheckModes(Reference<Channel> &c) anope_override
+ void OnCheckModes(Reference<Channel> &c) override
{
if (!c || !c->ci)
return;
ModeLocks *locks = modelocks.Get(c->ci);
if (locks)
- for (ModeLocks::ModeList::const_iterator it = locks->GetMLock().begin(), it_end = locks->GetMLock().end(); it != it_end; ++it)
+ {
+ for (auto *ml : locks->GetMLock())
{
- const ModeLock *ml = *it;
- ChannelMode *cm = ModeManager::FindChannelModeByName(ml->name);
+ ChannelMode *cm = ModeManager::FindChannelModeByName(ml->name);
if (!cm)
continue;
@@ -1003,9 +993,10 @@ class CSMode : public Module
c->RemoveMode(NULL, cm, ml->param, false);
}
}
+ }
}
- void OnChanRegistered(ChannelInfo *ci) anope_override
+ void OnChanRegistered(ChannelInfo *ci) override
{
ModeLocks *ml = modelocks.Require(ci);
Anope::string mlock;
@@ -1013,21 +1004,21 @@ class CSMode : public Module
if (sep.GetToken(mlock))
{
bool add = true;
- for (unsigned i = 0; i < mlock.length(); ++i)
+ for (auto mode : mlock)
{
- if (mlock[i] == '+')
+ if (mode == '+')
{
add = true;
continue;
}
- if (mlock[i] == '-')
+ if (mode == '-')
{
add = false;
continue;
}
- ChannelMode *cm = ModeManager::FindChannelModeByChar(mlock[i]);
+ ChannelMode *cm = ModeManager::FindChannelModeByChar(mode);
if (!cm)
continue;
@@ -1055,7 +1046,7 @@ class CSMode : public Module
ml->Check();
}
- void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_hidden) anope_override
+ void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_hidden) override
{
if (!show_hidden)
return;
diff --git a/modules/commands/cs_register.cpp b/modules/commands/cs_register.cpp
index e69d83526..76066349e 100644
--- a/modules/commands/cs_register.cpp
+++ b/modules/commands/cs_register.cpp
@@ -20,7 +20,7 @@ class CommandCSRegister : public Command
this->SetSyntax(_("\037channel\037 [\037description\037]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &chan = params[0];
const Anope::string &chdesc = params.size() > 1 ? params[1] : "";
@@ -79,7 +79,7 @@ class CommandCSRegister : public Command
}
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/cs_seen.cpp b/modules/commands/cs_seen.cpp
index 84ca102dd..6bdb85bbf 100644
--- a/modules/commands/cs_seen.cpp
+++ b/modules/commands/cs_seen.cpp
@@ -36,14 +36,14 @@ struct SeenInfo : Serializable
{
}
- ~SeenInfo()
+ ~SeenInfo() override
{
database_map::iterator iter = database.find(nick);
if (iter != database.end() && iter->second == this)
database.erase(iter);
}
- void Serialize(Serialize::Data &data) const anope_override
+ void Serialize(Serialize::Data &data) const override
{
data["nick"] << nick;
data["vhost"] << vhost;
@@ -119,20 +119,20 @@ class CommandOSSeen : public Command
this->SetSyntax(_("CLEAR \037time\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (params[0].equals_ci("STATS"))
{
size_t mem_counter;
mem_counter = sizeof(database_map);
- for (database_map::iterator it = database.begin(), it_end = database.end(); it != it_end; ++it)
+ for (auto &[nick, si] : database)
{
mem_counter += (5 * sizeof(Anope::string)) + sizeof(TypeInfo) + sizeof(time_t);
- mem_counter += it->first.capacity();
- mem_counter += it->second->vhost.capacity();
- mem_counter += it->second->nick2.capacity();
- mem_counter += it->second->channel.capacity();
- mem_counter += it->second->message.capacity();
+ mem_counter += nick.capacity();
+ mem_counter += si->vhost.capacity();
+ mem_counter += si->nick2.capacity();
+ mem_counter += si->channel.capacity();
+ mem_counter += si->message.capacity();
}
source.Reply(_("%lu nicks are stored in the database, using %.2Lf kB of memory."), database.size(), static_cast<long double>(mem_counter) / 1024);
}
@@ -165,7 +165,7 @@ class CommandOSSeen : public Command
this->SendSyntax(source);
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -222,9 +222,8 @@ class CommandSeen : public Command
return;
}
- for (Channel::ChanUserList::const_iterator it = source.c->users.begin(), it_end = source.c->users.end(); it != it_end; ++it)
+ for (const auto &[_, uc] : source.c->users)
{
- ChanUserContainer *uc = it->second;
User *u = uc->user;
if (u->Account() == na->nc)
@@ -236,10 +235,8 @@ class CommandSeen : public Command
AccessGroup ag = source.c->ci->AccessFor(na->nc);
time_t last = 0;
- for (unsigned int i = 0; i < ag.paths.size(); ++i)
+ for (const auto &p : ag.paths)
{
- ChanAccess::Path &p = ag.paths[i];
-
if (p.empty())
continue;
@@ -263,7 +260,7 @@ class CommandSeen : public Command
this->AllowUnregistered(true);
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &target = params[0];
@@ -360,7 +357,7 @@ class CommandSeen : public Command
}
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -381,12 +378,12 @@ class CSSeen : public Module
{
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
simple = conf->GetModule(this)->Get<bool>("simple");
}
- void OnExpireTick() anope_override
+ void OnExpireTick() override
{
size_t previous_size = database.size();
time_t purgetime = Config->GetModule(this)->Get<time_t>("purgetime");
@@ -406,34 +403,34 @@ class CSSeen : public Module
Log(LOG_DEBUG) << "cs_seen: Purged database, checked " << previous_size << " nicks and removed " << (previous_size - database.size()) << " old entries.";
}
- void OnUserConnect(User *u, bool &exempt) anope_override
+ void OnUserConnect(User *u, bool &exempt) override
{
if (!u->Quitting())
UpdateUser(u, NEW, u->nick, "", "", "");
}
- void OnUserNickChange(User *u, const Anope::string &oldnick) anope_override
+ void OnUserNickChange(User *u, const Anope::string &oldnick) override
{
UpdateUser(u, NICK_TO, oldnick, u->nick, "", "");
UpdateUser(u, NICK_FROM, u->nick, oldnick, "", "");
}
- void OnUserQuit(User *u, const Anope::string &msg) anope_override
+ void OnUserQuit(User *u, const Anope::string &msg) override
{
UpdateUser(u, QUIT, u->nick, "", "", msg);
}
- void OnJoinChannel(User *u, Channel *c) anope_override
+ void OnJoinChannel(User *u, Channel *c) override
{
UpdateUser(u, JOIN, u->nick, "", c->name, "");
}
- void OnPartChannel(User *u, Channel *c, const Anope::string &channel, const Anope::string &msg) anope_override
+ void OnPartChannel(User *u, Channel *c, const Anope::string &channel, const Anope::string &msg) override
{
UpdateUser(u, PART, u->nick, "", channel, msg);
}
- void OnPreUserKicked(const MessageSource &source, ChanUserContainer *cu, const Anope::string &msg) anope_override
+ void OnPreUserKicked(const MessageSource &source, ChanUserContainer *cu, const Anope::string &msg) override
{
UpdateUser(cu->user, KICK, cu->user->nick, source.GetSource(), cu->chan->name, msg);
}
diff --git a/modules/commands/cs_set.cpp b/modules/commands/cs_set.cpp
index 73fa9f4a0..0456f56b8 100644
--- a/modules/commands/cs_set.cpp
+++ b/modules/commands/cs_set.cpp
@@ -21,12 +21,12 @@ class CommandCSSet : public Command
this->SetSyntax(_("\037option\037 \037channel\037 \037parameters\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
this->OnSyntaxError(source, "");
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -37,10 +37,8 @@ class CommandCSSet : public Command
Anope::string this_name = source.command;
bool hide_privileged_commands = Config->GetBlock("options")->Get<bool>("hideprivilegedcommands"),
hide_registered_commands = Config->GetBlock("options")->Get<bool>("hideregisteredcommands");
- for (CommandInfo::map::const_iterator it = source.service->commands.begin(), it_end = source.service->commands.end(); it != it_end; ++it)
+ for (const auto &[c_name, info] : source.service->commands)
{
- const Anope::string &c_name = it->first;
- const CommandInfo &info = it->second;
if (c_name.find_ci(this_name + " ") == 0)
{
if (info.hide)
@@ -56,7 +54,7 @@ class CommandCSSet : public Command
else if (hide_privileged_commands && !info.permission.empty() && !source.HasCommand(info.permission))
continue;
- source.command = it->first;
+ source.command = c_name;
c->OnServHelp(source);
}
}
@@ -75,7 +73,7 @@ class CommandCSSetAutoOp : public Command
this->SetSyntax(_("\037channel\037 {ON | OFF}"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (Anope::ReadOnly)
{
@@ -117,7 +115,7 @@ class CommandCSSetAutoOp : public Command
this->OnSyntaxError(source, "AUTOOP");
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -134,11 +132,11 @@ class CommandCSSetBanType : public Command
public:
CommandCSSetBanType(Module *creator, const Anope::string &cname = "chanserv/set/bantype") : Command(creator, cname, 2, 2)
{
- this->SetDesc(_("Set how Services make bans on the channel"));
+ this->SetDesc(_("Set how services make bans on the channel"));
this->SetSyntax(_("\037channel\037 \037bantype\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (Anope::ReadOnly)
{
@@ -179,7 +177,7 @@ class CommandCSSetBanType : public Command
}
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -205,7 +203,7 @@ class CommandCSSetDescription : public Command
this->SetSyntax(_("\037channel\037 [\037description\037]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (Anope::ReadOnly)
{
@@ -248,7 +246,7 @@ class CommandCSSetDescription : public Command
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -267,7 +265,7 @@ class CommandCSSetFounder : public Command
this->SetSyntax(_("\037channel\037 \037nick\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (Anope::ReadOnly)
{
@@ -317,7 +315,7 @@ class CommandCSSetFounder : public Command
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -336,7 +334,7 @@ class CommandCSSetKeepModes : public Command
this->SetSyntax(_("\037channel\037 {ON | OFF}"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (Anope::ReadOnly)
{
@@ -381,7 +379,7 @@ class CommandCSSetKeepModes : public Command
this->OnSyntaxError(source, "KEEPMODES");
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -401,7 +399,7 @@ class CommandCSSetPeace : public Command
this->SetSyntax(_("\037channel\037 {ON | OFF}"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (Anope::ReadOnly)
{
@@ -445,7 +443,7 @@ class CommandCSSetPeace : public Command
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -473,7 +471,7 @@ class CommandCSSetPersist : public Command
this->SetSyntax(_("\037channel\037 {ON | OFF}"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (Anope::ReadOnly)
{
@@ -583,7 +581,7 @@ class CommandCSSetPersist : public Command
this->OnSyntaxError(source, "PERSIST");
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
BotInfo *BotServ = Config->GetClient("BotServ");
BotInfo *ChanServ = Config->GetClient("ChanServ");
@@ -622,7 +620,7 @@ class CommandCSSetRestricted : public Command
this->SetSyntax(_("\037channel\037 {ON | OFF}"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (Anope::ReadOnly)
{
@@ -664,7 +662,7 @@ class CommandCSSetRestricted : public Command
this->OnSyntaxError(source, "RESTRICTED");
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -684,7 +682,7 @@ class CommandCSSetSecure : public Command
this->SetSyntax(_("\037channel\037 {ON | OFF}"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (Anope::ReadOnly)
{
@@ -726,7 +724,7 @@ class CommandCSSetSecure : public Command
this->OnSyntaxError(source, "SECURE");
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -747,7 +745,7 @@ class CommandCSSetSecureFounder : public Command
this->SetSyntax(_("\037channel\037 {ON | OFF}"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (Anope::ReadOnly)
{
@@ -789,7 +787,7 @@ class CommandCSSetSecureFounder : public Command
this->OnSyntaxError(source, "SECUREFOUNDER");
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -811,7 +809,7 @@ class CommandCSSetSecureOps : public Command
this->SetSyntax(_("\037channel\037 {ON | OFF}"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (Anope::ReadOnly)
{
@@ -853,7 +851,7 @@ class CommandCSSetSecureOps : public Command
this->OnSyntaxError(source, "SECUREOPS");
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -873,7 +871,7 @@ class CommandCSSetSignKick : public Command
this->SetSyntax(_("\037channel\037 {ON | LEVEL | OFF}"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (Anope::ReadOnly)
{
@@ -925,7 +923,7 @@ class CommandCSSetSignKick : public Command
this->OnSyntaxError(source, "SIGNKICK");
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -950,7 +948,7 @@ class CommandCSSetSuccessor : public Command
this->SetSyntax(_("\037channel\037 [\037nick\037]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (Anope::ReadOnly)
{
@@ -1010,7 +1008,7 @@ class CommandCSSetSuccessor : public Command
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -1044,7 +1042,7 @@ class CommandCSSetNoexpire : public Command
this->SetSyntax(_("\037channel\037 {ON | OFF}"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (Anope::ReadOnly)
{
@@ -1083,7 +1081,7 @@ class CommandCSSetNoexpire : public Command
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -1103,7 +1101,7 @@ class CSSet : public Module
{
KeepModes(Module *m, const Anope::string &n) : SerializableExtensibleItem<bool>(m, n) { }
- void ExtensibleSerialize(const Extensible *e, const Serializable *s, Serialize::Data &data) const anope_override
+ void ExtensibleSerialize(const Extensible *e, const Serializable *s, Serialize::Data &data) const override
{
SerializableExtensibleItem<bool>::ExtensibleSerialize(e, s, data);
@@ -1112,18 +1110,18 @@ class CSSet : public Module
const ChannelInfo *ci = anope_dynamic_static_cast<const ChannelInfo *>(s);
Anope::string modes;
- for (Channel::ModeList::const_iterator it = ci->last_modes.begin(); it != ci->last_modes.end(); ++it)
+ for (const auto &[last_mode, last_value] : ci->last_modes)
{
if (!modes.empty())
modes += " ";
- modes += it->first;
- if (!it->second.empty())
- modes += "," + it->second;
+ modes += last_mode;
+ if (!last_value.empty())
+ modes += "," + last_value;
}
data["last_modes"] << modes;
}
- void ExtensibleUnserialize(Extensible *e, Serializable *s, Serialize::Data &data) anope_override
+ void ExtensibleUnserialize(Extensible *e, Serializable *s, Serialize::Data &data) override
{
SerializableExtensibleItem<bool>::ExtensibleUnserialize(e, s, data);
@@ -1138,9 +1136,9 @@ class CSSet : public Module
{
size_t c = modes.find(',');
if (c == Anope::string::npos)
- ci->last_modes.insert(std::make_pair(modes, ""));
+ ci->last_modes.emplace(modes, "");
else
- ci->last_modes.insert(std::make_pair(modes.substr(0, c), modes.substr(c + 1)));
+ ci->last_modes.emplace(modes.substr(0, c), modes.substr(c + 1));
}
}
} keep_modes;
@@ -1184,27 +1182,27 @@ class CSSet : public Module
{
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
persist_lower_ts = conf->GetModule(this)->Get<bool>("persist_lower_ts");
}
- void OnCreateChan(ChannelInfo *ci) anope_override
+ void OnCreateChan(ChannelInfo *ci) override
{
ci->bantype = Config->GetModule(this)->Get<int>("defbantype", "2");
}
- void OnChannelSync(Channel *c) anope_override
+ void OnChannelSync(Channel *c) override
{
if (c->ci && keep_modes.HasExt(c->ci))
{
Channel::ModeList ml = c->ci->last_modes;
- for (Channel::ModeList::iterator it = ml.begin(); it != ml.end(); ++it)
- c->SetMode(c->ci->WhoSends(), it->first, it->second);
+ for (const auto &[last_mode, last_value] : c->ci->last_modes)
+ c->SetMode(c->ci->WhoSends(), last_mode, last_value);
}
}
- EventReturn OnCheckKick(User *u, Channel *c, Anope::string &mask, Anope::string &reason) anope_override
+ EventReturn OnCheckKick(User *u, Channel *c, Anope::string &mask, Anope::string &reason) override
{
if (!c->ci || !restricted.HasExt(c->ci) || c->MatchesList(u, "EXCEPT"))
return EVENT_CONTINUE;
@@ -1215,14 +1213,14 @@ class CSSet : public Module
return EVENT_CONTINUE;
}
- void OnDelChan(ChannelInfo *ci) anope_override
+ void OnDelChan(ChannelInfo *ci) override
{
if (ci->c && persist.HasExt(ci))
ci->c->RemoveMode(ci->WhoSends(), "PERM", "", false);
persist.Unset(ci);
}
- EventReturn OnChannelModeSet(Channel *c, MessageSource &setter, ChannelMode *mode, const Anope::string &param) anope_override
+ EventReturn OnChannelModeSet(Channel *c, MessageSource &setter, ChannelMode *mode, const Anope::string &param) override
{
if (c->ci)
{
@@ -1237,7 +1235,7 @@ class CSSet : public Module
return EVENT_CONTINUE;
}
- EventReturn OnChannelModeUnset(Channel *c, MessageSource &setter, ChannelMode *mode, const Anope::string &param) anope_override
+ EventReturn OnChannelModeUnset(Channel *c, MessageSource &setter, ChannelMode *mode, const Anope::string &param) override
{
if (mode->name == "PERM")
{
@@ -1251,7 +1249,7 @@ class CSSet : public Module
return EVENT_CONTINUE;
}
- void OnJoinChannel(User *u, Channel *c) anope_override
+ void OnJoinChannel(User *u, Channel *c) override
{
if (u->server != Me && persist_lower_ts && c->ci && persist.HasExt(c->ci) && c->creation_time > c->ci->time_registered)
{
@@ -1262,7 +1260,7 @@ class CSSet : public Module
}
}
- void OnSetCorrectModes(User *user, Channel *chan, AccessGroup &access, bool &give_modes, bool &take_modes) anope_override
+ void OnSetCorrectModes(User *user, Channel *chan, AccessGroup &access, bool &give_modes, bool &take_modes) override
{
if (chan->ci)
{
@@ -1274,13 +1272,13 @@ class CSSet : public Module
}
}
- void OnPreChanExpire(ChannelInfo *ci, bool &expire) anope_override
+ void OnPreChanExpire(ChannelInfo *ci, bool &expire) override
{
if (noexpire.HasExt(ci))
expire = false;
}
- void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_all) anope_override
+ void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_all) override
{
if (!show_all)
return;
diff --git a/modules/commands/cs_set_misc.cpp b/modules/commands/cs_set_misc.cpp
index 9c75f72e2..86233c97a 100644
--- a/modules/commands/cs_set_misc.cpp
+++ b/modules/commands/cs_set_misc.cpp
@@ -42,7 +42,7 @@ struct CSMiscData : MiscData, Serializable
data = d;
}
- void Serialize(Serialize::Data &sdata) const anope_override
+ void Serialize(Serialize::Data &sdata) const override
{
sdata["ci"] << this->object;
sdata["name"] << this->name;
@@ -96,7 +96,7 @@ class CommandCSSetMisc : public Command
this->SetSyntax(_("\037channel\037 [\037parameters\037]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (Anope::ReadOnly)
{
@@ -143,7 +143,7 @@ class CommandCSSetMisc : public Command
}
}
- void OnServHelp(CommandSource &source) anope_override
+ void OnServHelp(CommandSource &source) override
{
if (descriptions.count(source.command))
{
@@ -152,7 +152,7 @@ class CommandCSSetMisc : public Command
}
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
if (descriptions.count(source.command))
{
@@ -176,13 +176,13 @@ class CSSetMisc : public Module
me = this;
}
- ~CSSetMisc()
+ ~CSSetMisc() override
{
- for (Anope::map<ExtensibleItem<CSMiscData> *>::iterator it = items.begin(); it != items.end(); ++it)
- delete it->second;
+ for (const auto &[_, item] : items)
+ delete item;
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
descriptions.clear();
@@ -203,11 +203,10 @@ class CSSetMisc : public Module
}
}
- void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool) anope_override
+ void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool) override
{
- for (Anope::map<ExtensibleItem<CSMiscData> *>::iterator it = items.begin(); it != items.end(); ++it)
+ for (const auto &[_, e] : items)
{
- ExtensibleItem<CSMiscData> *e = it->second;
MiscData *data = e->Get(ci);
if (data != NULL)
diff --git a/modules/commands/cs_status.cpp b/modules/commands/cs_status.cpp
index 7404cce5d..9d5f856f8 100644
--- a/modules/commands/cs_status.cpp
+++ b/modules/commands/cs_status.cpp
@@ -20,7 +20,7 @@ public:
this->SetSyntax(_("\037channel\037 [\037user\037]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &channel = params[0];
@@ -57,11 +57,9 @@ public:
{
source.Reply(_("Access for \002%s\002 on \002%s\002:"), nick.c_str(), ci->name.c_str());
- for (unsigned i = 0; i < ag.paths.size(); ++i)
+ for (const auto &p : ag.paths)
{
- ChanAccess::Path &p = ag.paths[i];
-
- if (p.empty())
+ if (p.empty())
continue;
if (p.size() == 1)
@@ -99,7 +97,7 @@ public:
}
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/cs_suspend.cpp b/modules/commands/cs_suspend.cpp
index 839fe74de..ca8dfce56 100644
--- a/modules/commands/cs_suspend.cpp
+++ b/modules/commands/cs_suspend.cpp
@@ -16,7 +16,7 @@ struct CSSuspendInfo : SuspendInfo, Serializable
{
CSSuspendInfo(Extensible *) : Serializable("CSSuspendInfo") { }
- void Serialize(Serialize::Data &data) const anope_override
+ void Serialize(Serialize::Data &data) const override
{
data["chan"] << what;
data["by"] << by;
@@ -59,7 +59,7 @@ class CommandCSSuspend : public Command
this->SetSyntax(_("\037channel\037 [+\037expiry\037] [\037reason\037]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &chan = params[0];
Anope::string expiry = params[1];
@@ -109,16 +109,15 @@ class CommandCSSuspend : public Command
{
std::vector<User *> users;
- for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
+ for (const auto &[_, uc] : ci->c->users)
{
- ChanUserContainer *uc = it->second;
User *user = uc->user;
if (!user->HasMode("OPER") && user->server != Me)
users.push_back(user);
}
- for (unsigned i = 0; i < users.size(); ++i)
- ci->c->Kick(NULL, users[i], "%s", !reason.empty() ? reason.c_str() : Language::Translate(users[i], _("This channel has been suspended.")));
+ for (auto *user : users)
+ ci->c->Kick(NULL, user, "%s", !reason.empty() ? reason.c_str() : Language::Translate(user, _("This channel has been suspended.")));
}
Log(LOG_ADMIN, source, this, ci) << "(" << (!reason.empty() ? reason : "No reason") << "), expires on " << (expiry_secs ? Anope::strftime(Anope::CurTime + expiry_secs) : "never");
@@ -127,7 +126,7 @@ class CommandCSSuspend : public Command
FOREACH_MOD(OnChanSuspend, (ci));
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -152,7 +151,7 @@ class CommandCSUnSuspend : public Command
this->SetSyntax(_("\037channel\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (Anope::ReadOnly)
@@ -184,7 +183,7 @@ class CommandCSUnSuspend : public Command
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -222,7 +221,7 @@ class CSSuspend : public Module
{
}
- void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_hidden) anope_override
+ void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_hidden) override
{
CSSuspendInfo *si = suspend.Get(ci);
if (!si)
@@ -240,7 +239,7 @@ class CSSuspend : public Module
info[_("Suspension expires")] = Anope::strftime(si->expires, source.GetAccount());
}
- void OnPreChanExpire(ChannelInfo *ci, bool &expire) anope_override
+ void OnPreChanExpire(ChannelInfo *ci, bool &expire) override
{
CSSuspendInfo *si = suspend.Get(ci);
if (!si)
@@ -260,7 +259,7 @@ class CSSuspend : public Module
}
}
- EventReturn OnCheckKick(User *u, Channel *c, Anope::string &mask, Anope::string &reason) anope_override
+ EventReturn OnCheckKick(User *u, Channel *c, Anope::string &mask, Anope::string &reason) override
{
if (u->HasMode("OPER") || !c->ci || !suspend.HasExt(c->ci))
return EVENT_CONTINUE;
@@ -269,7 +268,7 @@ class CSSuspend : public Module
return EVENT_STOP;
}
- EventReturn OnChanDrop(CommandSource &source, ChannelInfo *ci) anope_override
+ EventReturn OnChanDrop(CommandSource &source, ChannelInfo *ci) override
{
CSSuspendInfo *si = suspend.Get(ci);
if (si && !source.HasCommand("chanserv/drop"))
diff --git a/modules/commands/cs_sync.cpp b/modules/commands/cs_sync.cpp
index af76c47f7..2610f521c 100644
--- a/modules/commands/cs_sync.cpp
+++ b/modules/commands/cs_sync.cpp
@@ -20,7 +20,7 @@ class CommandCSSync : public Command
this->SetSyntax(_("\037channel\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
ChannelInfo *ci = ChannelInfo::Find(params[0]);
@@ -35,14 +35,14 @@ class CommandCSSync : public Command
bool override = !source.AccessFor(ci).HasPriv("ACCESS_CHANGE") && source.HasPriv("chanserv/administration");
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci);
- for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
- ci->c->SetCorrectModes(it->second->user, true);
+ for (const auto &[_, uc] : ci->c->users)
+ ci->c->SetCorrectModes(uc->user, true);
source.Reply(_("All user modes on \002%s\002 have been synced."), ci->name.c_str());
}
}
- bool OnHelp(CommandSource &source, const Anope::string &params) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &params) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/cs_topic.cpp b/modules/commands/cs_topic.cpp
index 28c821104..7e71020a1 100644
--- a/modules/commands/cs_topic.cpp
+++ b/modules/commands/cs_topic.cpp
@@ -21,7 +21,7 @@ class CommandCSSetKeepTopic : public Command
this->SetSyntax(_("\037channel\037 {ON | OFF}"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (Anope::ReadOnly)
{
@@ -63,7 +63,7 @@ class CommandCSSetKeepTopic : public Command
this->OnSyntaxError(source, "KEEPTOPIC");
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -152,7 +152,7 @@ class CommandCSTopic : public Command
this->SetSyntax(_("\037channel\037 [UNLOCK|LOCK]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &subcmd = params[1];
@@ -186,7 +186,7 @@ class CommandCSTopic : public Command
}
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -216,7 +216,7 @@ class CSTopic : public Module
}
- void OnChannelSync(Channel *c) anope_override
+ void OnChannelSync(Channel *c) override
{
if (c->ci)
{
@@ -228,7 +228,7 @@ class CSTopic : public Module
}
}
- void OnTopicUpdated(User *source, Channel *c, const Anope::string &user, const Anope::string &topic) anope_override
+ void OnTopicUpdated(User *source, Channel *c, const Anope::string &user, const Anope::string &topic) override
{
if (!c->ci)
return;
@@ -250,7 +250,7 @@ class CSTopic : public Module
}
}
- void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_all) anope_override
+ void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_all) override
{
if (keeptopic.HasExt(ci))
info.AddOption(_("Topic retention"));
diff --git a/modules/commands/cs_unban.cpp b/modules/commands/cs_unban.cpp
index 177a1a101..fec777cc0 100644
--- a/modules/commands/cs_unban.cpp
+++ b/modules/commands/cs_unban.cpp
@@ -20,7 +20,7 @@ class CommandCSUnban : public Command
this->SetSyntax(_("\037channel\037 [\037nick\037]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
ChannelMode *cm = ModeManager::FindChannelModeByName("BAN");
if (!cm)
@@ -38,17 +38,15 @@ class CommandCSUnban : public Command
source.GetAccount()->GetChannelReferences(queue);
unsigned count = 0;
- for (unsigned i = 0; i < queue.size(); ++i)
+ for (auto *ci : queue)
{
- ChannelInfo *ci = queue[i];
-
if (!ci->c || !source.AccessFor(ci).HasPriv("UNBAN"))
continue;
-
+
FOREACH_MOD(OnChannelUnban, (source.GetUser(), ci));
- for (unsigned j = 0; j < modes.size(); ++j)
- if (ci->c->Unban(source.GetUser(), modes[j]->name, true))
+ for (const auto *mode : modes)
+ if (ci->c->Unban(source.GetUser(), mode->name, true))
++count;
}
@@ -92,15 +90,15 @@ class CommandCSUnban : public Command
FOREACH_MOD(OnChannelUnban, (u2, ci));
- for (unsigned i = 0; i < modes.size(); ++i)
- ci->c->Unban(u2, modes[i]->name, source.GetUser() == u2);
+ for (const auto *mode : modes)
+ ci->c->Unban(u2, mode->name, source.GetUser() == u2);
if (u2 == source.GetUser())
source.Reply(_("You have been unbanned from \002%s\002."), ci->c->name.c_str());
else
source.Reply(_("\002%s\002 has been unbanned from \002%s\002."), u2->nick.c_str(), ci->c->name.c_str());
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/cs_updown.cpp b/modules/commands/cs_updown.cpp
index 5ebc3e8cc..59bd19660 100644
--- a/modules/commands/cs_updown.cpp
+++ b/modules/commands/cs_updown.cpp
@@ -24,9 +24,8 @@ class CommandCSUp : public Command
bool given = false;
AccessGroup u_access = c->ci->AccessFor(u);
- for (unsigned i = 0; i < ModeManager::GetStatusChannelModesByRank().size(); ++i)
+ for (auto *cm : ModeManager::GetStatusChannelModesByRank())
{
- ChannelModeStatus *cm = ModeManager::GetStatusChannelModesByRank()[i];
bool has_priv = u_access.HasPriv("AUTO" + cm->name) || u_access.HasPriv(cm->name);
if (has_priv)
@@ -49,7 +48,7 @@ class CommandCSUp : public Command
this->SetSyntax(_("[\037channel\037 [\037nick\037]]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (params.empty())
{
@@ -119,7 +118,7 @@ class CommandCSUp : public Command
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -147,7 +146,7 @@ class CommandCSDown : public Command
this->SetSyntax(_("[\037channel\037 [\037nick\037]]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (params.empty())
{
@@ -216,7 +215,7 @@ class CommandCSDown : public Command
}
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/cs_xop.cpp b/modules/commands/cs_xop.cpp
index 33b2f564e..5bd9de696 100644
--- a/modules/commands/cs_xop.cpp
+++ b/modules/commands/cs_xop.cpp
@@ -26,7 +26,7 @@ class XOPChanAccess : public ChanAccess
{
}
- bool HasPriv(const Anope::string &priv) const anope_override
+ bool HasPriv(const Anope::string &priv) const override
{
for (std::vector<Anope::string>::iterator it = std::find(order.begin(), order.end(), this->type); it != order.end(); ++it)
{
@@ -37,12 +37,12 @@ class XOPChanAccess : public ChanAccess
return false;
}
- Anope::string AccessSerialize() const anope_override
+ Anope::string AccessSerialize() const override
{
return this->type;
}
- void AccessUnserialize(const Anope::string &data) anope_override
+ void AccessUnserialize(const Anope::string &data) override
{
this->type = data;
}
@@ -58,25 +58,28 @@ class XOPChanAccess : public ChanAccess
{
std::map<Anope::string, int> count;
- for (std::map<Anope::string, std::vector<Anope::string> >::const_iterator it = permissions.begin(), it_end = permissions.end(); it != it_end; ++it)
+ for (const auto &[name, perms] : permissions)
{
- int &c = count[it->first];
- const std::vector<Anope::string> &perms = it->second;
- for (unsigned i = 0; i < perms.size(); ++i)
- if (access->HasPriv(perms[i]))
+ int &c = count[name];
+ for (const auto &perm : perms)
+ {
+ if (access->HasPriv(perm))
++c;
+ }
}
- Anope::string max;
- int maxn = 0;
- for (std::map<Anope::string, int>::iterator it = count.begin(), it_end = count.end(); it != it_end; ++it)
- if (it->second > maxn)
+ Anope::string maxname;
+ int maxpriv = 0;
+ for (const auto &[name, priv] : count)
+ {
+ if (priv > maxpriv)
{
- maxn = it->second;
- max = it->first;
+ maxname = name;
+ maxpriv = priv;
}
+ }
- return max;
+ return maxname;
}
}
};
@@ -88,7 +91,7 @@ class XOPAccessProvider : public AccessProvider
{
}
- ChanAccess *Create() anope_override
+ ChanAccess *Create() override
{
return new XOPChanAccess(this);
}
@@ -100,6 +103,7 @@ class CommandCSXOP : public Command
void DoAdd(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> &params)
{
Anope::string mask = params.size() > 2 ? params[2] : "";
+ Anope::string description = params.size() > 3 ? params[3] : "";
if (mask.empty())
{
@@ -208,6 +212,7 @@ class CommandCSXOP : public Command
XOPChanAccess *acc = anope_dynamic_static_cast<XOPChanAccess *>(provider->Create());
acc->SetMask(mask, ci);
acc->creator = source.GetNick();
+ acc->description = description;
acc->type = source.command.upper();
acc->last_seen = 0;
acc->created = Anope::CurTime;
@@ -280,15 +285,15 @@ class CommandCSXOP : public Command
CommandSource &source;
ChannelInfo *ci;
Command *c;
- unsigned deleted;
+ unsigned deleted = 0;
Anope::string nicks;
bool override;
public:
- XOPDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, bool _override, const Anope::string &numlist) : NumberList(numlist, true), source(_source), ci(_ci), c(_c), deleted(0), override(_override)
+ XOPDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, bool _override, const Anope::string &numlist) : NumberList(numlist, true), source(_source), ci(_ci), c(_c), override(_override)
{
}
- ~XOPDelCallback()
+ ~XOPDelCallback() override
{
if (!deleted)
source.Reply(_("No matching entries on %s %s list."), ci->name.c_str(), source.command.c_str());
@@ -303,7 +308,7 @@ class CommandCSXOP : public Command
}
}
- void HandleNumber(unsigned number) anope_override
+ void HandleNumber(unsigned number) override
{
if (!number || number > ci->GetAccessCount())
return;
@@ -374,7 +379,7 @@ class CommandCSXOP : public Command
}
ListFormatter list(source.GetAccount());
- list.AddColumn(_("Number")).AddColumn(_("Mask"));
+ list.AddColumn(_("Number")).AddColumn(_("Mask")).AddColumn(_("Description"));
if (!nick.empty() && nick.find_first_not_of("1234567890,-") == Anope::string::npos)
{
@@ -388,7 +393,7 @@ class CommandCSXOP : public Command
{
}
- void HandleNumber(unsigned Number) anope_override
+ void HandleNumber(unsigned Number) override
{
if (!Number || Number > ci->GetAccessCount())
return;
@@ -401,6 +406,7 @@ class CommandCSXOP : public Command
ListFormatter::ListEntry entry;
entry["Number"] = stringify(Number);
entry["Mask"] = a->Mask();
+ entry["Description"] = a->description;
this->list.AddEntry(entry);
}
} nl_list(list, ci, nick, source);
@@ -420,6 +426,7 @@ class CommandCSXOP : public Command
ListFormatter::ListEntry entry;
entry["Number"] = stringify(i + 1);
entry["Mask"] = a->Mask();
+ entry["Description"] = a->description;
list.AddEntry(entry);
}
}
@@ -432,8 +439,8 @@ class CommandCSXOP : public Command
list.Process(replies);
source.Reply(_("%s list for %s"), source.command.c_str(), ci->name.c_str());
- for (unsigned i = 0; i < replies.size(); ++i)
- source.Reply(replies[i]);
+ for (const auto &reply : replies)
+ source.Reply(reply);
}
}
@@ -478,18 +485,18 @@ class CommandCSXOP : public Command
public:
CommandCSXOP(Module *modname) : Command(modname, "chanserv/xop", 2, 4)
{
- this->SetSyntax(_("\037channel\037 ADD \037mask\037"));
+ this->SetSyntax(_("\037channel\037 ADD \037mask\037 [\037description\037]"));
this->SetSyntax(_("\037channel\037 DEL {\037mask\037 | \037entry-num\037 | \037list\037}"));
this->SetSyntax(_("\037channel\037 LIST [\037mask\037 | \037list\037]"));
this->SetSyntax(_("\037channel\037 CLEAR"));
}
- const Anope::string GetDesc(CommandSource &source) const anope_override
+ const Anope::string GetDesc(CommandSource &source) const override
{
return Anope::printf(Language::Translate(source.GetAccount(), _("Modify the list of %s users")), source.command.upper().c_str());
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL)
@@ -513,7 +520,7 @@ class CommandCSXOP : public Command
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
const Anope::string &cmd = source.command.upper();
@@ -524,9 +531,9 @@ class CommandCSXOP : public Command
" "), cmd.c_str(), cmd.c_str());
Anope::string buf;
- for (unsigned i = 0; i < permissions[cmd].size(); ++i)
+ for (const auto &permission : permissions[cmd])
{
- buf += ", " + permissions[cmd][i];
+ buf += ", " + permission;
if (buf.length() > 75)
{
source.Reply(" %s\n", buf.substr(2).c_str());
@@ -590,7 +597,7 @@ class CSXOP : public Module
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
order.clear();
permissions.clear();
diff --git a/modules/commands/gl_global.cpp b/modules/commands/gl_global.cpp
index 07d3c111a..072b786dc 100644
--- a/modules/commands/gl_global.cpp
+++ b/modules/commands/gl_global.cpp
@@ -22,7 +22,7 @@ class CommandGLGlobal : public Command
this->SetSyntax(_("\037message\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &msg = params[0];
@@ -35,7 +35,7 @@ class CommandGLGlobal : public Command
}
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
Reference<BotInfo> sender;
if (GService)
diff --git a/modules/commands/greet.cpp b/modules/commands/greet.cpp
index 864c8d3dc..0ebad1864 100644
--- a/modules/commands/greet.cpp
+++ b/modules/commands/greet.cpp
@@ -20,7 +20,7 @@ class CommandBSSetGreet : public Command
this->SetSyntax(_("\037channel\037 {\037ON|OFF\037}"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
ChannelInfo *ci = ChannelInfo::Find(params[0]);
const Anope::string &value = params[1];
@@ -63,7 +63,7 @@ class CommandBSSetGreet : public Command
this->OnSyntaxError(source, source.command);
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(_(" \n"
@@ -119,12 +119,12 @@ class CommandNSSetGreet : public Command
}
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
this->Run(source, source.nc->display, params.size() > 0 ? params[0] : "");
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -145,12 +145,12 @@ class CommandNSSASetGreet : public CommandNSSetGreet
this->SetSyntax(_("\037nickname\037 \037message\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
this->Run(source, params[0], params.size() > 1 ? params[1] : "");
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -182,7 +182,7 @@ class Greet : public Module
{
}
- void OnJoinChannel(User *user, Channel *c) anope_override
+ void OnJoinChannel(User *user, Channel *c) override
{
/* Only display the greet if the main uplink we're connected
* to has synced, or we'll get greet-floods when the net
@@ -199,14 +199,14 @@ class Greet : public Module
}
}
- void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_hidden) anope_override
+ void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_hidden) override
{
Anope::string *greet = ns_greet.Get(na->nc);
if (greet != NULL)
info[_("Greet")] = *greet;
}
- void OnBotInfo(CommandSource &source, BotInfo *bi, ChannelInfo *ci, InfoFormatter &info) anope_override
+ void OnBotInfo(CommandSource &source, BotInfo *bi, ChannelInfo *ci, InfoFormatter &info) override
{
if (bs_greet.HasExt(ci))
info.AddOption(_("Greet"));
diff --git a/modules/commands/help.cpp b/modules/commands/help.cpp
index f4271620d..071161fcd 100644
--- a/modules/commands/help.cpp
+++ b/modules/commands/help.cpp
@@ -17,9 +17,8 @@ class CommandHelp : public Command
static CommandGroup *FindGroup(const Anope::string &name)
{
- for (unsigned i = 0; i < Config->CommandGroups.size(); ++i)
+ for (auto &gr : Config->CommandGroups)
{
- CommandGroup &gr = Config->CommandGroups[i];
if (gr.name == name)
return &gr;
}
@@ -34,7 +33,7 @@ class CommandHelp : public Command
this->AllowUnregistered(true);
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
EventReturn MOD_RESULT;
FOREACH_RESULT(OnPreHelp, MOD_RESULT, (source, params));
@@ -56,18 +55,15 @@ class CommandHelp : public Command
if (all)
source.Reply(_("All available commands for \002%s\002:"), source.service->nick.c_str());
- for (CommandInfo::map::const_iterator it = map.begin(), it_end = map.end(); it != it_end; ++it)
+ for (const auto &[c_name, info] : map)
{
- const Anope::string &c_name = it->first;
- const CommandInfo &info = it->second;
-
if (info.hide)
continue;
// Smaller command exists
Anope::string cmd;
spacesepstream(c_name).GetToken(cmd, 0);
- if (cmd != it->first && map.count(cmd))
+ if (cmd != c_name && map.count(cmd))
continue;
ServiceReference<Command> c("Command", info.name);
@@ -95,18 +91,14 @@ class CommandHelp : public Command
}
- for (GroupInfo::iterator it = groups.begin(), it_end = groups.end(); it != it_end; ++it)
+ for (auto &[gr, cmds] : groups)
{
- CommandGroup *gr = it->first;
-
source.Reply(" ");
source.Reply("%s", gr->description.c_str());
Anope::string buf;
- for (std::list<Anope::string>::iterator it2 = it->second.begin(), it2_end = it->second.end(); it2 != it2_end; ++it2)
+ for (const auto &c_name : cmds)
{
- const Anope::string &c_name = *it2;
-
buf += ", " + c_name;
if (buf.length() > help_wrap_len)
diff --git a/modules/commands/hs_del.cpp b/modules/commands/hs_del.cpp
index ea5e4a222..9d4514907 100644
--- a/modules/commands/hs_del.cpp
+++ b/modules/commands/hs_del.cpp
@@ -20,7 +20,7 @@ class CommandHSDel : public Command
this->SetSyntax(_("\037nick\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (Anope::ReadOnly)
{
@@ -41,7 +41,7 @@ class CommandHSDel : public Command
source.Reply(NICK_X_NOT_REGISTERED, nick.c_str());
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -60,7 +60,7 @@ class CommandHSDelAll : public Command
this->SetSyntax(_("\037nick\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (Anope::ReadOnly)
{
@@ -74,9 +74,9 @@ class CommandHSDelAll : public Command
{
FOREACH_MOD(OnDeleteVhost, (na));
const NickCore *nc = na->nc;
- for (unsigned i = 0; i < nc->aliases->size(); ++i)
+ for (auto *alias : *nc->aliases)
{
- na = nc->aliases->at(i);
+ na = alias;
na->RemoveVhost();
}
Log(LOG_ADMIN, source, this) << "for all nicks in group " << nc->display;
@@ -86,7 +86,7 @@ class CommandHSDelAll : public Command
source.Reply(NICK_X_NOT_REGISTERED, nick.c_str());
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/hs_group.cpp b/modules/commands/hs_group.cpp
index 46f2f1a9d..03e1dc333 100644
--- a/modules/commands/hs_group.cpp
+++ b/modules/commands/hs_group.cpp
@@ -13,7 +13,7 @@
class CommandHSGroup : public Command
{
- bool setting;
+ bool setting = false;
public:
void Sync(const NickAlias *na)
@@ -25,9 +25,8 @@ class CommandHSGroup : public Command
return;
setting = true;
- for (unsigned i = 0; i < na->nc->aliases->size(); ++i)
+ for (auto *nick : *na->nc->aliases)
{
- NickAlias *nick = na->nc->aliases->at(i);
if (nick)
{
nick->SetVhost(na->GetVhostIdent(), na->GetVhostHost(), na->GetVhostCreator());
@@ -37,12 +36,12 @@ class CommandHSGroup : public Command
setting = false;
}
- CommandHSGroup(Module *creator) : Command(creator, "hostserv/group", 0, 0), setting(false)
+ CommandHSGroup(Module *creator) : Command(creator, "hostserv/group", 0, 0)
{
this->SetDesc(_("Syncs the vhost for all nicks in a group"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (Anope::ReadOnly)
{
@@ -65,7 +64,7 @@ class CommandHSGroup : public Command
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -90,7 +89,7 @@ class HSGroup : public Module
throw ModuleException("Your IRCd does not support vhosts");
}
- void OnSetVhost(NickAlias *na) anope_override
+ void OnSetVhost(NickAlias *na) override
{
if (!synconset)
return;
@@ -98,7 +97,7 @@ class HSGroup : public Module
commandhsgroup.Sync(na);
}
- void OnNickGroup(User *u, NickAlias *na) anope_override
+ void OnNickGroup(User *u, NickAlias *na) override
{
if (!syncongroup)
return;
@@ -106,7 +105,7 @@ class HSGroup : public Module
commandhsgroup.Sync(na);
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
Configuration::Block *block = conf->GetModule(this);
syncongroup = block->Get<bool>("syncongroup");
diff --git a/modules/commands/hs_list.cpp b/modules/commands/hs_list.cpp
index dbf76d1d6..00f2915d1 100644
--- a/modules/commands/hs_list.cpp
+++ b/modules/commands/hs_list.cpp
@@ -20,7 +20,7 @@ class CommandHSList : public Command
this->SetSyntax(_("[\037key\037|\037#X-Y\037]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &key = !params.empty() ? params[0] : "";
int from = 0, to = 0, counter = 1;
@@ -57,10 +57,8 @@ class CommandHSList : public Command
ListFormatter list(source.GetAccount());
list.AddColumn(_("Number")).AddColumn(_("Nick")).AddColumn(_("Vhost")).AddColumn(_("Creator")).AddColumn(_("Created"));
- for (nickalias_map::const_iterator it = NickAliasList->begin(), it_end = NickAliasList->end(); it != it_end; ++it)
+ for (const auto &[_, na] : *NickAliasList)
{
- const NickAlias *na = it->second;
-
if (!na->HasVhost())
continue;
@@ -125,11 +123,11 @@ class CommandHSList : public Command
std::vector<Anope::string> replies;
list.Process(replies);
- for (unsigned i = 0; i < replies.size(); ++i)
- source.Reply(replies[i]);
+ for (const auto &reply : replies)
+ source.Reply(reply);
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/hs_off.cpp b/modules/commands/hs_off.cpp
index d1f7dc4de..e2325bb45 100644
--- a/modules/commands/hs_off.cpp
+++ b/modules/commands/hs_off.cpp
@@ -20,7 +20,7 @@ class CommandHSOff : public Command
this->RequireUser(true);
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
User *u = source.GetUser();
@@ -42,7 +42,7 @@ class CommandHSOff : public Command
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/hs_on.cpp b/modules/commands/hs_on.cpp
index 714fb4410..a3feffbaf 100644
--- a/modules/commands/hs_on.cpp
+++ b/modules/commands/hs_on.cpp
@@ -20,7 +20,7 @@ class CommandHSOn : public Command
this->RequireUser(true);
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (!IRCD->CanSetVHost)
return; // HostServ wouldn't even be loaded at this point
@@ -48,7 +48,7 @@ class CommandHSOn : public Command
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/hs_request.cpp b/modules/commands/hs_request.cpp
index 0177d0d58..c626deca2 100644
--- a/modules/commands/hs_request.cpp
+++ b/modules/commands/hs_request.cpp
@@ -29,7 +29,7 @@ struct HostRequest : Serializable
HostRequest(Extensible *) : Serializable("HostRequest") { }
- void Serialize(Serialize::Data &data) const anope_override
+ void Serialize(Serialize::Data &data) const override
{
data["nick"] << this->nick;
data["ident"] << this->ident;
@@ -79,7 +79,7 @@ class CommandHSRequest : public Command
this->SetSyntax(_("vhost"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (Anope::ReadOnly)
{
@@ -132,12 +132,14 @@ class CommandHSRequest : public Command
source.Reply(HOST_NO_VIDENT);
return;
}
- for (Anope::string::iterator s = user.begin(), s_end = user.end(); s != s_end; ++s)
- if (!isvalidchar(*s))
+ for (const auto &chr : user)
+ {
+ if (!isvalidchar(chr))
{
source.Reply(HOST_SET_IDENT_ERROR);
return;
}
+ }
}
if (host.length() > Config->GetBlock("networkinfo")->Get<unsigned>("hostlen"))
@@ -172,7 +174,7 @@ class CommandHSRequest : public Command
Log(LOG_COMMAND, source, this) << "to request new vhost " << (!user.empty() ? user + "@" : "") << host;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -192,7 +194,7 @@ class CommandHSActivate : public Command
this->SetSyntax(_("\037nick\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (Anope::ReadOnly)
{
@@ -220,7 +222,7 @@ class CommandHSActivate : public Command
source.Reply(_("No request for nick %s found."), nick.c_str());
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -241,7 +243,7 @@ class CommandHSReject : public Command
this->SetSyntax(_("\037nick\037 [\037reason\037]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (Anope::ReadOnly)
{
@@ -276,7 +278,7 @@ class CommandHSReject : public Command
source.Reply(_("No request for nick %s found."), nick.c_str());
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -296,7 +298,7 @@ class CommandHSWaiting : public Command
this->SetDesc(_("Retrieves the vhost requests"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
unsigned counter = 0;
unsigned display_counter = 0, listmax = Config->GetModule(this->owner)->Get<unsigned>("listmax");
@@ -304,9 +306,8 @@ class CommandHSWaiting : public Command
list.AddColumn(_("Number")).AddColumn(_("Nick")).AddColumn(_("Vhost")).AddColumn(_("Created"));
- for (nickalias_map::const_iterator it = NickAliasList->begin(), it_end = NickAliasList->end(); it != it_end; ++it)
+ for (const auto &[nick, na] : *NickAliasList)
{
- const NickAlias *na = it->second;
HostRequest *hr = na->GetExt<HostRequest>("hostrequest");
if (!hr)
continue;
@@ -317,7 +318,7 @@ class CommandHSWaiting : public Command
ListFormatter::ListEntry entry;
entry["Number"] = stringify(display_counter);
- entry["Nick"] = it->first;
+ entry["Nick"] = nick;
if (!hr->ident.empty())
entry["Vhost"] = hr->ident + "@" + hr->host;
else
@@ -331,13 +332,13 @@ class CommandHSWaiting : public Command
std::vector<Anope::string> replies;
list.Process(replies);
- for (unsigned i = 0; i < replies.size(); ++i)
- source.Reply(replies[i]);
+ for (const auto &reply : replies)
+ source.Reply(reply);
source.Reply(_("Displayed \002%d\002 records (\002%d\002 total)."), display_counter, counter);
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -369,18 +370,15 @@ class HSRequest : public Module
static void req_send_memos(Module *me, CommandSource &source, const Anope::string &vIdent, const Anope::string &vHost)
{
Anope::string host;
- std::list<std::pair<Anope::string, Anope::string> >::iterator it, it_end;
-
if (!vIdent.empty())
host = vIdent + "@" + vHost;
else
host = vHost;
if (Config->GetModule(me)->Get<bool>("memooper") && memoserv)
- for (unsigned i = 0; i < Oper::opers.size(); ++i)
+ {
+ for (auto *o : Oper::opers)
{
- Oper *o = Oper::opers[i];
-
const NickAlias *na = NickAlias::Find(o->name);
if (!na)
continue;
@@ -389,6 +387,7 @@ static void req_send_memos(Module *me, CommandSource &source, const Anope::strin
memoserv->Send(source.service->nick, na->nick, message, true);
}
+ }
}
MODULE_INIT(HSRequest)
diff --git a/modules/commands/hs_set.cpp b/modules/commands/hs_set.cpp
index b506bfa60..926dc3bfe 100644
--- a/modules/commands/hs_set.cpp
+++ b/modules/commands/hs_set.cpp
@@ -20,7 +20,7 @@ class CommandHSSet : public Command
this->SetSyntax(_("\037nick\037 \037hostmask\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (Anope::ReadOnly)
{
@@ -92,7 +92,7 @@ class CommandHSSet : public Command
source.Reply(_("VHost for \002%s\002 set to \002%s\002."), nick.c_str(), host.c_str());
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -111,9 +111,8 @@ class CommandHSSetAll : public Command
if (!na || !na->HasVhost())
return;
- for (unsigned i = 0; i < na->nc->aliases->size(); ++i)
+ for (auto *nick : *na->nc->aliases)
{
- NickAlias *nick = na->nc->aliases->at(i);
if (nick)
nick->SetVhost(na->GetVhostIdent(), na->GetVhostHost(), na->GetVhostCreator());
}
@@ -126,7 +125,7 @@ class CommandHSSetAll : public Command
this->SetSyntax(_("\037nick\037 \037hostmask\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (Anope::ReadOnly)
{
@@ -199,7 +198,7 @@ class CommandHSSetAll : public Command
source.Reply(_("VHost for group \002%s\002 set to \002%s\002."), nick.c_str(), host.c_str());
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/ms_cancel.cpp b/modules/commands/ms_cancel.cpp
index f915457fe..d9f10b104 100644
--- a/modules/commands/ms_cancel.cpp
+++ b/modules/commands/ms_cancel.cpp
@@ -20,7 +20,7 @@ class CommandMSCancel : public Command
this->SetSyntax(_("{\037nick\037 | \037channel\037}"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (Anope::ReadOnly)
{
@@ -77,7 +77,7 @@ class CommandMSCancel : public Command
source.Reply(_("No memo was cancelable."));
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/ms_check.cpp b/modules/commands/ms_check.cpp
index f6f5d663b..a0b50eeb9 100644
--- a/modules/commands/ms_check.cpp
+++ b/modules/commands/ms_check.cpp
@@ -20,7 +20,7 @@ class CommandMSCheck : public Command
this->SetSyntax(_("\037nick\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &recipient = params[0];
@@ -62,7 +62,7 @@ class CommandMSCheck : public Command
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/ms_del.cpp b/modules/commands/ms_del.cpp
index dc8ac330f..eefd7add7 100644
--- a/modules/commands/ms_del.cpp
+++ b/modules/commands/ms_del.cpp
@@ -22,7 +22,7 @@ class MemoDelCallback : public NumberList
{
}
- void HandleNumber(unsigned number) anope_override
+ void HandleNumber(unsigned number) override
{
if (!number || number > mi->memos->size())
return;
@@ -45,7 +45,7 @@ class CommandMSDel : public Command
this->SetSyntax(_("[\037channel\037] {\037num\037 | \037list\037 | LAST | ALL}"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (Anope::ReadOnly)
{
@@ -122,7 +122,7 @@ class CommandMSDel : public Command
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/ms_ignore.cpp b/modules/commands/ms_ignore.cpp
index f4121ec16..ca6e1ae86 100644
--- a/modules/commands/ms_ignore.cpp
+++ b/modules/commands/ms_ignore.cpp
@@ -22,7 +22,7 @@ class CommandMSIgnore : public Command
this->SetSyntax(_("[\037channel\037] LIST"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (Anope::ReadOnly)
{
@@ -58,7 +58,7 @@ class CommandMSIgnore : public Command
if (std::find(mi->ignores.begin(), mi->ignores.end(), param.ci_str()) == mi->ignores.end())
{
- mi->ignores.push_back(param.ci_str());
+ mi->ignores.emplace_back(param.ci_str());
source.Reply(_("\002%s\002 added to ignore list."), param.c_str());
}
else
@@ -84,10 +84,10 @@ class CommandMSIgnore : public Command
{
ListFormatter list(source.GetAccount());
list.AddColumn(_("Mask"));
- for (unsigned i = 0; i < mi->ignores.size(); ++i)
+ for (const auto &ignore : mi->ignores)
{
ListFormatter::ListEntry entry;
- entry["Mask"] = mi->ignores[i];
+ entry["Mask"] = ignore;
list.AddEntry(entry);
}
@@ -96,8 +96,8 @@ class CommandMSIgnore : public Command
std::vector<Anope::string> replies;
list.Process(replies);
- for (unsigned i = 0; i < replies.size(); ++i)
- source.Reply(replies[i]);
+ for (const auto &reply : replies)
+ source.Reply(reply);
}
}
else
@@ -106,7 +106,7 @@ class CommandMSIgnore : public Command
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/ms_info.cpp b/modules/commands/ms_info.cpp
index 34533b9cb..f9dd20740 100644
--- a/modules/commands/ms_info.cpp
+++ b/modules/commands/ms_info.cpp
@@ -20,7 +20,7 @@ class CommandMSInfo : public Command
this->SetSyntax(_("[\037nick\037 | \037channel\037]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
NickCore *nc = source.nc;
const MemoInfo *mi;
@@ -197,7 +197,7 @@ class CommandMSInfo : public Command
}
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/ms_list.cpp b/modules/commands/ms_list.cpp
index 2bc25e0d2..728fe1a71 100644
--- a/modules/commands/ms_list.cpp
+++ b/modules/commands/ms_list.cpp
@@ -20,7 +20,7 @@ class CommandMSList : public Command
this->SetSyntax(_("[\037channel\037] [\037list\037 | NEW]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
Anope::string param = !params.empty() ? params[0] : "", chan;
@@ -75,7 +75,7 @@ class CommandMSList : public Command
{
}
- void HandleNumber(unsigned number) anope_override
+ void HandleNumber(unsigned number) override
{
if (!number || number > mi->memos->size())
return;
@@ -129,13 +129,13 @@ class CommandMSList : public Command
list.Process(replies);
source.Reply(_("Memos for %s:"), ci ? ci->name.c_str() : source.GetNick().c_str());
- for (unsigned i = 0; i < replies.size(); ++i)
- source.Reply(replies[i]);
+ for (const auto &reply : replies)
+ source.Reply(reply);
}
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/ms_read.cpp b/modules/commands/ms_read.cpp
index 1bfe86437..0fee45e31 100644
--- a/modules/commands/ms_read.cpp
+++ b/modules/commands/ms_read.cpp
@@ -59,13 +59,13 @@ class MemoListCallback : public NumberList
found = false;
}
- ~MemoListCallback()
+ ~MemoListCallback() override
{
if (!found)
source.Reply(_("No memos to display."));
}
- void HandleNumber(unsigned number) anope_override
+ void HandleNumber(unsigned number) override
{
if (!number || number > mi->memos->size())
return;
@@ -113,7 +113,7 @@ class CommandMSRead : public Command
this->SetSyntax(_("[\037channel\037] {\037num\037 | \037list\037 | LAST | NEW | ALL}"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
MemoInfo *mi;
@@ -192,7 +192,7 @@ class CommandMSRead : public Command
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/ms_rsend.cpp b/modules/commands/ms_rsend.cpp
index f7f64b725..bd88749a4 100644
--- a/modules/commands/ms_rsend.cpp
+++ b/modules/commands/ms_rsend.cpp
@@ -25,7 +25,7 @@ class CommandMSRSend : public Command
this->SetSyntax(_("{\037nick\037 | \037channel\037} \037memo-text\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (!memoserv)
return;
@@ -73,7 +73,7 @@ class CommandMSRSend : public Command
}
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/ms_send.cpp b/modules/commands/ms_send.cpp
index 7a1edd039..71d4cc7e4 100644
--- a/modules/commands/ms_send.cpp
+++ b/modules/commands/ms_send.cpp
@@ -25,7 +25,7 @@ class CommandMSSend : public Command
this->SetSyntax(_("{\037nick\037 | \037channel\037} \037memo-text\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (!memoserv)
return;
@@ -59,7 +59,7 @@ class CommandMSSend : public Command
source.Reply(_("Sorry, %s currently has too many memos and cannot receive more."), nick.c_str());
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/ms_sendall.cpp b/modules/commands/ms_sendall.cpp
index 60f93cd87..904e5e161 100644
--- a/modules/commands/ms_sendall.cpp
+++ b/modules/commands/ms_sendall.cpp
@@ -25,7 +25,7 @@ class CommandMSSendAll : public Command
this->SetSyntax(_("\037memo-text\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (!memoserv)
return;
@@ -34,10 +34,8 @@ class CommandMSSendAll : public Command
Log(LOG_ADMIN, source, this) << "to send " << text;
- for (nickcore_map::const_iterator it = NickCoreList->begin(), it_end = NickCoreList->end(); it != it_end; ++it)
+ for (const auto &[_, nc] : *NickCoreList)
{
- const NickCore *nc = it->second;
-
if (nc != source.nc)
memoserv->Send(source.GetNick(), nc->display, text);
}
@@ -45,7 +43,7 @@ class CommandMSSendAll : public Command
source.Reply(_("A massmemo has been sent to all registered users."));
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/ms_set.cpp b/modules/commands/ms_set.cpp
index fc87b9b61..f1d2ebba6 100644
--- a/modules/commands/ms_set.cpp
+++ b/modules/commands/ms_set.cpp
@@ -207,7 +207,7 @@ class CommandMSSet : public Command
this->SetSyntax(_("\037option\037 \037parameters\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &cmd = params[0];
MemoInfo *mi = &source.nc->memos;
@@ -226,7 +226,7 @@ class CommandMSSet : public Command
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
if (subcommand.empty())
{
diff --git a/modules/commands/ms_staff.cpp b/modules/commands/ms_staff.cpp
index fba892467..2b0efae6d 100644
--- a/modules/commands/ms_staff.cpp
+++ b/modules/commands/ms_staff.cpp
@@ -25,23 +25,21 @@ class CommandMSStaff : public Command
this->SetSyntax(_("\037memo-text\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (!memoserv)
return;
const Anope::string &text = params[0];
- for (nickcore_map::const_iterator it = NickCoreList->begin(), it_end = NickCoreList->end(); it != it_end; ++it)
+ for (const auto &[_, nc] : *NickCoreList)
{
- const NickCore *nc = it->second;
-
if (source.nc != nc && nc->IsServicesOper())
memoserv->Send(source.GetNick(), nc->display, text, true);
}
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/ns_access.cpp b/modules/commands/ns_access.cpp
index 73f760121..d85277a51 100644
--- a/modules/commands/ns_access.cpp
+++ b/modules/commands/ns_access.cpp
@@ -104,7 +104,7 @@ class CommandNSAccess : public Command
this->SetSyntax(_("LIST [\037nickname\037]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &cmd = params[0];
Anope::string nick, mask;
@@ -159,7 +159,7 @@ class CommandNSAccess : public Command
this->OnSyntaxError(source, "");
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -196,7 +196,7 @@ class NSAccess : public Module
{
}
- void OnNickRegister(User *u, NickAlias *na, const Anope::string &) anope_override
+ void OnNickRegister(User *u, NickAlias *na, const Anope::string &) override
{
if (u && Config->GetModule(this)->Get<bool>("addaccessonreg"))
na->nc->AddAccess(u->Mask());
diff --git a/modules/commands/ns_ajoin.cpp b/modules/commands/ns_ajoin.cpp
index fef32094f..a783708a9 100644
--- a/modules/commands/ns_ajoin.cpp
+++ b/modules/commands/ns_ajoin.cpp
@@ -27,7 +27,7 @@ struct AJoinEntry : Serializable
AJoinEntry(Extensible *) : Serializable("AJoinEntry") { }
- ~AJoinEntry()
+ ~AJoinEntry() override
{
AJoinList *channels = owner->GetExt<AJoinList>("ajoinlist");
if (channels)
@@ -38,7 +38,7 @@ struct AJoinEntry : Serializable
}
}
- void Serialize(Serialize::Data &sd) const anope_override
+ void Serialize(Serialize::Data &sd) const override
{
if (!this->owner)
return;
@@ -82,8 +82,8 @@ struct AJoinEntry : Serializable
AJoinList::~AJoinList()
{
- for (unsigned i = 0; i < (*this)->size(); ++i)
- delete (*this)->at(i);
+ for (const auto *ajoin : *(*this))
+ delete ajoin;
}
class CommandNSAJoin : public Command
@@ -113,8 +113,8 @@ class CommandNSAJoin : public Command
std::vector<Anope::string> replies;
list.Process(replies);
- for (unsigned i = 0; i < replies.size(); ++i)
- source.Reply(replies[i]);
+ for (const auto &reply : replies)
+ source.Reply(reply);
}
}
@@ -233,7 +233,7 @@ class CommandNSAJoin : public Command
this->SetSyntax(_("LIST [\037nickname\037]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &cmd = params[0];
Anope::string nick, param, param2;
@@ -285,7 +285,7 @@ class CommandNSAJoin : public Command
this->OnSyntaxError(source, "");
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -314,7 +314,7 @@ class NSAJoin : public Module
}
- void OnUserLogin(User *u) anope_override
+ void OnUserLogin(User *u) override
{
BotInfo *NickServ = Config->GetClient("NickServ");
if (!NickServ)
@@ -327,9 +327,8 @@ class NSAJoin : public Module
/* Set +r now, so we can ajoin users into +R channels */
ModeManager::ProcessModes();
- for (unsigned i = 0; i < (*channels)->size(); ++i)
+ for (auto *entry : *(*channels))
{
- AJoinEntry *entry = (*channels)->at(i);
Channel *c = Channel::Find(entry->channel);
ChannelInfo *ci;
@@ -356,7 +355,7 @@ class NSAJoin : public Module
continue;
else if (c->HasMode("ADMINONLY") && !u->HasMode("ADMIN"))
continue;
- else if (c->HasMode("SSL") && !(u->HasMode("SSL") || u->HasExt("ssl")))
+ else if (c->HasMode("SSL") && !u->IsSecurelyConnected())
continue;
else if (c->MatchesList(u, "BAN") == true && c->MatchesList(u, "EXCEPT") == false)
need_invite = true;
diff --git a/modules/commands/ns_alist.cpp b/modules/commands/ns_alist.cpp
index dc4a0a19e..e0f160aa2 100644
--- a/modules/commands/ns_alist.cpp
+++ b/modules/commands/ns_alist.cpp
@@ -25,7 +25,7 @@ class CommandNSAList : public Command
this->SetSyntax(_("[\037nickname\037]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
Anope::string nick = source.GetNick();
NickCore *nc = source.nc;
@@ -51,9 +51,8 @@ class CommandNSAList : public Command
nc->GetChannelReferences(queue);
std::sort(queue.begin(), queue.end(), ChannelSort);
- for (unsigned i = 0; i < queue.size(); ++i)
+ for (auto *ci : queue)
{
- ChannelInfo *ci = queue[i];
ListFormatter::ListEntry entry;
if (ci->GetFounder() == nc)
@@ -86,10 +85,8 @@ class CommandNSAList : public Command
entry["Number"] = stringify(chan_count);
entry["Channel"] = (ci->HasExt("CS_NO_EXPIRE") ? "!" : "") + ci->name;
- for (unsigned j = 0; j < access.paths.size(); ++j)
+ for (auto &p : access.paths)
{
- ChanAccess::Path &p = access.paths[j];
-
// not interested in indirect access
if (p.size() != 1)
continue;
@@ -113,14 +110,14 @@ class CommandNSAList : public Command
{
source.Reply(_("Channels that \002%s\002 has access on:"), nc->display.c_str());
- for (unsigned i = 0; i < replies.size(); ++i)
- source.Reply(replies[i]);
+ for (const auto &reply : replies)
+ source.Reply(reply);
source.Reply(_("End of list - %d channels shown."), chan_count);
}
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/ns_cert.cpp b/modules/commands/ns_cert.cpp
index a9674df67..4e42d9fb5 100644
--- a/modules/commands/ns_cert.cpp
+++ b/modules/commands/ns_cert.cpp
@@ -18,7 +18,7 @@ struct CertServiceImpl : CertService
{
CertServiceImpl(Module *o) : CertService(o) { }
- NickCore* FindAccountFromCert(const Anope::string &cert) anope_override
+ NickCore* FindAccountFromCert(const Anope::string &cert) override
{
Anope::hash_map<NickCore *>::iterator it = certmap.find(cert);
if (it != certmap.end())
@@ -35,7 +35,7 @@ struct NSCertListImpl : NSCertList
public:
NSCertListImpl(Extensible *obj) : nc(anope_dynamic_static_cast<NickCore *>(obj)) { }
- ~NSCertListImpl()
+ ~NSCertListImpl() override
{
ClearCert();
}
@@ -46,7 +46,7 @@ struct NSCertListImpl : NSCertList
*
* Adds a new entry into the cert list.
*/
- void AddCert(const Anope::string &entry) anope_override
+ void AddCert(const Anope::string &entry) override
{
this->certs.push_back(entry);
certmap[entry] = nc;
@@ -60,14 +60,14 @@ struct NSCertListImpl : NSCertList
*
* Retrieves an entry from the certificate list corresponding to the given index.
*/
- Anope::string GetCert(unsigned entry) const anope_override
+ Anope::string GetCert(unsigned entry) const override
{
if (entry >= this->certs.size())
return "";
return this->certs[entry];
}
- unsigned GetCertCount() const anope_override
+ unsigned GetCertCount() const override
{
return this->certs.size();
}
@@ -79,7 +79,7 @@ struct NSCertListImpl : NSCertList
*
* Search for an fingerprint within the cert list.
*/
- bool FindCert(const Anope::string &entry) const anope_override
+ bool FindCert(const Anope::string &entry) const override
{
return std::find(this->certs.begin(), this->certs.end(), entry) != this->certs.end();
}
@@ -90,7 +90,7 @@ struct NSCertListImpl : NSCertList
*
* Removes the specified fingerprint from the cert list.
*/
- void EraseCert(const Anope::string &entry) anope_override
+ void EraseCert(const Anope::string &entry) override
{
std::vector<Anope::string>::iterator it = std::find(this->certs.begin(), this->certs.end(), entry);
if (it != this->certs.end())
@@ -105,15 +105,15 @@ struct NSCertListImpl : NSCertList
*
* Deletes all the memory allocated in the certificate list vector and then clears the vector.
*/
- void ClearCert() anope_override
+ void ClearCert() override
{
FOREACH_MOD(OnNickClearCert, (this->nc));
- for (unsigned i = 0; i < certs.size(); ++i)
- certmap.erase(certs[i]);
+ for (const auto &cert : certs)
+ certmap.erase(cert);
this->certs.clear();
}
- void Check() anope_override
+ void Check() override
{
if (this->certs.empty())
nc->Shrink<NSCertList>("certificates");
@@ -123,7 +123,7 @@ struct NSCertListImpl : NSCertList
{
ExtensibleItem(Module *m, const Anope::string &ename) : ::ExtensibleItem<NSCertListImpl>(m, ename) { }
- void ExtensibleSerialize(const Extensible *e, const Serializable *s, Serialize::Data &data) const anope_override
+ void ExtensibleSerialize(const Extensible *e, const Serializable *s, Serialize::Data &data) const override
{
if (s->GetSerializableType()->GetName() != "NickCore")
return;
@@ -137,7 +137,7 @@ struct NSCertListImpl : NSCertList
data["cert"] << c->GetCert(i) << " ";
}
- void ExtensibleUnserialize(Extensible *e, Serializable *s, Serialize::Data &data) anope_override
+ void ExtensibleUnserialize(Extensible *e, Serializable *s, Serialize::Data &data) override
{
if (s->GetSerializableType()->GetName() != "NickCore")
return;
@@ -148,8 +148,8 @@ struct NSCertListImpl : NSCertList
Anope::string buf;
data["cert"] >> buf;
spacesepstream sep(buf);
- for (unsigned i = 0; i < c->certs.size(); ++i)
- certmap.erase(c->certs[i]);
+ for (const auto &cert : c->certs)
+ certmap.erase(cert);
c->certs.clear();
while (sep.GetToken(buf))
{
@@ -260,7 +260,7 @@ class CommandNSCert : public Command
this->SetSyntax(_("LIST [\037nickname\037]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &cmd = params[0];
Anope::string nick, certfp;
@@ -312,7 +312,7 @@ class CommandNSCert : public Command
this->OnSyntaxError(source, "");
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -352,7 +352,7 @@ class NSCert : public Module
throw ModuleException("Your IRCd does not support ssl client certificates");
}
- void OnFingerprint(User *u) anope_override
+ void OnFingerprint(User *u) override
{
BotInfo *NickServ = Config->GetClient("NickServ");
if (!NickServ || u->IsIdentified())
@@ -379,7 +379,7 @@ class NSCert : public Module
Log(NickServ) << u->GetMask() << " automatically identified for account " << nc->display << " via SSL certificate fingerprint";
}
- EventReturn OnNickValidate(User *u, NickAlias *na) anope_override
+ EventReturn OnNickValidate(User *u, NickAlias *na) override
{
NSCertList *cl = certs.Get(na->nc);
if (!u->fingerprint.empty() && cl && cl->FindCert(u->fingerprint))
diff --git a/modules/commands/ns_drop.cpp b/modules/commands/ns_drop.cpp
index bb4c95dff..3cf9c9bb0 100644
--- a/modules/commands/ns_drop.cpp
+++ b/modules/commands/ns_drop.cpp
@@ -20,7 +20,7 @@ class CommandNSDrop : public Command
this->SetDesc(_("Cancel the registration of a nickname"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &nick = params[0];
@@ -54,7 +54,7 @@ class CommandNSDrop : public Command
}
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/ns_getemail.cpp b/modules/commands/ns_getemail.cpp
index 685431fe9..de418cd0c 100644
--- a/modules/commands/ns_getemail.cpp
+++ b/modules/commands/ns_getemail.cpp
@@ -24,17 +24,15 @@ class CommandNSGetEMail : public Command
this->SetSyntax(_("\037email\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &email = params[0];
int j = 0;
Log(LOG_ADMIN, source, this) << "on " << email;
- for (nickcore_map::const_iterator it = NickCoreList->begin(), it_end = NickCoreList->end(); it != it_end; ++it)
+ for (const auto &[_, nc] : *NickCoreList)
{
- const NickCore *nc = it->second;
-
if (!nc->email.empty() && Anope::Match(nc->email, email))
{
++j;
@@ -51,7 +49,7 @@ class CommandNSGetEMail : public Command
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/ns_getpass.cpp b/modules/commands/ns_getpass.cpp
deleted file mode 100644
index 0605a3078..000000000
--- a/modules/commands/ns_getpass.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/* NickServ core functions
- *
- * (C) 2003-2023 Anope Team
- * Contact us at team@anope.org
- *
- * Please read COPYING and README for further details.
- *
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
- */
-
-#include "module.h"
-
-class CommandNSGetPass : public Command
-{
- public:
- CommandNSGetPass(Module *creator) : Command(creator, "nickserv/getpass", 1, 1)
- {
- this->SetDesc(_("Retrieve the password for a nickname"));
- this->SetSyntax(_("\037nickname\037"));
- }
-
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
- {
- const Anope::string &nick = params[0];
- Anope::string tmp_pass;
- const NickAlias *na;
-
- if (!(na = NickAlias::Find(nick)))
- source.Reply(NICK_X_NOT_REGISTERED, nick.c_str());
- else if (Config->GetModule("nickserv")->Get<bool>("secureadmins", "yes") && na->nc->IsServicesOper())
- source.Reply(_("You may not get the password of other Services Operators."));
- else
- {
- if (Anope::Decrypt(na->nc->pass, tmp_pass) == 1)
- {
- Log(LOG_ADMIN, source, this) << "for " << nick;
- source.Reply(_("Password for %s is \002%s\002."), nick.c_str(), tmp_pass.c_str());
- }
- else
- source.Reply(_("GETPASS command unavailable because encryption is in use."));
- }
- return;
- }
-
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
- {
- this->SendSyntax(source);
- source.Reply(" ");
- source.Reply(_("Returns the password for the given nickname. \002Note\002 that\n"
- "whenever this command is used, a message including the\n"
- "person who issued the command and the nickname it was used\n"
- "on will be logged and sent out as a WALLOPS/GLOBOPS."));
- return true;
- }
-};
-
-class NSGetPass : public Module
-{
- CommandNSGetPass commandnsgetpass;
-
- public:
- NSGetPass(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
- commandnsgetpass(this)
- {
-
- Anope::string tmp_pass = "plain:tmp";
- if (!Anope::Decrypt(tmp_pass, tmp_pass))
- throw ModuleException("Incompatible with the encryption module being used");
-
- }
-};
-
-MODULE_INIT(NSGetPass)
diff --git a/modules/commands/ns_group.cpp b/modules/commands/ns_group.cpp
index 6830b7cd1..af9b71584 100644
--- a/modules/commands/ns_group.cpp
+++ b/modules/commands/ns_group.cpp
@@ -22,7 +22,7 @@ class NSGroupRequest : public IdentifyRequest
public:
NSGroupRequest(Module *o, CommandSource &src, Command *c, const Anope::string &n, NickAlias *targ, const Anope::string &pass) : IdentifyRequest(o, targ->nc->display, pass), source(src), cmd(c), nick(n), target(targ) { }
- void OnSuccess() anope_override
+ void OnSuccess() override
{
User *u = source.GetUser();
@@ -67,7 +67,7 @@ class NSGroupRequest : public IdentifyRequest
u->lastnickreg = Anope::CurTime;
}
- void OnFail() anope_override
+ void OnFail() override
{
User *u = source.GetUser();
@@ -93,7 +93,7 @@ class CommandNSGroup : public Command
this->AllowUnregistered(true);
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
User *user = source.GetUser();
@@ -128,16 +128,16 @@ class CommandNSGroup : public Command
}
if (Config->GetModule("nickserv")->Get<bool>("restrictopernicks"))
- for (unsigned i = 0; i < Oper::opers.size(); ++i)
+ {
+ for (auto *o : Oper::opers)
{
- Oper *o = Oper::opers[i];
-
if (user != NULL && !user->HasMode("OPER") && user->nick.find_ci(o->name) != Anope::string::npos)
{
source.Reply(NICK_CANNOT_BE_REGISTERED, user->nick.c_str());
return;
}
}
+ }
NickAlias *target, *na = NickAlias::Find(source.GetNick());
const Anope::string &guestnick = Config->GetModule("nickserv")->Get<const Anope::string>("guestnickprefix", "Guest");
@@ -194,7 +194,7 @@ class CommandNSGroup : public Command
}
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -237,7 +237,7 @@ class CommandNSUngroup : public Command
this->SetSyntax(_("[\037nick\037]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
Anope::string nick = !params.empty() ? params[0] : "";
NickAlias *na = NickAlias::Find(!nick.empty() ? nick : source.GetNick());
@@ -278,7 +278,7 @@ class CommandNSUngroup : public Command
}
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -299,7 +299,7 @@ class CommandNSGList : public Command
this->SetDesc(_("Lists all nicknames in your group"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &nick = !params.empty() ? params[0] : "";
const NickCore *nc;
@@ -325,12 +325,10 @@ class CommandNSGList : public Command
ListFormatter list(source.GetAccount());
list.AddColumn(_("Nick")).AddColumn(_("Expires"));
- time_t nickserv_expire = Config->GetModule("nickserv")->Get<time_t>("expire", "21d"),
+ time_t nickserv_expire = Config->GetModule("nickserv")->Get<time_t>("expire", "90d"),
unconfirmed_expire = Config->GetModule("ns_register")->Get<time_t>("unconfirmedexpire", "1d");
- for (unsigned i = 0; i < nc->aliases->size(); ++i)
+ for (auto *na2 : *nc->aliases)
{
- const NickAlias *na2 = nc->aliases->at(i);
-
Anope::string expires;
if (na2->HasExt("NS_NO_EXPIRE"))
expires = NO_EXPIRE;
@@ -351,13 +349,13 @@ class CommandNSGList : public Command
std::vector<Anope::string> replies;
list.Process(replies);
- for (unsigned i = 0; i < replies.size(); ++i)
- source.Reply(replies[i]);
+ for (const auto &reply : replies)
+ source.Reply(reply);
source.Reply(_("%d nickname(s) in the group."), nc->aliases->size());
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
if (source.IsServicesOper())
source.Reply(_("Syntax: \002%s [\037nickname\037]\002\n"
diff --git a/modules/commands/ns_identify.cpp b/modules/commands/ns_identify.cpp
index 8608a11e6..edab989e2 100644
--- a/modules/commands/ns_identify.cpp
+++ b/modules/commands/ns_identify.cpp
@@ -19,7 +19,7 @@ class NSIdentifyRequest : public IdentifyRequest
public:
NSIdentifyRequest(Module *o, CommandSource &s, Command *c, const Anope::string &acc, const Anope::string &pass) : IdentifyRequest(o, acc, pass), source(s), cmd(c) { }
- void OnSuccess() anope_override
+ void OnSuccess() override
{
if (!source.GetUser())
return;
@@ -40,7 +40,7 @@ class NSIdentifyRequest : public IdentifyRequest
}
}
- void OnFail() anope_override
+ void OnFail() override
{
if (source.GetUser())
{
@@ -68,7 +68,7 @@ class CommandNSIdentify : public Command
this->RequireUser(true);
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
User *u = source.GetUser();
@@ -100,7 +100,7 @@ class CommandNSIdentify : public Command
req->Dispatch();
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/ns_info.cpp b/modules/commands/ns_info.cpp
index b65106ba5..abe423acb 100644
--- a/modules/commands/ns_info.cpp
+++ b/modules/commands/ns_info.cpp
@@ -21,7 +21,7 @@ class CommandNSInfo : public Command
this->AllowUnregistered(true);
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &nick = params.size() ? params[0] : (source.nc ? source.nc->display : source.GetNick());
@@ -114,12 +114,12 @@ class CommandNSInfo : public Command
std::vector<Anope::string> replies;
info.Process(replies);
- for (unsigned i = 0; i < replies.size(); ++i)
- source.Reply(replies[i]);
+ for (const auto &reply : replies)
+ source.Reply(reply);
}
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -212,12 +212,12 @@ class CommandNSSetHide : public Command
this->OnSyntaxError(source, "HIDE");
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
this->Run(source, source.nc->display, params[0], params[1]);
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -240,13 +240,13 @@ class CommandNSSASetHide : public CommandNSSetHide
this->SetSyntax(_("\037nickname\037 {EMAIL | STATUS | USERMASK | QUIT} {ON | OFF}"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
this->ClearSyntax();
this->Run(source, params[0], params[1], params[2]);
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/ns_list.cpp b/modules/commands/ns_list.cpp
index af29d8658..3c690984e 100644
--- a/modules/commands/ns_list.cpp
+++ b/modules/commands/ns_list.cpp
@@ -20,7 +20,7 @@ class CommandNSList : public Command
this->SetSyntax(_("\037pattern\037 [SUSPENDED] [NOEXPIRE] [UNCONFIRMED]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
Anope::string pattern = params[0];
@@ -75,13 +75,11 @@ class CommandNSList : public Command
list.AddColumn(_("Nick")).AddColumn(_("Last usermask"));
Anope::map<NickAlias *> ordered_map;
- for (nickalias_map::const_iterator it = NickAliasList->begin(), it_end = NickAliasList->end(); it != it_end; ++it)
- ordered_map[it->first] = it->second;
+ for (const auto &[nick, na] : *NickAliasList)
+ ordered_map[nick] = na;
- for (Anope::map<NickAlias *>::const_iterator it = ordered_map.begin(), it_end = ordered_map.end(); it != it_end; ++it)
+ for (const auto &[_, na] : ordered_map)
{
- const NickAlias *na = it->second;
-
/* Don't show private nicks to non-services admins. */
if (na->nc->HasExt("NS_PRIVATE") && !is_servadmin && na->nc != mync)
continue;
@@ -125,14 +123,14 @@ class CommandNSList : public Command
std::vector<Anope::string> replies;
list.Process(replies);
- for (unsigned i = 0; i < replies.size(); ++i)
- source.Reply(replies[i]);
+ for (const auto &reply : replies)
+ source.Reply(reply);
source.Reply(_("End of list - %d/%d matches shown."), nnicks > listmax ? listmax : nnicks, nnicks);
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -224,12 +222,12 @@ class CommandNSSetPrivate : public Command
this->OnSyntaxError(source, "PRIVATE");
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
this->Run(source, source.nc->display, params[0]);
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -252,12 +250,12 @@ class CommandNSSASetPrivate : public CommandNSSetPrivate
this->SetSyntax(_("\037nickname\037 {ON | OFF}"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
this->Run(source, params[0], params[1]);
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -288,7 +286,7 @@ class NSList : public Module
{
}
- void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_all) anope_override
+ void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_all) override
{
if (!show_all)
return;
diff --git a/modules/commands/ns_logout.cpp b/modules/commands/ns_logout.cpp
index 74e2e59f9..e281a9708 100644
--- a/modules/commands/ns_logout.cpp
+++ b/modules/commands/ns_logout.cpp
@@ -22,7 +22,7 @@ class CommandNSLogout : public Command
this->SetSyntax(_("[\037nickname\037 [REVALIDATE]]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &nick = !params.empty() ? params[0] : "";
@@ -59,7 +59,7 @@ class CommandNSLogout : public Command
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -69,7 +69,7 @@ class CommandNSLogout : public Command
"yourself.\n"
" \n"
"With a parameter, does the same for the given nick. If you\n"
- "specify \002REVALIDATE\002 as well, Services will ask the given nick\n"
+ "specify \002REVALIDATE\002 as well, services will ask the given nick\n"
"to re-identify. This is limited to \002Services Operators\002."));
return true;
diff --git a/modules/commands/ns_recover.cpp b/modules/commands/ns_recover.cpp
index 67994a983..f8ca00329 100644
--- a/modules/commands/ns_recover.cpp
+++ b/modules/commands/ns_recover.cpp
@@ -32,7 +32,7 @@ class NSRecoverRequest : public IdentifyRequest
public:
NSRecoverRequest(Module *o, CommandSource &src, Command *c, const Anope::string &nick, const Anope::string &pass) : IdentifyRequest(o, nick, pass), source(src), cmd(c), user(nick) { }
- void OnSuccess() anope_override
+ void OnSuccess() override
{
User *u = User::Find(user, true);
if (!source.GetUser() || !source.service)
@@ -69,8 +69,8 @@ class NSRecoverRequest : public IdentifyRequest
if (!u->chans.empty())
{
NSRecoverInfo *ei = source.GetUser()->Extend<NSRecoverInfo>("recover");
- for (User::ChanUserList::iterator it = u->chans.begin(), it_end = u->chans.end(); it != it_end; ++it)
- (*ei)[it->first->name] = it->second->status;
+ for (auto &[chan, cuc] : u->chans)
+ (*ei)[chan->name] = cuc->status;
}
}
@@ -124,7 +124,7 @@ class NSRecoverRequest : public IdentifyRequest
}
}
- void OnFail() anope_override
+ void OnFail() override
{
if (NickAlias::Find(GetAccount()) != NULL)
{
@@ -151,7 +151,7 @@ class CommandNSRecover : public Command
this->AllowUnregistered(true);
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &nick = params[0];
const Anope::string &pass = params.size() > 1 ? params[1] : "";
@@ -207,7 +207,7 @@ class CommandNSRecover : public Command
}
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -237,7 +237,7 @@ class NSRecover : public Module
}
- void OnUserNickChange(User *u, const Anope::string &oldnick) anope_override
+ void OnUserNickChange(User *u, const Anope::string &oldnick) override
{
if (Config->GetModule(this)->Get<bool>("restoreonrecover"))
{
@@ -272,7 +272,7 @@ class NSRecover : public Module
}
}
- void OnJoinChannel(User *u, Channel *c) anope_override
+ void OnJoinChannel(User *u, Channel *c) override
{
if (Config->GetModule(this)->Get<bool>("restoreonrecover"))
{
@@ -283,8 +283,8 @@ class NSRecover : public Module
NSRecoverInfo::iterator it = ei->find(c->name);
if (it != ei->end())
{
- for (size_t i = 0; i < it->second.Modes().length(); ++i)
- c->SetMode(c->WhoSends(), ModeManager::FindChannelModeByChar(it->second.Modes()[i]), u->GetUID());
+ for (auto mode : it->second.Modes())
+ c->SetMode(c->WhoSends(), ModeManager::FindChannelModeByChar(mode), u->GetUID());
ei->erase(it);
if (ei->empty())
diff --git a/modules/commands/ns_register.cpp b/modules/commands/ns_register.cpp
index bd188637c..6fd47ad38 100644
--- a/modules/commands/ns_register.cpp
+++ b/modules/commands/ns_register.cpp
@@ -23,7 +23,7 @@ class CommandNSConfirm : public Command
this->AllowUnregistered(true);
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &passcode = params[0];
@@ -88,7 +88,7 @@ class CommandNSConfirm : public Command
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -106,7 +106,7 @@ class CommandNSConfirm : public Command
return true;
}
- void OnSyntaxError(CommandSource &source, const Anope::string &subcommand) anope_override
+ void OnSyntaxError(CommandSource &source, const Anope::string &subcommand) override
{
source.Reply(NICK_CONFIRM_INVALID);
}
@@ -125,7 +125,7 @@ class CommandNSRegister : public Command
this->AllowUnregistered(true);
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
User *u = source.GetUser();
Anope::string u_nick = source.GetNick();
@@ -180,10 +180,8 @@ class CommandNSRegister : public Command
if (Config->GetModule("nickserv")->Get<bool>("restrictopernicks"))
{
- for (unsigned i = 0; i < Oper::opers.size(); ++i)
+ for (auto *o : Oper::opers)
{
- Oper *o = Oper::opers[i];
-
if (!source.IsOper() && u_nick.find_ci(o->name) != Anope::string::npos)
{
source.Reply(NICK_CANNOT_BE_REGISTERED, u_nick.c_str());
@@ -192,7 +190,8 @@ class CommandNSRegister : public Command
}
}
- unsigned int passlen = Config->GetModule("nickserv")->Get<unsigned>("passlen", "32");
+ unsigned int minpasslen = Config->GetModule("nickserv")->Get<unsigned>("minpasslen", "8");
+ unsigned int maxpasslen = Config->GetModule("nickserv")->Get<unsigned>("maxpasslen", "32");
if (Config->GetModule("nickserv")->Get<bool>("forceemail", "yes") && email.empty())
this->OnSyntaxError(source, "");
@@ -200,10 +199,12 @@ class CommandNSRegister : public Command
source.Reply(_("Please wait %d seconds before using the REGISTER command again."), (u->lastnickreg + reg_delay) - Anope::CurTime);
else if (NickAlias::Find(u_nick) != NULL)
source.Reply(NICK_ALREADY_REGISTERED, u_nick.c_str());
- else if (pass.equals_ci(u_nick) || (Config->GetBlock("options")->Get<bool>("strictpasswords") && pass.length() < 5))
+ else if (pass.equals_ci(u_nick))
source.Reply(MORE_OBSCURE_PASSWORD);
- else if (pass.length() > passlen)
- source.Reply(PASSWORD_TOO_LONG, passlen);
+ else if (pass.length() < minpasslen)
+ source.Reply(PASSWORD_TOO_SHORT, minpasslen);
+ else if (pass.length() > maxpasslen)
+ source.Reply(PASSWORD_TOO_LONG, maxpasslen);
else if (!email.empty() && !Mail::Validate(email))
source.Reply(MAIL_X_INVALID, email.c_str());
else
@@ -229,10 +230,6 @@ class CommandNSRegister : public Command
else
source.Reply(_("Nickname \002%s\002 registered."), u_nick.c_str());
- Anope::string tmp_pass;
- if (Anope::Decrypt(na->nc->pass, tmp_pass) == 1)
- source.Reply(_("Your password is \002%s\002 - remember this for later use."), tmp_pass.c_str());
-
if (nsregister.equals_ci("admin"))
{
nc->Extend<bool>("UNCONFIRMED");
@@ -264,7 +261,7 @@ class CommandNSRegister : public Command
}
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -314,7 +311,7 @@ class CommandNSResend : public Command
this->SetDesc(_("Resend registration confirmation email"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (!Config->GetModule(this->owner)->Get<const Anope::string>("registration").equals_ci("mail"))
{
@@ -345,7 +342,7 @@ class CommandNSResend : public Command
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
if (!Config->GetModule(this->owner)->Get<const Anope::string>("registration").equals_ci("mail"))
return false;
@@ -356,7 +353,7 @@ class CommandNSResend : public Command
return true;
}
- void OnServHelp(CommandSource &source) anope_override
+ void OnServHelp(CommandSource &source) override
{
if (Config->GetModule(this->owner)->Get<const Anope::string>("registration").equals_ci("mail"))
Command::OnServHelp(source);
@@ -381,7 +378,7 @@ class NSRegister : public Module
throw ModuleException("Module " + this->name + " will not load with registration disabled.");
}
- void OnNickIdentify(User *u) anope_override
+ void OnNickIdentify(User *u) override
{
BotInfo *NickServ;
if (unconfirmed.HasExt(u->Account()) && (NickServ = Config->GetClient("NickServ")))
@@ -399,7 +396,7 @@ class NSRegister : public Module
}
}
- void OnPreNickExpire(NickAlias *na, bool &expire) anope_override
+ void OnPreNickExpire(NickAlias *na, bool &expire) override
{
if (unconfirmed.HasExt(na->nc))
{
diff --git a/modules/commands/ns_resetpass.cpp b/modules/commands/ns_resetpass.cpp
index bf5f30230..c0001cbe4 100644
--- a/modules/commands/ns_resetpass.cpp
+++ b/modules/commands/ns_resetpass.cpp
@@ -23,7 +23,7 @@ class CommandNSResetPass : public Command
this->AllowUnregistered(true);
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const NickAlias *na;
@@ -43,7 +43,7 @@ class CommandNSResetPass : public Command
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -73,7 +73,7 @@ class NSResetPass : public Module
throw ModuleException("Not using mail.");
}
- EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> &params) anope_override
+ EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> &params) override
{
if (command->name == "nickserv/confirm" && params.size() > 1)
{
@@ -106,7 +106,7 @@ class NSResetPass : public Module
{
source.GetUser()->Identify(na);
}
-
+
source.Reply(_("You are now identified for your nick. Change your password now."));
}
else
diff --git a/modules/commands/ns_set.cpp b/modules/commands/ns_set.cpp
index 62dd51180..b18bb9cff 100644
--- a/modules/commands/ns_set.cpp
+++ b/modules/commands/ns_set.cpp
@@ -20,13 +20,13 @@ class CommandNSSet : public Command
this->SetSyntax(_("\037option\037 \037parameters\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
this->OnSyntaxError(source, "");
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -35,11 +35,8 @@ class CommandNSSet : public Command
Anope::string this_name = source.command;
bool hide_privileged_commands = Config->GetBlock("options")->Get<bool>("hideprivilegedcommands"),
hide_registered_commands = Config->GetBlock("options")->Get<bool>("hideregisteredcommands");
- for (CommandInfo::map::const_iterator it = source.service->commands.begin(), it_end = source.service->commands.end(); it != it_end; ++it)
+ for (const auto &[c_name, info] : source.service->commands)
{
- const Anope::string &c_name = it->first;
- const CommandInfo &info = it->second;
-
if (c_name.find_ci(this_name + " ") == 0)
{
if (info.hide)
@@ -75,24 +72,21 @@ class CommandNSSASet : public Command
this->SetSyntax(_("\037option\037 \037nickname\037 \037parameters\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
this->OnSyntaxError(source, "");
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
source.Reply(_("Sets various nickname options. \037option\037 can be one of:"));
Anope::string this_name = source.command;
- for (CommandInfo::map::const_iterator it = source.service->commands.begin(), it_end = source.service->commands.end(); it != it_end; ++it)
+ for (const auto &[c_name, info] : source.service->commands)
{
- const Anope::string &c_name = it->first;
- const CommandInfo &info = it->second;
-
if (c_name.find_ci(this_name + " ") == 0)
{
ServiceReference<Command> command("Command", info.name);
@@ -120,7 +114,7 @@ class CommandNSSetPassword : public Command
this->SetSyntax(_("\037new-password\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &param = params[0];
unsigned len = param.length();
@@ -131,30 +125,33 @@ class CommandNSSetPassword : public Command
return;
}
- if (source.GetNick().equals_ci(param) || (Config->GetBlock("options")->Get<bool>("strictpasswords") && len < 5))
+ if (source.GetNick().equals_ci(param))
{
source.Reply(MORE_OBSCURE_PASSWORD);
return;
}
- unsigned int passlen = Config->GetModule("nickserv")->Get<unsigned>("passlen", "32");
- if (len > passlen)
+ unsigned int minpasslen = Config->GetModule("nickserv")->Get<unsigned>("minpasslen", "8");
+ if (len < minpasslen)
{
- source.Reply(PASSWORD_TOO_LONG, passlen);
+ source.Reply(PASSWORD_TOO_SHORT, minpasslen);
+ return;
+ }
+
+ unsigned int maxpasslen = Config->GetModule("nickserv")->Get<unsigned>("maxpasslen", "32");
+ if (len > maxpasslen)
+ {
+ source.Reply(PASSWORD_TOO_LONG, maxpasslen);
return;
}
Log(LOG_COMMAND, source, this) << "to change their password";
Anope::Encrypt(param, source.nc->pass);
- Anope::string tmp_pass;
- if (Anope::Decrypt(source.nc->pass, tmp_pass) == 1)
- source.Reply(_("Password for \002%s\002 changed to \002%s\002."), source.nc->display.c_str(), tmp_pass.c_str());
- else
- source.Reply(_("Password for \002%s\002 changed."), source.nc->display.c_str());
+ source.Reply(_("Password for \002%s\002 changed."), source.nc->display.c_str());
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -173,7 +170,7 @@ class CommandNSSASetPassword : public Command
this->SetSyntax(_("\037nickname\037 \037new-password\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (Anope::ReadOnly)
{
@@ -197,16 +194,23 @@ class CommandNSSASetPassword : public Command
return;
}
- if (nc->display.equals_ci(params[1]) || (Config->GetBlock("options")->Get<bool>("strictpasswords") && len < 5))
+ if (nc->display.equals_ci(params[1]))
{
source.Reply(MORE_OBSCURE_PASSWORD);
return;
}
- unsigned int passlen = Config->GetModule("nickserv")->Get<unsigned>("passlen", "32");
- if (len > passlen)
+ unsigned int minpasslen = Config->GetModule("nickserv")->Get<unsigned>("minpasslen", "8");
+ if (len < minpasslen)
+ {
+ source.Reply(PASSWORD_TOO_SHORT, minpasslen);
+ return;
+ }
+
+ unsigned int maxpasslen = Config->GetModule("nickserv")->Get<unsigned>("maxpasslen", "32");
+ if (len > maxpasslen)
{
- source.Reply(PASSWORD_TOO_LONG, passlen);
+ source.Reply(PASSWORD_TOO_LONG, maxpasslen);
return;
}
@@ -214,13 +218,10 @@ class CommandNSSASetPassword : public Command
Anope::Encrypt(params[1], nc->pass);
Anope::string tmp_pass;
- if (Anope::Decrypt(nc->pass, tmp_pass) == 1)
- source.Reply(_("Password for \002%s\002 changed to \002%s\002."), nc->display.c_str(), tmp_pass.c_str());
- else
- source.Reply(_("Password for \002%s\002 changed."), nc->display.c_str());
+ source.Reply(_("Password for \002%s\002 changed."), nc->display.c_str());
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -275,12 +276,12 @@ class CommandNSSetAutoOp : public Command
this->OnSyntaxError(source, "AUTOOP");
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
this->Run(source, source.nc->display, params[0]);
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
BotInfo *bi = Config->GetClient("ChanServ");
this->SendSyntax(source);
@@ -302,12 +303,12 @@ class CommandNSSASetAutoOp : public CommandNSSetAutoOp
this->SetSyntax(_("\037nickname\037 {ON | OFF}"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
this->Run(source, params[0], params[1]);
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
BotInfo *bi = Config->GetClient("ChanServ");
this->SendSyntax(source);
@@ -375,12 +376,12 @@ class CommandNSSetDisplay : public Command
source.Reply(NICK_SET_DISPLAY_CHANGED, user_na->nc->display.c_str());
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
this->Run(source, source.nc->display, params[0]);
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -399,12 +400,12 @@ class CommandNSSASetDisplay : public CommandNSSetDisplay
this->SetSyntax(_("\037nickname\037 \037new-display\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
this->Run(source, params[0], params[1]);
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -521,12 +522,12 @@ class CommandNSSetEmail : public Command
}
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
this->Run(source, source.nc->display, params.size() ? params[0] : "");
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -546,12 +547,12 @@ class CommandNSSASetEmail : public CommandNSSetEmail
this->SetSyntax(_("\037nickname\037 \037address\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
this->Run(source, params[0], params.size() > 1 ? params[1] : "");
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -606,12 +607,12 @@ class CommandNSSetKeepModes : public Command
this->OnSyntaxError(source, "");
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
this->Run(source, source.nc->display, params[0]);
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -631,12 +632,12 @@ class CommandNSSASetKeepModes : public CommandNSSetKeepModes
this->SetSyntax(_("\037nickname\037 {ON | OFF}"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
this->Run(source, params[0], params[1]);
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -726,12 +727,12 @@ class CommandNSSetKill : public Command
return;
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
this->Run(source, source.nc->display, params[0]);
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -760,12 +761,12 @@ class CommandNSSASetKill : public CommandNSSetKill
this->SetSyntax(_("\037nickname\037 {ON | QUICK | IMMED | OFF}"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
this->Run(source, params[0], params[1]);
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -790,7 +791,7 @@ class CommandNSSetLanguage : public Command
public:
CommandNSSetLanguage(Module *creator, const Anope::string &sname = "nickserv/set/language", size_t min = 1) : Command(creator, sname, min, min + 1)
{
- this->SetDesc(_("Set the language Services will use when messaging you"));
+ this->SetDesc(_("Set the language services will use when messaging you"));
this->SetSyntax(_("\037language\037"));
}
@@ -836,27 +837,27 @@ class CommandNSSetLanguage : public Command
source.Reply(_("Language for \002%s\002 changed to \002%s\002."), nc->display.c_str(), Language::Translate(param.c_str(), _("English")));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &param) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &param) override
{
this->Run(source, source.nc->display, param[0]);
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
- source.Reply(_("Changes the language Services uses when sending messages to\n"
+ source.Reply(_("Changes the language services uses when sending messages to\n"
"you (for example, when responding to a command you send).\n"
"\037language\037 should be chosen from the following list of\n"
"supported languages:"));
source.Reply(" en_US (English)");
- for (unsigned j = 0; j < Language::Languages.size(); ++j)
+ for (const auto &language : Language::Languages)
{
- const Anope::string &langname = Language::Translate(Language::Languages[j].c_str(), _("English"));
+ const Anope::string &langname = Language::Translate(language.c_str(), _("English"));
if (langname == "English")
continue;
- source.Reply(" %s (%s)", Language::Languages[j].c_str(), langname.c_str());
+ source.Reply(" %s (%s)", language.c_str(), langname.c_str());
}
return true;
@@ -872,26 +873,26 @@ class CommandNSSASetLanguage : public CommandNSSetLanguage
this->SetSyntax(_("\037nickname\037 \037language\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
this->Run(source, params[0], params[1]);
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
- source.Reply(_("Changes the language Services uses when sending messages to\n"
+ source.Reply(_("Changes the language services uses when sending messages to\n"
"the given user (for example, when responding to a command they send).\n"
"\037language\037 should be chosen from the following list of\n"
"supported languages:"));
source.Reply(" en (English)");
- for (unsigned j = 0; j < Language::Languages.size(); ++j)
+ for (const auto &language : Language::Languages)
{
- const Anope::string &langname = Language::Translate(Language::Languages[j].c_str(), _("English"));
+ const Anope::string &langname = Language::Translate(language.c_str(), _("English"));
if (langname == "English")
continue;
- source.Reply(" %s (%s)", Language::Languages[j].c_str(), langname.c_str());
+ source.Reply(" %s (%s)", language.c_str(), langname.c_str());
}
return true;
}
@@ -902,7 +903,7 @@ class CommandNSSetMessage : public Command
public:
CommandNSSetMessage(Module *creator, const Anope::string &sname = "nickserv/set/message", size_t min = 1) : Command(creator, sname, min, min + 1)
{
- this->SetDesc(_("Change the communication method of Services"));
+ this->SetDesc(_("Change the communication method of services"));
this->SetSyntax("{ON | OFF}");
}
@@ -949,12 +950,12 @@ class CommandNSSetMessage : public Command
this->OnSyntaxError(source, "MSG");
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
this->Run(source, source.nc->display, params[0]);
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
Anope::string cmd = source.command;
size_t i = cmd.find_last_of(' ');
@@ -963,13 +964,13 @@ class CommandNSSetMessage : public Command
this->SendSyntax(source);
source.Reply(" ");
- source.Reply(_("Allows you to choose the way Services are communicating with\n"
- "you. With \002%s\002 set, Services will use messages, else they'll\n"
+ source.Reply(_("Allows you to choose the way services are communicating with\n"
+ "you. With \002%s\002 set, services will use messages, else they'll\n"
"use notices."), cmd.upper().c_str());
return true;
}
- void OnServHelp(CommandSource &source) anope_override
+ void OnServHelp(CommandSource &source) override
{
if (Config->GetBlock("options")->Get<bool>("useprivmsg"))
Command::OnServHelp(source);
@@ -985,17 +986,17 @@ class CommandNSSASetMessage : public CommandNSSetMessage
this->SetSyntax(_("\037nickname\037 {ON | OFF}"));
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
- source.Reply(_("Allows you to choose the way Services are communicating with\n"
- "the given user. With \002MSG\002 set, Services will use messages,\n"
+ source.Reply(_("Allows you to choose the way services are communicating with\n"
+ "the given user. With \002MSG\002 set, services will use messages,\n"
"else they'll use notices."));
return true;
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
this->Run(source, params[0], params[1]);
}
@@ -1047,12 +1048,12 @@ class CommandNSSetSecure : public Command
this->OnSyntaxError(source, "SECURE");
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
this->Run(source, source.nc->display, params[0]);
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -1076,12 +1077,12 @@ class CommandNSSASetSecure : public CommandNSSetSecure
this->SetSyntax(_("\037nickname\037 {ON | OFF}"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
this->Run(source, params[0], params[1]);
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -1105,7 +1106,7 @@ class CommandNSSASetNoexpire : public Command
this->SetSyntax(_("\037nickname\037 {ON | OFF}"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (Anope::ReadOnly)
{
@@ -1138,7 +1139,7 @@ class CommandNSSASetNoexpire : public Command
this->OnSyntaxError(source, "NOEXPIRE");
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -1189,7 +1190,7 @@ class NSSet : public Module
{
KeepModes(Module *m, const Anope::string &n) : SerializableExtensibleItem<bool>(m, n) { }
- void ExtensibleSerialize(const Extensible *e, const Serializable *s, Serialize::Data &data) const anope_override
+ void ExtensibleSerialize(const Extensible *e, const Serializable *s, Serialize::Data &data) const override
{
SerializableExtensibleItem<bool>::ExtensibleSerialize(e, s, data);
@@ -1198,18 +1199,18 @@ class NSSet : public Module
const NickCore *nc = anope_dynamic_static_cast<const NickCore *>(s);
Anope::string modes;
- for (User::ModeList::const_iterator it = nc->last_modes.begin(); it != nc->last_modes.end(); ++it)
+ for (const auto &[last_mode, last_value] : nc->last_modes)
{
if (!modes.empty())
modes += " ";
- modes += it->first;
- if (!it->second.empty())
- modes += "," + it->second;
+ modes += last_mode;
+ if (!last_value.empty())
+ modes += "," + last_value;
}
data["last_modes"] << modes;
}
- void ExtensibleUnserialize(Extensible *e, Serializable *s, Serialize::Data &data) anope_override
+ void ExtensibleUnserialize(Extensible *e, Serializable *s, Serialize::Data &data) override
{
SerializableExtensibleItem<bool>::ExtensibleUnserialize(e, s, data);
@@ -1224,9 +1225,9 @@ class NSSet : public Module
{
size_t c = modes.find(',');
if (c == Anope::string::npos)
- nc->last_modes.insert(std::make_pair(modes, ""));
+ nc->last_modes.emplace(modes, "");
else
- nc->last_modes.insert(std::make_pair(modes.substr(0, c), modes.substr(c + 1)));
+ nc->last_modes.emplace(modes.substr(0, c), modes.substr(c + 1));
}
}
} keep_modes;
@@ -1258,7 +1259,7 @@ class NSSet : public Module
}
- EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> &params) anope_override
+ EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> &params) override
{
NickCore *uac = source.nc;
@@ -1281,7 +1282,7 @@ class NSSet : public Module
return EVENT_CONTINUE;
}
- void OnSetCorrectModes(User *user, Channel *chan, AccessGroup &access, bool &give_modes, bool &take_modes) anope_override
+ void OnSetCorrectModes(User *user, Channel *chan, AccessGroup &access, bool &give_modes, bool &take_modes) override
{
if (chan->ci)
{
@@ -1290,13 +1291,13 @@ class NSSet : public Module
}
}
- void OnPreNickExpire(NickAlias *na, bool &expire) anope_override
+ void OnPreNickExpire(NickAlias *na, bool &expire) override
{
if (noexpire.HasExt(na))
expire = false;
}
- void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_hidden) anope_override
+ void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_hidden) override
{
if (!show_hidden)
return;
@@ -1319,29 +1320,28 @@ class NSSet : public Module
info.AddOption(_("Keep modes"));
}
- void OnUserModeSet(const MessageSource &setter, User *u, const Anope::string &mname) anope_override
+ void OnUserModeSet(const MessageSource &setter, User *u, const Anope::string &mname) override
{
if (u->Account() && setter.GetUser() == u)
u->Account()->last_modes = u->GetModeList();
}
- void OnUserModeUnset(const MessageSource &setter, User *u, const Anope::string &mname) anope_override
+ void OnUserModeUnset(const MessageSource &setter, User *u, const Anope::string &mname) override
{
if (u->Account() && setter.GetUser() == u)
u->Account()->last_modes = u->GetModeList();
}
- void OnUserLogin(User *u) anope_override
+ void OnUserLogin(User *u) override
{
if (keep_modes.HasExt(u->Account()))
{
- User::ModeList modes = u->Account()->last_modes;
- for (User::ModeList::iterator it = modes.begin(); it != modes.end(); ++it)
+ for (const auto &[last_mode, last_value] : u->Account()->last_modes)
{
- UserMode *um = ModeManager::FindUserModeByName(it->first);
+ UserMode *um = ModeManager::FindUserModeByName(last_mode);
/* if the null user can set the mode, then it's probably safe */
if (um && um->CanSet(NULL))
- u->SetMode(NULL, it->first, it->second);
+ u->SetMode(NULL, last_mode, last_value);
}
}
}
diff --git a/modules/commands/ns_set_misc.cpp b/modules/commands/ns_set_misc.cpp
index b8f098443..be2804f04 100644
--- a/modules/commands/ns_set_misc.cpp
+++ b/modules/commands/ns_set_misc.cpp
@@ -42,7 +42,7 @@ struct NSMiscData : MiscData, Serializable
data = d;
}
- void Serialize(Serialize::Data &sdata) const anope_override
+ void Serialize(Serialize::Data &sdata) const override
{
sdata["nc"] << this->object;
sdata["name"] << this->name;
@@ -135,12 +135,12 @@ class CommandNSSetMisc : public Command
}
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
this->Run(source, source.nc->display, !params.empty() ? params[0] : "");
}
- void OnServHelp(CommandSource &source) anope_override
+ void OnServHelp(CommandSource &source) override
{
if (descriptions.count(source.command))
{
@@ -149,7 +149,7 @@ class CommandNSSetMisc : public Command
}
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
if (descriptions.count(source.command))
{
@@ -170,7 +170,7 @@ class CommandNSSASetMisc : public CommandNSSetMisc
this->SetSyntax(_("\037nickname\037 [\037parameter\037]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
this->Run(source, params[0], params.size() > 1 ? params[1] : "");
}
@@ -189,13 +189,13 @@ class NSSetMisc : public Module
me = this;
}
- ~NSSetMisc()
+ ~NSSetMisc() override
{
- for (Anope::map<ExtensibleItem<NSMiscData> *>::iterator it = items.begin(); it != items.end(); ++it)
- delete it->second;
+ for (const auto &[_, data] : items)
+ delete data;
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
descriptions.clear();
@@ -218,11 +218,10 @@ class NSSetMisc : public Module
}
}
- void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool) anope_override
+ void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool) override
{
- for (Anope::map<ExtensibleItem<NSMiscData> *>::iterator it = items.begin(); it != items.end(); ++it)
+ for (const auto &[_, e] : items)
{
- ExtensibleItem<NSMiscData> *e = it->second;
NSMiscData *data = e->Get(na->nc);
if (data != NULL)
diff --git a/modules/commands/ns_status.cpp b/modules/commands/ns_status.cpp
index a1041be28..017da171d 100644
--- a/modules/commands/ns_status.cpp
+++ b/modules/commands/ns_status.cpp
@@ -21,7 +21,7 @@ class CommandNSStatus : public Command
this->AllowUnregistered(true);
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &nick = !params.empty() ? params[0] : source.GetNick();
const NickAlias *na = NickAlias::Find(nick);
@@ -48,7 +48,7 @@ class CommandNSStatus : public Command
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/ns_suspend.cpp b/modules/commands/ns_suspend.cpp
index 8db57e532..28ca99b68 100644
--- a/modules/commands/ns_suspend.cpp
+++ b/modules/commands/ns_suspend.cpp
@@ -18,7 +18,7 @@ struct NSSuspendInfo : SuspendInfo, Serializable
{
NSSuspendInfo(Extensible *) : Serializable("NSSuspendInfo") { }
- void Serialize(Serialize::Data &data) const anope_override
+ void Serialize(Serialize::Data &data) const override
{
data["nick"] << what;
data["by"] << by;
@@ -61,7 +61,7 @@ class CommandNSSuspend : public Command
this->SetSyntax(_("\037nickname\037 [+\037expiry\037] [\037reason\037]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &nick = params[0];
@@ -116,10 +116,8 @@ class CommandNSSuspend : public Command
si->when = Anope::CurTime;
si->expires = expiry_secs ? expiry_secs + Anope::CurTime : 0;
- for (unsigned i = 0; i < nc->aliases->size(); ++i)
+ for (auto *na2 : *nc->aliases)
{
- NickAlias *na2 = nc->aliases->at(i);
-
if (na2 && *na2->nc == *na->nc)
{
na2->last_quit = reason;
@@ -140,7 +138,7 @@ class CommandNSSuspend : public Command
FOREACH_MOD(OnNickSuspend, (na));
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -161,7 +159,7 @@ class CommandNSUnSuspend : public Command
this->SetSyntax(_("\037nickname\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &nick = params[0];
@@ -192,7 +190,7 @@ class CommandNSUnSuspend : public Command
FOREACH_MOD(OnNickUnsuspended, (na));
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -229,14 +227,14 @@ class NSSuspend : public Module
{
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
Anope::string s = conf->GetModule(this)->Get<Anope::string>("show");
commasepstream(s).GetTokens(show);
std::transform(show.begin(), show.end(), show.begin(), trim());
}
- void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_hidden) anope_override
+ void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_hidden) override
{
NSSuspendInfo *s = suspend.Get(na->nc);
if (!s)
@@ -254,7 +252,7 @@ class NSSuspend : public Module
info[_("Suspension expires")] = Anope::strftime(s->expires, source.GetAccount());
}
- void OnPreNickExpire(NickAlias *na, bool &expire) anope_override
+ void OnPreNickExpire(NickAlias *na, bool &expire) override
{
NSSuspendInfo *s = suspend.Get(na->nc);
if (!s)
@@ -274,7 +272,7 @@ class NSSuspend : public Module
}
}
- EventReturn OnNickValidate(User *u, NickAlias *na) anope_override
+ EventReturn OnNickValidate(User *u, NickAlias *na) override
{
NSSuspendInfo *s = suspend.Get(na->nc);
if (!s)
diff --git a/modules/commands/ns_update.cpp b/modules/commands/ns_update.cpp
index 86a862a2a..0d6a1f4c0 100644
--- a/modules/commands/ns_update.cpp
+++ b/modules/commands/ns_update.cpp
@@ -20,7 +20,7 @@ class CommandNSUpdate : public Command
this->RequireUser(true);
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
User *u = source.GetUser();
NickAlias *na = NickAlias::Find(u->nick);
@@ -36,7 +36,7 @@ class CommandNSUpdate : public Command
source.Reply(_("Status updated (memos, vhost, chmodes, flags)."));
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/os_akill.cpp b/modules/commands/os_akill.cpp
index 899c2410e..31f96b507 100644
--- a/modules/commands/os_akill.cpp
+++ b/modules/commands/os_akill.cpp
@@ -16,14 +16,14 @@ static ServiceReference<XLineManager> akills("XLineManager", "xlinemanager/sglin
class AkillDelCallback : public NumberList
{
CommandSource &source;
- unsigned deleted;
+ unsigned deleted = 0;
Command *cmd;
public:
- AkillDelCallback(CommandSource &_source, const Anope::string &numlist, Command *c) : NumberList(numlist, true), source(_source), deleted(0), cmd(c)
+ AkillDelCallback(CommandSource &_source, const Anope::string &numlist, Command *c) : NumberList(numlist, true), source(_source), cmd(c)
{
}
- ~AkillDelCallback()
+ ~AkillDelCallback() override
{
if (!deleted)
source.Reply(_("No matching entries on the AKILL list."));
@@ -33,7 +33,7 @@ class AkillDelCallback : public NumberList
source.Reply(_("Deleted %d entries from the AKILL list."), deleted);
}
- void HandleNumber(unsigned number) anope_override
+ void HandleNumber(unsigned number) override
{
if (!number)
return;
@@ -172,8 +172,8 @@ class CommandOSAKill : public Command
x->id = XLineManager::GenerateUID();
unsigned int affected = 0;
- for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
- if (akills->Check(it->second, x))
+ for (const auto &[_, user] : UserListByNick)
+ if (akills->Check(user, x))
++affected;
float percent = static_cast<float>(affected) / static_cast<float>(UserListByNick.size()) * 100.0;
@@ -271,7 +271,7 @@ class CommandOSAKill : public Command
{
}
- void HandleNumber(unsigned number) anope_override
+ void HandleNumber(unsigned number) override
{
if (!number)
return;
@@ -325,8 +325,8 @@ class CommandOSAKill : public Command
std::vector<Anope::string> replies;
list.Process(replies);
- for (unsigned i = 0; i < replies.size(); ++i)
- source.Reply(replies[i]);
+ for (const auto &reply : replies)
+ source.Reply(reply);
source.Reply(_("End of AKILL list."));
}
@@ -390,7 +390,7 @@ class CommandOSAKill : public Command
this->SetSyntax("CLEAR");
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &cmd = params[0];
@@ -413,7 +413,7 @@ class CommandOSAKill : public Command
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/os_chankill.cpp b/modules/commands/os_chankill.cpp
index e53f17629..a22eae178 100644
--- a/modules/commands/os_chankill.cpp
+++ b/modules/commands/os_chankill.cpp
@@ -22,7 +22,7 @@ class CommandOSChanKill : public Command
this->SetSyntax(_("[+\037expiry\037] \037channel\037 \037reason\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (!akills)
return;
@@ -69,10 +69,8 @@ class CommandOSChanKill : public Command
if ((c = Channel::Find(channel)))
{
- for (Channel::ChanUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it)
+ for (const auto &[_, uc] : c->users)
{
- ChanUserContainer *uc = it->second;
-
if (uc->user->server == Me || uc->user->HasMode("OPER"))
continue;
@@ -93,7 +91,7 @@ class CommandOSChanKill : public Command
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/os_config.cpp b/modules/commands/os_config.cpp
index d54730462..3f211d695 100644
--- a/modules/commands/os_config.cpp
+++ b/modules/commands/os_config.cpp
@@ -20,7 +20,7 @@ class CommandOSConfig : public Command
this->SetSyntax(_("{\037MODIFY\037|\037VIEW\037} [\037block name\037 \037item name\037 \037item value\037]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &what = params[0];
@@ -57,19 +57,16 @@ class CommandOSConfig : public Command
for (unsigned i = 0; !show_blocks[i].empty(); ++i)
{
Configuration::Block *block = Config->GetBlock(show_blocks[i]);
- const Configuration::Block::item_map *items = block->GetItems();
-
- if (!items)
- continue;
+ const Configuration::Block::item_map &items = block->GetItems();
ListFormatter lflist(source.GetAccount());
lflist.AddColumn(_("Name")).AddColumn(_("Value"));
- for (Configuration::Block::item_map::const_iterator it = items->begin(), it_end = items->end(); it != it_end; ++it)
+ for (const auto &[name, value] : items)
{
ListFormatter::ListEntry entry;
- entry["Name"] = it->first;
- entry["Value"] = it->second;
+ entry["Name"] = name;
+ entry["Value"] = value;
lflist.AddEntry(entry);
}
@@ -78,8 +75,8 @@ class CommandOSConfig : public Command
source.Reply(_("%s settings:"), block->GetName().c_str());
- for (unsigned j = 0; j < replies.size(); ++j)
- source.Reply(replies[j]);
+ for (const auto &reply : replies)
+ source.Reply(reply);
source.Reply(" ");
}
@@ -90,18 +87,18 @@ class CommandOSConfig : public Command
for (int i = 0; i < Config->CountBlock("module"); ++i)
{
Configuration::Block *block = Config->GetBlock("module", i);
- const Configuration::Block::item_map *items = block->GetItems();
+ const Configuration::Block::item_map &items = block->GetItems();
- if (!items || items->size() <= 1)
+ if (items.size() <= 1)
continue;
ListFormatter::ListEntry entry;
entry["Module Name"] = block->Get<Anope::string>("name");
- for (Configuration::Block::item_map::const_iterator it = items->begin(), it_end = items->end(); it != it_end; ++it)
+ for (const auto &[name, value] : items)
{
- entry["Name"] = it->first;
- entry["Value"] = it->second;
+ entry["Name"] = name;
+ entry["Value"] = value;
lflist.AddEntry(entry);
}
}
@@ -111,8 +108,8 @@ class CommandOSConfig : public Command
source.Reply(_("Module settings:"));
- for (unsigned j = 0; j < replies.size(); ++j)
- source.Reply(replies[j]);
+ for (const auto &reply : replies)
+ source.Reply(reply);
source.Reply(_("End of configuration."));
}
@@ -120,7 +117,7 @@ class CommandOSConfig : public Command
this->OnSyntaxError(source, what);
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/os_defcon.cpp b/modules/commands/os_defcon.cpp
index 7b89e6957..8a93a7f7b 100644
--- a/modules/commands/os_defcon.cpp
+++ b/modules/commands/os_defcon.cpp
@@ -72,7 +72,7 @@ struct DefconConfig
bool SetDefConParam(const Anope::string &name, const Anope::string &buf)
{
- return DefConModesOnParams.insert(std::make_pair(name, buf)).second;
+ return DefConModesOnParams.emplace(name, buf).second;
}
void UnsetDefConParam(const Anope::string &name)
@@ -115,12 +115,12 @@ class DefConTimeout : public Timer
timeout = this;
}
- ~DefConTimeout()
+ ~DefConTimeout() override
{
timeout = NULL;
}
- void Tick(time_t) anope_override
+ void Tick(time_t) override
{
if (DConfig.defaultlevel != level)
{
@@ -177,7 +177,7 @@ class CommandOSDefcon : public Command
this->SetSyntax(_("[\0021\002|\0022\002|\0023\002|\0024\002|\0025\002]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &lvl = params[0];
@@ -233,7 +233,7 @@ class CommandOSDefcon : public Command
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -253,7 +253,6 @@ class OSDefcon : public Module
void ParseModeString()
{
int add = -1; /* 1 if adding, 0 if deleting, -1 if neither */
- unsigned char mode;
ChannelMode *cm;
ChannelModeParam *cmp;
Anope::string modes, param;
@@ -265,10 +264,8 @@ class OSDefcon : public Module
ss.GetToken(modes);
/* Loop while there are modes to set */
- for (unsigned i = 0, end = modes.length(); i < end; ++i)
+ for (auto mode : modes)
{
- mode = modes[i];
-
switch (mode)
{
case '+':
@@ -335,7 +332,7 @@ class OSDefcon : public Module
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
Configuration::Block *block = conf->GetModule(this);
DefconConfig dconfig;
@@ -406,7 +403,7 @@ class OSDefcon : public Module
this->ParseModeString();
}
- EventReturn OnChannelModeSet(Channel *c, MessageSource &source, ChannelMode *mode, const Anope::string &param) anope_override
+ EventReturn OnChannelModeSet(Channel *c, MessageSource &source, ChannelMode *mode, const Anope::string &param) override
{
if (DConfig.Check(DEFCON_FORCE_CHAN_MODES) && DConfig.DefConModesOff.count(mode->name) && source.GetUser() && !source.GetBot())
{
@@ -418,7 +415,7 @@ class OSDefcon : public Module
return EVENT_CONTINUE;
}
- EventReturn OnChannelModeUnset(Channel *c, MessageSource &source, ChannelMode *mode, const Anope::string &) anope_override
+ EventReturn OnChannelModeUnset(Channel *c, MessageSource &source, ChannelMode *mode, const Anope::string &) override
{
if (DConfig.Check(DEFCON_FORCE_CHAN_MODES) && DConfig.DefConModesOn.count(mode->name) && source.GetUser() && !source.GetBot())
{
@@ -436,7 +433,7 @@ class OSDefcon : public Module
return EVENT_CONTINUE;
}
- EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> &params) anope_override
+ EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> &params) override
{
if (DConfig.Check(DEFCON_OPER_ONLY) && !source.IsOper())
{
@@ -483,7 +480,7 @@ class OSDefcon : public Module
return EVENT_CONTINUE;
}
- void OnUserConnect(User *u, bool &exempt) anope_override
+ void OnUserConnect(User *u, bool &exempt) override
{
if (exempt || u->Quitting() || !u->server->IsSynced() || u->server->IsULined())
return;
@@ -535,13 +532,13 @@ class OSDefcon : public Module
}
}
- void OnChannelModeAdd(ChannelMode *cm) anope_override
+ void OnChannelModeAdd(ChannelMode *cm) override
{
if (DConfig.chanmodes.find(cm->mchar) != Anope::string::npos)
this->ParseModeString();
}
- void OnChannelSync(Channel *c) anope_override
+ void OnChannelSync(Channel *c) override
{
if (DConfig.Check(DEFCON_FORCE_CHAN_MODES))
c->SetModes(Config->GetClient("OperServ"), false, "%s", DConfig.chanmodes.c_str());
@@ -559,8 +556,8 @@ static void runDefCon()
{
Log(OperServ, "operserv/defcon") << "DEFCON: setting " << DConfig.chanmodes << " on all channels";
DefConModesSet = true;
- for (channel_map::const_iterator it = ChannelList.begin(), it_end = ChannelList.end(); it != it_end; ++it)
- it->second->SetModes(OperServ, false, "%s", DConfig.chanmodes.c_str());
+ for (const auto &[_, chan] : ChannelList)
+ chan->SetModes(OperServ, false, "%s", DConfig.chanmodes.c_str());
}
}
}
@@ -575,8 +572,8 @@ static void runDefCon()
if (!newmodes.empty())
{
Log(OperServ, "operserv/defcon") << "DEFCON: setting " << newmodes << " on all channels";
- for (channel_map::const_iterator it = ChannelList.begin(), it_end = ChannelList.end(); it != it_end; ++it)
- it->second->SetModes(OperServ, true, "%s", newmodes.c_str());
+ for (const auto &[_, chan] : ChannelList)
+ chan->SetModes(OperServ, true, "%s", newmodes.c_str());
}
}
}
@@ -588,14 +585,14 @@ static Anope::string defconReverseModes(const Anope::string &modes)
if (modes.empty())
return "";
Anope::string newmodes;
- for (unsigned i = 0, end = modes.length(); i < end; ++i)
+ for (auto mode : modes)
{
- if (modes[i] == '+')
+ if (mode == '+')
newmodes += '-';
- else if (modes[i] == '-')
+ else if (mode == '-')
newmodes += '+';
else
- newmodes += modes[i];
+ newmodes += mode;
}
return newmodes;
}
diff --git a/modules/commands/os_dns.cpp b/modules/commands/os_dns.cpp
index b01690577..c297ec062 100644
--- a/modules/commands/os_dns.cpp
+++ b/modules/commands/os_dns.cpp
@@ -29,19 +29,19 @@ struct DNSZone : Serializable
zones->push_back(this);
}
- ~DNSZone()
+ ~DNSZone() override
{
std::vector<DNSZone *>::iterator it = std::find(zones->begin(), zones->end(), this);
if (it != zones->end())
zones->erase(it);
}
- void Serialize(Serialize::Data &data) const anope_override
+ void Serialize(Serialize::Data &data) const override
{
data["name"] << name;
unsigned count = 0;
- for (std::set<Anope::string, ci::less>::iterator it = servers.begin(), it_end = servers.end(); it != it_end; ++it)
- data["server" + stringify(count++)] << *it;
+ for (const auto &server : servers)
+ data["server" + stringify(count++)] << server;
}
static Serializable* Unserialize(Serializable *obj, Serialize::Data &data)
@@ -74,13 +74,14 @@ struct DNSZone : Serializable
static DNSZone *Find(const Anope::string &name)
{
- for (unsigned i = 0; i < zones->size(); ++i)
- if (zones->at(i)->name.equals_ci(name))
+ for (auto *zone : *zones)
+ {
+ if (zone->name.equals_ci(name))
{
- DNSZone *z = zones->at(i);
- z->QueueUpdate();
- return z;
+ zone->QueueUpdate();
+ return zone;
}
+ }
return NULL;
}
};
@@ -89,22 +90,22 @@ class DNSServer : public Serializable
{
Anope::string server_name;
std::vector<Anope::string> ips;
- unsigned limit;
+ unsigned limit = 0;
/* wants to be in the pool */
- bool pooled;
+ bool pooled = false;
/* is actually in the pool */
- bool active;
+ bool active = false;
public:
std::set<Anope::string, ci::less> zones;
- time_t repool;
+ time_t repool = 0;
- DNSServer(const Anope::string &sn) : Serializable("DNSServer"), server_name(sn), limit(0), pooled(false), active(false), repool(0)
+ DNSServer(const Anope::string &sn) : Serializable("DNSServer"), server_name(sn)
{
dns_servers->push_back(this);
}
- ~DNSServer()
+ ~DNSServer() override
{
std::vector<DNSServer *>::iterator it = std::find(dns_servers->begin(), dns_servers->end(), this);
if (it != dns_servers->end())
@@ -134,12 +135,12 @@ class DNSServer : public Serializable
if (dnsmanager)
{
dnsmanager->UpdateSerial();
- for (std::set<Anope::string, ci::less>::iterator it = zones.begin(), it_end = zones.end(); it != it_end; ++it)
- dnsmanager->Notify(*it);
+ for (const auto &zone : zones)
+ dnsmanager->Notify(zone);
}
}
- void Serialize(Serialize::Data &data) const anope_override
+ void Serialize(Serialize::Data &data) const override
{
data["server_name"] << server_name;
for (unsigned i = 0; i < ips.size(); ++i)
@@ -147,8 +148,8 @@ class DNSServer : public Serializable
data["limit"] << limit;
data["pooled"] << pooled;
unsigned count = 0;
- for (std::set<Anope::string, ci::less>::iterator it = zones.begin(), it_end = zones.end(); it != it_end; ++it)
- data["zone" + stringify(count++)] << *it;
+ for (const auto &zone : zones)
+ data["zone" + stringify(count++)] << zone;
}
static Serializable* Unserialize(Serializable *obj, Serialize::Data &data)
@@ -193,10 +194,9 @@ class DNSServer : public Serializable
static DNSServer *Find(const Anope::string &s)
{
- for (unsigned i = 0; i < dns_servers->size(); ++i)
- if (dns_servers->at(i)->GetName().equals_ci(s))
+ for (auto *serv : *dns_servers)
+ if (serv->GetName().equals_ci(s))
{
- DNSServer *serv = dns_servers->at(i);
serv->QueueUpdate();
return serv;
}
@@ -216,9 +216,8 @@ class CommandOSDNS : public Command
ListFormatter lf(source.GetAccount());
lf.AddColumn(_("Server")).AddColumn(_("IP")).AddColumn(_("Limit")).AddColumn(_("State"));
- for (unsigned i = 0; i < dns_servers->size(); ++i)
+ for (auto *s : *dns_servers)
{
- DNSServer *s = dns_servers->at(i);
Server *srv = Server::Find(s->GetName(), true);
ListFormatter::ListEntry entry;
@@ -226,8 +225,8 @@ class CommandOSDNS : public Command
entry["Limit"] = s->GetLimit() ? stringify(s->GetLimit()) : Language::Translate(source.GetAccount(), _("None"));
Anope::string ip_str;
- for (unsigned j = 0; j < s->GetIPs().size(); ++j)
- ip_str += s->GetIPs()[j] + " ";
+ for (const auto &ip : s->GetIPs())
+ ip_str += ip + " ";
ip_str.trim();
if (ip_str.empty())
ip_str = "None";
@@ -254,16 +253,14 @@ class CommandOSDNS : public Command
ListFormatter lf2(source.GetAccount());
lf2.AddColumn(_("Zone")).AddColumn(_("Servers"));
- for (unsigned i = 0; i < zones->size(); ++i)
+ for (auto *z : *zones)
{
- const DNSZone *z = zones->at(i);
-
ListFormatter::ListEntry entry;
entry["Zone"] = z->name;
Anope::string server_str;
- for (std::set<Anope::string, ci::less>::iterator it = z->servers.begin(), it_end = z->servers.end(); it != it_end; ++it)
- server_str += *it + " ";
+ for (const auto &server : z->servers)
+ server_str += server + " ";
server_str.trim();
if (server_str.empty())
@@ -277,8 +274,8 @@ class CommandOSDNS : public Command
lf2.Process(replies);
}
- for (unsigned i = 0; i < replies.size(); ++i)
- source.Reply(replies[i]);
+ for (const auto &reply : replies)
+ source.Reply(reply);
}
void AddZone(CommandSource &source, const std::vector<Anope::string> &params)
@@ -316,9 +313,9 @@ class CommandOSDNS : public Command
Log(LOG_ADMIN, source, this) << "to delete zone " << z->name;
- for (std::set<Anope::string, ci::less>::iterator it = z->servers.begin(), it_end = z->servers.end(); it != it_end; ++it)
+ for (const auto &server : z->servers)
{
- DNSServer *s = DNSServer::Find(*it);
+ DNSServer *s = DNSServer::Find(server);
if (s)
s->zones.erase(z->name);
}
@@ -466,9 +463,9 @@ class CommandOSDNS : public Command
return;
}
- for (std::set<Anope::string, ci::less>::iterator it = s->zones.begin(), it_end = s->zones.end(); it != it_end; ++it)
+ for (const auto &zone : s->zones)
{
- DNSZone *z = DNSZone::Find(*it);
+ DNSZone *z = DNSZone::Find(zone);
if (z)
z->servers.erase(s->GetName());
}
@@ -494,12 +491,14 @@ class CommandOSDNS : public Command
return;
}
- for (unsigned i = 0; i < s->GetIPs().size(); ++i)
- if (params[2].equals_ci(s->GetIPs()[i]))
+ for (const auto &ip : s->GetIPs())
+ {
+ if (params[2].equals_ci(ip))
{
- source.Reply(_("IP %s already exists for %s."), s->GetIPs()[i].c_str(), s->GetName().c_str());
+ source.Reply(_("IP %s already exists for %s."), ip.c_str(), s->GetName().c_str());
return;
}
+ }
sockaddrs addr(params[2]);
if (!addr.valid())
@@ -518,8 +517,8 @@ class CommandOSDNS : public Command
if (s->Active() && dnsmanager)
{
dnsmanager->UpdateSerial();
- for (std::set<Anope::string, ci::less>::iterator it = s->zones.begin(), it_end = s->zones.end(); it != it_end; ++it)
- dnsmanager->Notify(*it);
+ for (const auto &zone : s->zones)
+ dnsmanager->Notify(zone);
}
}
@@ -552,8 +551,8 @@ class CommandOSDNS : public Command
if (s->Active() && dnsmanager)
{
dnsmanager->UpdateSerial();
- for (std::set<Anope::string, ci::less>::iterator it = s->zones.begin(), it_end = s->zones.end(); it != it_end; ++it)
- dnsmanager->Notify(*it);
+ for (const auto &zone : s->zones)
+ dnsmanager->Notify(zone);
}
return;
@@ -669,7 +668,7 @@ class CommandOSDNS : public Command
this->SetSyntax(_("DEPOOL \037server.name\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (params.empty())
this->DisplayPoolState(source);
@@ -695,7 +694,7 @@ class CommandOSDNS : public Command
this->OnSyntaxError(source, "");
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -729,24 +728,20 @@ class ModuleDNS : public Module
bool remove_split_servers;
bool readd_connected_servers;
- time_t last_warn;
+ time_t last_warn = 0;
public:
ModuleDNS(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR),
- zone_type("DNSZone", DNSZone::Unserialize), dns_type("DNSServer", DNSServer::Unserialize), commandosdns(this),
- last_warn(0)
+ zone_type("DNSZone", DNSZone::Unserialize), dns_type("DNSServer", DNSServer::Unserialize), commandosdns(this)
{
-
-
- for (unsigned j = 0; j < dns_servers->size(); ++j)
+ for (auto *s : *dns_servers)
{
- DNSServer *s = dns_servers->at(j);
if (s->Pooled() && Server::Find(s->GetName(), true))
s->SetActive(true);
}
}
- ~ModuleDNS()
+ ~ModuleDNS() override
{
for (unsigned i = zones->size(); i > 0; --i)
delete zones->at(i - 1);
@@ -754,7 +749,7 @@ class ModuleDNS : public Module
delete dns_servers->at(i - 1);
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
Configuration::Block *block = conf->GetModule(this);
this->ttl = block->Get<time_t>("ttl");
@@ -765,7 +760,7 @@ class ModuleDNS : public Module
this->readd_connected_servers = block->Get<bool>("readd_connected_servers");
}
- void OnNewServer(Server *s) anope_override
+ void OnNewServer(Server *s) override
{
if (s == Me || s->IsJuped())
return;
@@ -780,7 +775,7 @@ class ModuleDNS : public Module
}
}
- void OnServerQuit(Server *s) anope_override
+ void OnServerQuit(Server *s) override
{
DNSServer *dns = DNSServer::Find(s->GetName());
if (remove_split_servers && dns && dns->Pooled() && dns->Active())
@@ -793,7 +788,7 @@ class ModuleDNS : public Module
}
}
- void OnUserConnect(User *u, bool &exempt) anope_override
+ void OnUserConnect(User *u, bool &exempt) override
{
if (!u->Quitting() && u->server)
{
@@ -807,7 +802,7 @@ class ModuleDNS : public Module
}
}
- void OnPreUserLogoff(User *u) anope_override
+ void OnPreUserLogoff(User *u) override
{
if (u && u->server)
{
@@ -852,7 +847,7 @@ class ModuleDNS : public Module
}
}
- void OnDnsRequest(DNS::Query &req, DNS::Query *packet) anope_override
+ void OnDnsRequest(DNS::Query &req, DNS::Query *packet) override
{
if (req.questions.empty())
return;
@@ -865,21 +860,21 @@ class ModuleDNS : public Module
size_t answer_size = packet->answers.size();
if (zone)
{
- for (std::set<Anope::string, ci::less>::iterator it = zone->servers.begin(), it_end = zone->servers.end(); it != it_end; ++it)
+ for (const auto &server : zone->servers)
{
- DNSServer *s = DNSServer::Find(*it);
+ DNSServer *s = DNSServer::Find(server);
if (!s || !s->Active())
continue;
- for (unsigned j = 0; j < s->GetIPs().size(); ++j)
+ for (const auto &ip : s->GetIPs())
{
- DNS::QueryType q_type = s->GetIPs()[j].find(':') != Anope::string::npos ? DNS::QUERY_AAAA : DNS::QUERY_A;
+ DNS::QueryType q_type = ip.find(':') != Anope::string::npos ? DNS::QUERY_AAAA : DNS::QUERY_A;
if (q.type == DNS::QUERY_AXFR || q.type == DNS::QUERY_ANY || q_type == q.type)
{
DNS::ResourceRecord rr(q.name, q_type);
rr.ttl = this->ttl;
- rr.rdata = s->GetIPs()[j];
+ rr.rdata = ip;
packet->answers.push_back(rr);
}
}
@@ -889,21 +884,20 @@ class ModuleDNS : public Module
if (packet->answers.size() == answer_size)
{
/* Default zone */
- for (unsigned i = 0; i < dns_servers->size(); ++i)
+ for (auto *s : *dns_servers)
{
- DNSServer *s = dns_servers->at(i);
if (!s->Active())
continue;
- for (unsigned j = 0; j < s->GetIPs().size(); ++j)
+ for (const auto &ip : s->GetIPs())
{
- DNS::QueryType q_type = s->GetIPs()[j].find(':') != Anope::string::npos ? DNS::QUERY_AAAA : DNS::QUERY_A;
+ DNS::QueryType q_type = ip.find(':') != Anope::string::npos ? DNS::QUERY_AAAA : DNS::QUERY_A;
if (q.type == DNS::QUERY_AXFR || q.type == DNS::QUERY_ANY || q_type == q.type)
{
DNS::ResourceRecord rr(q.name, q_type);
rr.ttl = this->ttl;
- rr.rdata = s->GetIPs()[j];
+ rr.rdata = ip;
packet->answers.push_back(rr);
}
}
@@ -919,19 +913,17 @@ class ModuleDNS : public Module
}
/* Something messed up, just return them all and hope one is available */
- for (unsigned i = 0; i < dns_servers->size(); ++i)
+ for (auto *s : *dns_servers)
{
- DNSServer *s = dns_servers->at(i);
-
- for (unsigned j = 0; j < s->GetIPs().size(); ++j)
+ for (const auto &ip : s->GetIPs())
{
- DNS::QueryType q_type = s->GetIPs()[j].find(':') != Anope::string::npos ? DNS::QUERY_AAAA : DNS::QUERY_A;
+ DNS::QueryType q_type = ip.find(':') != Anope::string::npos ? DNS::QUERY_AAAA : DNS::QUERY_A;
if (q.type == DNS::QUERY_AXFR || q.type == DNS::QUERY_ANY || q_type == q.type)
{
DNS::ResourceRecord rr(q.name, q_type);
rr.ttl = this->ttl;
- rr.rdata = s->GetIPs()[j];
+ rr.rdata = ip;
packet->answers.push_back(rr);
}
}
diff --git a/modules/commands/os_forbid.cpp b/modules/commands/os_forbid.cpp
index 59cb3da3d..c17a719b7 100644
--- a/modules/commands/os_forbid.cpp
+++ b/modules/commands/os_forbid.cpp
@@ -17,7 +17,7 @@ static ServiceReference<NickServService> nickserv("NickServService", "NickServ")
struct ForbidDataImpl : ForbidData, Serializable
{
ForbidDataImpl() : Serializable("ForbidData") { }
- void Serialize(Serialize::Data &data) const anope_override;
+ void Serialize(Serialize::Data &data) const override;
static Serializable* Unserialize(Serializable *obj, Serialize::Data &data);
};
@@ -68,19 +68,18 @@ class MyForbidService : public ForbidService
public:
MyForbidService(Module *m) : ForbidService(m), forbid_data("ForbidData") { }
- ~MyForbidService()
+ ~MyForbidService() override
{
- std::vector<ForbidData *> f = GetForbids();
- for (unsigned i = 0; i < f.size(); ++i)
- delete f[i];
+ for (const auto *forbid : GetForbids())
+ delete forbid;
}
- void AddForbid(ForbidData *d) anope_override
+ void AddForbid(ForbidData *d) override
{
this->forbids(d->type).push_back(d);
}
- void RemoveForbid(ForbidData *d) anope_override
+ void RemoveForbid(ForbidData *d) override
{
std::vector<ForbidData *>::iterator it = std::find(this->forbids(d->type).begin(), this->forbids(d->type).end(), d);
if (it != this->forbids(d->type).end())
@@ -88,12 +87,12 @@ class MyForbidService : public ForbidService
delete d;
}
- ForbidData *CreateForbid() anope_override
+ ForbidData *CreateForbid() override
{
return new ForbidDataImpl();
}
- ForbidData *FindForbid(const Anope::string &mask, ForbidType ftype) anope_override
+ ForbidData *FindForbid(const Anope::string &mask, ForbidType ftype) override
{
for (unsigned i = this->forbids(ftype).size(); i > 0; --i)
{
@@ -105,7 +104,7 @@ class MyForbidService : public ForbidService
return NULL;
}
- ForbidData *FindForbidExact(const Anope::string &mask, ForbidType ftype) anope_override
+ ForbidData *FindForbidExact(const Anope::string &mask, ForbidType ftype) override
{
for (unsigned i = this->forbids(ftype).size(); i > 0; --i)
{
@@ -117,7 +116,7 @@ class MyForbidService : public ForbidService
return NULL;
}
- std::vector<ForbidData *> GetForbids() anope_override
+ std::vector<ForbidData *> GetForbids() override
{
std::vector<ForbidData *> f;
for (unsigned j = FT_NICK; j < FT_SIZE; ++j)
@@ -159,7 +158,7 @@ class CommandOSForbid : public Command
this->SetSyntax("LIST [NICK|CHAN|EMAIL|REGISTER]");
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (!this->fs)
return;
@@ -245,8 +244,8 @@ class CommandOSForbid : public Command
{
int na_matches = 0;
- for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
- module->OnUserNickChange(it->second, "");
+ for (const auto &[_, user] : UserListByNick)
+ module->OnUserNickChange(user, "");
for (nickalias_map::const_iterator it = NickAliasList->begin(), it_end = NickAliasList->end(); it != it_end;)
{
@@ -358,31 +357,29 @@ class CommandOSForbid : public Command
list.AddColumn(_("Mask")).AddColumn(_("Type")).AddColumn(_("Creator")).AddColumn(_("Expires")).AddColumn(_("Reason"));
unsigned shown = 0;
- for (unsigned i = 0; i < forbids.size(); ++i)
+ for (auto *forbid : forbids)
{
- ForbidData *d = forbids[i];
-
- if (ftype != FT_SIZE && ftype != d->type)
+ if (ftype != FT_SIZE && ftype != forbid->type)
continue;
Anope::string stype;
- if (d->type == FT_NICK)
+ if (forbid->type == FT_NICK)
stype = "NICK";
- else if (d->type == FT_CHAN)
+ else if (forbid->type == FT_CHAN)
stype = "CHAN";
- else if (d->type == FT_EMAIL)
+ else if (forbid->type == FT_EMAIL)
stype = "EMAIL";
- else if (d->type == FT_REGISTER)
+ else if (forbid->type == FT_REGISTER)
stype = "REGISTER";
else
continue;
ListFormatter::ListEntry entry;
- entry["Mask"] = d->mask;
+ entry["Mask"] = forbid->mask;
entry["Type"] = stype;
- entry["Creator"] = d->creator;
- entry["Expires"] = d->expires ? Anope::strftime(d->expires, NULL, true).c_str() : Language::Translate(source.GetAccount(), _("Never"));
- entry["Reason"] = d->reason;
+ entry["Creator"] = forbid->creator;
+ entry["Expires"] = forbid->expires ? Anope::strftime(forbid->expires, NULL, true).c_str() : Language::Translate(source.GetAccount(), _("Never"));
+ entry["Reason"] = forbid->reason;
list.AddEntry(entry);
++shown;
}
@@ -398,8 +395,8 @@ class CommandOSForbid : public Command
std::vector<Anope::string> replies;
list.Process(replies);
- for (unsigned i = 0; i < replies.size(); ++i)
- source.Reply(replies[i]);
+ for (const auto &reply : replies)
+ source.Reply(reply);
if (shown >= forbids.size())
source.Reply(_("End of forbid list."));
@@ -414,7 +411,7 @@ class CommandOSForbid : public Command
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -446,7 +443,7 @@ class OSForbid : public Module
}
- void OnUserConnect(User *u, bool &exempt) anope_override
+ void OnUserConnect(User *u, bool &exempt) override
{
if (u->Quitting() || exempt)
return;
@@ -454,7 +451,7 @@ class OSForbid : public Module
this->OnUserNickChange(u, "");
}
- void OnUserNickChange(User *u, const Anope::string &) anope_override
+ void OnUserNickChange(User *u, const Anope::string &) override
{
if (u->HasMode("OPER"))
return;
@@ -472,7 +469,7 @@ class OSForbid : public Module
}
}
- EventReturn OnCheckKick(User *u, Channel *c, Anope::string &mask, Anope::string &reason) anope_override
+ EventReturn OnCheckKick(User *u, Channel *c, Anope::string &mask, Anope::string &reason) override
{
BotInfo *OperServ = Config->GetClient("OperServ");
if (u->HasMode("OPER") || !OperServ)
@@ -501,7 +498,7 @@ class OSForbid : public Module
return EVENT_CONTINUE;
}
- EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> &params) anope_override
+ EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> &params) override
{
if (command->name == "nickserv/info" && params.size() > 0)
{
diff --git a/modules/commands/os_ignore.cpp b/modules/commands/os_ignore.cpp
index cacfccff6..f779840fb 100644
--- a/modules/commands/os_ignore.cpp
+++ b/modules/commands/os_ignore.cpp
@@ -15,8 +15,8 @@
struct IgnoreDataImpl : IgnoreData, Serializable
{
IgnoreDataImpl() : Serializable("IgnoreData") { }
- ~IgnoreDataImpl();
- void Serialize(Serialize::Data &data) const anope_override;
+ ~IgnoreDataImpl() override;
+ void Serialize(Serialize::Data &data) const override;
static Serializable* Unserialize(Serializable *obj, Serialize::Data &data);
};
@@ -64,19 +64,19 @@ class OSIgnoreService : public IgnoreService
public:
OSIgnoreService(Module *o) : IgnoreService(o), ignores("IgnoreData") { }
- void AddIgnore(IgnoreData *ign) anope_override
+ void AddIgnore(IgnoreData *ign) override
{
ignores->push_back(ign);
}
- void DelIgnore(IgnoreData *ign) anope_override
+ void DelIgnore(IgnoreData *ign) override
{
std::vector<IgnoreData *>::iterator it = std::find(ignores->begin(), ignores->end(), ign);
if (it != ignores->end())
ignores->erase(it);
}
- void ClearIgnores() anope_override
+ void ClearIgnores() override
{
for (unsigned i = ignores->size(); i > 0; --i)
{
@@ -85,12 +85,12 @@ class OSIgnoreService : public IgnoreService
}
}
- IgnoreData *Create() anope_override
+ IgnoreData *Create() override
{
return new IgnoreDataImpl();
}
- IgnoreData *Find(const Anope::string &mask) anope_override
+ IgnoreData *Find(const Anope::string &mask) override
{
User *u = User::Find(mask, true);
std::vector<IgnoreData *>::iterator ign = this->ignores->begin(), ign_end = this->ignores->end();
@@ -148,7 +148,7 @@ class OSIgnoreService : public IgnoreService
return NULL;
}
- std::vector<IgnoreData *> &GetIgnores() anope_override
+ std::vector<IgnoreData *> &GetIgnores() override
{
return *ignores;
}
@@ -282,8 +282,8 @@ class CommandOSIgnore : public Command
std::vector<Anope::string> replies;
list.Process(replies);
- for (unsigned i = 0; i < replies.size(); ++i)
- source.Reply(replies[i]);
+ for (const auto &reply : replies)
+ source.Reply(reply);
}
}
@@ -338,14 +338,14 @@ class CommandOSIgnore : public Command
public:
CommandOSIgnore(Module *creator) : Command(creator, "operserv/ignore", 1, 4)
{
- this->SetDesc(_("Modify the Services ignore list"));
+ this->SetDesc(_("Modify the services ignore list"));
this->SetSyntax(_("ADD \037expiry\037 {\037nick\037|\037mask\037} [\037reason\037]"));
this->SetSyntax(_("DEL {\037nick\037|\037mask\037}"));
this->SetSyntax("LIST");
this->SetSyntax("CLEAR");
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &cmd = params[0];
@@ -363,17 +363,17 @@ class CommandOSIgnore : public Command
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
- source.Reply(_("Allows Services Operators to make Services ignore a nick or mask\n"
+ source.Reply(_("Allows Services Operators to make services ignore a nick or mask\n"
"for a certain time or until the next restart. The default\n"
"time format is seconds. You can specify it by using units.\n"
"Valid units are: \037s\037 for seconds, \037m\037 for minutes,\n"
"\037h\037 for hours and \037d\037 for days.\n"
"Combinations of these units are not permitted.\n"
- "To make Services permanently ignore the user, type 0 as time.\n"
+ "To make services permanently ignore the user, type 0 as time.\n"
"When adding a \037mask\037, it should be in the format nick!user@host,\n"
"everything else will be considered a nick. Wildcards are permitted.\n"
" \n"
@@ -404,7 +404,7 @@ class OSIgnore : public Module
}
- EventReturn OnBotPrivmsg(User *u, BotInfo *bi, Anope::string &message) anope_override
+ EventReturn OnBotPrivmsg(User *u, BotInfo *bi, Anope::string &message) override
{
if (!u->HasMode("OPER") && this->osignoreservice.Find(u->nick))
return EVENT_STOP;
diff --git a/modules/commands/os_info.cpp b/modules/commands/os_info.cpp
index 6cfe19cf1..8015f835d 100644
--- a/modules/commands/os_info.cpp
+++ b/modules/commands/os_info.cpp
@@ -13,15 +13,15 @@ struct OperInfo : Serializable
Anope::string target;
Anope::string info;
Anope::string adder;
- time_t created;
+ time_t created = 0;
- OperInfo() : Serializable("OperInfo"), created(0) { }
+ OperInfo() : Serializable("OperInfo") { }
OperInfo(const Anope::string &t, const Anope::string &i, const Anope::string &a, time_t c) :
Serializable("OperInfo"), target(t), info(i), adder(a), created(c) { }
- ~OperInfo();
+ ~OperInfo() override;
- void Serialize(Serialize::Data &data) const anope_override
+ void Serialize(Serialize::Data &data) const override
{
data["target"] << target;
data["info"] << info;
@@ -104,7 +104,7 @@ class CommandOSInfo : public Command
this->SetSyntax(_("CLEAR \037target\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &cmd = params[0], target = params[1], info = params.size() > 2 ? params[2] : "";
@@ -148,10 +148,8 @@ class CommandOSInfo : public Command
return;
}
- for (unsigned i = 0; i < (*oi)->size(); ++i)
+ for (auto *o : *(*oi))
{
- OperInfo *o = (*oi)->at(i);
-
if (o->info.equals_ci(info))
{
source.Reply(_("The oper info already exists on \002%s\002."), target.c_str());
@@ -236,7 +234,7 @@ class CommandOSInfo : public Command
}
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -262,9 +260,8 @@ class OSInfo : public Module
if (!oi)
return;
- for (unsigned i = 0; i < (*oi)->size(); ++i)
+ for (auto *o : *(*oi))
{
- OperInfo *o = (*oi)->at(i);
info[_("Oper Info")] = Anope::printf(_("(by %s on %s) %s"), o->adder.c_str(), Anope::strftime(o->created, source.GetAccount(), true).c_str(), o->info.c_str());
}
}
@@ -276,12 +273,12 @@ class OSInfo : public Module
}
- void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_hidden) anope_override
+ void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_hidden) override
{
OnInfo(source, na->nc, info);
}
- void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_hidden) anope_override
+ void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_hidden) override
{
OnInfo(source, ci, info);
}
diff --git a/modules/commands/os_jupe.cpp b/modules/commands/os_jupe.cpp
index beaba729d..1a773dee9 100644
--- a/modules/commands/os_jupe.cpp
+++ b/modules/commands/os_jupe.cpp
@@ -20,7 +20,7 @@ class CommandOSJupe : public Command
this->SetSyntax(_("\037server\037 [\037reason\037]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &jserver = params[0];
const Anope::string &reason = params.size() > 1 ? params[1] : "";
@@ -49,12 +49,12 @@ class CommandOSJupe : public Command
}
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
- source.Reply(_("Tells Services to jupiter a server -- that is, to create\n"
- "a fake \"server\" connected to Services which prevents\n"
+ source.Reply(_("Tells services to jupiter a server -- that is, to create\n"
+ "a fake \"server\" connected to services which prevents\n"
"the real server of that name from connecting. The jupe\n"
"may be removed using a standard \002SQUIT\002. If a reason is\n"
"given, it is placed in the server information field;\n"
diff --git a/modules/commands/os_kick.cpp b/modules/commands/os_kick.cpp
index 933757ce6..0330bb4ce 100644
--- a/modules/commands/os_kick.cpp
+++ b/modules/commands/os_kick.cpp
@@ -20,7 +20,7 @@ class CommandOSKick : public Command
this->SetSyntax(_("\037channel\037 \037user\037 \037reason\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &chan = params[0];
const Anope::string &nick = params[1];
@@ -55,7 +55,7 @@ class CommandOSKick : public Command
Log(LOG_ADMIN, source, this) << "on " << u2->nick << " in " << c->name << " (" << s << ")";
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/os_kill.cpp b/modules/commands/os_kill.cpp
index 7782f3579..4f9abd300 100644
--- a/modules/commands/os_kill.cpp
+++ b/modules/commands/os_kill.cpp
@@ -20,7 +20,7 @@ class CommandOSKill : public Command
this->SetSyntax(_("\037user\037 [\037reason\037]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &nick = params[0];
Anope::string reason = params.size() > 1 ? params[1] : "";
@@ -41,7 +41,7 @@ class CommandOSKill : public Command
}
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/os_list.cpp b/modules/commands/os_list.cpp
index 0d1a73ec3..163044210 100644
--- a/modules/commands/os_list.cpp
+++ b/modules/commands/os_list.cpp
@@ -20,7 +20,7 @@ class CommandOSChanList : public Command
this->SetSyntax(_("[{\037pattern\037 | \037nick\037} [\037SECRET\037]]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &pattern = !params.empty() ? params[0] : "";
const Anope::string &opt = params.size() > 1 ? params[1] : "";
@@ -46,14 +46,16 @@ class CommandOSChanList : public Command
{
source.Reply(_("\002%s\002 channel list:"), u2->nick.c_str());
- for (User::ChanUserList::iterator uit = u2->chans.begin(), uit_end = u2->chans.end(); uit != uit_end; ++uit)
+ for (const auto &[_, cc]: u2->chans)
{
- ChanUserContainer *cc = uit->second;
-
if (!modes.empty())
- for (std::set<Anope::string>::iterator it = modes.begin(), it_end = modes.end(); it != it_end; ++it)
- if (!cc->chan->HasMode(*it))
+ {
+ for (const auto &mode : modes)
+ {
+ if (!cc->chan->HasMode(mode))
continue;
+ }
+ }
ListFormatter::ListEntry entry;
entry["Name"] = cc->chan->name;
@@ -69,16 +71,18 @@ class CommandOSChanList : public Command
{
source.Reply(_("Channel list:"));
- for (channel_map::const_iterator cit = ChannelList.begin(), cit_end = ChannelList.end(); cit != cit_end; ++cit)
+ for (const auto &[_, c] : ChannelList)
{
- Channel *c = cit->second;
-
if (!pattern.empty() && !Anope::Match(c->name, pattern, false, true))
continue;
if (!modes.empty())
- for (std::set<Anope::string>::iterator it = modes.begin(), it_end = modes.end(); it != it_end; ++it)
- if (!c->HasMode(*it))
+ {
+ for (const auto &mode : modes)
+ {
+ if (!c->HasMode(mode))
continue;
+ }
+ }
ListFormatter::ListEntry entry;
entry["Name"] = c->name;
@@ -94,13 +98,13 @@ class CommandOSChanList : public Command
std::vector<Anope::string> replies;
list.Process(replies);
- for (unsigned i = 0; i < replies.size(); ++i)
- source.Reply(replies[i]);
+ for (const auto &reply : replies)
+ source.Reply(reply);
source.Reply(_("End of channel list. \002%u\002 channels shown."), count);
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -133,7 +137,7 @@ class CommandOSUserList : public Command
this->SetSyntax(_("[{\037pattern\037 | \037channel\037} [\037INVISIBLE\037]]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &pattern = !params.empty() ? params[0] : "";
const Anope::string &opt = params.size() > 1 ? params[1] : "";
@@ -156,14 +160,16 @@ class CommandOSUserList : public Command
{
source.Reply(_("\002%s\002 users list:"), pattern.c_str());
- for (Channel::ChanUserList::iterator cuit = c->users.begin(), cuit_end = c->users.end(); cuit != cuit_end; ++cuit)
+ for (const auto &[_, uc] : c->users)
{
- ChanUserContainer *uc = cuit->second;
-
if (!modes.empty())
- for (std::set<Anope::string>::iterator it = modes.begin(), it_end = modes.end(); it != it_end; ++it)
- if (!uc->user->HasMode(*it))
+ {
+ for (const auto &mode : modes)
+ {
+ if (!uc->user->HasMode(mode))
continue;
+ }
+ }
ListFormatter::ListEntry entry;
entry["Name"] = uc->user->nick;
@@ -178,8 +184,8 @@ class CommandOSUserList : public Command
{
/* Historically this has been ordered, so... */
Anope::map<User *> ordered_map;
- for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
- ordered_map[it->first] = it->second;
+ for (const auto &[nick, user] : UserListByNick)
+ ordered_map[nick] = user;
source.Reply(_("Users list:"));
@@ -197,10 +203,10 @@ class CommandOSUserList : public Command
};
bool match = false;
- for (unsigned int i = 0; i < sizeof(masks) / sizeof(*masks); ++i)
+ for (const auto &mask : masks)
{
/* Check mask with realname included, too */
- if (Anope::Match(masks[i], pattern, false, true) || Anope::Match(masks[i] + "#" + u2->realname, pattern, false, true))
+ if (Anope::Match(mask, pattern, false, true) || Anope::Match(mask + "#" + u2->realname, pattern, false, true))
{
match = true;
break;
@@ -211,9 +217,13 @@ class CommandOSUserList : public Command
continue;
if (!modes.empty())
- for (std::set<Anope::string>::iterator mit = modes.begin(), mit_end = modes.end(); mit != mit_end; ++mit)
- if (!u2->HasMode(*mit))
+ {
+ for (const auto &mode : modes)
+ {
+ if (!u2->HasMode(mode))
continue;
+ }
+ }
}
ListFormatter::ListEntry entry;
@@ -229,14 +239,14 @@ class CommandOSUserList : public Command
std::vector<Anope::string> replies;
list.Process(replies);
- for (unsigned i = 0; i < replies.size(); ++i)
- source.Reply(replies[i]);
+ for (const auto &reply : replies)
+ source.Reply(reply);
source.Reply(_("End of users list. \002%u\002 users shown."), count);
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/os_login.cpp b/modules/commands/os_login.cpp
index ace6d0393..023f1cfe8 100644
--- a/modules/commands/os_login.cpp
+++ b/modules/commands/os_login.cpp
@@ -20,7 +20,7 @@ class CommandOSLogin : public Command
this->RequireUser(true);
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &password = params[0];
@@ -45,7 +45,7 @@ class CommandOSLogin : public Command
}
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -55,7 +55,7 @@ class CommandOSLogin : public Command
return true;
}
- const Anope::string GetDesc(CommandSource &source) const anope_override
+ const Anope::string GetDesc(CommandSource &source) const override
{
return Anope::printf(Language::Translate(source.GetAccount(), _("Login to %s")), source.service->nick.c_str());
}
@@ -69,7 +69,7 @@ class CommandOSLogout : public Command
this->RequireUser(true);
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
User *u = source.GetUser();
Oper *o = source.nc->o;
@@ -87,7 +87,7 @@ class CommandOSLogout : public Command
}
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -97,7 +97,7 @@ class CommandOSLogout : public Command
return true;
}
- const Anope::string GetDesc(CommandSource &source) const anope_override
+ const Anope::string GetDesc(CommandSource &source) const override
{
return Anope::printf(Language::Translate(source.GetAccount(), _("Logout from %s")), source.service->nick.c_str());
}
@@ -116,7 +116,7 @@ class OSLogin : public Module
}
- EventReturn IsServicesOper(User *u) anope_override
+ EventReturn IsServicesOper(User *u) override
{
if (!u->Account()->o->password.empty())
{
diff --git a/modules/commands/os_logsearch.cpp b/modules/commands/os_logsearch.cpp
index ea12aea20..ecea323c5 100644
--- a/modules/commands/os_logsearch.cpp
+++ b/modules/commands/os_logsearch.cpp
@@ -33,7 +33,7 @@ class CommandOSLogSearch : public Command
this->SetSyntax(_("[+\037days\037d] [+\037limit\037l] \037pattern\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
int days = 7, replies = 50;
@@ -147,16 +147,16 @@ class CommandOSLogSearch : public Command
source.Reply(_("Matches for \002%s\002:"), search_string.c_str());
unsigned int count = 0;
- for (std::vector<Anope::string>::iterator it = matches.begin(), it_end = matches.end(); it != it_end; ++it)
- source.Reply("#%d: %s", ++count, it->c_str());
+ for (const auto &match : matches)
+ source.Reply("#%d: %s", ++count, match.c_str());
source.Reply(_("Showed %d/%d matches for \002%s\002."), matches.size(), found, search_string.c_str());
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
- source.Reply(_("This command searches the Services logfiles for messages\n"
+ source.Reply(_("This command searches the services logfiles for messages\n"
"that match the given pattern. The day and limit argument\n"
"may be used to specify how many days of logs to search\n"
"and the number of replies to limit to. By default this\n"
diff --git a/modules/commands/os_mode.cpp b/modules/commands/os_mode.cpp
index 0710065ea..096f50118 100644
--- a/modules/commands/os_mode.cpp
+++ b/modules/commands/os_mode.cpp
@@ -21,7 +21,7 @@ class CommandOSMode : public Command
this->SetSyntax(_("\037channel\037 CLEAR [ALL]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &target = params[0];
const Anope::string &modes = params[1];
@@ -35,9 +35,8 @@ class CommandOSMode : public Command
{
bool all = params.size() > 2 && params[2].equals_ci("ALL");
- const Channel::ModeList chmodes = c->GetModes();
- for (Channel::ModeList::const_iterator it = chmodes.begin(), it_end = chmodes.end(); it != it_end && c; ++it)
- c->RemoveMode(c->WhoSends(), it->first, it->second, false);
+ for (const auto &[mode, value] : c->GetModes())
+ c->RemoveMode(c->WhoSends(), mode, value, false);
if (!c)
{
@@ -47,10 +46,8 @@ class CommandOSMode : public Command
if (all)
{
- for (Channel::ChanUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it)
+ for (const auto &[_, uc] : c->users)
{
- ChanUserContainer *uc = it->second;
-
if (uc->user->HasMode("OPER"))
continue;
@@ -126,7 +123,7 @@ class CommandOSMode : public Command
}
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -147,7 +144,7 @@ class CommandOSUMode : public Command
this->SetSyntax(_("\037user\037 \037modes\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &target = params[0];
const Anope::string &modes = params[1];
@@ -166,7 +163,7 @@ class CommandOSUMode : public Command
}
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/os_modinfo.cpp b/modules/commands/os_modinfo.cpp
index bed3a63ab..5d6de2e6c 100644
--- a/modules/commands/os_modinfo.cpp
+++ b/modules/commands/os_modinfo.cpp
@@ -20,7 +20,7 @@ class CommandOSModInfo : public Command
this->SetSyntax(_("\037modname\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &file = params[0];
@@ -34,22 +34,18 @@ class CommandOSModInfo : public Command
source.Reply(_(" Loaded at: %p"), m->handle);
std::vector<Anope::string> servicekeys = Service::GetServiceKeys("Command");
- for (unsigned i = 0; i < servicekeys.size(); ++i)
+ for (const auto &servicekey : servicekeys)
{
- ServiceReference<Command> c("Command", servicekeys[i]);
+ ServiceReference<Command> c("Command", servicekey);
if (!c || c->owner != m)
continue;
source.Reply(_(" Providing service: \002%s\002"), c->name.c_str());
- for (botinfo_map::const_iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it)
+ for (const auto &[_, bi] : *BotListByNick)
{
- const BotInfo *bi = it->second;
-
- for (CommandInfo::map::const_iterator cit = bi->commands.begin(), cit_end = bi->commands.end(); cit != cit_end; ++cit)
+ for (const auto &[c_name, info] : bi->commands)
{
- const Anope::string &c_name = cit->first;
- const CommandInfo &info = cit->second;
if (info.name != c->name)
continue;
source.Reply(_(" Command \002%s\002 on \002%s\002 is linked to \002%s\002"), c_name.c_str(), bi->nick.c_str(), c->name.c_str());
@@ -63,7 +59,7 @@ class CommandOSModInfo : public Command
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -81,7 +77,7 @@ class CommandOSModList : public Command
this->SetSyntax("[all|third|vendor|extra|database|encryption|pseudoclient|protocol]");
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &param = !params.empty() ? params[0] : "";
@@ -116,10 +112,8 @@ class CommandOSModList : public Command
source.Reply(_("Current module list:"));
int count = 0;
- for (std::list<Module *>::iterator it = ModuleManager::Modules.begin(), it_end = ModuleManager::Modules.end(); it != it_end; ++it)
+ for (auto *m : ModuleManager::Modules)
{
- Module *m = *it;
-
bool show = false;
Anope::string mtype;
@@ -189,7 +183,7 @@ class CommandOSModList : public Command
source.Reply(_("%d modules loaded."), count);
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/os_module.cpp b/modules/commands/os_module.cpp
index 780b127b6..7f20132fa 100644
--- a/modules/commands/os_module.cpp
+++ b/modules/commands/os_module.cpp
@@ -20,7 +20,7 @@ class CommandOSModLoad : public Command
this->SetSyntax(_("\037modname\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &mname = params[0];
@@ -38,7 +38,7 @@ class CommandOSModLoad : public Command
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -57,7 +57,7 @@ class CommandOSModReLoad : public Command
this->SetSyntax(_("\037modname\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &mname = params[0];
@@ -111,7 +111,7 @@ class CommandOSModReLoad : public Command
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -129,7 +129,7 @@ class CommandOSModUnLoad : public Command
this->SetSyntax(_("\037modname\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &mname = params[0];
@@ -161,7 +161,7 @@ class CommandOSModUnLoad : public Command
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/os_news.cpp b/modules/commands/os_news.cpp
index 1c1faafb6..68c9f2629 100644
--- a/modules/commands/os_news.cpp
+++ b/modules/commands/os_news.cpp
@@ -61,7 +61,7 @@ struct NewsMessages msgarray[] = {
struct MyNewsItem : NewsItem
{
- void Serialize(Serialize::Data &data) const anope_override
+ void Serialize(Serialize::Data &data) const override
{
data["type"] << this->type;
data["text"] << this->text;
@@ -99,24 +99,26 @@ class MyNewsService : public NewsService
public:
MyNewsService(Module *m) : NewsService(m) { }
- ~MyNewsService()
+ ~MyNewsService() override
{
- for (unsigned i = 0; i < 3; ++i)
- for (unsigned j = 0; j < newsItems[i].size(); ++j)
- delete newsItems[i][j];
+ for (const auto &newstype : newsItems)
+ {
+ for (const auto *newsitem : newstype)
+ delete newsitem;
+ }
}
- NewsItem *CreateNewsItem() anope_override
+ NewsItem *CreateNewsItem() override
{
return new MyNewsItem();
}
- void AddNewsItem(NewsItem *n) anope_override
+ void AddNewsItem(NewsItem *n) override
{
this->newsItems[n->type].push_back(n);
}
- void DelNewsItem(NewsItem *n) anope_override
+ void DelNewsItem(NewsItem *n) override
{
std::vector<NewsItem *> &list = this->GetNewsList(n->type);
std::vector<NewsItem *>::iterator it = std::find(list.begin(), list.end(), n);
@@ -125,7 +127,7 @@ class MyNewsService : public NewsService
delete n;
}
- std::vector<NewsItem *> &GetNewsList(NewsType t) anope_override
+ std::vector<NewsItem *> &GetNewsList(NewsType t) override
{
return this->newsItems[t];
}
@@ -134,9 +136,9 @@ class MyNewsService : public NewsService
#define lenof(a) (sizeof(a) / sizeof(*(a)))
static const char **findmsgs(NewsType type)
{
- for (unsigned i = 0; i < lenof(msgarray); ++i)
- if (msgarray[i].type == type)
- return msgarray[i].msgs;
+ for (auto &msg : msgarray)
+ if (msg.type == type)
+ return msg.msgs;
return NULL;
}
@@ -170,8 +172,8 @@ class NewsBase : public Command
std::vector<Anope::string> replies;
lflist.Process(replies);
- for (unsigned i = 0; i < replies.size(); ++i)
- source.Reply(replies[i]);
+ for (const auto &reply : replies)
+ source.Reply(reply);
source.Reply(_("End of news list."));
}
@@ -280,13 +282,13 @@ class NewsBase : public Command
this->SetSyntax("LIST");
}
- virtual ~NewsBase()
+ ~NewsBase() override
{
}
- virtual void Execute(CommandSource &source, const std::vector<Anope::string> &params) = 0;
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override = 0;
- virtual bool OnHelp(CommandSource &source, const Anope::string &subcommand) = 0;
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override = 0;
};
class CommandOSLogonNews : public NewsBase
@@ -297,12 +299,12 @@ class CommandOSLogonNews : public NewsBase
this->SetDesc(_("Define messages to be shown to users at logon"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
return this->DoNews(source, params, NEWS_LOGON);
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -324,12 +326,12 @@ class CommandOSOperNews : public NewsBase
this->SetDesc(_("Define messages to be shown to users who oper"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
return this->DoNews(source, params, NEWS_OPER);
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -351,12 +353,12 @@ class CommandOSRandomNews : public NewsBase
this->SetDesc(_("Define messages to be randomly shown to users at logon"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
return this->DoNews(source, params, NEWS_RANDOM);
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -438,20 +440,20 @@ class OSNews : public Module
{
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
oper_announcer = conf->GetModule(this)->Get<const Anope::string>("oper_announcer", "OperServ");
announcer = conf->GetModule(this)->Get<const Anope::string>("announcer", "Global");
news_count = conf->GetModule(this)->Get<unsigned>("newscount", "3");
}
- void OnUserModeSet(const MessageSource &setter, User *u, const Anope::string &mname) anope_override
+ void OnUserModeSet(const MessageSource &setter, User *u, const Anope::string &mname) override
{
if (mname == "OPER")
DisplayNews(u, NEWS_OPER);
}
- void OnUserConnect(User *user, bool &) anope_override
+ void OnUserConnect(User *user, bool &) override
{
if (user->Quitting() || !user->server->IsSynced())
return;
diff --git a/modules/commands/os_noop.cpp b/modules/commands/os_noop.cpp
index e99be9d78..23cf83142 100644
--- a/modules/commands/os_noop.cpp
+++ b/modules/commands/os_noop.cpp
@@ -21,7 +21,7 @@ class CommandOSNOOP : public Command
this->SetSyntax(_("REVOKE \037server\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &cmd = params[0];
const Anope::string &server = params[1];
@@ -42,10 +42,8 @@ class CommandOSNOOP : public Command
Anope::string reason = "NOOP command used by " + source.GetNick();
/* Kill all the IRCops of the server */
- for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
+ for (const auto &[_, u2] : UserListByNick)
{
- User *u2 = it->second;
-
if (u2->server == s && u2->HasMode("OPER"))
u2->Kill(*source.service, reason);
}
@@ -61,7 +59,7 @@ class CommandOSNOOP : public Command
this->OnSyntaxError(source, "");
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -85,7 +83,7 @@ class OSNOOP : public Module
}
- void OnUserModeSet(const MessageSource &, User *u, const Anope::string &mname) anope_override
+ void OnUserModeSet(const MessageSource &, User *u, const Anope::string &mname) override
{
Anope::string *setter;
if (mname == "OPER" && (setter = noop.Get(u->server)))
diff --git a/modules/commands/os_oline.cpp b/modules/commands/os_oline.cpp
deleted file mode 100644
index 90d55f628..000000000
--- a/modules/commands/os_oline.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/* OperServ core functions
- *
- * (C) 2003-2023 Anope Team
- * Contact us at team@anope.org
- *
- * Please read COPYING and README for further details.
- *
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
- */
-
-#include "module.h"
-
-class CommandOSOLine : public Command
-{
- public:
- CommandOSOLine(Module *creator) : Command(creator, "operserv/oline", 2, 2)
- {
- this->SetDesc(_("Give Operflags to a certain user"));
- this->SetSyntax(_("\037nick\037 \037flags\037"));
- }
-
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
- {
- const Anope::string &nick = params[0];
- const Anope::string &flag = params[1];
- User *u2 = NULL;
-
- /* let's check whether the user is online */
- if (!(u2 = User::Find(nick, true)))
- source.Reply(NICK_X_NOT_IN_USE, nick.c_str());
- else if (u2 && flag[0] == '+')
- {
- IRCD->SendSVSO(source.service, nick, flag);
- u2->SetMode(source.service, "OPER");
- u2->SendMessage(source.service, _("You are now an IRC Operator."));
- source.Reply(_("Operflags \002%s\002 have been added for \002%s\002."), flag.c_str(), nick.c_str());
- Log(LOG_ADMIN, source, this) << "for " << nick;
- }
- else if (u2 && flag[0] == '-')
- {
- IRCD->SendSVSO(source.service, nick, flag);
- source.Reply(_("Operflags \002%s\002 have been removed from \002%s\002."), flag.c_str(), nick.c_str());
- Log(LOG_ADMIN, source, this) << "for " << nick;
- }
- else
- this->OnSyntaxError(source, "");
-
- return;
- }
-
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
- {
- this->SendSyntax(source);
- source.Reply(" ");
- source.Reply(_("Allows Services Operators to give Operflags to any user.\n"
- "Flags have to be prefixed with a \"+\" or a \"-\". To\n"
- "remove all flags simply type a \"-\" instead of any flags."));
- return true;
- }
-};
-
-class OSOLine : public Module
-{
- CommandOSOLine commandosoline;
-
- public:
- OSOLine(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
- commandosoline(this)
- {
-
- if (!IRCD || !IRCD->CanSVSO)
- throw ModuleException("Your IRCd does not support OMODE.");
-
- }
-};
-
-MODULE_INIT(OSOLine)
diff --git a/modules/commands/os_oper.cpp b/modules/commands/os_oper.cpp
index a60682e48..67612ea74 100644
--- a/modules/commands/os_oper.cpp
+++ b/modules/commands/os_oper.cpp
@@ -15,7 +15,7 @@ struct MyOper : Oper, Serializable
{
MyOper(const Anope::string &n, OperType *o) : Oper(n, o), Serializable("Oper") { }
- void Serialize(Serialize::Data &data) const anope_override
+ void Serialize(Serialize::Data &data) const override
{
data["name"] << this->name;
data["type"] << this->ot->GetName();
@@ -50,15 +50,17 @@ class CommandOSOper : public Command
{
bool HasPrivs(CommandSource &source, OperType *ot) const
{
- std::list<Anope::string> commands = ot->GetCommands(), privs = ot->GetPrivs();
-
- for (std::list<Anope::string>::iterator it = commands.begin(); it != commands.end(); ++it)
- if (!source.HasCommand(*it))
+ for (const auto &command : ot->GetCommands())
+ {
+ if (!source.HasCommand(command))
return false;
+ }
- for (std::list<Anope::string>::iterator it = privs.begin(); it != privs.end(); ++it)
- if (!source.HasPriv(*it))
+ for (const auto &priv : ot->GetPrivs())
+ {
+ if (!source.HasPriv(priv))
return false;
+ }
return true;
}
@@ -73,7 +75,7 @@ class CommandOSOper : public Command
this->SetSyntax("LIST");
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &subcommand = params[0];
@@ -151,20 +153,17 @@ class CommandOSOper : public Command
else if (subcommand.equals_ci("LIST"))
{
source.Reply(_("Name Type"));
- for (nickcore_map::const_iterator it = NickCoreList->begin(), it_end = NickCoreList->end(); it != it_end; ++it)
+ for (const auto &[_, nc] : *NickCoreList)
{
- const NickCore *nc = it->second;
-
if (!nc->o)
continue;
source.Reply(_("%-8s %s"), nc->o->name.c_str(), nc->o->ot->GetName().c_str());
if (std::find(Config->Opers.begin(), Config->Opers.end(), nc->o) != Config->Opers.end())
source.Reply(_(" This oper is configured in the configuration file."));
- for (std::list<User *>::const_iterator uit = nc->users.begin(); uit != nc->users.end(); ++uit)
+ for (auto *u : nc->users)
{
- User *u = *uit;
- source.Reply(_(" %s is online using this oper block."), u->nick.c_str());
+ source.Reply(_(" %s is online using this oper block."), u->nick.c_str());
}
}
}
@@ -173,9 +172,8 @@ class CommandOSOper : public Command
if (params.size() < 2)
{
source.Reply(_("Available opertypes:"));
- for (unsigned i = 0; i < Config->MyOperTypes.size(); ++i)
+ for (auto *ot : Config->MyOperTypes)
{
- OperType *ot = Config->MyOperTypes[i];
source.Reply("%s", ot->GetName().c_str());
}
return;
@@ -196,9 +194,9 @@ class CommandOSOper : public Command
source.Reply(_("Available commands for \002%s\002:"), ot->GetName().c_str());
Anope::string buf;
std::list<Anope::string> cmds = ot->GetCommands();
- for (std::list<Anope::string>::const_iterator it = cmds.begin(), it_end = cmds.end(); it != it_end; ++it)
+ for (const auto &cmd : cmds)
{
- buf += *it + " ";
+ buf += cmd + " ";
if (buf.length() > 400)
{
source.Reply("%s", buf.c_str());
@@ -218,9 +216,9 @@ class CommandOSOper : public Command
source.Reply(_("Available privileges for \002%s\002:"), ot->GetName().c_str());
Anope::string buf;
std::list<Anope::string> privs = ot->GetPrivs();
- for (std::list<Anope::string>::const_iterator it = privs.begin(), it_end = privs.end(); it != it_end; ++it)
+ for (const auto &priv : privs)
{
- buf += *it + " ";
+ buf += priv + " ";
if (buf.length() > 400)
{
source.Reply("%s", buf.c_str());
@@ -243,7 +241,7 @@ class CommandOSOper : public Command
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -265,12 +263,10 @@ class OSOper : public Module
{
}
- ~OSOper()
+ ~OSOper() override
{
- for (nickcore_map::const_iterator it = NickCoreList->begin(), it_end = NickCoreList->end(); it != it_end; ++it)
+ for (const auto &[_, nc] : *NickCoreList)
{
- NickCore *nc = it->second;
-
if (nc->o && dynamic_cast<MyOper *>(nc->o))
{
delete nc->o;
@@ -279,7 +275,7 @@ class OSOper : public Module
}
}
- void OnDelCore(NickCore *nc) anope_override
+ void OnDelCore(NickCore *nc) override
{
if (nc->o && dynamic_cast<MyOper *>(nc->o))
{
diff --git a/modules/commands/os_reload.cpp b/modules/commands/os_reload.cpp
index 722213f8f..7ae3228e4 100644
--- a/modules/commands/os_reload.cpp
+++ b/modules/commands/os_reload.cpp
@@ -19,7 +19,7 @@ class CommandOSReload : public Command
this->SetDesc(_("Reload services' configuration file"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
try
{
@@ -40,13 +40,13 @@ class CommandOSReload : public Command
}
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
- source.Reply(_("Causes Services to reload the configuration file. Note that\n"
- "some directives still need the restart of the Services to\n"
- "take effect (such as Services' nicknames, activation of the\n"
+ source.Reply(_("Causes services to reload the configuration file. Note that\n"
+ "some directives still need the restart of the services to\n"
+ "take effect (such as services' nicknames, activation of the\n"
"session limitation, etc.)."));
return true;
}
diff --git a/modules/commands/os_session.cpp b/modules/commands/os_session.cpp
index 4dca8eca5..07e1e551f 100644
--- a/modules/commands/os_session.cpp
+++ b/modules/commands/os_session.cpp
@@ -42,28 +42,27 @@ class MySessionService : public SessionService
public:
MySessionService(Module *m) : SessionService(m), Exceptions("Exception") { }
- Exception *CreateException() anope_override
+ Exception *CreateException() override
{
return new Exception();
}
- void AddException(Exception *e) anope_override
+ void AddException(Exception *e) override
{
this->Exceptions->push_back(e);
}
- void DelException(Exception *e) anope_override
+ void DelException(Exception *e) override
{
ExceptionVector::iterator it = std::find(this->Exceptions->begin(), this->Exceptions->end(), e);
if (it != this->Exceptions->end())
this->Exceptions->erase(it);
}
- Exception *FindException(User *u) anope_override
+ Exception *FindException(User *u) override
{
- for (std::vector<Exception *>::const_iterator it = this->Exceptions->begin(), it_end = this->Exceptions->end(); it != it_end; ++it)
+ for (auto *e : *this->Exceptions)
{
- Exception *e = *it;
if (Anope::Match(u->host, e->mask) || Anope::Match(u->ip.addr(), e->mask))
return e;
@@ -73,11 +72,10 @@ class MySessionService : public SessionService
return NULL;
}
- Exception *FindException(const Anope::string &host) anope_override
+ Exception *FindException(const Anope::string &host) override
{
- for (std::vector<Exception *>::const_iterator it = this->Exceptions->begin(), it_end = this->Exceptions->end(); it != it_end; ++it)
+ for (auto *e : *this->Exceptions)
{
- Exception *e = *it;
if (Anope::Match(host, e->mask))
return e;
@@ -88,7 +86,7 @@ class MySessionService : public SessionService
return NULL;
}
- ExceptionVector &GetExceptions() anope_override
+ ExceptionVector &GetExceptions() override
{
return this->Exceptions;
}
@@ -98,7 +96,7 @@ class MySessionService : public SessionService
this->Sessions.erase(s->addr);
}
- Session *FindSession(const Anope::string &ip) anope_override
+ Session *FindSession(const Anope::string &ip) override
{
cidr c(ip, ip.find(':') != Anope::string::npos ? ipv6_cidr : ipv4_cidr);
if (!c.valid())
@@ -122,7 +120,7 @@ class MySessionService : public SessionService
return this->Sessions[ip];
}
- SessionMap &GetSessions() anope_override
+ SessionMap &GetSessions() override
{
return this->Sessions;
}
@@ -132,14 +130,14 @@ class ExceptionDelCallback : public NumberList
{
protected:
CommandSource &source;
- unsigned deleted;
+ unsigned deleted = 0;
Command *cmd;
public:
- ExceptionDelCallback(CommandSource &_source, const Anope::string &numlist, Command *c) : NumberList(numlist, true), source(_source), deleted(0), cmd(c)
+ ExceptionDelCallback(CommandSource &_source, const Anope::string &numlist, Command *c) : NumberList(numlist, true), source(_source), cmd(c)
{
}
- ~ExceptionDelCallback()
+ ~ExceptionDelCallback() override
{
if (!deleted)
source.Reply(_("No matching entries on session-limit exception list."));
@@ -149,7 +147,7 @@ class ExceptionDelCallback : public NumberList
source.Reply(_("Deleted %d entries from session-limit exception list."), deleted);
}
- virtual void HandleNumber(unsigned number) anope_override
+ void HandleNumber(unsigned number) override
{
if (!number || number > session_service->GetExceptions().size())
return;
@@ -191,10 +189,8 @@ class CommandOSSession : public Command
ListFormatter list(source.GetAccount());
list.AddColumn(_("Session")).AddColumn(_("Host"));
- for (SessionService::SessionMap::iterator it = session_service->GetSessions().begin(), it_end = session_service->GetSessions().end(); it != it_end; ++it)
+ for (const auto &[_, session] : session_service->GetSessions())
{
- Session *session = it->second;
-
if (session->count >= mincount)
{
ListFormatter::ListEntry entry;
@@ -210,8 +206,8 @@ class CommandOSSession : public Command
list.Process(replies);
- for (unsigned i = 0; i < replies.size(); ++i)
- source.Reply(replies[i]);
+ for (const auto &reply : replies)
+ source.Reply(reply);
}
return;
@@ -247,7 +243,7 @@ class CommandOSSession : public Command
this->SetSyntax(_("VIEW \037host\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &cmd = params[0];
@@ -263,7 +259,7 @@ class CommandOSSession : public Command
this->OnSyntaxError(source, "");
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -347,9 +343,8 @@ class CommandOSException : public Command
return;
}
- for (std::vector<Exception *>::iterator it = session_service->GetExceptions().begin(), it_end = session_service->GetExceptions().end(); it != it_end; ++it)
+ for (auto *e : session_service->GetExceptions())
{
- Exception *e = *it;
if (e->mask.equals_ci(mask))
{
if (e->limit != limit)
@@ -445,7 +440,7 @@ class CommandOSException : public Command
{
}
- void HandleNumber(unsigned Number) anope_override
+ void HandleNumber(unsigned Number) override
{
if (!Number || Number > session_service->GetExceptions().size())
return;
@@ -495,8 +490,8 @@ class CommandOSException : public Command
std::vector<Anope::string> replies;
list.Process(replies);
- for (unsigned i = 0; i < replies.size(); ++i)
- source.Reply(replies[i]);
+ for (const auto &reply : replies)
+ source.Reply(reply);
}
}
@@ -526,7 +521,7 @@ class CommandOSException : public Command
this->SetSyntax(_("VIEW [\037mask\037 | \037list\037]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &cmd = params[0];
@@ -544,7 +539,7 @@ class CommandOSException : public Command
this->OnSyntaxError(source, "");
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -597,12 +592,12 @@ class OSSession : public Module
this->SetPermanent(true);
}
- void Prioritize() anope_override
+ void Prioritize() override
{
ModuleManager::SetPriority(this, PRIORITY_FIRST);
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
Configuration::Block *block = Config->GetModule(this);
@@ -622,7 +617,7 @@ class OSSession : public Module
throw ConfigException(this->name + ": session CIDR value out of range");
}
- void OnUserConnect(User *u, bool &exempt) anope_override
+ void OnUserConnect(User *u, bool &exempt) override
{
if (u->Quitting() || !session_limit || exempt || !u->server || u->server->IsULined())
return;
@@ -693,7 +688,7 @@ class OSSession : public Module
}
}
- void OnUserQuit(User *u, const Anope::string &msg) anope_override
+ void OnUserQuit(User *u, const Anope::string &msg) override
{
if (!session_limit || !u->server || u->server->IsULined())
return;
@@ -716,7 +711,7 @@ class OSSession : public Module
sessions.erase(sit);
}
- void OnExpireTick() anope_override
+ void OnExpireTick() override
{
if (Anope::NoExpire)
return;
diff --git a/modules/commands/os_set.cpp b/modules/commands/os_set.cpp
index 61f195cd6..51d9788d4 100644
--- a/modules/commands/os_set.cpp
+++ b/modules/commands/os_set.cpp
@@ -166,11 +166,11 @@ class CommandOSSet : public Command
public:
CommandOSSet(Module *creator) : Command(creator, "operserv/set", 1, 2)
{
- this->SetDesc(_("Set various global Services options"));
+ this->SetDesc(_("Set various global services options"));
this->SetSyntax(_("\037option\037 \037setting\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &option = params[0];
@@ -190,13 +190,13 @@ class CommandOSSet : public Command
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
if (subcommand.empty())
{
this->SendSyntax(source);
source.Reply(" ");
- source.Reply(_("Sets various global Services options. Option names\n"
+ source.Reply(_("Sets various global services options. Option names\n"
"currently defined are:\n"
" READONLY Set read-only or read-write mode\n"
" DEBUG Activate or deactivate debug mode\n"
@@ -212,13 +212,13 @@ class CommandOSSet : public Command
source.Reply(_("Syntax: \002READONLY {ON | OFF}\002\n"
" \n"
"Sets read-only mode on or off. In read-only mode, normal\n"
- "users will not be allowed to modify any Services data,\n"
+ "users will not be allowed to modify any services data,\n"
"including channel and nickname access lists, etc. IRCops\n"
- "with sufficient Services privileges will be able to modify\n"
+ "with sufficient services privileges will be able to modify\n"
"Services' AKILL, SQLINE, SNLINE and ignore lists, drop,\n"
"suspend or forbid nicknames and channels, and manage news,\n"
"oper info and DNS, but any such changes will not be saved\n"
- "unless read-only mode is deactivated before Services are\n"
+ "unless read-only mode is deactivated before services are\n"
"terminated or restarted.\n"
" \n"
"This option is equivalent to the command-line option\n"
diff --git a/modules/commands/os_shutdown.cpp b/modules/commands/os_shutdown.cpp
index 7dddf9f24..fbd9fd5e3 100644
--- a/modules/commands/os_shutdown.cpp
+++ b/modules/commands/os_shutdown.cpp
@@ -16,10 +16,10 @@ class CommandOSQuit : public Command
public:
CommandOSQuit(Module *creator) : Command(creator, "operserv/quit", 0, 0)
{
- this->SetDesc(_("Terminate Services WITHOUT saving"));
+ this->SetDesc(_("Terminate services WITHOUT saving"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
Log(LOG_ADMIN, source, this);
Anope::QuitReason = source.command + " command received from " + source.GetNick();
@@ -27,11 +27,11 @@ class CommandOSQuit : public Command
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
- source.Reply(_("Causes Services to do an immediate shutdown; databases are\n"
+ source.Reply(_("Causes services to do an immediate shutdown; databases are\n"
"\002not\002 saved. This command should not be used unless\n"
"damage to the in-memory copies of the databases is feared\n"
"and they should not be saved."));
@@ -47,7 +47,7 @@ class CommandOSRestart : public Command
this->SetDesc(_("Save databases and restart Services"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
Log(LOG_ADMIN, source, this);
Anope::QuitReason = source.command + " command received from " + source.GetNick();
@@ -56,10 +56,10 @@ class CommandOSRestart : public Command
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
- source.Reply(_("Causes Services to save all databases and then restart\n"
+ source.Reply(_("Causes services to save all databases and then restart\n"
"(i.e. exit and immediately re-run the executable)."));
return true;
}
@@ -73,7 +73,7 @@ class CommandOSShutdown : public Command
this->SetDesc(_("Terminate services with save"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
Log(LOG_ADMIN, source, this);
Anope::QuitReason = source.command + " command received from " + source.GetNick();
@@ -82,11 +82,11 @@ class CommandOSShutdown : public Command
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
- source.Reply(_("Causes Services to save all databases and then shut down."));
+ source.Reply(_("Causes services to save all databases and then shut down."));
return true;
}
};
diff --git a/modules/commands/os_stats.cpp b/modules/commands/os_stats.cpp
index 94c8365d8..2fe23ddaf 100644
--- a/modules/commands/os_stats.cpp
+++ b/modules/commands/os_stats.cpp
@@ -21,7 +21,7 @@ struct Stats : Serializable
me = this;
}
- void Serialize(Serialize::Data &data) const anope_override
+ void Serialize(Serialize::Data &data) const override
{
data["maxusercnt"] << MaxUserCount;
data["maxusertime"] << MaxUserTime;
@@ -50,8 +50,10 @@ static int stats_count_servers(Server *s)
int count = 1;
if (!s->GetLinks().empty())
- for (unsigned i = 0, j = s->GetLinks().size(); i < j; ++i)
- count += stats_count_servers(s->GetLinks()[i]);
+ {
+ for (auto *link : s->GetLinks())
+ count += stats_count_servers(link);
+ }
return count;
}
@@ -145,8 +147,8 @@ class CommandOSStats : public Command
void DoStatsUplink(CommandSource &source)
{
Anope::string buf;
- for (std::set<Anope::string>::iterator it = Servers::Capab.begin(); it != Servers::Capab.end(); ++it)
- buf += " " + *it;
+ for (const auto &capab : Servers::Capab)
+ buf += " " + capab;
if (!buf.empty())
buf.erase(buf.begin());
@@ -200,11 +202,11 @@ class CommandOSStats : public Command
CommandOSStats(Module *creator) : Command(creator, "operserv/stats", 0, 1),
akills("XLineManager", "xlinemanager/sgline"), snlines("XLineManager", "xlinemanager/snline"), sqlines("XLineManager", "xlinemanager/sqline")
{
- this->SetDesc(_("Show status of Services and network"));
+ this->SetDesc(_("Show status of services and network"));
this->SetSyntax("[AKILL | HASH | UPLINK | UPTIME | ALL | RESET]");
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
Anope::string extra = !params.empty() ? params[0] : "";
@@ -229,13 +231,13 @@ class CommandOSStats : public Command
source.Reply(_("Unknown STATS option: \002%s\002"), extra.c_str());
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
source.Reply(_("Without any option, shows the current number of users online,\n"
- "and the highest number of users online since Services was\n"
- "started, and the length of time Services has been running.\n"
+ "and the highest number of users online since services was\n"
+ "started, and the length of time services has been running.\n"
" \n"
"With the \002AKILL\002 option, displays the current size of the\n"
"AKILL list and the current default expiry time.\n"
@@ -266,7 +268,7 @@ class OSStats : public Module
}
- void OnUserConnect(User *u, bool &exempt) anope_override
+ void OnUserConnect(User *u, bool &exempt) override
{
if (UserListByNick.size() == MaxUserCount && Anope::CurTime == MaxUserTime)
stats_saver.QueueUpdate();
diff --git a/modules/commands/os_svs.cpp b/modules/commands/os_svs.cpp
index 493f0ddfd..8ac228270 100644
--- a/modules/commands/os_svs.cpp
+++ b/modules/commands/os_svs.cpp
@@ -20,7 +20,7 @@ class CommandOSSVSNick : public Command
this->SetSyntax(_("\037nick\037 \037newnick\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &nick = params[0];
Anope::string newnick = params[1];
@@ -61,7 +61,7 @@ class CommandOSSVSNick : public Command
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -79,7 +79,7 @@ class CommandOSSVSJoin : public Command
this->SetSyntax(_("\037nick\037 \037channel\037"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (!IRCD->CanSVSJoin)
{
@@ -105,7 +105,7 @@ class CommandOSSVSJoin : public Command
}
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -123,7 +123,7 @@ class CommandOSSVSPart : public Command
this->SetSyntax(_("\037nick\037 \037channel\037 [\037reason\037]"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (!IRCD->CanSVSJoin)
{
@@ -153,7 +153,7 @@ class CommandOSSVSPart : public Command
}
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
diff --git a/modules/commands/os_sxline.cpp b/modules/commands/os_sxline.cpp
index 4918a1793..f08b64933 100644
--- a/modules/commands/os_sxline.cpp
+++ b/modules/commands/os_sxline.cpp
@@ -16,13 +16,13 @@ class SXLineDelCallback : public NumberList
XLineManager *xlm;
Command *command;
CommandSource &source;
- unsigned deleted;
+ unsigned deleted = 0;
public:
- SXLineDelCallback(XLineManager *x, Command *c, CommandSource &_source, const Anope::string &numlist) : NumberList(numlist, true), xlm(x), command(c), source(_source), deleted(0)
+ SXLineDelCallback(XLineManager *x, Command *c, CommandSource &_source, const Anope::string &numlist) : NumberList(numlist, true), xlm(x), command(c), source(_source)
{
}
- ~SXLineDelCallback()
+ ~SXLineDelCallback() override
{
if (!deleted)
source.Reply(_("No matching entries on the %s list."), source.command.c_str());
@@ -32,7 +32,7 @@ class SXLineDelCallback : public NumberList
source.Reply(_("Deleted %d entries from the %s list."), deleted, source.command.c_str());
}
- void HandleNumber(unsigned number) anope_override
+ void HandleNumber(unsigned number) override
{
if (!number)
return;
@@ -128,7 +128,7 @@ class CommandOSSXLineBase : public Command
{
}
- void HandleNumber(unsigned number) anope_override
+ void HandleNumber(unsigned number) override
{
if (!number)
return;
@@ -182,8 +182,8 @@ class CommandOSSXLineBase : public Command
std::vector<Anope::string> replies;
list.Process(replies);
- for (unsigned i = 0; i < replies.size(); ++i)
- source.Reply(replies[i]);
+ for (const auto &reply : replies)
+ source.Reply(reply);
}
}
@@ -228,12 +228,12 @@ class CommandOSSXLineBase : public Command
{
}
- const Anope::string GetDesc(CommandSource &source) const anope_override
+ const Anope::string GetDesc(CommandSource &source) const override
{
return Anope::printf(Language::Translate(source.GetAccount(), _("Manipulate the %s list")), source.command.upper().c_str());
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
const Anope::string &cmd = params[0];
@@ -253,17 +253,17 @@ class CommandOSSXLineBase : public Command
return;
}
- virtual bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override = 0;
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override = 0;
};
class CommandOSSNLine : public CommandOSSXLineBase
{
- XLineManager *xlm() anope_override
+ XLineManager *xlm() override
{
return this->snlines;
}
- void OnAdd(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void OnAdd(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (!this->xlm())
return;
@@ -371,8 +371,8 @@ class CommandOSSNLine : public CommandOSSXLineBase
x->id = XLineManager::GenerateUID();
unsigned int affected = 0;
- for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
- if (this->xlm()->Check(it->second, x))
+ for (const auto &[_, user] : UserListByNick)
+ if (this->xlm()->Check(user, x))
++affected;
float percent = static_cast<float>(affected) / static_cast<float>(UserListByNick.size()) * 100.0;
@@ -401,10 +401,8 @@ class CommandOSSNLine : public CommandOSSXLineBase
{
Anope::string rreason = "G-Lined: " + reason;
- for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
+ for (const auto &[_, user] : UserListByNick)
{
- User *user = it->second;
-
if (!user->HasMode("OPER") && user->server != Me && this->xlm()->Check(user, x))
user->Kill(Me, rreason);
}
@@ -429,13 +427,13 @@ class CommandOSSNLine : public CommandOSSXLineBase
this->SetSyntax("CLEAR");
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
source.Reply(_("Allows Services Operators to manipulate the SNLINE list. If\n"
"a user with a realname matching an SNLINE mask attempts to\n"
- "connect, Services will not allow it to pursue his IRC\n"
+ "connect, services will not allow it to pursue his IRC\n"
"session."));
source.Reply(_(" \n"
"\002SNLINE ADD\002 adds the given realname mask to the SNLINE\n"
@@ -484,12 +482,12 @@ class CommandOSSNLine : public CommandOSSXLineBase
class CommandOSSQLine : public CommandOSSXLineBase
{
- XLineManager *xlm() anope_override
+ XLineManager *xlm() override
{
return this->sqlines;
}
- void OnAdd(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void OnAdd(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (!this->xlm())
return;
@@ -579,8 +577,8 @@ class CommandOSSQLine : public CommandOSSXLineBase
x->id = XLineManager::GenerateUID();
unsigned int affected = 0;
- for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
- if (this->xlm()->Check(it->second, x))
+ for (const auto &[_, user] : UserListByNick)
+ if (this->xlm()->Check(user, x))
++affected;
float percent = static_cast<float>(affected) / static_cast<float>(UserListByNick.size()) * 100.0;
@@ -611,33 +609,28 @@ class CommandOSSQLine : public CommandOSSXLineBase
if (mask[0] == '#')
{
- for (channel_map::const_iterator cit = ChannelList.begin(), cit_end = ChannelList.end(); cit != cit_end; ++cit)
+ for (const auto &[_, c] : ChannelList)
{
- Channel *c = cit->second;
-
if (!Anope::Match(c->name, mask, false, true))
continue;
std::vector<User *> users;
- for (Channel::ChanUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it)
+ for (const auto &[_, uc] : c->users)
{
- ChanUserContainer *uc = it->second;
User *user = uc->user;
if (!user->HasMode("OPER") && user->server != Me)
users.push_back(user);
}
- for (unsigned i = 0; i < users.size(); ++i)
- c->Kick(NULL, users[i], "%s", reason.c_str());
+ for (auto *user : users)
+ c->Kick(NULL, user, "%s", reason.c_str());
}
}
else
{
- for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
+ for (const auto &[_, user] : UserListByNick)
{
- User *user = it->second;
-
if (!user->HasMode("OPER") && user->server != Me && this->xlm()->Check(user, x))
user->Kill(Me, rreason);
}
@@ -663,13 +656,13 @@ class CommandOSSQLine : public CommandOSSXLineBase
this->SetSyntax("CLEAR");
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
source.Reply(_("Allows Services Operators to manipulate the SQLINE list. If\n"
"a user with a nick matching an SQLINE mask attempts to\n"
- "connect, Services will not allow it to pursue his IRC\n"
+ "connect, services will not allow it to pursue his IRC\n"
"session.\n"
"If the first character of the mask is #, services will\n"
"prevent the use of matching channels. If the mask is a\n"
diff --git a/modules/commands/os_update.cpp b/modules/commands/os_update.cpp
index af2a008dd..1b88e4b0d 100644
--- a/modules/commands/os_update.cpp
+++ b/modules/commands/os_update.cpp
@@ -16,10 +16,10 @@ class CommandOSUpdate : public Command
public:
CommandOSUpdate(Module *creator) : Command(creator, "operserv/update", 0, 0)
{
- this->SetDesc(_("Force the Services databases to be updated immediately"));
+ this->SetDesc(_("Force the services databases to be updated immediately"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
Log(LOG_ADMIN, source, this);
source.Reply(_("Updating databases."));
@@ -27,11 +27,11 @@ class CommandOSUpdate : public Command
return;
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
- source.Reply(_("Causes Services to update all database files as soon as you\n"
+ source.Reply(_("Causes services to update all database files as soon as you\n"
"send the command."));
return true;
}
diff --git a/modules/cs_statusupdate.cpp b/modules/cs_statusupdate.cpp
index 5b7d7614d..c871489fc 100644
--- a/modules/cs_statusupdate.cpp
+++ b/modules/cs_statusupdate.cpp
@@ -16,49 +16,51 @@ class StatusUpdate : public Module
}
- void OnAccessAdd(ChannelInfo *ci, CommandSource &, ChanAccess *access) anope_override
+ void OnAccessAdd(ChannelInfo *ci, CommandSource &, ChanAccess *access) override
{
if (ci->c)
- for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
+ {
+ for (const auto &[_, uc] : ci->c->users)
{
- User *user = it->second->user;
+ User *user = uc->user;
ChannelInfo *next;
if (user->server != Me && access->Matches(user, user->Account(), next))
{
AccessGroup ag = ci->AccessFor(user);
- for (unsigned i = 0; i < ModeManager::GetStatusChannelModesByRank().size(); ++i)
+ for (auto *cms : ModeManager::GetStatusChannelModesByRank())
{
- ChannelModeStatus *cms = ModeManager::GetStatusChannelModesByRank()[i];
if (!ag.HasPriv("AUTO" + cms->name))
ci->c->RemoveMode(NULL, cms, user->GetUID());
}
ci->c->SetCorrectModes(user, true);
}
}
+ }
}
- void OnAccessDel(ChannelInfo *ci, CommandSource &, ChanAccess *access) anope_override
+ void OnAccessDel(ChannelInfo *ci, CommandSource &, ChanAccess *access) override
{
if (ci->c)
- for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
+ {
+ for (const auto &[_, uc] : ci->c->users)
{
- User *user = it->second->user;
+ User *user = uc->user;
ChannelInfo *next;
if (user->server != Me && access->Matches(user, user->Account(), next))
{
AccessGroup ag = ci->AccessFor(user);
- for (unsigned i = 0; i < ModeManager::GetStatusChannelModesByRank().size(); ++i)
+ for (auto *cms : ModeManager::GetStatusChannelModesByRank())
{
- ChannelModeStatus *cms = ModeManager::GetStatusChannelModesByRank()[i];
- if (!ag.HasPriv("AUTO" + cms->name))
+ if (!ag.HasPriv("AUTO" + cms->name))
ci->c->RemoveMode(NULL, cms, user->GetUID());
}
}
}
+ }
}
};
diff --git a/modules/database/db_flatfile.cpp b/modules/database/db_flatfile.cpp
index 5f7d5c770..7841a57cf 100644
--- a/modules/database/db_flatfile.cpp
+++ b/modules/database/db_flatfile.cpp
@@ -19,11 +19,9 @@ class SaveData : public Serialize::Data
{
public:
Anope::string last;
- std::fstream *fs;
+ std::fstream *fs = nullptr;
- SaveData() : fs(NULL) { }
-
- std::iostream& operator[](const Anope::string &key) anope_override
+ std::iostream& operator[](const Anope::string &key) override
{
if (key != last)
{
@@ -38,15 +36,13 @@ class SaveData : public Serialize::Data
class LoadData : public Serialize::Data
{
public:
- std::fstream *fs;
- unsigned int id;
+ std::fstream *fs = nullptr;
+ unsigned int id = 0;
std::map<Anope::string, Anope::string> data;
std::stringstream ss;
- bool read;
-
- LoadData() : fs(NULL), id(0), read(false) { }
+ bool read = false;
- std::iostream& operator[](const Anope::string &key) anope_override
+ std::iostream& operator[](const Anope::string &key) override
{
if (!read)
{
@@ -78,20 +74,20 @@ class LoadData : public Serialize::Data
return this->ss;
}
- std::set<Anope::string> KeySet() const anope_override
+ std::set<Anope::string> KeySet() const override
{
std::set<Anope::string> keys;
- for (std::map<Anope::string, Anope::string>::const_iterator it = this->data.begin(), it_end = this->data.end(); it != it_end; ++it)
- keys.insert(it->first);
+ for (const auto &[key, _]: this->data)
+ keys.insert(key);
return keys;
}
- size_t Hash() const anope_override
+ size_t Hash() const override
{
size_t hash = 0;
- for (std::map<Anope::string, Anope::string>::const_iterator it = this->data.begin(), it_end = this->data.end(); it != it_end; ++it)
- if (!it->second.empty())
- hash ^= Anope::hash_cs()(it->second);
+ for (const auto &[_, value] : this->data)
+ if (!value.empty())
+ hash ^= Anope::hash_cs()(value);
return hash;
}
@@ -106,12 +102,12 @@ class LoadData : public Serialize::Data
class DBFlatFile : public Module, public Pipe
{
/* Day the last backup was on */
- int last_day;
+ int last_day = 0;
/* Backup file names */
std::map<Anope::string, std::list<Anope::string> > backups;
- bool loaded;
+ bool loaded = false;
- int child_pid;
+ int child_pid = -1;
void BackupDatabase()
{
@@ -121,69 +117,67 @@ class DBFlatFile : public Module, public Pipe
{
last_day = tm->tm_mday;
- const std::vector<Anope::string> &type_order = Serialize::Type::GetTypeOrder();
-
std::set<Anope::string> dbs;
dbs.insert(Config->GetModule(this)->Get<const Anope::string>("database", "anope.db"));
- for (unsigned i = 0; i < type_order.size(); ++i)
+ for (const auto &type_order : Serialize::Type::GetTypeOrder())
{
- Serialize::Type *stype = Serialize::Type::Find(type_order[i]);
+ Serialize::Type *stype = Serialize::Type::Find(type_order);
if (stype && stype->GetOwner())
dbs.insert("module_" + stype->GetOwner()->name + ".db");
}
- for (std::set<Anope::string>::const_iterator it = dbs.begin(), it_end = dbs.end(); it != it_end; ++it)
+ for (const auto &db : dbs)
{
- const Anope::string &oldname = Anope::DataDir + "/" + *it;
- Anope::string newname = Anope::DataDir + "/backups/" + *it + "-" + stringify(tm->tm_year + 1900) + Anope::printf("-%02i-", tm->tm_mon + 1) + Anope::printf("%02i", tm->tm_mday);
+ const Anope::string &oldname = Anope::DataDir + "/" + db;
+ Anope::string newname = Anope::DataDir + "/backups/" + db + "-" + stringify(tm->tm_year + 1900) + Anope::printf("-%02i-", tm->tm_mon + 1) + Anope::printf("%02i", tm->tm_mday);
/* Backup already exists or no database to backup */
if (Anope::IsFile(newname) || !Anope::IsFile(oldname))
continue;
- Log(LOG_DEBUG) << "db_flatfile: Attempting to rename " << *it << " to " << newname;
+ Log(LOG_DEBUG) << "db_flatfile: Attempting to rename " << db << " to " << newname;
if (rename(oldname.c_str(), newname.c_str()))
{
Anope::string err = Anope::LastError();
- Log(this) << "Unable to back up database " << *it << " (" << err << ")!";
+ Log(this) << "Unable to back up database " << db << " (" << err << ")!";
if (!Config->GetModule(this)->Get<bool>("nobackupokay"))
{
Anope::Quitting = true;
- Anope::QuitReason = "Unable to back up database " + *it + " (" + err + ")";
+ Anope::QuitReason = "Unable to back up database " + db + " (" + err + ")";
}
continue;
}
- backups[*it].push_back(newname);
+ backups[db].push_back(newname);
unsigned keepbackups = Config->GetModule(this)->Get<unsigned>("keepbackups");
- if (keepbackups > 0 && backups[*it].size() > keepbackups)
+ if (keepbackups > 0 && backups[db].size() > keepbackups)
{
- unlink(backups[*it].front().c_str());
- backups[*it].pop_front();
+ unlink(backups[db].front().c_str());
+ backups[db].pop_front();
}
}
}
}
public:
- DBFlatFile(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, DATABASE | VENDOR), last_day(0), loaded(false), child_pid(-1)
+ DBFlatFile(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, DATABASE | VENDOR)
{
}
#ifndef _WIN32
- void OnRestart() anope_override
+ void OnRestart() override
{
OnShutdown();
}
- void OnShutdown() anope_override
+ void OnShutdown() override
{
if (child_pid > -1)
{
@@ -197,7 +191,7 @@ class DBFlatFile : public Module, public Pipe
}
#endif
- void OnNotify() anope_override
+ void OnNotify() override
{
char buf[512];
int i = this->Read(buf, sizeof(buf) - 1);
@@ -219,9 +213,8 @@ class DBFlatFile : public Module, public Pipe
Anope::Quitting = true;
}
- EventReturn OnLoadDatabase() anope_override
+ EventReturn OnLoadDatabase() override
{
- const std::vector<Anope::string> &type_order = Serialize::Type::GetTypeOrder();
std::set<Anope::string> tried_dbs;
const Anope::string &db_name = Anope::DataDir + "/" + Config->GetModule(this)->Get<const Anope::string>("database", "anope.db");
@@ -242,18 +235,16 @@ class DBFlatFile : public Module, public Pipe
LoadData ld;
ld.fs = &fd;
- for (unsigned i = 0; i < type_order.size(); ++i)
+ for (const auto &type_order : Serialize::Type::GetTypeOrder())
{
- Serialize::Type *stype = Serialize::Type::Find(type_order[i]);
+ Serialize::Type *stype = Serialize::Type::Find(type_order);
if (!stype || stype->GetOwner())
continue;
- std::vector<std::streampos> &pos = positions[stype->GetName()];
-
- for (unsigned j = 0; j < pos.size(); ++j)
+ for (const auto &position : positions[stype->GetName()])
{
fd.clear();
- fd.seekg(pos[j]);
+ fd.seekg(position);
Serializable *obj = stype->Unserialize(NULL, ld);
if (obj != NULL)
@@ -269,7 +260,7 @@ class DBFlatFile : public Module, public Pipe
}
- void OnSaveDatabase() anope_override
+ void OnSaveDatabase() override
{
if (child_pid > -1)
{
@@ -299,10 +290,8 @@ class DBFlatFile : public Module, public Pipe
std::map<Module *, std::fstream *> databases;
/* First open the databases of all of the registered types. This way, if we have a type with 0 objects, that database will be properly cleared */
- for (std::map<Anope::string, Serialize::Type *>::const_iterator it = Serialize::Type::GetTypes().begin(), it_end = Serialize::Type::GetTypes().end(); it != it_end; ++it)
+ for (const auto &[_, s_type] : Serialize::Type::GetTypes())
{
- Serialize::Type *s_type = it->second;
-
if (databases[s_type->GetOwner()])
continue;
@@ -320,9 +309,8 @@ class DBFlatFile : public Module, public Pipe
SaveData data;
const std::list<Serializable *> &items = Serializable::GetItems();
- for (std::list<Serializable *>::const_iterator it = items.begin(), it_end = items.end(); it != it_end; ++it)
+ for (auto *base : items)
{
- Serializable *base = *it;
Serialize::Type *s_type = base->GetSerializableType();
data.fs = databases[s_type->GetOwner()];
@@ -336,10 +324,9 @@ class DBFlatFile : public Module, public Pipe
*data.fs << "\nEND\n";
}
- for (std::map<Module *, std::fstream *>::iterator it = databases.begin(), it_end = databases.end(); it != it_end; ++it)
+ for (auto &[mod, f] : databases)
{
- std::fstream *f = it->second;
- const Anope::string &db_name = Anope::DataDir + "/" + (it->first ? (it->first->name + ".db") : Config->GetModule(this)->Get<const Anope::string>("database", "anope.db"));
+ const Anope::string &db_name = Anope::DataDir + "/" + (mod ? (mod->name + ".db") : Config->GetModule(this)->Get<const Anope::string>("database", "anope.db"));
if (!f->is_open() || !f->good())
{
@@ -374,7 +361,7 @@ class DBFlatFile : public Module, public Pipe
}
/* Load just one type. Done if a module is reloaded during runtime */
- void OnSerializeTypeCreate(Serialize::Type *stype) anope_override
+ void OnSerializeTypeCreate(Serialize::Type *stype) override
{
if (!loaded)
return;
diff --git a/modules/database/db_old.cpp b/modules/database/db_old.cpp
index 492c5faa8..f8663b395 100644
--- a/modules/database/db_old.cpp
+++ b/modules/database/db_old.cpp
@@ -146,20 +146,22 @@ enum
static void process_mlock(ChannelInfo *ci, uint32_t lock, bool status, uint32_t *limit, Anope::string *key)
{
ModeLocks *ml = ci->Require<ModeLocks>("modelocks");
- for (unsigned i = 0; i < (sizeof(mlock_infos) / sizeof(mlock_info)); ++i)
- if (lock & mlock_infos[i].m)
+ for (auto &mlock_info : mlock_infos)
+ {
+ if (lock & mlock_info.m)
{
- ChannelMode *cm = ModeManager::FindChannelModeByChar(mlock_infos[i].c);
+ ChannelMode *cm = ModeManager::FindChannelModeByChar(mlock_info.c);
if (cm && ml)
{
- if (limit && mlock_infos[i].c == 'l')
+ if (limit && mlock_info.c == 'l')
ml->SetMLock(cm, status, stringify(*limit));
- else if (key && mlock_infos[i].c == 'k')
+ else if (key && mlock_info.c == 'k')
ml->SetMLock(cm, status, *key);
else
ml->SetMLock(cm, status);
}
}
+ }
}
static const char Base64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
@@ -449,8 +451,8 @@ static void LoadNicks()
const Anope::string settings[] = { "killprotect", "kill_quick", "ns_secure", "ns_private", "hide_email",
"hide_mask", "hide_quit", "memo_signon", "memo_receive", "autoop", "msg", "ns_keepmodes" };
- for (unsigned j = 0; j < sizeof(settings) / sizeof(Anope::string); ++j)
- nc->Shrink<bool>(settings[j].upper());
+ for (const auto &setting : settings)
+ nc->Shrink<bool>(setting.upper());
char pwbuf[32];
READ(read_buffer(pwbuf, f));
@@ -752,8 +754,8 @@ static void LoadChannels()
const Anope::string settings[] = { "keeptopic", "peace", "cs_private", "restricted", "cs_secure", "secureops", "securefounder",
"signkick", "signkick_level", "topiclock", "persist", "noautoop", "cs_keepmodes" };
- for (unsigned j = 0; j < sizeof(settings) / sizeof(Anope::string); ++j)
- ci->Shrink<bool>(settings[j].upper());
+ for (const auto &setting : settings)
+ ci->Shrink<bool>(setting.upper());
READ(read_string(buffer, f));
ci->SetFounder(NickCore::Find(buffer));
@@ -1104,9 +1106,8 @@ static void LoadOper()
XLineManager *akill, *sqline, *snline, *szline;
akill = sqline = snline = szline = NULL;
- for (std::list<XLineManager *>::iterator it = XLineManager::XLineManagers.begin(), it_end = XLineManager::XLineManagers.end(); it != it_end; ++it)
+ for (auto *xl : XLineManager::XLineManagers)
{
- XLineManager *xl = *it;
if (xl->Type() == 'G')
akill = xl;
else if (xl->Type() == 'Q')
@@ -1313,7 +1314,7 @@ class DBOld : public Module
throw ModuleException("Invalid hash method");
}
- EventReturn OnLoadDatabase() anope_override
+ EventReturn OnLoadDatabase() override
{
LoadNicks();
LoadVHosts();
@@ -1326,11 +1327,10 @@ class DBOld : public Module
return EVENT_STOP;
}
- void OnUplinkSync(Server *s) anope_override
+ void OnUplinkSync(Server *s) override
{
- for (registered_channel_map::iterator it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; ++it)
+ for (auto &[_, ci] : *RegisteredChannelList)
{
- ChannelInfo *ci = it->second;
uint32_t *limit = mlock_limit.Get(ci);
Anope::string *key = mlock_key.Get(ci);
diff --git a/modules/database/db_redis.cpp b/modules/database/db_redis.cpp
index 80fad06b2..4c90d179d 100644
--- a/modules/database/db_redis.cpp
+++ b/modules/database/db_redis.cpp
@@ -19,13 +19,13 @@ class Data : public Serialize::Data
public:
std::map<Anope::string, std::stringstream *> data;
- ~Data()
+ ~Data() override
{
- for (std::map<Anope::string, std::stringstream *>::iterator it = data.begin(), it_end = data.end(); it != it_end; ++it)
- delete it->second;
+ for (auto &[_, stream] : data)
+ delete stream;
}
- std::iostream& operator[](const Anope::string &key) anope_override
+ std::iostream& operator[](const Anope::string &key) override
{
std::stringstream* &stream = data[key];
if (!stream)
@@ -33,20 +33,20 @@ class Data : public Serialize::Data
return *stream;
}
- std::set<Anope::string> KeySet() const anope_override
+ std::set<Anope::string> KeySet() const override
{
std::set<Anope::string> keys;
- for (std::map<Anope::string, std::stringstream *>::const_iterator it = this->data.begin(), it_end = this->data.end(); it != it_end; ++it)
- keys.insert(it->first);
+ for (const auto &[key, _] : this->data)
+ keys.insert(key);
return keys;
}
- size_t Hash() const anope_override
+ size_t Hash() const override
{
size_t hash = 0;
- for (std::map<Anope::string, std::stringstream *>::const_iterator it = this->data.begin(), it_end = this->data.end(); it != it_end; ++it)
- if (!it->second->str().empty())
- hash ^= Anope::hash_cs()(it->second->str());
+ for (const auto &[_, value] : this->data)
+ if (!value->str().empty())
+ hash ^= Anope::hash_cs()(value->str());
return hash;
}
};
@@ -57,7 +57,7 @@ class TypeLoader : public Interface
public:
TypeLoader(Module *creator, const Anope::string &t) : Interface(creator), type(t) { }
- void OnResult(const Reply &r) anope_override;
+ void OnResult(const Reply &r) override;
};
class ObjectLoader : public Interface
@@ -68,7 +68,7 @@ class ObjectLoader : public Interface
public:
ObjectLoader(Module *creator, const Anope::string &t, int64_t i) : Interface(creator), type(t), id(i) { }
- void OnResult(const Reply &r) anope_override;
+ void OnResult(const Reply &r) override;
};
class IDInterface : public Interface
@@ -77,7 +77,7 @@ class IDInterface : public Interface
public:
IDInterface(Module *creator, Serializable *obj) : Interface(creator), o(obj) { }
- void OnResult(const Reply &r) anope_override;
+ void OnResult(const Reply &r) override;
};
class Deleter : public Interface
@@ -87,7 +87,7 @@ class Deleter : public Interface
public:
Deleter(Module *creator, const Anope::string &t, int64_t i) : Interface(creator), type(t), id(i) { }
- void OnResult(const Reply &r) anope_override;
+ void OnResult(const Reply &r) override;
};
class Updater : public Interface
@@ -97,7 +97,7 @@ class Updater : public Interface
public:
Updater(Module *creator, const Anope::string &t, int64_t i) : Interface(creator), type(t), id(i) { }
- void OnResult(const Reply &r) anope_override;
+ void OnResult(const Reply &r) override;
};
class ModifiedObject : public Interface
@@ -107,7 +107,7 @@ class ModifiedObject : public Interface
public:
ModifiedObject(Module *creator, const Anope::string &t, int64_t i) : Interface(creator), type(t), id(i) { }
- void OnResult(const Reply &r) anope_override;
+ void OnResult(const Reply &r) override;
};
class SubscriptionListener : public Interface
@@ -115,7 +115,7 @@ class SubscriptionListener : public Interface
public:
SubscriptionListener(Module *creator) : Interface(creator) { }
- void OnResult(const Reply &r) anope_override;
+ void OnResult(const Reply &r) override;
};
class DatabaseRedis : public Module, public Pipe
@@ -151,7 +151,7 @@ class DatabaseRedis : public Module, public Pipe
obj->UpdateCache(data);
std::vector<Anope::string> args;
- args.push_back("HGETALL");
+ args.emplace_back("HGETALL");
args.push_back("hash:" + t->GetName() + ":" + stringify(obj->id));
/* Get object attrs to clear before updating */
@@ -159,25 +159,23 @@ class DatabaseRedis : public Module, public Pipe
}
}
- void OnNotify() anope_override
+ void OnNotify() override
{
- for (std::set<Serializable *>::iterator it = this->updated_items.begin(), it_end = this->updated_items.end(); it != it_end; ++it)
+ for (auto *obj : this->updated_items)
{
- Serializable *s = *it;
-
- this->InsertObject(s);
+ this->InsertObject(obj);
}
this->updated_items.clear();
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
Configuration::Block *block = conf->GetModule(this);
this->redis = ServiceReference<Provider>("Redis::Provider", block->Get<const Anope::string>("engine", "redis/main"));
}
- EventReturn OnLoadDatabase() anope_override
+ EventReturn OnLoadDatabase() override
{
if (!redis)
{
@@ -185,10 +183,9 @@ class DatabaseRedis : public Module, public Pipe
return EVENT_CONTINUE;
}
- const std::vector<Anope::string> type_order = Serialize::Type::GetTypeOrder();
- for (unsigned i = 0; i < type_order.size(); ++i)
+ for (const auto &type_order : Serialize::Type::GetTypeOrder())
{
- Serialize::Type *sb = Serialize::Type::Find(type_order[i]);
+ Serialize::Type *sb = Serialize::Type::Find(type_order);
this->OnSerializeTypeCreate(sb);
}
@@ -205,25 +202,25 @@ class DatabaseRedis : public Module, public Pipe
return EVENT_STOP;
}
- void OnSerializeTypeCreate(Serialize::Type *sb) anope_override
+ void OnSerializeTypeCreate(Serialize::Type *sb) override
{
if (!redis)
return;
std::vector<Anope::string> args;
- args.push_back("SMEMBERS");
+ args.emplace_back("SMEMBERS");
args.push_back("ids:" + sb->GetName());
redis->SendCommand(new TypeLoader(this, sb->GetName()), args);
}
- void OnSerializableConstruct(Serializable *obj) anope_override
+ void OnSerializableConstruct(Serializable *obj) override
{
this->updated_items.insert(obj);
this->Notify();
}
- void OnSerializableDestruct(Serializable *obj) anope_override
+ void OnSerializableDestruct(Serializable *obj) override
{
Serialize::Type *t = obj->GetSerializableType();
@@ -240,7 +237,7 @@ class DatabaseRedis : public Module, public Pipe
}
std::vector<Anope::string> args;
- args.push_back("HGETALL");
+ args.emplace_back("HGETALL");
args.push_back("hash:" + t->GetName() + ":" + stringify(obj->id));
/* Get all of the attributes for this object */
@@ -251,7 +248,7 @@ class DatabaseRedis : public Module, public Pipe
this->Notify();
}
- void OnSerializableUpdate(Serializable *obj) anope_override
+ void OnSerializableUpdate(Serializable *obj) override
{
this->updated_items.insert(obj);
this->Notify();
@@ -266,10 +263,8 @@ void TypeLoader::OnResult(const Reply &r)
return;
}
- for (unsigned i = 0; i < r.multi_bulk.size(); ++i)
+ for (auto *reply : r.multi_bulk)
{
- const Reply *reply = r.multi_bulk[i];
-
if (reply->type != Reply::BULK)
continue;
@@ -284,7 +279,7 @@ void TypeLoader::OnResult(const Reply &r)
}
std::vector<Anope::string> args;
- args.push_back("HGETALL");
+ args.emplace_back("HGETALL");
args.push_back("hash:" + this->type + ":" + stringify(id));
me->redis->SendCommand(new ObjectLoader(me, this->type, id), args);
@@ -358,14 +353,14 @@ void Deleter::OnResult(const Reply &r)
me->redis->StartTransaction();
std::vector<Anope::string> args;
- args.push_back("DEL");
+ args.emplace_back("DEL");
args.push_back("hash:" + this->type + ":" + stringify(this->id));
/* Delete hash object */
me->redis->SendCommand(NULL, args);
args.clear();
- args.push_back("SREM");
+ args.emplace_back("SREM");
args.push_back("ids:" + this->type);
args.push_back(stringify(this->id));
@@ -378,7 +373,7 @@ void Deleter::OnResult(const Reply &r)
*value = r.multi_bulk[i + 1];
args.clear();
- args.push_back("SREM");
+ args.emplace_back("SREM");
args.push_back("value:" + this->type + ":" + key->bulk + ":" + value->bulk);
args.push_back(stringify(this->id));
@@ -421,7 +416,7 @@ void Updater::OnResult(const Reply &r)
*value = r.multi_bulk[i + 1];
std::vector<Anope::string> args;
- args.push_back("SREM");
+ args.emplace_back("SREM");
args.push_back("value:" + this->type + ":" + key->bulk + ":" + value->bulk);
args.push_back(stringify(this->id));
@@ -431,27 +426,23 @@ void Updater::OnResult(const Reply &r)
/* Add object id to id set for this type */
std::vector<Anope::string> args;
- args.push_back("SADD");
+ args.emplace_back("SADD");
args.push_back("ids:" + this->type);
args.push_back(stringify(obj->id));
me->redis->SendCommand(NULL, args);
args.clear();
- args.push_back("HMSET");
+ args.emplace_back("HMSET");
args.push_back("hash:" + this->type + ":" + stringify(obj->id));
- typedef std::map<Anope::string, std::stringstream *> items;
- for (items::iterator it = data.data.begin(), it_end = data.data.end(); it != it_end; ++it)
+ for (const auto &[key, value] : data.data)
{
- const Anope::string &key = it->first;
- std::stringstream *value = it->second;
-
args.push_back(key);
- args.push_back(value->str());
+ args.emplace_back(value->str());
std::vector<Anope::string> args2;
- args2.push_back("SADD");
+ args2.emplace_back("SADD");
args2.push_back("value:" + this->type + ":" + key + ":" + value->str());
args2.push_back(stringify(obj->id));
@@ -528,7 +519,7 @@ void SubscriptionListener::OnResult(const Reply &r)
Log(LOG_DEBUG) << "redis: notify: got modify for object id " << obj_id << " of type " << type;
std::vector<Anope::string> args;
- args.push_back("HGETALL");
+ args.emplace_back("HGETALL");
args.push_back("hash:" + type + ":" + id);
me->redis->SendCommand(new ModifiedObject(me, type, obj_id), args);
@@ -549,14 +540,10 @@ void SubscriptionListener::OnResult(const Reply &r)
/* Transaction start */
me->redis->StartTransaction();
- typedef std::map<Anope::string, std::stringstream *> items;
- for (items::iterator it = data.data.begin(), it_end = data.data.end(); it != it_end; ++it)
+ for (const auto &[k, value] : data.data)
{
- const Anope::string &k = it->first;
- std::stringstream *value = it->second;
-
std::vector<Anope::string> args;
- args.push_back("SREM");
+ args.emplace_back("SREM");
args.push_back("value:" + type + ":" + k + ":" + value->str());
args.push_back(id);
@@ -565,7 +552,7 @@ void SubscriptionListener::OnResult(const Reply &r)
}
std::vector<Anope::string> args;
- args.push_back("SREM");
+ args.emplace_back("SREM");
args.push_back("ids:" + type);
args.push_back(stringify(s->id));
@@ -602,14 +589,10 @@ void ModifiedObject::OnResult(const Reply &r)
obj->Serialize(data);
- typedef std::map<Anope::string, std::stringstream *> items;
- for (items::iterator it = data.data.begin(), it_end = data.data.end(); it != it_end; ++it)
+ for (auto &[key, value] : data.data)
{
- const Anope::string &key = it->first;
- std::stringstream *value = it->second;
-
std::vector<Anope::string> args;
- args.push_back("SREM");
+ args.emplace_back("SREM");
args.push_back("value:" + st->GetName() + ":" + key + ":" + value->str());
args.push_back(stringify(this->id));
@@ -635,14 +618,10 @@ void ModifiedObject::OnResult(const Reply &r)
obj->UpdateCache(data);
/* Insert new object values */
- typedef std::map<Anope::string, std::stringstream *> items;
- for (items::iterator it = data.data.begin(), it_end = data.data.end(); it != it_end; ++it)
+ for (const auto &[key, value] : data.data)
{
- const Anope::string &key = it->first;
- std::stringstream *value = it->second;
-
std::vector<Anope::string> args;
- args.push_back("SADD");
+ args.emplace_back("SADD");
args.push_back("value:" + st->GetName() + ":" + key + ":" + value->str());
args.push_back(stringify(obj->id));
@@ -651,7 +630,7 @@ void ModifiedObject::OnResult(const Reply &r)
}
std::vector<Anope::string> args;
- args.push_back("SADD");
+ args.emplace_back("SADD");
args.push_back("ids:" + st->GetName());
args.push_back(stringify(obj->id));
diff --git a/modules/database/db_sql.cpp b/modules/database/db_sql.cpp
index 1094fb9a9..f508c1615 100644
--- a/modules/database/db_sql.cpp
+++ b/modules/database/db_sql.cpp
@@ -19,12 +19,12 @@ class SQLSQLInterface : public Interface
public:
SQLSQLInterface(Module *o) : Interface(o) { }
- void OnResult(const Result &r) anope_override
+ void OnResult(const Result &r) override
{
Log(LOG_DEBUG) << "SQL successfully executed query: " << r.finished_query;
}
- void OnError(const Result &r) anope_override
+ void OnError(const Result &r) override
{
if (!r.GetQuery().query.empty())
Log(LOG_DEBUG) << "Error executing query " << r.finished_query << ": " << r.GetError();
@@ -40,7 +40,7 @@ class ResultSQLSQLInterface : public SQLSQLInterface
public:
ResultSQLSQLInterface(Module *o, Serializable *ob) : SQLSQLInterface(o), obj(ob) { }
- void OnResult(const Result &r) anope_override
+ void OnResult(const Result &r) override
{
SQLSQLInterface::OnResult(r);
if (r.GetID() > 0 && this->obj)
@@ -48,7 +48,7 @@ public:
delete this;
}
- void OnError(const Result &r) anope_override
+ void OnError(const Result &r) override
{
SQLSQLInterface::OnError(r);
delete this;
@@ -63,10 +63,10 @@ class DBSQL : public Module, public Pipe
bool import;
std::set<Serializable *> updated_items;
- bool shutting_down;
- bool loading_databases;
- bool loaded;
- bool imported;
+ bool shutting_down = false;
+ bool loading_databases = false;
+ bool loaded = false;
+ bool imported = false;
void RunBackground(const Query &q, Interface *iface = NULL)
{
@@ -90,7 +90,7 @@ class DBSQL : public Module, public Pipe
}
public:
- DBSQL(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, DATABASE | VENDOR), sql("", ""), sqlinterface(this), shutting_down(false), loading_databases(false), loaded(false), imported(false)
+ DBSQL(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, DATABASE | VENDOR), sql("", ""), sqlinterface(this)
{
@@ -98,12 +98,10 @@ class DBSQL : public Module, public Pipe
throw ModuleException("db_sql can not be loaded after db_sql_live");
}
- void OnNotify() anope_override
+ void OnNotify() override
{
- for (std::set<Serializable *>::iterator it = this->updated_items.begin(), it_end = this->updated_items.end(); it != it_end; ++it)
+ for (auto *obj : this->updated_items)
{
- Serializable *obj = *it;
-
if (this->sql)
{
Data data;
@@ -127,15 +125,15 @@ class DBSQL : public Module, public Pipe
if (this->imported)
{
- for (unsigned i = 0; i < create.size(); ++i)
- this->RunBackground(create[i]);
+ for (const auto &query : create)
+ this->RunBackground(query);
this->RunBackground(insert, new ResultSQLSQLInterface(this, obj));
}
else
{
- for (unsigned i = 0; i < create.size(); ++i)
- this->sql->RunQuery(create[i]);
+ for (const auto &query : create)
+ this->sql->RunQuery(query);
/* We are importing objects from another database module, so don't do asynchronous
* queries in case the core has to shut down, it will cut short the import
@@ -151,7 +149,7 @@ class DBSQL : public Module, public Pipe
this->imported = true;
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
Configuration::Block *block = conf->GetModule(this);
this->sql = ServiceReference<Provider>("SQL::Provider", block->Get<const Anope::string>("engine"));
@@ -159,18 +157,18 @@ class DBSQL : public Module, public Pipe
this->import = block->Get<bool>("import");
}
- void OnShutdown() anope_override
+ void OnShutdown() override
{
this->shutting_down = true;
this->OnNotify();
}
- void OnRestart() anope_override
+ void OnRestart() override
{
this->OnShutdown();
}
- EventReturn OnLoadDatabase() anope_override
+ EventReturn OnLoadDatabase() override
{
if (!this->sql)
{
@@ -180,10 +178,9 @@ class DBSQL : public Module, public Pipe
this->loading_databases = true;
- const std::vector<Anope::string> type_order = Serialize::Type::GetTypeOrder();
- for (unsigned i = 0; i < type_order.size(); ++i)
+ for (const auto &type_order : Serialize::Type::GetTypeOrder())
{
- Serialize::Type *sb = Serialize::Type::Find(type_order[i]);
+ Serialize::Type *sb = Serialize::Type::Find(type_order);
this->OnSerializeTypeCreate(sb);
}
@@ -193,7 +190,7 @@ class DBSQL : public Module, public Pipe
return EVENT_STOP;
}
- void OnSerializableConstruct(Serializable *obj) anope_override
+ void OnSerializableConstruct(Serializable *obj) override
{
if (this->shutting_down || this->loading_databases)
return;
@@ -202,7 +199,7 @@ class DBSQL : public Module, public Pipe
this->Notify();
}
- void OnSerializableDestruct(Serializable *obj) anope_override
+ void OnSerializableDestruct(Serializable *obj) override
{
if (this->shutting_down)
return;
@@ -212,7 +209,7 @@ class DBSQL : public Module, public Pipe
this->updated_items.erase(obj);
}
- void OnSerializableUpdate(Serializable *obj) anope_override
+ void OnSerializableUpdate(Serializable *obj) override
{
if (this->shutting_down || obj->IsTSCached())
return;
@@ -223,7 +220,7 @@ class DBSQL : public Module, public Pipe
this->Notify();
}
- void OnSerializeTypeCreate(Serialize::Type *sb) anope_override
+ void OnSerializeTypeCreate(Serialize::Type *sb) override
{
if (!this->loading_databases && !this->loaded)
return;
@@ -235,9 +232,8 @@ class DBSQL : public Module, public Pipe
{
Data data;
- const std::map<Anope::string, Anope::string> &row = res.Row(j);
- for (std::map<Anope::string, Anope::string>::const_iterator rit = row.begin(), rit_end = row.end(); rit != rit_end; ++rit)
- data[rit->first] << rit->second;
+ for (const auto &[key, value] : res.Row(j))
+ data[key] << value;
Serializable *obj = sb->Unserialize(NULL, data);
try
diff --git a/modules/database/db_sql_live.cpp b/modules/database/db_sql_live.cpp
index 509bcdc12..825628127 100644
--- a/modules/database/db_sql_live.cpp
+++ b/modules/database/db_sql_live.cpp
@@ -83,15 +83,13 @@ class DBMySQL : public Module, public Pipe
throw ModuleException("If db_sql_live is loaded it must be the first database module loaded.");
}
- void OnNotify() anope_override
+ void OnNotify() override
{
if (!this->CheckInit())
return;
- for (std::set<Serializable *>::iterator it = this->updated_items.begin(), it_end = this->updated_items.end(); it != it_end; ++it)
+ for (auto *obj : this->updated_items)
{
- Serializable *obj = *it;
-
if (obj && this->SQL)
{
Data data;
@@ -107,8 +105,8 @@ class DBMySQL : public Module, public Pipe
continue;
std::vector<Query> create = this->SQL->CreateTable(this->prefix + s_type->GetName(), data);
- for (unsigned i = 0; i < create.size(); ++i)
- this->RunQueryResult(create[i]);
+ for (const auto &query : create)
+ this->RunQueryResult(query);
Result res = this->RunQueryResult(this->SQL->BuildInsert(this->prefix + s_type->GetName(), obj->id, data));
if (res.GetID() && obj->id != res.GetID())
@@ -123,30 +121,30 @@ class DBMySQL : public Module, public Pipe
this->updated_items.clear();
}
- EventReturn OnLoadDatabase() anope_override
+ EventReturn OnLoadDatabase() override
{
init = true;
return EVENT_STOP;
}
- void OnShutdown() anope_override
+ void OnShutdown() override
{
init = false;
}
- void OnRestart() anope_override
+ void OnRestart() override
{
init = false;
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
Configuration::Block *block = conf->GetModule(this);
this->SQL = ServiceReference<Provider>("SQL::Provider", block->Get<const Anope::string>("engine"));
this->prefix = block->Get<const Anope::string>("prefix", "anope_db_");
}
- void OnSerializableConstruct(Serializable *obj) anope_override
+ void OnSerializableConstruct(Serializable *obj) override
{
if (!this->CheckInit())
return;
@@ -155,7 +153,7 @@ class DBMySQL : public Module, public Pipe
this->Notify();
}
- void OnSerializableDestruct(Serializable *obj) anope_override
+ void OnSerializableDestruct(Serializable *obj) override
{
if (!this->CheckInit())
return;
@@ -169,7 +167,7 @@ class DBMySQL : public Module, public Pipe
this->updated_items.erase(obj);
}
- void OnSerializeCheck(Serialize::Type *obj) anope_override
+ void OnSerializeCheck(Serialize::Type *obj) override
{
if (!this->CheckInit() || obj->GetTimestamp() == Anope::CurTime)
return;
@@ -207,8 +205,8 @@ class DBMySQL : public Module, public Pipe
{
Data data;
- for (std::map<Anope::string, Anope::string>::const_iterator it = row.begin(), it_end = row.end(); it != it_end; ++it)
- data[it->first] << it->second;
+ for (const auto &[key, value] : row)
+ data[key] << value;
Serializable *s = NULL;
std::map<uint64_t, Serializable *>::iterator it = obj->objects.find(id);
@@ -251,7 +249,7 @@ class DBMySQL : public Module, public Pipe
}
}
- void OnSerializableUpdate(Serializable *obj) anope_override
+ void OnSerializableUpdate(Serializable *obj) override
{
if (!this->CheckInit() || obj->IsTSCached())
return;
diff --git a/modules/encryption/enc_bcrypt.cpp b/modules/encryption/enc_bcrypt.cpp
index d70be1ba9..94c6fc164 100644
--- a/modules/encryption/enc_bcrypt.cpp
+++ b/modules/encryption/enc_bcrypt.cpp
@@ -6,842 +6,13 @@
* This program is free but copyrighted software; see the file COPYING for
* details.
*
- * Most of the code in this file is taken from
- * https://www.openwall.com/crypt/crypt_blowfish-1.3.tar.gz
-*/
-
-/*
- * The crypt_blowfish homepage is:
- *
- * http://www.openwall.com/crypt/
- *
- * This code comes from John the Ripper password cracker, with reentrant
- * and crypt(3) interfaces added, but optimizations specific to password
- * cracking removed.
- *
- * Written by Solar Designer <solar at openwall.com> in 1998-2014.
- * No copyright is claimed, and the software is hereby placed in the public
- * domain. In case this attempt to disclaim copyright and place the software
- * in the public domain is deemed null and void, then the software is
- * Copyright (c) 1998-2014 Solar Designer and it is hereby released to the
- * general public under the following terms:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted.
- *
- * There's ABSOLUTELY NO WARRANTY, express or implied.
- *
- * It is my intent that you should be able to use this on your system,
- * as part of a software package, or anywhere else to improve security,
- * ensure compatibility, or for any other purpose. I would appreciate
- * it if you give credit where it is due and keep your modifications in
- * the public domain as well, but I don't require that in order to let
- * you place this code and any modifications you make under a license
- * of your choice.
- *
- * This implementation is fully compatible with OpenBSD's bcrypt.c for prefix
- * "$2b$", originally by Niels Provos <provos at citi.umich.edu>, and it uses
- * some of his ideas. The password hashing algorithm was designed by David
- * Mazieres <dm at lcs.mit.edu>. For information on the level of
- * compatibility for bcrypt hash prefixes other than "$2b$", please refer to
- * the comments in BF_set_key() below and to the included crypt(3) man page.
- *
- * There's a paper on the algorithm that explains its design decisions:
- *
- * http://www.usenix.org/events/usenix99/provos.html
- *
- * Some of the tricks in BF_ROUND might be inspired by Eric Young's
- * Blowfish library (I can't be sure if I would think of something if I
- * hadn't seen his code).
- */
-
-#include <string.h>
-
-#ifdef __i386__
-#define BF_SCALE 1
-#elif defined(__x86_64__) || defined(__alpha__) || defined(__hppa__)
-#define BF_SCALE 1
-#else
-#define BF_SCALE 0
-#endif
-
-typedef unsigned int BF_word;
-typedef signed int BF_word_signed;
-
-/* Number of Blowfish rounds, this is also hardcoded into a few places */
-#define BF_N 16
-
-typedef BF_word BF_key[BF_N + 2];
-
-typedef struct {
- BF_word S[4][0x100];
- BF_key P;
-} BF_ctx;
-
-/*
- * Magic IV for 64 Blowfish encryptions that we do at the end.
- * The string is "OrpheanBeholderScryDoubt" on big-endian.
*/
-static BF_word BF_magic_w[6] = {
- 0x4F727068, 0x65616E42, 0x65686F6C,
- 0x64657253, 0x63727944, 0x6F756274
-};
-
-/*
- * P-box and S-box tables initialized with digits of Pi.
- */
-static BF_ctx BF_init_state = {
- {
- {
- 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7,
- 0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99,
- 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16,
- 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e,
- 0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee,
- 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013,
- 0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef,
- 0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e,
- 0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60,
- 0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440,
- 0x55ca396a, 0x2aab10b6, 0xb4cc5c34, 0x1141e8ce,
- 0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a,
- 0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e,
- 0xafd6ba33, 0x6c24cf5c, 0x7a325381, 0x28958677,
- 0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193,
- 0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032,
- 0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88,
- 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239,
- 0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e,
- 0x21c66842, 0xf6e96c9a, 0x670c9c61, 0xabd388f0,
- 0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3,
- 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98,
- 0xa1f1651d, 0x39af0176, 0x66ca593e, 0x82430e88,
- 0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe,
- 0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6,
- 0x4ed3aa62, 0x363f7706, 0x1bfedf72, 0x429b023d,
- 0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b,
- 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7,
- 0xe3fe501a, 0xb6794c3b, 0x976ce0bd, 0x04c006ba,
- 0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463,
- 0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f,
- 0x6dfc511f, 0x9b30952c, 0xcc814544, 0xaf5ebd09,
- 0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3,
- 0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb,
- 0x5579c0bd, 0x1a60320a, 0xd6a100c6, 0x402c7279,
- 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8,
- 0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab,
- 0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82,
- 0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db,
- 0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573,
- 0x695b27b0, 0xbbca58c8, 0xe1ffa35d, 0xb8f011a0,
- 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b,
- 0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790,
- 0xe1ddf2da, 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8,
- 0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4,
- 0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0,
- 0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7,
- 0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c,
- 0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad,
- 0x2f2f2218, 0xbe0e1777, 0xea752dfe, 0x8b021fa1,
- 0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299,
- 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9,
- 0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477,
- 0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf,
- 0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49,
- 0x00250e2d, 0x2071b35e, 0x226800bb, 0x57b8e0af,
- 0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa,
- 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5,
- 0x83260376, 0x6295cfa9, 0x11c81968, 0x4e734a41,
- 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915,
- 0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400,
- 0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915,
- 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664,
- 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a
- }, {
- 0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623,
- 0xad6ea6b0, 0x49a7df7d, 0x9cee60b8, 0x8fedb266,
- 0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1,
- 0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e,
- 0x3f54989a, 0x5b429d65, 0x6b8fe4d6, 0x99f73fd6,
- 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1,
- 0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e,
- 0x09686b3f, 0x3ebaefc9, 0x3c971814, 0x6b6a70a1,
- 0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737,
- 0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8,
- 0xb03ada37, 0xf0500c0d, 0xf01c1f04, 0x0200b3ff,
- 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd,
- 0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701,
- 0x3ae5e581, 0x37c2dadc, 0xc8b57634, 0x9af3dda7,
- 0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41,
- 0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331,
- 0x4e548b38, 0x4f6db908, 0x6f420d03, 0xf60a04bf,
- 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af,
- 0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e,
- 0x5512721f, 0x2e6b7124, 0x501adde6, 0x9f84cd87,
- 0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c,
- 0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2,
- 0xef1c1847, 0x3215d908, 0xdd433b37, 0x24c2ba16,
- 0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd,
- 0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b,
- 0x043556f1, 0xd7a3c76b, 0x3c11183b, 0x5924a509,
- 0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e,
- 0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3,
- 0x771fe71c, 0x4e3d06fa, 0x2965dcb9, 0x99e71d0f,
- 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a,
- 0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4,
- 0xf2f74ea7, 0x361d2b3d, 0x1939260f, 0x19c27960,
- 0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66,
- 0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28,
- 0xc332ddef, 0xbe6c5aa5, 0x65582185, 0x68ab9802,
- 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84,
- 0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510,
- 0x13cca830, 0xeb61bd96, 0x0334fe1e, 0xaa0363cf,
- 0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14,
- 0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e,
- 0x648b1eaf, 0x19bdf0ca, 0xa02369b9, 0x655abb50,
- 0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7,
- 0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8,
- 0xf837889a, 0x97e32d77, 0x11ed935f, 0x16681281,
- 0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99,
- 0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696,
- 0xcdb30aeb, 0x532e3054, 0x8fd948e4, 0x6dbc3128,
- 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73,
- 0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0,
- 0x45eee2b6, 0xa3aaabea, 0xdb6c4f15, 0xfacb4fd0,
- 0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105,
- 0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250,
- 0xcf62a1f2, 0x5b8d2646, 0xfc8883a0, 0xc1c7b6a3,
- 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285,
- 0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00,
- 0x58428d2a, 0x0c55f5ea, 0x1dadf43e, 0x233f7061,
- 0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb,
- 0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e,
- 0xa6078084, 0x19f8509e, 0xe8efd855, 0x61d99735,
- 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc,
- 0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9,
- 0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340,
- 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20,
- 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7
- }, {
- 0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934,
- 0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068,
- 0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af,
- 0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840,
- 0x4d95fc1d, 0x96b591af, 0x70f4ddd3, 0x66a02f45,
- 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504,
- 0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a,
- 0x28507825, 0x530429f4, 0x0a2c86da, 0xe9b66dfb,
- 0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee,
- 0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6,
- 0xaace1e7c, 0xd3375fec, 0xce78a399, 0x406b2a42,
- 0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b,
- 0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2,
- 0x3a6efa74, 0xdd5b4332, 0x6841e7f7, 0xca7820fb,
- 0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527,
- 0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b,
- 0x55a867bc, 0xa1159a58, 0xcca92963, 0x99e1db33,
- 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c,
- 0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3,
- 0x95c11548, 0xe4c66d22, 0x48c1133f, 0xc70f86dc,
- 0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17,
- 0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564,
- 0x257b7834, 0x602a9c60, 0xdff8e8a3, 0x1f636c1b,
- 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115,
- 0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922,
- 0x85b2a20e, 0xe6ba0d99, 0xde720c8c, 0x2da2f728,
- 0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0,
- 0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e,
- 0x0a476341, 0x992eff74, 0x3a6f6eab, 0xf4f8fd37,
- 0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d,
- 0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804,
- 0xf1290dc7, 0xcc00ffa3, 0xb5390f92, 0x690fed0b,
- 0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3,
- 0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb,
- 0x37392eb3, 0xcc115979, 0x8026e297, 0xf42e312d,
- 0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c,
- 0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350,
- 0x1a6b1018, 0x11caedfa, 0x3d25bdd8, 0xe2e1c3c9,
- 0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a,
- 0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe,
- 0x9dbc8057, 0xf0f7c086, 0x60787bf8, 0x6003604d,
- 0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc,
- 0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f,
- 0x77a057be, 0xbde8ae24, 0x55464299, 0xbf582e61,
- 0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2,
- 0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9,
- 0x7aeb2661, 0x8b1ddf84, 0x846a0e79, 0x915f95e2,
- 0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c,
- 0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e,
- 0xb77f19b6, 0xe0a9dc09, 0x662d09a1, 0xc4324633,
- 0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10,
- 0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169,
- 0xdcb7da83, 0x573906fe, 0xa1e2ce9b, 0x4fcd7f52,
- 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027,
- 0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5,
- 0xf0177a28, 0xc0f586e0, 0x006058aa, 0x30dc7d62,
- 0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634,
- 0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76,
- 0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24,
- 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc,
- 0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4,
- 0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c,
- 0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837,
- 0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0
- }, {
- 0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b,
- 0x5cb0679e, 0x4fa33742, 0xd3822740, 0x99bc9bbe,
- 0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b,
- 0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4,
- 0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8,
- 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6,
- 0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304,
- 0xa1fad5f0, 0x6a2d519a, 0x63ef8ce2, 0x9a86ee22,
- 0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4,
- 0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6,
- 0x2826a2f9, 0xa73a3ae1, 0x4ba99586, 0xef5562e9,
- 0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59,
- 0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593,
- 0xe990fd5a, 0x9e34d797, 0x2cf0b7d9, 0x022b8b51,
- 0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28,
- 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c,
- 0xe029ac71, 0xe019a5e6, 0x47b0acfd, 0xed93fa9b,
- 0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28,
- 0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c,
- 0x15056dd4, 0x88f46dba, 0x03a16125, 0x0564f0bd,
- 0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a,
- 0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319,
- 0x7533d928, 0xb155fdf5, 0x03563482, 0x8aba3cbb,
- 0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f,
- 0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991,
- 0xea7a90c2, 0xfb3e7bce, 0x5121ce64, 0x774fbe32,
- 0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680,
- 0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166,
- 0xb39a460a, 0x6445c0dd, 0x586cdecf, 0x1c20c8ae,
- 0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb,
- 0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5,
- 0x72eacea8, 0xfa6484bb, 0x8d6612ae, 0xbf3c6f47,
- 0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370,
- 0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d,
- 0x4040cb08, 0x4eb4e2cc, 0x34d2466a, 0x0115af84,
- 0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048,
- 0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8,
- 0x611560b1, 0xe7933fdc, 0xbb3a792b, 0x344525bd,
- 0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9,
- 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7,
- 0x1a908749, 0xd44fbd9a, 0xd0dadecb, 0xd50ada38,
- 0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f,
- 0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c,
- 0xbf97222c, 0x15e6fc2a, 0x0f91fc71, 0x9b941525,
- 0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1,
- 0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442,
- 0xe0ec6e0e, 0x1698db3b, 0x4c98a0be, 0x3278e964,
- 0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e,
- 0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8,
- 0xdf359f8d, 0x9b992f2e, 0xe60b6f47, 0x0fe3f11d,
- 0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f,
- 0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299,
- 0xf523f357, 0xa6327623, 0x93a83531, 0x56cccd02,
- 0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc,
- 0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614,
- 0xe6c6c7bd, 0x327a140a, 0x45e1d006, 0xc3f27b9a,
- 0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6,
- 0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b,
- 0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0,
- 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060,
- 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e,
- 0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9,
- 0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f,
- 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6
- }
- }, {
- 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344,
- 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89,
- 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c,
- 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917,
- 0x9216d5d9, 0x8979fb1b
- }
-};
-
-static unsigned char BF_itoa64[64 + 1] =
- "./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
-
-static unsigned char BF_atoi64[0x60] = {
- 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 0, 1,
- 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 64, 64, 64, 64, 64,
- 64, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
- 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 64, 64, 64, 64, 64,
- 64, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
- 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 64, 64, 64, 64, 64
-};
-
-#define BF_safe_atoi64(dst, src) \
-{ \
- tmp = (unsigned char)(src); \
- if ((unsigned int)(tmp -= 0x20) >= 0x60) return -1; \
- tmp = BF_atoi64[tmp]; \
- if (tmp > 63) return -1; \
- (dst) = tmp; \
-}
-
-static int BF_decode(BF_word *dst, const char *src, int size)
-{
- unsigned char *dptr = (unsigned char *)dst;
- unsigned char *end = dptr + size;
- const unsigned char *sptr = (const unsigned char *)src;
- unsigned int tmp, c1, c2, c3, c4;
-
- do {
- BF_safe_atoi64(c1, *sptr++);
- BF_safe_atoi64(c2, *sptr++);
- *dptr++ = (c1 << 2) | ((c2 & 0x30) >> 4);
- if (dptr >= end) break;
-
- BF_safe_atoi64(c3, *sptr++);
- *dptr++ = ((c2 & 0x0F) << 4) | ((c3 & 0x3C) >> 2);
- if (dptr >= end) break;
-
- BF_safe_atoi64(c4, *sptr++);
- *dptr++ = ((c3 & 0x03) << 6) | c4;
- } while (dptr < end);
-
- return 0;
-}
-
-static void BF_encode(char *dst, const BF_word *src, int size)
-{
- const unsigned char *sptr = (const unsigned char *)src;
- const unsigned char *end = sptr + size;
- unsigned char *dptr = (unsigned char *)dst;
- unsigned int c1, c2;
-
- do {
- c1 = *sptr++;
- *dptr++ = BF_itoa64[c1 >> 2];
- c1 = (c1 & 0x03) << 4;
- if (sptr >= end) {
- *dptr++ = BF_itoa64[c1];
- break;
- }
-
- c2 = *sptr++;
- c1 |= c2 >> 4;
- *dptr++ = BF_itoa64[c1];
- c1 = (c2 & 0x0f) << 2;
- if (sptr >= end) {
- *dptr++ = BF_itoa64[c1];
- break;
- }
-
- c2 = *sptr++;
- c1 |= c2 >> 6;
- *dptr++ = BF_itoa64[c1];
- *dptr++ = BF_itoa64[c2 & 0x3f];
- } while (sptr < end);
-}
-
-static void BF_swap(BF_word *x, int count)
-{
- static int endianness_check = 1;
- char *is_little_endian = (char *)&endianness_check;
- BF_word tmp;
-
- if (*is_little_endian)
- do {
- tmp = *x;
- tmp = (tmp << 16) | (tmp >> 16);
- *x++ = ((tmp & 0x00FF00FF) << 8) | ((tmp >> 8) & 0x00FF00FF);
- } while (--count);
-}
-
-#if BF_SCALE
-/* Architectures which can shift addresses left by 2 bits with no extra cost */
-#define BF_ROUND(L, R, N) \
- tmp1 = L & 0xFF; \
- tmp2 = L >> 8; \
- tmp2 &= 0xFF; \
- tmp3 = L >> 16; \
- tmp3 &= 0xFF; \
- tmp4 = L >> 24; \
- tmp1 = data.ctx.S[3][tmp1]; \
- tmp2 = data.ctx.S[2][tmp2]; \
- tmp3 = data.ctx.S[1][tmp3]; \
- tmp3 += data.ctx.S[0][tmp4]; \
- tmp3 ^= tmp2; \
- R ^= data.ctx.P[N + 1]; \
- tmp3 += tmp1; \
- R ^= tmp3;
-#else
-/* Architectures with no complicated addressing modes supported */
-#define BF_INDEX(S, i) \
- (*((BF_word *)(((unsigned char *)S) + (i))))
-#define BF_ROUND(L, R, N) \
- tmp1 = L & 0xFF; \
- tmp1 <<= 2; \
- tmp2 = L >> 6; \
- tmp2 &= 0x3FC; \
- tmp3 = L >> 14; \
- tmp3 &= 0x3FC; \
- tmp4 = L >> 22; \
- tmp4 &= 0x3FC; \
- tmp1 = BF_INDEX(data.ctx.S[3], tmp1); \
- tmp2 = BF_INDEX(data.ctx.S[2], tmp2); \
- tmp3 = BF_INDEX(data.ctx.S[1], tmp3); \
- tmp3 += BF_INDEX(data.ctx.S[0], tmp4); \
- tmp3 ^= tmp2; \
- R ^= data.ctx.P[N + 1]; \
- tmp3 += tmp1; \
- R ^= tmp3;
-#endif
-
-/*
- * Encrypt one block, BF_N is hardcoded here.
- */
-#define BF_ENCRYPT \
- L ^= data.ctx.P[0]; \
- BF_ROUND(L, R, 0); \
- BF_ROUND(R, L, 1); \
- BF_ROUND(L, R, 2); \
- BF_ROUND(R, L, 3); \
- BF_ROUND(L, R, 4); \
- BF_ROUND(R, L, 5); \
- BF_ROUND(L, R, 6); \
- BF_ROUND(R, L, 7); \
- BF_ROUND(L, R, 8); \
- BF_ROUND(R, L, 9); \
- BF_ROUND(L, R, 10); \
- BF_ROUND(R, L, 11); \
- BF_ROUND(L, R, 12); \
- BF_ROUND(R, L, 13); \
- BF_ROUND(L, R, 14); \
- BF_ROUND(R, L, 15); \
- tmp4 = R; \
- R = L; \
- L = tmp4 ^ data.ctx.P[BF_N + 1];
-
-#define BF_body() \
- L = R = 0; \
- ptr = data.ctx.P; \
- do { \
- ptr += 2; \
- BF_ENCRYPT; \
- *(ptr - 2) = L; \
- *(ptr - 1) = R; \
- } while (ptr < &data.ctx.P[BF_N + 2]); \
-\
- ptr = data.ctx.S[0]; \
- do { \
- ptr += 2; \
- BF_ENCRYPT; \
- *(ptr - 2) = L; \
- *(ptr - 1) = R; \
- } while (ptr < &data.ctx.S[3][0xFF]);
-
-static void BF_set_key(const char *key, BF_key expanded, BF_key initial,
- unsigned char flags)
-{
- const char *ptr = key;
- unsigned int bug, i, j;
- BF_word safety, sign, diff, tmp[2];
-
-/*
- * There was a sign extension bug in older revisions of this function. While
- * we would have liked to simply fix the bug and move on, we have to provide
- * a backwards compatibility feature (essentially the bug) for some systems and
- * a safety measure for some others. The latter is needed because for certain
- * multiple inputs to the buggy algorithm there exist easily found inputs to
- * the correct algorithm that produce the same hash. Thus, we optionally
- * deviate from the correct algorithm just enough to avoid such collisions.
- * While the bug itself affected the majority of passwords containing
- * characters with the 8th bit set (although only a percentage of those in a
- * collision-producing way), the anti-collision safety measure affects
- * only a subset of passwords containing the '\xff' character (not even all of
- * those passwords, just some of them). This character is not found in valid
- * UTF-8 sequences and is rarely used in popular 8-bit character encodings.
- * Thus, the safety measure is unlikely to cause much annoyance, and is a
- * reasonable tradeoff to use when authenticating against existing hashes that
- * are not reliably known to have been computed with the correct algorithm.
- *
- * We use an approach that tries to minimize side-channel leaks of password
- * information - that is, we mostly use fixed-cost bitwise operations instead
- * of branches or table lookups. (One conditional branch based on password
- * length remains. It is not part of the bug aftermath, though, and is
- * difficult and possibly unreasonable to avoid given the use of C strings by
- * the caller, which results in similar timing leaks anyway.)
- *
- * For actual implementation, we set an array index in the variable "bug"
- * (0 means no bug, 1 means sign extension bug emulation) and a flag in the
- * variable "safety" (bit 16 is set when the safety measure is requested).
- * Valid combinations of settings are:
- *
- * Prefix "$2a$": bug = 0, safety = 0x10000
- * Prefix "$2b$": bug = 0, safety = 0
- * Prefix "$2x$": bug = 1, safety = 0
- * Prefix "$2y$": bug = 0, safety = 0
- */
- bug = (unsigned int)flags & 1;
- safety = ((BF_word)flags & 2) << 15;
-
- sign = diff = 0;
-
- for (i = 0; i < BF_N + 2; i++) {
- tmp[0] = tmp[1] = 0;
- for (j = 0; j < 4; j++) {
- tmp[0] <<= 8;
- tmp[0] |= (unsigned char)*ptr; /* correct */
- tmp[1] <<= 8;
- tmp[1] |= (BF_word_signed)(signed char)*ptr; /* bug */
-/*
- * Sign extension in the first char has no effect - nothing to overwrite yet,
- * and those extra 24 bits will be fully shifted out of the 32-bit word. For
- * chars 2, 3, 4 in each four-char block, we set bit 7 of "sign" if sign
- * extension in tmp[1] occurs. Once this flag is set, it remains set.
- */
- if (j)
- sign |= tmp[1] & 0x80;
- if (!*ptr)
- ptr = key;
- else
- ptr++;
- }
- diff |= tmp[0] ^ tmp[1]; /* Non-zero on any differences */
-
- expanded[i] = tmp[bug];
- initial[i] = BF_init_state.P[i] ^ tmp[bug];
- }
-
-/*
- * At this point, "diff" is zero iff the correct and buggy algorithms produced
- * exactly the same result. If so and if "sign" is non-zero, which indicates
- * that there was a non-benign sign extension, this means that we have a
- * collision between the correctly computed hash for this password and a set of
- * passwords that could be supplied to the buggy algorithm. Our safety measure
- * is meant to protect from such many-buggy to one-correct collisions, by
- * deviating from the correct algorithm in such cases. Let's check for this.
- */
- diff |= diff >> 16; /* still zero iff exact match */
- diff &= 0xffff; /* ditto */
- diff += 0xffff; /* bit 16 set iff "diff" was non-zero (on non-match) */
- sign <<= 9; /* move the non-benign sign extension flag to bit 16 */
- sign &= ~diff & safety; /* action needed? */
-
-/*
- * If we have determined that we need to deviate from the correct algorithm,
- * flip bit 16 in initial expanded key. (The choice of 16 is arbitrary, but
- * let's stick to it now. It came out of the approach we used above, and it's
- * not any worse than any other choice we could make.)
- *
- * It is crucial that we don't do the same to the expanded key used in the main
- * Eksblowfish loop. By doing it to only one of these two, we deviate from a
- * state that could be directly specified by a password to the buggy algorithm
- * (and to the fully correct one as well, but that's a side-effect).
- */
- initial[0] ^= sign;
-}
-
-static const unsigned char flags_by_subtype[26] =
- {2, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 4, 0};
-
-static char *BF_crypt(const char *key, const char *setting,
- char *output, int size,
- BF_word min)
-{
- struct {
- BF_ctx ctx;
- BF_key expanded_key;
- union {
- BF_word salt[4];
- BF_word output[6];
- } binary;
- } data;
- BF_word L, R;
- BF_word tmp1, tmp2, tmp3, tmp4;
- BF_word *ptr;
- BF_word count;
- int i;
-
- if (size < 7 + 22 + 31 + 1) {
- return NULL;
- }
-
- if (setting[0] != '$' ||
- setting[1] != '2' ||
- setting[2] < 'a' || setting[2] > 'z' ||
- !flags_by_subtype[(unsigned int)(unsigned char)setting[2] - 'a'] ||
- setting[3] != '$' ||
- setting[4] < '0' || setting[4] > '3' ||
- setting[5] < '0' || setting[5] > '9' ||
- (setting[4] == '3' && setting[5] > '1') ||
- setting[6] != '$') {
- return NULL;
- }
-
- count = (BF_word)1 << ((setting[4] - '0') * 10 + (setting[5] - '0'));
- if (count < min || BF_decode(data.binary.salt, &setting[7], 16)) {
- return NULL;
- }
- BF_swap(data.binary.salt, 4);
-
- BF_set_key(key, data.expanded_key, data.ctx.P,
- flags_by_subtype[(unsigned int)(unsigned char)setting[2] - 'a']);
-
- memcpy(data.ctx.S, BF_init_state.S, sizeof(data.ctx.S));
-
- L = R = 0;
- for (i = 0; i < BF_N + 2; i += 2) {
- L ^= data.binary.salt[i & 2];
- R ^= data.binary.salt[(i & 2) + 1];
- BF_ENCRYPT;
- data.ctx.P[i] = L;
- data.ctx.P[i + 1] = R;
- }
-
- ptr = data.ctx.S[0];
- do {
- ptr += 4;
- L ^= data.binary.salt[(BF_N + 2) & 3];
- R ^= data.binary.salt[(BF_N + 3) & 3];
- BF_ENCRYPT;
- *(ptr - 4) = L;
- *(ptr - 3) = R;
-
- L ^= data.binary.salt[(BF_N + 4) & 3];
- R ^= data.binary.salt[(BF_N + 5) & 3];
- BF_ENCRYPT;
- *(ptr - 2) = L;
- *(ptr - 1) = R;
- } while (ptr < &data.ctx.S[3][0xFF]);
-
- do {
- int done;
-
- for (i = 0; i < BF_N + 2; i += 2) {
- data.ctx.P[i] ^= data.expanded_key[i];
- data.ctx.P[i + 1] ^= data.expanded_key[i + 1];
- }
-
- done = 0;
- do {
- BF_body();
- if (done)
- break;
- done = 1;
-
- tmp1 = data.binary.salt[0];
- tmp2 = data.binary.salt[1];
- tmp3 = data.binary.salt[2];
- tmp4 = data.binary.salt[3];
- for (i = 0; i < BF_N; i += 4) {
- data.ctx.P[i] ^= tmp1;
- data.ctx.P[i + 1] ^= tmp2;
- data.ctx.P[i + 2] ^= tmp3;
- data.ctx.P[i + 3] ^= tmp4;
- }
- data.ctx.P[16] ^= tmp1;
- data.ctx.P[17] ^= tmp2;
- } while (1);
- } while (--count);
-
- for (i = 0; i < 6; i += 2) {
- L = BF_magic_w[i];
- R = BF_magic_w[i + 1];
-
- count = 64;
- do {
- BF_ENCRYPT;
- } while (--count);
-
- data.binary.output[i] = L;
- data.binary.output[i + 1] = R;
- }
-
- memcpy(output, setting, 7 + 22 - 1);
- output[7 + 22 - 1] = BF_itoa64[(int)
- BF_atoi64[(int)setting[7 + 22 - 1] - 0x20] & 0x30];
-
-/* This has to be bug-compatible with the original implementation, so
- * only encode 23 of the 24 bytes. :-) */
- BF_swap(data.binary.output, 6);
- BF_encode(&output[7 + 22], data.binary.output, 23);
- output[7 + 22 + 31] = '\0';
-
- return output;
-}
-
-int _crypt_output_magic(const char *setting, char *output, int size)
-{
- if (size < 3)
- return -1;
-
- output[0] = '*';
- output[1] = '0';
- output[2] = '\0';
-
- if (setting[0] == '*' && setting[1] == '0')
- output[1] = '1';
-
- return 0;
-}
-
-/*
- * Please preserve the runtime self-test. It serves two purposes at once:
- *
- * 1. We really can't afford the risk of producing incompatible hashes e.g.
- * when there's something like gcc bug 26587 again, whereas an application or
- * library integrating this code might not also integrate our external tests or
- * it might not run them after every build. Even if it does, the miscompile
- * might only occur on the production build, but not on a testing build (such
- * as because of different optimization settings). It is painful to recover
- * from incorrectly-computed hashes - merely fixing whatever broke is not
- * enough. Thus, a proactive measure like this self-test is needed.
- *
- * 2. We don't want to leave sensitive data from our actual password hash
- * computation on the stack or in registers. Previous revisions of the code
- * would do explicit cleanups, but simply running the self-test after hash
- * computation is more reliable.
- *
- * The performance cost of this quick self-test is around 0.6% at the "$2a$08"
- * setting.
- */
-char *_crypt_blowfish_rn(const char *key, const char *setting,
- char *output, int size)
-{
- _crypt_output_magic(setting, output, size);
- return BF_crypt(key, setting, output, size, 16);
-}
-
-char *_crypt_gensalt_blowfish_rn(const char *prefix, unsigned long count,
- const char *input, int size, char *output, int output_size)
-{
- if (size < 16 || output_size < 7 + 22 + 1 ||
- (count && (count < 4 || count > 31)) ||
- prefix[0] != '$' || prefix[1] != '2' ||
- (prefix[2] != 'a' && prefix[2] != 'b' && prefix[2] != 'y')) {
- if (output_size > 0) output[0] = '\0';
- return NULL;
- }
-
- if (!count) count = 5;
-
- output[0] = '$';
- output[1] = '2';
- output[2] = prefix[2];
- output[3] = '$';
- output[4] = '0' + count / 10;
- output[5] = '0' + count % 10;
- output[6] = '$';
-
- BF_encode(&output[7], (const BF_word *)input, 16);
- output[7 + 22] = '\0';
-
- return output;
-}
-
-// Start Anope-specific code
#include "module.h"
#include "modules/encryption.h"
+#include "bcrypt/crypt_blowfish.c"
+
class EBCRYPT : public Module
{
unsigned int rounds;
@@ -849,8 +20,8 @@ class EBCRYPT : public Module
Anope::string Salt()
{
char entropy[16];
- for (unsigned int i = 0; i < sizeof(entropy); i++)
- entropy[i] = static_cast<char>(rand() % 0xFF);
+ for (auto &chr : entropy)
+ chr = static_cast<char>(rand() % 0xFF);
char salt[32];
if (!_crypt_gensalt_blowfish_rn("$2a$", rounds, entropy, sizeof(entropy), salt, sizeof(salt)))
@@ -888,14 +59,14 @@ class EBCRYPT : public Module
throw ModuleException("BCrypt could not load!");
}
- EventReturn OnEncrypt(const Anope::string &src, Anope::string &dest) anope_override
+ EventReturn OnEncrypt(const Anope::string &src, Anope::string &dest) override
{
dest = "bcrypt:" + Generate(src, Salt());
Log(LOG_DEBUG_2) << "(enc_bcrypt) hashed password from [" << src << "] to [" << dest << "]";
return EVENT_ALLOW;
}
- void OnCheckAuthentication(User *, IdentifyRequest *req) anope_override
+ void OnCheckAuthentication(User *, IdentifyRequest *req) override
{
const NickAlias *na = NickAlias::Find(req->GetAccount());
if (na == NULL)
@@ -935,7 +106,7 @@ class EBCRYPT : public Module
}
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
Configuration::Block *block = conf->GetModule(this);
rounds = block->Get<unsigned int>("rounds", "10");
diff --git a/modules/encryption/enc_md5.cpp b/modules/encryption/enc_md5.cpp
index ae946f78d..1fb12692a 100644
--- a/modules/encryption/enc_md5.cpp
+++ b/modules/encryption/enc_md5.cpp
@@ -250,7 +250,7 @@ class MD5Context : public Encryption::Context
* operation, processing another message block, and updating the
* context.
*/
- void Update(const unsigned char *input, size_t len) anope_override
+ void Update(const unsigned char *input, size_t len) override
{
unsigned i, index, partLen;
@@ -285,7 +285,7 @@ class MD5Context : public Encryption::Context
/* MD5 finalization. Ends an MD5 message-digest opera
* the message digest and zeroizing the context.
*/
- void Finalize() anope_override
+ void Finalize() override
{
unsigned char bits[8];
unsigned index, padLen;
@@ -309,7 +309,7 @@ class MD5Context : public Encryption::Context
memset(this->buffer, 0, sizeof(this->buffer));
}
- Encryption::Hash GetFinalizedHash() anope_override
+ Encryption::Hash GetFinalizedHash() override
{
Encryption::Hash hash;
hash.first = this->digest;
@@ -323,12 +323,12 @@ class MD5Provider : public Encryption::Provider
public:
MD5Provider(Module *creator) : Encryption::Provider(creator, "md5") { }
- Encryption::Context *CreateContext(Encryption::IV *iv) anope_override
+ Encryption::Context *CreateContext(Encryption::IV *iv) override
{
return new MD5Context(iv);
}
- Encryption::IV GetDefaultIV() anope_override
+ Encryption::IV GetDefaultIV() override
{
Encryption::IV iv;
iv.first = md5_iv;
@@ -345,10 +345,11 @@ class EMD5 : public Module
EMD5(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, ENCRYPTION | VENDOR),
md5provider(this)
{
-
+ if (ModuleManager::FindFirstOf(ENCRYPTION) == this)
+ throw ModuleException("enc_md5 is deprecated and can not be used as a primary encryption method");
}
- EventReturn OnEncrypt(const Anope::string &src, Anope::string &dest) anope_override
+ EventReturn OnEncrypt(const Anope::string &src, Anope::string &dest) override
{
MD5Context context;
@@ -364,7 +365,7 @@ class EMD5 : public Module
return EVENT_ALLOW;
}
- void OnCheckAuthentication(User *, IdentifyRequest *req) anope_override
+ void OnCheckAuthentication(User *, IdentifyRequest *req) override
{
const NickAlias *na = NickAlias::Find(req->GetAccount());
if (na == NULL)
diff --git a/modules/encryption/enc_none.cpp b/modules/encryption/enc_none.cpp
index 5cd9a7b88..f91997b1c 100644
--- a/modules/encryption/enc_none.cpp
+++ b/modules/encryption/enc_none.cpp
@@ -14,10 +14,11 @@ class ENone : public Module
public:
ENone(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, ENCRYPTION | VENDOR)
{
-
+ if (ModuleManager::FindFirstOf(ENCRYPTION) == this)
+ throw ModuleException("enc_none is deprecated and can not be used as a primary encryption method");
}
- EventReturn OnEncrypt(const Anope::string &src, Anope::string &dest) anope_override
+ EventReturn OnEncrypt(const Anope::string &src, Anope::string &dest) override
{
Anope::string buf = "plain:";
Anope::string cpass;
@@ -28,17 +29,7 @@ class ENone : public Module
return EVENT_ALLOW;
}
- EventReturn OnDecrypt(const Anope::string &hashm, const Anope::string &src, Anope::string &dest) anope_override
- {
- if (!hashm.equals_cs("plain"))
- return EVENT_CONTINUE;
- size_t pos = src.find(':');
- Anope::string buf = src.substr(pos + 1);
- Anope::B64Decode(buf, dest);
- return EVENT_ALLOW;
- }
-
- void OnCheckAuthentication(User *, IdentifyRequest *req) anope_override
+ void OnCheckAuthentication(User *, IdentifyRequest *req) override
{
const NickAlias *na = NickAlias::Find(req->GetAccount());
if (na == NULL)
diff --git a/modules/encryption/enc_old.cpp b/modules/encryption/enc_old.cpp
index 8e33fffb5..a0fc224c8 100644
--- a/modules/encryption/enc_old.cpp
+++ b/modules/encryption/enc_old.cpp
@@ -19,14 +19,14 @@ class OldMD5Provider : public Encryption::Provider
public:
OldMD5Provider(Module *creator) : Encryption::Provider(creator, "oldmd5") { }
- Encryption::Context *CreateContext(Encryption::IV *iv) anope_override
+ Encryption::Context *CreateContext(Encryption::IV *iv) override
{
if (md5)
return md5->CreateContext(iv);
return NULL;
}
- Encryption::IV GetDefaultIV() anope_override
+ Encryption::IV GetDefaultIV() override
{
if (md5)
return md5->GetDefaultIV();
@@ -44,6 +44,8 @@ class EOld : public Module
EOld(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, ENCRYPTION | VENDOR),
oldmd5provider(this)
{
+ if (ModuleManager::FindFirstOf(ENCRYPTION) == this)
+ throw ModuleException("enc_old is deprecated and can not be used as a primary encryption method");
ModuleManager::LoadModule("enc_md5", User::Find(creator, true));
if (!md5)
@@ -51,7 +53,7 @@ class EOld : public Module
}
- EventReturn OnEncrypt(const Anope::string &src, Anope::string &dest) anope_override
+ EventReturn OnEncrypt(const Anope::string &src, Anope::string &dest) override
{
if (!md5)
return EVENT_CONTINUE;
@@ -79,7 +81,7 @@ class EOld : public Module
return EVENT_ALLOW;
}
- void OnCheckAuthentication(User *, IdentifyRequest *req) anope_override
+ void OnCheckAuthentication(User *, IdentifyRequest *req) override
{
const NickAlias *na = NickAlias::Find(req->GetAccount());
if (na == NULL)
diff --git a/modules/encryption/enc_sha1.cpp b/modules/encryption/enc_sha1.cpp
index d5d61d7c8..0ddfcded0 100644
--- a/modules/encryption/enc_sha1.cpp
+++ b/modules/encryption/enc_sha1.cpp
@@ -125,7 +125,7 @@ class SHA1Context : public Encryption::Context
memset(this->digest, 0, sizeof(this->digest));
}
- void Update(const unsigned char *data, size_t len) anope_override
+ void Update(const unsigned char *data, size_t len) override
{
uint32_t i, j;
@@ -146,7 +146,7 @@ class SHA1Context : public Encryption::Context
memcpy(&this->buffer[j], &data[i], len - i);
}
- void Finalize() anope_override
+ void Finalize() override
{
uint32_t i;
unsigned char finalcount[8];
@@ -169,7 +169,7 @@ class SHA1Context : public Encryption::Context
this->Transform(this->buffer);
}
- Encryption::Hash GetFinalizedHash() anope_override
+ Encryption::Hash GetFinalizedHash() override
{
Encryption::Hash hash;
hash.first = this->digest;
@@ -183,12 +183,12 @@ class SHA1Provider : public Encryption::Provider
public:
SHA1Provider(Module *creator) : Encryption::Provider(creator, "sha1") { }
- Encryption::Context *CreateContext(Encryption::IV *iv) anope_override
+ Encryption::Context *CreateContext(Encryption::IV *iv) override
{
return new SHA1Context(iv);
}
- Encryption::IV GetDefaultIV() anope_override
+ Encryption::IV GetDefaultIV() override
{
Encryption::IV iv;
iv.first = sha1_iv;
@@ -205,10 +205,11 @@ class ESHA1 : public Module
ESHA1(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, ENCRYPTION | VENDOR),
sha1provider(this)
{
-
+ if (ModuleManager::FindFirstOf(ENCRYPTION) == this)
+ throw ModuleException("enc_sha1 is deprecated and can not be used as a primary encryption method");
}
- EventReturn OnEncrypt(const Anope::string &src, Anope::string &dest) anope_override
+ EventReturn OnEncrypt(const Anope::string &src, Anope::string &dest) override
{
SHA1Context context;
@@ -224,7 +225,7 @@ class ESHA1 : public Module
return EVENT_ALLOW;
}
- void OnCheckAuthentication(User *, IdentifyRequest *req) anope_override
+ void OnCheckAuthentication(User *, IdentifyRequest *req) override
{
const NickAlias *na = NickAlias::Find(req->GetAccount());
if (na == NULL)
diff --git a/modules/encryption/enc_sha256.cpp b/modules/encryption/enc_sha256.cpp
index ceae8ed8e..d5cebcb74 100644
--- a/modules/encryption/enc_sha256.cpp
+++ b/modules/encryption/enc_sha256.cpp
@@ -172,7 +172,7 @@ class SHA256Context : public Encryption::Context
memset(this->digest, 0, sizeof(this->digest));
}
- void Update(const unsigned char *message, size_t mlen) anope_override
+ void Update(const unsigned char *message, size_t mlen) override
{
unsigned tmp_len = SHA256_BLOCK_SIZE - this->len, rem_len = mlen < tmp_len ? mlen : tmp_len;
@@ -194,7 +194,7 @@ class SHA256Context : public Encryption::Context
this->tot_len += (block_nb + 1) << 6;
}
- void Finalize() anope_override
+ void Finalize() override
{
unsigned block_nb = 1 + ((SHA256_BLOCK_SIZE - 9) < (this->len % SHA256_BLOCK_SIZE));
unsigned len_b = (this->tot_len + this->len) << 3;
@@ -207,7 +207,7 @@ class SHA256Context : public Encryption::Context
UNPACK32(this->h[i], &this->digest[i << 2]);
}
- Encryption::Hash GetFinalizedHash() anope_override
+ Encryption::Hash GetFinalizedHash() override
{
Encryption::Hash hash;
hash.first = this->digest;
@@ -221,12 +221,12 @@ class SHA256Provider : public Encryption::Provider
public:
SHA256Provider(Module *creator) : Encryption::Provider(creator, "sha256") { }
- Encryption::Context *CreateContext(Encryption::IV *iv) anope_override
+ Encryption::Context *CreateContext(Encryption::IV *iv) override
{
return new SHA256Context(iv);
}
- Encryption::IV GetDefaultIV() anope_override
+ Encryption::IV GetDefaultIV() override
{
Encryption::IV iv;
iv.first = sha256_h0;
@@ -245,8 +245,8 @@ class ESHA256 : public Module
/* initializes the IV with a new random value */
void NewRandomIV()
{
- for (int i = 0; i < 8; ++i)
- iv[i] = static_cast<uint32_t>(rand());
+ for (auto &ivsegment : iv)
+ ivsegment = static_cast<uint32_t>(rand());
}
/* returns the IV as base64-encrypted string */
@@ -280,7 +280,7 @@ class ESHA256 : public Module
use_iv = false;
}
- EventReturn OnEncrypt(const Anope::string &src, Anope::string &dest) anope_override
+ EventReturn OnEncrypt(const Anope::string &src, Anope::string &dest) override
{
if (!use_iv)
NewRandomIV();
@@ -301,7 +301,7 @@ class ESHA256 : public Module
return EVENT_ALLOW;
}
- void OnCheckAuthentication(User *, IdentifyRequest *req) anope_override
+ void OnCheckAuthentication(User *, IdentifyRequest *req) override
{
const NickAlias *na = NickAlias::Find(req->GetAccount());
if (na == NULL)
diff --git a/modules/extra/m_ldap.cpp b/modules/extra/m_ldap.cpp
index 37b3df83d..a92385c7d 100644
--- a/modules/extra/m_ldap.cpp
+++ b/modules/extra/m_ldap.cpp
@@ -47,18 +47,15 @@ class LDAPRequest
public:
LDAPService *service;
LDAPInterface *inter;
- LDAPMessage *message; /* message returned by ldap_ */
- LDAPResult *result; /* final result */
+ LDAPMessage *message = nullptr; /* message returned by ldap_ */
+ LDAPResult *result = nullptr; /* final result */
struct timeval tv;
- QueryType type;
+ QueryType type = QUERY_UNKNOWN;
LDAPRequest(LDAPService *s, LDAPInterface *i)
: service(s)
, inter(i)
- , message(NULL)
- , result(NULL)
{
- type = QUERY_UNKNOWN;
tv.tv_sec = 0;
tv.tv_usec = 100000;
}
@@ -88,7 +85,7 @@ class LDAPBind : public LDAPRequest
type = QUERY_BIND;
}
- int run() anope_override;
+ int run() override;
};
class LDAPSearchRequest : public LDAPRequest
@@ -105,7 +102,7 @@ class LDAPSearchRequest : public LDAPRequest
type = QUERY_SEARCH;
}
- int run() anope_override;
+ int run() override;
};
class LDAPAdd : public LDAPRequest
@@ -122,7 +119,7 @@ class LDAPAdd : public LDAPRequest
type = QUERY_ADD;
}
- int run() anope_override;
+ int run() override;
};
class LDAPDel : public LDAPRequest
@@ -137,7 +134,7 @@ class LDAPDel : public LDAPRequest
type = QUERY_DELETE;
}
- int run() anope_override;
+ int run() override;
};
class LDAPModify : public LDAPRequest
@@ -154,7 +151,7 @@ class LDAPModify : public LDAPRequest
type = QUERY_MODIFY;
}
- int run() anope_override;
+ int run() override;
};
class LDAPService : public LDAPProvider, public Thread, public Condition
@@ -165,7 +162,7 @@ class LDAPService : public LDAPProvider, public Thread, public Condition
LDAP *con;
- time_t last_connect;
+ time_t last_connect = 0;
public:
static LDAPMod **BuildMods(const LDAPMods &attributes)
@@ -307,7 +304,7 @@ class LDAPService : public LDAPProvider, public Thread, public Condition
query_queue queries, results;
Mutex process_mutex; /* held when processing requests not in either queue */
- LDAPService(Module *o, const Anope::string &n, const Anope::string &s, const Anope::string &b, const Anope::string &p) : LDAPProvider(o, n), server(s), admin_binddn(b), admin_pass(p), last_connect(0)
+ LDAPService(Module *o, const Anope::string &n, const Anope::string &s, const Anope::string &b, const Anope::string &p) : LDAPProvider(o, n), server(s), admin_binddn(b), admin_pass(p)
{
Connect();
}
@@ -318,10 +315,8 @@ class LDAPService : public LDAPProvider, public Thread, public Condition
this->Lock();
- for (unsigned int i = 0; i < this->queries.size(); ++i)
+ for (auto *req : this->queries)
{
- LDAPRequest *req = this->queries[i];
-
/* queries have no results yet */
req->result = new LDAPResult();
req->result->type = req->type;
@@ -333,10 +328,8 @@ class LDAPService : public LDAPProvider, public Thread, public Condition
}
this->queries.clear();
- for (unsigned int i = 0; i < this->results.size(); ++i)
+ for (const auto *req : this->queries)
{
- LDAPRequest *req = this->results[i];
-
/* even though this may have already finished successfully we return that it didn't */
req->result->error = "LDAP Interface is going away";
if (req->inter)
@@ -350,18 +343,18 @@ class LDAPService : public LDAPProvider, public Thread, public Condition
ldap_unbind_ext(this->con, NULL, NULL);
}
- void BindAsAdmin(LDAPInterface *i) anope_override
+ void BindAsAdmin(LDAPInterface *i) override
{
this->Bind(i, this->admin_binddn, this->admin_pass);
}
- void Bind(LDAPInterface *i, const Anope::string &who, const Anope::string &pass) anope_override
+ void Bind(LDAPInterface *i, const Anope::string &who, const Anope::string &pass) override
{
LDAPBind *b = new LDAPBind(this, i, who, pass);
QueueRequest(b);
}
- void Search(LDAPInterface *i, const Anope::string &base, const Anope::string &filter) anope_override
+ void Search(LDAPInterface *i, const Anope::string &base, const Anope::string &filter) override
{
if (i == NULL)
throw LDAPException("No interface");
@@ -370,19 +363,19 @@ class LDAPService : public LDAPProvider, public Thread, public Condition
QueueRequest(s);
}
- void Add(LDAPInterface *i, const Anope::string &dn, LDAPMods &attributes) anope_override
+ void Add(LDAPInterface *i, const Anope::string &dn, LDAPMods &attributes) override
{
LDAPAdd *add = new LDAPAdd(this, i, dn, attributes);
QueueRequest(add);
}
- void Del(LDAPInterface *i, const Anope::string &dn) anope_override
+ void Del(LDAPInterface *i, const Anope::string &dn) override
{
LDAPDel *del = new LDAPDel(this, i, dn);
QueueRequest(del);
}
- void Modify(LDAPInterface *i, const Anope::string &base, LDAPMods &attributes) anope_override
+ void Modify(LDAPInterface *i, const Anope::string &base, LDAPMods &attributes) override
{
LDAPModify *mod = new LDAPModify(this, i, base, attributes);
QueueRequest(mod);
@@ -457,9 +450,8 @@ class LDAPService : public LDAPProvider, public Thread, public Condition
return;
}
- for (unsigned int i = 0; i < q.size(); ++i)
+ for (auto *req : q)
{
- LDAPRequest *req = q[i];
int ret = req->run();
if (ret == LDAP_SERVER_DOWN || ret == LDAP_TIMEOUT)
@@ -489,7 +481,7 @@ class LDAPService : public LDAPProvider, public Thread, public Condition
}
public:
- void Run() anope_override
+ void Run() override
{
while (!this->GetExitState())
{
@@ -532,7 +524,7 @@ class ModuleLDAP : public Module, public Pipe
LDAPServices.clear();
}
- void OnReload(Configuration::Conf *config) anope_override
+ void OnReload(Configuration::Conf *config) override
{
Configuration::Block *conf = config->GetModule(this);
@@ -576,7 +568,7 @@ class ModuleLDAP : public Module, public Pipe
{
LDAPService *ss = new LDAPService(this, connname, server, admin_binddn, admin_password);
ss->Start();
- this->LDAPServices.insert(std::make_pair(connname, ss));
+ this->LDAPServices.emplace(connname, ss);
Log(LOG_NORMAL, "ldap") << "LDAP: Successfully initialized server " << connname << " (" << server << ")";
}
@@ -588,7 +580,7 @@ class ModuleLDAP : public Module, public Pipe
}
}
- void OnModuleUnload(User *, Module *m) anope_override
+ void OnModuleUnload(User *, Module *m) override
{
for (std::map<Anope::string, LDAPService *>::iterator it = this->LDAPServices.begin(); it != this->LDAPServices.end(); ++it)
{
@@ -625,7 +617,7 @@ class ModuleLDAP : public Module, public Pipe
}
}
- void OnNotify() anope_override
+ void OnNotify() override
{
for (std::map<Anope::string, LDAPService *>::iterator it = this->LDAPServices.begin(); it != this->LDAPServices.end(); ++it)
{
@@ -636,9 +628,8 @@ class ModuleLDAP : public Module, public Pipe
results.swap(s->results);
s->Unlock();
- for (unsigned int i = 0; i < results.size(); ++i)
+ for (const auto *req : results)
{
- LDAPRequest *req = results[i];
LDAPInterface *li = req->inter;
LDAPResult *r = req->result;
diff --git a/modules/extra/m_ldap_authentication.cpp b/modules/extra/m_ldap_authentication.cpp
index d4fd704c3..d49daf284 100644
--- a/modules/extra/m_ldap_authentication.cpp
+++ b/modules/extra/m_ldap_authentication.cpp
@@ -22,10 +22,10 @@ struct IdentifyInfo
Reference<User> user;
IdentifyRequest *req;
ServiceReference<LDAPProvider> lprov;
- bool admin_bind;
+ bool admin_bind = true;
Anope::string dn;
- IdentifyInfo(User *u, IdentifyRequest *r, ServiceReference<LDAPProvider> &lp) : user(u), req(r), lprov(lp), admin_bind(true)
+ IdentifyInfo(User *u, IdentifyRequest *r, ServiceReference<LDAPProvider> &lp) : user(u), req(r), lprov(lp)
{
req->Hold(me);
}
@@ -48,12 +48,12 @@ class IdentifyInterface : public LDAPInterface
delete ii;
}
- void OnDelete() anope_override
+ void OnDelete() override
{
delete this;
}
- void OnResult(const LDAPResult &r) anope_override
+ void OnResult(const LDAPResult &r) override
{
if (!ii->lprov)
return;
@@ -122,7 +122,7 @@ class IdentifyInterface : public LDAPInterface
}
}
- void OnError(const LDAPResult &r) anope_override
+ void OnError(const LDAPResult &r) override
{
}
};
@@ -134,12 +134,12 @@ class OnIdentifyInterface : public LDAPInterface
public:
OnIdentifyInterface(Module *m, const Anope::string &i) : LDAPInterface(m), uid(i) { }
- void OnDelete() anope_override
+ void OnDelete() override
{
delete this;
}
- void OnResult(const LDAPResult &r) anope_override
+ void OnResult(const LDAPResult &r) override
{
User *u = User::Find(uid);
@@ -166,7 +166,7 @@ class OnIdentifyInterface : public LDAPInterface
}
}
- void OnError(const LDAPResult &r) anope_override
+ void OnError(const LDAPResult &r) override
{
Log(this->owner) << r.error;
}
@@ -177,12 +177,12 @@ class OnRegisterInterface : public LDAPInterface
public:
OnRegisterInterface(Module *m) : LDAPInterface(m) { }
- void OnResult(const LDAPResult &r) anope_override
+ void OnResult(const LDAPResult &r) override
{
Log(this->owner) << "Successfully added newly created account to LDAP";
}
- void OnError(const LDAPResult &r) anope_override
+ void OnError(const LDAPResult &r) override
{
Log(this->owner) << "Error adding newly created account to LDAP: " << r.getError();
}
@@ -206,12 +206,12 @@ class ModuleLDAPAuthentication : public Module
me = this;
}
- void Prioritize() anope_override
+ void Prioritize() override
{
ModuleManager::SetPriority(this, PRIORITY_FIRST);
}
- void OnReload(Configuration::Conf *config) anope_override
+ void OnReload(Configuration::Conf *config) override
{
Configuration::Block *conf = Config->GetModule(this);
@@ -229,7 +229,7 @@ class ModuleLDAPAuthentication : public Module
config->GetModule("nickserv")->Set("forceemail", "false");
}
- EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> &params) anope_override
+ EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> &params) override
{
if (!this->disable_register_reason.empty())
{
@@ -249,7 +249,7 @@ class ModuleLDAPAuthentication : public Module
return EVENT_CONTINUE;
}
- void OnCheckAuthentication(User *u, IdentifyRequest *req) anope_override
+ void OnCheckAuthentication(User *u, IdentifyRequest *req) override
{
if (!this->ldap)
return;
@@ -258,7 +258,7 @@ class ModuleLDAPAuthentication : public Module
this->ldap->BindAsAdmin(new IdentifyInterface(this, ii));
}
- void OnNickIdentify(User *u) anope_override
+ void OnNickIdentify(User *u) override
{
if (email_attribute.empty() || !this->ldap)
return;
@@ -270,7 +270,7 @@ class ModuleLDAPAuthentication : public Module
this->ldap->Search(new OnIdentifyInterface(this, u->GetUID()), *d, "(" + email_attribute + "=*)");
}
- void OnNickRegister(User *, NickAlias *na, const Anope::string &pass) anope_override
+ void OnNickRegister(User *, NickAlias *na, const Anope::string &pass) override
{
if (!this->disable_register_reason.empty() || !this->ldap)
return;
diff --git a/modules/extra/m_ldap_oper.cpp b/modules/extra/m_ldap_oper.cpp
index e876d89e8..0a3c2c71a 100644
--- a/modules/extra/m_ldap_oper.cpp
+++ b/modules/extra/m_ldap_oper.cpp
@@ -21,7 +21,7 @@ class IdentifyInterface : public LDAPInterface
{
}
- void OnResult(const LDAPResult &r) anope_override
+ void OnResult(const LDAPResult &r) override
{
if (!u || !u->Account())
return;
@@ -65,11 +65,11 @@ class IdentifyInterface : public LDAPInterface
}
}
- void OnError(const LDAPResult &r) anope_override
+ void OnError(const LDAPResult &r) override
{
}
- void OnDelete() anope_override
+ void OnDelete() override
{
delete this;
}
@@ -90,7 +90,7 @@ class LDAPOper : public Module
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
Configuration::Block *config = Config->GetModule(this);
@@ -100,12 +100,12 @@ class LDAPOper : public Module
this->filter = config->Get<const Anope::string>("filter");
opertype_attribute = config->Get<const Anope::string>("opertype_attribute");
- for (std::set<Oper *>::iterator it = my_opers.begin(), it_end = my_opers.end(); it != it_end; ++it)
- delete *it;
+ for (const auto *oper : my_opers)
+ delete oper;
my_opers.clear();
}
- void OnNickIdentify(User *u) anope_override
+ void OnNickIdentify(User *u) override
{
try
{
@@ -124,7 +124,7 @@ class LDAPOper : public Module
}
}
- void OnDelCore(NickCore *nc) anope_override
+ void OnDelCore(NickCore *nc) override
{
if (nc->o != NULL && my_opers.count(nc->o) > 0)
{
diff --git a/modules/extra/m_mysql.cpp b/modules/extra/m_mysql.cpp
index b08f33c05..0ec7f8989 100644
--- a/modules/extra/m_mysql.cpp
+++ b/modules/extra/m_mysql.cpp
@@ -11,7 +11,7 @@
#include "module.h"
#include "modules/sql.h"
-#define NO_CLIENT_LONG_LONG
+
#ifdef WIN32
# include <mysql.h>
#else
@@ -61,7 +61,7 @@ struct QueryResult
*/
class MySQLResult : public Result
{
- MYSQL_RES *res;
+ MYSQL_RES *res = nullptr;
public:
MySQLResult(unsigned int i, const Query &q, const Anope::string &fq, MYSQL_RES *r) : Result(i, q, fq), res(r)
@@ -94,7 +94,7 @@ class MySQLResult : public Result
}
}
- MySQLResult(const Query &q, const Anope::string &fq, const Anope::string &err) : Result(0, q, fq, err), res(NULL)
+ MySQLResult(const Query &q, const Anope::string &fq, const Anope::string &err) : Result(0, q, fq, err)
{
}
@@ -117,7 +117,7 @@ class MySQLService : public Provider
Anope::string password;
int port;
- MYSQL *sql;
+ MYSQL *sql = nullptr;
/** Escape a query.
* Note the mutex must be held!
@@ -135,15 +135,15 @@ class MySQLService : public Provider
~MySQLService();
- void Run(Interface *i, const Query &query) anope_override;
+ void Run(Interface *i, const Query &query) override;
- Result RunQuery(const Query &query) anope_override;
+ Result RunQuery(const Query &query) override;
- std::vector<Query> CreateTable(const Anope::string &table, const Data &data) anope_override;
+ std::vector<Query> CreateTable(const Anope::string &table, const Data &data) override;
- Query BuildInsert(const Anope::string &table, unsigned int id, Data &data) anope_override;
+ Query BuildInsert(const Anope::string &table, unsigned int id, Data &data) override;
- Query GetTables(const Anope::string &prefix) anope_override;
+ Query GetTables(const Anope::string &prefix) override;
void Connect();
@@ -151,7 +151,7 @@ class MySQLService : public Provider
Anope::string BuildQuery(const Query &q);
- Anope::string FromUnixtime(time_t);
+ Anope::string FromUnixtime(time_t) override;
};
/** The SQL thread used to execute queries
@@ -161,7 +161,7 @@ class DispatcherThread : public Thread, public Condition
public:
DispatcherThread() : Thread() { }
- void Run() anope_override;
+ void Run() override;
};
class ModuleSQL;
@@ -199,7 +199,7 @@ class ModuleSQL : public Module, public Pipe
delete DThread;
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
Configuration::Block *config = conf->GetModule(this);
@@ -240,7 +240,7 @@ class ModuleSQL : public Module, public Pipe
try
{
MySQLService *ss = new MySQLService(this, connname, database, server, user, password, port);
- this->MySQLServices.insert(std::make_pair(connname, ss));
+ this->MySQLServices.emplace(connname, ss);
Log(LOG_NORMAL, "mysql") << "MySQL: Successfully connected to server " << connname << " (" << server << ")";
}
@@ -252,7 +252,7 @@ class ModuleSQL : public Module, public Pipe
}
}
- void OnModuleUnload(User *, Module *m) anope_override
+ void OnModuleUnload(User *, Module *m) override
{
this->DThread->Lock();
@@ -277,17 +277,15 @@ class ModuleSQL : public Module, public Pipe
this->OnNotify();
}
- void OnNotify() anope_override
+ void OnNotify() override
{
this->DThread->Lock();
std::deque<QueryResult> finishedRequests = this->FinishedRequests;
this->FinishedRequests.clear();
this->DThread->Unlock();
- for (std::deque<QueryResult>::const_iterator it = finishedRequests.begin(), it_end = finishedRequests.end(); it != it_end; ++it)
+ for (const auto &qr : finishedRequests)
{
- const QueryResult &qr = *it;
-
if (!qr.sqlinterface)
throw SQL::Exception("NULL qr.sqlinterface in MySQLPipe::OnNotify() ?");
@@ -300,7 +298,7 @@ class ModuleSQL : public Module, public Pipe
};
MySQLService::MySQLService(Module *o, const Anope::string &n, const Anope::string &d, const Anope::string &s, const Anope::string &u, const Anope::string &p, int po)
-: Provider(o, n), database(d), server(s), user(u), password(p), port(po), sql(NULL)
+: Provider(o, n), database(d), server(s), user(u), password(p), port(po)
{
Connect();
}
@@ -389,12 +387,12 @@ std::vector<Query> MySQLService::CreateTable(const Anope::string &table, const D
{
Anope::string query_text = "CREATE TABLE `" + table + "` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT,"
" `timestamp` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP";
- for (Data::Map::const_iterator it = data.data.begin(), it_end = data.data.end(); it != it_end; ++it)
+ for (const auto &[column, _] : data.data)
{
- known_cols.insert(it->first);
+ known_cols.insert(column);
- query_text += ", `" + it->first + "` ";
- if (data.GetType(it->first) == Serialize::Data::DT_INT)
+ query_text += ", `" + column + "` ";
+ if (data.GetType(column) == Serialize::Data::DT_INT)
query_text += "int(11)";
else
query_text += "text";
@@ -403,21 +401,23 @@ std::vector<Query> MySQLService::CreateTable(const Anope::string &table, const D
queries.push_back(query_text);
}
else
- for (Data::Map::const_iterator it = data.data.begin(), it_end = data.data.end(); it != it_end; ++it)
+ {
+ for (const auto &[column, _] : data.data)
{
- if (known_cols.count(it->first) > 0)
+ if (known_cols.count(column) > 0)
continue;
- known_cols.insert(it->first);
+ known_cols.insert(column);
- Anope::string query_text = "ALTER TABLE `" + table + "` ADD `" + it->first + "` ";
- if (data.GetType(it->first) == Serialize::Data::DT_INT)
+ Anope::string query_text = "ALTER TABLE `" + table + "` ADD `" + column + "` ";
+ if (data.GetType(column) == Serialize::Data::DT_INT)
query_text += "int(11)";
else
query_text += "text";
queries.push_back(query_text);
}
+ }
return queries;
}
@@ -425,27 +425,29 @@ std::vector<Query> MySQLService::CreateTable(const Anope::string &table, const D
Query MySQLService::BuildInsert(const Anope::string &table, unsigned int id, Data &data)
{
/* Empty columns not present in the data set */
- const std::set<Anope::string> &known_cols = this->active_schema[table];
- for (std::set<Anope::string>::iterator it = known_cols.begin(), it_end = known_cols.end(); it != it_end; ++it)
- if (*it != "id" && *it != "timestamp" && data.data.count(*it) == 0)
- data[*it] << "";
+ for (const auto &known_col : this->active_schema[table])
+ {
+ if (known_col != "id" && known_col != "timestamp" && data.data.count(known_col) == 0)
+ data[known_col] << "";
+ }
Anope::string query_text = "INSERT INTO `" + table + "` (`id`";
- for (Data::Map::const_iterator it = data.data.begin(), it_end = data.data.end(); it != it_end; ++it)
- query_text += ",`" + it->first + "`";
+
+ for (const auto &[field, _] : data.data)
+ query_text += ",`" + field + "`";
query_text += ") VALUES (" + stringify(id);
- for (Data::Map::const_iterator it = data.data.begin(), it_end = data.data.end(); it != it_end; ++it)
- query_text += ",@" + it->first + "@";
+ for (const auto &[field, _] : data.data)
+ query_text += ",@" + field + "@";
query_text += ") ON DUPLICATE KEY UPDATE ";
- for (Data::Map::const_iterator it = data.data.begin(), it_end = data.data.end(); it != it_end; ++it)
- query_text += "`" + it->first + "`=VALUES(`" + it->first + "`),";
+ for (const auto &[field, _] : data.data)
+ query_text += "`" + field + "`=VALUES(`" + field + "`),";
query_text.erase(query_text.end() - 1);
Query query(query_text);
- for (Data::Map::const_iterator it = data.data.begin(), it_end = data.data.end(); it != it_end; ++it)
+ for (auto &[field, value] : data.data)
{
Anope::string buf;
- *it->second >> buf;
+ *value >> buf;
bool escape = true;
if (buf.empty())
@@ -454,7 +456,7 @@ Query MySQLService::BuildInsert(const Anope::string &table, unsigned int id, Dat
escape = false;
}
- query.SetValue(it->first, buf, escape);
+ query.SetValue(field, buf, escape);
}
return query;
@@ -509,8 +511,8 @@ Anope::string MySQLService::BuildQuery(const Query &q)
{
Anope::string real_query = q.query;
- for (std::map<Anope::string, QueryData>::const_iterator it = q.parameters.begin(), it_end = q.parameters.end(); it != it_end; ++it)
- real_query = real_query.replace_all_cs("@" + it->first + "@", (it->second.escape ? ("'" + this->Escape(it->second.data) + "'") : it->second.data));
+ for (const auto &[name, value] : q.parameters)
+ real_query = real_query.replace_all_cs("@" + name + "@", (value.escape ? ("'" + this->Escape(value.data) + "'") : value.data));
return real_query;
}
diff --git a/modules/extra/m_regex_pcre.cpp b/modules/extra/m_regex_pcre.cpp
index 1a1c4fce2..8fd18bebe 100644
--- a/modules/extra/m_regex_pcre.cpp
+++ b/modules/extra/m_regex_pcre.cpp
@@ -42,7 +42,7 @@ class PCRERegexProvider : public RegexProvider
public:
PCRERegexProvider(Module *creator) : RegexProvider(creator, "regex/pcre") { }
- Regex *Compile(const Anope::string &expression) anope_override
+ Regex *Compile(const Anope::string &expression) override
{
return new PCRERegex(expression);
}
@@ -61,15 +61,10 @@ class ModuleRegexPCRE : public Module
~ModuleRegexPCRE()
{
- for (std::list<XLineManager *>::iterator it = XLineManager::XLineManagers.begin(); it != XLineManager::XLineManagers.end(); ++it)
+ for (auto *xlm : XLineManager::XLineManagers)
{
- XLineManager *xlm = *it;
- const std::vector<XLine *> &xlines = xlm->GetList();
-
- for (unsigned int i = 0; i < xlines.size(); ++i)
+ for (auto *x : xlm->GetList())
{
- XLine *x = xlines[i];
-
if (x->regex && dynamic_cast<PCRERegex *>(x->regex))
{
delete x->regex;
diff --git a/modules/extra/m_regex_pcre2.cpp b/modules/extra/m_regex_pcre2.cpp
index 5655c3324..2d2be3916 100644
--- a/modules/extra/m_regex_pcre2.cpp
+++ b/modules/extra/m_regex_pcre2.cpp
@@ -52,7 +52,7 @@ class PCRERegexProvider : public RegexProvider
public:
PCRERegexProvider(Module *creator) : RegexProvider(creator, "regex/pcre") { }
- Regex *Compile(const Anope::string &expression) anope_override
+ Regex *Compile(const Anope::string &expression) override
{
return new PCRERegex(expression);
}
@@ -71,15 +71,10 @@ class ModuleRegexPCRE : public Module
~ModuleRegexPCRE()
{
- for (std::list<XLineManager *>::iterator it = XLineManager::XLineManagers.begin(); it != XLineManager::XLineManagers.end(); ++it)
+ for (auto *xlm : XLineManager::XLineManagers)
{
- XLineManager *xlm = *it;
- const std::vector<XLine *> &xlines = xlm->GetList();
-
- for (unsigned int i = 0; i < xlines.size(); ++i)
+ for (auto *x : xlm->GetList())
{
- XLine *x = xlines[i];
-
if (x->regex && dynamic_cast<PCRERegex *>(x->regex))
{
delete x->regex;
diff --git a/modules/extra/m_regex_posix.cpp b/modules/extra/m_regex_posix.cpp
index 75f58d0cb..add8ab084 100644
--- a/modules/extra/m_regex_posix.cpp
+++ b/modules/extra/m_regex_posix.cpp
@@ -43,7 +43,7 @@ class POSIXRegexProvider : public RegexProvider
public:
POSIXRegexProvider(Module *creator) : RegexProvider(creator, "regex/posix") { }
- Regex *Compile(const Anope::string &expression) anope_override
+ Regex *Compile(const Anope::string &expression) override
{
return new POSIXRegex(expression);
}
@@ -62,15 +62,10 @@ class ModuleRegexPOSIX : public Module
~ModuleRegexPOSIX()
{
- for (std::list<XLineManager *>::iterator it = XLineManager::XLineManagers.begin(); it != XLineManager::XLineManagers.end(); ++it)
+ for (auto *xlm : XLineManager::XLineManagers)
{
- XLineManager *xlm = *it;
- const std::vector<XLine *> &xlines = xlm->GetList();
-
- for (unsigned int i = 0; i < xlines.size(); ++i)
+ for (auto *x : xlm->GetList())
{
- XLine *x = xlines[i];
-
if (x->regex && dynamic_cast<POSIXRegex *>(x->regex))
{
delete x->regex;
diff --git a/modules/extra/m_regex_tre.cpp b/modules/extra/m_regex_tre.cpp
index 767b5fcbe..4ff111b6a 100644
--- a/modules/extra/m_regex_tre.cpp
+++ b/modules/extra/m_regex_tre.cpp
@@ -44,7 +44,7 @@ class TRERegexProvider : public RegexProvider
public:
TRERegexProvider(Module *creator) : RegexProvider(creator, "regex/tre") { }
- Regex *Compile(const Anope::string &expression) anope_override
+ Regex *Compile(const Anope::string &expression) override
{
return new TRERegex(expression);
}
@@ -63,15 +63,10 @@ class ModuleRegexTRE : public Module
~ModuleRegexTRE()
{
- for (std::list<XLineManager *>::iterator it = XLineManager::XLineManagers.begin(); it != XLineManager::XLineManagers.end(); ++it)
+ for (auto *xlm : XLineManager::XLineManagers)
{
- XLineManager *xlm = *it;
- const std::vector<XLine *> &xlines = xlm->GetList();
-
- for (unsigned int i = 0; i < xlines.size(); ++i)
+ for (auto *x : xlm->GetList())
{
- XLine *x = xlines[i];
-
if (x->regex && dynamic_cast<TRERegex *>(x->regex))
{
delete x->regex;
diff --git a/modules/extra/m_sql_authentication.cpp b/modules/extra/m_sql_authentication.cpp
index f89a90ff1..77bd8b3ca 100644
--- a/modules/extra/m_sql_authentication.cpp
+++ b/modules/extra/m_sql_authentication.cpp
@@ -27,7 +27,7 @@ class SQLAuthenticationResult : public SQL::Interface
req->Release(me);
}
- void OnResult(const SQL::Result &r) anope_override
+ void OnResult(const SQL::Result &r) override
{
if (r.Rows() == 0)
{
@@ -66,7 +66,7 @@ class SQLAuthenticationResult : public SQL::Interface
delete this;
}
- void OnError(const SQL::Result &r) anope_override
+ void OnError(const SQL::Result &r) override
{
Log(this->owner) << "m_sql_authentication: Error executing query " << r.GetQuery().query << ": " << r.GetError();
delete this;
@@ -88,7 +88,7 @@ class ModuleSQLAuthentication : public Module
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
Configuration::Block *config = conf->GetModule(this);
this->engine = config->Get<const Anope::string>("engine");
@@ -99,7 +99,7 @@ class ModuleSQLAuthentication : public Module
this->SQL = ServiceReference<SQL::Provider>("SQL::Provider", this->engine);
}
- EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> &params) anope_override
+ EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> &params) override
{
if (!this->disable_reason.empty() && (command->name == "nickserv/register" || command->name == "nickserv/group"))
{
@@ -116,7 +116,7 @@ class ModuleSQLAuthentication : public Module
return EVENT_CONTINUE;
}
- void OnCheckAuthentication(User *u, IdentifyRequest *req) anope_override
+ void OnCheckAuthentication(User *u, IdentifyRequest *req) override
{
if (!this->SQL)
{
diff --git a/modules/extra/m_sql_log.cpp b/modules/extra/m_sql_log.cpp
index 243844bb2..e64b0ebd4 100644
--- a/modules/extra/m_sql_log.cpp
+++ b/modules/extra/m_sql_log.cpp
@@ -19,20 +19,19 @@ class SQLLog : public Module
{
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
Configuration::Block *config = conf->GetModule(this);
this->table = config->Get<const Anope::string>("table", "logs");
}
- void OnLogMessage(LogInfo *li, const Log *l, const Anope::string &msg) anope_override
+ void OnLogMessage(LogInfo *li, const Log *l, const Anope::string &msg) override
{
Anope::string ref_name;
ServiceReference<SQL::Provider> SQL;
- for (unsigned i = 0; i < li->targets.size(); ++i)
+ for (const auto &target : li->targets)
{
- const Anope::string &target = li->targets[i];
size_t sz = target.find("sql_log:");
if (!sz)
{
diff --git a/modules/extra/m_sql_oper.cpp b/modules/extra/m_sql_oper.cpp
index db3c287ad..4be312459 100644
--- a/modules/extra/m_sql_oper.cpp
+++ b/modules/extra/m_sql_oper.cpp
@@ -42,7 +42,7 @@ class SQLOperResult : public SQL::Interface
public:
SQLOperResult(Module *m, User *u) : SQL::Interface(m), user(u) { }
- void OnResult(const SQL::Result &r) anope_override
+ void OnResult(const SQL::Result &r) override
{
SQLOperResultDeleter d(this);
@@ -116,7 +116,7 @@ class SQLOperResult : public SQL::Interface
}
}
- void OnError(const SQL::Result &r) anope_override
+ void OnError(const SQL::Result &r) override
{
SQLOperResultDeleter d(this);
Log(this->owner) << "m_sql_oper: Error executing query " << r.GetQuery().query << ": " << r.GetError();
@@ -137,10 +137,8 @@ class ModuleSQLOper : public Module
~ModuleSQLOper()
{
- for (nickcore_map::const_iterator it = NickCoreList->begin(), it_end = NickCoreList->end(); it != it_end; ++it)
+ for (const auto &[_, nc] : *NickCoreList)
{
- NickCore *nc = it->second;
-
if (nc->o && dynamic_cast<SQLOper *>(nc->o))
{
delete nc->o;
@@ -149,7 +147,7 @@ class ModuleSQLOper : public Module
}
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
Configuration::Block *config = conf->GetModule(this);
@@ -159,7 +157,7 @@ class ModuleSQLOper : public Module
this->SQL = ServiceReference<SQL::Provider>("SQL::Provider", this->engine);
}
- void OnNickIdentify(User *u) anope_override
+ void OnNickIdentify(User *u) override
{
if (!this->SQL)
{
diff --git a/modules/extra/m_sqlite.cpp b/modules/extra/m_sqlite.cpp
index cf825912d..28c9d6ed5 100644
--- a/modules/extra/m_sqlite.cpp
+++ b/modules/extra/m_sqlite.cpp
@@ -44,7 +44,7 @@ class SQLiteService : public Provider
Anope::string database;
- sqlite3 *sql;
+ sqlite3 *sql = nullptr;
Anope::string Escape(const Anope::string &query);
@@ -53,19 +53,19 @@ class SQLiteService : public Provider
~SQLiteService();
- void Run(Interface *i, const Query &query) anope_override;
+ void Run(Interface *i, const Query &query) override;
- Result RunQuery(const Query &query);
+ Result RunQuery(const Query &query) override;
- std::vector<Query> CreateTable(const Anope::string &table, const Data &data) anope_override;
+ std::vector<Query> CreateTable(const Anope::string &table, const Data &data) override;
- Query BuildInsert(const Anope::string &table, unsigned int id, Data &data);
+ Query BuildInsert(const Anope::string &table, unsigned int id, Data &data) override;
- Query GetTables(const Anope::string &prefix);
+ Query GetTables(const Anope::string &prefix) override;
Anope::string BuildQuery(const Query &q);
- Anope::string FromUnixtime(time_t);
+ Anope::string FromUnixtime(time_t) override;
};
class ModuleSQLite : public Module
@@ -84,7 +84,7 @@ class ModuleSQLite : public Module
SQLiteServices.clear();
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
Configuration::Block *config = conf->GetModule(this);
@@ -134,7 +134,7 @@ class ModuleSQLite : public Module
};
SQLiteService::SQLiteService(Module *o, const Anope::string &n, const Anope::string &d)
-: Provider(o, n), database(d), sql(NULL)
+: Provider(o, n), database(d)
{
int db = sqlite3_open_v2(database.c_str(), &this->sql, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, 0);
if (db != SQLITE_OK)
@@ -200,7 +200,7 @@ Result SQLiteService::RunQuery(const Query &query)
if (err != SQLITE_DONE)
return SQLiteResult(query, real_query, sqlite3_errmsg(this->sql));
- return result;
+ return std::move(result);
}
std::vector<Query> SQLiteService::CreateTable(const Anope::string &table, const Data &data)
@@ -226,12 +226,12 @@ std::vector<Query> SQLiteService::CreateTable(const Anope::string &table, const
{
Anope::string query_text = "CREATE TABLE `" + table + "` (`id` INTEGER PRIMARY KEY, `timestamp` timestamp DEFAULT CURRENT_TIMESTAMP";
- for (Data::Map::const_iterator it = data.data.begin(), it_end = data.data.end(); it != it_end; ++it)
+ for (const auto &[column, _] : data.data)
{
- known_cols.insert(it->first);
+ known_cols.insert(column);
- query_text += ", `" + it->first + "` ";
- if (data.GetType(it->first) == Serialize::Data::DT_INT)
+ query_text += ", `" + column + "` ";
+ if (data.GetType(column) == Serialize::Data::DT_INT)
query_text += "int(11)";
else
query_text += "text";
@@ -251,21 +251,23 @@ std::vector<Query> SQLiteService::CreateTable(const Anope::string &table, const
queries.push_back(query_text);
}
else
- for (Data::Map::const_iterator it = data.data.begin(), it_end = data.data.end(); it != it_end; ++it)
+ {
+ for (const auto &[column, _] : data.data)
{
- if (known_cols.count(it->first) > 0)
+ if (known_cols.count(column) > 0)
continue;
- known_cols.insert(it->first);
+ known_cols.insert(column);
- Anope::string query_text = "ALTER TABLE `" + table + "` ADD `" + it->first + "` ";
- if (data.GetType(it->first) == Serialize::Data::DT_INT)
+ Anope::string query_text = "ALTER TABLE `" + table + "` ADD `" + column + "` ";
+ if (data.GetType(column) == Serialize::Data::DT_INT)
query_text += "int(11)";
else
query_text += "text";
queries.push_back(query_text);
}
+ }
return queries;
}
@@ -273,31 +275,32 @@ std::vector<Query> SQLiteService::CreateTable(const Anope::string &table, const
Query SQLiteService::BuildInsert(const Anope::string &table, unsigned int id, Data &data)
{
/* Empty columns not present in the data set */
- const std::set<Anope::string> &known_cols = this->active_schema[table];
- for (std::set<Anope::string>::iterator it = known_cols.begin(), it_end = known_cols.end(); it != it_end; ++it)
- if (*it != "id" && *it != "timestamp" && data.data.count(*it) == 0)
- data[*it] << "";
+ for (const auto &known_col : this->active_schema[table])
+ {
+ if (known_col != "id" && known_col != "timestamp" && data.data.count(known_col) == 0)
+ data[known_col] << "";
+ }
Anope::string query_text = "REPLACE INTO `" + table + "` (";
if (id > 0)
query_text += "`id`,";
- for (Data::Map::const_iterator it = data.data.begin(), it_end = data.data.end(); it != it_end; ++it)
- query_text += "`" + it->first + "`,";
+ for (const auto &[field, _] : data.data)
+ query_text += "`" + field + "`,";
query_text.erase(query_text.length() - 1);
query_text += ") VALUES (";
if (id > 0)
query_text += stringify(id) + ",";
- for (Data::Map::const_iterator it = data.data.begin(), it_end = data.data.end(); it != it_end; ++it)
- query_text += "@" + it->first + "@,";
+ for (const auto &[field, _] : data.data)
+ query_text += "@" + field + "@,";
query_text.erase(query_text.length() - 1);
query_text += ")";
Query query(query_text);
- for (Data::Map::const_iterator it = data.data.begin(), it_end = data.data.end(); it != it_end; ++it)
+ for (auto &[field, value] : data.data)
{
Anope::string buf;
- *it->second >> buf;
- query.SetValue(it->first, buf);
+ *value >> buf;
+ query.SetValue(field, buf);
}
return query;
@@ -320,8 +323,8 @@ Anope::string SQLiteService::BuildQuery(const Query &q)
{
Anope::string real_query = q.query;
- for (std::map<Anope::string, QueryData>::const_iterator it = q.parameters.begin(), it_end = q.parameters.end(); it != it_end; ++it)
- real_query = real_query.replace_all_cs("@" + it->first + "@", (it->second.escape ? ("'" + this->Escape(it->second.data) + "'") : it->second.data));
+ for (const auto &[name, value] : q.parameters)
+ real_query = real_query.replace_all_cs("@" + name + "@", (value.escape ? ("'" + this->Escape(value.data) + "'") : value.data));
return real_query;
}
diff --git a/modules/extra/m_ssl_gnutls.cpp b/modules/extra/m_ssl_gnutls.cpp
index 255bbc805..baa4c977c 100644
--- a/modules/extra/m_ssl_gnutls.cpp
+++ b/modules/extra/m_ssl_gnutls.cpp
@@ -30,13 +30,13 @@ class MySSLService : public SSLService
/** Initialize a socket to use SSL
* @param s The socket
*/
- void Init(Socket *s) anope_override;
+ void Init(Socket *s) override;
};
class SSLSocketIO : public SocketIO
{
public:
- gnutls_session_t sess;
+ gnutls_session_t sess = nullptr;
GnuTLS::X509CertCredentials* mycreds;
/** Constructor
@@ -49,43 +49,43 @@ class SSLSocketIO : public SocketIO
* @param sz How much to read
* @return Number of bytes received
*/
- int Recv(Socket *s, char *buf, size_t sz) anope_override;
+ int Recv(Socket *s, char *buf, size_t sz) override;
/** Write something to the socket
* @param s The socket
* @param buf The data to write
* @param size The length of the data
*/
- int Send(Socket *s, const char *buf, size_t sz) anope_override;
+ int Send(Socket *s, const char *buf, size_t sz) override;
/** Accept a connection from a socket
* @param s The socket
* @return The new socket
*/
- ClientSocket *Accept(ListenSocket *s) anope_override;
+ ClientSocket *Accept(ListenSocket *s) override;
/** Finished accepting a connection from a socket
* @param s The socket
* @return SF_ACCEPTED if accepted, SF_ACCEPTING if still in process, SF_DEAD on error
*/
- SocketFlag FinishAccept(ClientSocket *cs) anope_override;
+ SocketFlag FinishAccept(ClientSocket *cs) override;
/** Connect the socket
* @param s THe socket
* @param target IP to connect to
* @param port to connect to
*/
- void Connect(ConnectionSocket *s, const Anope::string &target, int port) anope_override;
+ void Connect(ConnectionSocket *s, const Anope::string &target, int port) override;
/** Called to potentially finish a pending connection
* @param s The socket
* @return SF_CONNECTED on success, SF_CONNECTING if still pending, and SF_DEAD on error.
*/
- SocketFlag FinishConnect(ConnectionSocket *s) anope_override;
+ SocketFlag FinishConnect(ConnectionSocket *s) override;
/** Called when the socket is destructing
*/
- void Destroy() anope_override;
+ void Destroy() override;
};
namespace GnuTLS
@@ -115,11 +115,9 @@ namespace GnuTLS
class DHParams
{
- gnutls_dh_params_t dh_params;
+ gnutls_dh_params_t dh_params = nullptr;
public:
- DHParams() : dh_params(NULL) { }
-
void Import(const Anope::string &dhstr)
{
if (dh_params != NULL)
@@ -225,7 +223,7 @@ namespace GnuTLS
class X509CertCredentials
{
- unsigned int refcount;
+ unsigned int refcount = 0;
gnutls_certificate_credentials_t cred;
DHParams dh;
@@ -247,7 +245,7 @@ namespace GnuTLS
X509Key key;
X509CertCredentials(const Anope::string &certfile, const Anope::string &keyfile)
- : refcount(0), certs(LoadFile(certfile)), key(LoadFile(keyfile))
+ : certs(LoadFile(certfile)), key(LoadFile(keyfile))
{
if (gnutls_certificate_allocate_credentials(&cred) < 0)
throw ConfigException("Cannot allocate certificate credentials");
@@ -299,10 +297,10 @@ class GnuTLSModule : public Module
GnuTLS::Init libinit;
public:
- GnuTLS::X509CertCredentials *cred;
+ GnuTLS::X509CertCredentials *cred = nullptr;
MySSLService service;
- GnuTLSModule(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR), cred(NULL), service(this, "ssl")
+ GnuTLSModule(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR), service(this, "ssl")
{
me = this;
this->SetPermanent(true);
@@ -332,7 +330,7 @@ class GnuTLSModule : public Module
}
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
Configuration::Block *config = conf->GetModule(this);
@@ -368,7 +366,7 @@ class GnuTLSModule : public Module
Log(LOG_DEBUG) << "m_ssl_gnutls: Successfully loaded certificate " << certfile << " and private key " << keyfile;
}
- void OnPreServerConnect() anope_override
+ void OnPreServerConnect() override
{
Configuration::Block *config = Config->GetBlock("uplink", Anope::CurrentUplink);
@@ -535,7 +533,7 @@ void SSLSocketIO::Connect(ConnectionSocket *s, const Anope::string &target, int
s->flags[SF_CONNECTING] = s->flags[SF_CONNECTED] = false;
- s->conaddr.pton(s->IsIPv6() ? AF_INET6 : AF_INET, target, port);
+ s->conaddr.pton(s->GetFamily(), target, port);
int c = connect(s->GetFD(), &s->conaddr.sa, s->conaddr.size());
if (c == -1)
{
@@ -630,7 +628,7 @@ void SSLSocketIO::Destroy()
delete this;
}
-SSLSocketIO::SSLSocketIO() : sess(NULL), mycreds(me->cred)
+SSLSocketIO::SSLSocketIO() : mycreds(me->cred)
{
mycreds->incrref();
}
diff --git a/modules/extra/m_ssl_openssl.cpp b/modules/extra/m_ssl_openssl.cpp
index 26b47a330..1b504c122 100644
--- a/modules/extra/m_ssl_openssl.cpp
+++ b/modules/extra/m_ssl_openssl.cpp
@@ -29,7 +29,7 @@ class MySSLService : public SSLService
/** Initialize a socket to use SSL
* @param s The socket
*/
- void Init(Socket *s) anope_override;
+ void Init(Socket *s) override;
};
class SSLSocketIO : public SocketIO
@@ -48,43 +48,43 @@ class SSLSocketIO : public SocketIO
* @param sz How much to read
* @return Number of bytes received
*/
- int Recv(Socket *s, char *buf, size_t sz) anope_override;
+ int Recv(Socket *s, char *buf, size_t sz) override;
/** Write something to the socket
* @param s The socket
* @param buf The data to write
* @param size The length of the data
*/
- int Send(Socket *s, const char *buf, size_t sz) anope_override;
+ int Send(Socket *s, const char *buf, size_t sz) override;
/** Accept a connection from a socket
* @param s The socket
* @return The new socket
*/
- ClientSocket *Accept(ListenSocket *s) anope_override;
+ ClientSocket *Accept(ListenSocket *s) override;
/** Finished accepting a connection from a socket
* @param s The socket
* @return SF_ACCEPTED if accepted, SF_ACCEPTING if still in process, SF_DEAD on error
*/
- SocketFlag FinishAccept(ClientSocket *cs) anope_override;
+ SocketFlag FinishAccept(ClientSocket *cs) override;
/** Connect the socket
* @param s THe socket
* @param target IP to connect to
* @param port to connect to
*/
- void Connect(ConnectionSocket *s, const Anope::string &target, int port) anope_override;
+ void Connect(ConnectionSocket *s, const Anope::string &target, int port) override;
/** Called to potentially finish a pending connection
* @param s The socket
* @return SF_CONNECTED on success, SF_CONNECTING if still pending, and SF_DEAD on error.
*/
- SocketFlag FinishConnect(ConnectionSocket *s) anope_override;
+ SocketFlag FinishConnect(ConnectionSocket *s) override;
/** Called when the socket is destructing
*/
- void Destroy() anope_override;
+ void Destroy() override;
};
class SSLModule;
@@ -138,7 +138,7 @@ class SSLModule : public Module
SSL_CTX_free(server_ctx);
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
Configuration::Block *config = conf->GetModule(this);
@@ -186,7 +186,7 @@ class SSLModule : public Module
}
}
- void OnPreServerConnect() anope_override
+ void OnPreServerConnect() override
{
Configuration::Block *config = Config->GetBlock("uplink", Anope::CurrentUplink);
@@ -334,7 +334,7 @@ void SSLSocketIO::Connect(ConnectionSocket *s, const Anope::string &target, int
s->flags[SF_CONNECTING] = s->flags[SF_CONNECTED] = false;
- s->conaddr.pton(s->IsIPv6() ? AF_INET6 : AF_INET, target, port);
+ s->conaddr.pton(s->GetFamily(), target, port);
int c = connect(s->GetFD(), &s->conaddr.sa, s->conaddr.size());
if (c == -1)
{
diff --git a/modules/extra/stats/cs_fantasy_stats.cpp b/modules/extra/stats/cs_fantasy_stats.cpp
index 9284bbd60..3416947d1 100644
--- a/modules/extra/stats/cs_fantasy_stats.cpp
+++ b/modules/extra/stats/cs_fantasy_stats.cpp
@@ -17,11 +17,11 @@ class MySQLInterface : public SQL::Interface
public:
MySQLInterface(Module *o) : SQL::Interface(o) { }
- void OnResult(const SQL::Result &r) anope_override
+ void OnResult(const SQL::Result &r) override
{
}
- void OnError(const SQL::Result &r) anope_override
+ void OnError(const SQL::Result &r) override
{
if (!r.GetQuery().query.empty())
Log(LOG_DEBUG) << "Chanstats: Error executing query " << r.finished_query << ": " << r.GetError();
@@ -73,7 +73,7 @@ class CSStats : public Module
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
prefix = conf->GetModule("m_chanstats")->Get<const Anope::string>("prefix", "anope_");
this->sql = ServiceReference<SQL::Provider>("SQL::Provider", conf->GetModule("m_chanstats")->Get<const Anope::string>("engine"));
diff --git a/modules/extra/stats/cs_fantasy_top.cpp b/modules/extra/stats/cs_fantasy_top.cpp
index 496d9efb7..e2564db90 100644
--- a/modules/extra/stats/cs_fantasy_top.cpp
+++ b/modules/extra/stats/cs_fantasy_top.cpp
@@ -17,11 +17,11 @@ class MySQLInterface : public SQL::Interface
public:
MySQLInterface(Module *o) : SQL::Interface(o) { }
- void OnResult(const SQL::Result &r) anope_override
+ void OnResult(const SQL::Result &r) override
{
}
- void OnError(const SQL::Result &r) anope_override
+ void OnError(const SQL::Result &r) override
{
if (!r.GetQuery().query.empty())
Log(LOG_DEBUG) << "Chanstats: Error executing query " << r.finished_query << ": " << r.GetError();
@@ -98,7 +98,7 @@ class CSTop : public Module
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
prefix = conf->GetModule("m_chanstats")->Get<const Anope::string>("prefix", "anope_");
this->sql = ServiceReference<SQL::Provider>("SQL::Provider", conf->GetModule("m_chanstats")->Get<const Anope::string>("engine"));
diff --git a/modules/extra/stats/irc2sql/irc2sql.cpp b/modules/extra/stats/irc2sql/irc2sql.cpp
index b3c3192a2..730255656 100644
--- a/modules/extra/stats/irc2sql/irc2sql.cpp
+++ b/modules/extra/stats/irc2sql/irc2sql.cpp
@@ -47,19 +47,18 @@ void IRC2SQL::OnReload(Configuration::Conf *conf)
this->OnNewServer(it->second);
}
- for (channel_map::const_iterator it = ChannelList.begin(), it_end = ChannelList.end(); it != it_end; ++it)
+ for (const auto &[_, c] : ChannelList)
{
- this->OnChannelCreate(it->second);
+ this->OnChannelCreate(c);
}
- for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
+ for (const auto &[_, u] : UserListByNick)
{
- User *u = it->second;
bool exempt = false;
this->OnUserConnect(u, exempt);
- for (User::ChanUserList::const_iterator cit = u->chans.begin(), cit_end = u->chans.end(); cit != cit_end; ++cit)
+ for (const auto &[_, uc] : u->chans)
{
- this->OnJoinChannel(u, cit->second->chan);
+ this->OnJoinChannel(u, uc->chan);
}
}
}
@@ -107,7 +106,7 @@ void IRC2SQL::OnUserConnect(User *u, bool &exempt)
query.SetValue("ip", u->ip.addr());
query.SetValue("ident", u->GetIdent());
query.SetValue("vident", u->GetVIdent());
- query.SetValue("secure", u->HasMode("SSL") || u->HasExt("ssl") ? "Y" : "N");
+ query.SetValue("secure", u->IsSecurelyConnected() ? "Y" : "N");
query.SetValue("account", u->Account() ? u->Account()->display : "");
query.SetValue("fingerprint", u->fingerprint);
query.SetValue("signon", u->signon);
@@ -152,7 +151,7 @@ void IRC2SQL::OnUserAway(User *u, const Anope::string &message)
void IRC2SQL::OnFingerprint(User *u)
{
query = "UPDATE `" + prefix + "user` SET secure=@secure@, fingerprint=@fingerprint@ WHERE nick=@nick@";
- query.SetValue("secure", u->HasMode("SSL") || u->HasExt("ssl") ? "Y" : "N");
+ query.SetValue("secure", u->IsSecurelyConnected() ? "Y" : "N");
query.SetValue("fingerprint", u->fingerprint);
query.SetValue("nick", u->nick);
this->RunQuery(query);
diff --git a/modules/extra/stats/irc2sql/irc2sql.h b/modules/extra/stats/irc2sql/irc2sql.h
index 7fb8338cd..d343837b5 100644
--- a/modules/extra/stats/irc2sql/irc2sql.h
+++ b/modules/extra/stats/irc2sql/irc2sql.h
@@ -6,6 +6,8 @@
* Please read COPYING and README for further details.
*/
+#pragma once
+
#include "module.h"
#include "modules/sql.h"
@@ -14,11 +16,11 @@ class MySQLInterface : public SQL::Interface
public:
MySQLInterface(Module *o) : SQL::Interface(o) { }
- void OnResult(const SQL::Result &r) anope_override
+ void OnResult(const SQL::Result &r) override
{
}
- void OnError(const SQL::Result &r) anope_override
+ void OnError(const SQL::Result &r) override
{
if (!r.GetQuery().query.empty())
Log(LOG_DEBUG) << "m_irc2sql: Error executing query " << r.finished_query << ": " << r.GetError();
@@ -56,29 +58,29 @@ class IRC2SQL : public Module
introduced_myself = false;
}
- void OnShutdown() anope_override;
- void OnReload(Configuration::Conf *config) anope_override;
- void OnNewServer(Server *server) anope_override;
- void OnServerQuit(Server *server) anope_override;
- void OnUserConnect(User *u, bool &exempt) anope_override;
- void OnUserQuit(User *u, const Anope::string &msg) anope_override;
- void OnUserNickChange(User *u, const Anope::string &oldnick) anope_override;
- void OnUserAway(User *u, const Anope::string &message) anope_override;
- void OnFingerprint(User *u) anope_override;
- void OnUserModeSet(const MessageSource &setter, User *u, const Anope::string &mname) anope_override;
- void OnUserModeUnset(const MessageSource &setter, User *u, const Anope::string &mname) anope_override;
- void OnUserLogin(User *u) anope_override;
- void OnNickLogout(User *u) anope_override;
- void OnSetDisplayedHost(User *u) anope_override;
+ void OnShutdown() override;
+ void OnReload(Configuration::Conf *config) override;
+ void OnNewServer(Server *server) override;
+ void OnServerQuit(Server *server) override;
+ void OnUserConnect(User *u, bool &exempt) override;
+ void OnUserQuit(User *u, const Anope::string &msg) override;
+ void OnUserNickChange(User *u, const Anope::string &oldnick) override;
+ void OnUserAway(User *u, const Anope::string &message) override;
+ void OnFingerprint(User *u) override;
+ void OnUserModeSet(const MessageSource &setter, User *u, const Anope::string &mname) override;
+ void OnUserModeUnset(const MessageSource &setter, User *u, const Anope::string &mname) override;
+ void OnUserLogin(User *u) override;
+ void OnNickLogout(User *u) override;
+ void OnSetDisplayedHost(User *u) override;
- void OnChannelCreate(Channel *c) anope_override;
- void OnChannelDelete(Channel *c) anope_override;
- void OnLeaveChannel(User *u, Channel *c) anope_override;
- void OnJoinChannel(User *u, Channel *c) anope_override;
- EventReturn OnChannelModeSet(Channel *c, MessageSource &setter, ChannelMode *mode, const Anope::string &param) anope_override;
- EventReturn OnChannelModeUnset(Channel *c, MessageSource &setter, ChannelMode *mode, const Anope::string &param) anope_override;
+ void OnChannelCreate(Channel *c) override;
+ void OnChannelDelete(Channel *c) override;
+ void OnLeaveChannel(User *u, Channel *c) override;
+ void OnJoinChannel(User *u, Channel *c) override;
+ EventReturn OnChannelModeSet(Channel *c, MessageSource &setter, ChannelMode *mode, const Anope::string &param) override;
+ EventReturn OnChannelModeUnset(Channel *c, MessageSource &setter, ChannelMode *mode, const Anope::string &param) override;
- void OnTopicUpdated(User *source, Channel *c, const Anope::string &user, const Anope::string &topic) anope_override;
+ void OnTopicUpdated(User *source, Channel *c, const Anope::string &user, const Anope::string &topic) override;
- void OnBotNotice(User *u, BotInfo *bi, Anope::string &message) anope_override;
+ void OnBotNotice(User *u, BotInfo *bi, Anope::string &message) override;
};
diff --git a/modules/extra/stats/m_chanstats.cpp b/modules/extra/stats/m_chanstats.cpp
index 5df68eae6..34cd08056 100644
--- a/modules/extra/stats/m_chanstats.cpp
+++ b/modules/extra/stats/m_chanstats.cpp
@@ -18,7 +18,7 @@ class CommandCSSetChanstats : public Command
this->SetSyntax(_("\037channel\037 {ON | OFF}"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (!ci)
@@ -54,7 +54,7 @@ class CommandCSSetChanstats : public Command
this->OnSyntaxError(source, "");
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -107,12 +107,12 @@ class CommandNSSetChanstats : public Command
this->OnSyntaxError(source, "CHANSTATS");
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
this->Run(source, source.nc->display, params[0]);
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -130,12 +130,12 @@ class CommandNSSASetChanstats : public CommandNSSetChanstats
this->SetSyntax(_("\037nickname\037 {ON | OFF}"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
this->Run(source, params[0], params[1], true);
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(" ");
@@ -149,11 +149,11 @@ class MySQLInterface : public SQL::Interface
public:
MySQLInterface(Module *o) : SQL::Interface(o) { }
- void OnResult(const SQL::Result &r) anope_override
+ void OnResult(const SQL::Result &r) override
{
}
- void OnError(const SQL::Result &r) anope_override
+ void OnError(const SQL::Result &r) override
{
if (!r.GetQuery().query.empty())
Log(LOG_DEBUG) << "Chanstats: Error executing query " << r.finished_query << ": " << r.GetError();
@@ -492,7 +492,7 @@ class MChanstats : public Module
{
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
Configuration::Block *block = conf->GetModule(this);
prefix = block->Get<const Anope::string>("prefix", "anope_");
@@ -509,7 +509,7 @@ class MChanstats : public Module
Log(this) << "no database connection to " << engine;
}
- void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_all) anope_override
+ void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_all) override
{
if (!show_all)
return;
@@ -517,7 +517,7 @@ class MChanstats : public Module
info.AddOption(_("Chanstats"));
}
- void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_hidden) anope_override
+ void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_hidden) override
{
if (!show_hidden)
return;
@@ -525,7 +525,7 @@ class MChanstats : public Module
info.AddOption(_("Chanstats"));
}
- void OnTopicUpdated(User *source, Channel *c, const Anope::string &user, const Anope::string &topic) anope_override
+ void OnTopicUpdated(User *source, Channel *c, const Anope::string &user, const Anope::string &topic) override
{
if (!source || !source->Account() || !c->ci || !cs_stats.HasExt(c->ci))
return;
@@ -535,13 +535,13 @@ class MChanstats : public Module
this->RunQuery(query);
}
- EventReturn OnChannelModeSet(Channel *c, MessageSource &setter, ChannelMode *mode, const Anope::string &param) anope_override
+ EventReturn OnChannelModeSet(Channel *c, MessageSource &setter, ChannelMode *mode, const Anope::string &param) override
{
this->OnModeChange(c, setter.GetUser());
return EVENT_CONTINUE;
}
- EventReturn OnChannelModeUnset(Channel *c, MessageSource &setter, ChannelMode *, const Anope::string &param) anope_override
+ EventReturn OnChannelModeUnset(Channel *c, MessageSource &setter, ChannelMode *, const Anope::string &param) override
{
this->OnModeChange(c, setter.GetUser());
return EVENT_CONTINUE;
@@ -560,7 +560,7 @@ class MChanstats : public Module
}
public:
- void OnPreUserKicked(const MessageSource &source, ChanUserContainer *cu, const Anope::string &kickmsg) anope_override
+ void OnPreUserKicked(const MessageSource &source, ChanUserContainer *cu, const Anope::string &kickmsg) override
{
if (!cu->chan->ci || !cs_stats.HasExt(cu->chan->ci))
return;
@@ -576,7 +576,7 @@ class MChanstats : public Module
this->RunQuery(query);
}
- void OnPrivmsg(User *u, Channel *c, Anope::string &msg) anope_override
+ void OnPrivmsg(User *u, Channel *c, Anope::string &msg) override
{
if (!c->ci || !cs_stats.HasExt(c->ci))
return;
@@ -617,14 +617,14 @@ class MChanstats : public Module
this->RunQuery(query);
}
- void OnDelCore(NickCore *nc) anope_override
+ void OnDelCore(NickCore *nc) override
{
query = "DELETE FROM `" + prefix + "chanstats` WHERE `nick` = @nick@;";
query.SetValue("nick", nc->display);
this->RunQuery(query);
}
- void OnChangeCoreDisplay(NickCore *nc, const Anope::string &newdisplay) anope_override
+ void OnChangeCoreDisplay(NickCore *nc, const Anope::string &newdisplay) override
{
query = "CALL " + prefix + "chanstats_proc_chgdisplay(@old_display@, @new_display@);";
query.SetValue("old_display", nc->display);
@@ -632,20 +632,20 @@ class MChanstats : public Module
this->RunQuery(query);
}
- void OnDelChan(ChannelInfo *ci) anope_override
+ void OnDelChan(ChannelInfo *ci) override
{
query = "DELETE FROM `" + prefix + "chanstats` WHERE `chan` = @channel@;";
query.SetValue("channel", ci->name);
this->RunQuery(query);
}
- void OnChanRegistered(ChannelInfo *ci)
+ void OnChanRegistered(ChannelInfo *ci) override
{
if (CSDefChanstats)
ci->Extend<bool>("CS_STATS");
}
- void OnNickRegister(User *user, NickAlias *na, const Anope::string &)
+ void OnNickRegister(User *user, NickAlias *na, const Anope::string &) override
{
if (NSDefChanstats)
na->nc->Extend<bool>("NS_STATS");
diff --git a/modules/fantasy.cpp b/modules/fantasy.cpp
index 4928bc824..e35b2c299 100644
--- a/modules/fantasy.cpp
+++ b/modules/fantasy.cpp
@@ -20,7 +20,7 @@ class CommandBSSetFantasy : public Command
this->SetSyntax(_("\037channel\037 {\037ON|OFF\037}"));
}
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
ChannelInfo *ci = ChannelInfo::Find(params[0]);
const Anope::string &value = params[1];
@@ -63,7 +63,7 @@ class CommandBSSetFantasy : public Command
this->OnSyntaxError(source, source.command);
}
- bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &) override
{
this->SendSyntax(source);
source.Reply(_(" \n"
@@ -92,7 +92,7 @@ class Fantasy : public Module
{
}
- void OnPrivmsg(User *u, Channel *c, Anope::string &msg) anope_override
+ void OnPrivmsg(User *u, Channel *c, Anope::string &msg) override
{
if (!u || !c || !c->ci || !c->ci->bi || msg.empty() || msg[0] == '\1')
return;
@@ -208,7 +208,7 @@ class Fantasy : public Module
FOREACH_MOD(OnPostCommand, (source, cmd, params));
}
- void OnBotInfo(CommandSource &source, BotInfo *bi, ChannelInfo *ci, InfoFormatter &info) anope_override
+ void OnBotInfo(CommandSource &source, BotInfo *bi, ChannelInfo *ci, InfoFormatter &info) override
{
if (fantasy.HasExt(ci))
info.AddOption(_("Fantasy"));
diff --git a/modules/m_dns.cpp b/modules/m_dns.cpp
index 937e1f303..525e8637d 100644
--- a/modules/m_dns.cpp
+++ b/modules/m_dns.cpp
@@ -209,11 +209,11 @@ class Packet : public Query
/* Source or destination of the packet */
sockaddrs addr;
/* ID for this packet */
- unsigned short id;
+ unsigned short id = 0;
/* Flags on the packet */
- unsigned short flags;
+ unsigned short flags = 0;
- Packet(Manager *m, sockaddrs *a) : manager(m), id(0), flags(0)
+ Packet(Manager *m, sockaddrs *a) : manager(m)
{
if (a)
addr = *a;
@@ -286,10 +286,8 @@ class Packet : public Query
output[pos++] = this->additional.size() >> 8;
output[pos++] = this->additional.size() & 0xFF;
- for (unsigned i = 0; i < this->questions.size(); ++i)
+ for (auto &q : this->questions)
{
- Question &q = this->questions[i];
-
if (q.type == QUERY_PTR)
{
sockaddrs ip(q.name);
@@ -324,11 +322,10 @@ class Packet : public Query
}
std::vector<ResourceRecord> types[] = { this->answers, this->authorities, this->additional };
- for (int i = 0; i < 3; ++i)
- for (unsigned j = 0; j < types[i].size(); ++j)
+ for (auto &type : types)
+ {
+ for (const auto &rr : type)
{
- ResourceRecord &rr = types[i][j];
-
this->PackName(output, output_size, pos, rr.name);
if (pos + 8 >= output_size)
@@ -443,6 +440,7 @@ class Packet : public Query
break;
}
}
+ }
return pos;
}
@@ -453,7 +451,7 @@ namespace DNS
class ReplySocket : public virtual Socket
{
public:
- virtual ~ReplySocket() { }
+ ~ReplySocket() override = default;
virtual void Reply(Packet *p) = 0;
};
}
@@ -468,34 +466,34 @@ class TCPSocket : public ListenSocket
class Client : public ClientSocket, public Timer, public ReplySocket
{
Manager *manager;
- Packet *packet;
+ Packet *packet = nullptr;
unsigned char packet_buffer[524];
- int length;
+ int length = 0;
public:
- Client(Manager *m, TCPSocket *l, int fd, const sockaddrs &addr) : Socket(fd, l->IsIPv6()), ClientSocket(l, addr), Timer(5),
- manager(m), packet(NULL), length(0)
+ Client(Manager *m, TCPSocket *l, int fd, const sockaddrs &addr) : Socket(fd, l->GetFamily()), ClientSocket(l, addr), Timer(5),
+ manager(m)
{
Log(LOG_DEBUG_2) << "Resolver: New client from " << addr.addr();
}
- ~Client()
+ ~Client() override
{
Log(LOG_DEBUG_2) << "Resolver: Exiting client from " << clientaddr.addr();
delete packet;
}
/* Times out after a few seconds */
- void Tick(time_t) anope_override { }
+ void Tick(time_t) override { }
- void Reply(Packet *p) anope_override
+ void Reply(Packet *p) override
{
delete packet;
packet = p;
SocketEngine::Change(this, true, SF_WRITABLE);
}
- bool ProcessRead() anope_override
+ bool ProcessRead() override
{
Log(LOG_DEBUG_2) << "Resolver: Reading from DNS TCP socket";
@@ -515,7 +513,7 @@ class TCPSocket : public ListenSocket
return true;
}
- bool ProcessWrite() anope_override
+ bool ProcessWrite() override
{
Log(LOG_DEBUG_2) << "Resolver: Writing to DNS TCP socket";
@@ -545,7 +543,7 @@ class TCPSocket : public ListenSocket
TCPSocket(Manager *m, const Anope::string &ip, int port) : Socket(-1, ip.find(':') != Anope::string::npos), ListenSocket(ip, port, ip.find(':') != Anope::string::npos), manager(m) { }
- ClientSocket *OnAccept(int fd, const sockaddrs &addr) anope_override
+ ClientSocket *OnAccept(int fd, const sockaddrs &addr) override
{
return new Client(this->manager, this, fd, addr);
}
@@ -560,13 +558,13 @@ class UDPSocket : public ReplySocket
public:
UDPSocket(Manager *m, const Anope::string &ip, int port) : Socket(-1, ip.find(':') != Anope::string::npos, SOCK_DGRAM), manager(m) { }
- ~UDPSocket()
+ ~UDPSocket() override
{
- for (unsigned i = 0; i < packets.size(); ++i)
- delete packets[i];
+ for (const auto *packet : packets)
+ delete packet;
}
- void Reply(Packet *p) anope_override
+ void Reply(Packet *p) override
{
packets.push_back(p);
SocketEngine::Change(this, true, SF_WRITABLE);
@@ -574,7 +572,7 @@ class UDPSocket : public ReplySocket
std::deque<Packet *>& GetPackets() { return packets; }
- bool ProcessRead() anope_override
+ bool ProcessRead() override
{
Log(LOG_DEBUG_2) << "Resolver: Reading from DNS UDP socket";
@@ -585,7 +583,7 @@ class UDPSocket : public ReplySocket
return this->manager->HandlePacket(this, packet_buffer, length, &from_server);
}
- bool ProcessWrite() anope_override
+ bool ProcessWrite() override
{
Log(LOG_DEBUG_2) << "Resolver: Writing to DNS UDP socket";
@@ -622,7 +620,7 @@ class NotifySocket : public Socket
SocketEngine::Change(this, true, SF_WRITABLE);
}
- bool ProcessWrite() anope_override
+ bool ProcessWrite() override
{
if (!packet)
return false;
@@ -649,25 +647,24 @@ class MyManager : public Manager, public Timer
{
uint32_t serial;
- typedef TR1NS::unordered_map<Question, Query, Question::hash> cache_map;
+ typedef std::unordered_map<Question, Query, Question::hash> cache_map;
cache_map cache;
- TCPSocket *tcpsock;
- UDPSocket *udpsock;
+ TCPSocket *tcpsock = nullptr;
+ UDPSocket *udpsock = nullptr;
- bool listen;
+ bool listen = false;
sockaddrs addrs;
std::vector<std::pair<Anope::string, short> > notify;
public:
std::map<unsigned short, Request *> requests;
- MyManager(Module *creator) : Manager(creator), Timer(300, Anope::CurTime, true), serial(Anope::CurTime), tcpsock(NULL), udpsock(NULL),
- listen(false), cur_id(rand())
+ MyManager(Module *creator) : Manager(creator), Timer(300, Anope::CurTime, true), serial(Anope::CurTime), cur_id(rand())
{
}
- ~MyManager()
+ ~MyManager() override
{
delete udpsock;
delete tcpsock;
@@ -733,7 +730,7 @@ class MyManager : public Manager, public Timer
}
public:
- void Process(Request *req) anope_override
+ void Process(Request *req) override
{
Log(LOG_DEBUG_2) << "Resolver: Processing request to lookup " << req->name << ", of type " << req->type;
@@ -760,12 +757,12 @@ class MyManager : public Manager, public Timer
this->udpsock->Reply(p);
}
- void RemoveRequest(Request *req) anope_override
+ void RemoveRequest(Request *req) override
{
this->requests.erase(req->id);
}
- bool HandlePacket(ReplySocket *s, const unsigned char *const packet_buffer, int length, sockaddrs *from) anope_override
+ bool HandlePacket(ReplySocket *s, const unsigned char *const packet_buffer, int length, sockaddrs *from) override
{
if (length < Packet::HEADER_LENGTH)
return true;
@@ -800,10 +797,8 @@ class MyManager : public Manager, public Timer
packet->authorities.clear();
packet->additional.clear();
- for (unsigned i = 0; i < recv_packet.questions.size(); ++i)
+ for (auto &q : recv_packet.questions)
{
- const Question& q = recv_packet.questions[i];
-
if (q.type == QUERY_AXFR || q.type == QUERY_SOA)
{
ResourceRecord rr(q.name, QUERY_SOA);
@@ -826,10 +821,8 @@ class MyManager : public Manager, public Timer
FOREACH_MOD(OnDnsRequest, (recv_packet, packet));
- for (unsigned i = 0; i < recv_packet.questions.size(); ++i)
+ for (auto &q : recv_packet.questions)
{
- const Question& q = recv_packet.questions[i];
-
if (q.type == QUERY_AXFR)
{
ResourceRecord rr(q.name, QUERY_SOA);
@@ -920,19 +913,16 @@ class MyManager : public Manager, public Timer
return true;
}
- void UpdateSerial() anope_override
+ void UpdateSerial() override
{
serial = Anope::CurTime;
}
- void Notify(const Anope::string &zone) anope_override
+ void Notify(const Anope::string &zone) override
{
/* notify slaves of the update */
- for (unsigned i = 0; i < notify.size(); ++i)
+ for (const auto &[ip, port] : notify)
{
- const Anope::string &ip = notify[i].first;
- short port = notify[i].second;
-
sockaddrs addr;
addr.pton(ip.find(':') != Anope::string::npos ? AF_INET6 : AF_INET, ip, port);
if (!addr.valid())
@@ -950,18 +940,18 @@ class MyManager : public Manager, public Timer
continue;
}
- packet->questions.push_back(Question(zone, QUERY_SOA));
+ packet->questions.emplace_back(zone, QUERY_SOA);
new NotifySocket(ip.find(':') != Anope::string::npos, packet);
}
}
- uint32_t GetSerial() const anope_override
+ uint32_t GetSerial() const override
{
return serial;
}
- void Tick(time_t now) anope_override
+ void Tick(time_t now) override
{
Log(LOG_DEBUG_2) << "Resolver: Purging DNS cache";
@@ -1023,7 +1013,7 @@ class ModuleDNS : public Module
}
- ~ModuleDNS()
+ ~ModuleDNS() override
{
for (std::map<int, Socket *>::const_iterator it = SocketEngine::Sockets.begin(), it_end = SocketEngine::Sockets.end(); it != it_end;)
{
@@ -1035,7 +1025,7 @@ class ModuleDNS : public Module
}
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
Configuration::Block *block = conf->GetModule(this);
@@ -1053,7 +1043,7 @@ class ModuleDNS : public Module
Anope::string nip = n->Get<Anope::string>("ip");
short nport = n->Get<short>("port");
- notify.push_back(std::make_pair(nip, nport));
+ notify.emplace_back(nip, nport);
}
if (Anope::IsFile(nameserver))
@@ -1101,7 +1091,7 @@ class ModuleDNS : public Module
}
}
- void OnModuleUnload(User *u, Module *m) anope_override
+ void OnModuleUnload(User *u, Module *m) override
{
for (std::map<unsigned short, Request *>::iterator it = this->manager.requests.begin(), it_end = this->manager.requests.end(); it != it_end;)
{
diff --git a/modules/m_dnsbl.cpp b/modules/m_dnsbl.cpp
index d54969fad..59cd1f3fc 100644
--- a/modules/m_dnsbl.cpp
+++ b/modules/m_dnsbl.cpp
@@ -18,25 +18,23 @@ struct Blacklist
{
struct Reply
{
- int code;
+ int code = 0;
Anope::string reason;
- bool allow_account;
+ bool allow_account = false;
- Reply() : code(0), allow_account(false) { }
+ Reply() = default;
};
Anope::string name;
- time_t bantime;
+ time_t bantime = 0;
Anope::string reason;
std::vector<Reply> replies;
- Blacklist() : bantime(0) { }
-
- Reply *Find(int code)
+ const Reply *Find(int code)
{
- for (unsigned int i = 0; i < replies.size(); ++i)
- if (replies[i].code == code)
- return &replies[i];
+ for (const auto &reply : replies)
+ if (reply.code == code)
+ return &reply;
return NULL;
}
};
@@ -50,7 +48,7 @@ class DNSBLResolver : public Request
public:
DNSBLResolver(Module *c, User *u, const Blacklist &b, const Anope::string &host, bool add_akill) : Request(dnsmanager, c, host, QUERY_A, true), user(u), blacklist(b), add_to_akill(add_akill) { }
- void OnLookupComplete(const Query *record) anope_override
+ void OnLookupComplete(const Query *record) override
{
if (!user || user->Quitting())
return;
@@ -64,7 +62,7 @@ class DNSBLResolver : public Request
sresult.pton(AF_INET, ans_record.rdata);
int result = sresult.sa4.sin_addr.s_addr >> 24;
- Blacklist::Reply *reply = blacklist.Find(result);
+ const Blacklist::Reply *reply = blacklist.Find(result);
if (!blacklist.replies.empty() && !reply)
return;
@@ -110,7 +108,7 @@ class ModuleDNSBL : public Module
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
Configuration::Block *block = conf->GetModule(this);
this->check_on_connect = block->Get<bool>("check_on_connect");
@@ -152,7 +150,7 @@ class ModuleDNSBL : public Module
}
}
- void OnUserConnect(User *user, bool &exempt) anope_override
+ void OnUserConnect(User *user, bool &exempt) override
{
if (exempt || user->Quitting() || (!this->check_on_connect && !Me->IsSynced()) || !dnsmanager)
return;
@@ -175,10 +173,8 @@ class ModuleDNSBL : public Module
Anope::string reverse = user->ip.reverse();
- for (unsigned i = 0; i < this->blacklists.size(); ++i)
+ for (const auto &b : this->blacklists)
{
- const Blacklist &b = this->blacklists[i];
-
Anope::string dnsbl_host = reverse + "." + b.name;
DNSBLResolver *res = NULL;
try
diff --git a/modules/m_helpchan.cpp b/modules/m_helpchan.cpp
index 24a1059d3..4a56f5ec0 100644
--- a/modules/m_helpchan.cpp
+++ b/modules/m_helpchan.cpp
@@ -15,7 +15,7 @@ class HelpChannel : public Module
{
}
- EventReturn OnChannelModeSet(Channel *c, MessageSource &, ChannelMode *mode, const Anope::string &param) anope_override
+ EventReturn OnChannelModeSet(Channel *c, MessageSource &, ChannelMode *mode, const Anope::string &param) override
{
if (mode->name == "OP" && c && c->ci && c->name.equals_ci(Config->GetModule(this)->Get<const Anope::string>("helpchannel")))
{
diff --git a/modules/m_httpd.cpp b/modules/m_httpd.cpp
index 31b23c2c3..5edd891ab 100644
--- a/modules/m_httpd.cpp
+++ b/modules/m_httpd.cpp
@@ -41,19 +41,19 @@ class MyHTTPClient : public HTTPClient
{
HTTPProvider *provider;
HTTPMessage message;
- bool header_done, served;
+ bool header_done = false, served = false;
Anope::string page_name;
Reference<HTTPPage> page;
Anope::string ip;
- unsigned content_length;
+ unsigned content_length = 0;
enum
{
ACTION_NONE,
ACTION_GET,
ACTION_POST
- } action;
+ } action = ACTION_NONE;
void Serve()
{
@@ -69,10 +69,8 @@ class MyHTTPClient : public HTTPClient
if (std::find(this->provider->ext_ips.begin(), this->provider->ext_ips.end(), this->ip) != this->provider->ext_ips.end())
{
- for (unsigned i = 0; i < this->provider->ext_headers.size(); ++i)
+ for (auto &token : this->provider->ext_headers)
{
- const Anope::string &token = this->provider->ext_headers[i];
-
if (this->message.headers.count(token))
{
this->ip = this->message.headers[token];
@@ -94,28 +92,28 @@ class MyHTTPClient : public HTTPClient
public:
time_t created;
- MyHTTPClient(HTTPProvider *l, int f, const sockaddrs &a) : Socket(f, l->IsIPv6()), HTTPClient(l, f, a), provider(l), header_done(false), served(false), ip(a.addr()), content_length(0), action(ACTION_NONE), created(Anope::CurTime)
+ MyHTTPClient(HTTPProvider *l, int f, const sockaddrs &a) : Socket(f, l->GetFamily()), HTTPClient(l, f, a), provider(l), ip(a.addr()), created(Anope::CurTime)
{
Log(LOG_DEBUG, "httpd") << "Accepted connection " << f << " from " << a.addr();
}
- ~MyHTTPClient()
+ ~MyHTTPClient() override
{
Log(LOG_DEBUG, "httpd") << "Closing connection " << this->GetFD() << " from " << this->ip;
}
/* Close connection once all data is written */
- bool ProcessWrite() anope_override
+ bool ProcessWrite() override
{
return !BinarySocket::ProcessWrite() || this->write_buffer.empty() ? false : true;
}
- const Anope::string GetIP() anope_override
+ const Anope::string GetIP() override
{
return this->ip;
}
- bool Read(const char *buffer, size_t l) anope_override
+ bool Read(const char *buffer, size_t l) override
{
message.content.append(buffer, l);
@@ -233,7 +231,7 @@ class MyHTTPClient : public HTTPClient
return true;
}
- void SendError(HTTPError err, const Anope::string &msg) anope_override
+ void SendError(HTTPError err, const Anope::string &msg) override
{
HTTPReply h;
@@ -244,7 +242,7 @@ class MyHTTPClient : public HTTPClient
this->SendReply(&h);
}
- void SendReply(HTTPReply *msg) anope_override
+ void SendReply(HTTPReply *msg) override
{
this->WriteClient("HTTP/1.1 " + GetStatusFromCode(msg->error));
this->WriteClient("Date: " + BuildDate());
@@ -255,30 +253,27 @@ class MyHTTPClient : public HTTPClient
this->WriteClient("Content-Type: " + msg->content_type);
this->WriteClient("Content-Length: " + stringify(msg->length));
- for (unsigned i = 0; i < msg->cookies.size(); ++i)
+ for (const auto &cookie : msg->cookies)
{
Anope::string buf = "Set-Cookie:";
- for (HTTPReply::cookie::iterator it = msg->cookies[i].begin(), it_end = msg->cookies[i].end(); it != it_end; ++it)
- buf += " " + it->first + "=" + it->second + ";";
+ for (const auto &[name, value] : cookie)
+ buf += " " + name + "=" + value + ";";
buf.erase(buf.length() - 1);
this->WriteClient(buf);
}
- typedef std::map<Anope::string, Anope::string> map;
- for (map::iterator it = msg->headers.begin(), it_end = msg->headers.end(); it != it_end; ++it)
- this->WriteClient(it->first + ": " + it->second);
+ for (auto &[name, value] : msg->headers)
+ this->WriteClient(name + ": " + value);
this->WriteClient("Connection: Close");
this->WriteClient("");
- for (unsigned i = 0; i < msg->out.size(); ++i)
+ for (auto *d : msg->out)
{
- HTTPReply::Data* d = msg->out[i];
-
- this->Write(d->buf, d->len);
+ this->Write(d->buf, d->len);
delete d;
}
@@ -296,7 +291,7 @@ class MyHTTPProvider : public HTTPProvider, public Timer
public:
MyHTTPProvider(Module *c, const Anope::string &n, const Anope::string &i, const unsigned short p, const int t, bool s) : Socket(-1, i.find(':') != Anope::string::npos), HTTPProvider(c, n, i, p, s), Timer(c, 10, Anope::CurTime, true), timeout(t) { }
- void Tick(time_t) anope_override
+ void Tick(time_t) override
{
while (!this->clients.empty())
{
@@ -309,24 +304,24 @@ class MyHTTPProvider : public HTTPProvider, public Timer
}
}
- ClientSocket* OnAccept(int fd, const sockaddrs &addr) anope_override
+ ClientSocket* OnAccept(int fd, const sockaddrs &addr) override
{
MyHTTPClient *c = new MyHTTPClient(this, fd, addr);
- this->clients.push_back(c);
+ this->clients.emplace_back(c);
return c;
}
- bool RegisterPage(HTTPPage *page) anope_override
+ bool RegisterPage(HTTPPage *page) override
{
- return this->pages.insert(std::make_pair(page->GetURL(), page)).second;
+ return this->pages.emplace(page->GetURL(), page).second;
}
- void UnregisterPage(HTTPPage *page) anope_override
+ void UnregisterPage(HTTPPage *page) override
{
this->pages.erase(page->GetURL());
}
- HTTPPage* FindPage(const Anope::string &pname) anope_override
+ HTTPPage* FindPage(const Anope::string &pname) override
{
if (this->pages.count(pname) == 0)
return NULL;
@@ -344,7 +339,7 @@ class HTTPD : public Module
}
- ~HTTPD()
+ ~HTTPD() override
{
for (std::map<int, Socket *>::const_iterator it = SocketEngine::Sockets.begin(), it_end = SocketEngine::Sockets.end(); it != it_end;)
{
@@ -358,7 +353,7 @@ class HTTPD : public Module
this->providers.clear();
}
- void OnReload(Configuration::Conf *config) anope_override
+ void OnReload(Configuration::Conf *config) override
{
Configuration::Block *conf = config->GetModule(this);
std::set<Anope::string> existing;
@@ -453,12 +448,10 @@ class HTTPD : public Module
}
}
- void OnModuleLoad(User *u, Module *m) anope_override
+ void OnModuleLoad(User *u, Module *m) override
{
- for (std::map<Anope::string, MyHTTPProvider *>::iterator it = this->providers.begin(), it_end = this->providers.end(); it != it_end; ++it)
+ for (auto &[_, p] : this->providers)
{
- MyHTTPProvider *p = it->second;
-
if (p->IsSSL() && sslref)
try
{
diff --git a/modules/m_proxyscan.cpp b/modules/m_proxyscan.cpp
index 05323f1ac..50a0b021c 100644
--- a/modules/m_proxyscan.cpp
+++ b/modules/m_proxyscan.cpp
@@ -26,16 +26,16 @@ class ProxyCallbackListener : public ListenSocket
class ProxyCallbackClient : public ClientSocket, public BufferedSocket
{
public:
- ProxyCallbackClient(ListenSocket *l, int f, const sockaddrs &a) : Socket(f, l->IsIPv6()), ClientSocket(l, a), BufferedSocket()
+ ProxyCallbackClient(ListenSocket *l, int f, const sockaddrs &a) : Socket(f, l->GetFamily()), ClientSocket(l, a), BufferedSocket()
{
}
- void OnAccept() anope_override
+ void OnAccept() override
{
this->Write(ProxyCheckString);
}
- bool ProcessWrite() anope_override
+ bool ProcessWrite() override
{
return !BufferedSocket::ProcessWrite() || this->write_buffer.empty() ? false : true;
}
@@ -46,7 +46,7 @@ class ProxyCallbackListener : public ListenSocket
{
}
- ClientSocket *OnAccept(int fd, const sockaddrs &addr) anope_override
+ ClientSocket *OnAccept(int fd, const sockaddrs &addr) override
{
return new ProxyCallbackClient(this, fd, addr);
}
@@ -69,12 +69,12 @@ class ProxyConnect : public ConnectionSocket
proxies.insert(this);
}
- ~ProxyConnect()
+ ~ProxyConnect() override
{
proxies.erase(this);
}
- virtual void OnConnect() anope_override = 0;
+ void OnConnect() override = 0;
virtual const Anope::string GetType() const = 0;
protected:
@@ -87,7 +87,7 @@ class ProxyConnect : public ConnectionSocket
reason = reason.replace_all_cs("%p", stringify(this->conaddr.port()));
BotInfo *OperServ = Config->GetClient("OperServ");
- Log(OperServ) << "PROXYSCAN: Open " << this->GetType() << " proxy found on " << this->conaddr.addr() << ":" << this->conaddr.port() << " (" << reason << ")";
+ Log(OperServ) << "PROXYSCAN: Open " << this->GetType() << " proxy found on " << this->conaddr.str() << " (" << reason << ")";
XLine *x = new XLine("*@" + this->conaddr.addr(), OperServ ? OperServ->nick : "", Anope::CurTime + this->proxy.duration, reason, XLineManager::GenerateUID());
if (add_to_akill && akills)
{
@@ -114,7 +114,7 @@ class HTTPProxyConnect : public ProxyConnect, public BufferedSocket
{
}
- void OnConnect() anope_override
+ void OnConnect() override
{
this->Write("CONNECT %s:%d HTTP/1.0", target_ip.c_str(), target_port);
this->Write("Content-Length: 0");
@@ -122,12 +122,12 @@ class HTTPProxyConnect : public ProxyConnect, public BufferedSocket
this->Write("");
}
- const Anope::string GetType() const anope_override
+ const Anope::string GetType() const override
{
return "HTTP";
}
- bool ProcessRead() anope_override
+ bool ProcessRead() override
{
bool b = BufferedSocket::ProcessRead();
if (this->GetLine() == ProxyCheckString)
@@ -146,7 +146,7 @@ class SOCKS5ProxyConnect : public ProxyConnect, public BinarySocket
{
}
- void OnConnect() anope_override
+ void OnConnect() override
{
sockaddrs target_addr;
char buf[4 + sizeof(target_addr.sa4.sin_addr.s_addr) + sizeof(target_addr.sa4.sin_port)];
@@ -173,12 +173,12 @@ class SOCKS5ProxyConnect : public ProxyConnect, public BinarySocket
this->Write(buf, ptr);
}
- const Anope::string GetType() const anope_override
+ const Anope::string GetType() const override
{
return "SOCKS5";
}
- bool Read(const char *buffer, size_t l) anope_override
+ bool Read(const char *buffer, size_t l) override
{
if (l >= ProxyCheckString.length() && !strncmp(buffer, ProxyCheckString.c_str(), ProxyCheckString.length()))
{
@@ -205,7 +205,7 @@ class ModuleProxyScan : public Module
{
}
- void Tick(time_t) anope_override
+ void Tick(time_t) override
{
for (std::set<ProxyConnect *>::iterator it = ProxyConnect::proxies.begin(), it_end = ProxyConnect::proxies.end(); it != it_end;)
{
@@ -227,7 +227,7 @@ class ModuleProxyScan : public Module
this->listener = NULL;
}
- ~ModuleProxyScan()
+ ~ModuleProxyScan() override
{
for (std::set<ProxyConnect *>::iterator it = ProxyConnect::proxies.begin(), it_end = ProxyConnect::proxies.end(); it != it_end;)
{
@@ -249,7 +249,7 @@ class ModuleProxyScan : public Module
delete this->listener;
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
Configuration::Block *config = Config->GetModule(this);
@@ -329,7 +329,7 @@ class ModuleProxyScan : public Module
}
}
- void OnUserConnect(User *user, bool &exempt) anope_override
+ void OnUserConnect(User *user, bool &exempt) override
{
if (exempt || user->Quitting() || !Me->IsSynced() || !user->server->IsSynced())
return;
@@ -350,20 +350,20 @@ class ModuleProxyScan : public Module
{
ProxyCheck &p = this->proxyscans[i - 1];
- for (std::set<Anope::string, ci::less>::iterator it = p.types.begin(), it_end = p.types.end(); it != it_end; ++it)
+ for (const auto &type : p.types)
{
- for (unsigned k = 0; k < p.ports.size(); ++k)
+ for (const auto port : p.ports)
{
try
{
ProxyConnect *con = NULL;
- if (it->equals_ci("HTTP"))
- con = new HTTPProxyConnect(p, p.ports[k]);
- else if (it->equals_ci("SOCKS5"))
- con = new SOCKS5ProxyConnect(p, p.ports[k]);
+ if (type.equals_ci("HTTP"))
+ con = new HTTPProxyConnect(p, port);
+ else if (type.equals_ci("SOCKS5"))
+ con = new SOCKS5ProxyConnect(p, port);
else
continue;
- con->Connect(user->ip.addr(), p.ports[k]);
+ con->Connect(user->ip.addr(), port);
}
catch (const SocketException &ex)
{
diff --git a/modules/m_redis.cpp b/modules/m_redis.cpp
index f92baade5..4148ff65a 100644
--- a/modules/m_redis.cpp
+++ b/modules/m_redis.cpp
@@ -23,12 +23,12 @@ class RedisSocket : public BinarySocket, public ConnectionSocket
RedisSocket(MyRedisService *pro, bool v6) : Socket(-1, v6), provider(pro) { }
- ~RedisSocket();
+ ~RedisSocket() override;
- void OnConnect() anope_override;
- void OnError(const Anope::string &error) anope_override;
+ void OnConnect() override;
+ void OnError(const Anope::string &error) override;
- bool Read(const char *buffer, size_t l) anope_override;
+ bool Read(const char *buffer, size_t l) override;
};
class Transaction : public Interface
@@ -38,20 +38,18 @@ class Transaction : public Interface
Transaction(Module *creator) : Interface(creator) { }
- ~Transaction()
+ ~Transaction() override
{
- for (unsigned i = 0; i < interfaces.size(); ++i)
+ for (auto *iface : interfaces)
{
- Interface *inter = interfaces[i];
-
- if (!inter)
+ if (!iface)
continue;
- inter->OnError("Interface going away");
+ iface->OnError("Interface going away");
}
}
- void OnResult(const Reply &r) anope_override
+ void OnResult(const Reply &r) override
{
/* This is a multi bulk reply of the results of the queued commands
* in this transaction
@@ -59,10 +57,8 @@ class Transaction : public Interface
Log(LOG_DEBUG_2) << "redis: transaction complete with " << r.multi_bulk.size() << " results";
- for (unsigned i = 0; i < r.multi_bulk.size(); ++i)
+ for (auto *result : r.multi_bulk)
{
- const Reply *reply = r.multi_bulk[i];
-
if (interfaces.empty())
break;
@@ -70,7 +66,7 @@ class Transaction : public Interface
interfaces.pop_front();
if (inter)
- inter->OnResult(*reply);
+ inter->OnResult(*result);
}
}
};
@@ -82,13 +78,12 @@ class MyRedisService : public Provider
int port;
unsigned db;
- RedisSocket *sock, *sub;
+ RedisSocket *sock = nullptr, *sub = nullptr;
Transaction ti;
- bool in_transaction;
+ bool in_transaction = false;
- MyRedisService(Module *c, const Anope::string &n, const Anope::string &h, int p, unsigned d) : Provider(c, n), host(h), port(p), db(d), sock(NULL), sub(NULL),
- ti(c), in_transaction(false)
+ MyRedisService(Module *c, const Anope::string &n, const Anope::string &h, int p, unsigned d) : Provider(c, n), host(h), port(p), db(d), ti(c)
{
sock = new RedisSocket(this, host.find(':') != Anope::string::npos);
sock->Connect(host, port);
@@ -97,7 +92,7 @@ class MyRedisService : public Provider
sub->Connect(host, port);
}
- ~MyRedisService()
+ ~MyRedisService() override
{
if (sock)
{
@@ -131,15 +126,13 @@ class MyRedisService : public Provider
Pack(buffer, stringify(args.size()).c_str());
Pack(buffer, "\r\n");
- for (unsigned j = 0; j < args.size(); ++j)
+ for (const auto &[key, value] : args)
{
- const std::pair<const char *, size_t> &pair = args[j];
-
Pack(buffer, "$");
- Pack(buffer, stringify(pair.second).c_str());
+ Pack(buffer, stringify(value).c_str());
Pack(buffer, "\r\n");
- Pack(buffer, pair.first, pair.second);
+ Pack(buffer, key, value);
Pack(buffer, "\r\n");
}
@@ -157,7 +150,7 @@ class MyRedisService : public Provider
}
public:
- bool IsSocketDead() anope_override
+ bool IsSocketDead() override
{
return this->sock && this->sock->flags[SF_DEAD];
}
@@ -165,8 +158,8 @@ class MyRedisService : public Provider
void SendCommand(RedisSocket *s, Interface *i, const std::vector<Anope::string> &cmds)
{
std::vector<std::pair<const char *, size_t> > args;
- for (unsigned j = 0; j < cmds.size(); ++j)
- args.push_back(std::make_pair(cmds[j].c_str(), cmds[j].length()));
+ for (const auto &cmd : cmds)
+ args.emplace_back(cmd.c_str(), cmd.length());
this->Send(s, i, args);
}
@@ -188,15 +181,15 @@ class MyRedisService : public Provider
this->Send(sock, i, args);
}
- void SendCommand(Interface *i, const std::vector<Anope::string> &cmds) anope_override
+ void SendCommand(Interface *i, const std::vector<Anope::string> &cmds) override
{
std::vector<std::pair<const char *, size_t> > args;
- for (unsigned j = 0; j < cmds.size(); ++j)
- args.push_back(std::make_pair(cmds[j].c_str(), cmds[j].length()));
+ for (const auto &cmd : cmds)
+ args.emplace_back(cmd.c_str(), cmd.length());
this->Send(i, args);
}
- void SendCommand(Interface *i, const Anope::string &str) anope_override
+ void SendCommand(Interface *i, const Anope::string &str) override
{
std::vector<Anope::string> args;
spacesepstream(str).GetTokens(args);
@@ -204,7 +197,7 @@ class MyRedisService : public Provider
}
public:
- bool BlockAndProcess() anope_override
+ bool BlockAndProcess() override
{
if (!this->sock->ProcessWrite())
this->sock->flags[SF_DEAD] = true;
@@ -215,7 +208,7 @@ class MyRedisService : public Provider
return !this->sock->interfaces.empty();
}
- void Subscribe(Interface *i, const Anope::string &pattern) anope_override
+ void Subscribe(Interface *i, const Anope::string &pattern) override
{
if (sub == NULL)
{
@@ -224,20 +217,20 @@ class MyRedisService : public Provider
}
std::vector<Anope::string> args;
- args.push_back("PSUBSCRIBE");
+ args.emplace_back("PSUBSCRIBE");
args.push_back(pattern);
this->SendCommand(sub, NULL, args);
sub->subinterfaces[pattern] = i;
}
- void Unsubscribe(const Anope::string &pattern) anope_override
+ void Unsubscribe(const Anope::string &pattern) override
{
if (sub)
sub->subinterfaces.erase(pattern);
}
- void StartTransaction() anope_override
+ void StartTransaction() override
{
if (in_transaction)
throw CoreException();
@@ -246,7 +239,7 @@ class MyRedisService : public Provider
in_transaction = true;
}
- void CommitTransaction() anope_override
+ void CommitTransaction() override
{
/* The result of the transaction comes back to the reply of EXEC as a multi bulk.
* The reply to the individual commands that make up the transaction when executed
@@ -267,14 +260,12 @@ RedisSocket::~RedisSocket()
provider->sub = NULL;
}
- for (unsigned i = 0; i < interfaces.size(); ++i)
+ for (auto *iface : interfaces)
{
- Interface *inter = interfaces[i];
-
- if (!inter)
+ if (!iface)
continue;
- inter->OnError("Interface going away");
+ iface->OnError("Interface going away");
}
}
@@ -403,9 +394,9 @@ size_t RedisSocket::ParseReply(Reply &r, const char *buffer, size_t l)
else if (r.multi_bulk_size >= 0 && r.multi_bulk.size() == static_cast<unsigned>(r.multi_bulk_size))
{
/* This multi bulk is already complete, so check the sub bulks */
- for (unsigned i = 0; i < r.multi_bulk.size(); ++i)
- if (r.multi_bulk[i]->type == Reply::MULTI_BULK)
- ParseReply(*r.multi_bulk[i], buffer + used, l - used);
+ for (auto &bulk : r.multi_bulk)
+ if (bulk->type == Reply::MULTI_BULK)
+ ParseReply(*bulk, buffer + used, l - used);
break;
}
@@ -534,14 +525,13 @@ class ModuleRedis : public Module
{
}
- ~ModuleRedis()
+ ~ModuleRedis() override
{
- for (std::map<Anope::string, MyRedisService *>::iterator it = services.begin(); it != services.end(); ++it)
+ for (auto &[_, p] : services)
{
- MyRedisService *p = it->second;
-
delete p->sock;
p->sock = NULL;
+
delete p->sub;
p->sub = NULL;
@@ -549,7 +539,7 @@ class ModuleRedis : public Module
}
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
Configuration::Block *block = conf->GetModule(this);
std::vector<Anope::string> new_services;
@@ -578,12 +568,10 @@ class ModuleRedis : public Module
}
}
- void OnModuleUnload(User *, Module *m) anope_override
+ void OnModuleUnload(User *, Module *m) override
{
- for (std::map<Anope::string, MyRedisService *>::iterator it = services.begin(); it != services.end(); ++it)
+ for (auto &[_, p] : services)
{
- MyRedisService *p = it->second;
-
if (p->sock)
for (unsigned i = p->sock->interfaces.size(); i > 0; --i)
{
diff --git a/modules/m_rewrite.cpp b/modules/m_rewrite.cpp
index a69c575b9..b5218756c 100644
--- a/modules/m_rewrite.cpp
+++ b/modules/m_rewrite.cpp
@@ -74,10 +74,8 @@ struct Rewrite
static Rewrite *Find(const Anope::string &client, const Anope::string &cmd)
{
- for (unsigned i = 0; i < rewrites.size(); ++i)
+ for (auto &r : rewrites)
{
- Rewrite &r = rewrites[i];
-
if ((client.empty() || r.client.equals_ci(client)) && (r.source_message.equals_ci(cmd) || r.source_message.find_ci(cmd + " ") == 0))
return &r;
}
@@ -87,10 +85,8 @@ struct Rewrite
static Rewrite *Match(const Anope::string &client, const std::vector<Anope::string> &params)
{
- for (unsigned i = 0; i < rewrites.size(); ++i)
+ for (auto &r : rewrites)
{
- Rewrite &r = rewrites[i];
-
if ((client.empty() || r.client.equals_ci(client)) && r.Matches(params))
return &r;
}
@@ -106,7 +102,7 @@ class RewriteCommand : public Command
public:
RewriteCommand(Module *creator) : Command(creator, "rewrite", 0, 0) { }
- void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
std::vector<Anope::string> full_params = params;
full_params.insert(full_params.begin(), source.command);
@@ -125,7 +121,7 @@ class RewriteCommand : public Command
Log() << "m_rewrite: Unable to rewrite '" << source.command << (!params.empty() ? " " + params[0] : "") << "'";
}
- void OnServHelp(CommandSource &source) anope_override
+ void OnServHelp(CommandSource &source) override
{
Rewrite *r = Rewrite::Find(!source.c ? source.service->nick : "", source.command);
if (r != NULL && !r->desc.empty())
@@ -135,7 +131,7 @@ class RewriteCommand : public Command
}
}
- bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
Rewrite *r = Rewrite::Find(!source.c ? source.service->nick : "", source.command);
if (r != NULL && !r->desc.empty())
@@ -158,7 +154,7 @@ class ModuleRewrite : public Module
{
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
Rewrite::rewrites.clear();
diff --git a/modules/m_sasl.cpp b/modules/m_sasl.cpp
index 0475b94e5..d14118e3c 100644
--- a/modules/m_sasl.cpp
+++ b/modules/m_sasl.cpp
@@ -17,7 +17,7 @@ class Plain : public Mechanism
public:
Plain(Module *o) : Mechanism(o, "PLAIN") { }
- void ProcessMessage(Session *sess, const SASL::Message &m) anope_override
+ void ProcessMessage(Session *sess, const SASL::Message &m) override
{
if (m.type == "S")
{
@@ -80,12 +80,12 @@ class External : public Mechanism
throw ModuleException("No CertFP");
}
- Session* CreateSession(const Anope::string &uid) anope_override
+ Session* CreateSession(const Anope::string &uid) override
{
return new Session(this, uid);
}
- void ProcessMessage(SASL::Session *sess, const SASL::Message &m) anope_override
+ void ProcessMessage(SASL::Session *sess, const SASL::Message &m) override
{
Session *mysess = anope_dynamic_static_cast<Session *>(sess);
@@ -131,13 +131,13 @@ class SASLService : public SASL::Service, public Timer
public:
SASLService(Module *o) : SASL::Service(o), Timer(o, 60, Anope::CurTime, true) { }
- ~SASLService()
+ ~SASLService() override
{
- for (std::map<Anope::string, Session *>::iterator it = sessions.begin(); it != sessions.end(); it++)
- delete it->second;
+ for (const auto &[_, session] : sessions)
+ delete session;
}
- void ProcessMessage(const SASL::Message &m) anope_override
+ void ProcessMessage(const SASL::Message &m) override
{
if (m.target != "*")
{
@@ -202,7 +202,7 @@ class SASLService : public SASL::Service, public Timer
session->mech->ProcessMessage(session, m);
}
- Anope::string GetAgent() anope_override
+ Anope::string GetAgent() override
{
Anope::string agent = Config->GetModule(Service::owner)->Get<Anope::string>("agent", "NickServ");
BotInfo *bi = Config->GetClient(agent);
@@ -211,7 +211,7 @@ class SASLService : public SASL::Service, public Timer
return agent;
}
- Session* GetSession(const Anope::string &uid) anope_override
+ Session* GetSession(const Anope::string &uid) override
{
std::map<Anope::string, Session *>::iterator it = sessions.find(uid);
if (it != sessions.end())
@@ -219,12 +219,12 @@ class SASLService : public SASL::Service, public Timer
return NULL;
}
- void RemoveSession(Session *sess) anope_override
+ void RemoveSession(Session *sess) override
{
sessions.erase(sess->uid);
}
- void DeleteSessions(Mechanism *mech, bool da) anope_override
+ void DeleteSessions(Mechanism *mech, bool da) override
{
for (std::map<Anope::string, Session *>::iterator it = sessions.begin(); it != sessions.end();)
{
@@ -238,7 +238,7 @@ class SASLService : public SASL::Service, public Timer
}
}
- void SendMessage(Session *session, const Anope::string &mtype, const Anope::string &data) anope_override
+ void SendMessage(Session *session, const Anope::string &mtype, const Anope::string &data) override
{
SASL::Message msg;
msg.source = this->GetAgent();
@@ -249,7 +249,7 @@ class SASLService : public SASL::Service, public Timer
IRCD->SendSASLMessage(msg);
}
- void Succeed(Session *session, NickCore *nc) anope_override
+ void Succeed(Session *session, NickCore *nc) override
{
// If the user is already introduced then we log them in now.
// Otherwise, we send an SVSLOGIN to log them in later.
@@ -261,27 +261,27 @@ class SASLService : public SASL::Service, public Timer
}
else
{
- IRCD->SendSVSLogin(session->uid, nc->display, na->GetVhostIdent(), na->GetVhostHost());
+ IRCD->SendSVSLogin(session->uid, na);
}
this->SendMessage(session, "D", "S");
}
- void Fail(Session *session) anope_override
+ void Fail(Session *session) override
{
this->SendMessage(session, "D", "F");
}
- void SendMechs(Session *session) anope_override
+ void SendMechs(Session *session) override
{
std::vector<Anope::string> mechs = Service::GetServiceKeys("SASL::Mechanism");
Anope::string buf;
- for (unsigned j = 0; j < mechs.size(); ++j)
- buf += "," + mechs[j];
+ for (const auto &mech : mechs)
+ buf += "," + mech;
this->SendMessage(session, "M", buf.empty() ? "" : buf.substr(1));
}
- void Tick(time_t) anope_override
+ void Tick(time_t) override
{
for (std::map<Anope::string, Session *>::iterator it = sessions.begin(); it != sessions.end();)
{
@@ -303,7 +303,7 @@ class ModuleSASL : public Module
SASLService sasl;
Plain plain;
- External *external;
+ External *external = nullptr;
std::vector<Anope::string> mechs;
@@ -322,7 +322,7 @@ class ModuleSASL : public Module
public:
ModuleSASL(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
- sasl(this), plain(this), external(NULL)
+ sasl(this), plain(this)
{
try
{
@@ -332,22 +332,22 @@ class ModuleSASL : public Module
catch (ModuleException &) { }
}
- ~ModuleSASL()
+ ~ModuleSASL() override
{
delete external;
}
- void OnModuleLoad(User *, Module *) anope_override
+ void OnModuleLoad(User *, Module *) override
{
CheckMechs();
}
- void OnModuleUnload(User *, Module *) anope_override
+ void OnModuleUnload(User *, Module *) override
{
CheckMechs();
}
- void OnPreUplinkSync(Server *) anope_override
+ void OnPreUplinkSync(Server *) override
{
// We have not yet sent a mechanism list so always do it here.
IRCD->SendSASLMechanisms(mechs);
diff --git a/modules/m_xmlrpc.cpp b/modules/m_xmlrpc.cpp
index 5717d7ec7..2ced4bca9 100644
--- a/modules/m_xmlrpc.cpp
+++ b/modules/m_xmlrpc.cpp
@@ -39,12 +39,12 @@ class MyXMLRPCServiceInterface : public XMLRPCServiceInterface, public HTTPPage
public:
MyXMLRPCServiceInterface(Module *creator, const Anope::string &sname) : XMLRPCServiceInterface(creator, sname), HTTPPage("/xmlrpc", "text/xml") { }
- void Register(XMLRPCEvent *event) anope_override
+ void Register(XMLRPCEvent *event) override
{
this->events.push_back(event);
}
- void Unregister(XMLRPCEvent *event) anope_override
+ void Unregister(XMLRPCEvent *event) override
{
std::deque<XMLRPCEvent *>::iterator it = std::find(this->events.begin(), this->events.end(), event);
@@ -52,7 +52,7 @@ class MyXMLRPCServiceInterface : public XMLRPCServiceInterface, public HTTPPage
this->events.erase(it);
}
- Anope::string Sanitize(const Anope::string &string) anope_override
+ Anope::string Sanitize(const Anope::string &string) override
{
Anope::string ret = string;
for (int i = 0; special[i].character.empty() == false; ++i)
@@ -145,7 +145,7 @@ class MyXMLRPCServiceInterface : public XMLRPCServiceInterface, public HTTPPage
}
public:
- bool OnRequest(HTTPProvider *provider, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply) anope_override
+ bool OnRequest(HTTPProvider *provider, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply) override
{
Anope::string content = message.content, tname, data;
XMLRPCRequest request(reply);
@@ -164,10 +164,8 @@ class MyXMLRPCServiceInterface : public XMLRPCServiceInterface, public HTTPPage
request.data.push_back(data);
}
- for (unsigned i = 0; i < this->events.size(); ++i)
+ for (auto *e : this->events)
{
- XMLRPCEvent *e = this->events[i];
-
if (!e->Run(this, client, request))
return false;
else if (!request.get_replies().empty())
@@ -182,14 +180,14 @@ class MyXMLRPCServiceInterface : public XMLRPCServiceInterface, public HTTPPage
return true;
}
- void Reply(XMLRPCRequest &request) anope_override
+ void Reply(XMLRPCRequest &request) override
{
if (!request.id.empty())
request.reply("id", request.id);
Anope::string r = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n<methodResponse>\n<params>\n<param>\n<value>\n<struct>\n";
- for (std::map<Anope::string, Anope::string>::const_iterator it = request.get_replies().begin(); it != request.get_replies().end(); ++it)
- r += "<member>\n<name>" + it->first + "</name>\n<value>\n<string>" + this->Sanitize(it->second) + "</string>\n</value>\n</member>\n";
+ for (const auto &[name, value] : request.get_replies())
+ r += "<member>\n<name>" + name + "</name>\n<value>\n<string>" + this->Sanitize(value) + "</string>\n</value>\n</member>\n";
r += "</struct>\n</value>\n</param>\n</params>\n</methodResponse>";
request.r.Write(r);
@@ -208,13 +206,13 @@ class ModuleXMLRPC : public Module
}
- ~ModuleXMLRPC()
+ ~ModuleXMLRPC() override
{
if (httpref)
httpref->UnregisterPage(&xmlrpcinterface);
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
if (httpref)
httpref->UnregisterPage(&xmlrpcinterface);
diff --git a/modules/m_xmlrpc_main.cpp b/modules/m_xmlrpc_main.cpp
index 39199f6a2..cdc12ed7f 100644
--- a/modules/m_xmlrpc_main.cpp
+++ b/modules/m_xmlrpc_main.cpp
@@ -22,7 +22,7 @@ class XMLRPCIdentifyRequest : public IdentifyRequest
public:
XMLRPCIdentifyRequest(Module *m, XMLRPCRequest& req, HTTPClient *c, XMLRPCServiceInterface* iface, const Anope::string &acc, const Anope::string &pass) : IdentifyRequest(m, acc, pass), request(req), repl(request.r), client(c), xinterface(iface) { }
- void OnSuccess() anope_override
+ void OnSuccess() override
{
if (!xinterface || !client)
return;
@@ -36,7 +36,7 @@ class XMLRPCIdentifyRequest : public IdentifyRequest
client->SendReply(&request.r);
}
- void OnFail() anope_override
+ void OnFail() override
{
if (!xinterface || !client)
return;
@@ -53,7 +53,7 @@ class XMLRPCIdentifyRequest : public IdentifyRequest
class MyXMLRPCEvent : public XMLRPCEvent
{
public:
- bool Run(XMLRPCServiceInterface *iface, HTTPClient *client, XMLRPCRequest &request) anope_override
+ bool Run(XMLRPCServiceInterface *iface, HTTPClient *client, XMLRPCRequest &request) override
{
if (request.name == "command")
this->DoCommand(iface, client, request);
@@ -101,7 +101,7 @@ class MyXMLRPCEvent : public XMLRPCEvent
XMLRPCommandReply(Anope::string &s) : str(s) { }
- void SendMessage(BotInfo *, const Anope::string &msg) anope_override
+ void SendMessage(BotInfo *, const Anope::string &msg) override
{
str += msg + "\n";
};
@@ -142,8 +142,8 @@ class MyXMLRPCEvent : public XMLRPCEvent
request.reply("uplinkname", Me->GetLinks().front()->GetName());
{
Anope::string buf;
- for (std::set<Anope::string>::iterator it = Servers::Capab.begin(); it != Servers::Capab.end(); ++it)
- buf += " " + *it;
+ for (const auto &capab : Servers::Capab)
+ buf += " " + capab;
if (!buf.empty())
buf.erase(buf.begin());
request.reply("uplinkcapab", buf);
@@ -166,21 +166,18 @@ class MyXMLRPCEvent : public XMLRPCEvent
{
request.reply("bancount", stringify(c->HasMode("BAN")));
int count = 0;
- std::vector<Anope::string> v = c->GetModeList("BAN");
- for (unsigned int i = 0; i < v.size(); ++i)
- request.reply("ban" + stringify(++count), iface->Sanitize(v[i]));
+ for (auto &ban : c->GetModeList("BAN"))
+ request.reply("ban" + stringify(++count), iface->Sanitize(ban));
request.reply("exceptcount", stringify(c->HasMode("EXCEPT")));
count = 0;
- v = c->GetModeList("EXCEPT");
- for (unsigned int i = 0; i < v.size(); ++i)
- request.reply("except" + stringify(++count), iface->Sanitize(v[i]));
+ for (auto &except : c->GetModeList("EXCEPT"))
+ request.reply("except" + stringify(++count), iface->Sanitize(except));
request.reply("invitecount", stringify(c->HasMode("INVITEOVERRIDE")));
count = 0;
- v = c->GetModeList("INVITEOVERRIDE");
- for (unsigned int i = 0; i < v.size(); ++i)
- request.reply("invite" + stringify(++count), iface->Sanitize(v[i]));
+ for (auto &invite : c->GetModeList("INVITEOVERRIDE"))
+ request.reply("invite" + stringify(++count), iface->Sanitize(invite));
Anope::string users;
for (Channel::ChanUserList::const_iterator it = c->users.begin(); it != c->users.end(); ++it)
@@ -249,18 +246,13 @@ class MyXMLRPCEvent : public XMLRPCEvent
void DoOperType(XMLRPCServiceInterface *iface, HTTPClient *client, XMLRPCRequest &request)
{
- for (unsigned i = 0; i < Config->MyOperTypes.size(); ++i)
+ for (auto *ot : Config->MyOperTypes)
{
- OperType *ot = Config->MyOperTypes[i];
Anope::string perms;
-
- std::list<Anope::string> privs = ot->GetPrivs();
- for (std::list<Anope::string>::const_iterator it2 = privs.begin(), it2_end = privs.end(); it2 != it2_end; ++it2)
- perms += " " + *it2;
-
- std::list<Anope::string> commands = ot->GetCommands();
- for (std::list<Anope::string>::const_iterator it2 = commands.begin(), it2_end = commands.end(); it2 != it2_end; ++it2)
- perms += " " + *it2;
+ for (const auto &priv : ot->GetPrivs())
+ perms += " " + priv;
+ for (const auto &command : ot->GetCommands())
+ perms += " " + command;
request.reply(ot->GetName(), perms);
}
}
@@ -300,7 +292,7 @@ class ModuleXMLRPCMain : public Module
xmlrpc->Register(&stats);
}
- ~ModuleXMLRPCMain()
+ ~ModuleXMLRPCMain() override
{
if (xmlrpc)
xmlrpc->Unregister(&stats);
diff --git a/modules/ns_maxemail.cpp b/modules/ns_maxemail.cpp
index 72955d562..28aebbf55 100644
--- a/modules/ns_maxemail.cpp
+++ b/modules/ns_maxemail.cpp
@@ -14,7 +14,7 @@
class NSMaxEmail : public Module
{
- bool clean;
+ bool clean = false;
/* strip dots from username, and remove anything after the first + */
Anope::string CleanMail(const Anope::string &email)
@@ -62,10 +62,8 @@ class NSMaxEmail : public Module
Anope::string cleanemail = clean ? CleanMail(email) : email;
- for (nickcore_map::const_iterator it = NickCoreList->begin(), it_end = NickCoreList->end(); it != it_end; ++it)
+ for (const auto &[_, nc] : *NickCoreList)
{
- const NickCore *nc = it->second;
-
Anope::string cleannc = clean ? CleanMail(nc->email) : nc->email;
if (unc != nc && cleanemail.equals_ci(cleannc))
@@ -77,16 +75,15 @@ class NSMaxEmail : public Module
public:
NSMaxEmail(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR)
- , clean(false)
{
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
clean = conf->GetModule(this)->Get<bool>("remove_aliases", "true");
}
- EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> &params) anope_override
+ EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> &params) override
{
if (source.IsOper())
return EVENT_CONTINUE;
diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp
index 6cc23ea91..608d3d869 100644
--- a/modules/protocol/bahamut.cpp
+++ b/modules/protocol/bahamut.cpp
@@ -16,7 +16,7 @@ class ChannelModeFlood : public ChannelModeParam
public:
ChannelModeFlood(char modeChar, bool minusNoArg) : ChannelModeParam("FLOOD", modeChar, minusNoArg) { }
- bool IsValid(Anope::string &value) const anope_override
+ bool IsValid(Anope::string &value) const override
{
try
{
@@ -45,7 +45,7 @@ class BahamutIRCdProto : public IRCDProto
MaxModes = 60;
}
- void SendModeInternal(const MessageSource &source, const Channel *dest, const Anope::string &buf) anope_override
+ void SendModeInternal(const MessageSource &source, const Channel *dest, const Anope::string &buf) override
{
if (Servers::Capab.count("TSMODE") > 0)
{
@@ -55,47 +55,47 @@ class BahamutIRCdProto : public IRCDProto
IRCDProto::SendModeInternal(source, dest, buf);
}
- void SendModeInternal(const MessageSource &source, User *u, const Anope::string &buf) anope_override
+ void SendModeInternal(const MessageSource &source, User *u, const Anope::string &buf) override
{
UplinkSocket::Message(source) << "SVSMODE " << u->nick << " " << u->timestamp << " " << buf;
}
- void SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override
+ void SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg) override
{
UplinkSocket::Message(bi) << "NOTICE $" << dest->GetName() << " :" << msg;
}
- void SendGlobalPrivmsg(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override
+ void SendGlobalPrivmsg(BotInfo *bi, const Server *dest, const Anope::string &msg) override
{
UplinkSocket::Message(bi) << "PRIVMSG $" << dest->GetName() << " :" << msg;
}
/* SVSHOLD - set */
- void SendSVSHold(const Anope::string &nick, time_t time) anope_override
+ void SendSVSHold(const Anope::string &nick, time_t time) override
{
UplinkSocket::Message(Me) << "SVSHOLD " << nick << " " << time << " :Being held for registered user";
}
/* SVSHOLD - release */
- void SendSVSHoldDel(const Anope::string &nick) anope_override
+ void SendSVSHoldDel(const Anope::string &nick) override
{
UplinkSocket::Message(Me) << "SVSHOLD " << nick << " 0";
}
/* SQLINE */
- void SendSQLine(User *, const XLine *x) anope_override
+ void SendSQLine(User *, const XLine *x) override
{
UplinkSocket::Message() << "SQLINE " << x->mask << " :" << x->GetReason();
}
/* UNSLINE */
- void SendSGLineDel(const XLine *x) anope_override
+ void SendSGLineDel(const XLine *x) override
{
UplinkSocket::Message() << "UNSGLINE 0 :" << x->mask;
}
/* UNSZLINE */
- void SendSZLineDel(const XLine *x) anope_override
+ void SendSZLineDel(const XLine *x) override
{
/* this will likely fail so its only here for legacy */
UplinkSocket::Message() << "UNSZLINE 0 " << x->GetHost();
@@ -104,7 +104,7 @@ class BahamutIRCdProto : public IRCDProto
}
/* SZLINE */
- void SendSZLine(User *, const XLine *x) anope_override
+ void SendSZLine(User *, const XLine *x) override
{
// Calculate the time left before this would expire, capping it at 2 days
time_t timeleft = x->expires - Anope::CurTime;
@@ -117,19 +117,19 @@ class BahamutIRCdProto : public IRCDProto
}
/* SVSNOOP */
- void SendSVSNOOP(const Server *server, bool set) anope_override
+ void SendSVSNOOP(const Server *server, bool set) override
{
UplinkSocket::Message() << "SVSNOOP " << server->GetName() << " " << (set ? "+" : "-");
}
/* SGLINE */
- void SendSGLine(User *, const XLine *x) anope_override
+ void SendSGLine(User *, const XLine *x) override
{
UplinkSocket::Message() << "SGLINE " << x->mask.length() << " :" << x->mask << ":" << x->GetReason();
}
/* RAKILL */
- void SendAkillDel(const XLine *x) anope_override
+ void SendAkillDel(const XLine *x) override
{
if (x->IsRegex() || x->HasNickOrReal())
return;
@@ -149,19 +149,19 @@ class BahamutIRCdProto : public IRCDProto
}
/* TOPIC */
- void SendTopic(const MessageSource &source, Channel *c) anope_override
+ void SendTopic(const MessageSource &source, Channel *c) override
{
UplinkSocket::Message(source) << "TOPIC " << c->name << " " << c->topic_setter << " " << c->topic_ts << " :" << c->topic;
}
/* UNSQLINE */
- void SendSQLineDel(const XLine *x) anope_override
+ void SendSQLineDel(const XLine *x) override
{
UplinkSocket::Message() << "UNSQLINE " << x->mask;
}
/* JOIN - SJOIN */
- void SendJoin(User *user, Channel *c, const ChannelStatus *status) anope_override
+ void SendJoin(User *user, Channel *c, const ChannelStatus *status) override
{
UplinkSocket::Message(user) << "SJOIN " << c->creation_time << " " << c->name;
if (status)
@@ -176,24 +176,24 @@ class BahamutIRCdProto : public IRCDProto
uc->status.Clear();
BotInfo *setter = BotInfo::Find(user->GetUID());
- for (size_t i = 0; i < cs.Modes().length(); ++i)
- c->SetMode(setter, ModeManager::FindChannelModeByChar(cs.Modes()[i]), user->GetUID(), false);
+ for (auto mode : cs.Modes())
+ c->SetMode(setter, ModeManager::FindChannelModeByChar(mode), user->GetUID(), false);
if (uc != NULL)
uc->status = cs;
}
}
- void SendAkill(User *u, XLine *x) anope_override
+ void SendAkill(User *u, XLine *x) override
{
if (x->IsRegex() || x->HasNickOrReal())
{
if (!u)
{
/* No user (this akill was just added), and contains nick and/or realname. Find users that match and ban them */
- for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
- if (x->manager->Check(it->second, x))
- this->SendAkill(it->second, x);
+ for (const auto &[_, user] : UserListByNick)
+ if (x->manager->Check(user, x))
+ this->SendAkill(user, x);
return;
}
@@ -230,34 +230,34 @@ class BahamutIRCdProto : public IRCDProto
/*
Note: if the stamp is null 0, the below usage is correct of Bahamut
*/
- void SendSVSKillInternal(const MessageSource &source, User *user, const Anope::string &buf) anope_override
+ void SendSVSKillInternal(const MessageSource &source, User *user, const Anope::string &buf) override
{
UplinkSocket::Message(source) << "SVSKILL " << user->nick << " :" << buf;
}
- void SendBOB() anope_override
+ void SendBOB() override
{
UplinkSocket::Message() << "BURST";
}
- void SendEOB() anope_override
+ void SendEOB() override
{
UplinkSocket::Message() << "BURST 0";
}
- void SendClientIntroduction(User *u) anope_override
+ void SendClientIntroduction(User *u) override
{
Anope::string modes = "+" + u->GetModes();
UplinkSocket::Message() << "NICK " << u->nick << " 1 " << u->timestamp << " " << modes << " " << u->GetIdent() << " " << u->host << " " << u->server->GetName() << " 0 0 :" << u->realname;
}
/* SERVER */
- void SendServer(const Server *server) anope_override
+ void SendServer(const Server *server) override
{
UplinkSocket::Message() << "SERVER " << server->GetName() << " " << server->GetHops() << " :" << server->GetDescription();
}
- void SendConnect() anope_override
+ void SendConnect() override
{
UplinkSocket::Message() << "PASS " << Config->Uplinks[Anope::CurrentUplink].password << " :TS";
UplinkSocket::Message() << "CAPAB SSJOIN NOQUIT BURST UNCONNECT NICKIP TSMODE TS3";
@@ -274,7 +274,7 @@ class BahamutIRCdProto : public IRCDProto
this->SendBOB();
}
- void SendChannel(Channel *c) anope_override
+ void SendChannel(Channel *c) override
{
Anope::string modes = c->GetModes(true, true);
if (modes.empty())
@@ -282,12 +282,12 @@ class BahamutIRCdProto : public IRCDProto
UplinkSocket::Message() << "SJOIN " << c->creation_time << " " << c->name << " " << modes << " :";
}
- void SendLogin(User *u, NickAlias *) anope_override
+ void SendLogin(User *u, NickAlias *) override
{
IRCD->SendMode(Config->GetClient("NickServ"), u, "+d %d", u->signon);
}
- void SendLogout(User *u) anope_override
+ void SendLogout(User *u) override
{
IRCD->SendMode(Config->GetClient("NickServ"), u, "+d 1");
}
@@ -297,7 +297,7 @@ struct IRCDMessageBurst : IRCDMessage
{
IRCDMessageBurst(Module *creator) : IRCDMessage(creator, "BURST", 0) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
/* If we found a server with the given source, that one just
* finished bursting. If there was no source, then our uplink
@@ -315,7 +315,7 @@ struct IRCDMessageMode : IRCDMessage
{
IRCDMessageMode(Module *creator, const Anope::string &sname) : IRCDMessage(creator, sname, 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
if (params.size() > 2 && IRCD->IsChannelValid(params[0]))
{
@@ -366,7 +366,7 @@ struct IRCDMessageNick : IRCDMessage
{
IRCDMessageNick(Module *creator) : IRCDMessage(creator, "NICK", 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
if (params.size() == 10)
{
@@ -399,7 +399,7 @@ struct IRCDMessageServer : IRCDMessage
{
IRCDMessageServer(Module *creator) : IRCDMessage(creator, "SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
unsigned int hops = Anope::string(params[1]).is_pos_number_only() ? convertTo<unsigned>(params[1]) : 0;
new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], hops, params[2]);
@@ -410,7 +410,7 @@ struct IRCDMessageSJoin : IRCDMessage
{
IRCDMessageSJoin(Module *creator) : IRCDMessage(creator, "SJOIN", 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
Anope::string modes;
if (params.size() >= 4)
@@ -466,7 +466,7 @@ struct IRCDMessageTopic : IRCDMessage
{
IRCDMessageTopic(Module *creator) : IRCDMessage(creator, "TOPIC", 4) { }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
Channel *c = Channel::Find(params[0]);
if (c)
@@ -560,7 +560,7 @@ class ProtoBahamut : public Module
}
- void OnUserNickChange(User *u, const Anope::string &) anope_override
+ void OnUserNickChange(User *u, const Anope::string &) override
{
u->RemoveModeInternal(Me, ModeManager::FindUserModeByName("REGISTERED"));
IRCD->SendLogout(u);
diff --git a/modules/protocol/hybrid.cpp b/modules/protocol/hybrid.cpp
index fc248338e..c554cc19d 100644
--- a/modules/protocol/hybrid.cpp
+++ b/modules/protocol/hybrid.cpp
@@ -17,7 +17,7 @@ static bool UseSVSAccount = false; // Temporary backwards compatibility hack un
class HybridProto : public IRCDProto
{
- void SendSVSKillInternal(const MessageSource &source, User *u, const Anope::string &buf) anope_override
+ void SendSVSKillInternal(const MessageSource &source, User *u, const Anope::string &buf) override
{
IRCDProto::SendSVSKillInternal(source, u, buf);
u->KillInternal(source, buf);
@@ -40,42 +40,42 @@ class HybridProto : public IRCDProto
MaxModes = 6;
}
- void SendInvite(const MessageSource &source, const Channel *c, User *u) anope_override
+ void SendInvite(const MessageSource &source, const Channel *c, User *u) override
{
UplinkSocket::Message(source) << "INVITE " << u->GetUID() << " " << c->name << " " << c->creation_time;
}
- void SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override
+ void SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg) override
{
UplinkSocket::Message(bi) << "NOTICE $$" << dest->GetName() << " :" << msg;
}
- void SendGlobalPrivmsg(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override
+ void SendGlobalPrivmsg(BotInfo *bi, const Server *dest, const Anope::string &msg) override
{
UplinkSocket::Message(bi) << "PRIVMSG $$" << dest->GetName() << " :" << msg;
}
- void SendSQLine(User *, const XLine *x) anope_override
+ void SendSQLine(User *, const XLine *x) override
{
UplinkSocket::Message(Me) << "RESV * " << (x->expires ? x->expires - Anope::CurTime : 0) << " " << x->mask << " :" << x->reason;
}
- void SendSGLineDel(const XLine *x) anope_override
+ void SendSGLineDel(const XLine *x) override
{
UplinkSocket::Message(Me) << "UNXLINE * " << x->mask;
}
- void SendSGLine(User *, const XLine *x) anope_override
+ void SendSGLine(User *, const XLine *x) override
{
UplinkSocket::Message(Me) << "XLINE * " << x->mask << " " << (x->expires ? x->expires - Anope::CurTime : 0) << " :" << x->GetReason();
}
- void SendSZLineDel(const XLine *x) anope_override
+ void SendSZLineDel(const XLine *x) override
{
UplinkSocket::Message(Me) << "UNDLINE * " << x->GetHost();
}
- void SendSZLine(User *, const XLine *x) anope_override
+ void SendSZLine(User *, const XLine *x) override
{
/* Calculate the time left before this would expire, capping it at 2 days */
time_t timeleft = x->expires - Anope::CurTime;
@@ -86,7 +86,7 @@ class HybridProto : public IRCDProto
UplinkSocket::Message(Me) << "DLINE * " << timeleft << " " << x->GetHost() << " :" << x->GetReason();
}
- void SendAkillDel(const XLine *x) anope_override
+ void SendAkillDel(const XLine *x) override
{
if (x->IsRegex() || x->HasNickOrReal())
return;
@@ -94,12 +94,12 @@ class HybridProto : public IRCDProto
UplinkSocket::Message(Me) << "UNKLINE * " << x->GetUser() << " " << x->GetHost();
}
- void SendSQLineDel(const XLine *x) anope_override
+ void SendSQLineDel(const XLine *x) override
{
UplinkSocket::Message(Me) << "UNRESV * " << x->mask;
}
- void SendJoin(User *u, Channel *c, const ChannelStatus *status) anope_override
+ void SendJoin(User *u, Channel *c, const ChannelStatus *status) override
{
UplinkSocket::Message(Me) << "SJOIN " << c->creation_time << " " << c->name << " +" << c->GetModes(true, true) << " :" << u->GetUID();
@@ -122,15 +122,15 @@ class HybridProto : public IRCDProto
uc->status.Clear();
BotInfo *setter = BotInfo::Find(u->GetUID());
- for (size_t i = 0; i < cs.Modes().length(); ++i)
- c->SetMode(setter, ModeManager::FindChannelModeByChar(cs.Modes()[i]), u->GetUID(), false);
+ for (auto mode : cs.Modes())
+ c->SetMode(setter, ModeManager::FindChannelModeByChar(mode), u->GetUID(), false);
if (uc)
uc->status = cs;
}
}
- void SendAkill(User *u, XLine *x) anope_override
+ void SendAkill(User *u, XLine *x) override
{
if (x->IsRegex() || x->HasNickOrReal())
{
@@ -140,9 +140,9 @@ class HybridProto : public IRCDProto
* No user (this akill was just added), and contains nick and/or realname.
* Find users that match and ban them.
*/
- for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
- if (x->manager->Check(it->second, x))
- this->SendAkill(it->second, x);
+ for (const auto &[_, user] : UserListByNick)
+ if (x->manager->Check(user, x))
+ this->SendAkill(user, x);
return;
}
@@ -171,7 +171,7 @@ class HybridProto : public IRCDProto
UplinkSocket::Message(Me) << "KLINE * " << timeleft << " " << x->GetUser() << " " << x->GetHost() << " :" << x->GetReason();
}
- void SendServer(const Server *server) anope_override
+ void SendServer(const Server *server) override
{
if (server == Me)
UplinkSocket::Message() << "SERVER " << server->GetName() << " " << server->GetHops() + 1 << " " << server->GetSID() << " +" << " :" << server->GetDescription();
@@ -179,7 +179,7 @@ class HybridProto : public IRCDProto
UplinkSocket::Message(Me) << "SID " << server->GetName() << " " << server->GetHops() + 1 << " " << server->GetSID() << " +" << " :" << server->GetDescription();
}
- void SendConnect() anope_override
+ void SendConnect() override
{
UplinkSocket::Message() << "PASS " << Config->Uplinks[Anope::CurrentUplink].password;
@@ -197,7 +197,7 @@ class HybridProto : public IRCDProto
UplinkSocket::Message(Me) << "SVINFO 6 6 0 :" << Anope::CurTime;
}
- void SendClientIntroduction(User *u) anope_override
+ void SendClientIntroduction(User *u) override
{
Anope::string modes = "+" + u->GetModes();
@@ -205,17 +205,17 @@ class HybridProto : public IRCDProto
<< u->host << " " << u->host << " 0.0.0.0 " << u->GetUID() << " * :" << u->realname;
}
- void SendEOB() anope_override
+ void SendEOB() override
{
UplinkSocket::Message(Me) << "EOB";
}
- void SendModeInternal(const MessageSource &source, User *u, const Anope::string &buf) anope_override
+ void SendModeInternal(const MessageSource &source, User *u, const Anope::string &buf) override
{
UplinkSocket::Message(source) << "SVSMODE " << u->GetUID() << " " << u->timestamp << " " << buf;
}
- void SendLogin(User *u, NickAlias *na) anope_override
+ void SendLogin(User *u, NickAlias *na) override
{
if (UseSVSAccount == false)
IRCD->SendMode(Config->GetClient("NickServ"), u, "+d %s", na->nc->display.c_str());
@@ -223,7 +223,7 @@ class HybridProto : public IRCDProto
UplinkSocket::Message(Me) << "SVSACCOUNT " << u->GetUID() << " " << u->timestamp << " " << na->nc->display;
}
- void SendLogout(User *u) anope_override
+ void SendLogout(User *u) override
{
if (UseSVSAccount == false)
IRCD->SendMode(Config->GetClient("NickServ"), u, "+d *");
@@ -231,28 +231,28 @@ class HybridProto : public IRCDProto
UplinkSocket::Message(Me) << "SVSACCOUNT " << u->GetUID() << " " << u->timestamp << " *";
}
- void SendChannel(Channel *c) anope_override
+ void SendChannel(Channel *c) override
{
Anope::string modes = "+" + c->GetModes(true, true);
UplinkSocket::Message(Me) << "SJOIN " << c->creation_time << " " << c->name << " " << modes << " :";
}
- void SendTopic(const MessageSource &source, Channel *c) anope_override
+ void SendTopic(const MessageSource &source, Channel *c) override
{
UplinkSocket::Message(source) << "TBURST " << c->creation_time << " " << c->name << " " << c->topic_ts << " " << c->topic_setter << " :" << c->topic;
}
- void SendForceNickChange(User *u, const Anope::string &newnick, time_t when) anope_override
+ void SendForceNickChange(User *u, const Anope::string &newnick, time_t when) override
{
UplinkSocket::Message(Me) << "SVSNICK " << u->GetUID() << " " << u->timestamp << " " << newnick << " " << when;
}
- void SendSVSJoin(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string &) anope_override
+ void SendSVSJoin(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string &) override
{
UplinkSocket::Message(source) << "SVSJOIN " << u->GetUID() << " " << chan;
}
- void SendSVSPart(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string &param) anope_override
+ void SendSVSPart(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string &param) override
{
if (!param.empty())
UplinkSocket::Message(source) << "SVSPART " << u->GetUID() << " " << chan << " :" << param;
@@ -260,34 +260,34 @@ class HybridProto : public IRCDProto
UplinkSocket::Message(source) << "SVSPART " << u->GetUID() << " " << chan;
}
- void SendSVSHold(const Anope::string &nick, time_t t) anope_override
+ void SendSVSHold(const Anope::string &nick, time_t t) override
{
XLine x(nick, Me->GetName(), Anope::CurTime + t, "Being held for registered user");
this->SendSQLine(NULL, &x);
}
- void SendSVSHoldDel(const Anope::string &nick) anope_override
+ void SendSVSHoldDel(const Anope::string &nick) override
{
XLine x(nick);
this->SendSQLineDel(&x);
}
- void SendVhost(User *u, const Anope::string &ident, const Anope::string &host) anope_override
+ void SendVhost(User *u, const Anope::string &ident, const Anope::string &host) override
{
UplinkSocket::Message(Me) << "SVSHOST " << u->GetUID() << " " << u->timestamp << " " << host;
}
- void SendVhostDel(User *u) anope_override
+ void SendVhostDel(User *u) override
{
UplinkSocket::Message(Me) << "SVSHOST " << u->GetUID() << " " << u->timestamp << " " << u->host;
}
- bool IsExtbanValid(const Anope::string &mask) anope_override
+ bool IsExtbanValid(const Anope::string &mask) override
{
return mask.length() >= 4 && mask[0] == '$' && mask[2] == ':';
}
- bool IsIdentValid(const Anope::string &ident) anope_override
+ bool IsIdentValid(const Anope::string &ident) override
{
if (ident.empty() || ident.length() > Config->GetBlock("networkinfo")->Get<unsigned>("userlen"))
return false;
@@ -305,10 +305,8 @@ class HybridProto : public IRCDProto
if (a == '-' || a == '_' || a == '.')
return false;
- for (i = 0; i < ident.length(); ++i)
+ for (const auto c : ident)
{
- const char &c = ident[i];
-
/* A tilde can only be used as the first character of a user name. */
if (c == '~' && i == 0)
continue;
@@ -331,7 +329,7 @@ struct IRCDMessageBMask : IRCDMessage
/* 0 1 2 3 */
/* :0MC BMASK 1350157102 #channel b :*!*@*.test.com */
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
Channel *c = Channel::Find(params[1]);
ChannelMode *mode = ModeManager::FindChannelModeByChar(params[2][0]);
@@ -353,7 +351,7 @@ struct IRCDMessageCapab : Message::Capab
/* 0 */
/* CAPAB :TBURST EOB MLOCK */
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
spacesepstream sep(params[0]);
Anope::string capab;
@@ -368,7 +366,7 @@ struct IRCDMessageCapab : Message::Capab
ModeManager::AddChannelMode(new ChannelModeStatus("OWNER", 'q', '~', 4));
}
- Message::Capab::Run(source, params);
+ Message::Capab::Run(source, params, tags);
}
};
@@ -378,7 +376,7 @@ struct IRCDMessageCertFP: IRCDMessage
/* 0 */
/* :0MCAAAAAB CERTFP 4C62287BA6776A89CD4F8FF10A62FFB35E79319F51AF6C62C674984974FCCB1D */
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
User *u = source.GetUser();
@@ -391,7 +389,7 @@ struct IRCDMessageEOB : IRCDMessage
{
IRCDMessageEOB(Module *creator) : IRCDMessage(creator, "EOB", 0) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
source.GetServer()->Sync(true);
}
@@ -401,7 +399,7 @@ struct IRCDMessageJoin : Message::Join
{
IRCDMessageJoin(Module *creator) : Message::Join(creator, "JOIN") { }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
if (params.size() < 2)
return;
@@ -409,7 +407,7 @@ struct IRCDMessageJoin : Message::Join
std::vector<Anope::string> p = params;
p.erase(p.begin());
- Message::Join::Run(source, p);
+ Message::Join::Run(source, p, tags);
}
};
@@ -419,7 +417,7 @@ struct IRCDMessageMetadata : IRCDMessage
/* 0 1 2 3 */
/* :0MC METADATA client 0MCAAAAAB certfp :4C62287BA6776A89CD4F8FF10A62FFB35E79319F51AF6C62C674984974FCCB1D */
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
if (params[0].equals_cs("client"))
{
@@ -445,7 +443,7 @@ struct IRCDMessageMLock : IRCDMessage
/* 0 1 2 3 */
/* :0MC MLOCK 1350157102 #channel 1350158923 :nt */
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
Channel *c = Channel::Find(params[1]);
@@ -470,7 +468,7 @@ struct IRCDMessageNick : IRCDMessage
/* 0 1 */
/* :0MCAAAAAB NICK newnick 1350157102 */
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
source.GetUser()->ChangeNick(params[0], convertTo<time_t>(params[1]));
}
@@ -482,7 +480,7 @@ struct IRCDMessagePass : IRCDMessage
/* 0 */
/* PASS password */
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
if (params.size() == 4)
UplinkSID = params[3];
@@ -493,7 +491,7 @@ struct IRCDMessagePong : IRCDMessage
{
IRCDMessagePong(Module *creator) : IRCDMessage(creator, "PONG", 0) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
source.GetServer()->Sync(false);
}
@@ -505,7 +503,7 @@ struct IRCDMessageServer : IRCDMessage
/* 0 1 2 3 4 */
/* SERVER hades.arpa 1 4XY + :ircd-hybrid test server */
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
/* Servers other than our immediate uplink are introduced via SID */
if (params[1] != "1")
@@ -529,7 +527,7 @@ struct IRCDMessageSID : IRCDMessage
/* 0 1 2 3 4 */
/* :0MC SID hades.arpa 2 4XY + :ircd-hybrid test server */
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
unsigned int hops = params[1].is_pos_number_only() ? convertTo<unsigned>(params[1]) : 0;
new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], hops, params.back(), params[2]);
@@ -544,7 +542,7 @@ struct IRCDMessageSJoin : IRCDMessage
/* 0 1 2 3 */
/* :0MC SJOIN 1654877335 #nether +nt :@0MCAAAAAB +0MCAAAAAC */
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
Anope::string modes;
@@ -591,7 +589,7 @@ struct IRCDMessageSVSMode : IRCDMessage
/* 0 1 2 */
/* :0MC SVSMODE 0MCAAAAAB 1350157102 +r */
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
User *u = User::Find(params[0]);
@@ -611,7 +609,7 @@ struct IRCDMessageTBurst : IRCDMessage
/* 0 1 2 3 4 */
/* :0MC TBURST 1654867975 #nether 1654877335 Steve!~steve@the.mines :Join the ghast nation */
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
Anope::string setter;
sepstream(params[3], '!').GetToken(setter, 0);
@@ -629,7 +627,7 @@ struct IRCDMessageTMode : IRCDMessage
/* 0 1 2 */
/* :0MC TMODE 1654867975 #nether +ntR */
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
time_t ts = 0;
@@ -656,7 +654,7 @@ struct IRCDMessageUID : IRCDMessage
/* 0 1 2 3 4 5 6 7 8 9 10 */
/* :0MC UID Steve 1 1350157102 +oi ~steve virtual.host real.host 10.0.0.1 0MCAAAAAB Steve :Mining all the time */
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
NickAlias *na = NULL;
@@ -816,17 +814,17 @@ class ProtoHybrid : public Module
this->AddModes();
}
- void OnUserNickChange(User *u, const Anope::string &) anope_override
+ void OnUserNickChange(User *u, const Anope::string &) override
{
u->RemoveModeInternal(Me, ModeManager::FindUserModeByName("REGISTERED"));
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
use_server_side_mlock = conf->GetModule(this)->Get<bool>("use_server_side_mlock");
}
- void OnChannelSync(Channel *c) anope_override
+ void OnChannelSync(Channel *c) override
{
if (!c->ci)
return;
@@ -839,13 +837,13 @@ class ProtoHybrid : public Module
}
}
- void OnDelChan(ChannelInfo *ci) anope_override
+ void OnDelChan(ChannelInfo *ci) override
{
if (use_server_side_mlock && ci->c && Servers::Capab.count("MLOCK"))
UplinkSocket::Message(Me) << "MLOCK " << ci->c->creation_time << " " << ci->name << " " << Anope::CurTime << " :";
}
- EventReturn OnMLock(ChannelInfo *ci, ModeLock *lock) anope_override
+ EventReturn OnMLock(ChannelInfo *ci, ModeLock *lock) override
{
ModeLocks *modelocks = ci->GetExt<ModeLocks>("modelocks");
ChannelMode *cm = ModeManager::FindChannelModeByName(lock->name);
@@ -858,7 +856,7 @@ class ProtoHybrid : public Module
return EVENT_CONTINUE;
}
- EventReturn OnUnMLock(ChannelInfo *ci, ModeLock *lock) anope_override
+ EventReturn OnUnMLock(ChannelInfo *ci, ModeLock *lock) override
{
ModeLocks *modelocks = ci->GetExt<ModeLocks>("modelocks");
ChannelMode *cm = ModeManager::FindChannelModeByName(lock->name);
diff --git a/modules/protocol/inspircd3.cpp b/modules/protocol/inspircd.cpp
index ad29b56d9..e91e54b57 100644
--- a/modules/protocol/inspircd3.cpp
+++ b/modules/protocol/inspircd.cpp
@@ -1,4 +1,4 @@
-/* InspIRCd 3.0 functions
+/* InspIRCd functions
*
* (C) 2003-2023 Anope Team
* Contact us at team@anope.org
@@ -26,7 +26,7 @@ static std::list<SASLUser> saslusers;
static Anope::string rsquit_server, rsquit_id;
-class InspIRCd3Proto : public IRCDProto
+class InspIRCdProto : public IRCDProto
{
private:
void SendChgIdentInternal(const Anope::string &nick, const Anope::string &vIdent)
@@ -58,7 +58,7 @@ class InspIRCd3Proto : public IRCDProto
public:
PrimitiveExtensibleItem<ListLimits> maxlist;
- InspIRCd3Proto(Module *creator) : IRCDProto(creator, "InspIRCd 3"), maxlist(creator, "maxlist")
+ InspIRCdProto(Module *creator) : IRCDProto(creator, "InspIRCd 3+"), maxlist(creator, "maxlist")
{
DefaultPseudoclientModes = "+oI";
CanSVSNick = true;
@@ -70,12 +70,13 @@ class InspIRCd3Proto : public IRCDProto
CanSZLine = true;
CanSVSHold = true;
CanCertFP = true;
+ CanSendTags = true;
RequiresID = true;
MaxModes = 20;
MaxLine = 4096;
}
- unsigned GetMaxListFor(Channel *c, ChannelMode *cm) anope_override
+ unsigned GetMaxListFor(Channel *c, ChannelMode *cm) override
{
ListLimits *limits = maxlist.Get(c);
if (limits)
@@ -89,7 +90,7 @@ class InspIRCd3Proto : public IRCDProto
return IRCDProto::GetMaxListFor(c, cm);
}
- void SendConnect() anope_override
+ void SendConnect() override
{
UplinkSocket::Message() << "CAPAB START 1205";
UplinkSocket::Message() << "CAPAB CAPABILITIES :CASEMAPPING=" << Config->GetBlock("options")->Get<const Anope::string>("casemap", "ascii");
@@ -97,32 +98,32 @@ class InspIRCd3Proto : public IRCDProto
UplinkSocket::Message() << "SERVER " << Me->GetName() << " " << Config->Uplinks[Anope::CurrentUplink].password << " 0 " << Me->GetSID() << " :" << Me->GetDescription();
}
- void SendSASLMechanisms(std::vector<Anope::string> &mechanisms) anope_override
+ void SendSASLMechanisms(std::vector<Anope::string> &mechanisms) override
{
Anope::string mechlist;
- for (unsigned i = 0; i < mechanisms.size(); ++i)
- mechlist += "," + mechanisms[i];
+ for (const auto &mechanism : mechanisms)
+ mechlist += "," + mechanism;
UplinkSocket::Message(Me) << "METADATA * saslmechlist :" << (mechanisms.empty() ? "" : mechlist.substr(1));
}
- void SendSVSKillInternal(const MessageSource &source, User *user, const Anope::string &buf) anope_override
+ void SendSVSKillInternal(const MessageSource &source, User *user, const Anope::string &buf) override
{
IRCDProto::SendSVSKillInternal(source, user, buf);
user->KillInternal(source, buf);
}
- void SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override
+ void SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg) override
{
UplinkSocket::Message(bi) << "NOTICE $" << dest->GetName() << " :" << msg;
}
- void SendGlobalPrivmsg(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override
+ void SendGlobalPrivmsg(BotInfo *bi, const Server *dest, const Anope::string &msg) override
{
UplinkSocket::Message(bi) << "PRIVMSG $" << dest->GetName() << " :" << msg;
}
- void SendPong(const Anope::string &servname, const Anope::string &who) anope_override
+ void SendPong(const Anope::string &servname, const Anope::string &who) override
{
Server *serv = servname.empty() ? NULL : Server::Find(servname);
if (!serv)
@@ -131,7 +132,7 @@ class InspIRCd3Proto : public IRCDProto
UplinkSocket::Message(serv) << "PONG " << who;
}
- void SendAkillDel(const XLine *x) anope_override
+ void SendAkillDel(const XLine *x) override
{
{
/* InspIRCd may support regex bans
@@ -170,12 +171,12 @@ class InspIRCd3Proto : public IRCDProto
}
}
- void SendInvite(const MessageSource &source, const Channel *c, User *u) anope_override
+ void SendInvite(const MessageSource &source, const Channel *c, User *u) override
{
UplinkSocket::Message(source) << "INVITE " << u->GetUID() << " " << c->name << " " << c->creation_time;
}
- void SendTopic(const MessageSource &source, Channel *c) anope_override
+ void SendTopic(const MessageSource &source, Channel *c) override
{
if (Servers::Capab.count("SVSTOPIC"))
{
@@ -192,7 +193,7 @@ class InspIRCd3Proto : public IRCDProto
}
}
- void SendVhostDel(User *u) anope_override
+ void SendVhostDel(User *u) override
{
UserMode *um = ModeManager::FindUserModeByName("CLOAK");
@@ -204,7 +205,7 @@ class InspIRCd3Proto : public IRCDProto
this->SendChgHostInternal(u->nick, u->chost);
}
- void SendAkill(User *u, XLine *x) anope_override
+ void SendAkill(User *u, XLine *x) override
{
// Calculate the time left before this would expire, capping it at 2 days
time_t timeleft = x->expires - Anope::CurTime;
@@ -234,9 +235,9 @@ class InspIRCd3Proto : public IRCDProto
if (!u)
{
/* No user (this akill was just added), and contains nick and/or realname. Find users that match and ban them */
- for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
- if (x->manager->Check(it->second, x))
- this->SendAkill(it->second, x);
+ for (const auto &[_, user] : UserListByNick)
+ if (x->manager->Check(user, x))
+ this->SendAkill(user, x);
return;
}
@@ -266,17 +267,17 @@ class InspIRCd3Proto : public IRCDProto
SendAddLine("G", x->GetUser() + "@" + x->GetHost(), timeleft, x->by, x->GetReason());
}
- void SendNumericInternal(int numeric, const Anope::string &dest, const Anope::string &buf) anope_override
+ void SendNumericInternal(int numeric, const Anope::string &dest, const Anope::string &buf) override
{
UplinkSocket::Message() << "NUM " << Me->GetSID() << " " << dest << " " << numeric << " " << buf;
}
- void SendModeInternal(const MessageSource &source, const Channel *dest, const Anope::string &buf) anope_override
+ void SendModeInternal(const MessageSource &source, const Channel *dest, const Anope::string &buf) override
{
UplinkSocket::Message(source) << "FMODE " << dest->name << " " << dest->creation_time << " " << buf;
}
- void SendClientIntroduction(User *u) anope_override
+ void SendClientIntroduction(User *u) override
{
Anope::string modes = "+" + u->GetModes();
UplinkSocket::Message(Me) << "UID " << u->GetUID() << " " << u->timestamp << " " << u->nick << " " << u->host << " " << u->host << " " << u->GetIdent() << " 0.0.0.0 " << u->timestamp << " " << modes << " :" << u->realname;
@@ -292,14 +293,14 @@ class InspIRCd3Proto : public IRCDProto
}
}
- void SendServer(const Server *server) anope_override
+ void SendServer(const Server *server) override
{
/* if rsquit is set then we are waiting on a squit */
if (rsquit_id.empty() && rsquit_server.empty())
UplinkSocket::Message() << "SERVER " << server->GetName() << " " << server->GetSID() << " :" << server->GetDescription();
}
- void SendSquit(Server *s, const Anope::string &message) anope_override
+ void SendSquit(Server *s, const Anope::string &message) override
{
if (s != Me)
{
@@ -311,7 +312,7 @@ class InspIRCd3Proto : public IRCDProto
UplinkSocket::Message() << "SQUIT " << s->GetName() << " :" << message;
}
- void SendJoin(User *user, Channel *c, const ChannelStatus *status) anope_override
+ void SendJoin(User *user, Channel *c, const ChannelStatus *status) override
{
UplinkSocket::Message(Me) << "FJOIN " << c->name << " " << c->creation_time << " +" << c->GetModes(true, true) << " :," << user->GetUID();
/* Note that we can send this with the FJOIN but choose not to
@@ -330,15 +331,15 @@ class InspIRCd3Proto : public IRCDProto
uc->status.Clear();
BotInfo *setter = BotInfo::Find(user->GetUID());
- for (size_t i = 0; i < cs.Modes().length(); ++i)
- c->SetMode(setter, ModeManager::FindChannelModeByChar(cs.Modes()[i]), user->GetUID(), false);
+ for (auto mode : cs.Modes())
+ c->SetMode(setter, ModeManager::FindChannelModeByChar(mode), user->GetUID(), false);
if (uc != NULL)
uc->status = cs;
}
}
- void SendSQLineDel(const XLine *x) anope_override
+ void SendSQLineDel(const XLine *x) override
{
if (IRCD->CanSQLineChannel && (x->mask[0] == '#'))
SendDelLine("CBAN", x->mask);
@@ -346,7 +347,7 @@ class InspIRCd3Proto : public IRCDProto
SendDelLine("Q", x->mask);
}
- void SendSQLine(User *u, const XLine *x) anope_override
+ void SendSQLine(User *u, const XLine *x) override
{
// Calculate the time left before this would expire, capping it at 2 days
time_t timeleft = x->expires - Anope::CurTime;
@@ -359,7 +360,7 @@ class InspIRCd3Proto : public IRCDProto
SendAddLine("Q", x->mask, timeleft, x->by, x->GetReason());
}
- void SendVhost(User *u, const Anope::string &vIdent, const Anope::string &vhost) anope_override
+ void SendVhost(User *u, const Anope::string &vIdent, const Anope::string &vhost) override
{
if (!vIdent.empty())
this->SendChgIdentInternal(u->nick, vIdent);
@@ -367,22 +368,22 @@ class InspIRCd3Proto : public IRCDProto
this->SendChgHostInternal(u->nick, vhost);
}
- void SendSVSHold(const Anope::string &nick, time_t t) anope_override
+ void SendSVSHold(const Anope::string &nick, time_t t) override
{
UplinkSocket::Message(Config->GetClient("NickServ")) << "SVSHOLD " << nick << " " << t << " :Being held for registered user";
}
- void SendSVSHoldDel(const Anope::string &nick) anope_override
+ void SendSVSHoldDel(const Anope::string &nick) override
{
UplinkSocket::Message(Config->GetClient("NickServ")) << "SVSHOLD " << nick;
}
- void SendSZLineDel(const XLine *x) anope_override
+ void SendSZLineDel(const XLine *x) override
{
SendDelLine("Z", x->GetHost());
}
- void SendSZLine(User *u, const XLine *x) anope_override
+ void SendSZLine(User *u, const XLine *x) override
{
// Calculate the time left before this would expire, capping it at 2 days
time_t timeleft = x->expires - Anope::CurTime;
@@ -391,12 +392,12 @@ class InspIRCd3Proto : public IRCDProto
SendAddLine("Z", x->GetHost(), timeleft, x->by, x->GetReason());
}
- void SendSVSJoin(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string &other) anope_override
+ void SendSVSJoin(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string &other) override
{
UplinkSocket::Message(source) << "SVSJOIN " << u->GetUID() << " " << chan;
}
- void SendSVSPart(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string &param) anope_override
+ void SendSVSPart(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string &param) override
{
if (!param.empty())
UplinkSocket::Message(source) << "SVSPART " << u->GetUID() << " " << chan << " :" << param;
@@ -404,14 +405,14 @@ class InspIRCd3Proto : public IRCDProto
UplinkSocket::Message(source) << "SVSPART " << u->GetUID() << " " << chan;
}
- void SendSWhois(const MessageSource &bi, const Anope::string &who, const Anope::string &mask) anope_override
+ void SendSWhois(const MessageSource &bi, const Anope::string &who, const Anope::string &mask) override
{
User *u = User::Find(who);
UplinkSocket::Message(Me) << "METADATA " << u->GetUID() << " swhois :" << mask;
}
- void SendBOB() anope_override
+ void SendBOB() override
{
UplinkSocket::Message(Me) << "BURST " << Anope::CurTime;
Module *enc = ModuleManager::FindFirstOf(ENCRYPTION);
@@ -420,12 +421,12 @@ class InspIRCd3Proto : public IRCDProto
UplinkSocket::Message(Me) << "SINFO rawversion :Anope-" << Anope::VersionShort();
}
- void SendEOB() anope_override
+ void SendEOB() override
{
UplinkSocket::Message(Me) << "ENDBURST";
}
- void SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) anope_override
+ void SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) override
{
if (Servers::Capab.count("GLOBOPS"))
UplinkSocket::Message(source) << "SNONOTICE g :" << buf;
@@ -433,7 +434,7 @@ class InspIRCd3Proto : public IRCDProto
UplinkSocket::Message(source) << "SNONOTICE A :" << buf;
}
- void SendLogin(User *u, NickAlias *na) anope_override
+ void SendLogin(User *u, NickAlias *na) override
{
/* InspIRCd uses an account to bypass chmode +R, not umode +r, so we can't send this here */
if (na->nc->HasExt("UNCONFIRMED"))
@@ -443,40 +444,35 @@ class InspIRCd3Proto : public IRCDProto
UplinkSocket::Message(Me) << "METADATA " << u->GetUID() << " accountname :" << na->nc->display;
}
- void SendLogout(User *u) anope_override
+ void SendLogout(User *u) override
{
UplinkSocket::Message(Me) << "METADATA " << u->GetUID() << " accountid :";
UplinkSocket::Message(Me) << "METADATA " << u->GetUID() << " accountname :";
}
- void SendChannel(Channel *c) anope_override
+ void SendChannel(Channel *c) override
{
UplinkSocket::Message(Me) << "FJOIN " << c->name << " " << c->creation_time << " +" << c->GetModes(true, true) << " :";
}
- void SendSASLMessage(const SASL::Message &message) anope_override
+ void SendSASLMessage(const SASL::Message &message) override
{
UplinkSocket::Message(Me) << "ENCAP " << message.target.substr(0, 3) << " SASL " << message.source << " " << message.target << " " << message.type << " " << message.data << (message.ext.empty() ? "" : (" " + message.ext));
}
- void SendSVSLogin(const Anope::string &uid, const Anope::string &acc, const Anope::string &vident, const Anope::string &vhost) anope_override
+ void SendSVSLogin(const Anope::string &uid, NickAlias *na) override
{
- // TODO: in 2.1 this function should take a NickAlias instead of strings.
- NickCore *nc = NickCore::Find(acc);
- if (!nc)
- return;
-
- UplinkSocket::Message(Me) << "METADATA " << uid << " accountid :" << nc->GetId();
- UplinkSocket::Message(Me) << "METADATA " << uid << " accountname :" << acc;
+ UplinkSocket::Message(Me) << "METADATA " << uid << " accountid :" << na->nc->GetId();
+ UplinkSocket::Message(Me) << "METADATA " << uid << " accountname :" << na->nc->display;
- if (!vident.empty())
- UplinkSocket::Message(Me) << "ENCAP " << uid.substr(0, 3) << " CHGIDENT " << uid << " " << vident;
- if (!vhost.empty())
- UplinkSocket::Message(Me) << "ENCAP " << uid.substr(0, 3) << " CHGHOST " << uid << " " << vhost;
+ if (!na->GetVhostIdent().empty())
+ UplinkSocket::Message(Me) << "ENCAP " << uid.substr(0, 3) << " CHGIDENT " << uid << " " << na->GetVhostIdent();
+ if (!na->GetVhostHost().empty())
+ UplinkSocket::Message(Me) << "ENCAP " << uid.substr(0, 3) << " CHGHOST " << uid << " " << na->GetVhostHost();
SASLUser su;
su.uid = uid;
- su.acc = acc;
+ su.acc = na->nc->display;
su.created = Anope::CurTime;
for (std::list<SASLUser>::iterator it = saslusers.begin(); it != saslusers.end();)
@@ -492,20 +488,18 @@ class InspIRCd3Proto : public IRCDProto
saslusers.push_back(su);
}
- bool IsExtbanValid(const Anope::string &mask) anope_override
+ bool IsExtbanValid(const Anope::string &mask) override
{
return mask.length() >= 3 && mask[1] == ':';
}
- bool IsIdentValid(const Anope::string &ident) anope_override
+ bool IsIdentValid(const Anope::string &ident) override
{
if (ident.empty() || ident.length() > Config->GetBlock("networkinfo")->Get<unsigned>("userlen"))
return false;
- for (unsigned i = 0; i < ident.length(); ++i)
+ for (auto c : ident)
{
- const char &c = ident[i];
-
if (c >= 'A' && c <= '}')
continue;
@@ -526,7 +520,7 @@ class InspIRCdAutoOpMode : public ChannelModeList
{
}
- bool IsValid(Anope::string &mask) const anope_override
+ bool IsValid(Anope::string &mask) const override
{
// We can not validate this because we don't know about the
// privileges of the setter so just reject attempts to set it.
@@ -544,13 +538,13 @@ class InspIRCdExtBan : public ChannelModeVirtual<ChannelModeList>
{
}
- ChannelMode *Wrap(Anope::string &param) anope_override
+ ChannelMode *Wrap(Anope::string &param) override
{
param = Anope::string(ext) + ":" + param;
return ChannelModeVirtual<ChannelModeList>::Wrap(param);
}
- ChannelMode *Unwrap(ChannelMode *cm, Anope::string &param) anope_override
+ ChannelMode *Unwrap(ChannelMode *cm, Anope::string &param) override
{
if (cm->type != MODE_LIST || param.length() < 3 || param[0] != ext || param[1] != ':')
return cm;
@@ -569,7 +563,7 @@ namespace InspIRCdExtban
{
}
- bool Matches(User *u, const Entry *e) anope_override
+ bool Matches(User *u, const Entry *e) override
{
const Anope::string &mask = e->GetMask();
Anope::string real_mask = mask.substr(3);
@@ -585,7 +579,7 @@ namespace InspIRCdExtban
{
}
- bool Matches(User *u, const Entry *e) anope_override
+ bool Matches(User *u, const Entry *e) override
{
const Anope::string &mask = e->GetMask();
@@ -621,7 +615,7 @@ namespace InspIRCdExtban
{
}
- bool Matches(User *u, const Entry *e) anope_override
+ bool Matches(User *u, const Entry *e) override
{
const Anope::string &mask = e->GetMask();
Anope::string real_mask = mask.substr(2);
@@ -637,7 +631,7 @@ namespace InspIRCdExtban
{
}
- bool Matches(User *u, const Entry *e) anope_override
+ bool Matches(User *u, const Entry *e) override
{
const Anope::string &mask = e->GetMask();
Anope::string real_mask = mask.substr(2);
@@ -652,7 +646,7 @@ namespace InspIRCdExtban
{
}
- bool Matches(User *u, const Entry *e) anope_override
+ bool Matches(User *u, const Entry *e) override
{
const Anope::string &mask = e->GetMask();
Anope::string real_mask = mask.substr(2);
@@ -667,7 +661,7 @@ namespace InspIRCdExtban
{
}
- bool Matches(User *u, const Entry *e) anope_override
+ bool Matches(User *u, const Entry *e) override
{
const Anope::string &mask = e->GetMask();
Anope::string real_mask = mask.substr(2);
@@ -682,7 +676,7 @@ namespace InspIRCdExtban
{
}
- bool Matches(User *u, const Entry *e) anope_override
+ bool Matches(User *u, const Entry *e) override
{
const Anope::string &mask = e->GetMask();
Anope::string real_mask = mask.substr(2);
@@ -696,7 +690,7 @@ class ColonDelimitedParamMode : public ChannelModeParam
public:
ColonDelimitedParamMode(const Anope::string &modename, char modeChar) : ChannelModeParam(modename, modeChar, true) { }
- bool IsValid(Anope::string &value) const anope_override
+ bool IsValid(Anope::string &value) const override
{
return IsValid(value, false);
}
@@ -745,7 +739,7 @@ class SimpleNumberParamMode : public ChannelModeParam
public:
SimpleNumberParamMode(const Anope::string &modename, char modeChar) : ChannelModeParam(modename, modeChar, true) { }
- bool IsValid(Anope::string &value) const anope_override
+ bool IsValid(Anope::string &value) const override
{
if (value.empty())
return false; // empty param is never valid
@@ -770,7 +764,7 @@ class ChannelModeFlood : public ColonDelimitedParamMode
public:
ChannelModeFlood(char modeChar) : ColonDelimitedParamMode("FLOOD", modeChar) { }
- bool IsValid(Anope::string &value) const anope_override
+ bool IsValid(Anope::string &value) const override
{
// The parameter of this mode is a bit different, it may begin with a '*',
// ignore it if that's the case
@@ -784,7 +778,7 @@ class ChannelModeHistory : public ColonDelimitedParamMode
public:
ChannelModeHistory(char modeChar) : ColonDelimitedParamMode("HISTORY", modeChar) { }
- bool IsValid(Anope::string &value) const anope_override
+ bool IsValid(Anope::string &value) const override
{
return (ColonDelimitedParamMode::IsValid(value, true));
}
@@ -795,7 +789,7 @@ class ChannelModeRedirect : public ChannelModeParam
public:
ChannelModeRedirect(char modeChar) : ChannelModeParam("REDIRECT", modeChar, true) { }
- bool IsValid(Anope::string &value) const anope_override
+ bool IsValid(Anope::string &value) const override
{
// The parameter of this mode is a channel, and channel names start with '#'
return ((!value.empty()) && (value[0] == '#'));
@@ -806,13 +800,13 @@ struct IRCDMessageAway : Message::Away
{
IRCDMessageAway(Module *creator) : Message::Away(creator, "AWAY") { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
std::vector<Anope::string> newparams(params);
if (newparams.size() > 1)
newparams.erase(newparams.begin());
- Message::Away::Run(source, newparams);
+ Message::Away::Run(source, newparams, tags);
}
};
@@ -821,21 +815,19 @@ struct IRCDMessageCapab : Message::Capab
struct ModeInfo
{
// The letter assigned to the mode (e.g. o).
- char letter;
+ char letter = 0;
// If a prefix mode then the rank of the prefix.
- unsigned level;
+ unsigned level = 0;
// The name of the mode.
Anope::string name;
// If a prefix mode then the symbol associated with the prefix.
- char symbol;
+ char symbol = 0;
// The type of mode.
Anope::string type;
-
- ModeInfo() : letter(0), level(0), symbol(0) { }
};
static bool ParseMode(const Anope::string& token, ModeInfo& mode)
@@ -884,7 +876,7 @@ struct IRCDMessageCapab : Message::Capab
IRCDMessageCapab(Module *creator) : Message::Capab(creator, "CAPAB") { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
if (params[0].equals_cs("START"))
{
@@ -1212,7 +1204,7 @@ struct IRCDMessageCapab : Message::Capab
Log() << "CHGIDENT missing, Usage disabled until module is loaded.";
}
- Message::Capab::Run(source, params);
+ Message::Capab::Run(source, params, tags);
}
};
@@ -1220,7 +1212,7 @@ struct IRCDMessageEncap : IRCDMessage
{
IRCDMessageEncap(Module *creator) : IRCDMessage(creator, "ENCAP", 4) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
if (!Anope::Match(Me->GetSID(), params[0]) && !Anope::Match(Me->GetName(), params[0]))
return;
@@ -1270,7 +1262,7 @@ struct IRCDMessageFHost : IRCDMessage
{
IRCDMessageFHost(Module *creator) : IRCDMessage(creator, "FHOST", 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
User *u = source.GetUser();
if (u->HasMode("CLOAK"))
@@ -1283,7 +1275,7 @@ struct IRCDMessageFIdent : IRCDMessage
{
IRCDMessageFIdent(Module *creator) : IRCDMessage(creator, "FIDENT", 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
source.GetUser()->SetIdent(params[0]);
}
@@ -1293,7 +1285,7 @@ struct IRCDMessageKick : IRCDMessage
{
IRCDMessageKick(Module *creator) : IRCDMessage(creator, "KICK", 3) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
// Received: :715AAAAAA KICK #chan 715AAAAAD :reason
// Received: :715AAAAAA KICK #chan 628AAAAAA 4 :reason
@@ -1308,11 +1300,11 @@ struct IRCDMessageKick : IRCDMessage
struct IRCDMessageSave : IRCDMessage
{
- time_t last_collide;
+ time_t last_collide = 0;
- IRCDMessageSave(Module *creator) : IRCDMessage(creator, "SAVE", 2), last_collide(0) { }
+ IRCDMessageSave(Module *creator) : IRCDMessage(creator, "SAVE", 2) { }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
User *targ = User::Find(params[0]);
time_t ts;
@@ -1357,7 +1349,7 @@ class IRCDMessageMetadata : IRCDMessage
public:
IRCDMessageMetadata(Module *creator, const bool &handle_topiclock, const bool &handle_mlock, PrimitiveExtensibleItem<ListLimits> &listlimits) : IRCDMessage(creator, "METADATA", 3), do_topiclock(handle_topiclock), do_mlock(handle_mlock), maxlist(listlimits) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
// We deliberately ignore non-bursting servers to avoid pseudoserver fights
// Channel METADATA has an additional parameter: the channel TS
@@ -1392,7 +1384,7 @@ class IRCDMessageMetadata : IRCDMessage
Anope::string modechr, modelimit;
while (limitstream.GetToken(modechr) && limitstream.GetToken(modelimit))
{
- limits.insert(std::make_pair(modechr[0], convertTo<unsigned>(modelimit)));
+ limits.emplace(modechr[0], convertTo<unsigned>(modelimit));
}
maxlist.Set(c, limits);
}
@@ -1488,7 +1480,7 @@ struct IRCDMessageEndburst : IRCDMessage
{
IRCDMessageEndburst(Module *creator) : IRCDMessage(creator, "ENDBURST", 0) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
Server *s = source.GetServer();
@@ -1502,7 +1494,7 @@ struct IRCDMessageFJoin : IRCDMessage
{
IRCDMessageFJoin(Module *creator) : IRCDMessage(creator, "FJOIN", 2) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
Anope::string modes;
if (params.size() >= 3)
@@ -1558,7 +1550,7 @@ struct IRCDMessageFMode : IRCDMessage
{
IRCDMessageFMode(Module *creator) : IRCDMessage(creator, "FMODE", 3) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
/* :source FMODE #test 12345678 +nto foo */
@@ -1587,7 +1579,7 @@ struct IRCDMessageFTopic : IRCDMessage
{
IRCDMessageFTopic(Module *creator) : IRCDMessage(creator, "FTOPIC", 4) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
// :source FTOPIC channel ts topicts :topic
// :source FTOPIC channel ts topicts setby :topic (burst or RESYNC)
@@ -1605,7 +1597,7 @@ struct IRCDMessageIdle : IRCDMessage
{
IRCDMessageIdle(Module *creator) : IRCDMessage(creator, "IDLE", 1) { }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
BotInfo *bi = BotInfo::Find(params[0]);
if (bi)
@@ -1623,7 +1615,7 @@ struct IRCDMessageIJoin : IRCDMessage
{
IRCDMessageIJoin(Module *creator) : IRCDMessage(creator, "IJOIN", 2) { SetFlag(IRCDMESSAGE_REQUIRE_USER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
// :<uid> IJOIN <chan> <membid> [<ts> [<flags>]]
Channel *c = Channel::Find(params[0]);
@@ -1645,8 +1637,8 @@ struct IRCDMessageIJoin : IRCDMessage
if (params.size() >= 4)
{
chants = params[2].is_pos_number_only() ? convertTo<unsigned>(params[2]) : 0;
- for (unsigned i = 0; i < params[3].length(); ++i)
- user.first.AddMode(params[3][i]);
+ for (auto mode : params[3])
+ user.first.AddMode(mode);
}
std::list<Message::Join::SJoinUser> users;
@@ -1659,7 +1651,7 @@ struct IRCDMessageMode : IRCDMessage
{
IRCDMessageMode(Module *creator) : IRCDMessage(creator, "MODE", 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
if (IRCD->IsChannelValid(params[0]))
{
@@ -1689,7 +1681,7 @@ struct IRCDMessageNick : IRCDMessage
{
IRCDMessageNick(Module *creator) : IRCDMessage(creator, "NICK", 2) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
source.GetUser()->ChangeNick(params[0]);
}
@@ -1699,7 +1691,7 @@ struct IRCDMessageOperType : IRCDMessage
{
IRCDMessageOperType(Module *creator) : IRCDMessage(creator, "OPERTYPE", 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); SetFlag(IRCDMESSAGE_REQUIRE_USER); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
/* opertype is equivalent to mode +o because servers
don't do this directly */
@@ -1713,7 +1705,7 @@ struct IRCDMessagePing : IRCDMessage
{
IRCDMessagePing(Module *creator) : IRCDMessage(creator, "PING", 1) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
if (params[0] == Me->GetSID())
IRCD->SendPong(params[0], source.GetServer()->GetSID());
@@ -1724,7 +1716,7 @@ struct IRCDMessageRSQuit : IRCDMessage
{
IRCDMessageRSQuit(Module *creator) : IRCDMessage(creator, "RSQUIT", 1) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
Server *s = Server::Find(params[0]);
const Anope::string &reason = params.size() > 1 ? params[1] : "";
@@ -1740,7 +1732,7 @@ struct IRCDMessageServer : IRCDMessage
{
IRCDMessageServer(Module *creator) : IRCDMessage(creator, "SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
if (!source.GetServer() && params.size() == 5)
{
@@ -1773,7 +1765,7 @@ struct IRCDMessageSQuit : Message::SQuit
{
IRCDMessageSQuit(Module *creator) : Message::SQuit(creator) { }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
if (params[0] == rsquit_id || params[0] == rsquit_server)
{
@@ -1787,7 +1779,7 @@ struct IRCDMessageSQuit : Message::SQuit
IRCD->SendServer(s);
}
else
- Message::SQuit::Run(source, params);
+ Message::SQuit::Run(source, params, tags);
}
};
@@ -1795,7 +1787,7 @@ struct IRCDMessageTime : IRCDMessage
{
IRCDMessageTime(Module *creator) : IRCDMessage(creator, "TIME", 2) { }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
UplinkSocket::Message(Me) << "TIME " << source.GetSource() << " " << params[1] << " " << Anope::CurTime;
}
@@ -1818,7 +1810,7 @@ struct IRCDMessageUID : IRCDMessage
* 8+: modes and params -- IMPORTANT, some modes (e.g. +s) may have parameters. So don't assume a fixed position of realname!
* last: realname
*/
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
time_t ts = convertTo<time_t>(params[1]);
@@ -1849,9 +1841,9 @@ struct IRCDMessageUID : IRCDMessage
}
};
-class ProtoInspIRCd3 : public Module
+class ProtoInspIRCd : public Module
{
- InspIRCd3Proto ircd_proto;
+ InspIRCdProto ircd_proto;
ExtensibleItem<bool> ssl;
/* Core message handlers */
@@ -1898,7 +1890,7 @@ class ProtoInspIRCd3 : public Module
}
public:
- ProtoInspIRCd3(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL | VENDOR),
+ ProtoInspIRCd(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL | VENDOR),
ircd_proto(this), ssl(this, "ssl"),
message_error(this), message_invite(this), message_kill(this), message_motd(this), message_notice(this),
message_part(this), message_privmsg(this), message_quit(this), message_stats(this),
@@ -1910,24 +1902,24 @@ class ProtoInspIRCd3 : public Module
{
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
use_server_side_topiclock = conf->GetModule(this)->Get<bool>("use_server_side_topiclock");
use_server_side_mlock = conf->GetModule(this)->Get<bool>("use_server_side_mlock");
}
- void OnUserNickChange(User *u, const Anope::string &) anope_override
+ void OnUserNickChange(User *u, const Anope::string &) override
{
u->RemoveModeInternal(Me, ModeManager::FindUserModeByName("REGISTERED"));
}
- void OnChannelSync(Channel *c) anope_override
+ void OnChannelSync(Channel *c) override
{
if (c->ci)
this->OnChanRegistered(c->ci);
}
- void OnChanRegistered(ChannelInfo *ci) anope_override
+ void OnChanRegistered(ChannelInfo *ci) override
{
ModeLocks *modelocks = ci->GetExt<ModeLocks>("modelocks");
if (use_server_side_mlock && ci->c && modelocks && !modelocks->GetMLockAsString(false).empty())
@@ -1943,7 +1935,7 @@ class ProtoInspIRCd3 : public Module
}
}
- void OnDelChan(ChannelInfo *ci) anope_override
+ void OnDelChan(ChannelInfo *ci) override
{
if (use_server_side_mlock && ci->c)
SendChannelMetadata(ci->c, "mlock", "");
@@ -1952,7 +1944,7 @@ class ProtoInspIRCd3 : public Module
SendChannelMetadata(ci->c, "topiclock", "");
}
- EventReturn OnMLock(ChannelInfo *ci, ModeLock *lock) anope_override
+ EventReturn OnMLock(ChannelInfo *ci, ModeLock *lock) override
{
ModeLocks *modelocks = ci->GetExt<ModeLocks>("modelocks");
ChannelMode *cm = ModeManager::FindChannelModeByName(lock->name);
@@ -1965,7 +1957,7 @@ class ProtoInspIRCd3 : public Module
return EVENT_CONTINUE;
}
- EventReturn OnUnMLock(ChannelInfo *ci, ModeLock *lock) anope_override
+ EventReturn OnUnMLock(ChannelInfo *ci, ModeLock *lock) override
{
ModeLocks *modelocks = ci->GetExt<ModeLocks>("modelocks");
ChannelMode *cm = ModeManager::FindChannelModeByName(lock->name);
@@ -1978,7 +1970,7 @@ class ProtoInspIRCd3 : public Module
return EVENT_CONTINUE;
}
- EventReturn OnSetChannelOption(CommandSource &source, Command *cmd, ChannelInfo *ci, const Anope::string &setting) anope_override
+ EventReturn OnSetChannelOption(CommandSource &source, Command *cmd, ChannelInfo *ci, const Anope::string &setting) override
{
if (cmd->name == "chanserv/topic" && ci->c)
{
@@ -1992,4 +1984,4 @@ class ProtoInspIRCd3 : public Module
}
};
-MODULE_INIT(ProtoInspIRCd3)
+MODULE_INIT(ProtoInspIRCd)
diff --git a/modules/protocol/inspircd12.cpp b/modules/protocol/inspircd12.cpp
deleted file mode 100644
index 8b1a18bb2..000000000
--- a/modules/protocol/inspircd12.cpp
+++ /dev/null
@@ -1,1408 +0,0 @@
-/* inspircd 1.2 functions
- *
- * (C) 2003-2023 Anope Team
- * Contact us at team@anope.org
- *
- * Please read COPYING and README for further details.
- *
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
- */
-
-#include "module.h"
-#include "modules/sasl.h"
-
-struct SASLUser
-{
- Anope::string uid;
- Anope::string acc;
- time_t created;
-};
-
-static std::list<SASLUser> saslusers;
-
-static Anope::string rsquit_server, rsquit_id;
-
-class ChannelModeFlood : public ChannelModeParam
-{
- public:
- ChannelModeFlood(char modeChar, bool minusNoArg) : ChannelModeParam("FLOOD", modeChar, minusNoArg) { }
-
- bool IsValid(Anope::string &value) const anope_override
- {
- try
- {
- Anope::string rest;
- if (!value.empty() && value[0] != ':' && convertTo<int>(value[0] == '*' ? value.substr(1) : value, rest, false) > 0 && rest[0] == ':' && rest.length() > 1 && convertTo<int>(rest.substr(1), rest, false) > 0 && rest.empty())
- return true;
- }
- catch (const ConvertException &) { }
-
- return false;
- }
-};
-
-class InspIRCd12Proto : public IRCDProto
-{
- private:
- void SendSVSKillInternal(const MessageSource &source, User *user, const Anope::string &buf) anope_override
- {
- IRCDProto::SendSVSKillInternal(source, user, buf);
- user->KillInternal(source, buf);
- }
-
- void SendChgIdentInternal(const Anope::string &nick, const Anope::string &vIdent)
- {
- if (!Servers::Capab.count("CHGIDENT"))
- Log() << "CHGIDENT not loaded!";
- else
- UplinkSocket::Message(Me) << "CHGIDENT " << nick << " " << vIdent;
- }
-
- void SendChgHostInternal(const Anope::string &nick, const Anope::string &vhost)
- {
- if (!Servers::Capab.count("CHGHOST"))
- Log() << "CHGHOST not loaded!";
- else
- UplinkSocket::Message(Me) << "CHGHOST " << nick << " " << vhost;
- }
-
- void SendAddLine(const Anope::string &xtype, const Anope::string &mask, time_t duration, const Anope::string &addedby, const Anope::string &reason)
- {
- UplinkSocket::Message(Me) << "ADDLINE " << xtype << " " << mask << " " << addedby << " " << Anope::CurTime << " " << duration << " :" << reason;
- }
-
- void SendDelLine(const Anope::string &xtype, const Anope::string &mask)
- {
- UplinkSocket::Message(Me) << "DELLINE " << xtype << " " << mask;
- }
-
- public:
- InspIRCd12Proto(Module *creator) : IRCDProto(creator, "InspIRCd 1.2")
- {
- DefaultPseudoclientModes = "+I";
- CanSVSNick = true;
- CanSVSJoin = true;
- CanSetVHost = true;
- CanSetVIdent = true;
- CanSQLine = true;
- CanSZLine = true;
- CanSVSHold = true;
- CanCertFP = true;
- RequiresID = true;
- MaxModes = 20;
- }
-
- void SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override
- {
- UplinkSocket::Message(bi) << "NOTICE $" << dest->GetName() << " :" << msg;
- }
-
- void SendGlobalPrivmsg(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override
- {
- UplinkSocket::Message(bi) << "PRIVMSG $" << dest->GetName() << " :" << msg;
- }
-
- void SendAkillDel(const XLine *x) anope_override
- {
- /* InspIRCd may support regex bans
- * Mask is expected in format: 'n!u@h\sr' and spaces as '\s'
- * We remove the '//' and replace '#' and any ' ' with '\s'
- */
- if (x->IsRegex() && Servers::Capab.count("RLINE"))
- {
- Anope::string mask = x->mask;
- if (mask.length() >= 2 && mask[0] == '/' && mask[mask.length() - 1] == '/')
- mask = mask.substr(1, mask.length() - 2);
- size_t h = mask.find('#');
- if (h != Anope::string::npos)
- {
- mask = mask.replace(h, 1, "\\s");
- mask = mask.replace_all_cs(" ", "\\s");
- }
- SendDelLine("R", mask);
- return;
- }
- else if (x->IsRegex() || x->HasNickOrReal())
- return;
-
- /* ZLine if we can instead */
- if (x->GetUser() == "*")
- {
- cidr addr(x->GetHost());
- if (addr.valid())
- {
- IRCD->SendSZLineDel(x);
- return;
- }
- }
-
- SendDelLine("G", x->GetUser() + "@" + x->GetHost());
- }
-
- void SendTopic(const MessageSource &source, Channel *c) anope_override
- {
- if (Servers::Capab.count("SVSTOPIC"))
- {
- UplinkSocket::Message(c->WhoSends()) << "SVSTOPIC " << c->name << " " << c->topic_ts << " " << c->topic_setter << " :" << c->topic;
- }
- else
- {
- /* If the last time a topic was set is after the TS we want for this topic we must bump this topic's timestamp to now */
- time_t ts = c->topic_ts;
- if (c->topic_time > ts)
- ts = Anope::CurTime;
- /* But don't modify c->topic_ts, it should remain set to the real TS we want as ci->last_topic_time pulls from it */
- UplinkSocket::Message(source) << "FTOPIC " << c->name << " " << ts << " " << c->topic_setter << " :" << c->topic;
- }
- }
-
- void SendVhostDel(User *u) anope_override
- {
- UserMode *um = ModeManager::FindUserModeByName("CLOAK");
-
- if (um && !u->HasMode(um->name))
- // Just set +x if we can
- u->SetMode(NULL, um);
- else
- // Try to restore cloaked host
- this->SendChgHostInternal(u->nick, u->chost);
- }
-
- void SendAkill(User *u, XLine *x) anope_override
- {
- // Calculate the time left before this would expire, capping it at 2 days
- time_t timeleft = x->expires - Anope::CurTime;
- if (timeleft > 172800 || !x->expires)
- timeleft = 172800;
-
- /* InspIRCd may support regex bans, if they do we can send this and forget about it
- * Mask is expected in format: 'n!u@h\sr' and spaces as '\s'
- * We remove the '//' and replace '#' and any ' ' with '\s'
- */
- if (x->IsRegex() && Servers::Capab.count("RLINE"))
- {
- Anope::string mask = x->mask;
- if (mask.length() >= 2 && mask[0] == '/' && mask[mask.length() - 1] == '/')
- mask = mask.substr(1, mask.length() - 2);
- size_t h = mask.find('#');
- if (h != Anope::string::npos)
- {
- mask = mask.replace(h, 1, "\\s");
- mask = mask.replace_all_cs(" ", "\\s");
- }
- SendAddLine("R", mask, timeleft, x->by, x->GetReason());
- return;
- }
- else if (x->IsRegex() || x->HasNickOrReal())
- {
- if (!u)
- {
- /* No user (this akill was just added), and contains nick and/or realname. Find users that match and ban them */
- for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
- if (x->manager->Check(it->second, x))
- this->SendAkill(it->second, x);
- return;
- }
-
- const XLine *old = x;
-
- if (old->manager->HasEntry("*@" + u->host))
- return;
-
- /* We can't akill x as it has a nick and/or realname included, so create a new akill for *@host */
- x = new XLine("*@" + u->host, old->by, old->expires, old->reason, old->id);
- old->manager->AddXLine(x);
-
- Log(Config->GetClient("OperServ"), "akill") << "AKILL: Added an akill for " << x->mask << " because " << u->GetMask() << "#" << u->realname << " matches " << old->mask;
- }
-
- /* ZLine if we can instead */
- if (x->GetUser() == "*")
- {
- cidr addr(x->GetHost());
- if (addr.valid())
- {
- IRCD->SendSZLine(u, x);
- return;
- }
- }
-
- SendAddLine("G", x->GetUser() + "@" + x->GetHost(), timeleft, x->by, x->GetReason());
- }
-
- void SendNumericInternal(int numeric, const Anope::string &dest, const Anope::string &buf) anope_override
- {
- User *u = User::Find(dest);
- UplinkSocket::Message() << "PUSH " << dest << " ::" << Me->GetName() << " " << numeric << " " << (u ? u->nick : dest) << " " << buf;
- }
-
- void SendModeInternal(const MessageSource &source, const Channel *dest, const Anope::string &buf) anope_override
- {
- UplinkSocket::Message(source) << "FMODE " << dest->name << " " << dest->creation_time << " " << buf;
- }
-
- void SendClientIntroduction(User *u) anope_override
- {
- Anope::string modes = "+" + u->GetModes();
- UplinkSocket::Message(Me) << "UID " << u->GetUID() << " " << u->timestamp << " " << u->nick << " " << u->host << " " << u->host << " " << u->GetIdent() << " 0.0.0.0 " << u->timestamp << " " << modes << " :" << u->realname;
-
- if (modes.find('o') != Anope::string::npos)
- {
- // Mark as introduced so we can send an oper type.
- BotInfo *bi = BotInfo::Find(u->nick, true);
- if (bi)
- bi->introduced = true;
-
- UplinkSocket::Message(u) << "OPERTYPE :service";
- }
- }
-
- /* SERVER services-dev.chatspike.net password 0 :Description here */
- void SendServer(const Server *server) anope_override
- {
- /* if rsquit is set then we are waiting on a squit */
- if (rsquit_id.empty() && rsquit_server.empty())
- UplinkSocket::Message() << "SERVER " << server->GetName() << " " << Config->Uplinks[Anope::CurrentUplink].password << " " << server->GetHops() << " " << server->GetSID() << " :" << server->GetDescription();
- }
-
- void SendSquit(Server *s, const Anope::string &message) anope_override
- {
- if (s != Me)
- {
- rsquit_id = s->GetSID();
- rsquit_server = s->GetName();
- UplinkSocket::Message() << "RSQUIT " << s->GetName() << " :" << message;
- }
- else
- UplinkSocket::Message() << "SQUIT " << s->GetName() << " :" << message;
- }
-
- /* JOIN */
- void SendJoin(User *user, Channel *c, const ChannelStatus *status) anope_override
- {
- UplinkSocket::Message(Me) << "FJOIN " << c->name << " " << c->creation_time << " +" << c->GetModes(true, true) << " :," << user->GetUID();
- /* Note that we can send this with the FJOIN but choose not to
- * because the mode stacker will handle this and probably will
- * merge these modes with +nrt and other mlocked modes
- */
- if (status)
- {
- /* First save the channel status incase uc->Status == status */
- ChannelStatus cs = *status;
- /* If the user is internally on the channel with flags, kill them so that
- * the stacker will allow this.
- */
- ChanUserContainer *uc = c->FindUser(user);
- if (uc != NULL)
- uc->status.Clear();
-
- BotInfo *setter = BotInfo::Find(user->GetUID());
- for (size_t i = 0; i < cs.Modes().length(); ++i)
- c->SetMode(setter, ModeManager::FindChannelModeByChar(cs.Modes()[i]), user->GetUID(), false);
-
- if (uc != NULL)
- uc->status = cs;
- }
- }
-
- /* UNSQLINE */
- void SendSQLineDel(const XLine *x) anope_override
- {
- SendDelLine("Q", x->mask);
- }
-
- /* SQLINE */
- void SendSQLine(User *, const XLine *x) anope_override
- {
- // Calculate the time left before this would expire, capping it at 2 days
- time_t timeleft = x->expires - Anope::CurTime;
- if (timeleft > 172800 || !x->expires)
- timeleft = 172800;
- SendAddLine("Q", x->mask, timeleft, x->by, x->GetReason());
- }
-
- void SendVhost(User *u, const Anope::string &vIdent, const Anope::string &vhost) anope_override
- {
- if (!vIdent.empty())
- this->SendChgIdentInternal(u->nick, vIdent);
- if (!vhost.empty())
- this->SendChgHostInternal(u->nick, vhost);
- }
-
- void SendConnect() anope_override
- {
- SendServer(Me);
- }
-
- /* SVSHOLD - set */
- void SendSVSHold(const Anope::string &nick, time_t t) anope_override
- {
- UplinkSocket::Message(Config->GetClient("NickServ")) << "SVSHOLD " << nick << " " << t << " :Being held for registered user";
- }
-
- /* SVSHOLD - release */
- void SendSVSHoldDel(const Anope::string &nick) anope_override
- {
- UplinkSocket::Message(Config->GetClient("NickServ")) << "SVSHOLD " << nick;
- }
-
- /* UNSZLINE */
- void SendSZLineDel(const XLine *x) anope_override
- {
- SendDelLine("Z", x->GetHost());
- }
-
- /* SZLINE */
- void SendSZLine(User *, const XLine *x) anope_override
- {
- // Calculate the time left before this would expire, capping it at 2 days
- time_t timeleft = x->expires - Anope::CurTime;
- if (timeleft > 172800 || !x->expires)
- timeleft = 172800;
- SendAddLine("Z", x->GetHost(), timeleft, x->by, x->GetReason());
- }
-
- void SendSVSJoin(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string &) anope_override
- {
- UplinkSocket::Message(source) << "SVSJOIN " << u->GetUID() << " " << chan;
- }
-
- void SendSVSPart(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string &param) anope_override
- {
- if (!param.empty())
- UplinkSocket::Message(source) << "SVSPART " << u->GetUID() << " " << chan << " :" << param;
- else
- UplinkSocket::Message(source) << "SVSPART " << u->GetUID() << " " << chan;
- }
-
- void SendSWhois(const MessageSource &, const Anope::string &who, const Anope::string &mask) anope_override
- {
- User *u = User::Find(who);
-
- UplinkSocket::Message(Me) << "METADATA " << u->GetUID() << " swhois :" << mask;
- }
-
- void SendBOB() anope_override
- {
- UplinkSocket::Message(Me) << "BURST " << Anope::CurTime;
- Module *enc = ModuleManager::FindFirstOf(ENCRYPTION);
- UplinkSocket::Message(Me) << "VERSION :Anope-" << Anope::Version() << " " << Me->GetName() << " :" << IRCD->GetProtocolName() << " - (" << (enc ? enc->name : "none") << ") -- " << Anope::VersionBuildString();
- }
-
- void SendEOB() anope_override
- {
- UplinkSocket::Message(Me) << "ENDBURST";
- }
-
- void SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) anope_override
- {
- if (Servers::Capab.count("GLOBOPS"))
- UplinkSocket::Message(source) << "SNONOTICE g :" << buf;
- else
- UplinkSocket::Message(source) << "SNONOTICE A :" << buf;
- }
-
- void SendLogin(User *u, NickAlias *na) anope_override
- {
- /* InspIRCd uses an account to bypass chmode +R, not umode +r, so we can't send this here */
- if (na->nc->HasExt("UNCONFIRMED"))
- return;
-
- UplinkSocket::Message(Me) << "METADATA " << u->GetUID() << " accountname :" << na->nc->display;
- }
-
- void SendLogout(User *u) anope_override
- {
- UplinkSocket::Message(Me) << "METADATA " << u->GetUID() << " accountname :";
- }
-
- void SendChannel(Channel *c) anope_override
- {
- UplinkSocket::Message(Me) << "FJOIN " << c->name << " " << c->creation_time << " +" << c->GetModes(true, true) << " :";
- }
-
- void SendOper(User *u) anope_override
- {
- }
-
- void SendSASLMessage(const SASL::Message &message) anope_override
- {
- UplinkSocket::Message(Me) << "ENCAP " << message.target.substr(0, 3) << " SASL " << message.source << " " << message.target << " " << message.type << " " << message.data << (message.ext.empty() ? "" : (" " + message.ext));
- }
-
- void SendSVSLogin(const Anope::string &uid, const Anope::string &acc, const Anope::string &vident, const Anope::string &vhost) anope_override
- {
- UplinkSocket::Message(Me) << "METADATA " << uid << " accountname :" << acc;
-
- if (!vident.empty())
- UplinkSocket::Message(Me) << "ENCAP " << uid.substr(0, 3) << " CHGIDENT " << uid << " " << vident;
- if (!vhost.empty())
- UplinkSocket::Message(Me) << "ENCAP " << uid.substr(0, 3) << " CHGHOST " << uid << " " << vhost;
-
- SASLUser su;
- su.uid = uid;
- su.acc = acc;
- su.created = Anope::CurTime;
-
- for (std::list<SASLUser>::iterator it = saslusers.begin(); it != saslusers.end();)
- {
- SASLUser &u = *it;
-
- if (u.created + 30 < Anope::CurTime || u.uid == uid)
- it = saslusers.erase(it);
- else
- ++it;
- }
-
- saslusers.push_back(su);
- }
-
- bool IsExtbanValid(const Anope::string &mask) anope_override
- {
- return mask.length() >= 3 && mask[1] == ':';
- }
-
- bool IsIdentValid(const Anope::string &ident) anope_override
- {
- if (ident.empty() || ident.length() > Config->GetBlock("networkinfo")->Get<unsigned>("userlen"))
- return false;
-
- for (unsigned i = 0; i < ident.length(); ++i)
- {
- const char &c = ident[i];
-
- if (c >= 'A' && c <= '}')
- continue;
-
- if ((c >= '0' && c <= '9') || c == '-' || c == '.')
- continue;
-
- return false;
- }
-
- return true;
- }
-};
-
-class InspIRCdExtBan : public ChannelModeList
-{
- public:
- InspIRCdExtBan(const Anope::string &mname, char modeChar) : ChannelModeList(mname, modeChar) { }
-
- bool Matches(User *u, const Entry *e) anope_override
- {
- const Anope::string &mask = e->GetMask();
-
- if (mask.find("m:") == 0 || mask.find("N:") == 0)
- {
- Anope::string real_mask = mask.substr(2);
-
- Entry en(this->name, real_mask);
- if (en.Matches(u))
- return true;
- }
- else if (mask.find("j:") == 0)
- {
- Anope::string real_mask = mask.substr(2);
-
- Channel *c = Channel::Find(real_mask);
- if (c != NULL && c->FindUser(u) != NULL)
- return true;
- }
- else if (mask.find("M:") == 0 || mask.find("R:") == 0)
- {
- Anope::string real_mask = mask.substr(2);
-
- if (u->IsIdentified() && real_mask.equals_ci(u->Account()->display))
- return true;
- }
- else if (mask.find("r:") == 0)
- {
- Anope::string real_mask = mask.substr(2);
-
- if (Anope::Match(u->realname, real_mask))
- return true;
- }
- else if (mask.find("s:") == 0)
- {
- Anope::string real_mask = mask.substr(2);
-
- if (Anope::Match(u->server->GetName(), real_mask))
- return true;
- }
-
- return false;
- }
-};
-
-struct IRCDMessageCapab : Message::Capab
-{
- IRCDMessageCapab(Module *creator) : Message::Capab(creator, "CAPAB") { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- if (params[0].equals_cs("START"))
- {
- /* reset CAPAB */
- Servers::Capab.clear();
- Servers::Capab.insert("NOQUIT");
- IRCD->CanSVSHold = false;
- }
- else if (params[0].equals_cs("MODULES") && params.size() > 1)
- {
- if (params[1].find("m_globops.so") != Anope::string::npos)
- Servers::Capab.insert("GLOBOPS");
- if (params[1].find("m_services_account.so") != Anope::string::npos)
- Servers::Capab.insert("SERVICES");
- if (params[1].find("m_svshold.so") != Anope::string::npos)
- IRCD->CanSVSHold = true;
- if (params[1].find("m_chghost.so") != Anope::string::npos)
- Servers::Capab.insert("CHGHOST");
- if (params[1].find("m_chgident.so") != Anope::string::npos)
- Servers::Capab.insert("CHGIDENT");
- if (params[1].find("m_hidechans.so") != Anope::string::npos)
- Servers::Capab.insert("HIDECHANS");
- if (params[1].find("m_servprotect.so") != Anope::string::npos)
- IRCD->DefaultPseudoclientModes = "+Ik";
- if (params[1].find("m_rline.so") != Anope::string::npos)
- Servers::Capab.insert("RLINE");
- }
- else if (params[0].equals_cs("CAPABILITIES") && params.size() > 1)
- {
- spacesepstream ssep(params[1]);
- Anope::string capab;
- while (ssep.GetToken(capab))
- {
- if (capab.find("CHANMODES") != Anope::string::npos)
- {
- Anope::string modes(capab.begin() + 10, capab.end());
- commasepstream sep(modes);
- Anope::string modebuf;
-
- sep.GetToken(modebuf);
- for (size_t t = 0, end = modebuf.length(); t < end; ++t)
- {
- switch (modebuf[t])
- {
- case 'b':
- ModeManager::AddChannelMode(new InspIRCdExtBan("BAN", 'b'));
- continue;
- case 'e':
- ModeManager::AddChannelMode(new InspIRCdExtBan("EXCEPT", 'e'));
- continue;
- case 'I':
- ModeManager::AddChannelMode(new InspIRCdExtBan("INVITEOVERRIDE", 'I'));
- continue;
- /* InspIRCd sends q and a here if they have no prefixes */
- case 'q':
- ModeManager::AddChannelMode(new ChannelModeStatus("OWNER", 'q', '@', 4));
- continue;
- case 'a':
- ModeManager::AddChannelMode(new ChannelModeStatus("PROTECT" , 'a', '@', 3));
- continue;
- default:
- ModeManager::AddChannelMode(new ChannelModeList("", modebuf[t]));
- }
- }
-
- sep.GetToken(modebuf);
- for (size_t t = 0, end = modebuf.length(); t < end; ++t)
- {
- switch (modebuf[t])
- {
- case 'k':
- ModeManager::AddChannelMode(new ChannelModeKey('k'));
- continue;
- default:
- ModeManager::AddChannelMode(new ChannelModeParam("", modebuf[t]));
- }
- }
-
- sep.GetToken(modebuf);
- for (size_t t = 0, end = modebuf.length(); t < end; ++t)
- {
- switch (modebuf[t])
- {
- case 'F':
- ModeManager::AddChannelMode(new ChannelModeParam("NICKFLOOD", 'F', true));
- continue;
- case 'J':
- ModeManager::AddChannelMode(new ChannelModeParam("NOREJOIN", 'J', true));
- continue;
- case 'L':
- ModeManager::AddChannelMode(new ChannelModeParam("REDIRECT", 'L', true));
- continue;
- case 'f':
- ModeManager::AddChannelMode(new ChannelModeFlood('f', true));
- continue;
- case 'j':
- ModeManager::AddChannelMode(new ChannelModeParam("JOINFLOOD", 'j', true));
- continue;
- case 'l':
- ModeManager::AddChannelMode(new ChannelModeParam("LIMIT", 'l', true));
- continue;
- default:
- ModeManager::AddChannelMode(new ChannelModeParam("", modebuf[t], true));
- }
- }
-
- sep.GetToken(modebuf);
- for (size_t t = 0, end = modebuf.length(); t < end; ++t)
- {
- switch (modebuf[t])
- {
- case 'A':
- ModeManager::AddChannelMode(new ChannelMode("ALLINVITE", 'A'));
- continue;
- case 'B':
- ModeManager::AddChannelMode(new ChannelMode("BLOCKCAPS", 'B'));
- continue;
- case 'C':
- ModeManager::AddChannelMode(new ChannelMode("NOCTCP", 'C'));
- continue;
- case 'D':
- ModeManager::AddChannelMode(new ChannelMode("DELAYEDJOIN", 'D'));
- continue;
- case 'G':
- ModeManager::AddChannelMode(new ChannelMode("CENSOR", 'G'));
- continue;
- case 'K':
- ModeManager::AddChannelMode(new ChannelMode("NOKNOCK", 'K'));
- continue;
- case 'M':
- ModeManager::AddChannelMode(new ChannelMode("REGMODERATED", 'M'));
- continue;
- case 'N':
- ModeManager::AddChannelMode(new ChannelMode("NONICK", 'N'));
- continue;
- case 'O':
- ModeManager::AddChannelMode(new ChannelModeOperOnly("OPERONLY", 'O'));
- continue;
- case 'P':
- ModeManager::AddChannelMode(new ChannelMode("PERM", 'P'));
- continue;
- case 'Q':
- ModeManager::AddChannelMode(new ChannelMode("NOKICK", 'Q'));
- continue;
- case 'R':
- ModeManager::AddChannelMode(new ChannelMode("REGISTEREDONLY", 'R'));
- continue;
- case 'S':
- ModeManager::AddChannelMode(new ChannelMode("STRIPCOLOR", 'S'));
- continue;
- case 'T':
- ModeManager::AddChannelMode(new ChannelMode("NONOTICE", 'T'));
- continue;
- case 'c':
- ModeManager::AddChannelMode(new ChannelMode("BLOCKCOLOR", 'c'));
- continue;
- case 'i':
- ModeManager::AddChannelMode(new ChannelMode("INVITE", 'i'));
- continue;
- case 'm':
- ModeManager::AddChannelMode(new ChannelMode("MODERATED", 'm'));
- continue;
- case 'n':
- ModeManager::AddChannelMode(new ChannelMode("NOEXTERNAL", 'n'));
- continue;
- case 'p':
- ModeManager::AddChannelMode(new ChannelMode("PRIVATE", 'p'));
- continue;
- case 'r':
- ModeManager::AddChannelMode(new ChannelModeNoone("REGISTERED", 'r'));
- continue;
- case 's':
- ModeManager::AddChannelMode(new ChannelMode("SECRET", 's'));
- continue;
- case 't':
- ModeManager::AddChannelMode(new ChannelMode("TOPIC", 't'));
- continue;
- case 'u':
- ModeManager::AddChannelMode(new ChannelMode("AUDITORIUM", 'u'));
- continue;
- case 'z':
- ModeManager::AddChannelMode(new ChannelMode("SSL", 'z'));
- continue;
- default:
- ModeManager::AddChannelMode(new ChannelMode("", modebuf[t]));
- }
- }
- }
- else if (capab.find("USERMODES") != Anope::string::npos)
- {
- Anope::string modes(capab.begin() + 10, capab.end());
- commasepstream sep(modes);
- Anope::string modebuf;
-
- while (sep.GetToken(modebuf))
- {
- for (size_t t = 0, end = modebuf.length(); t < end; ++t)
- {
- switch (modebuf[t])
- {
- case 'h':
- ModeManager::AddUserMode(new UserModeOperOnly("HELPOP", 'h'));
- continue;
- case 'B':
- ModeManager::AddUserMode(new UserMode("BOT", 'B'));
- continue;
- case 'G':
- ModeManager::AddUserMode(new UserMode("CENSOR", 'G'));
- continue;
- case 'H':
- ModeManager::AddUserMode(new UserModeOperOnly("HIDEOPER", 'H'));
- continue;
- case 'I':
- ModeManager::AddUserMode(new UserMode("PRIV", 'I'));
- continue;
- case 'Q':
- ModeManager::AddUserMode(new UserModeOperOnly("HIDDEN", 'Q'));
- continue;
- case 'R':
- ModeManager::AddUserMode(new UserMode("REGPRIV", 'R'));
- continue;
- case 'S':
- ModeManager::AddUserMode(new UserMode("STRIPCOLOR", 'S'));
- continue;
- case 'W':
- ModeManager::AddUserMode(new UserMode("WHOIS", 'W'));
- continue;
- case 'c':
- ModeManager::AddUserMode(new UserMode("COMMONCHANS", 'c'));
- continue;
- case 'g':
- ModeManager::AddUserMode(new UserMode("CALLERID", 'g'));
- continue;
- case 'i':
- ModeManager::AddUserMode(new UserMode("INVIS", 'i'));
- continue;
- case 'k':
- ModeManager::AddUserMode(new UserModeNoone("PROTECTED", 'k'));
- continue;
- case 'o':
- ModeManager::AddUserMode(new UserModeOperOnly("OPER", 'o'));
- continue;
- case 'r':
- ModeManager::AddUserMode(new UserModeNoone("REGISTERED", 'r'));
- continue;
- case 'w':
- ModeManager::AddUserMode(new UserMode("WALLOPS", 'w'));
- continue;
- case 'x':
- ModeManager::AddUserMode(new UserMode("CLOAK", 'x'));
- continue;
- case 'd':
- ModeManager::AddUserMode(new UserMode("DEAF", 'd'));
- continue;
- default:
- ModeManager::AddUserMode(new UserMode("", modebuf[t]));
- }
- }
- }
- }
- else if (capab.find("PREFIX=(") != Anope::string::npos)
- {
- Anope::string modes(capab.begin() + 8, capab.begin() + capab.find(')'));
- Anope::string chars(capab.begin() + capab.find(')') + 1, capab.end());
- unsigned short level = modes.length() - 1;
-
- for (size_t t = 0, end = modes.length(); t < end; ++t)
- {
- switch (modes[t])
- {
- case 'q':
- ModeManager::AddChannelMode(new ChannelModeStatus("OWNER", 'q', chars[t], level--));
- continue;
- case 'a':
- ModeManager::AddChannelMode(new ChannelModeStatus("PROTECT", 'a', chars[t], level--));
- continue;
- case 'o':
- ModeManager::AddChannelMode(new ChannelModeStatus("OP", 'o', chars[t], level--));
- continue;
- case 'h':
- ModeManager::AddChannelMode(new ChannelModeStatus("HALFOP", 'h', chars[t], level--));
- continue;
- case 'v':
- ModeManager::AddChannelMode(new ChannelModeStatus("VOICE", 'v', chars[t], level--));
- continue;
- default:
- ModeManager::AddChannelMode(new ChannelModeStatus("", modes[t], chars[t], level--));
- }
- }
-
- ModeManager::RebuildStatusModes();
- }
- else if (capab.find("MAXMODES=") != Anope::string::npos)
- {
- Anope::string maxmodes(capab.begin() + 9, capab.end());
- IRCD->MaxModes = maxmodes.is_pos_number_only() ? convertTo<unsigned>(maxmodes) : 3;
- }
- }
- }
- else if (params[0].equals_cs("END"))
- {
- if (!Servers::Capab.count("GLOBOPS"))
- {
- UplinkSocket::Message() << "ERROR :m_globops is not loaded. This is required by Anope";
- Anope::QuitReason = "Remote server does not have the m_globops module loaded, and this is required.";
- Anope::Quitting = true;
- return;
- }
- if (!Servers::Capab.count("SERVICES"))
- {
- UplinkSocket::Message() << "ERROR :m_services_account.so is not loaded. This is required by Anope";
- Anope::QuitReason = "ERROR: Remote server does not have the m_services_account module loaded, and this is required.";
- Anope::Quitting = true;
- return;
- }
- if (!Servers::Capab.count("HIDECHANS"))
- {
- UplinkSocket::Message() << "ERROR :m_hidechans.so is not loaded. This is required by Anope";
- Anope::QuitReason = "ERROR: Remote server does not have the m_hidechans module loaded, and this is required.";
- Anope::Quitting = true;
- return;
- }
- if (!IRCD->CanSVSHold)
- Log() << "SVSHOLD missing, Usage disabled until module is loaded.";
- if (!Servers::Capab.count("CHGHOST"))
- Log() << "CHGHOST missing, Usage disabled until module is loaded.";
- if (!Servers::Capab.count("CHGIDENT"))
- Log() << "CHGIDENT missing, Usage disabled until module is loaded.";
- }
-
- Message::Capab::Run(source, params);
- }
-};
-
-struct IRCDMessageChgIdent : IRCDMessage
-{
- IRCDMessageChgIdent(Module *creator) : IRCDMessage(creator, "CHGIDENT", 2) { }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- User *u = User::Find(params[0]);
- if (u)
- u->SetIdent(params[1]);
- }
-};
-
-struct IRCDMessageChgName : IRCDMessage
-{
- IRCDMessageChgName(Module *creator, const Anope::string &n) : IRCDMessage(creator, n, 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- source.GetUser()->SetRealname(params[0]);
- }
-};
-
-struct IRCDMessageEncap : IRCDMessage
-{
- IRCDMessageEncap(Module *creator) : IRCDMessage(creator, "ENCAP", 4) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- if (!Anope::Match(Me->GetSID(), params[0]) && !Anope::Match(Me->GetName(), params[0]))
- return;
-
- if (SASL::sasl && params[1] == "SASL" && params.size() >= 6)
- {
- SASL::Message m;
- m.source = params[2];
- m.target = params[3];
- m.type = params[4];
- m.data = params[5];
- m.ext = params.size() > 6 ? params[6] : "";
-
- SASL::sasl->ProcessMessage(m);
- }
- }
-};
-
-struct IRCDMessageEndburst : IRCDMessage
-{
- IRCDMessageEndburst(Module *creator) : IRCDMessage(creator, "ENDBURST", 0) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- Server *s = source.GetServer();
-
- Log(LOG_DEBUG) << "Processed ENDBURST for " << s->GetName();
-
- s->Sync(true);
- }
-};
-
-struct IRCDMessageFHost : IRCDMessage
-{
- IRCDMessageFHost(Module *creator, const Anope::string &n) : IRCDMessage(creator, n, 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- source.GetUser()->SetDisplayedHost(params[0]);
- }
-};
-
-struct IRCDMessageFJoin : IRCDMessage
-{
- IRCDMessageFJoin(Module *creator) : IRCDMessage(creator, "FJOIN", 2) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- Anope::string modes;
- if (params.size() >= 3)
- {
- for (unsigned i = 2; i < params.size() - 1; ++i)
- modes += " " + params[i];
- if (!modes.empty())
- modes.erase(modes.begin());
- }
-
- std::list<Message::Join::SJoinUser> users;
-
- spacesepstream sep(params[params.size() - 1]);
- Anope::string buf;
- while (sep.GetToken(buf))
- {
- Message::Join::SJoinUser sju;
-
- /* Loop through prefixes and find modes for them */
- for (char c; (c = buf[0]) != ',' && c;)
- {
- buf.erase(buf.begin());
- sju.first.AddMode(c);
- }
- /* Erase the , */
- if (!buf.empty())
- buf.erase(buf.begin());
-
- sju.second = User::Find(buf);
- if (!sju.second)
- {
- Log(LOG_DEBUG) << "FJOIN for nonexistent user " << buf << " on " << params[0];
- continue;
- }
-
- users.push_back(sju);
- }
-
- time_t ts = Anope::string(params[1]).is_pos_number_only() ? convertTo<time_t>(params[1]) : Anope::CurTime;
- Message::Join::SJoin(source, params[0], ts, modes, users);
- }
-};
-
-struct IRCDMessageFMode : IRCDMessage
-{
- IRCDMessageFMode(Module *creator) : IRCDMessage(creator, "FMODE", 3) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- /* :source FMODE #test 12345678 +nto foo */
-
- Anope::string modes = params[2];
- for (unsigned n = 3; n < params.size(); ++n)
- modes += " " + params[n];
-
- Channel *c = Channel::Find(params[0]);
- time_t ts;
-
- try
- {
- ts = convertTo<time_t>(params[1]);
- }
- catch (const ConvertException &)
- {
- ts = 0;
- }
-
- if (c)
- c->SetModesInternal(source, modes, ts);
- }
-};
-
-struct IRCDMessageFTopic : IRCDMessage
-{
- IRCDMessageFTopic(Module *creator) : IRCDMessage(creator, "FTOPIC", 4) { }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- /* :source FTOPIC channel topicts setby :topic */
-
- Channel *c = Channel::Find(params[0]);
- if (c)
- c->ChangeTopicInternal(NULL, params[2], params[3], Anope::string(params[1]).is_pos_number_only() ? convertTo<time_t>(params[1]) : Anope::CurTime);
- }
-};
-
-struct IRCDMessageIdle : IRCDMessage
-{
- IRCDMessageIdle(Module *creator) : IRCDMessage(creator, "IDLE", 1) { }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- BotInfo *bi = BotInfo::Find(params[0]);
- if (bi)
- UplinkSocket::Message(bi) << "IDLE " << source.GetSource() << " " << Anope::StartTime << " " << (Anope::CurTime - bi->lastmsg);
- else
- {
- User *u = User::Find(params[0]);
- if (u && u->server == Me)
- UplinkSocket::Message(u) << "IDLE " << source.GetSource() << " " << Anope::StartTime << " 0";
- }
- }
-};
-
-/*
- * source = numeric of the sending server
- * params[0] = uuid
- * params[1] = metadata name
- * params[2] = data
- */
-struct IRCDMessageMetadata : IRCDMessage
-{
- IRCDMessageMetadata(Module *creator) : IRCDMessage(creator, "METADATA", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- if (isdigit(params[0][0]))
- {
- if (params[1].equals_cs("accountname"))
- {
- User *u = User::Find(params[0]);
- NickCore *nc = NickCore::Find(params[2]);
- if (u && nc)
- u->Login(nc);
- }
-
- /*
- * possible incoming ssl_cert messages:
- * Received: :409 METADATA 409AAAAAA ssl_cert :vTrSe c38070ce96e41cc144ed6590a68d45a6 <...> <...>
- * Received: :409 METADATA 409AAAAAC ssl_cert :vTrSE Could not get peer certificate: error:00000000:lib(0):func(0):reason(0)
- */
- else if (params[1].equals_cs("ssl_cert"))
- {
- User *u = User::Find(params[0]);
- if (!u)
- return;
- u->Extend<bool>("ssl");
- Anope::string data = params[2].c_str();
- size_t pos1 = data.find(' ') + 1;
- size_t pos2 = data.find(' ', pos1);
- if ((pos2 - pos1) >= 32) // inspircd supports md5 and sha1 fingerprint hashes -> size 32 or 40 bytes.
- {
- u->fingerprint = data.substr(pos1, pos2 - pos1);
- }
- FOREACH_MOD(OnFingerprint, (u));
- }
- }
- else if (params[0][0] == '#')
- {
- }
- else if (params[0] == "*")
- {
- // Wed Oct 3 15:40:27 2012: S[14] O :20D METADATA * modules :-m_svstopic.so
-
- if (params[1].equals_cs("modules") && !params[2].empty())
- {
- // only interested when it comes from our uplink
- Server* server = source.GetServer();
- if (!server || server->GetUplink() != Me)
- return;
-
- bool plus = (params[2][0] == '+');
- if (!plus && params[2][0] != '-')
- return;
-
- bool required = false;
- Anope::string capab, module = params[2].substr(1);
-
- if (module.equals_cs("m_services_account.so"))
- required = true;
- else if (module.equals_cs("m_hidechans.so"))
- required = true;
- else if (module.equals_cs("m_chghost.so"))
- capab = "CHGHOST";
- else if (module.equals_cs("m_chgident.so"))
- capab = "CHGIDENT";
- else if (module.equals_cs("m_svshold.so"))
- capab = "SVSHOLD";
- else if (module.equals_cs("m_rline.so"))
- capab = "RLINE";
- else if (module.equals_cs("m_topiclock.so"))
- capab = "TOPICLOCK";
- else
- return;
-
- if (required)
- {
- if (!plus)
- Log() << "Warning: InspIRCd unloaded module " << module << ", Anope won't function correctly without it";
- }
- else
- {
- if (plus)
- Servers::Capab.insert(capab);
- else
- Servers::Capab.erase(capab);
-
- Log() << "InspIRCd " << (plus ? "loaded" : "unloaded") << " module " << module << ", adjusted functionality";
- }
-
- }
- }
- }
-};
-
-struct IRCDMessageMode : IRCDMessage
-{
- IRCDMessageMode(Module *creator) : IRCDMessage(creator, "MODE", 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- if (IRCD->IsChannelValid(params[0]))
- {
- Channel *c = Channel::Find(params[0]);
-
- Anope::string modes = params[1];
- for (unsigned n = 2; n < params.size(); ++n)
- modes += " " + params[n];
-
- if (c)
- c->SetModesInternal(source, modes);
- }
- else
- {
- /* InspIRCd lets opers change another
- users modes, we have to kludge this
- as it slightly breaks RFC1459
- */
- User *u = User::Find(params[0]);
- if (u)
- u->SetModesInternal(source, "%s", params[1].c_str());
- }
- }
-};
-
-struct IRCDMessageNick : IRCDMessage
-{
- IRCDMessageNick(Module *creator) : IRCDMessage(creator, "NICK", 2) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- source.GetUser()->ChangeNick(params[0]);
- }
-};
-
-struct IRCDMessageOperType : IRCDMessage
-{
- IRCDMessageOperType(Module *creator) : IRCDMessage(creator, "OPERTYPE", 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); SetFlag(IRCDMESSAGE_REQUIRE_USER); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- /* opertype is equivalent to mode +o because servers
- don't do this directly */
- User *u = source.GetUser();
- if (!u->HasMode("OPER"))
- u->SetModesInternal(source, "+o");
- }
-};
-
-struct IRCDMessageRSQuit : IRCDMessage
-{
- IRCDMessageRSQuit(Module *creator) : IRCDMessage(creator, "RSQUIT", 1) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- Server *s = Server::Find(params[0]);
- const Anope::string &reason = params.size() > 1 ? params[1] : "";
- if (!s)
- return;
-
- UplinkSocket::Message(Me) << "SQUIT " << s->GetSID() << " :" << reason;
- s->Delete(s->GetName() + " " + s->GetUplink()->GetName());
- }
-};
-
-struct IRCDMessageSetIdent : IRCDMessage
-{
- IRCDMessageSetIdent(Module *creator) : IRCDMessage(creator, "SETIDENT", 0) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- source.GetUser()->SetIdent(params[0]);
- }
-};
-
-struct IRCDMessageServer : IRCDMessage
-{
- IRCDMessageServer(Module *creator) : IRCDMessage(creator, "SERVER", 5) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
-
- /*
- * [Nov 04 00:08:46.308435 2009] debug: Received: SERVER irc.inspircd.com pass 0 964 :Testnet Central!
- * 0: name
- * 1: pass
- * 2: hops
- * 3: numeric
- * 4: desc
- */
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- unsigned int hops = Anope::string(params[2]).is_pos_number_only() ? convertTo<unsigned>(params[2]) : 0;
- new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], hops, params[4], params[3]);
- }
-};
-
-struct IRCDMessageSQuit : Message::SQuit
-{
- IRCDMessageSQuit(Module *creator) : Message::SQuit(creator) { }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- if (params[0] == rsquit_id || params[0] == rsquit_server)
- {
- /* squit for a recently squit server, introduce the juped server now */
- Server *s = Server::Find(rsquit_server);
-
- rsquit_id.clear();
- rsquit_server.clear();
-
- if (s && s->IsJuped())
- IRCD->SendServer(s);
- }
- else
- Message::SQuit::Run(source, params);
- }
-};
-
-struct IRCDMessageTime : IRCDMessage
-{
- IRCDMessageTime(Module *creator) : IRCDMessage(creator, "TIME", 2) { }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- UplinkSocket::Message(Me) << "TIME " << source.GetSource() << " " << params[1] << " " << Anope::CurTime;
- }
-};
-
-struct IRCDMessageUID : IRCDMessage
-{
- IRCDMessageUID(Module *creator) : IRCDMessage(creator, "UID", 8) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
-
- /*
- * [Nov 03 22:09:58.176252 2009] debug: Received: :964 UID 964AAAAAC 1225746297 w00t2 localhost testnet.user w00t 127.0.0.1 1225746302 +iosw +ACGJKLNOQcdfgjklnoqtx :Robin Burchell <w00t@inspircd.org>
- * 0: uid
- * 1: ts
- * 2: nick
- * 3: host
- * 4: dhost
- * 5: ident
- * 6: ip
- * 7: signon
- * 8+: modes and params -- IMPORTANT, some modes (e.g. +s) may have parameters. So don't assume a fixed position of realname!
- * last: realname
- */
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- time_t ts = convertTo<time_t>(params[1]);
-
- Anope::string modes = params[8];
- for (unsigned i = 9; i < params.size() - 1; ++i)
- modes += " " + params[i];
-
- NickAlias *na = NULL;
- if (SASL::sasl)
- for (std::list<SASLUser>::iterator it = saslusers.begin(); it != saslusers.end();)
- {
- SASLUser &u = *it;
-
- if (u.created + 30 < Anope::CurTime)
- it = saslusers.erase(it);
- else if (u.uid == params[0])
- {
- na = NickAlias::Find(u.acc);
- it = saslusers.erase(it);
- }
- else
- ++it;
- }
-
- User *u = User::OnIntroduce(params[2], params[5], params[3], params[4], params[6], source.GetServer(), params[params.size() - 1], ts, modes, params[0], na ? *na->nc : NULL);
- if (u)
- u->signon = convertTo<time_t>(params[7]);
- }
-};
-
-class ProtoInspIRCd12 : public Module
-{
- InspIRCd12Proto ircd_proto;
- ExtensibleItem<bool> ssl;
-
- /* Core message handlers */
- Message::Away message_away;
- Message::Error message_error;
- Message::Invite message_invite;
- Message::Join message_join;
- Message::Kick message_kick;
- Message::Kill message_kill;
- Message::MOTD message_motd;
- Message::Notice message_notice;
- Message::Part message_part;
- Message::Ping message_ping;
- Message::Privmsg message_privmsg;
- Message::Quit message_quit;
- Message::Stats message_stats;
- Message::Topic message_topic;
-
- /* Our message handlers */
- IRCDMessageChgIdent message_chgident;
- IRCDMessageChgName message_setname, message_chgname;
- IRCDMessageCapab message_capab;
- IRCDMessageEncap message_encap;
- IRCDMessageEndburst message_endburst;
- IRCDMessageFHost message_fhost, message_sethost;
- IRCDMessageFJoin message_fjoin;
- IRCDMessageFMode message_fmode;
- IRCDMessageFTopic message_ftopic;
- IRCDMessageIdle message_idle;
- IRCDMessageMetadata message_metadata;
- IRCDMessageMode message_mode;
- IRCDMessageNick message_nick;
- IRCDMessageOperType message_opertype;
- IRCDMessageRSQuit message_rsquit;
- IRCDMessageSetIdent message_setident;
- IRCDMessageServer message_server;
- IRCDMessageSQuit message_squit;
- IRCDMessageTime message_time;
- IRCDMessageUID message_uid;
-
- public:
- ProtoInspIRCd12(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL | VENDOR),
- ircd_proto(this), ssl(this, "ssl"),
- message_away(this), message_error(this), message_invite(this), message_join(this), message_kick(this), message_kill(this),
- message_motd(this), message_notice(this), message_part(this), message_ping(this), message_privmsg(this), message_quit(this),
- message_stats(this), message_topic(this),
-
- message_chgident(this), message_setname(this, "SETNAME"), message_chgname(this, "FNAME"), message_capab(this), message_encap(this),
- message_endburst(this),
- message_fhost(this, "FHOST"), message_sethost(this, "SETHOST"), message_fjoin(this), message_fmode(this), message_ftopic(this),
- message_idle(this), message_metadata(this), message_mode(this), message_nick(this), message_opertype(this), message_rsquit(this),
- message_setident(this), message_server(this), message_squit(this), message_time(this), message_uid(this)
- {
- Servers::Capab.insert("NOQUIT");
- }
-
- void OnUserNickChange(User *u, const Anope::string &) anope_override
- {
- /* InspIRCd 1.2 doesn't set -r on nick change, remove -r here. Note that if we have to set +r later
- * this will cancel out this -r, resulting in no mode changes.
- *
- * Do not set -r if we don't have a NickServ loaded - DP
- */
- BotInfo *NickServ = Config->GetClient("NickServ");
- if (NickServ)
- u->RemoveMode(NickServ, "REGISTERED");
- }
-};
-
-MODULE_INIT(ProtoInspIRCd12)
diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp
deleted file mode 100644
index 59fd276aa..000000000
--- a/modules/protocol/inspircd20.cpp
+++ /dev/null
@@ -1,1106 +0,0 @@
-/* InspIRCd 2.0 functions
- *
- * (C) 2003-2023 Anope Team
- * Contact us at team@anope.org
- *
- * Please read COPYING and README for further details.
- *
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
- */
-
-#include "module.h"
-#include "modules/cs_mode.h"
-
-static unsigned int spanningtree_proto_ver = 0;
-
-static ServiceReference<IRCDProto> insp12("IRCDProto", "inspircd12");
-
-class InspIRCd20Proto : public IRCDProto
-{
- public:
- InspIRCd20Proto(Module *creator) : IRCDProto(creator, "InspIRCd 2.0")
- {
- DefaultPseudoclientModes = "+I";
- CanSVSNick = true;
- CanSVSJoin = true;
- CanSetVHost = true;
- CanSetVIdent = true;
- CanSQLine = true;
- CanSZLine = true;
- CanSVSHold = true;
- CanCertFP = true;
- RequiresID = true;
- MaxModes = 20;
- }
-
- void SendConnect() anope_override
- {
- UplinkSocket::Message() << "CAPAB START 1202";
- UplinkSocket::Message() << "CAPAB CAPABILITIES :PROTOCOL=1202";
- UplinkSocket::Message() << "CAPAB END";
- insp12->SendConnect();
- }
-
- void SendSASLMechanisms(std::vector<Anope::string> &mechanisms) anope_override
- {
- Anope::string mechlist;
- for (unsigned i = 0; i < mechanisms.size(); ++i)
- mechlist += "," + mechanisms[i];
-
- UplinkSocket::Message(Me) << "METADATA * saslmechlist :" << (mechanisms.empty() ? "" : mechlist.substr(1));
- }
-
- void SendSVSKillInternal(const MessageSource &source, User *user, const Anope::string &buf) anope_override { insp12->SendSVSKillInternal(source, user, buf); }
- void SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { insp12->SendGlobalNotice(bi, dest, msg); }
- void SendGlobalPrivmsg(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { insp12->SendGlobalPrivmsg(bi, dest, msg); }
- void SendAkillDel(const XLine *x) anope_override { insp12->SendAkillDel(x); }
- void SendTopic(const MessageSource &whosets, Channel *c) anope_override { insp12->SendTopic(whosets, c); };
- void SendVhostDel(User *u) anope_override { insp12->SendVhostDel(u); }
- void SendAkill(User *u, XLine *x) anope_override { insp12->SendAkill(u, x); }
- void SendNumericInternal(int numeric, const Anope::string &dest, const Anope::string &buf) anope_override { insp12->SendNumericInternal(numeric, dest, buf); }
- void SendModeInternal(const MessageSource &source, const Channel *dest, const Anope::string &buf) anope_override { insp12->SendModeInternal(source, dest, buf); }
- void SendClientIntroduction(User *u) anope_override { insp12->SendClientIntroduction(u); }
- void SendServer(const Server *server) anope_override { insp12->SendServer(server); }
- void SendSquit(Server *s, const Anope::string &message) anope_override { insp12->SendSquit(s, message); }
- void SendJoin(User *user, Channel *c, const ChannelStatus *status) anope_override { insp12->SendJoin(user, c, status); }
- void SendSQLineDel(const XLine *x) anope_override { insp12->SendSQLineDel(x); }
- void SendSQLine(User *u, const XLine *x) anope_override { insp12->SendSQLine(u, x); }
- void SendVhost(User *u, const Anope::string &vident, const Anope::string &vhost) anope_override { insp12->SendVhost(u, vident, vhost); }
- void SendSVSHold(const Anope::string &nick, time_t t) anope_override { insp12->SendSVSHold(nick, t); }
- void SendSVSHoldDel(const Anope::string &nick) anope_override { insp12->SendSVSHoldDel(nick); }
- void SendSZLineDel(const XLine *x) anope_override { insp12->SendSZLineDel(x); }
- void SendSZLine(User *u, const XLine *x) anope_override { insp12->SendSZLine(u, x); }
- void SendSVSJoin(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string &other) anope_override { insp12->SendSVSJoin(source, u, chan, other); }
- void SendSVSPart(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string &param) anope_override { insp12->SendSVSPart(source, u, chan, param); }
- void SendSWhois(const MessageSource &bi, const Anope::string &who, const Anope::string &mask) anope_override { insp12->SendSWhois(bi, who, mask); }
- void SendBOB() anope_override { insp12->SendBOB(); }
- void SendEOB() anope_override { insp12->SendEOB(); }
- void SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) { insp12->SendGlobopsInternal(source, buf); }
- void SendLogin(User *u, NickAlias *na) anope_override { insp12->SendLogin(u, na); }
- void SendLogout(User *u) anope_override { insp12->SendLogout(u); }
- void SendChannel(Channel *c) anope_override { insp12->SendChannel(c); }
- void SendSASLMessage(const SASL::Message &message) anope_override { insp12->SendSASLMessage(message); }
- void SendSVSLogin(const Anope::string &uid, const Anope::string &acc, const Anope::string &vident, const Anope::string &vhost) anope_override { insp12->SendSVSLogin(uid, acc, vident, vhost); }
- bool IsExtbanValid(const Anope::string &mask) anope_override { return insp12->IsExtbanValid(mask); }
- bool IsIdentValid(const Anope::string &ident) anope_override { return insp12->IsIdentValid(ident); }
-};
-
-class InspIRCdAutoOpMode : public ChannelModeList
-{
- public:
- InspIRCdAutoOpMode(char mode) : ChannelModeList("AUTOOP", mode)
- {
- }
-
- bool IsValid(Anope::string &mask) const anope_override
- {
- // We can not validate this because we don't know about the
- // privileges of the setter so just reject attempts to set it.
- return false;
- }
-};
-
-class InspIRCdExtBan : public ChannelModeVirtual<ChannelModeList>
-{
- char ext;
-
- public:
- InspIRCdExtBan(const Anope::string &mname, const Anope::string &basename, char extban) : ChannelModeVirtual<ChannelModeList>(mname, basename)
- , ext(extban)
- {
- }
-
- ChannelMode *Wrap(Anope::string &param) anope_override
- {
- param = Anope::string(ext) + ":" + param;
- return ChannelModeVirtual<ChannelModeList>::Wrap(param);
- }
-
- ChannelMode *Unwrap(ChannelMode *cm, Anope::string &param) anope_override
- {
- if (cm->type != MODE_LIST || param.length() < 3 || param[0] != ext || param[1] != ':')
- return cm;
-
- param = param.substr(2);
- return this;
- }
-};
-
-namespace InspIRCdExtban
-{
- class EntryMatcher : public InspIRCdExtBan
- {
- public:
- EntryMatcher(const Anope::string &mname, const Anope::string &mbase, char c) : InspIRCdExtBan(mname, mbase, c)
- {
- }
-
- bool Matches(User *u, const Entry *e) anope_override
- {
- const Anope::string &mask = e->GetMask();
- Anope::string real_mask = mask.substr(3);
-
- return Entry(this->name, real_mask).Matches(u);
- }
- };
-
- class ChannelMatcher : public InspIRCdExtBan
- {
- public:
- ChannelMatcher(const Anope::string &mname, const Anope::string &mbase, char c) : InspIRCdExtBan(mname, mbase, c)
- {
- }
-
- bool Matches(User *u, const Entry *e) anope_override
- {
- const Anope::string &mask = e->GetMask();
-
- Anope::string channel = mask.substr(3);
-
- ChannelMode *cm = NULL;
- if (channel[0] != '#')
- {
- char modeChar = ModeManager::GetStatusChar(channel[0]);
- channel.erase(channel.begin());
- cm = ModeManager::FindChannelModeByChar(modeChar);
- if (cm != NULL && cm->type != MODE_STATUS)
- cm = NULL;
- }
-
- Channel *c = Channel::Find(channel);
- if (c != NULL)
- {
- ChanUserContainer *uc = c->FindUser(u);
- if (uc != NULL)
- if (cm == NULL || uc->status.HasMode(cm->mchar))
- return true;
- }
-
- return false;
- }
- };
-
- class AccountMatcher : public InspIRCdExtBan
- {
- public:
- AccountMatcher(const Anope::string &mname, const Anope::string &mbase, char c) : InspIRCdExtBan(mname, mbase, c)
- {
- }
-
- bool Matches(User *u, const Entry *e) anope_override
- {
- const Anope::string &mask = e->GetMask();
- Anope::string real_mask = mask.substr(2);
-
- return u->IsIdentified() && real_mask.equals_ci(u->Account()->display);
- }
- };
-
- class RealnameMatcher : public InspIRCdExtBan
- {
- public:
- RealnameMatcher(const Anope::string &mname, const Anope::string &mbase, char c) : InspIRCdExtBan(mname, mbase, c)
- {
- }
-
- bool Matches(User *u, const Entry *e) anope_override
- {
- const Anope::string &mask = e->GetMask();
- Anope::string real_mask = mask.substr(2);
- return Anope::Match(u->realname, real_mask);
- }
- };
-
- class ServerMatcher : public InspIRCdExtBan
- {
- public:
- ServerMatcher(const Anope::string &mname, const Anope::string &mbase, char c) : InspIRCdExtBan(mname, mbase, c)
- {
- }
-
- bool Matches(User *u, const Entry *e) anope_override
- {
- const Anope::string &mask = e->GetMask();
- Anope::string real_mask = mask.substr(2);
- return Anope::Match(u->server->GetName(), real_mask);
- }
- };
-
- class FingerprintMatcher : public InspIRCdExtBan
- {
- public:
- FingerprintMatcher(const Anope::string &mname, const Anope::string &mbase, char c) : InspIRCdExtBan(mname, mbase, c)
- {
- }
-
- bool Matches(User *u, const Entry *e) anope_override
- {
- const Anope::string &mask = e->GetMask();
- Anope::string real_mask = mask.substr(2);
- return !u->fingerprint.empty() && Anope::Match(u->fingerprint, real_mask);
- }
- };
-
- class UnidentifiedMatcher : public InspIRCdExtBan
- {
- public:
- UnidentifiedMatcher(const Anope::string &mname, const Anope::string &mbase, char c) : InspIRCdExtBan(mname, mbase, c)
- {
- }
-
- bool Matches(User *u, const Entry *e) anope_override
- {
- const Anope::string &mask = e->GetMask();
- Anope::string real_mask = mask.substr(2);
- return !u->Account() && Entry("BAN", real_mask).Matches(u);
- }
- };
-}
-
-class ColonDelimitedParamMode : public ChannelModeParam
-{
- public:
- ColonDelimitedParamMode(const Anope::string &modename, char modeChar) : ChannelModeParam(modename, modeChar, true) { }
-
- bool IsValid(Anope::string &value) const anope_override
- {
- return IsValid(value, false);
- }
-
- bool IsValid(const Anope::string &value, bool historymode) const
- {
- if (value.empty())
- return false; // empty param is never valid
-
- Anope::string::size_type pos = value.find(':');
- if ((pos == Anope::string::npos) || (pos == 0))
- return false; // no ':' or it's the first char, both are invalid
-
- Anope::string rest;
- try
- {
- if (convertTo<int>(value, rest, false) <= 0)
- return false; // negative numbers and zero are invalid
-
- rest = rest.substr(1);
- int n;
- if (historymode)
- {
- // For the history mode, the part after the ':' is a duration and it
- // can be in the user friendly "1d3h20m" format, make sure we accept that
- n = Anope::DoTime(rest);
- }
- else
- n = convertTo<int>(rest);
-
- if (n <= 0)
- return false;
- }
- catch (const ConvertException &e)
- {
- // conversion error, invalid
- return false;
- }
-
- return true;
- }
-};
-
-class SimpleNumberParamMode : public ChannelModeParam
-{
- public:
- SimpleNumberParamMode(const Anope::string &modename, char modeChar) : ChannelModeParam(modename, modeChar, true) { }
-
- bool IsValid(Anope::string &value) const anope_override
- {
- if (value.empty())
- return false; // empty param is never valid
-
- try
- {
- if (convertTo<int>(value) <= 0)
- return false;
- }
- catch (const ConvertException &e)
- {
- // conversion error, invalid
- return false;
- }
-
- return true;
- }
-};
-
-class ChannelModeFlood : public ColonDelimitedParamMode
-{
- public:
- ChannelModeFlood(char modeChar) : ColonDelimitedParamMode("FLOOD", modeChar) { }
-
- bool IsValid(Anope::string &value) const anope_override
- {
- // The parameter of this mode is a bit different, it may begin with a '*',
- // ignore it if that's the case
- Anope::string v = value[0] == '*' ? value.substr(1) : value;
- return ((!value.empty()) && (ColonDelimitedParamMode::IsValid(v)));
- }
-};
-
-class ChannelModeHistory : public ColonDelimitedParamMode
-{
- public:
- ChannelModeHistory(char modeChar) : ColonDelimitedParamMode("HISTORY", modeChar) { }
-
- bool IsValid(Anope::string &value) const anope_override
- {
- return (ColonDelimitedParamMode::IsValid(value, true));
- }
-};
-
-class ChannelModeRedirect : public ChannelModeParam
-{
- public:
- ChannelModeRedirect(char modeChar) : ChannelModeParam("REDIRECT", modeChar, true) { }
-
- bool IsValid(Anope::string &value) const anope_override
- {
- // The parameter of this mode is a channel, and channel names start with '#'
- return ((!value.empty()) && (value[0] == '#'));
- }
-};
-
-struct IRCDMessageAway : Message::Away
-{
- IRCDMessageAway(Module *creator) : Message::Away(creator, "AWAY") { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- std::vector<Anope::string> newparams(params);
- if (newparams.size() > 1)
- newparams.erase(newparams.begin());
-
- Message::Away::Run(source, newparams);
- }
-};
-
-struct IRCDMessageCapab : Message::Capab
-{
- std::map<char, Anope::string> chmodes, umodes;
-
- IRCDMessageCapab(Module *creator) : Message::Capab(creator, "CAPAB") { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- if (params[0].equals_cs("START"))
- {
- if (params.size() >= 2)
- spanningtree_proto_ver = (Anope::string(params[1]).is_pos_number_only() ? convertTo<unsigned>(params[1]) : 0);
-
- if (spanningtree_proto_ver < 1202)
- {
- UplinkSocket::Message() << "ERROR :Protocol mismatch, no or invalid protocol version given in CAPAB START";
- Anope::QuitReason = "Protocol mismatch, no or invalid protocol version given in CAPAB START";
- Anope::Quitting = true;
- return;
- }
-
- /* reset CAPAB */
- chmodes.clear();
- umodes.clear();
- Servers::Capab.insert("SERVERS");
- Servers::Capab.insert("TOPICLOCK");
- IRCD->CanSVSHold = false;
- IRCD->DefaultPseudoclientModes = "+I";
- }
- else if (params[0].equals_cs("CHANMODES") && params.size() > 1)
- {
- spacesepstream ssep(params[1]);
- Anope::string capab;
-
- while (ssep.GetToken(capab))
- {
- Anope::string modename = capab.substr(0, capab.find('='));
- Anope::string modechar = capab.substr(capab.find('=') + 1);
- ChannelMode *cm = NULL;
-
- if (modename.equals_cs("admin"))
- cm = new ChannelModeStatus("PROTECT", modechar.length() > 1 ? modechar[1] : modechar[0], modechar.length() > 1 ? modechar[0] : 0, 3);
- else if (modename.equals_cs("allowinvite"))
- {
- cm = new ChannelMode("ALLINVITE", modechar[0]);
- ModeManager::AddChannelMode(new InspIRCdExtban::EntryMatcher("INVITEBAN", "BAN", 'A'));
- }
- else if (modename.equals_cs("auditorium"))
- cm = new ChannelMode("AUDITORIUM", modechar[0]);
- else if (modename.equals_cs("autoop"))
- cm = new InspIRCdAutoOpMode(modechar[0]);
- else if (modename.equals_cs("ban"))
- cm = new ChannelModeList("BAN", modechar[0]);
- else if (modename.equals_cs("banexception"))
- cm = new ChannelModeList("EXCEPT", modechar[0]);
- else if (modename.equals_cs("blockcaps"))
- {
- cm = new ChannelMode("BLOCKCAPS", modechar[0]);
- ModeManager::AddChannelMode(new InspIRCdExtban::EntryMatcher("BLOCKCAPSBAN", "BAN", 'B'));
- }
- else if (modename.equals_cs("blockcolor"))
- {
- cm = new ChannelMode("BLOCKCOLOR", modechar[0]);
- ModeManager::AddChannelMode(new InspIRCdExtban::EntryMatcher("BLOCKCOLORBAN", "BAN", 'c'));
- }
- else if (modename.equals_cs("c_registered"))
- cm = new ChannelModeNoone("REGISTERED", modechar[0]);
- else if (modename.equals_cs("censor"))
- cm = new ChannelMode("CENSOR", modechar[0]);
- else if (modename.equals_cs("delayjoin"))
- cm = new ChannelMode("DELAYEDJOIN", modechar[0]);
- else if (modename.equals_cs("delaymsg"))
- cm = new SimpleNumberParamMode("DELAYMSG", modechar[0]);
- else if (modename.equals_cs("filter"))
- cm = new ChannelModeList("FILTER", modechar[0]);
- else if (modename.equals_cs("flood"))
- cm = new ChannelModeFlood(modechar[0]);
- else if (modename.equals_cs("founder"))
- cm = new ChannelModeStatus("OWNER", modechar.length() > 1 ? modechar[1] : modechar[0], modechar.length() > 1 ? modechar[0] : 0, 4);
- else if (modename.equals_cs("halfop"))
- cm = new ChannelModeStatus("HALFOP", modechar.length() > 1 ? modechar[1] : modechar[0], modechar.length() > 1 ? modechar[0] : 0, 1);
- else if (modename.equals_cs("history"))
- cm = new ChannelModeHistory(modechar[0]);
- else if (modename.equals_cs("invex"))
- cm = new ChannelModeList("INVITEOVERRIDE", modechar[0]);
- else if (modename.equals_cs("inviteonly"))
- cm = new ChannelMode("INVITE", modechar[0]);
- else if (modename.equals_cs("joinflood"))
- cm = new ColonDelimitedParamMode("JOINFLOOD", modechar[0]);
- else if (modename.equals_cs("key"))
- cm = new ChannelModeKey(modechar[0]);
- else if (modename.equals_cs("kicknorejoin"))
- cm = new SimpleNumberParamMode("NOREJOIN", modechar[0]);
- else if (modename.equals_cs("limit"))
- cm = new ChannelModeParam("LIMIT", modechar[0], true);
- else if (modename.equals_cs("moderated"))
- cm = new ChannelMode("MODERATED", modechar[0]);
- else if (modename.equals_cs("nickflood"))
- cm = new ColonDelimitedParamMode("NICKFLOOD", modechar[0]);
- else if (modename.equals_cs("noctcp"))
- {
- cm = new ChannelMode("NOCTCP", modechar[0]);
- ModeManager::AddChannelMode(new InspIRCdExtban::EntryMatcher("NOCTCPBAN", "BAN", 'C'));
- }
- else if (modename.equals_cs("noextmsg"))
- cm = new ChannelMode("NOEXTERNAL", modechar[0]);
- else if (modename.equals_cs("nokick"))
- {
- cm = new ChannelMode("NOKICK", modechar[0]);
- ModeManager::AddChannelMode(new InspIRCdExtban::EntryMatcher("NOKICKBAN", "BAN", 'Q'));
- }
- else if (modename.equals_cs("noknock"))
- cm = new ChannelMode("NOKNOCK", modechar[0]);
- else if (modename.equals_cs("nonick"))
- {
- cm = new ChannelMode("NONICK", modechar[0]);
- ModeManager::AddChannelMode(new InspIRCdExtban::EntryMatcher("NONICKBAN", "BAN", 'N'));
- }
- else if (modename.equals_cs("nonotice"))
- {
- cm = new ChannelMode("NONOTICE", modechar[0]);
- ModeManager::AddChannelMode(new InspIRCdExtban::EntryMatcher("NONOTICEBAN", "BAN", 'T'));
- }
- else if (modename.equals_cs("official-join"))
- cm = new ChannelModeStatus("OFFICIALJOIN", modechar.length() > 1 ? modechar[1] : modechar[0], modechar.length() > 1 ? modechar[0] : 0, 2);
- else if (modename.equals_cs("op"))
- cm = new ChannelModeStatus("OP", modechar.length() > 1 ? modechar[1] : modechar[0], modechar.length() > 1 ? modechar[0] : 0, 2);
- else if (modename.equals_cs("operonly"))
- cm = new ChannelModeOperOnly("OPERONLY", modechar[0]);
- else if (modename.equals_cs("operprefix"))
- cm = new ChannelModeStatus("OPERPREFIX", modechar.length() > 1 ? modechar[1] : modechar[0], modechar.length() > 1 ? modechar[0] : 0, 2);
- else if (modename.equals_cs("permanent"))
- cm = new ChannelMode("PERM", modechar[0]);
- else if (modename.equals_cs("private"))
- cm = new ChannelMode("PRIVATE", modechar[0]);
- else if (modename.equals_cs("redirect"))
- cm = new ChannelModeRedirect(modechar[0]);
- else if (modename.equals_cs("reginvite"))
- cm = new ChannelMode("REGISTEREDONLY", modechar[0]);
- else if (modename.equals_cs("regmoderated"))
- cm = new ChannelMode("REGMODERATED", modechar[0]);
- else if (modename.equals_cs("secret"))
- cm = new ChannelMode("SECRET", modechar[0]);
- else if (modename.equals_cs("sslonly"))
- {
- cm = new ChannelMode("SSL", modechar[0]);
- ModeManager::AddChannelMode(new InspIRCdExtban::FingerprintMatcher("SSLBAN", "BAN", 'z'));
- }
- else if (modename.equals_cs("stripcolor"))
- {
- cm = new ChannelMode("STRIPCOLOR", modechar[0]);
- ModeManager::AddChannelMode(new InspIRCdExtban::EntryMatcher("STRIPCOLORBAN", "BAN", 'S'));
- }
- else if (modename.equals_cs("topiclock"))
- cm = new ChannelMode("TOPIC", modechar[0]);
- else if (modename.equals_cs("voice"))
- cm = new ChannelModeStatus("VOICE", modechar.length() > 1 ? modechar[1] : modechar[0], modechar.length() > 1 ? modechar[0] : 0, 0);
- /* Unknown status mode, (customprefix) - add it */
- else if (modechar.length() == 2)
- cm = new ChannelModeStatus(modename.upper(), modechar[1], modechar[0], -1);
- /* Unknown non status mode, add it to our list for later */
- else
- chmodes[modechar[0]] = modename.upper();
-
- if (cm)
- ModeManager::AddChannelMode(cm);
- }
- }
- if (params[0].equals_cs("USERMODES") && params.size() > 1)
- {
- spacesepstream ssep(params[1]);
- Anope::string capab;
-
- while (ssep.GetToken(capab))
- {
- Anope::string modename = capab.substr(0, capab.find('='));
- Anope::string modechar = capab.substr(capab.find('=') + 1);
- UserMode *um = NULL;
-
- if (modename.equals_cs("bot"))
- {
- um = new UserMode("BOT", modechar[0]);
- IRCD->DefaultPseudoclientModes += modechar;
- }
- else if (modename.equals_cs("callerid"))
- um = new UserMode("CALLERID", modechar[0]);
- else if (modename.equals_cs("cloak"))
- um = new UserMode("CLOAK", modechar[0]);
- else if (modename.equals_cs("deaf"))
- um = new UserMode("DEAF", modechar[0]);
- else if (modename.equals_cs("deaf_commonchan"))
- um = new UserMode("COMMONCHANS", modechar[0]);
- else if (modename.equals_cs("helpop"))
- um = new UserModeOperOnly("HELPOP", modechar[0]);
- else if (modename.equals_cs("hidechans"))
- um = new UserMode("PRIV", modechar[0]);
- else if (modename.equals_cs("hideoper"))
- um = new UserModeOperOnly("HIDEOPER", modechar[0]);
- else if (modename.equals_cs("invisible"))
- um = new UserMode("INVIS", modechar[0]);
- else if (modename.equals_cs("invis-oper"))
- um = new UserModeOperOnly("INVISIBLE_OPER", modechar[0]);
- else if (modename.equals_cs("oper"))
- um = new UserModeOperOnly("OPER", modechar[0]);
- else if (modename.equals_cs("regdeaf"))
- um = new UserMode("REGPRIV", modechar[0]);
- else if (modename.equals_cs("servprotect"))
- {
- um = new UserModeNoone("PROTECTED", modechar[0]);
- IRCD->DefaultPseudoclientModes += modechar;
- }
- else if (modename.equals_cs("showwhois"))
- um = new UserMode("WHOIS", modechar[0]);
- else if (modename.equals_cs("u_censor"))
- um = new UserMode("CENSOR", modechar[0]);
- else if (modename.equals_cs("u_registered"))
- um = new UserModeNoone("REGISTERED", modechar[0]);
- else if (modename.equals_cs("u_stripcolor"))
- um = new UserMode("STRIPCOLOR", modechar[0]);
- else if (modename.equals_cs("wallops"))
- um = new UserMode("WALLOPS", modechar[0]);
- else
- umodes[modechar[0]] = modename.upper();
-
- if (um)
- ModeManager::AddUserMode(um);
- }
- }
- else if (params[0].equals_cs("MODULES") && params.size() > 1)
- {
- spacesepstream ssep(params[1]);
- Anope::string module;
-
- while (ssep.GetToken(module))
- {
- if (module.equals_cs("m_svshold.so"))
- IRCD->CanSVSHold = true;
- else if (module.find("m_rline.so") == 0)
- {
- Servers::Capab.insert("RLINE");
- const Anope::string &regexengine = Config->GetBlock("options")->Get<const Anope::string>("regexengine");
- if (!regexengine.empty() && module.length() > 11 && regexengine != module.substr(11))
- Log() << "Warning: InspIRCd is using regex engine " << module.substr(11) << ", but we have " << regexengine << ". This may cause inconsistencies.";
- }
- else if (module.equals_cs("m_topiclock.so"))
- Servers::Capab.insert("TOPICLOCK");
- }
- }
- else if (params[0].equals_cs("MODSUPPORT") && params.size() > 1)
- {
- spacesepstream ssep(params[1]);
- Anope::string module;
-
- while (ssep.GetToken(module))
- {
- if (module.equals_cs("m_services_account.so"))
- {
- Servers::Capab.insert("SERVICES");
- ModeManager::AddChannelMode(new InspIRCdExtban::AccountMatcher("ACCOUNTBAN", "BAN", 'R'));
- ModeManager::AddChannelMode(new InspIRCdExtban::UnidentifiedMatcher("UNREGISTEREDBAN", "BAN", 'U'));
- }
- else if (module.equals_cs("m_chghost.so"))
- Servers::Capab.insert("CHGHOST");
- else if (module.equals_cs("m_chgident.so"))
- Servers::Capab.insert("CHGIDENT");
- else if (module == "m_channelban.so")
- ModeManager::AddChannelMode(new InspIRCdExtban::ChannelMatcher("CHANNELBAN", "BAN", 'j'));
- else if (module == "m_gecosban.so")
- ModeManager::AddChannelMode(new InspIRCdExtban::RealnameMatcher("REALNAMEBAN", "BAN", 'r'));
- else if (module == "m_nopartmsg.so")
- ModeManager::AddChannelMode(new InspIRCdExtban::EntryMatcher("PARTMESSAGEBAN", "BAN", 'p'));
- else if (module == "m_serverban.so")
- ModeManager::AddChannelMode(new InspIRCdExtban::ServerMatcher("SERVERBAN", "BAN", 's'));
- else if (module == "m_muteban.so")
- ModeManager::AddChannelMode(new InspIRCdExtban::EntryMatcher("QUIET", "BAN", 'm'));
- }
- }
- else if (params[0].equals_cs("CAPABILITIES") && params.size() > 1)
- {
- spacesepstream ssep(params[1]);
- Anope::string capab;
- while (ssep.GetToken(capab))
- {
- if (capab.find("CHANMODES") != Anope::string::npos)
- {
- Anope::string modes(capab.begin() + 10, capab.end());
- commasepstream sep(modes, true);
- Anope::string modebuf;
-
- sep.GetToken(modebuf);
- for (size_t t = 0, end = modebuf.length(); t < end; ++t)
- {
- if (ModeManager::FindChannelModeByChar(modebuf[t]))
- continue;
- ModeManager::AddChannelMode(new ChannelModeList(chmodes[modebuf[t]], modebuf[t]));
- }
-
- sep.GetToken(modebuf);
- for (size_t t = 0, end = modebuf.length(); t < end; ++t)
- {
- if (ModeManager::FindChannelModeByChar(modebuf[t]))
- continue;
- ModeManager::AddChannelMode(new ChannelModeParam(chmodes[modebuf[t]], modebuf[t]));
- }
-
- sep.GetToken(modebuf);
- for (size_t t = 0, end = modebuf.length(); t < end; ++t)
- {
- if (ModeManager::FindChannelModeByChar(modebuf[t]))
- continue;
- ModeManager::AddChannelMode(new ChannelModeParam(chmodes[modebuf[t]], modebuf[t], true));
- }
-
- sep.GetToken(modebuf);
- for (size_t t = 0, end = modebuf.length(); t < end; ++t)
- {
- if (ModeManager::FindChannelModeByChar(modebuf[t]))
- continue;
- ModeManager::AddChannelMode(new ChannelMode(chmodes[modebuf[t]], modebuf[t]));
- }
- }
- else if (capab.find("USERMODES") != Anope::string::npos)
- {
- Anope::string modes(capab.begin() + 10, capab.end());
- commasepstream sep(modes, true);
- Anope::string modebuf;
-
- sep.GetToken(modebuf);
- sep.GetToken(modebuf);
-
- if (sep.GetToken(modebuf))
- for (size_t t = 0, end = modebuf.length(); t < end; ++t)
- ModeManager::AddUserMode(new UserModeParam(umodes[modebuf[t]], modebuf[t]));
-
- if (sep.GetToken(modebuf))
- for (size_t t = 0, end = modebuf.length(); t < end; ++t)
- ModeManager::AddUserMode(new UserMode(umodes[modebuf[t]], modebuf[t]));
- }
- else if (capab.find("MAXMODES=") != Anope::string::npos)
- {
- Anope::string maxmodes(capab.begin() + 9, capab.end());
- IRCD->MaxModes = maxmodes.is_pos_number_only() ? convertTo<unsigned>(maxmodes) : 3;
- }
- else if (capab.find("PREFIX=") != Anope::string::npos)
- {
- Anope::string modes(capab.begin() + 8, capab.begin() + capab.find(')'));
- Anope::string chars(capab.begin() + capab.find(')') + 1, capab.end());
- short level = modes.length() - 1;
-
- for (size_t t = 0, end = modes.length(); t < end; ++t)
- {
- ChannelMode *cm = ModeManager::FindChannelModeByChar(modes[t]);
- if (cm == NULL || cm->type != MODE_STATUS)
- {
- Log() << "CAPAB PREFIX gave unknown channel status mode " << modes[t];
- continue;
- }
-
- ChannelModeStatus *cms = anope_dynamic_static_cast<ChannelModeStatus *>(cm);
- cms->level = level--;
-
- Log(LOG_DEBUG) << cms->name << " is now level " << cms->level;
- }
-
- ModeManager::RebuildStatusModes();
- }
- else if (capab == "GLOBOPS=1")
- Servers::Capab.insert("GLOBOPS");
- }
- }
- else if (params[0].equals_cs("END"))
- {
- if (!Servers::Capab.count("SERVICES"))
- {
- UplinkSocket::Message() << "ERROR :m_services_account.so is not loaded. This is required by Anope";
- Anope::QuitReason = "ERROR: Remote server does not have the m_services_account module loaded, and this is required.";
- Anope::Quitting = true;
- return;
- }
- if (!ModeManager::FindUserModeByName("PRIV"))
- {
- UplinkSocket::Message() << "ERROR :m_hidechans.so is not loaded. This is required by Anope";
- Anope::QuitReason = "ERROR: Remote server does not have the m_hidechans module loaded, and this is required.";
- Anope::Quitting = true;
- return;
- }
- if (!IRCD->CanSVSHold)
- Log() << "SVSHOLD missing, Usage disabled until module is loaded.";
- if (!Servers::Capab.count("CHGHOST"))
- Log() << "CHGHOST missing, Usage disabled until module is loaded.";
- if (!Servers::Capab.count("CHGIDENT"))
- Log() << "CHGIDENT missing, Usage disabled until module is loaded.";
-
- chmodes.clear();
- umodes.clear();
- }
-
- Message::Capab::Run(source, params);
- }
-};
-
-struct IRCDMessageEncap : IRCDMessage
-{
- ServiceReference<IRCDMessage> insp12_encap;
-
- IRCDMessageEncap(Module *creator) : IRCDMessage(creator, "ENCAP", 4), insp12_encap("IRCDMessage", "inspircd12/encap") { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- if (!Anope::Match(Me->GetSID(), params[0]) && !Anope::Match(Me->GetName(), params[0]))
- return;
-
- if (params[1] == "CHGIDENT")
- {
- User *u = User::Find(params[2]);
- if (!u || u->server != Me)
- return;
-
- u->SetIdent(params[3]);
- UplinkSocket::Message(u) << "FIDENT :" << params[3];
- }
- else if (params[1] == "CHGHOST")
- {
- User *u = User::Find(params[2]);
- if (!u || u->server != Me)
- return;
-
- u->SetDisplayedHost(params[3]);
- UplinkSocket::Message(u) << "FHOST :" << params[3];
- }
- else if (params[1] == "CHGNAME")
- {
- User *u = User::Find(params[2]);
- if (!u || u->server != Me)
- return;
-
- u->SetRealname(params[3]);
- UplinkSocket::Message(u) << "FNAME :" << params[3];
- }
-
- if (insp12_encap)
- insp12_encap->Run(source, params);
- }
-};
-
-struct IRCDMessageFHost : IRCDMessage
-{
- IRCDMessageFHost(Module *creator) : IRCDMessage(creator, "FHOST", 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- User *u = source.GetUser();
- if (u->HasMode("CLOAK"))
- u->RemoveModeInternal(source, ModeManager::FindUserModeByName("CLOAK"));
- u->SetDisplayedHost(params[0]);
- }
-};
-
-struct IRCDMessageFIdent : IRCDMessage
-{
- IRCDMessageFIdent(Module *creator) : IRCDMessage(creator, "FIDENT", 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- source.GetUser()->SetIdent(params[0]);
- }
-};
-
-struct IRCDMessageSave : IRCDMessage
-{
- time_t last_collide;
-
- IRCDMessageSave(Module *creator) : IRCDMessage(creator, "SAVE", 2), last_collide(0) { }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- User *targ = User::Find(params[0]);
- time_t ts;
-
- try
- {
- ts = convertTo<time_t>(params[1]);
- }
- catch (const ConvertException &)
- {
- return;
- }
-
- if (!targ || targ->timestamp != ts)
- return;
-
- BotInfo *bi;
- if (targ->server == Me && (bi = dynamic_cast<BotInfo *>(targ)))
- {
- if (last_collide == Anope::CurTime)
- {
- Anope::QuitReason = "Nick collision fight on " + targ->nick;
- Anope::Quitting = true;
- return;
- }
-
- IRCD->SendKill(Me, targ->nick, "Nick collision");
- IRCD->SendNickChange(targ, targ->nick);
- last_collide = Anope::CurTime;
- }
- else
- targ->ChangeNick(targ->GetUID());
- }
-};
-
-class IRCDMessageMetadata : IRCDMessage
-{
- ServiceReference<IRCDMessage> insp12_metadata;
- const bool &do_topiclock;
- const bool &do_mlock;
-
- public:
- IRCDMessageMetadata(Module *creator, const bool &handle_topiclock, const bool &handle_mlock) : IRCDMessage(creator, "METADATA", 3), insp12_metadata("IRCDMessage", "inspircd12/metadata"), do_topiclock(handle_topiclock), do_mlock(handle_mlock) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- // We deliberately ignore non-bursting servers to avoid pseudoserver fights
- if ((params[0][0] == '#') && (!source.GetServer()->IsSynced()))
- {
- Channel *c = Channel::Find(params[0]);
- if (c && c->ci)
- {
- if ((do_mlock) && (params[1] == "mlock"))
- {
- ModeLocks *modelocks = c->ci->GetExt<ModeLocks>("modelocks");
- Anope::string modes;
- if (modelocks)
- modes = modelocks->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "");
-
- // Mode lock string is not what we say it is?
- if (modes != params[2])
- UplinkSocket::Message(Me) << "METADATA " << c->name << " mlock :" << modes;
- }
- else if ((do_topiclock) && (params[1] == "topiclock"))
- {
- bool mystate = c->ci->HasExt("TOPICLOCK");
- bool serverstate = (params[2] == "1");
- if (mystate != serverstate)
- UplinkSocket::Message(Me) << "METADATA " << c->name << " topiclock :" << (mystate ? "1" : "");
- }
- }
- }
-
- if (insp12_metadata)
- insp12_metadata->Run(source, params);
- }
-};
-
-class ProtoInspIRCd20 : public Module
-{
- Module *m_insp12;
-
- InspIRCd20Proto ircd_proto;
-
- /* Core message handlers */
- Message::Error message_error;
- Message::Invite message_invite;
- Message::Join message_join;
- Message::Kick message_kick;
- Message::Kill message_kill;
- Message::MOTD message_motd;
- Message::Notice message_notice;
- Message::Part message_part;
- Message::Ping message_ping;
- Message::Privmsg message_privmsg;
- Message::Quit message_quit;
- Message::Stats message_stats;
- Message::Topic message_topic;
-
- /* InspIRCd 1.2 message handlers */
- ServiceAlias message_endburst, message_fjoin, message_fmode,
- message_ftopic, message_idle, message_mode,
- message_nick, message_opertype, message_rsquit, message_server,
- message_squit, message_time, message_uid;
-
- /* Our message handlers */
- IRCDMessageAway message_away;
- IRCDMessageCapab message_capab;
- IRCDMessageEncap message_encap;
- IRCDMessageFHost message_fhost;
- IRCDMessageFIdent message_fident;
- IRCDMessageMetadata message_metadata;
- IRCDMessageSave message_save;
-
- bool use_server_side_topiclock, use_server_side_mlock;
-
- void SendChannelMetadata(Channel *c, const Anope::string &metadataname, const Anope::string &value)
- {
- UplinkSocket::Message(Me) << "METADATA " << c->name << " " << metadataname << " :" << value;
- }
-
- public:
- ProtoInspIRCd20(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL | VENDOR),
- ircd_proto(this),
- message_error(this), message_invite(this), message_join(this), message_kick(this), message_kill(this),
- message_motd(this), message_notice(this), message_part(this), message_ping(this), message_privmsg(this),
- message_quit(this), message_stats(this), message_topic(this),
-
- message_endburst("IRCDMessage", "inspircd20/endburst", "inspircd12/endburst"),
- message_fjoin("IRCDMessage", "inspircd20/fjoin", "inspircd12/fjoin"),
- message_fmode("IRCDMessage", "inspircd20/fmode", "inspircd12/fmode"),
- message_ftopic("IRCDMessage", "inspircd20/ftopic", "inspircd12/ftopic"),
- message_idle("IRCDMessage", "inspircd20/idle", "inspircd12/idle"),
- message_mode("IRCDMessage", "inspircd20/mode", "inspircd12/mode"),
- message_nick("IRCDMessage", "inspircd20/nick", "inspircd12/nick"),
- message_opertype("IRCDMessage", "inspircd20/opertype", "inspircd12/opertype"),
- message_rsquit("IRCDMessage", "inspircd20/rsquit", "inspircd12/rsquit"),
- message_server("IRCDMessage", "inspircd20/server", "inspircd12/server"),
- message_squit("IRCDMessage", "inspircd20/squit", "inspircd12/squit"),
- message_time("IRCDMessage", "inspircd20/time", "inspircd12/time"),
- message_uid("IRCDMessage", "inspircd20/uid", "inspircd12/uid"),
-
- message_away(this), message_capab(this), message_encap(this), message_fhost(this), message_fident(this),
- message_metadata(this, use_server_side_topiclock, use_server_side_mlock), message_save(this)
- {
-
- if (ModuleManager::LoadModule("inspircd12", User::Find(creator)) != MOD_ERR_OK)
- throw ModuleException("Unable to load inspircd12");
- m_insp12 = ModuleManager::FindModule("inspircd12");
- if (!m_insp12)
- throw ModuleException("Unable to find inspircd12");
- if (!insp12)
- throw ModuleException("No protocol interface for insp12");
- ModuleManager::DetachAll(m_insp12);
-
- }
-
- ~ProtoInspIRCd20()
- {
- m_insp12 = ModuleManager::FindModule("inspircd12");
- ModuleManager::UnloadModule(m_insp12, NULL);
- }
-
- void OnReload(Configuration::Conf *conf) anope_override
- {
- use_server_side_topiclock = conf->GetModule(this)->Get<bool>("use_server_side_topiclock");
- use_server_side_mlock = conf->GetModule(this)->Get<bool>("use_server_side_mlock");
- }
-
- void OnUserNickChange(User *u, const Anope::string &) anope_override
- {
- u->RemoveModeInternal(Me, ModeManager::FindUserModeByName("REGISTERED"));
- }
-
- void OnChannelSync(Channel *c) anope_override
- {
- if (c->ci)
- this->OnChanRegistered(c->ci);
- }
-
- void OnChanRegistered(ChannelInfo *ci) anope_override
- {
- ModeLocks *modelocks = ci->GetExt<ModeLocks>("modelocks");
- if (use_server_side_mlock && ci->c && modelocks && !modelocks->GetMLockAsString(false).empty())
- {
- Anope::string modes = modelocks->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "");
- SendChannelMetadata(ci->c, "mlock", modes);
- }
-
- if (use_server_side_topiclock && Servers::Capab.count("TOPICLOCK") && ci->c)
- {
- if (ci->HasExt("TOPICLOCK"))
- SendChannelMetadata(ci->c, "topiclock", "1");
- }
- }
-
- void OnDelChan(ChannelInfo *ci) anope_override
- {
- if (use_server_side_mlock && ci->c)
- SendChannelMetadata(ci->c, "mlock", "");
-
- if (use_server_side_topiclock && Servers::Capab.count("TOPICLOCK") && ci->c)
- SendChannelMetadata(ci->c, "topiclock", "");
- }
-
- EventReturn OnMLock(ChannelInfo *ci, ModeLock *lock) anope_override
- {
- ModeLocks *modelocks = ci->GetExt<ModeLocks>("modelocks");
- ChannelMode *cm = ModeManager::FindChannelModeByName(lock->name);
- if (use_server_side_mlock && cm && ci->c && modelocks && (cm->type == MODE_REGULAR || cm->type == MODE_PARAM))
- {
- Anope::string modes = modelocks->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "") + cm->mchar;
- SendChannelMetadata(ci->c, "mlock", modes);
- }
-
- return EVENT_CONTINUE;
- }
-
- EventReturn OnUnMLock(ChannelInfo *ci, ModeLock *lock) anope_override
- {
- ModeLocks *modelocks = ci->GetExt<ModeLocks>("modelocks");
- ChannelMode *cm = ModeManager::FindChannelModeByName(lock->name);
- if (use_server_side_mlock && cm && ci->c && modelocks && (cm->type == MODE_REGULAR || cm->type == MODE_PARAM))
- {
- Anope::string modes = modelocks->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "").replace_all_cs(cm->mchar, "");
- SendChannelMetadata(ci->c, "mlock", modes);
- }
-
- return EVENT_CONTINUE;
- }
-
- EventReturn OnSetChannelOption(CommandSource &source, Command *cmd, ChannelInfo *ci, const Anope::string &setting) anope_override
- {
- if (cmd->name == "chanserv/topic" && ci->c)
- {
- if (setting == "topiclock on")
- SendChannelMetadata(ci->c, "topiclock", "1");
- else if (setting == "topiclock off")
- SendChannelMetadata(ci->c, "topiclock", "0");
- }
-
- return EVENT_CONTINUE;
- }
-};
-
-MODULE_INIT(ProtoInspIRCd20)
diff --git a/modules/protocol/ngircd.cpp b/modules/protocol/ngircd.cpp
index a59749a9c..7b2fc908e 100644
--- a/modules/protocol/ngircd.cpp
+++ b/modules/protocol/ngircd.cpp
@@ -13,7 +13,7 @@
class ngIRCdProto : public IRCDProto
{
- void SendSVSKillInternal(const MessageSource &source, User *user, const Anope::string &buf) anope_override
+ void SendSVSKillInternal(const MessageSource &source, User *user, const Anope::string &buf) override
{
IRCDProto::SendSVSKillInternal(source, user, buf);
user->KillInternal(source, buf);
@@ -30,7 +30,7 @@ class ngIRCdProto : public IRCDProto
MaxModes = 5;
}
- void SendAkill(User *u, XLine *x) anope_override
+ void SendAkill(User *u, XLine *x) override
{
// Calculate the time left before this would expire, capping it at 2 days
time_t timeleft = x->expires - Anope::CurTime;
@@ -39,24 +39,24 @@ class ngIRCdProto : public IRCDProto
UplinkSocket::Message(Me) << "GLINE " << x->mask << " " << timeleft << " :" << x->GetReason() << " (" << x->by << ")";
}
- void SendAkillDel(const XLine *x) anope_override
+ void SendAkillDel(const XLine *x) override
{
UplinkSocket::Message(Me) << "GLINE " << x->mask;
}
- void SendChannel(Channel *c) anope_override
+ void SendChannel(Channel *c) override
{
UplinkSocket::Message(Me) << "CHANINFO " << c->name << " +" << c->GetModes(true, true);
}
// Received: :dev.anope.de NICK DukeP 1 ~DukePyro p57ABF9C9.dip.t-dialin.net 1 +i :DukePyrolator
- void SendClientIntroduction(User *u) anope_override
+ void SendClientIntroduction(User *u) override
{
Anope::string modes = "+" + u->GetModes();
UplinkSocket::Message(Me) << "NICK " << u->nick << " 1 " << u->GetIdent() << " " << u->host << " 1 " << modes << " :" << u->realname;
}
- void SendConnect() anope_override
+ void SendConnect() override
{
UplinkSocket::Message() << "PASS " << Config->Uplinks[Anope::CurrentUplink].password << " 0210-IRC+ Anope|" << Anope::VersionShort() << ":CLHMSo P";
/* Make myself known to myself in the serverlist */
@@ -65,27 +65,27 @@ class ngIRCdProto : public IRCDProto
this->SendNumeric(376, "*", ":End of MOTD command");
}
- void SendForceNickChange(User *u, const Anope::string &newnick, time_t when) anope_override
+ void SendForceNickChange(User *u, const Anope::string &newnick, time_t when) override
{
UplinkSocket::Message(Me) << "SVSNICK " << u->nick << " " << newnick;
}
- void SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override
+ void SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg) override
{
UplinkSocket::Message(bi) << "NOTICE $" << dest->GetName() << " :" << msg;
}
- void SendGlobalPrivmsg(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override
+ void SendGlobalPrivmsg(BotInfo *bi, const Server *dest, const Anope::string &msg) override
{
UplinkSocket::Message(bi) << "PRIVMSG $" << dest->GetName() << " :" << msg;
}
- void SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) anope_override
+ void SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) override
{
UplinkSocket::Message(source) << "WALLOPS :" << buf;
}
- void SendJoin(User *user, Channel *c, const ChannelStatus *status) anope_override
+ void SendJoin(User *user, Channel *c, const ChannelStatus *status) override
{
UplinkSocket::Message(user) << "JOIN " << c->name;
if (status)
@@ -100,31 +100,31 @@ class ngIRCdProto : public IRCDProto
uc->status.Clear();
BotInfo *setter = BotInfo::Find(user->GetUID());
- for (size_t i = 0; i < cs.Modes().length(); ++i)
- c->SetMode(setter, ModeManager::FindChannelModeByChar(cs.Modes()[i]), user->GetUID(), false);
+ for (auto mode : cs.Modes())
+ c->SetMode(setter, ModeManager::FindChannelModeByChar(mode), user->GetUID(), false);
if (uc != NULL)
uc->status = cs;
}
}
- void SendLogin(User *u, NickAlias *na) anope_override
+ void SendLogin(User *u, NickAlias *na) override
{
UplinkSocket::Message(Me) << "METADATA " << u->GetUID() << " accountname :" << na->nc->display;
}
- void SendLogout(User *u) anope_override
+ void SendLogout(User *u) override
{
UplinkSocket::Message(Me) << "METADATA " << u->GetUID() << " accountname :";
}
/* SERVER name hop descript */
- void SendServer(const Server *server) anope_override
+ void SendServer(const Server *server) override
{
UplinkSocket::Message() << "SERVER " << server->GetName() << " " << server->GetHops() << " :" << server->GetDescription();
}
- void SendVhost(User *u, const Anope::string &vIdent, const Anope::string &vhost) anope_override
+ void SendVhost(User *u, const Anope::string &vIdent, const Anope::string &vhost) override
{
if (!vIdent.empty())
UplinkSocket::Message(Me) << "METADATA " << u->nick << " user :" << vIdent;
@@ -137,12 +137,12 @@ class ngIRCdProto : public IRCDProto
}
}
- void SendVhostDel(User *u) anope_override
+ void SendVhostDel(User *u) override
{
this->SendVhost(u, u->GetIdent(), "");
}
- Anope::string Format(const Anope::string &source, const Anope::string &message) anope_override
+ Anope::string Format(const Anope::string &source, const Anope::string &message) override
{
return IRCDProto::Format(source.empty() ? Me->GetSID() : source, message);
}
@@ -153,17 +153,17 @@ struct IRCDMessage005 : IRCDMessage
IRCDMessage005(Module *creator) : IRCDMessage(creator, "005", 1) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
// Please see <http://www.irc.org/tech_docs/005.html> for details.
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
size_t pos;
Anope::string parameter, data;
- for (unsigned i = 0, end = params.size(); i < end; ++i)
+ for (const auto &param : params)
{
- pos = params[i].find('=');
+ pos = param.find('=');
if (pos != Anope::string::npos)
{
- parameter = params[i].substr(0, pos);
- data = params[i].substr(pos+1, params[i].length());
+ parameter = param.substr(0, pos);
+ data = param.substr(pos+1, param.length());
if (parameter == "MODES")
{
unsigned maxmodes = convertTo<unsigned>(data);
@@ -194,7 +194,7 @@ struct IRCDMessage376 : IRCDMessage
*
*/
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
}
};
@@ -220,7 +220,7 @@ struct IRCDMessageChaninfo : IRCDMessage
* a channel has no user limit (the parameter <modes> doesn't list the "l"
* channel mode). In this case <limit> should be "0".
*/
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
bool created;
Channel *c = Channel::FindOrCreate(params[0], created);
@@ -262,7 +262,7 @@ struct IRCDMessageJoin : Message::Join
*
* if a user joins a new channel, the ircd sends <channelname>\7<umode>
*/
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
User *user = source.GetUser();
size_t pos = params[0].find('\7');
@@ -281,7 +281,7 @@ struct IRCDMessageJoin : Message::Join
std::vector<Anope::string> new_params;
new_params.push_back(channel);
- Message::Join::Run(source, new_params);
+ Message::Join::Run(source, new_params, tags);
if (!modes.empty())
{
@@ -312,7 +312,7 @@ struct IRCDMessageMetadata : IRCDMessage
* - "user": the user name (ident) of a client (can't be empty)
*/
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
User *u = User::Find(params[0]);
if (!u)
@@ -363,7 +363,7 @@ struct IRCDMessageMode : IRCDMessage
* params[n] = parameters
*/
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
Anope::string modes = params[1];
@@ -410,7 +410,7 @@ struct IRCDMessageNick : IRCDMessage
* params[0] = newnick
*
*/
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
if (params.size() == 1)
{
@@ -454,7 +454,7 @@ struct IRCDMessageNJoin : IRCDMessage
*
* Received: :dev.anope.de NJOIN #test :DukeP2,@DukeP,%test,+test2
*/
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
std::list<Message::Join::SJoinUser> users;
@@ -494,7 +494,7 @@ struct IRCDMessagePong : IRCDMessage
* when receiving a new server and then finish sync once we
* get a pong back from that server.
*/
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
if (!source.GetServer()->IsSynced())
source.GetServer()->Sync(false);
@@ -530,7 +530,7 @@ struct IRCDMessageServer : IRCDMessage
* params[3] = server description
*/
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
if (params.size() == 3)
{
@@ -557,7 +557,7 @@ struct IRCDMessageTopic : IRCDMessage
IRCDMessageTopic(Module *creator) : IRCDMessage(creator, "TOPIC", 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
// Received: :DukeP TOPIC #anope :test
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
Channel *c = Channel::Find(params[0]);
if (!c)
@@ -670,7 +670,7 @@ class ProtongIRCd : public Module
}
- void OnUserNickChange(User *u, const Anope::string &) anope_override
+ void OnUserNickChange(User *u, const Anope::string &) override
{
u->RemoveMode(Config->GetClient("NickServ"), "REGISTERED");
}
diff --git a/modules/protocol/plexus.cpp b/modules/protocol/plexus.cpp
index 572d0691f..679915b9d 100644
--- a/modules/protocol/plexus.cpp
+++ b/modules/protocol/plexus.cpp
@@ -35,26 +35,26 @@ class PlexusProto : public IRCDProto
MaxModes = 4;
}
- void SendSVSKillInternal(const MessageSource &source, User *targ, const Anope::string &reason) anope_override { hybrid->SendSVSKillInternal(source, targ, reason); }
- void SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { hybrid->SendGlobalNotice(bi, dest, msg); }
- void SendGlobalPrivmsg(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { hybrid->SendGlobalPrivmsg(bi, dest, msg); }
- void SendSQLine(User *u, const XLine *x) anope_override { hybrid->SendSQLine(u, x); }
- void SendSQLineDel(const XLine *x) anope_override { hybrid->SendSQLineDel(x); }
- void SendSGLineDel(const XLine *x) anope_override { hybrid->SendSGLineDel(x); }
- void SendSGLine(User *u, const XLine *x) anope_override { hybrid->SendSGLine(u, x); }
- void SendAkillDel(const XLine *x) anope_override { hybrid->SendAkillDel(x); }
- void SendAkill(User *u, XLine *x) anope_override { hybrid->SendAkill(u, x); }
- void SendServer(const Server *server) anope_override { hybrid->SendServer(server); }
- void SendChannel(Channel *c) anope_override { hybrid->SendChannel(c); }
- void SendSVSHold(const Anope::string &nick, time_t t) anope_override { hybrid->SendSVSHold(nick, t); }
- void SendSVSHoldDel(const Anope::string &nick) anope_override { hybrid->SendSVSHoldDel(nick); }
-
- void SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) anope_override
+ void SendSVSKillInternal(const MessageSource &source, User *targ, const Anope::string &reason) override { hybrid->SendSVSKillInternal(source, targ, reason); }
+ void SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg) override { hybrid->SendGlobalNotice(bi, dest, msg); }
+ void SendGlobalPrivmsg(BotInfo *bi, const Server *dest, const Anope::string &msg) override { hybrid->SendGlobalPrivmsg(bi, dest, msg); }
+ void SendSQLine(User *u, const XLine *x) override { hybrid->SendSQLine(u, x); }
+ void SendSQLineDel(const XLine *x) override { hybrid->SendSQLineDel(x); }
+ void SendSGLineDel(const XLine *x) override { hybrid->SendSGLineDel(x); }
+ void SendSGLine(User *u, const XLine *x) override { hybrid->SendSGLine(u, x); }
+ void SendAkillDel(const XLine *x) override { hybrid->SendAkillDel(x); }
+ void SendAkill(User *u, XLine *x) override { hybrid->SendAkill(u, x); }
+ void SendServer(const Server *server) override { hybrid->SendServer(server); }
+ void SendChannel(Channel *c) override { hybrid->SendChannel(c); }
+ void SendSVSHold(const Anope::string &nick, time_t t) override { hybrid->SendSVSHold(nick, t); }
+ void SendSVSHoldDel(const Anope::string &nick) override { hybrid->SendSVSHoldDel(nick); }
+
+ void SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) override
{
UplinkSocket::Message(source) << "OPERWALL :" << buf;
}
- void SendJoin(User *user, Channel *c, const ChannelStatus *status) anope_override
+ void SendJoin(User *user, Channel *c, const ChannelStatus *status) override
{
UplinkSocket::Message(Me) << "SJOIN " << c->creation_time << " " << c->name << " +" << c->GetModes(true, true) << " :" << user->GetUID();
if (status)
@@ -69,20 +69,20 @@ class PlexusProto : public IRCDProto
uc->status.Clear();
BotInfo *setter = BotInfo::Find(user->GetUID());
- for (size_t i = 0; i < cs.Modes().length(); ++i)
- c->SetMode(setter, ModeManager::FindChannelModeByChar(cs.Modes()[i]), user->GetUID(), false);
+ for (auto mode : cs.Modes())
+ c->SetMode(setter, ModeManager::FindChannelModeByChar(mode), user->GetUID(), false);
if (uc != NULL)
uc->status = cs;
}
}
- void SendForceNickChange(User *u, const Anope::string &newnick, time_t when) anope_override
+ void SendForceNickChange(User *u, const Anope::string &newnick, time_t when) override
{
UplinkSocket::Message(Me) << "ENCAP " << u->server->GetName() << " SVSNICK " << u->GetUID() << " " << u->timestamp << " " << newnick << " " << when;
}
- void SendVhost(User *u, const Anope::string &ident, const Anope::string &host) anope_override
+ void SendVhost(User *u, const Anope::string &ident, const Anope::string &host) override
{
if (!ident.empty())
UplinkSocket::Message(Me) << "ENCAP * CHGIDENT " << u->GetUID() << " " << ident;
@@ -90,12 +90,12 @@ class PlexusProto : public IRCDProto
u->SetMode(Config->GetClient("HostServ"), "CLOAK");
}
- void SendVhostDel(User *u) anope_override
+ void SendVhostDel(User *u) override
{
u->RemoveMode(Config->GetClient("HostServ"), "CLOAK");
}
- void SendConnect() anope_override
+ void SendConnect() override
{
UplinkSocket::Message() << "PASS " << Config->Uplinks[Anope::CurrentUplink].password << " TS 6 :" << Me->GetSID();
/* CAPAB
@@ -132,56 +132,56 @@ class PlexusProto : public IRCDProto
UplinkSocket::Message() << "SVINFO 6 5 0 :" << Anope::CurTime;
}
- void SendClientIntroduction(User *u) anope_override
+ void SendClientIntroduction(User *u) override
{
Anope::string modes = "+" + u->GetModes();
UplinkSocket::Message(Me) << "UID " << u->nick << " 1 " << u->timestamp << " " << modes << " " << u->GetIdent() << " " << u->host << " 255.255.255.255 " << u->GetUID() << " 0 " << u->host << " :" << u->realname;
}
- void SendModeInternal(const MessageSource &source, User *u, const Anope::string &buf) anope_override
+ void SendModeInternal(const MessageSource &source, User *u, const Anope::string &buf) override
{
UplinkSocket::Message(source) << "ENCAP * SVSMODE " << u->GetUID() << " " << u->timestamp << " " << buf;
}
- void SendLogin(User *u, NickAlias *na) anope_override
+ void SendLogin(User *u, NickAlias *na) override
{
UplinkSocket::Message(Me) << "ENCAP * SU " << u->GetUID() << " " << na->nc->display;
}
- void SendLogout(User *u) anope_override
+ void SendLogout(User *u) override
{
UplinkSocket::Message(Me) << "ENCAP * SU " << u->GetUID();
}
- void SendTopic(const MessageSource &source, Channel *c) anope_override
+ void SendTopic(const MessageSource &source, Channel *c) override
{
UplinkSocket::Message(source) << "ENCAP * TOPIC " << c->name << " " << c->topic_setter << " " << c->topic_ts << " :" << c->topic;
}
- void SendSVSJoin(const MessageSource &source, User *user, const Anope::string &chan, const Anope::string &param) anope_override
+ void SendSVSJoin(const MessageSource &source, User *user, const Anope::string &chan, const Anope::string &param) override
{
UplinkSocket::Message(source) << "ENCAP " << user->server->GetName() << " SVSJOIN " << user->GetUID() << " " << chan;
}
- void SendSVSPart(const MessageSource &source, User *user, const Anope::string &chan, const Anope::string &param) anope_override
+ void SendSVSPart(const MessageSource &source, User *user, const Anope::string &chan, const Anope::string &param) override
{
UplinkSocket::Message(source) << "ENCAP " << user->server->GetName() << " SVSPART " << user->GetUID() << " " << chan;
}
- void SendSASLMessage(const SASL::Message &message) anope_override
+ void SendSASLMessage(const SASL::Message &message) override
{
Server *s = Server::Find(message.target.substr(0, 3));
UplinkSocket::Message(Me) << "ENCAP " << (s ? s->GetName() : message.target.substr(0, 3)) << " SASL " << message.source << " " << message.target << " " << message.type << " " << message.data << (message.ext.empty() ? "" : (" " + message.ext));
}
- void SendSVSLogin(const Anope::string &uid, const Anope::string &acc, const Anope::string &vident, const Anope::string &vhost) anope_override
+ void SendSVSLogin(const Anope::string &uid, NickAlias *na) override
{
Server *s = Server::Find(uid.substr(0, 3));
UplinkSocket::Message(Me) << "ENCAP " << (s ? s->GetName() : uid.substr(0, 3)) << " SVSLOGIN " << uid << " * * "
- << (vhost.empty() ? "*" : vhost) << " " << acc;
+ << (na->GetVhostHost().empty() ? "*" : na->GetVhostHost()) << " " << na->nc->display;
}
- void SendSVSNOOP(const Server *server, bool set) anope_override
+ void SendSVSNOOP(const Server *server, bool set) override
{
UplinkSocket::Message() << "ENCAP " << server->GetName() << " SVSNOOP " << (set ? "+" : "-");
}
@@ -191,7 +191,7 @@ struct IRCDMessageEncap : IRCDMessage
{
IRCDMessageEncap(Module *creator) : IRCDMessage(creator, "ENCAP", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
/*
* Received: :dev.anope.de ENCAP * SU DukePyrolator DukePyrolator
@@ -247,7 +247,7 @@ struct IRCDMessagePass : IRCDMessage
{
IRCDMessagePass(Module *creator) : IRCDMessage(creator, "PASS", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
UplinkSID = params[3];
}
@@ -259,7 +259,7 @@ struct IRCDMessageServer : IRCDMessage
/* 0 1 2 */
/* SERVER hades.arpa 1 :ircd-hybrid test server */
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
/* Servers other than our immediate uplink are introduced via SID */
if (params[1] != "1")
@@ -287,7 +287,7 @@ struct IRCDMessageUID : IRCDMessage
params[10] = info
*/
// :42X UID Adam 1 1348535644 +aow Adam 192.168.0.5 192.168.0.5 42XAAAAAB 0 192.168.0.5 :Adam
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
/* An IP of 0 means the user is spoofed */
Anope::string ip = params[6];
@@ -441,7 +441,7 @@ class ProtoPlexus : public Module
this->AddModes();
}
- ~ProtoPlexus()
+ ~ProtoPlexus() override
{
m_hybrid = ModuleManager::FindModule("hybrid");
ModuleManager::UnloadModule(m_hybrid, NULL);
diff --git a/modules/protocol/ratbox.cpp b/modules/protocol/ratbox.cpp
index cdc5d78d4..1324fa057 100644
--- a/modules/protocol/ratbox.cpp
+++ b/modules/protocol/ratbox.cpp
@@ -24,9 +24,9 @@ class RatboxProto : public IRCDProto
if (bi && bi->introduced)
return bi;
- for (botinfo_map::iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it)
- if (it->second->introduced)
- return it->second;
+ for (const auto &[_, bi] : *BotListByNick)
+ if (bi->introduced)
+ return bi;
return NULL;
}
@@ -43,25 +43,25 @@ class RatboxProto : public IRCDProto
MaxModes = 4;
}
- void SendSVSKillInternal(const MessageSource &source, User *targ, const Anope::string &reason) anope_override { hybrid->SendSVSKillInternal(source, targ, reason); }
- void SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { hybrid->SendGlobalNotice(bi, dest, msg); }
- void SendGlobalPrivmsg(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { hybrid->SendGlobalPrivmsg(bi, dest, msg); }
- void SendSGLine(User *u, const XLine *x) anope_override { hybrid->SendSGLine(u, x); }
- void SendSGLineDel(const XLine *x) anope_override { hybrid->SendSGLineDel(x); }
- void SendAkill(User *u, XLine *x) anope_override { hybrid->SendAkill(u, x); }
- void SendAkillDel(const XLine *x) anope_override { hybrid->SendAkillDel(x); }
- void SendJoin(User *user, Channel *c, const ChannelStatus *status) anope_override { hybrid->SendJoin(user, c, status); }
- void SendServer(const Server *server) anope_override { hybrid->SendServer(server); }
- void SendModeInternal(const MessageSource &source, User *u, const Anope::string &buf) anope_override { hybrid->SendModeInternal(source, u, buf); }
- void SendChannel(Channel *c) anope_override { hybrid->SendChannel(c); }
- bool IsIdentValid(const Anope::string &ident) anope_override { return hybrid->IsIdentValid(ident); }
-
- void SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) anope_override
+ void SendSVSKillInternal(const MessageSource &source, User *targ, const Anope::string &reason) override { hybrid->SendSVSKillInternal(source, targ, reason); }
+ void SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg) override { hybrid->SendGlobalNotice(bi, dest, msg); }
+ void SendGlobalPrivmsg(BotInfo *bi, const Server *dest, const Anope::string &msg) override { hybrid->SendGlobalPrivmsg(bi, dest, msg); }
+ void SendSGLine(User *u, const XLine *x) override { hybrid->SendSGLine(u, x); }
+ void SendSGLineDel(const XLine *x) override { hybrid->SendSGLineDel(x); }
+ void SendAkill(User *u, XLine *x) override { hybrid->SendAkill(u, x); }
+ void SendAkillDel(const XLine *x) override { hybrid->SendAkillDel(x); }
+ void SendJoin(User *user, Channel *c, const ChannelStatus *status) override { hybrid->SendJoin(user, c, status); }
+ void SendServer(const Server *server) override { hybrid->SendServer(server); }
+ void SendModeInternal(const MessageSource &source, User *u, const Anope::string &buf) override { hybrid->SendModeInternal(source, u, buf); }
+ void SendChannel(Channel *c) override { hybrid->SendChannel(c); }
+ bool IsIdentValid(const Anope::string &ident) override { return hybrid->IsIdentValid(ident); }
+
+ void SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) override
{
UplinkSocket::Message(source) << "OPERWALL :" << buf;
}
- void SendSQLine(User *, const XLine *x) anope_override
+ void SendSQLine(User *, const XLine *x) override
{
/* Calculate the time left before this would expire, capping it at 2 days */
time_t timeleft = x->expires - Anope::CurTime;
@@ -72,12 +72,12 @@ class RatboxProto : public IRCDProto
UplinkSocket::Message(FindIntroduced()) << "ENCAP * RESV " << timeleft << " " << x->mask << " 0 :" << x->GetReason();
}
- void SendSQLineDel(const XLine *x) anope_override
+ void SendSQLineDel(const XLine *x) override
{
UplinkSocket::Message(Config->GetClient("OperServ")) << "ENCAP * UNRESV " << x->mask;
}
- void SendConnect() anope_override
+ void SendConnect() override
{
UplinkSocket::Message() << "PASS " << Config->Uplinks[Anope::CurrentUplink].password << " TS 6 :" << Me->GetSID();
/*
@@ -104,13 +104,13 @@ class RatboxProto : public IRCDProto
UplinkSocket::Message() << "SVINFO 6 3 0 :" << Anope::CurTime;
}
- void SendClientIntroduction(User *u) anope_override
+ void SendClientIntroduction(User *u) override
{
Anope::string modes = "+" + u->GetModes();
UplinkSocket::Message(Me) << "UID " << u->nick << " 1 " << u->timestamp << " " << modes << " " << u->GetIdent() << " " << u->host << " 0 " << u->GetUID() << " :" << u->realname;
}
- void SendLogin(User *u, NickAlias *na) anope_override
+ void SendLogin(User *u, NickAlias *na) override
{
if (na->nc->HasExt("UNCONFIRMED"))
return;
@@ -118,12 +118,12 @@ class RatboxProto : public IRCDProto
UplinkSocket::Message(Me) << "ENCAP * SU " << u->GetUID() << " " << na->nc->display;
}
- void SendLogout(User *u) anope_override
+ void SendLogout(User *u) override
{
UplinkSocket::Message(Me) << "ENCAP * SU " << u->GetUID();
}
- void SendTopic(const MessageSource &source, Channel *c) anope_override
+ void SendTopic(const MessageSource &source, Channel *c) override
{
BotInfo *bi = source.GetBot();
bool needjoin = c->FindUser(bi) == NULL;
@@ -148,7 +148,7 @@ struct IRCDMessageEncap : IRCDMessage
IRCDMessageEncap(Module *creator) : IRCDMessage(creator, "ENCAP", 3) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
// Debug: Received: :00BAAAAAB ENCAP * LOGIN Adam
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
if (params[1] == "LOGIN" || params[1] == "SU")
{
@@ -172,10 +172,10 @@ struct IRCDMessageJoin : Message::Join
{
IRCDMessageJoin(Module *creator) : Message::Join(creator, "JOIN") { }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
if (params.size() == 1 && params[0] == "0")
- return Message::Join::Run(source, params);
+ return Message::Join::Run(source, params, tags);
if (params.size() < 2)
return;
@@ -183,7 +183,7 @@ struct IRCDMessageJoin : Message::Join
std::vector<Anope::string> p = params;
p.erase(p.begin());
- return Message::Join::Run(source, p);
+ return Message::Join::Run(source, p, tags);
}
};
@@ -191,7 +191,7 @@ struct IRCDMessagePass : IRCDMessage
{
IRCDMessagePass(Module *creator) : IRCDMessage(creator, "PASS", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
UplinkSID = params[3];
}
@@ -202,7 +202,7 @@ struct IRCDMessageServer : IRCDMessage
IRCDMessageServer(Module *creator) : IRCDMessage(creator, "SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
// SERVER hades.arpa 1 :ircd-ratbox test server
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
// Servers other then our immediate uplink are introduced via SID
if (params[1] != "1")
@@ -222,7 +222,7 @@ struct IRCDMessageTBurst : IRCDMessage
* params[2] = topic OR who set the topic
* params[3] = topic if params[2] isn't the topic
*/
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
time_t topic_time = Anope::string(params[1]).is_pos_number_only() ? convertTo<time_t>(params[1]) : Anope::CurTime;
Channel *c = Channel::Find(params[0]);
@@ -242,7 +242,7 @@ struct IRCDMessageUID : IRCDMessage
IRCDMessageUID(Module *creator) : IRCDMessage(creator, "UID", 9) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
// :42X UID Adam 1 1348535644 +aow Adam 192.168.0.5 192.168.0.5 42XAAAAAB :Adam
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
/* Source is always the server */
User::OnIntroduce(params[0], params[4], params[5], "", params[6], source.GetServer(), params[8], params[2].is_pos_number_only() ? convertTo<time_t>(params[2]) : 0, params[3], params[7], NULL);
@@ -363,7 +363,7 @@ class ProtoRatbox : public Module
this->AddModes();
}
- ~ProtoRatbox()
+ ~ProtoRatbox() override
{
m_hybrid = ModuleManager::FindModule("hybrid");
ModuleManager::UnloadModule(m_hybrid, NULL);
diff --git a/modules/protocol/charybdis.cpp b/modules/protocol/solanum.cpp
index 091a0ed31..1ba740d04 100644
--- a/modules/protocol/charybdis.cpp
+++ b/modules/protocol/solanum.cpp
@@ -1,4 +1,4 @@
-/* Charybdis IRCD functions
+/* Solanum functions
*
* (C) 2003-2023 Anope Team
* Contact us at team@anope.org
@@ -22,18 +22,18 @@ class ChannelModeLargeBan : public ChannelMode
public:
ChannelModeLargeBan(const Anope::string &mname, char modeChar) : ChannelMode(mname, modeChar) { }
- bool CanSet(User *u) const anope_override
+ bool CanSet(User *u) const override
{
return u && u->HasMode("OPER");
}
};
-class CharybdisProto : public IRCDProto
+class SolanumProto : public IRCDProto
{
public:
- CharybdisProto(Module *creator) : IRCDProto(creator, "Charybdis 3.4+")
+ SolanumProto(Module *creator) : IRCDProto(creator, "Solanum")
{
DefaultPseudoclientModes = "+oiS";
CanCertFP = true;
@@ -48,37 +48,34 @@ class CharybdisProto : public IRCDProto
MaxModes = 4;
}
- void SendSVSKillInternal(const MessageSource &source, User *targ, const Anope::string &reason) anope_override { ratbox->SendSVSKillInternal(source, targ, reason); }
- void SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { ratbox->SendGlobalNotice(bi, dest, msg); }
- void SendGlobalPrivmsg(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { ratbox->SendGlobalPrivmsg(bi, dest, msg); }
- void SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) anope_override { ratbox->SendGlobopsInternal(source, buf); }
- void SendSGLine(User *u, const XLine *x) anope_override { ratbox->SendSGLine(u, x); }
- void SendSGLineDel(const XLine *x) anope_override { ratbox->SendSGLineDel(x); }
- void SendAkill(User *u, XLine *x) anope_override { ratbox->SendAkill(u, x); }
- void SendAkillDel(const XLine *x) anope_override { ratbox->SendAkillDel(x); }
- void SendSQLine(User *u, const XLine *x) anope_override { ratbox->SendSQLine(u, x); }
- void SendSQLineDel(const XLine *x) anope_override { ratbox->SendSQLineDel(x); }
- void SendJoin(User *user, Channel *c, const ChannelStatus *status) anope_override { ratbox->SendJoin(user, c, status); }
- void SendServer(const Server *server) anope_override { ratbox->SendServer(server); }
- void SendChannel(Channel *c) anope_override { ratbox->SendChannel(c); }
- void SendTopic(const MessageSource &source, Channel *c) anope_override { ratbox->SendTopic(source, c); }
- bool IsIdentValid(const Anope::string &ident) anope_override { return ratbox->IsIdentValid(ident); }
- void SendLogin(User *u, NickAlias *na) anope_override { ratbox->SendLogin(u, na); }
- void SendLogout(User *u) anope_override { ratbox->SendLogout(u); }
-
- void SendSASLMechanisms(std::vector<Anope::string> &mechanisms) anope_override
+ void SendSVSKillInternal(const MessageSource &source, User *targ, const Anope::string &reason) override { ratbox->SendSVSKillInternal(source, targ, reason); }
+ void SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg) override { ratbox->SendGlobalNotice(bi, dest, msg); }
+ void SendGlobalPrivmsg(BotInfo *bi, const Server *dest, const Anope::string &msg) override { ratbox->SendGlobalPrivmsg(bi, dest, msg); }
+ void SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) override { ratbox->SendGlobopsInternal(source, buf); }
+ void SendSGLine(User *u, const XLine *x) override { ratbox->SendSGLine(u, x); }
+ void SendSGLineDel(const XLine *x) override { ratbox->SendSGLineDel(x); }
+ void SendAkill(User *u, XLine *x) override { ratbox->SendAkill(u, x); }
+ void SendAkillDel(const XLine *x) override { ratbox->SendAkillDel(x); }
+ void SendSQLine(User *u, const XLine *x) override { ratbox->SendSQLine(u, x); }
+ void SendSQLineDel(const XLine *x) override { ratbox->SendSQLineDel(x); }
+ void SendJoin(User *user, Channel *c, const ChannelStatus *status) override { ratbox->SendJoin(user, c, status); }
+ void SendServer(const Server *server) override { ratbox->SendServer(server); }
+ void SendChannel(Channel *c) override { ratbox->SendChannel(c); }
+ void SendTopic(const MessageSource &source, Channel *c) override { ratbox->SendTopic(source, c); }
+ bool IsIdentValid(const Anope::string &ident) override { return ratbox->IsIdentValid(ident); }
+ void SendLogin(User *u, NickAlias *na) override { ratbox->SendLogin(u, na); }
+ void SendLogout(User *u) override { ratbox->SendLogout(u); }
+
+ void SendSASLMechanisms(std::vector<Anope::string> &mechanisms) override
{
Anope::string mechlist;
-
- for (unsigned i = 0; i < mechanisms.size(); ++i)
- {
- mechlist += "," + mechanisms[i];
- }
+ for (const auto &mechanism : mechanisms)
+ mechlist += "," + mechanism;
UplinkSocket::Message(Me) << "ENCAP * MECHLIST :" << (mechanisms.empty() ? "" : mechlist.substr(1));
}
- void SendConnect() anope_override
+ void SendConnect() override
{
UplinkSocket::Message() << "PASS " << Config->Uplinks[Anope::CurrentUplink].password << " TS 6 :" << Me->GetSID();
/*
@@ -88,6 +85,7 @@ class CharybdisProto : public IRCDProto
* BAN - Can do BAN message
* CHW - Can do channel wall @#
* CLUSTER - Supports umode +l, can send LOCOPS (encap only)
+ * ECHO - Supports sending echoed messages
* ENCAP - Can do ENCAP message
* EOPMOD - Can do channel wall =# (for cmode +z)
* EUID - Can do EUID (its similar to UID but includes the ENCAP REALHOST and ENCAP LOGIN information)
@@ -104,7 +102,7 @@ class CharybdisProto : public IRCDProto
* UNKLN - Can do UNKLINE (encap only)
* QS - Can handle quit storm removal
*/
- UplinkSocket::Message() << "CAPAB :BAN CHW CLUSTER ENCAP EOPMOD EUID EX IE KLN KNOCK MLOCK QS RSFNC SERVICES TB UNKLN";
+ UplinkSocket::Message() << "CAPAB :BAN CHW CLUSTER ECHO ENCAP EOPMOD EUID EX IE KLN KNOCK MLOCK QS RSFNC SERVICES TB UNKLN";
/* Make myself known to myself in the serverlist */
SendServer(Me);
@@ -119,48 +117,49 @@ class CharybdisProto : public IRCDProto
UplinkSocket::Message() << "SVINFO 6 6 0 :" << Anope::CurTime;
}
- void SendClientIntroduction(User *u) anope_override
+ void SendClientIntroduction(User *u) override
{
Anope::string modes = "+" + u->GetModes();
UplinkSocket::Message(Me) << "EUID " << u->nick << " 1 " << u->timestamp << " " << modes << " " << u->GetIdent() << " " << u->host << " 0 " << u->GetUID() << " * * :" << u->realname;
}
- void SendForceNickChange(User *u, const Anope::string &newnick, time_t when) anope_override
+ void SendForceNickChange(User *u, const Anope::string &newnick, time_t when) override
{
UplinkSocket::Message(Me) << "ENCAP " << u->server->GetName() << " RSFNC " << u->GetUID()
<< " " << newnick << " " << when << " " << u->timestamp;
}
- void SendSVSHold(const Anope::string &nick, time_t delay) anope_override
+ void SendSVSHold(const Anope::string &nick, time_t delay) override
{
UplinkSocket::Message(Me) << "ENCAP * NICKDELAY " << delay << " " << nick;
}
- void SendSVSHoldDel(const Anope::string &nick) anope_override
+ void SendSVSHoldDel(const Anope::string &nick) override
{
UplinkSocket::Message(Me) << "ENCAP * NICKDELAY 0 " << nick;
}
- void SendVhost(User *u, const Anope::string &ident, const Anope::string &host) anope_override
+ void SendVhost(User *u, const Anope::string &ident, const Anope::string &host) override
{
UplinkSocket::Message(Me) << "ENCAP * CHGHOST " << u->GetUID() << " :" << host;
}
- void SendVhostDel(User *u) anope_override
+ void SendVhostDel(User *u) override
{
this->SendVhost(u, "", u->host);
}
- void SendSASLMessage(const SASL::Message &message) anope_override
+ void SendSASLMessage(const SASL::Message &message) override
{
Server *s = Server::Find(message.target.substr(0, 3));
UplinkSocket::Message(Me) << "ENCAP " << (s ? s->GetName() : message.target.substr(0, 3)) << " SASL " << message.source << " " << message.target << " " << message.type << " " << message.data << (message.ext.empty() ? "" : (" " + message.ext));
}
- void SendSVSLogin(const Anope::string &uid, const Anope::string &acc, const Anope::string &vident, const Anope::string &vhost) anope_override
+ void SendSVSLogin(const Anope::string &uid, NickAlias *na) override
{
Server *s = Server::Find(uid.substr(0, 3));
- UplinkSocket::Message(Me) << "ENCAP " << (s ? s->GetName() : uid.substr(0, 3)) << " SVSLOGIN " << uid << " * " << (!vident.empty() ? vident : '*') << " " << (!vhost.empty() ? vhost : '*') << " " << acc;
+ UplinkSocket::Message(Me) << "ENCAP " << (s ? s->GetName() : uid.substr(0, 3)) << " SVSLOGIN " << uid << " * " << (!na->GetVhostIdent().empty() ? na->GetVhostIdent() : '*')
+ << " " << (!na->GetVhostHost().empty() ? na->GetVhostHost() : '*') << " " << na->nc->display;
}
};
@@ -172,7 +171,7 @@ struct IRCDMessageEncap : IRCDMessage
SetFlag(IRCDMESSAGE_SOFT_LIMIT);
}
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
// In a burst, states that the source user is logged in as the account.
if (params[1] == "LOGIN" || params[1] == "SU")
@@ -205,7 +204,7 @@ struct IRCDMessageEncap : IRCDMessage
* termination: 'A' for abort, 'F' for authentication failure, 'S' for
* authentication success).
*
- * Charybdis only accepts messages from SASL agents; these must have umode +S
+ * Solanum only accepts messages from SASL agents; these must have umode +S
*/
else if (params[1] == "SASL" && SASL::sasl && params.size() >= 6)
{
@@ -238,7 +237,7 @@ struct IRCDMessageEUID : IRCDMessage
* user is not logged in with services). Hence a NICK or UID command received
* from a remote server should not be sent in EUID form to other servers.
*/
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
NickAlias *na = NULL;
if (params[9] != "*")
@@ -253,8 +252,8 @@ struct IRCDMessageServer : IRCDMessage
{
IRCDMessageServer(Module *creator) : IRCDMessage(creator, "SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
- // SERVER dev.anope.de 1 :charybdis test server
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ // SERVER dev.anope.de 1 :solanum test server
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
// Servers other then our immediate uplink are introduced via SID
if (params[1] != "1")
@@ -269,18 +268,44 @@ struct IRCDMessagePass : IRCDMessage
{
IRCDMessagePass(Module *creator) : IRCDMessage(creator, "PASS", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
// UplinkSID is used in IRCDMessageServer
UplinkSID = params[3];
}
};
-class ProtoCharybdis : public Module
+struct IRCDMessageNotice : Message::Notice
+{
+ IRCDMessageNotice(Module *creator) : Message::Notice(creator) { }
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
+ {
+ if (Servers::Capab.count("ECHO"))
+ UplinkSocket::Message(Me) << "ECHO N " << source.GetSource() << " :" << params[1];
+
+ Message::Notice::Run(source, params, tags);
+ }
+};
+
+struct IRCDMessagePrivmsg : Message::Privmsg
+{
+ IRCDMessagePrivmsg(Module *creator) : Message::Privmsg(creator) { }
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
+ {
+ if (Servers::Capab.count("ECHO"))
+ UplinkSocket::Message(Me) << "ECHO P " << source.GetSource() << " :" << params[1];
+
+ Message::Privmsg::Run(source, params, tags);
+ }
+};
+
+class ProtoSolanum : public Module
{
Module *m_ratbox;
- CharybdisProto ircd_proto;
+ SolanumProto ircd_proto;
/* Core message handlers */
Message::Away message_away;
@@ -291,10 +316,8 @@ class ProtoCharybdis : public Module
Message::Kill message_kill;
Message::Mode message_mode;
Message::MOTD message_motd;
- Message::Notice message_notice;
Message::Part message_part;
Message::Ping message_ping;
- Message::Privmsg message_privmsg;
Message::Quit message_quit;
Message::SQuit message_squit;
Message::Stats message_stats;
@@ -310,7 +333,9 @@ class ProtoCharybdis : public Module
/* Our message handlers */
IRCDMessageEncap message_encap;
IRCDMessageEUID message_euid;
+ IRCDMessageNotice message_notice;
IRCDMessagePass message_pass;
+ IRCDMessagePrivmsg message_privmsg;
IRCDMessageServer message_server;
bool use_server_side_mlock;
@@ -340,25 +365,25 @@ class ProtoCharybdis : public Module
}
public:
- ProtoCharybdis(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL | VENDOR),
+ ProtoSolanum(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL | VENDOR),
ircd_proto(this),
message_away(this), message_capab(this), message_error(this), message_invite(this), message_kick(this),
- message_kill(this), message_mode(this), message_motd(this), message_notice(this), message_part(this),
- message_ping(this), message_privmsg(this), message_quit(this), message_squit(this), message_stats(this),
- message_time(this), message_topic(this), message_version(this), message_whois(this),
-
- message_bmask("IRCDMessage", "charybdis/bmask", "ratbox/bmask"),
- message_join("IRCDMessage", "charybdis/join", "ratbox/join"),
- message_nick("IRCDMessage", "charybdis/nick", "ratbox/nick"),
- message_pong("IRCDMessage", "charybdis/pong", "ratbox/pong"),
- message_sid("IRCDMessage", "charybdis/sid", "ratbox/sid"),
- message_sjoin("IRCDMessage", "charybdis/sjoin", "ratbox/sjoin"),
- message_tb("IRCDMessage", "charybdis/tb", "ratbox/tb"),
- message_tmode("IRCDMessage", "charybdis/tmode", "ratbox/tmode"),
- message_uid("IRCDMessage", "charybdis/uid", "ratbox/uid"),
-
- message_encap(this), message_euid(this), message_pass(this), message_server(this)
-
+ message_kill(this), message_mode(this), message_motd(this), message_part(this), message_ping(this),
+ message_quit(this), message_squit(this), message_stats(this), message_time(this), message_topic(this),
+ message_version(this), message_whois(this),
+
+ message_bmask("IRCDMessage", "solanum/bmask", "ratbox/bmask"),
+ message_join("IRCDMessage", "solanum/join", "ratbox/join"),
+ message_nick("IRCDMessage", "solanum/nick", "ratbox/nick"),
+ message_pong("IRCDMessage", "solanum/pong", "ratbox/pong"),
+ message_sid("IRCDMessage", "solanum/sid", "ratbox/sid"),
+ message_sjoin("IRCDMessage", "solanum/sjoin", "ratbox/sjoin"),
+ message_tb("IRCDMessage", "solanum/tb", "ratbox/tb"),
+ message_tmode("IRCDMessage", "solanum/tmode", "ratbox/tmode"),
+ message_uid("IRCDMessage", "solanum/uid", "ratbox/uid"),
+
+ message_encap(this), message_euid(this), message_notice(this), message_pass(this),
+ message_privmsg(this), message_server(this)
{
@@ -373,18 +398,42 @@ class ProtoCharybdis : public Module
this->AddModes();
}
- ~ProtoCharybdis()
+ ~ProtoSolanum() override
{
m_ratbox = ModuleManager::FindModule("ratbox");
ModuleManager::UnloadModule(m_ratbox, NULL);
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnUserLogin(User *u) override
+ {
+ // If the user has logged into their current nickname then mark them as such.
+ NickAlias *na = NickAlias::Find(u->nick);
+ if (na && na->nc == u->Account())
+ UplinkSocket::Message(Me) << "ENCAP * IDENTIFIED " << u->GetUID() << " " << u->nick;
+ else
+ UplinkSocket::Message(Me) << "ENCAP * IDENTIFIED " << u->GetUID() << " " << u->nick << " OFF";
+ }
+
+ void OnNickLogout(User *u) override
+ {
+ // We don't know what account the user was logged into so send in all cases.
+ UplinkSocket::Message(Me) << "ENCAP * IDENTIFIED " << u->GetUID() << " " << u->nick << " OFF";
+ }
+
+ void OnUserNickChange(User *u, const Anope::string &) override
+ {
+ // If the user is logged into an account check if we need to mark them
+ // as not identified to their nick.
+ if (u->Account())
+ OnUserLogin(u);
+ }
+
+ void OnReload(Configuration::Conf *conf) override
{
use_server_side_mlock = conf->GetModule(this)->Get<bool>("use_server_side_mlock");
}
- void OnChannelSync(Channel *c) anope_override
+ void OnChannelSync(Channel *c) override
{
if (!c->ci)
return;
@@ -397,7 +446,7 @@ class ProtoCharybdis : public Module
}
}
- EventReturn OnMLock(ChannelInfo *ci, ModeLock *lock) anope_override
+ EventReturn OnMLock(ChannelInfo *ci, ModeLock *lock) override
{
ModeLocks *modelocks = ci->GetExt<ModeLocks>("modelocks");
ChannelMode *cm = ModeManager::FindChannelModeByName(lock->name);
@@ -410,7 +459,7 @@ class ProtoCharybdis : public Module
return EVENT_CONTINUE;
}
- EventReturn OnUnMLock(ChannelInfo *ci, ModeLock *lock) anope_override
+ EventReturn OnUnMLock(ChannelInfo *ci, ModeLock *lock) override
{
ModeLocks *modelocks = ci->GetExt<ModeLocks>("modelocks");
ChannelMode *cm = ModeManager::FindChannelModeByName(lock->name);
@@ -424,4 +473,4 @@ class ProtoCharybdis : public Module
}
};
-MODULE_INIT(ProtoCharybdis)
+MODULE_INIT(ProtoSolanum)
diff --git a/modules/protocol/unreal.cpp b/modules/protocol/unreal.cpp
deleted file mode 100644
index ed4b95142..000000000
--- a/modules/protocol/unreal.cpp
+++ /dev/null
@@ -1,1340 +0,0 @@
-/* Unreal IRCD 3.2.x functions
- *
- * (C) 2003-2023 Anope Team
- * Contact us at team@anope.org
- *
- * Please read COPYING and README for further details.
- *
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
- */
-
-#include "module.h"
-#include "modules/cs_mode.h"
-#include "modules/sasl.h"
-
-class UnrealIRCdProto : public IRCDProto
-{
- public:
- UnrealIRCdProto(Module *creator) : IRCDProto(creator, "UnrealIRCd 3.2.x")
- {
- DefaultPseudoclientModes = "+Soiq";
- CanSVSNick = true;
- CanSVSJoin = true;
- CanSetVHost = true;
- CanSetVIdent = true;
- CanSNLine = true;
- CanSQLine = true;
- CanSZLine = true;
- CanSVSHold = true;
- CanSVSO = true;
- MaxModes = 12;
- }
-
- private:
- /* SVSNOOP */
- void SendSVSNOOP(const Server *server, bool set) anope_override
- {
- UplinkSocket::Message() << "SVSNOOP " << server->GetName() << " " << (set ? "+" : "-");
- }
-
- void SendAkillDel(const XLine *x) anope_override
- {
- if (x->IsRegex() || x->HasNickOrReal())
- return;
-
- /* ZLine if we can instead */
- if (x->GetUser() == "*")
- {
- cidr a(x->GetHost());
- if (a.valid())
- {
- IRCD->SendSZLineDel(x);
- return;
- }
- }
-
- UplinkSocket::Message() << "TKL - G " << x->GetUser() << " " << x->GetHost() << " " << x->by;
- }
-
- void SendTopic(const MessageSource &source, Channel *c) anope_override
- {
- UplinkSocket::Message(source) << "TOPIC " << c->name << " " << c->topic_setter << " " << c->topic_ts << " :" << c->topic;
- }
-
- void SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override
- {
- UplinkSocket::Message(bi) << "NOTICE $" << dest->GetName() << " :" << msg;
- }
-
- void SendGlobalPrivmsg(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override
- {
- UplinkSocket::Message(bi) << "PRIVMSG $" << dest->GetName() << " :" << msg;
- }
-
- void SendVhostDel(User *u) anope_override
- {
- BotInfo *HostServ = Config->GetClient("HostServ");
- u->RemoveMode(HostServ, "CLOAK");
- u->RemoveMode(HostServ, "VHOST");
- ModeManager::ProcessModes();
- u->SetMode(HostServ, "CLOAK");
- }
-
- void SendAkill(User *u, XLine *x) anope_override
- {
- if (x->IsRegex() || x->HasNickOrReal())
- {
- if (!u)
- {
- /* No user (this akill was just added), and contains nick and/or realname. Find users that match and ban them */
- for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
- if (x->manager->Check(it->second, x))
- this->SendAkill(it->second, x);
- return;
- }
-
- const XLine *old = x;
-
- if (old->manager->HasEntry("*@" + u->host))
- return;
-
- /* We can't akill x as it has a nick and/or realname included, so create a new akill for *@host */
- XLine *xline = new XLine("*@" + u->host, old->by, old->expires, old->reason, old->id);
- old->manager->AddXLine(xline);
- x = xline;
-
- Log(Config->GetClient("OperServ"), "akill") << "AKILL: Added an akill for " << x->mask << " because " << u->GetMask() << "#" << u->realname << " matches " << old->mask;
- }
-
- /* ZLine if we can instead */
- if (x->GetUser() == "*")
- {
- cidr a(x->GetHost());
- if (a.valid())
- {
- IRCD->SendSZLine(u, x);
- return;
- }
- }
-
- // Calculate the time left before this would expire, capping it at 2 days
- time_t timeleft = x->expires - Anope::CurTime;
- if (timeleft > 172800 || !x->expires)
- timeleft = 172800;
- UplinkSocket::Message() << "TKL + G " << x->GetUser() << " " << x->GetHost() << " " << x->by << " " << Anope::CurTime + timeleft << " " << x->created << " :" << x->GetReason();
- }
-
- void SendSVSKillInternal(const MessageSource &source, User *user, const Anope::string &buf) anope_override
- {
- UplinkSocket::Message(source) << "SVSKILL " << user->nick << " :" << buf;
- user->KillInternal(source, buf);
- }
-
- void SendModeInternal(const MessageSource &source, User *u, const Anope::string &buf) anope_override
- {
- UplinkSocket::Message(source) << "SVS2MODE " << u->nick <<" " << buf;
- }
-
- void SendClientIntroduction(User *u) anope_override
- {
- Anope::string modes = "+" + u->GetModes();
- UplinkSocket::Message() << "NICK " << u->nick << " 1 " << u->timestamp << " " << u->GetIdent() << " " << u->host << " " << u->server->GetName() << " 0 " << modes << " " << u->host << " * :" << u->realname;
- }
-
- /* SERVER name hop descript */
- /* Unreal 3.2 actually sends some info about itself in the descript area */
- void SendServer(const Server *server) anope_override
- {
- if (!server->GetSID().empty() && server == Me)
- UplinkSocket::Message() << "SERVER " << server->GetName() << " " << server->GetHops() << " :U0-*-" << server->GetSID() << " " << server->GetDescription();
- else
- UplinkSocket::Message() << "SERVER " << server->GetName() << " " << server->GetHops() << " :" << server->GetDescription();
- }
-
- /* JOIN */
- void SendJoin(User *user, Channel *c, const ChannelStatus *status) anope_override
- {
- UplinkSocket::Message(Me) << "SJOIN " << c->creation_time << " " << c->name << " :" << user->nick;
- if (status)
- {
- /* First save the channel status incase uc->Status == status */
- ChannelStatus cs = *status;
- /* If the user is internally on the channel with flags, kill them so that
- * the stacker will allow this.
- */
- ChanUserContainer *uc = c->FindUser(user);
- if (uc != NULL)
- uc->status.Clear();
-
- BotInfo *setter = BotInfo::Find(user->GetUID());
- for (size_t i = 0; i < cs.Modes().length(); ++i)
- c->SetMode(setter, ModeManager::FindChannelModeByChar(cs.Modes()[i]), user->GetUID(), false);
-
- if (uc != NULL)
- uc->status = cs;
- }
- }
-
- /* unsqline
- */
- void SendSQLineDel(const XLine *x) anope_override
- {
- UplinkSocket::Message() << "UNSQLINE " << x->mask;
- }
-
- /* SQLINE */
- /*
- ** - Unreal will translate this to TKL for us
- **
- */
- void SendSQLine(User *, const XLine *x) anope_override
- {
- UplinkSocket::Message() << "SQLINE " << x->mask << " :" << x->GetReason();
- }
-
- /*
- ** svso
- ** parv[0] = sender prefix
- ** parv[1] = nick
- ** parv[2] = options
- */
- void SendSVSO(BotInfo *source, const Anope::string &nick, const Anope::string &flag) anope_override
- {
- UplinkSocket::Message(source) << "SVSO " << nick << " " << flag;
- }
-
- /* Functions that use serval cmd functions */
-
- void SendVhost(User *u, const Anope::string &vIdent, const Anope::string &vhost) anope_override
- {
- if (!vIdent.empty())
- UplinkSocket::Message(Me) << "CHGIDENT " << u->nick << " " << vIdent;
- if (!vhost.empty())
- UplinkSocket::Message(Me) << "CHGHOST " << u->nick << " " << vhost;
- }
-
- void SendConnect() anope_override
- {
- /*
- NICKv2 = Nick Version 2
- VHP = Sends hidden host
- UMODE2 = sends UMODE2 on user modes
- NICKIP = Sends IP on NICK
- TOKEN = Use tokens to talk
- SJ3 = Supports SJOIN
- NOQUIT = No Quit
- TKLEXT = Extended TKL we don't use it but best to have it
- SJB64 = Base64 encoded time stamps
- ESVID = Allows storing account names as services stamp
- MLOCK = Supports the MLOCK server command
- VL = Version Info
- NS = Config->Numeric Server
- */
- Anope::string protoctl = "NICKv2 VHP UMODE2 NICKIP SJOIN SJOIN2 SJ3 NOQUIT TKLEXT ESVID MLOCK VL";
- if (!Me->GetSID().empty())
- protoctl += " VL";
- UplinkSocket::Message() << "PROTOCTL " << protoctl;
- UplinkSocket::Message() << "PASS :" << Config->Uplinks[Anope::CurrentUplink].password;
- SendServer(Me);
- }
-
- /* SVSHOLD - set */
- void SendSVSHold(const Anope::string &nick, time_t t) anope_override
- {
- UplinkSocket::Message() << "TKL + Q H " << nick << " " << Me->GetName() << " " << Anope::CurTime + t << " " << Anope::CurTime << " :Being held for registered user";
- }
-
- /* SVSHOLD - release */
- void SendSVSHoldDel(const Anope::string &nick) anope_override
- {
- UplinkSocket::Message() << "TKL - Q * " << nick << " " << Me->GetName();
- }
-
- /* UNSGLINE */
- /*
- * SVSNLINE - :realname mask
- */
- void SendSGLineDel(const XLine *x) anope_override
- {
- UplinkSocket::Message() << "SVSNLINE - :" << x->mask;
- }
-
- /* UNSZLINE */
- void SendSZLineDel(const XLine *x) anope_override
- {
- UplinkSocket::Message() << "TKL - Z * " << x->GetHost() << " " << x->by;
- }
-
- /* SZLINE */
- void SendSZLine(User *, const XLine *x) anope_override
- {
- // Calculate the time left before this would expire, capping it at 2 days
- time_t timeleft = x->expires - Anope::CurTime;
- if (timeleft > 172800 || !x->expires)
- timeleft = 172800;
- UplinkSocket::Message() << "TKL + Z * " << x->GetHost() << " " << x->by << " " << Anope::CurTime + timeleft << " " << x->created << " :" << x->GetReason();
- }
-
- /* SGLINE */
- /*
- * SVSNLINE + reason_where_is_space :realname mask with spaces
- */
- void SendSGLine(User *, const XLine *x) anope_override
- {
- Anope::string edited_reason = x->GetReason();
- edited_reason = edited_reason.replace_all_cs(" ", "_");
- UplinkSocket::Message() << "SVSNLINE + " << edited_reason << " :" << x->mask;
- }
-
- /* svsjoin
- parv[0] - sender
- parv[1] - nick to make join
- parv[2] - channel to join
- parv[3] - (optional) channel key(s)
- */
- /* In older Unreal SVSJOIN and SVSNLINE tokens were mixed so SVSJOIN and SVSNLINE are broken
- when coming from a none TOKEN'd server
- */
- void SendSVSJoin(const MessageSource &source, User *user, const Anope::string &chan, const Anope::string &param) anope_override
- {
- if (!param.empty())
- UplinkSocket::Message(source) << "SVSJOIN " << user->GetUID() << " " << chan << " :" << param;
- else
- UplinkSocket::Message(source) << "SVSJOIN " << user->GetUID() << " " << chan;
- }
-
- void SendSVSPart(const MessageSource &source, User *user, const Anope::string &chan, const Anope::string &param) anope_override
- {
- if (!param.empty())
- UplinkSocket::Message(source) << "SVSPART " << user->GetUID() << " " << chan << " :" << param;
- else
- UplinkSocket::Message(source) << "SVSPART " << user->GetUID() << " " << chan;
- }
-
- void SendSWhois(const MessageSource &source, const Anope::string &who, const Anope::string &mask) anope_override
- {
- UplinkSocket::Message(source) << "SWHOIS " << who << " :" << mask;
- }
-
- void SendEOB() anope_override
- {
- UplinkSocket::Message(Me) << "EOS";
- }
-
- bool IsNickValid(const Anope::string &nick) anope_override
- {
- if (nick.equals_ci("ircd") || nick.equals_ci("irc"))
- return false;
-
- return IRCDProto::IsNickValid(nick);
- }
-
- bool IsChannelValid(const Anope::string &chan) anope_override
- {
- if (chan.find(':') != Anope::string::npos)
- return false;
-
- return IRCDProto::IsChannelValid(chan);
- }
-
- bool IsExtbanValid(const Anope::string &mask) anope_override
- {
- return mask.length() >= 4 && mask[0] == '~' && mask[2] == ':';
- }
-
- void SendLogin(User *u, NickAlias *na) anope_override
- {
- /* 3.2.10.4+ treats users logged in with accounts as fully registered, even if -r, so we can not set this here. Just use the timestamp. */
- if (Servers::Capab.count("ESVID") > 0 && !na->nc->HasExt("UNCONFIRMED"))
- IRCD->SendMode(Config->GetClient("NickServ"), u, "+d %s", na->nc->display.c_str());
- else
- IRCD->SendMode(Config->GetClient("NickServ"), u, "+d %d", u->signon);
- }
-
- void SendLogout(User *u) anope_override
- {
- IRCD->SendMode(Config->GetClient("NickServ"), u, "+d 0");
- }
-
- void SendChannel(Channel *c) anope_override
- {
- /* Unreal does not support updating a channels TS without actually joining a user,
- * so we will join and part us now
- */
- BotInfo *bi = c->WhoSends();
- if (!bi)
- ;
- else if (c->FindUser(bi) == NULL)
- {
- bi->Join(c);
- bi->Part(c);
- }
- else
- {
- bi->Part(c);
- bi->Join(c);
- }
- }
-
- void SendSASLMessage(const SASL::Message &message) anope_override
- {
- size_t p = message.target.find('!');
- if (p == Anope::string::npos)
- return;
-
- UplinkSocket::Message(BotInfo::Find(message.source)) << "SASL " << message.target.substr(0, p) << " " << message.target << " " << message.type << " " << message.data << (message.ext.empty() ? "" : " " + message.ext);
- }
-
- void SendSVSLogin(const Anope::string &uid, const Anope::string &acc, const Anope::string &vident, const Anope::string &vhost) anope_override
- {
- size_t p = uid.find('!');
- if (p == Anope::string::npos)
- return;
- UplinkSocket::Message(Me) << "SVSLOGIN " << uid.substr(0, p) << " " << uid << " " << acc;
- }
-
- bool IsIdentValid(const Anope::string &ident) anope_override
- {
- if (ident.empty() || ident.length() > Config->GetBlock("networkinfo")->Get<unsigned>("userlen"))
- return false;
-
- for (unsigned i = 0; i < ident.length(); ++i)
- {
- const char &c = ident[i];
-
- if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || c == '.' || c == '-')
- continue;
-
- if (c == '-' || c == '.' || c == '_')
- continue;
-
- return false;
- }
-
- return true;
- }
-};
-
-class UnrealExtBan : public ChannelModeVirtual<ChannelModeList>
-{
- char ext;
-
- public:
- UnrealExtBan(const Anope::string &mname, const Anope::string &basename, char extban) : ChannelModeVirtual<ChannelModeList>(mname, basename)
- , ext(extban)
- {
- }
-
- ChannelMode *Wrap(Anope::string &param) anope_override
- {
- param = "~" + Anope::string(ext) + ":" + param;
- return ChannelModeVirtual<ChannelModeList>::Wrap(param);
- }
-
- ChannelMode *Unwrap(ChannelMode *cm, Anope::string &param) anope_override
- {
- if (cm->type != MODE_LIST || param.length() < 4 || param[0] != '~' || param[1] != ext || param[2] != ':')
- return cm;
-
- param = param.substr(3);
- return this;
- }
-};
-
-namespace UnrealExtban
-{
- class ChannelMatcher : public UnrealExtBan
- {
- public:
- ChannelMatcher(const Anope::string &mname, const Anope::string &mbase, char c) : UnrealExtBan(mname, mbase, c)
- {
- }
-
- bool Matches(User *u, const Entry *e) anope_override
- {
- const Anope::string &mask = e->GetMask();
- Anope::string channel = mask.substr(3);
-
- ChannelMode *cm = NULL;
- if (channel[0] != '#')
- {
- char modeChar = ModeManager::GetStatusChar(channel[0]);
- channel.erase(channel.begin());
- cm = ModeManager::FindChannelModeByChar(modeChar);
- if (cm != NULL && cm->type != MODE_STATUS)
- cm = NULL;
- }
-
- Channel *c = Channel::Find(channel);
- if (c != NULL)
- {
- ChanUserContainer *uc = c->FindUser(u);
- if (uc != NULL)
- if (cm == NULL || uc->status.HasMode(cm->mchar))
- return true;
- }
-
- return false;
- }
- };
-
- class EntryMatcher : public UnrealExtBan
- {
- public:
- EntryMatcher(const Anope::string &mname, const Anope::string &mbase, char c) : UnrealExtBan(mname, mbase, c)
- {
- }
-
- bool Matches(User *u, const Entry *e) anope_override
- {
- const Anope::string &mask = e->GetMask();
- Anope::string real_mask = mask.substr(3);
-
- return Entry(this->name, real_mask).Matches(u);
- }
- };
-
- class RealnameMatcher : public UnrealExtBan
- {
- public:
- RealnameMatcher(const Anope::string &mname, const Anope::string &mbase, char c) : UnrealExtBan(mname, mbase, c)
- {
- }
-
- bool Matches(User *u, const Entry *e) anope_override
- {
- const Anope::string &mask = e->GetMask();
- Anope::string real_mask = mask.substr(3);
-
- return Anope::Match(u->realname, real_mask);
- }
- };
-
- class RegisteredMatcher : public UnrealExtBan
- {
- public:
- RegisteredMatcher(const Anope::string &mname, const Anope::string &mbase, char c) : UnrealExtBan(mname, mbase, c)
- {
- }
-
- bool Matches(User *u, const Entry *e) anope_override
- {
- const Anope::string &mask = e->GetMask();
- return u->HasMode("REGISTERED") && mask.equals_ci(u->nick);
- }
- };
-
- class AccountMatcher : public UnrealExtBan
- {
- public:
- AccountMatcher(const Anope::string &mname, const Anope::string &mbase, char c) : UnrealExtBan(mname, mbase, c)
- {
- }
-
- bool Matches(User *u, const Entry *e) anope_override
- {
- const Anope::string &mask = e->GetMask();
- Anope::string real_mask = mask.substr(3);
-
- return u->Account() && Anope::Match(u->Account()->display, real_mask);
- }
- };
-}
-
-class ChannelModeFlood : public ChannelModeParam
-{
- public:
- ChannelModeFlood(char modeChar, bool minusNoArg) : ChannelModeParam("FLOOD", modeChar, minusNoArg) { }
-
- /* Borrowed part of this check from UnrealIRCd */
- bool IsValid(Anope::string &value) const anope_override
- {
- if (value.empty())
- return false;
- try
- {
- Anope::string rest;
- if (value[0] != ':' && convertTo<unsigned>(value[0] == '*' ? value.substr(1) : value, rest, false) > 0 && rest[0] == ':' && rest.length() > 1 && convertTo<unsigned>(rest.substr(1), rest, false) > 0 && rest.empty())
- return true;
- }
- catch (const ConvertException &) { }
-
- /* '['<number><1 letter>[optional: '#'+1 letter],[next..]']'':'<number> */
- size_t end_bracket = value.find(']', 1);
- if (end_bracket == Anope::string::npos)
- return false;
- Anope::string xbuf = value.substr(0, end_bracket);
- if (value[end_bracket + 1] != ':')
- return false;
- commasepstream args(xbuf.substr(1));
- Anope::string arg;
- while (args.GetToken(arg))
- {
- /* <number><1 letter>[optional: '#'+1 letter] */
- size_t p = 0;
- while (p < arg.length() && isdigit(arg[p]))
- ++p;
- if (p == arg.length() || !(arg[p] == 'c' || arg[p] == 'j' || arg[p] == 'k' || arg[p] == 'm' || arg[p] == 'n' || arg[p] == 't'))
- continue; /* continue instead of break for forward compatibility. */
- try
- {
- int v = arg.substr(0, p).is_number_only() ? convertTo<int>(arg.substr(0, p)) : 0;
- if (v < 1 || v > 999)
- return false;
- }
- catch (const ConvertException &)
- {
- return false;
- }
- }
-
- return true;
- }
-};
-
-class ChannelModeUnrealSSL : public ChannelMode
-{
- public:
- ChannelModeUnrealSSL(const Anope::string &n, char c) : ChannelMode(n, c)
- {
- }
-
- bool CanSet(User *u) const anope_override
- {
- return false;
- }
-};
-
-struct IRCDMessageCapab : Message::Capab
-{
- IRCDMessageCapab(Module *creator) : Message::Capab(creator, "PROTOCTL") { }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- for (unsigned i = 0; i < params.size(); ++i)
- {
- Anope::string capab = params[i];
-
- if (capab.find("CHANMODES") != Anope::string::npos)
- {
- Anope::string modes(capab.begin() + 10, capab.end());
- commasepstream sep(modes);
- Anope::string modebuf;
-
- sep.GetToken(modebuf);
- for (size_t t = 0, end = modebuf.length(); t < end; ++t)
- {
- switch (modebuf[t])
- {
- case 'b':
- ModeManager::AddChannelMode(new ChannelModeList("BAN", 'b'));
-
- ModeManager::AddChannelMode(new UnrealExtban::ChannelMatcher("CHANNELBAN", "BAN", 'c'));
- ModeManager::AddChannelMode(new UnrealExtban::EntryMatcher("JOINBAN", "BAN", 'j'));
- ModeManager::AddChannelMode(new UnrealExtban::EntryMatcher("NONICKBAN", "BAN", 'n'));
- ModeManager::AddChannelMode(new UnrealExtban::EntryMatcher("QUIET", "BAN", 'q'));
- ModeManager::AddChannelMode(new UnrealExtban::RealnameMatcher("REALNAMEBAN", "BAN", 'r'));
- ModeManager::AddChannelMode(new UnrealExtban::RegisteredMatcher("REGISTEREDBAN", "BAN", 'R'));
- ModeManager::AddChannelMode(new UnrealExtban::AccountMatcher("ACCOUNTBAN", "BAN", 'a'));
- continue;
- case 'e':
- ModeManager::AddChannelMode(new ChannelModeList("EXCEPT", 'e'));
- continue;
- case 'I':
- ModeManager::AddChannelMode(new ChannelModeList("INVITEOVERRIDE", 'I'));
- continue;
- default:
- ModeManager::AddChannelMode(new ChannelModeList("", modebuf[t]));
- }
- }
-
- sep.GetToken(modebuf);
- for (size_t t = 0, end = modebuf.length(); t < end; ++t)
- {
- switch (modebuf[t])
- {
- case 'k':
- ModeManager::AddChannelMode(new ChannelModeKey('k'));
- continue;
- case 'f':
- ModeManager::AddChannelMode(new ChannelModeFlood('f', false));
- continue;
- case 'L':
- ModeManager::AddChannelMode(new ChannelModeParam("REDIRECT", 'L'));
- continue;
- default:
- ModeManager::AddChannelMode(new ChannelModeParam("", modebuf[t]));
- }
- }
-
- sep.GetToken(modebuf);
- for (size_t t = 0, end = modebuf.length(); t < end; ++t)
- {
- switch (modebuf[t])
- {
- case 'l':
- ModeManager::AddChannelMode(new ChannelModeParam("LIMIT", 'l', true));
- continue;
- case 'j':
- ModeManager::AddChannelMode(new ChannelModeParam("JOINFLOOD", 'j', true));
- continue;
- default:
- ModeManager::AddChannelMode(new ChannelModeParam("", modebuf[t], true));
- }
- }
-
- sep.GetToken(modebuf);
- for (size_t t = 0, end = modebuf.length(); t < end; ++t)
- {
- switch (modebuf[t])
- {
- case 'p':
- ModeManager::AddChannelMode(new ChannelMode("PRIVATE", 'p'));
- continue;
- case 's':
- ModeManager::AddChannelMode(new ChannelMode("SECRET", 's'));
- continue;
- case 'm':
- ModeManager::AddChannelMode(new ChannelMode("MODERATED", 'm'));
- continue;
- case 'n':
- ModeManager::AddChannelMode(new ChannelMode("NOEXTERNAL", 'n'));
- continue;
- case 't':
- ModeManager::AddChannelMode(new ChannelMode("TOPIC", 't'));
- continue;
- case 'i':
- ModeManager::AddChannelMode(new ChannelMode("INVITE", 'i'));
- continue;
- case 'r':
- ModeManager::AddChannelMode(new ChannelModeNoone("REGISTERED", 'r'));
- continue;
- case 'R':
- ModeManager::AddChannelMode(new ChannelMode("REGISTEREDONLY", 'R'));
- continue;
- case 'c':
- ModeManager::AddChannelMode(new ChannelMode("BLOCKCOLOR", 'c'));
- continue;
- case 'O':
- ModeManager::AddChannelMode(new ChannelModeOperOnly("OPERONLY", 'O'));
- continue;
- case 'A':
- ModeManager::AddChannelMode(new ChannelModeOperOnly("ADMINONLY", 'A'));
- continue;
- case 'Q':
- ModeManager::AddChannelMode(new ChannelMode("NOKICK", 'Q'));
- continue;
- case 'K':
- ModeManager::AddChannelMode(new ChannelMode("NOKNOCK", 'K'));
- continue;
- case 'V':
- ModeManager::AddChannelMode(new ChannelMode("NOINVITE", 'V'));
- continue;
- case 'C':
- ModeManager::AddChannelMode(new ChannelMode("NOCTCP", 'C'));
- continue;
- case 'u':
- ModeManager::AddChannelMode(new ChannelMode("AUDITORIUM", 'u'));
- continue;
- case 'z':
- ModeManager::AddChannelMode(new ChannelMode("SSL", 'z'));
- continue;
- case 'N':
- ModeManager::AddChannelMode(new ChannelMode("NONICK", 'N'));
- continue;
- case 'S':
- ModeManager::AddChannelMode(new ChannelMode("STRIPCOLOR", 'S'));
- continue;
- case 'M':
- ModeManager::AddChannelMode(new ChannelMode("REGMODERATED", 'M'));
- continue;
- case 'T':
- ModeManager::AddChannelMode(new ChannelMode("NONOTICE", 'T'));
- continue;
- case 'G':
- ModeManager::AddChannelMode(new ChannelMode("CENSOR", 'G'));
- continue;
- case 'Z':
- ModeManager::AddChannelMode(new ChannelModeUnrealSSL("", 'Z'));
- continue;
- default:
- ModeManager::AddChannelMode(new ChannelMode("", modebuf[t]));
- }
- }
- }
- }
-
- Message::Capab::Run(source, params);
- }
-};
-
-struct IRCDMessageChgHost : IRCDMessage
-{
- IRCDMessageChgHost(Module *creator) : IRCDMessage(creator, "CHGHOST", 2) { }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- User *u = User::Find(params[0]);
- if (u)
- u->SetDisplayedHost(params[1]);
- }
-};
-
-struct IRCDMessageChgIdent : IRCDMessage
-{
- IRCDMessageChgIdent(Module *creator) : IRCDMessage(creator, "CHGIDENT", 2) { }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- User *u = User::Find(params[0]);
- if (u)
- u->SetVIdent(params[1]);
- }
-};
-
-struct IRCDMessageChgName : IRCDMessage
-{
- IRCDMessageChgName(Module *creator) : IRCDMessage(creator, "CHGNAME", 2) { }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- User *u = User::Find(params[0]);
- if (u)
- u->SetRealname(params[1]);
- }
-};
-
-struct IRCDMessageMode : IRCDMessage
-{
- IRCDMessageMode(Module *creator, const Anope::string &mname) : IRCDMessage(creator, mname, 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- bool server_source = source.GetServer() != NULL;
- Anope::string modes = params[1];
- for (unsigned i = 2; i < params.size() - (server_source ? 1 : 0); ++i)
- modes += " " + params[i];
-
- if (IRCD->IsChannelValid(params[0]))
- {
- Channel *c = Channel::Find(params[0]);
- time_t ts = 0;
-
- try
- {
- if (server_source)
- ts = convertTo<time_t>(params[params.size() - 1]);
- }
- catch (const ConvertException &) { }
-
- if (c)
- c->SetModesInternal(source, modes, ts);
- }
- else
- {
- User *u = User::Find(params[0]);
- if (u)
- u->SetModesInternal(source, "%s", params[1].c_str());
- }
- }
-};
-
-/* netinfo
- * argv[0] = max global count
- * argv[1] = time of end sync
- * argv[2] = unreal protocol using (numeric)
- * argv[3] = cloak-crc (> u2302)
- * argv[4] = free(**)
- * argv[5] = free(**)
- * argv[6] = free(**)
- * argv[7] = ircnet
- */
-struct IRCDMessageNetInfo : IRCDMessage
-{
- IRCDMessageNetInfo(Module *creator) : IRCDMessage(creator, "NETINFO", 8) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- UplinkSocket::Message() << "NETINFO " << MaxUserCount << " " << Anope::CurTime << " " << convertTo<int>(params[2]) << " " << params[3] << " 0 0 0 :" << params[7];
- }
-};
-
-struct IRCDMessageNick : IRCDMessage
-{
- IRCDMessageNick(Module *creator) : IRCDMessage(creator, "NICK", 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
-
- /*
- ** NICK - new
- ** source = NULL
- ** parv[0] = nickname
- ** parv[1] = hopcount
- ** parv[2] = timestamp
- ** parv[3] = username
- ** parv[4] = hostname
- ** parv[5] = servername
- ** parv[6] = servicestamp
- ** parv[7] = umodes
- ** parv[8] = virthost, * if none
- ** parv[9] = ip
- ** parv[10] = info
- **
- ** NICK - change
- ** source = oldnick
- ** parv[0] = new nickname
- ** parv[1] = hopcount
- */
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- if (params.size() == 11)
- {
- Anope::string ip;
- if (params[9] != "*")
- {
- Anope::string decoded_ip;
- Anope::B64Decode(params[9], decoded_ip);
-
- sockaddrs ip_addr;
- ip_addr.ntop(params[9].length() == 8 ? AF_INET : AF_INET6, decoded_ip.c_str());
- ip = ip_addr.addr();
- }
-
- Anope::string vhost = params[8];
- if (vhost.equals_cs("*"))
- vhost.clear();
-
- time_t user_ts = params[2].is_pos_number_only() ? convertTo<time_t>(params[2]) : Anope::CurTime;
-
- Server *s = Server::Find(params[5]);
- if (s == NULL)
- {
- Log(LOG_DEBUG) << "User " << params[0] << " introduced from nonexistent server " << params[5] << "?";
- return;
- }
-
- NickAlias *na = NULL;
-
- if (params[6] == "0")
- ;
- else if (params[6].is_pos_number_only())
- {
- if (convertTo<time_t>(params[6]) == user_ts)
- na = NickAlias::Find(params[0]);
- }
- else
- {
- na = NickAlias::Find(params[6]);
- }
-
- User::OnIntroduce(params[0], params[3], params[4], vhost, ip, s, params[10], user_ts, params[7], "", na ? *na->nc : NULL);
- }
- else
- {
- User *u = source.GetUser();
- if (u)
- u->ChangeNick(params[0]);
- }
- }
-};
-
-/** This is here because:
- *
- * If we had three servers, A, B & C linked like so: A<->B<->C
- * If Anope is linked to A and B splits from A and then reconnects
- * B introduces itself, introduces C, sends EOS for C, introduces Bs clients
- * introduces Cs clients, sends EOS for B. This causes all of Cs clients to be introduced
- * with their server "not syncing". We now send a PING immediately when receiving a new server
- * and then finish sync once we get a pong back from that server.
- */
-struct IRCDMessagePong : IRCDMessage
-{
- IRCDMessagePong(Module *creator) : IRCDMessage(creator, "PONG", 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- if (!source.GetServer()->IsSynced())
- source.GetServer()->Sync(false);
- }
-};
-
-struct IRCDMessageSASL : IRCDMessage
-{
- IRCDMessageSASL(Module *creator) : IRCDMessage(creator, "SASL", 4) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- size_t p = params[1].find('!');
- if (!SASL::sasl || p == Anope::string::npos)
- return;
-
- SASL::Message m;
- m.source = params[1];
- m.target = params[0];
- m.type = params[2];
- m.data = params[3];
- m.ext = params.size() > 4 ? params[4] : "";
-
- SASL::sasl->ProcessMessage(m);
- }
-};
-
-struct IRCDMessageSDesc : IRCDMessage
-{
- IRCDMessageSDesc(Module *creator) : IRCDMessage(creator, "SDESC", 1) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- source.GetServer()->SetDescription(params[0]);
- }
-};
-
-struct IRCDMessageSetHost : IRCDMessage
-{
- IRCDMessageSetHost(Module *creator) : IRCDMessage(creator, "SETHOST", 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- User *u = source.GetUser();
-
- /* When a user sets +x we receive the new host and then the mode change */
- if (u->HasMode("CLOAK"))
- u->SetDisplayedHost(params[0]);
- else
- u->SetCloakedHost(params[0]);
- }
-};
-
-struct IRCDMessageSetIdent : IRCDMessage
-{
- IRCDMessageSetIdent(Module *creator) : IRCDMessage(creator, "SETIDENT", 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- User *u = source.GetUser();
- u->SetVIdent(params[0]);
- }
-};
-
-struct IRCDMessageSetName : IRCDMessage
-{
- IRCDMessageSetName(Module *creator) : IRCDMessage(creator, "SETNAME", 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- User *u = source.GetUser();
- u->SetRealname(params[0]);
- }
-};
-
-struct IRCDMessageServer : IRCDMessage
-{
- IRCDMessageServer(Module *creator) : IRCDMessage(creator, "SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- unsigned int hops = Anope::string(params[1]).is_pos_number_only() ? convertTo<unsigned>(params[1]) : 0;
-
- if (params[1].equals_cs("1"))
- {
- Anope::string desc;
- spacesepstream(params[2]).GetTokenRemainder(desc, 1);
-
- new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], hops, desc);
- }
- else
- new Server(source.GetServer(), params[0], hops, params[2]);
-
- IRCD->SendPing(Me->GetName(), params[0]);
- }
-};
-
-struct IRCDMessageSJoin : IRCDMessage
-{
- IRCDMessageSJoin(Module *creator) : IRCDMessage(creator, "SJOIN", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- Anope::string modes;
- if (params.size() >= 4)
- for (unsigned i = 2; i < params.size() - 1; ++i)
- modes += " " + params[i];
- if (!modes.empty())
- modes.erase(modes.begin());
-
- std::list<Anope::string> bans, excepts, invites;
- std::list<Message::Join::SJoinUser> users;
-
- spacesepstream sep(params[params.size() - 1]);
- Anope::string buf;
- while (sep.GetToken(buf))
- {
- /* Ban */
- if (buf[0] == '&')
- {
- buf.erase(buf.begin());
- bans.push_back(buf);
- }
- /* Except */
- else if (buf[0] == '"')
- {
- buf.erase(buf.begin());
- excepts.push_back(buf);
- }
- /* Invex */
- else if (buf[0] == '\'')
- {
- buf.erase(buf.begin());
- invites.push_back(buf);
- }
- else
- {
- Message::Join::SJoinUser sju;
-
- /* Get prefixes from the nick */
- for (char ch; (ch = ModeManager::GetStatusChar(buf[0]));)
- {
- sju.first.AddMode(ch);
- buf.erase(buf.begin());
- }
-
- sju.second = User::Find(buf);
- if (!sju.second)
- {
- Log(LOG_DEBUG) << "SJOIN for nonexistent user " << buf << " on " << params[1];
- continue;
- }
-
- users.push_back(sju);
- }
- }
-
- time_t ts = Anope::string(params[0]).is_pos_number_only() ? convertTo<time_t>(params[0]) : Anope::CurTime;
- Message::Join::SJoin(source, params[1], ts, modes, users);
-
- if (!bans.empty() || !excepts.empty() || !invites.empty())
- {
- Channel *c = Channel::Find(params[1]);
-
- if (!c || c->creation_time != ts)
- return;
-
- ChannelMode *ban = ModeManager::FindChannelModeByName("BAN"),
- *except = ModeManager::FindChannelModeByName("EXCEPT"),
- *invex = ModeManager::FindChannelModeByName("INVITEOVERRIDE");
-
- if (ban)
- for (std::list<Anope::string>::iterator it = bans.begin(), it_end = bans.end(); it != it_end; ++it)
- c->SetModeInternal(source, ban, *it);
- if (except)
- for (std::list<Anope::string>::iterator it = excepts.begin(), it_end = excepts.end(); it != it_end; ++it)
- c->SetModeInternal(source, except, *it);
- if (invex)
- for (std::list<Anope::string>::iterator it = invites.begin(), it_end = invites.end(); it != it_end; ++it)
- c->SetModeInternal(source, invex, *it);
- }
- }
-};
-
-struct IRCDMessageTopic : IRCDMessage
-{
- IRCDMessageTopic(Module *creator) : IRCDMessage(creator, "TOPIC", 4) { }
-
- /*
- ** source = sender prefix
- ** parv[0] = channel name
- ** parv[1] = topic nickname
- ** parv[2] = topic time
- ** parv[3] = topic text
- */
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- Channel *c = Channel::Find(params[0]);
- if (c)
- c->ChangeTopicInternal(source.GetUser(), params[1], params[3], Anope::string(params[2]).is_pos_number_only() ? convertTo<time_t>(params[2]) : Anope::CurTime);
- }
-};
-
-
-struct IRCDMessageUmode2 : IRCDMessage
-{
- IRCDMessageUmode2(Module *creator) : IRCDMessage(creator, "UMODE2", 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- source.GetUser()->SetModesInternal(source, "%s", params[0].c_str());
- }
-};
-
-class ProtoUnreal : public Module
-{
- UnrealIRCdProto ircd_proto;
-
- /* Core message handlers */
- Message::Away message_away;
- Message::Error message_error;
- Message::Invite message_invite;
- Message::Join message_join;
- Message::Kick message_kick;
- Message::Kill message_kill, message_svskill;
- Message::MOTD message_motd;
- Message::Notice message_notice;
- Message::Part message_part;
- Message::Ping message_ping;
- Message::Privmsg message_privmsg;
- Message::Quit message_quit;
- Message::SQuit message_squit;
- Message::Stats message_stats;
- Message::Time message_time;
- Message::Version message_version;
- Message::Whois message_whois;
-
- /* Our message handlers */
- IRCDMessageCapab message_capab;
- IRCDMessageChgHost message_chghost;
- IRCDMessageChgIdent message_chgident;
- IRCDMessageChgName message_chgname;
- IRCDMessageMode message_mode, message_svsmode, message_svs2mode;
- IRCDMessageNetInfo message_netinfo;
- IRCDMessageNick message_nick;
- IRCDMessagePong message_pong;
- IRCDMessageSASL message_sasl;
- IRCDMessageSDesc message_sdesc;
- IRCDMessageSetHost message_sethost;
- IRCDMessageSetIdent message_setident;
- IRCDMessageSetName message_setname;
- IRCDMessageServer message_server;
- IRCDMessageSJoin message_sjoin;
- IRCDMessageTopic message_topic;
- IRCDMessageUmode2 message_umode2;
-
- bool use_server_side_mlock;
-
- void AddModes()
- {
- ModeManager::AddChannelMode(new ChannelModeStatus("VOICE", 'v', '+', 0));
- ModeManager::AddChannelMode(new ChannelModeStatus("HALFOP", 'h', '%', 1));
- ModeManager::AddChannelMode(new ChannelModeStatus("OP", 'o', '@', 2));
- /* Unreal sends +q as * and +a as ~ */
- ModeManager::AddChannelMode(new ChannelModeStatus("PROTECT", 'a', '~', 3));
- ModeManager::AddChannelMode(new ChannelModeStatus("OWNER", 'q', '*', 4));
-
- /* Add user modes */
- ModeManager::AddUserMode(new UserModeOperOnly("SERV_ADMIN", 'A'));
- ModeManager::AddUserMode(new UserMode("BOT", 'B'));
- ModeManager::AddUserMode(new UserModeOperOnly("CO_ADMIN", 'C'));
- ModeManager::AddUserMode(new UserMode("CENSOR", 'G'));
- ModeManager::AddUserMode(new UserModeOperOnly("HIDEOPER", 'H'));
- ModeManager::AddUserMode(new UserModeOperOnly("HIDEIDLE", 'I'));
- ModeManager::AddUserMode(new UserModeOperOnly("NETADMIN", 'N'));
- ModeManager::AddUserMode(new UserMode("REGPRIV", 'R'));
- ModeManager::AddUserMode(new UserModeOperOnly("PROTECTED", 'S'));
- ModeManager::AddUserMode(new UserMode("NOCTCP", 'T'));
- ModeManager::AddUserMode(new UserMode("WEBTV", 'V'));
- ModeManager::AddUserMode(new UserModeOperOnly("WHOIS", 'W'));
- ModeManager::AddUserMode(new UserModeOperOnly("ADMIN", 'a'));
- ModeManager::AddUserMode(new UserMode("DEAF", 'd'));
- ModeManager::AddUserMode(new UserModeOperOnly("GLOBOPS", 'g'));
- ModeManager::AddUserMode(new UserModeOperOnly("HELPOP", 'h'));
- ModeManager::AddUserMode(new UserMode("INVIS", 'i'));
- ModeManager::AddUserMode(new UserModeOperOnly("OPER", 'o'));
- ModeManager::AddUserMode(new UserMode("PRIV", 'p'));
- ModeManager::AddUserMode(new UserModeOperOnly("GOD", 'q'));
- ModeManager::AddUserMode(new UserModeNoone("REGISTERED", 'r'));
- ModeManager::AddUserMode(new UserModeOperOnly("SNOMASK", 's'));
- ModeManager::AddUserMode(new UserModeNoone("VHOST", 't'));
- ModeManager::AddUserMode(new UserMode("WALLOPS", 'w'));
- ModeManager::AddUserMode(new UserMode("CLOAK", 'x'));
- ModeManager::AddUserMode(new UserModeNoone("SSL", 'z'));
- }
-
- public:
- ProtoUnreal(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL | VENDOR),
- ircd_proto(this),
- message_away(this), message_error(this), message_invite(this), message_join(this), message_kick(this),
- message_kill(this), message_svskill(this, "SVSKILL"), message_motd(this), message_notice(this), message_part(this), message_ping(this),
- message_privmsg(this), message_quit(this), message_squit(this), message_stats(this), message_time(this),
- message_version(this), message_whois(this),
-
- message_capab(this), message_chghost(this), message_chgident(this), message_chgname(this), message_mode(this, "MODE"),
- message_svsmode(this, "SVSMODE"), message_svs2mode(this, "SVS2MODE"), message_netinfo(this), message_nick(this), message_pong(this),
- message_sasl(this), message_sdesc(this), message_sethost(this), message_setident(this), message_setname(this), message_server(this),
- message_sjoin(this), message_topic(this), message_umode2(this)
- {
-
- this->AddModes();
- }
-
- void Prioritize() anope_override
- {
- ModuleManager::SetPriority(this, PRIORITY_FIRST);
- }
-
- void OnReload(Configuration::Conf *conf) anope_override
- {
- use_server_side_mlock = conf->GetModule(this)->Get<bool>("use_server_side_mlock");
- }
-
- void OnUserNickChange(User *u, const Anope::string &) anope_override
- {
- u->RemoveModeInternal(Me, ModeManager::FindUserModeByName("REGISTERED"));
- if (Servers::Capab.count("ESVID") == 0)
- IRCD->SendLogout(u);
- }
-
- void OnChannelSync(Channel *c) anope_override
- {
- if (!c->ci)
- return;
-
- ModeLocks *modelocks = c->ci->GetExt<ModeLocks>("modelocks");
- if (use_server_side_mlock && Servers::Capab.count("MLOCK") > 0 && modelocks)
- {
- Anope::string modes = modelocks->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "");
- UplinkSocket::Message(Me) << "MLOCK " << static_cast<long>(c->creation_time) << " " << c->ci->name << " " << modes;
- }
- }
-
- void OnChanRegistered(ChannelInfo *ci) anope_override
- {
- ModeLocks *modelocks = ci->GetExt<ModeLocks>("modelocks");
- if (!ci->c || !use_server_side_mlock || !modelocks || !Servers::Capab.count("MLOCK"))
- return;
- Anope::string modes = modelocks->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "");
- UplinkSocket::Message(Me) << "MLOCK " << static_cast<long>(ci->c->creation_time) << " " << ci->name << " " << modes;
- }
-
- void OnDelChan(ChannelInfo *ci) anope_override
- {
- if (!ci->c || !use_server_side_mlock || !Servers::Capab.count("MLOCK"))
- return;
- UplinkSocket::Message(Me) << "MLOCK " << static_cast<long>(ci->c->creation_time) << " " << ci->name << " :";
- }
-
- EventReturn OnMLock(ChannelInfo *ci, ModeLock *lock) anope_override
- {
- ModeLocks *modelocks = ci->GetExt<ModeLocks>("modelocks");
- ChannelMode *cm = ModeManager::FindChannelModeByName(lock->name);
- if (use_server_side_mlock && cm && modelocks && ci->c && (cm->type == MODE_REGULAR || cm->type == MODE_PARAM) && Servers::Capab.count("MLOCK") > 0)
- {
- Anope::string modes = modelocks->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "") + cm->mchar;
- UplinkSocket::Message(Me) << "MLOCK " << static_cast<long>(ci->c->creation_time) << " " << ci->name << " " << modes;
- }
-
- return EVENT_CONTINUE;
- }
-
- EventReturn OnUnMLock(ChannelInfo *ci, ModeLock *lock) anope_override
- {
- ModeLocks *modelocks = ci->GetExt<ModeLocks>("modelocks");
- ChannelMode *cm = ModeManager::FindChannelModeByName(lock->name);
- if (use_server_side_mlock && cm && modelocks && ci->c && (cm->type == MODE_REGULAR || cm->type == MODE_PARAM) && Servers::Capab.count("MLOCK") > 0)
- {
- Anope::string modes = modelocks->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "").replace_all_cs(cm->mchar, "");
- UplinkSocket::Message(Me) << "MLOCK " << static_cast<long>(ci->c->creation_time) << " " << ci->name << " " << modes;
- }
-
- return EVENT_CONTINUE;
- }
-};
-
-MODULE_INIT(ProtoUnreal)
diff --git a/modules/protocol/unreal4.cpp b/modules/protocol/unrealircd.cpp
index ef5d09d40..0195f8861 100644
--- a/modules/protocol/unreal4.cpp
+++ b/modules/protocol/unrealircd.cpp
@@ -1,4 +1,4 @@
-/* Unreal IRCD 4 functions
+/* UnrealIRCd functions
*
* (C) 2003-2023 Anope Team
* Contact us at team@anope.org
@@ -41,12 +41,12 @@ class UnrealIRCdProto : public IRCDProto
private:
/* SVSNOOP */
- void SendSVSNOOP(const Server *server, bool set) anope_override
+ void SendSVSNOOP(const Server *server, bool set) override
{
UplinkSocket::Message() << "SVSNOOP " << server->GetSID() << " " << (set ? "+" : "-");
}
- void SendAkillDel(const XLine *x) anope_override
+ void SendAkillDel(const XLine *x) override
{
if (x->IsRegex() || x->HasNickOrReal())
return;
@@ -65,37 +65,37 @@ class UnrealIRCdProto : public IRCDProto
UplinkSocket::Message() << "TKL - G " << x->GetUser() << " " << x->GetHost() << " " << x->by;
}
- void SendTopic(const MessageSource &source, Channel *c) anope_override
+ void SendTopic(const MessageSource &source, Channel *c) override
{
UplinkSocket::Message(source) << "TOPIC " << c->name << " " << c->topic_setter << " " << c->topic_ts << " :" << c->topic;
}
- void SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override
+ void SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg) override
{
UplinkSocket::Message(bi) << "NOTICE $" << dest->GetName() << " :" << msg;
}
- void SendGlobalPrivmsg(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override
+ void SendGlobalPrivmsg(BotInfo *bi, const Server *dest, const Anope::string &msg) override
{
UplinkSocket::Message(bi) << "PRIVMSG $" << dest->GetName() << " :" << msg;
}
- void SendVhostDel(User *u) anope_override
+ void SendVhostDel(User *u) override
{
BotInfo *HostServ = Config->GetClient("HostServ");
u->RemoveMode(HostServ, "VHOST");
}
- void SendAkill(User *u, XLine *x) anope_override
+ void SendAkill(User *u, XLine *x) override
{
if (x->IsRegex() || x->HasNickOrReal())
{
if (!u)
{
/* No user (this akill was just added), and contains nick and/or realname. Find users that match and ban them */
- for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
- if (x->manager->Check(it->second, x))
- this->SendAkill(it->second, x);
+ for (const auto &[_, user] : UserListByNick)
+ if (x->manager->Check(user, x))
+ this->SendAkill(user, x);
return;
}
@@ -130,18 +130,18 @@ class UnrealIRCdProto : public IRCDProto
UplinkSocket::Message() << "TKL + G " << x->GetUser() << " " << x->GetHost() << " " << x->by << " " << Anope::CurTime + timeleft << " " << x->created << " :" << x->GetReason();
}
- void SendSVSKillInternal(const MessageSource &source, User *user, const Anope::string &buf) anope_override
+ void SendSVSKillInternal(const MessageSource &source, User *user, const Anope::string &buf) override
{
UplinkSocket::Message(source) << "SVSKILL " << user->GetUID() << " :" << buf;
user->KillInternal(source, buf);
}
- void SendModeInternal(const MessageSource &source, User *u, const Anope::string &buf) anope_override
+ void SendModeInternal(const MessageSource &source, User *u, const Anope::string &buf) override
{
UplinkSocket::Message(source) << "SVS2MODE " << u->GetUID() <<" " << buf;
}
- void SendClientIntroduction(User *u) anope_override
+ void SendClientIntroduction(User *u) override
{
Anope::string modes = "+" + u->GetModes();
UplinkSocket::Message(u->server) << "UID " << u->nick << " 1 " << u->timestamp << " " << u->GetIdent() << " " << u->host << " "
@@ -149,7 +149,7 @@ class UnrealIRCdProto : public IRCDProto
<< (!u->chost.empty() ? u->chost : "*") << " " << "*" << " :" << u->realname;
}
- void SendServer(const Server *server) anope_override
+ void SendServer(const Server *server) override
{
if (server == Me)
UplinkSocket::Message() << "SERVER " << server->GetName() << " " << server->GetHops() + 1 << " :" << server->GetDescription();
@@ -158,7 +158,7 @@ class UnrealIRCdProto : public IRCDProto
}
/* JOIN */
- void SendJoin(User *user, Channel *c, const ChannelStatus *status) anope_override
+ void SendJoin(User *user, Channel *c, const ChannelStatus *status) override
{
UplinkSocket::Message(Me) << "SJOIN " << c->creation_time << " " << c->name
<< " +" << c->GetModes(true, true) << " :" << user->GetUID();
@@ -174,8 +174,8 @@ class UnrealIRCdProto : public IRCDProto
uc->status.Clear();
BotInfo *setter = BotInfo::Find(user->GetUID());
- for (size_t i = 0; i < cs.Modes().length(); ++i)
- c->SetMode(setter, ModeManager::FindChannelModeByChar(cs.Modes()[i]), user->GetUID(), false);
+ for (auto mode : cs.Modes())
+ c->SetMode(setter, ModeManager::FindChannelModeByChar(mode), user->GetUID(), false);
if (uc != NULL)
uc->status = cs;
@@ -184,7 +184,7 @@ class UnrealIRCdProto : public IRCDProto
/* unsqline
*/
- void SendSQLineDel(const XLine *x) anope_override
+ void SendSQLineDel(const XLine *x) override
{
UplinkSocket::Message() << "UNSQLINE " << x->mask;
}
@@ -194,14 +194,14 @@ class UnrealIRCdProto : public IRCDProto
** - Unreal will translate this to TKL for us
**
*/
- void SendSQLine(User *, const XLine *x) anope_override
+ void SendSQLine(User *, const XLine *x) override
{
UplinkSocket::Message() << "SQLINE " << x->mask << " :" << x->GetReason();
}
/* Functions that use serval cmd functions */
- void SendVhost(User *u, const Anope::string &vIdent, const Anope::string &vhost) anope_override
+ void SendVhost(User *u, const Anope::string &vIdent, const Anope::string &vhost) override
{
if (!vIdent.empty())
UplinkSocket::Message(Me) << "CHGIDENT " << u->GetUID() << " " << vIdent;
@@ -213,7 +213,7 @@ class UnrealIRCdProto : public IRCDProto
u->SetMode(bi, "VHOST");
}
- void SendConnect() anope_override
+ void SendConnect() override
{
/*
NICKv2 = Nick Version 2
@@ -234,23 +234,23 @@ class UnrealIRCdProto : public IRCDProto
SendServer(Me);
}
- void SendSASLMechanisms(std::vector<Anope::string> &mechanisms) anope_override
+ void SendSASLMechanisms(std::vector<Anope::string> &mechanisms) override
{
Anope::string mechlist;
- for (unsigned i = 0; i < mechanisms.size(); ++i)
- mechlist += "," + mechanisms[i];
+ for (const auto &mechanism : mechanisms)
+ mechlist += "," + mechanism;
UplinkSocket::Message() << "MD client " << Me->GetName() << " saslmechlist :" << (mechanisms.empty() ? "" : mechlist.substr(1));
}
/* SVSHOLD - set */
- void SendSVSHold(const Anope::string &nick, time_t t) anope_override
+ void SendSVSHold(const Anope::string &nick, time_t t) override
{
UplinkSocket::Message() << "TKL + Q H " << nick << " " << Me->GetName() << " " << Anope::CurTime + t << " " << Anope::CurTime << " :Being held for registered user";
}
/* SVSHOLD - release */
- void SendSVSHoldDel(const Anope::string &nick) anope_override
+ void SendSVSHoldDel(const Anope::string &nick) override
{
UplinkSocket::Message() << "TKL - Q * " << nick << " " << Me->GetName();
}
@@ -259,19 +259,19 @@ class UnrealIRCdProto : public IRCDProto
/*
* SVSNLINE - :realname mask
*/
- void SendSGLineDel(const XLine *x) anope_override
+ void SendSGLineDel(const XLine *x) override
{
UplinkSocket::Message() << "SVSNLINE - :" << x->mask;
}
/* UNSZLINE */
- void SendSZLineDel(const XLine *x) anope_override
+ void SendSZLineDel(const XLine *x) override
{
UplinkSocket::Message() << "TKL - Z * " << x->GetHost() << " " << x->by;
}
/* SZLINE */
- void SendSZLine(User *, const XLine *x) anope_override
+ void SendSZLine(User *, const XLine *x) override
{
// Calculate the time left before this would expire, capping it at 2 days
time_t timeleft = x->expires - Anope::CurTime;
@@ -284,7 +284,7 @@ class UnrealIRCdProto : public IRCDProto
/*
* SVSNLINE + reason_where_is_space :realname mask with spaces
*/
- void SendSGLine(User *, const XLine *x) anope_override
+ void SendSGLine(User *, const XLine *x) override
{
Anope::string edited_reason = x->GetReason();
edited_reason = edited_reason.replace_all_cs(" ", "_");
@@ -300,7 +300,7 @@ class UnrealIRCdProto : public IRCDProto
/* In older Unreal SVSJOIN and SVSNLINE tokens were mixed so SVSJOIN and SVSNLINE are broken
when coming from a none TOKEN'd server
*/
- void SendSVSJoin(const MessageSource &source, User *user, const Anope::string &chan, const Anope::string &param) anope_override
+ void SendSVSJoin(const MessageSource &source, User *user, const Anope::string &chan, const Anope::string &param) override
{
if (!param.empty())
UplinkSocket::Message() << "SVSJOIN " << user->GetUID() << " " << chan << " :" << param;
@@ -308,7 +308,7 @@ class UnrealIRCdProto : public IRCDProto
UplinkSocket::Message() << "SVSJOIN " << user->GetUID() << " " << chan;
}
- void SendSVSPart(const MessageSource &source, User *user, const Anope::string &chan, const Anope::string &param) anope_override
+ void SendSVSPart(const MessageSource &source, User *user, const Anope::string &chan, const Anope::string &param) override
{
if (!param.empty())
UplinkSocket::Message() << "SVSPART " << user->GetUID() << " " << chan << " :" << param;
@@ -316,22 +316,22 @@ class UnrealIRCdProto : public IRCDProto
UplinkSocket::Message() << "SVSPART " << user->GetUID() << " " << chan;
}
- void SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) anope_override
+ void SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) override
{
UplinkSocket::Message(Me) << "SENDUMODE o :from " << source.GetName() << ": " << buf;
}
- void SendSWhois(const MessageSource &source, const Anope::string &who, const Anope::string &mask) anope_override
+ void SendSWhois(const MessageSource &source, const Anope::string &who, const Anope::string &mask) override
{
UplinkSocket::Message() << "SWHOIS " << who << " :" << mask;
}
- void SendEOB() anope_override
+ void SendEOB() override
{
UplinkSocket::Message(Me) << "EOS";
}
- bool IsNickValid(const Anope::string &nick) anope_override
+ bool IsNickValid(const Anope::string &nick) override
{
if (nick.equals_ci("ircd") || nick.equals_ci("irc"))
return false;
@@ -339,7 +339,7 @@ class UnrealIRCdProto : public IRCDProto
return IRCDProto::IsNickValid(nick);
}
- bool IsChannelValid(const Anope::string &chan) anope_override
+ bool IsChannelValid(const Anope::string &chan) override
{
if (chan.find(':') != Anope::string::npos)
return false;
@@ -347,12 +347,12 @@ class UnrealIRCdProto : public IRCDProto
return IRCDProto::IsChannelValid(chan);
}
- bool IsExtbanValid(const Anope::string &mask) anope_override
+ bool IsExtbanValid(const Anope::string &mask) override
{
return mask.length() >= 4 && mask[0] == '~' && mask[2] == ':';
}
- void SendLogin(User *u, NickAlias *na) anope_override
+ void SendLogin(User *u, NickAlias *na) override
{
/* 3.2.10.4+ treats users logged in with accounts as fully registered, even if -r, so we can not set this here. Just use the timestamp. */
if (Servers::Capab.count("ESVID") > 0 && !na->nc->HasExt("UNCONFIRMED"))
@@ -361,18 +361,18 @@ class UnrealIRCdProto : public IRCDProto
IRCD->SendMode(Config->GetClient("NickServ"), u, "+d %d", u->signon);
}
- void SendLogout(User *u) anope_override
+ void SendLogout(User *u) override
{
IRCD->SendMode(Config->GetClient("NickServ"), u, "+d 0");
}
- void SendChannel(Channel *c) anope_override
+ void SendChannel(Channel *c) override
{
UplinkSocket::Message(Me) << "SJOIN " << c->creation_time << " " << c->name
<< " +" << c->GetModes(true, true) << " :";
}
- void SendSASLMessage(const SASL::Message &message) anope_override
+ void SendSASLMessage(const SASL::Message &message) override
{
size_t p = message.target.find('!');
Anope::string distmask;
@@ -392,7 +392,7 @@ class UnrealIRCdProto : public IRCDProto
UplinkSocket::Message(BotInfo::Find(message.source)) << "SASL " << distmask << " " << message.target << " " << message.type << " " << message.data << (message.ext.empty() ? "" : " " + message.ext);
}
- void SendSVSLogin(const Anope::string &uid, const Anope::string &acc, const Anope::string &vident, const Anope::string &vhost) anope_override
+ void SendSVSLogin(const Anope::string &uid, NickAlias *na) override
{
size_t p = uid.find('!');
Anope::string distmask;
@@ -409,22 +409,20 @@ class UnrealIRCdProto : public IRCDProto
distmask = uid.substr(0, p);
}
- if (!vident.empty())
- UplinkSocket::Message(Me) << "CHGIDENT " << uid << " " << vident;
- if (!vhost.empty())
- UplinkSocket::Message(Me) << "CHGHOST " << uid << " " << vhost;
- UplinkSocket::Message(Me) << "SVSLOGIN " << distmask << " " << uid << " " << acc;
+ if (!na->GetVhostIdent().empty())
+ UplinkSocket::Message(Me) << "CHGIDENT " << uid << " " << na->GetVhostIdent();
+ if (!na->GetVhostHost().empty())
+ UplinkSocket::Message(Me) << "CHGHOST " << uid << " " << na->GetVhostHost();
+ UplinkSocket::Message(Me) << "SVSLOGIN " << distmask << " " << uid << " " << na->nc->display;
}
- bool IsIdentValid(const Anope::string &ident) anope_override
+ bool IsIdentValid(const Anope::string &ident) override
{
if (ident.empty() || ident.length() > Config->GetBlock("networkinfo")->Get<unsigned>("userlen"))
return false;
- for (unsigned i = 0; i < ident.length(); ++i)
+ for (auto c : ident)
{
- const char &c = ident[i];
-
if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || c == '.' || c == '-')
continue;
@@ -448,13 +446,13 @@ class UnrealExtBan : public ChannelModeVirtual<ChannelModeList>
{
}
- ChannelMode *Wrap(Anope::string &param) anope_override
+ ChannelMode *Wrap(Anope::string &param) override
{
param = "~" + Anope::string(ext) + ":" + param;
return ChannelModeVirtual<ChannelModeList>::Wrap(param);
}
- ChannelMode *Unwrap(ChannelMode *cm, Anope::string &param) anope_override
+ ChannelMode *Unwrap(ChannelMode *cm, Anope::string &param) override
{
if (cm->type != MODE_LIST || param.length() < 4 || param[0] != '~' || param[1] != ext || param[2] != ':')
return cm;
@@ -473,7 +471,7 @@ namespace UnrealExtban
{
}
- bool Matches(User *u, const Entry *e) anope_override
+ bool Matches(User *u, const Entry *e) override
{
const Anope::string &mask = e->GetMask();
Anope::string channel = mask.substr(3);
@@ -508,7 +506,7 @@ namespace UnrealExtban
{
}
- bool Matches(User *u, const Entry *e) anope_override
+ bool Matches(User *u, const Entry *e) override
{
const Anope::string &mask = e->GetMask();
Anope::string real_mask = mask.substr(3);
@@ -524,7 +522,7 @@ namespace UnrealExtban
{
}
- bool Matches(User *u, const Entry *e) anope_override
+ bool Matches(User *u, const Entry *e) override
{
const Anope::string &mask = e->GetMask();
Anope::string real_mask = mask.substr(3);
@@ -540,7 +538,7 @@ namespace UnrealExtban
{
}
- bool Matches(User *u, const Entry *e) anope_override
+ bool Matches(User *u, const Entry *e) override
{
const Anope::string &mask = e->GetMask();
return u->HasMode("REGISTERED") && mask.equals_ci(u->nick);
@@ -554,7 +552,7 @@ namespace UnrealExtban
{
}
- bool Matches(User *u, const Entry *e) anope_override
+ bool Matches(User *u, const Entry *e) override
{
const Anope::string &mask = e->GetMask();
Anope::string real_mask = mask.substr(3);
@@ -573,22 +571,22 @@ namespace UnrealExtban
{
}
- bool Matches(User *u, const Entry *e) anope_override
+ bool Matches(User *u, const Entry *e) override
{
const Anope::string &mask = e->GetMask();
Anope::string real_mask = mask.substr(3);
return !u->fingerprint.empty() && Anope::Match(u->fingerprint, real_mask);
}
};
-
+
class OperclassMatcher : public UnrealExtBan
{
public:
OperclassMatcher(const Anope::string &mname, const Anope::string &mbase, char c) : UnrealExtBan(mname, mbase, c)
{
}
-
- bool Matches(User *u, const Entry *e) anope_override
+
+ bool Matches(User *u, const Entry *e) override
{
const Anope::string &mask = e->GetMask();
Anope::string real_mask = mask.substr(3);
@@ -596,15 +594,15 @@ namespace UnrealExtban
return moddata != NULL && moddata->find("operclass") != moddata->end() && Anope::Match((*moddata)["operclass"], real_mask);
}
};
-
+
class TimedBanMatcher : public UnrealExtBan
{
public:
TimedBanMatcher(const Anope::string &mname, const Anope::string &mbase, char c) : UnrealExtBan(mname, mbase, c)
{
}
-
- bool Matches(User *u, const Entry *e) anope_override
+
+ bool Matches(User *u, const Entry *e) override
{
/* strip down the time (~t:1234:) and call other matchers */
const Anope::string &mask = e->GetMask();
@@ -620,8 +618,8 @@ namespace UnrealExtban
CountryMatcher(const Anope::string &mname, const Anope::string &mbase, char c) : UnrealExtBan(mname, mbase, c)
{
}
-
- bool Matches(User *u, const Entry *e) anope_override
+
+ bool Matches(User *u, const Entry *e) override
{
const Anope::string &mask = e->GetMask();
Anope::string real_mask = mask.substr(3);
@@ -639,7 +637,6 @@ namespace UnrealExtban
return false;
}
};
-
}
class ChannelModeFlood : public ChannelModeParam
@@ -648,7 +645,7 @@ class ChannelModeFlood : public ChannelModeParam
ChannelModeFlood(char modeChar, bool minusNoArg) : ChannelModeParam("FLOOD", modeChar, minusNoArg) { }
/* Borrowed part of this check from UnrealIRCd */
- bool IsValid(Anope::string &value) const anope_override
+ bool IsValid(Anope::string &value) const override
{
if (value.empty())
return false;
@@ -698,7 +695,7 @@ class ChannelModeHistory : public ChannelModeParam /* stolen from inspircd3's Co
public:
ChannelModeHistory(char modeChar) : ChannelModeParam("HISTORY", modeChar, true) { }
- bool IsValid(Anope::string &value) const anope_override
+ bool IsValid(Anope::string &value) const override
{
if (value.empty())
return false; // empty param is never valid
@@ -739,7 +736,7 @@ class ChannelModeUnrealSSL : public ChannelMode
{
}
- bool CanSet(User *u) const anope_override
+ bool CanSet(User *u) const override
{
return false;
}
@@ -749,18 +746,16 @@ struct IRCDMessageCapab : Message::Capab
{
IRCDMessageCapab(Module *creator) : Message::Capab(creator, "PROTOCTL") { }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
- for (unsigned i = 0; i < params.size(); ++i)
+ for (const auto &capab : params)
{
- Anope::string capab = params[i];
-
if (capab.find("USERMODES=") != Anope::string::npos)
{
Anope::string modebuf(capab.begin() + 10, capab.end());
- for (size_t t = 0, end = modebuf.length(); t < end; ++t)
+ for (auto mode : modebuf)
{
- switch (modebuf[t])
+ switch (mode)
{
case 'B':
ModeManager::AddUserMode(new UserMode("BOT", 'B'));
@@ -826,7 +821,7 @@ struct IRCDMessageCapab : Message::Capab
ModeManager::AddUserMode(new UserMode("SSLPRIV", 'Z'));
continue;
default:
- ModeManager::AddUserMode(new UserMode("", modebuf[t]));
+ ModeManager::AddUserMode(new UserMode("", mode));
}
}
}
@@ -837,9 +832,9 @@ struct IRCDMessageCapab : Message::Capab
Anope::string modebuf;
sep.GetToken(modebuf);
- for (size_t t = 0, end = modebuf.length(); t < end; ++t)
+ for (auto mode : modebuf)
{
- switch (modebuf[t])
+ switch (mode)
{
case 'b':
ModeManager::AddChannelMode(new ChannelModeList("BAN", 'b'));
@@ -863,14 +858,14 @@ struct IRCDMessageCapab : Message::Capab
ModeManager::AddChannelMode(new ChannelModeList("INVITEOVERRIDE", 'I'));
continue;
default:
- ModeManager::AddChannelMode(new ChannelModeList("", modebuf[t]));
+ ModeManager::AddChannelMode(new ChannelModeList("", mode));
}
}
sep.GetToken(modebuf);
- for (size_t t = 0, end = modebuf.length(); t < end; ++t)
+ for (auto mode : modebuf)
{
- switch (modebuf[t])
+ switch (mode)
{
case 'k':
ModeManager::AddChannelMode(new ChannelModeKey('k'));
@@ -882,14 +877,14 @@ struct IRCDMessageCapab : Message::Capab
ModeManager::AddChannelMode(new ChannelModeParam("REDIRECT", 'L'));
continue;
default:
- ModeManager::AddChannelMode(new ChannelModeParam("", modebuf[t]));
+ ModeManager::AddChannelMode(new ChannelModeParam("", mode));
}
}
sep.GetToken(modebuf);
- for (size_t t = 0, end = modebuf.length(); t < end; ++t)
+ for (auto mode : modebuf)
{
- switch (modebuf[t])
+ switch (mode)
{
case 'l':
ModeManager::AddChannelMode(new ChannelModeParam("LIMIT", 'l', true));
@@ -898,14 +893,14 @@ struct IRCDMessageCapab : Message::Capab
ModeManager::AddChannelMode(new ChannelModeHistory('H'));
continue;
default:
- ModeManager::AddChannelMode(new ChannelModeParam("", modebuf[t], true));
+ ModeManager::AddChannelMode(new ChannelModeParam("", mode, true));
}
}
sep.GetToken(modebuf);
- for (size_t t = 0, end = modebuf.length(); t < end; ++t)
+ for (auto mode : modebuf)
{
- switch (modebuf[t])
+ switch (mode)
{
case 'p':
ModeManager::AddChannelMode(new ChannelMode("PRIVATE", 'p'));
@@ -980,7 +975,7 @@ struct IRCDMessageCapab : Message::Capab
ModeManager::AddChannelMode(new ChannelModeOperOnly("PERM", 'P'));
continue;
default:
- ModeManager::AddChannelMode(new ChannelMode("", modebuf[t]));
+ ModeManager::AddChannelMode(new ChannelMode("", mode));
}
}
}
@@ -995,7 +990,7 @@ struct IRCDMessageCapab : Message::Capab
std::size_t mode_count = modes.find(')');
Anope::string mode_prefixes = modes.substr(0, mode_count);
Anope::string mode_chars = modes.substr(mode_count+1, mode_count);
-
+
for (size_t t = 0, end = mode_chars.length(); t < end; ++t)
{
Anope::string mode_name;
@@ -1026,7 +1021,7 @@ struct IRCDMessageCapab : Message::Capab
}
}
- Message::Capab::Run(source, params);
+ Message::Capab::Run(source, params, tags);
}
};
@@ -1034,7 +1029,7 @@ struct IRCDMessageChgHost : IRCDMessage
{
IRCDMessageChgHost(Module *creator) : IRCDMessage(creator, "CHGHOST", 2) { }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
User *u = User::Find(params[0]);
if (u)
@@ -1046,7 +1041,7 @@ struct IRCDMessageChgIdent : IRCDMessage
{
IRCDMessageChgIdent(Module *creator) : IRCDMessage(creator, "CHGIDENT", 2) { }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
User *u = User::Find(params[0]);
if (u)
@@ -1058,7 +1053,7 @@ struct IRCDMessageChgName : IRCDMessage
{
IRCDMessageChgName(Module *creator) : IRCDMessage(creator, "CHGNAME", 2) { }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
User *u = User::Find(params[0]);
if (u)
@@ -1076,7 +1071,7 @@ struct IRCDMessageMD : IRCDMessage
SetFlag(IRCDMESSAGE_SOFT_LIMIT);
}
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
const Anope::string &mdtype = params[0],
&obj = params[1],
@@ -1089,9 +1084,9 @@ struct IRCDMessageMD : IRCDMessage
if (u == NULL)
return;
-
+
ModData &clientmd = *ClientModData.Require(u);
-
+
if (value.empty())
{
clientmd.erase(var);
@@ -1115,9 +1110,9 @@ struct IRCDMessageMD : IRCDMessage
if (c == NULL)
return;
-
+
ModData &channelmd = *ChannelModData.Require(c);
-
+
if (value.empty())
{
channelmd.erase(var);
@@ -1136,7 +1131,7 @@ struct IRCDMessageMode : IRCDMessage
{
IRCDMessageMode(Module *creator, const Anope::string &mname) : IRCDMessage(creator, mname, 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
bool server_source = source.GetServer() != NULL;
Anope::string modes = params[1];
@@ -1181,7 +1176,7 @@ struct IRCDMessageNetInfo : IRCDMessage
{
IRCDMessageNetInfo(Module *creator) : IRCDMessage(creator, "NETINFO", 8) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
UplinkSocket::Message() << "NETINFO " << MaxUserCount << " " << Anope::CurTime << " " << convertTo<int>(params[2]) << " " << params[3] << " 0 0 0 :" << params[7];
}
@@ -1211,7 +1206,7 @@ struct IRCDMessageNick : IRCDMessage
** parv[0] = new nickname
** parv[1] = hopcount
*/
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
if (params.size() == 11)
{
@@ -1277,7 +1272,7 @@ struct IRCDMessagePong : IRCDMessage
{
IRCDMessagePong(Module *creator) : IRCDMessage(creator, "PONG", 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
if (!source.GetServer()->IsSynced())
source.GetServer()->Sync(false);
@@ -1288,7 +1283,7 @@ struct IRCDMessageSASL : IRCDMessage
{
IRCDMessageSASL(Module *creator) : IRCDMessage(creator, "SASL", 4) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
if (!SASL::sasl)
return;
@@ -1308,7 +1303,7 @@ struct IRCDMessageSDesc : IRCDMessage
{
IRCDMessageSDesc(Module *creator) : IRCDMessage(creator, "SDESC", 1) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
source.GetServer()->SetDescription(params[0]);
}
@@ -1318,7 +1313,7 @@ struct IRCDMessageSetHost : IRCDMessage
{
IRCDMessageSetHost(Module *creator) : IRCDMessage(creator, "SETHOST", 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
User *u = source.GetUser();
@@ -1334,7 +1329,7 @@ struct IRCDMessageSetIdent : IRCDMessage
{
IRCDMessageSetIdent(Module *creator) : IRCDMessage(creator, "SETIDENT", 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
User *u = source.GetUser();
u->SetVIdent(params[0]);
@@ -1345,7 +1340,7 @@ struct IRCDMessageSetName : IRCDMessage
{
IRCDMessageSetName(Module *creator) : IRCDMessage(creator, "SETNAME", 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
User *u = source.GetUser();
u->SetRealname(params[0]);
@@ -1356,7 +1351,7 @@ struct IRCDMessageServer : IRCDMessage
{
IRCDMessageServer(Module *creator) : IRCDMessage(creator, "SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
unsigned int hops = Anope::string(params[1]).is_pos_number_only() ? convertTo<unsigned>(params[1]) : 0;
@@ -1378,7 +1373,7 @@ struct IRCDMessageSID : IRCDMessage
{
IRCDMessageSID(Module *creator) : IRCDMessage(creator, "SID", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
unsigned int hops = Anope::string(params[1]).is_pos_number_only() ? convertTo<unsigned>(params[1]) : 0;
@@ -1405,7 +1400,7 @@ struct IRCDMessageSJoin : IRCDMessage
{
IRCDMessageSJoin(Module *creator) : IRCDMessage(creator, "SJOIN", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
Anope::string modes;
if (params.size() >= 4)
@@ -1476,14 +1471,20 @@ struct IRCDMessageSJoin : IRCDMessage
*invex = ModeManager::FindChannelModeByName("INVITEOVERRIDE");
if (ban)
- for (std::list<Anope::string>::iterator it = bans.begin(), it_end = bans.end(); it != it_end; ++it)
- c->SetModeInternal(source, ban, *it);
+ {
+ for (const auto &entry : bans)
+ c->SetModeInternal(source, ban, entry);
+ }
if (except)
- for (std::list<Anope::string>::iterator it = excepts.begin(), it_end = excepts.end(); it != it_end; ++it)
- c->SetModeInternal(source, except, *it);
+ {
+ for (const auto &entry : excepts)
+ c->SetModeInternal(source, except, entry);
+ }
if (invex)
- for (std::list<Anope::string>::iterator it = invites.begin(), it_end = invites.end(); it != it_end; ++it)
- c->SetModeInternal(source, invex, *it);
+ {
+ for (const auto &entry : invites)
+ c->SetModeInternal(source, invex, entry);
+ }
}
}
};
@@ -1499,7 +1500,7 @@ struct IRCDMessageTopic : IRCDMessage
** parv[2] = topic time
** parv[3] = topic text
*/
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
Channel *c = Channel::Find(params[0]);
if (c)
@@ -1525,7 +1526,7 @@ struct IRCDMessageUID : IRCDMessage
{
IRCDMessageUID(Module *creator) : IRCDMessage(creator, "UID", 12) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
Anope::string
nickname = params[0],
@@ -1594,7 +1595,7 @@ struct IRCDMessageUmode2 : IRCDMessage
{
IRCDMessageUmode2(Module *creator) : IRCDMessage(creator, "UMODE2", 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
source.GetUser()->SetModesInternal(source, "%s", params[0].c_str());
}
@@ -1664,24 +1665,24 @@ class ProtoUnreal : public Module
}
- void Prioritize() anope_override
+ void Prioritize() override
{
ModuleManager::SetPriority(this, PRIORITY_FIRST);
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
use_server_side_mlock = conf->GetModule(this)->Get<bool>("use_server_side_mlock");
}
- void OnUserNickChange(User *u, const Anope::string &) anope_override
+ void OnUserNickChange(User *u, const Anope::string &) override
{
u->RemoveModeInternal(Me, ModeManager::FindUserModeByName("REGISTERED"));
if (Servers::Capab.count("ESVID") == 0)
IRCD->SendLogout(u);
}
- void OnChannelSync(Channel *c) anope_override
+ void OnChannelSync(Channel *c) override
{
if (!c->ci)
return;
@@ -1694,7 +1695,7 @@ class ProtoUnreal : public Module
}
}
- void OnChanRegistered(ChannelInfo *ci) anope_override
+ void OnChanRegistered(ChannelInfo *ci) override
{
ModeLocks *modelocks = ci->GetExt<ModeLocks>("modelocks");
if (!ci->c || !use_server_side_mlock || !modelocks || !Servers::Capab.count("MLOCK"))
@@ -1703,14 +1704,14 @@ class ProtoUnreal : public Module
UplinkSocket::Message(Me) << "MLOCK " << static_cast<long>(ci->c->creation_time) << " " << ci->name << " " << modes;
}
- void OnDelChan(ChannelInfo *ci) anope_override
+ void OnDelChan(ChannelInfo *ci) override
{
if (!ci->c || !use_server_side_mlock || !Servers::Capab.count("MLOCK"))
return;
UplinkSocket::Message(Me) << "MLOCK " << static_cast<long>(ci->c->creation_time) << " " << ci->name << " :";
}
- EventReturn OnMLock(ChannelInfo *ci, ModeLock *lock) anope_override
+ EventReturn OnMLock(ChannelInfo *ci, ModeLock *lock) override
{
ModeLocks *modelocks = ci->GetExt<ModeLocks>("modelocks");
ChannelMode *cm = ModeManager::FindChannelModeByName(lock->name);
@@ -1723,7 +1724,7 @@ class ProtoUnreal : public Module
return EVENT_CONTINUE;
}
- EventReturn OnUnMLock(ChannelInfo *ci, ModeLock *lock) anope_override
+ EventReturn OnUnMLock(ChannelInfo *ci, ModeLock *lock) override
{
ModeLocks *modelocks = ci->GetExt<ModeLocks>("modelocks");
ChannelMode *cm = ModeManager::FindChannelModeByName(lock->name);
@@ -1736,7 +1737,7 @@ class ProtoUnreal : public Module
return EVENT_CONTINUE;
}
- void OnChannelUnban(User *u, ChannelInfo *ci) anope_override
+ void OnChannelUnban(User *u, ChannelInfo *ci) override
{
UplinkSocket::Message(ci->WhoSends()) << "SVS2MODE " << ci->c->name << " -b " << u->GetUID();
/* Unreal will remove all matching bans for us regardless of our internal matching.
diff --git a/modules/pseudoclients/botserv.cpp b/modules/pseudoclients/botserv.cpp
index 9b6e590ac..25cf8ab88 100644
--- a/modules/pseudoclients/botserv.cpp
+++ b/modules/pseudoclients/botserv.cpp
@@ -22,24 +22,24 @@ class BotServCore : public Module
{
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
const Anope::string &bsnick = conf->GetModule(this)->Get<const Anope::string>("client");
BotServ = BotInfo::Find(bsnick, true);
}
- void OnSetCorrectModes(User *user, Channel *chan, AccessGroup &access, bool &give_modes, bool &take_modes) anope_override
+ void OnSetCorrectModes(User *user, Channel *chan, AccessGroup &access, bool &give_modes, bool &take_modes) override
{
/* Do not allow removing bot modes on our service bots */
if (chan->ci && chan->ci->bi == user)
{
const Anope::string &botmodes = Config->GetModule(this)->Get<const Anope::string>("botmodes");
- for (unsigned i = 0; i < botmodes.length(); ++i)
- chan->SetMode(chan->ci->bi, ModeManager::FindChannelModeByChar(botmodes[i]), chan->ci->bi->GetUID());
+ for (auto botmode : botmodes)
+ chan->SetMode(chan->ci->bi, ModeManager::FindChannelModeByChar(botmode), chan->ci->bi->GetUID());
}
}
- void OnBotAssign(User *sender, ChannelInfo *ci, BotInfo *bi) anope_override
+ void OnBotAssign(User *sender, ChannelInfo *ci, BotInfo *bi) override
{
if (ci->c && ci->c->users.size() >= Config->GetModule(this)->Get<unsigned>("minusers"))
{
@@ -48,7 +48,7 @@ class BotServCore : public Module
}
}
- void OnJoinChannel(User *user, Channel *c) anope_override
+ void OnJoinChannel(User *user, Channel *c) override
{
if (!Config || !IRCD)
return;
@@ -56,12 +56,10 @@ class BotServCore : public Module
BotInfo *bi = user->server == Me ? dynamic_cast<BotInfo *>(user) : NULL;
if (bi && Config->GetModule(this)->Get<bool>("smartjoin"))
{
- std::vector<Anope::string> bans = c->GetModeList("BAN");
-
/* We check for bans */
- for (unsigned int i = 0; i < bans.size(); ++i)
+ for (const auto &entry : c->GetModeList("BAN"))
{
- Entry ban("BAN", bans[i]);
+ Entry ban("BAN", entry);
if (ban.Matches(user))
c->RemoveMode(NULL, "BAN", ban.GetMask());
}
@@ -103,7 +101,7 @@ class BotServCore : public Module
}
}
- void OnLeaveChannel(User *u, Channel *c) anope_override
+ void OnLeaveChannel(User *u, Channel *c) override
{
/* Channel is persistent, it shouldn't be deleted and the service bot should stay */
if (c->ci && persist && persist->HasExt(c->ci))
@@ -124,7 +122,7 @@ class BotServCore : public Module
c->ci->bi->Part(c->ci->c);
}
- EventReturn OnPreHelp(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ EventReturn OnPreHelp(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (!params.empty())
return EVENT_CONTINUE;
@@ -159,7 +157,7 @@ class BotServCore : public Module
return EVENT_CONTINUE;
}
- void OnPostHelp(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void OnPostHelp(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (!params.empty() || source.c || source.service != *BotServ)
return;
@@ -174,7 +172,7 @@ class BotServCore : public Module
"one of the following characters: %s"), fantasycharacters.c_str());
}
- EventReturn OnChannelModeSet(Channel *c, MessageSource &source, ChannelMode *mode, const Anope::string &param) anope_override
+ EventReturn OnChannelModeSet(Channel *c, MessageSource &source, ChannelMode *mode, const Anope::string &param) override
{
if (source.GetUser() && !source.GetBot() && Config->GetModule(this)->Get<bool>("smartjoin") && mode->name == "BAN" && c->ci && c->ci->bi && c->FindUser(c->ci->bi))
{
@@ -188,7 +186,7 @@ class BotServCore : public Module
return EVENT_CONTINUE;
}
- void OnCreateChan(ChannelInfo *ci) anope_override
+ void OnCreateChan(ChannelInfo *ci) override
{
/* Set default bot flags */
spacesepstream sep(Config->GetModule(this)->Get<const Anope::string>("defaults", "greet fantasy"));
@@ -196,7 +194,7 @@ class BotServCore : public Module
ci->Extend<bool>("BS_" + token.upper());
}
- void OnUserKicked(const MessageSource &source, User *target, const Anope::string &channel, ChannelStatus &status, const Anope::string &kickmsg) anope_override
+ void OnUserKicked(const MessageSource &source, User *target, const Anope::string &channel, ChannelStatus &status, const Anope::string &kickmsg) override
{
BotInfo *bi = BotInfo::Find(target->GetUID());
if (bi)
@@ -204,7 +202,7 @@ class BotServCore : public Module
bi->Join(channel, &status);
}
- void OnCreateBot(BotInfo *bi) anope_override
+ void OnCreateBot(BotInfo *bi) override
{
if (bi->botmodes.empty())
bi->botmodes = Config->GetModule(this)->Get<const Anope::string>("botumodes");
diff --git a/modules/pseudoclients/chanserv.cpp b/modules/pseudoclients/chanserv.cpp
index 0809a25b3..ca7c7b9ab 100644
--- a/modules/pseudoclients/chanserv.cpp
+++ b/modules/pseudoclients/chanserv.cpp
@@ -25,15 +25,15 @@ class ChanServCore : public Module, public ChanServService
std::vector<Anope::string> defaults;
ExtensibleItem<bool> inhabit;
ExtensibleRef<bool> persist;
- bool always_lower;
+ bool always_lower = false;
public:
ChanServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR),
- ChanServService(this), inhabit(this, "inhabit"), persist("PERSIST"), always_lower(false)
+ ChanServService(this), inhabit(this, "inhabit"), persist("PERSIST")
{
}
- void Hold(Channel *c) anope_override
+ void Hold(Channel *c) override
{
/** A timer used to keep the BotServ bot/ChanServ in the channel
* after kicking the last user in a channel
@@ -68,7 +68,7 @@ class ChanServCore : public Module, public ChanServService
/** Called when the delay is up
* @param The current time
*/
- void Tick(time_t) anope_override
+ void Tick(time_t) override
{
if (!c)
return;
@@ -96,7 +96,7 @@ class ChanServCore : public Module, public ChanServService
new ChanServTimer(ChanServ, inhabit, this->owner, c);
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
const Anope::string &channick = conf->GetModule(this)->Get<const Anope::string>("client");
@@ -112,10 +112,10 @@ class ChanServCore : public Module, public ChanServService
spacesepstream(conf->GetModule(this)->Get<const Anope::string>("defaults", "greet fantasy")).GetTokens(defaults);
if (defaults.empty())
{
- defaults.push_back("KEEPTOPIC");
- defaults.push_back("CS_SECURE");
- defaults.push_back("SECUREFOUNDER");
- defaults.push_back("SIGNKICK");
+ defaults.emplace_back("KEEPTOPIC");
+ defaults.emplace_back("CS_SECURE");
+ defaults.emplace_back("SECUREFOUNDER");
+ defaults.emplace_back("SIGNKICK");
}
else if (defaults[0].equals_ci("none"))
defaults.clear();
@@ -123,13 +123,13 @@ class ChanServCore : public Module, public ChanServService
always_lower = conf->GetModule(this)->Get<bool>("always_lower_ts");
}
- void OnBotDelete(BotInfo *bi) anope_override
+ void OnBotDelete(BotInfo *bi) override
{
if (bi == ChanServ)
ChanServ = NULL;
}
- EventReturn OnBotPrivmsg(User *u, BotInfo *bi, Anope::string &message) anope_override
+ EventReturn OnBotPrivmsg(User *u, BotInfo *bi, Anope::string &message) override
{
if (bi == ChanServ && Config->GetModule(this)->Get<bool>("opersonly") && !u->HasMode("OPER"))
{
@@ -140,16 +140,14 @@ class ChanServCore : public Module, public ChanServService
return EVENT_CONTINUE;
}
- void OnDelCore(NickCore *nc) anope_override
+ void OnDelCore(NickCore *nc) override
{
std::deque<ChannelInfo *> chans;
nc->GetChannelReferences(chans);
int max_reg = Config->GetModule(this)->Get<int>("maxregistered");
- for (unsigned i = 0; i < chans.size(); ++i)
+ for (auto *ci : chans)
{
- ChannelInfo *ci = chans[i];
-
if (ci->GetFounder() == nc)
{
NickCore *newowner = NULL;
@@ -213,16 +211,16 @@ class ChanServCore : public Module, public ChanServService
}
}
- void OnDelChan(ChannelInfo *ci) anope_override
+ void OnDelChan(ChannelInfo *ci) override
{
/* remove access entries that are this channel */
std::deque<Anope::string> chans;
ci->GetChannelReferences(chans);
- for (unsigned i = 0; i < chans.size(); ++i)
+ for (const auto &chan : chans)
{
- ChannelInfo *c = ChannelInfo::Find(chans[i]);
+ ChannelInfo *c = ChannelInfo::Find(chan);
if (!c)
continue;
@@ -248,7 +246,7 @@ class ChanServCore : public Module, public ChanServService
}
}
- EventReturn OnPreHelp(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ EventReturn OnPreHelp(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (!params.empty() || source.c || source.service != *ChanServ)
return EVENT_CONTINUE;
@@ -263,11 +261,11 @@ class ChanServCore : public Module, public ChanServService
return EVENT_CONTINUE;
}
- void OnPostHelp(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void OnPostHelp(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (!params.empty() || source.c || source.service != *ChanServ)
return;
- time_t chanserv_expire = Config->GetModule(this)->Get<time_t>("expire", "14d");
+ time_t chanserv_expire = Config->GetModule(this)->Get<time_t>("expire", "30d");
if (chanserv_expire >= 86400)
source.Reply(_(" \n"
"Note that any channel which is not used for %d days\n"
@@ -280,7 +278,7 @@ class ChanServCore : public Module, public ChanServService
"lists and settings for any channel."));
}
- void OnCheckModes(Reference<Channel> &c) anope_override
+ void OnCheckModes(Reference<Channel> &c) override
{
if (!c)
return;
@@ -300,14 +298,14 @@ class ChanServCore : public Module, public ChanServService
}
}
- void OnCreateChan(ChannelInfo *ci) anope_override
+ void OnCreateChan(ChannelInfo *ci) override
{
/* Set default chan flags */
- for (unsigned i = 0; i < defaults.size(); ++i)
- ci->Extend<bool>(defaults[i].upper());
+ for (const auto &def : defaults)
+ ci->Extend<bool>(def.upper());
}
- EventReturn OnCanSet(User *u, const ChannelMode *cm) anope_override
+ EventReturn OnCanSet(User *u, const ChannelMode *cm) override
{
if (Config->GetModule(this)->Get<const Anope::string>("nomlock").find(cm->mchar) != Anope::string::npos
|| Config->GetModule(this)->Get<const Anope::string>("require").find(cm->mchar) != Anope::string::npos)
@@ -315,7 +313,7 @@ class ChanServCore : public Module, public ChanServService
return EVENT_CONTINUE;
}
- void OnChannelSync(Channel *c) anope_override
+ void OnChannelSync(Channel *c) override
{
bool perm = c->HasMode("PERM") || (c->ci && persist && persist->HasExt(c->ci));
if (!perm && !c->botchannel && (c->users.empty() || (c->users.size() == 1 && c->users.begin()->second->user->server == Me)))
@@ -324,15 +322,15 @@ class ChanServCore : public Module, public ChanServService
}
}
- void OnLog(Log *l) anope_override
+ void OnLog(Log *l) override
{
if (l->type == LOG_CHANNEL)
l->bi = ChanServ;
}
- void OnExpireTick() anope_override
+ void OnExpireTick() override
{
- time_t chanserv_expire = Config->GetModule(this)->Get<time_t>("expire", "14d");
+ time_t chanserv_expire = Config->GetModule(this)->Get<time_t>("expire", "30d");
if (!chanserv_expire || Anope::NoExpire || Anope::ReadOnly)
return;
@@ -368,7 +366,7 @@ class ChanServCore : public Module, public ChanServService
}
}
- EventReturn OnCheckDelete(Channel *c) anope_override
+ EventReturn OnCheckDelete(Channel *c) override
{
/* Do not delete this channel if ChanServ/a BotServ bot is inhabiting it */
if (inhabit.HasExt(c))
@@ -377,7 +375,7 @@ class ChanServCore : public Module, public ChanServService
return EVENT_CONTINUE;
}
- void OnPostInit() anope_override
+ void OnPostInit() override
{
if (!persist)
return;
@@ -385,9 +383,8 @@ class ChanServCore : public Module, public ChanServService
ChannelMode *perm = ModeManager::FindChannelModeByName("PERM");
/* Find all persistent channels and create them, as we are about to finish burst to our uplink */
- for (registered_channel_map::iterator it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; ++it)
+ for (const auto &[_, ci] : *RegisteredChannelList)
{
- ChannelInfo *ci = it->second;
if (!persist->HasExt(ci))
continue;
@@ -413,7 +410,7 @@ class ChanServCore : public Module, public ChanServService
}
- void OnChanRegistered(ChannelInfo *ci) anope_override
+ void OnChanRegistered(ChannelInfo *ci) override
{
if (!persist || !ci->c)
return;
@@ -425,7 +422,7 @@ class ChanServCore : public Module, public ChanServService
ci->c->SetMode(NULL, "PERM");
}
- void OnJoinChannel(User *u, Channel *c) anope_override
+ void OnJoinChannel(User *u, Channel *c) override
{
if (always_lower && c->ci && c->creation_time > c->ci->time_registered)
{
@@ -436,7 +433,7 @@ class ChanServCore : public Module, public ChanServService
}
}
- EventReturn OnChannelModeSet(Channel *c, MessageSource &setter, ChannelMode *mode, const Anope::string &param) anope_override
+ EventReturn OnChannelModeSet(Channel *c, MessageSource &setter, ChannelMode *mode, const Anope::string &param) override
{
if (!always_lower && Anope::CurTime == c->creation_time && c->ci && setter.GetUser() && !setter.GetUser()->server->IsULined())
{
@@ -455,17 +452,17 @@ class ChanServCore : public Module, public ChanServService
return EVENT_CONTINUE;
}
- void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_all) anope_override
+ void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_all) override
{
if (!show_all)
return;
- time_t chanserv_expire = Config->GetModule(this)->Get<time_t>("expire", "14d");
+ time_t chanserv_expire = Config->GetModule(this)->Get<time_t>("expire", "30d");
if (!ci->HasExt("CS_NO_EXPIRE") && chanserv_expire && !Anope::NoExpire && ci->last_used != Anope::CurTime)
info[_("Expires")] = Anope::strftime(ci->last_used + chanserv_expire, source.GetAccount());
}
- void OnSetCorrectModes(User *user, Channel *chan, AccessGroup &access, bool &give_modes, bool &take_modes) anope_override
+ void OnSetCorrectModes(User *user, Channel *chan, AccessGroup &access, bool &give_modes, bool &take_modes) override
{
if (always_lower)
// Since we always lower the TS, the other side will remove the modes if the channel ts lowers, so we don't
diff --git a/modules/pseudoclients/global.cpp b/modules/pseudoclients/global.cpp
index e2159a378..c720282c7 100644
--- a/modules/pseudoclients/global.cpp
+++ b/modules/pseudoclients/global.cpp
@@ -19,8 +19,8 @@ class GlobalCore : public Module, public GlobalService
{
if (s != Me && !s->IsJuped())
s->Notice(sender, message);
- for (unsigned i = 0, j = s->GetLinks().size(); i < j; ++i)
- this->ServerGlobal(sender, s->GetLinks()[i], message);
+ for (auto *link : s->GetLinks())
+ this->ServerGlobal(sender, link, message);
}
public:
@@ -29,12 +29,12 @@ class GlobalCore : public Module, public GlobalService
{
}
- Reference<BotInfo> GetDefaultSender() anope_override
+ Reference<BotInfo> GetDefaultSender() override
{
return Global;
}
- void SendGlobal(BotInfo *sender, const Anope::string &source, const Anope::string &message) anope_override
+ void SendGlobal(BotInfo *sender, const Anope::string &source, const Anope::string &message) override
{
if (Me->GetLinks().empty())
return;
@@ -53,7 +53,7 @@ class GlobalCore : public Module, public GlobalService
this->ServerGlobal(sender, Servers::GetUplink(), rmessage);
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
const Anope::string &glnick = conf->GetModule(this)->Get<const Anope::string>("client");
@@ -67,28 +67,28 @@ class GlobalCore : public Module, public GlobalService
Global = bi;
}
- void OnRestart() anope_override
+ void OnRestart() override
{
const Anope::string &gl = Config->GetModule(this)->Get<const Anope::string>("globaloncycledown");
if (!gl.empty())
this->SendGlobal(Global, "", gl);
}
- void OnShutdown() anope_override
+ void OnShutdown() override
{
const Anope::string &gl = Config->GetModule(this)->Get<const Anope::string>("globaloncycledown");
if (!gl.empty())
this->SendGlobal(Global, "", gl);
}
- void OnNewServer(Server *s) anope_override
+ void OnNewServer(Server *s) override
{
const Anope::string &gl = Config->GetModule(this)->Get<const Anope::string>("globaloncycleup");
if (!gl.empty() && !Me->IsSynced())
s->Notice(Global, gl);
}
- EventReturn OnPreHelp(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ EventReturn OnPreHelp(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (!params.empty() || source.c || source.service != *Global)
return EVENT_CONTINUE;
diff --git a/modules/pseudoclients/hostserv.cpp b/modules/pseudoclients/hostserv.cpp
index bd0574975..4ef1aecfa 100644
--- a/modules/pseudoclients/hostserv.cpp
+++ b/modules/pseudoclients/hostserv.cpp
@@ -21,7 +21,7 @@ class HostServCore : public Module
throw ModuleException("Your IRCd does not support vhosts");
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
const Anope::string &hsnick = conf->GetModule(this)->Get<const Anope::string>("client");
@@ -35,7 +35,7 @@ class HostServCore : public Module
HostServ = bi;
}
- void OnUserLogin(User *u) anope_override
+ void OnUserLogin(User *u) override
{
if (!IRCD->CanSetVHost)
return;
@@ -66,7 +66,7 @@ class HostServCore : public Module
}
}
- void OnNickDrop(CommandSource &source, NickAlias *na) anope_override
+ void OnNickDrop(CommandSource &source, NickAlias *na) override
{
if (na->HasVhost())
{
@@ -75,12 +75,12 @@ class HostServCore : public Module
}
}
- void OnNickUpdate(User *u) anope_override
+ void OnNickUpdate(User *u) override
{
this->OnUserLogin(u);
}
- EventReturn OnPreHelp(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ EventReturn OnPreHelp(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (!params.empty() || source.c || source.service != *HostServ)
return EVENT_CONTINUE;
@@ -88,7 +88,7 @@ class HostServCore : public Module
return EVENT_CONTINUE;
}
- void OnSetVhost(NickAlias *na) anope_override
+ void OnSetVhost(NickAlias *na) override
{
if (Config->GetModule(this)->Get<bool>("activate_on_set"))
{
@@ -115,7 +115,7 @@ class HostServCore : public Module
}
}
- void OnDeleteVhost(NickAlias *na) anope_override
+ void OnDeleteVhost(NickAlias *na) override
{
if (Config->GetModule(this)->Get<bool>("activate_on_set"))
{
diff --git a/modules/pseudoclients/memoserv.cpp b/modules/pseudoclients/memoserv.cpp
index f22556a6e..d6946247f 100644
--- a/modules/pseudoclients/memoserv.cpp
+++ b/modules/pseudoclients/memoserv.cpp
@@ -41,7 +41,7 @@ class MemoServCore : public Module, public MemoServService
{
}
- MemoResult Send(const Anope::string &source, const Anope::string &target, const Anope::string &message, bool force) anope_override
+ MemoResult Send(const Anope::string &source, const Anope::string &target, const Anope::string &message, bool force) override
{
bool ischan;
MemoInfo *mi = MemoInfo::GetMemoInfo(target, ischan);
@@ -94,10 +94,8 @@ class MemoServCore : public Module, public MemoServService
if (ci->c)
{
- for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
+ for (const auto &[_, cu] : ci->c->users)
{
- ChanUserContainer *cu = it->second;
-
if (ci->AccessFor(cu->user).HasPriv("MEMO"))
{
if (cu->user->Account() && cu->user->Account()->HasExt("MEMO_RECEIVE"))
@@ -112,9 +110,8 @@ class MemoServCore : public Module, public MemoServService
if (nc->HasExt("MEMO_RECEIVE"))
{
- for (unsigned i = 0; i < nc->aliases->size(); ++i)
+ for (auto *na : *nc->aliases)
{
- const NickAlias *na = nc->aliases->at(i);
User *user = User::Find(na->nick, true);
if (user && user->IsIdentified())
user->SendMessage(MemoServ, MEMO_NEW_MEMO_ARRIVED, source.c_str(), Config->StrictPrivmsg.c_str(), MemoServ->nick.c_str(), mi->memos->size());
@@ -129,7 +126,7 @@ class MemoServCore : public Module, public MemoServService
return MEMO_SUCCESS;
}
- void Check(User *u) anope_override
+ void Check(User *u) override
{
const NickCore *nc = u->Account();
if (!nc)
@@ -150,7 +147,7 @@ class MemoServCore : public Module, public MemoServService
}
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
const Anope::string &msnick = conf->GetModule(this)->Get<const Anope::string>("client");
@@ -164,28 +161,28 @@ class MemoServCore : public Module, public MemoServService
MemoServ = bi;
}
- void OnNickCoreCreate(NickCore *nc) anope_override
+ void OnNickCoreCreate(NickCore *nc) override
{
nc->memos.memomax = Config->GetModule(this)->Get<int>("maxmemos");
}
- void OnCreateChan(ChannelInfo *ci) anope_override
+ void OnCreateChan(ChannelInfo *ci) override
{
ci->memos.memomax = Config->GetModule(this)->Get<int>("maxmemos");
}
- void OnBotDelete(BotInfo *bi) anope_override
+ void OnBotDelete(BotInfo *bi) override
{
if (bi == MemoServ)
MemoServ = NULL;
}
- void OnNickIdentify(User *u) anope_override
+ void OnNickIdentify(User *u) override
{
this->Check(u);
}
- void OnJoinChannel(User *u, Channel *c) anope_override
+ void OnJoinChannel(User *u, Channel *c) override
{
if (c->ci && !c->ci->memos.memos->empty() && c->ci->AccessFor(u).HasPriv("MEMO"))
{
@@ -196,23 +193,23 @@ class MemoServCore : public Module, public MemoServService
}
}
- void OnUserAway(User *u, const Anope::string &message) anope_override
+ void OnUserAway(User *u, const Anope::string &message) override
{
if (message.empty())
this->Check(u);
}
- void OnNickUpdate(User *u) anope_override
+ void OnNickUpdate(User *u) override
{
this->Check(u);
}
- void OnUserConnect(User *user, bool &exempt) anope_override
+ void OnUserConnect(User *user, bool &exempt) override
{
this->Check(user);
}
- EventReturn OnPreHelp(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ EventReturn OnPreHelp(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (!params.empty() || source.c || source.service != *MemoServ)
return EVENT_CONTINUE;
@@ -225,7 +222,7 @@ class MemoServCore : public Module, public MemoServService
return EVENT_CONTINUE;
}
- void OnPostHelp(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void OnPostHelp(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (!params.empty() || source.c || source.service != *MemoServ)
return;
diff --git a/modules/pseudoclients/nickserv.cpp b/modules/pseudoclients/nickserv.cpp
index 5fa3069ef..4cdb3a238 100644
--- a/modules/pseudoclients/nickserv.cpp
+++ b/modules/pseudoclients/nickserv.cpp
@@ -29,7 +29,7 @@ class NickServCollide : public Timer
collides.insert(this);
}
- ~NickServCollide()
+ ~NickServCollide() override
{
collides.erase(this);
}
@@ -44,7 +44,7 @@ class NickServCollide : public Timer
return na;
}
- void Tick(time_t t) anope_override
+ void Tick(time_t t) override
{
if (!u || !na)
return;
@@ -68,7 +68,7 @@ class NickServHeld : public Timer
n->Extend<bool>("HELD");
}
- void Tick(time_t)
+ void Tick(time_t) override
{
if (na)
na->Shrink<bool>("HELD");
@@ -96,18 +96,18 @@ class NickServRelease : public User, public Timer
delete nit->second;
}
- NickServReleases.insert(std::make_pair(this->nick, this));
+ NickServReleases.emplace(this->nick, this);
IRCD->SendClientIntroduction(this);
}
- ~NickServRelease()
+ ~NickServRelease() override
{
IRCD->SendQuit(this, "");
NickServReleases.erase(this->nick);
}
- void Tick(time_t t) anope_override { }
+ void Tick(time_t t) override { }
};
class NickServCore : public Module, public NickServService
@@ -137,26 +137,26 @@ class NickServCore : public Module, public NickServService
{
}
- ~NickServCore()
+ ~NickServCore() override
{
OnShutdown();
}
- void OnShutdown() anope_override
+ void OnShutdown() override
{
/* On shutdown, restart, or mod unload, remove all of our holds for nicks (svshold or qlines)
* because some IRCds do not allow us to have these automatically expire
*/
- for (nickalias_map::const_iterator it = NickAliasList->begin(); it != NickAliasList->end(); ++it)
- this->Release(it->second);
+ for (const auto &[_, na] : *NickAliasList)
+ this->Release(na);
}
- void OnRestart() anope_override
+ void OnRestart() override
{
OnShutdown();
}
- void Validate(User *u) anope_override
+ void Validate(User *u) override
{
NickAlias *na = NickAlias::Find(u->nick);
if (!na)
@@ -215,7 +215,7 @@ class NickServCore : public Module, public NickServService
}
- void OnUserLogin(User *u) anope_override
+ void OnUserLogin(User *u) override
{
NickAlias *na = NickAlias::Find(u->nick);
if (na && *na->nc == u->Account() && !Config->GetModule("nickserv")->Get<bool>("nonicknameownership") && !na->nc->HasExt("UNCONFIRMED"))
@@ -226,7 +226,7 @@ class NickServCore : public Module, public NickServService
u->SetModes(NickServ, "%s", modesonid.c_str());
}
- void Collide(User *u, NickAlias *na) anope_override
+ void Collide(User *u, NickAlias *na) override
{
if (na)
collided.Set(na);
@@ -259,7 +259,7 @@ class NickServCore : public Module, public NickServService
u->Kill(*NickServ, "Services nickname-enforcer kill");
}
- void Release(NickAlias *na) anope_override
+ void Release(NickAlias *na) override
{
if (held.HasExt(na))
{
@@ -279,7 +279,7 @@ class NickServCore : public Module, public NickServService
collided.Unset(na); /* clear pending collide */
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
const Anope::string &nsnick = conf->GetModule(this)->Get<const Anope::string>("client");
@@ -295,15 +295,15 @@ class NickServCore : public Module, public NickServService
spacesepstream(conf->GetModule(this)->Get<const Anope::string>("defaults", "ns_secure memo_signon memo_receive")).GetTokens(defaults);
if (defaults.empty())
{
- defaults.push_back("NS_SECURE");
- defaults.push_back("MEMO_SIGNON");
- defaults.push_back("MEMO_RECEIVE");
+ defaults.emplace_back("NS_SECURE");
+ defaults.emplace_back("MEMO_SIGNON");
+ defaults.emplace_back("MEMO_RECEIVE");
}
else if (defaults[0].equals_ci("none"))
defaults.clear();
}
- void OnDelNick(NickAlias *na) anope_override
+ void OnDelNick(NickAlias *na) override
{
User *u = User::Find(na->nick);
if (u && u->Account() == na->nc)
@@ -314,7 +314,7 @@ class NickServCore : public Module, public NickServService
}
}
- void OnDelCore(NickCore *nc) anope_override
+ void OnDelCore(NickCore *nc) override
{
Log(NickServ, "nick") << "Deleting nickname group " << nc->display;
@@ -330,24 +330,24 @@ class NickServCore : public Module, public NickServService
nc->users.clear();
}
- void OnChangeCoreDisplay(NickCore *nc, const Anope::string &newdisplay) anope_override
+ void OnChangeCoreDisplay(NickCore *nc, const Anope::string &newdisplay) override
{
Log(LOG_NORMAL, "nick", NickServ) << "Changing " << nc->display << " nickname group display to " << newdisplay;
}
- void OnNickIdentify(User *u) anope_override
+ void OnNickIdentify(User *u) override
{
Configuration::Block *block = Config->GetModule(this);
if (block->Get<bool>("modeonid", "yes"))
-
- for (User::ChanUserList::iterator it = u->chans.begin(), it_end = u->chans.end(); it != it_end; ++it)
+ {
+ for (const auto &[_, cc] : u->chans)
{
- ChanUserContainer *cc = it->second;
Channel *c = cc->chan;
if (c)
c->SetCorrectModes(u, true);
}
+ }
const Anope::string &modesonid = block->Get<const Anope::string>("modesonid");
if (!modesonid.empty())
@@ -363,9 +363,8 @@ class NickServCore : public Module, public NickServService
"any third-party person."), Config->StrictPrivmsg.c_str(), NickServ->nick.c_str());
}
- for (std::set<NickServCollide *>::iterator it = collides.begin(); it != collides.end(); ++it)
+ for (auto *c : collides)
{
- NickServCollide *c = *it;
if (c->GetUser() == u && c->GetNick() && c->GetNick()->nc == u->Account())
{
delete c;
@@ -374,24 +373,23 @@ class NickServCore : public Module, public NickServService
}
}
- void OnNickGroup(User *u, NickAlias *target) anope_override
+ void OnNickGroup(User *u, NickAlias *target) override
{
if (!target->nc->HasExt("UNCONFIRMED"))
u->SetMode(NickServ, "REGISTERED");
}
- void OnNickUpdate(User *u) anope_override
+ void OnNickUpdate(User *u) override
{
- for (User::ChanUserList::iterator it = u->chans.begin(), it_end = u->chans.end(); it != it_end; ++it)
+ for (const auto &[_, cc] : u->chans)
{
- ChanUserContainer *cc = it->second;
Channel *c = cc->chan;
if (c)
c->SetCorrectModes(u, true);
}
}
- void OnUserConnect(User *u, bool &exempt) anope_override
+ void OnUserConnect(User *u, bool &exempt) override
{
if (u->Quitting() || !u->server->IsSynced() || u->server->IsULined())
return;
@@ -405,19 +403,17 @@ class NickServCore : public Module, public NickServService
this->Validate(u);
}
- void OnPostUserLogoff(User *u) anope_override
+ void OnPostUserLogoff(User *u) override
{
NickAlias *na = NickAlias::Find(u->nick);
if (na)
OnCancel(u, na);
}
- void OnServerSync(Server *s) anope_override
+ void OnServerSync(Server *s) override
{
- for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
+ for (const auto &[_, u] : UserListByNick)
{
- User *u = it->second;
-
if (u->server == s)
{
if (u->HasMode("REGISTERED") && !u->IsIdentified(true))
@@ -428,7 +424,7 @@ class NickServCore : public Module, public NickServService
}
}
- void OnUserNickChange(User *u, const Anope::string &oldnick) anope_override
+ void OnUserNickChange(User *u, const Anope::string &oldnick) override
{
NickAlias *old_na = NickAlias::Find(oldnick), *na = NickAlias::Find(u->nick);
/* If the new nick isn't registered or it's registered and not yours */
@@ -452,13 +448,13 @@ class NickServCore : public Module, public NickServService
OnCancel(u, old_na);
}
- void OnUserModeSet(const MessageSource &setter, User *u, const Anope::string &mname) anope_override
+ void OnUserModeSet(const MessageSource &setter, User *u, const Anope::string &mname) override
{
if (u->server->IsSynced() && mname == "REGISTERED" && !u->IsIdentified(true))
u->RemoveMode(NickServ, mname);
}
- EventReturn OnPreHelp(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ EventReturn OnPreHelp(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (!params.empty() || source.c || source.service != *NickServ)
return EVENT_CONTINUE;
@@ -478,7 +474,7 @@ class NickServCore : public Module, public NickServService
return EVENT_CONTINUE;
}
- void OnPostHelp(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ void OnPostHelp(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (!params.empty() || source.c || source.service != *NickServ)
return;
@@ -487,7 +483,7 @@ class NickServCore : public Module, public NickServService
"Services Operators can also drop any nickname without needing\n"
"to identify for the nick, and may view the access list for\n"
"any nickname."));
- time_t nickserv_expire = Config->GetModule(this)->Get<time_t>("expire", "21d");
+ time_t nickserv_expire = Config->GetModule(this)->Get<time_t>("expire", "90d");
if (nickserv_expire >= 86400)
source.Reply(_(" \n"
"Accounts that are not used anymore are subject to\n"
@@ -495,14 +491,14 @@ class NickServCore : public Module, public NickServService
"after %d days if not used."), nickserv_expire / 86400);
}
- void OnNickCoreCreate(NickCore *nc) anope_override
+ void OnNickCoreCreate(NickCore *nc) override
{
/* Set default flags */
- for (unsigned i = 0; i < defaults.size(); ++i)
- nc->Extend<bool>(defaults[i].upper());
+ for (const auto &def : defaults)
+ nc->Extend<bool>(def.upper());
}
- void OnUserQuit(User *u, const Anope::string &msg) anope_override
+ void OnUserQuit(User *u, const Anope::string &msg) override
{
if (u->server && !u->server->GetQuitReason().empty() && Config->GetModule(this)->Get<bool>("hidenetsplitquit"))
return;
@@ -516,12 +512,12 @@ class NickServCore : public Module, public NickServService
}
}
- void OnExpireTick() anope_override
+ void OnExpireTick() override
{
if (Anope::NoExpire || Anope::ReadOnly)
return;
- time_t nickserv_expire = Config->GetModule(this)->Get<time_t>("expire", "21d");
+ time_t nickserv_expire = Config->GetModule(this)->Get<time_t>("expire", "90d");
for (nickalias_map::const_iterator it = NickAliasList->begin(), it_end = NickAliasList->end(); it != it_end; )
{
@@ -548,11 +544,11 @@ class NickServCore : public Module, public NickServService
}
}
- void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_hidden) anope_override
+ void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_hidden) override
{
if (!na->nc->HasExt("UNCONFIRMED"))
{
- time_t nickserv_expire = Config->GetModule(this)->Get<time_t>("expire", "21d");
+ time_t nickserv_expire = Config->GetModule(this)->Get<time_t>("expire", "90d");
if (!na->HasExt("NS_NO_EXPIRE") && nickserv_expire && !Anope::NoExpire && (source.HasPriv("nickserv/auspex") || na->last_seen != Anope::CurTime))
info[_("Expires")] = Anope::strftime(na->last_seen + nickserv_expire, source.GetAccount());
}
diff --git a/modules/pseudoclients/operserv.cpp b/modules/pseudoclients/operserv.cpp
index 2ff184cfd..0d6c719c8 100644
--- a/modules/pseudoclients/operserv.cpp
+++ b/modules/pseudoclients/operserv.cpp
@@ -16,27 +16,27 @@ class SGLineManager : public XLineManager
public:
SGLineManager(Module *creator) : XLineManager(creator, "xlinemanager/sgline", 'G') { }
- void OnMatch(User *u, XLine *x) anope_override
+ void OnMatch(User *u, XLine *x) override
{
this->Send(u, x);
}
- void OnExpire(const XLine *x) anope_override
+ void OnExpire(const XLine *x) override
{
Log(Config->GetClient("OperServ"), "expire/akill") << "AKILL on \002" << x->mask << "\002 has expired";
}
- void Send(User *u, XLine *x) anope_override
+ void Send(User *u, XLine *x) override
{
IRCD->SendAkill(u, x);
}
- void SendDel(XLine *x) anope_override
+ void SendDel(XLine *x) override
{
IRCD->SendAkillDel(x);
}
- bool Check(User *u, const XLine *x) anope_override
+ bool Check(User *u, const XLine *x) override
{
if (x->regex)
{
@@ -70,17 +70,17 @@ class SQLineManager : public XLineManager
public:
SQLineManager(Module *creator) : XLineManager(creator, "xlinemanager/sqline", 'Q'), nickserv("NickServService", "NickServ") { }
- void OnMatch(User *u, XLine *x) anope_override
+ void OnMatch(User *u, XLine *x) override
{
this->Send(u, x);
}
- void OnExpire(const XLine *x) anope_override
+ void OnExpire(const XLine *x) override
{
Log(Config->GetClient("OperServ"), "expire/sqline") << "SQLINE on \002" << x->mask << "\002 has expired";
}
- void Send(User *u, XLine *x) anope_override
+ void Send(User *u, XLine *x) override
{
if (!IRCD->CanSQLine)
{
@@ -105,7 +105,7 @@ class SQLineManager : public XLineManager
}
}
- void SendDel(XLine *x) anope_override
+ void SendDel(XLine *x) override
{
if (!IRCD->CanSQLine || x->IsRegex())
;
@@ -113,7 +113,7 @@ class SQLineManager : public XLineManager
IRCD->SendSQLineDel(x);
}
- bool Check(User *u, const XLine *x) anope_override
+ bool Check(User *u, const XLine *x) override
{
if (x->regex)
return x->regex->Matches(u->nick);
@@ -122,10 +122,8 @@ class SQLineManager : public XLineManager
XLine *CheckChannel(Channel *c)
{
- for (std::vector<XLine *>::const_iterator it = this->GetList().begin(), it_end = this->GetList().end(); it != it_end; ++it)
+ for (auto *x : this->GetList())
{
- XLine *x = *it;
-
if (x->regex)
{
if (x->regex->Matches(c->name))
@@ -149,17 +147,17 @@ class SNLineManager : public XLineManager
public:
SNLineManager(Module *creator) : XLineManager(creator, "xlinemanager/snline", 'N') { }
- void OnMatch(User *u, XLine *x) anope_override
+ void OnMatch(User *u, XLine *x) override
{
this->Send(u, x);
}
- void OnExpire(const XLine *x) anope_override
+ void OnExpire(const XLine *x) override
{
Log(Config->GetClient("OperServ"), "expire/snline") << "SNLINE on \002" << x->mask << "\002 has expired";
}
- void Send(User *u, XLine *x) anope_override
+ void Send(User *u, XLine *x) override
{
if (IRCD->CanSNLine && !x->IsRegex())
IRCD->SendSGLine(u, x);
@@ -168,13 +166,13 @@ class SNLineManager : public XLineManager
u->Kill(Config->GetClient("OperServ"), "SNLined: " + x->reason);
}
- void SendDel(XLine *x) anope_override
+ void SendDel(XLine *x) override
{
if (IRCD->CanSNLine && !x->IsRegex())
IRCD->SendSGLineDel(x);
}
- bool Check(User *u, const XLine *x) anope_override
+ bool Check(User *u, const XLine *x) override
{
if (x->regex)
return x->regex->Matches(u->realname);
@@ -200,7 +198,7 @@ class OperServCore : public Module
XLineManager::RegisterXLineManager(&snlines);
}
- ~OperServCore()
+ ~OperServCore() override
{
this->sglines.Clear();
this->sqlines.Clear();
@@ -211,7 +209,7 @@ class OperServCore : public Module
XLineManager::UnregisterXLineManager(&snlines);
}
- void OnReload(Configuration::Conf *conf) anope_override
+ void OnReload(Configuration::Conf *conf) override
{
const Anope::string &osnick = conf->GetModule(this)->Get<const Anope::string>("client");
@@ -225,7 +223,7 @@ class OperServCore : public Module
OperServ = bi;
}
- EventReturn OnBotPrivmsg(User *u, BotInfo *bi, Anope::string &message) anope_override
+ EventReturn OnBotPrivmsg(User *u, BotInfo *bi, Anope::string &message) override
{
if (bi == OperServ && !u->HasMode("OPER") && Config->GetModule(this)->Get<bool>("opersonly"))
{
@@ -237,37 +235,37 @@ class OperServCore : public Module
return EVENT_CONTINUE;
}
- void OnServerQuit(Server *server) anope_override
+ void OnServerQuit(Server *server) override
{
if (server->IsJuped())
Log(server, "squit", OperServ) << "Received SQUIT for juped server " << server->GetName();
}
- void OnUserModeSet(const MessageSource &setter, User *u, const Anope::string &mname) anope_override
+ void OnUserModeSet(const MessageSource &setter, User *u, const Anope::string &mname) override
{
if (mname == "OPER")
Log(u, "oper", OperServ) << "is now an IRC operator.";
}
- void OnUserModeUnset(const MessageSource &setter, User *u, const Anope::string &mname) anope_override
+ void OnUserModeUnset(const MessageSource &setter, User *u, const Anope::string &mname) override
{
if (mname == "OPER")
Log(u, "oper", OperServ) << "is no longer an IRC operator";
}
- void OnUserConnect(User *u, bool &exempt) anope_override
+ void OnUserConnect(User *u, bool &exempt) override
{
if (!u->Quitting() && !exempt)
XLineManager::CheckAll(u);
}
- void OnUserNickChange(User *u, const Anope::string &oldnick) anope_override
+ void OnUserNickChange(User *u, const Anope::string &oldnick) override
{
if (!u->HasMode("OPER"))
this->sqlines.CheckAllXLines(u);
}
- EventReturn OnCheckKick(User *u, Channel *c, Anope::string &mask, Anope::string &reason) anope_override
+ EventReturn OnCheckKick(User *u, Channel *c, Anope::string &mask, Anope::string &reason) override
{
XLine *x = this->sqlines.CheckChannel(c);
if (x)
@@ -280,7 +278,7 @@ class OperServCore : public Module
return EVENT_CONTINUE;
}
- EventReturn OnPreHelp(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ EventReturn OnPreHelp(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (!params.empty() || source.c || source.service != *OperServ)
return EVENT_CONTINUE;
@@ -288,7 +286,7 @@ class OperServCore : public Module
return EVENT_CONTINUE;
}
- void OnLog(Log *l) anope_override
+ void OnLog(Log *l) override
{
if (l->type == LOG_SERVER)
l->bi = OperServ;
diff --git a/modules/third/language/CMakeLists.txt b/modules/third/language/CMakeLists.txt
index 85278f5be..b20982cfc 100644
--- a/modules/third/language/CMakeLists.txt
+++ b/modules/third/language/CMakeLists.txt
@@ -1,8 +1,8 @@
# Only do this if gettext is installed
-if(GETTEXT_FOUND)
+if(HAVE_LOCALIZATION)
# Get all of the .po files
file(GLOB LANG_SRCS_PO RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.*.po")
- sort_list(LANG_SRCS_PO)
+ list(SORT LANG_SRCS_PO)
foreach(LANG_PO ${LANG_SRCS_PO})
# Get the domain for this language file
@@ -26,13 +26,13 @@ if(GETTEXT_FOUND)
# Add to cpack ignored files if not on Windows.
if(NOT WIN32)
add_to_cpack_ignored_files("${LANG_MO}")
- endif(NOT WIN32)
+ endif()
# Install the new language file
install(CODE "FILE(MAKE_DIRECTORY ${LOCALE_DIR}/${LANG_LANG}/LC_MESSAGES/)")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${LANG_MO} DESTINATION ${LOCALE_DIR}/${LANG_LANG}/LC_MESSAGES RENAME ${LANG_DOMAIN}.mo PERMISSIONS ${PERMS})
- endforeach(LANG_PO)
+ endforeach()
# Generate languages, depends on the mo files
add_custom_target(module_language DEPENDS ${LANG_SRCS_MO})
-endif(GETTEXT_FOUND)
+endif()
diff --git a/modules/webcpanel/pages/chanserv/access.cpp b/modules/webcpanel/pages/chanserv/access.cpp
index 7aec7a6ee..6422aa9b3 100644
--- a/modules/webcpanel/pages/chanserv/access.cpp
+++ b/modules/webcpanel/pages/chanserv/access.cpp
@@ -52,7 +52,7 @@ bool WebCPanel::ChanServ::Access::OnRequest(HTTPProvider *server, const Anope::s
{
std::vector<Anope::string> params;
params.push_back(ci->name);
- params.push_back("DEL");
+ params.emplace_back("DEL");
params.push_back(message.get_data["mask"]);
WebPanel::RunCommand(client, na->nc->display, na->nc, "ChanServ", "chanserv/access", params, replacements);
@@ -65,7 +65,7 @@ bool WebCPanel::ChanServ::Access::OnRequest(HTTPProvider *server, const Anope::s
{
std::vector<Anope::string> params;
params.push_back(ci->name);
- params.push_back("ADD");
+ params.emplace_back("ADD");
params.push_back(message.post_data["mask"]);
params.push_back(message.post_data["access"]);
@@ -75,7 +75,7 @@ bool WebCPanel::ChanServ::Access::OnRequest(HTTPProvider *server, const Anope::s
{
std::vector<Anope::string> params;
params.push_back(ci->name);
- params.push_back("ADD");
+ params.emplace_back("ADD");
params.push_back(message.post_data["mask"]);
WebPanel::RunCommandWithName(client, na->nc, "ChanServ", "chanserv/xop", message.post_data["access"], params, replacements);
@@ -84,7 +84,7 @@ bool WebCPanel::ChanServ::Access::OnRequest(HTTPProvider *server, const Anope::s
{
std::vector<Anope::string> params;
params.push_back(ci->name);
- params.push_back("MODIFY");
+ params.emplace_back("MODIFY");
params.push_back(message.post_data["mask"]);
params.push_back(message.post_data["access"]);
diff --git a/modules/webcpanel/pages/chanserv/access.h b/modules/webcpanel/pages/chanserv/access.h
index 01ea423e7..26cba776b 100644
--- a/modules/webcpanel/pages/chanserv/access.h
+++ b/modules/webcpanel/pages/chanserv/access.h
@@ -5,6 +5,8 @@
* Please read COPYING and README for further details.
*/
+#pragma once
+
namespace WebCPanel
{
@@ -16,9 +18,9 @@ class Access : public WebPanelProtectedPage
public:
Access(const Anope::string &cat, const Anope::string &u);
- bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) anope_override;
+ bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override;
- std::set<Anope::string> GetData() anope_override;
+ std::set<Anope::string> GetData() override;
};
}
diff --git a/modules/webcpanel/pages/chanserv/akick.cpp b/modules/webcpanel/pages/chanserv/akick.cpp
index 7a11eb5aa..533f4dc42 100644
--- a/modules/webcpanel/pages/chanserv/akick.cpp
+++ b/modules/webcpanel/pages/chanserv/akick.cpp
@@ -50,7 +50,7 @@ bool WebCPanel::ChanServ::Akick::OnRequest(HTTPProvider *server, const Anope::st
{
std::vector<Anope::string> params;
params.push_back(ci->name);
- params.push_back("DEL");
+ params.emplace_back("DEL");
params.push_back(message.get_data["mask"]);
WebPanel::RunCommand(client, na->nc->display, na->nc, "ChanServ", "chanserv/akick", params, replacements);
@@ -59,7 +59,7 @@ bool WebCPanel::ChanServ::Akick::OnRequest(HTTPProvider *server, const Anope::st
{
std::vector<Anope::string> params;
params.push_back(ci->name);
- params.push_back("ADD");
+ params.emplace_back("ADD");
params.push_back(message.post_data["mask"]);
if (message.post_data["reason"].empty() == false)
params.push_back(message.post_data["reason"]);
diff --git a/modules/webcpanel/pages/chanserv/akick.h b/modules/webcpanel/pages/chanserv/akick.h
index a902fe13e..b53383445 100644
--- a/modules/webcpanel/pages/chanserv/akick.h
+++ b/modules/webcpanel/pages/chanserv/akick.h
@@ -5,6 +5,8 @@
* Please read COPYING and README for further details.
*/
+#pragma once
+
namespace WebCPanel
{
@@ -16,9 +18,9 @@ class Akick : public WebPanelProtectedPage
public:
Akick(const Anope::string &cat, const Anope::string &u);
- bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) anope_override;
+ bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override;
- std::set<Anope::string> GetData() anope_override;
+ std::set<Anope::string> GetData() override;
};
}
diff --git a/modules/webcpanel/pages/chanserv/drop.cpp b/modules/webcpanel/pages/chanserv/drop.cpp
index 3416635d7..57be2055d 100644
--- a/modules/webcpanel/pages/chanserv/drop.cpp
+++ b/modules/webcpanel/pages/chanserv/drop.cpp
@@ -33,9 +33,8 @@ bool WebCPanel::ChanServ::Drop::OnRequest(HTTPProvider *server, const Anope::str
std::deque<ChannelInfo *> queue;
na->nc->GetChannelReferences(queue);
- for (unsigned i = 0; i < queue.size(); ++i)
+ for (auto *ci : queue)
{
- ChannelInfo *ci = queue[i];
if ((ci->HasExt("SECUREFOUNDER") ? ci->AccessFor(na->nc).founder : ci->AccessFor(na->nc).HasPriv("FOUNDER")) || (na->nc->IsServicesOper() && na->nc->o->ot->HasCommand("chanserv/drop")))
{
replacements["CHANNEL_NAMES"] = ci->name;
diff --git a/modules/webcpanel/pages/chanserv/drop.h b/modules/webcpanel/pages/chanserv/drop.h
index 035be5f39..51b6ba2a3 100644
--- a/modules/webcpanel/pages/chanserv/drop.h
+++ b/modules/webcpanel/pages/chanserv/drop.h
@@ -5,6 +5,8 @@
* Please read COPYING and README for further details.
*/
+#pragma once
+
namespace WebCPanel
{
@@ -16,7 +18,7 @@ namespace WebCPanel
public:
Drop(const Anope::string &cat, const Anope::string &u);
- bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) anope_override;
+ bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override;
};
diff --git a/modules/webcpanel/pages/chanserv/info.h b/modules/webcpanel/pages/chanserv/info.h
index 6a87ccb8f..c9fd670a4 100644
--- a/modules/webcpanel/pages/chanserv/info.h
+++ b/modules/webcpanel/pages/chanserv/info.h
@@ -5,6 +5,8 @@
* Please read COPYING and README for further details.
*/
+#pragma once
+
namespace WebCPanel
{
@@ -16,7 +18,7 @@ class Info : public WebPanelProtectedPage
public:
Info(const Anope::string &cat, const Anope::string &u);
- bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) anope_override;
+ bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override;
};
}
diff --git a/modules/webcpanel/pages/chanserv/modes.cpp b/modules/webcpanel/pages/chanserv/modes.cpp
index 67d6d0ca8..7e3de86d2 100644
--- a/modules/webcpanel/pages/chanserv/modes.cpp
+++ b/modules/webcpanel/pages/chanserv/modes.cpp
@@ -57,10 +57,8 @@ bool WebCPanel::ChanServ::Modes::OnRequest(HTTPProvider *server, const Anope::st
replacements["MODE"] = "YES";
/* build a list with the names of all listmodes */
- for (unsigned i = 0; i < ModeManager::GetChannelModes().size(); ++i)
+ for (auto *cm : ModeManager::GetChannelModes())
{
- ChannelMode *cm = ModeManager::GetChannelModes()[i];
-
if (cm->type == MODE_LIST && cm->mchar)
replacements["LISTMODES"] = cm->mchar;
}
@@ -79,7 +77,7 @@ bool WebCPanel::ChanServ::Modes::OnRequest(HTTPProvider *server, const Anope::st
{
std::vector<Anope::string> params;
params.push_back(ci->name);
- params.push_back("SET");
+ params.emplace_back("SET");
params.push_back("-" + Anope::string(cm->mchar));
params.push_back(message.get_data["mask"]);
WebPanel::RunCommand(client, na->nc->display, na->nc, "ChanServ", "chanserv/mode", params, replacements);
@@ -88,15 +86,14 @@ bool WebCPanel::ChanServ::Modes::OnRequest(HTTPProvider *server, const Anope::st
{
std::vector<Anope::string> params;
params.push_back(ci->name);
- params.push_back("SET");
+ params.emplace_back("SET");
params.push_back("+" + Anope::string(cm->mchar));
params.push_back(message.post_data["mask"]);
WebPanel::RunCommand(client, na->nc->display, na->nc, "ChanServ", "chanserv/mode", params, replacements);
}
- std::vector<Anope::string> v = c->GetModeList(cm->name);
- for (unsigned int i = 0; i < v.size(); ++i)
- replacements["MASKS"] = v[i];
+ for (const auto &mask : c->GetModeList(cm->name))
+ replacements["MASKS"] = mask;
}
Page.Serve(server, page_name, client, message, reply, replacements);
diff --git a/modules/webcpanel/pages/chanserv/modes.h b/modules/webcpanel/pages/chanserv/modes.h
index cf811e916..345e0022d 100644
--- a/modules/webcpanel/pages/chanserv/modes.h
+++ b/modules/webcpanel/pages/chanserv/modes.h
@@ -5,6 +5,8 @@
* Please read COPYING and README for further details.
*/
+#pragma once
+
namespace WebCPanel
{
@@ -16,9 +18,9 @@ class Modes : public WebPanelProtectedPage
public:
Modes(const Anope::string &cat, const Anope::string &u);
- bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) anope_override;
+ bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override;
- std::set<Anope::string> GetData() anope_override;
+ std::set<Anope::string> GetData() override;
};
}
diff --git a/modules/webcpanel/pages/chanserv/set.h b/modules/webcpanel/pages/chanserv/set.h
index fe6ab3de0..d715aa795 100644
--- a/modules/webcpanel/pages/chanserv/set.h
+++ b/modules/webcpanel/pages/chanserv/set.h
@@ -5,6 +5,8 @@
* Please read COPYING and README for further details.
*/
+#pragma once
+
namespace WebCPanel
{
@@ -16,9 +18,9 @@ class Set : public WebPanelProtectedPage
public:
Set(const Anope::string &cat, const Anope::string &u);
- bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) anope_override;
+ bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override;
- std::set<Anope::string> GetData() anope_override;
+ std::set<Anope::string> GetData() override;
};
}
diff --git a/modules/webcpanel/pages/chanserv/utils.cpp b/modules/webcpanel/pages/chanserv/utils.cpp
index 35b302ba6..c0b300541 100644
--- a/modules/webcpanel/pages/chanserv/utils.cpp
+++ b/modules/webcpanel/pages/chanserv/utils.cpp
@@ -27,10 +27,8 @@ void BuildChanList(NickAlias *na, TemplateFileServer::Replacements &replacements
na->nc->GetChannelReferences(queue);
std::sort(queue.begin(), queue.end(), ChannelSort);
- for (unsigned i = 0; i < queue.size(); ++i)
+ for (auto *ci : queue)
{
- ChannelInfo *ci = queue[i];
-
if (na->nc != ci->GetFounder() && ci->AccessFor(na->nc).empty())
continue;
diff --git a/modules/webcpanel/pages/chanserv/utils.h b/modules/webcpanel/pages/chanserv/utils.h
index 0a9575c77..162f24ad3 100644
--- a/modules/webcpanel/pages/chanserv/utils.h
+++ b/modules/webcpanel/pages/chanserv/utils.h
@@ -5,6 +5,8 @@
* Please read COPYING and README for further details.
*/
+#pragma once
+
namespace WebCPanel
{
diff --git a/modules/webcpanel/pages/confirm.h b/modules/webcpanel/pages/confirm.h
index 97809e471..b1f26d58d 100644
--- a/modules/webcpanel/pages/confirm.h
+++ b/modules/webcpanel/pages/confirm.h
@@ -5,6 +5,8 @@
* Please read COPYING and README for further details.
*/
+#pragma once
+
#include "modules/httpd.h"
namespace WebCPanel
@@ -15,7 +17,7 @@ class Confirm : public WebPanelPage
public:
Confirm(const Anope::string &u) : WebPanelPage(u) { }
- bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &) anope_override;
+ bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &) override;
};
}
diff --git a/modules/webcpanel/pages/hostserv/request.h b/modules/webcpanel/pages/hostserv/request.h
index 6b30a07e2..d508c447f 100644
--- a/modules/webcpanel/pages/hostserv/request.h
+++ b/modules/webcpanel/pages/hostserv/request.h
@@ -5,6 +5,8 @@
* Please read COPYING and README for further details.
*/
+#pragma once
+
namespace WebCPanel
{
@@ -16,7 +18,7 @@ class Request : public WebPanelProtectedPage
public:
Request(const Anope::string &cat, const Anope::string &u);
- bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) anope_override;
+ bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override;
};
}
diff --git a/modules/webcpanel/pages/index.cpp b/modules/webcpanel/pages/index.cpp
index 606616834..2ba78db02 100644
--- a/modules/webcpanel/pages/index.cpp
+++ b/modules/webcpanel/pages/index.cpp
@@ -19,7 +19,7 @@ class WebpanelRequest : public IdentifyRequest
public:
WebpanelRequest(Module *o, HTTPReply &r, HTTPMessage &m, HTTPProvider *s, const Anope::string &p_n, HTTPClient *c, TemplateFileServer::Replacements &re, const Anope::string &user, const Anope::string &pass) : IdentifyRequest(o, user, pass), reply(r), message(m), server(s), page_name(p_n), client(c), replacements(re) { }
- void OnSuccess() anope_override
+ void OnSuccess() override
{
if (!client || !server)
return;
@@ -60,15 +60,15 @@ class WebpanelRequest : public IdentifyRequest
{
HTTPReply::cookie c;
- c.push_back(std::make_pair("account", na->nick));
- c.push_back(std::make_pair("Path", "/"));
+ c.emplace_back("account", na->nick);
+ c.emplace_back("Path", "/");
reply.cookies.push_back(c);
}
{
HTTPReply::cookie c;
- c.push_back(std::make_pair("id", id));
- c.push_back(std::make_pair("Path", "/"));
+ c.emplace_back("id", id);
+ c.emplace_back("Path", "/");
reply.cookies.push_back(c);
}
@@ -78,7 +78,7 @@ class WebpanelRequest : public IdentifyRequest
client->SendReply(&reply);
}
- void OnFail() anope_override
+ void OnFail() override
{
if (!client || !server)
return;
diff --git a/modules/webcpanel/pages/index.h b/modules/webcpanel/pages/index.h
index 868e3b2f3..1f6102a4c 100644
--- a/modules/webcpanel/pages/index.h
+++ b/modules/webcpanel/pages/index.h
@@ -5,6 +5,8 @@
* Please read COPYING and README for further details.
*/
+#pragma once
+
#include "modules/httpd.h"
namespace WebCPanel
@@ -15,12 +17,12 @@ class Index : public WebPanelPage
static const int FLUSH_TIME = 60;
Anope::hash_map<time_t> last_login_attempt;
- time_t last_clear;
+ time_t last_clear = 0;
public:
- Index(const Anope::string &u) : WebPanelPage(u), last_clear(0) { }
+ Index(const Anope::string &u) : WebPanelPage(u) { }
- bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &) anope_override;
+ bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &) override;
};
}
diff --git a/modules/webcpanel/pages/logout.h b/modules/webcpanel/pages/logout.h
index 266bfe353..5e05a1aed 100644
--- a/modules/webcpanel/pages/logout.h
+++ b/modules/webcpanel/pages/logout.h
@@ -5,6 +5,8 @@
* Please read COPYING and README for further details.
*/
+#pragma once
+
namespace WebCPanel
{
@@ -13,7 +15,7 @@ class Logout : public WebPanelProtectedPage
public:
Logout(const Anope::string &u);
- bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) anope_override;
+ bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override;
};
}
diff --git a/modules/webcpanel/pages/memoserv/memos.cpp b/modules/webcpanel/pages/memoserv/memos.cpp
index b191f8e31..d134820b4 100644
--- a/modules/webcpanel/pages/memoserv/memos.cpp
+++ b/modules/webcpanel/pages/memoserv/memos.cpp
@@ -18,9 +18,9 @@ bool WebCPanel::MemoServ::Memos::OnRequest(HTTPProvider *server, const Anope::st
const MemoInfo *mi;
Memo *m;
- for (registered_channel_map::const_iterator it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; ++it)
+ for (const auto &[_, ci2] : *RegisteredChannelList)
{
- ci = it->second;
+ ci = ci2;
if (ci->AccessFor(na->nc).HasPriv("MEMO"))
{
diff --git a/modules/webcpanel/pages/memoserv/memos.h b/modules/webcpanel/pages/memoserv/memos.h
index 419719fe2..59cb46e84 100644
--- a/modules/webcpanel/pages/memoserv/memos.h
+++ b/modules/webcpanel/pages/memoserv/memos.h
@@ -5,6 +5,8 @@
* Please read COPYING and README for further details.
*/
+#pragma once
+
namespace WebCPanel
{
@@ -16,7 +18,7 @@ class Memos : public WebPanelProtectedPage
public:
Memos(const Anope::string &cat, const Anope::string &u);
- bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) anope_override;
+ bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override;
};
}
diff --git a/modules/webcpanel/pages/nickserv/access.cpp b/modules/webcpanel/pages/nickserv/access.cpp
index 33b2851b8..0614009dc 100644
--- a/modules/webcpanel/pages/nickserv/access.cpp
+++ b/modules/webcpanel/pages/nickserv/access.cpp
@@ -16,7 +16,7 @@ bool WebCPanel::NickServ::Access::OnRequest(HTTPProvider *server, const Anope::s
if (message.post_data.count("access") > 0)
{
std::vector<Anope::string> params;
- params.push_back("ADD");
+ params.emplace_back("ADD");
params.push_back(message.post_data["access"]);
WebPanel::RunCommand(client, na->nc->display, na->nc, "NickServ", "nickserv/access", params, replacements);
@@ -24,14 +24,14 @@ bool WebCPanel::NickServ::Access::OnRequest(HTTPProvider *server, const Anope::s
else if (message.get_data.count("del") > 0 && message.get_data.count("mask") > 0)
{
std::vector<Anope::string> params;
- params.push_back("DEL");
+ params.emplace_back("DEL");
params.push_back(message.get_data["mask"]);
WebPanel::RunCommand(client, na->nc->display, na->nc, "NickServ", "nickserv/access", params, replacements);
}
- for (unsigned i = 0; i < na->nc->access.size(); ++i)
- replacements["ACCESS"] = na->nc->access[i];
+ for (const auto &access : na->nc->access)
+ replacements["ACCESS"] = access;
TemplateFileServer page("nickserv/access.html");
page.Serve(server, page_name, client, message, reply, replacements);
diff --git a/modules/webcpanel/pages/nickserv/access.h b/modules/webcpanel/pages/nickserv/access.h
index 9aea45df6..031d1778f 100644
--- a/modules/webcpanel/pages/nickserv/access.h
+++ b/modules/webcpanel/pages/nickserv/access.h
@@ -5,6 +5,8 @@
* Please read COPYING and README for further details.
*/
+#pragma once
+
namespace WebCPanel
{
@@ -16,7 +18,7 @@ class Access : public WebPanelProtectedPage
public:
Access(const Anope::string &cat, const Anope::string &u);
- bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) anope_override;
+ bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override;
};
}
diff --git a/modules/webcpanel/pages/nickserv/alist.cpp b/modules/webcpanel/pages/nickserv/alist.cpp
index 924323e05..71320f7d9 100644
--- a/modules/webcpanel/pages/nickserv/alist.cpp
+++ b/modules/webcpanel/pages/nickserv/alist.cpp
@@ -24,10 +24,8 @@ bool WebCPanel::NickServ::Alist::OnRequest(HTTPProvider *server, const Anope::st
int chan_count = 0;
- for (unsigned q = 0; q < queue.size(); ++q)
+ for (auto *ci : queue)
{
- ChannelInfo *ci = queue[q];
-
if (ci->GetFounder() == na->nc)
{
++chan_count;
diff --git a/modules/webcpanel/pages/nickserv/alist.h b/modules/webcpanel/pages/nickserv/alist.h
index 1659babfa..8822492e0 100644
--- a/modules/webcpanel/pages/nickserv/alist.h
+++ b/modules/webcpanel/pages/nickserv/alist.h
@@ -5,6 +5,8 @@
* Please read COPYING and README for further details.
*/
+#pragma once
+
namespace WebCPanel
{
@@ -16,7 +18,7 @@ class Alist : public WebPanelProtectedPage
public:
Alist(const Anope::string &cat, const Anope::string &u);
- bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) anope_override;
+ bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override;
};
}
diff --git a/modules/webcpanel/pages/nickserv/cert.cpp b/modules/webcpanel/pages/nickserv/cert.cpp
index 49d5ab514..9d72ddbb8 100644
--- a/modules/webcpanel/pages/nickserv/cert.cpp
+++ b/modules/webcpanel/pages/nickserv/cert.cpp
@@ -17,7 +17,7 @@ bool WebCPanel::NickServ::Cert::OnRequest(HTTPProvider *server, const Anope::str
if (message.post_data.count("certfp") > 0)
{
std::vector<Anope::string> params;
- params.push_back("ADD");
+ params.emplace_back("ADD");
params.push_back(message.post_data["certfp"]);
WebPanel::RunCommand(client, na->nc->display, na->nc, "NickServ", "nickserv/cert", params, replacements);
@@ -25,7 +25,7 @@ bool WebCPanel::NickServ::Cert::OnRequest(HTTPProvider *server, const Anope::str
else if (message.get_data.count("del") > 0 && message.get_data.count("mask") > 0)
{
std::vector<Anope::string> params;
- params.push_back("DEL");
+ params.emplace_back("DEL");
params.push_back(message.get_data["mask"]);
WebPanel::RunCommand(client, na->nc->display, na->nc, "NickServ", "nickserv/cert", params, replacements);
diff --git a/modules/webcpanel/pages/nickserv/cert.h b/modules/webcpanel/pages/nickserv/cert.h
index 0db2c2d03..2c249bae1 100644
--- a/modules/webcpanel/pages/nickserv/cert.h
+++ b/modules/webcpanel/pages/nickserv/cert.h
@@ -5,6 +5,8 @@
* Please read COPYING and README for further details.
*/
+#pragma once
+
namespace WebCPanel
{
@@ -16,7 +18,7 @@ class Cert : public WebPanelProtectedPage
public:
Cert(const Anope::string &cat, const Anope::string &u);
- bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) anope_override;
+ bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override;
};
}
diff --git a/modules/webcpanel/pages/nickserv/confirm.h b/modules/webcpanel/pages/nickserv/confirm.h
index 1dac43710..e89f500ef 100644
--- a/modules/webcpanel/pages/nickserv/confirm.h
+++ b/modules/webcpanel/pages/nickserv/confirm.h
@@ -16,7 +16,7 @@ class Confirm : public WebPanelProtectedPage
public:
Confirm(const Anope::string &cat, const Anope::string &u);
- bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) anope_override;
+ bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override;
};
}
diff --git a/modules/webcpanel/pages/nickserv/info.h b/modules/webcpanel/pages/nickserv/info.h
index 36a76fef5..12f889b16 100644
--- a/modules/webcpanel/pages/nickserv/info.h
+++ b/modules/webcpanel/pages/nickserv/info.h
@@ -5,6 +5,8 @@
* Please read COPYING and README for further details.
*/
+#pragma once
+
namespace WebCPanel
{
@@ -16,7 +18,7 @@ class Info : public WebPanelProtectedPage
public:
Info(const Anope::string &cat, const Anope::string &u);
- bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) anope_override;
+ bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override;
};
}
diff --git a/modules/webcpanel/pages/operserv/akill.cpp b/modules/webcpanel/pages/operserv/akill.cpp
index 361924cad..affd25468 100644
--- a/modules/webcpanel/pages/operserv/akill.cpp
+++ b/modules/webcpanel/pages/operserv/akill.cpp
@@ -29,18 +29,18 @@ bool WebCPanel::OperServ::Akill::OnRequest(HTTPProvider *server, const Anope::st
{
std::vector<Anope::string> params;
std::stringstream cmdstr;
- params.push_back("ADD");
+ params.emplace_back("ADD");
cmdstr << "+" << HTTPUtils::URLDecode(message.post_data["expiry"]);
cmdstr << " " << HTTPUtils::URLDecode(message.post_data["mask"]);
cmdstr << " " << HTTPUtils::URLDecode(message.post_data["reason"]);
- params.push_back(cmdstr.str());
+ params.emplace_back(cmdstr.str());
WebPanel::RunCommand(client, na->nc->display, na->nc, "OperServ", "operserv/akill", params, replacements);
}
if (message.get_data["del"] == "1" && message.get_data.count("number") > 0)
{
std::vector<Anope::string> params;
- params.push_back("DEL");
+ params.emplace_back("DEL");
params.push_back(HTTPUtils::URLDecode(message.get_data["number"]));
WebPanel::RunCommand(client, na->nc->display, na->nc, "OperServ", "operserv/akill", params, replacements);
}
diff --git a/modules/webcpanel/pages/operserv/akill.h b/modules/webcpanel/pages/operserv/akill.h
index eac47dc33..c830f6930 100644
--- a/modules/webcpanel/pages/operserv/akill.h
+++ b/modules/webcpanel/pages/operserv/akill.h
@@ -5,6 +5,8 @@
* Please read COPYING and README for further details.
*/
+#pragma once
+
namespace WebCPanel
{
@@ -16,7 +18,7 @@ class Akill : public WebPanelProtectedPage
public:
Akill(const Anope::string &cat, const Anope::string &u);
- bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) anope_override;
+ bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override;
};
}
diff --git a/modules/webcpanel/pages/register.h b/modules/webcpanel/pages/register.h
index 4b9ccc20b..fd8cb46f2 100644
--- a/modules/webcpanel/pages/register.h
+++ b/modules/webcpanel/pages/register.h
@@ -5,6 +5,8 @@
* Please read COPYING and README for further details.
*/
+#pragma once
+
#include "modules/httpd.h"
namespace WebCPanel
@@ -15,7 +17,7 @@ class Register : public WebPanelPage
public:
Register(const Anope::string &u) : WebPanelPage(u) { }
- bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &) anope_override;
+ bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &) override;
};
}
diff --git a/modules/webcpanel/static_fileserver.cpp b/modules/webcpanel/static_fileserver.cpp
index 19f298a50..550330abe 100644
--- a/modules/webcpanel/static_fileserver.cpp
+++ b/modules/webcpanel/static_fileserver.cpp
@@ -6,8 +6,8 @@
*/
#include "webcpanel.h"
+#include <cerrno>
#include <fstream>
-#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
diff --git a/modules/webcpanel/static_fileserver.h b/modules/webcpanel/static_fileserver.h
index c69267312..512177d1a 100644
--- a/modules/webcpanel/static_fileserver.h
+++ b/modules/webcpanel/static_fileserver.h
@@ -5,6 +5,8 @@
* Please read COPYING and README for further details.
*/
+#pragma once
+
#include "modules/httpd.h"
/* A basic file server. Used for serving static content on disk. */
@@ -14,5 +16,5 @@ class StaticFileServer : public HTTPPage
public:
StaticFileServer(const Anope::string &f_n, const Anope::string &u, const Anope::string &c_t);
- bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &) anope_override;
+ bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &) override;
};
diff --git a/modules/webcpanel/template_fileserver.cpp b/modules/webcpanel/template_fileserver.cpp
index 384fbe126..da390bad8 100644
--- a/modules/webcpanel/template_fileserver.cpp
+++ b/modules/webcpanel/template_fileserver.cpp
@@ -6,9 +6,9 @@
*/
#include "webcpanel.h"
+#include <cerrno>
#include <fstream>
#include <stack>
-#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -25,28 +25,24 @@ struct ForLoop
ForLoop(size_t s, TemplateFileServer::Replacements &r, const std::vector<Anope::string> &v, const std::vector<Anope::string> &r_names) : start(s), vars(v)
{
- for (unsigned i = 0; i < r_names.size(); ++i)
- ranges.push_back(r.equal_range(r_names[i]));
+ for (const auto &r_name : r_names)
+ ranges.push_back(r.equal_range(r_name));
}
void increment(const TemplateFileServer::Replacements &r)
{
- for (unsigned i = 0; i < ranges.size(); ++i)
+ for (auto &[begin, end] : ranges)
{
- range &ra = ranges[i];
-
- if (ra.first != r.end() && ra.first != ra.second)
- ++ra.first;
+ if (begin != r.end() && begin != end)
+ ++begin;
}
}
bool finished(const TemplateFileServer::Replacements &r) const
{
- for (unsigned i = 0; i < ranges.size(); ++i)
+ for (const auto &[begin, end] : ranges)
{
- const range &ra = ranges[i];
-
- if (ra.first != r.end() && ra.first != ra.second)
+ if (begin != r.end() && begin != end)
return false;
}
@@ -186,7 +182,7 @@ void TemplateFileServer::Serve(HTTPProvider *server, const Anope::string &page_n
if (temp_variables.size() != real_variables.size())
Log() << "Invalid FOR in web template " << this->file_name << " variable mismatch";
else
- ForLoop::Stack.push_back(ForLoop(j + f, r, temp_variables, real_variables));
+ ForLoop::Stack.emplace_back(j + f, r, temp_variables, real_variables);
}
}
else if (content == "END FOR")
diff --git a/modules/webcpanel/template_fileserver.h b/modules/webcpanel/template_fileserver.h
index b564aa623..21483765c 100644
--- a/modules/webcpanel/template_fileserver.h
+++ b/modules/webcpanel/template_fileserver.h
@@ -5,6 +5,8 @@
* Please read COPYING and README for further details.
*/
+#pragma once
+
#include "modules/httpd.h"
/* A basic file server. Used for serving non-static non-binary content on disk. */
@@ -16,7 +18,7 @@ class TemplateFileServer
{
Anope::string& operator[](const Anope::string &key)
{
- return insert(std::make_pair(key, ""))->second;
+ return emplace(key, "")->second;
}
};
diff --git a/modules/webcpanel/webcpanel.cpp b/modules/webcpanel/webcpanel.cpp
index 394cf0a6b..b381eecdc 100644
--- a/modules/webcpanel/webcpanel.cpp
+++ b/modules/webcpanel/webcpanel.cpp
@@ -202,7 +202,7 @@ class ModuleWebCPanel : public Module
}
}
- ~ModuleWebCPanel()
+ ~ModuleWebCPanel() override
{
if (provider)
{
@@ -267,7 +267,7 @@ namespace WebPanel
MyComandReply(TemplateFileServer::Replacements &_r, const Anope::string &_k) : re(_r), k(_k) { }
- void SendMessage(BotInfo *source, const Anope::string &msg) anope_override
+ void SendMessage(BotInfo *source, const Anope::string &msg) override
{
re[k] = msg;
}
@@ -307,7 +307,7 @@ namespace WebPanel
MyComandReply(TemplateFileServer::Replacements &_r, const Anope::string &_k) : re(_r), k(_k) { }
- void SendMessage(BotInfo *source, const Anope::string &msg) anope_override
+ void SendMessage(BotInfo *source, const Anope::string &msg) override
{
re[k] = msg;
}
diff --git a/modules/webcpanel/webcpanel.h b/modules/webcpanel/webcpanel.h
index 21bdecd1a..e432264c8 100644
--- a/modules/webcpanel/webcpanel.h
+++ b/modules/webcpanel/webcpanel.h
@@ -5,6 +5,8 @@
* Please read COPYING and README for further details.
*/
+#pragma once
+
#include "module.h"
#include "modules/httpd.h"
@@ -80,7 +82,7 @@ class WebPanelProtectedPage : public WebPanelPage
{
}
- bool OnRequest(HTTPProvider *provider, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply) anope_override anope_final
+ bool OnRequest(HTTPProvider *provider, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply) override final
{
ServiceReference<Panel> panel("Panel", "webcpanel");
NickAlias *na;
@@ -103,16 +105,17 @@ class WebPanelProtectedPage : public WebPanelPage
Anope::string sections, get;
- for (std::map<Anope::string, Anope::string>::iterator it = message.get_data.begin(), it_end = message.get_data.end(); it != it_end; ++it)
- if (this->GetData().count(it->first) > 0)
- get += "&" + it->first + "=" + HTTPUtils::URLEncode(it->second);
+ for (const auto &[key, value] : message.get_data)
+ {
+ if (this->GetData().count(key) > 0)
+ get += "&" + key + "=" + HTTPUtils::URLEncode(value);
+ }
if (get.empty() == false)
get = "?" + get.substr(1);
Section *ns = NULL;
- for (unsigned i = 0; i < panel->sections.size(); ++i)
+ for (auto &s : panel->sections)
{
- Section& s = panel->sections[i];
if (s.name == this->category)
ns = &s;
replacements["CATEGORY_URLS"] = s.subsections[0].url;
@@ -122,9 +125,8 @@ class WebPanelProtectedPage : public WebPanelPage
if (ns)
{
sections = "";
- for (unsigned i = 0; i < ns->subsections.size(); ++i)
+ for (const auto &ss : ns->subsections)
{
- SubSection& ss = ns->subsections[i];
replacements["SUBCATEGORY_URLS"] = ss.url;
replacements["SUBCATEGORY_GETS"] = get;
replacements["SUBCATEGORY_NAMES"] = ss.name;
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b390d164b..80207756c 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -2,72 +2,48 @@
file(GLOB SRC_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cpp")
if(WIN32)
- append_to_list(SRC_SRCS win32/dir/dir.cpp)
- append_to_list(SRC_SRCS win32/socket.cpp)
- append_to_list(SRC_SRCS win32/windows.cpp)
- append_to_list(SRC_SRCS win32/dl/dl.cpp)
- append_to_list(SRC_SRCS win32/pipe/pipe.cpp)
- append_to_list(SRC_SRCS win32/pthread/pthread.cpp)
- append_to_list(SRC_SRCS win32/sigaction/sigaction.cpp)
-endif(WIN32)
+ list(APPEND SRC_SRCS win32/socket.cpp)
+ list(APPEND SRC_SRCS win32/windows.cpp)
+ list(APPEND SRC_SRCS win32/dl/dl.cpp)
+ list(APPEND SRC_SRCS win32/pipe/pipe.cpp)
+ list(APPEND SRC_SRCS win32/pthread/pthread.cpp)
+ list(APPEND SRC_SRCS win32/sigaction/sigaction.cpp)
+endif()
if(HAVE_EPOLL)
- append_to_list(SRC_SRCS socketengines/socketengine_epoll.cpp)
-else(HAVE_EPOLL)
- if(HAVE_KQUEUE)
- append_to_list(SRC_SRCS socketengines/socketengine_kqueue.cpp)
- else(HAVE_KQUEUE)
- if(HAVE_POLL)
- append_to_list(SRC_SRCS socketengines/socketengine_poll.cpp)
- else(HAVE_POLL)
- append_to_list(SRC_SRCS socketengines/socketengine_select.cpp)
- endif(HAVE_POLL)
- endif(HAVE_KQUEUE)
-endif(HAVE_EPOLL)
+ list(APPEND SRC_SRCS socketengines/socketengine_epoll.cpp)
+elseif(HAVE_KQUEUE)
+ list(APPEND SRC_SRCS socketengines/socketengine_kqueue.cpp)
+elseif(HAVE_POLL)
+ list(APPEND SRC_SRCS socketengines/socketengine_poll.cpp)
+else()
+ list(APPEND SRC_SRCS socketengines/socketengine_select.cpp)
+endif()
-sort_list(SRC_SRCS)
+list(SORT SRC_SRCS)
# Set all the files to use C++ as well as set their compile flags (use the module-specific compile flags, though)
set_source_files_properties(${SRC_SRCS} PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${CXXFLAGS}")
-# Create an empty list to store extra include directories
-set(EXTRA_INCLUDES)
-# Iterate through all the source files
-foreach(SRC ${SRC_SRCS})
- # Temporary variable for the current source's include directories
- set(TEMP_INCLUDES)
- # Calculate the header file dependencies for the given source file
- calculate_depends(${SRC} TEMP_INCLUDES)
- # If there were some extra include directories, add them to the list
- if(TEMP_INCLUDES)
- append_to_list(EXTRA_INCLUDES ${TEMP_INCLUDES})
- endif(TEMP_INCLUDES)
-endforeach(SRC)
-# If there were extra include directories, remove the duplicates and add the directories to the include path
-if(EXTRA_INCLUDES)
- remove_list_duplicates(EXTRA_INCLUDES)
- include_directories(${EXTRA_INCLUDES})
-endif(EXTRA_INCLUDES)
-
# Under Windows, we also include a resource file to the build
if(WIN32)
# Make sure that the resource file is seen as an RC file to be compiled with a resource compiler, not a C++ compiler
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/win32/win32.rc LANGUAGE RC)
# Add the resource file to the list of sources
- append_to_list(SRC_SRCS ${CMAKE_CURRENT_BINARY_DIR}/win32/win32.rc)
+ list(APPEND SRC_SRCS ${CMAKE_CURRENT_BINARY_DIR}/win32/win32.rc)
# For MinGW, we have to change the compile flags
if(MINGW)
set(RC_CFLAGS "-DMINGW -Ocoff -I${Anope_SOURCE_DIR}/include")
# If any sort of debugging is being enabled, add a _DEBUG define to the flags for the resource compiler
if(CMAKE_BUILD_TYPE STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO")
set(RC_CFLAGS "${RC_CFLAGS} -D_DEBUG")
- endif(CMAKE_BUILD_TYPE STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO")
+ endif()
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/win32/win32.rc COMPILE_FLAGS "${RC_CFLAGS}")
# For anything else, assumingly Visual Studio at this point, use a different set of compile flags
- else(MINGW)
+ else()
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/win32/win32.rc COMPILE_FLAGS "/i\"${Anope_SOURCE_DIR}/include\"")
- endif(MINGW)
-endif(WIN32)
+ endif()
+endif()
# If compiling with Visual Studio, create a static library out of win32/win32_memory.cpp to be included with everything else, needed to override its override of new/delete operators
if(MSVC)
@@ -75,29 +51,36 @@ if(MSVC)
add_library(win32_memory STATIC win32/win32_memory.cpp)
set(WIN32_MEMORY win32_memory)
set(EXTRA_LDFLAGS "/OPT:NOREF") # https://sourceware.org/bugzilla/show_bug.cgi?id=12633
-else(MSVC)
+else()
set(WIN32_MEMORY)
-endif(MSVC)
+endif()
# Generate the Anope executable and set it's linker flags, also set it to export it's symbols even though it's not a module
add_executable(${PROGRAM_NAME} ${SRC_SRCS})
set_target_properties(${PROGRAM_NAME} PROPERTIES LINKER_LANGUAGE CXX LINK_FLAGS "${LDFLAGS} ${EXTRA_LDFLAGS}" ENABLE_EXPORTS ON INSTALL_RPATH_USE_LINK_PATH ON BUILD_WITH_INSTALL_RPATH ON)
+
# On Windows, also link Anope to the wsock32 and Ws2_32 library, as well as set the version
if(WIN32)
- target_link_libraries(${PROGRAM_NAME} wsock32 Ws2_32 ${LINK_LIBS} ${GETTEXT_LIBRARIES} ${WIN32_MEMORY})
+ target_link_libraries(${PROGRAM_NAME} wsock32 Ws2_32 ${LINK_LIBS} ${WIN32_MEMORY})
set_target_properties(${PROGRAM_NAME} PROPERTIES VERSION "${VERSION_DOTTED}")
-else(WIN32)
- target_link_libraries(${PROGRAM_NAME} ${LINK_LIBS} ${GETTEXT_LIBRARIES})
-endif(WIN32)
+else()
+ target_link_libraries(${PROGRAM_NAME} ${LINK_LIBS})
+endif()
+
+# If being built with localisation we might need to link against libintl.
+if(HAVE_LOCALIZATION AND Intl_LIBRARY)
+ target_link_libraries(${PROGRAM_NAME} ${Intl_LIBRARY})
+endif()
+
# Building the Anope executable requires the version.h header to be generated
add_dependencies(${PROGRAM_NAME} headers)
# Also require the language files if we have gettext
-if(GETTEXT_FOUND)
+if(HAVE_LOCALIZATION)
add_dependencies(${PROGRAM_NAME} language)
-endif(GETTEXT_FOUND)
+endif()
# Get the filename of the Anope executable as it is in on this system
-get_target_property(SERVICES_BINARY ${PROGRAM_NAME} LOCATION)
+set(SERVICES_BINARY "$<TARGET_FILE:${PROGRAM_NAME}>")
get_filename_component(SERVICES_BINARY ${SERVICES_BINARY} NAME)
# Add the Anope executable to the list of files for CPack to ignore
add_to_cpack_ignored_files("${SERVICES_BINARY}$" TRUE)
@@ -108,7 +91,7 @@ configure_file(${Anope_SOURCE_DIR}/include/sysconf.h.cmake ${Anope_BINARY_DIR}/i
# Go into the following directories and run their CMakeLists.txt as well
if(NOT DISABLE_TOOLS)
add_subdirectory(tools)
-endif(NOT DISABLE_TOOLS)
+endif()
# Set Anope to be installed to the bin directory
install(TARGETS ${PROGRAM_NAME}
diff --git a/src/access.cpp b/src/access.cpp
index 68fd0777d..063280809 100644
--- a/src/access.cpp
+++ b/src/access.cpp
@@ -62,9 +62,13 @@ static struct
Privilege::Privilege(const Anope::string &n, const Anope::string &d, int r) : name(n), desc(d), rank(r)
{
if (this->desc.empty())
- for (unsigned j = 0; j < sizeof(descriptions) / sizeof(*descriptions); ++j)
- if (descriptions[j].name.equals_ci(name))
- this->desc = descriptions[j].desc;
+ {
+ for (const auto &description : descriptions)
+ {
+ if (description.name.equals_ci(name))
+ this->desc = description.desc;
+ }
+ }
}
bool Privilege::operator==(const Privilege &other) const
@@ -94,10 +98,10 @@ void PrivilegeManager::RemovePrivilege(Privilege &p)
if (it != Privileges.end())
Privileges.erase(it);
- for (registered_channel_map::const_iterator cit = RegisteredChannelList->begin(), cit_end = RegisteredChannelList->end(); cit != cit_end; ++cit)
+ for (const auto &[_, ci] : *RegisteredChannelList)
{
- cit->second->QueueUpdate();
- cit->second->RemoveLevel(p.name);
+ ci->QueueUpdate();
+ ci->RemoveLevel(p.name);
}
}
@@ -211,6 +215,7 @@ void ChanAccess::Serialize(Serialize::Data &data) const
data["ci"] << this->ci->name;
data["mask"] << this->Mask();
data["creator"] << this->creator;
+ data["description"] << this->description;
data.SetType("last_seen", Serialize::Data::DT_INT); data["last_seen"] << this->last_seen;
data.SetType("created", Serialize::Data::DT_INT); data["created"] << this->created;
data["data"] << this->AccessSerialize();
@@ -238,6 +243,7 @@ Serializable* ChanAccess::Unserialize(Serializable *obj, Serialize::Data &data)
data["mask"] >> m;
access->SetMask(m, ci);
data["creator"] >> access->creator;
+ data["description"] >> access->description;
data["last_seen"] >> access->last_seen;
data["created"] >> access->created;
@@ -268,9 +274,8 @@ bool ChanAccess::Matches(const User *u, const NickCore *acc, ChannelInfo* &next)
if (acc)
{
- for (unsigned i = 0; i < acc->aliases->size(); ++i)
+ for (auto *na : *acc->aliases)
{
- const NickAlias *na = acc->aliases->at(i);
if (Anope::Match(na->nick, this->mask))
return true;
}
@@ -340,10 +345,8 @@ static bool HasPriv(const ChanAccess::Path &path, const Anope::string &name)
if (path.empty())
return false;
- for (unsigned int i = 0; i < path.size(); ++i)
+ for (auto *access : path)
{
- ChanAccess *access = path[i];
-
EventReturn MOD_RESULT;
FOREACH_RESULT(OnCheckPriv, MOD_RESULT, (access, name));
@@ -390,9 +393,9 @@ static ChanAccess *HighestInPath(const ChanAccess::Path &path)
{
ChanAccess *highest = NULL;
- for (unsigned int i = 0; i < path.size(); ++i)
- if (highest == NULL || *path[i] > *highest)
- highest = path[i];
+ for (auto *ca : path)
+ if (highest == NULL || *ca > *highest)
+ highest = ca;
return highest;
}
@@ -401,9 +404,9 @@ const ChanAccess *AccessGroup::Highest() const
{
ChanAccess *highest = NULL;
- for (unsigned int i = 0; i < paths.size(); ++i)
+ for (const auto &path : paths)
{
- ChanAccess *hip = HighestInPath(paths[i]);
+ ChanAccess *hip = HighestInPath(path);
if (highest == NULL || *hip > *highest)
highest = hip;
diff --git a/src/account.cpp b/src/account.cpp
index dc5d68d28..df05eb046 100644
--- a/src/account.cpp
+++ b/src/account.cpp
@@ -18,7 +18,7 @@
std::set<IdentifyRequest *> IdentifyRequest::Requests;
-IdentifyRequest::IdentifyRequest(Module *o, const Anope::string &acc, const Anope::string &pass) : owner(o), account(acc), password(pass), dispatched(false), success(false)
+IdentifyRequest::IdentifyRequest(Module *o, const Anope::string &acc, const Anope::string &pass) : owner(o), account(acc), password(pass)
{
Requests.insert(this);
}
diff --git a/src/base.cpp b/src/base.cpp
index 82a45c633..31b85a41c 100644
--- a/src/base.cpp
+++ b/src/base.cpp
@@ -13,16 +13,12 @@
std::map<Anope::string, std::map<Anope::string, Service *> > Service::Services;
std::map<Anope::string, std::map<Anope::string, Anope::string> > Service::Aliases;
-Base::Base() : references(NULL)
-{
-}
-
Base::~Base()
{
if (this->references != NULL)
{
- for (std::set<ReferenceBase *>::iterator it = this->references->begin(), it_end = this->references->end(); it != it_end; ++it)
- (*it)->Invalidate();
+ for (auto *reference : *this->references)
+ reference->Invalidate();
delete this->references;
}
}
diff --git a/src/bots.cpp b/src/bots.cpp
index 6e78cd5d2..3a658ee17 100644
--- a/src/bots.cpp
+++ b/src/bots.cpp
@@ -131,8 +131,8 @@ void BotInfo::OnKill()
IRCD->SendClientIntroduction(this);
this->introduced = true;
- for (User::ChanUserList::const_iterator cit = this->chans.begin(), cit_end = this->chans.end(); cit != cit_end; ++cit)
- IRCD->SendJoin(this, cit->second->chan, &cit->second->status);
+ for (const auto &[_, chan] : this->chans)
+ IRCD->SendJoin(this, chan->chan, &chan->status);
}
void BotInfo::SetNewNick(const Anope::string &newnick)
diff --git a/src/channels.cpp b/src/channels.cpp
index 8a1f89081..5c6ba55e7 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -71,25 +71,23 @@ void Channel::Reset()
{
this->modes.clear();
- for (ChanUserList::const_iterator it = this->users.begin(), it_end = this->users.end(); it != it_end; ++it)
+ for (const auto &[_, uc] : this->users)
{
- ChanUserContainer *uc = it->second;
-
ChannelStatus f = uc->status;
uc->status.Clear();
/* reset modes for my clients */
if (uc->user->server == Me)
{
- for (size_t i = 0; i < f.Modes().length(); ++i)
- this->SetMode(NULL, ModeManager::FindChannelModeByChar(f.Modes()[i]), uc->user->GetUID(), false);
+ for (auto mode : f.Modes())
+ this->SetMode(NULL, ModeManager::FindChannelModeByChar(mode), uc->user->GetUID(), false);
/* Modes might not exist yet, so be sure the status is really reset */
uc->status = f;
}
}
- for (ChanUserList::const_iterator it = this->users.begin(), it_end = this->users.end(); it != it_end; ++it)
- this->SetCorrectModes(it->second->user, true);
+ for (auto &[_, cuc] : this->users)
+ this->SetCorrectModes(cuc->user, true);
// If the channel is syncing now, do not force a sync due to Reset(), as we are probably iterating over users in Message::SJoin
// A sync will come soon
@@ -203,10 +201,12 @@ size_t Channel::HasMode(const Anope::string &mname, const Anope::string &param)
{
if (param.empty())
return modes.count(mname);
- std::vector<Anope::string> v = this->GetModeList(mname);
- for (unsigned int i = 0; i < v.size(); ++i)
- if (v[i].equals_ci(param))
+
+ for (const auto &mode : this->GetModeList(mname))
+ {
+ if (mode.equals_ci(param))
return 1;
+ }
return 0;
}
@@ -214,22 +214,22 @@ Anope::string Channel::GetModes(bool complete, bool plus)
{
Anope::string res, params;
- for (std::multimap<Anope::string, Anope::string>::const_iterator it = this->modes.begin(), it_end = this->modes.end(); it != it_end; ++it)
+ for (const auto &[mode, value] : this->modes)
{
- ChannelMode *cm = ModeManager::FindChannelModeByName(it->first);
+ ChannelMode *cm = ModeManager::FindChannelModeByName(mode);
if (!cm || cm->type == MODE_LIST)
continue;
res += cm->mchar;
- if (complete && !it->second.empty())
+ if (complete && !value.empty())
{
ChannelModeParam *cmp = NULL;
if (cm->type == MODE_PARAM)
cmp = anope_dynamic_static_cast<ChannelModeParam *>(cm);
if (plus || !cmp || !cmp->minus_no_arg)
- params += " " + it->second;
+ params += " " + value;
}
}
@@ -304,7 +304,7 @@ void Channel::SetModeInternal(MessageSource &setter, ChannelMode *ocm, const Ano
else if (this->HasMode(cm->name, param))
return;
- this->modes.insert(std::make_pair(cm->name, param));
+ this->modes.emplace(cm->name, param);
if (param.empty() && cm->type != MODE_REGULAR)
{
@@ -728,10 +728,9 @@ bool Channel::MatchesList(User *u, const Anope::string &mode)
if (!this->HasMode(mode))
return false;
- std::vector<Anope::string> v = this->GetModeList(mode);
- for (unsigned i = 0; i < v.size(); ++i)
+ for (const auto &entry : this->GetModeList(mode))
{
- Entry e(mode, v[i]);
+ Entry e(mode, entry);
if (e.Matches(u))
return true;
}
@@ -845,9 +844,8 @@ void Channel::SetCorrectModes(User *user, bool give_modes)
bool giving = give_modes;
/* whether or not we have given a mode */
bool given = false;
- for (unsigned i = 0; i < ModeManager::GetStatusChannelModesByRank().size(); ++i)
+ for (auto *cm : ModeManager::GetStatusChannelModesByRank())
{
- ChannelModeStatus *cm = ModeManager::GetStatusChannelModesByRank()[i];
bool has_priv = u_access.HasPriv("AUTO" + cm->name);
if (give_modes && has_priv)
@@ -880,10 +878,9 @@ bool Channel::Unban(User *u, const Anope::string &mode, bool full)
bool ret = false;
- std::vector<Anope::string> v = this->GetModeList(mode);
- for (unsigned int i = 0; i < v.size(); ++i)
+ for (const auto &entry : this->GetModeList(mode))
{
- Entry ban(mode, v[i]);
+ Entry ban(mode, entry);
if (ban.Matches(u, full))
{
this->RemoveMode(NULL, mode, ban.GetMask());
@@ -967,10 +964,8 @@ void Channel::QueueForDeletion()
void Channel::DeleteChannels()
{
- for (unsigned int i = 0; i < deleting.size(); ++i)
+ for (auto *c : deleting)
{
- Channel *c = deleting[i];
-
if (c->CheckDelete())
delete c;
}
diff --git a/src/command.cpp b/src/command.cpp
index d51836b22..4205fc4a6 100644
--- a/src/command.cpp
+++ b/src/command.cpp
@@ -122,10 +122,6 @@ Command::Command(Module *o, const Anope::string &sname, size_t minparams, size_t
allow_unregistered = require_user = false;
}
-Command::~Command()
-{
-}
-
void Command::SetDesc(const Anope::string &d)
{
this->desc = d;
@@ -292,15 +288,10 @@ bool Command::FindCommandFromService(const Anope::string &command_service, BotIn
{
bot = NULL;
- for (botinfo_map::iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it)
+ for (const auto &[_, bi] : *BotListByNick)
{
- BotInfo *bi = it->second;
-
- for (CommandInfo::map::const_iterator cit = bi->commands.begin(), cit_end = bi->commands.end(); cit != cit_end; ++cit)
+ for (const auto &[c_name, info] : bi->commands)
{
- const Anope::string &c_name = cit->first;
- const CommandInfo &info = cit->second;
-
if (info.name != command_service)
continue;
diff --git a/src/config.cpp b/src/config.cpp
index 8413e59f5..08b82bbc2 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -21,7 +21,7 @@ using Configuration::File;
using Configuration::Conf;
using Configuration::Internal::Block;
-File ServicesConf("services.conf", false); // Services configuration file name
+File ServicesConf("anope.conf", false); // Configuration file name
Conf *Config = NULL;
Block Block::EmptyBlock("");
@@ -66,9 +66,9 @@ bool Block::Set(const Anope::string &tag, const Anope::string &value)
return true;
}
-const Block::item_map* Block::GetItems() const
+const Block::item_map &Block::GetItems() const
{
- return &items;
+ return items;
}
template<> const Anope::string Block::Get(const Anope::string &tag, const Anope::string& def) const
@@ -154,9 +154,11 @@ Conf::Conf() : Block("")
{"networkinfo", "chanlen"},
};
- for (unsigned i = 0; i < sizeof(noreload) / sizeof(noreload[0]); ++i)
- if (this->GetBlock(noreload[i].block)->Get<const Anope::string>(noreload[i].name) != Config->GetBlock(noreload[i].block)->Get<const Anope::string>(noreload[i].name))
- throw ConfigException("<" + noreload[i].block + ":" + noreload[i].name + "> can not be modified once set");
+ for (const auto &tag : noreload)
+ {
+ if (this->GetBlock(tag.block)->Get<const Anope::string>(tag.name) != Config->GetBlock(tag.block)->Get<const Anope::string>(tag.name))
+ throw ConfigException("<" + tag.block + ":" + tag.name + "> can not be modified once set");
+ }
}
const Block *serverinfo = this->GetBlock("serverinfo"), *options = this->GetBlock("options"),
@@ -186,8 +188,8 @@ Conf::Conf() : Block("")
if (mail->Get<bool>("usemail"))
{
Anope::string check[] = { "sendmailpath", "sendfrom", "registration_subject", "registration_message", "emailchange_subject", "emailchange_message", "memo_subject", "memo_message" };
- for (unsigned i = 0; i < sizeof(check) / sizeof(Anope::string); ++i)
- ValidateNotEmpty("mail", check[i], mail->Get<const Anope::string>(check[i]));
+ for (const auto &field : check)
+ ValidateNotEmpty("mail", field, mail->Get<const Anope::string>(field));
}
this->ReadTimeout = options->Get<time_t>("readtimeout");
@@ -207,19 +209,33 @@ Conf::Conf() : Block("")
{
const Block *uplink = this->GetBlock("uplink", i);
- const Anope::string &host = uplink->Get<const Anope::string>("host");
- bool ipv6 = uplink->Get<bool>("ipv6");
- int port = uplink->Get<int>("port");
- const Anope::string &password = uplink->Get<const Anope::string>("password");
+ int protocol;
+ const Anope::string &protocolstr = uplink->Get<const Anope::string>("protocol", "ipv4");
+ if (protocolstr == "ipv4")
+ protocol = AF_INET;
+ else if (protocolstr == "ipv6")
+ protocol = AF_INET6;
+ else if (protocolstr == "unix")
+ protocol = AF_UNIX;
+ else
+ throw ConfigException("uplink:protocol must be set to ipv4, ipv6, or unix");
+ const Anope::string &host = uplink->Get<const Anope::string>("host");
ValidateNotEmptyOrSpaces("uplink", "host", host);
- ValidateNotZero("uplink", "port", port);
- ValidateNotEmptyOrSpaces("uplink", "password", password);
- if (password.find(' ') != Anope::string::npos || password[0] == ':')
+ int port = 0;
+ if (protocol != AF_UNIX)
+ {
+ port = uplink->Get<int>("port");
+ ValidateNotZero("uplink", "port", port);
+ }
+
+ const Anope::string &password = uplink->Get<const Anope::string>("password");
+ ValidateNotEmptyOrSpaces("uplink", "password", password);
+ if (password[0] == ':')
throw ConfigException("uplink:password is not valid");
- this->Uplinks.push_back(Uplink(host, port, password, ipv6));
+ this->Uplinks.emplace_back(host, port, password, protocol);
}
for (int i = 0; i < this->CountBlock("module"); ++i)
@@ -262,10 +278,8 @@ Conf::Conf() : Block("")
/* Strip leading ' ' after , */
if (str.length() > 1 && str[0] == ' ')
str.erase(str.begin());
- for (unsigned j = 0; j < this->MyOperTypes.size(); ++j)
+ for (auto *ot2 : this->MyOperTypes)
{
- OperType *ot2 = this->MyOperTypes[j];
-
if (ot2->GetName().equals_ci(str))
{
Log() << "Inheriting commands and privs from " << ot2->GetName() << " to " << ot->GetName();
@@ -294,9 +308,11 @@ Conf::Conf() : Block("")
ValidateNotEmpty("oper", "type", type);
OperType *ot = NULL;
- for (unsigned j = 0; j < this->MyOperTypes.size(); ++j)
- if (this->MyOperTypes[j]->GetName() == type)
- ot = this->MyOperTypes[j];
+ for (auto *opertype : this->MyOperTypes)
+ {
+ if (opertype->GetName() == type)
+ ot = opertype;
+ }
if (ot == NULL)
throw ConfigException("Oper block for " + nname + " has invalid oper type " + type);
@@ -310,8 +326,8 @@ Conf::Conf() : Block("")
this->Opers.push_back(o);
}
- for (botinfo_map::const_iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it)
- it->second->conf = false;
+ for (const auto &[_, bi] : *BotListByNick)
+ bi->conf = false;
for (int i = 0; i < this->CountBlock("service"); ++i)
{
const Block *service = this->GetBlock("service", i);
@@ -359,28 +375,30 @@ Conf::Conf() : Block("")
/* Remove all existing modes */
ChanUserContainer *cu = c->FindUser(bi);
if (cu != NULL)
- for (size_t j = 0; j < cu->status.Modes().length(); ++j)
- c->RemoveMode(bi, ModeManager::FindChannelModeByChar(cu->status.Modes()[j]), bi->GetUID());
+ {
+ for (auto mode : cu->status.Modes())
+ c->RemoveMode(bi, ModeManager::FindChannelModeByChar(mode), bi->GetUID());
+ }
/* Set the new modes */
- for (unsigned j = 0; j < want_modes.length(); ++j)
+ for (char want_mode : want_modes)
{
- ChannelMode *cm = ModeManager::FindChannelModeByChar(want_modes[j]);
+ ChannelMode *cm = ModeManager::FindChannelModeByChar(want_mode);
if (cm == NULL)
- cm = ModeManager::FindChannelModeByChar(ModeManager::GetStatusChar(want_modes[j]));
+ cm = ModeManager::FindChannelModeByChar(ModeManager::GetStatusChar(want_mode));
if (cm && cm->type == MODE_STATUS)
c->SetMode(bi, cm, bi->GetUID());
}
}
- for (unsigned k = 0; k < oldchannels.size(); ++k)
+ for (const auto &oldchannel : oldchannels)
{
- size_t ch = oldchannels[k].find('#');
- Anope::string chname = oldchannels[k].substr(ch != Anope::string::npos ? ch : 0);
+ size_t ch = oldchannel.find('#');
+ Anope::string chname = oldchannel.substr(ch != Anope::string::npos ? ch : 0);
bool found = false;
- for (unsigned j = 0; j < bi->botchannels.size(); ++j)
+ for (const auto &botchannel : bi->botchannels)
{
- ch = bi->botchannels[j].find('#');
- Anope::string ochname = bi->botchannels[j].substr(ch != Anope::string::npos ? ch : 0);
+ ch = botchannel.find('#');
+ Anope::string ochname = botchannel.substr(ch != Anope::string::npos ? ch : 0);
if (chname.equals_ci(ochname))
found = true;
@@ -422,8 +440,8 @@ Conf::Conf() : Block("")
this->LogInfos.push_back(l);
}
- for (botinfo_map::const_iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it)
- it->second->commands.clear();
+ for (const auto &[_, bi] : *BotListByNick)
+ bi->commands.clear();
for (int i = 0; i < this->CountBlock("command"); ++i)
{
const Block *command = this->GetBlock("command", i);
@@ -500,17 +518,14 @@ Conf::Conf() : Block("")
if (Config)
/* Clear existing conf opers */
- for (nickcore_map::const_iterator it = NickCoreList->begin(), it_end = NickCoreList->end(); it != it_end; ++it)
+ for (const auto &[_, nc] : *NickCoreList)
{
- NickCore *nc = it->second;
if (nc->o && std::find(Config->Opers.begin(), Config->Opers.end(), nc->o) != Config->Opers.end())
nc->o = NULL;
}
/* Apply new opers */
- for (unsigned i = 0; i < this->Opers.size(); ++i)
+ for (auto *o : this->Opers)
{
- Oper *o = this->Opers[i];
-
NickAlias *na = NickAlias::Find(o->name);
if (!na)
continue;
@@ -550,21 +565,27 @@ Conf::Conf() : Block("")
Conf::~Conf()
{
- for (unsigned i = 0; i < MyOperTypes.size(); ++i)
- delete MyOperTypes[i];
- for (unsigned i = 0; i < Opers.size(); ++i)
- delete Opers[i];
+ for (const auto *opertype : MyOperTypes)
+ delete opertype;
+
+ for (const auto *oper : Opers)
+ delete oper;
}
void Conf::Post(Conf *old)
{
/* Apply module changes */
- for (unsigned i = 0; i < old->ModulesAutoLoad.size(); ++i)
- if (std::find(this->ModulesAutoLoad.begin(), this->ModulesAutoLoad.end(), old->ModulesAutoLoad[i]) == this->ModulesAutoLoad.end())
- ModuleManager::UnloadModule(ModuleManager::FindModule(old->ModulesAutoLoad[i]), NULL);
- for (unsigned i = 0; i < this->ModulesAutoLoad.size(); ++i)
- if (std::find(old->ModulesAutoLoad.begin(), old->ModulesAutoLoad.end(), this->ModulesAutoLoad[i]) == old->ModulesAutoLoad.end())
- ModuleManager::LoadModule(this->ModulesAutoLoad[i], NULL);
+ for (const auto &mod : old->ModulesAutoLoad)
+ {
+ if (std::find(this->ModulesAutoLoad.begin(), this->ModulesAutoLoad.end(), mod) == this->ModulesAutoLoad.end())
+ ModuleManager::UnloadModule(ModuleManager::FindModule(mod), NULL);
+ }
+
+ for (const auto &mod : this->ModulesAutoLoad)
+ {
+ if (std::find(old->ModulesAutoLoad.begin(), old->ModulesAutoLoad.end(), mod) == old->ModulesAutoLoad.end())
+ ModuleManager::LoadModule(mod, NULL);
+ }
/* Apply opertype changes, as non-conf opers still point to the old oper types */
for (unsigned i = Oper::opers.size(); i > 0; --i)
@@ -577,9 +598,11 @@ void Conf::Post(Conf *old)
OperType *ot = o->ot;
o->ot = NULL;
- for (unsigned j = 0; j < MyOperTypes.size(); ++j)
- if (ot->GetName() == MyOperTypes[j]->GetName())
- o->ot = MyOperTypes[j];
+ for (auto *opertype : MyOperTypes)
+ {
+ if (ot->GetName() == opertype->GetName())
+ o->ot = opertype;
+ }
if (o->ot == NULL)
{
@@ -659,7 +682,7 @@ const Block *Conf::GetCommand(CommandSource &source)
return &Block::EmptyBlock;
}
-File::File(const Anope::string &n, bool e) : name(n), executable(e), fp(NULL)
+File::File(const Anope::string &n, bool e) : name(n), executable(e)
{
}
@@ -848,7 +871,7 @@ void Conf::LoadConf(File &file)
}
Block *b = block_stack.empty() ? this : block_stack.top();
- block_map::iterator it = b->blocks.insert(std::make_pair(wordbuffer, Configuration::Block(wordbuffer)));
+ block_map::iterator it = b->blocks.emplace(wordbuffer, Configuration::Block(wordbuffer));
b = &it->second;
b->linenum = linenumber;
block_stack.push(b);
diff --git a/src/extensible.cpp b/src/extensible.cpp
index 05ab7c5ac..06ffeeb3f 100644
--- a/src/extensible.cpp
+++ b/src/extensible.cpp
@@ -52,10 +52,9 @@ void Extensible::ExtensibleSerialize(const Extensible *e, const Serializable *s,
void Extensible::ExtensibleUnserialize(Extensible *e, Serializable *s, Serialize::Data &data)
{
- for (std::set<ExtensibleBase *>::iterator it = extensible_items.begin(); it != extensible_items.end(); ++it)
+ for (auto *extensible_item : extensible_items)
{
- ExtensibleBase *eb = *it;
- eb->ExtensibleUnserialize(e, s, data);
+ extensible_item->ExtensibleUnserialize(e, s, data);
}
}
diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp
index 79c205298..db53e0fc3 100644
--- a/src/hashcomp.cpp
+++ b/src/hashcomp.cpp
@@ -91,7 +91,7 @@ bool ci::less::operator()(const Anope::string &s1, const Anope::string &s2) cons
return s1.ci_str().compare(s2.ci_str()) < 0;
}
-sepstream::sepstream(const Anope::string &source, char separator, bool ae) : tokens(source), sep(separator), pos(0), allow_empty(ae)
+sepstream::sepstream(const Anope::string &source, char separator, bool ae) : tokens(source), sep(separator), allow_empty(ae)
{
}
diff --git a/src/init.cpp b/src/init.cpp
index 082f39b96..a0c46cb2f 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -23,10 +23,10 @@
#include <sys/wait.h>
#include <sys/stat.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <pwd.h>
+#include <cerrno>
#include <grp.h>
+#include <pwd.h>
+#include <sys/types.h>
#endif
Anope::string Anope::ConfigDir = "conf", Anope::DataDir = "data", Anope::ModuleDir = "lib", Anope::LocaleDir = "locale", Anope::LogDir = "logs";
@@ -57,7 +57,7 @@ static void ParseCommandLineArguments(int ac, char **av)
if (option.empty())
continue;
- CommandLineArguments.push_back(std::make_pair(option, param));
+ CommandLineArguments.emplace_back(option, param);
}
}
@@ -71,11 +71,11 @@ static bool GetCommandLineArgument(const Anope::string &name, char shortname, An
{
param.clear();
- for (std::vector<std::pair<Anope::string, Anope::string> >::iterator it = CommandLineArguments.begin(), it_end = CommandLineArguments.end(); it != it_end; ++it)
+ for (const auto &[argument, value] : CommandLineArguments)
{
- if (it->first.equals_ci(name) || (it->first.length() == 1 && it->first[0] == shortname))
+ if (argument.equals_ci(name) || (argument.length() == 1 && argument[0] == shortname))
{
- param = it->second;
+ param = argument;
return true;
}
}
@@ -258,14 +258,10 @@ static void setuidgid()
gid = g->gr_gid;
}
- for (unsigned i = 0; i < Config->LogInfos.size(); ++i)
+ for (const auto &li : Config->LogInfos)
{
- LogInfo& li = Config->LogInfos[i];
-
- for (unsigned j = 0; j < li.logfiles.size(); ++j)
+ for (const auto *lf : li.logfiles)
{
- LogFile* lf = li.logfiles[j];
-
errno = 0;
if (chown(lf->filename.c_str(), uid, gid) != 0)
Log() << "Unable to change the ownership of " << lf->filename << " to " << uid << "/" << gid << ": " << Anope::LastError();
@@ -411,7 +407,7 @@ void Anope::Init(int ac, char **av)
Anope::LogDir = arg;
}
- /* Chdir to Services data directory. */
+ /* Chdir to Anope data directory. */
if (chdir(Anope::ServicesDir.c_str()) < 0)
{
throw CoreException("Unable to chdir to " + Anope::ServicesDir + ": " + Anope::LastError());
@@ -479,7 +475,7 @@ void Anope::Init(int ac, char **av)
catch (const ConfigException &ex)
{
Log(LOG_TERMINAL) << ex.GetReason();
- Log(LOG_TERMINAL) << "*** Support resources: Read through the services.conf self-contained";
+ Log(LOG_TERMINAL) << "*** Support resources: Read through the anope.conf self-contained";
Log(LOG_TERMINAL) << "*** documentation. Read the documentation files found in the 'docs'";
Log(LOG_TERMINAL) << "*** folder. Visit our portal located at https://www.anope.org/. Join";
Log(LOG_TERMINAL) << "*** our support channel on /server irc.anope.org channel #anope.";
@@ -489,9 +485,9 @@ void Anope::Init(int ac, char **av)
/* Create me */
Configuration::Block *block = Config->GetBlock("serverinfo");
Me = new Server(NULL, block->Get<const Anope::string>("name"), 0, block->Get<const Anope::string>("description"), block->Get<const Anope::string>("id"));
- for (botinfo_map::const_iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it)
+ for (const auto &[_, bi] : *BotListByNick)
{
- it->second->server = Me;
+ bi->server = Me;
++Me->users;
}
@@ -547,8 +543,8 @@ void Anope::Init(int ac, char **av)
Anope::string sid = IRCD->SID_Retrieve();
if (Me->GetSID() == Me->GetName())
Me->SetSID(sid);
- for (botinfo_map::iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it)
- it->second->GenerateUID();
+ for (const auto &[_, bi] : *BotListByNick)
+ bi->GenerateUID();
}
/* Load up databases */
@@ -560,8 +556,8 @@ void Anope::Init(int ac, char **av)
FOREACH_MOD(OnPostInit, ());
- for (channel_map::const_iterator it = ChannelList.begin(), it_end = ChannelList.end(); it != it_end; ++it)
- it->second->Sync();
+ for (const auto &[_, ci] : ChannelList)
+ ci->Sync();
Serialize::CheckTypes();
}
diff --git a/src/language.cpp b/src/language.cpp
index 73263d97e..3b3066510 100644
--- a/src/language.cpp
+++ b/src/language.cpp
@@ -15,7 +15,7 @@
#include "config.h"
#include "language.h"
-#if GETTEXT_FOUND
+#if HAVE_LOCALIZATION
# include <libintl.h>
#endif
@@ -24,7 +24,7 @@ std::vector<Anope::string> Language::Domains;
void Language::InitLanguages()
{
-#if GETTEXT_FOUND
+#if HAVE_LOCALIZATION
Log(LOG_DEBUG) << "Initializing Languages...";
Languages.clear();
@@ -73,7 +73,7 @@ const char *Language::Translate(const NickCore *nc, const char *string)
return Translate(nc ? nc->language.c_str() : "", string);
}
-#if GETTEXT_FOUND
+#if HAVE_LOCALIZATION
#if defined(__GLIBC__) && defined(__USE_GNU_GETTEXT)
extern "C" int _nl_msg_cat_cntr;
diff --git a/src/logger.cpp b/src/logger.cpp
index 49cbc05b2..fb4b4bea8 100644
--- a/src/logger.cpp
+++ b/src/logger.cpp
@@ -74,11 +74,11 @@ const Anope::string &LogFile::GetName() const
return this->filename;
}
-Log::Log(LogType t, const Anope::string &cat, BotInfo *b) : bi(b), u(NULL), nc(NULL), c(NULL), source(NULL), chan(NULL), ci(NULL), s(NULL), m(NULL), type(t), category(cat)
+Log::Log(LogType t, const Anope::string &cat, BotInfo *b) : bi(b), type(t), category(cat)
{
}
-Log::Log(LogType t, CommandSource &src, Command *_c, ChannelInfo *_ci) : u(src.GetUser()), nc(src.nc), c(_c), source(&src), chan(NULL), ci(_ci), s(NULL), m(NULL), type(t)
+Log::Log(LogType t, CommandSource &src, Command *_c, ChannelInfo *_ci) : u(src.GetUser()), nc(src.nc), c(_c), source(&src), ci(_ci), type(t)
{
if (!c)
throw CoreException("Invalid pointers passed to Log::Log");
@@ -87,35 +87,34 @@ Log::Log(LogType t, CommandSource &src, Command *_c, ChannelInfo *_ci) : u(src.G
throw CoreException("This constructor does not support this log type");
size_t sl = c->name.find('/');
- this->bi = NULL;
if (sl != Anope::string::npos)
this->bi = Config->GetClient(c->name.substr(0, sl));
this->category = c->name;
}
-Log::Log(User *_u, Channel *ch, const Anope::string &cat) : bi(NULL), u(_u), nc(NULL), c(NULL), source(NULL), chan(ch), ci(chan ? *chan->ci : NULL), s(NULL), m(NULL), type(LOG_CHANNEL), category(cat)
+Log::Log(User *_u, Channel *ch, const Anope::string &cat) : u(_u), chan(ch), ci(chan ? *chan->ci : nullptr), type(LOG_CHANNEL), category(cat)
{
if (!chan)
throw CoreException("Invalid pointers passed to Log::Log");
}
-Log::Log(User *_u, const Anope::string &cat, BotInfo *_bi) : bi(_bi), u(_u), nc(NULL), c(NULL), source(NULL), chan(NULL), ci(NULL), s(NULL), m(NULL), type(LOG_USER), category(cat)
+Log::Log(User *_u, const Anope::string &cat, BotInfo *_bi) : bi(_bi), u(_u), type(LOG_USER), category(cat)
{
if (!u)
throw CoreException("Invalid pointers passed to Log::Log");
}
-Log::Log(Server *serv, const Anope::string &cat, BotInfo *_bi) : bi(_bi), u(NULL), nc(NULL), c(NULL), source(NULL), chan(NULL), ci(NULL), s(serv), m(NULL), type(LOG_SERVER), category(cat)
+Log::Log(Server *serv, const Anope::string &cat, BotInfo *_bi) : bi(_bi), s(serv), type(LOG_SERVER), category(cat)
{
if (!s)
throw CoreException("Invalid pointer passed to Log::Log");
}
-Log::Log(BotInfo *b, const Anope::string &cat) : bi(b), u(NULL), nc(NULL), c(NULL), source(NULL), chan(NULL), ci(NULL), s(NULL), m(NULL), type(LOG_NORMAL), category(cat)
+Log::Log(BotInfo *b, const Anope::string &cat) : bi(b), type(LOG_NORMAL), category(cat)
{
}
-Log::Log(Module *mod, const Anope::string &cat, BotInfo *_bi) : bi(_bi), u(NULL), nc(NULL), c(NULL), source(NULL), chan(NULL), ci(NULL), s(NULL), m(mod), type(LOG_MODULE), category(cat)
+Log::Log(Module *mod, const Anope::string &cat, BotInfo *_bi) : bi(_bi), m(mod), type(LOG_MODULE), category(cat)
{
}
@@ -131,9 +130,13 @@ Log::~Log()
FOREACH_MOD(OnLog, (this));
if (Config)
- for (unsigned i = 0; i < Config->LogInfos.size(); ++i)
- if (Config->LogInfos[i].HasType(this->type, this->category))
- Config->LogInfos[i].ProcessMessage(this);
+ {
+ for (auto &li : Config->LogInfos)
+ {
+ if (li.HasType(this->type, this->category))
+ li.ProcessMessage(this);
+ }
+ }
}
Anope::string Log::FormatSource() const
@@ -227,14 +230,14 @@ Anope::string Log::BuildPrefix() const
return buffer;
}
-LogInfo::LogInfo(int la, bool rio, bool ldebug) : bot(NULL), last_day(0), log_age(la), raw_io(rio), debug(ldebug)
+LogInfo::LogInfo(int la, bool rio, bool ldebug) : log_age(la), raw_io(rio), debug(ldebug)
{
}
LogInfo::~LogInfo()
{
- for (unsigned i = 0; i < this->logfiles.size(); ++i)
- delete this->logfiles[i];
+ for (const auto *logfile : this->logfiles)
+ delete logfile;
this->logfiles.clear();
}
@@ -281,16 +284,15 @@ bool LogInfo::HasType(LogType ltype, const Anope::string &type) const
if (list == NULL)
return false;
- for (unsigned i = 0; i < list->size(); ++i)
+ for (auto value : *list)
{
- Anope::string cat = list->at(i);
bool inverse = false;
- if (cat[0] == '~')
+ if (value[0] == '~')
{
- cat.erase(cat.begin());
+ value.erase(value.begin());
inverse = true;
}
- if (Anope::Match(type, cat))
+ if (Anope::Match(type, value))
{
return !inverse;
}
@@ -301,14 +303,12 @@ bool LogInfo::HasType(LogType ltype, const Anope::string &type) const
void LogInfo::OpenLogFiles()
{
- for (unsigned i = 0; i < this->logfiles.size(); ++i)
- delete this->logfiles[i];
+ for (const auto *logfile : this->logfiles)
+ delete logfile;
this->logfiles.clear();
- for (unsigned i = 0; i < this->targets.size(); ++i)
+ for (const auto &target : this->targets)
{
- const Anope::string &target = this->targets[i];
-
if (target.empty() || target[0] == '#' || target == "globops" || target.find(":") != Anope::string::npos)
continue;
@@ -353,10 +353,8 @@ void LogInfo::ProcessMessage(const Log *l)
FOREACH_MOD(OnLogMessage, (this, l, buffer));
- for (unsigned i = 0; i < this->targets.size(); ++i)
+ for (const auto &target : this->targets)
{
- const Anope::string &target = this->targets[i];
-
if (!target.empty() && target[0] == '#')
{
if (UplinkSock && l->type <= LOG_NORMAL && Me && Me->IsSynced())
@@ -394,11 +392,10 @@ void LogInfo::ProcessMessage(const Log *l)
this->OpenLogFiles();
if (this->log_age)
- for (unsigned i = 0; i < this->targets.size(); ++i)
+ {
+ for (const auto &target : this->targets)
{
- const Anope::string &target = this->targets[i];
-
- if (target.empty() || target[0] == '#' || target == "globops" || target.find(":") != Anope::string::npos)
+ if (target.empty() || target[0] == '#' || target == "globops" || target.find(":") != Anope::string::npos)
continue;
Anope::string oldlog = CreateLogName(target, Anope::CurTime - 86400 * this->log_age);
@@ -408,11 +405,11 @@ void LogInfo::ProcessMessage(const Log *l)
Log(LOG_DEBUG) << "Deleted old logfile " << oldlog;
}
}
+ }
}
- for (unsigned i = 0; i < this->logfiles.size(); ++i)
+ for (auto *lf : this->logfiles)
{
- LogFile *lf = this->logfiles[i];
lf->stream << GetTimeStamp() << " " << buffer << std::endl;
}
}
diff --git a/src/mail.cpp b/src/mail.cpp
index ca6edcffa..3f24e3a54 100644
--- a/src/mail.cpp
+++ b/src/mail.cpp
@@ -16,13 +16,13 @@
Mail::Message::Message(const Anope::string &sf, const Anope::string &mailto, const Anope::string &a, const Anope::string &s, const Anope::string &m)
: Thread()
, sendmail_path(Config->GetBlock("mail")->Get<const Anope::string>("sendmailpath"))
- , send_from(sf), mail_to(mailto)
+ , send_from(sf)
+ , mail_to(mailto)
, addr(a)
, subject(s)
, message(m)
, content_type(Config->GetBlock("mail")->Get<const Anope::string>("content_type", "text/plain; charset=UTF-8"))
, dont_quote_addresses(Config->GetBlock("mail")->Get<bool>("dontquoteaddresses"))
- , success(false)
{
}
@@ -144,13 +144,15 @@ bool Mail::Validate(const Anope::string &email)
return false;
/* Check for forbidden characters in the name */
- for (unsigned i = 0, end = copy.length(); i < end; ++i)
+ for (auto chr : copy)
{
- if (copy[i] <= 31 || copy[i] >= 127)
+ if (chr <= 31 || chr >= 127)
return false;
- for (unsigned int j = 0; j < 13; ++j)
- if (copy[i] == specials[j])
+ for (auto special : specials)
+ {
+ if (chr == special)
return false;
+ }
}
/* Check for forbidden characters in the domain */
@@ -158,9 +160,11 @@ bool Mail::Validate(const Anope::string &email)
{
if (domain[i] <= 31 || domain[i] >= 127)
return false;
- for (unsigned int j = 0; j < 13; ++j)
- if (domain[i] == specials[j])
+ for (auto special : specials)
+ {
+ if (domain[i] == special)
return false;
+ }
if (domain[i] == '.')
{
if (!i || i == end - 1)
diff --git a/src/main.cpp b/src/main.cpp
index e951df0d3..b41c591d7 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,4 +1,4 @@
-/* Services -- main source file.
+/* Anope -- main source file.
*
* (C) 2003-2023 Anope Team
* Contact us at team@anope.org
@@ -17,7 +17,7 @@
#include "uplink.h"
#ifndef _WIN32
-#include <limits.h>
+#include <climits>
#else
#include <process.h>
#endif
@@ -46,7 +46,7 @@ class UpdateTimer : public Timer
public:
UpdateTimer(time_t timeout) : Timer(timeout, Anope::CurTime, true) { }
- void Tick(time_t) anope_override
+ void Tick(time_t) override
{
Anope::SaveDatabases();
}
@@ -57,7 +57,7 @@ class ExpireTimer : public Timer
public:
ExpireTimer(time_t timeout) : Timer(timeout, Anope::CurTime, true) { }
- void Tick(time_t) anope_override
+ void Tick(time_t) override
{
FOREACH_MOD(OnExpireTick, ());
}
diff --git a/src/memos.cpp b/src/memos.cpp
index 333094caf..03cd7f77d 100644
--- a/src/memos.cpp
+++ b/src/memos.cpp
@@ -76,7 +76,7 @@ Serializable* Memo::Unserialize(Serializable *obj, Serialize::Data &data)
return m;
}
-MemoInfo::MemoInfo() : memomax(0), memos("Memo")
+MemoInfo::MemoInfo() : memos("Memo")
{
}
@@ -113,9 +113,11 @@ void MemoInfo::Del(unsigned index)
bool MemoInfo::HasIgnore(User *u)
{
- for (unsigned i = 0; i < this->ignores.size(); ++i)
- if (u->nick.equals_ci(this->ignores[i]) || (u->Account() && u->Account()->display.equals_ci(this->ignores[i])) || Anope::Match(u->GetMask(), Anope::string(this->ignores[i])))
+ for (const auto &ignore : this->ignores)
+ {
+ if (u->nick.equals_ci(ignore) || (u->Account() && u->Account()->display.equals_ci(ignore)) || Anope::Match(u->GetMask(), Anope::string(ignore)))
return true;
+ }
return false;
}
diff --git a/src/messages.cpp b/src/messages.cpp
index 84124f5e8..2aaae177f 100644
--- a/src/messages.cpp
+++ b/src/messages.cpp
@@ -22,7 +22,7 @@
using namespace Message;
-void Away::Run(MessageSource &source, const std::vector<Anope::string> &params)
+void Away::Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags)
{
const Anope::string &msg = !params.empty() ? params[0] : "";
@@ -33,7 +33,7 @@ void Away::Run(MessageSource &source, const std::vector<Anope::string> &params)
Log(source.GetUser(), "away") << "is no longer away";
}
-void Capab::Run(MessageSource &source, const std::vector<Anope::string> &params)
+void Capab::Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags)
{
if (params.size() == 1)
{
@@ -43,18 +43,20 @@ void Capab::Run(MessageSource &source, const std::vector<Anope::string> &params)
Servers::Capab.insert(token);
}
else
- for (unsigned i = 0; i < params.size(); ++i)
- Servers::Capab.insert(params[i]);
+ {
+ for (const auto &param : params)
+ Servers::Capab.insert(param);
+ }
}
-void Error::Run(MessageSource &source, const std::vector<Anope::string> &params)
+void Error::Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags)
{
Log(LOG_TERMINAL) << "ERROR: " << params[0];
Anope::QuitReason = "Received ERROR from uplink: " + params[0];
Anope::Quitting = true;
}
-void Invite::Run(MessageSource &source, const std::vector<Anope::string> &params)
+void Invite::Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags)
{
User *targ = User::Find(params[0]);
Channel *c = Channel::Find(params[1]);
@@ -65,7 +67,7 @@ void Invite::Run(MessageSource &source, const std::vector<Anope::string> &params
FOREACH_MOD(OnInvite, (source.GetUser(), c, targ));
}
-void Join::Run(MessageSource &source, const std::vector<Anope::string> &params)
+void Join::Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags)
{
User *user = source.GetUser();
const Anope::string &channels = params[0];
@@ -92,7 +94,7 @@ void Join::Run(MessageSource &source, const std::vector<Anope::string> &params)
}
std::list<SJoinUser> users;
- users.push_back(std::make_pair(ChannelStatus(), user));
+ users.emplace_back(ChannelStatus(), user);
Channel *chan = Channel::Find(channel);
SJoin(source, channel, chan ? chan->creation_time : Anope::CurTime, "", users);
@@ -127,10 +129,8 @@ void Join::SJoin(MessageSource &source, const Anope::string &chan, time_t ts, co
*/
c->SetModesInternal(source, modes, ts, !c->syncing);
- for (std::list<SJoinUser>::const_iterator it = users.begin(), it_end = users.end(); it != it_end; ++it)
+ for (const auto &[status, u] : users)
{
- const ChannelStatus &status = it->first;
- User *u = it->second;
keep_their_modes = ts <= c->creation_time; // OnJoinChannel can call modules which can modify this channel's ts
if (c->FindUser(u))
@@ -167,7 +167,7 @@ void Join::SJoin(MessageSource &source, const Anope::string &chan, time_t ts, co
}
}
-void Kick::Run(MessageSource &source, const std::vector<Anope::string> &params)
+void Kick::Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags)
{
const Anope::string &channel = params[0];
const Anope::string &users = params[1];
@@ -184,7 +184,7 @@ void Kick::Run(MessageSource &source, const std::vector<Anope::string> &params)
c->KickInternal(source, user, reason);
}
-void Kill::Run(MessageSource &source, const std::vector<Anope::string> &params)
+void Kill::Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags)
{
User *u = User::Find(params[0]);
BotInfo *bi;
@@ -199,7 +199,7 @@ void Kill::Run(MessageSource &source, const std::vector<Anope::string> &params)
if (last_time == Anope::CurTime)
{
- Anope::QuitReason = "Kill loop detected. Are Services U:Lined?";
+ Anope::QuitReason = "Kill loop detected. Is Anope U:Lined?";
Anope::Quitting = true;
return;
}
@@ -211,7 +211,7 @@ void Kill::Run(MessageSource &source, const std::vector<Anope::string> &params)
u->KillInternal(source, params[1]);
}
-void Message::Mode::Run(MessageSource &source, const std::vector<Anope::string> &params)
+void Message::Mode::Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags)
{
Anope::string buf;
for (unsigned i = 1; i < params.size(); ++i)
@@ -234,7 +234,7 @@ void Message::Mode::Run(MessageSource &source, const std::vector<Anope::string>
}
/* XXX We should cache the file somewhere not open/read/close it on every request */
-void MOTD::Run(MessageSource &source, const std::vector<Anope::string> &params)
+void MOTD::Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags)
{
Server *s = Server::Find(params[0]);
if (s != Me)
@@ -257,7 +257,7 @@ void MOTD::Run(MessageSource &source, const std::vector<Anope::string> &params)
IRCD->SendNumeric(422, source.GetSource(), ":- MOTD file not found! Please contact your IRC administrator.");
}
-void Notice::Run(MessageSource &source, const std::vector<Anope::string> &params)
+void Notice::Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags)
{
Anope::string message = params[1];
@@ -273,7 +273,7 @@ void Notice::Run(MessageSource &source, const std::vector<Anope::string> &params
}
}
-void Part::Run(MessageSource &source, const std::vector<Anope::string> &params)
+void Part::Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags)
{
User *u = source.GetUser();
const Anope::string &reason = params.size() > 1 ? params[1] : "";
@@ -295,12 +295,12 @@ void Part::Run(MessageSource &source, const std::vector<Anope::string> &params)
}
}
-void Ping::Run(MessageSource &source, const std::vector<Anope::string> &params)
+void Ping::Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags)
{
IRCD->SendPong(params.size() > 1 ? params[1] : Me->GetSID(), params[0]);
}
-void Privmsg::Run(MessageSource &source, const std::vector<Anope::string> &params)
+void Privmsg::Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags)
{
const Anope::string &receiver = params[0];
Anope::string message = params[1];
@@ -373,7 +373,7 @@ void Privmsg::Run(MessageSource &source, const std::vector<Anope::string> &param
return;
}
-void Quit::Run(MessageSource &source, const std::vector<Anope::string> &params)
+void Quit::Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags)
{
const Anope::string &reason = params[0];
User *user = source.GetUser();
@@ -383,7 +383,7 @@ void Quit::Run(MessageSource &source, const std::vector<Anope::string> &params)
user->Quit(reason);
}
-void SQuit::Run(MessageSource &source, const std::vector<Anope::string> &params)
+void SQuit::Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags)
{
Server *s = Server::Find(params[0]);
@@ -404,7 +404,7 @@ void SQuit::Run(MessageSource &source, const std::vector<Anope::string> &params)
s->Delete(s->GetName() + " " + s->GetUplink()->GetName());
}
-void Stats::Run(MessageSource &source, const std::vector<Anope::string> &params)
+void Stats::Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags)
{
User *u = source.GetUser();
@@ -426,10 +426,8 @@ void Stats::Run(MessageSource &source, const std::vector<Anope::string> &params)
IRCD->SendNumeric(219, source.GetSource(), "%c :End of /STATS report.", params[0][0]);
else
{
- for (unsigned i = 0; i < Oper::opers.size(); ++i)
+ for (auto *o : Oper::opers)
{
- Oper *o = Oper::opers[i];
-
const NickAlias *na = NickAlias::Find(o->name);
if (na)
IRCD->SendNumeric(243, source.GetSource(), "O * * %s %s 0", o->name.c_str(), o->ot->GetName().replace_all_cs(" ", "_").c_str());
@@ -455,7 +453,7 @@ void Stats::Run(MessageSource &source, const std::vector<Anope::string> &params)
return;
}
-void Time::Run(MessageSource &source, const std::vector<Anope::string> &params)
+void Time::Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags)
{
time_t t;
time(&t);
@@ -466,7 +464,7 @@ void Time::Run(MessageSource &source, const std::vector<Anope::string> &params)
return;
}
-void Topic::Run(MessageSource &source, const std::vector<Anope::string> &params)
+void Topic::Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags)
{
Channel *c = Channel::Find(params[0]);
if (c)
@@ -475,13 +473,13 @@ void Topic::Run(MessageSource &source, const std::vector<Anope::string> &params)
return;
}
-void Version::Run(MessageSource &source, const std::vector<Anope::string> &params)
+void Version::Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags)
{
Module *enc = ModuleManager::FindFirstOf(ENCRYPTION);
IRCD->SendNumeric(351, source.GetSource(), "Anope-%s %s :%s -(%s) -- %s", Anope::Version().c_str(), Me->GetName().c_str(), IRCD->GetProtocolName().c_str(), enc ? enc->name.c_str() : "(none)", Anope::VersionBuildString().c_str());
}
-void Whois::Run(MessageSource &source, const std::vector<Anope::string> &params)
+void Whois::Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags)
{
User *u = User::Find(params[0]);
diff --git a/src/misc.cpp b/src/misc.cpp
index 7e68686a2..39c688ea6 100644
--- a/src/misc.cpp
+++ b/src/misc.cpp
@@ -19,15 +19,15 @@
#include "regexpr.h"
#include "sockets.h"
-#include <errno.h>
-#include <sys/types.h>
+#include <cerrno>
#include <sys/stat.h>
+#include <sys/types.h>
#ifndef _WIN32
#include <sys/socket.h>
#include <netdb.h>
#endif
-NumberList::NumberList(const Anope::string &list, bool descending) : is_valid(true), desc(descending)
+NumberList::NumberList(const Anope::string &list, bool descending) : desc(descending)
{
Anope::string error;
commasepstream sep(list);
@@ -90,10 +90,6 @@ NumberList::NumberList(const Anope::string &list, bool descending) : is_valid(tr
} while (sep.GetToken(token));
}
-NumberList::~NumberList()
-{
-}
-
void NumberList::Process()
{
if (!is_valid)
@@ -106,8 +102,8 @@ void NumberList::Process()
}
else
{
- for (std::set<unsigned>::iterator it = numbers.begin(), it_end = numbers.end(); it != it_end; ++it)
- this->HandleNumber(*it);
+ for (unsigned int number : numbers)
+ this->HandleNumber(number);
}
}
@@ -145,29 +141,30 @@ void ListFormatter::Process(std::vector<Anope::string> &buffer)
std::vector<Anope::string> tcolumns;
std::map<Anope::string, size_t> lengths;
std::set<Anope::string> breaks;
- for (unsigned i = 0; i < this->columns.size(); ++i)
+ for (const auto &column : this->columns)
{
- tcolumns.push_back(Language::Translate(this->nc, this->columns[i].c_str()));
- lengths[this->columns[i]] = tcolumns[i].length();
+ tcolumns.emplace_back(Language::Translate(this->nc, column.c_str()));
+ lengths[column] = column.length();
}
- for (unsigned i = 0; i < this->entries.size(); ++i)
+ for (auto &entry : this->entries)
{
- ListEntry &e = this->entries[i];
- for (unsigned j = 0; j < this->columns.size(); ++j)
- if (e[this->columns[j]].length() > lengths[this->columns[j]])
- lengths[this->columns[j]] = e[this->columns[j]].length();
+ for (const auto &column : this->columns)
+ {
+ if (entry[column].length() > lengths[column])
+ lengths[column] = entry[column].length();
+ }
}
- unsigned length = 0;
- for (std::map<Anope::string, size_t>::iterator it = lengths.begin(), it_end = lengths.end(); it != it_end; ++it)
+ unsigned total_length = 0;
+ for (const auto &[column, length] : lengths)
{
/* Break lines at 80 chars */
- if (length > 80)
+ if (total_length > 80)
{
- breaks.insert(it->first);
- length = 0;
+ breaks.insert(column);
+ total_length = 0;
}
else
- length += it->second;
+ total_length += length;
}
/* Only put a list header if more than 1 column */
@@ -191,10 +188,8 @@ void ListFormatter::Process(std::vector<Anope::string> &buffer)
buffer.push_back(s);
}
- for (unsigned i = 0; i < this->entries.size(); ++i)
+ for (auto &entry : this->entries)
{
- ListEntry &e = this->entries[i];
-
Anope::string s;
for (unsigned j = 0; j < this->columns.size(); ++j)
{
@@ -205,16 +200,16 @@ void ListFormatter::Process(std::vector<Anope::string> &buffer)
}
else if (!s.empty())
s += " ";
- s += e[this->columns[j]];
+ s += entry[this->columns[j]];
if (j + 1 != this->columns.size())
- for (unsigned k = e[this->columns[j]].length(); k < lengths[this->columns[j]]; ++k)
+ for (unsigned k = entry[this->columns[j]].length(); k < lengths[this->columns[j]]; ++k)
s += " ";
}
buffer.push_back(s);
}
}
-InfoFormatter::InfoFormatter(NickCore *acc) : nc(acc), longest(0)
+InfoFormatter::InfoFormatter(NickCore *acc) : nc(acc)
{
}
@@ -222,12 +217,12 @@ void InfoFormatter::Process(std::vector<Anope::string> &buffer)
{
buffer.clear();
- for (std::vector<std::pair<Anope::string, Anope::string> >::iterator it = this->replies.begin(), it_end = this->replies.end(); it != it_end; ++it)
+ for (const auto &[key, value] : this->replies)
{
Anope::string s;
- for (unsigned i = it->first.length(); i < this->longest; ++i)
+ for (unsigned i = key.length(); i < this->longest; ++i)
s += " ";
- s += it->first + ": " + Language::Translate(this->nc, it->second.c_str());
+ s += key + ": " + Language::Translate(this->nc, value.c_str());
buffer.push_back(s);
}
@@ -238,7 +233,7 @@ Anope::string& InfoFormatter::operator[](const Anope::string &key)
Anope::string tkey = Language::Translate(this->nc, key.c_str());
if (tkey.length() > this->longest)
this->longest = tkey.length();
- this->replies.push_back(std::make_pair(tkey, ""));
+ this->replies.emplace_back(tkey, "");
return this->replies.back().second;
}
@@ -246,11 +241,11 @@ void InfoFormatter::AddOption(const Anope::string &opt)
{
Anope::string options = Language::Translate(this->nc, "Options");
Anope::string *optstr = NULL;
- for (std::vector<std::pair<Anope::string, Anope::string> >::iterator it = this->replies.begin(), it_end = this->replies.end(); it != it_end; ++it)
+ for (auto &[option, value] : this->replies)
{
- if (it->first == options)
+ if (option == options)
{
- optstr = &it->second;
+ optstr = &value;
break;
}
}
@@ -514,24 +509,6 @@ void Anope::Encrypt(const Anope::string &src, Anope::string &dest)
static_cast<void>(MOD_RESULT);
}
-bool Anope::Decrypt(const Anope::string &src, Anope::string &dest)
-{
- size_t pos = src.find(':');
- if (pos == Anope::string::npos)
- {
- Log() << "Error: Anope::Decrypt() called with invalid password string (" << src << ")";
- return false;
- }
- Anope::string hashm(src.begin(), src.begin() + pos);
-
- EventReturn MOD_RESULT;
- FOREACH_RESULT(OnDecrypt, MOD_RESULT, (hashm, src, dest));
- if (MOD_RESULT == EVENT_ALLOW)
- return true;
-
- return false;
-}
-
Anope::string Anope::printf(const char *fmt, ...)
{
va_list args;
@@ -639,7 +616,7 @@ Anope::string Anope::VersionBuildString()
#endif
Anope::string flags;
-#ifdef DEBUG_BUILD
+#if DEBUG_BUILD
flags += "D";
#endif
#ifdef VERSION_GIT
diff --git a/src/modes.cpp b/src/modes.cpp
index 5f950df57..6c46302de 100644
--- a/src/modes.cpp
+++ b/src/modes.cpp
@@ -46,9 +46,7 @@ struct StackerInfo
/* Modes to be deleted */
std::list<std::pair<Mode *, Anope::string> > DelModes;
/* Bot this is sent from */
- BotInfo *bi;
-
- StackerInfo() : bi(NULL) { }
+ BotInfo *bi = nullptr;
/** Add a mode to this object
* @param mode The mode
@@ -58,10 +56,6 @@ struct StackerInfo
void AddMode(Mode *mode, bool set, const Anope::string &param);
};
-ChannelStatus::ChannelStatus()
-{
-}
-
ChannelStatus::ChannelStatus(const Anope::string &m) : modes(m)
{
}
@@ -101,9 +95,9 @@ Anope::string ChannelStatus::BuildModePrefixList() const
{
Anope::string ret;
- for (size_t i = 0; i < modes.length(); ++i)
+ for (auto mode : modes)
{
- ChannelMode *cm = ModeManager::FindChannelModeByChar(modes[i]);
+ ChannelMode *cm = ModeManager::FindChannelModeByChar(mode);
if (cm != NULL && cm->type == MODE_STATUS)
{
ChannelModeStatus *cms = anope_dynamic_static_cast<ChannelModeStatus *>(cm);
@@ -118,10 +112,6 @@ Mode::Mode(const Anope::string &mname, ModeClass mcl, char mch, ModeType mt) : n
{
}
-Mode::~Mode()
-{
-}
-
bool Mode::CanSet(User *u) const
{
return true;
@@ -154,9 +144,9 @@ ChannelMode *ChannelMode::Wrap(Anope::string &param)
ChannelMode *ChannelMode::Unwrap(Anope::string &param)
{
- for (unsigned i = 0; i < listeners.size(); ++i)
+ for (auto *listener : listeners)
{
- ChannelMode *cm = listeners[i]->Unwrap(this, param);
+ ChannelMode *cm = listener->Unwrap(this, param);
if (cm != this)
return cm;
}
@@ -307,13 +297,13 @@ void StackerInfo::AddMode(Mode *mode, bool set, const Anope::string &param)
}
/* Add this mode and its param to our list */
- list->push_back(std::make_pair(mode, param));
+ list->emplace_back(mode, param);
}
static class ModePipe : public Pipe
{
public:
- void OnNotify()
+ void OnNotify() override
{
ModeManager::ProcessModes();
}
@@ -456,8 +446,8 @@ bool ModeManager::AddChannelMode(ChannelMode *cm)
FOREACH_MOD(OnChannelModeAdd, (cm));
- for (unsigned int i = 0; i < ChannelModes.size(); ++i)
- ChannelModes[i]->Check();
+ for (auto *cmode : ChannelModes)
+ cmode->Check();
return true;
}
@@ -600,10 +590,8 @@ static struct StatusSort
void ModeManager::RebuildStatusModes()
{
ChannelModesByStatus.clear();
- for (unsigned j = 0; j < ChannelModesIdx.size(); ++j)
+ for (auto *cm : ChannelModesIdx)
{
- ChannelMode *cm = ChannelModesIdx[j];
-
if (cm && cm->type == MODE_STATUS && std::find(ChannelModesByStatus.begin(), ChannelModesByStatus.end(), cm) == ChannelModesByStatus.end())
ChannelModesByStatus.push_back(anope_dynamic_static_cast<ChannelModeStatus *>(cm));
}
@@ -640,30 +628,22 @@ void ModeManager::ProcessModes()
{
if (!UserStackerObjects.empty())
{
- for (std::map<User *, StackerInfo *>::const_iterator it = UserStackerObjects.begin(), it_end = UserStackerObjects.end(); it != it_end; ++it)
+ for (const auto &[u, s] : UserStackerObjects)
{
- User *u = it->first;
- StackerInfo *s = it->second;
-
- std::list<Anope::string> ModeStrings = BuildModeStrings(s);
- for (std::list<Anope::string>::iterator lit = ModeStrings.begin(), lit_end = ModeStrings.end(); lit != lit_end; ++lit)
- IRCD->SendMode(s->bi, u, "%s", lit->c_str());
- delete it->second;
+ for (const auto &modestr : BuildModeStrings(s))
+ IRCD->SendMode(s->bi, u, "%s", modestr.c_str());
+ delete s;
}
UserStackerObjects.clear();
}
if (!ChannelStackerObjects.empty())
{
- for (std::map<Channel *, StackerInfo *>::const_iterator it = ChannelStackerObjects.begin(), it_end = ChannelStackerObjects.end(); it != it_end; ++it)
+ for (const auto &[c, s] : ChannelStackerObjects)
{
- Channel *c = it->first;
- StackerInfo *s = it->second;
-
- std::list<Anope::string> ModeStrings = BuildModeStrings(s);
- for (std::list<Anope::string>::iterator lit = ModeStrings.begin(), lit_end = ModeStrings.end(); lit != lit_end; ++lit)
- IRCD->SendMode(s->bi, c, "%s", lit->c_str());
- delete it->second;
+ for (const auto &modestr : BuildModeStrings(s))
+ IRCD->SendMode(s->bi, c, "%s", modestr.c_str());
+ delete s;
}
ChannelStackerObjects.clear();
}
@@ -676,9 +656,8 @@ static void StackerDel(std::map<T *, StackerInfo *> &map, T *obj)
if (it != map.end())
{
StackerInfo *si = it->second;
- std::list<Anope::string> ModeStrings = BuildModeStrings(si);
- for (std::list<Anope::string>::iterator lit = ModeStrings.begin(), lit_end = ModeStrings.end(); lit != lit_end; ++lit)
- IRCD->SendMode(si->bi, obj, "%s", lit->c_str());
+ for (const auto &modestr : BuildModeStrings(si))
+ IRCD->SendMode(si->bi, obj, "%s", modestr.c_str());
delete si;
map.erase(it);
@@ -742,7 +721,7 @@ void ModeManager::StackerDel(Mode *m)
}
}
-Entry::Entry(const Anope::string &m, const Anope::string &fh) : name(m), mask(fh), cidr_len(0), family(0)
+Entry::Entry(const Anope::string &m, const Anope::string &fh) : name(m), mask(fh)
{
Anope::string n, u, h;
diff --git a/src/module.cpp b/src/module.cpp
index 2da365270..7722c7748 100644
--- a/src/module.cpp
+++ b/src/module.cpp
@@ -11,7 +11,7 @@
#include "language.h"
#include "account.h"
-#ifdef GETTEXT_FOUND
+#if HAVE_LOCALIZATION
# include <libintl.h>
#endif
@@ -39,12 +39,12 @@ Module::Module(const Anope::string &modname, const Anope::string &, ModType modt
ModuleManager::Modules.push_back(this);
-#if GETTEXT_FOUND
- for (unsigned i = 0; i < Language::Languages.size(); ++i)
+#if HAVE_LOCALIZATION
+ for (const auto &language : Language::Languages)
{
/* Remove .UTF-8 or any other suffix */
Anope::string lang;
- sepstream(Language::Languages[i], '.').GetToken(lang);
+ sepstream(language, '.').GetToken(lang);
if (Anope::IsFile(Anope::LocaleDir + "/" + lang + "/LC_MESSAGES/" + modname + ".mo"))
{
@@ -75,7 +75,7 @@ Module::~Module()
if (it != ModuleManager::Modules.end())
ModuleManager::Modules.erase(it);
-#if GETTEXT_FOUND
+#if HAVE_LOCALIZATION
std::vector<Anope::string>::iterator dit = std::find(Language::Domains.begin(), Language::Domains.end(), this->name);
if (dit != Language::Domains.end())
Language::Domains.erase(dit);
diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp
index f5f93a937..38ed130f7 100644
--- a/src/modulemanager.cpp
+++ b/src/modulemanager.cpp
@@ -15,11 +15,12 @@
#include <sys/types.h>
#include <sys/stat.h>
#ifndef _WIN32
-#include <dirent.h>
#include <sys/types.h>
#include <dlfcn.h>
#endif
+#include <filesystem>
+
std::list<Module *> ModuleManager::Modules;
std::vector<Module *> ModuleManager::EventHandlers[I_SIZE];
@@ -29,25 +30,18 @@ void ModuleManager::CleanupRuntimeDirectory()
Anope::string dirbuf = Anope::DataDir + "/runtime";
Log(LOG_DEBUG) << "Cleaning out Module run time directory (" << dirbuf << ") - this may take a moment, please wait";
-
- DIR *dirp = opendir(dirbuf.c_str());
- if (!dirp)
+ try
{
- Log(LOG_DEBUG) << "Cannot open directory (" << dirbuf << ")";
- return;
+ for (const auto &entry : std::filesystem::directory_iterator(dirbuf.str()))
+ {
+ if (entry.is_regular_file())
+ std::filesystem::remove(entry);
+ }
}
-
- for (dirent *dp; (dp = readdir(dirp));)
+ catch (const std::filesystem::filesystem_error &err)
{
- if (!dp->d_ino)
- continue;
- if (Anope::string(dp->d_name).equals_cs(".") || Anope::string(dp->d_name).equals_cs(".."))
- continue;
- Anope::string filebuf = dirbuf + "/" + dp->d_name;
- unlink(filebuf.c_str());
+ Log(LOG_DEBUG) << "Cannot open directory (" << dirbuf << "): " << err.what();
}
-
- closedir(dirp);
}
/**
@@ -273,8 +267,8 @@ ModuleReturn ModuleManager::LoadModule(const Anope::string &modname, User *u)
Log(LOG_DEBUG) << "Module " << modname << " loaded.";
/* Attach module to all events */
- for (unsigned i = 0; i < I_SIZE; ++i)
- EventHandlers[i].push_back(m);
+ for (auto &mods : EventHandlers)
+ mods.push_back(m);
m->Prioritize();
@@ -313,10 +307,8 @@ ModuleReturn ModuleManager::UnloadModule(Module *m, User *u)
Module *ModuleManager::FindModule(const Anope::string &name)
{
- for (std::list<Module *>::const_iterator it = Modules.begin(), it_end = Modules.end(); it != it_end; ++it)
+ for (auto *m : Modules)
{
- Module *m = *it;
-
if (m->name.equals_ci(name))
return m;
}
@@ -326,10 +318,8 @@ Module *ModuleManager::FindModule(const Anope::string &name)
Module *ModuleManager::FindFirstOf(ModType type)
{
- for (std::list<Module *>::const_iterator it = Modules.begin(), it_end = Modules.end(); it != it_end; ++it)
+ for (auto *m : Modules)
{
- Module *m = *it;
-
if (m->type & type)
return m;
}
@@ -395,9 +385,8 @@ ModuleReturn ModuleManager::DeleteModule(Module *m)
void ModuleManager::DetachAll(Module *mod)
{
- for (unsigned i = 0; i < I_SIZE; ++i)
+ for (auto &mods : EventHandlers)
{
- std::vector<Module *> &mods = EventHandlers[i];
std::vector<Module *>::iterator it2 = std::find(mods.begin(), mods.end(), mod);
if (it2 != mods.end())
mods.erase(it2);
@@ -510,16 +499,17 @@ void ModuleManager::UnloadAll()
{
std::vector<Anope::string> modules;
for (size_t i = 1, j = 0; i != MT_END; j |= i, i <<= 1)
- for (std::list<Module *>::iterator it = Modules.begin(), it_end = Modules.end(); it != it_end; ++it)
+ {
+ for (auto *m : Modules)
{
- Module *m = *it;
if ((m->type & j) == m->type)
modules.push_back(m->name);
}
+ }
- for (unsigned i = 0; i < modules.size(); ++i)
+ for (auto &module : modules)
{
- Module *m = FindModule(modules[i]);
+ Module *m = FindModule(module);
if (m != NULL)
UnloadModule(m, NULL);
}
diff --git a/src/nickcore.cpp b/src/nickcore.cpp
index 4c14d8591..9d292bbf3 100644
--- a/src/nickcore.cpp
+++ b/src/nickcore.cpp
@@ -78,11 +78,11 @@ void NickCore::Serialize(Serialize::Data &data) const
data["pass"] << this->pass;
data["email"] << this->email;
data["language"] << this->language;
- for (unsigned i = 0; i < this->access.size(); ++i)
- data["access"] << this->access[i] << " ";
+ for (const auto &mask : this->access)
+ data["access"] << mask << " ";
data["memomax"] << this->memos.memomax;
- for (unsigned i = 0; i < this->memos.ignores.size(); ++i)
- data["memoignores"] << this->memos.ignores[i] << " ";
+ for (const auto &ignore : this->memos.ignores)
+ data["memoignores"] << ignore << " ";
Extensible::ExtensibleSerialize(this, this, data);
}
@@ -171,8 +171,8 @@ void NickCore::SetDisplay(const NickAlias *na)
FOREACH_MOD(OnChangeCoreDisplay, (this, na->nick));
/* this affects the serialized aliases */
- for (unsigned i = 0; i < aliases->size(); ++i)
- aliases->at(i)->QueueUpdate();
+ for (auto *alias : *aliases)
+ alias->QueueUpdate();
/* Remove the core from the list */
NickCoreList->erase(this->display);
@@ -207,9 +207,11 @@ unsigned NickCore::GetAccessCount() const
bool NickCore::FindAccess(const Anope::string &entry)
{
- for (unsigned i = 0, end = this->access.size(); i < end; ++i)
- if (this->access[i] == entry)
+ for (const auto &mask : this->access)
+ {
+ if (mask == entry)
return true;
+ }
return false;
}
@@ -263,8 +265,8 @@ void NickCore::RemoveChannelReference(ChannelInfo *ci)
void NickCore::GetChannelReferences(std::deque<ChannelInfo *> &queue)
{
queue.clear();
- for (std::map<ChannelInfo *, int>::iterator it = this->chanaccess->begin(), it_end = this->chanaccess->end(); it != it_end; ++it)
- queue.push_back(it->first);
+ for (const auto &[ci, _] : *this->chanaccess)
+ queue.push_back(ci);
}
NickCore* NickCore::Find(const Anope::string &nick)
@@ -300,8 +302,8 @@ uint64_t NickCore::GetId()
{
// Generate a random key for SipHash.
char key[16];
- for (size_t i = 0; i < sizeof(key); ++i)
- key[i] = rand() % CHAR_MAX;
+ for (auto &chr : key)
+ chr = rand() % CHAR_MAX;
uint64_t newid = Anope::SipHash24(secretid.c_str(), secretid.length(), key);
nickcoreid_map::const_iterator it = NickCoreIdList.find(newid);
diff --git a/src/opertype.cpp b/src/opertype.cpp
index fb92ca488..e7708f99f 100644
--- a/src/opertype.cpp
+++ b/src/opertype.cpp
@@ -13,7 +13,7 @@
std::vector<Oper *> Oper::opers;
-Oper::Oper(const Anope::string &n, OperType *o) : name(n), ot(o), require_oper(true)
+Oper::Oper(const Anope::string &n, OperType *o) : name(n), ot(o)
{
opers.push_back(this);
}
@@ -27,10 +27,8 @@ Oper::~Oper()
Oper *Oper::Find(const Anope::string &name)
{
- for (unsigned i = 0; i < opers.size(); ++i)
+ for (auto *o : opers)
{
- Oper *o = opers[i];
-
if (o->name.equals_ci(name))
return o;
}
@@ -40,10 +38,8 @@ Oper *Oper::Find(const Anope::string &name)
OperType *OperType::Find(const Anope::string &name)
{
- for (unsigned i = 0; i < Config->MyOperTypes.size(); ++i)
+ for (auto *ot : Config->MyOperTypes)
{
- OperType *ot = Config->MyOperTypes[i];
-
if (ot->GetName() == name)
return ot;
}
@@ -57,19 +53,15 @@ OperType::OperType(const Anope::string &nname) : name(nname)
bool OperType::HasCommand(const Anope::string &cmdstr) const
{
- for (std::list<Anope::string>::const_iterator it = this->commands.begin(), it_end = this->commands.end(); it != it_end; ++it)
+ for (const auto &command : this->commands)
{
- const Anope::string &s = *it;
-
- if (!s.find('~') && Anope::Match(cmdstr, s.substr(1)))
+ if (!command.find('~') && Anope::Match(cmdstr, command.substr(1)))
return false;
- else if (Anope::Match(cmdstr, s))
+ else if (Anope::Match(cmdstr, command))
return true;
}
- for (std::set<OperType *>::const_iterator iit = this->inheritances.begin(), iit_end = this->inheritances.end(); iit != iit_end; ++iit)
+ for (auto *ot : this->inheritances)
{
- OperType *ot = *iit;
-
if (ot->HasCommand(cmdstr))
return true;
}
@@ -79,19 +71,15 @@ bool OperType::HasCommand(const Anope::string &cmdstr) const
bool OperType::HasPriv(const Anope::string &privstr) const
{
- for (std::list<Anope::string>::const_iterator it = this->privs.begin(), it_end = this->privs.end(); it != it_end; ++it)
+ for (const auto &priv : this->privs)
{
- const Anope::string &s = *it;
-
- if (!s.find('~') && Anope::Match(privstr, s.substr(1)))
+ if (!priv.find('~') && Anope::Match(privstr, priv.substr(1)))
return false;
- else if (Anope::Match(privstr, s))
+ else if (Anope::Match(privstr, priv))
return true;
}
- for (std::set<OperType *>::const_iterator iit = this->inheritances.begin(), iit_end = this->inheritances.end(); iit != iit_end; ++iit)
+ for (auto *ot : this->inheritances)
{
- OperType *ot = *iit;
-
if (ot->HasPriv(privstr))
return true;
}
@@ -123,12 +111,10 @@ void OperType::Inherits(OperType *ot)
const std::list<Anope::string> OperType::GetCommands() const
{
std::list<Anope::string> cmd_list = this->commands;
- for (std::set<OperType *>::const_iterator it = this->inheritances.begin(), it_end = this->inheritances.end(); it != it_end; ++it)
+ for (auto *ot : this->inheritances)
{
- OperType *ot = *it;
- std::list<Anope::string> cmds = ot->GetCommands();
- for (std::list<Anope::string>::const_iterator it2 = cmds.begin(), it2_end = cmds.end(); it2 != it2_end; ++it2)
- cmd_list.push_back(*it2);
+ for (const auto &cmd : ot->GetCommands())
+ cmd_list.push_back(cmd);
}
return cmd_list;
}
@@ -136,12 +122,10 @@ const std::list<Anope::string> OperType::GetCommands() const
const std::list<Anope::string> OperType::GetPrivs() const
{
std::list<Anope::string> priv_list = this->privs;
- for (std::set<OperType *>::const_iterator it = this->inheritances.begin(), it_end = this->inheritances.end(); it != it_end; ++it)
+ for (auto *ot : this->inheritances)
{
- OperType *ot = *it;
- std::list<Anope::string> priv = ot->GetPrivs();
- for (std::list<Anope::string>::const_iterator it2 = priv.begin(), it2_end = priv.end(); it2 != it2_end; ++it2)
- priv_list.push_back(*it2);
+ for (const auto &priv : ot->GetPrivs())
+ priv_list.push_back(priv);
}
return priv_list;
}
diff --git a/src/process.cpp b/src/process.cpp
index 3a21943f3..261849bae 100644
--- a/src/process.cpp
+++ b/src/process.cpp
@@ -133,7 +133,6 @@ Anope::string IRCDProto::Format(const Anope::string &source, const Anope::string
MessageTokenizer::MessageTokenizer(const Anope::string &msg)
: message(msg)
- , position(0)
{
}
diff --git a/src/protocol.cpp b/src/protocol.cpp
index f27866212..090187819 100644
--- a/src/protocol.cpp
+++ b/src/protocol.cpp
@@ -25,7 +25,7 @@ IRCDProto::IRCDProto(Module *creator, const Anope::string &p) : Service(creator,
{
DefaultPseudoclientModes = "+io";
CanSVSNick = CanSVSJoin = CanSetVHost = CanSetVIdent = CanSNLine = CanSQLine = CanSQLineChannel
- = CanSZLine = CanSVSHold = CanSVSO = CanCertFP = RequiresID = AmbiguousID = false;
+ = CanSZLine = CanSVSHold = CanCertFP = CanSendTags = RequiresID = AmbiguousID = false;
MaxModes = 3;
MaxLine = 512;
@@ -389,10 +389,8 @@ bool IRCDProto::IsIdentValid(const Anope::string &ident)
if (ident.empty() || ident.length() > Config->GetBlock("networkinfo")->Get<unsigned>("userlen"))
return false;
- for (unsigned i = 0; i < ident.length(); ++i)
+ for (auto c : ident)
{
- const char &c = ident[i];
-
if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || c == '.' || c == '-')
continue;
@@ -416,11 +414,11 @@ bool IRCDProto::IsHostValid(const Anope::string &host)
return false;
int dots = 0;
- for (unsigned i = 0; i < host.length(); ++i)
+ for (auto chr : host)
{
- if (host[i] == '.')
+ if (chr == '.')
++dots;
- if (vhostchars.find_first_of(host[i]) == Anope::string::npos)
+ if (vhostchars.find_first_of(chr) == Anope::string::npos)
return false;
}
@@ -450,7 +448,7 @@ Anope::string IRCDProto::NormalizeMask(const Anope::string &mask)
return Entry("", mask).GetNUHMask();
}
-MessageSource::MessageSource(const Anope::string &src) : source(src), u(NULL), s(NULL)
+MessageSource::MessageSource(const Anope::string &src) : source(src)
{
/* no source for incoming message is our uplink */
if (src.empty())
@@ -461,11 +459,11 @@ MessageSource::MessageSource(const Anope::string &src) : source(src), u(NULL), s
this->u = User::Find(src);
}
-MessageSource::MessageSource(User *_u) : source(_u ? _u->nick : ""), u(_u), s(NULL)
+MessageSource::MessageSource(User *_u) : source(_u ? _u->nick : ""), u(_u)
{
}
-MessageSource::MessageSource(Server *_s) : source(_s ? _s->GetName() : ""), u(NULL), s(_s)
+MessageSource::MessageSource(Server *_s) : source(_s ? _s->GetName() : ""), s(_s)
{
}
@@ -507,10 +505,3 @@ unsigned IRCDMessage::GetParamCount() const
{
return this->param_count;
}
-
-void IRCDMessage::Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags)
-{
- // Most IRCds don't support message tags yet so use the tagless variant.
- Run(source, params);
-}
-
diff --git a/src/regchannel.cpp b/src/regchannel.cpp
index 984da55ab..966f3e1b4 100644
--- a/src/regchannel.cpp
+++ b/src/regchannel.cpp
@@ -194,16 +194,16 @@ void ChannelInfo::Serialize(Serialize::Data &data) const
data.SetType("bantype", Serialize::Data::DT_INT); data["bantype"] << this->bantype;
{
Anope::string levels_buffer;
- for (Anope::map<int16_t>::const_iterator it = this->levels.begin(), it_end = this->levels.end(); it != it_end; ++it)
- levels_buffer += it->first + " " + stringify(it->second) + " ";
+ for (const auto &[name, level] : this->levels)
+ levels_buffer += name + " " + stringify(level) + " ";
data["levels"] << levels_buffer;
}
if (this->bi)
data["bi"] << this->bi->nick;
data.SetType("banexpire", Serialize::Data::DT_INT); data["banexpire"] << this->banexpire;
data["memomax"] << this->memos.memomax;
- for (unsigned i = 0; i < this->memos.ignores.size(); ++i)
- data["memoignores"] << this->memos.ignores[i] << " ";
+ for (const auto &ignore : this->memos.ignores)
+ data["memoignores"] << ignore << " ";
Extensible::ExtensibleSerialize(this, this, data);
}
@@ -443,12 +443,10 @@ AccessGroup ChannelInfo::AccessFor(const User *u, bool updateLastUsed)
if (updateLastUsed)
this->last_used = Anope::CurTime;
- for (unsigned i = 0; i < group.paths.size(); ++i)
+ for (auto &p : group.paths)
{
- ChanAccess::Path &p = group.paths[i];
-
- for (unsigned int j = 0; j < p.size(); ++j)
- p[j]->last_seen = Anope::CurTime;
+ for (auto *ca : p)
+ ca->last_seen = Anope::CurTime;
}
}
@@ -688,6 +686,6 @@ void ChannelInfo::RemoveChannelReference(const Anope::string &what)
void ChannelInfo::GetChannelReferences(std::deque<Anope::string> &chans)
{
chans.clear();
- for (Anope::map<int>::iterator it = references.begin(); it != references.end(); ++it)
- chans.push_back(it->first);
+ for (auto &[chan, _] : references)
+ chans.push_back(chan);
}
diff --git a/src/serialize.cpp b/src/serialize.cpp
index 873d304b1..03d9ed626 100644
--- a/src/serialize.cpp
+++ b/src/serialize.cpp
@@ -34,14 +34,13 @@ void Serialize::RegisterTypes()
void Serialize::CheckTypes()
{
- for (std::map<Anope::string, Serialize::Type *>::const_iterator it = Serialize::Type::GetTypes().begin(), it_end = Serialize::Type::GetTypes().end(); it != it_end; ++it)
+ for (const auto &[_, t] : Serialize::Type::GetTypes())
{
- Serialize::Type *t = it->second;
t->Check();
}
}
-Serializable::Serializable(const Anope::string &serialize_type) : last_commit(0), last_commit_time(0), id(0), redis_ignore(0)
+Serializable::Serializable(const Anope::string &serialize_type)
{
if (SerializableItems == NULL)
SerializableItems = new std::list<Serializable *>();
@@ -55,7 +54,7 @@ Serializable::Serializable(const Anope::string &serialize_type) : last_commit(0)
FOREACH_MOD(OnSerializableConstruct, (this));
}
-Serializable::Serializable(const Serializable &other) : last_commit(0), last_commit_time(0), id(0), redis_ignore(0)
+Serializable::Serializable(const Serializable &other)
{
SerializableItems->push_back(this);
this->s_iter = SerializableItems->end();
@@ -112,7 +111,7 @@ const std::list<Serializable *> &Serializable::GetItems()
return *SerializableItems;
}
-Type::Type(const Anope::string &n, unserialize_func f, Module *o) : name(n), unserialize(f), owner(o), timestamp(0)
+Type::Type(const Anope::string &n, unserialize_func f, Module *o) : name(n), unserialize(f), owner(o)
{
TypeOrder.push_back(this->name);
Types[this->name] = this;
@@ -124,13 +123,13 @@ Type::~Type()
{
/* null the type of existing serializable objects of this type */
if (Serializable::SerializableItems != NULL)
- for (std::list<Serializable *>::iterator it = Serializable::SerializableItems->begin(); it != Serializable::SerializableItems->end(); ++it)
+ {
+ for (auto *s : *Serializable::SerializableItems)
{
- Serializable *s = *it;
-
if (s->s_type == this)
s->s_type = NULL;
}
+ }
std::vector<Anope::string>::iterator it = std::find(TypeOrder.begin(), TypeOrder.end(), this->name);
if (it != TypeOrder.end())
diff --git a/src/servers.cpp b/src/servers.cpp
index 23ea18139..e8547015a 100644
--- a/src/servers.cpp
+++ b/src/servers.cpp
@@ -27,7 +27,7 @@ Anope::map<Server *> Servers::ByID;
std::set<Anope::string> Servers::Capab;
-Server::Server(Server *up, const Anope::string &sname, unsigned shops, const Anope::string &desc, const Anope::string &ssid, bool jupe) : name(sname), hops(shops), description(desc), sid(ssid), uplink(up), users(0)
+Server::Server(Server *up, const Anope::string &sname, unsigned shops, const Anope::string &desc, const Anope::string &ssid, bool jupe) : name(sname), hops(shops), description(desc), sid(ssid), uplink(up)
{
syncing = true;
juped = jupe;
@@ -48,27 +48,26 @@ Server::Server(Server *up, const Anope::string &sname, unsigned shops, const Ano
if (Me == this->uplink && !juped)
{
/* Now do mode related stuff as we know what modes exist .. */
- for (botinfo_map::iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it)
+ for (auto &[_, bi] : *BotListByNick)
{
- BotInfo *bi = it->second;
Anope::string modes = !bi->botmodes.empty() ? ("+" + bi->botmodes) : IRCD->DefaultPseudoclientModes;
bi->SetModesInternal(bi, modes.c_str());
- for (unsigned i = 0; i < bi->botchannels.size(); ++i)
+ for (const auto &botchannel : bi->botchannels)
{
- size_t h = bi->botchannels[i].find('#');
+ size_t h = botchannel.find('#');
if (h == Anope::string::npos)
continue;
- Anope::string chname = bi->botchannels[i].substr(h);
+ Anope::string chname = botchannel.substr(h);
Channel *c = Channel::Find(chname);
if (c && c->FindUser(bi))
{
- Anope::string want_modes = bi->botchannels[i].substr(0, h);
- for (unsigned j = 0; j < want_modes.length(); ++j)
+ Anope::string want_modes = botchannel.substr(0, h);
+ for (char want_mode : want_modes)
{
- ChannelMode *cm = ModeManager::FindChannelModeByChar(want_modes[j]);
+ ChannelMode *cm = ModeManager::FindChannelModeByChar(want_mode);
if (cm == NULL)
- cm = ModeManager::FindChannelModeByChar(ModeManager::GetStatusChar(want_modes[j]));
+ cm = ModeManager::FindChannelModeByChar(ModeManager::GetStatusChar(want_mode));
if (cm && cm->type == MODE_STATUS)
{
MessageSource ms = bi;
@@ -81,19 +80,15 @@ Server::Server(Server *up, const Anope::string &sname, unsigned shops, const Ano
IRCD->SendBOB();
- for (unsigned i = 0; i < Me->GetLinks().size(); ++i)
+ for (auto *link : Me->GetLinks())
{
- Server *s = Me->GetLinks()[i];
-
- if (s->juped)
- IRCD->SendServer(s);
+ if (link->juped)
+ IRCD->SendServer(link);
}
/* We make the bots go online */
- for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
+ for (const auto &[_, u] : UserListByNick)
{
- User *u = it->second;
-
BotInfo *bi = BotInfo::Find(u->GetUID());
if (bi)
{
@@ -106,22 +101,22 @@ Server::Server(Server *up, const Anope::string &sname, unsigned shops, const Ano
bi->introduced = true;
}
- for (channel_map::const_iterator it = ChannelList.begin(), it_end = ChannelList.end(); it != it_end; ++it)
+ for (const auto &[_, c] : ChannelList)
{
- Channel *c = it->second;
-
if (c->users.empty())
IRCD->SendChannel(c);
else
- for (Channel::ChanUserList::const_iterator cit = c->users.begin(), cit_end = c->users.end(); cit != cit_end; ++cit)
- IRCD->SendJoin(cit->second->user, c, &cit->second->status);
+ {
+ for (const auto &[_, uc] : c->users)
+ IRCD->SendJoin(uc->user, c, &uc->status);
+ }
- for (Channel::ModeList::const_iterator it2 = c->GetModes().begin(); it2 != c->GetModes().end(); ++it2)
+ for (const auto &[mode, value] : c->GetModes())
{
- ChannelMode *cm = ModeManager::FindChannelModeByName(it2->first);
+ ChannelMode *cm = ModeManager::FindChannelModeByName(mode);
if (!cm || cm->type != MODE_LIST)
continue;
- ModeManager::StackerAdd(c->WhoSends(), c, cm, true, it2->second);
+ ModeManager::StackerAdd(c->WhoSends(), c, cm, true, value);
}
if (!c->topic.empty() && !c->topic_setter.empty())
@@ -139,10 +134,8 @@ Server::~Server()
{
Log(this, "quit") << "quit from " << (this->uplink ? this->uplink->GetName() : "no uplink") << " for " << this->quit_reason;
- for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
+ for (const auto &[_, u] : UserListByNick)
{
- User *u = it->second;
-
if (u->server == this)
{
u->Quit(this->quit_reason);
@@ -259,8 +252,8 @@ void Server::Sync(bool sync_links)
if (sync_links && !this->links.empty())
{
- for (unsigned i = 0, j = this->links.size(); i < j; ++i)
- this->links[i]->Sync(true);
+ for (auto *link : this->links)
+ link->Sync(true);
}
bool me = this->GetUplink() && this->GetUplink() == Me;
@@ -309,9 +302,11 @@ bool Server::IsULined() const
if (this == Me)
return true;
- for (unsigned i = 0; i < Config->Ulines.size(); ++i)
- if (Config->Ulines[i].equals_ci(this->GetName()))
+ for (const auto &uline : Config->Ulines)
+ {
+ if (uline.equals_ci(this->GetName()))
return true;
+ }
return false;
}
@@ -353,8 +348,10 @@ Server *Server::Find(const Anope::string &name, bool name_only)
Server* Servers::GetUplink()
{
- for (unsigned i = 0; Me && i < Me->GetLinks().size(); ++i)
- if (!Me->GetLinks()[i]->IsJuped())
- return Me->GetLinks()[i];
+ for (auto *link : Me->GetLinks())
+ {
+ if (!link->IsJuped())
+ return link;
+ }
return NULL;
}
diff --git a/src/siphash.cpp b/src/siphash.cpp
index c98147131..f4b0b0b62 100644
--- a/src/siphash.cpp
+++ b/src/siphash.cpp
@@ -120,12 +120,12 @@ uint64_t Anope::SipHash24(const void *src, unsigned long src_sz, const char key[
uint64_t t = 0; uint8_t *pt = (uint8_t *)&t; uint8_t *m = (uint8_t *)in;
switch (src_sz)
{
- case 7: pt[6] = m[6];
- case 6: pt[5] = m[5];
- case 5: pt[4] = m[4];
+ case 7: pt[6] = m[6]; [[fallthrough]];
+ case 6: pt[5] = m[5]; [[fallthrough]];
+ case 5: pt[4] = m[4]; [[fallthrough]];
case 4: *((uint32_t*)&pt[0]) = *((uint32_t*)&m[0]); break;
- case 3: pt[2] = m[2];
- case 2: pt[1] = m[1];
+ case 3: pt[2] = m[2]; [[fallthrough]];
+ case 2: pt[1] = m[1]; [[fallthrough]];
case 1: pt[0] = m[0];
}
b |= _le64toh(t);
diff --git a/src/socket_clients.cpp b/src/socket_clients.cpp
index da5057b19..5a992a4a3 100644
--- a/src/socket_clients.cpp
+++ b/src/socket_clients.cpp
@@ -14,7 +14,7 @@
#include "logger.h"
#include "sockets.h"
-#include <errno.h>
+#include <cerrno>
void ConnectionSocket::Connect(const Anope::string &TargetHost, int Port)
{
diff --git a/src/socket_transport.cpp b/src/socket_transport.cpp
index a7aef0b70..b10bf2f0a 100644
--- a/src/socket_transport.cpp
+++ b/src/socket_transport.cpp
@@ -13,14 +13,6 @@
#include "sockets.h"
#include "socketengine.h"
-BufferedSocket::BufferedSocket()
-{
-}
-
-BufferedSocket::~BufferedSocket()
-{
-}
-
bool BufferedSocket::ProcessRead()
{
char tbuffer[NET_BUFSIZE];
@@ -115,14 +107,6 @@ BinarySocket::DataBlock::~DataBlock()
delete [] this->orig;
}
-BinarySocket::BinarySocket()
-{
-}
-
-BinarySocket::~BinarySocket()
-{
-}
-
bool BinarySocket::ProcessRead()
{
char tbuffer[NET_BUFSIZE];
diff --git a/src/socketengines/socketengine_epoll.cpp b/src/socketengines/socketengine_epoll.cpp
index e0c978010..0d5f4e005 100644
--- a/src/socketengines/socketengine_epoll.cpp
+++ b/src/socketengines/socketengine_epoll.cpp
@@ -15,9 +15,9 @@
#include "socketengine.h"
#include "config.h"
+#include <cerrno>
#include <sys/epoll.h>
#include <ulimit.h>
-#include <errno.h>
static int EngineHandle;
static std::vector<epoll_event> events;
@@ -53,7 +53,7 @@ void SocketEngine::Change(Socket *s, bool set, SocketFlag flag)
memset(&ev, 0, sizeof(ev));
- ev.events = (s->flags[SF_READABLE] ? EPOLLIN : 0) | (s->flags[SF_WRITABLE] ? EPOLLOUT : 0);
+ ev.events = (s->flags[SF_READABLE] ? EPOLLIN : 0u) | (s->flags[SF_WRITABLE] ? EPOLLOUT : 0u);
ev.data.fd = s->GetFD();
int mod;
diff --git a/src/sockets.cpp b/src/sockets.cpp
index 153eadf7f..277ec2d14 100644
--- a/src/sockets.cpp
+++ b/src/sockets.cpp
@@ -16,7 +16,7 @@
#ifndef _WIN32
#include <arpa/inet.h>
-#include <errno.h>
+#include <cerrno>
#include <fcntl.h>
#endif
@@ -52,6 +52,8 @@ size_t sockaddrs::size() const
return sizeof(sa4);
case AF_INET6:
return sizeof(sa6);
+ case AF_UNIX:
+ return sizeof(saun);
default:
break;
}
@@ -67,6 +69,8 @@ int sockaddrs::port() const
return ntohs(sa4.sin_port);
case AF_INET6:
return ntohs(sa6.sin6_port);
+ case AF_UNIX:
+ return 0;
default:
break;
}
@@ -76,18 +80,51 @@ int sockaddrs::port() const
Anope::string sockaddrs::addr() const
{
- char address[INET6_ADDRSTRLEN];
-
switch (sa.sa_family)
{
case AF_INET:
- if (inet_ntop(AF_INET, &sa4.sin_addr, address, sizeof(address)))
- return address;
+ {
+ char v4address[INET_ADDRSTRLEN];
+ if (inet_ntop(AF_INET, &sa4.sin_addr, v4address, sizeof(v4address)))
+ return v4address;
break;
+ }
case AF_INET6:
- if (inet_ntop(AF_INET6, &sa6.sin6_addr, address, sizeof(address)))
- return address;
+ {
+ char v6address[INET6_ADDRSTRLEN];
+ if (inet_ntop(AF_INET6, &sa6.sin6_addr, v6address, sizeof(v6address)))
+ return v6address;
break;
+ }
+ case AF_UNIX:
+ return saun.sun_path;
+ default:
+ break;
+ }
+
+ return "";
+}
+
+Anope::string sockaddrs::str() const
+{
+ switch (sa.sa_family)
+ {
+ case AF_INET:
+ {
+ char v4address[INET_ADDRSTRLEN];
+ if (!inet_ntop(AF_INET, &sa4.sin_addr, v4address, sizeof(v4address)))
+ strcpy(v4address, "0.0.0.0");
+ return Anope::printf("%s:%u", v4address, sa4.sin_port);
+ }
+ case AF_INET6:
+ {
+ char v6address[INET6_ADDRSTRLEN];
+ if (!inet_ntop(AF_INET6, &sa6.sin6_addr, v6address, sizeof(v6address)))
+ strcpy(v6address, "0:0:0:0:0:0:0:0");
+ return Anope::printf("[%s]:%u", v6address, sa6.sin6_port);
+ }
+ case AF_UNIX:
+ return saun.sun_path;
default:
break;
}
@@ -187,6 +224,15 @@ void sockaddrs::pton(int type, const Anope::string &address, int pport)
}
break;
}
+ case AF_UNIX:
+ {
+ if (address.length() < sizeof(saun.sun_path))
+ {
+ saun.sun_family = AF_UNIX;
+ memcpy(&saun.sun_path, address.c_str(), address.length() + 1);
+ }
+ break;
+ }
default:
break;
}
@@ -306,7 +352,7 @@ bool cidr::match(const sockaddrs &other)
byte = len % 8;
if (byte)
{
- uint8_t m = ~0 << (8 - byte);
+ uint8_t m = ~0u << (8 - byte);
return (*ip & m) == (*their_ip & m);
}
@@ -432,7 +478,7 @@ SocketFlag SocketIO::FinishAccept(ClientSocket *cs)
void SocketIO::Bind(Socket *s, const Anope::string &ip, int port)
{
- s->bindaddr.pton(s->IsIPv6() ? AF_INET6 : AF_INET, ip, port);
+ s->bindaddr.pton(s->GetFamily(), ip, port);
if (bind(s->GetFD(), &s->bindaddr.sa, s->bindaddr.size()) == -1)
throw SocketException("Unable to bind to address: " + Anope::LastError());
}
@@ -440,7 +486,7 @@ void SocketIO::Bind(Socket *s, const Anope::string &ip, int port)
void SocketIO::Connect(ConnectionSocket *s, const Anope::string &target, int port)
{
s->flags[SF_CONNECTING] = s->flags[SF_CONNECTED] = false;
- s->conaddr.pton(s->IsIPv6() ? AF_INET6 : AF_INET, target, port);
+ s->conaddr.pton(s->GetFamily(), target, port);
int c = connect(s->GetFD(), &s->conaddr.sa, s->conaddr.size());
if (c == -1)
{
@@ -488,12 +534,12 @@ Socket::Socket()
throw CoreException("Socket::Socket() ?");
}
-Socket::Socket(int s, bool i, int type)
+Socket::Socket(int s, int f, int type)
{
this->io = &NormalSocketIO;
- this->ipv6 = i;
+ this->family = f;
if (s == -1)
- this->sock = socket(this->ipv6 ? AF_INET6 : AF_INET, type, 0);
+ this->sock = socket(this->family, type, 0);
else
this->sock = s;
this->SetBlocking(false);
@@ -510,14 +556,14 @@ Socket::~Socket()
SocketEngine::Sockets.erase(this->sock);
}
-int Socket::GetFD() const
+int Socket::GetFamily() const
{
- return sock;
+ return family;
}
-bool Socket::IsIPv6() const
+int Socket::GetFD() const
{
- return ipv6;
+ return sock;
}
bool Socket::SetBlocking(bool state)
@@ -567,10 +613,6 @@ ListenSocket::ListenSocket(const Anope::string &bindip, int port, bool i)
throw SocketException("Unable to listen: " + Anope::LastError());
}
-ListenSocket::~ListenSocket()
-{
-}
-
bool ListenSocket::ProcessRead()
{
try
diff --git a/src/threadengine.cpp b/src/threadengine.cpp
index cecec9f22..d3d843794 100644
--- a/src/threadengine.cpp
+++ b/src/threadengine.cpp
@@ -44,14 +44,6 @@ static void *entry_point(void *parameter)
return NULL;
}
-Thread::Thread() : exit(false)
-{
-}
-
-Thread::~Thread()
-{
-}
-
void Thread::Join()
{
this->SetExitState();
diff --git a/src/timers.cpp b/src/timers.cpp
index cc2a93693..1ba88f67e 100644
--- a/src/timers.cpp
+++ b/src/timers.cpp
@@ -80,7 +80,7 @@ Module *Timer::GetOwner() const
void TimerManager::AddTimer(Timer *t)
{
- Timers.insert(std::make_pair(t->GetTimer(), t));
+ Timers.emplace(t->GetTimer(), t);
}
void TimerManager::DelTimer(Timer *t)
diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt
index 3e00b981d..5aa833ea9 100644
--- a/src/tools/CMakeLists.txt
+++ b/src/tools/CMakeLists.txt
@@ -1,6 +1,6 @@
# Find all the *.cpp files within the current source directory, and sort the list
file(GLOB TOOLS_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cpp")
-sort_list(TOOLS_SRCS)
+list(SORT TOOLS_SRCS)
# Set all the files to use C++ as well as set their compile flags
set_source_files_properties(${TOOLS_SRCS} PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${CXXFLAGS}")
@@ -9,31 +9,22 @@ set_source_files_properties(${TOOLS_SRCS} PROPERTIES LANGUAGE CXX COMPILE_FLAGS
foreach(SRC ${TOOLS_SRCS})
# Convert the source file extension to have no extension
string(REGEX REPLACE "\\.cpp$" "" EXE ${SRC})
- # Calculate the header file dependencies for the given source file
- calculate_depends(${SRC})
# Only continue if this file isn't skipped
if(NOT SKIP)
# Generate the executable and set its linker flags, also set it to depend on the main Anope executable to be built beforehand
add_executable(${EXE} ${SRC})
set_target_properties(${EXE} PROPERTIES LINKER_LANGUAGE CXX LINK_FLAGS "${LDFLAGS}")
add_dependencies(${EXE} ${PROGRAM_NAME})
- # Only for Windows, set anopesmtp to require the wsock32 library
- if(WIN32 AND ${EXE} STREQUAL anopesmtp)
- target_link_libraries(${EXE} wsock32)
- endif(WIN32 AND ${EXE} STREQUAL anopesmtp)
- if(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS" AND ${EXE} STREQUAL anopesmtp)
- target_link_libraries(${EXE} socket nsl)
- endif(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS" AND ${EXE} STREQUAL anopesmtp)
# Set the executable to be installed to the bin directory under the main directory
install(TARGETS ${EXE}
DESTINATION ${BIN_DIR}
)
# Add the executable to the list of files for CPack to ignore
- get_target_property(EXE_BINARY ${EXE} LOCATION)
+ set(EXE_BINARY "$<TARGET_FILE:${EXE}>")
get_filename_component(EXE_BINARY ${EXE_BINARY} NAME)
add_to_cpack_ignored_files("${EXE_BINARY}$" TRUE)
- endif(NOT SKIP)
-endforeach(SRC)
+ endif()
+endforeach()
# If not on Windows, generate anoperc and install it along with mydbgen
if(NOT WIN32)
@@ -44,9 +35,9 @@ if(NOT WIN32)
install (PROGRAMS geoipupdate.sh
DESTINATION ${BIN_DIR}
)
-endif(NOT WIN32)
+endif()
# On non-Windows platforms, if RUNGROUP is set, change the permissions of the tools directory
if(NOT WIN32 AND RUNGROUP)
install(CODE "execute_process(COMMAND ${CHMOD} 2770 \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/bin\")")
-endif(NOT WIN32 AND RUNGROUP)
+endif()
diff --git a/src/tools/anoperc.in b/src/tools/anoperc.in
index 823f99d5e..5a68b01f1 100644
--- a/src/tools/anoperc.in
+++ b/src/tools/anoperc.in
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# Configuration script for Services
+# Configuration script for Anope
#
# (C) 2003-2023 Anope Team
# Contact us at team@anope.org
@@ -14,8 +14,8 @@
-ANOPEPID="@INSTDIR@/data/services.pid"
-ANOPROG="@INSTDIR@/bin/services"
+ANOPEPID="@INSTDIR@/data/anope.pid"
+ANOPROG="@INSTDIR@/bin/anope"
LOG="@INSTDIR@/logs/"
ARCVERSION="2"
diff --git a/src/tools/anopesmtp.cpp b/src/tools/anopesmtp.cpp
deleted file mode 100644
index 686627e6f..000000000
--- a/src/tools/anopesmtp.cpp
+++ /dev/null
@@ -1,535 +0,0 @@
-/* smtp stuff handler for win32.
- *
- * (C) 2003-2023 Anope Team
- * Contact us at team@anope.org
- *
- * Please read COPYING and README for further details.
- *
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
- *
- * Written by Dominick Meglio <codemastr@unrealircd.com>
- * *nix port by Trystan Scott Lee <trystan@nomadirc.net>
- */
-
-#include "sysconf.h"
-
-/* Some Linux boxes (or maybe glibc includes) require this for the
- * prototype of strsignal(). */
-#ifndef _GNU_SOURCE
-# define _GNU_SOURCE
-#endif
-
-#include <string>
-#include <vector>
-#include <cstdarg>
-#include <cstdio>
-#include <cstdlib>
-#include <cstring>
-#include <ctime>
-#include <cerrno>
-#include <iostream>
-#include <fstream>
-
-#ifndef _WIN32
-# include <unistd.h>
-# include <netdb.h>
-# include <netinet/in.h>
-# include <sys/socket.h>
-# include <arpa/inet.h>
-# include <sys/time.h>
-#else
-# include <winsock.h>
-# define WIN32_LEAN_AND_MEAN
-# include <windows.h>
-#endif
-
-#include <sys/types.h>
-
-#ifdef _AIX
-extern int strcasecmp(const char *, const char *);
-extern int strncasecmp(const char *, const char *, size_t);
-# if 0 /* These break on some AIX boxes (4.3.1 reported). */
-extern int socket(int, int, int);
-extern int connect(int, struct sockaddr *, int);
-# endif
-#endif /* _AIX */
-
-/* Some SUN fixs */
-#ifdef __sun
-/* Solaris specific code, types that do not exist in Solaris'
- * * sys/types.h
- * **/
-# ifndef INADDR_NONE
-# define INADDR_NONE (-1)
-# endif
-#endif
-
-#ifdef _WIN32
-typedef SOCKET ano_socket_t;
-#define ano_sockclose(fd) closesocket(fd)
-#define ano_sockread(fd, buf, len) recv(fd, buf, len, 0)
-#define ano_sockwrite(fd, buf, len) send(fd, buf, len, 0)
-#else
-typedef int ano_socket_t;
-#define ano_sockclose(fd) close(fd)
-#define ano_sockread(fd, buf, len) read(fd, buf, len)
-#define ano_sockwrite(fd, buf, len) write(fd, buf, len)
-#define SOCKET_ERROR -1
-#endif
-
-/* Data structures */
-struct smtp_message
-{
- std::vector<std::string> smtp_headers;
- std::vector<std::string> smtp_body;
- std::string from;
- std::string to;
- ano_socket_t sock;
-};
-
-int smtp_debug = 0;
-
-struct smtp_message smail;
-
-static std::string get_logname(struct tm *tm = NULL)
-{
- char timestamp[32];
-
- if (!tm)
- {
- time_t t = time(NULL);
- tm = localtime(&t);
- }
-
- strftime(timestamp, sizeof(timestamp), "%Y%m%d", tm);
- std::string name = std::string("anopesmtp.") + timestamp;
- return name;
-}
-
-/* TimeStamp for Email Header */
-static std::string GetTimeStamp()
-{
- char tbuf[256];
- time_t t = time(NULL);
- struct tm *tm = gmtime(&t);
-
- strftime(tbuf, sizeof(tbuf) - 1, "%a, %d %b %Y %H:%M:%S +0000", tm);
-
- return tbuf;
-}
-
-/* Log stuff to the log file with a datestamp. Note that errno is
- * preserved by this routine and log_perror().
- */
-
-void alog(const char *fmt, ...)
-{
- if (!smtp_debug || !fmt)
- return;
-
- std::fstream file;
- file.open(get_logname().c_str(), std::ios_base::out | std::ios_base::app);
-
- if (!file.is_open())
- return;
-
- va_list args;
- va_start(args, fmt);
-
- time_t t = time(NULL);
- struct tm *tm = localtime(&t);
-
- char buf[256];
- strftime(buf, sizeof(buf) - 1, "[%b %d %H:%M:%S %Y] ", tm);
- file << buf;
- vsnprintf(buf, sizeof(buf), fmt, args);
- file << buf << std::endl;
- va_end(args);
- va_end(args);
-
- file.close();
-}
-
-/* Remove a trailing \r\n */
-std::string strip(const std::string &buf)
-{
- std::string newbuf = buf;
- char c = newbuf[newbuf.size() - 1];
- while (c == '\n' || c == '\r')
- {
- newbuf.erase(newbuf.end() - 1);
- c = newbuf[newbuf.size() - 1];
- }
- return newbuf;
-}
-
-/* Is the buffer a header? */
-bool smtp_is_header(const std::string &buf)
-{
- size_t tmp = buf.find(' ');
-
- if (tmp == std::string::npos)
- return false;
-
- if (tmp > 0 && buf[tmp - 1] == ':')
- return true;
- return false;
-}
-
-/* Parse a header into a name and value */
-void smtp_parse_header(const std::string &buf, std::string &header, std::string &value)
-{
- std::string newbuf = strip(buf);
-
- size_t space = newbuf.find(' ');
- if (space != std::string::npos)
- {
- header = newbuf.substr(0, space);
- value = newbuf.substr(space + 1);
- }
- else
- {
- header = newbuf;
- value = "";
- }
-}
-
-/* Have we reached the end of input? */
-bool smtp_is_end(const std::string &buf)
-{
- if (buf[0] == '.')
- if (buf[1] == '\r' || buf[1] == '\n')
- return true;
-
- return false;
-}
-
-/* Set who the email is to */
-void smtp_set_to(const std::string &to)
-{
- smail.to = to;
- size_t c = smail.to.rfind('<');
- if (c != std::string::npos && c + 1 < smail.to.size())
- {
- smail.to = smail.to.substr(c + 1);
- smail.to.erase(smail.to.end() - 1);
- }
-}
-
-/* Establish a connection to the SMTP server */
-int smtp_connect(const char *host, unsigned short port)
-{
- struct sockaddr_in addr;
-
- if ((smail.sock = socket(AF_INET, SOCK_STREAM, 0)) == SOCKET_ERROR)
- return 0;
-
- if ((addr.sin_addr.s_addr = inet_addr(host)) == INADDR_NONE)
- {
- struct hostent *hent;
- if (!(hent = gethostbyname(host)))
- return 0;
- memcpy(&addr.sin_addr, hent->h_addr, hent->h_length);
- }
- addr.sin_family = AF_INET;
- addr.sin_port = htons(port ? port : 25);
- if (connect(smail.sock, reinterpret_cast<struct sockaddr *>(&addr), sizeof(struct sockaddr_in)) == SOCKET_ERROR)
- {
- ano_sockclose(smail.sock);
- return 0;
- }
-
- return 1;
-}
-
-/* Send a line of text */
-int smtp_send(const char *text)
-{
- int result = ano_sockwrite(smail.sock, text, strlen(text));
-
- alog("SMTP: sent %s",text);
-
- if (result == SOCKET_ERROR)
- ano_sockclose(smail.sock);
-
- return result;
-}
-
-/* Read a line of text */
-int smtp_read(char *buf, int len)
-{
- int result;
-
- memset(buf, 0, len);
- result = ano_sockread(smail.sock, buf, len);
-
- if (result == SOCKET_ERROR)
- ano_sockclose(smail.sock);
-
- return result;
-}
-
-/* Retrieve a response code */
-int smtp_get_code(const std::string &text)
-{
- size_t tmp = text.find(' ');
-
- if (tmp == std::string::npos)
- return 0;
-
- return atol(text.substr(0, tmp).c_str());
-}
-
-/* Send the email */
-int smtp_send_email()
-{
- char buf[1024];
- if (!smtp_read(buf, 1024))
- {
- alog("SMTP: error reading buffer");
- return 0;
- }
-
- int code = smtp_get_code(buf);
- if (code != 220)
- {
- alog("SMTP: error expected code 220 got %d",code);
- return 0;
- }
-
- if (!smtp_send("HELO anope\r\n"))
- {
- alog("SMTP: error writing to socket");
- return 0;
- }
-
- if (!smtp_read(buf, 1024))
- {
- alog("SMTP: error reading buffer");
- return 0;
- }
-
- code = smtp_get_code(buf);
- if (code != 250)
- {
- alog("SMTP: error expected code 250 got %d",code);
- return 0;
- }
-
- strcpy(buf, "MAIL FROM: <");
- strcat(buf, smail.from.c_str());
- strcat(buf, ">\r\n");
-
- if (!smtp_send(buf))
- {
- alog("SMTP: error writing to socket");
- return 0;
- }
-
- if (!smtp_read(buf, 1024))
- {
- alog("SMTP: error reading buffer");
- return 0;
- }
-
- code = smtp_get_code(buf);
- if (code != 250)
- return 0;
-
- strcpy(buf, "RCPT TO: <");
- strcat(buf, smail.to.c_str());
- strcat(buf, ">\r\n");
-
- if (!smtp_send(buf))
- {
- alog("SMTP: error writing to socket");
- return 0;
- }
-
- if (!smtp_read(buf, 1024))
- {
- alog("SMTP: error reading buffer");
- return 0;
- }
-
- code = smtp_get_code(buf);
- if (smtp_get_code(buf) != 250)
- {
- alog("SMTP: error expected code 250 got %d",code);
- return 0;
- }
-
- if (!smtp_send("DATA\r\n"))
- {
- alog("SMTP: error writing to socket");
- return 0;
- }
-
- if (!smtp_read(buf, 1024))
- {
- alog("SMTP: error reading buffer");
- return 0;
- }
-
- code = smtp_get_code(buf);
- if (code != 354)
- {
- alog("SMTP: error expected code 354 got %d",code);
- return 0;
- }
-
- for (std::vector<std::string>::const_iterator it = smail.smtp_headers.begin(), it_end = smail.smtp_headers.end(); it != it_end; ++it)
- if (!smtp_send(it->c_str()))
- {
- alog("SMTP: error writing to socket");
- return 0;
- }
-
- if (!smtp_send("\r\n"))
- {
- alog("SMTP: error writing to socket");
- return 0;
- }
-
- bool skip_done = false;
- for (std::vector<std::string>::const_iterator it = smail.smtp_body.begin(), it_end = smail.smtp_body.end(); it != it_end; ++it)
- if (skip_done)
- {
- if (!smtp_send(it->c_str()))
- {
- alog("SMTP: error writing to socket");
- return 0;
- }
- }
- else
- skip_done = true;
-
- if (!smtp_send("\r\n.\r\n"))
- {
- alog("SMTP: error writing to socket");
- return 0;
- }
-
- if (!smtp_read(buf, 1024))
- {
- alog("SMTP: error reading buffer");
- return 0;
- }
-
- code = smtp_get_code(buf);
- if (code != 250)
- {
- alog("SMTP: error expected code 250 got %d",code);
- return 0;
- }
-
- return 1;
-}
-
-void smtp_disconnect()
-{
- char buf[1024];
-
- if (!smtp_send("QUIT\r\n"))
- {
- alog("SMTP: error writing to socket");
- }
-
- if (!smtp_read(buf, 1024))
- {
- alog("SMTP: error reading buffer");
- }
-
- int code = smtp_get_code(buf);
- if (code != 221)
- {
- alog("SMTP: error expected code 221 got %d",code);
- }
-
- ano_sockclose(smail.sock);
-}
-
-int main(int argc, char *argv[])
-{
- /* Win32 stuff */
-#ifdef _WIN32
- WSADATA wsa;
-#endif
-
- if (argc == 1)
- return 0;
-
- if (argc == 3 && !strcmp(argv[2], "--debug"))
- smtp_debug = 1;
-
- char *server = strtok(argv[1], ":"), *aport;
- short port;
- if ((aport = strtok(NULL, "")))
- port = atoi(aport);
- else
- port = 25;
-
- if (!server)
- {
- alog("No Server");
- /* Bad, bad, bad. This was a return from main with no value! -GD */
- return 0;
- }
- else
- alog("SMTP: server %s port %d",server,port);
-
- /* The WSAStartup function initiates use of WS2_32.DLL by a process. */
- /* guessing we can skip it under *nix */
-#ifdef _WIN32
- if (WSAStartup(MAKEWORD(1, 1), &wsa))
- return 0;
-#endif
-
- char buf[8192];
- bool headers_done = false;
- /* Read the message and parse it */
- while (fgets(buf, 8192, stdin))
- {
- if (smtp_is_header(buf) && !headers_done)
- {
- smail.smtp_headers.push_back(strip(buf) + "\r\n");
- std::string header, value;
- smtp_parse_header(buf, header, value);
- if (header == "From:")
- {
- alog("SMTP: from: %s", value.c_str());
- smail.from = value;
- }
- else if (header == "To:")
- {
- alog("SMTP: to: %s", value.c_str());
- smtp_set_to(value);
- }
- else if (smtp_is_end(buf))
- break;
- else
- {
- smail.smtp_headers.push_back("Date: " + GetTimeStamp() + "\r\n");
- headers_done = true;
- smail.smtp_body.push_back(strip(buf) + "\r\n");
- }
- }
- else
- smail.smtp_body.push_back(strip(buf) + "\r\n");
- }
-
- if (!smtp_connect(server, port))
- {
- alog("SMTP: failed to connect to %s:%d", server, port);
- return 0;
- }
- if (!smtp_send_email())
- {
- alog("SMTP: error during sending of mail");
- return 0;
- }
- smtp_disconnect();
-
- return 1;
-}
diff --git a/src/uplink.cpp b/src/uplink.cpp
index b0ce92b33..67599c2d6 100644
--- a/src/uplink.cpp
+++ b/src/uplink.cpp
@@ -22,7 +22,7 @@ class ReconnectTimer : public Timer
public:
ReconnectTimer(int wait) : Timer(wait) { }
- void Tick(time_t)
+ void Tick(time_t) override
{
try
{
@@ -52,12 +52,12 @@ void Uplink::Connect()
if (!Config->GetBlock("serverinfo")->Get<const Anope::string>("localhost").empty())
UplinkSock->Bind(Config->GetBlock("serverinfo")->Get<const Anope::string>("localhost"));
FOREACH_MOD(OnPreServerConnect, ());
- Anope::string ip = Anope::Resolve(u.host, u.ipv6 ? AF_INET6 : AF_INET);
+ Anope::string ip = Anope::Resolve(u.host, u.protocol);
Log(LOG_TERMINAL) << "Attempting to connect to uplink #" << (Anope::CurrentUplink + 1) << " " << u.host << " (" << ip << '/' << u.port << ") with protocol " << IRCD->GetProtocolName();
UplinkSock->Connect(ip, u.port);
}
-UplinkSocket::UplinkSocket() : Socket(-1, Config->Uplinks[Anope::CurrentUplink].ipv6), ConnectionSocket(), BufferedSocket()
+UplinkSocket::UplinkSocket() : Socket(-1, Config->Uplinks[Anope::CurrentUplink].protocol), ConnectionSocket(), BufferedSocket()
{
error = false;
UplinkSock = this;
@@ -79,10 +79,8 @@ UplinkSocket::~UplinkSocket()
{
FOREACH_MOD(OnServerDisconnect, ());
- for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
+ for (const auto &[_, u] : UserListByNick)
{
- User *u = it->second;
-
if (u->server == Me)
{
/* Don't use quitmsg here, it may contain information you don't want people to see */
diff --git a/src/users.cpp b/src/users.cpp
index 09529bb5f..ce22828a9 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -448,6 +448,11 @@ bool User::IsRecognized(bool check_secure) const
return on_access;
}
+bool User::IsSecurelyConnected() const
+{
+ return HasMode("SSL") || HasExt("ssl");
+}
+
bool User::IsServicesOper()
{
if (!this->nc || !this->nc->IsServicesOper())
@@ -463,9 +468,8 @@ bool User::IsServicesOper()
bool match = false;
Anope::string match_host = this->GetIdent() + "@" + this->host;
Anope::string match_ip = this->GetIdent() + "@" + this->ip.addr();
- for (unsigned i = 0; i < this->nc->o->hosts.size(); ++i)
+ for (const auto &userhost : this->nc->o->hosts)
{
- const Anope::string &userhost = this->nc->o->hosts[i];
if (Anope::Match(match_host, userhost) || Anope::Match(match_ip, userhost))
{
match = true;
@@ -624,11 +628,11 @@ void User::SetModes(BotInfo *bi, const char *umodes, ...)
spacesepstream sep(buf);
sep.GetToken(modebuf);
- for (unsigned i = 0, end = modebuf.length(); i < end; ++i)
+ for (auto mode : modebuf)
{
UserMode *um;
- switch (modebuf[i])
+ switch (mode)
{
case '+':
add = 1;
@@ -639,7 +643,7 @@ void User::SetModes(BotInfo *bi, const char *umodes, ...)
default:
if (add == -1)
continue;
- um = ModeManager::FindUserModeByChar(modebuf[i]);
+ um = ModeManager::FindUserModeByChar(mode);
if (!um)
continue;
}
@@ -671,11 +675,11 @@ void User::SetModesInternal(const MessageSource &source, const char *umodes, ...
spacesepstream sep(buf);
sep.GetToken(modebuf);
- for (unsigned i = 0, end = modebuf.length(); i < end; ++i)
+ for (auto mode : modebuf)
{
UserMode *um;
- switch (modebuf[i])
+ switch (mode)
{
case '+':
add = 1;
@@ -686,7 +690,7 @@ void User::SetModesInternal(const MessageSource &source, const char *umodes, ...
default:
if (add == -1)
continue;
- um = ModeManager::FindUserModeByChar(modebuf[i]);
+ um = ModeManager::FindUserModeByChar(mode);
if (!um)
continue;
}
@@ -707,16 +711,16 @@ Anope::string User::GetModes() const
{
Anope::string m, params;
- for (ModeList::const_iterator it = this->modes.begin(), it_end = this->modes.end(); it != it_end; ++it)
+ for (const auto &[mode, value] : this->modes)
{
- UserMode *um = ModeManager::FindUserModeByName(it->first);
+ UserMode *um = ModeManager::FindUserModeByName(mode);
if (um == NULL)
continue;
m += um->mchar;
- if (!it->second.empty())
- params += " " + it->second;
+ if (!value.empty())
+ params += " " + value;
}
return m + params;
@@ -847,7 +851,7 @@ User* User::Find(const Anope::string &name, bool nick_only)
void User::QuitUsers()
{
- for (std::list<User *>::iterator it = quitting_users.begin(), it_end = quitting_users.end(); it != it_end; ++it)
- delete *it;
+ for (const auto *quitting_user : quitting_users)
+ delete quitting_user;
quitting_users.clear();
}
diff --git a/src/version.sh b/src/version.sh
index c4597b675..c79f66a2f 100644
--- a/src/version.sh
+++ b/src/version.sh
@@ -1,6 +1,6 @@
#!/bin/sh
VERSION_MAJOR=2
-VERSION_MINOR=0
-VERSION_PATCH=15
+VERSION_MINOR=1
+VERSION_PATCH=0
VERSION_EXTRA="-git"
diff --git a/src/win32/anope_windows.h b/src/win32/anope_windows.h
index 53cb91115..691f731d0 100644
--- a/src/win32/anope_windows.h
+++ b/src/win32/anope_windows.h
@@ -29,9 +29,7 @@
# define DllExport __declspec(dllimport)
#endif
-#define MARK_DEPRECATED
-
-#if GETTEXT_FOUND
+#if HAVE_LOCALIZATION
/* Undefine some functions libintl defines */
# undef snprintf
# undef vsnprintf
@@ -53,7 +51,6 @@
#define EINPROGRESS WSAEWOULDBLOCK
#include "socket.h"
-#include "dir/dir.h"
#include "dl/dl.h"
#include "pipe/pipe.h"
#include "pthread/pthread.h"
diff --git a/src/win32/dir/dir.cpp b/src/win32/dir/dir.cpp
deleted file mode 100644
index a3e731a5f..000000000
--- a/src/win32/dir/dir.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-/* POSIX emulation layer for Windows.
- *
- * (C) 2008-2023 Anope Team
- * Contact us at team@anope.org
- *
- * Please read COPYING and README for further details.
- */
-
-#include "dir.h"
-#include <stdio.h>
-
-DIR *opendir(const char *path)
-{
- char real_path[MAX_PATH];
- _snprintf(real_path, sizeof(real_path), "%s/*", path);
-
- DIR *d = new DIR();
- d->handle = FindFirstFile(real_path, &d->data);
- d->read_first = false;
-
- if (d->handle == INVALID_HANDLE_VALUE)
- {
- delete d;
- return NULL;
- }
-
- return d;
-}
-
-dirent *readdir(DIR *d)
-{
- if (d->read_first == false)
- d->read_first = true;
- else if (!FindNextFile(d->handle, &d->data))
- return NULL;
-
- d->ent.d_ino = 1;
- d->ent.d_name = d->data.cFileName;
-
- return &d->ent;
-}
-
-int closedir(DIR *d)
-{
- FindClose(d->handle);
- delete d;
- return 0;
-}
diff --git a/src/win32/dir/dir.h b/src/win32/dir/dir.h
deleted file mode 100644
index 80af8dd8d..000000000
--- a/src/win32/dir/dir.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* POSIX emulation layer for Windows.
- *
- * (C) 2008-2023 Anope Team
- * Contact us at team@anope.org
- *
- * Please read COPYING and README for further details.
- */
-
-#include <windows.h>
-
-struct dirent
-{
- int d_ino;
- char *d_name;
-};
-
-struct DIR
-{
- dirent ent;
- HANDLE handle;
- WIN32_FIND_DATA data;
- bool read_first;
-};
-
-DIR *opendir(const char *);
-dirent *readdir(DIR *);
-int closedir(DIR *);
diff --git a/src/win32/socket.cpp b/src/win32/socket.cpp
index 864546b94..b14023779 100644
--- a/src/win32/socket.cpp
+++ b/src/win32/socket.cpp
@@ -48,87 +48,6 @@ int windows_accept(int fd, struct sockaddr *addr, int *addrlen)
return i;
}
-/** This is inet_pton, but it works on Windows
- * @param af The protocol type, AF_INET or AF_INET6
- * @param src The address
- * @param dst Struct to put results in
- * @return 1 on success, -1 on error
- */
-int windows_inet_pton(int af, const char *src, void *dst)
-{
- int address_length;
- sockaddr_storage sa;
- sockaddr_in *sin = reinterpret_cast<sockaddr_in *>(&sa);
- sockaddr_in6 *sin6 = reinterpret_cast<sockaddr_in6 *>(&sa);
-
- switch (af)
- {
- case AF_INET:
- address_length = sizeof(sockaddr_in);
- break;
- case AF_INET6:
- address_length = sizeof(sockaddr_in6);
- break;
- default:
- return -1;
- }
-
- if (!WSAStringToAddress(static_cast<LPSTR>(const_cast<char *>(src)), af, NULL, reinterpret_cast<LPSOCKADDR>(&sa), &address_length))
- {
- switch (af)
- {
- case AF_INET:
- memcpy(dst, &sin->sin_addr, sizeof(in_addr));
- break;
- case AF_INET6:
- memcpy(dst, &sin6->sin6_addr, sizeof(in6_addr));
- break;
- }
- return 1;
- }
-
- return 0;
-}
-
-/** This is inet_ntop, but it works on Windows
- * @param af The protocol type, AF_INET or AF_INET6
- * @param src Network address structure
- * @param dst After converting put it here
- * @param size sizeof the dest
- * @return dst
- */
-const char *windows_inet_ntop(int af, const void *src, char *dst, size_t size)
-{
- int address_length;
- DWORD string_length = size;
- sockaddr_storage sa;
- sockaddr_in *sin = reinterpret_cast<sockaddr_in *>(&sa);
- sockaddr_in6 *sin6 = reinterpret_cast<sockaddr_in6 *>(&sa);
-
- memset(&sa, 0, sizeof(sa));
-
- switch (af)
- {
- case AF_INET:
- address_length = sizeof(sockaddr_in);
- sin->sin_family = af;
- memcpy(&sin->sin_addr, src, sizeof(in_addr));
- break;
- case AF_INET6:
- address_length = sizeof(sockaddr_in6);
- sin6->sin6_family = af;
- memcpy(&sin6->sin6_addr, src, sizeof(in6_addr));
- break;
- default:
- return NULL;
- }
-
- if (!WSAAddressToString(reinterpret_cast<LPSOCKADDR>(&sa), address_length, NULL, dst, &string_length))
- return dst;
-
- return NULL;
-}
-
int fcntl(int fd, int cmd, int arg)
{
if (cmd == F_GETFL)
diff --git a/src/win32/socket.h b/src/win32/socket.h
index 3a6ea2f3c..6d63d748f 100644
--- a/src/win32/socket.h
+++ b/src/win32/socket.h
@@ -21,12 +21,8 @@ extern CoreExport int read(int fd, char *buf, size_t count);
extern CoreExport int write(int fd, const char *buf, size_t count);
extern CoreExport int windows_close(int fd);
extern CoreExport int windows_accept(int fd, struct sockaddr *addr, int *addrlen);
-extern CoreExport int windows_inet_pton(int af, const char *src, void *dst);
-extern CoreExport const char *windows_inet_ntop(int af, const void *src, char *dst, size_t size);
extern CoreExport int fcntl(int fd, int cmd, int arg);
#ifndef WIN32_NO_OVERRIDE
# define accept windows_accept
-# define inet_pton windows_inet_pton
-# define inet_ntop windows_inet_ntop
#endif
diff --git a/src/xline.cpp b/src/xline.cpp
index e86c22084..1e39e9840 100644
--- a/src/xline.cpp
+++ b/src/xline.cpp
@@ -86,7 +86,7 @@ void XLine::Init()
}
}
-XLine::XLine(const Anope::string &ma, const Anope::string &r, const Anope::string &uid) : Serializable("XLine"), mask(ma), by(Me->GetName()), created(0), expires(0), reason(r), id(uid)
+XLine::XLine(const Anope::string &ma, const Anope::string &r, const Anope::string &uid) : Serializable("XLine"), mask(ma), by(Me->GetName()), reason(r), id(uid)
{
regex = NULL;
manager = NULL;
@@ -224,10 +224,8 @@ void XLineManager::UnregisterXLineManager(XLineManager *xlm)
void XLineManager::CheckAll(User *u)
{
- for (std::list<XLineManager *>::iterator it = XLineManagers.begin(), it_end = XLineManagers.end(); it != it_end; ++it)
+ for (auto *xlm : XLineManagers)
{
- XLineManager *xlm = *it;
-
if (xlm->CheckAllXLines(u))
break;
}
@@ -288,7 +286,7 @@ const std::vector<XLine *> &XLineManager::GetList() const
void XLineManager::AddXLine(XLine *x)
{
if (!x->id.empty())
- XLinesByUID->insert(std::make_pair(x->id, x));
+ XLinesByUID->emplace(x->id, x);
this->xlines->push_back(x);
x->manager = this;
}
@@ -361,9 +359,8 @@ void XLineManager::Clear()
std::vector<XLine *> xl;
this->xlines->swap(xl);
- for (unsigned i = 0; i < xl.size(); ++i)
+ for (auto *x : xl)
{
- XLine *x = xl[i];
if (!x->id.empty())
XLinesByUID->erase(x->id);
delete x;
@@ -427,10 +424,8 @@ XLine* XLineManager::HasEntry(const Anope::string &mask)
it->second->QueueUpdate();
return it->second;
}
- for (unsigned i = 0, end = this->xlines->size(); i < end; ++i)
+ for (auto *x : *this->xlines)
{
- XLine *x = this->xlines->at(i);
-
if (x->mask.equals_ci(mask))
{
x->QueueUpdate();
diff --git a/vendor/README.md b/vendor/README.md
new file mode 100644
index 000000000..dc979d39c
--- /dev/null
+++ b/vendor/README.md
@@ -0,0 +1,13 @@
+# Vendored Libraries
+
+This directory contains vendored dependencies that are shipped with Anope to avoid users needing to install them manually.
+
+## bcrypt
+
+**Author** &mdash; [Solar Designer](mailto:solar@openwall.com)
+
+**License** &mdash; Public Domain
+
+**Version** &mdash; v1.3
+
+**Website** &mdash; [https://www.openwall.com/crypt/](https://www.openwall.com/crypt/)
diff --git a/vendor/bcrypt/crypt_blowfish.c b/vendor/bcrypt/crypt_blowfish.c
new file mode 100644
index 000000000..9d3f3be82
--- /dev/null
+++ b/vendor/bcrypt/crypt_blowfish.c
@@ -0,0 +1,907 @@
+/*
+ * The crypt_blowfish homepage is:
+ *
+ * http://www.openwall.com/crypt/
+ *
+ * This code comes from John the Ripper password cracker, with reentrant
+ * and crypt(3) interfaces added, but optimizations specific to password
+ * cracking removed.
+ *
+ * Written by Solar Designer <solar at openwall.com> in 1998-2014.
+ * No copyright is claimed, and the software is hereby placed in the public
+ * domain. In case this attempt to disclaim copyright and place the software
+ * in the public domain is deemed null and void, then the software is
+ * Copyright (c) 1998-2014 Solar Designer and it is hereby released to the
+ * general public under the following terms:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted.
+ *
+ * There's ABSOLUTELY NO WARRANTY, express or implied.
+ *
+ * It is my intent that you should be able to use this on your system,
+ * as part of a software package, or anywhere else to improve security,
+ * ensure compatibility, or for any other purpose. I would appreciate
+ * it if you give credit where it is due and keep your modifications in
+ * the public domain as well, but I don't require that in order to let
+ * you place this code and any modifications you make under a license
+ * of your choice.
+ *
+ * This implementation is fully compatible with OpenBSD's bcrypt.c for prefix
+ * "$2b$", originally by Niels Provos <provos at citi.umich.edu>, and it uses
+ * some of his ideas. The password hashing algorithm was designed by David
+ * Mazieres <dm at lcs.mit.edu>. For information on the level of
+ * compatibility for bcrypt hash prefixes other than "$2b$", please refer to
+ * the comments in BF_set_key() below and to the included crypt(3) man page.
+ *
+ * There's a paper on the algorithm that explains its design decisions:
+ *
+ * http://www.usenix.org/events/usenix99/provos.html
+ *
+ * Some of the tricks in BF_ROUND might be inspired by Eric Young's
+ * Blowfish library (I can't be sure if I would think of something if I
+ * hadn't seen his code).
+ */
+
+#include <string.h>
+
+#include <errno.h>
+#ifndef __set_errno
+#define __set_errno(val) errno = (val)
+#endif
+
+/* Just to make sure the prototypes match the actual definitions */
+#include "crypt_blowfish.h"
+
+#ifdef __i386__
+#define BF_ASM 1
+#define BF_SCALE 1
+#elif defined(__x86_64__) || defined(__alpha__) || defined(__hppa__)
+#define BF_ASM 0
+#define BF_SCALE 1
+#else
+#define BF_ASM 0
+#define BF_SCALE 0
+#endif
+
+typedef unsigned int BF_word;
+typedef signed int BF_word_signed;
+
+/* Number of Blowfish rounds, this is also hardcoded into a few places */
+#define BF_N 16
+
+typedef BF_word BF_key[BF_N + 2];
+
+typedef struct {
+ BF_word S[4][0x100];
+ BF_key P;
+} BF_ctx;
+
+/*
+ * Magic IV for 64 Blowfish encryptions that we do at the end.
+ * The string is "OrpheanBeholderScryDoubt" on big-endian.
+ */
+static BF_word BF_magic_w[6] = {
+ 0x4F727068, 0x65616E42, 0x65686F6C,
+ 0x64657253, 0x63727944, 0x6F756274
+};
+
+/*
+ * P-box and S-box tables initialized with digits of Pi.
+ */
+static BF_ctx BF_init_state = {
+ {
+ {
+ 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7,
+ 0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99,
+ 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16,
+ 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e,
+ 0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee,
+ 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013,
+ 0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef,
+ 0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e,
+ 0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60,
+ 0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440,
+ 0x55ca396a, 0x2aab10b6, 0xb4cc5c34, 0x1141e8ce,
+ 0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a,
+ 0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e,
+ 0xafd6ba33, 0x6c24cf5c, 0x7a325381, 0x28958677,
+ 0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193,
+ 0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032,
+ 0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88,
+ 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239,
+ 0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e,
+ 0x21c66842, 0xf6e96c9a, 0x670c9c61, 0xabd388f0,
+ 0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3,
+ 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98,
+ 0xa1f1651d, 0x39af0176, 0x66ca593e, 0x82430e88,
+ 0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe,
+ 0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6,
+ 0x4ed3aa62, 0x363f7706, 0x1bfedf72, 0x429b023d,
+ 0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b,
+ 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7,
+ 0xe3fe501a, 0xb6794c3b, 0x976ce0bd, 0x04c006ba,
+ 0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463,
+ 0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f,
+ 0x6dfc511f, 0x9b30952c, 0xcc814544, 0xaf5ebd09,
+ 0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3,
+ 0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb,
+ 0x5579c0bd, 0x1a60320a, 0xd6a100c6, 0x402c7279,
+ 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8,
+ 0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab,
+ 0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82,
+ 0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db,
+ 0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573,
+ 0x695b27b0, 0xbbca58c8, 0xe1ffa35d, 0xb8f011a0,
+ 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b,
+ 0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790,
+ 0xe1ddf2da, 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8,
+ 0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4,
+ 0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0,
+ 0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7,
+ 0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c,
+ 0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad,
+ 0x2f2f2218, 0xbe0e1777, 0xea752dfe, 0x8b021fa1,
+ 0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299,
+ 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9,
+ 0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477,
+ 0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf,
+ 0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49,
+ 0x00250e2d, 0x2071b35e, 0x226800bb, 0x57b8e0af,
+ 0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa,
+ 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5,
+ 0x83260376, 0x6295cfa9, 0x11c81968, 0x4e734a41,
+ 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915,
+ 0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400,
+ 0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915,
+ 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664,
+ 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a
+ }, {
+ 0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623,
+ 0xad6ea6b0, 0x49a7df7d, 0x9cee60b8, 0x8fedb266,
+ 0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1,
+ 0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e,
+ 0x3f54989a, 0x5b429d65, 0x6b8fe4d6, 0x99f73fd6,
+ 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1,
+ 0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e,
+ 0x09686b3f, 0x3ebaefc9, 0x3c971814, 0x6b6a70a1,
+ 0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737,
+ 0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8,
+ 0xb03ada37, 0xf0500c0d, 0xf01c1f04, 0x0200b3ff,
+ 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd,
+ 0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701,
+ 0x3ae5e581, 0x37c2dadc, 0xc8b57634, 0x9af3dda7,
+ 0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41,
+ 0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331,
+ 0x4e548b38, 0x4f6db908, 0x6f420d03, 0xf60a04bf,
+ 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af,
+ 0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e,
+ 0x5512721f, 0x2e6b7124, 0x501adde6, 0x9f84cd87,
+ 0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c,
+ 0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2,
+ 0xef1c1847, 0x3215d908, 0xdd433b37, 0x24c2ba16,
+ 0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd,
+ 0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b,
+ 0x043556f1, 0xd7a3c76b, 0x3c11183b, 0x5924a509,
+ 0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e,
+ 0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3,
+ 0x771fe71c, 0x4e3d06fa, 0x2965dcb9, 0x99e71d0f,
+ 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a,
+ 0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4,
+ 0xf2f74ea7, 0x361d2b3d, 0x1939260f, 0x19c27960,
+ 0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66,
+ 0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28,
+ 0xc332ddef, 0xbe6c5aa5, 0x65582185, 0x68ab9802,
+ 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84,
+ 0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510,
+ 0x13cca830, 0xeb61bd96, 0x0334fe1e, 0xaa0363cf,
+ 0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14,
+ 0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e,
+ 0x648b1eaf, 0x19bdf0ca, 0xa02369b9, 0x655abb50,
+ 0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7,
+ 0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8,
+ 0xf837889a, 0x97e32d77, 0x11ed935f, 0x16681281,
+ 0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99,
+ 0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696,
+ 0xcdb30aeb, 0x532e3054, 0x8fd948e4, 0x6dbc3128,
+ 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73,
+ 0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0,
+ 0x45eee2b6, 0xa3aaabea, 0xdb6c4f15, 0xfacb4fd0,
+ 0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105,
+ 0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250,
+ 0xcf62a1f2, 0x5b8d2646, 0xfc8883a0, 0xc1c7b6a3,
+ 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285,
+ 0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00,
+ 0x58428d2a, 0x0c55f5ea, 0x1dadf43e, 0x233f7061,
+ 0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb,
+ 0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e,
+ 0xa6078084, 0x19f8509e, 0xe8efd855, 0x61d99735,
+ 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc,
+ 0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9,
+ 0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340,
+ 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20,
+ 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7
+ }, {
+ 0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934,
+ 0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068,
+ 0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af,
+ 0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840,
+ 0x4d95fc1d, 0x96b591af, 0x70f4ddd3, 0x66a02f45,
+ 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504,
+ 0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a,
+ 0x28507825, 0x530429f4, 0x0a2c86da, 0xe9b66dfb,
+ 0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee,
+ 0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6,
+ 0xaace1e7c, 0xd3375fec, 0xce78a399, 0x406b2a42,
+ 0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b,
+ 0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2,
+ 0x3a6efa74, 0xdd5b4332, 0x6841e7f7, 0xca7820fb,
+ 0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527,
+ 0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b,
+ 0x55a867bc, 0xa1159a58, 0xcca92963, 0x99e1db33,
+ 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c,
+ 0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3,
+ 0x95c11548, 0xe4c66d22, 0x48c1133f, 0xc70f86dc,
+ 0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17,
+ 0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564,
+ 0x257b7834, 0x602a9c60, 0xdff8e8a3, 0x1f636c1b,
+ 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115,
+ 0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922,
+ 0x85b2a20e, 0xe6ba0d99, 0xde720c8c, 0x2da2f728,
+ 0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0,
+ 0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e,
+ 0x0a476341, 0x992eff74, 0x3a6f6eab, 0xf4f8fd37,
+ 0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d,
+ 0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804,
+ 0xf1290dc7, 0xcc00ffa3, 0xb5390f92, 0x690fed0b,
+ 0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3,
+ 0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb,
+ 0x37392eb3, 0xcc115979, 0x8026e297, 0xf42e312d,
+ 0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c,
+ 0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350,
+ 0x1a6b1018, 0x11caedfa, 0x3d25bdd8, 0xe2e1c3c9,
+ 0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a,
+ 0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe,
+ 0x9dbc8057, 0xf0f7c086, 0x60787bf8, 0x6003604d,
+ 0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc,
+ 0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f,
+ 0x77a057be, 0xbde8ae24, 0x55464299, 0xbf582e61,
+ 0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2,
+ 0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9,
+ 0x7aeb2661, 0x8b1ddf84, 0x846a0e79, 0x915f95e2,
+ 0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c,
+ 0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e,
+ 0xb77f19b6, 0xe0a9dc09, 0x662d09a1, 0xc4324633,
+ 0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10,
+ 0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169,
+ 0xdcb7da83, 0x573906fe, 0xa1e2ce9b, 0x4fcd7f52,
+ 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027,
+ 0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5,
+ 0xf0177a28, 0xc0f586e0, 0x006058aa, 0x30dc7d62,
+ 0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634,
+ 0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76,
+ 0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24,
+ 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc,
+ 0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4,
+ 0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c,
+ 0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837,
+ 0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0
+ }, {
+ 0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b,
+ 0x5cb0679e, 0x4fa33742, 0xd3822740, 0x99bc9bbe,
+ 0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b,
+ 0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4,
+ 0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8,
+ 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6,
+ 0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304,
+ 0xa1fad5f0, 0x6a2d519a, 0x63ef8ce2, 0x9a86ee22,
+ 0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4,
+ 0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6,
+ 0x2826a2f9, 0xa73a3ae1, 0x4ba99586, 0xef5562e9,
+ 0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59,
+ 0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593,
+ 0xe990fd5a, 0x9e34d797, 0x2cf0b7d9, 0x022b8b51,
+ 0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28,
+ 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c,
+ 0xe029ac71, 0xe019a5e6, 0x47b0acfd, 0xed93fa9b,
+ 0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28,
+ 0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c,
+ 0x15056dd4, 0x88f46dba, 0x03a16125, 0x0564f0bd,
+ 0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a,
+ 0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319,
+ 0x7533d928, 0xb155fdf5, 0x03563482, 0x8aba3cbb,
+ 0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f,
+ 0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991,
+ 0xea7a90c2, 0xfb3e7bce, 0x5121ce64, 0x774fbe32,
+ 0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680,
+ 0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166,
+ 0xb39a460a, 0x6445c0dd, 0x586cdecf, 0x1c20c8ae,
+ 0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb,
+ 0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5,
+ 0x72eacea8, 0xfa6484bb, 0x8d6612ae, 0xbf3c6f47,
+ 0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370,
+ 0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d,
+ 0x4040cb08, 0x4eb4e2cc, 0x34d2466a, 0x0115af84,
+ 0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048,
+ 0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8,
+ 0x611560b1, 0xe7933fdc, 0xbb3a792b, 0x344525bd,
+ 0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9,
+ 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7,
+ 0x1a908749, 0xd44fbd9a, 0xd0dadecb, 0xd50ada38,
+ 0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f,
+ 0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c,
+ 0xbf97222c, 0x15e6fc2a, 0x0f91fc71, 0x9b941525,
+ 0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1,
+ 0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442,
+ 0xe0ec6e0e, 0x1698db3b, 0x4c98a0be, 0x3278e964,
+ 0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e,
+ 0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8,
+ 0xdf359f8d, 0x9b992f2e, 0xe60b6f47, 0x0fe3f11d,
+ 0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f,
+ 0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299,
+ 0xf523f357, 0xa6327623, 0x93a83531, 0x56cccd02,
+ 0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc,
+ 0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614,
+ 0xe6c6c7bd, 0x327a140a, 0x45e1d006, 0xc3f27b9a,
+ 0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6,
+ 0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b,
+ 0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0,
+ 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060,
+ 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e,
+ 0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9,
+ 0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f,
+ 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6
+ }
+ }, {
+ 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344,
+ 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89,
+ 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c,
+ 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917,
+ 0x9216d5d9, 0x8979fb1b
+ }
+};
+
+static unsigned char BF_itoa64[64 + 1] =
+ "./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
+
+static unsigned char BF_atoi64[0x60] = {
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 0, 1,
+ 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 64, 64, 64, 64, 64,
+ 64, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
+ 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 64, 64, 64, 64, 64,
+ 64, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
+ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 64, 64, 64, 64, 64
+};
+
+#define BF_safe_atoi64(dst, src) \
+{ \
+ tmp = (unsigned char)(src); \
+ if ((unsigned int)(tmp -= 0x20) >= 0x60) return -1; \
+ tmp = BF_atoi64[tmp]; \
+ if (tmp > 63) return -1; \
+ (dst) = tmp; \
+}
+
+static int BF_decode(BF_word *dst, const char *src, int size)
+{
+ unsigned char *dptr = (unsigned char *)dst;
+ unsigned char *end = dptr + size;
+ const unsigned char *sptr = (const unsigned char *)src;
+ unsigned int tmp, c1, c2, c3, c4;
+
+ do {
+ BF_safe_atoi64(c1, *sptr++);
+ BF_safe_atoi64(c2, *sptr++);
+ *dptr++ = (c1 << 2) | ((c2 & 0x30) >> 4);
+ if (dptr >= end) break;
+
+ BF_safe_atoi64(c3, *sptr++);
+ *dptr++ = ((c2 & 0x0F) << 4) | ((c3 & 0x3C) >> 2);
+ if (dptr >= end) break;
+
+ BF_safe_atoi64(c4, *sptr++);
+ *dptr++ = ((c3 & 0x03) << 6) | c4;
+ } while (dptr < end);
+
+ return 0;
+}
+
+static void BF_encode(char *dst, const BF_word *src, int size)
+{
+ const unsigned char *sptr = (const unsigned char *)src;
+ const unsigned char *end = sptr + size;
+ unsigned char *dptr = (unsigned char *)dst;
+ unsigned int c1, c2;
+
+ do {
+ c1 = *sptr++;
+ *dptr++ = BF_itoa64[c1 >> 2];
+ c1 = (c1 & 0x03) << 4;
+ if (sptr >= end) {
+ *dptr++ = BF_itoa64[c1];
+ break;
+ }
+
+ c2 = *sptr++;
+ c1 |= c2 >> 4;
+ *dptr++ = BF_itoa64[c1];
+ c1 = (c2 & 0x0f) << 2;
+ if (sptr >= end) {
+ *dptr++ = BF_itoa64[c1];
+ break;
+ }
+
+ c2 = *sptr++;
+ c1 |= c2 >> 6;
+ *dptr++ = BF_itoa64[c1];
+ *dptr++ = BF_itoa64[c2 & 0x3f];
+ } while (sptr < end);
+}
+
+static void BF_swap(BF_word *x, int count)
+{
+ static int endianness_check = 1;
+ char *is_little_endian = (char *)&endianness_check;
+ BF_word tmp;
+
+ if (*is_little_endian)
+ do {
+ tmp = *x;
+ tmp = (tmp << 16) | (tmp >> 16);
+ *x++ = ((tmp & 0x00FF00FF) << 8) | ((tmp >> 8) & 0x00FF00FF);
+ } while (--count);
+}
+
+#if BF_SCALE
+/* Architectures which can shift addresses left by 2 bits with no extra cost */
+#define BF_ROUND(L, R, N) \
+ tmp1 = L & 0xFF; \
+ tmp2 = L >> 8; \
+ tmp2 &= 0xFF; \
+ tmp3 = L >> 16; \
+ tmp3 &= 0xFF; \
+ tmp4 = L >> 24; \
+ tmp1 = data.ctx.S[3][tmp1]; \
+ tmp2 = data.ctx.S[2][tmp2]; \
+ tmp3 = data.ctx.S[1][tmp3]; \
+ tmp3 += data.ctx.S[0][tmp4]; \
+ tmp3 ^= tmp2; \
+ R ^= data.ctx.P[N + 1]; \
+ tmp3 += tmp1; \
+ R ^= tmp3;
+#else
+/* Architectures with no complicated addressing modes supported */
+#define BF_INDEX(S, i) \
+ (*((BF_word *)(((unsigned char *)S) + (i))))
+#define BF_ROUND(L, R, N) \
+ tmp1 = L & 0xFF; \
+ tmp1 <<= 2; \
+ tmp2 = L >> 6; \
+ tmp2 &= 0x3FC; \
+ tmp3 = L >> 14; \
+ tmp3 &= 0x3FC; \
+ tmp4 = L >> 22; \
+ tmp4 &= 0x3FC; \
+ tmp1 = BF_INDEX(data.ctx.S[3], tmp1); \
+ tmp2 = BF_INDEX(data.ctx.S[2], tmp2); \
+ tmp3 = BF_INDEX(data.ctx.S[1], tmp3); \
+ tmp3 += BF_INDEX(data.ctx.S[0], tmp4); \
+ tmp3 ^= tmp2; \
+ R ^= data.ctx.P[N + 1]; \
+ tmp3 += tmp1; \
+ R ^= tmp3;
+#endif
+
+/*
+ * Encrypt one block, BF_N is hardcoded here.
+ */
+#define BF_ENCRYPT \
+ L ^= data.ctx.P[0]; \
+ BF_ROUND(L, R, 0); \
+ BF_ROUND(R, L, 1); \
+ BF_ROUND(L, R, 2); \
+ BF_ROUND(R, L, 3); \
+ BF_ROUND(L, R, 4); \
+ BF_ROUND(R, L, 5); \
+ BF_ROUND(L, R, 6); \
+ BF_ROUND(R, L, 7); \
+ BF_ROUND(L, R, 8); \
+ BF_ROUND(R, L, 9); \
+ BF_ROUND(L, R, 10); \
+ BF_ROUND(R, L, 11); \
+ BF_ROUND(L, R, 12); \
+ BF_ROUND(R, L, 13); \
+ BF_ROUND(L, R, 14); \
+ BF_ROUND(R, L, 15); \
+ tmp4 = R; \
+ R = L; \
+ L = tmp4 ^ data.ctx.P[BF_N + 1];
+
+#if BF_ASM
+#define BF_body() \
+ _BF_body_r(&data.ctx);
+#else
+#define BF_body() \
+ L = R = 0; \
+ ptr = data.ctx.P; \
+ do { \
+ ptr += 2; \
+ BF_ENCRYPT; \
+ *(ptr - 2) = L; \
+ *(ptr - 1) = R; \
+ } while (ptr < &data.ctx.P[BF_N + 2]); \
+\
+ ptr = data.ctx.S[0]; \
+ do { \
+ ptr += 2; \
+ BF_ENCRYPT; \
+ *(ptr - 2) = L; \
+ *(ptr - 1) = R; \
+ } while (ptr < &data.ctx.S[3][0xFF]);
+#endif
+
+static void BF_set_key(const char *key, BF_key expanded, BF_key initial,
+ unsigned char flags)
+{
+ const char *ptr = key;
+ unsigned int bug, i, j;
+ BF_word safety, sign, diff, tmp[2];
+
+/*
+ * There was a sign extension bug in older revisions of this function. While
+ * we would have liked to simply fix the bug and move on, we have to provide
+ * a backwards compatibility feature (essentially the bug) for some systems and
+ * a safety measure for some others. The latter is needed because for certain
+ * multiple inputs to the buggy algorithm there exist easily found inputs to
+ * the correct algorithm that produce the same hash. Thus, we optionally
+ * deviate from the correct algorithm just enough to avoid such collisions.
+ * While the bug itself affected the majority of passwords containing
+ * characters with the 8th bit set (although only a percentage of those in a
+ * collision-producing way), the anti-collision safety measure affects
+ * only a subset of passwords containing the '\xff' character (not even all of
+ * those passwords, just some of them). This character is not found in valid
+ * UTF-8 sequences and is rarely used in popular 8-bit character encodings.
+ * Thus, the safety measure is unlikely to cause much annoyance, and is a
+ * reasonable tradeoff to use when authenticating against existing hashes that
+ * are not reliably known to have been computed with the correct algorithm.
+ *
+ * We use an approach that tries to minimize side-channel leaks of password
+ * information - that is, we mostly use fixed-cost bitwise operations instead
+ * of branches or table lookups. (One conditional branch based on password
+ * length remains. It is not part of the bug aftermath, though, and is
+ * difficult and possibly unreasonable to avoid given the use of C strings by
+ * the caller, which results in similar timing leaks anyway.)
+ *
+ * For actual implementation, we set an array index in the variable "bug"
+ * (0 means no bug, 1 means sign extension bug emulation) and a flag in the
+ * variable "safety" (bit 16 is set when the safety measure is requested).
+ * Valid combinations of settings are:
+ *
+ * Prefix "$2a$": bug = 0, safety = 0x10000
+ * Prefix "$2b$": bug = 0, safety = 0
+ * Prefix "$2x$": bug = 1, safety = 0
+ * Prefix "$2y$": bug = 0, safety = 0
+ */
+ bug = (unsigned int)flags & 1;
+ safety = ((BF_word)flags & 2) << 15;
+
+ sign = diff = 0;
+
+ for (i = 0; i < BF_N + 2; i++) {
+ tmp[0] = tmp[1] = 0;
+ for (j = 0; j < 4; j++) {
+ tmp[0] <<= 8;
+ tmp[0] |= (unsigned char)*ptr; /* correct */
+ tmp[1] <<= 8;
+ tmp[1] |= (BF_word_signed)(signed char)*ptr; /* bug */
+/*
+ * Sign extension in the first char has no effect - nothing to overwrite yet,
+ * and those extra 24 bits will be fully shifted out of the 32-bit word. For
+ * chars 2, 3, 4 in each four-char block, we set bit 7 of "sign" if sign
+ * extension in tmp[1] occurs. Once this flag is set, it remains set.
+ */
+ if (j)
+ sign |= tmp[1] & 0x80;
+ if (!*ptr)
+ ptr = key;
+ else
+ ptr++;
+ }
+ diff |= tmp[0] ^ tmp[1]; /* Non-zero on any differences */
+
+ expanded[i] = tmp[bug];
+ initial[i] = BF_init_state.P[i] ^ tmp[bug];
+ }
+
+/*
+ * At this point, "diff" is zero iff the correct and buggy algorithms produced
+ * exactly the same result. If so and if "sign" is non-zero, which indicates
+ * that there was a non-benign sign extension, this means that we have a
+ * collision between the correctly computed hash for this password and a set of
+ * passwords that could be supplied to the buggy algorithm. Our safety measure
+ * is meant to protect from such many-buggy to one-correct collisions, by
+ * deviating from the correct algorithm in such cases. Let's check for this.
+ */
+ diff |= diff >> 16; /* still zero iff exact match */
+ diff &= 0xffff; /* ditto */
+ diff += 0xffff; /* bit 16 set iff "diff" was non-zero (on non-match) */
+ sign <<= 9; /* move the non-benign sign extension flag to bit 16 */
+ sign &= ~diff & safety; /* action needed? */
+
+/*
+ * If we have determined that we need to deviate from the correct algorithm,
+ * flip bit 16 in initial expanded key. (The choice of 16 is arbitrary, but
+ * let's stick to it now. It came out of the approach we used above, and it's
+ * not any worse than any other choice we could make.)
+ *
+ * It is crucial that we don't do the same to the expanded key used in the main
+ * Eksblowfish loop. By doing it to only one of these two, we deviate from a
+ * state that could be directly specified by a password to the buggy algorithm
+ * (and to the fully correct one as well, but that's a side-effect).
+ */
+ initial[0] ^= sign;
+}
+
+static const unsigned char flags_by_subtype[26] =
+ {2, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 4, 0};
+
+static char *BF_crypt(const char *key, const char *setting,
+ char *output, int size,
+ BF_word min)
+{
+#if BF_ASM
+ extern void _BF_body_r(BF_ctx *ctx);
+#endif
+ struct {
+ BF_ctx ctx;
+ BF_key expanded_key;
+ union {
+ BF_word salt[4];
+ BF_word output[6];
+ } binary;
+ } data;
+ BF_word L, R;
+ BF_word tmp1, tmp2, tmp3, tmp4;
+ BF_word *ptr;
+ BF_word count;
+ int i;
+
+ if (size < 7 + 22 + 31 + 1) {
+ __set_errno(ERANGE);
+ return NULL;
+ }
+
+ if (setting[0] != '$' ||
+ setting[1] != '2' ||
+ setting[2] < 'a' || setting[2] > 'z' ||
+ !flags_by_subtype[(unsigned int)(unsigned char)setting[2] - 'a'] ||
+ setting[3] != '$' ||
+ setting[4] < '0' || setting[4] > '3' ||
+ setting[5] < '0' || setting[5] > '9' ||
+ (setting[4] == '3' && setting[5] > '1') ||
+ setting[6] != '$') {
+ __set_errno(EINVAL);
+ return NULL;
+ }
+
+ count = (BF_word)1 << ((setting[4] - '0') * 10 + (setting[5] - '0'));
+ if (count < min || BF_decode(data.binary.salt, &setting[7], 16)) {
+ __set_errno(EINVAL);
+ return NULL;
+ }
+ BF_swap(data.binary.salt, 4);
+
+ BF_set_key(key, data.expanded_key, data.ctx.P,
+ flags_by_subtype[(unsigned int)(unsigned char)setting[2] - 'a']);
+
+ memcpy(data.ctx.S, BF_init_state.S, sizeof(data.ctx.S));
+
+ L = R = 0;
+ for (i = 0; i < BF_N + 2; i += 2) {
+ L ^= data.binary.salt[i & 2];
+ R ^= data.binary.salt[(i & 2) + 1];
+ BF_ENCRYPT;
+ data.ctx.P[i] = L;
+ data.ctx.P[i + 1] = R;
+ }
+
+ ptr = data.ctx.S[0];
+ do {
+ ptr += 4;
+ L ^= data.binary.salt[(BF_N + 2) & 3];
+ R ^= data.binary.salt[(BF_N + 3) & 3];
+ BF_ENCRYPT;
+ *(ptr - 4) = L;
+ *(ptr - 3) = R;
+
+ L ^= data.binary.salt[(BF_N + 4) & 3];
+ R ^= data.binary.salt[(BF_N + 5) & 3];
+ BF_ENCRYPT;
+ *(ptr - 2) = L;
+ *(ptr - 1) = R;
+ } while (ptr < &data.ctx.S[3][0xFF]);
+
+ do {
+ int done;
+
+ for (i = 0; i < BF_N + 2; i += 2) {
+ data.ctx.P[i] ^= data.expanded_key[i];
+ data.ctx.P[i + 1] ^= data.expanded_key[i + 1];
+ }
+
+ done = 0;
+ do {
+ BF_body();
+ if (done)
+ break;
+ done = 1;
+
+ tmp1 = data.binary.salt[0];
+ tmp2 = data.binary.salt[1];
+ tmp3 = data.binary.salt[2];
+ tmp4 = data.binary.salt[3];
+ for (i = 0; i < BF_N; i += 4) {
+ data.ctx.P[i] ^= tmp1;
+ data.ctx.P[i + 1] ^= tmp2;
+ data.ctx.P[i + 2] ^= tmp3;
+ data.ctx.P[i + 3] ^= tmp4;
+ }
+ data.ctx.P[16] ^= tmp1;
+ data.ctx.P[17] ^= tmp2;
+ } while (1);
+ } while (--count);
+
+ for (i = 0; i < 6; i += 2) {
+ L = BF_magic_w[i];
+ R = BF_magic_w[i + 1];
+
+ count = 64;
+ do {
+ BF_ENCRYPT;
+ } while (--count);
+
+ data.binary.output[i] = L;
+ data.binary.output[i + 1] = R;
+ }
+
+ memcpy(output, setting, 7 + 22 - 1);
+ output[7 + 22 - 1] = BF_itoa64[(int)
+ BF_atoi64[(int)setting[7 + 22 - 1] - 0x20] & 0x30];
+
+/* This has to be bug-compatible with the original implementation, so
+ * only encode 23 of the 24 bytes. :-) */
+ BF_swap(data.binary.output, 6);
+ BF_encode(&output[7 + 22], data.binary.output, 23);
+ output[7 + 22 + 31] = '\0';
+
+ return output;
+}
+
+int _crypt_output_magic(const char *setting, char *output, int size)
+{
+ if (size < 3)
+ return -1;
+
+ output[0] = '*';
+ output[1] = '0';
+ output[2] = '\0';
+
+ if (setting[0] == '*' && setting[1] == '0')
+ output[1] = '1';
+
+ return 0;
+}
+
+/*
+ * Please preserve the runtime self-test. It serves two purposes at once:
+ *
+ * 1. We really can't afford the risk of producing incompatible hashes e.g.
+ * when there's something like gcc bug 26587 again, whereas an application or
+ * library integrating this code might not also integrate our external tests or
+ * it might not run them after every build. Even if it does, the miscompile
+ * might only occur on the production build, but not on a testing build (such
+ * as because of different optimization settings). It is painful to recover
+ * from incorrectly-computed hashes - merely fixing whatever broke is not
+ * enough. Thus, a proactive measure like this self-test is needed.
+ *
+ * 2. We don't want to leave sensitive data from our actual password hash
+ * computation on the stack or in registers. Previous revisions of the code
+ * would do explicit cleanups, but simply running the self-test after hash
+ * computation is more reliable.
+ *
+ * The performance cost of this quick self-test is around 0.6% at the "$2a$08"
+ * setting.
+ */
+char *_crypt_blowfish_rn(const char *key, const char *setting,
+ char *output, int size)
+{
+ const char *test_key = "8b \xd0\xc1\xd2\xcf\xcc\xd8";
+ const char *test_setting = "$2a$00$abcdefghijklmnopqrstuu";
+ static const char * const test_hashes[2] =
+ {"i1D709vfamulimlGcq0qq3UvuUasvEa\0\x55", /* 'a', 'b', 'y' */
+ "VUrPmXD6q/nVSSp7pNDhCR9071IfIRe\0\x55"}; /* 'x' */
+ const char *test_hash = test_hashes[0];
+ char *retval;
+ const char *p;
+ int save_errno, ok;
+ struct {
+ char s[7 + 22 + 1];
+ char o[7 + 22 + 31 + 1 + 1 + 1];
+ } buf;
+
+/* Hash the supplied password */
+ _crypt_output_magic(setting, output, size);
+ retval = BF_crypt(key, setting, output, size, 16);
+ save_errno = errno;
+
+/*
+ * Do a quick self-test. It is important that we make both calls to BF_crypt()
+ * from the same scope such that they likely use the same stack locations,
+ * which makes the second call overwrite the first call's sensitive data on the
+ * stack and makes it more likely that any alignment related issues would be
+ * detected by the self-test.
+ */
+ memcpy(buf.s, test_setting, sizeof(buf.s));
+ if (retval) {
+ unsigned int flags = flags_by_subtype[
+ (unsigned int)(unsigned char)setting[2] - 'a'];
+ test_hash = test_hashes[flags & 1];
+ buf.s[2] = setting[2];
+ }
+ memset(buf.o, 0x55, sizeof(buf.o));
+ buf.o[sizeof(buf.o) - 1] = 0;
+ p = BF_crypt(test_key, buf.s, buf.o, sizeof(buf.o) - (1 + 1), 1);
+
+ ok = (p == buf.o &&
+ !memcmp(p, buf.s, 7 + 22) &&
+ !memcmp(p + (7 + 22), test_hash, 31 + 1 + 1 + 1));
+
+ {
+ const char *k = "\xff\xa3" "34" "\xff\xff\xff\xa3" "345";
+ BF_key ae, ai, ye, yi;
+ BF_set_key(k, ae, ai, 2); /* $2a$ */
+ BF_set_key(k, ye, yi, 4); /* $2y$ */
+ ai[0] ^= 0x10000; /* undo the safety (for comparison) */
+ ok = ok && ai[0] == 0xdb9c59bc && ye[17] == 0x33343500 &&
+ !memcmp(ae, ye, sizeof(ae)) &&
+ !memcmp(ai, yi, sizeof(ai));
+ }
+
+ __set_errno(save_errno);
+ if (ok)
+ return retval;
+
+/* Should not happen */
+ _crypt_output_magic(setting, output, size);
+ __set_errno(EINVAL); /* pretend we don't support this hash type */
+ return NULL;
+}
+
+char *_crypt_gensalt_blowfish_rn(const char *prefix, unsigned long count,
+ const char *input, int size, char *output, int output_size)
+{
+ if (size < 16 || output_size < 7 + 22 + 1 ||
+ (count && (count < 4 || count > 31)) ||
+ prefix[0] != '$' || prefix[1] != '2' ||
+ (prefix[2] != 'a' && prefix[2] != 'b' && prefix[2] != 'y')) {
+ if (output_size > 0) output[0] = '\0';
+ __set_errno((output_size < 7 + 22 + 1) ? ERANGE : EINVAL);
+ return NULL;
+ }
+
+ if (!count) count = 5;
+
+ output[0] = '$';
+ output[1] = '2';
+ output[2] = prefix[2];
+ output[3] = '$';
+ output[4] = '0' + count / 10;
+ output[5] = '0' + count % 10;
+ output[6] = '$';
+
+ BF_encode(&output[7], (const BF_word *)input, 16);
+ output[7 + 22] = '\0';
+
+ return output;
+}
diff --git a/vendor/bcrypt/crypt_blowfish.h b/vendor/bcrypt/crypt_blowfish.h
new file mode 100644
index 000000000..2ee0d8c1d
--- /dev/null
+++ b/vendor/bcrypt/crypt_blowfish.h
@@ -0,0 +1,27 @@
+/*
+ * Written by Solar Designer <solar at openwall.com> in 2000-2011.
+ * No copyright is claimed, and the software is hereby placed in the public
+ * domain. In case this attempt to disclaim copyright and place the software
+ * in the public domain is deemed null and void, then the software is
+ * Copyright (c) 2000-2011 Solar Designer and it is hereby released to the
+ * general public under the following terms:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted.
+ *
+ * There's ABSOLUTELY NO WARRANTY, express or implied.
+ *
+ * See crypt_blowfish.c for more information.
+ */
+
+#ifndef _CRYPT_BLOWFISH_H
+#define _CRYPT_BLOWFISH_H
+
+extern int _crypt_output_magic(const char *setting, char *output, int size);
+extern char *_crypt_blowfish_rn(const char *key, const char *setting,
+ char *output, int size);
+extern char *_crypt_gensalt_blowfish_rn(const char *prefix,
+ unsigned long count,
+ const char *input, int size, char *output, int output_size);
+
+#endif
diff --git a/vendor/update b/vendor/update
new file mode 100755
index 000000000..df7056d23
--- /dev/null
+++ b/vendor/update
@@ -0,0 +1,111 @@
+#!/usr/bin/env perl
+#
+# (C) 2003-2023 Anope Team
+# Contact us at team@anope.org
+#
+# Please read COPYING and README for further details.
+#
+# Based on the original code of Epona by Lara.
+# Based on the original code of Services by Andy Church.
+
+use v5.26.0;
+use strict;
+use warnings FATAL => qw(all);
+
+use File::Basename qw(basename dirname);
+use File::Copy qw(move);
+use File::Spec::Functions qw(abs2rel catdir catfile);
+use File::Temp qw(tempdir);
+use FindBin qw($RealDir);
+use File::Path qw(mkpath);
+use POSIX qw(strftime);
+use TOML qw(from_toml);
+
+use constant {
+ CC_BOLD => -t STDOUT ? "\e[1m" : '',
+ CC_RESET => -t STDOUT ? "\e[0m" : '',
+ CC_GREEN => -t STDOUT ? "\e[1;32m" : '',
+ CC_RED => -t STDOUT ? "\e[1;31m" : '',
+};
+
+sub execute(@) {
+ say "${\CC_BOLD}\$${\CC_RESET} @_";
+ return system @_;
+}
+
+sub print_error {
+ print STDERR "${\CC_BOLD}Error:${\CC_RESET} ";
+ for my $line (@_) {
+ say STDERR $line;
+ }
+ exit 1;
+}
+
+my $config = catfile $RealDir, 'update.toml';
+open(my $fh, $config) or print_error "unable to read $config: $!";
+my $contents = do { local $/; <$fh> };
+close $fh;
+
+my ($data, $error) = from_toml $contents;
+print_error "unable to parse $config: $!" if $error;
+
+while (my ($name, $info) = each %{$data}) {
+ say "Updating ${\CC_GREEN}$name${\CC_RESET} ...";
+
+ my $unpackdir = File::Temp->newdir;
+ my $vendordir = catdir $RealDir, $name;
+ my $success = 0;
+ if (defined $info->{git}) {
+ my @extra_args;
+ push @extra_args, '--branch', $info->{branch} if defined $info->{branch};
+ $success ||= execute 'git', 'clone', @extra_args, $info->{git}, $unpackdir;
+ chomp(my $tag = `git -C $unpackdir describe --abbrev=0 --tags HEAD 2>/dev/null`) unless $success;
+ $success ||= execute 'git', '-C', $unpackdir, 'checkout', $tag if $tag;
+ chomp($info->{version} = `git -C $unpackdir describe --always --tags HEAD 2>/dev/null`);
+ if (defined $info->{patches}) {
+ my $patches = catfile($unpackdir, $info->{patches});
+ for my $patch (glob $patches) {
+ $success |= execute 'git', '-C', $unpackdir, 'apply', $patch;
+ }
+ }
+ } elsif (defined $info->{tarball}) {
+ my $tarball = catfile $unpackdir, basename $info->{tarball};
+ $success ||= execute 'wget', '--output-document', $tarball, $info->{tarball};
+ $success ||= execute 'tar', 'fx', $tarball, '-C', $unpackdir, '--strip-components', 1;
+ } else {
+ print_error "unable to update $name; no git or tarball specified!";
+ }
+ print_error "unable to update $name: download failed!" if $success;
+
+ unlink $vendordir;
+ my $glob = $info->{files} or print_error "unable to update $name: no file glob specified!";
+ for my $file (glob catfile $unpackdir, $glob) {
+ my $pathname = abs2rel $file, $unpackdir;
+ for (my $i = 0; $i < ($info->{depth} // 0); ++$i) {
+ $pathname =~ s/[^\/]+\///;
+ }
+ my $filename = catfile $vendordir, $pathname;
+ my $dirname = dirname $filename;
+ mkdir $dirname, 0750 or print_error "unable to create $dirname: $!." unless -e $dirname;
+ move $file, $filename;
+ }
+}
+
+my $readme = catfile $RealDir, 'README.md';
+open($fh, $readme) or print_error "unable to read $readme: $!";
+$contents = do { local $/; <$fh> };
+close $fh;
+
+open($fh, '>', $readme) or print_error "unable to write $readme: $!";
+print $fh $contents =~ s/\n\#\#.*//rs;
+for my $name (sort keys %{$data}) {
+ my $info = $data->{$name};
+ printf $fh "\n## %s\n\n", $name;
+ printf $fh "**Author** &mdash; [%s](mailto:%s)\n\n", $info->{author}, $info->{email} if $info->{email};
+ printf $fh "**Author** &mdash; %s\n\n", $info->{author} unless $info->{email};
+ printf $fh "**License** &mdash; %s\n\n", $info->{license};
+ printf $fh "**Version** &mdash; %s\n\n", $info->{version};
+ my $website = $info->{website} // $info->{git};
+ printf $fh "**Website** &mdash; [%s](%s)\n", $website, $website;
+}
+close $fh;
diff --git a/vendor/update.toml b/vendor/update.toml
new file mode 100644
index 000000000..6a41ec287
--- /dev/null
+++ b/vendor/update.toml
@@ -0,0 +1,8 @@
+[bcrypt]
+author = "Solar Designer"
+email = "solar@openwall.com"
+files = "crypt_blowfish.[ch]"
+license = "Public Domain"
+tarball = "https://www.openwall.com/crypt/crypt_blowfish-1.3.tar.gz"
+version = "v1.3"
+website = "https://www.openwall.com/crypt/"