From 4a2b9ebcf38d6c0a2860b966421b3af125438488 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 25 May 2010 00:57:25 -0500 Subject: Renamed all of source files from .c to .cpp --- src/CMakeLists.txt | 3 +- src/Makefile | 57 +- src/actions.c | 124 --- src/actions.cpp | 124 +++ src/base64.c | 416 --------- src/base64.cpp | 416 +++++++++ src/botserv.c | 853 ------------------ src/botserv.cpp | 853 ++++++++++++++++++ src/channels.c | 1929 ---------------------------------------- src/channels.cpp | 1929 ++++++++++++++++++++++++++++++++++++++++ src/chanserv.c | 1066 ---------------------- src/chanserv.cpp | 1066 ++++++++++++++++++++++ src/commands.c | 196 ---- src/commands.cpp | 196 ++++ src/compat.c | 58 -- src/compat.cpp | 58 ++ src/config.c | 1788 ------------------------------------- src/config.cpp | 1788 +++++++++++++++++++++++++++++++++++++ src/core/CMakeLists.txt | 3 +- src/core/Makefile | 8 +- src/core/bs_act.c | 88 -- src/core/bs_act.cpp | 88 ++ src/core/bs_assign.c | 98 -- src/core/bs_assign.cpp | 98 ++ src/core/bs_badwords.c | 282 ------ src/core/bs_badwords.cpp | 282 ++++++ src/core/bs_bot.c | 432 --------- src/core/bs_bot.cpp | 432 +++++++++ src/core/bs_botlist.c | 96 -- src/core/bs_botlist.cpp | 96 ++ src/core/bs_help.c | 55 -- src/core/bs_help.cpp | 55 ++ src/core/bs_info.c | 263 ------ src/core/bs_info.cpp | 263 ++++++ src/core/bs_kick.c | 348 -------- src/core/bs_kick.cpp | 348 ++++++++ src/core/bs_say.c | 94 -- src/core/bs_say.cpp | 94 ++ src/core/bs_set.c | 198 ----- src/core/bs_set.cpp | 198 +++++ src/core/bs_unassign.c | 76 -- src/core/bs_unassign.cpp | 76 ++ src/core/cs_access.c | 616 ------------- src/core/cs_access.cpp | 616 +++++++++++++ src/core/cs_akick.c | 596 ------------- src/core/cs_akick.cpp | 596 +++++++++++++ src/core/cs_ban.c | 119 --- src/core/cs_ban.cpp | 119 +++ src/core/cs_clear.c | 184 ---- src/core/cs_clear.cpp | 184 ++++ src/core/cs_drop.c | 127 --- src/core/cs_drop.cpp | 127 +++ src/core/cs_forbid.c | 132 --- src/core/cs_forbid.cpp | 132 +++ src/core/cs_getkey.c | 79 -- src/core/cs_getkey.cpp | 79 ++ src/core/cs_help.c | 78 -- src/core/cs_help.cpp | 78 ++ src/core/cs_info.c | 181 ---- src/core/cs_info.cpp | 181 ++++ src/core/cs_invite.c | 97 -- src/core/cs_invite.cpp | 97 ++ src/core/cs_kick.c | 103 --- src/core/cs_kick.cpp | 103 +++ src/core/cs_list.c | 201 ----- src/core/cs_list.cpp | 201 +++++ src/core/cs_modes.c | 452 ---------- src/core/cs_modes.cpp | 452 ++++++++++ src/core/cs_register.c | 136 --- src/core/cs_register.cpp | 136 +++ src/core/cs_set.c | 835 ----------------- src/core/cs_set.cpp | 835 +++++++++++++++++ src/core/cs_status.c | 79 -- src/core/cs_status.cpp | 79 ++ src/core/cs_suspend.c | 194 ---- src/core/cs_suspend.cpp | 194 ++++ src/core/cs_topic.c | 101 --- src/core/cs_topic.cpp | 101 +++ src/core/cs_unban.c | 93 -- src/core/cs_unban.cpp | 93 ++ src/core/cs_xop.c | 650 -------------- src/core/cs_xop.cpp | 650 ++++++++++++++ src/core/enc_md5.c | 398 --------- src/core/enc_md5.cpp | 398 +++++++++ src/core/enc_none.c | 78 -- src/core/enc_none.cpp | 78 ++ src/core/enc_old.c | 401 --------- src/core/enc_old.cpp | 401 +++++++++ src/core/enc_sha1.c | 257 ------ src/core/enc_sha1.cpp | 257 ++++++ src/core/enc_sha256.c | 345 ------- src/core/enc_sha256.cpp | 345 +++++++ src/core/hs_del.c | 76 -- src/core/hs_del.cpp | 76 ++ src/core/hs_delall.c | 81 -- src/core/hs_delall.cpp | 81 ++ src/core/hs_group.c | 69 -- src/core/hs_group.cpp | 69 ++ src/core/hs_help.c | 51 -- src/core/hs_help.cpp | 51 ++ src/core/hs_list.c | 135 --- src/core/hs_list.cpp | 135 +++ src/core/hs_off.c | 65 -- src/core/hs_off.cpp | 65 ++ src/core/hs_on.c | 79 -- src/core/hs_on.cpp | 79 ++ src/core/hs_set.c | 173 ---- src/core/hs_set.cpp | 173 ++++ src/core/hs_setall.c | 171 ---- src/core/hs_setall.cpp | 171 ++++ src/core/ms_cancel.c | 92 -- src/core/ms_cancel.cpp | 92 ++ src/core/ms_check.c | 108 --- src/core/ms_check.cpp | 108 +++ src/core/ms_del.c | 222 ----- src/core/ms_del.cpp | 222 +++++ src/core/ms_help.c | 51 -- src/core/ms_help.cpp | 51 ++ src/core/ms_info.c | 221 ----- src/core/ms_info.cpp | 221 +++++ src/core/ms_list.c | 179 ---- src/core/ms_list.cpp | 179 ++++ src/core/ms_read.c | 164 ---- src/core/ms_read.cpp | 164 ++++ src/core/ms_rsend.c | 95 -- src/core/ms_rsend.cpp | 95 ++ src/core/ms_send.c | 63 -- src/core/ms_send.cpp | 63 ++ src/core/ms_sendall.c | 79 -- src/core/ms_sendall.cpp | 79 ++ src/core/ms_set.c | 275 ------ src/core/ms_set.cpp | 275 ++++++ src/core/ms_staff.c | 76 -- src/core/ms_staff.cpp | 76 ++ src/core/ns_access.c | 184 ---- src/core/ns_access.cpp | 184 ++++ src/core/ns_alist.c | 158 ---- src/core/ns_alist.cpp | 158 ++++ src/core/ns_drop.c | 131 --- src/core/ns_drop.cpp | 131 +++ src/core/ns_forbid.c | 124 --- src/core/ns_forbid.cpp | 124 +++ src/core/ns_getemail.c | 90 -- src/core/ns_getemail.cpp | 90 ++ src/core/ns_getpass.c | 97 -- src/core/ns_getpass.cpp | 97 ++ src/core/ns_ghost.c | 106 --- src/core/ns_ghost.cpp | 106 +++ src/core/ns_group.c | 298 ------- src/core/ns_group.cpp | 298 +++++++ src/core/ns_help.c | 67 -- src/core/ns_help.cpp | 67 ++ src/core/ns_identify.c | 129 --- src/core/ns_identify.cpp | 129 +++ src/core/ns_info.c | 223 ----- src/core/ns_info.cpp | 223 +++++ src/core/ns_list.c | 230 ----- src/core/ns_list.cpp | 230 +++++ src/core/ns_logout.c | 101 --- src/core/ns_logout.cpp | 101 +++ src/core/ns_recover.c | 127 --- src/core/ns_recover.cpp | 127 +++ src/core/ns_register.c | 400 --------- src/core/ns_register.cpp | 400 +++++++++ src/core/ns_release.c | 109 --- src/core/ns_release.cpp | 109 +++ src/core/ns_resetpass.c | 172 ---- src/core/ns_resetpass.cpp | 172 ++++ src/core/ns_saset.c | 589 ------------ src/core/ns_saset.cpp | 589 ++++++++++++ src/core/ns_sendpass.c | 104 --- src/core/ns_sendpass.cpp | 104 +++ src/core/ns_set.c | 545 ------------ src/core/ns_set.cpp | 545 ++++++++++++ src/core/ns_status.c | 80 -- src/core/ns_status.cpp | 80 ++ src/core/ns_suspend.c | 198 ----- src/core/ns_suspend.cpp | 198 +++++ src/core/ns_update.c | 68 -- src/core/ns_update.cpp | 68 ++ src/core/os_akill.c | 403 --------- src/core/os_akill.cpp | 403 +++++++++ src/core/os_chankill.c | 120 --- src/core/os_chankill.cpp | 120 +++ src/core/os_chanlist.c | 110 --- src/core/os_chanlist.cpp | 110 +++ src/core/os_clearmodes.c | 190 ---- src/core/os_clearmodes.cpp | 190 ++++ src/core/os_defcon.c | 523 ----------- src/core/os_defcon.cpp | 523 +++++++++++ src/core/os_global.c | 65 -- src/core/os_global.cpp | 65 ++ src/core/os_help.c | 50 -- src/core/os_help.cpp | 50 ++ src/core/os_ignore.c | 204 ----- src/core/os_ignore.cpp | 204 +++++ src/core/os_jupe.c | 81 -- src/core/os_jupe.cpp | 81 ++ src/core/os_kick.c | 83 -- src/core/os_kick.cpp | 83 ++ src/core/os_mode.c | 74 -- src/core/os_mode.cpp | 74 ++ src/core/os_modinfo.c | 102 --- src/core/os_modinfo.cpp | 102 +++ src/core/os_modlist.c | 211 ----- src/core/os_modlist.cpp | 211 +++++ src/core/os_modload.c | 76 -- src/core/os_modload.cpp | 76 ++ src/core/os_modunload.c | 78 -- src/core/os_modunload.cpp | 78 ++ src/core/os_news.c | 478 ---------- src/core/os_news.cpp | 478 ++++++++++ src/core/os_noop.c | 92 -- src/core/os_noop.cpp | 92 ++ src/core/os_oline.c | 86 -- src/core/os_oline.cpp | 86 ++ src/core/os_quit.c | 65 -- src/core/os_quit.cpp | 65 ++ src/core/os_reload.c | 67 -- src/core/os_reload.cpp | 67 ++ src/core/os_restart.c | 64 -- src/core/os_restart.cpp | 64 ++ src/core/os_session.c | 505 ----------- src/core/os_session.cpp | 505 +++++++++++ src/core/os_set.c | 311 ------- src/core/os_set.cpp | 311 +++++++ src/core/os_shutdown.c | 65 -- src/core/os_shutdown.cpp | 65 ++ src/core/os_sqline.c | 407 --------- src/core/os_sqline.cpp | 407 +++++++++ src/core/os_staff.c | 87 -- src/core/os_staff.cpp | 87 ++ src/core/os_stats.c | 398 --------- src/core/os_stats.cpp | 398 +++++++++ src/core/os_svsnick.c | 104 --- src/core/os_svsnick.cpp | 104 +++ src/core/os_szline.c | 405 --------- src/core/os_szline.cpp | 405 +++++++++ src/core/os_umode.c | 89 -- src/core/os_umode.cpp | 89 ++ src/core/os_update.c | 57 -- src/core/os_update.cpp | 57 ++ src/core/os_userlist.c | 113 --- src/core/os_userlist.cpp | 113 +++ src/core/ss_main.c | 68 -- src/core/ss_main.cpp | 68 ++ src/encrypt.c | 94 -- src/encrypt.cpp | 94 ++ src/hostserv.c | 219 ----- src/hostserv.cpp | 219 +++++ src/init.c | 472 ---------- src/init.cpp | 472 ++++++++++ src/ircd.c | 59 -- src/ircd.cpp | 59 ++ src/language.c | 339 ------- src/language.cpp | 339 +++++++ src/log.c | 281 ------ src/log.cpp | 281 ++++++ src/main.c | 587 ------------ src/main.cpp | 587 ++++++++++++ src/memory.c | 115 --- src/memory.cpp | 115 +++ src/memoserv.c | 419 --------- src/memoserv.cpp | 419 +++++++++ src/messages.c | 327 ------- src/messages.cpp | 327 +++++++ src/misc.c | 1562 -------------------------------- src/misc.cpp | 1562 ++++++++++++++++++++++++++++++++ src/modules.c | 413 --------- src/modules.cpp | 413 +++++++++ src/modules/CMakeLists.txt | 3 +- src/modules/Makefile | 10 +- src/modules/cs_appendtopic.c | 234 ----- src/modules/cs_appendtopic.cpp | 234 +++++ src/modules/cs_enforce.c | 450 ---------- src/modules/cs_enforce.cpp | 450 ++++++++++ src/modules/cs_tban.c | 214 ----- src/modules/cs_tban.cpp | 214 +++++ src/modules/hs_request.c | 833 ----------------- src/modules/hs_request.cpp | 833 +++++++++++++++++ src/modules/ns_maxemail.c | 169 ---- src/modules/ns_maxemail.cpp | 169 ++++ src/modules/os_info.c | 516 ----------- src/modules/os_info.cpp | 516 +++++++++++ src/nickserv.c | 513 ----------- src/nickserv.cpp | 513 +++++++++++ src/operserv.c | 828 ----------------- src/operserv.cpp | 828 +++++++++++++++++ src/process.c | 367 -------- src/process.cpp | 367 ++++++++ src/protocol/CMakeLists.txt | 3 +- src/protocol/Makefile | 8 +- src/protocol/bahamut.c | 831 ----------------- src/protocol/bahamut.cpp | 831 +++++++++++++++++ src/protocol/inspircd11.c | 1189 ------------------------- src/protocol/inspircd11.cpp | 1189 +++++++++++++++++++++++++ src/protocol/ratbox.c | 899 ------------------- src/protocol/ratbox.cpp | 899 +++++++++++++++++++ src/protocol/unreal32.c | 1347 ---------------------------- src/protocol/unreal32.cpp | 1347 ++++++++++++++++++++++++++++ src/send.c | 232 ----- src/send.cpp | 232 +++++ src/sessions.c | 316 ------- src/sessions.cpp | 316 +++++++ src/users.c | 1246 -------------------------- src/users.cpp | 1246 ++++++++++++++++++++++++++ 306 files changed, 42786 insertions(+), 42807 deletions(-) delete mode 100644 src/actions.c create mode 100644 src/actions.cpp delete mode 100644 src/base64.c create mode 100644 src/base64.cpp delete mode 100644 src/botserv.c create mode 100644 src/botserv.cpp delete mode 100644 src/channels.c create mode 100644 src/channels.cpp delete mode 100644 src/chanserv.c create mode 100644 src/chanserv.cpp delete mode 100644 src/commands.c create mode 100644 src/commands.cpp delete mode 100644 src/compat.c create mode 100644 src/compat.cpp delete mode 100644 src/config.c create mode 100644 src/config.cpp delete mode 100644 src/core/bs_act.c create mode 100644 src/core/bs_act.cpp delete mode 100644 src/core/bs_assign.c create mode 100644 src/core/bs_assign.cpp delete mode 100644 src/core/bs_badwords.c create mode 100644 src/core/bs_badwords.cpp delete mode 100644 src/core/bs_bot.c create mode 100644 src/core/bs_bot.cpp delete mode 100644 src/core/bs_botlist.c create mode 100644 src/core/bs_botlist.cpp delete mode 100644 src/core/bs_help.c create mode 100644 src/core/bs_help.cpp delete mode 100644 src/core/bs_info.c create mode 100644 src/core/bs_info.cpp delete mode 100644 src/core/bs_kick.c create mode 100644 src/core/bs_kick.cpp delete mode 100644 src/core/bs_say.c create mode 100644 src/core/bs_say.cpp delete mode 100644 src/core/bs_set.c create mode 100644 src/core/bs_set.cpp delete mode 100644 src/core/bs_unassign.c create mode 100644 src/core/bs_unassign.cpp delete mode 100644 src/core/cs_access.c create mode 100644 src/core/cs_access.cpp delete mode 100644 src/core/cs_akick.c create mode 100644 src/core/cs_akick.cpp delete mode 100644 src/core/cs_ban.c create mode 100644 src/core/cs_ban.cpp delete mode 100644 src/core/cs_clear.c create mode 100644 src/core/cs_clear.cpp delete mode 100644 src/core/cs_drop.c create mode 100644 src/core/cs_drop.cpp delete mode 100644 src/core/cs_forbid.c create mode 100644 src/core/cs_forbid.cpp delete mode 100644 src/core/cs_getkey.c create mode 100644 src/core/cs_getkey.cpp delete mode 100644 src/core/cs_help.c create mode 100644 src/core/cs_help.cpp delete mode 100644 src/core/cs_info.c create mode 100644 src/core/cs_info.cpp delete mode 100644 src/core/cs_invite.c create mode 100644 src/core/cs_invite.cpp delete mode 100644 src/core/cs_kick.c create mode 100644 src/core/cs_kick.cpp delete mode 100644 src/core/cs_list.c create mode 100644 src/core/cs_list.cpp delete mode 100644 src/core/cs_modes.c create mode 100644 src/core/cs_modes.cpp delete mode 100644 src/core/cs_register.c create mode 100644 src/core/cs_register.cpp delete mode 100644 src/core/cs_set.c create mode 100644 src/core/cs_set.cpp delete mode 100644 src/core/cs_status.c create mode 100644 src/core/cs_status.cpp delete mode 100644 src/core/cs_suspend.c create mode 100644 src/core/cs_suspend.cpp delete mode 100644 src/core/cs_topic.c create mode 100644 src/core/cs_topic.cpp delete mode 100644 src/core/cs_unban.c create mode 100644 src/core/cs_unban.cpp delete mode 100644 src/core/cs_xop.c create mode 100644 src/core/cs_xop.cpp delete mode 100644 src/core/enc_md5.c create mode 100644 src/core/enc_md5.cpp delete mode 100644 src/core/enc_none.c create mode 100644 src/core/enc_none.cpp delete mode 100644 src/core/enc_old.c create mode 100644 src/core/enc_old.cpp delete mode 100644 src/core/enc_sha1.c create mode 100644 src/core/enc_sha1.cpp delete mode 100644 src/core/enc_sha256.c create mode 100644 src/core/enc_sha256.cpp delete mode 100644 src/core/hs_del.c create mode 100644 src/core/hs_del.cpp delete mode 100644 src/core/hs_delall.c create mode 100644 src/core/hs_delall.cpp delete mode 100644 src/core/hs_group.c create mode 100644 src/core/hs_group.cpp delete mode 100644 src/core/hs_help.c create mode 100644 src/core/hs_help.cpp delete mode 100644 src/core/hs_list.c create mode 100644 src/core/hs_list.cpp delete mode 100644 src/core/hs_off.c create mode 100644 src/core/hs_off.cpp delete mode 100644 src/core/hs_on.c create mode 100644 src/core/hs_on.cpp delete mode 100644 src/core/hs_set.c create mode 100644 src/core/hs_set.cpp delete mode 100644 src/core/hs_setall.c create mode 100644 src/core/hs_setall.cpp delete mode 100644 src/core/ms_cancel.c create mode 100644 src/core/ms_cancel.cpp delete mode 100644 src/core/ms_check.c create mode 100644 src/core/ms_check.cpp delete mode 100644 src/core/ms_del.c create mode 100644 src/core/ms_del.cpp delete mode 100644 src/core/ms_help.c create mode 100644 src/core/ms_help.cpp delete mode 100644 src/core/ms_info.c create mode 100644 src/core/ms_info.cpp delete mode 100644 src/core/ms_list.c create mode 100644 src/core/ms_list.cpp delete mode 100644 src/core/ms_read.c create mode 100644 src/core/ms_read.cpp delete mode 100644 src/core/ms_rsend.c create mode 100644 src/core/ms_rsend.cpp delete mode 100644 src/core/ms_send.c create mode 100644 src/core/ms_send.cpp delete mode 100644 src/core/ms_sendall.c create mode 100644 src/core/ms_sendall.cpp delete mode 100644 src/core/ms_set.c create mode 100644 src/core/ms_set.cpp delete mode 100644 src/core/ms_staff.c create mode 100644 src/core/ms_staff.cpp delete mode 100644 src/core/ns_access.c create mode 100644 src/core/ns_access.cpp delete mode 100644 src/core/ns_alist.c create mode 100644 src/core/ns_alist.cpp delete mode 100644 src/core/ns_drop.c create mode 100644 src/core/ns_drop.cpp delete mode 100644 src/core/ns_forbid.c create mode 100644 src/core/ns_forbid.cpp delete mode 100644 src/core/ns_getemail.c create mode 100644 src/core/ns_getemail.cpp delete mode 100644 src/core/ns_getpass.c create mode 100644 src/core/ns_getpass.cpp delete mode 100644 src/core/ns_ghost.c create mode 100644 src/core/ns_ghost.cpp delete mode 100644 src/core/ns_group.c create mode 100644 src/core/ns_group.cpp delete mode 100644 src/core/ns_help.c create mode 100644 src/core/ns_help.cpp delete mode 100644 src/core/ns_identify.c create mode 100644 src/core/ns_identify.cpp delete mode 100644 src/core/ns_info.c create mode 100644 src/core/ns_info.cpp delete mode 100644 src/core/ns_list.c create mode 100644 src/core/ns_list.cpp delete mode 100644 src/core/ns_logout.c create mode 100644 src/core/ns_logout.cpp delete mode 100644 src/core/ns_recover.c create mode 100644 src/core/ns_recover.cpp delete mode 100644 src/core/ns_register.c create mode 100644 src/core/ns_register.cpp delete mode 100644 src/core/ns_release.c create mode 100644 src/core/ns_release.cpp delete mode 100644 src/core/ns_resetpass.c create mode 100644 src/core/ns_resetpass.cpp delete mode 100644 src/core/ns_saset.c create mode 100644 src/core/ns_saset.cpp delete mode 100644 src/core/ns_sendpass.c create mode 100644 src/core/ns_sendpass.cpp delete mode 100644 src/core/ns_set.c create mode 100644 src/core/ns_set.cpp delete mode 100644 src/core/ns_status.c create mode 100644 src/core/ns_status.cpp delete mode 100644 src/core/ns_suspend.c create mode 100644 src/core/ns_suspend.cpp delete mode 100644 src/core/ns_update.c create mode 100644 src/core/ns_update.cpp delete mode 100644 src/core/os_akill.c create mode 100644 src/core/os_akill.cpp delete mode 100644 src/core/os_chankill.c create mode 100644 src/core/os_chankill.cpp delete mode 100644 src/core/os_chanlist.c create mode 100644 src/core/os_chanlist.cpp delete mode 100644 src/core/os_clearmodes.c create mode 100644 src/core/os_clearmodes.cpp delete mode 100644 src/core/os_defcon.c create mode 100644 src/core/os_defcon.cpp delete mode 100644 src/core/os_global.c create mode 100644 src/core/os_global.cpp delete mode 100644 src/core/os_help.c create mode 100644 src/core/os_help.cpp delete mode 100644 src/core/os_ignore.c create mode 100644 src/core/os_ignore.cpp delete mode 100644 src/core/os_jupe.c create mode 100644 src/core/os_jupe.cpp delete mode 100644 src/core/os_kick.c create mode 100644 src/core/os_kick.cpp delete mode 100644 src/core/os_mode.c create mode 100644 src/core/os_mode.cpp delete mode 100644 src/core/os_modinfo.c create mode 100644 src/core/os_modinfo.cpp delete mode 100644 src/core/os_modlist.c create mode 100644 src/core/os_modlist.cpp delete mode 100644 src/core/os_modload.c create mode 100644 src/core/os_modload.cpp delete mode 100644 src/core/os_modunload.c create mode 100644 src/core/os_modunload.cpp delete mode 100644 src/core/os_news.c create mode 100644 src/core/os_news.cpp delete mode 100644 src/core/os_noop.c create mode 100644 src/core/os_noop.cpp delete mode 100644 src/core/os_oline.c create mode 100644 src/core/os_oline.cpp delete mode 100644 src/core/os_quit.c create mode 100644 src/core/os_quit.cpp delete mode 100644 src/core/os_reload.c create mode 100644 src/core/os_reload.cpp delete mode 100644 src/core/os_restart.c create mode 100644 src/core/os_restart.cpp delete mode 100644 src/core/os_session.c create mode 100644 src/core/os_session.cpp delete mode 100644 src/core/os_set.c create mode 100644 src/core/os_set.cpp delete mode 100644 src/core/os_shutdown.c create mode 100644 src/core/os_shutdown.cpp delete mode 100644 src/core/os_sqline.c create mode 100644 src/core/os_sqline.cpp delete mode 100644 src/core/os_staff.c create mode 100644 src/core/os_staff.cpp delete mode 100644 src/core/os_stats.c create mode 100644 src/core/os_stats.cpp delete mode 100644 src/core/os_svsnick.c create mode 100644 src/core/os_svsnick.cpp delete mode 100644 src/core/os_szline.c create mode 100644 src/core/os_szline.cpp delete mode 100644 src/core/os_umode.c create mode 100644 src/core/os_umode.cpp delete mode 100644 src/core/os_update.c create mode 100644 src/core/os_update.cpp delete mode 100644 src/core/os_userlist.c create mode 100644 src/core/os_userlist.cpp delete mode 100644 src/core/ss_main.c create mode 100644 src/core/ss_main.cpp delete mode 100644 src/encrypt.c create mode 100644 src/encrypt.cpp delete mode 100644 src/hostserv.c create mode 100644 src/hostserv.cpp delete mode 100644 src/init.c create mode 100644 src/init.cpp delete mode 100644 src/ircd.c create mode 100644 src/ircd.cpp delete mode 100644 src/language.c create mode 100644 src/language.cpp delete mode 100644 src/log.c create mode 100644 src/log.cpp delete mode 100644 src/main.c create mode 100644 src/main.cpp delete mode 100644 src/memory.c create mode 100644 src/memory.cpp delete mode 100644 src/memoserv.c create mode 100644 src/memoserv.cpp delete mode 100644 src/messages.c create mode 100644 src/messages.cpp delete mode 100644 src/misc.c create mode 100644 src/misc.cpp delete mode 100644 src/modules.c create mode 100644 src/modules.cpp delete mode 100644 src/modules/cs_appendtopic.c create mode 100644 src/modules/cs_appendtopic.cpp delete mode 100644 src/modules/cs_enforce.c create mode 100644 src/modules/cs_enforce.cpp delete mode 100644 src/modules/cs_tban.c create mode 100644 src/modules/cs_tban.cpp delete mode 100644 src/modules/hs_request.c create mode 100644 src/modules/hs_request.cpp delete mode 100644 src/modules/ns_maxemail.c create mode 100644 src/modules/ns_maxemail.cpp delete mode 100644 src/modules/os_info.c create mode 100644 src/modules/os_info.cpp delete mode 100644 src/nickserv.c create mode 100644 src/nickserv.cpp delete mode 100644 src/operserv.c create mode 100644 src/operserv.cpp delete mode 100644 src/process.c create mode 100644 src/process.cpp delete mode 100644 src/protocol/bahamut.c create mode 100644 src/protocol/bahamut.cpp delete mode 100644 src/protocol/inspircd11.c create mode 100644 src/protocol/inspircd11.cpp delete mode 100644 src/protocol/ratbox.c create mode 100644 src/protocol/ratbox.cpp delete mode 100644 src/protocol/unreal32.c create mode 100644 src/protocol/unreal32.cpp delete mode 100644 src/send.c create mode 100644 src/send.cpp delete mode 100644 src/sessions.c create mode 100644 src/sessions.cpp delete mode 100644 src/users.c create mode 100644 src/users.cpp (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8cf232a77..b9c082c7b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,4 @@ -# Find all the *.c and *.cpp files within the current source directory, and sort the list -file(GLOB SRC_SRCS_C RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.c") +# Find all the *.cpp files within the current source directory, and sort the list file(GLOB SRC_SRCS_CPP RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cpp") set(SRC_SRCS ${SRC_SRCS_C} ${SRC_SRCS_CPP}) diff --git a/src/Makefile b/src/Makefile index e7c8ba2fb..d4ce6625e 100644 --- a/src/Makefile +++ b/src/Makefile @@ -19,9 +19,6 @@ MAKEARGS = 'CFLAGS=${CFLAGS}' 'CC=${CC}' 'ANOPELIBS=${ANOPELIBS}' \ 'SHARED=${SHARED}' 'MODULEFLAGS=${MODULEFLAGS}' \ 'MAKEBIN=${MAKEBIN}' 'MYSQLDIR=${MYSQLDIR}' -.c.o: - $(MAKEBIN) $(CC) $(CFLAGS) -I../include/ -c $< - .cpp.o: $(MAKEBIN) $(CC) $(CFLAGS) -I../include/ -c $< @@ -34,50 +31,50 @@ services: $(OBJS) $(MAKEBIN) $(CC) $(CFLAGS) $(OBJS) $(ANOPELIBS) $(MLIBS) -o $@ $(LDFLAGS) $(OBJS): Makefile -actions.o: actions.c $(INCLUDES) -base64.o: base64.c $(INCLUDES) +actions.o: actions.cpp $(INCLUDES) +base64.o: base64.cpp $(INCLUDES) bots.o: bots.cpp $(INCLUDES) -botserv.o: botserv.c $(INCLUDES) -channels.o: channels.c $(INCLUDES) -chanserv.o: chanserv.c $(INCLUDES) +botserv.o: botserv.cpp $(INCLUDES) +channels.o: channels.cpp $(INCLUDES) +chanserv.o: chanserv.cpp $(INCLUDES) command.o: command.cpp $(INCLUDES) -commands.o: commands.c $(INCLUDES) -compat.o: compat.c $(INCLUDES) -config.o: config.c $(INCLUDES) +commands.o: commands.cpp $(INCLUDES) +compat.o: compat.cpp $(INCLUDES) +config.o: config.cpp $(INCLUDES) configreader.o: configreader.cpp $(INCLUDES) -encrypt.o: encrypt.c $(INCLUDES) -init.o: init.c $(INCLUDES) -ircd.o: ircd.c $(INCLUDES) -hostserv.o: hostserv.c $(INCLUDES) -language.o: language.c $(INCLUDES) -log.o: log.c $(INCLUDES) +encrypt.o: encrypt.cpp $(INCLUDES) +init.o: init.cpp $(INCLUDES) +ircd.o: ircd.cpp $(INCLUDES) +hostserv.o: hostserv.cpp $(INCLUDES) +language.o: language.cpp $(INCLUDES) +log.o: log.cpp $(INCLUDES) mail.o: mail.cpp $(INCLUDES) -main.o: main.c $(INCLUDES) -memory.o: memory.c $(INCLUDES) -memoserv.o: memoserv.c $(INCLUDES) -messages.o: messages.c $(INCLUDES) +main.o: main.cpp $(INCLUDES) +memory.o: memory.cpp $(INCLUDES) +memoserv.o: memoserv.cpp $(INCLUDES) +messages.o: messages.cpp $(INCLUDES) modes.o: modes.cpp $(INCLUDES) -modules.o: modules.c $(INCLUDES) +modules.o: modules.cpp $(INCLUDES) module.o: module.cpp $(INCLUDES) modulemanager.o: modulemanager.cpp $(INCLUDES) -misc.o: misc.c $(INCLUDES) +misc.o: misc.cpp $(INCLUDES) nickalias.o: nickalias.cpp $(INCLUDES) nickcore.o: nickcore.cpp $(INCLUDES) -nickserv.o: nickserv.c $(INCLUDES) -operserv.o: operserv.c $(INCLUDES) +nickserv.o: nickserv.cpp $(INCLUDES) +operserv.o: operserv.cpp $(INCLUDES) opertype.o: opertype.cpp $(INCLUDES) -process.o: process.c $(INCLUDES) +process.o: process.cpp $(INCLUDES) protocol.o: protocol.cpp $(INCLUDES) regchannel.o: regchannel.cpp $(INCLUDES) -send.o: send.c $(INCLUDES) +send.o: send.cpp $(INCLUDES) servers.o: servers.cpp $(INCLUDES) -sessions.o: sessions.c $(INCLUDES) -slist.o: slist.c $(INCLUDES) +sessions.o: sessions.cpp $(INCLUDES) +slist.o: slist.cpp $(INCLUDES) sockets.o: sockets.cpp $(INCLUDES) threadengine.o: threadengine.cpp $(INCLUDES) threadengine_pthread.o: threadengine_pthread.cpp $(INCLUDES) timers.o: timers.cpp $(INCLUDES) -users.o: users.c $(INCLUDES) +users.o: users.cpp $(INCLUDES) wildcard.o: wildcard.cpp $(INCLUDES) modules: DUMMY diff --git a/src/actions.c b/src/actions.c deleted file mode 100644 index 00ed01100..000000000 --- a/src/actions.c +++ /dev/null @@ -1,124 +0,0 @@ -/* Various routines to perform simple actions. - * - * (C) 2003-2010 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 "services.h" - -/*************************************************************************/ - -/** - * Note a bad password attempt for the given user. If they've used up - * their limit, toss them off. - * @param u the User to check - * @return true if the user was killed, otherwise false - */ -bool bad_password(User *u) -{ - time_t now = time(NULL); - - if (!u || !Config.BadPassLimit) - return false; - - if (Config.BadPassTimeout > 0 && u->invalid_pw_time > 0 && u->invalid_pw_time < now - Config.BadPassTimeout) - u->invalid_pw_count = 0; - ++u->invalid_pw_count; - u->invalid_pw_time = now; - if (u->invalid_pw_count >= Config.BadPassLimit) - { - kill_user("", u->nick, "Too many invalid passwords"); - return true; - } - - return false; -} - -/*************************************************************************/ - -/** - * Remove a user from the IRC network. - * @param source is the nick which should generate the kill, or NULL for a server-generated kill. - * @param user to remove - * @param reason for the kill - * @return void - */ -void kill_user(const std::string &source, const std::string &user, const std::string &reason) -{ - char buf[BUFSIZE]; - - if (user.empty()) - return; - - std::string real_source = source.empty() ? Config.ServerName : source; - - snprintf(buf, sizeof(buf), "%s (%s)", source.c_str(), reason.c_str()); - - ircdproto->SendSVSKill(findbot(source), finduser(user), buf); - - if (!ircd->quitonkill && finduser(user)) - do_kill(user, buf); -} - -/*************************************************************************/ - -/** - * Unban the nick from a channel - * @param ci channel info for the channel - * @param nick to remove the ban for - * @return void - */ -void common_unban(ChannelInfo *ci, const std::string &nick) -{ - char *host = NULL; - uint32 ip = 0; - User *u; - Entry *ban, *next; - - if (!ci || !ci->c || nick.empty()) - return; - - if (!(u = finduser(nick))) - return; - - if (!ci->c->bans || !ci->c->bans->count) - return; - - if (u->hostip == NULL) - { - host = host_resolve(u->host); - /* we store the just resolved hostname so we don't - * need to do this again */ - if (host) - u->hostip = sstrdup(host); - } - else - host = sstrdup(u->hostip); - /* Convert the host to an IP.. */ - if (host) - ip = str_is_ip(host); - - if (ircd->svsmode_unban) - ircdproto->SendBanDel(ci->c, nick); - else - { - for (ban = ci->c->bans->entries; ban; ban = next) - { - next = ban->next; - if (entry_match(ban, u->nick.c_str(), u->GetIdent().c_str(), u->host, ip) || entry_match(ban, u->nick.c_str(), u->GetIdent().c_str(), u->GetDisplayedHost().c_str(), ip)) - ci->c->RemoveMode(NULL, CMODE_BAN, ban->mask); - } - } - /* host_resolve() sstrdup us this info so we gotta free it */ - if (host) - delete [] host; -} - -/*************************************************************************/ diff --git a/src/actions.cpp b/src/actions.cpp new file mode 100644 index 000000000..00ed01100 --- /dev/null +++ b/src/actions.cpp @@ -0,0 +1,124 @@ +/* Various routines to perform simple actions. + * + * (C) 2003-2010 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 "services.h" + +/*************************************************************************/ + +/** + * Note a bad password attempt for the given user. If they've used up + * their limit, toss them off. + * @param u the User to check + * @return true if the user was killed, otherwise false + */ +bool bad_password(User *u) +{ + time_t now = time(NULL); + + if (!u || !Config.BadPassLimit) + return false; + + if (Config.BadPassTimeout > 0 && u->invalid_pw_time > 0 && u->invalid_pw_time < now - Config.BadPassTimeout) + u->invalid_pw_count = 0; + ++u->invalid_pw_count; + u->invalid_pw_time = now; + if (u->invalid_pw_count >= Config.BadPassLimit) + { + kill_user("", u->nick, "Too many invalid passwords"); + return true; + } + + return false; +} + +/*************************************************************************/ + +/** + * Remove a user from the IRC network. + * @param source is the nick which should generate the kill, or NULL for a server-generated kill. + * @param user to remove + * @param reason for the kill + * @return void + */ +void kill_user(const std::string &source, const std::string &user, const std::string &reason) +{ + char buf[BUFSIZE]; + + if (user.empty()) + return; + + std::string real_source = source.empty() ? Config.ServerName : source; + + snprintf(buf, sizeof(buf), "%s (%s)", source.c_str(), reason.c_str()); + + ircdproto->SendSVSKill(findbot(source), finduser(user), buf); + + if (!ircd->quitonkill && finduser(user)) + do_kill(user, buf); +} + +/*************************************************************************/ + +/** + * Unban the nick from a channel + * @param ci channel info for the channel + * @param nick to remove the ban for + * @return void + */ +void common_unban(ChannelInfo *ci, const std::string &nick) +{ + char *host = NULL; + uint32 ip = 0; + User *u; + Entry *ban, *next; + + if (!ci || !ci->c || nick.empty()) + return; + + if (!(u = finduser(nick))) + return; + + if (!ci->c->bans || !ci->c->bans->count) + return; + + if (u->hostip == NULL) + { + host = host_resolve(u->host); + /* we store the just resolved hostname so we don't + * need to do this again */ + if (host) + u->hostip = sstrdup(host); + } + else + host = sstrdup(u->hostip); + /* Convert the host to an IP.. */ + if (host) + ip = str_is_ip(host); + + if (ircd->svsmode_unban) + ircdproto->SendBanDel(ci->c, nick); + else + { + for (ban = ci->c->bans->entries; ban; ban = next) + { + next = ban->next; + if (entry_match(ban, u->nick.c_str(), u->GetIdent().c_str(), u->host, ip) || entry_match(ban, u->nick.c_str(), u->GetIdent().c_str(), u->GetDisplayedHost().c_str(), ip)) + ci->c->RemoveMode(NULL, CMODE_BAN, ban->mask); + } + } + /* host_resolve() sstrdup us this info so we gotta free it */ + if (host) + delete [] host; +} + +/*************************************************************************/ diff --git a/src/base64.c b/src/base64.c deleted file mode 100644 index 3f576e96a..000000000 --- a/src/base64.c +++ /dev/null @@ -1,416 +0,0 @@ -/* base64 routines. - * - * (C) 2003-2010 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. - * - * - */ - -/* - This is borrowed from Unreal -*/ - -#include "services.h" - -static char *int_to_base64(long); -static long base64_to_int(const char *); - -const char *base64enc(long i) -{ - if (i < 0) - return "0"; - return int_to_base64(i); -} - -long base64dec(const char *b64) -{ - if (b64) - return base64_to_int(b64); - else - return 0; -} - -static const char Base64[] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; -static const char Pad64 = '='; - -/* (From RFC1521 and draft-ietf-dnssec-secext-03.txt) - The following encoding technique is taken from RFC 1521 by Borenstein - and Freed. It is reproduced here in a slightly edited form for - convenience. - - A 65-character subset of US-ASCII is used, enabling 6 bits to be - represented per printable character. (The extra 65th character, "=", - is used to signify a special processing function.) - - The encoding process represents 24-bit groups of input bits as output - strings of 4 encoded characters. Proceeding from left to right, a - 24-bit input group is formed by concatenating 3 8-bit input groups. - These 24 bits are then treated as 4 concatenated 6-bit groups, each - of which is translated into a single digit in the base64 alphabet. - - Each 6-bit group is used as an index into an array of 64 printable - characters. The character referenced by the index is placed in the - output string. - - Table 1: The Base64 Alphabet - - Value Encoding Value Encoding Value Encoding Value Encoding - 0 A 17 R 34 i 51 z - 1 B 18 S 35 j 52 0 - 2 C 19 T 36 k 53 1 - 3 D 20 U 37 l 54 2 - 4 E 21 V 38 m 55 3 - 5 F 22 W 39 n 56 4 - 6 G 23 X 40 o 57 5 - 7 H 24 Y 41 p 58 6 - 8 I 25 Z 42 q 59 7 - 9 J 26 a 43 r 60 8 - 10 K 27 b 44 s 61 9 - 11 L 28 c 45 t 62 + - 12 M 29 d 46 u 63 / - 13 N 30 e 47 v - 14 O 31 f 48 w (pad) = - 15 P 32 g 49 x - 16 Q 33 h 50 y - - Special processing is performed if fewer than 24 bits are available - at the end of the data being encoded. A full encoding quantum is - always completed at the end of a quantity. When fewer than 24 input - bits are available in an input group, zero bits are added (on the - right) to form an integral number of 6-bit groups. Padding at the - end of the data is performed using the '=' character. - - Since all base64 input is an integral number of octets, only the - ------------------------------------------------- - following cases can arise: - - (1) the final quantum of encoding input is an integral - multiple of 24 bits; here, the final unit of encoded - output will be an integral multiple of 4 characters - with no "=" padding, - (2) the final quantum of encoding input is exactly 8 bits; - here, the final unit of encoded output will be two - characters followed by two "=" padding characters, or - (3) the final quantum of encoding input is exactly 16 bits; - here, the final unit of encoded output will be three - characters followed by one "=" padding character. - */ - -int b64_encode(const char *src, size_t srclength, char *target, size_t targsize) -{ - size_t datalength = 0; - unsigned char input[3]; - unsigned char output[4]; - size_t i; - - while (2 < srclength) - { - input[0] = *src++; - input[1] = *src++; - input[2] = *src++; - srclength -= 3; - - output[0] = input[0] >> 2; - output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4); - output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6); - output[3] = input[2] & 0x3f; - - if (datalength + 4 > targsize) - return -1; - target[datalength++] = Base64[output[0]]; - target[datalength++] = Base64[output[1]]; - target[datalength++] = Base64[output[2]]; - target[datalength++] = Base64[output[3]]; - } - - /* Now we worry about padding. */ - if (srclength) - { - /* Get what's left. */ - input[0] = input[1] = input[2] = '\0'; - for (i = 0; i < srclength; ++i) - input[i] = *src++; - - output[0] = input[0] >> 2; - output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4); - output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6); - - if (datalength + 4 > targsize) - return -1; - target[datalength++] = Base64[output[0]]; - target[datalength++] = Base64[output[1]]; - if (srclength == 1) - target[datalength++] = Pad64; - else - target[datalength++] = Base64[output[2]]; - target[datalength++] = Pad64; - } - if (datalength >= targsize) - return -1; - target[datalength] = '\0'; /* Returned value doesn't count \0. */ - return datalength; -} - -/* skips all whitespace anywhere. - converts characters, four at a time, starting at (or after) - src from base - 64 numbers into three 8 bit bytes in the target area. - it returns the number of data bytes stored at the target, or -1 on error. - */ - -int b64_decode(const char *src, char *target, size_t targsize) -{ - int tarindex, state, ch; - char *pos; - - state = 0; - tarindex = 0; - - while ((ch = *src++) != '\0') - { - if (isspace(ch)) /* Skip whitespace anywhere. */ - continue; - - if (ch == Pad64) - break; - - pos = const_cast(strchr(Base64, ch)); - if (!pos) /* A non-base64 character. */ - return -1; - - switch (state) - { - case 0: - if (target) - { - if (static_cast(tarindex) >= targsize) - return -1; - target[tarindex] = (pos - Base64) << 2; - } - state = 1; - break; - case 1: - if (target) - { - if (static_cast(tarindex) + 1 >= targsize) - return -1; - target[tarindex] |= (pos - Base64) >> 4; - target[tarindex + 1] = ((pos - Base64) & 0x0f) << 4; - } - ++tarindex; - state = 2; - break; - case 2: - if (target) - { - if (static_cast(tarindex) + 1 >= targsize) - return -1; - target[tarindex] |= (pos - Base64) >> 2; - target[tarindex + 1] = ((pos - Base64) & 0x03) << 6; - } - ++tarindex; - state = 3; - break; - case 3: - if (target) - { - if (static_cast(tarindex) >= targsize) - return -1; - target[tarindex] |= (pos - Base64); - } - ++tarindex; - state = 0; - break; - default: - abort(); - } - } - - /* - * We are done decoding Base-64 chars. Let's see if we ended - * on a byte boundary, and/or with erroneous trailing characters. - */ - - if (ch == Pad64) /* We got a pad char. */ - { - ch = *src++; /* Skip it, get next. */ - switch (state) - { - case 0: /* Invalid = in first position */ - case 1: /* Invalid = in second position */ - return -1; - - case 2: /* Valid, means one byte of info */ - /* Skip any number of spaces. */ - for (; ch != '\0'; ch = *src++) - if (!isspace(ch)) - break; - /* Make sure there is another trailing = sign. */ - if (ch != Pad64) - return -1; - ch = *src++; /* Skip the = */ - /* Fall through to "single trailing =" case. */ - /* FALLTHROUGH */ - - case 3: /* Valid, means two bytes of info */ - /* - * We know this char is an =. Is there anything but - * whitespace after it? - */ - for (; ch != '\0'; ch = *src++) - if (!isspace(ch)) - return -1; - - /* - * Now make sure for cases 2 and 3 that the "extra" - * bits that slopped past the last full byte were - * zeros. If we don't check them, they become a - * subliminal channel. - */ - if (target && target[tarindex]) - return -1; - } - } - else - { - /* - * We ended by seeing the end of the string. Make sure we - * have no partial bytes lying around. - */ - if (state) - return -1; - } - - return tarindex; -} - -const char* encode_ip(unsigned char *ip) -{ - static char buf[25]; - unsigned char *cp; - struct in_addr ia; /* For IPv4 */ - char *s_ip; /* Signed ip string */ - - if (!ip) - return "*"; - - if (strchr(reinterpret_cast(ip), ':')) - return NULL; - else - { - s_ip = str_signed(ip); - ia.s_addr = inet_addr(s_ip); - cp = reinterpret_cast(ia.s_addr); - b64_encode(reinterpret_cast(&cp), sizeof(struct in_addr), buf, 25); - } - return buf; -} - -int decode_ip(const char *buf) -{ - int len = strlen(buf); - char targ[25]; - struct in_addr ia; - - b64_decode(buf, targ, 25); - ia = *reinterpret_cast(targ); - if (len == 24) /* IPv6 */ - return 0; - else if (len == 8) /* IPv4 */ - return ia.s_addr; - else /* Error?? */ - return 0; -} - -/* ':' and '#' and '&' and '+' and '@' must never be in this table. */ -/* these tables must NEVER CHANGE! >) */ -char int6_to_base64_map[] = { - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', - 'E', 'F', - 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', - 'U', 'V', - 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', - 'k', 'l', - 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', - '{', '}' -}; - -char base64_to_int6_map[] = { - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, - -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, - -1, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, - 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, -1, 63, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 -}; - -static char *int_to_base64(long val) -{ - /* 32/6 == max 6 bytes for representation, - * +1 for the null, +1 for byte boundaries - */ - static char base64buf[8]; - long i = 7; - - base64buf[i] = '\0'; - - /* Temporary debugging code.. remove before 2038 ;p. - * This might happen in case of 64bit longs (opteron/ia64), - * if the value is then too large it can easily lead to - * a buffer underflow and thus to a crash. -- Syzop - */ - if (val > 2147483647L) - abort(); - - do - { - base64buf[--i] = int6_to_base64_map[val & 63]; - } while (val >>= 6); - - return base64buf + i; -} - -static long base64_to_int(const char *b64) -{ - int v = base64_to_int6_map[static_cast(*b64++)]; - - if (!b64) - return 0; - - while (*b64) - { - v <<= 6; - v += base64_to_int6_map[static_cast(*b64++)]; - } - - return v; -} - -long base64dects(const char *ts) -{ - if (!ts) - return 0; - - char *token = myStrGetToken(ts, '!', 1); - if (!token) - return strtoul(ts, NULL, 10); - - long value = base64dec(token); - delete [] token; - return value; -} diff --git a/src/base64.cpp b/src/base64.cpp new file mode 100644 index 000000000..3f576e96a --- /dev/null +++ b/src/base64.cpp @@ -0,0 +1,416 @@ +/* base64 routines. + * + * (C) 2003-2010 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. + * + * + */ + +/* + This is borrowed from Unreal +*/ + +#include "services.h" + +static char *int_to_base64(long); +static long base64_to_int(const char *); + +const char *base64enc(long i) +{ + if (i < 0) + return "0"; + return int_to_base64(i); +} + +long base64dec(const char *b64) +{ + if (b64) + return base64_to_int(b64); + else + return 0; +} + +static const char Base64[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; +static const char Pad64 = '='; + +/* (From RFC1521 and draft-ietf-dnssec-secext-03.txt) + The following encoding technique is taken from RFC 1521 by Borenstein + and Freed. It is reproduced here in a slightly edited form for + convenience. + + A 65-character subset of US-ASCII is used, enabling 6 bits to be + represented per printable character. (The extra 65th character, "=", + is used to signify a special processing function.) + + The encoding process represents 24-bit groups of input bits as output + strings of 4 encoded characters. Proceeding from left to right, a + 24-bit input group is formed by concatenating 3 8-bit input groups. + These 24 bits are then treated as 4 concatenated 6-bit groups, each + of which is translated into a single digit in the base64 alphabet. + + Each 6-bit group is used as an index into an array of 64 printable + characters. The character referenced by the index is placed in the + output string. + + Table 1: The Base64 Alphabet + + Value Encoding Value Encoding Value Encoding Value Encoding + 0 A 17 R 34 i 51 z + 1 B 18 S 35 j 52 0 + 2 C 19 T 36 k 53 1 + 3 D 20 U 37 l 54 2 + 4 E 21 V 38 m 55 3 + 5 F 22 W 39 n 56 4 + 6 G 23 X 40 o 57 5 + 7 H 24 Y 41 p 58 6 + 8 I 25 Z 42 q 59 7 + 9 J 26 a 43 r 60 8 + 10 K 27 b 44 s 61 9 + 11 L 28 c 45 t 62 + + 12 M 29 d 46 u 63 / + 13 N 30 e 47 v + 14 O 31 f 48 w (pad) = + 15 P 32 g 49 x + 16 Q 33 h 50 y + + Special processing is performed if fewer than 24 bits are available + at the end of the data being encoded. A full encoding quantum is + always completed at the end of a quantity. When fewer than 24 input + bits are available in an input group, zero bits are added (on the + right) to form an integral number of 6-bit groups. Padding at the + end of the data is performed using the '=' character. + + Since all base64 input is an integral number of octets, only the + ------------------------------------------------- + following cases can arise: + + (1) the final quantum of encoding input is an integral + multiple of 24 bits; here, the final unit of encoded + output will be an integral multiple of 4 characters + with no "=" padding, + (2) the final quantum of encoding input is exactly 8 bits; + here, the final unit of encoded output will be two + characters followed by two "=" padding characters, or + (3) the final quantum of encoding input is exactly 16 bits; + here, the final unit of encoded output will be three + characters followed by one "=" padding character. + */ + +int b64_encode(const char *src, size_t srclength, char *target, size_t targsize) +{ + size_t datalength = 0; + unsigned char input[3]; + unsigned char output[4]; + size_t i; + + while (2 < srclength) + { + input[0] = *src++; + input[1] = *src++; + input[2] = *src++; + srclength -= 3; + + output[0] = input[0] >> 2; + output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4); + output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6); + output[3] = input[2] & 0x3f; + + if (datalength + 4 > targsize) + return -1; + target[datalength++] = Base64[output[0]]; + target[datalength++] = Base64[output[1]]; + target[datalength++] = Base64[output[2]]; + target[datalength++] = Base64[output[3]]; + } + + /* Now we worry about padding. */ + if (srclength) + { + /* Get what's left. */ + input[0] = input[1] = input[2] = '\0'; + for (i = 0; i < srclength; ++i) + input[i] = *src++; + + output[0] = input[0] >> 2; + output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4); + output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6); + + if (datalength + 4 > targsize) + return -1; + target[datalength++] = Base64[output[0]]; + target[datalength++] = Base64[output[1]]; + if (srclength == 1) + target[datalength++] = Pad64; + else + target[datalength++] = Base64[output[2]]; + target[datalength++] = Pad64; + } + if (datalength >= targsize) + return -1; + target[datalength] = '\0'; /* Returned value doesn't count \0. */ + return datalength; +} + +/* skips all whitespace anywhere. + converts characters, four at a time, starting at (or after) + src from base - 64 numbers into three 8 bit bytes in the target area. + it returns the number of data bytes stored at the target, or -1 on error. + */ + +int b64_decode(const char *src, char *target, size_t targsize) +{ + int tarindex, state, ch; + char *pos; + + state = 0; + tarindex = 0; + + while ((ch = *src++) != '\0') + { + if (isspace(ch)) /* Skip whitespace anywhere. */ + continue; + + if (ch == Pad64) + break; + + pos = const_cast(strchr(Base64, ch)); + if (!pos) /* A non-base64 character. */ + return -1; + + switch (state) + { + case 0: + if (target) + { + if (static_cast(tarindex) >= targsize) + return -1; + target[tarindex] = (pos - Base64) << 2; + } + state = 1; + break; + case 1: + if (target) + { + if (static_cast(tarindex) + 1 >= targsize) + return -1; + target[tarindex] |= (pos - Base64) >> 4; + target[tarindex + 1] = ((pos - Base64) & 0x0f) << 4; + } + ++tarindex; + state = 2; + break; + case 2: + if (target) + { + if (static_cast(tarindex) + 1 >= targsize) + return -1; + target[tarindex] |= (pos - Base64) >> 2; + target[tarindex + 1] = ((pos - Base64) & 0x03) << 6; + } + ++tarindex; + state = 3; + break; + case 3: + if (target) + { + if (static_cast(tarindex) >= targsize) + return -1; + target[tarindex] |= (pos - Base64); + } + ++tarindex; + state = 0; + break; + default: + abort(); + } + } + + /* + * We are done decoding Base-64 chars. Let's see if we ended + * on a byte boundary, and/or with erroneous trailing characters. + */ + + if (ch == Pad64) /* We got a pad char. */ + { + ch = *src++; /* Skip it, get next. */ + switch (state) + { + case 0: /* Invalid = in first position */ + case 1: /* Invalid = in second position */ + return -1; + + case 2: /* Valid, means one byte of info */ + /* Skip any number of spaces. */ + for (; ch != '\0'; ch = *src++) + if (!isspace(ch)) + break; + /* Make sure there is another trailing = sign. */ + if (ch != Pad64) + return -1; + ch = *src++; /* Skip the = */ + /* Fall through to "single trailing =" case. */ + /* FALLTHROUGH */ + + case 3: /* Valid, means two bytes of info */ + /* + * We know this char is an =. Is there anything but + * whitespace after it? + */ + for (; ch != '\0'; ch = *src++) + if (!isspace(ch)) + return -1; + + /* + * Now make sure for cases 2 and 3 that the "extra" + * bits that slopped past the last full byte were + * zeros. If we don't check them, they become a + * subliminal channel. + */ + if (target && target[tarindex]) + return -1; + } + } + else + { + /* + * We ended by seeing the end of the string. Make sure we + * have no partial bytes lying around. + */ + if (state) + return -1; + } + + return tarindex; +} + +const char* encode_ip(unsigned char *ip) +{ + static char buf[25]; + unsigned char *cp; + struct in_addr ia; /* For IPv4 */ + char *s_ip; /* Signed ip string */ + + if (!ip) + return "*"; + + if (strchr(reinterpret_cast(ip), ':')) + return NULL; + else + { + s_ip = str_signed(ip); + ia.s_addr = inet_addr(s_ip); + cp = reinterpret_cast(ia.s_addr); + b64_encode(reinterpret_cast(&cp), sizeof(struct in_addr), buf, 25); + } + return buf; +} + +int decode_ip(const char *buf) +{ + int len = strlen(buf); + char targ[25]; + struct in_addr ia; + + b64_decode(buf, targ, 25); + ia = *reinterpret_cast(targ); + if (len == 24) /* IPv6 */ + return 0; + else if (len == 8) /* IPv4 */ + return ia.s_addr; + else /* Error?? */ + return 0; +} + +/* ':' and '#' and '&' and '+' and '@' must never be in this table. */ +/* these tables must NEVER CHANGE! >) */ +char int6_to_base64_map[] = { + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', + 'E', 'F', + 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', + 'U', 'V', + 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', + 'k', 'l', + 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', + '{', '}' +}; + +char base64_to_int6_map[] = { + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, + -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, + -1, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, -1, 63, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 +}; + +static char *int_to_base64(long val) +{ + /* 32/6 == max 6 bytes for representation, + * +1 for the null, +1 for byte boundaries + */ + static char base64buf[8]; + long i = 7; + + base64buf[i] = '\0'; + + /* Temporary debugging code.. remove before 2038 ;p. + * This might happen in case of 64bit longs (opteron/ia64), + * if the value is then too large it can easily lead to + * a buffer underflow and thus to a crash. -- Syzop + */ + if (val > 2147483647L) + abort(); + + do + { + base64buf[--i] = int6_to_base64_map[val & 63]; + } while (val >>= 6); + + return base64buf + i; +} + +static long base64_to_int(const char *b64) +{ + int v = base64_to_int6_map[static_cast(*b64++)]; + + if (!b64) + return 0; + + while (*b64) + { + v <<= 6; + v += base64_to_int6_map[static_cast(*b64++)]; + } + + return v; +} + +long base64dects(const char *ts) +{ + if (!ts) + return 0; + + char *token = myStrGetToken(ts, '!', 1); + if (!token) + return strtoul(ts, NULL, 10); + + long value = base64dec(token); + delete [] token; + return value; +} diff --git a/src/botserv.c b/src/botserv.c deleted file mode 100644 index aefe37b08..000000000 --- a/src/botserv.c +++ /dev/null @@ -1,853 +0,0 @@ -/* BotServ functions - * - * (C) 2003-2010 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 "services.h" -#include "modules.h" -#include "language.h" - -static UserData *get_user_data(Channel * c, User * u); - -static void check_ban(ChannelInfo * ci, User * u, int ttbtype); -static void bot_kick(ChannelInfo * ci, User * u, int message, ...); - -E void moduleAddBotServCmds(); - -/*************************************************************************/ -/* *INDENT-OFF* */ -void moduleAddBotServCmds() { - ModuleManager::LoadModuleList(Config.BotServCoreModules); -} -/* *INDENT-ON* */ -/*************************************************************************/ -/*************************************************************************/ - -/* Return information on memory use. Assumes pointers are valid. */ - -void get_botserv_stats(long *nrec, long *memuse) -{ - long count = 0, mem = 0; - - for (botinfo_map::const_iterator it = BotList.begin(); it != BotList.end(); ++it) - { - BotInfo *bi = it->second; - - count++; - mem += sizeof(*bi); - mem += bi->nick.size() + 1; - mem += bi->user.size() + 1; - mem += bi->host.size() + 1; - mem += bi->real.size() + 1; - } - - *nrec = count; - *memuse = mem; -} - -/*************************************************************************/ -/*************************************************************************/ - -/* BotServ initialization. */ - -void bs_init() -{ - if (Config.s_BotServ) { - moduleAddBotServCmds(); - } -} - -/*************************************************************************/ - -/* Main BotServ routine. */ - -void botserv(User * u, char *buf) -{ - char *cmd, *s; - - cmd = strtok(buf, " "); - - if (!cmd) { - return; - } else if (stricmp(cmd, "\1PING") == 0) { - if (!(s = strtok(NULL, ""))) { - *s = 0; - } - ircdproto->SendCTCP(BotServ, u->nick.c_str(), "PING %s", s); - } else { - mod_run_cmd(BotServ, u, cmd); - } - -} - -/*************************************************************************/ - -/* Handles all messages sent to bots. (Currently only answers to pings ;) */ - -void botmsgs(User * u, BotInfo * bi, char *buf) -{ - char *cmd = strtok(buf, " "); - char *s; - - if (!cmd || !u || !bi) - return; - - if (!stricmp(cmd, "\1PING")) { - if (!(s = strtok(NULL, ""))) { - *s = 0; - } - ircdproto->SendCTCP(bi, u->nick.c_str(), "PING %s", s); - } - else if (cmd && !bi->Commands.empty()) - { - mod_run_cmd(bi, u, cmd); - } -} - -/*************************************************************************/ - -/* Handles all messages that are sent to registered channels where a - * bot is on. - * - */ - -void botchanmsgs(User * u, ChannelInfo * ci, char *buf) -{ - int c; - char *cmd; - UserData *ud; - bool was_action = false; - std::string bbuf; - - if (!u || !buf || !ci || !ci->c) - return; - - /* Answer to ping if needed, without breaking the buffer. */ - if (!strnicmp(buf, "\1PING", 5)) { - ircdproto->SendCTCP(ci->bi, u->nick.c_str(), "PING %s", buf); - } - - /* If it's a /me, cut the CTCP part at the beginning (not - * at the end, because one character just doesn't matter, - * but the ACTION may create strange behaviours with the - * caps or badwords kickers */ - if (!strnicmp(buf, "\1ACTION ", 8)) - { - buf += 8; - was_action = true; - } - - /* Now we can make kicker stuff. We try to order the checks - * from the fastest one to the slowest one, since there's - * no need to process other kickers if an user is kicked before - * the last kicker check. - * - * But FIRST we check whether the user is protected in any - * way. - */ - - bool Allow = false; - if (!ci->botflags.HasFlag(BS_DONTKICKOPS) && !ci->botflags.HasFlag(BS_DONTKICKVOICES)) - Allow = true; - else if (ci->botflags.HasFlag(BS_DONTKICKOPS) && (ci->c->HasUserStatus(u, CMODE_HALFOP) || ci->c->HasUserStatus(u, CMODE_OP) || ci->c->HasUserStatus(u, CMODE_PROTECT) || ci->c->HasUserStatus(u, CMODE_OWNER))) - Allow = true; - else if (ci->botflags.HasFlag(BS_DONTKICKVOICES) && ci->c->HasUserStatus(u, CMODE_VOICE)) - Allow = true; - - if (buf && !check_access(u, ci, CA_NOKICK) && Allow) - { - /* Bolds kicker */ - if (ci->botflags.HasFlag(BS_KICK_BOLDS) && strchr(buf, 2)) { - check_ban(ci, u, TTB_BOLDS); - bot_kick(ci, u, BOT_REASON_BOLD); - return; - } - - /* Color ki