diff options
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/Anope_Install_Script.nsi | 540 | ||||
-rw-r--r-- | src/tools/Anope_MySQL_Install_Script.nsi | 542 | ||||
-rw-r--r-- | src/tools/Makefile | 39 | ||||
-rw-r--r-- | src/tools/Makefile.win32 | 29 | ||||
-rw-r--r-- | src/tools/README | 58 | ||||
-rw-r--r-- | src/tools/anopesmtp.c | 604 | ||||
-rw-r--r-- | src/tools/db-merger.c | 2031 | ||||
-rw-r--r-- | src/tools/epona2anope.c | 856 | ||||
-rw-r--r-- | src/tools/smtp.h | 130 |
9 files changed, 4829 insertions, 0 deletions
diff --git a/src/tools/Anope_Install_Script.nsi b/src/tools/Anope_Install_Script.nsi new file mode 100644 index 000000000..633a4aa19 --- /dev/null +++ b/src/tools/Anope_Install_Script.nsi @@ -0,0 +1,540 @@ +; Script generated by the HM NIS Edit Script Wizard.
+
+; HM NIS Edit Wizard helper defines
+!define PRODUCT_NAME "Anope IRC Services"
+!define PRODUCT_VERSION "1.8.0"
+!define PRODUCT_PUBLISHER "Anope"
+!define PRODUCT_WEB_SITE "http://www.anope.org"
+!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\anope.exe"
+!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
+!define PRODUCT_UNINST_ROOT_KEY "HKLM"
+
+; MUI 1.67 compatible ------
+!include "MUI.nsh"
+
+; MUI Settings
+!define MUI_ABORTWARNING
+!define MUI_ICON "anope-icon.ico"
+!define MUI_UNICON "anope-icon.ico"
+
+; Language Selection Dialog Settings
+!define MUI_LANGDLL_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
+!define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
+!define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language"
+
+; Welcome page
+!insertmacro MUI_PAGE_WELCOME
+; License page
+!define MUI_LICENSEPAGE_RADIOBUTTONS
+!insertmacro MUI_PAGE_LICENSE "anope-1.8.0\docs\COPYING.txt"
+; Directory page
+!insertmacro MUI_PAGE_DIRECTORY
+; Instfiles page
+!insertmacro MUI_PAGE_INSTFILES
+; Finish page
+!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\docs\README.txt"
+!insertmacro MUI_PAGE_FINISH
+
+; Uninstaller pages
+!insertmacro MUI_UNPAGE_INSTFILES
+
+; Language files
+!insertmacro MUI_LANGUAGE "Dutch"
+!insertmacro MUI_LANGUAGE "English"
+!insertmacro MUI_LANGUAGE "French"
+!insertmacro MUI_LANGUAGE "German"
+!insertmacro MUI_LANGUAGE "Italian"
+!insertmacro MUI_LANGUAGE "Portuguese"
+!insertmacro MUI_LANGUAGE "Spanish"
+
+; MUI end ------
+
+Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
+OutFile "Anope-1.8.0.exe"
+InstallDir "$PROGRAMFILES\Anope"
+InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
+ShowInstDetails show
+ShowUnInstDetails show
+
+Function .onInit
+ !insertmacro MUI_LANGDLL_DISPLAY
+FunctionEnd
+
+Section "MainSection" SEC01
+ SetOutPath "$INSTDIR"
+ File "anope-1.8.0\anope.exe"
+File "anope-1.8.0\anope.bat"
+ SetShellVarContext all
+ CreateDirectory "$SMPROGRAMS\Anope"
+ CreateShortCut "$SMPROGRAMS\Anope\Anope IRC Services.lnk" "$INSTDIR\anope.exe"
+ CreateDirectory "$SMPROGRAMS\Anope\Advanced"
+ CreateShortCut "$SMPROGRAMS\Anope\Advanced\Anope IRC Services (Debug and Window Logging).lnk" "$INSTDIR\anope.bat" "-debug -nofork"
+ CreateShortCut "$SMPROGRAMS\Anope\Advanced\Anope IRC Services (Window Logging).lnk" "$INSTDIR\anope.bat" "-nofork"
+ CreateShortCut "$SMPROGRAMS\Anope\Advanced\Anope IRC Services (No Third Party Modules).lnk" "$INSTDIR\anope.bat" "-nothird"
+ CreateShortCut "$DESKTOP\Anope IRC Services.lnk" "$INSTDIR\anope.exe"
+ File "anope-1.8.0\anope.exe.manifest"
+ File "anope-1.8.0\Changes.conf.txt"
+ File "anope-1.8.0\Changes.lang.txt"
+ File "anope-1.8.0\Changes.mysql.txt"
+ File "anope-1.8.0\Changes.txt"
+ SetOutPath "$INSTDIR\data"
+ File "anope-1.8.0\data\anopesmtp.exe"
+ File "anope-1.8.0\data\anopesmtp.exe.manifest"
+ SetOutPath "$INSTDIR\data\bin"
+ File "anope-1.8.0\data\bin\am"
+ File "anope-1.8.0\data\bin\anoperc.in"
+ File "anope-1.8.0\data\bin\cp-recursive"
+ File "anope-1.8.0\data\bin\langtool"
+ File "anope-1.8.0\data\bin\mydbgen"
+ File "anope-1.8.0\data\bin\register"
+ SetOutPath "$INSTDIR\data"
+ File "anope-1.8.0\data\db-merger.exe"
+ File "anope-1.8.0\data\db-merger.exe.manifest"
+ File "anope-1.8.0\data\epona2anope.exe"
+ File "anope-1.8.0\data\epona2anope.exe.manifest"
+ File "anope-1.8.0\data\example.conf"
+ SetOutPath "$INSTDIR\data\languages"
+ File "anope-1.8.0\data\languages\cat"
+ File "anope-1.8.0\data\languages\de"
+ File "anope-1.8.0\data\languages\en_us"
+ File "anope-1.8.0\data\languages\es"
+ File "anope-1.8.0\data\languages\fr"
+ File "anope-1.8.0\data\languages\gr"
+ File "anope-1.8.0\data\languages\hun"
+ File "anope-1.8.0\data\languages\it"
+ File "anope-1.8.0\data\languages\nl"
+ File "anope-1.8.0\data\languages\pl"
+ File "anope-1.8.0\data\languages\pt"
+ File "anope-1.8.0\data\languages\ru"
+ File "anope-1.8.0\data\languages\tr"
+ SetOutPath "$INSTDIR\data\logs"
+ SetOutPath "$INSTDIR\data\backups"
+ SetOutPath "$INSTDIR\data\modules"
+ File "anope-1.8.0\data\modules\bahamut.dll"
+ File "anope-1.8.0\data\modules\bs_act.dll"
+ File "anope-1.8.0\data\modules\bs_assign.dll"
+ File "anope-1.8.0\data\modules\bs_badwords.dll"
+ File "anope-1.8.0\data\modules\bs_bot.dll"
+ File "anope-1.8.0\data\modules\bs_botlist.dll"
+ File "anope-1.8.0\data\modules\bs_fantasy.dll"
+ File "anope-1.8.0\data\modules\bs_fantasy_kick.dll"
+ File "anope-1.8.0\data\modules\bs_fantasy_kickban.dll"
+ File "anope-1.8.0\data\modules\bs_fantasy_owner.dll"
+ File "anope-1.8.0\data\modules\bs_fantasy_seen.dll"
+ File "anope-1.8.0\data\modules\bs_fantasy_unban.dll"
+ File "anope-1.8.0\data\modules\bs_help.dll"
+ File "anope-1.8.0\data\modules\bs_info.dll"
+ File "anope-1.8.0\data\modules\bs_kick.dll"
+ File "anope-1.8.0\data\modules\bs_say.dll"
+ File "anope-1.8.0\data\modules\bs_set.dll"
+ File "anope-1.8.0\data\modules\bs_unassign.dll"
+ File "anope-1.8.0\data\modules\charybdis.dll"
+ File "anope-1.8.0\data\modules\cs_access.dll"
+ File "anope-1.8.0\data\modules\cs_akick.dll"
+ File "anope-1.8.0\data\modules\cs_appendtopic.dll"
+ File "anope-1.8.0\data\modules\cs_ban.dll"
+ File "anope-1.8.0\data\modules\cs_clear.dll"
+ File "anope-1.8.0\data\modules\cs_drop.dll"
+ File "anope-1.8.0\data\modules\cs_enforce.dll"
+ File "anope-1.8.0\data\modules\cs_forbid.dll"
+ File "anope-1.8.0\data\modules\cs_getkey.dll"
+ File "anope-1.8.0\data\modules\cs_getpass.dll"
+ File "anope-1.8.0\data\modules\cs_help.dll"
+ File "anope-1.8.0\data\modules\cs_identify.dll"
+ File "anope-1.8.0\data\modules\cs_info.dll"
+ File "anope-1.8.0\data\modules\cs_invite.dll"
+ File "anope-1.8.0\data\modules\cs_kick.dll"
+ File "anope-1.8.0\data\modules\cs_list.dll"
+ File "anope-1.8.0\data\modules\cs_logout.dll"
+ File "anope-1.8.0\data\modules\cs_modes.dll"
+ File "anope-1.8.0\data\modules\cs_register.dll"
+ File "anope-1.8.0\data\modules\cs_sendpass.dll"
+ File "anope-1.8.0\data\modules\cs_set.dll"
+ File "anope-1.8.0\data\modules\cs_status.dll"
+ File "anope-1.8.0\data\modules\cs_suspend.dll"
+ File "anope-1.8.0\data\modules\cs_tban.dll"
+ File "anope-1.8.0\data\modules\cs_topic.dll"
+ File "anope-1.8.0\data\modules\cs_xop.dll"
+ File "anope-1.8.0\data\modules\dreamforge.dll"
+ File "anope-1.8.0\data\modules\enc_md5.dll"
+ File "anope-1.8.0\data\modules\enc_sha1.dll"
+ File "anope-1.8.0\data\modules\enc_none.dll"
+ File "anope-1.8.0\data\modules\enc_old.dll"
+ File "anope-1.8.0\data\modules\he_help.dll"
+ File "anope-1.8.0\data\modules\hs_del.dll"
+ File "anope-1.8.0\data\modules\hs_delall.dll"
+ File "anope-1.8.0\data\modules\hs_group.dll"
+ File "anope-1.8.0\data\modules\hs_help.dll"
+ File "anope-1.8.0\data\modules\hs_list.dll"
+ File "anope-1.8.0\data\modules\hs_off.dll"
+ File "anope-1.8.0\data\modules\hs_on.dll"
+ File "anope-1.8.0\data\modules\hs_request.dll"
+ File "anope-1.8.0\data\modules\hs_set.dll"
+ File "anope-1.8.0\data\modules\hs_setall.dll"
+ File "anope-1.8.0\data\modules\hybrid.dll"
+ File "anope-1.8.0\data\modules\inspircd10.dll"
+ File "anope-1.8.0\data\modules\inspircd11.dll"
+ File "anope-1.8.0\data\modules\ms_cancel.dll"
+ File "anope-1.8.0\data\modules\ms_check.dll"
+ File "anope-1.8.0\data\modules\ms_del.dll"
+ File "anope-1.8.0\data\modules\ms_help.dll"
+ File "anope-1.8.0\data\modules\ms_info.dll"
+ File "anope-1.8.0\data\modules\ms_list.dll"
+ File "anope-1.8.0\data\modules\ms_read.dll"
+ File "anope-1.8.0\data\modules\ms_rsend.dll"
+ File "anope-1.8.0\data\modules\ms_send.dll"
+ File "anope-1.8.0\data\modules\ms_sendall.dll"
+ File "anope-1.8.0\data\modules\ms_set.dll"
+ File "anope-1.8.0\data\modules\ms_staff.dll"
+ File "anope-1.8.0\data\modules\ns_access.dll"
+ File "anope-1.8.0\data\modules\ns_alist.dll"
+ File "anope-1.8.0\data\modules\ns_drop.dll"
+ File "anope-1.8.0\data\modules\ns_forbid.dll"
+ File "anope-1.8.0\data\modules\ns_getemail.dll"
+ File "anope-1.8.0\data\modules\ns_getpass.dll"
+ File "anope-1.8.0\data\modules\ns_ghost.dll"
+ File "anope-1.8.0\data\modules\ns_group.dll"
+ File "anope-1.8.0\data\modules\ns_help.dll"
+ File "anope-1.8.0\data\modules\ns_identify.dll"
+ File "anope-1.8.0\data\modules\ns_info.dll"
+ File "anope-1.8.0\data\modules\ns_list.dll"
+ File "anope-1.8.0\data\modules\ns_logout.dll"
+ File "anope-1.8.0\data\modules\ns_maxemail.dll"
+ File "anope-1.8.0\data\modules\ns_recover.dll"
+ File "anope-1.8.0\data\modules\ns_register.dll"
+ File "anope-1.8.0\data\modules\ns_release.dll"
+ File "anope-1.8.0\data\modules\ns_saset.dll"
+ File "anope-1.8.0\data\modules\ns_sendpass.dll"
+ File "anope-1.8.0\data\modules\ns_set.dll"
+ File "anope-1.8.0\data\modules\ns_status.dll"
+ File "anope-1.8.0\data\modules\ns_suspend.dll"
+ File "anope-1.8.0\data\modules\ns_update.dll"
+ File "anope-1.8.0\data\modules\os_admin.dll"
+ File "anope-1.8.0\data\modules\os_akill.dll"
+ File "anope-1.8.0\data\modules\os_chankill.dll"
+ File "anope-1.8.0\data\modules\os_chanlist.dll"
+ File "anope-1.8.0\data\modules\os_clearmodes.dll"
+ File "anope-1.8.0\data\modules\os_defcon.dll"
+ File "anope-1.8.0\data\modules\os_global.dll"
+ File "anope-1.8.0\data\modules\os_help.dll"
+ File "anope-1.8.0\data\modules\os_ignore.dll"
+ File "anope-1.8.0\data\modules\os_info.dll"
+ File "anope-1.8.0\data\modules\os_jupe.dll"
+ File "anope-1.8.0\data\modules\os_kick.dll"
+ File "anope-1.8.0\data\modules\os_logonnews.dll"
+ File "anope-1.8.0\data\modules\os_mode.dll"
+ File "anope-1.8.0\data\modules\os_modinfo.dll"
+ File "anope-1.8.0\data\modules\os_modlist.dll"
+ File "anope-1.8.0\data\modules\os_modload.dll"
+ File "anope-1.8.0\data\modules\os_modunload.dll"
+ File "anope-1.8.0\data\modules\os_noop.dll"
+ File "anope-1.8.0\data\modules\os_oline.dll"
+ File "anope-1.8.0\data\modules\os_oper.dll"
+ File "anope-1.8.0\data\modules\os_opernews.dll"
+ File "anope-1.8.0\data\modules\os_quit.dll"
+ File "anope-1.8.0\data\modules\os_randomnews.dll"
+ File "anope-1.8.0\data\modules\os_raw.dll"
+ File "anope-1.8.0\data\modules\os_reload.dll"
+ File "anope-1.8.0\data\modules\os_restart.dll"
+ File "anope-1.8.0\data\modules\os_session.dll"
+ File "anope-1.8.0\data\modules\os_set.dll"
+ File "anope-1.8.0\data\modules\os_sgline.dll"
+ File "anope-1.8.0\data\modules\os_shutdown.dll"
+ File "anope-1.8.0\data\modules\os_sqline.dll"
+ File "anope-1.8.0\data\modules\os_staff.dll"
+ File "anope-1.8.0\data\modules\os_stats.dll"
+ File "anope-1.8.0\data\modules\os_svsnick.dll"
+ File "anope-1.8.0\data\modules\os_szline.dll"
+ File "anope-1.8.0\data\modules\os_umode.dll"
+ File "anope-1.8.0\data\modules\os_update.dll"
+ File "anope-1.8.0\data\modules\os_userlist.dll"
+ File "anope-1.8.0\data\modules\plexus2.dll"
+ File "anope-1.8.0\data\modules\plexus3.dll"
+ File "anope-1.8.0\data\modules\ptlink.dll"
+ File "anope-1.8.0\data\modules\rageircd.dll"
+ File "anope-1.8.0\data\modules\ratbox.dll"
+ File "anope-1.8.0\data\modules\shadowircd.dll"
+ File "anope-1.8.0\data\modules\solidircd.dll"
+ File "anope-1.8.0\data\modules\ultimate2.dll"
+ File "anope-1.8.0\data\modules\ultimate3.dll"
+ File "anope-1.8.0\data\modules\unreal31.dll"
+ File "anope-1.8.0\data\modules\unreal32.dll"
+ File "anope-1.8.0\data\modules\viagra.dll"
+ SetOutPath "$INSTDIR\data\modules\runtime"
+ SetOutPath "$INSTDIR\data"
+ File "anope-1.8.0\data\tables.sql"
+ SetOutPath "$INSTDIR\docs"
+ File "anope-1.8.0\docs\BUGS.txt"
+ File "anope-1.8.0\docs\COPYING.txt"
+ File "anope-1.8.0\docs\DEFCON.txt"
+ File "anope-1.8.0\docs\EVENTS.txt"
+ File "anope-1.8.0\docs\FAQ.txt"
+ File "anope-1.8.0\docs\INSTALL.txt"
+ File "anope-1.8.0\docs\IRCD.txt"
+ File "anope-1.8.0\docs\MODULES.txt"
+ File "anope-1.8.0\docs\MYSQL.txt"
+ File "anope-1.8.0\docs\NEWS.txt"
+ File "anope-1.8.0\docs\OLDCHANGES.txt"
+ File "anope-1.8.0\docs\PROXY.txt"
+ File "anope-1.8.0\docs\README.txt"
+ File "anope-1.8.0\docs\WIN32.txt"
+ File "anope-1.8.0\docs\OLDNEWS.txt"
+
+SectionEnd
+
+Section -AdditionalIcons
+ SetOutPath $INSTDIR
+ WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
+ CreateShortCut "$SMPROGRAMS\Anope\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
+ CreateShortCut "$SMPROGRAMS\Anope\Uninstall.lnk" "$INSTDIR\uninst.exe"
+SectionEnd
+
+Section -Post
+ WriteUninstaller "$INSTDIR\uninst.exe"
+ WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\anope.exe"
+ WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
+ WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
+ WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\anope.exe"
+ WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
+ WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
+ WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
+SectionEnd
+
+
+Function un.onUninstSuccess
+ HideWindow
+ MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer."
+FunctionEnd
+
+Function un.onInit
+!insertmacro MUI_UNGETLANGUAGE
+ MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2
+ Abort
+FunctionEnd
+
+Section Uninstall
+ Delete "$INSTDIR\${PRODUCT_NAME}.url"
+ Delete "$INSTDIR\uninst.exe"
+ Delete "$INSTDIR\docs\WIN32.txt"
+ Delete "$INSTDIR\docs\README.txt"
+ Delete "$INSTDIR\docs\PROXY.txt"
+ Delete "$INSTDIR\docs\OLDCHANGES.txt"
+ Delete "$INSTDIR\docs\OLDNEWS.txt"
+ Delete "$INSTDIR\docs\NEWS.txt"
+ Delete "$INSTDIR\docs\MYSQL.txt"
+ Delete "$INSTDIR\docs\MODULES.txt"
+ Delete "$INSTDIR\docs\IRCD.txt"
+ Delete "$INSTDIR\docs\INSTALL.txt"
+ Delete "$INSTDIR\docs\FAQ.txt"
+ Delete "$INSTDIR\docs\EVENTS.txt"
+ Delete "$INSTDIR\docs\DEFCON.txt"
+ Delete "$INSTDIR\docs\COPYING.txt"
+ Delete "$INSTDIR\docs\BUGS.txt"
+ Delete "$INSTDIR\data\tables.sql"
+ Delete "$INSTDIR\data\modules\viagra.dll"
+ Delete "$INSTDIR\data\modules\unreal32.dll"
+ Delete "$INSTDIR\data\modules\unreal31.dll"
+ Delete "$INSTDIR\data\modules\ultimate3.dll"
+ Delete "$INSTDIR\data\modules\ultimate2.dll"
+ Delete "$INSTDIR\data\modules\solidircd.dll"
+ Delete "$INSTDIR\data\modules\shadowircd.dll"
+ Delete "$INSTDIR\data\modules\ratbox.dll"
+ Delete "$INSTDIR\data\modules\rageircd.dll"
+ Delete "$INSTDIR\data\modules\ptlink.dll"
+ Delete "$INSTDIR\data\modules\plexus3.dll"
+ Delete "$INSTDIR\data\modules\plexus2.dll"
+ Delete "$INSTDIR\data\modules\os_userlist.dll"
+ Delete "$INSTDIR\data\modules\os_update.dll"
+ Delete "$INSTDIR\data\modules\os_umode.dll"
+ Delete "$INSTDIR\data\modules\os_szline.dll"
+ Delete "$INSTDIR\data\modules\os_svsnick.dll"
+ Delete "$INSTDIR\data\modules\os_stats.dll"
+ Delete "$INSTDIR\data\modules\os_staff.dll"
+ Delete "$INSTDIR\data\modules\os_sqline.dll"
+ Delete "$INSTDIR\data\modules\os_shutdown.dll"
+ Delete "$INSTDIR\data\modules\os_sgline.dll"
+ Delete "$INSTDIR\data\modules\os_set.dll"
+ Delete "$INSTDIR\data\modules\os_session.dll"
+ Delete "$INSTDIR\data\modules\os_restart.dll"
+ Delete "$INSTDIR\data\modules\os_reload.dll"
+ Delete "$INSTDIR\data\modules\os_raw.dll"
+ Delete "$INSTDIR\data\modules\os_randomnews.dll"
+ Delete "$INSTDIR\data\modules\os_quit.dll"
+ Delete "$INSTDIR\data\modules\os_opernews.dll"
+ Delete "$INSTDIR\data\modules\os_oper.dll"
+ Delete "$INSTDIR\data\modules\os_oline.dll"
+ Delete "$INSTDIR\data\modules\os_noop.dll"
+ Delete "$INSTDIR\data\modules\os_modunload.dll"
+ Delete "$INSTDIR\data\modules\os_modload.dll"
+ Delete "$INSTDIR\data\modules\os_modlist.dll"
+ Delete "$INSTDIR\data\modules\os_modinfo.dll"
+ Delete "$INSTDIR\data\modules\os_mode.dll"
+ Delete "$INSTDIR\data\modules\os_logonnews.dll"
+ Delete "$INSTDIR\data\modules\os_kick.dll"
+ Delete "$INSTDIR\data\modules\os_jupe.dll"
+ Delete "$INSTDIR\data\modules\os_info.dll"
+ Delete "$INSTDIR\data\modules\os_ignore.dll"
+ Delete "$INSTDIR\data\modules\os_help.dll"
+ Delete "$INSTDIR\data\modules\os_global.dll"
+ Delete "$INSTDIR\data\modules\os_defcon.dll"
+ Delete "$INSTDIR\data\modules\os_clearmodes.dll"
+ Delete "$INSTDIR\data\modules\os_chanlist.dll"
+ Delete "$INSTDIR\data\modules\os_chankill.dll"
+ Delete "$INSTDIR\data\modules\os_akill.dll"
+ Delete "$INSTDIR\data\modules\os_admin.dll"
+ Delete "$INSTDIR\data\modules\ns_update.dll"
+ Delete "$INSTDIR\data\modules\ns_suspend.dll"
+ Delete "$INSTDIR\data\modules\ns_status.dll"
+ Delete "$INSTDIR\data\modules\ns_set.dll"
+ Delete "$INSTDIR\data\modules\ns_sendpass.dll"
+ Delete "$INSTDIR\data\modules\ns_saset.dll"
+ Delete "$INSTDIR\data\modules\ns_release.dll"
+ Delete "$INSTDIR\data\modules\ns_register.dll"
+ Delete "$INSTDIR\data\modules\ns_recover.dll"
+ Delete "$INSTDIR\data\modules\ns_maxemail.dll"
+ Delete "$INSTDIR\data\modules\ns_logout.dll"
+ Delete "$INSTDIR\data\modules\ns_list.dll"
+ Delete "$INSTDIR\data\modules\ns_info.dll"
+ Delete "$INSTDIR\data\modules\ns_identify.dll"
+ Delete "$INSTDIR\data\modules\ns_help.dll"
+ Delete "$INSTDIR\data\modules\ns_group.dll"
+ Delete "$INSTDIR\data\modules\ns_ghost.dll"
+ Delete "$INSTDIR\data\modules\ns_getpass.dll"
+ Delete "$INSTDIR\data\modules\ns_getemail.dll"
+ Delete "$INSTDIR\data\modules\ns_forbid.dll"
+ Delete "$INSTDIR\data\modules\ns_drop.dll"
+ Delete "$INSTDIR\data\modules\ns_alist.dll"
+ Delete "$INSTDIR\data\modules\ns_access.dll"
+ Delete "$INSTDIR\data\modules\ms_staff.dll"
+ Delete "$INSTDIR\data\modules\ms_set.dll"
+ Delete "$INSTDIR\data\modules\ms_sendall.dll"
+ Delete "$INSTDIR\data\modules\ms_send.dll"
+ Delete "$INSTDIR\data\modules\ms_rsend.dll"
+ Delete "$INSTDIR\data\modules\ms_read.dll"
+ Delete "$INSTDIR\data\modules\ms_list.dll"
+ Delete "$INSTDIR\data\modules\ms_info.dll"
+ Delete "$INSTDIR\data\modules\ms_help.dll"
+ Delete "$INSTDIR\data\modules\ms_del.dll"
+ Delete "$INSTDIR\data\modules\ms_check.dll"
+ Delete "$INSTDIR\data\modules\ms_cancel.dll"
+ Delete "$INSTDIR\data\modules\inspircd11.dll"
+ Delete "$INSTDIR\data\modules\inspircd10.dll"
+ Delete "$INSTDIR\data\modules\hybrid.dll"
+ Delete "$INSTDIR\data\modules\hs_setall.dll"
+ Delete "$INSTDIR\data\modules\hs_set.dll"
+ Delete "$INSTDIR\data\modules\hs_request.dll"
+ Delete "$INSTDIR\data\modules\hs_on.dll"
+ Delete "$INSTDIR\data\modules\hs_off.dll"
+ Delete "$INSTDIR\data\modules\hs_list.dll"
+ Delete "$INSTDIR\data\modules\hs_help.dll"
+ Delete "$INSTDIR\data\modules\hs_group.dll"
+ Delete "$INSTDIR\data\modules\hs_delall.dll"
+ Delete "$INSTDIR\data\modules\hs_del.dll"
+ Delete "$INSTDIR\data\modules\he_help.dll"
+ Delete "$INSTDIR\data\modules\enc_old.dll"
+ Delete "$INSTDIR\data\modules\enc_none.dll"
+ Delete "$INSTDIR\data\modules\enc_md5.dll"
+ Delete "$INSTDIR\data\modules\enc_sha1.dll"
+ Delete "$INSTDIR\data\modules\dreamforge.dll"
+ Delete "$INSTDIR\data\modules\cs_xop.dll"
+ Delete "$INSTDIR\data\modules\cs_topic.dll"
+ Delete "$INSTDIR\data\modules\cs_tban.dll"
+ Delete "$INSTDIR\data\modules\cs_suspend.dll"
+ Delete "$INSTDIR\data\modules\cs_status.dll"
+ Delete "$INSTDIR\data\modules\cs_set.dll"
+ Delete "$INSTDIR\data\modules\cs_sendpass.dll"
+ Delete "$INSTDIR\data\modules\cs_register.dll"
+ Delete "$INSTDIR\data\modules\cs_modes.dll"
+ Delete "$INSTDIR\data\modules\cs_logout.dll"
+ Delete "$INSTDIR\data\modules\cs_list.dll"
+ Delete "$INSTDIR\data\modules\cs_kick.dll"
+ Delete "$INSTDIR\data\modules\cs_invite.dll"
+ Delete "$INSTDIR\data\modules\cs_info.dll"
+ Delete "$INSTDIR\data\modules\cs_identify.dll"
+ Delete "$INSTDIR\data\modules\cs_help.dll"
+ Delete "$INSTDIR\data\modules\cs_getpass.dll"
+ Delete "$INSTDIR\data\modules\cs_getkey.dll"
+ Delete "$INSTDIR\data\modules\cs_forbid.dll"
+ Delete "$INSTDIR\data\modules\cs_enforce.dll"
+ Delete "$INSTDIR\data\modules\cs_drop.dll"
+ Delete "$INSTDIR\data\modules\cs_clear.dll"
+ Delete "$INSTDIR\data\modules\cs_ban.dll"
+ Delete "$INSTDIR\data\modules\cs_appendtopic.dll"
+ Delete "$INSTDIR\data\modules\cs_akick.dll"
+ Delete "$INSTDIR\data\modules\cs_access.dll"
+ Delete "$INSTDIR\data\modules\charybdis.dll"
+ Delete "$INSTDIR\data\modules\bs_unassign.dll"
+ Delete "$INSTDIR\data\modules\bs_set.dll"
+ Delete "$INSTDIR\data\modules\bs_say.dll"
+ Delete "$INSTDIR\data\modules\bs_kick.dll"
+ Delete "$INSTDIR\data\modules\bs_info.dll"
+ Delete "$INSTDIR\data\modules\bs_help.dll"
+ Delete "$INSTDIR\data\modules\bs_fantasy_unban.dll"
+ Delete "$INSTDIR\data\modules\bs_fantasy_seen.dll"
+ Delete "$INSTDIR\data\modules\bs_fantasy_owner.dll"
+ Delete "$INSTDIR\data\modules\bs_fantasy_kickban.dll"
+ Delete "$INSTDIR\data\modules\bs_fantasy_kick.dll"
+ Delete "$INSTDIR\data\modules\bs_fantasy.dll"
+ Delete "$INSTDIR\data\modules\bs_botlist.dll"
+ Delete "$INSTDIR\data\modules\bs_bot.dll"
+ Delete "$INSTDIR\data\modules\bs_badwords.dll"
+ Delete "$INSTDIR\data\modules\bs_assign.dll"
+ Delete "$INSTDIR\data\modules\bs_act.dll"
+ Delete "$INSTDIR\data\modules\bahamut.dll"
+ Delete "$INSTDIR\data\languages\tr"
+ Delete "$INSTDIR\data\languages\ru"
+ Delete "$INSTDIR\data\languages\pt"
+ Delete "$INSTDIR\data\languages\pl"
+ Delete "$INSTDIR\data\languages\nl"
+ Delete "$INSTDIR\data\languages\it"
+ Delete "$INSTDIR\data\languages\hun"
+ Delete "$INSTDIR\data\languages\gr"
+ Delete "$INSTDIR\data\languages\fr"
+ Delete "$INSTDIR\data\languages\es"
+ Delete "$INSTDIR\data\languages\en_us"
+ Delete "$INSTDIR\data\languages\de"
+ Delete "$INSTDIR\data\languages\cat"
+ Delete "$INSTDIR\data\example.conf"
+ Delete "$INSTDIR\data\epona2anope.exe.manifest"
+ Delete "$INSTDIR\data\epona2anope.exe"
+ Delete "$INSTDIR\data\db-merger.exe.manifest"
+ Delete "$INSTDIR\data\db-merger.exe"
+ Delete "$INSTDIR\data\bin\register"
+ Delete "$INSTDIR\data\bin\mydbgen"
+ Delete "$INSTDIR\data\bin\langtool"
+ Delete "$INSTDIR\data\bin\cp-recursive"
+ Delete "$INSTDIR\data\bin\anoperc.in"
+ Delete "$INSTDIR\data\bin\am"
+ Delete "$INSTDIR\data\anopesmtp.exe.manifest"
+ Delete "$INSTDIR\data\anopesmtp.exe"
+ Delete "$INSTDIR\Changes.txt"
+ Delete "$INSTDIR\Changes.mysql.txt"
+ Delete "$INSTDIR\Changes.lang.txt"
+ Delete "$INSTDIR\Changes.conf.txt"
+ Delete "$INSTDIR\anope.exe.manifest"
+ Delete "$INSTDIR\anope.exe"
+Delete "$INSTDIR\anope.bat"
+ SetShellVarContext all
+ Delete "$SMPROGRAMS\Anope\Uninstall.lnk"
+ Delete "$SMPROGRAMS\Anope\Website.lnk"
+ Delete "$DESKTOP\Anope IRC Services.lnk"
+ Delete "$SMPROGRAMS\Anope\Anope IRC Services.lnk"
+ Delete "$SMPROGRAMS\Anope\Advanced\Anope IRC Services (Debug and Window Logging).lnk"
+ Delete "$SMPROGRAMS\Anope\Advanced\Anope IRC Services (Window Logging).lnk"
+ Delete "$SMPROGRAMS\Anope\Advanced\Anope IRC Services (No Third Party Modules).lnk"
+
+RMDir "$SMPROGRAMS\Anope\Advanced"
+ RMDir "$SMPROGRAMS\Anope"
+ RMDir "$INSTDIR\docs"
+ RMDir "$INSTDIR\data\modules"
+RMDir "$INSTDIR\data\backups"
+ RMDir "$INSTDIR\data\logs"
+ RMDir "$INSTDIR\data\languages"
+ RMDir "$INSTDIR\data\bin"
+ RMDir "$INSTDIR\data"
+ RMDir "$INSTDIR"
+
+ DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
+ DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
+ SetAutoClose true
+SectionEnd
\ No newline at end of file diff --git a/src/tools/Anope_MySQL_Install_Script.nsi b/src/tools/Anope_MySQL_Install_Script.nsi new file mode 100644 index 000000000..ead85e449 --- /dev/null +++ b/src/tools/Anope_MySQL_Install_Script.nsi @@ -0,0 +1,542 @@ +; Script generated by the HM NIS Edit Script Wizard.
+
+; HM NIS Edit Wizard helper defines
+!define PRODUCT_NAME "Anope IRC Services"
+!define PRODUCT_VERSION "1.8.0-MySQL"
+!define PRODUCT_PUBLISHER "Anope"
+!define PRODUCT_WEB_SITE "http://www.anope.org"
+!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\anope.exe"
+!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
+!define PRODUCT_UNINST_ROOT_KEY "HKLM"
+
+; MUI 1.67 compatible ------
+!include "MUI.nsh"
+
+; MUI Settings
+!define MUI_ABORTWARNING
+!define MUI_ICON "anope-icon.ico"
+!define MUI_UNICON "anope-icon.ico"
+
+; Language Selection Dialog Settings
+!define MUI_LANGDLL_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
+!define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
+!define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language"
+
+; Welcome page
+!insertmacro MUI_PAGE_WELCOME
+; License page
+!define MUI_LICENSEPAGE_RADIOBUTTONS
+!insertmacro MUI_PAGE_LICENSE "anope-1.8.0-MySQL\docs\COPYING.txt"
+; Directory page
+!insertmacro MUI_PAGE_DIRECTORY
+; Instfiles page
+!insertmacro MUI_PAGE_INSTFILES
+; Finish page
+!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\docs\README.txt"
+!insertmacro MUI_PAGE_FINISH
+
+; Uninstaller pages
+!insertmacro MUI_UNPAGE_INSTFILES
+
+; Language files
+!insertmacro MUI_LANGUAGE "Dutch"
+!insertmacro MUI_LANGUAGE "English"
+!insertmacro MUI_LANGUAGE "French"
+!insertmacro MUI_LANGUAGE "German"
+!insertmacro MUI_LANGUAGE "Italian"
+!insertmacro MUI_LANGUAGE "Portuguese"
+!insertmacro MUI_LANGUAGE "Spanish"
+
+; MUI end ------
+
+Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
+OutFile "Anope-1.8.0-MySQL.exe"
+InstallDir "$PROGRAMFILES\Anope"
+InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
+ShowInstDetails show
+ShowUnInstDetails show
+
+Function .onInit
+ !insertmacro MUI_LANGDLL_DISPLAY
+FunctionEnd
+
+Section "MainSection" SEC01
+ SetOutPath "$INSTDIR"
+ File "anope-1.8.0-MySQL\anope.exe"
+File "anope-1.8.0\anope.bat"
+ SetShellVarContext all
+ CreateDirectory "$SMPROGRAMS\Anope"
+ CreateShortCut "$SMPROGRAMS\Anope\Anope IRC Services.lnk" "$INSTDIR\anope.exe"
+ CreateShortCut "$DESKTOP\Anope IRC Services.lnk" "$INSTDIR\anope.exe"
+ CreateDirectory "$SMPROGRAMS\Anope\Advanced"
+ CreateShortCut "$SMPROGRAMS\Anope\Advanced\Anope IRC Services (Debug and Window Logging).lnk" "$INSTDIR\anope.bat" "-debug -nofork"
+ CreateShortCut "$SMPROGRAMS\Anope\Advanced\Anope IRC Services (Window Logging).lnk" "$INSTDIR\anope.bat" "-nofork"
+ CreateShortCut "$SMPROGRAMS\Anope\Advanced\Anope IRC Services (No Third Party Modules).lnk" "$INSTDIR\anope.bat" "-nothird"
+
+ File "anope-1.8.0-MySQL\anope.exe.manifest"
+ File "anope-1.8.0-MySQL\Changes.conf.txt"
+ File "anope-1.8.0-MySQL\Changes.lang.txt"
+ File "anope-1.8.0-MySQL\Changes.mysql.txt"
+ File "anope-1.8.0-MySQL\Changes.txt"
+ SetOutPath "$INSTDIR\data"
+ File "anope-1.8.0-MySQL\data\anopesmtp.exe"
+ File "anope-1.8.0-MySQL\data\anopesmtp.exe.manifest"
+ SetOutPath "$INSTDIR\data\bin"
+ File "anope-1.8.0-MySQL\data\bin\am"
+ File "anope-1.8.0-MySQL\data\bin\anoperc.in"
+ File "anope-1.8.0-MySQL\data\bin\cp-recursive"
+ File "anope-1.8.0-MySQL\data\bin\langtool"
+ File "anope-1.8.0-MySQL\data\bin\mydbgen"
+ File "anope-1.8.0-MySQL\data\bin\register"
+ SetOutPath "$INSTDIR\data"
+ File "anope-1.8.0-MySQL\data\db-merger.exe"
+ File "anope-1.8.0-MySQL\data\db-merger.exe.manifest"
+ File "anope-1.8.0-MySQL\data\epona2anope.exe"
+ File "anope-1.8.0-MySQL\data\epona2anope.exe.manifest"
+ File "anope-1.8.0-MySQL\data\example.conf"
+ SetOutPath "$INSTDIR\data\languages"
+ File "anope-1.8.0-MySQL\data\languages\cat"
+ File "anope-1.8.0-MySQL\data\languages\de"
+ File "anope-1.8.0-MySQL\data\languages\en_us"
+ File "anope-1.8.0-MySQL\data\languages\es"
+ File "anope-1.8.0-MySQL\data\languages\fr"
+ File "anope-1.8.0-MySQL\data\languages\gr"
+ File "anope-1.8.0-MySQL\data\languages\hun"
+ File "anope-1.8.0-MySQL\data\languages\it"
+ File "anope-1.8.0-MySQL\data\languages\nl"
+ File "anope-1.8.0-MySQL\data\languages\pl"
+ File "anope-1.8.0-MySQL\data\languages\pt"
+ File "anope-1.8.0-MySQL\data\languages\ru"
+ File "anope-1.8.0-MySQL\data\languages\tr"
+ SetOutPath "$INSTDIR\data\logs"
+SetOutPath "$INSTDIR\data\backups"
+ SetOutPath "$INSTDIR\data\modules"
+ File "anope-1.8.0-MySQL\data\modules\bahamut.dll"
+ File "anope-1.8.0-MySQL\data\modules\bs_act.dll"
+ File "anope-1.8.0-MySQL\data\modules\bs_assign.dll"
+ File "anope-1.8.0-MySQL\data\modules\bs_badwords.dll"
+ File "anope-1.8.0-MySQL\data\modules\bs_bot.dll"
+ File "anope-1.8.0-MySQL\data\modules\bs_botlist.dll"
+ File "anope-1.8.0-MySQL\data\modules\bs_fantasy.dll"
+ File "anope-1.8.0-MySQL\data\modules\bs_fantasy_kick.dll"
+ File "anope-1.8.0-MySQL\data\modules\bs_fantasy_kickban.dll"
+ File "anope-1.8.0-MySQL\data\modules\bs_fantasy_owner.dll"
+ File "anope-1.8.0-MySQL\data\modules\bs_fantasy_seen.dll"
+ File "anope-1.8.0-MySQL\data\modules\bs_fantasy_unban.dll"
+ File "anope-1.8.0-MySQL\data\modules\bs_help.dll"
+ File "anope-1.8.0-MySQL\data\modules\bs_info.dll"
+ File "anope-1.8.0-MySQL\data\modules\bs_kick.dll"
+ File "anope-1.8.0-MySQL\data\modules\bs_say.dll"
+ File "anope-1.8.0-MySQL\data\modules\bs_set.dll"
+ File "anope-1.8.0-MySQL\data\modules\bs_unassign.dll"
+ File "anope-1.8.0-MySQL\data\modules\charybdis.dll"
+ File "anope-1.8.0-MySQL\data\modules\cs_access.dll"
+ File "anope-1.8.0-MySQL\data\modules\cs_akick.dll"
+ File "anope-1.8.0-MySQL\data\modules\cs_appendtopic.dll"
+ File "anope-1.8.0-MySQL\data\modules\cs_ban.dll"
+ File "anope-1.8.0-MySQL\data\modules\cs_clear.dll"
+ File "anope-1.8.0-MySQL\data\modules\cs_drop.dll"
+ File "anope-1.8.0-MySQL\data\modules\cs_enforce.dll"
+ File "anope-1.8.0-MySQL\data\modules\cs_forbid.dll"
+ File "anope-1.8.0-MySQL\data\modules\cs_getkey.dll"
+ File "anope-1.8.0-MySQL\data\modules\cs_getpass.dll"
+ File "anope-1.8.0-MySQL\data\modules\cs_help.dll"
+ File "anope-1.8.0-MySQL\data\modules\cs_identify.dll"
+ File "anope-1.8.0-MySQL\data\modules\cs_info.dll"
+ File "anope-1.8.0-MySQL\data\modules\cs_invite.dll"
+ File "anope-1.8.0-MySQL\data\modules\cs_kick.dll"
+ File "anope-1.8.0-MySQL\data\modules\cs_list.dll"
+ File "anope-1.8.0-MySQL\data\modules\cs_logout.dll"
+ File "anope-1.8.0-MySQL\data\modules\cs_modes.dll"
+ File "anope-1.8.0-MySQL\data\modules\cs_register.dll"
+ File "anope-1.8.0-MySQL\data\modules\cs_sendpass.dll"
+ File "anope-1.8.0-MySQL\data\modules\cs_set.dll"
+ File "anope-1.8.0-MySQL\data\modules\cs_status.dll"
+ File "anope-1.8.0-MySQL\data\modules\cs_suspend.dll"
+ File "anope-1.8.0-MySQL\data\modules\cs_tban.dll"
+ File "anope-1.8.0-MySQL\data\modules\cs_topic.dll"
+ File "anope-1.8.0-MySQL\data\modules\cs_xop.dll"
+ File "anope-1.8.0-MySQL\data\modules\dreamforge.dll"
+ File "anope-1.8.0-MySQL\data\modules\enc_md5.dll"
+ File "anope-1.8.0-MySQL\data\modules\enc_sha1.dll"
+ File "anope-1.8.0-MySQL\data\modules\enc_none.dll"
+ File "anope-1.8.0-MySQL\data\modules\enc_old.dll"
+ File "anope-1.8.0-MySQL\data\modules\he_help.dll"
+ File "anope-1.8.0-MySQL\data\modules\hs_del.dll"
+ File "anope-1.8.0-MySQL\data\modules\hs_delall.dll"
+ File "anope-1.8.0-MySQL\data\modules\hs_group.dll"
+ File "anope-1.8.0-MySQL\data\modules\hs_help.dll"
+ File "anope-1.8.0-MySQL\data\modules\hs_list.dll"
+ File "anope-1.8.0-MySQL\data\modules\hs_off.dll"
+ File "anope-1.8.0-MySQL\data\modules\hs_on.dll"
+ File "anope-1.8.0-MySQL\data\modules\hs_request.dll"
+ File "anope-1.8.0-MySQL\data\modules\hs_set.dll"
+ File "anope-1.8.0-MySQL\data\modules\hs_setall.dll"
+ File "anope-1.8.0-MySQL\data\modules\hybrid.dll"
+ File "anope-1.8.0-MySQL\data\modules\inspircd10.dll"
+ File "anope-1.8.0-MySQL\data\modules\inspircd11.dll"
+ File "anope-1.8.0-MySQL\data\modules\ms_cancel.dll"
+ File "anope-1.8.0-MySQL\data\modules\ms_check.dll"
+ File "anope-1.8.0-MySQL\data\modules\ms_del.dll"
+ File "anope-1.8.0-MySQL\data\modules\ms_help.dll"
+ File "anope-1.8.0-MySQL\data\modules\ms_info.dll"
+ File "anope-1.8.0-MySQL\data\modules\ms_list.dll"
+ File "anope-1.8.0-MySQL\data\modules\ms_read.dll"
+ File "anope-1.8.0-MySQL\data\modules\ms_rsend.dll"
+ File "anope-1.8.0-MySQL\data\modules\ms_send.dll"
+ File "anope-1.8.0-MySQL\data\modules\ms_sendall.dll"
+ File "anope-1.8.0-MySQL\data\modules\ms_set.dll"
+ File "anope-1.8.0-MySQL\data\modules\ms_staff.dll"
+ File "anope-1.8.0-MySQL\data\modules\ns_access.dll"
+ File "anope-1.8.0-MySQL\data\modules\ns_alist.dll"
+ File "anope-1.8.0-MySQL\data\modules\ns_drop.dll"
+ File "anope-1.8.0-MySQL\data\modules\ns_forbid.dll"
+ File "anope-1.8.0-MySQL\data\modules\ns_getemail.dll"
+ File "anope-1.8.0-MySQL\data\modules\ns_getpass.dll"
+ File "anope-1.8.0-MySQL\data\modules\ns_ghost.dll"
+ File "anope-1.8.0-MySQL\data\modules\ns_group.dll"
+ File "anope-1.8.0-MySQL\data\modules\ns_help.dll"
+ File "anope-1.8.0-MySQL\data\modules\ns_identify.dll"
+ File "anope-1.8.0-MySQL\data\modules\ns_info.dll"
+ File "anope-1.8.0-MySQL\data\modules\ns_list.dll"
+ File "anope-1.8.0-MySQL\data\modules\ns_logout.dll"
+ File "anope-1.8.0-MySQL\data\modules\ns_maxemail.dll"
+ File "anope-1.8.0-MySQL\data\modules\ns_recover.dll"
+ File "anope-1.8.0-MySQL\data\modules\ns_register.dll"
+ File "anope-1.8.0-MySQL\data\modules\ns_release.dll"
+ File "anope-1.8.0-MySQL\data\modules\ns_saset.dll"
+ File "anope-1.8.0-MySQL\data\modules\ns_sendpass.dll"
+ File "anope-1.8.0-MySQL\data\modules\ns_set.dll"
+ File "anope-1.8.0-MySQL\data\modules\ns_status.dll"
+ File "anope-1.8.0-MySQL\data\modules\ns_suspend.dll"
+ File "anope-1.8.0-MySQL\data\modules\ns_update.dll"
+ File "anope-1.8.0-MySQL\data\modules\os_admin.dll"
+ File "anope-1.8.0-MySQL\data\modules\os_akill.dll"
+ File "anope-1.8.0-MySQL\data\modules\os_chankill.dll"
+ File "anope-1.8.0-MySQL\data\modules\os_chanlist.dll"
+ File "anope-1.8.0-MySQL\data\modules\os_clearmodes.dll"
+ File "anope-1.8.0-MySQL\data\modules\os_defcon.dll"
+ File "anope-1.8.0-MySQL\data\modules\os_global.dll"
+ File "anope-1.8.0-MySQL\data\modules\os_help.dll"
+ File "anope-1.8.0-MySQL\data\modules\os_ignore.dll"
+ File "anope-1.8.0-MySQL\data\modules\os_info.dll"
+ File "anope-1.8.0-MySQL\data\modules\os_jupe.dll"
+ File "anope-1.8.0-MySQL\data\modules\os_kick.dll"
+ File "anope-1.8.0-MySQL\data\modules\os_logonnews.dll"
+ File "anope-1.8.0-MySQL\data\modules\os_mode.dll"
+ File "anope-1.8.0-MySQL\data\modules\os_modinfo.dll"
+ File "anope-1.8.0-MySQL\data\modules\os_modlist.dll"
+ File "anope-1.8.0-MySQL\data\modules\os_modload.dll"
+ File "anope-1.8.0-MySQL\data\modules\os_modunload.dll"
+ File "anope-1.8.0-MySQL\data\modules\os_noop.dll"
+ File "anope-1.8.0-MySQL\data\modules\os_oline.dll"
+ File "anope-1.8.0-MySQL\data\modules\os_oper.dll"
+ File "anope-1.8.0-MySQL\data\modules\os_opernews.dll"
+ File "anope-1.8.0-MySQL\data\modules\os_quit.dll"
+ File "anope-1.8.0-MySQL\data\modules\os_randomnews.dll"
+ File "anope-1.8.0-MySQL\data\modules\os_raw.dll"
+ File "anope-1.8.0-MySQL\data\modules\os_reload.dll"
+ File "anope-1.8.0-MySQL\data\modules\os_restart.dll"
+ File "anope-1.8.0-MySQL\data\modules\os_session.dll"
+ File "anope-1.8.0-MySQL\data\modules\os_set.dll"
+ File "anope-1.8.0-MySQL\data\modules\os_sgline.dll"
+ File "anope-1.8.0-MySQL\data\modules\os_shutdown.dll"
+ File "anope-1.8.0-MySQL\data\modules\os_sqline.dll"
+ File "anope-1.8.0-MySQL\data\modules\os_staff.dll"
+ File "anope-1.8.0-MySQL\data\modules\os_stats.dll"
+ File "anope-1.8.0-MySQL\data\modules\os_svsnick.dll"
+ File "anope-1.8.0-MySQL\data\modules\os_szline.dll"
+ File "anope-1.8.0-MySQL\data\modules\os_umode.dll"
+ File "anope-1.8.0-MySQL\data\modules\os_update.dll"
+ File "anope-1.8.0-MySQL\data\modules\os_userlist.dll"
+ File "anope-1.8.0-MySQL\data\modules\plexus2.dll"
+ File "anope-1.8.0-MySQL\data\modules\plexus3.dll"
+ File "anope-1.8.0-MySQL\data\modules\ptlink.dll"
+ File "anope-1.8.0-MySQL\data\modules\rageircd.dll"
+ File "anope-1.8.0-MySQL\data\modules\ratbox.dll"
+ File "anope-1.8.0-MySQL\data\modules\shadowircd.dll"
+ File "anope-1.8.0-MySQL\data\modules\solidircd.dll"
+ File "anope-1.8.0-MySQL\data\modules\ultimate2.dll"
+ File "anope-1.8.0-MySQL\data\modules\ultimate3.dll"
+ File "anope-1.8.0-MySQL\data\modules\unreal31.dll"
+ File "anope-1.8.0-MySQL\data\modules\unreal32.dll"
+ File "anope-1.8.0-MySQL\data\modules\viagra.dll"
+ SetOutPath "$INSTDIR\data\modules\runtime"
+ SetOutPath "$INSTDIR\data"
+ File "anope-1.8.0-MySQL\data\tables.sql"
+ SetOutPath "$INSTDIR\docs"
+ File "anope-1.8.0-MySQL\docs\BUGS.txt"
+ File "anope-1.8.0-MySQL\docs\COPYING.txt"
+ File "anope-1.8.0-MySQL\docs\DEFCON.txt"
+ File "anope-1.8.0-MySQL\docs\EVENTS.txt"
+ File "anope-1.8.0-MySQL\docs\FAQ.txt"
+ File "anope-1.8.0-MySQL\docs\INSTALL.txt"
+ File "anope-1.8.0-MySQL\docs\IRCD.txt"
+ File "anope-1.8.0-MySQL\docs\MODULES.txt"
+ File "anope-1.8.0-MySQL\docs\MYSQL.txt"
+ File "anope-1.8.0-MySQL\docs\NEWS.txt"
+ File "anope-1.8.0-MySQL\docs\OLDNEWS.txt"
+ File "anope-1.8.0-MySQL\docs\OLDCHANGES.txt"
+ File "anope-1.8.0-MySQL\docs\PROXY.txt"
+ File "anope-1.8.0-MySQL\docs\README.txt"
+ File "anope-1.8.0-MySQL\docs\WIN32.txt"
+SectionEnd
+
+Section -AdditionalIcons
+ SetOutPath $INSTDIR
+ WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
+ CreateShortCut "$SMPROGRAMS\Anope\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
+ CreateShortCut "$SMPROGRAMS\Anope\Uninstall.lnk" "$INSTDIR\uninst.exe"
+SectionEnd
+
+Section -Post
+ WriteUninstaller "$INSTDIR\uninst.exe"
+ WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\anope.exe"
+ WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
+ WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
+ WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\anope.exe"
+ WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
+ WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
+ WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
+SectionEnd
+
+
+Function un.onUninstSuccess
+ HideWindow
+ MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer."
+FunctionEnd
+
+Function un.onInit
+!insertmacro MUI_UNGETLANGUAGE
+ MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2
+ Abort
+FunctionEnd
+
+Section Uninstall
+ Delete "$INSTDIR\${PRODUCT_NAME}.url"
+ Delete "$INSTDIR\uninst.exe"
+ Delete "$INSTDIR\docs\WIN32.txt"
+ Delete "$INSTDIR\docs\README.txt"
+ Delete "$INSTDIR\docs\PROXY.txt"
+ Delete "$INSTDIR\docs\OLDCHANGES.txt"
+ Delete "$INSTDIR\docs\OLDNEWS.txt"
+ Delete "$INSTDIR\docs\NEWS.txt"
+ Delete "$INSTDIR\docs\MYSQL.txt"
+ Delete "$INSTDIR\docs\MODULES.txt"
+ Delete "$INSTDIR\docs\IRCD.txt"
+ Delete "$INSTDIR\docs\INSTALL.txt"
+ Delete "$INSTDIR\docs\FAQ.txt"
+ Delete "$INSTDIR\docs\EVENTS.txt"
+ Delete "$INSTDIR\docs\DEFCON.txt"
+ Delete "$INSTDIR\docs\COPYING.txt"
+ Delete "$INSTDIR\docs\BUGS.txt"
+ Delete "$INSTDIR\data\tables.sql"
+ Delete "$INSTDIR\data\modules\viagra.dll"
+ Delete "$INSTDIR\data\modules\unreal32.dll"
+ Delete "$INSTDIR\data\modules\unreal31.dll"
+ Delete "$INSTDIR\data\modules\ultimate3.dll"
+ Delete "$INSTDIR\data\modules\ultimate2.dll"
+ Delete "$INSTDIR\data\modules\solidircd.dll"
+ Delete "$INSTDIR\data\modules\shadowircd.dll"
+ Delete "$INSTDIR\data\modules\ratbox.dll"
+ Delete "$INSTDIR\data\modules\rageircd.dll"
+ Delete "$INSTDIR\data\modules\ptlink.dll"
+ Delete "$INSTDIR\data\modules\plexus3.dll"
+ Delete "$INSTDIR\data\modules\plexus2.dll"
+ Delete "$INSTDIR\data\modules\os_userlist.dll"
+ Delete "$INSTDIR\data\modules\os_update.dll"
+ Delete "$INSTDIR\data\modules\os_umode.dll"
+ Delete "$INSTDIR\data\modules\os_szline.dll"
+ Delete "$INSTDIR\data\modules\os_svsnick.dll"
+ Delete "$INSTDIR\data\modules\os_stats.dll"
+ Delete "$INSTDIR\data\modules\os_staff.dll"
+ Delete "$INSTDIR\data\modules\os_sqline.dll"
+ Delete "$INSTDIR\data\modules\os_shutdown.dll"
+ Delete "$INSTDIR\data\modules\os_sgline.dll"
+ Delete "$INSTDIR\data\modules\os_set.dll"
+ Delete "$INSTDIR\data\modules\os_session.dll"
+ Delete "$INSTDIR\data\modules\os_restart.dll"
+ Delete "$INSTDIR\data\modules\os_reload.dll"
+ Delete "$INSTDIR\data\modules\os_raw.dll"
+ Delete "$INSTDIR\data\modules\os_randomnews.dll"
+ Delete "$INSTDIR\data\modules\os_quit.dll"
+ Delete "$INSTDIR\data\modules\os_opernews.dll"
+ Delete "$INSTDIR\data\modules\os_oper.dll"
+ Delete "$INSTDIR\data\modules\os_oline.dll"
+ Delete "$INSTDIR\data\modules\os_noop.dll"
+ Delete "$INSTDIR\data\modules\os_modunload.dll"
+ Delete "$INSTDIR\data\modules\os_modload.dll"
+ Delete "$INSTDIR\data\modules\os_modlist.dll"
+ Delete "$INSTDIR\data\modules\os_modinfo.dll"
+ Delete "$INSTDIR\data\modules\os_mode.dll"
+ Delete "$INSTDIR\data\modules\os_logonnews.dll"
+ Delete "$INSTDIR\data\modules\os_kick.dll"
+ Delete "$INSTDIR\data\modules\os_jupe.dll"
+ Delete "$INSTDIR\data\modules\os_info.dll"
+ Delete "$INSTDIR\data\modules\os_ignore.dll"
+ Delete "$INSTDIR\data\modules\os_help.dll"
+ Delete "$INSTDIR\data\modules\os_global.dll"
+ Delete "$INSTDIR\data\modules\os_defcon.dll"
+ Delete "$INSTDIR\data\modules\os_clearmodes.dll"
+ Delete "$INSTDIR\data\modules\os_chanlist.dll"
+ Delete "$INSTDIR\data\modules\os_chankill.dll"
+ Delete "$INSTDIR\data\modules\os_akill.dll"
+ Delete "$INSTDIR\data\modules\os_admin.dll"
+ Delete "$INSTDIR\data\modules\ns_update.dll"
+ Delete "$INSTDIR\data\modules\ns_suspend.dll"
+ Delete "$INSTDIR\data\modules\ns_status.dll"
+ Delete "$INSTDIR\data\modules\ns_set.dll"
+ Delete "$INSTDIR\data\modules\ns_sendpass.dll"
+ Delete "$INSTDIR\data\modules\ns_saset.dll"
+ Delete "$INSTDIR\data\modules\ns_release.dll"
+ Delete "$INSTDIR\data\modules\ns_register.dll"
+ Delete "$INSTDIR\data\modules\ns_recover.dll"
+ Delete "$INSTDIR\data\modules\ns_maxemail.dll"
+ Delete "$INSTDIR\data\modules\ns_logout.dll"
+ Delete "$INSTDIR\data\modules\ns_list.dll"
+ Delete "$INSTDIR\data\modules\ns_info.dll"
+ Delete "$INSTDIR\data\modules\ns_identify.dll"
+ Delete "$INSTDIR\data\modules\ns_help.dll"
+ Delete "$INSTDIR\data\modules\ns_group.dll"
+ Delete "$INSTDIR\data\modules\ns_ghost.dll"
+ Delete "$INSTDIR\data\modules\ns_getpass.dll"
+ Delete "$INSTDIR\data\modules\ns_getemail.dll"
+ Delete "$INSTDIR\data\modules\ns_forbid.dll"
+ Delete "$INSTDIR\data\modules\ns_drop.dll"
+ Delete "$INSTDIR\data\modules\ns_alist.dll"
+ Delete "$INSTDIR\data\modules\ns_access.dll"
+ Delete "$INSTDIR\data\modules\ms_staff.dll"
+ Delete "$INSTDIR\data\modules\ms_set.dll"
+ Delete "$INSTDIR\data\modules\ms_sendall.dll"
+ Delete "$INSTDIR\data\modules\ms_send.dll"
+ Delete "$INSTDIR\data\modules\ms_rsend.dll"
+ Delete "$INSTDIR\data\modules\ms_read.dll"
+ Delete "$INSTDIR\data\modules\ms_list.dll"
+ Delete "$INSTDIR\data\modules\ms_info.dll"
+ Delete "$INSTDIR\data\modules\ms_help.dll"
+ Delete "$INSTDIR\data\modules\ms_del.dll"
+ Delete "$INSTDIR\data\modules\ms_check.dll"
+ Delete "$INSTDIR\data\modules\ms_cancel.dll"
+ Delete "$INSTDIR\data\modules\inspircd11.dll"
+ Delete "$INSTDIR\data\modules\inspircd10.dll"
+ Delete "$INSTDIR\data\modules\hybrid.dll"
+ Delete "$INSTDIR\data\modules\hs_setall.dll"
+ Delete "$INSTDIR\data\modules\hs_set.dll"
+ Delete "$INSTDIR\data\modules\hs_request.dll"
+ Delete "$INSTDIR\data\modules\hs_on.dll"
+ Delete "$INSTDIR\data\modules\hs_off.dll"
+ Delete "$INSTDIR\data\modules\hs_list.dll"
+ Delete "$INSTDIR\data\modules\hs_help.dll"
+ Delete "$INSTDIR\data\modules\hs_group.dll"
+ Delete "$INSTDIR\data\modules\hs_delall.dll"
+ Delete "$INSTDIR\data\modules\hs_del.dll"
+ Delete "$INSTDIR\data\modules\he_help.dll"
+ Delete "$INSTDIR\data\modules\enc_old.dll"
+ Delete "$INSTDIR\data\modules\enc_none.dll"
+ Delete "$INSTDIR\data\modules\enc_md5.dll"
+ Delete "$INSTDIR\data\modules\enc_sha1.dll"
+ Delete "$INSTDIR\data\modules\dreamforge.dll"
+ Delete "$INSTDIR\data\modules\cs_xop.dll"
+ Delete "$INSTDIR\data\modules\cs_topic.dll"
+ Delete "$INSTDIR\data\modules\cs_tban.dll"
+ Delete "$INSTDIR\data\modules\cs_suspend.dll"
+ Delete "$INSTDIR\data\modules\cs_status.dll"
+ Delete "$INSTDIR\data\modules\cs_set.dll"
+ Delete "$INSTDIR\data\modules\cs_sendpass.dll"
+ Delete "$INSTDIR\data\modules\cs_register.dll"
+ Delete "$INSTDIR\data\modules\cs_modes.dll"
+ Delete "$INSTDIR\data\modules\cs_logout.dll"
+ Delete "$INSTDIR\data\modules\cs_list.dll"
+ Delete "$INSTDIR\data\modules\cs_kick.dll"
+ Delete "$INSTDIR\data\modules\cs_invite.dll"
+ Delete "$INSTDIR\data\modules\cs_info.dll"
+ Delete "$INSTDIR\data\modules\cs_identify.dll"
+ Delete "$INSTDIR\data\modules\cs_help.dll"
+ Delete "$INSTDIR\data\modules\cs_getpass.dll"
+ Delete "$INSTDIR\data\modules\cs_getkey.dll"
+ Delete "$INSTDIR\data\modules\cs_forbid.dll"
+ Delete "$INSTDIR\data\modules\cs_enforce.dll"
+ Delete "$INSTDIR\data\modules\cs_drop.dll"
+ Delete "$INSTDIR\data\modules\cs_clear.dll"
+ Delete "$INSTDIR\data\modules\cs_ban.dll"
+ Delete "$INSTDIR\data\modules\cs_appendtopic.dll"
+ Delete "$INSTDIR\data\modules\cs_akick.dll"
+ Delete "$INSTDIR\data\modules\cs_access.dll"
+ Delete "$INSTDIR\data\modules\charybdis.dll"
+ Delete "$INSTDIR\data\modules\bs_unassign.dll"
+ Delete "$INSTDIR\data\modules\bs_set.dll"
+ Delete "$INSTDIR\data\modules\bs_say.dll"
+ Delete "$INSTDIR\data\modules\bs_kick.dll"
+ Delete "$INSTDIR\data\modules\bs_info.dll"
+ Delete "$INSTDIR\data\modules\bs_help.dll"
+ Delete "$INSTDIR\data\modules\bs_fantasy_unban.dll"
+ Delete "$INSTDIR\data\modules\bs_fantasy_seen.dll"
+ Delete "$INSTDIR\data\modules\bs_fantasy_owner.dll"
+ Delete "$INSTDIR\data\modules\bs_fantasy_kickban.dll"
+ Delete "$INSTDIR\data\modules\bs_fantasy_kick.dll"
+ Delete "$INSTDIR\data\modules\bs_fantasy.dll"
+ Delete "$INSTDIR\data\modules\bs_botlist.dll"
+ Delete "$INSTDIR\data\modules\bs_bot.dll"
+ Delete "$INSTDIR\data\modules\bs_badwords.dll"
+ Delete "$INSTDIR\data\modules\bs_assign.dll"
+ Delete "$INSTDIR\data\modules\bs_act.dll"
+ Delete "$INSTDIR\data\modules\bahamut.dll"
+ Delete "$INSTDIR\data\languages\tr"
+ Delete "$INSTDIR\data\languages\ru"
+ Delete "$INSTDIR\data\languages\pt"
+ Delete "$INSTDIR\data\languages\pl"
+ Delete "$INSTDIR\data\languages\nl"
+ Delete "$INSTDIR\data\languages\it"
+ Delete "$INSTDIR\data\languages\hun"
+ Delete "$INSTDIR\data\languages\gr"
+ Delete "$INSTDIR\data\languages\fr"
+ Delete "$INSTDIR\data\languages\es"
+ Delete "$INSTDIR\data\languages\en_us"
+ Delete "$INSTDIR\data\languages\de"
+ Delete "$INSTDIR\data\languages\cat"
+ Delete "$INSTDIR\data\example.conf"
+ Delete "$INSTDIR\data\epona2anope.exe.manifest"
+ Delete "$INSTDIR\data\epona2anope.exe"
+ Delete "$INSTDIR\data\db-merger.exe.manifest"
+ Delete "$INSTDIR\data\db-merger.exe"
+ Delete "$INSTDIR\data\bin\register"
+ Delete "$INSTDIR\data\bin\mydbgen"
+ Delete "$INSTDIR\data\bin\langtool"
+ Delete "$INSTDIR\data\bin\cp-recursive"
+ Delete "$INSTDIR\data\bin\anoperc.in"
+ Delete "$INSTDIR\data\bin\am"
+ Delete "$INSTDIR\data\anopesmtp.exe.manifest"
+ Delete "$INSTDIR\data\anopesmtp.exe"
+ Delete "$INSTDIR\Changes.txt"
+ Delete "$INSTDIR\Changes.mysql.txt"
+ Delete "$INSTDIR\Changes.lang.txt"
+ Delete "$INSTDIR\Changes.conf.txt"
+ Delete "$INSTDIR\anope.exe.manifest"
+ Delete "$INSTDIR\anope.exe"
+Delete "$INSTDIR\anope.bat"
+ SetShellVarContext all
+
+ Delete "$SMPROGRAMS\Anope\Uninstall.lnk"
+ Delete "$SMPROGRAMS\Anope\Website.lnk"
+ Delete "$DESKTOP\Anope IRC Services.lnk"
+ Delete "$SMPROGRAMS\Anope\Anope IRC Services.lnk"
+ Delete "$SMPROGRAMS\Anope\Advanced\Anope IRC Services (Debug and Window Logging).lnk"
+ Delete "$SMPROGRAMS\Anope\Advanced\Anope IRC Services (Window Logging).lnk"
+ Delete "$SMPROGRAMS\Anope\Advanced\Anope IRC Services (No Third Party Modules).lnk"
+
+RMDir "$SMPROGRAMS\Anope\Advanced"
+
+ RMDir "$SMPROGRAMS\Anope"
+ RMDir "$INSTDIR\docs"
+ RMDir "$INSTDIR\data\modules"
+ RMDir "$INSTDIR\data\logs"
+ RMDir "$INSTDIR\data\languages"
+ RMDir "$INSTDIR\data\bin"
+RMDir "$INSTDIR\data\backups"
+ RMDir "$INSTDIR\data"
+ RMDir "$INSTDIR"
+
+ DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
+ DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
+ SetAutoClose true
+SectionEnd
\ No newline at end of file diff --git a/src/tools/Makefile b/src/tools/Makefile new file mode 100644 index 000000000..c0aa9fb85 --- /dev/null +++ b/src/tools/Makefile @@ -0,0 +1,39 @@ +SRCS = anopesmtp.c db-merger.c epona2anope.c +OBJS = $(SRCS:.c=.o) + +INCLUDES = ../../include/services.h + +MAKEARGS = 'CFLAGS=${CFLAGS}' 'CC=${CC}' 'ANOPELIBS=${ANOPELIBS}' \ + 'LDFLAGS=${LDFLAGS}' 'BINDEST=${BINDEST}' 'INSTALL=${INSTALL}' \ + 'INCLUDEDIR=${INCLUDEDIR}' 'RM=${RM}' 'CP=${CP}' \ + 'TOUCH=${TOUCH}' 'SHELL=${SHELL}' 'DATDEST=${DATDEST}' \ + 'RUNGROUP=${RUNGROUP}' + +.c.o: + $(CC) $(CFLAGS) -I../include/ -c $< + +all: ${OBJS} + +distclean: spotless + +anopesmpt: $(OBJS) + $(CC) $(CFLAGS) $(OBJS) $(ANOPELIBS) $(MLIBS) -o $@ $(LDFLAGS) + +$(OBJS): Makefile +anopesmtp.o: anopesmtp.c $(INCLUDES) +db-merger.o: db-merger.c $(INCLUDES) +epona2anope.o: epona2anope.c $(INCLUDES) + +clean: + rm -f *.o anopesmtp a.out db-merger epona2anope + +spotless: clean + +install: anopesmtp db-merger epona2anope + test -d ${BINDEST} || mkdir ${BINDEST} + test -d $(BINDEST)/tools || mkdir $(BINDEST)/tools + $(INSTALL) anopesmtp $(BINDEST)/tools/anopesmtp + $(INSTALL) db-merger $(BINDEST)/tools/db-merger + $(INSTALL) epona2anope $(BINDEST)/tools/epona2anope + +DUMMY: diff --git a/src/tools/Makefile.win32 b/src/tools/Makefile.win32 new file mode 100644 index 000000000..77e7f2c91 --- /dev/null +++ b/src/tools/Makefile.win32 @@ -0,0 +1,29 @@ +include ../../Makefile.inc.win32
+
+SRCS=anopesmtp.c epona2anope.c db-merger.c
+OBJECTS= $(SRCS:.c=.exe)
+CFLAGS=$(CFLAGS) /I"../../include"
+LFLAGS=/link wsock32.lib $(LIBS) $(LFLAGS)
+
+all: $(OBJECTS)
+
+distclean: clean spotless
+
+.c.exe:
+ $(CC) $(CFLAGS) $< $(LFLAGS)
+
+clean:
+ -@del *.obj
+
+spotless: clean
+ -@del *.exe *.lib *.exp
+
+install: exe_install manifest_install
+
+exe_install: FRC
+ -@copy *.exe ..\..\$(DATDEST)\
+
+manifest_install: FRC
+ -@copy *.manifest ..\..\$(DATDEST)\
+
+FRC:
diff --git a/src/tools/README b/src/tools/README new file mode 100644 index 000000000..3acb80ad2 --- /dev/null +++ b/src/tools/README @@ -0,0 +1,58 @@ +Anope Bundled Tools +------------------- + +1) Anope SMTP Client +2) Anope Database Merger +3) Epona to Anope Database Converter + +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 "tools/anopesmtp" and the IP address of a valid SMTP server. It + should look like this: + + SendMailPath "/home/anope/services/tools/anopesmtp 127.0.0.1" + + If the SMTP client doesn't send mail, or if there's an other problem with + it, you can compile it in debug mode. To do this, open smtp.h, and look + for "smtp_debug" near the bottom. Change this from 0 to 1 and recompile + the code. 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> + +2) Anope Database Merger + + This program tries to merge two standard Anope database sets (ChanServ, + NickServ, BotServ, and MemoServ). + + To merge two database sets, put them both in the folder where the merger + is located. The first database set must be named <name>1.db (nick1.db, + chan1.db, etc); the second database set must be named <name>2.db (nick2.db, + chan2.db, etc). If you execute the merger now the databases will be merged + into databases named <name>.db. + + Credits: + Written by Florian Schulze <certus@anope.org> + +3) Epona to Anope Database Converter + + This program tries to convert databases made by epona .4.15 and up to + standard anope databases. Currently, only the ChanServ database needs to + be converted. + + Put your Epona (ChanServ) database in the folder where the epona2anope + executable file is located. Rename this ChanServ database file to + chan1.db and then run the converter (epona2anope). A new database called + chan.db will be created; this file is Anope-compatible. + + Credits: + Written by Florian Schulze <certus@anope.org> diff --git a/src/tools/anopesmtp.c b/src/tools/anopesmtp.c new file mode 100644 index 000000000..4ff0c6fcf --- /dev/null +++ b/src/tools/anopesmtp.c @@ -0,0 +1,604 @@ +/* smtp stuff handler for win32. + * + * (C) 2003-2008 Anope Team + * Contact us at info@anope.org + * + * Please read COPYING and README for furhter details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + * + * Written by Dominick Meglio <codemastr@unrealircd.com> + * *nix port by Trystan Scott Lee <trystan@nomadirc.net> + * + */ + +#include "smtp.h" + +static FILE *logfile; +static int curday = 0; + +/*************************************************************************/ + +#ifdef _WIN32 +int strcasecmp(const char *s1, const char *s2) +{ + register int c; + + while ((c = tolower(*s1)) == tolower(*s2)) { + if (c == 0) + return 0; + s1++; + s2++; + } + if (c < tolower(*s2)) + return -1; + return 1; +} +#endif + +static int get_logname(char *name, int count, struct tm *tm) +{ + + char timestamp[32]; + + if (!tm) { + time_t t; + + time(&t); + tm = localtime(&t); + } + + strftime(timestamp, count, "%Y%m%d", tm); + snprintf(name, count, "logs/%s.%s", "anopesmtp", timestamp); + curday = tm->tm_yday; + + return 1; +} + +/*************************************************************************/ + +/* Close the log file. */ + +void close_log(void) +{ + if (!logfile) + return; + fclose(logfile); + logfile = NULL; +} + +/*************************************************************************/ + +static void remove_log(void) +{ + time_t t; + struct tm tm; + + char name[PATH_MAX]; + + time(&t); + t -= (60 * 60 * 24 * 30); + tm = *localtime(&t); + + if (!get_logname(name, sizeof(name), &tm)) + return; + unlink(name); +} + +/*************************************************************************/ + +/* Open the log file. Return -1 if the log file could not be opened, else + * return 0. */ + +int open_log(void) +{ + char name[PATH_MAX]; + + if (logfile) + return 0; + + if (!get_logname(name, sizeof(name), NULL)) + return 0; + logfile = fopen(name, "a"); + + if (logfile) + setbuf(logfile, NULL); + return logfile != NULL ? 0 : -1; +} + +/*************************************************************************/ + +static void checkday(void) +{ + time_t t; + struct tm tm; + + time(&t); + tm = *localtime(&t); + + if (curday != tm.tm_yday) { + close_log(); + remove_log(); + open_log(); + } +} + +/*************************************************************************/ + +/* 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, ...) +{ + va_list args; + time_t t; + struct tm tm; + char buf[256]; + int errno_save = errno; + + if (!smtp_debug) { + return; + } + + checkday(); + + if (!fmt) { + return; + } + + va_start(args, fmt); + time(&t); + tm = *localtime(&t); + strftime(buf, sizeof(buf) - 1, "[%b %d %H:%M:%S %Y] ", &tm); + if (logfile && args) { + fputs(buf, logfile); + vfprintf(logfile, fmt, args); + fputc('\n', logfile); + } + va_end(args); + errno = errno_save; +} + +/*************************************************************************/ + +/* Remove a trailing \r\n */ +char *strip(char *buf) +{ + char *c; + if ((c = strchr(buf, '\n'))) + *c = 0; + if ((c = strchr(buf, '\r'))) + *c = 0; + return buf; +} + +/*************************************************************************/ + +/* Convert a trailing \n to \r\n + * The caller must free the allocated memory + */ +char *lftocrlf(char *buf) +{ + char *result = malloc(strlen(buf) + 2); + strip(buf); + strcpy(result, buf); + strcat(result, "\r\n"); + return result; +} + +/*************************************************************************/ + +/* Add a header to the list */ +void smtp_add_header(char *header) +{ + struct smtp_header *head = malloc(sizeof(struct smtp_header)); + + head->header = lftocrlf(header); + head->next = NULL; + + if (!mail.smtp_headers) { + mail.smtp_headers = head; + } + if (mail.smtp_headers_tail) { + mail.smtp_headers_tail->next = head; + } + mail.smtp_headers_tail = head; +} + +/*************************************************************************/ + +/* Is the buffer a header? */ +int smtp_is_header(char *buf) +{ + char *tmp = strchr(buf, ' '); + + if (!tmp) + return 0; + + if (*(tmp - 1) == ':') + return 1; + return 0; +} + +/*************************************************************************/ + +/* Parse a header into a name and value */ +void smtp_parse_header(char *buf, char **header, char **value) +{ + strip(buf); + + *header = strtok(buf, " "); + *value = strtok(NULL, ""); + if (*header) + (*header)[strlen(*header) - 1] = 0; +} + +/*************************************************************************/ + +/* Have we reached the end of input? */ +int smtp_is_end(char *buf) +{ + if (*buf == '.') + if (*(buf + 1) == '\r' || *(buf + 1) == '\n') + return 1; + + return 0; +} + +/*************************************************************************/ + +/* Set who the email is from */ +void smtp_set_from(char *from) +{ + mail.from = strdup(from); +} + +/*************************************************************************/ + +/* Set who the email is to */ +void smtp_set_to(char *to) +{ + char *c; + + if ((c = strrchr(to, '<')) && *(c + 1)) { + to = c + 1; + to[strlen(to) - 1] = 0; + } + mail.to = strdup(to); +} + +/*************************************************************************/ + +/* Add a line of body text */ +void smtp_add_body_line(char *line) +{ + struct smtp_body_line *body; + + body = malloc(sizeof(struct smtp_body_line)); + + body->line = lftocrlf(line); + body->next = NULL; + + if (!mail.smtp_body) + mail.smtp_body = body; + if (mail.smtp_body_tail) + mail.smtp_body_tail->next = body; + mail.smtp_body_tail = body; + +} + +/*************************************************************************/ + +/* Establish a connection to the SMTP server */ +int smtp_connect(char *host, unsigned short port) +{ + struct sockaddr_in addr; + + if ((mail.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(mail.sock, (struct sockaddr *) &addr, sizeof(struct sockaddr_in)) == SOCKET_ERROR) { + ano_sockclose(mail.sock); + return 0; + } + + return 1; +} + +/*************************************************************************/ + +/* Send a line of text */ +int smtp_send(char *text) +{ + int result = ano_sockwrite(mail.sock, text, strlen(text)); + + alog("SMTP: sent %s",text); + + if (result == SOCKET_ERROR) + ano_sockclose(mail.sock); + + return result; +} + +/*************************************************************************/ + +/* Read a line of text */ +int smtp_read(char *buf, int len) +{ + int result; + + memset(buf, 0, len); + result = ano_sockread(mail.sock, buf, len); + + if (result == SOCKET_ERROR) + ano_sockclose(mail.sock); + + return result; +} + +/*************************************************************************/ + +/* Retrieve a response code */ +int smtp_get_code(char *text) +{ + char *tmp = strtok(text, " "); + + if (!tmp) + return 0; + + return atol(tmp); +} + +/*************************************************************************/ + +/* Send the email */ +int smtp_send_email() +{ + char buf[1024]; + struct smtp_header *head; + struct smtp_body_line *body; + int code; + int skip_done = 0; + + if (!smtp_read(buf, 1024)) { + alog("SMTP: error reading buffer"); + return 0; + } + + 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 writting 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, mail.from); + strcat(buf, ">\r\n"); + + if (!smtp_send(buf)) { + alog("SMTP: error writting 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, mail.to); + strcat(buf, ">\r\n"); + + if (!smtp_send(buf)) { + alog("SMTP: error writting 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 writting 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 (head = mail.smtp_headers; head; head = head->next) { + if (!smtp_send(head->header)) { + alog("SMTP: error writting to socket"); + return 0; + } + } + + if (!smtp_send("\r\n")) { + alog("SMTP: error writting to socket"); + return 0; + } + + for (body = mail.smtp_body; body; body = body->next) { + if (skip_done) { + if (!smtp_send(body->line)) { + alog("SMTP: error writting to socket"); + return 0; + } + } else { + skip_done = 1; + } + } + + if (!smtp_send("\r\n.\r\n")) { + alog("SMTP: error writting to socket"); + return 0; + } + + return 1; +} + +/*************************************************************************/ + +void smtp_disconnect() +{ + smtp_send("QUIT\r\n"); + ano_sockclose(mail.sock); +} + +/*************************************************************************/ + +void mail_cleanup() +{ + struct smtp_header *headers, *nexth; + struct smtp_body_line *body, *nextb; + + if (mail.from) + free(mail.from); + if (mail.to) + free(mail.to); + + headers = mail.smtp_headers; + while (headers) { + nexth = headers->next; + free(headers->header); + free(headers); + headers = nexth; + } + + body = mail.smtp_body; + while (body) { + nextb = body->next; + free(body->line); + free(body); + body = nextb; + } +} + +/*************************************************************************/ + +int main(int argc, char *argv[]) +{ + char buf[8192]; +/* These are somehow unused - why are they here? -GD + + struct smtp_body_line *b; + struct smtp_header *h; +*/ + int headers_done = 0; +/* Win32 stuff */ +#ifdef _WIN32 + WSADATA wsa; +#endif + char *server, *aport; + short port; + + if (argc == 1) + return 0; + + server = strtok(argv[1], ":"); + if ((aport = strtok(NULL, ""))) { + port = atoi(aport); + } else { + port = 25; + } + + if (!server) { + alog("No Server"); + /* Bad, bad, bad. This was a eturn from main with no value! -GD */ + return 0; + } else { + alog("SMTP: server %s port %d",server,port); + } + + memset(&mail, 0, sizeof(mail)); + +/* 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) != 0) + return 0; +#endif + + /* Read the message and parse it */ + while (fgets(buf, 8192, stdin)) { + if (smtp_is_header(buf) && !headers_done) { + char *header, *value; + smtp_add_header(buf); + smtp_parse_header(buf, &header, &value); + if (!strcasecmp(header, "from")) { + alog("SMTP: from: %s",value); + smtp_set_from(value); + } else if (!strcasecmp(header, "to")) { + alog("SMTP: to: %s",value); + smtp_set_to(value); + } else if (smtp_is_end(buf)) { + break; + } else { + headers_done = 1; + smtp_add_body_line(buf); + } + } else { + smtp_add_body_line(buf); + } + } + + if (!smtp_connect(server, port)) { + alog("SMTP: failed to connect to %s:%d",server, port); + mail_cleanup(); + return 0; + } + if (!smtp_send_email()) { + alog("SMTP: error during sending of mail"); + mail_cleanup(); + return 0; + } + smtp_disconnect(); + mail_cleanup(); + + return 1; +} diff --git a/src/tools/db-merger.c b/src/tools/db-merger.c new file mode 100644 index 000000000..b44e5b9d0 --- /dev/null +++ b/src/tools/db-merger.c @@ -0,0 +1,2031 @@ +/* + * Anope Database Merger + * (C) 2003-2008 Anope Team + * Contact us at info@anope.org + * + * Please read COPYING and README for furhter details. + * + ***** + * + * Based on the original IRC, db-merger.c + * (C) Copyright 2005-2006, Florian Schulze (Certus) + * Based on the original code of Anope, (C) 2003-2005 Anope Team + * + */ + +/* + * Known issues: + * - When merging it is possible that ownership of a channel is transferred + * to another nickgroup if the founder's main nick is dropped and granted + * to another user in the other database. This user will then become + * founder of the channel. + * + * - The count of channels a nickgroup has registered is not recalculated + * after the merge. This means that if a channel was dropped, the owner may + * have an incorrect counter and may sooner reach the maximum number of + * allowed registered channels. + * + * Ideally, this should be rewritten from scratch to only merge after both + * database sets are fully loaded, however since we will be migrating to + * another database architecture, this is unlikely to be done for the + * current "stable" DB architecture. + * + * ~ Viper + */ + +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <fcntl.h> +#include <ctype.h> +#include <time.h> + +#ifndef _WIN32 +#include <unistd.h> +#else +#include "sysconf.h" +#include <windows.h> +#endif + +/* Some SUN fixs */ +#ifdef __sun +/* Solaris specific code, types that do not exist in Solaris' + * sys/types.h + **/ +#undef u_int8_t +#undef u_int16_t +#undef u_int32_t +#undef u_int_64_t +#define u_int8_t uint8_t +#define u_int16_t uint16_t +#define u_int32_t uint32_t +#define u_int64_t uint64_t + +#ifndef INADDR_NONE +#define INADDR_NONE (-1) +#endif + +#endif + + +/* CONFIGURATION BLOCK */ + +#define NICK_DB_1 "nick1.db" +#define NICK_DB_2 "nick2.db" +#define NICK_DB_NEW "nick.db" + +#define CHAN_DB_1 "chan1.db" +#define CHAN_DB_2 "chan2.db" +#define CHAN_DB_NEW "chan.db" + +#define BOT_DB_1 "bot1.db" +#define BOT_DB_2 "bot2.db" +#define BOT_DB_NEW "bot.db" + +#define HOST_DB_1 "hosts1.db" +#define HOST_DB_2 "hosts2.db" +#define HOST_DB_NEW "hosts.db" + +/* END OF CONFIGURATION BLOCK */ + +#ifndef _WIN32 +#define C_LBLUE "\033[1;34m" +#define C_NONE "\033[m" +#else +#define C_LBLUE "" +#define C_NONE "" +#endif + +#define getc_db(f) (fgetc((f)->fp)) +#define HASH(nick) ((tolower((nick)[0])&31)<<5 | (tolower((nick)[1])&31)) +#define HASH2(chan) ((chan)[1] ? ((chan)[1]&31)<<5 | ((chan)[2]&31) : 0) +#define read_buffer(buf,f) (read_db((f),(buf),sizeof(buf)) == sizeof(buf)) +#define write_buffer(buf,f) (write_db((f),(buf),sizeof(buf)) == sizeof(buf)) +#define read_db(f,buf,len) (fread((buf),1,(len),(f)->fp)) +#define write_db(f,buf,len) (fwrite((buf),1,(len),(f)->fp)) +#define read_int8(ret,f) ((*(ret)=fgetc((f)->fp))==EOF ? -1 : 0) +#define write_int8(val,f) (fputc((val),(f)->fp)==EOF ? -1 : 0) +#define SAFE(x) do { \ + if ((x) < 0) { \ + printf("Error, the database is broken, trying to continue... no guarantee.\n"); \ + } \ +} while (0) +#define READ(x) do { \ + if ((x) < 0) { \ + printf("Error, the database is broken, trying to continue... no guarantee.\n"); \ + exit(0); \ + } \ +} while (0) + +typedef int16_t int16; +typedef u_int16_t uint16; +typedef int32_t int32; +typedef u_int32_t uint32; +typedef struct memo_ Memo; +typedef struct dbFILE_ dbFILE; +typedef struct nickalias_ NickAlias; +typedef struct nickcore_ NickCore; +typedef struct chaninfo_ ChannelInfo; +typedef struct botinfo_ BotInfo; +typedef struct badword_ BadWord; +typedef struct hostcore_ HostCore; + +struct memo_ { + uint32 number; /* Index number -- not necessarily array position! */ + uint16 flags; /* Flags */ + time_t time; /* When was it sent? */ + char sender[32]; /* Name of the sender */ + char *text; +}; + +struct dbFILE_ { + int mode; /* 'r' for reading, 'w' for writing */ + FILE *fp; /* The normal file descriptor */ + char filename[1024]; /* Name of the database file */ +}; + +typedef struct { + int16 memocount; /* Current # of memos */ + int16 memomax; /* Max # of memos one can hold*/ + Memo *memos; /* Pointer to original memos */ +} MemoInfo; + +typedef struct { + uint16 in_use; /* 1 if this entry is in use, else 0 */ + int16 level; + NickCore *nc; /* Guaranteed to be non-NULL if in use, NULL if not */ + time_t last_seen; +} ChanAccess; + +typedef struct { + int16 in_use; /* Always 0 if not in use */ + int16 is_nick; /* 1 if a regged nickname, 0 if a nick!user@host mask */ + uint16 flags; + union { + char *mask; /* Guaranteed to be non-NULL if in use, NULL if not */ + NickCore *nc; /* Same */ + } u; + char *reason; + char *creator; + time_t addtime; +} AutoKick; + +struct nickalias_ { + NickAlias *next, *prev; + char *nick; /* Nickname */ + char *last_quit; /* Last quit message */ + char *last_realname; /* Last realname */ + char *last_usermask; /* Last usermask */ + time_t time_registered; /* When the nick was registered */ + time_t last_seen; /* When it was seen online for the last time */ + uint16 status; /* See NS_* below */ + NickCore *nc; /* I'm an alias of this */ +}; + +struct nickcore_ { + NickCore *next, *prev; + + char *display; /* How the nick is displayed */ + char pass[32]; /* Password of the nicks */ + char *email; /* E-mail associated to the nick */ + char *greet; /* Greet associated to the nick */ + uint32 icq; /* ICQ # associated to the nick */ + char *url; /* URL associated to the nick */ + uint32 flags; /* See NI_* below */ + uint16 language; /* Language selected by nickname owner (LANG_*) */ + uint16 accesscount; /* # of entries */ + char **access; /* Array of strings */ + MemoInfo memos; /* Memo information */ + uint16 channelcount; /* Number of channels currently registered */ + uint16 channelmax; /* Maximum number of channels allowed */ + int unused; /* Used for nick collisions */ + int aliascount; /* How many aliases link to us? Remove the core if 0 */ +}; + +struct chaninfo_ { + ChannelInfo *next, *prev; + + char name[64]; /* Channel name */ + char *founder; /* Who registered the channel */ + char *successor; /* Who gets the channel if the founder nick is dropped or expires */ + char founderpass[32]; /* Channel password */ + char *desc; /* Description */ + char *url; /* URL */ + char *email; /* Email address */ + time_t time_registered; /* When was it registered */ + time_t last_used; /* When was it used hte last time */ + char *last_topic; /* Last topic on the channel */ + char last_topic_setter[32]; /* Who set the last topic */ + time_t last_topic_time; /* When the last topic was set */ + uint32 flags; /* Flags */ + char *forbidby; /* if forbidden: who did it */ + char *forbidreason; /* if forbidden: why */ + int16 bantype; /* Bantype */ + int16 *levels; /* Access levels for commands */ + uint16 accesscount; /* # of pple with access */ + ChanAccess *access; /* List of authorized users */ + uint16 akickcount; /* # of akicked pple */ + AutoKick *akick; /* List of users to kickban */ + uint32 mlock_on, mlock_off; /* See channel modes below */ + uint32 mlock_limit; /* 0 if no limit */ + char *mlock_key; /* NULL if no key */ + char *mlock_flood; /* NULL if no +f */ + char *mlock_redirect; /* NULL if no +L */ + char *entry_message; /* Notice sent on entering channel */ + MemoInfo memos; /* Memos */ + char *bi; /* Bot used on this channel */ + uint32 botflags; /* BS_* below */ + int16 *ttb; /* Times to ban for each kicker */ + uint16 bwcount; /* Badword count */ + BadWord *badwords; /* For BADWORDS kicker */ + int16 capsmin, capspercent; /* For CAPS kicker */ + int16 floodlines, floodsecs; /* For FLOOD kicker */ + int16 repeattimes; /* For REPEAT kicker */ +}; + +struct botinfo_ { + BotInfo *next, *prev; + char *nick; /* Nickname of the bot */ + char *user; /* Its user name */ + char *host; /* Its hostname */ + char *real; /* Its real name */ + int16 flags; /* Bot flags */ + time_t created; /* Birth date */ + int16 chancount; /* Number of channels that use the bot. */ +}; + +struct badword_ { + uint16 in_use; + char *word; + uint16 type; +}; + +struct hostcore_ { + HostCore *next, *last; + char *nick; /* Owner of the vHost */ + char *vIdent; /* vIdent for the user */ + char *vHost; /* Vhost for this user */ + char *creator; /* Oper Nick of the oper who set the vhost */ + time_t time; /* Date/Time vHost was set */ +}; + +dbFILE *open_db_write(const char *service, const char *filename, int version); +dbFILE *open_db_read(const char *service, const char *filename, int version); +NickCore *findcore(const char *nick, int version); +NickAlias *findnick(const char *nick); +BotInfo *findbot(char *nick); +ChannelInfo *cs_findchan(const char *chan); +char *strscpy(char *d, const char *s, size_t len); +int write_file_version(dbFILE * f, uint32 version); +int mystricmp(const char *s1, const char *s2); +int delnick(NickAlias *na, int donttouchthelist); +int write_string(const char *s, dbFILE * f); +int write_ptr(const void *ptr, dbFILE * f); +int read_int16(int16 * ret, dbFILE * f); +int read_int32(int32 * ret, dbFILE * f); +int read_uint16(uint16 * ret, dbFILE * f); +int read_uint32(uint32 * ret, dbFILE * f); +int read_string(char **ret, dbFILE * f); +int write_int16(uint16 val, dbFILE * f); +int write_int32(uint32 val, dbFILE * f); +int read_ptr(void **ret, dbFILE * f); +int delcore(NickCore *nc); +void alpha_insert_chan(ChannelInfo * ci); +void insert_bot(BotInfo * bi); +void close_db(dbFILE * f); + +ChannelInfo *chanlists[256]; +NickAlias *nalists[1024]; +NickCore *nclists[1024]; +BotInfo *botlists[256]; + +int preferfirst = 0, prefersecond = 0, preferoldest = 0, prefernewest = 0; +int nonick = 0, nochan = 0, nobot = 0, nohost = 0; + +int main(int argc, char *argv[]) +{ + dbFILE *f; + int i; + NickCore *nc, *ncnext; + HostCore *firsthc = NULL; + + printf("\n"C_LBLUE"DB Merger for Anope IRC Services"C_NONE"\n"); + printf("Version: $Id$"C_NONE"\n\n"); + + if (argc >= 2) { + if (!mystricmp(argv[1], "--PREFEROLDEST")) { + printf("Preferring oldest database entries on collision.\n"); + preferoldest = 1; + } else if (!mystricmp(argv[1], "--PREFERFIRST")) { + printf("Preferring first database's entries on collision .\n"); + preferfirst = 1; + } else if (!mystricmp(argv[1], "--PREFERSECOND")) { + printf("Preferring second database's entries on collision.\n"); + prefersecond = 1; + } else if (!mystricmp(argv[1], "--PREFERNEWEST")) { + printf("Preferring newest database entries on collision.\n"); + prefernewest = 1; + } + } + + /* Section I: Nicks */ + /* Ia: First database */ + if ((f = open_db_read("NickServ", NICK_DB_1, 14))) { + + NickAlias *na, **nalast, *naprev; + NickCore *nc, **nclast, *ncprev; + int16 tmp16; + int32 tmp32; + int i, j, c; + + printf("Trying to merge nicks...\n"); + + /* Nick cores */ + for (i = 0; i < 1024; i++) { + nclast = &nclists[i]; + ncprev = NULL; + + while ((c = getc_db(f)) == 1) { + if (c != 1) { + printf("Invalid format in %s.\n", NICK_DB_1); + exit(0); + } + + nc = calloc(1, sizeof(NickCore)); + nc->aliascount = 0; + nc->unused = 0; + + *nclast = nc; + nclast = &nc->next; + nc->prev = ncprev; + ncprev = nc; + + READ(read_string(&nc->display, f)); + READ(read_buffer(nc->pass, f)); + READ(read_string(&nc->email, f)); + READ(read_string(&nc->greet, f)); + READ(read_uint32(&nc->icq, f)); + READ(read_string(&nc->url, f)); + READ(read_uint32(&nc->flags, f)); + READ(read_uint16(&nc->language, f)); + READ(read_uint16(&nc->accesscount, f)); + if (nc->accesscount) { + char **access; + access = calloc(sizeof(char *) * nc->accesscount, 1); + nc->access = access; + for (j = 0; j < nc->accesscount; j++, access++) + READ(read_string(access, f)); + } + READ(read_int16(&nc->memos.memocount, f)); + READ(read_int16(&nc->memos.memomax, f)); + if (nc->memos.memocount) { + Memo *memos; + memos = calloc(sizeof(Memo) * nc->memos.memocount, 1); + nc->memos.memos = memos; + for (j = 0; j < nc->memos.memocount; j++, memos++) { + READ(read_uint32(&memos->number, f)); + READ(read_uint16(&memos->flags, f)); + READ(read_int32(&tmp32, f)); + memos->time = tmp32; + READ(read_buffer(memos->sender, f)); + READ(read_string(&memos->text, f)); + } + } + READ(read_uint16(&nc->channelcount, f)); + READ(read_int16(&tmp16, f)); + } /* getc_db() */ + *nclast = NULL; + } /* for() loop */ + + /* Nick aliases */ + for (i = 0; i < 1024; i++) { + char *s = NULL; + + nalast = &nalists[i]; + naprev = NULL; + + while ((c = getc_db(f)) == 1) { + if (c != 1) { + printf("Invalid format in %s.\n", NICK_DB_1); + exit(0); + } + + na = calloc(1, sizeof(NickAlias)); + + READ(read_string(&na->nick, f)); + READ(read_string(&na->last_usermask, f)); + READ(read_string(&na->last_realname, f)); + READ(read_string(&na->last_quit, f)); + + READ(read_int32(&tmp32, f)); + na->time_registered = tmp32; + READ(read_int32(&tmp32, f)); + na->last_seen = tmp32; + READ(read_uint16(&na->status, f)); + READ(read_string(&s, f)); + na->nc = findcore(s, 0); + na->nc->aliascount++; + free(s); + + *nalast = na; + nalast = &na->next; + na->prev = naprev; + naprev = na; + } /* getc_db() */ + *nalast = NULL; + } /* for() loop */ + close_db(f); /* End of section Ia */ + } else + nonick = 1; + + /* Ib: Second database */ + if (!nonick) { + if ((f = open_db_read("NickServ", NICK_DB_2, 14))) { + + NickAlias *na, *naptr; + NickCore *nc; + int16 tmp16; + int32 tmp32; + int i, j, index, c; + + /* Nick cores */ + for (i = 0; i < 1024; i++) { + + while ((c = getc_db(f)) == 1) { + if (c != 1) { + printf("Invalid format in %s.\n", NICK_DB_2); + exit(0); + } + + nc = calloc(1, sizeof(NickCore)); + READ(read_string(&nc->display, f)); + READ(read_buffer(nc->pass, f)); + READ(read_string(&nc->email, f)); + + naptr = findnick(nc->display); + if (naptr) + nc->unused = 1; + else + nc->unused = 0; + + nc->aliascount = 0; + + index = HASH(nc->display); + nc->prev = NULL; + nc->next = nclists[index]; + if (nc->next) + nc->next->prev = nc; + nclists[index] = nc; + + READ(read_string(&nc->greet, f)); + READ(read_uint32(&nc->icq, f)); + READ(read_string(&nc->url, f)); + READ(read_uint32(&nc->flags, f)); + READ(read_uint16(&nc->language, f)); + READ(read_uint16(&nc->accesscount, f)); + if (nc->accesscount) { + char **access; + access = calloc(sizeof(char *) * nc->accesscount, 1); + nc->access = access; + for (j = 0; j < nc->accesscount; j++, access++) + READ(read_string(access, f)); + } + READ(read_int16(&nc->memos.memocount, f)); + READ(read_int16(&nc->memos.memomax, f)); + if (nc->memos.memocount) { + Memo *memos; + memos = calloc(sizeof(Memo) * nc->memos.memocount, 1); + nc->memos.memos = memos; + for (j = 0; j < nc->memos.memocount; j++, memos++) { + READ(read_uint32(&memos->number, f)); + READ(read_uint16(&memos->flags, f)); + READ(read_int32(&tmp32, f)); + memos->time = tmp32; + READ(read_buffer(memos->sender, f)); + READ(read_string(&memos->text, f)); + } + } + READ(read_uint16(&nc->channelcount, f)); + READ(read_int16(&tmp16, f)); + } /* getc_db() */ + } /* for() loop */ + + /* Nick aliases */ + for (i = 0; i < 1024; i++) { + char *s = NULL; + NickAlias *ptr, *prev, *naptr; + + while ((c = getc_db(f)) == 1) { + if (c != 1) { + printf("Invalid format in %s.\n", NICK_DB_2); + exit(0); + } + + na = calloc(1, sizeof(NickAlias)); + + READ(read_string(&na->nick, f)); + READ(read_string(&na->last_usermask, f)); + READ(read_string(&na->last_realname, f)); + READ(read_string(&na->last_quit, f)); + READ(read_int32(&tmp32, f)); + na->time_registered = tmp32; + READ(read_int32(&tmp32, f)); + na->last_seen = tmp32; + READ(read_uint16(&na->status, f)); + READ(read_string(&s, f)); + + naptr = findnick(na->nick); + if (naptr) { /* COLLISION! na = collision #2 = new (na->nc doesn't exist yet), naptr = collision #1 = old (naptr->nc exists) */ + char input[1024]; + NickCore *ncptr = findcore(na->nick, 1); /* Find core for #2, ncptr MUST exist since we've read all cores, if it doesn't eixst, we have a malformed db */; + + if (!ncptr) { /* malformed */ + printf("\n\n WARNING! Malformed database. No nickcore for nick %s, droping it.\n\n\n", na->nick); + delnick(na, 1); + } else { /* not malformed */ + if (!preferoldest && !preferfirst && !prefersecond && !prefernewest) { + printf("Nick collision for nick %s:\n\n", na->nick); + printf("Group 1: %s (%s)\n", naptr->nc->display, naptr->nc->email); + printf("Time registered: %s\n", ctime(&naptr->time_registered)); + printf("Group 2: %s (%s)\n", ncptr->display, ncptr->email); + printf("Time registered: %s\n", ctime(&na->time_registered)); + printf("What group do you want to keep? Enter the related group number \"1\" or \"2\".\n"); + } + + if (preferoldest) { + input[0] = (na->time_registered > naptr->time_registered) ? '1' : '2'; + } else if (prefernewest) { + input[0] = (na->time_registered > naptr->time_registered) ? '2' : '1'; + } else if (preferfirst) { + input[0] = '1'; + } else if (prefersecond) { + input[0] = '2'; + } else { + waiting_for_input: + scanf("%s", input); + } + if (input[0] == '1') { /* #2 isn't in the list yet, #1 is. free #2 alias. */ + printf("Deleting nick alias %s (#2).\n", na->nick); + delnick(na, 1); /* free()s the alias without touching the list since na isn't in the list */ + } else if (input[0] == '2') { /* get alias #1 out of the list, then free() it, then add #2 to the list */ + printf("Deleting nick alias %s (#1).\n", naptr->nick); + naptr->nc->aliascount--; /* tell the core it has one alias less */ + delnick(naptr, 0); /* removes the alias from the list and free()s it */ + na->nc = ncptr; + na->nc->aliascount++; + index = HASH(na->nick); + for (prev = NULL, ptr = nalists[index]; ptr && mystricmp(ptr->nick, na->nick) < 0; prev = ptr, ptr = ptr->next); + na->prev = prev; + na->next = ptr; + if (!prev) + nalists[index] = na; + else + prev->next = na; + if (ptr) + ptr->prev = na; + } else { + printf("Invalid number, give us a valid one (1 or 2).\n"); + goto waiting_for_input; + } + } /* not malformed */ + } else { /* No collision, add the core pointer and put the alias in the list */ + na->nc = findcore(s, 0); + if (!na->nc) { + printf("\n\n WARNING! Malformed database. No nickcore for nick %s, droping it.\n\n\n", na->nick); + delnick(na, 1); + } else { + na->nc->aliascount++; + index = HASH(na->nick); + for (prev = NULL, ptr = nalists[index]; ptr && mystricmp(ptr->nick, na->nick) < 0; prev = ptr, ptr = ptr->next); + na->prev = prev; + na->next = ptr; + if (!prev) + nalists[index] = na; + else + prev->next = na; + if (ptr) + ptr->prev = na; + } + } + free(s); + } /* getc_db() */ + } /* for() loop */ + close_db(f); /* End of section Ib */ + } else + nonick = 1; + } + + /* CLEAN THE CORES */ + + for (i = 0; i < 1024; i++) { + for (nc = nclists[i]; nc; nc = ncnext) { + ncnext = nc->next; + if (nc->aliascount < 1) { + printf("Deleting core %s (%s).\n", nc->display, nc->email); + delcore(nc); + } + } + } + + /* Ic: Saving */ + if (!nonick) { + if ((f = open_db_write("NickServ", NICK_DB_NEW, 14))) { + + NickAlias *na; + NickCore *nc; + char **access; + Memo *memos; + int i, j; + + /* Nick cores */ + for (i = 0; i < 1024; i++) { + for (nc = nclists[i]; nc; nc = nc->next) { + SAFE(write_int8(1, f)); + SAFE(write_string(nc->display, f)); + SAFE(write_buffer(nc->pass, f)); + SAFE(write_string(nc->email, f)); + SAFE(write_string(nc->greet, f)); + SAFE(write_int32(nc->icq, f)); + SAFE(write_string(nc->url, f)); + SAFE(write_int32(nc->flags, f)); + SAFE(write_int16(nc->language, f)); + SAFE(write_int16(nc->accesscount, f)); + for (j = 0, access = nc->access; j < nc->accesscount; j++, access++) + SAFE(write_string(*access, f)); + + SAFE(write_int16(nc->memos.memocount, f)); + SAFE(write_int16(nc->memos.memomax, f)); + memos = nc->memos.memos; + for (j = 0; j < nc->memos.memocount; j++, memos++) { + SAFE(write_int32(memos->number, f)); + SAFE(write_int16(memos->flags, f)); + SAFE(write_int32(memos->time, f)); + SAFE(write_buffer(memos->sender, f)); + SAFE(write_string(memos->text, f)); + } + SAFE(write_int16(nc->channelcount, f)); + SAFE(write_int16(nc->channelmax, f)); + } /* for (nc) */ + SAFE(write_int8(0, f)); + } /* for (i) */ + + /* Nick aliases */ + for (i = 0; i < 1024; i++) { + for (na = nalists[i]; na; na = na->next) { + SAFE(write_int8(1, f)); + SAFE(write_string(na->nick, f)); + SAFE(write_string(na->last_usermask, f)); + SAFE(write_string(na->last_realname, f)); + SAFE(write_string(na->last_quit, f)); + SAFE(write_int32(na->time_registered, f)); + SAFE(write_int32(na->last_seen, f)); + SAFE(write_int16(na->status, f)); + SAFE(write_string(na->nc->display, f)); + + } /* for (na) */ + SAFE(write_int8(0, f)); + } /* for (i) */ + close_db(f); /* End of section Ic */ + printf("Nick merging done. New database saved as %s.\n", NICK_DB_NEW); + } + } /* End of section I */ + + /* Section II: Chans */ + /* IIa: First database */ + if ((f = open_db_read("ChanServ", CHAN_DB_1, 16))) { + ChannelInfo *ci, **last, *prev; + int c; + + printf("Trying to merge channels...\n"); + + for (i = 0; i < 256; i++) { + int16 tmp16; + int32 tmp32; + int n_levels; + char *s; + int n_ttb; + /* Unused variable - why? -GD + int J; + */ + + last = &chanlists[i]; + prev = NULL; + + while ((c = getc_db(f)) == 1) { + int j; + + if (c != 1) { + printf("Invalid format in %s.\n", CHAN_DB_1); + exit(0); + } + + ci = calloc(sizeof(ChannelInfo), 1); + *last = ci; + last = &ci->next; + ci->prev = prev; + prev = ci; + READ(read_buffer(ci->name, f)); + READ(read_string(&ci->founder, f)); + READ(read_string(&ci->successor, f)); + READ(read_buffer(ci->founderpass, f)); + READ(read_string(&ci->desc, f)); + if (!ci->desc) + ci->desc = strdup(""); + READ(read_string(&ci->url, f)); + READ(read_string(&ci->email, f)); + READ(read_int32(&tmp32, f)); + ci->time_registered = tmp32; + READ(read_int32(&tmp32, f)); + ci->last_used = tmp32; + READ(read_string(&ci->last_topic, f)); + READ(read_buffer(ci->last_topic_setter, f)); + READ(read_int32(&tmp32, f)); + ci->last_topic_time = tmp32; + READ(read_uint32(&ci->flags, f)); + /* Temporary flags cleanup */ + ci->flags &= ~0x80000000; + READ(read_string(&ci->forbidby, f)); + READ(read_string(&ci->forbidreason, f)); + READ(read_int16(&tmp16, f)); + ci->bantype = tmp16; + READ(read_int16(&tmp16, f)); + n_levels = tmp16; + ci->levels = calloc(36 * sizeof(*ci->levels), 1); + for (j = 0; j < n_levels; j++) { + if (j < 36) + READ(read_int16(&ci->levels[j], f)); + else + READ(read_int16(&tmp16, f)); + } + READ(read_uint16(&ci->accesscount, f)); + if (ci->accesscount) { + ci->access = calloc(ci->accesscount, sizeof(ChanAccess)); + for (j = 0; j < ci->accesscount; j++) { + READ(read_uint16(&ci->access[j].in_use, f)); + if (ci->access[j].in_use) { + READ(read_int16(&ci->access[j].level, f)); + READ(read_string(&s, f)); + if (s) { + ci->access[j].nc = findcore(s, 0); + free(s); + } + if (ci->access[j].nc == NULL) + ci->access[j].in_use = 0; + READ(read_int32(&tmp32, f)); + ci->access[j].last_seen = tmp32; + } + } + } else { + ci->access = NULL; + } + READ(read_uint16(&ci->akickcount, f)); + if (ci->akickcount) { + ci->akick = calloc(ci->akickcount, sizeof(AutoKick)); + for (j = 0; j < ci->akickcount; j++) { + SAFE(read_uint16(&ci->akick[j].flags, f)); + if (ci->akick[j].flags & 0x0001) { + SAFE(read_string(&s, f)); + if (ci->akick[j].flags & 0x0002) { + ci->akick[j].u.nc = findcore(s, 0); + if (!ci->akick[j].u.nc) + ci->akick[j].flags &= ~0x0001; + free(s); + } else { + ci->akick[j].u.mask = s; + } + SAFE(read_string(&s, f)); + if (ci->akick[j].flags & 0x0001) + ci->akick[j].reason = s; + else if (s) + free(s); + SAFE(read_string(&s, f)); + if (ci->akick[j].flags & 0x0001) { + ci->akick[j].creator = s; + } else if (s) { + free(s); + } + SAFE(read_int32(&tmp32, f)); + if (ci->akick[j].flags & 0x0001) + ci->akick[j].addtime = tmp32; + } + } + } else { + ci->akick = NULL; + } + READ(read_uint32(&ci->mlock_on, f)); + READ(read_uint32(&ci->mlock_off, f)); + READ(read_uint32(&ci->mlock_limit, f)); + READ(read_string(&ci->mlock_key, f)); + READ(read_string(&ci->mlock_flood, f)); + READ(read_string(&ci->mlock_redirect, f)); + READ(read_int16(&ci->memos.memocount, f)); + READ(read_int16(&ci->memos.memomax, f)); + if (ci->memos.memocount) { + Memo *memos; + memos = calloc(sizeof(Memo) * ci->memos.memocount, 1); + ci->memos.memos = memos; + for (j = 0; j < ci->memos.memocount; j++, memos++) { + READ(read_uint32(&memos->number, f)); + READ(read_uint16(&memos->flags, f)); + READ(read_int32(&tmp32, f)); + memos->time = tmp32; + READ(read_buffer(memos->sender, f)); + READ(read_string(&memos->text, f)); + } + } + READ(read_string(&ci->entry_message, f)); + + /* BotServ options */ + READ(read_string(&ci->bi, f)); + READ(read_int32(&tmp32, f)); + ci->botflags = tmp32; + READ(read_int16(&tmp16, f)); + n_ttb = tmp16; + ci->ttb = calloc(2 * 8, 1); + for (j = 0; j < n_ttb; j++) { + if (j < 8) + READ(read_int16(&ci->ttb[j], f)); + else + READ(read_int16(&tmp16, f)); + } + for (j = n_ttb; j < 8; j++) + ci->ttb[j] = 0; + READ(read_int16(&tmp16, f)); + ci->capsmin = tmp16; + READ(read_int16(&tmp16, f)); + ci->capspercent = tmp16; + READ(read_int16(&tmp16, f)); + ci->floodlines = tmp16; + READ(read_int16(&tmp16, f)); + ci->floodsecs = tmp16; + READ(read_int16(&tmp16, f)); + ci->repeattimes = tmp16; + + READ(read_uint16(&ci->bwcount, f)); + if (ci->bwcount) { + ci->badwords = calloc(ci->bwcount, sizeof(BadWord)); + for (j = 0; j < ci->bwcount; j++) { + SAFE(read_uint16(&ci->badwords[j].in_use, f)); + if (ci->badwords[j].in_use) { + SAFE(read_string(&ci->badwords[j].word, f)); + SAFE(read_uint16(&ci->badwords[j].type, f)); + } + } + } else { + ci->badwords = NULL; + } + } /* getc_db() */ + *last = NULL; + } /* for() loop */ + close_db(f); + } else + nochan = 1; + + /* IIb: Second database */ + if (!nochan) { + if ((f = open_db_read("ChanServ", CHAN_DB_2, 16))) { + int c; + + for (i = 0; i < 256; i++) { + int16 tmp16; + int32 tmp32; + int n_levels; + char *s; + int n_ttb; + /* Unused variables - why? -GD + char input[1024]; + NickAlias *na; + int J; + */ + + while ((c = getc_db(f)) == 1) { + ChannelInfo *ci = NULL, *ciptr = NULL; + int j; + + if (c != 1) { + printf("Invalid format in %s.\n", CHAN_DB_2); + exit(0); + } + + ci = calloc(sizeof(ChannelInfo), 1); + READ(read_buffer(ci->name, f)); + READ(read_string(&ci->founder, f)); + READ(read_string(&ci->successor, f)); + READ(read_buffer(ci->founderpass, f)); + READ(read_string(&ci->desc, f)); + if (!ci->desc) + ci->desc = strdup(""); + READ(read_string(&ci->url, f)); + READ(read_string(&ci->email, f)); + READ(read_int32(&tmp32, f)); + ci->time_registered = tmp32; + READ(read_int32(&tmp32, f)); + ci->last_used = tmp32; + READ(read_string(&ci->last_topic, f)); + READ(read_buffer(ci->last_topic_setter, f)); + READ(read_int32(&tmp32, f)); + ci->last_topic_time = tmp32; + READ(read_uint32(&ci->flags, f)); + /* Temporary flags cleanup */ + ci->flags &= ~0x80000000; + READ(read_string(&ci->forbidby, f)); + READ(read_string(&ci->forbidreason, f)); + READ(read_int16(&tmp16, f)); + ci->bantype = tmp16; + READ(read_int16(&tmp16, f)); + n_levels = tmp16; + ci->levels = calloc(36 * sizeof(*ci->levels), 1); + for (j = 0; j < n_levels; j++) { + if (j < 36) + READ(read_int16(&ci->levels[j], f)); + else + READ(read_int16(&tmp16, f)); + } + READ(read_uint16(&ci->accesscount, f)); + if (ci->accesscount) { + ci->access = calloc(ci->accesscount, sizeof(ChanAccess)); + for (j = 0; j < ci->accesscount; j++) { + READ(read_uint16(&ci->access[j].in_use, f)); + if (ci->access[j].in_use) { + READ(read_int16(&ci->access[j].level, f)); + READ(read_string(&s, f)); + if (s) { + ci->access[j].nc = findcore(s, 0); + free(s); + } + if (ci->access[j].nc == NULL) + ci->access[j].in_use = 0; + READ(read_int32(&tmp32, f)); + ci->access[j].last_seen = tmp32; + } + } + } else { + ci->access = NULL; + } + READ(read_uint16(&ci->akickcount, f)); + if (ci->akickcount) { + ci->akick = calloc(ci->akickcount, sizeof(AutoKick)); + for (j = 0; j < ci->akickcount; j++) { + SAFE(read_uint16(&ci->akick[j].flags, f)); + if (ci->akick[j].flags & 0x0001) { + SAFE(read_string(&s, f)); + if (ci->akick[j].flags & 0x0002) { + ci->akick[j].u.nc = findcore(s, 0); + if (!ci->akick[j].u.nc) + ci->akick[j].flags &= ~0x0001; + free(s); + } else { + ci->akick[j].u.mask = s; + } + SAFE(read_string(&s, f)); + if (ci->akick[j].flags & 0x0001) + ci->akick[j].reason = s; + else if (s) + free(s); + SAFE(read_string(&s, f)); + if (ci->akick[j].flags & 0x0001) { + ci->akick[j].creator = s; + } else if (s) { + free(s); + } + SAFE(read_int32(&tmp32, f)); + if (ci->akick[j].flags & 0x0001) + ci->akick[j].addtime = tmp32; + } + } + } else { + ci->akick = NULL; + } + READ(read_uint32(&ci->mlock_on, f)); + READ(read_uint32(&ci->mlock_off, f)); + READ(read_uint32(&ci->mlock_limit, f)); + READ(read_string(&ci->mlock_key, f)); + READ(read_string(&ci->mlock_flood, f)); + READ(read_string(&ci->mlock_redirect, f)); + READ(read_int16(&ci->memos.memocount, f)); + READ(read_int16(&ci->memos.memomax, f)); + if (ci->memos.memocount) { + Memo *memos; + memos = calloc(sizeof(Memo) * ci->memos.memocount, 1); + ci->memos.memos = memos; + for (j = 0; j < ci->memos.memocount; j++, memos++) { + READ(read_uint32(&memos->number, f)); + READ(read_uint16(&memos->flags, f)); + READ(read_int32(&tmp32, f)); + memos->time = tmp32; + READ(read_buffer(memos->sender, f)); + READ(read_string(&memos->text, f)); + } + } + READ(read_string(&ci->entry_message, f)); + + /* BotServ options */ + READ(read_string(&ci->bi, f)); + READ(read_int32(&tmp32, f)); + ci->botflags = tmp32; + READ(read_int16(&tmp16, f)); + n_ttb = tmp16; + ci->ttb = calloc(32, 1); + for (j = 0; j < n_ttb; j++) { + if (j < 8) + READ(read_int16(&ci->ttb[j], f)); + else + READ(read_int16(&tmp16, f)); + } + for (j = n_ttb; j < 8; j++) + ci->ttb[j] = 0; + READ(read_int16(&tmp16, f)); + ci->capsmin = tmp16; + READ(read_int16(&tmp16, f)); + ci->capspercent = tmp16; + READ(read_int16(&tmp16, f)); + ci->floodlines = tmp16; + READ(read_int16(&tmp16, f)); + ci->floodsecs = tmp16; + READ(read_int16(&tmp16, f)); + ci->repeattimes = tmp16; + + READ(read_uint16(&ci->bwcount, f)); + if (ci->bwcount) { + ci->badwords = calloc(ci->bwcount, sizeof(BadWord)); + for (j = 0; j < ci->bwcount; j++) { + SAFE(read_uint16(&ci->badwords[j].in_use, f)); + if (ci->badwords[j].in_use) { + SAFE(read_string(&ci->badwords[j].word, f)); + SAFE(read_uint16(&ci->badwords[j].type, f)); + } + } + } else { + ci->badwords = NULL; + } + /* READING DONE */ + ciptr = cs_findchan(ci->name); + if (ciptr) { /* COLLISION! ciptr = old = 1; ci = new = 2*/ + char input[1024]; + + if (!preferoldest && !preferfirst && !prefersecond && !prefernewest) { + printf("Chan collision for channel %s:\n\n", ci->name); + + printf("Owner of channel 1: %s (%s)\n", (ciptr->founder) ? ciptr->founder : "none", (ciptr->email) ? ciptr->email : "no valid email"); + printf("Accesscount: %u\n", ciptr->accesscount); + if (ciptr->flags & 0x00000080) { + printf("Status: Channel is forbidden"); + } else if (ciptr->flags & 0x00010000) { + printf("Status: Channel is suspended"); + } + printf("Time registered: %s\n", ctime(&ciptr->time_registered)); + + printf("Owner of channel 2: %s (%s)\n", (ci->founder) ? ci->founder : "none", (ci->email) ? ci->email : "no valid email"); + printf("Accesscount: %u\n", ci->accesscount); + if (ci->flags & 0x00000080) { + printf("Status: Channel is forbidden"); + } else if (ci->flags & 0x00010000) { + printf("Status: Channel is suspended"); + } + printf("Time registered: %s\n", ctime(&ci->time_registered)); + + printf("What channel do you want to keep? Enter the related number \"1\" or \"2\".\n"); + } + + if (preferoldest) { + input[0] = (ci->time_registered > ciptr->time_registered) ? '1' : '2'; + } else if (prefernewest) { + input[0] = (ci->time_registered > ciptr->time_registered) ? '2' : '1'; + } else if (preferfirst) { + input[0] = '1'; + } else if (prefersecond) { + input[0] = '2'; + } else { + waiting_for_input4: + scanf("%s", input); + } + if (input[0] == '1') { /* #2 isn't in the list yet, #1 is. -> free() #2 [ci] */ + NickCore *nc = NULL; + int i; + printf("Deleting chan %s (#2).\n", ci->name); + + if (ci->founder) { + nc = findcore(ci->founder, 0); + if (nc) + nc->channelcount--; + } + free(ci->desc); + free(ci->founder); + free(ci->successor); + if (ci->url) + free(ci->url); + if (ci->email) + free(ci->email); + if (ci->last_topic) + free(ci->last_topic); + if (ci->forbidby) + free(ci->forbidby); + if (ci->forbidreason) + free(ci->forbidreason); + if (ci->mlock_key) + free(ci->mlock_key); + if (ci->mlock_flood) + free(ci->mlock_flood); + if (ci->mlock_redirect) + free(ci->mlock_redirect); + if (ci->entry_message) + free(ci->entry_message); + if (ci->access) + free(ci->access); + for (i = 0; i < ci->akickcount; i++) { + if (!(ci->akick[i].flags & 0x0002) && ci->akick[i].u.mask) + free(ci->akick[i].u.mask); + if (ci->akick[i].reason) + free(ci->akick[i].reason); + if (ci->akick[i].creator) + free(ci->akick[i].creator); + } + if (ci->akick) + free(ci->akick); + if (ci->levels) + free(ci->levels); + if (ci->memos.memos) { + for (i = 0; i < ci->memos.memocount; i++) { + if (ci->memos.memos[i].text) + free(ci->memos.memos[i].text); + } + free(ci->memos.memos); + } + if (ci->ttb) + free(ci->ttb); + for (i = 0; i < ci->bwcount; i++) { + if (ci->badwords[i].word) + free(ci->badwords[i].word); + } + if (ci->badwords) + free(ci->badwords); + if (ci->bi) + free(ci->bi); + free(ci); + + } else if (input[0] == '2') { /* get #1 out of the list, free() it and add #2 to the list */ + NickCore *nc = NULL; + printf("Deleting chan %s (#1).\n", ciptr->name); + + if (ciptr->next) + ciptr->next->prev = ciptr->prev; + if (ciptr->prev) + ciptr->prev->next = ciptr->next; + else + chanlists[tolower(ciptr->name[1])] = ciptr->next; + + if (ciptr->founder) { + nc = findcore(ciptr->founder, 0); + if (nc) + nc->channelcount--; + } + free(ciptr->desc); + if (ciptr->url) + free(ciptr->url); + if (ciptr->email) + free(ciptr->email); + if (ciptr->last_topic) + free(ciptr->last_topic); + if (ciptr->forbidby) + free(ciptr->forbidby); + if (ciptr->forbidreason) + free(ciptr->forbidreason); + if (ciptr->mlock_key) + free(ciptr->mlock_key); + if (ciptr->mlock_flood) + free(ciptr->mlock_flood); + if (ciptr->mlock_redirect) + free(ciptr->mlock_redirect); + if (ciptr->entry_message) + free(ciptr->entry_message); + if (ciptr->access) + free(ciptr->access); + for (i = 0; i < ciptr->akickcount; i++) { + if (!(ciptr->akick[i].flags & 0x0002) && ciptr->akick[i].u.mask) + free(ciptr->akick[i].u.mask); + if (ciptr->akick[i].reason) + free(ciptr->akick[i].reason); + if (ciptr->akick[i].creator) + free(ciptr->akick[i].creator); + } + if (ciptr->akick) + free(ciptr->akick); + if (ciptr->levels) + free(ciptr->levels); + if (ciptr->memos.memos) { + for (i = 0; i < ciptr->memos.memocount; i++) { + if (ciptr->memos.memos[i].text) + free(ciptr->memos.memos[i].text); + } + free(ciptr->memos.memos); + } + if (ciptr->ttb) + free(ciptr->ttb); + for (i = 0; i < ciptr->bwcount; i++) { + if (ciptr->badwords[i].word) + free(ciptr->badwords[i].word); + } + if (ciptr->badwords) + free(ciptr->badwords); + free(ciptr); + + alpha_insert_chan(ci); + + } else { + printf("Invalid number, give us a valid one (1 or 2).\n"); + goto waiting_for_input4; + } + } else { /* no collision, put the chan into the list */ + alpha_insert_chan(ci); + } + } /* getc_db() */ + } /* for() loop */ + close_db(f); + } else + nochan = 1; + } + + /* IIc: Saving */ + if (!nochan) { + if ((f = open_db_write("ChanServ", CHAN_DB_NEW, 16))) { + ChannelInfo *ci; + Memo *memos; + /* Unused variable - why? -GD + static time_t lastwarn = 0; + */ + + for (i = 0; i < 256; i++) { + int16 tmp16; + for (ci = chanlists[i]; ci; ci = ci->next) { + int j; + SAFE(write_int8(1, f)); + SAFE(write_buffer(ci->name, f)); + if (ci->founder) + SAFE(write_string(ci->founder, f)); + else + SAFE(write_string(NULL, f)); + if (ci->successor) + SAFE(write_string(ci->successor, f)); + else + SAFE(write_string(NULL, f)); + SAFE(write_buffer(ci->founderpass, f)); + SAFE(write_string(ci->desc, f)); + SAFE(write_string(ci->url, f)); + SAFE(write_string(ci->email, f)); + SAFE(write_int32(ci->time_registered, f)); + SAFE(write_int32(ci->last_used, f)); + SAFE(write_string(ci->last_topic, f)); + SAFE(write_buffer(ci->last_topic_setter, f)); + SAFE(write_int32(ci->last_topic_time, f)); + SAFE(write_int32(ci->flags, f)); + SAFE(write_string(ci->forbidby, f)); + SAFE(write_string(ci->forbidreason, f)); + SAFE(write_int16(ci->bantype, f)); + tmp16 = 36; + SAFE(write_int16(tmp16, f)); + for (j = 0; j < 36; j++) + SAFE(write_int16(ci->levels[j], f)); + + SAFE(write_int16(ci->accesscount, f)); + for (j = 0; j < ci->accesscount; j++) { + SAFE(write_int16(ci->access[j].in_use, f)); + if (ci->access[j].in_use) { + SAFE(write_int16(ci->access[j].level, f)); + SAFE(write_string(ci->access[j].nc->display, f)); + SAFE(write_int32(ci->access[j].last_seen, f)); + } + } + SAFE(write_int16(ci->akickcount, f)); + for (j = 0; j < ci->akickcount; j++) { + SAFE(write_int16(ci->akick[j].flags, f)); + if (ci->akick[j].flags & 0x0001) { + if (ci->akick[j].flags & 0x0002) + SAFE(write_string(ci->akick[j].u.nc->display, f)); + else + SAFE(write_string(ci->akick[j].u.mask, f)); + SAFE(write_string(ci->akick[j].reason, f)); + SAFE(write_string(ci->akick[j].creator, f)); + SAFE(write_int32(ci->akick[j].addtime, f)); + } + } + + SAFE(write_int32(ci->mlock_on, f)); + SAFE(write_int32(ci->mlock_off, f)); + SAFE(write_int32(ci->mlock_limit, f)); + SAFE(write_string(ci->mlock_key, f)); + SAFE(write_string(ci->mlock_flood, f)); + SAFE(write_string(ci->mlock_redirect, f)); + SAFE(write_int16(ci->memos.memocount, f)); + SAFE(write_int16(ci->memos.memomax, f)); + memos = ci->memos.memos; + for (j = 0; j < ci->memos.memocount; j++, memos++) { + SAFE(write_int32(memos->number, f)); + SAFE(write_int16(memos->flags, f)); + SAFE(write_int32(memos->time, f)); + SAFE(write_buffer(memos->sender, f)); + SAFE(write_string(memos->text, f)); + } + SAFE(write_string(ci->entry_message, f)); + if (ci->bi) + SAFE(write_string(ci->bi, f)); + else + SAFE(write_string(NULL, f)); + SAFE(write_int32(ci->botflags, f)); + tmp16 = 8; + SAFE(write_int16(tmp16, f)); + for (j = 0; j < 8; j++) + SAFE(write_int16(ci->ttb[j], f)); + SAFE(write_int16(ci->capsmin, f)); + SAFE(write_int16(ci->capspercent, f)); + SAFE(write_int16(ci->floodlines, f)); + SAFE(write_int16(ci->floodsecs, f)); + SAFE(write_int16(ci->repeattimes, f)); + + SAFE(write_int16(ci->bwcount, f)); + for (j = 0; j < ci->bwcount; j++) { + SAFE(write_int16(ci->badwords[j].in_use, f)); + if (ci->badwords[j].in_use) { + SAFE(write_string(ci->badwords[j].word, f)); + SAFE(write_int16(ci->badwords[j].type, f)); + } + } + } /* for (chanlists[i]) */ + SAFE(write_int8(0, f)); + } /* for (i) */ + close_db(f); + printf("Chan merging done. New database saved as %s.\n", CHAN_DB_NEW); + } + } + + /* Section III: Bots */ + /* IIIa: First database */ + if ((f = open_db_read("Botserv", BOT_DB_1, 10))) { + BotInfo *bi; + int c; + int32 tmp32; + int16 tmp16; + + printf("Trying to merge bots...\n"); + + while ((c = getc_db(f)) == 1) { + if (c != 1) { + printf("Invalid format in %s.\n", BOT_DB_1); + exit(0); + } + + bi = calloc(sizeof(BotInfo), 1); + READ(read_string(&bi->nick, f)); + READ(read_string(&bi->user, f)); + READ(read_string(&bi->host, f)); + READ(read_string(&bi->real, f)); + SAFE(read_int16(&tmp16, f)); + bi->flags = tmp16; + READ(read_int32(&tmp32, f)); + bi->created = tmp32; + READ(read_int16(&tmp16, f)); + bi->chancount = tmp16; + insert_bot(bi); + } + } else + nobot = 1; + + /* IIIb: Second database */ + if (!nobot) { + if ((f = open_db_read("Botserv", BOT_DB_2, 10))) { + BotInfo *bi, *biptr; + int c; + int32 tmp32; + int16 tmp16; + char input[1024]; + + while ((c = getc_db(f)) == 1) { + if (c != 1) { + printf("Invalid format in %s.\n", BOT_DB_2); + exit(0); + } + + bi = calloc(sizeof(BotInfo), 1); + READ(read_string(&bi->nick, f)); + READ(read_string(&bi->user, f)); + READ(read_string(&bi->host, f)); + READ(read_string(&bi->real, f)); + SAFE(read_int16(&tmp16, f)); + bi->flags = tmp16; + READ(read_int32(&tmp32, f)); + bi->created = tmp32; + READ(read_int16(&tmp16, f)); + bi->chancount = tmp16; + biptr = findbot(bi->nick); + if (biptr) { /* BOT COLLISION! #1 is biptr-> (db1), #2 is bi-> (db2) */ + if (!preferoldest && !preferfirst && !prefersecond && !prefernewest) { + printf("Bot collision for botnick %s:\n\n", biptr->nick); + printf("Bot 1: %s@%s (%s) is assigned to %d chans\n", biptr->user, biptr->host, biptr->real, biptr->chancount); + printf("Time registered: %s\n", ctime(&biptr->created)); + printf("Bot 2: %s@%s (%s) is assigned to %d chans\n", bi->user, bi->host, bi->real, bi->chancount); + printf("Time registered: %s\n", ctime(&bi->created)); + printf("What bot do you want to keep? Enter the related bot number \"1\" or \"2\".\n"); + } + + if (preferoldest) { + input[0] = (biptr->created > bi->created) ? '1' : '2'; + } else if (prefernewest) { + input[0] = (biptr->created > bi->created) ? '2' : '1'; + } else if (preferfirst) { + input[0] = '2'; + } else if (prefersecond) { + input[0] = '1'; + } else { + waiting_for_input3: + scanf("%s", input); + } + if (input[0] == '1') { /* free() bot #2 (bi) */ + printf("Deleting Bot %s!%s@%s (%s) (#2).\n", bi->nick, bi->user, bi->host, bi->real); + free(bi->nick); + free(bi->user); + free(bi->host); + free(bi->real); + free(bi); + } else if (input[0] == '2') { /* get bot #1 (biptr) out of the list, free() it and add #2 to the list */ + printf("Deleting Bot %s!%s@%s (%s) (#1).\n", biptr->nick, biptr->user, biptr->host, biptr->real); + if (biptr->next) + biptr->next->prev = biptr->prev; + if (biptr->prev) + biptr->prev->next = biptr->next; + else + botlists[tolower(*biptr->nick)] = biptr->next; + free(biptr->nick); + free(biptr->user); + free(biptr->host); + free(biptr->real); + free(biptr); + insert_bot(bi); + } else { + printf("Invalid number, give us a valid one (1 or 2).\n"); + goto waiting_for_input3; + } + } /* NO COLLISION (biptr) */ + insert_bot(bi); + } + } else + nobot = 1; + } + + /* IIIc: Saving */ + if (!nobot) { + if ((f = open_db_write("Botserv", BOT_DB_NEW, 10))) { + BotInfo *bi; + for (i = 0; i < 256; i++) { + for (bi = botlists[i]; bi; bi = bi->next) { + SAFE(write_int8(1, f)); + SAFE(write_string(bi->nick, f)); + SAFE(write_string(bi->user, f)); + SAFE(write_string(bi->host, f)); + SAFE(write_string(bi->real, f)); + SAFE(write_int16(bi->flags, f)); + SAFE(write_int32(bi->created, f)); + SAFE(write_int16(bi->chancount, f)); + } + } + SAFE(write_int8(0, f)); + close_db(f); + printf("Bot merging done. New database saved as %s.\n", BOT_DB_NEW); + } + } /* End of section III */ + + /* Section IV: Hosts */ + /* IVa: First database */ + if ((f = open_db_read("HostServ", HOST_DB_1, 3))) { + HostCore *hc; + int c; + int32 tmp32; + + printf("Trying to merge hosts...\n"); + + while ((c = getc_db(f)) == 1) { + if (c != 1) { + printf("Invalid format in %s.\n", HOST_DB_1); + exit(0); + } + hc = calloc(1, sizeof(HostCore)); + READ(read_string(&hc->nick, f)); + READ(read_string(&hc->vIdent, f)); + READ(read_string(&hc->vHost, f)); + READ(read_string(&hc->creator, f)); + READ(read_int32(&tmp32, f)); + hc->time = tmp32; + hc->next = firsthc; + if (firsthc) + firsthc->last = hc; + hc->last = NULL; + firsthc = hc; + } + } else + nohost = 1; + + /* IVb: Second database */ + if (!nohost) { + if ((f = open_db_read("HostServ", HOST_DB_2, 3))) { + HostCore *hc, *hcptr; + char input[1024]; + int32 tmp32; + int c; + int collision = 0; + + while ((c = getc_db(f)) == 1) { + if (c != 1) { + printf("Invalid format in %s.\n", HOST_DB_2); + exit(0); + } + collision = 0; + hc = calloc(1, sizeof(HostCore)); + READ(read_string(&hc->nick, f)); + READ(read_string(&hc->vIdent, f)); + READ(read_string(&hc->vHost, f)); + READ(read_string(&hc->creator, f)); + READ(read_int32(&tmp32, f)); + hc->time = tmp32; + + for (hcptr = firsthc; hcptr; hcptr = hcptr->next) { + if (!mystricmp(hcptr->nick, hc->nick)) { /* COLLISION: #1 is from db1 (hcptr), #2 is from db2 (hc) */ + collision++; + if (!preferoldest && !preferfirst && !prefersecond && !prefernewest) { + printf("vHost collision for nick %s:\n\n", hcptr->nick); + printf("vHost 1: %s (vIdent: %s)\n", hcptr->vHost, (hcptr->vIdent) ? hcptr->vIdent : "none"); + printf("Time set: %s\n", ctime(&hcptr->time)); + printf("vHost 2: %s (vIdent: %s)\n", hc->vHost, (hc->vIdent) ? hc->vIdent : "none"); + printf("Time set: %s\n", ctime(&hc->time)); + printf("What vhost do you want to keep? Enter the related number \"1\" or \"2\".\n"); + } + if (preferoldest) { + input[0] = (hcptr->time > hc->time) ? '1' : '2'; + } else if (prefernewest) { + input[0] = (hcptr->time > hc->time) ? '2' : '1'; + } else if (preferfirst) { + input[0] = '1'; + } else if (prefersecond) { + input[0] = '2'; + } else { + waiting_for_input2: + scanf("%s", input); + } + if (input[0] == '2') { /* free() hcptr and get it out of the list, put hc into the list */ + printf("Deleting vHost %s (vIdent: %s) for nick %s (#1).\n", hcptr->vHost, (hcptr->vIdent) ? hcptr->vIdent : "none", hcptr->nick); + if (hcptr->last) + hcptr->last->next = hcptr->next; + if (hcptr->next) + hcptr->next->last = hcptr->last; + free(hcptr->nick); + free(hcptr->vHost); + free(hcptr->vIdent); + free(hcptr->creator); + free(hcptr); + hc->next = firsthc; + if (firsthc) + firsthc->last = hc; + hc->last = NULL; + firsthc = hc; + } else if (input[0] == '1') { /* free() hc */ + printf("Deleting vHost %s (vIdent: %s) for nick %s (#2).\n", hc->vHost, (hc->vIdent) ? hc->vIdent : "none", hc->nick); + free(hc->nick); + free(hc->vHost); + free(hc->vIdent); + free(hc->creator); + free(hc); + } else { + printf("Invalid number, give us a valid one (1 or 2).\n"); + goto waiting_for_input2; + } /* input[0] */ + } /* mystricmp */ + } /* for (hcptr...) */ + if (!collision) { /* No collision */ + hc->next = firsthc; + if (firsthc) + firsthc->last = hc; + hc->last = NULL; + firsthc = hc; + } + } /* while */ + } else + nohost = 1; + } + + /* IVc: Saving */ + if (!nohost) { + if ((f = open_db_write("HostServ", HOST_DB_NEW, 3))) { + HostCore *hcptr; + for (hcptr = firsthc; hcptr; hcptr = hcptr->next) { + SAFE(write_int8(1, f)); + SAFE(write_string(hcptr->nick, f)); + SAFE(write_string(hcptr->vIdent, f)); + SAFE(write_string(hcptr->vHost, f)); + SAFE(write_string(hcptr->creator, f)); + SAFE(write_int32(hcptr->time, f)); + } + SAFE(write_int8(0, f)); + close_db(f); + printf("Host merging done. New database saved as %s.\n", HOST_DB_NEW); + } + } /* End of section IV */ + + /* MERGING DONE \o/ HURRAY! */ + + printf("\n\nMerging is now done. I give NO guarantee for your DBs.\n"); + return 0; +} /* End of main() */ + +/* Open a database file for reading and check for the version */ +dbFILE *open_db_read(const char *service, const char *filename, int version) +{ + dbFILE *f; + FILE *fp; + int myversion; + + f = calloc(sizeof(*f), 1); + if (!f) { + printf("Can't allocate memory for %s database %s.\n", service, filename); + exit(0); + } + strscpy(f->filename, filename, sizeof(f->filename)); + f->mode = 'r'; + fp = fopen(f->filename, "rb"); + if (!fp) { + printf("Can't read %s database %s.\n", service, f->filename); + free(f); + return NULL; + } + f->fp = fp; + myversion = fgetc(fp) << 24 | fgetc(fp) << 16 | fgetc(fp) << 8 | fgetc(fp); + if (feof(fp)) { + printf("Error reading version number on %s: End of file detected.\n", f->filename); + exit(0); + } else if (myversion < version) { + printf("Unsuported database version (%d) on %s.\n", myversion, f->filename); + exit(0); + } + return f; +} + +/* Open a database file for reading and check for the version */ +dbFILE *open_db_write(const char *service, const char *filename, int version) +{ + dbFILE *f; + int fd; + + f = calloc(sizeof(*f), 1); + if (!f) { + printf("Can't allocate memory for %s database %s.\n", service, filename); + exit(0); + } + strscpy(f->filename, filename, sizeof(f->filename)); + filename = f->filename; +#ifndef _WIN32 + unlink(filename); +#else + DeleteFile(filename); +#endif + f->mode = 'w'; +#ifndef _WIN32 + fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0666); +#else + fd = open(filename, O_WRONLY | O_CREAT | O_EXCL | _O_BINARY, 0666); +#endif + f->fp = fdopen(fd, "wb"); /* will fail and return NULL if fd < 0 */ + if (!f->fp || !write_file_version(f, version)) { + printf("Can't write to %s database %s.\n", service, filename); + if (f->fp) { + fclose(f->fp); +#ifndef _WIN32 + unlink(filename); +#else + DeleteFile(filename); +#endif + } + free(f); + return NULL; + } + return f; +} + +/* Close it */ +void close_db(dbFILE * f) +{ + fclose(f->fp); + free(f); +} + +int read_int16(int16 * ret, dbFILE * f) +{ + int c1, c2; + + c1 = fgetc(f->fp); + c2 = fgetc(f->fp); + if (c1 == EOF || c2 == EOF) + return -1; + *ret = c1 << 8 | c2; + return 0; +} + +int read_uint16(uint16 * ret, dbFILE * f) +{ + int c1, c2; + + c1 = fgetc(f->fp); + c2 = fgetc(f->fp); + if (c1 == EOF || c2 == EOF) + return -1; + *ret = c1 << 8 | c2; + return 0; +} + + +int write_int16(uint16 val, dbFILE * f) +{ + if (fputc((val >> 8) & 0xFF, f->fp) == EOF + || fputc(val & 0xFF, f->fp) == EOF) + return -1; + return 0; +} + +int read_int32(int32 * ret, dbFILE * f) +{ + int c1, c2, c3, c4; + + c1 = fgetc(f->fp); + c2 = fgetc(f->fp); + c3 = fgetc(f->fp); + c4 = fgetc(f->fp); + if (c1 == EOF || c2 == EOF || c3 == EOF || c4 == EOF) + return -1; + *ret = c1 << 24 | c2 << 16 | c3 << 8 | c4; + return 0; +} + +int read_uint32(uint32 * ret, dbFILE * f) +{ + int c1, c2, c3, c4; + + c1 = fgetc(f->fp); + c2 = fgetc(f->fp); + c3 = fgetc(f->fp); + c4 = fgetc(f->fp); + if (c1 == EOF || c2 == EOF || c3 == EOF || c4 == EOF) + return -1; + *ret = c1 << 24 | c2 << 16 | c3 << 8 | c4; + return 0; +} + +int write_int32(uint32 val, dbFILE * f) +{ + if (fputc((val >> 24) & 0xFF, f->fp) == EOF) + return -1; + if (fputc((val >> 16) & 0xFF, f->fp) == EOF) + return -1; + if (fputc((val >> 8) & 0xFF, f->fp) == EOF) + return -1; + if (fputc((val) & 0xFF, f->fp) == EOF) + return -1; + return 0; +} + + +int read_ptr(void **ret, dbFILE * f) +{ + int c; + + c = fgetc(f->fp); + if (c == EOF) + return -1; + *ret = (c ? (void *) 1 : (void *) 0); + return 0; +} + +int write_ptr(const void *ptr, dbFILE * f) +{ + if (fputc(ptr ? 1 : 0, f->fp) == EOF) + return -1; + return 0; +} + + +int read_string(char **ret, dbFILE * f) +{ + char *s; + uint16 len; + + if (read_uint16(&len, f) < 0) + return -1; + if (len == 0) { + *ret = NULL; + return 0; + } + s = calloc(len, 1); + if (len != fread(s, 1, len, f->fp)) { + free(s); + return -1; + } + *ret = s; + return 0; +} + +int write_string(const char *s, dbFILE * f) +{ + uint32 len; + + if (!s) + return write_int16(0, f); + len = strlen(s); + if (len > 65534) + len = 65534; + if (write_int16((uint16) (len + 1), f) < 0) + return -1; + if (len > 0 && fwrite(s, 1, len, f->fp) != len) + return -1; + if (fputc(0, f->fp) == EOF) + return -1; + return 0; +} + +NickCore *findcore(const char *nick, int unused) +{ + NickCore *nc; + + for (nc = nclists[HASH(nick)]; nc; nc = nc->next) { + if (!mystricmp(nc->display, nick)) + if ((nc->unused && unused) || (!nc->unused && !unused)) + return nc; + } + + return NULL; +} + +NickAlias *findnick(const char *nick) +{ + NickAlias *na; + + for (na = nalists[HASH(nick)]; na; na = na->next) { + if (!mystricmp(na->nick, nick)) + return na; + } + + return NULL; +} + +int write_file_version(dbFILE * f, uint32 version) +{ + FILE *fp = f->fp; + if (fputc(version >> 24 & 0xFF, fp) < 0 || + fputc(version >> 16 & 0xFF, fp) < 0 || + fputc(version >> 8 & 0xFF, fp) < 0 || + fputc(version & 0xFF, fp) < 0) { + printf("Error writing version number on %s.\n", f->filename); + exit(0); + } + return 1; +} + +/* strscpy: Copy at most len-1 characters from a string to a buffer, and + * add a null terminator after the last character copied. + */ + +char *strscpy(char *d, const char *s, size_t len) +{ + char *d_orig = d; + + if (!len) + return d; + while (--len && (*d++ = *s++)); + *d = '\0'; + return d_orig; +} + +int mystricmp(const char *s1, const char *s2) +{ + register int c; + + while ((c = tolower(*s1)) == tolower(*s2)) { + if (c == 0) + return 0; + s1++; + s2++; + } + if (c < tolower(*s2)) + return -1; + return 1; +} + +int delnick(NickAlias *na, int donttouchthelist) +{ + if (!donttouchthelist) { + /* Remove us from the aliases list */ + if (na->next) + na->next->prev = na->prev; + if (na->prev) + na->prev->next = na->next; + else + nalists[HASH(na->nick)] = na->next; + } + + /* free() us */ + free(na->nick); + if (na->last_usermask) + free(na->last_usermask); + if (na->last_realname) + free(na->last_realname); + if (na->last_quit) + free(na->last_quit); + free(na); + return 1; +} + +int delcore(NickCore *nc) +{ + int i; + /* Remove the core from the list */ + if (nc->next) + nc->next->prev = nc->prev; + if (nc->prev) + nc->prev->next = nc->next; + else + nclists[HASH(nc->display)] = nc->next; + + free(nc->display); + if (nc->email) + free(nc->email); + if (nc->greet) + free(nc->greet); + if (nc->url) + free(nc->url); + if (nc->access) { + for (i = 0; i < nc->accesscount; i++) { + if (nc->access[i]) + free(nc->access[i]); + } + free(nc->access); + } + if (nc->memos.memos) { + for (i = 0; i < nc->memos.memocount; i++) { + if (nc->memos.memos[i].text) + free(nc->memos.memos[i].text); + } + free(nc->memos.memos); + } + free(nc); + return 1; +} + +void insert_bot(BotInfo * bi) +{ + BotInfo *ptr, *prev; + + for (prev = NULL, ptr = botlists[tolower(*bi->nick)]; + ptr != NULL && mystricmp(ptr->nick, bi->nick) < 0; + prev = ptr, ptr = ptr->next); + bi->prev = prev; + bi->next = ptr; + if (!prev) + botlists[tolower(*bi->nick)] = bi; + else + prev->next = bi; + if (ptr) + ptr->prev = bi; +} + +BotInfo *findbot(char *nick) +{ + BotInfo *bi; + + for (bi = botlists[tolower(*nick)]; bi; bi = bi->next) + if (!mystricmp(nick, bi->nick)) + return bi; + + return NULL; +} + +ChannelInfo *cs_findchan(const char *chan) +{ + ChannelInfo *ci; + for (ci = chanlists[tolower(chan[1])]; ci; ci = ci->next) { + if (!mystricmp(ci->name, chan)) + return ci; + } + return NULL; +} + +void alpha_insert_chan(ChannelInfo * ci) +{ + ChannelInfo *ptr, *prev; + char *chan = ci->name; + + for (prev = NULL, ptr = chanlists[tolower(chan[1])]; + ptr != NULL && mystricmp(ptr->name, chan) < 0; + prev = ptr, ptr = ptr->next); + ci->prev = prev; + ci->next = ptr; + if (!prev) + chanlists[tolower(chan[1])] = ci; + else + prev->next = ci; + if (ptr) + ptr->prev = ci; +} + diff --git a/src/tools/epona2anope.c b/src/tools/epona2anope.c new file mode 100644 index 000000000..d89be6d12 --- /dev/null +++ b/src/tools/epona2anope.c @@ -0,0 +1,856 @@ +/* + * IRC - Internet Relay Chat, epona2anope.c + * (C) Copyright 2005-2006, Florian Schulze (Certus) + * + * Based on the original code of Anope, (C) 2003-2005 Anope Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License (see it online + * at http://www.gnu.org/copyleft/gpl.html) as published by the Free + * Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This program tries to convert epona-1.4.15+ dbs to anope standard dbs. + * At the moment this only affects chanserv dbs. + * + * - Certus + * February 26, 2005 + * + * Added win32 fix. Who needs that anyways? :P + * - Certus + * July 20, 2006 + */ + + +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <fcntl.h> +#include <ctype.h> +#include <time.h> + +#ifndef _WIN32 +#include <unistd.h> +#else +#include "sysconf.h" +#include <windows.h> +#endif + +/* Some SUN fixs */ +#ifdef __sun +/* Solaris specific code, types that do not exist in Solaris' + * * sys/types.h + * **/ +#undef u_int8_t +#undef u_int16_t +#undef u_int32_t +#undef u_int_64_t +#define u_int8_t uint8_t +#define u_int16_t uint16_t +#define u_int32_t uint32_t +#define u_int64_t uint64_t + +#ifndef INADDR_NONE +#define INADDR_NONE (-1) +#endif + +#endif + + +/* CONFIGURATION BLOCK */ + +#define CHAN_DB_EPONA "chan1.db" +#define CHAN_DB_ANOPE "chan.db" + +/* END OF CONFIGURATION BLOCK */ + +#ifndef _WIN32 +#define C_LBLUE "\033[1;34m" +#define C_NONE "\033[m" +#else +#define C_LBLUE "" +#define C_NONE "" +#endif + +#define getc_db(f) (fgetc((f)->fp)) +#define HASH(nick) ((tolower((nick)[0])&31)<<5 | (tolower((nick)[1])&31)) +#define HASH2(chan) ((chan)[1] ? ((chan)[1]&31)<<5 | ((chan)[2]&31) : 0) +#define read_buffer(buf,f) (read_db((f),(buf),sizeof(buf)) == sizeof(buf)) +#define write_buffer(buf,f) (write_db((f),(buf),sizeof(buf)) == sizeof(buf)) +#define read_db(f,buf,len) (fread((buf),1,(len),(f)->fp)) +#define write_db(f,buf,len) (fwrite((buf),1,(len),(f)->fp)) +#define read_int8(ret,f) ((*(ret)=fgetc((f)->fp))==EOF ? -1 : 0) +#define write_int8(val,f) (fputc((val),(f)->fp)==EOF ? -1 : 0) +#define SAFE(x) do { \ + if ((x) < 0) { \ + printf("Error, the database is broken, trying to continue... no guarantee.\n"); \ + } \ +} while (0) +#define READ(x) do { \ + if ((x) < 0) { \ + printf("Error, the database is broken, trying to continue... no guarantee.\n"); \ + exit(0); \ + } \ +} while (0) + +typedef int16_t int16; +typedef u_int16_t uint16; +typedef int32_t int32; +typedef u_int32_t uint32; +typedef struct memo_ Memo; +typedef struct dbFILE_ dbFILE; +typedef struct nickalias_ NickAlias; +typedef struct nickcore_ NickCore; +typedef struct chaninfo_ ChannelInfo; +typedef struct botinfo_ BotInfo; +typedef struct badword_ BadWord; +typedef struct hostcore_ HostCore; + +struct memo_ { + uint32 number; /* Index number -- not necessarily array position! */ + int16 flags; /* Flags */ + time_t time; /* When was it sent? */ + char sender[32]; /* Name of the sender */ + char *text; +}; + +struct dbFILE_ { + int mode; /* 'r' for reading, 'w' for writing */ + FILE *fp; /* The normal file descriptor */ + char filename[1024]; /* Name of the database file */ +}; + +typedef struct { + int16 memocount; /* Current # of memos */ + int16 memomax; /* Max # of memos one can hold*/ + Memo *memos; /* Pointer to original memos */ +} MemoInfo; + +typedef struct { + int16 in_use; /* 1 if this entry is in use, else 0 */ + int16 level; + NickCore *nc; /* Guaranteed to be non-NULL if in use, NULL if not */ + time_t last_seen; +} ChanAccess; + +typedef struct { + int16 in_use; /* Always 0 if not in use */ + int16 is_nick; /* 1 if a regged nickname, 0 if a nick!user@host mask */ + int16 flags; + union { + char *mask; /* Guaranteed to be non-NULL if in use, NULL if not */ + NickCore *nc; /* Same */ + } u; + char *reason; + char *creator; + time_t addtime; +} AutoKick; + +struct nickcore_ { + NickCore *next, *prev; + + char *display; /* How the nick is displayed */ + int unused; /* Used for nick collisions */ +}; + +struct chaninfo_ { + ChannelInfo *next, *prev; + + char name[64]; /* Channel name */ + char *founder; /* Who registered the channel */ + char *successor; /* Who gets the channel if the founder nick is dropped or expires */ + char founderpass[32]; /* Channel password */ + char *desc; /* Description */ + char *url; /* URL */ + char *email; /* Email address */ + time_t time_registered; /* When was it registered */ + time_t last_used; /* When was it used hte last time */ + char *last_topic; /* Last topic on the channel */ + char last_topic_setter[32]; /* Who set the last topic */ + time_t last_topic_time; /* When the last topic was set */ + uint32 flags; /* Flags */ + char *forbidby; /* if forbidden: who did it */ + char *forbidreason; /* if forbidden: why */ + int16 bantype; /* Bantype */ + int16 *levels; /* Access levels for commands */ + int16 accesscount; /* # of pple with access */ + ChanAccess *access; /* List of authorized users */ + int16 akickcount; /* # of akicked pple */ + AutoKick *akick; /* List of users to kickban */ + uint32 mlock_on, mlock_off; /* See channel modes below */ + uint32 mlock_limit; /* 0 if no limit */ + char *mlock_key; /* NULL if no key */ + char *mlock_flood; /* NULL if no +f */ + char *mlock_joinrate; /* NULL if no +j */ + char *mlock_redirect; /* NULL if no +L */ + char *entry_message; /* Notice sent on entering channel */ + MemoInfo memos; /* Memos */ + char *bi; /* Bot used on this channel */ + uint32 botflags; /* BS_* below */ + int16 *ttb; /* Times to ban for each kicker */ + int16 bwcount; /* Badword count */ + BadWord *badwords; /* For BADWORDS kicker */ + int16 capsmin, capspercent; /* For CAPS kicker */ + int16 floodlines, floodsecs; /* For FLOOD kicker */ + int16 repeattimes; /* For REPEAT kicker */ +}; + +struct botinfo_ { + BotInfo *next, *prev; + char *nick; /* Nickname of the bot */ + char *user; /* Its user name */ + char *host; /* Its hostname */ + char *real; /* Its real name */ + int16 flags; /* Bot flags */ + time_t created; /* Birth date */ + int16 chancount; /* Number of channels that use the bot. */ +}; + +struct badword_ { + int16 in_use; + char *word; + int16 type; +}; + +dbFILE *open_db_write(const char *service, const char *filename, int version); +dbFILE *open_db_read(const char *service, const char *filename, int version); +NickCore *findcore(const char *nick, int version); +ChannelInfo *cs_findchan(const char *chan); +char *strscpy(char *d, const char *s, size_t len); +int write_file_version(dbFILE * f, uint32 version); +int mystricmp(const char *s1, const char *s2); +int write_string(const char *s, dbFILE * f); +int write_ptr(const void *ptr, dbFILE * f); +int read_int16(int16 * ret, dbFILE * f); +int read_uint16(uint16 * ret, dbFILE * f); +int read_int32(int32 * ret, dbFILE * f); +int read_uint32(uint32 * ret, dbFILE * f); +int read_string(char **ret, dbFILE * f); +int write_int16(uint16 val, dbFILE * f); +int write_int32(uint32 val, dbFILE * f); +int read_ptr(void **ret, dbFILE * f); +void alpha_insert_chan(ChannelInfo * ci); +void close_db(dbFILE * f); + +ChannelInfo *chanlists[256]; +NickCore *nclists[1024]; + +int main(int argc, char *argv[]) +{ + dbFILE *f; + int i; + long countr = 0, countw = 0; + /* Unused variables - why? -GD + NickCore *nc, *ncnext; + */ + + printf("\n"C_LBLUE"Epona to Anope DB converter by Certus"C_NONE"\n\n"); + + /* Section I: Reading */ + if ((f = open_db_read("ChanServ", CHAN_DB_EPONA, 17))) { + ChannelInfo *ci, **last, *prev; + int c; + + printf("Trying to convert channel database...\n"); + + for (i = 0; i < 256; i++) { + int16 tmp16; + int32 tmp32; + int n_levels; + char *s; + int n_ttb; + /* Unused variable - why? -GD + int J; + */ + + last = &chanlists[i]; + prev = NULL; + + while ((c = getc_db(f)) == 1) { + int j; + + if (c != 1) { + printf("Invalid format in %s.\n", CHAN_DB_EPONA); + exit(0); + } + + ci = calloc(sizeof(ChannelInfo), 1); + *last = ci; + last = &ci->next; + ci->prev = prev; + prev = ci; + READ(read_buffer(ci->name, f)); + READ(read_string(&ci->founder, f)); + READ(read_string(&ci->successor, f)); + READ(read_buffer(ci->founderpass, f)); + READ(read_string(&ci->desc, f)); + if (!ci->desc) + ci->desc = strdup(""); + READ(read_string(&ci->url, f)); + READ(read_string(&ci->email, f)); + READ(read_int32(&tmp32, f)); + ci->time_registered = tmp32; + READ(read_int32(&tmp32, f)); + ci->last_used = tmp32; + READ(read_string(&ci->last_topic, f)); + READ(read_buffer(ci->last_topic_setter, f)); + READ(read_int32(&tmp32, f)); + ci->last_topic_time = tmp32; + READ(read_uint32(&ci->flags, f)); + /* Temporary flags cleanup */ + ci->flags &= ~0x80000000; + READ(read_string(&ci->forbidby, f)); + READ(read_string(&ci->forbidreason, f)); + READ(read_int16(&tmp16, f)); + ci->bantype = tmp16; + READ(read_int16(&tmp16, f)); + n_levels = tmp16; + ci->levels = calloc(36 * sizeof(*ci->levels), 1); + for (j = 0; j < n_levels; j++) { + if (j < 36) + READ(read_int16(&ci->levels[j], f)); + else + READ(read_int16(&tmp16, f)); + } + READ(read_int16(&ci->accesscount, f)); + if (ci->accesscount) { + ci->access = calloc(ci->accesscount, sizeof(ChanAccess)); + for (j = 0; j < ci->accesscount; j++) { + READ(read_int16(&ci->access[j].in_use, f)); + if (ci->access[j].in_use) { + READ(read_int16(&ci->access[j].level, f)); + READ(read_string(&s, f)); + if (s) { + ci->access[j].nc = findcore(s, 0); + free(s); + } + if (ci->access[j].nc == NULL) + ci->access[j].in_use = 0; + READ(read_int32(&tmp32, f)); + ci->access[j].last_seen = tmp32; + } + } + } else { + ci->access = NULL; + } + READ(read_int16(&ci->akickcount, f)); + if (ci->akickcount) { + ci->akick = calloc(ci->akickcount, sizeof(AutoKick)); + for (j = 0; j < ci->akickcount; j++) { + SAFE(read_int16(&ci->akick[j].flags, f)); + if (ci->akick[j].flags & 0x0001) { + SAFE(read_string(&s, f)); + if (ci->akick[j].flags & 0x0002) { + ci->akick[j].u.nc = findcore(s, 0); + if (!ci->akick[j].u.nc) + ci->akick[j].flags &= ~0x0001; + free(s); + } else { + ci->akick[j].u.mask = s; + } + SAFE(read_string(&s, f)); + if (ci->akick[j].flags & 0x0001) + ci->akick[j].reason = s; + else if (s) + free(s); + SAFE(read_string(&s, f)); + if (ci->akick[j].flags & 0x0001) { + ci->akick[j].creator = s; + } else if (s) { + free(s); + } + SAFE(read_int32(&tmp32, f)); + if (ci->akick[j].flags & 0x0001) + ci->akick[j].addtime = tmp32; + } + } + } else { + ci->akick = NULL; + } + READ(read_uint32(&ci->mlock_on, f)); + READ(read_uint32(&ci->mlock_off, f)); + READ(read_uint32(&ci->mlock_limit, f)); + READ(read_string(&ci->mlock_key, f)); + READ(read_string(&ci->mlock_flood, f)); + READ(read_string(&ci->mlock_joinrate, f)); + READ(read_string(&ci->mlock_redirect, f)); + READ(read_int16(&ci->memos.memocount, f)); + READ(read_int16(&ci->memos.memomax, f)); + if (ci->memos.memocount) { + Memo *memos; + memos = calloc(sizeof(Memo) * ci->memos.memocount, 1); + ci->memos.memos = memos; + for (j = 0; j < ci->memos.memocount; j++, memos++) { + READ(read_uint32(&memos->number, f)); + READ(read_int16(&memos->flags, f)); + READ(read_int32(&tmp32, f)); + memos->time = tmp32; + READ(read_buffer(memos->sender, f)); + READ(read_string(&memos->text, f)); + } + } + READ(read_string(&ci->entry_message, f)); + + /* BotServ options */ + READ(read_string(&ci->bi, f)); + READ(read_int32(&tmp32, f)); + ci->botflags = tmp32; + READ(read_int16(&tmp16, f)); + n_ttb = tmp16; + ci->ttb = calloc(2 * 8, 1); + for (j = 0; j < n_ttb; j++) { + if (j < 8) + READ(read_int16(&ci->ttb[j], f)); + else + READ(read_int16(&tmp16, f)); + } + for (j = n_ttb; j < 8; j++) + ci->ttb[j] = 0; + READ(read_int16(&tmp16, f)); + ci->capsmin = tmp16; + READ(read_int16(&tmp16, f)); + ci->capspercent = tmp16; + READ(read_int16(&tmp16, f)); + ci->floodlines = tmp16; + READ(read_int16(&tmp16, f)); + ci->floodsecs = tmp16; + READ(read_int16(&tmp16, f)); + ci->repeattimes = tmp16; + + READ(read_int16(&ci->bwcount, f)); + if (ci->bwcount) { + ci->badwords = calloc(ci->bwcount, sizeof(BadWord)); + for (j = 0; j < ci->bwcount; j++) { + SAFE(read_int16(&ci->badwords[j].in_use, f)); + if (ci->badwords[j].in_use) { + SAFE(read_string(&ci->badwords[j].word, f)); + SAFE(read_int16(&ci->badwords[j].type, f)); + } + } + } else { + ci->badwords = NULL; + } + countr++; + } /* getc_db() */ + *last = NULL; + } /* for() loop */ + close_db(f); + } + + /* II: Saving */ + { + if ((f = open_db_write("ChanServ", CHAN_DB_ANOPE, 16))) { + ChannelInfo *ci; + Memo *memos; + /* Unused variable - why? -GD + static time_t lastwarn = 0; + */ + + for (i = 0; i < 256; i++) { + int16 tmp16; + for (ci = chanlists[i]; ci; ci = ci->next) { + int j; + SAFE(write_int8(1, f)); + SAFE(write_buffer(ci->name, f)); + if (ci->founder) + SAFE(write_string(ci->founder, f)); + else + SAFE(write_string(NULL, f)); + if (ci->successor) + SAFE(write_string(ci->successor, f)); + else + SAFE(write_string(NULL, f)); + SAFE(write_buffer(ci->founderpass, f)); + SAFE(write_string(ci->desc, f)); + SAFE(write_string(ci->url, f)); + SAFE(write_string(ci->email, f)); + SAFE(write_int32(ci->time_registered, f)); + SAFE(write_int32(ci->last_used, f)); + SAFE(write_string(ci->last_topic, f)); + SAFE(write_buffer(ci->last_topic_setter, f)); + SAFE(write_int32(ci->last_topic_time, f)); + SAFE(write_int32(ci->flags, f)); + SAFE(write_string(ci->forbidby, f)); + SAFE(write_string(ci->forbidreason, f)); + SAFE(write_int16(ci->bantype, f)); + tmp16 = 36; + SAFE(write_int16(tmp16, f)); + for (j = 0; j < 36; j++) + SAFE(write_int16(ci->levels[j], f)); + + SAFE(write_int16(ci->accesscount, f)); + for (j = 0; j < ci->accesscount; j++) { + SAFE(write_int16(ci->access[j].in_use, f)); + if (ci->access[j].in_use) { + SAFE(write_int16(ci->access[j].level, f)); + SAFE(write_string(ci->access[j].nc->display, f)); + SAFE(write_int32(ci->access[j].last_seen, f)); + } + } + SAFE(write_int16(ci->akickcount, f)); + for (j = 0; j < ci->akickcount; j++) { + SAFE(write_int16(ci->akick[j].flags, f)); + if (ci->akick[j].flags & 0x0001) { + if (ci->akick[j].flags & 0x0002) + SAFE(write_string(ci->akick[j].u.nc->display, f)); + else + SAFE(write_string(ci->akick[j].u.mask, f)); + SAFE(write_string(ci->akick[j].reason, f)); + SAFE(write_string(ci->akick[j].creator, f)); + SAFE(write_int32(ci->akick[j].addtime, f)); + } + } + + SAFE(write_int32(ci->mlock_on, f)); + SAFE(write_int32(ci->mlock_off, f)); + SAFE(write_int32(ci->mlock_limit, f)); + SAFE(write_string(ci->mlock_key, f)); + SAFE(write_string(ci->mlock_flood, f)); + SAFE(write_string(ci->mlock_redirect, f)); + SAFE(write_int16(ci->memos.memocount, f)); + SAFE(write_int16(ci->memos.memomax, f)); + memos = ci->memos.memos; + for (j = 0; j < ci->memos.memocount; j++, memos++) { + SAFE(write_int32(memos->number, f)); + SAFE(write_int16(memos->flags, f)); + SAFE(write_int32(memos->time, f)); + SAFE(write_buffer(memos->sender, f)); + SAFE(write_string(memos->text, f)); + } + SAFE(write_string(ci->entry_message, f)); + if (ci->bi) + SAFE(write_string(ci->bi, f)); + else + SAFE(write_string(NULL, f)); + SAFE(write_int32(ci->botflags, f)); + tmp16 = 8; + SAFE(write_int16(tmp16, f)); + for (j = 0; j < 8; j++) + SAFE(write_int16(ci->ttb[j], f)); + SAFE(write_int16(ci->capsmin, f)); + SAFE(write_int16(ci->capspercent, f)); + SAFE(write_int16(ci->floodlines, f)); + SAFE(write_int16(ci->floodsecs, f)); + SAFE(write_int16(ci->repeattimes, f)); + + SAFE(write_int16(ci->bwcount, f)); + for (j = 0; j < ci->bwcount; j++) { + SAFE(write_int16(ci->badwords[j].in_use, f)); + if (ci->badwords[j].in_use) { + SAFE(write_string(ci->badwords[j].word, f)); + SAFE(write_int16(ci->badwords[j].type, f)); + } + } + countw++; + } /* for (chanlists[i]) */ + SAFE(write_int8(0, f)); + } /* for (i) */ + close_db(f); + printf("%ld channels read, %ld channels written. New database saved as %s.\n", countr, countw, CHAN_DB_ANOPE); + } + } + + printf("\n\nConverting is now done.\n"); + return 0; +} /* End of main() */ + +/* Open a database file for reading and check for the version */ +dbFILE *open_db_read(const char *service, const char *filename, int version) +{ + dbFILE *f; + FILE *fp; + int myversion; + + f = calloc(sizeof(*f), 1); + if (!f) { + printf("Can't allocate memory for %s database %s.\n", service, filename); + exit(0); + } + strscpy(f->filename, filename, sizeof(f->filename)); + f->mode = 'r'; + fp = fopen(f->filename, "rb"); + if (!fp) { + printf("Can't read %s database %s.\n", service, f->filename); + free(f); + return NULL; + } + f->fp = fp; + myversion = fgetc(fp) << 24 | fgetc(fp) << 16 | fgetc(fp) << 8 | fgetc(fp); + if (feof(fp)) { + printf("Error reading version number on %s: End of file detected.\n", f->filename); + exit(0); + } else if (myversion < version) { + printf("Unsuported database version (%d) on %s.\n", myversion, f->filename); + exit(0); + } + return f; +} + +/* Open a database file for reading and check for the version */ +dbFILE *open_db_write(const char *service, const char *filename, int version) +{ + dbFILE *f; + int fd; + + f = calloc(sizeof(*f), 1); + if (!f) { + printf("Can't allocate memory for %s database %s.\n", service, filename); + exit(0); + } + strscpy(f->filename, filename, sizeof(f->filename)); + filename = f->filename; +#ifndef _WIN32 + unlink(filename); +#else + DeleteFile(filename); +#endif + f->mode = 'w'; +#ifndef _WIN32 + fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0666); +#else + fd = open(filename, O_WRONLY | O_CREAT | O_EXCL | _O_BINARY, 0666); +#endif + f->fp = fdopen(fd, "wb"); /* will fail and return NULL if fd < 0 */ + if (!f->fp || !write_file_version(f, version)) { + printf("Can't write to %s database %s.\n", service, filename); + if (f->fp) { + fclose(f->fp); +#ifndef _WIN32 + unlink(filename); +#else + DeleteFile(filename); +#endif + } + free(f); + return NULL; + } + return f; +} + +/* Close it */ +void close_db(dbFILE * f) +{ + fclose(f->fp); + free(f); +} + +int read_int16(int16 * ret, dbFILE * f) +{ + int c1, c2; + + c1 = fgetc(f->fp); + c2 = fgetc(f->fp); + if (c1 == EOF || c2 == EOF) + return -1; + *ret = c1 << 8 | c2; + return 0; +} + +int read_uint16(uint16 * ret, dbFILE * f) +{ + int c1, c2; + + c1 = fgetc(f->fp); + c2 = fgetc(f->fp); + if (c1 == EOF || c2 == EOF) + return -1; + *ret = c1 << 8 | c2; + return 0; +} + +int write_int16(uint16 val, dbFILE * f) +{ + if (fputc((val >> 8) & 0xFF, f->fp) == EOF + || fputc(val & 0xFF, f->fp) == EOF) + return -1; + return 0; +} + + +int read_int32(int32 * ret, dbFILE * f) +{ + int c1, c2, c3, c4; + + c1 = fgetc(f->fp); + c2 = fgetc(f->fp); + c3 = fgetc(f->fp); + c4 = fgetc(f->fp); + if (c1 == EOF || c2 == EOF || c3 == EOF || c4 == EOF) + return -1; + *ret = c1 << 24 | c2 << 16 | c3 << 8 | c4; + return 0; +} + +int read_uint32(uint32 * ret, dbFILE * f) +{ + int c1, c2, c3, c4; + + c1 = fgetc(f->fp); + c2 = fgetc(f->fp); + c3 = fgetc(f->fp); + c4 = fgetc(f->fp); + if (c1 == EOF || c2 == EOF || c3 == EOF || c4 == EOF) + return -1; + *ret = c1 << 24 | c2 << 16 | c3 << 8 | c4; + return 0; +} + +int write_int32(uint32 val, dbFILE * f) +{ + if (fputc((val >> 24) & 0xFF, f->fp) == EOF) + return -1; + if (fputc((val >> 16) & 0xFF, f->fp) == EOF) + return -1; + if (fputc((val >> 8) & 0xFF, f->fp) == EOF) + return -1; + if (fputc((val) & 0xFF, f->fp) == EOF) + return -1; + return 0; +} + + +int read_ptr(void **ret, dbFILE * f) +{ + int c; + + c = fgetc(f->fp); + if (c == EOF) + return -1; + *ret = (c ? (void *) 1 : (void *) 0); + return 0; +} + +int write_ptr(const void *ptr, dbFILE * f) +{ + if (fputc(ptr ? 1 : 0, f->fp) == EOF) + return -1; + return 0; +} + + +int read_string(char **ret, dbFILE * f) +{ + char *s; + uint16 len; + + if (read_uint16(&len, f) < 0) + return -1; + if (len == 0) { + *ret = NULL; + return 0; + } + s = calloc(len, 1); + if (len != fread(s, 1, len, f->fp)) { + free(s); + return -1; + } + *ret = s; + return 0; +} + +int write_string(const char *s, dbFILE * f) +{ + uint32 len; + + if (!s) + return write_int16(0, f); + len = strlen(s); + if (len > 65534) + len = 65534; + if (write_int16((uint16) (len + 1), f) < 0) + return -1; + if (len > 0 && fwrite(s, 1, len, f->fp) != len) + return -1; + if (fputc(0, f->fp) == EOF) + return -1; + return 0; +} + +NickCore *findcore(const char *nick, int unused) +{ + NickCore *nc; + + for (nc = nclists[HASH(nick)]; nc; nc = nc->next) { + if (!mystricmp(nc->display, nick)) + if ((nc->unused && unused) || (!nc->unused && !unused)) + return nc; + } + + return NULL; +} + +int write_file_version(dbFILE * f, uint32 version) +{ + FILE *fp = f->fp; + if (fputc(version >> 24 & 0xFF, fp) < 0 || + fputc(version >> 16 & 0xFF, fp) < 0 || + fputc(version >> 8 & 0xFF, fp) < 0 || + fputc(version & 0xFF, fp) < 0) { + printf("Error writing version number on %s.\n", f->filename); + exit(0); + } + return 1; +} + +/* strscpy: Copy at most len-1 characters from a string to a buffer, and + * add a null terminator after the last character copied. + */ + +char *strscpy(char *d, const char *s, size_t len) +{ + char *d_orig = d; + + if (!len) + return d; + while (--len && (*d++ = *s++)); + *d = '\0'; + return d_orig; +} + +int mystricmp(const char *s1, const char *s2) +{ + register int c; + + while ((c = tolower(*s1)) == tolower(*s2)) { + if (c == 0) + return 0; + s1++; + s2++; + } + if (c < tolower(*s2)) + return -1; + return 1; +} + +ChannelInfo *cs_findchan(const char *chan) +{ + ChannelInfo *ci; + for (ci = chanlists[tolower(chan[1])]; ci; ci = ci->next) { + if (!mystricmp(ci->name, chan)) + return ci; + } + return NULL; +} + +void alpha_insert_chan(ChannelInfo * ci) +{ + ChannelInfo *ptr, *prev; + char *chan = ci->name; + + for (prev = NULL, ptr = chanlists[tolower(chan[1])]; + ptr != NULL && mystricmp(ptr->name, chan) < 0; + prev = ptr, ptr = ptr->next); + ci->prev = prev; + ci->next = ptr; + if (!prev) + chanlists[tolower(chan[1])] = ci; + else + prev->next = ci; + if (ptr) + ptr->prev = ci; +} + diff --git a/src/tools/smtp.h b/src/tools/smtp.h new file mode 100644 index 000000000..7a30cc0fe --- /dev/null +++ b/src/tools/smtp.h @@ -0,0 +1,130 @@ +/* + * + * (C) 2003-2008 Anope Team + * Contact us at info@anope.org + * + * Please read COPYING and README for furhter details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + * + * + */ + +#ifndef SMTP_H +#define SMTP_H + +/*************************************************************************/ + +/* Some Linux boxes (or maybe glibc includes) require this for the + * prototype of strsignal(). */ +#define _GNU_SOURCE + +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +/* Windows does not have: + * unistd.h, grp.h, + * netdb.h, netinet/in.h, + * sys/socket.h, sys/time.h + * Windows requires: + * winsock.h + * -- codemastr + */ + +#ifndef _WIN32 +#include <unistd.h> +#endif + +#include <signal.h> +#include <time.h> +#include <errno.h> +#include <limits.h> + +#ifndef _WIN32 +#include <netdb.h> +#include <netinet/in.h> +#include <sys/socket.h> +#include <arpa/inet.h> +#else +#include <winsock.h> +#include <windows.h> +#endif + +#include <sys/types.h> + +#ifndef _WIN32 +#include <sys/time.h> +#endif + +#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 +#define PATH_MAX MAX_PATH +#define snprintf _snprintf +#endif + + +/*************************************************************************/ + +#ifdef _WIN32 +#include <winsock.h> +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_header { + char *header; + struct smtp_header *next; +}; + +struct smtp_body_line { + char *line; + struct smtp_body_line *next; +}; + +struct smtp_message { + struct smtp_header *smtp_headers, *smtp_headers_tail; + struct smtp_body_line *smtp_body, *smtp_body_tail; + char *from; + char *to; + ano_socket_t sock; +}; + +struct smtp_message mail; + +/* set this to 1 if you want to get a log otherwise it runs silent */ +int smtp_debug = 0; + +#endif /* SMTP_H */ |